@beeos-ai/device-agent 0.9.3 → 0.9.7
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/dist/adapters/transport-bridge-ws.d.ts +12 -0
- package/dist/adapters/transport-bridge-ws.js +27 -3
- package/dist/adapters/transport-bridge-ws.js.map +1 -1
- package/dist/agent-runtime/core.d.ts +1 -1
- package/dist/agent-runtime/core.js +41 -0
- package/dist/agent-runtime/core.js.map +1 -1
- package/dist/app/session-manager.d.ts +14 -11
- package/dist/app/session-manager.js +8 -9
- package/dist/app/session-manager.js.map +1 -1
- package/dist/bootstrap.js +140 -11
- package/dist/bootstrap.js.map +1 -1
- package/dist/chat.js +11 -1
- package/dist/chat.js.map +1 -1
- package/dist/config/loader.js +3 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/schema.js +65 -21
- package/dist/config/schema.js.map +1 -1
- package/dist/fleet/adapters/process/node-process-manager.d.ts +115 -13
- package/dist/fleet/adapters/process/node-process-manager.js +412 -64
- package/dist/fleet/adapters/process/node-process-manager.js.map +1 -1
- package/dist/fleet/adapters/state/port-allocator.d.ts +12 -0
- package/dist/fleet/adapters/state/port-allocator.js +39 -5
- package/dist/fleet/adapters/state/port-allocator.js.map +1 -1
- package/dist/fleet/domain/events.d.ts +23 -1
- package/dist/fleet/domain/fsm.d.ts +13 -1
- package/dist/fleet/domain/fsm.js +70 -0
- package/dist/fleet/domain/fsm.js.map +1 -1
- package/dist/fleet/supervisor.js +30 -0
- package/dist/fleet/supervisor.js.map +1 -1
- package/dist/health/adb-track-devices.d.ts +103 -0
- package/dist/health/adb-track-devices.js +171 -0
- package/dist/health/adb-track-devices.js.map +1 -0
- package/dist/health/health-reporter.d.ts +67 -0
- package/dist/health/health-reporter.js +123 -0
- package/dist/health/health-reporter.js.map +1 -0
- package/dist/health/index.d.ts +6 -0
- package/dist/health/index.js +4 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/mcp-health-monitor.d.ts +190 -0
- package/dist/health/mcp-health-monitor.js +267 -0
- package/dist/health/mcp-health-monitor.js.map +1 -0
- package/dist/inbound/cli/main.js +10 -3
- package/dist/inbound/cli/main.js.map +1 -1
- package/dist/inbound/cli/run-command.js +24 -2
- package/dist/inbound/cli/run-command.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-client/action-mapping.d.ts +45 -0
- package/dist/mcp-client/action-mapping.js +224 -0
- package/dist/mcp-client/action-mapping.js.map +1 -0
- package/dist/mcp-client/autospawn.d.ts +15 -2
- package/dist/mcp-client/autospawn.js +82 -4
- package/dist/mcp-client/autospawn.js.map +1 -1
- package/dist/mcp-client/client.d.ts +134 -38
- package/dist/mcp-client/client.js +394 -87
- package/dist/mcp-client/client.js.map +1 -1
- package/dist/mcp-client/index.d.ts +5 -3
- package/dist/mcp-client/index.js +2 -1
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/inproc.d.ts +2 -2
- package/dist/mcp-client/inproc.js.map +1 -1
- package/dist/mcp-client/runtime.d.ts +124 -21
- package/dist/mcp-client/runtime.js +18 -7
- package/dist/mcp-client/runtime.js.map +1 -1
- package/dist/messaging/token-provider.d.ts +15 -14
- package/dist/messaging/token-provider.js +16 -16
- package/dist/messaging/token-provider.js.map +1 -1
- package/dist/model/adapters/autoglm.js +44 -45
- package/dist/model/adapters/autoglm.js.map +1 -1
- package/dist/model/adapters/guiowl.js +3 -2
- package/dist/model/adapters/guiowl.js.map +1 -1
- package/dist/model/adapters/maiui.js +80 -53
- package/dist/model/adapters/maiui.js.map +1 -1
- package/dist/model/adapters/qwenvl.js +147 -51
- package/dist/model/adapters/qwenvl.js.map +1 -1
- package/dist/model/adapters/tool-call.js +13 -3
- package/dist/model/adapters/tool-call.js.map +1 -1
- package/dist/model/adapters/uitars.js +80 -84
- package/dist/model/adapters/uitars.js.map +1 -1
- package/dist/plugins/acp/index.d.ts +35 -0
- package/dist/plugins/acp/index.js +121 -0
- package/dist/plugins/acp/index.js.map +1 -1
- package/dist/plugins/message-bus/busy-reply.d.ts +5 -5
- package/dist/plugins/message-bus/busy-reply.js +30 -9
- package/dist/plugins/message-bus/busy-reply.js.map +1 -1
- package/dist/plugins/message-bus/cancel.d.ts +5 -11
- package/dist/plugins/message-bus/cancel.js +8 -14
- package/dist/plugins/message-bus/cancel.js.map +1 -1
- package/dist/plugins/message-bus/inbound.d.ts +18 -25
- package/dist/plugins/message-bus/inbound.js +23 -55
- package/dist/plugins/message-bus/inbound.js.map +1 -1
- package/dist/plugins/message-bus/index.d.ts +25 -44
- package/dist/plugins/message-bus/index.js +70 -111
- package/dist/plugins/message-bus/index.js.map +1 -1
- package/dist/plugins/message-bus/ms-channel-notifier.d.ts +24 -37
- package/dist/plugins/message-bus/ms-channel-notifier.js +39 -59
- package/dist/plugins/message-bus/ms-channel-notifier.js.map +1 -1
- package/dist/ports/transport.d.ts +11 -0
- package/dist/resources/parsers.js +17 -0
- package/dist/resources/parsers.js.map +1 -1
- package/package.json +4 -3
|
@@ -2,35 +2,34 @@
|
|
|
2
2
|
* Plugin — message-bus.
|
|
3
3
|
*
|
|
4
4
|
* Subscribes the device-agent to the BeeOS Message Service so it can
|
|
5
|
-
* receive `chat_message`
|
|
6
|
-
* invocations and reply over `ch:{
|
|
7
|
-
* `agent_reply_delta` (
|
|
5
|
+
* receive `chat_message` messages from L0 / A2A / MCP / OpenAPI
|
|
6
|
+
* invocations and reply over `ch:{conversationId}` with `agent_reply` /
|
|
7
|
+
* `agent_reply_delta` (replyTo = original message_id).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* Enabled by default since v0.9.7. Opt out with
|
|
10
|
+
* `BEEOS_MESSAGE_BUS_ENABLED=false` or `--no-message-bus`. Even when
|
|
11
|
+
* enabled, the plugin requires BOTH `--agent-gateway-url` and an
|
|
12
|
+
* Ed25519 identity to actually connect; missing either, it logs a
|
|
13
|
+
* one-line warning during `start()` and stays dormant — the rest of
|
|
14
|
+
* the agent (Bridge ACP, HTTP debug) still runs.
|
|
14
15
|
*
|
|
15
16
|
* Lifecycle:
|
|
16
17
|
* - `init` — read config, decide enabled / disabled.
|
|
17
18
|
* - `start` — kick off the connect loop. Returns IMMEDIATELY (does
|
|
18
19
|
* not block bootstrap on the network). The first connect attempt
|
|
19
20
|
* and any subsequent retries run in the background.
|
|
20
|
-
* - `stop` — cancel any pending retry, disconnect
|
|
21
|
-
*
|
|
21
|
+
* - `stop` — cancel any pending retry, disconnect client, drop
|
|
22
|
+
* in-flight register.
|
|
22
23
|
*
|
|
23
24
|
* Failure mode: if `tokenProvider()` rejects (e.g. the device instance
|
|
24
25
|
* has not been provisioned with `agentPublicKey` yet), the plugin
|
|
25
26
|
* schedules a retry with exponential backoff (30s → 60s → 120s → 240s,
|
|
26
27
|
* capped at 300s) and keeps trying forever until either `connect`
|
|
27
|
-
* succeeds or `stop()` cancels the loop.
|
|
28
|
-
* `localServer.onceAgentMappingReady(...)` deferred-connect pattern —
|
|
29
|
-
* see `[index.ts:484-498](agents/beeos-claw/src/index.ts)`.
|
|
28
|
+
* succeeds or `stop()` cancels the loop.
|
|
30
29
|
*/
|
|
31
|
-
import {
|
|
30
|
+
import { MessageClient, } from "@beeos-ai/message-sdk";
|
|
32
31
|
import { createDeviceMessagingTokenProvider } from "../../messaging/token-provider.js";
|
|
33
|
-
import {
|
|
32
|
+
import { MessageClientBusyReplyHandler } from "./busy-reply.js";
|
|
34
33
|
import { buildMessageBusCancelHandler, MESSAGE_TYPE_CHAT_CANCEL, } from "./cancel.js";
|
|
35
34
|
import { buildMessageBusInboundHandler } from "./inbound.js";
|
|
36
35
|
import { MsInflightTracker } from "./ms-inflight-tracker.js";
|
|
@@ -56,22 +55,15 @@ export class MessageBusPlugin {
|
|
|
56
55
|
opts;
|
|
57
56
|
name = "message-bus";
|
|
58
57
|
ctx;
|
|
59
|
-
|
|
58
|
+
client = null;
|
|
60
59
|
tracker = null;
|
|
61
60
|
resolvedPrincipalId = "";
|
|
62
61
|
// Connect-loop state.
|
|
63
62
|
stopped = false;
|
|
64
63
|
retryHandle = null;
|
|
65
|
-
// When the loop is sleeping in `sleep(ms)`, this resolver lets
|
|
66
|
-
// `stop()` (or any other test-level cancel) wake it up early with
|
|
67
|
-
// `cancelled = true`. Always cleared back to `null` once the resolver
|
|
68
|
-
// fires.
|
|
69
64
|
retryResolve = null;
|
|
70
65
|
connectAttempt = 0;
|
|
71
66
|
legacyDeprecationLogged = false;
|
|
72
|
-
// Resolves once the plugin has either successfully connected OR is
|
|
73
|
-
// permanently disabled. Tests await this to avoid racing the
|
|
74
|
-
// background loop. Production callers ignore it.
|
|
75
67
|
connectSettled = Promise.resolve();
|
|
76
68
|
resolveConnectSettled = () => undefined;
|
|
77
69
|
constructor(opts = {}) {
|
|
@@ -80,7 +72,7 @@ export class MessageBusPlugin {
|
|
|
80
72
|
async init(ctx) {
|
|
81
73
|
this.ctx = ctx;
|
|
82
74
|
if (!ctx.config.messageBus?.enabled) {
|
|
83
|
-
ctx.log.info("message-bus: disabled
|
|
75
|
+
ctx.log.info("message-bus: disabled via BEEOS_MESSAGE_BUS_ENABLED=false / --no-message-bus");
|
|
84
76
|
return;
|
|
85
77
|
}
|
|
86
78
|
if (!this.opts.keypair) {
|
|
@@ -105,42 +97,29 @@ export class MessageBusPlugin {
|
|
|
105
97
|
this.connectSettled = new Promise((resolve) => {
|
|
106
98
|
this.resolveConnectSettled = resolve;
|
|
107
99
|
});
|
|
108
|
-
// Kick off the loop. Do NOT await — the bootstrap should not block
|
|
109
|
-
// on a remote handshake. The loop reschedules itself via setTimeout
|
|
110
|
-
// until either `tryConnectOnce` returns true or `stop()` is called.
|
|
111
100
|
void this.runConnectLoop();
|
|
112
101
|
}
|
|
113
102
|
async stop() {
|
|
114
103
|
this.stopped = true;
|
|
115
104
|
this.cancelPendingRetry();
|
|
116
|
-
// Resolve any outstanding waiter so test code that awaits
|
|
117
|
-
// `whenSettled()` does not hang past stop().
|
|
118
105
|
this.resolveConnectSettled();
|
|
119
|
-
if (this.
|
|
106
|
+
if (this.client) {
|
|
120
107
|
try {
|
|
121
|
-
await this.
|
|
108
|
+
await this.client.disconnect();
|
|
122
109
|
}
|
|
123
110
|
catch (err) {
|
|
124
111
|
this.ctx?.log.warn({ err: err instanceof Error ? err.message : String(err) }, "message-bus: disconnect failed");
|
|
125
112
|
}
|
|
126
|
-
this.
|
|
113
|
+
this.client = null;
|
|
127
114
|
}
|
|
128
115
|
if (this.tracker) {
|
|
129
116
|
this.tracker.reset();
|
|
130
117
|
this.tracker = null;
|
|
131
118
|
}
|
|
132
119
|
}
|
|
133
|
-
// Test seam — exposes the resolved principal so integration tests can
|
|
134
|
-
// assert what the plugin actually subscribed to without poking at
|
|
135
|
-
// private state.
|
|
136
120
|
get principalId() {
|
|
137
121
|
return this.resolvedPrincipalId;
|
|
138
122
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Test helper — resolves once `start()`'s connect loop has either
|
|
141
|
-
* successfully connected or `stop()` was called. Production code
|
|
142
|
-
* never needs this.
|
|
143
|
-
*/
|
|
144
123
|
whenSettled() {
|
|
145
124
|
return this.connectSettled;
|
|
146
125
|
}
|
|
@@ -170,15 +149,13 @@ export class MessageBusPlugin {
|
|
|
170
149
|
this.resolveConnectSettled();
|
|
171
150
|
}
|
|
172
151
|
/**
|
|
173
|
-
* Single connect attempt. Returns `true` on success
|
|
174
|
-
*
|
|
175
|
-
* should schedule a retry).
|
|
152
|
+
* Single connect attempt. Returns `true` on success, `false` on any
|
|
153
|
+
* failure (caller should schedule a retry).
|
|
176
154
|
*
|
|
177
|
-
* Each attempt builds a FRESH `
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* handshake only.
|
|
155
|
+
* Each attempt builds a FRESH `MessageClient` — re-using one across
|
|
156
|
+
* reconnects would carry stale handlers and confuse centrifuge-js
|
|
157
|
+
* internal state. The client has its own internal reconnect once
|
|
158
|
+
* `.connect()` succeeds; this loop is for the OPENING handshake only.
|
|
182
159
|
*/
|
|
183
160
|
async tryConnectOnce(attempt) {
|
|
184
161
|
const ctx = this.ctx;
|
|
@@ -187,16 +164,9 @@ export class MessageBusPlugin {
|
|
|
187
164
|
const agentGatewayUrl = ctx.config.agentGatewayUrl;
|
|
188
165
|
const tokenProvider = this.opts.tokenProviderFactory?.({ agentGatewayUrl, keypair }) ??
|
|
189
166
|
createDeviceMessagingTokenProvider({ agentGatewayUrl, keypair });
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// late-bound via setServiceUrl below. Once bound, the SDK
|
|
194
|
-
// forwards the Centrifugo token as Authorization: Bearer
|
|
195
|
-
// for principal-level REST auth — agent never sees the MS
|
|
196
|
-
// X-API-Key. This is the durable publish path used by
|
|
197
|
-
// sendChannelMessage for terminal agent_reply.
|
|
198
|
-
centrifugoUrl: ctx.config.messageBus.centrifugoUrl || undefined,
|
|
199
|
-
}, wrapLoggerForSdk(log));
|
|
167
|
+
// Probe the token once so we can pin identityId + serviceUrl + WSS
|
|
168
|
+
// URL on the client. MessageClient itself will refresh the JWT
|
|
169
|
+
// via centrifuge-js's internal refresh loop on every connect.
|
|
200
170
|
let tok;
|
|
201
171
|
try {
|
|
202
172
|
tok = await tokenProvider(ctx.config.messageBus.principalIdOverride ?? "");
|
|
@@ -205,25 +175,24 @@ export class MessageBusPlugin {
|
|
|
205
175
|
this.logAttemptFailure(attempt, "messaging-token fetch failed", err, log);
|
|
206
176
|
return false;
|
|
207
177
|
}
|
|
208
|
-
const principalId = tok.
|
|
178
|
+
const principalId = tok.identityId;
|
|
209
179
|
if (!principalId) {
|
|
210
|
-
this.logAttemptFailure(attempt, "gateway returned empty
|
|
180
|
+
this.logAttemptFailure(attempt, "gateway returned empty identityId", null, log);
|
|
211
181
|
return false;
|
|
212
182
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
sdk.setServiceUrl(tok.service_url);
|
|
183
|
+
const client = this.opts.clientFactory?.(log) ??
|
|
184
|
+
new MessageClient({
|
|
185
|
+
serviceUrl: tok.serviceUrl || "https://msg.invalid",
|
|
186
|
+
centrifugoUrl: ctx.config.messageBus.centrifugoUrl || tok.centrifugoUrl,
|
|
187
|
+
tokenProvider,
|
|
188
|
+
logger: wrapLoggerForSdk(log),
|
|
189
|
+
});
|
|
221
190
|
const tracker = new MsInflightTracker();
|
|
222
|
-
const busyReply = new
|
|
191
|
+
const busyReply = new MessageClientBusyReplyHandler({ client });
|
|
223
192
|
const sessionManager = ctx.sessionManager;
|
|
224
193
|
const chatHandler = buildMessageBusInboundHandler({
|
|
225
194
|
sessionManager,
|
|
226
|
-
|
|
195
|
+
client,
|
|
227
196
|
busyReply,
|
|
228
197
|
tracker,
|
|
229
198
|
logger: log,
|
|
@@ -232,53 +201,53 @@ export class MessageBusPlugin {
|
|
|
232
201
|
});
|
|
233
202
|
const legacyHandler = buildMessageBusInboundHandler({
|
|
234
203
|
sessionManager,
|
|
235
|
-
|
|
204
|
+
client,
|
|
236
205
|
busyReply,
|
|
237
206
|
tracker,
|
|
238
207
|
logger: log,
|
|
239
208
|
localAgentId: this.opts.localAgentId,
|
|
240
209
|
source: "agent_request",
|
|
241
210
|
});
|
|
242
|
-
sdk.onMessage("chat_message", async (env) => chatHandler(env));
|
|
243
|
-
// Gap F — fire a one-shot deprecation warn the FIRST time a legacy
|
|
244
|
-
// `agent_request` envelope arrives. Mirrors beeos-claw
|
|
245
|
-
// [`index.ts:551-557`](agents/beeos-claw/src/index.ts).
|
|
246
|
-
sdk.onMessage("agent_request", async (env) => {
|
|
247
|
-
if (!this.legacyDeprecationLogged) {
|
|
248
|
-
this.legacyDeprecationLogged = true;
|
|
249
|
-
log.warn({}, "message-bus: received legacy 'agent_request' envelope — this path is deprecated; please migrate upstream callers to 'chat_message' (L0 AgentInvocationService)");
|
|
250
|
-
}
|
|
251
|
-
await legacyHandler(env);
|
|
252
|
-
});
|
|
253
|
-
// Cooperative cancel: the platform pushes `chat_cancel` envelopes
|
|
254
|
-
// when the caller hangs up / explicitly cancels / times out. We
|
|
255
|
-
// address the in-flight turn IM-natively by `target_message_id`
|
|
256
|
-
// (== inbound chat_message.message_id) so the agent stays free of
|
|
257
|
-
// A2A / MCP / OpenAPI protocol knowledge.
|
|
258
211
|
const cancelHandler = buildMessageBusCancelHandler({
|
|
259
212
|
sessionManager,
|
|
260
213
|
tracker,
|
|
261
214
|
logger: log,
|
|
262
215
|
});
|
|
263
|
-
|
|
264
|
-
|
|
216
|
+
// Single dispatch: filter by msg.type. Mirrors beeos-claw.
|
|
217
|
+
client.on("message", async (msg) => {
|
|
218
|
+
try {
|
|
219
|
+
if (msg.type === "chat_message") {
|
|
220
|
+
await chatHandler(msg);
|
|
221
|
+
}
|
|
222
|
+
else if (msg.type === "agent_request") {
|
|
223
|
+
if (!this.legacyDeprecationLogged) {
|
|
224
|
+
this.legacyDeprecationLogged = true;
|
|
225
|
+
log.warn({}, "message-bus: received legacy 'agent_request' message — this path is deprecated; please migrate upstream callers to 'chat_message' (L0 AgentInvocationService)");
|
|
226
|
+
}
|
|
227
|
+
await legacyHandler(msg);
|
|
228
|
+
}
|
|
229
|
+
else if (msg.type === MESSAGE_TYPE_CHAT_CANCEL) {
|
|
230
|
+
await cancelHandler(msg);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
log.error({ err: err instanceof Error ? err.message : String(err), type: msg.type }, "message-bus: dispatch handler threw");
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
client.once("connect", () => {
|
|
265
238
|
log.info({
|
|
266
239
|
principalId,
|
|
267
|
-
centrifugoUrl: tok.
|
|
240
|
+
centrifugoUrl: tok.centrifugoUrl,
|
|
268
241
|
channels: tok.channels,
|
|
269
242
|
attempt,
|
|
270
243
|
}, "message-bus: connected");
|
|
271
244
|
});
|
|
272
245
|
try {
|
|
273
|
-
await
|
|
274
|
-
centrifugoUrl: tok.centrifugo_url,
|
|
275
|
-
tokenProvider,
|
|
276
|
-
});
|
|
246
|
+
await client.connect({ identityId: principalId });
|
|
277
247
|
}
|
|
278
248
|
catch (err) {
|
|
279
|
-
// Disconnect the half-opened SDK so the next retry starts clean.
|
|
280
249
|
try {
|
|
281
|
-
await
|
|
250
|
+
await client.disconnect();
|
|
282
251
|
}
|
|
283
252
|
catch {
|
|
284
253
|
/* ignore */
|
|
@@ -286,7 +255,7 @@ export class MessageBusPlugin {
|
|
|
286
255
|
this.logAttemptFailure(attempt, "Centrifugo connect failed", err, log);
|
|
287
256
|
return false;
|
|
288
257
|
}
|
|
289
|
-
this.
|
|
258
|
+
this.client = client;
|
|
290
259
|
this.tracker = tracker;
|
|
291
260
|
this.resolvedPrincipalId = principalId;
|
|
292
261
|
return true;
|
|
@@ -296,11 +265,6 @@ export class MessageBusPlugin {
|
|
|
296
265
|
const idx = Math.min(attempt - 1, schedule.length - 1);
|
|
297
266
|
return schedule[idx];
|
|
298
267
|
}
|
|
299
|
-
/**
|
|
300
|
-
* Log an attempt failure with attenuated severity — first attempt
|
|
301
|
-
* + a few well-spaced retries get a `warn`, the rest are `debug` to
|
|
302
|
-
* avoid log spam when an instance has never been provisioned.
|
|
303
|
-
*/
|
|
304
268
|
logAttemptFailure(attempt, summary, err, log) {
|
|
305
269
|
const errStr = err == null
|
|
306
270
|
? null
|
|
@@ -322,11 +286,6 @@ export class MessageBusPlugin {
|
|
|
322
286
|
log.warn({ attempt, retryInMs: delayMs }, "message-bus: scheduled connect retry");
|
|
323
287
|
}
|
|
324
288
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Sleep `ms` milliseconds. Returns `true` when stop() cancels the
|
|
327
|
-
* timer mid-flight (so the caller breaks out of its loop), or
|
|
328
|
-
* `false` once the timer fires normally.
|
|
329
|
-
*/
|
|
330
289
|
sleep(ms) {
|
|
331
290
|
const sched = this.scheduler();
|
|
332
291
|
return new Promise((resolve) => {
|
|
@@ -362,10 +321,10 @@ export class MessageBusPlugin {
|
|
|
362
321
|
}
|
|
363
322
|
}
|
|
364
323
|
/**
|
|
365
|
-
* Adapt the device-agent pino logger to the
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
324
|
+
* Adapt the device-agent pino logger to the SDK's Logger shape. The
|
|
325
|
+
* SDK calls `info(msg)` / `warn(msg, fields?)` with positional args;
|
|
326
|
+
* pino's signature is `(obj, msg)` so we coerce to a stringly form
|
|
327
|
+
* that prints sanely either way.
|
|
369
328
|
*/
|
|
370
329
|
function wrapLoggerForSdk(log) {
|
|
371
330
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EACL,aAAa,GAGd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AAIvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACxE,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,oBAAoB,GAAG,IAAI,GAA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AAC,IAAe;IACpC,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,YAAY,KAAK;YAAE,OAAO,CAAC,CAAC,OAAO,CAAC;QACzC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MsChannelNotifier — translate per-session ACP `session/update`
|
|
3
|
-
* envelopes into BeeOS Message Service wire
|
|
4
|
-
*
|
|
3
|
+
* envelopes into BeeOS Message Service wire messages for ONE
|
|
4
|
+
* conversation (`ch:{conversationId}`).
|
|
5
5
|
*
|
|
6
6
|
* Implements `SessionUpdateNotifier` so it can be `bindNotifier`'d
|
|
7
7
|
* to a specific sid in `SessionManager`. The MessageBus inbound
|
|
8
|
-
* handler creates one of these per `chat_message
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* handler creates one of these per `chat_message`, binds it for the
|
|
9
|
+
* duration of the turn, then unbinds it when the await for
|
|
10
|
+
* `promptForSession()` returns.
|
|
11
11
|
*
|
|
12
12
|
* Wire mapping (locked in to match beeos-claw `acp-server.ts onStreamDelta`):
|
|
13
13
|
*
|
|
14
|
-
* - `agent_message_chunk` → `agent_reply_delta`
|
|
14
|
+
* - `agent_message_chunk` → `agent_reply_delta` with
|
|
15
15
|
* `update.sessionUpdate=agent_message_chunk`. The text is also
|
|
16
16
|
* accumulated into `accumulatedText` so the terminal `agent_reply`
|
|
17
|
-
* can carry the full reply as `
|
|
17
|
+
* can carry the full reply as `content.text`.
|
|
18
18
|
*
|
|
19
|
-
* - `agent_thought_chunk` → `agent_reply_delta`
|
|
19
|
+
* - `agent_thought_chunk` → `agent_reply_delta` with
|
|
20
20
|
* `update.sessionUpdate=agent_thought_chunk`. Reasoning is NEVER
|
|
21
21
|
* accumulated — `backend/pkg/convmsg/extract.go::extractNestedDelta`
|
|
22
22
|
* intentionally drops thought chunks so they don't pollute reply
|
|
23
23
|
* text, and we mirror that here.
|
|
24
24
|
*
|
|
25
|
-
* - `stream_complete` → terminal `agent_reply
|
|
26
|
-
*
|
|
25
|
+
* - `stream_complete` → terminal `agent_reply`. Content shape
|
|
26
|
+
* mirrors beeos-claw:
|
|
27
27
|
* success → { session_key, text }
|
|
28
28
|
* cancelled → { session_key, error: "cancelled", text? }
|
|
29
29
|
* failure → { session_key, error, text? }
|
|
@@ -34,48 +34,35 @@
|
|
|
34
34
|
* outbound listener also skipped them; mirroring keeps the wire
|
|
35
35
|
* format byte-for-byte identical for downstream consumers.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* - Terminal `agent_reply` — `sdk.sendChannelMessage` (durable REST
|
|
45
|
-
* POST that writes to `channel_messages` and fans out via MS).
|
|
46
|
-
* Carries `in_reply_to = inboundMessageId` so the caller's `/wait`
|
|
47
|
-
* can match. Persistence is REQUIRED: caller `/wait` long-polls in
|
|
48
|
-
* 30s reconnect cycles, and a Centrifugo direct publish landing in
|
|
49
|
-
* the reconnect gap would be lost forever (no DB row to replay
|
|
50
|
-
* from). Persistent path takes ~10-50ms more but is the only
|
|
51
|
-
* race-free option — see plan "Direct MS Token Auth".
|
|
52
|
-
*
|
|
53
|
-
* Mirrors beeos-claw `acp-server.ts:73-85` (delta) + the prescribed
|
|
54
|
-
* sendChannelMessage path for terminal reply (which beeos-claw uses
|
|
55
|
-
* as a fallback when sendToChannel fails).
|
|
37
|
+
* Both delta and terminal sends go through `client.messages.send`
|
|
38
|
+
* (persistent v2 path). Persistence is REQUIRED for terminal replies:
|
|
39
|
+
* caller `/wait` long-polls in 30s reconnect cycles, and an
|
|
40
|
+
* unpersisted publish landing in the reconnect gap would be lost
|
|
41
|
+
* forever (no DB row to replay from). Deltas inherit the same
|
|
42
|
+
* persistent path because the SDK no longer offers a non-persistent
|
|
43
|
+
* direct-Centrifugo publish.
|
|
56
44
|
*
|
|
57
45
|
* The notifier never throws out of `send()` — that runs on the
|
|
58
46
|
* SessionManager event hot path and a synchronous throw would skip
|
|
59
47
|
* subsequent handlers (e.g. status:idle). All publish failures are
|
|
60
|
-
* logged and swallowed.
|
|
61
|
-
* any subsequent publishes via the same path.
|
|
48
|
+
* logged and swallowed.
|
|
62
49
|
*/
|
|
63
|
-
import type {
|
|
50
|
+
import type { MessageClient } from "@beeos-ai/message-sdk";
|
|
64
51
|
import type { SessionUpdateNotifier } from "../../app/session-manager.js";
|
|
65
52
|
import type { Logger } from "../../logger/index.js";
|
|
66
53
|
export interface MsChannelNotifierOptions {
|
|
67
|
-
|
|
68
|
-
/**
|
|
54
|
+
client: MessageClient;
|
|
55
|
+
/** Conversation the reply is published on (`ch:{conversationId}`). */
|
|
69
56
|
channelId: string;
|
|
70
57
|
/**
|
|
71
|
-
* Original `chat_message.
|
|
72
|
-
*
|
|
58
|
+
* Original `chat_message.id`. Echoed as `replyTo` on the terminal
|
|
59
|
+
* `agent_reply` so L0 `/wait` can match.
|
|
73
60
|
*/
|
|
74
61
|
inboundMessageId: string;
|
|
75
62
|
/**
|
|
76
63
|
* Stable session anchor (`agent:{id}:invoke:ctx-{contextId}` or
|
|
77
64
|
* `agent:{id}:invoke:ch-{channelId}`) derived by `extractChatPrompt`.
|
|
78
|
-
* Embedded as `
|
|
65
|
+
* Embedded as `content.session_key` for forward-compat parity with
|
|
79
66
|
* beeos-claw downstream observers.
|
|
80
67
|
*/
|
|
81
68
|
sessionKey: string;
|