@akagilnc/pi-workflow-roles 0.1.5504 → 0.1.5575
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 +5965 -5994
- package/dist/analyst-gate-cycles-read.js +23 -55
- package/dist/analyst-ledger.js +21 -35
- 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-pointer.js +38 -30
- package/dist/auditor-dossier-tool.js +4 -3
- package/dist/auditor-soul.js +3 -11
- package/dist/doctor-evidence.js +3 -3
- package/dist/engine-detour-usage.js +6 -14
- package/dist/headless-host/production-host.js +5316 -5324
- package/dist/host-descriptions.js +0 -4
- package/dist/host-session-record.js +266 -267
- package/dist/migrate-book-topology.js +1314 -696
- package/dist/notary-source-run.js +1 -1
- package/dist/packaged-role-registry.js +5 -44
- package/dist/pi/role-turn-host.js +53 -3
- package/dist/public-cli/auto-resume.js +8 -47
- package/dist/public-cli/instruction-seat-run.js +5 -3
- package/dist/public-cli/invocation.js +51 -56
- package/dist/public-cli/main.js +1916 -1748
- package/dist/public-cli/post-admission.js +96 -55
- package/dist/public-cli/run-lifecycle.js +27 -53
- package/dist/public-cli/settlement.js +157 -302
- package/dist/role-run-placement.js +1 -11
- package/dist/role-run-relocation.js +72 -50
- package/dist/run-dossier-files.js +30 -0
- package/dist/run-dossier.js +322 -0
- package/dist/run-terminal-artifacts.js +68 -197
- package/dist/run-ticket-number.js +16 -3
- package/dist/session-identity.js +49 -18
- package/dist/sitian-appender.js +13 -16
- package/dist/sitian-facade.js +11 -0
- package/dist/sitian-reader.js +44 -29
- package/dist/submission-gate.js +1 -1
- package/dist/ticket-provenance.js +22 -7
- 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 +9 -2
- package/src/analyst-gate-cycles-read.ts +26 -60
- package/src/analyst-ledger.ts +27 -42
- 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 +2 -2
- package/src/archivist-record-pointer.ts +50 -36
- package/src/auditor-dossier-tool.ts +7 -5
- package/src/auditor-soul.ts +3 -9
- 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/doctor-contracts.ts +1 -1
- package/src/doctor-evidence.ts +2 -2
- package/src/engine-detour-tool.ts +1 -1
- package/src/engine-detour-usage.ts +6 -16
- package/src/external-host-turn-loop.ts +25 -0
- package/src/headless-host/production-host.ts +1 -4
- package/src/headless-host/role-turn-host.ts +54 -20
- package/src/host-descriptions.ts +0 -6
- package/src/host-session-record.ts +224 -140
- package/src/notary-source-run.ts +1 -1
- package/src/packaged-role-registry.ts +1 -50
- package/src/pi/adapter.ts +50 -7
- package/src/pi/role-turn-host.ts +51 -3
- package/src/public-cli/auto-resume.ts +7 -43
- package/src/public-cli/instruction-seat-run.ts +9 -2
- package/src/public-cli/invocation.ts +61 -87
- package/src/public-cli/post-admission.ts +111 -72
- package/src/public-cli/run-lifecycle.ts +27 -72
- package/src/public-cli/settlement.ts +193 -418
- package/src/public-cli/terminal.ts +1 -1
- package/src/role-run-placement.ts +2 -13
- package/src/role-run-relocation.ts +71 -68
- package/src/role-runtime.ts +6 -10
- package/src/run-dossier-files.ts +33 -0
- package/src/run-dossier.ts +357 -0
- package/src/run-terminal-artifacts.ts +83 -237
- package/src/run-ticket-number.ts +41 -11
- package/src/session-identity.ts +52 -20
- package/src/sitian-appender.ts +17 -18
- package/src/sitian-facade.ts +22 -0
- package/src/sitian-reader.ts +62 -32
- package/src/submission-gate.ts +1 -1
- package/src/ticket-provenance.ts +20 -7
- package/src/ticket-trajectory.ts +10 -10
|
@@ -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,16 +577,640 @@ 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";
|
|
556
1214
|
function isPositiveTicketNumber(value2) {
|
|
557
1215
|
return typeof value2 === "number" && Number.isInteger(value2) && value2 >= 1;
|
|
558
1216
|
}
|
|
@@ -568,6 +1226,19 @@ function parseTicketNumber(value2) {
|
|
|
568
1226
|
const parsed2 = Number(value2);
|
|
569
1227
|
return isSafePositiveTicketNumber(parsed2) ? parsed2 : void 0;
|
|
570
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);
|
|
1241
|
+
}
|
|
571
1242
|
function requireSafePositiveTicketNumber(ticketNumber, context = "ticketNumber") {
|
|
572
1243
|
if (!isSafePositiveTicketNumber(ticketNumber)) {
|
|
573
1244
|
throw new Error(
|
|
@@ -591,42 +1262,62 @@ async function readJsonObject(path8) {
|
|
|
591
1262
|
throw error;
|
|
592
1263
|
}
|
|
593
1264
|
}
|
|
594
|
-
|
|
595
|
-
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]));
|
|
596
1271
|
if (record === void 0) return void 0;
|
|
597
1272
|
return ticketFromRecord(record);
|
|
598
1273
|
}
|
|
599
1274
|
async function readBoardTicketNumber(runDirectory) {
|
|
600
|
-
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");
|
|
601
1279
|
}
|
|
602
1280
|
async function readMigrationDerivedTicketNumber(runDirectory) {
|
|
603
1281
|
const record = await readJsonObject(
|
|
604
|
-
|
|
1282
|
+
join4(runDirectory, MIGRATION_TICKET_DERIVATION_PAGE)
|
|
605
1283
|
);
|
|
606
1284
|
if (record === void 0) return void 0;
|
|
607
1285
|
if (record.derivation !== "worktree-path-basename") return void 0;
|
|
608
1286
|
return ticketFromRecord(record);
|
|
609
1287
|
}
|
|
610
|
-
var MIGRATION_TICKET_DERIVATION_PAGE;
|
|
1288
|
+
var MIGRATION_TICKET_DERIVATION_PAGE, LEGACY_BOARD_PAGE;
|
|
611
1289
|
var init_run_ticket_number = __esm({
|
|
612
1290
|
"src/run-ticket-number.ts"() {
|
|
613
1291
|
"use strict";
|
|
1292
|
+
init_run_dossier();
|
|
614
1293
|
init_unknown_value();
|
|
615
1294
|
MIGRATION_TICKET_DERIVATION_PAGE = "migration-ticket-derivation.json";
|
|
1295
|
+
LEGACY_BOARD_PAGE = {
|
|
1296
|
+
admitted: "admitted-request.json",
|
|
1297
|
+
invocation: "invocation.json"
|
|
1298
|
+
};
|
|
616
1299
|
}
|
|
617
1300
|
});
|
|
618
1301
|
|
|
619
1302
|
// src/role-run-placement.ts
|
|
620
1303
|
import { readdir } from "node:fs/promises";
|
|
621
|
-
import { basename as
|
|
1304
|
+
import { basename as basename5, dirname as dirname4, join as join5 } from "node:path";
|
|
622
1305
|
function formatRunLeaf(runId, role) {
|
|
623
1306
|
return `${runId}@${role}`;
|
|
624
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
|
+
}
|
|
625
1313
|
function sessionDirectoryOf(runDirectory) {
|
|
626
|
-
return
|
|
1314
|
+
return join5(runDirectory, "session");
|
|
627
1315
|
}
|
|
628
1316
|
function sessionFileIn(sessionDirectory) {
|
|
629
|
-
return
|
|
1317
|
+
return join5(sessionDirectory, ROLE_RUN_SESSION_FILENAME);
|
|
1318
|
+
}
|
|
1319
|
+
function sessionFileOf(runDirectory) {
|
|
1320
|
+
return sessionFileIn(sessionDirectoryOf(runDirectory));
|
|
630
1321
|
}
|
|
631
1322
|
async function listBookRunDirectories(bookDir) {
|
|
632
1323
|
const out = [];
|
|
@@ -641,13 +1332,13 @@ async function listBookRunDirectories(bookDir) {
|
|
|
641
1332
|
}
|
|
642
1333
|
for (const entry of entries) {
|
|
643
1334
|
if (!entry.isDirectory()) continue;
|
|
644
|
-
const runDir =
|
|
1335
|
+
const runDir = join5(runsDir, entry.name);
|
|
645
1336
|
if (seen.has(runDir)) continue;
|
|
646
1337
|
seen.add(runDir);
|
|
647
1338
|
out.push(runDir);
|
|
648
1339
|
}
|
|
649
1340
|
};
|
|
650
|
-
await collect(
|
|
1341
|
+
await collect(join5(bookDir, "runs"));
|
|
651
1342
|
let subjects;
|
|
652
1343
|
try {
|
|
653
1344
|
subjects = await readdir(bookDir, { withFileTypes: true });
|
|
@@ -657,7 +1348,7 @@ async function listBookRunDirectories(bookDir) {
|
|
|
657
1348
|
}
|
|
658
1349
|
for (const subject of subjects) {
|
|
659
1350
|
if (!subject.isDirectory() || subject.name === "runs") continue;
|
|
660
|
-
await collect(
|
|
1351
|
+
await collect(join5(bookDir, subject.name, "runs"));
|
|
661
1352
|
}
|
|
662
1353
|
return out.sort();
|
|
663
1354
|
}
|
|
@@ -666,7 +1357,7 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
666
1357
|
input.subject.ticketNumber,
|
|
667
1358
|
"roleRunPlacement subject.ticketNumber"
|
|
668
1359
|
)) : "unbound";
|
|
669
|
-
const runDirectory =
|
|
1360
|
+
const runDirectory = join5(
|
|
670
1361
|
activationBookDirectory(ledgerHome, input.bookKey),
|
|
671
1362
|
subjectDirectory,
|
|
672
1363
|
"runs",
|
|
@@ -677,13 +1368,9 @@ function roleRunPlacement(ledgerHome, input) {
|
|
|
677
1368
|
runDirectory,
|
|
678
1369
|
sessionDirectory,
|
|
679
1370
|
sessionFile: sessionFileIn(sessionDirectory),
|
|
680
|
-
|
|
681
|
-
attachmentsDirectory: join3(runDirectory, "attachments")
|
|
1371
|
+
attachmentsDirectory: join5(runDirectory, "attachments")
|
|
682
1372
|
};
|
|
683
1373
|
}
|
|
684
|
-
function roleRunArtifactsDirectory(runDirectory) {
|
|
685
|
-
return join3(runDirectory, "artifacts");
|
|
686
|
-
}
|
|
687
1374
|
function isUnboundRunDirectory(runDirectory) {
|
|
688
1375
|
return runDirectory.replaceAll("\\", "/").includes("/unbound/runs/");
|
|
689
1376
|
}
|
|
@@ -8038,6 +8725,7 @@ var init_build = __esm({
|
|
|
8038
8725
|
var init_auditor_dossier_tool = __esm({
|
|
8039
8726
|
"src/auditor-dossier-tool.ts"() {
|
|
8040
8727
|
"use strict";
|
|
8728
|
+
init_run_dossier();
|
|
8041
8729
|
init_role_run_placement();
|
|
8042
8730
|
init_build();
|
|
8043
8731
|
}
|
|
@@ -14098,14 +14786,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14098
14786
|
outputTool: FIXER_OUTPUT_TOOL_NAME,
|
|
14099
14787
|
settlement: "sealed",
|
|
14100
14788
|
artifactFace: {
|
|
14101
|
-
reportPhase: true
|
|
14102
|
-
evidenceRole: true,
|
|
14103
|
-
leaves: [
|
|
14104
|
-
{ key: "phase" },
|
|
14105
|
-
{ key: "packetPath" },
|
|
14106
|
-
{ key: "prerequisitesPath", omitUndefined: true },
|
|
14107
|
-
{ key: "prerequisites" }
|
|
14108
|
-
]
|
|
14789
|
+
reportPhase: true
|
|
14109
14790
|
},
|
|
14110
14791
|
boardPlacement: "marshal",
|
|
14111
14792
|
activationFlags: [
|
|
@@ -14136,12 +14817,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14136
14817
|
outputTool: CODER_OUTPUT_TOOL_NAME,
|
|
14137
14818
|
settlement: "sealed",
|
|
14138
14819
|
artifactFace: {
|
|
14139
|
-
reportPhase: true
|
|
14140
|
-
evidenceRole: true,
|
|
14141
|
-
leaves: [
|
|
14142
|
-
{ key: "phase" },
|
|
14143
|
-
{ key: "taskPath" }
|
|
14144
|
-
]
|
|
14820
|
+
reportPhase: true
|
|
14145
14821
|
},
|
|
14146
14822
|
activationFlags: [
|
|
14147
14823
|
{ field: "taskPath", flag: "ak-coder-task", binds: "input" },
|
|
@@ -14175,15 +14851,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14175
14851
|
settlement: "sealed",
|
|
14176
14852
|
/** Publish only an accepted ledger outcome; audit escalation stays unsettled here. */
|
|
14177
14853
|
sealedAcceptedOnly: true,
|
|
14178
|
-
artifactFace: {
|
|
14179
|
-
evidenceRole: true,
|
|
14180
|
-
leaves: [
|
|
14181
|
-
{ key: "baseRevision" },
|
|
14182
|
-
{ key: "lens" },
|
|
14183
|
-
{ key: "authorityRefs", copyArray: true },
|
|
14184
|
-
{ key: "callerProvenance", callerProvenance: true }
|
|
14185
|
-
]
|
|
14186
|
-
},
|
|
14854
|
+
artifactFace: {},
|
|
14187
14855
|
/** Frozen base/lens/authority become the initial prompt; instruction follows. */
|
|
14188
14856
|
transportPrompt: "skill-args",
|
|
14189
14857
|
boardPlacement: "marshal",
|
|
@@ -14214,14 +14882,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14214
14882
|
bareCommand: false,
|
|
14215
14883
|
outputTool: COLLECTOR_OUTPUT_TOOL,
|
|
14216
14884
|
settlement: "sealed",
|
|
14217
|
-
artifactFace: {
|
|
14218
|
-
evidenceRole: true,
|
|
14219
|
-
leaves: [
|
|
14220
|
-
{ key: "prNumber", omitUndefined: true },
|
|
14221
|
-
{ key: "repository", from: "repository.canonical" },
|
|
14222
|
-
{ key: "manifestDigest" }
|
|
14223
|
-
]
|
|
14224
|
-
},
|
|
14885
|
+
artifactFace: {},
|
|
14225
14886
|
boardPlacement: "collector",
|
|
14226
14887
|
/** Taishi acceptance is a typed groups array, not a status leaf. */
|
|
14227
14888
|
analystTerminal: "groups",
|
|
@@ -14250,12 +14911,6 @@ var init_packaged_role_registry = __esm({
|
|
|
14250
14911
|
auditTool: DOCTOR_AUDIT_TOOL_NAME,
|
|
14251
14912
|
settlement: "sealed",
|
|
14252
14913
|
artifactFace: {
|
|
14253
|
-
evidenceRole: true,
|
|
14254
|
-
leaves: [
|
|
14255
|
-
{ key: "issueNumber" },
|
|
14256
|
-
{ key: "caseRunsPath" },
|
|
14257
|
-
{ key: "caseIdentity" }
|
|
14258
|
-
],
|
|
14259
14914
|
doctorReportFacts: true
|
|
14260
14915
|
},
|
|
14261
14916
|
/** Navigator subject is the doctor case, not the case-path file bytes. */
|
|
@@ -14281,13 +14936,7 @@ var init_packaged_role_registry = __esm({
|
|
|
14281
14936
|
phases: [null],
|
|
14282
14937
|
outputTool: MERGER_OUTPUT_TOOL_NAME,
|
|
14283
14938
|
settlement: "sealed",
|
|
14284
|
-
artifactFace: {
|
|
14285
|
-
evidenceRole: true,
|
|
14286
|
-
leaves: [
|
|
14287
|
-
{ key: "mergerInputPath" },
|
|
14288
|
-
{ key: "derived" }
|
|
14289
|
-
]
|
|
14290
|
-
},
|
|
14939
|
+
artifactFace: {},
|
|
14291
14940
|
activationFlags: [
|
|
14292
14941
|
{ field: "inputPath", from: "mergerInputPath", flag: "ak-merger-input", binds: "input" }
|
|
14293
14942
|
],
|
|
@@ -14704,22 +15353,12 @@ var init_terminal = __esm({
|
|
|
14704
15353
|
});
|
|
14705
15354
|
|
|
14706
15355
|
// src/run-terminal-artifacts.ts
|
|
14707
|
-
var RUN_TERMINAL_ERROR_SETTLEMENT_FILE, RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS, UNIQUE_ERROR_FALLBACK_STEM, UNIQUE_ERROR_FALLBACK_NAME;
|
|
14708
15356
|
var init_run_terminal_artifacts = __esm({
|
|
14709
15357
|
"src/run-terminal-artifacts.ts"() {
|
|
14710
15358
|
"use strict";
|
|
14711
15359
|
init_role_run_placement();
|
|
15360
|
+
init_run_dossier();
|
|
14712
15361
|
init_unknown_value();
|
|
14713
|
-
RUN_TERMINAL_ERROR_SETTLEMENT_FILE = "error.settlement.json";
|
|
14714
|
-
RUN_TERMINAL_ERROR_FALLBACK_RELATIVE_PATHS = [
|
|
14715
|
-
`artifacts/${RUN_TERMINAL_ERROR_SETTLEMENT_FILE}`,
|
|
14716
|
-
RUN_TERMINAL_ERROR_SETTLEMENT_FILE
|
|
14717
|
-
];
|
|
14718
|
-
UNIQUE_ERROR_FALLBACK_STEM = "error";
|
|
14719
|
-
UNIQUE_ERROR_FALLBACK_NAME = new RegExp(
|
|
14720
|
-
`^${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$`,
|
|
14721
|
-
"i"
|
|
14722
|
-
);
|
|
14723
15362
|
}
|
|
14724
15363
|
});
|
|
14725
15364
|
|
|
@@ -14762,8 +15401,7 @@ var init_host_descriptions = __esm({
|
|
|
14762
15401
|
suffix: Object.freeze(["stdio"])
|
|
14763
15402
|
}),
|
|
14764
15403
|
modelPassing: "set_model",
|
|
14765
|
-
setModelId: "bare"
|
|
14766
|
-
sessionBindingFile: "grok-acp-session.json"
|
|
15404
|
+
setModelId: "bare"
|
|
14767
15405
|
}),
|
|
14768
15406
|
/**
|
|
14769
15407
|
* Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
|
|
@@ -14781,7 +15419,6 @@ var init_host_descriptions = __esm({
|
|
|
14781
15419
|
}),
|
|
14782
15420
|
modelPassing: "set_model",
|
|
14783
15421
|
setModelId: "provider:model",
|
|
14784
|
-
sessionBindingFile: "hermes-acp-session.json",
|
|
14785
15422
|
seatProfileSoul: Object.freeze({
|
|
14786
15423
|
flag: "-p",
|
|
14787
15424
|
namePrefix: "ak-",
|
|
@@ -14794,7 +15431,6 @@ var init_host_descriptions = __esm({
|
|
|
14794
15431
|
"claude": Object.freeze({
|
|
14795
15432
|
protocol: "claude-print",
|
|
14796
15433
|
binaryFromHome: Object.freeze([".local", "bin", "claude"]),
|
|
14797
|
-
sessionBindingFile: "claude-headless-session.json",
|
|
14798
15434
|
fixedArgs: Object.freeze([
|
|
14799
15435
|
// Live NDJSON events → sitian host-session records (#811); last line is the result receipt.
|
|
14800
15436
|
"--output-format",
|
|
@@ -14820,8 +15456,7 @@ var init_host_descriptions = __esm({
|
|
|
14820
15456
|
*/
|
|
14821
15457
|
"codex": Object.freeze({
|
|
14822
15458
|
protocol: "codex-exec",
|
|
14823
|
-
binaryFromHome: Object.freeze([".local", "bin", "codex"])
|
|
14824
|
-
sessionBindingFile: "codex-headless-session.json"
|
|
15459
|
+
binaryFromHome: Object.freeze([".local", "bin", "codex"])
|
|
14825
15460
|
})
|
|
14826
15461
|
});
|
|
14827
15462
|
}
|
|
@@ -14902,9 +15537,8 @@ var init_compliance_transport = __esm({
|
|
|
14902
15537
|
});
|
|
14903
15538
|
|
|
14904
15539
|
// src/role-run-relocation.ts
|
|
14905
|
-
import { existsSync } from "node:fs";
|
|
14906
15540
|
import { readdir as readdir2, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
14907
|
-
import { dirname as
|
|
15541
|
+
import { dirname as dirname5, join as join6, sep as sep2 } from "node:path";
|
|
14908
15542
|
function rewriteRunDirectoryPathValue(value2, oldRunDirectory, newRunDirectory) {
|
|
14909
15543
|
if (typeof value2 !== "string") return value2;
|
|
14910
15544
|
if (value2 === oldRunDirectory) return newRunDirectory;
|
|
@@ -14998,25 +15632,22 @@ function rewriteAdmittedRoleRunPage(page, rewrites) {
|
|
|
14998
15632
|
);
|
|
14999
15633
|
}
|
|
15000
15634
|
}
|
|
15001
|
-
async function
|
|
15002
|
-
if (!existsSync(path8)) return;
|
|
15635
|
+
async function rewriteLegacyOfficerPointerFile(path8, rewrites) {
|
|
15003
15636
|
const page = JSON.parse(await readFile2(path8, "utf8"));
|
|
15004
|
-
if (!isRecord(page)) return;
|
|
15005
|
-
if (page.kind !== "direct-officer-run-pointer") return;
|
|
15637
|
+
if (!isRecord(page) || page.kind !== "direct-officer-run-pointer") return;
|
|
15006
15638
|
const before = JSON.stringify(page);
|
|
15007
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
15008
|
-
|
|
15009
|
-
OFFICER_POINTER_FIELDS,
|
|
15010
|
-
rewrites
|
|
15011
|
-
);
|
|
15012
|
-
if (JSON.stringify(page) !== before) {
|
|
15013
|
-
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)}
|
|
15014
15641
|
`, "utf8");
|
|
15015
|
-
}
|
|
15016
15642
|
}
|
|
15017
15643
|
async function rewriteSitianRecordsJsonl(path8, rewrites) {
|
|
15018
|
-
|
|
15019
|
-
|
|
15644
|
+
let raw;
|
|
15645
|
+
try {
|
|
15646
|
+
raw = await readFile2(path8, "utf8");
|
|
15647
|
+
} catch (error) {
|
|
15648
|
+
if (isEnoent(error)) return;
|
|
15649
|
+
throw error;
|
|
15650
|
+
}
|
|
15020
15651
|
if (raw.length === 0) return;
|
|
15021
15652
|
const endsWithNewline = raw.endsWith("\n");
|
|
15022
15653
|
const lines = raw.split("\n");
|
|
@@ -15066,8 +15697,13 @@ async function rewriteSitianRecordsJsonl(path8, rewrites) {
|
|
|
15066
15697
|
);
|
|
15067
15698
|
}
|
|
15068
15699
|
async function rewriteSessionTranscriptBindings(path8, rewrites) {
|
|
15069
|
-
|
|
15070
|
-
|
|
15700
|
+
let raw;
|
|
15701
|
+
try {
|
|
15702
|
+
raw = await readFile2(path8, "utf8");
|
|
15703
|
+
} catch (error) {
|
|
15704
|
+
if (isEnoent(error)) return;
|
|
15705
|
+
throw error;
|
|
15706
|
+
}
|
|
15071
15707
|
if (raw.length === 0) return;
|
|
15072
15708
|
const endsWithNewline = raw.endsWith("\n");
|
|
15073
15709
|
const lines = raw.split("\n");
|
|
@@ -15126,7 +15762,7 @@ async function rewriteSessionTranscriptBindings(path8, rewrites) {
|
|
|
15126
15762
|
);
|
|
15127
15763
|
}
|
|
15128
15764
|
async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
15129
|
-
const sessionRoot =
|
|
15765
|
+
const sessionRoot = join6(pagesDirectory, "session");
|
|
15130
15766
|
async function walk3(directory) {
|
|
15131
15767
|
let entries;
|
|
15132
15768
|
try {
|
|
@@ -15136,14 +15772,14 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
15136
15772
|
throw error;
|
|
15137
15773
|
}
|
|
15138
15774
|
for (const entry of entries) {
|
|
15139
|
-
const path8 =
|
|
15775
|
+
const path8 = join6(directory, entry.name);
|
|
15140
15776
|
if (entry.isDirectory()) {
|
|
15141
15777
|
await walk3(path8);
|
|
15142
15778
|
continue;
|
|
15143
15779
|
}
|
|
15144
15780
|
if (!entry.isFile()) continue;
|
|
15145
15781
|
if (entry.name.endsWith(".pointer.json")) {
|
|
15146
|
-
await
|
|
15782
|
+
await rewriteLegacyOfficerPointerFile(path8, rewrites);
|
|
15147
15783
|
} else if (entry.name === "records.jsonl") {
|
|
15148
15784
|
await rewriteSitianRecordsJsonl(path8, rewrites);
|
|
15149
15785
|
} else if (entry.name.endsWith(".jsonl")) {
|
|
@@ -15156,47 +15792,49 @@ async function rewriteNestedMachinePathPages(pagesDirectory, rewrites) {
|
|
|
15156
15792
|
async function rewriteRoleRunDurablePages(input) {
|
|
15157
15793
|
const { pagesDirectory } = input;
|
|
15158
15794
|
const rewrites = collectRewrites(input);
|
|
15159
|
-
const
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
|
|
15163
|
-
|
|
15164
|
-
|
|
15165
|
-
|
|
15166
|
-
|
|
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
|
+
}
|
|
15167
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
|
+
});
|
|
15168
15819
|
}
|
|
15169
|
-
const
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
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;
|
|
15177
15832
|
}
|
|
15178
|
-
|
|
15179
|
-
const statePath = join4(pagesDirectory, "run-state.json");
|
|
15180
|
-
if (existsSync(statePath)) {
|
|
15181
|
-
const page = JSON.parse(await readFile2(statePath, "utf8"));
|
|
15833
|
+
const page = JSON.parse(raw);
|
|
15182
15834
|
const before = JSON.stringify(page);
|
|
15183
|
-
|
|
15184
|
-
page,
|
|
15185
|
-
RUN_STATE_PAGE_FIELDS,
|
|
15186
|
-
rewrites
|
|
15187
|
-
);
|
|
15188
|
-
if (isRecord(page.principal)) {
|
|
15189
|
-
rewriteRunDirectoryPathFieldsAgainstRewrites(
|
|
15190
|
-
page.principal,
|
|
15191
|
-
["sessionDirectory", "sessionFile"],
|
|
15192
|
-
rewrites
|
|
15193
|
-
);
|
|
15194
|
-
}
|
|
15195
|
-
if (isRecord(page.currentCourt)) {
|
|
15196
|
-
rewriteSummonsMaterials(page.currentCourt.summons, rewrites);
|
|
15197
|
-
}
|
|
15835
|
+
rewrite(page);
|
|
15198
15836
|
if (JSON.stringify(page) !== before) {
|
|
15199
|
-
await writeFile(
|
|
15837
|
+
await writeFile(path8, `${JSON.stringify(page, null, 2)}
|
|
15200
15838
|
`, "utf8");
|
|
15201
15839
|
}
|
|
15202
15840
|
}
|
|
@@ -15210,10 +15848,12 @@ var init_role_run_relocation = __esm({
|
|
|
15210
15848
|
init_run_lifecycle();
|
|
15211
15849
|
init_role_run_placement();
|
|
15212
15850
|
init_compliance_transport();
|
|
15851
|
+
init_run_dossier();
|
|
15213
15852
|
init_unknown_value();
|
|
15214
15853
|
ADMITTED_PAGE_FIELDS = [
|
|
15215
15854
|
"runDirectory",
|
|
15216
15855
|
"admittedRequestPath",
|
|
15856
|
+
// pre-#1161 pages only
|
|
15217
15857
|
"sessionDirectory",
|
|
15218
15858
|
"sessionFile",
|
|
15219
15859
|
"taskPath",
|
|
@@ -15231,6 +15871,7 @@ var init_role_run_relocation = __esm({
|
|
|
15231
15871
|
RUN_STATE_PAGE_FIELDS = [
|
|
15232
15872
|
"runDirectory",
|
|
15233
15873
|
"admittedRequestPath",
|
|
15874
|
+
// pre-#1161 pages only
|
|
15234
15875
|
"sessionDirectory",
|
|
15235
15876
|
"sessionFile"
|
|
15236
15877
|
];
|
|
@@ -15243,14 +15884,6 @@ var init_role_run_relocation = __esm({
|
|
|
15243
15884
|
}
|
|
15244
15885
|
});
|
|
15245
15886
|
|
|
15246
|
-
// src/activation-ledger-git.ts
|
|
15247
|
-
var init_activation_ledger_git = __esm({
|
|
15248
|
-
"src/activation-ledger-git.ts"() {
|
|
15249
|
-
"use strict";
|
|
15250
|
-
init_unknown_value();
|
|
15251
|
-
}
|
|
15252
|
-
});
|
|
15253
|
-
|
|
15254
15887
|
// src/submission-correctable-error.ts
|
|
15255
15888
|
var correctableSubmissionErrorBrand, CorrectableSubmissionError;
|
|
15256
15889
|
var init_submission_correctable_error = __esm({
|
|
@@ -15341,33 +15974,6 @@ var init_ledger_session_read = __esm({
|
|
|
15341
15974
|
}
|
|
15342
15975
|
});
|
|
15343
15976
|
|
|
15344
|
-
// src/sitian-contracts.ts
|
|
15345
|
-
var init_sitian_contracts = __esm({
|
|
15346
|
-
"src/sitian-contracts.ts"() {
|
|
15347
|
-
"use strict";
|
|
15348
|
-
}
|
|
15349
|
-
});
|
|
15350
|
-
|
|
15351
|
-
// src/sitian-appender.ts
|
|
15352
|
-
var S4_SUBMISSION_LEDGER_KINDS;
|
|
15353
|
-
var init_sitian_appender = __esm({
|
|
15354
|
-
"src/sitian-appender.ts"() {
|
|
15355
|
-
"use strict";
|
|
15356
|
-
init_role_run_placement();
|
|
15357
|
-
init_run_ticket_number();
|
|
15358
|
-
init_activation_ledger_git();
|
|
15359
|
-
init_activation_ledger_topology();
|
|
15360
|
-
init_sitian_contracts();
|
|
15361
|
-
S4_SUBMISSION_LEDGER_KINDS = /* @__PURE__ */ new Set([
|
|
15362
|
-
"candidate",
|
|
15363
|
-
"roundContext",
|
|
15364
|
-
"outcome",
|
|
15365
|
-
"sealed",
|
|
15366
|
-
"post-seal-anomaly"
|
|
15367
|
-
]);
|
|
15368
|
-
}
|
|
15369
|
-
});
|
|
15370
|
-
|
|
15371
15977
|
// src/session-dialogue.ts
|
|
15372
15978
|
var init_session_dialogue = __esm({
|
|
15373
15979
|
"src/session-dialogue.ts"() {
|
|
@@ -15376,18 +15982,11 @@ var init_session_dialogue = __esm({
|
|
|
15376
15982
|
}
|
|
15377
15983
|
});
|
|
15378
15984
|
|
|
15379
|
-
// src/sitian-reader.ts
|
|
15380
|
-
var init_sitian_reader = __esm({
|
|
15381
|
-
"src/sitian-reader.ts"() {
|
|
15382
|
-
"use strict";
|
|
15383
|
-
init_unknown_value();
|
|
15384
|
-
}
|
|
15385
|
-
});
|
|
15386
|
-
|
|
15387
15985
|
// src/sitian-facade.ts
|
|
15388
15986
|
var init_sitian_facade = __esm({
|
|
15389
15987
|
"src/sitian-facade.ts"() {
|
|
15390
15988
|
"use strict";
|
|
15989
|
+
init_role_run_placement();
|
|
15391
15990
|
init_sitian_appender();
|
|
15392
15991
|
init_sitian_contracts();
|
|
15393
15992
|
init_sitian_appender();
|
|
@@ -15403,9 +16002,10 @@ var init_ticket_provenance = __esm({
|
|
|
15403
16002
|
init_ledger_session_read();
|
|
15404
16003
|
init_run_ticket_number();
|
|
15405
16004
|
init_role_run_placement();
|
|
15406
|
-
|
|
16005
|
+
init_run_dossier_files();
|
|
15407
16006
|
init_session_dialogue();
|
|
15408
16007
|
init_sitian_facade();
|
|
16008
|
+
init_sitian_reader();
|
|
15409
16009
|
init_ticket_provenance_contracts();
|
|
15410
16010
|
init_unknown_value();
|
|
15411
16011
|
}
|
|
@@ -16190,6 +16790,7 @@ var init_invocation = __esm({
|
|
|
16190
16790
|
init_packaged_role_registry();
|
|
16191
16791
|
init_run_ticket_number();
|
|
16192
16792
|
init_role_run_relocation();
|
|
16793
|
+
init_run_dossier();
|
|
16193
16794
|
init_doctor_evidence();
|
|
16194
16795
|
init_collector_config();
|
|
16195
16796
|
init_github_remote();
|
|
@@ -16209,7 +16810,7 @@ var init_invocation = __esm({
|
|
|
16209
16810
|
});
|
|
16210
16811
|
|
|
16211
16812
|
// src/public-cli/run-lifecycle.ts
|
|
16212
|
-
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";
|
|
16213
16814
|
function describeErrorIdentity(error) {
|
|
16214
16815
|
const candidate = error;
|
|
16215
16816
|
const name = typeof candidate?.name === "string" && candidate.name !== "" ? candidate.name : typeof error;
|
|
@@ -16258,6 +16859,7 @@ var init_run_lifecycle = __esm({
|
|
|
16258
16859
|
init_engine_material();
|
|
16259
16860
|
init_packaged_role_registry();
|
|
16260
16861
|
init_invocation();
|
|
16862
|
+
init_run_dossier();
|
|
16261
16863
|
init_unknown_value();
|
|
16262
16864
|
}
|
|
16263
16865
|
});
|
|
@@ -16356,12 +16958,12 @@ var require_isexe = __commonJS({
|
|
|
16356
16958
|
if (typeof Promise !== "function") {
|
|
16357
16959
|
throw new TypeError("callback not provided");
|
|
16358
16960
|
}
|
|
16359
|
-
return new Promise(function(
|
|
16961
|
+
return new Promise(function(resolve13, reject) {
|
|
16360
16962
|
isexe(path8, options || {}, function(er, is) {
|
|
16361
16963
|
if (er) {
|
|
16362
16964
|
reject(er);
|
|
16363
16965
|
} else {
|
|
16364
|
-
|
|
16966
|
+
resolve13(is);
|
|
16365
16967
|
}
|
|
16366
16968
|
});
|
|
16367
16969
|
});
|
|
@@ -16427,27 +17029,27 @@ var require_which = __commonJS({
|
|
|
16427
17029
|
opt = {};
|
|
16428
17030
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
16429
17031
|
const found = [];
|
|
16430
|
-
const step = (i2) => new Promise((
|
|
17032
|
+
const step = (i2) => new Promise((resolve13, reject) => {
|
|
16431
17033
|
if (i2 === pathEnv.length)
|
|
16432
|
-
return opt.all && found.length ?
|
|
17034
|
+
return opt.all && found.length ? resolve13(found) : reject(getNotFoundError(cmd));
|
|
16433
17035
|
const ppRaw = pathEnv[i2];
|
|
16434
17036
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
16435
17037
|
const pCmd = path8.join(pathPart, cmd);
|
|
16436
17038
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
16437
|
-
|
|
17039
|
+
resolve13(subStep(p, i2, 0));
|
|
16438
17040
|
});
|
|
16439
|
-
const subStep = (p, i2, ii) => new Promise((
|
|
17041
|
+
const subStep = (p, i2, ii) => new Promise((resolve13, reject) => {
|
|
16440
17042
|
if (ii === pathExt.length)
|
|
16441
|
-
return
|
|
17043
|
+
return resolve13(step(i2 + 1));
|
|
16442
17044
|
const ext2 = pathExt[ii];
|
|
16443
17045
|
isexe(p + ext2, { pathExt: pathExtExe }, (er, is) => {
|
|
16444
17046
|
if (!er && is) {
|
|
16445
17047
|
if (opt.all)
|
|
16446
17048
|
found.push(p + ext2);
|
|
16447
17049
|
else
|
|
16448
|
-
return
|
|
17050
|
+
return resolve13(p + ext2);
|
|
16449
17051
|
}
|
|
16450
|
-
return
|
|
17052
|
+
return resolve13(subStep(p, i2, ii + 1));
|
|
16451
17053
|
});
|
|
16452
17054
|
});
|
|
16453
17055
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -16769,7 +17371,7 @@ var init_child_process = __esm({
|
|
|
16769
17371
|
|
|
16770
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
|
|
16771
17373
|
import { homedir as homedir2 } from "node:os";
|
|
16772
|
-
import { isAbsolute as
|
|
17374
|
+
import { isAbsolute as isAbsolute3, join as join8, resolve as nodeResolvePath, relative as relative2, sep as sep3 } from "node:path";
|
|
16773
17375
|
import { fileURLToPath } from "node:url";
|
|
16774
17376
|
function normalizeWindowsShellPath(filePath) {
|
|
16775
17377
|
if (!filePath.startsWith("/") || filePath.startsWith("//") || filePath.includes("\\"))
|
|
@@ -16796,7 +17398,7 @@ function normalizePath(input, options = {}) {
|
|
|
16796
17398
|
if (normalized === "~")
|
|
16797
17399
|
return home;
|
|
16798
17400
|
if (normalized.startsWith("~/") || process.platform === "win32" && normalized.startsWith("~\\")) {
|
|
16799
|
-
return
|
|
17401
|
+
return join8(home, normalized.slice(2));
|
|
16800
17402
|
}
|
|
16801
17403
|
}
|
|
16802
17404
|
if (/^file:\/\//.test(normalized)) {
|
|
@@ -16825,22 +17427,22 @@ var init_text = __esm({
|
|
|
16825
17427
|
});
|
|
16826
17428
|
|
|
16827
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
|
|
16828
|
-
import { accessSync, constants, existsSync as
|
|
17430
|
+
import { accessSync, constants, existsSync, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "fs";
|
|
16829
17431
|
import { createRequire } from "module";
|
|
16830
17432
|
import { homedir as homedir3 } from "os";
|
|
16831
|
-
import { basename as
|
|
17433
|
+
import { basename as basename7, dirname as dirname7, join as join9, resolve as resolve4, sep as sep4, win32 } from "path";
|
|
16832
17434
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16833
17435
|
function findNodePackageDir(startDir) {
|
|
16834
17436
|
let dir = startDir;
|
|
16835
|
-
while (dir !==
|
|
16836
|
-
if (
|
|
16837
|
-
const parent =
|
|
16838
|
-
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"))) {
|
|
16839
17441
|
return parent;
|
|
16840
17442
|
}
|
|
16841
17443
|
return dir;
|
|
16842
17444
|
}
|
|
16843
|
-
dir =
|
|
17445
|
+
dir = dirname7(dir);
|
|
16844
17446
|
}
|
|
16845
17447
|
return startDir;
|
|
16846
17448
|
}
|
|
@@ -16850,12 +17452,12 @@ function getPackageDir() {
|
|
|
16850
17452
|
return normalizePath(envDir);
|
|
16851
17453
|
}
|
|
16852
17454
|
if (isBunBinary) {
|
|
16853
|
-
return
|
|
17455
|
+
return dirname7(process.execPath);
|
|
16854
17456
|
}
|
|
16855
17457
|
return findNodePackageDir(__dirname);
|
|
16856
17458
|
}
|
|
16857
17459
|
function getPackageJsonPath() {
|
|
16858
|
-
return
|
|
17460
|
+
return join9(getPackageDir(), "package.json");
|
|
16859
17461
|
}
|
|
16860
17462
|
function getQuickJSWasmPath() {
|
|
16861
17463
|
return embeddedQuickJSWasmPath ?? createRequire(import.meta.url).resolve("quickjs-wasi/quickjs.wasm");
|
|
@@ -16875,10 +17477,10 @@ function getAgentDir() {
|
|
|
16875
17477
|
if (envDir) {
|
|
16876
17478
|
return expandTildePath(envDir);
|
|
16877
17479
|
}
|
|
16878
|
-
return
|
|
17480
|
+
return join9(homedir3(), CONFIG_DIR_NAME, "agent");
|
|
16879
17481
|
}
|
|
16880
17482
|
function getBinDir() {
|
|
16881
|
-
return
|
|
17483
|
+
return join9(getAgentDir(), "bin");
|
|
16882
17484
|
}
|
|
16883
17485
|
var __filename2, __dirname, isBunBinary, isBunRuntime, isBundledNode, embeddedQuickJSWasmPath, pkg, piConfigName, PACKAGE_NAME, APP_NAME, CONFIG_DIR_NAME, VERSION, ENV_AGENT_DIR, ENV_SESSION_DIR;
|
|
16884
17486
|
var init_config3 = __esm({
|
|
@@ -16887,13 +17489,13 @@ var init_config3 = __esm({
|
|
|
16887
17489
|
init_paths();
|
|
16888
17490
|
init_text();
|
|
16889
17491
|
__filename2 = fileURLToPath2(import.meta.url);
|
|
16890
|
-
__dirname =
|
|
17492
|
+
__dirname = dirname7(__filename2);
|
|
16891
17493
|
isBunBinary = import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
|
|
16892
17494
|
isBunRuntime = !!process.versions.bun;
|
|
16893
17495
|
isBundledNode = typeof PI_BUNDLED_NODE !== "undefined" && PI_BUNDLED_NODE;
|
|
16894
17496
|
pkg = {};
|
|
16895
17497
|
try {
|
|
16896
|
-
pkg = JSON.parse(stripBom(
|
|
17498
|
+
pkg = JSON.parse(stripBom(readFileSync2(getPackageJsonPath(), "utf-8")));
|
|
16897
17499
|
} catch (e2) {
|
|
16898
17500
|
const err2 = e2;
|
|
16899
17501
|
if (err2.code !== "ENOENT")
|
|
@@ -24931,8 +25533,8 @@ var init_event_stream = __esm({
|
|
|
24931
25533
|
constructor(isComplete, extractResult) {
|
|
24932
25534
|
this.isComplete = isComplete;
|
|
24933
25535
|
this.extractResult = extractResult;
|
|
24934
|
-
this.finalResultPromise = new Promise((
|
|
24935
|
-
this.resolveFinalResult =
|
|
25536
|
+
this.finalResultPromise = new Promise((resolve13) => {
|
|
25537
|
+
this.resolveFinalResult = resolve13;
|
|
24936
25538
|
});
|
|
24937
25539
|
}
|
|
24938
25540
|
push(event) {
|
|
@@ -24966,7 +25568,7 @@ var init_event_stream = __esm({
|
|
|
24966
25568
|
} else if (this.done) {
|
|
24967
25569
|
return;
|
|
24968
25570
|
} else {
|
|
24969
|
-
const result = await new Promise((
|
|
25571
|
+
const result = await new Promise((resolve13) => this.waiting.enqueue(resolve13));
|
|
24970
25572
|
if (result.done)
|
|
24971
25573
|
return;
|
|
24972
25574
|
yield result.value;
|
|
@@ -25119,7 +25721,7 @@ function raceWithAbortSignal(operation, signal) {
|
|
|
25119
25721
|
});
|
|
25120
25722
|
return Promise.reject(abortReason(signal));
|
|
25121
25723
|
}
|
|
25122
|
-
return new Promise((
|
|
25724
|
+
return new Promise((resolve13, reject) => {
|
|
25123
25725
|
let settled = false;
|
|
25124
25726
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
25125
25727
|
const onAbort = () => {
|
|
@@ -25135,7 +25737,7 @@ function raceWithAbortSignal(operation, signal) {
|
|
|
25135
25737
|
return;
|
|
25136
25738
|
settled = true;
|
|
25137
25739
|
cleanup();
|
|
25138
|
-
|
|
25740
|
+
resolve13(value2);
|
|
25139
25741
|
}, (error) => {
|
|
25140
25742
|
if (settled)
|
|
25141
25743
|
return;
|
|
@@ -26168,8 +26770,8 @@ var init_models = __esm({
|
|
|
26168
26770
|
const credential = await raceWithAbortSignal(loginOperation, signal);
|
|
26169
26771
|
let mutationStarted = false;
|
|
26170
26772
|
let markMutationStarted;
|
|
26171
|
-
const started = new Promise((
|
|
26172
|
-
markMutationStarted =
|
|
26773
|
+
const started = new Promise((resolve13) => {
|
|
26774
|
+
markMutationStarted = resolve13;
|
|
26173
26775
|
});
|
|
26174
26776
|
const mutation = this.credentials.modify(providerId, async () => {
|
|
26175
26777
|
mutationStarted = true;
|
|
@@ -26179,7 +26781,7 @@ var init_models = __esm({
|
|
|
26179
26781
|
void mutation.catch(() => {
|
|
26180
26782
|
});
|
|
26181
26783
|
try {
|
|
26182
|
-
await new Promise((
|
|
26784
|
+
await new Promise((resolve13, reject) => {
|
|
26183
26785
|
const onAbort = () => {
|
|
26184
26786
|
if (!mutationStarted)
|
|
26185
26787
|
reject(signal.reason);
|
|
@@ -26187,7 +26789,7 @@ var init_models = __esm({
|
|
|
26187
26789
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
26188
26790
|
void Promise.race([started, mutation]).then(() => {
|
|
26189
26791
|
signal.removeEventListener("abort", onAbort);
|
|
26190
|
-
|
|
26792
|
+
resolve13();
|
|
26191
26793
|
}, (error) => {
|
|
26192
26794
|
signal.removeEventListener("abort", onAbort);
|
|
26193
26795
|
reject(error);
|
|
@@ -42111,13 +42713,13 @@ var require_ignore = __commonJS({
|
|
|
42111
42713
|
const rules = this._rules;
|
|
42112
42714
|
const { length } = rules;
|
|
42113
42715
|
const shortcut = this._basenameCount * 2 >= length;
|
|
42114
|
-
const
|
|
42716
|
+
const basename15 = shortcut ? basenameOf(path8) : path8;
|
|
42115
42717
|
for (let index3 = 0; index3 < length; index3++) {
|
|
42116
42718
|
const rule = rules[index3];
|
|
42117
42719
|
const { negative } = rule;
|
|
42118
42720
|
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
42119
42721
|
if (!skip && rule[mode].test(
|
|
42120
|
-
shortcut && rule._basenameOnly ?
|
|
42722
|
+
shortcut && rule._basenameOnly ? basename15 : path8
|
|
42121
42723
|
)) {
|
|
42122
42724
|
ignored = !negative;
|
|
42123
42725
|
unignored = negative;
|
|
@@ -43080,16 +43682,16 @@ var init_values2 = __esm({
|
|
|
43080
43682
|
var sleep;
|
|
43081
43683
|
var init_sleep = __esm({
|
|
43082
43684
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.124.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
|
|
43083
|
-
sleep = (ms, signal) => new Promise((
|
|
43685
|
+
sleep = (ms, signal) => new Promise((resolve13) => {
|
|
43084
43686
|
if (signal?.aborted)
|
|
43085
|
-
return
|
|
43687
|
+
return resolve13();
|
|
43086
43688
|
const onAbort = () => {
|
|
43087
43689
|
clearTimeout(timer);
|
|
43088
|
-
|
|
43690
|
+
resolve13();
|
|
43089
43691
|
};
|
|
43090
43692
|
const timer = setTimeout(() => {
|
|
43091
43693
|
signal?.removeEventListener("abort", onAbort);
|
|
43092
|
-
|
|
43694
|
+
resolve13();
|
|
43093
43695
|
}, ms);
|
|
43094
43696
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
43095
43697
|
});
|
|
@@ -45261,8 +45863,8 @@ var init_api_promise = __esm({
|
|
|
45261
45863
|
init_parse7();
|
|
45262
45864
|
APIPromise = class _APIPromise extends Promise {
|
|
45263
45865
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
45264
|
-
super((
|
|
45265
|
-
|
|
45866
|
+
super((resolve13) => {
|
|
45867
|
+
resolve13(null);
|
|
45266
45868
|
});
|
|
45267
45869
|
this.responsePromise = responsePromise;
|
|
45268
45870
|
this.parseResponse = parseResponse2;
|
|
@@ -47901,16 +48503,16 @@ var init_async_queue = __esm({
|
|
|
47901
48503
|
if (__classPrivateFieldGet3(this, _AsyncQueue_closed, "f") || signal?.aborted) {
|
|
47902
48504
|
return Promise.resolve({ done: true, value: void 0 });
|
|
47903
48505
|
}
|
|
47904
|
-
return new Promise((
|
|
48506
|
+
return new Promise((resolve13) => {
|
|
47905
48507
|
const waiter = (r2) => {
|
|
47906
48508
|
signal?.removeEventListener("abort", onAbort);
|
|
47907
|
-
|
|
48509
|
+
resolve13(r2);
|
|
47908
48510
|
};
|
|
47909
48511
|
const onAbort = () => {
|
|
47910
48512
|
const idx = __classPrivateFieldGet3(this, _AsyncQueue_waiters, "f").indexOf(waiter);
|
|
47911
48513
|
if (idx >= 0)
|
|
47912
48514
|
__classPrivateFieldGet3(this, _AsyncQueue_waiters, "f").splice(idx, 1);
|
|
47913
|
-
|
|
48515
|
+
resolve13({ done: true, value: void 0 });
|
|
47914
48516
|
};
|
|
47915
48517
|
__classPrivateFieldGet3(this, _AsyncQueue_waiters, "f").push(waiter);
|
|
47916
48518
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -48544,13 +49146,13 @@ var init_json_schema = __esm({
|
|
|
48544
49146
|
|
|
48545
49147
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.124.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs
|
|
48546
49148
|
function promiseWithResolvers() {
|
|
48547
|
-
let
|
|
49149
|
+
let resolve13;
|
|
48548
49150
|
let reject;
|
|
48549
49151
|
const promise = new Promise((res, rej) => {
|
|
48550
|
-
|
|
49152
|
+
resolve13 = res;
|
|
48551
49153
|
reject = rej;
|
|
48552
49154
|
});
|
|
48553
|
-
return { promise, resolve:
|
|
49155
|
+
return { promise, resolve: resolve13, reject };
|
|
48554
49156
|
}
|
|
48555
49157
|
var init_promise = __esm({
|
|
48556
49158
|
"node_modules/.pnpm/@anthropic-ai+sdk@0.124.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/internal/utils/promise.mjs"() {
|
|
@@ -48702,10 +49304,10 @@ async function setupSkills(ctx) {
|
|
|
48702
49304
|
for (const skill of session.agent.skills) {
|
|
48703
49305
|
try {
|
|
48704
49306
|
const version = await client.beta.skills.versions.retrieve(skill.version, { skill_id: skill.skill_id });
|
|
48705
|
-
let
|
|
48706
|
-
if (
|
|
48707
|
-
|
|
48708
|
-
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);
|
|
48709
49311
|
if (dest !== skillsRoot && !dest.startsWith(skillsRoot + path.sep)) {
|
|
48710
49312
|
log.warn("skill name escapes the skills dir; skipping", {
|
|
48711
49313
|
component: "agent-tool-context",
|
|
@@ -49339,10 +49941,10 @@ async function settledOrAborted(p, signal) {
|
|
|
49339
49941
|
return;
|
|
49340
49942
|
}
|
|
49341
49943
|
let onAbort;
|
|
49342
|
-
const aborted = new Promise((
|
|
49343
|
-
onAbort =
|
|
49944
|
+
const aborted = new Promise((resolve13) => {
|
|
49945
|
+
onAbort = resolve13;
|
|
49344
49946
|
if (signal.aborted)
|
|
49345
|
-
|
|
49947
|
+
resolve13();
|
|
49346
49948
|
});
|
|
49347
49949
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
49348
49950
|
try {
|
|
@@ -50406,7 +51008,7 @@ function betaGrepTool(ctx) {
|
|
|
50406
51008
|
});
|
|
50407
51009
|
}
|
|
50408
51010
|
function runRipgrep(rg, pattern, searchPath, signal) {
|
|
50409
|
-
return new Promise((
|
|
51011
|
+
return new Promise((resolve13, reject) => {
|
|
50410
51012
|
const proc = cp.spawn(rg, ["-n", "--no-heading", "-e", pattern, "--", searchPath], {
|
|
50411
51013
|
...signal ? { signal } : {}
|
|
50412
51014
|
});
|
|
@@ -50428,12 +51030,12 @@ function runRipgrep(rg, pattern, searchPath, signal) {
|
|
|
50428
51030
|
if (signal?.aborted)
|
|
50429
51031
|
return reject(new ToolError("grep: aborted"));
|
|
50430
51032
|
if (truncated)
|
|
50431
|
-
return
|
|
51033
|
+
return resolve13(out + `
|
|
50432
51034
|
[output truncated at ${GREP_OUTPUT_LIMIT} bytes]`);
|
|
50433
51035
|
if (code === 0)
|
|
50434
|
-
return
|
|
51036
|
+
return resolve13(out);
|
|
50435
51037
|
if (code === 1)
|
|
50436
|
-
return
|
|
51038
|
+
return resolve13("no matches");
|
|
50437
51039
|
reject(new ToolError(`grep: rg failed: ${errOut || `exit ${code}`}`));
|
|
50438
51040
|
});
|
|
50439
51041
|
proc.on("error", (e2) => {
|
|
@@ -50614,8 +51216,8 @@ var init_node2 = __esm({
|
|
|
50614
51216
|
`;
|
|
50615
51217
|
__classPrivateFieldGet3(this, _BashSession_proc, "f").stdin.write(wrapped);
|
|
50616
51218
|
if (__classPrivateFieldGet3(this, _BashSession_buf, "f").indexOf(sentinel3) < 0) {
|
|
50617
|
-
const { promise: sentinelSeen, resolve:
|
|
50618
|
-
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel3, resolve:
|
|
51219
|
+
const { promise: sentinelSeen, resolve: resolve13 } = promiseWithResolvers();
|
|
51220
|
+
__classPrivateFieldSet(this, _BashSession_waiting, { sentinel: sentinel3, resolve: resolve13 }, "f");
|
|
50619
51221
|
let timer;
|
|
50620
51222
|
let onAbort;
|
|
50621
51223
|
try {
|
|
@@ -50772,8 +51374,8 @@ async function withTimeout(p, ms) {
|
|
|
50772
51374
|
try {
|
|
50773
51375
|
return await Promise.race([
|
|
50774
51376
|
p.then(() => false, () => false),
|
|
50775
|
-
new Promise((
|
|
50776
|
-
timer = setTimeout(() =>
|
|
51377
|
+
new Promise((resolve13) => {
|
|
51378
|
+
timer = setTimeout(() => resolve13(true), ms);
|
|
50777
51379
|
})
|
|
50778
51380
|
]);
|
|
50779
51381
|
} finally {
|
|
@@ -52677,12 +53279,12 @@ var init_BetaMessageStream = __esm({
|
|
|
52677
53279
|
}
|
|
52678
53280
|
return this._emit("error", new AnthropicError(String(error)));
|
|
52679
53281
|
});
|
|
52680
|
-
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
52681
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise,
|
|
53282
|
+
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve13, reject) => {
|
|
53283
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve13, "f");
|
|
52682
53284
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
52683
53285
|
}), "f");
|
|
52684
|
-
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((
|
|
52685
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise,
|
|
53286
|
+
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve13, reject) => {
|
|
53287
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve13, "f");
|
|
52686
53288
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
52687
53289
|
}), "f");
|
|
52688
53290
|
__classPrivateFieldGet3(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -52857,11 +53459,11 @@ var init_BetaMessageStream = __esm({
|
|
|
52857
53459
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
52858
53460
|
*/
|
|
52859
53461
|
emitted(event) {
|
|
52860
|
-
return new Promise((
|
|
53462
|
+
return new Promise((resolve13, reject) => {
|
|
52861
53463
|
__classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
|
|
52862
53464
|
if (event !== "error")
|
|
52863
53465
|
this.once("error", reject);
|
|
52864
|
-
this.once(event,
|
|
53466
|
+
this.once(event, resolve13);
|
|
52865
53467
|
});
|
|
52866
53468
|
}
|
|
52867
53469
|
async done() {
|
|
@@ -53234,7 +53836,7 @@ var init_BetaMessageStream = __esm({
|
|
|
53234
53836
|
if (done) {
|
|
53235
53837
|
return { value: void 0, done: true };
|
|
53236
53838
|
}
|
|
53237
|
-
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 });
|
|
53238
53840
|
}
|
|
53239
53841
|
const chunk = pushQueue.shift();
|
|
53240
53842
|
return { value: chunk, done: false };
|
|
@@ -57515,12 +58117,12 @@ var init_MessageStream = __esm({
|
|
|
57515
58117
|
}
|
|
57516
58118
|
return this._emit("error", new AnthropicError(String(error)));
|
|
57517
58119
|
});
|
|
57518
|
-
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((
|
|
57519
|
-
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise,
|
|
58120
|
+
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve13, reject) => {
|
|
58121
|
+
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve13, "f");
|
|
57520
58122
|
__classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
57521
58123
|
}), "f");
|
|
57522
|
-
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((
|
|
57523
|
-
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise,
|
|
58124
|
+
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve13, reject) => {
|
|
58125
|
+
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve13, "f");
|
|
57524
58126
|
__classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
57525
58127
|
}), "f");
|
|
57526
58128
|
__classPrivateFieldGet3(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -57695,11 +58297,11 @@ var init_MessageStream = __esm({
|
|
|
57695
58297
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
57696
58298
|
*/
|
|
57697
58299
|
emitted(event) {
|
|
57698
|
-
return new Promise((
|
|
58300
|
+
return new Promise((resolve13, reject) => {
|
|
57699
58301
|
__classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
57700
58302
|
if (event !== "error")
|
|
57701
58303
|
this.once("error", reject);
|
|
57702
|
-
this.once(event,
|
|
58304
|
+
this.once(event, resolve13);
|
|
57703
58305
|
});
|
|
57704
58306
|
}
|
|
57705
58307
|
async done() {
|
|
@@ -58024,7 +58626,7 @@ var init_MessageStream = __esm({
|
|
|
58024
58626
|
if (done) {
|
|
58025
58627
|
return { value: void 0, done: true };
|
|
58026
58628
|
}
|
|
58027
|
-
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 });
|
|
58028
58630
|
}
|
|
58029
58631
|
const chunk = pushQueue.shift();
|
|
58030
58632
|
return { value: chunk, done: false };
|
|
@@ -59530,8 +60132,8 @@ function getBunSandboxEnvValue(name) {
|
|
|
59530
60132
|
if (procEnvCache === null) {
|
|
59531
60133
|
procEnvCache = /* @__PURE__ */ new Map();
|
|
59532
60134
|
try {
|
|
59533
|
-
const { readFileSync:
|
|
59534
|
-
const data =
|
|
60135
|
+
const { readFileSync: readFileSync5 } = __require("node:fs");
|
|
60136
|
+
const data = readFileSync5("/proc/self/environ", "utf-8");
|
|
59535
60137
|
for (const entry of data.split("\0")) {
|
|
59536
60138
|
const idx = entry.indexOf("=");
|
|
59537
60139
|
if (idx > 0) {
|
|
@@ -59598,7 +60200,7 @@ function createAbortError() {
|
|
|
59598
60200
|
return error;
|
|
59599
60201
|
}
|
|
59600
60202
|
function abortableSleep(ms, signal) {
|
|
59601
|
-
return new Promise((
|
|
60203
|
+
return new Promise((resolve13, reject) => {
|
|
59602
60204
|
if (signal?.aborted) {
|
|
59603
60205
|
reject(createAbortError());
|
|
59604
60206
|
return;
|
|
@@ -59609,7 +60211,7 @@ function abortableSleep(ms, signal) {
|
|
|
59609
60211
|
};
|
|
59610
60212
|
const timeout = setTimeout(() => {
|
|
59611
60213
|
signal?.removeEventListener("abort", onAbort);
|
|
59612
|
-
|
|
60214
|
+
resolve13();
|
|
59613
60215
|
}, Math.max(0, ms));
|
|
59614
60216
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
59615
60217
|
});
|
|
@@ -61582,7 +62184,7 @@ var init_values3 = __esm({
|
|
|
61582
62184
|
var sleep2;
|
|
61583
62185
|
var init_sleep2 = __esm({
|
|
61584
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"() {
|
|
61585
|
-
sleep2 = (ms, ...signals) => new Promise((
|
|
62187
|
+
sleep2 = (ms, ...signals) => new Promise((resolve13, reject) => {
|
|
61586
62188
|
const activeSignals = [...new Set(signals.filter((signal) => signal != null))];
|
|
61587
62189
|
let timeout;
|
|
61588
62190
|
let settled = false;
|
|
@@ -61614,7 +62216,7 @@ var init_sleep2 = __esm({
|
|
|
61614
62216
|
return;
|
|
61615
62217
|
}
|
|
61616
62218
|
timeout = setTimeout(() => {
|
|
61617
|
-
settle(
|
|
62219
|
+
settle(resolve13);
|
|
61618
62220
|
}, ms);
|
|
61619
62221
|
for (const signal of activeSignals) {
|
|
61620
62222
|
if (settled) {
|
|
@@ -62156,8 +62758,8 @@ function createAbortableSSESource(body, signal) {
|
|
|
62156
62758
|
let interrupt;
|
|
62157
62759
|
const waitForAbort = () => (
|
|
62158
62760
|
// oxlint-disable-next-line promise/avoid-new -- AbortSignal callbacks need a portable Promise bridge.
|
|
62159
|
-
new Promise((
|
|
62160
|
-
interrupt =
|
|
62761
|
+
new Promise((resolve13) => {
|
|
62762
|
+
interrupt = resolve13;
|
|
62161
62763
|
})
|
|
62162
62764
|
);
|
|
62163
62765
|
const cancel = () => {
|
|
@@ -63429,8 +64031,8 @@ var init_api_promise2 = __esm({
|
|
|
63429
64031
|
init_parse8();
|
|
63430
64032
|
APIPromise2 = class _APIPromise extends Promise {
|
|
63431
64033
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
63432
|
-
super((
|
|
63433
|
-
|
|
64034
|
+
super((resolve13) => {
|
|
64035
|
+
resolve13(null);
|
|
63434
64036
|
});
|
|
63435
64037
|
this.responsePromise = responsePromise;
|
|
63436
64038
|
this.parseResponse = parseResponse2;
|
|
@@ -64954,20 +65556,20 @@ function getName2(value2, options) {
|
|
|
64954
65556
|
const name = "name" in value2 ? value2.name : void 0;
|
|
64955
65557
|
const explicitName = name && String(name) || "filename" in value2 && value2.filename && String(value2.filename);
|
|
64956
65558
|
if (explicitName) {
|
|
64957
|
-
return options?.stripFilename === false ? normalizeFilenamePath(explicitName) :
|
|
65559
|
+
return options?.stripFilename === false ? normalizeFilenamePath(explicitName) : basename8(explicitName);
|
|
64958
65560
|
}
|
|
64959
65561
|
const url = "url" in value2 && value2.url && String(value2.url);
|
|
64960
65562
|
if (url) {
|
|
64961
65563
|
try {
|
|
64962
|
-
return
|
|
65564
|
+
return basename8(new URL(url).pathname);
|
|
64963
65565
|
} catch {
|
|
64964
|
-
return
|
|
65566
|
+
return basename8(url);
|
|
64965
65567
|
}
|
|
64966
65568
|
}
|
|
64967
65569
|
const path8 = "path" in value2 && value2.path && String(value2.path);
|
|
64968
|
-
return path8 ?
|
|
65570
|
+
return path8 ? basename8(path8) : void 0;
|
|
64969
65571
|
}
|
|
64970
|
-
function
|
|
65572
|
+
function basename8(value2) {
|
|
64971
65573
|
return value2.split(/[\\/]/).pop() || void 0;
|
|
64972
65574
|
}
|
|
64973
65575
|
function normalizeFilenamePath(value2) {
|
|
@@ -65071,7 +65673,7 @@ function getStreamingFileName(value2, options) {
|
|
|
65071
65673
|
if (typeof name !== "string" || !name) {
|
|
65072
65674
|
throw new TypeError("Streaming upload file name must be a non-empty string");
|
|
65073
65675
|
}
|
|
65074
|
-
return options.stripFilenames === false ? normalizeFilenamePath(name) :
|
|
65676
|
+
return options.stripFilenames === false ? normalizeFilenamePath(name) : basename8(name) ?? "unknown_file";
|
|
65075
65677
|
}
|
|
65076
65678
|
return getName2(value2, { stripFilename: options.stripFilenames }) ?? "unknown_file";
|
|
65077
65679
|
}
|
|
@@ -66524,12 +67126,12 @@ var init_EventStream = __esm({
|
|
|
66524
67126
|
_EventStream_aborted.set(this, false);
|
|
66525
67127
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
66526
67128
|
_EventStream_terminalFailure.set(this, void 0);
|
|
66527
|
-
__classPrivateFieldSet2(this, _EventStream_connectedPromise, new Promise((
|
|
66528
|
-
__classPrivateFieldSet2(this, _EventStream_resolveConnectedPromise,
|
|
67129
|
+
__classPrivateFieldSet2(this, _EventStream_connectedPromise, new Promise((resolve13, reject) => {
|
|
67130
|
+
__classPrivateFieldSet2(this, _EventStream_resolveConnectedPromise, resolve13, "f");
|
|
66529
67131
|
__classPrivateFieldSet2(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
66530
67132
|
}), "f");
|
|
66531
|
-
__classPrivateFieldSet2(this, _EventStream_endPromise, new Promise((
|
|
66532
|
-
__classPrivateFieldSet2(this, _EventStream_resolveEndPromise,
|
|
67133
|
+
__classPrivateFieldSet2(this, _EventStream_endPromise, new Promise((resolve13, reject) => {
|
|
67134
|
+
__classPrivateFieldSet2(this, _EventStream_resolveEndPromise, resolve13, "f");
|
|
66533
67135
|
__classPrivateFieldSet2(this, _EventStream_rejectEndPromise, reject, "f");
|
|
66534
67136
|
}), "f");
|
|
66535
67137
|
__classPrivateFieldGet4(this, _EventStream_connectedPromise, "f").catch(() => void 0);
|
|
@@ -66667,7 +67269,7 @@ var init_EventStream = __esm({
|
|
|
66667
67269
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
66668
67270
|
*/
|
|
66669
67271
|
emitted(event) {
|
|
66670
|
-
return new Promise((
|
|
67272
|
+
return new Promise((resolve13, reject) => {
|
|
66671
67273
|
__classPrivateFieldSet2(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
66672
67274
|
const onError = (error) => {
|
|
66673
67275
|
this.off(event, onEvent);
|
|
@@ -66677,7 +67279,7 @@ var init_EventStream = __esm({
|
|
|
66677
67279
|
if (event !== "error") {
|
|
66678
67280
|
this.off("error", onError);
|
|
66679
67281
|
}
|
|
66680
|
-
|
|
67282
|
+
resolve13(values.length > 1 ? values : values[0]);
|
|
66681
67283
|
};
|
|
66682
67284
|
if (event !== "error") {
|
|
66683
67285
|
__classPrivateFieldGet4(this, _EventStream_instances, "m", _EventStream_onceForEmitted).call(this, "error", onError);
|
|
@@ -66893,8 +67495,8 @@ var init_EventStream = __esm({
|
|
|
66893
67495
|
if (ended) {
|
|
66894
67496
|
return Promise.resolve(doneResult());
|
|
66895
67497
|
}
|
|
66896
|
-
return new Promise((
|
|
66897
|
-
readQueue.enqueue({ resolve:
|
|
67498
|
+
return new Promise((resolve13, reject) => {
|
|
67499
|
+
readQueue.enqueue({ resolve: resolve13, reject });
|
|
66898
67500
|
});
|
|
66899
67501
|
},
|
|
66900
67502
|
return: () => {
|
|
@@ -73046,8 +73648,8 @@ var init_agent_session_stream = __esm({
|
|
|
73046
73648
|
try {
|
|
73047
73649
|
await __classPrivateFieldGet4(this, _AgentSessionStream_instances, "m", _AgentSessionStream_wait).call(this, () => (
|
|
73048
73650
|
// oxlint-disable-next-line promise/avoid-new -- Own the registration timer so cancellation clears it promptly.
|
|
73049
|
-
new Promise((
|
|
73050
|
-
timer = setTimeout(
|
|
73651
|
+
new Promise((resolve13) => {
|
|
73652
|
+
timer = setTimeout(resolve13, delay2);
|
|
73051
73653
|
})
|
|
73052
73654
|
));
|
|
73053
73655
|
} finally {
|
|
@@ -75530,7 +76132,7 @@ var init_AssistantStream = __esm({
|
|
|
75530
76132
|
|
|
75531
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
|
|
75532
76134
|
function sleepUntilAborted(milliseconds, signal) {
|
|
75533
|
-
return new Promise((
|
|
76135
|
+
return new Promise((resolve13, reject) => {
|
|
75534
76136
|
let timer;
|
|
75535
76137
|
let registered;
|
|
75536
76138
|
let settled = false;
|
|
@@ -75579,7 +76181,7 @@ function sleepUntilAborted(milliseconds, signal) {
|
|
|
75579
76181
|
}
|
|
75580
76182
|
settled = true;
|
|
75581
76183
|
cleanup();
|
|
75582
|
-
|
|
76184
|
+
resolve13();
|
|
75583
76185
|
}, milliseconds);
|
|
75584
76186
|
registered = abort;
|
|
75585
76187
|
try {
|
|
@@ -82842,7 +83444,7 @@ var require_p_retry = __commonJS({
|
|
|
82842
83444
|
return error;
|
|
82843
83445
|
};
|
|
82844
83446
|
var isNetworkError = (errorMessage5) => networkErrorMsgs.includes(errorMessage5);
|
|
82845
|
-
var pRetry2 = (input, options) => new Promise((
|
|
83447
|
+
var pRetry2 = (input, options) => new Promise((resolve13, reject) => {
|
|
82846
83448
|
options = {
|
|
82847
83449
|
onFailedAttempt: () => {
|
|
82848
83450
|
},
|
|
@@ -82852,7 +83454,7 @@ var require_p_retry = __commonJS({
|
|
|
82852
83454
|
const operation = retry2.operation(options);
|
|
82853
83455
|
operation.attempt(async (attemptNumber) => {
|
|
82854
83456
|
try {
|
|
82855
|
-
|
|
83457
|
+
resolve13(await input(attemptNumber));
|
|
82856
83458
|
} catch (error) {
|
|
82857
83459
|
if (!(error instanceof Error)) {
|
|
82858
83460
|
reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
|
|
@@ -83386,8 +83988,8 @@ var require_retry3 = __commonJS({
|
|
|
83386
83988
|
}
|
|
83387
83989
|
const delay2 = getNextRetryDelay(config);
|
|
83388
83990
|
err2.config.retryConfig.currentRetryAttempt += 1;
|
|
83389
|
-
const backoff3 = config.retryBackoff ? config.retryBackoff(err2, delay2) : new Promise((
|
|
83390
|
-
setTimeout(
|
|
83991
|
+
const backoff3 = config.retryBackoff ? config.retryBackoff(err2, delay2) : new Promise((resolve13) => {
|
|
83992
|
+
setTimeout(resolve13, delay2);
|
|
83391
83993
|
});
|
|
83392
83994
|
if (config.onRetryAttempt) {
|
|
83393
83995
|
await config.onRetryAttempt(err2);
|
|
@@ -84163,8 +84765,8 @@ var require_helpers = __commonJS({
|
|
|
84163
84765
|
function req(url, opts = {}) {
|
|
84164
84766
|
const href = typeof url === "string" ? url : url.href;
|
|
84165
84767
|
const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts);
|
|
84166
|
-
const promise = new Promise((
|
|
84167
|
-
req2.once("response",
|
|
84768
|
+
const promise = new Promise((resolve13, reject) => {
|
|
84769
|
+
req2.once("response", resolve13).once("error", reject).end();
|
|
84168
84770
|
});
|
|
84169
84771
|
req2.then = promise.then.bind(promise);
|
|
84170
84772
|
return req2;
|
|
@@ -84341,7 +84943,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
84341
84943
|
var debug_1 = __importDefault(require_src());
|
|
84342
84944
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
84343
84945
|
function parseProxyResponse(socket) {
|
|
84344
|
-
return new Promise((
|
|
84946
|
+
return new Promise((resolve13, reject) => {
|
|
84345
84947
|
let buffersLength = 0;
|
|
84346
84948
|
const buffers = [];
|
|
84347
84949
|
function read() {
|
|
@@ -84407,7 +85009,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
84407
85009
|
}
|
|
84408
85010
|
debug("got proxy server response: %o %o", firstLine2, headers);
|
|
84409
85011
|
cleanup();
|
|
84410
|
-
|
|
85012
|
+
resolve13({
|
|
84411
85013
|
connect: {
|
|
84412
85014
|
statusCode,
|
|
84413
85015
|
statusText,
|
|
@@ -84649,7 +85251,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
84649
85251
|
return new originalPromise(executor);
|
|
84650
85252
|
}
|
|
84651
85253
|
function promiseResolvedWith(value2) {
|
|
84652
|
-
return newPromise((
|
|
85254
|
+
return newPromise((resolve13) => resolve13(value2));
|
|
84653
85255
|
}
|
|
84654
85256
|
function promiseRejectedWith(reason) {
|
|
84655
85257
|
return originalPromiseReject(reason);
|
|
@@ -84819,8 +85421,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
84819
85421
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
84820
85422
|
}
|
|
84821
85423
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
84822
|
-
reader._closedPromise = newPromise((
|
|
84823
|
-
reader._closedPromise_resolve =
|
|
85424
|
+
reader._closedPromise = newPromise((resolve13, reject) => {
|
|
85425
|
+
reader._closedPromise_resolve = resolve13;
|
|
84824
85426
|
reader._closedPromise_reject = reject;
|
|
84825
85427
|
});
|
|
84826
85428
|
}
|
|
@@ -84994,8 +85596,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
84994
85596
|
}
|
|
84995
85597
|
let resolvePromise;
|
|
84996
85598
|
let rejectPromise;
|
|
84997
|
-
const promise = newPromise((
|
|
84998
|
-
resolvePromise =
|
|
85599
|
+
const promise = newPromise((resolve13, reject) => {
|
|
85600
|
+
resolvePromise = resolve13;
|
|
84999
85601
|
rejectPromise = reject;
|
|
85000
85602
|
});
|
|
85001
85603
|
const readRequest = {
|
|
@@ -85100,8 +85702,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
85100
85702
|
const reader = this._reader;
|
|
85101
85703
|
let resolvePromise;
|
|
85102
85704
|
let rejectPromise;
|
|
85103
|
-
const promise = newPromise((
|
|
85104
|
-
resolvePromise =
|
|
85705
|
+
const promise = newPromise((resolve13, reject) => {
|
|
85706
|
+
resolvePromise = resolve13;
|
|
85105
85707
|
rejectPromise = reject;
|
|
85106
85708
|
});
|
|
85107
85709
|
const readRequest = {
|
|
@@ -86120,8 +86722,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86120
86722
|
}
|
|
86121
86723
|
let resolvePromise;
|
|
86122
86724
|
let rejectPromise;
|
|
86123
|
-
const promise = newPromise((
|
|
86124
|
-
resolvePromise =
|
|
86725
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86726
|
+
resolvePromise = resolve13;
|
|
86125
86727
|
rejectPromise = reject;
|
|
86126
86728
|
});
|
|
86127
86729
|
const readIntoRequest = {
|
|
@@ -86433,10 +87035,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86433
87035
|
wasAlreadyErroring = true;
|
|
86434
87036
|
reason = void 0;
|
|
86435
87037
|
}
|
|
86436
|
-
const promise = newPromise((
|
|
87038
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86437
87039
|
stream12._pendingAbortRequest = {
|
|
86438
87040
|
_promise: void 0,
|
|
86439
|
-
_resolve:
|
|
87041
|
+
_resolve: resolve13,
|
|
86440
87042
|
_reject: reject,
|
|
86441
87043
|
_reason: reason,
|
|
86442
87044
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -86453,9 +87055,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86453
87055
|
if (state3 === "closed" || state3 === "errored") {
|
|
86454
87056
|
return promiseRejectedWith(new TypeError(`The stream (in ${state3} state) is not in the writable state and cannot be closed`));
|
|
86455
87057
|
}
|
|
86456
|
-
const promise = newPromise((
|
|
87058
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86457
87059
|
const closeRequest = {
|
|
86458
|
-
_resolve:
|
|
87060
|
+
_resolve: resolve13,
|
|
86459
87061
|
_reject: reject
|
|
86460
87062
|
};
|
|
86461
87063
|
stream12._closeRequest = closeRequest;
|
|
@@ -86468,9 +87070,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
86468
87070
|
return promise;
|
|
86469
87071
|
}
|
|
86470
87072
|
function WritableStreamAddWriteRequest(stream12) {
|
|
86471
|
-
const promise = newPromise((
|
|
87073
|
+
const promise = newPromise((resolve13, reject) => {
|
|
86472
87074
|
const writeRequest = {
|
|
86473
|
-
_resolve:
|
|
87075
|
+
_resolve: resolve13,
|
|
86474
87076
|
_reject: reject
|
|
86475
87077
|
};
|
|
86476
87078
|
stream12._writeRequests.push(writeRequest);
|
|
@@ -87086,8 +87688,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87086
87688
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
87087
87689
|
}
|
|
87088
87690
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
87089
|
-
writer._closedPromise = newPromise((
|
|
87090
|
-
writer._closedPromise_resolve =
|
|
87691
|
+
writer._closedPromise = newPromise((resolve13, reject) => {
|
|
87692
|
+
writer._closedPromise_resolve = resolve13;
|
|
87091
87693
|
writer._closedPromise_reject = reject;
|
|
87092
87694
|
writer._closedPromiseState = "pending";
|
|
87093
87695
|
});
|
|
@@ -87123,8 +87725,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87123
87725
|
writer._closedPromiseState = "resolved";
|
|
87124
87726
|
}
|
|
87125
87727
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
87126
|
-
writer._readyPromise = newPromise((
|
|
87127
|
-
writer._readyPromise_resolve =
|
|
87728
|
+
writer._readyPromise = newPromise((resolve13, reject) => {
|
|
87729
|
+
writer._readyPromise_resolve = resolve13;
|
|
87128
87730
|
writer._readyPromise_reject = reject;
|
|
87129
87731
|
});
|
|
87130
87732
|
writer._readyPromiseState = "pending";
|
|
@@ -87211,7 +87813,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87211
87813
|
source._disturbed = true;
|
|
87212
87814
|
let shuttingDown = false;
|
|
87213
87815
|
let currentWrite = promiseResolvedWith(void 0);
|
|
87214
|
-
return newPromise((
|
|
87816
|
+
return newPromise((resolve13, reject) => {
|
|
87215
87817
|
let abortAlgorithm;
|
|
87216
87818
|
if (signal !== void 0) {
|
|
87217
87819
|
abortAlgorithm = () => {
|
|
@@ -87356,7 +87958,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87356
87958
|
if (isError) {
|
|
87357
87959
|
reject(error);
|
|
87358
87960
|
} else {
|
|
87359
|
-
|
|
87961
|
+
resolve13(void 0);
|
|
87360
87962
|
}
|
|
87361
87963
|
return null;
|
|
87362
87964
|
}
|
|
@@ -87637,8 +88239,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87637
88239
|
let branch1;
|
|
87638
88240
|
let branch2;
|
|
87639
88241
|
let resolveCancelPromise;
|
|
87640
|
-
const cancelPromise = newPromise((
|
|
87641
|
-
resolveCancelPromise =
|
|
88242
|
+
const cancelPromise = newPromise((resolve13) => {
|
|
88243
|
+
resolveCancelPromise = resolve13;
|
|
87642
88244
|
});
|
|
87643
88245
|
function pullAlgorithm() {
|
|
87644
88246
|
if (reading) {
|
|
@@ -87729,8 +88331,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
87729
88331
|
let branch1;
|
|
87730
88332
|
let branch2;
|
|
87731
88333
|
let resolveCancelPromise;
|
|
87732
|
-
const cancelPromise = newPromise((
|
|
87733
|
-
resolveCancelPromise =
|
|
88334
|
+
const cancelPromise = newPromise((resolve13) => {
|
|
88335
|
+
resolveCancelPromise = resolve13;
|
|
87734
88336
|
});
|
|
87735
88337
|
function forwardReaderError(thisReader) {
|
|
87736
88338
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -88510,8 +89112,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88510
89112
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
88511
89113
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
88512
89114
|
let startPromise_resolve;
|
|
88513
|
-
const startPromise = newPromise((
|
|
88514
|
-
startPromise_resolve =
|
|
89115
|
+
const startPromise = newPromise((resolve13) => {
|
|
89116
|
+
startPromise_resolve = resolve13;
|
|
88515
89117
|
});
|
|
88516
89118
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
88517
89119
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -88604,8 +89206,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88604
89206
|
if (stream12._backpressureChangePromise !== void 0) {
|
|
88605
89207
|
stream12._backpressureChangePromise_resolve();
|
|
88606
89208
|
}
|
|
88607
|
-
stream12._backpressureChangePromise = newPromise((
|
|
88608
|
-
stream12._backpressureChangePromise_resolve =
|
|
89209
|
+
stream12._backpressureChangePromise = newPromise((resolve13) => {
|
|
89210
|
+
stream12._backpressureChangePromise_resolve = resolve13;
|
|
88609
89211
|
});
|
|
88610
89212
|
stream12._backpressure = backpressure;
|
|
88611
89213
|
}
|
|
@@ -88773,8 +89375,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88773
89375
|
return controller._finishPromise;
|
|
88774
89376
|
}
|
|
88775
89377
|
const readable = stream12._readable;
|
|
88776
|
-
controller._finishPromise = newPromise((
|
|
88777
|
-
controller._finishPromise_resolve =
|
|
89378
|
+
controller._finishPromise = newPromise((resolve13, reject) => {
|
|
89379
|
+
controller._finishPromise_resolve = resolve13;
|
|
88778
89380
|
controller._finishPromise_reject = reject;
|
|
88779
89381
|
});
|
|
88780
89382
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -88800,8 +89402,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88800
89402
|
return controller._finishPromise;
|
|
88801
89403
|
}
|
|
88802
89404
|
const readable = stream12._readable;
|
|
88803
|
-
controller._finishPromise = newPromise((
|
|
88804
|
-
controller._finishPromise_resolve =
|
|
89405
|
+
controller._finishPromise = newPromise((resolve13, reject) => {
|
|
89406
|
+
controller._finishPromise_resolve = resolve13;
|
|
88805
89407
|
controller._finishPromise_reject = reject;
|
|
88806
89408
|
});
|
|
88807
89409
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -88831,8 +89433,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
88831
89433
|
return controller._finishPromise;
|
|
88832
89434
|
}
|
|
88833
89435
|
const writable = stream12._writable;
|
|
88834
|
-
controller._finishPromise = newPromise((
|
|
88835
|
-
controller._finishPromise_resolve =
|
|
89436
|
+
controller._finishPromise = newPromise((resolve13, reject) => {
|
|
89437
|
+
controller._finishPromise_resolve = resolve13;
|
|
88836
89438
|
controller._finishPromise_reject = reject;
|
|
88837
89439
|
});
|
|
88838
89440
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -89370,8 +89972,8 @@ var require_node_domexception = __commonJS({
|
|
|
89370
89972
|
});
|
|
89371
89973
|
|
|
89372
89974
|
// node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js
|
|
89373
|
-
import { statSync as
|
|
89374
|
-
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";
|
|
89375
89977
|
var import_node_domexception, stat2, blobFromSync, blobFrom, fileFrom, fileFromSync, fromBlob, fromFile, BlobDataItem;
|
|
89376
89978
|
var init_from = __esm({
|
|
89377
89979
|
"node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js"() {
|
|
@@ -89379,10 +89981,10 @@ var init_from = __esm({
|
|
|
89379
89981
|
init_file();
|
|
89380
89982
|
init_fetch_blob();
|
|
89381
89983
|
({ stat: stat2 } = fs5);
|
|
89382
|
-
blobFromSync = (path8, type) => fromBlob(
|
|
89984
|
+
blobFromSync = (path8, type) => fromBlob(statSync3(path8), path8, type);
|
|
89383
89985
|
blobFrom = (path8, type) => stat2(path8).then((stat7) => fromBlob(stat7, path8, type));
|
|
89384
89986
|
fileFrom = (path8, type) => stat2(path8).then((stat7) => fromFile(stat7, path8, type));
|
|
89385
|
-
fileFromSync = (path8, type) => fromFile(
|
|
89987
|
+
fileFromSync = (path8, type) => fromFile(statSync3(path8), path8, type);
|
|
89386
89988
|
fromBlob = (stat7, path8, type = "") => new fetch_blob_default([new BlobDataItem({
|
|
89387
89989
|
path: path8,
|
|
89388
89990
|
size: stat7.size,
|
|
@@ -89394,7 +89996,7 @@ var init_from = __esm({
|
|
|
89394
89996
|
size: stat7.size,
|
|
89395
89997
|
lastModified: stat7.mtimeMs,
|
|
89396
89998
|
start: 0
|
|
89397
|
-
})],
|
|
89999
|
+
})], basename9(path8), { type, lastModified: stat7.mtimeMs });
|
|
89398
90000
|
BlobDataItem = class _BlobDataItem {
|
|
89399
90001
|
#path;
|
|
89400
90002
|
#start;
|
|
@@ -90783,7 +91385,7 @@ import zlib from "node:zlib";
|
|
|
90783
91385
|
import Stream4, { PassThrough as PassThrough2, pipeline as pump } from "node:stream";
|
|
90784
91386
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
90785
91387
|
async function fetch2(url, options_) {
|
|
90786
|
-
return new Promise((
|
|
91388
|
+
return new Promise((resolve13, reject) => {
|
|
90787
91389
|
const request = new Request2(url, options_);
|
|
90788
91390
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
90789
91391
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -90792,7 +91394,7 @@ async function fetch2(url, options_) {
|
|
|
90792
91394
|
if (parsedURL.protocol === "data:") {
|
|
90793
91395
|
const data = dist_default(request.url);
|
|
90794
91396
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
90795
|
-
|
|
91397
|
+
resolve13(response2);
|
|
90796
91398
|
return;
|
|
90797
91399
|
}
|
|
90798
91400
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -90914,7 +91516,7 @@ async function fetch2(url, options_) {
|
|
|
90914
91516
|
if (responseReferrerPolicy) {
|
|
90915
91517
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
90916
91518
|
}
|
|
90917
|
-
|
|
91519
|
+
resolve13(fetch2(new Request2(locationURL, requestOptions)));
|
|
90918
91520
|
finalize();
|
|
90919
91521
|
return;
|
|
90920
91522
|
}
|
|
@@ -90947,7 +91549,7 @@ async function fetch2(url, options_) {
|
|
|
90947
91549
|
const codings = headers.get("Content-Encoding");
|
|
90948
91550
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
90949
91551
|
response = new Response2(body, responseOptions);
|
|
90950
|
-
|
|
91552
|
+
resolve13(response);
|
|
90951
91553
|
return;
|
|
90952
91554
|
}
|
|
90953
91555
|
const zlibOptions = {
|
|
@@ -90961,7 +91563,7 @@ async function fetch2(url, options_) {
|
|
|
90961
91563
|
}
|
|
90962
91564
|
});
|
|
90963
91565
|
response = new Response2(body, responseOptions);
|
|
90964
|
-
|
|
91566
|
+
resolve13(response);
|
|
90965
91567
|
return;
|
|
90966
91568
|
}
|
|
90967
91569
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -90985,12 +91587,12 @@ async function fetch2(url, options_) {
|
|
|
90985
91587
|
});
|
|
90986
91588
|
}
|
|
90987
91589
|
response = new Response2(body, responseOptions);
|
|
90988
|
-
|
|
91590
|
+
resolve13(response);
|
|
90989
91591
|
});
|
|
90990
91592
|
raw.once("end", () => {
|
|
90991
91593
|
if (!response) {
|
|
90992
91594
|
response = new Response2(body, responseOptions);
|
|
90993
|
-
|
|
91595
|
+
resolve13(response);
|
|
90994
91596
|
}
|
|
90995
91597
|
});
|
|
90996
91598
|
return;
|
|
@@ -91002,11 +91604,11 @@ async function fetch2(url, options_) {
|
|
|
91002
91604
|
}
|
|
91003
91605
|
});
|
|
91004
91606
|
response = new Response2(body, responseOptions);
|
|
91005
|
-
|
|
91607
|
+
resolve13(response);
|
|
91006
91608
|
return;
|
|
91007
91609
|
}
|
|
91008
91610
|
response = new Response2(body, responseOptions);
|
|
91009
|
-
|
|
91611
|
+
resolve13(response);
|
|
91010
91612
|
});
|
|
91011
91613
|
writeToStream(request_, request).catch(reject);
|
|
91012
91614
|
});
|
|
@@ -91078,7 +91680,7 @@ var require_gaxios = __commonJS({
|
|
|
91078
91680
|
var retry_js_1 = require_retry3();
|
|
91079
91681
|
var stream_1 = __require("stream");
|
|
91080
91682
|
var interceptor_js_1 = require_interceptor();
|
|
91081
|
-
var
|
|
91683
|
+
var randomUUID4 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
|
|
91082
91684
|
var HTTP_STATUS_NO_CONTENT = 204;
|
|
91083
91685
|
var Gaxios = class {
|
|
91084
91686
|
agentCache = /* @__PURE__ */ new Map();
|
|
@@ -91351,7 +91953,7 @@ var require_gaxios = __commonJS({
|
|
|
91351
91953
|
*/
|
|
91352
91954
|
["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
|
|
91353
91955
|
if (opts.multipart?.length) {
|
|
91354
|
-
const boundary = await
|
|
91956
|
+
const boundary = await randomUUID4();
|
|
91355
91957
|
preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
|
|
91356
91958
|
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
|
|
91357
91959
|
} else if (shouldDirectlyPassData) {
|
|
@@ -97074,7 +97676,7 @@ var require_jwtaccess = __commonJS({
|
|
|
97074
97676
|
}
|
|
97075
97677
|
}
|
|
97076
97678
|
fromStreamAsync(inputStream) {
|
|
97077
|
-
return new Promise((
|
|
97679
|
+
return new Promise((resolve13, reject) => {
|
|
97078
97680
|
if (!inputStream) {
|
|
97079
97681
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
97080
97682
|
}
|
|
@@ -97083,7 +97685,7 @@ var require_jwtaccess = __commonJS({
|
|
|
97083
97685
|
try {
|
|
97084
97686
|
const data = JSON.parse(s2);
|
|
97085
97687
|
this.fromJSON(data);
|
|
97086
|
-
|
|
97688
|
+
resolve13();
|
|
97087
97689
|
} catch (err2) {
|
|
97088
97690
|
reject(err2);
|
|
97089
97691
|
}
|
|
@@ -97322,7 +97924,7 @@ var require_jwtclient = __commonJS({
|
|
|
97322
97924
|
}
|
|
97323
97925
|
}
|
|
97324
97926
|
fromStreamAsync(inputStream) {
|
|
97325
|
-
return new Promise((
|
|
97927
|
+
return new Promise((resolve13, reject) => {
|
|
97326
97928
|
if (!inputStream) {
|
|
97327
97929
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
97328
97930
|
}
|
|
@@ -97331,7 +97933,7 @@ var require_jwtclient = __commonJS({
|
|
|
97331
97933
|
try {
|
|
97332
97934
|
const data = JSON.parse(s2);
|
|
97333
97935
|
this.fromJSON(data);
|
|
97334
|
-
|
|
97936
|
+
resolve13();
|
|
97335
97937
|
} catch (e2) {
|
|
97336
97938
|
reject(e2);
|
|
97337
97939
|
}
|
|
@@ -97464,7 +98066,7 @@ var require_refreshclient = __commonJS({
|
|
|
97464
98066
|
}
|
|
97465
98067
|
}
|
|
97466
98068
|
async fromStreamAsync(inputStream) {
|
|
97467
|
-
return new Promise((
|
|
98069
|
+
return new Promise((resolve13, reject) => {
|
|
97468
98070
|
if (!inputStream) {
|
|
97469
98071
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
97470
98072
|
}
|
|
@@ -97473,7 +98075,7 @@ var require_refreshclient = __commonJS({
|
|
|
97473
98075
|
try {
|
|
97474
98076
|
const data = JSON.parse(s2);
|
|
97475
98077
|
this.fromJSON(data);
|
|
97476
|
-
return
|
|
98078
|
+
return resolve13();
|
|
97477
98079
|
} catch (err2) {
|
|
97478
98080
|
return reject(err2);
|
|
97479
98081
|
}
|
|
@@ -99306,7 +99908,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
99306
99908
|
* @return A promise that resolves with the executable response.
|
|
99307
99909
|
*/
|
|
99308
99910
|
retrieveResponseFromExecutable(envMap) {
|
|
99309
|
-
return new Promise((
|
|
99911
|
+
return new Promise((resolve13, reject) => {
|
|
99310
99912
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
99311
99913
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
99312
99914
|
});
|
|
@@ -99328,7 +99930,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
99328
99930
|
try {
|
|
99329
99931
|
const responseJson = JSON.parse(output);
|
|
99330
99932
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
99331
|
-
return
|
|
99933
|
+
return resolve13(response);
|
|
99332
99934
|
} catch (error) {
|
|
99333
99935
|
if (error instanceof executable_response_1.ExecutableResponseError) {
|
|
99334
99936
|
return reject(error);
|
|
@@ -100520,7 +101122,7 @@ var require_googleauth = __commonJS({
|
|
|
100520
101122
|
}
|
|
100521
101123
|
}
|
|
100522
101124
|
fromStreamAsync(inputStream, options) {
|
|
100523
|
-
return new Promise((
|
|
101125
|
+
return new Promise((resolve13, reject) => {
|
|
100524
101126
|
if (!inputStream) {
|
|
100525
101127
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
100526
101128
|
}
|
|
@@ -100530,7 +101132,7 @@ var require_googleauth = __commonJS({
|
|
|
100530
101132
|
try {
|
|
100531
101133
|
const data = JSON.parse(chunks.join(""));
|
|
100532
101134
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
100533
|
-
return
|
|
101135
|
+
return resolve13(r2);
|
|
100534
101136
|
} catch (err2) {
|
|
100535
101137
|
if (!this.keyFilename)
|
|
100536
101138
|
throw err2;
|
|
@@ -100540,7 +101142,7 @@ var require_googleauth = __commonJS({
|
|
|
100540
101142
|
});
|
|
100541
101143
|
this.cachedCredential = client;
|
|
100542
101144
|
this.setGapicJWTValues(client);
|
|
100543
|
-
return
|
|
101145
|
+
return resolve13(client);
|
|
100544
101146
|
}
|
|
100545
101147
|
} catch (err2) {
|
|
100546
101148
|
return reject(err2);
|
|
@@ -100576,17 +101178,17 @@ var require_googleauth = __commonJS({
|
|
|
100576
101178
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
100577
101179
|
*/
|
|
100578
101180
|
async getDefaultServiceProjectId() {
|
|
100579
|
-
return new Promise((
|
|
101181
|
+
return new Promise((resolve13) => {
|
|
100580
101182
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err2, stdout) => {
|
|
100581
101183
|
if (!err2 && stdout) {
|
|
100582
101184
|
try {
|
|
100583
101185
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
100584
|
-
|
|
101186
|
+
resolve13(projectId);
|
|
100585
101187
|
return;
|
|
100586
101188
|
} catch (e2) {
|
|
100587
101189
|
}
|
|
100588
101190
|
}
|
|
100589
|
-
|
|
101191
|
+
resolve13(null);
|
|
100590
101192
|
});
|
|
100591
101193
|
});
|
|
100592
101194
|
}
|
|
@@ -108311,14 +108913,14 @@ function __asyncValues(o) {
|
|
|
108311
108913
|
}, i2);
|
|
108312
108914
|
function verb(n) {
|
|
108313
108915
|
i2[n] = o[n] && function(v2) {
|
|
108314
|
-
return new Promise(function(
|
|
108315
|
-
v2 = o[n](v2), settle(
|
|
108916
|
+
return new Promise(function(resolve13, reject) {
|
|
108917
|
+
v2 = o[n](v2), settle(resolve13, reject, v2.done, v2.value);
|
|
108316
108918
|
});
|
|
108317
108919
|
};
|
|
108318
108920
|
}
|
|
108319
|
-
function settle(
|
|
108921
|
+
function settle(resolve13, reject, d, v2) {
|
|
108320
108922
|
Promise.resolve(v2).then(function(v3) {
|
|
108321
|
-
|
|
108923
|
+
resolve13({ value: v3, done: d });
|
|
108322
108924
|
}, reject);
|
|
108323
108925
|
}
|
|
108324
108926
|
}
|
|
@@ -115238,7 +115840,7 @@ function retryIntervalFromResponse(res) {
|
|
|
115238
115840
|
return 0;
|
|
115239
115841
|
}
|
|
115240
115842
|
async function delay(delay2) {
|
|
115241
|
-
return new Promise((
|
|
115843
|
+
return new Promise((resolve13) => setTimeout(resolve13, delay2));
|
|
115242
115844
|
}
|
|
115243
115845
|
async function logRequest(logger, req) {
|
|
115244
115846
|
if (!logger) {
|
|
@@ -122560,8 +123162,8 @@ var init_node3 = __esm({
|
|
|
122560
123162
|
const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
|
|
122561
123163
|
let onopenResolve = () => {
|
|
122562
123164
|
};
|
|
122563
|
-
const onopenPromise = new Promise((
|
|
122564
|
-
onopenResolve =
|
|
123165
|
+
const onopenPromise = new Promise((resolve13) => {
|
|
123166
|
+
onopenResolve = resolve13;
|
|
122565
123167
|
});
|
|
122566
123168
|
const callbacks = params.callbacks;
|
|
122567
123169
|
const onopenAwaitedCallback = function() {
|
|
@@ -122767,8 +123369,8 @@ var init_node3 = __esm({
|
|
|
122767
123369
|
}
|
|
122768
123370
|
let onopenResolve = () => {
|
|
122769
123371
|
};
|
|
122770
|
-
const onopenPromise = new Promise((
|
|
122771
|
-
onopenResolve =
|
|
123372
|
+
const onopenPromise = new Promise((resolve13) => {
|
|
123373
|
+
onopenResolve = resolve13;
|
|
122772
123374
|
});
|
|
122773
123375
|
const callbacks = params.callbacks;
|
|
122774
123376
|
const onopenAwaitedCallback = function() {
|
|
@@ -122781,8 +123383,8 @@ var init_node3 = __esm({
|
|
|
122781
123383
|
const messageQueue = [];
|
|
122782
123384
|
let setupCompleteResolve = () => {
|
|
122783
123385
|
};
|
|
122784
|
-
const setupCompletePromise = new Promise((
|
|
122785
|
-
setupCompleteResolve =
|
|
123386
|
+
const setupCompletePromise = new Promise((resolve13) => {
|
|
123387
|
+
setupCompleteResolve = resolve13;
|
|
122786
123388
|
});
|
|
122787
123389
|
const websocketCallbacks = {
|
|
122788
123390
|
onopen: onopenAwaitedCallback,
|
|
@@ -129143,12 +129745,12 @@ function validateRetryDelayMs(delayMs, options) {
|
|
|
129143
129745
|
return delayMs;
|
|
129144
129746
|
}
|
|
129145
129747
|
function sleep4(ms, signal) {
|
|
129146
|
-
return new Promise((
|
|
129748
|
+
return new Promise((resolve13, reject) => {
|
|
129147
129749
|
if (signal?.aborted) {
|
|
129148
129750
|
reject(new Error("Request was aborted"));
|
|
129149
129751
|
return;
|
|
129150
129752
|
}
|
|
129151
|
-
const timeout = setTimeout(
|
|
129753
|
+
const timeout = setTimeout(resolve13, ms);
|
|
129152
129754
|
signal?.addEventListener("abort", () => {
|
|
129153
129755
|
clearTimeout(timeout);
|
|
129154
129756
|
reject(new Error("Request was aborted"));
|
|
@@ -129536,7 +130138,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
129536
130138
|
}
|
|
129537
130139
|
const wsHeaders = headersToRecord(headers);
|
|
129538
130140
|
delete wsHeaders["OpenAI-Beta"];
|
|
129539
|
-
return new Promise((
|
|
130141
|
+
return new Promise((resolve13, reject) => {
|
|
129540
130142
|
let settled = false;
|
|
129541
130143
|
let timeout;
|
|
129542
130144
|
let socket;
|
|
@@ -129571,7 +130173,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
|
|
|
129571
130173
|
return;
|
|
129572
130174
|
settled = true;
|
|
129573
130175
|
cleanup();
|
|
129574
|
-
|
|
130176
|
+
resolve13(socket);
|
|
129575
130177
|
};
|
|
129576
130178
|
const onError = (event) => {
|
|
129577
130179
|
fail2(extractWebSocketError(event));
|
|
@@ -129747,9 +130349,9 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
129747
130349
|
const wake = () => {
|
|
129748
130350
|
if (!pending)
|
|
129749
130351
|
return;
|
|
129750
|
-
const
|
|
130352
|
+
const resolve13 = pending;
|
|
129751
130353
|
pending = null;
|
|
129752
|
-
|
|
130354
|
+
resolve13();
|
|
129753
130355
|
};
|
|
129754
130356
|
const onMessage = (event) => {
|
|
129755
130357
|
void (async () => {
|
|
@@ -129816,8 +130418,8 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
|
|
|
129816
130418
|
if (done)
|
|
129817
130419
|
break;
|
|
129818
130420
|
let timeout;
|
|
129819
|
-
await new Promise((
|
|
129820
|
-
pending =
|
|
130421
|
+
await new Promise((resolve13, reject) => {
|
|
130422
|
+
pending = resolve13;
|
|
129821
130423
|
if (idleTimeoutMs !== void 0 && idleTimeoutMs > 0) {
|
|
129822
130424
|
timeout = setTimeout(() => {
|
|
129823
130425
|
const error = new Error(`WebSocket idle timeout after ${idleTimeoutMs}ms`);
|
|
@@ -133927,7 +134529,7 @@ function timeoutError(timeoutMs) {
|
|
|
133927
134529
|
error.body = "";
|
|
133928
134530
|
return error;
|
|
133929
134531
|
}
|
|
133930
|
-
function
|
|
134532
|
+
function isRecord3(value2) {
|
|
133931
134533
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
133932
134534
|
}
|
|
133933
134535
|
function requiredNumber(label, value2, field2) {
|
|
@@ -133937,7 +134539,7 @@ function requiredNumber(label, value2, field2) {
|
|
|
133937
134539
|
return value2;
|
|
133938
134540
|
}
|
|
133939
134541
|
function probabilities(label, value2, id) {
|
|
133940
|
-
if (!
|
|
134542
|
+
if (!isRecord3(value2))
|
|
133941
134543
|
throw new Error(`${label} returned invalid probabilities for ${id}`);
|
|
133942
134544
|
return Object.fromEntries(Object.entries(value2).map(([key, probability]) => [
|
|
133943
134545
|
key,
|
|
@@ -133945,12 +134547,12 @@ function probabilities(label, value2, id) {
|
|
|
133945
134547
|
]));
|
|
133946
134548
|
}
|
|
133947
134549
|
function parseAnswers(label, value2, context) {
|
|
133948
|
-
if (!
|
|
134550
|
+
if (!isRecord3(value2))
|
|
133949
134551
|
throw new Error(`${label} returned an unexpected response`);
|
|
133950
134552
|
const answers = [];
|
|
133951
134553
|
for (const [id, question] of Object.entries(context.questions)) {
|
|
133952
134554
|
const answer = value2[id];
|
|
133953
|
-
if (!
|
|
134555
|
+
if (!isRecord3(answer))
|
|
133954
134556
|
throw new Error(`${label} did not return an answer for ${id}`);
|
|
133955
134557
|
if (question.type === "choice") {
|
|
133956
134558
|
if (answer.type !== "choice" || typeof answer.choice !== "string") {
|
|
@@ -133994,7 +134596,7 @@ function tokenCount(value2) {
|
|
|
133994
134596
|
return typeof value2 === "number" && Number.isFinite(value2) && value2 > 0 ? value2 : 0;
|
|
133995
134597
|
}
|
|
133996
134598
|
function parseUsage2(value2, model) {
|
|
133997
|
-
if (!
|
|
134599
|
+
if (!isRecord3(value2) || value2.input_tokens === void 0 && value2.output_tokens === void 0)
|
|
133998
134600
|
return void 0;
|
|
133999
134601
|
const input = tokenCount(value2.input_tokens);
|
|
134000
134602
|
const output = tokenCount(value2.output_tokens);
|
|
@@ -134093,7 +134695,7 @@ __export(cloudflare_workers_ai_system_one_exports, {
|
|
|
134093
134695
|
});
|
|
134094
134696
|
function cloudflareErrorMessage(errors) {
|
|
134095
134697
|
if (Array.isArray(errors)) {
|
|
134096
|
-
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);
|
|
134097
134699
|
if (messages.length > 0)
|
|
134098
134700
|
return `${LABEL} error: ${messages.join("; ")}`;
|
|
134099
134701
|
}
|
|
@@ -134110,17 +134712,17 @@ var init_cloudflare_workers_ai_system_one = __esm({
|
|
|
134110
134712
|
url: (model) => new URL("run", `${model.baseUrl.replace(/\/+$/u, "")}/`),
|
|
134111
134713
|
payload: (model, request) => ({ model: model.id, input: request }),
|
|
134112
134714
|
output: (body) => {
|
|
134113
|
-
if (!
|
|
134715
|
+
if (!isRecord3(body))
|
|
134114
134716
|
throw new Error(`${LABEL} returned an unexpected response`);
|
|
134115
134717
|
if (body.success === false)
|
|
134116
134718
|
throw new Error(cloudflareErrorMessage(body.errors));
|
|
134117
134719
|
const run = body.result;
|
|
134118
|
-
if (!
|
|
134720
|
+
if (!isRecord3(run))
|
|
134119
134721
|
throw new Error(`${LABEL} returned an unexpected response`);
|
|
134120
134722
|
if (run.state !== "Completed") {
|
|
134121
134723
|
throw new Error(`${LABEL} run did not complete (state: ${String(run.state)})`);
|
|
134122
134724
|
}
|
|
134123
|
-
if (!
|
|
134725
|
+
if (!isRecord3(run.result))
|
|
134124
134726
|
throw new Error(`${LABEL} returned an unexpected response`);
|
|
134125
134727
|
return run.result;
|
|
134126
134728
|
}
|
|
@@ -134650,7 +135252,7 @@ var init_typesafe_system_one = __esm({
|
|
|
134650
135252
|
url: (model) => new URL("systemone", `${model.baseUrl.replace(/\/+$/u, "")}/`),
|
|
134651
135253
|
payload: (model, request) => ({ model: model.id, ...request }),
|
|
134652
135254
|
output: (body) => {
|
|
134653
|
-
if (!
|
|
135255
|
+
if (!isRecord3(body))
|
|
134654
135256
|
throw new Error("System One API returned an unexpected response");
|
|
134655
135257
|
return body;
|
|
134656
135258
|
}
|
|
@@ -138769,7 +139371,7 @@ var init_terminal_colors = __esm({
|
|
|
138769
139371
|
// node_modules/.pnpm/@earendil-works+pi-tui@0.99.1/node_modules/@earendil-works/pi-tui/dist/terminal-image.js
|
|
138770
139372
|
import { execSync } from "node:child_process";
|
|
138771
139373
|
import { homedir as homedir4 } from "node:os";
|
|
138772
|
-
import { isAbsolute as
|
|
139374
|
+
import { isAbsolute as isAbsolute5 } from "node:path";
|
|
138773
139375
|
import { pathToFileURL } from "node:url";
|
|
138774
139376
|
function setCellDimensions(dims) {
|
|
138775
139377
|
cellDimensions = dims;
|
|
@@ -139074,7 +139676,7 @@ function imageFallback(mimeType, dimensions, filename) {
|
|
|
139074
139676
|
const parts = [];
|
|
139075
139677
|
if (filename) {
|
|
139076
139678
|
const display = shortenImagePath(filename);
|
|
139077
|
-
if (getCapabilities().hyperlinks &&
|
|
139679
|
+
if (getCapabilities().hyperlinks && isAbsolute5(filename)) {
|
|
139078
139680
|
parts.push(hyperlink(display, pathToFileURL(filename).href));
|
|
139079
139681
|
} else {
|
|
139080
139682
|
parts.push(display);
|
|
@@ -140043,16 +140645,16 @@ var init_tui = __esm({
|
|
|
140043
140645
|
* @param onLateReply Receives the replies if the query completes after the timeout, e.g. over slow links.
|
|
140044
140646
|
*/
|
|
140045
140647
|
queryTerminalColors({ timeoutMs, onLateReply }) {
|
|
140046
|
-
return new Promise((
|
|
140648
|
+
return new Promise((resolve13) => {
|
|
140047
140649
|
const query = {
|
|
140048
140650
|
palette: Array.from({ length: TERMINAL_PALETTE_SIZE }, () => void 0),
|
|
140049
140651
|
replied: /* @__PURE__ */ new Set(),
|
|
140050
|
-
deliver:
|
|
140652
|
+
deliver: resolve13,
|
|
140051
140653
|
timer: void 0
|
|
140052
140654
|
};
|
|
140053
140655
|
query.timer = setTimeout(() => {
|
|
140054
140656
|
query.deliver = onLateReply;
|
|
140055
|
-
|
|
140657
|
+
resolve13(this.terminalColorQueryResult(query));
|
|
140056
140658
|
}, timeoutMs);
|
|
140057
140659
|
this.pendingTerminalColorQueries.push(query);
|
|
140058
140660
|
this.terminal.write(TERMINAL_COLOR_QUERY);
|
|
@@ -143074,10 +143676,10 @@ var init_tui_alt_screen = __esm({
|
|
|
143074
143676
|
this.mousePressMoved = true;
|
|
143075
143677
|
this.lastComponentClick = void 0;
|
|
143076
143678
|
}
|
|
143077
|
-
let
|
|
143679
|
+
let render2 = false;
|
|
143078
143680
|
const targetResult = this.dispatchMouseToTarget(event, target);
|
|
143079
143681
|
if (targetResult)
|
|
143080
|
-
|
|
143682
|
+
render2 = this.applyMouseDispatchResult(event, targetResult);
|
|
143081
143683
|
if (raw.release) {
|
|
143082
143684
|
if (!this.mousePressMoved && this.mousePressPoint?.x === raw.x && this.mousePressPoint.y === raw.y) {
|
|
143083
143685
|
const clickEvent = this.createMouseEvent("click", raw.button, raw.x, raw.y, {
|
|
@@ -143085,11 +143687,11 @@ var init_tui_alt_screen = __esm({
|
|
|
143085
143687
|
});
|
|
143086
143688
|
const clickResult = this.dispatchMouseToTarget(clickEvent, target);
|
|
143087
143689
|
if (clickResult)
|
|
143088
|
-
|
|
143690
|
+
render2 = this.applyMouseDispatchResult(clickEvent, clickResult) || render2;
|
|
143089
143691
|
}
|
|
143090
143692
|
this.clearComponentMouseGesture();
|
|
143091
143693
|
}
|
|
143092
|
-
if (
|
|
143694
|
+
if (render2)
|
|
143093
143695
|
this.requestRender();
|
|
143094
143696
|
return;
|
|
143095
143697
|
}
|
|
@@ -143109,14 +143711,14 @@ var init_tui_alt_screen = __esm({
|
|
|
143109
143711
|
}
|
|
143110
143712
|
const result = overlay.result ?? (overlay.hit ? void 0 : this.dispatchMouseToLayout(event));
|
|
143111
143713
|
if (result) {
|
|
143112
|
-
const
|
|
143714
|
+
const render2 = this.applyMouseDispatchResult(event, result);
|
|
143113
143715
|
if (type === "press") {
|
|
143114
143716
|
this.clearTextSelection();
|
|
143115
143717
|
this.mousePressTarget = result.target;
|
|
143116
143718
|
this.mousePressPoint = { x: raw.x, y: raw.y };
|
|
143117
143719
|
this.mousePressMoved = false;
|
|
143118
143720
|
}
|
|
143119
|
-
if (
|
|
143721
|
+
if (render2)
|
|
143120
143722
|
this.requestRender();
|
|
143121
143723
|
return;
|
|
143122
143724
|
}
|
|
@@ -143459,9 +144061,9 @@ var init_tui_alt_screen = __esm({
|
|
|
143459
144061
|
const overlay = this.dispatchMouseToOverlay(clickEvent);
|
|
143460
144062
|
const result = overlay.result ?? (overlay.hit ? void 0 : this.dispatchMouseToLayout(clickEvent));
|
|
143461
144063
|
if (result) {
|
|
143462
|
-
const
|
|
144064
|
+
const render2 = this.applyMouseDispatchResult(clickEvent, result);
|
|
143463
144065
|
this.clearTextSelection();
|
|
143464
|
-
if (
|
|
144066
|
+
if (render2)
|
|
143465
144067
|
this.requestRender();
|
|
143466
144068
|
return;
|
|
143467
144069
|
}
|
|
@@ -144134,7 +144736,7 @@ var require_core = __commonJS({
|
|
|
144134
144736
|
return match3 && match3.index === 0;
|
|
144135
144737
|
}
|
|
144136
144738
|
var BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
144137
|
-
function
|
|
144739
|
+
function join25(regexps, separator = "|") {
|
|
144138
144740
|
let numCaptures = 0;
|
|
144139
144741
|
return regexps.map((regex2) => {
|
|
144140
144742
|
numCaptures += 1;
|
|
@@ -144438,7 +145040,7 @@ var require_core = __commonJS({
|
|
|
144438
145040
|
this.exec = () => null;
|
|
144439
145041
|
}
|
|
144440
145042
|
const terminators = this.regexes.map((el) => el[1]);
|
|
144441
|
-
this.matcherRe = langRe(
|
|
145043
|
+
this.matcherRe = langRe(join25(terminators), true);
|
|
144442
145044
|
this.lastIndex = 0;
|
|
144443
145045
|
}
|
|
144444
145046
|
/** @param {string} s */
|
|
@@ -144733,7 +145335,7 @@ var require_core = __commonJS({
|
|
|
144733
145335
|
function close(node) {
|
|
144734
145336
|
result += "</" + tag(node) + ">";
|
|
144735
145337
|
}
|
|
144736
|
-
function
|
|
145338
|
+
function render2(event) {
|
|
144737
145339
|
(event.event === "start" ? open3 : close)(event.node);
|
|
144738
145340
|
}
|
|
144739
145341
|
while (original.length || highlighted.length) {
|
|
@@ -144743,7 +145345,7 @@ var require_core = __commonJS({
|
|
|
144743
145345
|
if (stream12 === original) {
|
|
144744
145346
|
nodeStack.reverse().forEach(close);
|
|
144745
145347
|
do {
|
|
144746
|
-
|
|
145348
|
+
render2(stream12.splice(0, 1)[0]);
|
|
144747
145349
|
stream12 = selectStream();
|
|
144748
145350
|
} while (stream12 === original && stream12.length && stream12[0].offset === processed);
|
|
144749
145351
|
nodeStack.reverse().forEach(open3);
|
|
@@ -144753,7 +145355,7 @@ var require_core = __commonJS({
|
|
|
144753
145355
|
} else {
|
|
144754
145356
|
nodeStack.pop();
|
|
144755
145357
|
}
|
|
144756
|
-
|
|
145358
|
+
render2(stream12.splice(0, 1)[0]);
|
|
144757
145359
|
}
|
|
144758
145360
|
}
|
|
144759
145361
|
return result + escapeHTML(value2.substr(processed));
|
|
@@ -151766,7 +152368,7 @@ var init_ansi = __esm({
|
|
|
151766
152368
|
});
|
|
151767
152369
|
|
|
151768
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
|
|
151769
|
-
import { existsSync as
|
|
152371
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
151770
152372
|
import { spawn as spawn2, spawnSync } from "child_process";
|
|
151771
152373
|
function isLegacyWslBashPath(path8) {
|
|
151772
152374
|
const normalized = path8.replace(/\//g, "\\").toLowerCase();
|
|
@@ -151785,7 +152387,7 @@ function findExecutableOnPath(executable) {
|
|
|
151785
152387
|
});
|
|
151786
152388
|
if (result.status === 0 && result.stdout) {
|
|
151787
152389
|
const firstMatch = result.stdout.trim().split(/\r?\n/)[0];
|
|
151788
|
-
if (firstMatch &&
|
|
152390
|
+
if (firstMatch && existsSync2(firstMatch)) {
|
|
151789
152391
|
return firstMatch;
|
|
151790
152392
|
}
|
|
151791
152393
|
}
|
|
@@ -151807,7 +152409,7 @@ function findExecutableOnPath(executable) {
|
|
|
151807
152409
|
}
|
|
151808
152410
|
function getShellConfig(customShellPath) {
|
|
151809
152411
|
if (customShellPath) {
|
|
151810
|
-
if (
|
|
152412
|
+
if (existsSync2(customShellPath)) {
|
|
151811
152413
|
return getBashShellConfig(customShellPath);
|
|
151812
152414
|
}
|
|
151813
152415
|
throw new Error(`Custom shell path not found: ${customShellPath}`);
|
|
@@ -151823,7 +152425,7 @@ function getShellConfig(customShellPath) {
|
|
|
151823
152425
|
paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
|
|
151824
152426
|
}
|
|
151825
152427
|
for (const path8 of paths) {
|
|
151826
|
-
if (
|
|
152428
|
+
if (existsSync2(path8)) {
|
|
151827
152429
|
return getBashShellConfig(path8);
|
|
151828
152430
|
}
|
|
151829
152431
|
}
|
|
@@ -151839,7 +152441,7 @@ function getShellConfig(customShellPath) {
|
|
|
151839
152441
|
Searched Git Bash in:
|
|
151840
152442
|
${paths.map((p) => ` ${p}`).join("\n")}`);
|
|
151841
152443
|
}
|
|
151842
|
-
if (
|
|
152444
|
+
if (existsSync2("/bin/bash")) {
|
|
151843
152445
|
return getBashShellConfig("/bin/bash");
|
|
151844
152446
|
}
|
|
151845
152447
|
const bashOnPath = findExecutableOnPath("bash");
|
|
@@ -152107,16 +152709,16 @@ function isLoopbackRedirectUri(value2) {
|
|
|
152107
152709
|
const url = new URL(value2);
|
|
152108
152710
|
return url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname) && url.search === "" && url.hash === "";
|
|
152109
152711
|
}
|
|
152110
|
-
function
|
|
152712
|
+
function isRecord4(value2) {
|
|
152111
152713
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
152112
152714
|
}
|
|
152113
152715
|
function isStringRecord(value2) {
|
|
152114
|
-
return
|
|
152716
|
+
return isRecord4(value2) && Object.values(value2).every((entry) => typeof entry === "string");
|
|
152115
152717
|
}
|
|
152116
152718
|
function validateOAuth(value2) {
|
|
152117
152719
|
if (value2 === void 0)
|
|
152118
152720
|
return void 0;
|
|
152119
|
-
if (!
|
|
152721
|
+
if (!isRecord4(value2))
|
|
152120
152722
|
return "oauth must be an object";
|
|
152121
152723
|
if (value2.clientId !== void 0 && typeof value2.clientId !== "string")
|
|
152122
152724
|
return "oauth.clientId must be a string";
|
|
@@ -152161,7 +152763,7 @@ function getMcpToolExposure(config, toolName2) {
|
|
|
152161
152763
|
function validateMcpServerConfig(name, value2) {
|
|
152162
152764
|
if (!SERVER_NAME.test(name))
|
|
152163
152765
|
return `invalid server name "${name}" (use letters, digits, "_" and "-")`;
|
|
152164
|
-
if (!
|
|
152766
|
+
if (!isRecord4(value2))
|
|
152165
152767
|
return `server "${name}" must be an object`;
|
|
152166
152768
|
const { type, exposure, enabled, timeout, toolExposure } = value2;
|
|
152167
152769
|
const exposures = MCP_EXPOSURES.map((value3) => `"${value3}"`).join(", ");
|
|
@@ -152169,7 +152771,7 @@ function validateMcpServerConfig(name, value2) {
|
|
|
152169
152771
|
return `server "${name}": exposure must be one of ${exposures}`;
|
|
152170
152772
|
}
|
|
152171
152773
|
if (toolExposure !== void 0) {
|
|
152172
|
-
if (!
|
|
152774
|
+
if (!isRecord4(toolExposure))
|
|
152173
152775
|
return `server "${name}": toolExposure must map tool names to exposures`;
|
|
152174
152776
|
for (const [tool, value3] of Object.entries(toolExposure)) {
|
|
152175
152777
|
if (!isExposure(value3))
|
|
@@ -154531,12 +155133,12 @@ var require_adapter = __commonJS({
|
|
|
154531
155133
|
return newFs;
|
|
154532
155134
|
}
|
|
154533
155135
|
function toPromise(method) {
|
|
154534
|
-
return (...args) => new Promise((
|
|
155136
|
+
return (...args) => new Promise((resolve13, reject) => {
|
|
154535
155137
|
args.push((err2, result) => {
|
|
154536
155138
|
if (err2) {
|
|
154537
155139
|
reject(err2);
|
|
154538
155140
|
} else {
|
|
154539
|
-
|
|
155141
|
+
resolve13(result);
|
|
154540
155142
|
}
|
|
154541
155143
|
});
|
|
154542
155144
|
method(...args);
|
|
@@ -154625,7 +155227,7 @@ function raceWithAbortSignal2(operation, signal) {
|
|
|
154625
155227
|
});
|
|
154626
155228
|
return Promise.reject(abortReason2(signal));
|
|
154627
155229
|
}
|
|
154628
|
-
return new Promise((
|
|
155230
|
+
return new Promise((resolve13, reject) => {
|
|
154629
155231
|
let settled = false;
|
|
154630
155232
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
154631
155233
|
const onAbort = () => {
|
|
@@ -154641,7 +155243,7 @@ function raceWithAbortSignal2(operation, signal) {
|
|
|
154641
155243
|
return;
|
|
154642
155244
|
settled = true;
|
|
154643
155245
|
cleanup();
|
|
154644
|
-
|
|
155246
|
+
resolve13(value2);
|
|
154645
155247
|
}, (error) => {
|
|
154646
155248
|
if (settled)
|
|
154647
155249
|
return;
|
|
@@ -154659,8 +155261,8 @@ var init_abort4 = __esm({
|
|
|
154659
155261
|
});
|
|
154660
155262
|
|
|
154661
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
|
|
154662
|
-
import { existsSync as
|
|
154663
|
-
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";
|
|
154664
155266
|
import { setTimeout as sleep6 } from "timers/promises";
|
|
154665
155267
|
var import_proper_lockfile, AUTH_FILE_WRITE_OPTIONS, FileAuthStorageBackend;
|
|
154666
155268
|
var init_auth_storage = __esm({
|
|
@@ -154674,18 +155276,18 @@ var init_auth_storage = __esm({
|
|
|
154674
155276
|
AUTH_FILE_WRITE_OPTIONS = { encoding: "utf-8", mode: 384 };
|
|
154675
155277
|
FileAuthStorageBackend = class {
|
|
154676
155278
|
authPath;
|
|
154677
|
-
constructor(authPath =
|
|
155279
|
+
constructor(authPath = join12(getAgentDir(), "auth.json")) {
|
|
154678
155280
|
this.authPath = normalizePath(authPath);
|
|
154679
155281
|
}
|
|
154680
155282
|
ensureParentDir() {
|
|
154681
|
-
const dir =
|
|
154682
|
-
if (!
|
|
155283
|
+
const dir = dirname10(this.authPath);
|
|
155284
|
+
if (!existsSync3(dir)) {
|
|
154683
155285
|
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
154684
155286
|
}
|
|
154685
155287
|
}
|
|
154686
155288
|
ensureFileExists() {
|
|
154687
|
-
if (!
|
|
154688
|
-
|
|
155289
|
+
if (!existsSync3(this.authPath)) {
|
|
155290
|
+
writeFileSync2(this.authPath, "{}", AUTH_FILE_WRITE_OPTIONS);
|
|
154689
155291
|
}
|
|
154690
155292
|
}
|
|
154691
155293
|
acquireLockSyncWithRetry(path8) {
|
|
@@ -154714,10 +155316,10 @@ var init_auth_storage = __esm({
|
|
|
154714
155316
|
let release;
|
|
154715
155317
|
try {
|
|
154716
155318
|
release = this.acquireLockSyncWithRetry(this.authPath);
|
|
154717
|
-
const current =
|
|
155319
|
+
const current = existsSync3(this.authPath) ? readFileSync3(this.authPath, "utf-8") : void 0;
|
|
154718
155320
|
const { result, next } = fn(current);
|
|
154719
155321
|
if (next !== void 0) {
|
|
154720
|
-
|
|
155322
|
+
writeFileSync2(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);
|
|
154721
155323
|
}
|
|
154722
155324
|
return result;
|
|
154723
155325
|
} finally {
|
|
@@ -154782,12 +155384,12 @@ var init_auth_storage = __esm({
|
|
|
154782
155384
|
});
|
|
154783
155385
|
throwIfCompromised();
|
|
154784
155386
|
options?.signal?.throwIfAborted();
|
|
154785
|
-
const current =
|
|
155387
|
+
const current = existsSync3(this.authPath) ? readFileSync3(this.authPath, "utf-8") : void 0;
|
|
154786
155388
|
const { result, next } = await fn(current);
|
|
154787
155389
|
throwIfCompromised();
|
|
154788
155390
|
options?.signal?.throwIfAborted();
|
|
154789
155391
|
if (next !== void 0) {
|
|
154790
|
-
|
|
155392
|
+
writeFileSync2(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);
|
|
154791
155393
|
}
|
|
154792
155394
|
throwIfCompromised();
|
|
154793
155395
|
return result;
|
|
@@ -162782,9 +163384,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
162782
163384
|
}
|
|
162783
163385
|
close(callback) {
|
|
162784
163386
|
if (callback === void 0) {
|
|
162785
|
-
return new Promise((
|
|
163387
|
+
return new Promise((resolve13, reject) => {
|
|
162786
163388
|
this.close((err2, data) => {
|
|
162787
|
-
return err2 ? reject(err2) :
|
|
163389
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
162788
163390
|
});
|
|
162789
163391
|
});
|
|
162790
163392
|
}
|
|
@@ -162822,9 +163424,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
162822
163424
|
err2 = null;
|
|
162823
163425
|
}
|
|
162824
163426
|
if (callback === void 0) {
|
|
162825
|
-
return new Promise((
|
|
163427
|
+
return new Promise((resolve13, reject) => {
|
|
162826
163428
|
this.destroy(err2, (err3, data) => {
|
|
162827
|
-
return err3 ? reject(err3) :
|
|
163429
|
+
return err3 ? reject(err3) : resolve13(data);
|
|
162828
163430
|
});
|
|
162829
163431
|
});
|
|
162830
163432
|
}
|
|
@@ -167781,12 +168383,12 @@ upgrade: ${upgrade}\r
|
|
|
167781
168383
|
cb();
|
|
167782
168384
|
}
|
|
167783
168385
|
}
|
|
167784
|
-
const waitForDrain = () => new Promise((
|
|
168386
|
+
const waitForDrain = () => new Promise((resolve13, reject) => {
|
|
167785
168387
|
assert(callback === null);
|
|
167786
168388
|
if (socket[kError]) {
|
|
167787
168389
|
reject(socket[kError]);
|
|
167788
168390
|
} else {
|
|
167789
|
-
callback =
|
|
168391
|
+
callback = resolve13;
|
|
167790
168392
|
}
|
|
167791
168393
|
});
|
|
167792
168394
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -169169,12 +169771,12 @@ var require_client_h2 = __commonJS({
|
|
|
169169
169771
|
cb();
|
|
169170
169772
|
}
|
|
169171
169773
|
}
|
|
169172
|
-
const waitForDrain = () => new Promise((
|
|
169774
|
+
const waitForDrain = () => new Promise((resolve13, reject) => {
|
|
169173
169775
|
assert(callback === null);
|
|
169174
169776
|
if (socket[kError]) {
|
|
169175
169777
|
reject(socket[kError]);
|
|
169176
169778
|
} else {
|
|
169177
|
-
callback =
|
|
169779
|
+
callback = resolve13;
|
|
169178
169780
|
}
|
|
169179
169781
|
});
|
|
169180
169782
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -169543,16 +170145,16 @@ var require_client = __commonJS({
|
|
|
169543
170145
|
return this[kNeedDrain] < 2;
|
|
169544
170146
|
}
|
|
169545
170147
|
[kClose]() {
|
|
169546
|
-
return new Promise((
|
|
170148
|
+
return new Promise((resolve13) => {
|
|
169547
170149
|
if (this[kSize]) {
|
|
169548
|
-
this[kClosedResolve] =
|
|
170150
|
+
this[kClosedResolve] = resolve13;
|
|
169549
170151
|
} else {
|
|
169550
|
-
|
|
170152
|
+
resolve13(null);
|
|
169551
170153
|
}
|
|
169552
170154
|
});
|
|
169553
170155
|
}
|
|
169554
170156
|
[kDestroy](err2) {
|
|
169555
|
-
return new Promise((
|
|
170157
|
+
return new Promise((resolve13) => {
|
|
169556
170158
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
169557
170159
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
169558
170160
|
const request = requests[i2];
|
|
@@ -169565,7 +170167,7 @@ var require_client = __commonJS({
|
|
|
169565
170167
|
this[kClosedResolve]();
|
|
169566
170168
|
this[kClosedResolve] = null;
|
|
169567
170169
|
}
|
|
169568
|
-
|
|
170170
|
+
resolve13(null);
|
|
169569
170171
|
};
|
|
169570
170172
|
if (this[kHTTPContext]) {
|
|
169571
170173
|
this[kHTTPContext].destroy(err2, callback);
|
|
@@ -169978,8 +170580,8 @@ var require_pool_base = __commonJS({
|
|
|
169978
170580
|
}
|
|
169979
170581
|
return Promise.all(closeAll);
|
|
169980
170582
|
} else {
|
|
169981
|
-
return new Promise((
|
|
169982
|
-
this[kClosedResolve] =
|
|
170583
|
+
return new Promise((resolve13) => {
|
|
170584
|
+
this[kClosedResolve] = resolve13;
|
|
169983
170585
|
});
|
|
169984
170586
|
}
|
|
169985
170587
|
}
|
|
@@ -172642,7 +173244,7 @@ var require_readable = __commonJS({
|
|
|
172642
173244
|
if (this._readableState.closeEmitted) {
|
|
172643
173245
|
return Promise.resolve(null);
|
|
172644
173246
|
}
|
|
172645
|
-
return new Promise((
|
|
173247
|
+
return new Promise((resolve13, reject) => {
|
|
172646
173248
|
if (this[kContentLength] && this[kContentLength] > limit3 || this[kBytesRead] > limit3) {
|
|
172647
173249
|
this.destroy(new AbortError2());
|
|
172648
173250
|
}
|
|
@@ -172656,11 +173258,11 @@ var require_readable = __commonJS({
|
|
|
172656
173258
|
if (signal.aborted) {
|
|
172657
173259
|
reject(signal.reason ?? new AbortError2());
|
|
172658
173260
|
} else {
|
|
172659
|
-
|
|
173261
|
+
resolve13(null);
|
|
172660
173262
|
}
|
|
172661
173263
|
});
|
|
172662
173264
|
} else {
|
|
172663
|
-
this.on("close",
|
|
173265
|
+
this.on("close", resolve13);
|
|
172664
173266
|
}
|
|
172665
173267
|
this.on("error", noop4).on("data", () => {
|
|
172666
173268
|
if (this[kBytesRead] > limit3) {
|
|
@@ -172688,7 +173290,7 @@ var require_readable = __commonJS({
|
|
|
172688
173290
|
}
|
|
172689
173291
|
function consume(stream12, type) {
|
|
172690
173292
|
assert(!stream12[kConsume]);
|
|
172691
|
-
return new Promise((
|
|
173293
|
+
return new Promise((resolve13, reject) => {
|
|
172692
173294
|
if (isUnusable(stream12)) {
|
|
172693
173295
|
const rState = stream12._readableState;
|
|
172694
173296
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -172703,7 +173305,7 @@ var require_readable = __commonJS({
|
|
|
172703
173305
|
stream12[kConsume] = {
|
|
172704
173306
|
type,
|
|
172705
173307
|
stream: stream12,
|
|
172706
|
-
resolve:
|
|
173308
|
+
resolve: resolve13,
|
|
172707
173309
|
reject,
|
|
172708
173310
|
length: 0,
|
|
172709
173311
|
body: []
|
|
@@ -172781,18 +173383,18 @@ var require_readable = __commonJS({
|
|
|
172781
173383
|
return buffer;
|
|
172782
173384
|
}
|
|
172783
173385
|
function consumeEnd(consume2, encoding) {
|
|
172784
|
-
const { type, body, resolve:
|
|
173386
|
+
const { type, body, resolve: resolve13, stream: stream12, length } = consume2;
|
|
172785
173387
|
try {
|
|
172786
173388
|
if (type === "text") {
|
|
172787
|
-
|
|
173389
|
+
resolve13(chunksDecode(body, length, encoding));
|
|
172788
173390
|
} else if (type === "json") {
|
|
172789
|
-
|
|
173391
|
+
resolve13(JSON.parse(chunksDecode(body, length, encoding)));
|
|
172790
173392
|
} else if (type === "arrayBuffer") {
|
|
172791
|
-
|
|
173393
|
+
resolve13(chunksConcat(body, length).buffer);
|
|
172792
173394
|
} else if (type === "blob") {
|
|
172793
|
-
|
|
173395
|
+
resolve13(new Blob(body, { type: stream12[kContentType] }));
|
|
172794
173396
|
} else if (type === "bytes") {
|
|
172795
|
-
|
|
173397
|
+
resolve13(chunksConcat(body, length));
|
|
172796
173398
|
}
|
|
172797
173399
|
consumeFinish(consume2);
|
|
172798
173400
|
} catch (err2) {
|
|
@@ -173011,9 +173613,9 @@ var require_api_request = __commonJS({
|
|
|
173011
173613
|
};
|
|
173012
173614
|
function request(opts, callback) {
|
|
173013
173615
|
if (callback === void 0) {
|
|
173014
|
-
return new Promise((
|
|
173616
|
+
return new Promise((resolve13, reject) => {
|
|
173015
173617
|
request.call(this, opts, (err2, data) => {
|
|
173016
|
-
return err2 ? reject(err2) :
|
|
173618
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173017
173619
|
});
|
|
173018
173620
|
});
|
|
173019
173621
|
}
|
|
@@ -173274,9 +173876,9 @@ var require_api_stream = __commonJS({
|
|
|
173274
173876
|
};
|
|
173275
173877
|
function stream12(opts, factory, callback) {
|
|
173276
173878
|
if (callback === void 0) {
|
|
173277
|
-
return new Promise((
|
|
173879
|
+
return new Promise((resolve13, reject) => {
|
|
173278
173880
|
stream12.call(this, opts, factory, (err2, data) => {
|
|
173279
|
-
return err2 ? reject(err2) :
|
|
173881
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173280
173882
|
});
|
|
173281
173883
|
});
|
|
173282
173884
|
}
|
|
@@ -173576,9 +174178,9 @@ var require_api_upgrade = __commonJS({
|
|
|
173576
174178
|
};
|
|
173577
174179
|
function upgrade(opts, callback) {
|
|
173578
174180
|
if (callback === void 0) {
|
|
173579
|
-
return new Promise((
|
|
174181
|
+
return new Promise((resolve13, reject) => {
|
|
173580
174182
|
upgrade.call(this, opts, (err2, data) => {
|
|
173581
|
-
return err2 ? reject(err2) :
|
|
174183
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173582
174184
|
});
|
|
173583
174185
|
});
|
|
173584
174186
|
}
|
|
@@ -173672,9 +174274,9 @@ var require_api_connect = __commonJS({
|
|
|
173672
174274
|
};
|
|
173673
174275
|
function connect(opts, callback) {
|
|
173674
174276
|
if (callback === void 0) {
|
|
173675
|
-
return new Promise((
|
|
174277
|
+
return new Promise((resolve13, reject) => {
|
|
173676
174278
|
connect.call(this, opts, (err2, data) => {
|
|
173677
|
-
return err2 ? reject(err2) :
|
|
174279
|
+
return err2 ? reject(err2) : resolve13(data);
|
|
173678
174280
|
});
|
|
173679
174281
|
});
|
|
173680
174282
|
}
|
|
@@ -175141,7 +175743,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
175141
175743
|
"node_modules/.pnpm/undici@8.10.2/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
175142
175744
|
"use strict";
|
|
175143
175745
|
var { writeFile: writeFile10, readFile: readFile10, mkdir: mkdir7 } = __require("node:fs/promises");
|
|
175144
|
-
var { dirname:
|
|
175746
|
+
var { dirname: dirname18, resolve: resolve13 } = __require("node:path");
|
|
175145
175747
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
175146
175748
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
175147
175749
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -175357,7 +175959,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
175357
175959
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
175358
175960
|
}
|
|
175359
175961
|
try {
|
|
175360
|
-
const data = await readFile10(
|
|
175962
|
+
const data = await readFile10(resolve13(path8), "utf8");
|
|
175361
175963
|
const parsed2 = JSON.parse(data);
|
|
175362
175964
|
if (Array.isArray(parsed2)) {
|
|
175363
175965
|
this.#snapshots.clear();
|
|
@@ -175386,8 +175988,8 @@ var require_snapshot_recorder = __commonJS({
|
|
|
175386
175988
|
if (!path8) {
|
|
175387
175989
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
175388
175990
|
}
|
|
175389
|
-
const resolvedPath =
|
|
175390
|
-
await mkdir7(
|
|
175991
|
+
const resolvedPath = resolve13(path8);
|
|
175992
|
+
await mkdir7(dirname18(resolvedPath), { recursive: true });
|
|
175391
175993
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
175392
175994
|
hash,
|
|
175393
175995
|
snapshot
|
|
@@ -183050,7 +183652,7 @@ var require_fetch = __commonJS({
|
|
|
183050
183652
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
183051
183653
|
return dispatchWithProtocolPreference(body);
|
|
183052
183654
|
function dispatchWithProtocolPreference(body2, allowH2) {
|
|
183053
|
-
return new Promise((
|
|
183655
|
+
return new Promise((resolve13, reject) => agent.dispatch(
|
|
183054
183656
|
{
|
|
183055
183657
|
path: hasTrailingQuestionMark ? `${path8}?` : path8,
|
|
183056
183658
|
origin: url.origin,
|
|
@@ -183133,7 +183735,7 @@ var require_fetch = __commonJS({
|
|
|
183133
183735
|
}
|
|
183134
183736
|
}
|
|
183135
183737
|
const onError = (err2) => this.onResponseError(controller, err2);
|
|
183136
|
-
|
|
183738
|
+
resolve13({
|
|
183137
183739
|
status,
|
|
183138
183740
|
statusText,
|
|
183139
183741
|
headersList,
|
|
@@ -183166,7 +183768,7 @@ var require_fetch = __commonJS({
|
|
|
183166
183768
|
fetchParams.controller.off("terminated", this.abort);
|
|
183167
183769
|
}
|
|
183168
183770
|
if (request.mode === "websocket" && allowH2 !== false && error?.code === "UND_ERR_INFO" && error?.message === "HTTP/2: Extended CONNECT protocol not supported by server") {
|
|
183169
|
-
|
|
183771
|
+
resolve13(dispatchWithProtocolPreference(body2, false));
|
|
183170
183772
|
return;
|
|
183171
183773
|
}
|
|
183172
183774
|
this.body?.destroy(error);
|
|
@@ -183183,7 +183785,7 @@ var require_fetch = __commonJS({
|
|
|
183183
183785
|
const rawHeaders = controller?.rawHeaders ?? [];
|
|
183184
183786
|
const headersList = new HeadersList();
|
|
183185
183787
|
appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders);
|
|
183186
|
-
|
|
183788
|
+
resolve13({
|
|
183187
183789
|
status,
|
|
183188
183790
|
statusText: STATUS_CODES[status],
|
|
183189
183791
|
headersList,
|
|
@@ -188111,8 +188713,8 @@ var init_host = __esm({
|
|
|
188111
188713
|
pending = /* @__PURE__ */ new Map();
|
|
188112
188714
|
finished = false;
|
|
188113
188715
|
constructor(options) {
|
|
188114
|
-
this.promise = new Promise((
|
|
188115
|
-
this.resolveResult =
|
|
188716
|
+
this.promise = new Promise((resolve13) => {
|
|
188717
|
+
this.resolveResult = resolve13;
|
|
188116
188718
|
});
|
|
188117
188719
|
this.tools = options.tools;
|
|
188118
188720
|
this.globals = options.globals;
|
|
@@ -188851,7 +189453,7 @@ __export(execute_exports, {
|
|
|
188851
189453
|
import { randomBytes } from "node:crypto";
|
|
188852
189454
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
188853
189455
|
import { tmpdir } from "node:os";
|
|
188854
|
-
import { join as
|
|
189456
|
+
import { join as join13 } from "node:path";
|
|
188855
189457
|
function truncateText(text, maxChars) {
|
|
188856
189458
|
return text.length > maxChars ? `${text.slice(0, maxChars - 3)}...` : text;
|
|
188857
189459
|
}
|
|
@@ -188889,7 +189491,7 @@ function createLimiter(limit3) {
|
|
|
188889
189491
|
const waiting = [];
|
|
188890
189492
|
return async (run) => {
|
|
188891
189493
|
if (active >= limit3)
|
|
188892
|
-
await new Promise((
|
|
189494
|
+
await new Promise((resolve13) => waiting.push(resolve13));
|
|
188893
189495
|
active++;
|
|
188894
189496
|
try {
|
|
188895
189497
|
return await run();
|
|
@@ -188936,7 +189538,7 @@ function formatError(result, calls) {
|
|
|
188936
189538
|
${formatCallSummary(calls)}`;
|
|
188937
189539
|
}
|
|
188938
189540
|
async function spillOutput(text) {
|
|
188939
|
-
const path8 =
|
|
189541
|
+
const path8 = join13(tmpdir(), `pi-codemode-${randomBytes(8).toString("hex")}.txt`);
|
|
188940
189542
|
try {
|
|
188941
189543
|
await writeFile4(path8, text);
|
|
188942
189544
|
return { path: path8 };
|
|
@@ -189612,23 +190214,23 @@ var init_open_browser = __esm({
|
|
|
189612
190214
|
});
|
|
189613
190215
|
|
|
189614
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
|
|
189615
|
-
import { existsSync as
|
|
189616
|
-
import { dirname as
|
|
189617
|
-
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) {
|
|
189618
190220
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
189619
190221
|
}
|
|
189620
190222
|
function readConfigFile(path8, scope, state3) {
|
|
189621
190223
|
const { servers, errors } = state3;
|
|
189622
|
-
if (!
|
|
190224
|
+
if (!existsSync4(path8))
|
|
189623
190225
|
return;
|
|
189624
190226
|
let parsed2;
|
|
189625
190227
|
try {
|
|
189626
|
-
parsed2 = JSON.parse(
|
|
190228
|
+
parsed2 = JSON.parse(readFileSync4(path8, "utf8"));
|
|
189627
190229
|
} catch (error) {
|
|
189628
190230
|
errors.push(`${path8}: ${error instanceof Error ? error.message : String(error)}`);
|
|
189629
190231
|
return;
|
|
189630
190232
|
}
|
|
189631
|
-
if (!
|
|
190233
|
+
if (!isRecord5(parsed2) || parsed2.mcpServers !== void 0 && !isRecord5(parsed2.mcpServers)) {
|
|
189632
190234
|
errors.push(`${path8}: expected an object with an "mcpServers" object`);
|
|
189633
190235
|
return;
|
|
189634
190236
|
}
|
|
@@ -189647,9 +190249,9 @@ function readConfigFile(path8, scope, state3) {
|
|
|
189647
190249
|
}
|
|
189648
190250
|
function loadMcpConfig(options) {
|
|
189649
190251
|
const state3 = { servers: /* @__PURE__ */ new Map(), errors: [] };
|
|
189650
|
-
readConfigFile(
|
|
190252
|
+
readConfigFile(join14(options.agentDir, "mcp.json"), "global", state3);
|
|
189651
190253
|
if (options.projectTrusted)
|
|
189652
|
-
readConfigFile(
|
|
190254
|
+
readConfigFile(join14(options.cwd, CONFIG_DIR_NAME, "mcp.json"), "project", state3);
|
|
189653
190255
|
return {
|
|
189654
190256
|
servers: [...state3.servers.values()],
|
|
189655
190257
|
...state3.autoEnableCodemode === void 0 ? {} : { autoEnableCodemode: state3.autoEnableCodemode },
|
|
@@ -189659,7 +190261,7 @@ function loadMcpConfig(options) {
|
|
|
189659
190261
|
function updateMcpServerConfig(path8, name, patch) {
|
|
189660
190262
|
editMcpServers(path8, (servers) => {
|
|
189661
190263
|
const server = servers?.[name];
|
|
189662
|
-
if (!
|
|
190264
|
+
if (!isRecord5(server))
|
|
189663
190265
|
throw new Error(`${path8} does not define MCP server "${name}"`);
|
|
189664
190266
|
if (patch.enabled !== void 0) {
|
|
189665
190267
|
if (patch.enabled)
|
|
@@ -189677,17 +190279,17 @@ function updateMcpServerConfig(path8, name, patch) {
|
|
|
189677
190279
|
});
|
|
189678
190280
|
}
|
|
189679
190281
|
function editMcpServers(path8, edit) {
|
|
189680
|
-
const text =
|
|
190282
|
+
const text = existsSync4(path8) ? readFileSync4(path8, "utf8") : void 0;
|
|
189681
190283
|
const parsed2 = text === void 0 ? {} : JSON.parse(text);
|
|
189682
|
-
if (!
|
|
190284
|
+
if (!isRecord5(parsed2) || parsed2.mcpServers !== void 0 && !isRecord5(parsed2.mcpServers)) {
|
|
189683
190285
|
throw new Error(`${path8}: expected an object with an "mcpServers" object`);
|
|
189684
190286
|
}
|
|
189685
|
-
const servers =
|
|
190287
|
+
const servers = isRecord5(parsed2.mcpServers) ? parsed2.mcpServers : void 0;
|
|
189686
190288
|
if (!edit(servers, parsed2))
|
|
189687
190289
|
return;
|
|
189688
190290
|
const indent = text && /^([ \t]+)\S/m.exec(text)?.[1] || " ";
|
|
189689
|
-
mkdirSync3(
|
|
189690
|
-
|
|
190291
|
+
mkdirSync3(dirname11(path8), { recursive: true });
|
|
190292
|
+
writeFileSync3(path8, `${JSON.stringify(parsed2, null, indent)}
|
|
189691
190293
|
`);
|
|
189692
190294
|
}
|
|
189693
190295
|
var init_config6 = __esm({
|
|
@@ -190028,9 +190630,9 @@ var init_client3 = __esm({
|
|
|
190028
190630
|
method,
|
|
190029
190631
|
...requestParams === void 0 ? {} : { params: requestParams }
|
|
190030
190632
|
};
|
|
190031
|
-
return new Promise((
|
|
190633
|
+
return new Promise((resolve13, reject) => {
|
|
190032
190634
|
const entry = {
|
|
190033
|
-
resolve:
|
|
190635
|
+
resolve: resolve13,
|
|
190034
190636
|
reject,
|
|
190035
190637
|
timeoutMs: options.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
190036
190638
|
timer: void 0,
|
|
@@ -190402,10 +191004,10 @@ var init_stdio = __esm({
|
|
|
190402
191004
|
this.stdoutBuffer = Buffer.alloc(0);
|
|
190403
191005
|
this.emitClose();
|
|
190404
191006
|
});
|
|
190405
|
-
await new Promise((
|
|
191007
|
+
await new Promise((resolve13, reject) => {
|
|
190406
191008
|
const onSpawn = () => {
|
|
190407
191009
|
child.off("error", onError);
|
|
190408
|
-
|
|
191010
|
+
resolve13();
|
|
190409
191011
|
};
|
|
190410
191012
|
const onError = (error) => {
|
|
190411
191013
|
child.off("spawn", onSpawn);
|
|
@@ -190425,8 +191027,8 @@ var init_stdio = __esm({
|
|
|
190425
191027
|
throw new McpConnectionClosedError();
|
|
190426
191028
|
const payload = `${JSON.stringify(message)}
|
|
190427
191029
|
`;
|
|
190428
|
-
await new Promise((
|
|
190429
|
-
stdin.write(payload, (error) => error ? reject(error) :
|
|
191030
|
+
await new Promise((resolve13, reject) => {
|
|
191031
|
+
stdin.write(payload, (error) => error ? reject(error) : resolve13());
|
|
190430
191032
|
});
|
|
190431
191033
|
}
|
|
190432
191034
|
async close() {
|
|
@@ -190443,13 +191045,13 @@ var init_stdio = __esm({
|
|
|
190443
191045
|
return;
|
|
190444
191046
|
}
|
|
190445
191047
|
const closeTimeoutMs = this.options.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
|
|
190446
|
-
await new Promise((
|
|
191048
|
+
await new Promise((resolve13) => {
|
|
190447
191049
|
const timers = [];
|
|
190448
191050
|
child.once("close", () => {
|
|
190449
191051
|
for (const timer of timers)
|
|
190450
191052
|
clearTimeout(timer);
|
|
190451
191053
|
killProcessTree2(child, "SIGTERM");
|
|
190452
|
-
|
|
191054
|
+
resolve13();
|
|
190453
191055
|
});
|
|
190454
191056
|
const grace = Math.min(STDIN_CLOSE_GRACE_MS, closeTimeoutMs);
|
|
190455
191057
|
timers.push(setTimeout(() => killProcessTree2(child, "SIGTERM"), grace));
|
|
@@ -190917,14 +191519,14 @@ var init_streamable_http = __esm({
|
|
|
190917
191519
|
const signal = this.controller.signal;
|
|
190918
191520
|
if (signal.aborted)
|
|
190919
191521
|
return Promise.resolve(false);
|
|
190920
|
-
return new Promise((
|
|
191522
|
+
return new Promise((resolve13) => {
|
|
190921
191523
|
const onAbort = () => {
|
|
190922
191524
|
clearTimeout(timer);
|
|
190923
|
-
|
|
191525
|
+
resolve13(false);
|
|
190924
191526
|
};
|
|
190925
191527
|
const timer = setTimeout(() => {
|
|
190926
191528
|
signal.removeEventListener("abort", onAbort);
|
|
190927
|
-
|
|
191529
|
+
resolve13(true);
|
|
190928
191530
|
}, ms);
|
|
190929
191531
|
timer.unref?.();
|
|
190930
191532
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
@@ -190949,12 +191551,12 @@ var init_dist7 = __esm({
|
|
|
190949
191551
|
import { createHash as createHash2, randomBytes as randomBytes2 } from "node:crypto";
|
|
190950
191552
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
190951
191553
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
190952
|
-
import { join as
|
|
191554
|
+
import { join as join15 } from "node:path";
|
|
190953
191555
|
function toToolExposure(exposure) {
|
|
190954
191556
|
return exposure === "codemode-deferred" ? "deferred" : exposure;
|
|
190955
191557
|
}
|
|
190956
191558
|
async function saveToTempFile(data, extension2) {
|
|
190957
|
-
const path8 =
|
|
191559
|
+
const path8 = join15(tmpdir2(), `pi-mcp-${randomBytes2(8).toString("hex")}${extension2}`);
|
|
190958
191560
|
await writeFile5(path8, data, { mode: 384 });
|
|
190959
191561
|
return path8;
|
|
190960
191562
|
}
|
|
@@ -191422,11 +192024,11 @@ var init_callback3 = __esm({
|
|
|
191422
192024
|
const path8 = options.path ?? "/callback";
|
|
191423
192025
|
let instance;
|
|
191424
192026
|
const server = createServer((request, response) => instance?.handle(request.url ?? "/", response));
|
|
191425
|
-
await new Promise((
|
|
192027
|
+
await new Promise((resolve13, reject) => {
|
|
191426
192028
|
server.once("error", reject);
|
|
191427
192029
|
server.listen(options.port ?? 0, host, () => {
|
|
191428
192030
|
server.off("error", reject);
|
|
191429
|
-
|
|
192031
|
+
resolve13();
|
|
191430
192032
|
});
|
|
191431
192033
|
});
|
|
191432
192034
|
const address = server.address();
|
|
@@ -191438,12 +192040,12 @@ var init_callback3 = __esm({
|
|
|
191438
192040
|
waitForCallback(state3) {
|
|
191439
192041
|
if (this.pending.has(state3))
|
|
191440
192042
|
throw new Error("OAuth state is already pending");
|
|
191441
|
-
return new Promise((
|
|
192043
|
+
return new Promise((resolve13, reject) => {
|
|
191442
192044
|
const timer = setTimeout(() => {
|
|
191443
192045
|
this.pending.delete(state3);
|
|
191444
192046
|
reject(new Error("OAuth callback timed out"));
|
|
191445
192047
|
}, this.timeoutMs);
|
|
191446
|
-
this.pending.set(state3, { resolve:
|
|
192048
|
+
this.pending.set(state3, { resolve: resolve13, reject, timer });
|
|
191447
192049
|
});
|
|
191448
192050
|
}
|
|
191449
192051
|
async close() {
|
|
@@ -191452,8 +192054,8 @@ var init_callback3 = __esm({
|
|
|
191452
192054
|
pending.reject(new Error("OAuth callback server closed"));
|
|
191453
192055
|
}
|
|
191454
192056
|
this.pending.clear();
|
|
191455
|
-
await new Promise((
|
|
191456
|
-
this.server.close((error) => error ? reject(error) :
|
|
192057
|
+
await new Promise((resolve13, reject) => {
|
|
192058
|
+
this.server.close((error) => error ? reject(error) : resolve13());
|
|
191457
192059
|
});
|
|
191458
192060
|
}
|
|
191459
192061
|
reply(response, status, page) {
|
|
@@ -192254,7 +192856,7 @@ var init_oauth_page = __esm({
|
|
|
192254
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
|
|
192255
192857
|
import { createHash as createHash3 } from "node:crypto";
|
|
192256
192858
|
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
192257
|
-
import { join as
|
|
192859
|
+
import { join as join16 } from "node:path";
|
|
192258
192860
|
function callbackSettings(settings3) {
|
|
192259
192861
|
const url = new URL(settings3.callbackUrl ?? `http://${CALLBACK_HOST}${CALLBACK_PATH}`);
|
|
192260
192862
|
const address = url.hostname.replace(/^\[|\]$/g, "");
|
|
@@ -192460,7 +193062,7 @@ var init_oauth2 = __esm({
|
|
|
192460
193062
|
/** Directory for the refresh lock files. Without one, refreshes are only serialized in this process. */
|
|
192461
193063
|
lockDir;
|
|
192462
193064
|
constructor(backend, lockDir) {
|
|
192463
|
-
this.backend = backend ?? new FileAuthStorageBackend(
|
|
193065
|
+
this.backend = backend ?? new FileAuthStorageBackend(join16(getAgentDir(), "mcp-auth.json"));
|
|
192464
193066
|
this.lockDir = backend ? lockDir : getAgentDir();
|
|
192465
193067
|
}
|
|
192466
193068
|
forServer(serverUrl) {
|
|
@@ -192482,7 +193084,7 @@ var init_oauth2 = __esm({
|
|
|
192482
193084
|
return fn();
|
|
192483
193085
|
mkdirSync4(this.lockDir, { recursive: true, mode: 448 });
|
|
192484
193086
|
const hash = createHash3("sha256").update(key).digest("hex").slice(0, 16);
|
|
192485
|
-
const release = await import_proper_lockfile4.default.lock(
|
|
193087
|
+
const release = await import_proper_lockfile4.default.lock(join16(this.lockDir, `mcp-auth-refresh-${hash}`), {
|
|
192486
193088
|
realpath: false,
|
|
192487
193089
|
stale: REFRESH_LOCK_STALE_MS,
|
|
192488
193090
|
retries: {
|
|
@@ -192537,9 +193139,9 @@ var init_oauth2 = __esm({
|
|
|
192537
193139
|
});
|
|
192538
193140
|
|
|
192539
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
|
|
192540
|
-
import { appendFileSync, mkdirSync as mkdirSync5, renameSync, statSync as
|
|
192541
|
-
import { dirname as
|
|
192542
|
-
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) {
|
|
192543
193145
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
192544
193146
|
}
|
|
192545
193147
|
function formatData(data) {
|
|
@@ -192552,7 +193154,7 @@ function formatData(data) {
|
|
|
192552
193154
|
}
|
|
192553
193155
|
}
|
|
192554
193156
|
function formatMcpLogMessage(server, params, now = /* @__PURE__ */ new Date()) {
|
|
192555
|
-
const message =
|
|
193157
|
+
const message = isRecord6(params) ? params : { data: params };
|
|
192556
193158
|
const level = typeof message.level === "string" ? message.level : "info";
|
|
192557
193159
|
const logger = typeof message.logger === "string" && message.logger ? ` ${message.logger}:` : "";
|
|
192558
193160
|
const text = formatData(message.data).replace(/\r?\n/g, "\n ");
|
|
@@ -192573,22 +193175,22 @@ var init_log3 = __esm({
|
|
|
192573
193175
|
const line = formatMcpLogMessage(server, params);
|
|
192574
193176
|
try {
|
|
192575
193177
|
if (this.size === void 0) {
|
|
192576
|
-
mkdirSync5(
|
|
193178
|
+
mkdirSync5(dirname12(this.path), { recursive: true });
|
|
192577
193179
|
this.size = this.currentSize();
|
|
192578
193180
|
}
|
|
192579
193181
|
if (this.size > MAX_LOG_BYTES) {
|
|
192580
193182
|
if (this.currentSize() > MAX_LOG_BYTES)
|
|
192581
|
-
|
|
193183
|
+
renameSync2(this.path, `${this.path}.1`);
|
|
192582
193184
|
this.size = this.currentSize();
|
|
192583
193185
|
}
|
|
192584
|
-
|
|
193186
|
+
appendFileSync2(this.path, line);
|
|
192585
193187
|
this.size += Buffer.byteLength(line);
|
|
192586
193188
|
} catch {
|
|
192587
193189
|
}
|
|
192588
193190
|
}
|
|
192589
193191
|
currentSize() {
|
|
192590
193192
|
try {
|
|
192591
|
-
return
|
|
193193
|
+
return statSync4(this.path).size;
|
|
192592
193194
|
} catch {
|
|
192593
193195
|
return 0;
|
|
192594
193196
|
}
|
|
@@ -192608,7 +193210,7 @@ __export(runtime_exports, {
|
|
|
192608
193210
|
signInMcpServer: () => signInMcpServer
|
|
192609
193211
|
});
|
|
192610
193212
|
import { homedir as homedir5 } from "node:os";
|
|
192611
|
-
import { basename as
|
|
193213
|
+
import { basename as basename11, join as join17, resolve as resolve7 } from "node:path";
|
|
192612
193214
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
192613
193215
|
function errorMessage3(error) {
|
|
192614
193216
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -192632,7 +193234,7 @@ function expandHome(value2) {
|
|
|
192632
193234
|
if (value2 === "~")
|
|
192633
193235
|
return homedir5();
|
|
192634
193236
|
if (value2.startsWith("~/") || process.platform === "win32" && value2.startsWith("~\\")) {
|
|
192635
|
-
return
|
|
193237
|
+
return join17(homedir5(), value2.slice(2));
|
|
192636
193238
|
}
|
|
192637
193239
|
return value2;
|
|
192638
193240
|
}
|
|
@@ -192652,7 +193254,7 @@ function createDefaultTransport(entry, cwd, authProvider) {
|
|
|
192652
193254
|
return new StdioTransport({
|
|
192653
193255
|
command: expandHome(config.command),
|
|
192654
193256
|
args: config.args?.map(expandHome),
|
|
192655
|
-
cwd:
|
|
193257
|
+
cwd: resolve7(cwd, expandHome(config.cwd ?? ".")),
|
|
192656
193258
|
env: env2,
|
|
192657
193259
|
stderr: "pipe"
|
|
192658
193260
|
});
|
|
@@ -192798,7 +193400,7 @@ var init_runtime = __esm({
|
|
|
192798
193400
|
return await run(client);
|
|
192799
193401
|
} catch (error) {
|
|
192800
193402
|
if (readOnly && attempt === 1 && error instanceof McpHttpError && isTransientError(error)) {
|
|
192801
|
-
await new Promise((
|
|
193403
|
+
await new Promise((resolve13) => setTimeout(resolve13, CONNECT_RETRY_DELAYS_MS[0]));
|
|
192802
193404
|
continue;
|
|
192803
193405
|
}
|
|
192804
193406
|
if (error instanceof McpSessionExpiredError && attempt === 1) {
|
|
@@ -192859,7 +193461,7 @@ var init_runtime = __esm({
|
|
|
192859
193461
|
if (this.closed || delay2 === void 0 || !isTransientError(error)) {
|
|
192860
193462
|
throw this.connectFailed(error);
|
|
192861
193463
|
}
|
|
192862
|
-
await new Promise((
|
|
193464
|
+
await new Promise((resolve13) => setTimeout(resolve13, delay2));
|
|
192863
193465
|
if (this.closed)
|
|
192864
193466
|
throw this.connectFailed(error);
|
|
192865
193467
|
}
|
|
@@ -192870,7 +193472,7 @@ var init_runtime = __esm({
|
|
|
192870
193472
|
name: "pi",
|
|
192871
193473
|
version: VERSION,
|
|
192872
193474
|
requestTimeoutMs: this.timeoutMs,
|
|
192873
|
-
roots: [{ uri: pathToFileURL2(this.cwd).href, name:
|
|
193475
|
+
roots: [{ uri: pathToFileURL2(this.cwd).href, name: basename11(this.cwd) }]
|
|
192874
193476
|
});
|
|
192875
193477
|
const log = this.log;
|
|
192876
193478
|
if (log)
|
|
@@ -193063,7 +193665,7 @@ var init_ui = __esm({
|
|
|
193063
193665
|
this.tui.requestRender();
|
|
193064
193666
|
}
|
|
193065
193667
|
menu(build, subscribe) {
|
|
193066
|
-
return new Promise((
|
|
193668
|
+
return new Promise((resolve13) => {
|
|
193067
193669
|
let unsubscribe;
|
|
193068
193670
|
let settled = false;
|
|
193069
193671
|
const finish = (value2) => {
|
|
@@ -193071,10 +193673,10 @@ var init_ui = __esm({
|
|
|
193071
193673
|
return;
|
|
193072
193674
|
settled = true;
|
|
193073
193675
|
unsubscribe?.();
|
|
193074
|
-
|
|
193676
|
+
resolve13(value2);
|
|
193075
193677
|
};
|
|
193076
193678
|
let selected;
|
|
193077
|
-
const
|
|
193679
|
+
const render2 = () => {
|
|
193078
193680
|
const menu = build();
|
|
193079
193681
|
const wanted = selected ?? menu.selected;
|
|
193080
193682
|
const body = [];
|
|
@@ -193105,10 +193707,10 @@ var init_ui = __esm({
|
|
|
193105
193707
|
body.push(list2);
|
|
193106
193708
|
this.setContent(frame(this.theme, menu.title, body, footer), (data) => list2.handleInput(data));
|
|
193107
193709
|
};
|
|
193108
|
-
|
|
193710
|
+
render2();
|
|
193109
193711
|
unsubscribe = subscribe?.(() => {
|
|
193110
193712
|
if (!settled)
|
|
193111
|
-
|
|
193713
|
+
render2();
|
|
193112
193714
|
});
|
|
193113
193715
|
});
|
|
193114
193716
|
}
|
|
@@ -193116,14 +193718,14 @@ var init_ui = __esm({
|
|
|
193116
193718
|
this.setContent(frame(this.theme, title, [new Spacer(1), new Text(this.theme.fg("muted", message), 1, 0)]));
|
|
193117
193719
|
}
|
|
193118
193720
|
redirectUrl(title, authorizationUrl, signal) {
|
|
193119
|
-
return new Promise((
|
|
193721
|
+
return new Promise((resolve13) => {
|
|
193120
193722
|
let settled = false;
|
|
193121
193723
|
const finish = (value2) => {
|
|
193122
193724
|
if (settled)
|
|
193123
193725
|
return;
|
|
193124
193726
|
settled = true;
|
|
193125
193727
|
signal.removeEventListener("abort", onAbort);
|
|
193126
|
-
|
|
193728
|
+
resolve13(value2);
|
|
193127
193729
|
};
|
|
193128
193730
|
const onAbort = () => finish(void 0);
|
|
193129
193731
|
if (signal.aborted) {
|
|
@@ -193170,7 +193772,7 @@ var init_ui = __esm({
|
|
|
193170
193772
|
});
|
|
193171
193773
|
|
|
193172
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
|
|
193173
|
-
import { join as
|
|
193775
|
+
import { join as join18, resolve as resolve8 } from "node:path";
|
|
193174
193776
|
function errorMessage4(error) {
|
|
193175
193777
|
return error instanceof Error ? error.message : String(error);
|
|
193176
193778
|
}
|
|
@@ -193280,7 +193882,7 @@ function createMcpExtension(options = {}) {
|
|
|
193280
193882
|
return credentials;
|
|
193281
193883
|
};
|
|
193282
193884
|
const getServerLog = (runtime) => {
|
|
193283
|
-
serverLog ??= new runtime.McpServerLog(options.logPath ??
|
|
193885
|
+
serverLog ??= new runtime.McpServerLog(options.logPath ?? join18(getAgentDir(), "mcp.log"));
|
|
193284
193886
|
return serverLog;
|
|
193285
193887
|
};
|
|
193286
193888
|
const toolOwners = /* @__PURE__ */ new Map();
|
|
@@ -193541,7 +194143,7 @@ Run /mcp to fix.`, "warning");
|
|
|
193541
194143
|
label: server.entry.name,
|
|
193542
194144
|
description: `${describeState(server)} \xB7 ${exposureOf(server.entry)} \xB7 ${server.entry.scope ?? server.entry.source}`
|
|
193543
194145
|
})),
|
|
193544
|
-
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.`,
|
|
193545
194147
|
confirmLabel: "manage",
|
|
193546
194148
|
cancelLabel: "close"
|
|
193547
194149
|
});
|
|
@@ -193691,7 +194293,7 @@ Run /mcp to fix.`, "warning");
|
|
|
193691
194293
|
};
|
|
193692
194294
|
const formatStatus = () => {
|
|
193693
194295
|
if (servers.length === 0 && configErrors.length === 0 && overridden.length === 0) {
|
|
193694
|
-
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.`;
|
|
193695
194297
|
}
|
|
193696
194298
|
const lines = servers.map((server) => {
|
|
193697
194299
|
const { name } = server.entry;
|
|
@@ -193779,7 +194381,7 @@ ${url.href}`, "info");
|
|
|
193779
194381
|
reportProblems(ctx);
|
|
193780
194382
|
return;
|
|
193781
194383
|
}
|
|
193782
|
-
pending = new Promise((
|
|
194384
|
+
pending = new Promise((resolve13) => setImmediate(resolve13)).then(() => loadMcpRuntime()).then(async () => {
|
|
193783
194385
|
if (current !== generation)
|
|
193784
194386
|
return;
|
|
193785
194387
|
const started = await Promise.all(enabled.map((server) => createConnection(server)));
|
|
@@ -193805,8 +194407,8 @@ ${url.href}`, "info");
|
|
|
193805
194407
|
let timer;
|
|
193806
194408
|
const finished2 = await Promise.race([
|
|
193807
194409
|
startup.then(() => true),
|
|
193808
|
-
new Promise((
|
|
193809
|
-
timer = setTimeout(() =>
|
|
194410
|
+
new Promise((resolve13) => {
|
|
194411
|
+
timer = setTimeout(() => resolve13(false), startupWaitMs);
|
|
193810
194412
|
})
|
|
193811
194413
|
]);
|
|
193812
194414
|
clearTimeout(timer);
|
|
@@ -195351,24 +195953,26 @@ var init_archivist_record_pointer = __esm({
|
|
|
195351
195953
|
"src/archivist-record-pointer.ts"() {
|
|
195352
195954
|
"use strict";
|
|
195353
195955
|
init_unknown_value();
|
|
195956
|
+
init_run_dossier();
|
|
195957
|
+
init_run_dossier_files();
|
|
195958
|
+
init_sitian_facade();
|
|
195354
195959
|
init_activation_ledger_topology();
|
|
195355
195960
|
init_run_lifecycle();
|
|
195356
195961
|
init_role_run_relocation();
|
|
195357
195962
|
init_role_run_placement();
|
|
195358
|
-
init_sitian_appender();
|
|
195359
195963
|
}
|
|
195360
195964
|
});
|
|
195361
195965
|
|
|
195362
195966
|
// scripts/migrate-book-topology.ts
|
|
195363
195967
|
import { homedir as homedir6 } from "node:os";
|
|
195364
|
-
import { join as
|
|
195968
|
+
import { join as join24, resolve as resolve12 } from "node:path";
|
|
195365
195969
|
|
|
195366
195970
|
// src/book-topology-migration.ts
|
|
195367
195971
|
init_activation_ledger_topology();
|
|
195368
195972
|
init_run_lifecycle();
|
|
195369
195973
|
import { mkdir, readdir as readdir4, rename } from "node:fs/promises";
|
|
195370
195974
|
import { homedir } from "node:os";
|
|
195371
|
-
import { basename as
|
|
195975
|
+
import { basename as basename6, dirname as dirname6, join as join7, resolve as resolve3 } from "node:path";
|
|
195372
195976
|
function reconcileMigrationPartition(partition3, unit, outcomes) {
|
|
195373
195977
|
let placed = 0;
|
|
195374
195978
|
let unbound = 0;
|
|
@@ -195396,7 +196000,7 @@ async function findWriterLocks(root) {
|
|
|
195396
196000
|
const locks = [];
|
|
195397
196001
|
async function walk3(directory) {
|
|
195398
196002
|
for (const entry of await readdir4(directory, { withFileTypes: true })) {
|
|
195399
|
-
const path8 =
|
|
196003
|
+
const path8 = join7(directory, entry.name);
|
|
195400
196004
|
if (entry.name === "writer.lock") {
|
|
195401
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";
|
|
195402
196006
|
locks.push({ path: path8, regularFile: entry.isFile(), kind });
|
|
@@ -195438,7 +196042,7 @@ ${active.join("\n")}`);
|
|
|
195438
196042
|
}
|
|
195439
196043
|
function datedBooksBackupDirectory(booksDirectory, now = /* @__PURE__ */ new Date()) {
|
|
195440
196044
|
const date = now.toISOString().slice(0, 10);
|
|
195441
|
-
return
|
|
196045
|
+
return join7(dirname6(booksDirectory), `${basename6(booksDirectory)}-${date}`);
|
|
195442
196046
|
}
|
|
195443
196047
|
async function renameBooksToDatedBackup(booksDirectory, now = /* @__PURE__ */ new Date()) {
|
|
195444
196048
|
const backup = datedBooksBackupDirectory(booksDirectory, now);
|
|
@@ -195449,8 +196053,8 @@ async function migrateBookTopology(input) {
|
|
|
195449
196053
|
if (input.migrators.length === 0) {
|
|
195450
196054
|
throw new Error("book topology migration has no partition migrators");
|
|
195451
196055
|
}
|
|
195452
|
-
const ledgerHome =
|
|
195453
|
-
const booksDirectory =
|
|
196056
|
+
const ledgerHome = resolve3(input.ledgerHome ?? join7(homedir(), ".ak-roles"));
|
|
196057
|
+
const booksDirectory = join7(ledgerHome, "books");
|
|
195454
196058
|
await assertBookTopologyMigrationPrerequisites(booksDirectory, input.env);
|
|
195455
196059
|
const backupBooksDirectory = await renameBooksToDatedBackup(booksDirectory, input.now);
|
|
195456
196060
|
await mkdir(booksDirectory);
|
|
@@ -195474,7 +196078,7 @@ async function migrateBookTopology(input) {
|
|
|
195474
196078
|
|
|
195475
196079
|
// src/book-topology-mixed-volume-migrators.ts
|
|
195476
196080
|
import { appendFile, cp as cp2, lstat as lstat2, mkdir as mkdir3, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
|
|
195477
|
-
import { dirname as
|
|
196081
|
+
import { dirname as dirname14, join as join20, relative as relative4, resolve as resolve10, sep as sep7 } from "node:path";
|
|
195478
196082
|
|
|
195479
196083
|
// src/archivist-record-entry.ts
|
|
195480
196084
|
init_activation_ledger_topology();
|
|
@@ -195497,9 +196101,10 @@ var WORKER_SUBMISSION_GATE_KIND = "worker-submission-gate";
|
|
|
195497
196101
|
init_activation_ledger_topology();
|
|
195498
196102
|
init_role_run_placement();
|
|
195499
196103
|
init_run_ticket_number();
|
|
196104
|
+
init_run_dossier();
|
|
195500
196105
|
init_unknown_value();
|
|
195501
196106
|
import { readdir as readdir6, readFile as readFile6 } from "node:fs/promises";
|
|
195502
|
-
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";
|
|
195503
196108
|
var TICKET_NUMBER_RE = /^[1-9][0-9]*$/;
|
|
195504
196109
|
var RUN_DIR_NAME_RE = /^([^@]+)@([^@]+)$/;
|
|
195505
196110
|
async function listMigrationBookKeys(booksDirectory) {
|
|
@@ -195538,8 +196143,19 @@ function ticketNumberFromWorktreeBasename(pathBasename) {
|
|
|
195538
196143
|
return ticketNumber;
|
|
195539
196144
|
}
|
|
195540
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
|
+
}
|
|
195541
196157
|
for (const page of ["admitted-request.json", "invocation.json", "run-state.json"]) {
|
|
195542
|
-
const path8 =
|
|
196158
|
+
const path8 = join19(runDirectory, page);
|
|
195543
196159
|
try {
|
|
195544
196160
|
const raw = JSON.parse(await readFile6(path8, "utf8"));
|
|
195545
196161
|
if (!isRecord(raw)) continue;
|
|
@@ -195555,7 +196171,7 @@ async function readProjectRootFromRun(runDirectory) {
|
|
|
195555
196171
|
return void 0;
|
|
195556
196172
|
}
|
|
195557
196173
|
async function resolveMigratingRunTicket(runDirectory) {
|
|
195558
|
-
const boardTicket = await
|
|
196174
|
+
const boardTicket = await readMigrationBoardTicketNumber(runDirectory);
|
|
195559
196175
|
if (boardTicket !== void 0) {
|
|
195560
196176
|
return {
|
|
195561
196177
|
ticketNumber: boardTicket,
|
|
@@ -195575,7 +196191,7 @@ async function resolveMigratingRunTicket(runDirectory) {
|
|
|
195575
196191
|
}
|
|
195576
196192
|
const project = await readProjectRootFromRun(runDirectory);
|
|
195577
196193
|
if (project === void 0) return { ticketNumber: void 0, derivation: void 0 };
|
|
195578
|
-
const leaf =
|
|
196194
|
+
const leaf = basename12(project.projectRoot.replace(/\\/g, "/"));
|
|
195579
196195
|
const ticketNumber = ticketNumberFromWorktreeBasename(leaf);
|
|
195580
196196
|
if (ticketNumber === void 0) return { ticketNumber: void 0, derivation: void 0 };
|
|
195581
196197
|
return {
|
|
@@ -195588,7 +196204,7 @@ async function resolveMigratingRunTicket(runDirectory) {
|
|
|
195588
196204
|
};
|
|
195589
196205
|
}
|
|
195590
196206
|
function bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey) {
|
|
195591
|
-
return [
|
|
196207
|
+
return [join19(booksDirectory, bookKey), join19(backupBooksDirectory, bookKey)];
|
|
195592
196208
|
}
|
|
195593
196209
|
function runLeafFromRelative(path8) {
|
|
195594
196210
|
const segments = path8.replaceAll("\\", "/").split("/").filter((segment) => segment.length > 0);
|
|
@@ -195600,8 +196216,8 @@ function runLeafFromRelative(path8) {
|
|
|
195600
196216
|
}
|
|
195601
196217
|
function runRefFromBoundPath(path8, bookRoots) {
|
|
195602
196218
|
for (const root of bookRoots) {
|
|
195603
|
-
const rootResolved =
|
|
195604
|
-
const candidate =
|
|
196219
|
+
const rootResolved = resolve9(root);
|
|
196220
|
+
const candidate = isAbsolute6(path8) ? resolve9(path8) : resolve9(rootResolved, path8);
|
|
195605
196221
|
if (candidate === rootResolved || !pathContainedIn(rootResolved, candidate)) continue;
|
|
195606
196222
|
const rel = relative3(rootResolved, candidate).split(sep6).join("/");
|
|
195607
196223
|
const leaf = runLeafFromRelative(rel);
|
|
@@ -195623,11 +196239,11 @@ async function listRunLeafEntries(runsDirectory) {
|
|
|
195623
196239
|
async function listBackupRunLeaves(backupBookDirectory) {
|
|
195624
196240
|
const leaves = [];
|
|
195625
196241
|
const collect = async (relativeDir, layout) => {
|
|
195626
|
-
const runsDirectory =
|
|
196242
|
+
const runsDirectory = join19(backupBookDirectory, ...relativeDir.split("/"));
|
|
195627
196243
|
for (const entry of await listRunLeafEntries(runsDirectory)) {
|
|
195628
196244
|
leaves.push({
|
|
195629
196245
|
relativePath: `${relativeDir}/${entry.name}`,
|
|
195630
|
-
sourcePath:
|
|
196246
|
+
sourcePath: join19(runsDirectory, entry.name),
|
|
195631
196247
|
leafName: entry.name,
|
|
195632
196248
|
isDirectory: entry.isDirectory,
|
|
195633
196249
|
layout
|
|
@@ -195640,7 +196256,7 @@ async function listBackupRunLeaves(backupBookDirectory) {
|
|
|
195640
196256
|
if (!subject.isDirectory() || !isTicketNumberString2(subject.name)) continue;
|
|
195641
196257
|
await collect(`${subject.name}/runs`, "ticket");
|
|
195642
196258
|
}
|
|
195643
|
-
for (const issue of await listMigrationDirents(
|
|
196259
|
+
for (const issue of await listMigrationDirents(join19(backupBookDirectory, "issues"))) {
|
|
195644
196260
|
if (!issue.isDirectory() || !isTicketNumberString2(issue.name)) continue;
|
|
195645
196261
|
await collect(`issues/${issue.name}/runs`, "issues");
|
|
195646
196262
|
}
|
|
@@ -195650,13 +196266,13 @@ async function listExactPlacedRunPaths(bookDir, leafName) {
|
|
|
195650
196266
|
const matches = [];
|
|
195651
196267
|
const subjectEntries = await listMigrationDirents(bookDir);
|
|
195652
196268
|
const runsDirs = [
|
|
195653
|
-
|
|
195654
|
-
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) =>
|
|
196269
|
+
join19(bookDir, "runs"),
|
|
196270
|
+
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) => join19(bookDir, entry.name, "runs"))
|
|
195655
196271
|
];
|
|
195656
196272
|
for (const runsDir of runsDirs) {
|
|
195657
196273
|
const entries = await listMigrationDirents(runsDir);
|
|
195658
196274
|
if (entries.some((entry) => entry.name === leafName)) {
|
|
195659
|
-
matches.push(
|
|
196275
|
+
matches.push(join19(runsDir, leafName));
|
|
195660
196276
|
}
|
|
195661
196277
|
}
|
|
195662
196278
|
return matches;
|
|
@@ -195669,13 +196285,13 @@ function destPathFromSourceRelative(booksDirectory, bookKey, sourceRelative2) {
|
|
|
195669
196285
|
const before = parts.slice(0, runsIndex);
|
|
195670
196286
|
if (leaf === void 0) return void 0;
|
|
195671
196287
|
if (before.length === 2 && before[0] === "issues" && before[1] !== void 0 && isTicketNumberString2(before[1])) {
|
|
195672
|
-
return
|
|
196288
|
+
return join19(booksDirectory, bookKey, before[1], "runs", leaf);
|
|
195673
196289
|
}
|
|
195674
196290
|
if (before.length !== 1) return void 0;
|
|
195675
196291
|
const subject = before[0];
|
|
195676
196292
|
if (subject === void 0) return void 0;
|
|
195677
196293
|
if (subject !== "unbound" && !isTicketNumberString2(subject)) return void 0;
|
|
195678
|
-
return
|
|
196294
|
+
return join19(booksDirectory, bookKey, subject, "runs", leaf);
|
|
195679
196295
|
}
|
|
195680
196296
|
function placedRunFromPath(runDirectory) {
|
|
195681
196297
|
return {
|
|
@@ -195687,15 +196303,15 @@ async function listPrincipalPlacedRunPaths(bookDir, runId) {
|
|
|
195687
196303
|
const matches = [...await listExactPlacedRunPaths(bookDir, runId)];
|
|
195688
196304
|
const subjectEntries = await listMigrationDirents(bookDir);
|
|
195689
196305
|
const runsDirs = [
|
|
195690
|
-
|
|
195691
|
-
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) =>
|
|
196306
|
+
join19(bookDir, "runs"),
|
|
196307
|
+
...subjectEntries.filter((entry) => entry.isDirectory()).map((entry) => join19(bookDir, entry.name, "runs"))
|
|
195692
196308
|
];
|
|
195693
196309
|
const prefix = `${runId}@`;
|
|
195694
196310
|
for (const runsDir of runsDirs) {
|
|
195695
196311
|
for (const entry of await listMigrationDirents(runsDir)) {
|
|
195696
196312
|
const name = entry.name;
|
|
195697
196313
|
if (!name.startsWith(prefix) || name.slice(runId.length + 1).includes("@")) continue;
|
|
195698
|
-
const path8 =
|
|
196314
|
+
const path8 = join19(runsDir, name);
|
|
195699
196315
|
if (!matches.includes(path8)) matches.push(path8);
|
|
195700
196316
|
}
|
|
195701
196317
|
}
|
|
@@ -195723,7 +196339,7 @@ function isFlatRunsRelative(sourceRelative2, leafName) {
|
|
|
195723
196339
|
}
|
|
195724
196340
|
async function findPlacedMigratingRun(booksDirectory, bookKey, leafName, sourceRelative2) {
|
|
195725
196341
|
if (leafName.trim() === "") return void 0;
|
|
195726
|
-
const bookDir =
|
|
196342
|
+
const bookDir = join19(booksDirectory, bookKey);
|
|
195727
196343
|
const matches = await listExactPlacedRunPaths(bookDir, leafName);
|
|
195728
196344
|
if (sourceRelative2 !== void 0 && sourceRelative2.length > 0) {
|
|
195729
196345
|
const preferred = destPathFromSourceRelative(booksDirectory, bookKey, sourceRelative2);
|
|
@@ -195749,12 +196365,12 @@ async function uniqueRunLeafExistsInBook(bookDir, leafName) {
|
|
|
195749
196365
|
}
|
|
195750
196366
|
async function findUniquePrincipalPlacedRun(booksDirectory, bookKey, runId) {
|
|
195751
196367
|
if (runId.trim() === "") return void 0;
|
|
195752
|
-
const matches = await listPrincipalPlacedRunPaths(
|
|
196368
|
+
const matches = await listPrincipalPlacedRunPaths(join19(booksDirectory, bookKey), runId);
|
|
195753
196369
|
if (matches.length !== 1) return void 0;
|
|
195754
196370
|
return placedRunFromPath(matches[0]);
|
|
195755
196371
|
}
|
|
195756
196372
|
function destinationRunDirectory(booksDirectory, bookKey, ticketNumber, runId, role) {
|
|
195757
|
-
const ledgerHome =
|
|
196373
|
+
const ledgerHome = dirname13(booksDirectory);
|
|
195758
196374
|
const subject = ticketNumber !== void 0 ? { ticketNumber } : { unbound: true };
|
|
195759
196375
|
return roleRunPlacement(ledgerHome, {
|
|
195760
196376
|
bookKey,
|
|
@@ -195891,9 +196507,9 @@ function inspectWorkerSubmissionGateVolume(text, bookRoots) {
|
|
|
195891
196507
|
}
|
|
195892
196508
|
function volumeDestinationFile(booksDirectory, bookKey, destRun, kind, fileName) {
|
|
195893
196509
|
if (destRun === void 0) {
|
|
195894
|
-
return
|
|
196510
|
+
return join20(booksDirectory, bookKey, "unbound", kind, fileName);
|
|
195895
196511
|
}
|
|
195896
|
-
return
|
|
196512
|
+
return join20(destRun.runDirectory, "session", kind, fileName);
|
|
195897
196513
|
}
|
|
195898
196514
|
async function placedRunForLeaf(cache, booksDirectory, bookKey, leaf, sourceRelative2) {
|
|
195899
196515
|
const cacheKey = `${bookKey}\0${sourceRelative2 ?? ""}\0${leaf}`;
|
|
@@ -195908,7 +196524,7 @@ async function placedRunForLeaf(cache, booksDirectory, bookKey, leaf, sourceRela
|
|
|
195908
196524
|
return placed;
|
|
195909
196525
|
}
|
|
195910
196526
|
async function appendRawLine(file, raw) {
|
|
195911
|
-
await mkdir3(
|
|
196527
|
+
await mkdir3(dirname14(file), { recursive: true });
|
|
195912
196528
|
await appendFile(file, `${raw}
|
|
195913
196529
|
`, "utf8");
|
|
195914
196530
|
}
|
|
@@ -195924,7 +196540,7 @@ function jsonlRows(text) {
|
|
|
195924
196540
|
return rows;
|
|
195925
196541
|
}
|
|
195926
196542
|
async function migrateCurrentSessionPointer(input) {
|
|
195927
|
-
const sourceFile =
|
|
196543
|
+
const sourceFile = join20(input.sourceDir, CURRENT_SESSION_LEDGER);
|
|
195928
196544
|
const raw = await readRegularBackupFile(sourceFile);
|
|
195929
196545
|
if (raw === void 0) return;
|
|
195930
196546
|
let sessionFile;
|
|
@@ -195938,11 +196554,11 @@ async function migrateCurrentSessionPointer(input) {
|
|
|
195938
196554
|
}
|
|
195939
196555
|
let destinationSessionFile;
|
|
195940
196556
|
if (sessionFile !== void 0) {
|
|
195941
|
-
const pointed =
|
|
196557
|
+
const pointed = resolve10(input.sourceDir, sessionFile);
|
|
195942
196558
|
destinationSessionFile = input.volumeDestinations.get(pointed) ?? input.volumeDestinations.get(sessionFile);
|
|
195943
196559
|
}
|
|
195944
196560
|
if (destinationSessionFile === void 0) {
|
|
195945
|
-
await mkdir3(
|
|
196561
|
+
await mkdir3(dirname14(input.unboundPointerFile), { recursive: true });
|
|
195946
196562
|
await writeFile6(
|
|
195947
196563
|
input.unboundPointerFile,
|
|
195948
196564
|
raw.endsWith("\n") ? raw : `${raw}
|
|
@@ -195951,8 +196567,8 @@ async function migrateCurrentSessionPointer(input) {
|
|
|
195951
196567
|
);
|
|
195952
196568
|
return;
|
|
195953
196569
|
}
|
|
195954
|
-
const pointerFile =
|
|
195955
|
-
await mkdir3(
|
|
196570
|
+
const pointerFile = join20(dirname14(destinationSessionFile), CURRENT_SESSION_LEDGER);
|
|
196571
|
+
await mkdir3(dirname14(pointerFile), { recursive: true });
|
|
195956
196572
|
await writeFile6(
|
|
195957
196573
|
pointerFile,
|
|
195958
196574
|
`${JSON.stringify({ sessionFile: destinationSessionFile })}
|
|
@@ -195965,15 +196581,15 @@ async function migrateSitianMixedVolume(partition3, context) {
|
|
|
195965
196581
|
const placedCache = /* @__PURE__ */ new Map();
|
|
195966
196582
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
195967
196583
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
195968
|
-
const sourceDir =
|
|
195969
|
-
const recordsFile =
|
|
196584
|
+
const sourceDir = join20(backupBooksDirectory, bookKey, partition3);
|
|
196585
|
+
const recordsFile = join20(sourceDir, "records.jsonl");
|
|
195970
196586
|
const bookRoots = bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey);
|
|
195971
196587
|
const text = await readRegularBackupFile(recordsFile);
|
|
195972
196588
|
if (text === void 0) {
|
|
195973
196589
|
await migrateCurrentSessionPointer({
|
|
195974
196590
|
sourceDir,
|
|
195975
196591
|
volumeDestinations: /* @__PURE__ */ new Map(),
|
|
195976
|
-
unboundPointerFile:
|
|
196592
|
+
unboundPointerFile: join20(
|
|
195977
196593
|
booksDirectory,
|
|
195978
196594
|
bookKey,
|
|
195979
196595
|
"unbound",
|
|
@@ -196051,16 +196667,16 @@ async function migrateSitianMixedVolume(partition3, context) {
|
|
|
196051
196667
|
const volumeDestinations = /* @__PURE__ */ new Map();
|
|
196052
196668
|
if (placedDests.size === 1) {
|
|
196053
196669
|
const onlyDest = placedDests.values().next().value;
|
|
196054
|
-
volumeDestinations.set(
|
|
196670
|
+
volumeDestinations.set(resolve10(recordsFile), onlyDest);
|
|
196055
196671
|
volumeDestinations.set(
|
|
196056
|
-
|
|
196672
|
+
resolve10(join20(booksDirectory, bookKey, partition3, "records.jsonl")),
|
|
196057
196673
|
onlyDest
|
|
196058
196674
|
);
|
|
196059
196675
|
}
|
|
196060
196676
|
await migrateCurrentSessionPointer({
|
|
196061
196677
|
sourceDir,
|
|
196062
196678
|
volumeDestinations,
|
|
196063
|
-
unboundPointerFile:
|
|
196679
|
+
unboundPointerFile: join20(
|
|
196064
196680
|
booksDirectory,
|
|
196065
196681
|
bookKey,
|
|
196066
196682
|
"unbound",
|
|
@@ -196078,13 +196694,13 @@ async function migrateWorkerSubmissionGate(context) {
|
|
|
196078
196694
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196079
196695
|
const kind = WORKER_SUBMISSION_GATE_KIND;
|
|
196080
196696
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196081
|
-
const sourceDir =
|
|
196697
|
+
const sourceDir = join20(backupBooksDirectory, bookKey, kind);
|
|
196082
196698
|
const entries = await listMigrationDirents(sourceDir);
|
|
196083
196699
|
if (entries.length === 0) continue;
|
|
196084
196700
|
const bookRoots = bookHistoricalRoots(booksDirectory, backupBooksDirectory, bookKey);
|
|
196085
196701
|
const volumes = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map((entry) => entry.name).sort();
|
|
196086
196702
|
for (const name of volumes) {
|
|
196087
|
-
const sourcePath =
|
|
196703
|
+
const sourcePath = join20(sourceDir, name);
|
|
196088
196704
|
const source = posixRelative(backupBooksDirectory, sourcePath);
|
|
196089
196705
|
const text = await readRegularBackupFile(sourcePath);
|
|
196090
196706
|
if (text === void 0) continue;
|
|
@@ -196103,7 +196719,7 @@ async function migrateWorkerSubmissionGate(context) {
|
|
|
196103
196719
|
kind,
|
|
196104
196720
|
name
|
|
196105
196721
|
);
|
|
196106
|
-
await mkdir3(
|
|
196722
|
+
await mkdir3(dirname14(dest), { recursive: true });
|
|
196107
196723
|
await cp2(sourcePath, dest, { preserveTimestamps: true });
|
|
196108
196724
|
outcomes.push({
|
|
196109
196725
|
disposition: destRun?.disposition === "placed" ? "placed" : "unbound",
|
|
@@ -196140,7 +196756,7 @@ var BOOK_TOPOLOGY_MIXED_VOLUME_MIGRATORS = [
|
|
|
196140
196756
|
// src/book-topology-migrators-t11.ts
|
|
196141
196757
|
init_activation_ledger_topology();
|
|
196142
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";
|
|
196143
|
-
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";
|
|
196144
196760
|
init_role_run_relocation();
|
|
196145
196761
|
init_unknown_value();
|
|
196146
196762
|
var AUDITOR_ROLES_PARTITION = "auditor-roles";
|
|
@@ -196192,7 +196808,7 @@ async function directoryExists(path8) {
|
|
|
196192
196808
|
}
|
|
196193
196809
|
async function hasAnyFileRecursive(directory) {
|
|
196194
196810
|
for (const entry of await listMigrationDirents(directory)) {
|
|
196195
|
-
const path8 =
|
|
196811
|
+
const path8 = join21(directory, entry.name);
|
|
196196
196812
|
if (entry.isDirectory()) {
|
|
196197
196813
|
if (await hasAnyFileRecursive(path8)) return true;
|
|
196198
196814
|
} else {
|
|
@@ -196202,14 +196818,14 @@ async function hasAnyFileRecursive(directory) {
|
|
|
196202
196818
|
return false;
|
|
196203
196819
|
}
|
|
196204
196820
|
function mapBooksPathToBackup(booksDirectory, backupBooksDirectory, absolutePath) {
|
|
196205
|
-
const booksRoot =
|
|
196206
|
-
const resolved =
|
|
196821
|
+
const booksRoot = resolve11(booksDirectory);
|
|
196822
|
+
const resolved = resolve11(absolutePath);
|
|
196207
196823
|
if (resolved !== booksRoot && !pathContainedIn(booksRoot, resolved)) return void 0;
|
|
196208
|
-
return
|
|
196824
|
+
return join21(backupBooksDirectory, relative5(booksRoot, resolved));
|
|
196209
196825
|
}
|
|
196210
196826
|
function resolveVolumeSessionFile(booksDirectory, backupBooksDirectory, volumeDirectory, sessionFileField) {
|
|
196211
|
-
const resolvedVolume =
|
|
196212
|
-
const resolvedSession =
|
|
196827
|
+
const resolvedVolume = resolve11(volumeDirectory);
|
|
196828
|
+
const resolvedSession = resolve11(sessionFileField);
|
|
196213
196829
|
if (physicallyContainedIn(resolvedVolume, resolvedSession)) return resolvedSession;
|
|
196214
196830
|
const mapped = mapBooksPathToBackup(
|
|
196215
196831
|
booksDirectory,
|
|
@@ -196217,13 +196833,13 @@ function resolveVolumeSessionFile(booksDirectory, backupBooksDirectory, volumeDi
|
|
|
196217
196833
|
sessionFileField
|
|
196218
196834
|
);
|
|
196219
196835
|
if (mapped === void 0) return void 0;
|
|
196220
|
-
const resolvedMapped =
|
|
196836
|
+
const resolvedMapped = resolve11(mapped);
|
|
196221
196837
|
return physicallyContainedIn(resolvedVolume, resolvedMapped) ? resolvedMapped : void 0;
|
|
196222
196838
|
}
|
|
196223
196839
|
function parseParentRunBoundToMigration(booksDirectory, backupBooksDirectory, parentSession) {
|
|
196224
|
-
const resolved =
|
|
196225
|
-
const booksRoot =
|
|
196226
|
-
const backupRoot =
|
|
196840
|
+
const resolved = resolve11(parentSession);
|
|
196841
|
+
const booksRoot = resolve11(booksDirectory);
|
|
196842
|
+
const backupRoot = resolve11(backupBooksDirectory);
|
|
196227
196843
|
let rel;
|
|
196228
196844
|
if (resolved === booksRoot || pathContainedIn(booksRoot, resolved)) {
|
|
196229
196845
|
rel = relative5(booksRoot, resolved).split(sep8).join("/");
|
|
@@ -196280,15 +196896,15 @@ async function readJsonlParentSession(path8) {
|
|
|
196280
196896
|
}
|
|
196281
196897
|
}
|
|
196282
196898
|
async function backupParentRunExists(backupBooksDirectory, parent) {
|
|
196283
|
-
const backupBook =
|
|
196284
|
-
if (await directoryExists(
|
|
196899
|
+
const backupBook = join21(backupBooksDirectory, parent.bookKey);
|
|
196900
|
+
if (await directoryExists(join21(backupBook, parent.sourceRelative))) return true;
|
|
196285
196901
|
if (!isFlatRunsRelative(parent.sourceRelative, parent.leafName)) return false;
|
|
196286
196902
|
return uniqueRunLeafExistsInBook(backupBook, parent.leafName);
|
|
196287
196903
|
}
|
|
196288
196904
|
async function findTrueVolumeParent(backupBooksDirectory, booksDirectory, volumeDirectory) {
|
|
196289
196905
|
let ledgerRaw;
|
|
196290
196906
|
try {
|
|
196291
|
-
ledgerRaw = await readFile8(
|
|
196907
|
+
ledgerRaw = await readFile8(join21(volumeDirectory, CURRENT_SESSION_LEDGER2), "utf8");
|
|
196292
196908
|
} catch (error) {
|
|
196293
196909
|
if (isEnoent(error)) return void 0;
|
|
196294
196910
|
throw error;
|
|
@@ -196339,22 +196955,22 @@ async function collectPlacedRunRewrites(booksDirectory, backupBooksDirectory) {
|
|
|
196339
196955
|
rewrites.push({ oldRunDirectory, newRunDirectory });
|
|
196340
196956
|
};
|
|
196341
196957
|
for (const bookKey of await listMigrationBookKeys(booksDirectory)) {
|
|
196342
|
-
for (const subject of await listMigrationDirents(
|
|
196958
|
+
for (const subject of await listMigrationDirents(join21(booksDirectory, bookKey))) {
|
|
196343
196959
|
if (!subject.isDirectory()) continue;
|
|
196344
|
-
const runsRoot =
|
|
196960
|
+
const runsRoot = join21(booksDirectory, bookKey, subject.name, "runs");
|
|
196345
196961
|
for (const run of await listMigrationDirents(runsRoot)) {
|
|
196346
196962
|
if (!run.isDirectory()) continue;
|
|
196347
|
-
const finalPath =
|
|
196348
|
-
push(
|
|
196349
|
-
push(
|
|
196350
|
-
push(
|
|
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);
|
|
196351
196967
|
if (isTicketNumberString2(subject.name)) {
|
|
196352
196968
|
push(
|
|
196353
|
-
|
|
196969
|
+
join21(booksDirectory, bookKey, "issues", subject.name, "runs", run.name),
|
|
196354
196970
|
finalPath
|
|
196355
196971
|
);
|
|
196356
196972
|
push(
|
|
196357
|
-
|
|
196973
|
+
join21(backupBooksDirectory, bookKey, "issues", subject.name, "runs", run.name),
|
|
196358
196974
|
finalPath
|
|
196359
196975
|
);
|
|
196360
196976
|
}
|
|
@@ -196365,12 +196981,12 @@ async function collectPlacedRunRewrites(booksDirectory, backupBooksDirectory) {
|
|
|
196365
196981
|
}
|
|
196366
196982
|
function historicalRunDirectoriesFor(booksDirectory, backupBooksDirectory, parent) {
|
|
196367
196983
|
const out = [
|
|
196368
|
-
|
|
196369
|
-
|
|
196984
|
+
join21(booksDirectory, parent.bookKey, parent.sourceRelative),
|
|
196985
|
+
join21(backupBooksDirectory, parent.bookKey, parent.sourceRelative)
|
|
196370
196986
|
];
|
|
196371
196987
|
if (!parent.sourceRelative.startsWith("runs/")) {
|
|
196372
|
-
out.push(
|
|
196373
|
-
out.push(
|
|
196988
|
+
out.push(join21(booksDirectory, parent.bookKey, "runs", parent.leafName));
|
|
196989
|
+
out.push(join21(backupBooksDirectory, parent.bookKey, "runs", parent.leafName));
|
|
196374
196990
|
}
|
|
196375
196991
|
return out;
|
|
196376
196992
|
}
|
|
@@ -196383,11 +196999,11 @@ async function resolveDestinationRun(context, parent) {
|
|
|
196383
196999
|
);
|
|
196384
197000
|
}
|
|
196385
197001
|
function rewritePathIntoDestination(sessionFile, sourceRoots, destRoot) {
|
|
196386
|
-
const resolved =
|
|
197002
|
+
const resolved = resolve11(sessionFile);
|
|
196387
197003
|
for (const root of sourceRoots) {
|
|
196388
|
-
const resolvedRoot =
|
|
197004
|
+
const resolvedRoot = resolve11(root);
|
|
196389
197005
|
if (pathContainedIn(resolvedRoot, resolved)) {
|
|
196390
|
-
return
|
|
197006
|
+
return join21(destRoot, relative5(resolvedRoot, resolved));
|
|
196391
197007
|
}
|
|
196392
197008
|
}
|
|
196393
197009
|
return sessionFile;
|
|
@@ -196432,8 +197048,8 @@ async function writeWinningCurrentSession(destPath, srcStat, destStat, nextRaw,
|
|
|
196432
197048
|
`book topology migration cannot compare current-session pointer at ${destPath}: file disappeared during tie-break`
|
|
196433
197049
|
);
|
|
196434
197050
|
}
|
|
196435
|
-
const srcName =
|
|
196436
|
-
const destName =
|
|
197051
|
+
const srcName = basename13(nextSessionFile ?? "");
|
|
197052
|
+
const destName = basename13(destSessionFile);
|
|
196437
197053
|
if (destName >= srcName) return;
|
|
196438
197054
|
}
|
|
196439
197055
|
}
|
|
@@ -196441,7 +197057,7 @@ async function writeWinningCurrentSession(destPath, srcStat, destStat, nextRaw,
|
|
|
196441
197057
|
await utimes(destPath, srcStat.atime, srcStat.mtime);
|
|
196442
197058
|
}
|
|
196443
197059
|
async function mergeRewrittenCurrentSession(volumeDirectory, historicalVolume, destNest) {
|
|
196444
|
-
const srcPath =
|
|
197060
|
+
const srcPath = join21(volumeDirectory, CURRENT_SESSION_LEDGER2);
|
|
196445
197061
|
let srcRaw;
|
|
196446
197062
|
let srcStat;
|
|
196447
197063
|
try {
|
|
@@ -196473,7 +197089,7 @@ async function mergeRewrittenCurrentSession(volumeDirectory, historicalVolume, d
|
|
|
196473
197089
|
} catch {
|
|
196474
197090
|
nextSessionFile = void 0;
|
|
196475
197091
|
}
|
|
196476
|
-
const destPath =
|
|
197092
|
+
const destPath = join21(destNest, CURRENT_SESSION_LEDGER2);
|
|
196477
197093
|
let destStat;
|
|
196478
197094
|
try {
|
|
196479
197095
|
destStat = await stat4(destPath);
|
|
@@ -196492,8 +197108,8 @@ async function copyDirSkippingCurrentSession(from, to) {
|
|
|
196492
197108
|
await mkdir4(to, { recursive: true });
|
|
196493
197109
|
for (const entry of await listMigrationDirents(from)) {
|
|
196494
197110
|
if (entry.name === CURRENT_SESSION_LEDGER2 && entry.isFile()) continue;
|
|
196495
|
-
const src =
|
|
196496
|
-
const dest =
|
|
197111
|
+
const src = join21(from, entry.name);
|
|
197112
|
+
const dest = join21(to, entry.name);
|
|
196497
197113
|
if (entry.isDirectory()) {
|
|
196498
197114
|
await copyDirSkippingCurrentSession(src, dest);
|
|
196499
197115
|
} else if (entry.isFile()) {
|
|
@@ -196506,7 +197122,7 @@ async function copyVolumeIntoNest(volumeDirectory, historicalVolume, destNest) {
|
|
|
196506
197122
|
await mergeRewrittenCurrentSession(volumeDirectory, historicalVolume, destNest);
|
|
196507
197123
|
}
|
|
196508
197124
|
async function copyTree(source, destination) {
|
|
196509
|
-
await mkdir4(
|
|
197125
|
+
await mkdir4(dirname15(destination), { recursive: true });
|
|
196510
197126
|
await cp3(source, destination, { recursive: true, preserveTimestamps: true });
|
|
196511
197127
|
}
|
|
196512
197128
|
var bookTopologyAuditorRolesMigrator = {
|
|
@@ -196520,9 +197136,9 @@ var bookTopologyAuditorRolesMigrator = {
|
|
|
196520
197136
|
);
|
|
196521
197137
|
const rewriteSeen = new Set(crossRunRewrites.map((r2) => r2.oldRunDirectory));
|
|
196522
197138
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196523
|
-
const auditorRoot =
|
|
197139
|
+
const auditorRoot = join21(backupBooksDirectory, bookKey, AUDITOR_ROLES_PARTITION);
|
|
196524
197140
|
for (const entry of await listMigrationDirents(auditorRoot)) {
|
|
196525
|
-
const sourcePath =
|
|
197141
|
+
const sourcePath = join21(auditorRoot, entry.name);
|
|
196526
197142
|
if (entry.isFile() && entry.name === T10_MISFILED_NAME) {
|
|
196527
197143
|
continue;
|
|
196528
197144
|
}
|
|
@@ -196541,14 +197157,14 @@ var bookTopologyAuditorRolesMigrator = {
|
|
|
196541
197157
|
continue;
|
|
196542
197158
|
}
|
|
196543
197159
|
const destination = await resolveDestinationRun(context, parent);
|
|
196544
|
-
const historicalVolume =
|
|
197160
|
+
const historicalVolume = join21(
|
|
196545
197161
|
booksDirectory,
|
|
196546
197162
|
bookKey,
|
|
196547
197163
|
AUDITOR_ROLES_PARTITION,
|
|
196548
197164
|
entry.name
|
|
196549
197165
|
);
|
|
196550
197166
|
if (destination === void 0) {
|
|
196551
|
-
const destNest2 =
|
|
197167
|
+
const destNest2 = join21(
|
|
196552
197168
|
booksDirectory,
|
|
196553
197169
|
bookKey,
|
|
196554
197170
|
"unbound",
|
|
@@ -196559,7 +197175,7 @@ var bookTopologyAuditorRolesMigrator = {
|
|
|
196559
197175
|
outcomes.push({ disposition: "unbound", source });
|
|
196560
197176
|
continue;
|
|
196561
197177
|
}
|
|
196562
|
-
const destNest =
|
|
197178
|
+
const destNest = join21(destination.runDirectory, "session", AUDITOR_ROLES_PARTITION);
|
|
196563
197179
|
await copyVolumeIntoNest(sourcePath, historicalVolume, destNest);
|
|
196564
197180
|
const historicalParents = historicalRunDirectoriesFor(
|
|
196565
197181
|
booksDirectory,
|
|
@@ -196590,8 +197206,8 @@ async function copyIssuesNonRunTree(source, destination) {
|
|
|
196590
197206
|
await mkdir4(destination, { recursive: true });
|
|
196591
197207
|
for (const entry of await listMigrationDirents(source)) {
|
|
196592
197208
|
if (entry.name === "runs") continue;
|
|
196593
|
-
const from =
|
|
196594
|
-
const to =
|
|
197209
|
+
const from = join21(source, entry.name);
|
|
197210
|
+
const to = join21(destination, entry.name);
|
|
196595
197211
|
if (entry.isDirectory()) {
|
|
196596
197212
|
await copyIssuesNonRunTree(from, to);
|
|
196597
197213
|
continue;
|
|
@@ -196614,9 +197230,9 @@ var bookTopologyIssuesMigrator = {
|
|
|
196614
197230
|
const outcomes = [];
|
|
196615
197231
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196616
197232
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196617
|
-
const issuesRoot =
|
|
197233
|
+
const issuesRoot = join21(backupBooksDirectory, bookKey, ISSUES_PARTITION);
|
|
196618
197234
|
for (const entry of await listMigrationDirents(issuesRoot)) {
|
|
196619
|
-
const sourcePath =
|
|
197235
|
+
const sourcePath = join21(issuesRoot, entry.name);
|
|
196620
197236
|
const source = sourceIdentity(backupBooksDirectory, sourcePath);
|
|
196621
197237
|
const isTicketDir = entry.isDirectory() && TICKET_NUMBER_NAME.test(entry.name);
|
|
196622
197238
|
if (!isTicketDir || !await hasAnyFileRecursive(sourcePath)) {
|
|
@@ -196625,7 +197241,7 @@ var bookTopologyIssuesMigrator = {
|
|
|
196625
197241
|
}
|
|
196626
197242
|
await copyIssuesNonRunTree(
|
|
196627
197243
|
sourcePath,
|
|
196628
|
-
|
|
197244
|
+
join21(booksDirectory, bookKey, entry.name)
|
|
196629
197245
|
);
|
|
196630
197246
|
outcomes.push({ disposition: "placed", source });
|
|
196631
197247
|
}
|
|
@@ -196640,11 +197256,11 @@ var bookTopologyDeprecatedKindsMigrator = {
|
|
|
196640
197256
|
const { backupBooksDirectory } = context;
|
|
196641
197257
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196642
197258
|
for (const kind of DEPRECATED_KIND_DIRECTORIES) {
|
|
196643
|
-
const kindRoot =
|
|
197259
|
+
const kindRoot = join21(backupBooksDirectory, bookKey, kind);
|
|
196644
197260
|
for (const entry of await listMigrationDirents(kindRoot)) {
|
|
196645
197261
|
outcomes.push({
|
|
196646
197262
|
disposition: "discarded",
|
|
196647
|
-
source: sourceIdentity(backupBooksDirectory,
|
|
197263
|
+
source: sourceIdentity(backupBooksDirectory, join21(kindRoot, entry.name))
|
|
196648
197264
|
});
|
|
196649
197265
|
}
|
|
196650
197266
|
}
|
|
@@ -196666,11 +197282,11 @@ async function discardDeprecatedPagesFromRunSource(input) {
|
|
|
196666
197282
|
disposition: "discarded",
|
|
196667
197283
|
source: sourceIdentity(
|
|
196668
197284
|
input.backupBooksDirectory,
|
|
196669
|
-
|
|
197285
|
+
join21(input.sourceRunDirectory, page.name)
|
|
196670
197286
|
)
|
|
196671
197287
|
});
|
|
196672
197288
|
if (input.destinationRunDirectory !== void 0) {
|
|
196673
|
-
await unlinkIfPresent(
|
|
197289
|
+
await unlinkIfPresent(join21(input.destinationRunDirectory, page.name));
|
|
196674
197290
|
}
|
|
196675
197291
|
}
|
|
196676
197292
|
}
|
|
@@ -196680,7 +197296,7 @@ var bookTopologyDeprecatedRunPagesMigrator = {
|
|
|
196680
197296
|
const outcomes = [];
|
|
196681
197297
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196682
197298
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196683
|
-
for (const leaf of await listBackupRunLeaves(
|
|
197299
|
+
for (const leaf of await listBackupRunLeaves(join21(backupBooksDirectory, bookKey))) {
|
|
196684
197300
|
if (!leaf.isDirectory) continue;
|
|
196685
197301
|
const placed = await findPlacedMigratingRun(
|
|
196686
197302
|
booksDirectory,
|
|
@@ -196701,15 +197317,15 @@ var bookTopologyDeprecatedRunPagesMigrator = {
|
|
|
196701
197317
|
};
|
|
196702
197318
|
async function copyBookTopLevelPartition(context, partition3, outcomes) {
|
|
196703
197319
|
for (const bookKey of await listMigrationBookKeys(context.backupBooksDirectory)) {
|
|
196704
|
-
const sourceDir =
|
|
197320
|
+
const sourceDir = join21(context.backupBooksDirectory, bookKey, partition3);
|
|
196705
197321
|
if (!await directoryExists(sourceDir)) continue;
|
|
196706
|
-
await copyTree(sourceDir,
|
|
197322
|
+
await copyTree(sourceDir, join21(context.booksDirectory, bookKey, partition3));
|
|
196707
197323
|
for (const entry of await listMigrationDirents(sourceDir)) {
|
|
196708
197324
|
outcomes.push({
|
|
196709
197325
|
disposition: "placed",
|
|
196710
197326
|
source: sourceIdentity(
|
|
196711
197327
|
context.backupBooksDirectory,
|
|
196712
|
-
|
|
197328
|
+
join21(sourceDir, entry.name)
|
|
196713
197329
|
)
|
|
196714
197330
|
});
|
|
196715
197331
|
}
|
|
@@ -196736,12 +197352,12 @@ var bookTopologyManualArchivesMigrator = {
|
|
|
196736
197352
|
async migrate(context) {
|
|
196737
197353
|
const outcomes = [];
|
|
196738
197354
|
const { backupBooksDirectory, booksDirectory } = context;
|
|
196739
|
-
const archivesRoot =
|
|
197355
|
+
const archivesRoot = join21(dirname15(booksDirectory), MANUAL_ARCHIVES_PARTITION);
|
|
196740
197356
|
for (const bookKey of await listMigrationBookKeys(backupBooksDirectory)) {
|
|
196741
197357
|
for (const dirName of MANUAL_ARCHIVE_DIRECTORIES) {
|
|
196742
|
-
const sourceDir =
|
|
197358
|
+
const sourceDir = join21(backupBooksDirectory, bookKey, dirName);
|
|
196743
197359
|
if (!await directoryExists(sourceDir)) continue;
|
|
196744
|
-
await copyTree(sourceDir,
|
|
197360
|
+
await copyTree(sourceDir, join21(archivesRoot, bookKey, dirName));
|
|
196745
197361
|
outcomes.push({
|
|
196746
197362
|
disposition: "placed",
|
|
196747
197363
|
source: sourceIdentity(backupBooksDirectory, sourceDir)
|
|
@@ -196763,11 +197379,11 @@ var BOOK_TOPOLOGY_T11_MIGRATORS = [
|
|
|
196763
197379
|
|
|
196764
197380
|
// src/book-topology-record-class-migrators.ts
|
|
196765
197381
|
import { appendFile as appendFile2, mkdir as mkdir5, readFile as readFile9, stat as stat5, writeFile as writeFile8 } from "node:fs/promises";
|
|
196766
|
-
import { dirname as
|
|
196767
|
-
init_sitian_appender();
|
|
197382
|
+
import { dirname as dirname16, join as join22, relative as relative6, sep as sep9 } from "node:path";
|
|
196768
197383
|
init_ticket_provenance_contracts();
|
|
196769
197384
|
init_sha256();
|
|
196770
197385
|
init_unknown_value();
|
|
197386
|
+
var LEGACY_SUBMISSION_LEDGER_KINDS = /* @__PURE__ */ new Set(["candidate", "roundContext", "outcome", "sealed", "post-seal-anomaly"]);
|
|
196771
197387
|
var TICKET_PROVENANCE = "ticket-provenance";
|
|
196772
197388
|
var SUBMISSION_LEDGER = "submission-ledger";
|
|
196773
197389
|
var ATTEMPT_HISTORY = "attempt-history";
|
|
@@ -196856,14 +197472,14 @@ var RecordWriteCache = class {
|
|
|
196856
197472
|
}
|
|
196857
197473
|
}
|
|
196858
197474
|
this.destPlacements.delete(recordFile);
|
|
196859
|
-
await ensureDir(
|
|
197475
|
+
await ensureDir(dirname16(recordFile));
|
|
196860
197476
|
const text = body.endsWith("\n") ? body : `${body}
|
|
196861
197477
|
`;
|
|
196862
197478
|
await writeFile8(recordFile, text, "utf8");
|
|
196863
197479
|
this.markBareVolume(recordFile);
|
|
196864
197480
|
}
|
|
196865
197481
|
async append(recordFile, raw, options) {
|
|
196866
|
-
await ensureDir(
|
|
197482
|
+
await ensureDir(dirname16(recordFile));
|
|
196867
197483
|
const line = raw.endsWith("\n") ? raw : `${raw}
|
|
196868
197484
|
`;
|
|
196869
197485
|
const parsed2 = parseJsonlLine(raw);
|
|
@@ -196898,14 +197514,14 @@ function runIdFromPayload(payload) {
|
|
|
196898
197514
|
function recordClassOfKind(kind) {
|
|
196899
197515
|
if (kind === TICKET_PROVENANCE) return TICKET_PROVENANCE;
|
|
196900
197516
|
if (kind === ATTEMPT_HISTORY) return ATTEMPT_HISTORY;
|
|
196901
|
-
if (typeof kind === "string" &&
|
|
197517
|
+
if (typeof kind === "string" && LEGACY_SUBMISSION_LEDGER_KINDS.has(kind)) return SUBMISSION_LEDGER;
|
|
196902
197518
|
return void 0;
|
|
196903
197519
|
}
|
|
196904
197520
|
async function listFilesRecursive(root, predicate) {
|
|
196905
197521
|
const out = [];
|
|
196906
197522
|
async function walk3(directory) {
|
|
196907
197523
|
for (const entry of await listMigrationDirents(directory)) {
|
|
196908
|
-
const path8 =
|
|
197524
|
+
const path8 = join22(directory, entry.name);
|
|
196909
197525
|
if (entry.isDirectory()) await walk3(path8);
|
|
196910
197526
|
else if (entry.isFile() && predicate(entry.name)) out.push(path8);
|
|
196911
197527
|
}
|
|
@@ -196914,10 +197530,10 @@ async function listFilesRecursive(root, predicate) {
|
|
|
196914
197530
|
return out;
|
|
196915
197531
|
}
|
|
196916
197532
|
async function listVolumeRecordFiles(partitionDir) {
|
|
196917
|
-
const files = [
|
|
197533
|
+
const files = [join22(partitionDir, "records.jsonl")];
|
|
196918
197534
|
for (const entry of await listMigrationDirents(partitionDir)) {
|
|
196919
197535
|
if (!entry.isDirectory()) continue;
|
|
196920
|
-
files.push(
|
|
197536
|
+
files.push(join22(partitionDir, entry.name, "records.jsonl"));
|
|
196921
197537
|
}
|
|
196922
197538
|
return files;
|
|
196923
197539
|
}
|
|
@@ -196963,7 +197579,7 @@ function relativePathWithinRun(relPosix) {
|
|
|
196963
197579
|
return parts.slice(runsIndex + 2).join("/");
|
|
196964
197580
|
}
|
|
196965
197581
|
function unboundCategoryFile(booksDirectory, bookKey, category, key) {
|
|
196966
|
-
return
|
|
197582
|
+
return join22(booksDirectory, bookKey, "unbound", category, key, "records.jsonl");
|
|
196967
197583
|
}
|
|
196968
197584
|
async function resolveRunDestination(context, bookKey, runId, hints) {
|
|
196969
197585
|
const hasSessionParent = typeof hints.sessionParent === "string" && hints.sessionParent.length > 0;
|
|
@@ -197029,7 +197645,7 @@ async function placeTicketProvenanceLine(context, bookKey, writes, source, raw,
|
|
|
197029
197645
|
await writes.append(unboundCategoryFile(context.booksDirectory, bookKey, TICKET_PROVENANCE, stableKey(raw)), raw);
|
|
197030
197646
|
return { disposition: "unbound", source };
|
|
197031
197647
|
}
|
|
197032
|
-
const dest =
|
|
197648
|
+
const dest = join22(
|
|
197033
197649
|
context.booksDirectory,
|
|
197034
197650
|
bookKey,
|
|
197035
197651
|
String(ticketNumber),
|
|
@@ -197074,7 +197690,7 @@ async function placeRunOwnedLine(context, bookKey, writes, category, source, raw
|
|
|
197074
197690
|
await writes.append(unboundCategoryFile(context.booksDirectory, bookKey, category, target.key), raw);
|
|
197075
197691
|
return { disposition: "unbound", source };
|
|
197076
197692
|
}
|
|
197077
|
-
await writes.append(
|
|
197693
|
+
await writes.append(join22(target.runDirectory, "session", category, "records.jsonl"), raw);
|
|
197078
197694
|
return { disposition: target.disposition, source };
|
|
197079
197695
|
}
|
|
197080
197696
|
async function placeRecordClassLine(context, bookKey, writes, source, raw, value2, fallbackCategory, outcomeIndex) {
|
|
@@ -197106,7 +197722,7 @@ function tryBareTicketProvenanceVolume(lines) {
|
|
|
197106
197722
|
return { ticket: header.ticket, body };
|
|
197107
197723
|
}
|
|
197108
197724
|
async function placeBareTicketProvenanceVolume(context, bookKey, writes, filePath, bare, outcomes) {
|
|
197109
|
-
const dest =
|
|
197725
|
+
const dest = join22(
|
|
197110
197726
|
context.booksDirectory,
|
|
197111
197727
|
bookKey,
|
|
197112
197728
|
String(bare.ticket),
|
|
@@ -197177,7 +197793,7 @@ async function migrateJsonlFileByKind(context, bookKey, writes, filePath, fallba
|
|
|
197177
197793
|
}
|
|
197178
197794
|
var OFFERED_IDENTITIES = "offered-identities.jsonl";
|
|
197179
197795
|
async function mergeOfferedIdentities(destDir, volumeDir, writes) {
|
|
197180
|
-
const from =
|
|
197796
|
+
const from = join22(volumeDir, OFFERED_IDENTITIES);
|
|
197181
197797
|
let lines;
|
|
197182
197798
|
try {
|
|
197183
197799
|
await stat5(from);
|
|
@@ -197186,14 +197802,14 @@ async function mergeOfferedIdentities(destDir, volumeDir, writes) {
|
|
|
197186
197802
|
if (isEnoent(error)) return;
|
|
197187
197803
|
throw error;
|
|
197188
197804
|
}
|
|
197189
|
-
const destFile =
|
|
197805
|
+
const destFile = join22(destDir, OFFERED_IDENTITIES);
|
|
197190
197806
|
for (const raw of lines) {
|
|
197191
197807
|
if (raw.trim() === "") continue;
|
|
197192
197808
|
await writes.append(destFile, raw);
|
|
197193
197809
|
}
|
|
197194
197810
|
}
|
|
197195
197811
|
async function ticketNumbersInVolume(volumeDir) {
|
|
197196
|
-
const lines = await readJsonlLines(
|
|
197812
|
+
const lines = await readJsonlLines(join22(volumeDir, "records.jsonl"));
|
|
197197
197813
|
const bare = tryBareTicketProvenanceVolume(lines);
|
|
197198
197814
|
if (bare !== void 0) return [bare.ticket];
|
|
197199
197815
|
const out = [];
|
|
@@ -197212,29 +197828,29 @@ async function ticketNumbersInVolume(volumeDir) {
|
|
|
197212
197828
|
}
|
|
197213
197829
|
async function mergeCompanionsFromVolume(context, bookKey, volumeDir, writes) {
|
|
197214
197830
|
for (const ticketNumber of await ticketNumbersInVolume(volumeDir)) {
|
|
197215
|
-
const destDir =
|
|
197831
|
+
const destDir = join22(context.booksDirectory, bookKey, String(ticketNumber));
|
|
197216
197832
|
await ensureDir(destDir);
|
|
197217
197833
|
await mergeOfferedIdentities(destDir, volumeDir, writes);
|
|
197218
197834
|
}
|
|
197219
197835
|
}
|
|
197220
197836
|
async function migrateHomePartitionBook(context, bookKey, writes, category, outcomes) {
|
|
197221
|
-
const backupBook =
|
|
197222
|
-
const rootFiles = await listVolumeRecordFiles(
|
|
197837
|
+
const backupBook = join22(context.backupBooksDirectory, bookKey);
|
|
197838
|
+
const rootFiles = await listVolumeRecordFiles(join22(backupBook, category));
|
|
197223
197839
|
for (const filePath of rootFiles) {
|
|
197224
197840
|
await migrateJsonlFileByKind(context, bookKey, writes, filePath, category, outcomes);
|
|
197225
197841
|
if (category === TICKET_PROVENANCE) {
|
|
197226
|
-
await mergeCompanionsFromVolume(context, bookKey,
|
|
197842
|
+
await mergeCompanionsFromVolume(context, bookKey, dirname16(filePath), writes);
|
|
197227
197843
|
}
|
|
197228
197844
|
}
|
|
197229
197845
|
if (category !== TICKET_PROVENANCE) return;
|
|
197230
197846
|
for (const entry of await listMigrationDirents(backupBook)) {
|
|
197231
197847
|
if (!entry.isDirectory() || !isTicketNumberString2(entry.name)) continue;
|
|
197232
|
-
const ticketDir =
|
|
197848
|
+
const ticketDir = join22(backupBook, entry.name);
|
|
197233
197849
|
for (const volumeDir of [
|
|
197234
|
-
|
|
197850
|
+
join22(ticketDir, TICKET_PROVENANCE),
|
|
197235
197851
|
ticketDir
|
|
197236
197852
|
]) {
|
|
197237
|
-
const recordsFile =
|
|
197853
|
+
const recordsFile = join22(volumeDir, "records.jsonl");
|
|
197238
197854
|
try {
|
|
197239
197855
|
await stat5(recordsFile);
|
|
197240
197856
|
} catch (error) {
|
|
@@ -197266,11 +197882,11 @@ async function scrubRawLinesFromFile(recordFile, rawLines) {
|
|
|
197266
197882
|
kept.push(normalized);
|
|
197267
197883
|
}
|
|
197268
197884
|
if (!changed) return;
|
|
197269
|
-
await ensureDir(
|
|
197885
|
+
await ensureDir(dirname16(recordFile));
|
|
197270
197886
|
await writeFile8(recordFile, kept.join(""), "utf8");
|
|
197271
197887
|
}
|
|
197272
197888
|
async function migrateMisplacedBook(context, bookKey, writes, outcomes) {
|
|
197273
|
-
const backupBook =
|
|
197889
|
+
const backupBook = join22(context.backupBooksDirectory, bookKey);
|
|
197274
197890
|
const files = await listFilesRecursive(backupBook, (name) => name.endsWith(".jsonl"));
|
|
197275
197891
|
const scrubPlans = /* @__PURE__ */ new Map();
|
|
197276
197892
|
for (const filePath of files) {
|
|
@@ -197319,12 +197935,12 @@ async function migrateMisplacedBook(context, bookKey, writes, outcomes) {
|
|
|
197319
197935
|
const withinRun = relativePathWithinRun(withinBook);
|
|
197320
197936
|
if (coords === void 0 || withinRun === void 0) continue;
|
|
197321
197937
|
const destRun = await findBookRunDirectory(
|
|
197322
|
-
|
|
197938
|
+
join22(context.booksDirectory, bookKey),
|
|
197323
197939
|
coords.runId,
|
|
197324
197940
|
coords.role
|
|
197325
197941
|
);
|
|
197326
197942
|
if (destRun === void 0) continue;
|
|
197327
|
-
await scrubRawLinesFromFile(
|
|
197943
|
+
await scrubRawLinesFromFile(join22(destRun.runDirectory, withinRun), rawLines);
|
|
197328
197944
|
}
|
|
197329
197945
|
}
|
|
197330
197946
|
async function forEachBook(context, body) {
|
|
@@ -197373,9 +197989,10 @@ var BOOK_TOPOLOGY_RECORD_CLASS_MIGRATORS = [
|
|
|
197373
197989
|
|
|
197374
197990
|
// src/book-topology-runs-migrator.ts
|
|
197375
197991
|
import { cp as cp4, mkdir as mkdir6, rename as rename2, readdir as readdir7, stat as stat6, writeFile as writeFile9 } from "node:fs/promises";
|
|
197376
|
-
import { basename as
|
|
197992
|
+
import { basename as basename14, dirname as dirname17, join as join23, relative as relative7, sep as sep10 } from "node:path";
|
|
197377
197993
|
init_role_run_placement();
|
|
197378
197994
|
init_role_run_relocation();
|
|
197995
|
+
init_run_dossier();
|
|
197379
197996
|
init_run_ticket_number();
|
|
197380
197997
|
init_unknown_value();
|
|
197381
197998
|
var RUNS_PARTITION = "runs";
|
|
@@ -197402,18 +198019,18 @@ async function writeDerivationPage(targetRunDirectory, derivation) {
|
|
|
197402
198019
|
page: derivation.sourcePage,
|
|
197403
198020
|
field: "projectRoot",
|
|
197404
198021
|
path: derivation.projectRoot,
|
|
197405
|
-
basename:
|
|
198022
|
+
basename: basename14(derivation.projectRoot)
|
|
197406
198023
|
}
|
|
197407
198024
|
};
|
|
197408
198025
|
await writeFile9(
|
|
197409
|
-
|
|
198026
|
+
join23(targetRunDirectory, MIGRATION_TICKET_DERIVATION_PAGE),
|
|
197410
198027
|
`${JSON.stringify(page, null, 2)}
|
|
197411
198028
|
`,
|
|
197412
198029
|
"utf8"
|
|
197413
198030
|
);
|
|
197414
198031
|
}
|
|
197415
198032
|
async function copyRunTree(source, target, isDirectory) {
|
|
197416
|
-
await mkdir6(
|
|
198033
|
+
await mkdir6(dirname17(target), { recursive: true });
|
|
197417
198034
|
if (isDirectory) {
|
|
197418
198035
|
await cp4(source, target, { recursive: true, preserveTimestamps: true });
|
|
197419
198036
|
return;
|
|
@@ -197421,7 +198038,7 @@ async function copyRunTree(source, target, isDirectory) {
|
|
|
197421
198038
|
await cp4(source, target, { preserveTimestamps: true });
|
|
197422
198039
|
}
|
|
197423
198040
|
async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
197424
|
-
const backupBook =
|
|
198041
|
+
const backupBook = join23(backupBooksDirectory, bookKey);
|
|
197425
198042
|
const claimed = /* @__PURE__ */ new Map();
|
|
197426
198043
|
const planned = [];
|
|
197427
198044
|
for (const leaf of await listBackupRunLeaves(backupBook)) {
|
|
@@ -197435,9 +198052,9 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197435
198052
|
const parts = leaf.relativePath.replaceAll("\\", "/").split("/");
|
|
197436
198053
|
const ticketStr = parts[1];
|
|
197437
198054
|
if (ticketStr !== void 0 && isTicketNumberString2(ticketStr)) {
|
|
197438
|
-
targetPath =
|
|
198055
|
+
targetPath = join23(booksDirectory, bookKey, ticketStr, "runs", leaf.leafName);
|
|
197439
198056
|
disposition = "placed";
|
|
197440
|
-
historicalRunDirectory =
|
|
198057
|
+
historicalRunDirectory = join23(
|
|
197441
198058
|
booksDirectory,
|
|
197442
198059
|
bookKey,
|
|
197443
198060
|
"issues",
|
|
@@ -197446,13 +198063,13 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197446
198063
|
leaf.leafName
|
|
197447
198064
|
);
|
|
197448
198065
|
} else {
|
|
197449
|
-
targetPath =
|
|
198066
|
+
targetPath = join23(booksDirectory, bookKey, "unbound", "runs", leaf.leafName);
|
|
197450
198067
|
disposition = "unbound";
|
|
197451
|
-
historicalRunDirectory =
|
|
198068
|
+
historicalRunDirectory = join23(booksDirectory, bookKey, leaf.relativePath);
|
|
197452
198069
|
}
|
|
197453
198070
|
derivation = void 0;
|
|
197454
198071
|
} else if (leaf.layout === "unbound") {
|
|
197455
|
-
const boardTicket = leaf.isDirectory ? await
|
|
198072
|
+
const boardTicket = leaf.isDirectory ? await readMigrationBoardTicketNumber(leaf.sourcePath) : void 0;
|
|
197456
198073
|
if (parsed2 !== void 0 && boardTicket !== void 0) {
|
|
197457
198074
|
targetPath = destinationRunDirectory(
|
|
197458
198075
|
booksDirectory,
|
|
@@ -197462,7 +198079,7 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197462
198079
|
parsed2.role
|
|
197463
198080
|
);
|
|
197464
198081
|
disposition = "placed";
|
|
197465
|
-
historicalRunDirectory =
|
|
198082
|
+
historicalRunDirectory = join23(
|
|
197466
198083
|
booksDirectory,
|
|
197467
198084
|
bookKey,
|
|
197468
198085
|
"unbound",
|
|
@@ -197470,20 +198087,20 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197470
198087
|
leaf.leafName
|
|
197471
198088
|
);
|
|
197472
198089
|
} else {
|
|
197473
|
-
targetPath =
|
|
198090
|
+
targetPath = join23(booksDirectory, bookKey, leaf.relativePath);
|
|
197474
198091
|
disposition = "unbound";
|
|
197475
198092
|
historicalRunDirectory = void 0;
|
|
197476
198093
|
}
|
|
197477
198094
|
derivation = void 0;
|
|
197478
198095
|
} else if (leaf.layout !== "flat") {
|
|
197479
|
-
targetPath =
|
|
198096
|
+
targetPath = join23(booksDirectory, bookKey, leaf.relativePath);
|
|
197480
198097
|
disposition = "placed";
|
|
197481
198098
|
historicalRunDirectory = void 0;
|
|
197482
198099
|
derivation = void 0;
|
|
197483
198100
|
} else if (parsed2 === void 0) {
|
|
197484
|
-
targetPath =
|
|
198101
|
+
targetPath = join23(booksDirectory, bookKey, "unbound", "runs", leaf.leafName);
|
|
197485
198102
|
disposition = "unbound";
|
|
197486
|
-
historicalRunDirectory =
|
|
198103
|
+
historicalRunDirectory = join23(booksDirectory, bookKey, "runs", leaf.leafName);
|
|
197487
198104
|
derivation = void 0;
|
|
197488
198105
|
} else {
|
|
197489
198106
|
const ticket = await resolveMigratingRunTicket(leaf.sourcePath);
|
|
@@ -197495,7 +198112,7 @@ async function planBookMoves(backupBooksDirectory, booksDirectory, bookKey) {
|
|
|
197495
198112
|
parsed2.role
|
|
197496
198113
|
);
|
|
197497
198114
|
disposition = ticket.ticketNumber === void 0 ? "unbound" : "placed";
|
|
197498
|
-
historicalRunDirectory =
|
|
198115
|
+
historicalRunDirectory = join23(booksDirectory, bookKey, "runs", leaf.leafName);
|
|
197499
198116
|
derivation = ticket.derivation?.method === "project-root-basename" && ticket.ticketNumber !== void 0 ? {
|
|
197500
198117
|
ticketNumber: ticket.ticketNumber,
|
|
197501
198118
|
projectRoot: ticket.derivation.source,
|
|
@@ -197564,9 +198181,9 @@ var bookTopologyRunsMigrator = {
|
|
|
197564
198181
|
}
|
|
197565
198182
|
};
|
|
197566
198183
|
async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
|
|
197567
|
-
const bookKey =
|
|
197568
|
-
const booksDirectory =
|
|
197569
|
-
const unboundRuns =
|
|
198184
|
+
const bookKey = basename14(bookDirectory);
|
|
198185
|
+
const booksDirectory = dirname17(bookDirectory);
|
|
198186
|
+
const unboundRuns = join23(bookDirectory, "unbound", "runs");
|
|
197570
198187
|
let entries;
|
|
197571
198188
|
try {
|
|
197572
198189
|
entries = await readdir7(unboundRuns, { withFileTypes: true });
|
|
@@ -197579,8 +198196,8 @@ async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
|
|
|
197579
198196
|
if (!entry.isDirectory()) continue;
|
|
197580
198197
|
const parsed2 = parseRunLeaf3(entry.name);
|
|
197581
198198
|
if (parsed2 === void 0) continue;
|
|
197582
|
-
const sourcePath =
|
|
197583
|
-
const boardTicket = await
|
|
198199
|
+
const sourcePath = join23(unboundRuns, entry.name);
|
|
198200
|
+
const boardTicket = await readMigrationBoardTicketNumber(sourcePath);
|
|
197584
198201
|
if (boardTicket === void 0) continue;
|
|
197585
198202
|
const targetPath = destinationRunDirectory(
|
|
197586
198203
|
booksDirectory,
|
|
@@ -197620,8 +198237,9 @@ async function relocateBoardBoundUnboundRunsInBook(bookDirectory) {
|
|
|
197620
198237
|
});
|
|
197621
198238
|
}
|
|
197622
198239
|
for (const move of planned) {
|
|
197623
|
-
await mkdir6(
|
|
198240
|
+
await mkdir6(dirname17(move.targetPath), { recursive: true });
|
|
197624
198241
|
await rename2(move.sourcePath, move.targetPath);
|
|
198242
|
+
renderCurrentSync(move.targetPath);
|
|
197625
198243
|
}
|
|
197626
198244
|
return planned.map((move) => ({
|
|
197627
198245
|
from: move.sourcePath,
|
|
@@ -197633,7 +198251,7 @@ async function relocateBoardBoundUnboundRunsInBooks(booksDirectory) {
|
|
|
197633
198251
|
const relocated = [];
|
|
197634
198252
|
for (const bookKey of await listMigrationBookKeys(booksDirectory)) {
|
|
197635
198253
|
const batch = await relocateBoardBoundUnboundRunsInBook(
|
|
197636
|
-
|
|
198254
|
+
join23(booksDirectory, bookKey)
|
|
197637
198255
|
);
|
|
197638
198256
|
relocated.push(...batch);
|
|
197639
198257
|
}
|
|
@@ -197662,7 +198280,7 @@ function parseMigrateArgv(argv) {
|
|
|
197662
198280
|
if (arg === "--ledger-home") {
|
|
197663
198281
|
const value2 = argv[i2 + 1];
|
|
197664
198282
|
if (value2 === void 0) throw new Error(USAGE);
|
|
197665
|
-
ledgerHome =
|
|
198283
|
+
ledgerHome = resolve12(value2);
|
|
197666
198284
|
i2 += 1;
|
|
197667
198285
|
continue;
|
|
197668
198286
|
}
|
|
@@ -197672,9 +198290,9 @@ function parseMigrateArgv(argv) {
|
|
|
197672
198290
|
}
|
|
197673
198291
|
var parsed = parseMigrateArgv(process.argv.slice(2));
|
|
197674
198292
|
if (parsed.relocateBoardBoundUnbound) {
|
|
197675
|
-
const ledgerHome = parsed.ledgerHome ??
|
|
198293
|
+
const ledgerHome = parsed.ledgerHome ?? join24(homedir6(), ".ak-roles");
|
|
197676
198294
|
const relocated = await relocateBoardBoundUnboundRunsInBooks(
|
|
197677
|
-
|
|
198295
|
+
join24(ledgerHome, "books")
|
|
197678
198296
|
);
|
|
197679
198297
|
process.stdout.write(
|
|
197680
198298
|
`${JSON.stringify({ ledgerHome, relocatedCount: relocated.length, relocated }, null, 2)}
|