@opencode-ai/plugin 0.0.0-test-bedrock-202511260007 → 0.0.0-tui-v2-202606261840

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 (67) hide show
  1. package/dist/example-workspace.d.ts +3 -0
  2. package/dist/example-workspace.js +30 -0
  3. package/dist/example.d.ts +1 -1
  4. package/dist/example.js +2 -2
  5. package/dist/index.d.ts +173 -8
  6. package/dist/index.js +1 -1
  7. package/dist/shell.js +1 -0
  8. package/dist/tool.d.ts +42 -2
  9. package/dist/tui.d.ts +510 -0
  10. package/dist/tui.js +7 -0
  11. package/dist/v2/effect/agent.d.ts +12 -0
  12. package/dist/v2/effect/agent.js +1 -0
  13. package/dist/v2/effect/aisdk.d.ts +17 -0
  14. package/dist/v2/effect/aisdk.js +1 -0
  15. package/dist/v2/effect/catalog.d.ts +29 -0
  16. package/dist/v2/effect/catalog.js +1 -0
  17. package/dist/v2/effect/command.d.ts +11 -0
  18. package/dist/v2/effect/command.js +1 -0
  19. package/dist/v2/effect/context.d.ts +21 -0
  20. package/dist/v2/effect/context.js +1 -0
  21. package/dist/v2/effect/event.d.ts +8 -0
  22. package/dist/v2/effect/event.js +1 -0
  23. package/dist/v2/effect/filesystem.d.ts +23 -0
  24. package/dist/v2/effect/filesystem.js +1 -0
  25. package/dist/v2/effect/index.d.ts +3 -0
  26. package/dist/v2/effect/index.js +1 -0
  27. package/dist/v2/effect/integration.d.ts +46 -0
  28. package/dist/v2/effect/integration.js +1 -0
  29. package/dist/v2/effect/location.d.ts +6 -0
  30. package/dist/v2/effect/location.js +1 -0
  31. package/dist/v2/effect/npm.d.ts +7 -0
  32. package/dist/v2/effect/npm.js +1 -0
  33. package/dist/v2/effect/path.d.ts +8 -0
  34. package/dist/v2/effect/path.js +1 -0
  35. package/dist/v2/effect/plugin.d.ts +11 -0
  36. package/dist/v2/effect/plugin.js +3 -0
  37. package/dist/v2/effect/reference.d.ts +10 -0
  38. package/dist/v2/effect/reference.js +1 -0
  39. package/dist/v2/effect/registration.d.ts +10 -0
  40. package/dist/v2/effect/registration.js +1 -0
  41. package/dist/v2/effect/skill.d.ts +9 -0
  42. package/dist/v2/effect/skill.js +1 -0
  43. package/dist/v2/options.d.ts +1 -0
  44. package/dist/v2/options.js +1 -0
  45. package/dist/v2/promise/agent.d.ts +6 -0
  46. package/dist/v2/promise/agent.js +1 -0
  47. package/dist/v2/promise/aisdk.d.ts +17 -0
  48. package/dist/v2/promise/aisdk.js +1 -0
  49. package/dist/v2/promise/catalog.d.ts +6 -0
  50. package/dist/v2/promise/catalog.js +1 -0
  51. package/dist/v2/promise/command.d.ts +6 -0
  52. package/dist/v2/promise/command.js +1 -0
  53. package/dist/v2/promise/context.d.ts +21 -0
  54. package/dist/v2/promise/context.js +1 -0
  55. package/dist/v2/promise/index.d.ts +12 -0
  56. package/dist/v2/promise/index.js +1 -0
  57. package/dist/v2/promise/integration.d.ts +12 -0
  58. package/dist/v2/promise/integration.js +1 -0
  59. package/dist/v2/promise/plugin.d.ts +10 -0
  60. package/dist/v2/promise/plugin.js +3 -0
  61. package/dist/v2/promise/reference.d.ts +6 -0
  62. package/dist/v2/promise/reference.js +1 -0
  63. package/dist/v2/promise/registration.d.ts +9 -0
  64. package/dist/v2/promise/registration.js +1 -0
  65. package/dist/v2/promise/skill.d.ts +6 -0
  66. package/dist/v2/promise/skill.js +1 -0
  67. package/package.json +46 -4
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ export declare const FolderWorkspacePlugin: Plugin;
3
+ export default FolderWorkspacePlugin;
@@ -0,0 +1,30 @@
1
+ import { mkdir, rm } from "node:fs/promises";
2
+ export const FolderWorkspacePlugin = async ({ experimental_workspace }) => {
3
+ experimental_workspace.register("folder", {
4
+ name: "Folder",
5
+ description: "Create a blank folder",
6
+ configure(config) {
7
+ const rand = "" + Math.random();
8
+ return {
9
+ ...config,
10
+ directory: `/tmp/folder/folder-${rand}`,
11
+ };
12
+ },
13
+ async create(config) {
14
+ if (!config.directory)
15
+ return;
16
+ await mkdir(config.directory, { recursive: true });
17
+ },
18
+ async remove(config) {
19
+ await rm(config.directory, { recursive: true, force: true });
20
+ },
21
+ target(config) {
22
+ return {
23
+ type: "local",
24
+ directory: config.directory,
25
+ };
26
+ },
27
+ });
28
+ return {};
29
+ };
30
+ export default FolderWorkspacePlugin;
package/dist/example.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Plugin } from "./index";
1
+ import { Plugin } from "./index.js";
2
2
  export declare const ExamplePlugin: Plugin;
package/dist/example.js CHANGED
@@ -1,5 +1,5 @@
1
- import { tool } from "./tool";
2
- export const ExamplePlugin = async (ctx) => {
1
+ import { tool } from "./tool.js";
2
+ export const ExamplePlugin = async (_ctx) => {
3
3
  return {
4
4
  tool: {
5
5
  mytool: tool({
package/dist/index.d.ts CHANGED
@@ -1,15 +1,64 @@
1
- import type { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage, Part, Auth, Config } from "@opencode-ai/sdk";
2
- import type { BunShell } from "./shell";
3
- import { type ToolDefinition } from "./tool";
4
- export * from "./tool";
1
+ import type { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage, Message, Part, Config as SDKConfig } from "@opencode-ai/sdk";
2
+ import type { Provider as ProviderV2, Model as ModelV2, Auth } from "@opencode-ai/sdk/v2";
3
+ import type { BunShell } from "./shell.js";
4
+ import { type ToolDefinition } from "./tool.js";
5
+ export * from "./tool.js";
6
+ export type ProviderContext = {
7
+ source: "env" | "config" | "custom" | "api";
8
+ info: Provider;
9
+ options: Record<string, any>;
10
+ };
11
+ export type WorkspaceInfo = {
12
+ id: string;
13
+ type: string;
14
+ name: string;
15
+ branch: string | null;
16
+ directory: string | null;
17
+ extra: unknown | null;
18
+ projectID: string;
19
+ };
20
+ export type WorkspaceTarget = {
21
+ type: "local";
22
+ directory: string;
23
+ } | {
24
+ type: "remote";
25
+ url: string | URL;
26
+ headers?: HeadersInit;
27
+ };
28
+ export type WorkspaceAdapter = {
29
+ name: string;
30
+ description: string;
31
+ configure(config: WorkspaceInfo): WorkspaceInfo | Promise<WorkspaceInfo>;
32
+ create(config: WorkspaceInfo, env: Record<string, string | undefined>, from?: WorkspaceInfo): Promise<void>;
33
+ remove(config: WorkspaceInfo): Promise<void>;
34
+ target(config: WorkspaceInfo): WorkspaceTarget | Promise<WorkspaceTarget>;
35
+ };
5
36
  export type PluginInput = {
6
37
  client: ReturnType<typeof createOpencodeClient>;
7
38
  project: Project;
8
39
  directory: string;
9
40
  worktree: string;
41
+ experimental_workspace: {
42
+ register(type: string, adapter: WorkspaceAdapter): void;
43
+ };
44
+ serverUrl: URL;
10
45
  $: BunShell;
11
46
  };
12
- export type Plugin = (input: PluginInput) => Promise<Hooks>;
47
+ export type PluginOptions = Record<string, unknown>;
48
+ export type Config = Omit<SDKConfig, "plugin"> & {
49
+ plugin?: Array<string | [string, PluginOptions]>;
50
+ };
51
+ export type Plugin = (input: PluginInput, options?: PluginOptions) => Promise<Hooks>;
52
+ export type PluginModule = {
53
+ id?: string;
54
+ server: Plugin;
55
+ tui?: never;
56
+ };
57
+ type Rule = {
58
+ key: string;
59
+ op: "eq" | "neq";
60
+ value: string;
61
+ };
13
62
  export type AuthHook = {
14
63
  provider: string;
15
64
  loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>;
@@ -22,7 +71,9 @@ export type AuthHook = {
22
71
  message: string;
23
72
  placeholder?: string;
24
73
  validate?: (value: string) => string | undefined;
74
+ /** @deprecated Use `when` instead */
25
75
  condition?: (inputs: Record<string, string>) => boolean;
76
+ when?: Rule;
26
77
  } | {
27
78
  type: "select";
28
79
  key: string;
@@ -32,9 +83,11 @@ export type AuthHook = {
32
83
  value: string;
33
84
  hint?: string;
34
85
  }>;
86
+ /** @deprecated Use `when` instead */
35
87
  condition?: (inputs: Record<string, string>) => boolean;
88
+ when?: Rule;
36
89
  }>;
37
- authorize(inputs?: Record<string, string>): Promise<AuthOuathResult>;
90
+ authorize(inputs?: Record<string, string>): Promise<AuthOAuthResult>;
38
91
  } | {
39
92
  type: "api";
40
93
  label: string;
@@ -44,7 +97,9 @@ export type AuthHook = {
44
97
  message: string;
45
98
  placeholder?: string;
46
99
  validate?: (value: string) => string | undefined;
100
+ /** @deprecated Use `when` instead */
47
101
  condition?: (inputs: Record<string, string>) => boolean;
102
+ when?: Rule;
48
103
  } | {
49
104
  type: "select";
50
105
  key: string;
@@ -54,18 +109,21 @@ export type AuthHook = {
54
109
  value: string;
55
110
  hint?: string;
56
111
  }>;
112
+ /** @deprecated Use `when` instead */
57
113
  condition?: (inputs: Record<string, string>) => boolean;
114
+ when?: Rule;
58
115
  }>;
59
116
  authorize?(inputs?: Record<string, string>): Promise<{
60
117
  type: "success";
61
118
  key: string;
62
119
  provider?: string;
120
+ metadata?: Record<string, string>;
63
121
  } | {
64
122
  type: "failed";
65
123
  }>;
66
124
  })[];
67
125
  };
68
- export type AuthOuathResult = {
126
+ export type AuthOAuthResult = {
69
127
  url: string;
70
128
  instructions: string;
71
129
  } & ({
@@ -77,8 +135,11 @@ export type AuthOuathResult = {
77
135
  refresh: string;
78
136
  access: string;
79
137
  expires: number;
138
+ accountId?: string;
139
+ enterpriseUrl?: string;
80
140
  } | {
81
141
  key: string;
142
+ metadata?: Record<string, string>;
82
143
  })) | {
83
144
  type: "failed";
84
145
  }>;
@@ -91,13 +152,26 @@ export type AuthOuathResult = {
91
152
  refresh: string;
92
153
  access: string;
93
154
  expires: number;
155
+ accountId?: string;
156
+ enterpriseUrl?: string;
94
157
  } | {
95
158
  key: string;
159
+ metadata?: Record<string, string>;
96
160
  })) | {
97
161
  type: "failed";
98
162
  }>;
99
163
  });
164
+ export type ProviderHookContext = {
165
+ auth?: Auth;
166
+ };
167
+ export type ProviderHook = {
168
+ id: string;
169
+ models?: (provider: ProviderV2, ctx: ProviderHookContext) => Promise<Record<string, ModelV2>>;
170
+ };
171
+ /** @deprecated Use AuthOAuthResult instead. */
172
+ export type AuthOuathResult = AuthOAuthResult;
100
173
  export interface Hooks {
174
+ dispose?: () => Promise<void>;
101
175
  event?: (input: {
102
176
  event: Event;
103
177
  }) => Promise<void>;
@@ -106,6 +180,7 @@ export interface Hooks {
106
180
  [key: string]: ToolDefinition;
107
181
  };
108
182
  auth?: AuthHook;
183
+ provider?: ProviderHook;
109
184
  /**
110
185
  * Called when a new message is received
111
186
  */
@@ -117,6 +192,7 @@ export interface Hooks {
117
192
  modelID: string;
118
193
  };
119
194
  messageID?: string;
195
+ variant?: string;
120
196
  }, output: {
121
197
  message: UserMessage;
122
198
  parts: Part[];
@@ -128,16 +204,34 @@ export interface Hooks {
128
204
  sessionID: string;
129
205
  agent: string;
130
206
  model: Model;
131
- provider: Provider;
207
+ provider: ProviderContext;
132
208
  message: UserMessage;
133
209
  }, output: {
134
210
  temperature: number;
135
211
  topP: number;
212
+ topK: number;
213
+ maxOutputTokens: number | undefined;
136
214
  options: Record<string, any>;
137
215
  }) => Promise<void>;
216
+ "chat.headers"?: (input: {
217
+ sessionID: string;
218
+ agent: string;
219
+ model: Model;
220
+ provider: ProviderContext;
221
+ message: UserMessage;
222
+ }, output: {
223
+ headers: Record<string, string>;
224
+ }) => Promise<void>;
138
225
  "permission.ask"?: (input: Permission, output: {
139
226
  status: "ask" | "deny" | "allow";
140
227
  }) => Promise<void>;
228
+ "command.execute.before"?: (input: {
229
+ command: string;
230
+ sessionID: string;
231
+ arguments: string;
232
+ }, output: {
233
+ parts: Part[];
234
+ }) => Promise<void>;
141
235
  "tool.execute.before"?: (input: {
142
236
  tool: string;
143
237
  sessionID: string;
@@ -145,13 +239,84 @@ export interface Hooks {
145
239
  }, output: {
146
240
  args: any;
147
241
  }) => Promise<void>;
242
+ "shell.env"?: (input: {
243
+ cwd: string;
244
+ sessionID?: string;
245
+ callID?: string;
246
+ }, output: {
247
+ env: Record<string, string>;
248
+ }) => Promise<void>;
148
249
  "tool.execute.after"?: (input: {
149
250
  tool: string;
150
251
  sessionID: string;
151
252
  callID: string;
253
+ args: any;
152
254
  }, output: {
153
255
  title: string;
154
256
  output: string;
155
257
  metadata: any;
156
258
  }) => Promise<void>;
259
+ "experimental.chat.messages.transform"?: (input: {}, output: {
260
+ messages: {
261
+ info: Message;
262
+ parts: Part[];
263
+ }[];
264
+ }) => Promise<void>;
265
+ "experimental.chat.system.transform"?: (input: {
266
+ sessionID?: string;
267
+ model: Model;
268
+ }, output: {
269
+ system: string[];
270
+ }) => Promise<void>;
271
+ "experimental.provider.small_model"?: (input: {
272
+ provider: ProviderV2;
273
+ }, output: {
274
+ model?: ModelV2;
275
+ }) => Promise<void>;
276
+ /**
277
+ * Called before session compaction starts. Allows plugins to customize
278
+ * the compaction prompt.
279
+ *
280
+ * - `context`: Additional context strings appended to the default prompt
281
+ * - `prompt`: If set, replaces the default compaction prompt entirely
282
+ */
283
+ "experimental.session.compacting"?: (input: {
284
+ sessionID: string;
285
+ }, output: {
286
+ context: string[];
287
+ prompt?: string;
288
+ }) => Promise<void>;
289
+ /**
290
+ * Called after compaction succeeds and before a synthetic user
291
+ * auto-continue message is added.
292
+ *
293
+ * - `enabled`: Defaults to `true`. Set to `false` to skip the synthetic
294
+ * user "continue" turn.
295
+ */
296
+ "experimental.compaction.autocontinue"?: (input: {
297
+ sessionID: string;
298
+ agent: string;
299
+ model: Model;
300
+ provider: ProviderContext;
301
+ message: UserMessage;
302
+ overflow: boolean;
303
+ }, output: {
304
+ enabled: boolean;
305
+ }) => Promise<void>;
306
+ "experimental.text.complete"?: (input: {
307
+ sessionID: string;
308
+ messageID: string;
309
+ partID: string;
310
+ }, output: {
311
+ text: string;
312
+ }) => Promise<void>;
313
+ /**
314
+ * Modify tool definitions (description and parameters) sent to LLM
315
+ */
316
+ "tool.definition"?: (input: {
317
+ toolID: string;
318
+ }, output: {
319
+ description: string;
320
+ parameters: any;
321
+ }) => Promise<void>;
157
322
  }
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./tool";
1
+ export * from "./tool.js";
package/dist/shell.js CHANGED
@@ -0,0 +1 @@
1
+ export {};
package/dist/tool.d.ts CHANGED
@@ -3,18 +3,58 @@ export type ToolContext = {
3
3
  sessionID: string;
4
4
  messageID: string;
5
5
  agent: string;
6
+ /**
7
+ * Current project directory for this session.
8
+ * Prefer this over process.cwd() when resolving relative paths.
9
+ */
10
+ directory: string;
11
+ /**
12
+ * Project worktree root for this session.
13
+ * Useful for generating stable relative paths (e.g. path.relative(worktree, absPath)).
14
+ */
15
+ worktree: string;
6
16
  abort: AbortSignal;
17
+ metadata(input: {
18
+ title?: string;
19
+ metadata?: {
20
+ [key: string]: any;
21
+ };
22
+ }): void;
23
+ ask(input: AskInput): Promise<void>;
24
+ };
25
+ type AskInput = {
26
+ permission: string;
27
+ patterns: string[];
28
+ always: string[];
29
+ metadata: {
30
+ [key: string]: any;
31
+ };
32
+ };
33
+ export type ToolAttachment = {
34
+ type: "file";
35
+ mime: string;
36
+ url: string;
37
+ filename?: string;
38
+ };
39
+ export type ToolResult = string | {
40
+ title?: string;
41
+ output: string;
42
+ metadata?: {
43
+ [key: string]: any;
44
+ };
45
+ attachments?: ToolAttachment[];
7
46
  };
8
47
  export declare function tool<Args extends z.ZodRawShape>(input: {
9
48
  description: string;
10
49
  args: Args;
11
- execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string>;
50
+ execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<ToolResult>;
12
51
  }): {
13
52
  description: string;
14
53
  args: Args;
15
- execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string>;
54
+ execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<ToolResult>;
16
55
  };
17
56
  export declare namespace tool {
18
57
  var schema: typeof z;
19
58
  }
20
59
  export type ToolDefinition = ReturnType<typeof tool>;
60
+ export {};