@primitive.ai/prim 0.1.0-alpha.106 → 0.1.0-alpha.108
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/SKILL.md +42 -5
- package/dist/{chunk-6VFUHQ4J.js → chunk-AIAYIXBJ.js} +1 -1
- package/dist/{chunk-HT2CJ3YD.js → chunk-D24AUSVP.js} +65 -28
- package/dist/{chunk-4CO4A6NR.js → chunk-EQYIPUFX.js} +1 -1
- package/dist/{chunk-XY4CRWTF.js → chunk-FDXDV2AT.js} +3 -3
- package/dist/{chunk-FFYZ3XMX.js → chunk-GFJ4QIVR.js} +210 -117
- package/dist/{chunk-7GSBXHK4.js → chunk-LFZYNNQQ.js} +71 -7
- package/dist/{chunk-TPWJQD5E.js → chunk-QJOK2VOE.js} +1 -1
- package/dist/{chunk-72CQVK4E.js → chunk-RXD6LFA2.js} +1 -1
- package/dist/{chunk-LVRD562C.js → chunk-YQFJUBNU.js} +1 -1
- package/dist/daemon/server.js +210 -117
- package/dist/hook-runtime/daemon/server.js +210 -117
- package/dist/hook-runtime/hooks/post-commit.js +210 -117
- package/dist/hook-runtime/hooks/post-rewrite.js +210 -117
- package/dist/hook-runtime/hooks/post-tool-use.js +890 -749
- package/dist/hook-runtime/hooks/pre-tool-use.js +484 -343
- package/dist/hook-runtime/hooks/prim-hook.js +543 -402
- package/dist/hook-runtime/hooks/session-start.js +210 -117
- package/dist/hook-runtime/index.js +608 -354
- package/dist/hooks/post-commit.js +3 -3
- package/dist/hooks/post-rewrite.js +3 -3
- package/dist/hooks/post-tool-use.js +9 -9
- package/dist/hooks/pre-tool-use.js +6 -6
- package/dist/hooks/prim-hook.js +8 -8
- package/dist/hooks/session-start.js +3 -3
- package/dist/index.js +184 -71
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ var require_ucs2length = __commonJS({
|
|
|
53
53
|
|
|
54
54
|
// src/hooks/post-tool-use.ts
|
|
55
55
|
import { readFileSync as readFileSync17 } from "fs";
|
|
56
|
-
import { dirname as dirname12, join as
|
|
56
|
+
import { dirname as dirname12, join as join20 } from "path";
|
|
57
57
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
58
58
|
|
|
59
59
|
// src/binding.ts
|
|
@@ -436,12 +436,445 @@ function resolveOrg(args) {
|
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
// src/demo/isolation.ts
|
|
439
|
-
import { existsSync as
|
|
439
|
+
import { existsSync as existsSync7 } from "fs";
|
|
440
|
+
|
|
441
|
+
// src/lib/bin-path.ts
|
|
442
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "fs";
|
|
443
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join4 } from "path";
|
|
444
|
+
import { fileURLToPath } from "url";
|
|
445
|
+
var PKG_NAME = "@primitive.ai/prim";
|
|
446
|
+
var ROOT_WALK_LIMIT = 6;
|
|
447
|
+
var STABLE_HOOK_LAUNCHER_NAME = "prim-hook-launcher-v1";
|
|
448
|
+
var resolvedRoot;
|
|
449
|
+
function locateRoot() {
|
|
450
|
+
if (resolvedRoot !== void 0) {
|
|
451
|
+
return resolvedRoot;
|
|
452
|
+
}
|
|
453
|
+
let dir = dirname2(fileURLToPath(import.meta.url));
|
|
454
|
+
for (let depth = 0; depth < ROOT_WALK_LIMIT; depth++) {
|
|
455
|
+
const manifestPath = join4(dir, "package.json");
|
|
456
|
+
if (existsSync2(manifestPath)) {
|
|
457
|
+
try {
|
|
458
|
+
const manifest = JSON.parse(readFileSync3(manifestPath, "utf-8"));
|
|
459
|
+
if (manifest.name === PKG_NAME && manifest.bin) {
|
|
460
|
+
resolvedRoot = { dir, version: manifest.version, bin: manifest.bin };
|
|
461
|
+
return resolvedRoot;
|
|
462
|
+
}
|
|
463
|
+
} catch {
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const parent = dirname2(dir);
|
|
467
|
+
if (parent === dir) {
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
dir = parent;
|
|
471
|
+
}
|
|
472
|
+
resolvedRoot = null;
|
|
473
|
+
return resolvedRoot;
|
|
474
|
+
}
|
|
475
|
+
function packageVersion() {
|
|
476
|
+
return locateRoot()?.version ?? null;
|
|
477
|
+
}
|
|
478
|
+
function shellQuote(value) {
|
|
479
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
480
|
+
}
|
|
481
|
+
var STABLE_HOOK_ARGUMENTS_RE = /^[-A-Za-z0-9_ ]*$/u;
|
|
482
|
+
var STABLE_HOOK_BIN_RE = /^[A-Za-z0-9][A-Za-z0-9-]*$/u;
|
|
483
|
+
var PRIM_CONFIG_SHELL_RESOLVER = [
|
|
484
|
+
'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
|
|
485
|
+
'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
|
|
486
|
+
'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
|
|
487
|
+
'else prim_home=${HOME:-}; prim_absolute "$prim_home" || exit 78; case "$prim_home" in /) prim_config=/.config/prim ;; *) prim_config="$prim_home/.config/prim" ;; esac; ',
|
|
488
|
+
"fi; fi; "
|
|
489
|
+
].join("");
|
|
490
|
+
function stableHookCommand(bin, args = "") {
|
|
491
|
+
if (!STABLE_HOOK_BIN_RE.test(bin) || !STABLE_HOOK_ARGUMENTS_RE.test(args)) {
|
|
492
|
+
throw new Error("invalid stable hook command");
|
|
493
|
+
}
|
|
494
|
+
const resolver = [
|
|
495
|
+
// #242 and earlier identify managed commands by this package marker. Keep
|
|
496
|
+
// it as inert data during the rolling window so an older uninstall or
|
|
497
|
+
// reinstall can remove the stable entry without invoking npm or PATH.
|
|
498
|
+
`prim_legacy_reader='-p ${PKG_NAME}@stable prim-shim.sh ${bin} '; `,
|
|
499
|
+
PRIM_CONFIG_SHELL_RESOLVER,
|
|
500
|
+
`case "$prim_config" in /) prim_launcher=/${STABLE_HOOK_LAUNCHER_NAME} ;; *) prim_launcher="$prim_config/${STABLE_HOOK_LAUNCHER_NAME}" ;; esac; `,
|
|
501
|
+
'exec "$prim_launcher" "$@"'
|
|
502
|
+
].join("");
|
|
503
|
+
const suffix = args ? ` ${args}` : "";
|
|
504
|
+
return `/bin/sh -c ${shellQuote(resolver)} ${STABLE_HOOK_LAUNCHER_NAME} ${bin}${suffix}`;
|
|
505
|
+
}
|
|
506
|
+
function detachedHookShimCommand(bin, args = "") {
|
|
507
|
+
return `payload=$(cat); { trap '' HUP; printf '%s' "$payload" | { ${stableHookCommand(bin, args)}; }; } </dev/null >/dev/null 2>&1 &`;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// src/demo/diagnostics.ts
|
|
511
|
+
import { existsSync as existsSync6 } from "fs";
|
|
512
|
+
import { join as join8 } from "path";
|
|
513
|
+
|
|
514
|
+
// src/lib/hook-runtime.ts
|
|
515
|
+
import { createHash as createHash2, randomBytes as randomBytes2 } from "crypto";
|
|
516
|
+
import {
|
|
517
|
+
constants as constants2,
|
|
518
|
+
accessSync,
|
|
519
|
+
chmodSync,
|
|
520
|
+
copyFileSync,
|
|
521
|
+
existsSync as existsSync4,
|
|
522
|
+
lstatSync,
|
|
523
|
+
mkdirSync as mkdirSync3,
|
|
524
|
+
mkdtempSync,
|
|
525
|
+
readFileSync as readFileSync5,
|
|
526
|
+
readdirSync,
|
|
527
|
+
realpathSync,
|
|
528
|
+
renameSync as renameSync2,
|
|
529
|
+
rmSync as rmSync3,
|
|
530
|
+
statSync as statSync2,
|
|
531
|
+
utimesSync,
|
|
532
|
+
writeFileSync as writeFileSync3
|
|
533
|
+
} from "fs";
|
|
534
|
+
import { delimiter, dirname as dirname5, isAbsolute as isAbsolute3, join as join6, resolve } from "path";
|
|
535
|
+
|
|
536
|
+
// src/lib/atomic-file.ts
|
|
537
|
+
import { randomUUID } from "crypto";
|
|
538
|
+
import {
|
|
539
|
+
constants,
|
|
540
|
+
closeSync,
|
|
541
|
+
fchmodSync,
|
|
542
|
+
fsyncSync,
|
|
543
|
+
mkdirSync,
|
|
544
|
+
openSync,
|
|
545
|
+
renameSync,
|
|
546
|
+
rmSync,
|
|
547
|
+
writeFileSync
|
|
548
|
+
} from "fs";
|
|
549
|
+
import { dirname as dirname3 } from "path";
|
|
550
|
+
var DEFAULT_FILE_MODE = 438;
|
|
551
|
+
function syncDirectory(path) {
|
|
552
|
+
const fd = openSync(path, constants.O_RDONLY);
|
|
553
|
+
try {
|
|
554
|
+
fsyncSync(fd);
|
|
555
|
+
} finally {
|
|
556
|
+
closeSync(fd);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
function syncCreatedParentChain(firstCreatedParent, parent) {
|
|
560
|
+
const createdDirectories = [];
|
|
561
|
+
let current = parent;
|
|
562
|
+
while (current !== firstCreatedParent) {
|
|
563
|
+
createdDirectories.push(current);
|
|
564
|
+
const next = dirname3(current);
|
|
565
|
+
if (next === current) {
|
|
566
|
+
throw new Error("recursive mkdir returned a path outside the target parent chain");
|
|
567
|
+
}
|
|
568
|
+
current = next;
|
|
569
|
+
}
|
|
570
|
+
createdDirectories.push(firstCreatedParent);
|
|
571
|
+
syncDirectory(dirname3(firstCreatedParent));
|
|
572
|
+
for (const directory of createdDirectories.reverse().slice(0, -1)) {
|
|
573
|
+
syncDirectory(directory);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function ensureDurableDirectory(path, mode) {
|
|
577
|
+
const firstCreatedParent = mkdirSync(path, { recursive: true, mode });
|
|
578
|
+
if (firstCreatedParent) {
|
|
579
|
+
syncCreatedParentChain(firstCreatedParent, path);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function atomicWriteFile(target, content, options = {}) {
|
|
583
|
+
const parent = dirname3(target);
|
|
584
|
+
if (options.ensureParent) {
|
|
585
|
+
ensureDurableDirectory(parent);
|
|
586
|
+
}
|
|
587
|
+
const temporaryPath = `${target}.${randomUUID()}.tmp`;
|
|
588
|
+
let temporaryCreated = false;
|
|
589
|
+
try {
|
|
590
|
+
const flags = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW;
|
|
591
|
+
const fd = openSync(temporaryPath, flags, options.mode ?? DEFAULT_FILE_MODE);
|
|
592
|
+
temporaryCreated = true;
|
|
593
|
+
try {
|
|
594
|
+
if (options.mode !== void 0) fchmodSync(fd, options.mode);
|
|
595
|
+
writeFileSync(fd, content);
|
|
596
|
+
fsyncSync(fd);
|
|
597
|
+
} finally {
|
|
598
|
+
closeSync(fd);
|
|
599
|
+
}
|
|
600
|
+
options.validate?.(temporaryPath);
|
|
601
|
+
renameSync(temporaryPath, target);
|
|
602
|
+
syncDirectory(parent);
|
|
603
|
+
} catch (error) {
|
|
604
|
+
if (temporaryCreated) {
|
|
605
|
+
try {
|
|
606
|
+
rmSync(temporaryPath, { force: true });
|
|
607
|
+
} catch {
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
throw error;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// src/lib/file-lock.ts
|
|
615
|
+
import { randomBytes } from "crypto";
|
|
616
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
|
|
617
|
+
import { dirname as dirname4, join as join5 } from "path";
|
|
618
|
+
|
|
619
|
+
// src/lib/process-liveness.ts
|
|
620
|
+
function processIsAlive(pid, probe = process.kill) {
|
|
621
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return false;
|
|
622
|
+
try {
|
|
623
|
+
probe(pid, 0);
|
|
624
|
+
return true;
|
|
625
|
+
} catch (error) {
|
|
626
|
+
return error.code === "EPERM";
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// src/lib/file-lock.ts
|
|
631
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
632
|
+
var DEFAULT_POLL_MS = 50;
|
|
633
|
+
var DEFAULT_INIT_GRACE_MS = 2e3;
|
|
634
|
+
var DIRECTORY_MODE = 448;
|
|
635
|
+
var FILE_MODE = 384;
|
|
636
|
+
function ownerPath(lockDir) {
|
|
637
|
+
return join5(lockDir, "owner.json");
|
|
638
|
+
}
|
|
639
|
+
function readOwner(lockDir) {
|
|
640
|
+
try {
|
|
641
|
+
const owner = JSON.parse(readFileSync4(ownerPath(lockDir), "utf8"));
|
|
642
|
+
if (!Number.isInteger(owner.pid) || owner.pid <= 0 || typeof owner.nonce !== "string" || typeof owner.createdAt !== "number") {
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
return owner;
|
|
646
|
+
} catch {
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
function sameOwner(a, b) {
|
|
651
|
+
return a?.pid === b.pid && a.nonce === b.nonce && a.createdAt === b.createdAt;
|
|
652
|
+
}
|
|
653
|
+
function tryTakeLock(lockDir, now) {
|
|
654
|
+
try {
|
|
655
|
+
mkdirSync2(lockDir, { mode: DIRECTORY_MODE });
|
|
656
|
+
} catch (error) {
|
|
657
|
+
if (error.code === "EEXIST") return null;
|
|
658
|
+
throw error;
|
|
659
|
+
}
|
|
660
|
+
const owner = {
|
|
661
|
+
pid: process.pid,
|
|
662
|
+
nonce: randomBytes(16).toString("hex"),
|
|
663
|
+
createdAt: now
|
|
664
|
+
};
|
|
665
|
+
try {
|
|
666
|
+
writeFileSync2(ownerPath(lockDir), `${JSON.stringify(owner)}
|
|
667
|
+
`, {
|
|
668
|
+
encoding: "utf8",
|
|
669
|
+
mode: FILE_MODE,
|
|
670
|
+
flag: "wx"
|
|
671
|
+
});
|
|
672
|
+
return owner;
|
|
673
|
+
} catch (error) {
|
|
674
|
+
rmSync2(lockDir, { recursive: true, force: true });
|
|
675
|
+
throw error;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function recoverStaleLock(lockDir, now, alive, initGraceMs) {
|
|
679
|
+
const owner = readOwner(lockDir);
|
|
680
|
+
if (owner) {
|
|
681
|
+
if (alive(owner.pid)) return false;
|
|
682
|
+
if (!sameOwner(readOwner(lockDir), owner)) return false;
|
|
683
|
+
rmSync2(lockDir, { recursive: true, force: true });
|
|
684
|
+
return true;
|
|
685
|
+
}
|
|
686
|
+
try {
|
|
687
|
+
const before = statSync(lockDir).mtimeMs;
|
|
688
|
+
if (now - before < initGraceMs) return false;
|
|
689
|
+
if (readOwner(lockDir)) return false;
|
|
690
|
+
if (statSync(lockDir).mtimeMs !== before) return false;
|
|
691
|
+
rmSync2(lockDir, { recursive: true, force: true });
|
|
692
|
+
return true;
|
|
693
|
+
} catch {
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function abortError(signal) {
|
|
698
|
+
if (signal.reason instanceof Error) return signal.reason;
|
|
699
|
+
const error = new Error("The operation was aborted");
|
|
700
|
+
error.name = "AbortError";
|
|
701
|
+
return error;
|
|
702
|
+
}
|
|
703
|
+
function throwIfAborted(signal) {
|
|
704
|
+
if (signal?.aborted) throw abortError(signal);
|
|
705
|
+
}
|
|
706
|
+
async function defaultSleep(ms, signal) {
|
|
707
|
+
if (!signal) {
|
|
708
|
+
await new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
throwIfAborted(signal);
|
|
712
|
+
await new Promise((resolve7, reject) => {
|
|
713
|
+
const timer = setTimeout(() => {
|
|
714
|
+
signal.removeEventListener("abort", onAbort);
|
|
715
|
+
resolve7();
|
|
716
|
+
}, ms);
|
|
717
|
+
const onAbort = () => {
|
|
718
|
+
clearTimeout(timer);
|
|
719
|
+
reject(abortError(signal));
|
|
720
|
+
};
|
|
721
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
725
|
+
function defaultSleepSync(ms) {
|
|
726
|
+
Atomics.wait(syncSleeper, 0, 0, ms);
|
|
727
|
+
}
|
|
728
|
+
function withFileLockSync(lockDir, operation, options = {}) {
|
|
729
|
+
mkdirSync2(dirname4(lockDir), { recursive: true, mode: DIRECTORY_MODE });
|
|
730
|
+
const nowMs = options.nowMs ?? Date.now;
|
|
731
|
+
const alive = options.processAlive ?? processIsAlive;
|
|
732
|
+
const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
733
|
+
let owner = null;
|
|
734
|
+
while (!owner) {
|
|
735
|
+
const now = nowMs();
|
|
736
|
+
owner = tryTakeLock(lockDir, now);
|
|
737
|
+
if (owner) break;
|
|
738
|
+
recoverStaleLock(lockDir, now, alive, options.initGraceMs ?? DEFAULT_INIT_GRACE_MS);
|
|
739
|
+
if (now >= deadline) {
|
|
740
|
+
throw new Error(`timed out waiting for file lock ${lockDir}`);
|
|
741
|
+
}
|
|
742
|
+
(options.sleep ?? defaultSleepSync)(options.pollMs ?? DEFAULT_POLL_MS);
|
|
743
|
+
}
|
|
744
|
+
try {
|
|
745
|
+
return operation();
|
|
746
|
+
} finally {
|
|
747
|
+
if (sameOwner(readOwner(lockDir), owner)) {
|
|
748
|
+
rmSync2(lockDir, { recursive: true, force: true });
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
async function withFileLock(lockDir, operation, options = {}) {
|
|
753
|
+
mkdirSync2(dirname4(lockDir), { recursive: true, mode: DIRECTORY_MODE });
|
|
754
|
+
const nowMs = options.nowMs ?? Date.now;
|
|
755
|
+
const alive = options.processAlive ?? processIsAlive;
|
|
756
|
+
const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
757
|
+
let owner = null;
|
|
758
|
+
while (!owner) {
|
|
759
|
+
throwIfAborted(options.signal);
|
|
760
|
+
const now = nowMs();
|
|
761
|
+
owner = tryTakeLock(lockDir, now);
|
|
762
|
+
if (owner) break;
|
|
763
|
+
recoverStaleLock(lockDir, now, alive, options.initGraceMs ?? DEFAULT_INIT_GRACE_MS);
|
|
764
|
+
if (now >= deadline) {
|
|
765
|
+
throw new Error(`timed out waiting for file lock ${lockDir}`);
|
|
766
|
+
}
|
|
767
|
+
if (options.sleep) {
|
|
768
|
+
await options.sleep(options.pollMs ?? DEFAULT_POLL_MS);
|
|
769
|
+
throwIfAborted(options.signal);
|
|
770
|
+
} else {
|
|
771
|
+
await defaultSleep(options.pollMs ?? DEFAULT_POLL_MS, options.signal);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
throwIfAborted(options.signal);
|
|
776
|
+
return await operation();
|
|
777
|
+
} finally {
|
|
778
|
+
if (sameOwner(readOwner(lockDir), owner)) {
|
|
779
|
+
rmSync2(lockDir, { recursive: true, force: true });
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// src/lib/git-hook-contract.ts
|
|
785
|
+
var GIT_HOOK_ENTRYPOINT_CONTENT = `#!/bin/sh
|
|
786
|
+
# prim git hook entrypoint v1 \u2014 managed by prim; do not edit.
|
|
787
|
+
# Run by the "# >>> prim <hook> hook >>>" block in a Git hook file. Acts only
|
|
788
|
+
# where prim is active (git config prim.active true) and never fails the hook.
|
|
789
|
+
case "$0" in */*) prim_dir=\${0%/*} ;; *) exit 0 ;; esac
|
|
790
|
+
prim_launcher="$prim_dir/${STABLE_HOOK_LAUNCHER_NAME}"
|
|
791
|
+
[ -x "$prim_launcher" ] || exit 0
|
|
792
|
+
[ "$(git config --get prim.active 2>/dev/null)" = "true" ] || exit 0
|
|
793
|
+
prim_hook=\${1-}
|
|
794
|
+
if [ "$#" -gt 0 ]; then shift; fi
|
|
795
|
+
case "$prim_hook" in
|
|
796
|
+
pre-commit)
|
|
797
|
+
"$prim_launcher" prim-pre-commit "$@" || :
|
|
798
|
+
;;
|
|
799
|
+
post-commit)
|
|
800
|
+
prim_sha=$(git rev-parse --verify HEAD 2>/dev/null) || exit 0
|
|
801
|
+
case "$prim_sha" in *[!0-9a-f]* | "") exit 0 ;; esac
|
|
802
|
+
case "\${#prim_sha}" in 40 | 64) ;; *) exit 0 ;; esac
|
|
803
|
+
prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
|
|
804
|
+
prim_observed=$(mktemp "\${TMPDIR:-/tmp}/prim-post-commit-observed.XXXXXXXX" 2>/dev/null) || prim_observed=
|
|
805
|
+
(
|
|
806
|
+
trap '' HUP
|
|
807
|
+
trap 'if [ -n "$prim_observed" ]; then rm -f "$prim_observed"; fi' 0
|
|
808
|
+
PRIM_COMMIT_SHA=$prim_sha PRIM_COMMIT_BRANCH=$prim_branch PRIM_COMMIT_OBSERVED_FILE=$prim_observed "$prim_launcher" prim-post-commit
|
|
809
|
+
) </dev/null >/dev/null 2>&1 &
|
|
810
|
+
;;
|
|
811
|
+
post-rewrite)
|
|
812
|
+
case "\${1-}" in amend | rebase) prim_source=$1 ;; *) exit 0 ;; esac
|
|
813
|
+
prim_pairs=$(mktemp "\${TMPDIR:-/tmp}/prim-post-rewrite-pairs.XXXXXXXX" 2>/dev/null) || exit 0
|
|
814
|
+
if ! chmod 600 "$prim_pairs" 2>/dev/null || ! cat >"$prim_pairs"; then
|
|
815
|
+
rm -f "$prim_pairs"
|
|
816
|
+
exit 0
|
|
817
|
+
fi
|
|
818
|
+
prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
|
|
819
|
+
(
|
|
820
|
+
trap '' HUP
|
|
821
|
+
trap 'rm -f "$prim_pairs"' 0
|
|
822
|
+
PRIM_REWRITE_SOURCE=$prim_source PRIM_REWRITE_BRANCH=$prim_branch PRIM_REWRITE_PAIRS_FILE=$prim_pairs "$prim_launcher" prim-post-rewrite
|
|
823
|
+
) </dev/null >/dev/null 2>&1 &
|
|
824
|
+
;;
|
|
825
|
+
esac
|
|
826
|
+
exit 0
|
|
827
|
+
`;
|
|
828
|
+
|
|
829
|
+
// src/lib/hook-runtime.ts
|
|
830
|
+
var RELEASE_PREFIX = "release-";
|
|
831
|
+
var MAX_MANIFEST_BYTES = 64 * 1024;
|
|
832
|
+
var RELEASE_GRACE_MS = 10 * 60 * 1e3;
|
|
833
|
+
var HOOK_RUNTIME_ENTRIES = {
|
|
834
|
+
// SessionStart self-healing resolves this exact CLI entry to run
|
|
835
|
+
// `daemon ensure`; it must travel with the immutable hook release.
|
|
836
|
+
prim: "dist/index.js",
|
|
837
|
+
"prim-hook": "dist/hooks/prim-hook.js",
|
|
838
|
+
"prim-pre-commit": "dist/hooks/pre-commit.js",
|
|
839
|
+
"prim-post-commit": "dist/hooks/post-commit.js",
|
|
840
|
+
"prim-post-rewrite": "dist/hooks/post-rewrite.js",
|
|
841
|
+
"prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
|
|
842
|
+
"prim-post-tool-use": "dist/hooks/post-tool-use.js",
|
|
843
|
+
"prim-session-start": "dist/hooks/session-start.js",
|
|
844
|
+
"prim-session-end": "dist/hooks/session-end.js",
|
|
845
|
+
"prim-daemon-server": "dist/daemon/server.js",
|
|
846
|
+
"prim-statusline": "dist/statusline-main.js"
|
|
847
|
+
};
|
|
848
|
+
var SOURCE_ENTRIES = Object.fromEntries(
|
|
849
|
+
Object.entries(HOOK_RUNTIME_ENTRIES).map(([bin, target]) => [
|
|
850
|
+
bin,
|
|
851
|
+
target.replace(/^dist\//u, "")
|
|
852
|
+
])
|
|
853
|
+
);
|
|
854
|
+
var STABLE_HOOK_LAUNCHER_CONTENT = `#!/bin/sh
|
|
855
|
+
set -eu
|
|
856
|
+
case "$0" in */*) prim_launcher_dir=\${0%/*} ;; *) exit 78 ;; esac
|
|
857
|
+
IFS= read -r prim_release_name < "$prim_launcher_dir/hook-runtime/current" || exit 69
|
|
858
|
+
case "$prim_release_name" in ${RELEASE_PREFIX}*) ;; *) exit 69 ;; esac
|
|
859
|
+
prim_release_id=\${prim_release_name#${RELEASE_PREFIX}}
|
|
860
|
+
case "$prim_release_id" in *[!0-9a-f]*|"") exit 69 ;; esac
|
|
861
|
+
[ "\${#prim_release_id}" -eq 64 ] || exit 69
|
|
862
|
+
prim_release="$prim_launcher_dir/hook-runtime/releases/$prim_release_name"
|
|
863
|
+
case "\${1-}" in
|
|
864
|
+
${Object.entries(HOOK_RUNTIME_ENTRIES).map(([bin, entry]) => ` ${bin}) prim_entry="$prim_release/${entry}" ;;`).join("\n")}
|
|
865
|
+
*) exit 64 ;;
|
|
866
|
+
esac
|
|
867
|
+
shift
|
|
868
|
+
IFS= read -r prim_node < "$prim_release/node" || exit 69
|
|
869
|
+
case "$prim_node" in /*) ;; *) exit 69 ;; esac
|
|
870
|
+
[ -x "$prim_node" ] && [ -f "$prim_entry" ] || exit 69
|
|
871
|
+
exec "$prim_node" "$prim_entry" "$@"
|
|
872
|
+
`;
|
|
440
873
|
|
|
441
874
|
// src/demo/state.ts
|
|
442
|
-
import { createHash as
|
|
443
|
-
import { existsSync as
|
|
444
|
-
import { join as
|
|
875
|
+
import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
|
|
876
|
+
import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "fs";
|
|
877
|
+
import { join as join7, resolve as resolve2 } from "path";
|
|
445
878
|
|
|
446
879
|
// src/generated/cli-http-v1.validators.js
|
|
447
880
|
var import_ucs2length = __toESM(require_ucs2length(), 1);
|
|
@@ -10533,8 +10966,9 @@ function validate43(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
10533
10966
|
}
|
|
10534
10967
|
validate43.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
10535
10968
|
var isDemoStatusResponse = validate44;
|
|
10536
|
-
var schema79 = { "type": "object", "properties": { "scenarioVersion": { "type": "number", "const": 1 }, "fictional": { "type": "boolean", "const": true }, "evaluation": { "type": "string", "const": "live" }, "runId": { "type": "string", "pattern": "^[a-zA-Z0-9]{1,64}$" }, "revision": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "stage": { "type": "string", "enum": ["ready", "checking", "blocked", "approved", "completed", "skipped", "expired"] }, "authorName": { "type": "string", "maxLength": 200 }, "email": { "type": "string", "enum": ["not_queued", "queued", "accepted", "failed", "suppressed"] }, "verdict": { "type": "string", "enum": ["block", "pass", "pending"] }, "reasonCode": { "type": "string", "maxLength": 100 }, "choice": { "type": "string", "enum": ["adhere", "supersede"] }, "reason": { "type": "string", "maxLength": 500 }, "approvedDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" } }, "required": ["scenarioVersion", "fictional", "evaluation", "runId", "revision", "stage", "authorName", "email"], "additionalProperties": false };
|
|
10969
|
+
var schema79 = { "type": "object", "properties": { "scenarioVersion": { "type": "number", "const": 1 }, "fictional": { "type": "boolean", "const": true }, "evaluation": { "type": "string", "const": "live" }, "runId": { "type": "string", "pattern": "^[a-zA-Z0-9]{1,64}$" }, "revision": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "stage": { "type": "string", "enum": ["ready", "checking", "blocked", "approved", "completed", "skipped", "expired"] }, "authorName": { "type": "string", "maxLength": 200 }, "story": { "type": "object", "properties": { "orgName": { "type": "string", "maxLength": 200 }, "recipient": { "type": "string", "format": "email", "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$" }, "decisionDate": { "type": "string", "maxLength": 100 } }, "required": ["orgName", "recipient", "decisionDate"], "additionalProperties": false }, "email": { "type": "string", "enum": ["not_queued", "queued", "accepted", "failed", "suppressed"] }, "verdict": { "type": "string", "enum": ["block", "pass", "pending"] }, "reasonCode": { "type": "string", "maxLength": 100 }, "choice": { "type": "string", "enum": ["adhere", "supersede"] }, "reason": { "type": "string", "maxLength": 500 }, "approvedDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" } }, "required": ["scenarioVersion", "fictional", "evaluation", "runId", "revision", "stage", "authorName", "story", "email"], "additionalProperties": false };
|
|
10537
10970
|
var func34 = Object.prototype.hasOwnProperty;
|
|
10971
|
+
var pattern12 = new RegExp("^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$", "u");
|
|
10538
10972
|
function validate44(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
10539
10973
|
;
|
|
10540
10974
|
let vErrors = null;
|
|
@@ -10550,7 +10984,7 @@ function validate44(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
10550
10984
|
if (errors === _errs0) {
|
|
10551
10985
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
10552
10986
|
let missing0;
|
|
10553
|
-
if (data.scenarioVersion === void 0 && (missing0 = "scenarioVersion") || data.fictional === void 0 && (missing0 = "fictional") || data.evaluation === void 0 && (missing0 = "evaluation") || data.runId === void 0 && (missing0 = "runId") || data.revision === void 0 && (missing0 = "revision") || data.stage === void 0 && (missing0 = "stage") || data.authorName === void 0 && (missing0 = "authorName") || data.email === void 0 && (missing0 = "email")) {
|
|
10987
|
+
if (data.scenarioVersion === void 0 && (missing0 = "scenarioVersion") || data.fictional === void 0 && (missing0 = "fictional") || data.evaluation === void 0 && (missing0 = "evaluation") || data.runId === void 0 && (missing0 = "runId") || data.revision === void 0 && (missing0 = "revision") || data.stage === void 0 && (missing0 = "stage") || data.authorName === void 0 && (missing0 = "authorName") || data.story === void 0 && (missing0 = "story") || data.email === void 0 && (missing0 = "email")) {
|
|
10554
10988
|
validate44.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/required", keyword: "required", params: { missingProperty: missing0 }, message: "must have required property '" + missing0 + "'" }];
|
|
10555
10989
|
return false;
|
|
10556
10990
|
} else {
|
|
@@ -10690,109 +11124,201 @@ function validate44(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
10690
11124
|
var valid1 = true;
|
|
10691
11125
|
}
|
|
10692
11126
|
if (valid1) {
|
|
10693
|
-
if (data.
|
|
10694
|
-
let data7 = data.
|
|
11127
|
+
if (data.story !== void 0) {
|
|
11128
|
+
let data7 = data.story;
|
|
10695
11129
|
const _errs17 = errors;
|
|
10696
|
-
if (
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
11130
|
+
if (errors === _errs17) {
|
|
11131
|
+
if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
|
|
11132
|
+
let missing1;
|
|
11133
|
+
if (data7.orgName === void 0 && (missing1 = "orgName") || data7.recipient === void 0 && (missing1 = "recipient") || data7.decisionDate === void 0 && (missing1 = "decisionDate")) {
|
|
11134
|
+
validate44.errors = [{ instancePath: instancePath + "/story", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/required", keyword: "required", params: { missingProperty: missing1 }, message: "must have required property '" + missing1 + "'" }];
|
|
11135
|
+
return false;
|
|
11136
|
+
} else {
|
|
11137
|
+
const _errs19 = errors;
|
|
11138
|
+
for (const key1 in data7) {
|
|
11139
|
+
if (!(key1 === "orgName" || key1 === "recipient" || key1 === "decisionDate")) {
|
|
11140
|
+
validate44.errors = [{ instancePath: instancePath + "/story", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key1 }, message: "must NOT have additional properties" }];
|
|
11141
|
+
return false;
|
|
11142
|
+
break;
|
|
11143
|
+
}
|
|
11144
|
+
}
|
|
11145
|
+
if (_errs19 === errors) {
|
|
11146
|
+
if (data7.orgName !== void 0) {
|
|
11147
|
+
let data8 = data7.orgName;
|
|
11148
|
+
const _errs20 = errors;
|
|
11149
|
+
if (errors === _errs20) {
|
|
11150
|
+
if (typeof data8 === "string") {
|
|
11151
|
+
if (func1(data8) > 200) {
|
|
11152
|
+
validate44.errors = [{ instancePath: instancePath + "/story/orgName", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/properties/orgName/maxLength", keyword: "maxLength", params: { limit: 200 }, message: "must NOT have more than 200 characters" }];
|
|
11153
|
+
return false;
|
|
11154
|
+
}
|
|
11155
|
+
} else {
|
|
11156
|
+
validate44.errors = [{ instancePath: instancePath + "/story/orgName", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/properties/orgName/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11157
|
+
return false;
|
|
11158
|
+
}
|
|
11159
|
+
}
|
|
11160
|
+
var valid2 = _errs20 === errors;
|
|
11161
|
+
} else {
|
|
11162
|
+
var valid2 = true;
|
|
11163
|
+
}
|
|
11164
|
+
if (valid2) {
|
|
11165
|
+
if (data7.recipient !== void 0) {
|
|
11166
|
+
let data9 = data7.recipient;
|
|
11167
|
+
const _errs22 = errors;
|
|
11168
|
+
if (errors === _errs22) {
|
|
11169
|
+
if (errors === _errs22) {
|
|
11170
|
+
if (typeof data9 === "string") {
|
|
11171
|
+
if (!pattern12.test(data9)) {
|
|
11172
|
+
validate44.errors = [{ instancePath: instancePath + "/story/recipient", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/properties/recipient/pattern", keyword: "pattern", params: { pattern: "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$" }, message: `must match pattern "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"` }];
|
|
11173
|
+
return false;
|
|
11174
|
+
}
|
|
11175
|
+
} else {
|
|
11176
|
+
validate44.errors = [{ instancePath: instancePath + "/story/recipient", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/properties/recipient/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11177
|
+
return false;
|
|
11178
|
+
}
|
|
11179
|
+
}
|
|
11180
|
+
}
|
|
11181
|
+
var valid2 = _errs22 === errors;
|
|
11182
|
+
} else {
|
|
11183
|
+
var valid2 = true;
|
|
11184
|
+
}
|
|
11185
|
+
if (valid2) {
|
|
11186
|
+
if (data7.decisionDate !== void 0) {
|
|
11187
|
+
let data10 = data7.decisionDate;
|
|
11188
|
+
const _errs24 = errors;
|
|
11189
|
+
if (errors === _errs24) {
|
|
11190
|
+
if (typeof data10 === "string") {
|
|
11191
|
+
if (func1(data10) > 100) {
|
|
11192
|
+
validate44.errors = [{ instancePath: instancePath + "/story/decisionDate", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/properties/decisionDate/maxLength", keyword: "maxLength", params: { limit: 100 }, message: "must NOT have more than 100 characters" }];
|
|
11193
|
+
return false;
|
|
11194
|
+
}
|
|
11195
|
+
} else {
|
|
11196
|
+
validate44.errors = [{ instancePath: instancePath + "/story/decisionDate", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/properties/decisionDate/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11197
|
+
return false;
|
|
11198
|
+
}
|
|
11199
|
+
}
|
|
11200
|
+
var valid2 = _errs24 === errors;
|
|
11201
|
+
} else {
|
|
11202
|
+
var valid2 = true;
|
|
11203
|
+
}
|
|
11204
|
+
}
|
|
11205
|
+
}
|
|
11206
|
+
}
|
|
11207
|
+
}
|
|
11208
|
+
} else {
|
|
11209
|
+
validate44.errors = [{ instancePath: instancePath + "/story", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/story/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
11210
|
+
return false;
|
|
11211
|
+
}
|
|
10703
11212
|
}
|
|
10704
11213
|
var valid1 = _errs17 === errors;
|
|
10705
11214
|
} else {
|
|
10706
11215
|
var valid1 = true;
|
|
10707
11216
|
}
|
|
10708
11217
|
if (valid1) {
|
|
10709
|
-
if (data.
|
|
10710
|
-
let
|
|
10711
|
-
const
|
|
10712
|
-
if (typeof
|
|
10713
|
-
validate44.errors = [{ instancePath: instancePath + "/
|
|
11218
|
+
if (data.email !== void 0) {
|
|
11219
|
+
let data11 = data.email;
|
|
11220
|
+
const _errs26 = errors;
|
|
11221
|
+
if (typeof data11 !== "string") {
|
|
11222
|
+
validate44.errors = [{ instancePath: instancePath + "/email", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/email/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
10714
11223
|
return false;
|
|
10715
11224
|
}
|
|
10716
|
-
if (!(
|
|
10717
|
-
validate44.errors = [{ instancePath: instancePath + "/
|
|
11225
|
+
if (!(data11 === "not_queued" || data11 === "queued" || data11 === "accepted" || data11 === "failed" || data11 === "suppressed")) {
|
|
11226
|
+
validate44.errors = [{ instancePath: instancePath + "/email", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/email/enum", keyword: "enum", params: { allowedValues: schema79.properties.email.enum }, message: "must be equal to one of the allowed values" }];
|
|
10718
11227
|
return false;
|
|
10719
11228
|
}
|
|
10720
|
-
var valid1 =
|
|
11229
|
+
var valid1 = _errs26 === errors;
|
|
10721
11230
|
} else {
|
|
10722
11231
|
var valid1 = true;
|
|
10723
11232
|
}
|
|
10724
11233
|
if (valid1) {
|
|
10725
|
-
if (data.
|
|
10726
|
-
let
|
|
10727
|
-
const
|
|
10728
|
-
if (
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
validate44.errors = [{ instancePath: instancePath + "/reasonCode", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/reasonCode/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
10736
|
-
return false;
|
|
10737
|
-
}
|
|
11234
|
+
if (data.verdict !== void 0) {
|
|
11235
|
+
let data12 = data.verdict;
|
|
11236
|
+
const _errs28 = errors;
|
|
11237
|
+
if (typeof data12 !== "string") {
|
|
11238
|
+
validate44.errors = [{ instancePath: instancePath + "/verdict", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/verdict/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11239
|
+
return false;
|
|
11240
|
+
}
|
|
11241
|
+
if (!(data12 === "block" || data12 === "pass" || data12 === "pending")) {
|
|
11242
|
+
validate44.errors = [{ instancePath: instancePath + "/verdict", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/verdict/enum", keyword: "enum", params: { allowedValues: schema79.properties.verdict.enum }, message: "must be equal to one of the allowed values" }];
|
|
11243
|
+
return false;
|
|
10738
11244
|
}
|
|
10739
|
-
var valid1 =
|
|
11245
|
+
var valid1 = _errs28 === errors;
|
|
10740
11246
|
} else {
|
|
10741
11247
|
var valid1 = true;
|
|
10742
11248
|
}
|
|
10743
11249
|
if (valid1) {
|
|
10744
|
-
if (data.
|
|
10745
|
-
let
|
|
10746
|
-
const
|
|
10747
|
-
if (
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
11250
|
+
if (data.reasonCode !== void 0) {
|
|
11251
|
+
let data13 = data.reasonCode;
|
|
11252
|
+
const _errs30 = errors;
|
|
11253
|
+
if (errors === _errs30) {
|
|
11254
|
+
if (typeof data13 === "string") {
|
|
11255
|
+
if (func1(data13) > 100) {
|
|
11256
|
+
validate44.errors = [{ instancePath: instancePath + "/reasonCode", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/reasonCode/maxLength", keyword: "maxLength", params: { limit: 100 }, message: "must NOT have more than 100 characters" }];
|
|
11257
|
+
return false;
|
|
11258
|
+
}
|
|
11259
|
+
} else {
|
|
11260
|
+
validate44.errors = [{ instancePath: instancePath + "/reasonCode", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/reasonCode/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11261
|
+
return false;
|
|
11262
|
+
}
|
|
10754
11263
|
}
|
|
10755
|
-
var valid1 =
|
|
11264
|
+
var valid1 = _errs30 === errors;
|
|
10756
11265
|
} else {
|
|
10757
11266
|
var valid1 = true;
|
|
10758
11267
|
}
|
|
10759
11268
|
if (valid1) {
|
|
10760
|
-
if (data.
|
|
10761
|
-
let
|
|
10762
|
-
const
|
|
10763
|
-
if (
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
validate44.errors = [{ instancePath: instancePath + "/reason", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/reason/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
10771
|
-
return false;
|
|
10772
|
-
}
|
|
11269
|
+
if (data.choice !== void 0) {
|
|
11270
|
+
let data14 = data.choice;
|
|
11271
|
+
const _errs32 = errors;
|
|
11272
|
+
if (typeof data14 !== "string") {
|
|
11273
|
+
validate44.errors = [{ instancePath: instancePath + "/choice", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/choice/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11274
|
+
return false;
|
|
11275
|
+
}
|
|
11276
|
+
if (!(data14 === "adhere" || data14 === "supersede")) {
|
|
11277
|
+
validate44.errors = [{ instancePath: instancePath + "/choice", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/choice/enum", keyword: "enum", params: { allowedValues: schema79.properties.choice.enum }, message: "must be equal to one of the allowed values" }];
|
|
11278
|
+
return false;
|
|
10773
11279
|
}
|
|
10774
|
-
var valid1 =
|
|
11280
|
+
var valid1 = _errs32 === errors;
|
|
10775
11281
|
} else {
|
|
10776
11282
|
var valid1 = true;
|
|
10777
11283
|
}
|
|
10778
11284
|
if (valid1) {
|
|
10779
|
-
if (data.
|
|
10780
|
-
let
|
|
10781
|
-
const
|
|
10782
|
-
if (errors ===
|
|
10783
|
-
if (typeof
|
|
10784
|
-
if (
|
|
10785
|
-
validate44.errors = [{ instancePath: instancePath + "/
|
|
11285
|
+
if (data.reason !== void 0) {
|
|
11286
|
+
let data15 = data.reason;
|
|
11287
|
+
const _errs34 = errors;
|
|
11288
|
+
if (errors === _errs34) {
|
|
11289
|
+
if (typeof data15 === "string") {
|
|
11290
|
+
if (func1(data15) > 500) {
|
|
11291
|
+
validate44.errors = [{ instancePath: instancePath + "/reason", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/reason/maxLength", keyword: "maxLength", params: { limit: 500 }, message: "must NOT have more than 500 characters" }];
|
|
11292
|
+
return false;
|
|
11293
|
+
}
|
|
11294
|
+
} else {
|
|
11295
|
+
validate44.errors = [{ instancePath: instancePath + "/reason", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/reason/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
11296
|
+
return false;
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
11299
|
+
var valid1 = _errs34 === errors;
|
|
11300
|
+
} else {
|
|
11301
|
+
var valid1 = true;
|
|
11302
|
+
}
|
|
11303
|
+
if (valid1) {
|
|
11304
|
+
if (data.approvedDigest !== void 0) {
|
|
11305
|
+
let data16 = data.approvedDigest;
|
|
11306
|
+
const _errs36 = errors;
|
|
11307
|
+
if (errors === _errs36) {
|
|
11308
|
+
if (typeof data16 === "string") {
|
|
11309
|
+
if (!pattern5.test(data16)) {
|
|
11310
|
+
validate44.errors = [{ instancePath: instancePath + "/approvedDigest", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/approvedDigest/pattern", keyword: "pattern", params: { pattern: "^[a-f0-9]{64}$" }, message: 'must match pattern "^[a-f0-9]{64}$"' }];
|
|
11311
|
+
return false;
|
|
11312
|
+
}
|
|
11313
|
+
} else {
|
|
11314
|
+
validate44.errors = [{ instancePath: instancePath + "/approvedDigest", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/approvedDigest/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
10786
11315
|
return false;
|
|
10787
11316
|
}
|
|
10788
|
-
} else {
|
|
10789
|
-
validate44.errors = [{ instancePath: instancePath + "/approvedDigest", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/DemoStatusResponse/properties/approvedDigest/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
10790
|
-
return false;
|
|
10791
11317
|
}
|
|
11318
|
+
var valid1 = _errs36 === errors;
|
|
11319
|
+
} else {
|
|
11320
|
+
var valid1 = true;
|
|
10792
11321
|
}
|
|
10793
|
-
var valid1 = _errs27 === errors;
|
|
10794
|
-
} else {
|
|
10795
|
-
var valid1 = true;
|
|
10796
11322
|
}
|
|
10797
11323
|
}
|
|
10798
11324
|
}
|
|
@@ -11684,7 +12210,7 @@ function validate48(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
11684
12210
|
}
|
|
11685
12211
|
validate48.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
11686
12212
|
var schema89 = { "anyOf": [{ "type": "object", "properties": { "protocolVersion": { "type": "integer", "minimum": 1, "maximum": 2 }, "status": { "type": "string", "const": "empty" }, "hasMore": { "type": "boolean", "const": false } }, "required": ["protocolVersion", "status", "hasMore"], "additionalProperties": {} }, { "type": "object", "properties": { "protocolVersion": { "type": "integer", "minimum": 1, "maximum": 2 }, "status": { "type": "string", "const": "leased" }, "events": { "minItems": 1, "maxItems": 40, "type": "array", "items": { "type": "object", "properties": { "eventId": { "type": "string", "minLength": 1, "maxLength": 128 }, "leaseVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "shortId": { "type": "string", "pattern": "^[0-9a-f]{8}$" }, "decisionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "intent": { "type": "string" }, "webUrl": { "type": "string" }, "kind": { "type": "string", "enum": ["confirm_prompt", "publish_prompt"] } }, "required": ["eventId", "leaseVersion", "shortId", "intent", "webUrl"], "additionalProperties": {} } }, "hasMore": { "type": "boolean" } }, "required": ["protocolVersion", "status", "events", "hasMore"], "additionalProperties": {} }, { "type": "object", "properties": { "protocolVersion": { "type": "integer", "minimum": 1, "maximum": 2 }, "status": { "type": "string", "const": "unavailable" }, "reason": { "type": "string", "const": "organization_unbound" } }, "required": ["protocolVersion", "status", "reason"], "additionalProperties": {} }], "x-primitive-runtime-refinements": ["feedback_response_version_negotiation", "feedback_publish_prompt_decision_id", "unique_feedback_event_ids"] };
|
|
11687
|
-
var
|
|
12213
|
+
var pattern14 = new RegExp("^[0-9a-f]{8}$", "u");
|
|
11688
12214
|
function validate49(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
11689
12215
|
;
|
|
11690
12216
|
let vErrors = null;
|
|
@@ -12023,7 +12549,7 @@ function validate49(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
12023
12549
|
const _errs27 = errors;
|
|
12024
12550
|
if (errors === _errs27) {
|
|
12025
12551
|
if (typeof data9 === "string") {
|
|
12026
|
-
if (!
|
|
12552
|
+
if (!pattern14.test(data9)) {
|
|
12027
12553
|
const err24 = { instancePath: instancePath + "/events/" + i0 + "/shortId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/FeedbackLeaseResponse/anyOf/1/properties/events/items/properties/shortId/pattern", keyword: "pattern", params: { pattern: "^[0-9a-f]{8}$" }, message: 'must match pattern "^[0-9a-f]{8}$"' };
|
|
12028
12554
|
if (vErrors === null) {
|
|
12029
12555
|
vErrors = [err24];
|
|
@@ -13079,8 +13605,8 @@ function validate51(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
13079
13605
|
return errors === 0;
|
|
13080
13606
|
}
|
|
13081
13607
|
validate51.evaluated = { "dynamicProps": true, "dynamicItems": false };
|
|
13082
|
-
var
|
|
13083
|
-
var
|
|
13608
|
+
var pattern15 = new RegExp("^[A-Za-z0-9]{1,128}$", "u");
|
|
13609
|
+
var pattern16 = new RegExp("^https:\\/\\/github\\.com\\/apps\\/primitive(?:-staging)?\\/installations\\/new\\?state=[0-9a-f]{64}$", "u");
|
|
13084
13610
|
function validate52(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
13085
13611
|
;
|
|
13086
13612
|
let vErrors = null;
|
|
@@ -13162,7 +13688,7 @@ function validate52(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
13162
13688
|
const _errs9 = errors;
|
|
13163
13689
|
if (errors === _errs9) {
|
|
13164
13690
|
if (typeof data3 === "string") {
|
|
13165
|
-
if (!
|
|
13691
|
+
if (!pattern15.test(data3)) {
|
|
13166
13692
|
validate52.errors = [{ instancePath: instancePath + "/intentId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartResponse/properties/intentId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9]{1,128}$" }, message: 'must match pattern "^[A-Za-z0-9]{1,128}$"' }];
|
|
13167
13693
|
return false;
|
|
13168
13694
|
}
|
|
@@ -13181,7 +13707,7 @@ function validate52(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
13181
13707
|
const _errs11 = errors;
|
|
13182
13708
|
if (errors === _errs11) {
|
|
13183
13709
|
if (typeof data4 === "string") {
|
|
13184
|
-
if (!
|
|
13710
|
+
if (!pattern16.test(data4)) {
|
|
13185
13711
|
validate52.errors = [{ instancePath: instancePath + "/browserUrl", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartResponse/properties/browserUrl/pattern", keyword: "pattern", params: { pattern: "^https:\\/\\/github\\.com\\/apps\\/primitive(?:-staging)?\\/installations\\/new\\?state=[0-9a-f]{64}$" }, message: 'must match pattern "^https:\\/\\/github\\.com\\/apps\\/primitive(?:-staging)?\\/installations\\/new\\?state=[0-9a-f]{64}$"' }];
|
|
13186
13712
|
return false;
|
|
13187
13713
|
}
|
|
@@ -13589,7 +14115,7 @@ function validate54(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
13589
14115
|
const _errs3 = errors;
|
|
13590
14116
|
if (errors === _errs3) {
|
|
13591
14117
|
if (typeof data0 === "string") {
|
|
13592
|
-
if (!
|
|
14118
|
+
if (!pattern15.test(data0)) {
|
|
13593
14119
|
validate54.errors = [{ instancePath: instancePath + "/intentId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStatusRequest/properties/intentId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9]{1,128}$" }, message: 'must match pattern "^[A-Za-z0-9]{1,128}$"' }];
|
|
13594
14120
|
return false;
|
|
13595
14121
|
}
|
|
@@ -15161,7 +15687,7 @@ function validate55(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
15161
15687
|
}
|
|
15162
15688
|
validate55.evaluated = { "dynamicProps": true, "dynamicItems": false };
|
|
15163
15689
|
var schema103 = { "type": "object", "properties": { "batch": { "type": "array", "items": { "anyOf": [{ "type": "object", "properties": { "moveId": { "type": "string" }, "capturedAt": { "type": "number" }, "sessionId": { "type": "string" }, "invocationId": { "type": "string" }, "eventType": { "type": "string" }, "payload": {}, "env": {}, "repositoryContext": { "oneOf": [{ "type": "object", "properties": { "kind": { "type": "string", "const": "repository_bound" }, "repoSyncId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["kind", "repoSyncId"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "type": "string", "const": "non_repository" } }, "required": ["kind"], "additionalProperties": false }] }, "capturedOrganizationId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "decisionLifecycleProtocolVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "producer": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "toolOutcome": { "type": "string", "enum": ["succeeded", "returned", "failed", "interrupted", "prevented", "unknown"] }, "envelopeVersion": { "type": "number", "const": 4 } }, "required": ["moveId", "capturedAt", "sessionId", "eventType", "capturedOrganizationId", "captureAuthorityKind", "decisionLifecycleProtocolVersion", "envelopeVersion"], "additionalProperties": {} }, { "type": "object", "properties": { "moveId": { "type": "string" }, "capturedAt": { "type": "number" }, "sessionId": { "type": "string" }, "invocationId": { "type": "string" }, "eventType": { "type": "string" }, "payload": {}, "env": {}, "repositoryContext": { "oneOf": [{ "type": "object", "properties": { "kind": { "type": "string", "const": "repository_bound" }, "repoSyncId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["kind", "repoSyncId"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "type": "string", "const": "non_repository" } }, "required": ["kind"], "additionalProperties": false }] }, "capturedOrganizationId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "decisionLifecycleProtocolVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "producer": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "toolOutcome": { "type": "string", "enum": ["succeeded", "returned", "failed", "interrupted", "prevented", "unknown"] }, "envelopeVersion": { "type": "number", "exclusiveMaximum": 4 } }, "required": ["moveId", "capturedAt", "sessionId", "eventType"], "additionalProperties": {} }] } } }, "required": ["batch"], "additionalProperties": {} };
|
|
15164
|
-
var
|
|
15690
|
+
var pattern18 = new RegExp("^[A-Za-z0-9_-]+$", "u");
|
|
15165
15691
|
function validate56(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
15166
15692
|
;
|
|
15167
15693
|
let vErrors = null;
|
|
@@ -15522,7 +16048,7 @@ function validate56(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
15522
16048
|
}
|
|
15523
16049
|
errors++;
|
|
15524
16050
|
} else {
|
|
15525
|
-
if (!
|
|
16051
|
+
if (!pattern18.test(data11)) {
|
|
15526
16052
|
const err22 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]+$" }, message: 'must match pattern "^[A-Za-z0-9_-]+$"' };
|
|
15527
16053
|
if (vErrors === null) {
|
|
15528
16054
|
vErrors = [err22];
|
|
@@ -16047,7 +16573,7 @@ function validate56(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16047
16573
|
}
|
|
16048
16574
|
errors++;
|
|
16049
16575
|
} else {
|
|
16050
|
-
if (!
|
|
16576
|
+
if (!pattern18.test(data26)) {
|
|
16051
16577
|
const err58 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]+$" }, message: 'must match pattern "^[A-Za-z0-9_-]+$"' };
|
|
16052
16578
|
if (vErrors === null) {
|
|
16053
16579
|
vErrors = [err58];
|
|
@@ -16290,10 +16816,10 @@ function validate56(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16290
16816
|
}
|
|
16291
16817
|
validate56.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
16292
16818
|
var schema105 = { "type": "object", "properties": { "protocolVersion": { "type": "number", "const": 3 }, "agent": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "sessionId": { "type": "string", "pattern": "^[A-Za-z0-9._:-]{1,128}$" }, "invocationId": { "type": "string", "pattern": "^[A-Za-z0-9._:-]{1,128}$" }, "repoSyncId": { "type": "string", "pattern": "^[A-Za-z0-9]{1,64}$" }, "paths": { "maxItems": 32, "type": "array", "items": { "type": "string" } }, "coverage": { "type": "string", "enum": ["complete", "unverified"] }, "branch": { "type": "string", "maxLength": 255, "pattern": "^(?!@?$)(?!\\/)(?!.*\\/$)(?!.*\\/\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*(?:^|\\/)[^/]*\\.lock(?:\\/|$))(?!.*\\.\\.)(?!.*@\\{)(?!.*[~^:?*\\\\]).+$" }, "clientMode": { "type": "string", "enum": ["block", "warn"] }, "clientVersion": { "type": "string", "maxLength": 32, "pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]*$" }, "proposal": { "type": "string" } }, "required": ["protocolVersion", "agent", "sessionId", "invocationId", "repoSyncId", "paths", "coverage", "proposal"], "additionalProperties": false, "x-primitive-runtime-refinements": ["canonical_repository_paths", "unique_repository_paths", "complete_coverage_requires_path", "proposal_utf8_max_6144", "degrade_invalid_rollout_fields", "degrade_invalid_branch"] };
|
|
16293
|
-
var
|
|
16294
|
-
var
|
|
16295
|
-
var
|
|
16296
|
-
var
|
|
16819
|
+
var pattern20 = new RegExp("^[A-Za-z0-9._:-]{1,128}$", "u");
|
|
16820
|
+
var pattern22 = new RegExp("^[A-Za-z0-9]{1,64}$", "u");
|
|
16821
|
+
var pattern23 = new RegExp("^(?!@?$)(?!\\/)(?!.*\\/$)(?!.*\\/\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*(?:^|\\/)[^/]*\\.lock(?:\\/|$))(?!.*\\.\\.)(?!.*@\\{)(?!.*[~^:?*\\\\]).+$", "u");
|
|
16822
|
+
var pattern24 = new RegExp("^[A-Za-z0-9][A-Za-z0-9._+-]*$", "u");
|
|
16297
16823
|
function validate57(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
16298
16824
|
;
|
|
16299
16825
|
let vErrors = null;
|
|
@@ -16359,7 +16885,7 @@ function validate57(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16359
16885
|
const _errs8 = errors;
|
|
16360
16886
|
if (errors === _errs8) {
|
|
16361
16887
|
if (typeof data2 === "string") {
|
|
16362
|
-
if (!
|
|
16888
|
+
if (!pattern20.test(data2)) {
|
|
16363
16889
|
validate57.errors = [{ instancePath: instancePath + "/sessionId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/sessionId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9._:-]{1,128}$" }, message: 'must match pattern "^[A-Za-z0-9._:-]{1,128}$"' }];
|
|
16364
16890
|
return false;
|
|
16365
16891
|
}
|
|
@@ -16378,7 +16904,7 @@ function validate57(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16378
16904
|
const _errs10 = errors;
|
|
16379
16905
|
if (errors === _errs10) {
|
|
16380
16906
|
if (typeof data3 === "string") {
|
|
16381
|
-
if (!
|
|
16907
|
+
if (!pattern20.test(data3)) {
|
|
16382
16908
|
validate57.errors = [{ instancePath: instancePath + "/invocationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/invocationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9._:-]{1,128}$" }, message: 'must match pattern "^[A-Za-z0-9._:-]{1,128}$"' }];
|
|
16383
16909
|
return false;
|
|
16384
16910
|
}
|
|
@@ -16397,7 +16923,7 @@ function validate57(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16397
16923
|
const _errs12 = errors;
|
|
16398
16924
|
if (errors === _errs12) {
|
|
16399
16925
|
if (typeof data4 === "string") {
|
|
16400
|
-
if (!
|
|
16926
|
+
if (!pattern22.test(data4)) {
|
|
16401
16927
|
validate57.errors = [{ instancePath: instancePath + "/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/repoSyncId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9]{1,64}$" }, message: 'must match pattern "^[A-Za-z0-9]{1,64}$"' }];
|
|
16402
16928
|
return false;
|
|
16403
16929
|
}
|
|
@@ -16469,7 +16995,7 @@ function validate57(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16469
16995
|
validate57.errors = [{ instancePath: instancePath + "/branch", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/branch/maxLength", keyword: "maxLength", params: { limit: 255 }, message: "must NOT have more than 255 characters" }];
|
|
16470
16996
|
return false;
|
|
16471
16997
|
} else {
|
|
16472
|
-
if (!
|
|
16998
|
+
if (!pattern23.test(data8)) {
|
|
16473
16999
|
validate57.errors = [{ instancePath: instancePath + "/branch", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/branch/pattern", keyword: "pattern", params: { pattern: "^(?!@?$)(?!\\/)(?!.*\\/$)(?!.*\\/\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*(?:^|\\/)[^/]*\\.lock(?:\\/|$))(?!.*\\.\\.)(?!.*@\\{)(?!.*[~^:?*\\\\]).+$" }, message: 'must match pattern "^(?!@?$)(?!\\/)(?!.*\\/$)(?!.*\\/\\/)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*(?:^|\\/)[^/]*\\.lock(?:\\/|$))(?!.*\\.\\.)(?!.*@\\{)(?!.*[~^:?*\\\\]).+$"' }];
|
|
16474
17000
|
return false;
|
|
16475
17001
|
}
|
|
@@ -16509,7 +17035,7 @@ function validate57(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16509
17035
|
validate57.errors = [{ instancePath: instancePath + "/clientVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/clientVersion/maxLength", keyword: "maxLength", params: { limit: 32 }, message: "must NOT have more than 32 characters" }];
|
|
16510
17036
|
return false;
|
|
16511
17037
|
} else {
|
|
16512
|
-
if (!
|
|
17038
|
+
if (!pattern24.test(data10)) {
|
|
16513
17039
|
validate57.errors = [{ instancePath: instancePath + "/clientVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightRequestV3/properties/clientVersion/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9][A-Za-z0-9._+-]*$" }, message: 'must match pattern "^[A-Za-z0-9][A-Za-z0-9._+-]*$"' }];
|
|
16514
17040
|
return false;
|
|
16515
17041
|
}
|
|
@@ -16596,7 +17122,7 @@ function validate58(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16596
17122
|
const _errs5 = errors;
|
|
16597
17123
|
if (errors === _errs5) {
|
|
16598
17124
|
if (typeof data1 === "string") {
|
|
16599
|
-
if (!
|
|
17125
|
+
if (!pattern20.test(data1)) {
|
|
16600
17126
|
validate58.errors = [{ instancePath: instancePath + "/checkId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PreflightResponseV3/properties/checkId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9._:-]{1,128}$" }, message: 'must match pattern "^[A-Za-z0-9._:-]{1,128}$"' }];
|
|
16601
17127
|
return false;
|
|
16602
17128
|
}
|
|
@@ -16893,8 +17419,8 @@ function validate58(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16893
17419
|
return errors === 0;
|
|
16894
17420
|
}
|
|
16895
17421
|
validate58.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
16896
|
-
var
|
|
16897
|
-
var
|
|
17422
|
+
var pattern26 = new RegExp("^[A-Za-z0-9._-]{1,128}$", "u");
|
|
17423
|
+
var pattern27 = new RegExp("^pci_[A-Za-z0-9_-]{43}$", "u");
|
|
16898
17424
|
function validate59(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
16899
17425
|
;
|
|
16900
17426
|
let vErrors = null;
|
|
@@ -16919,7 +17445,7 @@ function validate59(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16919
17445
|
const _errs3 = errors;
|
|
16920
17446
|
if (errors === _errs3) {
|
|
16921
17447
|
if (typeof data0 === "string") {
|
|
16922
|
-
if (!
|
|
17448
|
+
if (!pattern26.test(data0)) {
|
|
16923
17449
|
validate59.errors = [{ instancePath: instancePath + "/sessionId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PresenceHeartbeatRequest/properties/sessionId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9._-]{1,128}$" }, message: 'must match pattern "^[A-Za-z0-9._-]{1,128}$"' }];
|
|
16924
17450
|
return false;
|
|
16925
17451
|
}
|
|
@@ -16938,7 +17464,7 @@ function validate59(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
16938
17464
|
const _errs5 = errors;
|
|
16939
17465
|
if (errors === _errs5) {
|
|
16940
17466
|
if (typeof data1 === "string") {
|
|
16941
|
-
if (!
|
|
17467
|
+
if (!pattern27.test(data1)) {
|
|
16942
17468
|
validate59.errors = [{ instancePath: instancePath + "/clientInstanceId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/PresenceHeartbeatRequest/properties/clientInstanceId/pattern", keyword: "pattern", params: { pattern: "^pci_[A-Za-z0-9_-]{43}$" }, message: 'must match pattern "^pci_[A-Za-z0-9_-]{43}$"' }];
|
|
16943
17469
|
return false;
|
|
16944
17470
|
}
|
|
@@ -17601,7 +18127,7 @@ function validate62(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17601
18127
|
return errors === 0;
|
|
17602
18128
|
}
|
|
17603
18129
|
validate62.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
17604
|
-
var
|
|
18130
|
+
var pattern28 = new RegExp("^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?\\/[A-Za-z0-9._-]{1,100}$", "u");
|
|
17605
18131
|
function validate63(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
17606
18132
|
;
|
|
17607
18133
|
let vErrors = null;
|
|
@@ -17635,7 +18161,7 @@ function validate63(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17635
18161
|
const _errs3 = errors;
|
|
17636
18162
|
if (errors === _errs3) {
|
|
17637
18163
|
if (typeof data0 === "string") {
|
|
17638
|
-
if (!
|
|
18164
|
+
if (!pattern28.test(data0)) {
|
|
17639
18165
|
validate63.errors = [{ instancePath: instancePath + "/repositoryFullName", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/RepositoryBindRequest/properties/repositoryFullName/pattern", keyword: "pattern", params: { pattern: "^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?\\/[A-Za-z0-9._-]{1,100}$" }, message: 'must match pattern "^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?\\/[A-Za-z0-9._-]{1,100}$"' }];
|
|
17640
18166
|
return false;
|
|
17641
18167
|
}
|
|
@@ -17700,7 +18226,7 @@ function validate64(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17700
18226
|
return errors === 0;
|
|
17701
18227
|
}
|
|
17702
18228
|
validate64.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
17703
|
-
var
|
|
18229
|
+
var pattern30 = new RegExp("^api_key_[A-Za-z0-9_-]+$", "u");
|
|
17704
18230
|
function validate65(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
17705
18231
|
;
|
|
17706
18232
|
let vErrors = null;
|
|
@@ -17786,7 +18312,7 @@ function validate65(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17786
18312
|
validate65.errors = [{ instancePath: instancePath + "/after", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/after/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
|
|
17787
18313
|
return false;
|
|
17788
18314
|
} else {
|
|
17789
|
-
if (!
|
|
18315
|
+
if (!pattern30.test(data2)) {
|
|
17790
18316
|
validate65.errors = [{ instancePath: instancePath + "/after", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListRequest/properties/after/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
|
|
17791
18317
|
return false;
|
|
17792
18318
|
}
|
|
@@ -17814,9 +18340,9 @@ function validate65(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17814
18340
|
return errors === 0;
|
|
17815
18341
|
}
|
|
17816
18342
|
validate65.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
17817
|
-
var
|
|
17818
|
-
var
|
|
17819
|
-
var
|
|
18343
|
+
var pattern32 = new RegExp("^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$", "u");
|
|
18344
|
+
var pattern33 = new RegExp("^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$", "u");
|
|
18345
|
+
var pattern34 = new RegExp("^[\\x21-\\x7e]+$", "u");
|
|
17820
18346
|
function validate66(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
17821
18347
|
;
|
|
17822
18348
|
let vErrors = null;
|
|
@@ -17888,7 +18414,7 @@ function validate66(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17888
18414
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/id/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
|
|
17889
18415
|
return false;
|
|
17890
18416
|
} else {
|
|
17891
|
-
if (!
|
|
18417
|
+
if (!pattern30.test(data2)) {
|
|
17892
18418
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/id/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
|
|
17893
18419
|
return false;
|
|
17894
18420
|
}
|
|
@@ -17917,7 +18443,7 @@ function validate66(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17917
18443
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
17918
18444
|
return false;
|
|
17919
18445
|
} else {
|
|
17920
|
-
if (!
|
|
18446
|
+
if (!pattern32.test(data3)) {
|
|
17921
18447
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
|
|
17922
18448
|
return false;
|
|
17923
18449
|
}
|
|
@@ -17946,7 +18472,7 @@ function validate66(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17946
18472
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/obfuscatedValue/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
17947
18473
|
return false;
|
|
17948
18474
|
} else {
|
|
17949
|
-
if (!
|
|
18475
|
+
if (!pattern33.test(data4)) {
|
|
17950
18476
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/obfuscatedValue/pattern", keyword: "pattern", params: { pattern: "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$" }, message: 'must match pattern "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$"' }];
|
|
17951
18477
|
return false;
|
|
17952
18478
|
}
|
|
@@ -17986,7 +18512,7 @@ function validate66(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
17986
18512
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions/" + i1, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/items/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
17987
18513
|
return false;
|
|
17988
18514
|
} else {
|
|
17989
|
-
if (!
|
|
18515
|
+
if (!pattern34.test(data6)) {
|
|
17990
18516
|
validate66.errors = [{ instancePath: instancePath + "/apiKeys/" + i0 + "/permissions/" + i1, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/apiKeys/items/properties/permissions/items/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e]+$" }, message: 'must match pattern "^[\\x21-\\x7e]+$"' }];
|
|
17991
18517
|
return false;
|
|
17992
18518
|
}
|
|
@@ -18272,7 +18798,7 @@ function validate66(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18272
18798
|
}
|
|
18273
18799
|
errors++;
|
|
18274
18800
|
} else {
|
|
18275
|
-
if (!
|
|
18801
|
+
if (!pattern30.test(data11)) {
|
|
18276
18802
|
const err12 = { instancePath: instancePath + "/nextCursor", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyListResponse/properties/nextCursor/anyOf/0/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' };
|
|
18277
18803
|
if (vErrors === null) {
|
|
18278
18804
|
vErrors = [err12];
|
|
@@ -18384,7 +18910,7 @@ function validate67(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18384
18910
|
validate67.errors = [{ instancePath: instancePath + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/id/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
|
|
18385
18911
|
return false;
|
|
18386
18912
|
} else {
|
|
18387
|
-
if (!
|
|
18913
|
+
if (!pattern30.test(data0)) {
|
|
18388
18914
|
validate67.errors = [{ instancePath: instancePath + "/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/id/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
|
|
18389
18915
|
return false;
|
|
18390
18916
|
}
|
|
@@ -18413,7 +18939,7 @@ function validate67(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18413
18939
|
validate67.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
18414
18940
|
return false;
|
|
18415
18941
|
} else {
|
|
18416
|
-
if (!
|
|
18942
|
+
if (!pattern32.test(data1)) {
|
|
18417
18943
|
validate67.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
|
|
18418
18944
|
return false;
|
|
18419
18945
|
}
|
|
@@ -18442,7 +18968,7 @@ function validate67(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18442
18968
|
validate67.errors = [{ instancePath: instancePath + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/obfuscatedValue/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
18443
18969
|
return false;
|
|
18444
18970
|
} else {
|
|
18445
|
-
if (!
|
|
18971
|
+
if (!pattern33.test(data2)) {
|
|
18446
18972
|
validate67.errors = [{ instancePath: instancePath + "/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/obfuscatedValue/pattern", keyword: "pattern", params: { pattern: "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$" }, message: 'must match pattern "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$"' }];
|
|
18447
18973
|
return false;
|
|
18448
18974
|
}
|
|
@@ -18482,7 +19008,7 @@ function validate67(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18482
19008
|
validate67.errors = [{ instancePath: instancePath + "/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/items/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
18483
19009
|
return false;
|
|
18484
19010
|
} else {
|
|
18485
|
-
if (!
|
|
19011
|
+
if (!pattern34.test(data4)) {
|
|
18486
19012
|
validate67.errors = [{ instancePath: instancePath + "/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMetadata/properties/permissions/items/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e]+$" }, message: 'must match pattern "^[\\x21-\\x7e]+$"' }];
|
|
18487
19013
|
return false;
|
|
18488
19014
|
}
|
|
@@ -18790,7 +19316,7 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18790
19316
|
validate68.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
18791
19317
|
return false;
|
|
18792
19318
|
} else {
|
|
18793
|
-
if (!
|
|
19319
|
+
if (!pattern32.test(data1)) {
|
|
18794
19320
|
validate68.errors = [{ instancePath: instancePath + "/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintRequest/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
|
|
18795
19321
|
return false;
|
|
18796
19322
|
}
|
|
@@ -18843,7 +19369,7 @@ function validate68(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18843
19369
|
return errors === 0;
|
|
18844
19370
|
}
|
|
18845
19371
|
validate68.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
18846
|
-
var
|
|
19372
|
+
var pattern46 = new RegExp("^sk_[\\x21-\\x7e]+(?: [\\x21-\\x7e]+)*$", "u");
|
|
18847
19373
|
function validate69(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
18848
19374
|
;
|
|
18849
19375
|
let vErrors = null;
|
|
@@ -18904,7 +19430,7 @@ function validate69(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18904
19430
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/id/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
|
|
18905
19431
|
return false;
|
|
18906
19432
|
} else {
|
|
18907
|
-
if (!
|
|
19433
|
+
if (!pattern30.test(data1)) {
|
|
18908
19434
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/id/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
|
|
18909
19435
|
return false;
|
|
18910
19436
|
}
|
|
@@ -18933,7 +19459,7 @@ function validate69(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18933
19459
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/name/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
18934
19460
|
return false;
|
|
18935
19461
|
} else {
|
|
18936
|
-
if (!
|
|
19462
|
+
if (!pattern32.test(data2)) {
|
|
18937
19463
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/name", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/name/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$" }, message: 'must match pattern "^[\\x21-\\x7e](?:[\\x20-\\x7e]{0,126}[\\x21-\\x7e])?$"' }];
|
|
18938
19464
|
return false;
|
|
18939
19465
|
}
|
|
@@ -18962,7 +19488,7 @@ function validate69(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
18962
19488
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/obfuscatedValue/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
18963
19489
|
return false;
|
|
18964
19490
|
} else {
|
|
18965
|
-
if (!
|
|
19491
|
+
if (!pattern33.test(data3)) {
|
|
18966
19492
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/obfuscatedValue", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/obfuscatedValue/pattern", keyword: "pattern", params: { pattern: "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$" }, message: 'must match pattern "^[^\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029\\u061c\\u200b-\\u200f\\u202a-\\u202e\\u2060\\u2066-\\u2069\\ufeff]+$"' }];
|
|
18967
19493
|
return false;
|
|
18968
19494
|
}
|
|
@@ -19002,7 +19528,7 @@ function validate69(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
19002
19528
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/items/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" }];
|
|
19003
19529
|
return false;
|
|
19004
19530
|
} else {
|
|
19005
|
-
if (!
|
|
19531
|
+
if (!pattern34.test(data5)) {
|
|
19006
19532
|
validate69.errors = [{ instancePath: instancePath + "/apiKey/permissions/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/apiKey/properties/permissions/items/pattern", keyword: "pattern", params: { pattern: "^[\\x21-\\x7e]+$" }, message: 'must match pattern "^[\\x21-\\x7e]+$"' }];
|
|
19007
19533
|
return false;
|
|
19008
19534
|
}
|
|
@@ -19264,7 +19790,7 @@ function validate69(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
19264
19790
|
validate69.errors = [{ instancePath: instancePath + "/secret", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/secret/minLength", keyword: "minLength", params: { limit: 4 }, message: "must NOT have fewer than 4 characters" }];
|
|
19265
19791
|
return false;
|
|
19266
19792
|
} else {
|
|
19267
|
-
if (!
|
|
19793
|
+
if (!pattern46.test(data10)) {
|
|
19268
19794
|
validate69.errors = [{ instancePath: instancePath + "/secret", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyMintResponse/properties/secret/pattern", keyword: "pattern", params: { pattern: "^sk_[\\x21-\\x7e]+(?: [\\x21-\\x7e]+)*$" }, message: 'must match pattern "^sk_[\\x21-\\x7e]+(?: [\\x21-\\x7e]+)*$"' }];
|
|
19269
19795
|
return false;
|
|
19270
19796
|
}
|
|
@@ -19386,7 +19912,7 @@ function validate71(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
19386
19912
|
validate71.errors = [{ instancePath: instancePath + "/apiKeyId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/apiKeyId/minLength", keyword: "minLength", params: { limit: 9 }, message: "must NOT have fewer than 9 characters" }];
|
|
19387
19913
|
return false;
|
|
19388
19914
|
} else {
|
|
19389
|
-
if (!
|
|
19915
|
+
if (!pattern30.test(data0)) {
|
|
19390
19916
|
validate71.errors = [{ instancePath: instancePath + "/apiKeyId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/UserApiKeyRevokeResponse/properties/apiKeyId/pattern", keyword: "pattern", params: { pattern: "^api_key_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^api_key_[A-Za-z0-9_-]+$"' }];
|
|
19391
19917
|
return false;
|
|
19392
19918
|
}
|
|
@@ -19650,7 +20176,7 @@ function validate73(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
19650
20176
|
}
|
|
19651
20177
|
validate73.evaluated = { "dynamicProps": true, "dynamicItems": false };
|
|
19652
20178
|
var schema139 = { "type": "object", "properties": { "protocol_version": { "type": "number", "const": 1 }, "issuer": { "type": "string", "format": "uri" }, "client_id": { "type": "string", "maxLength": 256, "pattern": "^client_[A-Za-z0-9_-]+$" }, "default_scopes": { "minItems": 4, "maxItems": 4, "type": "array", "items": { "type": "string", "enum": ["openid", "profile", "email", "offline_access"] } } }, "required": ["protocol_version", "issuer", "client_id", "default_scopes"], "additionalProperties": false, "x-primitive-runtime-refinements": ["canonical_https_origin", "exact_workos_connect_device_scopes"] };
|
|
19653
|
-
var
|
|
20179
|
+
var pattern49 = new RegExp("^client_[A-Za-z0-9_-]+$", "u");
|
|
19654
20180
|
function validate74(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
19655
20181
|
;
|
|
19656
20182
|
let vErrors = null;
|
|
@@ -19719,7 +20245,7 @@ function validate74(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
19719
20245
|
validate74.errors = [{ instancePath: instancePath + "/client_id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationSuccess/properties/client_id/maxLength", keyword: "maxLength", params: { limit: 256 }, message: "must NOT have more than 256 characters" }];
|
|
19720
20246
|
return false;
|
|
19721
20247
|
} else {
|
|
19722
|
-
if (!
|
|
20248
|
+
if (!pattern49.test(data2)) {
|
|
19723
20249
|
validate74.errors = [{ instancePath: instancePath + "/client_id", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationSuccess/properties/client_id/pattern", keyword: "pattern", params: { pattern: "^client_[A-Za-z0-9_-]+$" }, message: 'must match pattern "^client_[A-Za-z0-9_-]+$"' }];
|
|
19724
20250
|
return false;
|
|
19725
20251
|
}
|
|
@@ -19816,290 +20342,42 @@ function validate75(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
19816
20342
|
return false;
|
|
19817
20343
|
break;
|
|
19818
20344
|
}
|
|
19819
|
-
}
|
|
19820
|
-
if (_errs2 === errors) {
|
|
19821
|
-
if (data.error !== void 0) {
|
|
19822
|
-
let data0 = data.error;
|
|
19823
|
-
if (typeof data0 !== "string") {
|
|
19824
|
-
validate75.errors = [{ instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationUnavailable/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
19825
|
-
return false;
|
|
19826
|
-
}
|
|
19827
|
-
if ("connect_device_auth_unavailable" !== data0) {
|
|
19828
|
-
validate75.errors = [{ instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationUnavailable/properties/error/const", keyword: "const", params: { allowedValue: "connect_device_auth_unavailable" }, message: "must be equal to constant" }];
|
|
19829
|
-
return false;
|
|
19830
|
-
}
|
|
19831
|
-
}
|
|
19832
|
-
}
|
|
19833
|
-
}
|
|
19834
|
-
} else {
|
|
19835
|
-
validate75.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationUnavailable/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
19836
|
-
return false;
|
|
19837
|
-
}
|
|
19838
|
-
}
|
|
19839
|
-
validate75.errors = vErrors;
|
|
19840
|
-
return errors === 0;
|
|
19841
|
-
}
|
|
19842
|
-
validate75.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
19843
|
-
|
|
19844
|
-
// src/lib/atomic-file.ts
|
|
19845
|
-
import { randomUUID } from "crypto";
|
|
19846
|
-
import {
|
|
19847
|
-
constants,
|
|
19848
|
-
closeSync,
|
|
19849
|
-
fchmodSync,
|
|
19850
|
-
fsyncSync,
|
|
19851
|
-
mkdirSync,
|
|
19852
|
-
openSync,
|
|
19853
|
-
renameSync,
|
|
19854
|
-
rmSync,
|
|
19855
|
-
writeFileSync
|
|
19856
|
-
} from "fs";
|
|
19857
|
-
import { dirname as dirname2 } from "path";
|
|
19858
|
-
var DEFAULT_FILE_MODE = 438;
|
|
19859
|
-
function syncDirectory(path) {
|
|
19860
|
-
const fd = openSync(path, constants.O_RDONLY);
|
|
19861
|
-
try {
|
|
19862
|
-
fsyncSync(fd);
|
|
19863
|
-
} finally {
|
|
19864
|
-
closeSync(fd);
|
|
19865
|
-
}
|
|
19866
|
-
}
|
|
19867
|
-
function syncCreatedParentChain(firstCreatedParent, parent) {
|
|
19868
|
-
const createdDirectories = [];
|
|
19869
|
-
let current = parent;
|
|
19870
|
-
while (current !== firstCreatedParent) {
|
|
19871
|
-
createdDirectories.push(current);
|
|
19872
|
-
const next = dirname2(current);
|
|
19873
|
-
if (next === current) {
|
|
19874
|
-
throw new Error("recursive mkdir returned a path outside the target parent chain");
|
|
19875
|
-
}
|
|
19876
|
-
current = next;
|
|
19877
|
-
}
|
|
19878
|
-
createdDirectories.push(firstCreatedParent);
|
|
19879
|
-
syncDirectory(dirname2(firstCreatedParent));
|
|
19880
|
-
for (const directory of createdDirectories.reverse().slice(0, -1)) {
|
|
19881
|
-
syncDirectory(directory);
|
|
19882
|
-
}
|
|
19883
|
-
}
|
|
19884
|
-
function ensureDurableDirectory(path, mode) {
|
|
19885
|
-
const firstCreatedParent = mkdirSync(path, { recursive: true, mode });
|
|
19886
|
-
if (firstCreatedParent) {
|
|
19887
|
-
syncCreatedParentChain(firstCreatedParent, path);
|
|
19888
|
-
}
|
|
19889
|
-
}
|
|
19890
|
-
function atomicWriteFile(target, content, options = {}) {
|
|
19891
|
-
const parent = dirname2(target);
|
|
19892
|
-
if (options.ensureParent) {
|
|
19893
|
-
ensureDurableDirectory(parent);
|
|
19894
|
-
}
|
|
19895
|
-
const temporaryPath = `${target}.${randomUUID()}.tmp`;
|
|
19896
|
-
let temporaryCreated = false;
|
|
19897
|
-
try {
|
|
19898
|
-
const flags = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW;
|
|
19899
|
-
const fd = openSync(temporaryPath, flags, options.mode ?? DEFAULT_FILE_MODE);
|
|
19900
|
-
temporaryCreated = true;
|
|
19901
|
-
try {
|
|
19902
|
-
if (options.mode !== void 0) fchmodSync(fd, options.mode);
|
|
19903
|
-
writeFileSync(fd, content);
|
|
19904
|
-
fsyncSync(fd);
|
|
19905
|
-
} finally {
|
|
19906
|
-
closeSync(fd);
|
|
19907
|
-
}
|
|
19908
|
-
options.validate?.(temporaryPath);
|
|
19909
|
-
renameSync(temporaryPath, target);
|
|
19910
|
-
syncDirectory(parent);
|
|
19911
|
-
} catch (error) {
|
|
19912
|
-
if (temporaryCreated) {
|
|
19913
|
-
try {
|
|
19914
|
-
rmSync(temporaryPath, { force: true });
|
|
19915
|
-
} catch {
|
|
19916
|
-
}
|
|
19917
|
-
}
|
|
19918
|
-
throw error;
|
|
19919
|
-
}
|
|
19920
|
-
}
|
|
19921
|
-
|
|
19922
|
-
// src/lib/file-lock.ts
|
|
19923
|
-
import { randomBytes } from "crypto";
|
|
19924
|
-
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
|
|
19925
|
-
import { dirname as dirname3, join as join4 } from "path";
|
|
19926
|
-
|
|
19927
|
-
// src/lib/process-liveness.ts
|
|
19928
|
-
function processIsAlive(pid, probe = process.kill) {
|
|
19929
|
-
if (!Number.isSafeInteger(pid) || pid <= 0) return false;
|
|
19930
|
-
try {
|
|
19931
|
-
probe(pid, 0);
|
|
19932
|
-
return true;
|
|
19933
|
-
} catch (error) {
|
|
19934
|
-
return error.code === "EPERM";
|
|
19935
|
-
}
|
|
19936
|
-
}
|
|
19937
|
-
|
|
19938
|
-
// src/lib/file-lock.ts
|
|
19939
|
-
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
19940
|
-
var DEFAULT_POLL_MS = 50;
|
|
19941
|
-
var DEFAULT_INIT_GRACE_MS = 2e3;
|
|
19942
|
-
var DIRECTORY_MODE = 448;
|
|
19943
|
-
var FILE_MODE = 384;
|
|
19944
|
-
function ownerPath(lockDir) {
|
|
19945
|
-
return join4(lockDir, "owner.json");
|
|
19946
|
-
}
|
|
19947
|
-
function readOwner(lockDir) {
|
|
19948
|
-
try {
|
|
19949
|
-
const owner = JSON.parse(readFileSync3(ownerPath(lockDir), "utf8"));
|
|
19950
|
-
if (!Number.isInteger(owner.pid) || owner.pid <= 0 || typeof owner.nonce !== "string" || typeof owner.createdAt !== "number") {
|
|
19951
|
-
return null;
|
|
19952
|
-
}
|
|
19953
|
-
return owner;
|
|
19954
|
-
} catch {
|
|
19955
|
-
return null;
|
|
19956
|
-
}
|
|
19957
|
-
}
|
|
19958
|
-
function sameOwner(a, b) {
|
|
19959
|
-
return a?.pid === b.pid && a.nonce === b.nonce && a.createdAt === b.createdAt;
|
|
19960
|
-
}
|
|
19961
|
-
function tryTakeLock(lockDir, now) {
|
|
19962
|
-
try {
|
|
19963
|
-
mkdirSync2(lockDir, { mode: DIRECTORY_MODE });
|
|
19964
|
-
} catch (error) {
|
|
19965
|
-
if (error.code === "EEXIST") return null;
|
|
19966
|
-
throw error;
|
|
19967
|
-
}
|
|
19968
|
-
const owner = {
|
|
19969
|
-
pid: process.pid,
|
|
19970
|
-
nonce: randomBytes(16).toString("hex"),
|
|
19971
|
-
createdAt: now
|
|
19972
|
-
};
|
|
19973
|
-
try {
|
|
19974
|
-
writeFileSync2(ownerPath(lockDir), `${JSON.stringify(owner)}
|
|
19975
|
-
`, {
|
|
19976
|
-
encoding: "utf8",
|
|
19977
|
-
mode: FILE_MODE,
|
|
19978
|
-
flag: "wx"
|
|
19979
|
-
});
|
|
19980
|
-
return owner;
|
|
19981
|
-
} catch (error) {
|
|
19982
|
-
rmSync2(lockDir, { recursive: true, force: true });
|
|
19983
|
-
throw error;
|
|
19984
|
-
}
|
|
19985
|
-
}
|
|
19986
|
-
function recoverStaleLock(lockDir, now, alive, initGraceMs) {
|
|
19987
|
-
const owner = readOwner(lockDir);
|
|
19988
|
-
if (owner) {
|
|
19989
|
-
if (alive(owner.pid)) return false;
|
|
19990
|
-
if (!sameOwner(readOwner(lockDir), owner)) return false;
|
|
19991
|
-
rmSync2(lockDir, { recursive: true, force: true });
|
|
19992
|
-
return true;
|
|
19993
|
-
}
|
|
19994
|
-
try {
|
|
19995
|
-
const before = statSync(lockDir).mtimeMs;
|
|
19996
|
-
if (now - before < initGraceMs) return false;
|
|
19997
|
-
if (readOwner(lockDir)) return false;
|
|
19998
|
-
if (statSync(lockDir).mtimeMs !== before) return false;
|
|
19999
|
-
rmSync2(lockDir, { recursive: true, force: true });
|
|
20000
|
-
return true;
|
|
20001
|
-
} catch {
|
|
20002
|
-
return true;
|
|
20003
|
-
}
|
|
20004
|
-
}
|
|
20005
|
-
function abortError(signal) {
|
|
20006
|
-
if (signal.reason instanceof Error) return signal.reason;
|
|
20007
|
-
const error = new Error("The operation was aborted");
|
|
20008
|
-
error.name = "AbortError";
|
|
20009
|
-
return error;
|
|
20010
|
-
}
|
|
20011
|
-
function throwIfAborted(signal) {
|
|
20012
|
-
if (signal?.aborted) throw abortError(signal);
|
|
20013
|
-
}
|
|
20014
|
-
async function defaultSleep(ms, signal) {
|
|
20015
|
-
if (!signal) {
|
|
20016
|
-
await new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
20017
|
-
return;
|
|
20018
|
-
}
|
|
20019
|
-
throwIfAborted(signal);
|
|
20020
|
-
await new Promise((resolve7, reject) => {
|
|
20021
|
-
const timer = setTimeout(() => {
|
|
20022
|
-
signal.removeEventListener("abort", onAbort);
|
|
20023
|
-
resolve7();
|
|
20024
|
-
}, ms);
|
|
20025
|
-
const onAbort = () => {
|
|
20026
|
-
clearTimeout(timer);
|
|
20027
|
-
reject(abortError(signal));
|
|
20028
|
-
};
|
|
20029
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
20030
|
-
});
|
|
20031
|
-
}
|
|
20032
|
-
var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
20033
|
-
function defaultSleepSync(ms) {
|
|
20034
|
-
Atomics.wait(syncSleeper, 0, 0, ms);
|
|
20035
|
-
}
|
|
20036
|
-
function withFileLockSync(lockDir, operation, options = {}) {
|
|
20037
|
-
mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
|
|
20038
|
-
const nowMs = options.nowMs ?? Date.now;
|
|
20039
|
-
const alive = options.processAlive ?? processIsAlive;
|
|
20040
|
-
const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
20041
|
-
let owner = null;
|
|
20042
|
-
while (!owner) {
|
|
20043
|
-
const now = nowMs();
|
|
20044
|
-
owner = tryTakeLock(lockDir, now);
|
|
20045
|
-
if (owner) break;
|
|
20046
|
-
recoverStaleLock(lockDir, now, alive, options.initGraceMs ?? DEFAULT_INIT_GRACE_MS);
|
|
20047
|
-
if (now >= deadline) {
|
|
20048
|
-
throw new Error(`timed out waiting for file lock ${lockDir}`);
|
|
20049
|
-
}
|
|
20050
|
-
(options.sleep ?? defaultSleepSync)(options.pollMs ?? DEFAULT_POLL_MS);
|
|
20051
|
-
}
|
|
20052
|
-
try {
|
|
20053
|
-
return operation();
|
|
20054
|
-
} finally {
|
|
20055
|
-
if (sameOwner(readOwner(lockDir), owner)) {
|
|
20056
|
-
rmSync2(lockDir, { recursive: true, force: true });
|
|
20057
|
-
}
|
|
20058
|
-
}
|
|
20059
|
-
}
|
|
20060
|
-
async function withFileLock(lockDir, operation, options = {}) {
|
|
20061
|
-
mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
|
|
20062
|
-
const nowMs = options.nowMs ?? Date.now;
|
|
20063
|
-
const alive = options.processAlive ?? processIsAlive;
|
|
20064
|
-
const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
20065
|
-
let owner = null;
|
|
20066
|
-
while (!owner) {
|
|
20067
|
-
throwIfAborted(options.signal);
|
|
20068
|
-
const now = nowMs();
|
|
20069
|
-
owner = tryTakeLock(lockDir, now);
|
|
20070
|
-
if (owner) break;
|
|
20071
|
-
recoverStaleLock(lockDir, now, alive, options.initGraceMs ?? DEFAULT_INIT_GRACE_MS);
|
|
20072
|
-
if (now >= deadline) {
|
|
20073
|
-
throw new Error(`timed out waiting for file lock ${lockDir}`);
|
|
20074
|
-
}
|
|
20075
|
-
if (options.sleep) {
|
|
20076
|
-
await options.sleep(options.pollMs ?? DEFAULT_POLL_MS);
|
|
20077
|
-
throwIfAborted(options.signal);
|
|
20345
|
+
}
|
|
20346
|
+
if (_errs2 === errors) {
|
|
20347
|
+
if (data.error !== void 0) {
|
|
20348
|
+
let data0 = data.error;
|
|
20349
|
+
if (typeof data0 !== "string") {
|
|
20350
|
+
validate75.errors = [{ instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationUnavailable/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" }];
|
|
20351
|
+
return false;
|
|
20352
|
+
}
|
|
20353
|
+
if ("connect_device_auth_unavailable" !== data0) {
|
|
20354
|
+
validate75.errors = [{ instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationUnavailable/properties/error/const", keyword: "const", params: { allowedValue: "connect_device_auth_unavailable" }, message: "must be equal to constant" }];
|
|
20355
|
+
return false;
|
|
20356
|
+
}
|
|
20357
|
+
}
|
|
20358
|
+
}
|
|
20359
|
+
}
|
|
20078
20360
|
} else {
|
|
20079
|
-
|
|
20080
|
-
|
|
20081
|
-
}
|
|
20082
|
-
try {
|
|
20083
|
-
throwIfAborted(options.signal);
|
|
20084
|
-
return await operation();
|
|
20085
|
-
} finally {
|
|
20086
|
-
if (sameOwner(readOwner(lockDir), owner)) {
|
|
20087
|
-
rmSync2(lockDir, { recursive: true, force: true });
|
|
20361
|
+
validate75.errors = [{ instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/WorkosConnectDeviceConfigurationUnavailable/type", keyword: "type", params: { type: "object" }, message: "must be object" }];
|
|
20362
|
+
return false;
|
|
20088
20363
|
}
|
|
20089
20364
|
}
|
|
20365
|
+
validate75.errors = vErrors;
|
|
20366
|
+
return errors === 0;
|
|
20090
20367
|
}
|
|
20368
|
+
validate75.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
|
|
20091
20369
|
|
|
20092
20370
|
// src/demo/state.ts
|
|
20093
20371
|
var RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
20094
|
-
var demoDirectory = () =>
|
|
20372
|
+
var demoDirectory = () => join7(primConfigDirectory(), "demo");
|
|
20095
20373
|
var runPath = (id) => {
|
|
20096
20374
|
if (!RUN_ID.test(id)) throw new Error("invalid demo run ID");
|
|
20097
|
-
return
|
|
20375
|
+
return join7(demoDirectory(), "runs", `${id}.json`);
|
|
20098
20376
|
};
|
|
20099
20377
|
function readDemoJson(path) {
|
|
20100
|
-
const stat =
|
|
20378
|
+
const stat = lstatSync2(path);
|
|
20101
20379
|
if (!stat.isFile() || stat.size > 16384) throw new Error(`invalid demo state: ${path}`);
|
|
20102
|
-
return JSON.parse(
|
|
20380
|
+
return JSON.parse(readFileSync6(path, "utf8"));
|
|
20103
20381
|
}
|
|
20104
20382
|
function saveDemoJson(path, value) {
|
|
20105
20383
|
atomicWriteFile(path, `${JSON.stringify(value)}
|
|
@@ -20136,16 +20414,16 @@ function demoCommand(run, action, choice, reason) {
|
|
|
20136
20414
|
].map(quote).join(" ");
|
|
20137
20415
|
}
|
|
20138
20416
|
function sessionKey(agent, session) {
|
|
20139
|
-
return
|
|
20417
|
+
return createHash3("sha256").update(`${agent}\0${session}`).digest("hex");
|
|
20140
20418
|
}
|
|
20141
20419
|
function exclusionPath(key) {
|
|
20142
20420
|
if (!/^[0-9a-f]{64}$/u.test(key)) throw new Error("invalid demo session identity");
|
|
20143
|
-
return
|
|
20421
|
+
return join7(demoDirectory(), "excluded-sessions", `${key}.json`);
|
|
20144
20422
|
}
|
|
20145
20423
|
function sessionExcluded(agent, session) {
|
|
20146
20424
|
if (typeof session !== "string" || !session) return false;
|
|
20147
20425
|
const path = exclusionPath(sessionKey(agent, session));
|
|
20148
|
-
if (!
|
|
20426
|
+
if (!existsSync5(path)) return false;
|
|
20149
20427
|
const record = readDemoJson(path);
|
|
20150
20428
|
if (typeof record.runId !== "string" || !RUN_ID.test(record.runId)) {
|
|
20151
20429
|
throw new Error("invalid demo capture exclusion");
|
|
@@ -20178,42 +20456,86 @@ function demoArgv(command) {
|
|
|
20178
20456
|
}
|
|
20179
20457
|
}
|
|
20180
20458
|
|
|
20459
|
+
// src/demo/diagnostics.ts
|
|
20460
|
+
var observationPath = (id) => join8(demoDirectory(), "observations", `${id}.json`);
|
|
20461
|
+
function observeRun(id, observation) {
|
|
20462
|
+
try {
|
|
20463
|
+
saveDemoJson(observationPath(id), observation);
|
|
20464
|
+
} catch {
|
|
20465
|
+
process.stderr.write(
|
|
20466
|
+
"[prim] demo isolation diagnostic could not be saved; check access to Primitive's configuration directory.\n"
|
|
20467
|
+
);
|
|
20468
|
+
}
|
|
20469
|
+
}
|
|
20470
|
+
|
|
20181
20471
|
// src/demo/isolation.ts
|
|
20182
20472
|
function observeDemoInvocation(envelope, agent, checkExclusion = true) {
|
|
20183
20473
|
const session = typeof envelope.session_id === "string" && envelope.session_id ? envelope.session_id : agent === "hermes" ? envelope.extra?.session_key : void 0;
|
|
20184
20474
|
let invocation = false;
|
|
20185
|
-
if (envelope.hook_event_name === "PreToolUse"
|
|
20475
|
+
if (envelope.hook_event_name === "PreToolUse") {
|
|
20186
20476
|
const tool = agent === "cursor" ? "Shell" : agent === "hermes" ? "terminal" : "Bash";
|
|
20187
20477
|
const input = envelope.tool_input;
|
|
20188
|
-
const command = input?.command;
|
|
20189
|
-
if (
|
|
20478
|
+
const command = input?.command ?? input?.cmd;
|
|
20479
|
+
if (typeof command === "string" && command.length < 8192) {
|
|
20190
20480
|
const argv = demoArgv(command);
|
|
20191
|
-
const id = argv?.[4];
|
|
20192
|
-
if (id && RUN_ID.test(id) &&
|
|
20193
|
-
|
|
20194
|
-
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
|
|
20199
|
-
|
|
20200
|
-
|
|
20201
|
-
return false;
|
|
20202
|
-
}
|
|
20203
|
-
if (action === "skip") return true;
|
|
20204
|
-
const key = sessionKey(agent, session);
|
|
20205
|
-
if (run.agent && run.agent !== agent || run.binding && run.binding !== key) {
|
|
20206
|
-
run.acknowledgment = void 0;
|
|
20207
|
-
saveRun(run);
|
|
20208
|
-
return false;
|
|
20209
|
-
}
|
|
20210
|
-
saveDemoJson(exclusionPath(key), { runId: run.id });
|
|
20211
|
-
run.binding = key;
|
|
20212
|
-
run.agent = agent;
|
|
20213
|
-
run.acknowledgment = { command, at: Date.now() };
|
|
20214
|
-
saveRun(run);
|
|
20215
|
-
return true;
|
|
20481
|
+
const id = argv?.[4] ?? command.match(/\x27([0-9a-f-]{36})\x27/u)?.[1];
|
|
20482
|
+
if (id && RUN_ID.test(id) && existsSync7(runPath(id))) {
|
|
20483
|
+
const identity = typeof session === "string" && session ? sessionKey(agent, session) : void 0;
|
|
20484
|
+
const observed = (result, errorCode2) => observeRun(id, {
|
|
20485
|
+
at: Date.now(),
|
|
20486
|
+
agent,
|
|
20487
|
+
runtimeVersion: packageVersion() ?? void 0,
|
|
20488
|
+
session: identity,
|
|
20489
|
+
result,
|
|
20490
|
+
...errorCode2 ? { errorCode: errorCode2 } : {}
|
|
20216
20491
|
});
|
|
20492
|
+
const action = argv?.[3];
|
|
20493
|
+
const choice = argv?.[6];
|
|
20494
|
+
const reason = argv?.[8];
|
|
20495
|
+
const recognized = ["start", "attempt", "resolve", "status", "skip"].includes(action);
|
|
20496
|
+
const validChoice = action !== "resolve" || choice === "adhere" || choice === "supersede" && typeof reason === "string" && reason.trim().length > 0 && reason.length <= 500;
|
|
20497
|
+
const matches = (run) => !run.terminal && recognized && validChoice && demoCommand(run, action, choice, reason) === command;
|
|
20498
|
+
let candidate;
|
|
20499
|
+
try {
|
|
20500
|
+
candidate = readRun(id);
|
|
20501
|
+
} catch {
|
|
20502
|
+
}
|
|
20503
|
+
if (envelope.tool_name !== tool || typeof input?.command !== "string") {
|
|
20504
|
+
observed("tool-mismatch");
|
|
20505
|
+
} else if (!candidate || !matches(candidate)) {
|
|
20506
|
+
observed("command-mismatch");
|
|
20507
|
+
} else
|
|
20508
|
+
try {
|
|
20509
|
+
invocation = lockRun(id, (run) => {
|
|
20510
|
+
if (!matches(run)) {
|
|
20511
|
+
observed("command-mismatch");
|
|
20512
|
+
return false;
|
|
20513
|
+
}
|
|
20514
|
+
if (action === "skip") return true;
|
|
20515
|
+
if (!identity) {
|
|
20516
|
+
observed("session-missing");
|
|
20517
|
+
return false;
|
|
20518
|
+
}
|
|
20519
|
+
const key = identity;
|
|
20520
|
+
if (run.agent && run.agent !== agent || run.binding && run.binding !== key) {
|
|
20521
|
+
observed("session-mismatch");
|
|
20522
|
+
run.acknowledgment = void 0;
|
|
20523
|
+
saveRun(run);
|
|
20524
|
+
return false;
|
|
20525
|
+
}
|
|
20526
|
+
saveDemoJson(exclusionPath(key), { runId: run.id });
|
|
20527
|
+
run.binding = key;
|
|
20528
|
+
run.agent = agent;
|
|
20529
|
+
run.acknowledgment = { command, at: Date.now() };
|
|
20530
|
+
saveRun(run);
|
|
20531
|
+
observed("acknowledged");
|
|
20532
|
+
return true;
|
|
20533
|
+
});
|
|
20534
|
+
} catch (error) {
|
|
20535
|
+
const code = error.code;
|
|
20536
|
+
observed("write-failed", code && /^[A-Z0-9_]{1,32}$/u.test(code) ? code : void 0);
|
|
20537
|
+
throw error;
|
|
20538
|
+
}
|
|
20217
20539
|
}
|
|
20218
20540
|
}
|
|
20219
20541
|
}
|
|
@@ -20222,15 +20544,15 @@ function observeDemoInvocation(envelope, agent, checkExclusion = true) {
|
|
|
20222
20544
|
|
|
20223
20545
|
// src/lib/activation.ts
|
|
20224
20546
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
20225
|
-
import { existsSync as
|
|
20547
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7 } from "fs";
|
|
20226
20548
|
import { homedir as homedir2 } from "os";
|
|
20227
|
-
import { join as
|
|
20549
|
+
import { join as join9 } from "path";
|
|
20228
20550
|
|
|
20229
20551
|
// src/lib/git.ts
|
|
20230
20552
|
import { execFileSync } from "child_process";
|
|
20231
|
-
import { createHash as
|
|
20232
|
-
import { lstatSync as
|
|
20233
|
-
import { basename, dirname as
|
|
20553
|
+
import { createHash as createHash4 } from "crypto";
|
|
20554
|
+
import { lstatSync as lstatSync3, realpathSync as realpathSync2 } from "fs";
|
|
20555
|
+
import { basename, dirname as dirname6, isAbsolute as isAbsolute4, relative, resolve as resolve3, sep } from "path";
|
|
20234
20556
|
var GIT_TIMEOUT_MS = 1e3;
|
|
20235
20557
|
var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
|
|
20236
20558
|
var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
|
|
@@ -20279,19 +20601,19 @@ function githubRepositoryFullName(cwd) {
|
|
|
20279
20601
|
function canonicalGitRoot(cwd) {
|
|
20280
20602
|
try {
|
|
20281
20603
|
const top = gitToplevel(cwd);
|
|
20282
|
-
return top ?
|
|
20604
|
+
return top ? realpathSync2.native(top) : null;
|
|
20283
20605
|
} catch {
|
|
20284
20606
|
return null;
|
|
20285
20607
|
}
|
|
20286
20608
|
}
|
|
20287
20609
|
function relatedWorktreeTarget(path, cwd, origin) {
|
|
20288
|
-
let parent =
|
|
20610
|
+
let parent = dirname6(resolve3(cwd, path));
|
|
20289
20611
|
while (true) {
|
|
20290
20612
|
try {
|
|
20291
|
-
|
|
20613
|
+
realpathSync2.native(parent);
|
|
20292
20614
|
break;
|
|
20293
20615
|
} catch {
|
|
20294
|
-
const next =
|
|
20616
|
+
const next = dirname6(parent);
|
|
20295
20617
|
if (next === parent) return null;
|
|
20296
20618
|
parent = next;
|
|
20297
20619
|
}
|
|
@@ -20301,7 +20623,7 @@ function relatedWorktreeTarget(path, cwd, origin) {
|
|
|
20301
20623
|
const common = (root) => {
|
|
20302
20624
|
const value = gitValue(root, ["rev-parse", "--git-common-dir"]);
|
|
20303
20625
|
try {
|
|
20304
|
-
return value ?
|
|
20626
|
+
return value ? realpathSync2.native(resolve3(root, value)) : void 0;
|
|
20305
20627
|
} catch {
|
|
20306
20628
|
return void 0;
|
|
20307
20629
|
}
|
|
@@ -20331,16 +20653,16 @@ function normalizeOriginRemote(remote) {
|
|
|
20331
20653
|
}
|
|
20332
20654
|
}
|
|
20333
20655
|
function opaqueRepoKey(source, value) {
|
|
20334
|
-
return `repo_v1_${
|
|
20656
|
+
return `repo_v1_${createHash4("sha256").update(`${source}\0${value}`).digest("hex")}`;
|
|
20335
20657
|
}
|
|
20336
20658
|
function resolveRepositoryContext(cwd = process.cwd()) {
|
|
20337
20659
|
const top = gitToplevel(cwd);
|
|
20338
20660
|
if (!top) return null;
|
|
20339
20661
|
let repoRoot;
|
|
20340
20662
|
try {
|
|
20341
|
-
repoRoot =
|
|
20663
|
+
repoRoot = realpathSync2.native(top);
|
|
20342
20664
|
} catch {
|
|
20343
|
-
repoRoot =
|
|
20665
|
+
repoRoot = resolve3(top);
|
|
20344
20666
|
}
|
|
20345
20667
|
const origin = gitValue(repoRoot, ["config", "--get", "remote.origin.url"]);
|
|
20346
20668
|
const repoFullName = githubRepositoryFullName(repoRoot) ?? void 0;
|
|
@@ -20369,19 +20691,19 @@ function nearestExistingAncestor(path) {
|
|
|
20369
20691
|
let cursor = path;
|
|
20370
20692
|
while (true) {
|
|
20371
20693
|
try {
|
|
20372
|
-
|
|
20694
|
+
lstatSync3(cursor);
|
|
20373
20695
|
break;
|
|
20374
20696
|
} catch (error) {
|
|
20375
20697
|
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
20376
20698
|
if (code !== "ENOENT" && code !== "ENOTDIR") return null;
|
|
20377
|
-
const parent =
|
|
20699
|
+
const parent = dirname6(cursor);
|
|
20378
20700
|
if (parent === cursor) return null;
|
|
20379
20701
|
suffix.unshift(cursor.slice(parent.length + (parent.endsWith(sep) ? 0 : 1)));
|
|
20380
20702
|
cursor = parent;
|
|
20381
20703
|
}
|
|
20382
20704
|
}
|
|
20383
20705
|
try {
|
|
20384
|
-
return { real:
|
|
20706
|
+
return { real: realpathSync2.native(cursor), suffix };
|
|
20385
20707
|
} catch {
|
|
20386
20708
|
return null;
|
|
20387
20709
|
}
|
|
@@ -20390,13 +20712,13 @@ function canonicalRepositoryPathScoped(filePath, context, baseDir) {
|
|
|
20390
20712
|
if (!filePath || filePath !== filePath.trim() || filePath.includes("\0")) {
|
|
20391
20713
|
return { ok: false, reason: "invalid_path" };
|
|
20392
20714
|
}
|
|
20393
|
-
const absolute =
|
|
20715
|
+
const absolute = resolve3(baseDir, filePath);
|
|
20394
20716
|
const resolved = nearestExistingAncestor(absolute);
|
|
20395
20717
|
if (!resolved) return { ok: false, reason: "invalid_path" };
|
|
20396
|
-
const target =
|
|
20718
|
+
const target = resolve3(resolved.real, ...resolved.suffix);
|
|
20397
20719
|
const rel = relative(context.repoRoot, target);
|
|
20398
20720
|
if (!rel || rel === ".") return { ok: false, reason: "invalid_path" };
|
|
20399
|
-
if (
|
|
20721
|
+
if (isAbsolute4(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
20400
20722
|
return { ok: false, reason: "outside_repository" };
|
|
20401
20723
|
}
|
|
20402
20724
|
return { ok: true, file: sep === "/" ? rel : rel.split(sep).join("/") };
|
|
@@ -20404,26 +20726,26 @@ function canonicalRepositoryPathScoped(filePath, context, baseDir) {
|
|
|
20404
20726
|
function canonicalRepositoryPathLegacy(filePath, cwd, repositoryRoot = canonicalGitRoot(cwd)) {
|
|
20405
20727
|
if (!repositoryRoot || !filePath || [...filePath].some((char) => char < " " || char === "\x7F" || "~*?[]{}$`\\".includes(char)))
|
|
20406
20728
|
return null;
|
|
20407
|
-
const absolute =
|
|
20729
|
+
const absolute = resolve3(cwd, filePath);
|
|
20408
20730
|
let target;
|
|
20409
20731
|
try {
|
|
20410
|
-
const stat =
|
|
20732
|
+
const stat = lstatSync3(absolute);
|
|
20411
20733
|
if (!stat.isFile() || stat.isSymbolicLink()) return null;
|
|
20412
|
-
target =
|
|
20734
|
+
target = realpathSync2.native(absolute);
|
|
20413
20735
|
} catch (error) {
|
|
20414
20736
|
if (!(error instanceof Error) || error.code !== "ENOENT") {
|
|
20415
20737
|
return null;
|
|
20416
20738
|
}
|
|
20417
20739
|
try {
|
|
20418
|
-
const parent =
|
|
20419
|
-
if (!
|
|
20420
|
-
target =
|
|
20740
|
+
const parent = realpathSync2.native(dirname6(absolute));
|
|
20741
|
+
if (!lstatSync3(parent).isDirectory()) return null;
|
|
20742
|
+
target = resolve3(parent, basename(absolute));
|
|
20421
20743
|
} catch {
|
|
20422
20744
|
return null;
|
|
20423
20745
|
}
|
|
20424
20746
|
}
|
|
20425
20747
|
const rel = relative(repositoryRoot, target);
|
|
20426
|
-
if (!rel ||
|
|
20748
|
+
if (!rel || isAbsolute4(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
20427
20749
|
return null;
|
|
20428
20750
|
}
|
|
20429
20751
|
return sep === "/" ? rel : rel.split(sep).join("/");
|
|
@@ -20505,10 +20827,10 @@ function hasProjectPrimInstall(cwd) {
|
|
|
20505
20827
|
const root = gitToplevel(cwd);
|
|
20506
20828
|
if (root === null || root === homedir2()) return false;
|
|
20507
20829
|
for (const rel of PROJECT_INSTALL_FILES) {
|
|
20508
|
-
const path =
|
|
20509
|
-
if (
|
|
20830
|
+
const path = join9(root, rel);
|
|
20831
|
+
if (existsSync8(path)) {
|
|
20510
20832
|
try {
|
|
20511
|
-
const content =
|
|
20833
|
+
const content = readFileSync7(path, "utf-8");
|
|
20512
20834
|
if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
|
|
20513
20835
|
} catch {
|
|
20514
20836
|
}
|
|
@@ -20527,14 +20849,14 @@ function decisionIngestionStatus(cwd) {
|
|
|
20527
20849
|
}
|
|
20528
20850
|
|
|
20529
20851
|
// src/client.ts
|
|
20530
|
-
import { createHash as
|
|
20531
|
-
import { chmodSync as
|
|
20532
|
-
import { dirname as
|
|
20852
|
+
import { createHash as createHash5 } from "crypto";
|
|
20853
|
+
import { chmodSync as chmodSync3, existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync9, rmSync as rmSync4 } from "fs";
|
|
20854
|
+
import { dirname as dirname7 } from "path";
|
|
20533
20855
|
|
|
20534
20856
|
// src/daemon/client-instance-id.ts
|
|
20535
|
-
import { randomBytes as
|
|
20536
|
-
import { chmodSync, lstatSync as
|
|
20537
|
-
import { join as
|
|
20857
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
20858
|
+
import { chmodSync as chmodSync2, lstatSync as lstatSync4, readFileSync as readFileSync8 } from "fs";
|
|
20859
|
+
import { join as join10 } from "path";
|
|
20538
20860
|
var CONFIG_DIRECTORY_MODE = 448;
|
|
20539
20861
|
var INSTANCE_FILE_MODE = 384;
|
|
20540
20862
|
var INSTANCE_ENTROPY_BYTES = 32;
|
|
@@ -20547,17 +20869,17 @@ function isClientInstanceId(value) {
|
|
|
20547
20869
|
}
|
|
20548
20870
|
function ensurePrivateConfigDirectory(configDir) {
|
|
20549
20871
|
ensureDurableDirectory(configDir, CONFIG_DIRECTORY_MODE);
|
|
20550
|
-
const metadata =
|
|
20872
|
+
const metadata = lstatSync4(configDir);
|
|
20551
20873
|
if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
|
|
20552
20874
|
throw new Error("prim config path must be a private directory");
|
|
20553
20875
|
}
|
|
20554
|
-
|
|
20876
|
+
chmodSync2(configDir, CONFIG_DIRECTORY_MODE);
|
|
20555
20877
|
syncDirectory(configDir);
|
|
20556
20878
|
}
|
|
20557
20879
|
function readExisting(path) {
|
|
20558
20880
|
let metadata;
|
|
20559
20881
|
try {
|
|
20560
|
-
metadata =
|
|
20882
|
+
metadata = lstatSync4(path);
|
|
20561
20883
|
} catch (error) {
|
|
20562
20884
|
if (error.code === "ENOENT") {
|
|
20563
20885
|
return;
|
|
@@ -20567,11 +20889,11 @@ function readExisting(path) {
|
|
|
20567
20889
|
if (!metadata.isFile() || metadata.isSymbolicLink()) {
|
|
20568
20890
|
throw new Error("stored client instance identity is invalid");
|
|
20569
20891
|
}
|
|
20570
|
-
|
|
20892
|
+
chmodSync2(path, INSTANCE_FILE_MODE);
|
|
20571
20893
|
if (metadata.size > MAX_STORED_BYTES) {
|
|
20572
20894
|
throw new Error("stored client instance identity is invalid");
|
|
20573
20895
|
}
|
|
20574
|
-
const raw =
|
|
20896
|
+
const raw = readFileSync8(path, "utf8");
|
|
20575
20897
|
const value = raw.endsWith("\n") ? raw.slice(0, -1) : raw;
|
|
20576
20898
|
if (raw !== value && raw !== `${value}
|
|
20577
20899
|
` || !isClientInstanceId(value)) {
|
|
@@ -20585,8 +20907,8 @@ function atomicWrite(path, value) {
|
|
|
20585
20907
|
}
|
|
20586
20908
|
async function getOrCreateClientInstanceId(options) {
|
|
20587
20909
|
const configDir = options.configDir;
|
|
20588
|
-
const path =
|
|
20589
|
-
const lockPath =
|
|
20910
|
+
const path = join10(configDir, "client_instance_id");
|
|
20911
|
+
const lockPath = join10(configDir, "client-instance.lock");
|
|
20590
20912
|
ensurePrivateConfigDirectory(configDir);
|
|
20591
20913
|
return withFileLock(
|
|
20592
20914
|
lockPath,
|
|
@@ -20595,7 +20917,7 @@ async function getOrCreateClientInstanceId(options) {
|
|
|
20595
20917
|
if (existing !== void 0) {
|
|
20596
20918
|
return existing;
|
|
20597
20919
|
}
|
|
20598
|
-
const generated = `${INSTANCE_PREFIX}${
|
|
20920
|
+
const generated = `${INSTANCE_PREFIX}${randomBytes3(INSTANCE_ENTROPY_BYTES).toString(
|
|
20599
20921
|
"base64url"
|
|
20600
20922
|
)}`;
|
|
20601
20923
|
if (!isClientInstanceId(generated)) {
|
|
@@ -20608,75 +20930,6 @@ async function getOrCreateClientInstanceId(options) {
|
|
|
20608
20930
|
);
|
|
20609
20931
|
}
|
|
20610
20932
|
|
|
20611
|
-
// src/lib/bin-path.ts
|
|
20612
|
-
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
20613
|
-
import { dirname as dirname5, isAbsolute as isAbsolute3, join as join8 } from "path";
|
|
20614
|
-
import { fileURLToPath } from "url";
|
|
20615
|
-
var PKG_NAME = "@primitive.ai/prim";
|
|
20616
|
-
var ROOT_WALK_LIMIT = 6;
|
|
20617
|
-
var STABLE_HOOK_LAUNCHER_NAME = "prim-hook-launcher-v1";
|
|
20618
|
-
var resolvedRoot;
|
|
20619
|
-
function locateRoot() {
|
|
20620
|
-
if (resolvedRoot !== void 0) {
|
|
20621
|
-
return resolvedRoot;
|
|
20622
|
-
}
|
|
20623
|
-
let dir = dirname5(fileURLToPath(import.meta.url));
|
|
20624
|
-
for (let depth = 0; depth < ROOT_WALK_LIMIT; depth++) {
|
|
20625
|
-
const manifestPath = join8(dir, "package.json");
|
|
20626
|
-
if (existsSync6(manifestPath)) {
|
|
20627
|
-
try {
|
|
20628
|
-
const manifest = JSON.parse(readFileSync7(manifestPath, "utf-8"));
|
|
20629
|
-
if (manifest.name === PKG_NAME && manifest.bin) {
|
|
20630
|
-
resolvedRoot = { dir, version: manifest.version, bin: manifest.bin };
|
|
20631
|
-
return resolvedRoot;
|
|
20632
|
-
}
|
|
20633
|
-
} catch {
|
|
20634
|
-
}
|
|
20635
|
-
}
|
|
20636
|
-
const parent = dirname5(dir);
|
|
20637
|
-
if (parent === dir) {
|
|
20638
|
-
break;
|
|
20639
|
-
}
|
|
20640
|
-
dir = parent;
|
|
20641
|
-
}
|
|
20642
|
-
resolvedRoot = null;
|
|
20643
|
-
return resolvedRoot;
|
|
20644
|
-
}
|
|
20645
|
-
function packageVersion() {
|
|
20646
|
-
return locateRoot()?.version ?? null;
|
|
20647
|
-
}
|
|
20648
|
-
function shellQuote(value) {
|
|
20649
|
-
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
20650
|
-
}
|
|
20651
|
-
var STABLE_HOOK_ARGUMENTS_RE = /^[-A-Za-z0-9_ ]*$/u;
|
|
20652
|
-
var STABLE_HOOK_BIN_RE = /^[A-Za-z0-9][A-Za-z0-9-]*$/u;
|
|
20653
|
-
var PRIM_CONFIG_SHELL_RESOLVER = [
|
|
20654
|
-
'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
|
|
20655
|
-
'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
|
|
20656
|
-
'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
|
|
20657
|
-
'else prim_home=${HOME:-}; prim_absolute "$prim_home" || exit 78; case "$prim_home" in /) prim_config=/.config/prim ;; *) prim_config="$prim_home/.config/prim" ;; esac; ',
|
|
20658
|
-
"fi; fi; "
|
|
20659
|
-
].join("");
|
|
20660
|
-
function stableHookCommand(bin, args = "") {
|
|
20661
|
-
if (!STABLE_HOOK_BIN_RE.test(bin) || !STABLE_HOOK_ARGUMENTS_RE.test(args)) {
|
|
20662
|
-
throw new Error("invalid stable hook command");
|
|
20663
|
-
}
|
|
20664
|
-
const resolver = [
|
|
20665
|
-
// #242 and earlier identify managed commands by this package marker. Keep
|
|
20666
|
-
// it as inert data during the rolling window so an older uninstall or
|
|
20667
|
-
// reinstall can remove the stable entry without invoking npm or PATH.
|
|
20668
|
-
`prim_legacy_reader='-p ${PKG_NAME}@stable prim-shim.sh ${bin} '; `,
|
|
20669
|
-
PRIM_CONFIG_SHELL_RESOLVER,
|
|
20670
|
-
`case "$prim_config" in /) prim_launcher=/${STABLE_HOOK_LAUNCHER_NAME} ;; *) prim_launcher="$prim_config/${STABLE_HOOK_LAUNCHER_NAME}" ;; esac; `,
|
|
20671
|
-
'exec "$prim_launcher" "$@"'
|
|
20672
|
-
].join("");
|
|
20673
|
-
const suffix = args ? ` ${args}` : "";
|
|
20674
|
-
return `/bin/sh -c ${shellQuote(resolver)} ${STABLE_HOOK_LAUNCHER_NAME} ${bin}${suffix}`;
|
|
20675
|
-
}
|
|
20676
|
-
function detachedHookShimCommand(bin, args = "") {
|
|
20677
|
-
return `payload=$(cat); { trap '' HUP; printf '%s' "$payload" | { ${stableHookCommand(bin, args)}; }; } </dev/null >/dev/null 2>&1 &`;
|
|
20678
|
-
}
|
|
20679
|
-
|
|
20680
20933
|
// src/lib/ingest-uploader.ts
|
|
20681
20934
|
var runtimeVersion = process.env.PRIM_RUNTIME_VERSION ?? packageVersion();
|
|
20682
20935
|
var VERSION_RE = /^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?(?:\+[A-Za-z0-9.-]+)?$/u;
|
|
@@ -20749,7 +21002,7 @@ var DEFAULT_API_URL = "https://api.getprimitive.ai";
|
|
|
20749
21002
|
var AUTH_EXPIRED_MESSAGE = "Authentication expired. Run `prim auth login` to re-authenticate.";
|
|
20750
21003
|
function readTrimmed2(path) {
|
|
20751
21004
|
try {
|
|
20752
|
-
const value =
|
|
21005
|
+
const value = readFileSync9(path, "utf8").trim();
|
|
20753
21006
|
return value || void 0;
|
|
20754
21007
|
} catch {
|
|
20755
21008
|
return void 0;
|
|
@@ -20765,17 +21018,17 @@ function expiresAtFor(token, expiresIn) {
|
|
|
20765
21018
|
return expiresIn === void 0 ? jwtExpiresAt(token) : Date.now() + expiresIn * 1e3;
|
|
20766
21019
|
}
|
|
20767
21020
|
function ensureConfigDirectory() {
|
|
20768
|
-
const directory =
|
|
20769
|
-
|
|
20770
|
-
|
|
21021
|
+
const directory = dirname7(TOKEN_FILE_PATH);
|
|
21022
|
+
mkdirSync4(directory, { recursive: true, mode: CONFIG_DIR_MODE });
|
|
21023
|
+
chmodSync3(directory, CONFIG_DIR_MODE);
|
|
20771
21024
|
}
|
|
20772
21025
|
function atomicWrite2(path, content) {
|
|
20773
21026
|
ensureConfigDirectory();
|
|
20774
21027
|
atomicWriteFile(path, content, { mode: CREDENTIAL_FILE_MODE });
|
|
20775
21028
|
}
|
|
20776
21029
|
function removeCredentialFile(path) {
|
|
20777
|
-
if (!
|
|
20778
|
-
|
|
21030
|
+
if (!existsSync9(path)) return false;
|
|
21031
|
+
rmSync4(path, { force: true });
|
|
20779
21032
|
return true;
|
|
20780
21033
|
}
|
|
20781
21034
|
function getTokenExpiresAt() {
|
|
@@ -20790,7 +21043,7 @@ function isTokenExpiringSoon(credential) {
|
|
|
20790
21043
|
return expiresAt !== void 0 && Date.now() >= expiresAt - REFRESH_THRESHOLD_MS;
|
|
20791
21044
|
}
|
|
20792
21045
|
function refreshFingerprint(refreshToken2) {
|
|
20793
|
-
return
|
|
21046
|
+
return createHash5("sha256").update(refreshToken2).digest("hex");
|
|
20794
21047
|
}
|
|
20795
21048
|
function legacyBrokerCredentialMetadata(accessToken, refreshToken2) {
|
|
20796
21049
|
return {
|
|
@@ -21549,22 +21802,22 @@ function scheduleCollectScopeRefresh(cwd, collectScopeVersion, dependencies = de
|
|
|
21549
21802
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
21550
21803
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
21551
21804
|
import {
|
|
21552
|
-
constants as
|
|
21553
|
-
chmodSync as
|
|
21805
|
+
constants as constants3,
|
|
21806
|
+
chmodSync as chmodSync4,
|
|
21554
21807
|
closeSync as closeSync2,
|
|
21555
21808
|
fchmodSync as fchmodSync2,
|
|
21556
21809
|
fsyncSync as fsyncSync2,
|
|
21557
21810
|
linkSync,
|
|
21558
|
-
lstatSync as
|
|
21559
|
-
mkdirSync as
|
|
21811
|
+
lstatSync as lstatSync5,
|
|
21812
|
+
mkdirSync as mkdirSync5,
|
|
21560
21813
|
openSync as openSync2,
|
|
21561
|
-
readFileSync as
|
|
21562
|
-
statSync as
|
|
21814
|
+
readFileSync as readFileSync10,
|
|
21815
|
+
statSync as statSync3,
|
|
21563
21816
|
unlinkSync,
|
|
21564
|
-
writeFileSync as
|
|
21817
|
+
writeFileSync as writeFileSync4
|
|
21565
21818
|
} from "fs";
|
|
21566
|
-
import { dirname as
|
|
21567
|
-
var WORKSPACE_ID_RELATIVE_PATH =
|
|
21819
|
+
import { dirname as dirname8, isAbsolute as isAbsolute5, join as join12, resolve as resolve5 } from "path";
|
|
21820
|
+
var WORKSPACE_ID_RELATIVE_PATH = join12("prim", "workspace-id");
|
|
21568
21821
|
var MAX_ANCESTORS = 64;
|
|
21569
21822
|
var MAX_GIT_FILE_BYTES = 4096;
|
|
21570
21823
|
var MAX_ID_FILE_BYTES = 128;
|
|
@@ -21610,7 +21863,7 @@ function resolveWorkspaceIdPath(cwd) {
|
|
|
21610
21863
|
}
|
|
21611
21864
|
return {
|
|
21612
21865
|
status: "resolved",
|
|
21613
|
-
path:
|
|
21866
|
+
path: isAbsolute5(gitPath) ? resolve5(gitPath) : resolve5(cwd, gitPath)
|
|
21614
21867
|
};
|
|
21615
21868
|
} catch (error) {
|
|
21616
21869
|
const code = errorCode(error);
|
|
@@ -21621,21 +21874,21 @@ function resolveWorkspaceIdPath(cwd) {
|
|
|
21621
21874
|
}
|
|
21622
21875
|
}
|
|
21623
21876
|
function resolveFromFilesystem(cwd) {
|
|
21624
|
-
let current =
|
|
21877
|
+
let current = resolve5(cwd);
|
|
21625
21878
|
for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
|
|
21626
|
-
const dotGit =
|
|
21879
|
+
const dotGit = join12(current, ".git");
|
|
21627
21880
|
try {
|
|
21628
|
-
const stat =
|
|
21881
|
+
const stat = lstatSync5(dotGit);
|
|
21629
21882
|
if (stat.isDirectory() && isGitDirectory(dotGit)) {
|
|
21630
|
-
return
|
|
21883
|
+
return join12(dotGit, WORKSPACE_ID_RELATIVE_PATH);
|
|
21631
21884
|
}
|
|
21632
21885
|
if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
|
|
21633
|
-
const contents =
|
|
21886
|
+
const contents = readFileSync10(dotGit, "utf8");
|
|
21634
21887
|
const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
|
|
21635
21888
|
if (match?.[1]) {
|
|
21636
|
-
const gitDirectory =
|
|
21889
|
+
const gitDirectory = isAbsolute5(match[1]) ? resolve5(match[1]) : resolve5(current, match[1]);
|
|
21637
21890
|
if (isGitDirectory(gitDirectory)) {
|
|
21638
|
-
return
|
|
21891
|
+
return join12(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
|
|
21639
21892
|
}
|
|
21640
21893
|
}
|
|
21641
21894
|
}
|
|
@@ -21646,7 +21899,7 @@ function resolveFromFilesystem(cwd) {
|
|
|
21646
21899
|
return null;
|
|
21647
21900
|
}
|
|
21648
21901
|
}
|
|
21649
|
-
const parent =
|
|
21902
|
+
const parent = dirname8(current);
|
|
21650
21903
|
if (parent === current) break;
|
|
21651
21904
|
current = parent;
|
|
21652
21905
|
}
|
|
@@ -21654,7 +21907,7 @@ function resolveFromFilesystem(cwd) {
|
|
|
21654
21907
|
}
|
|
21655
21908
|
function isGitDirectory(path) {
|
|
21656
21909
|
try {
|
|
21657
|
-
return
|
|
21910
|
+
return statSync3(join12(path, "HEAD")).isFile();
|
|
21658
21911
|
} catch {
|
|
21659
21912
|
return false;
|
|
21660
21913
|
}
|
|
@@ -21662,7 +21915,7 @@ function isGitDirectory(path) {
|
|
|
21662
21915
|
function inspectPath(path) {
|
|
21663
21916
|
let stat;
|
|
21664
21917
|
try {
|
|
21665
|
-
stat =
|
|
21918
|
+
stat = lstatSync5(path);
|
|
21666
21919
|
} catch (error) {
|
|
21667
21920
|
const code = errorCode(error);
|
|
21668
21921
|
if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing", path };
|
|
@@ -21673,7 +21926,7 @@ function inspectPath(path) {
|
|
|
21673
21926
|
return { status: "corrupt", path, reason: "invalid_content" };
|
|
21674
21927
|
}
|
|
21675
21928
|
try {
|
|
21676
|
-
const contents =
|
|
21929
|
+
const contents = readFileSync10(path, "utf8");
|
|
21677
21930
|
const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
|
|
21678
21931
|
if ((contents === workspaceId || contents === `${workspaceId}
|
|
21679
21932
|
`) && isCanonicalWorkspaceId(workspaceId)) {
|
|
@@ -21690,22 +21943,22 @@ function inspectPath(path) {
|
|
|
21690
21943
|
}
|
|
21691
21944
|
}
|
|
21692
21945
|
function createWorkspaceId(path) {
|
|
21693
|
-
const parent =
|
|
21946
|
+
const parent = dirname8(path);
|
|
21694
21947
|
const workspaceId = randomUUID3();
|
|
21695
|
-
const temporaryPath =
|
|
21948
|
+
const temporaryPath = join12(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
|
|
21696
21949
|
let temporaryCreated = false;
|
|
21697
21950
|
let publishing = false;
|
|
21698
21951
|
try {
|
|
21699
|
-
|
|
21700
|
-
|
|
21952
|
+
mkdirSync5(parent, { recursive: true, mode: 448 });
|
|
21953
|
+
chmodSync4(parent, 448);
|
|
21701
21954
|
const fd = openSync2(
|
|
21702
21955
|
temporaryPath,
|
|
21703
|
-
|
|
21956
|
+
constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY,
|
|
21704
21957
|
384
|
|
21705
21958
|
);
|
|
21706
21959
|
temporaryCreated = true;
|
|
21707
21960
|
try {
|
|
21708
|
-
|
|
21961
|
+
writeFileSync4(fd, `${workspaceId}
|
|
21709
21962
|
`, "utf8");
|
|
21710
21963
|
fchmodSync2(fd, 384);
|
|
21711
21964
|
fsyncSync2(fd);
|
|
@@ -21762,33 +22015,33 @@ function parseAgent(argv) {
|
|
|
21762
22015
|
}
|
|
21763
22016
|
|
|
21764
22017
|
// src/hooks/codex-context.ts
|
|
21765
|
-
import { createHash as
|
|
22018
|
+
import { createHash as createHash7, randomBytes as randomBytes5 } from "crypto";
|
|
21766
22019
|
import {
|
|
21767
|
-
chmodSync as
|
|
21768
|
-
existsSync as
|
|
21769
|
-
mkdirSync as
|
|
21770
|
-
readFileSync as
|
|
21771
|
-
readdirSync as
|
|
21772
|
-
renameSync as
|
|
21773
|
-
rmSync as
|
|
21774
|
-
statSync as
|
|
22020
|
+
chmodSync as chmodSync5,
|
|
22021
|
+
existsSync as existsSync10,
|
|
22022
|
+
mkdirSync as mkdirSync6,
|
|
22023
|
+
readFileSync as readFileSync11,
|
|
22024
|
+
readdirSync as readdirSync3,
|
|
22025
|
+
renameSync as renameSync3,
|
|
22026
|
+
rmSync as rmSync5,
|
|
22027
|
+
statSync as statSync4,
|
|
21775
22028
|
unlinkSync as unlinkSync2,
|
|
21776
|
-
writeFileSync as
|
|
22029
|
+
writeFileSync as writeFileSync5
|
|
21777
22030
|
} from "fs";
|
|
21778
|
-
import { join as
|
|
22031
|
+
import { join as join14 } from "path";
|
|
21779
22032
|
|
|
21780
22033
|
// src/daemon/client.ts
|
|
21781
22034
|
import { createConnection } from "net";
|
|
21782
|
-
import { join as
|
|
22035
|
+
import { join as join13 } from "path";
|
|
21783
22036
|
|
|
21784
22037
|
// src/daemon/principal.ts
|
|
21785
|
-
import { createHash as
|
|
22038
|
+
import { createHash as createHash6 } from "crypto";
|
|
21786
22039
|
var PRINCIPAL_COMPONENT_MAX_LENGTH = 512;
|
|
21787
22040
|
function boundedClaim(value) {
|
|
21788
22041
|
return typeof value === "string" && value.length > 0 && value.length <= PRINCIPAL_COMPONENT_MAX_LENGTH ? value : void 0;
|
|
21789
22042
|
}
|
|
21790
22043
|
function sha256(value) {
|
|
21791
|
-
return
|
|
22044
|
+
return createHash6("sha256").update(value).digest("hex");
|
|
21792
22045
|
}
|
|
21793
22046
|
function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
|
|
21794
22047
|
if (!token) return void 0;
|
|
@@ -21829,7 +22082,7 @@ function parseDaemonResponseEnvelope(value) {
|
|
|
21829
22082
|
}
|
|
21830
22083
|
|
|
21831
22084
|
// src/daemon/client.ts
|
|
21832
|
-
var SOCK_PATH =
|
|
22085
|
+
var SOCK_PATH = join13(primConfigDirectory(), "sock");
|
|
21833
22086
|
var DEFAULT_TIMEOUT_MS2 = 250;
|
|
21834
22087
|
var nextRequestId = 1;
|
|
21835
22088
|
function daemonRequest(method, params = {}, opts = {}) {
|
|
@@ -21917,7 +22170,7 @@ function daemonRequest(method, params = {}, opts = {}) {
|
|
|
21917
22170
|
}
|
|
21918
22171
|
|
|
21919
22172
|
// src/daemon/decision-digest-cache.ts
|
|
21920
|
-
import { randomBytes as
|
|
22173
|
+
import { randomBytes as randomBytes4 } from "crypto";
|
|
21921
22174
|
var DECISION_DIGEST_CACHE_LIMIT = 100;
|
|
21922
22175
|
var DECISION_DIGEST_CACHE_WINDOW = "24h";
|
|
21923
22176
|
var DECISION_DIGEST_CACHE_PATH = `/api/cli/decisions/recent?limit=${String(DECISION_DIGEST_CACHE_LIMIT)}&since=${DECISION_DIGEST_CACHE_WINDOW}`;
|
|
@@ -22130,10 +22383,10 @@ function appendCodexContext(output, context) {
|
|
|
22130
22383
|
return next;
|
|
22131
22384
|
}
|
|
22132
22385
|
function stateRoot(namespace) {
|
|
22133
|
-
return
|
|
22386
|
+
return join14(primConfigDirectory(), namespace, "decision-digests");
|
|
22134
22387
|
}
|
|
22135
22388
|
function draftStateRoot(namespace) {
|
|
22136
|
-
return
|
|
22389
|
+
return join14(primConfigDirectory(), namespace, "decision-draft-deliveries");
|
|
22137
22390
|
}
|
|
22138
22391
|
function workspaceFor(cwd) {
|
|
22139
22392
|
try {
|
|
@@ -22144,13 +22397,13 @@ function workspaceFor(cwd) {
|
|
|
22144
22397
|
}
|
|
22145
22398
|
function statePath(args) {
|
|
22146
22399
|
const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}`;
|
|
22147
|
-
const key =
|
|
22148
|
-
return
|
|
22400
|
+
const key = createHash7("sha256").update(identity).digest("hex");
|
|
22401
|
+
return join14(stateRoot(args.namespace), `${key}.json`);
|
|
22149
22402
|
}
|
|
22150
22403
|
function draftStatePath(args) {
|
|
22151
22404
|
const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}\0${args.principalId}\0${args.organizationId}\0${args.credentialFingerprint}`;
|
|
22152
|
-
const key =
|
|
22153
|
-
return
|
|
22405
|
+
const key = createHash7("sha256").update(identity).digest("hex");
|
|
22406
|
+
return join14(draftStateRoot(args.namespace), `${key}.json`);
|
|
22154
22407
|
}
|
|
22155
22408
|
function parseState(value) {
|
|
22156
22409
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
@@ -22189,37 +22442,37 @@ function parseDraftState(value) {
|
|
|
22189
22442
|
};
|
|
22190
22443
|
}
|
|
22191
22444
|
function readState(path) {
|
|
22192
|
-
if (!
|
|
22445
|
+
if (!existsSync10(path)) return void 0;
|
|
22193
22446
|
try {
|
|
22194
|
-
return parseState(JSON.parse(
|
|
22447
|
+
return parseState(JSON.parse(readFileSync11(path, "utf8")));
|
|
22195
22448
|
} catch {
|
|
22196
22449
|
return void 0;
|
|
22197
22450
|
}
|
|
22198
22451
|
}
|
|
22199
22452
|
function readDraftState(path) {
|
|
22200
|
-
if (!
|
|
22453
|
+
if (!existsSync10(path)) return void 0;
|
|
22201
22454
|
try {
|
|
22202
|
-
return parseDraftState(JSON.parse(
|
|
22455
|
+
return parseDraftState(JSON.parse(readFileSync11(path, "utf8")));
|
|
22203
22456
|
} catch {
|
|
22204
22457
|
return void 0;
|
|
22205
22458
|
}
|
|
22206
22459
|
}
|
|
22207
22460
|
function writeStateFile(path, directory, state) {
|
|
22208
|
-
|
|
22209
|
-
|
|
22210
|
-
const temporary =
|
|
22461
|
+
mkdirSync6(directory, { recursive: true, mode: 448 });
|
|
22462
|
+
chmodSync5(directory, 448);
|
|
22463
|
+
const temporary = join14(
|
|
22211
22464
|
directory,
|
|
22212
|
-
`.${path.slice(directory.length + 1)}.tmp-${process.pid}-${
|
|
22465
|
+
`.${path.slice(directory.length + 1)}.tmp-${process.pid}-${randomBytes5(8).toString("hex")}`
|
|
22213
22466
|
);
|
|
22214
22467
|
try {
|
|
22215
|
-
|
|
22468
|
+
writeFileSync5(temporary, `${JSON.stringify(state)}
|
|
22216
22469
|
`, {
|
|
22217
22470
|
encoding: "utf8",
|
|
22218
22471
|
mode: 384,
|
|
22219
22472
|
flag: "wx"
|
|
22220
22473
|
});
|
|
22221
|
-
|
|
22222
|
-
|
|
22474
|
+
chmodSync5(temporary, 384);
|
|
22475
|
+
renameSync3(temporary, path);
|
|
22223
22476
|
} finally {
|
|
22224
22477
|
try {
|
|
22225
22478
|
unlinkSync2(temporary);
|
|
@@ -22228,19 +22481,19 @@ function writeStateFile(path, directory, state) {
|
|
|
22228
22481
|
}
|
|
22229
22482
|
}
|
|
22230
22483
|
function cleanupStateFiles(directory, now) {
|
|
22231
|
-
if (!
|
|
22484
|
+
if (!existsSync10(directory)) return;
|
|
22232
22485
|
let names;
|
|
22233
22486
|
try {
|
|
22234
|
-
names =
|
|
22487
|
+
names = readdirSync3(directory);
|
|
22235
22488
|
} catch {
|
|
22236
22489
|
return;
|
|
22237
22490
|
}
|
|
22238
22491
|
const files = [];
|
|
22239
22492
|
const residue = [];
|
|
22240
22493
|
for (const name of names) {
|
|
22241
|
-
const path =
|
|
22494
|
+
const path = join14(directory, name);
|
|
22242
22495
|
try {
|
|
22243
|
-
const mtimeMs =
|
|
22496
|
+
const mtimeMs = statSync4(path).mtimeMs;
|
|
22244
22497
|
if (name.endsWith(".json")) {
|
|
22245
22498
|
files.push({ path, mtimeMs });
|
|
22246
22499
|
} else if ((name.includes(".json.tmp-") || name.endsWith(".json.lock")) && now - mtimeMs > CODEX_DIGEST_STATE_RETENTION_MS) {
|
|
@@ -22259,8 +22512,8 @@ function cleanupStateFiles(directory, now) {
|
|
|
22259
22512
|
}
|
|
22260
22513
|
for (const path of residue) {
|
|
22261
22514
|
try {
|
|
22262
|
-
if (now -
|
|
22263
|
-
|
|
22515
|
+
if (now - statSync4(path).mtimeMs > CODEX_DIGEST_STATE_RETENTION_MS) {
|
|
22516
|
+
rmSync5(path, { recursive: true, force: true });
|
|
22264
22517
|
}
|
|
22265
22518
|
} catch {
|
|
22266
22519
|
}
|
|
@@ -22543,126 +22796,14 @@ async function prepareCodexContext(options) {
|
|
|
22543
22796
|
}
|
|
22544
22797
|
|
|
22545
22798
|
// src/commands/cursor-install.ts
|
|
22546
|
-
import { existsSync as
|
|
22799
|
+
import { existsSync as existsSync12, readFileSync as readFileSync13 } from "fs";
|
|
22547
22800
|
import { homedir as homedir4 } from "os";
|
|
22548
|
-
import { isAbsolute as isAbsolute6, join as
|
|
22549
|
-
|
|
22550
|
-
// src/lib/hook-runtime.ts
|
|
22551
|
-
import { createHash as createHash7, randomBytes as randomBytes5 } from "crypto";
|
|
22552
|
-
import {
|
|
22553
|
-
constants as constants3,
|
|
22554
|
-
accessSync,
|
|
22555
|
-
chmodSync as chmodSync5,
|
|
22556
|
-
copyFileSync,
|
|
22557
|
-
existsSync as existsSync9,
|
|
22558
|
-
lstatSync as lstatSync5,
|
|
22559
|
-
mkdirSync as mkdirSync6,
|
|
22560
|
-
mkdtempSync,
|
|
22561
|
-
readFileSync as readFileSync11,
|
|
22562
|
-
readdirSync as readdirSync3,
|
|
22563
|
-
realpathSync as realpathSync2,
|
|
22564
|
-
renameSync as renameSync3,
|
|
22565
|
-
rmSync as rmSync5,
|
|
22566
|
-
statSync as statSync4,
|
|
22567
|
-
utimesSync,
|
|
22568
|
-
writeFileSync as writeFileSync5
|
|
22569
|
-
} from "fs";
|
|
22570
|
-
import { delimiter, dirname as dirname8, isAbsolute as isAbsolute5, join as join13, resolve as resolve5 } from "path";
|
|
22571
|
-
|
|
22572
|
-
// src/lib/git-hook-contract.ts
|
|
22573
|
-
var GIT_HOOK_ENTRYPOINT_CONTENT = `#!/bin/sh
|
|
22574
|
-
# prim git hook entrypoint v1 \u2014 managed by prim; do not edit.
|
|
22575
|
-
# Run by the "# >>> prim <hook> hook >>>" block in a Git hook file. Acts only
|
|
22576
|
-
# where prim is active (git config prim.active true) and never fails the hook.
|
|
22577
|
-
case "$0" in */*) prim_dir=\${0%/*} ;; *) exit 0 ;; esac
|
|
22578
|
-
prim_launcher="$prim_dir/${STABLE_HOOK_LAUNCHER_NAME}"
|
|
22579
|
-
[ -x "$prim_launcher" ] || exit 0
|
|
22580
|
-
[ "$(git config --get prim.active 2>/dev/null)" = "true" ] || exit 0
|
|
22581
|
-
prim_hook=\${1-}
|
|
22582
|
-
if [ "$#" -gt 0 ]; then shift; fi
|
|
22583
|
-
case "$prim_hook" in
|
|
22584
|
-
pre-commit)
|
|
22585
|
-
"$prim_launcher" prim-pre-commit "$@" || :
|
|
22586
|
-
;;
|
|
22587
|
-
post-commit)
|
|
22588
|
-
prim_sha=$(git rev-parse --verify HEAD 2>/dev/null) || exit 0
|
|
22589
|
-
case "$prim_sha" in *[!0-9a-f]* | "") exit 0 ;; esac
|
|
22590
|
-
case "\${#prim_sha}" in 40 | 64) ;; *) exit 0 ;; esac
|
|
22591
|
-
prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
|
|
22592
|
-
prim_observed=$(mktemp "\${TMPDIR:-/tmp}/prim-post-commit-observed.XXXXXXXX" 2>/dev/null) || prim_observed=
|
|
22593
|
-
(
|
|
22594
|
-
trap '' HUP
|
|
22595
|
-
trap 'if [ -n "$prim_observed" ]; then rm -f "$prim_observed"; fi' 0
|
|
22596
|
-
PRIM_COMMIT_SHA=$prim_sha PRIM_COMMIT_BRANCH=$prim_branch PRIM_COMMIT_OBSERVED_FILE=$prim_observed "$prim_launcher" prim-post-commit
|
|
22597
|
-
) </dev/null >/dev/null 2>&1 &
|
|
22598
|
-
;;
|
|
22599
|
-
post-rewrite)
|
|
22600
|
-
case "\${1-}" in amend | rebase) prim_source=$1 ;; *) exit 0 ;; esac
|
|
22601
|
-
prim_pairs=$(mktemp "\${TMPDIR:-/tmp}/prim-post-rewrite-pairs.XXXXXXXX" 2>/dev/null) || exit 0
|
|
22602
|
-
if ! chmod 600 "$prim_pairs" 2>/dev/null || ! cat >"$prim_pairs"; then
|
|
22603
|
-
rm -f "$prim_pairs"
|
|
22604
|
-
exit 0
|
|
22605
|
-
fi
|
|
22606
|
-
prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
|
|
22607
|
-
(
|
|
22608
|
-
trap '' HUP
|
|
22609
|
-
trap 'rm -f "$prim_pairs"' 0
|
|
22610
|
-
PRIM_REWRITE_SOURCE=$prim_source PRIM_REWRITE_BRANCH=$prim_branch PRIM_REWRITE_PAIRS_FILE=$prim_pairs "$prim_launcher" prim-post-rewrite
|
|
22611
|
-
) </dev/null >/dev/null 2>&1 &
|
|
22612
|
-
;;
|
|
22613
|
-
esac
|
|
22614
|
-
exit 0
|
|
22615
|
-
`;
|
|
22616
|
-
|
|
22617
|
-
// src/lib/hook-runtime.ts
|
|
22618
|
-
var RELEASE_PREFIX = "release-";
|
|
22619
|
-
var MAX_MANIFEST_BYTES = 64 * 1024;
|
|
22620
|
-
var RELEASE_GRACE_MS = 10 * 60 * 1e3;
|
|
22621
|
-
var HOOK_RUNTIME_ENTRIES = {
|
|
22622
|
-
// SessionStart self-healing resolves this exact CLI entry to run
|
|
22623
|
-
// `daemon ensure`; it must travel with the immutable hook release.
|
|
22624
|
-
prim: "dist/index.js",
|
|
22625
|
-
"prim-hook": "dist/hooks/prim-hook.js",
|
|
22626
|
-
"prim-pre-commit": "dist/hooks/pre-commit.js",
|
|
22627
|
-
"prim-post-commit": "dist/hooks/post-commit.js",
|
|
22628
|
-
"prim-post-rewrite": "dist/hooks/post-rewrite.js",
|
|
22629
|
-
"prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
|
|
22630
|
-
"prim-post-tool-use": "dist/hooks/post-tool-use.js",
|
|
22631
|
-
"prim-session-start": "dist/hooks/session-start.js",
|
|
22632
|
-
"prim-session-end": "dist/hooks/session-end.js",
|
|
22633
|
-
"prim-daemon-server": "dist/daemon/server.js",
|
|
22634
|
-
"prim-statusline": "dist/statusline-main.js"
|
|
22635
|
-
};
|
|
22636
|
-
var SOURCE_ENTRIES = Object.fromEntries(
|
|
22637
|
-
Object.entries(HOOK_RUNTIME_ENTRIES).map(([bin, target]) => [
|
|
22638
|
-
bin,
|
|
22639
|
-
target.replace(/^dist\//u, "")
|
|
22640
|
-
])
|
|
22641
|
-
);
|
|
22642
|
-
var STABLE_HOOK_LAUNCHER_CONTENT = `#!/bin/sh
|
|
22643
|
-
set -eu
|
|
22644
|
-
case "$0" in */*) prim_launcher_dir=\${0%/*} ;; *) exit 78 ;; esac
|
|
22645
|
-
IFS= read -r prim_release_name < "$prim_launcher_dir/hook-runtime/current" || exit 69
|
|
22646
|
-
case "$prim_release_name" in ${RELEASE_PREFIX}*) ;; *) exit 69 ;; esac
|
|
22647
|
-
prim_release_id=\${prim_release_name#${RELEASE_PREFIX}}
|
|
22648
|
-
case "$prim_release_id" in *[!0-9a-f]*|"") exit 69 ;; esac
|
|
22649
|
-
[ "\${#prim_release_id}" -eq 64 ] || exit 69
|
|
22650
|
-
prim_release="$prim_launcher_dir/hook-runtime/releases/$prim_release_name"
|
|
22651
|
-
case "\${1-}" in
|
|
22652
|
-
${Object.entries(HOOK_RUNTIME_ENTRIES).map(([bin, entry]) => ` ${bin}) prim_entry="$prim_release/${entry}" ;;`).join("\n")}
|
|
22653
|
-
*) exit 64 ;;
|
|
22654
|
-
esac
|
|
22655
|
-
shift
|
|
22656
|
-
IFS= read -r prim_node < "$prim_release/node" || exit 69
|
|
22657
|
-
case "$prim_node" in /*) ;; *) exit 69 ;; esac
|
|
22658
|
-
[ -x "$prim_node" ] && [ -f "$prim_entry" ] || exit 69
|
|
22659
|
-
exec "$prim_node" "$prim_entry" "$@"
|
|
22660
|
-
`;
|
|
22801
|
+
import { isAbsolute as isAbsolute6, join as join16 } from "path";
|
|
22661
22802
|
|
|
22662
22803
|
// src/commands/claude-install.ts
|
|
22663
|
-
import { existsSync as
|
|
22804
|
+
import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
|
|
22664
22805
|
import { homedir as homedir3 } from "os";
|
|
22665
|
-
import { join as
|
|
22806
|
+
import { join as join15 } from "path";
|
|
22666
22807
|
var CAPTURE_BIN = "prim-hook";
|
|
22667
22808
|
var GATE_BIN = "prim-pre-tool-use";
|
|
22668
22809
|
var POST_TOOL_USE_BIN = "prim-post-tool-use";
|
|
@@ -22671,7 +22812,7 @@ var SESSION_END_BIN = "prim-session-end";
|
|
|
22671
22812
|
var STATUSLINE_BIN = "prim-statusline";
|
|
22672
22813
|
var STATUSLINE_ARGS = "";
|
|
22673
22814
|
var STATUSLINE_COMMAND = stableHookCommand(STATUSLINE_BIN, STATUSLINE_ARGS);
|
|
22674
|
-
var USER_SCOPE_PATH =
|
|
22815
|
+
var USER_SCOPE_PATH = join15(homedir3(), ".claude", "settings.json");
|
|
22675
22816
|
function projectRoot() {
|
|
22676
22817
|
return gitToplevel() ?? process.cwd();
|
|
22677
22818
|
}
|
|
@@ -22750,17 +22891,17 @@ function cursorConfigDirectory(env = process.env, home = homedir4(), platform2 =
|
|
|
22750
22891
|
const explicit = env.CURSOR_CONFIG_DIR?.trim();
|
|
22751
22892
|
if (explicit && isAbsolute6(explicit)) return explicit;
|
|
22752
22893
|
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
22753
|
-
if (platform2 !== "darwin" && xdg && isAbsolute6(xdg)) return
|
|
22754
|
-
return
|
|
22894
|
+
if (platform2 !== "darwin" && xdg && isAbsolute6(xdg)) return join16(xdg, "cursor");
|
|
22895
|
+
return join16(home, ".cursor");
|
|
22755
22896
|
}
|
|
22756
22897
|
function cursorHooksPath(scope, root = projectRoot()) {
|
|
22757
|
-
return scope === "user" ?
|
|
22898
|
+
return scope === "user" ? join16(cursorConfigDirectory(), "hooks.json") : join16(root, ".cursor", "hooks.json");
|
|
22758
22899
|
}
|
|
22759
22900
|
function plainObject(value) {
|
|
22760
22901
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22761
22902
|
}
|
|
22762
22903
|
function readCursorHooks(path) {
|
|
22763
|
-
if (!
|
|
22904
|
+
if (!existsSync12(path)) return {};
|
|
22764
22905
|
let parsed;
|
|
22765
22906
|
try {
|
|
22766
22907
|
parsed = JSON.parse(readFileSync13(path, "utf8"));
|
|
@@ -22983,8 +23124,8 @@ function extractFileTargets(toolName, toolInput, agent = "claude_code") {
|
|
|
22983
23124
|
}
|
|
22984
23125
|
|
|
22985
23126
|
// src/hooks/redact.ts
|
|
22986
|
-
import { existsSync as
|
|
22987
|
-
import { join as
|
|
23127
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, statSync as statSync5 } from "fs";
|
|
23128
|
+
import { join as join17 } from "path";
|
|
22988
23129
|
import { Worker } from "worker_threads";
|
|
22989
23130
|
var USER_HOME_RULES = [
|
|
22990
23131
|
{
|
|
@@ -23060,8 +23201,8 @@ function normalizedWorkspaceFlags(value) {
|
|
|
23060
23201
|
return [...new Set(`g${requested}`)].sort().join("");
|
|
23061
23202
|
}
|
|
23062
23203
|
function loadWorkspaceRules(cwd) {
|
|
23063
|
-
const path =
|
|
23064
|
-
if (!
|
|
23204
|
+
const path = join17(cwd, WORKSPACE_FILE2);
|
|
23205
|
+
if (!existsSync13(path)) return [];
|
|
23065
23206
|
let cfg;
|
|
23066
23207
|
try {
|
|
23067
23208
|
if (statSync5(path).size > MAX_WORKSPACE_CONFIG_BYTES) {
|
|
@@ -27994,7 +28135,7 @@ function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd(
|
|
|
27994
28135
|
import {
|
|
27995
28136
|
appendFileSync,
|
|
27996
28137
|
closeSync as closeSync3,
|
|
27997
|
-
existsSync as
|
|
28138
|
+
existsSync as existsSync15,
|
|
27998
28139
|
fstatSync,
|
|
27999
28140
|
mkdirSync as mkdirSync7,
|
|
28000
28141
|
openSync as openSync3,
|
|
@@ -28003,21 +28144,21 @@ import {
|
|
|
28003
28144
|
readSync,
|
|
28004
28145
|
readdirSync as readdirSync5
|
|
28005
28146
|
} from "fs";
|
|
28006
|
-
import { dirname as dirname11, join as
|
|
28147
|
+
import { dirname as dirname11, join as join19 } from "path";
|
|
28007
28148
|
|
|
28008
28149
|
// src/drain-progress.ts
|
|
28009
28150
|
import {
|
|
28010
28151
|
chmodSync as chmodSync6,
|
|
28011
|
-
existsSync as
|
|
28152
|
+
existsSync as existsSync14,
|
|
28012
28153
|
readFileSync as readFileSync15,
|
|
28013
28154
|
readdirSync as readdirSync4,
|
|
28014
28155
|
rmSync as rmSync6,
|
|
28015
28156
|
rmdirSync
|
|
28016
28157
|
} from "fs";
|
|
28017
|
-
import { basename as basename2, dirname as dirname10, join as
|
|
28158
|
+
import { basename as basename2, dirname as dirname10, join as join18 } from "path";
|
|
28018
28159
|
|
|
28019
28160
|
// src/journal.ts
|
|
28020
|
-
var JOURNAL_DIR =
|
|
28161
|
+
var JOURNAL_DIR = join19(primConfigDirectory(), "moves");
|
|
28021
28162
|
var UNBOUND_BUCKET = "_unbound";
|
|
28022
28163
|
var JOURNAL_BASENAME = "journal.ndjson";
|
|
28023
28164
|
var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
|
|
@@ -28029,7 +28170,7 @@ function envSlug(apiUrl) {
|
|
|
28029
28170
|
return slug;
|
|
28030
28171
|
}
|
|
28031
28172
|
function currentEnvDir() {
|
|
28032
|
-
return
|
|
28173
|
+
return join19(JOURNAL_DIR, envSlug(getSiteUrl()));
|
|
28033
28174
|
}
|
|
28034
28175
|
var DIR_MODE = 448;
|
|
28035
28176
|
var FILE_MODE2 = 384;
|
|
@@ -28037,7 +28178,7 @@ var SAFE_BUCKET = /^[A-Za-z0-9_-]+$/;
|
|
|
28037
28178
|
var RESERVED_BUCKETS = /* @__PURE__ */ new Set([UNBOUND_BUCKET, "_legacy"]);
|
|
28038
28179
|
function appendMoveToPath(path, move) {
|
|
28039
28180
|
const dir = dirname11(path);
|
|
28040
|
-
if (!
|
|
28181
|
+
if (!existsSync15(dir)) {
|
|
28041
28182
|
mkdirSync7(dir, { recursive: true, mode: DIR_MODE });
|
|
28042
28183
|
}
|
|
28043
28184
|
appendFileSync(path, `${JSON.stringify(move)}
|
|
@@ -28045,10 +28186,10 @@ function appendMoveToPath(path, move) {
|
|
|
28045
28186
|
}
|
|
28046
28187
|
function bucketDir(orgId) {
|
|
28047
28188
|
const safe = orgId !== void 0 && SAFE_BUCKET.test(orgId) && !RESERVED_BUCKETS.has(orgId);
|
|
28048
|
-
return
|
|
28189
|
+
return join19(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
|
|
28049
28190
|
}
|
|
28050
28191
|
function journalPath(orgId) {
|
|
28051
|
-
return
|
|
28192
|
+
return join19(bucketDir(orgId), JOURNAL_BASENAME);
|
|
28052
28193
|
}
|
|
28053
28194
|
function appendMove(move, orgId) {
|
|
28054
28195
|
appendMoveToPath(journalPath(orgId), move);
|
|
@@ -28220,7 +28361,7 @@ function editingToolsFor(agent) {
|
|
|
28220
28361
|
var here = dirname12(fileURLToPath2(import.meta.url));
|
|
28221
28362
|
function resolveCliVersion() {
|
|
28222
28363
|
try {
|
|
28223
|
-
const pkg = JSON.parse(readFileSync17(
|
|
28364
|
+
const pkg = JSON.parse(readFileSync17(join20(here, "..", "..", "package.json"), "utf-8"));
|
|
28224
28365
|
return pkg.version ?? "unknown";
|
|
28225
28366
|
} catch {
|
|
28226
28367
|
return "unknown";
|