@radheim/plugin 0.0.0-stage → 2.4.3

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 (170) hide show
  1. package/README.md +19 -3
  2. package/dist/app.d.ts +5 -0
  3. package/dist/app.js +0 -0
  4. package/dist/effect/agent.d.ts +15 -0
  5. package/dist/effect/agent.js +0 -0
  6. package/dist/effect/aisdk.d.ts +20 -0
  7. package/dist/effect/aisdk.js +0 -0
  8. package/dist/effect/artifact.d.ts +42 -0
  9. package/dist/effect/artifact.js +0 -0
  10. package/dist/effect/command.d.ts +23 -0
  11. package/dist/effect/command.js +0 -0
  12. package/dist/effect/event.d.ts +9 -0
  13. package/dist/effect/event.js +0 -0
  14. package/dist/effect/index.d.ts +20 -0
  15. package/dist/effect/index.js +19 -0
  16. package/dist/effect/integration.d.ts +103 -0
  17. package/dist/effect/integration.js +3 -0
  18. package/dist/effect/mcp.d.ts +15 -0
  19. package/dist/effect/mcp.js +0 -0
  20. package/dist/effect/model.d.ts +29 -0
  21. package/dist/effect/model.js +0 -0
  22. package/dist/effect/permission.d.ts +30 -0
  23. package/dist/effect/permission.js +0 -0
  24. package/dist/effect/plugin.d.ts +69 -0
  25. package/dist/effect/plugin.js +3 -0
  26. package/dist/effect/provider.d.ts +34 -0
  27. package/dist/effect/provider.js +0 -0
  28. package/dist/effect/push.d.ts +52 -0
  29. package/dist/effect/push.js +0 -0
  30. package/dist/effect/reference.d.ts +14 -0
  31. package/dist/effect/reference.js +0 -0
  32. package/dist/effect/registration.d.ts +13 -0
  33. package/dist/effect/registration.js +0 -0
  34. package/dist/effect/rpc.d.ts +19 -0
  35. package/dist/effect/rpc.js +0 -0
  36. package/dist/effect/session.d.ts +217 -0
  37. package/dist/effect/session.js +0 -0
  38. package/dist/effect/shell.d.ts +14 -0
  39. package/dist/effect/shell.js +0 -0
  40. package/dist/effect/skill.d.ts +15 -0
  41. package/dist/effect/skill.js +1 -0
  42. package/dist/effect/storage.d.ts +8 -0
  43. package/dist/effect/storage.js +0 -0
  44. package/dist/effect/tool.d.ts +60 -0
  45. package/dist/effect/tool.js +1 -0
  46. package/dist/effect/vcs.d.ts +43 -0
  47. package/dist/effect/vcs.js +0 -0
  48. package/dist/effect/websearch.d.ts +20 -0
  49. package/dist/effect/websearch.js +0 -0
  50. package/dist/effect/worktree.d.ts +18 -0
  51. package/dist/effect/worktree.js +0 -0
  52. package/dist/gui/browser.d.ts +54 -0
  53. package/dist/gui/browser.js +3 -0
  54. package/dist/gui/context.d.ts +287 -0
  55. package/dist/gui/context.js +0 -0
  56. package/dist/gui/core.d.ts +581 -0
  57. package/dist/gui/core.js +86 -0
  58. package/dist/gui/declarations.d.ts +47 -0
  59. package/dist/gui/declarations.js +0 -0
  60. package/dist/gui/file.d.ts +122 -0
  61. package/dist/gui/file.js +7 -0
  62. package/dist/gui/host-apis.d.ts +2239 -0
  63. package/dist/gui/host-apis.js +0 -0
  64. package/dist/gui/icon-name.d.ts +2 -0
  65. package/dist/gui/icon-name.js +1 -0
  66. package/dist/gui/index.d.ts +7 -0
  67. package/dist/gui/index.js +6 -0
  68. package/dist/gui/internal.d.ts +44 -0
  69. package/dist/gui/internal.js +33 -0
  70. package/dist/gui/main.d.ts +279 -0
  71. package/dist/gui/main.js +20 -0
  72. package/dist/gui/modules.d.ts +15 -0
  73. package/dist/gui/modules.js +30 -0
  74. package/dist/gui/plugin.d.ts +87 -0
  75. package/dist/gui/plugin.js +9 -0
  76. package/dist/gui/reactive.d.ts +93 -0
  77. package/dist/gui/reactive.js +130 -0
  78. package/dist/gui/registries.d.ts +1045 -0
  79. package/dist/gui/registries.js +153 -0
  80. package/dist/gui/review.d.ts +74 -0
  81. package/dist/gui/review.js +3 -0
  82. package/dist/gui/scope.d.ts +64 -0
  83. package/dist/gui/scope.js +85 -0
  84. package/dist/gui/solid.d.ts +111 -0
  85. package/dist/gui/solid.js +74 -0
  86. package/dist/gui/vite.d.ts +24 -0
  87. package/dist/gui/vite.js +49 -0
  88. package/dist/host.d.ts +23 -0
  89. package/dist/host.js +65 -0
  90. package/dist/options.d.ts +1 -0
  91. package/dist/options.js +0 -0
  92. package/dist/permission.d.ts +22 -0
  93. package/dist/permission.js +12 -0
  94. package/dist/promise/adapter.d.ts +12 -0
  95. package/dist/promise/adapter.js +576 -0
  96. package/dist/promise/agent.d.ts +15 -0
  97. package/dist/promise/agent.js +0 -0
  98. package/dist/promise/aisdk.d.ts +20 -0
  99. package/dist/promise/aisdk.js +0 -0
  100. package/dist/promise/artifact.d.ts +49 -0
  101. package/dist/promise/artifact.js +0 -0
  102. package/dist/promise/command.d.ts +22 -0
  103. package/dist/promise/command.js +0 -0
  104. package/dist/promise/event.d.ts +7 -0
  105. package/dist/promise/event.js +0 -0
  106. package/dist/promise/index.d.ts +20 -0
  107. package/dist/promise/index.js +18 -0
  108. package/dist/promise/integration.d.ts +102 -0
  109. package/dist/promise/integration.js +3 -0
  110. package/dist/promise/mcp.d.ts +15 -0
  111. package/dist/promise/mcp.js +0 -0
  112. package/dist/promise/model.d.ts +29 -0
  113. package/dist/promise/model.js +0 -0
  114. package/dist/promise/permission.d.ts +29 -0
  115. package/dist/promise/permission.js +0 -0
  116. package/dist/promise/plugin.d.ts +70 -0
  117. package/dist/promise/plugin.js +3 -0
  118. package/dist/promise/provider.d.ts +34 -0
  119. package/dist/promise/provider.js +0 -0
  120. package/dist/promise/push.d.ts +50 -0
  121. package/dist/promise/push.js +0 -0
  122. package/dist/promise/reference.d.ts +13 -0
  123. package/dist/promise/reference.js +0 -0
  124. package/dist/promise/registration.d.ts +12 -0
  125. package/dist/promise/registration.js +0 -0
  126. package/dist/promise/rpc.d.ts +22 -0
  127. package/dist/promise/rpc.js +0 -0
  128. package/dist/promise/session.d.ts +217 -0
  129. package/dist/promise/session.js +0 -0
  130. package/dist/promise/shell.d.ts +14 -0
  131. package/dist/promise/shell.js +0 -0
  132. package/dist/promise/skill.d.ts +15 -0
  133. package/dist/promise/skill.js +0 -0
  134. package/dist/promise/storage.d.ts +8 -0
  135. package/dist/promise/storage.js +0 -0
  136. package/dist/promise/tool.d.ts +71 -0
  137. package/dist/promise/tool.js +2 -0
  138. package/dist/promise/vcs.d.ts +53 -0
  139. package/dist/promise/vcs.js +0 -0
  140. package/dist/promise/websearch.d.ts +21 -0
  141. package/dist/promise/websearch.js +0 -0
  142. package/dist/promise/worktree.d.ts +23 -0
  143. package/dist/promise/worktree.js +0 -0
  144. package/dist/rpc.d.ts +1 -0
  145. package/dist/rpc.js +1 -0
  146. package/dist/runtime-modules.d.ts +6 -0
  147. package/dist/runtime-modules.js +103 -0
  148. package/dist/runtime.d.ts +4 -0
  149. package/dist/runtime.js +46 -0
  150. package/dist/source.bun.d.ts +4 -0
  151. package/dist/source.bun.js +75 -0
  152. package/dist/source.d.ts +8 -0
  153. package/dist/source.js +59 -0
  154. package/dist/source.node.d.ts +5 -0
  155. package/dist/source.node.js +55 -0
  156. package/dist/source.package.d.ts +1 -0
  157. package/dist/source.package.js +15 -0
  158. package/dist/storage.d.ts +14 -0
  159. package/dist/storage.js +0 -0
  160. package/dist/tui/context.d.ts +500 -0
  161. package/dist/tui/context.js +0 -0
  162. package/dist/tui/index.d.ts +2 -0
  163. package/dist/tui/index.js +2 -0
  164. package/dist/tui/plugin.d.ts +8 -0
  165. package/dist/tui/plugin.js +3 -0
  166. package/dist/tui/solid.d.ts +7 -0
  167. package/dist/tui/solid.js +16 -0
  168. package/dist/worktree.d.ts +18 -0
  169. package/dist/worktree.js +0 -0
  170. package/package.json +137 -4
package/README.md CHANGED
@@ -1,3 +1,19 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # `@radheim/plugin`
2
+
3
+ Authoring interfaces and runtime loader support for OpenCode V2 plugins:
4
+
5
+ - `@radheim/plugin` — [Promise plugin API](./src/README.md)
6
+ - `@radheim/plugin/effect` — [Effect plugin API](./src/effect/README.md)
7
+ - `@radheim/plugin/rpc` — portable RPC contract definitions
8
+ - `@radheim/plugin/tui` - terminal UI plugin API
9
+ - `@radheim/plugin/gui/browser` - desktop pane contract, including experimental scoped tab handles
10
+
11
+ ## Packaging And Runtime `effect`
12
+
13
+ When the OpenCode CLI loads server or TUI plugins, it resolves imports of `effect`, exported `effect/*` subpaths, and `@radheim/plugin` entrypoints (including imports from dependencies inside a plugin's `node_modules`) to the host's runtime module instances so fibers, loggers, and `Schema` parsers share one copy.
14
+
15
+ - Declare `"effect": "^4.0.0"` as a `peerDependency` (and `devDependency` for local type-checking and testing) rather than a bundled runtime dependency.
16
+ - Do not bundle `effect` into published plugin files; if you build with a bundler, keep `effect` and `effect/*` external. Two copies of `effect` do not share fiber, logger, or `Schema` internals.
17
+ - Plugins and their `node_modules` dependencies always receive OpenCode's host `effect` instance. Use `effect` APIs and module paths compatible with the OpenCode release you target; dependencies built on another `effect` major (such as Effect 3) are not supported.
18
+ - Only public `effect` subpaths are provided. A plugin that imports one of Effect's private `internal` modules fails to load with an error naming the path.
19
+ - The compiled OpenCode binary does not include the Scalar and Swagger UI assets used by Effect's HTTP API docs pages; serving those pages from a plugin shows a notice instead.
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 "@radheim/client/effect/api";
2
+ import type { Agent } from "@radheim/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 "@radheim/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,42 @@
1
+ import type { Artifact } from "@radheim/schema/artifact";
2
+ import type { Session } from "@radheim/schema/session";
3
+ import type { Effect } from "effect";
4
+ import type { Transform } from "./registration.js";
5
+ export interface ArtifactProviderCreateInput {
6
+ readonly id: Artifact.ID;
7
+ readonly title: string;
8
+ readonly entry: string;
9
+ readonly files: Readonly<Record<string, Uint8Array>>;
10
+ readonly sessionID?: Session.ID;
11
+ }
12
+ export interface ArtifactProviderUpdateInput {
13
+ readonly title: string;
14
+ readonly entry: string;
15
+ readonly files: Readonly<Record<string, Uint8Array>>;
16
+ readonly sessionID?: Session.ID;
17
+ }
18
+ export interface ArtifactProviderResult {
19
+ readonly url?: string;
20
+ }
21
+ export interface ArtifactProviderDefinition {
22
+ readonly id: string;
23
+ readonly name: string;
24
+ readonly capabilities: readonly Artifact.Capability[];
25
+ readonly prompt: string;
26
+ readonly create: (input: ArtifactProviderCreateInput) => Effect.Effect<ArtifactProviderResult, unknown>;
27
+ readonly read: (id: Artifact.ID) => Effect.Effect<Readonly<Record<string, Uint8Array>>, unknown>;
28
+ readonly update: (id: Artifact.ID, input: ArtifactProviderUpdateInput) => Effect.Effect<ArtifactProviderResult, unknown>;
29
+ readonly delete: (id: Artifact.ID) => Effect.Effect<void, unknown>;
30
+ }
31
+ export interface ArtifactEditor {
32
+ add(definition: ArtifactProviderDefinition): void;
33
+ remove(id: string): void;
34
+ readonly default: {
35
+ get(): string | undefined;
36
+ set(providerID: string | undefined): void;
37
+ };
38
+ }
39
+ export interface ExperimentalArtifactDomain {
40
+ readonly transform: Transform<ArtifactEditor>;
41
+ readonly reload: () => Effect.Effect<void>;
42
+ }
File without changes
@@ -0,0 +1,23 @@
1
+ import type { CommandApi } from "@radheim/client/effect/api";
2
+ import type { PromptInput } from "@radheim/schema/prompt-input";
3
+ import type { Session } from "@radheim/schema/session";
4
+ import type { SessionInbox } from "@radheim/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,9 @@
1
+ import type { EventSubscribeInput, EventSubscribeOutput, SelectedEvent } from "@radheim/client/effect/api";
2
+ import type { Stream } from "effect";
3
+ type EventType = NonNullable<EventSubscribeInput["types"]>[number];
4
+ export interface EventDomain {
5
+ readonly subscribe: <Type extends EventType = EventType>(input?: {
6
+ readonly types?: ReadonlyArray<Type>;
7
+ }) => Stream.Stream<SelectedEvent<EventSubscribeOutput, Type>, unknown>;
8
+ }
9
+ export {};
File without changes
@@ -0,0 +1,20 @@
1
+ export * as Plugin from "./plugin.js";
2
+ export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js";
3
+ export { Agent } from "@radheim/schema/agent";
4
+ export { Artifact } from "@radheim/schema/artifact";
5
+ export { Command } from "@radheim/schema/command";
6
+ export { Connection } from "@radheim/schema/connection";
7
+ export { Credential } from "@radheim/schema/credential";
8
+ export { Integration } from "@radheim/schema/integration";
9
+ export { Location } from "@radheim/schema/location";
10
+ export { Mcp } from "@radheim/schema/mcp";
11
+ export { Model } from "@radheim/schema/model";
12
+ export { PersistentPty } from "@radheim/schema/persistent-pty";
13
+ export { Provider } from "@radheim/schema/provider";
14
+ export { Reference } from "@radheim/schema/reference";
15
+ export { Rpc } from "@radheim/schema/rpc";
16
+ export { Skill } from "@radheim/schema/skill";
17
+ export { Tool } from "@radheim/schema/tool";
18
+ export { Vcs } from "@radheim/schema/vcs";
19
+ export { WebSearch } from "@radheim/schema/websearch";
20
+ export { Worktree } from "@radheim/schema/worktree";
@@ -0,0 +1,19 @@
1
+ export * as Plugin from "./plugin.js";
2
+ export { Agent } from "@radheim/schema/agent";
3
+ export { Artifact } from "@radheim/schema/artifact";
4
+ export { Command } from "@radheim/schema/command";
5
+ export { Connection } from "@radheim/schema/connection";
6
+ export { Credential } from "@radheim/schema/credential";
7
+ export { Integration } from "@radheim/schema/integration";
8
+ export { Location } from "@radheim/schema/location";
9
+ export { Mcp } from "@radheim/schema/mcp";
10
+ export { Model } from "@radheim/schema/model";
11
+ export { PersistentPty } from "@radheim/schema/persistent-pty";
12
+ export { Provider } from "@radheim/schema/provider";
13
+ export { Reference } from "@radheim/schema/reference";
14
+ export { Rpc } from "@radheim/schema/rpc";
15
+ export { Skill } from "@radheim/schema/skill";
16
+ export { Tool } from "@radheim/schema/tool";
17
+ export { Vcs } from "@radheim/schema/vcs";
18
+ export { WebSearch } from "@radheim/schema/websearch";
19
+ export { Worktree } from "@radheim/schema/worktree";
@@ -0,0 +1,103 @@
1
+ import type { ConnectionInfo } from "@radheim/client";
2
+ import type { IntegrationApi } from "@radheim/client/effect/api";
3
+ import { Connection } from "@radheim/schema/connection";
4
+ import { Credential } from "@radheim/schema/credential";
5
+ import { Form } from "@radheim/schema/form";
6
+ import type { Effect, Scope } from "effect";
7
+ import type { Transform } from "./registration.js";
8
+ type IntegrationRef = {
9
+ id: string;
10
+ name: string;
11
+ };
12
+ export interface IntegrationOAuthMethod {
13
+ readonly id: string;
14
+ readonly type: "oauth";
15
+ readonly label: string;
16
+ readonly form?: Form.Fields;
17
+ }
18
+ export interface IntegrationCommandMethod {
19
+ readonly id: string;
20
+ readonly type: "command";
21
+ readonly label: string;
22
+ readonly command: ReadonlyArray<string>;
23
+ }
24
+ export interface IntegrationKeyMethod {
25
+ readonly type: "key";
26
+ readonly label?: string;
27
+ readonly form?: Form.Fields;
28
+ }
29
+ export interface IntegrationExternalMethod {
30
+ readonly id: string;
31
+ readonly type: "external";
32
+ readonly label: string;
33
+ readonly form?: Form.Fields;
34
+ }
35
+ export interface IntegrationEnvMethod {
36
+ readonly type: "env";
37
+ readonly names: ReadonlyArray<string>;
38
+ }
39
+ export type IntegrationMethod = IntegrationOAuthMethod | IntegrationCommandMethod | IntegrationKeyMethod | IntegrationExternalMethod | IntegrationEnvMethod;
40
+ export type IntegrationOAuthAuthorization = {
41
+ readonly url: string;
42
+ readonly instructions: string;
43
+ readonly expiresAt?: number;
44
+ } & ({
45
+ readonly mode: "auto";
46
+ readonly callback: Effect.Effect<Credential.OAuth, unknown>;
47
+ /**
48
+ * Accepts the redirect URL a user pasted when the browser could not reach this machine, and settles `callback`
49
+ * with it. Check the URL's `state` as the browser path does; a failure rejects only this paste.
50
+ */
51
+ readonly submit?: (redirect: string) => Effect.Effect<void, unknown>;
52
+ } | {
53
+ readonly mode: "code";
54
+ readonly callback: (code: string) => Effect.Effect<Credential.OAuth, unknown>;
55
+ });
56
+ export type IntegrationOAuthMethodRegistration = {
57
+ readonly integrationID: string;
58
+ readonly method: IntegrationOAuthMethod;
59
+ readonly authorize: (answer: Form.Answer) => Effect.Effect<IntegrationOAuthAuthorization, unknown, Scope.Scope>;
60
+ readonly refresh?: (credential: Credential.OAuth) => Effect.Effect<Credential.OAuth, unknown>;
61
+ /** Signs the credential out remotely before it is removed. A failure is logged and the credential is still removed. */
62
+ readonly revoke?: (credential: Credential.OAuth) => Effect.Effect<void, unknown>;
63
+ readonly label?: (credential: Credential.OAuth) => string | undefined;
64
+ };
65
+ export type IntegrationMethodRegistration = IntegrationOAuthMethodRegistration | {
66
+ readonly integrationID: string;
67
+ readonly method: IntegrationCommandMethod;
68
+ } | {
69
+ readonly integrationID: string;
70
+ readonly method: IntegrationKeyMethod;
71
+ } | {
72
+ readonly integrationID: string;
73
+ readonly method: IntegrationExternalMethod;
74
+ } | {
75
+ readonly integrationID: string;
76
+ readonly method: IntegrationEnvMethod;
77
+ };
78
+ export interface IntegrationEditor {
79
+ list(): readonly IntegrationRef[];
80
+ get(id: string): IntegrationRef | undefined;
81
+ update(id: string, update: (integration: IntegrationRef) => void): void;
82
+ remove(id: string): void;
83
+ readonly method: {
84
+ list(integrationID: string): readonly IntegrationMethod[];
85
+ update(input: IntegrationMethodRegistration): void;
86
+ remove(integrationID: string, method: IntegrationMethod): void;
87
+ };
88
+ }
89
+ export interface IntegrationDomain extends Omit<IntegrationApi<unknown>, "wellknown"> {
90
+ readonly transform: Transform<IntegrationEditor>;
91
+ readonly reload: () => Effect.Effect<void>;
92
+ readonly connection: {
93
+ readonly active: (integrationID: string) => Effect.Effect<ConnectionInfo | undefined>;
94
+ readonly resolve: (connection: ConnectionInfo) => Effect.Effect<Credential.Value | undefined, unknown>;
95
+ /** Reports a problem with a connection, such as a required sign-in; `undefined` clears it. */
96
+ readonly status: (input: {
97
+ readonly integrationID: string;
98
+ readonly connection: ConnectionInfo;
99
+ readonly status: Connection.Status | undefined;
100
+ }) => Effect.Effect<void>;
101
+ };
102
+ }
103
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Connection } from "@radheim/schema/connection";
2
+ import { Credential } from "@radheim/schema/credential";
3
+ import { Form } from "@radheim/schema/form";
@@ -0,0 +1,15 @@
1
+ import type { McpApi } from "@radheim/client/effect/api";
2
+ import type { Mcp } from "@radheim/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,29 @@
1
+ import type { ModelApi } from "@radheim/client/effect/api";
2
+ import type { Model } from "@radheim/schema/model";
3
+ import type { Effect, Types } from "effect";
4
+ import type { ProviderRecord } from "./provider.js";
5
+ import type { Transform } from "./registration.js";
6
+ export interface ModelEditor {
7
+ /** Candidates from available providers, including models disabled by earlier transforms. */
8
+ list(providerID?: string): readonly Types.DeepMutable<Model.Info>[];
9
+ get(providerID: string, modelID: string): Types.DeepMutable<Model.Info> | undefined;
10
+ /** Edits raw model overrides; cannot create an unavailable provider. */
11
+ update(providerID: string, modelID: string, update: (model: Types.DeepMutable<Model.Info>) => void): void;
12
+ remove(providerID: string, modelID: string): void;
13
+ readonly default: {
14
+ get(): {
15
+ providerID: string;
16
+ modelID: string;
17
+ } | undefined;
18
+ set(providerID: string, modelID: string): void;
19
+ };
20
+ /** Immutable provider inputs, including inactive templates, before model transforms. */
21
+ readonly provider: {
22
+ list(): readonly ProviderRecord[];
23
+ get(providerID: string): ProviderRecord | undefined;
24
+ };
25
+ }
26
+ export interface ModelDomain extends ModelApi<unknown> {
27
+ readonly transform: Transform<ModelEditor>;
28
+ readonly reload: () => Effect.Effect<void>;
29
+ }
File without changes
@@ -0,0 +1,30 @@
1
+ import type { PermissionApi } from "@radheim/client/effect/api";
2
+ import type { Agent } from "@radheim/schema/agent";
3
+ import type { Permission } from "@radheim/schema/permission";
4
+ import type { Session } from "@radheim/schema/session";
5
+ import type { Tool } from "@radheim/schema/tool";
6
+ import type { Effect } from "effect";
7
+ import type { AssertInput } from "../permission.js";
8
+ import type { Hooks } from "./registration.js";
9
+ export interface PermissionEvaluation {
10
+ readonly sessionID: Session.ID;
11
+ readonly agent?: Agent.ID;
12
+ readonly action: string;
13
+ readonly resources: ReadonlyArray<string>;
14
+ readonly metadata?: Record<string, unknown>;
15
+ readonly source?: Permission.Source;
16
+ effect: Permission.Effect;
17
+ message?: string;
18
+ }
19
+ export interface PermissionHooks {
20
+ readonly evaluate: PermissionEvaluation;
21
+ }
22
+ export type PermissionDomain = Pick<PermissionApi<unknown>, "list" | "get" | "reply"> & {
23
+ readonly hook: Hooks<PermissionHooks>;
24
+ /**
25
+ * Evaluates the session's permission rules and, when approval is required, prompts the user and
26
+ * waits for the reply. Succeeds when allowed. A deny rule or a rejection with feedback fails with a
27
+ * `Tool.Error` carrying the reason; a plain rejection ends the current step.
28
+ */
29
+ readonly assert: (input: AssertInput) => Effect.Effect<void, Tool.Error>;
30
+ };
File without changes
@@ -0,0 +1,69 @@
1
+ import type { CredentialApi, ExperimentalApi, ExperimentalGenerateApi, PluginApi } from "@radheim/client/effect/api";
2
+ import type { Location } from "@radheim/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 { ExperimentalArtifactDomain } from "./artifact.js";
8
+ import type { AISDKDomain } from "./aisdk.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 { ModelDomain } from "./model.js";
14
+ import type { PermissionDomain } from "./permission.js";
15
+ import type { ProviderDomain } from "./provider.js";
16
+ import type { ExperimentalPushDomain } from "./push.js";
17
+ import type { ReferenceDomain } from "./reference.js";
18
+ import type { RpcDomain } from "./rpc.js";
19
+ import type { SessionDomain } from "./session.js";
20
+ import type { ShellDomain } from "./shell.js";
21
+ import type { SkillDomain } from "./skill.js";
22
+ import type { StorageDomain } from "./storage.js";
23
+ import type { ToolDomain } from "./tool.js";
24
+ import type { VcsDomain } from "./vcs.js";
25
+ import type { WebSearchDomain } from "./websearch.js";
26
+ import type { WorktreeDomain } from "./worktree.js";
27
+ export interface Context {
28
+ readonly app: App;
29
+ readonly location: Location.Info;
30
+ readonly options: PluginOptions;
31
+ readonly agent: AgentDomain;
32
+ readonly aisdk: AISDKDomain;
33
+ readonly command: CommandDomain;
34
+ readonly credential: Pick<CredentialApi<unknown>, "activate">;
35
+ readonly event: EventDomain;
36
+ readonly experimental: {
37
+ readonly terminal: Pick<ExperimentalApi<unknown>["persistentPty"], "read">;
38
+ /** Stateless generation with a model and a prompt: no session, history or tools. Video jobs are server-only for now. */
39
+ readonly generate: Omit<ExperimentalGenerateApi<unknown>, "video">;
40
+ readonly artifact: ExperimentalArtifactDomain;
41
+ /** Create, list and delete automations. Creation fails while automations are off where they would run. */
42
+ readonly automation: Pick<ExperimentalApi<unknown>["automation"], "create" | "list" | "delete">;
43
+ /** Send phone notifications, and edit or drop them before they are sent. */
44
+ readonly push: ExperimentalPushDomain;
45
+ };
46
+ readonly integration: IntegrationDomain;
47
+ readonly mcp: MCPDomain;
48
+ readonly model: ModelDomain;
49
+ /** @deprecated Use `experimental.generate.text`. */
50
+ readonly generate: Pick<ExperimentalGenerateApi<unknown>, "text">;
51
+ readonly permission: PermissionDomain;
52
+ readonly plugin: Pick<PluginApi<unknown>, "list">;
53
+ readonly provider: ProviderDomain;
54
+ readonly reference: ReferenceDomain;
55
+ readonly rpc: RpcDomain;
56
+ readonly session: SessionDomain;
57
+ readonly shell: ShellDomain;
58
+ readonly skill: SkillDomain;
59
+ readonly storage: StorageDomain;
60
+ readonly tool: ToolDomain;
61
+ readonly vcs: VcsDomain;
62
+ readonly websearch: WebSearchDomain;
63
+ readonly worktree: WorktreeDomain;
64
+ }
65
+ export interface Plugin<R = Scope.Scope> {
66
+ readonly id: string;
67
+ readonly effect: (context: Context) => Effect.Effect<void, never, R>;
68
+ }
69
+ 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,34 @@
1
+ import type { ProviderApi } from "@radheim/client/effect/api";
2
+ import type { Model } from "@radheim/schema/model";
3
+ import type { Provider } from "@radheim/schema/provider";
4
+ import type { ConnectionInfo } from "@radheim/client";
5
+ import type { Effect, Types } from "effect";
6
+ import type { Transform } from "./registration.js";
7
+ /** Provider metadata and immutable source definitions, including inactive providers. */
8
+ export interface ProviderRecord {
9
+ readonly provider: Provider.Info;
10
+ readonly models: ReadonlyMap<string, Model.Info>;
11
+ readonly sourceConnection?: ConnectionInfo;
12
+ }
13
+ export interface ProviderEditor {
14
+ list(): readonly ProviderRecord[];
15
+ get(providerID: string): ProviderRecord | undefined;
16
+ /** A discovered account-specific inventory can be bound to the connection that produced it. */
17
+ add(input: {
18
+ info: Provider.Info;
19
+ models: readonly Model.Info[];
20
+ sourceConnection?: ConnectionInfo;
21
+ }): void;
22
+ update(providerID: string, update: (provider: Types.DeepMutable<Provider.Info>) => void): void;
23
+ remove(providerID: string): void;
24
+ readonly models: {
25
+ set(providerID: string, models: readonly Model.Info[]): void;
26
+ /** Updates an owned copy of a source definition. */
27
+ update(providerID: string, modelID: string, update: (model: Types.DeepMutable<Model.Info>) => void): void;
28
+ remove(providerID: string, modelID: string): void;
29
+ };
30
+ }
31
+ export interface ProviderDomain extends ProviderApi<unknown> {
32
+ readonly transform: Transform<ProviderEditor>;
33
+ readonly reload: () => Effect.Effect<void>;
34
+ }
File without changes
@@ -0,0 +1,52 @@
1
+ import type { Push } from "@radheim/schema/push";
2
+ import type { Session } from "@radheim/schema/session";
3
+ import type { Effect } from "effect";
4
+ import type { Hooks } from "./registration.js";
5
+ /**
6
+ * A phone notification about to be sent. Only `title`, `body`, `attention`, `data` and `skip` can be changed;
7
+ * changes to the other fields are ignored.
8
+ */
9
+ export interface PushSend {
10
+ /** What a later clear names: the permission request, the form, the session for a finished turn, or a plugin's id. */
11
+ readonly id: string;
12
+ /** `plugin` for a notification a plugin sent. */
13
+ readonly type: "turn" | "form" | "permission" | "plugin";
14
+ /** The session to open: the top-level one, or the one a plugin named. And the folder it works in. */
15
+ readonly sessionID: string;
16
+ readonly directory: string;
17
+ /** When the event happened, in ms since the epoch. */
18
+ readonly time: number;
19
+ /** True when the notification needs the person. Phones at the `attention` level get only these. */
20
+ attention: boolean;
21
+ /**
22
+ * For a `type` it knows, a phone builds what it shows from `data` and falls back to `title` and `body`. To change
23
+ * what it shows, replace the object: `event.data = { ...event.data, text: summary }`.
24
+ */
25
+ data: Push.Data;
26
+ title: string;
27
+ body: string;
28
+ /** Set to true to not send the notification. */
29
+ skip: boolean;
30
+ }
31
+ export interface PushHooks {
32
+ readonly send: PushSend;
33
+ }
34
+ /** A phone notification a plugin sends. */
35
+ export interface PushNotification {
36
+ /** Sending the same id again replaces the notification on the phone. */
37
+ readonly id: string;
38
+ /** Tapping the notification opens this session. */
39
+ readonly sessionID: Session.ID;
40
+ /** Defaults to the session's title. */
41
+ readonly title?: string;
42
+ readonly body: string;
43
+ /** True also reaches phones whose level is `attention`. Defaults to false. */
44
+ readonly attention?: boolean;
45
+ }
46
+ export interface ExperimentalPushDomain {
47
+ readonly hook: Hooks<PushHooks>;
48
+ /** Runs this location's `send` hooks, then sends to the phones that want it. Does nothing when no phone is registered. */
49
+ readonly send: (notification: PushNotification) => Effect.Effect<void, unknown>;
50
+ /** Removes the notifications sent under these ids from the phones that got them. */
51
+ readonly clear: (ids: ReadonlyArray<string>) => Effect.Effect<void>;
52
+ }
File without changes
@@ -0,0 +1,14 @@
1
+ import type { ReferenceGitSource, ReferenceLocalSource } from "@radheim/client";
2
+ import type { ReferenceApi } from "@radheim/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 "@radheim/client/effect/api";
2
+ export type { RpcClient } from "@radheim/client/effect/api";
3
+ import type { Rpc } from "@radheim/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