@claudexor/orchestrator 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attemptFinalize.d.ts +14 -11
- package/dist/attemptFinalize.d.ts.map +1 -1
- package/dist/attemptFinalize.js +41 -14
- package/dist/attemptFinalize.js.map +1 -1
- package/dist/attemptTelemetry.d.ts +16 -20
- package/dist/attemptTelemetry.d.ts.map +1 -1
- package/dist/attemptTelemetry.js +38 -70
- package/dist/attemptTelemetry.js.map +1 -1
- package/dist/attemptUsageCost.d.ts +47 -0
- package/dist/attemptUsageCost.d.ts.map +1 -0
- package/dist/attemptUsageCost.js +191 -0
- package/dist/attemptUsageCost.js.map +1 -0
- package/dist/budgetFailure.d.ts +3 -1
- package/dist/budgetFailure.d.ts.map +1 -1
- package/dist/budgetFailure.js.map +1 -1
- package/dist/candidateEvidence.d.ts +5 -0
- package/dist/candidateEvidence.d.ts.map +1 -1
- package/dist/candidateEvidence.js +3 -1
- package/dist/candidateEvidence.js.map +1 -1
- package/dist/candidateOutputs.d.ts +19 -0
- package/dist/candidateOutputs.d.ts.map +1 -1
- package/dist/candidateOutputs.js +201 -67
- package/dist/candidateOutputs.js.map +1 -1
- package/dist/credential-profile-rotation.d.ts +145 -0
- package/dist/credential-profile-rotation.d.ts.map +1 -0
- package/dist/credential-profile-rotation.js +315 -0
- package/dist/credential-profile-rotation.js.map +1 -0
- package/dist/credential-profiles.d.ts +35 -134
- package/dist/credential-profiles.d.ts.map +1 -1
- package/dist/credential-profiles.js +73 -295
- package/dist/credential-profiles.js.map +1 -1
- package/dist/decisionBudget.d.ts +43 -0
- package/dist/decisionBudget.d.ts.map +1 -0
- package/dist/decisionBudget.js +84 -0
- package/dist/decisionBudget.js.map +1 -0
- package/dist/decisionTerminalReconciliation.d.ts +18 -0
- package/dist/decisionTerminalReconciliation.d.ts.map +1 -0
- package/dist/decisionTerminalReconciliation.js +26 -0
- package/dist/decisionTerminalReconciliation.js.map +1 -0
- package/dist/deepScanReducer.d.ts +14 -44
- package/dist/deepScanReducer.d.ts.map +1 -1
- package/dist/deepScanReducer.js +240 -128
- package/dist/deepScanReducer.js.map +1 -1
- package/dist/delegation-parent-activation.d.ts +6 -0
- package/dist/delegation-parent-activation.d.ts.map +1 -0
- package/dist/delegation-parent-activation.js +13 -0
- package/dist/delegation-parent-activation.js.map +1 -0
- package/dist/delegationBudgetAuthority.d.ts +30 -0
- package/dist/delegationBudgetAuthority.d.ts.map +1 -0
- package/dist/delegationBudgetAuthority.js +157 -0
- package/dist/delegationBudgetAuthority.js.map +1 -0
- package/dist/delegationFailure.d.ts +58 -0
- package/dist/delegationFailure.d.ts.map +1 -0
- package/dist/delegationFailure.js +184 -0
- package/dist/delegationFailure.js.map +1 -0
- package/dist/delegationToolEvidence.d.ts +20 -0
- package/dist/delegationToolEvidence.d.ts.map +1 -0
- package/dist/delegationToolEvidence.js +46 -0
- package/dist/delegationToolEvidence.js.map +1 -0
- package/dist/git-precondition.d.ts +11 -0
- package/dist/git-precondition.d.ts.map +1 -0
- package/dist/git-precondition.js +69 -0
- package/dist/git-precondition.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +14 -6
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +106 -19
- package/dist/interaction.js.map +1 -1
- package/dist/orchestrator.d.ts +62 -115
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +671 -965
- package/dist/orchestrator.js.map +1 -1
- package/dist/plan-prompt.d.ts +3 -0
- package/dist/plan-prompt.d.ts.map +1 -0
- package/dist/plan-prompt.js +28 -0
- package/dist/plan-prompt.js.map +1 -0
- package/dist/planBrief.d.ts +27 -0
- package/dist/planBrief.d.ts.map +1 -0
- package/dist/planBrief.js +42 -0
- package/dist/planBrief.js.map +1 -0
- package/dist/planRun.d.ts +4 -3
- package/dist/planRun.d.ts.map +1 -1
- package/dist/planRun.js +33 -33
- package/dist/planRun.js.map +1 -1
- package/dist/plannerAttempt.d.ts +64 -0
- package/dist/plannerAttempt.d.ts.map +1 -0
- package/dist/plannerAttempt.js +235 -0
- package/dist/plannerAttempt.js.map +1 -0
- package/dist/policyFindings.js.map +1 -1
- package/dist/requestRequirements.d.ts +45 -1
- package/dist/requestRequirements.d.ts.map +1 -1
- package/dist/requestRequirements.js +158 -11
- package/dist/requestRequirements.js.map +1 -1
- package/dist/reviewerPanel.js.map +1 -1
- package/dist/root-ledger.d.ts +13 -0
- package/dist/root-ledger.d.ts.map +1 -0
- package/dist/root-ledger.js +21 -0
- package/dist/root-ledger.js.map +1 -0
- package/dist/routing-failure.d.ts +6 -0
- package/dist/routing-failure.d.ts.map +1 -0
- package/dist/routing-failure.js +12 -0
- package/dist/routing-failure.js.map +1 -0
- package/dist/run-bounded.d.ts +3 -0
- package/dist/run-bounded.d.ts.map +1 -0
- package/dist/run-bounded.js +23 -0
- package/dist/run-bounded.js.map +1 -0
- package/dist/run-input-resolution.d.ts +10 -0
- package/dist/run-input-resolution.d.ts.map +1 -0
- package/dist/run-input-resolution.js +88 -0
- package/dist/run-input-resolution.js.map +1 -0
- package/dist/runEventLog.d.ts +48 -0
- package/dist/runEventLog.d.ts.map +1 -0
- package/dist/runEventLog.js +63 -0
- package/dist/runEventLog.js.map +1 -0
- package/dist/runFacts.d.ts +23 -0
- package/dist/runFacts.d.ts.map +1 -0
- package/dist/runFacts.js +179 -0
- package/dist/runFacts.js.map +1 -0
- package/dist/runFactsBuilder.d.ts +5 -0
- package/dist/runFactsBuilder.d.ts.map +1 -0
- package/dist/runFactsBuilder.js +412 -0
- package/dist/runFactsBuilder.js.map +1 -0
- package/dist/runFactsDeliverable.d.ts +13 -0
- package/dist/runFactsDeliverable.d.ts.map +1 -0
- package/dist/runFactsDeliverable.js +94 -0
- package/dist/runFactsDeliverable.js.map +1 -0
- package/dist/runFactsPresentation.d.ts +7 -0
- package/dist/runFactsPresentation.d.ts.map +1 -0
- package/dist/runFactsPresentation.js +113 -0
- package/dist/runFactsPresentation.js.map +1 -0
- package/dist/runFactsReview.d.ts +7 -0
- package/dist/runFactsReview.d.ts.map +1 -0
- package/dist/runFactsReview.js +63 -0
- package/dist/runFactsReview.js.map +1 -0
- package/dist/runSupport.d.ts +17 -15
- package/dist/runSupport.d.ts.map +1 -1
- package/dist/runSupport.js +16 -0
- package/dist/runSupport.js.map +1 -1
- package/dist/runTelemetryWriter.d.ts +5 -2
- package/dist/runTelemetryWriter.d.ts.map +1 -1
- package/dist/runTelemetryWriter.js +72 -1
- package/dist/runTelemetryWriter.js.map +1 -1
- package/dist/runTerminalContext.d.ts +31 -0
- package/dist/runTerminalContext.d.ts.map +1 -0
- package/dist/runTerminalContext.js +12 -0
- package/dist/runTerminalContext.js.map +1 -0
- package/dist/runTerminalResults.d.ts +55 -0
- package/dist/runTerminalResults.d.ts.map +1 -0
- package/dist/runTerminalResults.js +134 -0
- package/dist/runTerminalResults.js.map +1 -0
- package/dist/runTerminals.d.ts +8 -57
- package/dist/runTerminals.d.ts.map +1 -1
- package/dist/runTerminals.js +423 -135
- package/dist/runTerminals.js.map +1 -1
- package/dist/secretDiff.d.ts +32 -0
- package/dist/secretDiff.d.ts.map +1 -0
- package/dist/secretDiff.js +140 -0
- package/dist/secretDiff.js.map +1 -0
- package/dist/structuredOutput.d.ts.map +1 -1
- package/dist/structuredOutput.js.map +1 -1
- package/dist/task-contract-builder.d.ts +35 -0
- package/dist/task-contract-builder.d.ts.map +1 -0
- package/dist/task-contract-builder.js +114 -0
- package/dist/task-contract-builder.js.map +1 -0
- package/dist/terminalOutcome.d.ts +22 -0
- package/dist/terminalOutcome.d.ts.map +1 -0
- package/dist/terminalOutcome.js +39 -0
- package/dist/terminalOutcome.js.map +1 -0
- package/dist/transientClassify.js.map +1 -1
- package/package.json +17 -17
|
@@ -23,9 +23,9 @@ import type { ToolErrorRecord, WebEvidenceState } from "./attemptTelemetry.js";
|
|
|
23
23
|
* - `side_tool`: a `{work_report}`-only schema arms claude's StructuredOutput
|
|
24
24
|
* TOOL; the markdown final message stays the deliverable and the report rides
|
|
25
25
|
* the tool payload (surfaced on the final message's `work_report_side_tool`).
|
|
26
|
-
* - `instructed_fence`: no native constraint — the model
|
|
27
|
-
*
|
|
28
|
-
* the last fenced JSON (cursor).
|
|
26
|
+
* - `instructed_fence`: no native constraint — the model writes its complete
|
|
27
|
+
* markdown answer, then appends a fenced `{work_report}` metadata block
|
|
28
|
+
* validated off the last fenced JSON (cursor).
|
|
29
29
|
*/
|
|
30
30
|
export type WorkReportChannel = "constrained_json" | "side_tool" | "instructed_fence";
|
|
31
31
|
/** The per-attempt envelope decision made at spec build and consumed by the
|
|
@@ -41,9 +41,10 @@ export interface WorkReportEnvelopeMode {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* The instruction appended to an `instructed_fence` (cursor) route so the model
|
|
44
|
-
* emits the WorkReport
|
|
44
|
+
* emits the WorkReport footer the finalizer validates. No native schema
|
|
45
45
|
* constrains cursor, so the contract is instructed and validated off the last
|
|
46
|
-
* fenced JSON block (D-16c). The
|
|
46
|
+
* fenced JSON block (D-16c). The normal markdown before that footer is the
|
|
47
|
+
* deliverable; a historical fence-only `output` remains a read fallback.
|
|
47
48
|
*/
|
|
48
49
|
export declare const WORK_REPORT_FENCE_INSTRUCTION: string;
|
|
49
50
|
/** Result of the spec-build envelope decision. */
|
|
@@ -87,8 +88,9 @@ export interface UnwrappedAnswer {
|
|
|
87
88
|
* Un-nest the WorkReport envelope from an active route's answer (D-16 §2). The
|
|
88
89
|
* behavior forks on `mode.channel`:
|
|
89
90
|
* - `constrained_json`: the whole answer IS `{work_report, output}` JSON.
|
|
90
|
-
* - `instructed_fence`: the
|
|
91
|
-
* before it is
|
|
91
|
+
* - `instructed_fence`: the LAST fenced JSON block carries metadata; the
|
|
92
|
+
* markdown before it is the deliverable. Historical fence-only envelopes
|
|
93
|
+
* fall back to their string `output`.
|
|
92
94
|
* - `side_tool`: the answer text IS the markdown deliverable; the report rides
|
|
93
95
|
* `opts.sideToolReport` (the tool payload the adapter surfaced).
|
|
94
96
|
* A non-active mode passes the answer through untouched. The WorkReport
|
|
@@ -105,12 +107,13 @@ export declare function unwrapWorkReportEnvelope(answerText: string, mode: WorkR
|
|
|
105
107
|
sideToolReport?: unknown;
|
|
106
108
|
}): UnwrappedAnswer;
|
|
107
109
|
/**
|
|
108
|
-
* QA-036: the terminal outcome facts for a read-only
|
|
110
|
+
* QA-036: the terminal outcome facts for a read-only run that produced NO
|
|
109
111
|
* successful attempt. The D8 legacy mapping treated ANY web-blocked run as a
|
|
110
112
|
* succeeded/review_blocked terminal (exit 0, "Needs review"); a blocked Ask that
|
|
111
|
-
* delivered nothing then read as done
|
|
112
|
-
*
|
|
113
|
-
*
|
|
113
|
+
* delivered nothing then read as done, and Plan later repeated the same error
|
|
114
|
+
* without a final/plan.md. This re-checks the DELIVERABLE: only a blocked
|
|
115
|
+
* attempt that actually produced a canonical read-only output is a
|
|
116
|
+
* review-blocked SUCCESS; an empty blocked (or plain failed) run is a failure.
|
|
114
117
|
*/
|
|
115
118
|
export declare function readOnlyNoSuccessTerminal(opts: {
|
|
116
119
|
webBlocked: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attemptFinalize.d.ts","sourceRoot":"","sources":["../src/attemptFinalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAGL,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEtF;;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;AAED,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAExF,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kEAAkE;IAClE,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,kEAAkE;IAClE,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,mBAAmB,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAkDlF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,SAAS,eAAe,EAAE,EACvC,mBAAmB,EAAE,OAAO,GAC3B,MAAM,GAAG,IAAI,CAIf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,cAAc,CAAC,GACxD,MAAM,CAER"}
|
package/dist/attemptFinalize.js
CHANGED
|
@@ -18,16 +18,19 @@ import { buildWorkReportEnvelope, strictifyOutputSchema, WorkReport, } from "@cl
|
|
|
18
18
|
import { redactSecrets } from "@claudexor/util";
|
|
19
19
|
/**
|
|
20
20
|
* The instruction appended to an `instructed_fence` (cursor) route so the model
|
|
21
|
-
* emits the WorkReport
|
|
21
|
+
* emits the WorkReport footer the finalizer validates. No native schema
|
|
22
22
|
* constrains cursor, so the contract is instructed and validated off the last
|
|
23
|
-
* fenced JSON block (D-16c). The
|
|
23
|
+
* fenced JSON block (D-16c). The normal markdown before that footer is the
|
|
24
|
+
* deliverable; a historical fence-only `output` remains a read fallback.
|
|
24
25
|
*/
|
|
25
26
|
export const WORK_REPORT_FENCE_INSTRUCTION = [
|
|
26
|
-
"
|
|
27
|
+
"Write your complete final answer as normal Markdown.",
|
|
28
|
+
"When you have finished, append a single fenced ```json code block",
|
|
27
29
|
"containing exactly this object and nothing after it:",
|
|
28
30
|
'{"work_report": {"state": "completed" | "needs_input" | "incomplete",',
|
|
29
31
|
'"required_inputs": [{"kind": "file"|"context"|"credential"|"permission"|"decision"|"external_dependency",',
|
|
30
|
-
'"locator": string|null, "description": string}]}
|
|
32
|
+
'"locator": string|null, "description": string}]}}.',
|
|
33
|
+
"Do not duplicate or summarize your answer inside this block.",
|
|
31
34
|
'Use state "completed" only when the task is fully done with an empty required_inputs list;',
|
|
32
35
|
'use "needs_input" (with at least one required_inputs entry) when you are blocked on a missing input;',
|
|
33
36
|
'use "incomplete" when partial work remains. This block is mandatory.',
|
|
@@ -136,8 +139,9 @@ function extractOutput(obj, mode) {
|
|
|
136
139
|
return { deliverable: output };
|
|
137
140
|
}
|
|
138
141
|
/** Extract the LAST fenced ```…``` block's body (its optional language tag
|
|
139
|
-
* stripped)
|
|
140
|
-
*
|
|
142
|
+
* stripped) and the complete prefix before its opening fence, or null when the
|
|
143
|
+
* text has no closed fence. No-regex, mechanical transport parsing (INV-049
|
|
144
|
+
* governs the typed WorkReport, not this seam). */
|
|
141
145
|
function lastFencedBlock(text) {
|
|
142
146
|
const FENCE = "```";
|
|
143
147
|
const end = text.lastIndexOf(FENCE);
|
|
@@ -158,14 +162,20 @@ function lastFencedBlock(text) {
|
|
|
158
162
|
if (firstLine === "" || isLangTag)
|
|
159
163
|
inner = inner.slice(nl + 1);
|
|
160
164
|
}
|
|
161
|
-
return
|
|
165
|
+
return {
|
|
166
|
+
body: inner.trim(),
|
|
167
|
+
// Remove only the separator before the metadata footer. The caller owns
|
|
168
|
+
// any further presentation trimming; all authored markdown stays intact.
|
|
169
|
+
prefix: text.slice(0, start).trimEnd(),
|
|
170
|
+
};
|
|
162
171
|
}
|
|
163
172
|
/**
|
|
164
173
|
* Un-nest the WorkReport envelope from an active route's answer (D-16 §2). The
|
|
165
174
|
* behavior forks on `mode.channel`:
|
|
166
175
|
* - `constrained_json`: the whole answer IS `{work_report, output}` JSON.
|
|
167
|
-
* - `instructed_fence`: the
|
|
168
|
-
* before it is
|
|
176
|
+
* - `instructed_fence`: the LAST fenced JSON block carries metadata; the
|
|
177
|
+
* markdown before it is the deliverable. Historical fence-only envelopes
|
|
178
|
+
* fall back to their string `output`.
|
|
169
179
|
* - `side_tool`: the answer text IS the markdown deliverable; the report rides
|
|
170
180
|
* `opts.sideToolReport` (the tool payload the adapter surfaced).
|
|
171
181
|
* A non-active mode passes the answer through untouched. The WorkReport
|
|
@@ -201,6 +211,7 @@ export function unwrapWorkReportEnvelope(answerText, mode, opts = {}) {
|
|
|
201
211
|
return validateWorkReport(answerText, opts.sideToolReport, mode.source);
|
|
202
212
|
}
|
|
203
213
|
let text = answerText.trim();
|
|
214
|
+
let instructedPrefix = null;
|
|
204
215
|
if (mode.channel === "instructed_fence") {
|
|
205
216
|
const fenced = lastFencedBlock(answerText);
|
|
206
217
|
if (fenced === null) {
|
|
@@ -211,7 +222,8 @@ export function unwrapWorkReportEnvelope(answerText, mode, opts = {}) {
|
|
|
211
222
|
contractViolation: "final answer has no fenced work_report envelope",
|
|
212
223
|
};
|
|
213
224
|
}
|
|
214
|
-
text = fenced;
|
|
225
|
+
text = fenced.body;
|
|
226
|
+
instructedPrefix = fenced.prefix;
|
|
215
227
|
}
|
|
216
228
|
let parsed;
|
|
217
229
|
try {
|
|
@@ -234,6 +246,20 @@ export function unwrapWorkReportEnvelope(answerText, mode, opts = {}) {
|
|
|
234
246
|
};
|
|
235
247
|
}
|
|
236
248
|
const obj = parsed;
|
|
249
|
+
// Cursor's current contract makes the complete normal markdown canonical.
|
|
250
|
+
// The legacy output slot is consulted only for historical fence-only replies;
|
|
251
|
+
// when both exist the prefix wins deterministically, without length/heading
|
|
252
|
+
// heuristics that could silently replace a full answer with a summary.
|
|
253
|
+
if (mode.channel === "instructed_fence" && instructedPrefix?.trim()) {
|
|
254
|
+
return validateWorkReport(instructedPrefix, obj["work_report"], mode.source);
|
|
255
|
+
}
|
|
256
|
+
// A footer-only reply is still a valid report. Each consumer keeps its
|
|
257
|
+
// established product rule: Ask/report may surface honest "(no output)",
|
|
258
|
+
// Plan/reducer require prose, and a mutating attempt may have a real diff.
|
|
259
|
+
// Only a PRESENT legacy output must satisfy the old string shape.
|
|
260
|
+
if (mode.channel === "instructed_fence" && obj["output"] === undefined) {
|
|
261
|
+
return validateWorkReport("", obj["work_report"], mode.source);
|
|
262
|
+
}
|
|
237
263
|
const extracted = extractOutput(obj, mode);
|
|
238
264
|
if ("violation" in extracted) {
|
|
239
265
|
return {
|
|
@@ -292,12 +318,13 @@ function validateWorkReport(deliverable, rawReport, source) {
|
|
|
292
318
|
return { deliverable, workReport: report, source, contractViolation: null };
|
|
293
319
|
}
|
|
294
320
|
/**
|
|
295
|
-
* QA-036: the terminal outcome facts for a read-only
|
|
321
|
+
* QA-036: the terminal outcome facts for a read-only run that produced NO
|
|
296
322
|
* successful attempt. The D8 legacy mapping treated ANY web-blocked run as a
|
|
297
323
|
* succeeded/review_blocked terminal (exit 0, "Needs review"); a blocked Ask that
|
|
298
|
-
* delivered nothing then read as done
|
|
299
|
-
*
|
|
300
|
-
*
|
|
324
|
+
* delivered nothing then read as done, and Plan later repeated the same error
|
|
325
|
+
* without a final/plan.md. This re-checks the DELIVERABLE: only a blocked
|
|
326
|
+
* attempt that actually produced a canonical read-only output is a
|
|
327
|
+
* review-blocked SUCCESS; an empty blocked (or plain failed) run is a failure.
|
|
301
328
|
*/
|
|
302
329
|
export function readOnlyNoSuccessTerminal(opts) {
|
|
303
330
|
if (opts.webBlocked && opts.hasDeliverable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attemptFinalize.js","sourceRoot":"","sources":["../src/attemptFinalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,UAAU,GAKX,MAAM,mBAAmB,C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@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Attempt-level telemetry: the single owner of tool-error records, web
|
|
3
3
|
* evidence state, transient-failure observations, and the attempt outcome
|
|
4
4
|
* truth. Adapters emit typed events; the orchestrator observes them here —
|
|
5
|
-
* no regex over prose
|
|
6
|
-
*
|
|
5
|
+
* no regex over prose. Recovery needs matching tool + kind + target plus matching
|
|
6
|
+
* non-null use ids when both exist; a missing id retains the tuple fallback.
|
|
7
7
|
*/
|
|
8
8
|
import type { AttemptTelemetryRecord, AuthSourceKind, ExternalContextPolicy, HarnessEvent, RequestRequirementResolution, TaskContract, ToolKind, WorkState } from "@claudexor/schema";
|
|
9
|
+
import { type AttemptUsageCost } from "./attemptUsageCost.js";
|
|
9
10
|
import { type TransientFailureObservation } from "./transientClassify.js";
|
|
10
11
|
export { type TransientFailureObservation, classifyAdapterThrow } from "./transientClassify.js";
|
|
11
12
|
export interface ToolErrorRecord {
|
|
@@ -14,7 +15,7 @@ export interface ToolErrorRecord {
|
|
|
14
15
|
target: string | null;
|
|
15
16
|
summary: string;
|
|
16
17
|
toolUseId: string | null;
|
|
17
|
-
/** True when a later
|
|
18
|
+
/** True when a later success matches tool + kind + target and any ids both records provide (INV-043). */
|
|
18
19
|
recovered: boolean;
|
|
19
20
|
}
|
|
20
21
|
export type AttemptOutcomeStatus = "success" | "success_with_warnings" | "blocked" | "failed";
|
|
@@ -63,9 +64,10 @@ export interface BrowserEvidenceState {
|
|
|
63
64
|
* Delegation-belt runtime readiness for one attempt (QA-024). `requested` is
|
|
64
65
|
* set at attempt creation when a belt MCP server was injected into the spec;
|
|
65
66
|
* `ready`/`failed` are filled from the harness's `started` event (its
|
|
66
|
-
* `mcp_servers[<belt>].status`); `toolEvidence` flips when any
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* `mcp_servers[<belt>].status`); `toolEvidence` flips when any exact belt tool
|
|
68
|
+
* actually runs. Startup failure lives in this state; an exact non-ok tool
|
|
69
|
+
* result lives in `toolErrors` and hard-fails under INV-030 while reusing
|
|
70
|
+
* INV-043's invocation-aware recovery key.
|
|
69
71
|
*/
|
|
70
72
|
export interface DelegationBeltState {
|
|
71
73
|
requested: boolean;
|
|
@@ -137,11 +139,7 @@ export interface AttemptTelemetry {
|
|
|
137
139
|
};
|
|
138
140
|
/** Per-usage-event billing split. Route can change across native retries,
|
|
139
141
|
* so this is deliberately not derived from the attempt's first route. */
|
|
140
|
-
usageCost:
|
|
141
|
-
cashUsd: number;
|
|
142
|
-
valuationUsd: number;
|
|
143
|
-
unknownUsd: number;
|
|
144
|
-
};
|
|
142
|
+
usageCost: AttemptUsageCost;
|
|
145
143
|
}
|
|
146
144
|
export declare function createAttemptTelemetry(policy: ExternalContextPolicy, webRequired: boolean, effectiveMode?: ExternalContextPolicy, requestRequirements?: RequestRequirementResolution[], requestedModel?: string | null,
|
|
147
145
|
/** The delegation-belt MCP server name injected into THIS attempt's spec, or
|
|
@@ -151,15 +149,6 @@ beltServerName?: string | null,
|
|
|
151
149
|
* namespace), or null when the browser was not injected (QA-040). Non-null
|
|
152
150
|
* marks the browser requested/armed. */
|
|
153
151
|
browserServerName?: string | null): AttemptTelemetry;
|
|
154
|
-
/**
|
|
155
|
-
* The delegation belt was requested (--delegate injected it) but never became
|
|
156
|
-
* operational: the harness reported the server `failed` and no belt tool ever
|
|
157
|
-
* ran (QA-024). This is the false-success trap — the harness may have answered
|
|
158
|
-
* from its own native subagent with no Claudexor sub-run provenance. A belt
|
|
159
|
-
* that was ready-but-unused is NOT unavailable (docs leave the spawn decision to
|
|
160
|
-
* the harness); only a startup failure counts.
|
|
161
|
-
*/
|
|
162
|
-
export declare function delegationBeltUnavailable(t: AttemptTelemetry): boolean;
|
|
163
152
|
/**
|
|
164
153
|
* QA-040: the browser was armed but never called while generic web evidence
|
|
165
154
|
* satisfied the run — a legitimately policy-satisfied run (e.g. web_search
|
|
@@ -185,6 +174,13 @@ export declare function setAttemptOutcome(t: AttemptTelemetry, opts: {
|
|
|
185
174
|
* incomplete veto rides HERE without flipping `status` — the lifecycle
|
|
186
175
|
* stays succeeded-class; applyability and the CLI exit read the axis. */
|
|
187
176
|
workState?: WorkState;
|
|
177
|
+
/** The lane's contract does NOT require a deliverable: a clean completion
|
|
178
|
+
* with an honestly empty answer stays a success (read-only ask/report,
|
|
179
|
+
* where "(no output)" is a valid outcome). Every harder axis still wins —
|
|
180
|
+
* a harness error, failed gate, unsatisfied web, or belt failure fails the
|
|
181
|
+
* attempt exactly as before; this only stops a MISSING deliverable from
|
|
182
|
+
* being counted as a contract failure on its own. */
|
|
183
|
+
emptyDeliverableAllowed?: boolean;
|
|
188
184
|
}): void;
|
|
189
185
|
/** Bounded telemetry summary for events/artifacts (full detail lives in telemetry.yaml). */
|
|
190
186
|
export declare function telemetrySummary(t: AttemptTelemetry): Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attemptTelemetry.d.ts","sourceRoot":"","sources":["../src/attemptTelemetry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,4BAA4B,EAC5B,YAAY,EACZ,QAAQ,EACR,SAAS,EACV,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"attemptTelemetry.d.ts","sourceRoot":"","sources":["../src/attemptTelemetry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,4BAA4B,EAC5B,YAAY,EACZ,QAAQ,EACR,SAAS,EACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,KAAK,2BAA2B,EAKjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC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OAAO,CAAC;IAChC;;6EAEyE;IACzE,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;yDAKqD;IACrD,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,GACA,IAAI,CAyBN;AAWD,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiE7E;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,CAAC,EAAE,gBAAgB,GAClB,sBAAsB,CAsFxB;AAED;;mEAEmE;AACnE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG;IACzE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC,CAcA;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,sBAAsB,EAAE,EACjC,QAAQ,EAAE,YAAY,GACrB,sBAAsB,CAAC,KAAK,CAAC,CAqB/B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAI3D"}
|
package/dist/attemptTelemetry.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { newAttemptUsageCost, observeAttemptUsageEvent, } from "./attemptUsageCost.js";
|
|
1
2
|
import { redactSecrets } from "@claudexor/util";
|
|
3
|
+
import * as belt from "./delegationToolEvidence.js";
|
|
2
4
|
import { classifyCompletedCrash, classifyRateLimit, classifyStatusError, classifyTransientSignal, } from "./transientClassify.js";
|
|
3
5
|
export { classifyAdapterThrow } from "./transientClassify.js";
|
|
4
6
|
export function createAttemptTelemetry(policy, webRequired, effectiveMode = policy, requestRequirements = [], requestedModel = null,
|
|
@@ -53,7 +55,7 @@ browserServerName = null) {
|
|
|
53
55
|
sideToolWorkReport: null,
|
|
54
56
|
outcome: null,
|
|
55
57
|
usage: { inputTokens: null, outputTokens: null, cachedInputTokens: null },
|
|
56
|
-
usageCost:
|
|
58
|
+
usageCost: newAttemptUsageCost(),
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
61
|
/** Add one present token field to a null-aware accumulator (null stays null
|
|
@@ -88,17 +90,6 @@ function observeBeltStartup(t, ev) {
|
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
|
-
/**
|
|
92
|
-
* The delegation belt was requested (--delegate injected it) but never became
|
|
93
|
-
* operational: the harness reported the server `failed` and no belt tool ever
|
|
94
|
-
* ran (QA-024). This is the false-success trap — the harness may have answered
|
|
95
|
-
* from its own native subagent with no Claudexor sub-run provenance. A belt
|
|
96
|
-
* that was ready-but-unused is NOT unavailable (docs leave the spawn decision to
|
|
97
|
-
* the harness); only a startup failure counts.
|
|
98
|
-
*/
|
|
99
|
-
export function delegationBeltUnavailable(t) {
|
|
100
|
-
return t.delegationBelt.requested && t.delegationBelt.failed && !t.delegationBelt.toolEvidence;
|
|
101
|
-
}
|
|
102
93
|
/**
|
|
103
94
|
* QA-040: does this tool ref belong to the engine-armed browser MCP? Adapters
|
|
104
95
|
* normalize browser calls as `kind:"mcp"` (codex `browser:browser_navigate`,
|
|
@@ -138,20 +129,19 @@ function bumpWebVerification(t, retrieval) {
|
|
|
138
129
|
* matching or tool-name heuristics.
|
|
139
130
|
*/
|
|
140
131
|
export function observeAttemptTelemetry(t, ev) {
|
|
141
|
-
// Delegation belt readiness (QA-024):
|
|
142
|
-
// MCP
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
if (ev.type === "started" && t.delegationBelt.requested) {
|
|
132
|
+
// Delegation belt readiness (QA-024): normalized startup/error events carry
|
|
133
|
+
// typed MCP server statuses. Read THAT server's status as first-class truth;
|
|
134
|
+
// a failed belt must never launder into a native-subagent success.
|
|
135
|
+
if (t.delegationBelt.requested && Array.isArray(ev.payload?.["mcp_servers"])) {
|
|
146
136
|
observeBeltStartup(t, ev);
|
|
147
137
|
}
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
138
|
+
// Exact adapter-neutral evidence distinguishes the belt from a native subagent;
|
|
139
|
+
// recovery uses matching ids when both exist, else legacy tool+kind+target.
|
|
140
|
+
const beltToolEvent = t.delegationBelt.requested &&
|
|
141
|
+
t.delegationBelt.serverName &&
|
|
142
|
+
belt.isDelegationBeltTool(ev.tool, t.delegationBelt.serverName);
|
|
143
|
+
if (beltToolEvent) {
|
|
144
|
+
t.delegationBelt.toolEvidence = true;
|
|
155
145
|
}
|
|
156
146
|
// Route evidence: remember the model identity the stream itself disclosed.
|
|
157
147
|
if (ev.observed_model && !t.observedModel)
|
|
@@ -164,29 +154,7 @@ export function observeAttemptTelemetry(t, ev) {
|
|
|
164
154
|
else if (ev.credential_route === "managed_api_key")
|
|
165
155
|
t.authMode = "api_key";
|
|
166
156
|
}
|
|
167
|
-
|
|
168
|
-
t.currentAuthMode = "local_session";
|
|
169
|
-
else if (ev.credential_route === "managed_api_key")
|
|
170
|
-
t.currentAuthMode = "api_key";
|
|
171
|
-
if (ev.type === "message" && ev.payload?.["auth_switched"] === true) {
|
|
172
|
-
if (ev.payload["to_auth_mode"] === "subscription")
|
|
173
|
-
t.currentAuthMode = "local_session";
|
|
174
|
-
if (ev.payload["to_auth_mode"] === "api_key")
|
|
175
|
-
t.currentAuthMode = "api_key";
|
|
176
|
-
}
|
|
177
|
-
if (ev.usage?.cost_usd) {
|
|
178
|
-
const usageMode = ev.credential_route === "vendor_native"
|
|
179
|
-
? "local_session"
|
|
180
|
-
: ev.credential_route === "managed_api_key"
|
|
181
|
-
? "api_key"
|
|
182
|
-
: t.currentAuthMode;
|
|
183
|
-
if (usageMode === "local_session")
|
|
184
|
-
t.usageCost.valuationUsd += ev.usage.cost_usd;
|
|
185
|
-
else if (usageMode === "api_key")
|
|
186
|
-
t.usageCost.cashUsd += ev.usage.cost_usd;
|
|
187
|
-
else
|
|
188
|
-
t.usageCost.unknownUsd += ev.usage.cost_usd;
|
|
189
|
-
}
|
|
157
|
+
t.currentAuthMode = observeAttemptUsageEvent(t.usageCost, ev, t.currentAuthMode);
|
|
190
158
|
// First-wins like the route: the source is decided once before spawn.
|
|
191
159
|
if (!t.authSource && ev.credential_source)
|
|
192
160
|
t.authSource = ev.credential_source;
|
|
@@ -271,9 +239,13 @@ export function observeAttemptTelemetry(t, ev) {
|
|
|
271
239
|
if (tool.status === undefined) {
|
|
272
240
|
// A result without a status must never silently count as ok.
|
|
273
241
|
t.statuslessResults += 1;
|
|
242
|
+
if (beltToolEvent)
|
|
243
|
+
belt.recordDelegationBeltResultFailure(t, tool, "required delegation belt tool result omitted status");
|
|
274
244
|
return;
|
|
275
245
|
}
|
|
276
246
|
if (tool.status === "cancelled" || tool.status === "denied") {
|
|
247
|
+
if (beltToolEvent)
|
|
248
|
+
belt.recordDelegationBeltResultFailure(t, tool, `required delegation belt tool result marked ${tool.status}`);
|
|
277
249
|
if (tool.kind === "web") {
|
|
278
250
|
t.web.attempted = true;
|
|
279
251
|
t.web.tool = tool.name;
|
|
@@ -316,18 +288,18 @@ export function observeAttemptTelemetry(t, ev) {
|
|
|
316
288
|
}
|
|
317
289
|
return;
|
|
318
290
|
}
|
|
319
|
-
// status === "ok":
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
|
|
291
|
+
// status === "ok": recovery needs the same tool + kind + target, plus the same
|
|
292
|
+
// non-null use id when both sides have one. A missing id retains the legacy
|
|
293
|
+
// tuple key for adapters and synthetic telemetry that cannot correlate calls.
|
|
294
|
+
const resultToolUseId = tool.use_id ?? null;
|
|
323
295
|
for (const err of t.toolErrors) {
|
|
324
|
-
// INV-043:
|
|
325
|
-
//
|
|
326
|
-
// tool must not clear its web error).
|
|
296
|
+
// INV-043: a later identical-looking invocation cannot launder an earlier
|
|
297
|
+
// error when both vendor records prove different invocation ids.
|
|
327
298
|
if (!err.recovered &&
|
|
328
299
|
err.tool === tool.name &&
|
|
329
300
|
err.kind === tool.kind &&
|
|
330
|
-
err.target === (tool.target ?? null)
|
|
301
|
+
err.target === (tool.target ?? null) &&
|
|
302
|
+
(err.toolUseId === null || resultToolUseId === null || err.toolUseId === resultToolUseId)) {
|
|
331
303
|
err.recovered = true;
|
|
332
304
|
}
|
|
333
305
|
}
|
|
@@ -339,12 +311,12 @@ export function observeAttemptTelemetry(t, ev) {
|
|
|
339
311
|
// legitimate alternative-route recovery, not laundering (blocking it
|
|
340
312
|
// would false-block the most common web workflow). What must NOT vanish
|
|
341
313
|
// is the DISCLOSURE: `failed` clears only when the success matches the
|
|
342
|
-
// failed
|
|
314
|
+
// failed invocation (INV-043 keying), so telemetry.yaml keeps the
|
|
343
315
|
// unrecovered failure + errorSummary visible even on satisfied runs.
|
|
344
316
|
t.web.satisfied = true;
|
|
345
|
-
// Derived rollup, single source of truth: the
|
|
317
|
+
// Derived rollup, single source of truth: the invocation-keyed
|
|
346
318
|
// toolErrors store (the recovery loop above already marked matching
|
|
347
|
-
// errors recovered). Multiple failed
|
|
319
|
+
// errors recovered). Multiple failed invocations stay disclosed until EACH
|
|
348
320
|
// recovers; a missing target never wildcards (exact null==null match).
|
|
349
321
|
t.web.failed = t.toolErrors.some((e) => e.kind === "web" && !e.recovered);
|
|
350
322
|
// Keep the summary in lockstep with the rollup: point at a live
|
|
@@ -399,16 +371,12 @@ export function toolWarnings(t) {
|
|
|
399
371
|
}
|
|
400
372
|
export function setAttemptOutcome(t, opts) {
|
|
401
373
|
const warnings = toolWarnings(t).length;
|
|
402
|
-
const contractFailed = !opts.deliverablePresent
|
|
403
|
-
|
|
404
|
-
//
|
|
405
|
-
//
|
|
406
|
-
//
|
|
407
|
-
|
|
408
|
-
// `failed`; a future finalizer that prefers a softer disclosure would flip
|
|
409
|
-
// this to `success_with_warnings` — the typed telemetry fact
|
|
410
|
-
// (delegation_belt.*) is what a consumer reads either way.
|
|
411
|
-
const beltUnavailable = delegationBeltUnavailable(t);
|
|
374
|
+
const contractFailed = (!opts.deliverablePresent && opts.emptyDeliverableAllowed !== true) ||
|
|
375
|
+
opts.gatesPassed === false;
|
|
376
|
+
// INV-030: after injection, startup failure or an unrecovered exact belt
|
|
377
|
+
// operation is an unsatisfied required capability. It can only ELEVATE
|
|
378
|
+
// severity, never soften into a warning or mask a harder terminal fact.
|
|
379
|
+
const beltUnavailable = belt.delegationBeltUnavailable(t) || belt.delegationBeltToolFailure(t);
|
|
412
380
|
const status = opts.webRequiredUnsatisfied
|
|
413
381
|
? "blocked"
|
|
414
382
|
: opts.harnessErrored || contractFailed || beltUnavailable
|
|
@@ -484,7 +452,7 @@ export function telemetrySummary(t) {
|
|
|
484
452
|
ready: t.delegationBelt.ready,
|
|
485
453
|
failed: t.delegationBelt.failed,
|
|
486
454
|
tool_evidence: t.delegationBelt.toolEvidence,
|
|
487
|
-
unavailable: delegationBeltUnavailable(t),
|
|
455
|
+
unavailable: belt.delegationBeltUnavailable(t),
|
|
488
456
|
},
|
|
489
457
|
}
|
|
490
458
|
: {}),
|
|
@@ -552,7 +520,7 @@ export function attemptTelemetryRecord(attemptId, harnessId, t) {
|
|
|
552
520
|
gates_passed: t.outcome?.gatesPassed ?? null,
|
|
553
521
|
harness_errored: t.outcome?.harnessErrored ?? false,
|
|
554
522
|
web_required_unsatisfied: t.outcome?.webRequiredUnsatisfied ?? false,
|
|
555
|
-
delegation_belt_unavailable: delegationBeltUnavailable(t),
|
|
523
|
+
delegation_belt_unavailable: belt.delegationBeltUnavailable(t),
|
|
556
524
|
tool_warnings_count: t.outcome?.toolWarningsCount ?? warnings.length,
|
|
557
525
|
status: t.outcome?.status ?? (warnings.length > 0 ? "success_with_warnings" : "success"),
|
|
558
526
|
...(t.outcome?.workState ? { work_state: t.outcome.workState } : {}),
|