@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31

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 (172) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/README.md +739 -116
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +18 -7
  6. package/dist/agents.js +19 -10
  7. package/dist/app.js +101 -26
  8. package/dist/background.d.ts +29 -0
  9. package/dist/background.js +397 -0
  10. package/dist/box-egress-vm.d.ts +125 -0
  11. package/dist/box-egress-vm.js +350 -0
  12. package/dist/box-egress.d.ts +99 -0
  13. package/dist/box-egress.js +259 -0
  14. package/dist/box-image.d.ts +1 -1
  15. package/dist/box-image.js +9 -7
  16. package/dist/box-relay-vm.d.ts +84 -0
  17. package/dist/box-relay-vm.js +410 -0
  18. package/dist/box-relay.d.ts +8 -5
  19. package/dist/box-relay.js +14 -9
  20. package/dist/boxes.d.ts +28 -5
  21. package/dist/boxes.js +44 -18
  22. package/dist/browser-cost.d.ts +41 -0
  23. package/dist/browser-cost.js +158 -0
  24. package/dist/cap.d.ts +130 -21
  25. package/dist/cap.js +339 -67
  26. package/dist/cli.js +30 -4
  27. package/dist/coding-tools.d.ts +7 -3
  28. package/dist/coding-tools.js +16 -10
  29. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  30. package/dist/console/assets/index-CnJBf7Lc.js +486 -0
  31. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/content-filter.d.ts +7 -0
  34. package/dist/content-filter.js +23 -0
  35. package/dist/decision-rows.d.ts +11 -3
  36. package/dist/decision-rows.js +18 -11
  37. package/dist/decisions.d.ts +3 -3
  38. package/dist/decisions.js +4 -3
  39. package/dist/errors.d.ts +2 -0
  40. package/dist/errors.js +5 -2
  41. package/dist/files.d.ts +9 -1
  42. package/dist/files.js +10 -2
  43. package/dist/grade.d.ts +11 -11
  44. package/dist/grade.js +43 -55
  45. package/dist/graph-served.d.ts +23 -0
  46. package/dist/graph-served.js +75 -0
  47. package/dist/graph-view.d.ts +7 -5
  48. package/dist/graph-view.js +10 -3
  49. package/dist/harness-app.d.ts +4 -2
  50. package/dist/harness-app.js +110 -19
  51. package/dist/harness-opencode/adapter.d.ts +45 -0
  52. package/dist/harness-opencode/adapter.js +272 -0
  53. package/dist/harness-opencode/binary.d.ts +18 -0
  54. package/dist/harness-opencode/binary.js +87 -0
  55. package/dist/harness-opencode/config.d.ts +24 -0
  56. package/dist/harness-opencode/config.js +61 -0
  57. package/dist/harness-opencode/harness.d.ts +77 -0
  58. package/dist/harness-opencode/harness.js +620 -0
  59. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  60. package/dist/harness-opencode/host/mcp.js +208 -0
  61. package/dist/harness-opencode/host/policy.d.ts +71 -0
  62. package/dist/harness-opencode/host/policy.js +419 -0
  63. package/dist/harness-opencode/host/server.d.ts +55 -0
  64. package/dist/harness-opencode/host/server.js +165 -0
  65. package/dist/harness-opencode/index.d.ts +9 -0
  66. package/dist/harness-opencode/index.js +6 -0
  67. package/dist/harness-opencode/verify.d.ts +32 -0
  68. package/dist/harness-opencode/verify.js +75 -0
  69. package/dist/harness-opencode/versions.d.ts +33 -0
  70. package/dist/harness-opencode/versions.js +64 -0
  71. package/dist/harness.d.ts +4 -1
  72. package/dist/harness.js +5 -2
  73. package/dist/host-check.d.ts +12 -0
  74. package/dist/host-check.js +34 -0
  75. package/dist/host-tools.d.ts +12 -2
  76. package/dist/host-tools.js +26 -12
  77. package/dist/host.js +6 -2
  78. package/dist/hosted-search.js +5 -1
  79. package/dist/import.d.ts +2 -2
  80. package/dist/import.js +4 -3
  81. package/dist/key-check.d.ts +3 -2
  82. package/dist/key-check.js +7 -3
  83. package/dist/key-refusal.js +8 -4
  84. package/dist/key-words.d.ts +37 -0
  85. package/dist/key-words.js +40 -0
  86. package/dist/learn/check.d.ts +10 -1
  87. package/dist/learn/check.js +19 -1
  88. package/dist/learn/grade.d.ts +6 -2
  89. package/dist/learn/grade.js +28 -14
  90. package/dist/learn/index.d.ts +3 -3
  91. package/dist/learn/index.js +3 -3
  92. package/dist/learn/notes.js +2 -1
  93. package/dist/learn/reflect.d.ts +2 -2
  94. package/dist/learn/reflect.js +53 -5
  95. package/dist/learn/secrets.js +28 -8
  96. package/dist/learn/skills.d.ts +19 -4
  97. package/dist/learn/skills.js +95 -6
  98. package/dist/learned-workflow.d.ts +59 -0
  99. package/dist/learned-workflow.js +191 -0
  100. package/dist/learning-routes.d.ts +30 -1
  101. package/dist/learning-routes.js +173 -19
  102. package/dist/learning-run.d.ts +8 -6
  103. package/dist/learning-run.js +70 -27
  104. package/dist/learning-words.d.ts +12 -5
  105. package/dist/learning-words.js +34 -13
  106. package/dist/learning.d.ts +52 -3
  107. package/dist/learning.js +204 -4
  108. package/dist/mcp-gateway.d.ts +96 -0
  109. package/dist/mcp-gateway.js +408 -0
  110. package/dist/mcp-meta.d.ts +17 -0
  111. package/dist/mcp-meta.js +38 -0
  112. package/dist/mcp-servers.d.ts +33 -9
  113. package/dist/mcp-servers.js +58 -10
  114. package/dist/mcp.js +5 -5
  115. package/dist/model.d.ts +13 -11
  116. package/dist/model.js +11 -10
  117. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  118. package/dist/openapi.js +407 -54
  119. package/dist/page.d.ts +2 -0
  120. package/dist/page.js +3 -0
  121. package/dist/paid-calls.d.ts +5 -1
  122. package/dist/paid-calls.js +1 -1
  123. package/dist/pause.d.ts +2 -0
  124. package/dist/place.d.ts +29 -5
  125. package/dist/place.js +51 -11
  126. package/dist/print.d.ts +7 -0
  127. package/dist/print.js +13 -0
  128. package/dist/propose.d.ts +2 -0
  129. package/dist/propose.js +38 -8
  130. package/dist/request-start.d.ts +12 -4
  131. package/dist/request-start.js +139 -15
  132. package/dist/run-box.d.ts +56 -4
  133. package/dist/run-box.js +183 -23
  134. package/dist/runnable.d.ts +13 -3
  135. package/dist/runnable.js +63 -6
  136. package/dist/runs.d.ts +266 -37
  137. package/dist/runs.js +884 -90
  138. package/dist/secrets.d.ts +27 -0
  139. package/dist/secrets.js +38 -2
  140. package/dist/server.d.ts +141 -36
  141. package/dist/server.js +562 -118
  142. package/dist/sign-ins.d.ts +99 -0
  143. package/dist/sign-ins.js +288 -0
  144. package/dist/skills.d.ts +16 -4
  145. package/dist/skills.js +35 -7
  146. package/dist/stats.d.ts +7 -2
  147. package/dist/stats.js +28 -7
  148. package/dist/tool-gate.d.ts +281 -0
  149. package/dist/tool-gate.js +585 -0
  150. package/dist/tool-keys.d.ts +48 -11
  151. package/dist/tool-keys.js +46 -8
  152. package/dist/tool-plane.d.ts +116 -27
  153. package/dist/tool-plane.js +232 -50
  154. package/dist/tools.d.ts +69 -14
  155. package/dist/tools.js +148 -26
  156. package/dist/trigger-secrets.d.ts +32 -0
  157. package/dist/trigger-secrets.js +143 -0
  158. package/dist/triggers.d.ts +439 -0
  159. package/dist/triggers.js +863 -0
  160. package/dist/turn-end.d.ts +3 -2
  161. package/dist/turn-end.js +3 -2
  162. package/dist/usage-lines.d.ts +26 -0
  163. package/dist/usage-lines.js +28 -0
  164. package/dist/validate.d.ts +2 -0
  165. package/dist/validate.js +11 -2
  166. package/dist/web-fetch.js +3 -3
  167. package/dist/webhooks.d.ts +11 -4
  168. package/dist/webhooks.js +17 -1
  169. package/launcher/agentrun-serve +1 -1
  170. package/package.json +16 -14
  171. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  172. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -0,0 +1,281 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import { type Extension, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
3
+ import type { DurableRun } from "@parcha/pi-durable-disk";
4
+ import type { TurnOrigin } from "./learning-run.js";
5
+ /** What the gate does with a tool's calls. */
6
+ export declare const PERMISSIONS: readonly ["allow", "ask", "deny"];
7
+ export type Permission = (typeof PERMISSIONS)[number];
8
+ /** An MCP tool's gate name: `mcp:<server>/<tool>`. */
9
+ export declare const mcpToolName: (server: string, tool: string) => string;
10
+ /** Whether `name` is an MCP tool's gate name. */
11
+ export declare const isMcpTool: (name: string) => boolean;
12
+ /** A third-party catalog tool, by its name: monid's (`monid.<tool>`) or an MCP server's (`mcp:<server>/<tool>`). */
13
+ export declare const isCatalogTool: (name: string) => boolean;
14
+ /** The owner's defaults (11-01): a built-in kernel tool allow; a third-party catalog tool ask. */
15
+ export declare const defaultPermission: (name: string) => Permission;
16
+ /** The tools that run a command in the run's box (background.ts SHELL_TOOLS), each held to bash's setting: bash: deny
17
+ * refuses bash_background as it refuses bash, and none of them is a settings key of its own. Under bash: ask the
18
+ * watchers (SHELL_WATCHERS) run unasked. */
19
+ export declare const SHELL_FAMILY: Readonly<Record<string, string>>;
20
+ /** The shell tools that only watch or end a process the run already started, by its own id (background.ts: an id is
21
+ * digits under the run's own work/background/, and another's is "no background process"): under bash: ask they run
22
+ * unasked, so watching an approved process costs no approval per page. bash: deny still refuses them. */
23
+ export declare const SHELL_WATCHERS: ReadonlySet<string>;
24
+ /** The settings keys that may set `name`'s permission, most specific first: the tool's own name, then, for an MCP
25
+ * tool, its server's wildcard `mcp:<server>/*`. */
26
+ export declare function permissionKeys(name: string): string[];
27
+ /** The settings key a call named `name` on `harness` is held to: the one mapping from every name a call reaches the gate
28
+ * by. A settings key is itself (a table tool, `monid.<tool>`, `mcp:<server>/<tool>`); a CLI's own tool is the table's it
29
+ * is; an MCP alias, `mcp__<server>__<tool>` (claude-agent's host tools `mcp__hands__<wire name>`, mapped as their
30
+ * wire name) and on OpenCode `<server>_<tool>`, is `mcp:<server>/<tool>`; a catalog's wire name (`monid_run`) is its
31
+ * catalog name; the browser's registrations are `browser`. OpenCode's `<server>_<tool>` maps only for a server of
32
+ * `mcpServers` (the run's configured MCP servers), never by its shape, since a host tool's name has the same shape.
33
+ * Undefined: nothing maps it, and the gate asks. The key only: an MCP call enters the gate once, in the MCP gateway for a
34
+ * registration it marks (GATED_BY_GATEWAY), else where its tool is wrapped. */
35
+ export declare function settingsKeyOf(harness: string, name: string, mcpServers?: readonly string[]): string | undefined;
36
+ /** A layer of tool settings (the server's, PUT /v2/settings/tools, or an agent's own, definition.tool_settings) as the
37
+ * gate reads it: a permission by settings key. */
38
+ export type PermissionSettings = Readonly<Record<string, {
39
+ permission?: Permission; /** Not as written: a value not offered, read as its fail-closed stand-in (tool-plane.ts readToolSettings). Never shown. */
40
+ fallback?: true;
41
+ } | undefined>>;
42
+ /** `name`'s permission in force and the layer it came from, most specific first: the agent's exact key, the agent's
43
+ * server wildcard, the server's exact key, the server's server wildcard, then the default. Rules over a call's
44
+ * arguments are not in V1. */
45
+ export declare function permissionFrom(name: string, server: PermissionSettings, agent?: PermissionSettings): {
46
+ permission: Permission;
47
+ from: "agent" | "server" | "default";
48
+ };
49
+ /** `name`'s permission in force (permissionFrom): the one rule every path reads, the gate's, the tool plane's and a
50
+ * workflow's call nodes'. */
51
+ export declare const permissionOf: (name: string, server: PermissionSettings, agent?: PermissionSettings) => Permission;
52
+ /** A call's answer as the model reads it: its text, and whether it failed. */
53
+ export type ToolAnswer = {
54
+ text: string;
55
+ isError: boolean;
56
+ };
57
+ /** An approval's price for the person who answers it: USD where the tool declares one (booked through the spend cap's
58
+ * paidCall), else "not metered" (an unpriced MCP call, the owner's ruling of 11-04). */
59
+ export type ApprovalPrice = number | "not metered";
60
+ /** One pending approval, as the run's view shows it (`pending`) and the console's approval card reads it. */
61
+ export type PendingApproval = {
62
+ kind: "approval";
63
+ /** The approval's id, the answer route's `{approval_id}`; the same for the same call after a crash. */
64
+ id: string;
65
+ tool: string;
66
+ call_id: string;
67
+ /** The call's arguments as text, at most ARGS_PREVIEW_BYTES. */
68
+ args_preview: string;
69
+ requested_at: string;
70
+ price?: ApprovalPrice;
71
+ };
72
+ /** The run's journal commit for the call, which makes the request durable before the gate answers, and who is told it
73
+ * parked, so its turn ends (harness-app.ts endsTurn): by the call's id, or, where the caller cannot name it, by its tool
74
+ * and its arguments' digest. */
75
+ export type Park = {
76
+ commit<T>(change: (tx: unknown) => Promise<T>): Promise<T>;
77
+ parked?(callId: string): void;
78
+ parkedBy?(match: {
79
+ tool: string;
80
+ argsDigest: string;
81
+ }): void; /** The message the turn running the call took (harness-app's), kept with its request. */
82
+ turn?(): string | undefined;
83
+ };
84
+ /** What a call's ask carries beyond the call. */
85
+ export type EnterOptions = {
86
+ /** What the approval card shows the call costs. */
87
+ price?: ApprovalPrice;
88
+ };
89
+ /** enter's answer. `undefined`: run the call. Otherwise the answer the model reads instead: a refusal
90
+ * (`isError: true`), or the waiting text with `parked: true`, after which the caller ends the turn. */
91
+ export type Entered = undefined | (ToolAnswer & {
92
+ parked?: true;
93
+ });
94
+ /** Runs an APPROVED parked call of a tool family the gate does not own (the MCP gateway's), exactly once. It owns the
95
+ * call's deadline: the gate puts no wall-clock bound on it (only a stop or a cancel cuts it, through `signal`), so an
96
+ * executor bounds its own work and answers a timeout as an error result (`isError: true`), never by waiting on. */
97
+ export type Executor = (tool: string, args: unknown, callId: string, signal: AbortSignal) => Promise<ToolAnswer>;
98
+ /** The mark a tool registration carries when its calls are gated by whoever registered it (the MCP gateway, which marks
99
+ * its registrations only when it holds this run's gate and park, and enters the gate in each call): RunGate.extension
100
+ * does not wrap it again. `Symbol.for`, so the mark is the same symbol whichever copy of this module set or reads it. */
101
+ export declare const GATED_BY_GATEWAY: unique symbol;
102
+ /** A registration that may carry GATED_BY_GATEWAY. */
103
+ export type GatewayMarked = ToolRegistration & {
104
+ [GATED_BY_GATEWAY]?: true;
105
+ };
106
+ /** The gate of one run, in the run's process. */
107
+ export interface Gate {
108
+ /** One model-initiated call at the gate: allow, deny, or ask, which parks (see the header). */
109
+ enter(tool: string, args: unknown, callId: string, park: Park, options?: EnterOptions): Promise<Entered>;
110
+ /** Registers how an approved parked call of tools named `prefix…` (e.g. "mcp:") runs; one per prefix and run. */
111
+ executor(prefix: string, run: Executor): void;
112
+ /** A call's result text as the model gets it: as it is, a host tool's result already cut by HOST_RESULT_MAX_CHARS. */
113
+ spill(callId: string, text: string): string;
114
+ }
115
+ /** The refusal of a call whose tool is set to deny; of one held to another tool's setting (`heldTo`, a shell tool's
116
+ * bash), naming the setting to change. */
117
+ export declare const deniedText: (tool: string, heldTo?: string) => string;
118
+ /** The refusal of an ask where no one can approve it: a server with accounts off, whose answer route takes no token. */
119
+ export declare const noApproverText: (tool: string) => string;
120
+ /** Set by the server in a run's environment when no one can approve here (accounts off): the gate refuses each ask. */
121
+ export declare const NO_APPROVER_ENV = "AGENTRUN_SERVE_NO_APPROVER";
122
+ /** A parked call's answer: the run pauses here. */
123
+ export declare const waitingText: (tool: string) => string;
124
+ /** A call a person denied, with their reason when they gave one. */
125
+ export declare const refusedText: (tool: string, note?: string) => string;
126
+ /** The Timeline row of a call that waits for an approval. */
127
+ export declare const APPROVAL_ROW: "tool_approval_requested";
128
+ /** A call's arguments shown on its approval, at most this many bytes. */
129
+ export declare const ARGS_PREVIEW_BYTES = 2048;
130
+ /** A gate of `policy` (the run's permission of a tool now) with no run behind it: allow and deny are enforced and
131
+ * executors are kept; an ask throws, since nothing here can park a call (a run's is RunGate), and spill returns
132
+ * the text as it is. */
133
+ export declare function gateOf(policy: (tool: string) => Permission): Gate;
134
+ /** The file in a run's directory that names the origin of the turn it runs now: written by the server alone, as it sends
135
+ * the learning lane's reflect turn (runs.ts's toLiveDoor), and gone before a person's turn is sent (runs.ts's personsTurn).
136
+ * The gate refuses that turn's writes under work/.learning/ (NOTE_ONLY_TEXT). */
137
+ export declare const TURN_ORIGIN_FILE = "turn-origin.json";
138
+ /** The run's store's record of a call that waits for approval (`phase: "requested"`), and of its answer acted on
139
+ * (`phase: "resolved"`), on its root conversation. */
140
+ export declare const APPROVAL_ENTRY = "agentrun.tool_approval";
141
+ /** The refusal of the end-of-run turn's write or edit under work/.learning/: its notes are kept only from its answer's
142
+ * note blocks (learn/reflect.ts parseReflection), which the host merges in its own store; a file there is never kept. */
143
+ export declare const NOTE_ONLY_TEXT = "A note is kept only from your answer: write it in a ```note block, not to a file.";
144
+ /** Whether `args.path`, as a file tool resolves it (a leading `@` dropped, Unicode spaces made plain, then lexically),
145
+ * names work/.learning/ or a path under it: by this machine's `work` or the box's (BOX_WORK). */
146
+ export declare function underLearning(work: string, args: unknown): boolean;
147
+ /** One call that waits for approval, as the run's store keeps it. */
148
+ export type ApprovalRequest = {
149
+ id: string;
150
+ tool: string;
151
+ call_id: string;
152
+ args: unknown;
153
+ args_preview: string;
154
+ requested_at: string; /** The message the turn that parked it took: a reopen settles that turn, answered or not. */
155
+ turn?: string;
156
+ price?: ApprovalPrice;
157
+ };
158
+ /** Resumes the session with `content` as one message of its own (`approval-<id>`), writing `mark` with it or after it. */
159
+ export type Resume = (id: string, content: string, mark: (tx: Tx) => Promise<unknown>) => Promise<void>;
160
+ /** `text` cut to at most ARGS_PREVIEW_BYTES. What is shown of a call's arguments is the whole of them redacted first, then
161
+ * cut (runs.ts), so a cut never leaves the head of a key no redaction recognizes. */
162
+ export declare function previewOf(text: string): string;
163
+ /** `args` as JSON, at most ARGS_PREVIEW_BYTES: the request's own record of them, never shown as it is. */
164
+ export declare const argsPreview: (args: unknown) => string;
165
+ /** How the gate's resume message starts: the server knows its row by it, and redacts the row whole (runs.ts). */
166
+ export declare const RESUME_PREFIX = "[tool approval] ";
167
+ /** The one message that resumes a session once a person answered: it names the call it answers (its tool, call id and
168
+ * arguments), so the model tells it from a person's new input, and carries the call's result, or the refusal. */
169
+ export declare function resumeText(request: Pick<ApprovalRequest, "tool" | "call_id">, shown: string, decision: "allow" | "deny", result: ToolAnswer): string;
170
+ /** The gate of the run `runId` at `where` (its directory, under the data directory's runs/), on its pinned revision:
171
+ * an agentic run's parks an asked call; a workflow's model node cannot. */
172
+ export declare function runGate(where: {
173
+ root: string;
174
+ work: string;
175
+ }, runId: string, revision: {
176
+ kind: string;
177
+ body: {
178
+ toolSettings?: unknown;
179
+ harness?: string;
180
+ };
181
+ }): RunGate;
182
+ /** The gate in a run's process, park mode: its policy, the turn's origin, the calls that wait, and the answers acted on. */
183
+ export declare class RunGate {
184
+ private readonly where;
185
+ private readonly overrides;
186
+ private readonly parks;
187
+ private readonly approvers;
188
+ private readonly requests;
189
+ private durable?;
190
+ private context?;
191
+ private coding?;
192
+ /** The run's own tools beyond the table (its learned_workflow), on which an approved call of one runs. */
193
+ private extra;
194
+ private resume?;
195
+ private drive?;
196
+ private timer?;
197
+ private settling;
198
+ private readonly stop;
199
+ /** `where.data`: the server's data directory, its tool settings beside the store; `overrides`: the pinned revision's
200
+ * own; `parks`: whether an asked call parks the run (an agentic run's), which a workflow's model node cannot;
201
+ * `approvers`: whether anyone can answer an ask here (the owner's password session: accounts on). */
202
+ constructor(where: {
203
+ root: string;
204
+ work: string;
205
+ data: string;
206
+ runId: string;
207
+ harness?: string;
208
+ mcpServers?: readonly string[];
209
+ }, overrides?: PermissionSettings, parks?: boolean, approvers?: boolean);
210
+ /** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
211
+ * reaches a live run at its next call. */
212
+ readonly policy: (tool: string) => Permission;
213
+ private lastGood?;
214
+ private readonly told;
215
+ /** The server's settings now: read at each call, so a change reaches a live run; a file that does not read keeps the
216
+ * last good (undefined: none read yet). Each problem is said once, by file and field, never a value. */
217
+ private serverSettings;
218
+ /** The origin of the turn running now: what the server's internal path wrote for it; none for a person's turn. */
219
+ turnOrigin(): TurnOrigin | undefined;
220
+ /** One model-initiated call at the gate: undefined when it may run; else its answer, refused at once (deny) or parked
221
+ * (ask). One call waits at a time: another asked meanwhile is answered so, not run. */
222
+ enter(name: string, args: unknown, callId: string, park: Park, options?: EnterOptions): Promise<Entered>;
223
+ /** pi's `tools` behind the gate: wraps, by name, for the run's registry, which apply wherever it is selected (every
224
+ * agent selects it: the root by default, a workflow's model node by name, app.ts). */
225
+ extension(tools: readonly ToolRegistration[]): Extension;
226
+ private wrap;
227
+ /** Reads the requests the run's store holds, as the run's process opens, before its turns go on. `coding`: the run's
228
+ * coding source (coding-tools.ts), on which an approved coding call runs, as the run's own would; `extra`, the run's
229
+ * own tools beyond the table (its learned_workflow), on which an approved call of one runs. */
230
+ load(durable: DurableRun, context: Context, coding?: readonly ToolRegistration[], extra?: readonly ToolRegistration[]): Promise<void>;
231
+ /** Whether a call waits for its answer, or for its answer to be acted on: a harness keeps the turn it ended closed. */
232
+ waiting(): boolean;
233
+ /** Whether a call of the turn that took `message` was parked, answered or not: that turn ended at the park, though a
234
+ * process that went before the next open settled it leaves it open in its session. */
235
+ parkedIn(message: string | undefined): boolean;
236
+ /** Acts on the answers from now on, resuming the session through `resume`; by default pi's root conversation. */
237
+ start(resume?: Resume): void;
238
+ private note;
239
+ /** Reads the run's serve.json for answers while a call waits. */
240
+ private watch;
241
+ /** pi's resume: an input to the root conversation under the request's own id, which pi takes once however often it
242
+ * is sent, then the mark. */
243
+ private readonly submit;
244
+ private settle;
245
+ /** The approved call in flight, and its own abort: a stop or a cancel of the run cuts it (cutIfWithdrawn). */
246
+ private inFlight?;
247
+ /** Cuts the approved call in flight when a stop or a cancel since withdrew its answer (runs.ts supersede). */
248
+ private cutIfWithdrawn;
249
+ /** A call withdrawn with its run: resolved in the run's store with nothing run and nothing resumed. */
250
+ private resolveSilently;
251
+ /** The approved call, run once by the kernel through the journal any host tool's call goes through, as an effect of
252
+ * the run's own `approvals:` session, on the run's coding source: its intent is durable before it runs, its outcome
253
+ * after; a replay-safe call a crash cut off runs again, any other is answered interrupted and never runs again. */
254
+ private run;
255
+ private readonly executors;
256
+ /** Registers how an approved call of tools named `prefix…` runs (the MCP gateway's, "mcp:"): one per prefix and run.
257
+ * The gate runs it exactly once on its journaled path, as it runs a kernel host tool, with no deadline of its own: the
258
+ * executor bounds the call (Executor). */
259
+ executor(prefix: string, run: Executor): void;
260
+ /** What runs an approved call: the executor its tool's prefix names, which may have effects anywhere, so a call a
261
+ * crash cut off is never run again; else the kernel's host tool of the name, as replay-safe as that tool is. Neither:
262
+ * refused, in words, and never run. */
263
+ private runnerOf;
264
+ }
265
+ /** A parked call: by its id, or, where the caller cannot name it (OpenCode's MCP calls carry none), by its tool, as the
266
+ * harness reports it, and its arguments' digest (argsDigest). */
267
+ export type ParkedCall = {
268
+ callId: string;
269
+ } | {
270
+ tool: string;
271
+ argsDigest: string;
272
+ };
273
+ /** The digest a park by tool and arguments is matched on: the sha256 of the arguments' canonical JSON, in hex. */
274
+ export declare const argsDigest: (args: unknown) => string;
275
+ /** Whether the tool result `result` ends the turn `parked` waits in (harness-app.ts asks it at each one): the parked
276
+ * call's own, by its id; or, for a park by tool and arguments, the next result of that tool with those arguments. */
277
+ export declare function endsTurn(parked: ParkedCall | undefined, result: {
278
+ callId: string;
279
+ tool: string;
280
+ args: unknown;
281
+ }): boolean;