@opencode/plugin 2.1.4 → 2.2.1

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 (48) hide show
  1. package/dist/effect/event.d.ts +8 -2
  2. package/dist/effect/plugin.d.ts +5 -2
  3. package/dist/effect/session.d.ts +41 -3
  4. package/dist/effect/vcs.d.ts +1 -0
  5. package/dist/gui/browser.d.ts +36 -0
  6. package/dist/gui/browser.js +3 -0
  7. package/dist/gui/context.d.ts +271 -0
  8. package/dist/gui/context.js +0 -0
  9. package/dist/gui/core.d.ts +560 -0
  10. package/dist/gui/core.js +86 -0
  11. package/dist/gui/declarations.d.ts +24 -0
  12. package/dist/gui/declarations.js +0 -0
  13. package/dist/gui/file.d.ts +122 -0
  14. package/dist/gui/file.js +7 -0
  15. package/dist/gui/host-apis.d.ts +1925 -0
  16. package/dist/gui/host-apis.js +0 -0
  17. package/dist/gui/icon-name.d.ts +2 -0
  18. package/dist/gui/icon-name.js +1 -0
  19. package/dist/gui/index.d.ts +7 -0
  20. package/dist/gui/index.js +6 -0
  21. package/dist/gui/internal.d.ts +44 -0
  22. package/dist/gui/internal.js +33 -0
  23. package/dist/gui/main.d.ts +279 -0
  24. package/dist/gui/main.js +20 -0
  25. package/dist/gui/modules.d.ts +15 -0
  26. package/dist/gui/modules.js +30 -0
  27. package/dist/gui/plugin.d.ts +86 -0
  28. package/dist/gui/plugin.js +9 -0
  29. package/dist/gui/reactive.d.ts +93 -0
  30. package/dist/gui/reactive.js +130 -0
  31. package/dist/gui/registries.d.ts +801 -0
  32. package/dist/gui/registries.js +110 -0
  33. package/dist/gui/review.d.ts +73 -0
  34. package/dist/gui/review.js +3 -0
  35. package/dist/gui/scope.d.ts +64 -0
  36. package/dist/gui/scope.js +85 -0
  37. package/dist/gui/solid.d.ts +99 -0
  38. package/dist/gui/solid.js +74 -0
  39. package/dist/gui/vite.d.ts +24 -0
  40. package/dist/gui/vite.js +49 -0
  41. package/dist/host.d.ts +12 -1
  42. package/dist/host.js +34 -2
  43. package/dist/promise/adapter.js +13 -1
  44. package/dist/promise/event.d.ts +6 -2
  45. package/dist/promise/plugin.d.ts +5 -2
  46. package/dist/promise/session.d.ts +41 -3
  47. package/dist/runtime-modules.js +3 -1
  48. package/package.json +66 -17
@@ -227,12 +227,17 @@ export function fromPromise(plugin) {
227
227
  activate: adaptApiMethod(CredentialEndpoints["credential.activate"], host.credential.activate),
228
228
  },
229
229
  event: {
230
- subscribe: (options) => streams(host.event.subscribe().pipe(Stream.mapEffect((event) => encodeOpenCodeEvent(event)), Stream.map((event) => event)), options),
230
+ subscribe: (options) => streams(host.event.subscribe({ types: options?.types }).pipe(Stream.mapEffect((event) => encodeOpenCodeEvent(event)), Stream.map((event) => event)), options),
231
231
  },
232
232
  experimental: {
233
233
  terminal: {
234
234
  read: adaptApiMethod(ExperimentalEndpoints["persistentPty.read"], host.experimental.terminal.read),
235
235
  },
236
+ generate: {
237
+ text: adaptApiMethod(GenerateEndpoints["generate.text"], host.experimental.generate.text),
238
+ image: adaptApiMethod(GenerateEndpoints["generate.image"], host.experimental.generate.image),
239
+ decisions: adaptApiMethod(GenerateEndpoints["generate.decisions"], host.experimental.generate.decisions),
240
+ },
236
241
  },
237
242
  generate: {
238
243
  text: adaptApiMethod(GenerateEndpoints["generate.text"], host.generate.text),
@@ -443,6 +448,13 @@ export function fromPromise(plugin) {
443
448
  move: adaptApiMethod(SessionEndpoints["session.move"], host.session.move),
444
449
  wait: adaptApiMethod(SessionEndpoints["session.wait"], host.session.wait),
445
450
  context: adaptApiMethod(SessionEndpoints["session.context"], host.session.context),
451
+ instructions: {
452
+ entry: {
453
+ list: adaptApiMethod(SessionEndpoints["session.instructions.entry.list"], host.session.instructions.entry.list),
454
+ put: adaptApiMethod(SessionEndpoints["session.instructions.entry.put"], host.session.instructions.entry.put),
455
+ remove: adaptApiMethod(SessionEndpoints["session.instructions.entry.remove"], host.session.instructions.entry.remove),
456
+ },
457
+ },
446
458
  },
447
459
  shell: {
448
460
  hook: (name, callback) => register(host.shell.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
@@ -1,3 +1,7 @@
1
- import type { EventApi } from "@opencode/client/promise/api";
2
- export interface EventDomain extends Pick<EventApi, "subscribe"> {
1
+ import type { OpenCodeEvent } from "@opencode/client";
2
+ import type { SelectedEvent, SubscribeOptions } from "@opencode/client/promise/api";
3
+ type EventType = Exclude<OpenCodeEvent["type"], "server.connected">;
4
+ export interface EventDomain {
5
+ readonly subscribe: <Type extends EventType = EventType>(options?: SubscribeOptions<Type>) => AsyncIterable<SelectedEvent<OpenCodeEvent, Type>>;
3
6
  }
7
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { OpenCodeClient } from "@opencode/client";
2
- import type { CredentialApi, GenerateApi, PluginApi } from "@opencode/client/promise/api";
2
+ import type { CredentialApi, ExperimentalGenerateApi, PluginApi } from "@opencode/client/promise/api";
3
3
  import type { Location } from "@opencode/schema/location";
4
4
  import type { PluginOptions } from "../options.js";
5
5
  import type { App } from "../app.js";
@@ -33,11 +33,14 @@ export interface Context {
33
33
  readonly event: EventDomain;
34
34
  readonly experimental: {
35
35
  readonly terminal: Pick<OpenCodeClient["experimental"]["persistentPty"], "read">;
36
+ /** Stateless generation with a model and a prompt: no session, history or tools. */
37
+ readonly generate: ExperimentalGenerateApi;
36
38
  };
37
39
  readonly integration: IntegrationDomain;
38
40
  readonly mcp: MCPDomain;
39
41
  readonly model: ModelDomain;
40
- readonly generate: GenerateApi;
42
+ /** @deprecated Use `experimental.generate.text`. */
43
+ readonly generate: Pick<ExperimentalGenerateApi, "text">;
41
44
  readonly permission: PermissionDomain;
42
45
  readonly plugin: Pick<PluginApi, "list">;
43
46
  readonly provider: ProviderDomain;
@@ -1,5 +1,5 @@
1
- import type { SessionApi } from "@opencode/client/promise/api";
2
- import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai";
1
+ import type { ExperimentalSessionApi, SessionApi } from "@opencode/client/promise/api";
2
+ import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai/effect";
3
3
  import type { Agent } from "@opencode/schema/agent";
4
4
  import type { Model } from "@opencode/schema/model";
5
5
  import type { PromptInput } from "@opencode/schema/prompt-input";
@@ -127,6 +127,43 @@ export interface SessionRetry {
127
127
  readonly attempt: number;
128
128
  decision: SessionRetryDecision;
129
129
  }
130
+ /**
131
+ * Background work still running for the idle Session or one of its descendants. `sessionID` is
132
+ * the Session that owns the job: the idle Session itself, or a descendant such as a subagent child.
133
+ */
134
+ export type SessionIdleBackground = {
135
+ readonly kind: "shell";
136
+ readonly sessionID: Session.ID;
137
+ readonly shellID: string;
138
+ readonly command: string;
139
+ } | {
140
+ readonly kind: "subagent";
141
+ readonly sessionID: Session.ID;
142
+ readonly childSessionID: Session.ID;
143
+ readonly agent: string;
144
+ readonly description: string;
145
+ } | {
146
+ readonly kind: "image";
147
+ readonly sessionID: Session.ID;
148
+ readonly path: string;
149
+ readonly model: string;
150
+ };
151
+ /**
152
+ * Runs when a Session finishes model work and has no pending input, just before it goes idle.
153
+ * It does not run after interruption, failure, or control-only work such as a manual compaction.
154
+ * Input admitted by the hook, such as a synthetic message, runs in the same execution instead
155
+ * of the Session going idle.
156
+ *
157
+ * `background` lists work that is still running. When the Session's own shell or subagent finishes,
158
+ * its notice wakes the Session and the hook runs again, so a plugin that waits for that work can
159
+ * simply return. Work a descendant owns, such as a shell a subagent left running, wakes that
160
+ * descendant instead, so it is listed for information only. Notices admitted with `resume: false`,
161
+ * such as those recovered after a restart, wait for the next wake. Experimental.
162
+ */
163
+ export interface SessionIdle {
164
+ readonly sessionID: Session.ID;
165
+ readonly background: ReadonlyArray<SessionIdleBackground>;
166
+ }
130
167
  export interface SessionHooks {
131
168
  readonly prompt: SessionPrompt;
132
169
  readonly context: SessionContext;
@@ -140,7 +177,8 @@ export interface SessionHooks {
140
177
  readonly "experimental.ws.send": SessionWebSocketSend;
141
178
  readonly "experimental.ws.receive": SessionWebSocketReceive;
142
179
  readonly retry: SessionRetry;
180
+ readonly "experimental.idle": SessionIdle;
143
181
  }
144
- export type SessionDomain = Pick<SessionApi, "list" | "create" | "get" | "remove" | "switchAgent" | "switchModel" | "prompt" | "generate" | "command" | "compact" | "synthetic" | "interrupt" | "update" | "move" | "wait" | "context"> & {
182
+ export type SessionDomain = Pick<SessionApi, "list" | "create" | "get" | "remove" | "switchAgent" | "switchModel" | "prompt" | "generate" | "command" | "compact" | "synthetic" | "interrupt" | "update" | "move" | "context"> & Pick<ExperimentalSessionApi, "wait" | "instructions"> & {
145
183
  readonly hook: ModelHooks<SessionHooks>;
146
184
  };
@@ -29,10 +29,12 @@ export function discoverPluginRuntimeSpecifiers(from = import.meta.dir, packages
29
29
  entries.set(pkgName, toLoadPath(rootEntry));
30
30
  for (const file of new Bun.Glob(`**/*${ext}`).scanSync({ cwd: scanDir })) {
31
31
  const normalized = file.replaceAll("\\", "/");
32
+ // The GUI SDK and its Vite preset (`gui/`) run in the desktop app and at build time, never in the server or the TUI.
32
33
  if (normalized.startsWith("internal/") ||
33
34
  normalized.includes("/internal/") ||
34
35
  normalized.startsWith("source.") ||
35
- normalized.startsWith("runtime")) {
36
+ normalized.startsWith("runtime") ||
37
+ normalized.startsWith("gui/")) {
36
38
  continue;
37
39
  }
38
40
  const base = normalized.slice(0, -ext.length);
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/plugin",
4
- "version": "2.1.4",
4
+ "version": "2.2.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
8
  "test": "bun test --only-failures",
9
9
  "typecheck": "bun check --no-script",
10
10
  "typecheck:tsc": "tsc --noEmit",
11
- "build": "tsc -p tsconfig.build.json"
11
+ "build": "tsc -p tsconfig.build.json",
12
+ "pack": "bun run script/pack.ts",
13
+ "generate": "bun script/icon-name.ts"
12
14
  },
13
15
  "exports": {
14
16
  ".": {
@@ -31,6 +33,34 @@
31
33
  "import": "./dist/tui/index.js",
32
34
  "types": "./dist/tui/index.d.ts"
33
35
  },
36
+ "./gui": {
37
+ "import": "./dist/gui/index.js",
38
+ "types": "./dist/gui/index.d.ts"
39
+ },
40
+ "./gui/main": {
41
+ "import": "./dist/gui/main.js",
42
+ "types": "./dist/gui/main.d.ts"
43
+ },
44
+ "./gui/host": null,
45
+ "./gui/builtin": null,
46
+ "./gui/file": {
47
+ "import": "./dist/gui/file.js",
48
+ "types": "./dist/gui/file.d.ts"
49
+ },
50
+ "./gui/review": {
51
+ "import": "./dist/gui/review.js",
52
+ "types": "./dist/gui/review.d.ts"
53
+ },
54
+ "./gui/browser": {
55
+ "import": "./dist/gui/browser.js",
56
+ "types": "./dist/gui/browser.d.ts"
57
+ },
58
+ "./gui/updater": null,
59
+ "./gui/vite": {
60
+ "import": "./dist/gui/vite.js",
61
+ "types": "./dist/gui/vite.d.ts"
62
+ },
63
+ "./gui/*": null,
34
64
  "./*": {
35
65
  "import": "./dist/*.js",
36
66
  "types": "./dist/*.d.ts"
@@ -48,18 +78,21 @@
48
78
  ],
49
79
  "dependencies": {
50
80
  "@ai-sdk/provider": "3.0.8",
51
- "@opencode/ai": "2.1.4",
52
- "@opencode/client": "2.1.4",
53
- "@opencode/protocol": "2.1.4",
54
- "@opencode/schema": "2.1.4",
55
- "@opencode/util": "2.1.4",
81
+ "@opencode/ai": "2.2.1",
82
+ "@opencode/client": "2.2.1",
83
+ "@opencode/protocol": "2.2.1",
84
+ "@opencode/schema": "2.2.1",
85
+ "@opencode/util": "2.2.1",
56
86
  "effect": "4.0.1"
57
87
  },
58
88
  "peerDependencies": {
59
- "@opencode/theme": "2.1.4",
60
- "@opentui/core": ">=0.6.8",
61
- "@opentui/solid": ">=0.6.8",
62
- "solid-js": ">=1.9.0"
89
+ "@opencode/theme": "2.2.1",
90
+ "@opentui/core": "0.7.0",
91
+ "@opentui/solid": "0.7.0",
92
+ "electron": "*",
93
+ "solid-js": ">=1.9.0",
94
+ "vite": ">=6",
95
+ "vite-plugin-solid": ">=2.11"
63
96
  },
64
97
  "peerDependenciesMeta": {
65
98
  "@opencode/theme": {
@@ -71,20 +104,36 @@
71
104
  "@opentui/solid": {
72
105
  "optional": true
73
106
  },
107
+ "electron": {
108
+ "optional": true
109
+ },
74
110
  "solid-js": {
75
111
  "optional": true
112
+ },
113
+ "vite": {
114
+ "optional": true
115
+ },
116
+ "vite-plugin-solid": {
117
+ "optional": true
76
118
  }
77
119
  },
78
120
  "devDependencies": {
79
- "@opencode/theme": "2.1.4",
80
- "@opentui/core": "0.6.8",
81
- "@opentui/solid": "0.6.8",
121
+ "@opencode/theme": "2.2.1",
122
+ "@opentui/core": "0.7.0",
123
+ "@opentui/solid": "0.7.0",
82
124
  "@tsconfig/bun": "1.0.9",
83
- "@tsconfig/node22": "22.0.2",
84
125
  "@types/bun": "1.4.3",
85
126
  "@types/node": "24.12.2",
86
- "solid-js": "1.9.15",
127
+ "electron": "44.9.1",
128
+ "solid-js": "1.9.17",
87
129
  "typescript": "npm:@typescript/typescript6@6.0.2",
130
+ "vite": "7.3.7",
131
+ "vite-plugin-solid": "2.11.10",
88
132
  "@typescript/native": "npm:typescript@7.1.0-beta"
133
+ },
134
+ "repository": {
135
+ "type": "git",
136
+ "url": "git+https://github.com/anomalyco/opencode.git",
137
+ "directory": "packages/plugin"
89
138
  }
90
- }
139
+ }