@ouro.bot/cli 0.1.0-alpha.682 → 0.1.0-alpha.684

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,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.684",
6
+ "changes": [
7
+ "Bootstrap private-runtime provider credentials before queued work is flushed."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.683",
12
+ "changes": [
13
+ "Apply daemon credential bootstrap IPC buffered before the private-runtime credential waiter attaches."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.682",
6
18
  "changes": [
@@ -36,21 +36,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  // Unified agent runtime entrypoint.
37
37
  // Requires --agent before importing runtime modules that rely on identity.
38
38
  const agentArgIndex = process.argv.indexOf("--agent");
39
- const agentName = agentArgIndex >= 0 ? process.argv[agentArgIndex + 1] : undefined;
40
- if (!agentName) {
39
+ const parsedAgentName = agentArgIndex >= 0 ? process.argv[agentArgIndex + 1] : undefined;
40
+ if (!parsedAgentName) {
41
41
  // eslint-disable-next-line no-console -- pre-boot guard
42
42
  console.error("Missing required --agent <name> argument.\nUsage: node dist/heart/agent-entry.js --agent ouroboros");
43
43
  process.exit(1);
44
44
  }
45
+ const agentName = parsedAgentName;
45
46
  const cli_logging_1 = require("../nerves/cli-logging");
46
47
  const runtime_1 = require("../nerves/runtime");
47
48
  (0, cli_logging_1.configureCliRuntimeLogger)("self");
48
49
  const ipcStateKey = Symbol.for("ouro.agentEntry.ipcState");
49
50
  const ipcState = (globalThis[ipcStateKey] ??= {
51
+ bufferedRuntimeCredentialMessages: [],
50
52
  bufferedMessages: [],
51
53
  installed: false,
52
54
  workerMessageHandler: null,
53
55
  });
56
+ ipcState.bufferedRuntimeCredentialMessages = [];
54
57
  ipcState.bufferedMessages = [];
55
58
  ipcState.workerMessageHandler = null;
56
59
  function isRuntimeCredentialBootstrapMessage(message) {
@@ -59,6 +62,24 @@ function isRuntimeCredentialBootstrapMessage(message) {
59
62
  && !Array.isArray(message)
60
63
  && message.type === "ouro.runtimeCredentialBootstrap";
61
64
  }
65
+ function isRuntimeCredentialBootstrapForAgent(message, expectedAgentName) {
66
+ return isRuntimeCredentialBootstrapMessage(message)
67
+ && message.agentName === expectedAgentName;
68
+ }
69
+ function drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage) {
70
+ let bootstrapped = false;
71
+ const remainingMessages = [];
72
+ for (const message of ipcState.bufferedRuntimeCredentialMessages.splice(0)) {
73
+ if (isRuntimeCredentialBootstrapForAgent(message, agentName)) {
74
+ bootstrapped = applyRuntimeCredentialBootstrapMessage(message) || bootstrapped;
75
+ }
76
+ else {
77
+ remainingMessages.push(message);
78
+ }
79
+ }
80
+ ipcState.bufferedRuntimeCredentialMessages.push(...remainingMessages);
81
+ return bootstrapped;
82
+ }
62
83
  function isPrivateRuntimeWorkMessage(message) {
63
84
  if (!message || typeof message !== "object" || Array.isArray(message))
64
85
  return false;
@@ -72,8 +93,10 @@ function isPrivateRuntimeWorkMessage(message) {
72
93
  || type === "message";
73
94
  }
74
95
  function forwardOrBufferRuntimeMessage(message) {
75
- if (isRuntimeCredentialBootstrapMessage(message))
96
+ if (isRuntimeCredentialBootstrapMessage(message)) {
97
+ ipcState.bufferedRuntimeCredentialMessages.push(message);
76
98
  return;
99
+ }
77
100
  if (!isPrivateRuntimeWorkMessage(message))
78
101
  return;
79
102
  if (ipcState.workerMessageHandler) {
@@ -98,11 +121,23 @@ if (!ipcState.installed) {
98
121
  });
99
122
  // Dynamic import: agent-entry is process-start wiring that starts a sense process.
100
123
  // Using dynamic import avoids a static heart/ -> senses/ dependency.
101
- Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).then(async ({ readMachineRuntimeCredentialConfig, readRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, refreshRuntimeCredentialConfig, waitForRuntimeCredentialBootstrap, }) => {
102
- await waitForRuntimeCredentialBootstrap(agentName);
124
+ Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).then(async ({ readMachineRuntimeCredentialConfig, readRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, refreshRuntimeCredentialConfig, applyRuntimeCredentialBootstrapMessage, waitForRuntimeCredentialBootstrap, }) => {
125
+ const { readProviderCredentialPool, refreshProviderCredentialPool } = await Promise.resolve().then(() => __importStar(require("./provider-credentials")));
126
+ const bootstrappedBeforeWait = drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage);
127
+ const bootstrappedDuringWait = bootstrappedBeforeWait ? true : await waitForRuntimeCredentialBootstrap(agentName);
128
+ if (bootstrappedDuringWait) {
129
+ ipcState.bufferedRuntimeCredentialMessages = ipcState.bufferedRuntimeCredentialMessages.filter((message) => !isRuntimeCredentialBootstrapForAgent(message, agentName));
130
+ }
131
+ else {
132
+ drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage);
133
+ }
103
134
  if (!readRuntimeCredentialConfig(agentName).ok) {
104
135
  void refreshRuntimeCredentialConfig(agentName, { preserveCachedOnFailure: true }).catch(() => undefined);
105
136
  }
137
+ const providerPool = readProviderCredentialPool(agentName);
138
+ if (!providerPool.ok || Object.keys(providerPool.pool.providers).length === 0) {
139
+ await refreshProviderCredentialPool(agentName, { preserveCachedOnFailure: true }).catch(() => undefined);
140
+ }
106
141
  /* v8 ignore next 7 -- process-start best-effort machine credential refresh runs in a child entrypoint and is covered operationally by daemon startup tests @preserve */
107
142
  if (!readMachineRuntimeCredentialConfig(agentName).ok) {
108
143
  void Promise.resolve().then(() => __importStar(require("./machine-identity"))).then(({ loadOrCreateMachineIdentity }) => {
@@ -66,6 +66,8 @@ const bundle_manifest_1 = require("../../mind/bundle-manifest");
66
66
  const mcp_canary_1 = require("./mcp-canary");
67
67
  const context_loss_sentinel_1 = require("../context-loss-sentinel");
68
68
  const provider_credentials_1 = require("../provider-credentials");
69
+ const runtime_credentials_1 = require("../runtime-credentials");
70
+ const machine_identity_1 = require("../machine-identity");
69
71
  function parseSocketPath(argv) {
70
72
  const socketIndex = argv.indexOf("--socket");
71
73
  if (socketIndex >= 0) {
@@ -100,6 +102,28 @@ const managedPrivateRuntimes = managedAgents.map((agent) => ({
100
102
  agent,
101
103
  config: (0, agent_discovery_1.readPrivateRuntimeConfig)(agent),
102
104
  }));
105
+ function currentMachineId() {
106
+ return (0, machine_identity_1.loadOrCreateMachineIdentity)().machineId;
107
+ }
108
+ function privateRuntimeCredentialBootstrapFor(agent) {
109
+ const machineId = currentMachineId();
110
+ const runtime = (0, runtime_credentials_1.readRuntimeCredentialConfig)(agent);
111
+ const machine = (0, runtime_credentials_1.readMachineRuntimeCredentialConfig)(agent);
112
+ const providerPool = (0, provider_credentials_1.readProviderCredentialPool)(agent);
113
+ const providerCredentialRecords = providerPool.ok
114
+ ? Object.values(providerPool.pool.providers).filter((record) => !!record)
115
+ : [];
116
+ const bootstrap = {
117
+ agentName: agent,
118
+ runtimeConfig: runtime.ok ? runtime.config : undefined,
119
+ machineRuntimeConfig: machine.ok ? machine.config : undefined,
120
+ machineId,
121
+ providerCredentialRecords: providerCredentialRecords.length > 0 ? providerCredentialRecords : undefined,
122
+ };
123
+ if (!bootstrap.runtimeConfig && !bootstrap.machineRuntimeConfig && !bootstrap.providerCredentialRecords)
124
+ return null;
125
+ return bootstrap;
126
+ }
103
127
  function sentinelHealthStatus(receipt) {
104
128
  if (receipt.verdict === "ready")
105
129
  return "ok";
@@ -178,6 +202,7 @@ const processManager = new process_manager_1.DaemonProcessManager({
178
202
  entry: "heart/agent-entry.js",
179
203
  channel: "private-runtime",
180
204
  autoStart: config.autoStart,
205
+ getRuntimeCredentialBootstrap: () => privateRuntimeCredentialBootstrapFor(agent),
181
206
  })),
182
207
  existsSync: fs.existsSync,
183
208
  /* v8 ignore next 4 -- wiring: delegates to checkAgentConfig which has full unit tests @preserve */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.682",
3
+ "version": "0.1.0-alpha.684",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",