@opencode/plugin 0.0.0-reserved → 2.0.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 (116) 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/effect/aisdk.d.ts +20 -0
  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 +18 -0
  14. package/dist/effect/index.js +17 -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 +56 -0
  22. package/dist/effect/plugin.js +3 -0
  23. package/dist/effect/reference.d.ts +14 -0
  24. package/dist/effect/reference.js +0 -0
  25. package/dist/effect/registration.d.ts +13 -0
  26. package/dist/effect/registration.js +0 -0
  27. package/dist/effect/rpc.d.ts +19 -0
  28. package/dist/effect/rpc.js +0 -0
  29. package/dist/effect/session.d.ts +107 -0
  30. package/dist/effect/session.js +0 -0
  31. package/dist/effect/shell.d.ts +14 -0
  32. package/dist/effect/shell.js +0 -0
  33. package/dist/effect/skill.d.ts +15 -0
  34. package/dist/effect/skill.js +1 -0
  35. package/dist/effect/storage.d.ts +8 -0
  36. package/dist/effect/storage.js +0 -0
  37. package/dist/effect/tool.d.ts +52 -0
  38. package/dist/effect/tool.js +1 -0
  39. package/dist/effect/vcs.d.ts +41 -0
  40. package/dist/effect/vcs.js +0 -0
  41. package/dist/effect/websearch.d.ts +20 -0
  42. package/dist/effect/websearch.js +0 -0
  43. package/dist/effect/worktree.d.ts +18 -0
  44. package/dist/effect/worktree.js +0 -0
  45. package/dist/host.d.ts +12 -0
  46. package/dist/host.js +33 -0
  47. package/dist/options.d.ts +1 -0
  48. package/dist/options.js +0 -0
  49. package/dist/promise/adapter.d.ts +12 -0
  50. package/dist/promise/adapter.js +444 -0
  51. package/dist/promise/agent.d.ts +15 -0
  52. package/dist/promise/agent.js +0 -0
  53. package/dist/promise/aisdk.d.ts +20 -0
  54. package/dist/promise/aisdk.js +0 -0
  55. package/dist/promise/catalog.d.ts +33 -0
  56. package/dist/promise/catalog.js +0 -0
  57. package/dist/promise/command.d.ts +22 -0
  58. package/dist/promise/command.js +0 -0
  59. package/dist/promise/event.d.ts +3 -0
  60. package/dist/promise/event.js +0 -0
  61. package/dist/promise/index.d.ts +19 -0
  62. package/dist/promise/index.js +17 -0
  63. package/dist/promise/integration.d.ts +79 -0
  64. package/dist/promise/integration.js +2 -0
  65. package/dist/promise/mcp.d.ts +15 -0
  66. package/dist/promise/mcp.js +0 -0
  67. package/dist/promise/permission.d.ts +21 -0
  68. package/dist/promise/permission.js +0 -0
  69. package/dist/promise/plugin.d.ts +57 -0
  70. package/dist/promise/plugin.js +3 -0
  71. package/dist/promise/reference.d.ts +13 -0
  72. package/dist/promise/reference.js +0 -0
  73. package/dist/promise/registration.d.ts +12 -0
  74. package/dist/promise/registration.js +0 -0
  75. package/dist/promise/rpc.d.ts +22 -0
  76. package/dist/promise/rpc.js +0 -0
  77. package/dist/promise/session.d.ts +107 -0
  78. package/dist/promise/session.js +0 -0
  79. package/dist/promise/shell.d.ts +14 -0
  80. package/dist/promise/shell.js +0 -0
  81. package/dist/promise/skill.d.ts +15 -0
  82. package/dist/promise/skill.js +0 -0
  83. package/dist/promise/storage.d.ts +8 -0
  84. package/dist/promise/storage.js +0 -0
  85. package/dist/promise/tool.d.ts +56 -0
  86. package/dist/promise/tool.js +2 -0
  87. package/dist/promise/types.d.ts +3 -0
  88. package/dist/promise/types.js +0 -0
  89. package/dist/promise/vcs.d.ts +50 -0
  90. package/dist/promise/vcs.js +0 -0
  91. package/dist/promise/websearch.d.ts +21 -0
  92. package/dist/promise/websearch.js +0 -0
  93. package/dist/promise/worktree.d.ts +23 -0
  94. package/dist/promise/worktree.js +0 -0
  95. package/dist/rpc.d.ts +1 -0
  96. package/dist/rpc.js +1 -0
  97. package/dist/source.bun.d.ts +4 -0
  98. package/dist/source.bun.js +62 -0
  99. package/dist/source.d.ts +8 -0
  100. package/dist/source.js +59 -0
  101. package/dist/source.node.d.ts +5 -0
  102. package/dist/source.node.js +45 -0
  103. package/dist/storage.d.ts +14 -0
  104. package/dist/storage.js +0 -0
  105. package/dist/tui/context.d.ts +458 -0
  106. package/dist/tui/context.js +0 -0
  107. package/dist/tui/index.d.ts +2 -0
  108. package/dist/tui/index.js +2 -0
  109. package/dist/tui/plugin.d.ts +8 -0
  110. package/dist/tui/plugin.js +3 -0
  111. package/dist/tui/solid.d.ts +7 -0
  112. package/dist/tui/solid.js +16 -0
  113. package/dist/worktree.d.ts +18 -0
  114. package/dist/worktree.js +0 -0
  115. package/package.json +83 -11
  116. package/README.md +0 -5
package/dist/app.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export interface App {
2
+ readonly name: string;
3
+ readonly version: string;
4
+ readonly channel: string;
5
+ }
package/dist/app.js ADDED
File without changes
@@ -0,0 +1,15 @@
1
+ import type { AgentApi } from "@opencode/client/effect/api";
2
+ import type { Agent } from "@opencode/schema/agent";
3
+ import type { Effect, Types } from "effect";
4
+ import type { Transform } from "./registration.js";
5
+ export interface AgentEditor {
6
+ list(): readonly Types.DeepMutable<Agent.Info>[];
7
+ get(id: string): Types.DeepMutable<Agent.Info> | undefined;
8
+ default(id: string | undefined): void;
9
+ update(id: string, update: (agent: Types.DeepMutable<Agent.Info>) => void): void;
10
+ remove(id: string): void;
11
+ }
12
+ export interface AgentDomain extends AgentApi<unknown> {
13
+ readonly transform: Transform<AgentEditor>;
14
+ readonly reload: () => Effect.Effect<void>;
15
+ }
File without changes
@@ -0,0 +1,20 @@
1
+ import type { LanguageModelV3 } from "@ai-sdk/provider";
2
+ import type { Model } from "@opencode/schema/model";
3
+ import type { ModelHooks } from "./registration.js";
4
+ export interface AISDKHooks {
5
+ sdk: {
6
+ readonly model: Model.Info;
7
+ readonly package: string;
8
+ readonly options: Record<string, any>;
9
+ sdk?: any;
10
+ };
11
+ language: {
12
+ readonly model: Model.Info;
13
+ readonly sdk: any;
14
+ readonly options: Record<string, any>;
15
+ language?: LanguageModelV3;
16
+ };
17
+ }
18
+ export interface AISDKDomain {
19
+ readonly hook: ModelHooks<AISDKHooks>;
20
+ }
File without changes
@@ -0,0 +1,33 @@
1
+ import type { CatalogApi } from "@opencode/client/effect/api";
2
+ import { Model } from "@opencode/schema/model";
3
+ import { Provider } from "@opencode/schema/provider";
4
+ import type { Effect, Types } from "effect";
5
+ import type { Transform } from "./registration.js";
6
+ export interface CatalogProviderRecord {
7
+ readonly provider: Types.DeepMutable<Provider.Info>;
8
+ readonly models: ReadonlyMap<string, Types.DeepMutable<Model.Info>>;
9
+ }
10
+ export interface CatalogEditor {
11
+ readonly provider: {
12
+ list(): readonly CatalogProviderRecord[];
13
+ get(providerID: string): CatalogProviderRecord | undefined;
14
+ update(providerID: string, update: (provider: Types.DeepMutable<Provider.Info>) => void): void;
15
+ remove(providerID: string): void;
16
+ };
17
+ readonly model: {
18
+ get(providerID: string, modelID: string): Types.DeepMutable<Model.Info> | undefined;
19
+ update(providerID: string, modelID: string, update: (model: Types.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<unknown> {
31
+ readonly transform: Transform<CatalogEditor>;
32
+ readonly reload: () => Effect.Effect<void>;
33
+ }
@@ -0,0 +1,2 @@
1
+ import { Model } from "@opencode/schema/model";
2
+ import { Provider } from "@opencode/schema/provider";
@@ -0,0 +1,23 @@
1
+ import type { CommandApi } from "@opencode/client/effect/api";
2
+ import type { PromptInput } from "@opencode/schema/prompt-input";
3
+ import type { Session } from "@opencode/schema/session";
4
+ import type { SessionInbox } from "@opencode/schema/session-inbox";
5
+ import type { Effect } from "effect";
6
+ import type { Transform } from "./registration.js";
7
+ export interface CommandInvocation {
8
+ readonly sessionID: Session.ID;
9
+ readonly prompt: PromptInput.Prompt;
10
+ readonly delivery: SessionInbox.Delivery;
11
+ }
12
+ export interface CommandDefinition {
13
+ readonly name: string;
14
+ readonly description?: string;
15
+ readonly execute: (input: CommandInvocation) => Effect.Effect<void, unknown>;
16
+ }
17
+ export interface CommandEditor {
18
+ add(definition: CommandDefinition): void;
19
+ }
20
+ export interface CommandDomain extends Pick<CommandApi<unknown>, "list"> {
21
+ readonly transform: Transform<CommandEditor>;
22
+ readonly reload: () => Effect.Effect<void>;
23
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ import type { EventApi } from "@opencode/client/effect/api";
2
+ export interface EventDomain extends Pick<EventApi<unknown>, "subscribe"> {
3
+ }
File without changes
@@ -0,0 +1,18 @@
1
+ export * as Plugin from "./plugin.js";
2
+ export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js";
3
+ export { Agent } from "@opencode/schema/agent";
4
+ export { Command } from "@opencode/schema/command";
5
+ export { Connection } from "@opencode/schema/connection";
6
+ export { Credential } from "@opencode/schema/credential";
7
+ export { Integration } from "@opencode/schema/integration";
8
+ export { Location } from "@opencode/schema/location";
9
+ export { Mcp } from "@opencode/schema/mcp";
10
+ export { Model } from "@opencode/schema/model";
11
+ export { PersistentPty } from "@opencode/schema/persistent-pty";
12
+ export { Provider } from "@opencode/schema/provider";
13
+ export { Reference } from "@opencode/schema/reference";
14
+ export { Rpc } from "@opencode/schema/rpc";
15
+ export { Skill } from "@opencode/schema/skill";
16
+ export { Vcs } from "@opencode/schema/vcs";
17
+ export { WebSearch } from "@opencode/schema/websearch";
18
+ export { Worktree } from "@opencode/schema/worktree";
@@ -0,0 +1,17 @@
1
+ export * as Plugin from "./plugin.js";
2
+ export { Agent } from "@opencode/schema/agent";
3
+ export { Command } from "@opencode/schema/command";
4
+ export { Connection } from "@opencode/schema/connection";
5
+ export { Credential } from "@opencode/schema/credential";
6
+ export { Integration } from "@opencode/schema/integration";
7
+ export { Location } from "@opencode/schema/location";
8
+ export { Mcp } from "@opencode/schema/mcp";
9
+ export { Model } from "@opencode/schema/model";
10
+ export { PersistentPty } from "@opencode/schema/persistent-pty";
11
+ export { Provider } from "@opencode/schema/provider";
12
+ export { Reference } from "@opencode/schema/reference";
13
+ export { Rpc } from "@opencode/schema/rpc";
14
+ export { Skill } from "@opencode/schema/skill";
15
+ export { Vcs } from "@opencode/schema/vcs";
16
+ export { WebSearch } from "@opencode/schema/websearch";
17
+ export { Worktree } from "@opencode/schema/worktree";
@@ -0,0 +1,80 @@
1
+ import type { ConnectionInfo } from "@opencode/client";
2
+ import type { IntegrationApi } from "@opencode/client/effect/api";
3
+ import { Credential } from "@opencode/schema/credential";
4
+ import { Form } from "@opencode/schema/form";
5
+ import type { Effect, Scope } from "effect";
6
+ import type { Transform } from "./registration.js";
7
+ type IntegrationRef = {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ export interface IntegrationOAuthMethod {
12
+ readonly id: string;
13
+ readonly type: "oauth";
14
+ readonly label: string;
15
+ readonly form?: Form.Fields;
16
+ }
17
+ export interface IntegrationCommandMethod {
18
+ readonly id: string;
19
+ readonly type: "command";
20
+ readonly label: string;
21
+ readonly command: ReadonlyArray<string>;
22
+ }
23
+ export interface IntegrationKeyMethod {
24
+ readonly type: "key";
25
+ readonly label?: string;
26
+ readonly form?: Form.Fields;
27
+ }
28
+ export interface IntegrationEnvMethod {
29
+ readonly type: "env";
30
+ readonly names: ReadonlyArray<string>;
31
+ }
32
+ export type IntegrationMethod = IntegrationOAuthMethod | IntegrationCommandMethod | IntegrationKeyMethod | IntegrationEnvMethod;
33
+ export type IntegrationOAuthAuthorization = {
34
+ readonly url: string;
35
+ readonly instructions: string;
36
+ readonly expiresAt?: number;
37
+ } & ({
38
+ readonly mode: "auto";
39
+ readonly callback: Effect.Effect<Credential.OAuth, unknown>;
40
+ } | {
41
+ readonly mode: "code";
42
+ readonly callback: (code: string) => Effect.Effect<Credential.OAuth, unknown>;
43
+ });
44
+ export type IntegrationOAuthMethodRegistration = {
45
+ readonly integrationID: string;
46
+ readonly method: IntegrationOAuthMethod;
47
+ readonly authorize: (answer: Form.Answer) => Effect.Effect<IntegrationOAuthAuthorization, unknown, Scope.Scope>;
48
+ readonly refresh?: (credential: Credential.OAuth) => Effect.Effect<Credential.OAuth, unknown>;
49
+ readonly label?: (credential: Credential.OAuth) => string | undefined;
50
+ };
51
+ export type IntegrationMethodRegistration = IntegrationOAuthMethodRegistration | {
52
+ readonly integrationID: string;
53
+ readonly method: IntegrationCommandMethod;
54
+ } | {
55
+ readonly integrationID: string;
56
+ readonly method: IntegrationKeyMethod;
57
+ } | {
58
+ readonly integrationID: string;
59
+ readonly method: IntegrationEnvMethod;
60
+ };
61
+ export interface IntegrationEditor {
62
+ list(): readonly IntegrationRef[];
63
+ get(id: string): IntegrationRef | undefined;
64
+ update(id: string, update: (integration: IntegrationRef) => void): void;
65
+ remove(id: string): void;
66
+ readonly method: {
67
+ list(integrationID: string): readonly IntegrationMethod[];
68
+ update(input: IntegrationMethodRegistration): void;
69
+ remove(integrationID: string, method: IntegrationMethod): void;
70
+ };
71
+ }
72
+ export interface IntegrationDomain extends Omit<IntegrationApi<unknown>, "wellknown"> {
73
+ readonly transform: Transform<IntegrationEditor>;
74
+ readonly reload: () => Effect.Effect<void>;
75
+ readonly connection: {
76
+ readonly active: (integrationID: string) => Effect.Effect<ConnectionInfo | undefined>;
77
+ readonly resolve: (connection: ConnectionInfo) => Effect.Effect<Credential.Value | undefined, unknown>;
78
+ };
79
+ }
80
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Credential } from "@opencode/schema/credential";
2
+ import { Form } from "@opencode/schema/form";
@@ -0,0 +1,15 @@
1
+ import type { McpApi } from "@opencode/client/effect/api";
2
+ import type { Mcp } from "@opencode/schema/mcp";
3
+ import type { Effect, Types } from "effect";
4
+ import type { Transform } from "./registration.js";
5
+ export interface MCPEditor {
6
+ list(): readonly [string, Types.DeepMutable<Mcp.ServerConfig>][];
7
+ get(name: string): Types.DeepMutable<Mcp.ServerConfig> | undefined;
8
+ set(name: string, config: Mcp.ServerConfig): void;
9
+ update(name: string, update: (config: Types.DeepMutable<Mcp.ServerConfig>) => void): void;
10
+ remove(name: string): void;
11
+ }
12
+ export interface MCPDomain extends Pick<McpApi<unknown>, "list"> {
13
+ readonly transform: Transform<MCPEditor>;
14
+ readonly reload: () => Effect.Effect<void>;
15
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ import type { PermissionApi } from "@opencode/client/effect/api";
2
+ import type { Agent } from "@opencode/schema/agent";
3
+ import type { Permission } from "@opencode/schema/permission";
4
+ import type { Session } from "@opencode/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<unknown>, "list" | "get" | "reply" | "rules"> & {
20
+ readonly hook: Hooks<PermissionHooks>;
21
+ };
File without changes
@@ -0,0 +1,56 @@
1
+ import type { ExperimentalApi, GenerateApi, PluginApi } from "@opencode/client/effect/api";
2
+ import type { Location } from "@opencode/schema/location";
3
+ import type { Effect, Scope } from "effect";
4
+ import type { PluginOptions } from "../options.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 { RpcDomain } from "./rpc.js";
16
+ import type { SessionDomain } from "./session.js";
17
+ import type { ShellDomain } from "./shell.js";
18
+ import type { SkillDomain } from "./skill.js";
19
+ import type { StorageDomain } from "./storage.js";
20
+ import type { ToolDomain } from "./tool.js";
21
+ import type { VcsDomain } from "./vcs.js";
22
+ import type { WebSearchDomain } from "./websearch.js";
23
+ import type { WorktreeDomain } from "./worktree.js";
24
+ export interface Context {
25
+ readonly app: App;
26
+ readonly location: Location.Info;
27
+ readonly options: PluginOptions;
28
+ readonly agent: AgentDomain;
29
+ readonly aisdk: AISDKDomain;
30
+ readonly catalog: CatalogDomain;
31
+ readonly command: CommandDomain;
32
+ readonly event: EventDomain;
33
+ readonly experimental: {
34
+ readonly terminal: Pick<ExperimentalApi<unknown>["persistentPty"], "read">;
35
+ };
36
+ readonly integration: IntegrationDomain;
37
+ readonly mcp: MCPDomain;
38
+ readonly generate: GenerateApi<unknown>;
39
+ readonly permission: PermissionDomain;
40
+ readonly plugin: Pick<PluginApi<unknown>, "list">;
41
+ readonly reference: ReferenceDomain;
42
+ readonly rpc: RpcDomain;
43
+ readonly session: SessionDomain;
44
+ readonly shell: ShellDomain;
45
+ readonly skill: SkillDomain;
46
+ readonly storage: StorageDomain;
47
+ readonly tool: ToolDomain;
48
+ readonly vcs: VcsDomain;
49
+ readonly websearch: WebSearchDomain;
50
+ readonly worktree: WorktreeDomain;
51
+ }
52
+ export interface Plugin<R = Scope.Scope> {
53
+ readonly id: string;
54
+ readonly effect: (context: Context) => Effect.Effect<void, never, R>;
55
+ }
56
+ export declare function define<R = Scope.Scope>(plugin: Plugin<R>): Plugin<R>;
@@ -0,0 +1,3 @@
1
+ export function define(plugin) {
2
+ return plugin;
3
+ }
@@ -0,0 +1,14 @@
1
+ import type { ReferenceGitSource, ReferenceLocalSource } from "@opencode/client";
2
+ import type { ReferenceApi } from "@opencode/client/effect/api";
3
+ import type { Effect } from "effect";
4
+ import type { Transform } from "./registration.js";
5
+ export interface ReferenceEditor {
6
+ add(name: string, source: ReferenceLocalSource | ReferenceGitSource): void;
7
+ remove(name: string): void;
8
+ list(): readonly (readonly [string, ReferenceLocalSource | ReferenceGitSource])[];
9
+ get(name: string): ReferenceLocalSource | ReferenceGitSource | undefined;
10
+ }
11
+ export interface ReferenceDomain extends ReferenceApi<unknown> {
12
+ readonly transform: Transform<ReferenceEditor>;
13
+ readonly reload: () => Effect.Effect<void>;
14
+ }
File without changes
@@ -0,0 +1,13 @@
1
+ import type { Effect, Scope } from "effect";
2
+ export interface Registration {
3
+ readonly dispose: Effect.Effect<void>;
4
+ }
5
+ export interface ModelHookOptions {
6
+ /** Limits the hook to one provider. Unscoped hooks apply to every provider. */
7
+ readonly providerID?: string;
8
+ }
9
+ export type Hooks<Spec, Failures extends Record<keyof Spec, unknown> = Record<keyof Spec, never>> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Effect.Effect<void, Failures[Name]>) => Effect.Effect<Registration, never, Scope.Scope>;
10
+ export type ModelHooks<Spec, Failures extends Record<keyof Spec, unknown> = Record<keyof Spec, never>> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Effect.Effect<void, Failures[Name]>, options?: Spec[Name] extends {
11
+ readonly model: unknown;
12
+ } ? ModelHookOptions : never) => Effect.Effect<Registration, never, Scope.Scope>;
13
+ export type Transform<Input> = (callback: (input: Input) => void) => Effect.Effect<Registration, never, Scope.Scope>;
File without changes
@@ -0,0 +1,19 @@
1
+ import type { RpcApi } from "@opencode/client/effect/api";
2
+ export type { RpcClient } from "@opencode/client/effect/api";
3
+ import type { Rpc } from "@opencode/schema/rpc";
4
+ import type { Effect, Scope } from "effect";
5
+ import type { Registration } from "./registration.js";
6
+ export interface RpcCallContext<M extends Rpc.Method> {
7
+ readonly error: Rpc.ErrorFactory<M>;
8
+ }
9
+ export type RpcHandlers<D extends Rpc.Definition> = {
10
+ readonly [Name in keyof D["methods"]]: (input: Rpc.Output<D["methods"][Name]["input"]>, context: RpcCallContext<D["methods"][Name]>) => Effect.Effect<Rpc.HandlerOutput<D["methods"][Name]["output"]>, Rpc.HandlerError<D["methods"][Name]>>;
11
+ };
12
+ export interface RpcRegistration<D extends Rpc.Definition> extends Registration {
13
+ readonly events: {
14
+ readonly emit: (...args: Rpc.EventInput<D>) => Effect.Effect<void, unknown>;
15
+ };
16
+ }
17
+ export interface RpcDomain extends RpcApi<Rpc.SystemError, never, unknown> {
18
+ readonly register: <const D extends Rpc.Definition>(definition: D, handlers: RpcHandlers<NoInfer<D>>) => Effect.Effect<RpcRegistration<D>, unknown, Scope.Scope>;
19
+ }
File without changes
@@ -0,0 +1,107 @@
1
+ import type { SessionApi } from "@opencode/client/effect/api";
2
+ import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai";
3
+ import type { Agent } from "@opencode/schema/agent";
4
+ import type { Model } from "@opencode/schema/model";
5
+ import type { PromptInput } from "@opencode/schema/prompt-input";
6
+ import type { Session } from "@opencode/schema/session";
7
+ import type { SessionInbox } from "@opencode/schema/session-inbox";
8
+ import type { SessionError } from "@opencode/schema/session-error";
9
+ import type { SessionMessage } from "@opencode/schema/session-message";
10
+ import type { TokenUsage } from "@opencode/schema/token-usage";
11
+ import type { JsonSchema, Types } from "effect";
12
+ import type { ModelHooks } from "./registration.js";
13
+ export interface SessionPrompt {
14
+ readonly sessionID: Session.ID;
15
+ readonly messageID: SessionMessage.ID;
16
+ prompt: Types.DeepMutable<PromptInput.Prompt>;
17
+ metadata?: Record<string, unknown>;
18
+ delivery: SessionInbox.Delivery;
19
+ }
20
+ /** Request overrides. Typed keys are generation settings; any other key is a provider option. */
21
+ export type SessionRequestOptions = Types.DeepMutable<GenerationOptionsFields> & Record<string, unknown>;
22
+ export interface SessionRequest {
23
+ readonly sessionID: Session.ID;
24
+ readonly model: Model.Ref;
25
+ system: Array<SystemPart>;
26
+ messages: Array<Message>;
27
+ options: SessionRequestOptions;
28
+ }
29
+ export interface SessionContext extends SessionRequest {
30
+ readonly agent: Agent.ID;
31
+ tools: Record<string, {
32
+ description: string;
33
+ input: JsonSchema.JsonSchema;
34
+ }>;
35
+ }
36
+ export interface SessionCompactionResult {
37
+ summary: string;
38
+ providerState?: SessionMessage.ProviderState;
39
+ metadata?: Record<string, unknown>;
40
+ tokens?: TokenUsage.Info;
41
+ }
42
+ export interface SessionCompaction extends SessionContext {
43
+ /** Set to use this compaction and skip the model request. */
44
+ result?: SessionCompactionResult;
45
+ }
46
+ export interface SessionGenerate extends SessionContext {
47
+ }
48
+ export interface SessionTitle extends SessionRequest {
49
+ /** Set to use this title and skip the model request. */
50
+ result?: string;
51
+ }
52
+ /**
53
+ * Why a Session request is being made. Auxiliary requests share the Session's
54
+ * hook identity but need to be told apart from the agent loop.
55
+ */
56
+ export type SessionRequestKind = "primary" | "compaction" | "title" | "generate";
57
+ export interface SessionModelRequest {
58
+ readonly sessionID: Session.ID;
59
+ readonly agent: Agent.ID;
60
+ readonly model: Model.Ref;
61
+ readonly kind: SessionRequestKind;
62
+ baseURL?: string;
63
+ headers: Record<string, string>;
64
+ }
65
+ export interface SessionHttpRequest {
66
+ readonly sessionID: Session.ID;
67
+ readonly agent: Agent.ID;
68
+ readonly model: Model.Ref;
69
+ readonly kind: SessionRequestKind;
70
+ request: Request;
71
+ }
72
+ export interface SessionHttpResponse {
73
+ readonly sessionID: Session.ID;
74
+ readonly agent: Agent.ID;
75
+ readonly model: Model.Ref;
76
+ readonly kind: SessionRequestKind;
77
+ readonly request: Request;
78
+ response: Response;
79
+ }
80
+ export type SessionRetryDecision = {
81
+ retry: false;
82
+ } | {
83
+ retry: true;
84
+ delay: number;
85
+ };
86
+ export interface SessionRetry {
87
+ readonly sessionID: Session.ID;
88
+ readonly agent: Agent.ID;
89
+ readonly model: Model.Ref;
90
+ readonly error: SessionError.Error;
91
+ readonly attempt: number;
92
+ decision: SessionRetryDecision;
93
+ }
94
+ export interface SessionHooks {
95
+ readonly prompt: SessionPrompt;
96
+ readonly context: SessionContext;
97
+ readonly compaction: SessionCompaction;
98
+ readonly generate: SessionGenerate;
99
+ readonly title: SessionTitle;
100
+ readonly "model.request": SessionModelRequest;
101
+ readonly "http.request": SessionHttpRequest;
102
+ readonly "http.response": SessionHttpResponse;
103
+ readonly retry: SessionRetry;
104
+ }
105
+ export type SessionDomain = Pick<SessionApi<unknown>, "create" | "get" | "switchAgent" | "switchModel" | "prompt" | "generate" | "command" | "synthetic" | "interrupt" | "rename" | "move" | "wait" | "context"> & {
106
+ readonly hook: ModelHooks<SessionHooks>;
107
+ };
File without changes
@@ -0,0 +1,14 @@
1
+ import type { Hooks } from "./registration.js";
2
+ export interface ShellCreateBefore {
3
+ command: string;
4
+ cwd: string;
5
+ timeout: number;
6
+ shell: string;
7
+ env: Record<string, string | undefined>;
8
+ }
9
+ export interface ShellHooks {
10
+ readonly "create.before": ShellCreateBefore;
11
+ }
12
+ export interface ShellDomain {
13
+ readonly hook: Hooks<ShellHooks>;
14
+ }
File without changes
@@ -0,0 +1,15 @@
1
+ import type { SkillApi } from "@opencode/client/effect/api";
2
+ import { Skill } from "@opencode/schema/skill";
3
+ import type { Effect, Types } from "effect";
4
+ import type { Transform } from "./registration.js";
5
+ export interface SkillEditor {
6
+ list(): readonly Types.DeepMutable<Skill.Info>[];
7
+ get(id: string): Types.DeepMutable<Skill.Info> | undefined;
8
+ add(skill: Skill.Info): void;
9
+ update(id: string, update: (skill: Types.DeepMutable<Skill.Info>) => void): void;
10
+ remove(id: string): void;
11
+ }
12
+ export interface SkillDomain extends SkillApi<unknown> {
13
+ readonly transform: Transform<SkillEditor>;
14
+ readonly reload: () => Effect.Effect<void>;
15
+ }
@@ -0,0 +1 @@
1
+ import { Skill } from "@opencode/schema/skill";
@@ -0,0 +1,8 @@
1
+ import type { Effect, Schema } from "effect";
2
+ import type { StorageScanOptions, StorageScanResult } from "../storage.js";
3
+ export interface StorageDomain {
4
+ readonly get: (key: string) => Effect.Effect<Schema.Json | undefined>;
5
+ readonly set: (key: string, value: Schema.Json) => Effect.Effect<void>;
6
+ readonly remove: (key: string) => Effect.Effect<void>;
7
+ readonly scan: (options: StorageScanOptions) => Effect.Effect<StorageScanResult>;
8
+ }
File without changes
@@ -0,0 +1,52 @@
1
+ import { Tool } from "@opencode/schema/tool";
2
+ import type { Agent } from "@opencode/schema/agent";
3
+ import type { Session } from "@opencode/schema/session";
4
+ import type { SessionMessage } from "@opencode/schema/session-message";
5
+ import type { Effect, Types } from "effect";
6
+ import type { Hooks, Transform } from "./registration.js";
7
+ export interface ToolEditor {
8
+ list(): readonly (Tool.Info & {
9
+ readonly id: string;
10
+ })[];
11
+ get(id: string): (Tool.Info & {
12
+ readonly id: string;
13
+ }) | undefined;
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;
16
+ /** Updates an existing tool; missing IDs are ignored. */
17
+ update(id: string, update: (tool: Types.Mutable<Tool.Info>) => void): void;
18
+ remove(id: string): void;
19
+ }
20
+ export interface ToolHooks {
21
+ readonly "execute.before": {
22
+ tool: string;
23
+ readonly sessionID: Session.ID;
24
+ readonly agent: Agent.ID;
25
+ readonly messageID: SessionMessage.ID;
26
+ readonly id: Tool.CallID;
27
+ input: unknown;
28
+ };
29
+ readonly "execute.after": {
30
+ readonly tool: string;
31
+ readonly sessionID: Session.ID;
32
+ readonly agent: Agent.ID;
33
+ readonly messageID: SessionMessage.ID;
34
+ readonly id: Tool.CallID;
35
+ readonly input: unknown;
36
+ } & ({
37
+ readonly status: "completed";
38
+ result: Tool.Result;
39
+ } | {
40
+ readonly status: "error";
41
+ error: Tool.Error;
42
+ });
43
+ }
44
+ export interface ToolFailures extends Record<keyof ToolHooks, unknown> {
45
+ readonly "execute.before": Tool.Error;
46
+ readonly "execute.after": never;
47
+ }
48
+ export interface ToolDomain {
49
+ readonly transform: Transform<ToolEditor>;
50
+ readonly reload: () => Effect.Effect<void>;
51
+ readonly hook: Hooks<ToolHooks, ToolFailures>;
52
+ }
@@ -0,0 +1 @@
1
+ import { Tool } from "@opencode/schema/tool";