@ouro.bot/cli 0.1.0-alpha.682 → 0.1.0-alpha.683
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/dist/heart/agent-entry.js +35 -5
- 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.683",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Apply daemon credential bootstrap IPC buffered before the private-runtime credential waiter attaches."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.682",
|
|
6
12
|
"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
|
|
40
|
-
if (!
|
|
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,8 +121,15 @@ 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
|
-
|
|
124
|
+
Promise.resolve().then(() => __importStar(require("./runtime-credentials"))).then(async ({ readMachineRuntimeCredentialConfig, readRuntimeCredentialConfig, refreshMachineRuntimeCredentialConfig, refreshRuntimeCredentialConfig, applyRuntimeCredentialBootstrapMessage, waitForRuntimeCredentialBootstrap, }) => {
|
|
125
|
+
const bootstrappedBeforeWait = drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage);
|
|
126
|
+
const bootstrappedDuringWait = bootstrappedBeforeWait ? true : await waitForRuntimeCredentialBootstrap(agentName);
|
|
127
|
+
if (bootstrappedDuringWait) {
|
|
128
|
+
ipcState.bufferedRuntimeCredentialMessages = ipcState.bufferedRuntimeCredentialMessages.filter((message) => !isRuntimeCredentialBootstrapForAgent(message, agentName));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
drainBufferedRuntimeCredentialBootstrap(applyRuntimeCredentialBootstrapMessage);
|
|
132
|
+
}
|
|
103
133
|
if (!readRuntimeCredentialConfig(agentName).ok) {
|
|
104
134
|
void refreshRuntimeCredentialConfig(agentName, { preserveCachedOnFailure: true }).catch(() => undefined);
|
|
105
135
|
}
|