@ouro.bot/cli 0.1.0-alpha.997 → 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 +12 -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/mailroom/azure-sdk.js +27 -0
- package/dist/mailroom/core.js +3 -2
- package/dist/mailroom/reader.js +17 -18
- package/dist/repertoire/stripe-client.js +36 -5
- 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,18 @@
|
|
|
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
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.998",
|
|
12
|
+
"changes": [
|
|
13
|
+
"Ouro starts leaner: the CLI and the daemon no longer load the Stripe, Azure storage and identity, or mailparser SDKs at startup. Each loads on the first card, hosted-mail or mail-parse call that needs it, which takes `ouro --version` from 1,483 to about 863 modules and roughly 35 MB less memory per process. An integration contract test keeps product SDKs out of startup and caps its module count and memory."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.997",
|
|
6
18
|
"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;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAzureBlobSdk = loadAzureBlobSdk;
|
|
4
|
+
const runtime_1 = require("../nerves/runtime");
|
|
5
|
+
let loaded = null;
|
|
6
|
+
/**
|
|
7
|
+
* The Azure storage and identity SDKs, loaded on first use.
|
|
8
|
+
*
|
|
9
|
+
* They cost about 22 MB and 200 modules in every process that imports them, and
|
|
10
|
+
* only a hosted mailroom needs them, so callers reach them through this
|
|
11
|
+
* function instead of a top-level import.
|
|
12
|
+
*/
|
|
13
|
+
function loadAzureBlobSdk() {
|
|
14
|
+
if (loaded)
|
|
15
|
+
return loaded;
|
|
16
|
+
const { BlobServiceClient } = require("@azure/storage-blob");
|
|
17
|
+
const { DefaultAzureCredential } = require("@azure/identity");
|
|
18
|
+
loaded = { BlobServiceClient, DefaultAzureCredential };
|
|
19
|
+
(0, runtime_1.emitNervesEvent)({
|
|
20
|
+
level: "debug",
|
|
21
|
+
component: "senses",
|
|
22
|
+
event: "senses.mail_azure_sdk_loaded",
|
|
23
|
+
message: "loaded the Azure storage and identity SDKs for hosted mail",
|
|
24
|
+
meta: {},
|
|
25
|
+
});
|
|
26
|
+
return loaded;
|
|
27
|
+
}
|
package/dist/mailroom/core.js
CHANGED
|
@@ -57,7 +57,6 @@ exports.readDecryptedMailMessage = readDecryptedMailMessage;
|
|
|
57
57
|
exports.provisionMailboxRegistry = provisionMailboxRegistry;
|
|
58
58
|
exports.ensureMailboxRegistry = ensureMailboxRegistry;
|
|
59
59
|
const crypto = __importStar(require("node:crypto"));
|
|
60
|
-
const mailparser_1 = require("mailparser");
|
|
61
60
|
const runtime_1 = require("../nerves/runtime");
|
|
62
61
|
const LOCAL_PART_LIMIT = 64;
|
|
63
62
|
const SNIPPET_LIMIT = 240;
|
|
@@ -455,7 +454,9 @@ function privateMailEnvelopeReadableText(privateEnvelope) {
|
|
|
455
454
|
return htmlMailBodyToText(privateEnvelope.html);
|
|
456
455
|
}
|
|
457
456
|
async function parsePrivateMailEnvelope(rawMime) {
|
|
458
|
-
|
|
457
|
+
// mailparser and its charset tables cost about 19 MB per process; load it on the first parse.
|
|
458
|
+
const { simpleParser } = await Promise.resolve().then(() => __importStar(require("mailparser")));
|
|
459
|
+
const parsed = await simpleParser(rawMime);
|
|
459
460
|
const html = typeof parsed.html === "string" ? parsed.html : undefined;
|
|
460
461
|
const parsedText = parsed.text ?? "";
|
|
461
462
|
/* v8 ignore next -- mailparser body-shape ternary permutations are covered by plain-text, HTML-only, and empty-MIME tests; this line is a projection adapter, not policy. @preserve */
|
package/dist/mailroom/reader.js
CHANGED
|
@@ -41,10 +41,9 @@ exports.resolveHostedMailAuthority = resolveHostedMailAuthority;
|
|
|
41
41
|
exports.resolveMailroomReaderWithRefresh = resolveMailroomReaderWithRefresh;
|
|
42
42
|
const fs = __importStar(require("node:fs"));
|
|
43
43
|
const path = __importStar(require("node:path"));
|
|
44
|
-
const
|
|
45
|
-
const identity_1 = require("@azure/identity");
|
|
44
|
+
const azure_sdk_1 = require("./azure-sdk");
|
|
46
45
|
const runtime_1 = require("../nerves/runtime");
|
|
47
|
-
const
|
|
46
|
+
const identity_1 = require("../heart/identity");
|
|
48
47
|
const runtime_credentials_1 = require("../heart/runtime-credentials");
|
|
49
48
|
const blob_store_1 = require("./blob-store");
|
|
50
49
|
const file_store_1 = require("./file-store");
|
|
@@ -107,27 +106,29 @@ function parseMailroomConfig(value) {
|
|
|
107
106
|
privateKeys,
|
|
108
107
|
};
|
|
109
108
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
function createBlobServiceClient(accountUrl, managedIdentityClientId) {
|
|
110
|
+
const { BlobServiceClient: Client, DefaultAzureCredential } = (0, azure_sdk_1.loadAzureBlobSdk)();
|
|
111
|
+
const credential = managedIdentityClientId
|
|
112
|
+
? new DefaultAzureCredential({ managedIdentityClientId })
|
|
113
|
+
: new DefaultAzureCredential();
|
|
114
|
+
return new Client(accountUrl, credential);
|
|
114
115
|
}
|
|
115
116
|
function createMailroomStore(config, agentName) {
|
|
116
117
|
if (config.azureAccountUrl) {
|
|
117
118
|
const containerName = config.azureContainer ?? "mailroom";
|
|
118
119
|
return {
|
|
119
120
|
store: new blob_store_1.AzureBlobMailroomStore({
|
|
120
|
-
serviceClient:
|
|
121
|
+
serviceClient: createBlobServiceClient(config.azureAccountUrl, config.azureManagedIdentityClientId),
|
|
121
122
|
containerName,
|
|
122
123
|
mailSearchCache: {
|
|
123
|
-
cacheDirForAgent: (agentId) => path.join((0,
|
|
124
|
+
cacheDirForAgent: (agentId) => path.join((0, identity_1.getAgentRoot)(agentId), "state", "mail-search"),
|
|
124
125
|
},
|
|
125
126
|
}),
|
|
126
127
|
storeKind: "azure-blob",
|
|
127
128
|
storeLabel: `${config.azureAccountUrl}/${containerName}`,
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
|
-
const storePath = config.storePath ?? (0,
|
|
131
|
+
const storePath = config.storePath ?? (0, identity_1.getAgentMailroomRoot)(agentName);
|
|
131
132
|
return {
|
|
132
133
|
store: new file_store_1.FileMailroomStore({ rootDir: storePath, migrateAgentId: agentName }),
|
|
133
134
|
storeKind: "file",
|
|
@@ -144,7 +145,7 @@ async function readMailroomRegistry(config) {
|
|
|
144
145
|
if (!registryAzureAccountUrl || !registryBlob) {
|
|
145
146
|
throw new Error("mailroom config is missing registryPath or hosted registry coordinates");
|
|
146
147
|
}
|
|
147
|
-
const serviceClient =
|
|
148
|
+
const serviceClient = createBlobServiceClient(registryAzureAccountUrl, config.azureManagedIdentityClientId);
|
|
148
149
|
const blobClient = serviceClient.getContainerClient(registryContainer).getBlockBlobClient(registryBlob);
|
|
149
150
|
if (!await blobClient.exists()) {
|
|
150
151
|
throw new Error(`mailroom registry blob not found: ${registryAzureAccountUrl}/${registryContainer}/${registryBlob}`);
|
|
@@ -164,7 +165,7 @@ async function writeMailroomRegistry(config, registry) {
|
|
|
164
165
|
if (!registryAzureAccountUrl || !registryBlob) {
|
|
165
166
|
throw new Error("mailroom config is missing registryPath or hosted registry coordinates");
|
|
166
167
|
}
|
|
167
|
-
const serviceClient =
|
|
168
|
+
const serviceClient = createBlobServiceClient(registryAzureAccountUrl, config.azureManagedIdentityClientId);
|
|
168
169
|
const blobClient = serviceClient.getContainerClient(registryContainer).getBlockBlobClient(registryBlob);
|
|
169
170
|
await blobClient.upload(serialized, Buffer.byteLength(serialized), {
|
|
170
171
|
blobHTTPHeaders: {
|
|
@@ -172,7 +173,7 @@ async function writeMailroomRegistry(config, registry) {
|
|
|
172
173
|
},
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
|
-
function resolveMailroomReader(agentName = (0,
|
|
176
|
+
function resolveMailroomReader(agentName = (0, identity_1.getAgentName)()) {
|
|
176
177
|
const runtime = (0, runtime_credentials_1.readRuntimeCredentialConfig)(agentName);
|
|
177
178
|
if (!runtime.ok) {
|
|
178
179
|
const result = {
|
|
@@ -222,7 +223,7 @@ function resolveMailroomReader(agentName = (0, identity_2.getAgentName)()) {
|
|
|
222
223
|
});
|
|
223
224
|
return result;
|
|
224
225
|
}
|
|
225
|
-
function resolveHostedMailAuthority(agentName = (0,
|
|
226
|
+
function resolveHostedMailAuthority(agentName = (0, identity_1.getAgentName)()) {
|
|
226
227
|
const runtime = (0, runtime_credentials_1.readRuntimeCredentialConfig)(agentName);
|
|
227
228
|
if (!runtime.ok) {
|
|
228
229
|
const result = {
|
|
@@ -259,9 +260,7 @@ function resolveHostedMailAuthority(agentName = (0, identity_2.getAgentName)())
|
|
|
259
260
|
const azureContainer = textField(mailroom, "azureContainer") ?? "mailroom";
|
|
260
261
|
const azureManagedIdentityClientId = textField(mailroom, "azureManagedIdentityClientId");
|
|
261
262
|
const store = new blob_store_1.AzureBlobMailroomStore({
|
|
262
|
-
serviceClient:
|
|
263
|
-
? new identity_1.DefaultAzureCredential({ managedIdentityClientId: azureManagedIdentityClientId })
|
|
264
|
-
: new identity_1.DefaultAzureCredential()),
|
|
263
|
+
serviceClient: createBlobServiceClient(azureAccountUrl, azureManagedIdentityClientId),
|
|
265
264
|
containerName: azureContainer,
|
|
266
265
|
});
|
|
267
266
|
const result = {
|
|
@@ -280,7 +279,7 @@ function resolveHostedMailAuthority(agentName = (0, identity_2.getAgentName)())
|
|
|
280
279
|
});
|
|
281
280
|
return result;
|
|
282
281
|
}
|
|
283
|
-
async function resolveMailroomReaderWithRefresh(agentName = (0,
|
|
282
|
+
async function resolveMailroomReaderWithRefresh(agentName = (0, identity_1.getAgentName)()) {
|
|
284
283
|
const resolved = resolveMailroomReader(agentName);
|
|
285
284
|
if (resolved.ok
|
|
286
285
|
|| resolved.reason !== "auth-required"
|
|
@@ -8,12 +8,41 @@
|
|
|
8
8
|
* (e.g., passing card details to Duffel) — the returned data must
|
|
9
9
|
* never escape the calling function's scope.
|
|
10
10
|
*/
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
14
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
45
|
exports.createStripeClient = createStripeClient;
|
|
16
|
-
const stripe_1 = __importDefault(require("stripe"));
|
|
17
46
|
const credential_access_1 = require("./credential-access");
|
|
18
47
|
const runtime_1 = require("../nerves/runtime");
|
|
19
48
|
// ---------------------------------------------------------------------------
|
|
@@ -32,7 +61,9 @@ function toCardInfo(card) {
|
|
|
32
61
|
async function createStripeClient() {
|
|
33
62
|
const store = (0, credential_access_1.getCredentialStore)();
|
|
34
63
|
const apiKey = await store.getRawSecret("stripe.com", "restrictedKey");
|
|
35
|
-
|
|
64
|
+
// Stripe's SDK is about 10 MB and 185 modules; only agents that issue cards load it.
|
|
65
|
+
const { default: StripeConstructor } = await Promise.resolve().then(() => __importStar(require("stripe")));
|
|
66
|
+
const StripeFactory = StripeConstructor;
|
|
36
67
|
const stripe = new StripeFactory(apiKey);
|
|
37
68
|
return {
|
|
38
69
|
async createVirtualCard(opts) {
|
|
@@ -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",
|