@pleri/olam-cli 0.1.144 → 0.1.145
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/doctor.d.ts +53 -23
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +117 -46
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/logs.d.ts +17 -3
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +38 -35
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/memory/bridge.d.ts +57 -0
- package/dist/commands/memory/bridge.d.ts.map +1 -0
- package/dist/commands/memory/bridge.js +156 -0
- package/dist/commands/memory/bridge.js.map +1 -0
- package/dist/commands/memory/index.d.ts +3 -0
- package/dist/commands/memory/index.d.ts.map +1 -1
- package/dist/commands/memory/index.js +10 -1
- package/dist/commands/memory/index.js.map +1 -1
- package/dist/commands/memory/reclassify.d.ts +56 -0
- package/dist/commands/memory/reclassify.d.ts.map +1 -0
- package/dist/commands/memory/reclassify.js +177 -0
- package/dist/commands/memory/reclassify.js.map +1 -0
- package/dist/commands/memory/stats.d.ts +69 -0
- package/dist/commands/memory/stats.d.ts.map +1 -0
- package/dist/commands/memory/stats.js +164 -0
- package/dist/commands/memory/stats.js.map +1 -0
- package/dist/commands/skills-source.d.ts +12 -0
- package/dist/commands/skills-source.d.ts.map +1 -0
- package/dist/commands/skills-source.js +133 -0
- package/dist/commands/skills-source.js.map +1 -0
- package/dist/commands/skills.d.ts +11 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +163 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/status.d.ts +27 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +102 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/image-digests.json +7 -7
- package/dist/index.js +2027 -529
- package/dist/index.js.map +1 -1
- package/dist/lib/health-probes.d.ts +72 -0
- package/dist/lib/health-probes.d.ts.map +1 -1
- package/dist/lib/health-probes.js +218 -0
- package/dist/lib/health-probes.js.map +1 -1
- package/dist/mcp-server.js +1246 -351
- package/host-cp/src/agent-runtime-trigger.mjs +74 -4
- package/host-cp/src/engine-identity.mjs +32 -0
- package/host-cp/src/server.mjs +188 -3
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* olam memory stats — operator-facing formatter over `/bridge/stats`.
|
|
3
|
+
*
|
|
4
|
+
* $ olam memory stats
|
|
5
|
+
* # human-readable counters + derived cache_error_rate
|
|
6
|
+
*
|
|
7
|
+
* $ olam memory stats --json
|
|
8
|
+
* # raw /bridge/stats response (for jq / monitoring scripts)
|
|
9
|
+
*
|
|
10
|
+
* Config (env vars):
|
|
11
|
+
* AGENTMEMORY_BRIDGE_URL bridge base URL
|
|
12
|
+
* (default: https://olam-agent-memory.ernestcodes.workers.dev)
|
|
13
|
+
* AGENTMEMORY_BRIDGE_SECRET bearer token
|
|
14
|
+
*
|
|
15
|
+
* Derived metric: cache_error_rate =
|
|
16
|
+
* (cache_busted_hash + cache_busted_version) / max(writes_observed, 1)
|
|
17
|
+
*
|
|
18
|
+
* Interpretation: high rates (>5%) mean operators have been forced to
|
|
19
|
+
* reclassify a lot of recent writes — usually a sign that the prompt
|
|
20
|
+
* template / classifier_version is churning. The denominator is
|
|
21
|
+
* classifier_writes_observed (NOT bridge writes_observed).
|
|
22
|
+
*
|
|
23
|
+
* Plan reference:
|
|
24
|
+
* docs/plans/agentmemory-classifier-and-regret/phase-b-tasks.md (B5/B6)
|
|
25
|
+
*/
|
|
26
|
+
import { printError, printHeader, printInfo } from '../../output.js';
|
|
27
|
+
const DEFAULT_BRIDGE_URL = 'https://olam-agent-memory.ernestcodes.workers.dev';
|
|
28
|
+
const STATS_TIMEOUT_MS = 10_000;
|
|
29
|
+
/**
|
|
30
|
+
* Pure helper — separated so it's unit-testable without HTTP.
|
|
31
|
+
* Guards divide-by-zero (returns 0 when writes_observed === 0, even
|
|
32
|
+
* if busts are nonzero — Infinity / NaN would be operator-hostile).
|
|
33
|
+
*/
|
|
34
|
+
export function computeCacheErrorRate(counters) {
|
|
35
|
+
if (counters.writes_observed <= 0)
|
|
36
|
+
return 0;
|
|
37
|
+
const busted = counters.cache_busted_hash + counters.cache_busted_version;
|
|
38
|
+
return busted / counters.writes_observed;
|
|
39
|
+
}
|
|
40
|
+
function resolveBridgeUrl(opts) {
|
|
41
|
+
return opts.bridgeUrl
|
|
42
|
+
?? process.env['AGENTMEMORY_BRIDGE_URL']
|
|
43
|
+
?? DEFAULT_BRIDGE_URL;
|
|
44
|
+
}
|
|
45
|
+
function resolveBearer(opts) {
|
|
46
|
+
const fromOpt = opts.bearer;
|
|
47
|
+
if (fromOpt && fromOpt.length > 0)
|
|
48
|
+
return fromOpt;
|
|
49
|
+
const fromEnv = process.env['AGENTMEMORY_BRIDGE_SECRET'];
|
|
50
|
+
if (fromEnv && fromEnv.length > 0)
|
|
51
|
+
return fromEnv;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function intOrZero(v) {
|
|
55
|
+
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
56
|
+
return 0;
|
|
57
|
+
return Math.trunc(v);
|
|
58
|
+
}
|
|
59
|
+
function extractCounters(stats) {
|
|
60
|
+
return {
|
|
61
|
+
writes_observed: intOrZero(stats.classifier_writes_observed),
|
|
62
|
+
writes_deduped_hash: intOrZero(stats.classifier_writes_deduped_hash),
|
|
63
|
+
writes_deduped_semantic: intOrZero(stats.classifier_writes_deduped_semantic),
|
|
64
|
+
recalls_observed: intOrZero(stats.classifier_recalls_observed),
|
|
65
|
+
cache_busted_hash: intOrZero(stats.classifier_cache_busted_hash),
|
|
66
|
+
cache_busted_version: intOrZero(stats.classifier_cache_busted_version),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Run the stats call. Pure-ish: takes opts + fetch (so tests can stub) +
|
|
71
|
+
* returns a structured result. Mirrors `runReclassify` for symmetry.
|
|
72
|
+
*/
|
|
73
|
+
export async function runStats(opts, fetchImpl = fetch) {
|
|
74
|
+
const bridgeUrl = resolveBridgeUrl(opts);
|
|
75
|
+
const bearer = resolveBearer(opts);
|
|
76
|
+
if (!bearer) {
|
|
77
|
+
return {
|
|
78
|
+
ok: false,
|
|
79
|
+
error: 'AGENTMEMORY_BRIDGE_SECRET not set (or --bearer not passed)',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const res = await fetchImpl(`${bridgeUrl}/bridge/stats`, {
|
|
84
|
+
method: 'GET',
|
|
85
|
+
headers: {
|
|
86
|
+
authorization: `Bearer ${bearer}`,
|
|
87
|
+
},
|
|
88
|
+
signal: AbortSignal.timeout(STATS_TIMEOUT_MS),
|
|
89
|
+
});
|
|
90
|
+
if (!res.ok) {
|
|
91
|
+
const detail = await res.text().catch(() => '');
|
|
92
|
+
return {
|
|
93
|
+
ok: false,
|
|
94
|
+
error: `bridge returned ${res.status} ${res.statusText}${detail ? `: ${detail.slice(0, 200)}` : ''}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const payload = (await res.json());
|
|
98
|
+
if (!payload || typeof payload !== 'object' || !payload.stats || typeof payload.stats !== 'object') {
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
error: 'bridge response missing stats envelope',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const counters = extractCounters(payload.stats);
|
|
105
|
+
const cacheErrorRate = computeCacheErrorRate(counters);
|
|
106
|
+
return {
|
|
107
|
+
ok: true,
|
|
108
|
+
counters,
|
|
109
|
+
cacheErrorRate,
|
|
110
|
+
raw: payload,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
error: err instanceof Error ? err.message : String(err),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function formatPct(numerator, denominator) {
|
|
121
|
+
if (denominator <= 0)
|
|
122
|
+
return '0.0%';
|
|
123
|
+
return `${((numerator / denominator) * 100).toFixed(1)}%`;
|
|
124
|
+
}
|
|
125
|
+
/** Run + render. Returns the process exit code. */
|
|
126
|
+
export async function runStatsCli(opts) {
|
|
127
|
+
const result = await runStats(opts);
|
|
128
|
+
if (opts.json) {
|
|
129
|
+
// Preserve the raw bridge envelope when possible so jq pipelines
|
|
130
|
+
// see the same shape they'd get from curl. Fall back to the
|
|
131
|
+
// structured result on error so callers can still inspect.
|
|
132
|
+
const out = result.ok && result.raw !== undefined ? result.raw : result;
|
|
133
|
+
process.stdout.write(JSON.stringify(out, null, 2) + '\n');
|
|
134
|
+
return result.ok ? 0 : 1;
|
|
135
|
+
}
|
|
136
|
+
printHeader('olam memory stats — bridge counters');
|
|
137
|
+
if (!result.ok) {
|
|
138
|
+
printError(`stats failed: ${result.error ?? '(unknown error)'}`);
|
|
139
|
+
return 1;
|
|
140
|
+
}
|
|
141
|
+
const c = result.counters;
|
|
142
|
+
printInfo('writes_observed', String(c.writes_observed));
|
|
143
|
+
printInfo('writes_deduped_hash', `${c.writes_deduped_hash} (${formatPct(c.writes_deduped_hash, c.writes_observed)})`);
|
|
144
|
+
printInfo('writes_deduped_semantic', `${c.writes_deduped_semantic} (${formatPct(c.writes_deduped_semantic, c.writes_observed)})`);
|
|
145
|
+
printInfo('recalls_observed', String(c.recalls_observed));
|
|
146
|
+
printInfo('cache_busted_hash', String(c.cache_busted_hash));
|
|
147
|
+
printInfo('cache_busted_version', String(c.cache_busted_version));
|
|
148
|
+
printInfo('cache_error_rate', `${(result.cacheErrorRate * 100).toFixed(1)}%`);
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
export function registerMemoryStats(cmd) {
|
|
152
|
+
cmd
|
|
153
|
+
.command('stats')
|
|
154
|
+
.description('Fetch /bridge/stats from the agent-memory bridge and format classifier counters (writes_observed, dedup rates, recalls, cache busts, derived cache_error_rate)')
|
|
155
|
+
.option('--bridge-url <url>', 'Override AGENTMEMORY_BRIDGE_URL')
|
|
156
|
+
.option('--bearer <token>', 'Override AGENTMEMORY_BRIDGE_SECRET')
|
|
157
|
+
.option('--json', 'Machine-readable JSON output (raw bridge envelope)', false)
|
|
158
|
+
.action(async (opts) => {
|
|
159
|
+
const rc = await runStatsCli(opts);
|
|
160
|
+
if (rc !== 0)
|
|
161
|
+
process.exitCode = rc;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/commands/memory/stats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,kBAAkB,GAAG,mDAAmD,CAAC;AAC/E,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAiChC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAA+F;IAE/F,IAAI,QAAQ,CAAC,eAAe,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;IAC1E,OAAO,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC;AAC3C,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAkB;IAC1C,OAAO,IAAI,CAAC,SAAS;WAChB,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;WACrC,kBAAkB,CAAC;AAC1B,CAAC;AAED,SAAS,aAAa,CAAC,IAAkB;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAClD,MAAM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|
|
5
|
+
* olam skills source add --name <n> --git-url <url> [--branch <b>]
|
|
6
|
+
* olam skills source remove <id>
|
|
7
|
+
* olam skills source pull <id>
|
|
8
|
+
* olam skills source show <id>
|
|
9
|
+
*/
|
|
10
|
+
import type { Command } from 'commander';
|
|
11
|
+
export declare function registerSkillsSource(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=skills-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills-source.d.ts","sourceRoot":"","sources":["../../src/commands/skills-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2H3D"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* olam skills source — manage registered skill sources.
|
|
3
|
+
*
|
|
4
|
+
* olam skills source list
|
|
5
|
+
* olam skills source add --name <n> --git-url <url> [--branch <b>]
|
|
6
|
+
* olam skills source remove <id>
|
|
7
|
+
* olam skills source pull <id>
|
|
8
|
+
* olam skills source show <id>
|
|
9
|
+
*/
|
|
10
|
+
import pc from 'picocolors';
|
|
11
|
+
import { listSkillSources, getSkillSource, addSkillSource, removeSkillSource, updateSkillSource, cloneSkillSource, pullSkillSource, removeSkillSourceClone, skillSourceClonePath, } from '@olam/core/src/skill-sources/index.js';
|
|
12
|
+
import { printError, printSuccess, printHeader } from '../output.js';
|
|
13
|
+
function asMessage(err) {
|
|
14
|
+
return err instanceof Error ? err.message : String(err);
|
|
15
|
+
}
|
|
16
|
+
export function registerSkillsSource(program) {
|
|
17
|
+
const skills = program.command('skills').description('Manage skill sources and synchronization');
|
|
18
|
+
const source = skills.command('source').description('Manage registered skill sources');
|
|
19
|
+
source
|
|
20
|
+
.command('list')
|
|
21
|
+
.description('List all registered skill sources')
|
|
22
|
+
.action(() => {
|
|
23
|
+
const all = listSkillSources();
|
|
24
|
+
if (all.length === 0) {
|
|
25
|
+
console.log(pc.dim('0 skill source(s) registered. Add one with: olam skills source add --name <n> --git-url <url>'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
printHeader(`${all.length} skill source(s)`);
|
|
29
|
+
for (const s of all) {
|
|
30
|
+
const when = new Date(s.addedAt).toISOString().slice(0, 10);
|
|
31
|
+
const sha = s.lastPulledSha ? s.lastPulledSha.slice(0, 8) : pc.dim('(unpulled)');
|
|
32
|
+
console.log(` ${pc.bold(s.id.padEnd(14))} ${s.name.padEnd(24)} ${s.branch.padEnd(12)} ${sha.padEnd(12)} ${pc.dim(when)} ${pc.dim(s.gitUrl)}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
source
|
|
36
|
+
.command('add')
|
|
37
|
+
.description('Register and clone a skill source')
|
|
38
|
+
.requiredOption('--name <name>', 'Display name (lowercase, digits, dash)')
|
|
39
|
+
.requiredOption('--git-url <url>', 'git URL (https://, git@, ssh://, file://, or absolute path)')
|
|
40
|
+
.option('--branch <branch>', 'Branch to track', 'main')
|
|
41
|
+
.action((opts) => {
|
|
42
|
+
let entry;
|
|
43
|
+
try {
|
|
44
|
+
entry = addSkillSource({ name: opts.name, gitUrl: opts.gitUrl, branch: opts.branch });
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
printError(asMessage(err));
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const result = cloneSkillSource({
|
|
53
|
+
gitUrl: entry.gitUrl,
|
|
54
|
+
branch: entry.branch,
|
|
55
|
+
id: entry.id,
|
|
56
|
+
});
|
|
57
|
+
updateSkillSource(entry.id, { lastPulledSha: result.headSha });
|
|
58
|
+
printSuccess(`registered skill source "${entry.name}" (${entry.id}) at ${result.clonePath} @ ${result.headSha.slice(0, 8)}`);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
// Roll back the state-store entry so add stays atomic
|
|
62
|
+
try {
|
|
63
|
+
removeSkillSource(entry.id);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// best-effort rollback
|
|
67
|
+
}
|
|
68
|
+
printError(asMessage(err));
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
source
|
|
73
|
+
.command('remove')
|
|
74
|
+
.description('Remove a registered skill source (deletes its clone)')
|
|
75
|
+
.argument('<id>', 'Skill source id (from "olam skills source list")')
|
|
76
|
+
.action((id) => {
|
|
77
|
+
try {
|
|
78
|
+
removeSkillSourceClone(id);
|
|
79
|
+
removeSkillSource(id);
|
|
80
|
+
printSuccess(`removed skill source "${id}"`);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
printError(asMessage(err));
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
source
|
|
88
|
+
.command('pull')
|
|
89
|
+
.description('Fetch + reset the clone to upstream HEAD')
|
|
90
|
+
.argument('<id>', 'Skill source id')
|
|
91
|
+
.action((id) => {
|
|
92
|
+
try {
|
|
93
|
+
const entry = getSkillSource(id);
|
|
94
|
+
if (!entry) {
|
|
95
|
+
printError(`skill source "${id}" is not registered`);
|
|
96
|
+
process.exitCode = 1;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const result = pullSkillSource({
|
|
100
|
+
gitUrl: entry.gitUrl,
|
|
101
|
+
branch: entry.branch,
|
|
102
|
+
id: entry.id,
|
|
103
|
+
});
|
|
104
|
+
updateSkillSource(entry.id, { lastPulledSha: result.headSha });
|
|
105
|
+
printSuccess(`pulled "${entry.name}" → ${result.headSha.slice(0, 8)}`);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
printError(asMessage(err));
|
|
109
|
+
process.exitCode = 1;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
source
|
|
113
|
+
.command('show')
|
|
114
|
+
.description('Show details for a single skill source')
|
|
115
|
+
.argument('<id>', 'Skill source id')
|
|
116
|
+
.action((id) => {
|
|
117
|
+
const entry = getSkillSource(id);
|
|
118
|
+
if (!entry) {
|
|
119
|
+
printError(`skill source "${id}" is not registered`);
|
|
120
|
+
process.exitCode = 1;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const when = new Date(entry.addedAt).toISOString();
|
|
124
|
+
console.log(`${pc.bold('id:')} ${entry.id}`);
|
|
125
|
+
console.log(`${pc.bold('name:')} ${entry.name}`);
|
|
126
|
+
console.log(`${pc.bold('gitUrl:')} ${entry.gitUrl}`);
|
|
127
|
+
console.log(`${pc.bold('branch:')} ${entry.branch}`);
|
|
128
|
+
console.log(`${pc.bold('addedAt:')} ${when}`);
|
|
129
|
+
console.log(`${pc.bold('lastPulledSha:')} ${entry.lastPulledSha ?? pc.dim('(unpulled)')}`);
|
|
130
|
+
console.log(`${pc.bold('clonePath:')} ${skillSourceClonePath(entry.id)}`);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=skills-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills-source.js","sourceRoot":"","sources":["../../src/commands/skills-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,SAAS,SAAS,CAAC,GAAY;IAC7B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;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,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAC3F,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* olam skills — sync, dry-run/diff, list-installed, show.
|
|
3
|
+
*
|
|
4
|
+
* olam skills sync [--dry-run] [--atlas-user <u>]
|
|
5
|
+
* olam skills diff [--atlas-user <u>] (alias of `sync --dry-run`)
|
|
6
|
+
* olam skills list (lists deployed artifacts)
|
|
7
|
+
* olam skills show <name> (shows details for a deployed artifact)
|
|
8
|
+
*/
|
|
9
|
+
import type { Command } from 'commander';
|
|
10
|
+
export declare function registerSkills(program: Command): void;
|
|
11
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/commands/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0FzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgFrD"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* olam skills — sync, dry-run/diff, list-installed, show.
|
|
3
|
+
*
|
|
4
|
+
* olam skills sync [--dry-run] [--atlas-user <u>]
|
|
5
|
+
* olam skills diff [--atlas-user <u>] (alias of `sync --dry-run`)
|
|
6
|
+
* olam skills list (lists deployed artifacts)
|
|
7
|
+
* olam skills show <name> (shows details for a deployed artifact)
|
|
8
|
+
*/
|
|
9
|
+
import * as fs from 'node:fs';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import pc from 'picocolors';
|
|
12
|
+
import { syncSkills, claudeDir, listSkillSources, skillSourceClonePath, } from '@olam/core/src/skill-sources/index.js';
|
|
13
|
+
import { printError, printSuccess, printHeader } from '../output.js';
|
|
14
|
+
function asMessage(err) {
|
|
15
|
+
return err instanceof Error ? err.message : String(err);
|
|
16
|
+
}
|
|
17
|
+
function listDeployed() {
|
|
18
|
+
const dir = claudeDir();
|
|
19
|
+
const sources = listSkillSources();
|
|
20
|
+
const sourcePaths = new Map(sources.map((s) => [skillSourceClonePath(s.id), s.id]));
|
|
21
|
+
const entries = [];
|
|
22
|
+
for (const bucket of ['skills', 'agents', 'scripts', 'rules', 'commands']) {
|
|
23
|
+
const bucketDir = path.join(dir, bucket);
|
|
24
|
+
if (!fs.existsSync(bucketDir))
|
|
25
|
+
continue;
|
|
26
|
+
for (const name of fs.readdirSync(bucketDir)) {
|
|
27
|
+
const full = path.join(bucketDir, name);
|
|
28
|
+
try {
|
|
29
|
+
const stat = fs.lstatSync(full);
|
|
30
|
+
if (!stat.isSymbolicLink())
|
|
31
|
+
continue;
|
|
32
|
+
const target = fs.readlinkSync(full);
|
|
33
|
+
let sourceId;
|
|
34
|
+
for (const [clonePath, id] of sourcePaths.entries()) {
|
|
35
|
+
if (target.startsWith(clonePath)) {
|
|
36
|
+
sourceId = id;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
entries.push({ bucket, name, target, sourceId });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// ignore
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return entries;
|
|
48
|
+
}
|
|
49
|
+
function printSyncSummary(summary, dryRun) {
|
|
50
|
+
printHeader(dryRun ? 'dry-run summary' : 'sync summary');
|
|
51
|
+
console.log(` sources: ${summary.sourceCount}`);
|
|
52
|
+
console.log(` artifacts: ${summary.artifactCount}`);
|
|
53
|
+
console.log(` hook files: ${summary.hookFileCount}`);
|
|
54
|
+
console.log(` permission files:${summary.permissionFileCount}`);
|
|
55
|
+
if (summary.deploy) {
|
|
56
|
+
console.log(` symlinks made: ${summary.deploy.linked}`);
|
|
57
|
+
if (summary.deploy.shadowBackups.length > 0) {
|
|
58
|
+
console.log(` ${pc.yellow('shadow backups:')} ${summary.deploy.shadowBackups.length}`);
|
|
59
|
+
for (const p of summary.deploy.shadowBackups)
|
|
60
|
+
console.log(` ${pc.dim(p)}`);
|
|
61
|
+
}
|
|
62
|
+
if (summary.deploy.subagentCollisions.length > 0) {
|
|
63
|
+
console.log(` ${pc.yellow('agent name collisions:')} ${summary.deploy.subagentCollisions.length}`);
|
|
64
|
+
for (const c of summary.deploy.subagentCollisions) {
|
|
65
|
+
console.log(` ${pc.bold(c.name)} → winner: ${pc.dim(c.winner)}`);
|
|
66
|
+
for (const l of c.losers)
|
|
67
|
+
console.log(` ${pc.dim('(skipped)')} ${l}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (summary.merge) {
|
|
72
|
+
console.log(` hooks added: ${summary.merge.hooksAdded}`);
|
|
73
|
+
console.log(` permissions: ${summary.merge.permissionsCount}`);
|
|
74
|
+
if (summary.merge.backupPath) {
|
|
75
|
+
console.log(` settings backup: ${pc.dim(summary.merge.backupPath)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
console.log();
|
|
79
|
+
for (const s of summary.perSource) {
|
|
80
|
+
const sub = s.fromSubscriptionsFile ? '(subscribed)' : '(all categories)';
|
|
81
|
+
console.log(` ${pc.bold(s.name.padEnd(24))} ${s.artifactCount} artifacts · ${s.categories.join(', ') || '(none)'} ${pc.dim(sub)}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function registerSkills(program) {
|
|
85
|
+
const skills = program.commands.find((c) => c.name() === 'skills') ?? program.command('skills').description('Manage skill sources and synchronization');
|
|
86
|
+
skills
|
|
87
|
+
.command('sync')
|
|
88
|
+
.description('Sync registered skill sources to ~/.claude/')
|
|
89
|
+
.option('--dry-run', 'Resolve artifacts but do not deploy or merge')
|
|
90
|
+
.option('--atlas-user <user>', 'Override atlas-user (defaults to ~/.claude/.atlas-user)')
|
|
91
|
+
.action(async (opts) => {
|
|
92
|
+
try {
|
|
93
|
+
const summary = await syncSkills({ dryRun: opts.dryRun, atlasUser: opts.atlasUser });
|
|
94
|
+
printSyncSummary(summary, !!opts.dryRun);
|
|
95
|
+
if (!opts.dryRun) {
|
|
96
|
+
printSuccess(`synced ${summary.sourceCount} source(s), ${summary.artifactCount} artifact(s)`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
printError(asMessage(err));
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
skills
|
|
105
|
+
.command('diff')
|
|
106
|
+
.description('Show what `olam skills sync` would deploy (no on-disk changes)')
|
|
107
|
+
.option('--atlas-user <user>', 'Override atlas-user')
|
|
108
|
+
.action(async (opts) => {
|
|
109
|
+
try {
|
|
110
|
+
const summary = await syncSkills({ dryRun: true, atlasUser: opts.atlasUser });
|
|
111
|
+
printSyncSummary(summary, true);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
printError(asMessage(err));
|
|
115
|
+
process.exitCode = 1;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
skills
|
|
119
|
+
.command('list')
|
|
120
|
+
.description('List artifacts currently deployed to ~/.claude/')
|
|
121
|
+
.action(() => {
|
|
122
|
+
const entries = listDeployed();
|
|
123
|
+
if (entries.length === 0) {
|
|
124
|
+
console.log(pc.dim('0 deployed artifact(s). Run "olam skills sync" first.'));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const byBucket = new Map();
|
|
128
|
+
for (const e of entries) {
|
|
129
|
+
const list = byBucket.get(e.bucket) ?? [];
|
|
130
|
+
list.push(e);
|
|
131
|
+
byBucket.set(e.bucket, list);
|
|
132
|
+
}
|
|
133
|
+
printHeader(`${entries.length} deployed artifact(s)`);
|
|
134
|
+
for (const [bucket, list] of byBucket.entries()) {
|
|
135
|
+
console.log(` ${pc.bold(bucket)} (${list.length})`);
|
|
136
|
+
for (const e of list) {
|
|
137
|
+
const src = e.sourceId ? `[${e.sourceId}]` : pc.yellow('[unknown]');
|
|
138
|
+
console.log(` ${e.name.padEnd(40)} ${pc.dim(src)} → ${pc.dim(e.target)}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
skills
|
|
143
|
+
.command('show')
|
|
144
|
+
.description('Show details for a deployed artifact (by name)')
|
|
145
|
+
.argument('<name>', 'Artifact name (e.g. plan-hard, codex-second-opinion.md)')
|
|
146
|
+
.action((name) => {
|
|
147
|
+
const entries = listDeployed();
|
|
148
|
+
const matches = entries.filter((e) => e.name === name);
|
|
149
|
+
if (matches.length === 0) {
|
|
150
|
+
printError(`no deployed artifact matches "${name}"`);
|
|
151
|
+
process.exitCode = 1;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
for (const e of matches) {
|
|
155
|
+
console.log(`${pc.bold('bucket:')} ${e.bucket}`);
|
|
156
|
+
console.log(`${pc.bold('name:')} ${e.name}`);
|
|
157
|
+
console.log(`${pc.bold('target:')} ${e.target}`);
|
|
158
|
+
console.log(`${pc.bold('source:')} ${e.sourceId ?? pc.dim('(unknown — not from a registered olam source)')}`);
|
|
159
|
+
console.log();
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/commands/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,SAAS,SAAS,CAAC,GAAY;IAC7B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AASD,SAAS,YAAY;IACnB,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,MAAM,WAAW,GAAG,IAAI,GAAG,CACzB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACvD,CAAC;IAEF,MAAM,OAAO,GAAoB,EAAE,CAAC;IACpC,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;QAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACzC,IAAI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
|
@@ -11,6 +11,33 @@
|
|
|
11
11
|
* transitive @olam/adapters resolution.
|
|
12
12
|
*/
|
|
13
13
|
import type { Command } from 'commander';
|
|
14
|
+
/**
|
|
15
|
+
* Canonical runtime-state contract per Decision 17. Surfaced by host-cp's
|
|
16
|
+
* `GET /v1/worlds/:id/status` endpoint; both Docker and Kubernetes engines
|
|
17
|
+
* map their native state onto this shape so the wire-format is identical.
|
|
18
|
+
*/
|
|
19
|
+
export interface WorldRuntimeStatus {
|
|
20
|
+
readonly state: 'running' | 'starting' | 'stopped' | 'crashed' | 'unknown';
|
|
21
|
+
readonly ready_replicas: number;
|
|
22
|
+
readonly restarts: number;
|
|
23
|
+
readonly last_event_type: string | null;
|
|
24
|
+
readonly last_event_age_seconds: number | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse and validate a server response payload into WorldRuntimeStatus.
|
|
28
|
+
* Returns null on any shape mismatch so the caller falls back gracefully.
|
|
29
|
+
* Exported for unit testing.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseRuntimeStatus(raw: unknown): WorldRuntimeStatus | null;
|
|
32
|
+
export type FetchRuntimeFn = (worldId: string, token: string) => Promise<WorldRuntimeStatus | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Default fetcher — hits host-cp's /v1/worlds/:id/status via the loopback
|
|
35
|
+
* port with a 2-second timeout. Returns null on any error so the calling
|
|
36
|
+
* `olam status` command renders the registry view without the runtime
|
|
37
|
+
* block when host-cp is down or the engine fails (preserves the legacy
|
|
38
|
+
* behaviour for operators with a stopped host-cp).
|
|
39
|
+
*/
|
|
40
|
+
export declare const fetchWorldRuntimeStatus: FetchRuntimeFn;
|
|
14
41
|
export interface MachineStatus {
|
|
15
42
|
readonly version: string;
|
|
16
43
|
readonly port: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
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