@ouro.bot/cli 0.1.0-alpha.998 → 0.1.0-alpha.999
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/changelog.json +6 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/agent-entry.js +4 -3
- package/dist/heart/daemon/daemon-entry.js +6 -1
- package/dist/heart/daemon/process-manager.js +3 -0
- package/dist/heart/daemon/sense-manager.js +3 -1
- package/dist/heart/runtime-credentials.js +40 -1
- package/dist/senses/shepherd-entry.js +2 -2
- package/dist/senses/telegram-entry.js +6 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.999",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Agent workers and senses start without asking the vault again. The daemon now reads this machine's runtime config in its startup vault pass and tells each worker and sense which items the vault said don't exist, so a child only asks the vault for what the daemon couldn't settle. A worker's start goes from three vault CLI runs to none, which on a small Linux machine saves about 15 seconds and 125 MB at its first message."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.998",
|
|
6
12
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.999</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -161,7 +161,7 @@ function providerPoolMissingTargets(providerPool, providers) {
|
|
|
161
161
|
}
|
|
162
162
|
// Dynamic import: agent-entry is process-start wiring that starts a sense process.
|
|
163
163
|
// Using dynamic import avoids a static heart/ -> senses/ dependency.
|
|
164
|
-
Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).then(async ({
|
|
164
|
+
Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).then(async ({ refreshMachineRuntimeCredentialConfig, refreshRuntimeCredentialConfig, runtimeCredentialConfigSettled, applyRuntimeCredentialBootstrapMessage, waitForRuntimeCredentialBootstrap, }) => {
|
|
165
165
|
const { readProviderCredentialPool, refreshProviderCredentialPool } = await Promise.resolve().then(() => __importStar(require("./provider-credentials")));
|
|
166
166
|
const bootstrappedBeforeWait = drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage);
|
|
167
167
|
const bootstrappedDuringWait = bootstrappedBeforeWait ? true : await waitForRuntimeCredentialBootstrap(agentName);
|
|
@@ -171,7 +171,8 @@ Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).the
|
|
|
171
171
|
else {
|
|
172
172
|
drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage);
|
|
173
173
|
}
|
|
174
|
-
|
|
174
|
+
// Ask the vault only for what the daemon's bootstrap didn't settle: each ask spawns the vault CLI.
|
|
175
|
+
if (!runtimeCredentialConfigSettled(agentName, "runtimeConfig")) {
|
|
175
176
|
await refreshRuntimeCredentialConfig(agentName, { preserveCachedOnFailure: true }).catch(() => undefined);
|
|
176
177
|
}
|
|
177
178
|
const providerPool = readProviderCredentialPool(agentName);
|
|
@@ -179,7 +180,7 @@ Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).the
|
|
|
179
180
|
if (providerTargets.length > 0 && providerPoolMissingTargets(providerPool, providerTargets)) {
|
|
180
181
|
await refreshProviderCredentialPool(agentName, { preserveCachedOnFailure: true, providers: providerTargets }).catch(() => undefined);
|
|
181
182
|
}
|
|
182
|
-
if (!
|
|
183
|
+
if (!runtimeCredentialConfigSettled(agentName, "machineRuntimeConfig")) {
|
|
183
184
|
await Promise.resolve().then(() => __importStar(require("./machine-identity"))).then(({ loadOrCreateMachineIdentity }) => {
|
|
184
185
|
const machine = loadOrCreateMachineIdentity();
|
|
185
186
|
return refreshMachineRuntimeCredentialConfig(agentName, machine.machineId, { preserveCachedOnFailure: true });
|
|
@@ -144,14 +144,16 @@ function privateRuntimeCredentialBootstrapFor(agent) {
|
|
|
144
144
|
const providerCredentialRecords = providerPool.ok
|
|
145
145
|
? Object.values(providerPool.pool.providers).filter((record) => !!record)
|
|
146
146
|
: [];
|
|
147
|
+
const absent = (0, runtime_credentials_1.confirmedAbsentRuntimeCredentialItems)(agent);
|
|
147
148
|
const bootstrap = {
|
|
148
149
|
agentName: agent,
|
|
149
150
|
runtimeConfig: runtime.ok ? runtime.config : undefined,
|
|
150
151
|
machineRuntimeConfig: machine.ok ? machine.config : undefined,
|
|
151
152
|
machineId,
|
|
152
153
|
providerCredentialRecords: providerCredentialRecords.length > 0 ? providerCredentialRecords : undefined,
|
|
154
|
+
absent: absent.length > 0 ? absent : undefined,
|
|
153
155
|
};
|
|
154
|
-
if (!bootstrap.runtimeConfig && !bootstrap.machineRuntimeConfig && !bootstrap.providerCredentialRecords)
|
|
156
|
+
if (!bootstrap.runtimeConfig && !bootstrap.machineRuntimeConfig && !bootstrap.providerCredentialRecords && !bootstrap.absent)
|
|
155
157
|
return null;
|
|
156
158
|
return bootstrap;
|
|
157
159
|
}
|
|
@@ -627,6 +629,9 @@ async function prepareProviderRuntime() {
|
|
|
627
629
|
const readiness = await Promise.all(readinessAgents.map(async (agent) => {
|
|
628
630
|
try {
|
|
629
631
|
await (0, runtime_credentials_1.refreshRuntimeCredentialConfig)(agent, { preserveCachedOnFailure: true });
|
|
632
|
+
// Read from the same vault listing: whether this machine has config or not, the
|
|
633
|
+
// daemon then knows, and its bootstrap spares each worker and sense a vault CLI run.
|
|
634
|
+
await (0, runtime_credentials_1.refreshMachineRuntimeCredentialConfig)(agent, daemonMachineId, { preserveCachedOnFailure: true });
|
|
630
635
|
const result = await (0, agent_config_check_1.checkAgentConfigWithProviderHealth)(agent, bundlesRoot);
|
|
631
636
|
if (result.ok)
|
|
632
637
|
return null;
|
|
@@ -369,6 +369,8 @@ class DaemonProcessManager {
|
|
|
369
369
|
message.machineId = bootstrap.machineId;
|
|
370
370
|
if (bootstrap.providerCredentialRecords)
|
|
371
371
|
message.providerCredentialRecords = bootstrap.providerCredentialRecords;
|
|
372
|
+
if (bootstrap.absent)
|
|
373
|
+
message.absent = bootstrap.absent;
|
|
372
374
|
try {
|
|
373
375
|
child.send?.(message);
|
|
374
376
|
(0, runtime_1.emitNervesEvent)({
|
|
@@ -380,6 +382,7 @@ class DaemonProcessManager {
|
|
|
380
382
|
runtimeConfig: !!bootstrap.runtimeConfig,
|
|
381
383
|
machineRuntimeConfig: !!bootstrap.machineRuntimeConfig,
|
|
382
384
|
providerCredentialRecords: bootstrap.providerCredentialRecords?.length ?? 0,
|
|
385
|
+
absent: bootstrap.absent ?? [],
|
|
383
386
|
},
|
|
384
387
|
});
|
|
385
388
|
}
|
|
@@ -438,14 +438,16 @@ function runtimeCredentialBootstrapFor(agent) {
|
|
|
438
438
|
const providerCredentialRecords = providerPool.ok
|
|
439
439
|
? Object.values(providerPool.pool.providers).filter((record) => !!record)
|
|
440
440
|
: [];
|
|
441
|
+
const absent = (0, runtime_credentials_1.confirmedAbsentRuntimeCredentialItems)(agent);
|
|
441
442
|
const bootstrap = {
|
|
442
443
|
agentName: agent,
|
|
443
444
|
runtimeConfig: runtime.ok ? runtime.config : undefined,
|
|
444
445
|
machineRuntimeConfig: machine.ok ? machine.config : undefined,
|
|
445
446
|
machineId,
|
|
446
447
|
providerCredentialRecords: providerCredentialRecords.length > 0 ? providerCredentialRecords : undefined,
|
|
448
|
+
absent: absent.length > 0 ? absent : undefined,
|
|
447
449
|
};
|
|
448
|
-
if (!bootstrap.runtimeConfig && !bootstrap.machineRuntimeConfig && !bootstrap.providerCredentialRecords)
|
|
450
|
+
if (!bootstrap.runtimeConfig && !bootstrap.machineRuntimeConfig && !bootstrap.providerCredentialRecords && !bootstrap.absent)
|
|
449
451
|
return null;
|
|
450
452
|
return bootstrap;
|
|
451
453
|
}
|
|
@@ -37,6 +37,8 @@ exports.MACHINE_RUNTIME_CONFIG_ITEM_PREFIX = exports.RUNTIME_CONFIG_ITEM_NAME =
|
|
|
37
37
|
exports.machineRuntimeConfigItemName = machineRuntimeConfigItemName;
|
|
38
38
|
exports.readRuntimeCredentialConfig = readRuntimeCredentialConfig;
|
|
39
39
|
exports.readMachineRuntimeCredentialConfig = readMachineRuntimeCredentialConfig;
|
|
40
|
+
exports.runtimeCredentialConfigSettled = runtimeCredentialConfigSettled;
|
|
41
|
+
exports.confirmedAbsentRuntimeCredentialItems = confirmedAbsentRuntimeCredentialItems;
|
|
40
42
|
exports.cacheRuntimeCredentialConfig = cacheRuntimeCredentialConfig;
|
|
41
43
|
exports.cacheMachineRuntimeCredentialConfig = cacheMachineRuntimeCredentialConfig;
|
|
42
44
|
exports.isRuntimeCredentialBootstrapMessage = isRuntimeCredentialBootstrapMessage;
|
|
@@ -55,6 +57,7 @@ const runtime_1 = require("../nerves/runtime");
|
|
|
55
57
|
const credential_access_1 = require("../repertoire/credential-access");
|
|
56
58
|
const identity_1 = require("./identity");
|
|
57
59
|
const provider_credentials_1 = require("./provider-credentials");
|
|
60
|
+
const RUNTIME_CREDENTIAL_ITEM_KINDS = ["runtimeConfig", "machineRuntimeConfig"];
|
|
58
61
|
exports.RUNTIME_CONFIG_ITEM_NAME = "runtime/config";
|
|
59
62
|
exports.MACHINE_RUNTIME_CONFIG_ITEM_PREFIX = "runtime/machines";
|
|
60
63
|
let cachedRuntimeConfigs = new Map();
|
|
@@ -257,6 +260,23 @@ function readRuntimeCredentialConfig(agentName = (0, identity_1.getAgentName)())
|
|
|
257
260
|
function readMachineRuntimeCredentialConfig(agentName = (0, identity_1.getAgentName)()) {
|
|
258
261
|
return cachedMachineRuntimeConfigs.get(agentName) ?? missingMachineRuntimeConfig(agentName);
|
|
259
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* True once the vault itself has answered for this item in this process: the
|
|
265
|
+
* item was loaded, or the vault (or the daemon's bootstrap, on the vault's
|
|
266
|
+
* word) said it doesn't exist. False when it was never read or the vault was
|
|
267
|
+
* unreachable, which are the only cases worth another vault round trip.
|
|
268
|
+
*/
|
|
269
|
+
function runtimeCredentialConfigSettled(agentName, kind) {
|
|
270
|
+
const cached = (kind === "runtimeConfig" ? cachedRuntimeConfigs : cachedMachineRuntimeConfigs).get(agentName);
|
|
271
|
+
return !!cached && (cached.ok || cached.reason === "missing");
|
|
272
|
+
}
|
|
273
|
+
/** The items the vault confirmed missing for this agent, for a child process's bootstrap. */
|
|
274
|
+
function confirmedAbsentRuntimeCredentialItems(agentName) {
|
|
275
|
+
return RUNTIME_CREDENTIAL_ITEM_KINDS.filter((kind) => {
|
|
276
|
+
const cached = (kind === "runtimeConfig" ? cachedRuntimeConfigs : cachedMachineRuntimeConfigs).get(agentName);
|
|
277
|
+
return !!cached && !cached.ok && cached.reason === "missing";
|
|
278
|
+
});
|
|
279
|
+
}
|
|
260
280
|
function cacheRuntimeCredentialConfig(agentName, config, now = new Date()) {
|
|
261
281
|
const payload = {
|
|
262
282
|
schemaVersion: 1,
|
|
@@ -286,6 +306,7 @@ function isRuntimeCredentialBootstrapMessage(value) {
|
|
|
286
306
|
"machineRuntimeConfig",
|
|
287
307
|
"machineId",
|
|
288
308
|
"providerCredentialRecords",
|
|
309
|
+
"absent",
|
|
289
310
|
].includes(key)))
|
|
290
311
|
return false;
|
|
291
312
|
if (record.type !== "ouro.runtimeCredentialBootstrap")
|
|
@@ -310,9 +331,20 @@ function isRuntimeCredentialBootstrapMessage(value) {
|
|
|
310
331
|
if (new Set(providers).size !== providers.length)
|
|
311
332
|
return false;
|
|
312
333
|
}
|
|
334
|
+
if (record.absent !== undefined) {
|
|
335
|
+
if (!Array.isArray(record.absent) || record.absent.length === 0)
|
|
336
|
+
return false;
|
|
337
|
+
if (!record.absent.every((kind) => RUNTIME_CREDENTIAL_ITEM_KINDS.includes(kind)))
|
|
338
|
+
return false;
|
|
339
|
+
if (new Set(record.absent).size !== record.absent.length)
|
|
340
|
+
return false;
|
|
341
|
+
if (record.absent.some((kind) => record[kind] !== undefined))
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
313
344
|
if (record.runtimeConfig === undefined
|
|
314
345
|
&& record.machineRuntimeConfig === undefined
|
|
315
|
-
&& (!Array.isArray(record.providerCredentialRecords) || record.providerCredentialRecords.length === 0)
|
|
346
|
+
&& (!Array.isArray(record.providerCredentialRecords) || record.providerCredentialRecords.length === 0)
|
|
347
|
+
&& record.absent === undefined)
|
|
316
348
|
return false;
|
|
317
349
|
return true;
|
|
318
350
|
}
|
|
@@ -330,6 +362,12 @@ function applyRuntimeCredentialBootstrapMessage(message) {
|
|
|
330
362
|
if (message.providerCredentialRecords && message.providerCredentialRecords.length > 0) {
|
|
331
363
|
(0, provider_credentials_1.cacheProviderCredentialRecords)(agentName, message.providerCredentialRecords, now);
|
|
332
364
|
}
|
|
365
|
+
const absent = message.absent ?? [];
|
|
366
|
+
if (absent.includes("runtimeConfig"))
|
|
367
|
+
cacheResult(agentName, missingRuntimeConfig(agentName));
|
|
368
|
+
if (absent.includes("machineRuntimeConfig")) {
|
|
369
|
+
cacheMachineResult(agentName, missingRuntimeConfig(agentName, machineRuntimeConfigItemName(message.machineId ?? "<this-machine>")));
|
|
370
|
+
}
|
|
333
371
|
(0, runtime_1.emitNervesEvent)({
|
|
334
372
|
component: "config/identity",
|
|
335
373
|
event: "config.runtime_credentials_bootstrapped",
|
|
@@ -339,6 +377,7 @@ function applyRuntimeCredentialBootstrapMessage(message) {
|
|
|
339
377
|
runtimeConfig: !!message.runtimeConfig,
|
|
340
378
|
machineRuntimeConfig: !!message.machineRuntimeConfig,
|
|
341
379
|
providerCredentialRecords: message.providerCredentialRecords?.length ?? 0,
|
|
380
|
+
absent,
|
|
342
381
|
},
|
|
343
382
|
});
|
|
344
383
|
return true;
|
|
@@ -49,9 +49,9 @@ const runtime_1 = require("../nerves/runtime");
|
|
|
49
49
|
message: "booting Shepherd entrypoint",
|
|
50
50
|
meta: { entry: "shepherd", agentName },
|
|
51
51
|
});
|
|
52
|
-
Promise.resolve().then(() => __importStar(require("../heart/runtime-credentials"))).then(async ({ readMachineRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, waitForRuntimeCredentialBootstrap }) => {
|
|
52
|
+
Promise.resolve().then(() => __importStar(require("../heart/runtime-credentials"))).then(async ({ readMachineRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, runtimeCredentialConfigSettled, waitForRuntimeCredentialBootstrap }) => {
|
|
53
53
|
await waitForRuntimeCredentialBootstrap(agentName);
|
|
54
|
-
if (!
|
|
54
|
+
if (!runtimeCredentialConfigSettled(agentName, "machineRuntimeConfig")) {
|
|
55
55
|
const { loadOrCreateMachineIdentity } = await Promise.resolve().then(() => __importStar(require("../heart/machine-identity")));
|
|
56
56
|
await refreshMachineRuntimeCredentialConfig(agentName, loadOrCreateMachineIdentity().machineId, { preserveCachedOnFailure: true }).catch(() => undefined);
|
|
57
57
|
}
|
|
@@ -54,13 +54,16 @@ Promise.all([
|
|
|
54
54
|
Promise.resolve().then(() => __importStar(require("../heart/machine-identity"))),
|
|
55
55
|
Promise.resolve().then(() => __importStar(require("./telegram"))),
|
|
56
56
|
])
|
|
57
|
-
.then(async ([{ waitForRuntimeCredentialBootstrap, readRuntimeCredentialConfig, refreshRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig }, { loadOrCreateMachineIdentity }, { startTelegramSenseApp }]) => {
|
|
57
|
+
.then(async ([{ waitForRuntimeCredentialBootstrap, readRuntimeCredentialConfig, refreshRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, runtimeCredentialConfigSettled }, { loadOrCreateMachineIdentity }, { startTelegramSenseApp }]) => {
|
|
58
58
|
const bootstrapped = await waitForRuntimeCredentialBootstrap(agentName);
|
|
59
59
|
if (!bootstrapped && !readRuntimeCredentialConfig(agentName).ok) {
|
|
60
60
|
await refreshRuntimeCredentialConfig(agentName);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// Each vault ask spawns the vault CLI; skip it when the daemon's bootstrap already settled this machine's config.
|
|
63
|
+
if (!runtimeCredentialConfigSettled(agentName, "machineRuntimeConfig")) {
|
|
64
|
+
const machine = loadOrCreateMachineIdentity();
|
|
65
|
+
await refreshMachineRuntimeCredentialConfig(agentName, machine.machineId, { preserveCachedOnFailure: true }).catch(() => undefined);
|
|
66
|
+
}
|
|
64
67
|
const app = await startTelegramSenseApp(agentName, true);
|
|
65
68
|
let stopping;
|
|
66
69
|
const stop = () => { stopping ??= app.stop(); };
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.999",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.999",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@azure/identity": "^4.13.0",
|