@tangle-network/agent-runtime 0.53.0 → 0.54.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/README.md +27 -16
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +5 -3
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +2 -2
- package/dist/{chunk-K5M3SHEU.js → chunk-2BDXWZUC.js} +5 -34
- package/dist/chunk-2BDXWZUC.js.map +1 -0
- package/dist/chunk-A73RADPB.js +281 -0
- package/dist/chunk-A73RADPB.js.map +1 -0
- package/dist/chunk-FRBWCJLP.js +396 -0
- package/dist/chunk-FRBWCJLP.js.map +1 -0
- package/dist/chunk-GRAGM4MC.js +72 -0
- package/dist/chunk-GRAGM4MC.js.map +1 -0
- package/dist/{chunk-K6WP7PYW.js → chunk-JTH2FPCK.js} +3231 -424
- package/dist/chunk-JTH2FPCK.js.map +1 -0
- package/dist/{chunk-P4QNEXFC.js → chunk-KJH62YEK.js} +2 -2
- package/dist/{chunk-HNUXAZIJ.js → chunk-P5OKDSLB.js} +2 -2
- package/dist/{chunk-GSUO5QS6.js → chunk-VLF5RHEQ.js} +2 -5
- package/dist/{chunk-GSUO5QS6.js.map → chunk-VLF5RHEQ.js.map} +1 -1
- package/dist/{chunk-JFIYKDXF.js → chunk-XRYEZPR6.js} +2 -1
- package/dist/chunk-XRYEZPR6.js.map +1 -0
- package/dist/{coder-LKm3Mczw.d.ts → coder-CEkUFv8h.d.ts} +1 -1
- package/dist/{types-CNDJCL_0.d.ts → coordination-BMzskrUR.d.ts} +268 -2
- package/dist/{kb-gate-CKfykcYQ.d.ts → delegates-BPLIl8EC.d.ts} +491 -566
- package/dist/index.d.ts +7 -7
- package/dist/index.js +23 -80
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -2
- package/dist/kb-gate-CuzMYGYM.d.ts +76 -0
- package/dist/{loop-runner-bin-D4Ir7b00.d.ts → loop-runner-bin-BGpVVyXp.d.ts} +6 -27
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +6 -5
- package/dist/loops.d.ts +8 -6
- package/dist/loops.js +32 -8
- package/dist/mcp/bin.js +94 -30
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +9 -272
- package/dist/mcp/index.js +45 -365
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-CKfR3EMh.d.ts → openai-tools-CoeLQ7Uo.d.ts} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +4 -4
- package/dist/{router-client-B0Qi1NiN.d.ts → router-client-30Y_pca8.d.ts} +1 -1
- package/dist/{run-loop-DgVhucoR.d.ts → run-loop-DluzfJ2h.d.ts} +1 -1
- package/dist/runtime.d.ts +424 -23
- package/dist/runtime.js +32 -8
- package/dist/topology.d.ts +54 -1
- package/dist/topology.js +222 -0
- package/dist/topology.js.map +1 -1
- package/dist/{types-CklkW4Eh.d.ts → types-C8rNlxfV.d.ts} +4 -4
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +4 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +5 -5
- package/skills/agent-runtime-adoption/SKILL.md +54 -46
- package/skills/build-with-agent-runtime/SKILL.md +12 -8
- package/skills/loop-writer/SKILL.md +9 -1
- package/skills/supervise/SKILL.md +24 -0
- package/dist/chunk-5M2WDWBI.js +0 -908
- package/dist/chunk-5M2WDWBI.js.map +0 -1
- package/dist/chunk-AYRQZRDV.js +0 -623
- package/dist/chunk-AYRQZRDV.js.map +0 -1
- package/dist/chunk-FO4DCM7R.js +0 -1356
- package/dist/chunk-FO4DCM7R.js.map +0 -1
- package/dist/chunk-JFIYKDXF.js.map +0 -1
- package/dist/chunk-K5M3SHEU.js.map +0 -1
- package/dist/chunk-K6WP7PYW.js.map +0 -1
- package/dist/driver-B2RKkVJW.d.ts +0 -221
- /package/dist/{chunk-P4QNEXFC.js.map → chunk-KJH62YEK.js.map} +0 -0
- /package/dist/{chunk-HNUXAZIJ.js.map → chunk-P5OKDSLB.js.map} +0 -0
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
DELEGATION_STATUS_DESCRIPTION,
|
|
15
15
|
DELEGATION_STATUS_INPUT_SCHEMA,
|
|
16
16
|
DELEGATION_STATUS_TOOL_NAME
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-JTH2FPCK.js";
|
|
18
18
|
|
|
19
19
|
// src/mcp/openai-tools.ts
|
|
20
20
|
function buildTool(name, description, parameters) {
|
|
@@ -61,4 +61,4 @@ export {
|
|
|
61
61
|
mcpToolsForRuntimeMcp,
|
|
62
62
|
mcpToolsForRuntimeMcpSubset
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-KJH62YEK.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AnalystError,
|
|
3
3
|
extractLlmCallEvent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VLF5RHEQ.js";
|
|
5
5
|
|
|
6
6
|
// src/analyst-loop/iterations-to-trace-store.ts
|
|
7
7
|
import {
|
|
@@ -577,4 +577,4 @@ export {
|
|
|
577
577
|
iterationsToTraceStore,
|
|
578
578
|
runAnalystLoop
|
|
579
579
|
};
|
|
580
|
-
//# sourceMappingURL=chunk-
|
|
580
|
+
//# sourceMappingURL=chunk-P5OKDSLB.js.map
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
import { AgentEvalError } from "@tangle-network/agent-eval";
|
|
3
3
|
import {
|
|
4
4
|
AgentEvalError as AgentEvalError2,
|
|
5
|
-
CaptureIntegrityError,
|
|
6
5
|
ConfigError,
|
|
7
6
|
JudgeError,
|
|
8
7
|
NotFoundError,
|
|
9
|
-
|
|
10
|
-
ValidationError,
|
|
11
|
-
VerificationError
|
|
8
|
+
ValidationError
|
|
12
9
|
} from "@tangle-network/agent-eval";
|
|
13
10
|
var SessionMismatchError = class extends AgentEvalError {
|
|
14
11
|
sessionBackend;
|
|
@@ -143,4 +140,4 @@ export {
|
|
|
143
140
|
extractLlmCallEvent,
|
|
144
141
|
mapSandboxEvent
|
|
145
142
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-VLF5RHEQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/runtime/sandbox-events.ts"],"sourcesContent":["/**\n * @stable\n *\n * Error taxonomy for `@tangle-network/agent-runtime`.\n *\n * Public contract: every error this package throws as part of its consumer-\n * facing API either extends `AgentEvalError` (re-exported here for ergonomic\n * `instanceof` checks at the runtime boundary) or extends one of the\n * runtime-specific subclasses below.\n *\n * Internal invariant guards (`throw new Error('this should never happen')`)\n * remain plain `Error` — they are programmer-mistake assertions, not\n * consumer-catchable contract failures.\n *\n * Subclassing strategy: where a runtime-specific failure maps cleanly to an\n * agent-eval code (validation, config, not_found), we re-use the agent-eval\n * subclass. Runtime-only failure modes (session resume against the wrong\n * backend, backend transport errors) get fresh subclasses that still carry an\n * `AgentEvalErrorCode` so cross-package handlers can pattern-match without\n * importing the runtime.\n */\n\nimport { AgentEvalError } from '@tangle-network/agent-eval'\n\nexport {\n AgentEvalError,\n type AgentEvalErrorCode,\n CaptureIntegrityError,\n ConfigError,\n JudgeError,\n NotFoundError,\n ReplayError,\n ValidationError,\n VerificationError,\n} from '@tangle-network/agent-eval'\n\n/**\n * @stable\n *\n * Caller asked to resume a session against a backend whose `kind` does not\n * match the session's recorded backend. This is a routing bug — the same\n * session id was reused across two different backend implementations — and\n * is not retryable without picking the right backend.\n */\nexport class SessionMismatchError extends AgentEvalError {\n readonly sessionBackend: string\n readonly requestedBackend: string\n\n constructor(sessionBackend: string, requestedBackend: string, options?: { cause?: unknown }) {\n super(\n 'validation',\n `Cannot resume ${sessionBackend} session with ${requestedBackend} backend`,\n options,\n )\n this.sessionBackend = sessionBackend\n this.requestedBackend = requestedBackend\n }\n}\n\n/**\n * @stable\n *\n * A backend transport call (HTTP, gRPC, sidecar IPC) failed with a non-success\n * status. Distinct from `JudgeError` (which is structural / unrecoverable)\n * because backend failures are sometimes retryable and consumers may want to\n * branch on the upstream status code.\n */\nexport class BackendTransportError extends AgentEvalError {\n readonly backend: string\n readonly status?: number\n /**\n * Truncated upstream response body (≤2 KiB) when available. Diagnostic\n * only — surfaces in `backend_error.error.body` and `final.error.body`\n * so operators can see \"free_tier_limit\", \"invalid_api_key\", etc. without\n * cracking the log line open.\n */\n readonly body?: string\n\n constructor(\n backend: string,\n message: string,\n options?: { cause?: unknown; status?: number; body?: string },\n ) {\n super('config', message, options)\n this.backend = backend\n this.status = options?.status\n this.body = options?.body\n }\n}\n\n/**\n * @stable\n *\n * A runtime-run lifecycle method was called in an order the state machine does\n * not allow: `persist()` before `complete()`, `complete()` twice, etc.\n */\nexport class RuntimeRunStateError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n * @stable\n *\n * The dynamic-loop planner returned an unusable topology move — the LLM emitted\n * no parseable envelope, an unknown `kind`, or a structurally-invalid move\n * (e.g. a fanout with zero tasks). This is a structural failure of the\n * agent-authored topology, not a config mistake: the planner ran but its output\n * cannot drive the kernel. Carries `validation` so cross-package handlers can\n * pattern-match without importing the runtime. Fail loud — never substitute a\n * default move, or the loop silently runs a topology nobody chose.\n */\nexport class PlannerError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n * The analyst loop could not read or run over a round's trace — e.g. an empty round\n * (no iterations to analyze) or a malformed trace projection. Fail loud: a silent empty\n * store would mask a broken capture path and the driver would steer on nothing.\n */\nexport class AnalystError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n","/**\n * Sandbox-event → runtime-event mapping.\n *\n * The sandbox SDK emits a polymorphic `SandboxEvent = { type, data, id? }`\n * whose `type` vocabulary is backend-determined (opencode, etc.) rather than\n * enumerated by the SDK. Two consumers project it:\n * - the loop kernel's cost ledger (`extractLlmCallEvent`) — sums usage off\n * every cost-bearing event, regardless of stream shape;\n * - the `AgentRuntime.act` streaming contract (`mapSandboxEvent`) — projects\n * incremental events to the `RuntimeStreamEvent` chat-UX vocabulary.\n *\n * Both live here so the empirically-observed `type` vocabulary has one home.\n */\n\nimport type { SandboxEvent } from '@tangle-network/sandbox'\nimport type { RuntimeStreamEvent } from '../types'\n\n/**\n * Extract a `RuntimeStreamEvent`-shaped `llm_call` from a sandbox event when\n * the event carries usage/cost data. Returns `undefined` for non-cost events\n * so the kernel can iterate the full stream without branching.\n *\n * Canonical cost-carrying types observed in the wild:\n * - `llm_call` — `data: { model, tokensIn, tokensOut, costUsd, ... }`\n * - `message.completed` / `result` — `data: { usage: { inputTokens,\n * outputTokens, totalCostUsd? } }`\n * - `cost.usage` / `usage` — same shape under a dedicated type\n *\n * Numeric coercion is strict: `Number.isFinite` gates every accumulator write\n * so a sentinel `NaN` from a misbehaving backend cannot poison the ledger.\n */\nexport function extractLlmCallEvent(\n event: SandboxEvent,\n agentRunName: string,\n): (RuntimeStreamEvent & { type: 'llm_call' }) | undefined {\n if (!event || typeof event !== 'object') return undefined\n const type = String(event.type ?? '')\n const data =\n event.data && typeof event.data === 'object'\n ? (event.data as Record<string, unknown>)\n : ({} as Record<string, unknown>)\n\n if (type === 'llm_call' || type === 'cost.usage' || type === 'usage') {\n return buildLlmCall(data, agentRunName)\n }\n if (type === 'message.completed' || type === 'result' || type === 'final') {\n const usage = data.usage as Record<string, unknown> | undefined\n if (!usage || typeof usage !== 'object') return undefined\n return buildLlmCall({ ...usage, model: data.model ?? usage.model }, agentRunName)\n }\n // sandbox 0.4.0 terminal event: `data = { tokenUsage: { inputTokens, outputTokens,\n // reasoningTokens, cacheReadInputTokens }, totalCostUsd }`. Usage lives under\n // `tokenUsage` (not `usage`) and the cost is top-level — neither matched the\n // branches above, so an in-process loopDispatch run reported {0,0} and the\n // backend-integrity guard misread a real run as a stub. Reasoning tokens are\n // billed output (reasoning models), so they fold into the output count.\n if (type === 'done') {\n const usage = data.tokenUsage as Record<string, unknown> | undefined\n if (!usage || typeof usage !== 'object') return undefined\n const out = pickFiniteNumber(usage, ['outputTokens', 'completion_tokens', 'tokensOut'])\n const reasoning = pickFiniteNumber(usage, ['reasoningTokens'])\n const mergedOut =\n out !== undefined || reasoning !== undefined ? (out ?? 0) + (reasoning ?? 0) : undefined\n return buildLlmCall(\n {\n inputTokens: usage.inputTokens,\n outputTokens: mergedOut,\n totalCostUsd: data.totalCostUsd,\n model: data.model ?? usage.model,\n },\n agentRunName,\n )\n }\n return undefined\n}\n\nfunction buildLlmCall(\n data: Record<string, unknown>,\n agentRunName: string,\n): (RuntimeStreamEvent & { type: 'llm_call' }) | undefined {\n const tokensIn = pickFiniteNumber(data, ['tokensIn', 'inputTokens', 'prompt_tokens'])\n const tokensOut = pickFiniteNumber(data, ['tokensOut', 'outputTokens', 'completion_tokens'])\n const costUsd = pickFiniteNumber(data, ['costUsd', 'totalCostUsd', 'cost_usd', 'cost'])\n if (tokensIn === undefined && tokensOut === undefined && costUsd === undefined) {\n return undefined\n }\n const model = typeof data.model === 'string' && data.model.length > 0 ? data.model : agentRunName\n const event: RuntimeStreamEvent & { type: 'llm_call' } = {\n type: 'llm_call',\n model,\n }\n if (tokensIn !== undefined) event.tokensIn = tokensIn\n if (tokensOut !== undefined) event.tokensOut = tokensOut\n if (costUsd !== undefined) event.costUsd = costUsd\n return event\n}\n\nfunction pickFiniteNumber(data: Record<string, unknown>, keys: string[]): number | undefined {\n for (const key of keys) {\n const value = data[key]\n if (typeof value === 'number' && Number.isFinite(value)) return value\n }\n return undefined\n}\n\n/**\n * Project one `SandboxEvent` onto the `RuntimeStreamEvent` chat-UX vocabulary,\n * for runtimes that bridge a sandbox `streamPrompt` into the\n * `AgentRuntime.act` streaming contract. Returns `undefined` for events that\n * have no faithful projection — the raw stream is preserved separately for the\n * `OutputAdapter`, so an unmapped event never loses data.\n *\n * Mapped (the task-optional incremental variants — no synthesized task\n * lifecycle, no guessed tool-part shapes):\n * - `message.part.updated` text part → `text_delta`\n * - `message.part.updated` reasoning/thinking part → `reasoning_delta`\n * - cost-bearing events → `llm_call` (shared with the ledger extractor)\n *\n * The opencode backend emits incremental text as\n * `{ type: 'message.part.updated', data: { part: { type, text }, delta } }`;\n * `delta` is the increment, `part.text` the running accumulation.\n */\nexport function mapSandboxEvent(\n event: SandboxEvent,\n opts: { agentRunName?: string } = {},\n): RuntimeStreamEvent | undefined {\n if (!event || typeof event !== 'object') return undefined\n const type = String(event.type ?? '')\n const data =\n event.data && typeof event.data === 'object'\n ? (event.data as Record<string, unknown>)\n : ({} as Record<string, unknown>)\n\n if (type === 'message.part.updated') {\n const part =\n data.part && typeof data.part === 'object' ? (data.part as Record<string, unknown>) : {}\n const partType = String(part.type ?? '')\n const delta = typeof data.delta === 'string' ? data.delta : undefined\n const text = delta ?? (typeof part.text === 'string' ? part.text : undefined)\n if (text === undefined) return undefined\n if (partType === 'text') return { type: 'text_delta', text }\n if (partType === 'reasoning' || partType === 'thinking')\n return { type: 'reasoning_delta', text }\n return undefined\n }\n\n return extractLlmCallEvent(event, opts.agentRunName ?? 'agent')\n}\n"],"mappings":";AAsBA,SAAS,sBAAsB;AAE/B;AAAA,EACE,kBAAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUA,IAAM,uBAAN,cAAmC,eAAe;AAAA,EAC9C;AAAA,EACA;AAAA,EAET,YAAY,gBAAwB,kBAA0B,SAA+B;AAC3F;AAAA,MACE;AAAA,MACA,iBAAiB,cAAc,iBAAiB,gBAAgB;AAAA,MAChE;AAAA,IACF;AACA,SAAK,iBAAiB;AACtB,SAAK,mBAAmB;AAAA,EAC1B;AACF;AAUO,IAAM,wB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AM,SAAS,WAC/B,MAAM,OACN,CAAC;AAER,MAAI,SAAS,wBAAwB;AACnC,UAAM,OACJ,KAAK,QAAQ,OAAO,KAAK,SAAS,WAAY,KAAK,OAAmC,CAAC;AACzF,UAAM,WAAW,OAAO,KAAK,QAAQ,EAAE;AACvC,UAAM,QAAQ,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ;AAC5D,UAAM,OAAO,UAAU,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACnE,QAAI,SAAS,OAAW,QAAO;AAC/B,QAAI,aAAa,OAAQ,QAAO,EAAE,MAAM,cAAc,KAAK;AAC3D,QAAI,aAAa,eAAe,aAAa;AAC3C,aAAO,EAAE,MAAM,mBAAmB,KAAK;AACzC,WAAO;AAAA,EACT;AAEA,SAAO,oBAAoB,OAAO,KAAK,gBAAgB,OAAO;AAChE;","names":["AgentEvalError"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/runtime/sandbox-events.ts"],"sourcesContent":["/**\n * @stable\n *\n * Error taxonomy for `@tangle-network/agent-runtime`.\n *\n * Public contract: every error this package throws as part of its consumer-\n * facing API either extends `AgentEvalError` (re-exported here for ergonomic\n * `instanceof` checks at the runtime boundary) or extends one of the\n * runtime-specific subclasses below.\n *\n * Internal invariant guards (`throw new Error('this should never happen')`)\n * remain plain `Error` — they are programmer-mistake assertions, not\n * consumer-catchable contract failures.\n *\n * Subclassing strategy: where a runtime-specific failure maps cleanly to an\n * agent-eval code (validation, config, not_found), we re-use the agent-eval\n * subclass. Runtime-only failure modes (session resume against the wrong\n * backend, backend transport errors) get fresh subclasses that still carry an\n * `AgentEvalErrorCode` so cross-package handlers can pattern-match without\n * importing the runtime.\n */\n\nimport { AgentEvalError } from '@tangle-network/agent-eval'\n\nexport {\n AgentEvalError,\n type AgentEvalErrorCode,\n ConfigError,\n JudgeError,\n NotFoundError,\n ValidationError,\n} from '@tangle-network/agent-eval'\n\n/**\n * @stable\n *\n * Caller asked to resume a session against a backend whose `kind` does not\n * match the session's recorded backend. This is a routing bug — the same\n * session id was reused across two different backend implementations — and\n * is not retryable without picking the right backend.\n */\nexport class SessionMismatchError extends AgentEvalError {\n readonly sessionBackend: string\n readonly requestedBackend: string\n\n constructor(sessionBackend: string, requestedBackend: string, options?: { cause?: unknown }) {\n super(\n 'validation',\n `Cannot resume ${sessionBackend} session with ${requestedBackend} backend`,\n options,\n )\n this.sessionBackend = sessionBackend\n this.requestedBackend = requestedBackend\n }\n}\n\n/**\n * @stable\n *\n * A backend transport call (HTTP, gRPC, sidecar IPC) failed with a non-success\n * status. Distinct from `JudgeError` (which is structural / unrecoverable)\n * because backend failures are sometimes retryable and consumers may want to\n * branch on the upstream status code.\n */\nexport class BackendTransportError extends AgentEvalError {\n readonly backend: string\n readonly status?: number\n /**\n * Truncated upstream response body (≤2 KiB) when available. Diagnostic\n * only — surfaces in `backend_error.error.body` and `final.error.body`\n * so operators can see \"free_tier_limit\", \"invalid_api_key\", etc. without\n * cracking the log line open.\n */\n readonly body?: string\n\n constructor(\n backend: string,\n message: string,\n options?: { cause?: unknown; status?: number; body?: string },\n ) {\n super('config', message, options)\n this.backend = backend\n this.status = options?.status\n this.body = options?.body\n }\n}\n\n/**\n * @stable\n *\n * A runtime-run lifecycle method was called in an order the state machine does\n * not allow: `persist()` before `complete()`, `complete()` twice, etc.\n */\nexport class RuntimeRunStateError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n * @stable\n *\n * The dynamic-loop planner returned an unusable topology move — the LLM emitted\n * no parseable envelope, an unknown `kind`, or a structurally-invalid move\n * (e.g. a fanout with zero tasks). This is a structural failure of the\n * agent-authored topology, not a config mistake: the planner ran but its output\n * cannot drive the kernel. Carries `validation` so cross-package handlers can\n * pattern-match without importing the runtime. Fail loud — never substitute a\n * default move, or the loop silently runs a topology nobody chose.\n */\nexport class PlannerError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n * The analyst loop could not read or run over a round's trace — e.g. an empty round\n * (no iterations to analyze) or a malformed trace projection. Fail loud: a silent empty\n * store would mask a broken capture path and the driver would steer on nothing.\n */\nexport class AnalystError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n","/**\n * Sandbox-event → runtime-event mapping.\n *\n * The sandbox SDK emits a polymorphic `SandboxEvent = { type, data, id? }`\n * whose `type` vocabulary is backend-determined (opencode, etc.) rather than\n * enumerated by the SDK. Two consumers project it:\n * - the loop kernel's cost ledger (`extractLlmCallEvent`) — sums usage off\n * every cost-bearing event, regardless of stream shape;\n * - the `AgentRuntime.act` streaming contract (`mapSandboxEvent`) — projects\n * incremental events to the `RuntimeStreamEvent` chat-UX vocabulary.\n *\n * Both live here so the empirically-observed `type` vocabulary has one home.\n */\n\nimport type { SandboxEvent } from '@tangle-network/sandbox'\nimport type { RuntimeStreamEvent } from '../types'\n\n/**\n * Extract a `RuntimeStreamEvent`-shaped `llm_call` from a sandbox event when\n * the event carries usage/cost data. Returns `undefined` for non-cost events\n * so the kernel can iterate the full stream without branching.\n *\n * Canonical cost-carrying types observed in the wild:\n * - `llm_call` — `data: { model, tokensIn, tokensOut, costUsd, ... }`\n * - `message.completed` / `result` — `data: { usage: { inputTokens,\n * outputTokens, totalCostUsd? } }`\n * - `cost.usage` / `usage` — same shape under a dedicated type\n *\n * Numeric coercion is strict: `Number.isFinite` gates every accumulator write\n * so a sentinel `NaN` from a misbehaving backend cannot poison the ledger.\n */\nexport function extractLlmCallEvent(\n event: SandboxEvent,\n agentRunName: string,\n): (RuntimeStreamEvent & { type: 'llm_call' }) | undefined {\n if (!event || typeof event !== 'object') return undefined\n const type = String(event.type ?? '')\n const data =\n event.data && typeof event.data === 'object'\n ? (event.data as Record<string, unknown>)\n : ({} as Record<string, unknown>)\n\n if (type === 'llm_call' || type === 'cost.usage' || type === 'usage') {\n return buildLlmCall(data, agentRunName)\n }\n if (type === 'message.completed' || type === 'result' || type === 'final') {\n const usage = data.usage as Record<string, unknown> | undefined\n if (!usage || typeof usage !== 'object') return undefined\n return buildLlmCall({ ...usage, model: data.model ?? usage.model }, agentRunName)\n }\n // sandbox 0.4.0 terminal event: `data = { tokenUsage: { inputTokens, outputTokens,\n // reasoningTokens, cacheReadInputTokens }, totalCostUsd }`. Usage lives under\n // `tokenUsage` (not `usage`) and the cost is top-level — neither matched the\n // branches above, so an in-process loopDispatch run reported {0,0} and the\n // backend-integrity guard misread a real run as a stub. Reasoning tokens are\n // billed output (reasoning models), so they fold into the output count.\n if (type === 'done') {\n const usage = data.tokenUsage as Record<string, unknown> | undefined\n if (!usage || typeof usage !== 'object') return undefined\n const out = pickFiniteNumber(usage, ['outputTokens', 'completion_tokens', 'tokensOut'])\n const reasoning = pickFiniteNumber(usage, ['reasoningTokens'])\n const mergedOut =\n out !== undefined || reasoning !== undefined ? (out ?? 0) + (reasoning ?? 0) : undefined\n return buildLlmCall(\n {\n inputTokens: usage.inputTokens,\n outputTokens: mergedOut,\n totalCostUsd: data.totalCostUsd,\n model: data.model ?? usage.model,\n },\n agentRunName,\n )\n }\n return undefined\n}\n\nfunction buildLlmCall(\n data: Record<string, unknown>,\n agentRunName: string,\n): (RuntimeStreamEvent & { type: 'llm_call' }) | undefined {\n const tokensIn = pickFiniteNumber(data, ['tokensIn', 'inputTokens', 'prompt_tokens'])\n const tokensOut = pickFiniteNumber(data, ['tokensOut', 'outputTokens', 'completion_tokens'])\n const costUsd = pickFiniteNumber(data, ['costUsd', 'totalCostUsd', 'cost_usd', 'cost'])\n if (tokensIn === undefined && tokensOut === undefined && costUsd === undefined) {\n return undefined\n }\n const model = typeof data.model === 'string' && data.model.length > 0 ? data.model : agentRunName\n const event: RuntimeStreamEvent & { type: 'llm_call' } = {\n type: 'llm_call',\n model,\n }\n if (tokensIn !== undefined) event.tokensIn = tokensIn\n if (tokensOut !== undefined) event.tokensOut = tokensOut\n if (costUsd !== undefined) event.costUsd = costUsd\n return event\n}\n\nfunction pickFiniteNumber(data: Record<string, unknown>, keys: string[]): number | undefined {\n for (const key of keys) {\n const value = data[key]\n if (typeof value === 'number' && Number.isFinite(value)) return value\n }\n return undefined\n}\n\n/**\n * Project one `SandboxEvent` onto the `RuntimeStreamEvent` chat-UX vocabulary,\n * for runtimes that bridge a sandbox `streamPrompt` into the\n * `AgentRuntime.act` streaming contract. Returns `undefined` for events that\n * have no faithful projection — the raw stream is preserved separately for the\n * `OutputAdapter`, so an unmapped event never loses data.\n *\n * Mapped (the task-optional incremental variants — no synthesized task\n * lifecycle, no guessed tool-part shapes):\n * - `message.part.updated` text part → `text_delta`\n * - `message.part.updated` reasoning/thinking part → `reasoning_delta`\n * - cost-bearing events → `llm_call` (shared with the ledger extractor)\n *\n * The opencode backend emits incremental text as\n * `{ type: 'message.part.updated', data: { part: { type, text }, delta } }`;\n * `delta` is the increment, `part.text` the running accumulation.\n */\nexport function mapSandboxEvent(\n event: SandboxEvent,\n opts: { agentRunName?: string } = {},\n): RuntimeStreamEvent | undefined {\n if (!event || typeof event !== 'object') return undefined\n const type = String(event.type ?? '')\n const data =\n event.data && typeof event.data === 'object'\n ? (event.data as Record<string, unknown>)\n : ({} as Record<string, unknown>)\n\n if (type === 'message.part.updated') {\n const part =\n data.part && typeof data.part === 'object' ? (data.part as Record<string, unknown>) : {}\n const partType = String(part.type ?? '')\n const delta = typeof data.delta === 'string' ? data.delta : undefined\n const text = delta ?? (typeof part.text === 'string' ? part.text : undefined)\n if (text === undefined) return undefined\n if (partType === 'text') return { type: 'text_delta', text }\n if (partType === 'reasoning' || partType === 'thinking')\n return { type: 'reasoning_delta', text }\n return undefined\n }\n\n return extractLlmCallEvent(event, opts.agentRunName ?? 'agent')\n}\n"],"mappings":";AAsBA,SAAS,sBAAsB;AAE/B;AAAA,EACE,kBAAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUA,IAAM,uBAAN,cAAmC,eAAe;AAAA,EAC9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G,QAAO;AAAA,EAClE;AACA,SAAO;AACT;AAmBO,SAAS,gBACd,OACA,OAAkC,CAAC,GACH;AAChC,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAO,OAAO,MAAM,QAAQ,EAAE;AACpC,QAAM,OACJ,MAAM,QAAQ,OAAO,MAAM,SAAS,WAC/B,MAAM,OACN,CAAC;AAER,MAAI,SAAS,wBAAwB;AACnC,UAAM,OACJ,KAAK,QAAQ,OAAO,KAAK,SAAS,WAAY,KAAK,OAAmC,CAAC;AACzF,UAAM,WAAW,OAAO,KAAK,QAAQ,EAAE;AACvC,UAAM,QAAQ,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ;AAC5D,UAAM,OAAO,UAAU,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACnE,QAAI,SAAS,OAAW,QAAO;AAC/B,QAAI,aAAa,OAAQ,QAAO,EAAE,MAAM,cAAc,KAAK;AAC3D,QAAI,aAAa,eAAe,aAAa;AAC3C,aAAO,EAAE,MAAM,mBAAmB,KAAK;AACzC,WAAO;AAAA,EACT;AAEA,SAAO,oBAAoB,OAAO,KAAK,gBAAgB,OAAO;AAChE;","names":["AgentEvalError"]}
|
|
@@ -81,7 +81,8 @@ function mergeHooks(base, overlay) {
|
|
|
81
81
|
|
|
82
82
|
export {
|
|
83
83
|
DELEGATION_MCP_SERVER_KEY,
|
|
84
|
+
DEFAULT_SANDBOX_BASE_URL,
|
|
84
85
|
buildDelegationMcpServer,
|
|
85
86
|
composeProductionAgentProfile
|
|
86
87
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-XRYEZPR6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp/delegation-profile.ts"],"sourcesContent":["/**\n * Production-profile composition for the agent-runtime delegation MCP.\n *\n * A product agent's sandbox loads the delegation tools (`delegate_code`,\n * `delegate_research`, `delegate_feedback`, `delegation_status`,\n * `delegation_history`) by mounting the `agent-runtime-mcp` stdio server as\n * an MCP entry in its `AgentProfile`. This module is the single composer for\n * that wiring, so every consumer — the fleet agents and agent-builder's\n * generated agents — shares one implementation instead of copying it.\n *\n * The load-bearing invariant: the delegation MCP entry is only ever emitted\n * when a sandbox API key is present. Without the key the kernel's\n * coder/researcher delegate cannot construct an authenticated sandbox client,\n * so we omit the entry rather than ship an MCP child that fails to\n * authenticate on startup. No static profile entry, ever.\n */\n\nimport type {\n AgentProfile,\n AgentProfileFileMount,\n AgentProfileMcpServer,\n AgentSubagentProfile,\n} from '@tangle-network/sandbox'\n\n/** One hook command entry. The SDK declares `AgentProfile.hooks` as\n * `Record<string, AgentProfileHookCommand[]>` but does not re-export the element\n * type from the package entry, so derive it from `AgentProfile` by indexed\n * access — the single source of truth, no drift from the SDK shape. */\ntype AgentProfileHookCommand = NonNullable<AgentProfile['hooks']>[string][number]\n\n/** MCP server key under which the agent-runtime delegation tools mount. */\nexport const DELEGATION_MCP_SERVER_KEY = 'agent-runtime-delegation'\n\n/**\n * Env vars forwarded into the delegation MCP child so its delegated\n * build/research loops export topology spans to the configured OTLP /\n * Tangle Intelligence sink. Each is forwarded only when present, so the\n * child is a no-op exporter until `OTEL_EXPORTER_OTLP_ENDPOINT` is set in the\n * parent env — never a hardcoded endpoint.\n */\nconst OTEL_FORWARD_KEYS = [\n 'OTEL_EXPORTER_OTLP_ENDPOINT',\n 'OTEL_EXPORTER_OTLP_HEADERS',\n 'TRACE_ID',\n 'PARENT_SPAN_ID',\n] as const\n\nexport const DEFAULT_SANDBOX_BASE_URL = 'https://sandbox.tangle.tools'\n\nexport interface BuildDelegationMcpServerOptions {\n /** Sandbox API key forwarded as `TANGLE_API_KEY` to the MCP child. The\n * agent-runtime MCP bin reads `TANGLE_API_KEY` and passes it straight to\n * `new Sandbox({ apiKey })`. Defaults to `env.TANGLE_API_KEY`. */\n sandboxApiKey?: string\n /** Sandbox base URL forwarded as `SANDBOX_BASE_URL`. Defaults to\n * `env.SANDBOX_BASE_URL`, then `env.SANDBOX_API_URL`, then the public\n * sandbox endpoint. */\n sandboxBaseUrl?: string\n /** Environment source for key + OTEL resolution. Defaults to `process.env`;\n * injectable for tests and non-process callers. */\n env?: Record<string, string | undefined>\n}\n\n/**\n * Build the delegation MCP entry the sandbox-side agent loads on startup.\n * Returns `undefined` when no sandbox API key is resolvable — callers merge\n * the result into a profile's `mcp` map only when defined.\n */\nexport function buildDelegationMcpServer(\n options: BuildDelegationMcpServerOptions = {},\n): Record<string, AgentProfileMcpServer> | undefined {\n const env = options.env ?? process.env\n const sandboxApiKey = options.sandboxApiKey ?? env.TANGLE_API_KEY\n if (!sandboxApiKey) return undefined\n const baseUrl =\n options.sandboxBaseUrl ??\n env.SANDBOX_BASE_URL ??\n env.SANDBOX_API_URL ??\n DEFAULT_SANDBOX_BASE_URL\n\n const otelEnv: Record<string, string> = {}\n for (const key of OTEL_FORWARD_KEYS) {\n const value = env[key]\n if (value) otelEnv[key] = value\n }\n\n return {\n [DELEGATION_MCP_SERVER_KEY]: {\n transport: 'stdio',\n command: 'npx',\n args: ['-y', '@tangle-network/agent-runtime', 'mcp'],\n env: {\n TANGLE_API_KEY: sandboxApiKey,\n SANDBOX_BASE_URL: baseUrl,\n ...otelEnv,\n },\n enabled: true,\n metadata: {\n surface: 'delegation:dispatch',\n tools: [\n 'delegate_code',\n 'delegate_research',\n 'delegate_feedback',\n 'delegation_status',\n 'delegation_history',\n ],\n },\n },\n }\n}\n\nexport interface ComposeProductionAgentProfileOptions {\n /** Sandbox API key forwarded to the delegation MCP child. Defaults to\n * `env.TANGLE_API_KEY`. When unset, the delegation MCP entry is omitted. */\n sandboxApiKey?: string\n /** Sandbox base URL forwarded as `SANDBOX_BASE_URL` to the MCP child. */\n sandboxBaseUrl?: string\n /** Replace the base profile's system prompt. Used by per-turn calls that\n * swap in workspace-augmented prompts (board summary, learned style). */\n systemPrompt?: string\n /** Extra file mounts layered after the base profile's `resources.files`. */\n extraFiles?: AgentProfileFileMount[]\n /** Override the profile `name`. Defaults to the base profile's name. */\n name?: string\n /** Environment source for key + OTEL resolution. Defaults to `process.env`. */\n env?: Record<string, string | undefined>\n /** Box built-in tool ON/OFF flags merged over the base profile's `tools`\n * (overlay wins per key). The sandbox-seam mapping of a certified surface's\n * tool grants — `AgentProfile.tools` is `Record<string, boolean>` box flags,\n * so it carries grants, not arbitrary tool defs. */\n tools?: Record<string, boolean>\n /** Per-event hook commands merged over the base profile's `hooks`. An event\n * present in both has the extra commands appended after the base ones. */\n hooks?: Record<string, AgentProfileHookCommand[]>\n /** Subagent definitions merged over the base profile's `subagents` (overlay\n * wins per key). */\n subagents?: Record<string, AgentSubagentProfile>\n /** Resolved certified MCP connections injected into `AgentProfile.mcp` — the\n * sandbox-seam delivery of a `ResolvedSurface.mcpConnections`. Merged after\n * the base map and before the delegation entry, so a base/delegation key is\n * never silently shadowed by an injected one. */\n mcpConnections?: Record<string, AgentProfileMcpServer>\n}\n\n/**\n * Compose the production `AgentProfile`: the canonical base profile with the\n * delegation MCP merged into `mcp`. Used by every call site that boots a\n * sandbox or runs a chat turn through the sandbox path, and by eval wiring so\n * the scorecard profile hash reflects the actual production profile.\n *\n * Merge rules:\n * - `mcp`: base map preserved; `options.mcpConnections` (resolved certified\n * servers) merged over it; the delegation entry is appended last under\n * {@link DELEGATION_MCP_SERVER_KEY}, and omitted entirely when no sandbox\n * API key resolves.\n * - `tools`: base box-flags map preserved; `options.tools` overlaid per key.\n * - `hooks`: per event, base commands preserved; `options.hooks[event]`\n * appended after the base ones.\n * - `subagents`: base map preserved; `options.subagents` overlaid per key.\n * - `prompt.systemPrompt`: replaced when `options.systemPrompt` is set.\n * - `resources.files`: `options.extraFiles` concatenated after base files.\n * - `name`: replaced when `options.name` is set.\n */\nexport function composeProductionAgentProfile(\n baseProfile: AgentProfile,\n options: ComposeProductionAgentProfileOptions = {},\n): AgentProfile {\n const delegationMcp = buildDelegationMcpServer({\n sandboxApiKey: options.sandboxApiKey,\n sandboxBaseUrl: options.sandboxBaseUrl,\n env: options.env,\n })\n\n const baseMcp = baseProfile.mcp ?? {}\n const withInjected: Record<string, AgentProfileMcpServer> = options.mcpConnections\n ? { ...baseMcp, ...options.mcpConnections }\n : { ...baseMcp }\n const mergedMcp: Record<string, AgentProfileMcpServer> = delegationMcp\n ? { ...withInjected, ...delegationMcp }\n : withInjected\n\n const baseFiles = baseProfile.resources?.files ?? []\n const mergedFiles: AgentProfileFileMount[] = options.extraFiles?.length\n ? [...baseFiles, ...options.extraFiles]\n : [...baseFiles]\n\n const prompt = options.systemPrompt\n ? { ...baseProfile.prompt, systemPrompt: options.systemPrompt }\n : baseProfile.prompt\n\n const mergedTools = options.tools\n ? { ...(baseProfile.tools ?? {}), ...options.tools }\n : baseProfile.tools\n\n const mergedHooks = mergeHooks(baseProfile.hooks, options.hooks)\n\n const mergedSubagents = options.subagents\n ? { ...(baseProfile.subagents ?? {}), ...options.subagents }\n : baseProfile.subagents\n\n return {\n ...baseProfile,\n name: options.name ?? baseProfile.name,\n prompt,\n ...(mergedTools ? { tools: mergedTools } : {}),\n ...(mergedHooks ? { hooks: mergedHooks } : {}),\n ...(mergedSubagents ? { subagents: mergedSubagents } : {}),\n mcp: mergedMcp,\n resources: {\n ...baseProfile.resources,\n files: mergedFiles,\n },\n }\n}\n\n/** Merge per-event hook command lists: base commands first, overlay commands\n * appended after. Returns the base map unchanged when no overlay is given. */\nfunction mergeHooks(\n base: Record<string, AgentProfileHookCommand[]> | undefined,\n overlay: Record<string, AgentProfileHookCommand[]> | undefined,\n): Record<string, AgentProfileHookCommand[]> | undefined {\n if (!overlay) return base\n const merged: Record<string, AgentProfileHookCommand[]> = { ...(base ?? {}) }\n for (const [event, commands] of Object.entries(overlay)) {\n merged[event] = [...(merged[event] ?? []), ...commands]\n }\n return merged\n}\n"],"mappings":";AA+BO,IAAM,4BAA4B;AASzC,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EAC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pC,CAAC,GAAG,SAAS;AAEjB,QAAM,SAAS,QAAQ,eACnB,EAAE,GAAG,YAAY,QAAQ,cAAc,QAAQ,aAAa,IAC5D,YAAY;AAEhB,QAAM,cAAc,QAAQ,QACxB,EAAE,GAAI,YAAY,SAAS,CAAC,GAAI,GAAG,QAAQ,MAAM,IACjD,YAAY;AAEhB,QAAM,cAAc,WAAW,YAAY,OAAO,QAAQ,KAAK;AAE/D,QAAM,kBAAkB,QAAQ,YAC5B,EAAE,GAAI,YAAY,aAAa,CAAC,GAAI,GAAG,QAAQ,UAAU,IACzD,YAAY;AAEhB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,QAAQ,QAAQ,YAAY;AAAA,IAClC;AAAA,IACA,GAAI,cAAc,EAAE,OAAO,YAAY,IAAI,CAAC;AAAA,IAC5C,GAAI,cAAc,EAAE,OAAO,YAAY,IAAI,CAAC;AAAA,IAC5C,GAAI,kBAAkB,EAAE,WAAW,gBAAgB,IAAI,CAAC;AAAA,IACxD,KAAK;AAAA,IACL,WAAW;AAAA,MACT,GAAG,YAAY;AAAA,MACf,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAIA,SAAS,WACP,MACA,SACuD;AACvD,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,SAAoD,EAAE,GAAI,QAAQ,CAAC,EAAG;AAC5E,aAAW,CAAC,OAAO,QAAQ,KAAK,OAAO,QAAQ,OAAO,GAAG;AACvD,WAAO,KAAK,IAAI,CAAC,GAAI,OAAO,KAAK,KAAK,CAAC,GAAI,GAAG,QAAQ;AAAA,EACxD;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentProfile } from '@tangle-network/sandbox';
|
|
2
|
-
import { O as OutputAdapter, V as Validator, A as AgentRunSpec, D as Driver } from './types-
|
|
2
|
+
import { O as OutputAdapter, V as Validator, A as AgentRunSpec, D as Driver } from './types-C8rNlxfV.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @experimental
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DefaultVerdict } from '@tangle-network/agent-eval';
|
|
2
2
|
import { AgentProfile, BackendType } from '@tangle-network/sandbox';
|
|
3
3
|
import { R as RuntimeHooks } from './runtime-hooks-C7JwKb9E.js';
|
|
4
|
-
import { d as LoopTokenUsage } from './types-
|
|
4
|
+
import { d as LoopTokenUsage } from './types-C8rNlxfV.js';
|
|
5
|
+
import { b as DelegateFeedbackArgs, c as DelegationFeedbackSnapshot, d as DelegationTaskQueue, e as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, T as TraceContext } from './delegates-BPLIl8EC.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @experimental
|
|
@@ -435,4 +436,269 @@ interface WidenGate<Out> {
|
|
|
435
436
|
readonly judgeExempt?: boolean;
|
|
436
437
|
}
|
|
437
438
|
|
|
438
|
-
|
|
439
|
+
/**
|
|
440
|
+
* @experimental
|
|
441
|
+
*
|
|
442
|
+
* Feedback persistence surface for the MCP layer.
|
|
443
|
+
*
|
|
444
|
+
* The substrate cannot import `@tangle-network/agent-knowledge` (it would
|
|
445
|
+
* induce a dependency cycle), so the store is an abstract interface. The
|
|
446
|
+
* default implementation is in-memory; consumers wire their own adapter
|
|
447
|
+
* (a real KbStore-backed sink, an HTTP relay to gtm-agent's knowledge
|
|
448
|
+
* service, etc.) via `createMcpServer({ feedbackStore })`.
|
|
449
|
+
*
|
|
450
|
+
* Feedback events are append-only: every rating is a new event with a
|
|
451
|
+
* fresh id, even when the same delegation is rated multiple times. The
|
|
452
|
+
* caller decides how to roll up scores downstream.
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
/** @experimental */
|
|
456
|
+
interface FeedbackEvent {
|
|
457
|
+
id: string;
|
|
458
|
+
refersTo: DelegateFeedbackArgs['refersTo'];
|
|
459
|
+
rating: DelegateFeedbackArgs['rating'];
|
|
460
|
+
by: DelegateFeedbackArgs['by'];
|
|
461
|
+
capturedAt: string;
|
|
462
|
+
namespace?: string;
|
|
463
|
+
}
|
|
464
|
+
/** @experimental */
|
|
465
|
+
interface FeedbackStore {
|
|
466
|
+
/** Append a new event. Never dedupes — every rating is its own event. */
|
|
467
|
+
put(event: FeedbackEvent): Promise<void>;
|
|
468
|
+
/**
|
|
469
|
+
* List events filtered by `namespace`. When `namespace` is omitted, list
|
|
470
|
+
* across all namespaces. Returns events in insertion order.
|
|
471
|
+
*/
|
|
472
|
+
list(filter?: {
|
|
473
|
+
namespace?: string;
|
|
474
|
+
refersToRef?: string;
|
|
475
|
+
}): Promise<FeedbackEvent[]>;
|
|
476
|
+
}
|
|
477
|
+
/** @experimental */
|
|
478
|
+
declare class InMemoryFeedbackStore implements FeedbackStore {
|
|
479
|
+
private readonly events;
|
|
480
|
+
put(event: FeedbackEvent): Promise<void>;
|
|
481
|
+
list(filter?: {
|
|
482
|
+
namespace?: string;
|
|
483
|
+
refersToRef?: string;
|
|
484
|
+
}): Promise<FeedbackEvent[]>;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Project a `FeedbackEvent` down to the snapshot shape carried on
|
|
488
|
+
* `delegation_history` entries.
|
|
489
|
+
*
|
|
490
|
+
* @experimental
|
|
491
|
+
*/
|
|
492
|
+
declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapshot;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* @experimental
|
|
496
|
+
*
|
|
497
|
+
* Stdio JSON-RPC MCP server exposing the 5 delegation tools to sandbox
|
|
498
|
+
* coding-harness agents (claude-code, codex, opencode, ...).
|
|
499
|
+
*
|
|
500
|
+
* The server is transport-bound but topology-free: tool execution is
|
|
501
|
+
* delegated to handler functions composed from a queue, a feedback
|
|
502
|
+
* store, and per-profile run delegates. Consumers wire those at
|
|
503
|
+
* construction time. The `agent-runtime-mcp` bin spins up a default
|
|
504
|
+
* configuration for the common case (real sandbox client + coder).
|
|
505
|
+
*
|
|
506
|
+
* Wire protocol: line-delimited JSON-RPC 2.0 over stdio. Each line is
|
|
507
|
+
* one request; each response is one line. `tools/list` and `tools/call`
|
|
508
|
+
* mirror the MCP 2024-11-05 spec; we do not pull in
|
|
509
|
+
* `@modelcontextprotocol/sdk` to keep the dependency footprint zero.
|
|
510
|
+
*/
|
|
511
|
+
|
|
512
|
+
/** @experimental */
|
|
513
|
+
interface McpServerOptions {
|
|
514
|
+
/** Required to enable delegate_code. */
|
|
515
|
+
coderDelegate?: CoderDelegate;
|
|
516
|
+
/**
|
|
517
|
+
* Required to enable delegate_research. The substrate cannot ship a
|
|
518
|
+
* default — wire one that closes over your `runLoop` + a
|
|
519
|
+
* researcher profile (typically `@tangle-network/agent-knowledge`'s
|
|
520
|
+
* `researcherProfile` / `multiHarnessResearcherFanout`).
|
|
521
|
+
*/
|
|
522
|
+
researcherDelegate?: ResearcherDelegate;
|
|
523
|
+
/**
|
|
524
|
+
* Required to enable delegate_ui_audit. Wire one that closes over your
|
|
525
|
+
* `runLoop` + `uiAuditorProfile` + a `SandboxClient` (the
|
|
526
|
+
* canonical in-process choice is `createInProcessUiAuditClient` from
|
|
527
|
+
* `@tangle-network/agent-runtime/profiles`) + your vision judge.
|
|
528
|
+
*/
|
|
529
|
+
uiAuditorDelegate?: UiAuditorDelegate;
|
|
530
|
+
/** Override the default in-memory feedback store. */
|
|
531
|
+
feedbackStore?: FeedbackStore;
|
|
532
|
+
/** Override the default in-memory task queue. */
|
|
533
|
+
queue?: DelegationTaskQueue;
|
|
534
|
+
/**
|
|
535
|
+
* Record deterministic detached-session resume keys on single-variant
|
|
536
|
+
* coder/researcher submissions so a durable queue can resume them after a
|
|
537
|
+
* restart. Enable only when the wired delegates dispatch via sandbox
|
|
538
|
+
* sessions (`driveTurn`) AND `queue` persists records — the keys are inert
|
|
539
|
+
* otherwise. The bin turns this on alongside the durable store for
|
|
540
|
+
* session-backed (sibling/fleet) placements.
|
|
541
|
+
*/
|
|
542
|
+
detachedDispatch?: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* Extra tools to serve alongside the delegation tools, for example
|
|
545
|
+
* `createCoordinationTools(...).tools`. Registered after the built-ins; a
|
|
546
|
+
* duplicate name throws so delegation tools cannot be shadowed silently.
|
|
547
|
+
*/
|
|
548
|
+
extraTools?: McpToolDescriptor[];
|
|
549
|
+
/**
|
|
550
|
+
* Inherited trace identity (`readTraceContextFromEnv()`) stamped on every
|
|
551
|
+
* record the DEFAULT queue creates. Ignored when `queue` is supplied —
|
|
552
|
+
* pass `traceContext` to that queue's constructor instead.
|
|
553
|
+
*/
|
|
554
|
+
traceContext?: TraceContext;
|
|
555
|
+
/** Server display name surfaced via `initialize`. Default `'agent-runtime-mcp'`. */
|
|
556
|
+
serverName?: string;
|
|
557
|
+
/** Server version surfaced via `initialize`. Default = the package version baked at build time. */
|
|
558
|
+
serverVersion?: string;
|
|
559
|
+
}
|
|
560
|
+
/** @experimental */
|
|
561
|
+
interface McpToolDescriptor {
|
|
562
|
+
name: string;
|
|
563
|
+
description: string;
|
|
564
|
+
inputSchema: Record<string, unknown>;
|
|
565
|
+
handler: (raw: unknown) => Promise<unknown>;
|
|
566
|
+
}
|
|
567
|
+
/** @experimental */
|
|
568
|
+
interface McpServer {
|
|
569
|
+
/** Tools currently registered (depend on which delegates were wired). */
|
|
570
|
+
readonly tools: ReadonlyMap<string, McpToolDescriptor>;
|
|
571
|
+
/** The underlying queue — exposed so tests can introspect it. */
|
|
572
|
+
readonly queue: DelegationTaskQueue;
|
|
573
|
+
/** The feedback store — exposed for the same reason. */
|
|
574
|
+
readonly feedbackStore: FeedbackStore;
|
|
575
|
+
/** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */
|
|
576
|
+
handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>;
|
|
577
|
+
/** Drive the server on a stdio-shaped transport until `stop()` is called. */
|
|
578
|
+
serve(transport?: McpTransport): Promise<void>;
|
|
579
|
+
/** Stop a `serve` call. Subsequent requests are rejected. */
|
|
580
|
+
stop(): void;
|
|
581
|
+
}
|
|
582
|
+
/** @experimental */
|
|
583
|
+
interface McpTransport {
|
|
584
|
+
input: NodeJS.ReadableStream;
|
|
585
|
+
output: NodeJS.WritableStream;
|
|
586
|
+
}
|
|
587
|
+
/** @experimental */
|
|
588
|
+
interface JsonRpcMessage {
|
|
589
|
+
jsonrpc: '2.0';
|
|
590
|
+
id?: number | string | null;
|
|
591
|
+
method: string;
|
|
592
|
+
params?: unknown;
|
|
593
|
+
}
|
|
594
|
+
/** @experimental */
|
|
595
|
+
interface JsonRpcResponse {
|
|
596
|
+
jsonrpc: '2.0';
|
|
597
|
+
id: number | string | null;
|
|
598
|
+
result?: unknown;
|
|
599
|
+
error?: {
|
|
600
|
+
code: number;
|
|
601
|
+
message: string;
|
|
602
|
+
data?: unknown;
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
/** @experimental */
|
|
606
|
+
declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
607
|
+
/**
|
|
608
|
+
* In-process pair of `Readable` + `Writable` streams suitable for driving
|
|
609
|
+
* `server.serve(...)` from a test. Returns the agent-side stream (the
|
|
610
|
+
* client writes to it) and the server-side stream (the test reads from it).
|
|
611
|
+
*
|
|
612
|
+
* @experimental
|
|
613
|
+
*/
|
|
614
|
+
declare function createInProcessTransport(): {
|
|
615
|
+
transport: McpTransport;
|
|
616
|
+
clientWrite(line: string): void;
|
|
617
|
+
clientClose(): void;
|
|
618
|
+
readServer(): Promise<JsonRpcResponse[]>;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* @experimental
|
|
623
|
+
*
|
|
624
|
+
* MCP binding for a live `Scope`. A sandbox driver gets the same small verbs
|
|
625
|
+
* the in-process driver has: spawn, observe, await, steer, ask/answer, analyze,
|
|
626
|
+
* and stop. Settled outputs remain Scope artifacts; product code can project
|
|
627
|
+
* them into any UI/report envelope it needs.
|
|
628
|
+
*/
|
|
629
|
+
|
|
630
|
+
/** A worker the driver has drained via `await_next`. */
|
|
631
|
+
interface SettledWorker {
|
|
632
|
+
readonly id: string;
|
|
633
|
+
readonly status: 'done' | 'down';
|
|
634
|
+
readonly score?: number;
|
|
635
|
+
readonly valid?: boolean;
|
|
636
|
+
readonly outRef?: string;
|
|
637
|
+
readonly reason?: string;
|
|
638
|
+
}
|
|
639
|
+
type QuestionLevel = 'worker' | 'driver' | 'loop';
|
|
640
|
+
type QuestionUrgency = 'continue-without' | 'blocks-step' | 'blocks-run';
|
|
641
|
+
interface QuestionOption {
|
|
642
|
+
readonly label: string;
|
|
643
|
+
readonly tradeoff: string;
|
|
644
|
+
}
|
|
645
|
+
interface Question {
|
|
646
|
+
readonly id: string;
|
|
647
|
+
readonly from: string;
|
|
648
|
+
readonly level: QuestionLevel;
|
|
649
|
+
readonly question: string;
|
|
650
|
+
readonly reason: string;
|
|
651
|
+
readonly urgency: QuestionUrgency;
|
|
652
|
+
readonly options?: ReadonlyArray<QuestionOption>;
|
|
653
|
+
}
|
|
654
|
+
type QuestionDecision = {
|
|
655
|
+
readonly kind: 'answer';
|
|
656
|
+
readonly answer: string;
|
|
657
|
+
readonly by: string;
|
|
658
|
+
} | {
|
|
659
|
+
readonly kind: 'defer';
|
|
660
|
+
readonly reason: string;
|
|
661
|
+
} | {
|
|
662
|
+
readonly kind: 'escalate';
|
|
663
|
+
readonly to: 'parent' | 'user' | string;
|
|
664
|
+
readonly reason: string;
|
|
665
|
+
};
|
|
666
|
+
interface QuestionRecord extends Question {
|
|
667
|
+
readonly status: 'open' | 'answered' | 'deferred' | 'escalated';
|
|
668
|
+
readonly decision?: QuestionDecision;
|
|
669
|
+
readonly openedAt: number;
|
|
670
|
+
}
|
|
671
|
+
type QuestionPolicy = 'auto' | 'mustDecide' | 'bubble' | 'failClosed';
|
|
672
|
+
interface AnalystRegistry {
|
|
673
|
+
readonly kinds: ReadonlyArray<{
|
|
674
|
+
id: string;
|
|
675
|
+
description: string;
|
|
676
|
+
area: string;
|
|
677
|
+
}>;
|
|
678
|
+
readonly run: (kindId: string, trace: unknown) => Promise<unknown>;
|
|
679
|
+
}
|
|
680
|
+
type CoordinationEvent = {
|
|
681
|
+
readonly type: 'question';
|
|
682
|
+
readonly question: QuestionRecord;
|
|
683
|
+
};
|
|
684
|
+
type MakeWorkerAgent = (profile: unknown) => Agent<unknown, unknown>;
|
|
685
|
+
interface CoordinationToolsOptions {
|
|
686
|
+
readonly scope: Scope<unknown>;
|
|
687
|
+
readonly blobs: ResultBlobStore;
|
|
688
|
+
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
689
|
+
readonly perWorker: Budget;
|
|
690
|
+
readonly analysts?: AnalystRegistry;
|
|
691
|
+
readonly onEvent?: (event: CoordinationEvent) => void | Promise<void>;
|
|
692
|
+
readonly questionPolicy?: QuestionPolicy;
|
|
693
|
+
}
|
|
694
|
+
interface CoordinationTools {
|
|
695
|
+
readonly tools: McpToolDescriptor[];
|
|
696
|
+
isStopped(): boolean;
|
|
697
|
+
stopReason(): string | undefined;
|
|
698
|
+
settled(): ReadonlyArray<SettledWorker>;
|
|
699
|
+
questions(): ReadonlyArray<QuestionRecord>;
|
|
700
|
+
}
|
|
701
|
+
/** Build the driver's MCP tools over a live scope. */
|
|
702
|
+
declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
|
|
703
|
+
|
|
704
|
+
export { type AnalystRegistry as A, type Budget as B, type CoordinationEvent as C, type Supervisor as D, type ExecutorRegistry as E, type FeedbackStore as F, type ExecutorContext as G, type ExecutorResult as H, InMemoryFeedbackStore as I, type JsonRpcMessage as J, type Handle as K, type NodeSnapshot as L, type MakeWorkerAgent as M, type NodeId as N, type NodeStatus as O, type Restart as P, type Question as Q, type ResultBlobStore as R, type SettledWorker as S, type TreeView as T, type UsageEvent as U, type RootSignal as V, type Runtime as W, type SpawnOpts as X, type SupervisorOpts as Y, type WidenGate as Z, 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 SpawnJournal as p, type SpawnEvent as q, type Settled as r, type AgentSpec as s, type Agent as t, type RootHandle as u, type SupervisedResult as v, type Spend as w, type Scope as x, type ExecutorFactory as y, type Executor as z };
|