Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@effect/platform-node-shared": "catalog:",
"@effect/sql-sqlite-bun": "catalog:",
"@ff-labs/fff-node": "0.9.4",
"@opencode-ai/client": "0.0.0-beta-18155",
"@opencode-ai/sdk": "^1.3.15",
"@pierre/diffs": "catalog:",
"effect": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ describe("runtimeEventToActivities approval details", () => {
expect((activity?.payload as Record<string, unknown> | undefined)?.detail).toBe(detail);
});

it("keeps OpenCode v2 project-wide approval choices available to every client", () => {
const options = [
{ decision: "decline", label: "Decline" },
{ decision: "acceptAlways", label: "Always allow this project" },
{ decision: "accept", label: "Allow once" },
] as const;
const event = {
type: "request.opened",
eventId: EventId.make("evt-opencode-approval"),
provider: ProviderDriverKind.make("opencode"),
createdAt: "2026-08-25T00:00:00.000Z",
threadId: ThreadId.make("thread-opencode"),
requestId: RuntimeRequestId.make("approval-opencode"),
payload: {
requestType: "command_execution_approval",
detail: "git status",
options,
},
} satisfies ProviderRuntimeEvent;

const [activity] = runtimeEventToActivities(event);

expect(activity).toMatchObject({
kind: "approval.requested",
payload: {
requestId: "approval-opencode",
requestKind: "command",
options,
},
});
});

it("keeps app details and approval options available to remote clients", () => {
const options = [
{ decision: "decline", label: "Decline" },
Expand Down
22 changes: 21 additions & 1 deletion apps/server/src/provider/Drivers/OpenCodeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import type { ServerProviderDraft } from "../providerSnapshot.ts";
import { mergeProviderInstanceEnvironment } from "../ProviderInstanceEnvironment.ts";
import {
enrichProviderSnapshotWithVersionAdvisory,
makeManualOnlyProviderMaintenanceCapabilities,
makePackageManagedProviderMaintenanceResolver,
normalizeCommandPath,
resolveProviderMaintenanceCapabilitiesEffect,
Expand All @@ -64,7 +65,7 @@ function isOpenCodeNativeCommandPath(commandPath: string): boolean {
);
}

const UPDATE = makePackageManagedProviderMaintenanceResolver({
const LEGACY_UPDATE = makePackageManagedProviderMaintenanceResolver({
provider: DRIVER_KIND,
npmPackageName: "opencode-ai",
homebrewFormula: "anomalyco/tap/opencode",
Expand All @@ -76,6 +77,25 @@ const UPDATE = makePackageManagedProviderMaintenanceResolver({
},
});

const UPDATE = {
resolve(options?: Parameters<typeof LEGACY_UPDATE.resolve>[0]) {
const paths = [options?.binaryPath, options?.resolvedCommandPath, options?.realCommandPath];
const isOpenCodeV2 = paths.some(
(commandPath) =>
typeof commandPath === "string" &&
/(?:^|\/)opencode2(?:\.(?:cmd|bat|exe))?$/.test(normalizeCommandPath(commandPath)),
);
const isUnresolvedDefault =
options?.binaryPath === "opencode" &&
!options.resolvedCommandPath &&
!options.realCommandPath;

return isOpenCodeV2 || isUnresolvedDefault
? makeManualOnlyProviderMaintenanceCapabilities({ provider: DRIVER_KIND, packageName: null })
: LEGACY_UPDATE.resolve(options);
},
};

export type OpenCodeDriverEnv =
| BackgroundPolicy.BackgroundPolicy
| ChildProcessSpawner.ChildProcessSpawner
Expand Down
Loading
Loading