(input: {
sdk: OpencodeClient
connection?: ServiceConnection
directory?: Directory.Interface
session?: ACPSession.Interface
usage?: UsageService.Interface
eventSubscription?: (subscription: ACPEvent.Subscription) => void
})
| 73 | export class Service extends Context.Service<Service, Interface>()("@opencode/ACP/Service") {} |
| 74 | |
| 75 | export function make(input: { |
| 76 | sdk: OpencodeClient |
| 77 | connection?: ServiceConnection |
| 78 | directory?: Directory.Interface |
| 79 | session?: ACPSession.Interface |
| 80 | usage?: UsageService.Interface |
| 81 | eventSubscription?: (subscription: ACPEvent.Subscription) => void |
| 82 | }): Interface { |
| 83 | const session = input.session ?? makeSessionService() |
| 84 | const directoryService = input.directory ?? makeDirectoryService(input.sdk) |
| 85 | const registeredMcp = new Map<string, Set<string>>() |
| 86 | const sessionSnapshots = new Map<string, Directory.Snapshot>() |
| 87 | const events = input.connection |
| 88 | ? ACPEvent.start({ sdk: input.sdk, connection: input.connection, session }) |
| 89 | : undefined |
| 90 | if (events) input.eventSubscription?.(events) |
| 91 | |
| 92 | const initialize = Effect.fn("ACP.initialize")(function* (params: InitializeRequest) { |
| 93 | const started = performance.now() |
| 94 | const authMethod: AuthMethod = { |
| 95 | description: "Run `opencode auth login` in the terminal", |
| 96 | name: "Login with opencode", |
| 97 | id: AuthMethodID, |
| 98 | } |
| 99 | |
| 100 | if (params.clientCapabilities?._meta?.["terminal-auth"] === true) { |
| 101 | authMethod._meta = { |
| 102 | "terminal-auth": { |
| 103 | command: "opencode", |
| 104 | args: ["auth", "login"], |
| 105 | label: "OpenCode Login", |
| 106 | }, |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | const response = { |
| 111 | protocolVersion: 1, |
| 112 | agentCapabilities: { |
| 113 | loadSession: true, |
| 114 | mcpCapabilities: { |
| 115 | http: true, |
| 116 | sse: true, |
| 117 | }, |
| 118 | promptCapabilities: { |
| 119 | embeddedContext: true, |
| 120 | image: true, |
| 121 | }, |
| 122 | sessionCapabilities: { |
| 123 | close: {}, |
| 124 | fork: {}, |
| 125 | list: {}, |
| 126 | resume: {}, |
| 127 | }, |
| 128 | }, |
| 129 | authMethods: [authMethod], |
| 130 | agentInfo: { |
| 131 | name: "OpenCode", |
| 132 | version: InstallationVersion, |
nothing calls this directly
no test coverage detected