@pleri/olam-cli 0.1.125 → 0.1.126
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/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +43 -0
- package/dist/commands/create.js.map +1 -1
- package/dist/image-digests.json +3 -3
- package/dist/index.js +263 -147
- package/dist/lib/world-mcp-register.d.ts +98 -0
- package/dist/lib/world-mcp-register.d.ts.map +1 -0
- package/dist/lib/world-mcp-register.js +117 -0
- package/dist/lib/world-mcp-register.js.map +1 -0
- package/dist/mcp-server.js +21 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5870,6 +5870,17 @@ function readHostCpToken() {
|
|
|
5870
5870
|
return "";
|
|
5871
5871
|
}
|
|
5872
5872
|
}
|
|
5873
|
+
function readMemorySecret() {
|
|
5874
|
+
const fromEnv = process.env["OLAM_MEMORY_SECRET"];
|
|
5875
|
+
if (fromEnv && fromEnv.length > 0)
|
|
5876
|
+
return fromEnv;
|
|
5877
|
+
const file = path11.join(os6.homedir(), ".olam", "memory-secret");
|
|
5878
|
+
try {
|
|
5879
|
+
return fs10.readFileSync(file, "utf-8").trim();
|
|
5880
|
+
} catch {
|
|
5881
|
+
return "";
|
|
5882
|
+
}
|
|
5883
|
+
}
|
|
5873
5884
|
function sanitizeContainerName(name) {
|
|
5874
5885
|
return name.replace(/[^a-zA-Z0-9_.-]/g, "-");
|
|
5875
5886
|
}
|
|
@@ -5917,7 +5928,7 @@ async function auditPortsForZombies(docker2, hostPorts) {
|
|
|
5917
5928
|
}
|
|
5918
5929
|
}
|
|
5919
5930
|
}
|
|
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;
|
|
5931
|
+
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
5932
|
var init_container2 = __esm({
|
|
5922
5933
|
"../adapters/dist/docker/container.js"() {
|
|
5923
5934
|
"use strict";
|
|
@@ -5925,6 +5936,7 @@ var init_container2 = __esm({
|
|
|
5925
5936
|
init_pull();
|
|
5926
5937
|
init_volume();
|
|
5927
5938
|
realPullImage = (imageRef, platform) => pullImageWithRetry(imageRef, void 0, platform ? { perAttemptTimeoutMs: 18e4, retryOnce: true, platform } : { perAttemptTimeoutMs: 18e4, retryOnce: true });
|
|
5939
|
+
AGENTMEMORY_HOST_INTERNAL_URL = "http://host.docker.internal:3111";
|
|
5928
5940
|
serviceContainerName = (worldId, serviceName) => `olam-${sanitizeContainerName(worldId)}-${sanitizeContainerName(serviceName)}`;
|
|
5929
5941
|
worldContainerName = (worldId) => `olam-${sanitizeContainerName(worldId)}-devbox`;
|
|
5930
5942
|
miseCacheVolumeName = (arch2 = process.arch) => `olam-mise-cache-${arch2}`;
|
|
@@ -6007,6 +6019,7 @@ var init_container2 = __esm({
|
|
|
6007
6019
|
const labels = olamLabels(worldId, worldName);
|
|
6008
6020
|
const authSecret = readAuthSecret();
|
|
6009
6021
|
const hostCpToken = readHostCpToken();
|
|
6022
|
+
const memorySecret = readMemorySecret();
|
|
6010
6023
|
const worldEnv = {
|
|
6011
6024
|
OLAM_WORLD_ID: worldId,
|
|
6012
6025
|
OLAM_WORLD_NAME: worldName,
|
|
@@ -6023,6 +6036,14 @@ var init_container2 = __esm({
|
|
|
6023
6036
|
OLAM_HOST_CP_URL: "http://host.docker.internal:19000",
|
|
6024
6037
|
...authSecret ? { OLAM_AUTH_SECRET: authSecret } : {},
|
|
6025
6038
|
...hostCpToken ? { OLAM_HOST_CP_TOKEN: hostCpToken } : {},
|
|
6039
|
+
// Phase B1 — agent-memory wiring. Both vars are injected together
|
|
6040
|
+
// (or neither): without a secret the URL is useless. The in-world
|
|
6041
|
+
// @agentmemory/mcp shim (Phase B2/B3) reads these env vars to find
|
|
6042
|
+
// the host's REST endpoint.
|
|
6043
|
+
...memorySecret ? {
|
|
6044
|
+
AGENTMEMORY_URL: AGENTMEMORY_HOST_INTERNAL_URL,
|
|
6045
|
+
AGENTMEMORY_SECRET: memorySecret
|
|
6046
|
+
} : {},
|
|
6026
6047
|
...env
|
|
6027
6048
|
};
|
|
6028
6049
|
const envList = Object.entries(worldEnv).map(([k, v]) => `${k}=${v}`);
|
|
@@ -16888,9 +16909,9 @@ ${pc9.dim("Next: olam create --name my-world")}`);
|
|
|
16888
16909
|
|
|
16889
16910
|
// src/commands/create.ts
|
|
16890
16911
|
init_manager();
|
|
16891
|
-
import { spawnSync as
|
|
16892
|
-
import { existsSync as
|
|
16893
|
-
import { dirname as
|
|
16912
|
+
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
16913
|
+
import { existsSync as existsSync29 } from "node:fs";
|
|
16914
|
+
import { dirname as dirname19, resolve as resolve12 } from "node:path";
|
|
16894
16915
|
import ora3 from "ora";
|
|
16895
16916
|
import pc10 from "picocolors";
|
|
16896
16917
|
|
|
@@ -17124,6 +17145,132 @@ function decideWorkspaceMatch(input) {
|
|
|
17124
17145
|
init_context();
|
|
17125
17146
|
init_output();
|
|
17126
17147
|
init_host_cp();
|
|
17148
|
+
|
|
17149
|
+
// src/lib/memory-secret.ts
|
|
17150
|
+
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";
|
|
17151
|
+
import { homedir as homedir17 } from "node:os";
|
|
17152
|
+
import { join as join34, dirname as dirname18 } from "node:path";
|
|
17153
|
+
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
17154
|
+
var MEMORY_SECRET_PATH = join34(homedir17(), ".olam", "memory-secret");
|
|
17155
|
+
var SECRET_LEN_BYTES = 32;
|
|
17156
|
+
function generateSecret() {
|
|
17157
|
+
return randomBytes6(SECRET_LEN_BYTES).toString("hex");
|
|
17158
|
+
}
|
|
17159
|
+
function writeSecretAtPath(path56, value) {
|
|
17160
|
+
mkdirSync17(dirname18(path56), { recursive: true });
|
|
17161
|
+
const tmp = `${path56}.tmp.${process.pid}`;
|
|
17162
|
+
writeFileSync13(tmp, value, { mode: 384 });
|
|
17163
|
+
chmodSync3(tmp, 384);
|
|
17164
|
+
renameSync4(tmp, path56);
|
|
17165
|
+
}
|
|
17166
|
+
function readSecretAtPathOrNull(path56) {
|
|
17167
|
+
if (!existsSync28(path56)) return null;
|
|
17168
|
+
const mode = statSync7(path56).mode & 511;
|
|
17169
|
+
if (mode !== 384) {
|
|
17170
|
+
process.stderr.write(
|
|
17171
|
+
`warn: ${path56} has mode 0${mode.toString(8)}; expected 0600. Run 'olam memory secret rotate' to regenerate.
|
|
17172
|
+
`
|
|
17173
|
+
);
|
|
17174
|
+
}
|
|
17175
|
+
return readFileSync20(path56, "utf8").trim();
|
|
17176
|
+
}
|
|
17177
|
+
function readSecretAtPath(path56) {
|
|
17178
|
+
const v = readSecretAtPathOrNull(path56);
|
|
17179
|
+
if (v === null) {
|
|
17180
|
+
throw new Error(
|
|
17181
|
+
`Secret not found at ${path56}. Run 'olam memory start' to generate it.`
|
|
17182
|
+
);
|
|
17183
|
+
}
|
|
17184
|
+
return v;
|
|
17185
|
+
}
|
|
17186
|
+
function ensureMemorySecret(path56 = MEMORY_SECRET_PATH) {
|
|
17187
|
+
const existing = readSecretAtPathOrNull(path56);
|
|
17188
|
+
if (existing) return existing;
|
|
17189
|
+
const fresh = generateSecret();
|
|
17190
|
+
writeSecretAtPath(path56, fresh);
|
|
17191
|
+
return fresh;
|
|
17192
|
+
}
|
|
17193
|
+
function readMemorySecretOrNull(path56 = MEMORY_SECRET_PATH) {
|
|
17194
|
+
return readSecretAtPathOrNull(path56);
|
|
17195
|
+
}
|
|
17196
|
+
function readMemorySecret2(path56 = MEMORY_SECRET_PATH) {
|
|
17197
|
+
return readSecretAtPath(path56);
|
|
17198
|
+
}
|
|
17199
|
+
function rotateMemorySecret(path56 = MEMORY_SECRET_PATH) {
|
|
17200
|
+
const fresh = generateSecret();
|
|
17201
|
+
writeSecretAtPath(path56, fresh);
|
|
17202
|
+
return fresh;
|
|
17203
|
+
}
|
|
17204
|
+
function hasMemorySecret(path56 = MEMORY_SECRET_PATH) {
|
|
17205
|
+
return existsSync28(path56);
|
|
17206
|
+
}
|
|
17207
|
+
|
|
17208
|
+
// src/lib/world-mcp-register.ts
|
|
17209
|
+
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
17210
|
+
var DEFAULT_DOCKER_EXEC_DEPS = {
|
|
17211
|
+
spawn: spawnSync11,
|
|
17212
|
+
log: (msg) => console.log(msg)
|
|
17213
|
+
};
|
|
17214
|
+
var MCP_NAME = "agentmemory";
|
|
17215
|
+
var MCP_BIN = "agentmemory-mcp";
|
|
17216
|
+
function probeMcpListed(containerName, deps) {
|
|
17217
|
+
const result = deps.spawn(
|
|
17218
|
+
"docker",
|
|
17219
|
+
["exec", containerName, "claude", "mcp", "list"],
|
|
17220
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
17221
|
+
);
|
|
17222
|
+
if (result.status !== 0) return "unknown";
|
|
17223
|
+
const combined = `${result.stdout ?? ""}
|
|
17224
|
+
${result.stderr ?? ""}`;
|
|
17225
|
+
return new RegExp(`^\\s*${MCP_NAME}\\b`, "m").test(combined) ? "present" : "absent";
|
|
17226
|
+
}
|
|
17227
|
+
function registerAgentMemoryMcp(opts, deps = DEFAULT_DOCKER_EXEC_DEPS) {
|
|
17228
|
+
if (!opts.agentmemorySecret || opts.agentmemorySecret.length === 0) {
|
|
17229
|
+
return {
|
|
17230
|
+
outcome: "skipped-no-env",
|
|
17231
|
+
reason: "world has no AGENTMEMORY_SECRET (memory service was absent or --skip-memory active at spawn time)"
|
|
17232
|
+
};
|
|
17233
|
+
}
|
|
17234
|
+
const probe2 = probeMcpListed(opts.containerName, deps);
|
|
17235
|
+
if (probe2 === "present") {
|
|
17236
|
+
return { outcome: "already-registered", scope: "user" };
|
|
17237
|
+
}
|
|
17238
|
+
const args = [
|
|
17239
|
+
"exec",
|
|
17240
|
+
opts.containerName,
|
|
17241
|
+
"claude",
|
|
17242
|
+
"mcp",
|
|
17243
|
+
"add",
|
|
17244
|
+
MCP_NAME,
|
|
17245
|
+
"--scope",
|
|
17246
|
+
"user",
|
|
17247
|
+
"--env",
|
|
17248
|
+
`AGENTMEMORY_URL=${opts.agentmemoryUrl}`,
|
|
17249
|
+
"--env",
|
|
17250
|
+
`AGENTMEMORY_SECRET=${opts.agentmemorySecret}`,
|
|
17251
|
+
"--",
|
|
17252
|
+
MCP_BIN
|
|
17253
|
+
];
|
|
17254
|
+
const redacted = args.map(
|
|
17255
|
+
(a) => a.startsWith("AGENTMEMORY_SECRET=") ? "AGENTMEMORY_SECRET=<redacted>" : a
|
|
17256
|
+
);
|
|
17257
|
+
deps.log?.(`Wiring agent-memory MCP in ${opts.containerName}: docker ${redacted.join(" ")}`);
|
|
17258
|
+
const result = deps.spawn("docker", args, {
|
|
17259
|
+
encoding: "utf8",
|
|
17260
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
17261
|
+
});
|
|
17262
|
+
if (result.status === 0) {
|
|
17263
|
+
return { outcome: "registered", scope: "user" };
|
|
17264
|
+
}
|
|
17265
|
+
const detail = (result.stderr?.trim() || result.stdout?.trim() || "(no output)").replace(
|
|
17266
|
+
/AGENTMEMORY_SECRET=\S+/g,
|
|
17267
|
+
"AGENTMEMORY_SECRET=<redacted>"
|
|
17268
|
+
);
|
|
17269
|
+
return { outcome: "failed", rc: result.status ?? 1, detail };
|
|
17270
|
+
}
|
|
17271
|
+
|
|
17272
|
+
// src/commands/create.ts
|
|
17273
|
+
var AGENTMEMORY_LOCAL_URL = "http://host.docker.internal:3111";
|
|
17127
17274
|
var HOST_CP_URL = "http://127.0.0.1:19000";
|
|
17128
17275
|
async function readHostCpTokenForCreate() {
|
|
17129
17276
|
try {
|
|
@@ -17160,7 +17307,7 @@ function registerCreate(program2) {
|
|
|
17160
17307
|
if (decision.stderrLine) {
|
|
17161
17308
|
process.stderr.write(decision.stderrLine + "\n");
|
|
17162
17309
|
}
|
|
17163
|
-
|
|
17310
|
+
spawnSync12("docker", ["pull", overrideRef], { stdio: "pipe" });
|
|
17164
17311
|
const { inspectImageProtocolVersions: inspectImageProtocolVersions2, checkProtocolOverlap: checkProtocolOverlap2 } = await Promise.resolve().then(() => (init_protocol_version(), protocol_version_exports));
|
|
17165
17312
|
const inspect = inspectImageProtocolVersions2(overrideRef);
|
|
17166
17313
|
if (inspect.inspectFailed) {
|
|
@@ -17277,7 +17424,7 @@ function registerCreate(program2) {
|
|
|
17277
17424
|
throw err;
|
|
17278
17425
|
}
|
|
17279
17426
|
const spinner2 = ora3("Rebuilding olam-devbox:latest\u2026").start();
|
|
17280
|
-
const rebuild =
|
|
17427
|
+
const rebuild = spawnSync12(
|
|
17281
17428
|
"bash",
|
|
17282
17429
|
[buildScript],
|
|
17283
17430
|
{ cwd: repoRoot, stdio: "inherit" }
|
|
@@ -17314,6 +17461,34 @@ function registerCreate(program2) {
|
|
|
17314
17461
|
...opts.runbook ? { runbookName: opts.runbook } : {}
|
|
17315
17462
|
});
|
|
17316
17463
|
spinner.succeed("World created");
|
|
17464
|
+
try {
|
|
17465
|
+
const memorySecret = readMemorySecretOrNull() ?? "";
|
|
17466
|
+
const containerName = `olam-${world.id}-devbox`;
|
|
17467
|
+
const result = registerAgentMemoryMcp({
|
|
17468
|
+
containerName,
|
|
17469
|
+
agentmemoryUrl: AGENTMEMORY_LOCAL_URL,
|
|
17470
|
+
agentmemorySecret: memorySecret
|
|
17471
|
+
});
|
|
17472
|
+
switch (result.outcome) {
|
|
17473
|
+
case "registered":
|
|
17474
|
+
printInfo("Agent memory", `MCP registered in-world (--scope ${result.scope})`);
|
|
17475
|
+
break;
|
|
17476
|
+
case "already-registered":
|
|
17477
|
+
printInfo("Agent memory", `MCP already registered (idempotent skip)`);
|
|
17478
|
+
break;
|
|
17479
|
+
case "skipped-no-env":
|
|
17480
|
+
break;
|
|
17481
|
+
case "failed":
|
|
17482
|
+
printWarning(
|
|
17483
|
+
`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.`
|
|
17484
|
+
);
|
|
17485
|
+
break;
|
|
17486
|
+
}
|
|
17487
|
+
} catch (err) {
|
|
17488
|
+
printWarning(
|
|
17489
|
+
`Agent memory MCP registration threw: ${err instanceof Error ? err.message : String(err)}. World is still usable.`
|
|
17490
|
+
);
|
|
17491
|
+
}
|
|
17317
17492
|
if (opts.keepAfterMerge) {
|
|
17318
17493
|
const { WorldRegistry: WorldRegistry2 } = await Promise.resolve().then(() => (init_registry(), registry_exports));
|
|
17319
17494
|
const reg2 = new WorldRegistry2();
|
|
@@ -17484,10 +17659,10 @@ ${pc10.cyan("Host CP UI:")} ${worldUrl}`);
|
|
|
17484
17659
|
function resolveRepoRoot(start) {
|
|
17485
17660
|
let cur = start;
|
|
17486
17661
|
while (true) {
|
|
17487
|
-
if (
|
|
17662
|
+
if (existsSync29(resolve12(cur, "packages")) && existsSync29(resolve12(cur, "package.json"))) {
|
|
17488
17663
|
return cur;
|
|
17489
17664
|
}
|
|
17490
|
-
const parent =
|
|
17665
|
+
const parent = dirname19(cur);
|
|
17491
17666
|
if (parent === cur) return start;
|
|
17492
17667
|
cur = parent;
|
|
17493
17668
|
}
|
|
@@ -20951,7 +21126,7 @@ function registerPolicyCheck(program2) {
|
|
|
20951
21126
|
}
|
|
20952
21127
|
|
|
20953
21128
|
// src/commands/worldspec/compile.ts
|
|
20954
|
-
import { existsSync as
|
|
21129
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
|
|
20955
21130
|
import { resolve as resolvePath } from "node:path";
|
|
20956
21131
|
import YAML5 from "yaml";
|
|
20957
21132
|
|
|
@@ -21754,13 +21929,13 @@ function registerWorldspecCompile(parent) {
|
|
|
21754
21929
|
const sourcePolicies = [];
|
|
21755
21930
|
for (const p of paths) {
|
|
21756
21931
|
const abs = resolvePath(process.cwd(), p);
|
|
21757
|
-
if (!
|
|
21932
|
+
if (!existsSync34(abs)) {
|
|
21758
21933
|
printError(`worldspec not found at ${abs}`);
|
|
21759
21934
|
process.exit(EXIT_WORLDSPEC_FILE_NOT_FOUND);
|
|
21760
21935
|
}
|
|
21761
21936
|
let yaml;
|
|
21762
21937
|
try {
|
|
21763
|
-
yaml = YAML5.parse(
|
|
21938
|
+
yaml = YAML5.parse(readFileSync23(abs, "utf8"));
|
|
21764
21939
|
} catch (err) {
|
|
21765
21940
|
printError(
|
|
21766
21941
|
`${p}: YAML parse error: ${err.message}`
|
|
@@ -21816,13 +21991,13 @@ Resolutions:
|
|
|
21816
21991
|
if (opts.out) {
|
|
21817
21992
|
const outDir = resolvePath(process.cwd(), opts.out);
|
|
21818
21993
|
try {
|
|
21819
|
-
|
|
21820
|
-
|
|
21994
|
+
mkdirSync19(outDir, { recursive: true });
|
|
21995
|
+
writeFileSync15(
|
|
21821
21996
|
resolvePath(outDir, "execution-graph.json"),
|
|
21822
21997
|
graphJson,
|
|
21823
21998
|
"utf8"
|
|
21824
21999
|
);
|
|
21825
|
-
|
|
22000
|
+
writeFileSync15(
|
|
21826
22001
|
resolvePath(outDir, "lockfile.json"),
|
|
21827
22002
|
lockfileJson,
|
|
21828
22003
|
"utf8"
|
|
@@ -21845,7 +22020,7 @@ function getPkgVersion() {
|
|
|
21845
22020
|
// src/commands/worldspec/init.ts
|
|
21846
22021
|
init_exit_codes();
|
|
21847
22022
|
init_output();
|
|
21848
|
-
import { existsSync as
|
|
22023
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync20, readFileSync as readFileSync24, writeFileSync as writeFileSync16 } from "node:fs";
|
|
21849
22024
|
import { execSync as execSync10 } from "node:child_process";
|
|
21850
22025
|
import { basename as basename3, resolve as resolvePath2 } from "node:path";
|
|
21851
22026
|
function registerWorldspecInit(parent) {
|
|
@@ -21863,7 +22038,7 @@ function registerWorldspecInit(parent) {
|
|
|
21863
22038
|
const cwd = process.cwd();
|
|
21864
22039
|
const targetDir = resolvePath2(cwd, ".olam/worldspecs");
|
|
21865
22040
|
const targetFile = resolvePath2(targetDir, "default.yaml");
|
|
21866
|
-
if (
|
|
22041
|
+
if (existsSync35(targetFile) && !opts.force) {
|
|
21867
22042
|
printError(
|
|
21868
22043
|
`${targetFile} already exists; pass --force to overwrite`
|
|
21869
22044
|
);
|
|
@@ -21878,8 +22053,8 @@ function registerWorldspecInit(parent) {
|
|
|
21878
22053
|
const shape = detectProjectShape(cwd, opts.fromAdbYaml);
|
|
21879
22054
|
const yaml = renderWorldspecYaml(shape);
|
|
21880
22055
|
try {
|
|
21881
|
-
|
|
21882
|
-
|
|
22056
|
+
mkdirSync20(targetDir, { recursive: true });
|
|
22057
|
+
writeFileSync16(targetFile, yaml, {
|
|
21883
22058
|
encoding: "utf8",
|
|
21884
22059
|
flag: opts.force ? "w" : "wx"
|
|
21885
22060
|
});
|
|
@@ -21897,14 +22072,14 @@ function registerWorldspecInit(parent) {
|
|
|
21897
22072
|
});
|
|
21898
22073
|
}
|
|
21899
22074
|
function detectProjectShape(root, useAdbYaml) {
|
|
21900
|
-
const hasGemfile =
|
|
21901
|
-
const hasNodePackageJson =
|
|
21902
|
-
const hasAdbYaml =
|
|
22075
|
+
const hasGemfile = existsSync35(resolvePath2(root, "Gemfile"));
|
|
22076
|
+
const hasNodePackageJson = existsSync35(resolvePath2(root, "package.json"));
|
|
22077
|
+
const hasAdbYaml = existsSync35(resolvePath2(root, ".adb.yaml"));
|
|
21903
22078
|
let rubyVersion = null;
|
|
21904
22079
|
const rubyVersionPath = resolvePath2(root, ".ruby-version");
|
|
21905
|
-
if (
|
|
22080
|
+
if (existsSync35(rubyVersionPath)) {
|
|
21906
22081
|
try {
|
|
21907
|
-
const raw =
|
|
22082
|
+
const raw = readFileSync24(rubyVersionPath, "utf8").trim();
|
|
21908
22083
|
const match2 = raw.match(/(\d+\.\d+\.\d+)/);
|
|
21909
22084
|
if (match2) rubyVersion = match2[1] ?? null;
|
|
21910
22085
|
} catch {
|
|
@@ -21976,7 +22151,7 @@ function relativeFromCwd(absPath, cwd) {
|
|
|
21976
22151
|
}
|
|
21977
22152
|
|
|
21978
22153
|
// src/commands/worldspec/schema.ts
|
|
21979
|
-
import { writeFileSync as
|
|
22154
|
+
import { writeFileSync as writeFileSync17 } from "node:fs";
|
|
21980
22155
|
import { resolve as resolvePath3 } from "node:path";
|
|
21981
22156
|
|
|
21982
22157
|
// ../../node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
@@ -23291,7 +23466,7 @@ function registerWorldspecSchema(parent) {
|
|
|
23291
23466
|
if (opts.out) {
|
|
23292
23467
|
const absPath = resolvePath3(process.cwd(), opts.out);
|
|
23293
23468
|
try {
|
|
23294
|
-
|
|
23469
|
+
writeFileSync17(absPath, json + "\n", "utf8");
|
|
23295
23470
|
} catch (err) {
|
|
23296
23471
|
printError(
|
|
23297
23472
|
`failed to write ${absPath}: ${err.message}`
|
|
@@ -23307,7 +23482,7 @@ function registerWorldspecSchema(parent) {
|
|
|
23307
23482
|
}
|
|
23308
23483
|
|
|
23309
23484
|
// src/commands/worldspec/validate.ts
|
|
23310
|
-
import { existsSync as
|
|
23485
|
+
import { existsSync as existsSync36, readFileSync as readFileSync25 } from "node:fs";
|
|
23311
23486
|
import { resolve as resolvePath4 } from "node:path";
|
|
23312
23487
|
init_exit_codes();
|
|
23313
23488
|
init_output();
|
|
@@ -23324,13 +23499,13 @@ function registerWorldspecValidate(parent) {
|
|
|
23324
23499
|
"human"
|
|
23325
23500
|
).action(async (pathArg, opts) => {
|
|
23326
23501
|
const absPath = resolvePath4(process.cwd(), pathArg);
|
|
23327
|
-
if (!
|
|
23502
|
+
if (!existsSync36(absPath)) {
|
|
23328
23503
|
printError(`worldspec not found at ${absPath}`);
|
|
23329
23504
|
process.exit(EXIT_WORLDSPEC_FILE_NOT_FOUND);
|
|
23330
23505
|
}
|
|
23331
23506
|
let yamlSource;
|
|
23332
23507
|
try {
|
|
23333
|
-
yamlSource =
|
|
23508
|
+
yamlSource = readFileSync25(absPath, "utf8");
|
|
23334
23509
|
} catch (err) {
|
|
23335
23510
|
printError(
|
|
23336
23511
|
`failed to read ${absPath}: ${err.message}`
|
|
@@ -23378,7 +23553,7 @@ init_output();
|
|
|
23378
23553
|
init_host_cp();
|
|
23379
23554
|
import * as fs35 from "node:fs";
|
|
23380
23555
|
import * as path38 from "node:path";
|
|
23381
|
-
import { spawnSync as
|
|
23556
|
+
import { spawnSync as spawnSync14 } from "node:child_process";
|
|
23382
23557
|
import ora7 from "ora";
|
|
23383
23558
|
import pc18 from "picocolors";
|
|
23384
23559
|
|
|
@@ -23386,7 +23561,7 @@ import pc18 from "picocolors";
|
|
|
23386
23561
|
import * as fs33 from "node:fs";
|
|
23387
23562
|
import * as os19 from "node:os";
|
|
23388
23563
|
import * as path36 from "node:path";
|
|
23389
|
-
import { spawnSync as
|
|
23564
|
+
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
23390
23565
|
var LOCK_FILE_PATH = path36.join(os19.homedir(), ".olam", ".upgrade.lock");
|
|
23391
23566
|
var STALE_LOCK_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
23392
23567
|
function readLockFile(lockPath) {
|
|
@@ -23411,7 +23586,7 @@ function isPidAlive2(pid) {
|
|
|
23411
23586
|
}
|
|
23412
23587
|
var PS_UNAVAILABLE = "__ps_unavailable__";
|
|
23413
23588
|
function getPidCommand(pid) {
|
|
23414
|
-
const result =
|
|
23589
|
+
const result = spawnSync13("ps", ["-p", String(pid), "-o", "comm="], {
|
|
23415
23590
|
encoding: "utf-8",
|
|
23416
23591
|
stdio: ["ignore", "pipe", "ignore"]
|
|
23417
23592
|
});
|
|
@@ -23670,7 +23845,7 @@ function extractBundleHash(indexHtml) {
|
|
|
23670
23845
|
function runStep2(label, cmd, args, opts = {}) {
|
|
23671
23846
|
const start = Date.now();
|
|
23672
23847
|
process.stdout.write(` ${pc18.dim(label.padEnd(34))}`);
|
|
23673
|
-
const result =
|
|
23848
|
+
const result = spawnSync14(cmd, [...args], {
|
|
23674
23849
|
encoding: "utf-8",
|
|
23675
23850
|
stdio: ["ignore", "pipe", "pipe"],
|
|
23676
23851
|
cwd: opts.cwd ?? process.cwd(),
|
|
@@ -23689,7 +23864,7 @@ function runStep2(label, cmd, args, opts = {}) {
|
|
|
23689
23864
|
};
|
|
23690
23865
|
}
|
|
23691
23866
|
function isGitDirty(cwd) {
|
|
23692
|
-
const result =
|
|
23867
|
+
const result = spawnSync14("git", ["status", "--porcelain"], {
|
|
23693
23868
|
encoding: "utf-8",
|
|
23694
23869
|
stdio: ["ignore", "pipe", "pipe"],
|
|
23695
23870
|
cwd
|
|
@@ -23697,7 +23872,7 @@ function isGitDirty(cwd) {
|
|
|
23697
23872
|
return (result.stdout ?? "").trim().length > 0;
|
|
23698
23873
|
}
|
|
23699
23874
|
function hasGitUpstream(cwd) {
|
|
23700
|
-
const result =
|
|
23875
|
+
const result = spawnSync14("git", ["rev-parse", "--abbrev-ref", "@{u}"], {
|
|
23701
23876
|
encoding: "utf-8",
|
|
23702
23877
|
stdio: ["ignore", "pipe", "pipe"],
|
|
23703
23878
|
cwd
|
|
@@ -23705,7 +23880,7 @@ function hasGitUpstream(cwd) {
|
|
|
23705
23880
|
return result.status === 0;
|
|
23706
23881
|
}
|
|
23707
23882
|
function captureHeadSha(cwd) {
|
|
23708
|
-
const result =
|
|
23883
|
+
const result = spawnSync14("git", ["rev-parse", "HEAD"], {
|
|
23709
23884
|
encoding: "utf-8",
|
|
23710
23885
|
stdio: ["ignore", "pipe", "pipe"],
|
|
23711
23886
|
cwd
|
|
@@ -23720,7 +23895,7 @@ function abbreviateSha(sha) {
|
|
|
23720
23895
|
}
|
|
23721
23896
|
function imageExists(tag) {
|
|
23722
23897
|
try {
|
|
23723
|
-
const result =
|
|
23898
|
+
const result = spawnSync14("docker", ["image", "inspect", "--format", "{{.Id}}", tag], {
|
|
23724
23899
|
encoding: "utf-8",
|
|
23725
23900
|
stdio: ["ignore", "pipe", "ignore"]
|
|
23726
23901
|
});
|
|
@@ -23736,7 +23911,7 @@ function checkRollbackSetExists(plan) {
|
|
|
23736
23911
|
}
|
|
23737
23912
|
var SMOKE_DOCKER_TIMEOUT_MS = 3e4;
|
|
23738
23913
|
function smokeImage(image, targetSha) {
|
|
23739
|
-
const createResult =
|
|
23914
|
+
const createResult = spawnSync14("docker", ["create", "--name", `olam-smoke-${Date.now()}`, image], {
|
|
23740
23915
|
encoding: "utf-8",
|
|
23741
23916
|
stdio: ["ignore", "pipe", "pipe"],
|
|
23742
23917
|
timeout: SMOKE_DOCKER_TIMEOUT_MS
|
|
@@ -23750,7 +23925,7 @@ function smokeImage(image, targetSha) {
|
|
|
23750
23925
|
};
|
|
23751
23926
|
}
|
|
23752
23927
|
const containerId = (createResult.stdout ?? "").trim();
|
|
23753
|
-
const inspectResult =
|
|
23928
|
+
const inspectResult = spawnSync14(
|
|
23754
23929
|
"docker",
|
|
23755
23930
|
["inspect", "--format", '{{index .Config.Labels "olam.build.sha"}}', image],
|
|
23756
23931
|
{
|
|
@@ -23760,7 +23935,7 @@ function smokeImage(image, targetSha) {
|
|
|
23760
23935
|
}
|
|
23761
23936
|
);
|
|
23762
23937
|
if (containerId.length > 0) {
|
|
23763
|
-
|
|
23938
|
+
spawnSync14("docker", ["rm", "-f", containerId], {
|
|
23764
23939
|
encoding: "utf-8",
|
|
23765
23940
|
stdio: ["ignore", "ignore", "ignore"],
|
|
23766
23941
|
timeout: SMOKE_DOCKER_TIMEOUT_MS
|
|
@@ -23800,7 +23975,7 @@ var PRODUCTION_SWAP_PLAN = [
|
|
|
23800
23975
|
];
|
|
23801
23976
|
function dockerTag(source, dest) {
|
|
23802
23977
|
try {
|
|
23803
|
-
const result =
|
|
23978
|
+
const result = spawnSync14("docker", ["tag", source, dest], {
|
|
23804
23979
|
encoding: "utf-8",
|
|
23805
23980
|
stdio: ["ignore", "ignore", "pipe"]
|
|
23806
23981
|
});
|
|
@@ -23964,11 +24139,11 @@ async function waitForAuthHealthLocal(timeoutMs = AUTH_HEALTH_TIMEOUT_MS) {
|
|
|
23964
24139
|
async function recreateAuthService() {
|
|
23965
24140
|
const start = Date.now();
|
|
23966
24141
|
try {
|
|
23967
|
-
|
|
24142
|
+
spawnSync14("docker", ["stop", "olam-auth"], {
|
|
23968
24143
|
encoding: "utf-8",
|
|
23969
24144
|
stdio: ["ignore", "ignore", "ignore"]
|
|
23970
24145
|
});
|
|
23971
|
-
|
|
24146
|
+
spawnSync14("docker", ["rm", "olam-auth"], {
|
|
23972
24147
|
encoding: "utf-8",
|
|
23973
24148
|
stdio: ["ignore", "ignore", "ignore"]
|
|
23974
24149
|
});
|
|
@@ -24227,11 +24402,11 @@ async function defaultRecreateMcpAuthForUpgrade() {
|
|
|
24227
24402
|
}
|
|
24228
24403
|
async function defaultRecreateAuthForUpgrade() {
|
|
24229
24404
|
try {
|
|
24230
|
-
|
|
24405
|
+
spawnSync14("docker", ["stop", "olam-auth"], {
|
|
24231
24406
|
encoding: "utf-8",
|
|
24232
24407
|
stdio: ["ignore", "ignore", "ignore"]
|
|
24233
24408
|
});
|
|
24234
|
-
|
|
24409
|
+
spawnSync14("docker", ["rm", "olam-auth"], {
|
|
24235
24410
|
encoding: "utf-8",
|
|
24236
24411
|
stdio: ["ignore", "ignore", "ignore"]
|
|
24237
24412
|
});
|
|
@@ -24577,7 +24752,7 @@ ${spaResult.stderr}`);
|
|
|
24577
24752
|
process.stdout.write(` ${pc18.dim(step.label.padEnd(34))}
|
|
24578
24753
|
`);
|
|
24579
24754
|
const start = Date.now();
|
|
24580
|
-
const result =
|
|
24755
|
+
const result = spawnSync14("bash", [scriptPath], {
|
|
24581
24756
|
stdio: "inherit",
|
|
24582
24757
|
cwd,
|
|
24583
24758
|
env: { ...process.env, ...olamTagEnv }
|
|
@@ -24926,7 +25101,7 @@ function registerLogs(program2) {
|
|
|
24926
25101
|
init_context();
|
|
24927
25102
|
init_output();
|
|
24928
25103
|
import pc20 from "picocolors";
|
|
24929
|
-
import { spawnSync as
|
|
25104
|
+
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
24930
25105
|
var SAFE_IDENT4 = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
24931
25106
|
function parseDockerTop(stdout) {
|
|
24932
25107
|
const trimmed = stdout.trim();
|
|
@@ -25026,7 +25201,7 @@ function registerPs(program2) {
|
|
|
25026
25201
|
const containerName = `olam-${worldId}-devbox`;
|
|
25027
25202
|
let watchInterval;
|
|
25028
25203
|
function fetchAndPrint() {
|
|
25029
|
-
const result =
|
|
25204
|
+
const result = spawnSync15(
|
|
25030
25205
|
"docker",
|
|
25031
25206
|
["top", containerName, "pid", "user", "pcpu", "pmem", "stime", "stat", "cmd"],
|
|
25032
25207
|
{ encoding: "utf-8", timeout: 3e3 }
|
|
@@ -25519,7 +25694,7 @@ init_output();
|
|
|
25519
25694
|
import * as fs39 from "node:fs";
|
|
25520
25695
|
import * as os22 from "node:os";
|
|
25521
25696
|
import * as path42 from "node:path";
|
|
25522
|
-
import { spawnSync as
|
|
25697
|
+
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
25523
25698
|
import ora8 from "ora";
|
|
25524
25699
|
|
|
25525
25700
|
// src/commands/refresh-helpers.ts
|
|
@@ -25563,7 +25738,7 @@ var RESTART_TIMEOUT_S = 30;
|
|
|
25563
25738
|
var HEALTH_POLL_MS = 500;
|
|
25564
25739
|
var HEALTH_TIMEOUT_MS = 3e4;
|
|
25565
25740
|
function docker(args) {
|
|
25566
|
-
const result =
|
|
25741
|
+
const result = spawnSync16("docker", args, {
|
|
25567
25742
|
encoding: "utf-8",
|
|
25568
25743
|
stdio: ["ignore", "pipe", "pipe"]
|
|
25569
25744
|
});
|
|
@@ -25911,9 +26086,9 @@ function registerDiagnose(program2) {
|
|
|
25911
26086
|
}
|
|
25912
26087
|
|
|
25913
26088
|
// src/lib/health-probes.ts
|
|
25914
|
-
import { spawnSync as
|
|
25915
|
-
import { existsSync as
|
|
25916
|
-
import { homedir as
|
|
26089
|
+
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
26090
|
+
import { existsSync as existsSync45, readdirSync as readdirSync11, readFileSync as readFileSync32, statSync as statSync14 } from "node:fs";
|
|
26091
|
+
import { homedir as homedir24 } from "node:os";
|
|
25917
26092
|
import path44 from "node:path";
|
|
25918
26093
|
|
|
25919
26094
|
// src/lib/kg-caps.ts
|
|
@@ -25923,7 +26098,7 @@ var HARD_CAP_BYTES = 5e9;
|
|
|
25923
26098
|
// src/lib/health-probes.ts
|
|
25924
26099
|
var HEALTH_TIMEOUT_MS2 = 5e3;
|
|
25925
26100
|
var defaultDockerExec2 = (cmd, args) => {
|
|
25926
|
-
const r =
|
|
26101
|
+
const r = spawnSync17(cmd, [...args], {
|
|
25927
26102
|
encoding: "utf-8",
|
|
25928
26103
|
stdio: ["ignore", "pipe", "pipe"]
|
|
25929
26104
|
});
|
|
@@ -26009,7 +26184,7 @@ function isHostCpHealthEnvelope(body) {
|
|
|
26009
26184
|
}
|
|
26010
26185
|
async function probeAuthVault(olamHomeOverride) {
|
|
26011
26186
|
const vaultPath = resolveAccountsPath(olamHomeOverride);
|
|
26012
|
-
if (!
|
|
26187
|
+
if (!existsSync45(vaultPath)) {
|
|
26013
26188
|
return {
|
|
26014
26189
|
ok: false,
|
|
26015
26190
|
message: `auth vault missing at ${vaultPath}`,
|
|
@@ -26018,7 +26193,7 @@ async function probeAuthVault(olamHomeOverride) {
|
|
|
26018
26193
|
}
|
|
26019
26194
|
let parsed;
|
|
26020
26195
|
try {
|
|
26021
|
-
parsed = JSON.parse(
|
|
26196
|
+
parsed = JSON.parse(readFileSync32(vaultPath, "utf-8"));
|
|
26022
26197
|
} catch (err) {
|
|
26023
26198
|
return {
|
|
26024
26199
|
ok: false,
|
|
@@ -26048,7 +26223,7 @@ async function probeAuthVault(olamHomeOverride) {
|
|
|
26048
26223
|
function resolveAccountsPath(olamHomeOverride) {
|
|
26049
26224
|
const explicit = process.env.OLAM_AUTH_DATA_PATH;
|
|
26050
26225
|
if (explicit) return explicit;
|
|
26051
|
-
const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(
|
|
26226
|
+
const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(homedir24(), ".olam");
|
|
26052
26227
|
return path44.join(olamHome5, "auth-data", "accounts.json");
|
|
26053
26228
|
}
|
|
26054
26229
|
function effectiveState2(account, now) {
|
|
@@ -26062,7 +26237,7 @@ function effectiveState2(account, now) {
|
|
|
26062
26237
|
return persisted;
|
|
26063
26238
|
}
|
|
26064
26239
|
async function probeKgStorage(olamHomeOverride) {
|
|
26065
|
-
const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(
|
|
26240
|
+
const olamHome5 = olamHomeOverride ?? process.env.OLAM_HOME ?? path44.join(homedir24(), ".olam");
|
|
26066
26241
|
const kgRoot3 = path44.join(olamHome5, "kg");
|
|
26067
26242
|
const worldsRoot3 = path44.join(olamHome5, "worlds");
|
|
26068
26243
|
const kgBytes = enumerateGraphifyOut(kgRoot3, "pristine");
|
|
@@ -26084,7 +26259,7 @@ async function probeKgStorage(olamHomeOverride) {
|
|
|
26084
26259
|
return { ok: true, message: `KG storage ${formatBytes4(totalBytes)} (under cap)` };
|
|
26085
26260
|
}
|
|
26086
26261
|
function enumerateGraphifyOut(root, layout) {
|
|
26087
|
-
if (!
|
|
26262
|
+
if (!existsSync45(root)) return 0;
|
|
26088
26263
|
let total = 0;
|
|
26089
26264
|
let entries;
|
|
26090
26265
|
try {
|
|
@@ -26113,7 +26288,7 @@ function enumerateGraphifyOut(root, layout) {
|
|
|
26113
26288
|
return total;
|
|
26114
26289
|
}
|
|
26115
26290
|
function dirSizeBytes(dir) {
|
|
26116
|
-
if (!
|
|
26291
|
+
if (!existsSync45(dir)) return 0;
|
|
26117
26292
|
let total = 0;
|
|
26118
26293
|
const stack = [dir];
|
|
26119
26294
|
while (stack.length > 0) {
|
|
@@ -26132,7 +26307,7 @@ function dirSizeBytes(dir) {
|
|
|
26132
26307
|
continue;
|
|
26133
26308
|
}
|
|
26134
26309
|
try {
|
|
26135
|
-
total +=
|
|
26310
|
+
total += statSync14(full).size;
|
|
26136
26311
|
} catch {
|
|
26137
26312
|
}
|
|
26138
26313
|
}
|
|
@@ -26369,20 +26544,20 @@ function registerCompletion(program2) {
|
|
|
26369
26544
|
// src/commands/setup.ts
|
|
26370
26545
|
init_cli_version();
|
|
26371
26546
|
import { spawn as spawn5 } from "node:child_process";
|
|
26372
|
-
import { existsSync as
|
|
26373
|
-
import { homedir as
|
|
26547
|
+
import { existsSync as existsSync47 } from "node:fs";
|
|
26548
|
+
import { homedir as homedir25 } from "node:os";
|
|
26374
26549
|
import path46 from "node:path";
|
|
26375
26550
|
import { createInterface as createInterface3 } from "node:readline";
|
|
26376
26551
|
|
|
26377
26552
|
// src/lib/shell-rc.ts
|
|
26378
|
-
import { copyFileSync as copyFileSync5, existsSync as
|
|
26553
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync46, readFileSync as readFileSync33, renameSync as renameSync5, writeFileSync as writeFileSync21 } from "node:fs";
|
|
26379
26554
|
import path45 from "node:path";
|
|
26380
26555
|
function appendIdempotent(opts) {
|
|
26381
26556
|
const { rcPath, marker, contentLine, clock = () => /* @__PURE__ */ new Date() } = opts;
|
|
26382
|
-
if (!
|
|
26557
|
+
if (!existsSync46(rcPath)) {
|
|
26383
26558
|
return { status: "no-rc-file", backupPath: null };
|
|
26384
26559
|
}
|
|
26385
|
-
const content =
|
|
26560
|
+
const content = readFileSync33(rcPath, "utf-8");
|
|
26386
26561
|
if (content.includes(marker)) {
|
|
26387
26562
|
return { status: "already-present", backupPath: null };
|
|
26388
26563
|
}
|
|
@@ -26393,8 +26568,8 @@ function appendIdempotent(opts) {
|
|
|
26393
26568
|
const trailing = contentLine.endsWith("\n") ? "" : "\n";
|
|
26394
26569
|
const nextContent = `${content}${separator}${contentLine}${trailing}`;
|
|
26395
26570
|
const tmpPath = `${rcPath}.olam-tmp.${process.pid}`;
|
|
26396
|
-
|
|
26397
|
-
|
|
26571
|
+
writeFileSync21(tmpPath, nextContent, { encoding: "utf-8" });
|
|
26572
|
+
renameSync5(tmpPath, rcPath);
|
|
26398
26573
|
return { status: "appended", backupPath };
|
|
26399
26574
|
}
|
|
26400
26575
|
function resolveShellRc(home, shellEnv) {
|
|
@@ -26503,7 +26678,7 @@ async function phase4ShellInit(opts, deps) {
|
|
|
26503
26678
|
if (opts.skipShellInit) {
|
|
26504
26679
|
return { ok: true, skipped: true, message: "skipped via --skip-shell-init" };
|
|
26505
26680
|
}
|
|
26506
|
-
const home = deps.home ??
|
|
26681
|
+
const home = deps.home ?? homedir25();
|
|
26507
26682
|
const shellEnv = deps.shellEnv ?? process.env.SHELL;
|
|
26508
26683
|
const rcPath = resolveShellRc(home, shellEnv);
|
|
26509
26684
|
if (rcPath === null) {
|
|
@@ -26540,7 +26715,7 @@ async function phase5InitProject(opts, deps) {
|
|
|
26540
26715
|
const cwd = deps.cwd ?? process.cwd();
|
|
26541
26716
|
const projectRoot = findProjectRoot(cwd);
|
|
26542
26717
|
const configPath = path46.join(projectRoot, ".olam", "config.yaml");
|
|
26543
|
-
if (
|
|
26718
|
+
if (existsSync47(configPath)) {
|
|
26544
26719
|
return { ok: true, message: `${configPath} present (no change)` };
|
|
26545
26720
|
}
|
|
26546
26721
|
const promptFn = deps.prompt ?? defaultPrompt;
|
|
@@ -27406,17 +27581,17 @@ function registerWorldUpgrade(program2) {
|
|
|
27406
27581
|
|
|
27407
27582
|
// src/commands/mcp/serve.ts
|
|
27408
27583
|
init_output();
|
|
27409
|
-
import { existsSync as
|
|
27410
|
-
import { dirname as
|
|
27584
|
+
import { existsSync as existsSync52 } from "node:fs";
|
|
27585
|
+
import { dirname as dirname26, resolve as resolve13 } from "node:path";
|
|
27411
27586
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
27412
|
-
var here =
|
|
27587
|
+
var here = dirname26(fileURLToPath6(import.meta.url));
|
|
27413
27588
|
var BUNDLE_PATH_CANDIDATES = [
|
|
27414
27589
|
// bundled (`dist/index.js` after bundle-cli.mjs) — sibling
|
|
27415
27590
|
resolve13(here, "mcp-server.js"),
|
|
27416
27591
|
// dev / tsc-only (`dist/commands/mcp/serve.js`) — up two levels
|
|
27417
27592
|
resolve13(here, "..", "..", "mcp-server.js")
|
|
27418
27593
|
];
|
|
27419
|
-
function resolveBundlePath(candidates2 = BUNDLE_PATH_CANDIDATES, exists =
|
|
27594
|
+
function resolveBundlePath(candidates2 = BUNDLE_PATH_CANDIDATES, exists = existsSync52) {
|
|
27420
27595
|
return candidates2.find(exists) ?? null;
|
|
27421
27596
|
}
|
|
27422
27597
|
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 +27613,9 @@ function registerMcpServe(cmd) {
|
|
|
27438
27613
|
init_output();
|
|
27439
27614
|
|
|
27440
27615
|
// src/commands/mcp/install-shared.ts
|
|
27441
|
-
import { spawnSync as
|
|
27616
|
+
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
27442
27617
|
var DEFAULT_CLAUDE_SHELL_DEPS = {
|
|
27443
|
-
spawn:
|
|
27618
|
+
spawn: spawnSync18,
|
|
27444
27619
|
log: (msg) => console.log(msg)
|
|
27445
27620
|
};
|
|
27446
27621
|
function isOnPath(deps, bin) {
|
|
@@ -28159,65 +28334,6 @@ import { spawn as spawn8 } from "node:child_process";
|
|
|
28159
28334
|
import { existsSync as existsSync54, mkdirSync as mkdirSync30, openSync as openSync3, readFileSync as readFileSync38, writeFileSync as writeFileSync24 } from "node:fs";
|
|
28160
28335
|
import { join as join52 } from "node:path";
|
|
28161
28336
|
|
|
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
28337
|
// src/commands/memory/_paths.ts
|
|
28222
28338
|
import { homedir as homedir30 } from "node:os";
|
|
28223
28339
|
import { join as join51, dirname as dirname27 } from "node:path";
|
|
@@ -28550,7 +28666,7 @@ async function runMemorySecretShow() {
|
|
|
28550
28666
|
);
|
|
28551
28667
|
return 1;
|
|
28552
28668
|
}
|
|
28553
|
-
process.stdout.write(`${
|
|
28669
|
+
process.stdout.write(`${readMemorySecret2()}
|
|
28554
28670
|
`);
|
|
28555
28671
|
return 0;
|
|
28556
28672
|
}
|
|
@@ -28602,7 +28718,7 @@ function registerMemorySecret(cmd) {
|
|
|
28602
28718
|
|
|
28603
28719
|
// src/commands/memory/install.ts
|
|
28604
28720
|
init_output();
|
|
28605
|
-
var
|
|
28721
|
+
var MCP_NAME2 = "agentmemory";
|
|
28606
28722
|
var NPM_PACKAGE_NAME2 = "@agentmemory/mcp";
|
|
28607
28723
|
var DEFAULT_SECRET_READER = () => readMemorySecretOrNull();
|
|
28608
28724
|
function buildClaudeMcpAddArgs2(scope, agentmemoryUrl, secret) {
|
|
@@ -28611,7 +28727,7 @@ function buildClaudeMcpAddArgs2(scope, agentmemoryUrl, secret) {
|
|
|
28611
28727
|
args: [
|
|
28612
28728
|
"mcp",
|
|
28613
28729
|
"add",
|
|
28614
|
-
|
|
28730
|
+
MCP_NAME2,
|
|
28615
28731
|
"--scope",
|
|
28616
28732
|
scope,
|
|
28617
28733
|
"--env",
|
|
@@ -28681,11 +28797,11 @@ function registerMemoryInstall(cmd) {
|
|
|
28681
28797
|
|
|
28682
28798
|
// src/commands/memory/uninstall.ts
|
|
28683
28799
|
init_output();
|
|
28684
|
-
var
|
|
28800
|
+
var MCP_NAME3 = "agentmemory";
|
|
28685
28801
|
function buildClaudeMcpRemoveArgs2(scope) {
|
|
28686
28802
|
return {
|
|
28687
28803
|
command: "claude",
|
|
28688
|
-
args: ["mcp", "remove",
|
|
28804
|
+
args: ["mcp", "remove", MCP_NAME3, "--scope", scope]
|
|
28689
28805
|
};
|
|
28690
28806
|
}
|
|
28691
28807
|
async function runUninstall2(opts, deps = DEFAULT_CLAUDE_SHELL_DEPS) {
|
|
@@ -28753,7 +28869,7 @@ function registerMemory(program2) {
|
|
|
28753
28869
|
init_storage_paths();
|
|
28754
28870
|
init_workspace_name();
|
|
28755
28871
|
init_output();
|
|
28756
|
-
import { spawnSync as
|
|
28872
|
+
import { spawnSync as spawnSync19 } from "node:child_process";
|
|
28757
28873
|
import fs49 from "node:fs";
|
|
28758
28874
|
import path54 from "node:path";
|
|
28759
28875
|
|
|
@@ -29151,13 +29267,13 @@ function resolveWorkspace(arg) {
|
|
|
29151
29267
|
}
|
|
29152
29268
|
function copyWorkspaceToScratch(source, scratch) {
|
|
29153
29269
|
if (process.platform === "darwin") {
|
|
29154
|
-
const r2 =
|
|
29270
|
+
const r2 = spawnSync19("cp", ["-c", "-r", source + "/.", scratch], {
|
|
29155
29271
|
stdio: ["ignore", "ignore", "pipe"],
|
|
29156
29272
|
encoding: "utf-8"
|
|
29157
29273
|
});
|
|
29158
29274
|
if (r2.status === 0) return "cp-c-r-reflink";
|
|
29159
29275
|
}
|
|
29160
|
-
const r =
|
|
29276
|
+
const r = spawnSync19("cp", ["-r", source + "/.", scratch], {
|
|
29161
29277
|
stdio: ["ignore", "ignore", "pipe"],
|
|
29162
29278
|
encoding: "utf-8"
|
|
29163
29279
|
});
|
|
@@ -29178,7 +29294,7 @@ function parseNodeCount(graphifyOutDir) {
|
|
|
29178
29294
|
}
|
|
29179
29295
|
}
|
|
29180
29296
|
function readGraphifyVersion(image) {
|
|
29181
|
-
const r =
|
|
29297
|
+
const r = spawnSync19(
|
|
29182
29298
|
"docker",
|
|
29183
29299
|
[
|
|
29184
29300
|
"run",
|
|
@@ -29230,7 +29346,7 @@ async function runKgBuild(workspaceArg, options = {}) {
|
|
|
29230
29346
|
"update",
|
|
29231
29347
|
"."
|
|
29232
29348
|
];
|
|
29233
|
-
const r = human ?
|
|
29349
|
+
const r = human ? spawnSync19("docker", dockerArgs, { stdio: "inherit" }) : spawnSync19("docker", dockerArgs, { stdio: ["ignore", "ignore", "pipe"] });
|
|
29234
29350
|
if (r.status !== 0) {
|
|
29235
29351
|
printError(`graphify update failed (exit ${r.status})`);
|
|
29236
29352
|
return { exitCode: r.status ?? 1 };
|
|
@@ -29288,7 +29404,7 @@ function registerKg(program2) {
|
|
|
29288
29404
|
|
|
29289
29405
|
// src/commands/seed.ts
|
|
29290
29406
|
init_output();
|
|
29291
|
-
import { spawnSync as
|
|
29407
|
+
import { spawnSync as spawnSync20, spawn as spawnAsync2 } from "node:child_process";
|
|
29292
29408
|
var DEFAULT_SINGLETON_CONTAINER = "olam-postgres";
|
|
29293
29409
|
var DEFAULT_SINGLETON_USER = "development";
|
|
29294
29410
|
function assertValidSeedName(name) {
|
|
@@ -29299,7 +29415,7 @@ function assertValidSeedName(name) {
|
|
|
29299
29415
|
}
|
|
29300
29416
|
}
|
|
29301
29417
|
function singletonDocker(container, user, args, stdin) {
|
|
29302
|
-
return
|
|
29418
|
+
return spawnSync20(
|
|
29303
29419
|
"docker",
|
|
29304
29420
|
["exec", "-i", container, "psql", "-U", user, ...args],
|
|
29305
29421
|
{ encoding: "utf-8", input: stdin }
|
|
@@ -29354,7 +29470,7 @@ async function handleBake(opts) {
|
|
|
29354
29470
|
if (sources.length > 1) {
|
|
29355
29471
|
throw new Error("multiple sources specified \u2014 pass exactly one of --source-container, --source-url, --source-local");
|
|
29356
29472
|
}
|
|
29357
|
-
const ping =
|
|
29473
|
+
const ping = spawnSync20("docker", ["inspect", "--format", "{{.State.Status}}", singleton], { encoding: "utf-8" });
|
|
29358
29474
|
if (ping.status !== 0 || (ping.stdout || "").trim() !== "running") {
|
|
29359
29475
|
throw new Error(`singleton container "${singleton}" not running \u2014 run \`olam bootstrap\` first`);
|
|
29360
29476
|
}
|