@claudexor/orchestrator 1.0.1

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/attemptTelemetry.d.ts +82 -0
  4. package/dist/attemptTelemetry.d.ts.map +1 -0
  5. package/dist/attemptTelemetry.js +283 -0
  6. package/dist/attemptTelemetry.js.map +1 -0
  7. package/dist/diffReview.d.ts +32 -0
  8. package/dist/diffReview.d.ts.map +1 -0
  9. package/dist/diffReview.js +69 -0
  10. package/dist/diffReview.js.map +1 -0
  11. package/dist/finalVerifier.d.ts +25 -0
  12. package/dist/finalVerifier.d.ts.map +1 -0
  13. package/dist/finalVerifier.js +110 -0
  14. package/dist/finalVerifier.js.map +1 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +2 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/interaction.d.ts +22 -0
  20. package/dist/interaction.d.ts.map +1 -0
  21. package/dist/interaction.js +117 -0
  22. package/dist/interaction.js.map +1 -0
  23. package/dist/modelGovernance.d.ts +22 -0
  24. package/dist/modelGovernance.d.ts.map +1 -0
  25. package/dist/modelGovernance.js +33 -0
  26. package/dist/modelGovernance.js.map +1 -0
  27. package/dist/orchestratePlanner.d.ts +12 -0
  28. package/dist/orchestratePlanner.d.ts.map +1 -0
  29. package/dist/orchestratePlanner.js +91 -0
  30. package/dist/orchestratePlanner.js.map +1 -0
  31. package/dist/orchestrator.d.ts +380 -0
  32. package/dist/orchestrator.d.ts.map +1 -0
  33. package/dist/orchestrator.js +4927 -0
  34. package/dist/orchestrator.js.map +1 -0
  35. package/dist/reviewerPanel.d.ts +26 -0
  36. package/dist/reviewerPanel.d.ts.map +1 -0
  37. package/dist/reviewerPanel.js +146 -0
  38. package/dist/reviewerPanel.js.map +1 -0
  39. package/dist/runSupport.d.ts +178 -0
  40. package/dist/runSupport.d.ts.map +1 -0
  41. package/dist/runSupport.js +372 -0
  42. package/dist/runSupport.js.map +1 -0
  43. package/dist/runTerminals.d.ts +56 -0
  44. package/dist/runTerminals.d.ts.map +1 -0
  45. package/dist/runTerminals.js +124 -0
  46. package/dist/runTerminals.js.map +1 -0
  47. package/package.json +58 -0
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Run-support helpers: transient retry pacing, gate-derived protected paths,
3
+ * prompt constraints, harness-event redaction/payload projection, and the
4
+ * run summary/findings renderers. Pure functions — no orchestrator state.
5
+ */
6
+ import type { HarnessEvent, ModeKind, ProtectedPathApproval, ReviewFinding } from "@claudexor/schema";
7
+ import type { EventLog } from "@claudexor/event-log";
8
+ import type { CandidateEvidence } from "@claudexor/arbitration";
9
+ import type { BudgetObservation, InteractionAnswerSet } from "@claudexor/schema";
10
+ /**
11
+ * Relay cross-share: the prior planners' plans, injected into a later
12
+ * planner's prompt so the harnesses CONVERGE on an aligned plan instead of
13
+ * each planning in isolation. `runPlan` already iterates planners
14
+ * sequentially, so each leg after the first sees what the earlier ones
15
+ * proposed and is asked to reconcile/extend them (not blindly repeat).
16
+ */
17
+ export declare function relayPriorPlansSection(plans: {
18
+ id: string;
19
+ text: string;
20
+ }[]): string;
21
+ export interface TransientRetryPolicy {
22
+ maxRetries: number;
23
+ initialDelayMs: number;
24
+ maxDelayMs: number;
25
+ }
26
+ export declare function transientRetryDelayMs(nativeDelayMs: number | null, policy: TransientRetryPolicy, retryIndex: number): number;
27
+ export declare function gateProtectedPaths(commands: string[]): string[];
28
+ export declare function promptWithProtectedPathConstraint(prompt: string, protectedPaths: string[], autoProtectedPaths?: string[], approvals?: ProtectedPathApproval[]): string;
29
+ export declare function sleep(ms: number): Promise<void>;
30
+ export declare function redactHarnessEvent(ev: HarnessEvent): HarnessEvent;
31
+ export declare function harnessEventPayload(harnessId: string, attemptId: string, ev: HarnessEvent): Record<string, unknown>;
32
+ /**
33
+ * Deduplicate the known "final result repeats the last streamed message" shape
34
+ * (adjacent only). Legitimately repeated earlier messages are preserved — a
35
+ * whole-array dedupe would silently merge real output.
36
+ */
37
+ export declare function pushUniqueText(parts: string[], text: string): void;
38
+ export declare function formatFindings(findings: ReviewFinding[]): string;
39
+ export declare function renderSummary(runId: string, mode: ModeKind, decision: {
40
+ winner: string | null;
41
+ status: string;
42
+ outcome?: string;
43
+ why_winner: string;
44
+ apply_recommendation: string;
45
+ }, evidences: CandidateEvidence[], synthReason: string, reviewVerified: boolean): string;
46
+ /** Pure read: a referenced run's decision/work_product status, or null. */
47
+ export declare function readRunStatus(repoRoot: string, runId: string): string | null;
48
+ /** Pure read: a referenced run's recorded patch diff, or null. */
49
+ export declare function readRunPatch(repoRoot: string, runId: string): string | null;
50
+ /** Config-derived runtime knobs (pure projections of ResolvedConfig). */
51
+ export interface ResolvedConfigLike {
52
+ global: {
53
+ routing: {
54
+ env_inheritance: "mirror_native" | "clean";
55
+ };
56
+ runtime: {
57
+ transient_retry: {
58
+ max_retries: number;
59
+ initial_delay_ms: number;
60
+ max_delay_ms: number;
61
+ };
62
+ reviewer_timeout_ms: number;
63
+ harness_inactivity_timeout_ms: number;
64
+ };
65
+ };
66
+ }
67
+ export declare function envInheritance(cfg: ResolvedConfigLike): "mirror_native" | "clean";
68
+ export declare function transientRetryPolicy(cfg: ResolvedConfigLike): TransientRetryPolicy;
69
+ export declare function reviewerTimeoutMs(cfg: ResolvedConfigLike): number;
70
+ export declare function harnessInactivityTimeoutMs(cfg: ResolvedConfigLike): number;
71
+ /** Typed auth-switch disclosure: adapters mark auth_switched on a message;
72
+ * the run event log gets the typed route.fallback payload. */
73
+ export declare function observeAuthSwitch(log: EventLog | undefined, harnessId: string, attemptId: string, ev: HarnessEvent): void;
74
+ /** Observe ALL budget/quota signals from one harness event and disclose
75
+ * quota pressure ONCE per attempt (crossing semantics). One owner — the
76
+ * agent, plan, and read-only loops all consume this instead of pasting the
77
+ * loop (critic finding: triplicated logic drifts). */
78
+ export declare function observeBudgetSignals(ledger: {
79
+ observe(o: BudgetObservation): void;
80
+ }, log: {
81
+ emit(type: string, payload: Record<string, unknown>): unknown;
82
+ } | undefined, harnessId: string, attemptId: string, ev: HarnessEvent, state: {
83
+ quotaPressureDisclosed: boolean;
84
+ }): void;
85
+ /** Stall rotation with an HONEST route event: picks via
86
+ * pickStallRotationIdx and emits route.fallback.started only when the idx
87
+ * actually moved — STAY (every alternative cooling) is a retry, not a
88
+ * fallback. Returns the (possibly unchanged) idx. */
89
+ export declare function rotateOnStall(poolIds: string[], currentIdx: number, ledger: {
90
+ headroom(id: string): number;
91
+ cooldownActive(id: string): boolean;
92
+ }, tried: ReadonlySet<string>, log: {
93
+ emit(type: string, payload: Record<string, unknown>): unknown;
94
+ }, fromHarness: string | null): number;
95
+ /** Stall-rotation pick: UNTRIED candidates first (the caller's exhaustion
96
+ * check counts distinct harnesses, so headroom alone could ping-pong between
97
+ * two strong harnesses and starve a third), then by remaining rate-window
98
+ * headroom, cooldowns excluded, round-robin order among equals. Pure. */
99
+ export declare function pickStallRotationIdx(poolIds: string[], currentIdx: number, ledger: {
100
+ headroom(id: string): number;
101
+ cooldownActive(id: string): boolean;
102
+ }, tried?: ReadonlySet<string>): number;
103
+ /** Routing metrics: one settled sample per CLEAN attempt (advisory input;
104
+ * failures never fail the run). Errored/cancelled attempts are NOT samples —
105
+ * a fast-failing harness must not earn a flattering latency average (the
106
+ * router divides by latency). Duration = stream time only (gates excluded). */
107
+ export declare function recordCleanAttemptMetrics(configDir: string, harnessId: string, sample: {
108
+ costUsd: number;
109
+ streamMs: number;
110
+ errored: boolean;
111
+ aborted: boolean;
112
+ }): void;
113
+ /** Build the ISOLATED-ENVELOPE sub-run input for an orchestrate SAFE step
114
+ * (start_run/race): inPlace forced false, no thread binding, no nested
115
+ * autonomy, recursion depth incremented. Pure construction; the caller
116
+ * asserts the envelope invariant. */
117
+ export declare function buildEnvelopeSubInput<T extends {
118
+ repoRoot: string;
119
+ portfolio?: unknown;
120
+ web?: unknown;
121
+ externalContextPolicy?: unknown;
122
+ signal?: AbortSignal;
123
+ orchestrateDepth?: number;
124
+ }>(input: T, call: {
125
+ tool: "start_run" | "race";
126
+ prompt: string;
127
+ mode?: string;
128
+ n?: number;
129
+ harness?: string | null;
130
+ }, remainingUsd: number | null): {
131
+ repoRoot: string;
132
+ prompt: string;
133
+ mode: "agent" | "ask" | "plan" | "audit" | "orchestrate";
134
+ n: number | undefined;
135
+ harnesses: string[] | undefined;
136
+ portfolio: unknown;
137
+ maxUsd: number | null;
138
+ web: unknown;
139
+ externalContextPolicy: unknown;
140
+ signal: AbortSignal | undefined;
141
+ inPlace: boolean;
142
+ threadId: undefined;
143
+ executionRoot: undefined;
144
+ autonomy: undefined;
145
+ resumeSessions: undefined;
146
+ onSessionObserved: undefined;
147
+ orchestrateDepth: number;
148
+ };
149
+ /**
150
+ * Deliver typed answers to a referenced pending interaction for the
151
+ * orchestrate `answer_question` SAFE step (read-only w.r.t. the tree). The
152
+ * daemon owns the live registry; without an injected service this context
153
+ * cannot reach it, so SKIP honestly.
154
+ *
155
+ * INVARIANT: safe sub-runs are NON-interactive (their sub-input omits
156
+ * onInteraction, so a start_run/race sub-run never raises an interaction and
157
+ * nothing registers under its run id). The only pending interactions
158
+ * therefore belong to the ORCHESTRATE run itself, so `input.runId` is the
159
+ * correct registry key. If sub-runs are ever made interactive, the
160
+ * answer_question plan call MUST carry the target sub-run id instead (the
161
+ * registry is keyed by runId+interactionId).
162
+ */
163
+ export declare function deliverPlanAnswer(input: {
164
+ runId?: string;
165
+ answerInteraction?: (runId: string, interactionId: string, answers: InteractionAnswerSet) => Promise<boolean> | boolean;
166
+ }, call: {
167
+ interaction_id: string;
168
+ answers: Array<{
169
+ question_id: string;
170
+ selected_labels: string[];
171
+ free_text: string | null;
172
+ }>;
173
+ }): Promise<{
174
+ status: "done" | "skipped";
175
+ runId: null;
176
+ detail: string;
177
+ }>;
178
+ //# sourceMappingURL=runSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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B7H;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CACzH,EACD,IAAI,EAAE;IACJ,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CAC9F,GACA,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBtE"}
@@ -0,0 +1,372 @@
1
+ import { FallbackReason as FallbackReasonSchema, RouteFallbackPayload as RouteFallbackPayloadSchema } from "@claudexor/schema";
2
+ import { isBlocking } from "@claudexor/schema";
3
+ import { redactSecrets } from "@claudexor/util";
4
+ import { observationsFromEvent, recordHarnessMetric } from "@claudexor/budget";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { ArtifactStore } from "@claudexor/artifact-store";
8
+ /**
9
+ * Relay cross-share: the prior planners' plans, injected into a later
10
+ * planner's prompt so the harnesses CONVERGE on an aligned plan instead of
11
+ * each planning in isolation. `runPlan` already iterates planners
12
+ * sequentially, so each leg after the first sees what the earlier ones
13
+ * proposed and is asked to reconcile/extend them (not blindly repeat).
14
+ */
15
+ export function relayPriorPlansSection(plans) {
16
+ if (plans.length === 0)
17
+ return "";
18
+ // No silent truncation: a relayed plan cut at the cap carries an explicit
19
+ // in-band marker so the next planner KNOWS it saw a prefix, not the whole.
20
+ const CAP = 4000;
21
+ const blocks = plans
22
+ .map((p) => {
23
+ const cut = p.text.length > CAP;
24
+ const body = cut ? `${p.text.slice(0, CAP)}\n[... plan truncated at ${CAP} chars — the source run's plan artifact carries the full text]` : p.text;
25
+ return `### Plan already proposed by ${p.id}\n${body}`;
26
+ })
27
+ .join("\n\n");
28
+ return `\n\n---\nOTHER HARNESSES HAVE ALREADY PROPOSED PLANS FOR THIS SAME TASK (below). Read them, then produce YOUR plan: build on what is solid, RECONCILE the differences, and EXPLICITLY call out where you disagree and why. Do not blindly repeat them — converge toward one aligned plan.\n\n${blocks}\n---\n`;
29
+ }
30
+ export function transientRetryDelayMs(nativeDelayMs, policy, retryIndex) {
31
+ const fallback = policy.initialDelayMs * 2 ** retryIndex;
32
+ const delay = nativeDelayMs ?? fallback;
33
+ return Math.min(delay, policy.maxDelayMs);
34
+ }
35
+ export function gateProtectedPaths(commands) {
36
+ if (commands.length === 0)
37
+ return [];
38
+ const paths = new Set([
39
+ "package.json",
40
+ "**/package.json",
41
+ "test/**",
42
+ "tests/**",
43
+ "__tests__/**",
44
+ "**/*.test.*",
45
+ "**/*.spec.*",
46
+ ]);
47
+ for (const command of commands) {
48
+ for (const raw of command.split(/\s+/)) {
49
+ const token = raw.trim().replace(/^['"]|['"]$/g, "");
50
+ if (!token ||
51
+ token.startsWith("-") ||
52
+ token.includes("=") ||
53
+ token.includes("://") ||
54
+ token.startsWith("/"))
55
+ continue;
56
+ if (!token.includes("/") && !token.includes("."))
57
+ continue;
58
+ const clean = token.replace(/^[./]+/, "").replace(/[),;]+$/g, "");
59
+ if (!clean || clean === "package.json")
60
+ continue;
61
+ const testish = clean.startsWith("test/") ||
62
+ clean.startsWith("tests/") ||
63
+ clean.startsWith("__tests__/") ||
64
+ clean.includes(".test.") ||
65
+ clean.includes(".spec.");
66
+ if (testish)
67
+ paths.add(clean.endsWith("/") ? `${clean}**` : clean);
68
+ }
69
+ }
70
+ return [...paths];
71
+ }
72
+ export function promptWithProtectedPathConstraint(prompt, protectedPaths, autoProtectedPaths = [], approvals = []) {
73
+ if (protectedPaths.length === 0 && autoProtectedPaths.length === 0)
74
+ return prompt;
75
+ const specLines = protectedPaths.length
76
+ ? [
77
+ "",
78
+ "Engine constraint: do not edit spec/config protected paths unless the frozen task contract explicitly asks for it. Protected paths:",
79
+ ...protectedPaths.slice(0, 20).map((p) => `- ${p}`),
80
+ ]
81
+ : [];
82
+ const approvalLines = approvals.length
83
+ ? [
84
+ "",
85
+ "Approved auto-protected gate/test path changes for this run:",
86
+ ...approvals.slice(0, 20).map((a) => `- ${a.path}${a.reason ? ` (${a.reason})` : ""}`),
87
+ ]
88
+ : [];
89
+ const autoLines = autoProtectedPaths.length
90
+ ? [
91
+ "",
92
+ "Engine constraint: do not edit auto-protected gate/test paths, test commands, or package test scripts unless the user explicitly asked to change tests. Auto-protected paths:",
93
+ ...autoProtectedPaths.slice(0, 20).map((p) => `- ${p}`),
94
+ ...approvalLines,
95
+ ]
96
+ : [];
97
+ return [
98
+ prompt,
99
+ ...specLines,
100
+ ...autoLines,
101
+ ].join("\n");
102
+ }
103
+ export function sleep(ms) {
104
+ if (ms <= 0)
105
+ return Promise.resolve();
106
+ return new Promise((resolve) => setTimeout(resolve, ms));
107
+ }
108
+ export function redactHarnessEvent(ev) {
109
+ try {
110
+ return JSON.parse(redactSecrets(JSON.stringify(ev)));
111
+ }
112
+ catch {
113
+ return {
114
+ ...ev,
115
+ text: ev.text ? redactSecrets(ev.text) : undefined,
116
+ error: ev.error ? redactSecrets(ev.error) : undefined,
117
+ payload: ev.payload ? { redacted: true } : undefined,
118
+ };
119
+ }
120
+ }
121
+ export function harnessEventPayload(harnessId, attemptId, ev) {
122
+ const safe = redactHarnessEvent(ev);
123
+ const title = safe.error ??
124
+ safe.text ??
125
+ (safe.usage
126
+ ? `usage: ${safe.usage.input_tokens ?? 0} in / ${safe.usage.output_tokens ?? 0} out`
127
+ : safe.type);
128
+ return {
129
+ harness_id: harnessId,
130
+ attempt_id: attemptId,
131
+ session_id: safe.session_id,
132
+ type: safe.type,
133
+ title: String(title).slice(0, 500),
134
+ text: safe.text,
135
+ error: safe.error,
136
+ usage: safe.usage,
137
+ observed_model: safe.observed_model,
138
+ tool: safe.tool,
139
+ interaction: safe.interaction,
140
+ payload: safe.payload,
141
+ };
142
+ }
143
+ /**
144
+ * Deduplicate the known "final result repeats the last streamed message" shape
145
+ * (adjacent only). Legitimately repeated earlier messages are preserved — a
146
+ * whole-array dedupe would silently merge real output.
147
+ */
148
+ export function pushUniqueText(parts, text) {
149
+ const normalized = text.trim();
150
+ if (!normalized)
151
+ return;
152
+ const last = parts[parts.length - 1]?.trim();
153
+ if (last === normalized)
154
+ return;
155
+ parts.push(normalized);
156
+ }
157
+ export function formatFindings(findings) {
158
+ if (findings.length === 0)
159
+ return "(no findings recorded)";
160
+ return findings
161
+ .map((f) => `- [${f.severity}/${f.status}] ${f.claim}` +
162
+ (f.evidence.files.length > 0
163
+ ? ` (${f.evidence.files.map((x) => x.path).join(", ")})`
164
+ : "") +
165
+ (f.proposed_fix ? ` -> fix: ${f.proposed_fix}` : ""))
166
+ .join("\n");
167
+ }
168
+ export function renderSummary(runId, mode, decision, evidences, synthReason, reviewVerified) {
169
+ return ([
170
+ `# Run ${runId} (${mode})`,
171
+ "",
172
+ `- Status: ${decision.status}`,
173
+ `- Outcome: ${decision.outcome ?? "unknown"}`,
174
+ `- Winner: ${decision.winner ?? "none"}`,
175
+ `- Apply: ${decision.apply_recommendation}`,
176
+ `- Review verified (cross-family): ${reviewVerified}`,
177
+ `- Synthesis: ${synthReason}`,
178
+ "",
179
+ "## Candidates",
180
+ ...evidences.map((e) => `- ${e.label} (${e.attemptId}): gates ${e.testsPassed}/${e.testsTotal}, blockers ${e.findings.filter((f) => isBlocking(f)).length}, cleanReview ${e.finalReviewClean}`),
181
+ "",
182
+ "## Why winner",
183
+ decision.why_winner,
184
+ ].join("\n") + "\n");
185
+ }
186
+ /** Pure read: a referenced run's decision/work_product status, or null. */
187
+ export function readRunStatus(repoRoot, runId) {
188
+ const store = new ArtifactStore(repoRoot);
189
+ const sub = store.runPaths(runId);
190
+ const decision = store.readYaml(join(sub.arbitrationDir, "decision.yaml"));
191
+ const wp = store.readYaml(join(sub.finalDir, "work_product.yaml"));
192
+ if (!decision && !wp)
193
+ return null;
194
+ const parts = [];
195
+ if (decision?.status)
196
+ parts.push(`decision=${decision.status}`);
197
+ if (wp?.meta?.["result_kind"])
198
+ parts.push(`result_kind=${String(wp.meta["result_kind"])}`);
199
+ if (wp?.meta?.["apply_state"])
200
+ parts.push(`apply_state=${String(wp.meta["apply_state"])}`);
201
+ return parts.length > 0 ? parts.join(", ") : `run ${runId}: artifacts present`;
202
+ }
203
+ /** Pure read: a referenced run's recorded patch diff, or null. */
204
+ export function readRunPatch(repoRoot, runId) {
205
+ const store = new ArtifactStore(repoRoot);
206
+ const sub = store.runPaths(runId);
207
+ const path = join(sub.finalDir, "patch.diff");
208
+ return existsSync(path) ? readFileSync(path, "utf8") : null;
209
+ }
210
+ export function envInheritance(cfg) {
211
+ return cfg.global.routing.env_inheritance;
212
+ }
213
+ export function transientRetryPolicy(cfg) {
214
+ const c = cfg.global.runtime.transient_retry;
215
+ return { maxRetries: c.max_retries, initialDelayMs: c.initial_delay_ms, maxDelayMs: c.max_delay_ms };
216
+ }
217
+ export function reviewerTimeoutMs(cfg) {
218
+ return cfg.global.runtime.reviewer_timeout_ms;
219
+ }
220
+ export function harnessInactivityTimeoutMs(cfg) {
221
+ return cfg.global.runtime.harness_inactivity_timeout_ms;
222
+ }
223
+ /** Typed auth-switch disclosure: adapters mark auth_switched on a message;
224
+ * the run event log gets the typed route.fallback payload. */
225
+ export function observeAuthSwitch(log, harnessId, attemptId, ev) {
226
+ if (!log || ev.type !== "message" || ev.payload?.["auth_switched"] !== true)
227
+ return;
228
+ // Most auth_switched markers mean the preferred auth route was unavailable,
229
+ // so the default reason is `auth_unavailable`. Adapters may override with a
230
+ // more specific typed reason, e.g. `readiness_preferred` when auto selects a
231
+ // smoke-proven route for reliability/cost transparency.
232
+ const overrideReason = FallbackReasonSchema.safeParse(ev.payload?.["reason"]);
233
+ try {
234
+ log.emit("route.fallback.auth_switched", RouteFallbackPayloadSchema.parse({
235
+ from_harness: harnessId,
236
+ to_harness: harnessId,
237
+ from_auth_mode: ev.payload?.["from_auth_mode"],
238
+ to_auth_mode: ev.payload?.["to_auth_mode"],
239
+ reason: overrideReason.success ? overrideReason.data : "auth_unavailable",
240
+ attempt_id: attemptId,
241
+ }));
242
+ }
243
+ catch {
244
+ /* a malformed marker must not fail the run */
245
+ }
246
+ }
247
+ /** Observe ALL budget/quota signals from one harness event and disclose
248
+ * quota pressure ONCE per attempt (crossing semantics). One owner — the
249
+ * agent, plan, and read-only loops all consume this instead of pasting the
250
+ * loop (critic finding: triplicated logic drifts). */
251
+ export function observeBudgetSignals(ledger, log, harnessId, attemptId, ev, state) {
252
+ for (const obs of observationsFromEvent(harnessId, ev)) {
253
+ ledger.observe(obs);
254
+ if (obs.kind === "used_percent" && (obs.used_percent ?? 0) >= 50 && !state.quotaPressureDisclosed) {
255
+ state.quotaPressureDisclosed = true;
256
+ log?.emit("budget.quota_pressure", {
257
+ harness_id: harnessId,
258
+ attempt_id: attemptId,
259
+ used_percent: obs.used_percent,
260
+ resets_at: obs.resets_at ?? null,
261
+ });
262
+ }
263
+ }
264
+ }
265
+ /** Stall rotation with an HONEST route event: picks via
266
+ * pickStallRotationIdx and emits route.fallback.started only when the idx
267
+ * actually moved — STAY (every alternative cooling) is a retry, not a
268
+ * fallback. Returns the (possibly unchanged) idx. */
269
+ export function rotateOnStall(poolIds, currentIdx, ledger, tried, log, fromHarness) {
270
+ const pickedIdx = pickStallRotationIdx(poolIds, currentIdx, ledger, tried);
271
+ if (pickedIdx !== currentIdx) {
272
+ log.emit("route.fallback.started", {
273
+ from_harness: fromHarness,
274
+ to_harness: poolIds[pickedIdx],
275
+ reason: "stall",
276
+ headroom: ledger.headroom(poolIds[pickedIdx]),
277
+ });
278
+ }
279
+ return pickedIdx;
280
+ }
281
+ /** Stall-rotation pick: UNTRIED candidates first (the caller's exhaustion
282
+ * check counts distinct harnesses, so headroom alone could ping-pong between
283
+ * two strong harnesses and starve a third), then by remaining rate-window
284
+ * headroom, cooldowns excluded, round-robin order among equals. Pure. */
285
+ export function pickStallRotationIdx(poolIds, currentIdx, ledger, tried = new Set()) {
286
+ if (poolIds.length === 0)
287
+ return currentIdx; // total: never NaN via %0
288
+ const rank = (candidates) => candidates.sort((a, b) => ledger.headroom(b.id) - ledger.headroom(a.id) ||
289
+ ((a.idx - currentIdx + poolIds.length) % poolIds.length) -
290
+ ((b.idx - currentIdx + poolIds.length) % poolIds.length))[0];
291
+ const eligible = poolIds
292
+ .map((id, idx) => ({ id, idx }))
293
+ .filter(({ idx, id }) => idx !== currentIdx && !ledger.cooldownActive(id));
294
+ const next = rank(eligible.filter(({ id }) => !tried.has(id))) ?? rank(eligible);
295
+ // Every alternative cooling: STAY — retrying the stalled-but-not-throttled
296
+ // current harness beats hopping onto a known rate-limited one.
297
+ return next ? next.idx : currentIdx;
298
+ }
299
+ /** Routing metrics: one settled sample per CLEAN attempt (advisory input;
300
+ * failures never fail the run). Errored/cancelled attempts are NOT samples —
301
+ * a fast-failing harness must not earn a flattering latency average (the
302
+ * router divides by latency). Duration = stream time only (gates excluded). */
303
+ export function recordCleanAttemptMetrics(configDir, harnessId, sample) {
304
+ if (sample.errored || sample.aborted)
305
+ return;
306
+ recordHarnessMetric(configDir, harnessId, {
307
+ costUsd: sample.costUsd > 0 ? sample.costUsd : null,
308
+ durationMs: sample.streamMs,
309
+ });
310
+ }
311
+ /** Build the ISOLATED-ENVELOPE sub-run input for an orchestrate SAFE step
312
+ * (start_run/race): inPlace forced false, no thread binding, no nested
313
+ * autonomy, recursion depth incremented. Pure construction; the caller
314
+ * asserts the envelope invariant. */
315
+ export function buildEnvelopeSubInput(input, call, remainingUsd) {
316
+ return {
317
+ repoRoot: input.repoRoot,
318
+ prompt: call.prompt,
319
+ mode: (call.tool === "start_run" ? (call.mode ?? "agent") : "agent"),
320
+ n: call.tool === "race" ? call.n : undefined,
321
+ harnesses: call.tool === "start_run" && call.harness ? [call.harness] : undefined,
322
+ portfolio: input.portfolio,
323
+ // Aggregate budget: the sub-run gets only the REMAINING headroom.
324
+ maxUsd: remainingUsd,
325
+ web: input.web,
326
+ externalContextPolicy: input.externalContextPolicy,
327
+ signal: input.signal,
328
+ // SAFETY: isolated envelope, never the live in-place thread tree.
329
+ inPlace: false,
330
+ threadId: undefined,
331
+ executionRoot: undefined,
332
+ autonomy: undefined,
333
+ resumeSessions: undefined,
334
+ onSessionObserved: undefined,
335
+ orchestrateDepth: (input.orchestrateDepth ?? 0) + 1,
336
+ };
337
+ }
338
+ /**
339
+ * Deliver typed answers to a referenced pending interaction for the
340
+ * orchestrate `answer_question` SAFE step (read-only w.r.t. the tree). The
341
+ * daemon owns the live registry; without an injected service this context
342
+ * cannot reach it, so SKIP honestly.
343
+ *
344
+ * INVARIANT: safe sub-runs are NON-interactive (their sub-input omits
345
+ * onInteraction, so a start_run/race sub-run never raises an interaction and
346
+ * nothing registers under its run id). The only pending interactions
347
+ * therefore belong to the ORCHESTRATE run itself, so `input.runId` is the
348
+ * correct registry key. If sub-runs are ever made interactive, the
349
+ * answer_question plan call MUST carry the target sub-run id instead (the
350
+ * registry is keyed by runId+interactionId).
351
+ */
352
+ export async function deliverPlanAnswer(input, call) {
353
+ if (!input.answerInteraction) {
354
+ return { status: "skipped", runId: null, detail: "no live interaction surface in this context" };
355
+ }
356
+ const delivered = await input.answerInteraction(input.runId ?? "", call.interaction_id, {
357
+ interaction_id: call.interaction_id,
358
+ answers: call.answers.map((a) => ({
359
+ question_id: a.question_id,
360
+ selected_labels: a.selected_labels,
361
+ free_text: a.free_text,
362
+ })),
363
+ });
364
+ return {
365
+ status: delivered ? "done" : "skipped",
366
+ runId: null,
367
+ detail: delivered
368
+ ? `delivered answers to ${call.interaction_id}`
369
+ : `interaction ${call.interaction_id} not found / already resolved`,
370
+ };
371
+ }
372
+ //# sourceMappingURL=runSupport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runSupport.js","sourceRoot":"","sources":["../src/runSupport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/H,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAqC;IAC1E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,0EAA0E;IAC1E,2EAA2E;IAC3E,MAAM,GAAG,GAAG,IAAI,CAAC;IACjB,MAAM,MAAM,GAAG,KAAK;SACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAChC,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,4BAA4B,GAAG,gEAAgE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnJ,OAAO,gCAAgC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;IACzD,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;IAChB,OAAO,gSAAgS,MAAM,SAAS,CA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B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,6CAA6C,EAAE,CAAC;IACnG,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE;QACtF,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChC,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,eAAe,EAAE,CAAC,CAAC,eAAe;YAClC,SAAS,EAAE,CAAC,CAAC,SAAS;SACvB,CAAC,CAAC;KACJ,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QACtC,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,SAAS;YACf,CAAC,CAAC,wBAAwB,IAAI,CAAC,cAAc,EAAE;YAC/C,CAAC,CAAC,eAAe,IAAI,CAAC,cAAc,+BAA+B;KACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ModeKind } from "@claudexor/schema";
2
+ import type { ArtifactStore } from "@claudexor/artifact-store";
3
+ import type { EventLog } from "@claudexor/event-log";
4
+ import type { OrchestratorResult } from "./orchestrator.js";
5
+ export interface AnnouncedRunContext {
6
+ log: EventLog;
7
+ store: ArtifactStore;
8
+ paths: ReturnType<ArtifactStore["runPaths"]>;
9
+ runId: string;
10
+ taskId: string;
11
+ mode: ModeKind;
12
+ /** Failure phase label when the net has to stamp the terminal. */
13
+ phase: string;
14
+ /** Settled ledger spend snapshot — failure/cancel terminals must account
15
+ * for money already spent exactly like success terminals do. */
16
+ spend?: () => number;
17
+ }
18
+ export declare function writeFailure(store: ArtifactStore, paths: ReturnType<ArtifactStore["runPaths"]>, failure: {
19
+ phase: string;
20
+ category: string;
21
+ safeMessage: string;
22
+ harnessId?: string;
23
+ attemptId?: string;
24
+ rawDetailRef?: string;
25
+ logRefs?: string[];
26
+ eventRefs?: string[];
27
+ runDir?: string;
28
+ nextActions?: string[];
29
+ }): void;
30
+ /**
31
+ * Terminal result for a cancelled run: emits run.failed with status
32
+ * "cancelled" so every mode ends consistently. `writeTelemetry` carries the
33
+ * PARTIAL attempt telemetry collected before the abort — a cancelled run
34
+ * must still account for what it spent and observed; it used to be
35
+ * written only by convergence.
36
+ */
37
+ export declare function cancelledResult(log: EventLog, runId: string, taskId: string, mode: ModeKind, runDir: string, candidates: {
38
+ attemptId: string;
39
+ harnessId: string;
40
+ status: string;
41
+ }[], writeTelemetry?: () => void, spendUsd?: number | null): OrchestratorResult;
42
+ /**
43
+ * Terminal safety net for an unexpected throw in a post-announce phase.
44
+ * Every run must end with failure.yaml + summary + a terminal run.failed
45
+ * event.
46
+ */
47
+ export declare function failTerminally(log: EventLog, store: ArtifactStore, paths: ReturnType<ArtifactStore["runPaths"]>, runId: string, taskId: string, mode: ModeKind, phase: string, err: unknown, spendUsd?: number | null): OrchestratorResult;
48
+ /**
49
+ * Whole-strategy terminal net: run `body`; if it throws AFTER announcing,
50
+ * stamp terminal artifacts instead of orphaning the run. Pre-announce throws
51
+ * keep the loud-request contract (the caller gets the error; no run dir
52
+ * exists). An abort surfaced as a throw is a CANCELLED terminal, not an
53
+ * internal failure.
54
+ */
55
+ export declare function guardAnnouncedRun(signal: AbortSignal | undefined, body: (announce: (a: AnnouncedRunContext) => void) => Promise<OrchestratorResult>): Promise<OrchestratorResult>;
56
+ //# sourceMappingURL=runTerminals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runTerminals.d.ts","sourceRoot":"","sources":["../src/runTerminals.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2B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