@opencode/plugin 0.0.0-dev-1312 → 0.0.0-dev-1314

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.
@@ -171,6 +171,10 @@ export type SessionIdleBackground = {
171
171
  readonly sessionID: Session.ID;
172
172
  readonly path: string;
173
173
  readonly model: string;
174
+ } | {
175
+ readonly kind: "video";
176
+ readonly sessionID: Session.ID;
177
+ readonly path: string;
174
178
  };
175
179
  /**
176
180
  * Runs when a Session finishes model work and has no pending input, just before it goes idle.
@@ -12,7 +12,7 @@ export interface ToolEditor {
12
12
  readonly id: string;
13
13
  }) | undefined;
14
14
  namespace(namespace: Tool.Namespace): void;
15
- add<Input extends Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined>(tool: Tool.Info<Input, Output>): void;
15
+ add<Input extends Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined = undefined, CMInput extends Tool.ValueSchema<any> = Input, CMOutput extends Tool.ValueSchema<any> | undefined = Output>(tool: Tool.Info<Input, Output, CMInput, CMOutput>): void;
16
16
  /** Updates an existing tool; missing IDs are ignored. */
17
17
  update(id: string, update: (tool: Types.Mutable<Tool.Info>) => void): void;
18
18
  remove(id: string): void;
@@ -20,6 +20,8 @@ export interface ToolEditor {
20
20
  export interface ToolHooks {
21
21
  readonly "execute.before": {
22
22
  tool: string;
23
+ readonly info?: Tool.Info;
24
+ readonly codemode: boolean;
23
25
  readonly sessionID: Session.ID;
24
26
  readonly agent: Agent.ID;
25
27
  readonly messageID: SessionMessage.ID;
@@ -28,6 +30,8 @@ export interface ToolHooks {
28
30
  };
29
31
  readonly "execute.after": {
30
32
  readonly tool: string;
33
+ readonly info?: Tool.Info;
34
+ readonly codemode: boolean;
31
35
  readonly sessionID: Session.ID;
32
36
  readonly agent: Agent.ID;
33
37
  readonly messageID: SessionMessage.ID;
@@ -185,6 +185,34 @@ export function fromPromise(plugin) {
185
185
  ...context,
186
186
  progress: (update) => Effect.promise(() => context.progress(update)),
187
187
  }), { signal: context.signal });
188
+ // Only execute.before may reject a call; a rejection fails that call alone, like an Effect hook.
189
+ const adaptToolHook = {
190
+ "execute.before": (callback) => (event) => {
191
+ const adapted = {
192
+ ...event,
193
+ info: event.info && { ...event.info, execute: promiseExecutor(event.info.execute) },
194
+ };
195
+ return Effect.tryPromise({
196
+ try: () => Promise.resolve(callback(adapted)).then(() => {
197
+ event.tool = adapted.tool;
198
+ event.input = adapted.input;
199
+ }),
200
+ catch: toolError,
201
+ });
202
+ },
203
+ "execute.after": (callback) => (event) => {
204
+ const adapted = {
205
+ ...event,
206
+ info: event.info && { ...event.info, execute: promiseExecutor(event.info.execute) },
207
+ };
208
+ return Effect.promise(() => Promise.resolve(callback(adapted)).then(() => {
209
+ if (event.status === "completed" && adapted.status === "completed")
210
+ event.result = adapted.result;
211
+ if (event.status === "error" && adapted.status === "error")
212
+ event.error = adapted.error;
213
+ }));
214
+ },
215
+ };
188
216
  const adaptApiMethod = (endpoint, method) => {
189
217
  const compiled = compileEndpoint(endpoint);
190
218
  return ((input) => Effect.gen(function* () {
@@ -396,7 +424,7 @@ export function fromPromise(plugin) {
396
424
  }),
397
425
  remove: editor.remove,
398
426
  }))),
399
- hook: (name, callback) => register(host.tool.hook(name, (event) => toolHook[name](() => Promise.resolve(callback(event))))),
427
+ hook: (name, callback) => register(host.tool.hook(name, adaptToolHook[name](callback))),
400
428
  },
401
429
  vcs: {
402
430
  get: adaptApiMethod(VcsEndpoints["vcs.get"], host.vcs.get),
@@ -499,11 +527,6 @@ function attempt(evaluate) {
499
527
  const toolError = (error) => error instanceof Tool.Error
500
528
  ? error
501
529
  : new Tool.Error({ message: error instanceof Error ? error.message : String(error), error });
502
- // Only execute.before may reject a call; a rejection fails that call alone, like an Effect hook.
503
- const toolHook = {
504
- "execute.before": (run) => Effect.tryPromise({ try: run, catch: toolError }),
505
- "execute.after": (run) => Effect.promise(run),
506
- };
507
530
  const executePromiseTool = (tool, input, context) => Effect.tryPromise({
508
531
  try: (interrupted) => {
509
532
  // `signal` aborts when the call is interrupted, and also when the user stops the call once the tool has read
@@ -171,6 +171,10 @@ export type SessionIdleBackground = {
171
171
  readonly sessionID: Session.ID;
172
172
  readonly path: string;
173
173
  readonly model: string;
174
+ } | {
175
+ readonly kind: "video";
176
+ readonly sessionID: Session.ID;
177
+ readonly path: string;
174
178
  };
175
179
  /**
176
180
  * Runs when a Session finishes model work and has no pending input, just before it goes idle.
@@ -16,8 +16,8 @@ export interface ToolContext extends Omit<Tool.Context, "progress" | "cancel"> {
16
16
  readonly signal: AbortSignal;
17
17
  readonly progress: (update: Tool.Metadata) => Promise<void>;
18
18
  }
19
- export type Info<Input extends Tool.ValueSchema<any> = Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined = Tool.ValueSchema<any> | undefined> = Omit<Tool.Info<Input, Output>, "execute"> & {
20
- readonly execute: (input: Parameters<Tool.Info<Input, Output>["execute"]>[0], context: ToolContext) => Promise<Tool.Result<Output>>;
19
+ export type Info<Input extends Tool.ValueSchema<any> = Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined = Tool.ValueSchema<any> | undefined, CMInput extends Tool.ValueSchema<any> = Input, CMOutput extends Tool.ValueSchema<any> | undefined = Output> = Omit<Tool.Info<Input, Output, CMInput, CMOutput>, "execute"> & {
20
+ readonly execute: (input: Parameters<Tool.Info<Input, Output, CMInput, CMOutput>["execute"]>[0], context: ToolContext) => Promise<Tool.Result<Output | CMOutput>>;
21
21
  };
22
22
  export interface ToolEditor {
23
23
  list(): readonly (Info & {
@@ -27,14 +27,16 @@ export interface ToolEditor {
27
27
  readonly id: string;
28
28
  }) | undefined;
29
29
  namespace(namespace: Tool.Namespace): void;
30
- add<Input extends Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined>(tool: Info<Input, Output>): void;
30
+ add<Input extends Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined = undefined, CMInput extends Tool.ValueSchema<any> = Input, CMOutput extends Tool.ValueSchema<any> | undefined = Output>(tool: Info<Input, Output, CMInput, CMOutput>): void;
31
31
  /** Updates an existing tool; missing IDs are ignored. */
32
32
  update(id: string, update: (tool: Types.Mutable<Info>) => void): void;
33
33
  remove(id: string): void;
34
34
  }
35
- interface ToolHooks {
35
+ export interface ToolHooks {
36
36
  readonly "execute.before": {
37
37
  tool: string;
38
+ readonly info?: Info;
39
+ readonly codemode: boolean;
38
40
  readonly sessionID: Session.ID;
39
41
  readonly agent: Agent.ID;
40
42
  readonly messageID: SessionMessage.ID;
@@ -43,6 +45,8 @@ interface ToolHooks {
43
45
  };
44
46
  readonly "execute.after": {
45
47
  readonly tool: string;
48
+ readonly info?: Info;
49
+ readonly codemode: boolean;
46
50
  readonly sessionID: Session.ID;
47
51
  readonly agent: Agent.ID;
48
52
  readonly messageID: SessionMessage.ID;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/plugin",
4
- "version": "0.0.0-dev-1312",
4
+ "version": "0.0.0-dev-1314",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -78,15 +78,15 @@
78
78
  ],
79
79
  "dependencies": {
80
80
  "@ai-sdk/provider": "3.0.8",
81
- "@opencode/ai": "0.0.0-dev-1312",
82
- "@opencode/client": "0.0.0-dev-1312",
83
- "@opencode/protocol": "0.0.0-dev-1312",
84
- "@opencode/schema": "0.0.0-dev-1312",
85
- "@opencode/util": "0.0.0-dev-1312",
81
+ "@opencode/ai": "0.0.0-dev-1314",
82
+ "@opencode/client": "0.0.0-dev-1314",
83
+ "@opencode/protocol": "0.0.0-dev-1314",
84
+ "@opencode/schema": "0.0.0-dev-1314",
85
+ "@opencode/util": "0.0.0-dev-1314",
86
86
  "effect": "4.1.0"
87
87
  },
88
88
  "peerDependencies": {
89
- "@opencode/theme": "0.0.0-dev-1312",
89
+ "@opencode/theme": "0.0.0-dev-1314",
90
90
  "@opentui/core": ">=0.8.4",
91
91
  "@opentui/solid": ">=0.8.4",
92
92
  "electron": "*",
@@ -118,7 +118,7 @@
118
118
  }
119
119
  },
120
120
  "devDependencies": {
121
- "@opencode/theme": "0.0.0-dev-1312",
121
+ "@opencode/theme": "0.0.0-dev-1314",
122
122
  "@opentui/core": "0.8.4",
123
123
  "@opentui/solid": "0.8.4",
124
124
  "@tsconfig/bun": "1.0.9",