@claudexor/orchestrator 4.1.0 → 4.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.
Files changed (121) hide show
  1. package/dist/account-pool.d.ts +11 -0
  2. package/dist/account-pool.d.ts.map +1 -1
  3. package/dist/account-pool.js +9 -0
  4. package/dist/account-pool.js.map +1 -1
  5. package/dist/account-resolution.d.ts +3 -0
  6. package/dist/account-resolution.d.ts.map +1 -1
  7. package/dist/account-resolution.js +1 -0
  8. package/dist/account-resolution.js.map +1 -1
  9. package/dist/attemptTelemetry.d.ts +4 -6
  10. package/dist/attemptTelemetry.d.ts.map +1 -1
  11. package/dist/attemptTelemetry.js +1 -1
  12. package/dist/attemptTelemetry.js.map +1 -1
  13. package/dist/budgetFailure.d.ts +4 -1
  14. package/dist/budgetFailure.d.ts.map +1 -1
  15. package/dist/budgetFailure.js +4 -2
  16. package/dist/budgetFailure.js.map +1 -1
  17. package/dist/candidateEvidence.d.ts.map +1 -1
  18. package/dist/candidateEvidence.js +7 -2
  19. package/dist/candidateEvidence.js.map +1 -1
  20. package/dist/candidateOutputs.d.ts.map +1 -1
  21. package/dist/candidateOutputs.js +6 -0
  22. package/dist/candidateOutputs.js.map +1 -1
  23. package/dist/candidateReview.d.ts +3 -1
  24. package/dist/candidateReview.d.ts.map +1 -1
  25. package/dist/candidateReview.js +6 -1
  26. package/dist/candidateReview.js.map +1 -1
  27. package/dist/candidateTerminals.d.ts +12 -1
  28. package/dist/candidateTerminals.d.ts.map +1 -1
  29. package/dist/candidateTerminals.js +51 -21
  30. package/dist/candidateTerminals.js.map +1 -1
  31. package/dist/captureRefusal.d.ts +28 -0
  32. package/dist/captureRefusal.d.ts.map +1 -0
  33. package/dist/captureRefusal.js +54 -0
  34. package/dist/captureRefusal.js.map +1 -0
  35. package/dist/continuity-terminal.d.ts +3 -1
  36. package/dist/continuity-terminal.d.ts.map +1 -1
  37. package/dist/continuity-terminal.js.map +1 -1
  38. package/dist/contract-gates.d.ts +10 -2
  39. package/dist/contract-gates.d.ts.map +1 -1
  40. package/dist/contract-gates.js +14 -1
  41. package/dist/contract-gates.js.map +1 -1
  42. package/dist/credential-profile-rotation.js +2 -3
  43. package/dist/credential-profile-rotation.js.map +1 -1
  44. package/dist/delegationFailure.d.ts +104 -7
  45. package/dist/delegationFailure.d.ts.map +1 -1
  46. package/dist/delegationFailure.js +47 -31
  47. package/dist/delegationFailure.js.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/inrun-continuity-types.d.ts +13 -1
  51. package/dist/inrun-continuity-types.d.ts.map +1 -1
  52. package/dist/inrun-continuity.d.ts +9 -2
  53. package/dist/inrun-continuity.d.ts.map +1 -1
  54. package/dist/inrun-continuity.js +43 -23
  55. package/dist/inrun-continuity.js.map +1 -1
  56. package/dist/inrun-continuity.test-support.d.ts +6 -2
  57. package/dist/inrun-continuity.test-support.d.ts.map +1 -1
  58. package/dist/inrun-continuity.test-support.js +4 -1
  59. package/dist/inrun-continuity.test-support.js.map +1 -1
  60. package/dist/orchestrator-credentials.d.ts +5 -4
  61. package/dist/orchestrator-credentials.d.ts.map +1 -1
  62. package/dist/orchestrator-credentials.js +7 -4
  63. package/dist/orchestrator-credentials.js.map +1 -1
  64. package/dist/orchestrator.d.ts +11 -3
  65. package/dist/orchestrator.d.ts.map +1 -1
  66. package/dist/orchestrator.js +341 -414
  67. package/dist/orchestrator.js.map +1 -1
  68. package/dist/persistedPatch.js +2 -2
  69. package/dist/persistedPatch.js.map +1 -1
  70. package/dist/pool-attempt-evidence.d.ts +62 -0
  71. package/dist/pool-attempt-evidence.d.ts.map +1 -0
  72. package/dist/pool-attempt-evidence.js +153 -0
  73. package/dist/pool-attempt-evidence.js.map +1 -0
  74. package/dist/pre-progress-refusal.d.ts +43 -6
  75. package/dist/pre-progress-refusal.d.ts.map +1 -1
  76. package/dist/pre-progress-refusal.js +53 -8
  77. package/dist/pre-progress-refusal.js.map +1 -1
  78. package/dist/readonlyTerminals.d.ts +55 -0
  79. package/dist/readonlyTerminals.d.ts.map +1 -0
  80. package/dist/readonlyTerminals.js +205 -0
  81. package/dist/readonlyTerminals.js.map +1 -0
  82. package/dist/reviewEvidence.d.ts +4 -0
  83. package/dist/reviewEvidence.d.ts.map +1 -0
  84. package/dist/reviewEvidence.js +46 -0
  85. package/dist/reviewEvidence.js.map +1 -0
  86. package/dist/rotation-predicate.d.ts +7 -23
  87. package/dist/rotation-predicate.d.ts.map +1 -1
  88. package/dist/rotation-predicate.js +45 -0
  89. package/dist/rotation-predicate.js.map +1 -1
  90. package/dist/runEventLog.d.ts +1 -0
  91. package/dist/runEventLog.d.ts.map +1 -1
  92. package/dist/runEventLog.js +3 -2
  93. package/dist/runEventLog.js.map +1 -1
  94. package/dist/runScope.d.ts +86 -0
  95. package/dist/runScope.d.ts.map +1 -0
  96. package/dist/runScope.js +181 -0
  97. package/dist/runScope.js.map +1 -0
  98. package/dist/runTerminalContext.d.ts +4 -0
  99. package/dist/runTerminalContext.d.ts.map +1 -1
  100. package/dist/runTerminalContext.js.map +1 -1
  101. package/dist/runTerminalHelpers.d.ts +50 -0
  102. package/dist/runTerminalHelpers.d.ts.map +1 -0
  103. package/dist/runTerminalHelpers.js +200 -0
  104. package/dist/runTerminalHelpers.js.map +1 -0
  105. package/dist/runTerminalResults.d.ts +25 -3
  106. package/dist/runTerminalResults.d.ts.map +1 -1
  107. package/dist/runTerminalResults.js +61 -29
  108. package/dist/runTerminalResults.js.map +1 -1
  109. package/dist/runTerminals.d.ts +1 -12
  110. package/dist/runTerminals.d.ts.map +1 -1
  111. package/dist/runTerminals.js +113 -140
  112. package/dist/runTerminals.js.map +1 -1
  113. package/dist/secretDiff.d.ts +14 -11
  114. package/dist/secretDiff.d.ts.map +1 -1
  115. package/dist/secretDiff.js +21 -28
  116. package/dist/secretDiff.js.map +1 -1
  117. package/dist/terminalOutcome.d.ts +24 -4
  118. package/dist/terminalOutcome.d.ts.map +1 -1
  119. package/dist/terminalOutcome.js +32 -5
  120. package/dist/terminalOutcome.js.map +1 -1
  121. package/package.json +17 -17
@@ -0,0 +1,205 @@
1
+ import { join } from "node:path";
2
+ import { makeOutcomeFacts } from "@claudexor/schema";
3
+ import { readOnlyNoSuccessTerminal } from "./attemptFinalize.js";
4
+ import { budgetFailureRecord, classifyBudgetFailure } from "./budgetFailure.js";
5
+ import { unanimousDeclaredFailure } from "./candidateEvidence.js";
6
+ import { resumableTerminal } from "./continuity-terminal.js";
7
+ import { attemptVendorFailure, dominantHarnessFailureCategory, harnessFailureNextActions, } from "./harnessFailure.js";
8
+ import { poolFailure } from "./pool-attempt-evidence.js";
9
+ import { writeFailure } from "./runTerminalResults.js";
10
+ /** A read-only chain with no successful attempt (QA-036/QA-050/A5). */
11
+ export function readOnlyChainFailureResult(input) {
12
+ const { store, paths, log, runId, taskId, mode, ledger, attempts, attemptTelemetries } = input;
13
+ const { budgetStopped, budgetDenial } = input;
14
+ const last = attempts[attempts.length - 1];
15
+ const webBlocked = attempts.some((a) => a.status === "blocked");
16
+ // QA-050: a budget refusal is a BUDGET failure, not a harness one — route
17
+ // it through the shared classifier so phase/category/code/route and the
18
+ // remediation are budget-typed (never auth/setup) across every mode.
19
+ const budgetMapping = budgetStopped && !webBlocked
20
+ ? classifyBudgetFailure({ denial: budgetDenial, terminal: ledger.terminal() })
21
+ : null;
22
+ const { message: singleError, poolAttempts } = poolFailure(budgetMapping?.safeMessage ??
23
+ last?.error ??
24
+ (budgetStopped ? "budget exhausted before any attempt" : "harness failed"), attempts);
25
+ if (input.fallbackOpen || webBlocked) {
26
+ log.emit("route.fallback.exhausted", {
27
+ harness_id: last?.harnessId ?? null,
28
+ attempt_id: last?.attemptId ?? null,
29
+ reason: "web_evidence_unsatisfied",
30
+ error: singleError,
31
+ });
32
+ }
33
+ const partialReport = [...attempts].reverse().find((a) => a.report)?.report ?? "";
34
+ input.writeTelemetry();
35
+ store.writeText(join(paths.contextDir, "context_error.md"), `# ${budgetMapping ? "Budget Denied" : "Harness Error"}\n\n${singleError}\n`);
36
+ const roEventRefs = attempts.map((a) => `attempts/${a.attemptId}/events.jsonl`);
37
+ if (budgetMapping) {
38
+ writeFailure(store, paths, {
39
+ ...budgetFailureRecord(budgetMapping, { eventRefs: roEventRefs, runDir: paths.root }),
40
+ safeMessage: singleError,
41
+ poolAttempts,
42
+ });
43
+ }
44
+ else {
45
+ // #31: classify the harness cause across the read-only attempts so auth
46
+ // guidance appears only on a real auth failure.
47
+ const roCategory = dominantHarnessFailureCategory(attemptTelemetries.flatMap((a) => a.telemetry.transientFailures));
48
+ // A5: the terminal already speaks with the LAST attempt's message; its
49
+ // typed refusal rides along machine-readably instead of reducing to it.
50
+ const roDeclared = webBlocked ? undefined : last?.declaredFailure;
51
+ writeFailure(store, paths, {
52
+ phase: "harness",
53
+ category: webBlocked ? "policy" : (roDeclared?.category ?? "harness_error"),
54
+ code: roDeclared?.code ?? null,
55
+ harnessId: last?.harnessId,
56
+ attemptId: last?.attemptId,
57
+ safeMessage: singleError,
58
+ eventRefs: roEventRefs,
59
+ runDir: paths.root,
60
+ resetsAt: roDeclared?.resetsAt ?? null,
61
+ requestRefusal: roDeclared?.requestRefusal,
62
+ vendorFailure: attemptVendorFailure(attemptTelemetries, last?.attemptId),
63
+ poolAttempts,
64
+ nextActions: harnessFailureNextActions(roCategory),
65
+ });
66
+ }
67
+ // QA-036: re-check the DELIVERABLE through the shared finalizer helper —
68
+ // a blocked Ask that produced NO answer can no longer read as a succeeded
69
+ // "Needs review" run (exit 0); it is an honest failure (exit 1).
70
+ const roTerminal = readOnlyNoSuccessTerminal({
71
+ webBlocked,
72
+ hasDeliverable: partialReport.trim().length > 0,
73
+ budgetStopped,
74
+ attemptsCount: attempts.length,
75
+ });
76
+ const terminalFacts = makeOutcomeFacts(roTerminal.lifecycle, {
77
+ ...(roTerminal.review ? { review: roTerminal.review } : {}),
78
+ reason: budgetMapping?.reason ?? roTerminal.reason,
79
+ });
80
+ const terminalHarnessId = budgetMapping?.harnessId ?? last?.harnessId;
81
+ store.writeText(join(paths.finalDir, "summary.md"), `# Run ${runId} (${mode})\n\n- Harness: ${terminalHarnessId ?? "none"}\n- Lifecycle: ${terminalFacts.lifecycle}${terminalFacts.reason ? ` (${terminalFacts.reason})` : ""}\n\n${singleError}\n`);
82
+ log.emit("output.ready", { kind: "summary", path: "final/summary.md", state: "diagnostic" });
83
+ if (terminalFacts.lifecycle === "succeeded") {
84
+ log.emit("run.blocked", {
85
+ lifecycle: terminalFacts.lifecycle,
86
+ facts: terminalFacts,
87
+ harness_id: terminalHarnessId,
88
+ error: singleError,
89
+ pool_attempts: poolAttempts,
90
+ failure_ref: "final/failure.yaml",
91
+ ...resumableTerminal(store, paths, attempts, true),
92
+ });
93
+ }
94
+ else {
95
+ log.emit("run.failed", {
96
+ lifecycle: terminalFacts.lifecycle,
97
+ facts: terminalFacts,
98
+ reason: terminalFacts.reason,
99
+ phase: budgetMapping?.phase,
100
+ harness_id: terminalHarnessId,
101
+ error: singleError,
102
+ pool_attempts: poolAttempts,
103
+ failure_ref: "final/failure.yaml",
104
+ ...resumableTerminal(store, paths, attempts, true),
105
+ });
106
+ }
107
+ return {
108
+ spendUsd: ledger.spend(),
109
+ runId,
110
+ taskId,
111
+ mode,
112
+ lifecycle: terminalFacts.lifecycle,
113
+ facts: terminalFacts,
114
+ winner: null,
115
+ runDir: paths.root,
116
+ summary: singleError,
117
+ candidates: attempts.map((a) => ({
118
+ attemptId: a.attemptId,
119
+ harnessId: a.harnessId,
120
+ status: a.status,
121
+ })),
122
+ };
123
+ }
124
+ /** A deep scan whose every explorer failed: no synthesizable deliverable (QA-036). */
125
+ export function deepScanFailureResult(input) {
126
+ const { store, paths, log, runId, taskId, mode, ledger, attempts, attemptTelemetries } = input;
127
+ const { budgetStopped, budgetDenial } = input;
128
+ const blocked = attempts.some((a) => a.status === "blocked");
129
+ // QA-050/QA-019: only a pure-denial scan may claim a budget failure.
130
+ const scanBudgetMapping = budgetStopped && !blocked && attempts.every((a) => a.budgetDenied === true)
131
+ ? classifyBudgetFailure({ denial: budgetDenial, terminal: ledger.terminal() })
132
+ : null;
133
+ // D-16 r8: ALL scouts out of context → the aggregate is interrupted.
134
+ const allInterrupted = attempts.length > 0 && attempts.every((a) => a.interrupted === true);
135
+ const scanFailFacts = allInterrupted
136
+ ? makeOutcomeFacts("interrupted", { reason: "context_capacity_exhausted" })
137
+ : makeOutcomeFacts("failed", {
138
+ reason: scanBudgetMapping ? scanBudgetMapping.reason : "harness_failed",
139
+ });
140
+ const { message, poolAttempts } = poolFailure(scanBudgetMapping
141
+ ? scanBudgetMapping.safeMessage
142
+ : attempts.map((a) => `${a.attemptId}/${a.harnessId}: ${a.error ?? "failed"}`).join("\n"), attempts);
143
+ input.writeTelemetry();
144
+ if (scanBudgetMapping) {
145
+ writeFailure(store, paths, {
146
+ ...budgetFailureRecord(scanBudgetMapping, {
147
+ eventRefs: attempts.map((a) => `attempts/${a.attemptId}/events.jsonl`),
148
+ runDir: paths.root,
149
+ }),
150
+ safeMessage: message,
151
+ poolAttempts,
152
+ });
153
+ }
154
+ else {
155
+ // Mixed causes stay generic; only unanimous evidence may name the scan's cause.
156
+ const declared = blocked ? null : unanimousDeclaredFailure(attempts);
157
+ const scanCategory = dominantHarnessFailureCategory(attemptTelemetries.flatMap((a) => a.telemetry.transientFailures));
158
+ writeFailure(store, paths, {
159
+ phase: "harness",
160
+ category: blocked ? "policy" : (declared?.category ?? "harness_error"),
161
+ code: declared?.code,
162
+ resetsAt: declared?.resetsAt,
163
+ requestRefusal: declared?.requestRefusal,
164
+ safeMessage: message || "all explorers failed",
165
+ eventRefs: attempts.map((a) => `attempts/${a.attemptId}/events.jsonl`),
166
+ runDir: paths.root,
167
+ poolAttempts,
168
+ nextActions: [
169
+ ...harnessFailureNextActions(scanCategory).filter((a) => !a.startsWith("Retry")),
170
+ "Reduce explore width",
171
+ "Retry after setup",
172
+ ],
173
+ });
174
+ }
175
+ // QA-036: no successful explorer means no synthesizable deliverable.
176
+ store.writeText(join(paths.finalDir, "summary.md"), `# Run ${runId} (${mode})\n\n- Lifecycle: ${scanFailFacts.lifecycle}${scanFailFacts.reason ? ` (${scanFailFacts.reason})` : ""}\n\n${message}\n`);
177
+ log.emit("output.ready", { kind: "summary", path: "final/summary.md", state: "diagnostic" });
178
+ log.emit("run.failed", {
179
+ lifecycle: scanFailFacts.lifecycle,
180
+ facts: scanFailFacts,
181
+ reason: scanFailFacts.reason,
182
+ phase: scanBudgetMapping ? scanBudgetMapping.phase : "harness",
183
+ error: message,
184
+ pool_attempts: poolAttempts,
185
+ failure_ref: "final/failure.yaml",
186
+ ...resumableTerminal(store, paths, attempts, true),
187
+ });
188
+ return {
189
+ spendUsd: ledger.spend(),
190
+ runId,
191
+ taskId,
192
+ mode,
193
+ lifecycle: scanFailFacts.lifecycle,
194
+ facts: scanFailFacts,
195
+ winner: null,
196
+ runDir: paths.root,
197
+ summary: message,
198
+ candidates: attempts.map((a) => ({
199
+ attemptId: a.attemptId,
200
+ harnessId: a.harnessId,
201
+ status: a.status,
202
+ })),
203
+ };
204
+ }
205
+ //# sourceMappingURL=readonlyTerminals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readonlyTerminals.js","sourceRoot":"","sources":["../src/readonlyTerminals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAiB,MAAM,mBAAmB,CAAC;AAGpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAqB,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAgC,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,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AAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;QAC9D,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,YAAY;QAC3B,WAAW,EAAE,oBAAoB;QACjC,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC;KACnD,CAAC,CAAC;IACH,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE;QACxB,KAAK;QACL,MAAM;QACN,IAAI;QACJ,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC/B,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,MAAM,EAAE,CAAC,CAAC,MAAM;SACjB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ArtifactStore } from "@claudexor/artifact-store";
2
+ export declare function prepareReviewEvidenceDir(sourceDir: string, _candidateCwd: string): string;
3
+ export declare function recordReviewEvidenceCleanup(store: ArtifactStore, metadataPath: string, attemptId: string, candidateEvidenceDir: string, candidateCwd: string): void;
4
+ //# sourceMappingURL=reviewEvidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviewEvidence.d.ts","sourceRoot":"","sources":["../src/reviewEvidence.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CASzF;AAqBD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,EAC5B,YAAY,EAAE,MAAM,GACnB,IAAI,CAYN"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Review evidence preflight and cleanup for candidate review (`candidateReview.ts`):
3
+ * the evidence packet is an external runtime artifact that ReviewEngine copies
4
+ * into its own reviewer workspace; nothing is ever written into the candidate tree.
5
+ */
6
+ import { existsSync } from "node:fs";
7
+ import { preflightEvidence } from "@claudexor/context";
8
+ export function prepareReviewEvidenceDir(sourceDir, _candidateCwd) {
9
+ // Evidence is an external runtime artifact. ReviewEngine builds a separate
10
+ // reviewer workspace and copies the packet there; writing/copying it into
11
+ // the candidate tree would contaminate the Git diff and, worse, overwrite a
12
+ // user-owned path with the same name.
13
+ if (!existsSync(sourceDir)) {
14
+ throw new Error(`review evidence preflight failed for ${sourceDir}: source packet missing`);
15
+ }
16
+ return requireReviewEvidence(sourceDir);
17
+ }
18
+ function requireReviewEvidence(dir) {
19
+ const result = preflightEvidence(dir);
20
+ if (result.ok)
21
+ return dir;
22
+ const missing = result.missing.length ? `missing=${result.missing.join(",")}` : "";
23
+ const empty = result.empty.length ? `empty=${result.empty.join(",")}` : "";
24
+ throw new Error(`review evidence preflight failed for ${dir}: ${[missing, empty].filter(Boolean).join(" ")}`);
25
+ }
26
+ function cleanupReviewEvidenceDir(_candidateEvidenceDir, _candidateCwd) {
27
+ // No candidate-tree packet exists in v2; external runtime retention is
28
+ // governed by the artifact/journal lifecycle rather than best-effort rm.
29
+ return null;
30
+ }
31
+ export function recordReviewEvidenceCleanup(store, metadataPath, attemptId, candidateEvidenceDir, candidateCwd) {
32
+ const cleanupMetadata = cleanupReviewEvidenceDir(candidateEvidenceDir, candidateCwd);
33
+ if (!cleanupMetadata)
34
+ return;
35
+ try {
36
+ store.writeYaml(metadataPath, {
37
+ ...cleanupMetadata,
38
+ attempt_id: attemptId,
39
+ });
40
+ }
41
+ catch {
42
+ // Cleanup telemetry must not mask the review/revalidation failure that
43
+ // triggered best-effort cleanup.
44
+ }
45
+ }
46
+ //# sourceMappingURL=reviewEvidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviewEvidence.js","sourceRoot":"","sources":["../src/reviewEvidence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,UAAU,wBAAwB,CAAC,SAAiB,EAAE,aAAqB;IAC/E,2EAA2E;IAC3E,0EAA0E;IAC1E,4EAA4E;IAC5E,sCAAsC;IACtC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,wCAAwC,SAAS,yBAAyB,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAW;IACxC,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,MAAM,CAAC,EAAE;QAAE,OAAO,GAAG,CAAC;IAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,IAAI,KAAK,CACb,wCAAwC,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAC7F,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAC/B,qBAA6B,EAC7B,aAAqB;IAErB,uEAAuE;IACvE,yEAAyE;IACzE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,KAAoB,EACpB,YAAoB,EACpB,SAAiB,EACjB,oBAA4B,EAC5B,YAAoB;IAEpB,MAAM,eAAe,GAAG,wBAAwB,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;IACrF,IAAI,CAAC,eAAe;QAAE,OAAO;IAC7B,IAAI,CAAC;QACH,KAAK,CAAC,SAAS,CAAC,YAAY,EAAE;YAC5B,GAAG,eAAe;YAClB,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,iCAAiC;IACnC,CAAC;AACH,CAAC"}
@@ -1,27 +1,5 @@
1
- /**
2
- * A2: the WIDENED reactive rotation predicate (W5.4 + the structural branch).
3
- *
4
- * Two independent ways an attempt becomes rotation-eligible:
5
- *
6
- * 1. TYPED fast path (W5.4 canon, unchanged): the attempt saw a TYPED vendor
7
- * rate-limit signal. Deliberately NOT hardened against thinking/tool
8
- * activity — the canon guard is no-deliverable/no-mutation, not
9
- * no-progress.
10
- *
11
- * 2. STRUCTURAL branch (owner decision 7=A): the attempt ended in a TERMINAL,
12
- * non-transient death BEFORE the agent demonstrably did any work. This
13
- * deliberately covers ANY pre-progress non-transient death — an invalid
14
- * flag, a missing binary, an untyped vendor refusal — bounded by the
15
- * profile pool size, and is NEVER narrowed by error-text matching.
16
- * Transient-retryable deaths are excluded: the transient machinery retries
17
- * them on the SAME profile first (rotation never fires on a plain
18
- * transient).
19
- *
20
- * Both branches require an empty deliverable and no observed workspace
21
- * mutation — a partially-acted attempt never silently reruns under another
22
- * credential.
23
- */
24
1
  import type { AttemptOutputMarkers } from "./attemptOutputMarkers.js";
2
+ import type { TryFacts } from "./inrun-continuity-types.js";
25
3
  /** Typed evidence one native try presents to the rotation predicate. */
26
4
  export interface RotationEvidence {
27
5
  requestRefused?: boolean;
@@ -71,4 +49,10 @@ export declare function reactiveRotationEvidence(args: {
71
49
  deliverableEmpty: boolean;
72
50
  workspaceDiffNonEmpty?: boolean;
73
51
  }): RotationEvidence;
52
+ /**
53
+ * One settled in-run try's facts as that fold's input. After progress
54
+ * (`forceEligible`) the no-deliverable/no-mutation fence scopes only the
55
+ * `fresh` carrier: the planner picks the carrier, rotation only the account.
56
+ */
57
+ export declare function inRunRotationArgs(facts: TryFacts, forceEligible: boolean): Parameters<typeof reactiveRotationEvidence>[0];
74
58
  //# sourceMappingURL=rotation-predicate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rotation-predicate.d.ts","sourceRoot":"","sources":["../src/rotation-predicate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qEAAqE;IACrE,aAAa,EAAE,OAAO,CAAC;IACvB;;gFAE4E;IAC5E,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;iFAE6E;IAC7E,gBAAgB,EAAE,OAAO,CAAC;IAC1B;iFAC6E;IAC7E,yBAAyB,EAAE,OAAO,CAAC;IACnC;gFAC4E;IAC5E,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,OAAO,CAKV;AAED;;;;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,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GAAG,gBAAgB,CASnB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,QAAQ,EACf,aAAa,EAAE,OAAO,GACrB,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAehD"}
@@ -1,3 +1,27 @@
1
+ /**
2
+ * A2: the WIDENED reactive rotation predicate (W5.4 + the structural branch).
3
+ *
4
+ * Two independent ways an attempt becomes rotation-eligible:
5
+ *
6
+ * 1. TYPED fast path (W5.4 canon, unchanged): the attempt saw a TYPED vendor
7
+ * rate-limit signal. Deliberately NOT hardened against thinking/tool
8
+ * activity — the canon guard is no-deliverable/no-mutation, not
9
+ * no-progress.
10
+ *
11
+ * 2. STRUCTURAL branch (owner decision 7=A): the attempt ended in a TERMINAL,
12
+ * non-transient death BEFORE the agent demonstrably did any work. This
13
+ * deliberately covers ANY pre-progress non-transient death — an invalid
14
+ * flag, a missing binary, an untyped vendor refusal — bounded by the
15
+ * profile pool size, and is NEVER narrowed by error-text matching.
16
+ * Transient-retryable deaths are excluded: the transient machinery retries
17
+ * them on the SAME profile first (rotation never fires on a plain
18
+ * transient).
19
+ *
20
+ * Both branches require an empty deliverable and no observed workspace
21
+ * mutation — a partially-acted attempt never silently reruns under another
22
+ * credential.
23
+ */
24
+ import { acceptedTryOutput } from "@claudexor/core";
1
25
  /**
2
26
  * `rotation_retry_eligible`: the one predicate both lanes and both branches
3
27
  * read. Optional fields default CONSERVATIVELY (absent evidence never widens
@@ -29,4 +53,25 @@ export function reactiveRotationEvidence(args) {
29
53
  sawAgentProgress: args.markers.sawAgentProgress,
30
54
  };
31
55
  }
56
+ /**
57
+ * One settled in-run try's facts as that fold's input. After progress
58
+ * (`forceEligible`) the no-deliverable/no-mutation fence scopes only the
59
+ * `fresh` carrier: the planner picks the carrier, rotation only the account.
60
+ */
61
+ export function inRunRotationArgs(facts, forceEligible) {
62
+ const accepted = acceptedTryOutput(facts.answer, facts.harnessErrored);
63
+ return {
64
+ markers: forceEligible
65
+ ? { sawAgentProgress: false, fileChanges: 0, sawSessionStart: facts.markers.sawSessionStart }
66
+ : facts.markers,
67
+ requestRefused: facts.requestRefused,
68
+ sawTypedLimit: facts.sawTypedLimit,
69
+ sawRetryable: facts.sawRetryable,
70
+ attemptErrored: facts.harnessErrored,
71
+ deliverableEmpty: forceEligible
72
+ ? true
73
+ : facts.workspaceDiffNonEmpty !== true && accepted.length === 0,
74
+ workspaceDiffNonEmpty: forceEligible ? false : facts.workspaceDiffNonEmpty,
75
+ };
76
+ }
32
77
  //# sourceMappingURL=rotation-predicate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rotation-predicate.js","sourceRoot":"","sources":["../src/rotation-predicate.ts"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAOrC;IACC,IAAI,KAAK,CAAC,cAAc;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC7E,IAAI,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO,KAAK,CAAC,yBAAyB,KAAK,IAAI,IAAI,KAAK,CAAC,gBAAgB,KAAK,IAAI,CAAC;AACrF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAQxC;IACC,OAAO;QACL,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,gBAAgB,EAAE,CAAC,IAAI,C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AiB,CAC/B,KAAe,EACf,aAAsB;IAEtB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACvE,OAAO;QACL,OAAO,EAAE,aAAa;YACpB,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE;YAC7F,CAAC,CAAC,KAAK,CAAC,OAAO;QACjB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,gBAAgB,EAAE,aAAa;YAC7B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,KAAK,CAAC,qBAAqB,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QACjE,qBAAqB,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,qBAAqB;KAC3E,CAAC;AACJ,CAAC"}
@@ -44,6 +44,7 @@ export declare function beginAnnouncedRun(start: RunAnnouncementInput, announce:
44
44
  paths: RunPaths;
45
45
  log: EventLog;
46
46
  ledger: BudgetLedger;
47
+ runContext: AnnouncedRunContext;
47
48
  };
48
49
  export {};
49
50
  //# sourceMappingURL=runEventLog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runEventLog.d.ts","sourceRoot":"","sources":["../src/runEventLog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EA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AAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mGAAmG;AACnG,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,gBAAgB,GACtB,QAAQ,CAWV;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAO5E;AAcD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAC/C;IACD,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,mBAAmB,CAAC;CACjC,CA4BA"}
@@ -63,9 +63,10 @@ export function beginAnnouncedRun(start, announce) {
63
63
  log.emit("run.created", { mode, prompt: redactSecrets(start.prompt) });
64
64
  return preparedLedger;
65
65
  });
66
- announce(announcedRunContext({ log, store, paths, runId, taskId, mode, phase }, ledger, () => authority?.hasParent(runId) === true));
66
+ const runContext = announcedRunContext({ log, store, paths, runId, taskId, mode, phase }, ledger, () => authority?.hasParent(runId) === true);
67
+ announce(runContext);
67
68
  safeInvoke(input.onRunStart, { runId, taskId, runDir: paths.root });
68
69
  announcePreparedProjectGitInitialization(input, log);
69
- return { store, paths, log, ledger };
70
+ return { store, paths, log, ledger, runContext };
70
71
  }
71
72
  //# sourceMappingURL=runEventLog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runEventLog.js","sourceRoot":"","sources":["../src/runEventLog.ts"],"names":[],"mappings":"AAEA,OA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AAC,IAAI,CAAC;YACrC,wBAAwB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACvE,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,mBAAmB,CACpC,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EACjD,MAAM,EACN,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,CAC3C,CAAC;IACF,QAAQ,CAAC,UAAU,CAAC,CAAC;IACrB,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACpE,wCAAwC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AACnD,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { type ScopeReapOptions, type ScopeReapOutcome } from "@claudexor/core";
2
+ import { type RunProcessScopeOutcome as RunProcessScopeOutcomeType } from "@claudexor/schema";
3
+ import type { AnnouncedRunContext } from "./runTerminalContext.js";
4
+ import type { ResolvedRouteContext } from "./routeContext.js";
5
+ export interface RunScopeCustodian {
6
+ /**
7
+ * Mint and durably record the run's scope marker BEFORE its first launch.
8
+ * Returns the marker NAME to carry in every spec env. Must not throw for a
9
+ * recoverable persistence failure — it degrades to in-process custody and
10
+ * discloses, never fails the run.
11
+ */
12
+ open(runId: string): Promise<{
13
+ marker: string;
14
+ }>;
15
+ /**
16
+ * End every live process carrying the run's marker and retire/disclose the
17
+ * durable entry. Idempotent per run.
18
+ */
19
+ settle(runId: string, marker: string): Promise<ScopeReapOutcome>;
20
+ }
21
+ /**
22
+ * The default custodian for an embedder/test with no daemon index: it mints
23
+ * and reaps in process (no durable crash-recovery record), remembering each
24
+ * marker's opening time so the census can skip processes older than the
25
+ * scope. The reaper's own per-marker coalescing makes repeat settles safe.
26
+ */
27
+ export declare function createInProcessRunScopeCustodian(reap?: (opts: ScopeReapOptions) => Promise<ScopeReapOutcome>): RunScopeCustodian;
28
+ export declare const inProcessRunScopeCustodian: RunScopeCustodian;
29
+ /**
30
+ * Add the run's scope marker (and, when the env is a scoped native-state HOME,
31
+ * the host facts) to a harness spec env WITHOUT overwriting the existing
32
+ * HOME/config/auth patch. The marker is applied last so it always survives.
33
+ * `baseEnv` may be absent (an in-place run that inherits the operator env):
34
+ * the marker still applies so the run can end what it leaves. Returns
35
+ * `undefined` only when there is no marker (custody disabled).
36
+ */
37
+ export declare function scopedSpecEnv(marker: string | undefined, baseEnv: Record<string, string> | undefined, options?: {
38
+ source?: NodeJS.ProcessEnv;
39
+ }): Record<string, string> | undefined;
40
+ /**
41
+ * The env patch for a deterministic command the run itself launches (its
42
+ * candidate gates, final verification and adoption): the scope marker alone, so
43
+ * whatever the command leaves running is ended at the whole-run barrier. The
44
+ * gate keeps its own HOME and allowlist; nothing is cleaned up per command.
45
+ */
46
+ export declare function runScopeGateEnv(marker: string | undefined): Record<string, string> | undefined;
47
+ /** The outcome written when the custodian itself failed: unknown, never clean. */
48
+ export declare function failedScopeOutcome(reason: string): ScopeReapOutcome;
49
+ /**
50
+ * Write the scope outcome to its OWN terminal artifact (`final/process_scope.yaml`)
51
+ * so it survives the record rewrites and projections the immutable RunFacts
52
+ * receipt goes through. Best-effort: a write failure never fails an
53
+ * already-terminal run (the reap itself already happened).
54
+ */
55
+ export declare function writeRunScopeFacts(ctx: AnnouncedRunContext, marker: string, outcome: ScopeReapOutcome): RunProcessScopeOutcomeType | null;
56
+ /**
57
+ * The route-admitting readiness probe and the run must share the EXACT env
58
+ * (W3.3 / TZ-1 §B: evidence gathered in one env while the run executes in
59
+ * another is not evidence). The marker and host facts therefore join the
60
+ * route context itself, so the probe, the model inventory and the spawn all
61
+ * see one env; `scopedSpecEnv` on the eventual spec is then idempotent.
62
+ */
63
+ export declare function scopedRouteContext(ctx: ResolvedRouteContext, marker: string | undefined): ResolvedRouteContext;
64
+ /**
65
+ * The per-run custody wiring of `Orchestrator.run()` (owner 1A, #449): the
66
+ * marker minted and recorded BEFORE the first launch, the announced context
67
+ * holding its terminal (the existing deferred-terminal mechanism) until the
68
+ * barrier has settled custody, settlement memoised so the barrier, the
69
+ * terminalization fallback and the never-announced path agree on ONE outcome,
70
+ * and the typed facts recorded exactly once. A settlement that throws is
71
+ * disclosed as a failed outcome, never as a run failure. Without a custodian
72
+ * (an embedder), custody is in-process only.
73
+ */
74
+ export interface RunScopeCustody {
75
+ readonly marker: string;
76
+ /** Wrap `announce`: remember the context and hold its terminal for the barrier. */
77
+ announced(announce: (a: AnnouncedRunContext) => void): (a: AnnouncedRunContext) => void;
78
+ /** The whole-run barrier body: `drain` first; settle and record in `finally`. */
79
+ barrier(drain: () => Promise<void>): Promise<void>;
80
+ /** Idempotent fallback for a path that never reached the barrier. */
81
+ record(): Promise<void>;
82
+ /** A run that never announced launched nothing, but its marker was recorded: settle it. */
83
+ settleUnannounced(): Promise<void>;
84
+ }
85
+ export declare function openRunScopeCustody(custodian: RunScopeCustodian | undefined, runId: string): Promise<RunScopeCustody>;
86
+ //# sourceMappingURL=runScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runScope.d.ts","sourceRoot":"","sources":["../src/runScope.ts"],"names":[],"mappings":"AAcA,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,s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