@opencode/plugin 2.1.3 → 2.2.0

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 (55) hide show
  1. package/dist/effect/event.d.ts +8 -2
  2. package/dist/effect/plugin.d.ts +4 -1
  3. package/dist/effect/session.d.ts +2 -2
  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/core.d.ts +560 -0
  9. package/dist/gui/core.js +86 -0
  10. package/dist/gui/declarations.d.ts +24 -0
  11. package/dist/gui/declarations.js +0 -0
  12. package/dist/gui/file.d.ts +122 -0
  13. package/dist/gui/file.js +7 -0
  14. package/dist/gui/host-apis.d.ts +1925 -0
  15. package/dist/gui/host-apis.js +0 -0
  16. package/dist/gui/icon-name.d.ts +2 -0
  17. package/dist/gui/icon-name.js +1 -0
  18. package/dist/gui/index.d.ts +7 -0
  19. package/dist/gui/index.js +6 -0
  20. package/dist/gui/internal.d.ts +44 -0
  21. package/dist/gui/internal.js +33 -0
  22. package/dist/gui/main.d.ts +279 -0
  23. package/dist/gui/main.js +20 -0
  24. package/dist/gui/modules.d.ts +15 -0
  25. package/dist/gui/modules.js +30 -0
  26. package/dist/gui/plugin.d.ts +86 -0
  27. package/dist/gui/plugin.js +9 -0
  28. package/dist/gui/reactive.d.ts +93 -0
  29. package/dist/gui/reactive.js +130 -0
  30. package/dist/gui/registries.d.ts +783 -0
  31. package/dist/gui/registries.js +110 -0
  32. package/dist/gui/review.d.ts +73 -0
  33. package/dist/gui/review.js +3 -0
  34. package/dist/gui/scope.d.ts +64 -0
  35. package/dist/gui/scope.js +85 -0
  36. package/dist/gui/solid.d.ts +99 -0
  37. package/dist/gui/solid.js +74 -0
  38. package/dist/gui/vite.d.ts +24 -0
  39. package/dist/gui/vite.js +49 -0
  40. package/dist/host.d.ts +12 -1
  41. package/dist/host.js +34 -2
  42. package/dist/permission.d.ts +0 -1
  43. package/dist/promise/adapter.js +14 -1
  44. package/dist/promise/agent.d.ts +4 -4
  45. package/dist/promise/event.d.ts +6 -2
  46. package/dist/promise/mcp.d.ts +4 -4
  47. package/dist/promise/model.d.ts +4 -4
  48. package/dist/promise/plugin.d.ts +4 -1
  49. package/dist/promise/provider.d.ts +3 -3
  50. package/dist/promise/session.d.ts +2 -2
  51. package/dist/promise/skill.d.ts +4 -4
  52. package/dist/runtime-modules.js +3 -1
  53. package/package.json +68 -17
  54. package/dist/promise/types.d.ts +0 -3
  55. /package/dist/{promise/types.js → gui/context.js} +0 -0
@@ -156,6 +156,7 @@ export function fromPromise(plugin) {
156
156
  id: plugin.id,
157
157
  effect: (host) => Effect.gen(function* () {
158
158
  const [{ ClientApi }, { OpenCodeEvent }] = yield* Effect.promise(() => Promise.all([import("@opencode/protocol/client"), import("@opencode/protocol/groups/event")]));
159
+ const encodeOpenCodeEvent = Schema.encodeUnknownEffect(OpenCodeEvent);
159
160
  const AgentEndpoints = ClientApi.groups["server.agent"].endpoints;
160
161
  const CommandEndpoints = ClientApi.groups["server.command"].endpoints;
161
162
  const CredentialEndpoints = ClientApi.groups["server.credential"].endpoints;
@@ -226,12 +227,17 @@ export function fromPromise(plugin) {
226
227
  activate: adaptApiMethod(CredentialEndpoints["credential.activate"], host.credential.activate),
227
228
  },
228
229
  event: {
229
- subscribe: (options) => streams(host.event.subscribe().pipe(Stream.mapEffect((event) => Schema.encodeUnknownEffect(OpenCodeEvent)(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),
230
231
  },
231
232
  experimental: {
232
233
  terminal: {
233
234
  read: adaptApiMethod(ExperimentalEndpoints["persistentPty.read"], host.experimental.terminal.read),
234
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
+ },
235
241
  },
236
242
  generate: {
237
243
  text: adaptApiMethod(GenerateEndpoints["generate.text"], host.generate.text),
@@ -442,6 +448,13 @@ export function fromPromise(plugin) {
442
448
  move: adaptApiMethod(SessionEndpoints["session.move"], host.session.move),
443
449
  wait: adaptApiMethod(SessionEndpoints["session.wait"], host.session.wait),
444
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
+ },
445
458
  },
446
459
  shell: {
447
460
  hook: (name, callback) => register(host.shell.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
@@ -1,12 +1,12 @@
1
1
  import type { AgentApi } from "@opencode/client/promise/api";
2
2
  import type { Agent } from "@opencode/schema/agent";
3
+ import type { Types } from "effect";
3
4
  import type { Transform } from "./registration.js";
4
- import type { DeepMutable } from "./types.js";
5
5
  export interface AgentEditor {
6
- list(): readonly DeepMutable<Agent.Info>[];
7
- get(id: string): DeepMutable<Agent.Info> | undefined;
6
+ list(): readonly Types.DeepMutable<Agent.Info>[];
7
+ get(id: string): Types.DeepMutable<Agent.Info> | undefined;
8
8
  default(id: string | undefined): void;
9
- update(id: string, update: (agent: DeepMutable<Agent.Info>) => void): void;
9
+ update(id: string, update: (agent: Types.DeepMutable<Agent.Info>) => void): void;
10
10
  remove(id: string): void;
11
11
  }
12
12
  export interface AgentDomain extends AgentApi {
@@ -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,12 +1,12 @@
1
1
  import type { McpApi } from "@opencode/client/promise/api";
2
2
  import type { Mcp } from "@opencode/schema/mcp";
3
+ import type { Types } from "effect";
3
4
  import type { Transform } from "./registration.js";
4
- import type { DeepMutable } from "./types.js";
5
5
  export interface MCPEditor {
6
- list(): readonly [string, DeepMutable<Mcp.ServerConfig>][];
7
- get(name: string): DeepMutable<Mcp.ServerConfig> | undefined;
6
+ list(): readonly [string, Types.DeepMutable<Mcp.ServerConfig>][];
7
+ get(name: string): Types.DeepMutable<Mcp.ServerConfig> | undefined;
8
8
  set(name: string, config: Mcp.ServerConfig): void;
9
- update(name: string, update: (config: DeepMutable<Mcp.ServerConfig>) => void): void;
9
+ update(name: string, update: (config: Types.DeepMutable<Mcp.ServerConfig>) => void): void;
10
10
  remove(name: string): void;
11
11
  }
12
12
  export interface MCPDomain extends Pick<McpApi, "list"> {
@@ -1,14 +1,14 @@
1
1
  import type { ModelApi } from "@opencode/client/promise/api";
2
2
  import type { Model } from "@opencode/schema/model";
3
+ import type { Types } from "effect";
3
4
  import type { ProviderRecord } from "./provider.js";
4
5
  import type { Transform } from "./registration.js";
5
- import type { DeepMutable } from "./types.js";
6
6
  export interface ModelEditor {
7
7
  /** Candidates from available providers, including models disabled by earlier transforms. */
8
- list(providerID?: string): readonly DeepMutable<Model.Info>[];
9
- get(providerID: string, modelID: string): DeepMutable<Model.Info> | undefined;
8
+ list(providerID?: string): readonly Types.DeepMutable<Model.Info>[];
9
+ get(providerID: string, modelID: string): Types.DeepMutable<Model.Info> | undefined;
10
10
  /** Edits raw model overrides; cannot create an unavailable provider. */
11
- update(providerID: string, modelID: string, update: (model: DeepMutable<Model.Info>) => void): void;
11
+ update(providerID: string, modelID: string, update: (model: Types.DeepMutable<Model.Info>) => void): void;
12
12
  remove(providerID: string, modelID: string): void;
13
13
  readonly default: {
14
14
  get(): {
@@ -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: GenerateApi;
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<GenerateApi, "text">;
41
44
  readonly permission: PermissionDomain;
42
45
  readonly plugin: Pick<PluginApi, "list">;
43
46
  readonly provider: ProviderDomain;
@@ -2,8 +2,8 @@ import type { ProviderApi } from "@opencode/client/promise/api";
2
2
  import type { Model } from "@opencode/schema/model";
3
3
  import type { Provider } from "@opencode/schema/provider";
4
4
  import type { ConnectionInfo } from "@opencode/client";
5
+ import type { Types } from "effect";
5
6
  import type { Transform } from "./registration.js";
6
- import type { DeepMutable } from "./types.js";
7
7
  /** Provider metadata and immutable source definitions, including inactive providers. */
8
8
  export interface ProviderRecord {
9
9
  readonly provider: Provider.Info;
@@ -19,12 +19,12 @@ export interface ProviderEditor {
19
19
  models: readonly Model.Info[];
20
20
  sourceConnection?: ConnectionInfo;
21
21
  }): void;
22
- update(providerID: string, update: (provider: DeepMutable<Provider.Info>) => void): void;
22
+ update(providerID: string, update: (provider: Types.DeepMutable<Provider.Info>) => void): void;
23
23
  remove(providerID: string): void;
24
24
  readonly models: {
25
25
  set(providerID: string, models: readonly Model.Info[]): void;
26
26
  /** Updates an owned copy of a source definition. */
27
- update(providerID: string, modelID: string, update: (model: DeepMutable<Model.Info>) => void): void;
27
+ update(providerID: string, modelID: string, update: (model: Types.DeepMutable<Model.Info>) => void): void;
28
28
  remove(providerID: string, modelID: string): void;
29
29
  };
30
30
  }
@@ -1,5 +1,5 @@
1
1
  import type { SessionApi } from "@opencode/client/promise/api";
2
- import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai";
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";
@@ -141,6 +141,6 @@ export interface SessionHooks {
141
141
  readonly "experimental.ws.receive": SessionWebSocketReceive;
142
142
  readonly retry: SessionRetry;
143
143
  }
144
- export type SessionDomain = Pick<SessionApi, "list" | "create" | "get" | "remove" | "switchAgent" | "switchModel" | "prompt" | "generate" | "command" | "compact" | "synthetic" | "interrupt" | "update" | "move" | "wait" | "context"> & {
144
+ export type SessionDomain = Pick<SessionApi, "list" | "create" | "get" | "remove" | "switchAgent" | "switchModel" | "prompt" | "generate" | "command" | "compact" | "synthetic" | "interrupt" | "update" | "move" | "wait" | "context" | "instructions"> & {
145
145
  readonly hook: ModelHooks<SessionHooks>;
146
146
  };
@@ -1,12 +1,12 @@
1
1
  import type { SkillApi } from "@opencode/client/promise/api";
2
2
  import type { Skill } from "@opencode/schema/skill";
3
+ import type { Types } from "effect";
3
4
  import type { Transform } from "./registration.js";
4
- import type { DeepMutable } from "./types.js";
5
5
  export interface SkillEditor {
6
- list(): readonly DeepMutable<Skill.Info>[];
7
- get(id: string): DeepMutable<Skill.Info> | undefined;
6
+ list(): readonly Types.DeepMutable<Skill.Info>[];
7
+ get(id: string): Types.DeepMutable<Skill.Info> | undefined;
8
8
  add(skill: Skill.Info): void;
9
- update(id: string, update: (skill: DeepMutable<Skill.Info>) => void): void;
9
+ update(id: string, update: (skill: Types.DeepMutable<Skill.Info>) => void): void;
10
10
  remove(id: string): void;
11
11
  }
12
12
  export interface SkillDomain extends SkillApi {
@@ -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,13 +1,16 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/plugin",
4
- "version": "2.1.3",
4
+ "version": "2.2.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
8
  "test": "bun test --only-failures",
9
- "typecheck": "tsc --noEmit",
10
- "build": "tsc -p tsconfig.build.json"
9
+ "typecheck": "bun check --no-script",
10
+ "typecheck:tsc": "tsc --noEmit",
11
+ "build": "tsc -p tsconfig.build.json",
12
+ "pack": "bun run script/pack.ts",
13
+ "generate": "bun script/icon-name.ts"
11
14
  },
12
15
  "exports": {
13
16
  ".": {
@@ -30,6 +33,34 @@
30
33
  "import": "./dist/tui/index.js",
31
34
  "types": "./dist/tui/index.d.ts"
32
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,
33
64
  "./*": {
34
65
  "import": "./dist/*.js",
35
66
  "types": "./dist/*.d.ts"
@@ -47,18 +78,21 @@
47
78
  ],
48
79
  "dependencies": {
49
80
  "@ai-sdk/provider": "3.0.8",
50
- "@opencode/ai": "2.1.3",
51
- "@opencode/client": "2.1.3",
52
- "@opencode/protocol": "2.1.3",
53
- "@opencode/schema": "2.1.3",
54
- "@opencode/util": "2.1.3",
81
+ "@opencode/ai": "2.2.0",
82
+ "@opencode/client": "2.2.0",
83
+ "@opencode/protocol": "2.2.0",
84
+ "@opencode/schema": "2.2.0",
85
+ "@opencode/util": "2.2.0",
55
86
  "effect": "4.0.1"
56
87
  },
57
88
  "peerDependencies": {
58
- "@opencode/theme": "2.1.3",
59
- "@opentui/core": ">=0.6.6",
60
- "@opentui/solid": ">=0.6.6",
61
- "solid-js": ">=1.9.0"
89
+ "@opencode/theme": "2.2.0",
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"
62
96
  },
63
97
  "peerDependenciesMeta": {
64
98
  "@opencode/theme": {
@@ -70,20 +104,37 @@
70
104
  "@opentui/solid": {
71
105
  "optional": true
72
106
  },
107
+ "electron": {
108
+ "optional": true
109
+ },
73
110
  "solid-js": {
74
111
  "optional": true
112
+ },
113
+ "vite": {
114
+ "optional": true
115
+ },
116
+ "vite-plugin-solid": {
117
+ "optional": true
75
118
  }
76
119
  },
77
120
  "devDependencies": {
78
- "@opencode/theme": "2.1.3",
79
- "@opentui/core": "0.6.6",
80
- "@opentui/solid": "0.6.6",
121
+ "@opencode/theme": "2.2.0",
122
+ "@opentui/core": "0.7.0",
123
+ "@opentui/solid": "0.7.0",
81
124
  "@tsconfig/bun": "1.0.9",
82
125
  "@tsconfig/node22": "22.0.2",
83
126
  "@types/bun": "1.4.3",
84
127
  "@types/node": "24.12.2",
128
+ "electron": "44.9.1",
85
129
  "solid-js": "1.9.15",
86
130
  "typescript": "npm:@typescript/typescript6@6.0.2",
87
- "@typescript/native": "npm:typescript@7.0.2"
131
+ "vite": "7.3.6",
132
+ "vite-plugin-solid": "2.11.10",
133
+ "@typescript/native": "npm:typescript@7.1.0-beta"
134
+ },
135
+ "repository": {
136
+ "type": "git",
137
+ "url": "git+https://github.com/anomalyco/opencode.git",
138
+ "directory": "packages/plugin"
88
139
  }
89
- }
140
+ }
@@ -1,3 +0,0 @@
1
- export type DeepMutable<A> = A extends (...args: never[]) => unknown ? A : A extends ReadonlyMap<infer K, infer V> ? Map<DeepMutable<K>, DeepMutable<V>> : A extends ReadonlyArray<infer I> ? DeepMutable<I>[] : A extends object ? {
2
- -readonly [K in keyof A]: DeepMutable<A[K]>;
3
- } : A;
File without changes