MCPcopy Create free account
hub / github.com/anomalyco/opencode / make

Function make

packages/opencode/src/acp/service.ts:75–570  ·  view source on GitHub ↗
(input: {
  sdk: OpencodeClient
  connection?: ServiceConnection
  directory?: Directory.Interface
  session?: ACPSession.Interface
  usage?: UsageService.Interface
  eventSubscription?: (subscription: ACPEvent.Subscription) => void
})

Source from the content-addressed store, hash-verified

73export class Service extends Context.Service<Service, Interface>()("@opencode/ACP/Service") {}
74
75export 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,

Callers

nothing calls this directly

Calls 15

promptContentToPartsFunction · 0.90
makeDirectoryServiceFunction · 0.85
selectDefaultModelFunction · 0.85
profiledRequestFunction · 0.85
registerMcpServersFunction · 0.85
sendAvailableCommandsFunction · 0.85
configOptionsFunction · 0.85
restoreFromMessagesFunction · 0.85
parseSelectedModelFunction · 0.85
detectSlashCommandFunction · 0.85
sendUsageUpdateFunction · 0.85
atMethod · 0.80

Tested by

no test coverage detected