@workit-dev/codex 2.29.1 → 2.29.2

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.
@@ -71,12 +71,12 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
71
71
  };
72
72
  });
73
73
  // packages/workit-core/src/hooks/context.ts
74
- import { createHash as createHash11 } from "node:crypto";
74
+ import { createHash as createHash12 } from "node:crypto";
75
75
  import fs15 from "node:fs";
76
- import path20 from "node:path";
76
+ import path21 from "node:path";
77
77
 
78
78
  // packages/workit-core/src/core/branch.ts
79
- import { createHash as createHash4 } from "node:crypto";
79
+ import { createHash as createHash5 } from "node:crypto";
80
80
 
81
81
  // packages/workit-core/src/core/branch-policy.ts
82
82
  import { spawnSync } from "node:child_process";
@@ -295,9 +295,9 @@ var releaseTagPrefixOf = (workspaceRoot, policyPrefix) => {
295
295
 
296
296
  // packages/workit-core/src/core/workspaces.ts
297
297
  import { spawnSync as spawnSync5 } from "node:child_process";
298
- import { createHash as createHash2 } from "node:crypto";
299
- import { existsSync as existsSync3, lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
300
- import path5 from "node:path";
298
+ import { createHash as createHash3 } from "node:crypto";
299
+ import { existsSync as existsSync3, lstatSync as lstatSync2, readFileSync as readFileSync5, realpathSync as realpathSync3 } from "node:fs";
300
+ import path6 from "node:path";
301
301
 
302
302
  // node_modules/zod/v4/core/util.js
303
303
  function getEnumValues(entries) {
@@ -4041,6 +4041,103 @@ var pushTarget = (cwd, remote, replay = {}) => {
4041
4041
  return { remotes };
4042
4042
  };
4043
4043
 
4044
+ // packages/workit-core/src/core/grant-seal.ts
4045
+ import { createHash as createHash2 } from "node:crypto";
4046
+ import { readFileSync as readFileSync4 } from "node:fs";
4047
+ import path5 from "node:path";
4048
+ var SEAL_FILE = "workspaces.json.seal";
4049
+ var SEAL_VERSION = 2;
4050
+ var isSealVersion = (value) => value === 1 || value === 2;
4051
+ var SEAL_COMMAND = "workit workspace seal";
4052
+ var pick3 = (value, keys) => {
4053
+ if (!value || typeof value !== "object" || Array.isArray(value))
4054
+ return;
4055
+ const out = Object.fromEntries(keys.flatMap((key) => {
4056
+ const item = value[key];
4057
+ return item === undefined ? [] : [[key, item]];
4058
+ }));
4059
+ return Object.keys(out).length > 0 ? out : undefined;
4060
+ };
4061
+ var ENTRY_KEYS = [
4062
+ "name",
4063
+ "glob",
4064
+ "remotes",
4065
+ "externalRepos",
4066
+ "additiveRiskPaths",
4067
+ "vcs",
4068
+ "autonomy",
4069
+ "autoApprove",
4070
+ "defaultEndpoint",
4071
+ "verification",
4072
+ "youtrack"
4073
+ ];
4074
+ var RELEASE_KEYS = [
4075
+ "releaseNotes",
4076
+ "releaseTagPrefix",
4077
+ "branchPolicy",
4078
+ "profiles",
4079
+ "defaultProfile",
4080
+ "releaseTracks",
4081
+ "releasePackages"
4082
+ ];
4083
+ var keysOf = (version) => version >= 2 ? [...ENTRY_KEYS, ...RELEASE_KEYS] : ENTRY_KEYS;
4084
+ var IDENTITY_KEYS = ["provider", "account", "tokenFile", "host"];
4085
+ var sealProjection = (entries, version = SEAL_VERSION) => entries.map((entry) => {
4086
+ const keys = keysOf(version);
4087
+ const all = pick3(entry, keys) ?? {};
4088
+ return pick3({
4089
+ ...all,
4090
+ vcs: pick3(all.vcs, IDENTITY_KEYS),
4091
+ youtrack: pick3(all.youtrack, ["writes", "autoHosts"]),
4092
+ ...version >= 2 ? releaseLineMapping(entry, true) : {}
4093
+ }, keys);
4094
+ });
4095
+ var canonical2 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
4096
+ var sealDigest = (projection) => createHash2("sha256").update(canonical2(projection)).digest("hex");
4097
+ var broken = (reason, sealed = null, version) => ({
4098
+ state: "broken",
4099
+ reason,
4100
+ sealed,
4101
+ ...version ? { version } : {}
4102
+ });
4103
+ var PARTIAL_KEYS = ["releaseTracks", "branchPolicy", "profiles", "defaultProfile"];
4104
+ var sealedEntries = (projection, file) => {
4105
+ const partial = projection.map((entry) => pick3(entry, PARTIAL_KEYS));
4106
+ const validated = validateWorkspacesDocument({
4107
+ workspaces: projection.map((entry) => {
4108
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
4109
+ return entry;
4110
+ const rest = { ...entry };
4111
+ for (const key of PARTIAL_KEYS)
4112
+ delete rest[key];
4113
+ return rest;
4114
+ })
4115
+ }, file);
4116
+ if (validated.status !== "valid" || validated.entries.length !== projection.length)
4117
+ return null;
4118
+ return validated.entries.map((entry, at) => partial[at] === undefined ? entry : { ...entry, ...partial[at] });
4119
+ };
4120
+ function checkSeal(dir) {
4121
+ const file = path5.join(dir, SEAL_FILE);
4122
+ let seal;
4123
+ try {
4124
+ seal = JSON.parse(readFileSync4(file, "utf8"));
4125
+ } catch (error) {
4126
+ if (error.code === "ENOENT")
4127
+ return { state: "none" };
4128
+ return broken(`${SEAL_FILE} cannot be read`);
4129
+ }
4130
+ if (!isSealVersion(seal?.version) || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
4131
+ return broken(`${SEAL_FILE} is malformed`);
4132
+ const version = seal.version;
4133
+ const sealed = sealedEntries(seal.projection, file);
4134
+ if (!sealed)
4135
+ return broken(`${SEAL_FILE} is malformed`, null, version);
4136
+ const current = readWorkspacesResult(dir);
4137
+ const ok = current.status === "valid" || current.status === "missing";
4138
+ return ok && sealDigest(sealProjection(current.entries, version)) === seal.sha256 ? { state: "valid", version } : broken("workspaces.json changed since it was sealed", sealed, version);
4139
+ }
4140
+
4044
4141
  // packages/workit-core/src/core/workspaces.ts
4045
4142
  var nonBlank = string2().check(refine((value) => value.trim().length > 0, "must not be blank"));
4046
4143
  var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
@@ -4106,7 +4203,7 @@ var releaseTrackSchema = looseObject({
4106
4203
  });
4107
4204
  }
4108
4205
  }
4109
- if (track.versionSource?.kind === "package-json" && (path5.posix.isAbsolute(track.versionSource.path.replaceAll("\\", "/")) || /^[A-Za-z]:\//u.test(track.versionSource.path.replaceAll("\\", "/")) || track.versionSource.path.replaceAll("\\", "/").split("/").includes(".."))) {
4206
+ if (track.versionSource?.kind === "package-json" && (path6.posix.isAbsolute(track.versionSource.path.replaceAll("\\", "/")) || /^[A-Za-z]:\//u.test(track.versionSource.path.replaceAll("\\", "/")) || track.versionSource.path.replaceAll("\\", "/").split("/").includes(".."))) {
4110
4207
  context.addIssue({
4111
4208
  code: "custom",
4112
4209
  path: ["versionSource", "path"],
@@ -4205,7 +4302,7 @@ var workspacesFileSchema = looseObject({
4205
4302
  names.add(workspace.name);
4206
4303
  }
4207
4304
  }));
4208
- var workspacesRevision = (contents) => createHash2("sha256").update(contents ?? "<missing>").digest("hex");
4305
+ var workspacesRevision = (contents) => createHash3("sha256").update(contents ?? "<missing>").digest("hex");
4209
4306
  var validateWorkspacesDocument = (parsed, file) => {
4210
4307
  if (!isConfigObject(parsed)) {
4211
4308
  return {
@@ -4251,10 +4348,10 @@ var validateWorkspacesDocument = (parsed, file) => {
4251
4348
  };
4252
4349
  };
4253
4350
  var readWorkspacesResult = (dir = configDir()) => {
4254
- const file = path5.join(dir, "workspaces.json");
4351
+ const file = path6.join(dir, "workspaces.json");
4255
4352
  let raw;
4256
4353
  try {
4257
- raw = readFileSync4(file, "utf8");
4354
+ raw = readFileSync5(file, "utf8");
4258
4355
  } catch (error) {
4259
4356
  if (error.code === "ENOENT")
4260
4357
  return {
@@ -4355,9 +4452,9 @@ var probeCheckout = (cwd) => {
4355
4452
  const cached = probes.get(cwd);
4356
4453
  if (cached !== undefined)
4357
4454
  return cached;
4358
- let dir = path5.resolve(cwd);
4359
- while (!existsSync3(path5.join(dir, ".git"))) {
4360
- if (["HEAD", "objects", "refs"].every((name) => existsSync3(path5.join(dir, name)))) {
4455
+ let dir = path6.resolve(cwd);
4456
+ while (!existsSync3(path6.join(dir, ".git"))) {
4457
+ if (["HEAD", "objects", "refs"].every((name) => existsSync3(path6.join(dir, name)))) {
4361
4458
  const real = realpathOf(dir);
4362
4459
  const owner = ownInternals(real) === true ? gitDirOwner(real) : null;
4363
4460
  if (owner === null)
@@ -4366,7 +4463,7 @@ var probeCheckout = (cwd) => {
4366
4463
  probes.set(cwd, probe);
4367
4464
  return probe;
4368
4465
  }
4369
- const up = path5.dirname(dir);
4466
+ const up = path6.dirname(dir);
4370
4467
  if (up === dir)
4371
4468
  return null;
4372
4469
  dir = up;
@@ -4395,9 +4492,9 @@ var probeCheckout = (cwd) => {
4395
4492
  if (!gitDir || !common)
4396
4493
  return failed;
4397
4494
  let main = null;
4398
- if (path5.resolve(gitDir) === path5.resolve(common)) {
4495
+ if (path6.resolve(gitDir) === path6.resolve(common)) {
4399
4496
  const real = realpathOf(common);
4400
- if (!ownGitDir(path5.join(dir, ".git"), real)) {
4497
+ if (!ownGitDir(path6.join(dir, ".git"), real)) {
4401
4498
  const owner = gitDirOwner(real);
4402
4499
  if (owner === null)
4403
4500
  return Error(`${cwd} uses the repository at ${real}, owned by no checkout workit can name`);
@@ -4416,7 +4513,7 @@ var probeCheckout = (cwd) => {
4416
4513
  const list = git(["worktree", "list", "--porcelain"]);
4417
4514
  if (list === null)
4418
4515
  return failed;
4419
- main = /^worktree (.+)$/mu.exec(list)?.[1]?.trim() || (path5.basename(common) === ".git" ? path5.dirname(common) : common);
4516
+ main = /^worktree (.+)$/mu.exec(list)?.[1]?.trim() || (path6.basename(common) === ".git" ? path6.dirname(common) : common);
4420
4517
  }
4421
4518
  const probe = { main, superproject: superproject || null };
4422
4519
  probes.set(cwd, probe);
@@ -4433,7 +4530,7 @@ var INTERNALS = ["refs", "objects", "config", "packed-refs", "commondir"];
4433
4530
  var ownInternals = (real) => {
4434
4531
  let lender = null;
4435
4532
  for (const name of INTERNALS) {
4436
- const at = path5.join(real, name);
4533
+ const at = path6.join(real, name);
4437
4534
  try {
4438
4535
  lstatSync2(at);
4439
4536
  } catch {
@@ -4445,10 +4542,10 @@ var ownInternals = (real) => {
4445
4542
  } catch {
4446
4543
  return false;
4447
4544
  }
4448
- const rel = path5.relative(real, resolved);
4449
- if (rel && !rel.startsWith("..") && !path5.isAbsolute(rel))
4545
+ const rel = path6.relative(real, resolved);
4546
+ if (rel && !rel.startsWith("..") && !path6.isAbsolute(rel))
4450
4547
  continue;
4451
- const owner = path5.basename(resolved) === name ? gitDirOwner(path5.dirname(resolved)) : null;
4548
+ const owner = path6.basename(resolved) === name ? gitDirOwner(path6.dirname(resolved)) : null;
4452
4549
  if (owner === null || lender !== null && lender !== owner)
4453
4550
  return false;
4454
4551
  lender = owner;
@@ -4462,7 +4559,7 @@ var gitDirOwner = (real) => {
4462
4559
  return null;
4463
4560
  const rest = parts.slice(at + 1);
4464
4561
  const module = rest[0] === "modules" || rest[0] === "worktrees" && rest[2] === "modules";
4465
- return rest.length === 0 || module ? parts.slice(0, at).join(path5.sep) || path5.sep : null;
4562
+ return rest.length === 0 || module ? parts.slice(0, at).join(path6.sep) || path6.sep : null;
4466
4563
  };
4467
4564
  var mainCheckoutOf = (cwd) => {
4468
4565
  const probe = probeCheckout(cwd);
@@ -4586,11 +4683,11 @@ var resolveRuntimeWorkspaceVcs = (cwd) => resolveRuntimeWorkspaceCandidate(cwd,
4586
4683
  var runtimeWorkspaceIndexSchema = looseObject({
4587
4684
  workspaces: optional(array(looseObject({ name: nonBlank, glob: nonBlank })))
4588
4685
  });
4589
- var matchRuntimeWorkspace = (cwd, dir = configDir()) => {
4590
- const file = path5.join(dir, "workspaces.json");
4686
+ var matchRuntimeWorkspace = (cwd, dir = configDir(), workspaceName = namedWorkspace()) => {
4687
+ const file = path6.join(dir, "workspaces.json");
4591
4688
  let raw;
4592
4689
  try {
4593
- raw = readFileSync4(file, "utf8");
4690
+ raw = readFileSync5(file, "utf8");
4594
4691
  } catch (error) {
4595
4692
  if (error.code === "ENOENT")
4596
4693
  return null;
@@ -4613,13 +4710,21 @@ var matchRuntimeWorkspace = (cwd, dir = configDir()) => {
4613
4710
  if (!glob.ok)
4614
4711
  throw new WorkspaceConfigError(`${file} workspace ${entry.name}: ${glob.error}`);
4615
4712
  }
4616
- const workspaceName = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
4617
- const selected = resolveWorkspaceFromEntries(cwd, entries ?? [], workspaceName, true);
4713
+ const matched = matchAmong(cwd, entries ?? [], workspaceName);
4714
+ return matched ? { file, ...matched } : null;
4715
+ };
4716
+ var namedWorkspace = () => process.env.WORKIT_WORKSPACE_NAME?.trim() || null;
4717
+ var matchAmong = (cwd, entries, workspaceName = namedWorkspace()) => {
4718
+ const selected = resolveWorkspaceFromEntries(cwd, entries, workspaceName ?? undefined, true);
4618
4719
  if (!selected)
4619
4720
  return null;
4620
- const matches = matchingEntries(cwd, entries ?? []);
4621
- return { file, selected, matches: matches.length ? matches : [selected] };
4721
+ const matches = matchingEntries(cwd, entries);
4722
+ return { selected, matches: matches.length ? matches : [selected] };
4622
4723
  };
4724
+ var chainOf = (matched) => matched ? [
4725
+ matched.selected,
4726
+ ...matched.matches.filter((entry) => entry !== matched.selected).toSorted((a, b) => globSpecificity(b.glob) - globSpecificity(a.glob))
4727
+ ] : [];
4623
4728
  var resolveRuntimeReleaseTracks = (cwd) => {
4624
4729
  const matched = matchRuntimeWorkspace(cwd);
4625
4730
  return matched ? {
@@ -4636,11 +4741,9 @@ var inheritedSetting = (cwd, dir, has) => {
4636
4741
  }
4637
4742
  if (!matched)
4638
4743
  return null;
4639
- const { selected, matches } = matched;
4640
- const enclosing = matches.filter((entry) => entry !== selected).toSorted((a, b) => globSpecificity(b.glob) - globSpecificity(a.glob));
4641
4744
  return {
4642
- workspace: selected.name,
4643
- source: [selected, ...enclosing].find(has) ?? null
4745
+ workspace: matched.selected.name,
4746
+ source: chainOf(matched).find(has) ?? null
4644
4747
  };
4645
4748
  };
4646
4749
  var resolveRuntimeReleasePackages = (cwd, dir) => {
@@ -4670,6 +4773,47 @@ var changelogPathOf = (value) => {
4670
4773
  return null;
4671
4774
  return parts.includes("..") ? null : parts.join("/");
4672
4775
  };
4776
+ var isPlainRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4777
+ var pickSet = (value, keys) => isPlainRecord(value) ? Object.fromEntries(keys.filter((key) => value[key] !== undefined).map((key) => [key, value[key]])) : {};
4778
+ var mapRecord = (value, map) => Object.fromEntries(Object.entries(value).map(([name, item]) => [name, map(item)]));
4779
+ var TRACK_LINE_KEYS = [
4780
+ "tagNamespace",
4781
+ "productionBranch",
4782
+ "integrationBranch",
4783
+ "baseBranch",
4784
+ "mergeBackBranches",
4785
+ "pullRequestTarget",
4786
+ "naming",
4787
+ "strategy"
4788
+ ];
4789
+ var releaseLineMapping = (entry, notes = false) => {
4790
+ if (!isPlainRecord(entry))
4791
+ return;
4792
+ const out = {};
4793
+ if (notes && entry.releaseNotes !== undefined)
4794
+ out.releaseNotes = entry.releaseNotes;
4795
+ if (entry.releaseTagPrefix !== undefined)
4796
+ out.releaseTagPrefix = entry.releaseTagPrefix;
4797
+ if (entry.defaultProfile !== undefined)
4798
+ out.defaultProfile = entry.defaultProfile;
4799
+ const policy = pickSet(entry.branchPolicy, ["releaseTagPrefix"]);
4800
+ if (Object.keys(policy).length)
4801
+ out.branchPolicy = policy;
4802
+ const profiles = Object.fromEntries(Object.entries(isPlainRecord(entry.profiles) ? entry.profiles : {}).flatMap(([name, profile]) => {
4803
+ const prefix = pickSet(isPlainRecord(profile) ? profile.branchPolicy : undefined, [
4804
+ "releaseTagPrefix"
4805
+ ]);
4806
+ return Object.keys(prefix).length ? [[name, { branchPolicy: prefix }]] : [];
4807
+ }));
4808
+ if (Object.keys(profiles).length)
4809
+ out.profiles = profiles;
4810
+ const trackKeys = notes ? [...TRACK_LINE_KEYS, "releaseNotes"] : TRACK_LINE_KEYS;
4811
+ if (entry.releaseTracks !== undefined)
4812
+ out.releaseTracks = isPlainRecord(entry.releaseTracks) ? mapRecord(entry.releaseTracks, (track) => pickSet(track, trackKeys)) : entry.releaseTracks;
4813
+ if (entry.releasePackages !== undefined)
4814
+ out.releasePackages = isPlainRecord(entry.releasePackages) ? mapRecord(entry.releasePackages, (pkg) => pickSet(pkg, ["tagNamespace"])) : entry.releasePackages;
4815
+ return Object.keys(out).length ? out : undefined;
4816
+ };
4673
4817
  var modelSources = (cwd, dir) => {
4674
4818
  const out = [];
4675
4819
  try {
@@ -4686,7 +4830,7 @@ var modelSources = (cwd, dir) => {
4686
4830
  }
4687
4831
  } catch {}
4688
4832
  try {
4689
- const document = JSON.parse(readFileSync4(path5.join(dir ?? configDir(), "workspaces.json"), "utf8"));
4833
+ const document = JSON.parse(readFileSync5(path6.join(dir ?? configDir(), "workspaces.json"), "utf8"));
4690
4834
  if (document && typeof document === "object" && !Array.isArray(document))
4691
4835
  out.push({
4692
4836
  name: "global",
@@ -4751,10 +4895,10 @@ function workspaceDefaultTarget(cwd, globalDefault) {
4751
4895
 
4752
4896
  // packages/workit-core/src/core/vcs-config.ts
4753
4897
  import fs3 from "node:fs";
4754
- import path6 from "node:path";
4898
+ import path7 from "node:path";
4755
4899
 
4756
4900
  // packages/workit-core/src/core/release-tracks.ts
4757
- import { createHash as createHash3 } from "node:crypto";
4901
+ import { createHash as createHash4 } from "node:crypto";
4758
4902
  import { spawnSync as spawnSync6 } from "node:child_process";
4759
4903
  class ReleaseTrackError extends Error {
4760
4904
  }
@@ -5137,7 +5281,7 @@ function resolveTrackFor(cwd, options) {
5137
5281
  ]) ?? "",
5138
5282
  git2(cwd, ["config", "--get", recordedBaseKey(branch)]) ?? ""
5139
5283
  ] : [];
5140
- key = createHash3("sha256").update(JSON.stringify({ cwd, input, refs, head, own })).digest("hex");
5284
+ key = createHash4("sha256").update(JSON.stringify({ cwd, input, refs, head, own })).digest("hex");
5141
5285
  const hit = memo2.get(key);
5142
5286
  if (hit)
5143
5287
  return hit;
@@ -5152,7 +5296,7 @@ function resolveTrackFor(cwd, options) {
5152
5296
  }
5153
5297
 
5154
5298
  // packages/workit-core/src/core/vcs-config.ts
5155
- var workspacesPath = () => path6.join(configDir(), "workspaces.json");
5299
+ var workspacesPath = () => path7.join(configDir(), "workspaces.json");
5156
5300
  var vcsCwd = (cwd) => cwd ?? process.env.WORKIT_WORKSPACE_ROOT ?? process.cwd();
5157
5301
  var remoteProvider = (cwd) => {
5158
5302
  const url = originUrl(cwd) ?? "";
@@ -5291,7 +5435,7 @@ function vcsConfig(mode, cwd, options = {}) {
5291
5435
  const prov = cfg[provider] ?? {};
5292
5436
  const out = {
5293
5437
  ok: true,
5294
- configPath: path6.resolve(cfgPath),
5438
+ configPath: path7.resolve(cfgPath),
5295
5439
  provider,
5296
5440
  defaultTargetBranch: workspaceDefault,
5297
5441
  pr: cfg.pr ?? {},
@@ -5444,7 +5588,7 @@ var branchPolicySnapshotFor = (workspaceRoot) => {
5444
5588
  const source = resolved.provenance.branchPolicy;
5445
5589
  const allowed = branchPolicy.allowed.map((pattern) => `${pattern.source}/${pattern.flags}`).toSorted();
5446
5590
  const protectedRefs = [...branchPolicy.protected].map((name) => name.toLowerCase()).toSorted();
5447
- const fingerprint = createHash4("sha256").update(JSON.stringify({ allowed, protectedRefs, source })).digest("hex");
5591
+ const fingerprint = createHash5("sha256").update(JSON.stringify({ allowed, protectedRefs, source })).digest("hex");
5448
5592
  return {
5449
5593
  branchPolicy,
5450
5594
  namePolicy: { allowed: branchPolicy.allowed, protected: branchPolicy.protected },
@@ -5535,9 +5679,9 @@ var isProtectedTarget = (root, name) => {
5535
5679
  };
5536
5680
 
5537
5681
  // packages/workit-core/src/core/model-fallback.ts
5538
- import { createHash as createHash5 } from "node:crypto";
5539
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
5540
- import path7 from "node:path";
5682
+ import { createHash as createHash6 } from "node:crypto";
5683
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync6, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
5684
+ import path8 from "node:path";
5541
5685
 
5542
5686
  // packages/workit-core/src/core/logger.ts
5543
5687
  import os3 from "node:os";
@@ -5605,10 +5749,10 @@ var providerOf = (model, host) => {
5605
5749
  return null;
5606
5750
  };
5607
5751
  var empty = () => ({ exhausted: {}, seen: {}, redispatched: {} });
5608
- var storePath = (stateDir) => path7.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
5752
+ var storePath = (stateDir) => path8.join(stateDir ?? resolveStateDir(), LIMITS_FILE);
5609
5753
  var readStore = (stateDir) => {
5610
5754
  try {
5611
- const parsed = JSON.parse(readFileSync5(storePath(stateDir), "utf8"));
5755
+ const parsed = JSON.parse(readFileSync6(storePath(stateDir), "utf8"));
5612
5756
  const store = empty();
5613
5757
  for (const key of ["exhausted", "seen", "redispatched"])
5614
5758
  if (parsed[key] && typeof parsed[key] === "object")
@@ -5629,7 +5773,7 @@ var writeStore = (store, now, stateDir) => {
5629
5773
  delete store.exhausted[id];
5630
5774
  try {
5631
5775
  const file = storePath(stateDir);
5632
- mkdirSync2(path7.dirname(file), { recursive: true });
5776
+ mkdirSync2(path8.dirname(file), { recursive: true });
5633
5777
  const temp = `${file}.${process.pid}.tmp`;
5634
5778
  writeFileSync2(temp, `${JSON.stringify(store, null, 2)}
5635
5779
  `);
@@ -5665,7 +5809,7 @@ var firstSighting = (id, now = new Date, stateDir) => {
5665
5809
  writeStore(store, now, stateDir);
5666
5810
  return true;
5667
5811
  };
5668
- var promptKey = (prompt) => createHash5("sha256").update(prompt.trim()).digest("hex").slice(0, 16);
5812
+ var promptKey = (prompt) => createHash6("sha256").update(prompt.trim()).digest("hex").slice(0, 16);
5669
5813
  var claimRedispatch = (key, now = new Date, stateDir) => {
5670
5814
  const store = readStore(stateDir);
5671
5815
  if (store.redispatched[key])
@@ -6083,14 +6227,14 @@ ${table}` : bootstrap;
6083
6227
 
6084
6228
  // packages/workit-core/src/store/paths.ts
6085
6229
  import { spawnSync as spawnSync7 } from "node:child_process";
6086
- import { createHash as createHash6 } from "node:crypto";
6230
+ import { createHash as createHash7 } from "node:crypto";
6087
6231
  import fs5 from "node:fs";
6088
- import path9 from "node:path";
6232
+ import path10 from "node:path";
6089
6233
 
6090
6234
  // packages/workit-core/src/store/folder-store.ts
6091
6235
  import fs4 from "node:fs";
6092
6236
  import os4 from "node:os";
6093
- import path8 from "node:path";
6237
+ import path9 from "node:path";
6094
6238
  var FOLDER_CONFIG = new Set(["checks.json", "risk-paths"]);
6095
6239
  var MOVED_POINTER = "MOVED-TO-STATE.txt";
6096
6240
  var V2_LEFTOVERS = new Set(["recovery", "index.json"]);
@@ -6099,7 +6243,7 @@ var MARKER = "workspace.json";
6099
6243
  var v2Workspace = (workit) => {
6100
6244
  let bytes;
6101
6245
  try {
6102
- bytes = fs4.readFileSync(path8.join(workit, MARKER), "utf8");
6246
+ bytes = fs4.readFileSync(path9.join(workit, MARKER), "utf8");
6103
6247
  } catch {
6104
6248
  return null;
6105
6249
  }
@@ -6148,7 +6292,7 @@ var strayEntries = (workit) => {
6148
6292
  } catch {
6149
6293
  return [];
6150
6294
  }
6151
- return names.filter((name) => !FOLDER_CONFIG.has(name) && !V2_LEFTOVERS.has(name) && name !== MOVED_POINTER && name !== MARKER && !(name === ".gitignore" && generatedIgnore(path8.join(workit, name))) && !(name === "tasks" && onlyStubs(path8.join(workit, name))));
6295
+ return names.filter((name) => !FOLDER_CONFIG.has(name) && !V2_LEFTOVERS.has(name) && name !== MOVED_POINTER && name !== MARKER && !(name === ".gitignore" && generatedIgnore(path9.join(workit, name))) && !(name === "tasks" && onlyStubs(path9.join(workit, name))));
6152
6296
  };
6153
6297
  var folderStoreIo = {
6154
6298
  rename: (from, to) => fs4.renameSync(from, to),
@@ -6156,13 +6300,13 @@ var folderStoreIo = {
6156
6300
  judgedStale: () => {}
6157
6301
  };
6158
6302
  var tempSeq = 0;
6159
- var tempBeside = (file) => path8.join(path8.dirname(file), `.${path8.basename(file)}.workit-move-${process.pid}-${tempSeq += 1}`);
6303
+ var tempBeside = (file) => path9.join(path9.dirname(file), `.${path9.basename(file)}.workit-move-${process.pid}-${tempSeq += 1}`);
6160
6304
  var copyInto = (from, to) => {
6161
6305
  const stat = fs4.lstatSync(from);
6162
6306
  if (stat.isDirectory()) {
6163
6307
  fs4.mkdirSync(to, { recursive: true });
6164
6308
  for (const name of fs4.readdirSync(from))
6165
- copyInto(path8.join(from, name), path8.join(to, name));
6309
+ copyInto(path9.join(from, name), path9.join(to, name));
6166
6310
  return;
6167
6311
  }
6168
6312
  if (exists(to))
@@ -6213,7 +6357,7 @@ var merge2 = (from, to, rel, moved) => {
6213
6357
  }
6214
6358
  if (!isDir(from) || !isDir(to))
6215
6359
  return [rel];
6216
- const kept = fs4.readdirSync(from).flatMap((name) => merge2(path8.join(from, name), path8.join(to, name), `${rel}/${name}`, moved));
6360
+ const kept = fs4.readdirSync(from).flatMap((name) => merge2(path9.join(from, name), path9.join(to, name), `${rel}/${name}`, moved));
6217
6361
  try {
6218
6362
  if (fs4.readdirSync(from).length === 0)
6219
6363
  fs4.rmdirSync(from);
@@ -6292,38 +6436,38 @@ var takeMoveLock = (target) => {
6292
6436
  pause(25);
6293
6437
  }
6294
6438
  };
6295
- var canonical2 = (dir) => {
6439
+ var canonical3 = (dir) => {
6296
6440
  try {
6297
6441
  return fs4.realpathSync.native(dir);
6298
6442
  } catch {
6299
- return path8.resolve(dir);
6443
+ return path9.resolve(dir);
6300
6444
  }
6301
6445
  };
6302
6446
  var below = (parent, child) => {
6303
- const rel = path8.relative(parent, child);
6304
- return rel !== "" && !rel.startsWith("..") && !path8.isAbsolute(rel);
6447
+ const rel = path9.relative(parent, child);
6448
+ return rel !== "" && !rel.startsWith("..") && !path9.isAbsolute(rel);
6305
6449
  };
6306
- var insideTempDir = (dir, tempDir = os4.tmpdir()) => below(canonical2(tempDir), canonical2(dir));
6450
+ var insideTempDir = (dir, tempDir = os4.tmpdir()) => below(canonical3(tempDir), canonical3(dir));
6307
6451
  var TEST_RUN_REFUSALS = "folder-store-refusals.log";
6308
6452
  var testRunFolderRefusal = (folder, hasStray, env = process.env, tempDir = os4.tmpdir()) => {
6309
6453
  if (env.WORKIT_TEST_RUN === undefined || !hasStray)
6310
6454
  return null;
6311
- const real = canonical2(folder);
6312
- const tmp = canonical2(tempDir);
6455
+ const real = canonical3(folder);
6456
+ const tmp = canonical3(tempDir);
6313
6457
  if (insideTempDir(folder, tempDir))
6314
6458
  return null;
6315
- return `workit test run (WORKIT_TEST_RUN): refusing to move ${path8.join(real, ".workit")} into the run's throwaway state dir; a test must work in a fresh dir inside ${tmp}, never the temp dir itself, a parent of it or a folder outside it (#892)`;
6459
+ return `workit test run (WORKIT_TEST_RUN): refusing to move ${path9.join(real, ".workit")} into the run's throwaway state dir; a test must work in a fresh dir inside ${tmp}, never the temp dir itself, a parent of it or a folder outside it (#892)`;
6316
6460
  };
6317
6461
  function migrateFolderStore(folder, target, note = (line) => process.stderr.write(`${line}
6318
6462
  `)) {
6319
- const workit = path8.join(folder, ".workit");
6463
+ const workit = path9.join(folder, ".workit");
6320
6464
  const names = strayEntries(workit);
6321
6465
  const refusal = testRunFolderRefusal(folder, names.length > 0);
6322
6466
  if (refusal) {
6323
6467
  const run = process.env.WORKIT_TEST_RUN ?? "";
6324
- if (path8.isAbsolute(run))
6468
+ if (path9.isAbsolute(run))
6325
6469
  try {
6326
- fs4.appendFileSync(path8.join(run, TEST_RUN_REFUSALS), `${refusal}
6470
+ fs4.appendFileSync(path9.join(run, TEST_RUN_REFUSALS), `${refusal}
6327
6471
  `);
6328
6472
  } catch {}
6329
6473
  throw new Error(refusal);
@@ -6331,7 +6475,7 @@ function migrateFolderStore(folder, target, note = (line) => process.stderr.writ
6331
6475
  if (names.length === 0 || v2Workspace(workit) === true)
6332
6476
  return null;
6333
6477
  try {
6334
- fs4.mkdirSync(path8.dirname(target), { recursive: true });
6478
+ fs4.mkdirSync(path9.dirname(target), { recursive: true });
6335
6479
  } catch {
6336
6480
  return null;
6337
6481
  }
@@ -6355,7 +6499,7 @@ function moveLocked(workit, target, note) {
6355
6499
  }
6356
6500
  const result = { from: workit, to: target, moved: [], kept: [] };
6357
6501
  for (const name of names) {
6358
- result.kept.push(...merge2(path8.join(workit, name), path8.join(target, name), name, result.moved));
6502
+ result.kept.push(...merge2(path9.join(workit, name), path9.join(target, name), name, result.moved));
6359
6503
  }
6360
6504
  const left = (() => {
6361
6505
  try {
@@ -6364,13 +6508,13 @@ function moveLocked(workit, target, note) {
6364
6508
  return [];
6365
6509
  }
6366
6510
  })();
6367
- const v2Left = left.some((name) => V2_LEFTOVERS.has(name) || name === "tasks" && isDir(path8.join(workit, name)));
6511
+ const v2Left = left.some((name) => V2_LEFTOVERS.has(name) || name === "tasks" && isDir(path9.join(workit, name)));
6368
6512
  if (!v2Left && result.kept.length === 0) {
6369
- fs4.rmSync(path8.join(workit, MARKER), { force: true });
6370
- if (generatedIgnore(path8.join(workit, ".gitignore")))
6371
- fs4.rmSync(path8.join(workit, ".gitignore"), { force: true });
6513
+ fs4.rmSync(path9.join(workit, MARKER), { force: true });
6514
+ if (generatedIgnore(path9.join(workit, ".gitignore")))
6515
+ fs4.rmSync(path9.join(workit, ".gitignore"), { force: true });
6372
6516
  }
6373
- const pointer = path8.join(workit, MOVED_POINTER);
6517
+ const pointer = path9.join(workit, MOVED_POINTER);
6374
6518
  let wrote = false;
6375
6519
  if (result.kept.length > 0) {
6376
6520
  const text = `Workit keeps this folder's state in ${target}.
@@ -6420,7 +6564,7 @@ var gitRun = (cwd, args) => {
6420
6564
  missing: error?.code === "ENOENT"
6421
6565
  };
6422
6566
  };
6423
- var shortHash = (value) => createHash6("sha256").update(value).digest("hex").slice(0, 12);
6567
+ var shortHash = (value) => createHash7("sha256").update(value).digest("hex").slice(0, 12);
6424
6568
  var real = (file) => {
6425
6569
  try {
6426
6570
  return fs5.realpathSync.native(file);
@@ -6437,14 +6581,14 @@ var DISCOVERY_ENV = [
6437
6581
  ];
6438
6582
  var isGitDir = (dir) => {
6439
6583
  try {
6440
- return fs5.statSync(path9.join(dir, "HEAD")).isFile() && fs5.statSync(path9.join(dir, "objects")).isDirectory() && fs5.statSync(path9.join(dir, "refs")).isDirectory();
6584
+ return fs5.statSync(path10.join(dir, "HEAD")).isFile() && fs5.statSync(path10.join(dir, "objects")).isDirectory() && fs5.statSync(path10.join(dir, "refs")).isDirectory();
6441
6585
  } catch {
6442
6586
  return false;
6443
6587
  }
6444
6588
  };
6445
6589
  var reftableRefs = (common) => {
6446
6590
  try {
6447
- return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs5.readFileSync(path9.join(common, "config"), "utf8"));
6591
+ return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs5.readFileSync(path10.join(common, "config"), "utf8"));
6448
6592
  } catch {
6449
6593
  return false;
6450
6594
  }
@@ -6464,7 +6608,7 @@ function fastGit(root) {
6464
6608
  if (device !== null && stat.dev !== device)
6465
6609
  return { kind: "none" };
6466
6610
  device = stat.dev;
6467
- const dotGit = path9.join(dir, ".git");
6611
+ const dotGit = path10.join(dir, ".git");
6468
6612
  let entry = null;
6469
6613
  try {
6470
6614
  entry = fs5.statSync(dotGit);
@@ -6485,19 +6629,19 @@ function fastGit(root) {
6485
6629
  const match = /^gitdir: (.+)$/mu.exec(text);
6486
6630
  if (!match)
6487
6631
  return null;
6488
- gitDir = path9.resolve(dir, match[1].trim());
6632
+ gitDir = path10.resolve(dir, match[1].trim());
6489
6633
  } else
6490
6634
  return null;
6491
- if (!fs5.existsSync(path9.join(gitDir, "HEAD")))
6635
+ if (!fs5.existsSync(path10.join(gitDir, "HEAD")))
6492
6636
  return null;
6493
6637
  } else if (isGitDir(dir))
6494
6638
  gitDir = dir;
6495
6639
  if (gitDir) {
6496
6640
  let common = gitDir;
6497
6641
  try {
6498
- common = path9.resolve(gitDir, fs5.readFileSync(path9.join(gitDir, "commondir"), "utf8").trim());
6642
+ common = path10.resolve(gitDir, fs5.readFileSync(path10.join(gitDir, "commondir"), "utf8").trim());
6499
6643
  } catch {}
6500
- if (!fs5.existsSync(path9.join(common, "objects")))
6644
+ if (!fs5.existsSync(path10.join(common, "objects")))
6501
6645
  return null;
6502
6646
  return {
6503
6647
  kind: "repo",
@@ -6507,7 +6651,7 @@ function fastGit(root) {
6507
6651
  reftable: reftableRefs(common)
6508
6652
  };
6509
6653
  }
6510
- const parent = path9.dirname(dir);
6654
+ const parent = path10.dirname(dir);
6511
6655
  if (parent === dir)
6512
6656
  return { kind: "none" };
6513
6657
  dir = parent;
@@ -6519,7 +6663,7 @@ var outsideGit = (root) => {
6519
6663
  return { dir, shared: false, top: null };
6520
6664
  };
6521
6665
  function resolveStore(root) {
6522
- root = path9.resolve(root);
6666
+ root = path10.resolve(root);
6523
6667
  let stat = null;
6524
6668
  try {
6525
6669
  stat = fs5.statSync(root);
@@ -6527,13 +6671,13 @@ function resolveStore(root) {
6527
6671
  if (!stat)
6528
6672
  return new Error(`cannot locate the workit store: ${root} does not exist (removed while workit ran?); nothing is recorded under a missing directory`);
6529
6673
  if (!stat.isDirectory())
6530
- return { dir: path9.join(root, ".workit"), shared: false, top: null };
6674
+ return { dir: path10.join(root, ".workit"), shared: false, top: null };
6531
6675
  const fast = fastGit(root);
6532
6676
  if (fast?.kind === "none")
6533
6677
  return outsideGit(root);
6534
6678
  if (fast?.kind === "repo")
6535
6679
  return {
6536
- dir: path9.join(fast.common, "workit"),
6680
+ dir: path10.join(fast.common, "workit"),
6537
6681
  shared: true,
6538
6682
  top: fast.top,
6539
6683
  git: { gitDir: fast.gitDir, top: fast.top, reftable: fast.reftable }
@@ -6543,7 +6687,7 @@ function resolveStore(root) {
6543
6687
  if (run.ok && common) {
6544
6688
  const top = gitRun(root, ["rev-parse", "--path-format=absolute", "--show-toplevel"]);
6545
6689
  return {
6546
- dir: path9.join(real(path9.resolve(root, common)), "workit"),
6690
+ dir: path10.join(real(path10.resolve(root, common)), "workit"),
6547
6691
  shared: true,
6548
6692
  top: top.ok && top.stdout.trim() ? real(top.stdout.trim()) : null
6549
6693
  };
@@ -6556,7 +6700,7 @@ function resolveStore(root) {
6556
6700
  var rebasingBranch = (gitDir) => {
6557
6701
  for (const state of ["rebase-merge", "rebase-apply"]) {
6558
6702
  try {
6559
- const ref = fs5.readFileSync(path9.join(gitDir, state, "head-name"), "utf8").trim();
6703
+ const ref = fs5.readFileSync(path10.join(gitDir, state, "head-name"), "utf8").trim();
6560
6704
  const match = /^refs\/heads\/(.+)$/u.exec(ref);
6561
6705
  if (match)
6562
6706
  return match[1];
@@ -6571,7 +6715,7 @@ function resolveTaskKey(root, location) {
6571
6715
  if (location.git && !location.git.reftable) {
6572
6716
  let head = "";
6573
6717
  try {
6574
- head = fs5.readFileSync(path9.join(location.git.gitDir, "HEAD"), "utf8").trim();
6718
+ head = fs5.readFileSync(path10.join(location.git.gitDir, "HEAD"), "utf8").trim();
6575
6719
  } catch {}
6576
6720
  const ref = /^ref: refs\/heads\/(.+)$/u.exec(head);
6577
6721
  if (ref && ref[1] !== ".invalid")
@@ -6602,7 +6746,7 @@ function resolveTaskKey(root, location) {
6602
6746
  return { key: `detached-${shortHash(real(worktree))}`, kind: "detached", branch: null };
6603
6747
  }
6604
6748
  function checkoutRootOf(root, location) {
6605
- const resolved = path9.resolve(root);
6749
+ const resolved = path10.resolve(root);
6606
6750
  let canonical = resolved;
6607
6751
  try {
6608
6752
  canonical = fs5.realpathSync(resolved);
@@ -6633,13 +6777,13 @@ function branchRenames(location) {
6633
6777
  }
6634
6778
  for (const entry of entries)
6635
6779
  if (entry.isDirectory())
6636
- walk(path9.join(dir, entry.name));
6780
+ walk(path10.join(dir, entry.name));
6637
6781
  else
6638
- files.push(path9.join(dir, entry.name));
6782
+ files.push(path10.join(dir, entry.name));
6639
6783
  };
6640
- walk(path9.join(path9.dirname(location.dir), "logs", "refs", "heads"));
6784
+ walk(path10.join(path10.dirname(location.dir), "logs", "refs", "heads"));
6641
6785
  if (location.git)
6642
- files.push(path9.join(location.git.gitDir, "logs", "HEAD"));
6786
+ files.push(path10.join(location.git.gitDir, "logs", "HEAD"));
6643
6787
  const seen = new Set;
6644
6788
  const renames = [];
6645
6789
  for (const file of files) {
@@ -6673,7 +6817,7 @@ function followRenames(key, boundAt, renames) {
6673
6817
  var checkoutSlug = (root) => folderSlug2(root);
6674
6818
 
6675
6819
  // packages/workit-core/src/core/task-contract.ts
6676
- import { createHash as createHash7, randomUUID } from "node:crypto";
6820
+ import { createHash as createHash8, randomUUID } from "node:crypto";
6677
6821
 
6678
6822
  // packages/workit-core/src/core/scope-glob.ts
6679
6823
  var GLOB = /[*?[\]{}]/u;
@@ -7235,7 +7379,7 @@ function resolveIdRef(kind, ref, ids) {
7235
7379
  return failure2("not_found", `${kind} not found`);
7236
7380
  return failure2("invalid_input", `${kind} prefix ${ref} is ambiguous; candidates: ${matches.join(", ")}`);
7237
7381
  }
7238
- function canonical3(value, seen) {
7382
+ function canonical4(value, seen) {
7239
7383
  if (value === null || typeof value === "boolean" || typeof value === "string") {
7240
7384
  if (typeof value === "string" && invalidUnicode(value))
7241
7385
  throw new TypeError("invalid Unicode");
@@ -7257,7 +7401,7 @@ function canonical3(value, seen) {
7257
7401
  if (!(index in value))
7258
7402
  throw new TypeError("sparse array");
7259
7403
  }
7260
- result = value.map((item) => canonical3(item, seen));
7404
+ result = value.map((item) => canonical4(item, seen));
7261
7405
  } else {
7262
7406
  if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
7263
7407
  throw new TypeError("value is not a JSON object");
@@ -7265,18 +7409,18 @@ function canonical3(value, seen) {
7265
7409
  throw new TypeError("symbol key is not JSON");
7266
7410
  if (Object.keys(value).some((key) => invalidUnicode(key)))
7267
7411
  throw new TypeError("invalid Unicode");
7268
- result = Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, canonical3(value[key], seen)]));
7412
+ result = Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, canonical4(value[key], seen)]));
7269
7413
  }
7270
7414
  seen.delete(value);
7271
7415
  return result;
7272
7416
  }
7273
7417
  function canonicalJson(value) {
7274
- return JSON.stringify(canonical3(value, new Set));
7418
+ return JSON.stringify(canonical4(value, new Set));
7275
7419
  }
7276
7420
  function sha256(value) {
7277
7421
  if (typeof value === "string" && invalidUnicode(value))
7278
7422
  throw new TypeError("invalid Unicode");
7279
- return createHash7("sha256").update(typeof value === "string" ? value : canonicalJson(value), "utf8").digest("hex");
7423
+ return createHash8("sha256").update(typeof value === "string" ? value : canonicalJson(value), "utf8").digest("hex");
7280
7424
  }
7281
7425
  function newId() {
7282
7426
  return randomUUID().toLowerCase();
@@ -7311,15 +7455,15 @@ function candidateDigest(input) {
7311
7455
  }
7312
7456
 
7313
7457
  // packages/workit-core/src/core/task-evaluation.ts
7314
- import { createHash as createHash10 } from "node:crypto";
7458
+ import { createHash as createHash11 } from "node:crypto";
7315
7459
  import * as fs14 from "node:fs";
7316
7460
  import { spawnSync as spawnSync12 } from "node:child_process";
7317
- import path19 from "node:path";
7461
+ import path20 from "node:path";
7318
7462
 
7319
7463
  // packages/workit-core/src/core/task-read.ts
7320
7464
  import { randomUUID as randomUUID3 } from "node:crypto";
7321
7465
  import * as fs11 from "node:fs";
7322
- import path14 from "node:path";
7466
+ import path15 from "node:path";
7323
7467
 
7324
7468
  // node_modules/@openclaw/fs-safe/dist/errors.js
7325
7469
  var OPERATIONAL_CODES = new Set([
@@ -7370,7 +7514,7 @@ function sameFileIdentity(left, right, platform = process.platform) {
7370
7514
  // node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js
7371
7515
  import { randomBytes } from "node:crypto";
7372
7516
  import fsSync from "node:fs";
7373
- import path10 from "node:path";
7517
+ import path11 from "node:path";
7374
7518
 
7375
7519
  // node_modules/@openclaw/fs-safe/dist/bounded-read.js
7376
7520
  import fs6 from "node:fs";
@@ -7460,13 +7604,13 @@ ${ownershipToken}
7460
7604
  return { raw, ownershipToken };
7461
7605
  }
7462
7606
  function relativeSidecarLockPath(lockRoot, lockPath) {
7463
- const resolved = path10.resolve(lockPath);
7464
- const lexicalRelative = path10.relative(lockRoot.rootDir, resolved);
7465
- const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path10.sep}`) && !path10.isAbsolute(lexicalRelative) ? lexicalRelative : path10.relative(lockRoot.rootReal, resolved);
7466
- if (!relative || relative === ".." || relative.startsWith(`..${path10.sep}`) || path10.isAbsolute(relative)) {
7607
+ const resolved = path11.resolve(lockPath);
7608
+ const lexicalRelative = path11.relative(lockRoot.rootDir, resolved);
7609
+ const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path11.sep}`) && !path11.isAbsolute(lexicalRelative) ? lexicalRelative : path11.relative(lockRoot.rootReal, resolved);
7610
+ if (!relative || relative === ".." || relative.startsWith(`..${path11.sep}`) || path11.isAbsolute(relative)) {
7467
7611
  throw new FsSafeError("outside-workspace", "sidecar lock path is outside lockRoot");
7468
7612
  }
7469
- return relative.split(path10.sep).join(path10.posix.sep);
7613
+ return relative.split(path11.sep).join(path11.posix.sep);
7470
7614
  }
7471
7615
  function parseSidecarLockPayload(raw, parser) {
7472
7616
  if (parser) {
@@ -7613,7 +7757,7 @@ function getFsSafeLockConfig() {
7613
7757
 
7614
7758
  // node_modules/@openclaw/fs-safe/dist/file-lock-sync.js
7615
7759
  import fs8 from "node:fs";
7616
- import path11 from "node:path";
7760
+ import path12 from "node:path";
7617
7761
 
7618
7762
  // node_modules/@openclaw/fs-safe/dist/timing.js
7619
7763
  function sleepSync(ms) {
@@ -7704,26 +7848,26 @@ function canonicalLockParentSync(parent) {
7704
7848
  return process.platform === "win32" ? fs8.realpathSync.native(parent) : fs8.realpathSync(parent);
7705
7849
  }
7706
7850
  function normalizeTargetPath(targetPath) {
7707
- const resolved = path11.resolve(targetPath);
7708
- fs8.mkdirSync(path11.dirname(resolved), { recursive: true });
7851
+ const resolved = path12.resolve(targetPath);
7852
+ fs8.mkdirSync(path12.dirname(resolved), { recursive: true });
7709
7853
  try {
7710
- return path11.join(canonicalLockParentSync(path11.dirname(resolved)), path11.basename(resolved));
7854
+ return path12.join(canonicalLockParentSync(path12.dirname(resolved)), path12.basename(resolved));
7711
7855
  } catch {
7712
7856
  return resolved;
7713
7857
  }
7714
7858
  }
7715
7859
  function boundedLockPath(lockPath, lockRoot) {
7716
- const resolved = path11.resolve(lockPath);
7860
+ const resolved = path12.resolve(lockPath);
7717
7861
  if (!lockRoot)
7718
7862
  return resolved;
7719
7863
  relativeSidecarLockPath(lockRoot, resolved);
7720
- const parent = path11.dirname(resolved);
7864
+ const parent = path12.dirname(resolved);
7721
7865
  const parentReal = canonicalLockParentSync(parent);
7722
- const parentRelative = path11.relative(lockRoot.rootReal, parentReal);
7723
- if (parentRelative === ".." || parentRelative.startsWith(`..${path11.sep}`) || path11.isAbsolute(parentRelative)) {
7866
+ const parentRelative = path12.relative(lockRoot.rootReal, parentReal);
7867
+ if (parentRelative === ".." || parentRelative.startsWith(`..${path12.sep}`) || path12.isAbsolute(parentRelative)) {
7724
7868
  throw new FsSafeError("outside-workspace", "sidecar lock parent is outside lockRoot");
7725
7869
  }
7726
- return path11.join(parentReal, path11.basename(resolved));
7870
+ return path12.join(parentReal, path12.basename(resolved));
7727
7871
  }
7728
7872
  function defaultShouldReclaim(snapshot, staleMs, nowMs) {
7729
7873
  const createdAtMs = sidecarLockPayloadCreatedAtMs(snapshot.payload);
@@ -7924,13 +8068,13 @@ function acquireFileLockSync(targetPath, options) {
7924
8068
  }
7925
8069
  // packages/workit-core/src/core/package-root.ts
7926
8070
  import { existsSync as existsSync4 } from "node:fs";
7927
- import path12 from "node:path";
8071
+ import path13 from "node:path";
7928
8072
  import { fileURLToPath } from "node:url";
7929
8073
  var packageRoot = () => {
7930
- let dir = path12.dirname(fileURLToPath(import.meta.url));
8074
+ let dir = path13.dirname(fileURLToPath(import.meta.url));
7931
8075
  while (true) {
7932
- const parent = path12.dirname(dir);
7933
- if (existsSync4(path12.join(dir, "package.json")) || parent === dir)
8076
+ const parent = path13.dirname(dir);
8077
+ if (existsSync4(path13.join(dir, "package.json")) || parent === dir)
7934
8078
  return dir;
7935
8079
  dir = parent;
7936
8080
  }
@@ -8088,7 +8232,7 @@ var clearAbandonedReclaimGuard = (lockPath, nowMs = Date.now()) => {
8088
8232
  // packages/workit-core/src/store/event-log.ts
8089
8233
  import { randomUUID as randomUUID2 } from "node:crypto";
8090
8234
  import fs10 from "node:fs";
8091
- import path13 from "node:path";
8235
+ import path14 from "node:path";
8092
8236
  var EVENT_VERSION = 1;
8093
8237
 
8094
8238
  class LogDamage extends Error {
@@ -8189,7 +8333,7 @@ function replaceFile(file, bytes, durable) {
8189
8333
  }
8190
8334
  renameWithRetry(temporary, file);
8191
8335
  if (durable)
8192
- fsyncDirectory(path13.dirname(file));
8336
+ fsyncDirectory(path14.dirname(file));
8193
8337
  } catch (error) {
8194
8338
  try {
8195
8339
  fs10.unlinkSync(temporary);
@@ -8426,7 +8570,7 @@ var cachedRuntimeVersion = null;
8426
8570
  var runtimeVersion = () => {
8427
8571
  if (cachedRuntimeVersion === null) {
8428
8572
  try {
8429
- const pkg = JSON.parse(fs11.readFileSync(path14.join(packageRoot(), "package.json"), "utf8"));
8573
+ const pkg = JSON.parse(fs11.readFileSync(path15.join(packageRoot(), "package.json"), "utf8"));
8430
8574
  cachedRuntimeVersion = typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
8431
8575
  } catch {
8432
8576
  cachedRuntimeVersion = "0.0.0";
@@ -8455,7 +8599,7 @@ var readText2 = (file) => {
8455
8599
  };
8456
8600
  var REFLOG_LINE = /^[0-9a-f]+ ([0-9a-f]+) .* (\d+) [+-]\d{4}\t(.*)$/u;
8457
8601
  var branchStart = (location, branch, aliases) => {
8458
- const first = readText2(path14.join(path14.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
8602
+ const first = readText2(path15.join(path15.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
8459
8603
  `, 1)[0];
8460
8604
  const created = REFLOG_LINE.exec(first);
8461
8605
  const start = created && /^branch: Created from (\S+)$/u.exec(created[3])?.[1];
@@ -8465,7 +8609,7 @@ var branchStart = (location, branch, aliases) => {
8465
8609
  return start;
8466
8610
  if (!location.git)
8467
8611
  return null;
8468
- for (const line of readText2(path14.join(location.git.gitDir, "logs", "HEAD")).split(`
8612
+ for (const line of readText2(path15.join(location.git.gitDir, "logs", "HEAD")).split(`
8469
8613
  `)) {
8470
8614
  const entry = REFLOG_LINE.exec(line);
8471
8615
  const moved = entry && /^checkout: moving from (\S+) to (\S+)$/u.exec(entry[3]);
@@ -8475,14 +8619,14 @@ var branchStart = (location, branch, aliases) => {
8475
8619
  }
8476
8620
  return null;
8477
8621
  };
8478
- var refExists2 = (common, ref) => fs11.existsSync(path14.join(common, ref)) || readText2(path14.join(common, "packed-refs")).includes(` ${ref}
8622
+ var refExists2 = (common, ref) => fs11.existsSync(path15.join(common, ref)) || readText2(path15.join(common, "packed-refs")).includes(` ${ref}
8479
8623
  `);
8480
8624
  var origins = new Map;
8481
8625
  var sameDirectoryIdentity = (left, right) => {
8482
- if (!path14.isAbsolute(left) || !path14.isAbsolute(right))
8626
+ if (!path15.isAbsolute(left) || !path15.isAbsolute(right))
8483
8627
  return false;
8484
- const normalizedLeft = path14.resolve(left);
8485
- const normalizedRight = path14.resolve(right);
8628
+ const normalizedLeft = path15.resolve(left);
8629
+ const normalizedRight = path15.resolve(right);
8486
8630
  try {
8487
8631
  const a = fs11.statSync(normalizedLeft, { bigint: true });
8488
8632
  const b = fs11.statSync(normalizedRight, { bigint: true });
@@ -8516,14 +8660,14 @@ class TaskReader {
8516
8660
  located;
8517
8661
  migrationChecked = false;
8518
8662
  constructor(root, options = {}) {
8519
- const resolved = path14.resolve(root);
8663
+ const resolved = path15.resolve(root);
8520
8664
  this.origin = fs11.existsSync(resolved) ? fs11.realpathSync(resolved) : resolved;
8521
8665
  this.located = resolveStore(this.origin);
8522
8666
  this.root = checkoutRootOf(this.origin, this.located);
8523
8667
  this.lockTimeoutMs = options.lockTimeoutMs ?? defaultLockTimeout();
8524
8668
  }
8525
8669
  location() {
8526
- if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs11.existsSync(path14.join(this.root, ".git"))) {
8670
+ if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs11.existsSync(path15.join(this.root, ".git"))) {
8527
8671
  this.located = undefined;
8528
8672
  this.migrationChecked = false;
8529
8673
  }
@@ -8681,14 +8825,14 @@ class TaskReader {
8681
8825
  const branch = key.ok ? key.data.branch : null;
8682
8826
  if (!branch || !location.ok)
8683
8827
  return success(null, null, null);
8684
- const common = path14.dirname(location.data.dir);
8685
- const heads = path14.join(common, "logs", "refs", "heads");
8686
- const headLog = location.data.git ? path14.join(location.data.git.gitDir, "logs", "HEAD") : "";
8828
+ const common = path15.dirname(location.data.dir);
8829
+ const heads = path15.join(common, "logs", "refs", "heads");
8830
+ const headLog = location.data.git ? path15.join(location.data.git.gitDir, "logs", "HEAD") : "";
8687
8831
  const signatures = [
8688
- path14.join(heads, branch),
8832
+ path15.join(heads, branch),
8689
8833
  headLog,
8690
8834
  heads,
8691
- path14.join(common, "packed-refs")
8835
+ path15.join(common, "packed-refs")
8692
8836
  ].map((file) => fileSignature(file) ?? "-");
8693
8837
  const slot = `${location.data.dir}\x00${headLog}\x00${branch}`;
8694
8838
  let resolved = origins.get(slot);
@@ -8700,7 +8844,7 @@ class TaskReader {
8700
8844
  aliases.push(rename.from);
8701
8845
  const start = branchStart(location.data, branch, aliases);
8702
8846
  const slash = start?.indexOf("/") ?? -1;
8703
- const remote = slash > 0 && !refExists2(common, `refs/heads/${start}`) && (refExists2(common, `refs/remotes/${start}`) || readText2(path14.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
8847
+ const remote = slash > 0 && !refExists2(common, `refs/heads/${start}`) && (refExists2(common, `refs/remotes/${start}`) || readText2(path15.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
8704
8848
  const name = start && (remote ? start.slice(slash + 1) : start);
8705
8849
  resolved = {
8706
8850
  signature: signatures.join("|"),
@@ -8720,27 +8864,27 @@ class TaskReader {
8720
8864
  }
8721
8865
  paths() {
8722
8866
  const location = this.location();
8723
- const dir = location.ok ? location.data.dir : path14.join(this.root, ".workit");
8724
- const checkout = path14.join(dir, "checkouts", checkoutSlug(this.root));
8867
+ const dir = location.ok ? location.data.dir : path15.join(this.root, ".workit");
8868
+ const checkout = path15.join(dir, "checkouts", checkoutSlug(this.root));
8725
8869
  return {
8726
8870
  dir,
8727
8871
  shared: location.ok ? location.data.shared : false,
8728
- marker: path14.join(dir, "store.json"),
8872
+ marker: path15.join(dir, "store.json"),
8729
8873
  checkout,
8730
- workspace: path14.join(checkout, "workspace.json"),
8731
- checkoutLock: path14.join(checkout, "metadata.lock"),
8732
- tasks: path14.join(dir, "tasks"),
8733
- index: path14.join(dir, "task-index.json"),
8734
- blobs: path14.join(dir, "blobs", "candidates"),
8735
- legacy: path14.join(dir, "legacy", checkoutSlug(this.root), "v2"),
8736
- v2: path14.join(this.root, ".workit")
8874
+ workspace: path15.join(checkout, "workspace.json"),
8875
+ checkoutLock: path15.join(checkout, "metadata.lock"),
8876
+ tasks: path15.join(dir, "tasks"),
8877
+ index: path15.join(dir, "task-index.json"),
8878
+ blobs: path15.join(dir, "blobs", "candidates"),
8879
+ legacy: path15.join(dir, "legacy", checkoutSlug(this.root), "v2"),
8880
+ v2: path15.join(this.root, ".workit")
8737
8881
  };
8738
8882
  }
8739
8883
  eventsPath(taskId) {
8740
- return path14.join(this.paths().tasks, taskId, "events.jsonl");
8884
+ return path15.join(this.paths().tasks, taskId, "events.jsonl");
8741
8885
  }
8742
8886
  snapshotPath(taskId) {
8743
- return path14.join(this.paths().tasks, taskId, "snapshot.json");
8887
+ return path15.join(this.paths().tasks, taskId, "snapshot.json");
8744
8888
  }
8745
8889
  ready(write = false) {
8746
8890
  const location = this.location();
@@ -8775,7 +8919,7 @@ class TaskReader {
8775
8919
  return {
8776
8920
  read: (digest) => {
8777
8921
  try {
8778
- return JSON.parse(fs11.readFileSync(path14.join(dir, `${digest}.json`), "utf8"));
8922
+ return JSON.parse(fs11.readFileSync(path15.join(dir, `${digest}.json`), "utf8"));
8779
8923
  } catch (error) {
8780
8924
  throw new LogDamage(`stored candidate ${digest} is missing or unreadable: ${String(error)}`);
8781
8925
  }
@@ -8941,11 +9085,11 @@ class TaskReader {
8941
9085
  return failure2("recovery_required", `${label} record does not satisfy its schema`);
8942
9086
  }
8943
9087
  v2Dirs() {
8944
- return [...new Set([this.root, this.origin])].map((dir) => path14.join(dir, ".workit"));
9088
+ return [...new Set([this.root, this.origin])].map((dir) => path15.join(dir, ".workit"));
8945
9089
  }
8946
9090
  pendingMigrations() {
8947
9091
  return this.v2Dirs().filter((dir) => {
8948
- const raw = this.readV2Workspace(path14.join(dir, "workspace.json"));
9092
+ const raw = this.readV2Workspace(path15.join(dir, "workspace.json"));
8949
9093
  return raw !== null && raw !== TOMBSTONE;
8950
9094
  });
8951
9095
  }
@@ -8961,7 +9105,7 @@ class TaskReader {
8961
9105
  }
8962
9106
  adoptStoreFrom(local) {
8963
9107
  const dirs = this.paths();
8964
- const marker = path14.join(local, "store.json");
9108
+ const marker = path15.join(local, "store.json");
8965
9109
  if (!fs11.existsSync(marker))
8966
9110
  return success(null, null, null);
8967
9111
  return this.withLock(dirs.checkoutLock, () => {
@@ -8971,7 +9115,7 @@ class TaskReader {
8971
9115
  try {
8972
9116
  const merge = (from, to) => {
8973
9117
  if (!fs11.existsSync(to)) {
8974
- fs11.mkdirSync(path14.dirname(to), { recursive: true });
9118
+ fs11.mkdirSync(path15.dirname(to), { recursive: true });
8975
9119
  try {
8976
9120
  fs11.renameSync(from, to);
8977
9121
  } catch {
@@ -8982,24 +9126,24 @@ class TaskReader {
8982
9126
  }
8983
9127
  if (fs11.lstatSync(from).isDirectory() && fs11.lstatSync(to).isDirectory())
8984
9128
  for (const name of fs11.readdirSync(from))
8985
- merge(path14.join(from, name), path14.join(to, name));
9129
+ merge(path15.join(from, name), path15.join(to, name));
8986
9130
  };
8987
9131
  for (const sub of ["tasks", "checkouts", "blobs", "legacy"]) {
8988
- const from = path14.join(local, sub);
9132
+ const from = path15.join(local, sub);
8989
9133
  if (!fs11.existsSync(from))
8990
9134
  continue;
8991
9135
  if (sub === "tasks") {
8992
9136
  for (const name of fs11.readdirSync(from))
8993
- if (validId(name) && !fs11.existsSync(path14.join(dirs.dir, sub, name)))
9137
+ if (validId(name) && !fs11.existsSync(path15.join(dirs.dir, sub, name)))
8994
9138
  tasks += 1;
8995
9139
  }
8996
- merge(from, path14.join(dirs.dir, sub));
9140
+ merge(from, path15.join(dirs.dir, sub));
8997
9141
  }
8998
- const ledger = path14.join(local, "ledger");
8999
- if (fs11.existsSync(ledger) && !fs11.existsSync(path14.join(dirs.dir, "ledger")))
9000
- merge(ledger, path14.join(dirs.dir, "ledger"));
9001
- fs11.rmSync(path14.join(local, "task-index.json"), { force: true });
9002
- fs11.renameSync(marker, path14.join(local, "store.moved.json"));
9142
+ const ledger = path15.join(local, "ledger");
9143
+ if (fs11.existsSync(ledger) && !fs11.existsSync(path15.join(dirs.dir, "ledger")))
9144
+ merge(ledger, path15.join(dirs.dir, "ledger"));
9145
+ fs11.rmSync(path15.join(local, "task-index.json"), { force: true });
9146
+ fs11.renameSync(marker, path15.join(local, "store.moved.json"));
9003
9147
  } catch (error) {
9004
9148
  return failure2("storage_error", `cannot move ${local} into ${dirs.dir}: ${String(error)}`, {
9005
9149
  path: local
@@ -9037,7 +9181,7 @@ class TaskReader {
9037
9181
  schemaVersion: SCHEMA_VERSION,
9038
9182
  id: workspaceId ?? newId(),
9039
9183
  revision: newRevision(),
9040
- root: path14.dirname(v2),
9184
+ root: path15.dirname(v2),
9041
9185
  runtime: { createdWith: version, updatedWith: version },
9042
9186
  writer: null,
9043
9187
  store: {
@@ -9049,11 +9193,11 @@ class TaskReader {
9049
9193
  critical: ["store"]
9050
9194
  };
9051
9195
  fs11.mkdirSync(v2, { recursive: true });
9052
- const ignore = path14.join(v2, ".gitignore");
9196
+ const ignore = path15.join(v2, ".gitignore");
9053
9197
  if (!fs11.existsSync(ignore))
9054
9198
  fs11.writeFileSync(ignore, `*
9055
9199
  `);
9056
- replaceFile(path14.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
9200
+ replaceFile(path15.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
9057
9201
  `, true);
9058
9202
  }
9059
9203
  initializeStorage() {
@@ -9112,7 +9256,7 @@ class TaskReader {
9112
9256
  withLock(lockPath, operation) {
9113
9257
  try {
9114
9258
  this.initializeStorage();
9115
- fs11.mkdirSync(path14.dirname(lockPath), { recursive: true });
9259
+ fs11.mkdirSync(path15.dirname(lockPath), { recursive: true });
9116
9260
  } catch (error) {
9117
9261
  return failure2("storage_error", `unable to initialize store: ${String(error)}`, {
9118
9262
  path: this.paths().dir
@@ -9175,7 +9319,7 @@ class TaskReader {
9175
9319
  if (isTransientWindowsError(error) && !this.lockHolderPresent(lockPath) && !this.lockDirWritable(lockPath))
9176
9320
  return failure2("storage_error", `cannot create the workit lock (${code}); no other Workit call holds it`, {
9177
9321
  path: lockPath,
9178
- guidance: `Check permissions and the read-only attribute on ${path14.dirname(lockPath)}.`
9322
+ guidance: `Check permissions and the read-only attribute on ${path15.dirname(lockPath)}.`
9179
9323
  });
9180
9324
  if (code === "EEXIST" || code === "file_lock_timeout" || code === "file_lock_stale" || isTransientWindowsError(error)) {
9181
9325
  let lock = null;
@@ -9195,13 +9339,13 @@ class TaskReader {
9195
9339
 
9196
9340
  // packages/workit-core/src/core/policy/derive.ts
9197
9341
  import { existsSync as existsSync7 } from "node:fs";
9198
- import path18 from "node:path";
9342
+ import path19 from "node:path";
9199
9343
 
9200
9344
  // packages/workit-core/src/ledger.ts
9201
9345
  import { spawnSync as spawnSync11 } from "node:child_process";
9202
- import { createHash as createHash9, randomBytes as randomBytes3 } from "node:crypto";
9346
+ import { createHash as createHash10, randomBytes as randomBytes3 } from "node:crypto";
9203
9347
  import fs13 from "node:fs";
9204
- import path17 from "node:path";
9348
+ import path18 from "node:path";
9205
9349
 
9206
9350
  // packages/workit-core/src/core/policy/bookkeeping.ts
9207
9351
  import { spawnSync as spawnSync9 } from "node:child_process";
@@ -9281,8 +9425,8 @@ function bookkeepingPaths(cwd, input) {
9281
9425
  }
9282
9426
 
9283
9427
  // packages/workit-core/src/core/policy/lane.ts
9284
- import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
9285
- import path15 from "node:path";
9428
+ import { existsSync as existsSync6, readFileSync as readFileSync8 } from "node:fs";
9429
+ import path16 from "node:path";
9286
9430
 
9287
9431
  // packages/workit-core/src/git/default-base.ts
9288
9432
  import { spawnSync as spawnSync10 } from "node:child_process";
@@ -10673,7 +10817,7 @@ function computeLane(input) {
10673
10817
  }
10674
10818
  function untrackedStat(cwd, file) {
10675
10819
  try {
10676
- const bytes = readFileSync7(path15.join(cwd, file));
10820
+ const bytes = readFileSync8(path16.join(cwd, file));
10677
10821
  if (bytes.includes(0))
10678
10822
  return { path: file, added: 0, deleted: 0, binary: true };
10679
10823
  const text = bytes.toString("utf8");
@@ -10705,7 +10849,7 @@ function cosmeticFiles(cwd, fork, head) {
10705
10849
  let after = blobs.get(entry.newBlob);
10706
10850
  if (!after && head === null && ABSENT.test(entry.newBlob))
10707
10851
  try {
10708
- after = readFileSync7(path15.join(cwd, entry.path));
10852
+ after = readFileSync8(path16.join(cwd, entry.path));
10709
10853
  } catch {
10710
10854
  after = undefined;
10711
10855
  }
@@ -10860,9 +11004,9 @@ function verdictDrift(cwd, input) {
10860
11004
  }
10861
11005
 
10862
11006
  // packages/workit-core/src/host-session.ts
10863
- import { createHash as createHash8, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
11007
+ import { createHash as createHash9, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
10864
11008
  import fs12 from "node:fs";
10865
- import path16 from "node:path";
11009
+ import path17 from "node:path";
10866
11010
  var STAMPING_HOSTS = new Set([
10867
11011
  "claude_code",
10868
11012
  "codex_cli",
@@ -10870,13 +11014,13 @@ var STAMPING_HOSTS = new Set([
10870
11014
  ]);
10871
11015
  var ISSUED_PER_LEAD = 64;
10872
11016
  var ISSUED_SESSIONS_MARKER = "workit-issued-sessions/3";
10873
- var hash = (value) => createHash8("sha256").update(value).digest("hex").slice(0, 32);
11017
+ var hash = (value) => createHash9("sha256").update(value).digest("hex").slice(0, 32);
10874
11018
  var PIN_FILE = "issued-registry";
10875
11019
  var pinFiles = new Map;
10876
11020
  var pinFile = (cwd) => {
10877
11021
  if (cwd === undefined)
10878
11022
  return null;
10879
- const key = path16.resolve(cwd);
11023
+ const key = path17.resolve(cwd);
10880
11024
  const known = pinFiles.get(key);
10881
11025
  if (known !== undefined)
10882
11026
  return known;
@@ -10884,7 +11028,7 @@ var pinFile = (cwd) => {
10884
11028
  const location = resolveStore(key);
10885
11029
  if (location instanceof Error)
10886
11030
  return null;
10887
- const file = location.shared ? path16.join(location.dir, "ledger", PIN_FILE) : null;
11031
+ const file = location.shared ? path17.join(location.dir, "ledger", PIN_FILE) : null;
10888
11032
  pinFiles.set(key, file);
10889
11033
  return file;
10890
11034
  } catch {
@@ -10897,32 +11041,32 @@ var pinnedStateDir = (cwd) => {
10897
11041
  return null;
10898
11042
  try {
10899
11043
  const pinned = fs12.readFileSync(file, "utf8").trim();
10900
- return path16.isAbsolute(pinned) ? pinned : null;
11044
+ return path17.isAbsolute(pinned) ? pinned : null;
10901
11045
  } catch {
10902
11046
  return null;
10903
11047
  }
10904
11048
  };
10905
11049
  var registryDir = (cwd) => pinnedStateDir(cwd) ?? resolveStateDir();
10906
- var testRunSkipsPin = (file) => process.env.WORKIT_TEST_RUN !== undefined && !insideTempDir(path16.dirname(path16.dirname(path16.dirname(file))));
11050
+ var testRunSkipsPin = (file) => process.env.WORKIT_TEST_RUN !== undefined && !insideTempDir(path17.dirname(path17.dirname(path17.dirname(file))));
10907
11051
  function pinIssuedRegistry(cwd) {
10908
11052
  const file = pinFile(cwd);
10909
11053
  if (file === null)
10910
11054
  return;
10911
- const state = path16.resolve(resolveStateDir());
11055
+ const state = path17.resolve(resolveStateDir());
10912
11056
  if (pinnedStateDir(cwd) === state)
10913
11057
  return;
10914
11058
  if (testRunSkipsPin(file))
10915
11059
  return;
10916
11060
  try {
10917
- fs12.mkdirSync(path16.dirname(file), { recursive: true });
11061
+ fs12.mkdirSync(path17.dirname(file), { recursive: true });
10918
11062
  const temp = `${file}.${process.pid}.tmp`;
10919
11063
  fs12.writeFileSync(temp, `${state}
10920
11064
  `, { mode: 420 });
10921
11065
  fs12.renameSync(temp, file);
10922
11066
  } catch {}
10923
11067
  }
10924
- var userIssuedRoot = (cwd) => path16.join(registryDir(cwd), "issued");
10925
- var userTokenRoot = (cwd) => path16.join(registryDir(cwd), "issued-tokens");
11068
+ var userIssuedRoot = (cwd) => path17.join(registryDir(cwd), "issued");
11069
+ var userTokenRoot = (cwd) => path17.join(registryDir(cwd), "issued-tokens");
10926
11070
  function migrateRepoIssued(cwd) {
10927
11071
  if (cwd === undefined)
10928
11072
  return;
@@ -10931,7 +11075,7 @@ function migrateRepoIssued(cwd) {
10931
11075
  const location = resolveStore(cwd);
10932
11076
  if (location instanceof Error)
10933
11077
  return;
10934
- old = path16.join(location.dir, "hooks", "issued");
11078
+ old = path17.join(location.dir, "hooks", "issued");
10935
11079
  if (!fs12.existsSync(old))
10936
11080
  return;
10937
11081
  } catch {
@@ -10939,19 +11083,19 @@ function migrateRepoIssued(cwd) {
10939
11083
  }
10940
11084
  for (const lead of safeList(old)) {
10941
11085
  try {
10942
- const from = path16.join(old, lead);
11086
+ const from = path17.join(old, lead);
10943
11087
  if (!fs12.statSync(from).isDirectory())
10944
11088
  continue;
10945
- const to = path16.join(userIssuedRoot(cwd), lead);
11089
+ const to = path17.join(userIssuedRoot(cwd), lead);
10946
11090
  fs12.mkdirSync(to, { recursive: true, mode: 448 });
10947
11091
  for (const id of fs12.readdirSync(from)) {
10948
11092
  try {
10949
- fs12.copyFileSync(path16.join(from, id), path16.join(to, id), fs12.constants.COPYFILE_EXCL);
11093
+ fs12.copyFileSync(path17.join(from, id), path17.join(to, id), fs12.constants.COPYFILE_EXCL);
10950
11094
  } catch (error) {
10951
11095
  if (error.code !== "EEXIST")
10952
11096
  throw error;
10953
11097
  }
10954
- fs12.rmSync(path16.join(from, id), { force: true });
11098
+ fs12.rmSync(path17.join(from, id), { force: true });
10955
11099
  }
10956
11100
  removeIfEmpty(from);
10957
11101
  } catch {}
@@ -10970,7 +11114,7 @@ var removeIfEmpty = (dir) => {
10970
11114
  fs12.rmdirSync(dir);
10971
11115
  } catch {}
10972
11116
  };
10973
- var tokenHash = (token) => createHash8("sha256").update(token).digest("hex");
11117
+ var tokenHash = (token) => createHash9("sha256").update(token).digest("hex");
10974
11118
  function recordIssuedSession(cwd, lead, issued) {
10975
11119
  const token = randomBytes2(18).toString("hex");
10976
11120
  try {
@@ -10978,13 +11122,13 @@ function recordIssuedSession(cwd, lead, issued) {
10978
11122
  migrateRepoIssued(cwd);
10979
11123
  const own = hash(issued);
10980
11124
  const state = resolveStateDir();
10981
- const tokens = path16.join(state, "issued-tokens", hash(lead));
11125
+ const tokens = path17.join(state, "issued-tokens", hash(lead));
10982
11126
  fs12.mkdirSync(tokens, { recursive: true, mode: 448 });
10983
- fs12.writeFileSync(path16.join(tokens, own), `${tokenHash(token)}
11127
+ fs12.writeFileSync(path17.join(tokens, own), `${tokenHash(token)}
10984
11128
  `, { mode: 384, flag: "wx" });
10985
- const dir = path16.join(state, "issued", hash(lead));
11129
+ const dir = path17.join(state, "issued", hash(lead));
10986
11130
  fs12.mkdirSync(dir, { recursive: true, mode: 448 });
10987
- fs12.writeFileSync(path16.join(dir, own), `${ISSUED_SESSIONS_MARKER}
11131
+ fs12.writeFileSync(path17.join(dir, own), `${ISSUED_SESSIONS_MARKER}
10988
11132
  `, { mode: 384 });
10989
11133
  pruneIssued(dir, own, tokens);
10990
11134
  return token;
@@ -11014,10 +11158,10 @@ function pruneIssued(dir, own, tokens) {
11014
11158
  const entries = fs12.readdirSync(dir);
11015
11159
  if (entries.length <= ISSUED_PER_LEAD)
11016
11160
  return;
11017
- const byAge = entries.filter((name) => name !== own).map((name) => ({ name, at: fs12.statSync(path16.join(dir, name)).mtimeMs })).toSorted((a, b) => a.at - b.at);
11161
+ const byAge = entries.filter((name) => name !== own).map((name) => ({ name, at: fs12.statSync(path17.join(dir, name)).mtimeMs })).toSorted((a, b) => a.at - b.at);
11018
11162
  for (const { name } of byAge.slice(0, entries.length - ISSUED_PER_LEAD)) {
11019
- fs12.rmSync(path16.join(dir, name), { force: true });
11020
- fs12.rmSync(path16.join(tokens, name), { force: true });
11163
+ fs12.rmSync(path17.join(dir, name), { force: true });
11164
+ fs12.rmSync(path17.join(tokens, name), { force: true });
11021
11165
  }
11022
11166
  } catch {}
11023
11167
  }
@@ -11027,7 +11171,7 @@ var issuedRecord = (cwd, claimed) => {
11027
11171
  return null;
11028
11172
  migrateRepoIssued(cwd);
11029
11173
  try {
11030
- return fs12.readFileSync(path16.join(userIssuedRoot(cwd), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
11174
+ return fs12.readFileSync(path17.join(userIssuedRoot(cwd), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
11031
11175
  } catch {
11032
11176
  return null;
11033
11177
  }
@@ -11037,9 +11181,9 @@ var issuedToken = (cwd, claimed) => {
11037
11181
  const cut = claimed.lastIndexOf(":");
11038
11182
  if (cut <= 0)
11039
11183
  return { stored: null, leadBound: false };
11040
- const dir = path16.join(userTokenRoot(cwd), hash(claimed.slice(0, cut)));
11184
+ const dir = path17.join(userTokenRoot(cwd), hash(claimed.slice(0, cut)));
11041
11185
  try {
11042
- const text = fs12.readFileSync(path16.join(dir, hash(claimed)), "utf8");
11186
+ const text = fs12.readFileSync(path17.join(dir, hash(claimed)), "utf8");
11043
11187
  return { stored: TOKEN_HASH.exec(text)?.[1] ?? null, leadBound: true };
11044
11188
  } catch {
11045
11189
  return { stored: null, leadBound: safeList(dir).length > 0 };
@@ -11133,7 +11277,7 @@ var binaryRangeDiff = (cwd, base, head) => {
11133
11277
  return diff.ok && diff.stdout ? diff.stdout : null;
11134
11278
  };
11135
11279
  var hashOfDiff = (diff) => {
11136
- const hash = createHash9("sha256");
11280
+ const hash = createHash10("sha256");
11137
11281
  for (const line of diff.split(`
11138
11282
  `)) {
11139
11283
  if (line.startsWith("index "))
@@ -11166,14 +11310,14 @@ function cleanRebase(cwd, range) {
11166
11310
  return Boolean(tree) && tree === git3(cwd, ["rev-parse", "--verify", "-q", `${range.to}^{tree}`]);
11167
11311
  }
11168
11312
  function storeRoot(cwd) {
11169
- const location = resolveStore(path17.resolve(cwd));
11313
+ const location = resolveStore(path18.resolve(cwd));
11170
11314
  if (location instanceof Error)
11171
11315
  return err("unavailable", location.message.replace(/; fix the repository.*$/u, ""), / does not exist /u.test(location.message) ? "run workit from a directory that exists" : "fix the repository (git status should work here) or run from a non-git directory");
11172
11316
  return { ok: true, value: { root: location.dir, shared: location.shared } };
11173
11317
  }
11174
11318
  function ledgerPath(cwd) {
11175
11319
  const root = storeRoot(cwd);
11176
- return root.ok ? { ok: true, value: path17.join(root.value.root, "ledger", "ledger.jsonl") } : root;
11320
+ return root.ok ? { ok: true, value: path18.join(root.value.root, "ledger", "ledger.jsonl") } : root;
11177
11321
  }
11178
11322
  var newId2 = () => `${Date.now().toString(36)}-${randomBytes3(6).toString("hex")}`;
11179
11323
  var NETWORK_FS_TYPES = new Set([
@@ -11203,13 +11347,13 @@ var LOCK_STALE_MS2 = 30000;
11203
11347
  var LOCK_OWNER = "owner";
11204
11348
  var lockToken = (lock) => {
11205
11349
  try {
11206
- return fs13.readFileSync(path17.join(lock, LOCK_OWNER), "utf8");
11350
+ return fs13.readFileSync(path18.join(lock, LOCK_OWNER), "utf8");
11207
11351
  } catch {
11208
11352
  return null;
11209
11353
  }
11210
11354
  };
11211
11355
  var lockAgeMs = (lock) => {
11212
- for (const target of [path17.join(lock, LOCK_OWNER), lock]) {
11356
+ for (const target of [path18.join(lock, LOCK_OWNER), lock]) {
11213
11357
  try {
11214
11358
  return Date.now() - fs13.statSync(target).mtimeMs;
11215
11359
  } catch {}
@@ -11226,7 +11370,7 @@ var ledgerLock = {
11226
11370
  throw error;
11227
11371
  }
11228
11372
  const token = `${process.pid}-${randomBytes3(8).toString("hex")}`;
11229
- fs13.writeFileSync(path17.join(lock, LOCK_OWNER), token);
11373
+ fs13.writeFileSync(path18.join(lock, LOCK_OWNER), token);
11230
11374
  return token;
11231
11375
  },
11232
11376
  release(lock, token) {
@@ -11289,7 +11433,7 @@ function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS2))
11289
11433
  ledgerLock.release(lock, token);
11290
11434
  }
11291
11435
  }
11292
- var sha2562 = (text) => createHash9("sha256").update(text).digest("hex");
11436
+ var sha2562 = (text) => createHash10("sha256").update(text).digest("hex");
11293
11437
  var chainHash = (prevHash, body) => sha2562(`${prevHash ?? ""}
11294
11438
  ${body}`);
11295
11439
  var TAIL_BYTES = 64 * 1024;
@@ -11351,8 +11495,8 @@ ${line.value}`);
11351
11495
  }
11352
11496
  };
11353
11497
  try {
11354
- fs13.mkdirSync(path17.dirname(file), { recursive: true });
11355
- if (options.heldLock || !options.forceLock && !onNetworkFs(path17.dirname(file)))
11498
+ fs13.mkdirSync(path18.dirname(file), { recursive: true });
11499
+ if (options.heldLock || !options.forceLock && !onNetworkFs(path18.dirname(file)))
11356
11500
  return write();
11357
11501
  const locked = withLedgerLock(file, write);
11358
11502
  return locked ?? err("busy", `ledger lock ${file}.lock is held`, "retry; remove the .lock directory if no workit process is running");
@@ -11369,7 +11513,7 @@ var sealed = (row, id, at, previous) => {
11369
11513
  ` };
11370
11514
  };
11371
11515
  function appendRaw(cwd, row, options) {
11372
- const file = options.store ? { ok: true, value: path17.join(options.store.root, "ledger", "ledger.jsonl") } : ledgerPath(cwd);
11516
+ const file = options.store ? { ok: true, value: path18.join(options.store.root, "ledger", "ledger.jsonl") } : ledgerPath(cwd);
11373
11517
  if (!file.ok)
11374
11518
  return file;
11375
11519
  const id = newId2();
@@ -12025,7 +12169,7 @@ function remoteIdentity(cwd, hop = 0) {
12025
12169
  return null;
12026
12170
  if (hop === 0 && !/^[\w+.-]+:\/\/|^[^/\\]+@[^/\\]+:/u.test(raw)) {
12027
12171
  const local = raw.replace(/^file:\/\//u, "");
12028
- const resolved = path17.isAbsolute(local) ? local : path17.resolve(cwd, local);
12172
+ const resolved = path18.isAbsolute(local) ? local : path18.resolve(cwd, local);
12029
12173
  if (fs13.existsSync(resolved))
12030
12174
  return remoteIdentity(resolved, 1);
12031
12175
  }
@@ -12046,8 +12190,8 @@ function verdictMirrorPath(cwd) {
12046
12190
  }
12047
12191
  if (!identity)
12048
12192
  return null;
12049
- const key = createHash9("sha256").update(identity).digest("hex").slice(0, 32);
12050
- return path17.join(resolveStateDir(), "verdicts", key, "ledger.jsonl");
12193
+ const key = createHash10("sha256").update(identity).digest("hex").slice(0, 32);
12194
+ return path18.join(resolveStateDir(), "verdicts", key, "ledger.jsonl");
12051
12195
  }
12052
12196
  var importedStamp = new Map;
12053
12197
  function importMirroredVerdicts(cwd, branch) {
@@ -12070,7 +12214,7 @@ function importMirroredVerdicts(cwd, branch) {
12070
12214
  const candidates = mirror.value.rows.filter((row) => (row.type === "verdict" || row.type === VOID_TYPE) && row.branch === branch && row.integrity === "verified");
12071
12215
  const added = new Set;
12072
12216
  try {
12073
- fs13.mkdirSync(path17.dirname(local.value), { recursive: true });
12217
+ fs13.mkdirSync(path18.dirname(local.value), { recursive: true });
12074
12218
  } catch {
12075
12219
  return [];
12076
12220
  }
@@ -12186,7 +12330,7 @@ var productDecision = (task, ledger) => {
12186
12330
  };
12187
12331
  };
12188
12332
  var planRecorded = (task, root) => {
12189
- const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync7(path18.resolve(root, ref.path)));
12333
+ const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync7(path19.resolve(root, ref.path)));
12190
12334
  if (cited)
12191
12335
  return {
12192
12336
  met: true,
@@ -12263,15 +12407,15 @@ function writeBlockers(task, root) {
12263
12407
  }
12264
12408
 
12265
12409
  // packages/workit-core/src/core/task-evaluation.ts
12266
- var digestBytes = (value) => createHash10("sha256").update(value).digest("hex");
12267
- var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path19.sep}`);
12268
- var relative = (root, candidate) => path19.relative(root, candidate).split(path19.sep).join("/") || ".";
12410
+ var digestBytes = (value) => createHash11("sha256").update(value).digest("hex");
12411
+ var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path20.sep}`);
12412
+ var relative = (root, candidate) => path20.relative(root, candidate).split(path20.sep).join("/") || ".";
12269
12413
  var canonicalPath = (value) => {
12270
12414
  if (typeof value !== "string" || !value)
12271
12415
  return null;
12272
12416
  if (value.includes("\\") || value.split("/").includes(".."))
12273
12417
  return null;
12274
- const normalized = path19.posix.normalize(value);
12418
+ const normalized = path20.posix.normalize(value);
12275
12419
  if (normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/"))
12276
12420
  return null;
12277
12421
  return normalized === "." ? "." : normalized.replace(/\/$/, "");
@@ -12319,14 +12463,14 @@ var gitPaths = (root) => {
12319
12463
  git: !/not a git repository/i.test(stderr)
12320
12464
  };
12321
12465
  }
12322
- const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path19.sep).join("/")) : [];
12466
+ const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path20.sep).join("/")) : [];
12323
12467
  const stagedDeleted = spawnSync12("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
12324
12468
  if (stagedDeleted.status !== 0) {
12325
12469
  const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
12326
12470
  if (!/not a git repository/i.test(stderr))
12327
12471
  return { paths, uncertain: true, git: true };
12328
12472
  } else if (stagedDeleted.stdout) {
12329
- paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path19.sep).join("/")));
12473
+ paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path20.sep).join("/")));
12330
12474
  }
12331
12475
  return { paths: [...new Set(paths)], uncertain: false, git: true };
12332
12476
  };
@@ -12341,7 +12485,7 @@ var walk = (root, directory, output) => {
12341
12485
  for (const name of names) {
12342
12486
  if (name === ".git" || name === ".workit")
12343
12487
  continue;
12344
- const target = path19.join(directory, name);
12488
+ const target = path20.join(directory, name);
12345
12489
  let stat;
12346
12490
  try {
12347
12491
  stat = fs14.lstatSync(target);
@@ -12359,12 +12503,12 @@ var walk = (root, directory, output) => {
12359
12503
  var scopeRoots = (root, scope) => {
12360
12504
  const roots = [];
12361
12505
  for (const item of scope.paths.length ? scope.paths : ["."]) {
12362
- const target = path19.resolve(root, item);
12506
+ const target = path20.resolve(root, item);
12363
12507
  if (!inside(root, target))
12364
12508
  return failure2("invalid_input", `candidate scope escapes checkout: ${item} — keep one task per repository and coordinate a separate linked task in the other checkout`, { fields: [{ path: "scope.paths", reason: `${item} is outside the checkout` }] });
12365
12509
  let ancestor = target;
12366
12510
  while (!fs14.existsSync(ancestor) && ancestor !== root)
12367
- ancestor = path19.dirname(ancestor);
12511
+ ancestor = path20.dirname(ancestor);
12368
12512
  try {
12369
12513
  if (!inside(root, fs14.realpathSync(ancestor)))
12370
12514
  return failure2("invalid_input", `candidate scope escapes checkout through a symlink: ${item} — keep one task per repository and coordinate a separate linked task in the other checkout`, { fields: [{ path: "scope.paths", reason: `${item} resolves outside the checkout` }] });
@@ -12416,7 +12560,7 @@ function captureCandidate(root, scope, environment = []) {
12416
12560
  for (const item of [...names].toSorted()) {
12417
12561
  if (!scopeMatches(item, normalizedScope))
12418
12562
  continue;
12419
- const target = path19.join(checkout, item);
12563
+ const target = path20.join(checkout, item);
12420
12564
  try {
12421
12565
  const stat = fs14.lstatSync(target);
12422
12566
  if (stat.isSymbolicLink()) {
@@ -12585,23 +12729,23 @@ var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
12585
12729
  continue;
12586
12730
  if (!reference.digest)
12587
12731
  return failure2("invalid_input", "document references require a byte digest");
12588
- const target = path19.resolve(root, reference.path);
12589
- if (target !== root && !target.startsWith(`${root}${path19.sep}`))
12732
+ const target = path20.resolve(root, reference.path);
12733
+ if (target !== root && !target.startsWith(`${root}${path20.sep}`))
12590
12734
  return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
12591
12735
  fields: [
12592
12736
  { path: "contentRefs.path", reason: `${reference.path} is outside the checkout` }
12593
12737
  ]
12594
12738
  });
12595
12739
  try {
12596
- const below = path19.relative(root, target);
12740
+ const below = path20.relative(root, target);
12597
12741
  let current = root;
12598
- for (const segment of below.split(path19.sep)) {
12742
+ for (const segment of below.split(path20.sep)) {
12599
12743
  if (!segment)
12600
12744
  continue;
12601
- current = path19.join(current, segment);
12745
+ current = path20.join(current, segment);
12602
12746
  const stat = fs14.lstatSync(current);
12603
12747
  const real = fs14.realpathSync(current);
12604
- if (real !== root && !real.startsWith(`${root}${path19.sep}`))
12748
+ if (real !== root && !real.startsWith(`${root}${path20.sep}`))
12605
12749
  return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
12606
12750
  fields: [
12607
12751
  {
@@ -13099,7 +13243,7 @@ function entryCompactContext(store, entry, session, context) {
13099
13243
  current: () => recentSignal(store.root)
13100
13244
  };
13101
13245
  const observed = task?.data.evidence.some(isObservedCheck) ?? false;
13102
- const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path20.resolve(store.root, ref.path)] : []));
13246
+ const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path21.resolve(store.root, ref.path)] : []));
13103
13247
  const observedFiles = filesKey(files);
13104
13248
  const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
13105
13249
  if (!compact.ok || !compact.data)
@@ -13158,17 +13302,17 @@ ${options.addendum}` : ""}
13158
13302
  </workit-contract>`;
13159
13303
  };
13160
13304
  var checkoutAt = (cwd) => {
13161
- for (let dir = path20.resolve(cwd);; dir = path20.dirname(dir)) {
13162
- const dotGit = path20.join(dir, ".git");
13305
+ for (let dir = path21.resolve(cwd);; dir = path21.dirname(dir)) {
13306
+ const dotGit = path21.join(dir, ".git");
13163
13307
  if (fs15.existsSync(dotGit)) {
13164
- const admin = fs15.statSync(dotGit).isFile() ? path20.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs15.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
13165
- const head = fs15.readFileSync(path20.join(admin, "HEAD"), "utf8").trim();
13308
+ const admin = fs15.statSync(dotGit).isFile() ? path21.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs15.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
13309
+ const head = fs15.readFileSync(path21.join(admin, "HEAD"), "utf8").trim();
13166
13310
  return {
13167
13311
  root: dir,
13168
13312
  branch: /^ref: refs\/heads\/(.+)$/u.exec(head)?.[1] ?? null
13169
13313
  };
13170
13314
  }
13171
- if (path20.dirname(dir) === dir)
13315
+ if (path21.dirname(dir) === dir)
13172
13316
  return null;
13173
13317
  }
13174
13318
  };
@@ -13179,7 +13323,7 @@ var whereLine = (cwd) => {
13179
13323
  return null;
13180
13324
  const allowed = branchPolicySnapshotFor(cwd).namePolicy.allowed;
13181
13325
  const kinds = allowed.some((pattern) => pattern.source === "^.*$") ? "any" : allowedKinds(allowed).join(", ") || "see `workit help git`";
13182
- const place = checkout.root === path20.resolve(cwd) ? "" : ` in ${checkout.root}`;
13326
+ const place = checkout.root === path21.resolve(cwd) ? "" : ` in ${checkout.root}`;
13183
13327
  return `cwd ${cwd}${place} on ${checkout.branch ?? "detached HEAD"}; branch kinds: ${kinds}`;
13184
13328
  } catch {
13185
13329
  return null;
@@ -13197,7 +13341,7 @@ var turnContextText = (input, descriptor) => {
13197
13341
  }
13198
13342
  };
13199
13343
  var TURN_TTL_MS = 7 * 24 * 60 * 60 * 1000;
13200
- var digestOf = (text) => createHash11("sha256").update(text).digest("hex");
13344
+ var digestOf = (text) => createHash12("sha256").update(text).digest("hex");
13201
13345
  var turnMarker = (input) => {
13202
13346
  if (!input.session.id)
13203
13347
  return null;
@@ -13206,14 +13350,14 @@ var turnMarker = (input) => {
13206
13350
  if (location instanceof Error)
13207
13351
  return null;
13208
13352
  const session = [input.host, input.session.id, input.session.agentId ?? ""].join("\x00");
13209
- return path20.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
13353
+ return path21.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
13210
13354
  } catch {
13211
13355
  return null;
13212
13356
  }
13213
13357
  };
13214
13358
  var writeTurnDigest = (file, digest) => {
13215
13359
  try {
13216
- fs15.mkdirSync(path20.dirname(file), { recursive: true });
13360
+ fs15.mkdirSync(path21.dirname(file), { recursive: true });
13217
13361
  fs15.writeFileSync(file, `${JSON.stringify({ digest })}
13218
13362
  `);
13219
13363
  } catch {}
@@ -13228,7 +13372,7 @@ var pruneTurnDigests = (dir, now) => {
13228
13372
  for (const name of fs15.readdirSync(dir)) {
13229
13373
  if (!name.startsWith("turn-"))
13230
13374
  continue;
13231
- const file = path20.join(dir, name);
13375
+ const file = path21.join(dir, name);
13232
13376
  try {
13233
13377
  if (now - fs15.statSync(file).mtimeMs > TURN_TTL_MS)
13234
13378
  fs15.rmSync(file, { force: true });
@@ -13258,7 +13402,7 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
13258
13402
  const file = turnMarker(input);
13259
13403
  if (!file)
13260
13404
  return;
13261
- pruneTurnDigests(path20.dirname(file), Date.now());
13405
+ pruneTurnDigests(path21.dirname(file), Date.now());
13262
13406
  if (text)
13263
13407
  writeTurnDigest(file, digestOf(text));
13264
13408
  else
@@ -13283,20 +13427,20 @@ import path23 from "node:path";
13283
13427
  // packages/workit-core/src/core/eval-world.ts
13284
13428
  import { existsSync as existsSync9, realpathSync as realpathSync7 } from "node:fs";
13285
13429
  import os5 from "node:os";
13286
- import path21 from "node:path";
13430
+ import path22 from "node:path";
13287
13431
  var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
13288
13432
  var EVAL_WORLD_MARKER = ".workit-eval-world";
13289
13433
  var inside2 = (dir, file) => {
13290
- const rel = path21.relative(dir, file);
13291
- return !rel.startsWith("..") && !path21.isAbsolute(rel);
13434
+ const rel = path22.relative(dir, file);
13435
+ return !rel.startsWith("..") && !path22.isAbsolute(rel);
13292
13436
  };
13293
13437
  var evalWorld = (cwd) => {
13294
13438
  const raw = process.env[EVAL_WORLD_ENV];
13295
- if (!raw || !path21.isAbsolute(raw))
13439
+ if (!raw || !path22.isAbsolute(raw))
13296
13440
  return null;
13297
13441
  try {
13298
13442
  const world = realpathSync7(raw);
13299
- return inside2(realpathSync7(os5.tmpdir()), world) && inside2(world, realpathSync7(cwd)) && existsSync9(path21.join(world, EVAL_WORLD_MARKER)) ? world : null;
13443
+ return inside2(realpathSync7(os5.tmpdir()), world) && inside2(world, realpathSync7(cwd)) && existsSync9(path22.join(world, EVAL_WORLD_MARKER)) ? world : null;
13300
13444
  } catch {
13301
13445
  return null;
13302
13446
  }
@@ -13304,77 +13448,12 @@ var evalWorld = (cwd) => {
13304
13448
  var evalWorldEntry = (cwd) => {
13305
13449
  const world = evalWorld(cwd);
13306
13450
  try {
13307
- return world ? loadWorkspacesFrom(path21.join(world, "config"))[0] ?? null : null;
13451
+ return world ? loadWorkspacesFrom(path22.join(world, "config"))[0] ?? null : null;
13308
13452
  } catch {
13309
13453
  return null;
13310
13454
  }
13311
13455
  };
13312
13456
 
13313
- // packages/workit-core/src/core/grant-seal.ts
13314
- import { createHash as createHash12 } from "node:crypto";
13315
- import { readFileSync as readFileSync9 } from "node:fs";
13316
- import path22 from "node:path";
13317
- var SEAL_FILE = "workspaces.json.seal";
13318
- var SEAL_VERSION = 1;
13319
- var SEAL_COMMAND = "workit workspace seal";
13320
- var pick3 = (value, keys) => {
13321
- if (!value || typeof value !== "object" || Array.isArray(value))
13322
- return;
13323
- const out = Object.fromEntries(keys.flatMap((key) => {
13324
- const item = value[key];
13325
- return item === undefined ? [] : [[key, item]];
13326
- }));
13327
- return Object.keys(out).length > 0 ? out : undefined;
13328
- };
13329
- var ENTRY_KEYS = [
13330
- "name",
13331
- "glob",
13332
- "remotes",
13333
- "externalRepos",
13334
- "additiveRiskPaths",
13335
- "vcs",
13336
- "autonomy",
13337
- "autoApprove",
13338
- "defaultEndpoint",
13339
- "verification",
13340
- "youtrack"
13341
- ];
13342
- var IDENTITY_KEYS = ["provider", "account", "tokenFile", "host"];
13343
- var sealProjection = (entries) => entries.map((entry) => {
13344
- const all = pick3(entry, ENTRY_KEYS) ?? {};
13345
- return pick3({
13346
- ...all,
13347
- vcs: pick3(all.vcs, IDENTITY_KEYS),
13348
- youtrack: pick3(all.youtrack, ["writes", "autoHosts"])
13349
- }, ENTRY_KEYS);
13350
- });
13351
- var canonical4 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
13352
- var sealDigest = (projection) => createHash12("sha256").update(canonical4(projection)).digest("hex");
13353
- var broken = (reason, sealed = null) => ({
13354
- state: "broken",
13355
- reason,
13356
- sealed
13357
- });
13358
- function checkSeal(dir) {
13359
- const file = path22.join(dir, SEAL_FILE);
13360
- let seal;
13361
- try {
13362
- seal = JSON.parse(readFileSync9(file, "utf8"));
13363
- } catch (error) {
13364
- if (error.code === "ENOENT")
13365
- return { state: "none" };
13366
- return broken(`${SEAL_FILE} cannot be read`);
13367
- }
13368
- if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
13369
- return broken(`${SEAL_FILE} is malformed`);
13370
- const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
13371
- if (sealed.status !== "valid")
13372
- return broken(`${SEAL_FILE} is malformed`);
13373
- const current = readWorkspacesResult(dir);
13374
- const ok = current.status === "valid" || current.status === "missing";
13375
- return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
13376
- }
13377
-
13378
13457
  // packages/workit-core/src/forge/redact.ts
13379
13458
  var NAME = "[A-Za-z0-9_.-]";
13380
13459
  var KEY = String.raw`(?<!${NAME})(?=${NAME}*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature))${NAME}+`;
@@ -13455,7 +13534,7 @@ var sealOf = () => {
13455
13534
  var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
13456
13535
  var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
13457
13536
  var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never run), so grants, endpoint, verification and youtrack.writes stay at or below the D4 defaults; ${NO_SEAL_UNBLOCK}`;
13458
- var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
13537
+ var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values, and a sealed releaseNotes review stays; ${SEAL_UNBLOCK}` : null;
13459
13538
  var ASK = { mode: "ask" };
13460
13539
  var youtrackOf = (entry) => entry?.youtrack;
13461
13540
  var autoHostsOf = (entry) => {
@@ -13871,7 +13950,14 @@ var SCOPE_FIELDS = new Set([
13871
13950
  "autoApprove",
13872
13951
  "defaultEndpoint",
13873
13952
  "verification",
13874
- "youtrack"
13953
+ "youtrack",
13954
+ "releaseNotes",
13955
+ "releaseTagPrefix",
13956
+ "branchPolicy",
13957
+ "profiles",
13958
+ "defaultProfile",
13959
+ "releaseTracks",
13960
+ "releasePackages"
13875
13961
  ]);
13876
13962
 
13877
13963
  // packages/workit-core/src/core/release-packages.ts