@opencode-ai/plugin 0.0.0-dev-202608272023 → 0.0.0-dev-18430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/app.d.ts +5 -0
  2. package/dist/app.js +0 -0
  3. package/dist/effect/agent.d.ts +15 -0
  4. package/dist/effect/agent.js +0 -0
  5. package/dist/{v2/promise → effect}/aisdk.d.ts +9 -6
  6. package/dist/effect/aisdk.js +0 -0
  7. package/dist/effect/catalog.d.ts +33 -0
  8. package/dist/effect/catalog.js +2 -0
  9. package/dist/effect/command.d.ts +23 -0
  10. package/dist/effect/command.js +0 -0
  11. package/dist/effect/event.d.ts +3 -0
  12. package/dist/effect/event.js +0 -0
  13. package/dist/effect/index.d.ts +15 -0
  14. package/dist/effect/index.js +14 -0
  15. package/dist/effect/integration.d.ts +80 -0
  16. package/dist/effect/integration.js +2 -0
  17. package/dist/effect/mcp.d.ts +15 -0
  18. package/dist/effect/mcp.js +0 -0
  19. package/dist/effect/permission.d.ts +21 -0
  20. package/dist/effect/permission.js +0 -0
  21. package/dist/effect/plugin.d.ts +52 -0
  22. package/dist/effect/reference.d.ts +13 -0
  23. package/dist/effect/reference.js +0 -0
  24. package/dist/effect/registration.d.ts +13 -0
  25. package/dist/effect/registration.js +0 -0
  26. package/dist/effect/session.d.ts +61 -0
  27. package/dist/effect/session.js +0 -0
  28. package/dist/effect/shell.d.ts +14 -0
  29. package/dist/effect/shell.js +0 -0
  30. package/dist/effect/skill.d.ts +14 -0
  31. package/dist/effect/skill.js +1 -0
  32. package/dist/effect/storage.d.ts +8 -0
  33. package/dist/effect/storage.js +0 -0
  34. package/dist/effect/tool.d.ts +51 -0
  35. package/dist/effect/tool.js +1 -0
  36. package/dist/effect/vcs.d.ts +39 -0
  37. package/dist/effect/vcs.js +0 -0
  38. package/dist/effect/websearch.d.ts +20 -0
  39. package/dist/effect/websearch.js +0 -0
  40. package/dist/options.js +0 -0
  41. package/dist/promise/adapter.d.ts +12 -0
  42. package/dist/promise/adapter.js +313 -0
  43. package/dist/promise/agent.d.ts +15 -0
  44. package/dist/promise/agent.js +0 -0
  45. package/dist/{v2/effect → promise}/aisdk.d.ts +9 -6
  46. package/dist/promise/aisdk.js +0 -0
  47. package/dist/promise/catalog.d.ts +33 -0
  48. package/dist/promise/catalog.js +0 -0
  49. package/dist/promise/command.d.ts +22 -0
  50. package/dist/promise/command.js +0 -0
  51. package/dist/promise/event.d.ts +3 -0
  52. package/dist/promise/event.js +0 -0
  53. package/dist/promise/index.d.ts +16 -0
  54. package/dist/promise/index.js +14 -0
  55. package/dist/promise/integration.d.ts +79 -0
  56. package/dist/promise/integration.js +2 -0
  57. package/dist/promise/mcp.d.ts +15 -0
  58. package/dist/promise/mcp.js +0 -0
  59. package/dist/promise/permission.d.ts +21 -0
  60. package/dist/promise/permission.js +0 -0
  61. package/dist/promise/plugin.d.ts +52 -0
  62. package/dist/{v2/effect → promise}/reference.d.ts +7 -5
  63. package/dist/promise/reference.js +0 -0
  64. package/dist/promise/registration.d.ts +12 -0
  65. package/dist/promise/registration.js +0 -0
  66. package/dist/promise/session.d.ts +61 -0
  67. package/dist/promise/session.js +0 -0
  68. package/dist/promise/shell.d.ts +14 -0
  69. package/dist/promise/shell.js +0 -0
  70. package/dist/promise/skill.d.ts +14 -0
  71. package/dist/promise/skill.js +0 -0
  72. package/dist/promise/storage.d.ts +8 -0
  73. package/dist/promise/storage.js +0 -0
  74. package/dist/promise/tool.d.ts +55 -0
  75. package/dist/promise/tool.js +2 -0
  76. package/dist/promise/types.d.ts +3 -0
  77. package/dist/promise/types.js +0 -0
  78. package/dist/promise/vcs.d.ts +46 -0
  79. package/dist/promise/vcs.js +0 -0
  80. package/dist/promise/websearch.d.ts +21 -0
  81. package/dist/promise/websearch.js +0 -0
  82. package/dist/storage.d.ts +14 -0
  83. package/dist/storage.js +0 -0
  84. package/dist/tui/context.d.ts +424 -0
  85. package/dist/tui/context.js +0 -0
  86. package/dist/tui/index.d.ts +2 -0
  87. package/dist/tui/index.js +2 -0
  88. package/dist/tui/plugin.d.ts +8 -0
  89. package/dist/tui/plugin.js +3 -0
  90. package/dist/tui/solid.d.ts +7 -0
  91. package/dist/tui/solid.js +16 -0
  92. package/dist/vcs.d.ts +4 -0
  93. package/dist/vcs.js +0 -0
  94. package/package.json +33 -34
  95. package/dist/example-workspace.d.ts +0 -3
  96. package/dist/example-workspace.js +0 -30
  97. package/dist/example.d.ts +0 -2
  98. package/dist/example.js +0 -16
  99. package/dist/index.d.ts +0 -322
  100. package/dist/index.js +0 -1
  101. package/dist/shell.d.ts +0 -109
  102. package/dist/shell.js +0 -1
  103. package/dist/tool.d.ts +0 -60
  104. package/dist/tool.js +0 -5
  105. package/dist/tui.d.ts +0 -510
  106. package/dist/tui.js +0 -7
  107. package/dist/v2/effect/agent.d.ts +0 -12
  108. package/dist/v2/effect/agent.js +0 -1
  109. package/dist/v2/effect/aisdk.js +0 -1
  110. package/dist/v2/effect/catalog.d.ts +0 -29
  111. package/dist/v2/effect/catalog.js +0 -1
  112. package/dist/v2/effect/command.d.ts +0 -11
  113. package/dist/v2/effect/command.js +0 -1
  114. package/dist/v2/effect/context.d.ts +0 -21
  115. package/dist/v2/effect/context.js +0 -1
  116. package/dist/v2/effect/event.d.ts +0 -8
  117. package/dist/v2/effect/event.js +0 -1
  118. package/dist/v2/effect/filesystem.d.ts +0 -23
  119. package/dist/v2/effect/filesystem.js +0 -1
  120. package/dist/v2/effect/index.d.ts +0 -3
  121. package/dist/v2/effect/index.js +0 -1
  122. package/dist/v2/effect/integration.d.ts +0 -46
  123. package/dist/v2/effect/integration.js +0 -1
  124. package/dist/v2/effect/location.d.ts +0 -6
  125. package/dist/v2/effect/location.js +0 -1
  126. package/dist/v2/effect/npm.d.ts +0 -7
  127. package/dist/v2/effect/npm.js +0 -1
  128. package/dist/v2/effect/path.d.ts +0 -8
  129. package/dist/v2/effect/path.js +0 -1
  130. package/dist/v2/effect/plugin.d.ts +0 -11
  131. package/dist/v2/effect/reference.js +0 -1
  132. package/dist/v2/effect/registration.d.ts +0 -10
  133. package/dist/v2/effect/registration.js +0 -1
  134. package/dist/v2/effect/skill.d.ts +0 -9
  135. package/dist/v2/effect/skill.js +0 -1
  136. package/dist/v2/options.js +0 -1
  137. package/dist/v2/promise/agent.d.ts +0 -6
  138. package/dist/v2/promise/agent.js +0 -1
  139. package/dist/v2/promise/aisdk.js +0 -1
  140. package/dist/v2/promise/catalog.d.ts +0 -6
  141. package/dist/v2/promise/catalog.js +0 -1
  142. package/dist/v2/promise/command.d.ts +0 -6
  143. package/dist/v2/promise/command.js +0 -1
  144. package/dist/v2/promise/context.d.ts +0 -21
  145. package/dist/v2/promise/context.js +0 -1
  146. package/dist/v2/promise/index.d.ts +0 -12
  147. package/dist/v2/promise/index.js +0 -1
  148. package/dist/v2/promise/integration.d.ts +0 -12
  149. package/dist/v2/promise/integration.js +0 -1
  150. package/dist/v2/promise/plugin.d.ts +0 -10
  151. package/dist/v2/promise/reference.d.ts +0 -6
  152. package/dist/v2/promise/reference.js +0 -1
  153. package/dist/v2/promise/registration.d.ts +0 -9
  154. package/dist/v2/promise/registration.js +0 -1
  155. package/dist/v2/promise/skill.d.ts +0 -6
  156. package/dist/v2/promise/skill.js +0 -1
  157. /package/dist/{v2/effect → effect}/plugin.js +0 -0
  158. /package/dist/{v2/options.d.ts → options.d.ts} +0 -0
  159. /package/dist/{v2/promise → promise}/plugin.js +0 -0
@@ -0,0 +1,313 @@
1
+ import { Tool } from "@opencode-ai/schema/tool";
2
+ import { Effect, Schema, SchemaAST, Stream } from "effect";
3
+ import { HttpApiEndpoint, HttpApiSchema } from "effect/unstable/httpapi";
4
+ import { define } from "../effect/plugin.js";
5
+ const compiledEndpoints = new WeakMap();
6
+ function compileEndpoint(endpoint) {
7
+ const cached = compiledEndpoints.get(endpoint);
8
+ if (cached)
9
+ return cached;
10
+ const payloadSchemas = Array.from(endpoint.payload.values()).flatMap(({ schemas }) => schemas);
11
+ const successSchemas = Array.from(endpoint.success);
12
+ if (payloadSchemas.length > 1 || successSchemas.length > 1) {
13
+ throw new Error(`Unsupported API schema cardinality: ${endpoint.identifier}`);
14
+ }
15
+ const inputs = [
16
+ endpoint.params,
17
+ endpoint.query === undefined ? undefined : Schema.toType(endpoint.query),
18
+ endpoint.headers,
19
+ ...payloadSchemas,
20
+ ].filter((schema) => schema !== undefined);
21
+ const success = (successSchemas[0] ?? HttpApiSchema.NoContent);
22
+ const noContent = HttpApiSchema.isNoContent(success.ast);
23
+ const type = Schema.toType(success).ast;
24
+ const data = SchemaAST.isObjects(success.ast)
25
+ ? success.ast.propertySignatures.find((property) => property.name === "data")
26
+ : undefined;
27
+ const output = !noContent &&
28
+ SchemaAST.isObjects(type) &&
29
+ type.indexSignatures.length === 0 &&
30
+ type.propertySignatures.length === 1 &&
31
+ type.propertySignatures[0]?.name === "data" &&
32
+ data !== undefined
33
+ ? Schema.make(data.type)
34
+ : success;
35
+ const compiled = {
36
+ decode: inputs.map((schema) => Schema.decodeUnknownEffect(schema)),
37
+ encode: Schema.encodeUnknownEffect(output),
38
+ noContent,
39
+ };
40
+ compiledEndpoints.set(endpoint, compiled);
41
+ return compiled;
42
+ }
43
+ /**
44
+ * Adapts a Promise plugin into an Effect plugin so the existing Effect-only
45
+ * loader (`Plugin` / `PluginSupervisor`) can run it unchanged.
46
+ *
47
+ * Hook registrations created during the async `setup` attach to the plugin's
48
+ * scope, so unloading the plugin disposes them. The captured fiber context
49
+ * preserves boot-time batching, so Promise-plugin transforms still coalesce
50
+ * into one reload per domain.
51
+ */
52
+ export function fromPromise(plugin) {
53
+ return define({
54
+ id: plugin.id,
55
+ tui: plugin.tui,
56
+ vcs: plugin.vcs,
57
+ effect: (host) => Effect.gen(function* () {
58
+ const [{ ClientApi }, { OpenCodeEvent }] = yield* Effect.promise(() => Promise.all([import("@opencode-ai/protocol/client"), import("@opencode-ai/protocol/groups/event")]));
59
+ const AgentEndpoints = ClientApi.groups["server.agent"].endpoints;
60
+ const CommandEndpoints = ClientApi.groups["server.command"].endpoints;
61
+ const GenerateEndpoints = ClientApi.groups["server.generate"].endpoints;
62
+ const IntegrationEndpoints = ClientApi.groups["server.integration"].endpoints;
63
+ const McpEndpoints = ClientApi.groups["server.mcp"].endpoints;
64
+ const ModelEndpoints = ClientApi.groups["server.model"].endpoints;
65
+ const PluginEndpoints = ClientApi.groups["server.plugin"].endpoints;
66
+ const PermissionEndpoints = ClientApi.groups["server.permission"].endpoints;
67
+ const ProviderEndpoints = ClientApi.groups["server.provider"].endpoints;
68
+ const ReferenceEndpoints = ClientApi.groups["server.reference"].endpoints;
69
+ const SessionEndpoints = ClientApi.groups["server.session"].endpoints;
70
+ const SkillEndpoints = ClientApi.groups["server.skill"].endpoints;
71
+ const VcsEndpoints = ClientApi.groups["server.vcs"].endpoints;
72
+ const WebSearchEndpoints = ClientApi.groups["server.websearch"].endpoints;
73
+ const context = yield* Effect.context();
74
+ // Run a hook registration on the plugin scope and resolve once it is registered.
75
+ const register = (effect) => Effect.runPromiseWith(context)(effect).then((registration) => ({
76
+ dispose: () => Effect.runPromiseWith(context)(registration.dispose),
77
+ }));
78
+ const run = (effect) => Effect.runPromiseWith(context)(effect);
79
+ const promiseExecutor = (execute) => (input, context) => run(execute(input, {
80
+ ...context,
81
+ progress: (update) => Effect.promise(() => context.progress(update)),
82
+ }));
83
+ const adaptApiMethod = (endpoint, method) => {
84
+ const compiled = compileEndpoint(endpoint);
85
+ return ((input) => Effect.gen(function* () {
86
+ const decoded = yield* Effect.forEach(compiled.decode, (decode) => decode(input ?? {}));
87
+ const result = yield* method(Object.assign({}, ...decoded));
88
+ if (compiled.noContent)
89
+ return undefined;
90
+ return yield* compiled.encode(result);
91
+ }).pipe(Effect.runPromiseWith(context)));
92
+ };
93
+ const transform = (domain) => (callback) => register(domain.transform((draft) => {
94
+ callback(draft);
95
+ }));
96
+ const context2 = {
97
+ app: host.app,
98
+ location: host.location,
99
+ options: host.options,
100
+ agent: {
101
+ get: adaptApiMethod(AgentEndpoints["agent.get"], host.agent.get),
102
+ list: adaptApiMethod(AgentEndpoints["agent.list"], host.agent.list),
103
+ transform: transform(host.agent),
104
+ reload: () => run(host.agent.reload()),
105
+ },
106
+ aisdk: {
107
+ hook: (name, callback, options) => register(host.aisdk.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))), options)),
108
+ },
109
+ catalog: {
110
+ provider: {
111
+ list: adaptApiMethod(ProviderEndpoints["provider.list"], host.catalog.provider.list),
112
+ get: adaptApiMethod(ProviderEndpoints["provider.get"], host.catalog.provider.get),
113
+ },
114
+ model: {
115
+ list: adaptApiMethod(ModelEndpoints["model.list"], host.catalog.model.list),
116
+ default: adaptApiMethod(ModelEndpoints["model.default"], host.catalog.model.default),
117
+ },
118
+ transform: transform(host.catalog),
119
+ reload: () => run(host.catalog.reload()),
120
+ },
121
+ command: {
122
+ list: adaptApiMethod(CommandEndpoints["command.list"], host.command.list),
123
+ transform: (callback) => register(host.command.transform((draft) => callback({
124
+ add: (definition) => draft.add({
125
+ ...definition,
126
+ execute: (input) => Effect.tryPromise({ try: () => definition.execute(input), catch: (cause) => cause }),
127
+ }),
128
+ }))),
129
+ reload: () => run(host.command.reload()),
130
+ },
131
+ event: {
132
+ subscribe: () => Stream.toAsyncIterable(host.event.subscribe().pipe(Stream.mapEffect((event) => Schema.encodeUnknownEffect(OpenCodeEvent)(event)), Stream.map((event) => event))),
133
+ },
134
+ generate: {
135
+ text: adaptApiMethod(GenerateEndpoints["generate.text"], host.generate.text),
136
+ },
137
+ integration: {
138
+ list: adaptApiMethod(IntegrationEndpoints["integration.list"], host.integration.list),
139
+ get: adaptApiMethod(IntegrationEndpoints["integration.get"], host.integration.get),
140
+ connect: {
141
+ key: adaptApiMethod(IntegrationEndpoints["integration.connect.key"], host.integration.connect.key),
142
+ },
143
+ oauth: {
144
+ connect: adaptApiMethod(IntegrationEndpoints["integration.oauth.connect"], host.integration.oauth.connect),
145
+ status: adaptApiMethod(IntegrationEndpoints["integration.oauth.status"], host.integration.oauth.status),
146
+ complete: adaptApiMethod(IntegrationEndpoints["integration.oauth.complete"], host.integration.oauth.complete),
147
+ cancel: adaptApiMethod(IntegrationEndpoints["integration.oauth.cancel"], host.integration.oauth.cancel),
148
+ },
149
+ command: {
150
+ connect: adaptApiMethod(IntegrationEndpoints["integration.command.connect"], host.integration.command.connect),
151
+ status: adaptApiMethod(IntegrationEndpoints["integration.command.status"], host.integration.command.status),
152
+ cancel: adaptApiMethod(IntegrationEndpoints["integration.command.cancel"], host.integration.command.cancel),
153
+ },
154
+ transform: (callback) => register(host.integration.transform((draft) => callback({
155
+ list: draft.list,
156
+ get: draft.get,
157
+ update: draft.update,
158
+ remove: draft.remove,
159
+ method: {
160
+ list: draft.method.list,
161
+ update: (input) => {
162
+ if (!("authorize" in input))
163
+ return draft.method.update(input);
164
+ const refresh = input.refresh;
165
+ draft.method.update({
166
+ ...input,
167
+ authorize: (answer) => Effect.promise(() => input.authorize(answer)).pipe(Effect.map((authorization) => authorization.mode === "auto"
168
+ ? {
169
+ ...authorization,
170
+ callback: Effect.promise(() => authorization.callback),
171
+ }
172
+ : {
173
+ ...authorization,
174
+ callback: (code) => Effect.promise(() => authorization.callback(code)),
175
+ })),
176
+ refresh: refresh === undefined
177
+ ? undefined
178
+ : (credential) => Effect.promise(() => refresh(credential)),
179
+ });
180
+ },
181
+ remove: draft.method.remove,
182
+ },
183
+ }))),
184
+ reload: () => run(host.integration.reload()),
185
+ connection: {
186
+ active: (id) => Effect.runPromiseWith(context)(host.integration.connection.active(id)),
187
+ resolve: (connection) => Effect.runPromiseWith(context)(host.integration.connection.resolve(connection)),
188
+ },
189
+ },
190
+ mcp: {
191
+ list: adaptApiMethod(McpEndpoints["mcp.list"], host.mcp.list),
192
+ transform: transform(host.mcp),
193
+ reload: () => run(host.mcp.reload()),
194
+ },
195
+ permission: {
196
+ hook: (name, callback) => register(host.permission.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
197
+ list: adaptApiMethod(PermissionEndpoints["session.permission.list"], host.permission.list),
198
+ get: adaptApiMethod(PermissionEndpoints["session.permission.get"], host.permission.get),
199
+ reply: adaptApiMethod(PermissionEndpoints["session.permission.reply"], host.permission.reply),
200
+ },
201
+ plugin: {
202
+ list: adaptApiMethod(PluginEndpoints["plugin.list"], host.plugin.list),
203
+ },
204
+ reference: {
205
+ list: adaptApiMethod(ReferenceEndpoints["reference.list"], host.reference.list),
206
+ transform: transform(host.reference),
207
+ reload: () => run(host.reference.reload()),
208
+ },
209
+ skill: {
210
+ list: adaptApiMethod(SkillEndpoints["skill.list"], host.skill.list),
211
+ transform: transform(host.skill),
212
+ reload: () => run(host.skill.reload()),
213
+ },
214
+ storage: {
215
+ get: (key) => run(host.storage.get(key)),
216
+ set: (key, value) => run(host.storage.set(key, value)),
217
+ remove: (key) => run(host.storage.remove(key)),
218
+ scan: (options) => run(host.storage.scan(options)),
219
+ },
220
+ tool: {
221
+ reload: () => run(host.tool.reload()),
222
+ transform: (callback) => register(host.tool.transform((draft) => callback({
223
+ list: () => draft.list().map((tool) => ({ ...tool, execute: promiseExecutor(tool.execute) })),
224
+ get: (id) => {
225
+ const tool = draft.get(id);
226
+ return tool ? { ...tool, execute: promiseExecutor(tool.execute) } : undefined;
227
+ },
228
+ add: (tool) => draft.add({
229
+ ...tool,
230
+ execute: (input, context) => executePromiseTool(tool, input, context),
231
+ }),
232
+ update: (id, update) => draft.update(id, (tool) => {
233
+ const value = {
234
+ ...tool,
235
+ execute: promiseExecutor(tool.execute),
236
+ };
237
+ update(value);
238
+ Object.assign(tool, value, {
239
+ output: value.output,
240
+ options: value.options,
241
+ execute: (input, context) => executePromiseTool(value, input, context),
242
+ });
243
+ }),
244
+ remove: draft.remove,
245
+ }))),
246
+ hook: (name, callback) => register(host.tool.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
247
+ },
248
+ vcs: {
249
+ get: adaptApiMethod(VcsEndpoints["vcs.get"], host.vcs.get),
250
+ branches: adaptApiMethod(VcsEndpoints["vcs.branches"], host.vcs.branches),
251
+ status: adaptApiMethod(VcsEndpoints["vcs.status"], host.vcs.status),
252
+ diff: adaptApiMethod(VcsEndpoints["vcs.diff"], host.vcs.diff),
253
+ reload: () => run(host.vcs.reload()),
254
+ transform: (callback) => register(host.vcs.transform((draft) => {
255
+ callback({
256
+ add: (definition) => draft.add({
257
+ id: definition.id,
258
+ name: definition.name,
259
+ info: (input) => attempt((signal) => definition.info(input, { signal })),
260
+ branches: (input) => attempt((signal) => definition.branches(input, { signal })),
261
+ status: (input) => attempt((signal) => definition.status(input, { signal })),
262
+ diff: (input) => attempt((signal) => definition.diff(input, { signal })),
263
+ }),
264
+ default: draft.default,
265
+ });
266
+ })),
267
+ },
268
+ websearch: {
269
+ providers: adaptApiMethod(WebSearchEndpoints["websearch.providers"], host.websearch.providers),
270
+ query: adaptApiMethod(WebSearchEndpoints["websearch.query"], host.websearch.query),
271
+ reload: () => run(host.websearch.reload()),
272
+ transform: (callback) => register(host.websearch.transform((draft) => {
273
+ callback({
274
+ add: (definition) => draft.add({
275
+ id: definition.id,
276
+ name: definition.name,
277
+ execute: (input) => attempt((signal) => definition.execute(input, { signal })),
278
+ }),
279
+ default: draft.default,
280
+ });
281
+ })),
282
+ },
283
+ session: {
284
+ hook: (name, callback, options) => register(host.session.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))), options)),
285
+ create: adaptApiMethod(SessionEndpoints["session.create"], host.session.create),
286
+ get: adaptApiMethod(SessionEndpoints["session.get"], host.session.get),
287
+ switchAgent: adaptApiMethod(SessionEndpoints["session.switchAgent"], host.session.switchAgent),
288
+ switchModel: adaptApiMethod(SessionEndpoints["session.switchModel"], host.session.switchModel),
289
+ prompt: adaptApiMethod(SessionEndpoints["session.prompt"], host.session.prompt),
290
+ generate: adaptApiMethod(SessionEndpoints["session.generate"], host.session.generate),
291
+ command: adaptApiMethod(SessionEndpoints["session.command"], host.session.command),
292
+ synthetic: adaptApiMethod(SessionEndpoints["session.synthetic"], host.session.synthetic),
293
+ interrupt: adaptApiMethod(SessionEndpoints["session.interrupt"], host.session.interrupt),
294
+ rename: adaptApiMethod(SessionEndpoints["session.rename"], host.session.rename),
295
+ move: adaptApiMethod(SessionEndpoints["session.move"], host.session.move),
296
+ wait: adaptApiMethod(SessionEndpoints["session.wait"], host.session.wait),
297
+ context: adaptApiMethod(SessionEndpoints["session.context"], host.session.context),
298
+ },
299
+ shell: {
300
+ hook: (name, callback) => register(host.shell.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
301
+ },
302
+ };
303
+ yield* Effect.acquireRelease(Effect.promise(() => Promise.resolve(plugin.setup(context2))), (cleanup) => (cleanup ? Effect.promise(() => Promise.resolve(cleanup())) : Effect.void));
304
+ }),
305
+ });
306
+ }
307
+ function attempt(evaluate) {
308
+ return Effect.tryPromise({ try: evaluate, catch: (cause) => cause });
309
+ }
310
+ const executePromiseTool = (tool, input, context) => Effect.promise(() => tool.execute(input, {
311
+ ...context,
312
+ progress: (update) => Effect.runPromise(context.progress(update)),
313
+ }));
@@ -0,0 +1,15 @@
1
+ import type { AgentApi } from "@opencode-ai/client/promise/api";
2
+ import type { Agent } from "@opencode-ai/schema/agent";
3
+ import type { Transform } from "./registration.js";
4
+ import type { DeepMutable } from "./types.js";
5
+ export interface AgentDraft {
6
+ list(): readonly DeepMutable<Agent.Info>[];
7
+ get(id: string): DeepMutable<Agent.Info> | undefined;
8
+ default(id: string | undefined): void;
9
+ update(id: string, update: (agent: DeepMutable<Agent.Info>) => void): void;
10
+ remove(id: string): void;
11
+ }
12
+ export interface AgentDomain extends AgentApi {
13
+ readonly transform: Transform<AgentDraft>;
14
+ readonly reload: () => Promise<void>;
15
+ }
File without changes
@@ -1,17 +1,20 @@
1
1
  import type { LanguageModelV3 } from "@ai-sdk/provider";
2
- import type { ModelV2Info } from "@opencode-ai/sdk/v2/types";
3
- import type { Hooks } from "./registration.js";
4
- export type AISDKHooks = Hooks<{
2
+ import type { Model } from "@opencode-ai/schema/model";
3
+ import type { ModelHooks } from "./registration.js";
4
+ export interface AISDKHooks {
5
5
  sdk: {
6
- readonly model: ModelV2Info;
6
+ readonly model: Model.Info;
7
7
  readonly package: string;
8
8
  readonly options: Record<string, any>;
9
9
  sdk?: any;
10
10
  };
11
11
  language: {
12
- readonly model: ModelV2Info;
12
+ readonly model: Model.Info;
13
13
  readonly sdk: any;
14
14
  readonly options: Record<string, any>;
15
15
  language?: LanguageModelV3;
16
16
  };
17
- }>;
17
+ }
18
+ export interface AISDKDomain {
19
+ readonly hook: ModelHooks<AISDKHooks>;
20
+ }
File without changes
@@ -0,0 +1,33 @@
1
+ import type { CatalogApi } from "@opencode-ai/client/promise/api";
2
+ import type { Model } from "@opencode-ai/schema/model";
3
+ import type { Provider } from "@opencode-ai/schema/provider";
4
+ import type { Transform } from "./registration.js";
5
+ import type { DeepMutable } from "./types.js";
6
+ export interface CatalogProviderRecord {
7
+ readonly provider: DeepMutable<Provider.Info>;
8
+ readonly models: ReadonlyMap<string, DeepMutable<Model.Info>>;
9
+ }
10
+ export interface CatalogDraft {
11
+ readonly provider: {
12
+ list(): readonly CatalogProviderRecord[];
13
+ get(providerID: string): CatalogProviderRecord | undefined;
14
+ update(providerID: string, update: (provider: DeepMutable<Provider.Info>) => void): void;
15
+ remove(providerID: string): void;
16
+ };
17
+ readonly model: {
18
+ get(providerID: string, modelID: string): DeepMutable<Model.Info> | undefined;
19
+ update(providerID: string, modelID: string, update: (model: DeepMutable<Model.Info>) => void): void;
20
+ remove(providerID: string, modelID: string): void;
21
+ readonly default: {
22
+ get(): {
23
+ providerID: string;
24
+ modelID: string;
25
+ } | undefined;
26
+ set(providerID: string, modelID: string): void;
27
+ };
28
+ };
29
+ }
30
+ export interface CatalogDomain extends CatalogApi {
31
+ readonly transform: Transform<CatalogDraft>;
32
+ readonly reload: () => Promise<void>;
33
+ }
File without changes
@@ -0,0 +1,22 @@
1
+ import type { CommandApi } from "@opencode-ai/client/promise/api";
2
+ import type { PromptInput } from "@opencode-ai/schema/prompt-input";
3
+ import type { Session } from "@opencode-ai/schema/session";
4
+ import type { SessionInbox } from "@opencode-ai/schema/session-inbox";
5
+ import type { Transform } from "./registration.js";
6
+ export interface CommandInvocation {
7
+ readonly sessionID: Session.ID;
8
+ readonly prompt: PromptInput.Prompt;
9
+ readonly delivery: SessionInbox.Delivery;
10
+ }
11
+ export interface CommandDefinition {
12
+ readonly name: string;
13
+ readonly description?: string;
14
+ readonly execute: (input: CommandInvocation) => Promise<void>;
15
+ }
16
+ export interface CommandDraft {
17
+ add(definition: CommandDefinition): void;
18
+ }
19
+ export interface CommandDomain extends Pick<CommandApi, "list"> {
20
+ readonly transform: Transform<CommandDraft>;
21
+ readonly reload: () => Promise<void>;
22
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ import type { EventApi } from "@opencode-ai/client/promise/api";
2
+ export interface EventDomain extends Pick<EventApi, "subscribe"> {
3
+ }
File without changes
@@ -0,0 +1,16 @@
1
+ export type { PluginOptions } from "../options.js";
2
+ export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js";
3
+ export * as Plugin from "./plugin.js";
4
+ export { Agent } from "@opencode-ai/schema/agent";
5
+ export { Command } from "@opencode-ai/schema/command";
6
+ export { Connection } from "@opencode-ai/schema/connection";
7
+ export { Credential } from "@opencode-ai/schema/credential";
8
+ export { Integration } from "@opencode-ai/schema/integration";
9
+ export { Location } from "@opencode-ai/schema/location";
10
+ export { Mcp } from "@opencode-ai/schema/mcp";
11
+ export { Model } from "@opencode-ai/schema/model";
12
+ export { Provider } from "@opencode-ai/schema/provider";
13
+ export { Reference } from "@opencode-ai/schema/reference";
14
+ export { Skill } from "@opencode-ai/schema/skill";
15
+ export { Vcs } from "@opencode-ai/schema/vcs";
16
+ export { WebSearch } from "@opencode-ai/schema/websearch";
@@ -0,0 +1,14 @@
1
+ export * as Plugin from "./plugin.js";
2
+ export { Agent } from "@opencode-ai/schema/agent";
3
+ export { Command } from "@opencode-ai/schema/command";
4
+ export { Connection } from "@opencode-ai/schema/connection";
5
+ export { Credential } from "@opencode-ai/schema/credential";
6
+ export { Integration } from "@opencode-ai/schema/integration";
7
+ export { Location } from "@opencode-ai/schema/location";
8
+ export { Mcp } from "@opencode-ai/schema/mcp";
9
+ export { Model } from "@opencode-ai/schema/model";
10
+ export { Provider } from "@opencode-ai/schema/provider";
11
+ export { Reference } from "@opencode-ai/schema/reference";
12
+ export { Skill } from "@opencode-ai/schema/skill";
13
+ export { Vcs } from "@opencode-ai/schema/vcs";
14
+ export { WebSearch } from "@opencode-ai/schema/websearch";
@@ -0,0 +1,79 @@
1
+ import type { ConnectionInfo } from "@opencode-ai/client";
2
+ import type { IntegrationApi } from "@opencode-ai/client/promise/api";
3
+ import { Credential } from "@opencode-ai/schema/credential";
4
+ import { Form } from "@opencode-ai/schema/form";
5
+ import type { Transform } from "./registration.js";
6
+ type IntegrationRef = {
7
+ id: string;
8
+ name: string;
9
+ };
10
+ export interface IntegrationOAuthMethod {
11
+ readonly id: string;
12
+ readonly type: "oauth";
13
+ readonly label: string;
14
+ readonly form?: Form.Fields;
15
+ }
16
+ export interface IntegrationCommandMethod {
17
+ readonly id: string;
18
+ readonly type: "command";
19
+ readonly label: string;
20
+ readonly command: ReadonlyArray<string>;
21
+ }
22
+ export interface IntegrationKeyMethod {
23
+ readonly type: "key";
24
+ readonly label?: string;
25
+ readonly form?: Form.Fields;
26
+ }
27
+ export interface IntegrationEnvMethod {
28
+ readonly type: "env";
29
+ readonly names: ReadonlyArray<string>;
30
+ }
31
+ export type IntegrationMethod = IntegrationOAuthMethod | IntegrationCommandMethod | IntegrationKeyMethod | IntegrationEnvMethod;
32
+ export type IntegrationOAuthAuthorization = {
33
+ readonly url: string;
34
+ readonly instructions: string;
35
+ readonly expiresAt?: number;
36
+ } & ({
37
+ readonly mode: "auto";
38
+ readonly callback: Promise<Credential.OAuth>;
39
+ } | {
40
+ readonly mode: "code";
41
+ readonly callback: (code: string) => Promise<Credential.OAuth>;
42
+ });
43
+ export type IntegrationOAuthMethodRegistration = {
44
+ readonly integrationID: string;
45
+ readonly method: IntegrationOAuthMethod;
46
+ readonly authorize: (answer: Form.Answer) => Promise<IntegrationOAuthAuthorization>;
47
+ readonly refresh?: (credential: Credential.OAuth) => Promise<Credential.OAuth>;
48
+ readonly label?: (credential: Credential.OAuth) => string | undefined;
49
+ };
50
+ export type IntegrationMethodRegistration = IntegrationOAuthMethodRegistration | {
51
+ readonly integrationID: string;
52
+ readonly method: IntegrationCommandMethod;
53
+ } | {
54
+ readonly integrationID: string;
55
+ readonly method: IntegrationKeyMethod;
56
+ } | {
57
+ readonly integrationID: string;
58
+ readonly method: IntegrationEnvMethod;
59
+ };
60
+ export interface IntegrationDraft {
61
+ list(): readonly IntegrationRef[];
62
+ get(id: string): IntegrationRef | undefined;
63
+ update(id: string, update: (integration: IntegrationRef) => void): void;
64
+ remove(id: string): void;
65
+ readonly method: {
66
+ list(integrationID: string): readonly IntegrationMethod[];
67
+ update(input: IntegrationMethodRegistration): void;
68
+ remove(integrationID: string, method: IntegrationMethod): void;
69
+ };
70
+ }
71
+ export interface IntegrationDomain extends Omit<IntegrationApi, "wellknown"> {
72
+ readonly transform: Transform<IntegrationDraft>;
73
+ readonly reload: () => Promise<void>;
74
+ readonly connection: {
75
+ readonly active: (integrationID: string) => Promise<ConnectionInfo | undefined>;
76
+ readonly resolve: (connection: ConnectionInfo) => Promise<Credential.Value | undefined>;
77
+ };
78
+ }
79
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Credential } from "@opencode-ai/schema/credential";
2
+ import { Form } from "@opencode-ai/schema/form";
@@ -0,0 +1,15 @@
1
+ import type { McpApi } from "@opencode-ai/client/promise/api";
2
+ import type { Mcp } from "@opencode-ai/schema/mcp";
3
+ import type { Transform } from "./registration.js";
4
+ import type { DeepMutable } from "./types.js";
5
+ export interface MCPDraft {
6
+ list(): readonly [string, DeepMutable<Mcp.ServerConfig>][];
7
+ get(name: string): DeepMutable<Mcp.ServerConfig> | undefined;
8
+ set(name: string, config: Mcp.ServerConfig): void;
9
+ update(name: string, update: (config: DeepMutable<Mcp.ServerConfig>) => void): void;
10
+ remove(name: string): void;
11
+ }
12
+ export interface MCPDomain extends Pick<McpApi, "list"> {
13
+ readonly transform: Transform<MCPDraft>;
14
+ readonly reload: () => Promise<void>;
15
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import type { PermissionApi } from "@opencode-ai/client/promise/api";
2
+ import type { Agent } from "@opencode-ai/schema/agent";
3
+ import type { Permission } from "@opencode-ai/schema/permission";
4
+ import type { Session } from "@opencode-ai/schema/session";
5
+ import type { Hooks } from "./registration.js";
6
+ export interface PermissionEvaluation {
7
+ readonly sessionID: Session.ID;
8
+ readonly agent?: Agent.ID;
9
+ readonly action: string;
10
+ readonly resources: ReadonlyArray<string>;
11
+ readonly metadata?: Record<string, unknown>;
12
+ readonly source?: Permission.Source;
13
+ effect: Permission.Effect;
14
+ message?: string;
15
+ }
16
+ export interface PermissionHooks {
17
+ readonly evaluate: PermissionEvaluation;
18
+ }
19
+ export type PermissionDomain = Pick<PermissionApi, "list" | "get" | "reply"> & {
20
+ readonly hook: Hooks<PermissionHooks>;
21
+ };
File without changes
@@ -0,0 +1,52 @@
1
+ import type { GenerateApi, PluginApi } from "@opencode-ai/client/promise/api";
2
+ import type { Location } from "@opencode-ai/schema/location";
3
+ import type { PluginOptions } from "../options.js";
4
+ import type { VcsDiscovery } from "../vcs.js";
5
+ import type { App } from "../app.js";
6
+ import type { AgentDomain } from "./agent.js";
7
+ import type { AISDKDomain } from "./aisdk.js";
8
+ import type { CatalogDomain } from "./catalog.js";
9
+ import type { CommandDomain } from "./command.js";
10
+ import type { EventDomain } from "./event.js";
11
+ import type { IntegrationDomain } from "./integration.js";
12
+ import type { MCPDomain } from "./mcp.js";
13
+ import type { PermissionDomain } from "./permission.js";
14
+ import type { ReferenceDomain } from "./reference.js";
15
+ import type { SessionDomain } from "./session.js";
16
+ import type { ShellDomain } from "./shell.js";
17
+ import type { SkillDomain } from "./skill.js";
18
+ import type { StorageDomain } from "./storage.js";
19
+ import type { ToolDomain } from "./tool.js";
20
+ import type { VcsDomain } from "./vcs.js";
21
+ import type { WebSearchDomain } from "./websearch.js";
22
+ export interface Context {
23
+ readonly app: App;
24
+ readonly location: Location.Info;
25
+ readonly options: PluginOptions;
26
+ readonly agent: AgentDomain;
27
+ readonly aisdk: AISDKDomain;
28
+ readonly catalog: CatalogDomain;
29
+ readonly command: CommandDomain;
30
+ readonly event: EventDomain;
31
+ readonly integration: IntegrationDomain;
32
+ readonly mcp: MCPDomain;
33
+ readonly generate: GenerateApi;
34
+ readonly permission: PermissionDomain;
35
+ readonly plugin: PluginApi;
36
+ readonly reference: ReferenceDomain;
37
+ readonly session: SessionDomain;
38
+ readonly shell: ShellDomain;
39
+ readonly skill: SkillDomain;
40
+ readonly storage: StorageDomain;
41
+ readonly tool: ToolDomain;
42
+ readonly vcs: VcsDomain;
43
+ readonly websearch: WebSearchDomain;
44
+ }
45
+ export type Cleanup = () => Promise<void> | void;
46
+ export interface Plugin {
47
+ readonly id: string;
48
+ readonly tui?: boolean;
49
+ readonly vcs?: VcsDiscovery;
50
+ readonly setup: (context: Context) => Promise<Cleanup | void> | Cleanup | void;
51
+ }
52
+ export declare function define(plugin: Plugin): Plugin;