@tangle-network/agent-runtime 0.59.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -2
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/{chunk-IN7WHMGZ.js → chunk-5V343QPB.js} +47 -7
- package/dist/chunk-5V343QPB.js.map +1 -0
- package/dist/chunk-7IXF3VUJ.js +59 -0
- package/dist/chunk-7IXF3VUJ.js.map +1 -0
- package/dist/{chunk-ZWGEA722.js → chunk-AU5MCNHO.js} +2 -2
- package/dist/chunk-IBRJTG7O.js +475 -0
- package/dist/chunk-IBRJTG7O.js.map +1 -0
- package/dist/{chunk-MMDIORZY.js → chunk-Q5R33I7Y.js} +4 -23
- package/dist/chunk-Q5R33I7Y.js.map +1 -0
- package/dist/{chunk-45D64J7B.js → chunk-VCOT7XEQ.js} +190 -99
- package/dist/chunk-VCOT7XEQ.js.map +1 -0
- package/dist/coder-DD5J5Onk.d.ts +52 -0
- package/dist/coordination-k29badiX.d.ts +381 -0
- package/dist/{delegates-C94qchkz.d.ts → delegates-CWMv_rKL.d.ts} +649 -21
- package/dist/index.d.ts +9 -6
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +1 -1
- package/dist/{loop-runner-bin-Noz7P-mS.d.ts → loop-runner-bin-Bqt0hiNY.d.ts} +46 -12
- package/dist/loop-runner-bin.d.ts +7 -4
- package/dist/loop-runner-bin.js +4 -4
- package/dist/loops.d.ts +7 -6
- package/dist/loops.js +17 -6
- package/dist/mcp/bin.js +10 -10
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +12 -12
- package/dist/mcp/index.js +7 -7
- package/dist/{openai-tools-d4GKwgya.d.ts → openai-tools-CA2N3-Ak.d.ts} +1 -1
- package/dist/profiles.d.ts +7 -9
- package/dist/profiles.js +5 -7
- package/dist/profiles.js.map +1 -1
- package/dist/{run-loop-CcqfR_gy.d.ts → run-loop-D3PwlG7J.d.ts} +1 -1
- package/dist/runtime.d.ts +30 -1046
- package/dist/runtime.js +17 -6
- package/dist/{types-CUzjRFZ3.d.ts → types-Crxftafi.d.ts} +2 -2
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +1 -2
- package/dist/workflow.js.map +1 -1
- package/dist/worktree-fanout-CBULEoVe.d.ts +1098 -0
- package/package.json +2 -2
- package/dist/chunk-45D64J7B.js.map +0 -1
- package/dist/chunk-4FEUFYOY.js +0 -282
- package/dist/chunk-4FEUFYOY.js.map +0 -1
- package/dist/chunk-7QYOXFCD.js +0 -293
- package/dist/chunk-7QYOXFCD.js.map +0 -1
- package/dist/chunk-IN7WHMGZ.js.map +0 -1
- package/dist/chunk-MMDIORZY.js.map +0 -1
- package/dist/coder-CybltHEm.d.ts +0 -163
- package/dist/coordination-Biw19JzN.d.ts +0 -944
- /package/dist/{chunk-ZWGEA722.js.map → chunk-AU5MCNHO.js.map} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AgentProfile } from '@tangle-network/sandbox';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @experimental
|
|
5
|
+
*
|
|
6
|
+
* `coderProfile` — the §1.5 author-the-profile DATA for code-modification tasks: an `AgentProfile`
|
|
7
|
+
* constant (the agent IS its profile) plus a pure `coderTaskToPrompt` formatter that renders a
|
|
8
|
+
* `CoderTask` into the per-task instruction. There is no factory, output adapter, or validator
|
|
9
|
+
* here — a domain customizes the worker by authoring a profile + handing it to a leaf executor
|
|
10
|
+
* (`createWorktreeCliExecutor`) or a fanout (`worktreeFanout`), and "is it delivered" is a
|
|
11
|
+
* `DeliverableSpec` (`patchDelivered`), not a bundled validator.
|
|
12
|
+
*
|
|
13
|
+
* The standing instruction tells the agent to work on a fresh branch, keep the patch minimal,
|
|
14
|
+
* avoid forbidden paths, and run the test + typecheck commands before declaring done.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @experimental The per-task inputs `coderTaskToPrompt` renders + the worktree gate enforces. */
|
|
18
|
+
interface CoderTask {
|
|
19
|
+
/** What the agent must accomplish. Free-form prose. */
|
|
20
|
+
goal: string;
|
|
21
|
+
/** Absolute path inside the sandbox where the repo lives. */
|
|
22
|
+
repoRoot: string;
|
|
23
|
+
/** Default `main`. The branch the agent diffs against. */
|
|
24
|
+
baseBranch?: string;
|
|
25
|
+
/** Default `pnpm test --run`. */
|
|
26
|
+
testCmd?: string;
|
|
27
|
+
/** Default `pnpm typecheck`. */
|
|
28
|
+
typecheckCmd?: string;
|
|
29
|
+
/** Files the agent may inspect for context. Surfaced verbatim in the prompt. */
|
|
30
|
+
contextFiles?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Paths the agent must not touch. The mechanical gate hard-fails on any match.
|
|
33
|
+
* Use glob-free literal path prefixes for unambiguous enforcement.
|
|
34
|
+
*/
|
|
35
|
+
forbiddenPaths?: string[];
|
|
36
|
+
/** Default 400. Hard cap; the gate hard-fails when exceeded. */
|
|
37
|
+
maxDiffLines?: number;
|
|
38
|
+
}
|
|
39
|
+
/** @experimental The coder agent's standing instruction (its body lives in `coderProfile.prompt`). */
|
|
40
|
+
declare const DEFAULT_CODER_SYSTEM_PROMPT: string;
|
|
41
|
+
/**
|
|
42
|
+
* @experimental
|
|
43
|
+
*
|
|
44
|
+
* The coder `AgentProfile` — the §1.5 DATA the substrate materializes into a harness invocation.
|
|
45
|
+
* Stateless and harness-agnostic: a consumer overrides `model`/`metadata.backendType` by spreading
|
|
46
|
+
* a copy, never by a factory. `worktreeFanout` authors one such profile per harness leaf.
|
|
47
|
+
*/
|
|
48
|
+
declare const coderProfile: AgentProfile;
|
|
49
|
+
/** @experimental Render a `CoderTask` into the per-task instruction handed to the coder profile. */
|
|
50
|
+
declare function coderTaskToPrompt(task: CoderTask): string;
|
|
51
|
+
|
|
52
|
+
export { type CoderTask as C, DEFAULT_CODER_SYSTEM_PROMPT as D, coderTaskToPrompt as a, coderProfile as c };
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { c as DelegateFeedbackArgs, d as DelegationFeedbackSnapshot, e as DelegationTaskQueue, f as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, T as TraceContext, A as Agent, S as Scope, g as ResultBlobStore, B as Budget } from './delegates-CWMv_rKL.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @experimental
|
|
5
|
+
*
|
|
6
|
+
* The child→parent message bus: the ONE pipe carrying every message a worker, sub-driver, or
|
|
7
|
+
* analyst sends up to the driver — settled outputs, questions, and trace-analyst findings. It
|
|
8
|
+
* unifies channels that were ad-hoc before (the settled-worker cursor, the ask-parent question
|
|
9
|
+
* channel, and analyst results) into a single typed primitive with two lanes:
|
|
10
|
+
*
|
|
11
|
+
* - PASS-THROUGH (`subscribe`): every published event reaches subscribers immediately — the
|
|
12
|
+
* express lane for online steering and live observation (a UI, a hook, the parent's box).
|
|
13
|
+
* - STANDBY (`pull`): events also queue so the driver consumes them on its own cadence. The queue
|
|
14
|
+
* is PRIORITY-ordered: a higher-`priority` event (a blocking question) is bumped ahead of
|
|
15
|
+
* queued settles/findings so the driver sees it first; ties resolve FIFO by publish order.
|
|
16
|
+
*
|
|
17
|
+
* Observability is first-class (A++): every event is stamped with a monotonic `seq` and wall-clock
|
|
18
|
+
* `at`, the full ordered `history()` is retained as an audit/replay trail, and `stats()` exposes
|
|
19
|
+
* published/pulled counts by kind. Subscribers receive the stamped record, not a bare event.
|
|
20
|
+
*
|
|
21
|
+
* The interface is transport-agnostic on purpose. Same box → this in-process queue. Cross box →
|
|
22
|
+
* the SAME publish/pull/subscribe surface backed by a durable mailbox on the parent's box (children
|
|
23
|
+
* POST events with at-least-once retry; payloads are blob refs so the event stays small). Consumers
|
|
24
|
+
* depend only on this interface, so distribution is a transport swap, never an architecture change.
|
|
25
|
+
*/
|
|
26
|
+
/** Every bus event is a discriminated union member keyed by `type`. */
|
|
27
|
+
interface BusEvent {
|
|
28
|
+
readonly type: string;
|
|
29
|
+
}
|
|
30
|
+
/** A published event stamped for ordering and observability. `seq` is the monotonic publish index;
|
|
31
|
+
* `priority` drives pull order (higher = bumped ahead); `at` is the wall-clock publish time (ms). */
|
|
32
|
+
interface BusRecord<E extends BusEvent> {
|
|
33
|
+
readonly seq: number;
|
|
34
|
+
readonly at: number;
|
|
35
|
+
readonly priority: number;
|
|
36
|
+
readonly event: E;
|
|
37
|
+
}
|
|
38
|
+
interface PublishOptions {
|
|
39
|
+
/** Higher = pulled ahead of lower-priority queued events (default 0). A blocking question sets
|
|
40
|
+
* this so it bumps to the front of the driver's inbox. */
|
|
41
|
+
readonly priority?: number;
|
|
42
|
+
/** Whether the event enters the pull queue (default true). Set `false` for record-only events —
|
|
43
|
+
* the parent→child down-leg (steer / answer / resume): they belong in `history()` and reach
|
|
44
|
+
* `subscribe` observers, but the parent must never `pull` its own outbound message back. */
|
|
45
|
+
readonly queue?: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface BusStats {
|
|
48
|
+
readonly published: number;
|
|
49
|
+
readonly pulled: number;
|
|
50
|
+
/** Count published per event `type`. */
|
|
51
|
+
readonly byKind: Readonly<Record<string, number>>;
|
|
52
|
+
}
|
|
53
|
+
interface EventBus<E extends BusEvent> {
|
|
54
|
+
/** Stamp + queue the event, then deliver the stamped record to every subscriber in order.
|
|
55
|
+
* Returns the stamped record. */
|
|
56
|
+
publish(event: E, opts?: PublishOptions): Promise<BusRecord<E>>;
|
|
57
|
+
/** Remove and return the highest-priority QUEUED event whose type is in `kinds` (any if omitted),
|
|
58
|
+
* ties broken FIFO by `seq`; `undefined` when nothing matches. */
|
|
59
|
+
pull(kinds?: ReadonlyArray<E['type']>): E | undefined;
|
|
60
|
+
/** Register a pass-through handler; it receives the stamped record of every event published after
|
|
61
|
+
* registration. Returns an unsubscribe fn. */
|
|
62
|
+
subscribe(handler: (record: BusRecord<E>) => void | Promise<void>): () => void;
|
|
63
|
+
/** Count of queued, not-yet-pulled events (filtered by `kinds` when given). */
|
|
64
|
+
pending(kinds?: ReadonlyArray<E['type']>): number;
|
|
65
|
+
/** The full ordered log of every event ever published (the audit/replay trail). */
|
|
66
|
+
history(): ReadonlyArray<BusRecord<E>>;
|
|
67
|
+
/** Throughput counters for observability dashboards. */
|
|
68
|
+
stats(): BusStats;
|
|
69
|
+
}
|
|
70
|
+
declare function createEventBus<E extends BusEvent>(now?: () => number): EventBus<E>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @experimental
|
|
74
|
+
*
|
|
75
|
+
* Feedback persistence surface for the MCP layer.
|
|
76
|
+
*
|
|
77
|
+
* The substrate cannot import `@tangle-network/agent-knowledge` (it would
|
|
78
|
+
* induce a dependency cycle), so the store is an abstract interface. The
|
|
79
|
+
* default implementation is in-memory; consumers wire their own adapter
|
|
80
|
+
* (a real KbStore-backed sink, an HTTP relay to gtm-agent's knowledge
|
|
81
|
+
* service, etc.) via `createMcpServer({ feedbackStore })`.
|
|
82
|
+
*
|
|
83
|
+
* Feedback events are append-only: every rating is a new event with a
|
|
84
|
+
* fresh id, even when the same delegation is rated multiple times. The
|
|
85
|
+
* caller decides how to roll up scores downstream.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/** @experimental */
|
|
89
|
+
interface FeedbackEvent {
|
|
90
|
+
id: string;
|
|
91
|
+
refersTo: DelegateFeedbackArgs['refersTo'];
|
|
92
|
+
rating: DelegateFeedbackArgs['rating'];
|
|
93
|
+
by: DelegateFeedbackArgs['by'];
|
|
94
|
+
capturedAt: string;
|
|
95
|
+
namespace?: string;
|
|
96
|
+
}
|
|
97
|
+
/** @experimental */
|
|
98
|
+
interface FeedbackStore {
|
|
99
|
+
/** Append a new event. Never dedupes — every rating is its own event. */
|
|
100
|
+
put(event: FeedbackEvent): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* List events filtered by `namespace`. When `namespace` is omitted, list
|
|
103
|
+
* across all namespaces. Returns events in insertion order.
|
|
104
|
+
*/
|
|
105
|
+
list(filter?: {
|
|
106
|
+
namespace?: string;
|
|
107
|
+
refersToRef?: string;
|
|
108
|
+
}): Promise<FeedbackEvent[]>;
|
|
109
|
+
}
|
|
110
|
+
/** @experimental */
|
|
111
|
+
declare class InMemoryFeedbackStore implements FeedbackStore {
|
|
112
|
+
private readonly events;
|
|
113
|
+
put(event: FeedbackEvent): Promise<void>;
|
|
114
|
+
list(filter?: {
|
|
115
|
+
namespace?: string;
|
|
116
|
+
refersToRef?: string;
|
|
117
|
+
}): Promise<FeedbackEvent[]>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Project a `FeedbackEvent` down to the snapshot shape carried on
|
|
121
|
+
* `delegation_history` entries.
|
|
122
|
+
*
|
|
123
|
+
* @experimental
|
|
124
|
+
*/
|
|
125
|
+
declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapshot;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @experimental
|
|
129
|
+
*
|
|
130
|
+
* Stdio JSON-RPC MCP server exposing the 5 delegation tools to sandbox
|
|
131
|
+
* coding-harness agents (claude-code, codex, opencode, ...).
|
|
132
|
+
*
|
|
133
|
+
* The server is transport-bound but topology-free: tool execution is
|
|
134
|
+
* delegated to handler functions composed from a queue, a feedback
|
|
135
|
+
* store, and per-profile run delegates. Consumers wire those at
|
|
136
|
+
* construction time. The `agent-runtime-mcp` bin spins up a default
|
|
137
|
+
* configuration for the common case (real sandbox client + coder).
|
|
138
|
+
*
|
|
139
|
+
* Wire protocol: line-delimited JSON-RPC 2.0 over stdio. Each line is
|
|
140
|
+
* one request; each response is one line. `tools/list` and `tools/call`
|
|
141
|
+
* mirror the MCP 2024-11-05 spec; we do not pull in
|
|
142
|
+
* `@modelcontextprotocol/sdk` to keep the dependency footprint zero.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/** @experimental */
|
|
146
|
+
interface McpServerOptions {
|
|
147
|
+
/** Required to enable delegate_code. */
|
|
148
|
+
coderDelegate?: CoderDelegate;
|
|
149
|
+
/**
|
|
150
|
+
* Required to enable delegate_research. The substrate cannot ship a
|
|
151
|
+
* default — wire one that closes over your `runLoop` + a
|
|
152
|
+
* researcher profile (typically `@tangle-network/agent-knowledge`'s
|
|
153
|
+
* `researcherProfile` / `multiHarnessResearcherFanout`).
|
|
154
|
+
*/
|
|
155
|
+
researcherDelegate?: ResearcherDelegate;
|
|
156
|
+
/**
|
|
157
|
+
* Required to enable delegate_ui_audit. Wire one that closes over your
|
|
158
|
+
* `runLoop` + `uiAuditorProfile` + a `SandboxClient` (the
|
|
159
|
+
* canonical in-process choice is `createInProcessUiAuditClient` from
|
|
160
|
+
* `@tangle-network/agent-runtime/profiles`) + your vision judge.
|
|
161
|
+
*/
|
|
162
|
+
uiAuditorDelegate?: UiAuditorDelegate;
|
|
163
|
+
/** Override the default in-memory feedback store. */
|
|
164
|
+
feedbackStore?: FeedbackStore;
|
|
165
|
+
/** Override the default in-memory task queue. */
|
|
166
|
+
queue?: DelegationTaskQueue;
|
|
167
|
+
/**
|
|
168
|
+
* Record deterministic detached-session resume keys on single-variant
|
|
169
|
+
* coder/researcher submissions so a durable queue can resume them after a
|
|
170
|
+
* restart. Enable only when the wired delegates dispatch via sandbox
|
|
171
|
+
* sessions (`driveTurn`) AND `queue` persists records — the keys are inert
|
|
172
|
+
* otherwise. The bin turns this on alongside the durable store for
|
|
173
|
+
* session-backed (sibling/fleet) placements.
|
|
174
|
+
*/
|
|
175
|
+
detachedDispatch?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Extra tools to serve alongside the delegation tools, for example
|
|
178
|
+
* `createCoordinationTools(...).tools`. Registered after the built-ins; a
|
|
179
|
+
* duplicate name throws so delegation tools cannot be shadowed silently.
|
|
180
|
+
*/
|
|
181
|
+
extraTools?: McpToolDescriptor[];
|
|
182
|
+
/**
|
|
183
|
+
* Inherited trace identity (`readTraceContextFromEnv()`) stamped on every
|
|
184
|
+
* record the DEFAULT queue creates. Ignored when `queue` is supplied —
|
|
185
|
+
* pass `traceContext` to that queue's constructor instead.
|
|
186
|
+
*/
|
|
187
|
+
traceContext?: TraceContext;
|
|
188
|
+
/** Server display name surfaced via `initialize`. Default `'agent-runtime-mcp'`. */
|
|
189
|
+
serverName?: string;
|
|
190
|
+
/** Server version surfaced via `initialize`. Default = the package version baked at build time. */
|
|
191
|
+
serverVersion?: string;
|
|
192
|
+
}
|
|
193
|
+
/** @experimental */
|
|
194
|
+
interface McpToolDescriptor {
|
|
195
|
+
name: string;
|
|
196
|
+
description: string;
|
|
197
|
+
inputSchema: Record<string, unknown>;
|
|
198
|
+
handler: (raw: unknown) => Promise<unknown>;
|
|
199
|
+
}
|
|
200
|
+
/** @experimental */
|
|
201
|
+
interface McpServer {
|
|
202
|
+
/** Tools currently registered (depend on which delegates were wired). */
|
|
203
|
+
readonly tools: ReadonlyMap<string, McpToolDescriptor>;
|
|
204
|
+
/** The underlying queue — exposed so tests can introspect it. */
|
|
205
|
+
readonly queue: DelegationTaskQueue;
|
|
206
|
+
/** The feedback store — exposed for the same reason. */
|
|
207
|
+
readonly feedbackStore: FeedbackStore;
|
|
208
|
+
/** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */
|
|
209
|
+
handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>;
|
|
210
|
+
/** Drive the server on a stdio-shaped transport until `stop()` is called. */
|
|
211
|
+
serve(transport?: McpTransport): Promise<void>;
|
|
212
|
+
/** Stop a `serve` call. Subsequent requests are rejected. */
|
|
213
|
+
stop(): void;
|
|
214
|
+
}
|
|
215
|
+
/** @experimental */
|
|
216
|
+
interface McpTransport {
|
|
217
|
+
input: NodeJS.ReadableStream;
|
|
218
|
+
output: NodeJS.WritableStream;
|
|
219
|
+
}
|
|
220
|
+
/** @experimental */
|
|
221
|
+
interface JsonRpcMessage {
|
|
222
|
+
jsonrpc: '2.0';
|
|
223
|
+
id?: number | string | null;
|
|
224
|
+
method: string;
|
|
225
|
+
params?: unknown;
|
|
226
|
+
}
|
|
227
|
+
/** @experimental */
|
|
228
|
+
interface JsonRpcResponse {
|
|
229
|
+
jsonrpc: '2.0';
|
|
230
|
+
id: number | string | null;
|
|
231
|
+
result?: unknown;
|
|
232
|
+
error?: {
|
|
233
|
+
code: number;
|
|
234
|
+
message: string;
|
|
235
|
+
data?: unknown;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/** @experimental */
|
|
239
|
+
declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
240
|
+
/**
|
|
241
|
+
* In-process pair of `Readable` + `Writable` streams suitable for driving
|
|
242
|
+
* `server.serve(...)` from a test. Returns the agent-side stream (the
|
|
243
|
+
* client writes to it) and the server-side stream (the test reads from it).
|
|
244
|
+
*
|
|
245
|
+
* @experimental
|
|
246
|
+
*/
|
|
247
|
+
declare function createInProcessTransport(): {
|
|
248
|
+
transport: McpTransport;
|
|
249
|
+
clientWrite(line: string): void;
|
|
250
|
+
clientClose(): void;
|
|
251
|
+
readServer(): Promise<JsonRpcResponse[]>;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @experimental
|
|
256
|
+
*
|
|
257
|
+
* MCP binding for a live `Scope`. A sandbox driver gets the same small verbs
|
|
258
|
+
* the in-process driver has: spawn, observe, await, steer, ask/answer, analyze,
|
|
259
|
+
* and stop. Settled outputs remain Scope artifacts; product code can project
|
|
260
|
+
* them into any UI/report envelope it needs.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/** A worker the driver has drained via `await_event`. */
|
|
264
|
+
interface SettledWorker {
|
|
265
|
+
readonly id: string;
|
|
266
|
+
readonly status: 'done' | 'down';
|
|
267
|
+
readonly score?: number;
|
|
268
|
+
readonly valid?: boolean;
|
|
269
|
+
readonly outRef?: string;
|
|
270
|
+
readonly reason?: string;
|
|
271
|
+
}
|
|
272
|
+
type QuestionLevel = 'worker' | 'driver' | 'loop';
|
|
273
|
+
type QuestionUrgency = 'continue-without' | 'blocks-step' | 'blocks-run';
|
|
274
|
+
interface QuestionOption {
|
|
275
|
+
readonly label: string;
|
|
276
|
+
readonly tradeoff: string;
|
|
277
|
+
}
|
|
278
|
+
interface Question {
|
|
279
|
+
readonly id: string;
|
|
280
|
+
readonly from: string;
|
|
281
|
+
readonly level: QuestionLevel;
|
|
282
|
+
readonly question: string;
|
|
283
|
+
readonly reason: string;
|
|
284
|
+
readonly urgency: QuestionUrgency;
|
|
285
|
+
readonly options?: ReadonlyArray<QuestionOption>;
|
|
286
|
+
}
|
|
287
|
+
type QuestionDecision = {
|
|
288
|
+
readonly kind: 'answer';
|
|
289
|
+
readonly answer: string;
|
|
290
|
+
readonly by: string;
|
|
291
|
+
} | {
|
|
292
|
+
readonly kind: 'defer';
|
|
293
|
+
readonly reason: string;
|
|
294
|
+
} | {
|
|
295
|
+
readonly kind: 'escalate';
|
|
296
|
+
readonly to: 'parent' | 'user' | string;
|
|
297
|
+
readonly reason: string;
|
|
298
|
+
};
|
|
299
|
+
interface QuestionRecord extends Question {
|
|
300
|
+
readonly status: 'open' | 'answered' | 'deferred' | 'escalated';
|
|
301
|
+
readonly decision?: QuestionDecision;
|
|
302
|
+
readonly openedAt: number;
|
|
303
|
+
}
|
|
304
|
+
type QuestionPolicy = 'auto' | 'mustDecide' | 'bubble' | 'failClosed';
|
|
305
|
+
interface AnalystRegistry {
|
|
306
|
+
readonly kinds: ReadonlyArray<{
|
|
307
|
+
id: string;
|
|
308
|
+
description: string;
|
|
309
|
+
area: string;
|
|
310
|
+
}>;
|
|
311
|
+
readonly run: (kindId: string, trace: unknown) => Promise<unknown>;
|
|
312
|
+
}
|
|
313
|
+
/** A trace-analyst result re-entered as a message on the bus (the `finding` event kind). */
|
|
314
|
+
interface AnalystFindingEvent {
|
|
315
|
+
readonly fromWorker: string;
|
|
316
|
+
readonly analyst: string;
|
|
317
|
+
readonly findings: unknown;
|
|
318
|
+
}
|
|
319
|
+
/** A parent→child message (the down-leg): recorded for observability, delivered via the child inbox,
|
|
320
|
+
* never pulled back by the parent. `delivered` mirrors whether the live child accepted it. */
|
|
321
|
+
interface DownMessageEvent {
|
|
322
|
+
readonly toWorker: string;
|
|
323
|
+
readonly instruction: string;
|
|
324
|
+
readonly delivered: boolean;
|
|
325
|
+
}
|
|
326
|
+
/** Every message on the one typed pipe. UP (child→parent): question / settled / finding — queued for
|
|
327
|
+
* the driver to `pull`. DOWN (parent→child): steer / answer — record-only (history + subscribers),
|
|
328
|
+
* routed to the child inbox. New kinds are additive. */
|
|
329
|
+
type CoordinationEvent = {
|
|
330
|
+
readonly type: 'question';
|
|
331
|
+
readonly question: QuestionRecord;
|
|
332
|
+
} | {
|
|
333
|
+
readonly type: 'settled';
|
|
334
|
+
readonly worker: SettledWorker;
|
|
335
|
+
} | {
|
|
336
|
+
readonly type: 'finding';
|
|
337
|
+
readonly finding: AnalystFindingEvent;
|
|
338
|
+
} | {
|
|
339
|
+
readonly type: 'steer';
|
|
340
|
+
readonly down: DownMessageEvent;
|
|
341
|
+
} | {
|
|
342
|
+
readonly type: 'answer';
|
|
343
|
+
readonly down: DownMessageEvent;
|
|
344
|
+
readonly questionId: string;
|
|
345
|
+
};
|
|
346
|
+
type MakeWorkerAgent = (profile: unknown) => Agent<unknown, unknown>;
|
|
347
|
+
interface CoordinationToolsOptions {
|
|
348
|
+
readonly scope: Scope<unknown>;
|
|
349
|
+
readonly blobs: ResultBlobStore;
|
|
350
|
+
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
351
|
+
readonly perWorker: Budget;
|
|
352
|
+
readonly analysts?: AnalystRegistry;
|
|
353
|
+
readonly onEvent?: (event: CoordinationEvent) => void | Promise<void>;
|
|
354
|
+
readonly questionPolicy?: QuestionPolicy;
|
|
355
|
+
/** Analyst kind ids to run AUTOMATICALLY when a worker settles `done` (the analyst-on-settle
|
|
356
|
+
* hook). Each result is published as a `finding` event on the bus — pass-through to subscribers
|
|
357
|
+
* and queued for the driver to pull via `await_event`. Omit/empty = no auto-analysis (default;
|
|
358
|
+
* the driver can still run lenses on demand via `run_analyst`). Requires `analysts`. */
|
|
359
|
+
readonly analyzeOnSettle?: ReadonlyArray<string>;
|
|
360
|
+
}
|
|
361
|
+
interface CoordinationTools {
|
|
362
|
+
readonly tools: McpToolDescriptor[];
|
|
363
|
+
isStopped(): boolean;
|
|
364
|
+
stopReason(): string | undefined;
|
|
365
|
+
settled(): ReadonlyArray<SettledWorker>;
|
|
366
|
+
questions(): ReadonlyArray<QuestionRecord>;
|
|
367
|
+
/** The full ordered log of every bus event — UP (settled / question / finding) and DOWN
|
|
368
|
+
* (steer / answer) — the observability audit + replay trail. Each record carries seq,
|
|
369
|
+
* timestamp, and priority. */
|
|
370
|
+
history(): ReadonlyArray<BusRecord<CoordinationEvent>>;
|
|
371
|
+
/** Bus throughput counters (published / pulled / by-kind) for live dashboards. */
|
|
372
|
+
stats(): BusStats;
|
|
373
|
+
/** Raise a `finding` on the bus from outside the settle hook — the seam an ONLINE detector
|
|
374
|
+
* (mid-run, on the worker pipe) uses to tell the driver "this worker is looping/erroring" the
|
|
375
|
+
* moment it happens, instead of only at settle. Queued for `await_event` + pass-through. */
|
|
376
|
+
raiseFinding(finding: AnalystFindingEvent): Promise<void>;
|
|
377
|
+
}
|
|
378
|
+
/** Build the driver's MCP tools over a live scope. */
|
|
379
|
+
declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
|
|
380
|
+
|
|
381
|
+
export { type AnalystRegistry as A, type BusEvent as B, type CoordinationEvent as C, type EventBus as E, type FeedbackStore as F, InMemoryFeedbackStore as I, type JsonRpcMessage as J, type MakeWorkerAgent as M, type PublishOptions as P, type Question as Q, type SettledWorker as S, type CoordinationTools as a, type CoordinationToolsOptions as b, type FeedbackEvent as c, type JsonRpcResponse as d, type McpServer as e, type McpServerOptions as f, type McpToolDescriptor as g, type McpTransport as h, type QuestionDecision as i, type QuestionPolicy as j, type QuestionRecord as k, createCoordinationTools as l, createInProcessTransport as m, createMcpServer as n, eventToSnapshot as o, type BusRecord as p, type BusStats as q, createEventBus as r };
|