@pleri/olam-cli 0.1.119 → 0.1.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/commands/bootstrap.d.ts +4 -0
  2. package/dist/commands/bootstrap.d.ts.map +1 -1
  3. package/dist/commands/bootstrap.js +64 -0
  4. package/dist/commands/bootstrap.js.map +1 -1
  5. package/dist/commands/mcp/install-shared.d.ts +2 -0
  6. package/dist/commands/mcp/install-shared.d.ts.map +1 -1
  7. package/dist/commands/mcp/install-shared.js +13 -0
  8. package/dist/commands/mcp/install-shared.js.map +1 -1
  9. package/dist/commands/mcp/uninstall.d.ts.map +1 -1
  10. package/dist/commands/mcp/uninstall.js +1 -10
  11. package/dist/commands/mcp/uninstall.js.map +1 -1
  12. package/dist/commands/memory/_paths.d.ts +15 -0
  13. package/dist/commands/memory/_paths.d.ts.map +1 -0
  14. package/dist/commands/memory/_paths.js +34 -0
  15. package/dist/commands/memory/_paths.js.map +1 -0
  16. package/dist/commands/memory/index.d.ts +17 -0
  17. package/dist/commands/memory/index.d.ts.map +1 -0
  18. package/dist/commands/memory/index.js +34 -0
  19. package/dist/commands/memory/index.js.map +1 -0
  20. package/dist/commands/memory/install.d.ts +57 -0
  21. package/dist/commands/memory/install.d.ts.map +1 -0
  22. package/dist/commands/memory/install.js +114 -0
  23. package/dist/commands/memory/install.js.map +1 -0
  24. package/dist/commands/memory/logs.d.ts +15 -0
  25. package/dist/commands/memory/logs.d.ts.map +1 -0
  26. package/dist/commands/memory/logs.js +45 -0
  27. package/dist/commands/memory/logs.js.map +1 -0
  28. package/dist/commands/memory/secret.d.ts +16 -0
  29. package/dist/commands/memory/secret.d.ts.map +1 -0
  30. package/dist/commands/memory/secret.js +79 -0
  31. package/dist/commands/memory/secret.js.map +1 -0
  32. package/dist/commands/memory/start.d.ts +23 -0
  33. package/dist/commands/memory/start.d.ts.map +1 -0
  34. package/dist/commands/memory/start.js +166 -0
  35. package/dist/commands/memory/start.js.map +1 -0
  36. package/dist/commands/memory/status.d.ts +25 -0
  37. package/dist/commands/memory/status.d.ts.map +1 -0
  38. package/dist/commands/memory/status.js +101 -0
  39. package/dist/commands/memory/status.js.map +1 -0
  40. package/dist/commands/memory/stop.d.ts +12 -0
  41. package/dist/commands/memory/stop.d.ts.map +1 -0
  42. package/dist/commands/memory/stop.js +81 -0
  43. package/dist/commands/memory/stop.js.map +1 -0
  44. package/dist/commands/memory/uninstall.d.ts +19 -0
  45. package/dist/commands/memory/uninstall.d.ts.map +1 -0
  46. package/dist/commands/memory/uninstall.js +60 -0
  47. package/dist/commands/memory/uninstall.js.map +1 -0
  48. package/dist/commands/seed.d.ts +27 -0
  49. package/dist/commands/seed.d.ts.map +1 -0
  50. package/dist/commands/seed.js +303 -0
  51. package/dist/commands/seed.js.map +1 -0
  52. package/dist/image-digests.json +1 -1
  53. package/dist/index.js +1643 -183
  54. package/dist/index.js.map +1 -1
  55. package/dist/lib/memory-secret.d.ts +48 -0
  56. package/dist/lib/memory-secret.d.ts.map +1 -0
  57. package/dist/lib/memory-secret.js +92 -0
  58. package/dist/lib/memory-secret.js.map +1 -0
  59. package/dist/mcp-server.js +481 -65
  60. package/package.json +4 -2
@@ -0,0 +1,45 @@
1
+ /**
2
+ * olam memory logs — tail ~/.olam/memory-service.log.
3
+ *
4
+ * --follow (alias -f): tail -f-style; Ctrl-C to stop.
5
+ * --tail N (default 50): last N lines.
6
+ *
7
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
8
+ */
9
+ import { existsSync } from 'node:fs';
10
+ import { spawn } from 'node:child_process';
11
+ import { printWarning, printHeader } from '../../output.js';
12
+ import { MEMORY_LOG_PATH } from './_paths.js';
13
+ export async function runMemoryLogs(opts) {
14
+ if (!existsSync(MEMORY_LOG_PATH)) {
15
+ printWarning(`no log at ${MEMORY_LOG_PATH} (start the service first via 'olam memory start')`);
16
+ return 1;
17
+ }
18
+ const tailN = opts.tail ? parseInt(opts.tail, 10) : 50;
19
+ if (!Number.isFinite(tailN) || tailN < 0) {
20
+ printWarning(`invalid --tail value: ${opts.tail}`);
21
+ return 1;
22
+ }
23
+ const args = ['-n', `${tailN}`];
24
+ if (opts.follow)
25
+ args.push('-f');
26
+ args.push(MEMORY_LOG_PATH);
27
+ printHeader(`olam memory logs (${opts.follow ? 'follow' : `tail -n ${tailN}`})`);
28
+ const child = spawn('tail', args, { stdio: 'inherit' });
29
+ return new Promise((resolve) => {
30
+ child.on('exit', (code) => resolve(code ?? 0));
31
+ });
32
+ }
33
+ export function registerMemoryLogs(cmd) {
34
+ cmd
35
+ .command('logs')
36
+ .description('Tail the memory service log file at ~/.olam/memory-service.log')
37
+ .option('-f, --follow', 'Stream new log lines (Ctrl-C to stop)', false)
38
+ .option('--tail <n>', 'Number of trailing lines (default 50)', '50')
39
+ .action(async (opts) => {
40
+ const rc = await runMemoryLogs(opts);
41
+ if (rc !== 0)
42
+ process.exitCode = rc;
43
+ });
44
+ }
45
+ //# sourceMappingURL=logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/commands/memory/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAyC;IAC3E,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,YAAY,CAAC,aAAa,eAAe,oDAAoD,CAAC,CAAC;QAC/F,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,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AAI,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * olam memory secret — show or rotate the bearer secret at ~/.olam/memory-secret.
3
+ *
4
+ * Subcommands:
5
+ * show — print the current secret value (use with care; do not pipe to logs)
6
+ * rotate — generate a fresh secret + restart the running memory service so
7
+ * it picks up the new value. Worlds created BEFORE the rotation
8
+ * continue to use the old value until they're re-created.
9
+ *
10
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A3
11
+ */
12
+ import type { Command } from 'commander';
13
+ export declare function runMemorySecretShow(): Promise<number>;
14
+ export declare function runMemorySecretRotate(): Promise<number>;
15
+ export declare function registerMemorySecret(cmd: Command): void;
16
+ //# sourceMappingURL=secret.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../../src/commands/memory/secret.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAazC,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAU3D;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAoC7D;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAsBvD"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * olam memory secret — show or rotate the bearer secret at ~/.olam/memory-secret.
3
+ *
4
+ * Subcommands:
5
+ * show — print the current secret value (use with care; do not pipe to logs)
6
+ * rotate — generate a fresh secret + restart the running memory service so
7
+ * it picks up the new value. Worlds created BEFORE the rotation
8
+ * continue to use the old value until they're re-created.
9
+ *
10
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A3
11
+ */
12
+ import { existsSync } from 'node:fs';
13
+ import { MEMORY_SECRET_PATH, hasMemorySecret, readMemorySecret, rotateMemorySecret, } from '../../lib/memory-secret.js';
14
+ import { printError, printSuccess, printInfo, printWarning, printHeader } from '../../output.js';
15
+ import { runMemoryStart } from './start.js';
16
+ import { runMemoryStop } from './stop.js';
17
+ import { MEMORY_PID_PATH } from './_paths.js';
18
+ export async function runMemorySecretShow() {
19
+ if (!hasMemorySecret()) {
20
+ printError(`secret missing at ${MEMORY_SECRET_PATH}. Run 'olam memory start' to generate it.`);
21
+ return 1;
22
+ }
23
+ // Plain stdout so it's pipeable; helper helpers go to stderr in the lib.
24
+ process.stdout.write(`${readMemorySecret()}\n`);
25
+ return 0;
26
+ }
27
+ export async function runMemorySecretRotate() {
28
+ printHeader('olam memory secret rotate');
29
+ const wasRunning = existsSync(MEMORY_PID_PATH);
30
+ if (wasRunning) {
31
+ printInfo('current state', 'service running; will restart with new secret');
32
+ const stopRc = await runMemoryStop();
33
+ if (stopRc !== 0) {
34
+ printError('failed to stop the running service; rotation aborted to avoid split-brain');
35
+ return stopRc;
36
+ }
37
+ }
38
+ else {
39
+ printInfo('current state', 'service stopped');
40
+ }
41
+ const fresh = rotateMemorySecret();
42
+ printSuccess(`secret rotated (${fresh.length / 2}-byte hex written to ${MEMORY_SECRET_PATH})`);
43
+ if (wasRunning) {
44
+ printInfo('restarting', 'memory service with new secret');
45
+ const startRc = await runMemoryStart();
46
+ if (startRc !== 0) {
47
+ printError('service failed to restart after rotation. The new secret is on disk; run `olam memory start` once you fix the underlying issue.');
48
+ return startRc;
49
+ }
50
+ }
51
+ else {
52
+ printWarning('service was not running; new secret will be picked up on next `olam memory start`');
53
+ }
54
+ // Heads-up: worlds created before this rotation still have the old value in env.
55
+ printWarning('worlds created BEFORE this rotation still have the old secret in their env. Re-create them (olam destroy + olam create) to pick up the new value.');
56
+ return 0;
57
+ }
58
+ export function registerMemorySecret(cmd) {
59
+ const secret = cmd
60
+ .command('secret')
61
+ .description('Show or rotate the bearer secret at ~/.olam/memory-secret');
62
+ secret
63
+ .command('show')
64
+ .description('Print the current secret value (use with care; do not pipe to logs)')
65
+ .action(async () => {
66
+ const rc = await runMemorySecretShow();
67
+ if (rc !== 0)
68
+ process.exitCode = rc;
69
+ });
70
+ secret
71
+ .command('rotate')
72
+ .description('Regenerate the secret and restart the running memory service (worlds created before rotation must be re-created)')
73
+ .action(async () => {
74
+ const rc = await runMemorySecretRotate();
75
+ if (rc !== 0)
76
+ process.exitCode = rc;
77
+ });
78
+ }
79
+ //# sourceMappingURL=secret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret.js","sourceRoot":"","sources":["../../../src/commands/memory/secret.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;QACvB,UAAU,CACR,qBAAqB,kBAAkB,2CAA2C,CACnF,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,yEAAyE;IACzE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,WAAW,CAAC,2BAA2B,CAAC,CAAC;IAEzC,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,CAAC,C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EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEL,MAAM;SACH,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CACV,kHAAkH,CACnH;SACA,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,EAAE,GAAG,MAAM,qBAAqB,EAAE,CAAC;QACzC,IAAI,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * olam memory start — spawn agentmemory as a managed host child process.
3
+ *
4
+ * Flow:
5
+ * 1. Ensure iii v0.11.2 binary at ~/.olam/bin/iii (calls A1's ensure-iii-engine.mjs equivalent)
6
+ * 2. Ensure ~/.olam/memory-secret (0600) exists
7
+ * 3. Locate packages/memory-service/ (the npm-installed agentmemory)
8
+ * 4. Spawn `agentmemory` (the bin from @agentmemory/agentmemory@0.9.6) with:
9
+ * env: { AGENTMEMORY_SECRET, PATH: ~/.olam/bin:$PATH, ...inherit }
10
+ * cwd: ~/.olam (so agentmemory writes state under ~/.olam/data/)
11
+ * stdio: append to ~/.olam/memory-service.log
12
+ * detached: true so the child outlives this CLI invocation
13
+ * 5. Write child pid to ~/.olam/memory.pid
14
+ * 6. Poll http://localhost:3111/agentmemory/livez until 200 (timeout 30s)
15
+ *
16
+ * Idempotent: re-running while the service is healthy prints status and exits 0.
17
+ *
18
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
19
+ */
20
+ import type { Command } from 'commander';
21
+ export declare function runMemoryStart(): Promise<number>;
22
+ export declare function registerMemoryStart(cmd: Command): void;
23
+ //# sourceMappingURL=start.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/commands/memory/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwFzC,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CA6EtD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAQtD"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * olam memory start — spawn agentmemory as a managed host child process.
3
+ *
4
+ * Flow:
5
+ * 1. Ensure iii v0.11.2 binary at ~/.olam/bin/iii (calls A1's ensure-iii-engine.mjs equivalent)
6
+ * 2. Ensure ~/.olam/memory-secret (0600) exists
7
+ * 3. Locate packages/memory-service/ (the npm-installed agentmemory)
8
+ * 4. Spawn `agentmemory` (the bin from @agentmemory/agentmemory@0.9.6) with:
9
+ * env: { AGENTMEMORY_SECRET, PATH: ~/.olam/bin:$PATH, ...inherit }
10
+ * cwd: ~/.olam (so agentmemory writes state under ~/.olam/data/)
11
+ * stdio: append to ~/.olam/memory-service.log
12
+ * detached: true so the child outlives this CLI invocation
13
+ * 5. Write child pid to ~/.olam/memory.pid
14
+ * 6. Poll http://localhost:3111/agentmemory/livez until 200 (timeout 30s)
15
+ *
16
+ * Idempotent: re-running while the service is healthy prints status and exits 0.
17
+ *
18
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
19
+ */
20
+ import { spawn } from 'node:child_process';
21
+ import { existsSync, mkdirSync, openSync, readFileSync, writeFileSync } from 'node:fs';
22
+ import { join } from 'node:path';
23
+ import { printError, printSuccess, printInfo, printHeader } from '../../output.js';
24
+ import { ensureMemorySecret } from '../../lib/memory-secret.js';
25
+ import { III_BINARY_PATH, MEMORY_DATA_DIR, MEMORY_LIVEZ_URL, MEMORY_LOG_PATH, MEMORY_PID_PATH, MEMORY_SERVICE_CANDIDATES, OLAM_BIN_DIR, OLAM_HOME, } from './_paths.js';
26
+ const READINESS_TIMEOUT_MS = 30_000;
27
+ const READINESS_POLL_MS = 500;
28
+ function resolveMemoryServiceDir() {
29
+ for (const c of MEMORY_SERVICE_CANDIDATES) {
30
+ if (existsSync(c))
31
+ return c;
32
+ }
33
+ throw new Error(`Could not find packages/memory-service/. Searched: ${MEMORY_SERVICE_CANDIDATES.join(', ')}. ` +
34
+ `If running from a published @pleri/olam-cli tarball, this is a packaging bug — please file an issue.`);
35
+ }
36
+ function resolveAgentMemoryBin(serviceDir) {
37
+ // npm hoists @agentmemory/agentmemory to the workspace root in monorepo mode.
38
+ // Search likely locations in order.
39
+ const candidates = [
40
+ join(serviceDir, 'node_modules', '.bin', 'agentmemory'),
41
+ join(serviceDir, '..', '..', 'node_modules', '.bin', 'agentmemory'),
42
+ join(serviceDir, '..', '..', '..', 'node_modules', '.bin', 'agentmemory'),
43
+ ];
44
+ for (const c of candidates) {
45
+ if (existsSync(c))
46
+ return c;
47
+ }
48
+ throw new Error(`Could not find agentmemory bin. Searched: ${candidates.join(', ')}. ` +
49
+ `Run 'npm install' from the repo root.`);
50
+ }
51
+ function isProcessAlive(pid) {
52
+ try {
53
+ // signal 0 doesn't deliver; just tests existence + permission
54
+ process.kill(pid, 0);
55
+ return true;
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
61
+ function readPidFromFile() {
62
+ if (!existsSync(MEMORY_PID_PATH))
63
+ return null;
64
+ const raw = readFileSync(MEMORY_PID_PATH, 'utf8').trim();
65
+ const pid = parseInt(raw, 10);
66
+ if (!Number.isFinite(pid) || pid <= 0)
67
+ return null;
68
+ return pid;
69
+ }
70
+ async function probeLivez(secret, signal) {
71
+ try {
72
+ const resp = await fetch(MEMORY_LIVEZ_URL, {
73
+ headers: { authorization: `Bearer ${secret}` },
74
+ signal,
75
+ });
76
+ if (!resp.ok)
77
+ return false;
78
+ const body = (await resp.json());
79
+ return body.status === 'ok';
80
+ }
81
+ catch {
82
+ return false;
83
+ }
84
+ }
85
+ async function waitForReady(secret) {
86
+ const deadline = Date.now() + READINESS_TIMEOUT_MS;
87
+ while (Date.now() < deadline) {
88
+ if (await probeLivez(secret))
89
+ return true;
90
+ await new Promise((r) => setTimeout(r, READINESS_POLL_MS));
91
+ }
92
+ return false;
93
+ }
94
+ export async function runMemoryStart() {
95
+ printHeader('olam memory start');
96
+ // 1. iii binary (A1's deliverable)
97
+ if (!existsSync(III_BINARY_PATH)) {
98
+ printError(`iii binary missing at ${III_BINARY_PATH}. Run: node packages/memory-service/scripts/ensure-iii-engine.mjs`);
99
+ return 1;
100
+ }
101
+ printInfo('iii binary', III_BINARY_PATH);
102
+ // 2. Secret (A3 lib)
103
+ const secret = ensureMemorySecret();
104
+ printInfo('secret', '~/.olam/memory-secret (0600)');
105
+ // 3. Locate the service + agentmemory bin
106
+ const serviceDir = resolveMemoryServiceDir();
107
+ const agentmemoryBin = resolveAgentMemoryBin(serviceDir);
108
+ printInfo('agentmemory', agentmemoryBin);
109
+ // 4. Idempotency: already running?
110
+ const existingPid = readPidFromFile();
111
+ if (existingPid !== null && isProcessAlive(existingPid)) {
112
+ const ready = await probeLivez(secret);
113
+ if (ready) {
114
+ printSuccess(`already running (pid ${existingPid}); /agentmemory/livez ok`);
115
+ return 0;
116
+ }
117
+ // Pidfile points at a live process that isn't responding — leave it alone, error out.
118
+ printError(`pid ${existingPid} is alive but /agentmemory/livez isn't responding. ` +
119
+ `Run 'olam memory stop' to clear, then retry.`);
120
+ return 1;
121
+ }
122
+ // 5. Ensure dirs exist
123
+ mkdirSync(OLAM_HOME, { recursive: true });
124
+ mkdirSync(MEMORY_DATA_DIR, { recursive: true });
125
+ // 6. Spawn detached, redirect output to log file (append).
126
+ const logFd = openSync(MEMORY_LOG_PATH, 'a');
127
+ const child = spawn(agentmemoryBin, [], {
128
+ cwd: OLAM_HOME,
129
+ env: {
130
+ ...process.env,
131
+ AGENTMEMORY_SECRET: secret,
132
+ PATH: `${OLAM_BIN_DIR}:${process.env.PATH ?? ''}`,
133
+ },
134
+ stdio: ['ignore', logFd, logFd],
135
+ detached: true,
136
+ });
137
+ child.unref();
138
+ if (child.pid === undefined) {
139
+ printError('spawn returned no pid (process failed to start)');
140
+ return 1;
141
+ }
142
+ // 7. Persist pid
143
+ writeFileSync(MEMORY_PID_PATH, `${child.pid}\n`, { mode: 0o644 });
144
+ printInfo('pid', `${child.pid}`);
145
+ // 8. Wait for readiness
146
+ printInfo('readiness', `polling ${MEMORY_LIVEZ_URL}`);
147
+ const ready = await waitForReady(secret);
148
+ if (!ready) {
149
+ printError(`agentmemory failed to come up within ${READINESS_TIMEOUT_MS / 1000}s. ` +
150
+ `Inspect ${MEMORY_LOG_PATH} for engine errors.`);
151
+ return 1;
152
+ }
153
+ printSuccess(`memory service ready (pid ${child.pid}; logs at ${MEMORY_LOG_PATH})`);
154
+ return 0;
155
+ }
156
+ export function registerMemoryStart(cmd) {
157
+ cmd
158
+ .command('start')
159
+ .description('Start the host agent-memory process (idempotent; polls livez until ready)')
160
+ .action(async () => {
161
+ const rc = await runMemoryStart();
162
+ if (rc !== 0)
163
+ process.exitCode = rc;
164
+ });
165
+ }
166
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/memory/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,iBAAi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,GAAG,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * olam memory status — diagnostic dump for the host memory service.
3
+ *
4
+ * Reports: pidfile state, process liveness, /agentmemory/livez response,
5
+ * secret-set Y/N, iii binary location, REST port. Intended for both
6
+ * humans (default output) and machines (--json).
7
+ *
8
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
9
+ */
10
+ import type { Command } from 'commander';
11
+ interface MemoryStatus {
12
+ pid: number | null;
13
+ alive: boolean | null;
14
+ livez: 'ok' | 'unreachable' | 'unauthorized' | 'unknown';
15
+ secretSet: boolean;
16
+ iiiBinary: string | null;
17
+ port: number;
18
+ }
19
+ export declare function collectMemoryStatus(): Promise<MemoryStatus>;
20
+ export declare function runMemoryStatus(opts?: {
21
+ json?: boolean;
22
+ }): Promise<number>;
23
+ export declare function registerMemoryStatus(cmd: Command): void;
24
+ export {};
25
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/memory/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWzC,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,IAAI,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS,CAAC;IACzD,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAyBD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,YAAY,CAAC,CAkBjE;AAED,wBAAsB,eAAe,CAAC,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAgCpF;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CASvD"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * olam memory status — diagnostic dump for the host memory service.
3
+ *
4
+ * Reports: pidfile state, process liveness, /agentmemory/livez response,
5
+ * secret-set Y/N, iii binary location, REST port. Intended for both
6
+ * humans (default output) and machines (--json).
7
+ *
8
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
9
+ */
10
+ import { existsSync, readFileSync } from 'node:fs';
11
+ import { printError, printInfo, printHeader, printWarning } from '../../output.js';
12
+ import { hasMemorySecret, readMemorySecretOrNull } from '../../lib/memory-secret.js';
13
+ import { III_BINARY_PATH, MEMORY_LIVEZ_URL, MEMORY_PID_PATH, MEMORY_REST_PORT, } from './_paths.js';
14
+ function isAlive(pid) {
15
+ try {
16
+ process.kill(pid, 0);
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ async function probe(secret) {
24
+ try {
25
+ const headers = {};
26
+ if (secret)
27
+ headers.authorization = `Bearer ${secret}`;
28
+ const resp = await fetch(MEMORY_LIVEZ_URL, { headers });
29
+ if (resp.status === 401)
30
+ return 'unauthorized';
31
+ if (!resp.ok)
32
+ return 'unknown';
33
+ const body = (await resp.json());
34
+ return body.status === 'ok' ? 'ok' : 'unknown';
35
+ }
36
+ catch {
37
+ return 'unreachable';
38
+ }
39
+ }
40
+ export async function collectMemoryStatus() {
41
+ let pid = null;
42
+ if (existsSync(MEMORY_PID_PATH)) {
43
+ const raw = readFileSync(MEMORY_PID_PATH, 'utf8').trim();
44
+ const parsed = parseInt(raw, 10);
45
+ pid = Number.isFinite(parsed) && parsed > 0 ? parsed : null;
46
+ }
47
+ const alive = pid === null ? null : isAlive(pid);
48
+ const secret = readMemorySecretOrNull();
49
+ const livez = await probe(secret);
50
+ return {
51
+ pid,
52
+ alive,
53
+ livez,
54
+ secretSet: hasMemorySecret(),
55
+ iiiBinary: existsSync(III_BINARY_PATH) ? III_BINARY_PATH : null,
56
+ port: MEMORY_REST_PORT,
57
+ };
58
+ }
59
+ export async function runMemoryStatus(opts = {}) {
60
+ const s = await collectMemoryStatus();
61
+ if (opts.json) {
62
+ process.stdout.write(JSON.stringify(s, null, 2) + '\n');
63
+ return s.livez === 'ok' ? 0 : 1;
64
+ }
65
+ printHeader('olam memory status');
66
+ printInfo('pid', s.pid === null ? '(no pidfile)' : `${s.pid}`);
67
+ printInfo('alive', s.alive === null ? 'n/a' : s.alive ? 'yes' : 'no (stale pidfile)');
68
+ printInfo('livez', s.livez);
69
+ printInfo('secret', s.secretSet ? '~/.olam/memory-secret (set)' : '(missing)');
70
+ printInfo('iii', s.iiiBinary ?? '(not installed)');
71
+ printInfo('port', `${s.port}`);
72
+ if (s.livez === 'ok' && s.alive)
73
+ return 0;
74
+ if (s.livez === 'unauthorized') {
75
+ printWarning('livez returned 401 — the memory service is up but the local secret does not match. Try `olam memory secret rotate`.');
76
+ return 1;
77
+ }
78
+ if (s.alive === false && s.pid !== null) {
79
+ printWarning('pidfile points at a dead process; run `olam memory stop` to clean up');
80
+ return 1;
81
+ }
82
+ if (!s.iiiBinary) {
83
+ printWarning('iii binary missing; run `node packages/memory-service/scripts/ensure-iii-engine.mjs`');
84
+ }
85
+ if (!s.secretSet) {
86
+ printWarning('secret missing; `olam memory start` will generate it');
87
+ }
88
+ return s.livez === 'ok' ? 0 : 1;
89
+ }
90
+ export function registerMemoryStatus(cmd) {
91
+ cmd
92
+ .command('status')
93
+ .description('Diagnostic dump for the host memory service (pid + livez + secret-set check)')
94
+ .option('--json', 'Machine-readable JSON output', false)
95
+ .action(async (opts) => {
96
+ const rc = await runMemoryStatus(opts);
97
+ if (rc !== 0)
98
+ process.exitCode = rc;
99
+ });
100
+ }
101
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/memory/status.ts"],"names":[],"mappings":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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,GAAG;SACA,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,8EAA8E,CAAC;SAC3F,MAAM,CAAC,QAAQ,EAAE,8BAA8B,EAAE,KAAK,CAAC;SACvD,MAAM,CAAC,KAAK,EAAE,IAAwB,EAAE,EAAE;QACzC,MAAM,EAAE,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * olam memory stop — terminate the host agent-memory process gracefully.
3
+ *
4
+ * SIGTERM → wait 10s → SIGKILL. Removes the pidfile on clean exit.
5
+ * Idempotent: no pidfile or stale pidfile → exit 0 with informational message.
6
+ *
7
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
8
+ */
9
+ import type { Command } from 'commander';
10
+ export declare function runMemoryStop(): Promise<number>;
11
+ export declare function registerMemoryStop(cmd: Command): void;
12
+ //# sourceMappingURL=stop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/commands/memory/stop.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBzC,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAmDrD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAQrD"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * olam memory stop — terminate the host agent-memory process gracefully.
3
+ *
4
+ * SIGTERM → wait 10s → SIGKILL. Removes the pidfile on clean exit.
5
+ * Idempotent: no pidfile or stale pidfile → exit 0 with informational message.
6
+ *
7
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A2
8
+ */
9
+ import { existsSync, readFileSync, unlinkSync } from 'node:fs';
10
+ import { printSuccess, printWarning, printInfo, printHeader } from '../../output.js';
11
+ import { MEMORY_PID_PATH } from './_paths.js';
12
+ const SIGTERM_GRACE_MS = 10_000;
13
+ const POLL_MS = 250;
14
+ function isAlive(pid) {
15
+ try {
16
+ process.kill(pid, 0);
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ export async function runMemoryStop() {
24
+ printHeader('olam memory stop');
25
+ if (!existsSync(MEMORY_PID_PATH)) {
26
+ printSuccess('no pidfile present (nothing to stop)');
27
+ return 0;
28
+ }
29
+ const pid = parseInt(readFileSync(MEMORY_PID_PATH, 'utf8').trim(), 10);
30
+ if (!Number.isFinite(pid) || pid <= 0) {
31
+ printWarning(`pidfile contained invalid value; removing`);
32
+ unlinkSync(MEMORY_PID_PATH);
33
+ return 0;
34
+ }
35
+ if (!isAlive(pid)) {
36
+ printSuccess(`pid ${pid} is not running (stale pidfile); cleaned up`);
37
+ unlinkSync(MEMORY_PID_PATH);
38
+ return 0;
39
+ }
40
+ printInfo('pid', `${pid}`);
41
+ try {
42
+ process.kill(pid, 'SIGTERM');
43
+ }
44
+ catch (err) {
45
+ printWarning(`SIGTERM to pid ${pid} failed: ${err.message}`);
46
+ }
47
+ // Wait for graceful exit
48
+ const deadline = Date.now() + SIGTERM_GRACE_MS;
49
+ while (Date.now() < deadline) {
50
+ if (!isAlive(pid))
51
+ break;
52
+ await new Promise((r) => setTimeout(r, POLL_MS));
53
+ }
54
+ if (isAlive(pid)) {
55
+ printWarning(`pid ${pid} did not exit within ${SIGTERM_GRACE_MS / 1000}s; sending SIGKILL`);
56
+ try {
57
+ process.kill(pid, 'SIGKILL');
58
+ }
59
+ catch (err) {
60
+ printWarning(`SIGKILL to pid ${pid} failed: ${err.message}`);
61
+ }
62
+ // Brief wait for SIGKILL to take effect
63
+ await new Promise((r) => setTimeout(r, 500));
64
+ }
65
+ if (existsSync(MEMORY_PID_PATH)) {
66
+ unlinkSync(MEMORY_PID_PATH);
67
+ }
68
+ printSuccess(`stopped (pid ${pid})`);
69
+ return 0;
70
+ }
71
+ export function registerMemoryStop(cmd) {
72
+ cmd
73
+ .command('stop')
74
+ .description('Stop the host agent-memory process (SIGTERM → SIGKILL after 10s; idempotent)')
75
+ .action(async () => {
76
+ const rc = await runMemoryStop();
77
+ if (rc !== 0)
78
+ process.exitCode = rc;
79
+ });
80
+ }
81
+ //# sourceMappingURL=stop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stop.js","sourceRoot":"","sources":["../../../src/commands/memory/stop.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IAEhC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,YAAY,CAAC,sCAAsC,CAAC,CAAC;QACrD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,CAAC,YAA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S,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,YAAY,CAAC,kBAAkB,GAAG,YAAa,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,wCAAwC;QACxC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAChC,UAAU,CAAC,eAAe,CAAC,CAAC;IAC9B,CAAC;IACD,YAAY,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC;IACrC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,GAAG;SACA,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,8EAA8E,CAAC;SAC3F,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,EAAE,GAAG,MAAM,aAAa,EAAE,CAAC;QACjC,IAAI,EAAE,KAAK,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * olam memory uninstall — Remove `agentmemory` from the operator's host
3
+ * claude. Symmetric with `install`. Idempotent — "not registered" is
4
+ * success-as-noop.
5
+ *
6
+ * Plan reference: docs/plans/olam-agent-memory-distributed/phase-a-tasks.md A4
7
+ */
8
+ import type { Command } from 'commander';
9
+ import { type ClaudeShellDeps, type McpScope } from '../mcp/install-shared.js';
10
+ export declare function buildClaudeMcpRemoveArgs(scope: McpScope): {
11
+ command: string;
12
+ args: string[];
13
+ };
14
+ export interface UninstallOpts {
15
+ scope: McpScope;
16
+ }
17
+ export declare function runUninstall(opts: UninstallOpts, deps?: ClaudeShellDeps): Promise<number>;
18
+ export declare function registerMemoryUninstall(cmd: Command): void;
19
+ //# sourceMappingURL=uninstall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../src/commands/memory/uninstall.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAIlC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAKA;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,aAAa,EACnB,IAAI,GAAE,eAA2C,GAChD,OAAO,CAAC,MAAM,CAAC,CAkCjB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAmB1D"}