@tangle-network/agent-runtime 0.105.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 +2 -2
- 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 -1058
- package/dist/index.js +2106 -2082
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +768 -889
- package/dist/intelligence.js +1466 -1367
- 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 -15
- 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 -436
- 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 +149 -145
- package/dist/primeintellect/index.js +626 -1003
- 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 -56
- package/skills/build-with-agent-runtime/SKILL.md +1 -0
- 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-2VZYRB55.js +0 -834
- package/dist/chunk-2VZYRB55.js.map +0 -1
- package/dist/chunk-3MDZX7YU.js +0 -125
- package/dist/chunk-3MDZX7YU.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-C5RTIBNZ.js +0 -48
- package/dist/chunk-C5RTIBNZ.js.map +0 -1
- package/dist/chunk-CTRA64LY.js +0 -680
- package/dist/chunk-CTRA64LY.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-H5QPIZNX.js +0 -907
- package/dist/chunk-H5QPIZNX.js.map +0 -1
- package/dist/chunk-HLKC4UYB.js +0 -3514
- package/dist/chunk-HLKC4UYB.js.map +0 -1
- package/dist/chunk-HNP72PNU.js +0 -192
- package/dist/chunk-HNP72PNU.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-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-OPVWXJ2H.js +0 -75
- package/dist/chunk-OPVWXJ2H.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-RDOAVVHY.js +0 -699
- package/dist/chunk-RDOAVVHY.js.map +0 -1
- package/dist/chunk-SGKPNBXE.js +0 -60
- package/dist/chunk-SGKPNBXE.js.map +0 -1
- package/dist/chunk-SMQXZGLZ.js +0 -351
- package/dist/chunk-SMQXZGLZ.js.map +0 -1
- package/dist/chunk-UHEZW5BU.js +0 -2918
- package/dist/chunk-UHEZW5BU.js.map +0 -1
- package/dist/chunk-UPWGXKXB.js +0 -254
- package/dist/chunk-UPWGXKXB.js.map +0 -1
- package/dist/chunk-VISA6CI3.js +0 -200
- package/dist/chunk-VISA6CI3.js.map +0 -1
- package/dist/chunk-WMTCUOQL.js +0 -474
- package/dist/chunk-WMTCUOQL.js.map +0 -1
- package/dist/chunk-WRTOVNN4.js +0 -4728
- package/dist/chunk-WRTOVNN4.js.map +0 -1
- package/dist/chunk-WSTRQZYQ.js +0 -5576
- package/dist/chunk-WSTRQZYQ.js.map +0 -1
- package/dist/chunk-XBG2W2VW.js +0 -6434
- package/dist/chunk-XBG2W2VW.js.map +0 -1
- package/dist/chunk-YEJR7IXO.js +0 -68
- package/dist/chunk-YEJR7IXO.js.map +0 -1
- package/dist/chunk-YJZA2BIK.js +0 -1338
- package/dist/chunk-YJZA2BIK.js.map +0 -1
- package/dist/completion-gate-BMy5LGoP.d.ts +0 -256
- package/dist/conversation.js.map +0 -1
- package/dist/coordination-BZZSVYpZ.d.ts +0 -2570
- package/dist/environment-provider.js.map +0 -1
- package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
- package/dist/knowledge.js.map +0 -1
- package/dist/local-harness-BDNcl6jI.d.ts +0 -175
- package/dist/loop-runner-bin-68aoM9-7.d.ts +0 -199
- 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-B4t-OQjL.d.ts +0 -271
- package/dist/redact-BuFjxBUJ.d.ts +0 -481
- package/dist/sanitize-DEbPNtyI.d.ts +0 -328
- package/dist/structural-rollout-DEh6CEsa.d.ts +0 -446
- package/dist/supervise-4_48wwvy.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-DxhAWr5Z.d.ts +0 -999
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { ControlBudget, ControlDecision, ControlEvalResult, ControlRunResult, ControlStep, DataAcquisitionPlan, KnowledgeReadinessReport, KnowledgeRequirement, RunRecord, TraceStore, UserQuestion } from "@tangle-network/agent-eval";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
/** @stable */
|
|
4
|
+
interface AgentTaskSpec {
|
|
5
|
+
id: string;
|
|
6
|
+
intent: string;
|
|
7
|
+
/** Domain is metadata, not an architectural boundary: tax, legal, gtm, creative, blueprint, redteam, etc. */
|
|
8
|
+
domain?: string;
|
|
9
|
+
inputs?: Record<string, unknown>;
|
|
10
|
+
requiredKnowledge?: KnowledgeRequirement[];
|
|
11
|
+
budget?: Partial<ControlBudget>;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** @stable */
|
|
15
|
+
interface AgentKnowledgeProvider {
|
|
16
|
+
buildReadiness?(task: AgentTaskSpec): Promise<KnowledgeReadinessReport> | KnowledgeReadinessReport;
|
|
17
|
+
answerQuestions?(questions: UserQuestion[], task: AgentTaskSpec): Promise<Record<string, string>> | Record<string, string>;
|
|
18
|
+
executeAcquisitionPlans?(plans: DataAcquisitionPlan[], task: AgentTaskSpec): Promise<string[]> | string[];
|
|
19
|
+
refreshReadiness?(input: {
|
|
20
|
+
task: AgentTaskSpec;
|
|
21
|
+
previous: KnowledgeReadinessReport;
|
|
22
|
+
userAnswers: Record<string, string>;
|
|
23
|
+
acquiredEvidenceIds: string[];
|
|
24
|
+
}): Promise<KnowledgeReadinessReport> | KnowledgeReadinessReport;
|
|
25
|
+
}
|
|
26
|
+
/** @stable */
|
|
27
|
+
interface AgentTaskContext<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
28
|
+
task: AgentTaskSpec;
|
|
29
|
+
knowledge: KnowledgeReadinessReport;
|
|
30
|
+
state: TState;
|
|
31
|
+
evals: TEval[];
|
|
32
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
33
|
+
budget: ControlBudget;
|
|
34
|
+
stepIndex: number;
|
|
35
|
+
wallMs: number;
|
|
36
|
+
spentCostUsd: number;
|
|
37
|
+
remainingCostUsd?: number;
|
|
38
|
+
abortSignal: AbortSignal;
|
|
39
|
+
}
|
|
40
|
+
/** @stable */
|
|
41
|
+
interface AgentAdapter<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
42
|
+
observe(ctx: {
|
|
43
|
+
task: AgentTaskSpec;
|
|
44
|
+
knowledge: KnowledgeReadinessReport;
|
|
45
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
46
|
+
abortSignal: AbortSignal;
|
|
47
|
+
}): Promise<TState> | TState;
|
|
48
|
+
validate(ctx: {
|
|
49
|
+
task: AgentTaskSpec;
|
|
50
|
+
knowledge: KnowledgeReadinessReport;
|
|
51
|
+
state: TState;
|
|
52
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
53
|
+
abortSignal: AbortSignal;
|
|
54
|
+
}): Promise<TEval[]> | TEval[];
|
|
55
|
+
decide(ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
|
|
56
|
+
act(action: TAction, ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<TActionResult> | TActionResult;
|
|
57
|
+
shouldStop?(ctx: AgentTaskContext<TState, TAction, TActionResult, TEval>): Promise<{
|
|
58
|
+
stop: boolean;
|
|
59
|
+
pass: boolean;
|
|
60
|
+
reason: string;
|
|
61
|
+
score?: number;
|
|
62
|
+
}> | {
|
|
63
|
+
stop: boolean;
|
|
64
|
+
pass: boolean;
|
|
65
|
+
reason: string;
|
|
66
|
+
score?: number;
|
|
67
|
+
};
|
|
68
|
+
onKnowledgeBlocked?(ctx: {
|
|
69
|
+
task: AgentTaskSpec;
|
|
70
|
+
knowledge: KnowledgeReadinessReport;
|
|
71
|
+
questions: UserQuestion[];
|
|
72
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
73
|
+
}): Promise<ControlDecision<TAction>> | ControlDecision<TAction>;
|
|
74
|
+
getActionCostUsd?(ctx: {
|
|
75
|
+
action: TAction;
|
|
76
|
+
result: TActionResult;
|
|
77
|
+
task: AgentTaskSpec;
|
|
78
|
+
state: TState;
|
|
79
|
+
evals: TEval[];
|
|
80
|
+
history: ControlStep<TState, TAction, TActionResult, TEval>[];
|
|
81
|
+
}): number | undefined;
|
|
82
|
+
projectRunRecords?(result: ControlRunResult<TState, TAction, TActionResult, TEval>, task: AgentTaskSpec): RunRecord[];
|
|
83
|
+
}
|
|
84
|
+
/** @stable */
|
|
85
|
+
type AgentTaskStatus = 'completed' | 'blocked' | 'failed' | 'aborted';
|
|
86
|
+
/** @stable */
|
|
87
|
+
type AgentRuntimeEvent<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> = {
|
|
88
|
+
type: 'task_start';
|
|
89
|
+
task: AgentTaskSpec;
|
|
90
|
+
} | {
|
|
91
|
+
type: 'readiness_start';
|
|
92
|
+
task: AgentTaskSpec;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'readiness_end';
|
|
95
|
+
task: AgentTaskSpec;
|
|
96
|
+
knowledge: KnowledgeReadinessReport;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'questions_start';
|
|
99
|
+
task: AgentTaskSpec;
|
|
100
|
+
questions: UserQuestion[];
|
|
101
|
+
} | {
|
|
102
|
+
type: 'questions_end';
|
|
103
|
+
task: AgentTaskSpec;
|
|
104
|
+
questions: UserQuestion[];
|
|
105
|
+
userAnswers: Record<string, string>;
|
|
106
|
+
} | {
|
|
107
|
+
type: 'acquisition_start';
|
|
108
|
+
task: AgentTaskSpec;
|
|
109
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
110
|
+
} | {
|
|
111
|
+
type: 'acquisition_end';
|
|
112
|
+
task: AgentTaskSpec;
|
|
113
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
114
|
+
acquiredEvidenceIds: string[];
|
|
115
|
+
} | {
|
|
116
|
+
type: 'control_start';
|
|
117
|
+
task: AgentTaskSpec;
|
|
118
|
+
knowledge: KnowledgeReadinessReport;
|
|
119
|
+
} | {
|
|
120
|
+
type: 'control_step';
|
|
121
|
+
task: AgentTaskSpec;
|
|
122
|
+
step: ControlStep<TState, TAction, TActionResult, TEval>;
|
|
123
|
+
} | {
|
|
124
|
+
type: 'control_end';
|
|
125
|
+
task: AgentTaskSpec;
|
|
126
|
+
control: ControlRunResult<TState, TAction, TActionResult, TEval>;
|
|
127
|
+
} | {
|
|
128
|
+
type: 'task_end';
|
|
129
|
+
task: AgentTaskSpec;
|
|
130
|
+
status: AgentTaskStatus;
|
|
131
|
+
reason: string;
|
|
132
|
+
};
|
|
133
|
+
/** @stable */
|
|
134
|
+
type AgentRuntimeEventSink<TState = unknown, TAction = unknown, TActionResult = unknown, TEval extends ControlEvalResult = ControlEvalResult> = (event: AgentRuntimeEvent<TState, TAction, TActionResult, TEval>) => Promise<void> | void;
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* Typed transport / backend failure detail. Carried on `backend_error` and
|
|
138
|
+
* `final` events when the backend's stream throws or the upstream HTTP call
|
|
139
|
+
* returns a non-success status. Lets consumers (a) distinguish "stream
|
|
140
|
+
* completed with no text" from "stream never reached the model" and
|
|
141
|
+
* (b) reconstruct the precise upstream signal (status + truncated body) when
|
|
142
|
+
* building a `RunRecord.error`.
|
|
143
|
+
*
|
|
144
|
+
* `body` is truncated to 2 KiB by the backend so an HTML error page from a
|
|
145
|
+
* misconfigured proxy never bloats event payloads or logs. Consumers needing
|
|
146
|
+
* the full body should inspect the underlying `BackendTransportError.body`
|
|
147
|
+
* via a custom `mapEvent` or backend wrapper.
|
|
148
|
+
*
|
|
149
|
+
* @stable
|
|
150
|
+
*/
|
|
151
|
+
interface BackendErrorDetail {
|
|
152
|
+
/**
|
|
153
|
+
* `'transport'` — upstream HTTP / network failure with optional status code.
|
|
154
|
+
* `'backend'` — the backend's `stream()` generator threw for a non-transport
|
|
155
|
+
* reason (e.g. a custom adapter error, sandbox crash).
|
|
156
|
+
*/
|
|
157
|
+
kind: 'transport' | 'backend';
|
|
158
|
+
message: string;
|
|
159
|
+
/** Upstream HTTP status when known. `0` for connection / abort errors. */
|
|
160
|
+
status?: number;
|
|
161
|
+
/** Truncated response body (≤2 KiB). Diagnostic only — never machine-parsed. */
|
|
162
|
+
body?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
*
|
|
166
|
+
* OpenAI Chat Completions tool descriptor. The shape mirrors the
|
|
167
|
+
* `/v1/chat/completions` `tools[]` parameter so callers can pass tool
|
|
168
|
+
* definitions through `createOpenAICompatibleBackend({ tools })` without any
|
|
169
|
+
* runtime translation. The router proxies this shape verbatim to Anthropic
|
|
170
|
+
* (translated server-side), DeepSeek, Groq, OpenAI, and Gemini — every model
|
|
171
|
+
* that the eval surface targets.
|
|
172
|
+
*
|
|
173
|
+
* Callers that build their tool list from MCP servers should run a one-shot
|
|
174
|
+
* MCP `tools/list` at config time and project the result into this shape. The
|
|
175
|
+
* runtime intentionally does NOT depend on `@modelcontextprotocol/sdk` —
|
|
176
|
+
* keeping the backend transport thin lets domain repos own MCP plumbing.
|
|
177
|
+
*
|
|
178
|
+
* @stable
|
|
179
|
+
*/
|
|
180
|
+
interface OpenAIChatTool {
|
|
181
|
+
type: 'function';
|
|
182
|
+
function: {
|
|
183
|
+
name: string;
|
|
184
|
+
description?: string;
|
|
185
|
+
parameters?: Record<string, unknown>;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* `tool_choice` parameter for OpenAI-compat chat. Same shape as the OpenAI
|
|
191
|
+
* spec: `'auto'` (default — model decides), `'none'` (disable tool calling
|
|
192
|
+
* for this turn), `'required'` (force a tool call), or a specific function
|
|
193
|
+
* pin `{ type: 'function', function: { name } }`.
|
|
194
|
+
*
|
|
195
|
+
* @stable
|
|
196
|
+
*/
|
|
197
|
+
type OpenAIChatToolChoice = 'auto' | 'none' | 'required' | {
|
|
198
|
+
type: 'function';
|
|
199
|
+
function: {
|
|
200
|
+
name: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
*
|
|
205
|
+
* `response_format` parameter for OpenAI-compatible chat endpoints. Use
|
|
206
|
+
* `json_object` when the caller needs syntactically valid JSON, or
|
|
207
|
+
* `json_schema` when the upstream provider supports schema-constrained JSON.
|
|
208
|
+
*
|
|
209
|
+
* @stable
|
|
210
|
+
*/
|
|
211
|
+
type OpenAIChatResponseFormat = {
|
|
212
|
+
type: 'text';
|
|
213
|
+
} | {
|
|
214
|
+
type: 'json_object';
|
|
215
|
+
} | {
|
|
216
|
+
type: 'json_schema';
|
|
217
|
+
json_schema: Record<string, unknown>;
|
|
218
|
+
};
|
|
219
|
+
/** @stable */
|
|
220
|
+
type RuntimeStreamEvent = {
|
|
221
|
+
type: 'task_start';
|
|
222
|
+
task: AgentTaskSpec;
|
|
223
|
+
timestamp: string;
|
|
224
|
+
} | {
|
|
225
|
+
type: 'readiness_start';
|
|
226
|
+
task: AgentTaskSpec;
|
|
227
|
+
timestamp: string;
|
|
228
|
+
} | {
|
|
229
|
+
type: 'readiness_end';
|
|
230
|
+
task: AgentTaskSpec;
|
|
231
|
+
knowledge: KnowledgeReadinessReport;
|
|
232
|
+
decision: KnowledgeReadinessDecision;
|
|
233
|
+
timestamp: string;
|
|
234
|
+
} | {
|
|
235
|
+
type: 'questions_start';
|
|
236
|
+
task: AgentTaskSpec;
|
|
237
|
+
questions: UserQuestion[];
|
|
238
|
+
timestamp: string;
|
|
239
|
+
} | {
|
|
240
|
+
type: 'questions_end';
|
|
241
|
+
task: AgentTaskSpec;
|
|
242
|
+
questions: UserQuestion[];
|
|
243
|
+
userAnswers: Record<string, string>;
|
|
244
|
+
timestamp: string;
|
|
245
|
+
} | {
|
|
246
|
+
type: 'acquisition_start';
|
|
247
|
+
task: AgentTaskSpec;
|
|
248
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
249
|
+
timestamp: string;
|
|
250
|
+
} | {
|
|
251
|
+
type: 'acquisition_end';
|
|
252
|
+
task: AgentTaskSpec;
|
|
253
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
254
|
+
acquiredEvidenceIds: string[];
|
|
255
|
+
timestamp: string;
|
|
256
|
+
} | {
|
|
257
|
+
type: 'session_created';
|
|
258
|
+
task: AgentTaskSpec;
|
|
259
|
+
session: RuntimeSession;
|
|
260
|
+
timestamp: string;
|
|
261
|
+
} | {
|
|
262
|
+
type: 'session_resumed';
|
|
263
|
+
task: AgentTaskSpec;
|
|
264
|
+
session: RuntimeSession;
|
|
265
|
+
timestamp: string;
|
|
266
|
+
} | {
|
|
267
|
+
type: 'backend_start';
|
|
268
|
+
task: AgentTaskSpec;
|
|
269
|
+
session: RuntimeSession;
|
|
270
|
+
backend: string;
|
|
271
|
+
timestamp: string;
|
|
272
|
+
} | {
|
|
273
|
+
type: 'text_delta';
|
|
274
|
+
task?: AgentTaskSpec;
|
|
275
|
+
session?: RuntimeSession;
|
|
276
|
+
text: string;
|
|
277
|
+
timestamp?: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: 'reasoning_delta';
|
|
280
|
+
task?: AgentTaskSpec;
|
|
281
|
+
session?: RuntimeSession;
|
|
282
|
+
text: string;
|
|
283
|
+
timestamp?: string;
|
|
284
|
+
} | {
|
|
285
|
+
type: 'tool_call';
|
|
286
|
+
task?: AgentTaskSpec;
|
|
287
|
+
session?: RuntimeSession;
|
|
288
|
+
toolName: string;
|
|
289
|
+
toolCallId?: string;
|
|
290
|
+
args?: unknown;
|
|
291
|
+
timestamp?: string;
|
|
292
|
+
} | {
|
|
293
|
+
type: 'tool_result';
|
|
294
|
+
task?: AgentTaskSpec;
|
|
295
|
+
session?: RuntimeSession;
|
|
296
|
+
toolName: string;
|
|
297
|
+
toolCallId?: string;
|
|
298
|
+
result?: unknown;
|
|
299
|
+
timestamp?: string;
|
|
300
|
+
} | {
|
|
301
|
+
type: 'llm_call';
|
|
302
|
+
task?: AgentTaskSpec;
|
|
303
|
+
session?: RuntimeSession;
|
|
304
|
+
model: string;
|
|
305
|
+
tokensIn?: number;
|
|
306
|
+
tokensOut?: number;
|
|
307
|
+
costUsd?: number;
|
|
308
|
+
latencyMs?: number;
|
|
309
|
+
finishReason?: string;
|
|
310
|
+
timestamp?: string;
|
|
311
|
+
} | {
|
|
312
|
+
type: 'artifact';
|
|
313
|
+
task?: AgentTaskSpec;
|
|
314
|
+
session?: RuntimeSession;
|
|
315
|
+
artifactId: string;
|
|
316
|
+
name?: string;
|
|
317
|
+
mimeType?: string;
|
|
318
|
+
uri?: string;
|
|
319
|
+
content?: string;
|
|
320
|
+
metadata?: Record<string, unknown>;
|
|
321
|
+
timestamp?: string;
|
|
322
|
+
} | {
|
|
323
|
+
type: 'proposal_created';
|
|
324
|
+
task?: AgentTaskSpec;
|
|
325
|
+
session?: RuntimeSession;
|
|
326
|
+
proposalId: string;
|
|
327
|
+
title: string;
|
|
328
|
+
status?: 'pending' | 'approved' | 'rejected';
|
|
329
|
+
content?: string;
|
|
330
|
+
timestamp?: string;
|
|
331
|
+
} | {
|
|
332
|
+
type: 'backend_error';
|
|
333
|
+
task: AgentTaskSpec;
|
|
334
|
+
session?: RuntimeSession;
|
|
335
|
+
backend: string;
|
|
336
|
+
message: string;
|
|
337
|
+
recoverable: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Typed transport diagnostic. Present when the upstream returned a
|
|
340
|
+
* non-success HTTP status or every retry attempt threw. Consumers MUST
|
|
341
|
+
* surface this onto their `RunRecord.error` — silently treating a
|
|
342
|
+
* `backend_error` as "no output" hides credit exhaustion, auth failure,
|
|
343
|
+
* and upstream outages from operators.
|
|
344
|
+
* - `kind: 'transport'` — HTTP / network failure with optional `status`
|
|
345
|
+
* + truncated response `body`.
|
|
346
|
+
* - `kind: 'backend'` — the backend's `stream()` generator threw for a
|
|
347
|
+
* reason that isn't a recognized transport failure.
|
|
348
|
+
*/
|
|
349
|
+
error?: BackendErrorDetail;
|
|
350
|
+
timestamp: string;
|
|
351
|
+
} | {
|
|
352
|
+
type: 'backend_end';
|
|
353
|
+
task: AgentTaskSpec;
|
|
354
|
+
session: RuntimeSession;
|
|
355
|
+
backend: string;
|
|
356
|
+
timestamp: string;
|
|
357
|
+
} | {
|
|
358
|
+
type: 'task_end';
|
|
359
|
+
task: AgentTaskSpec;
|
|
360
|
+
status: AgentTaskStatus;
|
|
361
|
+
reason: string;
|
|
362
|
+
timestamp: string;
|
|
363
|
+
} | {
|
|
364
|
+
type: 'final';
|
|
365
|
+
task: AgentTaskSpec;
|
|
366
|
+
session?: RuntimeSession;
|
|
367
|
+
status: AgentTaskStatus;
|
|
368
|
+
reason: string;
|
|
369
|
+
text?: string;
|
|
370
|
+
metadata?: Record<string, unknown>;
|
|
371
|
+
/**
|
|
372
|
+
* Typed terminal-error diagnostic. Mirrors the `backend_error.error`
|
|
373
|
+
* shape so a consumer that only listens for `final` still receives a
|
|
374
|
+
* loud, structured failure when the backend never produced output. Only
|
|
375
|
+
* set when `status !== 'completed'`. Consumers building a `RunRecord`
|
|
376
|
+
* MUST map this to `RunRecord.error` rather than recording silent
|
|
377
|
+
* `error: null` with empty `finalText`.
|
|
378
|
+
*/
|
|
379
|
+
error?: BackendErrorDetail;
|
|
380
|
+
timestamp: string;
|
|
381
|
+
};
|
|
382
|
+
/** @stable */
|
|
383
|
+
interface RuntimeSession {
|
|
384
|
+
id: string;
|
|
385
|
+
backend: string;
|
|
386
|
+
status: 'active' | 'completed' | 'failed' | 'aborted';
|
|
387
|
+
resumeToken?: string;
|
|
388
|
+
createdAt: string;
|
|
389
|
+
updatedAt: string;
|
|
390
|
+
metadata?: Record<string, unknown>;
|
|
391
|
+
}
|
|
392
|
+
/** @stable */
|
|
393
|
+
interface RuntimeSessionStore {
|
|
394
|
+
get(sessionId: string): Promise<RuntimeSession | undefined> | RuntimeSession | undefined;
|
|
395
|
+
put(session: RuntimeSession): Promise<void> | void;
|
|
396
|
+
appendEvent?(sessionId: string, event: RuntimeStreamEvent): Promise<void> | void;
|
|
397
|
+
listEvents?(sessionId: string): Promise<RuntimeStreamEvent[]> | RuntimeStreamEvent[];
|
|
398
|
+
}
|
|
399
|
+
/** @stable */
|
|
400
|
+
interface AgentBackendInput {
|
|
401
|
+
task: AgentTaskSpec;
|
|
402
|
+
message?: string;
|
|
403
|
+
messages?: Array<{
|
|
404
|
+
role: string;
|
|
405
|
+
content: string;
|
|
406
|
+
}>;
|
|
407
|
+
inputs?: Record<string, unknown>;
|
|
408
|
+
}
|
|
409
|
+
/** @stable */
|
|
410
|
+
interface AgentBackendContext {
|
|
411
|
+
task: AgentTaskSpec;
|
|
412
|
+
knowledge: KnowledgeReadinessReport;
|
|
413
|
+
session: RuntimeSession;
|
|
414
|
+
signal?: AbortSignal;
|
|
415
|
+
/**
|
|
416
|
+
* Conversation/run identifier when this call is part of a multi-agent run.
|
|
417
|
+
* Backends should stamp it into any trace/log emission so cross-participant
|
|
418
|
+
* events correlate. Absent when the call is a stand-alone `runAgentTask`.
|
|
419
|
+
*/
|
|
420
|
+
runId?: string;
|
|
421
|
+
/**
|
|
422
|
+
* Deterministic turn id for this single call. Stable across retries of the
|
|
423
|
+
* same logical turn so a caching gateway / idempotent backend can dedupe.
|
|
424
|
+
*/
|
|
425
|
+
turnId?: string;
|
|
426
|
+
/**
|
|
427
|
+
* If this call is itself nested inside a higher-order conversation
|
|
428
|
+
* (recursion via `createConversationBackend`), the enclosing turn's id.
|
|
429
|
+
* Used for trace stitching across nested orchestration.
|
|
430
|
+
*/
|
|
431
|
+
parentTurnId?: string;
|
|
432
|
+
/**
|
|
433
|
+
* Headers to forward verbatim to any outbound HTTP the backend issues:
|
|
434
|
+
* `X-Tangle-Forwarded-Authorization`, `X-Tangle-Forwarded-Depth`,
|
|
435
|
+
* run/turn correlation. Backends that issue HTTP MUST merge these into
|
|
436
|
+
* the outbound request; backends that don't issue HTTP may ignore them.
|
|
437
|
+
*/
|
|
438
|
+
propagatedHeaders?: Readonly<Record<string, string>>;
|
|
439
|
+
}
|
|
440
|
+
/** @stable */
|
|
441
|
+
interface AgentExecutionBackend<TInput extends AgentBackendInput = AgentBackendInput> {
|
|
442
|
+
kind: string;
|
|
443
|
+
start?(input: TInput, context: Omit<AgentBackendContext, 'session'> & {
|
|
444
|
+
requestedSessionId?: string;
|
|
445
|
+
}): Promise<RuntimeSession> | RuntimeSession;
|
|
446
|
+
resume?(session: RuntimeSession, input: TInput, context: Omit<AgentBackendContext, 'session'>): Promise<RuntimeSession> | RuntimeSession;
|
|
447
|
+
stream(input: TInput, context: AgentBackendContext): AsyncIterable<RuntimeStreamEvent>;
|
|
448
|
+
stop?(session: RuntimeSession, reason: string): Promise<void> | void;
|
|
449
|
+
}
|
|
450
|
+
/** @stable */
|
|
451
|
+
interface RunAgentTaskStreamOptions<TInput extends AgentBackendInput = AgentBackendInput> {
|
|
452
|
+
task: AgentTaskSpec;
|
|
453
|
+
backend: AgentExecutionBackend<TInput>;
|
|
454
|
+
input?: Omit<TInput, 'task'>;
|
|
455
|
+
knowledge?: AgentKnowledgeProvider;
|
|
456
|
+
sessionStore?: RuntimeSessionStore;
|
|
457
|
+
sessionId?: string;
|
|
458
|
+
resume?: boolean;
|
|
459
|
+
signal?: AbortSignal;
|
|
460
|
+
minimumReadinessScore?: number;
|
|
461
|
+
}
|
|
462
|
+
/** @stable */
|
|
463
|
+
interface RunAgentTaskOptions<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
464
|
+
task: AgentTaskSpec;
|
|
465
|
+
adapter: AgentAdapter<TState, TAction, TActionResult, TEval>;
|
|
466
|
+
knowledge?: AgentKnowledgeProvider;
|
|
467
|
+
onEvent?: AgentRuntimeEventSink<TState, TAction, TActionResult, TEval>;
|
|
468
|
+
store?: TraceStore;
|
|
469
|
+
signal?: AbortSignal;
|
|
470
|
+
scenarioId?: string;
|
|
471
|
+
projectId?: string;
|
|
472
|
+
variantId?: string;
|
|
473
|
+
minimumReadinessScore?: number;
|
|
474
|
+
}
|
|
475
|
+
/** @stable */
|
|
476
|
+
interface AgentTaskRunResult<TState, TAction, TActionResult, TEval extends ControlEvalResult = ControlEvalResult> {
|
|
477
|
+
task: AgentTaskSpec;
|
|
478
|
+
status: AgentTaskStatus;
|
|
479
|
+
knowledge: KnowledgeReadinessReport;
|
|
480
|
+
questions: UserQuestion[];
|
|
481
|
+
acquisitionPlans: DataAcquisitionPlan[];
|
|
482
|
+
userAnswers: Record<string, string>;
|
|
483
|
+
acquiredEvidenceIds: string[];
|
|
484
|
+
control: ControlRunResult<TState, TAction, TActionResult, TEval>;
|
|
485
|
+
runRecords: RunRecord[];
|
|
486
|
+
}
|
|
487
|
+
/** @stable */
|
|
488
|
+
interface KnowledgeReadinessDecision {
|
|
489
|
+
passed: boolean;
|
|
490
|
+
status: 'ready' | 'blocked' | 'caveat';
|
|
491
|
+
reason: string;
|
|
492
|
+
readinessScore: number;
|
|
493
|
+
recommendedAction: KnowledgeReadinessReport['recommendedAction'];
|
|
494
|
+
severity: KnowledgeReadinessReport['severity'];
|
|
495
|
+
blockingGapIds: string[];
|
|
496
|
+
nonBlockingGapIds: string[];
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
499
|
+
export { RunAgentTaskOptions as _, AgentKnowledgeProvider as a, RuntimeSessionStore as b, AgentTaskContext as c, AgentTaskStatus as d, BackendErrorDetail as f, OpenAIChatToolChoice as g, OpenAIChatTool as h, AgentExecutionBackend as i, AgentTaskRunResult as l, OpenAIChatResponseFormat as m, AgentBackendContext as n, AgentRuntimeEvent as o, KnowledgeReadinessDecision as p, AgentBackendInput as r, AgentRuntimeEventSink as s, AgentAdapter as t, AgentTaskSpec as u, RunAgentTaskStreamOptions as v, RuntimeStreamEvent as x, RuntimeSession as y };
|
|
500
|
+
//# sourceMappingURL=types-C9j4qg6l.d.ts.map
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { AnalystFinding, AnalystRunEvent, AnalystRunInputs, AnalystRunResult, FindingsDiff } from "@tangle-network/agent-eval";
|
|
2
|
+
//#region src/analyst-loop/types.d.ts
|
|
3
|
+
/** Knowledge-side bridge — consumers wire `proposeFromFindings` from agent-knowledge. */
|
|
4
|
+
interface KnowledgeProposalSource<TProposal = unknown> {
|
|
5
|
+
/**
|
|
6
|
+
* Convert a findings batch into proposals. Returns the partitioned
|
|
7
|
+
* result so the loop can report malformed
|
|
8
|
+
* findings. Implementations SHOULD honour the convention "non-
|
|
9
|
+
* knowledge subjects return null and are counted in `skipped`."
|
|
10
|
+
*/
|
|
11
|
+
proposeFromFindings(findings: ReadonlyArray<AnalystFinding>): Promise<KnowledgeProposalBatch<TProposal>> | KnowledgeProposalBatch<TProposal>;
|
|
12
|
+
}
|
|
13
|
+
interface KnowledgeProposalBatch<TProposal = unknown> {
|
|
14
|
+
proposals: TProposal[];
|
|
15
|
+
skipped: number;
|
|
16
|
+
errors: Array<{
|
|
17
|
+
findingId: string;
|
|
18
|
+
subject: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** Agent-surface bridge — proposes prompt, skill, tool, and scaffolding edits. */
|
|
23
|
+
interface ImprovementProposalSource<TEdit = unknown> {
|
|
24
|
+
proposeFromFindings(findings: ReadonlyArray<AnalystFinding>): Promise<ImprovementEditBatch<TEdit>> | ImprovementEditBatch<TEdit>;
|
|
25
|
+
}
|
|
26
|
+
interface ImprovementEditBatch<TEdit = unknown> {
|
|
27
|
+
edits: TEdit[];
|
|
28
|
+
skipped: number;
|
|
29
|
+
errors: Array<{
|
|
30
|
+
findingId: string;
|
|
31
|
+
subject: string;
|
|
32
|
+
message: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
interface RunAnalystLoopOpts {
|
|
36
|
+
/** The run id of the work being analysed. */
|
|
37
|
+
runId: string;
|
|
38
|
+
/** The registry — pre-populated with the analyst kinds the consumer wants. */
|
|
39
|
+
registry: AnalystRegistryLike;
|
|
40
|
+
/** Inputs forwarded to `registry.run` — typically `{ traceStore }`. */
|
|
41
|
+
inputs: AnalystRunInputs;
|
|
42
|
+
/**
|
|
43
|
+
* Findings ledger. The loop appends the new run + diffs against the
|
|
44
|
+
* baseline run before running adapters. Pass `null` to skip
|
|
45
|
+
* persistence (useful for one-shot analyses).
|
|
46
|
+
*/
|
|
47
|
+
findingsStore: FindingsStoreLike | null;
|
|
48
|
+
/**
|
|
49
|
+
* Prior run id whose findings the loop reads + provides to analysts
|
|
50
|
+
* as `priorFindings` AND diffs against. When omitted, the loop picks
|
|
51
|
+
* the most recent run in the store (excluding `runId` itself); pass
|
|
52
|
+
* `null` to explicitly start with an empty baseline.
|
|
53
|
+
*/
|
|
54
|
+
baselineRunId?: string | null;
|
|
55
|
+
/** Strategy for forwarding prior findings into `ctx.priorFindings`. */
|
|
56
|
+
priorFindingsStrategy?: 'per-kind' | 'wildcard' | 'none';
|
|
57
|
+
/** Knowledge-side bridge — usually `agent-knowledge`'s `proposeFromFindings`. */
|
|
58
|
+
knowledgeProposalSource?: KnowledgeProposalSource;
|
|
59
|
+
/** Agent-surface bridge — usually a prompt, skill, or tool diff producer. */
|
|
60
|
+
improvementProposalSource?: ImprovementProposalSource;
|
|
61
|
+
/** Optional logger. Defaults to `console.log` for `[analyst-loop]` lines. */
|
|
62
|
+
log?: (msg: string, fields?: Record<string, unknown>) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Event sink for live progress. Called for every phase of the loop:
|
|
65
|
+
* baseline resolution, registry events forwarded from `runStream`,
|
|
66
|
+
* ledger persistence, diff, knowledge / improvement proposals, and
|
|
67
|
+
* the terminal `loop-completed`. Awaited so
|
|
68
|
+
* slow sinks (SSE write, JSONL append) apply backpressure.
|
|
69
|
+
*
|
|
70
|
+
* The callback MUST NOT throw — exceptions propagate and abort the
|
|
71
|
+
* loop. Catch + swallow internally if your sink is unreliable.
|
|
72
|
+
*/
|
|
73
|
+
onEvent?: (event: AnalystLoopEvent) => void | Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
interface RunAnalystLoopResult<TProposal = unknown, TEdit = unknown> {
|
|
76
|
+
runId: string;
|
|
77
|
+
baselineRunId: string | null;
|
|
78
|
+
analystResult: AnalystRunResult;
|
|
79
|
+
diff: FindingsDiff | null;
|
|
80
|
+
knowledge: KnowledgeReport<TProposal> | null;
|
|
81
|
+
improvement: ImprovementReport<TEdit> | null;
|
|
82
|
+
}
|
|
83
|
+
interface KnowledgeReport<TProposal = unknown> {
|
|
84
|
+
proposals: TProposal[];
|
|
85
|
+
skipped: number;
|
|
86
|
+
errors: Array<{
|
|
87
|
+
findingId: string;
|
|
88
|
+
subject: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
interface ImprovementReport<TEdit = unknown> {
|
|
93
|
+
edits: TEdit[];
|
|
94
|
+
skipped: number;
|
|
95
|
+
errors: Array<{
|
|
96
|
+
findingId: string;
|
|
97
|
+
subject: string;
|
|
98
|
+
message: string;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Narrowed shape we accept for `AnalystRegistry` so the orchestrator
|
|
103
|
+
* remains testable without instantiating the real class. The real
|
|
104
|
+
* class satisfies this trivially.
|
|
105
|
+
*/
|
|
106
|
+
interface AnalystRegistryLike {
|
|
107
|
+
list(): ReadonlyArray<{
|
|
108
|
+
id: string;
|
|
109
|
+
}>;
|
|
110
|
+
run(runId: string, inputs: AnalystRunInputs, opts?: {
|
|
111
|
+
priorFindings?: ReadonlyArray<AnalystFinding> | Record<string, ReadonlyArray<AnalystFinding>>;
|
|
112
|
+
[k: string]: unknown;
|
|
113
|
+
}): Promise<AnalystRunResult>;
|
|
114
|
+
}
|
|
115
|
+
/** Narrowed shape we accept for `FindingsStore`. */
|
|
116
|
+
interface FindingsStoreLike {
|
|
117
|
+
loadAll(): ReadonlyArray<AnalystFinding & {
|
|
118
|
+
run_id: string;
|
|
119
|
+
}>;
|
|
120
|
+
loadRun(runId: string): ReadonlyArray<AnalystFinding & {
|
|
121
|
+
run_id: string;
|
|
122
|
+
}>;
|
|
123
|
+
append(runId: string, findings: ReadonlyArray<AnalystFinding>): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Narrow the `AnalystRegistryLike` further when we need streaming: the
|
|
127
|
+
* loop checks if the registry exposes `runStream` and uses it when
|
|
128
|
+
* present, falling back to `run()` otherwise. This keeps the type
|
|
129
|
+
* surface backwards-compatible — older registry shims that only
|
|
130
|
+
* implement `run` still work; they just don't forward per-analyst
|
|
131
|
+
* events.
|
|
132
|
+
*/
|
|
133
|
+
interface AnalystRegistryStreamingLike extends AnalystRegistryLike {
|
|
134
|
+
runStream?(runId: string, inputs: AnalystRunInputs, opts?: {
|
|
135
|
+
priorFindings?: ReadonlyArray<AnalystFinding> | Record<string, ReadonlyArray<AnalystFinding>>;
|
|
136
|
+
[k: string]: unknown;
|
|
137
|
+
}): AsyncIterable<AnalystRunEvent>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Events emitted by `runAnalystLoop` via `opts.onEvent`. UIs and
|
|
141
|
+
* JSONL tail-sinks consume this stream. The loop awaits each
|
|
142
|
+
* callback so a slow sink applies backpressure to the loop's phases
|
|
143
|
+
* (e.g. an SSE write that takes 200ms delays the next phase by
|
|
144
|
+
* 200ms — the loop never out-paces its observer).
|
|
145
|
+
*
|
|
146
|
+
* Forwards registry events verbatim via `analyst` so consumers don't
|
|
147
|
+
* have to wire two streams.
|
|
148
|
+
*/
|
|
149
|
+
type AnalystLoopEvent = {
|
|
150
|
+
type: 'baseline-resolved';
|
|
151
|
+
runId: string;
|
|
152
|
+
baselineRunId: string | null;
|
|
153
|
+
priorFindingCount: number;
|
|
154
|
+
} | {
|
|
155
|
+
type: 'analyst';
|
|
156
|
+
runId: string;
|
|
157
|
+
/** Forwarded verbatim from `AnalystRegistry.runStream`. */
|
|
158
|
+
event: AnalystRunEvent;
|
|
159
|
+
} | {
|
|
160
|
+
type: 'findings-persisted';
|
|
161
|
+
runId: string;
|
|
162
|
+
count: number;
|
|
163
|
+
} | {
|
|
164
|
+
type: 'diff-computed';
|
|
165
|
+
runId: string;
|
|
166
|
+
baselineRunId: string;
|
|
167
|
+
appeared: number;
|
|
168
|
+
disappeared: number;
|
|
169
|
+
persisted: number;
|
|
170
|
+
changed: number;
|
|
171
|
+
} | {
|
|
172
|
+
type: 'knowledge-proposed';
|
|
173
|
+
runId: string;
|
|
174
|
+
proposalCount: number;
|
|
175
|
+
skipped: number;
|
|
176
|
+
errors: number;
|
|
177
|
+
} | {
|
|
178
|
+
type: 'improvement-proposed';
|
|
179
|
+
runId: string;
|
|
180
|
+
editCount: number;
|
|
181
|
+
skipped: number;
|
|
182
|
+
errors: number;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'loop-completed';
|
|
185
|
+
runId: string;
|
|
186
|
+
durationMs: number;
|
|
187
|
+
};
|
|
188
|
+
//#endregion
|
|
189
|
+
export { ImprovementEditBatch as a, KnowledgeProposalBatch as c, RunAnalystLoopOpts as d, RunAnalystLoopResult as f, FindingsStoreLike as i, KnowledgeProposalSource as l, AnalystRegistryLike as n, ImprovementProposalSource as o, AnalystRegistryStreamingLike as r, ImprovementReport as s, AnalystLoopEvent as t, KnowledgeReport as u };
|
|
190
|
+
//# sourceMappingURL=types-Cja5OTGh.d.ts.map
|