@beeos-ai/device-agent 0.8.0 → 0.9.3
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/app/fixed-session-id.d.ts +19 -0
- package/dist/app/fixed-session-id.js +26 -0
- package/dist/app/fixed-session-id.js.map +1 -0
- package/dist/app/jsonl-session-sweeper.d.ts +90 -0
- package/dist/app/jsonl-session-sweeper.js +162 -0
- package/dist/app/jsonl-session-sweeper.js.map +1 -0
- package/dist/app/jsonl-store.d.ts +10 -0
- package/dist/app/jsonl-store.js +10 -4
- package/dist/app/jsonl-store.js.map +1 -1
- package/dist/app/session-manager.d.ts +135 -1
- package/dist/app/session-manager.js +195 -12
- package/dist/app/session-manager.js.map +1 -1
- package/dist/bootstrap.js +146 -2
- package/dist/bootstrap.js.map +1 -1
- package/dist/config/loader.js +2 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +2 -0
- package/dist/config/schema.js +41 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/fleet/domain/device.d.ts +17 -0
- package/dist/fleet/domain/device.js +1 -0
- package/dist/fleet/domain/device.js.map +1 -1
- package/dist/fleet/domain/fsm.d.ts +30 -1
- package/dist/fleet/domain/fsm.js +100 -4
- package/dist/fleet/domain/fsm.js.map +1 -1
- package/dist/fleet/supervisor.js +38 -18
- package/dist/fleet/supervisor.js.map +1 -1
- package/dist/plugins/acp/index.d.ts +27 -30
- package/dist/plugins/acp/index.js +44 -137
- package/dist/plugins/acp/index.js.map +1 -1
- package/dist/plugins/message-bus/busy-reply.js +13 -5
- package/dist/plugins/message-bus/busy-reply.js.map +1 -1
- package/dist/plugins/message-bus/cancel.d.ts +48 -0
- package/dist/plugins/message-bus/cancel.js +66 -0
- package/dist/plugins/message-bus/cancel.js.map +1 -0
- package/dist/plugins/message-bus/inbound.d.ts +38 -22
- package/dist/plugins/message-bus/inbound.js +113 -50
- package/dist/plugins/message-bus/inbound.js.map +1 -1
- package/dist/plugins/message-bus/index.d.ts +1 -2
- package/dist/plugins/message-bus/index.js +39 -37
- package/dist/plugins/message-bus/index.js.map +1 -1
- package/dist/plugins/message-bus/ms-channel-notifier.d.ts +113 -0
- package/dist/plugins/message-bus/ms-channel-notifier.js +206 -0
- package/dist/plugins/message-bus/ms-channel-notifier.js.map +1 -0
- package/dist/plugins/message-bus/ms-inflight-tracker.d.ts +36 -0
- package/dist/plugins/message-bus/ms-inflight-tracker.js +42 -0
- package/dist/plugins/message-bus/ms-inflight-tracker.js.map +1 -0
- package/dist/ports/plugin.d.ts +12 -0
- package/package.json +2 -2
- package/dist/agent-runtime/skills/sqlite-store.d.ts +0 -60
- package/dist/agent-runtime/skills/sqlite-store.js +0 -234
- package/dist/agent-runtime/skills/sqlite-store.js.map +0 -1
- package/dist/plugins/message-bus/outbound.d.ts +0 -43
- package/dist/plugins/message-bus/outbound.js +0 -149
- package/dist/plugins/message-bus/outbound.js.map +0 -1
- package/dist/plugins/message-bus/turn-context.d.ts +0 -57
- package/dist/plugins/message-bus/turn-context.js +0 -53
- package/dist/plugins/message-bus/turn-context.js.map +0 -1
- package/dist/test-lan-autoglm.d.ts +0 -7
- package/dist/test-lan-autoglm.js +0 -46
- package/dist/test-lan-autoglm.js.map +0 -1
- package/dist/test-mem-breakdown.d.ts +0 -1
- package/dist/test-mem-breakdown.js +0 -103
- package/dist/test-mem-breakdown.js.map +0 -1
- package/dist/test-mem.d.ts +0 -1
- package/dist/test-mem.js +0 -60
- package/dist/test-mem.js.map +0 -1
- package/dist/test-mobile-use.d.ts +0 -1
- package/dist/test-mobile-use.js +0 -18
- package/dist/test-mobile-use.js.map +0 -1
- package/dist/test-screenshot-loop.d.ts +0 -1
- package/dist/test-screenshot-loop.js +0 -43
- package/dist/test-screenshot-loop.js.map +0 -1
- package/dist/test-screenshot.d.ts +0 -1
- package/dist/test-screenshot.js +0 -10
- package/dist/test-screenshot.js.map +0 -1
- package/dist/test-ui-xml-dump.d.ts +0 -15
- package/dist/test-ui-xml-dump.js +0 -49
- package/dist/test-ui-xml-dump.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAsB,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AAIvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAsB,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AAIvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,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,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AA6CpD,MAAM,OAAO,gBAAgB;IAuBE;IAtBpB,IAAI,GAAG,aAAa,CAAC;IACtB,GAAG,CAAiB;IACpB,GAAG,GAAsB,IAAI,CAA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O,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"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MsChannelNotifier — translate per-session ACP `session/update`
|
|
3
|
+
* envelopes into BeeOS Message Service wire envelopes for ONE
|
|
4
|
+
* Centrifugo channel (`ch:{channelId}`).
|
|
5
|
+
*
|
|
6
|
+
* Implements `SessionUpdateNotifier` so it can be `bindNotifier`'d
|
|
7
|
+
* to a specific sid in `SessionManager`. The MessageBus inbound
|
|
8
|
+
* handler creates one of these per `chat_message` envelope, binds
|
|
9
|
+
* it for the duration of the turn, then unbinds it when the await
|
|
10
|
+
* for `promptForSession()` returns.
|
|
11
|
+
*
|
|
12
|
+
* Wire mapping (locked in to match beeos-claw `acp-server.ts onStreamDelta`):
|
|
13
|
+
*
|
|
14
|
+
* - `agent_message_chunk` → `agent_reply_delta` envelope with
|
|
15
|
+
* `update.sessionUpdate=agent_message_chunk`. The text is also
|
|
16
|
+
* accumulated into `accumulatedText` so the terminal `agent_reply`
|
|
17
|
+
* can carry the full reply as `payload.text`.
|
|
18
|
+
*
|
|
19
|
+
* - `agent_thought_chunk` → `agent_reply_delta` envelope with
|
|
20
|
+
* `update.sessionUpdate=agent_thought_chunk`. Reasoning is NEVER
|
|
21
|
+
* accumulated — `backend/pkg/convmsg/extract.go::extractNestedDelta`
|
|
22
|
+
* intentionally drops thought chunks so they don't pollute reply
|
|
23
|
+
* text, and we mirror that here.
|
|
24
|
+
*
|
|
25
|
+
* - `stream_complete` → terminal `agent_reply` envelope. Payload
|
|
26
|
+
* shape mirrors beeos-claw:
|
|
27
|
+
* success → { session_key, text }
|
|
28
|
+
* cancelled → { session_key, error: "cancelled", text? }
|
|
29
|
+
* failure → { session_key, error, text? }
|
|
30
|
+
*
|
|
31
|
+
* - All other `sessionUpdate` types (`agent_status`, `tool_call`,
|
|
32
|
+
* `tool_call_update`, `history_turn`, `system_message_chunk`,
|
|
33
|
+
* `user_message_chunk`) are intentionally SKIPPED. The old
|
|
34
|
+
* outbound listener also skipped them; mirroring keeps the wire
|
|
35
|
+
* format byte-for-byte identical for downstream consumers.
|
|
36
|
+
*
|
|
37
|
+
* Two distinct publish paths:
|
|
38
|
+
*
|
|
39
|
+
* - Streaming deltas (`agent_reply_delta`) — `sdk.sendToChannel`
|
|
40
|
+
* (Centrifugo direct publish, fire-and-forget, fan-out only). They
|
|
41
|
+
* MUST NOT carry `in_reply_to` because MS `/wait` matches purely
|
|
42
|
+
* on that field and would short-circuit on the first delta.
|
|
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).
|
|
56
|
+
*
|
|
57
|
+
* The notifier never throws out of `send()` — that runs on the
|
|
58
|
+
* SessionManager event hot path and a synchronous throw would skip
|
|
59
|
+
* subsequent handlers (e.g. status:idle). All publish failures are
|
|
60
|
+
* logged and swallowed. The next event for the same turn will retry
|
|
61
|
+
* any subsequent publishes via the same path.
|
|
62
|
+
*/
|
|
63
|
+
import type { MessageSDK } from "@beeos-ai/message-sdk";
|
|
64
|
+
import type { SessionUpdateNotifier } from "../../app/session-manager.js";
|
|
65
|
+
import type { Logger } from "../../logger/index.js";
|
|
66
|
+
export interface MsChannelNotifierOptions {
|
|
67
|
+
sdk: MessageSDK;
|
|
68
|
+
/** IM channel the reply is published on (`ch:{channelId}`). */
|
|
69
|
+
channelId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Original `chat_message.message_id`. Echoed as `in_reply_to` on
|
|
72
|
+
* every published envelope so L0 `/wait` can match.
|
|
73
|
+
*/
|
|
74
|
+
inboundMessageId: string;
|
|
75
|
+
/**
|
|
76
|
+
* Stable session anchor (`agent:{id}:invoke:ctx-{contextId}` or
|
|
77
|
+
* `agent:{id}:invoke:ch-{channelId}`) derived by `extractChatPrompt`.
|
|
78
|
+
* Embedded as `payload.session_key` for forward-compat parity with
|
|
79
|
+
* beeos-claw downstream observers.
|
|
80
|
+
*/
|
|
81
|
+
sessionKey: string;
|
|
82
|
+
logger: Logger;
|
|
83
|
+
}
|
|
84
|
+
export declare class MsChannelNotifier implements SessionUpdateNotifier {
|
|
85
|
+
private readonly opts;
|
|
86
|
+
/** Cumulative `agent_message_chunk` text — populates terminal `agent_reply.text`. */
|
|
87
|
+
private accumulatedText;
|
|
88
|
+
private finalized;
|
|
89
|
+
constructor(opts: MsChannelNotifierOptions);
|
|
90
|
+
/**
|
|
91
|
+
* Called by SessionManager for every `session/update` envelope on
|
|
92
|
+
* this notifier's bound sid. Fire-and-forget: the SessionManager
|
|
93
|
+
* event hot path is synchronous, so we kick off the publish in the
|
|
94
|
+
* background and never block.
|
|
95
|
+
*/
|
|
96
|
+
send(_sessionId: string, update: Record<string, unknown>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Cumulative reply text emitted so far. Exposed for diagnostics +
|
|
99
|
+
* tests; not part of any wire contract.
|
|
100
|
+
*/
|
|
101
|
+
get currentText(): string;
|
|
102
|
+
/** True once the terminal `agent_reply` has been published. */
|
|
103
|
+
get isFinalized(): boolean;
|
|
104
|
+
private handle;
|
|
105
|
+
private publishDelta;
|
|
106
|
+
/**
|
|
107
|
+
* Emit the terminal `agent_reply`. Idempotent — guarded by
|
|
108
|
+
* `finalized` so a duplicate `stream_complete` (extremely rare,
|
|
109
|
+
* but possible if the host event handler ever fires twice) cannot
|
|
110
|
+
* publish two terminal envelopes.
|
|
111
|
+
*/
|
|
112
|
+
private publishFinal;
|
|
113
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MsChannelNotifier — translate per-session ACP `session/update`
|
|
3
|
+
* envelopes into BeeOS Message Service wire envelopes for ONE
|
|
4
|
+
* Centrifugo channel (`ch:{channelId}`).
|
|
5
|
+
*
|
|
6
|
+
* Implements `SessionUpdateNotifier` so it can be `bindNotifier`'d
|
|
7
|
+
* to a specific sid in `SessionManager`. The MessageBus inbound
|
|
8
|
+
* handler creates one of these per `chat_message` envelope, binds
|
|
9
|
+
* it for the duration of the turn, then unbinds it when the await
|
|
10
|
+
* for `promptForSession()` returns.
|
|
11
|
+
*
|
|
12
|
+
* Wire mapping (locked in to match beeos-claw `acp-server.ts onStreamDelta`):
|
|
13
|
+
*
|
|
14
|
+
* - `agent_message_chunk` → `agent_reply_delta` envelope with
|
|
15
|
+
* `update.sessionUpdate=agent_message_chunk`. The text is also
|
|
16
|
+
* accumulated into `accumulatedText` so the terminal `agent_reply`
|
|
17
|
+
* can carry the full reply as `payload.text`.
|
|
18
|
+
*
|
|
19
|
+
* - `agent_thought_chunk` → `agent_reply_delta` envelope with
|
|
20
|
+
* `update.sessionUpdate=agent_thought_chunk`. Reasoning is NEVER
|
|
21
|
+
* accumulated — `backend/pkg/convmsg/extract.go::extractNestedDelta`
|
|
22
|
+
* intentionally drops thought chunks so they don't pollute reply
|
|
23
|
+
* text, and we mirror that here.
|
|
24
|
+
*
|
|
25
|
+
* - `stream_complete` → terminal `agent_reply` envelope. Payload
|
|
26
|
+
* shape mirrors beeos-claw:
|
|
27
|
+
* success → { session_key, text }
|
|
28
|
+
* cancelled → { session_key, error: "cancelled", text? }
|
|
29
|
+
* failure → { session_key, error, text? }
|
|
30
|
+
*
|
|
31
|
+
* - All other `sessionUpdate` types (`agent_status`, `tool_call`,
|
|
32
|
+
* `tool_call_update`, `history_turn`, `system_message_chunk`,
|
|
33
|
+
* `user_message_chunk`) are intentionally SKIPPED. The old
|
|
34
|
+
* outbound listener also skipped them; mirroring keeps the wire
|
|
35
|
+
* format byte-for-byte identical for downstream consumers.
|
|
36
|
+
*
|
|
37
|
+
* Two distinct publish paths:
|
|
38
|
+
*
|
|
39
|
+
* - Streaming deltas (`agent_reply_delta`) — `sdk.sendToChannel`
|
|
40
|
+
* (Centrifugo direct publish, fire-and-forget, fan-out only). They
|
|
41
|
+
* MUST NOT carry `in_reply_to` because MS `/wait` matches purely
|
|
42
|
+
* on that field and would short-circuit on the first delta.
|
|
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).
|
|
56
|
+
*
|
|
57
|
+
* The notifier never throws out of `send()` — that runs on the
|
|
58
|
+
* SessionManager event hot path and a synchronous throw would skip
|
|
59
|
+
* subsequent handlers (e.g. status:idle). All publish failures are
|
|
60
|
+
* logged and swallowed. The next event for the same turn will retry
|
|
61
|
+
* any subsequent publishes via the same path.
|
|
62
|
+
*/
|
|
63
|
+
export class MsChannelNotifier {
|
|
64
|
+
opts;
|
|
65
|
+
/** Cumulative `agent_message_chunk` text — populates terminal `agent_reply.text`. */
|
|
66
|
+
accumulatedText = "";
|
|
67
|
+
finalized = false;
|
|
68
|
+
constructor(opts) {
|
|
69
|
+
this.opts = opts;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Called by SessionManager for every `session/update` envelope on
|
|
73
|
+
* this notifier's bound sid. Fire-and-forget: the SessionManager
|
|
74
|
+
* event hot path is synchronous, so we kick off the publish in the
|
|
75
|
+
* background and never block.
|
|
76
|
+
*/
|
|
77
|
+
send(_sessionId, update) {
|
|
78
|
+
void this.handle(update);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Cumulative reply text emitted so far. Exposed for diagnostics +
|
|
82
|
+
* tests; not part of any wire contract.
|
|
83
|
+
*/
|
|
84
|
+
get currentText() {
|
|
85
|
+
return this.accumulatedText;
|
|
86
|
+
}
|
|
87
|
+
/** True once the terminal `agent_reply` has been published. */
|
|
88
|
+
get isFinalized() {
|
|
89
|
+
return this.finalized;
|
|
90
|
+
}
|
|
91
|
+
async handle(update) {
|
|
92
|
+
const sessionUpdate = pickSessionUpdate(update);
|
|
93
|
+
try {
|
|
94
|
+
switch (sessionUpdate) {
|
|
95
|
+
case "agent_message_chunk": {
|
|
96
|
+
const text = pickContentText(update.content);
|
|
97
|
+
if (!text)
|
|
98
|
+
return;
|
|
99
|
+
this.accumulatedText += text;
|
|
100
|
+
await this.publishDelta("agent_message_chunk", text);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
case "agent_thought_chunk": {
|
|
104
|
+
const text = pickContentText(update.content);
|
|
105
|
+
if (!text)
|
|
106
|
+
return;
|
|
107
|
+
await this.publishDelta("agent_thought_chunk", text);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
case "stream_complete": {
|
|
111
|
+
const stopReason = pickString(update.stopReason) || "end_turn";
|
|
112
|
+
const errorText = pickString(update.error);
|
|
113
|
+
await this.publishFinal(stopReason, errorText);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
default:
|
|
117
|
+
// agent_status / tool_call / tool_call_update / history_turn
|
|
118
|
+
// / system_message_chunk / user_message_chunk → skip.
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
this.opts.logger.error({
|
|
124
|
+
err: err instanceof Error ? err.message : String(err),
|
|
125
|
+
channelId: this.opts.channelId,
|
|
126
|
+
sessionUpdate,
|
|
127
|
+
}, "ms-channel-notifier: publish failed");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async publishDelta(sessionUpdate, text) {
|
|
131
|
+
// Streaming deltas are fan-out only — they MUST NOT carry
|
|
132
|
+
// `in_reply_to`, otherwise MS `/wait` (which only checks
|
|
133
|
+
// `in_reply_to`, not message type) would short-circuit on the
|
|
134
|
+
// first delta and the caller would think the turn finished.
|
|
135
|
+
// Mirrors beeos-claw `acp-server.ts:73-85`.
|
|
136
|
+
await this.opts.sdk.sendToChannel(this.opts.channelId, "agent_reply_delta", {
|
|
137
|
+
session_key: this.opts.sessionKey,
|
|
138
|
+
update: {
|
|
139
|
+
sessionUpdate,
|
|
140
|
+
content: { type: "text", text },
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Emit the terminal `agent_reply`. Idempotent — guarded by
|
|
146
|
+
* `finalized` so a duplicate `stream_complete` (extremely rare,
|
|
147
|
+
* but possible if the host event handler ever fires twice) cannot
|
|
148
|
+
* publish two terminal envelopes.
|
|
149
|
+
*/
|
|
150
|
+
async publishFinal(stopReason, errorText) {
|
|
151
|
+
if (this.finalized)
|
|
152
|
+
return;
|
|
153
|
+
this.finalized = true;
|
|
154
|
+
let payload;
|
|
155
|
+
if (stopReason === "cancelled") {
|
|
156
|
+
payload = {
|
|
157
|
+
session_key: this.opts.sessionKey,
|
|
158
|
+
error: "cancelled",
|
|
159
|
+
text: this.accumulatedText,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else if (errorText) {
|
|
163
|
+
payload = {
|
|
164
|
+
session_key: this.opts.sessionKey,
|
|
165
|
+
error: errorText,
|
|
166
|
+
text: this.accumulatedText,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
payload = {
|
|
171
|
+
session_key: this.opts.sessionKey,
|
|
172
|
+
text: this.accumulatedText,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Durable persist via MS REST. sendChannelMessage:
|
|
176
|
+
// - writes to MS `channel_messages` table (caller's /wait
|
|
177
|
+
// `FirstByInReplyTo` DB scan can match even if live publication
|
|
178
|
+
// missed during reconnect)
|
|
179
|
+
// - server-side fan-out to ch:{} + every personal:{} of the
|
|
180
|
+
// channel participants (real-time path preserved)
|
|
181
|
+
// - auth: SDK forwards the connect-time Centrifugo token as
|
|
182
|
+
// `Authorization: Bearer <jwt>`; MS verifies HMAC and pins
|
|
183
|
+
// sender_id to ctx.principal_id (no need for us to set it).
|
|
184
|
+
await this.opts.sdk.sendChannelMessage(this.opts.channelId, {
|
|
185
|
+
type: "agent_reply",
|
|
186
|
+
payload,
|
|
187
|
+
inReplyTo: this.opts.inboundMessageId,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function pickSessionUpdate(update) {
|
|
192
|
+
const v = update.sessionUpdate;
|
|
193
|
+
return typeof v === "string" ? v : "";
|
|
194
|
+
}
|
|
195
|
+
function pickContentText(content) {
|
|
196
|
+
if (!content || typeof content !== "object")
|
|
197
|
+
return "";
|
|
198
|
+
const c = content;
|
|
199
|
+
if (typeof c.text === "string")
|
|
200
|
+
return c.text;
|
|
201
|
+
return "";
|
|
202
|
+
}
|
|
203
|
+
function pickString(v) {
|
|
204
|
+
return typeof v === "string" ? v : "";
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=ms-channel-notifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms-channel-notifier.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/ms-channel-notifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AA0BH,MAAM,OAAO,iBAAiB;IAKC;IAJ7B,qFAAqF;IAC7E,eAAe,GAAG,EAAE,CAAC;IACrB,SAAS,GAAG,KAAK,CAAC;IAE1B,YAA6B,IAA8B;QAA9B,SAAI,GAAJ,IAAI,CAA0B;IAAG,CAAC;IAE/D;;;;;OAKG;IACH,IAAI,CAAC,UAAkB,EAAE,MAA+B;QACtD,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,+DAA+D;IAC/D,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,MAAM,CAAC,MAA+B;QAClD,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC;YACH,QAAQ,aAAa,EAAE,CAAC;gBACtB,KAAK,qBAAqB,CAAC,CAAC,CAAC;oBAC3B,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC7C,IAAI,CAAC,IAAI;wBAAE,OAAO;oBAClB,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gBAAgB;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,MAA+B;IACxD,MAAM,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACvD,MAAM,CAAC,GAAG,OAA6C,CAAC;IACxD,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,IAAI,CAAC;IAC9C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,UAAU,CAAC,CAAU;IAC5B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny single-entry tracker for the IN-FLIGHT MS-originated turn.
|
|
3
|
+
*
|
|
4
|
+
* v0.9.0 — replaces the v0.8.0 `TurnContextRegister`, which carried
|
|
5
|
+
* far more state because the outbound listener needed to look up the
|
|
6
|
+
* channelId / sessionKey / inboundMessageId per AgentEvent. With
|
|
7
|
+
* `MsChannelNotifier` owning the wire mapping per-sid, the tracker
|
|
8
|
+
* only needs to answer ONE question: "given a `chat_cancel.target_
|
|
9
|
+
* message_id`, which sid (if any) is currently running?".
|
|
10
|
+
*
|
|
11
|
+
* The tracker is single-entry by design — `SessionManager.currentTask`
|
|
12
|
+
* already enforces "at most one in-flight turn" at the SessionManager
|
|
13
|
+
* level, so the plugin layer can't legitimately have two MS turns
|
|
14
|
+
* active at once.
|
|
15
|
+
*/
|
|
16
|
+
export interface MsInflightEntry {
|
|
17
|
+
/** Original inbound `chat_message.message_id`. */
|
|
18
|
+
messageId: string;
|
|
19
|
+
/** Centrifugo channel `ch:{channelId}` the reply will be published on. */
|
|
20
|
+
channelId: string;
|
|
21
|
+
/** Per-channel sid bound on `SessionManager` (== `extractChatPrompt.sessionKey`). */
|
|
22
|
+
sid: string;
|
|
23
|
+
/** Wall-clock timestamp the turn was claimed (ms). For diagnostics. */
|
|
24
|
+
startedAt: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class MsInflightTracker {
|
|
27
|
+
private current;
|
|
28
|
+
set(entry: Omit<MsInflightEntry, "startedAt">): MsInflightEntry;
|
|
29
|
+
/** Idempotent — clearing twice or with a wrong id is a no-op. */
|
|
30
|
+
clear(messageId: string): void;
|
|
31
|
+
/** Force-clear (used during plugin stop / disconnect). */
|
|
32
|
+
reset(): void;
|
|
33
|
+
findByInboundMessageId(messageId: string): MsInflightEntry | null;
|
|
34
|
+
/** Visible for tests / logs. */
|
|
35
|
+
peek(): MsInflightEntry | null;
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny single-entry tracker for the IN-FLIGHT MS-originated turn.
|
|
3
|
+
*
|
|
4
|
+
* v0.9.0 — replaces the v0.8.0 `TurnContextRegister`, which carried
|
|
5
|
+
* far more state because the outbound listener needed to look up the
|
|
6
|
+
* channelId / sessionKey / inboundMessageId per AgentEvent. With
|
|
7
|
+
* `MsChannelNotifier` owning the wire mapping per-sid, the tracker
|
|
8
|
+
* only needs to answer ONE question: "given a `chat_cancel.target_
|
|
9
|
+
* message_id`, which sid (if any) is currently running?".
|
|
10
|
+
*
|
|
11
|
+
* The tracker is single-entry by design — `SessionManager.currentTask`
|
|
12
|
+
* already enforces "at most one in-flight turn" at the SessionManager
|
|
13
|
+
* level, so the plugin layer can't legitimately have two MS turns
|
|
14
|
+
* active at once.
|
|
15
|
+
*/
|
|
16
|
+
export class MsInflightTracker {
|
|
17
|
+
current = null;
|
|
18
|
+
set(entry) {
|
|
19
|
+
this.current = { ...entry, startedAt: Date.now() };
|
|
20
|
+
return this.current;
|
|
21
|
+
}
|
|
22
|
+
/** Idempotent — clearing twice or with a wrong id is a no-op. */
|
|
23
|
+
clear(messageId) {
|
|
24
|
+
if (this.current && this.current.messageId === messageId) {
|
|
25
|
+
this.current = null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Force-clear (used during plugin stop / disconnect). */
|
|
29
|
+
reset() {
|
|
30
|
+
this.current = null;
|
|
31
|
+
}
|
|
32
|
+
findByInboundMessageId(messageId) {
|
|
33
|
+
return this.current && this.current.messageId === messageId
|
|
34
|
+
? this.current
|
|
35
|
+
: null;
|
|
36
|
+
}
|
|
37
|
+
/** Visible for tests / logs. */
|
|
38
|
+
peek() {
|
|
39
|
+
return this.current;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=ms-inflight-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms-inflight-tracker.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/ms-inflight-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,MAAM,OAAO,iBAAiB;IACpB,OAAO,GAA2B,IAAI,CAAC;IAE/C,GAAG,CAAC,KAAyC;QAC3C,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,SAAiB;QACrB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACzD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAED,0DAA0D;IAC1D,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,sBAAsB,CAAC,SAAiB;QACtC,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;YACzD,CAAC,CAAC,IAAI,CAAC,OAAO;YACd,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED,gCAAgC;IAChC,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
package/dist/ports/plugin.d.ts
CHANGED
|
@@ -33,11 +33,23 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import type { Logger } from "pino";
|
|
35
35
|
import type { Config } from "../config/schema.js";
|
|
36
|
+
import type { SessionManager } from "../app/session-manager.js";
|
|
36
37
|
import type { AgentHost } from "./agent-host.js";
|
|
37
38
|
export interface PluginContext {
|
|
38
39
|
host: AgentHost;
|
|
39
40
|
config: Config;
|
|
40
41
|
log: Logger;
|
|
42
|
+
/**
|
|
43
|
+
* v0.9.0 — bootstrap-owned `SessionManager` shared across plugins.
|
|
44
|
+
*
|
|
45
|
+
* AcpPlugin uses it via the operator's fixed sid; MessageBusPlugin
|
|
46
|
+
* uses `findOrCreateSession(sessionKey)` + `bindNotifier` to route
|
|
47
|
+
* per-channel turns. Plugins MUST NOT construct their own
|
|
48
|
+
* SessionManager — single instance per process is the invariant
|
|
49
|
+
* that lets the in-flight gate (Layer 3) protect the physical
|
|
50
|
+
* device.
|
|
51
|
+
*/
|
|
52
|
+
sessionManager: SessionManager;
|
|
41
53
|
}
|
|
42
54
|
export interface AgentPlugin {
|
|
43
55
|
/** Unique, stable plugin name (used for logging / disable filters). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beeos-ai/device-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "BeeOS device-agent — Android/desktop AI control agent (TypeScript) speaking ACP over Bridge WebSocket. Connects to a sibling device-mcp-server process for device control.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@beeos-ai/beeos-types": "^1.0.0",
|
|
55
55
|
"@beeos-ai/bridge-client": "^0.1.1",
|
|
56
|
-
"@beeos-ai/message-sdk": "^0.1.
|
|
56
|
+
"@beeos-ai/message-sdk": "^0.1.1",
|
|
57
57
|
"@fastify/cors": "^11.2.0",
|
|
58
58
|
"@fastify/multipart": "^10.0.0",
|
|
59
59
|
"@mariozechner/pi-coding-agent": "0.70.2",
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* agent-runtime/skills/sqlite-store — SQLite-backed
|
|
3
|
-
* {@link SkillCacheStore}.
|
|
4
|
-
*
|
|
5
|
-
* Phase 3.1 of the [device-agent reflector upgrade plan](../../../../../../.cursor/plans/device-agent-reflector-skills_d5599350.plan.md).
|
|
6
|
-
*
|
|
7
|
-
* Schema (kept verbatim with the plan):
|
|
8
|
-
* ```sql
|
|
9
|
-
* CREATE TABLE skills (
|
|
10
|
-
* id TEXT PRIMARY KEY,
|
|
11
|
-
* app_package TEXT NOT NULL,
|
|
12
|
-
* task_summary TEXT NOT NULL,
|
|
13
|
-
* task_embedding BLOB,
|
|
14
|
-
* action_sequence_json TEXT NOT NULL,
|
|
15
|
-
* success_count INTEGER NOT NULL DEFAULT 1,
|
|
16
|
-
* fail_count INTEGER NOT NULL DEFAULT 0,
|
|
17
|
-
* last_used_at INTEGER NOT NULL,
|
|
18
|
-
* created_at INTEGER NOT NULL
|
|
19
|
-
* );
|
|
20
|
-
* CREATE INDEX idx_skills_app ON skills(app_package);
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Default DB path: `~/.beeos/device-agent/skills.sqlite`. Containerised
|
|
24
|
-
* deployments mount `/var/lib/beeos/device-agent` and override
|
|
25
|
-
* `SKILL_CACHE_PATH` accordingly.
|
|
26
|
-
*
|
|
27
|
-
* Search is implemented as a full scan over the matching app rows —
|
|
28
|
-
* the cache is intentionally small (<10k rows / device), so a brute
|
|
29
|
-
* cosine pass is cheaper than maintaining an ANN index. If profile
|
|
30
|
-
* data shows that's wrong we can plug in `sqlite-vss` / `pgvector`
|
|
31
|
-
* later behind the same {@link SkillCacheStore} interface.
|
|
32
|
-
*/
|
|
33
|
-
import type { Database as DB } from "better-sqlite3";
|
|
34
|
-
import type { NewSkillInput, Skill, SkillCacheStore, SkillMatch } from "./types.js";
|
|
35
|
-
export interface SQLiteSkillCacheStoreOptions {
|
|
36
|
-
/** Override the default DB path. Use ":memory:" for ephemeral tests. */
|
|
37
|
-
path?: string;
|
|
38
|
-
/** Pre-built better-sqlite3 Database (used by tests). */
|
|
39
|
-
db?: DB;
|
|
40
|
-
/** Skip auto-mkdir on the parent dir (when path is :memory:). */
|
|
41
|
-
noMkdir?: boolean;
|
|
42
|
-
}
|
|
43
|
-
export declare function defaultSkillCachePath(): string;
|
|
44
|
-
export declare class SQLiteSkillCacheStore implements SkillCacheStore {
|
|
45
|
-
private readonly db;
|
|
46
|
-
private readonly stmts;
|
|
47
|
-
private closed;
|
|
48
|
-
constructor(opts?: SQLiteSkillCacheStoreOptions);
|
|
49
|
-
insert(input: NewSkillInput): Skill;
|
|
50
|
-
get(id: string): Skill | undefined;
|
|
51
|
-
listByApp(appPackage: string, limit?: number): Skill[];
|
|
52
|
-
listAll(limit?: number): Skill[];
|
|
53
|
-
search(appPackage: string, query: Float32Array, k: number): SkillMatch[];
|
|
54
|
-
recordSuccess(id: string, now?: number): void;
|
|
55
|
-
recordFailure(id: string, now?: number): void;
|
|
56
|
-
delete(id: string): boolean;
|
|
57
|
-
clear(): void;
|
|
58
|
-
close(): void;
|
|
59
|
-
private applyMigrations;
|
|
60
|
-
}
|