@ouro.bot/cli 0.1.0-alpha.997 → 0.1.0-alpha.998

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 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.998",
6
+ "changes": [
7
+ "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."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.997",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.997",
2
+ "runtimeVersion": "0.1.0-alpha.998",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -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.997</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.998</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -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
+ }
@@ -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
- const parsed = await (0, mailparser_1.simpleParser)(rawMime);
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 */
@@ -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 storage_blob_1 = require("@azure/storage-blob");
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 identity_2 = require("../heart/identity");
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 createBlobCredential(config) {
111
- return config.azureManagedIdentityClientId
112
- ? new identity_1.DefaultAzureCredential({ managedIdentityClientId: config.azureManagedIdentityClientId })
113
- : new identity_1.DefaultAzureCredential();
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: new storage_blob_1.BlobServiceClient(config.azureAccountUrl, createBlobCredential(config)),
121
+ serviceClient: createBlobServiceClient(config.azureAccountUrl, config.azureManagedIdentityClientId),
121
122
  containerName,
122
123
  mailSearchCache: {
123
- cacheDirForAgent: (agentId) => path.join((0, identity_2.getAgentRoot)(agentId), "state", "mail-search"),
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, identity_2.getAgentMailroomRoot)(agentName);
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 = new storage_blob_1.BlobServiceClient(registryAzureAccountUrl, createBlobCredential(config));
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 = new storage_blob_1.BlobServiceClient(registryAzureAccountUrl, createBlobCredential(config));
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, identity_2.getAgentName)()) {
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, identity_2.getAgentName)()) {
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: new storage_blob_1.BlobServiceClient(azureAccountUrl, azureManagedIdentityClientId
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, identity_2.getAgentName)()) {
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- const StripeFactory = stripe_1.default;
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) {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.997",
3
+ "version": "0.1.0-alpha.998",
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.997",
9
+ "version": "0.1.0-alpha.998",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@azure/identity": "^4.13.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.997",
3
+ "version": "0.1.0-alpha.998",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },