@akagilnc/pi-workflow-roles 0.1.5483 → 0.1.5571
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/acp-host/production-host.js +6312 -6376
- package/dist/analyst-gate-cycles-read.js +28 -78
- package/dist/analyst-ledger.js +26 -42
- package/dist/analyst-metric-families/acceptance-success-rework.js +25 -1
- package/dist/analyst-metric-families/round-timeline.js +2 -5
- package/dist/archivist-record-entry.js +4 -3
- package/dist/archivist-record-pointer.js +71 -36
- package/dist/atomic-write.js +2 -2
- package/dist/auditor-dossier-tool.js +11 -6
- package/dist/auditor-soul.js +5 -12
- package/dist/collector-config.js +6 -5
- package/dist/doctor-evidence.js +8 -4
- package/dist/engine-detour-usage.js +8 -22
- package/dist/headless-host/production-host.js +5969 -6011
- package/dist/host-descriptions.js +0 -4
- package/dist/host-session-record.js +266 -267
- package/dist/ledger-session-read.js +5 -0
- package/dist/migrate-book-topology.js +1369 -722
- package/dist/navigator-public-session.js +13 -17
- package/dist/notary-source-run.js +8 -16
- package/dist/packaged-role-registry.js +5 -56
- package/dist/pi/durable-principal.js +2 -3
- package/dist/pi/role-turn-host.js +79 -15
- package/dist/public-cli/auto-resume.js +8 -47
- package/dist/public-cli/instruction-seat-run.js +9 -7
- package/dist/public-cli/invocation.js +67 -100
- package/dist/public-cli/main.js +2689 -2532
- package/dist/public-cli/post-admission.js +96 -55
- package/dist/public-cli/run-lifecycle.js +44 -100
- package/dist/public-cli/settlement.js +184 -429
- package/dist/public-cli/terminal.js +0 -12
- package/dist/role-run-placement.js +53 -16
- package/dist/role-run-relocation.js +111 -52
- package/dist/run-dossier-files.js +30 -0
- package/dist/run-dossier.js +322 -0
- package/dist/run-terminal-artifacts.js +69 -202
- package/dist/run-ticket-number.js +49 -7
- package/dist/session-assistant-usage.js +9 -18
- package/dist/session-identity.js +49 -19
- package/dist/sitian-appender.js +29 -18
- package/dist/sitian-facade.js +11 -0
- package/dist/sitian-reader.js +44 -29
- package/dist/submission-gate.js +1 -1
- package/dist/submission-ledger.js +4 -4
- package/dist/ticket-provenance-contracts.js +2 -8
- package/dist/ticket-provenance.js +25 -9
- package/package.json +1 -1
- package/scripts/build-package.mjs +2 -0
- package/src/acp-host/production-host.ts +1 -1
- package/src/acp-host/role-turn-host.ts +11 -4
- package/src/analyst-gate-cycles-read.ts +31 -88
- package/src/analyst-ledger.ts +36 -51
- package/src/analyst-metric-families/acceptance-success-rework.ts +24 -1
- package/src/analyst-metric-families/gate-cycles.ts +1 -1
- package/src/analyst-metric-families/round-timeline.ts +2 -5
- package/src/analyst-page.ts +3 -3
- package/src/archivist-record-entry.ts +6 -5
- package/src/archivist-record-pointer.ts +92 -42
- package/src/atomic-write.ts +3 -1
- package/src/auditor-dossier-tool.ts +14 -8
- package/src/auditor-soul.ts +5 -10
- package/src/book-topology-migration-placement.ts +16 -3
- package/src/book-topology-record-class-migrators.ts +4 -2
- package/src/book-topology-runs-migrator.ts +6 -3
- package/src/collector-config.ts +5 -3
- package/src/doctor-contracts.ts +1 -1
- package/src/doctor-evidence.ts +7 -3
- package/src/engine-detour-tool.ts +1 -1
- package/src/engine-detour-usage.ts +12 -25
- package/src/external-host-turn-loop.ts +25 -0
- package/src/factory-board.ts +16 -81
- package/src/headless-host/production-host.ts +1 -4
- package/src/headless-host/role-turn-host.ts +56 -21
- package/src/host-descriptions.ts +0 -6
- package/src/host-session-record.ts +224 -140
- package/src/ledger-session-read.ts +6 -0
- package/src/navigator-public-session.ts +13 -18
- package/src/navigator-work-context.ts +3 -1
- package/src/notary-role.ts +2 -1
- package/src/notary-source-run.ts +8 -18
- package/src/packaged-role-registry.ts +1 -65
- package/src/pi/adapter.ts +50 -7
- package/src/pi/durable-principal.ts +2 -4
- package/src/pi/role-turn-host.ts +85 -14
- package/src/public-cli/auto-resume.ts +7 -43
- package/src/public-cli/instruction-seat-run.ts +13 -6
- package/src/public-cli/invocation.ts +90 -144
- package/src/public-cli/post-admission.ts +111 -72
- package/src/public-cli/run-lifecycle.ts +47 -115
- package/src/public-cli/settlement.ts +221 -589
- package/src/public-cli/terminal.ts +1 -61
- package/src/role-envelope.ts +4 -2
- package/src/role-run-placement.ts +65 -17
- package/src/role-run-relocation.ts +110 -70
- package/src/role-runtime.ts +46 -69
- package/src/run-dossier-files.ts +33 -0
- package/src/run-dossier.ts +357 -0
- package/src/run-terminal-artifacts.ts +84 -240
- package/src/run-ticket-number.ts +82 -14
- package/src/session-assistant-usage.ts +8 -20
- package/src/session-identity.ts +52 -21
- package/src/sitian-appender.ts +33 -26
- package/src/sitian-facade.ts +22 -0
- package/src/sitian-reader.ts +62 -32
- package/src/submission-gate.ts +1 -1
- package/src/submission-ledger.ts +4 -4
- package/src/ticket-provenance-contracts.ts +3 -6
- package/src/ticket-provenance.ts +23 -11
- package/src/ticket-snapshot.ts +3 -2
- package/src/ticket-trajectory.ts +95 -109
|
@@ -499,6 +499,10 @@ function errorText(error) {
|
|
|
499
499
|
function isEnoent(error) {
|
|
500
500
|
return error instanceof Error && errnoCode(error) === "ENOENT";
|
|
501
501
|
}
|
|
502
|
+
function isMissingPathError(error) {
|
|
503
|
+
const code = errnoCode(error);
|
|
504
|
+
return error instanceof Error && (code === "ENOENT" || code === "ENOTDIR");
|
|
505
|
+
}
|
|
502
506
|
var init_unknown_value = __esm({
|
|
503
507
|
"src/unknown-value.ts"() {
|
|
504
508
|
"use strict";
|
|
@@ -513,7 +517,37 @@ import {
|
|
|
513
517
|
realpathSync,
|
|
514
518
|
statSync
|
|
515
519
|
} from "node:fs";
|
|
520
|
+
import { userInfo } from "node:os";
|
|
516
521
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
522
|
+
function packageMachineHome() {
|
|
523
|
+
return resolve(userInfo().homedir);
|
|
524
|
+
}
|
|
525
|
+
function tryHomeFromAkRolesPath(path8) {
|
|
526
|
+
const match3 = /(^|[\\/])\.ak-roles(?=[\\/]|$)/.exec(path8);
|
|
527
|
+
if (!match3) return void 0;
|
|
528
|
+
if (match3.index === 0) {
|
|
529
|
+
return match3[1] === "" ? "" : match3[1];
|
|
530
|
+
}
|
|
531
|
+
return path8.slice(0, match3.index);
|
|
532
|
+
}
|
|
533
|
+
function resolveActivationLedgerHome(home) {
|
|
534
|
+
const processHome = typeof home === "string" ? home : packageMachineHome();
|
|
535
|
+
if (typeof processHome !== "string" || processHome.length === 0 || !isAbsolute(processHome)) {
|
|
536
|
+
throw new ActivationLedgerError(
|
|
537
|
+
`activation ledger process home must be absolute, got ${JSON.stringify(processHome)}`
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
return resolve(processHome, ".ak-roles");
|
|
541
|
+
}
|
|
542
|
+
function resolveActivationLedgerHomeForPath(path8) {
|
|
543
|
+
if (typeof path8 === "string" && path8.length > 0) {
|
|
544
|
+
const derived = tryHomeFromAkRolesPath(path8);
|
|
545
|
+
if (derived !== void 0 && derived.length > 0) {
|
|
546
|
+
return resolveActivationLedgerHome(derived);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return resolveActivationLedgerHome();
|
|
550
|
+
}
|
|
517
551
|
function activationBookDirectory(ledgerHome, bookKey) {
|
|
518
552
|
return join(ledgerHome, "books", bookKey);
|
|
519
553
|
}
|
|
@@ -543,18 +577,667 @@ function physicalPathIdentity(path8) {
|
|
|
543
577
|
function physicallyContainedIn(root, candidate) {
|
|
544
578
|
return pathContainedIn(physicalPathIdentity(root), physicalPathIdentity(candidate));
|
|
545
579
|
}
|
|
580
|
+
function assertPhysicalLedgerRoot(absoluteRoot) {
|
|
581
|
+
let st2;
|
|
582
|
+
try {
|
|
583
|
+
st2 = lstatSync(absoluteRoot);
|
|
584
|
+
} catch (error) {
|
|
585
|
+
if (errnoCode(error) !== "ENOENT") {
|
|
586
|
+
throw new ActivationLedgerError(
|
|
587
|
+
`activation ledger failed to stat home (${absoluteRoot}): ${errorText(error)}`,
|
|
588
|
+
{ cause: error }
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (st2 === void 0) {
|
|
593
|
+
try {
|
|
594
|
+
mkdirSync(absoluteRoot, { recursive: true });
|
|
595
|
+
} catch (error) {
|
|
596
|
+
if (errnoCode(error) !== "EEXIST") {
|
|
597
|
+
throw new ActivationLedgerError(
|
|
598
|
+
`activation ledger failed to create home (${absoluteRoot}): ${errorText(error)}`,
|
|
599
|
+
{ cause: error }
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
try {
|
|
604
|
+
st2 = lstatSync(absoluteRoot);
|
|
605
|
+
} catch (error) {
|
|
606
|
+
throw new ActivationLedgerError(
|
|
607
|
+
`activation ledger failed to stat home (${absoluteRoot}): ${errorText(error)}`,
|
|
608
|
+
{ cause: error }
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (st2.isSymbolicLink()) {
|
|
613
|
+
throw new ActivationLedgerError(
|
|
614
|
+
`activation ledger home is a symbolic link: ${absoluteRoot}`
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
if (!st2.isDirectory()) {
|
|
618
|
+
throw new ActivationLedgerError(`activation ledger home is not a directory: ${absoluteRoot}`);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
function ensureRealDirectoryTree(root, targetDir) {
|
|
622
|
+
if (!isAbsolute(root)) {
|
|
623
|
+
throw new ActivationLedgerError(`activation ledger home must be absolute: ${root}`);
|
|
624
|
+
}
|
|
625
|
+
const absoluteRoot = resolve(root);
|
|
626
|
+
const absoluteTarget = resolve(targetDir);
|
|
627
|
+
if (absoluteTarget !== absoluteRoot && !pathContainedIn(absoluteRoot, absoluteTarget)) {
|
|
628
|
+
throw new ActivationLedgerError(
|
|
629
|
+
`activation ledger path escapes ledger home (${absoluteRoot}): ${absoluteTarget}`
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
assertPhysicalLedgerRoot(absoluteRoot);
|
|
633
|
+
let realRoot;
|
|
634
|
+
try {
|
|
635
|
+
realRoot = realpathSync(absoluteRoot);
|
|
636
|
+
} catch (error) {
|
|
637
|
+
throw new ActivationLedgerError(
|
|
638
|
+
`activation ledger home is not resolvable (${absoluteRoot}): ${errorText(error)}`,
|
|
639
|
+
{ cause: error }
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
if (!statSync(realRoot).isDirectory()) {
|
|
643
|
+
throw new ActivationLedgerError(`activation ledger home is not a directory: ${realRoot}`);
|
|
644
|
+
}
|
|
645
|
+
const rel = absoluteTarget === absoluteRoot ? "" : relative(absoluteRoot, absoluteTarget);
|
|
646
|
+
if (rel === "") return realRoot;
|
|
647
|
+
if (isAbsolute(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
648
|
+
throw new ActivationLedgerError(
|
|
649
|
+
`activation ledger path escapes ledger home (${absoluteRoot}): ${absoluteTarget}`
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
let lexicalCursor = absoluteRoot;
|
|
653
|
+
for (const part of rel.split(sep)) {
|
|
654
|
+
if (part === "" || part === ".") continue;
|
|
655
|
+
if (part === "..") {
|
|
656
|
+
throw new ActivationLedgerError(`activation ledger path contains '..': ${absoluteTarget}`);
|
|
657
|
+
}
|
|
658
|
+
lexicalCursor = join(lexicalCursor, part);
|
|
659
|
+
let st2;
|
|
660
|
+
try {
|
|
661
|
+
st2 = lstatSync(lexicalCursor);
|
|
662
|
+
} catch (error) {
|
|
663
|
+
if (errnoCode(error) !== "ENOENT") {
|
|
664
|
+
throw new ActivationLedgerError(
|
|
665
|
+
`activation ledger failed to stat path component (${lexicalCursor}): ${errorText(error)}`,
|
|
666
|
+
{ cause: error }
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
try {
|
|
670
|
+
mkdirSync(lexicalCursor);
|
|
671
|
+
} catch (mkdirError) {
|
|
672
|
+
if (errnoCode(mkdirError) !== "EEXIST") {
|
|
673
|
+
throw new ActivationLedgerError(
|
|
674
|
+
`activation ledger failed to create directory (${lexicalCursor}): ${errorText(mkdirError)}`,
|
|
675
|
+
{ cause: mkdirError }
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
try {
|
|
680
|
+
st2 = lstatSync(lexicalCursor);
|
|
681
|
+
} catch (statError) {
|
|
682
|
+
throw new ActivationLedgerError(
|
|
683
|
+
`activation ledger failed to stat path component (${lexicalCursor}): ${errorText(statError)}`,
|
|
684
|
+
{ cause: statError }
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (st2.isSymbolicLink()) {
|
|
689
|
+
throw new ActivationLedgerError(
|
|
690
|
+
`activation ledger path component is a symbolic link: ${lexicalCursor}`
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
if (!st2.isDirectory()) {
|
|
694
|
+
throw new ActivationLedgerError(`activation ledger path component is not a directory: ${lexicalCursor}`);
|
|
695
|
+
}
|
|
696
|
+
let realCursor;
|
|
697
|
+
try {
|
|
698
|
+
realCursor = realpathSync(lexicalCursor);
|
|
699
|
+
} catch (error) {
|
|
700
|
+
throw new ActivationLedgerError(
|
|
701
|
+
`activation ledger path component is not resolvable (${lexicalCursor}): ${errorText(error)}`,
|
|
702
|
+
{ cause: error }
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
if (realCursor !== realRoot && !pathContainedIn(realRoot, realCursor)) {
|
|
706
|
+
throw new ActivationLedgerError(
|
|
707
|
+
`activation ledger path component escapes ledger home (${lexicalCursor} -> ${realCursor})`
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
try {
|
|
712
|
+
return realpathSync(absoluteTarget);
|
|
713
|
+
} catch (error) {
|
|
714
|
+
throw new ActivationLedgerError(
|
|
715
|
+
`activation ledger directory is not resolvable (${absoluteTarget}): ${errorText(error)}`,
|
|
716
|
+
{ cause: error }
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
var ActivationLedgerError;
|
|
546
721
|
var init_activation_ledger_topology = __esm({
|
|
547
722
|
"src/activation-ledger-topology.ts"() {
|
|
548
723
|
"use strict";
|
|
549
724
|
init_unknown_value();
|
|
725
|
+
ActivationLedgerError = class extends Error {
|
|
726
|
+
code = "AK_ACTIVATION_LEDGER";
|
|
727
|
+
constructor(message, options) {
|
|
728
|
+
super(
|
|
729
|
+
message,
|
|
730
|
+
options?.cause === void 0 ? void 0 : { cause: options.cause }
|
|
731
|
+
);
|
|
732
|
+
this.name = "ActivationLedgerError";
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
// src/run-dossier-files.ts
|
|
739
|
+
var RUN_CURRENT_FILE, RUN_HISTORY_FILE, RUN_LOG_FILE, RUN_STATE_FILE, RUN_HISTORY_KINDS, OFFICER_POINTER_RECORD_KIND, RUN_STATE_KINDS;
|
|
740
|
+
var init_run_dossier_files = __esm({
|
|
741
|
+
"src/run-dossier-files.ts"() {
|
|
742
|
+
"use strict";
|
|
743
|
+
RUN_CURRENT_FILE = "current.json";
|
|
744
|
+
RUN_HISTORY_FILE = "history.jsonl";
|
|
745
|
+
RUN_LOG_FILE = "log.jsonl";
|
|
746
|
+
RUN_STATE_FILE = "state.jsonl";
|
|
747
|
+
RUN_HISTORY_KINDS = /* @__PURE__ */ new Set([
|
|
748
|
+
"candidate",
|
|
749
|
+
"roundContext",
|
|
750
|
+
"outcome",
|
|
751
|
+
"sealed",
|
|
752
|
+
"post-seal-anomaly",
|
|
753
|
+
"attempt-history",
|
|
754
|
+
"turn-delivery",
|
|
755
|
+
"officer-pointer"
|
|
756
|
+
]);
|
|
757
|
+
OFFICER_POINTER_RECORD_KIND = "officer-pointer";
|
|
758
|
+
RUN_STATE_KINDS = /* @__PURE__ */ new Set([
|
|
759
|
+
"invocation",
|
|
760
|
+
"admitted-request",
|
|
761
|
+
"run-state",
|
|
762
|
+
"terminal",
|
|
763
|
+
"host-session-id"
|
|
764
|
+
]);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
// src/activation-ledger-git.ts
|
|
769
|
+
import { execFileSync } from "node:child_process";
|
|
770
|
+
import { basename as basename2, dirname as dirname2, isAbsolute as isAbsolute2, resolve as resolve2 } from "node:path";
|
|
771
|
+
function envWithoutGitDiscovery(base = process.env) {
|
|
772
|
+
const env2 = { ...base, LC_ALL: "C" };
|
|
773
|
+
for (const key of GIT_DISCOVERY_ENV_KEYS) {
|
|
774
|
+
delete env2[key];
|
|
775
|
+
}
|
|
776
|
+
return env2;
|
|
777
|
+
}
|
|
778
|
+
function isConfirmedNonRepositoryStderr(stderr) {
|
|
779
|
+
return CONFIRMED_NON_REPOSITORY_STDERR.test(stderr);
|
|
780
|
+
}
|
|
781
|
+
function isGitSpawnInfrastructureError(error) {
|
|
782
|
+
const code = errnoCode(error);
|
|
783
|
+
return code === "ENOENT" || code === "EACCES" || code === "EPERM";
|
|
784
|
+
}
|
|
785
|
+
function gitChildExitedNonzero(error) {
|
|
786
|
+
if (error === null || typeof error !== "object" || !("status" in error)) return false;
|
|
787
|
+
const status = error.status;
|
|
788
|
+
return typeof status === "number" && status !== 0;
|
|
789
|
+
}
|
|
790
|
+
function resolveBookKeyFromGit(cwd) {
|
|
791
|
+
let commonDir;
|
|
792
|
+
try {
|
|
793
|
+
commonDir = execFileSync("git", ["rev-parse", "--git-common-dir"], {
|
|
794
|
+
cwd,
|
|
795
|
+
encoding: "utf8",
|
|
796
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
797
|
+
env: envWithoutGitDiscovery()
|
|
798
|
+
}).trim();
|
|
799
|
+
} catch (error) {
|
|
800
|
+
if (isGitSpawnInfrastructureError(error) || !gitChildExitedNonzero(error)) {
|
|
801
|
+
throw error;
|
|
802
|
+
}
|
|
803
|
+
const err2 = error;
|
|
804
|
+
const detail = typeof err2.stderr === "string" ? err2.stderr.trim() : Buffer.isBuffer(err2.stderr) ? err2.stderr.toString("utf8").trim() : typeof err2.message === "string" ? err2.message : "";
|
|
805
|
+
throw new ActivationGitRepositoryRequiredError(detail || "unknown git error", {
|
|
806
|
+
cause: error,
|
|
807
|
+
confirmedNonRepository: isConfirmedNonRepositoryStderr(detail)
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
if (commonDir.length === 0) {
|
|
811
|
+
throw new Error("git rev-parse --git-common-dir returned an empty path");
|
|
812
|
+
}
|
|
813
|
+
const absoluteCommon = isAbsolute2(commonDir) ? commonDir : resolve2(cwd, commonDir);
|
|
814
|
+
const hostDirectory = basename2(absoluteCommon) === ".git" ? dirname2(absoluteCommon) : absoluteCommon;
|
|
815
|
+
const bookKey = basename2(hostDirectory);
|
|
816
|
+
if (bookKey.length === 0 || bookKey === "." || bookKey === "/") {
|
|
817
|
+
throw new Error(`Unable to derive activation book key from git common dir: ${absoluteCommon}`);
|
|
818
|
+
}
|
|
819
|
+
return bookKey;
|
|
820
|
+
}
|
|
821
|
+
var GIT_DISCOVERY_ENV_KEYS, CONFIRMED_NON_REPOSITORY_STDERR, ActivationGitRepositoryRequiredError;
|
|
822
|
+
var init_activation_ledger_git = __esm({
|
|
823
|
+
"src/activation-ledger-git.ts"() {
|
|
824
|
+
"use strict";
|
|
825
|
+
init_unknown_value();
|
|
826
|
+
GIT_DISCOVERY_ENV_KEYS = [
|
|
827
|
+
"GIT_DIR",
|
|
828
|
+
"GIT_COMMON_DIR",
|
|
829
|
+
"GIT_WORK_TREE",
|
|
830
|
+
"GIT_CEILING_DIRECTORIES",
|
|
831
|
+
"GIT_DISCOVERY_ACROSS_FILESYSTEM"
|
|
832
|
+
];
|
|
833
|
+
CONFIRMED_NON_REPOSITORY_STDERR = /^fatal:\s*not a git repository/i;
|
|
834
|
+
ActivationGitRepositoryRequiredError = class extends Error {
|
|
835
|
+
code = "AK_ACTIVATION_GIT_REPOSITORY_REQUIRED";
|
|
836
|
+
confirmedNonRepository;
|
|
837
|
+
constructor(detail, options) {
|
|
838
|
+
super(
|
|
839
|
+
`Workflow role activation requires a git repository cwd (git rev-parse --git-common-dir failed): ${detail || "unknown git error"}`,
|
|
840
|
+
options?.cause === void 0 ? void 0 : { cause: options.cause }
|
|
841
|
+
);
|
|
842
|
+
this.name = "ActivationGitRepositoryRequiredError";
|
|
843
|
+
this.confirmedNonRepository = options?.confirmedNonRepository ?? false;
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
// src/sitian-contracts.ts
|
|
850
|
+
function attachDirectErrnoCode(error, cause) {
|
|
851
|
+
if (cause === null || typeof cause !== "object" || !("code" in cause)) return;
|
|
852
|
+
const code = cause.code;
|
|
853
|
+
if (typeof code === "string") error.code = code;
|
|
854
|
+
}
|
|
855
|
+
var SitianInfrastructureError;
|
|
856
|
+
var init_sitian_contracts = __esm({
|
|
857
|
+
"src/sitian-contracts.ts"() {
|
|
858
|
+
"use strict";
|
|
859
|
+
SitianInfrastructureError = class extends Error {
|
|
860
|
+
knownCause = "session";
|
|
861
|
+
constructor(message, options) {
|
|
862
|
+
super(message, options);
|
|
863
|
+
this.name = "SitianInfrastructureError";
|
|
864
|
+
attachDirectErrnoCode(this, options?.cause);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// src/sitian-appender.ts
|
|
871
|
+
import { randomUUID } from "node:crypto";
|
|
872
|
+
import { appendFileSync } from "node:fs";
|
|
873
|
+
import { basename as basename3, dirname as dirname3, join as join2 } from "node:path";
|
|
874
|
+
function resolveSitianVolumeCategory(kind) {
|
|
875
|
+
return kind;
|
|
876
|
+
}
|
|
877
|
+
function sitianVolumeDirectory(sessionDirectory, category) {
|
|
878
|
+
return join2(sessionDirectory, category);
|
|
879
|
+
}
|
|
880
|
+
function sitianVolumeRecordsFile(volumeDirectory) {
|
|
881
|
+
return join2(volumeDirectory, SITIAN_RECORDS_LEAF);
|
|
882
|
+
}
|
|
883
|
+
function ticketProvenanceUnderBookPaths(ledgerHome, bookKey, ticketId) {
|
|
884
|
+
const sessionDir = join2(activationBookDirectory(ledgerHome, bookKey), ticketId);
|
|
885
|
+
return { sessionDir, recordFile: sitianVolumeRecordsFile(sessionDir) };
|
|
886
|
+
}
|
|
887
|
+
function resolveSitianRecordPathInLedger(input, ledgerHome) {
|
|
888
|
+
const category = resolveSitianVolumeCategory(input.kind);
|
|
889
|
+
const ticketNumber = category === "ticket-provenance" ? ticketNumberFromSitianSubject(input.subject) : void 0;
|
|
890
|
+
let sessionDir;
|
|
891
|
+
let recordFile;
|
|
892
|
+
if (ticketNumber !== void 0) {
|
|
893
|
+
const paths = ticketProvenanceUnderBookPaths(
|
|
894
|
+
ledgerHome,
|
|
895
|
+
resolveBookKeyFromGit(input.cwd ?? process.cwd()),
|
|
896
|
+
ticketNumber
|
|
897
|
+
);
|
|
898
|
+
sessionDir = paths.sessionDir;
|
|
899
|
+
recordFile = paths.recordFile;
|
|
900
|
+
} else if (category === "ticket-provenance" && input.runDirectory !== void 0) {
|
|
901
|
+
sessionDir = input.runDirectory;
|
|
902
|
+
recordFile = join2(sessionDir, RUN_HISTORY_FILE);
|
|
903
|
+
} else {
|
|
904
|
+
if (input.sessionParent === void 0 || input.sessionParent.length === 0 || !physicallyContainedIn(ledgerHome, input.sessionParent)) {
|
|
905
|
+
throw new Error("Sitian record ownership requires a parent session inside the ledger home");
|
|
906
|
+
}
|
|
907
|
+
const sessionParentDir = dirname3(input.sessionParent);
|
|
908
|
+
const runDirectory = dirname3(sessionParentDir);
|
|
909
|
+
if (basename3(sessionParentDir) === "session" && parseRunLeaf(basename3(runDirectory)) !== void 0) {
|
|
910
|
+
sessionDir = runDirectory;
|
|
911
|
+
recordFile = join2(runDirectory, RUN_HISTORY_KINDS.has(input.kind) ? RUN_HISTORY_FILE : RUN_STATE_KINDS.has(input.kind) ? RUN_STATE_FILE : RUN_LOG_FILE);
|
|
912
|
+
} else {
|
|
913
|
+
sessionDir = sitianVolumeDirectory(sessionParentDir, category);
|
|
914
|
+
recordFile = sitianVolumeRecordsFile(sessionDir);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
if (!physicallyContainedIn(ledgerHome, sessionDir)) {
|
|
918
|
+
throw new Error("Sitian record ownership requires a directory inside the ledger home");
|
|
919
|
+
}
|
|
920
|
+
return { sessionDir, recordFile, ledgerHome };
|
|
921
|
+
}
|
|
922
|
+
function resolveSitianRecordPath(input) {
|
|
923
|
+
const ledgerHome = input.home !== void 0 && input.home.length > 0 ? resolveActivationLedgerHome(input.home) : resolveActivationLedgerHomeForPath(input.runDirectory ?? input.sessionParent);
|
|
924
|
+
return resolveSitianRecordPathInLedger(input, ledgerHome);
|
|
925
|
+
}
|
|
926
|
+
function appendSitianRecord(input) {
|
|
927
|
+
try {
|
|
928
|
+
const { sessionDir, recordFile, ledgerHome } = resolveSitianRecordPath(input);
|
|
929
|
+
ensureRealDirectoryTree(ledgerHome, sessionDir);
|
|
930
|
+
const identity = input.identity ?? randomUUID();
|
|
931
|
+
const timestamp = input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
932
|
+
const host = input.host ?? "pi";
|
|
933
|
+
const record = {
|
|
934
|
+
level: input.level,
|
|
935
|
+
kind: input.kind,
|
|
936
|
+
identity,
|
|
937
|
+
...input.subject === void 0 ? {} : { subject: input.subject },
|
|
938
|
+
...input.sessionParent === void 0 ? {} : { sessionParent: input.sessionParent },
|
|
939
|
+
timestamp,
|
|
940
|
+
host,
|
|
941
|
+
...input.source === void 0 ? {} : { source: input.source },
|
|
942
|
+
...input.payload === void 0 ? {} : { payload: input.payload },
|
|
943
|
+
...input.raw === void 0 ? {} : { raw: input.raw },
|
|
944
|
+
...input.usage === void 0 ? {} : { usage: input.usage }
|
|
945
|
+
};
|
|
946
|
+
const row = `${JSON.stringify(record)}
|
|
947
|
+
`;
|
|
948
|
+
appendFileSync(recordFile, row, "utf8");
|
|
949
|
+
return {
|
|
950
|
+
identity: record.identity,
|
|
951
|
+
recordFile,
|
|
952
|
+
kind: record.kind,
|
|
953
|
+
level: record.level
|
|
954
|
+
};
|
|
955
|
+
} catch (error) {
|
|
956
|
+
if (error instanceof SitianInfrastructureError) throw error;
|
|
957
|
+
throw new SitianInfrastructureError(
|
|
958
|
+
`Sitian appender persistence failure: ${errorText(error)}`,
|
|
959
|
+
{ cause: error }
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
var SITIAN_RECORDS_LEAF;
|
|
964
|
+
var init_sitian_appender = __esm({
|
|
965
|
+
"src/sitian-appender.ts"() {
|
|
966
|
+
"use strict";
|
|
967
|
+
init_role_run_placement();
|
|
968
|
+
init_run_dossier_files();
|
|
969
|
+
init_run_ticket_number();
|
|
970
|
+
init_activation_ledger_git();
|
|
971
|
+
init_activation_ledger_topology();
|
|
972
|
+
init_sitian_contracts();
|
|
973
|
+
SITIAN_RECORDS_LEAF = "records.jsonl";
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
// src/sitian-reader.ts
|
|
978
|
+
function decodeSitianRecordLine(line, lineNumber) {
|
|
979
|
+
if (!line.trim()) return void 0;
|
|
980
|
+
try {
|
|
981
|
+
const parsed2 = JSON.parse(line);
|
|
982
|
+
if (isRecord(parsed2)) {
|
|
983
|
+
return { ok: true, record: parsed2 };
|
|
984
|
+
}
|
|
985
|
+
const typeDesc = parsed2 === null ? "null" : Array.isArray(parsed2) ? "array" : typeof parsed2;
|
|
986
|
+
return {
|
|
987
|
+
ok: false,
|
|
988
|
+
diagnostic: {
|
|
989
|
+
kind: "malformed",
|
|
990
|
+
line: lineNumber,
|
|
991
|
+
raw: line,
|
|
992
|
+
error: `expected JSON object, got ${typeDesc}`
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
} catch (error) {
|
|
996
|
+
return {
|
|
997
|
+
ok: false,
|
|
998
|
+
diagnostic: {
|
|
999
|
+
kind: "malformed",
|
|
1000
|
+
line: lineNumber,
|
|
1001
|
+
raw: line,
|
|
1002
|
+
error: errorText(error)
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
function parseSitianRecordText(text) {
|
|
1008
|
+
const lines = text.split("\n");
|
|
1009
|
+
const records = [];
|
|
1010
|
+
const diagnostics = [];
|
|
1011
|
+
for (let index3 = 0; index3 < lines.length; index3 += 1) {
|
|
1012
|
+
const decoded = decodeSitianRecordLine(lines[index3], index3 + 1);
|
|
1013
|
+
if (decoded === void 0) continue;
|
|
1014
|
+
if (decoded.ok) records.push(decoded.record);
|
|
1015
|
+
else diagnostics.push(decoded.diagnostic);
|
|
1016
|
+
}
|
|
1017
|
+
return { records, diagnostics };
|
|
1018
|
+
}
|
|
1019
|
+
var init_sitian_reader = __esm({
|
|
1020
|
+
"src/sitian-reader.ts"() {
|
|
1021
|
+
"use strict";
|
|
1022
|
+
init_unknown_value();
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
// src/run-dossier.ts
|
|
1027
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1028
|
+
import { readFileSync, renameSync, rmSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
1029
|
+
import { basename as basename4, join as join3 } from "node:path";
|
|
1030
|
+
function runCurrentPath(runDirectory) {
|
|
1031
|
+
return join3(runDirectory, RUN_CURRENT_FILE);
|
|
1032
|
+
}
|
|
1033
|
+
function readRowFile(path8) {
|
|
1034
|
+
let buffer;
|
|
1035
|
+
try {
|
|
1036
|
+
buffer = readFileSync(path8);
|
|
1037
|
+
} catch (error) {
|
|
1038
|
+
if (isMissingPathError(error)) return { rows: [], bytes: 0 };
|
|
1039
|
+
return { rows: [], bytes: 0, fault: String(error.code ?? error.name) };
|
|
1040
|
+
}
|
|
1041
|
+
const { records, diagnostics } = parseSitianRecordText(buffer.toString("utf8"));
|
|
1042
|
+
return {
|
|
1043
|
+
rows: [...records],
|
|
1044
|
+
bytes: buffer.length,
|
|
1045
|
+
...diagnostics.length > 0 ? { diagnostics: diagnostics.map((d) => ({ line: d.line, error: d.error })) } : {}
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
function fileBytes(path8) {
|
|
1049
|
+
try {
|
|
1050
|
+
return statSync2(path8).size;
|
|
1051
|
+
} catch (error) {
|
|
1052
|
+
return isMissingPathError(error) ? 0 : void 0;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function lastPayloadOfKind(rows, kind) {
|
|
1056
|
+
for (let index3 = rows.length - 1; index3 >= 0; index3 -= 1) {
|
|
1057
|
+
const row = rows[index3];
|
|
1058
|
+
if (row.kind === kind) return row.payload;
|
|
1059
|
+
}
|
|
1060
|
+
return void 0;
|
|
1061
|
+
}
|
|
1062
|
+
function lastPagePayload(rows, kind, runDirectory) {
|
|
1063
|
+
const payload = lastPayloadOfKind(rows, kind);
|
|
1064
|
+
if (payload === void 0) return void 0;
|
|
1065
|
+
if (!isRecord(payload)) {
|
|
1066
|
+
throw new TypeError(`${RUN_STATE_FILE} ${kind} payload is not an object: ${runDirectory}`);
|
|
1067
|
+
}
|
|
1068
|
+
return payload;
|
|
1069
|
+
}
|
|
1070
|
+
function latestOfficerPointersFromRecords(records) {
|
|
1071
|
+
const latest = {};
|
|
1072
|
+
for (const record of records) {
|
|
1073
|
+
if (record.kind !== OFFICER_POINTER_RECORD_KIND) continue;
|
|
1074
|
+
if (!isRecord(record.payload) || typeof record.payload.officer !== "string") {
|
|
1075
|
+
throw new TypeError("officer-pointer payload is not a record with string officer");
|
|
1076
|
+
}
|
|
1077
|
+
latest[record.payload.officer] = record.payload;
|
|
1078
|
+
}
|
|
1079
|
+
return latest;
|
|
1080
|
+
}
|
|
1081
|
+
function render(runDirectory, history, state3, log, unreadable) {
|
|
1082
|
+
const whole = {};
|
|
1083
|
+
for (const section of ["invocation", "admitted", "runState", "terminal"]) {
|
|
1084
|
+
const page = lastPayloadOfKind(state3, PAGE_ROW_KIND[section]);
|
|
1085
|
+
if (page !== void 0) whole[section] = page;
|
|
1086
|
+
}
|
|
1087
|
+
let latest;
|
|
1088
|
+
for (const row of history) {
|
|
1089
|
+
const payload = isRecord(row.payload) ? row.payload : void 0;
|
|
1090
|
+
if (row.kind === "sealed" && payload !== void 0) {
|
|
1091
|
+
latest = { toolCallId: payload.toolCallId, role: payload.role, accepted: payload.accepted, at: row.timestamp };
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
let officers = {};
|
|
1095
|
+
try {
|
|
1096
|
+
officers = latestOfficerPointersFromRecords(history);
|
|
1097
|
+
} catch (error) {
|
|
1098
|
+
if (!(error instanceof TypeError)) throw error;
|
|
1099
|
+
if (unreadable[RUN_HISTORY_FILE] === void 0) unreadable[RUN_HISTORY_FILE] = "malformed";
|
|
1100
|
+
}
|
|
1101
|
+
const sessions = {};
|
|
1102
|
+
for (const row of state3) {
|
|
1103
|
+
const payload = isRecord(row.payload) ? row.payload : void 0;
|
|
1104
|
+
if (row.kind === "host-session-id" && payload !== void 0 && typeof payload.host === "string") {
|
|
1105
|
+
sessions[payload.host] = payload.sessionId;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
let original;
|
|
1109
|
+
for (const row of log) {
|
|
1110
|
+
const payload = isRecord(row.payload) ? row.payload : void 0;
|
|
1111
|
+
if (row.kind === "host-session" && payload?.type === "native-session-copy" && typeof payload.landingPath === "string") {
|
|
1112
|
+
original = payload.landingPath;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
if (typeof original === "string") original = join3(runDirectory, "session", basename4(original));
|
|
1116
|
+
whole.host = { sessions, ...original === void 0 ? {} : { original } };
|
|
1117
|
+
whole.submission = latest === void 0 ? {} : { latest };
|
|
1118
|
+
whole.officers = officers;
|
|
1119
|
+
if (Object.keys(unreadable).length > 0) whole.unreadable = unreadable;
|
|
1120
|
+
return whole;
|
|
1121
|
+
}
|
|
1122
|
+
function writeWhole(runDirectory, whole) {
|
|
1123
|
+
const destination = runCurrentPath(runDirectory);
|
|
1124
|
+
const body = `${JSON.stringify(whole, null, 2)}
|
|
1125
|
+
`;
|
|
1126
|
+
const temporary = join3(runDirectory, `.${RUN_CURRENT_FILE}-${randomUUID2()}.tmp`);
|
|
1127
|
+
try {
|
|
1128
|
+
writeFileSync(temporary, body, "utf8");
|
|
1129
|
+
renameSync(temporary, destination);
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
rmSync(temporary, { force: true });
|
|
1132
|
+
const code = error.code;
|
|
1133
|
+
if (code !== "EACCES" && code !== "EPERM" && code !== "EROFS") throw error;
|
|
1134
|
+
writeFileSync(destination, body, "utf8");
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
function renderCurrentSync(runDirectory) {
|
|
1138
|
+
const paths = [RUN_HISTORY_FILE, RUN_STATE_FILE, RUN_LOG_FILE].map((name) => join3(runDirectory, name));
|
|
1139
|
+
for (; ; ) {
|
|
1140
|
+
const [history, state3, log] = paths.map(readRowFile);
|
|
1141
|
+
const unreadable = {};
|
|
1142
|
+
for (const [name, file] of [[RUN_HISTORY_FILE, history], [RUN_STATE_FILE, state3], [RUN_LOG_FILE, log]]) {
|
|
1143
|
+
if (file.fault !== void 0) unreadable[name] = file.fault;
|
|
1144
|
+
else if (file.diagnostics !== void 0 && file.diagnostics.length > 0) unreadable[name] = "malformed";
|
|
1145
|
+
}
|
|
1146
|
+
const whole = render(runDirectory, history.rows, state3.rows, log.rows, unreadable);
|
|
1147
|
+
for (const [name, code] of Object.entries(unreadable)) {
|
|
1148
|
+
const key = `${runDirectory}\0${name}`;
|
|
1149
|
+
if (declaredUnreadable.get(key) === code) continue;
|
|
1150
|
+
const detail = code === "malformed" ? `${name} has malformed row(s); current.json keeps reachable rows and retains the diagnostic` : `${name} cannot be read (${code}); current.json is rendered without it`;
|
|
1151
|
+
process.stderr.write(`[run-dossier] ${detail}: ${runDirectory}
|
|
1152
|
+
`);
|
|
1153
|
+
declaredUnreadable.set(key, code);
|
|
1154
|
+
}
|
|
1155
|
+
writeWhole(runDirectory, whole);
|
|
1156
|
+
const grew = [history, state3, log].some((file, index3) => file.fault === void 0 && fileBytes(paths[index3]) !== file.bytes);
|
|
1157
|
+
if (!grew) return;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function appendPageRow(runDirectory, section, page) {
|
|
1161
|
+
appendSitianRecord({
|
|
1162
|
+
level: "event",
|
|
1163
|
+
kind: PAGE_ROW_KIND[section],
|
|
1164
|
+
sessionParent: sessionFileOf(runDirectory),
|
|
1165
|
+
source: "run-dossier",
|
|
1166
|
+
payload: page
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
function readPageSync(runDirectory, section) {
|
|
1170
|
+
const state3 = readRowFile(join3(runDirectory, RUN_STATE_FILE));
|
|
1171
|
+
if (state3.fault !== void 0) throw new Error(`${RUN_STATE_FILE} is unreadable (${state3.fault}): ${runDirectory}`);
|
|
1172
|
+
if (state3.diagnostics !== void 0 && state3.diagnostics.length > 0) {
|
|
1173
|
+
throw new Error(
|
|
1174
|
+
`${RUN_STATE_FILE} has malformed row(s); refusing stale control-plane page: ${runDirectory}`
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1177
|
+
return lastPagePayload(state3.rows, PAGE_ROW_KIND[section], runDirectory);
|
|
1178
|
+
}
|
|
1179
|
+
function writeSectionSync(runDirectory, section, value2) {
|
|
1180
|
+
appendPageRow(runDirectory, section, value2);
|
|
1181
|
+
renderCurrentSync(runDirectory);
|
|
1182
|
+
}
|
|
1183
|
+
function updateSectionSync(runDirectory, section, update) {
|
|
1184
|
+
const current = readPageSync(runDirectory, section);
|
|
1185
|
+
if (current === void 0) {
|
|
1186
|
+
throw new Error(`${RUN_STATE_FILE} has no ${PAGE_ROW_KIND[section]} row: ${runDirectory}`);
|
|
1187
|
+
}
|
|
1188
|
+
const next = update(current);
|
|
1189
|
+
if (next === void 0) return;
|
|
1190
|
+
writeSectionSync(runDirectory, section, next);
|
|
1191
|
+
}
|
|
1192
|
+
var PAGE_ROW_KIND, declaredUnreadable;
|
|
1193
|
+
var init_run_dossier = __esm({
|
|
1194
|
+
"src/run-dossier.ts"() {
|
|
1195
|
+
"use strict";
|
|
1196
|
+
init_role_run_placement();
|
|
1197
|
+
init_run_dossier_files();
|
|
1198
|
+
init_sitian_appender();
|
|
1199
|
+
init_sitian_reader();
|
|
1200
|
+
init_unknown_value();
|
|
1201
|
+
PAGE_ROW_KIND = {
|
|
1202
|
+
invocation: "invocation",
|
|
1203
|
+
admitted: "admitted-request",
|
|
1204
|
+
runState: "run-state",
|
|
1205
|
+
terminal: "terminal"
|
|
1206
|
+
};
|
|
1207
|
+
declaredUnreadable = /* @__PURE__ */ new Map();
|
|
550
1208
|
}
|
|
551
1209
|
});
|
|
552
1210
|
|
|
553
1211
|
// src/run-ticket-number.ts
|
|
554
1212
|
import { readFile } from "node:fs/promises";
|
|
555
|
-
import { join as
|
|
1213
|
+
import { join as join4 } from "node:path";
|
|
1214
|
+
function isPositiveTicketNumber(value2) {
|
|
1215
|
+
return typeof value2 === "number" && Number.isInteger(value2) && value2 >= 1;
|
|
1216
|
+
}
|
|
556
1217
|
function isSafePositiveTicketNumber(value2) {
|
|
557
|
-
return
|
|
1218
|
+
return isPositiveTicketNumber(value2) && Number.isSafeInteger(value2);
|
|
1219
|
+
}
|
|
1220
|
+
function isTicketNumberString(value2) {
|
|
1221
|
+
return typeof value2 === "string" && /^[1-9][0-9]*$/.test(value2);
|
|
1222
|
+
}
|
|
1223
|
+
function parseTicketNumber(value2) {
|
|
1224
|
+
if (isSafePositiveTicketNumber(value2)) return value2;
|
|
1225
|
+
if (!isTicketNumberString(value2)) return void 0;
|
|
1226
|
+
const parsed2 = Number(value2);
|
|
1227
|
+
return isSafePositiveTicketNumber(parsed2) ? parsed2 : void 0;
|
|
1228
|
+
}
|
|
1229
|
+
function sitianSubjectTicketNumber(subject) {
|
|
1230
|
+
if (typeof subject === "string" || typeof subject === "number") {
|
|
1231
|
+
return parseTicketNumber(subject);
|
|
1232
|
+
}
|
|
1233
|
+
if (subject !== null && typeof subject === "object" && !Array.isArray(subject)) {
|
|
1234
|
+
return parseTicketNumber(subject.ticketNumber);
|
|
1235
|
+
}
|
|
1236
|
+
return void 0;
|
|
1237
|
+
}
|
|
1238
|
+
function ticketNumberFromSitianSubject(subject) {
|
|
1239
|
+
const parsed2 = sitianSubjectTicketNumber(subject);
|
|
1240
|
+
return parsed2 === void 0 ? void 0 : String(parsed2);
|
|
558
1241
|
}
|
|
559
1242
|
function requireSafePositiveTicketNumber(ticketNumber, context = "ticketNumber") {
|
|
560
1243
|
if (!isSafePositiveTicketNumber(ticketNumber)) {
|
|
@@ -579,34 +1262,63 @@ async function readJsonObject(path8) {
|
|
|
579
1262
|
throw error;
|
|
580
1263
|
}
|
|
581
1264
|
}
|
|
582
|
-
|
|
583
|
-
const
|
|
1265
|
+
function readBoardPageTicketNumberFromRows(runDirectory, section) {
|
|
1266
|
+
const fromRows = readPageSync(runDirectory, section);
|
|
1267
|
+
return fromRows === void 0 ? void 0 : ticketFromRecord(fromRows);
|
|
1268
|
+
}
|
|
1269
|
+
async function readBoardPageTicketNumberFromLegacy(runDirectory, section) {
|
|
1270
|
+
const record = await readJsonObject(join4(runDirectory, LEGACY_BOARD_PAGE[section]));
|
|
584
1271
|
if (record === void 0) return void 0;
|
|
585
1272
|
return ticketFromRecord(record);
|
|
586
1273
|
}
|
|
587
1274
|
async function readBoardTicketNumber(runDirectory) {
|
|
588
|
-
return
|
|
1275
|
+
return readBoardPageTicketNumberFromRows(runDirectory, "admitted") ?? readBoardPageTicketNumberFromRows(runDirectory, "invocation");
|
|
1276
|
+
}
|
|
1277
|
+
async function readMigrationBoardTicketNumber(runDirectory) {
|
|
1278
|
+
return await readBoardTicketNumber(runDirectory) ?? await readBoardPageTicketNumberFromLegacy(runDirectory, "admitted") ?? await readBoardPageTicketNumberFromLegacy(runDirectory, "invocation");
|
|
589
1279
|
}
|
|
590
1280
|
async function readMigrationDerivedTicketNumber(runDirectory) {
|
|
591
1281
|
const record = await readJsonObject(
|
|
592
|
-
|
|
1282
|
+
join4(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
|
|
593
1283
|
);
|
|
594
1284
|
if (record === void 0) return void 0;
|
|
595
1285
|
if (record.derivation !== "worktree-path-basename") return void 0;
|
|
596
1286
|
return ticketFromRecord(record);
|
|
597
1287
|
}
|
|
598
|
-
var MIGRATION_TICKET_DERIVATION_PAGE;
|
|
1288
|
+
var MIGRATION_TICKET_DERIVATION_PAGE, LEGACY_BOARD_PAGE;
|
|
599
1289
|
var init_run_ticket_number = __esm({
|
|
600
1290
|
"src/run-ticket-number.ts"() {
|
|
601
1291
|
"use strict";
|
|
1292
|
+
init_run_dossier();
|
|
602
1293
|
init_unknown_value();
|
|
603
1294
|
MIGRATION_TICKET_DERIVATION_PAGE = "migration-ticket-derivation.json";
|
|
1295
|
+
LEGACY_BOARD_PAGE = {
|
|
1296
|
+
admitted: "admitted-request.json",
|
|
1297
|
+
invocation: "invocation.json"
|
|
1298
|
+
};
|
|
604
1299
|
}
|
|
605
1300
|
});
|
|
606
1301
|
|
|
607
1302
|
// src/role-run-placement.ts
|
|
608
1303
|
import { readdir } from "node:fs/promises";
|
|
609
|
-
import { join as
|
|
1304
|
+
import { basename as basename5, dirname as dirname4, join as join5 } from "node:path";
|
|
1305
|
+
function formatRunLeaf(runId, role) {
|
|
1306
|
+
return `${runId}@${role}`;
|
|
1307
|
+
}
|
|
1308
|
+
function parseRunLeaf(name) {
|
|
1309
|
+
const at2 = name.lastIndexOf("@");
|
|
1310
|
+
if (at2 <= 0 || at2 === name.length - 1) return void 0;
|
|
1311
|
+
return { runId: name.slice(0, at2), role: name.slice(at2 + 1) };
|
|
1312
|
+
}
|
|
1313
|
+
function sessionDirectoryOf(runDirectory) {
|
|
1314
|
+
return join5(runDirectory, "session");
|
|
1315
|
+
}
|
|
1316
|
+
function sessionFileIn(sessionDirectory) {
|
|
1317
|
+
return join5(sessionDirectory, ROLE_RUN_SESSION_FILENAME);
|
|
1318
|
+
}
|
|
1319
|
+
function sessionFileOf(runDirectory) {
|
|
1320
|
+
return sessionFileIn(sessionDirectoryOf(runDirectory));
|
|
1321
|
+
}
|
|
610
1322
|
async function listBookRunDirectories(bookDir) {
|
|
611
1323
|
const out = [];
|
|
612
1324
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -620,13 +1332,13 @@ async function listBookRunDirectories(bookDir) {
|
|
|
620
1332
|
}
|
|
621
1333
|
for (const entry of entries) {
|
|
622
1334
|
if (!entry.isDirectory()) continue;
|
|
623
|
-
const runDir =
|
|
1335
|
+
const runDir = join5(runsDir, entry.name);
|
|
624
1336
|
if (seen.has(runDir)) continue;
|
|
625
1337
|
seen.add(runDir);
|
|
626
1338
|
out.push(runDir);
|
|
627
1339
|
}
|
|
628
1340
|
};
|
|
629
|
-
await collect(
|
|
1341
|
+
await collect(join5(bookDir, "runs"));
|
|
630
1342
|
let subjects;
|
|
631
1343
|
try {
|
|
632
1344
|
subjects = await readdir(bookDir, { withFileTypes: true });
|
|
@@ -636,7 +1348,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
636
1348
|
}
|
|
637
1349
|
for (const subject of subjects) {
|
|
638
1350
|
if (!subject.isDirectory() || subject.name === "runs") continue;
|
|
639
|
-
await collect(
|
|
1351
|
+
await collect(join5(bookDir, subject.name, "runs"));
|
|
640
1352
|
}
|
|
641
1353
|
return out.sort();
|
|
642
1354
|
}
|
|
@@ -645,33 +1357,31 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
645
1357
|
input.subject.ticketNumber,
|
|
646
1358
|
"roleRunPlacement subject.ticketNumber"
|
|
647
1359
|
)) : "unbound";
|
|
648
|
-
const runDirectory =
|
|
1360
|
+
const runDirectory = join5(
|
|
649
1361
|
activationBookDirectory(ledgerHome, input.bookKey),
|
|
650
1362
|
subjectDirectory,
|
|
651
1363
|
"runs",
|
|
652
|
-
|
|
1364
|
+
formatRunLeaf(input.runId, input.role)
|
|
653
1365
|
);
|
|
654
|
-
const sessionDirectory =
|
|
1366
|
+
const sessionDirectory = sessionDirectoryOf(runDirectory);
|
|
655
1367
|
return {
|
|
656
1368
|
runDirectory,
|
|
657
1369
|
sessionDirectory,
|
|
658
|
-
sessionFile:
|
|
659
|
-
|
|
660
|
-
attachmentsDirectory: join3(runDirectory, "attachments")
|
|
1370
|
+
sessionFile: sessionFileIn(sessionDirectory),
|
|
1371
|
+
attachmentsDirectory: join5(runDirectory, "attachments")
|
|
661
1372
|
};
|
|
662
1373
|
}
|
|
663
|
-
function roleRunArtifactsDirectory(runDirectory) {
|
|
664
|
-
return join3(runDirectory, "artifacts");
|
|
665
|
-
}
|
|
666
1374
|
function isUnboundRunDirectory(runDirectory) {
|
|
667
1375
|
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
668
1376
|
}
|
|
1377
|
+
var ROLE_RUN_SESSION_FILENAME;
|
|
669
1378
|
var init_role_run_placement = __esm({
|
|
670
1379
|
"src/role-run-placement.ts"() {
|
|
671
1380
|
"use strict";
|
|
672
1381
|
init_activation_ledger_topology();
|
|
673
1382
|
init_run_ticket_number();
|
|
674
1383
|
init_unknown_value();
|
|
1384
|
+
ROLE_RUN_SESSION_FILENAME = "session.jsonl";
|
|
675
1385
|
}
|
|
676
1386
|
});
|
|
677
1387
|
|
|
@@ -699,6 +1409,7 @@ var init_collector_config = __esm({
|
|
|
699
1409
|
"use strict";
|
|
700
1410
|
init_sha256();
|
|
701
1411
|
init_unknown_value();
|
|
1412
|
+
init_run_ticket_number();
|
|
702
1413
|
}
|
|
703
1414
|
});
|
|
704
1415
|
|
|
@@ -8014,6 +8725,7 @@ var init_build = __esm({
|
|
|
8014
8725
|
var init_auditor_dossier_tool = __esm({
|
|
8015
8726
|
"src/auditor-dossier-tool.ts"() {
|
|
8016
8727
|
"use strict";
|
|
8728
|
+
init_run_dossier();
|
|
8017
8729
|
init_role_run_placement();
|
|
8018
8730
|
init_build();
|
|
8019
8731
|
}
|
|
@@ -13841,12 +14553,7 @@ var init_auditor_output = __esm({
|
|
|
13841
14553
|
|
|
13842
14554
|
// src/ticket-provenance-contracts.ts
|
|
13843
14555
|
function positiveInteger(value2) {
|
|
13844
|
-
|
|
13845
|
-
if (typeof value2 === "string" && /^[1-9][0-9]*$/.test(value2)) {
|
|
13846
|
-
const parsed2 = Number(value2);
|
|
13847
|
-
if (Number.isSafeInteger(parsed2)) return parsed2;
|
|
13848
|
-
}
|
|
13849
|
-
return void 0;
|
|
14556
|
+
return parseTicketNumber(value2);
|
|
13850
14557
|
}
|
|
13851
14558
|
function projectBound(value2) {
|
|
13852
14559
|
if (!isRecord(value2)) return void 0;
|
|
@@ -13897,6 +14604,7 @@ function projectTicketProvenanceHeader(value2) {
|
|
|
13897
14604
|
var init_ticket_provenance_contracts = __esm({
|
|
13898
14605
|
"src/ticket-provenance-contracts.ts"() {
|
|
13899
14606
|
"use strict";
|
|
14607
|
+
init_run_ticket_number();
|
|
13900
14608
|
init_unknown_value();
|
|
13901
14609
|
}
|
|
13902
14610
|
});
|
|
@@ -14078,14 +14786,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14078
14786
|
outputTool: FIXER_OUTPUT_TOOL_NAME,
|
|
14079
14787
|
settlement: "sealed",
|
|
14080
14788
|
artifactFace: {
|
|
14081
|
-
reportPhase: true
|
|
14082
|
-
evidenceRole: true,
|
|
14083
|
-
leaves: [
|
|
14084
|
-
{ key: "phase" },
|
|
14085
|
-
{ key: "packetPath" },
|
|
14086
|
-
{ key: "prerequisitesPath", omitUndefined: true },
|
|
14087
|
-
{ key: "prerequisites" }
|
|
14088
|
-
]
|
|
14789
|
+
reportPhase: true
|
|
14089
14790
|
},
|
|
14090
14791
|
boardPlacement: "marshal",
|
|
14091
14792
|
activationFlags: [
|
|
@@ -14116,12 +14817,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14116
14817
|
outputTool: CODER_OUTPUT_TOOL_NAME,
|
|
14117
14818
|
settlement: "sealed",
|
|
14118
14819
|
artifactFace: {
|
|
14119
|
-
reportPhase: true
|
|
14120
|
-
evidenceRole: true,
|
|
14121
|
-
leaves: [
|
|
14122
|
-
{ key: "phase" },
|
|
14123
|
-
{ key: "taskPath" }
|
|
14124
|
-
]
|
|
14820
|
+
reportPhase: true
|
|
14125
14821
|
},
|
|
14126
14822
|
activationFlags: [
|
|
14127
14823
|
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
@@ -14155,15 +14851,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14155
14851
|
settlement: "sealed",
|
|
14156
14852
|
/** Publish only an accepted ledger outcome; audit escalation stays unsettled here. */
|
|
14157
14853
|
sealedAcceptedOnly: true,
|
|
14158
|
-
artifactFace: {
|
|
14159
|
-
evidenceRole: true,
|
|
14160
|
-
leaves: [
|
|
14161
|
-
{ key: "baseRevision" },
|
|
14162
|
-
{ key: "lens" },
|
|
14163
|
-
{ key: "authorityRefs", copyArray: true },
|
|
14164
|
-
{ key: "callerProvenance", callerProvenance: true }
|
|
14165
|
-
]
|
|
14166
|
-
},
|
|
14854
|
+
artifactFace: {},
|
|
14167
14855
|
/** Frozen base/lens/authority become the initial prompt; instruction follows. */
|
|
14168
14856
|
transportPrompt: "skill-args",
|
|
14169
14857
|
boardPlacement: "marshal",
|
|
@@ -14194,14 +14882,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14194
14882
|
bareCommand: false,
|
|
14195
14883
|
outputTool: COLLECTOR_OUTPUT_TOOL,
|
|
14196
14884
|
settlement: "sealed",
|
|
14197
|
-
artifactFace: {
|
|
14198
|
-
evidenceRole: true,
|
|
14199
|
-
leaves: [
|
|
14200
|
-
{ key: "prNumber", omitUndefined: true },
|
|
14201
|
-
{ key: "repository", from: "repository.canonical" },
|
|
14202
|
-
{ key: "manifestDigest" }
|
|
14203
|
-
]
|
|
14204
|
-
},
|
|
14885
|
+
artifactFace: {},
|
|
14205
14886
|
boardPlacement: "collector",
|
|
14206
14887
|
/** Taishi acceptance is a typed groups array, not a status leaf. */
|
|
14207
14888
|
analystTerminal: "groups",
|
|
@@ -14230,12 +14911,6 @@ var init_packaged_role_registry = __esm({
|
|
|
14230
14911
|
auditTool: DOCTOR_AUDIT_TOOL_NAME,
|
|
14231
14912
|
settlement: "sealed",
|
|
14232
14913
|
artifactFace: {
|
|
14233
|
-
evidenceRole: true,
|
|
14234
|
-
leaves: [
|
|
14235
|
-
{ key: "issueNumber" },
|
|
14236
|
-
{ key: "caseRunsPath" },
|
|
14237
|
-
{ key: "caseIdentity" }
|
|
14238
|
-
],
|
|
14239
14914
|
doctorReportFacts: true
|
|
14240
14915
|
},
|
|
14241
14916
|
/** Navigator subject is the doctor case, not the case-path file bytes. */
|
|
@@ -14261,13 +14936,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14261
14936
|
phases: [null],
|
|
14262
14937
|
outputTool: MERGER_OUTPUT_TOOL_NAME,
|
|
14263
14938
|
settlement: "sealed",
|
|
14264
|
-
artifactFace: {
|
|
14265
|
-
evidenceRole: true,
|
|
14266
|
-
leaves: [
|
|
14267
|
-
{ key: "mergerInputPath" },
|
|
14268
|
-
{ key: "derived" }
|
|
14269
|
-
]
|
|
14270
|
-
},
|
|
14939
|
+
artifactFace: {},
|
|
14271
14940
|
activationFlags: [
|
|
14272
14941
|
{ field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
|
|
14273
14942
|
],
|
|
@@ -14287,8 +14956,6 @@ var init_packaged_role_registry = __esm({
|
|
|
14287
14956
|
sourceRunStored: "raw",
|
|
14288
14957
|
argvResult: "source-run",
|
|
14289
14958
|
sameParent: "source-locator",
|
|
14290
|
-
/** Infrastructure failure at this stage has no accepted gate cycle to project. */
|
|
14291
|
-
skipGateOnInfrastructureStage: true,
|
|
14292
14959
|
/** 符宝郎 is a review officer and inherits the gatekeeper model. */
|
|
14293
14960
|
reviewOfficer: true,
|
|
14294
14961
|
provinceConfig: true,
|
|
@@ -14396,8 +15063,6 @@ var init_packaged_role_registry = __esm({
|
|
|
14396
15063
|
sameParent: "gate-pointer",
|
|
14397
15064
|
/** Resume restores an optional source-run path onto the admitted face. */
|
|
14398
15065
|
resumeSourcePath: true,
|
|
14399
|
-
/** Infrastructure failure at this stage has no accepted gate cycle to project. */
|
|
14400
|
-
skipGateOnInfrastructureStage: true,
|
|
14401
15066
|
/** 台院 is a review officer and inherits the gatekeeper model. */
|
|
14402
15067
|
reviewOfficer: true,
|
|
14403
15068
|
provinceConfig: true,
|
|
@@ -14429,8 +15094,6 @@ var init_packaged_role_registry = __esm({
|
|
|
14429
15094
|
presentSettled: "always",
|
|
14430
15095
|
summonResume: true,
|
|
14431
15096
|
admission: "instruction",
|
|
14432
|
-
/** Infrastructure failure at this stage has no accepted gate cycle to project. */
|
|
14433
|
-
skipGateOnInfrastructureStage: true,
|
|
14434
15097
|
sameParent: "none",
|
|
14435
15098
|
/** Province model root. Officers name this seat via modelInheritsFrom. */
|
|
14436
15099
|
provinceConfig: true,
|
|
@@ -14690,22 +15353,12 @@ var init_terminal = __esm({
|
|
|
14690
15353
|
});
|
|
14691
15354
|
|
|
14692
15355
|
// src/run-terminal-artifacts.ts
|
|
14693
|
-
var RUN_TERMINAL_ERROR_SETTLEMENT_FILE, RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS, UNIQUE_ERROR_FALLBACK_STEM, UNIQUE_ERROR_FALLBACK_NAME;
|
|
14694
15356
|
var init_run_terminal_artifacts = __esm({
|
|
14695
15357
|
"src/run-terminal-artifacts.ts"() {
|
|
14696
15358
|
"use strict";
|
|
14697
15359
|
init_role_run_placement();
|
|
15360
|
+
init_run_dossier();
|
|
14698
15361
|
init_unknown_value();
|
|
14699
|
-
RUN_TERMINAL_ERROR_SETTLEMENT_FILE = "error.settlement.json";
|
|
14700
|
-
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS = [
|
|
14701
|
-
`artifacts/${RUN_TERMINAL_ERROR_SETTLEMENT_FILE}`,
|
|
14702
|
-
RUN_TERMINAL_ERROR_SETTLEMENT_FILE
|
|
14703
|
-
];
|
|
14704
|
-
UNIQUE_ERROR_FALLBACK_STEM = "error";
|
|
14705
|
-
UNIQUE_ERROR_FALLBACK_NAME = new RegExp(
|
|
14706
|
-
`^${UNIQUE_ERROR_FALLBACK_STEM}\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.json$`,
|
|
14707
|
-
"i"
|
|
14708
|
-
);
|
|
14709
15362
|
}
|
|
14710
15363
|
});
|
|
14711
15364
|
|
|
@@ -14748,8 +15401,7 @@ var init_host_descriptions = __esm({
|
|
|
14748
15401
|
suffix: Object.freeze(["stdio"])
|
|
14749
15402
|
}),
|
|
14750
15403
|
modelPassing: "set_model",
|
|
14751
|
-
setModelId: "bare"
|
|
14752
|
-
sessionBindingFile: "grok-acp-session.json"
|
|
15404
|
+
setModelId: "bare"
|
|
14753
15405
|
}),
|
|
14754
15406
|
/**
|
|
14755
15407
|
* Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
|
|
@@ -14767,7 +15419,6 @@ var init_host_descriptions = __esm({
|
|
|
14767
15419
|
}),
|
|
14768
15420
|
modelPassing: "set_model",
|
|
14769
15421
|
setModelId: "provider:model",
|
|
14770
|
-
sessionBindingFile: "hermes-acp-session.json",
|
|
14771
15422
|
seatProfileSoul: Object.freeze({
|
|
14772
15423
|
flag: "-p",
|
|
14773
15424
|
namePrefix: "ak-",
|
|
@@ -14780,7 +15431,6 @@ var init_host_descriptions = __esm({
|
|
|
14780
15431
|
"claude": Object.freeze({
|
|
14781
15432
|
protocol: "claude-print",
|
|
14782
15433
|
binaryFromHome: Object.freeze([".local", "bin", "claude"]),
|
|
14783
|
-
sessionBindingFile: "claude-headless-session.json",
|
|
14784
15434
|
fixedArgs: Object.freeze([
|
|
14785
15435
|
// Live NDJSON events → sitian host-session records (#811); last line is the result receipt.
|
|
14786
15436
|
"--output-format",
|
|
@@ -14806,8 +15456,7 @@ var init_host_descriptions = __esm({
|
|
|
14806
15456
|
*/
|
|
14807
15457
|
"codex": Object.freeze({
|
|
14808
15458
|
protocol: "codex-exec",
|
|
14809
|
-
binaryFromHome: Object.freeze([".local", "bin", "codex"])
|
|
14810
|
-
sessionBindingFile: "codex-headless-session.json"
|
|
15459
|
+
binaryFromHome: Object.freeze([".local", "bin", "codex"])
|
|
14811
15460
|
})
|
|
14812
15461
|
});
|
|
14813
15462
|
}
|
|
@@ -14888,9 +15537,8 @@ var init_compliance_transport = __esm({
|
|
|
14888
15537
|
});
|
|
14889
15538
|
|
|
14890
15539
|
// src/role-run-relocation.ts
|
|
14891
|
-
import { existsSync } from "node:fs";
|
|
14892
15540
|
import { readdir as readdir2, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
14893
|
-
import { join as
|
|
15541
|
+
import { dirname as dirname5, join as join6, sep as sep2 } from "node:path";
|
|
14894
15542
|
function rewriteRunDirectoryPathValue(value2, oldRunDirectory, newRunDirectory) {
|
|
14895
15543
|
if (typeof value2 !== "string") return value2;
|
|
14896
15544
|
if (value2 === oldRunDirectory) return newRunDirectory;
|
|
@@ -14984,25 +15632,22 @@ function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
|
14984
15632
|
);
|
|
14985
15633
|
}
|
|
14986
15634
|
}
|
|
14987
|
-
async function
|
|
14988
|
-
if (!existsSync(path8)) return;
|
|
15635
|
+
async function rewriteLegacyOfficerPointerFile(path8, rewrites) {
|
|
14989
15636
|
const page = JSON.parse(await readFile2(path8, "utf8"));
|
|
14990
|
-
if (!isRecord(page)) return;
|
|
14991
|
-
if (page.kind !== "direct-officer-run-pointer") return;
|
|
15637
|
+
if (!isRecord(page) || page.kind !== "direct-officer-run-pointer") return;
|
|
14992
15638
|
const before = JSON.stringify(page);
|
|
14993
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
14994
|
-
|
|
14995
|
-
OFFICER_POINTER_FIELDS,
|
|
14996
|
-
rewrites
|
|
14997
|
-
);
|
|
14998
|
-
if (JSON.stringify(page) !== before) {
|
|
14999
|
-
await writeFile(path8, `${JSON.stringify(page)}
|
|
15639
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(page, OFFICER_POINTER_FIELDS, rewrites);
|
|
15640
|
+
if (JSON.stringify(page) !== before) await writeFile(path8, `${JSON.stringify(page)}
|
|
15000
15641
|
`, "utf8");
|
|
15001
|
-
}
|
|
15002
15642
|
}
|
|
15003
15643
|
async function rewriteSitianRecordsJsonl(path8, rewrites) {
|
|
15004
|
-
|
|
15005
|
-
|
|
15644
|
+
let raw;
|
|
15645
|
+
try {
|
|
15646
|
+
raw = await readFile2(path8, "utf8");
|
|
15647
|
+
} catch (error) {
|
|
15648
|
+
if (isEnoent(error)) return;
|
|
15649
|
+
throw error;
|
|
15650
|
+
}
|
|
15006
15651
|
if (raw.length === 0) return;
|
|
15007
15652
|
const endsWithNewline = raw.endsWith("\n");
|
|
15008
15653
|
const lines = raw.split("\n");
|
|
@@ -15052,8 +15697,13 @@ async function rewriteSitianRecordsJsonl(path8, rewrites) {
|
|
|
15052
15697
|
);
|
|
15053
15698
|
}
|
|
15054
15699
|
async function rewriteSessionTranscriptBindings(path8, rewrites) {
|
|
15055
|
-
|
|
15056
|
-
|
|
15700
|
+
let raw;
|
|
15701
|
+
try {
|
|
15702
|
+
raw = await readFile2(path8, "utf8");
|
|
15703
|
+
} catch (error) {
|
|
15704
|
+
if (isEnoent(error)) return;
|
|
15705
|
+
throw error;
|
|
15706
|
+
}
|
|
15057
15707
|
if (raw.length === 0) return;
|
|
15058
15708
|
const endsWithNewline = raw.endsWith("\n");
|
|
15059
15709
|
const lines = raw.split("\n");
|
|
@@ -15112,7 +15762,7 @@ async function rewriteSessionTranscriptBindings(path8, rewrites) {
|
|
|
15112
15762
|
);
|
|
15113
15763
|
}
|
|
15114
15764
|
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
15115
|
-
const sessionRoot =
|
|
15765
|
+
const sessionRoot = join6(pagesDirectory, "session");
|
|
15116
15766
|
async function walk3(directory) {
|
|
15117
15767
|
let entries;
|
|
15118
15768
|
try {
|
|
@@ -15122,14 +15772,14 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
15122
15772
|
throw error;
|
|
15123
15773
|
}
|
|
15124
15774
|
for (const entry of entries) {
|
|
15125
|
-
const path8 =
|
|
15775
|
+
const path8 = join6(directory, entry.name);
|
|
15126
15776
|
if (entry.isDirectory()) {
|
|
15127
15777
|
await walk3(path8);
|
|
15128
15778
|
continue;
|
|
15129
15779
|
}
|
|
15130
15780
|
if (!entry.isFile()) continue;
|
|
15131
15781
|
if (entry.name.endsWith(".pointer.json")) {
|
|
15132
|
-
await
|
|
15782
|
+
await rewriteLegacyOfficerPointerFile(path8, rewrites);
|
|
15133
15783
|
} else if (entry.name === "records.jsonl") {
|
|
15134
15784
|
await rewriteSitianRecordsJsonl(path8, rewrites);
|
|
15135
15785
|
} else if (entry.name.endsWith(".jsonl")) {
|
|
@@ -15142,47 +15792,49 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
15142
15792
|
async function rewriteRoleRunDurablePages(input) {
|
|
15143
15793
|
const { pagesDirectory } = input;
|
|
15144
15794
|
const rewrites = collectRewrites(input);
|
|
15145
|
-
const
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15795
|
+
const pageRewriters = {
|
|
15796
|
+
admitted: (page) => rewriteAdmittedRoleRunPage(page, rewrites),
|
|
15797
|
+
invocation: (page) => rewriteRunDirectoryPathFieldsAgainstRewrites(page, INVOCATION_PAGE_FIELDS, rewrites),
|
|
15798
|
+
runState: (page) => {
|
|
15799
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(page, RUN_STATE_PAGE_FIELDS, rewrites);
|
|
15800
|
+
if (isRecord(page.principal)) {
|
|
15801
|
+
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
15802
|
+
page.principal,
|
|
15803
|
+
["sessionDirectory", "sessionFile"],
|
|
15804
|
+
rewrites
|
|
15805
|
+
);
|
|
15806
|
+
}
|
|
15807
|
+
if (isRecord(page.currentCourt)) {
|
|
15808
|
+
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
15809
|
+
}
|
|
15153
15810
|
}
|
|
15811
|
+
};
|
|
15812
|
+
for (const [section, rewrite] of Object.entries(pageRewriters)) {
|
|
15813
|
+
if (readPageSync(pagesDirectory, section) === void 0) continue;
|
|
15814
|
+
updateSectionSync(pagesDirectory, section, (current) => {
|
|
15815
|
+
const page = structuredClone(current);
|
|
15816
|
+
rewrite(page);
|
|
15817
|
+
return JSON.stringify(page) === JSON.stringify(current) ? void 0 : page;
|
|
15818
|
+
});
|
|
15154
15819
|
}
|
|
15155
|
-
const
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
|
|
15820
|
+
for (const [file, rewrite] of [
|
|
15821
|
+
["admitted-request.json", pageRewriters.admitted],
|
|
15822
|
+
["invocation.json", pageRewriters.invocation],
|
|
15823
|
+
["run-state.json", pageRewriters.runState]
|
|
15824
|
+
]) {
|
|
15825
|
+
const path8 = join6(pagesDirectory, file);
|
|
15826
|
+
let raw;
|
|
15827
|
+
try {
|
|
15828
|
+
raw = await readFile2(path8, "utf8");
|
|
15829
|
+
} catch (error) {
|
|
15830
|
+
if (isEnoent(error)) continue;
|
|
15831
|
+
throw error;
|
|
15163
15832
|
}
|
|
15164
|
-
|
|
15165
|
-
const statePath = join4(pagesDirectory, "run-state.json");
|
|
15166
|
-
if (existsSync(statePath)) {
|
|
15167
|
-
const page = JSON.parse(await readFile2(statePath, "utf8"));
|
|
15833
|
+
const page = JSON.parse(raw);
|
|
15168
15834
|
const before = JSON.stringify(page);
|
|
15169
|
-
|
|
15170
|
-
page,
|
|
15171
|
-
RUN_STATE_PAGE_FIELDS,
|
|
15172
|
-
rewrites
|
|
15173
|
-
);
|
|
15174
|
-
if (isRecord(page.principal)) {
|
|
15175
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
15176
|
-
page.principal,
|
|
15177
|
-
["sessionDirectory", "sessionFile"],
|
|
15178
|
-
rewrites
|
|
15179
|
-
);
|
|
15180
|
-
}
|
|
15181
|
-
if (isRecord(page.currentCourt)) {
|
|
15182
|
-
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
15183
|
-
}
|
|
15835
|
+
rewrite(page);
|
|
15184
15836
|
if (JSON.stringify(page) !== before) {
|
|
15185
|
-
await writeFile(
|
|
15837
|
+
await writeFile(path8, `${JSON.stringify(page, null, 2)}
|
|
15186
15838
|
`, "utf8");
|
|
15187
15839
|
}
|
|
15188
15840
|
}
|
|
@@ -15192,11 +15844,16 @@ var ADMITTED_PAGE_FIELDS, INVOCATION_PAGE_FIELDS, RUN_STATE_PAGE_FIELDS, SOURCE_
|
|
|
15192
15844
|
var init_role_run_relocation = __esm({
|
|
15193
15845
|
"src/role-run-relocation.ts"() {
|
|
15194
15846
|
"use strict";
|
|
15847
|
+
init_activation_ledger_topology();
|
|
15848
|
+
init_run_lifecycle();
|
|
15849
|
+
init_role_run_placement();
|
|
15195
15850
|
init_compliance_transport();
|
|
15851
|
+
init_run_dossier();
|
|
15196
15852
|
init_unknown_value();
|
|
15197
15853
|
ADMITTED_PAGE_FIELDS = [
|
|
15198
15854
|
"runDirectory",
|
|
15199
15855
|
"admittedRequestPath",
|
|
15856
|
+
// pre-#1161 pages only
|
|
15200
15857
|
"sessionDirectory",
|
|
15201
15858
|
"sessionFile",
|
|
15202
15859
|
"taskPath",
|
|
@@ -15214,6 +15871,7 @@ var init_role_run_relocation = __esm({
|
|
|
15214
15871
|
RUN_STATE_PAGE_FIELDS = [
|
|
15215
15872
|
"runDirectory",
|
|
15216
15873
|
"admittedRequestPath",
|
|
15874
|
+
// pre-#1161 pages only
|
|
15217
15875
|
"sessionDirectory",
|
|
15218
15876
|
"sessionFile"
|
|
15219
15877
|
];
|
|
@@ -15226,14 +15884,6 @@ var init_role_run_relocation = __esm({
|
|
|
15226
15884
|
}
|
|
15227
15885
|
});
|
|
15228
15886
|
|
|
15229
|
-
// src/activation-ledger-git.ts
|
|
15230
|
-
var init_activation_ledger_git = __esm({
|
|
15231
|
-
"src/activation-ledger-git.ts"() {
|
|
15232
|
-
"use strict";
|
|
15233
|
-
init_unknown_value();
|
|
15234
|
-
}
|
|
15235
|
-
});
|
|
15236
|
-
|
|
15237
15887
|
// src/submission-correctable-error.ts
|
|
15238
15888
|
var correctableSubmissionErrorBrand, CorrectableSubmissionError;
|
|
15239
15889
|
var init_submission_correctable_error = __esm({
|
|
@@ -15283,6 +15933,7 @@ var init_doctor_evidence = __esm({
|
|
|
15283
15933
|
"src/doctor-evidence.ts"() {
|
|
15284
15934
|
"use strict";
|
|
15285
15935
|
init_sha256();
|
|
15936
|
+
init_activation_ledger_topology();
|
|
15286
15937
|
init_terminating_tools();
|
|
15287
15938
|
init_unknown_value();
|
|
15288
15939
|
}
|
|
@@ -15331,43 +15982,11 @@ var init_session_dialogue = __esm({
|
|
|
15331
15982
|
}
|
|
15332
15983
|
});
|
|
15333
15984
|
|
|
15334
|
-
// src/sitian-contracts.ts
|
|
15335
|
-
var init_sitian_contracts = __esm({
|
|
15336
|
-
"src/sitian-contracts.ts"() {
|
|
15337
|
-
"use strict";
|
|
15338
|
-
}
|
|
15339
|
-
});
|
|
15340
|
-
|
|
15341
|
-
// src/sitian-appender.ts
|
|
15342
|
-
var S4_SUBMISSION_LEDGER_KINDS;
|
|
15343
|
-
var init_sitian_appender = __esm({
|
|
15344
|
-
"src/sitian-appender.ts"() {
|
|
15345
|
-
"use strict";
|
|
15346
|
-
init_activation_ledger_git();
|
|
15347
|
-
init_activation_ledger_topology();
|
|
15348
|
-
init_sitian_contracts();
|
|
15349
|
-
S4_SUBMISSION_LEDGER_KINDS = /* @__PURE__ */ new Set([
|
|
15350
|
-
"candidate",
|
|
15351
|
-
"roundContext",
|
|
15352
|
-
"outcome",
|
|
15353
|
-
"sealed",
|
|
15354
|
-
"post-seal-anomaly"
|
|
15355
|
-
]);
|
|
15356
|
-
}
|
|
15357
|
-
});
|
|
15358
|
-
|
|
15359
|
-
// src/sitian-reader.ts
|
|
15360
|
-
var init_sitian_reader = __esm({
|
|
15361
|
-
"src/sitian-reader.ts"() {
|
|
15362
|
-
"use strict";
|
|
15363
|
-
init_unknown_value();
|
|
15364
|
-
}
|
|
15365
|
-
});
|
|
15366
|
-
|
|
15367
15985
|
// src/sitian-facade.ts
|
|
15368
15986
|
var init_sitian_facade = __esm({
|
|
15369
15987
|
"src/sitian-facade.ts"() {
|
|
15370
15988
|
"use strict";
|
|
15989
|
+
init_role_run_placement();
|
|
15371
15990
|
init_sitian_appender();
|
|
15372
15991
|
init_sitian_contracts();
|
|
15373
15992
|
init_sitian_appender();
|
|
@@ -15382,8 +16001,11 @@ var init_ticket_provenance = __esm({
|
|
|
15382
16001
|
init_activation_ledger_topology();
|
|
15383
16002
|
init_ledger_session_read();
|
|
15384
16003
|
init_run_ticket_number();
|
|
16004
|
+
init_role_run_placement();
|
|
16005
|
+
init_run_dossier_files();
|
|
15385
16006
|
init_session_dialogue();
|
|
15386
16007
|
init_sitian_facade();
|
|
16008
|
+
init_sitian_reader();
|
|
15387
16009
|
init_ticket_provenance_contracts();
|
|
15388
16010
|
init_unknown_value();
|
|
15389
16011
|
}
|
|
@@ -15403,6 +16025,7 @@ var init_notary_source_run = __esm({
|
|
|
15403
16025
|
init_activation_ledger_git();
|
|
15404
16026
|
init_activation_ledger_topology();
|
|
15405
16027
|
init_run_lifecycle();
|
|
16028
|
+
init_role_run_placement();
|
|
15406
16029
|
}
|
|
15407
16030
|
});
|
|
15408
16031
|
|
|
@@ -16167,6 +16790,7 @@ var init_invocation = __esm({
|
|
|
16167
16790
|
init_packaged_role_registry();
|
|
16168
16791
|
init_run_ticket_number();
|
|
16169
16792
|
init_role_run_relocation();
|
|
16793
|
+
init_run_dossier();
|
|
16170
16794
|
init_doctor_evidence();
|
|
16171
16795
|
init_collector_config();
|
|
16172
16796
|
init_github_remote();
|
|
@@ -16186,7 +16810,7 @@ var init_invocation = __esm({
|
|
|
16186
16810
|
});
|
|
16187
16811
|
|
|
16188
16812
|
// src/public-cli/run-lifecycle.ts
|
|
16189
|
-
import { chmod, lstat, open, readdir as readdir3, readFile as readFile3, unlink
|
|
16813
|
+
import { chmod, lstat, open, readdir as readdir3, readFile as readFile3, unlink } from "node:fs/promises";
|
|
16190
16814
|
function describeErrorIdentity(error) {
|
|
16191
16815
|
const candidate = error;
|
|
16192
16816
|
const name = typeof candidate?.name === "string" && candidate.name !== "" ? candidate.name : typeof error;
|
|
@@ -16235,6 +16859,7 @@ var init_run_lifecycle = __esm({
|
|
|
16235
16859
|
init_engine_material();
|
|
16236
16860
|
init_packaged_role_registry();
|
|
16237
16861
|
init_invocation();
|
|
16862
|
+
init_run_dossier();
|
|
16238
16863
|
init_unknown_value();
|
|
16239
16864
|
}
|
|
16240
16865
|
});
|
|
@@ -16333,12 +16958,12 @@ var require_isexe = __commonJS({
|
|
|
16333
16958
|
if (typeof Promise !== "function") {
|
|
16334
16959
|
throw new TypeError("callback not provided");
|
|
16335
16960
|
}
|
|
16336
|
-
return new Promise(function(
|
|
16961
|
+
return new Promise(function(resolve13, reject) {
|
|
16337
16962
|
isexe(path8, options || {}, function(er, is) {
|
|
16338
16963
|
if (er) {
|
|
16339
16964
|
reject(er);
|
|
16340
16965
|
} else {
|
|
16341
|
-
|
|
16966
|
+
resolve13(is);
|
|
16342
16967
|
}
|
|
16343
16968
|
});
|
|
16344
16969
|
});
|
|
@@ -16404,27 +17029,27 @@ var require_which = __commonJS({
|
|
|
16404
17029
|
opt = {};
|
|
16405
17030
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
16406
17031
|
const found = [];
|
|
16407
|
-
const step = (i2) => new Promise((
|
|
17032
|
+
const step = (i2) => new Promise((resolve13, reject) => {
|
|
16408
17033
|
if (i2 === pathEnv.length)
|
|
16409
|
-
return opt.all && found.length ?
|
|
17034
|
+
return opt.all && found.length ? resolve13(found) : reject(getNotFoundError(cmd));
|
|
16410
17035
|
const ppRaw = pathEnv[i2];
|
|
16411
17036
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
16412
17037
|
const pCmd = path8.join(pathPart, cmd);
|
|
16413
17038
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
16414
|
-
|
|
17039
|
+
resolve13(subStep(p, i2, 0));
|
|
16415
17040
|
});
|
|
16416
|
-
const subStep = (p, i2, ii) => new Promise((
|
|
17041
|
+
const subStep = (p, i2, ii) => new Promise((resolve13, reject) => {
|
|
16417
17042
|
if (ii === pathExt.length)
|
|
16418
|
-
return
|
|
17043
|
+
return resolve13(step(i2 + 1));
|
|
16419
17044
|
const ext2 = pathExt[ii];
|
|
16420
17045
|
isexe(p + ext2, { pathExt: pathExtExe }, (er, is) => {
|
|
16421
17046
|
if (!er && is) {
|
|
16422
17047
|
if (opt.all)
|
|
16423
17048
|
found.push(p + ext2);
|
|
16424
17049
|
else
|
|
16425
|
-
return
|
|
17050
|
+
return resolve13(p + ext2);
|
|
16426
17051
|
}
|
|
16427
|
-
return
|
|
17052
|
+
return resolve13(subStep(p, i2, ii + 1));
|
|
16428
17053
|
});
|
|
16429
17054
|
});
|
|
16430
17055
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -16746,7 +17371,7 @@ var init_child_process = __esm({
|
|
|
16746
17371
|
|
|
16747
17372
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.js
|
|
16748
17373
|
import { homedir as homedir2 } from "node:os";
|
|
16749
|
-
import { isAbsolute as
|
|
17374
|
+
import { isAbsolute as isAbsolute3, join as join8, resolve as nodeResolvePath, relative as relative2, sep as sep3 } from "node:path";
|
|
16750
17375
|
import { fileURLToPath } from "node:url";
|
|
16751
17376
|
function normalizeWindowsShellPath(filePath) {
|
|
16752
17377
|
if (!filePath.startsWith("/") || filePath.startsWith("//") || filePath.includes("\\"))
|
|
@@ -16773,7 +17398,7 @@ function normalizePath(input, options = {}) {
|
|
|
16773
17398
|
if (normalized === "~")
|
|
16774
17399
|
return home;
|
|
16775
17400
|
if (normalized.startsWith("~/") || process.platform === "win32" && normalized.startsWith("~\\")) {
|
|
16776
|
-
return
|
|
17401
|
+
return join8(home, normalized.slice(2));
|
|
16777
17402
|
}
|
|
16778
17403
|
}
|
|
16779
17404
|
if (/^file:\/\//.test(normalized)) {
|
|
@@ -16802,22 +17427,22 @@ var init_text = __esm({
|
|
|
16802
17427
|
});
|
|
16803
17428
|
|
|
16804
17429
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/config.js
|
|
16805
|
-
import { accessSync, constants, existsSync as
|
|
17430
|
+
import { accessSync, constants, existsSync, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "fs";
|
|
16806
17431
|
import { createRequire } from "module";
|
|
16807
17432
|
import { homedir as homedir3 } from "os";
|
|
16808
|
-
import { basename as
|
|
17433
|
+
import { basename as basename7, dirname as dirname7, join as join9, resolve as resolve4, sep as sep4, win32 } from "path";
|
|
16809
17434
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16810
17435
|
function findNodePackageDir(startDir) {
|
|
16811
17436
|
let dir = startDir;
|
|
16812
|
-
while (dir !==
|
|
16813
|
-
if (
|
|
16814
|
-
const parent =
|
|
16815
|
-
if (
|
|
17437
|
+
while (dir !== dirname7(dir)) {
|
|
17438
|
+
if (existsSync(join9(dir, "package.json"))) {
|
|
17439
|
+
const parent = dirname7(dir);
|
|
17440
|
+
if (basename7(dir) === "dist" && existsSync(join9(parent, "package.json"))) {
|
|
16816
17441
|
return parent;
|
|
16817
17442
|
}
|
|
16818
17443
|
return dir;
|
|
16819
17444
|
}
|
|
16820
|
-
dir =
|
|
17445
|
+
dir = dirname7(dir);
|
|
16821
17446
|
}
|
|
16822
17447
|
return startDir;
|
|
16823
17448
|
}
|
|
@@ -16827,12 +17452,12 @@ function getPackageDir() {
|
|
|
16827
17452
|
return normalizePath(envDir);
|
|
16828
17453
|
}
|
|
16829
17454
|
if (isBunBinary) {
|
|
16830
|
-
return
|
|
17455
|
+
return dirname7(process.execPath);
|
|
16831
17456
|
}
|
|
16832
17457
|
return findNodePackageDir(__dirname);
|
|
16833
17458
|
}
|
|
16834
17459
|
function getPackageJsonPath() {
|
|
16835
|
-
return
|
|
17460
|
+
return join9(getPackageDir(), "package.json");
|
|
16836
17461
|
}
|
|
16837
17462
|
function getQuickJSWasmPath() {
|
|
16838
17463
|
return embeddedQuickJSWasmPath ?? createRequire(import.meta.url).resolve("quickjs-wasi/quickjs.wasm");
|
|
@@ -16852,10 +17477,10 @@ function getAgentDir() {
|
|
|
16852
17477
|
if (envDir) {
|
|
16853
17478
|
return expandTildePath(envDir);
|
|
16854
17479
|
}
|
|
16855
|
-
return
|
|
17480
|
+
return join9(homedir3(), CONFIG_DIR_NAME, "agent");
|
|
16856
17481
|
}
|
|
16857
17482
|
function getBinDir() {
|
|
16858
|
-
return
|
|
17483
|
+
return join9(getAgentDir(), "bin");
|
|
16859
17484
|
}
|
|
16860
17485
|
var __filename2, __dirname, isBunBinary, isBunRuntime, isBundledNode, embeddedQuickJSWasmPath, pkg, piConfigName, PACKAGE_NAME, APP_NAME, CONFIG_DIR_NAME, VERSION, ENV_AGENT_DIR, ENV_SESSION_DIR;
|
|
16861
17486
|
var init_config3 = __esm({
|
|
@@ -16864,13 +17489,13 @@ var init_config3 = __esm({
|
|
|
16864
17489
|
init_paths();
|
|
16865
17490
|
init_text();
|
|
16866
17491
|
__filename2 = fileURLToPath2(import.meta.url);
|
|
16867
|
-
__dirname =
|
|
17492
|
+
__dirname = dirname7(__filename2);
|
|
16868
17493
|
isBunBinary = import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
|
|
16869
17494
|
isBunRuntime = !!process.versions.bun;
|
|
16870
17495
|
isBundledNode = typeof PI_BUNDLED_NODE !== "undefined" && PI_BUNDLED_NODE;
|
|
16871
17496
|
pkg = {};
|
|
16872
17497
|
try {
|
|
16873
|
-
pkg = JSON.parse(stripBom(
|
|
17498
|
+
pkg = JSON.parse(stripBom(readFileSync2(getPackageJsonPath(), "utf-8")));
|
|
16874
17499
|
} catch (e2) {
|
|
16875
17500
|
const err2 = e2;
|
|
16876
17501
|
if (err2.code !== "ENOENT")
|
|
@@ -24908,8 +25533,8 @@ var init_event_stream = __esm({
|
|
|
24908
25533
|
constructor(isComplete, extractResult) {
|
|
24909
25534
|
this.isComplete = isComplete;
|
|
24910
25535
|
this.extractResult = extractResult;
|
|
24911
|
-
this.finalResultPromise = new Promise((
|
|
24912
|
-
this.resolveFinalResult =
|
|
25536
|
+
this.finalResultPromise = new Promise((resolve13) => {
|
|
25537
|
+
this.resolveFinalResult = resolve13;
|
|
24913
25538
|
});
|
|
24914
25539
|
}
|
|
24915
25540
|
push(event) {
|
|
@@ -24943,7 +25568,7 @@ var init_event_stream = __esm({
|
|
|
24943
25568
|
} else if (this.done) {
|
|
24944
25569
|
return;
|
|
24945
25570
|
} else {
|
|
24946
|
-
const result = await new Promise((
|
|
25571
|
+
const result = await new Promise((resolve13) => this.waiting.enqueue(resolve13));
|
|
24947
25572
|
if (result.done)
|
|
24948
25573
|
return;
|
|
24949
25574
|
yield result.value;
|
|
@@ -25096,7 +25721,7 @@ function raceWithAbortSignal(operation, signal) {
|
|
|
25096
25721
|
});
|
|
25097
25722
|
return Promise.reject(abortReason(signal));
|
|
25098
25723
|
}
|
|
25099
|
-
return new Promise((
|
|
25724
|
+
return new Promise((resolve13, reject) => {
|
|
25100
25725
|
let settled = false;
|
|
25101
25726
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
25102
25727
|
const onAbort = () => {
|
|
@@ -25112,7 +25737,7 @@ function raceWithAbortSignal(operation, signal) {
|
|
|
25112
25737
|
return;
|
|
25113
25738
|
settled = true;
|
|
25114
25739
|
cleanup();
|
|
25115
|
-
|
|
25740
|
+
resolve13(value2);
|
|
25116
25741
|
}, (error) => {
|
|
25117
25742
|
if (settled)
|
|
25118
25743
|
return;
|
|
@@ -26145,8 +26770,8 @@ var init_models = __esm({
|
|
|
26145
26770
|
const credential = await raceWithAbortSignal(loginOperation, signal);
|
|
26146
26771
|
let mutationStarted = false;
|
|
26147
26772
|
let markMutationStarted;
|
|
26148
|
-
const started = new Promise((
|
|
26149
|
-
markMutationStarted =
|
|
26773
|
+
const started = new Promise((resolve13) => {
|
|
26774
|
+
markMutationStarted = resolve13;
|
|
26150
26775
|
});
|
|
26151
26776
|
const mutation = this.credentials.modify(providerId, async () => {
|
|
26152
26777
|
mutationStarted = true;
|
|
@@ -26156,7 +26781,7 @@ var init_models = __esm({
|
|
|
26156
26781
|
void mutation.catch(() => {
|
|
26157
26782
|
});
|
|
26158
26783
|
try {
|
|
26159
|
-
await new Promise((
|
|
26784
|
+
await new Promise((resolve13, reject) => {
|
|
26160
26785
|
const onAbort = () => {
|
|
26161
26786
|
if (!mutationStarted)
|
|
26162
26787
|
reject(signal.reason);
|
|
@@ -26164,7 +26789,7 @@ var init_models = __esm({
|
|
|
26164
26789
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
26165
26790
|
void Promise.race([started, mutation]).then(() => {
|
|
26166
26791
|
signal.removeEventListener("abort", onAbort);
|
|
26167
|
-
|
|
26792
|
+
resolve13();
|
|
26168
26793
|
}, (error) => {
|
|
26169
26794
|
signal.removeEventListener("abort", onAbort);
|
|
26170
26795
|
reject(error);
|
|
@@ -42088,13 +42713,13 @@ var require_ignore = __commonJS({
|
|
|
42088
42713
|
const rules = this._rules;
|
|
42089
42714
|
const { length } = rules;
|
|
42090
42715
|
const shortcut = this._basenameCount * 2 >= length;
|
|
42091
|
-
const
|
|
42716
|
+
const basename15 = shortcut ? basenameOf(path8) : path8;
|
|
42092
42717
|
for (let index3 = 0; index3 < length; index3++) {
|
|
42093
42718
|
const rule = rules[index3];
|
|
42094
42719
|
const { negative } = rule;
|
|
42095
42720
|
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
42096
42721
|
if (!skip && rule[mode].test(
|
|
42097
|
-
shortcut && rule._basenameOnly ?
|
|
42722
|
+
shortcut && rule._basenameOnly ? basename15 : path8
|
|
42098
42723
|
)) {
|
|
42099
42724
|
ignored = !negative;
|
|
42100
42725
|
unignored = negative;
|
|
@@ -43057,16 +43682,16 @@ var init_values2 = __esm({
|
|
|
43057
43682
|
var sleep;
|
|
43058
43683
|
var init_sleep = __esm({
|
|
43059
43684
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.124.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
43060
|
-
sleep = (ms, signal) => new Promise((
|
|
43685
|
+
sleep = (ms, signal) => new Promise((resolve13) => {
|
|
43061
43686
|
if (signal?.aborted)
|
|
43062
|
-
return
|
|
43687
|
+
return resolve13();
|
|
43063
43688
|
const onAbort = () => {
|
|
43064
43689
|
clearTimeout(timer);
|
|
43065
|
-
|
|
43690
|
+
resolve13();
|
|
43066
43691
|
};
|
|
43067
43692
|
const timer = setTimeout(() => {
|
|
43068
43693
|
signal?.removeEventListener("abort", onAbort);
|
|
43069
|
-
|
|
43694
|
+
resolve13();
|
|
43070
43695
|
}, ms);
|
|
43071
43696
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
43072
43697
|
});
|
|
@@ -45238,8 +45863,8 @@ var init_api_promise = __esm({
|
|
|
45238
45863
|
init_parse7();
|
|
45239
45864
|
APIPromise = class _APIPromise extends Promise {
|
|
45240
45865
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
45241
|
-
super((
|
|
45242
|
-
|
|
45866
|
+
super((resolve13) => {
|
|
45867
|
+
resolve13(null);
|
|
45243
45868
|
});
|
|
45244
45869
|
this.responsePromise = responsePromise;
|
|
45245
45870
|
this.parseResponse = parseResponse2;
|
|
@@ -47878,16 +48503,16 @@ var init_async_queue = __esm({
|
|
|
47878
48503
|
if (__classPrivateFieldGet3(this, _AsyncQueue_closed, "f") || signal?.aborted) {
|
|
47879
48504
|
return Promise.resolve({ done: true, value: void 0 });
|
|
47880
48505
|
}
|
|
47881
|
-
return new Promise((
|
|
48506
|
+
return new Promise((resolve13) => {
|
|
47882
48507
|
const waiter = (r2) => {
|
|
47883
48508
|
signal?.removeEventListener("abort", onAbort);
|
|
47884
|
-
|
|
48509
|
+
resolve13(r2);
|
|
47885
48510
|
};
|
|
47886
48511
|
const onAbort = () => {
|
|
47887
48512
|
const idx = __classPrivateFieldGet3(this, _AsyncQueue_waiters, "f").indexOf(waiter);
|
|
47888
48513
|
if (idx >= 0)
|
|
47889
48514
|
__classPrivateFieldGet3(this, _AsyncQueue_waiters, "f").splice(idx, 1);
|
|
47890
|
-
|
|
48515
|
+
resolve13({ done: true, value: void 0 });
|
|
47891
48516
|
};
|
|
47892
48517
|
__classPrivateFieldGet3(this, _AsyncQueue_waiters, "f").push(waiter);
|
|
47893
48518
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -48521,13 +49146,13 @@ var init_json_schema = __esm({
|
|
|
48521
49146
|
|
|
48522
49147
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.124.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs
|
|
48523
49148
|
function promiseWithResolvers() {
|
|
48524
|
-
let
|
|
49149
|
+
let resolve13;
|
|
48525
49150
|
let reject;
|
|
48526
49151
|
const promise = new Promise((res, rej) => {
|
|
48527
|
-
|
|
49152
|
+
resolve13 = res;
|
|
48528
49153
|
reject = rej;
|
|
48529
49154
|
});
|
|
48530
|
-
return { promise, resolve:
|
|
49155
|
+
return { promise, resolve: resolve13, reject };
|
|
48531
49156
|
}
|
|
48532
49157
|
var init_promise = __esm({
|
|
48533
49158
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.124.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs"() {
|
|
@@ -48679,10 +49304,10 @@ async function setupSkills(ctx) {
|
|
|
48679
49304
|
for (const skill of session.agent.skills) {
|
|
48680
49305
|
try {
|
|
48681
49306
|
const version = await client.beta.skills.versions.retrieve(skill.version, { skill_id: skill.skill_id });
|
|
48682
|
-
let
|
|
48683
|
-
if (
|
|
48684
|
-
|
|
48685
|
-
const dest = path.resolve(skillsRoot,
|
|
49307
|
+
let dirname18 = path.basename(version.name.trim());
|
|
49308
|
+
if (dirname18 === "" || dirname18 === "." || dirname18 === "..")
|
|
49309
|
+
dirname18 = skill.skill_id;
|
|
49310
|
+
const dest = path.resolve(skillsRoot, dirname18);
|
|
48686
49311
|
if (dest !== skillsRoot && !dest.startsWith(skillsRoot + path.sep)) {
|
|
48687
49312
|
log.warn("skill name escapes the skills dir; skipping", {
|
|
48688
49313
|
component: "agent-tool-context",
|
|
@@ -49316,10 +49941,10 @@ async function settledOrAborted(p, signal) {
|
|
|
49316
49941
|
return;
|
|
49317
49942
|
}
|
|
49318
49943
|
let onAbort;
|
|
49319
|
-
const aborted = new Promise((
|
|
49320
|
-
onAbort =
|
|
49944
|
+
const aborted = new Promise((resolve13) => {
|
|
49945
|
+
onAbort = resolve13;
|
|
49321
49946
|
if (signal.aborted)
|
|
49322
|
-
|
|
49947
|
+
resolve13();
|
|
49323
49948
|
});
|
|
49324
49949
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
49325
49950
|
try {
|
|
@@ -50383,7 +51008,7 @@ function betaGrepTool(ctx) {
|
|
|
50383
51008
|
});
|
|
50384
51009
|
}
|
|
50385
51010
|
function runRipgrep(rg, pattern, searchPath, signal) {
|
|
50386
|
-
return new Promise((
|
|
51011
|
+
return new Promise((resolve13, reject) => {
|
|
50387
51012
|
const proc = cp.spawn(rg, ["-n", "--no-heading", "-e", pattern, "--", searchPath], {
|
|
50388
51013
|
...signal ? { signal } : {}
|
|
50389
51014
|
});
|
|
@@ -50405,12 +51030,12 @@ function runRipgrep(rg, pattern, searchPath, signal) {
|
|
|
50405
51030
|
if (signal?.aborted)
|
|
50406
51031
|
return reject(new ToolError("grep: aborted"));
|
|
50407
51032
|
if (truncated)
|
|
50408
|
-
return
|
|
51033
|
+
return resolve13(out + `
|
|
50409
51034
|
[output truncated at ${GREP_OUTPUT_LIMIT} bytes]`);
|
|
50410
51035
|
if (code === 0)
|
|
50411
|
-
return
|
|
51036
|
+
return resolve13(out);
|
|
50412
51037
|
if (code === 1)
|
|
50413
|
-
return
|
|
51038
|
+
return resolve13("no matches");
|
|
50414
51039
|
reject(new ToolError(`grep: rg failed: ${errOut || `exit ${code}`}`));
|
|
50415
51040
|
});
|
|
50416
51041
|
proc.on("error", (e2) => {
|
|
@@ -50591,8 +51216,8 @@ var init_node2 = __esm({
|
|
|
50591
51216
|
`;
|
|
50592
51217
|
__classPrivateFieldGet3(this, _BashSession_proc, "f").stdin.write(wrapped);
|
|
50593
51218
|
if (__classPrivateFieldGet3(this, _BashSession_buf, "f").indexOf(sentinel3) < 0) {
|
|
50594
|
-
const { promise: sentinelSeen, resolve:
|
|
50595
|
-
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel3, resolve:
|
|
51219
|
+
const { promise: sentinelSeen, resolve: resolve13 } = promiseWithResolvers();
|
|
51220
|
+
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel3, resolve: resolve13 }, "f");
|
|
50596
51221
|
let timer;
|
|
50597
51222
|
let onAbort;
|
|
50598
51223
|
try {
|
|
@@ -50749,8 +51374,8 @@ async function withTimeout(p, ms) {
|
|
|
50749
51374
|
try {
|
|
50750
51375
|
return await Promise.race([
|
|
50751
51376
|
p.then(() => false, () => false),
|
|
50752
|
-
new Promise((
|
|
50753
|
-
timer = setTimeout(() =>
|
|
51377
|
+
new Promise((resolve13) => {
|
|
51378
|
+
timer = setTimeout(() => resolve13(true), ms);
|
|
50754
51379
|
})
|
|
50755
51380
|
]);
|
|
50756
51381
|
} finally {
|
|
@@ -52654,12 +53279,12 @@ var init_BetaMessageStream = __esm({
|
|
|
52654
53279
|
}
|
|
52655
53280
|
return this._emit("error", new AnthropicError(String(error)));
|
|
52656
53281
|
});
|
|
52657
|
-
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
52658
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise,
|
|
53282
|
+
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve13, reject) => {
|
|
53283
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve13, "f");
|
|
52659
53284
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
52660
53285
|
}), "f");
|
|
52661
|
-
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((
|
|
52662
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise,
|
|
53286
|
+
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve13, reject) => {
|
|
53287
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve13, "f");
|
|
52663
53288
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
52664
53289
|
}), "f");
|
|
52665
53290
|
__classPrivateFieldGet3(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -52834,11 +53459,11 @@ var init_BetaMessageStream = __esm({
|
|
|
52834
53459
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
52835
53460
|
*/
|
|
52836
53461
|
emitted(event) {
|
|
52837
|
-
return new Promise((
|
|
53462
|
+
return new Promise((resolve13, reject) => {
|
|
52838
53463
|
__classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
52839
53464
|
if (event !== "error")
|
|
52840
53465
|
this.once("error", reject);
|
|
52841
|
-
this.once(event,
|
|
53466
|
+
this.once(event, resolve13);
|
|
52842
53467
|
});
|
|
52843
53468
|
}
|
|
52844
53469
|
async done() {
|
|
@@ -53211,7 +53836,7 @@ var init_BetaMessageStream = __esm({
|
|
|
53211
53836
|
if (done) {
|
|
53212
53837
|
return { value: void 0, done: true };
|
|
53213
53838
|
}
|
|
53214
|
-
return new Promise((
|
|
53839
|
+
return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
53215
53840
|
}
|
|
53216
53841
|
const chunk = pushQueue.shift();
|
|
53217
53842
|
return { value: chunk, done: false };
|
|
@@ -57492,12 +58117,12 @@ var init_MessageStream = __esm({
|
|
|
57492
58117
|
}
|
|
57493
58118
|
return this._emit("error", new AnthropicError(String(error)));
|
|
57494
58119
|
});
|
|
57495
|
-
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((
|
|
57496
|
-
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise,
|
|
58120
|
+
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve13, reject) => {
|
|
58121
|
+
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve13, "f");
|
|
57497
58122
|
__classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
57498
58123
|
}), "f");
|
|
57499
|
-
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((
|
|
57500
|
-
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise,
|
|
58124
|
+
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve13, reject) => {
|
|
58125
|
+
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve13, "f");
|
|
57501
58126
|
__classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
57502
58127
|
}), "f");
|
|
57503
58128
|
__classPrivateFieldGet3(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -57672,11 +58297,11 @@ var init_MessageStream = __esm({
|
|
|
57672
58297
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
57673
58298
|
*/
|
|
57674
58299
|
emitted(event) {
|
|
57675
|
-
return new Promise((
|
|
58300
|
+
return new Promise((resolve13, reject) => {
|
|
57676
58301
|
__classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
57677
58302
|
if (event !== "error")
|
|
57678
58303
|
this.once("error", reject);
|
|
57679
|
-
this.once(event,
|
|
58304
|
+
this.once(event, resolve13);
|
|
57680
58305
|
});
|
|
57681
58306
|
}
|
|
57682
58307
|
async done() {
|
|
@@ -58001,7 +58626,7 @@ var init_MessageStream = __esm({
|
|
|
58001
58626
|
if (done) {
|
|
58002
58627
|
return { value: void 0, done: true };
|
|
58003
58628
|
}
|
|
58004
|
-
return new Promise((
|
|
58629
|
+
return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
58005
58630
|
}
|
|
58006
58631
|
const chunk = pushQueue.shift();
|
|
58007
58632
|
return { value: chunk, done: false };
|
|
@@ -59507,8 +60132,8 @@ function getBunSandboxEnvValue(name) {
|
|
|
59507
60132
|
if (procEnvCache === null) {
|
|
59508
60133
|
procEnvCache = /* @__PURE__ */ new Map();
|
|
59509
60134
|
try {
|
|
59510
|
-
const { readFileSync:
|
|
59511
|
-
const data =
|
|
60135
|
+
const { readFileSync: readFileSync5 } = __require("node:fs");
|
|
60136
|
+
const data = readFileSync5("/proc/self/environ", "utf-8");
|
|
59512
60137
|
for (const entry of data.split("\0")) {
|
|
59513
60138
|
const idx = entry.indexOf("=");
|
|
59514
60139
|
if (idx > 0) {
|
|
@@ -59575,7 +60200,7 @@ function createAbortError() {
|
|
|
59575
60200
|
return error;
|
|
59576
60201
|
}
|
|
59577
60202
|
function abortableSleep(ms, signal) {
|
|
59578
|
-
return new Promise((
|
|
60203
|
+
return new Promise((resolve13, reject) => {
|
|
59579
60204
|
if (signal?.aborted) {
|
|
59580
60205
|
reject(createAbortError());
|
|
59581
60206
|
return;
|
|
@@ -59586,7 +60211,7 @@ function abortableSleep(ms, signal) {
|
|
|
59586
60211
|
};
|
|
59587
60212
|
const timeout = setTimeout(() => {
|
|
59588
60213
|
signal?.removeEventListener("abort", onAbort);
|
|
59589
|
-
|
|
60214
|
+
resolve13();
|
|
59590
60215
|
}, Math.max(0, ms));
|
|
59591
60216
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
59592
60217
|
});
|
|
@@ -61559,7 +62184,7 @@ var init_values3 = __esm({
|
|
|
61559
62184
|
var sleep2;
|
|
61560
62185
|
var init_sleep2 = __esm({
|
|
61561
62186
|
"node_modules/.pnpm/openai@7.19.0_@aws-sdk+credential-provider-node@3.972.83_@smithy+signature-v4@5.7.3_undici@8.10.2_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/sleep.mjs"() {
|
|
61562
|
-
sleep2 = (ms, ...signals) => new Promise((
|
|
62187
|
+
sleep2 = (ms, ...signals) => new Promise((resolve13, reject) => {
|
|
61563
62188
|
const activeSignals = [...new Set(signals.filter((signal) => signal != null))];
|
|
61564
62189
|
let timeout;
|
|
61565
62190
|
let settled = false;
|
|
@@ -61591,7 +62216,7 @@ var init_sleep2 = __esm({
|
|
|
61591
62216
|
return;
|
|
61592
62217
|
}
|
|
61593
62218
|
timeout = setTimeout(() => {
|
|
61594
|
-
settle(
|
|
62219
|
+
settle(resolve13);
|
|
61595
62220
|
}, ms);
|
|
61596
62221
|
for (const signal of activeSignals) {
|
|
61597
62222
|
if (settled) {
|
|
@@ -62133,8 +62758,8 @@ function createAbortableSSESource(body, signal) {
|
|
|
62133
62758
|
let interrupt;
|
|
62134
62759
|
const waitForAbort = () => (
|
|
62135
62760
|
// oxlint-disable-next-line promise/avoid-new -- AbortSignal callbacks need a portable Promise bridge.
|
|
62136
|
-
new Promise((
|
|
62137
|
-
interrupt =
|
|
62761
|
+
new Promise((resolve13) => {
|
|
62762
|
+
interrupt = resolve13;
|
|
62138
62763
|
})
|
|
62139
62764
|
);
|
|
62140
62765
|
const cancel = () => {
|
|
@@ -63406,8 +64031,8 @@ var init_api_promise2 = __esm({
|
|
|
63406
64031
|
init_parse8();
|
|
63407
64032
|
APIPromise2 = class _APIPromise extends Promise {
|
|
63408
64033
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
63409
|
-
super((
|
|
63410
|
-
|
|
64034
|
+
super((resolve13) => {
|
|
64035
|
+
resolve13(null);
|
|
63411
64036
|
});
|
|
63412
64037
|
this.responsePromise = responsePromise;
|
|
63413
64038
|
this.parseResponse = parseResponse2;
|
|
@@ -64931,20 +65556,20 @@ function getName2(value2, options) {
|
|
|
64931
65556
|
const name = "name" in value2 ? value2.name : void 0;
|
|
64932
65557
|
const explicitName = name && String(name) || "filename" in value2 && value2.filename && String(value2.filename);
|
|
64933
65558
|
if (explicitName) {
|
|
64934
|
-
return options?.stripFilename === false ? normalizeFilenamePath(explicitName) :
|
|
65559
|
+
return options?.stripFilename === false ? normalizeFilenamePath(explicitName) : basename8(explicitName);
|
|
64935
65560
|
}
|
|
64936
65561
|
const url = "url" in value2 && value2.url && String(value2.url);
|
|
64937
65562
|
if (url) {
|
|
64938
65563
|
try {
|
|
64939
|
-
return
|
|
65564
|
+
return basename8(new URL(url).pathname);
|
|
64940
65565
|
} catch {
|
|
64941
|
-
return
|
|
65566
|
+
return basename8(url);
|
|
64942
65567
|
}
|
|
64943
65568
|
}
|
|
64944
65569
|
const path8 = "path" in value2 && value2.path && String(value2.path);
|
|
64945
|
-
return path8 ?
|
|
65570
|
+
return path8 ? basename8(path8) : void 0;
|
|
64946
65571
|
}
|
|
64947
|
-
function
|
|
65572
|
+
function basename8(value2) {
|
|
64948
65573
|
return value2.split(/[\\/]/).pop() || void 0;
|
|
64949
65574
|
}
|
|
64950
65575
|
function normalizeFilenamePath(value2) {
|
|
@@ -65048,7 +65673,7 @@ function getStreamingFileName(value2, options) {
|
|
|
65048
65673
|
if (typeof name !== "string" || !name) {
|
|
65049
65674
|
throw new TypeError("Streaming upload file name must be a non-empty string");
|
|
65050
65675
|
}
|
|
65051
|
-
return options.stripFilenames === false ? normalizeFilenamePath(name) :
|
|
65676
|
+
return options.stripFilenames === false ? normalizeFilenamePath(name) : basename8(name) ?? "unknown_file";
|
|
65052
65677
|
}
|
|
65053
65678
|
return getName2(value2, { stripFilename: options.stripFilenames }) ?? "unknown_file";
|
|
65054
65679
|
}
|
|
@@ -66501,12 +67126,12 @@ var init_EventStream = __esm({
|
|
|
66501
67126
|
_EventStream_aborted.set(this, false);
|
|
66502
67127
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
66503
67128
|
_EventStream_terminalFailure.set(this, void 0);
|
|
66504
|
-
__classPrivateFieldSet2(this, _EventStream_connectedPromise, new Promise((
|
|
66505
|
-
__classPrivateFieldSet2(this, _EventStream_resolveConnectedPromise,
|
|
67129
|
+
__classPrivateFieldSet2(this, _EventStream_connectedPromise, new Promise((resolve13, reject) => {
|
|
67130
|
+
__classPrivateFieldSet2(this, _EventStream_resolveConnectedPromise, resolve13, "f");
|
|
66506
67131
|
__classPrivateFieldSet2(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
66507
67132
|
}), "f");
|
|
66508
|
-
__classPrivateFieldSet2(this, _EventStream_endPromise, new Promise((
|
|
66509
|
-
__classPrivateFieldSet2(this, _EventStream_resolveEndPromise,
|
|
67133
|
+
__classPrivateFieldSet2(this, _EventStream_endPromise, new Promise((resolve13, reject) => {
|
|
67134
|
+
__classPrivateFieldSet2(this, _EventStream_resolveEndPromise, resolve13, "f");
|
|
66510
67135
|
__classPrivateFieldSet2(this, _EventStream_rejectEndPromise, reject, "f");
|
|
66511
67136
|
}), "f");
|
|
66512
67137
|
__classPrivateFieldGet4(this, _EventStream_connectedPromise, "f").catch(() => void 0);
|
|
@@ -66644,7 +67269,7 @@ var init_EventStream = __esm({
|
|
|
66644
67269
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
66645
67270
|
*/
|
|
66646
67271
|
emitted(event) {
|
|
66647
|
-
return new Promise((
|
|
67272
|
+
return new Promise((resolve13, reject) => {
|
|
66648
67273
|
__classPrivateFieldSet2(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
66649
67274
|
const onError = (error) => {
|
|
66650
67275
|
this.off(event, onEvent);
|
|
@@ -66654,7 +67279,7 @@ var init_EventStream = __esm({
|
|
|
66654
67279
|
if (event !== "error") {
|
|
66655
67280
|
this.off("error", onError);
|
|
66656
67281
|
}
|
|
66657
|
-
|
|
67282
|
+
resolve13(values.length > 1 ? values : values[0]);
|
|
66658
67283
|
};
|
|
66659
67284
|
if (event !== "error") {
|
|
66660
67285
|
__classPrivateFieldGet4(this, _EventStream_instances, "m", _EventStream_onceForEmitted).call(this, "error", onError);
|
|
@@ -66870,8 +67495,8 @@ var init_EventStream = __esm({
|
|
|
66870
67495
|
if (ended) {
|
|
66871
67496
|
return Promise.resolve(doneResult());
|
|
66872
67497
|
}
|
|
66873
|
-
return new Promise((
|
|
66874
|
-
readQueue.enqueue({ resolve:
|
|
67498
|
+
return new Promise((resolve13, reject) => {
|
|
67499
|
+
readQueue.enqueue({ resolve: resolve13, reject });
|
|
66875
67500
|
});
|
|
66876
67501
|
},
|
|
66877
67502
|
return: () => {
|
|
@@ -73023,8 +73648,8 @@ var init_agent_session_stream = __esm({
|
|
|
73023
73648
|
try {
|
|
73024
73649
|
await __classPrivateFieldGet4(this, _AgentSessionStream_instances, "m", _AgentSessionStream_wait).call(this, () => (
|
|
73025
73650
|
// oxlint-disable-next-line promise/avoid-new -- Own the registration timer so cancellation clears it promptly.
|
|
73026
|
-
new Promise((
|
|
73027
|
-
timer = setTimeout(
|
|
73651
|
+
new Promise((resolve13) => {
|
|
73652
|
+
timer = setTimeout(resolve13, delay2);
|
|
73028
73653
|
})
|
|
73029
73654
|
));
|
|
73030
73655
|
} finally {
|
|
@@ -75507,7 +76132,7 @@ var init_AssistantStream = __esm({
|
|
|
75507
76132
|
|
|
75508
76133
|
// node_modules/.pnpm/openai@7.19.0_@aws-sdk+credential-provider-node@3.972.83_@smithy+signature-v4@5.7.3_undici@8.10.2_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/polling.mjs
|
|
75509
76134
|
function sleepUntilAborted(milliseconds, signal) {
|
|
75510
|
-
return new Promise((
|
|
76135
|
+
return new Promise((resolve13, reject) => {
|
|
75511
76136
|
let timer;
|
|
75512
76137
|
let registered;
|
|
75513
76138
|
let settled = false;
|
|
@@ -75556,7 +76181,7 @@ function sleepUntilAborted(milliseconds, signal) {
|
|
|
75556
76181
|
}
|
|
75557
76182
|
settled = true;
|
|
75558
76183
|
cleanup();
|
|
75559
|
-
|
|
76184
|
+
resolve13();
|
|
75560
76185
|
}, milliseconds);
|
|
75561
76186
|
registered = abort;
|
|
75562
76187
|
try {
|
|
@@ -82819,7 +83444,7 @@ var require_p_retry = __commonJS({
|
|
|
82819
83444
|
return error;
|
|
82820
83445
|
};
|
|
82821
83446
|
var isNetworkError = (errorMessage5) => networkErrorMsgs.includes(errorMessage5);
|
|
82822
|
-
var pRetry2 = (input, options) => new Promise((
|
|
83447
|
+
var pRetry2 = (input, options) => new Promise((resolve13, reject) => {
|
|
82823
83448
|
options = {
|
|
82824
83449
|
onFailedAttempt: () => {
|
|
82825
83450
|
},
|
|
@@ -82829,7 +83454,7 @@ var require_p_retry = __commonJS({
|
|
|
82829
83454
|
const operation = retry2.operation(options);
|
|
82830
83455
|
operation.attempt(async (attemptNumber) => {
|
|
82831
83456
|
try {
|
|
82832
|
-
|
|
83457
|
+
resolve13(await input(attemptNumber));
|
|
82833
83458
|
} catch (error) {
|
|
82834
83459
|
if (!(error instanceof Error)) {
|
|
82835
83460
|
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
@@ -83363,8 +83988,8 @@ var require_retry3 = __commonJS({
|
|
|
83363
83988
|
}
|
|
83364
83989
|
const delay2 = getNextRetryDelay(config);
|
|
83365
83990
|
err2.config.retryConfig.currentRetryAttempt += 1;
|
|
83366
|
-
const backoff3 = config.retryBackoff ? config.retryBackoff(err2, delay2) : new Promise((
|
|
83367
|
-
setTimeout(
|
|
83991
|
+
const backoff3 = config.retryBackoff ? config.retryBackoff(err2, delay2) : new Promise((resolve13) => {
|
|
83992
|
+
setTimeout(resolve13, delay2);
|
|
83368
83993
|
});
|
|
83369
83994
|
if (config.onRetryAttempt) {
|
|
83370
83995
|
await config.onRetryAttempt(err2);
|
|
@@ -84140,8 +84765,8 @@ var require_helpers = __commonJS({
|
|
|
84140
84765
|
function req(url, opts = {}) {
|
|
84141
84766
|
const href = typeof url === "string" ? url : url.href;
|
|
84142
84767
|
const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts);
|
|
84143
|
-
const promise = new Promise((
|
|
84144
|
-
req2.once("response",
|
|
84768
|
+
const promise = new Promise((resolve13, reject) => {
|
|
84769
|
+
req2.once("response", resolve13).once("error", reject).end();
|
|
84145
84770
|
});
|
|
84146
84771
|
req2.then = promise.then.bind(promise);
|
|
84147
84772
|
return req2;
|
|
@@ -84318,7 +84943,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
84318
84943
|
var debug_1 = __importDefault(require_src());
|
|
84319
84944
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
84320
84945
|
function parseProxyResponse(socket) {
|
|
84321
|
-
return new Promise((
|
|
84946
|
+
return new Promise((resolve13, reject) => {
|
|
84322
84947
|
let buffersLength = 0;
|
|
84323
84948
|
const buffers = [];
|
|
84324
84949
|
function read() {
|
|
@@ -84384,7 +85009,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
84384
85009
|
}
|
|
84385
85010
|
debug("got proxy server response: %o %o", firstLine2, headers);
|
|
84386
85011
|
cleanup();
|
|
84387
|
-
|
|
85012
|
+
resolve13({
|
|
84388
85013
|
connect: {
|
|
84389
85014
|
statusCode,
|
|
84390
85015
|
statusText,
|
|
@@ -84626,7 +85251,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
84626
85251
|
return new originalPromise(executor);
|
|
84627
85252
|
}
|
|
84628
85253
|
function promiseResolvedWith(value2) {
|
|
84629
|
-
return newPromise((
|
|
85254
|
+
return newPromise((resolve13) => resolve13(value2));
|
|
84630
85255
|
}
|
|
84631
85256
|
function promiseRejectedWith(reason) {
|
|
84632
85257
|
return originalPromiseReject(reason);
|
|
@@ -84796,8 +85421,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
84796
85421
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
84797
85422
|
}
|
|
84798
85423
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
84799
|
-
reader._closedPromise = newPromise((
|
|
84800
|
-
reader._closedPromise_resolve =
|
|
85424
|
+
reader._closedPromise = newPromise((resolve13, reject) => {
|
|
85425
|
+
reader._closedPromise_resolve = resolve13;
|
|
84801
85426
|
reader._closedPromise_reject = reject;
|
|
84802
85427
|
});
|
|
84803
85428
|
}
|
|
@@ -84971,8 +85596,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
84971
85596
|
}
|
|
84972
85597
|
let resolvePromise;
|
|
84973
85598
|
let rejectPromise;
|
|
84974
|
-
const promise = newPromise((
|
|
84975
|
-
resolvePromise =
|
|
85599
|
+
const promise = newPromise((resolve13, reject) => {
|
|
85600
|
+
resolvePromise = resolve13;
|
|
84976
85601
|
rejectPromise = reject;
|
|
84977
85602
|
});
|
|
84978
85603
|
const readRequest = {
|
|
@@ -85077,8 +85702,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
85077
85702
|
const reader = this._reader;
|
|
85078
85703
|
let resolvePromise;
|
|
85079
85704
|
let rejectPromise;
|
|
85080
|
-
const promise = newPromise((
|
|
85081
|
-
resolvePromise =
|
|
85705
|
+
const promise = newPromise((resolve13, reject) => {
|
|
85706
|
+
resolvePromise = resolve13;
|
|
85082
85707
|
rejectPromise = reject;
|
|
85083
85708
|
});
|
|
85084
85709
|
const readRequest = {
|
|
@@ -86097,8 +86722,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86097
86722
|
}
|
|
86098
86723
|
let resolvePromise;
|
|
86099
86724
|
let rejectPromise;
|
|
86100
|
-
const promise = newPromise((
|
|
86101
|
-
resolvePromise =
|
|
86725
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86726
|
+
resolvePromise = resolve13;
|
|
86102
86727
|
rejectPromise = reject;
|
|
86103
86728
|
});
|
|
86104
86729
|
const readIntoRequest = {
|
|
@@ -86410,10 +87035,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86410
87035
|
wasAlreadyErroring = true;
|
|
86411
87036
|
reason = void 0;
|
|
86412
87037
|
}
|
|
86413
|
-
const promise = newPromise((
|
|
87038
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86414
87039
|
stream12._pendingAbortRequest = {
|
|
86415
87040
|
_promise: void 0,
|
|
86416
|
-
_resolve:
|
|
87041
|
+
_resolve: resolve13,
|
|
86417
87042
|
_reject: reject,
|
|
86418
87043
|
_reason: reason,
|
|
86419
87044
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -86430,9 +87055,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86430
87055
|
if (state3 === "closed" || state3 === "errored") {
|
|
86431
87056
|
return promiseRejectedWith(new TypeError(`The stream (in ${state3} state) is not in the writable state and cannot be closed`));
|
|
86432
87057
|
}
|
|
86433
|
-
const promise = newPromise((
|
|
87058
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86434
87059
|
const closeRequest = {
|
|
86435
|
-
_resolve:
|
|
87060
|
+
_resolve: resolve13,
|
|
86436
87061
|
_reject: reject
|
|
86437
87062
|
};
|
|
86438
87063
|
stream12._closeRequest = closeRequest;
|
|
@@ -86445,9 +87070,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86445
87070
|
return promise;
|
|
86446
87071
|
}
|
|
86447
87072
|
function WritableStreamAddWriteRequest(stream12) {
|
|
86448
|
-
const promise = newPromise((
|
|
87073
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86449
87074
|
const writeRequest = {
|
|
86450
|
-
_resolve:
|
|
87075
|
+
_resolve: resolve13,
|
|
86451
87076
|
_reject: reject
|
|
86452
87077
|
};
|
|
86453
87078
|
stream12._writeRequests.push(writeRequest);
|
|
@@ -87063,8 +87688,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87063
87688
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
87064
87689
|
}
|
|
87065
87690
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
87066
|
-
writer._closedPromise = newPromise((
|
|
87067
|
-
writer._closedPromise_resolve =
|
|
87691
|
+
writer._closedPromise = newPromise((resolve13, reject) => {
|
|
87692
|
+
writer._closedPromise_resolve = resolve13;
|
|
87068
87693
|
writer._closedPromise_reject = reject;
|
|
87069
87694
|
writer._closedPromiseState = "pending";
|
|
87070
87695
|
});
|
|
@@ -87100,8 +87725,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87100
87725
|
writer._closedPromiseState = "resolved";
|
|
87101
87726
|
}
|
|
87102
87727
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
87103
|
-
writer._readyPromise = newPromise((
|
|
87104
|
-
writer._readyPromise_resolve =
|
|
87728
|
+
writer._readyPromise = newPromise((resolve13, reject) => {
|
|
87729
|
+
writer._readyPromise_resolve = resolve13;
|
|
87105
87730
|
writer._readyPromise_reject = reject;
|
|
87106
87731
|
});
|
|
87107
87732
|
writer._readyPromiseState = "pending";
|
|
@@ -87188,7 +87813,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87188
87813
|
source._disturbed = true;
|
|
87189
87814
|
let shuttingDown = false;
|
|
87190
87815
|
let currentWrite = promiseResolvedWith(void 0);
|
|
87191
|
-
return newPromise((
|
|
87816
|
+
return newPromise((resolve13, reject) => {
|
|
87192
87817
|
let abortAlgorithm;
|
|
87193
87818
|
if (signal !== void 0) {
|
|
87194
87819
|
abortAlgorithm = () => {
|
|
@@ -87333,7 +87958,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87333
87958
|
if (isError) {
|
|
87334
87959
|
reject(error);
|
|
87335
87960
|
} else {
|
|
87336
|
-
|
|
87961
|
+
resolve13(void 0);
|
|
87337
87962
|
}
|
|
87338
87963
|
return null;
|
|
87339
87964
|
}
|
|
@@ -87614,8 +88239,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87614
88239
|
let branch1;
|
|
87615
88240
|
let branch2;
|
|
87616
88241
|
let resolveCancelPromise;
|
|
87617
|
-
const cancelPromise = newPromise((
|
|
87618
|
-
resolveCancelPromise =
|
|
88242
|
+
const cancelPromise = newPromise((resolve13) => {
|
|
88243
|
+
resolveCancelPromise = resolve13;
|
|
87619
88244
|
});
|
|
87620
88245
|
function pullAlgorithm() {
|
|
87621
88246
|
if (reading) {
|
|
@@ -87706,8 +88331,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87706
88331
|
let branch1;
|
|
87707
88332
|
let branch2;
|
|
87708
88333
|
let resolveCancelPromise;
|
|
87709
|
-
const cancelPromise = newPromise((
|
|
87710
|
-
resolveCancelPromise =
|
|
88334
|
+
const cancelPromise = newPromise((resolve13) => {
|
|
88335
|
+
resolveCancelPromise = resolve13;
|
|
87711
88336
|
});
|
|
87712
88337
|
function forwardReaderError(thisReader) {
|
|
87713
88338
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -88487,8 +89112,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88487
89112
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
88488
89113
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
88489
89114
|
let startPromise_resolve;
|
|
88490
|
-
const startPromise = newPromise((
|
|
88491
|
-
startPromise_resolve =
|
|
89115
|
+
const startPromise = newPromise((resolve13) => {
|
|
89116
|
+
startPromise_resolve = resolve13;
|
|
88492
89117
|
});
|
|
88493
89118
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
88494
89119
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -88581,8 +89206,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88581
89206
|
if (stream12._backpressureChangePromise !== void 0) {
|
|
88582
89207
|
stream12._backpressureChangePromise_resolve();
|
|
88583
89208
|
}
|
|
88584
|
-
stream12._backpressureChangePromise = newPromise((
|
|
88585
|
-
stream12._backpressureChangePromise_resolve =
|
|
89209
|
+
stream12._backpressureChangePromise = newPromise((resolve13) => {
|
|
89210
|
+
stream12._backpressureChangePromise_resolve = resolve13;
|
|
88586
89211
|
});
|
|
88587
89212
|
stream12._backpressure = backpressure;
|
|
88588
89213
|
}
|
|
@@ -88750,8 +89375,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88750
89375
|
return controller._finishPromise;
|
|
88751
89376
|
}
|
|
88752
89377
|
const readable = stream12._readable;
|
|
88753
|
-
controller._finishPromise = newPromise((
|
|
88754
|
-
controller._finishPromise_resolve =
|
|
89378
|
+
controller._finishPromise = newPromise((resolve13, reject) => {
|
|
89379
|
+
controller._finishPromise_resolve = resolve13;
|
|
88755
89380
|
controller._finishPromise_reject = reject;
|
|
88756
89381
|
});
|
|
88757
89382
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -88777,8 +89402,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88777
89402
|
return controller._finishPromise;
|
|
88778
89403
|
}
|
|
88779
89404
|
const readable = stream12._readable;
|
|
88780
|
-
controller._finishPromise = newPromise((
|
|
88781
|
-
controller._finishPromise_resolve =
|
|
89405
|
+
controller._finishPromise = newPromise((resolve13, reject) => {
|
|
89406
|
+
controller._finishPromise_resolve = resolve13;
|
|
88782
89407
|
controller._finishPromise_reject = reject;
|
|
88783
89408
|
});
|
|
88784
89409
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -88808,8 +89433,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88808
89433
|
return controller._finishPromise;
|
|
88809
89434
|
}
|
|
88810
89435
|
const writable = stream12._writable;
|
|
88811
|
-
controller._finishPromise = newPromise((
|
|
88812
|
-
controller._finishPromise_resolve =
|
|
89436
|
+
controller._finishPromise = newPromise((resolve13, reject) => {
|
|
89437
|
+
controller._finishPromise_resolve = resolve13;
|
|
88813
89438
|
controller._finishPromise_reject = reject;
|
|
88814
89439
|
});
|
|
88815
89440
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -89347,8 +89972,8 @@ var require_node_domexception = __commonJS({
|
|
|
89347
89972
|
});
|
|
89348
89973
|
|
|
89349
89974
|
// node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js
|
|
89350
|
-
import { statSync as
|
|
89351
|
-
import { basename as
|
|
89975
|
+
import { statSync as statSync3, createReadStream as createReadStream2, promises as fs5 } from "node:fs";
|
|
89976
|
+
import { basename as basename9 } from "node:path";
|
|
89352
89977
|
var import_node_domexception, stat2, blobFromSync, blobFrom, fileFrom, fileFromSync, fromBlob, fromFile, BlobDataItem;
|
|
89353
89978
|
var init_from = __esm({
|
|
89354
89979
|
"node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js"() {
|
|
@@ -89356,10 +89981,10 @@ var init_from = __esm({
|
|
|
89356
89981
|
init_file();
|
|
89357
89982
|
init_fetch_blob();
|
|
89358
89983
|
({ stat: stat2 } = fs5);
|
|
89359
|
-
blobFromSync = (path8, type) => fromBlob(
|
|
89984
|
+
blobFromSync = (path8, type) => fromBlob(statSync3(path8), path8, type);
|
|
89360
89985
|
blobFrom = (path8, type) => stat2(path8).then((stat7) => fromBlob(stat7, path8, type));
|
|
89361
89986
|
fileFrom = (path8, type) => stat2(path8).then((stat7) => fromFile(stat7, path8, type));
|
|
89362
|
-
fileFromSync = (path8, type) => fromFile(
|
|
89987
|
+
fileFromSync = (path8, type) => fromFile(statSync3(path8), path8, type);
|
|
89363
89988
|
fromBlob = (stat7, path8, type = "") => new fetch_blob_default([new BlobDataItem({
|
|
89364
89989
|
path: path8,
|
|
89365
89990
|
size: stat7.size,
|
|
@@ -89371,7 +89996,7 @@ var init_from = __esm({
|
|
|
89371
89996
|
size: stat7.size,
|
|
89372
89997
|
lastModified: stat7.mtimeMs,
|
|
89373
89998
|
start: 0
|
|
89374
|
-
})],
|
|
89999
|
+
})], basename9(path8), { type, lastModified: stat7.mtimeMs });
|
|
89375
90000
|
BlobDataItem = class _BlobDataItem {
|
|
89376
90001
|
#path;
|
|
89377
90002
|
#start;
|
|
@@ -90760,7 +91385,7 @@ import zlib from "node:zlib";
|
|
|
90760
91385
|
import Stream4, { PassThrough as PassThrough2, pipeline as pump } from "node:stream";
|
|
90761
91386
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
90762
91387
|
async function fetch2(url, options_) {
|
|
90763
|
-
return new Promise((
|
|
91388
|
+
return new Promise((resolve13, reject) => {
|
|
90764
91389
|
const request = new Request2(url, options_);
|
|
90765
91390
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
90766
91391
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -90769,7 +91394,7 @@ async function fetch2(url, options_) {
|
|
|
90769
91394
|
if (parsedURL.protocol === "data:") {
|
|
90770
91395
|
const data = dist_default(request.url);
|
|
90771
91396
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
90772
|
-
|
|
91397
|
+
resolve13(response2);
|
|
90773
91398
|
return;
|
|
90774
91399
|
}
|
|
90775
91400
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -90891,7 +91516,7 @@ async function fetch2(url, options_) {
|
|
|
90891
91516
|
if (responseReferrerPolicy) {
|
|
90892
91517
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
90893
91518
|
}
|
|
90894
|
-
|
|
91519
|
+
resolve13(fetch2(new Request2(locationURL, requestOptions)));
|
|
90895
91520
|
finalize();
|
|
90896
91521
|
return;
|
|
90897
91522
|
}
|
|
@@ -90924,7 +91549,7 @@ async function fetch2(url, options_) {
|
|
|
90924
91549
|
const codings = headers.get("Content-Encoding");
|
|
90925
91550
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
90926
91551
|
response = new Response2(body, responseOptions);
|
|
90927
|
-
|
|
91552
|
+
resolve13(response);
|
|
90928
91553
|
return;
|
|
90929
91554
|
}
|
|
90930
91555
|
const zlibOptions = {
|
|
@@ -90938,7 +91563,7 @@ async function fetch2(url, options_) {
|
|
|
90938
91563
|
}
|
|
90939
91564
|
});
|
|
90940
91565
|
response = new Response2(body, responseOptions);
|
|
90941
|
-
|
|
91566
|
+
resolve13(response);
|
|
90942
91567
|
return;
|
|
90943
91568
|
}
|
|
90944
91569
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -90962,12 +91587,12 @@ async function fetch2(url, options_) {
|
|
|
90962
91587
|
});
|
|
90963
91588
|
}
|
|
90964
91589
|
response = new Response2(body, responseOptions);
|
|
90965
|
-
|
|
91590
|
+
resolve13(response);
|
|
90966
91591
|
});
|
|
90967
91592
|
raw.once("end", () => {
|
|
90968
91593
|
if (!response) {
|
|
90969
91594
|
response = new Response2(body, responseOptions);
|
|
90970
|
-
|
|
91595
|
+
resolve13(response);
|
|
90971
91596
|
}
|
|
90972
91597
|
});
|
|
90973
91598
|
return;
|
|
@@ -90979,11 +91604,11 @@ async function fetch2(url, options_) {
|
|
|
90979
91604
|
}
|
|
90980
91605
|
});
|
|
90981
91606
|
response = new Response2(body, responseOptions);
|
|
90982
|
-
|
|
91607
|
+
resolve13(response);
|
|
90983
91608
|
return;
|
|
90984
91609
|
}
|
|
90985
91610
|
response = new Response2(body, responseOptions);
|
|
90986
|
-
|
|
91611
|
+
resolve13(response);
|
|
90987
91612
|
});
|
|
90988
91613
|
writeToStream(request_, request).catch(reject);
|
|
90989
91614
|
});
|
|
@@ -91055,7 +91680,7 @@ var require_gaxios = __commonJS({
|
|
|
91055
91680
|
var retry_js_1 = require_retry3();
|
|
91056
91681
|
var stream_1 = __require("stream");
|
|
91057
91682
|
var interceptor_js_1 = require_interceptor();
|
|
91058
|
-
var
|
|
91683
|
+
var randomUUID4 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
|
|
91059
91684
|
var HTTP_STATUS_NO_CONTENT = 204;
|
|
91060
91685
|
var Gaxios = class {
|
|
91061
91686
|
agentCache = /* @__PURE__ */ new Map();
|
|
@@ -91328,7 +91953,7 @@ var require_gaxios = __commonJS({
|
|
|
91328
91953
|
*/
|
|
91329
91954
|
["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
|
|
91330
91955
|
if (opts.multipart?.length) {
|
|
91331
|
-
const boundary = await
|
|
91956
|
+
const boundary = await randomUUID4();
|
|
91332
91957
|
preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
|
|
91333
91958
|
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
|
|
91334
91959
|
} else if (shouldDirectlyPassData) {
|
|
@@ -97051,7 +97676,7 @@ var require_jwtaccess = __commonJS({
|
|
|
97051
97676
|
}
|
|
97052
97677
|
}
|
|
97053
97678
|
fromStreamAsync(inputStream) {
|
|
97054
|
-
return new Promise((
|
|
97679
|
+
return new Promise((resolve13, reject) => {
|
|
97055
97680
|
if (!inputStream) {
|
|
97056
97681
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
97057
97682
|
}
|
|
@@ -97060,7 +97685,7 @@ var require_jwtaccess = __commonJS({
|
|
|
97060
97685
|
try {
|
|
97061
97686
|
const data = JSON.parse(s2);
|
|
97062
97687
|
this.fromJSON(data);
|
|
97063
|
-
|
|
97688
|
+
resolve13();
|
|
97064
97689
|
} catch (err2) {
|
|
97065
97690
|
reject(err2);
|
|
97066
97691
|
}
|
|
@@ -97299,7 +97924,7 @@ var require_jwtclient = __commonJS({
|
|
|
97299
97924
|
}
|
|
97300
97925
|
}
|
|
97301
97926
|
fromStreamAsync(inputStream) {
|
|
97302
|
-
return new Promise((
|
|
97927
|
+
return new Promise((resolve13, reject) => {
|
|
97303
97928
|
if (!inputStream) {
|
|
97304
97929
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
97305
97930
|
}
|
|
@@ -97308,7 +97933,7 @@ var require_jwtclient = __commonJS({
|
|
|
97308
97933
|
try {
|
|
97309
97934
|
const data = JSON.parse(s2);
|
|
97310
97935
|
this.fromJSON(data);
|
|
97311
|
-
|
|
97936
|
+
resolve13();
|
|
97312
97937
|
} catch (e2) {
|
|
97313
97938
|
reject(e2);
|
|
97314
97939
|
}
|
|
@@ -97441,7 +98066,7 @@ var require_refreshclient = __commonJS({
|
|
|
97441
98066
|
}
|
|
97442
98067
|
}
|
|
97443
98068
|
async fromStreamAsync(inputStream) {
|
|
97444
|
-
return new Promise((
|
|
98069
|
+
return new Promise((resolve13, reject) => {
|
|
97445
98070
|
if (!inputStream) {
|
|
97446
98071
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
97447
98072
|
}
|
|
@@ -97450,7 +98075,7 @@ var require_refreshclient = __commonJS({
|
|
|
97450
98075
|
try {
|
|
97451
98076
|
const data = JSON.parse(s2);
|
|
97452
98077
|
this.fromJSON(data);
|
|
97453
|
-
return
|
|
98078
|
+
return resolve13();
|
|
97454
98079
|
} catch (err2) {
|
|
97455
98080
|
return reject(err2);
|
|
97456
98081
|
}
|
|
@@ -99283,7 +99908,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
99283
99908
|
* @return A promise that resolves with the executable response.
|
|
99284
99909
|
*/
|
|
99285
99910
|
retrieveResponseFromExecutable(envMap) {
|
|
99286
|
-
return new Promise((
|
|
99911
|
+
return new Promise((resolve13, reject) => {
|
|
99287
99912
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
99288
99913
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
99289
99914
|
});
|
|
@@ -99305,7 +99930,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
99305
99930
|
try {
|
|
99306
99931
|
const responseJson = JSON.parse(output);
|
|
99307
99932
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
99308
|
-
return
|
|
99933
|
+
return resolve13(response);
|
|
99309
99934
|
} catch (error) {
|
|
99310
99935
|
if (error instanceof executable_response_1.ExecutableResponseError) {
|
|
99311
99936
|
return reject(error);
|
|
@@ -100497,7 +101122,7 @@ var require_googleauth = __commonJS({
|
|
|
100497
101122
|
}
|
|
100498
101123
|
}
|
|
100499
101124
|
fromStreamAsync(inputStream, options) {
|
|
100500
|
-
return new Promise((
|
|
101125
|
+
return new Promise((resolve13, reject) => {
|
|
100501
101126
|
if (!inputStream) {
|
|
100502
101127
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
100503
101128
|
}
|
|
@@ -100507,7 +101132,7 @@ var require_googleauth = __commonJS({
|
|
|
100507
101132
|
try {
|
|
100508
101133
|
const data = JSON.parse(chunks.join(""));
|
|
100509
101134
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
100510
|
-
return
|
|
101135
|
+
return resolve13(r2);
|
|
100511
101136
|
} catch (err2) {
|
|
100512
101137
|
if (!this.keyFilename)
|
|
100513
101138
|
throw err2;
|
|
@@ -100517,7 +101142,7 @@ var require_googleauth = __commonJS({
|
|
|
100517
101142
|
});
|
|
100518
101143
|
this.cachedCredential = client;
|
|
100519
101144
|
this.setGapicJWTValues(client);
|
|
100520
|
-
return
|
|
101145
|
+
return resolve13(client);
|
|
100521
101146
|
}
|
|
100522
101147
|
} catch (err2) {
|
|
100523
101148
|
return reject(err2);
|
|
@@ -100553,17 +101178,17 @@ var require_googleauth = __commonJS({
|
|
|
100553
101178
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
100554
101179
|
*/
|
|
100555
101180
|
async getDefaultServiceProjectId() {
|
|
100556
|
-
return new Promise((
|
|
101181
|
+
return new Promise((resolve13) => {
|
|
100557
101182
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err2, stdout) => {
|
|
100558
101183
|
if (!err2 && stdout) {
|
|
100559
101184
|
try {
|
|
100560
101185
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
100561
|
-
|
|
101186
|
+
resolve13(projectId);
|
|
100562
101187
|
return;
|
|
100563
101188
|
} catch (e2) {
|
|
100564
101189
|
}
|
|
100565
101190
|
}
|
|
100566
|
-
|
|
101191
|
+
resolve13(null);
|
|
100567
101192
|
});
|
|
100568
101193
|
});
|
|
100569
101194
|
}
|
|
@@ -108288,14 +108913,14 @@ function __asyncValues(o) {
|
|
|
108288
108913
|
}, i2);
|
|
108289
108914
|
function verb(n) {
|
|
108290
108915
|
i2[n] = o[n] && function(v2) {
|
|
108291
|
-
return new Promise(function(
|
|
108292
|
-
v2 = o[n](v2), settle(
|
|
108916
|
+
return new Promise(function(resolve13, reject) {
|
|
108917
|
+
v2 = o[n](v2), settle(resolve13, reject, v2.done, v2.value);
|
|
108293
108918
|
});
|
|
108294
108919
|
};
|
|
108295
108920
|
}
|
|
108296
|
-
function settle(
|
|
108921
|
+
function settle(resolve13, reject, d, v2) {
|
|
108297
108922
|
Promise.resolve(v2).then(function(v3) {
|
|
108298
|
-
|
|
108923
|
+
resolve13({ value: v3, done: d });
|
|
108299
108924
|
}, reject);
|
|
108300
108925
|
}
|
|
108301
108926
|
}
|
|
@@ -115215,7 +115840,7 @@ function retryIntervalFromResponse(res) {
|
|
|
115215
115840
|
return 0;
|
|
115216
115841
|
}
|
|
115217
115842
|
async function delay(delay2) {
|
|
115218
|
-
return new Promise((
|
|
115843
|
+
return new Promise((resolve13) => setTimeout(resolve13, delay2));
|
|
115219
115844
|
}
|
|
115220
115845
|
async function logRequest(logger, req) {
|
|
115221
115846
|
if (!logger) {
|
|
@@ -122537,8 +123162,8 @@ var init_node3 = __esm({
|
|
|
122537
123162
|
const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
|
|
122538
123163
|
let onopenResolve = () => {
|
|
122539
123164
|
};
|
|
122540
|
-
const onopenPromise = new Promise((
|
|
122541
|
-
onopenResolve =
|
|
123165
|
+
const onopenPromise = new Promise((resolve13) => {
|
|
123166
|
+
onopenResolve = resolve13;
|
|
122542
123167
|
});
|
|
122543
123168
|
const callbacks = params.callbacks;
|
|
122544
123169
|
const onopenAwaitedCallback = function() {
|
|
@@ -122744,8 +123369,8 @@ var init_node3 = __esm({
|
|
|
122744
123369
|
}
|
|
122745
123370
|
let onopenResolve = () => {
|
|
122746
123371
|
};
|
|
122747
|
-
const onopenPromise = new Promise((
|
|
122748
|
-
onopenResolve =
|
|
123372
|
+
const onopenPromise = new Promise((resolve13) => {
|
|
123373
|
+
onopenResolve = resolve13;
|
|
122749
123374
|
});
|
|
122750
123375
|
const callbacks = params.callbacks;
|
|
122751
123376
|
const onopenAwaitedCallback = function() {
|
|
@@ -122758,8 +123383,8 @@ var init_node3 = __esm({
|
|
|
122758
123383
|
const messageQueue = [];
|
|
122759
123384
|
let setupCompleteResolve = () => {
|
|
122760
123385
|
};
|
|
122761
|
-
const setupCompletePromise = new Promise((
|
|
122762
|
-
setupCompleteResolve =
|
|
123386
|
+
const setupCompletePromise = new Promise((resolve13) => {
|
|
123387
|
+
setupCompleteResolve = resolve13;
|
|
122763
123388
|
});
|
|
122764
123389
|
const websocketCallbacks = {
|
|
122765
123390
|
onopen: onopenAwaitedCallback,
|
|
@@ -129120,12 +129745,12 @@ function validateRetryDelayMs(delayMs, options) {
|
|
|
129120
129745
|
return delayMs;
|
|
129121
129746
|
}
|
|
129122
129747
|
function sleep4(ms, signal) {
|
|
129123
|
-
return new Promise((
|
|
129748
|
+
return new Promise((resolve13, reject) => {
|
|
129124
129749
|
if (signal?.aborted) {
|
|
129125
129750
|
reject(new Error("Request was aborted"));
|
|
129126
129751
|
return;
|
|
129127
129752
|
}
|
|
129128
|
-
const timeout = setTimeout(
|
|
129753
|
+
const timeout = setTimeout(resolve13, ms);
|
|
129129
129754
|
signal?.addEventListener("abort", () => {
|
|
129130
129755
|
clearTimeout(timeout);
|
|
129131
129756
|
reject(new Error("Request was aborted"));
|
|
@@ -129513,7 +130138,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
129513
130138
|
}
|
|
129514
130139
|
const wsHeaders = headersToRecord(headers);
|
|
129515
130140
|
delete wsHeaders["OpenAI-Beta"];
|
|
129516
|
-
return new Promise((
|
|
130141
|
+
return new Promise((resolve13, reject) => {
|
|
129517
130142
|
let settled = false;
|
|
129518
130143
|
let timeout;
|
|
129519
130144
|
let socket;
|
|
@@ -129548,7 +130173,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
129548
130173
|
return;
|
|
129549
130174
|
settled = true;
|
|
129550
130175
|
cleanup();
|
|
129551
|
-
|
|
130176
|
+
resolve13(socket);
|
|
129552
130177
|
};
|
|
129553
130178
|
const onError = (event) => {
|
|
129554
130179
|
fail2(extractWebSocketError(event));
|
|
@@ -129724,9 +130349,9 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
129724
130349
|
const wake = () => {
|
|
129725
130350
|
if (!pending)
|
|
129726
130351
|
return;
|
|
129727
|
-
const
|
|
130352
|
+
const resolve13 = pending;
|
|
129728
130353
|
pending = null;
|
|
129729
|
-
|
|
130354
|
+
resolve13();
|
|
129730
130355
|
};
|
|
129731
130356
|
const onMessage = (event) => {
|
|
129732
130357
|
void (async () => {
|
|
@@ -129793,8 +130418,8 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
129793
130418
|
if (done)
|
|
129794
130419
|
break;
|
|
129795
130420
|
let timeout;
|
|
129796
|
-
await new Promise((
|
|
129797
|
-
pending =
|
|
130421
|
+
await new Promise((resolve13, reject) => {
|
|
130422
|
+
pending = resolve13;
|
|
129798
130423
|
if (idleTimeoutMs !== void 0 && idleTimeoutMs > 0) {
|
|
129799
130424
|
timeout = setTimeout(() => {
|
|
129800
130425
|
const error = new Error(`WebSocket idle timeout after ${idleTimeoutMs}ms`);
|
|
@@ -133904,7 +134529,7 @@ function timeoutError(timeoutMs) {
|
|
|
133904
134529
|
error.body = "";
|
|
133905
134530
|
return error;
|
|
133906
134531
|
}
|
|
133907
|
-
function
|
|
134532
|
+
function isRecord3(value2) {
|
|
133908
134533
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
133909
134534
|
}
|
|
133910
134535
|
function requiredNumber(label, value2, field2) {
|
|
@@ -133914,7 +134539,7 @@ function requiredNumber(label, value2, field2) {
|
|
|
133914
134539
|
return value2;
|
|
133915
134540
|
}
|
|
133916
134541
|
function probabilities(label, value2, id) {
|
|
133917
|
-
if (!
|
|
134542
|
+
if (!isRecord3(value2))
|
|
133918
134543
|
throw new Error(`${label} returned invalid probabilities for ${id}`);
|
|
133919
134544
|
return Object.fromEntries(Object.entries(value2).map(([key, probability]) => [
|
|
133920
134545
|
key,
|
|
@@ -133922,12 +134547,12 @@ function probabilities(label, value2, id) {
|
|
|
133922
134547
|
]));
|
|
133923
134548
|
}
|
|
133924
134549
|
function parseAnswers(label, value2, context) {
|
|
133925
|
-
if (!
|
|
134550
|
+
if (!isRecord3(value2))
|
|
133926
134551
|
throw new Error(`${label} returned an unexpected response`);
|
|
133927
134552
|
const answers = [];
|
|
133928
134553
|
for (const [id, question] of Object.entries(context.questions)) {
|
|
133929
134554
|
const answer = value2[id];
|
|
133930
|
-
if (!
|
|
134555
|
+
if (!isRecord3(answer))
|
|
133931
134556
|
throw new Error(`${label} did not return an answer for ${id}`);
|
|
133932
134557
|
if (question.type === "choice") {
|
|
133933
134558
|
if (answer.type !== "choice" || typeof answer.choice !== "string") {
|
|
@@ -133971,7 +134596,7 @@ function tokenCount(value2) {
|
|
|
133971
134596
|
return typeof value2 === "number" && Number.isFinite(value2) && value2 > 0 ? value2 : 0;
|
|
133972
134597
|
}
|
|
133973
134598
|
function parseUsage2(value2, model) {
|
|
133974
|
-
if (!
|
|
134599
|
+
if (!isRecord3(value2) || value2.input_tokens === void 0 && value2.output_tokens === void 0)
|
|
133975
134600
|
return void 0;
|
|
133976
134601
|
const input = tokenCount(value2.input_tokens);
|
|
133977
134602
|
const output = tokenCount(value2.output_tokens);
|
|
@@ -134070,7 +134695,7 @@ __export(cloudflare_workers_ai_system_one_exports, {
|
|
|
134070
134695
|
});
|
|
134071
134696
|
function cloudflareErrorMessage(errors) {
|
|
134072
134697
|
if (Array.isArray(errors)) {
|
|
134073
|
-
const messages = errors.map((error) =>
|
|
134698
|
+
const messages = errors.map((error) => isRecord3(error) && typeof error.message === "string" ? error.message : void 0).filter((message) => message !== void 0);
|
|
134074
134699
|
if (messages.length > 0)
|
|
134075
134700
|
return `${LABEL} error: ${messages.join("; ")}`;
|
|
134076
134701
|
}
|
|
@@ -134087,17 +134712,17 @@ var init_cloudflare_workers_ai_system_one = __esm({
|
|
|
134087
134712
|
url: (model) => new URL("run", `${model.baseUrl.replace(/\/+$/u, "")}/`),
|
|
134088
134713
|
payload: (model, request) => ({ model: model.id, input: request }),
|
|
134089
134714
|
output: (body) => {
|
|
134090
|
-
if (!
|
|
134715
|
+
if (!isRecord3(body))
|
|
134091
134716
|
throw new Error(`${LABEL} returned an unexpected response`);
|
|
134092
134717
|
if (body.success === false)
|
|
134093
134718
|
throw new Error(cloudflareErrorMessage(body.errors));
|
|
134094
134719
|
const run = body.result;
|
|
134095
|
-
if (!
|
|
134720
|
+
if (!isRecord3(run))
|
|
134096
134721
|
throw new Error(`${LABEL} returned an unexpected response`);
|
|
134097
134722
|
if (run.state !== "Completed") {
|
|
134098
134723
|
throw new Error(`${LABEL} run did not complete (state: ${String(run.state)})`);
|
|
134099
134724
|
}
|
|
134100
|
-
if (!
|
|
134725
|
+
if (!isRecord3(run.result))
|
|
134101
134726
|
throw new Error(`${LABEL} returned an unexpected response`);
|
|
134102
134727
|
return run.result;
|
|
134103
134728
|
}
|
|
@@ -134627,7 +135252,7 @@ var init_typesafe_system_one = __esm({
|
|
|
134627
135252
|
url: (model) => new URL("systemone", `${model.baseUrl.replace(/\/+$/u, "")}/`),
|
|
134628
135253
|
payload: (model, request) => ({ model: model.id, ...request }),
|
|
134629
135254
|
output: (body) => {
|
|
134630
|
-
if (!
|
|
135255
|
+
if (!isRecord3(body))
|
|
134631
135256
|
throw new Error("System One API returned an unexpected response");
|
|
134632
135257
|
return body;
|
|
134633
135258
|
}
|
|
@@ -138746,7 +139371,7 @@ var init_terminal_colors = __esm({
|
|
|
138746
139371
|
// node_modules/.pnpm/@earendil-works+pi-tui@0.99.1/node_modules/@earendil-works/pi-tui/dist/terminal-image.js
|
|
138747
139372
|
import { execSync } from "node:child_process";
|
|
138748
139373
|
import { homedir as homedir4 } from "node:os";
|
|
138749
|
-
import { isAbsolute as
|
|
139374
|
+
import { isAbsolute as isAbsolute5 } from "node:path";
|
|
138750
139375
|
import { pathToFileURL } from "node:url";
|
|
138751
139376
|
function setCellDimensions(dims) {
|
|
138752
139377
|
cellDimensions = dims;
|
|
@@ -139051,7 +139676,7 @@ function imageFallback(mimeType, dimensions, filename) {
|
|
|
139051
139676
|
const parts = [];
|
|
139052
139677
|
if (filename) {
|
|
139053
139678
|
const display = shortenImagePath(filename);
|
|
139054
|
-
if (getCapabilities().hyperlinks &&
|
|
139679
|
+
if (getCapabilities().hyperlinks && isAbsolute5(filename)) {
|
|
139055
139680
|
parts.push(hyperlink(display, pathToFileURL(filename).href));
|
|
139056
139681
|
} else {
|
|
139057
139682
|
parts.push(display);
|
|
@@ -140020,16 +140645,16 @@ var init_tui = __esm({
|
|
|
140020
140645
|
* @param onLateReply Receives the replies if the query completes after the timeout, e.g. over slow links.
|
|
140021
140646
|
*/
|
|
140022
140647
|
queryTerminalColors({ timeoutMs, onLateReply }) {
|
|
140023
|
-
return new Promise((
|
|
140648
|
+
return new Promise((resolve13) => {
|
|
140024
140649
|
const query = {
|
|
140025
140650
|
palette: Array.from({ length: TERMINAL_PALETTE_SIZE }, () => void 0),
|
|
140026
140651
|
replied: /* @__PURE__ */ new Set(),
|
|
140027
|
-
deliver:
|
|
140652
|
+
deliver: resolve13,
|
|
140028
140653
|
timer: void 0
|
|
140029
140654
|
};
|
|
140030
140655
|
query.timer = setTimeout(() => {
|
|
140031
140656
|
query.deliver = onLateReply;
|
|
140032
|
-
|
|
140657
|
+
resolve13(this.terminalColorQueryResult(query));
|
|
140033
140658
|
}, timeoutMs);
|
|
140034
140659
|
this.pendingTerminalColorQueries.push(query);
|
|
140035
140660
|
this.terminal.write(TERMINAL_COLOR_QUERY);
|
|
@@ -143051,10 +143676,10 @@ var init_tui_alt_screen = __esm({
|
|
|
143051
143676
|
this.mousePressMoved = true;
|
|
143052
143677
|
this.lastComponentClick = void 0;
|
|
143053
143678
|
}
|
|
143054
|
-
let
|
|
143679
|
+
let render2 = false;
|
|
143055
143680
|
const targetResult = this.dispatchMouseToTarget(event, target);
|
|
143056
143681
|
if (targetResult)
|
|
143057
|
-
|
|
143682
|
+
render2 = this.applyMouseDispatchResult(event, targetResult);
|
|
143058
143683
|
if (raw.release) {
|
|
143059
143684
|
if (!this.mousePressMoved && this.mousePressPoint?.x === raw.x && this.mousePressPoint.y === raw.y) {
|
|
143060
143685
|
const clickEvent = this.createMouseEvent("click", raw.button, raw.x, raw.y, {
|
|
@@ -143062,11 +143687,11 @@ var init_tui_alt_screen = __esm({
|
|
|
143062
143687
|
});
|
|
143063
143688
|
const clickResult = this.dispatchMouseToTarget(clickEvent, target);
|
|
143064
143689
|
if (clickResult)
|
|
143065
|
-
|
|
143690
|
+
render2 = this.applyMouseDispatchResult(clickEvent, clickResult) || render2;
|
|
143066
143691
|
}
|
|
143067
143692
|
this.clearComponentMouseGesture();
|
|
143068
143693
|
}
|
|
143069
|
-
if (
|
|
143694
|
+
if (render2)
|
|
143070
143695
|
this.requestRender();
|
|
143071
143696
|
return;
|
|
143072
143697
|
}
|
|
@@ -143086,14 +143711,14 @@ var init_tui_alt_screen = __esm({
|
|
|
143086
143711
|
}
|
|
143087
143712
|
const result = overlay.result ?? (overlay.hit ? void 0 : this.dispatchMouseToLayout(event));
|
|
143088
143713
|
if (result) {
|
|
143089
|
-
const
|
|
143714
|
+
const render2 = this.applyMouseDispatchResult(event, result);
|
|
143090
143715
|
if (type === "press") {
|
|
143091
143716
|
this.clearTextSelection();
|
|
143092
143717
|
this.mousePressTarget = result.target;
|
|
143093
143718
|
this.mousePressPoint = { x: raw.x, y: raw.y };
|
|
143094
143719
|
this.mousePressMoved = false;
|
|
143095
143720
|
}
|
|
143096
|
-
if (
|
|
143721
|
+
if (render2)
|
|
143097
143722
|
this.requestRender();
|
|
143098
143723
|
return;
|
|
143099
143724
|
}
|
|
@@ -143436,9 +144061,9 @@ var init_tui_alt_screen = __esm({
|
|
|
143436
144061
|
const overlay = this.dispatchMouseToOverlay(clickEvent);
|
|
143437
144062
|
const result = overlay.result ?? (overlay.hit ? void 0 : this.dispatchMouseToLayout(clickEvent));
|
|
143438
144063
|
if (result) {
|
|
143439
|
-
const
|
|
144064
|
+
const render2 = this.applyMouseDispatchResult(clickEvent, result);
|
|
143440
144065
|
this.clearTextSelection();
|
|
143441
|
-
if (
|
|
144066
|
+
if (render2)
|
|
143442
144067
|
this.requestRender();
|
|
143443
144068
|
return;
|
|
143444
144069
|
}
|
|
@@ -144111,7 +144736,7 @@ var require_core = __commonJS({
|
|
|
144111
144736
|
return match3 && match3.index === 0;
|
|
144112
144737
|
}
|
|
144113
144738
|
var BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
144114
|
-
function
|
|
144739
|
+
function join25(regexps, separator = "|") {
|
|
144115
144740
|
let numCaptures = 0;
|
|
144116
144741
|
return regexps.map((regex2) => {
|
|
144117
144742
|
numCaptures += 1;
|
|
@@ -144415,7 +145040,7 @@ var require_core = __commonJS({
|
|
|
144415
145040
|
this.exec = () => null;
|
|
144416
145041
|
}
|
|
144417
145042
|
const terminators = this.regexes.map((el) => el[1]);
|
|
144418
|
-
this.matcherRe = langRe(
|
|
145043
|
+
this.matcherRe = langRe(join25(terminators), true);
|
|
144419
145044
|
this.lastIndex = 0;
|
|
144420
145045
|
}
|
|
144421
145046
|
/** @param {string} s */
|
|
@@ -144710,7 +145335,7 @@ var require_core = __commonJS({
|
|
|
144710
145335
|
function close(node) {
|
|
144711
145336
|
result += "</" + tag(node) + ">";
|
|
144712
145337
|
}
|
|
144713
|
-
function
|
|
145338
|
+
function render2(event) {
|
|
144714
145339
|
(event.event === "start" ? open3 : close)(event.node);
|
|
144715
145340
|
}
|
|
144716
145341
|
while (original.length || highlighted.length) {
|
|
@@ -144720,7 +145345,7 @@ var require_core = __commonJS({
|
|
|
144720
145345
|
if (stream12 === original) {
|
|
144721
145346
|
nodeStack.reverse().forEach(close);
|
|
144722
145347
|
do {
|
|
144723
|
-
|
|
145348
|
+
render2(stream12.splice(0, 1)[0]);
|
|
144724
145349
|
stream12 = selectStream();
|
|
144725
145350
|
} while (stream12 === original && stream12.length && stream12[0].offset === processed);
|
|
144726
145351
|
nodeStack.reverse().forEach(open3);
|
|
@@ -144730,7 +145355,7 @@ var require_core = __commonJS({
|
|
|
144730
145355
|
} else {
|
|
144731
145356
|
nodeStack.pop();
|
|
144732
145357
|
}
|
|
144733
|
-
|
|
145358
|
+
render2(stream12.splice(0, 1)[0]);
|
|
144734
145359
|
}
|
|
144735
145360
|
}
|
|
144736
145361
|
return result + escapeHTML(value2.substr(processed));
|
|
@@ -151743,7 +152368,7 @@ var init_ansi = __esm({
|
|
|
151743
152368
|
});
|
|
151744
152369
|
|
|
151745
152370
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js
|
|
151746
|
-
import { existsSync as
|
|
152371
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
151747
152372
|
import { spawn as spawn2, spawnSync } from "child_process";
|
|
151748
152373
|
function isLegacyWslBashPath(path8) {
|
|
151749
152374
|
const normalized = path8.replace(/\//g, "\\").toLowerCase();
|
|
@@ -151762,7 +152387,7 @@ function findExecutableOnPath(executable) {
|
|
|
151762
152387
|
});
|
|
151763
152388
|
if (result.status === 0 && result.stdout) {
|
|
151764
152389
|
const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
|
|
151765
|
-
if (firstMatch &&
|
|
152390
|
+
if (firstMatch && existsSync2(firstMatch)) {
|
|
151766
152391
|
return firstMatch;
|
|
151767
152392
|
}
|
|
151768
152393
|
}
|
|
@@ -151784,7 +152409,7 @@ function findExecutableOnPath(executable) {
|
|
|
151784
152409
|
}
|
|
151785
152410
|
function getShellConfig(customShellPath) {
|
|
151786
152411
|
if (customShellPath) {
|
|
151787
|
-
if (
|
|
152412
|
+
if (existsSync2(customShellPath)) {
|
|
151788
152413
|
return getBashShellConfig(customShellPath);
|
|
151789
152414
|
}
|
|
151790
152415
|
throw new Error(`Custom shell path not found: ${customShellPath}`);
|
|
@@ -151800,7 +152425,7 @@ function getShellConfig(customShellPath) {
|
|
|
151800
152425
|
paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
|
|
151801
152426
|
}
|
|
151802
152427
|
for (const path8 of paths) {
|
|
151803
|
-
if (
|
|
152428
|
+
if (existsSync2(path8)) {
|
|
151804
152429
|
return getBashShellConfig(path8);
|
|
151805
152430
|
}
|
|
151806
152431
|
}
|
|
@@ -151816,7 +152441,7 @@ function getShellConfig(customShellPath) {
|
|
|
151816
152441
|
Searched Git Bash in:
|
|
151817
152442
|
${paths.map((p) => ` ${p}`).join("\n")}`);
|
|
151818
152443
|
}
|
|
151819
|
-
if (
|
|
152444
|
+
if (existsSync2("/bin/bash")) {
|
|
151820
152445
|
return getBashShellConfig("/bin/bash");
|
|
151821
152446
|
}
|
|
151822
152447
|
const bashOnPath = findExecutableOnPath("bash");
|
|
@@ -152084,16 +152709,16 @@ function isLoopbackRedirectUri(value2) {
|
|
|
152084
152709
|
const url = new URL(value2);
|
|
152085
152710
|
return url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === "" && url.hash === "";
|
|
152086
152711
|
}
|
|
152087
|
-
function
|
|
152712
|
+
function isRecord4(value2) {
|
|
152088
152713
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
152089
152714
|
}
|
|
152090
152715
|
function isStringRecord(value2) {
|
|
152091
|
-
return
|
|
152716
|
+
return isRecord4(value2) && Object.values(value2).every((entry) => typeof entry === "string");
|
|
152092
152717
|
}
|
|
152093
152718
|
function validateOAuth(value2) {
|
|
152094
152719
|
if (value2 === void 0)
|
|
152095
152720
|
return void 0;
|
|
152096
|
-
if (!
|
|
152721
|
+
if (!isRecord4(value2))
|
|
152097
152722
|
return "oauth must be an object";
|
|
152098
152723
|
if (value2.clientId !== void 0 && typeof value2.clientId !== "string")
|
|
152099
152724
|
return "oauth.clientId must be a string";
|
|
@@ -152138,7 +152763,7 @@ function getMcpToolExposure(config, toolName2) {
|
|
|
152138
152763
|
function validateMcpServerConfig(name, value2) {
|
|
152139
152764
|
if (!SERVER_NAME.test(name))
|
|
152140
152765
|
return `invalid server name "${name}" (use letters, digits, "_" and "-")`;
|
|
152141
|
-
if (!
|
|
152766
|
+
if (!isRecord4(value2))
|
|
152142
152767
|
return `server "${name}" must be an object`;
|
|
152143
152768
|
const { type, exposure, enabled, timeout, toolExposure } = value2;
|
|
152144
152769
|
const exposures = MCP_EXPOSURES.map((value3) => `"${value3}"`).join(", ");
|
|
@@ -152146,7 +152771,7 @@ function validateMcpServerConfig(name, value2) {
|
|
|
152146
152771
|
return `server "${name}": exposure must be one of ${exposures}`;
|
|
152147
152772
|
}
|
|
152148
152773
|
if (toolExposure !== void 0) {
|
|
152149
|
-
if (!
|
|
152774
|
+
if (!isRecord4(toolExposure))
|
|
152150
152775
|
return `server "${name}": toolExposure must map tool names to exposures`;
|
|
152151
152776
|
for (const [tool, value3] of Object.entries(toolExposure)) {
|
|
152152
152777
|
if (!isExposure(value3))
|
|
@@ -154508,12 +155133,12 @@ var require_adapter = __commonJS({
|
|
|
154508
155133
|
return newFs;
|
|
154509
155134
|
}
|
|
154510
155135
|
function toPromise(method) {
|
|
154511
|
-
return (...args) => new Promise((
|
|
155136
|
+
return (...args) => new Promise((resolve13, reject) => {
|
|
154512
155137
|
args.push((err2, result) => {
|
|
154513
155138
|
if (err2) {
|
|
154514
155139
|
reject(err2);
|
|
154515
155140
|
} else {
|
|
154516
|
-
|
|
155141
|
+
resolve13(result);
|
|
154517
155142
|
}
|
|
154518
155143
|
});
|
|
154519
155144
|
method(...args);
|
|
@@ -154602,7 +155227,7 @@ function raceWithAbortSignal2(operation, signal) {
|
|
|
154602
155227
|
});
|
|
154603
155228
|
return Promise.reject(abortReason2(signal));
|
|
154604
155229
|
}
|
|
154605
|
-
return new Promise((
|
|
155230
|
+
return new Promise((resolve13, reject) => {
|
|
154606
155231
|
let settled = false;
|
|
154607
155232
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
154608
155233
|
const onAbort = () => {
|
|
@@ -154618,7 +155243,7 @@ function raceWithAbortSignal2(operation, signal) {
|
|
|
154618
155243
|
return;
|
|
154619
155244
|
settled = true;
|
|
154620
155245
|
cleanup();
|
|
154621
|
-
|
|
155246
|
+
resolve13(value2);
|
|
154622
155247
|
}, (error) => {
|
|
154623
155248
|
if (settled)
|
|
154624
155249
|
return;
|
|
@@ -154636,8 +155261,8 @@ var init_abort4 = __esm({
|
|
|
154636
155261
|
});
|
|
154637
155262
|
|
|
154638
155263
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js
|
|
154639
|
-
import { existsSync as
|
|
154640
|
-
import { dirname as
|
|
155264
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
155265
|
+
import { dirname as dirname10, join as join12 } from "path";
|
|
154641
155266
|
import { setTimeout as sleep6 } from "timers/promises";
|
|
154642
155267
|
var import_proper_lockfile, AUTH_FILE_WRITE_OPTIONS, FileAuthStorageBackend;
|
|
154643
155268
|
var init_auth_storage = __esm({
|
|
@@ -154651,18 +155276,18 @@ var init_auth_storage = __esm({
|
|
|
154651
155276
|
AUTH_FILE_WRITE_OPTIONS = { encoding: "utf-8", mode: 384 };
|
|
154652
155277
|
FileAuthStorageBackend = class {
|
|
154653
155278
|
authPath;
|
|
154654
|
-
constructor(authPath =
|
|
155279
|
+
constructor(authPath = join12(getAgentDir(), "auth.json")) {
|
|
154655
155280
|
this.authPath = normalizePath(authPath);
|
|
154656
155281
|
}
|
|
154657
155282
|
ensureParentDir() {
|
|
154658
|
-
const dir =
|
|
154659
|
-
if (!
|
|
155283
|
+
const dir = dirname10(this.authPath);
|
|
155284
|
+
if (!existsSync3(dir)) {
|
|
154660
155285
|
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
154661
155286
|
}
|
|
154662
155287
|
}
|
|
154663
155288
|
ensureFileExists() {
|
|
154664
|
-
if (!
|
|
154665
|
-
|
|
155289
|
+
if (!existsSync3(this.authPath)) {
|
|
155290
|
+
writeFileSync2(this.authPath, "{}", AUTH_FILE_WRITE_OPTIONS);
|
|
154666
155291
|
}
|
|
154667
155292
|
}
|
|
154668
155293
|
acquireLockSyncWithRetry(path8) {
|
|
@@ -154691,10 +155316,10 @@ var init_auth_storage = __esm({
|
|
|
154691
155316
|
let release;
|
|
154692
155317
|
try {
|
|
154693
155318
|
release = this.acquireLockSyncWithRetry(this.authPath);
|
|
154694
|
-
const current =
|
|
155319
|
+
const current = existsSync3(this.authPath) ? readFileSync3(this.authPath, "utf-8") : void 0;
|
|
154695
155320
|
const { result, next } = fn(current);
|
|
154696
155321
|
if (next !== void 0) {
|
|
154697
|
-
|
|
155322
|
+
writeFileSync2(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);
|
|
154698
155323
|
}
|
|
154699
155324
|
return result;
|
|
154700
155325
|
} finally {
|
|
@@ -154759,12 +155384,12 @@ var init_auth_storage = __esm({
|
|
|
154759
155384
|
});
|
|
154760
155385
|
throwIfCompromised();
|
|
154761
155386
|
options?.signal?.throwIfAborted();
|
|
154762
|
-
const current =
|
|
155387
|
+
const current = existsSync3(this.authPath) ? readFileSync3(this.authPath, "utf-8") : void 0;
|
|
154763
155388
|
const { result, next } = await fn(current);
|
|
154764
155389
|
throwIfCompromised();
|
|
154765
155390
|
options?.signal?.throwIfAborted();
|
|
154766
155391
|
if (next !== void 0) {
|
|
154767
|
-
|
|
155392
|
+
writeFileSync2(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);
|
|
154768
155393
|
}
|
|
154769
155394
|
throwIfCompromised();
|
|
154770
155395
|
return result;
|
|
@@ -162759,9 +163384,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
162759
163384
|
}
|
|
162760
163385
|
close(callback) {
|
|
162761
163386
|
if (callback === void 0) {
|
|
162762
|
-
return new Promise((
|
|
163387
|
+
return new Promise((resolve13, reject) => {
|
|
162763
163388
|
this.close((err2, data) => {
|
|
162764
|
-
return err2 ? reject(err2) :
|
|
163389
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
162765
163390
|
});
|
|
162766
163391
|
});
|
|
162767
163392
|
}
|
|
@@ -162799,9 +163424,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
162799
163424
|
err2 = null;
|
|
162800
163425
|
}
|
|
162801
163426
|
if (callback === void 0) {
|
|
162802
|
-
return new Promise((
|
|
163427
|
+
return new Promise((resolve13, reject) => {
|
|
162803
163428
|
this.destroy(err2, (err3, data) => {
|
|
162804
|
-
return err3 ? reject(err3) :
|
|
163429
|
+
return err3 ? reject(err3) : resolve13(data);
|
|
162805
163430
|
});
|
|
162806
163431
|
});
|
|
162807
163432
|
}
|
|
@@ -167758,12 +168383,12 @@ upgrade: ${upgrade}\r
|
|
|
167758
168383
|
cb();
|
|
167759
168384
|
}
|
|
167760
168385
|
}
|
|
167761
|
-
const waitForDrain = () => new Promise((
|
|
168386
|
+
const waitForDrain = () => new Promise((resolve13, reject) => {
|
|
167762
168387
|
assert(callback === null);
|
|
167763
168388
|
if (socket[kError]) {
|
|
167764
168389
|
reject(socket[kError]);
|
|
167765
168390
|
} else {
|
|
167766
|
-
callback =
|
|
168391
|
+
callback = resolve13;
|
|
167767
168392
|
}
|
|
167768
168393
|
});
|
|
167769
168394
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -169146,12 +169771,12 @@ var require_client_h2 = __commonJS({
|
|
|
169146
169771
|
cb();
|
|
169147
169772
|
}
|
|
169148
169773
|
}
|
|
169149
|
-
const waitForDrain = () => new Promise((
|
|
169774
|
+
const waitForDrain = () => new Promise((resolve13, reject) => {
|
|
169150
169775
|
assert(callback === null);
|
|
169151
169776
|
if (socket[kError]) {
|
|
169152
169777
|
reject(socket[kError]);
|
|
169153
169778
|
} else {
|
|
169154
|
-
callback =
|
|
169779
|
+
callback = resolve13;
|
|
169155
169780
|
}
|
|
169156
169781
|
});
|
|
169157
169782
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -169520,16 +170145,16 @@ var require_client = __commonJS({
|
|
|
169520
170145
|
return this[kNeedDrain] < 2;
|
|
169521
170146
|
}
|
|
169522
170147
|
[kClose]() {
|
|
169523
|
-
return new Promise((
|
|
170148
|
+
return new Promise((resolve13) => {
|
|
169524
170149
|
if (this[kSize]) {
|
|
169525
|
-
this[kClosedResolve] =
|
|
170150
|
+
this[kClosedResolve] = resolve13;
|
|
169526
170151
|
} else {
|
|
169527
|
-
|
|
170152
|
+
resolve13(null);
|
|
169528
170153
|
}
|
|
169529
170154
|
});
|
|
169530
170155
|
}
|
|
169531
170156
|
[kDestroy](err2) {
|
|
169532
|
-
return new Promise((
|
|
170157
|
+
return new Promise((resolve13) => {
|
|
169533
170158
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
169534
170159
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
169535
170160
|
const request = requests[i2];
|
|
@@ -169542,7 +170167,7 @@ var require_client = __commonJS({
|
|
|
169542
170167
|
this[kClosedResolve]();
|
|
169543
170168
|
this[kClosedResolve] = null;
|
|
169544
170169
|
}
|
|
169545
|
-
|
|
170170
|
+
resolve13(null);
|
|
169546
170171
|
};
|
|
169547
170172
|
if (this[kHTTPContext]) {
|
|
169548
170173
|
this[kHTTPContext].destroy(err2, callback);
|
|
@@ -169955,8 +170580,8 @@ var require_pool_base = __commonJS({
|
|
|
169955
170580
|
}
|
|
169956
170581
|
return Promise.all(closeAll);
|
|
169957
170582
|
} else {
|
|
169958
|
-
return new Promise((
|
|
169959
|
-
this[kClosedResolve] =
|
|
170583
|
+
return new Promise((resolve13) => {
|
|
170584
|
+
this[kClosedResolve] = resolve13;
|
|
169960
170585
|
});
|
|
169961
170586
|
}
|
|
169962
170587
|
}
|
|
@@ -172619,7 +173244,7 @@ var require_readable = __commonJS({
|
|
|
172619
173244
|
if (this._readableState.closeEmitted) {
|
|
172620
173245
|
return Promise.resolve(null);
|
|
172621
173246
|
}
|
|
172622
|
-
return new Promise((
|
|
173247
|
+
return new Promise((resolve13, reject) => {
|
|
172623
173248
|
if (this[kContentLength] && this[kContentLength] > limit3 || this[kBytesRead] > limit3) {
|
|
172624
173249
|
this.destroy(new AbortError2());
|
|
172625
173250
|
}
|
|
@@ -172633,11 +173258,11 @@ var require_readable = __commonJS({
|
|
|
172633
173258
|
if (signal.aborted) {
|
|
172634
173259
|
reject(signal.reason ?? new AbortError2());
|
|
172635
173260
|
} else {
|
|
172636
|
-
|
|
173261
|
+
resolve13(null);
|
|
172637
173262
|
}
|
|
172638
173263
|
});
|
|
172639
173264
|
} else {
|
|
172640
|
-
this.on("close",
|
|
173265
|
+
this.on("close", resolve13);
|
|
172641
173266
|
}
|
|
172642
173267
|
this.on("error", noop4).on("data", () => {
|
|
172643
173268
|
if (this[kBytesRead] > limit3) {
|
|
@@ -172665,7 +173290,7 @@ var require_readable = __commonJS({
|
|
|
172665
173290
|
}
|
|
172666
173291
|
function consume(stream12, type) {
|
|
172667
173292
|
assert(!stream12[kConsume]);
|
|
172668
|
-
return new Promise((
|
|
173293
|
+
return new Promise((resolve13, reject) => {
|
|
172669
173294
|
if (isUnusable(stream12)) {
|
|
172670
173295
|
const rState = stream12._readableState;
|
|
172671
173296
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -172680,7 +173305,7 @@ var require_readable = __commonJS({
|
|
|
172680
173305
|
stream12[kConsume] = {
|
|
172681
173306
|
type,
|
|
172682
173307
|
stream: stream12,
|
|
172683
|
-
resolve:
|
|
173308
|
+
resolve: resolve13,
|
|
172684
173309
|
reject,
|
|
172685
173310
|
length: 0,
|
|
172686
173311
|
body: []
|
|
@@ -172758,18 +173383,18 @@ var require_readable = __commonJS({
|
|
|
172758
173383
|
return buffer;
|
|
172759
173384
|
}
|
|
172760
173385
|
function consumeEnd(consume2, encoding) {
|
|
172761
|
-
const { type, body, resolve:
|
|
173386
|
+
const { type, body, resolve: resolve13, stream: stream12, length } = consume2;
|
|
172762
173387
|
try {
|
|
172763
173388
|
if (type === "text") {
|
|
172764
|
-
|
|
173389
|
+
resolve13(chunksDecode(body, length, encoding));
|
|
172765
173390
|
} else if (type === "json") {
|
|
172766
|
-
|
|
173391
|
+
resolve13(JSON.parse(chunksDecode(body, length, encoding)));
|
|
172767
173392
|
} else if (type === "arrayBuffer") {
|
|
172768
|
-
|
|
173393
|
+
resolve13(chunksConcat(body, length).buffer);
|
|
172769
173394
|
} else if (type === "blob") {
|
|
172770
|
-
|
|
173395
|
+
resolve13(new Blob(body, { type: stream12[kContentType] }));
|
|
172771
173396
|
} else if (type === "bytes") {
|
|
172772
|
-
|
|
173397
|
+
resolve13(chunksConcat(body, length));
|
|
172773
173398
|
}
|
|
172774
173399
|
consumeFinish(consume2);
|
|
172775
173400
|
} catch (err2) {
|
|
@@ -172988,9 +173613,9 @@ var require_api_request = __commonJS({
|
|
|
172988
173613
|
};
|
|
172989
173614
|
function request(opts, callback) {
|
|
172990
173615
|
if (callback === void 0) {
|
|
172991
|
-
return new Promise((
|
|
173616
|
+
return new Promise((resolve13, reject) => {
|
|
172992
173617
|
request.call(this, opts, (err2, data) => {
|
|
172993
|
-
return err2 ? reject(err2) :
|
|
173618
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
172994
173619
|
});
|
|
172995
173620
|
});
|
|
172996
173621
|
}
|
|
@@ -173251,9 +173876,9 @@ var require_api_stream = __commonJS({
|
|
|
173251
173876
|
};
|
|
173252
173877
|
function stream12(opts, factory, callback) {
|
|
173253
173878
|
if (callback === void 0) {
|
|
173254
|
-
return new Promise((
|
|
173879
|
+
return new Promise((resolve13, reject) => {
|
|
173255
173880
|
stream12.call(this, opts, factory, (err2, data) => {
|
|
173256
|
-
return err2 ? reject(err2) :
|
|
173881
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173257
173882
|
});
|
|
173258
173883
|
});
|
|
173259
173884
|
}
|
|
@@ -173553,9 +174178,9 @@ var require_api_upgrade = __commonJS({
|
|
|
173553
174178
|
};
|
|
173554
174179
|
function upgrade(opts, callback) {
|
|
173555
174180
|
if (callback === void 0) {
|
|
173556
|
-
return new Promise((
|
|
174181
|
+
return new Promise((resolve13, reject) => {
|
|
173557
174182
|
upgrade.call(this, opts, (err2, data) => {
|
|
173558
|
-
return err2 ? reject(err2) :
|
|
174183
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173559
174184
|
});
|
|
173560
174185
|
});
|
|
173561
174186
|
}
|
|
@@ -173649,9 +174274,9 @@ var require_api_connect = __commonJS({
|
|
|
173649
174274
|
};
|
|
173650
174275
|
function connect(opts, callback) {
|
|
173651
174276
|
if (callback === void 0) {
|
|
173652
|
-
return new Promise((
|
|
174277
|
+
return new Promise((resolve13, reject) => {
|
|
173653
174278
|
connect.call(this, opts, (err2, data) => {
|
|
173654
|
-
return err2 ? reject(err2) :
|
|
174279
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173655
174280
|
});
|
|
173656
174281
|
});
|
|
173657
174282
|
}
|
|
@@ -175118,7 +175743,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
175118
175743
|
"node_modules/.pnpm/undici@8.10.2/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
175119
175744
|
"use strict";
|
|
175120
175745
|
var { writeFile: writeFile10, readFile: readFile10, mkdir: mkdir7 } = __require("node:fs/promises");
|
|
175121
|
-
var { dirname:
|
|
175746
|
+
var { dirname: dirname18, resolve: resolve13 } = __require("node:path");
|
|
175122
175747
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
175123
175748
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
175124
175749
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -175334,7 +175959,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
175334
175959
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
175335
175960
|
}
|
|
175336
175961
|
try {
|
|
175337
|
-
const data = await readFile10(
|
|
175962
|
+
const data = await readFile10(resolve13(path8), "utf8");
|
|
175338
175963
|
const parsed2 = JSON.parse(data);
|
|
175339
175964
|
if (Array.isArray(parsed2)) {
|
|
175340
175965
|
this.#snapshots.clear();
|
|
@@ -175363,8 +175988,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
175363
175988
|
if (!path8) {
|
|
175364
175989
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
175365
175990
|
}
|
|
175366
|
-
const resolvedPath =
|
|
175367
|
-
await mkdir7(
|
|
175991
|
+
const resolvedPath = resolve13(path8);
|
|
175992
|
+
await mkdir7(dirname18(resolvedPath), { recursive: true });
|
|
175368
175993
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
175369
175994
|
hash,
|
|
175370
175995
|
snapshot
|
|
@@ -183027,7 +183652,7 @@ var require_fetch = __commonJS({
|
|
|
183027
183652
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
183028
183653
|
return dispatchWithProtocolPreference(body);
|
|
183029
183654
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
183030
|
-
return new Promise((
|
|
183655
|
+
return new Promise((resolve13, reject) => agent.dispatch(
|
|
183031
183656
|
{
|
|
183032
183657
|
path: hasTrailingQuestionMark ? `${path8}?` : path8,
|
|
183033
183658
|
origin: url.origin,
|
|
@@ -183110,7 +183735,7 @@ var require_fetch = __commonJS({
|
|
|
183110
183735
|
}
|
|
183111
183736
|
}
|
|
183112
183737
|
const onError = (err2) => this.onResponseError(controller, err2);
|
|
183113
|
-
|
|
183738
|
+
resolve13({
|
|
183114
183739
|
status,
|
|
183115
183740
|
statusText,
|
|
183116
183741
|
headersList,
|
|
@@ -183143,7 +183768,7 @@ var require_fetch = __commonJS({
|
|
|
183143
183768
|
fetchParams.controller.off("terminated", this.abort);
|
|
183144
183769
|
}
|
|
183145
183770
|
if (request.mode === "websocket" && allowH2 !== false && error?.code === "UND_ERR_INFO" && error?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
183146
|
-
|
|
183771
|
+
resolve13(dispatchWithProtocolPreference(body2, false));
|
|
183147
183772
|
return;
|
|
183148
183773
|
}
|
|
183149
183774
|
this.body?.destroy(error);
|
|
@@ -183160,7 +183785,7 @@ var require_fetch = __commonJS({
|
|
|
183160
183785
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
183161
183786
|
const headersList = new HeadersList();
|
|
183162
183787
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
183163
|
-
|
|
183788
|
+
resolve13({
|
|
183164
183789
|
status,
|
|
183165
183790
|
statusText: STATUS_CODES[status],
|
|
183166
183791
|
headersList,
|
|
@@ -188088,8 +188713,8 @@ var init_host = __esm({
|
|
|
188088
188713
|
pending = /* @__PURE__ */ new Map();
|
|
188089
188714
|
finished = false;
|
|
188090
188715
|
constructor(options) {
|
|
188091
|
-
this.promise = new Promise((
|
|
188092
|
-
this.resolveResult =
|
|
188716
|
+
this.promise = new Promise((resolve13) => {
|
|
188717
|
+
this.resolveResult = resolve13;
|
|
188093
188718
|
});
|
|
188094
188719
|
this.tools = options.tools;
|
|
188095
188720
|
this.globals = options.globals;
|
|
@@ -188828,7 +189453,7 @@ __export(execute_exports, {
|
|
|
188828
189453
|
import { randomBytes } from "node:crypto";
|
|
188829
189454
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
188830
189455
|
import { tmpdir } from "node:os";
|
|
188831
|
-
import { join as
|
|
189456
|
+
import { join as join13 } from "node:path";
|
|
188832
189457
|
function truncateText(text, maxChars) {
|
|
188833
189458
|
return text.length > maxChars ? `${text.slice(0, maxChars - 3)}...` : text;
|
|
188834
189459
|
}
|
|
@@ -188866,7 +189491,7 @@ function createLimiter(limit3) {
|
|
|
188866
189491
|
const waiting = [];
|
|
188867
189492
|
return async (run) => {
|
|
188868
189493
|
if (active >= limit3)
|
|
188869
|
-
await new Promise((
|
|
189494
|
+
await new Promise((resolve13) => waiting.push(resolve13));
|
|
188870
189495
|
active++;
|
|
188871
189496
|
try {
|
|
188872
189497
|
return await run();
|
|
@@ -188913,7 +189538,7 @@ function formatError(result, calls) {
|
|
|
188913
189538
|
${formatCallSummary(calls)}`;
|
|
188914
189539
|
}
|
|
188915
189540
|
async function spillOutput(text) {
|
|
188916
|
-
const path8 =
|
|
189541
|
+
const path8 = join13(tmpdir(), `pi-codemode-${randomBytes(8).toString("hex")}.txt`);
|
|
188917
189542
|
try {
|
|
188918
189543
|
await writeFile4(path8, text);
|
|
188919
189544
|
return { path: path8 };
|
|
@@ -189589,23 +190214,23 @@ var init_open_browser = __esm({
|
|
|
189589
190214
|
});
|
|
189590
190215
|
|
|
189591
190216
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/config.js
|
|
189592
|
-
import { existsSync as
|
|
189593
|
-
import { dirname as
|
|
189594
|
-
function
|
|
190217
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
190218
|
+
import { dirname as dirname11, join as join14 } from "node:path";
|
|
190219
|
+
function isRecord5(value2) {
|
|
189595
190220
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
189596
190221
|
}
|
|
189597
190222
|
function readConfigFile(path8, scope, state3) {
|
|
189598
190223
|
const { servers, errors } = state3;
|
|
189599
|
-
if (!
|
|
190224
|
+
if (!existsSync4(path8))
|
|
189600
190225
|
return;
|
|
189601
190226
|
let parsed2;
|
|
189602
190227
|
try {
|
|
189603
|
-
parsed2 = JSON.parse(
|
|
190228
|
+
parsed2 = JSON.parse(readFileSync4(path8, "utf8"));
|
|
189604
190229
|
} catch (error) {
|
|
189605
190230
|
errors.push(`${path8}: ${error instanceof Error ? error.message : String(error)}`);
|
|
189606
190231
|
return;
|
|
189607
190232
|
}
|
|
189608
|
-
if (!
|
|
190233
|
+
if (!isRecord5(parsed2) || parsed2.mcpServers !== void 0 && !isRecord5(parsed2.mcpServers)) {
|
|
189609
190234
|
errors.push(`${path8}: expected an object with an "mcpServers" object`);
|
|
189610
190235
|
return;
|
|
189611
190236
|
}
|
|
@@ -189624,9 +190249,9 @@ function readConfigFile(path8, scope, state3) {
|
|
|
189624
190249
|
}
|
|
189625
190250
|
function loadMcpConfig(options) {
|
|
189626
190251
|
const state3 = { servers: /* @__PURE__ */ new Map(), errors: [] };
|
|
189627
|
-
readConfigFile(
|
|
190252
|
+
readConfigFile(join14(options.agentDir, "mcp.json"), "global", state3);
|
|
189628
190253
|
if (options.projectTrusted)
|
|
189629
|
-
readConfigFile(
|
|
190254
|
+
readConfigFile(join14(options.cwd, CONFIG_DIR_NAME, "mcp.json"), "project", state3);
|
|
189630
190255
|
return {
|
|
189631
190256
|
servers: [...state3.servers.values()],
|
|
189632
190257
|
...state3.autoEnableCodemode === void 0 ? {} : { autoEnableCodemode: state3.autoEnableCodemode },
|
|
@@ -189636,7 +190261,7 @@ function loadMcpConfig(options) {
|
|
|
189636
190261
|
function updateMcpServerConfig(path8, name, patch) {
|
|
189637
190262
|
editMcpServers(path8, (servers) => {
|
|
189638
190263
|
const server = servers?.[name];
|
|
189639
|
-
if (!
|
|
190264
|
+
if (!isRecord5(server))
|
|
189640
190265
|
throw new Error(`${path8} does not define MCP server "${name}"`);
|
|
189641
190266
|
if (patch.enabled !== void 0) {
|
|
189642
190267
|
if (patch.enabled)
|
|
@@ -189654,17 +190279,17 @@ function updateMcpServerConfig(path8, name, patch) {
|
|
|
189654
190279
|
});
|
|
189655
190280
|
}
|
|
189656
190281
|
function editMcpServers(path8, edit) {
|
|
189657
|
-
const text =
|
|
190282
|
+
const text = existsSync4(path8) ? readFileSync4(path8, "utf8") : void 0;
|
|
189658
190283
|
const parsed2 = text === void 0 ? {} : JSON.parse(text);
|
|
189659
|
-
if (!
|
|
190284
|
+
if (!isRecord5(parsed2) || parsed2.mcpServers !== void 0 && !isRecord5(parsed2.mcpServers)) {
|
|
189660
190285
|
throw new Error(`${path8}: expected an object with an "mcpServers" object`);
|
|
189661
190286
|
}
|
|
189662
|
-
const servers =
|
|
190287
|
+
const servers = isRecord5(parsed2.mcpServers) ? parsed2.mcpServers : void 0;
|
|
189663
190288
|
if (!edit(servers, parsed2))
|
|
189664
190289
|
return;
|
|
189665
190290
|
const indent = text && /^([ \t]+)\S/m.exec(text)?.[1] || " ";
|
|
189666
|
-
mkdirSync3(
|
|
189667
|
-
|
|
190291
|
+
mkdirSync3(dirname11(path8), { recursive: true });
|
|
190292
|
+
writeFileSync3(path8, `${JSON.stringify(parsed2, null, indent)}
|
|
189668
190293
|
`);
|
|
189669
190294
|
}
|
|
189670
190295
|
var init_config6 = __esm({
|
|
@@ -190005,9 +190630,9 @@ var init_client3 = __esm({
|
|
|
190005
190630
|
method,
|
|
190006
190631
|
...requestParams === void 0 ? {} : { params: requestParams }
|
|
190007
190632
|
};
|
|
190008
|
-
return new Promise((
|
|
190633
|
+
return new Promise((resolve13, reject) => {
|
|
190009
190634
|
const entry = {
|
|
190010
|
-
resolve:
|
|
190635
|
+
resolve: resolve13,
|
|
190011
190636
|
reject,
|
|
190012
190637
|
timeoutMs: options.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
190013
190638
|
timer: void 0,
|
|
@@ -190379,10 +191004,10 @@ var init_stdio = __esm({
|
|
|
190379
191004
|
this.stdoutBuffer = Buffer.alloc(0);
|
|
190380
191005
|
this.emitClose();
|
|
190381
191006
|
});
|
|
190382
|
-
await new Promise((
|
|
191007
|
+
await new Promise((resolve13, reject) => {
|
|
190383
191008
|
const onSpawn = () => {
|
|
190384
191009
|
child.off("error", onError);
|
|
190385
|
-
|
|
191010
|
+
resolve13();
|
|
190386
191011
|
};
|
|
190387
191012
|
const onError = (error) => {
|
|
190388
191013
|
child.off("spawn", onSpawn);
|
|
@@ -190402,8 +191027,8 @@ var init_stdio = __esm({
|
|
|
190402
191027
|
throw new McpConnectionClosedError();
|
|
190403
191028
|
const payload = `${JSON.stringify(message)}
|
|
190404
191029
|
`;
|
|
190405
|
-
await new Promise((
|
|
190406
|
-
stdin.write(payload, (error) => error ? reject(error) :
|
|
191030
|
+
await new Promise((resolve13, reject) => {
|
|
191031
|
+
stdin.write(payload, (error) => error ? reject(error) : resolve13());
|
|
190407
191032
|
});
|
|
190408
191033
|
}
|
|
190409
191034
|
async close() {
|
|
@@ -190420,13 +191045,13 @@ var init_stdio = __esm({
|
|
|
190420
191045
|
return;
|
|
190421
191046
|
}
|
|
190422
191047
|
const closeTimeoutMs = this.options.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
|
|
190423
|
-
await new Promise((
|
|
191048
|
+
await new Promise((resolve13) => {
|
|
190424
191049
|
const timers = [];
|
|
190425
191050
|
child.once("close", () => {
|
|
190426
191051
|
for (const timer of timers)
|
|
190427
191052
|
clearTimeout(timer);
|
|
190428
191053
|
killProcessTree2(child, "SIGTERM");
|
|
190429
|
-
|
|
191054
|
+
resolve13();
|
|
190430
191055
|
});
|
|
190431
191056
|
const grace = Math.min(STDIN_CLOSE_GRACE_MS, closeTimeoutMs);
|
|
190432
191057
|
timers.push(setTimeout(() => killProcessTree2(child, "SIGTERM"), grace));
|
|
@@ -190894,14 +191519,14 @@ var init_streamable_http = __esm({
|
|
|
190894
191519
|
const signal = this.controller.signal;
|
|
190895
191520
|
if (signal.aborted)
|
|
190896
191521
|
return Promise.resolve(false);
|
|
190897
|
-
return new Promise((
|
|
191522
|
+
return new Promise((resolve13) => {
|
|
190898
191523
|
const onAbort = () => {
|
|
190899
191524
|
clearTimeout(timer);
|
|
190900
|
-
|
|
191525
|
+
resolve13(false);
|
|
190901
191526
|
};
|
|
190902
191527
|
const timer = setTimeout(() => {
|
|
190903
191528
|
signal.removeEventListener("abort", onAbort);
|
|
190904
|
-
|
|
191529
|
+
resolve13(true);
|
|
190905
191530
|
}, ms);
|
|
190906
191531
|
timer.unref?.();
|
|
190907
191532
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
@@ -190926,12 +191551,12 @@ var init_dist7 = __esm({
|
|
|
190926
191551
|
import { createHash as createHash2, randomBytes as randomBytes2 } from "node:crypto";
|
|
190927
191552
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
190928
191553
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
190929
|
-
import { join as
|
|
191554
|
+
import { join as join15 } from "node:path";
|
|
190930
191555
|
function toToolExposure(exposure) {
|
|
190931
191556
|
return exposure === "codemode-deferred" ? "deferred" : exposure;
|
|
190932
191557
|
}
|
|
190933
191558
|
async function saveToTempFile(data, extension2) {
|
|
190934
|
-
const path8 =
|
|
191559
|
+
const path8 = join15(tmpdir2(), `pi-mcp-${randomBytes2(8).toString("hex")}${extension2}`);
|
|
190935
191560
|
await writeFile5(path8, data, { mode: 384 });
|
|
190936
191561
|
return path8;
|
|
190937
191562
|
}
|
|
@@ -191399,11 +192024,11 @@ var init_callback3 = __esm({
|
|
|
191399
192024
|
const path8 = options.path ?? "/callback";
|
|
191400
192025
|
let instance;
|
|
191401
192026
|
const server = createServer((request, response) => instance?.handle(request.url ?? "/", response));
|
|
191402
|
-
await new Promise((
|
|
192027
|
+
await new Promise((resolve13, reject) => {
|
|
191403
192028
|
server.once("error", reject);
|
|
191404
192029
|
server.listen(options.port ?? 0, host, () => {
|
|
191405
192030
|
server.off("error", reject);
|
|
191406
|
-
|
|
192031
|
+
resolve13();
|
|
191407
192032
|
});
|
|
191408
192033
|
});
|
|
191409
192034
|
const address = server.address();
|
|
@@ -191415,12 +192040,12 @@ var init_callback3 = __esm({
|
|
|
191415
192040
|
waitForCallback(state3) {
|
|
191416
192041
|
if (this.pending.has(state3))
|
|
191417
192042
|
throw new Error("OAuth state is already pending");
|
|
191418
|
-
return new Promise((
|
|
192043
|
+
return new Promise((resolve13, reject) => {
|
|
191419
192044
|
const timer = setTimeout(() => {
|
|
191420
192045
|
this.pending.delete(state3);
|
|
191421
192046
|
reject(new Error("OAuth callback timed out"));
|
|
191422
192047
|
}, this.timeoutMs);
|
|
191423
|
-
this.pending.set(state3, { resolve:
|
|
192048
|
+
this.pending.set(state3, { resolve: resolve13, reject, timer });
|
|
191424
192049
|
});
|
|
191425
192050
|
}
|
|
191426
192051
|
async close() {
|
|
@@ -191429,8 +192054,8 @@ var init_callback3 = __esm({
|
|
|
191429
192054
|
pending.reject(new Error("OAuth callback server closed"));
|
|
191430
192055
|
}
|
|
191431
192056
|
this.pending.clear();
|
|
191432
|
-
await new Promise((
|
|
191433
|
-
this.server.close((error) => error ? reject(error) :
|
|
192057
|
+
await new Promise((resolve13, reject) => {
|
|
192058
|
+
this.server.close((error) => error ? reject(error) : resolve13());
|
|
191434
192059
|
});
|
|
191435
192060
|
}
|
|
191436
192061
|
reply(response, status, page) {
|
|
@@ -192231,7 +192856,7 @@ var init_oauth_page = __esm({
|
|
|
192231
192856
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/oauth.js
|
|
192232
192857
|
import { createHash as createHash3 } from "node:crypto";
|
|
192233
192858
|
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
192234
|
-
import { join as
|
|
192859
|
+
import { join as join16 } from "node:path";
|
|
192235
192860
|
function callbackSettings(settings3) {
|
|
192236
192861
|
const url = new URL(settings3.callbackUrl ?? `http://${CALLBACK_HOST}${CALLBACK_PATH}`);
|
|
192237
192862
|
const address = url.hostname.replace(/^\[|\]$/g, "");
|
|
@@ -192437,7 +193062,7 @@ var init_oauth2 = __esm({
|
|
|
192437
193062
|
/** Directory for the refresh lock files. Without one, refreshes are only serialized in this process. */
|
|
192438
193063
|
lockDir;
|
|
192439
193064
|
constructor(backend, lockDir) {
|
|
192440
|
-
this.backend = backend ?? new FileAuthStorageBackend(
|
|
193065
|
+
this.backend = backend ?? new FileAuthStorageBackend(join16(getAgentDir(), "mcp-auth.json"));
|
|
192441
193066
|
this.lockDir = backend ? lockDir : getAgentDir();
|
|
192442
193067
|
}
|
|
192443
193068
|
forServer(serverUrl) {
|
|
@@ -192459,7 +193084,7 @@ var init_oauth2 = __esm({
|
|
|
192459
193084
|
return fn();
|
|
192460
193085
|
mkdirSync4(this.lockDir, { recursive: true, mode: 448 });
|
|
192461
193086
|
const hash = createHash3("sha256").update(key).digest("hex").slice(0, 16);
|
|
192462
|
-
const release = await import_proper_lockfile4.default.lock(
|
|
193087
|
+
const release = await import_proper_lockfile4.default.lock(join16(this.lockDir, `mcp-auth-refresh-${hash}`), {
|
|
192463
193088
|
realpath: false,
|
|
192464
193089
|
stale: REFRESH_LOCK_STALE_MS,
|
|
192465
193090
|
retries: {
|
|
@@ -192514,9 +193139,9 @@ var init_oauth2 = __esm({
|
|
|
192514
193139
|
});
|
|
192515
193140
|
|
|
192516
193141
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/log.js
|
|
192517
|
-
import { appendFileSync, mkdirSync as mkdirSync5, renameSync, statSync as
|
|
192518
|
-
import { dirname as
|
|
192519
|
-
function
|
|
193142
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5, renameSync as renameSync2, statSync as statSync4 } from "node:fs";
|
|
193143
|
+
import { dirname as dirname12 } from "node:path";
|
|
193144
|
+
function isRecord6(value2) {
|
|
192520
193145
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
192521
193146
|
}
|
|
192522
193147
|
function formatData(data) {
|
|
@@ -192529,7 +193154,7 @@ function formatData(data) {
|
|
|
192529
193154
|
}
|
|
192530
193155
|
}
|
|
192531
193156
|
function formatMcpLogMessage(server, params, now = /* @__PURE__ */ new Date()) {
|
|
192532
|
-
const message =
|
|
193157
|
+
const message = isRecord6(params) ? params : { data: params };
|
|
192533
193158
|
const level = typeof message.level === "string" ? message.level : "info";
|
|
192534
193159
|
const logger = typeof message.logger === "string" && message.logger ? ` ${message.logger}:` : "";
|
|
192535
193160
|
const text = formatData(message.data).replace(/\r?\n/g, "\n ");
|
|
@@ -192550,22 +193175,22 @@ var init_log3 = __esm({
|
|
|
192550
193175
|
const line = formatMcpLogMessage(server, params);
|
|
192551
193176
|
try {
|
|
192552
193177
|
if (this.size === void 0) {
|
|
192553
|
-
mkdirSync5(
|
|
193178
|
+
mkdirSync5(dirname12(this.path), { recursive: true });
|
|
192554
193179
|
this.size = this.currentSize();
|
|
192555
193180
|
}
|
|
192556
193181
|
if (this.size > MAX_LOG_BYTES) {
|
|
192557
193182
|
if (this.currentSize() > MAX_LOG_BYTES)
|
|
192558
|
-
|
|
193183
|
+
renameSync2(this.path, `${this.path}.1`);
|
|
192559
193184
|
this.size = this.currentSize();
|
|
192560
193185
|
}
|
|
192561
|
-
|
|
193186
|
+
appendFileSync2(this.path, line);
|
|
192562
193187
|
this.size += Buffer.byteLength(line);
|
|
192563
193188
|
} catch {
|
|
192564
193189
|
}
|
|
192565
193190
|
}
|
|
192566
193191
|
currentSize() {
|
|
192567
193192
|
try {
|
|
192568
|
-
return
|
|
193193
|
+
return statSync4(this.path).size;
|
|
192569
193194
|
} catch {
|
|
192570
193195
|
return 0;
|
|
192571
193196
|
}
|
|
@@ -192585,7 +193210,7 @@ __export(runtime_exports, {
|
|
|
192585
193210
|
signInMcpServer: () => signInMcpServer
|
|
192586
193211
|
});
|
|
192587
193212
|
import { homedir as homedir5 } from "node:os";
|
|
192588
|
-
import { basename as
|
|
193213
|
+
import { basename as basename11, join as join17, resolve as resolve7 } from "node:path";
|
|
192589
193214
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
192590
193215
|
function errorMessage3(error) {
|
|
192591
193216
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -192609,7 +193234,7 @@ function expandHome(value2) {
|
|
|
192609
193234
|
if (value2 === "~")
|
|
192610
193235
|
return homedir5();
|
|
192611
193236
|
if (value2.startsWith("~/") || process.platform === "win32" && value2.startsWith("~\\")) {
|
|
192612
|
-
return
|
|
193237
|
+
return join17(homedir5(), value2.slice(2));
|
|
192613
193238
|
}
|
|
192614
193239
|
return value2;
|
|
192615
193240
|
}
|
|
@@ -192629,7 +193254,7 @@ function createDefaultTransport(entry, cwd, authProvider) {
|
|
|
192629
193254
|
return new StdioTransport({
|
|
192630
193255
|
command: expandHome(config.command),
|
|
192631
193256
|
args: config.args?.map(expandHome),
|
|
192632
|
-
cwd:
|
|
193257
|
+
cwd: resolve7(cwd, expandHome(config.cwd ?? ".")),
|
|
192633
193258
|
env: env2,
|
|
192634
193259
|
stderr: "pipe"
|
|
192635
193260
|
});
|
|
@@ -192775,7 +193400,7 @@ var init_runtime = __esm({
|
|
|
192775
193400
|
return await run(client);
|
|
192776
193401
|
} catch (error) {
|
|
192777
193402
|
if (readOnly && attempt === 1 && error instanceof McpHttpError && isTransientError(error)) {
|
|
192778
|
-
await new Promise((
|
|
193403
|
+
await new Promise((resolve13) => setTimeout(resolve13, CONNECT_RETRY_DELAYS_MS[0]));
|
|
192779
193404
|
continue;
|
|
192780
193405
|
}
|
|
192781
193406
|
if (error instanceof McpSessionExpiredError && attempt === 1) {
|
|
@@ -192836,7 +193461,7 @@ var init_runtime = __esm({
|
|
|
192836
193461
|
if (this.closed || delay2 === void 0 || !isTransientError(error)) {
|
|
192837
193462
|
throw this.connectFailed(error);
|
|
192838
193463
|
}
|
|
192839
|
-
await new Promise((
|
|
193464
|
+
await new Promise((resolve13) => setTimeout(resolve13, delay2));
|
|
192840
193465
|
if (this.closed)
|
|
192841
193466
|
throw this.connectFailed(error);
|
|
192842
193467
|
}
|
|
@@ -192847,7 +193472,7 @@ var init_runtime = __esm({
|
|
|
192847
193472
|
name: "pi",
|
|
192848
193473
|
version: VERSION,
|
|
192849
193474
|
requestTimeoutMs: this.timeoutMs,
|
|
192850
|
-
roots: [{ uri: pathToFileURL2(this.cwd).href, name:
|
|
193475
|
+
roots: [{ uri: pathToFileURL2(this.cwd).href, name: basename11(this.cwd) }]
|
|
192851
193476
|
});
|
|
192852
193477
|
const log = this.log;
|
|
192853
193478
|
if (log)
|
|
@@ -193040,7 +193665,7 @@ var init_ui = __esm({
|
|
|
193040
193665
|
this.tui.requestRender();
|
|
193041
193666
|
}
|
|
193042
193667
|
menu(build, subscribe) {
|
|
193043
|
-
return new Promise((
|
|
193668
|
+
return new Promise((resolve13) => {
|
|
193044
193669
|
let unsubscribe;
|
|
193045
193670
|
let settled = false;
|
|
193046
193671
|
const finish = (value2) => {
|
|
@@ -193048,10 +193673,10 @@ var init_ui = __esm({
|
|
|
193048
193673
|
return;
|
|
193049
193674
|
settled = true;
|
|
193050
193675
|
unsubscribe?.();
|
|
193051
|
-
|
|
193676
|
+
resolve13(value2);
|
|
193052
193677
|
};
|
|
193053
193678
|
let selected;
|
|
193054
|
-
const
|
|
193679
|
+
const render2 = () => {
|
|
193055
193680
|
const menu = build();
|
|
193056
193681
|
const wanted = selected ?? menu.selected;
|
|
193057
193682
|
const body = [];
|
|
@@ -193082,10 +193707,10 @@ var init_ui = __esm({
|
|
|
193082
193707
|
body.push(list2);
|
|
193083
193708
|
this.setContent(frame(this.theme, menu.title, body, footer), (data) => list2.handleInput(data));
|
|
193084
193709
|
};
|
|
193085
|
-
|
|
193710
|
+
render2();
|
|
193086
193711
|
unsubscribe = subscribe?.(() => {
|
|
193087
193712
|
if (!settled)
|
|
193088
|
-
|
|
193713
|
+
render2();
|
|
193089
193714
|
});
|
|
193090
193715
|
});
|
|
193091
193716
|
}
|
|
@@ -193093,14 +193718,14 @@ var init_ui = __esm({
|
|
|
193093
193718
|
this.setContent(frame(this.theme, title, [new Spacer(1), new Text(this.theme.fg("muted", message), 1, 0)]));
|
|
193094
193719
|
}
|
|
193095
193720
|
redirectUrl(title, authorizationUrl, signal) {
|
|
193096
|
-
return new Promise((
|
|
193721
|
+
return new Promise((resolve13) => {
|
|
193097
193722
|
let settled = false;
|
|
193098
193723
|
const finish = (value2) => {
|
|
193099
193724
|
if (settled)
|
|
193100
193725
|
return;
|
|
193101
193726
|
settled = true;
|
|
193102
193727
|
signal.removeEventListener("abort", onAbort);
|
|
193103
|
-
|
|
193728
|
+
resolve13(value2);
|
|
193104
193729
|
};
|
|
193105
193730
|
const onAbort = () => finish(void 0);
|
|
193106
193731
|
if (signal.aborted) {
|
|
@@ -193147,7 +193772,7 @@ var init_ui = __esm({
|
|
|
193147
193772
|
});
|
|
193148
193773
|
|
|
193149
193774
|
// node_modules/.pnpm/@earendil-works+pi-coding-agent@0.99.1_@aws-sdk+credential-provider-node@3.972.83_@smit_1f563b9fb7db4619e2913cc40d230799/node_modules/@earendil-works/pi-coding-agent/dist/extensions/mcp/index.js
|
|
193150
|
-
import { join as
|
|
193775
|
+
import { join as join18, resolve as resolve8 } from "node:path";
|
|
193151
193776
|
function errorMessage4(error) {
|
|
193152
193777
|
return error instanceof Error ? error.message : String(error);
|
|
193153
193778
|
}
|
|
@@ -193257,7 +193882,7 @@ function createMcpExtension(options = {}) {
|
|
|
193257
193882
|
return credentials;
|
|
193258
193883
|
};
|
|
193259
193884
|
const getServerLog = (runtime) => {
|
|
193260
|
-
serverLog ??= new runtime.McpServerLog(options.logPath ??
|
|
193885
|
+
serverLog ??= new runtime.McpServerLog(options.logPath ?? join18(getAgentDir(), "mcp.log"));
|
|
193261
193886
|
return serverLog;
|
|
193262
193887
|
};
|
|
193263
193888
|
const toolOwners = /* @__PURE__ */ new Map();
|
|
@@ -193518,7 +194143,7 @@ Run /mcp to fix.`, "warning");
|
|
|
193518
194143
|
label: server.entry.name,
|
|
193519
194144
|
description: `${describeState(server)} \xB7 ${exposureOf(server.entry)} \xB7 ${server.entry.scope ?? server.entry.source}`
|
|
193520
194145
|
})),
|
|
193521
|
-
empty: `No MCP servers configured. Add them to ${
|
|
194146
|
+
empty: `No MCP servers configured. Add them to ${resolve8(getAgentDir(), "mcp.json")} or .pi/mcp.json.`,
|
|
193522
194147
|
confirmLabel: "manage",
|
|
193523
194148
|
cancelLabel: "close"
|
|
193524
194149
|
});
|
|
@@ -193668,7 +194293,7 @@ Run /mcp to fix.`, "warning");
|
|
|
193668
194293
|
};
|
|
193669
194294
|
const formatStatus = () => {
|
|
193670
194295
|
if (servers.length === 0 && configErrors.length === 0 && overridden.length === 0) {
|
|
193671
|
-
return `No MCP servers configured. Add them to ${
|
|
194296
|
+
return `No MCP servers configured. Add them to ${resolve8(getAgentDir(), "mcp.json")} or .pi/mcp.json.`;
|
|
193672
194297
|
}
|
|
193673
194298
|
const lines = servers.map((server) => {
|
|
193674
194299
|
const { name } = server.entry;
|
|
@@ -193756,7 +194381,7 @@ ${url.href}`, "info");
|
|
|
193756
194381
|
reportProblems(ctx);
|
|
193757
194382
|
return;
|
|
193758
194383
|
}
|
|
193759
|
-
pending = new Promise((
|
|
194384
|
+
pending = new Promise((resolve13) => setImmediate(resolve13)).then(() => loadMcpRuntime()).then(async () => {
|
|
193760
194385
|
if (current !== generation)
|
|
193761
194386
|
return;
|
|
193762
194387
|
const started = await Promise.all(enabled.map((server) => createConnection(server)));
|
|
@@ -193782,8 +194407,8 @@ ${url.href}`, "info");
|
|
|
193782
194407
|
let timer;
|
|
193783
194408
|
const finished2 = await Promise.race([
|
|
193784
194409
|
startup.then(() => true),
|
|
193785
|
-
new Promise((
|
|
193786
|
-
timer = setTimeout(() =>
|
|
194410
|
+
new Promise((resolve13) => {
|
|
194411
|
+
timer = setTimeout(() => resolve13(false), startupWaitMs);
|
|
193787
194412
|
})
|
|
193788
194413
|
]);
|
|
193789
194414
|
clearTimeout(timer);
|
|
@@ -195328,19 +195953,26 @@ var init_archivist_record_pointer = __esm({
|
|
|
195328
195953
|
"src/archivist-record-pointer.ts"() {
|
|
195329
195954
|
"use strict";
|
|
195330
195955
|
init_unknown_value();
|
|
195956
|
+
init_run_dossier();
|
|
195957
|
+
init_run_dossier_files();
|
|
195958
|
+
init_sitian_facade();
|
|
195959
|
+
init_activation_ledger_topology();
|
|
195960
|
+
init_run_lifecycle();
|
|
195961
|
+
init_role_run_relocation();
|
|
195962
|
+
init_role_run_placement();
|
|
195331
195963
|
}
|
|
195332
195964
|
});
|
|
195333
195965
|
|
|
195334
195966
|
// scripts/migrate-book-topology.ts
|
|
195335
195967
|
import { homedir as homedir6 } from "node:os";
|
|
195336
|
-
import { join as
|
|
195968
|
+
import { join as join24, resolve as resolve12 } from "node:path";
|
|
195337
195969
|
|
|
195338
195970
|
// src/book-topology-migration.ts
|
|
195339
195971
|
init_activation_ledger_topology();
|
|
195340
195972
|
init_run_lifecycle();
|
|
195341
195973
|
import { mkdir, readdir as readdir4, rename } from "node:fs/promises";
|
|
195342
195974
|
import { homedir } from "node:os";
|
|
195343
|
-
import { basename as
|
|
195975
|
+
import { basename as basename6, dirname as dirname6, join as join7, resolve as resolve3 } from "node:path";
|
|
195344
195976
|
function reconcileMigrationPartition(partition3, unit, outcomes) {
|
|
195345
195977
|
let placed = 0;
|
|
195346
195978
|
let unbound = 0;
|
|
@@ -195368,7 +196000,7 @@ async function findWriterLocks(root) {
|
|
|
195368
196000
|
const locks = [];
|
|
195369
196001
|
async function walk3(directory) {
|
|
195370
196002
|
for (const entry of await readdir4(directory, { withFileTypes: true })) {
|
|
195371
|
-
const path8 =
|
|
196003
|
+
const path8 = join7(directory, entry.name);
|
|
195372
196004
|
if (entry.name === "writer.lock") {
|
|
195373
196005
|
const kind = entry.isFile() ? "file" : entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symbolic link" : entry.isFIFO() ? "FIFO" : entry.isSocket() ? "socket" : entry.isCharacterDevice() ? "character device" : entry.isBlockDevice() ? "block device" : "unknown filesystem object";
|
|
195374
196006
|
locks.push({ path: path8, regularFile: entry.isFile(), kind });
|
|
@@ -195410,7 +196042,7 @@ ${active.join("\n")}`);
|
|
|
195410
196042
|
}
|
|
195411
196043
|
function datedBooksBackupDirectory(booksDirectory, now = /* @__PURE__ */ new Date()) {
|
|
195412
196044
|
const date = now.toISOString().slice(0, 10);
|
|
195413
|
-
return
|
|
196045
|
+
return join7(dirname6(booksDirectory), `${basename6(booksDirectory)}-${date}`);
|
|
195414
196046
|
}
|
|
195415
196047
|
async function renameBooksToDatedBackup(booksDirectory, now = /* @__PURE__ */ new Date()) {
|
|
195416
196048
|
const backup = datedBooksBackupDirectory(booksDirectory, now);
|
|
@@ -195421,8 +196053,8 @@ async function migrateBookTopology(input) {
|
|
|
195421
196053
|
if (input.migrators.length === 0) {
|
|
195422
196054
|
throw new Error("book topology migration has no partition migrators");
|
|
195423
196055
|
}
|
|
195424
|
-
const ledgerHome =
|
|
195425
|
-
const booksDirectory =
|
|
196056
|
+
const ledgerHome = resolve3(input.ledgerHome ?? join7(homedir(), ".ak-roles"));
|
|
196057
|
+
const booksDirectory = join7(ledgerHome, "books");
|
|
195426
196058
|
await assertBookTopologyMigrationPrerequisites(booksDirectory, input.env);
|
|
195427
196059
|
const backupBooksDirectory = await renameBooksToDatedBackup(booksDirectory, input.now);
|
|
195428
196060
|
await mkdir(booksDirectory);
|
|
@@ -195446,7 +196078,7 @@ async function migrateBookTopology(input) {
|
|
|
195446
196078
|
|
|
195447
196079
|
// src/book-topology-mixed-volume-migrators.ts
|
|
195448
196080
|
import { appendFile, cp as cp2, lstat as lstat2, mkdir as mkdir3, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
195449
|
-
import { dirname as
|
|
196081
|
+
import { dirname as dirname14, join as join20, relative as relative4, resolve as resolve10, sep as sep7 } from "node:path";
|
|
195450
196082
|
|
|
195451
196083
|
// src/archivist-record-entry.ts
|
|
195452
196084
|
init_activation_ledger_topology();
|
|
@@ -195460,6 +196092,7 @@ init_activation_ledger_topology();
|
|
|
195460
196092
|
init_dist8();
|
|
195461
196093
|
|
|
195462
196094
|
// src/archivist-record-entry.ts
|
|
196095
|
+
init_sitian_appender();
|
|
195463
196096
|
init_archivist_record_pointer();
|
|
195464
196097
|
var MAX_SESSION_HEADER_SCAN_BYTES2 = 1024 * 1024;
|
|
195465
196098
|
var WORKER_SUBMISSION_GATE_KIND = "worker-submission-gate";
|
|
@@ -195468,9 +196101,10 @@ var WORKER_SUBMISSION_GATE_KIND = "worker-submission-gate";
|
|
|
195468
196101
|
init_activation_ledger_topology();
|
|
195469
196102
|
init_role_run_placement();
|
|
195470
196103
|
init_run_ticket_number();
|
|
196104
|
+
init_run_dossier();
|
|
195471
196105
|
init_unknown_value();
|
|
195472
196106
|
import { readdir as readdir6, readFile as readFile6 } from "node:fs/promises";
|
|
195473
|
-
import { basename as
|
|
196107
|
+
import { basename as basename12, dirname as dirname13, isAbsolute as isAbsolute6, join as join19, relative as relative3, resolve as resolve9, sep as sep6 } from "node:path";
|
|
195474
196108
|
var TICKET_NUMBER_RE = /^[1-9][0-9]*$/;
|
|
195475
196109
|
var RUN_DIR_NAME_RE = /^([^@]+)@([^@]+)$/;
|
|
195476
196110
|
async function listMigrationBookKeys(booksDirectory) {
|
|
@@ -195496,7 +196130,7 @@ function ticketNumberFromUnknown(value2) {
|
|
|
195496
196130
|
if (typeof value2 === "string" && TICKET_NUMBER_RE.test(value2)) return Number(value2);
|
|
195497
196131
|
return void 0;
|
|
195498
196132
|
}
|
|
195499
|
-
function
|
|
196133
|
+
function isTicketNumberString2(value2) {
|
|
195500
196134
|
return TICKET_NUMBER_RE.test(value2);
|
|
195501
196135
|
}
|
|
195502
196136
|
function ticketNumberFromWorktreeBasename(pathBasename) {
|
|
@@ -195509,8 +196143,19 @@ function ticketNumberFromWorktreeBasename(pathBasename) {
|
|
|
195509
196143
|
return ticketNumber;
|
|
195510
196144
|
}
|
|
195511
196145
|
async function readProjectRootFromRun(runDirectory) {
|
|
196146
|
+
for (const section of ["admitted", "invocation", "runState"]) {
|
|
196147
|
+
try {
|
|
196148
|
+
const page = readPageSync(runDirectory, section);
|
|
196149
|
+
const projectRoot = page?.projectRoot;
|
|
196150
|
+
if (typeof projectRoot === "string" && projectRoot.length > 0) {
|
|
196151
|
+
return { projectRoot, sourcePage: `state.jsonl:${section}` };
|
|
196152
|
+
}
|
|
196153
|
+
} catch (error) {
|
|
196154
|
+
if (!isEnoent(error)) throw error;
|
|
196155
|
+
}
|
|
196156
|
+
}
|
|
195512
196157
|
for (const page of ["admitted-request.json", "invocation.json", "run-state.json"]) {
|
|
195513
|
-
const path8 =
|
|
196158
|
+
const path8 = join19(runDirectory, page);
|
|
195514
196159
|
try {
|
|
195515
196160
|
const raw = JSON.parse(await readFile6(path8, "utf8"));
|
|
195516
196161
|
if (!isRecord(raw)) continue;
|
|
@@ -195526,7 +196171,7 @@ async function readProjectRootFromRun(runDirectory) {
|
|
|
195526
196171
|
return void 0;
|
|
195527
196172
|
}
|
|
195528
196173
|
async function resolveMigratingRunTicket(runDirectory) {
|
|
195529
|
-
const boardTicket = await
|
|
196174
|
+
const boardTicket = await readMigrationBoardTicketNumber(runDirectory);
|
|
195530
196175
|
if (boardTicket !== void 0) {
|
|
195531
196176
|
return {
|
|
195532
196177
|
ticketNumber: boardTicket,
|
|
@@ -195546,7 +196191,7 @@ async function resolveMigratingRunTicket(runDirectory) {
|
|
|
195546
196191
|
}
|
|
195547
196192
|
const project = await readProjectRootFromRun(runDirectory);
|
|
195548
196193
|
if (project === void 0) return { ticketNumber: void 0, derivation: void 0 };
|
|
195549
|
-
const leaf =
|
|
196194
|
+
const leaf = basename12(project.projectRoot.replace(/\\/g, "/"));
|
|
195550
196195
|
const ticketNumber = ticketNumberFromWorktreeBasename(leaf);
|
|
195551
196196
|
if (ticketNumber === void 0) return { ticketNumber: void 0, derivation: void 0 };
|
|
195552
196197
|
return {
|
|
@@ -195559,7 +196204,7 @@ async function resolveMigratingRunTicket(runDirectory) {
|
|
|
195559
196204
|
};
|
|
195560
196205
|
}
|
|
195561
196206
|
function bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey) {
|
|
195562
|
-
return [
|
|
196207
|
+
return [join19(booksDirectory, bookKey), join19(backupBooksDirectory, bookKey)];
|
|
195563
196208
|
}
|
|
195564
196209
|
function runLeafFromRelative(path8) {
|
|
195565
196210
|
const segments = path8.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0);
|
|
@@ -195571,8 +196216,8 @@ function runLeafFromRelative(path8) {
|
|
|
195571
196216
|
}
|
|
195572
196217
|
function runRefFromBoundPath(path8, bookRoots) {
|
|
195573
196218
|
for (const root of bookRoots) {
|
|
195574
|
-
const rootResolved =
|
|
195575
|
-
const candidate =
|
|
196219
|
+
const rootResolved = resolve9(root);
|
|
196220
|
+
const candidate = isAbsolute6(path8) ? resolve9(path8) : resolve9(rootResolved, path8);
|
|
195576
196221
|
if (candidate === rootResolved || !pathContainedIn(rootResolved, candidate)) continue;
|
|
195577
196222
|
const rel = relative3(rootResolved, candidate).split(sep6).join("/");
|
|
195578
196223
|
const leaf = runLeafFromRelative(rel);
|
|
@@ -195594,11 +196239,11 @@ async function listRunLeafEntries(runsDirectory) {
|
|
|
195594
196239
|
async function listBackupRunLeaves(backupBookDirectory) {
|
|
195595
196240
|
const leaves = [];
|
|
195596
196241
|
const collect = async (relativeDir, layout) => {
|
|
195597
|
-
const runsDirectory =
|
|
196242
|
+
const runsDirectory = join19(backupBookDirectory, ...relativeDir.split("/"));
|
|
195598
196243
|
for (const entry of await listRunLeafEntries(runsDirectory)) {
|
|
195599
196244
|
leaves.push({
|
|
195600
196245
|
relativePath: `${relativeDir}/${entry.name}`,
|
|
195601
|
-
sourcePath:
|
|
196246
|
+
sourcePath: join19(runsDirectory, entry.name),
|
|
195602
196247
|
leafName: entry.name,
|
|
195603
196248
|
isDirectory: entry.isDirectory,
|
|
195604
196249
|
layout
|
|
@@ -195608,11 +196253,11 @@ async function listBackupRunLeaves(backupBookDirectory) {
|
|
|
195608
196253
|
await collect("runs", "flat");
|
|
195609
196254
|
await collect("unbound/runs", "unbound");
|
|
195610
196255
|
for (const subject of await listMigrationDirents(backupBookDirectory)) {
|
|
195611
|
-
if (!subject.isDirectory() || !
|
|
196256
|
+
if (!subject.isDirectory() || !isTicketNumberString2(subject.name)) continue;
|
|
195612
196257
|
await collect(`${subject.name}/runs`, "ticket");
|
|
195613
196258
|
}
|
|
195614
|
-
for (const issue of await listMigrationDirents(
|
|
195615
|
-
if (!issue.isDirectory() || !
|
|
196259
|
+
for (const issue of await listMigrationDirents(join19(backupBookDirectory, "issues"))) {
|
|
196260
|
+
if (!issue.isDirectory() || !isTicketNumberString2(issue.name)) continue;
|
|
195616
196261
|
await collect(`issues/${issue.name}/runs`, "issues");
|
|
195617
196262
|
}
|
|
195618
196263
|
return leaves;
|
|
@@ -195621,13 +196266,13 @@ async function listExactPlacedRunPaths(bookDir, leafName) {
|
|
|
195621
196266
|
const matches = [];
|
|
195622
196267
|
const subjectEntries = await listMigrationDirents(bookDir);
|
|
195623
196268
|
const runsDirs = [
|
|
195624
|
-
|
|
195625
|
-
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) =>
|
|
196269
|
+
join19(bookDir, "runs"),
|
|
196270
|
+
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) => join19(bookDir, entry.name, "runs"))
|
|
195626
196271
|
];
|
|
195627
196272
|
for (const runsDir of runsDirs) {
|
|
195628
196273
|
const entries = await listMigrationDirents(runsDir);
|
|
195629
196274
|
if (entries.some((entry) => entry.name === leafName)) {
|
|
195630
|
-
matches.push(
|
|
196275
|
+
matches.push(join19(runsDir, leafName));
|
|
195631
196276
|
}
|
|
195632
196277
|
}
|
|
195633
196278
|
return matches;
|
|
@@ -195639,14 +196284,14 @@ function destPathFromSourceRelative(booksDirectory, bookKey, sourceRelative2) {
|
|
|
195639
196284
|
const leaf = parts[runsIndex + 1];
|
|
195640
196285
|
const before = parts.slice(0, runsIndex);
|
|
195641
196286
|
if (leaf === void 0) return void 0;
|
|
195642
|
-
if (before.length === 2 && before[0] === "issues" && before[1] !== void 0 &&
|
|
195643
|
-
return
|
|
196287
|
+
if (before.length === 2 && before[0] === "issues" && before[1] !== void 0 && isTicketNumberString2(before[1])) {
|
|
196288
|
+
return join19(booksDirectory, bookKey, before[1], "runs", leaf);
|
|
195644
196289
|
}
|
|
195645
196290
|
if (before.length !== 1) return void 0;
|
|
195646
196291
|
const subject = before[0];
|
|
195647
196292
|
if (subject === void 0) return void 0;
|
|
195648
|
-
if (subject !== "unbound" && !
|
|
195649
|
-
return
|
|
196293
|
+
if (subject !== "unbound" && !isTicketNumberString2(subject)) return void 0;
|
|
196294
|
+
return join19(booksDirectory, bookKey, subject, "runs", leaf);
|
|
195650
196295
|
}
|
|
195651
196296
|
function placedRunFromPath(runDirectory) {
|
|
195652
196297
|
return {
|
|
@@ -195658,15 +196303,15 @@ async function listPrincipalPlacedRunPaths(bookDir, runId) {
|
|
|
195658
196303
|
const matches = [...await listExactPlacedRunPaths(bookDir, runId)];
|
|
195659
196304
|
const subjectEntries = await listMigrationDirents(bookDir);
|
|
195660
196305
|
const runsDirs = [
|
|
195661
|
-
|
|
195662
|
-
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) =>
|
|
196306
|
+
join19(bookDir, "runs"),
|
|
196307
|
+
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) => join19(bookDir, entry.name, "runs"))
|
|
195663
196308
|
];
|
|
195664
196309
|
const prefix = `${runId}@`;
|
|
195665
196310
|
for (const runsDir of runsDirs) {
|
|
195666
196311
|
for (const entry of await listMigrationDirents(runsDir)) {
|
|
195667
196312
|
const name = entry.name;
|
|
195668
196313
|
if (!name.startsWith(prefix) || name.slice(runId.length + 1).includes("@")) continue;
|
|
195669
|
-
const path8 =
|
|
196314
|
+
const path8 = join19(runsDir, name);
|
|
195670
196315
|
if (!matches.includes(path8)) matches.push(path8);
|
|
195671
196316
|
}
|
|
195672
196317
|
}
|
|
@@ -195694,7 +196339,7 @@ function isFlatRunsRelative(sourceRelative2, leafName) {
|
|
|
195694
196339
|
}
|
|
195695
196340
|
async function findPlacedMigratingRun(booksDirectory, bookKey, leafName, sourceRelative2) {
|
|
195696
196341
|
if (leafName.trim() === "") return void 0;
|
|
195697
|
-
const bookDir =
|
|
196342
|
+
const bookDir = join19(booksDirectory, bookKey);
|
|
195698
196343
|
const matches = await listExactPlacedRunPaths(bookDir, leafName);
|
|
195699
196344
|
if (sourceRelative2 !== void 0 && sourceRelative2.length > 0) {
|
|
195700
196345
|
const preferred = destPathFromSourceRelative(booksDirectory, bookKey, sourceRelative2);
|
|
@@ -195720,12 +196365,12 @@ async function uniqueRunLeafExistsInBook(bookDir, leafName) {
|
|
|
195720
196365
|
}
|
|
195721
196366
|
async function findUniquePrincipalPlacedRun(booksDirectory, bookKey, runId) {
|
|
195722
196367
|
if (runId.trim() === "") return void 0;
|
|
195723
|
-
const matches = await listPrincipalPlacedRunPaths(
|
|
196368
|
+
const matches = await listPrincipalPlacedRunPaths(join19(booksDirectory, bookKey), runId);
|
|
195724
196369
|
if (matches.length !== 1) return void 0;
|
|
195725
196370
|
return placedRunFromPath(matches[0]);
|
|
195726
196371
|
}
|
|
195727
196372
|
function destinationRunDirectory(booksDirectory, bookKey, ticketNumber, runId, role) {
|
|
195728
|
-
const ledgerHome =
|
|
196373
|
+
const ledgerHome = dirname13(booksDirectory);
|
|
195729
196374
|
const subject = ticketNumber !== void 0 ? { ticketNumber } : { unbound: true };
|
|
195730
196375
|
return roleRunPlacement(ledgerHome, {
|
|
195731
196376
|
bookKey,
|
|
@@ -195862,9 +196507,9 @@ function inspectWorkerSubmissionGateVolume(text, bookRoots) {
|
|
|
195862
196507
|
}
|
|
195863
196508
|
function volumeDestinationFile(booksDirectory, bookKey, destRun, kind, fileName) {
|
|
195864
196509
|
if (destRun === void 0) {
|
|
195865
|
-
return
|
|
196510
|
+
return join20(booksDirectory, bookKey, "unbound", kind, fileName);
|
|
195866
196511
|
}
|
|
195867
|
-
return
|
|
196512
|
+
return join20(destRun.runDirectory, "session", kind, fileName);
|
|
195868
196513
|
}
|
|
195869
196514
|
async function placedRunForLeaf(cache, booksDirectory, bookKey, leaf, sourceRelative2) {
|
|
195870
196515
|
const cacheKey = `${bookKey}\0${sourceRelative2 ?? ""}\0${leaf}`;
|
|
@@ -195879,7 +196524,7 @@ async function placedRunForLeaf(cache, booksDirectory, bookKey, leaf, sourceRela
|
|
|
195879
196524
|
return placed;
|
|
195880
196525
|
}
|
|
195881
196526
|
async function appendRawLine(file, raw) {
|
|
195882
|
-
await mkdir3(
|
|
196527
|
+
await mkdir3(dirname14(file), { recursive: true });
|
|
195883
196528
|
await appendFile(file, `${raw}
|
|
195884
196529
|
`, "utf8");
|
|
195885
196530
|
}
|
|
@@ -195895,7 +196540,7 @@ function jsonlRows(text) {
|
|
|
195895
196540
|
return rows;
|
|
195896
196541
|
}
|
|
195897
196542
|
async function migrateCurrentSessionPointer(input) {
|
|
195898
|
-
const sourceFile =
|
|
196543
|
+
const sourceFile = join20(input.sourceDir, CURRENT_SESSION_LEDGER);
|
|
195899
196544
|
const raw = await readRegularBackupFile(sourceFile);
|
|
195900
196545
|
if (raw === void 0) return;
|
|
195901
196546
|
let sessionFile;
|
|
@@ -195909,11 +196554,11 @@ async function migrateCurrentSessionPointer(input) {
|
|
|
195909
196554
|
}
|
|
195910
196555
|
let destinationSessionFile;
|
|
195911
196556
|
if (sessionFile !== void 0) {
|
|
195912
|
-
const pointed =
|
|
196557
|
+
const pointed = resolve10(input.sourceDir, sessionFile);
|
|
195913
196558
|
destinationSessionFile = input.volumeDestinations.get(pointed) ?? input.volumeDestinations.get(sessionFile);
|
|
195914
196559
|
}
|
|
195915
196560
|
if (destinationSessionFile === void 0) {
|
|
195916
|
-
await mkdir3(
|
|
196561
|
+
await mkdir3(dirname14(input.unboundPointerFile), { recursive: true });
|
|
195917
196562
|
await writeFile6(
|
|
195918
196563
|
input.unboundPointerFile,
|
|
195919
196564
|
raw.endsWith("\n") ? raw : `${raw}
|
|
@@ -195922,8 +196567,8 @@ async function migrateCurrentSessionPointer(input) {
|
|
|
195922
196567
|
);
|
|
195923
196568
|
return;
|
|
195924
196569
|
}
|
|
195925
|
-
const pointerFile =
|
|
195926
|
-
await mkdir3(
|
|
196570
|
+
const pointerFile = join20(dirname14(destinationSessionFile), CURRENT_SESSION_LEDGER);
|
|
196571
|
+
await mkdir3(dirname14(pointerFile), { recursive: true });
|
|
195927
196572
|
await writeFile6(
|
|
195928
196573
|
pointerFile,
|
|
195929
196574
|
`${JSON.stringify({ sessionFile: destinationSessionFile })}
|
|
@@ -195936,15 +196581,15 @@ async function migrateSitianMixedVolume(partition3, context) {
|
|
|
195936
196581
|
const placedCache = /* @__PURE__ */ new Map();
|
|
195937
196582
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
195938
196583
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
195939
|
-
const sourceDir =
|
|
195940
|
-
const recordsFile =
|
|
196584
|
+
const sourceDir = join20(backupBooksDirectory, bookKey, partition3);
|
|
196585
|
+
const recordsFile = join20(sourceDir, "records.jsonl");
|
|
195941
196586
|
const bookRoots = bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey);
|
|
195942
196587
|
const text = await readRegularBackupFile(recordsFile);
|
|
195943
196588
|
if (text === void 0) {
|
|
195944
196589
|
await migrateCurrentSessionPointer({
|
|
195945
196590
|
sourceDir,
|
|
195946
196591
|
volumeDestinations: /* @__PURE__ */ new Map(),
|
|
195947
|
-
unboundPointerFile:
|
|
196592
|
+
unboundPointerFile: join20(
|
|
195948
196593
|
booksDirectory,
|
|
195949
196594
|
bookKey,
|
|
195950
196595
|
"unbound",
|
|
@@ -196022,16 +196667,16 @@ async function migrateSitianMixedVolume(partition3, context) {
|
|
|
196022
196667
|
const volumeDestinations = /* @__PURE__ */ new Map();
|
|
196023
196668
|
if (placedDests.size === 1) {
|
|
196024
196669
|
const onlyDest = placedDests.values().next().value;
|
|
196025
|
-
volumeDestinations.set(
|
|
196670
|
+
volumeDestinations.set(resolve10(recordsFile), onlyDest);
|
|
196026
196671
|
volumeDestinations.set(
|
|
196027
|
-
|
|
196672
|
+
resolve10(join20(booksDirectory, bookKey, partition3, "records.jsonl")),
|
|
196028
196673
|
onlyDest
|
|
196029
196674
|
);
|
|
196030
196675
|
}
|
|
196031
196676
|
await migrateCurrentSessionPointer({
|
|
196032
196677
|
sourceDir,
|
|
196033
196678
|
volumeDestinations,
|
|
196034
|
-
unboundPointerFile:
|
|
196679
|
+
unboundPointerFile: join20(
|
|
196035
196680
|
booksDirectory,
|
|
196036
196681
|
bookKey,
|
|
196037
196682
|
"unbound",
|
|
@@ -196049,13 +196694,13 @@ async function migrateWorkerSubmissionGate(context) {
|
|
|
196049
196694
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196050
196695
|
const kind = WORKER_SUBMISSION_GATE_KIND;
|
|
196051
196696
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196052
|
-
const sourceDir =
|
|
196697
|
+
const sourceDir = join20(backupBooksDirectory, bookKey, kind);
|
|
196053
196698
|
const entries = await listMigrationDirents(sourceDir);
|
|
196054
196699
|
if (entries.length === 0) continue;
|
|
196055
196700
|
const bookRoots = bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey);
|
|
196056
196701
|
const volumes = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map((entry) => entry.name).sort();
|
|
196057
196702
|
for (const name of volumes) {
|
|
196058
|
-
const sourcePath =
|
|
196703
|
+
const sourcePath = join20(sourceDir, name);
|
|
196059
196704
|
const source = posixRelative(backupBooksDirectory, sourcePath);
|
|
196060
196705
|
const text = await readRegularBackupFile(sourcePath);
|
|
196061
196706
|
if (text === void 0) continue;
|
|
@@ -196074,7 +196719,7 @@ async function migrateWorkerSubmissionGate(context) {
|
|
|
196074
196719
|
kind,
|
|
196075
196720
|
name
|
|
196076
196721
|
);
|
|
196077
|
-
await mkdir3(
|
|
196722
|
+
await mkdir3(dirname14(dest), { recursive: true });
|
|
196078
196723
|
await cp2(sourcePath, dest, { preserveTimestamps: true });
|
|
196079
196724
|
outcomes.push({
|
|
196080
196725
|
disposition: destRun?.disposition === "placed" ? "placed" : "unbound",
|
|
@@ -196111,7 +196756,7 @@ var BOOK_TOPOLOGY_MIXED_VOLUME_MIGRATORS = [
|
|
|
196111
196756
|
// src/book-topology-migrators-t11.ts
|
|
196112
196757
|
init_activation_ledger_topology();
|
|
196113
196758
|
import { cp as cp3, lstat as lstat3, mkdir as mkdir4, readFile as readFile8, stat as stat4, unlink as unlink2, utimes, writeFile as writeFile7 } from "node:fs/promises";
|
|
196114
|
-
import { basename as
|
|
196759
|
+
import { basename as basename13, dirname as dirname15, join as join21, relative as relative5, resolve as resolve11, sep as sep8 } from "node:path";
|
|
196115
196760
|
init_role_run_relocation();
|
|
196116
196761
|
init_unknown_value();
|
|
196117
196762
|
var AUDITOR_ROLES_PARTITION = "auditor-roles";
|
|
@@ -196141,7 +196786,7 @@ var DEPRECATED_RUN_PAGE_NAME_SET = new Set(DEPRECATED_RUN_PAGE_NAMES);
|
|
|
196141
196786
|
function isDeprecatedRunPage(name) {
|
|
196142
196787
|
return DEPRECATED_RUN_PAGE_NAME_SET.has(name);
|
|
196143
196788
|
}
|
|
196144
|
-
function
|
|
196789
|
+
function parseRunLeaf2(name) {
|
|
196145
196790
|
const match3 = RUN_LEAF.exec(name);
|
|
196146
196791
|
if (match3 === null) return void 0;
|
|
196147
196792
|
const runId = match3[1];
|
|
@@ -196163,7 +196808,7 @@ async function directoryExists(path8) {
|
|
|
196163
196808
|
}
|
|
196164
196809
|
async function hasAnyFileRecursive(directory) {
|
|
196165
196810
|
for (const entry of await listMigrationDirents(directory)) {
|
|
196166
|
-
const path8 =
|
|
196811
|
+
const path8 = join21(directory, entry.name);
|
|
196167
196812
|
if (entry.isDirectory()) {
|
|
196168
196813
|
if (await hasAnyFileRecursive(path8)) return true;
|
|
196169
196814
|
} else {
|
|
@@ -196173,14 +196818,14 @@ async function hasAnyFileRecursive(directory) {
|
|
|
196173
196818
|
return false;
|
|
196174
196819
|
}
|
|
196175
196820
|
function mapBooksPathToBackup(booksDirectory, backupBooksDirectory, absolutePath) {
|
|
196176
|
-
const booksRoot =
|
|
196177
|
-
const resolved =
|
|
196821
|
+
const booksRoot = resolve11(booksDirectory);
|
|
196822
|
+
const resolved = resolve11(absolutePath);
|
|
196178
196823
|
if (resolved !== booksRoot && !pathContainedIn(booksRoot, resolved)) return void 0;
|
|
196179
|
-
return
|
|
196824
|
+
return join21(backupBooksDirectory, relative5(booksRoot, resolved));
|
|
196180
196825
|
}
|
|
196181
196826
|
function resolveVolumeSessionFile(booksDirectory, backupBooksDirectory, volumeDirectory, sessionFileField) {
|
|
196182
|
-
const resolvedVolume =
|
|
196183
|
-
const resolvedSession =
|
|
196827
|
+
const resolvedVolume = resolve11(volumeDirectory);
|
|
196828
|
+
const resolvedSession = resolve11(sessionFileField);
|
|
196184
196829
|
if (physicallyContainedIn(resolvedVolume, resolvedSession)) return resolvedSession;
|
|
196185
196830
|
const mapped = mapBooksPathToBackup(
|
|
196186
196831
|
booksDirectory,
|
|
@@ -196188,13 +196833,13 @@ function resolveVolumeSessionFile(booksDirectory, backupBooksDirectory, volumeDi
|
|
|
196188
196833
|
sessionFileField
|
|
196189
196834
|
);
|
|
196190
196835
|
if (mapped === void 0) return void 0;
|
|
196191
|
-
const resolvedMapped =
|
|
196836
|
+
const resolvedMapped = resolve11(mapped);
|
|
196192
196837
|
return physicallyContainedIn(resolvedVolume, resolvedMapped) ? resolvedMapped : void 0;
|
|
196193
196838
|
}
|
|
196194
196839
|
function parseParentRunBoundToMigration(booksDirectory, backupBooksDirectory, parentSession) {
|
|
196195
|
-
const resolved =
|
|
196196
|
-
const booksRoot =
|
|
196197
|
-
const backupRoot =
|
|
196840
|
+
const resolved = resolve11(parentSession);
|
|
196841
|
+
const booksRoot = resolve11(booksDirectory);
|
|
196842
|
+
const backupRoot = resolve11(backupBooksDirectory);
|
|
196198
196843
|
let rel;
|
|
196199
196844
|
if (resolved === booksRoot || pathContainedIn(booksRoot, resolved)) {
|
|
196200
196845
|
rel = relative5(booksRoot, resolved).split(sep8).join("/");
|
|
@@ -196212,13 +196857,13 @@ function parseParentRunBoundToMigration(booksDirectory, backupBooksDirectory, pa
|
|
|
196212
196857
|
let bookKey;
|
|
196213
196858
|
if (before.length === 1) {
|
|
196214
196859
|
bookKey = before[0];
|
|
196215
|
-
} else if (before.length === 2 && (before[1] === "unbound" || before[1] !== void 0 &&
|
|
196860
|
+
} else if (before.length === 2 && (before[1] === "unbound" || before[1] !== void 0 && isTicketNumberString2(before[1]))) {
|
|
196216
196861
|
bookKey = before[0];
|
|
196217
|
-
} else if (before.length === 3 && before[1] === "issues" && before[2] !== void 0 &&
|
|
196862
|
+
} else if (before.length === 3 && before[1] === "issues" && before[2] !== void 0 && isTicketNumberString2(before[2])) {
|
|
196218
196863
|
bookKey = before[0];
|
|
196219
196864
|
}
|
|
196220
196865
|
if (bookKey === void 0) return void 0;
|
|
196221
|
-
const leaf =
|
|
196866
|
+
const leaf = parseRunLeaf2(leafName);
|
|
196222
196867
|
if (leaf === void 0) return void 0;
|
|
196223
196868
|
return {
|
|
196224
196869
|
bookKey,
|
|
@@ -196251,15 +196896,15 @@ async function readJsonlParentSession(path8) {
|
|
|
196251
196896
|
}
|
|
196252
196897
|
}
|
|
196253
196898
|
async function backupParentRunExists(backupBooksDirectory, parent) {
|
|
196254
|
-
const backupBook =
|
|
196255
|
-
if (await directoryExists(
|
|
196899
|
+
const backupBook = join21(backupBooksDirectory, parent.bookKey);
|
|
196900
|
+
if (await directoryExists(join21(backupBook, parent.sourceRelative))) return true;
|
|
196256
196901
|
if (!isFlatRunsRelative(parent.sourceRelative, parent.leafName)) return false;
|
|
196257
196902
|
return uniqueRunLeafExistsInBook(backupBook, parent.leafName);
|
|
196258
196903
|
}
|
|
196259
196904
|
async function findTrueVolumeParent(backupBooksDirectory, booksDirectory, volumeDirectory) {
|
|
196260
196905
|
let ledgerRaw;
|
|
196261
196906
|
try {
|
|
196262
|
-
ledgerRaw = await readFile8(
|
|
196907
|
+
ledgerRaw = await readFile8(join21(volumeDirectory, CURRENT_SESSION_LEDGER2), "utf8");
|
|
196263
196908
|
} catch (error) {
|
|
196264
196909
|
if (isEnoent(error)) return void 0;
|
|
196265
196910
|
throw error;
|
|
@@ -196310,22 +196955,22 @@ async function collectPlacedRunRewrites(booksDirectory, backupBooksDirectory) {
|
|
|
196310
196955
|
rewrites.push({ oldRunDirectory, newRunDirectory });
|
|
196311
196956
|
};
|
|
196312
196957
|
for (const bookKey of await listMigrationBookKeys(booksDirectory)) {
|
|
196313
|
-
for (const subject of await listMigrationDirents(
|
|
196958
|
+
for (const subject of await listMigrationDirents(join21(booksDirectory, bookKey))) {
|
|
196314
196959
|
if (!subject.isDirectory()) continue;
|
|
196315
|
-
const runsRoot =
|
|
196960
|
+
const runsRoot = join21(booksDirectory, bookKey, subject.name, "runs");
|
|
196316
196961
|
for (const run of await listMigrationDirents(runsRoot)) {
|
|
196317
196962
|
if (!run.isDirectory()) continue;
|
|
196318
|
-
const finalPath =
|
|
196319
|
-
push(
|
|
196320
|
-
push(
|
|
196321
|
-
push(
|
|
196322
|
-
if (
|
|
196963
|
+
const finalPath = join21(runsRoot, run.name);
|
|
196964
|
+
push(join21(booksDirectory, bookKey, "runs", run.name), finalPath);
|
|
196965
|
+
push(join21(backupBooksDirectory, bookKey, "runs", run.name), finalPath);
|
|
196966
|
+
push(join21(backupBooksDirectory, bookKey, subject.name, "runs", run.name), finalPath);
|
|
196967
|
+
if (isTicketNumberString2(subject.name)) {
|
|
196323
196968
|
push(
|
|
196324
|
-
|
|
196969
|
+
join21(booksDirectory, bookKey, "issues", subject.name, "runs", run.name),
|
|
196325
196970
|
finalPath
|
|
196326
196971
|
);
|
|
196327
196972
|
push(
|
|
196328
|
-
|
|
196973
|
+
join21(backupBooksDirectory, bookKey, "issues", subject.name, "runs", run.name),
|
|
196329
196974
|
finalPath
|
|
196330
196975
|
);
|
|
196331
196976
|
}
|
|
@@ -196336,12 +196981,12 @@ async function collectPlacedRunRewrites(booksDirectory, backupBooksDirectory) {
|
|
|
196336
196981
|
}
|
|
196337
196982
|
function historicalRunDirectoriesFor(booksDirectory, backupBooksDirectory, parent) {
|
|
196338
196983
|
const out = [
|
|
196339
|
-
|
|
196340
|
-
|
|
196984
|
+
join21(booksDirectory, parent.bookKey, parent.sourceRelative),
|
|
196985
|
+
join21(backupBooksDirectory, parent.bookKey, parent.sourceRelative)
|
|
196341
196986
|
];
|
|
196342
196987
|
if (!parent.sourceRelative.startsWith("runs/")) {
|
|
196343
|
-
out.push(
|
|
196344
|
-
out.push(
|
|
196988
|
+
out.push(join21(booksDirectory, parent.bookKey, "runs", parent.leafName));
|
|
196989
|
+
out.push(join21(backupBooksDirectory, parent.bookKey, "runs", parent.leafName));
|
|
196345
196990
|
}
|
|
196346
196991
|
return out;
|
|
196347
196992
|
}
|
|
@@ -196354,11 +196999,11 @@ async function resolveDestinationRun(context, parent) {
|
|
|
196354
196999
|
);
|
|
196355
197000
|
}
|
|
196356
197001
|
function rewritePathIntoDestination(sessionFile, sourceRoots, destRoot) {
|
|
196357
|
-
const resolved =
|
|
197002
|
+
const resolved = resolve11(sessionFile);
|
|
196358
197003
|
for (const root of sourceRoots) {
|
|
196359
|
-
const resolvedRoot =
|
|
197004
|
+
const resolvedRoot = resolve11(root);
|
|
196360
197005
|
if (pathContainedIn(resolvedRoot, resolved)) {
|
|
196361
|
-
return
|
|
197006
|
+
return join21(destRoot, relative5(resolvedRoot, resolved));
|
|
196362
197007
|
}
|
|
196363
197008
|
}
|
|
196364
197009
|
return sessionFile;
|
|
@@ -196403,8 +197048,8 @@ async function writeWinningCurrentSession(destPath, srcStat, destStat, nextRaw,
|
|
|
196403
197048
|
`book topology migration cannot compare current-session pointer at ${destPath}: file disappeared during tie-break`
|
|
196404
197049
|
);
|
|
196405
197050
|
}
|
|
196406
|
-
const srcName =
|
|
196407
|
-
const destName =
|
|
197051
|
+
const srcName = basename13(nextSessionFile ?? "");
|
|
197052
|
+
const destName = basename13(destSessionFile);
|
|
196408
197053
|
if (destName >= srcName) return;
|
|
196409
197054
|
}
|
|
196410
197055
|
}
|
|
@@ -196412,7 +197057,7 @@ async function writeWinningCurrentSession(destPath, srcStat, destStat, nextRaw,
|
|
|
196412
197057
|
await utimes(destPath, srcStat.atime, srcStat.mtime);
|
|
196413
197058
|
}
|
|
196414
197059
|
async function mergeRewrittenCurrentSession(volumeDirectory, historicalVolume, destNest) {
|
|
196415
|
-
const srcPath =
|
|
197060
|
+
const srcPath = join21(volumeDirectory, CURRENT_SESSION_LEDGER2);
|
|
196416
197061
|
let srcRaw;
|
|
196417
197062
|
let srcStat;
|
|
196418
197063
|
try {
|
|
@@ -196444,7 +197089,7 @@ async function mergeRewrittenCurrentSession(volumeDirectory, historicalVolume, d
|
|
|
196444
197089
|
} catch {
|
|
196445
197090
|
nextSessionFile = void 0;
|
|
196446
197091
|
}
|
|
196447
|
-
const destPath =
|
|
197092
|
+
const destPath = join21(destNest, CURRENT_SESSION_LEDGER2);
|
|
196448
197093
|
let destStat;
|
|
196449
197094
|
try {
|
|
196450
197095
|
destStat = await stat4(destPath);
|
|
@@ -196463,8 +197108,8 @@ async function copyDirSkippingCurrentSession(from, to) {
|
|
|
196463
197108
|
await mkdir4(to, { recursive: true });
|
|
196464
197109
|
for (const entry of await listMigrationDirents(from)) {
|
|
196465
197110
|
if (entry.name === CURRENT_SESSION_LEDGER2 && entry.isFile()) continue;
|
|
196466
|
-
const src =
|
|
196467
|
-
const dest =
|
|
197111
|
+
const src = join21(from, entry.name);
|
|
197112
|
+
const dest = join21(to, entry.name);
|
|
196468
197113
|
if (entry.isDirectory()) {
|
|
196469
197114
|
await copyDirSkippingCurrentSession(src, dest);
|
|
196470
197115
|
} else if (entry.isFile()) {
|
|
@@ -196477,7 +197122,7 @@ async function copyVolumeIntoNest(volumeDirectory, historicalVolume, destNest) {
|
|
|
196477
197122
|
await mergeRewrittenCurrentSession(volumeDirectory, historicalVolume, destNest);
|
|
196478
197123
|
}
|
|
196479
197124
|
async function copyTree(source, destination) {
|
|
196480
|
-
await mkdir4(
|
|
197125
|
+
await mkdir4(dirname15(destination), { recursive: true });
|
|
196481
197126
|
await cp3(source, destination, { recursive: true, preserveTimestamps: true });
|
|
196482
197127
|
}
|
|
196483
197128
|
var bookTopologyAuditorRolesMigrator = {
|
|
@@ -196491,9 +197136,9 @@ var bookTopologyAuditorRolesMigrator = {
|
|
|
196491
197136
|
);
|
|
196492
197137
|
const rewriteSeen = new Set(crossRunRewrites.map((r2) => r2.oldRunDirectory));
|
|
196493
197138
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196494
|
-
const auditorRoot =
|
|
197139
|
+
const auditorRoot = join21(backupBooksDirectory, bookKey, AUDITOR_ROLES_PARTITION);
|
|
196495
197140
|
for (const entry of await listMigrationDirents(auditorRoot)) {
|
|
196496
|
-
const sourcePath =
|
|
197141
|
+
const sourcePath = join21(auditorRoot, entry.name);
|
|
196497
197142
|
if (entry.isFile() && entry.name === T10_MISFILED_NAME) {
|
|
196498
197143
|
continue;
|
|
196499
197144
|
}
|
|
@@ -196512,14 +197157,14 @@ var bookTopologyAuditorRolesMigrator = {
|
|
|
196512
197157
|
continue;
|
|
196513
197158
|
}
|
|
196514
197159
|
const destination = await resolveDestinationRun(context, parent);
|
|
196515
|
-
const historicalVolume =
|
|
197160
|
+
const historicalVolume = join21(
|
|
196516
197161
|
booksDirectory,
|
|
196517
197162
|
bookKey,
|
|
196518
197163
|
AUDITOR_ROLES_PARTITION,
|
|
196519
197164
|
entry.name
|
|
196520
197165
|
);
|
|
196521
197166
|
if (destination === void 0) {
|
|
196522
|
-
const destNest2 =
|
|
197167
|
+
const destNest2 = join21(
|
|
196523
197168
|
booksDirectory,
|
|
196524
197169
|
bookKey,
|
|
196525
197170
|
"unbound",
|
|
@@ -196530,7 +197175,7 @@ var bookTopologyAuditorRolesMigrator = {
|
|
|
196530
197175
|
outcomes.push({ disposition: "unbound", source });
|
|
196531
197176
|
continue;
|
|
196532
197177
|
}
|
|
196533
|
-
const destNest =
|
|
197178
|
+
const destNest = join21(destination.runDirectory, "session", AUDITOR_ROLES_PARTITION);
|
|
196534
197179
|
await copyVolumeIntoNest(sourcePath, historicalVolume, destNest);
|
|
196535
197180
|
const historicalParents = historicalRunDirectoriesFor(
|
|
196536
197181
|
booksDirectory,
|
|
@@ -196561,8 +197206,8 @@ async function copyIssuesNonRunTree(source, destination) {
|
|
|
196561
197206
|
await mkdir4(destination, { recursive: true });
|
|
196562
197207
|
for (const entry of await listMigrationDirents(source)) {
|
|
196563
197208
|
if (entry.name === "runs") continue;
|
|
196564
|
-
const from =
|
|
196565
|
-
const to =
|
|
197209
|
+
const from = join21(source, entry.name);
|
|
197210
|
+
const to = join21(destination, entry.name);
|
|
196566
197211
|
if (entry.isDirectory()) {
|
|
196567
197212
|
await copyIssuesNonRunTree(from, to);
|
|
196568
197213
|
continue;
|
|
@@ -196585,9 +197230,9 @@ var bookTopologyIssuesMigrator = {
|
|
|
196585
197230
|
const outcomes = [];
|
|
196586
197231
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196587
197232
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196588
|
-
const issuesRoot =
|
|
197233
|
+
const issuesRoot = join21(backupBooksDirectory, bookKey, ISSUES_PARTITION);
|
|
196589
197234
|
for (const entry of await listMigrationDirents(issuesRoot)) {
|
|
196590
|
-
const sourcePath =
|
|
197235
|
+
const sourcePath = join21(issuesRoot, entry.name);
|
|
196591
197236
|
const source = sourceIdentity(backupBooksDirectory, sourcePath);
|
|
196592
197237
|
const isTicketDir = entry.isDirectory() && TICKET_NUMBER_NAME.test(entry.name);
|
|
196593
197238
|
if (!isTicketDir || !await hasAnyFileRecursive(sourcePath)) {
|
|
@@ -196596,7 +197241,7 @@ var bookTopologyIssuesMigrator = {
|
|
|
196596
197241
|
}
|
|
196597
197242
|
await copyIssuesNonRunTree(
|
|
196598
197243
|
sourcePath,
|
|
196599
|
-
|
|
197244
|
+
join21(booksDirectory, bookKey, entry.name)
|
|
196600
197245
|
);
|
|
196601
197246
|
outcomes.push({ disposition: "placed", source });
|
|
196602
197247
|
}
|
|
@@ -196611,11 +197256,11 @@ var bookTopologyDeprecatedKindsMigrator = {
|
|
|
196611
197256
|
const { backupBooksDirectory } = context;
|
|
196612
197257
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196613
197258
|
for (const kind of DEPRECATED_KIND_DIRECTORIES) {
|
|
196614
|
-
const kindRoot =
|
|
197259
|
+
const kindRoot = join21(backupBooksDirectory, bookKey, kind);
|
|
196615
197260
|
for (const entry of await listMigrationDirents(kindRoot)) {
|
|
196616
197261
|
outcomes.push({
|
|
196617
197262
|
disposition: "discarded",
|
|
196618
|
-
source: sourceIdentity(backupBooksDirectory,
|
|
197263
|
+
source: sourceIdentity(backupBooksDirectory, join21(kindRoot, entry.name))
|
|
196619
197264
|
});
|
|
196620
197265
|
}
|
|
196621
197266
|
}
|
|
@@ -196637,11 +197282,11 @@ async function discardDeprecatedPagesFromRunSource(input) {
|
|
|
196637
197282
|
disposition: "discarded",
|
|
196638
197283
|
source: sourceIdentity(
|
|
196639
197284
|
input.backupBooksDirectory,
|
|
196640
|
-
|
|
197285
|
+
join21(input.sourceRunDirectory, page.name)
|
|
196641
197286
|
)
|
|
196642
197287
|
});
|
|
196643
197288
|
if (input.destinationRunDirectory !== void 0) {
|
|
196644
|
-
await unlinkIfPresent(
|
|
197289
|
+
await unlinkIfPresent(join21(input.destinationRunDirectory, page.name));
|
|
196645
197290
|
}
|
|
196646
197291
|
}
|
|
196647
197292
|
}
|
|
@@ -196651,7 +197296,7 @@ var bookTopologyDeprecatedRunPagesMigrator = {
|
|
|
196651
197296
|
const outcomes = [];
|
|
196652
197297
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196653
197298
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196654
|
-
for (const leaf of await listBackupRunLeaves(
|
|
197299
|
+
for (const leaf of await listBackupRunLeaves(join21(backupBooksDirectory, bookKey))) {
|
|
196655
197300
|
if (!leaf.isDirectory) continue;
|
|
196656
197301
|
const placed = await findPlacedMigratingRun(
|
|
196657
197302
|
booksDirectory,
|
|
@@ -196672,15 +197317,15 @@ var bookTopologyDeprecatedRunPagesMigrator = {
|
|
|
196672
197317
|
};
|
|
196673
197318
|
async function copyBookTopLevelPartition(context, partition3, outcomes) {
|
|
196674
197319
|
for (const bookKey of await listMigrationBookKeys(context.backupBooksDirectory)) {
|
|
196675
|
-
const sourceDir =
|
|
197320
|
+
const sourceDir = join21(context.backupBooksDirectory, bookKey, partition3);
|
|
196676
197321
|
if (!await directoryExists(sourceDir)) continue;
|
|
196677
|
-
await copyTree(sourceDir,
|
|
197322
|
+
await copyTree(sourceDir, join21(context.booksDirectory, bookKey, partition3));
|
|
196678
197323
|
for (const entry of await listMigrationDirents(sourceDir)) {
|
|
196679
197324
|
outcomes.push({
|
|
196680
197325
|
disposition: "placed",
|
|
196681
197326
|
source: sourceIdentity(
|
|
196682
197327
|
context.backupBooksDirectory,
|
|
196683
|
-
|
|
197328
|
+
join21(sourceDir, entry.name)
|
|
196684
197329
|
)
|
|
196685
197330
|
});
|
|
196686
197331
|
}
|
|
@@ -196707,12 +197352,12 @@ var bookTopologyManualArchivesMigrator = {
|
|
|
196707
197352
|
async migrate(context) {
|
|
196708
197353
|
const outcomes = [];
|
|
196709
197354
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196710
|
-
const archivesRoot =
|
|
197355
|
+
const archivesRoot = join21(dirname15(booksDirectory), MANUAL_ARCHIVES_PARTITION);
|
|
196711
197356
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196712
197357
|
for (const dirName of MANUAL_ARCHIVE_DIRECTORIES) {
|
|
196713
|
-
const sourceDir =
|
|
197358
|
+
const sourceDir = join21(backupBooksDirectory, bookKey, dirName);
|
|
196714
197359
|
if (!await directoryExists(sourceDir)) continue;
|
|
196715
|
-
await copyTree(sourceDir,
|
|
197360
|
+
await copyTree(sourceDir, join21(archivesRoot, bookKey, dirName));
|
|
196716
197361
|
outcomes.push({
|
|
196717
197362
|
disposition: "placed",
|
|
196718
197363
|
source: sourceIdentity(backupBooksDirectory, sourceDir)
|
|
@@ -196734,11 +197379,11 @@ var BOOK_TOPOLOGY_T11_MIGRATORS = [
|
|
|
196734
197379
|
|
|
196735
197380
|
// src/book-topology-record-class-migrators.ts
|
|
196736
197381
|
import { appendFile as appendFile2, mkdir as mkdir5, readFile as readFile9, stat as stat5, writeFile as writeFile8 } from "node:fs/promises";
|
|
196737
|
-
import { dirname as
|
|
196738
|
-
init_sitian_appender();
|
|
197382
|
+
import { dirname as dirname16, join as join22, relative as relative6, sep as sep9 } from "node:path";
|
|
196739
197383
|
init_ticket_provenance_contracts();
|
|
196740
197384
|
init_sha256();
|
|
196741
197385
|
init_unknown_value();
|
|
197386
|
+
var LEGACY_SUBMISSION_LEDGER_KINDS = /* @__PURE__ */ new Set(["candidate", "roundContext", "outcome", "sealed", "post-seal-anomaly"]);
|
|
196742
197387
|
var TICKET_PROVENANCE = "ticket-provenance";
|
|
196743
197388
|
var SUBMISSION_LEDGER = "submission-ledger";
|
|
196744
197389
|
var ATTEMPT_HISTORY = "attempt-history";
|
|
@@ -196827,14 +197472,14 @@ var RecordWriteCache = class {
|
|
|
196827
197472
|
}
|
|
196828
197473
|
}
|
|
196829
197474
|
this.destPlacements.delete(recordFile);
|
|
196830
|
-
await ensureDir(
|
|
197475
|
+
await ensureDir(dirname16(recordFile));
|
|
196831
197476
|
const text = body.endsWith("\n") ? body : `${body}
|
|
196832
197477
|
`;
|
|
196833
197478
|
await writeFile8(recordFile, text, "utf8");
|
|
196834
197479
|
this.markBareVolume(recordFile);
|
|
196835
197480
|
}
|
|
196836
197481
|
async append(recordFile, raw, options) {
|
|
196837
|
-
await ensureDir(
|
|
197482
|
+
await ensureDir(dirname16(recordFile));
|
|
196838
197483
|
const line = raw.endsWith("\n") ? raw : `${raw}
|
|
196839
197484
|
`;
|
|
196840
197485
|
const parsed2 = parseJsonlLine(raw);
|
|
@@ -196869,14 +197514,14 @@ function runIdFromPayload(payload) {
|
|
|
196869
197514
|
function recordClassOfKind(kind) {
|
|
196870
197515
|
if (kind === TICKET_PROVENANCE) return TICKET_PROVENANCE;
|
|
196871
197516
|
if (kind === ATTEMPT_HISTORY) return ATTEMPT_HISTORY;
|
|
196872
|
-
if (typeof kind === "string" &&
|
|
197517
|
+
if (typeof kind === "string" && LEGACY_SUBMISSION_LEDGER_KINDS.has(kind)) return SUBMISSION_LEDGER;
|
|
196873
197518
|
return void 0;
|
|
196874
197519
|
}
|
|
196875
197520
|
async function listFilesRecursive(root, predicate) {
|
|
196876
197521
|
const out = [];
|
|
196877
197522
|
async function walk3(directory) {
|
|
196878
197523
|
for (const entry of await listMigrationDirents(directory)) {
|
|
196879
|
-
const path8 =
|
|
197524
|
+
const path8 = join22(directory, entry.name);
|
|
196880
197525
|
if (entry.isDirectory()) await walk3(path8);
|
|
196881
197526
|
else if (entry.isFile() && predicate(entry.name)) out.push(path8);
|
|
196882
197527
|
}
|
|
@@ -196885,10 +197530,10 @@ async function listFilesRecursive(root, predicate) {
|
|
|
196885
197530
|
return out;
|
|
196886
197531
|
}
|
|
196887
197532
|
async function listVolumeRecordFiles(partitionDir) {
|
|
196888
|
-
const files = [
|
|
197533
|
+
const files = [join22(partitionDir, "records.jsonl")];
|
|
196889
197534
|
for (const entry of await listMigrationDirents(partitionDir)) {
|
|
196890
197535
|
if (!entry.isDirectory()) continue;
|
|
196891
|
-
files.push(
|
|
197536
|
+
files.push(join22(partitionDir, entry.name, "records.jsonl"));
|
|
196892
197537
|
}
|
|
196893
197538
|
return files;
|
|
196894
197539
|
}
|
|
@@ -196897,7 +197542,7 @@ function isHomeRecordClassRelativePath(relPosix) {
|
|
|
196897
197542
|
if (parts[0] === TICKET_PROVENANCE || parts[0] === SUBMISSION_LEDGER || parts[0] === ATTEMPT_HISTORY) {
|
|
196898
197543
|
return true;
|
|
196899
197544
|
}
|
|
196900
|
-
if (parts.length >= 2 &&
|
|
197545
|
+
if (parts.length >= 2 && isTicketNumberString2(parts[0])) {
|
|
196901
197546
|
if (parts[1] === TICKET_PROVENANCE) return true;
|
|
196902
197547
|
if (parts.length === 2 && parts[1] === "records.jsonl") return true;
|
|
196903
197548
|
}
|
|
@@ -196934,7 +197579,7 @@ function relativePathWithinRun(relPosix) {
|
|
|
196934
197579
|
return parts.slice(runsIndex + 2).join("/");
|
|
196935
197580
|
}
|
|
196936
197581
|
function unboundCategoryFile(booksDirectory, bookKey, category, key) {
|
|
196937
|
-
return
|
|
197582
|
+
return join22(booksDirectory, bookKey, "unbound", category, key, "records.jsonl");
|
|
196938
197583
|
}
|
|
196939
197584
|
async function resolveRunDestination(context, bookKey, runId, hints) {
|
|
196940
197585
|
const hasSessionParent = typeof hints.sessionParent === "string" && hints.sessionParent.length > 0;
|
|
@@ -197000,7 +197645,7 @@ async function placeTicketProvenanceLine(context, bookKey, writes, source, raw,
|
|
|
197000
197645
|
await writes.append(unboundCategoryFile(context.booksDirectory, bookKey, TICKET_PROVENANCE, stableKey(raw)), raw);
|
|
197001
197646
|
return { disposition: "unbound", source };
|
|
197002
197647
|
}
|
|
197003
|
-
const dest =
|
|
197648
|
+
const dest = join22(
|
|
197004
197649
|
context.booksDirectory,
|
|
197005
197650
|
bookKey,
|
|
197006
197651
|
String(ticketNumber),
|
|
@@ -197045,7 +197690,7 @@ async function placeRunOwnedLine(context, bookKey, writes, category, source, raw
|
|
|
197045
197690
|
await writes.append(unboundCategoryFile(context.booksDirectory, bookKey, category, target.key), raw);
|
|
197046
197691
|
return { disposition: "unbound", source };
|
|
197047
197692
|
}
|
|
197048
|
-
await writes.append(
|
|
197693
|
+
await writes.append(join22(target.runDirectory, "session", category, "records.jsonl"), raw);
|
|
197049
197694
|
return { disposition: target.disposition, source };
|
|
197050
197695
|
}
|
|
197051
197696
|
async function placeRecordClassLine(context, bookKey, writes, source, raw, value2, fallbackCategory, outcomeIndex) {
|
|
@@ -197077,7 +197722,7 @@ function tryBareTicketProvenanceVolume(lines) {
|
|
|
197077
197722
|
return { ticket: header.ticket, body };
|
|
197078
197723
|
}
|
|
197079
197724
|
async function placeBareTicketProvenanceVolume(context, bookKey, writes, filePath, bare, outcomes) {
|
|
197080
|
-
const dest =
|
|
197725
|
+
const dest = join22(
|
|
197081
197726
|
context.booksDirectory,
|
|
197082
197727
|
bookKey,
|
|
197083
197728
|
String(bare.ticket),
|
|
@@ -197148,7 +197793,7 @@ async function migrateJsonlFileByKind(context, bookKey, writes, filePath, fallba
|
|
|
197148
197793
|
}
|
|
197149
197794
|
var OFFERED_IDENTITIES = "offered-identities.jsonl";
|
|
197150
197795
|
async function mergeOfferedIdentities(destDir, volumeDir, writes) {
|
|
197151
|
-
const from =
|
|
197796
|
+
const from = join22(volumeDir, OFFERED_IDENTITIES);
|
|
197152
197797
|
let lines;
|
|
197153
197798
|
try {
|
|
197154
197799
|
await stat5(from);
|
|
@@ -197157,14 +197802,14 @@ async function mergeOfferedIdentities(destDir, volumeDir, writes) {
|
|
|
197157
197802
|
if (isEnoent(error)) return;
|
|
197158
197803
|
throw error;
|
|
197159
197804
|
}
|
|
197160
|
-
const destFile =
|
|
197805
|
+
const destFile = join22(destDir, OFFERED_IDENTITIES);
|
|
197161
197806
|
for (const raw of lines) {
|
|
197162
197807
|
if (raw.trim() === "") continue;
|
|
197163
197808
|
await writes.append(destFile, raw);
|
|
197164
197809
|
}
|
|
197165
197810
|
}
|
|
197166
197811
|
async function ticketNumbersInVolume(volumeDir) {
|
|
197167
|
-
const lines = await readJsonlLines(
|
|
197812
|
+
const lines = await readJsonlLines(join22(volumeDir, "records.jsonl"));
|
|
197168
197813
|
const bare = tryBareTicketProvenanceVolume(lines);
|
|
197169
197814
|
if (bare !== void 0) return [bare.ticket];
|
|
197170
197815
|
const out = [];
|
|
@@ -197183,29 +197828,29 @@ async function ticketNumbersInVolume(volumeDir) {
|
|
|
197183
197828
|
}
|
|
197184
197829
|
async function mergeCompanionsFromVolume(context, bookKey, volumeDir, writes) {
|
|
197185
197830
|
for (const ticketNumber of await ticketNumbersInVolume(volumeDir)) {
|
|
197186
|
-
const destDir =
|
|
197831
|
+
const destDir = join22(context.booksDirectory, bookKey, String(ticketNumber));
|
|
197187
197832
|
await ensureDir(destDir);
|
|
197188
197833
|
await mergeOfferedIdentities(destDir, volumeDir, writes);
|
|
197189
197834
|
}
|
|
197190
197835
|
}
|
|
197191
197836
|
async function migrateHomePartitionBook(context, bookKey, writes, category, outcomes) {
|
|
197192
|
-
const backupBook =
|
|
197193
|
-
const rootFiles = await listVolumeRecordFiles(
|
|
197837
|
+
const backupBook = join22(context.backupBooksDirectory, bookKey);
|
|
197838
|
+
const rootFiles = await listVolumeRecordFiles(join22(backupBook, category));
|
|
197194
197839
|
for (const filePath of rootFiles) {
|
|
197195
197840
|
await migrateJsonlFileByKind(context, bookKey, writes, filePath, category, outcomes);
|
|
197196
197841
|
if (category === TICKET_PROVENANCE) {
|
|
197197
|
-
await mergeCompanionsFromVolume(context, bookKey,
|
|
197842
|
+
await mergeCompanionsFromVolume(context, bookKey, dirname16(filePath), writes);
|
|
197198
197843
|
}
|
|
197199
197844
|
}
|
|
197200
197845
|
if (category !== TICKET_PROVENANCE) return;
|
|
197201
197846
|
for (const entry of await listMigrationDirents(backupBook)) {
|
|
197202
|
-
if (!entry.isDirectory() || !
|
|
197203
|
-
const ticketDir =
|
|
197847
|
+
if (!entry.isDirectory() || !isTicketNumberString2(entry.name)) continue;
|
|
197848
|
+
const ticketDir = join22(backupBook, entry.name);
|
|
197204
197849
|
for (const volumeDir of [
|
|
197205
|
-
|
|
197850
|
+
join22(ticketDir, TICKET_PROVENANCE),
|
|
197206
197851
|
ticketDir
|
|
197207
197852
|
]) {
|
|
197208
|
-
const recordsFile =
|
|
197853
|
+
const recordsFile = join22(volumeDir, "records.jsonl");
|
|
197209
197854
|
try {
|
|
197210
197855
|
await stat5(recordsFile);
|
|
197211
197856
|
} catch (error) {
|
|
@@ -197237,11 +197882,11 @@ async function scrubRawLinesFromFile(recordFile, rawLines) {
|
|
|
197237
197882
|
kept.push(normalized);
|
|
197238
197883
|
}
|
|
197239
197884
|
if (!changed) return;
|
|
197240
|
-
await ensureDir(
|
|
197885
|
+
await ensureDir(dirname16(recordFile));
|
|
197241
197886
|
await writeFile8(recordFile, kept.join(""), "utf8");
|
|
197242
197887
|
}
|
|
197243
197888
|
async function migrateMisplacedBook(context, bookKey, writes, outcomes) {
|
|
197244
|
-
const backupBook =
|
|
197889
|
+
const backupBook = join22(context.backupBooksDirectory, bookKey);
|
|
197245
197890
|
const files = await listFilesRecursive(backupBook, (name) => name.endsWith(".jsonl"));
|
|
197246
197891
|
const scrubPlans = /* @__PURE__ */ new Map();
|
|
197247
197892
|
for (const filePath of files) {
|
|
@@ -197290,12 +197935,12 @@ async function migrateMisplacedBook(context, bookKey, writes, outcomes) {
|
|
|
197290
197935
|
const withinRun = relativePathWithinRun(withinBook);
|
|
197291
197936
|
if (coords === void 0 || withinRun === void 0) continue;
|
|
197292
197937
|
const destRun = await findBookRunDirectory(
|
|
197293
|
-
|
|
197938
|
+
join22(context.booksDirectory, bookKey),
|
|
197294
197939
|
coords.runId,
|
|
197295
197940
|
coords.role
|
|
197296
197941
|
);
|
|
197297
197942
|
if (destRun === void 0) continue;
|
|
197298
|
-
await scrubRawLinesFromFile(
|
|
197943
|
+
await scrubRawLinesFromFile(join22(destRun.runDirectory, withinRun), rawLines);
|
|
197299
197944
|
}
|
|
197300
197945
|
}
|
|
197301
197946
|
async function forEachBook(context, body) {
|
|
@@ -197344,14 +197989,15 @@ var BOOK_TOPOLOGY_RECORD_CLASS_MIGRATORS = [
|
|
|
197344
197989
|
|
|
197345
197990
|
// src/book-topology-runs-migrator.ts
|
|
197346
197991
|
import { cp as cp4, mkdir as mkdir6, rename as rename2, readdir as readdir7, stat as stat6, writeFile as writeFile9 } from "node:fs/promises";
|
|
197347
|
-
import { basename as
|
|
197992
|
+
import { basename as basename14, dirname as dirname17, join as join23, relative as relative7, sep as sep10 } from "node:path";
|
|
197348
197993
|
init_role_run_placement();
|
|
197349
197994
|
init_role_run_relocation();
|
|
197995
|
+
init_run_dossier();
|
|
197350
197996
|
init_run_ticket_number();
|
|
197351
197997
|
init_unknown_value();
|
|
197352
197998
|
var RUNS_PARTITION = "runs";
|
|
197353
197999
|
var RUN_LEAF2 = /^([A-Za-z0-9][A-Za-z0-9._-]*)@([A-Za-z][A-Za-z0-9_-]*)$/;
|
|
197354
|
-
function
|
|
198000
|
+
function parseRunLeaf3(name) {
|
|
197355
198001
|
const match3 = RUN_LEAF2.exec(name);
|
|
197356
198002
|
if (match3 === null) return void 0;
|
|
197357
198003
|
return { runId: match3[1], role: match3[2] };
|
|
@@ -197373,18 +198019,18 @@ async function writeDerivationPage(targetRunDirectory, derivation) {
|
|
|
197373
198019
|
page: derivation.sourcePage,
|
|
197374
198020
|
field: "projectRoot",
|
|
197375
198021
|
path: derivation.projectRoot,
|
|
197376
|
-
basename:
|
|
198022
|
+
basename: basename14(derivation.projectRoot)
|
|
197377
198023
|
}
|
|
197378
198024
|
};
|
|
197379
198025
|
await writeFile9(
|
|
197380
|
-
|
|
198026
|
+
join23(targetRunDirectory, MIGRATION_TICKET_DERIVATION_PAGE),
|
|
197381
198027
|
`${JSON.stringify(page, null, 2)}
|
|
197382
198028
|
`,
|
|
197383
198029
|
"utf8"
|
|
197384
198030
|
);
|
|
197385
198031
|
}
|
|
197386
198032
|
async function copyRunTree(source, target, isDirectory) {
|
|
197387
|
-
await mkdir6(
|
|
198033
|
+
await mkdir6(dirname17(target), { recursive: true });
|
|
197388
198034
|
if (isDirectory) {
|
|
197389
198035
|
await cp4(source, target, { recursive: true, preserveTimestamps: true });
|
|
197390
198036
|
return;
|
|
@@ -197392,12 +198038,12 @@ async function copyRunTree(source, target, isDirectory) {
|
|
|
197392
198038
|
await cp4(source, target, { preserveTimestamps: true });
|
|
197393
198039
|
}
|
|
197394
198040
|
async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
197395
|
-
const backupBook =
|
|
198041
|
+
const backupBook = join23(backupBooksDirectory, bookKey);
|
|
197396
198042
|
const claimed = /* @__PURE__ */ new Map();
|
|
197397
198043
|
const planned = [];
|
|
197398
198044
|
for (const leaf of await listBackupRunLeaves(backupBook)) {
|
|
197399
198045
|
const sourceIdentity2 = relative7(backupBooksDirectory, leaf.sourcePath).split(sep10).join("/");
|
|
197400
|
-
const parsed2 = leaf.isDirectory ?
|
|
198046
|
+
const parsed2 = leaf.isDirectory ? parseRunLeaf3(leaf.leafName) : void 0;
|
|
197401
198047
|
let targetPath;
|
|
197402
198048
|
let disposition;
|
|
197403
198049
|
let historicalRunDirectory;
|
|
@@ -197405,10 +198051,10 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197405
198051
|
if (leaf.layout === "issues") {
|
|
197406
198052
|
const parts = leaf.relativePath.replaceAll("\\", "/").split("/");
|
|
197407
198053
|
const ticketStr = parts[1];
|
|
197408
|
-
if (ticketStr !== void 0 &&
|
|
197409
|
-
targetPath =
|
|
198054
|
+
if (ticketStr !== void 0 && isTicketNumberString2(ticketStr)) {
|
|
198055
|
+
targetPath = join23(booksDirectory, bookKey, ticketStr, "runs", leaf.leafName);
|
|
197410
198056
|
disposition = "placed";
|
|
197411
|
-
historicalRunDirectory =
|
|
198057
|
+
historicalRunDirectory = join23(
|
|
197412
198058
|
booksDirectory,
|
|
197413
198059
|
bookKey,
|
|
197414
198060
|
"issues",
|
|
@@ -197417,13 +198063,13 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197417
198063
|
leaf.leafName
|
|
197418
198064
|
);
|
|
197419
198065
|
} else {
|
|
197420
|
-
targetPath =
|
|
198066
|
+
targetPath = join23(booksDirectory, bookKey, "unbound", "runs", leaf.leafName);
|
|
197421
198067
|
disposition = "unbound";
|
|
197422
|
-
historicalRunDirectory =
|
|
198068
|
+
historicalRunDirectory = join23(booksDirectory, bookKey, leaf.relativePath);
|
|
197423
198069
|
}
|
|
197424
198070
|
derivation = void 0;
|
|
197425
198071
|
} else if (leaf.layout === "unbound") {
|
|
197426
|
-
const boardTicket = leaf.isDirectory ? await
|
|
198072
|
+
const boardTicket = leaf.isDirectory ? await readMigrationBoardTicketNumber(leaf.sourcePath) : void 0;
|
|
197427
198073
|
if (parsed2 !== void 0 && boardTicket !== void 0) {
|
|
197428
198074
|
targetPath = destinationRunDirectory(
|
|
197429
198075
|
booksDirectory,
|
|
@@ -197433,7 +198079,7 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197433
198079
|
parsed2.role
|
|
197434
198080
|
);
|
|
197435
198081
|
disposition = "placed";
|
|
197436
|
-
historicalRunDirectory =
|
|
198082
|
+
historicalRunDirectory = join23(
|
|
197437
198083
|
booksDirectory,
|
|
197438
198084
|
bookKey,
|
|
197439
198085
|
"unbound",
|
|
@@ -197441,20 +198087,20 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197441
198087
|
leaf.leafName
|
|
197442
198088
|
);
|
|
197443
198089
|
} else {
|
|
197444
|
-
targetPath =
|
|
198090
|
+
targetPath = join23(booksDirectory, bookKey, leaf.relativePath);
|
|
197445
198091
|
disposition = "unbound";
|
|
197446
198092
|
historicalRunDirectory = void 0;
|
|
197447
198093
|
}
|
|
197448
198094
|
derivation = void 0;
|
|
197449
198095
|
} else if (leaf.layout !== "flat") {
|
|
197450
|
-
targetPath =
|
|
198096
|
+
targetPath = join23(booksDirectory, bookKey, leaf.relativePath);
|
|
197451
198097
|
disposition = "placed";
|
|
197452
198098
|
historicalRunDirectory = void 0;
|
|
197453
198099
|
derivation = void 0;
|
|
197454
198100
|
} else if (parsed2 === void 0) {
|
|
197455
|
-
targetPath =
|
|
198101
|
+
targetPath = join23(booksDirectory, bookKey, "unbound", "runs", leaf.leafName);
|
|
197456
198102
|
disposition = "unbound";
|
|
197457
|
-
historicalRunDirectory =
|
|
198103
|
+
historicalRunDirectory = join23(booksDirectory, bookKey, "runs", leaf.leafName);
|
|
197458
198104
|
derivation = void 0;
|
|
197459
198105
|
} else {
|
|
197460
198106
|
const ticket = await resolveMigratingRunTicket(leaf.sourcePath);
|
|
@@ -197466,7 +198112,7 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197466
198112
|
parsed2.role
|
|
197467
198113
|
);
|
|
197468
198114
|
disposition = ticket.ticketNumber === void 0 ? "unbound" : "placed";
|
|
197469
|
-
historicalRunDirectory =
|
|
198115
|
+
historicalRunDirectory = join23(booksDirectory, bookKey, "runs", leaf.leafName);
|
|
197470
198116
|
derivation = ticket.derivation?.method === "project-root-basename" && ticket.ticketNumber !== void 0 ? {
|
|
197471
198117
|
ticketNumber: ticket.ticketNumber,
|
|
197472
198118
|
projectRoot: ticket.derivation.source,
|
|
@@ -197535,9 +198181,9 @@ var bookTopologyRunsMigrator = {
|
|
|
197535
198181
|
}
|
|
197536
198182
|
};
|
|
197537
198183
|
async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
|
|
197538
|
-
const bookKey =
|
|
197539
|
-
const booksDirectory =
|
|
197540
|
-
const unboundRuns =
|
|
198184
|
+
const bookKey = basename14(bookDirectory);
|
|
198185
|
+
const booksDirectory = dirname17(bookDirectory);
|
|
198186
|
+
const unboundRuns = join23(bookDirectory, "unbound", "runs");
|
|
197541
198187
|
let entries;
|
|
197542
198188
|
try {
|
|
197543
198189
|
entries = await readdir7(unboundRuns, { withFileTypes: true });
|
|
@@ -197548,10 +198194,10 @@ async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
|
|
|
197548
198194
|
const planned = [];
|
|
197549
198195
|
for (const entry of entries) {
|
|
197550
198196
|
if (!entry.isDirectory()) continue;
|
|
197551
|
-
const parsed2 =
|
|
198197
|
+
const parsed2 = parseRunLeaf3(entry.name);
|
|
197552
198198
|
if (parsed2 === void 0) continue;
|
|
197553
|
-
const sourcePath =
|
|
197554
|
-
const boardTicket = await
|
|
198199
|
+
const sourcePath = join23(unboundRuns, entry.name);
|
|
198200
|
+
const boardTicket = await readMigrationBoardTicketNumber(sourcePath);
|
|
197555
198201
|
if (boardTicket === void 0) continue;
|
|
197556
198202
|
const targetPath = destinationRunDirectory(
|
|
197557
198203
|
booksDirectory,
|
|
@@ -197591,8 +198237,9 @@ async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
|
|
|
197591
198237
|
});
|
|
197592
198238
|
}
|
|
197593
198239
|
for (const move of planned) {
|
|
197594
|
-
await mkdir6(
|
|
198240
|
+
await mkdir6(dirname17(move.targetPath), { recursive: true });
|
|
197595
198241
|
await rename2(move.sourcePath, move.targetPath);
|
|
198242
|
+
renderCurrentSync(move.targetPath);
|
|
197596
198243
|
}
|
|
197597
198244
|
return planned.map((move) => ({
|
|
197598
198245
|
from: move.sourcePath,
|
|
@@ -197604,7 +198251,7 @@ async function relocateBoardBoundUnboundRunsInBooks(booksDirectory) {
|
|
|
197604
198251
|
const relocated = [];
|
|
197605
198252
|
for (const bookKey of await listMigrationBookKeys(booksDirectory)) {
|
|
197606
198253
|
const batch = await relocateBoardBoundUnboundRunsInBook(
|
|
197607
|
-
|
|
198254
|
+
join23(booksDirectory, bookKey)
|
|
197608
198255
|
);
|
|
197609
198256
|
relocated.push(...batch);
|
|
197610
198257
|
}
|
|
@@ -197633,7 +198280,7 @@ function parseMigrateArgv(argv) {
|
|
|
197633
198280
|
if (arg === "--ledger-home") {
|
|
197634
198281
|
const value2 = argv[i2 + 1];
|
|
197635
198282
|
if (value2 === void 0) throw new Error(USAGE);
|
|
197636
|
-
ledgerHome =
|
|
198283
|
+
ledgerHome = resolve12(value2);
|
|
197637
198284
|
i2 += 1;
|
|
197638
198285
|
continue;
|
|
197639
198286
|
}
|
|
@@ -197643,9 +198290,9 @@ function parseMigrateArgv(argv) {
|
|
|
197643
198290
|
}
|
|
197644
198291
|
var parsed = parseMigrateArgv(process.argv.slice(2));
|
|
197645
198292
|
if (parsed.relocateBoardBoundUnbound) {
|
|
197646
|
-
const ledgerHome = parsed.ledgerHome ??
|
|
198293
|
+
const ledgerHome = parsed.ledgerHome ?? join24(homedir6(), ".ak-roles");
|
|
197647
198294
|
const relocated = await relocateBoardBoundUnboundRunsInBooks(
|
|
197648
|
-
|
|
198295
|
+
join24(ledgerHome, "books")
|
|
197649
198296
|
);
|
|
197650
198297
|
process.stdout.write(
|
|
197651
198298
|
`${JSON.stringify({ ledgerHome, relocatedCount: relocated.length, relocated }, null, 2)}
|