@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
@@ -0,0 +1,49 @@
1
+ import type { Artifact } from "@radheim/schema/artifact";
2
+ import type { Session } from "@radheim/schema/session";
3
+ import type { Transform } from "./registration.js";
4
+ export interface ArtifactProviderCreateInput {
5
+ readonly id: Artifact.ID;
6
+ readonly title: string;
7
+ readonly entry: string;
8
+ readonly files: Readonly<Record<string, Uint8Array>>;
9
+ readonly sessionID?: Session.ID;
10
+ }
11
+ export interface ArtifactProviderUpdateInput {
12
+ readonly title: string;
13
+ readonly entry: string;
14
+ readonly files: Readonly<Record<string, Uint8Array>>;
15
+ readonly sessionID?: Session.ID;
16
+ }
17
+ export interface ArtifactProviderResult {
18
+ readonly url?: string;
19
+ }
20
+ export interface ArtifactProviderDefinition {
21
+ readonly id: string;
22
+ readonly name: string;
23
+ readonly capabilities: readonly Artifact.Capability[];
24
+ readonly prompt: string;
25
+ readonly create: (input: ArtifactProviderCreateInput, context: {
26
+ readonly signal: AbortSignal;
27
+ }) => Promise<ArtifactProviderResult>;
28
+ readonly read: (id: Artifact.ID, context: {
29
+ readonly signal: AbortSignal;
30
+ }) => Promise<Readonly<Record<string, Uint8Array>>>;
31
+ readonly update: (id: Artifact.ID, input: ArtifactProviderUpdateInput, context: {
32
+ readonly signal: AbortSignal;
33
+ }) => Promise<ArtifactProviderResult>;
34
+ readonly delete: (id: Artifact.ID, context: {
35
+ readonly signal: AbortSignal;
36
+ }) => Promise<void>;
37
+ }
38
+ export interface ArtifactEditor {
39
+ add(definition: ArtifactProviderDefinition): void;
40
+ remove(id: string): void;
41
+ readonly default: {
42
+ get(): string | undefined;
43
+ set(providerID: string | undefined): void;
44
+ };
45
+ }
46
+ export interface ExperimentalArtifactDomain {
47
+ readonly transform: Transform<ArtifactEditor>;
48
+ readonly reload: () => Promise<void>;
49
+ }
File without changes
@@ -0,0 +1,22 @@
1
+ import type { CommandApi } from "@radheim/client/promise/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 { Transform } from "./registration.js";
6
+ export interface CommandInvocation {
7
+ readonly sessionID: Session.ID;
8
+ readonly prompt: PromptInput.Prompt;
9
+ readonly delivery: SessionInbox.Delivery;
10
+ }
11
+ export interface CommandDefinition {
12
+ readonly name: string;
13
+ readonly description?: string;
14
+ readonly execute: (input: CommandInvocation) => Promise<void>;
15
+ }
16
+ export interface CommandEditor {
17
+ add(definition: CommandDefinition): void;
18
+ }
19
+ export interface CommandDomain extends Pick<CommandApi, "list"> {
20
+ readonly transform: Transform<CommandEditor>;
21
+ readonly reload: () => Promise<void>;
22
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ import type { RadheEvent } from "@radheim/client";
2
+ import type { SelectedEvent, SubscribeOptions } from "@radheim/client/promise/api";
3
+ type EventType = Exclude<RadheEvent["type"], "server.connected" | `experimental.space.${string}`>;
4
+ export interface EventDomain {
5
+ readonly subscribe: <Type extends EventType = EventType>(options?: SubscribeOptions<Type>) => AsyncIterable<SelectedEvent<RadheEvent, Type>>;
6
+ }
7
+ export {};
File without changes
@@ -0,0 +1,20 @@
1
+ export type { PluginOptions } from "../options.js";
2
+ export type { StorageEntry, StorageScanOptions, StorageScanResult } from "../storage.js";
3
+ export * as Plugin from "./plugin.js";
4
+ export { Agent } from "@radheim/schema/agent";
5
+ export { Artifact } from "@radheim/schema/artifact";
6
+ export { Command } from "@radheim/schema/command";
7
+ export { Connection } from "@radheim/schema/connection";
8
+ export { Credential } from "@radheim/schema/credential";
9
+ export { Integration } from "@radheim/schema/integration";
10
+ export { Location } from "@radheim/schema/location";
11
+ export { Mcp } from "@radheim/schema/mcp";
12
+ export { Model } from "@radheim/schema/model";
13
+ export { PersistentPty } from "@radheim/schema/persistent-pty";
14
+ export { Provider } from "@radheim/schema/provider";
15
+ export { Reference } from "@radheim/schema/reference";
16
+ export { Rpc } from "@radheim/schema/rpc";
17
+ export { Skill } from "@radheim/schema/skill";
18
+ export { Vcs } from "@radheim/schema/vcs";
19
+ export { WebSearch } from "@radheim/schema/websearch";
20
+ export { Worktree } from "@radheim/schema/worktree";
@@ -0,0 +1,18 @@
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 { Vcs } from "@radheim/schema/vcs";
17
+ export { WebSearch } from "@radheim/schema/websearch";
18
+ export { Worktree } from "@radheim/schema/worktree";
@@ -0,0 +1,102 @@
1
+ import type { ConnectionInfo } from "@radheim/client";
2
+ import type { IntegrationApi } from "@radheim/client/promise/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 { 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 IntegrationExternalMethod {
29
+ readonly id: string;
30
+ readonly type: "external";
31
+ readonly label: string;
32
+ readonly form?: Form.Fields;
33
+ }
34
+ export interface IntegrationEnvMethod {
35
+ readonly type: "env";
36
+ readonly names: ReadonlyArray<string>;
37
+ }
38
+ export type IntegrationMethod = IntegrationOAuthMethod | IntegrationCommandMethod | IntegrationKeyMethod | IntegrationExternalMethod | IntegrationEnvMethod;
39
+ export type IntegrationOAuthAuthorization = {
40
+ readonly url: string;
41
+ readonly instructions: string;
42
+ readonly expiresAt?: number;
43
+ } & ({
44
+ readonly mode: "auto";
45
+ readonly callback: Promise<Credential.OAuth>;
46
+ /**
47
+ * Accepts the redirect URL a user pasted when the browser could not reach this machine, and settles `callback`
48
+ * with it. Check the URL's `state` as the browser path does; a rejection rejects only this paste.
49
+ */
50
+ readonly submit?: (redirect: string) => Promise<void>;
51
+ } | {
52
+ readonly mode: "code";
53
+ readonly callback: (code: string) => Promise<Credential.OAuth>;
54
+ });
55
+ export type IntegrationOAuthMethodRegistration = {
56
+ readonly integrationID: string;
57
+ readonly method: IntegrationOAuthMethod;
58
+ readonly authorize: (answer: Form.Answer) => Promise<IntegrationOAuthAuthorization>;
59
+ readonly refresh?: (credential: Credential.OAuth) => Promise<Credential.OAuth>;
60
+ /** Signs the credential out remotely before it is removed. A rejection is logged and the credential is still removed. */
61
+ readonly revoke?: (credential: Credential.OAuth) => Promise<void>;
62
+ readonly label?: (credential: Credential.OAuth) => string | undefined;
63
+ };
64
+ export type IntegrationMethodRegistration = IntegrationOAuthMethodRegistration | {
65
+ readonly integrationID: string;
66
+ readonly method: IntegrationCommandMethod;
67
+ } | {
68
+ readonly integrationID: string;
69
+ readonly method: IntegrationKeyMethod;
70
+ } | {
71
+ readonly integrationID: string;
72
+ readonly method: IntegrationExternalMethod;
73
+ } | {
74
+ readonly integrationID: string;
75
+ readonly method: IntegrationEnvMethod;
76
+ };
77
+ export interface IntegrationEditor {
78
+ list(): readonly IntegrationRef[];
79
+ get(id: string): IntegrationRef | undefined;
80
+ update(id: string, update: (integration: IntegrationRef) => void): void;
81
+ remove(id: string): void;
82
+ readonly method: {
83
+ list(integrationID: string): readonly IntegrationMethod[];
84
+ update(input: IntegrationMethodRegistration): void;
85
+ remove(integrationID: string, method: IntegrationMethod): void;
86
+ };
87
+ }
88
+ export interface IntegrationDomain extends Omit<IntegrationApi, "wellknown"> {
89
+ readonly transform: Transform<IntegrationEditor>;
90
+ readonly reload: () => Promise<void>;
91
+ readonly connection: {
92
+ readonly active: (integrationID: string) => Promise<ConnectionInfo | undefined>;
93
+ readonly resolve: (connection: ConnectionInfo) => Promise<Credential.Value | undefined>;
94
+ /** Reports a problem with a connection, such as a required sign-in; `undefined` clears it. */
95
+ readonly status: (input: {
96
+ readonly integrationID: string;
97
+ readonly connection: ConnectionInfo;
98
+ readonly status: Connection.Status | undefined;
99
+ }) => Promise<void>;
100
+ };
101
+ }
102
+ 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/promise/api";
2
+ import type { Mcp } from "@radheim/schema/mcp";
3
+ import type { 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, "list"> {
13
+ readonly transform: Transform<MCPEditor>;
14
+ readonly reload: () => Promise<void>;
15
+ }
File without changes
@@ -0,0 +1,29 @@
1
+ import type { ModelApi } from "@radheim/client/promise/api";
2
+ import type { Model } from "@radheim/schema/model";
3
+ import type { 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 {
27
+ readonly transform: Transform<ModelEditor>;
28
+ readonly reload: () => Promise<void>;
29
+ }
File without changes
@@ -0,0 +1,29 @@
1
+ import type { PermissionApi } from "@radheim/client/promise/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 { AssertInput } from "../permission.js";
6
+ import type { Hooks } from "./registration.js";
7
+ export interface PermissionEvaluation {
8
+ readonly sessionID: Session.ID;
9
+ readonly agent?: Agent.ID;
10
+ readonly action: string;
11
+ readonly resources: ReadonlyArray<string>;
12
+ readonly metadata?: Record<string, unknown>;
13
+ readonly source?: Permission.Source;
14
+ effect: Permission.Effect;
15
+ message?: string;
16
+ }
17
+ export interface PermissionHooks {
18
+ readonly evaluate: PermissionEvaluation;
19
+ }
20
+ export type PermissionDomain = Pick<PermissionApi, "list" | "get" | "reply"> & {
21
+ readonly hook: Hooks<PermissionHooks>;
22
+ /**
23
+ * Evaluates the session's permission rules and, when approval is required, prompts the user and
24
+ * waits for the reply. Resolves when allowed. A deny rule or a rejection with feedback rejects with
25
+ * a `Tool.Error` carrying the reason. A plain rejection rejects with an error that ends the current
26
+ * step; rethrow it rather than returning it as tool output.
27
+ */
28
+ readonly assert: (input: typeof AssertInput.Encoded) => Promise<void>;
29
+ };
File without changes
@@ -0,0 +1,70 @@
1
+ import type { RadheClient } from "@radheim/client";
2
+ import type { CredentialApi, ExperimentalGenerateApi, PluginApi } from "@radheim/client/promise/api";
3
+ import type { Location } from "@radheim/schema/location";
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, "activate">;
35
+ readonly event: EventDomain;
36
+ readonly experimental: {
37
+ readonly terminal: Pick<RadheClient["experimental"]["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, "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<RadheClient["experimental"]["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, "text">;
51
+ readonly permission: PermissionDomain;
52
+ readonly plugin: Pick<PluginApi, "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 type Cleanup = () => Promise<void> | void;
66
+ export interface Plugin {
67
+ readonly id: string;
68
+ readonly setup: (context: Context) => Promise<Cleanup | void> | Cleanup | void;
69
+ }
70
+ export declare function define(plugin: Plugin): Plugin;
@@ -0,0 +1,3 @@
1
+ export function define(plugin) {
2
+ return plugin;
3
+ }
@@ -0,0 +1,34 @@
1
+ import type { ProviderApi } from "@radheim/client/promise/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 { 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 {
32
+ readonly transform: Transform<ProviderEditor>;
33
+ readonly reload: () => Promise<void>;
34
+ }
File without changes
@@ -0,0 +1,50 @@
1
+ import type { Push } from "@radheim/schema/push";
2
+ import type { Hooks } from "./registration.js";
3
+ /**
4
+ * A phone notification about to be sent. Only `title`, `body`, `attention`, `data` and `skip` can be changed;
5
+ * changes to the other fields are ignored.
6
+ */
7
+ export interface PushSend {
8
+ /** What a later clear names: the permission request, the form, the session for a finished turn, or a plugin's id. */
9
+ readonly id: string;
10
+ /** `plugin` for a notification a plugin sent. */
11
+ readonly type: "turn" | "form" | "permission" | "plugin";
12
+ /** The session to open: the top-level one, or the one a plugin named. And the folder it works in. */
13
+ readonly sessionID: string;
14
+ readonly directory: string;
15
+ /** When the event happened, in ms since the epoch. */
16
+ readonly time: number;
17
+ /** True when the notification needs the person. Phones at the `attention` level get only these. */
18
+ attention: boolean;
19
+ /**
20
+ * For a `type` it knows, a phone builds what it shows from `data` and falls back to `title` and `body`. To change
21
+ * what it shows, replace the object: `event.data = { ...event.data, text: summary }`.
22
+ */
23
+ data: Push.Data;
24
+ title: string;
25
+ body: string;
26
+ /** Set to true to not send the notification. */
27
+ skip: boolean;
28
+ }
29
+ export interface PushHooks {
30
+ readonly send: PushSend;
31
+ }
32
+ /** A phone notification a plugin sends. */
33
+ export interface PushNotification {
34
+ /** Sending the same id again replaces the notification on the phone. */
35
+ readonly id: string;
36
+ /** Tapping the notification opens this session. */
37
+ readonly sessionID: string;
38
+ /** Defaults to the session's title. */
39
+ readonly title?: string;
40
+ readonly body: string;
41
+ /** True also reaches phones whose level is `attention`. Defaults to false. */
42
+ readonly attention?: boolean;
43
+ }
44
+ export interface ExperimentalPushDomain {
45
+ readonly hook: Hooks<PushHooks>;
46
+ /** Runs this location's `send` hooks, then sends to the phones that want it. Does nothing when no phone is registered. */
47
+ readonly send: (notification: PushNotification) => Promise<void>;
48
+ /** Removes the notifications sent under these ids from the phones that got them. */
49
+ readonly clear: (ids: ReadonlyArray<string>) => Promise<void>;
50
+ }
File without changes
@@ -0,0 +1,13 @@
1
+ import type { ReferenceApi } from "@radheim/client/promise/api";
2
+ import type { ReferenceGitSource, ReferenceLocalSource } from "@radheim/client";
3
+ import type { Transform } from "./registration.js";
4
+ export interface ReferenceEditor {
5
+ add(name: string, source: ReferenceLocalSource | ReferenceGitSource): void;
6
+ remove(name: string): void;
7
+ list(): readonly (readonly [string, ReferenceLocalSource | ReferenceGitSource])[];
8
+ get(name: string): ReferenceLocalSource | ReferenceGitSource | undefined;
9
+ }
10
+ export interface ReferenceDomain extends ReferenceApi {
11
+ readonly transform: Transform<ReferenceEditor>;
12
+ readonly reload: () => Promise<void>;
13
+ }
File without changes
@@ -0,0 +1,12 @@
1
+ export interface Registration {
2
+ readonly dispose: () => Promise<void>;
3
+ }
4
+ export interface ModelHookOptions {
5
+ /** Limits the hook to one provider. Unscoped hooks apply to every provider. */
6
+ readonly providerID?: string;
7
+ }
8
+ export type Hooks<Spec> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Promise<void> | void) => Promise<Registration>;
9
+ export type ModelHooks<Spec> = <Name extends keyof Spec>(name: Name, callback: (input: Spec[Name]) => Promise<void> | void, options?: Spec[Name] extends {
10
+ readonly model: unknown;
11
+ } ? ModelHookOptions : never) => Promise<Registration>;
12
+ export type Transform<Input> = (callback: (input: Input) => void) => Promise<Registration>;
File without changes
@@ -0,0 +1,22 @@
1
+ import type { RpcApi, RpcCallOptions } from "@radheim/client/promise/api";
2
+ import type { Rpc } from "@radheim/schema/rpc";
3
+ import type { Registration } from "./registration.js";
4
+ export type { RpcEventPayload } from "@radheim/client/promise/api";
5
+ export interface RpcCallContext<M extends Rpc.Method> {
6
+ readonly signal: AbortSignal;
7
+ readonly error: Rpc.ErrorFactory<M>;
8
+ }
9
+ export type RpcHandlers<D extends Rpc.PortableDefinition> = {
10
+ readonly [Name in keyof D["methods"]]: (input: Rpc.Output<D["methods"][Name]["input"]>, context: RpcCallContext<D["methods"][Name]>) => Promise<Rpc.HandlerOutput<D["methods"][Name]["output"]> | Rpc.HandlerError<D["methods"][Name]>>;
11
+ };
12
+ export interface RpcRegistration<D extends Rpc.PortableDefinition> extends Registration {
13
+ readonly events: {
14
+ readonly emit: (...args: Rpc.EventInput<D>) => Promise<void>;
15
+ };
16
+ }
17
+ export interface RpcDomain extends RpcApi<Pick<RpcCallOptions, "signal"> & {
18
+ readonly location?: never;
19
+ readonly headers?: never;
20
+ }> {
21
+ readonly register: <const D extends Rpc.PortableDefinition>(definition: D, handlers: RpcHandlers<NoInfer<D>>) => Promise<RpcRegistration<D>>;
22
+ }
File without changes