@tangle-network/agent-runtime 0.104.0 → 0.106.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 +176 -42
- package/dist/activation-CRjVfOiy.js +203 -0
- package/dist/activation-CRjVfOiy.js.map +1 -0
- package/dist/activation-DyWB0K6E.d.ts +98 -0
- package/dist/agent.d.ts +216 -234
- package/dist/agent.js +615 -547
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop-DGdtVENg.js +517 -0
- package/dist/analyst-loop-DGdtVENg.js.map +1 -0
- package/dist/analyst-loop.d.ts +10 -43
- package/dist/analyst-loop.js +2 -11
- package/dist/backends-Dy8NujB4.js +713 -0
- package/dist/backends-Dy8NujB4.js.map +1 -0
- package/dist/candidate-execution/index.d.ts +4 -192
- package/dist/candidate-execution/index.js +5 -66
- package/dist/candidate-execution-DqMbv1rU.js +488 -0
- package/dist/candidate-execution-DqMbv1rU.js.map +1 -0
- package/dist/coder-yhVWbdWc.js +40 -0
- package/dist/coder-yhVWbdWc.js.map +1 -0
- package/dist/conversation-XucG_K3l.js +1265 -0
- package/dist/conversation-XucG_K3l.js.map +1 -0
- package/dist/conversation.d.ts +2 -804
- package/dist/conversation.js +2 -55
- package/dist/environment-provider-CfLUmKmf.js +1168 -0
- package/dist/environment-provider-CfLUmKmf.js.map +1 -0
- package/dist/environment-provider-IUGU3epE.d.ts +964 -0
- package/dist/environment-provider.d.ts +2 -78
- package/dist/environment-provider.js +2 -18
- package/dist/errors-DEAvWQPy.js +111 -0
- package/dist/errors-DEAvWQPy.js.map +1 -0
- package/dist/improvement-adapter-Cr5TBSji.d.ts +166 -0
- package/dist/improvement-cycle-C095kS_g.js +2624 -0
- package/dist/improvement-cycle-C095kS_g.js.map +1 -0
- package/dist/index-BGdxAwfO.d.ts +838 -0
- package/dist/index-C-FYUuFG.d.ts +193 -0
- package/dist/index-CbNM40xG.d.ts +140 -0
- package/dist/index-DruSKs3Z.d.ts +7224 -0
- package/dist/index-Efjb3nrQ.d.ts +671 -0
- package/dist/index.d.ts +14 -1134
- package/dist/index.js +2134 -1972
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +776 -888
- package/dist/intelligence.js +1466 -1410
- package/dist/intelligence.js.map +1 -1
- package/dist/{kb-gate-CwHO0vz6.d.ts → kb-gate-C8z2juK8.d.ts} +33 -31
- package/dist/kb-gate-DpaSwXVx.js +80 -0
- package/dist/kb-gate-DpaSwXVx.js.map +1 -0
- package/dist/knowledge-Ku-mPP4f.js +433 -0
- package/dist/knowledge-Ku-mPP4f.js.map +1 -0
- package/dist/knowledge.d.ts +2 -150
- package/dist/knowledge.js +2 -40
- package/dist/local-harness-Dh8PJ0ot.d.ts +455 -0
- package/dist/loop-runner-bin-BXsFEUcf.d.ts +162 -0
- package/dist/loop-runner-bin-BwjQ1NfH.js +268 -0
- package/dist/loop-runner-bin-BwjQ1NfH.js.map +1 -0
- package/dist/loop-runner-bin.d.ts +2 -17
- package/dist/loop-runner-bin.js +2 -24
- package/dist/loops.d.ts +5 -4164
- package/dist/loops.js +8 -419
- package/dist/mcp/bin.d.ts +1 -1
- package/dist/mcp/bin.js +116 -146
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +295 -437
- package/dist/mcp/index.js +1242 -1177
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/memory-bin.d.ts +1 -1
- package/dist/mcp/memory-bin.js +37 -16
- package/dist/mcp/memory-bin.js.map +1 -1
- package/dist/memory-server-DL6cE2Ag.js +234 -0
- package/dist/memory-server-DL6cE2Ag.js.map +1 -0
- package/dist/model-resolution-Btd9iIKV.js +98 -0
- package/dist/model-resolution-Btd9iIKV.js.map +1 -0
- package/dist/openai-tools-B68JaOCx.d.ts +24 -0
- package/dist/openai-tools-CKLy1C7M.js +44 -0
- package/dist/openai-tools-CKLy1C7M.js.map +1 -0
- package/dist/otel-export-D34IQW1C.js +843 -0
- package/dist/otel-export-D34IQW1C.js.map +1 -0
- package/dist/platform.d.ts +188 -185
- package/dist/platform.js +185 -218
- package/dist/platform.js.map +1 -1
- package/dist/prepare-B53sPV7M.js +4292 -0
- package/dist/prepare-B53sPV7M.js.map +1 -0
- package/dist/primeintellect/index.d.ts +150 -147
- package/dist/primeintellect/index.js +626 -1004
- package/dist/primeintellect/index.js.map +1 -1
- package/dist/profiles.d.ts +296 -490
- package/dist/profiles.js +722 -749
- package/dist/profiles.js.map +1 -1
- package/dist/protected-model-port-BLPH5VVv.js +722 -0
- package/dist/protected-model-port-BLPH5VVv.js.map +1 -0
- package/dist/protected-model-port-BP6Z4eau.d.ts +283 -0
- package/dist/protected-redaction--F3v1oo8.js +200 -0
- package/dist/protected-redaction--F3v1oo8.js.map +1 -0
- package/dist/redact-D-u-rrcn.js +82 -0
- package/dist/redact-D-u-rrcn.js.map +1 -0
- package/dist/redact-kbIOjfjM.d.ts +452 -0
- package/dist/researcher-CoVqNhfI.js +433 -0
- package/dist/researcher-CoVqNhfI.js.map +1 -0
- package/dist/runtime-BG0BziaP.js +5408 -0
- package/dist/runtime-BG0BziaP.js.map +1 -0
- package/dist/sandbox-events-DeI5xX8P.js +316 -0
- package/dist/sandbox-events-DeI5xX8P.js.map +1 -0
- package/dist/spawn-journal-CwPvKUTa.js +456 -0
- package/dist/spawn-journal-CwPvKUTa.js.map +1 -0
- package/dist/structural-rollout-IXUEplky.js +1445 -0
- package/dist/structural-rollout-IXUEplky.js.map +1 -0
- package/dist/substrate-B0TYNrXn.js +27 -0
- package/dist/substrate-B0TYNrXn.js.map +1 -0
- package/dist/{substrate-Dyiqmd3o.d.ts → substrate-BcnuSHXm.d.ts} +57 -54
- package/dist/supervise-BiRutHS9.js +7321 -0
- package/dist/supervise-BiRutHS9.js.map +1 -0
- package/dist/supervisor-DTKhF-RV.js +3826 -0
- package/dist/supervisor-DTKhF-RV.js.map +1 -0
- package/dist/testing.d.ts +4 -3
- package/dist/testing.js +2478 -2637
- package/dist/testing.js.map +1 -1
- package/dist/tool-server-RcWgLIsL.js +141 -0
- package/dist/tool-server-RcWgLIsL.js.map +1 -0
- package/dist/trace-propagation-CJJC7SVB.js +57 -0
- package/dist/trace-propagation-CJJC7SVB.js.map +1 -0
- package/dist/types-BaIpb0XT.d.ts +492 -0
- package/dist/types-BevOjfTY.d.ts +765 -0
- package/dist/types-C9j4qg6l.d.ts +500 -0
- package/dist/types-Cja5OTGh.d.ts +190 -0
- package/dist/util-MVgdwuIS.js +145 -0
- package/dist/util-MVgdwuIS.js.map +1 -0
- package/dist/workspace-archive-BosQiotA.js +575 -0
- package/dist/workspace-archive-BosQiotA.js.map +1 -0
- package/package.json +43 -55
- package/skills/build-with-agent-runtime/SKILL.md +16 -9
- package/skills/loop-writer/SKILL.md +1 -1
- package/dist/activation-Cm-9MMX1.d.ts +0 -69
- package/dist/analyst-loop.js.map +0 -1
- package/dist/backends-BO4Jqoe2.d.ts +0 -134
- package/dist/candidate-execution/index.js.map +0 -1
- package/dist/chunk-2KGAN2HM.js +0 -1256
- package/dist/chunk-2KGAN2HM.js.map +0 -1
- package/dist/chunk-2QJSNOGK.js +0 -48
- package/dist/chunk-2QJSNOGK.js.map +0 -1
- package/dist/chunk-2UABGGUB.js +0 -474
- package/dist/chunk-2UABGGUB.js.map +0 -1
- package/dist/chunk-2VZYRB55.js +0 -834
- package/dist/chunk-2VZYRB55.js.map +0 -1
- package/dist/chunk-2X65HYMI.js +0 -3526
- package/dist/chunk-2X65HYMI.js.map +0 -1
- package/dist/chunk-3MDZX7YU.js +0 -125
- package/dist/chunk-3MDZX7YU.js.map +0 -1
- package/dist/chunk-3PPVCS75.js +0 -199
- package/dist/chunk-3PPVCS75.js.map +0 -1
- package/dist/chunk-5HNDYWUT.js +0 -6424
- package/dist/chunk-5HNDYWUT.js.map +0 -1
- package/dist/chunk-5IBQAPVB.js +0 -29
- package/dist/chunk-5IBQAPVB.js.map +0 -1
- package/dist/chunk-5QOB7H74.js +0 -387
- package/dist/chunk-5QOB7H74.js.map +0 -1
- package/dist/chunk-ATDFUJYI.js +0 -4728
- package/dist/chunk-ATDFUJYI.js.map +0 -1
- package/dist/chunk-B7K7V22Y.js +0 -699
- package/dist/chunk-B7K7V22Y.js.map +0 -1
- package/dist/chunk-DPEUKJRO.js +0 -27
- package/dist/chunk-DPEUKJRO.js.map +0 -1
- package/dist/chunk-FD2MBMOH.js +0 -494
- package/dist/chunk-FD2MBMOH.js.map +0 -1
- package/dist/chunk-FJI3EXU3.js +0 -2402
- package/dist/chunk-FJI3EXU3.js.map +0 -1
- package/dist/chunk-HAO4CXHP.js +0 -200
- package/dist/chunk-HAO4CXHP.js.map +0 -1
- package/dist/chunk-ISPWRSEC.js +0 -408
- package/dist/chunk-ISPWRSEC.js.map +0 -1
- package/dist/chunk-KRBFHMV6.js +0 -1228
- package/dist/chunk-KRBFHMV6.js.map +0 -1
- package/dist/chunk-L5DST3QC.js +0 -351
- package/dist/chunk-L5DST3QC.js.map +0 -1
- package/dist/chunk-M22PL4GH.js +0 -171
- package/dist/chunk-M22PL4GH.js.map +0 -1
- package/dist/chunk-NURIQBJQ.js +0 -72
- package/dist/chunk-NURIQBJQ.js.map +0 -1
- package/dist/chunk-PZZKQVQV.js +0 -52
- package/dist/chunk-PZZKQVQV.js.map +0 -1
- package/dist/chunk-Q2JSAVQ3.js +0 -671
- package/dist/chunk-Q2JSAVQ3.js.map +0 -1
- package/dist/chunk-SBTWKPVR.js +0 -5576
- package/dist/chunk-SBTWKPVR.js.map +0 -1
- package/dist/chunk-SGKPNBXE.js +0 -60
- package/dist/chunk-SGKPNBXE.js.map +0 -1
- package/dist/chunk-SNSMRT6H.js +0 -680
- package/dist/chunk-SNSMRT6H.js.map +0 -1
- package/dist/chunk-STJEHM5F.js +0 -1338
- package/dist/chunk-STJEHM5F.js.map +0 -1
- package/dist/chunk-UPWGXKXB.js +0 -254
- package/dist/chunk-UPWGXKXB.js.map +0 -1
- package/dist/chunk-YEJR7IXO.js +0 -68
- package/dist/chunk-YEJR7IXO.js.map +0 -1
- package/dist/chunk-ZXICDSAK.js +0 -907
- package/dist/chunk-ZXICDSAK.js.map +0 -1
- package/dist/completion-gate-Bv47cOnn.d.ts +0 -256
- package/dist/conversation.js.map +0 -1
- package/dist/coordination-CxtzMxSM.d.ts +0 -2570
- package/dist/environment-provider.js.map +0 -1
- package/dist/improve--2A0gK1-.d.ts +0 -440
- package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
- package/dist/knowledge.js.map +0 -1
- package/dist/local-harness-CtK9dSny.d.ts +0 -175
- package/dist/loop-runner-bin-DUOGtvOl.d.ts +0 -207
- package/dist/loop-runner-bin.js.map +0 -1
- package/dist/loops.js.map +0 -1
- package/dist/openai-tools-fnj6SRVg.d.ts +0 -46
- package/dist/protected-model-port-DzkUY3HQ.d.ts +0 -271
- package/dist/sanitize-DEbPNtyI.d.ts +0 -328
- package/dist/structural-rollout-C4mabf87.d.ts +0 -446
- package/dist/supervise-7q9F5brx.d.ts +0 -379
- package/dist/types-BCoemcXU.d.ts +0 -802
- package/dist/types-BwoZWq-i.d.ts +0 -510
- package/dist/types-Cbp72qyu.d.ts +0 -491
- package/dist/types-CmYCMbFT.d.ts +0 -203
- package/dist/types-CvNwMzQt.d.ts +0 -957
- package/dist/worktree-fanout-WsOzt8qu.d.ts +0 -999
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { TraceStore } from '@tangle-network/agent-eval';
|
|
2
|
-
import { AgentCandidateArtifactRef, AgentCandidateAttemptPolicy, Sha256Digest, AgentCandidateResolvedModel, AgentCandidateFixedSpend, AgentProfile, AgentCandidateProfile, AgentProfileDiff, AgentCandidateProfilePlanEvidence, AgentCandidateProfileActivation } from '@tangle-network/agent-interface';
|
|
3
|
-
import { A as AgentCandidateExecutorPort, a as AgentCandidateBenchmarkGraderPort, b as AgentCandidateOutputArtifactPort, P as PreparedAgentCandidateExecution, c as AgentCandidateRunFinalization, V as VerifiedAgentCandidate, d as AgentCandidateTaskExecution, e as AgentCandidateExecutionPorts, f as AgentCandidateModelPort, g as AgentCandidateProtectedModelReservation, h as AgentCandidateProtectedModelActivation, i as AgentCandidateProtectedModelSettlement } from './types-Cbp72qyu.js';
|
|
4
|
-
|
|
5
|
-
interface AgentCandidatePreparationEvidence {
|
|
6
|
-
readonly executionPlan: AgentCandidateArtifactRef;
|
|
7
|
-
readonly materializationReceipt: AgentCandidateArtifactRef;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** Durable one-shot lifecycle for candidate execution attempts. */
|
|
11
|
-
|
|
12
|
-
/** Non-secret identities a trusted recovery worker needs to close an abandoned attempt. */
|
|
13
|
-
interface AgentCandidateExecutionCleanupHandles {
|
|
14
|
-
readonly preparationId: string;
|
|
15
|
-
readonly modelGrantDigest: Sha256Digest;
|
|
16
|
-
readonly resolvedModel: AgentCandidateResolvedModel;
|
|
17
|
-
readonly traceRunId: string;
|
|
18
|
-
readonly cleanupTimeoutMs: number;
|
|
19
|
-
readonly memory?: {
|
|
20
|
-
readonly accessDigest: Sha256Digest;
|
|
21
|
-
readonly effectiveNamespace: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/** Immutable signed identity stored for one execution attempt. */
|
|
25
|
-
interface AgentCandidateExecutionClaim {
|
|
26
|
-
readonly executionId: string;
|
|
27
|
-
readonly attempt: number;
|
|
28
|
-
readonly maxAttempts: number;
|
|
29
|
-
readonly retryPolicy: AgentCandidateAttemptPolicy['retryPolicy'];
|
|
30
|
-
readonly bundleDigest: Sha256Digest;
|
|
31
|
-
readonly executionPlanDigest: Sha256Digest;
|
|
32
|
-
/** Durable canonical bytes needed to reconstruct the signed preparation. */
|
|
33
|
-
readonly preparationEvidence: AgentCandidatePreparationEvidence;
|
|
34
|
-
/** Frozen plan identity with only attempt number and per-attempt grant identity normalized. */
|
|
35
|
-
readonly retryLineageDigest: Sha256Digest;
|
|
36
|
-
/** The winning lease stops authorizing a new terminal write at this instant. */
|
|
37
|
-
readonly leaseExpiresAtMs: number;
|
|
38
|
-
/** Frozen budget for task verification, executable grading, and receipt construction. */
|
|
39
|
-
readonly resultTimeoutMs: number;
|
|
40
|
-
/** Non-secret handles retained so an expired attempt can be closed and reconciled. */
|
|
41
|
-
readonly cleanup: AgentCandidateExecutionCleanupHandles;
|
|
42
|
-
}
|
|
43
|
-
/** Secret capability required to finish the acquired attempt. */
|
|
44
|
-
interface AgentCandidateExecutionLease {
|
|
45
|
-
readonly executionId: string;
|
|
46
|
-
readonly attempt: number;
|
|
47
|
-
readonly token: string;
|
|
48
|
-
readonly expiresAtMs: number;
|
|
49
|
-
}
|
|
50
|
-
/** Only the first class is retryable, and only when the closed model ledger has zero calls. */
|
|
51
|
-
type AgentCandidateExecutionFailureClass = 'pre-model-infrastructure' | 'execution' | 'post-model-infrastructure' | 'unknown';
|
|
52
|
-
/** Evaluator-owned terminal facts staged durably before the terminal CAS. */
|
|
53
|
-
type AgentCandidateExecutionTerminalResult = {
|
|
54
|
-
readonly status: 'succeeded';
|
|
55
|
-
readonly usage: AgentCandidateFixedSpend;
|
|
56
|
-
readonly modelSettlement: AgentCandidateArtifactRef;
|
|
57
|
-
readonly taskOutcome: AgentCandidateArtifactRef;
|
|
58
|
-
readonly benchmarkResult: AgentCandidateArtifactRef;
|
|
59
|
-
readonly runReceipt: AgentCandidateArtifactRef;
|
|
60
|
-
} | {
|
|
61
|
-
readonly status: 'failed';
|
|
62
|
-
readonly failureClass: AgentCandidateExecutionFailureClass;
|
|
63
|
-
readonly usage: AgentCandidateFixedSpend;
|
|
64
|
-
readonly modelSettlement: AgentCandidateArtifactRef;
|
|
65
|
-
readonly failureEvidence?: AgentCandidateArtifactRef;
|
|
66
|
-
};
|
|
67
|
-
/** Durable terminal record for one acquired execution attempt. */
|
|
68
|
-
type AgentCandidateExecutionTerminalRecord = AgentCandidateExecutionTerminalResult & {
|
|
69
|
-
readonly executionId: string;
|
|
70
|
-
readonly attempt: number;
|
|
71
|
-
readonly bundleDigest: Sha256Digest;
|
|
72
|
-
readonly executionPlanDigest: Sha256Digest;
|
|
73
|
-
readonly preparationEvidence: AgentCandidateExecutionClaim['preparationEvidence'];
|
|
74
|
-
/** RFC 8785 SHA-256 of this record with `terminalDigest` omitted. */
|
|
75
|
-
readonly terminalDigest: Sha256Digest;
|
|
76
|
-
};
|
|
77
|
-
/** Monotonic durable phase: the second value means candidate code could have started. */
|
|
78
|
-
type AgentCandidateExecutionPhase = 'claimed' | 'candidate-may-run';
|
|
79
|
-
/** Trusted, independently observed closure facts for one expired winning lease. */
|
|
80
|
-
interface AgentCandidateExecutionRecoveryEvidence {
|
|
81
|
-
readonly failureClass: AgentCandidateExecutionFailureClass;
|
|
82
|
-
readonly usage: AgentCandidateFixedSpend;
|
|
83
|
-
readonly modelSettlement: AgentCandidateArtifactRef;
|
|
84
|
-
readonly failureEvidence?: AgentCandidateArtifactRef;
|
|
85
|
-
readonly process: {
|
|
86
|
-
readonly stopped: true;
|
|
87
|
-
readonly executionPlanDigest: Sha256Digest;
|
|
88
|
-
};
|
|
89
|
-
readonly model: {
|
|
90
|
-
readonly closed: true;
|
|
91
|
-
readonly preparationId: string;
|
|
92
|
-
readonly grantDigest: Sha256Digest;
|
|
93
|
-
};
|
|
94
|
-
readonly memory?: {
|
|
95
|
-
readonly closed: true;
|
|
96
|
-
readonly preparationId: string;
|
|
97
|
-
readonly accessDigest: Sha256Digest;
|
|
98
|
-
readonly effectiveNamespace: string;
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
interface AgentCandidateExecutionAttemptRef {
|
|
102
|
-
readonly executionId: string;
|
|
103
|
-
readonly attempt: number;
|
|
104
|
-
}
|
|
105
|
-
/** Persisted state available to a fresh trusted recovery worker after a crash. */
|
|
106
|
-
interface AgentCandidateExecutionAttemptRecord {
|
|
107
|
-
readonly claim: AgentCandidateExecutionClaim;
|
|
108
|
-
readonly phase: AgentCandidateExecutionPhase;
|
|
109
|
-
/** Durable outbox content written before the terminal compare-and-set. */
|
|
110
|
-
readonly staged?: AgentCandidateExecutionTerminalRecord;
|
|
111
|
-
readonly terminal?: AgentCandidateExecutionTerminalRecord;
|
|
112
|
-
}
|
|
113
|
-
/** Result of atomically claiming one execution attempt. */
|
|
114
|
-
type AgentCandidateExecutionClaimResult = {
|
|
115
|
-
readonly acquired: true;
|
|
116
|
-
readonly claim: AgentCandidateExecutionClaim;
|
|
117
|
-
readonly lease: AgentCandidateExecutionLease;
|
|
118
|
-
} | {
|
|
119
|
-
readonly acquired: false;
|
|
120
|
-
readonly reason: 'already-claimed';
|
|
121
|
-
/** The durable winner already occupying this execution-attempt slot. */
|
|
122
|
-
readonly claim: AgentCandidateExecutionClaim;
|
|
123
|
-
/** True only when every signed claim field matches the durable winner. */
|
|
124
|
-
readonly exactReplay: boolean;
|
|
125
|
-
} | {
|
|
126
|
-
readonly acquired: false;
|
|
127
|
-
readonly reason: 'retry-not-eligible';
|
|
128
|
-
readonly claim: AgentCandidateExecutionClaim;
|
|
129
|
-
readonly detail: AgentCandidateRetryRejection;
|
|
130
|
-
};
|
|
131
|
-
/** Result of atomically recording an attempt's terminal facts. */
|
|
132
|
-
type AgentCandidateExecutionFinishResult = {
|
|
133
|
-
readonly finished: true;
|
|
134
|
-
readonly terminal: AgentCandidateExecutionTerminalRecord;
|
|
135
|
-
} | {
|
|
136
|
-
readonly finished: false;
|
|
137
|
-
readonly terminal: AgentCandidateExecutionTerminalRecord;
|
|
138
|
-
/** True when a repeated finish supplied the same terminal digest. */
|
|
139
|
-
readonly exactReplay: boolean;
|
|
140
|
-
};
|
|
141
|
-
/** Result of durably staging the one immutable terminal outbox entry. */
|
|
142
|
-
type AgentCandidateExecutionStageResult = {
|
|
143
|
-
readonly staged: true;
|
|
144
|
-
readonly terminal: AgentCandidateExecutionTerminalRecord;
|
|
145
|
-
} | {
|
|
146
|
-
readonly staged: false;
|
|
147
|
-
readonly terminal: AgentCandidateExecutionTerminalRecord;
|
|
148
|
-
readonly exactReplay: boolean;
|
|
149
|
-
};
|
|
150
|
-
/** Result of crossing the irreversible candidate-may-run boundary. */
|
|
151
|
-
type AgentCandidateExecutionPhaseResult = {
|
|
152
|
-
readonly marked: true;
|
|
153
|
-
readonly phase: 'candidate-may-run';
|
|
154
|
-
} | {
|
|
155
|
-
readonly marked: false;
|
|
156
|
-
readonly phase: 'candidate-may-run';
|
|
157
|
-
};
|
|
158
|
-
type AgentCandidateRetryRejection = 'prior-attempt-missing' | 'prior-attempt-running' | 'prior-attempt-succeeded' | 'prior-attempt-spent-model-calls' | 'prior-attempt-not-pre-model-infrastructure' | 'retry-lineage-mismatch';
|
|
159
|
-
/**
|
|
160
|
-
* Atomic one-shot store for candidate execution attempts.
|
|
161
|
-
*
|
|
162
|
-
* Implementations must linearize both methods across every process sharing the
|
|
163
|
-
* store. Terminal publication is deliberately two-step: `stageTerminal`
|
|
164
|
-
* fsyncs the complete immutable outbox record, then `finish` publishes exactly
|
|
165
|
-
* those staged bytes by digest. A crash between the two leaves recoverable
|
|
166
|
-
* evidence rather than an ambiguous completed run.
|
|
167
|
-
*/
|
|
168
|
-
interface AgentCandidateExecutionClaimStore {
|
|
169
|
-
tryClaim(claim: AgentCandidateExecutionClaim): Promise<AgentCandidateExecutionClaimResult>;
|
|
170
|
-
getAttempt(attempt: AgentCandidateExecutionAttemptRef): Promise<AgentCandidateExecutionAttemptRecord | undefined>;
|
|
171
|
-
/** Persist the point after which candidate code may have run. */
|
|
172
|
-
markCandidateMayRun(lease: AgentCandidateExecutionLease): Promise<AgentCandidateExecutionPhaseResult>;
|
|
173
|
-
/** Fsync the complete terminal record into the durable outbox. */
|
|
174
|
-
stageTerminal(lease: AgentCandidateExecutionLease, result: AgentCandidateExecutionTerminalResult): Promise<AgentCandidateExecutionStageResult>;
|
|
175
|
-
/** Publish exactly the staged terminal identified by `terminalDigest`. */
|
|
176
|
-
finish(lease: AgentCandidateExecutionLease, terminalDigest: Sha256Digest): Promise<AgentCandidateExecutionFinishResult>;
|
|
177
|
-
/**
|
|
178
|
-
* Write a failed terminal only after the lease expired and a trusted worker
|
|
179
|
-
* independently proved process death plus model and memory closure.
|
|
180
|
-
*/
|
|
181
|
-
recoverExpired(attempt: AgentCandidateExecutionAttemptRef, evidence: AgentCandidateExecutionRecoveryEvidence): Promise<AgentCandidateExecutionFinishResult>;
|
|
182
|
-
}
|
|
183
|
-
interface InMemoryAgentCandidateExecutionClaimStoreOptions {
|
|
184
|
-
/** Testable evaluator clock; defaults to `Date.now`. */
|
|
185
|
-
now?: () => number;
|
|
186
|
-
}
|
|
187
|
-
/** Single-process lifecycle implementation. */
|
|
188
|
-
declare class InMemoryAgentCandidateExecutionClaimStore implements AgentCandidateExecutionClaimStore {
|
|
189
|
-
private readonly claims;
|
|
190
|
-
private readonly now;
|
|
191
|
-
constructor(options?: InMemoryAgentCandidateExecutionClaimStoreOptions);
|
|
192
|
-
tryClaim(requested: AgentCandidateExecutionClaim): Promise<AgentCandidateExecutionClaimResult>;
|
|
193
|
-
getAttempt(requestedAttempt: AgentCandidateExecutionAttemptRef): Promise<AgentCandidateExecutionAttemptRecord | undefined>;
|
|
194
|
-
markCandidateMayRun(requestedLease: AgentCandidateExecutionLease): Promise<AgentCandidateExecutionPhaseResult>;
|
|
195
|
-
stageTerminal(requestedLease: AgentCandidateExecutionLease, result: AgentCandidateExecutionTerminalResult): Promise<AgentCandidateExecutionStageResult>;
|
|
196
|
-
finish(requestedLease: AgentCandidateExecutionLease, requestedTerminalDigest: Sha256Digest): Promise<AgentCandidateExecutionFinishResult>;
|
|
197
|
-
recoverExpired(requestedAttempt: AgentCandidateExecutionAttemptRef, evidence: AgentCandidateExecutionRecoveryEvidence): Promise<AgentCandidateExecutionFinishResult>;
|
|
198
|
-
private requireClaim;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
interface ExecutePreparedAgentCandidateOptions {
|
|
202
|
-
executor: AgentCandidateExecutorPort;
|
|
203
|
-
grader: AgentCandidateBenchmarkGraderPort;
|
|
204
|
-
outputArtifacts: AgentCandidateOutputArtifactPort;
|
|
205
|
-
traceStore: TraceStore;
|
|
206
|
-
/** Long-lived evaluator-owned store shared by every process that can run this benchmark. */
|
|
207
|
-
claimStore: AgentCandidateExecutionClaimStore;
|
|
208
|
-
/** Maximum time to prove process death and revoke protected access after a run ends. */
|
|
209
|
-
cleanupTimeoutMs?: number;
|
|
210
|
-
/** Maximum time for task verification, executable grading, and receipt construction. */
|
|
211
|
-
resultTimeoutMs?: number;
|
|
212
|
-
}
|
|
213
|
-
/** Executes and finalizes one durably claimed candidate without exposing an unproven result. */
|
|
214
|
-
declare function executePreparedAgentCandidate(prepared: PreparedAgentCandidateExecution, options: ExecutePreparedAgentCandidateOptions): Promise<AgentCandidateRunFinalization>;
|
|
215
|
-
|
|
216
|
-
interface PrepareAgentCandidateExecutionOptions {
|
|
217
|
-
cleanupTimeoutMs?: number;
|
|
218
|
-
/** Maximum time for task verification, executable grading, and receipt construction. */
|
|
219
|
-
resultTimeoutMs?: number;
|
|
220
|
-
}
|
|
221
|
-
/** Materializes a verified candidate into one immutable evaluator-owned execution plan. */
|
|
222
|
-
declare function prepareAgentCandidateExecution(candidate: VerifiedAgentCandidate, task: AgentCandidateTaskExecution, ports: AgentCandidateExecutionPorts, options?: PrepareAgentCandidateExecutionOptions): Promise<PreparedAgentCandidateExecution>;
|
|
223
|
-
|
|
224
|
-
/** Parse and check every native file hash plus both canonical document digests. */
|
|
225
|
-
declare function parseAgentCandidateProfileActivation(input: unknown, expectedProfilePlanDigest?: AgentCandidateProfilePlanEvidence['digest']): AgentCandidateProfileActivation;
|
|
226
|
-
/** Prove the measured generic profile and sealed candidate profile describe the same behavior. */
|
|
227
|
-
declare function assertCandidateProfileBinding(measuredInput: AgentProfile, bundled: AgentCandidateProfile): void;
|
|
228
|
-
/** Parse a complete profile without silently discarding unsupported fields. */
|
|
229
|
-
declare function parseExactAgentProfile(input: unknown, label: string): AgentProfile;
|
|
230
|
-
/** Parse a profile diff without silently discarding unsupported fields. */
|
|
231
|
-
declare function parseExactAgentProfileDiff(input: unknown, label: string): AgentProfileDiff;
|
|
232
|
-
/** Apply one exact diff and reject any value that cannot be preserved canonically. */
|
|
233
|
-
declare function applyExactAgentProfileDiff(baseInput: unknown, diffInput: unknown, label: string): AgentProfile;
|
|
234
|
-
|
|
235
|
-
type AgentCandidateModelGrantReserveInput = Parameters<AgentCandidateModelPort['reserveGrant']>[0];
|
|
236
|
-
type AgentCandidateModelGrantActivateInput = Parameters<AgentCandidateModelPort['activateGrant']>[0];
|
|
237
|
-
type AgentCandidateModelGrantSettleInput = Parameters<AgentCandidateModelPort['settleGrant']>[0];
|
|
238
|
-
/** Secret-free response from the service's reservation endpoint. */
|
|
239
|
-
type AgentCandidateModelGrantReservation = AgentCandidateProtectedModelReservation;
|
|
240
|
-
/**
|
|
241
|
-
* Narrow transport contract for a service that owns scoped model credentials
|
|
242
|
-
* and the authoritative per-call usage ledger.
|
|
243
|
-
*
|
|
244
|
-
* An HTTP client can bind these methods to control-plane endpoints. Keeping
|
|
245
|
-
* transport out of the runtime prevents parent credentials, endpoint paths,
|
|
246
|
-
* and retry policy from becoming part of the portable candidate contract.
|
|
247
|
-
*/
|
|
248
|
-
interface AgentCandidateModelGrantClient {
|
|
249
|
-
reserve(input: AgentCandidateModelGrantReserveInput): Promise<AgentCandidateModelGrantReservation>;
|
|
250
|
-
activate(input: AgentCandidateModelGrantActivateInput): Promise<AgentCandidateProtectedModelActivation>;
|
|
251
|
-
settle(input: AgentCandidateModelGrantSettleInput): Promise<AgentCandidateProtectedModelSettlement>;
|
|
252
|
-
}
|
|
253
|
-
interface CreateProtectedAgentCandidateModelPortOptions {
|
|
254
|
-
client: AgentCandidateModelGrantClient;
|
|
255
|
-
/** Catalog/snapshot resolution stays separate from credential issuance. */
|
|
256
|
-
resolveModel: AgentCandidateModelPort['resolve'];
|
|
257
|
-
/** The only public DNS name candidate processes may reach for inference. */
|
|
258
|
-
gatewayDomain: string;
|
|
259
|
-
/** Exact environment names the activation endpoint must return, no more or fewer. */
|
|
260
|
-
activationEnvNames: readonly string[];
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Bind a protected model-grant service to the immutable candidate runtime.
|
|
264
|
-
*
|
|
265
|
-
* The service remains the authority for expiry, admission, revocation, and
|
|
266
|
-
* metering. This adapter independently checks every response before allowing
|
|
267
|
-
* it to cross into candidate execution or durable receipt finalization.
|
|
268
|
-
*/
|
|
269
|
-
declare function createProtectedAgentCandidateModelPort(options: CreateProtectedAgentCandidateModelPortOptions): AgentCandidateModelPort;
|
|
270
|
-
|
|
271
|
-
export { type AgentCandidateExecutionClaimStore as A, parseExactAgentProfile as B, type CreateProtectedAgentCandidateModelPortOptions as C, parseExactAgentProfileDiff as D, type ExecutePreparedAgentCandidateOptions as E, prepareAgentCandidateExecution as F, InMemoryAgentCandidateExecutionClaimStore as I, type PrepareAgentCandidateExecutionOptions as P, type AgentCandidateExecutionAttemptRecord as a, type AgentCandidateExecutionAttemptRef as b, type AgentCandidateExecutionClaim as c, type AgentCandidateExecutionClaimResult as d, type AgentCandidateExecutionCleanupHandles as e, type AgentCandidateExecutionFailureClass as f, type AgentCandidateExecutionFinishResult as g, type AgentCandidateExecutionLease as h, type AgentCandidateExecutionPhase as i, type AgentCandidateExecutionPhaseResult as j, type AgentCandidateExecutionRecoveryEvidence as k, type AgentCandidateExecutionStageResult as l, type AgentCandidateExecutionTerminalRecord as m, type AgentCandidateExecutionTerminalResult as n, type AgentCandidateModelGrantActivateInput as o, parseAgentCandidateProfileActivation as p, type AgentCandidateModelGrantClient as q, type AgentCandidateModelGrantReservation as r, type AgentCandidateModelGrantReserveInput as s, type AgentCandidateModelGrantSettleInput as t, type AgentCandidatePreparationEvidence as u, type AgentCandidateRetryRejection as v, applyExactAgentProfileDiff as w, assertCandidateProfileBinding as x, createProtectedAgentCandidateModelPort as y, executePreparedAgentCandidate as z };
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { ControlEvalResult, KnowledgeReadinessReport, KnowledgeRequirement } from '@tangle-network/agent-eval';
|
|
2
|
-
import { e as AgentRuntimeEvent, R as RuntimeStreamEvent, f as AgentTaskStatus } from './types-BwoZWq-i.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The one router chat client: direct OpenAI-compatible completions through the
|
|
6
|
-
* Tangle router — the cheapest dial, no sandbox. Three layers: `routerChatWithUsage`
|
|
7
|
-
* (chat-only), `routerChatWithTools` (one completion with function tools), and
|
|
8
|
-
* `routerToolLoop` (the off-box agentic loop over tool-calling). Shared by the
|
|
9
|
-
* built-in executors and the bench/lab harnesses.
|
|
10
|
-
*
|
|
11
|
-
* Reports REAL token usage so the backend-integrity guard sees a real backend.
|
|
12
|
-
* Returns `undefined` usage when the provider omitted it — never a fabricated 0
|
|
13
|
-
* (a phantom 0 reads as a free call downstream, which the gate would act on).
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
interface RouterConfig {
|
|
17
|
-
routerBaseUrl: string;
|
|
18
|
-
routerKey: string;
|
|
19
|
-
model: string;
|
|
20
|
-
/**
|
|
21
|
-
* Optional completion transport. When set, `routerChatWithUsage` / `routerChatWithTools` call it
|
|
22
|
-
* with the OpenAI-shape request body and use the parsed `/chat/completions` JSON it returns,
|
|
23
|
-
* INSTEAD of `fetch(routerBaseUrl + '/chat/completions')`. When absent the fetch path runs
|
|
24
|
-
* unchanged — the live router stays the default. The injection seam an offline benchmark uses to
|
|
25
|
-
* drive the worker with no network: a deterministic in-process responder satisfies it, no server.
|
|
26
|
-
*/
|
|
27
|
-
complete?: (body: Record<string, unknown>) => Promise<unknown>;
|
|
28
|
-
}
|
|
29
|
-
interface RouterChatResult {
|
|
30
|
-
/** The final answer, with any inline `<think>...</think>` block stripped into `reasoning`. */
|
|
31
|
-
content: string;
|
|
32
|
-
/**
|
|
33
|
-
* Thinking-model reasoning, when the provider surfaced it — either as a separate
|
|
34
|
-
* `reasoning`/`reasoning_content` message field (OpenRouter style) or inlined into
|
|
35
|
-
* `content` as a `<think>` block (Groq style). Undefined for non-thinking models.
|
|
36
|
-
* Downstream parsers that match single-token answers must read `content`, which is
|
|
37
|
-
* clean either way; before this split, Groq-style inlining made the same model look
|
|
38
|
-
* broken on one provider and fine on another.
|
|
39
|
-
*/
|
|
40
|
-
reasoning?: string;
|
|
41
|
-
/** REAL usage, or undefined when the provider reported none. */
|
|
42
|
-
usage?: {
|
|
43
|
-
input: number;
|
|
44
|
-
output: number;
|
|
45
|
-
};
|
|
46
|
-
/** Derived from usage via `estimateCost` when the model is priced; else undefined. */
|
|
47
|
-
costUsd?: number;
|
|
48
|
-
}
|
|
49
|
-
/** One OpenAI-compatible chat completion through the Tangle router, returning text + REAL token usage (`undefined` when the provider omits it — never a fabricated 0). */
|
|
50
|
-
declare function routerChatWithUsage(cfg: RouterConfig, messages: Array<{
|
|
51
|
-
role: string;
|
|
52
|
-
content: string;
|
|
53
|
-
}>, opts?: {
|
|
54
|
-
temperature?: number;
|
|
55
|
-
signal?: AbortSignal;
|
|
56
|
-
maxTokens?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Reasoning control for thinking models, forwarded as `reasoning_effort`.
|
|
59
|
-
* 'none' is the load-bearing value: binary/single-token decisions (routing,
|
|
60
|
-
* gating) on a thinking model otherwise burn the whole token budget inside
|
|
61
|
-
* the think block — on slow backends (CPU-local) that turns into a client
|
|
62
|
-
* timeout, not just waste. Providers that ignore the field are handled by
|
|
63
|
-
* the reasoning/content split in `parseChatResult`.
|
|
64
|
-
*/
|
|
65
|
-
reasoningEffort?: 'none' | 'low' | 'medium' | 'high';
|
|
66
|
-
}): Promise<RouterChatResult>;
|
|
67
|
-
/** A tool-call the model emitted (provider-neutral; mirrors the runtime's ToolCallRequest). */
|
|
68
|
-
interface RouterToolCall {
|
|
69
|
-
id: string;
|
|
70
|
-
name: string;
|
|
71
|
-
/** Raw JSON arguments string as emitted by the model. */
|
|
72
|
-
arguments: string;
|
|
73
|
-
}
|
|
74
|
-
interface RouterChatToolsResult {
|
|
75
|
-
content: string | null;
|
|
76
|
-
toolCalls: RouterToolCall[];
|
|
77
|
-
usage?: {
|
|
78
|
-
input: number;
|
|
79
|
-
output: number;
|
|
80
|
-
};
|
|
81
|
-
costUsd?: number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* A router completion WITH tool-calling — the operator driver's LLM seam. Passes OpenAI-shape
|
|
85
|
-
* `messages` (system/user/assistant-with-tool_calls/tool roles) + function `tools`, and returns the
|
|
86
|
-
* assistant text plus the tool calls the model wants run. Same fail-loud + real-usage discipline as
|
|
87
|
-
* `routerChatWithUsage`. `tool_choice: 'auto'` lets the model decide; the driver loops on the result.
|
|
88
|
-
*/
|
|
89
|
-
declare function routerChatWithTools(cfg: RouterConfig, messages: ReadonlyArray<Record<string, unknown>>, tools: ReadonlyArray<{
|
|
90
|
-
type: 'function';
|
|
91
|
-
function: {
|
|
92
|
-
name: string;
|
|
93
|
-
description?: string;
|
|
94
|
-
parameters: unknown;
|
|
95
|
-
};
|
|
96
|
-
}>, opts?: {
|
|
97
|
-
temperature?: number;
|
|
98
|
-
signal?: AbortSignal;
|
|
99
|
-
toolChoice?: 'auto' | 'required' | 'none';
|
|
100
|
-
maxTokens?: number;
|
|
101
|
-
}): Promise<RouterChatToolsResult>;
|
|
102
|
-
interface ToolSpec {
|
|
103
|
-
type: 'function';
|
|
104
|
-
function: {
|
|
105
|
-
name: string;
|
|
106
|
-
description?: string;
|
|
107
|
-
parameters: unknown;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
interface RouterToolLoopResult {
|
|
111
|
-
/** The model's final assistant text (the turn where it stopped calling tools, or the budget turn). */
|
|
112
|
-
final: string;
|
|
113
|
-
/** Inference turns spent (≤ maxTurns) — the equal-budget unit vs random@k. */
|
|
114
|
-
turns: number;
|
|
115
|
-
toolCalls: number;
|
|
116
|
-
/** The behavior trace: each tool call + its result, in order. What a trace-analyst
|
|
117
|
-
* steerer reads (behavior, never the verdict) to diagnose + redirect the next shot. */
|
|
118
|
-
toolTrace: Array<{
|
|
119
|
-
name: string;
|
|
120
|
-
args: string;
|
|
121
|
-
result: string;
|
|
122
|
-
}>;
|
|
123
|
-
usage: {
|
|
124
|
-
input: number;
|
|
125
|
-
output: number;
|
|
126
|
-
};
|
|
127
|
-
/** The full conversation after the loop (seed + every assistant/tool turn). Lets a caller
|
|
128
|
-
* CARRY the messages into the next shot (depth continuation) and read the trajectory. */
|
|
129
|
-
messages: Array<Record<string, unknown>>;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* The tool-using router backend: a real agentic loop OVER the Tangle router (which
|
|
133
|
-
* supports tool-calling), off-box — no sandbox. Each turn is one router completion
|
|
134
|
-
* with `tools`; if the model emits tool_calls, `execute` runs them on the host and
|
|
135
|
-
* their results are folded back as `tool` messages; the loop repeats until the
|
|
136
|
-
* model answers without a tool call or the turn budget is hit. One turn = one
|
|
137
|
-
* inference call, so `maxTurns` is the equal-compute unit against random@k.
|
|
138
|
-
*
|
|
139
|
-
* This is the depth substrate for agentic gates (the worker ACTS, observes the real
|
|
140
|
-
* result, and continues) that the chat-only `routerChatWithUsage` cannot express.
|
|
141
|
-
*/
|
|
142
|
-
declare function routerToolLoop(cfg: RouterConfig, system: string, user: string, tools: ReadonlyArray<ToolSpec>, execute: (name: string, args: Record<string, unknown>) => Promise<string>, opts?: {
|
|
143
|
-
maxTurns?: number;
|
|
144
|
-
temperature?: number;
|
|
145
|
-
signal?: AbortSignal;
|
|
146
|
-
maxTokens?: number;
|
|
147
|
-
/** Seed the loop with an existing conversation (depth continuation) instead of
|
|
148
|
-
* `[system, user]`. When set, `system`/`user` are ignored. The array is copied. */
|
|
149
|
-
initialMessages?: ReadonlyArray<Record<string, unknown>>;
|
|
150
|
-
}): Promise<RouterToolLoopResult>;
|
|
151
|
-
/**
|
|
152
|
-
* The router as a supervisor BRAIN: the canonical `ToolLoopChat` seam backed by the router's
|
|
153
|
-
* tool-calling. The driver's spawn/observe/steer/await/stop turns become real router tool-calls.
|
|
154
|
-
* The turnkey production brain — tests script a mock `ToolLoopChat`; production passes
|
|
155
|
-
* `routerBrain(cfg)`. No message translation: the loop already speaks the router's OpenAI shape.
|
|
156
|
-
*/
|
|
157
|
-
declare function routerBrain(cfg: RouterConfig, opts?: {
|
|
158
|
-
temperature?: number;
|
|
159
|
-
}): ToolLoopChat;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* THE canonical agentic tool-loop. One inference turn → run any requested tools → fold the
|
|
163
|
-
* results back as `tool` messages → repeat, until the model answers without a tool call or the
|
|
164
|
-
* turn budget is hit. One turn = one inference call (the equal-compute unit vs random@k).
|
|
165
|
-
*
|
|
166
|
-
* The inference is an INJECTABLE seam (`ToolLoopChat`): a router model, a sandboxed CLI
|
|
167
|
-
* harness, or a scripted mock all satisfy it — so the loop is backend-agnostic. The metered /
|
|
168
|
-
* steerable concerns the call sites add (a driver's conserved-pool + deadline bound; an inline
|
|
169
|
-
* executor's inbox flush + abort) attach via optional `hooks`; the skeleton stays one copy.
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
type Msg = Record<string, unknown>;
|
|
173
|
-
/** One inference turn over the running conversation + the tool specs → the model's text, any
|
|
174
|
-
* tool calls, and token usage. The seam every brain satisfies. */
|
|
175
|
-
type ToolLoopChat = (messages: ReadonlyArray<Msg>, tools: ReadonlyArray<ToolSpec>) => Promise<{
|
|
176
|
-
content?: string | null;
|
|
177
|
-
toolCalls: RouterToolCall[];
|
|
178
|
-
usage?: {
|
|
179
|
-
input: number;
|
|
180
|
-
output: number;
|
|
181
|
-
};
|
|
182
|
-
/** The turn's inference cost (usd) when the provider priced it — for callers that meter usd
|
|
183
|
-
* into a conserved pool (the supervisor brain). `runBrainLoop` itself ignores it. */
|
|
184
|
-
costUsd?: number;
|
|
185
|
-
}>;
|
|
186
|
-
/** Self-compaction — bound the loop's OWN context window the way a fresh-respawn (dumb-Ralph) loop
|
|
187
|
-
* does, but in place. A stateless chat API re-sends the WHOLE running conversation every turn, so an
|
|
188
|
-
* agent that accumulates dozens of turns of tool results re-bills its entire transcript on every
|
|
189
|
-
* inference — the context-overflow-one-level-up that the conserved budget pool cannot fix. With
|
|
190
|
-
* compaction set, once the conversation exceeds `thresholdTokens` the accumulated middle (every prior
|
|
191
|
-
* assistant turn + tool result) is distilled into ONE compact progress note and the conversation is
|
|
192
|
-
* reset to `[...head, digest]`: the preserved head (system + the original task) survives, the stale
|
|
193
|
-
* turn-by-turn history does not. The model keeps deciding; it stops re-billing the whole transcript.
|
|
194
|
-
* Fires at a CLEAN turn boundary (after a turn's tool results are folded in, before the next
|
|
195
|
-
* inference) so it never orphans an assistant `tool_calls` from its `tool` replies. */
|
|
196
|
-
interface ToolLoopCompaction {
|
|
197
|
-
/** Compact once the estimated token count of the conversation exceeds this. */
|
|
198
|
-
readonly thresholdTokens: number;
|
|
199
|
-
/** Distill the conversation into a compact progress note that REPLACES the middle. Receives the
|
|
200
|
-
* full conversation (so it can summarize everything done so far); returns the digest string. */
|
|
201
|
-
readonly distill: (messages: ReadonlyArray<Msg>) => Promise<string> | string;
|
|
202
|
-
/** Leading messages preserved verbatim (system + the original task). Default 2. */
|
|
203
|
-
readonly preserveHead?: number;
|
|
204
|
-
/** Token estimator over the conversation. Default ≈ chars/4 (incl. tool-call arguments). */
|
|
205
|
-
readonly estimateTokens?: (messages: ReadonlyArray<Msg>) => number;
|
|
206
|
-
/** Notified each time a compaction fires — for observability/metering. */
|
|
207
|
-
readonly onCompact?: (info: {
|
|
208
|
-
turn: number;
|
|
209
|
-
beforeTokens: number;
|
|
210
|
-
afterTokens: number;
|
|
211
|
-
}) => void;
|
|
212
|
-
}
|
|
213
|
-
/** Public supervisor-facing compaction config: same knobs as the primitive, but `distill` is optional
|
|
214
|
-
* because the supervisor has a default digest that combines a brain note with live worker state. */
|
|
215
|
-
type ToolLoopCompactionOptions = Omit<ToolLoopCompaction, 'distill'> & {
|
|
216
|
-
readonly distill?: ToolLoopCompaction['distill'];
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
*
|
|
221
|
-
* Sanitization for runtime telemetry. The rule: nothing user-controlled leaks
|
|
222
|
-
* unless the caller opts in with a `RuntimeTelemetryOptions` flag. This is the
|
|
223
|
-
* envelope that ends up in `agent_run.metadata.runtimeEvents` on every
|
|
224
|
-
* consumer, so the default must be safe.
|
|
225
|
-
*
|
|
226
|
-
* @stable
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
/** @stable */
|
|
230
|
-
interface RuntimeTelemetryOptions {
|
|
231
|
-
/**
|
|
232
|
-
* Include raw task inputs. Off by default because task inputs often contain
|
|
233
|
-
* customer facts, credentials, source text, or internal IDs.
|
|
234
|
-
*/
|
|
235
|
-
includeInputs?: boolean;
|
|
236
|
-
/** Include requirement descriptions. Secret requirements are always redacted. */
|
|
237
|
-
includeRequirementDescriptions?: boolean;
|
|
238
|
-
/** Include evidence IDs. Off by default; counts are safer for shared reports. */
|
|
239
|
-
includeEvidenceIds?: boolean;
|
|
240
|
-
/** Include user answers from question preflight. Off by default. */
|
|
241
|
-
includeUserAnswers?: boolean;
|
|
242
|
-
/** Include action payloads and action results for control steps. Off by default. */
|
|
243
|
-
includeControlPayloads?: boolean;
|
|
244
|
-
/** Include task metadata. Off by default because metadata may carry IDs or policy internals. */
|
|
245
|
-
includeMetadata?: boolean;
|
|
246
|
-
/** Include eval detail/evidence strings. Off by default because validators may echo private input. */
|
|
247
|
-
includeEvalDetails?: boolean;
|
|
248
|
-
}
|
|
249
|
-
/** @stable */
|
|
250
|
-
interface SanitizedKnowledgeRequirement {
|
|
251
|
-
id: string;
|
|
252
|
-
description?: string;
|
|
253
|
-
requiredFor: string[];
|
|
254
|
-
category: KnowledgeRequirement['category'];
|
|
255
|
-
acquisitionMode: KnowledgeRequirement['acquisitionMode'];
|
|
256
|
-
importance: KnowledgeRequirement['importance'];
|
|
257
|
-
freshness: KnowledgeRequirement['freshness'];
|
|
258
|
-
sensitivity: KnowledgeRequirement['sensitivity'];
|
|
259
|
-
confidenceNeeded: number;
|
|
260
|
-
currentConfidence: number;
|
|
261
|
-
evidenceCount: number;
|
|
262
|
-
evidenceIds?: string[];
|
|
263
|
-
fallbackPolicy: KnowledgeRequirement['fallbackPolicy'];
|
|
264
|
-
}
|
|
265
|
-
/** @stable */
|
|
266
|
-
interface SanitizedKnowledgeReadinessReport {
|
|
267
|
-
taskId: string;
|
|
268
|
-
readinessScore: number;
|
|
269
|
-
recommendedAction: KnowledgeReadinessReport['recommendedAction'];
|
|
270
|
-
severity: KnowledgeReadinessReport['severity'];
|
|
271
|
-
reason: string;
|
|
272
|
-
blockingMissingRequirements: SanitizedKnowledgeRequirement[];
|
|
273
|
-
nonBlockingGaps: SanitizedKnowledgeRequirement[];
|
|
274
|
-
evidenceCount: number;
|
|
275
|
-
evidenceIds?: string[];
|
|
276
|
-
missingRequirementIds: string[];
|
|
277
|
-
}
|
|
278
|
-
/** Strip PII and large blobs from a `KnowledgeReadinessReport` for safe telemetry emission. @stable */
|
|
279
|
-
declare function sanitizeKnowledgeReadinessReport(report: KnowledgeReadinessReport, options?: RuntimeTelemetryOptions): SanitizedKnowledgeReadinessReport;
|
|
280
|
-
/** Reduce an `AgentRuntimeEvent` to a PII-safe, serializable plain object for telemetry. @stable */
|
|
281
|
-
declare function sanitizeAgentRuntimeEvent<TState, TAction, TActionResult, TEval extends ControlEvalResult>(event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>, options?: RuntimeTelemetryOptions): Record<string, unknown>;
|
|
282
|
-
/** Reduce a `RuntimeStreamEvent` to a PII-safe, serializable plain object for telemetry. @stable */
|
|
283
|
-
declare function sanitizeRuntimeStreamEvent(event: RuntimeStreamEvent, options?: RuntimeTelemetryOptions): Record<string, unknown>;
|
|
284
|
-
/** @stable */
|
|
285
|
-
interface RuntimeEventCollector<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
286
|
-
onEvent: (event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>) => void;
|
|
287
|
-
events: Array<Record<string, unknown>>;
|
|
288
|
-
}
|
|
289
|
-
/** @stable */
|
|
290
|
-
type RuntimeStreamEventSink = (event: RuntimeStreamEvent) => void;
|
|
291
|
-
/** @stable */
|
|
292
|
-
interface RuntimeStreamEventSummary {
|
|
293
|
-
/** Total count of sanitized events collected. */
|
|
294
|
-
eventCount: number;
|
|
295
|
-
/** Count of events per `type`. Useful for log-line summaries. */
|
|
296
|
-
eventCountsByType: Record<string, number>;
|
|
297
|
-
/** First session id observed in a `session_created` / `session_resumed` event, if any. */
|
|
298
|
-
firstSessionId?: string;
|
|
299
|
-
/** Last `final` event's status, if a final event was observed. */
|
|
300
|
-
finalStatus?: AgentTaskStatus;
|
|
301
|
-
/** Last `final` event's reason, if a final event was observed. */
|
|
302
|
-
finalReason?: string;
|
|
303
|
-
/** Concatenated `text_delta.text` across the stream, even when payloads are redacted. */
|
|
304
|
-
finalText: string;
|
|
305
|
-
}
|
|
306
|
-
/** @stable */
|
|
307
|
-
interface RuntimeStreamEventCollector {
|
|
308
|
-
onEvent: RuntimeStreamEventSink;
|
|
309
|
-
events: Array<Record<string, unknown>>;
|
|
310
|
-
/** Snapshot of a small streaming-flavored summary derived from collected events. */
|
|
311
|
-
summary(): RuntimeStreamEventSummary;
|
|
312
|
-
}
|
|
313
|
-
/** Build an in-memory collector that sanitizes and accumulates `AgentRuntimeEvent`s for inspection. @stable */
|
|
314
|
-
declare function createRuntimeEventCollector<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult>(options?: RuntimeTelemetryOptions): RuntimeEventCollector<TState, TAction, TActionResult, TEval>;
|
|
315
|
-
/**
|
|
316
|
-
*
|
|
317
|
-
* Streaming-event counterpart of `createRuntimeEventCollector`. Pass each
|
|
318
|
-
* event yielded by `runAgentTaskStream` through `onEvent` and read the
|
|
319
|
-
* sanitized copies off `events`; the same `RuntimeTelemetryOptions` redaction
|
|
320
|
-
* flags apply. Kept distinct from `createRuntimeEventCollector` because the
|
|
321
|
-
* stream and non-stream event shapes overlap on `type` literals — dispatching
|
|
322
|
-
* on `type` alone would misroute events.
|
|
323
|
-
*
|
|
324
|
-
* @stable
|
|
325
|
-
*/
|
|
326
|
-
declare function createRuntimeStreamEventCollector(options?: RuntimeTelemetryOptions): RuntimeStreamEventCollector;
|
|
327
|
-
|
|
328
|
-
export { type RouterConfig as R, type SanitizedKnowledgeReadinessReport as S, type ToolLoopChat as T, type ToolLoopCompactionOptions as a, type ToolSpec as b, type RuntimeTelemetryOptions as c, type RuntimeEventCollector as d, type RuntimeStreamEventCollector as e, createRuntimeEventCollector as f, createRuntimeStreamEventCollector as g, sanitizeKnowledgeReadinessReport as h, sanitizeRuntimeStreamEvent as i, type RouterChatResult as j, type RouterChatToolsResult as k, type RouterToolCall as l, type RouterToolLoopResult as m, type ToolLoopCompaction as n, routerChatWithTools as o, routerChatWithUsage as p, routerToolLoop as q, routerBrain as r, sanitizeAgentRuntimeEvent as s };
|