@primitive.ai/prim 0.1.0-alpha.101 → 0.1.0-alpha.103

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.
@@ -53,8 +53,8 @@ var require_ucs2length = __commonJS({
53
53
 
54
54
  // src/hooks/prim-hook.ts
55
55
  import { spawn } from "child_process";
56
- import { readFileSync as readFileSync17 } from "fs";
57
- import { dirname as dirname13, join as join19 } from "path";
56
+ import { readFileSync as readFileSync18 } from "fs";
57
+ import { dirname as dirname13, join as join20 } from "path";
58
58
  import { fileURLToPath as fileURLToPath2 } from "url";
59
59
 
60
60
  // src/binding.ts
@@ -613,14 +613,14 @@ function throwIfAborted(signal) {
613
613
  }
614
614
  async function defaultSleep(ms, signal) {
615
615
  if (!signal) {
616
- await new Promise((resolve7) => setTimeout(resolve7, ms));
616
+ await new Promise((resolve8) => setTimeout(resolve8, ms));
617
617
  return;
618
618
  }
619
619
  throwIfAborted(signal);
620
- await new Promise((resolve7, reject) => {
620
+ await new Promise((resolve8, reject) => {
621
621
  const timer = setTimeout(() => {
622
622
  signal.removeEventListener("abort", onAbort);
623
- resolve7();
623
+ resolve8();
624
624
  }, ms);
625
625
  const onAbort = () => {
626
626
  clearTimeout(timer);
@@ -630,6 +630,33 @@ async function defaultSleep(ms, signal) {
630
630
  });
631
631
  }
632
632
  var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
633
+ function defaultSleepSync(ms) {
634
+ Atomics.wait(syncSleeper, 0, 0, ms);
635
+ }
636
+ function withFileLockSync(lockDir, operation, options = {}) {
637
+ mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
638
+ const nowMs = options.nowMs ?? Date.now;
639
+ const alive = options.processAlive ?? processIsAlive;
640
+ const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
641
+ let owner = null;
642
+ while (!owner) {
643
+ const now = nowMs();
644
+ owner = tryTakeLock(lockDir, now);
645
+ if (owner) break;
646
+ recoverStaleLock(lockDir, now, alive, options.initGraceMs ?? DEFAULT_INIT_GRACE_MS);
647
+ if (now >= deadline) {
648
+ throw new Error(`timed out waiting for file lock ${lockDir}`);
649
+ }
650
+ (options.sleep ?? defaultSleepSync)(options.pollMs ?? DEFAULT_POLL_MS);
651
+ }
652
+ try {
653
+ return operation();
654
+ } finally {
655
+ if (sameOwner(readOwner(lockDir), owner)) {
656
+ rmSync2(lockDir, { recursive: true, force: true });
657
+ }
658
+ }
659
+ }
633
660
  async function withFileLock(lockDir, operation, options = {}) {
634
661
  mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
635
662
  const nowMs = options.nowMs ?? Date.now;
@@ -1507,34 +1534,140 @@ async function acknowledgeDecisionFeedback(input, dependencies = {}) {
1507
1534
  }
1508
1535
  }
1509
1536
 
1537
+ // src/demo/isolation.ts
1538
+ import { existsSync as existsSync6 } from "fs";
1539
+
1540
+ // src/demo/state.ts
1541
+ import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
1542
+ import { existsSync as existsSync5, lstatSync as lstatSync2, readFileSync as readFileSync7, readdirSync } from "fs";
1543
+ import { join as join8, resolve as resolve2 } from "path";
1544
+ 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;
1545
+ var demoDirectory = () => join8(primConfigDirectory(), "demo");
1546
+ var runPath = (id) => {
1547
+ if (!RUN_ID.test(id)) throw new Error("invalid demo run ID");
1548
+ return join8(demoDirectory(), "runs", `${id}.json`);
1549
+ };
1550
+ function readDemoJson(path) {
1551
+ const stat = lstatSync2(path);
1552
+ if (!stat.isFile() || stat.size > 16384) throw new Error(`invalid demo state: ${path}`);
1553
+ return JSON.parse(readFileSync7(path, "utf8"));
1554
+ }
1555
+ function saveDemoJson(path, value) {
1556
+ atomicWriteFile(path, `${JSON.stringify(value)}
1557
+ `, { mode: 384, ensureParent: true });
1558
+ }
1559
+ function readRun(id) {
1560
+ const run = readDemoJson(runPath(id));
1561
+ if (run.version !== 1 || run.id !== id || !["prepared", "proposal", "conflict", "completed", "skipped"].includes(run.stage) || typeof run.terminal !== "boolean" || !Array.isArray(run.launcher) || run.launcher.length !== 2 || run.launcher.some((value) => typeof value !== "string" || !value.startsWith("/")) || run.agent !== void 0 && !["claude_code", "codex", "cursor", "hermes"].includes(run.agent)) {
1562
+ throw new Error("invalid demo run state");
1563
+ }
1564
+ return run;
1565
+ }
1566
+ var saveRun = (run) => saveDemoJson(runPath(run.id), run);
1567
+ var lockRun = (id, action) => withFileLockSync(`${runPath(id)}.lock`, () => action(readRun(id)), { timeoutMs: 500 });
1568
+ var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
1569
+ function demoCommand(run, action, choice) {
1570
+ return [
1571
+ ...run.launcher,
1572
+ "demo",
1573
+ action,
1574
+ run.id,
1575
+ ...choice === void 0 ? [] : ["--choice", choice]
1576
+ ].map(quote).join(" ");
1577
+ }
1578
+ function sessionKey(agent, session) {
1579
+ return createHash3("sha256").update(`${agent}\0${session}`).digest("hex");
1580
+ }
1581
+ function exclusionPath(key) {
1582
+ if (!/^[0-9a-f]{64}$/u.test(key)) throw new Error("invalid demo session identity");
1583
+ return join8(demoDirectory(), "excluded-sessions", `${key}.json`);
1584
+ }
1585
+ function sessionExcluded(agent, session) {
1586
+ if (typeof session !== "string" || !session) return false;
1587
+ const path = exclusionPath(sessionKey(agent, session));
1588
+ if (!existsSync5(path)) return false;
1589
+ const record = readDemoJson(path);
1590
+ if (typeof record.runId !== "string" || !RUN_ID.test(record.runId)) {
1591
+ throw new Error("invalid demo capture exclusion");
1592
+ }
1593
+ return true;
1594
+ }
1595
+
1596
+ // src/demo/isolation.ts
1597
+ function observeDemoInvocation(envelope, agent, checkExclusion = true) {
1598
+ const session = typeof envelope.session_id === "string" && envelope.session_id ? envelope.session_id : agent === "hermes" ? envelope.extra?.session_key : void 0;
1599
+ let invocation = false;
1600
+ if (envelope.hook_event_name === "PreToolUse" && typeof session === "string" && session) {
1601
+ const tool = agent === "cursor" ? "Shell" : agent === "hermes" ? "terminal" : "Bash";
1602
+ const input = envelope.tool_input;
1603
+ const command = input?.command;
1604
+ if (envelope.tool_name === tool && typeof command === "string" && command.length < 8192) {
1605
+ const ids = command.match(
1606
+ /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gu
1607
+ );
1608
+ if (ids?.length === 1 && existsSync6(runPath(ids[0]))) {
1609
+ invocation = lockRun(ids[0], (run) => {
1610
+ const actions = [
1611
+ ["start"],
1612
+ ["confirm"],
1613
+ ["resolve", "repository"],
1614
+ ["resolve", "local-storage"],
1615
+ ["skip"]
1616
+ ];
1617
+ const match = actions.find(
1618
+ ([action, choice]) => demoCommand(run, action, choice) === command
1619
+ );
1620
+ if (run.terminal || !match) {
1621
+ return false;
1622
+ }
1623
+ if (match[0] === "skip") return true;
1624
+ const key = sessionKey(agent, session);
1625
+ if (run.agent && run.agent !== agent || run.binding && run.binding !== key) {
1626
+ run.acknowledgment = void 0;
1627
+ saveRun(run);
1628
+ return false;
1629
+ }
1630
+ saveDemoJson(exclusionPath(key), { runId: run.id });
1631
+ run.binding = key;
1632
+ run.agent = agent;
1633
+ run.acknowledgment = { command, at: Date.now() };
1634
+ saveRun(run);
1635
+ return true;
1636
+ });
1637
+ }
1638
+ }
1639
+ }
1640
+ return { invocation, excluded: checkExclusion && sessionExcluded(agent, session) };
1641
+ }
1642
+
1510
1643
  // src/journal.ts
1511
1644
  import {
1512
1645
  appendFileSync,
1513
1646
  closeSync as closeSync2,
1514
- existsSync as existsSync6,
1647
+ existsSync as existsSync8,
1515
1648
  fstatSync,
1516
1649
  mkdirSync as mkdirSync4,
1517
1650
  openSync as openSync2,
1518
1651
  opendirSync,
1519
- readFileSync as readFileSync8,
1652
+ readFileSync as readFileSync9,
1520
1653
  readSync,
1521
- readdirSync as readdirSync2
1654
+ readdirSync as readdirSync3
1522
1655
  } from "fs";
1523
- import { dirname as dirname7, join as join9 } from "path";
1656
+ import { dirname as dirname7, join as join10 } from "path";
1524
1657
 
1525
1658
  // src/drain-progress.ts
1526
1659
  import {
1527
1660
  chmodSync as chmodSync3,
1528
- existsSync as existsSync5,
1529
- readFileSync as readFileSync7,
1530
- readdirSync,
1661
+ existsSync as existsSync7,
1662
+ readFileSync as readFileSync8,
1663
+ readdirSync as readdirSync2,
1531
1664
  rmSync as rmSync4,
1532
1665
  rmdirSync
1533
1666
  } from "fs";
1534
- import { basename, dirname as dirname6, join as join8 } from "path";
1667
+ import { basename, dirname as dirname6, join as join9 } from "path";
1535
1668
 
1536
1669
  // src/journal.ts
1537
- var JOURNAL_DIR = join9(primConfigDirectory(), "moves");
1670
+ var JOURNAL_DIR = join10(primConfigDirectory(), "moves");
1538
1671
  var UNBOUND_BUCKET = "_unbound";
1539
1672
  var JOURNAL_BASENAME = "journal.ndjson";
1540
1673
  var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
@@ -1546,7 +1679,7 @@ function envSlug(apiUrl) {
1546
1679
  return slug;
1547
1680
  }
1548
1681
  function currentEnvDir() {
1549
- return join9(JOURNAL_DIR, envSlug(getSiteUrl()));
1682
+ return join10(JOURNAL_DIR, envSlug(getSiteUrl()));
1550
1683
  }
1551
1684
  var DIR_MODE = 448;
1552
1685
  var FILE_MODE2 = 384;
@@ -1554,7 +1687,7 @@ var SAFE_BUCKET = /^[A-Za-z0-9_-]+$/;
1554
1687
  var RESERVED_BUCKETS = /* @__PURE__ */ new Set([UNBOUND_BUCKET, "_legacy"]);
1555
1688
  function appendMoveToPath(path, move) {
1556
1689
  const dir = dirname7(path);
1557
- if (!existsSync6(dir)) {
1690
+ if (!existsSync8(dir)) {
1558
1691
  mkdirSync4(dir, { recursive: true, mode: DIR_MODE });
1559
1692
  }
1560
1693
  appendFileSync(path, `${JSON.stringify(move)}
@@ -1562,10 +1695,10 @@ function appendMoveToPath(path, move) {
1562
1695
  }
1563
1696
  function bucketDir(orgId) {
1564
1697
  const safe = orgId !== void 0 && SAFE_BUCKET.test(orgId) && !RESERVED_BUCKETS.has(orgId);
1565
- return join9(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
1698
+ return join10(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
1566
1699
  }
1567
1700
  function journalPath(orgId) {
1568
- return join9(bucketDir(orgId), JOURNAL_BASENAME);
1701
+ return join10(bucketDir(orgId), JOURNAL_BASENAME);
1569
1702
  }
1570
1703
  function appendMove(move, orgId) {
1571
1704
  appendMoveToPath(journalPath(orgId), move);
@@ -1574,15 +1707,15 @@ var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
1574
1707
 
1575
1708
  // src/lib/activation.ts
1576
1709
  import { execFileSync as execFileSync2 } from "child_process";
1577
- import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
1710
+ import { existsSync as existsSync9, readFileSync as readFileSync10 } from "fs";
1578
1711
  import { homedir as homedir2 } from "os";
1579
- import { join as join10 } from "path";
1712
+ import { join as join11 } from "path";
1580
1713
 
1581
1714
  // src/lib/git.ts
1582
1715
  import { execFileSync } from "child_process";
1583
- import { createHash as createHash3 } from "crypto";
1584
- import { lstatSync as lstatSync2, realpathSync } from "fs";
1585
- import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
1716
+ import { createHash as createHash4 } from "crypto";
1717
+ import { lstatSync as lstatSync3, realpathSync } from "fs";
1718
+ import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute3, relative, resolve as resolve3, sep } from "path";
1586
1719
  var GIT_TIMEOUT_MS = 1e3;
1587
1720
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
1588
1721
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
@@ -1637,7 +1770,7 @@ function canonicalGitRoot(cwd) {
1637
1770
  }
1638
1771
  }
1639
1772
  function relatedWorktreeTarget(path, cwd, origin) {
1640
- let parent = dirname8(resolve2(cwd, path));
1773
+ let parent = dirname8(resolve3(cwd, path));
1641
1774
  while (true) {
1642
1775
  try {
1643
1776
  realpathSync.native(parent);
@@ -1653,7 +1786,7 @@ function relatedWorktreeTarget(path, cwd, origin) {
1653
1786
  const common = (root) => {
1654
1787
  const value = gitValue(root, ["rev-parse", "--git-common-dir"]);
1655
1788
  try {
1656
- return value ? realpathSync.native(resolve2(root, value)) : void 0;
1789
+ return value ? realpathSync.native(resolve3(root, value)) : void 0;
1657
1790
  } catch {
1658
1791
  return void 0;
1659
1792
  }
@@ -1683,7 +1816,7 @@ function normalizeOriginRemote(remote) {
1683
1816
  }
1684
1817
  }
1685
1818
  function opaqueRepoKey(source, value) {
1686
- return `repo_v1_${createHash3("sha256").update(`${source}\0${value}`).digest("hex")}`;
1819
+ return `repo_v1_${createHash4("sha256").update(`${source}\0${value}`).digest("hex")}`;
1687
1820
  }
1688
1821
  function resolveRepositoryContext(cwd = process.cwd()) {
1689
1822
  const top = gitToplevel(cwd);
@@ -1692,7 +1825,7 @@ function resolveRepositoryContext(cwd = process.cwd()) {
1692
1825
  try {
1693
1826
  repoRoot = realpathSync.native(top);
1694
1827
  } catch {
1695
- repoRoot = resolve2(top);
1828
+ repoRoot = resolve3(top);
1696
1829
  }
1697
1830
  const origin = gitValue(repoRoot, ["config", "--get", "remote.origin.url"]);
1698
1831
  const repoFullName = githubRepositoryFullName(repoRoot) ?? void 0;
@@ -1721,7 +1854,7 @@ function nearestExistingAncestor(path) {
1721
1854
  let cursor = path;
1722
1855
  while (true) {
1723
1856
  try {
1724
- lstatSync2(cursor);
1857
+ lstatSync3(cursor);
1725
1858
  break;
1726
1859
  } catch (error) {
1727
1860
  const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
@@ -1742,10 +1875,10 @@ function canonicalRepositoryPathScoped(filePath, context, baseDir) {
1742
1875
  if (!filePath || filePath !== filePath.trim() || filePath.includes("\0")) {
1743
1876
  return { ok: false, reason: "invalid_path" };
1744
1877
  }
1745
- const absolute = resolve2(baseDir, filePath);
1878
+ const absolute = resolve3(baseDir, filePath);
1746
1879
  const resolved = nearestExistingAncestor(absolute);
1747
1880
  if (!resolved) return { ok: false, reason: "invalid_path" };
1748
- const target = resolve2(resolved.real, ...resolved.suffix);
1881
+ const target = resolve3(resolved.real, ...resolved.suffix);
1749
1882
  const rel = relative(context.repoRoot, target);
1750
1883
  if (!rel || rel === ".") return { ok: false, reason: "invalid_path" };
1751
1884
  if (isAbsolute3(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
@@ -1756,10 +1889,10 @@ function canonicalRepositoryPathScoped(filePath, context, baseDir) {
1756
1889
  function canonicalRepositoryPathLegacy(filePath, cwd, repositoryRoot = canonicalGitRoot(cwd)) {
1757
1890
  if (!repositoryRoot || !filePath || [...filePath].some((char) => char < " " || char === "\x7F" || "~*?[]{}$`\\".includes(char)))
1758
1891
  return null;
1759
- const absolute = resolve2(cwd, filePath);
1892
+ const absolute = resolve3(cwd, filePath);
1760
1893
  let target;
1761
1894
  try {
1762
- const stat = lstatSync2(absolute);
1895
+ const stat = lstatSync3(absolute);
1763
1896
  if (!stat.isFile() || stat.isSymbolicLink()) return null;
1764
1897
  target = realpathSync.native(absolute);
1765
1898
  } catch (error) {
@@ -1768,8 +1901,8 @@ function canonicalRepositoryPathLegacy(filePath, cwd, repositoryRoot = canonical
1768
1901
  }
1769
1902
  try {
1770
1903
  const parent = realpathSync.native(dirname8(absolute));
1771
- if (!lstatSync2(parent).isDirectory()) return null;
1772
- target = resolve2(parent, basename2(absolute));
1904
+ if (!lstatSync3(parent).isDirectory()) return null;
1905
+ target = resolve3(parent, basename2(absolute));
1773
1906
  } catch {
1774
1907
  return null;
1775
1908
  }
@@ -1850,10 +1983,10 @@ function hasProjectPrimInstall(cwd) {
1850
1983
  const root = gitToplevel(cwd);
1851
1984
  if (root === null || root === homedir2()) return false;
1852
1985
  for (const rel of PROJECT_INSTALL_FILES) {
1853
- const path = join10(root, rel);
1854
- if (existsSync7(path)) {
1986
+ const path = join11(root, rel);
1987
+ if (existsSync9(path)) {
1855
1988
  try {
1856
- const content = readFileSync9(path, "utf-8");
1989
+ const content = readFileSync10(path, "utf-8");
1857
1990
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
1858
1991
  } catch {
1859
1992
  }
@@ -20630,8 +20763,8 @@ function cachedCollectScopeAdmits(cwd, facts) {
20630
20763
 
20631
20764
  // src/lib/commit-heartbeat.ts
20632
20765
  import { execFileSync as execFileSync3 } from "child_process";
20633
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync10, readdirSync as readdirSync3, unlinkSync } from "fs";
20634
- import { dirname as dirname9, join as join11, resolve as resolve3 } from "path";
20766
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync11, readdirSync as readdirSync4, unlinkSync } from "fs";
20767
+ import { dirname as dirname9, join as join12, resolve as resolve4 } from "path";
20635
20768
  var GIT_TIMEOUT_MS3 = 1e3;
20636
20769
  function gitPath(cwd, relative3) {
20637
20770
  const value = execFileSync3("git", ["rev-parse", "--git-path", relative3], {
@@ -20641,7 +20774,7 @@ function gitPath(cwd, relative3) {
20641
20774
  timeout: GIT_TIMEOUT_MS3
20642
20775
  }).replace(/\r?\n$/u, "");
20643
20776
  if (value === "" || /[\0\r\n]/u.test(value)) throw new Error("Git returned an unsafe path");
20644
- return resolve3(cwd, value);
20777
+ return resolve4(cwd, value);
20645
20778
  }
20646
20779
  function ensurePrivateParent(path) {
20647
20780
  mkdirSync5(dirname9(dirname9(path)), { recursive: true, mode: 448 });
@@ -20667,7 +20800,7 @@ function unattendedEnv(env = process.env) {
20667
20800
 
20668
20801
  // src/lib/workspace-id.ts
20669
20802
  import { execFileSync as execFileSync4 } from "child_process";
20670
- import { randomUUID as randomUUID2 } from "crypto";
20803
+ import { randomUUID as randomUUID3 } from "crypto";
20671
20804
  import {
20672
20805
  constants as constants2,
20673
20806
  chmodSync as chmodSync4,
@@ -20675,16 +20808,16 @@ import {
20675
20808
  fchmodSync as fchmodSync2,
20676
20809
  fsyncSync as fsyncSync2,
20677
20810
  linkSync,
20678
- lstatSync as lstatSync3,
20811
+ lstatSync as lstatSync4,
20679
20812
  mkdirSync as mkdirSync6,
20680
20813
  openSync as openSync3,
20681
- readFileSync as readFileSync11,
20814
+ readFileSync as readFileSync12,
20682
20815
  statSync as statSync2,
20683
20816
  unlinkSync as unlinkSync2,
20684
20817
  writeFileSync as writeFileSync3
20685
20818
  } from "fs";
20686
- import { dirname as dirname10, isAbsolute as isAbsolute4, join as join12, resolve as resolve4 } from "path";
20687
- var WORKSPACE_ID_RELATIVE_PATH = join12("prim", "workspace-id");
20819
+ import { dirname as dirname10, isAbsolute as isAbsolute4, join as join13, resolve as resolve5 } from "path";
20820
+ var WORKSPACE_ID_RELATIVE_PATH = join13("prim", "workspace-id");
20688
20821
  var MAX_ANCESTORS = 64;
20689
20822
  var MAX_GIT_FILE_BYTES = 4096;
20690
20823
  var MAX_ID_FILE_BYTES = 128;
@@ -20730,7 +20863,7 @@ function resolveWorkspaceIdPath(cwd) {
20730
20863
  }
20731
20864
  return {
20732
20865
  status: "resolved",
20733
- path: isAbsolute4(gitPath2) ? resolve4(gitPath2) : resolve4(cwd, gitPath2)
20866
+ path: isAbsolute4(gitPath2) ? resolve5(gitPath2) : resolve5(cwd, gitPath2)
20734
20867
  };
20735
20868
  } catch (error) {
20736
20869
  const code = errorCode(error);
@@ -20741,21 +20874,21 @@ function resolveWorkspaceIdPath(cwd) {
20741
20874
  }
20742
20875
  }
20743
20876
  function resolveFromFilesystem(cwd) {
20744
- let current = resolve4(cwd);
20877
+ let current = resolve5(cwd);
20745
20878
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
20746
- const dotGit = join12(current, ".git");
20879
+ const dotGit = join13(current, ".git");
20747
20880
  try {
20748
- const stat = lstatSync3(dotGit);
20881
+ const stat = lstatSync4(dotGit);
20749
20882
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
20750
- return join12(dotGit, WORKSPACE_ID_RELATIVE_PATH);
20883
+ return join13(dotGit, WORKSPACE_ID_RELATIVE_PATH);
20751
20884
  }
20752
20885
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
20753
- const contents = readFileSync11(dotGit, "utf8");
20886
+ const contents = readFileSync12(dotGit, "utf8");
20754
20887
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
20755
20888
  if (match?.[1]) {
20756
- const gitDirectory = isAbsolute4(match[1]) ? resolve4(match[1]) : resolve4(current, match[1]);
20889
+ const gitDirectory = isAbsolute4(match[1]) ? resolve5(match[1]) : resolve5(current, match[1]);
20757
20890
  if (isGitDirectory(gitDirectory)) {
20758
- return join12(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
20891
+ return join13(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
20759
20892
  }
20760
20893
  }
20761
20894
  }
@@ -20774,7 +20907,7 @@ function resolveFromFilesystem(cwd) {
20774
20907
  }
20775
20908
  function isGitDirectory(path) {
20776
20909
  try {
20777
- return statSync2(join12(path, "HEAD")).isFile();
20910
+ return statSync2(join13(path, "HEAD")).isFile();
20778
20911
  } catch {
20779
20912
  return false;
20780
20913
  }
@@ -20782,7 +20915,7 @@ function isGitDirectory(path) {
20782
20915
  function inspectPath(path) {
20783
20916
  let stat;
20784
20917
  try {
20785
- stat = lstatSync3(path);
20918
+ stat = lstatSync4(path);
20786
20919
  } catch (error) {
20787
20920
  const code = errorCode(error);
20788
20921
  if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing", path };
@@ -20793,7 +20926,7 @@ function inspectPath(path) {
20793
20926
  return { status: "corrupt", path, reason: "invalid_content" };
20794
20927
  }
20795
20928
  try {
20796
- const contents = readFileSync11(path, "utf8");
20929
+ const contents = readFileSync12(path, "utf8");
20797
20930
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
20798
20931
  if ((contents === workspaceId || contents === `${workspaceId}
20799
20932
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -20811,8 +20944,8 @@ function inspectPath(path) {
20811
20944
  }
20812
20945
  function createWorkspaceId(path) {
20813
20946
  const parent = dirname10(path);
20814
- const workspaceId = randomUUID2();
20815
- const temporaryPath = join12(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
20947
+ const workspaceId = randomUUID3();
20948
+ const temporaryPath = join13(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
20816
20949
  let temporaryCreated = false;
20817
20950
  let publishing = false;
20818
20951
  try {
@@ -20882,33 +21015,33 @@ function parseAgent(argv) {
20882
21015
  }
20883
21016
 
20884
21017
  // src/hooks/codex-context.ts
20885
- import { createHash as createHash5, randomBytes as randomBytes4 } from "crypto";
21018
+ import { createHash as createHash6, randomBytes as randomBytes4 } from "crypto";
20886
21019
  import {
20887
21020
  chmodSync as chmodSync5,
20888
- existsSync as existsSync8,
21021
+ existsSync as existsSync10,
20889
21022
  mkdirSync as mkdirSync7,
20890
- readFileSync as readFileSync12,
20891
- readdirSync as readdirSync4,
21023
+ readFileSync as readFileSync13,
21024
+ readdirSync as readdirSync5,
20892
21025
  renameSync as renameSync2,
20893
21026
  rmSync as rmSync5,
20894
21027
  statSync as statSync3,
20895
21028
  unlinkSync as unlinkSync3,
20896
21029
  writeFileSync as writeFileSync4
20897
21030
  } from "fs";
20898
- import { join as join14 } from "path";
21031
+ import { join as join15 } from "path";
20899
21032
 
20900
21033
  // src/daemon/client.ts
20901
21034
  import { createConnection } from "net";
20902
- import { join as join13 } from "path";
21035
+ import { join as join14 } from "path";
20903
21036
 
20904
21037
  // src/daemon/principal.ts
20905
- import { createHash as createHash4 } from "crypto";
21038
+ import { createHash as createHash5 } from "crypto";
20906
21039
  var PRINCIPAL_COMPONENT_MAX_LENGTH = 512;
20907
21040
  function boundedClaim(value) {
20908
21041
  return typeof value === "string" && value.length > 0 && value.length <= PRINCIPAL_COMPONENT_MAX_LENGTH ? value : void 0;
20909
21042
  }
20910
21043
  function sha256(value) {
20911
- return createHash4("sha256").update(value).digest("hex");
21044
+ return createHash5("sha256").update(value).digest("hex");
20912
21045
  }
20913
21046
  function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
20914
21047
  if (!token) return void 0;
@@ -20949,7 +21082,7 @@ function parseDaemonResponseEnvelope(value) {
20949
21082
  }
20950
21083
 
20951
21084
  // src/daemon/client.ts
20952
- var SOCK_PATH = join13(primConfigDirectory(), "sock");
21085
+ var SOCK_PATH = join14(primConfigDirectory(), "sock");
20953
21086
  var DEFAULT_TIMEOUT_MS2 = 250;
20954
21087
  var nextRequestId = 1;
20955
21088
  function daemonRequest(method, params = {}, opts = {}) {
@@ -20962,7 +21095,7 @@ function daemonRequest(method, params = {}, opts = {}) {
20962
21095
  ...caller ? { caller } : {}
20963
21096
  };
20964
21097
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
20965
- return new Promise((resolve7) => {
21098
+ return new Promise((resolve8) => {
20966
21099
  let settled = false;
20967
21100
  let socket;
20968
21101
  let buffer = Buffer.alloc(0);
@@ -20977,7 +21110,7 @@ function daemonRequest(method, params = {}, opts = {}) {
20977
21110
  } catch {
20978
21111
  }
20979
21112
  }
20980
- resolve7(value);
21113
+ resolve8(value);
20981
21114
  };
20982
21115
  const timer = setTimeout(() => settle(null), timeoutMs);
20983
21116
  timer.unref();
@@ -21196,10 +21329,10 @@ var STATE_VERSION = 1;
21196
21329
  var DRAFT_STATE_VERSION = 2;
21197
21330
  var NO_CURSOR = -1;
21198
21331
  function stateRoot(namespace) {
21199
- return join14(primConfigDirectory(), namespace, "decision-digests");
21332
+ return join15(primConfigDirectory(), namespace, "decision-digests");
21200
21333
  }
21201
21334
  function draftStateRoot(namespace) {
21202
- return join14(primConfigDirectory(), namespace, "decision-draft-deliveries");
21335
+ return join15(primConfigDirectory(), namespace, "decision-draft-deliveries");
21203
21336
  }
21204
21337
  function workspaceFor(cwd) {
21205
21338
  try {
@@ -21210,13 +21343,13 @@ function workspaceFor(cwd) {
21210
21343
  }
21211
21344
  function statePath(args) {
21212
21345
  const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}`;
21213
- const key = createHash5("sha256").update(identity).digest("hex");
21214
- return join14(stateRoot(args.namespace), `${key}.json`);
21346
+ const key = createHash6("sha256").update(identity).digest("hex");
21347
+ return join15(stateRoot(args.namespace), `${key}.json`);
21215
21348
  }
21216
21349
  function draftStatePath(args) {
21217
21350
  const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}\0${args.principalId}\0${args.organizationId}\0${args.credentialFingerprint}`;
21218
- const key = createHash5("sha256").update(identity).digest("hex");
21219
- return join14(draftStateRoot(args.namespace), `${key}.json`);
21351
+ const key = createHash6("sha256").update(identity).digest("hex");
21352
+ return join15(draftStateRoot(args.namespace), `${key}.json`);
21220
21353
  }
21221
21354
  function parseState(value) {
21222
21355
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
@@ -21255,17 +21388,17 @@ function parseDraftState(value) {
21255
21388
  };
21256
21389
  }
21257
21390
  function readState(path) {
21258
- if (!existsSync8(path)) return void 0;
21391
+ if (!existsSync10(path)) return void 0;
21259
21392
  try {
21260
- return parseState(JSON.parse(readFileSync12(path, "utf8")));
21393
+ return parseState(JSON.parse(readFileSync13(path, "utf8")));
21261
21394
  } catch {
21262
21395
  return void 0;
21263
21396
  }
21264
21397
  }
21265
21398
  function readDraftState(path) {
21266
- if (!existsSync8(path)) return void 0;
21399
+ if (!existsSync10(path)) return void 0;
21267
21400
  try {
21268
- return parseDraftState(JSON.parse(readFileSync12(path, "utf8")));
21401
+ return parseDraftState(JSON.parse(readFileSync13(path, "utf8")));
21269
21402
  } catch {
21270
21403
  return void 0;
21271
21404
  }
@@ -21273,7 +21406,7 @@ function readDraftState(path) {
21273
21406
  function writeStateFile(path, directory, state) {
21274
21407
  mkdirSync7(directory, { recursive: true, mode: 448 });
21275
21408
  chmodSync5(directory, 448);
21276
- const temporary = join14(
21409
+ const temporary = join15(
21277
21410
  directory,
21278
21411
  `.${path.slice(directory.length + 1)}.tmp-${process.pid}-${randomBytes4(8).toString("hex")}`
21279
21412
  );
@@ -21294,17 +21427,17 @@ function writeStateFile(path, directory, state) {
21294
21427
  }
21295
21428
  }
21296
21429
  function cleanupStateFiles(directory, now) {
21297
- if (!existsSync8(directory)) return;
21430
+ if (!existsSync10(directory)) return;
21298
21431
  let names;
21299
21432
  try {
21300
- names = readdirSync4(directory);
21433
+ names = readdirSync5(directory);
21301
21434
  } catch {
21302
21435
  return;
21303
21436
  }
21304
21437
  const files = [];
21305
21438
  const residue = [];
21306
21439
  for (const name of names) {
21307
- const path = join14(directory, name);
21440
+ const path = join15(directory, name);
21308
21441
  try {
21309
21442
  const mtimeMs = statSync3(path).mtimeMs;
21310
21443
  if (name.endsWith(".json")) {
@@ -21642,23 +21775,23 @@ async function processCodexMessageContext(envelope, deps = defaultDeps) {
21642
21775
  }
21643
21776
 
21644
21777
  // src/commands/cursor-install.ts
21645
- import { existsSync as existsSync11, readFileSync as readFileSync15 } from "fs";
21778
+ import { existsSync as existsSync13, readFileSync as readFileSync16 } from "fs";
21646
21779
  import { homedir as homedir4 } from "os";
21647
- import { isAbsolute as isAbsolute6, join as join17 } from "path";
21780
+ import { isAbsolute as isAbsolute6, join as join18 } from "path";
21648
21781
 
21649
21782
  // src/lib/hook-runtime.ts
21650
- import { createHash as createHash6, randomBytes as randomBytes5 } from "crypto";
21783
+ import { createHash as createHash7, randomBytes as randomBytes5 } from "crypto";
21651
21784
  import {
21652
21785
  constants as constants3,
21653
21786
  accessSync,
21654
21787
  chmodSync as chmodSync6,
21655
21788
  copyFileSync,
21656
- existsSync as existsSync9,
21657
- lstatSync as lstatSync4,
21789
+ existsSync as existsSync11,
21790
+ lstatSync as lstatSync5,
21658
21791
  mkdirSync as mkdirSync8,
21659
21792
  mkdtempSync,
21660
- readFileSync as readFileSync13,
21661
- readdirSync as readdirSync5,
21793
+ readFileSync as readFileSync14,
21794
+ readdirSync as readdirSync6,
21662
21795
  realpathSync as realpathSync2,
21663
21796
  renameSync as renameSync3,
21664
21797
  rmSync as rmSync6,
@@ -21666,7 +21799,7 @@ import {
21666
21799
  utimesSync,
21667
21800
  writeFileSync as writeFileSync5
21668
21801
  } from "fs";
21669
- import { delimiter, dirname as dirname11, isAbsolute as isAbsolute5, join as join15, resolve as resolve5 } from "path";
21802
+ import { delimiter, dirname as dirname11, isAbsolute as isAbsolute5, join as join16, resolve as resolve6 } from "path";
21670
21803
 
21671
21804
  // src/lib/git-hook-contract.ts
21672
21805
  var GIT_HOOK_ENTRYPOINT_CONTENT = `#!/bin/sh
@@ -21759,9 +21892,9 @@ exec "$prim_node" "$prim_entry" "$@"
21759
21892
  `;
21760
21893
 
21761
21894
  // src/commands/claude-install.ts
21762
- import { existsSync as existsSync10, readFileSync as readFileSync14 } from "fs";
21895
+ import { existsSync as existsSync12, readFileSync as readFileSync15 } from "fs";
21763
21896
  import { homedir as homedir3 } from "os";
21764
- import { join as join16 } from "path";
21897
+ import { join as join17 } from "path";
21765
21898
  var CAPTURE_BIN = "prim-hook";
21766
21899
  var GATE_BIN = "prim-pre-tool-use";
21767
21900
  var POST_TOOL_USE_BIN = "prim-post-tool-use";
@@ -21770,7 +21903,7 @@ var SESSION_END_BIN = "prim-session-end";
21770
21903
  var STATUSLINE_BIN = "prim-statusline";
21771
21904
  var STATUSLINE_ARGS = "";
21772
21905
  var STATUSLINE_COMMAND = stableHookCommand(STATUSLINE_BIN, STATUSLINE_ARGS);
21773
- var USER_SCOPE_PATH = join16(homedir3(), ".claude", "settings.json");
21906
+ var USER_SCOPE_PATH = join17(homedir3(), ".claude", "settings.json");
21774
21907
  function projectRoot() {
21775
21908
  return gitToplevel() ?? process.cwd();
21776
21909
  }
@@ -21849,20 +21982,20 @@ function cursorConfigDirectory(env = process.env, home = homedir4(), platform2 =
21849
21982
  const explicit = env.CURSOR_CONFIG_DIR?.trim();
21850
21983
  if (explicit && isAbsolute6(explicit)) return explicit;
21851
21984
  const xdg = env.XDG_CONFIG_HOME?.trim();
21852
- if (platform2 !== "darwin" && xdg && isAbsolute6(xdg)) return join17(xdg, "cursor");
21853
- return join17(home, ".cursor");
21985
+ if (platform2 !== "darwin" && xdg && isAbsolute6(xdg)) return join18(xdg, "cursor");
21986
+ return join18(home, ".cursor");
21854
21987
  }
21855
21988
  function cursorHooksPath(scope, root = projectRoot()) {
21856
- return scope === "user" ? join17(cursorConfigDirectory(), "hooks.json") : join17(root, ".cursor", "hooks.json");
21989
+ return scope === "user" ? join18(cursorConfigDirectory(), "hooks.json") : join18(root, ".cursor", "hooks.json");
21857
21990
  }
21858
21991
  function plainObject(value) {
21859
21992
  return typeof value === "object" && value !== null && !Array.isArray(value);
21860
21993
  }
21861
21994
  function readCursorHooks(path) {
21862
- if (!existsSync11(path)) return {};
21995
+ if (!existsSync13(path)) return {};
21863
21996
  let parsed;
21864
21997
  try {
21865
- parsed = JSON.parse(readFileSync15(path, "utf8"));
21998
+ parsed = JSON.parse(readFileSync16(path, "utf8"));
21866
21999
  } catch {
21867
22000
  throw new Error(`invalid Cursor hooks JSON at ${path}`);
21868
22001
  }
@@ -21985,13 +22118,13 @@ function buildHookOutput(options) {
21985
22118
  return output;
21986
22119
  }
21987
22120
  function writeHookOutput(output, stream = process.stdout) {
21988
- return new Promise((resolve7) => {
22121
+ return new Promise((resolve8) => {
21989
22122
  let settled = false;
21990
22123
  const finish = (ok, retainErrorListener = false) => {
21991
22124
  if (settled) return;
21992
22125
  settled = true;
21993
22126
  if (!retainErrorListener) stream.off("error", onError);
21994
- resolve7(ok);
22127
+ resolve8(ok);
21995
22128
  };
21996
22129
  const onError = () => {
21997
22130
  if (settled) {
@@ -22133,8 +22266,8 @@ function extractFileTargets(toolName, toolInput, agent = "claude_code") {
22133
22266
  }
22134
22267
 
22135
22268
  // src/hooks/redact.ts
22136
- import { existsSync as existsSync12, readFileSync as readFileSync16, statSync as statSync5 } from "fs";
22137
- import { join as join18 } from "path";
22269
+ import { existsSync as existsSync14, readFileSync as readFileSync17, statSync as statSync5 } from "fs";
22270
+ import { join as join19 } from "path";
22138
22271
  import { Worker } from "worker_threads";
22139
22272
  var USER_HOME_RULES = [
22140
22273
  {
@@ -22210,15 +22343,15 @@ function normalizedWorkspaceFlags(value) {
22210
22343
  return [...new Set(`g${requested}`)].sort().join("");
22211
22344
  }
22212
22345
  function loadWorkspaceRules(cwd) {
22213
- const path = join18(cwd, WORKSPACE_FILE2);
22214
- if (!existsSync12(path)) return [];
22346
+ const path = join19(cwd, WORKSPACE_FILE2);
22347
+ if (!existsSync14(path)) return [];
22215
22348
  let cfg;
22216
22349
  try {
22217
22350
  if (statSync5(path).size > MAX_WORKSPACE_CONFIG_BYTES) {
22218
22351
  debugRedaction(`ignoring oversized ${WORKSPACE_FILE2}`);
22219
22352
  return [];
22220
22353
  }
22221
- cfg = JSON.parse(readFileSync16(path, "utf-8"));
22354
+ cfg = JSON.parse(readFileSync17(path, "utf-8"));
22222
22355
  } catch {
22223
22356
  debugRedaction(`ignoring unparseable ${WORKSPACE_FILE2}`);
22224
22357
  return [];
@@ -22337,7 +22470,7 @@ function applyWorkspaceRules(value, rules) {
22337
22470
  flags: pattern.flags,
22338
22471
  reason
22339
22472
  }));
22340
- return new Promise((resolve7) => {
22473
+ return new Promise((resolve8) => {
22341
22474
  let worker;
22342
22475
  try {
22343
22476
  worker = new Worker(WORKSPACE_REDACTION_WORKER, {
@@ -22345,7 +22478,7 @@ function applyWorkspaceRules(value, rules) {
22345
22478
  workerData: { value, rules: serialized }
22346
22479
  });
22347
22480
  } catch {
22348
- resolve7(redactEveryString(value, "workspace-rule-failed"));
22481
+ resolve8(redactEveryString(value, "workspace-rule-failed"));
22349
22482
  return;
22350
22483
  }
22351
22484
  let settled = false;
@@ -22354,7 +22487,7 @@ function applyWorkspaceRules(value, rules) {
22354
22487
  settled = true;
22355
22488
  clearTimeout(timer);
22356
22489
  void worker.terminate();
22357
- resolve7(result);
22490
+ resolve8(result);
22358
22491
  };
22359
22492
  const failClosed = () => finish(redactEveryString(value, "workspace-rule-failed"));
22360
22493
  const timer = setTimeout(failClosed, WORKSPACE_RULE_TIMEOUT_MS);
@@ -26925,7 +27058,7 @@ function enrichHookPayloadWithFileRefs(args) {
26925
27058
  // src/hooks/hook-stdin.ts
26926
27059
  var DEFAULT_MAX_BYTES = 1024 * 1024;
26927
27060
  function readHookStdin(timeoutMs = 1e3, maxBytes = DEFAULT_MAX_BYTES) {
26928
- return new Promise((resolve7, reject) => {
27061
+ return new Promise((resolve8, reject) => {
26929
27062
  const chunks = [];
26930
27063
  let bytes = 0;
26931
27064
  let settled = false;
@@ -26937,7 +27070,7 @@ function readHookStdin(timeoutMs = 1e3, maxBytes = DEFAULT_MAX_BYTES) {
26937
27070
  process.stdin.removeAllListeners("end");
26938
27071
  process.stdin.removeAllListeners("error");
26939
27072
  if (error) reject(error);
26940
- else resolve7(Buffer.concat(chunks, bytes).toString("utf-8"));
27073
+ else resolve8(Buffer.concat(chunks, bytes).toString("utf-8"));
26941
27074
  };
26942
27075
  const timer = setTimeout(() => finish(new Error("stdin read timeout")), timeoutMs);
26943
27076
  process.stdin.on("data", (chunk) => {
@@ -26954,9 +27087,9 @@ function readHookStdin(timeoutMs = 1e3, maxBytes = DEFAULT_MAX_BYTES) {
26954
27087
  }
26955
27088
 
26956
27089
  // src/hooks/normalize.ts
26957
- import { createHash as createHash7 } from "crypto";
27090
+ import { createHash as createHash8 } from "crypto";
26958
27091
  import { realpathSync as realpathSync3 } from "fs";
26959
- import { isAbsolute as isAbsolute8, resolve as resolve6 } from "path";
27092
+ import { isAbsolute as isAbsolute8, resolve as resolve7 } from "path";
26960
27093
  var HERMES_EVENT_MAP = {
26961
27094
  on_session_start: "SessionStart",
26962
27095
  on_session_end: "SessionEnd",
@@ -26999,7 +27132,7 @@ function requiredId(value, field) {
26999
27132
  }
27000
27133
  function cursorToolUseId(value) {
27001
27134
  if (SAFE_CORRELATION_ID_RE.test(value)) return value;
27002
- return `cursor:tool:v1:${createHash7("sha256").update(value).digest("hex")}`;
27135
+ return `cursor:tool:v1:${createHash8("sha256").update(value).digest("hex")}`;
27003
27136
  }
27004
27137
  function workspaceCandidates(value) {
27005
27138
  if (!Array.isArray(value)) return [];
@@ -27013,7 +27146,7 @@ function pathIdentity(path) {
27013
27146
  try {
27014
27147
  return realpathSync3.native(path);
27015
27148
  } catch {
27016
- return resolve6(path);
27149
+ return resolve7(path);
27017
27150
  }
27018
27151
  }
27019
27152
  function resolveCursorCwd(parsed) {
@@ -27038,7 +27171,7 @@ function resolveCursorCwd(parsed) {
27038
27171
  if (rawToolCwd && !isAbsolute8(rawToolCwd) && !base) {
27039
27172
  throw new TypeError("relative Cursor tool cwd has no workspace base");
27040
27173
  }
27041
- const toolCwd = rawToolCwd ? pathIdentity(isAbsolute8(rawToolCwd) ? rawToolCwd : resolve6(base, rawToolCwd)) : void 0;
27174
+ const toolCwd = rawToolCwd ? pathIdentity(isAbsolute8(rawToolCwd) ? rawToolCwd : resolve7(base, rawToolCwd)) : void 0;
27042
27175
  const selected = toolCwd ?? envelopeCwd ?? (roots.length === 1 ? roots[0] : expectedRepo);
27043
27176
  if (!selected) {
27044
27177
  throw new TypeError("Cursor hook envelope has no unambiguous workspace");
@@ -27096,7 +27229,7 @@ function normalizeEnvelope(parsed, agent) {
27096
27229
  ]);
27097
27230
  return {
27098
27231
  ...parsed,
27099
- tool_use_id: `codex:fallback:v1:${createHash7("sha256").update(stableToolIdentity).digest("hex")}`
27232
+ tool_use_id: `codex:fallback:v1:${createHash8("sha256").update(stableToolIdentity).digest("hex")}`
27100
27233
  };
27101
27234
  }
27102
27235
  return parsed;
@@ -27112,7 +27245,7 @@ function normalizeEnvelope(parsed, agent) {
27112
27245
  }
27113
27246
 
27114
27247
  // src/hooks/prim-hook-core.ts
27115
- import { createHash as createHash8, randomUUID as randomUUID3 } from "crypto";
27248
+ import { createHash as createHash9, randomUUID as randomUUID4 } from "crypto";
27116
27249
  import { platform } from "os";
27117
27250
 
27118
27251
  // src/protocol/move.ts
@@ -27186,9 +27319,9 @@ function toMove(parsed, cliVersion, agent = "claude_code", workspaceId, reposito
27186
27319
  const toolOutcome = toolOutcomeFor(parsed, agent);
27187
27320
  let moveId;
27188
27321
  if (CORRELATED_TOOL_EVENTS.has(eventType) && sessionId && invocationId) {
27189
- moveId = `posttool:v1:${createHash8("sha256").update(JSON.stringify([agent, sessionId, eventType, invocationId])).digest("hex")}`;
27322
+ moveId = `posttool:v1:${createHash9("sha256").update(JSON.stringify([agent, sessionId, eventType, invocationId])).digest("hex")}`;
27190
27323
  } else if (CORRELATED_TOOL_EVENTS.has(eventType) && sessionId && agent !== "cursor") {
27191
- moveId = `posttool:fallback:v1:${createHash8("sha256").update(
27324
+ moveId = `posttool:fallback:v1:${createHash9("sha256").update(
27192
27325
  JSON.stringify([
27193
27326
  agent,
27194
27327
  sessionId,
@@ -27199,7 +27332,7 @@ function toMove(parsed, cliVersion, agent = "claude_code", workspaceId, reposito
27199
27332
  ])
27200
27333
  ).digest("hex")}`;
27201
27334
  } else {
27202
- moveId = randomUUID3();
27335
+ moveId = randomUUID4();
27203
27336
  }
27204
27337
  return {
27205
27338
  moveId,
@@ -27239,14 +27372,14 @@ function emitOutput(output, acknowledge) {
27239
27372
  }
27240
27373
  function resolveCliVersion() {
27241
27374
  try {
27242
- const pkg = JSON.parse(readFileSync17(join19(here, "..", "..", "package.json"), "utf-8"));
27375
+ const pkg = JSON.parse(readFileSync18(join20(here, "..", "..", "package.json"), "utf-8"));
27243
27376
  return pkg.version ?? "unknown";
27244
27377
  } catch {
27245
27378
  return "unknown";
27246
27379
  }
27247
27380
  }
27248
27381
  function spawnBackgroundFlush() {
27249
- const entry = join19(here, "..", "index.js");
27382
+ const entry = join20(here, "..", "index.js");
27250
27383
  spawn(process.execPath, [entry, "moves", "flush"], {
27251
27384
  detached: true,
27252
27385
  stdio: "ignore",
@@ -27263,6 +27396,10 @@ async function main() {
27263
27396
  const incoming = JSON.parse(raw);
27264
27397
  if (agent !== "cursor" && shouldSuppressImportedCursorHandler(incoming, "prim-hook")) return;
27265
27398
  parsed = normalizeEnvelope(incoming, agent);
27399
+ if (observeDemoInvocation(parsed, agent).excluded) {
27400
+ await emitOutput(cursorPassiveOutput());
27401
+ return;
27402
+ }
27266
27403
  } catch (error) {
27267
27404
  writeHookDebug("capture failed", error);
27268
27405
  await emitOutput(cursorPassiveOutput());