@pleri/olam-cli 0.1.199 → 0.1.201

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.
Files changed (59) hide show
  1. package/dist/ask/knowledge-pack.generated.d.ts.map +1 -1
  2. package/dist/ask/knowledge-pack.generated.js +3 -1
  3. package/dist/ask/knowledge-pack.generated.js.map +1 -1
  4. package/dist/commands/auth.d.ts.map +1 -1
  5. package/dist/commands/auth.js +23 -8
  6. package/dist/commands/auth.js.map +1 -1
  7. package/dist/commands/create.d.ts.map +1 -1
  8. package/dist/commands/create.js +3 -0
  9. package/dist/commands/create.js.map +1 -1
  10. package/dist/commands/flywheel/diversity-check.d.ts +1 -1
  11. package/dist/commands/flywheel/diversity-check.js +1 -1
  12. package/dist/commands/flywheel/k5-score.d.ts +1 -1
  13. package/dist/commands/flywheel/k5-score.js +1 -1
  14. package/dist/commands/flywheel/k5-validate.d.ts +1 -1
  15. package/dist/commands/init.js +1 -1
  16. package/dist/commands/init.js.map +1 -1
  17. package/dist/commands/kg-mirror.d.ts +16 -0
  18. package/dist/commands/kg-mirror.d.ts.map +1 -1
  19. package/dist/commands/kg-mirror.js +94 -0
  20. package/dist/commands/kg-mirror.js.map +1 -1
  21. package/dist/commands/ps.d.ts.map +1 -1
  22. package/dist/commands/ps.js +7 -3
  23. package/dist/commands/ps.js.map +1 -1
  24. package/dist/commands/refresh.js +1 -1
  25. package/dist/commands/refresh.js.map +1 -1
  26. package/dist/commands/skills-100x.d.ts +34 -0
  27. package/dist/commands/skills-100x.d.ts.map +1 -0
  28. package/dist/commands/{skills-10x.js → skills-100x.js} +138 -41
  29. package/dist/commands/skills-100x.js.map +1 -0
  30. package/dist/commands/skills-install-model-router.d.ts +20 -0
  31. package/dist/commands/skills-install-model-router.d.ts.map +1 -0
  32. package/dist/commands/skills-install-model-router.js +55 -0
  33. package/dist/commands/skills-install-model-router.js.map +1 -0
  34. package/dist/commands/skills.d.ts.map +1 -1
  35. package/dist/commands/skills.js +2 -0
  36. package/dist/commands/skills.js.map +1 -1
  37. package/dist/commands/status.d.ts.map +1 -1
  38. package/dist/commands/status.js +0 -1
  39. package/dist/commands/status.js.map +1 -1
  40. package/dist/commands/workspace.d.ts.map +1 -1
  41. package/dist/commands/workspace.js +1 -2
  42. package/dist/commands/workspace.js.map +1 -1
  43. package/dist/image-digests.json +8 -8
  44. package/dist/index.js +1127 -716
  45. package/dist/index.js.map +1 -1
  46. package/dist/lib/help-groups.js +1 -1
  47. package/dist/lib/help-groups.js.map +1 -1
  48. package/dist/mcp-server.js +547 -346
  49. package/hermes-bundle/version.json +1 -1
  50. package/hooks/model-router.py +445 -0
  51. package/host-cp/k8s/manifests/50-deployment.yaml +1 -1
  52. package/host-cp/k8s/manifests/auth-service/50-deployment.yaml +1 -1
  53. package/host-cp/k8s/manifests/kg-service/50-deployment.yaml +1 -1
  54. package/host-cp/k8s/manifests/mcp-auth-service/50-deployment.yaml +1 -1
  55. package/host-cp/k8s/manifests/memory-service/50-deployment.yaml +1 -1
  56. package/package.json +2 -1
  57. package/dist/commands/skills-10x.d.ts +0 -23
  58. package/dist/commands/skills-10x.d.ts.map +0 -1
  59. package/dist/commands/skills-10x.js.map +0 -1
@@ -7090,7 +7090,7 @@ var require_compile = __commonJS({
7090
7090
  const schOrFunc = root.refs[ref];
7091
7091
  if (schOrFunc)
7092
7092
  return schOrFunc;
7093
- let _sch = resolve15.call(this, root, ref);
7093
+ let _sch = resolve16.call(this, root, ref);
7094
7094
  if (_sch === void 0) {
7095
7095
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
7096
7096
  const { schemaId } = this.opts;
@@ -7117,7 +7117,7 @@ var require_compile = __commonJS({
7117
7117
  function sameSchemaEnv(s1, s2) {
7118
7118
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
7119
7119
  }
7120
- function resolve15(root, ref) {
7120
+ function resolve16(root, ref) {
7121
7121
  let sch;
7122
7122
  while (typeof (sch = this.refs[ref]) == "string")
7123
7123
  ref = sch;
@@ -7692,7 +7692,7 @@ var require_fast_uri = __commonJS({
7692
7692
  }
7693
7693
  return uri;
7694
7694
  }
7695
- function resolve15(baseURI, relativeURI, options) {
7695
+ function resolve16(baseURI, relativeURI, options) {
7696
7696
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
7697
7697
  const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
7698
7698
  schemelessOptions.skipEscape = true;
@@ -7919,7 +7919,7 @@ var require_fast_uri = __commonJS({
7919
7919
  var fastUri = {
7920
7920
  SCHEMES,
7921
7921
  normalize,
7922
- resolve: resolve15,
7922
+ resolve: resolve16,
7923
7923
  resolveComponent,
7924
7924
  equal,
7925
7925
  serialize,
@@ -10895,12 +10895,12 @@ var require_dist = __commonJS({
10895
10895
  throw new Error(`Unknown format "${name}"`);
10896
10896
  return f;
10897
10897
  };
10898
- function addFormats(ajv, list, fs55, exportName) {
10898
+ function addFormats(ajv, list, fs56, exportName) {
10899
10899
  var _a3;
10900
10900
  var _b;
10901
10901
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
10902
10902
  for (const f of list)
10903
- ajv.addFormat(f, fs55[f]);
10903
+ ajv.addFormat(f, fs56[f]);
10904
10904
  }
10905
10905
  module.exports = exports = formatsPlugin;
10906
10906
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -12143,7 +12143,7 @@ var init_schema4 = __esm({
12143
12143
  env: external_exports.record(external_exports.string().min(1), external_exports.record(external_exports.string().min(1), external_exports.string())).optional(),
12144
12144
  updatedAt: external_exports.number().int().nonnegative()
12145
12145
  });
12146
- MetaHookBlockKindSchema = external_exports.enum(["memory-recall", "memory-classify"]);
12146
+ MetaHookBlockKindSchema = external_exports.enum(["memory-recall", "memory-classify", "model-router"]);
12147
12147
  GlobalConfigSchema = external_exports.object({
12148
12148
  schemaVersion: external_exports.literal(1),
12149
12149
  repos: external_exports.array(RepoEntrySchema).optional().default([]),
@@ -13854,17 +13854,143 @@ var init_memory_classify = __esm({
13854
13854
  }
13855
13855
  });
13856
13856
 
13857
+ // ../core/dist/meta-hooks/model-router.js
13858
+ import * as fs26 from "node:fs";
13859
+ function buildModelRouterHookEntry() {
13860
+ return {
13861
+ hooks: [
13862
+ {
13863
+ type: "command",
13864
+ command: `OLAM_META_SENTINEL=${OLAM_META_MODEL_ROUTER_SENTINEL}; ${OLAM_META_NOOP_GUARD3} python3 "${OLAM_META_MODEL_ROUTER_SCRIPT_PATH}"`,
13865
+ timeout: OLAM_META_MODEL_ROUTER_TIMEOUT_MS
13866
+ }
13867
+ ]
13868
+ };
13869
+ }
13870
+ function computeModelRouterUninstall(settings) {
13871
+ const matchers = settings.hooks?.UserPromptSubmit;
13872
+ if (!Array.isArray(matchers) || matchers.length === 0) {
13873
+ return { status: "not-found" };
13874
+ }
13875
+ let changed = false;
13876
+ const filteredMatchers = [];
13877
+ for (const matcher of matchers) {
13878
+ const innerHooks = matcher.hooks ?? [];
13879
+ const keptInner = innerHooks.filter((h) => {
13880
+ if (typeof h.command === "string" && h.command.includes(OLAM_META_MODEL_ROUTER_SENTINEL)) {
13881
+ changed = true;
13882
+ return false;
13883
+ }
13884
+ return true;
13885
+ });
13886
+ if (keptInner.length === 0 && innerHooks.length > 0) {
13887
+ changed = true;
13888
+ continue;
13889
+ }
13890
+ if (keptInner.length === innerHooks.length) {
13891
+ filteredMatchers.push(matcher);
13892
+ } else {
13893
+ filteredMatchers.push({ ...matcher, hooks: keptInner });
13894
+ }
13895
+ }
13896
+ if (!changed)
13897
+ return { status: "not-found" };
13898
+ const next = {
13899
+ ...settings,
13900
+ hooks: {
13901
+ ...settings.hooks,
13902
+ UserPromptSubmit: filteredMatchers
13903
+ }
13904
+ };
13905
+ if (filteredMatchers.length === 0) {
13906
+ const otherStages = Object.keys(next.hooks ?? {}).filter((k) => k !== "UserPromptSubmit");
13907
+ if (otherStages.length === 0) {
13908
+ delete next.hooks;
13909
+ } else {
13910
+ delete next.hooks.UserPromptSubmit;
13911
+ }
13912
+ }
13913
+ return { status: "removed", settingsAfter: next };
13914
+ }
13915
+ function matchModelRouterSentinel(commandLine) {
13916
+ return commandLine.includes(OLAM_META_MODEL_ROUTER_SENTINEL);
13917
+ }
13918
+ var OLAM_META_MODEL_ROUTER_SENTINEL, OLAM_META_MODEL_ROUTER_STAGE, OLAM_META_MODEL_ROUTER_TIMEOUT_MS, OLAM_META_MODEL_ROUTER_SCRIPT_PATH, OLAM_META_MODEL_ROUTER_SCRIPT_BASENAME, OLAM_META_NOOP_GUARD3;
13919
+ var init_model_router = __esm({
13920
+ "../core/dist/meta-hooks/model-router.js"() {
13921
+ "use strict";
13922
+ OLAM_META_MODEL_ROUTER_SENTINEL = "olam-meta-model-router-v1";
13923
+ OLAM_META_MODEL_ROUTER_STAGE = "UserPromptSubmit";
13924
+ OLAM_META_MODEL_ROUTER_TIMEOUT_MS = 5e3;
13925
+ OLAM_META_MODEL_ROUTER_SCRIPT_PATH = "$HOME/.claude/hooks/model-router.py";
13926
+ OLAM_META_MODEL_ROUTER_SCRIPT_BASENAME = "model-router.py";
13927
+ OLAM_META_NOOP_GUARD3 = "command -v olam >/dev/null 2>&1 || exit 0;";
13928
+ }
13929
+ });
13930
+
13931
+ // ../core/dist/meta-hooks/model-router-deploy.js
13932
+ import { existsSync as existsSync28, mkdirSync as mkdirSync16, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
13933
+ import { homedir as homedir16 } from "node:os";
13934
+ import { dirname as dirname13, join as join24, resolve as resolve7 } from "node:path";
13935
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
13936
+ function resolveModelRouterSourcePath() {
13937
+ const here = dirname13(fileURLToPath3(import.meta.url));
13938
+ const candidates = [
13939
+ // (1) in-repo tsc dist: core/dist/meta-hooks → ../../../cli/hooks
13940
+ resolve7(here, "..", "..", "..", "cli", "hooks", MODEL_ROUTER_SCRIPT_BASENAME),
13941
+ // (1b) in-repo src (tsx / vitest): core/src/meta-hooks → ../../../cli/hooks
13942
+ resolve7(here, "..", "..", "..", "cli", "hooks", MODEL_ROUTER_SCRIPT_BASENAME),
13943
+ // (2) bundled CLI: dist/<bundle> → ../hooks (hooks is sibling of dist)
13944
+ resolve7(here, "..", "hooks", MODEL_ROUTER_SCRIPT_BASENAME),
13945
+ resolve7(here, "..", "..", "hooks", MODEL_ROUTER_SCRIPT_BASENAME)
13946
+ ];
13947
+ for (const candidate of candidates) {
13948
+ if (existsSync28(candidate))
13949
+ return candidate;
13950
+ }
13951
+ return candidates[0];
13952
+ }
13953
+ function deployModelRouterScript(opts = {}) {
13954
+ const targetDir = opts.targetDir ?? join24(homedir16(), ".claude", "hooks");
13955
+ const targetPath = join24(targetDir, MODEL_ROUTER_SCRIPT_BASENAME);
13956
+ const sourcePath = opts.sourcePath ?? resolveModelRouterSourcePath();
13957
+ if (!existsSync28(sourcePath)) {
13958
+ return { basename: MODEL_ROUTER_SCRIPT_BASENAME, action: "source-missing", targetPath };
13959
+ }
13960
+ const newContent = readFileSync22(sourcePath, "utf8");
13961
+ if (existsSync28(targetPath)) {
13962
+ const existing = readFileSync22(targetPath, "utf8");
13963
+ if (existing === newContent) {
13964
+ return { basename: MODEL_ROUTER_SCRIPT_BASENAME, action: "unchanged", targetPath };
13965
+ }
13966
+ }
13967
+ if (opts.dryRun !== true) {
13968
+ mkdirSync16(dirname13(targetPath), { recursive: true });
13969
+ writeFileSync14(targetPath, newContent, { mode: 493 });
13970
+ }
13971
+ return { basename: MODEL_ROUTER_SCRIPT_BASENAME, action: "written", targetPath };
13972
+ }
13973
+ var MODEL_ROUTER_SCRIPT_BASENAME;
13974
+ var init_model_router_deploy = __esm({
13975
+ "../core/dist/meta-hooks/model-router-deploy.js"() {
13976
+ "use strict";
13977
+ MODEL_ROUTER_SCRIPT_BASENAME = "model-router.py";
13978
+ }
13979
+ });
13980
+
13857
13981
  // ../core/dist/meta-hooks/index.js
13858
13982
  var init_meta_hooks = __esm({
13859
13983
  "../core/dist/meta-hooks/index.js"() {
13860
13984
  "use strict";
13861
13985
  init_memory_recall();
13862
13986
  init_memory_classify();
13987
+ init_model_router();
13988
+ init_model_router_deploy();
13863
13989
  }
13864
13990
  });
13865
13991
 
13866
13992
  // ../core/dist/skill-sync/settings-merger.js
13867
- import * as fs26 from "node:fs";
13993
+ import * as fs27 from "node:fs";
13868
13994
  import * as os16 from "node:os";
13869
13995
  import * as path25 from "node:path";
13870
13996
  function claudeSettingsPath() {
@@ -13933,28 +14059,28 @@ function tagOlam(entry) {
13933
14059
  return { ...entry, [OLAM_SKILLS_MARKER]: true };
13934
14060
  }
13935
14061
  function readJson(file) {
13936
- return JSON.parse(fs26.readFileSync(file, "utf-8"));
14062
+ return JSON.parse(fs27.readFileSync(file, "utf-8"));
13937
14063
  }
13938
14064
  function rotateBackups(backupDir) {
13939
- if (!fs26.existsSync(backupDir))
14065
+ if (!fs27.existsSync(backupDir))
13940
14066
  return;
13941
- const files = fs26.readdirSync(backupDir).filter((f) => f.endsWith(".json")).map((f) => ({ name: f, full: path25.join(backupDir, f), mtime: fs26.statSync(path25.join(backupDir, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
14067
+ const files = fs27.readdirSync(backupDir).filter((f) => f.endsWith(".json")).map((f) => ({ name: f, full: path25.join(backupDir, f), mtime: fs27.statSync(path25.join(backupDir, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
13942
14068
  for (const f of files.slice(BACKUP_RETENTION)) {
13943
14069
  try {
13944
- fs26.unlinkSync(f.full);
14070
+ fs27.unlinkSync(f.full);
13945
14071
  } catch {
13946
14072
  }
13947
14073
  }
13948
14074
  }
13949
14075
  function backupSettings() {
13950
14076
  const src = claudeSettingsPath();
13951
- if (!fs26.existsSync(src))
14077
+ if (!fs27.existsSync(src))
13952
14078
  return void 0;
13953
14079
  const dir = settingsBackupDir();
13954
- fs26.mkdirSync(dir, { recursive: true });
14080
+ fs27.mkdirSync(dir, { recursive: true });
13955
14081
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
13956
14082
  const dest = path25.join(dir, `settings-${stamp}.json`);
13957
- fs26.copyFileSync(src, dest);
14083
+ fs27.copyFileSync(src, dest);
13958
14084
  rotateBackups(dir);
13959
14085
  return dest;
13960
14086
  }
@@ -13962,7 +14088,7 @@ function mergeSettings(input) {
13962
14088
  const settingsPath = claudeSettingsPath();
13963
14089
  const backupPath = backupSettings();
13964
14090
  let base = {};
13965
- if (fs26.existsSync(settingsPath)) {
14091
+ if (fs27.existsSync(settingsPath)) {
13966
14092
  try {
13967
14093
  base = readJson(settingsPath);
13968
14094
  } catch {
@@ -14030,10 +14156,10 @@ function mergeSettings(input) {
14030
14156
  ...input.permissionFiles.length > 0 ? { allow: [...permSet] } : {}
14031
14157
  }
14032
14158
  };
14033
- fs26.mkdirSync(path25.dirname(settingsPath), { recursive: true });
14159
+ fs27.mkdirSync(path25.dirname(settingsPath), { recursive: true });
14034
14160
  const tmp = `${settingsPath}.tmp-${process.pid}`;
14035
- fs26.writeFileSync(tmp, JSON.stringify(next, null, 2) + "\n", { mode: 420 });
14036
- fs26.renameSync(tmp, settingsPath);
14161
+ fs27.writeFileSync(tmp, JSON.stringify(next, null, 2) + "\n", { mode: 420 });
14162
+ fs27.renameSync(tmp, settingsPath);
14037
14163
  return { backupPath, hooksAdded, permissionsCount: permSet.size, dualWriteDeduped, dualWriteDroppedCommands };
14038
14164
  }
14039
14165
  var OLAM_SKILLS_MARKER, BACKUP_RETENTION, DUAL_WRITE_DEDUP_RULES;
@@ -14090,7 +14216,7 @@ var init_schema5 = __esm({
14090
14216
 
14091
14217
  // ../core/dist/skill-sync/per-project-override.js
14092
14218
  import { execFileSync as execFileSync3 } from "node:child_process";
14093
- import * as fs27 from "node:fs";
14219
+ import * as fs28 from "node:fs";
14094
14220
  import * as path26 from "node:path";
14095
14221
  import { parse as parseYaml3 } from "yaml";
14096
14222
  function findProjectOverride(startDir) {
@@ -14098,8 +14224,8 @@ function findProjectOverride(startDir) {
14098
14224
  const root = path26.parse(dir).root;
14099
14225
  while (true) {
14100
14226
  const candidate = path26.join(dir, PROJECT_OVERRIDE_RELATIVE_PATH);
14101
- if (fs27.existsSync(candidate) && fs27.statSync(candidate).isFile()) {
14102
- const raw = fs27.readFileSync(candidate, "utf-8");
14227
+ if (fs28.existsSync(candidate) && fs28.statSync(candidate).isFile()) {
14228
+ const raw = fs28.readFileSync(candidate, "utf-8");
14103
14229
  let parsed;
14104
14230
  try {
14105
14231
  parsed = parseYaml3(raw);
@@ -14158,7 +14284,7 @@ var init_per_project_override = __esm({
14158
14284
  });
14159
14285
 
14160
14286
  // ../core/dist/lib/file-lock.js
14161
- import * as fs28 from "node:fs";
14287
+ import * as fs29 from "node:fs";
14162
14288
  import * as os17 from "node:os";
14163
14289
  import * as path27 from "node:path";
14164
14290
  function defaultIsPidAlive(pid) {
@@ -14171,11 +14297,11 @@ function defaultIsPidAlive(pid) {
14171
14297
  }
14172
14298
  }
14173
14299
  function sleep3(ms) {
14174
- return new Promise((resolve15) => setTimeout(resolve15, ms));
14300
+ return new Promise((resolve16) => setTimeout(resolve16, ms));
14175
14301
  }
14176
14302
  function readLockMeta(lockPath) {
14177
14303
  try {
14178
- const raw = fs28.readFileSync(lockPath, "utf-8");
14304
+ const raw = fs29.readFileSync(lockPath, "utf-8");
14179
14305
  const parsed = JSON.parse(raw);
14180
14306
  if (typeof parsed?.pid === "number" && typeof parsed?.hostname === "string" && typeof parsed?.timestamp === "number") {
14181
14307
  return parsed;
@@ -14194,12 +14320,12 @@ function isLockStale(meta2, opts) {
14194
14320
  }
14195
14321
  function tryAcquireOnce(lockPath, meta2, opts) {
14196
14322
  try {
14197
- fs28.mkdirSync(path27.dirname(lockPath), { recursive: true });
14198
- const fd = fs28.openSync(lockPath, "wx", 384);
14323
+ fs29.mkdirSync(path27.dirname(lockPath), { recursive: true });
14324
+ const fd = fs29.openSync(lockPath, "wx", 384);
14199
14325
  try {
14200
- fs28.writeSync(fd, JSON.stringify(meta2));
14326
+ fs29.writeSync(fd, JSON.stringify(meta2));
14201
14327
  } finally {
14202
- fs28.closeSync(fd);
14328
+ fs29.closeSync(fd);
14203
14329
  }
14204
14330
  return true;
14205
14331
  } catch (err) {
@@ -14209,14 +14335,14 @@ function tryAcquireOnce(lockPath, meta2, opts) {
14209
14335
  const existing = readLockMeta(lockPath);
14210
14336
  if (existing === void 0) {
14211
14337
  try {
14212
- fs28.unlinkSync(lockPath);
14338
+ fs29.unlinkSync(lockPath);
14213
14339
  } catch {
14214
14340
  }
14215
14341
  return tryAcquireOnce(lockPath, meta2, opts);
14216
14342
  }
14217
14343
  if (isLockStale(existing, opts)) {
14218
14344
  try {
14219
- fs28.unlinkSync(lockPath);
14345
+ fs29.unlinkSync(lockPath);
14220
14346
  } catch {
14221
14347
  }
14222
14348
  return tryAcquireOnce(lockPath, meta2, opts);
@@ -14246,7 +14372,7 @@ async function acquireFileLock(lockDir, options = {}) {
14246
14372
  lockPath,
14247
14373
  release: () => {
14248
14374
  try {
14249
- fs28.unlinkSync(lockPath);
14375
+ fs29.unlinkSync(lockPath);
14250
14376
  } catch {
14251
14377
  }
14252
14378
  }
@@ -14286,13 +14412,13 @@ var init_file_lock = __esm({
14286
14412
  });
14287
14413
 
14288
14414
  // ../core/dist/lib/min-version-filter.js
14289
- import { existsSync as existsSync29, readFileSync as readFileSync24 } from "node:fs";
14415
+ import { existsSync as existsSync31, readFileSync as readFileSync26 } from "node:fs";
14290
14416
  function readOlamMinVersion(filepath) {
14291
- if (!existsSync29(filepath))
14417
+ if (!existsSync31(filepath))
14292
14418
  return void 0;
14293
14419
  let text;
14294
14420
  try {
14295
- text = readFileSync24(filepath, "utf8");
14421
+ text = readFileSync26(filepath, "utf8");
14296
14422
  } catch {
14297
14423
  return void 0;
14298
14424
  }
@@ -14350,11 +14476,11 @@ var init_min_version_filter = __esm({
14350
14476
  });
14351
14477
 
14352
14478
  // ../core/dist/skill-sync/overlay-scan.js
14353
- import * as fs29 from "node:fs";
14479
+ import * as fs30 from "node:fs";
14354
14480
  import * as path28 from "node:path";
14355
14481
  function scanOverlayReferences(overlayRoot, basenames, caps = DEFAULT_CAPS) {
14356
14482
  const result = /* @__PURE__ */ new Map();
14357
- if (!fs29.existsSync(overlayRoot)) {
14483
+ if (!fs30.existsSync(overlayRoot)) {
14358
14484
  return result;
14359
14485
  }
14360
14486
  if (basenames.length === 0) {
@@ -14363,13 +14489,13 @@ function scanOverlayReferences(overlayRoot, basenames, caps = DEFAULT_CAPS) {
14363
14489
  const mdFiles = [];
14364
14490
  let overlayRootReal;
14365
14491
  try {
14366
- overlayRootReal = fs29.realpathSync(overlayRoot);
14492
+ overlayRootReal = fs30.realpathSync(overlayRoot);
14367
14493
  } catch {
14368
14494
  return result;
14369
14495
  }
14370
14496
  for (const subdir of OVERRIDE_SUBDIRS) {
14371
14497
  const dir = path28.join(overlayRoot, subdir);
14372
- if (!fs29.existsSync(dir))
14498
+ if (!fs30.existsSync(dir))
14373
14499
  continue;
14374
14500
  walkMarkdown(dir, mdFiles, caps.maxFiles);
14375
14501
  }
@@ -14377,7 +14503,7 @@ function scanOverlayReferences(overlayRoot, basenames, caps = DEFAULT_CAPS) {
14377
14503
  for (const filepath of mdFiles) {
14378
14504
  let realFile;
14379
14505
  try {
14380
- realFile = fs29.realpathSync(filepath);
14506
+ realFile = fs30.realpathSync(filepath);
14381
14507
  } catch (err) {
14382
14508
  const code = err.code;
14383
14509
  if (code === "ENOENT" || code === "EACCES")
@@ -14390,12 +14516,12 @@ function scanOverlayReferences(overlayRoot, basenames, caps = DEFAULT_CAPS) {
14390
14516
  }
14391
14517
  let content;
14392
14518
  try {
14393
- const stat2 = fs29.statSync(filepath);
14519
+ const stat2 = fs30.statSync(filepath);
14394
14520
  totalBytes += stat2.size;
14395
14521
  if (totalBytes > caps.maxTotalBytes) {
14396
14522
  throw new Error(`[overlay-scan] aborted: overlay tree exceeds ${caps.maxTotalBytes} total bytes. Check OLAM_CLAUDE_DIR / overlay paths are correctly scoped.`);
14397
14523
  }
14398
- content = fs29.readFileSync(filepath, "utf8");
14524
+ content = fs30.readFileSync(filepath, "utf8");
14399
14525
  } catch (err) {
14400
14526
  const code = err.code;
14401
14527
  if (code === "ENOENT" || code === "EACCES") {
@@ -14417,7 +14543,7 @@ function scanOverlayReferences(overlayRoot, basenames, caps = DEFAULT_CAPS) {
14417
14543
  function walkMarkdown(dir, out, cap) {
14418
14544
  let entries;
14419
14545
  try {
14420
- entries = fs29.readdirSync(dir, { withFileTypes: true });
14546
+ entries = fs30.readdirSync(dir, { withFileTypes: true });
14421
14547
  } catch (err) {
14422
14548
  if (err.code === "ENOENT")
14423
14549
  return;
@@ -14452,7 +14578,7 @@ var init_overlay_scan = __esm({
14452
14578
  });
14453
14579
 
14454
14580
  // ../core/dist/skill-sync/settings-json-lock.js
14455
- import * as fs30 from "node:fs";
14581
+ import * as fs31 from "node:fs";
14456
14582
  import * as os18 from "node:os";
14457
14583
  import * as path29 from "node:path";
14458
14584
  function defaultSettingsJsonLockPath() {
@@ -14469,11 +14595,11 @@ function defaultIsPidAlive2(pid) {
14469
14595
  }
14470
14596
  }
14471
14597
  function sleep4(ms) {
14472
- return new Promise((resolve15) => setTimeout(resolve15, ms));
14598
+ return new Promise((resolve16) => setTimeout(resolve16, ms));
14473
14599
  }
14474
14600
  function readLockMeta2(lockPath) {
14475
14601
  try {
14476
- const raw = fs30.readFileSync(lockPath, "utf-8");
14602
+ const raw = fs31.readFileSync(lockPath, "utf-8");
14477
14603
  const parsed = JSON.parse(raw);
14478
14604
  if (typeof parsed?.pid === "number" && typeof parsed?.hostname === "string" && typeof parsed?.timestamp === "number") {
14479
14605
  return parsed;
@@ -14496,12 +14622,12 @@ function isLockStale2(meta2, opts) {
14496
14622
  function tryAcquireOnce2(lockPath, meta2, opts) {
14497
14623
  for (let attempt = 0; attempt <= MAX_STEAL_ATTEMPTS; attempt += 1) {
14498
14624
  try {
14499
- fs30.mkdirSync(path29.dirname(lockPath), { recursive: true });
14500
- const fd = fs30.openSync(lockPath, "wx", 384);
14625
+ fs31.mkdirSync(path29.dirname(lockPath), { recursive: true });
14626
+ const fd = fs31.openSync(lockPath, "wx", 384);
14501
14627
  try {
14502
- fs30.writeSync(fd, JSON.stringify(meta2));
14628
+ fs31.writeSync(fd, JSON.stringify(meta2));
14503
14629
  } finally {
14504
- fs30.closeSync(fd);
14630
+ fs31.closeSync(fd);
14505
14631
  }
14506
14632
  return true;
14507
14633
  } catch (err) {
@@ -14519,9 +14645,9 @@ function tryAcquireOnce2(lockPath, meta2, opts) {
14519
14645
  }
14520
14646
  const victimPath = `${lockPath}.victim-${process.pid}-${attempt}-${Date.now()}`;
14521
14647
  try {
14522
- fs30.renameSync(lockPath, victimPath);
14648
+ fs31.renameSync(lockPath, victimPath);
14523
14649
  try {
14524
- fs30.unlinkSync(victimPath);
14650
+ fs31.unlinkSync(victimPath);
14525
14651
  } catch {
14526
14652
  }
14527
14653
  } catch (err) {
@@ -14553,7 +14679,7 @@ async function acquireSettingsJsonLock(options = {}) {
14553
14679
  lockPath,
14554
14680
  release: () => {
14555
14681
  try {
14556
- fs30.unlinkSync(lockPath);
14682
+ fs31.unlinkSync(lockPath);
14557
14683
  } catch {
14558
14684
  }
14559
14685
  }
@@ -14656,7 +14782,7 @@ var init_services_status = __esm({
14656
14782
 
14657
14783
  // ../core/dist/skill-sources/meta-hooks-migration-snapshot.js
14658
14784
  import * as crypto5 from "node:crypto";
14659
- import * as fs31 from "node:fs";
14785
+ import * as fs32 from "node:fs";
14660
14786
  import * as os19 from "node:os";
14661
14787
  import * as path30 from "node:path";
14662
14788
  function migrationSnapshotsDir2() {
@@ -14674,11 +14800,11 @@ function writeMetaHooksSnapshot(originalSettings) {
14674
14800
  };
14675
14801
  const validated = MetaHooksMigrationSnapshotSchema.parse(snapshot);
14676
14802
  const dir = migrationSnapshotsDir2();
14677
- fs31.mkdirSync(dir, { recursive: true });
14803
+ fs32.mkdirSync(dir, { recursive: true });
14678
14804
  const stamp = validated.takenAt.replace(/[:.]/g, "-");
14679
14805
  const rand = crypto5.randomBytes(3).toString("hex");
14680
14806
  const file = path30.join(dir, `${META_HOOKS_SNAPSHOT_PREFIX}${stamp}-${process.pid}-${rand}.json`);
14681
- fs31.writeFileSync(file, JSON.stringify(validated, null, 2) + "\n", { mode: 384 });
14807
+ fs32.writeFileSync(file, JSON.stringify(validated, null, 2) + "\n", { mode: 384 });
14682
14808
  return file;
14683
14809
  }
14684
14810
  var META_HOOKS_SNAPSHOT_SCHEMA_VERSION, META_HOOKS_SNAPSHOT_PREFIX, SettingsLooseSchema, MetaHooksMigrationSnapshotSchema;
@@ -14819,6 +14945,8 @@ function decideTargetBlocks(opts) {
14819
14945
  target.add("memory-recall");
14820
14946
  if (wantMemory && !disabled.has("memory-classify"))
14821
14947
  target.add("memory-classify");
14948
+ if (!disabled.has("model-router"))
14949
+ target.add("model-router");
14822
14950
  return target;
14823
14951
  }
14824
14952
  function injectMetaHooks(opts) {
@@ -14826,6 +14954,7 @@ function injectMetaHooks(opts) {
14826
14954
  let working = JSON.parse(JSON.stringify(opts.currentSettings ?? {}));
14827
14955
  const blocksAdded = [];
14828
14956
  const blocksRemoved = [];
14957
+ const blocksSkippedForeign = [];
14829
14958
  const memoryRecallPresent = hasMemoryRecallBlock(working);
14830
14959
  if (target.has("memory-recall")) {
14831
14960
  if (!memoryRecallPresent) {
@@ -14856,10 +14985,30 @@ function injectMetaHooks(opts) {
14856
14985
  }
14857
14986
  }
14858
14987
  }
14988
+ const modelRouterPresent = hasModelRouterBlock(working);
14989
+ if (target.has("model-router")) {
14990
+ if (!modelRouterPresent) {
14991
+ if (hasForeignModelRouterEntry(working)) {
14992
+ blocksSkippedForeign.push("model-router");
14993
+ } else {
14994
+ working = appendBlock(working, OLAM_META_MODEL_ROUTER_STAGE, buildModelRouterHookEntry());
14995
+ blocksAdded.push("model-router");
14996
+ }
14997
+ }
14998
+ } else {
14999
+ if (modelRouterPresent) {
15000
+ const r = computeModelRouterUninstall(working);
15001
+ if (r.status === "removed" && r.settingsAfter) {
15002
+ working = r.settingsAfter;
15003
+ blocksRemoved.push("model-router");
15004
+ }
15005
+ }
15006
+ }
14859
15007
  return {
14860
15008
  nextSettings: working,
14861
15009
  blocksAdded,
14862
15010
  blocksRemoved,
15011
+ blocksSkippedForeign,
14863
15012
  mode: opts.mode ?? "auto"
14864
15013
  };
14865
15014
  }
@@ -14893,6 +15042,40 @@ function hasMemoryClassifyBlock(settings) {
14893
15042
  }
14894
15043
  return false;
14895
15044
  }
15045
+ function hasModelRouterBlock(settings) {
15046
+ const entries = settings.hooks?.UserPromptSubmit;
15047
+ if (!Array.isArray(entries))
15048
+ return false;
15049
+ for (const matcher of entries) {
15050
+ const inner = matcher?.hooks ?? [];
15051
+ if (!Array.isArray(inner))
15052
+ continue;
15053
+ for (const h of inner) {
15054
+ if (typeof h?.command === "string" && matchModelRouterSentinel(h.command))
15055
+ return true;
15056
+ }
15057
+ }
15058
+ return false;
15059
+ }
15060
+ function hasForeignModelRouterEntry(settings) {
15061
+ const entries = settings.hooks?.UserPromptSubmit;
15062
+ if (!Array.isArray(entries))
15063
+ return false;
15064
+ for (const matcher of entries) {
15065
+ const inner = matcher?.hooks ?? [];
15066
+ if (!Array.isArray(inner))
15067
+ continue;
15068
+ for (const h of inner) {
15069
+ if (typeof h?.command !== "string")
15070
+ continue;
15071
+ if (matchModelRouterSentinel(h.command))
15072
+ continue;
15073
+ if (h.command.includes(OLAM_META_MODEL_ROUTER_SCRIPT_BASENAME))
15074
+ return true;
15075
+ }
15076
+ }
15077
+ return false;
15078
+ }
14896
15079
  function appendBlock(settings, stage, entry) {
14897
15080
  const next = { ...settings };
14898
15081
  const hooks = { ...settings.hooks ?? {} };
@@ -14911,7 +15094,7 @@ var init_meta_hook_injector = __esm({
14911
15094
 
14912
15095
  // ../core/dist/lib/markdown-merger.js
14913
15096
  import { createHash as createHash5 } from "node:crypto";
14914
- import { readFileSync as readFileSync28, existsSync as existsSync32, statSync as statSync8 } from "node:fs";
15097
+ import { readFileSync as readFileSync30, existsSync as existsSync34, statSync as statSync8 } from "node:fs";
14915
15098
  function parseFrontmatter(text) {
14916
15099
  const match = FM_RE2.exec(text);
14917
15100
  if (match === null)
@@ -15040,9 +15223,9 @@ function mergeMarkdown(upstreamText, overlayText, labelForError, upstreamPath, o
15040
15223
  return { merged: fmBlock !== "" ? fmBlock + mergedBody : mergedBody };
15041
15224
  }
15042
15225
  function sha256OfPath(p) {
15043
- if (!existsSync32(p) || !statSync8(p).isFile())
15226
+ if (!existsSync34(p) || !statSync8(p).isFile())
15044
15227
  return "MISSING";
15045
- return createHash5("sha256").update(readFileSync28(p)).digest("hex");
15228
+ return createHash5("sha256").update(readFileSync30(p)).digest("hex");
15046
15229
  }
15047
15230
  var FM_RE2, H2_RE;
15048
15231
  var init_markdown_merger = __esm({
@@ -15054,7 +15237,7 @@ var init_markdown_merger = __esm({
15054
15237
  });
15055
15238
 
15056
15239
  // ../core/dist/skill-sync/managed-merge.js
15057
- import * as fs32 from "node:fs";
15240
+ import * as fs33 from "node:fs";
15058
15241
  import * as path31 from "node:path";
15059
15242
  function materializeMergedSkill(opts) {
15060
15243
  const { sourceId, sourcePath, deployBasename, mergedContent, claudeDir: claudeDir2 } = opts;
@@ -15064,12 +15247,12 @@ function materializeMergedSkill(opts) {
15064
15247
  if (!(managedResolved === sourceRoot || managedResolved.startsWith(sourceRoot + path31.sep))) {
15065
15248
  throw new Error(`[managed-merge] refusing to materialize: deployBasename "${deployBasename}" escapes managed root "${sourceRoot}" (resolved to "${managedResolved}")`);
15066
15249
  }
15067
- fs32.mkdirSync(managedDir, { recursive: true });
15250
+ fs33.mkdirSync(managedDir, { recursive: true });
15068
15251
  const skillMdPath = path31.join(managedDir, "SKILL.md");
15069
15252
  const tmpPath = `${skillMdPath}.tmp-${process.pid}-${Date.now()}`;
15070
- fs32.writeFileSync(tmpPath, mergedContent);
15071
- fs32.renameSync(tmpPath, skillMdPath);
15072
- const baseEntries = fs32.readdirSync(sourcePath);
15253
+ fs33.writeFileSync(tmpPath, mergedContent);
15254
+ fs33.renameSync(tmpPath, skillMdPath);
15255
+ const baseEntries = fs33.readdirSync(sourcePath);
15073
15256
  for (const entry of baseEntries) {
15074
15257
  if (entry === "SKILL.md")
15075
15258
  continue;
@@ -15077,13 +15260,13 @@ function materializeMergedSkill(opts) {
15077
15260
  const targetAbsolute = path31.join(sourcePath, entry);
15078
15261
  const targetRelative = path31.relative(managedDir, targetAbsolute);
15079
15262
  try {
15080
- fs32.lstatSync(linkPath);
15081
- fs32.rmSync(linkPath, { recursive: true, force: true });
15263
+ fs33.lstatSync(linkPath);
15264
+ fs33.rmSync(linkPath, { recursive: true, force: true });
15082
15265
  } catch {
15083
15266
  }
15084
- fs32.symlinkSync(targetRelative, linkPath);
15267
+ fs33.symlinkSync(targetRelative, linkPath);
15085
15268
  }
15086
- const managedEntries = fs32.readdirSync(managedDir);
15269
+ const managedEntries = fs33.readdirSync(managedDir);
15087
15270
  const baseEntrySet = new Set(baseEntries);
15088
15271
  for (const entry of managedEntries) {
15089
15272
  if (entry === "SKILL.md")
@@ -15091,7 +15274,7 @@ function materializeMergedSkill(opts) {
15091
15274
  if (!baseEntrySet.has(entry)) {
15092
15275
  const stalePath = path31.join(managedDir, entry);
15093
15276
  try {
15094
- fs32.rmSync(stalePath, { recursive: true, force: true });
15277
+ fs33.rmSync(stalePath, { recursive: true, force: true });
15095
15278
  } catch {
15096
15279
  }
15097
15280
  }
@@ -15099,7 +15282,7 @@ function materializeMergedSkill(opts) {
15099
15282
  return managedDir;
15100
15283
  }
15101
15284
  function cleanMergedDir(claudeDir2) {
15102
- fs32.rmSync(path31.join(claudeDir2, ".olam-merged"), { recursive: true, force: true });
15285
+ fs33.rmSync(path31.join(claudeDir2, ".olam-merged"), { recursive: true, force: true });
15103
15286
  }
15104
15287
  var init_managed_merge = __esm({
15105
15288
  "../core/dist/skill-sync/managed-merge.js"() {
@@ -15197,7 +15380,7 @@ var init_prefix_rules = __esm({
15197
15380
  });
15198
15381
 
15199
15382
  // ../core/dist/skill-sync/prefix-deploy.js
15200
- import * as fs33 from "node:fs";
15383
+ import * as fs34 from "node:fs";
15201
15384
  import * as path32 from "node:path";
15202
15385
  function buildSourcePrefixMap(sources) {
15203
15386
  const byId = /* @__PURE__ */ new Map();
@@ -15253,7 +15436,7 @@ function applyPrefixRewrites(baseArtifacts, sourceMap, claudeDir2, dryRun) {
15253
15436
  }
15254
15437
  if (artifact.kind === "skill") {
15255
15438
  const skillMdPath = path32.join(artifact.sourcePath, "SKILL.md");
15256
- const content = fs33.readFileSync(skillMdPath);
15439
+ const content = fs34.readFileSync(skillMdPath);
15257
15440
  const rewritten = rewriteFrontmatterName(content, () => renamedFrontmatterName);
15258
15441
  const managedDir = materializeMergedSkill({
15259
15442
  sourceId: artifact.sourceId,
@@ -15265,7 +15448,7 @@ function applyPrefixRewrites(baseArtifacts, sourceMap, claudeDir2, dryRun) {
15265
15448
  artifact.sourcePath = managedDir;
15266
15449
  artifact.deployBasename = renamed;
15267
15450
  } else {
15268
- const content = artifact.resolvedContent !== void 0 ? artifact.resolvedContent : fs33.readFileSync(artifact.sourcePath);
15451
+ const content = artifact.resolvedContent !== void 0 ? artifact.resolvedContent : fs34.readFileSync(artifact.sourcePath);
15269
15452
  const rewritten = rewriteFrontmatterName(content, () => renamedFrontmatterName);
15270
15453
  artifact.resolvedContent = rewritten;
15271
15454
  artifact.deployBasename = renamed;
@@ -15310,19 +15493,19 @@ var init_prefix_deploy = __esm({
15310
15493
  });
15311
15494
 
15312
15495
  // ../core/dist/skill-sync/resolve-source-config.js
15313
- import { readFileSync as readFileSync30, existsSync as existsSync33 } from "node:fs";
15314
- import { join as join32 } from "node:path";
15496
+ import { readFileSync as readFileSync32, existsSync as existsSync35 } from "node:fs";
15497
+ import { join as join33 } from "node:path";
15315
15498
  import { parse as parseYaml4 } from "yaml";
15316
15499
  function sourceConfigPath(clonePath) {
15317
- return join32(clonePath, "shared", "source-config.yaml");
15500
+ return join33(clonePath, "shared", "source-config.yaml");
15318
15501
  }
15319
15502
  function readSourceConfig(clonePath, sourceId) {
15320
15503
  const path56 = sourceConfigPath(clonePath);
15321
- if (!existsSync33(path56))
15504
+ if (!existsSync35(path56))
15322
15505
  return void 0;
15323
15506
  let raw;
15324
15507
  try {
15325
- raw = readFileSync30(path56, "utf-8");
15508
+ raw = readFileSync32(path56, "utf-8");
15326
15509
  } catch (err) {
15327
15510
  emitMalformedWarning(sourceId, `read failed: ${errToMsg(err)}`);
15328
15511
  return void 0;
@@ -15417,7 +15600,7 @@ var init_resolve_source_config = __esm({
15417
15600
  });
15418
15601
 
15419
15602
  // ../core/dist/skill-sync/engine.js
15420
- import * as fs34 from "node:fs";
15603
+ import * as fs35 from "node:fs";
15421
15604
  import * as os20 from "node:os";
15422
15605
  import * as path33 from "node:path";
15423
15606
  function resolveAtlasUser(override) {
@@ -15425,8 +15608,8 @@ function resolveAtlasUser(override) {
15425
15608
  return override;
15426
15609
  const claudeDir2 = process.env["OLAM_CLAUDE_DIR"] || path33.join(os20.homedir(), ".claude");
15427
15610
  const f = path33.join(claudeDir2, ".atlas-user");
15428
- if (fs34.existsSync(f)) {
15429
- return fs34.readFileSync(f, "utf-8").trim() || void 0;
15611
+ if (fs35.existsSync(f)) {
15612
+ return fs35.readFileSync(f, "utf-8").trim() || void 0;
15430
15613
  }
15431
15614
  return void 0;
15432
15615
  }
@@ -15438,7 +15621,7 @@ async function syncSkills(opts = {}) {
15438
15621
  const perSource = [];
15439
15622
  for (const source of sources) {
15440
15623
  const clonePath = skillSourceClonePath(source.id);
15441
- if (!fs34.existsSync(clonePath))
15624
+ if (!fs35.existsSync(clonePath))
15442
15625
  continue;
15443
15626
  const { artifacts, subscription } = await withFileLock(clonePath, () => {
15444
15627
  const pinRef = projectOverride?.override.pin?.[source.id];
@@ -15478,7 +15661,7 @@ async function syncSkills(opts = {}) {
15478
15661
  const overlayArtifacts = memberOverlaysEnabled ? projectFilteredArtifacts.filter((a) => a.kind === "overlay") : [];
15479
15662
  const effectiveSources = sources.map((s) => {
15480
15663
  const clonePath = skillSourceClonePath(s.id);
15481
- const sourceConfig = fs34.existsSync(clonePath) ? readSourceConfig(clonePath, s.id) : void 0;
15664
+ const sourceConfig = fs35.existsSync(clonePath) ? readSourceConfig(clonePath, s.id) : void 0;
15482
15665
  const eff = resolveEffectivePrefix(s, sourceConfig);
15483
15666
  const entry = {
15484
15667
  id: s.id,
@@ -15585,12 +15768,12 @@ async function syncSkills(opts = {}) {
15585
15768
  let basePath;
15586
15769
  if (overlay.targetKind === "skill") {
15587
15770
  basePath = path33.join(base.sourcePath, "SKILL.md");
15588
- baseContent = fs34.readFileSync(basePath, "utf-8");
15771
+ baseContent = fs35.readFileSync(basePath, "utf-8");
15589
15772
  } else {
15590
15773
  basePath = base.sourcePath;
15591
- baseContent = fs34.readFileSync(basePath, "utf-8");
15774
+ baseContent = fs35.readFileSync(basePath, "utf-8");
15592
15775
  }
15593
- const overlayContent = fs34.readFileSync(overlay.sourcePath, "utf-8");
15776
+ const overlayContent = fs35.readFileSync(overlay.sourcePath, "utf-8");
15594
15777
  const label = `${overlay.sourceId}/${overlay.deployBasename}`;
15595
15778
  const mergeResult = mergeMarkdown(baseContent, overlayContent, label, basePath, overlay.sourcePath);
15596
15779
  if ("error" in mergeResult) {
@@ -15672,24 +15855,34 @@ async function injectMetaHooksIntoSettings(opts) {
15672
15855
  ...memoryProbe.detail !== void 0 ? { memoryDetail: memoryProbe.detail } : {}
15673
15856
  };
15674
15857
  const settingsFile = claudeSettingsPath();
15858
+ let configDisabled = [];
15859
+ try {
15860
+ const cfg = readGlobalConfig();
15861
+ configDisabled = cfg.metaHooksDisabled ?? [];
15862
+ } catch {
15863
+ }
15864
+ const disabledBlocks = Array.from(/* @__PURE__ */ new Set([
15865
+ ...configDisabled,
15866
+ ...opts.metaHooksDisabled ?? []
15867
+ ]));
15675
15868
  let snapshotError;
15676
15869
  let stripCandidates = [];
15677
15870
  const result = await withSettingsJsonLock(() => {
15678
15871
  let currentSettings = {};
15679
15872
  let settingsExisted = false;
15680
- if (fs34.existsSync(settingsFile)) {
15873
+ if (fs35.existsSync(settingsFile)) {
15681
15874
  settingsExisted = true;
15682
15875
  try {
15683
- const raw = fs34.readFileSync(settingsFile, "utf-8");
15876
+ const raw = fs35.readFileSync(settingsFile, "utf-8");
15684
15877
  currentSettings = raw.trim() ? JSON.parse(raw) : {};
15685
15878
  } catch {
15686
15879
  try {
15687
- const raw = fs34.readFileSync(settingsFile);
15880
+ const raw = fs35.readFileSync(settingsFile);
15688
15881
  const bakDir = path33.join(path33.dirname(settingsFile), ".malformed-backups");
15689
- fs34.mkdirSync(bakDir, { recursive: true });
15882
+ fs35.mkdirSync(bakDir, { recursive: true });
15690
15883
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
15691
15884
  const bakFile = path33.join(bakDir, `settings.json.malformed.${stamp}.bak`);
15692
- fs34.writeFileSync(bakFile, raw, { mode: 384 });
15885
+ fs35.writeFileSync(bakFile, raw, { mode: 384 });
15693
15886
  snapshotError = `settings.json was malformed; original bytes preserved at ${bakFile}`;
15694
15887
  } catch (bakErr) {
15695
15888
  snapshotError = `settings.json malformed AND .bak write failed: ${bakErr instanceof Error ? bakErr.message : String(bakErr)}`;
@@ -15700,16 +15893,6 @@ async function injectMetaHooksIntoSettings(opts) {
15700
15893
  }
15701
15894
  stripCandidates = findStripCandidates(currentSettings);
15702
15895
  const settingsForInject = stripCandidates.length > 0 ? applyStrip(currentSettings, stripCandidates).nextSettings : currentSettings;
15703
- let configDisabled = [];
15704
- try {
15705
- const cfg = readGlobalConfig();
15706
- configDisabled = cfg.metaHooksDisabled ?? [];
15707
- } catch {
15708
- }
15709
- const disabledBlocks = Array.from(/* @__PURE__ */ new Set([
15710
- ...configDisabled,
15711
- ...opts.metaHooksDisabled ?? []
15712
- ]));
15713
15896
  const inject = injectMetaHooks({
15714
15897
  servicesStatus,
15715
15898
  currentSettings: settingsForInject,
@@ -15739,17 +15922,34 @@ async function injectMetaHooksIntoSettings(opts) {
15739
15922
  } catch {
15740
15923
  }
15741
15924
  }
15742
- fs34.mkdirSync(path33.dirname(settingsFile), { recursive: true });
15925
+ fs35.mkdirSync(path33.dirname(settingsFile), { recursive: true });
15743
15926
  const tmpPath = `${settingsFile}.tmp-${process.pid}-${Date.now()}`;
15744
- fs34.writeFileSync(tmpPath, JSON.stringify(inject.nextSettings, null, 2) + "\n");
15745
- fs34.renameSync(tmpPath, settingsFile);
15927
+ fs35.writeFileSync(tmpPath, JSON.stringify(inject.nextSettings, null, 2) + "\n");
15928
+ fs35.renameSync(tmpPath, settingsFile);
15746
15929
  return inject;
15747
15930
  }, { reason: `syncSkills meta-hook injection (mode=${mode})` });
15931
+ let scriptDeploy;
15932
+ const modelRouterTargeted = mode !== "never" && !disabledBlocks.includes("model-router");
15933
+ if (modelRouterTargeted) {
15934
+ try {
15935
+ scriptDeploy = deployModelRouterScript({
15936
+ targetDir: path33.join(claudeDir(), "hooks")
15937
+ });
15938
+ } catch (err) {
15939
+ scriptDeploy = {
15940
+ basename: "model-router.py",
15941
+ action: "source-missing",
15942
+ targetPath: `${err instanceof Error ? err.message : String(err)}`
15943
+ };
15944
+ }
15945
+ }
15748
15946
  return {
15749
15947
  mode: result.mode,
15750
15948
  servicesStatus,
15751
15949
  blocksAdded: result.blocksAdded,
15752
15950
  blocksRemoved: result.blocksRemoved,
15951
+ ...result.blocksSkippedForeign.length > 0 ? { blocksSkippedForeign: result.blocksSkippedForeign } : {},
15952
+ ...scriptDeploy !== void 0 ? { scriptDeploy } : {},
15753
15953
  ...snapshotError !== void 0 ? { snapshotError } : {},
15754
15954
  ...stripCandidates.length > 0 ? { autoMigrated: { strippedCount: stripCandidates.length, stripCandidates } } : {}
15755
15955
  };
@@ -15774,6 +15974,7 @@ var init_engine = __esm({
15774
15974
  init_trust_audit_log();
15775
15975
  init_atlas_hook_strip();
15776
15976
  init_meta_hook_injector();
15977
+ init_model_router_deploy();
15777
15978
  init_markdown_merger();
15778
15979
  init_managed_merge();
15779
15980
  init_prefix_deploy();
@@ -15783,7 +15984,7 @@ var init_engine = __esm({
15783
15984
  });
15784
15985
 
15785
15986
  // ../core/dist/skill-sync/shadow-backup-manager.js
15786
- import * as fs35 from "node:fs";
15987
+ import * as fs36 from "node:fs";
15787
15988
  import * as path34 from "node:path";
15788
15989
  function listShadowBackups(opts = {}) {
15789
15990
  const claude = opts.claudeDirOverride ?? claudeDir();
@@ -15791,11 +15992,11 @@ function listShadowBackups(opts = {}) {
15791
15992
  const out = [];
15792
15993
  for (const bucket of SHADOW_BACKUP_BUCKETS) {
15793
15994
  const bucketDir = path34.join(claude, bucket);
15794
- if (!fs35.existsSync(bucketDir))
15995
+ if (!fs36.existsSync(bucketDir))
15795
15996
  continue;
15796
15997
  let entries;
15797
15998
  try {
15798
- entries = fs35.readdirSync(bucketDir);
15999
+ entries = fs36.readdirSync(bucketDir);
15799
16000
  } catch {
15800
16001
  continue;
15801
16002
  }
@@ -15809,7 +16010,7 @@ function listShadowBackups(opts = {}) {
15809
16010
  const full = path34.join(bucketDir, name);
15810
16011
  let sizeBytes = 0;
15811
16012
  try {
15812
- const st = fs35.statSync(full);
16013
+ const st = fs36.statSync(full);
15813
16014
  if (st.isDirectory())
15814
16015
  continue;
15815
16016
  sizeBytes = st.size;
@@ -15865,7 +16066,7 @@ function pruneShadowBackups(opts) {
15865
16066
  }
15866
16067
  if (!opts.dryRun) {
15867
16068
  try {
15868
- fs35.unlinkSync(b.path);
16069
+ fs36.unlinkSync(b.path);
15869
16070
  } catch {
15870
16071
  skipped.push(b);
15871
16072
  continue;
@@ -15877,7 +16078,7 @@ function pruneShadowBackups(opts) {
15877
16078
  }
15878
16079
  function restoreShadowBackup(opts) {
15879
16080
  const abs = path34.resolve(opts.backupPath);
15880
- if (!fs35.existsSync(abs)) {
16081
+ if (!fs36.existsSync(abs)) {
15881
16082
  throw new Error(`backup file not found: ${abs}`);
15882
16083
  }
15883
16084
  const basename6 = path34.basename(abs);
@@ -15887,13 +16088,13 @@ function restoreShadowBackup(opts) {
15887
16088
  }
15888
16089
  const originalBasename = basename6.slice(0, basename6.length - match[0].length);
15889
16090
  const originalPath = path34.join(path34.dirname(abs), originalBasename);
15890
- if (fs35.existsSync(originalPath) && !opts.force) {
16091
+ if (fs36.existsSync(originalPath) && !opts.force) {
15891
16092
  throw new Error(`original path already occupied: ${originalPath}. Move/rename it first OR re-run with --force.`);
15892
16093
  }
15893
- if (opts.force && fs35.existsSync(originalPath)) {
15894
- fs35.unlinkSync(originalPath);
16094
+ if (opts.force && fs36.existsSync(originalPath)) {
16095
+ fs36.unlinkSync(originalPath);
15895
16096
  }
15896
- fs35.renameSync(abs, originalPath);
16097
+ fs36.renameSync(abs, originalPath);
15897
16098
  return { restoredTo: originalPath };
15898
16099
  }
15899
16100
  var SHADOW_BACKUP_BUCKETS, SHADOW_BACKUP_SUFFIX_RE;
@@ -15907,7 +16108,7 @@ var init_shadow_backup_manager = __esm({
15907
16108
  });
15908
16109
 
15909
16110
  // ../core/dist/skill-sources/doctor-checks.js
15910
- import * as fs36 from "node:fs";
16111
+ import * as fs37 from "node:fs";
15911
16112
  import * as path35 from "node:path";
15912
16113
  import * as os21 from "node:os";
15913
16114
  function claudeDirInternal3() {
@@ -15923,11 +16124,11 @@ function checkStateFileParse() {
15923
16124
  healthy: true,
15924
16125
  description: `~/.olam state file (${filePath})`
15925
16126
  };
15926
- if (!fs36.existsSync(filePath)) {
16127
+ if (!fs37.existsSync(filePath)) {
15927
16128
  result.details = ["(file does not yet exist \u2014 will be created on first write)"];
15928
16129
  return result;
15929
16130
  }
15930
- const raw = fs36.readFileSync(filePath, "utf-8");
16131
+ const raw = fs37.readFileSync(filePath, "utf-8");
15931
16132
  let parsed;
15932
16133
  try {
15933
16134
  parsed = JSON.parse(raw);
@@ -15937,8 +16138,8 @@ function checkStateFileParse() {
15937
16138
  result.details = [err instanceof Error ? err.message : String(err)];
15938
16139
  result.repair = () => {
15939
16140
  const aside = `${filePath}.corrupt-${Math.floor(Date.now() / 1e3)}`;
15940
- fs36.renameSync(filePath, aside);
15941
- fs36.writeFileSync(filePath, JSON.stringify({ schemaVersion: 1, repos: [], runbooks: [], skillSources: [] }, null, 2));
16141
+ fs37.renameSync(filePath, aside);
16142
+ fs37.writeFileSync(filePath, JSON.stringify({ schemaVersion: 1, repos: [], runbooks: [], skillSources: [] }, null, 2));
15942
16143
  };
15943
16144
  return result;
15944
16145
  }
@@ -15949,7 +16150,7 @@ function checkStateFileParse() {
15949
16150
  result.details = validation.error.issues.map((e) => `${e.path.join(".")}: ${e.message}`);
15950
16151
  result.repair = () => {
15951
16152
  const aside = `${filePath}.corrupt-${Math.floor(Date.now() / 1e3)}`;
15952
- fs36.copyFileSync(filePath, aside);
16153
+ fs37.copyFileSync(filePath, aside);
15953
16154
  const base = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
15954
16155
  const next = {
15955
16156
  ...base,
@@ -15958,7 +16159,7 @@ function checkStateFileParse() {
15958
16159
  runbooks: [],
15959
16160
  skillSources: []
15960
16161
  };
15961
- fs36.writeFileSync(filePath, JSON.stringify(next, null, 2));
16162
+ fs37.writeFileSync(filePath, JSON.stringify(next, null, 2));
15962
16163
  };
15963
16164
  return result;
15964
16165
  }
@@ -15970,15 +16171,15 @@ function checkDanglingSymlinks() {
15970
16171
  const dangling = [];
15971
16172
  for (const bucket of buckets) {
15972
16173
  const dir = path35.join(claude, bucket);
15973
- if (!fs36.existsSync(dir))
16174
+ if (!fs37.existsSync(dir))
15974
16175
  continue;
15975
- for (const name of fs36.readdirSync(dir)) {
16176
+ for (const name of fs37.readdirSync(dir)) {
15976
16177
  const linkPath = path35.join(dir, name);
15977
16178
  try {
15978
- const lst = fs36.lstatSync(linkPath);
16179
+ const lst = fs37.lstatSync(linkPath);
15979
16180
  if (!lst.isSymbolicLink())
15980
16181
  continue;
15981
- if (!fs36.existsSync(linkPath)) {
16182
+ if (!fs37.existsSync(linkPath)) {
15982
16183
  dangling.push(linkPath);
15983
16184
  }
15984
16185
  } catch {
@@ -15996,7 +16197,7 @@ function checkDanglingSymlinks() {
15996
16197
  result.repair = () => {
15997
16198
  for (const p of dangling) {
15998
16199
  try {
15999
- fs36.unlinkSync(p);
16200
+ fs37.unlinkSync(p);
16000
16201
  } catch {
16001
16202
  }
16002
16203
  }
@@ -16011,19 +16212,19 @@ function checkOrphanedSnapshots() {
16011
16212
  healthy: true,
16012
16213
  description: `orphaned migration snapshots under ${dir}`
16013
16214
  };
16014
- if (!fs36.existsSync(dir)) {
16215
+ if (!fs37.existsSync(dir)) {
16015
16216
  return result;
16016
16217
  }
16017
16218
  const orphans = [];
16018
- for (const name of fs36.readdirSync(dir)) {
16219
+ for (const name of fs37.readdirSync(dir)) {
16019
16220
  if (!name.endsWith(".json"))
16020
16221
  continue;
16021
16222
  const full = path35.join(dir, name);
16022
16223
  try {
16023
- const stat2 = fs36.statSync(full);
16224
+ const stat2 = fs37.statSync(full);
16024
16225
  if (!stat2.isFile())
16025
16226
  continue;
16026
- const raw = fs36.readFileSync(full, "utf-8");
16227
+ const raw = fs37.readFileSync(full, "utf-8");
16027
16228
  let parsed;
16028
16229
  try {
16029
16230
  parsed = JSON.parse(raw);
@@ -16048,7 +16249,7 @@ function checkOrphanedSnapshots() {
16048
16249
  result.repair = () => {
16049
16250
  for (const o of orphans) {
16050
16251
  try {
16051
- fs36.unlinkSync(o.path);
16252
+ fs37.unlinkSync(o.path);
16052
16253
  } catch {
16053
16254
  }
16054
16255
  }
@@ -16063,12 +16264,12 @@ function checkSentinelDrift() {
16063
16264
  healthy: true,
16064
16265
  description: `olam-skills sentinel block in ${filePath}`
16065
16266
  };
16066
- if (!fs36.existsSync(filePath)) {
16267
+ if (!fs37.existsSync(filePath)) {
16067
16268
  return result;
16068
16269
  }
16069
16270
  let parsed;
16070
16271
  try {
16071
- parsed = JSON.parse(fs36.readFileSync(filePath, "utf-8"));
16272
+ parsed = JSON.parse(fs37.readFileSync(filePath, "utf-8"));
16072
16273
  } catch {
16073
16274
  return result;
16074
16275
  }
@@ -16109,7 +16310,7 @@ function checkSentinelDrift() {
16109
16310
  backupSettings();
16110
16311
  } catch {
16111
16312
  }
16112
- const next = JSON.parse(fs36.readFileSync(filePath, "utf-8"));
16313
+ const next = JSON.parse(fs37.readFileSync(filePath, "utf-8"));
16113
16314
  if (!next.hooks)
16114
16315
  return;
16115
16316
  for (const stage of Object.keys(next.hooks)) {
@@ -16132,7 +16333,7 @@ function checkSentinelDrift() {
16132
16333
  return bad === void 0;
16133
16334
  });
16134
16335
  }
16135
- fs36.writeFileSync(filePath, JSON.stringify(next, null, 2) + "\n");
16336
+ fs37.writeFileSync(filePath, JSON.stringify(next, null, 2) + "\n");
16136
16337
  };
16137
16338
  }
16138
16339
  return result;
@@ -16157,7 +16358,7 @@ function checkMemberNameMissing() {
16157
16358
  }
16158
16359
  const claudeDir2 = claudeDirInternal3();
16159
16360
  const atlasUserPath = path35.join(claudeDir2, ".atlas-user");
16160
- const value = fs36.existsSync(atlasUserPath) ? fs36.readFileSync(atlasUserPath, "utf-8").trim() : "";
16361
+ const value = fs37.existsSync(atlasUserPath) ? fs37.readFileSync(atlasUserPath, "utf-8").trim() : "";
16161
16362
  if (value.length > 0) {
16162
16363
  result.details = [`atlas-user: ${value}`];
16163
16364
  return result;
@@ -16166,9 +16367,9 @@ function checkMemberNameMissing() {
16166
16367
  result.issue = "atlas-toolbox source registered but ~/.claude/.atlas-user not set";
16167
16368
  const clonePath = skillSourceClonePath(atlasSource.id);
16168
16369
  const membersDir = path35.join(clonePath, "members");
16169
- const existing = fs36.existsSync(membersDir) ? fs36.readdirSync(membersDir).filter((e) => {
16370
+ const existing = fs37.existsSync(membersDir) ? fs37.readdirSync(membersDir).filter((e) => {
16170
16371
  try {
16171
- return fs36.statSync(path35.join(membersDir, e)).isDirectory();
16372
+ return fs37.statSync(path35.join(membersDir, e)).isDirectory();
16172
16373
  } catch {
16173
16374
  return false;
16174
16375
  }
@@ -16183,7 +16384,7 @@ function checkMemberNameMissing() {
16183
16384
  function checkMemberOverlayDrift() {
16184
16385
  const claudeDir2 = claudeDirInternal3();
16185
16386
  const atlasUserPath = path35.join(claudeDir2, ".atlas-user");
16186
- const atlasUser = fs36.existsSync(atlasUserPath) ? fs36.readFileSync(atlasUserPath, "utf-8").trim() : "";
16387
+ const atlasUser = fs37.existsSync(atlasUserPath) ? fs37.readFileSync(atlasUserPath, "utf-8").trim() : "";
16187
16388
  if (atlasUser.length === 0) {
16188
16389
  return [];
16189
16390
  }
@@ -16200,11 +16401,11 @@ function checkMemberOverlayDrift() {
16200
16401
  const results = [];
16201
16402
  for (const kind of ["skills", "agents"]) {
16202
16403
  const localRoot = path35.join(claudeDir2, `${kind}.overrides`);
16203
- if (!fs36.existsSync(localRoot))
16404
+ if (!fs37.existsSync(localRoot))
16204
16405
  continue;
16205
16406
  let entries;
16206
16407
  try {
16207
- entries = fs36.readdirSync(localRoot);
16408
+ entries = fs37.readdirSync(localRoot);
16208
16409
  } catch {
16209
16410
  continue;
16210
16411
  }
@@ -16212,7 +16413,7 @@ function checkMemberOverlayDrift() {
16212
16413
  const localFile = path35.join(localRoot, entry);
16213
16414
  let stat2;
16214
16415
  try {
16215
- stat2 = fs36.statSync(localFile);
16416
+ stat2 = fs37.statSync(localFile);
16216
16417
  } catch {
16217
16418
  continue;
16218
16419
  }
@@ -23431,12 +23632,12 @@ var StdioServerTransport = class {
23431
23632
  this.onclose?.();
23432
23633
  }
23433
23634
  send(message) {
23434
- return new Promise((resolve15) => {
23635
+ return new Promise((resolve16) => {
23435
23636
  const json = serializeMessage(message);
23436
23637
  if (this._stdout.write(json)) {
23437
- resolve15();
23638
+ resolve16();
23438
23639
  } else {
23439
- this._stdout.once("drain", resolve15);
23640
+ this._stdout.once("drain", resolve16);
23440
23641
  }
23441
23642
  });
23442
23643
  }
@@ -25473,7 +25674,7 @@ var Protocol = class {
25473
25674
  return;
25474
25675
  }
25475
25676
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
25476
- await new Promise((resolve15) => setTimeout(resolve15, pollInterval));
25677
+ await new Promise((resolve16) => setTimeout(resolve16, pollInterval));
25477
25678
  options?.signal?.throwIfAborted();
25478
25679
  }
25479
25680
  } catch (error2) {
@@ -25490,7 +25691,7 @@ var Protocol = class {
25490
25691
  */
25491
25692
  request(request2, resultSchema, options) {
25492
25693
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
25493
- return new Promise((resolve15, reject2) => {
25694
+ return new Promise((resolve16, reject2) => {
25494
25695
  const earlyReject = (error2) => {
25495
25696
  reject2(error2);
25496
25697
  };
@@ -25568,7 +25769,7 @@ var Protocol = class {
25568
25769
  if (!parseResult.success) {
25569
25770
  reject2(parseResult.error);
25570
25771
  } else {
25571
- resolve15(parseResult.data);
25772
+ resolve16(parseResult.data);
25572
25773
  }
25573
25774
  } catch (error2) {
25574
25775
  reject2(error2);
@@ -25829,12 +26030,12 @@ var Protocol = class {
25829
26030
  }
25830
26031
  } catch {
25831
26032
  }
25832
- return new Promise((resolve15, reject2) => {
26033
+ return new Promise((resolve16, reject2) => {
25833
26034
  if (signal.aborted) {
25834
26035
  reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
25835
26036
  return;
25836
26037
  }
25837
- const timeoutId = setTimeout(resolve15, interval);
26038
+ const timeoutId = setTimeout(resolve16, interval);
25838
26039
  signal.addEventListener("abort", () => {
25839
26040
  clearTimeout(timeoutId);
25840
26041
  reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -27156,7 +27357,7 @@ var McpServer = class {
27156
27357
  let task = createTaskResult.task;
27157
27358
  const pollInterval = task.pollInterval ?? 5e3;
27158
27359
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
27159
- await new Promise((resolve15) => setTimeout(resolve15, pollInterval));
27360
+ await new Promise((resolve16) => setTimeout(resolve16, pollInterval));
27160
27361
  const updatedTask = await extra.taskStore.getTask(taskId);
27161
27362
  if (!updatedTask) {
27162
27363
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -28345,7 +28546,7 @@ async function safeText(res) {
28345
28546
  }
28346
28547
  }
28347
28548
  function sleep(ms) {
28348
- return new Promise((resolve15) => setTimeout(resolve15, ms));
28549
+ return new Promise((resolve16) => setTimeout(resolve16, ms));
28349
28550
  }
28350
28551
 
28351
28552
  // ../core/dist/auth/container.js
@@ -28491,7 +28692,7 @@ function resolveAuthServicePath() {
28491
28692
  return path4.join(pkgsDir, "auth-service");
28492
28693
  }
28493
28694
  function sleep2(ms) {
28494
- return new Promise((resolve15) => setTimeout(resolve15, ms));
28695
+ return new Promise((resolve16) => setTimeout(resolve16, ms));
28495
28696
  }
28496
28697
 
28497
28698
  // ../core/dist/auth/preflight.js
@@ -29307,12 +29508,12 @@ function register3(server, _ctx, _initError) {
29307
29508
  registry2.close();
29308
29509
  }
29309
29510
  try {
29310
- const { default: fs55 } = await import("node:fs");
29511
+ const { default: fs56 } = await import("node:fs");
29311
29512
  const { default: os34 } = await import("node:os");
29312
29513
  const { default: path56 } = await import("node:path");
29313
29514
  const tokenPath = path56.join(os34.homedir(), ".olam", "host-cp.token");
29314
- if (fs55.existsSync(tokenPath)) {
29315
- const token = fs55.readFileSync(tokenPath, "utf-8").trim();
29515
+ if (fs56.existsSync(tokenPath)) {
29516
+ const token = fs56.readFileSync(tokenPath, "utf-8").trim();
29316
29517
  await fetch("http://127.0.0.1:19000/api/admin/world-pr", {
29317
29518
  method: "POST",
29318
29519
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
@@ -29905,7 +30106,7 @@ var realDocker = {
29905
30106
  }
29906
30107
  };
29907
30108
  function spawnAsync(cmd, args, opts = {}) {
29908
- return new Promise((resolve15) => {
30109
+ return new Promise((resolve16) => {
29909
30110
  const child = spawn(cmd, [...args], {
29910
30111
  stdio: ["ignore", "pipe", "pipe"],
29911
30112
  signal: opts.signal
@@ -29919,10 +30120,10 @@ function spawnAsync(cmd, args, opts = {}) {
29919
30120
  stderr += chunk.toString();
29920
30121
  });
29921
30122
  child.on("error", (err) => {
29922
- resolve15({ exitCode: -1, stdout, stderr: stderr + err.message });
30123
+ resolve16({ exitCode: -1, stdout, stderr: stderr + err.message });
29923
30124
  });
29924
30125
  child.on("close", (code) => {
29925
- resolve15({ exitCode: code ?? -1, stdout, stderr });
30126
+ resolve16({ exitCode: code ?? -1, stdout, stderr });
29926
30127
  });
29927
30128
  });
29928
30129
  }
@@ -30427,7 +30628,7 @@ var stopAndRemove = async (container) => {
30427
30628
 
30428
30629
  // ../adapters/dist/docker/exec.js
30429
30630
  import { PassThrough } from "node:stream";
30430
- var demuxStream = (stream) => new Promise((resolve15, reject2) => {
30631
+ var demuxStream = (stream) => new Promise((resolve16, reject2) => {
30431
30632
  const stdoutChunks = [];
30432
30633
  const stderrChunks = [];
30433
30634
  const stdout = new PassThrough();
@@ -30441,7 +30642,7 @@ var demuxStream = (stream) => new Promise((resolve15, reject2) => {
30441
30642
  stream.pipe(stdout);
30442
30643
  }
30443
30644
  stream.on("end", () => {
30444
- resolve15({
30645
+ resolve16({
30445
30646
  stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
30446
30647
  stderr: Buffer.concat(stderrChunks).toString("utf-8")
30447
30648
  });
@@ -30814,7 +31015,7 @@ var SSHConnectionPool = class {
30814
31015
  // -----------------------------------------------------------------------
30815
31016
  async exec(host, command) {
30816
31017
  const client = await this.getConnection(host);
30817
- return new Promise((resolve15, reject2) => {
31018
+ return new Promise((resolve16, reject2) => {
30818
31019
  client.exec(command, (err, stream) => {
30819
31020
  if (err) {
30820
31021
  reject2(new Error(`SSH exec failed on ${host}: ${err.message}`));
@@ -30829,7 +31030,7 @@ var SSHConnectionPool = class {
30829
31030
  stderr += data.toString();
30830
31031
  });
30831
31032
  stream.on("close", (code) => {
30832
- resolve15({
31033
+ resolve16({
30833
31034
  exitCode: code ?? 0,
30834
31035
  stdout: stdout.trimEnd(),
30835
31036
  stderr: stderr.trimEnd()
@@ -30860,10 +31061,10 @@ var SSHConnectionPool = class {
30860
31061
  throw new Error(`No SSH configuration found for host: ${host}`);
30861
31062
  }
30862
31063
  const client = new SSHClient();
30863
- return new Promise((resolve15, reject2) => {
31064
+ return new Promise((resolve16, reject2) => {
30864
31065
  client.on("ready", () => {
30865
31066
  this.connections.set(host, client);
30866
- resolve15(client);
31067
+ resolve16(client);
30867
31068
  }).on("error", (err) => {
30868
31069
  this.connections.delete(host);
30869
31070
  reject2(new Error(`SSH connection to ${host} failed: ${err.message}`));
@@ -32049,7 +32250,7 @@ function register6(server, ctx, initError) {
32049
32250
  } catch {
32050
32251
  }
32051
32252
  await new Promise(
32052
- (resolve15) => setTimeout(resolve15, POLL_INTERVAL_MS)
32253
+ (resolve16) => setTimeout(resolve16, POLL_INTERVAL_MS)
32053
32254
  );
32054
32255
  }
32055
32256
  }
@@ -33087,7 +33288,7 @@ var GoalSpecSchema = external_exports.object({
33087
33288
  "Optional structured completion condition; when set, the world loops between turns checking this until met or timeout"
33088
33289
  );
33089
33290
  async function defaultExecGh(args) {
33090
- return new Promise((resolve15) => {
33291
+ return new Promise((resolve16) => {
33091
33292
  const child = spawn2("gh", [...args], {
33092
33293
  stdio: ["ignore", "pipe", "pipe"]
33093
33294
  });
@@ -33100,10 +33301,10 @@ async function defaultExecGh(args) {
33100
33301
  stderr += chunk.toString("utf8");
33101
33302
  });
33102
33303
  child.on("close", (code) => {
33103
- resolve15({ stdout, stderr, exitCode: code ?? 1 });
33304
+ resolve16({ stdout, stderr, exitCode: code ?? 1 });
33104
33305
  });
33105
33306
  child.on("error", (err) => {
33106
- resolve15({
33307
+ resolve16({
33107
33308
  stdout: "",
33108
33309
  stderr: err instanceof Error ? err.message : String(err),
33109
33310
  exitCode: 1
@@ -33112,7 +33313,7 @@ async function defaultExecGh(args) {
33112
33313
  });
33113
33314
  }
33114
33315
  async function defaultExecVitest(testNamePattern, cwd) {
33115
- return new Promise((resolve15) => {
33316
+ return new Promise((resolve16) => {
33116
33317
  const child = spawn2(
33117
33318
  "npx",
33118
33319
  [
@@ -33125,10 +33326,10 @@ async function defaultExecVitest(testNamePattern, cwd) {
33125
33326
  { cwd, stdio: ["ignore", "pipe", "pipe"] }
33126
33327
  );
33127
33328
  child.on("close", (code) => {
33128
- resolve15({ exitCode: code ?? 1 });
33329
+ resolve16({ exitCode: code ?? 1 });
33129
33330
  });
33130
33331
  child.on("error", () => {
33131
- resolve15({ exitCode: 1 });
33332
+ resolve16({ exitCode: 1 });
33132
33333
  });
33133
33334
  });
33134
33335
  }
@@ -34879,15 +35080,15 @@ ${JSON.stringify({ error: reason })}`
34879
35080
  unlinkSync2(udsPath);
34880
35081
  } catch {
34881
35082
  }
34882
- await new Promise((resolve15, reject2) => {
34883
- server.listen(udsPath, () => resolve15());
35083
+ await new Promise((resolve16, reject2) => {
35084
+ server.listen(udsPath, () => resolve16());
34884
35085
  server.once("error", reject2);
34885
35086
  });
34886
35087
  chmodSync5(udsPath, 384);
34887
35088
  port2 = 0;
34888
35089
  } else {
34889
- await new Promise((resolve15, reject2) => {
34890
- server.listen(opts.port ?? 0, "127.0.0.1", () => resolve15());
35090
+ await new Promise((resolve16, reject2) => {
35091
+ server.listen(opts.port ?? 0, "127.0.0.1", () => resolve16());
34891
35092
  server.once("error", reject2);
34892
35093
  });
34893
35094
  const addr = server.address();
@@ -34903,10 +35104,10 @@ ${JSON.stringify({ error: reason })}`
34903
35104
  } catch {
34904
35105
  }
34905
35106
  await Promise.race([
34906
- new Promise((resolve15, reject2) => {
34907
- server.close((err) => err ? reject2(err) : resolve15());
35107
+ new Promise((resolve16, reject2) => {
35108
+ server.close((err) => err ? reject2(err) : resolve16());
34908
35109
  }),
34909
- new Promise((resolve15) => setTimeout(resolve15, 5e3))
35110
+ new Promise((resolve16) => setTimeout(resolve16, 5e3))
34910
35111
  ]);
34911
35112
  if (udsPath) {
34912
35113
  try {
@@ -35299,10 +35500,10 @@ async function acquireLaunchSlot() {
35299
35500
  _inFlightLaunches++;
35300
35501
  return releaseLaunchSlot;
35301
35502
  }
35302
- return new Promise((resolve15) => {
35503
+ return new Promise((resolve16) => {
35303
35504
  _launchQueue.push(() => {
35304
35505
  _inFlightLaunches++;
35305
- resolve15(releaseLaunchSlot);
35506
+ resolve16(releaseLaunchSlot);
35306
35507
  });
35307
35508
  });
35308
35509
  }
@@ -36107,12 +36308,12 @@ function openUrl(url2) {
36107
36308
  var HOST_CP_URL = "http://127.0.0.1:19000";
36108
36309
  async function readHostCpToken2() {
36109
36310
  try {
36110
- const { default: fs55 } = await import("node:fs");
36311
+ const { default: fs56 } = await import("node:fs");
36111
36312
  const { default: os34 } = await import("node:os");
36112
36313
  const { default: path56 } = await import("node:path");
36113
36314
  const tp = path56.join(os34.homedir(), ".olam", "host-cp.token");
36114
- if (!fs55.existsSync(tp)) return { token: null };
36115
- return { token: fs55.readFileSync(tp, "utf-8").trim() };
36315
+ if (!fs56.existsSync(tp)) return { token: null };
36316
+ return { token: fs56.readFileSync(tp, "utf-8").trim() };
36116
36317
  } catch {
36117
36318
  return { token: null };
36118
36319
  }
@@ -36453,7 +36654,7 @@ __export(process_port_exports, {
36453
36654
  register: () => register23,
36454
36655
  resolveHostCpToken: () => resolveHostCpToken
36455
36656
  });
36456
- import fs37 from "node:fs";
36657
+ import fs38 from "node:fs";
36457
36658
  import os22 from "node:os";
36458
36659
  import path36 from "node:path";
36459
36660
 
@@ -36501,7 +36702,7 @@ function resolveHostCpToken() {
36501
36702
  const envToken = process.env["OLAM_HOST_CP_TOKEN"];
36502
36703
  if (envToken) return envToken;
36503
36704
  const tokenPath = path36.join(os22.homedir(), ".olam", "host-cp.token");
36504
- if (fs37.existsSync(tokenPath)) return fs37.readFileSync(tokenPath, "utf-8").trim();
36705
+ if (fs38.existsSync(tokenPath)) return fs38.readFileSync(tokenPath, "utf-8").trim();
36505
36706
  return null;
36506
36707
  }
36507
36708
  function tokenMissingError() {
@@ -36974,7 +37175,7 @@ __export(skills_exports, {
36974
37175
  register: () => register26
36975
37176
  });
36976
37177
  init_skill_sources();
36977
- import * as fs38 from "node:fs";
37178
+ import * as fs39 from "node:fs";
36978
37179
  import * as path37 from "node:path";
36979
37180
 
36980
37181
  // ../skill-runtime/dist/skills/skills-sync.js
@@ -37055,13 +37256,13 @@ function listDeployed() {
37055
37256
  const entries = [];
37056
37257
  for (const bucket of ["skills", "agents", "scripts", "rules", "commands"]) {
37057
37258
  const bucketDir = path37.join(dir, bucket);
37058
- if (!fs38.existsSync(bucketDir)) continue;
37059
- for (const name of fs38.readdirSync(bucketDir)) {
37259
+ if (!fs39.existsSync(bucketDir)) continue;
37260
+ for (const name of fs39.readdirSync(bucketDir)) {
37060
37261
  const full = path37.join(bucketDir, name);
37061
37262
  try {
37062
- const stat2 = fs38.lstatSync(full);
37263
+ const stat2 = fs39.lstatSync(full);
37063
37264
  if (!stat2.isSymbolicLink()) continue;
37064
- const target = fs38.readlinkSync(full);
37265
+ const target = fs39.readlinkSync(full);
37065
37266
  let sourceId;
37066
37267
  for (const [clonePath, id] of sourcePaths.entries()) {
37067
37268
  if (target.startsWith(clonePath)) {
@@ -37124,7 +37325,7 @@ import * as os24 from "node:os";
37124
37325
 
37125
37326
  // ../mcp-server/src/lib/skills-index.mjs
37126
37327
  import { createRequire as createRequire5 } from "node:module";
37127
- import * as fs39 from "node:fs";
37328
+ import * as fs40 from "node:fs";
37128
37329
  import * as path38 from "node:path";
37129
37330
  import * as os23 from "node:os";
37130
37331
  var VECTOR_DIM = 256;
@@ -37215,7 +37416,7 @@ function bufferToVector(buf) {
37215
37416
  return vec;
37216
37417
  }
37217
37418
  function openIndex(dbPath) {
37218
- if (!fs39.existsSync(dbPath)) {
37419
+ if (!fs40.existsSync(dbPath)) {
37219
37420
  throw new Error(
37220
37421
  `skills index not found at ${dbPath}. Run \`node scripts/skills-index-build.mjs --out ${dbPath}\` first.`
37221
37422
  );
@@ -37549,7 +37750,7 @@ __export(kg_install_hook_exports, {
37549
37750
  register: () => register30
37550
37751
  });
37551
37752
  init_merge_settings();
37552
- import * as fs40 from "node:fs";
37753
+ import * as fs41 from "node:fs";
37553
37754
  import * as path40 from "node:path";
37554
37755
  import * as os25 from "node:os";
37555
37756
 
@@ -37641,12 +37842,12 @@ function register30(server, _ctx, _initError) {
37641
37842
  const scope = params.scope === "user" ? "user" : "project";
37642
37843
  const filePath = settingsPathFor2(scope, params.projectPath);
37643
37844
  try {
37644
- fs40.mkdirSync(path40.dirname(filePath), { recursive: true });
37845
+ fs41.mkdirSync(path40.dirname(filePath), { recursive: true });
37645
37846
  let backupPath = null;
37646
- if (fs40.existsSync(filePath)) {
37847
+ if (fs41.existsSync(filePath)) {
37647
37848
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
37648
37849
  backupPath = `${filePath}.olam-bak.${ts}`;
37649
- fs40.copyFileSync(filePath, backupPath);
37850
+ fs41.copyFileSync(filePath, backupPath);
37650
37851
  }
37651
37852
  const result = mergeHomeSettingsJson(filePath, {
37652
37853
  ensureHook: {
@@ -37657,7 +37858,7 @@ function register30(server, _ctx, _initError) {
37657
37858
  });
37658
37859
  if (result.status === "already-present" && backupPath) {
37659
37860
  try {
37660
- fs40.unlinkSync(backupPath);
37861
+ fs41.unlinkSync(backupPath);
37661
37862
  } catch {
37662
37863
  }
37663
37864
  }
@@ -37699,7 +37900,7 @@ var kg_uninstall_hook_exports = {};
37699
37900
  __export(kg_uninstall_hook_exports, {
37700
37901
  register: () => register31
37701
37902
  });
37702
- import * as fs41 from "node:fs";
37903
+ import * as fs42 from "node:fs";
37703
37904
  import * as path41 from "node:path";
37704
37905
  import * as os26 from "node:os";
37705
37906
 
@@ -37753,7 +37954,7 @@ function register31(server, _ctx, _initError) {
37753
37954
  const scope = params.scope === "user" ? "user" : "project";
37754
37955
  const filePath = settingsPathFor3(scope, params.projectPath);
37755
37956
  try {
37756
- if (!fs41.existsSync(filePath)) {
37957
+ if (!fs42.existsSync(filePath)) {
37757
37958
  return {
37758
37959
  content: [
37759
37960
  {
@@ -37767,7 +37968,7 @@ function register31(server, _ctx, _initError) {
37767
37968
  ]
37768
37969
  };
37769
37970
  }
37770
- const raw = fs41.readFileSync(filePath, "utf-8");
37971
+ const raw = fs42.readFileSync(filePath, "utf-8");
37771
37972
  const settings = raw.trim() ? JSON.parse(raw) : {};
37772
37973
  const preToolUse = settings.hooks?.PreToolUse;
37773
37974
  if (!Array.isArray(preToolUse) || preToolUse.length === 0) {
@@ -37802,7 +38003,7 @@ function register31(server, _ctx, _initError) {
37802
38003
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
37803
38004
  const backupPath = `${filePath}.olam-bak.${ts}`;
37804
38005
  try {
37805
- fs41.copyFileSync(filePath, backupPath);
38006
+ fs42.copyFileSync(filePath, backupPath);
37806
38007
  } catch {
37807
38008
  }
37808
38009
  const next = {
@@ -37814,7 +38015,7 @@ function register31(server, _ctx, _initError) {
37814
38015
  if (otherStages.length === 0) delete next.hooks;
37815
38016
  else delete next.hooks.PreToolUse;
37816
38017
  }
37817
- fs41.writeFileSync(filePath, JSON.stringify(next, null, 2) + "\n");
38018
+ fs42.writeFileSync(filePath, JSON.stringify(next, null, 2) + "\n");
37818
38019
  return {
37819
38020
  content: [
37820
38021
  {
@@ -38200,7 +38401,7 @@ ${BOUNDARY_CLOSE}`
38200
38401
  }
38201
38402
 
38202
38403
  // ../mcp-server/src/resources/chunks.ts
38203
- import fs42 from "node:fs";
38404
+ import fs43 from "node:fs";
38204
38405
  import os27 from "node:os";
38205
38406
  import path42 from "node:path";
38206
38407
  var DEFAULT_HOST_CP_URL = "http://127.0.0.1:19000";
@@ -38219,7 +38420,7 @@ function loadBearer(bearerOpt, secretPath) {
38219
38420
  const envBearer = process.env.OLAM_PLAN_CHAT_BEARER?.trim();
38220
38421
  if (envBearer && envBearer.length > 0) return envBearer;
38221
38422
  try {
38222
- const onDisk = fs42.readFileSync(secretPath, "utf8").trim();
38423
+ const onDisk = fs43.readFileSync(secretPath, "utf8").trim();
38223
38424
  return onDisk.length > 0 ? onDisk : null;
38224
38425
  } catch (err) {
38225
38426
  if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
@@ -39506,7 +39707,7 @@ init_loader();
39506
39707
  // ../core/dist/world/manager.js
39507
39708
  import * as crypto8 from "node:crypto";
39508
39709
  import { execSync as execSync6, spawnSync as spawnSync4 } from "node:child_process";
39509
- import * as fs52 from "node:fs";
39710
+ import * as fs53 from "node:fs";
39510
39711
  import * as os32 from "node:os";
39511
39712
  import * as path53 from "node:path";
39512
39713
 
@@ -39604,7 +39805,7 @@ function resolveDevboxImage(config2, tag) {
39604
39805
 
39605
39806
  // ../core/dist/world/worktree.js
39606
39807
  import { execFileSync as execFileSync4 } from "node:child_process";
39607
- import * as fs43 from "node:fs";
39808
+ import * as fs44 from "node:fs";
39608
39809
  import * as path43 from "node:path";
39609
39810
  function resolveGitDir(repo) {
39610
39811
  if (repo.path) {
@@ -39619,7 +39820,7 @@ async function createWorktrees(repos, worldId, workspacePath, branch) {
39619
39820
  const gitDir = resolveGitDir(repo);
39620
39821
  const branchName = branch || `olam/${worldId}`;
39621
39822
  try {
39622
- fs43.mkdirSync(path43.dirname(worktreePath), { recursive: true });
39823
+ fs44.mkdirSync(path43.dirname(worktreePath), { recursive: true });
39623
39824
  execFileSync4("git", ["worktree", "add", worktreePath, "-b", branchName], {
39624
39825
  cwd: gitDir,
39625
39826
  stdio: "pipe"
@@ -39727,12 +39928,12 @@ function removeBranch(repo, branch) {
39727
39928
 
39728
39929
  // ../core/dist/world/kg-overlay.js
39729
39930
  import { execFileSync as execFileSync5 } from "node:child_process";
39730
- import * as fs44 from "node:fs";
39931
+ import * as fs45 from "node:fs";
39731
39932
  import * as path44 from "node:path";
39732
39933
 
39733
39934
  // ../core/dist/kg/storage-paths.js
39734
- import { homedir as homedir25 } from "node:os";
39735
- import { join as join42, resolve as resolve10 } from "node:path";
39935
+ import { homedir as homedir26 } from "node:os";
39936
+ import { join as join43, resolve as resolve11 } from "node:path";
39736
39937
 
39737
39938
  // ../core/dist/world/workspace-name.js
39738
39939
  var InvalidWorkspaceNameError = class extends Error {
@@ -39753,13 +39954,13 @@ function validateWorkspaceName(name) {
39753
39954
 
39754
39955
  // ../core/dist/kg/storage-paths.js
39755
39956
  function olamHome2() {
39756
- return process.env.OLAM_HOME ?? join42(homedir25(), ".olam");
39957
+ return process.env.OLAM_HOME ?? join43(homedir26(), ".olam");
39757
39958
  }
39758
39959
  function kgRoot() {
39759
- return join42(olamHome2(), "kg");
39960
+ return join43(olamHome2(), "kg");
39760
39961
  }
39761
39962
  function worldsRoot() {
39762
- return join42(olamHome2(), "worlds");
39963
+ return join43(olamHome2(), "worlds");
39763
39964
  }
39764
39965
  function assertWithinPrefix(path56, prefix, label) {
39765
39966
  if (!path56.startsWith(prefix + "/")) {
@@ -39769,7 +39970,7 @@ function assertWithinPrefix(path56, prefix, label) {
39769
39970
  function kgPristinePath(workspace) {
39770
39971
  validateWorkspaceName(workspace);
39771
39972
  const root = kgRoot();
39772
- const path56 = resolve10(join42(root, workspace));
39973
+ const path56 = resolve11(join43(root, workspace));
39773
39974
  assertWithinPrefix(path56, root, "kgPristinePath");
39774
39975
  return path56;
39775
39976
  }
@@ -39788,9 +39989,9 @@ var KgOverlayError = class extends Error {
39788
39989
  };
39789
39990
  function ensureGitignoreEntry(worldClonePath) {
39790
39991
  const gitignorePath = path44.join(worldClonePath, ".gitignore");
39791
- if (!fs44.existsSync(gitignorePath))
39992
+ if (!fs45.existsSync(gitignorePath))
39792
39993
  return "no-gitignore";
39793
- const content = fs44.readFileSync(gitignorePath, "utf-8");
39994
+ const content = fs45.readFileSync(gitignorePath, "utf-8");
39794
39995
  const lines = content.split("\n").map((l) => l.trim());
39795
39996
  const recognised = /* @__PURE__ */ new Set([
39796
39997
  "graphify-out",
@@ -39805,24 +40006,24 @@ function ensureGitignoreEntry(worldClonePath) {
39805
40006
  const eol = content.includes("\r\n") ? "\r\n" : "\n";
39806
40007
  const needsLeadingNewline = content.length > 0 && !content.endsWith(eol);
39807
40008
  const block = `${needsLeadingNewline ? eol : ""}${eol}# olam-kg-service: per-world KG overlay (Phase B1)${eol}graphify-out/${eol}`;
39808
- fs44.appendFileSync(gitignorePath, block, "utf-8");
40009
+ fs45.appendFileSync(gitignorePath, block, "utf-8");
39809
40010
  return "appended";
39810
40011
  }
39811
40012
  function createWorldOverlay(opts) {
39812
40013
  const pristineRoot = kgPristinePath(opts.workspace);
39813
40014
  const pristinePath = path44.join(pristineRoot, "graphify-out");
39814
- if (!fs44.existsSync(pristinePath)) {
40015
+ if (!fs45.existsSync(pristinePath)) {
39815
40016
  throw new KgOverlayError(`Pristine KG for workspace ${JSON.stringify(opts.workspace)} not found at ${pristinePath}. Run \`olam kg build ${opts.workspace}\` first.`);
39816
40017
  }
39817
40018
  if (!path44.isAbsolute(opts.worldClonePath)) {
39818
40019
  throw new KgOverlayError(`worldClonePath must be absolute (got ${opts.worldClonePath})`);
39819
40020
  }
39820
- if (!fs44.existsSync(opts.worldClonePath)) {
40021
+ if (!fs45.existsSync(opts.worldClonePath)) {
39821
40022
  throw new KgOverlayError(`worldClonePath does not exist: ${opts.worldClonePath}. Create the clone before reflinking.`);
39822
40023
  }
39823
40024
  const overlayPath = path44.join(opts.worldClonePath, "graphify-out");
39824
- if (fs44.existsSync(overlayPath)) {
39825
- fs44.rmSync(overlayPath, { recursive: true, force: true });
40025
+ if (fs45.existsSync(overlayPath)) {
40026
+ fs45.rmSync(overlayPath, { recursive: true, force: true });
39826
40027
  }
39827
40028
  const useReflink = process.platform === "darwin";
39828
40029
  let strategy;
@@ -39840,7 +40041,7 @@ function createWorldOverlay(opts) {
39840
40041
  } else {
39841
40042
  strategy = "cp-r";
39842
40043
  }
39843
- if (strategy === "cp-r" || !fs44.existsSync(overlayPath)) {
40044
+ if (strategy === "cp-r" || !fs45.existsSync(overlayPath)) {
39844
40045
  try {
39845
40046
  execFileSync5("cp", ["-r", pristinePath, opts.worldClonePath], {
39846
40047
  stdio: ["ignore", "ignore", "pipe"]
@@ -39852,7 +40053,7 @@ function createWorldOverlay(opts) {
39852
40053
  throw new KgOverlayError(`cp -r failed: ${msg}${reflinkMsg}`);
39853
40054
  }
39854
40055
  }
39855
- if (!fs44.existsSync(overlayPath)) {
40056
+ if (!fs45.existsSync(overlayPath)) {
39856
40057
  throw new KgOverlayError(`Overlay creation produced no ${overlayPath} after cp \u2014 filesystem returned without error?`);
39857
40058
  }
39858
40059
  const gitignoreAction = ensureGitignoreEntry(opts.worldClonePath);
@@ -39866,12 +40067,12 @@ function createWorldOverlay(opts) {
39866
40067
 
39867
40068
  // ../core/dist/world/baseline-diff.js
39868
40069
  import { execFileSync as execFileSync6 } from "node:child_process";
39869
- import * as fs45 from "node:fs";
40070
+ import * as fs46 from "node:fs";
39870
40071
  import * as os28 from "node:os";
39871
40072
  import * as path45 from "node:path";
39872
40073
  var DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
39873
- function expandHome2(p, homedir32) {
39874
- return p.replace(/^~(?=$|\/|\\)/, homedir32());
40074
+ function expandHome2(p, homedir33) {
40075
+ return p.replace(/^~(?=$|\/|\\)/, homedir33());
39875
40076
  }
39876
40077
  function sanitizeRepoFilename(name) {
39877
40078
  const sanitized = name.replace(/[^A-Za-z0-9._-]/g, "_");
@@ -39894,10 +40095,10 @@ ${stderr}`;
39894
40095
  }
39895
40096
  function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
39896
40097
  const exec = deps.exec ?? ((cmd, args, opts) => execFileSync6(cmd, args, opts));
39897
- const homedir32 = deps.homedir ?? (() => os28.homedir());
40098
+ const homedir33 = deps.homedir ?? (() => os28.homedir());
39898
40099
  const baselineDir = path45.join(workspacePath, ".olam", "baseline");
39899
40100
  try {
39900
- fs45.mkdirSync(baselineDir, { recursive: true });
40101
+ fs46.mkdirSync(baselineDir, { recursive: true });
39901
40102
  } catch (err) {
39902
40103
  const msg = err instanceof Error ? err.message : String(err);
39903
40104
  console.warn(`[baseline-diff] mkdir ${baselineDir} failed: ${msg}; reaper will see no baseline at all`);
@@ -39910,8 +40111,8 @@ function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
39910
40111
  continue;
39911
40112
  const filename = `${sanitizeRepoFilename(repo.name)}.diff`;
39912
40113
  const outPath = path45.join(baselineDir, filename);
39913
- const repoPath = expandHome2(repo.path, homedir32);
39914
- if (!fs45.existsSync(repoPath)) {
40114
+ const repoPath = expandHome2(repo.path, homedir33);
40115
+ if (!fs46.existsSync(repoPath)) {
39915
40116
  writeBaselineFile(outPath, `# repo: ${repo.name}
39916
40117
  # (skipped: path ${repoPath} does not exist)
39917
40118
  `);
@@ -39978,7 +40179,7 @@ function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
39978
40179
  }
39979
40180
  function writeBaselineFile(outPath, content) {
39980
40181
  try {
39981
- fs45.writeFileSync(outPath, content);
40182
+ fs46.writeFileSync(outPath, content);
39982
40183
  } catch (err) {
39983
40184
  const msg = err instanceof Error ? err.message : String(err);
39984
40185
  console.warn(`[baseline-diff] write to ${outPath} failed: ${msg}`);
@@ -39987,7 +40188,7 @@ function writeBaselineFile(outPath, content) {
39987
40188
  function stripWorktreeEdits(repos, workspacePath) {
39988
40189
  for (const repo of repos) {
39989
40190
  const worktreePath = path45.join(workspacePath, repo.name);
39990
- if (!fs45.existsSync(worktreePath))
40191
+ if (!fs46.existsSync(worktreePath))
39991
40192
  continue;
39992
40193
  try {
39993
40194
  execFileSync6("git", ["checkout", "--", "."], {
@@ -40046,21 +40247,21 @@ function extractStderr(err) {
40046
40247
  }
40047
40248
  function carryUncommittedEdits(repos, workspacePath, deps = {}) {
40048
40249
  const exec = deps.exec ?? ((cmd, args, opts) => execFileSync6(cmd, args, opts));
40049
- const homedir32 = deps.homedir ?? (() => os28.homedir());
40050
- const existsSync51 = deps.existsSync ?? ((p) => fs45.existsSync(p));
40051
- const copyFileSync9 = deps.copyFileSync ?? ((src, dest) => fs45.copyFileSync(src, dest));
40052
- const mkdirSync31 = deps.mkdirSync ?? ((dirPath, opts) => {
40053
- fs45.mkdirSync(dirPath, opts);
40250
+ const homedir33 = deps.homedir ?? (() => os28.homedir());
40251
+ const existsSync53 = deps.existsSync ?? ((p) => fs46.existsSync(p));
40252
+ const copyFileSync9 = deps.copyFileSync ?? ((src, dest) => fs46.copyFileSync(src, dest));
40253
+ const mkdirSync32 = deps.mkdirSync ?? ((dirPath, opts) => {
40254
+ fs46.mkdirSync(dirPath, opts);
40054
40255
  });
40055
40256
  const plans = [];
40056
40257
  for (const repo of repos) {
40057
40258
  if (!repo.path)
40058
40259
  continue;
40059
- const repoPath = expandHome2(repo.path, homedir32);
40260
+ const repoPath = expandHome2(repo.path, homedir33);
40060
40261
  const worktreePath = path45.join(workspacePath, repo.name);
40061
- if (!existsSync51(repoPath))
40262
+ if (!existsSync53(repoPath))
40062
40263
  continue;
40063
- if (!existsSync51(worktreePath)) {
40264
+ if (!existsSync53(worktreePath)) {
40064
40265
  console.warn(`[carry] ${repo.name}: world worktree ${worktreePath} missing; skipping carry for this repo`);
40065
40266
  continue;
40066
40267
  }
@@ -40120,10 +40321,10 @@ function carryUncommittedEdits(repos, workspacePath, deps = {}) {
40120
40321
  for (const rel of plan.diff.untracked) {
40121
40322
  const src = path45.join(plan.repoPath, rel);
40122
40323
  const dest = path45.join(plan.worktreePath, rel);
40123
- if (!existsSync51(src))
40324
+ if (!existsSync53(src))
40124
40325
  continue;
40125
40326
  try {
40126
- mkdirSync31(path45.dirname(dest), { recursive: true });
40327
+ mkdirSync32(path45.dirname(dest), { recursive: true });
40127
40328
  copyFileSync9(src, dest);
40128
40329
  } catch (err) {
40129
40330
  const msg = err instanceof Error ? err.message : String(err);
@@ -40149,7 +40350,7 @@ function formatBaselineSummary(result) {
40149
40350
  }
40150
40351
 
40151
40352
  // ../core/dist/world/context-injection.js
40152
- import * as fs46 from "node:fs";
40353
+ import * as fs47 from "node:fs";
40153
40354
  import * as path46 from "node:path";
40154
40355
 
40155
40356
  // ../core/dist/world/templates/_generated.js
@@ -40161,9 +40362,9 @@ var WORLD_CLAUDE_MD = '# Olam World: {{worldName}}\n\n{{taskBlock}}\n\n## Enviro
40161
40362
  function injectWorldContext(opts) {
40162
40363
  const { world } = opts;
40163
40364
  const claudeDir2 = path46.join(world.workspacePath, ".claude");
40164
- fs46.mkdirSync(claudeDir2, { recursive: true });
40365
+ fs47.mkdirSync(claudeDir2, { recursive: true });
40165
40366
  const content = WORLD_CLAUDE_MD.replace("{{worldName}}", world.name).replace("{{worldId}}", world.id).replace("{{branch}}", world.branch).replace("{{taskBlock}}", buildTaskBlock(opts)).replace("{{reposList}}", buildReposList(world)).replace("{{servicesLine}}", buildServicesLine(opts.services)).replace("{{pleriPlaneLine}}", buildPleriPlaneLine(opts.pleriPlaneUrl)).replace("{{planFileBlock}}", buildPlanFileBlock(world)).replace("{{extraContextBlock}}", buildExtraContextBlock(opts.claudeMdExtra));
40166
- fs46.writeFileSync(path46.join(claudeDir2, "CLAUDE.md"), content);
40367
+ fs47.writeFileSync(path46.join(claudeDir2, "CLAUDE.md"), content);
40167
40368
  writeOlamDocs(world.workspacePath);
40168
40369
  }
40169
40370
  function buildTaskBlock(opts) {
@@ -40238,9 +40439,9 @@ ${extra}`;
40238
40439
  }
40239
40440
  function writeOlamDocs(workspacePath) {
40240
40441
  const docsDir = path46.join(workspacePath, ".olam", "docs");
40241
- fs46.mkdirSync(docsDir, { recursive: true });
40242
- fs46.writeFileSync(path46.join(docsDir, "gh-pr-create.md"), GH_PR_CREATE);
40243
- fs46.writeFileSync(path46.join(docsDir, "lane-orchestration.md"), LANE_ORCHESTRATION);
40442
+ fs47.mkdirSync(docsDir, { recursive: true });
40443
+ fs47.writeFileSync(path46.join(docsDir, "gh-pr-create.md"), GH_PR_CREATE);
40444
+ fs47.writeFileSync(path46.join(docsDir, "lane-orchestration.md"), LANE_ORCHESTRATION);
40244
40445
  }
40245
40446
  function formatTaskSource(ctx) {
40246
40447
  if (ctx.source === "linear" && ctx.ticketId) {
@@ -40256,7 +40457,7 @@ function hasPlanFile(world) {
40256
40457
  return false;
40257
40458
  const plansDir = path46.join(world.workspacePath, world.repos[0], "docs", "plans");
40258
40459
  try {
40259
- return fs46.existsSync(plansDir) && fs46.readdirSync(plansDir).length > 0;
40460
+ return fs47.existsSync(plansDir) && fs47.readdirSync(plansDir).length > 0;
40260
40461
  } catch {
40261
40462
  return false;
40262
40463
  }
@@ -40828,7 +41029,7 @@ init_repo_manifest();
40828
41029
 
40829
41030
  // ../core/dist/world/snapshot.js
40830
41031
  import * as crypto7 from "node:crypto";
40831
- import * as fs47 from "node:fs";
41032
+ import * as fs48 from "node:fs";
40832
41033
  import * as os29 from "node:os";
40833
41034
  import * as path47 from "node:path";
40834
41035
  import { execFileSync as execFileSync7, spawn as spawn3 } from "node:child_process";
@@ -40843,10 +41044,10 @@ function cleanupLegacyByWorldDir(worldId) {
40843
41044
  const legacyDir = path47.join(snapshotsDir(), worldId);
40844
41045
  if (worldId === "by-workspace")
40845
41046
  return;
40846
- if (!fs47.existsSync(legacyDir))
41047
+ if (!fs48.existsSync(legacyDir))
40847
41048
  return;
40848
41049
  try {
40849
- fs47.rmSync(legacyDir, { recursive: true, force: true });
41050
+ fs48.rmSync(legacyDir, { recursive: true, force: true });
40850
41051
  } catch {
40851
41052
  }
40852
41053
  }
@@ -40866,10 +41067,10 @@ function hashBuffers(entries) {
40866
41067
  }
40867
41068
  function computeGemsFingerprint(repoDir, imageDigest) {
40868
41069
  const lockfile = path47.join(repoDir, "Gemfile.lock");
40869
- if (!fs47.existsSync(lockfile))
41070
+ if (!fs48.existsSync(lockfile))
40870
41071
  return null;
40871
41072
  const entries = [
40872
- { path: "Gemfile.lock", content: fs47.readFileSync(lockfile) }
41073
+ { path: "Gemfile.lock", content: fs48.readFileSync(lockfile) }
40873
41074
  ];
40874
41075
  if (imageDigest) {
40875
41076
  entries.push({ path: "__image_digest__", content: Buffer.from(imageDigest, "utf-8") });
@@ -40880,9 +41081,9 @@ function computeNodeFingerprint(repoDir, imageDigest) {
40880
41081
  const candidates = ["yarn.lock", "pnpm-lock.yaml", "package-lock.json"];
40881
41082
  for (const name of candidates) {
40882
41083
  const lockfile = path47.join(repoDir, name);
40883
- if (fs47.existsSync(lockfile)) {
41084
+ if (fs48.existsSync(lockfile)) {
40884
41085
  const entries = [
40885
- { path: name, content: fs47.readFileSync(lockfile) }
41086
+ { path: name, content: fs48.readFileSync(lockfile) }
40886
41087
  ];
40887
41088
  if (imageDigest) {
40888
41089
  entries.push({ path: "__image_digest__", content: Buffer.from(imageDigest, "utf-8") });
@@ -40902,17 +41103,17 @@ function unpackTarballAtomic(srcPath, destDir) {
40902
41103
  };
40903
41104
  }
40904
41105
  const parent = path47.dirname(destDir);
40905
- fs47.mkdirSync(parent, { recursive: true });
41106
+ fs48.mkdirSync(parent, { recursive: true });
40906
41107
  const tmpSuffix = `.tmp-${process.pid}-${crypto7.randomBytes(4).toString("hex")}`;
40907
41108
  const tmpDir = `${destDir}${tmpSuffix}`;
40908
41109
  try {
40909
- fs47.mkdirSync(tmpDir, { recursive: true });
41110
+ fs48.mkdirSync(tmpDir, { recursive: true });
40910
41111
  execFileSync7("tar", ["-xzf", srcPath, "-C", tmpDir], { stdio: "pipe" });
40911
- fs47.renameSync(tmpDir, destDir);
41112
+ fs48.renameSync(tmpDir, destDir);
40912
41113
  return { ok: true, entryCount: validation.entries.length };
40913
41114
  } catch (err) {
40914
41115
  try {
40915
- fs47.rmSync(tmpDir, { recursive: true, force: true });
41116
+ fs48.rmSync(tmpDir, { recursive: true, force: true });
40916
41117
  } catch {
40917
41118
  }
40918
41119
  return {
@@ -40978,7 +41179,7 @@ function parseTarListLine(line) {
40978
41179
  function validateHardlinksBinary(tarPath, targetDir) {
40979
41180
  let raw;
40980
41181
  try {
40981
- raw = gunzipSync(fs47.readFileSync(tarPath));
41182
+ raw = gunzipSync(fs48.readFileSync(tarPath));
40982
41183
  } catch {
40983
41184
  return null;
40984
41185
  }
@@ -41084,7 +41285,7 @@ function restoreSnapshotsForRepos(input) {
41084
41285
  const archDir = snapshotKindDirByWorkspace(input.workspace, input.arch, kind);
41085
41286
  const tarFilename = `${repo.name}-${input.arch}-${fingerprint}.tar.gz`;
41086
41287
  const tarPath = path47.join(archDir, tarFilename);
41087
- if (!fs47.existsSync(tarPath)) {
41288
+ if (!fs48.existsSync(tarPath)) {
41088
41289
  outcomes.push({ repo: repo.name, kind, outcome: "miss", reason: "no-tarball", fingerprint });
41089
41290
  continue;
41090
41291
  }
@@ -41101,7 +41302,7 @@ function restoreSnapshotsForRepos(input) {
41101
41302
  }
41102
41303
  const targetDir = path47.join(repo.worktreeDir, targetSubpath);
41103
41304
  try {
41104
- fs47.rmSync(targetDir, { recursive: true, force: true });
41305
+ fs48.rmSync(targetDir, { recursive: true, force: true });
41105
41306
  } catch {
41106
41307
  }
41107
41308
  const result = unpackTarballAtomic(tarPath, targetDir);
@@ -41114,8 +41315,8 @@ function restoreSnapshotsForRepos(input) {
41114
41315
  fingerprint
41115
41316
  });
41116
41317
  try {
41117
- fs47.rmSync(tarPath, { force: true });
41118
- fs47.rmSync(manifestPath(tarPath), { force: true });
41318
+ fs48.rmSync(tarPath, { force: true });
41319
+ fs48.rmSync(manifestPath(tarPath), { force: true });
41119
41320
  } catch {
41120
41321
  }
41121
41322
  continue;
@@ -41131,10 +41332,10 @@ function restoreSnapshotsForRepos(input) {
41131
41332
  }
41132
41333
  function readManifest(tarPath) {
41133
41334
  const mPath = manifestPath(tarPath);
41134
- if (!fs47.existsSync(mPath))
41335
+ if (!fs48.existsSync(mPath))
41135
41336
  return null;
41136
41337
  try {
41137
- return JSON.parse(fs47.readFileSync(mPath, "utf-8"));
41338
+ return JSON.parse(fs48.readFileSync(mPath, "utf-8"));
41138
41339
  } catch {
41139
41340
  return null;
41140
41341
  }
@@ -41149,17 +41350,17 @@ function isPidAlive(pid) {
41149
41350
  }
41150
41351
  }
41151
41352
  function evictOldSnapshotsWithFlock(maxBytes, dir = snapshotsDir()) {
41152
- fs47.mkdirSync(dir, { recursive: true });
41353
+ fs48.mkdirSync(dir, { recursive: true });
41153
41354
  const lockPath = path47.join(dir, EVICT_LOCK_FILENAME);
41154
41355
  let fd;
41155
41356
  try {
41156
- fd = fs47.openSync(lockPath, fs47.constants.O_WRONLY | fs47.constants.O_CREAT | fs47.constants.O_EXCL, 384);
41357
+ fd = fs48.openSync(lockPath, fs48.constants.O_WRONLY | fs48.constants.O_CREAT | fs48.constants.O_EXCL, 384);
41157
41358
  } catch (err) {
41158
41359
  if (err.code !== "EEXIST")
41159
41360
  return 0;
41160
41361
  let holderPid = null;
41161
41362
  try {
41162
- holderPid = parseInt(fs47.readFileSync(lockPath, "utf-8").trim(), 10);
41363
+ holderPid = parseInt(fs48.readFileSync(lockPath, "utf-8").trim(), 10);
41163
41364
  } catch {
41164
41365
  holderPid = null;
41165
41366
  }
@@ -41167,23 +41368,23 @@ function evictOldSnapshotsWithFlock(maxBytes, dir = snapshotsDir()) {
41167
41368
  return 0;
41168
41369
  }
41169
41370
  try {
41170
- fs47.unlinkSync(lockPath);
41171
- fd = fs47.openSync(lockPath, fs47.constants.O_WRONLY | fs47.constants.O_CREAT | fs47.constants.O_EXCL, 384);
41371
+ fs48.unlinkSync(lockPath);
41372
+ fd = fs48.openSync(lockPath, fs48.constants.O_WRONLY | fs48.constants.O_CREAT | fs48.constants.O_EXCL, 384);
41172
41373
  } catch {
41173
41374
  return 0;
41174
41375
  }
41175
41376
  }
41176
41377
  try {
41177
- fs47.writeSync(fd, `${process.pid}
41378
+ fs48.writeSync(fd, `${process.pid}
41178
41379
  `);
41179
41380
  } finally {
41180
- fs47.closeSync(fd);
41381
+ fs48.closeSync(fd);
41181
41382
  }
41182
41383
  try {
41183
41384
  return evictOldSnapshots(maxBytes, dir);
41184
41385
  } finally {
41185
41386
  try {
41186
- fs47.unlinkSync(lockPath);
41387
+ fs48.unlinkSync(lockPath);
41187
41388
  } catch {
41188
41389
  }
41189
41390
  }
@@ -41216,16 +41417,16 @@ function spawnAutoCapture(worldId, olamBin = "olam") {
41216
41417
  }
41217
41418
  }
41218
41419
  function evictOldSnapshots(maxBytes, dir = snapshotsDir()) {
41219
- if (!fs47.existsSync(dir))
41420
+ if (!fs48.existsSync(dir))
41220
41421
  return 0;
41221
41422
  const allTars = [];
41222
41423
  const walk = (d) => {
41223
- for (const entry of fs47.readdirSync(d, { withFileTypes: true })) {
41424
+ for (const entry of fs48.readdirSync(d, { withFileTypes: true })) {
41224
41425
  const full = path47.join(d, entry.name);
41225
41426
  if (entry.isDirectory()) {
41226
41427
  walk(full);
41227
41428
  } else if (entry.name.endsWith(".tar.gz")) {
41228
- const stat2 = fs47.statSync(full);
41429
+ const stat2 = fs48.statSync(full);
41229
41430
  allTars.push({ path: full, size: stat2.size, mtime: stat2.mtimeMs });
41230
41431
  }
41231
41432
  }
@@ -41240,8 +41441,8 @@ function evictOldSnapshots(maxBytes, dir = snapshotsDir()) {
41240
41441
  for (const tar of allTars) {
41241
41442
  if (remaining <= maxBytes)
41242
41443
  break;
41243
- fs47.rmSync(tar.path, { force: true });
41244
- fs47.rmSync(manifestPath(tar.path), { force: true });
41444
+ fs48.rmSync(tar.path, { force: true });
41445
+ fs48.rmSync(manifestPath(tar.path), { force: true });
41245
41446
  freed += tar.size;
41246
41447
  remaining -= tar.size;
41247
41448
  }
@@ -41380,7 +41581,7 @@ function enrichReposWithManifests(repos, workspacePath) {
41380
41581
  }
41381
41582
 
41382
41583
  // ../core/dist/policies/loader.js
41383
- import * as fs48 from "node:fs";
41584
+ import * as fs49 from "node:fs";
41384
41585
  import * as path49 from "node:path";
41385
41586
  import { parse as parseYaml5 } from "yaml";
41386
41587
  function parseFrontmatter2(content) {
@@ -41402,11 +41603,11 @@ function toStringArray(v) {
41402
41603
  }
41403
41604
  function loadPolicies(workspaceRoot) {
41404
41605
  const policiesDir = path49.join(workspaceRoot, ".olam", "policies");
41405
- if (!fs48.existsSync(policiesDir))
41606
+ if (!fs49.existsSync(policiesDir))
41406
41607
  return [];
41407
41608
  let files;
41408
41609
  try {
41409
- files = fs48.readdirSync(policiesDir).filter((f) => f.endsWith(".md")).sort();
41610
+ files = fs49.readdirSync(policiesDir).filter((f) => f.endsWith(".md")).sort();
41410
41611
  } catch {
41411
41612
  return [];
41412
41613
  }
@@ -41414,7 +41615,7 @@ function loadPolicies(workspaceRoot) {
41414
41615
  for (const file of files) {
41415
41616
  const filePath = path49.join(policiesDir, file);
41416
41617
  try {
41417
- const content = fs48.readFileSync(filePath, "utf8");
41618
+ const content = fs49.readFileSync(filePath, "utf8");
41418
41619
  const parsed = parseFrontmatter2(content);
41419
41620
  if (!parsed) {
41420
41621
  console.warn(`[policies] skipping ${file}: no valid frontmatter block`);
@@ -41497,7 +41698,7 @@ var TaskDispatchError = class extends Error {
41497
41698
  this.name = "TaskDispatchError";
41498
41699
  }
41499
41700
  };
41500
- var DEFAULT_SLEEP = (ms) => new Promise((resolve15) => setTimeout(resolve15, ms));
41701
+ var DEFAULT_SLEEP = (ms) => new Promise((resolve16) => setTimeout(resolve16, ms));
41501
41702
  async function probeHealth(containerName, dockerExec, budgetMs, sleep5) {
41502
41703
  const deadline = Date.now() + budgetMs;
41503
41704
  const cadenceMs = 100;
@@ -41558,7 +41759,7 @@ async function autoDispatchTask(opts) {
41558
41759
  }
41559
41760
 
41560
41761
  // ../core/dist/world/wiki-injection-loader.js
41561
- import * as fs49 from "node:fs";
41762
+ import * as fs50 from "node:fs";
41562
41763
  import * as os30 from "node:os";
41563
41764
  import * as path50 from "node:path";
41564
41765
  var WIKI_INJECTION_FLAG = "OLAM_WIKI_INJECTION";
@@ -41578,9 +41779,9 @@ function wikiBlobPath() {
41578
41779
  function defaultReadBlob() {
41579
41780
  const p = wikiBlobPath();
41580
41781
  try {
41581
- if (!fs49.existsSync(p))
41782
+ if (!fs50.existsSync(p))
41582
41783
  return null;
41583
- return fs49.readFileSync(p, "utf8");
41784
+ return fs50.readFileSync(p, "utf8");
41584
41785
  } catch {
41585
41786
  return null;
41586
41787
  }
@@ -41619,7 +41820,7 @@ init_store();
41619
41820
  init_bridge();
41620
41821
 
41621
41822
  // ../core/dist/global-config/runbook-resolver.js
41622
- import * as fs50 from "node:fs";
41823
+ import * as fs51 from "node:fs";
41623
41824
  import * as os31 from "node:os";
41624
41825
  import * as path51 from "node:path";
41625
41826
  function expandTilde(p) {
@@ -41636,7 +41837,7 @@ function resolveRunbookToWorldParams(runbook, repoRegistry) {
41636
41837
  throw new Error(`repo "${repoName}" is referenced by runbook "${runbook.name}" but is not in the registry. Run "olam repos add ${repoName} --path <path>" to register it.`);
41637
41838
  }
41638
41839
  const resolvedPath = expandTilde(entry.path);
41639
- if (!fs50.existsSync(resolvedPath)) {
41840
+ if (!fs51.existsSync(resolvedPath)) {
41640
41841
  throw new Error(`repo "${repoName}" path "${resolvedPath}" no longer exists. Run "olam repos update ${repoName} --path <new-path>" to fix.`);
41641
41842
  }
41642
41843
  }
@@ -41652,7 +41853,7 @@ function resolveRunbookToWorldParams(runbook, repoRegistry) {
41652
41853
  init_port_validator();
41653
41854
 
41654
41855
  // ../core/dist/world/bootstrap-hooks.js
41655
- import * as fs51 from "node:fs";
41856
+ import * as fs52 from "node:fs";
41656
41857
  import * as path52 from "node:path";
41657
41858
  function runFixtureCopySeeds(seeds, workspacePath) {
41658
41859
  if (!seeds)
@@ -41663,8 +41864,8 @@ function runFixtureCopySeeds(seeds, workspacePath) {
41663
41864
  const srcAbs = path52.resolve(workspacePath, seed.repo, seed.src);
41664
41865
  const destAbs = path52.resolve(workspacePath, seed.repo, seed.dest);
41665
41866
  const destDir = path52.dirname(destAbs);
41666
- fs51.mkdirSync(destDir, { recursive: true });
41667
- fs51.cpSync(srcAbs, destAbs, { recursive: true, force: true });
41867
+ fs52.mkdirSync(destDir, { recursive: true });
41868
+ fs52.cpSync(srcAbs, destAbs, { recursive: true, force: true });
41668
41869
  }
41669
41870
  }
41670
41871
  async function runSeedHooks(seeds, containerName, servicePortMap, exec) {
@@ -42451,7 +42652,7 @@ ${detail}`);
42451
42652
  continue;
42452
42653
  const sourceRoot = repo.path.replace(/^~/, os32.homedir());
42453
42654
  const worktreeRoot = path53.join(workspacePath, repo.name);
42454
- if (!fs52.existsSync(sourceRoot) || !fs52.existsSync(worktreeRoot))
42655
+ if (!fs53.existsSync(sourceRoot) || !fs53.existsSync(worktreeRoot))
42455
42656
  continue;
42456
42657
  let copied = 0;
42457
42658
  for (const pattern of RUNTIME_FILE_PATTERNS) {
@@ -42459,28 +42660,28 @@ ${detail}`);
42459
42660
  if (pattern.includes("*")) {
42460
42661
  const [dir, glob] = [path53.dirname(pattern), path53.basename(pattern)];
42461
42662
  const sourceDir = path53.join(sourceRoot, dir);
42462
- if (fs52.existsSync(sourceDir)) {
42663
+ if (fs53.existsSync(sourceDir)) {
42463
42664
  const ext = glob.replace(/^\*+/, "");
42464
42665
  try {
42465
- for (const entry of fs52.readdirSync(sourceDir)) {
42666
+ for (const entry of fs53.readdirSync(sourceDir)) {
42466
42667
  if (ext === "" || entry.endsWith(ext))
42467
42668
  matches2.push(path53.join(dir, entry));
42468
42669
  }
42469
42670
  } catch {
42470
42671
  }
42471
42672
  }
42472
- } else if (fs52.existsSync(path53.join(sourceRoot, pattern))) {
42673
+ } else if (fs53.existsSync(path53.join(sourceRoot, pattern))) {
42473
42674
  matches2.push(pattern);
42474
42675
  }
42475
42676
  for (const rel of matches2) {
42476
42677
  const src = path53.join(sourceRoot, rel);
42477
42678
  const dst = path53.join(worktreeRoot, rel);
42478
42679
  try {
42479
- const st = fs52.statSync(src);
42680
+ const st = fs53.statSync(src);
42480
42681
  if (!st.isFile())
42481
42682
  continue;
42482
- fs52.mkdirSync(path53.dirname(dst), { recursive: true });
42483
- fs52.copyFileSync(src, dst);
42683
+ fs53.mkdirSync(path53.dirname(dst), { recursive: true });
42684
+ fs53.copyFileSync(src, dst);
42484
42685
  copied++;
42485
42686
  } catch {
42486
42687
  }
@@ -42666,9 +42867,9 @@ ${detail}`);
42666
42867
  if (opts.task)
42667
42868
  worldEnv.OLAM_TASK = opts.task;
42668
42869
  const r2CredsPath = path53.join(os32.homedir(), ".olam", "r2-credentials.json");
42669
- if (fs52.existsSync(r2CredsPath)) {
42870
+ if (fs53.existsSync(r2CredsPath)) {
42670
42871
  try {
42671
- const r2Raw = fs52.readFileSync(r2CredsPath, "utf-8").trim();
42872
+ const r2Raw = fs53.readFileSync(r2CredsPath, "utf-8").trim();
42672
42873
  if (r2Raw.length > 0) {
42673
42874
  const r2 = JSON.parse(r2Raw);
42674
42875
  if (typeof r2.account_id === "string")
@@ -42686,9 +42887,9 @@ ${detail}`);
42686
42887
  }
42687
42888
  }
42688
42889
  const keysYamlPath = path53.join(os32.homedir(), ".olam", "keys.yaml");
42689
- if (fs52.existsSync(keysYamlPath)) {
42890
+ if (fs53.existsSync(keysYamlPath)) {
42690
42891
  try {
42691
- const keysRaw = fs52.readFileSync(keysYamlPath, "utf-8").trim();
42892
+ const keysRaw = fs53.readFileSync(keysYamlPath, "utf-8").trim();
42692
42893
  if (keysRaw.length > 0) {
42693
42894
  const parsed = YAML3.parse(keysRaw);
42694
42895
  if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
@@ -42749,8 +42950,8 @@ ${detail}`);
42749
42950
  for (const { repoName, relativePath, content } of fileWrites) {
42750
42951
  const absPath = path53.join(workspacePath, repoName, relativePath);
42751
42952
  try {
42752
- fs52.mkdirSync(path53.dirname(absPath), { recursive: true });
42753
- fs52.writeFileSync(absPath, content.endsWith("\n") ? content : content + "\n", {
42953
+ fs53.mkdirSync(path53.dirname(absPath), { recursive: true });
42954
+ fs53.writeFileSync(absPath, content.endsWith("\n") ? content : content + "\n", {
42754
42955
  mode: 384
42755
42956
  });
42756
42957
  console.log(`[secrets] ${repoName}: materialised ${relativePath} (${content.length} chars, mode 0600)`);
@@ -43047,7 +43248,7 @@ ${detail}`);
43047
43248
  execSync6(`docker exec ${containerName} mkdir -p /home/olam/.olam/policies`, { stdio: "pipe", timeout: 1e4 });
43048
43249
  for (const repo of repos) {
43049
43250
  const policiesDir = path53.join(workspacePath, repo.name, ".olam", "policies");
43050
- if (fs52.existsSync(policiesDir)) {
43251
+ if (fs53.existsSync(policiesDir)) {
43051
43252
  execSync6(`docker cp "${policiesDir}/." "${containerName}:/home/olam/.olam/policies/"`, { stdio: "pipe", timeout: 15e3 });
43052
43253
  }
43053
43254
  }
@@ -43157,8 +43358,8 @@ ${detail}`);
43157
43358
  } catch {
43158
43359
  }
43159
43360
  try {
43160
- fs52.rmSync(world.workspacePath, { recursive: true, force: true });
43161
- if (fs52.existsSync(world.workspacePath)) {
43361
+ fs53.rmSync(world.workspacePath, { recursive: true, force: true });
43362
+ if (fs53.existsSync(world.workspacePath)) {
43162
43363
  console.warn(`[WorldManager] destroyWorld(${worldId}): workspace dir ${world.workspacePath} still exists after rmSync. Run \`olam clean --apply\` to reap.`);
43163
43364
  }
43164
43365
  } catch (err) {
@@ -43267,14 +43468,14 @@ ${detail}`);
43267
43468
  }).filter((r) => r !== void 0);
43268
43469
  }
43269
43470
  transportPlanFile(planFilePath, workspacePath, repoNames) {
43270
- const planContent = fs52.readFileSync(planFilePath, "utf-8");
43471
+ const planContent = fs53.readFileSync(planFilePath, "utf-8");
43271
43472
  const planFileName = path53.basename(planFilePath);
43272
43473
  const targetRepo = repoNames[0];
43273
43474
  if (!targetRepo)
43274
43475
  return;
43275
43476
  const plansDir = path53.join(workspacePath, targetRepo, "docs", "plans");
43276
- fs52.mkdirSync(plansDir, { recursive: true });
43277
- fs52.writeFileSync(path53.join(plansDir, planFileName), planContent);
43477
+ fs53.mkdirSync(plansDir, { recursive: true });
43478
+ fs53.writeFileSync(path53.join(plansDir, planFileName), planContent);
43278
43479
  }
43279
43480
  resolveServices(repos) {
43280
43481
  const services = [];
@@ -43738,9 +43939,9 @@ import * as http2 from "node:http";
43738
43939
 
43739
43940
  // ../core/dist/dashboard/server.js
43740
43941
  import * as http from "node:http";
43741
- import * as fs53 from "node:fs";
43942
+ import * as fs54 from "node:fs";
43742
43943
  import * as path54 from "node:path";
43743
- import { fileURLToPath as fileURLToPath3 } from "node:url";
43944
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
43744
43945
 
43745
43946
  // ../core/dist/dashboard/serialize.js
43746
43947
  function serializeTokenUsage(usage) {
@@ -44074,7 +44275,7 @@ function notFound(res) {
44074
44275
  }
44075
44276
  function openThoughtStore(workspacePath) {
44076
44277
  const dbPath = getWorldDbPath(workspacePath);
44077
- if (!fs53.existsSync(dbPath))
44278
+ if (!fs54.existsSync(dbPath))
44078
44279
  return null;
44079
44280
  return new ThoughtLocalStore(dbPath);
44080
44281
  }
@@ -44245,13 +44446,13 @@ function findSessionInWorld(registry2, sessionId) {
44245
44446
  }
44246
44447
  function createDashboardServer(opts) {
44247
44448
  const { port: port2, registry: registry2 } = opts;
44248
- const thisDir = path54.dirname(fileURLToPath3(import.meta.url));
44449
+ const thisDir = path54.dirname(fileURLToPath4(import.meta.url));
44249
44450
  const defaultPublicDir = path54.resolve(thisDir, "../../../control-plane/public");
44250
44451
  const publicDir = opts.publicDir ?? defaultPublicDir;
44251
- let hasPublicDir = fs53.existsSync(publicDir);
44452
+ let hasPublicDir = fs54.existsSync(publicDir);
44252
44453
  const server = http.createServer((req, res) => {
44253
44454
  if (!hasPublicDir) {
44254
- hasPublicDir = fs53.existsSync(publicDir);
44455
+ hasPublicDir = fs54.existsSync(publicDir);
44255
44456
  }
44256
44457
  const host = req.headers.host ?? `localhost:${port2}`;
44257
44458
  const url2 = new URL(req.url ?? "/", `http://${host}`);
@@ -44530,17 +44731,17 @@ function createDashboardServer(opts) {
44530
44731
  notFound(res);
44531
44732
  return;
44532
44733
  }
44533
- if (fs53.existsSync(filePath) && fs53.statSync(filePath).isFile()) {
44734
+ if (fs54.existsSync(filePath) && fs54.statSync(filePath).isFile()) {
44534
44735
  const ext = path54.extname(filePath);
44535
44736
  const contentType = MIME[ext] ?? "application/octet-stream";
44536
44737
  res.writeHead(200, { "Content-Type": contentType });
44537
- fs53.createReadStream(filePath).pipe(res);
44738
+ fs54.createReadStream(filePath).pipe(res);
44538
44739
  return;
44539
44740
  }
44540
44741
  filePath = path54.join(publicDir, "index.html");
44541
- if (fs53.existsSync(filePath)) {
44742
+ if (fs54.existsSync(filePath)) {
44542
44743
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
44543
- fs53.createReadStream(filePath).pipe(res);
44744
+ fs54.createReadStream(filePath).pipe(res);
44544
44745
  return;
44545
44746
  }
44546
44747
  notFound(res);
@@ -44550,17 +44751,17 @@ function createDashboardServer(opts) {
44550
44751
  }
44551
44752
 
44552
44753
  // ../core/dist/dashboard/state.js
44553
- import * as fs54 from "node:fs";
44754
+ import * as fs55 from "node:fs";
44554
44755
  import * as os33 from "node:os";
44555
44756
  import * as path55 from "node:path";
44556
44757
  var STATE_PATH = path55.join(os33.homedir(), ".olam", "dashboard.json");
44557
44758
  function saveDashboardState(state) {
44558
- fs54.mkdirSync(path55.dirname(STATE_PATH), { recursive: true });
44559
- fs54.writeFileSync(STATE_PATH, JSON.stringify(state, null, 2));
44759
+ fs55.mkdirSync(path55.dirname(STATE_PATH), { recursive: true });
44760
+ fs55.writeFileSync(STATE_PATH, JSON.stringify(state, null, 2));
44560
44761
  }
44561
44762
  function loadDashboardState() {
44562
44763
  try {
44563
- const raw = fs54.readFileSync(STATE_PATH, "utf-8");
44764
+ const raw = fs55.readFileSync(STATE_PATH, "utf-8");
44564
44765
  return JSON.parse(raw);
44565
44766
  } catch {
44566
44767
  return null;
@@ -44568,7 +44769,7 @@ function loadDashboardState() {
44568
44769
  }
44569
44770
  function clearDashboardState() {
44570
44771
  try {
44571
- fs54.unlinkSync(STATE_PATH);
44772
+ fs55.unlinkSync(STATE_PATH);
44572
44773
  } catch {
44573
44774
  }
44574
44775
  }
@@ -44597,7 +44798,7 @@ function isCloudflaredAvailable() {
44597
44798
  }
44598
44799
  }
44599
44800
  function startTunnel(port2) {
44600
- return new Promise((resolve15, reject2) => {
44801
+ return new Promise((resolve16, reject2) => {
44601
44802
  const child = spawn4("cloudflared", ["tunnel", "--url", `http://localhost:${port2}`], {
44602
44803
  stdio: ["ignore", "pipe", "pipe"],
44603
44804
  detached: false
@@ -44619,7 +44820,7 @@ function startTunnel(port2) {
44619
44820
  if (match) {
44620
44821
  resolved = true;
44621
44822
  clearTimeout(timeout);
44622
- resolve15(match[0]);
44823
+ resolve16(match[0]);
44623
44824
  }
44624
44825
  }
44625
44826
  child.stdout?.on("data", scan);
@@ -44687,8 +44888,8 @@ var DashboardManager = class {
44687
44888
  }
44688
44889
  throw err;
44689
44890
  }
44690
- await new Promise((resolve15, reject2) => {
44691
- this.server.on("listening", resolve15);
44891
+ await new Promise((resolve16, reject2) => {
44892
+ this.server.on("listening", resolve16);
44692
44893
  this.server.on("error", reject2);
44693
44894
  });
44694
44895
  this.info = { localUrl: `http://localhost:${port2}` };
@@ -44734,8 +44935,8 @@ var DashboardManager = class {
44734
44935
  async stop() {
44735
44936
  stopTunnel();
44736
44937
  if (this.server) {
44737
- await new Promise((resolve15) => {
44738
- this.server.close(() => resolve15());
44938
+ await new Promise((resolve16) => {
44939
+ this.server.close(() => resolve16());
44739
44940
  });
44740
44941
  this.server = null;
44741
44942
  }
@@ -44848,8 +45049,8 @@ var PleriClient = class {
44848
45049
  };
44849
45050
 
44850
45051
  // ../mcp-server/src/env-loader.ts
44851
- import { readFileSync as readFileSync41, existsSync as existsSync50, statSync as statSync14 } from "node:fs";
44852
- import { join as join54, dirname as dirname29, resolve as resolve14 } from "node:path";
45052
+ import { readFileSync as readFileSync43, existsSync as existsSync52, statSync as statSync14 } from "node:fs";
45053
+ import { join as join55, dirname as dirname30, resolve as resolve15 } from "node:path";
44853
45054
  var PROJECT_MARKERS = [
44854
45055
  ".olam/config.yaml",
44855
45056
  ".olam/config.yml",
@@ -44857,30 +45058,30 @@ var PROJECT_MARKERS = [
44857
45058
  "olam.yml"
44858
45059
  ];
44859
45060
  function findProjectRoot2(startDir) {
44860
- let dir = resolve14(startDir);
44861
- const root = resolve14("/");
45061
+ let dir = resolve15(startDir);
45062
+ const root = resolve15("/");
44862
45063
  while (true) {
44863
45064
  for (const marker of PROJECT_MARKERS) {
44864
- if (existsSync50(join54(dir, marker))) return dir;
45065
+ if (existsSync52(join55(dir, marker))) return dir;
44865
45066
  }
44866
- const pkg = join54(dir, "package.json");
44867
- if (existsSync50(pkg)) {
45067
+ const pkg = join55(dir, "package.json");
45068
+ if (existsSync52(pkg)) {
44868
45069
  try {
44869
- const json = JSON.parse(readFileSync41(pkg, "utf8"));
45070
+ const json = JSON.parse(readFileSync43(pkg, "utf8"));
44870
45071
  const isOlamWorkspace = typeof json.name === "string" && json.name.startsWith("@olam/");
44871
45072
  const hasOlamDep = json.dependencies && Object.keys(json.dependencies).some((k) => k.startsWith("@olam/")) || json.devDependencies && Object.keys(json.devDependencies).some((k) => k.startsWith("@olam/"));
44872
45073
  if (isOlamWorkspace || hasOlamDep) return dir;
44873
45074
  } catch {
44874
45075
  }
44875
45076
  }
44876
- const parent = dirname29(dir);
45077
+ const parent = dirname30(dir);
44877
45078
  if (parent === dir || parent === root) return null;
44878
45079
  dir = parent;
44879
45080
  }
44880
45081
  }
44881
45082
  function parseEnvFile(path56) {
44882
45083
  const out = {};
44883
- const raw = readFileSync41(path56, "utf8");
45084
+ const raw = readFileSync43(path56, "utf8");
44884
45085
  for (const line of raw.split(/\r?\n/)) {
44885
45086
  const trimmed = line.trim();
44886
45087
  if (!trimmed || trimmed.startsWith("#")) continue;
@@ -44903,8 +45104,8 @@ function loadProjectEnv(startDir = process.cwd()) {
44903
45104
  const filesRead = [];
44904
45105
  const merged = {};
44905
45106
  for (const name of [".env", ".env.local"]) {
44906
- const p = join54(root, name);
44907
- if (existsSync50(p) && statSync14(p).isFile()) {
45107
+ const p = join55(root, name);
45108
+ if (existsSync52(p) && statSync14(p).isFile()) {
44908
45109
  Object.assign(merged, parseEnvFile(p));
44909
45110
  filesRead.push(p);
44910
45111
  }