@pleri/olam-cli 0.1.125 → 0.1.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4474,7 +4474,32 @@ var init_repo_manifest = __esm({
4474
4474
  // later in the seam. Statements are NOT exposed to operator-controlled
4475
4475
  // env variables — only the two whitelisted placeholders above. No shell
4476
4476
  // expansion, no DOLLAR-name expansion.
4477
- post_clone_sql: external_exports.record(external_exports.string().min(1), external_exports.array(external_exports.string().min(1))).optional()
4477
+ post_clone_sql: external_exports.record(external_exports.string().min(1), external_exports.array(external_exports.string().min(1))).optional(),
4478
+ // olam-hybrid-shared-postgres Phase B: per-seed env-var-name override.
4479
+ //
4480
+ // Phase A's F-6 derives the DB-name env var from the seed name using a
4481
+ // POSTGRESQL_<PURPOSE>_DATABASE convention (atlas_common_seed →
4482
+ // POSTGRESQL_COMMON_DATABASE). That works for atlas-core which uses
4483
+ // POSTGRESQL_*-prefixed env vars throughout.
4484
+ //
4485
+ // Atlas-pay (and other future repos) use different env var names —
4486
+ // e.g. ATLAS_PAY_DATABASE, not POSTGRESQL_PAY_DATABASE. This map lets
4487
+ // a manifest declare the override explicitly:
4488
+ //
4489
+ // services:
4490
+ // postgres:
4491
+ // seed_template:
4492
+ // - atlas_common_seed
4493
+ // - atlas_pay_seed
4494
+ // db_env_override:
4495
+ // atlas_pay_seed: ATLAS_PAY_DATABASE
4496
+ // # atlas_common_seed keeps F-6's default POSTGRESQL_COMMON_DATABASE
4497
+ //
4498
+ // Schema: Record<seed_template_name, env_var_name>. The env var name
4499
+ // must be uppercase letters/digits/underscores ([A-Z][A-Z0-9_]*) — same
4500
+ // shape as conventional shell env vars. F-6 honors the override when
4501
+ // present; falls back to the derived default otherwise.
4502
+ db_env_override: external_exports.record(external_exports.string().min(1), external_exports.string().regex(/^[A-Z][A-Z0-9_]*$/)).optional()
4478
4503
  }).passthrough();
4479
4504
  deploySchema = external_exports.object({
4480
4505
  tags: external_exports.array(external_exports.string()).optional()
@@ -5870,6 +5895,17 @@ function readHostCpToken() {
5870
5895
  return "";
5871
5896
  }
5872
5897
  }
5898
+ function readMemorySecret() {
5899
+ const fromEnv = process.env["OLAM_MEMORY_SECRET"];
5900
+ if (fromEnv && fromEnv.length > 0)
5901
+ return fromEnv;
5902
+ const file = path11.join(os6.homedir(), ".olam", "memory-secret");
5903
+ try {
5904
+ return fs10.readFileSync(file, "utf-8").trim();
5905
+ } catch {
5906
+ return "";
5907
+ }
5908
+ }
5873
5909
  function sanitizeContainerName(name) {
5874
5910
  return name.replace(/[^a-zA-Z0-9_.-]/g, "-");
5875
5911
  }
@@ -5917,7 +5953,7 @@ async function auditPortsForZombies(docker2, hostPorts) {
5917
5953
  }
5918
5954
  }
5919
5955
  }
5920
- var realPullImage, serviceContainerName, worldContainerName, miseCacheVolumeName, PACKAGE_MANAGER_CACHE_DIRS, createServiceContainer, DEFAULT_IMAGE2, CONTROL_PLANE_PORT, HOST_CONTROL_PLANE_BASE, HOST_APP_PORT_BASE_DELTA, DEFAULT_MEMORY_BYTES, PortHeldByZombieError, createWorldContainer, stopAndRemove;
5956
+ var realPullImage, AGENTMEMORY_HOST_INTERNAL_URL, serviceContainerName, worldContainerName, miseCacheVolumeName, PACKAGE_MANAGER_CACHE_DIRS, createServiceContainer, DEFAULT_IMAGE2, CONTROL_PLANE_PORT, HOST_CONTROL_PLANE_BASE, HOST_APP_PORT_BASE_DELTA, DEFAULT_MEMORY_BYTES, PortHeldByZombieError, createWorldContainer, stopAndRemove;
5921
5957
  var init_container2 = __esm({
5922
5958
  "../adapters/dist/docker/container.js"() {
5923
5959
  "use strict";
@@ -5925,6 +5961,7 @@ var init_container2 = __esm({
5925
5961
  init_pull();
5926
5962
  init_volume();
5927
5963
  realPullImage = (imageRef, platform) => pullImageWithRetry(imageRef, void 0, platform ? { perAttemptTimeoutMs: 18e4, retryOnce: true, platform } : { perAttemptTimeoutMs: 18e4, retryOnce: true });
5964
+ AGENTMEMORY_HOST_INTERNAL_URL = "http://host.docker.internal:3111";
5928
5965
  serviceContainerName = (worldId, serviceName) => `olam-${sanitizeContainerName(worldId)}-${sanitizeContainerName(serviceName)}`;
5929
5966
  worldContainerName = (worldId) => `olam-${sanitizeContainerName(worldId)}-devbox`;
5930
5967
  miseCacheVolumeName = (arch2 = process.arch) => `olam-mise-cache-${arch2}`;
@@ -6007,6 +6044,7 @@ var init_container2 = __esm({
6007
6044
  const labels = olamLabels(worldId, worldName);
6008
6045
  const authSecret = readAuthSecret();
6009
6046
  const hostCpToken = readHostCpToken();
6047
+ const memorySecret = readMemorySecret();
6010
6048
  const worldEnv = {
6011
6049
  OLAM_WORLD_ID: worldId,
6012
6050
  OLAM_WORLD_NAME: worldName,
@@ -6023,6 +6061,14 @@ var init_container2 = __esm({
6023
6061
  OLAM_HOST_CP_URL: "http://host.docker.internal:19000",
6024
6062
  ...authSecret ? { OLAM_AUTH_SECRET: authSecret } : {},
6025
6063
  ...hostCpToken ? { OLAM_HOST_CP_TOKEN: hostCpToken } : {},
6064
+ // Phase B1 — agent-memory wiring. Both vars are injected together
6065
+ // (or neither): without a secret the URL is useless. The in-world
6066
+ // @agentmemory/mcp shim (Phase B2/B3) reads these env vars to find
6067
+ // the host's REST endpoint.
6068
+ ...memorySecret ? {
6069
+ AGENTMEMORY_URL: AGENTMEMORY_HOST_INTERNAL_URL,
6070
+ AGENTMEMORY_SECRET: memorySecret
6071
+ } : {},
6026
6072
  ...env
6027
6073
  };
6028
6074
  const envList = Object.entries(worldEnv).map(([k, v]) => `${k}=${v}`);
@@ -11221,6 +11267,7 @@ function applyPostgresNetworkOverrides(worldEnv, enrichedRepos, worldId) {
11221
11267
  if (worldId !== void 0) {
11222
11268
  assertSafeWorldId(worldId);
11223
11269
  const seedTemplates = /* @__PURE__ */ new Set();
11270
+ const dbEnvOverride = {};
11224
11271
  for (const repo of enrichedRepos) {
11225
11272
  const pg = repo.manifest?.services?.["postgres"];
11226
11273
  const raw = pg?.seed_template;
@@ -11231,12 +11278,23 @@ function applyPostgresNetworkOverrides(worldEnv, enrichedRepos, worldId) {
11231
11278
  if (typeof s === "string")
11232
11279
  seedTemplates.add(s);
11233
11280
  }
11281
+ if (pg?.db_env_override && typeof pg.db_env_override === "object") {
11282
+ for (const [seedKey, envName] of Object.entries(pg.db_env_override)) {
11283
+ if (typeof envName === "string" && envName.length > 0) {
11284
+ dbEnvOverride[seedKey] = envName;
11285
+ }
11286
+ }
11287
+ }
11234
11288
  }
11235
11289
  for (const seed of seedTemplates) {
11236
- const match2 = seed.match(/^atlas_([a-z][a-z0-9_]*?)_seed$/i);
11237
- if (match2 && match2[1] !== void 0) {
11238
- const purpose = match2[1].toUpperCase();
11239
- const envKey = `POSTGRESQL_${purpose}_DATABASE`;
11290
+ let envKey = dbEnvOverride[seed];
11291
+ if (envKey === void 0) {
11292
+ const match2 = seed.match(/^atlas_([a-z][a-z0-9_]*?)_seed$/i);
11293
+ if (match2 && match2[1] !== void 0) {
11294
+ envKey = `POSTGRESQL_${match2[1].toUpperCase()}_DATABASE`;
11295
+ }
11296
+ }
11297
+ if (envKey !== void 0) {
11240
11298
  worldEnv[envKey] = deriveWorldDbName(seed, worldId);
11241
11299
  }
11242
11300
  }
@@ -16888,9 +16946,9 @@ ${pc9.dim("Next: olam create --name my-world")}`);
16888
16946
 
16889
16947
  // src/commands/create.ts
16890
16948
  init_manager();
16891
- import { spawnSync as spawnSync11 } from "node:child_process";
16892
- import { existsSync as existsSync28 } from "node:fs";
16893
- import { dirname as dirname18, resolve as resolve12 } from "node:path";
16949
+ import { spawnSync as spawnSync12 } from "node:child_process";
16950
+ import { existsSync as existsSync29 } from "node:fs";
16951
+ import { dirname as dirname19, resolve as resolve12 } from "node:path";
16894
16952
  import ora3 from "ora";
16895
16953
  import pc10 from "picocolors";
16896
16954
 
@@ -17124,6 +17182,132 @@ function decideWorkspaceMatch(input) {
17124
17182
  init_context();
17125
17183
  init_output();
17126
17184
  init_host_cp();
17185
+
17186
+ // src/lib/memory-secret.ts
17187
+ import { existsSync as existsSync28, mkdirSync as mkdirSync17, readFileSync as readFileSync20, statSync as statSync7, writeFileSync as writeFileSync13, renameSync as renameSync4, chmodSync as chmodSync3 } from "node:fs";
17188
+ import { homedir as homedir17 } from "node:os";
17189
+ import { join as join34, dirname as dirname18 } from "node:path";
17190
+ import { randomBytes as randomBytes6 } from "node:crypto";
17191
+ var MEMORY_SECRET_PATH = join34(homedir17(), ".olam", "memory-secret");
17192
+ var SECRET_LEN_BYTES = 32;
17193
+ function generateSecret() {
17194
+ return randomBytes6(SECRET_LEN_BYTES).toString("hex");
17195
+ }
17196
+ function writeSecretAtPath(path56, value) {
17197
+ mkdirSync17(dirname18(path56), { recursive: true });
17198
+ const tmp = `${path56}.tmp.${process.pid}`;
17199
+ writeFileSync13(tmp, value, { mode: 384 });
17200
+ chmodSync3(tmp, 384);
17201
+ renameSync4(tmp, path56);
17202
+ }
17203
+ function readSecretAtPathOrNull(path56) {
17204
+ if (!existsSync28(path56)) return null;
17205
+ const mode = statSync7(path56).mode & 511;
17206
+ if (mode !== 384) {
17207
+ process.stderr.write(
17208
+ `warn: ${path56} has mode 0${mode.toString(8)}; expected 0600. Run 'olam memory secret rotate' to regenerate.
17209
+ `
17210
+ );
17211
+ }
17212
+ return readFileSync20(path56, "utf8").trim();
17213
+ }
17214
+ function readSecretAtPath(path56) {
17215
+ const v = readSecretAtPathOrNull(path56);
17216
+ if (v === null) {
17217
+ throw new Error(
17218
+ `Secret not found at ${path56}. Run 'olam memory start' to generate it.`
17219
+ );
17220
+ }
17221
+ return v;
17222
+ }
17223
+ function ensureMemorySecret(path56 = MEMORY_SECRET_PATH) {
17224
+ const existing = readSecretAtPathOrNull(path56);
17225
+ if (existing) return existing;
17226
+ const fresh = generateSecret();
17227
+ writeSecretAtPath(path56, fresh);
17228
+ return fresh;
17229
+ }
17230
+ function readMemorySecretOrNull(path56 = MEMORY_SECRET_PATH) {
17231
+ return readSecretAtPathOrNull(path56);
17232
+ }
17233
+ function readMemorySecret2(path56 = MEMORY_SECRET_PATH) {
17234
+ return readSecretAtPath(path56);
17235
+ }
17236
+ function rotateMemorySecret(path56 = MEMORY_SECRET_PATH) {
17237
+ const fresh = generateSecret();
17238
+ writeSecretAtPath(path56, fresh);
17239
+ return fresh;
17240
+ }
17241
+ function hasMemorySecret(path56 = MEMORY_SECRET_PATH) {
17242
+ return existsSync28(path56);
17243
+ }
17244
+
17245
+ // src/lib/world-mcp-register.ts
17246
+ import { spawnSync as spawnSync11 } from "node:child_process";
17247
+ var DEFAULT_DOCKER_EXEC_DEPS = {
17248
+ spawn: spawnSync11,
17249
+ log: (msg) => console.log(msg)
17250
+ };
17251
+ var MCP_NAME = "agentmemory";
17252
+ var MCP_BIN = "agentmemory-mcp";
17253
+ function probeMcpListed(containerName, deps) {
17254
+ const result = deps.spawn(
17255
+ "docker",
17256
+ ["exec", containerName, "claude", "mcp", "list"],
17257
+ { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
17258
+ );
17259
+ if (result.status !== 0) return "unknown";
17260
+ const combined = `${result.stdout ?? ""}
17261
+ ${result.stderr ?? ""}`;
17262
+ return new RegExp(`^\\s*${MCP_NAME}\\b`, "m").test(combined) ? "present" : "absent";
17263
+ }
17264
+ function registerAgentMemoryMcp(opts, deps = DEFAULT_DOCKER_EXEC_DEPS) {
17265
+ if (!opts.agentmemorySecret || opts.agentmemorySecret.length === 0) {
17266
+ return {
17267
+ outcome: "skipped-no-env",
17268
+ reason: "world has no AGENTMEMORY_SECRET (memory service was absent or --skip-memory active at spawn time)"
17269
+ };
17270
+ }
17271
+ const probe2 = probeMcpListed(opts.containerName, deps);
17272
+ if (probe2 === "present") {
17273
+ return { outcome: "already-registered", scope: "user" };
17274
+ }
17275
+ const args = [
17276
+ "exec",
17277
+ opts.containerName,
17278
+ "claude",
17279
+ "mcp",
17280
+ "add",
17281
+ MCP_NAME,
17282
+ "--scope",
17283
+ "user",
17284
+ "--env",
17285
+ `AGENTMEMORY_URL=${opts.agentmemoryUrl}`,
17286
+ "--env",
17287
+ `AGENTMEMORY_SECRET=${opts.agentmemorySecret}`,
17288
+ "--",
17289
+ MCP_BIN
17290
+ ];
17291
+ const redacted = args.map(
17292
+ (a) => a.startsWith("AGENTMEMORY_SECRET=") ? "AGENTMEMORY_SECRET=<redacted>" : a
17293
+ );
17294
+ deps.log?.(`Wiring agent-memory MCP in ${opts.containerName}: docker ${redacted.join(" ")}`);
17295
+ const result = deps.spawn("docker", args, {
17296
+ encoding: "utf8",
17297
+ stdio: ["ignore", "pipe", "pipe"]
17298
+ });
17299
+ if (result.status === 0) {
17300
+ return { outcome: "registered", scope: "user" };
17301
+ }
17302
+ const detail = (result.stderr?.trim() || result.stdout?.trim() || "(no output)").replace(
17303
+ /AGENTMEMORY_SECRET=\S+/g,
17304
+ "AGENTMEMORY_SECRET=<redacted>"
17305
+ );
17306
+ return { outcome: "failed", rc: result.status ?? 1, detail };
17307
+ }
17308
+
17309
+ // src/commands/create.ts
17310
+ var AGENTMEMORY_LOCAL_URL = "http://host.docker.internal:3111";
17127
17311
  var HOST_CP_URL = "http://127.0.0.1:19000";
17128
17312
  async function readHostCpTokenForCreate() {
17129
17313
  try {
@@ -17160,7 +17344,7 @@ function registerCreate(program2) {
17160
17344
  if (decision.stderrLine) {
17161
17345
  process.stderr.write(decision.stderrLine + "\n");
17162
17346
  }
17163
- spawnSync11("docker", ["pull", overrideRef], { stdio: "pipe" });
17347
+ spawnSync12("docker", ["pull", overrideRef], { stdio: "pipe" });
17164
17348
  const { inspectImageProtocolVersions: inspectImageProtocolVersions2, checkProtocolOverlap: checkProtocolOverlap2 } = await Promise.resolve().then(() => (init_protocol_version(), protocol_version_exports));
17165
17349
  const inspect = inspectImageProtocolVersions2(overrideRef);
17166
17350
  if (inspect.inspectFailed) {
@@ -17277,7 +17461,7 @@ function registerCreate(program2) {
17277
17461
  throw err;
17278
17462
  }
17279
17463
  const spinner2 = ora3("Rebuilding olam-devbox:latest\u2026").start();
17280
- const rebuild = spawnSync11(
17464
+ const rebuild = spawnSync12(
17281
17465
  "bash",
17282
17466
  [buildScript],
17283
17467
  { cwd: repoRoot, stdio: "inherit" }
@@ -17314,6 +17498,34 @@ function registerCreate(program2) {
17314
17498
  ...opts.runbook ? { runbookName: opts.runbook } : {}
17315
17499
  });
17316
17500
  spinner.succeed("World created");
17501
+ try {
17502
+ const memorySecret = readMemorySecretOrNull() ?? "";
17503
+ const containerName = `olam-${world.id}-devbox`;
17504
+ const result = registerAgentMemoryMcp({
17505
+ containerName,
17506
+ agentmemoryUrl: AGENTMEMORY_LOCAL_URL,
17507
+ agentmemorySecret: memorySecret
17508
+ });
17509
+ switch (result.outcome) {
17510
+ case "registered":
17511
+ printInfo("Agent memory", `MCP registered in-world (--scope ${result.scope})`);
17512
+ break;
17513
+ case "already-registered":
17514
+ printInfo("Agent memory", `MCP already registered (idempotent skip)`);
17515
+ break;
17516
+ case "skipped-no-env":
17517
+ break;
17518
+ case "failed":
17519
+ printWarning(
17520
+ `Agent memory MCP registration failed (rc=${result.rc}): ${result.detail}. World is still usable; the in-world @agentmemory/mcp shim falls back to local InMemoryKV.`
17521
+ );
17522
+ break;
17523
+ }
17524
+ } catch (err) {
17525
+ printWarning(
17526
+ `Agent memory MCP registration threw: ${err instanceof Error ? err.message : String(err)}. World is still usable.`
17527
+ );
17528
+ }
17317
17529
  if (opts.keepAfterMerge) {
17318
17530
  const { WorldRegistry: WorldRegistry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
17319
17531
  const reg2 = new WorldRegistry2();
@@ -17484,10 +17696,10 @@ ${pc10.cyan("Host CP UI:")} ${worldUrl}`);
17484
17696
  function resolveRepoRoot(start) {
17485
17697
  let cur = start;
17486
17698
  while (true) {
17487
- if (existsSync28(resolve12(cur, "packages")) && existsSync28(resolve12(cur, "package.json"))) {
17699
+ if (existsSync29(resolve12(cur, "packages")) && existsSync29(resolve12(cur, "package.json"))) {
17488
17700
  return cur;
17489
17701
  }
17490
- const parent = dirname18(cur);
17702
+ const parent = dirname19(cur);
17491
17703
  if (parent === cur) return start;
17492
17704
  cur = parent;
17493
17705
  }
@@ -20951,7 +21163,7 @@ function registerPolicyCheck(program2) {
20951
21163
  }
20952
21164
 
20953
21165
  // src/commands/worldspec/compile.ts
20954
- import { existsSync as existsSync33, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
21166
+ import { existsSync as existsSync34, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
20955
21167
  import { resolve as resolvePath } from "node:path";
20956
21168
  import YAML5 from "yaml";
20957
21169
 
@@ -21754,13 +21966,13 @@ function registerWorldspecCompile(parent) {
21754
21966
  const sourcePolicies = [];
21755
21967
  for (const p of paths) {
21756
21968
  const abs = resolvePath(process.cwd(), p);
21757
- if (!existsSync33(abs)) {
21969
+ if (!existsSync34(abs)) {
21758
21970
  printError(`worldspec not found at ${abs}`);
21759
21971
  process.exit(EXIT_WORLDSPEC_FILE_NOT_FOUND);
21760
21972
  }
21761
21973
  let yaml;
21762
21974
  try {
21763
- yaml = YAML5.parse(readFileSync22(abs, "utf8"));
21975
+ yaml = YAML5.parse(readFileSync23(abs, "utf8"));
21764
21976
  } catch (err) {
21765
21977
  printError(
21766
21978
  `${p}: YAML parse error: ${err.message}`
@@ -21816,13 +22028,13 @@ Resolutions:
21816
22028
  if (opts.out) {
21817
22029
  const outDir = resolvePath(process.cwd(), opts.out);
21818
22030
  try {
21819
- mkdirSync18(outDir, { recursive: true });
21820
- writeFileSync14(
22031
+ mkdirSync19(outDir, { recursive: true });
22032
+ writeFileSync15(
21821
22033
  resolvePath(outDir, "execution-graph.json"),
21822
22034
  graphJson,
21823
22035
  "utf8"
21824
22036
  );
21825
- writeFileSync14(
22037
+ writeFileSync15(
21826
22038
  resolvePath(outDir, "lockfile.json"),
21827
22039
  lockfileJson,
21828
22040
  "utf8"
@@ -21845,7 +22057,7 @@ function getPkgVersion() {
21845
22057
  // src/commands/worldspec/init.ts
21846
22058
  init_exit_codes();
21847
22059
  init_output();
21848
- import { existsSync as existsSync34, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
22060
+ import { existsSync as existsSync35, mkdirSync as mkdirSync20, readFileSync as readFileSync24, writeFileSync as writeFileSync16 } from "node:fs";
21849
22061
  import { execSync as execSync10 } from "node:child_process";
21850
22062
  import { basename as basename3, resolve as resolvePath2 } from "node:path";
21851
22063
  function registerWorldspecInit(parent) {
@@ -21863,7 +22075,7 @@ function registerWorldspecInit(parent) {
21863
22075
  const cwd = process.cwd();
21864
22076
  const targetDir = resolvePath2(cwd, ".olam/worldspecs");
21865
22077
  const targetFile = resolvePath2(targetDir, "default.yaml");
21866
- if (existsSync34(targetFile) && !opts.force) {
22078
+ if (existsSync35(targetFile) && !opts.force) {
21867
22079
  printError(
21868
22080
  `${targetFile} already exists; pass --force to overwrite`
21869
22081
  );
@@ -21878,8 +22090,8 @@ function registerWorldspecInit(parent) {
21878
22090
  const shape = detectProjectShape(cwd, opts.fromAdbYaml);
21879
22091
  const yaml = renderWorldspecYaml(shape);
21880
22092
  try {
21881
- mkdirSync19(targetDir, { recursive: true });
21882
- writeFileSync15(targetFile, yaml, {
22093
+ mkdirSync20(targetDir, { recursive: true });
22094
+ writeFileSync16(targetFile, yaml, {
21883
22095
  encoding: "utf8",
21884
22096
  flag: opts.force ? "w" : "wx"
21885
22097
  });
@@ -21897,14 +22109,14 @@ function registerWorldspecInit(parent) {
21897
22109
  });
21898
22110
  }
21899
22111
  function detectProjectShape(root, useAdbYaml) {
21900
- const hasGemfile = existsSync34(resolvePath2(root, "Gemfile"));
21901
- const hasNodePackageJson = existsSync34(resolvePath2(root, "package.json"));
21902
- const hasAdbYaml = existsSync34(resolvePath2(root, ".adb.yaml"));
22112
+ const hasGemfile = existsSync35(resolvePath2(root, "Gemfile"));
22113
+ const hasNodePackageJson = existsSync35(resolvePath2(root, "package.json"));
22114
+ const hasAdbYaml = existsSync35(resolvePath2(root, ".adb.yaml"));
21903
22115
  let rubyVersion = null;
21904
22116
  const rubyVersionPath = resolvePath2(root, ".ruby-version");
21905
- if (existsSync34(rubyVersionPath)) {
22117
+ if (existsSync35(rubyVersionPath)) {
21906
22118
  try {
21907
- const raw = readFileSync23(rubyVersionPath, "utf8").trim();
22119
+ const raw = readFileSync24(rubyVersionPath, "utf8").trim();
21908
22120
  const match2 = raw.match(/(\d+\.\d+\.\d+)/);
21909
22121
  if (match2) rubyVersion = match2[1] ?? null;
21910
22122
  } catch {
@@ -21976,7 +22188,7 @@ function relativeFromCwd(absPath, cwd) {
21976
22188
  }
21977
22189
 
21978
22190
  // src/commands/worldspec/schema.ts
21979
- import { writeFileSync as writeFileSync16 } from "node:fs";
22191
+ import { writeFileSync as writeFileSync17 } from "node:fs";
21980
22192
  import { resolve as resolvePath3 } from "node:path";
21981
22193
 
21982
22194
  // ../../node_modules/zod-to-json-schema/dist/esm/Options.js
@@ -23291,7 +23503,7 @@ function registerWorldspecSchema(parent) {
23291
23503
  if (opts.out) {
23292
23504
  const absPath = resolvePath3(process.cwd(), opts.out);
23293
23505
  try {
23294
- writeFileSync16(absPath, json + "\n", "utf8");
23506
+ writeFileSync17(absPath, json + "\n", "utf8");
23295
23507
  } catch (err) {
23296
23508
  printError(
23297
23509
  `failed to write ${absPath}: ${err.message}`
@@ -23307,7 +23519,7 @@ function registerWorldspecSchema(parent) {
23307
23519
  }
23308
23520
 
23309
23521
  // src/commands/worldspec/validate.ts
23310
- import { existsSync as existsSync35, readFileSync as readFileSync24 } from "node:fs";
23522
+ import { existsSync as existsSync36, readFileSync as readFileSync25 } from "node:fs";
23311
23523
  import { resolve as resolvePath4 } from "node:path";
23312
23524
  init_exit_codes();
23313
23525
  init_output();
@@ -23324,13 +23536,13 @@ function registerWorldspecValidate(parent) {
23324
23536
  "human"
23325
23537
  ).action(async (pathArg, opts) => {
23326
23538
  const absPath = resolvePath4(process.cwd(), pathArg);
23327
- if (!existsSync35(absPath)) {
23539
+ if (!existsSync36(absPath)) {
23328
23540
  printError(`worldspec not found at ${absPath}`);
23329
23541
  process.exit(EXIT_WORLDSPEC_FILE_NOT_FOUND);
23330
23542
  }
23331
23543
  let yamlSource;
23332
23544
  try {
23333
- yamlSource = readFileSync24(absPath, "utf8");
23545
+ yamlSource = readFileSync25(absPath, "utf8");
23334
23546
  } catch (err) {
23335
23547
  printError(
23336
23548
  `failed to read ${absPath}: ${err.message}`
@@ -23378,7 +23590,7 @@ init_output();
23378
23590
  init_host_cp();
23379
23591
  import * as fs35 from "node:fs";
23380
23592
  import * as path38 from "node:path";
23381
- import { spawnSync as spawnSync13 } from "node:child_process";
23593
+ import { spawnSync as spawnSync14 } from "node:child_process";
23382
23594
  import ora7 from "ora";
23383
23595
  import pc18 from "picocolors";
23384
23596
 
@@ -23386,7 +23598,7 @@ import pc18 from "picocolors";
23386
23598
  import * as fs33 from "node:fs";
23387
23599
  import * as os19 from "node:os";
23388
23600
  import * as path36 from "node:path";
23389
- import { spawnSync as spawnSync12 } from "node:child_process";
23601
+ import { spawnSync as spawnSync13 } from "node:child_process";
23390
23602
  var LOCK_FILE_PATH = path36.join(os19.homedir(), ".olam", ".upgrade.lock");
23391
23603
  var STALE_LOCK_TIMEOUT_MS = 5 * 60 * 1e3;
23392
23604
  function readLockFile(lockPath) {
@@ -23411,7 +23623,7 @@ function isPidAlive2(pid) {
23411
23623
  }
23412
23624
  var PS_UNAVAILABLE = "__ps_unavailable__";
23413
23625
  function getPidCommand(pid) {
23414
- const result = spawnSync12("ps", ["-p", String(pid), "-o", "comm="], {
23626
+ const result = spawnSync13("ps", ["-p", String(pid), "-o", "comm="], {
23415
23627
  encoding: "utf-8",
23416
23628
  stdio: ["ignore", "pipe", "ignore"]
23417
23629
  });
@@ -23670,7 +23882,7 @@ function extractBundleHash(indexHtml) {
23670
23882
  function runStep2(label, cmd, args, opts = {}) {
23671
23883
  const start = Date.now();
23672
23884
  process.stdout.write(` ${pc18.dim(label.padEnd(34))}`);
23673
- const result = spawnSync13(cmd, [...args], {
23885
+ const result = spawnSync14(cmd, [...args], {
23674
23886
  encoding: "utf-8",
23675
23887
  stdio: ["ignore", "pipe", "pipe"],
23676
23888
  cwd: opts.cwd ?? process.cwd(),
@@ -23689,7 +23901,7 @@ function runStep2(label, cmd, args, opts = {}) {
23689
23901
  };
23690
23902
  }
23691
23903
  function isGitDirty(cwd) {
23692
- const result = spawnSync13("git", ["status", "--porcelain"], {
23904
+ const result = spawnSync14("git", ["status", "--porcelain"], {
23693
23905
  encoding: "utf-8",
23694
23906
  stdio: ["ignore", "pipe", "pipe"],
23695
23907
  cwd
@@ -23697,7 +23909,7 @@ function isGitDirty(cwd) {
23697
23909
  return (result.stdout ?? "").trim().length > 0;
23698
23910
  }
23699
23911
  function hasGitUpstream(cwd) {
23700
- const result = spawnSync13("git", ["rev-parse", "--abbrev-ref", "@{u}"], {
23912
+ const result = spawnSync14("git", ["rev-parse", "--abbrev-ref", "@{u}"], {
23701
23913
  encoding: "utf-8",
23702
23914
  stdio: ["ignore", "pipe", "pipe"],
23703
23915
  cwd
@@ -23705,7 +23917,7 @@ function hasGitUpstream(cwd) {
23705
23917
  return result.status === 0;
23706
23918
  }
23707
23919
  function captureHeadSha(cwd) {
23708
- const result = spawnSync13("git", ["rev-parse", "HEAD"], {
23920
+ const result = spawnSync14("git", ["rev-parse", "HEAD"], {
23709
23921
  encoding: "utf-8",
23710
23922
  stdio: ["ignore", "pipe", "pipe"],
23711
23923
  cwd
@@ -23720,7 +23932,7 @@ function abbreviateSha(sha) {
23720
23932
  }
23721
23933
  function imageExists(tag) {
23722
23934
  try {
23723
- const result = spawnSync13("docker", ["image", "inspect", "--format", "{{.Id}}", tag], {
23935
+ const result = spawnSync14("docker", ["image", "inspect", "--format", "{{.Id}}", tag], {
23724
23936
  encoding: "utf-8",
23725
23937
  stdio: ["ignore", "pipe", "ignore"]
23726
23938
  });
@@ -23736,7 +23948,7 @@ function checkRollbackSetExists(plan) {
23736
23948
  }
23737
23949
  var SMOKE_DOCKER_TIMEOUT_MS = 3e4;
23738
23950
  function smokeImage(image, targetSha) {
23739
- const createResult = spawnSync13("docker", ["create", "--name", `olam-smoke-${Date.now()}`, image], {
23951
+ const createResult = spawnSync14("docker", ["create", "--name", `olam-smoke-${Date.now()}`, image], {
23740
23952
  encoding: "utf-8",
23741
23953
  stdio: ["ignore", "pipe", "pipe"],
23742
23954
  timeout: SMOKE_DOCKER_TIMEOUT_MS
@@ -23750,7 +23962,7 @@ function smokeImage(image, targetSha) {
23750
23962
  };
23751
23963
  }
23752
23964
  const containerId = (createResult.stdout ?? "").trim();
23753
- const inspectResult = spawnSync13(
23965
+ const inspectResult = spawnSync14(
23754
23966
  "docker",
23755
23967
  ["inspect", "--format", '{{index .Config.Labels "olam.build.sha"}}', image],
23756
23968
  {
@@ -23760,7 +23972,7 @@ function smokeImage(image, targetSha) {
23760
23972
  }
23761
23973
  );
23762
23974
  if (containerId.length > 0) {
23763
- spawnSync13("docker", ["rm", "-f", containerId], {
23975
+ spawnSync14("docker", ["rm", "-f", containerId], {
23764
23976
  encoding: "utf-8",
23765
23977
  stdio: ["ignore", "ignore", "ignore"],
23766
23978
  timeout: SMOKE_DOCKER_TIMEOUT_MS
@@ -23800,7 +24012,7 @@ var PRODUCTION_SWAP_PLAN = [
23800
24012
  ];
23801
24013
  function dockerTag(source, dest) {
23802
24014
  try {
23803
- const result = spawnSync13("docker", ["tag", source, dest], {
24015
+ const result = spawnSync14("docker", ["tag", source, dest], {
23804
24016
  encoding: "utf-8",
23805
24017
  stdio: ["ignore", "ignore", "pipe"]
23806
24018
  });
@@ -23964,11 +24176,11 @@ async function waitForAuthHealthLocal(timeoutMs = AUTH_HEALTH_TIMEOUT_MS) {
23964
24176
  async function recreateAuthService() {
23965
24177
  const start = Date.now();
23966
24178
  try {
23967
- spawnSync13("docker", ["stop", "olam-auth"], {
24179
+ spawnSync14("docker", ["stop", "olam-auth"], {
23968
24180
  encoding: "utf-8",
23969
24181
  stdio: ["ignore", "ignore", "ignore"]
23970
24182
  });
23971
- spawnSync13("docker", ["rm", "olam-auth"], {
24183
+ spawnSync14("docker", ["rm", "olam-auth"], {
23972
24184
  encoding: "utf-8",
23973
24185
  stdio: ["ignore", "ignore", "ignore"]
23974
24186
  });
@@ -24227,11 +24439,11 @@ async function defaultRecreateMcpAuthForUpgrade() {
24227
24439
  }
24228
24440
  async function defaultRecreateAuthForUpgrade() {
24229
24441
  try {
24230
- spawnSync13("docker", ["stop", "olam-auth"], {
24442
+ spawnSync14("docker", ["stop", "olam-auth"], {
24231
24443
  encoding: "utf-8",
24232
24444
  stdio: ["ignore", "ignore", "ignore"]
24233
24445
  });
24234
- spawnSync13("docker", ["rm", "olam-auth"], {
24446
+ spawnSync14("docker", ["rm", "olam-auth"], {
24235
24447
  encoding: "utf-8",
24236
24448
  stdio: ["ignore", "ignore", "ignore"]
24237
24449
  });
@@ -24577,7 +24789,7 @@ ${spaResult.stderr}`);
24577
24789
  process.stdout.write(` ${pc18.dim(step.label.padEnd(34))}
24578
24790
  `);
24579
24791
  const start = Date.now();
24580
- const result = spawnSync13("bash", [scriptPath], {
24792
+ const result = spawnSync14("bash", [scriptPath], {
24581
24793
  stdio: "inherit",
24582
24794
  cwd,
24583
24795
  env: { ...process.env, ...olamTagEnv }
@@ -24926,7 +25138,7 @@ function registerLogs(program2) {
24926
25138
  init_context();
24927
25139
  init_output();
24928
25140
  import pc20 from "picocolors";
24929
- import { spawnSync as spawnSync14 } from "node:child_process";
25141
+ import { spawnSync as spawnSync15 } from "node:child_process";
24930
25142
  var SAFE_IDENT4 = /^[a-z0-9][a-z0-9-]{0,63}$/;
24931
25143
  function parseDockerTop(stdout) {
24932
25144
  const trimmed = stdout.trim();
@@ -25026,7 +25238,7 @@ function registerPs(program2) {
25026
25238
  const containerName = `olam-${worldId}-devbox`;
25027
25239
  let watchInterval;
25028
25240
  function fetchAndPrint() {
25029
- const result = spawnSync14(
25241
+ const result = spawnSync15(
25030
25242
  "docker",
25031
25243
  ["top", containerName, "pid", "user", "pcpu", "pmem", "stime", "stat", "cmd"],
25032
25244
  { encoding: "utf-8", timeout: 3e3 }
@@ -25519,7 +25731,7 @@ init_output();
25519
25731
  import * as fs39 from "node:fs";
25520
25732
  import * as os22 from "node:os";
25521
25733
  import * as path42 from "node:path";
25522
- import { spawnSync as spawnSync15 } from "node:child_process";
25734
+ import { spawnSync as spawnSync16 } from "node:child_process";
25523
25735
  import ora8 from "ora";
25524
25736
 
25525
25737
  // src/commands/refresh-helpers.ts
@@ -25563,7 +25775,7 @@ var RESTART_TIMEOUT_S = 30;
25563
25775
  var HEALTH_POLL_MS = 500;
25564
25776
  var HEALTH_TIMEOUT_MS = 3e4;
25565
25777
  function docker(args) {
25566
- const result = spawnSync15("docker", args, {
25778
+ const result = spawnSync16("docker", args, {
25567
25779
  encoding: "utf-8",
25568
25780
  stdio: ["ignore", "pipe", "pipe"]
25569
25781
  });
@@ -25911,9 +26123,9 @@ function registerDiagnose(program2) {
25911
26123
  }
25912
26124
 
25913
26125
  // src/lib/health-probes.ts
25914
- import { spawnSync as spawnSync16 } from "node:child_process";
25915
- import { existsSync as existsSync44, readdirSync as readdirSync11, readFileSync as readFileSync31, statSync as statSync13 } from "node:fs";
25916
- import { homedir as homedir23 } from "node:os";
26126
+ import { spawnSync as spawnSync17 } from "node:child_process";
26127
+ import { existsSync as existsSync45, readdirSync as readdirSync11, readFileSync as readFileSync32, statSync as statSync14 } from "node:fs";
26128
+ import { homedir as homedir24 } from "node:os";
25917
26129
  import path44 from "node:path";
25918
26130
 
25919
26131
  // src/lib/kg-caps.ts
@@ -25923,7 +26135,7 @@ var HARD_CAP_BYTES = 5e9;
25923
26135
  // src/lib/health-probes.ts
25924
26136
  var HEALTH_TIMEOUT_MS2 = 5e3;
25925
26137
  var defaultDockerExec2 = (cmd, args) => {
25926
- const r = spawnSync16(cmd, [...args], {
26138
+ const r = spawnSync17(cmd, [...args], {
25927
26139
  encoding: "utf-8",
25928
26140
  stdio: ["ignore", "pipe", "pipe"]
25929
26141
  });
@@ -26009,7 +26221,7 @@ function isHostCpHealthEnvelope(body) {
26009
26221
  }
26010
26222
  async function probeAuthVault(olamHomeOverride) {
26011
26223
  const vaultPath = resolveAccountsPath(olamHomeOverride);
26012
- if (!existsSync44(vaultPath)) {
26224
+ if (!existsSync45(vaultPath)) {
26013
26225
  return {
26014
26226
  ok: false,
26015
26227
  message: `auth vault missing at ${vaultPath}`,
@@ -26018,7 +26230,7 @@ async function probeAuthVault(olamHomeOverride) {
26018
26230
  }
26019
26231
  let parsed;
26020
26232
  try {
26021
- parsed = JSON.parse(readFileSync31(vaultPath, "utf-8"));
26233
+ parsed = JSON.parse(readFileSync32(vaultPath, "utf-8"));
26022
26234
  } catch (err) {
26023
26235
  return {
26024
26236
  ok: false,
@@ -26048,7 +26260,7 @@ async function probeAuthVault(olamHomeOverride) {
26048
26260
  function resolveAccountsPath(olamHomeOverride) {
26049
26261
  const explicit = process.env.OLAM_AUTH_DATA_PATH;
26050
26262
  if (explicit) return explicit;
26051
- const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(homedir23(), ".olam");
26263
+ const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(homedir24(), ".olam");
26052
26264
  return path44.join(olamHome5, "auth-data", "accounts.json");
26053
26265
  }
26054
26266
  function effectiveState2(account, now) {
@@ -26062,7 +26274,7 @@ function effectiveState2(account, now) {
26062
26274
  return persisted;
26063
26275
  }
26064
26276
  async function probeKgStorage(olamHomeOverride) {
26065
- const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(homedir23(), ".olam");
26277
+ const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(homedir24(), ".olam");
26066
26278
  const kgRoot3 = path44.join(olamHome5, "kg");
26067
26279
  const worldsRoot3 = path44.join(olamHome5, "worlds");
26068
26280
  const kgBytes = enumerateGraphifyOut(kgRoot3, "pristine");
@@ -26084,7 +26296,7 @@ async function probeKgStorage(olamHomeOverride) {
26084
26296
  return { ok: true, message: `KG storage ${formatBytes4(totalBytes)} (under cap)` };
26085
26297
  }
26086
26298
  function enumerateGraphifyOut(root, layout) {
26087
- if (!existsSync44(root)) return 0;
26299
+ if (!existsSync45(root)) return 0;
26088
26300
  let total = 0;
26089
26301
  let entries;
26090
26302
  try {
@@ -26113,7 +26325,7 @@ function enumerateGraphifyOut(root, layout) {
26113
26325
  return total;
26114
26326
  }
26115
26327
  function dirSizeBytes(dir) {
26116
- if (!existsSync44(dir)) return 0;
26328
+ if (!existsSync45(dir)) return 0;
26117
26329
  let total = 0;
26118
26330
  const stack = [dir];
26119
26331
  while (stack.length > 0) {
@@ -26132,7 +26344,7 @@ function dirSizeBytes(dir) {
26132
26344
  continue;
26133
26345
  }
26134
26346
  try {
26135
- total += statSync13(full).size;
26347
+ total += statSync14(full).size;
26136
26348
  } catch {
26137
26349
  }
26138
26350
  }
@@ -26369,20 +26581,20 @@ function registerCompletion(program2) {
26369
26581
  // src/commands/setup.ts
26370
26582
  init_cli_version();
26371
26583
  import { spawn as spawn5 } from "node:child_process";
26372
- import { existsSync as existsSync46 } from "node:fs";
26373
- import { homedir as homedir24 } from "node:os";
26584
+ import { existsSync as existsSync47 } from "node:fs";
26585
+ import { homedir as homedir25 } from "node:os";
26374
26586
  import path46 from "node:path";
26375
26587
  import { createInterface as createInterface3 } from "node:readline";
26376
26588
 
26377
26589
  // src/lib/shell-rc.ts
26378
- import { copyFileSync as copyFileSync5, existsSync as existsSync45, readFileSync as readFileSync32, renameSync as renameSync4, writeFileSync as writeFileSync20 } from "node:fs";
26590
+ import { copyFileSync as copyFileSync5, existsSync as existsSync46, readFileSync as readFileSync33, renameSync as renameSync5, writeFileSync as writeFileSync21 } from "node:fs";
26379
26591
  import path45 from "node:path";
26380
26592
  function appendIdempotent(opts) {
26381
26593
  const { rcPath, marker, contentLine, clock = () => /* @__PURE__ */ new Date() } = opts;
26382
- if (!existsSync45(rcPath)) {
26594
+ if (!existsSync46(rcPath)) {
26383
26595
  return { status: "no-rc-file", backupPath: null };
26384
26596
  }
26385
- const content = readFileSync32(rcPath, "utf-8");
26597
+ const content = readFileSync33(rcPath, "utf-8");
26386
26598
  if (content.includes(marker)) {
26387
26599
  return { status: "already-present", backupPath: null };
26388
26600
  }
@@ -26393,8 +26605,8 @@ function appendIdempotent(opts) {
26393
26605
  const trailing = contentLine.endsWith("\n") ? "" : "\n";
26394
26606
  const nextContent = `${content}${separator}${contentLine}${trailing}`;
26395
26607
  const tmpPath = `${rcPath}.olam-tmp.${process.pid}`;
26396
- writeFileSync20(tmpPath, nextContent, { encoding: "utf-8" });
26397
- renameSync4(tmpPath, rcPath);
26608
+ writeFileSync21(tmpPath, nextContent, { encoding: "utf-8" });
26609
+ renameSync5(tmpPath, rcPath);
26398
26610
  return { status: "appended", backupPath };
26399
26611
  }
26400
26612
  function resolveShellRc(home, shellEnv) {
@@ -26503,7 +26715,7 @@ async function phase4ShellInit(opts, deps) {
26503
26715
  if (opts.skipShellInit) {
26504
26716
  return { ok: true, skipped: true, message: "skipped via --skip-shell-init" };
26505
26717
  }
26506
- const home = deps.home ?? homedir24();
26718
+ const home = deps.home ?? homedir25();
26507
26719
  const shellEnv = deps.shellEnv ?? process.env.SHELL;
26508
26720
  const rcPath = resolveShellRc(home, shellEnv);
26509
26721
  if (rcPath === null) {
@@ -26540,7 +26752,7 @@ async function phase5InitProject(opts, deps) {
26540
26752
  const cwd = deps.cwd ?? process.cwd();
26541
26753
  const projectRoot = findProjectRoot(cwd);
26542
26754
  const configPath = path46.join(projectRoot, ".olam", "config.yaml");
26543
- if (existsSync46(configPath)) {
26755
+ if (existsSync47(configPath)) {
26544
26756
  return { ok: true, message: `${configPath} present (no change)` };
26545
26757
  }
26546
26758
  const promptFn = deps.prompt ?? defaultPrompt;
@@ -27406,17 +27618,17 @@ function registerWorldUpgrade(program2) {
27406
27618
 
27407
27619
  // src/commands/mcp/serve.ts
27408
27620
  init_output();
27409
- import { existsSync as existsSync51 } from "node:fs";
27410
- import { dirname as dirname25, resolve as resolve13 } from "node:path";
27621
+ import { existsSync as existsSync52 } from "node:fs";
27622
+ import { dirname as dirname26, resolve as resolve13 } from "node:path";
27411
27623
  import { fileURLToPath as fileURLToPath6 } from "node:url";
27412
- var here = dirname25(fileURLToPath6(import.meta.url));
27624
+ var here = dirname26(fileURLToPath6(import.meta.url));
27413
27625
  var BUNDLE_PATH_CANDIDATES = [
27414
27626
  // bundled (`dist/index.js` after bundle-cli.mjs) — sibling
27415
27627
  resolve13(here, "mcp-server.js"),
27416
27628
  // dev / tsc-only (`dist/commands/mcp/serve.js`) — up two levels
27417
27629
  resolve13(here, "..", "..", "mcp-server.js")
27418
27630
  ];
27419
- function resolveBundlePath(candidates2 = BUNDLE_PATH_CANDIDATES, exists = existsSync51) {
27631
+ function resolveBundlePath(candidates2 = BUNDLE_PATH_CANDIDATES, exists = existsSync52) {
27420
27632
  return candidates2.find(exists) ?? null;
27421
27633
  }
27422
27634
  var MISSING_BUNDLE_REMEDY = "olam mcp server bundle missing. Searched: " + BUNDLE_PATH_CANDIDATES.join(", ") + ". For local dev, run: node packages/cli/scripts/bundle-mcp-server.mjs. A fresh `npm install -g @pleri/olam-cli@latest` should always include the bundle (see prepublishOnly in packages/cli/package.json); file an issue if it does not.";
@@ -27438,9 +27650,9 @@ function registerMcpServe(cmd) {
27438
27650
  init_output();
27439
27651
 
27440
27652
  // src/commands/mcp/install-shared.ts
27441
- import { spawnSync as spawnSync17 } from "node:child_process";
27653
+ import { spawnSync as spawnSync18 } from "node:child_process";
27442
27654
  var DEFAULT_CLAUDE_SHELL_DEPS = {
27443
- spawn: spawnSync17,
27655
+ spawn: spawnSync18,
27444
27656
  log: (msg) => console.log(msg)
27445
27657
  };
27446
27658
  function isOnPath(deps, bin) {
@@ -28159,65 +28371,6 @@ import { spawn as spawn8 } from "node:child_process";
28159
28371
  import { existsSync as existsSync54, mkdirSync as mkdirSync30, openSync as openSync3, readFileSync as readFileSync38, writeFileSync as writeFileSync24 } from "node:fs";
28160
28372
  import { join as join52 } from "node:path";
28161
28373
 
28162
- // src/lib/memory-secret.ts
28163
- import { existsSync as existsSync53, mkdirSync as mkdirSync29, readFileSync as readFileSync37, statSync as statSync14, writeFileSync as writeFileSync23, renameSync as renameSync5, chmodSync as chmodSync4 } from "node:fs";
28164
- import { homedir as homedir29 } from "node:os";
28165
- import { join as join50, dirname as dirname26 } from "node:path";
28166
- import { randomBytes as randomBytes6 } from "node:crypto";
28167
- var MEMORY_SECRET_PATH = join50(homedir29(), ".olam", "memory-secret");
28168
- var SECRET_LEN_BYTES = 32;
28169
- function generateSecret() {
28170
- return randomBytes6(SECRET_LEN_BYTES).toString("hex");
28171
- }
28172
- function writeSecretAtPath(path56, value) {
28173
- mkdirSync29(dirname26(path56), { recursive: true });
28174
- const tmp = `${path56}.tmp.${process.pid}`;
28175
- writeFileSync23(tmp, value, { mode: 384 });
28176
- chmodSync4(tmp, 384);
28177
- renameSync5(tmp, path56);
28178
- }
28179
- function readSecretAtPathOrNull(path56) {
28180
- if (!existsSync53(path56)) return null;
28181
- const mode = statSync14(path56).mode & 511;
28182
- if (mode !== 384) {
28183
- process.stderr.write(
28184
- `warn: ${path56} has mode 0${mode.toString(8)}; expected 0600. Run 'olam memory secret rotate' to regenerate.
28185
- `
28186
- );
28187
- }
28188
- return readFileSync37(path56, "utf8").trim();
28189
- }
28190
- function readSecretAtPath(path56) {
28191
- const v = readSecretAtPathOrNull(path56);
28192
- if (v === null) {
28193
- throw new Error(
28194
- `Secret not found at ${path56}. Run 'olam memory start' to generate it.`
28195
- );
28196
- }
28197
- return v;
28198
- }
28199
- function ensureMemorySecret(path56 = MEMORY_SECRET_PATH) {
28200
- const existing = readSecretAtPathOrNull(path56);
28201
- if (existing) return existing;
28202
- const fresh = generateSecret();
28203
- writeSecretAtPath(path56, fresh);
28204
- return fresh;
28205
- }
28206
- function readMemorySecretOrNull(path56 = MEMORY_SECRET_PATH) {
28207
- return readSecretAtPathOrNull(path56);
28208
- }
28209
- function readMemorySecret(path56 = MEMORY_SECRET_PATH) {
28210
- return readSecretAtPath(path56);
28211
- }
28212
- function rotateMemorySecret(path56 = MEMORY_SECRET_PATH) {
28213
- const fresh = generateSecret();
28214
- writeSecretAtPath(path56, fresh);
28215
- return fresh;
28216
- }
28217
- function hasMemorySecret(path56 = MEMORY_SECRET_PATH) {
28218
- return existsSync53(path56);
28219
- }
28220
-
28221
28374
  // src/commands/memory/_paths.ts
28222
28375
  import { homedir as homedir30 } from "node:os";
28223
28376
  import { join as join51, dirname as dirname27 } from "node:path";
@@ -28550,7 +28703,7 @@ async function runMemorySecretShow() {
28550
28703
  );
28551
28704
  return 1;
28552
28705
  }
28553
- process.stdout.write(`${readMemorySecret()}
28706
+ process.stdout.write(`${readMemorySecret2()}
28554
28707
  `);
28555
28708
  return 0;
28556
28709
  }
@@ -28602,7 +28755,7 @@ function registerMemorySecret(cmd) {
28602
28755
 
28603
28756
  // src/commands/memory/install.ts
28604
28757
  init_output();
28605
- var MCP_NAME = "agentmemory";
28758
+ var MCP_NAME2 = "agentmemory";
28606
28759
  var NPM_PACKAGE_NAME2 = "@agentmemory/mcp";
28607
28760
  var DEFAULT_SECRET_READER = () => readMemorySecretOrNull();
28608
28761
  function buildClaudeMcpAddArgs2(scope, agentmemoryUrl, secret) {
@@ -28611,7 +28764,7 @@ function buildClaudeMcpAddArgs2(scope, agentmemoryUrl, secret) {
28611
28764
  args: [
28612
28765
  "mcp",
28613
28766
  "add",
28614
- MCP_NAME,
28767
+ MCP_NAME2,
28615
28768
  "--scope",
28616
28769
  scope,
28617
28770
  "--env",
@@ -28681,11 +28834,11 @@ function registerMemoryInstall(cmd) {
28681
28834
 
28682
28835
  // src/commands/memory/uninstall.ts
28683
28836
  init_output();
28684
- var MCP_NAME2 = "agentmemory";
28837
+ var MCP_NAME3 = "agentmemory";
28685
28838
  function buildClaudeMcpRemoveArgs2(scope) {
28686
28839
  return {
28687
28840
  command: "claude",
28688
- args: ["mcp", "remove", MCP_NAME2, "--scope", scope]
28841
+ args: ["mcp", "remove", MCP_NAME3, "--scope", scope]
28689
28842
  };
28690
28843
  }
28691
28844
  async function runUninstall2(opts, deps = DEFAULT_CLAUDE_SHELL_DEPS) {
@@ -28753,7 +28906,7 @@ function registerMemory(program2) {
28753
28906
  init_storage_paths();
28754
28907
  init_workspace_name();
28755
28908
  init_output();
28756
- import { spawnSync as spawnSync18 } from "node:child_process";
28909
+ import { spawnSync as spawnSync19 } from "node:child_process";
28757
28910
  import fs49 from "node:fs";
28758
28911
  import path54 from "node:path";
28759
28912
 
@@ -29151,13 +29304,13 @@ function resolveWorkspace(arg) {
29151
29304
  }
29152
29305
  function copyWorkspaceToScratch(source, scratch) {
29153
29306
  if (process.platform === "darwin") {
29154
- const r2 = spawnSync18("cp", ["-c", "-r", source + "/.", scratch], {
29307
+ const r2 = spawnSync19("cp", ["-c", "-r", source + "/.", scratch], {
29155
29308
  stdio: ["ignore", "ignore", "pipe"],
29156
29309
  encoding: "utf-8"
29157
29310
  });
29158
29311
  if (r2.status === 0) return "cp-c-r-reflink";
29159
29312
  }
29160
- const r = spawnSync18("cp", ["-r", source + "/.", scratch], {
29313
+ const r = spawnSync19("cp", ["-r", source + "/.", scratch], {
29161
29314
  stdio: ["ignore", "ignore", "pipe"],
29162
29315
  encoding: "utf-8"
29163
29316
  });
@@ -29178,7 +29331,7 @@ function parseNodeCount(graphifyOutDir) {
29178
29331
  }
29179
29332
  }
29180
29333
  function readGraphifyVersion(image) {
29181
- const r = spawnSync18(
29334
+ const r = spawnSync19(
29182
29335
  "docker",
29183
29336
  [
29184
29337
  "run",
@@ -29230,7 +29383,7 @@ async function runKgBuild(workspaceArg, options = {}) {
29230
29383
  "update",
29231
29384
  "."
29232
29385
  ];
29233
- const r = human ? spawnSync18("docker", dockerArgs, { stdio: "inherit" }) : spawnSync18("docker", dockerArgs, { stdio: ["ignore", "ignore", "pipe"] });
29386
+ const r = human ? spawnSync19("docker", dockerArgs, { stdio: "inherit" }) : spawnSync19("docker", dockerArgs, { stdio: ["ignore", "ignore", "pipe"] });
29234
29387
  if (r.status !== 0) {
29235
29388
  printError(`graphify update failed (exit ${r.status})`);
29236
29389
  return { exitCode: r.status ?? 1 };
@@ -29288,7 +29441,7 @@ function registerKg(program2) {
29288
29441
 
29289
29442
  // src/commands/seed.ts
29290
29443
  init_output();
29291
- import { spawnSync as spawnSync19, spawn as spawnAsync2 } from "node:child_process";
29444
+ import { spawnSync as spawnSync20, spawn as spawnAsync2 } from "node:child_process";
29292
29445
  var DEFAULT_SINGLETON_CONTAINER = "olam-postgres";
29293
29446
  var DEFAULT_SINGLETON_USER = "development";
29294
29447
  function assertValidSeedName(name) {
@@ -29299,7 +29452,7 @@ function assertValidSeedName(name) {
29299
29452
  }
29300
29453
  }
29301
29454
  function singletonDocker(container, user, args, stdin) {
29302
- return spawnSync19(
29455
+ return spawnSync20(
29303
29456
  "docker",
29304
29457
  ["exec", "-i", container, "psql", "-U", user, ...args],
29305
29458
  { encoding: "utf-8", input: stdin }
@@ -29354,7 +29507,7 @@ async function handleBake(opts) {
29354
29507
  if (sources.length > 1) {
29355
29508
  throw new Error("multiple sources specified \u2014 pass exactly one of --source-container, --source-url, --source-local");
29356
29509
  }
29357
- const ping = spawnSync19("docker", ["inspect", "--format", "{{.State.Status}}", singleton], { encoding: "utf-8" });
29510
+ const ping = spawnSync20("docker", ["inspect", "--format", "{{.State.Status}}", singleton], { encoding: "utf-8" });
29358
29511
  if (ping.status !== 0 || (ping.stdout || "").trim() !== "running") {
29359
29512
  throw new Error(`singleton container "${singleton}" not running \u2014 run \`olam bootstrap\` first`);
29360
29513
  }