@claudexor/orchestrator 3.20.1 → 3.22.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 -101
- package/dist/attemptFinalize.d.ts.map +1 -1
- package/dist/attemptFinalize.js +7 -328
- package/dist/attemptFinalize.js.map +1 -1
- package/dist/candidateEvidence.d.ts +15 -6
- package/dist/candidateEvidence.d.ts.map +1 -1
- package/dist/candidateEvidence.js +1 -1
- package/dist/candidateEvidence.js.map +1 -1
- package/dist/candidateOutputs.d.ts +7 -3
- package/dist/candidateOutputs.d.ts.map +1 -1
- package/dist/candidateOutputs.js +4 -1
- package/dist/candidateOutputs.js.map +1 -1
- package/dist/candidateReview.d.ts.map +1 -1
- package/dist/candidateReview.js +3 -1
- package/dist/candidateReview.js.map +1 -1
- package/dist/candidateTerminals.d.ts +4 -0
- package/dist/candidateTerminals.d.ts.map +1 -1
- package/dist/candidateTerminals.js +18 -7
- package/dist/candidateTerminals.js.map +1 -1
- package/dist/candidateWorkProduct.d.ts.map +1 -1
- package/dist/candidateWorkProduct.js +6 -6
- package/dist/candidateWorkProduct.js.map +1 -1
- package/dist/carrier-planner.d.ts +94 -0
- package/dist/carrier-planner.d.ts.map +1 -0
- package/dist/carrier-planner.js +111 -0
- package/dist/carrier-planner.js.map +1 -0
- package/dist/continuation-custody.d.ts +57 -0
- package/dist/continuation-custody.d.ts.map +1 -0
- package/dist/continuation-custody.js +151 -0
- package/dist/continuation-custody.js.map +1 -0
- package/dist/continuation-evidence-io.d.ts +18 -0
- package/dist/continuation-evidence-io.d.ts.map +1 -0
- package/dist/continuation-evidence-io.js +167 -0
- package/dist/continuation-evidence-io.js.map +1 -0
- package/dist/continuation-evidence.d.ts +81 -0
- package/dist/continuation-evidence.d.ts.map +1 -0
- package/dist/continuation-evidence.js +122 -0
- package/dist/continuation-evidence.js.map +1 -0
- package/dist/continuation-input.d.ts +10 -0
- package/dist/continuation-input.d.ts.map +1 -0
- package/dist/continuation-input.js +69 -0
- package/dist/continuation-input.js.map +1 -0
- package/dist/continue-from.d.ts +41 -0
- package/dist/continue-from.d.ts.map +1 -0
- package/dist/continue-from.js +292 -0
- package/dist/continue-from.js.map +1 -0
- package/dist/continuity-notice.d.ts +42 -0
- package/dist/continuity-notice.d.ts.map +1 -0
- package/dist/continuity-notice.js +42 -0
- package/dist/continuity-notice.js.map +1 -0
- package/dist/continuity-terminal.d.ts +19 -0
- package/dist/continuity-terminal.d.ts.map +1 -0
- package/dist/continuity-terminal.js +34 -0
- package/dist/continuity-terminal.js.map +1 -0
- package/dist/credential-cooldown.d.ts.map +1 -1
- package/dist/credential-cooldown.js +8 -3
- package/dist/credential-cooldown.js.map +1 -1
- package/dist/credential-differential.d.ts +1 -0
- package/dist/credential-differential.d.ts.map +1 -1
- package/dist/credential-differential.js +32 -4
- package/dist/credential-differential.js.map +1 -1
- package/dist/deepScanReducer.d.ts +4 -1
- package/dist/deepScanReducer.d.ts.map +1 -1
- package/dist/deepScanReducer.js +10 -5
- package/dist/deepScanReducer.js.map +1 -1
- package/dist/delegationFailure.d.ts +4 -3
- package/dist/delegationFailure.d.ts.map +1 -1
- package/dist/delegationFailure.js +25 -24
- package/dist/delegationFailure.js.map +1 -1
- package/dist/directoryCandidate.d.ts +2 -2
- package/dist/directoryCandidate.d.ts.map +1 -1
- package/dist/directoryCandidate.js +3 -0
- package/dist/directoryCandidate.js.map +1 -1
- package/dist/inrun-continuity-carrier.d.ts +76 -0
- package/dist/inrun-continuity-carrier.d.ts.map +1 -0
- package/dist/inrun-continuity-carrier.js +218 -0
- package/dist/inrun-continuity-carrier.js.map +1 -0
- package/dist/inrun-continuity-thread.d.ts +8 -0
- package/dist/inrun-continuity-thread.d.ts.map +1 -0
- package/dist/inrun-continuity-thread.js +23 -0
- package/dist/inrun-continuity-thread.js.map +1 -0
- package/dist/inrun-continuity-types.d.ts +105 -0
- package/dist/inrun-continuity-types.d.ts.map +1 -0
- package/dist/inrun-continuity-types.js +2 -0
- package/dist/inrun-continuity-types.js.map +1 -0
- package/dist/inrun-continuity.d.ts +79 -0
- package/dist/inrun-continuity.d.ts.map +1 -0
- package/dist/inrun-continuity.js +465 -0
- package/dist/inrun-continuity.js.map +1 -0
- package/dist/inrun-continuity.test-support.d.ts +374 -0
- package/dist/inrun-continuity.test-support.d.ts.map +1 -0
- package/dist/inrun-continuity.test-support.js +198 -0
- package/dist/inrun-continuity.test-support.js.map +1 -0
- package/dist/inrun-retained-output.d.ts +9 -0
- package/dist/inrun-retained-output.d.ts.map +1 -0
- package/dist/inrun-retained-output.js +16 -0
- package/dist/inrun-retained-output.js.map +1 -0
- package/dist/interaction.d.ts +1 -1
- package/dist/interaction.d.ts.map +1 -1
- package/dist/interaction.js +6 -1
- package/dist/interaction.js.map +1 -1
- package/dist/modelGovernance.d.ts +4 -0
- package/dist/modelGovernance.d.ts.map +1 -1
- package/dist/modelGovernance.js +27 -1
- package/dist/modelGovernance.js.map +1 -1
- package/dist/orchestrator-credentials.d.ts +1 -1
- package/dist/orchestrator-credentials.d.ts.map +1 -1
- package/dist/orchestrator-credentials.js +4 -3
- package/dist/orchestrator-credentials.js.map +1 -1
- package/dist/orchestrator.d.ts +4 -4
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +252 -226
- package/dist/orchestrator.js.map +1 -1
- package/dist/persistedPatch.d.ts +55 -0
- package/dist/persistedPatch.d.ts.map +1 -0
- package/dist/persistedPatch.js +132 -0
- package/dist/persistedPatch.js.map +1 -0
- package/dist/planFinalize.d.ts +37 -0
- package/dist/planFinalize.d.ts.map +1 -0
- package/dist/planFinalize.js +94 -0
- package/dist/planFinalize.js.map +1 -0
- package/dist/planRun.d.ts +2 -28
- package/dist/planRun.d.ts.map +1 -1
- package/dist/planRun.js +5 -88
- package/dist/planRun.js.map +1 -1
- package/dist/plannerAttempt.d.ts +4 -1
- package/dist/plannerAttempt.d.ts.map +1 -1
- package/dist/plannerAttempt.js +9 -4
- package/dist/plannerAttempt.js.map +1 -1
- package/dist/prompt-framing.d.ts +1 -1
- package/dist/prompt-framing.d.ts.map +1 -1
- package/dist/prompt-framing.js.map +1 -1
- package/dist/reviewerEffort.d.ts +41 -0
- package/dist/reviewerEffort.d.ts.map +1 -0
- package/dist/reviewerEffort.js +37 -0
- package/dist/reviewerEffort.js.map +1 -0
- package/dist/reviewerPanel.d.ts +5 -5
- package/dist/reviewerPanel.d.ts.map +1 -1
- package/dist/reviewerPanel.js +22 -50
- package/dist/reviewerPanel.js.map +1 -1
- package/dist/run-input-resolution.d.ts.map +1 -1
- package/dist/run-input-resolution.js +10 -0
- package/dist/run-input-resolution.js.map +1 -1
- package/dist/runEventLog.d.ts.map +1 -1
- package/dist/runEventLog.js +5 -0
- package/dist/runEventLog.js.map +1 -1
- package/dist/runFactsBuilder.d.ts.map +1 -1
- package/dist/runFactsBuilder.js +11 -2
- package/dist/runFactsBuilder.js.map +1 -1
- package/dist/runSupport.d.ts +2 -1
- package/dist/runSupport.d.ts.map +1 -1
- package/dist/runSupport.js +2 -1
- package/dist/runSupport.js.map +1 -1
- package/dist/runTelemetryWriter.d.ts.map +1 -1
- package/dist/runTelemetryWriter.js +7 -2
- package/dist/runTelemetryWriter.js.map +1 -1
- package/dist/runTerminalResults.d.ts +6 -2
- package/dist/runTerminalResults.d.ts.map +1 -1
- package/dist/runTerminalResults.js +8 -1
- package/dist/runTerminalResults.js.map +1 -1
- package/dist/runTerminals.d.ts.map +1 -1
- package/dist/runTerminals.js +6 -5
- package/dist/runTerminals.js.map +1 -1
- package/dist/secretDiff.d.ts +67 -27
- package/dist/secretDiff.d.ts.map +1 -1
- package/dist/secretDiff.js +143 -113
- package/dist/secretDiff.js.map +1 -1
- package/dist/session-capsule.d.ts +29 -0
- package/dist/session-capsule.d.ts.map +1 -0
- package/dist/session-capsule.js +86 -0
- package/dist/session-capsule.js.map +1 -0
- package/dist/workReportEnvelope.d.ts +123 -0
- package/dist/workReportEnvelope.d.ts.map +1 -0
- package/dist/workReportEnvelope.js +362 -0
- package/dist/workReportEnvelope.js.map +1 -0
- package/package.json +17 -17
- package/dist/effortGovernance.d.ts +0 -13
- package/dist/effortGovernance.d.ts.map +0 -1
- package/dist/effortGovernance.js +0 -7
- package/dist/effortGovernance.js.map +0 -1
package/dist/secretDiff.d.ts
CHANGED
|
@@ -1,32 +1,72 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ArtifactStore } from "@claudexor/artifact-store";
|
|
2
|
+
import { AnswerAssembly } from "@claudexor/core";
|
|
3
|
+
import type { HarnessEvent, WorkspaceEnvelope } from "@claudexor/schema";
|
|
4
|
+
import { type WorkspaceManager } from "@claudexor/workspace";
|
|
5
|
+
import { secretLikeSummaryLine, type SecretLikeFinding } from "./persistedPatch.js";
|
|
6
|
+
/** The candidate's changes could not be observed at all. This is the ONLY
|
|
7
|
+
* capture-time refusal left: secret-like content is never one (INV-062). */
|
|
8
|
+
export interface CaptureRefusal {
|
|
9
|
+
disposition: "discarded" | "manual_cleanup";
|
|
5
10
|
detail: string;
|
|
11
|
+
/** Failure phase; a directory result keeps its sensitive-resource phase. */
|
|
12
|
+
phase?: "workspace" | "artifact_security";
|
|
6
13
|
}
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
+
export declare function recordCaptureRefusal(refusal: CaptureRefusal | undefined, errors: string[], existingError: boolean): boolean;
|
|
15
|
+
export declare function captureRefusalNextActions(refusal: CaptureRefusal): string[];
|
|
16
|
+
/** Answer assembly that also counts secret-like matches in answer material
|
|
17
|
+
* BEFORE its first redaction. Harness events are redacted one by one on their
|
|
18
|
+
* way into the assembly, so a count taken on the assembled answer would
|
|
19
|
+
* always read zero. The count mirrors the assembly's own selection: a typed
|
|
20
|
+
* final wins verbatim, otherwise the narration parts add up. */
|
|
21
|
+
export declare class CountedAnswerAssembly extends AnswerAssembly {
|
|
22
|
+
private finalMatches;
|
|
23
|
+
private partMatches;
|
|
24
|
+
private lastPart;
|
|
25
|
+
observeCounted(raw: HarnessEvent, safe: HarnessEvent): void;
|
|
26
|
+
secretLikeMatches(): number;
|
|
27
|
+
}
|
|
28
|
+
/** Read-only products have no patch or media findings. Their selected answer's
|
|
29
|
+
* pre-redaction count uses the same disclosure shape as a candidate capture. */
|
|
30
|
+
export declare function answerSecretLikeFinding(answerMatches?: number): SecretLikeFinding | undefined;
|
|
31
|
+
export interface CandidateCapture {
|
|
32
|
+
/** The EXACT candidate patch: apply, synthesis, digests and gates read it. */
|
|
14
33
|
diff: string;
|
|
34
|
+
/** The saved copy, present only when it differs from the exact patch. */
|
|
35
|
+
persistedDiff?: string;
|
|
36
|
+
secretLike?: SecretLikeFinding;
|
|
37
|
+
captureRefusal?: CaptureRefusal;
|
|
38
|
+
/** Set when the private exact patch object of an isolated candidate could
|
|
39
|
+
* not be written: its envelope is kept and this is where the bytes still are. */
|
|
40
|
+
exactBytesRetainedAt?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Disclosure fields of one attempt record (`attempt.yaml`). */
|
|
43
|
+
export declare function attemptDisclosure(capture: CandidateCapture): Record<string, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Capture a candidate's changes and classify what a SAVED copy must hide.
|
|
46
|
+
* Nothing is rolled back, discarded or failed for secret-like content: the
|
|
47
|
+
* tree, the in-memory diff and the reviewer's verdict all keep the real bytes.
|
|
48
|
+
*/
|
|
49
|
+
export declare function captureCandidateWorkspace(input: {
|
|
50
|
+
wsm: WorkspaceManager;
|
|
51
|
+
envelope: WorkspaceEnvelope;
|
|
15
52
|
inPlace: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export declare function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
/** Project root owning the private exact patch object store. */
|
|
54
|
+
projectRoot: string;
|
|
55
|
+
answerText?: string;
|
|
56
|
+
answerMatches: number;
|
|
57
|
+
}): Promise<CandidateCapture>;
|
|
58
|
+
/**
|
|
59
|
+
* Write a run's final patch: the saved copy to `final/patch.diff`, the exact
|
|
60
|
+
* bytes to the private exact patch object when the copy hides anything, and
|
|
61
|
+
* the disclosure fields for `work_product.yaml` meta. `patchSha256` is ALWAYS
|
|
62
|
+
* the digest of the exact patch, so a redacted copy can never pass the apply
|
|
63
|
+
* gate's digest binding on any route.
|
|
64
|
+
*/
|
|
65
|
+
export declare function persistFinalPatch(store: ArtifactStore, finalDir: string, run: Pick<CandidateCapture, "diff" | "persistedDiff" | "secretLike" | "exactBytesRetainedAt">): {
|
|
66
|
+
patchSha256: string;
|
|
67
|
+
meta: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
export { secretLikeSummaryLine };
|
|
70
|
+
/** `\n`-prefixed disclosure line for a summary template; "" when clean. */
|
|
71
|
+
export declare function summaryDisclosure(finding: SecretLikeFinding | undefined): string;
|
|
32
72
|
//# sourceMappingURL=secretDiff.d.ts.map
|
package/dist/secretDiff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secretDiff.d.ts","sourceRoot":"","sources":["../src/secretDiff.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"secretDiff.d.ts","sourceRoot":"","sources":["../src/secretDiff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAqC,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGhG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;IACrD,GAAG,EAAE,gBAAgB,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA6D5B;AAMD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,eAAe,GAAG,YAAY,GAAG,sBAAsB,CAAC,GAC5F;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAgBxD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAGhF"}
|
package/dist/secretDiff.js
CHANGED
|
@@ -1,141 +1,171 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { containsSecretLikeToken, redactSecrets } from "@claudexor/util";
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { AnswerAssembly, summarizeDiffPaths } from "@claudexor/core";
|
|
3
|
+
import { createRevertAnchorFromPatchOrNull } from "@claudexor/workspace";
|
|
4
|
+
import { sensitiveResourcePolicy, sha256 } from "@claudexor/util";
|
|
6
5
|
import { candidateOutputSecretRisk, rasterLinksInMarkdown } from "./candidateOutputs.js";
|
|
7
|
-
|
|
6
|
+
import { assertPersistableText, buildSecretLikeFinding, persistedPatchCopy, secretLikeSummaryLine, } from "./persistedPatch.js";
|
|
7
|
+
export function recordCaptureRefusal(refusal, errors, existingError) {
|
|
8
8
|
if (!refusal)
|
|
9
9
|
return existingError;
|
|
10
|
-
errors.push(
|
|
10
|
+
errors.push(refusal.detail);
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
|
-
export function
|
|
13
|
+
export function captureRefusalNextActions(refusal) {
|
|
14
14
|
return refusal.disposition === "manual_cleanup"
|
|
15
|
-
? ["Inspect
|
|
16
|
-
: ["Retry the run
|
|
15
|
+
? ["Inspect the changed files in the project folder directly", "Retry the run"]
|
|
16
|
+
: ["Retry the run"];
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
/** Answer assembly that also counts secret-like matches in answer material
|
|
19
|
+
* BEFORE its first redaction. Harness events are redacted one by one on their
|
|
20
|
+
* way into the assembly, so a count taken on the assembled answer would
|
|
21
|
+
* always read zero. The count mirrors the assembly's own selection: a typed
|
|
22
|
+
* final wins verbatim, otherwise the narration parts add up. */
|
|
23
|
+
export class CountedAnswerAssembly extends AnswerAssembly {
|
|
24
|
+
finalMatches = null;
|
|
25
|
+
partMatches = 0;
|
|
26
|
+
lastPart;
|
|
27
|
+
observeCounted(raw, safe) {
|
|
28
|
+
this.observe(safe);
|
|
29
|
+
if (raw.type !== "message")
|
|
30
|
+
return;
|
|
31
|
+
const payload = raw.payload ?? {};
|
|
32
|
+
if (payload["auth_switched"] === true || payload["delta"] === true)
|
|
33
|
+
return;
|
|
34
|
+
if (payload["buffered"] === true)
|
|
35
|
+
return;
|
|
36
|
+
const text = raw.text ?? "";
|
|
37
|
+
const count = () => sensitiveResourcePolicy.inspectContent(text, "redact").matches;
|
|
38
|
+
if (raw.final === true) {
|
|
39
|
+
// The same acceptance as AnswerAssembly: an empty display final counts
|
|
40
|
+
// only when it carries the machine envelope (and then shows nothing).
|
|
41
|
+
const envelope = typeof payload["work_report_envelope"] === "string";
|
|
42
|
+
if (text.trim().length > 0 || envelope)
|
|
43
|
+
this.finalMatches = text.trim() ? count() : 0;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Narration repeats are shown once (pushUniqueText), so they count once.
|
|
47
|
+
const normalized = text.trim();
|
|
48
|
+
if (!normalized || normalized === this.lastPart)
|
|
49
|
+
return;
|
|
50
|
+
this.lastPart = normalized;
|
|
51
|
+
this.partMatches += count();
|
|
25
52
|
}
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
diff: "",
|
|
29
|
-
refusal: {
|
|
30
|
-
disposition: "discarded",
|
|
31
|
-
detail: "isolated candidate bytes that could not be proven secret-safe were discarded with the candidate envelope",
|
|
32
|
-
},
|
|
33
|
-
};
|
|
53
|
+
secretLikeMatches() {
|
|
54
|
+
return this.hasFinal() && this.finalMatches !== null ? this.finalMatches : this.partMatches;
|
|
34
55
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
noIndex: !input.gitBacked,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
const rollbackCompleted = error instanceof Error &&
|
|
53
|
-
Object.prototype.hasOwnProperty.call(error, "cleanupError") &&
|
|
54
|
-
error.rollbackReverted === true;
|
|
55
|
-
return {
|
|
56
|
-
diff: "",
|
|
57
|
-
refusal: {
|
|
58
|
-
disposition: "manual_cleanup",
|
|
59
|
-
detail: rollbackCompleted
|
|
60
|
-
? "in-place bytes were rolled back, but Claudexor scratch cleanup could not be proven; manual cleanup of Claudexor temporary state is required"
|
|
61
|
-
: "in-place output that could not be proven secret-safe could not be rolled back; manual cleanup required",
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const manuallyClean = !rollback.reverted || input.gitBacked || input.secretOutsidePatch === true;
|
|
56
|
+
}
|
|
57
|
+
/** Read-only products have no patch or media findings. Their selected answer's
|
|
58
|
+
* pre-redaction count uses the same disclosure shape as a candidate capture. */
|
|
59
|
+
export function answerSecretLikeFinding(answerMatches = 0) {
|
|
60
|
+
return buildSecretLikeFinding({
|
|
61
|
+
copy: { text: "", files: [], unattributedMatches: 0 },
|
|
62
|
+
binaryPaths: [],
|
|
63
|
+
mediaWithheld: [],
|
|
64
|
+
answerMatches,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Disclosure fields of one attempt record (`attempt.yaml`). */
|
|
68
|
+
export function attemptDisclosure(capture) {
|
|
66
69
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
: {
|
|
74
|
-
disposition: "manual_cleanup",
|
|
75
|
-
detail: redactSecrets(rollback.reverted && input.secretOutsidePatch
|
|
76
|
-
? `the exact reversible patch was removed, but candidate media outside that patch could not be proven removed; manual cleanup required${input.gitBacked ? "; inspect Git index, refs, and objects too" : ""}`
|
|
77
|
-
: rollback.reverted && input.gitBacked
|
|
78
|
-
? "worktree bytes were removed; inspect Git index, refs, and objects for harness-written secret state"
|
|
79
|
-
: (rollback.reason ??
|
|
80
|
-
"candidate output could not be proven removed; manual cleanup required")),
|
|
81
|
-
},
|
|
70
|
+
...(capture.captureRefusal ? { capture_refusal: capture.captureRefusal } : {}),
|
|
71
|
+
...(capture.secretLike ? { secret_like: capture.secretLike } : {}),
|
|
72
|
+
...(capture.exactBytesRetainedAt
|
|
73
|
+
? { exact_bytes_retained_at: capture.exactBytesRetainedAt }
|
|
74
|
+
: {}),
|
|
82
75
|
};
|
|
83
76
|
}
|
|
84
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Capture a candidate's changes and classify what a SAVED copy must hide.
|
|
79
|
+
* Nothing is rolled back, discarded or failed for secret-like content: the
|
|
80
|
+
* tree, the in-memory diff and the reviewer's verdict all keep the real bytes.
|
|
81
|
+
*/
|
|
82
|
+
export async function captureCandidateWorkspace(input) {
|
|
83
|
+
const { wsm, envelope, inPlace } = input;
|
|
85
84
|
let captured;
|
|
86
85
|
try {
|
|
87
86
|
captured = await wsm.captureDiff(envelope);
|
|
88
87
|
}
|
|
89
88
|
catch (error) {
|
|
90
89
|
const scratchCleanupUnproven = error instanceof Error && Object.prototype.hasOwnProperty.call(error, "cleanupError");
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
90
|
+
return refused(inPlace || scratchCleanupUnproven ? "manual_cleanup" : "discarded", scratchCleanupUnproven
|
|
91
|
+
? "candidate output capture failed and private scratch cleanup could not be proven; manual cleanup of Claudexor temporary state is required"
|
|
92
|
+
: inPlace
|
|
93
|
+
? "candidate output could not be captured; the changed files are untouched and need direct inspection"
|
|
94
|
+
: "uncaptured isolated candidate output was discarded with the candidate envelope");
|
|
95
|
+
}
|
|
96
|
+
if (captured.captureIncomplete) {
|
|
97
|
+
return refused(inPlace ? "manual_cleanup" : "discarded", inPlace
|
|
98
|
+
? "candidate output could not be captured as a complete patch; the changed files are untouched and need direct inspection"
|
|
99
|
+
: "uncaptured isolated candidate output was discarded with the candidate envelope");
|
|
102
100
|
}
|
|
103
|
-
const
|
|
104
|
-
const linkedPaths = rasterLinksInMarkdown(answerText ?? "");
|
|
105
|
-
const mediaRisk = candidateOutputSecretRisk({
|
|
101
|
+
const media = candidateOutputSecretRisk({
|
|
106
102
|
worktreePath: envelope.worktree_path,
|
|
107
|
-
changedPaths: [
|
|
103
|
+
changedPaths: [
|
|
104
|
+
...summarizeDiffPaths(captured.diff).paths,
|
|
105
|
+
...rasterLinksInMarkdown(input.answerText ?? ""),
|
|
106
|
+
],
|
|
108
107
|
artifactRelativeDir: wsm.ownedArtifactRelativeDirectory(envelope),
|
|
109
108
|
});
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
109
|
+
const copy = persistedPatchCopy(captured.diff, captured.binarySecretPaths);
|
|
110
|
+
const secretLike = buildSecretLikeFinding({
|
|
111
|
+
copy,
|
|
112
|
+
binaryPaths: captured.binarySecretPaths,
|
|
113
|
+
mediaWithheld: [
|
|
114
|
+
...media.riskyPaths,
|
|
115
|
+
...(media.artifactDirectoryUnsafe
|
|
116
|
+
? [wsm.ownedArtifactRelativeDirectory(envelope) ?? ""]
|
|
117
|
+
: []),
|
|
118
|
+
].filter(Boolean),
|
|
119
|
+
answerMatches: input.answerText ? input.answerMatches : 0,
|
|
121
120
|
});
|
|
121
|
+
const redactedCopy = copy.text !== captured.diff;
|
|
122
|
+
// An isolated candidate's envelope is the only other holder of the exact
|
|
123
|
+
// bytes and is about to be removed, so its exact object is written NOW. If
|
|
124
|
+
// that write fails the envelope is kept: a deferred Apply then refuses typed
|
|
125
|
+
// while the bytes, the answer and the run state stay readable.
|
|
126
|
+
const retained = redactedCopy &&
|
|
127
|
+
!inPlace &&
|
|
128
|
+
createRevertAnchorFromPatchOrNull(input.projectRoot, captured.diff) === null;
|
|
129
|
+
if (retained)
|
|
130
|
+
wsm.retainEnvelope(envelope);
|
|
131
|
+
return {
|
|
132
|
+
diff: captured.diff,
|
|
133
|
+
...(redactedCopy ? { persistedDiff: copy.text } : {}),
|
|
134
|
+
...(secretLike ? { secretLike } : {}),
|
|
135
|
+
...(retained ? { exactBytesRetainedAt: envelope.worktree_path } : {}),
|
|
136
|
+
};
|
|
122
137
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
if (absolute !== resolve(root) && !absolute.startsWith(resolve(root) + sep))
|
|
126
|
-
return absolute;
|
|
127
|
-
try {
|
|
128
|
-
return realpathSync.native(absolute);
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
return absolute;
|
|
132
|
-
}
|
|
138
|
+
function refused(disposition, detail) {
|
|
139
|
+
return { diff: "", captureRefusal: { disposition, detail } };
|
|
133
140
|
}
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Write a run's final patch: the saved copy to `final/patch.diff`, the exact
|
|
143
|
+
* bytes to the private exact patch object when the copy hides anything, and
|
|
144
|
+
* the disclosure fields for `work_product.yaml` meta. `patchSha256` is ALWAYS
|
|
145
|
+
* the digest of the exact patch, so a redacted copy can never pass the apply
|
|
146
|
+
* gate's digest binding on any route.
|
|
147
|
+
*/
|
|
148
|
+
export function persistFinalPatch(store, finalDir, run) {
|
|
149
|
+
const copy = run.persistedDiff ?? persistedPatchCopy(run.diff, []).text;
|
|
150
|
+
assertPersistableText("final patch copy", copy);
|
|
151
|
+
store.writeText(join(finalDir, "patch.diff"), copy);
|
|
152
|
+
const meta = run.secretLike ? { secret_like: run.secretLike } : {};
|
|
153
|
+
if (copy !== run.diff) {
|
|
154
|
+
meta["persisted_patch"] = "redacted";
|
|
155
|
+
// null: the exact bytes could not be stored; a deferred Apply answers
|
|
156
|
+
// patch_exact_bytes_unavailable instead of applying the copy.
|
|
157
|
+
const exactObject = createRevertAnchorFromPatchOrNull(store.repoRoot, run.diff);
|
|
158
|
+
meta["exact_patch_object"] = exactObject;
|
|
159
|
+
if (exactObject === null && run.exactBytesRetainedAt) {
|
|
160
|
+
meta["exact_bytes_retained_at"] = run.exactBytesRetainedAt;
|
|
161
|
+
}
|
|
139
162
|
}
|
|
163
|
+
return { patchSha256: sha256(run.diff), meta };
|
|
164
|
+
}
|
|
165
|
+
export { secretLikeSummaryLine };
|
|
166
|
+
/** `\n`-prefixed disclosure line for a summary template; "" when clean. */
|
|
167
|
+
export function summaryDisclosure(finding) {
|
|
168
|
+
const line = secretLikeSummaryLine(finding);
|
|
169
|
+
return line ? `\n${line}` : "";
|
|
140
170
|
}
|
|
141
171
|
//# sourceMappingURL=secretDiff.js.map
|
package/dist/secretDiff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secretDiff.js","sourceRoot":"","sources":["../src/secretDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"secretDiff.js","sourceRoot":"","sources":["../src/secretDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,iCAAiC,EAAyB,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAW7B,MAAM,UAAU,oBAAoB,CAClC,OAAmC,EACnC,MAAgB,EAChB,aAAsB;IAEtB,IAAI,CAAC,OAAO;QAAE,OAAO,aAAa,CAAC;IACnC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,OAAuB;IAC/D,OAAO,OAAO,CAAC,WAAW,KAAK,gBAAgB;QAC7C,CAAC,CAAC,CAAC,0DAA0D,EAAE,eAAe,CAAC;QAC/E,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;AACxB,CAAC;AAED;;;;gEAIgE;AAChE,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAC/C,YAAY,GAAkB,IAAI,CAAC;IACnC,WAAW,GAAG,CAAC,CAAC;IAChB,QAAQ,CAAqB;IAErC,cAAc,CAAC,GAAiB,EAAE,IA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K,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,IAAI,GAA4B,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,iBAAiB,CAAC,GAAG,UAAU,CAAC;QACrC,sEAAsE;QACtE,8DAA8D;QAC9D,MAAM,WAAW,GAAG,iCAAiC,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,oBAAoB,CAAC,GAAG,WAAW,CAAC;QACzC,IAAI,WAAW,KAAK,IAAI,IAAI,GAAG,CAAC,oBAAoB,EAAE,CAAC;YACrD,IAAI,CAAC,yBAAyB,CAAC,GAAG,GAAG,CAAC,oBAAoB,CAAC;QAC7D,CAAC;IACH,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAC,OAAsC;IACtE,MAAM,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SessionCapsule, type CredentialProfile } from "@claudexor/schema";
|
|
2
|
+
import { type EnvMap, type HarnessContinuityCapability } from "@claudexor/core";
|
|
3
|
+
export declare const SESSION_CAPSULE_FILE = "session-capsule.json";
|
|
4
|
+
export declare function sessionCapsulePath(attemptDir: string): string;
|
|
5
|
+
/** Atomic-enough write (temp + rename is overkill for a one-line JSON; a torn
|
|
6
|
+
* write fails `readSessionCapsule`'s parse and reads as "no capsule"). */
|
|
7
|
+
export declare function writeSessionCapsule(attemptDir: string, capsule: SessionCapsule): void;
|
|
8
|
+
/** The attempt's capsule, or null when none was written or it does not parse. */
|
|
9
|
+
export declare function readSessionCapsule(attemptDir: string): SessionCapsule | null;
|
|
10
|
+
/**
|
|
11
|
+
* The EnvMap the adapter's `locate`/`move` resolve a store from: the child's
|
|
12
|
+
* spec env plus the registry locator of the profile that holds the session.
|
|
13
|
+
* The engine names the row's `isolation_locator` under ONE neutral key; the
|
|
14
|
+
* adapter maps it onto its vendor variable (INV-135, no vendor paths here).
|
|
15
|
+
*/
|
|
16
|
+
export declare function storeEnvFor(specEnv: Record<string, string> | undefined, profile: Pick<CredentialProfile, "isolation_locator"> | null | undefined): EnvMap;
|
|
17
|
+
/** The registry row of a profile id, or null for the engine default. */
|
|
18
|
+
export declare function registryProfile(registry: readonly CredentialProfile[], profileId: string | null): CredentialProfile | null;
|
|
19
|
+
/**
|
|
20
|
+
* Re-locate the capsule's holder file through the adapter (best-effort I/O).
|
|
21
|
+
* A located file refreshes `file`/`mtimeMs`/`sidecars`; a miss leaves the
|
|
22
|
+
* capsule as it was (a resume by id; only adapters with `continuity` have the
|
|
23
|
+
* engine compare the resumed session id). Never throws.
|
|
24
|
+
*/
|
|
25
|
+
export declare function relocateSessionCapsule(capsule: SessionCapsule, continuity: HarnessContinuityCapability | undefined, env: EnvMap): Promise<{
|
|
26
|
+
capsule: SessionCapsule;
|
|
27
|
+
located: boolean | null;
|
|
28
|
+
}>;
|
|
29
|
+
//# sourceMappingURL=session-capsule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-capsule.d.ts","sourceRoot":"","sources":["../src/session-capsule.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,2BAA2B,EACjC,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;0EAC0E;AAC1E,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAIrF;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAQ5E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,GAAG,IAAI,GAAG,SAAS,GACvE,MAAM,CAMR;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,SAAS,EAAE,MAAM,GAAG,IAAI,GACvB,iBAAiB,GAAG,IAAI,CAG1B;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,2BAA2B,GAAG,SAAS,EACnD,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC,CAoB/D"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session capsule (A5): ONE durable record per attempt of the native vendor
|
|
3
|
+
* session — `attempts/<attemptId>/session-capsule.json` under the run dir.
|
|
4
|
+
*
|
|
5
|
+
* Written by the orchestrator when `started` reports a native session id (every
|
|
6
|
+
* try, every envelope kind, standalone runs included — the daemon's thread
|
|
7
|
+
* callback is not standalone persistence), re-located after the try settles
|
|
8
|
+
* (the vendor may write the history file after `started`) and refreshed after
|
|
9
|
+
* a move. The holder is the concrete file the adapter's `locate` found; a
|
|
10
|
+
* session has one holder at a time. Readers: the in-run continuation loop,
|
|
11
|
+
* the `continueFrom` run chain and the thread store's projection.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
import { SessionCapsule } from "@claudexor/schema";
|
|
16
|
+
import { CONTINUITY_PROFILE_LOCATOR_ENV, } from "@claudexor/core";
|
|
17
|
+
export const SESSION_CAPSULE_FILE = "session-capsule.json";
|
|
18
|
+
export function sessionCapsulePath(attemptDir) {
|
|
19
|
+
return join(attemptDir, SESSION_CAPSULE_FILE);
|
|
20
|
+
}
|
|
21
|
+
/** Atomic-enough write (temp + rename is overkill for a one-line JSON; a torn
|
|
22
|
+
* write fails `readSessionCapsule`'s parse and reads as "no capsule"). */
|
|
23
|
+
export function writeSessionCapsule(attemptDir, capsule) {
|
|
24
|
+
const path = sessionCapsulePath(attemptDir);
|
|
25
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
26
|
+
writeFileSync(path, JSON.stringify(SessionCapsule.parse(capsule), null, 2) + "\n");
|
|
27
|
+
}
|
|
28
|
+
/** The attempt's capsule, or null when none was written or it does not parse. */
|
|
29
|
+
export function readSessionCapsule(attemptDir) {
|
|
30
|
+
const path = sessionCapsulePath(attemptDir);
|
|
31
|
+
if (!existsSync(path))
|
|
32
|
+
return null;
|
|
33
|
+
try {
|
|
34
|
+
return SessionCapsule.parse(JSON.parse(readFileSync(path, "utf8")));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The EnvMap the adapter's `locate`/`move` resolve a store from: the child's
|
|
42
|
+
* spec env plus the registry locator of the profile that holds the session.
|
|
43
|
+
* The engine names the row's `isolation_locator` under ONE neutral key; the
|
|
44
|
+
* adapter maps it onto its vendor variable (INV-135, no vendor paths here).
|
|
45
|
+
*/
|
|
46
|
+
export function storeEnvFor(specEnv, profile) {
|
|
47
|
+
const locator = profile?.isolation_locator ?? null;
|
|
48
|
+
return {
|
|
49
|
+
...(specEnv ?? {}),
|
|
50
|
+
...(locator ? { [CONTINUITY_PROFILE_LOCATOR_ENV]: locator } : {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The registry row of a profile id, or null for the engine default. */
|
|
54
|
+
export function registryProfile(registry, profileId) {
|
|
55
|
+
if (profileId === null)
|
|
56
|
+
return null;
|
|
57
|
+
return registry.find((row) => row.profile_id === profileId) ?? null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Re-locate the capsule's holder file through the adapter (best-effort I/O).
|
|
61
|
+
* A located file refreshes `file`/`mtimeMs`/`sidecars`; a miss leaves the
|
|
62
|
+
* capsule as it was (a resume by id; only adapters with `continuity` have the
|
|
63
|
+
* engine compare the resumed session id). Never throws.
|
|
64
|
+
*/
|
|
65
|
+
export async function relocateSessionCapsule(capsule, continuity, env) {
|
|
66
|
+
if (!continuity)
|
|
67
|
+
return { capsule, located: null };
|
|
68
|
+
try {
|
|
69
|
+
const found = await continuity.locate({ nativeSessionId: capsule.nativeSessionId, cwd: capsule.cwd }, env);
|
|
70
|
+
if (!found.found)
|
|
71
|
+
return { capsule, located: false };
|
|
72
|
+
return {
|
|
73
|
+
capsule: {
|
|
74
|
+
...capsule,
|
|
75
|
+
file: found.file,
|
|
76
|
+
mtimeMs: found.mtimeMs,
|
|
77
|
+
sidecars: found.sidecars,
|
|
78
|
+
},
|
|
79
|
+
located: true,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return { capsule, located: false };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=session-capsule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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