@tangle-network/agent-runtime 0.126.0 → 0.131.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 +70 -20
- package/dist/{activation-DhWJ3p8N.js → activation-BCzMOTaV.js} +3 -3
- package/dist/{activation-DhWJ3p8N.js.map → activation-BCzMOTaV.js.map} +1 -1
- package/dist/agent.d.ts +2 -3
- package/dist/agent.js +4 -5
- package/dist/agent.js.map +1 -1
- package/dist/{analyst-loop-DvSciOfB.js → analyst-loop-BE8cDs5Q.js} +2 -2
- package/dist/{analyst-loop-DvSciOfB.js.map → analyst-loop-BE8cDs5Q.js.map} +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +1 -1
- package/dist/authoring-CvHwo1oW.js +163 -0
- package/dist/authoring-CvHwo1oW.js.map +1 -0
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{candidate-execution-BFpq-Xi6.js → candidate-execution-BNxKr-Bu.js} +5 -5
- package/dist/{candidate-execution-BFpq-Xi6.js.map → candidate-execution-BNxKr-Bu.js.map} +1 -1
- package/dist/{conversation-BpLQZGPH.js → conversation-DNtxaJ1Z.js} +113 -31
- package/dist/conversation-DNtxaJ1Z.js.map +1 -0
- package/dist/conversation.d.ts +2 -2
- package/dist/conversation.js +2 -2
- package/dist/environment-provider-CxvSd1W6.d.ts +86 -0
- package/dist/{environment-provider-DqFS6FSZ.js → environment-provider-Dyg8DtLK.js} +8 -4
- package/dist/environment-provider-Dyg8DtLK.js.map +1 -0
- package/dist/environment-provider.d.ts +1 -1
- package/dist/environment-provider.js +1 -1
- package/dist/graph-BJTxGOFB.js +471 -0
- package/dist/graph-BJTxGOFB.js.map +1 -0
- package/dist/{improvement-cycle-IJgCbKWQ.js → improvement-cycle-Csp38cWg.js} +133 -224
- package/dist/improvement-cycle-Csp38cWg.js.map +1 -0
- package/dist/{index-EdjCQBV9.d.ts → index-CoO7atyo.d.ts} +640 -1184
- package/dist/{index-DIV33AF5.d.ts → index-DwGtu9nc.d.ts} +7 -9
- package/dist/{index-Efjb3nrQ.d.ts → index-qYHpsmG2.d.ts} +36 -18
- package/dist/index.d.ts +353 -11
- package/dist/index.js +111 -354
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +6 -6
- package/dist/intelligence.js +9 -8
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +7 -5
- package/dist/kernel.js +13 -9
- package/dist/{knowledge-EnuEqm_Y.js → knowledge-ce0_uKCl.js} +19 -17
- package/dist/knowledge-ce0_uKCl.js.map +1 -0
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-Bo29_fiD.d.ts → loop-runner-bin-BwgZ8m_7.d.ts} +6 -3
- package/dist/{loop-runner-bin-qwT_4F5I.js → loop-runner-bin-DSbuDDqM.js} +5 -27
- package/dist/loop-runner-bin-DSbuDDqM.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/materialization-COJ1UYQ-.js +272 -0
- package/dist/materialization-COJ1UYQ-.js.map +1 -0
- package/dist/mcp/bin.js +39 -47
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +24 -30
- package/dist/mcp/index.js +66 -83
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{memory-server-DL6cE2Ag.js → memory-server-5HEJH672.js} +2 -2
- package/dist/{memory-server-DL6cE2Ag.js.map → memory-server-5HEJH672.js.map} +1 -1
- package/dist/model-policy-CqziaqS1.js +232 -0
- package/dist/model-policy-CqziaqS1.js.map +1 -0
- package/dist/{openai-tools-B68JaOCx.d.ts → openai-tools-D3oMyVGl.d.ts} +2 -2
- package/dist/{openai-tools-Bp1KSkP6.js → openai-tools-ru75mLjq.js} +2 -2
- package/dist/openai-tools-ru75mLjq.js.map +1 -0
- package/dist/{prepare--8EvLqCr.js → prepare-DYWjVcPx.js} +169 -153
- package/dist/prepare-DYWjVcPx.js.map +1 -0
- package/dist/primeintellect/index.d.ts +7 -6
- package/dist/primeintellect/index.js +9 -11
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +21 -174
- package/dist/profiles.js +67 -276
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-CXVfOUu_.js → protected-model-port-48ALLGxT.js} +2 -2
- package/dist/{protected-model-port-CXVfOUu_.js.map → protected-model-port-48ALLGxT.js.map} +1 -1
- package/dist/{redact-PQzmE1Jn.d.ts → redact-9_Gf-8m3.d.ts} +58 -69
- package/dist/{researcher-CoVqNhfI.js → researcher-Skz5-Uc8.js} +50 -26
- package/dist/researcher-Skz5-Uc8.js.map +1 -0
- package/dist/{run-layout-C2FGmZ3v.js → run-layout-CeJsEAom.js} +2 -2
- package/dist/{run-layout-C2FGmZ3v.js.map → run-layout-CeJsEAom.js.map} +1 -1
- package/dist/runtime-D-QfLbSd.d.ts +893 -0
- package/dist/{runtime-BzXz7OjS.js → runtime-hiAABiTk.js} +329 -854
- package/dist/runtime-hiAABiTk.js.map +1 -0
- package/dist/{sandbox-events-Yhd1GYWl.js → sandbox-events-CRDwc5WN.js} +42 -5
- package/dist/sandbox-events-CRDwc5WN.js.map +1 -0
- package/dist/snapshot-CXiiuHhL.js +21 -0
- package/dist/snapshot-CXiiuHhL.js.map +1 -0
- package/dist/{spawn-journal-DsZKDqeh.js → spawn-journal-saHQzqYi.js} +15 -21
- package/dist/spawn-journal-saHQzqYi.js.map +1 -0
- package/dist/stream-agent-turn-C852AgMT.d.ts +128 -0
- package/dist/stream-agent-turn-rYgaOLO0.js +910 -0
- package/dist/stream-agent-turn-rYgaOLO0.js.map +1 -0
- package/dist/{structural-rollout-zY0oqQzO.js → structural-rollout-3uxVGcg2.js} +459 -235
- package/dist/structural-rollout-3uxVGcg2.js.map +1 -0
- package/dist/{supervise-Ds8FtyI9.js → supervise-iPN27pO0.js} +932 -4771
- package/dist/supervise-iPN27pO0.js.map +1 -0
- package/dist/{supervisor-DpjO0Gmy.js → supervisor-CV6Jh28D.js} +7439 -2897
- package/dist/supervisor-CV6Jh28D.js.map +1 -0
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +271 -221
- package/dist/testing.js.map +1 -1
- package/dist/{top-app-5unxqovu.js → top-app-G4M18b6i.js} +3 -3
- package/dist/{top-app-5unxqovu.js.map → top-app-G4M18b6i.js.map} +1 -1
- package/dist/tui/bin.js +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{environment-provider-PM9PeW_J.d.ts → types-C6Q-J0Dt.d.ts} +57 -114
- package/dist/{types-DnNGJ5Gz.d.ts → types-ebIY0dMG.d.ts} +556 -30
- package/dist/{util-MVgdwuIS.js → util-Bw6srryQ.js} +3 -2
- package/dist/{util-MVgdwuIS.js.map → util-Bw6srryQ.js.map} +1 -1
- package/dist/{workspace-archive-BQxvkypI.js → workspace-archive-aOfJ47ms.js} +3 -3
- package/dist/{workspace-archive-BQxvkypI.js.map → workspace-archive-aOfJ47ms.js.map} +1 -1
- package/package.json +12 -15
- package/skills/agent-graphs/IMPROVE.md +58 -0
- package/skills/agent-graphs/SKILL.md +139 -0
- package/skills/agent-graphs/cases/artifact-mission-release-notes.json +10 -0
- package/skills/agent-graphs/cases/audited-single-writer.json +9 -0
- package/skills/agent-graphs/cases/cap-as-stop-mistake.json +8 -0
- package/skills/agent-graphs/cases/mission-in-deliverable.json +8 -0
- package/skills/agent-graphs/cases/review-pipeline.json +13 -0
- package/skills/agent-graphs/cases/runtime-discovered-fanout.json +8 -0
- package/skills/agent-graphs/cases/single-agent-suffices.json +7 -0
- package/skills/agent-graphs/cases/steer-heavy-drafting.json +9 -0
- package/skills/agent-graphs/cases/unmeasured-harness.json +7 -0
- package/skills/agent-graphs/generations/gen1-baseline.json +248 -0
- package/skills/agent-graphs/generations/gen2.json +375 -0
- package/skills/agent-graphs/generations/gen3.json +702 -0
- package/skills/build-with-agent-runtime/SKILL.md +1 -0
- package/dist/backends-CiOCyRHb.js +0 -743
- package/dist/backends-CiOCyRHb.js.map +0 -1
- package/dist/conversation-BpLQZGPH.js.map +0 -1
- package/dist/environment-provider-DqFS6FSZ.js.map +0 -1
- package/dist/improvement-cycle-IJgCbKWQ.js.map +0 -1
- package/dist/index-D_M4d1_B.d.ts +0 -545
- package/dist/knowledge-EnuEqm_Y.js.map +0 -1
- package/dist/local-harness-BIajef4A.d.ts +0 -465
- package/dist/loop-runner-bin-qwT_4F5I.js.map +0 -1
- package/dist/model-resolution-Btd9iIKV.js +0 -98
- package/dist/model-resolution-Btd9iIKV.js.map +0 -1
- package/dist/openai-tools-Bp1KSkP6.js.map +0 -1
- package/dist/prepare--8EvLqCr.js.map +0 -1
- package/dist/researcher-CoVqNhfI.js.map +0 -1
- package/dist/runtime-BzXz7OjS.js.map +0 -1
- package/dist/sandbox-events-Yhd1GYWl.js.map +0 -1
- package/dist/spawn-journal-DsZKDqeh.js.map +0 -1
- package/dist/structural-rollout-zY0oqQzO.js.map +0 -1
- package/dist/supervise-Ds8FtyI9.js.map +0 -1
- package/dist/supervisor-DpjO0Gmy.js.map +0 -1
- package/dist/types-C9j4qg6l.d.ts +0 -500
|
@@ -1,8 +1,516 @@
|
|
|
1
|
-
import { u as AgentTaskSpec, x as RuntimeStreamEvent } from "./types-C9j4qg6l.js";
|
|
2
1
|
import { l as RuntimeHooks } from "./runtime-hooks-sbRpjStq.js";
|
|
3
|
-
import { DefaultVerdict } from "@tangle-network/agent-eval";
|
|
2
|
+
import { ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, DefaultVerdict, KnowledgeReadinessReport, KnowledgeRequirement, RunRecord, TraceStore, UserQuestion } from "@tangle-network/agent-eval";
|
|
4
3
|
import { AgentProfile as AgentProfile$1 } from "@tangle-network/agent-interface";
|
|
5
4
|
import { CreateSandboxOptions, SandboxEvent, SandboxInstance } from "@tangle-network/sandbox";
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/** @stable */
|
|
7
|
+
interface AgentTaskSpec {
|
|
8
|
+
id: string;
|
|
9
|
+
intent: string;
|
|
10
|
+
/** Domain is metadata, not an architectural boundary: tax, legal, gtm, creative, blueprint, redteam, etc. */
|
|
11
|
+
domain?: string;
|
|
12
|
+
inputs?: Record<string, unknown>;
|
|
13
|
+
requiredKnowledge?: KnowledgeRequirement[];
|
|
14
|
+
budget?: Partial<ControlBudget>;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** @stable */
|
|
18
|
+
interface AgentKnowledgeProvider {
|
|
19
|
+
buildReadiness?(task: AgentTaskSpec): Promise<KnowledgeReadinessReport> | KnowledgeReadinessReport;
|
|
20
|
+
answerQuestions?(questions: UserQuestion[], task: AgentTaskSpec): Promise<Record<string, string>> | Record<string, string>;
|
|
21
|
+
executeAcquisitionPlans?(plans: DataAcquisitionPlan[], task: AgentTaskSpec): Promise<string[]> | string[];
|
|
22
|
+
refreshReadiness?(input: {
|
|
23
|
+
task: AgentTaskSpec;
|
|
24
|
+
previous: KnowledgeReadinessReport;
|
|
25
|
+
userAnswers: Record<string, string>;
|
|
26
|
+
acquiredEvidenceIds: string[];
|
|
27
|
+
}): Promise<KnowledgeReadinessReport> | KnowledgeReadinessReport;
|
|
28
|
+
}
|
|
29
|
+
/** @stable */
|
|
30
|
+
interface AgentTaskContext<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
31
|
+
task: AgentTaskSpec;
|
|
32
|
+
knowledge: KnowledgeReadinessReport;
|
|
33
|
+
state: TState;
|
|
34
|
+
evals: TEval[];
|
|
35
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
36
|
+
budget: ControlBudget;
|
|
37
|
+
stepIndex: number;
|
|
38
|
+
wallMs: number;
|
|
39
|
+
spentCostUsd: number;
|
|
40
|
+
remainingCostUsd?: number;
|
|
41
|
+
abortSignal: AbortSignal;
|
|
42
|
+
}
|
|
43
|
+
/** @stable */
|
|
44
|
+
interface AgentAdapter<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
45
|
+
observe(ctx: {
|
|
46
|
+
task: AgentTaskSpec;
|
|
47
|
+
knowledge: KnowledgeReadinessReport;
|
|
48
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
49
|
+
abortSignal: AbortSignal;
|
|
50
|
+
}): Promise<TState> | TState;
|
|
51
|
+
validate(ctx: {
|
|
52
|
+
task: AgentTaskSpec;
|
|
53
|
+
knowledge: KnowledgeReadinessReport;
|
|
54
|
+
state: TState;
|
|
55
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
56
|
+
abortSignal: AbortSignal;
|
|
57
|
+
}): Promise<TEval[]> | TEval[];
|
|
58
|
+
decide(ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
|
|
59
|
+
act(action: TAction, ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<TActionResult> | TActionResult;
|
|
60
|
+
shouldStop?(ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<{
|
|
61
|
+
stop: boolean;
|
|
62
|
+
pass: boolean;
|
|
63
|
+
reason: string;
|
|
64
|
+
score?: number;
|
|
65
|
+
}> | {
|
|
66
|
+
stop: boolean;
|
|
67
|
+
pass: boolean;
|
|
68
|
+
reason: string;
|
|
69
|
+
score?: number;
|
|
70
|
+
};
|
|
71
|
+
onKnowledgeBlocked?(ctx: {
|
|
72
|
+
task: AgentTaskSpec;
|
|
73
|
+
knowledge: KnowledgeReadinessReport;
|
|
74
|
+
questions: UserQuestion[];
|
|
75
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
76
|
+
}): Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
|
|
77
|
+
getActionCostUsd?(ctx: {
|
|
78
|
+
action: TAction;
|
|
79
|
+
result: TActionResult;
|
|
80
|
+
task: AgentTaskSpec;
|
|
81
|
+
state: TState;
|
|
82
|
+
evals: TEval[];
|
|
83
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
84
|
+
}): number | undefined;
|
|
85
|
+
projectRunRecords?(result: ControlRunResult<TState, TAction, TActionResult, TEval>, task: AgentTaskSpec): RunRecord[];
|
|
86
|
+
}
|
|
87
|
+
/** @stable */
|
|
88
|
+
type AgentTaskStatus = 'completed' | 'blocked' | 'failed' | 'aborted';
|
|
89
|
+
/** @stable */
|
|
90
|
+
type AgentRuntimeEvent<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> = {
|
|
91
|
+
type: 'task_start';
|
|
92
|
+
task: AgentTaskSpec;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'readiness_start';
|
|
95
|
+
task: AgentTaskSpec;
|
|
96
|
+
} | {
|
|
97
|
+
type: 'readiness_end';
|
|
98
|
+
task: AgentTaskSpec;
|
|
99
|
+
knowledge: KnowledgeReadinessReport;
|
|
100
|
+
} | {
|
|
101
|
+
type: 'questions_start';
|
|
102
|
+
task: AgentTaskSpec;
|
|
103
|
+
questions: UserQuestion[];
|
|
104
|
+
} | {
|
|
105
|
+
type: 'questions_end';
|
|
106
|
+
task: AgentTaskSpec;
|
|
107
|
+
questions: UserQuestion[];
|
|
108
|
+
userAnswers: Record<string, string>;
|
|
109
|
+
} | {
|
|
110
|
+
type: 'acquisition_start';
|
|
111
|
+
task: AgentTaskSpec;
|
|
112
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
113
|
+
} | {
|
|
114
|
+
type: 'acquisition_end';
|
|
115
|
+
task: AgentTaskSpec;
|
|
116
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
117
|
+
acquiredEvidenceIds: string[];
|
|
118
|
+
} | {
|
|
119
|
+
type: 'control_start';
|
|
120
|
+
task: AgentTaskSpec;
|
|
121
|
+
knowledge: KnowledgeReadinessReport;
|
|
122
|
+
} | {
|
|
123
|
+
type: 'control_step';
|
|
124
|
+
task: AgentTaskSpec;
|
|
125
|
+
step: ControlStep<TState, TAction, TActionResult, TEval>;
|
|
126
|
+
} | {
|
|
127
|
+
type: 'control_end';
|
|
128
|
+
task: AgentTaskSpec;
|
|
129
|
+
control: ControlRunResult<TState, TAction, TActionResult, TEval>;
|
|
130
|
+
} | {
|
|
131
|
+
type: 'task_end';
|
|
132
|
+
task: AgentTaskSpec;
|
|
133
|
+
status: AgentTaskStatus;
|
|
134
|
+
reason: string;
|
|
135
|
+
};
|
|
136
|
+
/** @stable */
|
|
137
|
+
type AgentRuntimeEventSink<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> = (event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>) => Promise<void> | void;
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* Typed transport / backend failure detail. Carried on `backend_error` and
|
|
141
|
+
* `final` events when the backend's stream throws or the upstream HTTP call
|
|
142
|
+
* returns a non-success status. Lets consumers (a) distinguish "stream
|
|
143
|
+
* completed with no text" from "stream never reached the model" and
|
|
144
|
+
* (b) reconstruct the precise upstream signal (status + truncated body) when
|
|
145
|
+
* building a `RunRecord.error`.
|
|
146
|
+
*
|
|
147
|
+
* `body` is truncated to 2 KiB by the backend so an HTML error page from a
|
|
148
|
+
* misconfigured proxy never bloats event payloads or logs. Consumers needing
|
|
149
|
+
* the full body should inspect the underlying `BackendTransportError.body`
|
|
150
|
+
* via a custom `mapEvent` or backend wrapper.
|
|
151
|
+
*
|
|
152
|
+
* @stable
|
|
153
|
+
*/
|
|
154
|
+
interface BackendErrorDetail {
|
|
155
|
+
/**
|
|
156
|
+
* `'transport'` — upstream HTTP / network failure with optional status code.
|
|
157
|
+
* `'backend'` — the backend's `stream()` generator threw for a non-transport
|
|
158
|
+
* reason (e.g. a custom adapter error, sandbox crash).
|
|
159
|
+
*/
|
|
160
|
+
kind: 'transport' | 'backend';
|
|
161
|
+
message: string;
|
|
162
|
+
/** Upstream HTTP status when known. `0` for connection / abort errors. */
|
|
163
|
+
status?: number;
|
|
164
|
+
/** Truncated response body (≤2 KiB). Diagnostic only — never machine-parsed. */
|
|
165
|
+
body?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* OpenAI Chat Completions tool descriptor. The shape mirrors the
|
|
170
|
+
* `/v1/chat/completions` `tools[]` parameter so caller-owned compatible
|
|
171
|
+
* transports can pass tool definitions without translation. A router can
|
|
172
|
+
* proxy this shape to Anthropic
|
|
173
|
+
* (translated server-side), DeepSeek, Groq, OpenAI, and Gemini — every model
|
|
174
|
+
* that the eval surface targets.
|
|
175
|
+
*
|
|
176
|
+
* Callers that build their tool list from MCP servers should run a one-shot
|
|
177
|
+
* MCP `tools/list` at config time and project the result into this shape. The
|
|
178
|
+
* runtime intentionally does NOT depend on `@modelcontextprotocol/sdk` —
|
|
179
|
+
* keeping the backend transport thin lets domain repos own MCP plumbing.
|
|
180
|
+
*
|
|
181
|
+
* @stable
|
|
182
|
+
*/
|
|
183
|
+
interface OpenAIChatTool {
|
|
184
|
+
type: 'function';
|
|
185
|
+
function: {
|
|
186
|
+
name: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
parameters?: Record<string, unknown>;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
*
|
|
193
|
+
* `tool_choice` parameter for OpenAI-compat chat. Same shape as the OpenAI
|
|
194
|
+
* spec: `'auto'` (default — model decides), `'none'` (disable tool calling
|
|
195
|
+
* for this turn), `'required'` (force a tool call), or a specific function
|
|
196
|
+
* pin `{ type: 'function', function: { name } }`.
|
|
197
|
+
*
|
|
198
|
+
* @stable
|
|
199
|
+
*/
|
|
200
|
+
type OpenAIChatToolChoice = 'auto' | 'none' | 'required' | {
|
|
201
|
+
type: 'function';
|
|
202
|
+
function: {
|
|
203
|
+
name: string;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
*
|
|
208
|
+
* `response_format` parameter for OpenAI-compatible chat endpoints. Use
|
|
209
|
+
* `json_object` when the caller needs syntactically valid JSON, or
|
|
210
|
+
* `json_schema` when the upstream provider supports schema-constrained JSON.
|
|
211
|
+
*
|
|
212
|
+
* @stable
|
|
213
|
+
*/
|
|
214
|
+
type OpenAIChatResponseFormat = {
|
|
215
|
+
type: 'text';
|
|
216
|
+
} | {
|
|
217
|
+
type: 'json_object';
|
|
218
|
+
} | {
|
|
219
|
+
type: 'json_schema';
|
|
220
|
+
json_schema: Record<string, unknown>;
|
|
221
|
+
};
|
|
222
|
+
/** @stable */
|
|
223
|
+
type RuntimeStreamEvent = {
|
|
224
|
+
type: 'task_start';
|
|
225
|
+
task: AgentTaskSpec;
|
|
226
|
+
timestamp: string;
|
|
227
|
+
} | {
|
|
228
|
+
type: 'readiness_start';
|
|
229
|
+
task: AgentTaskSpec;
|
|
230
|
+
timestamp: string;
|
|
231
|
+
} | {
|
|
232
|
+
type: 'readiness_end';
|
|
233
|
+
task: AgentTaskSpec;
|
|
234
|
+
knowledge: KnowledgeReadinessReport;
|
|
235
|
+
decision: KnowledgeReadinessDecision;
|
|
236
|
+
timestamp: string;
|
|
237
|
+
} | {
|
|
238
|
+
type: 'questions_start';
|
|
239
|
+
task: AgentTaskSpec;
|
|
240
|
+
questions: UserQuestion[];
|
|
241
|
+
timestamp: string;
|
|
242
|
+
} | {
|
|
243
|
+
type: 'questions_end';
|
|
244
|
+
task: AgentTaskSpec;
|
|
245
|
+
questions: UserQuestion[];
|
|
246
|
+
userAnswers: Record<string, string>;
|
|
247
|
+
timestamp: string;
|
|
248
|
+
} | {
|
|
249
|
+
type: 'acquisition_start';
|
|
250
|
+
task: AgentTaskSpec;
|
|
251
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
252
|
+
timestamp: string;
|
|
253
|
+
} | {
|
|
254
|
+
type: 'acquisition_end';
|
|
255
|
+
task: AgentTaskSpec;
|
|
256
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
257
|
+
acquiredEvidenceIds: string[];
|
|
258
|
+
timestamp: string;
|
|
259
|
+
} | {
|
|
260
|
+
type: 'session_created';
|
|
261
|
+
task: AgentTaskSpec;
|
|
262
|
+
session: RuntimeSession;
|
|
263
|
+
timestamp: string;
|
|
264
|
+
} | {
|
|
265
|
+
type: 'session_resumed';
|
|
266
|
+
task: AgentTaskSpec;
|
|
267
|
+
session: RuntimeSession;
|
|
268
|
+
timestamp: string;
|
|
269
|
+
} | {
|
|
270
|
+
type: 'backend_start';
|
|
271
|
+
task: AgentTaskSpec;
|
|
272
|
+
session: RuntimeSession;
|
|
273
|
+
backend: string;
|
|
274
|
+
/** Canonical execution identity and materialization evidence for this turn, when Runtime
|
|
275
|
+
* owns the selected executor. Generic metadata keeps the event vocabulary open while the
|
|
276
|
+
* values use Runtime's existing identity/materialization receipt shapes. */
|
|
277
|
+
metadata?: Record<string, unknown>;
|
|
278
|
+
timestamp: string;
|
|
279
|
+
} | {
|
|
280
|
+
type: 'text_delta';
|
|
281
|
+
task?: AgentTaskSpec;
|
|
282
|
+
session?: RuntimeSession;
|
|
283
|
+
text: string;
|
|
284
|
+
timestamp?: string;
|
|
285
|
+
} | {
|
|
286
|
+
type: 'reasoning_delta';
|
|
287
|
+
task?: AgentTaskSpec;
|
|
288
|
+
session?: RuntimeSession;
|
|
289
|
+
text: string;
|
|
290
|
+
timestamp?: string;
|
|
291
|
+
} | {
|
|
292
|
+
type: 'tool_call';
|
|
293
|
+
task?: AgentTaskSpec;
|
|
294
|
+
session?: RuntimeSession;
|
|
295
|
+
toolName: string;
|
|
296
|
+
toolCallId?: string;
|
|
297
|
+
args?: unknown;
|
|
298
|
+
timestamp?: string;
|
|
299
|
+
} | {
|
|
300
|
+
type: 'tool_result';
|
|
301
|
+
task?: AgentTaskSpec;
|
|
302
|
+
session?: RuntimeSession;
|
|
303
|
+
toolName: string;
|
|
304
|
+
toolCallId?: string;
|
|
305
|
+
result?: unknown;
|
|
306
|
+
timestamp?: string;
|
|
307
|
+
} | {
|
|
308
|
+
type: 'llm_call';
|
|
309
|
+
task?: AgentTaskSpec;
|
|
310
|
+
session?: RuntimeSession;
|
|
311
|
+
model: string;
|
|
312
|
+
tokensIn?: number;
|
|
313
|
+
tokensOut?: number;
|
|
314
|
+
/** False when the numeric token subtotal is incomplete or absent. */
|
|
315
|
+
tokensKnown?: false;
|
|
316
|
+
costUsd?: number;
|
|
317
|
+
/** False when `costUsd` is only an observed floor, estimate, or absent. */
|
|
318
|
+
usdKnown?: false;
|
|
319
|
+
/** Separately-labelled local/catalog estimate; never billed spend. */
|
|
320
|
+
estimatedCostUsd?: number;
|
|
321
|
+
/** Provider-reported prompt-cache fields; absent fields remain unknown. */
|
|
322
|
+
promptCache?: Readonly<Record<string, number | string>>;
|
|
323
|
+
latencyMs?: number;
|
|
324
|
+
finishReason?: string;
|
|
325
|
+
timestamp?: string;
|
|
326
|
+
} | {
|
|
327
|
+
type: 'artifact';
|
|
328
|
+
task?: AgentTaskSpec;
|
|
329
|
+
session?: RuntimeSession;
|
|
330
|
+
artifactId: string;
|
|
331
|
+
name?: string;
|
|
332
|
+
mimeType?: string;
|
|
333
|
+
uri?: string;
|
|
334
|
+
content?: string;
|
|
335
|
+
metadata?: Record<string, unknown>;
|
|
336
|
+
timestamp?: string;
|
|
337
|
+
} | {
|
|
338
|
+
type: 'proposal_created';
|
|
339
|
+
task?: AgentTaskSpec;
|
|
340
|
+
session?: RuntimeSession;
|
|
341
|
+
proposalId: string;
|
|
342
|
+
title: string;
|
|
343
|
+
status?: 'pending' | 'approved' | 'rejected';
|
|
344
|
+
content?: string;
|
|
345
|
+
timestamp?: string;
|
|
346
|
+
} | {
|
|
347
|
+
type: 'backend_error';
|
|
348
|
+
task: AgentTaskSpec;
|
|
349
|
+
session?: RuntimeSession;
|
|
350
|
+
backend: string;
|
|
351
|
+
message: string;
|
|
352
|
+
recoverable: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Typed transport diagnostic. Present when the upstream returned a
|
|
355
|
+
* non-success HTTP status or every retry attempt threw. Consumers MUST
|
|
356
|
+
* surface this onto their `RunRecord.error` — silently treating a
|
|
357
|
+
* `backend_error` as "no output" hides credit exhaustion, auth failure,
|
|
358
|
+
* and upstream outages from operators.
|
|
359
|
+
* - `kind: 'transport'` — HTTP / network failure with optional `status`
|
|
360
|
+
* + truncated response `body`.
|
|
361
|
+
* - `kind: 'backend'` — the backend's `stream()` generator threw for a
|
|
362
|
+
* reason that isn't a recognized transport failure.
|
|
363
|
+
*/
|
|
364
|
+
error?: BackendErrorDetail;
|
|
365
|
+
timestamp: string;
|
|
366
|
+
} | {
|
|
367
|
+
type: 'backend_end';
|
|
368
|
+
task: AgentTaskSpec;
|
|
369
|
+
session: RuntimeSession;
|
|
370
|
+
backend: string;
|
|
371
|
+
timestamp: string;
|
|
372
|
+
} | {
|
|
373
|
+
type: 'task_end';
|
|
374
|
+
task: AgentTaskSpec;
|
|
375
|
+
status: AgentTaskStatus;
|
|
376
|
+
reason: string;
|
|
377
|
+
timestamp: string;
|
|
378
|
+
} | {
|
|
379
|
+
type: 'final';
|
|
380
|
+
task: AgentTaskSpec;
|
|
381
|
+
session?: RuntimeSession;
|
|
382
|
+
status: AgentTaskStatus;
|
|
383
|
+
reason: string;
|
|
384
|
+
text?: string;
|
|
385
|
+
metadata?: Record<string, unknown>;
|
|
386
|
+
/**
|
|
387
|
+
* Typed terminal-error diagnostic. Mirrors the `backend_error.error`
|
|
388
|
+
* shape so a consumer that only listens for `final` still receives a
|
|
389
|
+
* loud, structured failure when the backend never produced output. Only
|
|
390
|
+
* set when `status !== 'completed'`. Consumers building a `RunRecord`
|
|
391
|
+
* MUST map this to `RunRecord.error` rather than recording silent
|
|
392
|
+
* `error: null` with empty `finalText`.
|
|
393
|
+
*/
|
|
394
|
+
error?: BackendErrorDetail;
|
|
395
|
+
timestamp: string;
|
|
396
|
+
};
|
|
397
|
+
/** @stable */
|
|
398
|
+
interface RuntimeSession {
|
|
399
|
+
id: string;
|
|
400
|
+
backend: string;
|
|
401
|
+
status: 'active' | 'completed' | 'failed' | 'aborted';
|
|
402
|
+
resumeToken?: string;
|
|
403
|
+
createdAt: string;
|
|
404
|
+
updatedAt: string;
|
|
405
|
+
metadata?: Record<string, unknown>;
|
|
406
|
+
}
|
|
407
|
+
/** @stable */
|
|
408
|
+
interface RuntimeSessionStore {
|
|
409
|
+
get(sessionId: string): Promise<RuntimeSession | undefined> | RuntimeSession | undefined;
|
|
410
|
+
put(session: RuntimeSession): Promise<void> | void;
|
|
411
|
+
appendEvent?(sessionId: string, event: RuntimeStreamEvent): Promise<void> | void;
|
|
412
|
+
listEvents?(sessionId: string): Promise<RuntimeStreamEvent[]> | RuntimeStreamEvent[];
|
|
413
|
+
}
|
|
414
|
+
/** @stable */
|
|
415
|
+
interface AgentBackendInput {
|
|
416
|
+
task: AgentTaskSpec;
|
|
417
|
+
message?: string;
|
|
418
|
+
messages?: Array<{
|
|
419
|
+
role: string;
|
|
420
|
+
content: string;
|
|
421
|
+
}>;
|
|
422
|
+
inputs?: Record<string, unknown>;
|
|
423
|
+
}
|
|
424
|
+
/** @stable */
|
|
425
|
+
interface AgentBackendContext {
|
|
426
|
+
task: AgentTaskSpec;
|
|
427
|
+
knowledge: KnowledgeReadinessReport;
|
|
428
|
+
session: RuntimeSession;
|
|
429
|
+
signal?: AbortSignal;
|
|
430
|
+
/**
|
|
431
|
+
* Conversation/run identifier when this call is part of a multi-agent run.
|
|
432
|
+
* Backends should stamp it into any trace/log emission so cross-participant
|
|
433
|
+
* events correlate. Absent when the call is a stand-alone `runAgentTask`.
|
|
434
|
+
*/
|
|
435
|
+
runId?: string;
|
|
436
|
+
/**
|
|
437
|
+
* Deterministic turn id for this single call. Stable across retries of the
|
|
438
|
+
* same logical turn so a caching gateway / idempotent backend can dedupe.
|
|
439
|
+
*/
|
|
440
|
+
turnId?: string;
|
|
441
|
+
/**
|
|
442
|
+
* If this call is itself nested inside a higher-order conversation
|
|
443
|
+
* (recursion via `createConversationBackend`), the enclosing turn's id.
|
|
444
|
+
* Used for trace stitching across nested orchestration.
|
|
445
|
+
*/
|
|
446
|
+
parentTurnId?: string;
|
|
447
|
+
/**
|
|
448
|
+
* Headers to forward verbatim to any outbound HTTP the backend issues:
|
|
449
|
+
* `X-Tangle-Forwarded-Authorization`, `X-Tangle-Forwarded-Depth`,
|
|
450
|
+
* run/turn correlation. Backends that issue HTTP MUST merge these into
|
|
451
|
+
* the outbound request; backends that don't issue HTTP may ignore them.
|
|
452
|
+
*/
|
|
453
|
+
propagatedHeaders?: Readonly<Record<string, string>>;
|
|
454
|
+
}
|
|
455
|
+
/** @stable */
|
|
456
|
+
interface AgentExecutionBackend<TInput extends AgentBackendInput = AgentBackendInput> {
|
|
457
|
+
kind: string;
|
|
458
|
+
start?(input: TInput, context: Omit<AgentBackendContext, 'session'> & {
|
|
459
|
+
requestedSessionId?: string;
|
|
460
|
+
}): Promise<RuntimeSession> | RuntimeSession;
|
|
461
|
+
resume?(session: RuntimeSession, input: TInput, context: Omit<AgentBackendContext, 'session'>): Promise<RuntimeSession> | RuntimeSession;
|
|
462
|
+
stream(input: TInput, context: AgentBackendContext): AsyncIterable<RuntimeStreamEvent>;
|
|
463
|
+
stop?(session: RuntimeSession, reason: string): Promise<void> | void;
|
|
464
|
+
}
|
|
465
|
+
/** @stable */
|
|
466
|
+
interface RunAgentTaskStreamOptions<TInput extends AgentBackendInput = AgentBackendInput> {
|
|
467
|
+
task: AgentTaskSpec;
|
|
468
|
+
backend: AgentExecutionBackend<TInput>;
|
|
469
|
+
input?: Omit<TInput, 'task'>;
|
|
470
|
+
knowledge?: AgentKnowledgeProvider;
|
|
471
|
+
sessionStore?: RuntimeSessionStore;
|
|
472
|
+
sessionId?: string;
|
|
473
|
+
resume?: boolean;
|
|
474
|
+
signal?: AbortSignal;
|
|
475
|
+
minimumReadinessScore?: number;
|
|
476
|
+
}
|
|
477
|
+
/** @stable */
|
|
478
|
+
interface RunAgentTaskOptions<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
479
|
+
task: AgentTaskSpec;
|
|
480
|
+
adapter: AgentAdapter<TState, TAction, TActionResult, TEval>;
|
|
481
|
+
knowledge?: AgentKnowledgeProvider;
|
|
482
|
+
onEvent?: AgentRuntimeEventSink<TState, TAction, TActionResult, TEval>;
|
|
483
|
+
store?: TraceStore;
|
|
484
|
+
signal?: AbortSignal;
|
|
485
|
+
scenarioId?: string;
|
|
486
|
+
projectId?: string;
|
|
487
|
+
variantId?: string;
|
|
488
|
+
minimumReadinessScore?: number;
|
|
489
|
+
}
|
|
490
|
+
/** @stable */
|
|
491
|
+
interface AgentTaskRunResult<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
492
|
+
task: AgentTaskSpec;
|
|
493
|
+
status: AgentTaskStatus;
|
|
494
|
+
knowledge: KnowledgeReadinessReport;
|
|
495
|
+
questions: UserQuestion[];
|
|
496
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
497
|
+
userAnswers: Record<string, string>;
|
|
498
|
+
acquiredEvidenceIds: string[];
|
|
499
|
+
control: ControlRunResult<TState, TAction, TActionResult, TEval>;
|
|
500
|
+
runRecords: RunRecord[];
|
|
501
|
+
}
|
|
502
|
+
/** @stable */
|
|
503
|
+
interface KnowledgeReadinessDecision {
|
|
504
|
+
passed: boolean;
|
|
505
|
+
status: 'ready' | 'blocked' | 'caveat';
|
|
506
|
+
reason: string;
|
|
507
|
+
readinessScore: number;
|
|
508
|
+
recommendedAction: KnowledgeReadinessReport['recommendedAction'];
|
|
509
|
+
severity: KnowledgeReadinessReport['severity'];
|
|
510
|
+
blockingGapIds: string[];
|
|
511
|
+
nonBlockingGapIds: string[];
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
6
514
|
//#region src/runtime-run.d.ts
|
|
7
515
|
/** @stable */
|
|
8
516
|
type RuntimeRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
@@ -114,7 +622,7 @@ interface RuntimeRunHandle {
|
|
|
114
622
|
declare function startRuntimeRun(options: RuntimeRunOptions): RuntimeRunHandle;
|
|
115
623
|
//#endregion
|
|
116
624
|
//#region src/runtime/types.d.ts
|
|
117
|
-
/** @
|
|
625
|
+
/** @stable */
|
|
118
626
|
interface ValidationCtx {
|
|
119
627
|
/** Iteration index this output came from (0-based). */
|
|
120
628
|
iteration: number;
|
|
@@ -133,7 +641,7 @@ interface ValidationCtx {
|
|
|
133
641
|
*/
|
|
134
642
|
traceEmitter?: LoopTraceEmitter;
|
|
135
643
|
}
|
|
136
|
-
/** @
|
|
644
|
+
/** @stable */
|
|
137
645
|
interface Validator<Output, Verdict = DefaultVerdict> {
|
|
138
646
|
validate(output: Output, ctx: ValidationCtx): Promise<Verdict>;
|
|
139
647
|
}
|
|
@@ -146,7 +654,7 @@ interface Validator<Output, Verdict = DefaultVerdict> {
|
|
|
146
654
|
* fanout supplies multiple `AgentRunSpec`s and the kernel round-robins
|
|
147
655
|
* through them when the driver plans N tasks.
|
|
148
656
|
*
|
|
149
|
-
* @
|
|
657
|
+
* @stable
|
|
150
658
|
*/
|
|
151
659
|
interface AgentRunSpec<Task> {
|
|
152
660
|
/** Sandbox SDK profile — what kind of agent runs the task. */
|
|
@@ -191,7 +699,7 @@ interface AgentRunSpec<Task> {
|
|
|
191
699
|
* do not receive the live AsyncIterable so they can be replayed against
|
|
192
700
|
* persisted streams during tests / replays.
|
|
193
701
|
*
|
|
194
|
-
* @
|
|
702
|
+
* @stable
|
|
195
703
|
*/
|
|
196
704
|
interface OutputAdapter<Output> {
|
|
197
705
|
parse(events: SandboxEvent[]): Output;
|
|
@@ -201,6 +709,8 @@ interface OutputAdapter<Output> {
|
|
|
201
709
|
interface LoopTokenUsage {
|
|
202
710
|
input: number;
|
|
203
711
|
output: number;
|
|
712
|
+
/** False when the subtotal is incomplete. */
|
|
713
|
+
tokensKnown?: false;
|
|
204
714
|
}
|
|
205
715
|
/**
|
|
206
716
|
* One mounted resource recorded during box preparation — a pure provenance
|
|
@@ -211,7 +721,7 @@ interface LoopTokenUsage {
|
|
|
211
721
|
* its content fingerprint, its size, and where it came from — so a run is
|
|
212
722
|
* auditable after the fact ("what exactly was this agent given?").
|
|
213
723
|
*
|
|
214
|
-
* @
|
|
724
|
+
* @stable
|
|
215
725
|
*/
|
|
216
726
|
interface MountManifestEntry {
|
|
217
727
|
/** Destination path inside the box where the resource was placed. */
|
|
@@ -232,7 +742,7 @@ interface MountManifestEntry {
|
|
|
232
742
|
* human-readable reason, with no domain semantics. The kernel emits one receipt
|
|
233
743
|
* per scored candidate at finalize so a run answers "why did THIS one win?".
|
|
234
744
|
*
|
|
235
|
-
* @
|
|
745
|
+
* @stable
|
|
236
746
|
*/
|
|
237
747
|
interface SelectionReceipt {
|
|
238
748
|
/** Iteration index this receipt is about. */
|
|
@@ -255,7 +765,7 @@ interface SelectionReceipt {
|
|
|
255
765
|
* it. Empty arrays when the caller recorded no mounts and there was no
|
|
256
766
|
* candidate to select.
|
|
257
767
|
*
|
|
258
|
-
* @
|
|
768
|
+
* @stable
|
|
259
769
|
*/
|
|
260
770
|
interface RunProvenance {
|
|
261
771
|
/** Every resource recorded via `prepareBox`'s `recordMount`, in record order. */
|
|
@@ -268,10 +778,10 @@ interface RunProvenance {
|
|
|
268
778
|
* `prepareBox` so the caller — which owns the bytes it writes into the box —
|
|
269
779
|
* declares what it mounted without the kernel having to inspect box contents.
|
|
270
780
|
*
|
|
271
|
-
* @
|
|
781
|
+
* @stable
|
|
272
782
|
*/
|
|
273
783
|
type MountRecorder = (entry: MountManifestEntry) => void;
|
|
274
|
-
/** @
|
|
784
|
+
/** @stable */
|
|
275
785
|
interface Iteration<Task, Output> {
|
|
276
786
|
/** 0-based iteration index assigned by the kernel. */
|
|
277
787
|
index: number;
|
|
@@ -286,10 +796,16 @@ interface Iteration<Task, Output> {
|
|
|
286
796
|
startedAt: number;
|
|
287
797
|
endedAt: number;
|
|
288
798
|
costUsd: number;
|
|
799
|
+
/** False when `costUsd` is only the observed subtotal, not a complete bill. */
|
|
800
|
+
costUsdKnown?: false;
|
|
801
|
+
/** Local/catalog estimates remain separate from billed spend. */
|
|
802
|
+
estimatedCostUsd?: number;
|
|
803
|
+
/** Provider-reported prompt-cache fields; absent fields remain unknown. */
|
|
804
|
+
promptCache?: Record<string, number | string>;
|
|
289
805
|
/** Summed LLM token usage across every `llm_call` event in this iteration. */
|
|
290
806
|
tokenUsage: LoopTokenUsage;
|
|
291
807
|
}
|
|
292
|
-
/** @
|
|
808
|
+
/** @stable */
|
|
293
809
|
interface Driver<Task, Output, Decision> {
|
|
294
810
|
/**
|
|
295
811
|
* Stable identifier surfaced in trace events. Default `'driver'`.
|
|
@@ -328,7 +844,7 @@ interface Driver<Task, Output, Decision> {
|
|
|
328
844
|
*/
|
|
329
845
|
selectWinner?(history: ReadonlyArray<Iteration<Task, Output>>): LoopWinner<Task, Output> | undefined;
|
|
330
846
|
}
|
|
331
|
-
/** @
|
|
847
|
+
/** @stable Driver-supplied description of the just-planned move. */
|
|
332
848
|
interface LoopPlanDescription {
|
|
333
849
|
/** Topology move this round — e.g. `'refine' | 'fanout' | 'verify' | 'stop'`. */
|
|
334
850
|
kind: string;
|
|
@@ -342,7 +858,7 @@ interface LoopPlanDescription {
|
|
|
342
858
|
*/
|
|
343
859
|
parentIndex?: number;
|
|
344
860
|
}
|
|
345
|
-
/** @
|
|
861
|
+
/** @stable */
|
|
346
862
|
interface LoopWinner<Task, Output> {
|
|
347
863
|
task: Task;
|
|
348
864
|
output: Output;
|
|
@@ -350,7 +866,7 @@ interface LoopWinner<Task, Output> {
|
|
|
350
866
|
iterationIndex: number;
|
|
351
867
|
agentRunName: string;
|
|
352
868
|
}
|
|
353
|
-
/** @
|
|
869
|
+
/** @stable */
|
|
354
870
|
interface LoopResult<Task, Output, Decision> {
|
|
355
871
|
decision: Decision;
|
|
356
872
|
iterations: Iteration<Task, Output>[];
|
|
@@ -358,6 +874,12 @@ interface LoopResult<Task, Output, Decision> {
|
|
|
358
874
|
durationMs: number;
|
|
359
875
|
/** Sum of every iteration's `costUsd`. */
|
|
360
876
|
costUsd: number;
|
|
877
|
+
/** False when `costUsd` is only the observed subtotal, not a complete bill. */
|
|
878
|
+
costUsdKnown?: false;
|
|
879
|
+
/** Sum of separately-labelled local/catalog estimates. */
|
|
880
|
+
estimatedCostUsd?: number;
|
|
881
|
+
/** Aggregated provider-reported prompt-cache fields. */
|
|
882
|
+
promptCache?: Record<string, number | string>;
|
|
361
883
|
/** Sum of every iteration's token usage. `loopDispatch` commits it through
|
|
362
884
|
* the campaign's paid-call receipt. */
|
|
363
885
|
tokenUsage: LoopTokenUsage;
|
|
@@ -377,7 +899,7 @@ interface LoopResult<Task, Output, Decision> {
|
|
|
377
899
|
* Fleet-aware adapters set this; the raw `Sandbox` SDK class does not, and
|
|
378
900
|
* the kernel falls back to `{ placement: 'sibling', sandboxId: box.id }`.
|
|
379
901
|
*
|
|
380
|
-
* @
|
|
902
|
+
* @stable
|
|
381
903
|
*/
|
|
382
904
|
interface SandboxClient {
|
|
383
905
|
create(options?: CreateSandboxOptions): Promise<SandboxInstance>;
|
|
@@ -463,18 +985,18 @@ interface LoopLineageOptions {
|
|
|
463
985
|
*/
|
|
464
986
|
streaming?: 'sse' | 'poll';
|
|
465
987
|
}
|
|
466
|
-
/** @
|
|
988
|
+
/** @stable */
|
|
467
989
|
interface LoopSandboxPlacement {
|
|
468
990
|
kind: 'sibling' | 'fleet';
|
|
469
991
|
sandboxId?: string;
|
|
470
992
|
fleetId?: string;
|
|
471
993
|
machineId?: string;
|
|
472
994
|
}
|
|
473
|
-
/** @
|
|
995
|
+
/** @stable */
|
|
474
996
|
interface LoopTraceEmitter {
|
|
475
997
|
emit(event: LoopTraceEvent): void | Promise<void>;
|
|
476
998
|
}
|
|
477
|
-
/** @
|
|
999
|
+
/** @stable */
|
|
478
1000
|
type LoopTraceEvent = {
|
|
479
1001
|
kind: 'loop.started';
|
|
480
1002
|
runId: string;
|
|
@@ -516,7 +1038,7 @@ type LoopTraceEvent = {
|
|
|
516
1038
|
timestamp: number;
|
|
517
1039
|
payload: LoopTeardownFailedPayload;
|
|
518
1040
|
};
|
|
519
|
-
/** @
|
|
1041
|
+
/** @stable */
|
|
520
1042
|
interface LoopStartedPayload {
|
|
521
1043
|
driver: string;
|
|
522
1044
|
agentRunNames: string[];
|
|
@@ -529,7 +1051,7 @@ interface LoopStartedPayload {
|
|
|
529
1051
|
* the inferred fan-width. `moveKind` is the driver's `describePlan().kind` when
|
|
530
1052
|
* provided, else inferred from `plannedCount` (0→stop, 1→refine, N→fanout).
|
|
531
1053
|
*
|
|
532
|
-
* @
|
|
1054
|
+
* @stable
|
|
533
1055
|
*/
|
|
534
1056
|
interface LoopPlanPayload {
|
|
535
1057
|
/** 0-based plan round (one per `plan()` call). */
|
|
@@ -549,7 +1071,7 @@ interface LoopPlanPayload {
|
|
|
549
1071
|
/** Iteration indices this round dispatched (the edge targets). */
|
|
550
1072
|
childIndices: number[];
|
|
551
1073
|
}
|
|
552
|
-
/** @
|
|
1074
|
+
/** @stable */
|
|
553
1075
|
interface LoopIterationStartedPayload {
|
|
554
1076
|
iterationIndex: number;
|
|
555
1077
|
agentRunName: string;
|
|
@@ -565,7 +1087,7 @@ interface LoopIterationStartedPayload {
|
|
|
565
1087
|
* a shared-workspace fleet — workers see the caller's filesystem and any diff
|
|
566
1088
|
* they write lands on it directly.
|
|
567
1089
|
*
|
|
568
|
-
* @
|
|
1090
|
+
* @stable
|
|
569
1091
|
*/
|
|
570
1092
|
interface LoopIterationDispatchPayload {
|
|
571
1093
|
iterationIndex: number;
|
|
@@ -582,7 +1104,7 @@ interface LoopIterationDispatchPayload {
|
|
|
582
1104
|
/** Iteration this one was planned from; `undefined` ⇒ root. */
|
|
583
1105
|
parentIndex?: number;
|
|
584
1106
|
}
|
|
585
|
-
/** @
|
|
1107
|
+
/** @stable */
|
|
586
1108
|
interface LoopIterationEndedPayload {
|
|
587
1109
|
iterationIndex: number;
|
|
588
1110
|
agentRunName: string;
|
|
@@ -590,6 +1112,8 @@ interface LoopIterationEndedPayload {
|
|
|
590
1112
|
verdict?: DefaultVerdict;
|
|
591
1113
|
error?: string;
|
|
592
1114
|
costUsd: number;
|
|
1115
|
+
costUsdKnown?: false;
|
|
1116
|
+
estimatedCostUsd?: number;
|
|
593
1117
|
durationMs: number;
|
|
594
1118
|
/** Summed LLM token usage for this iteration — maps to gen_ai.usage.* on the
|
|
595
1119
|
* branch span. Omitted when no `llm_call` events carried token counts. */
|
|
@@ -602,21 +1126,23 @@ interface LoopIterationEndedPayload {
|
|
|
602
1126
|
* Bounded to ~280 chars; never the full payload. */
|
|
603
1127
|
outputPreview?: string;
|
|
604
1128
|
}
|
|
605
|
-
/** @
|
|
1129
|
+
/** @stable */
|
|
606
1130
|
interface LoopDecisionPayload {
|
|
607
1131
|
decision: string;
|
|
608
1132
|
historyLength: number;
|
|
609
1133
|
}
|
|
610
|
-
/** @
|
|
1134
|
+
/** @stable */
|
|
611
1135
|
interface LoopEndedPayload {
|
|
612
1136
|
winnerIterationIndex?: number;
|
|
613
1137
|
totalCostUsd: number;
|
|
1138
|
+
costUsdKnown?: false;
|
|
1139
|
+
estimatedCostUsd?: number;
|
|
614
1140
|
durationMs: number;
|
|
615
1141
|
iterations: number;
|
|
616
1142
|
}
|
|
617
1143
|
/** Emitted when a box's `delete()` throws or times out during teardown — the
|
|
618
1144
|
* loop swallows the failure (platform reaps on expiry) but surfaces it here so
|
|
619
|
-
* a real leak (e.g. mid-loop auth expiry) is observable. @
|
|
1145
|
+
* a real leak (e.g. mid-loop auth expiry) is observable. @stable */
|
|
620
1146
|
interface LoopTeardownFailedPayload {
|
|
621
1147
|
sandboxId?: string;
|
|
622
1148
|
/** `'timeout'` or the delete error message. */
|
|
@@ -625,7 +1151,7 @@ interface LoopTeardownFailedPayload {
|
|
|
625
1151
|
/**
|
|
626
1152
|
* Execution context for `runAgentRounds`: the sandbox client the kernel creates boxes through, plus optional runtime hooks.
|
|
627
1153
|
*
|
|
628
|
-
* @
|
|
1154
|
+
* @stable
|
|
629
1155
|
*/
|
|
630
1156
|
interface ExecCtx {
|
|
631
1157
|
/** Sandbox SDK client — the kernel calls `.create()` per iteration. */
|
|
@@ -676,5 +1202,5 @@ interface ExecCtx {
|
|
|
676
1202
|
parentSpanId?: string;
|
|
677
1203
|
}
|
|
678
1204
|
//#endregion
|
|
679
|
-
export { RuntimeRunCompleteInput as A, MountRecorder as C, SelectionReceipt as D, SandboxClient as E, RuntimeRunRow as F, RuntimeRunStatus as I, startRuntimeRun as L, RuntimeRunHandle as M, RuntimeRunOptions as N, ValidationCtx as O, RuntimeRunPersistenceAdapter as P, MountManifestEntry as S, RunProvenance as T, LoopTeardownFailedPayload as _, Iteration as a, LoopTraceEvent as b, LoopIterationDispatchPayload as c, LoopLineageOptions as d, LoopPlanDescription as f, LoopStartedPayload as g, LoopSandboxPlacement as h, ExecCtx as i, RuntimeRunCost as j, Validator as k, LoopIterationEndedPayload as l, LoopResult as m, DefaultVerdict as n, LoopDecisionPayload as o, LoopPlanPayload as p, Driver as r, LoopEndedPayload as s, AgentRunSpec as t, LoopIterationStartedPayload as u, LoopTokenUsage as v, OutputAdapter as w, LoopWinner as x, LoopTraceEmitter as y };
|
|
680
|
-
//# sourceMappingURL=types-
|
|
1205
|
+
export { OpenAIChatToolChoice as $, RuntimeRunCompleteInput as A, AgentBackendInput as B, MountRecorder as C, SelectionReceipt as D, SandboxClient as E, RuntimeRunRow as F, AgentTaskContext as G, AgentKnowledgeProvider as H, RuntimeRunStatus as I, AgentTaskStatus as J, AgentTaskRunResult as K, startRuntimeRun as L, RuntimeRunHandle as M, RuntimeRunOptions as N, ValidationCtx as O, RuntimeRunPersistenceAdapter as P, OpenAIChatTool as Q, AgentAdapter as R, MountManifestEntry as S, RunProvenance as T, AgentRuntimeEvent as U, AgentExecutionBackend as V, AgentRuntimeEventSink as W, KnowledgeReadinessDecision as X, BackendErrorDetail as Y, OpenAIChatResponseFormat as Z, LoopTeardownFailedPayload as _, Iteration as a, LoopTraceEvent as b, LoopIterationDispatchPayload as c, LoopLineageOptions as d, RunAgentTaskOptions as et, LoopPlanDescription as f, LoopStartedPayload as g, LoopSandboxPlacement as h, ExecCtx as i, RuntimeStreamEvent as it, RuntimeRunCost as j, Validator as k, LoopIterationEndedPayload as l, LoopResult as m, DefaultVerdict as n, RuntimeSession as nt, LoopDecisionPayload as o, LoopPlanPayload as p, AgentTaskSpec as q, Driver as r, RuntimeSessionStore as rt, LoopEndedPayload as s, AgentRunSpec as t, RunAgentTaskStreamOptions as tt, LoopIterationStartedPayload as u, LoopTokenUsage as v, OutputAdapter as w, LoopWinner as x, LoopTraceEmitter as y, AgentBackendContext as z };
|
|
1206
|
+
//# sourceMappingURL=types-ebIY0dMG.d.ts.map
|