@beeos-ai/device-agent 0.9.9 → 0.9.11
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/agentcore-inner-loop.d.ts +3 -4
- package/dist/adapters/agentcore-inner-loop.js +3 -4
- package/dist/adapters/agentcore-inner-loop.js.map +1 -1
- package/dist/adapters/agentcore-orchestrator.d.ts +36 -0
- package/dist/adapters/agentcore-orchestrator.js +203 -0
- package/dist/adapters/agentcore-orchestrator.js.map +1 -0
- package/dist/adapters/agentcore-runner.d.ts +3 -3
- package/dist/adapters/agentcore-runner.js +3 -3
- package/dist/adapters/app-guide.d.ts +16 -0
- package/dist/adapters/app-guide.js +101 -0
- package/dist/adapters/app-guide.js.map +1 -0
- package/dist/adapters/orchestrator-agent-prompt.d.ts +7 -0
- package/dist/adapters/orchestrator-agent-prompt.js +59 -0
- package/dist/adapters/orchestrator-agent-prompt.js.map +1 -0
- package/dist/adapters/vlm-inner-loop.d.ts +6 -0
- package/dist/adapters/vlm-inner-loop.js +3 -0
- package/dist/adapters/vlm-inner-loop.js.map +1 -1
- package/dist/agent-runtime/core.js +1 -1
- package/dist/agent-runtime/core.js.map +1 -1
- package/dist/agent-runtime/shortcuts/types.d.ts +2 -3
- package/dist/agent-runtime/shortcuts/types.js +2 -3
- package/dist/agent-runtime/shortcuts/types.js.map +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/bootstrap.d.ts +4 -4
- package/dist/bootstrap.js +47 -61
- package/dist/bootstrap.js.map +1 -1
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/loader.js +2 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +4 -5
- package/dist/config/schema.js.map +1 -1
- package/dist/device/apps.js +1 -1
- package/dist/device/apps.js.map +1 -1
- package/dist/fleet/domain/events.d.ts +22 -1
- package/dist/fleet/domain/fsm.d.ts +23 -1
- package/dist/fleet/domain/fsm.js +29 -0
- package/dist/fleet/domain/fsm.js.map +1 -1
- package/dist/fleet/supervisor.d.ts +13 -0
- package/dist/fleet/supervisor.js +90 -0
- package/dist/fleet/supervisor.js.map +1 -1
- package/dist/grounding/grounder.d.ts +1 -1
- package/dist/inbound/cli/main.d.ts +1 -1
- package/dist/inbound/cli/main.js +4 -4
- package/dist/inbound/cli/main.js.map +1 -1
- package/dist/inbound/cli/run-command.d.ts +6 -0
- package/dist/inbound/cli/run-command.js +94 -0
- package/dist/inbound/cli/run-command.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/model/adapters/general.d.ts +11 -0
- package/dist/model/adapters/general.js +249 -0
- package/dist/model/adapters/general.js.map +1 -0
- package/dist/model/adapters/index.d.ts +1 -0
- package/dist/model/adapters/index.js +1 -0
- package/dist/model/adapters/index.js.map +1 -1
- package/dist/plugins/message-bus/ms-channel-notifier.d.ts +24 -0
- package/dist/plugins/message-bus/ms-channel-notifier.js +179 -12
- package/dist/plugins/message-bus/ms-channel-notifier.js.map +1 -1
- package/dist/ports/agent-core.d.ts +6 -5
- package/dist/shortcuts/types.d.ts +3 -6
- package/dist/shortcuts/types.js +1 -2
- package/dist/shortcuts/types.js.map +1 -1
- package/package.json +3 -6
- package/.pi/extensions/android-tools.ts +0 -291
- package/.pi/skills/.gitkeep +0 -0
- package/.pi/skills/ground-mobile-fallback/SKILL.md +0 -50
- package/dist/adapters/agentcore-pi.d.ts +0 -237
- package/dist/adapters/agentcore-pi.js +0 -512
- package/dist/adapters/agentcore-pi.js.map +0 -1
- package/dist/chat.d.ts +0 -16
- package/dist/chat.js +0 -185
- package/dist/chat.js.map +0 -1
- package/dist/debug/dump-system-prompt.d.ts +0 -1
- package/dist/debug/dump-system-prompt.js +0 -34
- package/dist/debug/dump-system-prompt.js.map +0 -1
- package/dist/orchestrator-system-prompt.d.ts +0 -32
- package/dist/orchestrator-system-prompt.js +0 -197
- package/dist/orchestrator-system-prompt.js.map +0 -1
- package/dist/pi-context.d.ts +0 -132
- package/dist/pi-context.js +0 -62
- package/dist/pi-context.js.map +0 -1
- package/dist/pi-local-skills.d.ts +0 -17
- package/dist/pi-local-skills.js +0 -24
- package/dist/pi-local-skills.js.map +0 -1
|
@@ -67,12 +67,28 @@ export interface MsChannelNotifierOptions {
|
|
|
67
67
|
*/
|
|
68
68
|
sessionKey: string;
|
|
69
69
|
logger: Logger;
|
|
70
|
+
/**
|
|
71
|
+
* Test seam — async delay used between publish retries. Defaults to a
|
|
72
|
+
* real `setTimeout`-backed sleep. Tests inject a no-op / fake clock so
|
|
73
|
+
* retry assertions don't wall-clock block.
|
|
74
|
+
*/
|
|
75
|
+
sleep?: (ms: number) => Promise<void>;
|
|
70
76
|
}
|
|
71
77
|
export declare class MsChannelNotifier implements SessionUpdateNotifier {
|
|
72
78
|
private readonly opts;
|
|
73
79
|
/** Cumulative `agent_message_chunk` text — populates terminal `agent_reply.text`. */
|
|
74
80
|
private accumulatedText;
|
|
81
|
+
/** Count of delta sends attempted this turn — diagnostics for the terminal log. */
|
|
82
|
+
private deltaCount;
|
|
75
83
|
private finalized;
|
|
84
|
+
/**
|
|
85
|
+
* Set synchronously on entry to `publishFinal` to guard against a
|
|
86
|
+
* concurrent duplicate `stream_complete`. `finalized` (the public
|
|
87
|
+
* "terminal reply actually landed" flag) is only set AFTER a
|
|
88
|
+
* successful send, so a failed publish can be retried.
|
|
89
|
+
*/
|
|
90
|
+
private finalizing;
|
|
91
|
+
private readonly sleep;
|
|
76
92
|
constructor(opts: MsChannelNotifierOptions);
|
|
77
93
|
/**
|
|
78
94
|
* Called by SessionManager for every `session/update` envelope on
|
|
@@ -97,4 +113,12 @@ export declare class MsChannelNotifier implements SessionUpdateNotifier {
|
|
|
97
113
|
* publish two terminal envelopes.
|
|
98
114
|
*/
|
|
99
115
|
private publishFinal;
|
|
116
|
+
/**
|
|
117
|
+
* Publish via `messages.send` with bounded exponential-backoff retry.
|
|
118
|
+
* Retries transient failures (network / 5xx / 408 / 429); treats a
|
|
119
|
+
* duplicate-id 409 as success (idempotent re-delivery); gives up
|
|
120
|
+
* immediately on fatal client errors (e.g. conversation closed, not a
|
|
121
|
+
* member) since retrying those can never succeed.
|
|
122
|
+
*/
|
|
123
|
+
private sendWithRetry;
|
|
100
124
|
}
|
|
@@ -47,13 +47,41 @@
|
|
|
47
47
|
* subsequent handlers (e.g. status:idle). All publish failures are
|
|
48
48
|
* logged and swallowed.
|
|
49
49
|
*/
|
|
50
|
+
/**
|
|
51
|
+
* Publish retry budgets. The terminal `agent_reply` is the only message
|
|
52
|
+
* the caller's `/wait` blocks on, so it gets a far larger budget than
|
|
53
|
+
* best-effort progress deltas. Backoff is exponential, capped at
|
|
54
|
+
* `RETRY_CAP_MS`.
|
|
55
|
+
*
|
|
56
|
+
* - delta: 3 attempts (≈ 0.5s + 1s of backoff) — best effort.
|
|
57
|
+
* - terminal: 8 attempts (≈ 0.5,1,2,4,8,16,30s ≈ 60s) — must arrive.
|
|
58
|
+
*
|
|
59
|
+
* Every send carries an `Idempotency-Key`, so a retry that races a
|
|
60
|
+
* server-side success is de-duped (409) rather than double-delivered.
|
|
61
|
+
*/
|
|
62
|
+
const DELTA_MAX_ATTEMPTS = 3;
|
|
63
|
+
const TERMINAL_MAX_ATTEMPTS = 8;
|
|
64
|
+
const RETRY_BASE_MS = 500;
|
|
65
|
+
const RETRY_CAP_MS = 30_000;
|
|
66
|
+
const realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
50
67
|
export class MsChannelNotifier {
|
|
51
68
|
opts;
|
|
52
69
|
/** Cumulative `agent_message_chunk` text — populates terminal `agent_reply.text`. */
|
|
53
70
|
accumulatedText = "";
|
|
71
|
+
/** Count of delta sends attempted this turn — diagnostics for the terminal log. */
|
|
72
|
+
deltaCount = 0;
|
|
54
73
|
finalized = false;
|
|
74
|
+
/**
|
|
75
|
+
* Set synchronously on entry to `publishFinal` to guard against a
|
|
76
|
+
* concurrent duplicate `stream_complete`. `finalized` (the public
|
|
77
|
+
* "terminal reply actually landed" flag) is only set AFTER a
|
|
78
|
+
* successful send, so a failed publish can be retried.
|
|
79
|
+
*/
|
|
80
|
+
finalizing = false;
|
|
81
|
+
sleep;
|
|
55
82
|
constructor(opts) {
|
|
56
83
|
this.opts = opts;
|
|
84
|
+
this.sleep = opts.sleep ?? realSleep;
|
|
57
85
|
}
|
|
58
86
|
/**
|
|
59
87
|
* Called by SessionManager for every `session/update` envelope on
|
|
@@ -106,18 +134,21 @@ export class MsChannelNotifier {
|
|
|
106
134
|
}
|
|
107
135
|
catch (err) {
|
|
108
136
|
this.opts.logger.error({
|
|
109
|
-
|
|
137
|
+
...describeError(err),
|
|
110
138
|
channelId: this.opts.channelId,
|
|
111
139
|
sessionUpdate,
|
|
112
140
|
}, "ms-channel-notifier: publish failed");
|
|
113
141
|
}
|
|
114
142
|
}
|
|
115
143
|
async publishDelta(sessionUpdate, text) {
|
|
144
|
+
this.deltaCount += 1;
|
|
116
145
|
// Persistent delta send via v2 messages.send. Deltas MUST NOT
|
|
117
146
|
// carry `replyTo` (it would short-circuit MS `/wait` on the
|
|
118
147
|
// first delta — the wait endpoint matches purely on `reply_to`,
|
|
119
|
-
// not message type).
|
|
120
|
-
|
|
148
|
+
// not message type). Best-effort retry only — terminal reply
|
|
149
|
+
// carries the full accumulated text, so a dropped delta degrades
|
|
150
|
+
// live progress UX but never loses the final answer.
|
|
151
|
+
await this.sendWithRetry({
|
|
121
152
|
conversationId: this.opts.channelId,
|
|
122
153
|
type: "agent_reply_delta",
|
|
123
154
|
content: {
|
|
@@ -127,7 +158,7 @@ export class MsChannelNotifier {
|
|
|
127
158
|
content: { type: "text", text },
|
|
128
159
|
},
|
|
129
160
|
},
|
|
130
|
-
});
|
|
161
|
+
}, DELTA_MAX_ATTEMPTS);
|
|
131
162
|
}
|
|
132
163
|
/**
|
|
133
164
|
* Emit the terminal `agent_reply`. Idempotent — guarded by
|
|
@@ -136,9 +167,13 @@ export class MsChannelNotifier {
|
|
|
136
167
|
* publish two terminal envelopes.
|
|
137
168
|
*/
|
|
138
169
|
async publishFinal(stopReason, errorText) {
|
|
139
|
-
|
|
170
|
+
// `finalized` guards a true duplicate (terminal already landed);
|
|
171
|
+
// `finalizing` guards a concurrent re-entry while a send is still
|
|
172
|
+
// in flight. We only flip `finalized` AFTER a confirmed send so a
|
|
173
|
+
// transient publish failure leaves the door open for a resend.
|
|
174
|
+
if (this.finalized || this.finalizing)
|
|
140
175
|
return;
|
|
141
|
-
this.
|
|
176
|
+
this.finalizing = true;
|
|
142
177
|
let content;
|
|
143
178
|
if (stopReason === "cancelled") {
|
|
144
179
|
content = {
|
|
@@ -160,12 +195,78 @@ export class MsChannelNotifier {
|
|
|
160
195
|
text: this.accumulatedText,
|
|
161
196
|
};
|
|
162
197
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
198
|
+
try {
|
|
199
|
+
await this.sendWithRetry({
|
|
200
|
+
conversationId: this.opts.channelId,
|
|
201
|
+
type: "agent_reply",
|
|
202
|
+
replyTo: this.opts.inboundMessageId,
|
|
203
|
+
// Stable idempotency key — retries that race a server-side
|
|
204
|
+
// success de-dupe (409) instead of double-delivering.
|
|
205
|
+
id: `${this.opts.inboundMessageId}:final`,
|
|
206
|
+
content,
|
|
207
|
+
}, TERMINAL_MAX_ATTEMPTS);
|
|
208
|
+
this.finalized = true;
|
|
209
|
+
// Confirms the device→platform handoff: a terminal reply WAS
|
|
210
|
+
// delivered. textLen=0 here means the device sent an empty answer
|
|
211
|
+
// (panel would render blank even though delivery succeeded) — a
|
|
212
|
+
// different failure mode from "reply never sent".
|
|
213
|
+
this.opts.logger.info({
|
|
214
|
+
channelId: this.opts.channelId,
|
|
215
|
+
inboundMessageId: this.opts.inboundMessageId,
|
|
216
|
+
replyTo: this.opts.inboundMessageId,
|
|
217
|
+
stopReason,
|
|
218
|
+
textLen: this.accumulatedText.length,
|
|
219
|
+
hasError: stopReason === "cancelled" || !!errorText,
|
|
220
|
+
deltaCount: this.deltaCount,
|
|
221
|
+
}, "ms-channel-notifier: terminal agent_reply delivered");
|
|
222
|
+
}
|
|
223
|
+
catch (err) {
|
|
224
|
+
// Terminal reply exhausted its retry budget. The caller's `/wait`
|
|
225
|
+
// will now time out with no answer — log loudly with the real
|
|
226
|
+
// cause so this is diagnosable, and leave `finalized=false` so an
|
|
227
|
+
// upstream fallback (inbound reject path) can still try.
|
|
228
|
+
this.opts.logger.error({
|
|
229
|
+
...describeError(err),
|
|
230
|
+
channelId: this.opts.channelId,
|
|
231
|
+
inboundMessageId: this.opts.inboundMessageId,
|
|
232
|
+
stopReason,
|
|
233
|
+
}, "ms-channel-notifier: TERMINAL agent_reply publish FAILED after retries — caller will not receive a reply");
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
this.finalizing = false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Publish via `messages.send` with bounded exponential-backoff retry.
|
|
241
|
+
* Retries transient failures (network / 5xx / 408 / 429); treats a
|
|
242
|
+
* duplicate-id 409 as success (idempotent re-delivery); gives up
|
|
243
|
+
* immediately on fatal client errors (e.g. conversation closed, not a
|
|
244
|
+
* member) since retrying those can never succeed.
|
|
245
|
+
*/
|
|
246
|
+
async sendWithRetry(input, maxAttempts) {
|
|
247
|
+
for (let attempt = 1;; attempt++) {
|
|
248
|
+
try {
|
|
249
|
+
await this.opts.client.messages.send(input);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
const verdict = classifyError(err);
|
|
254
|
+
if (verdict === "duplicate")
|
|
255
|
+
return;
|
|
256
|
+
if (verdict === "fatal" || attempt >= maxAttempts)
|
|
257
|
+
throw err;
|
|
258
|
+
const delay = Math.min(RETRY_CAP_MS, RETRY_BASE_MS * 2 ** (attempt - 1));
|
|
259
|
+
this.opts.logger.warn({
|
|
260
|
+
...describeError(err),
|
|
261
|
+
channelId: this.opts.channelId,
|
|
262
|
+
type: input.type,
|
|
263
|
+
attempt,
|
|
264
|
+
maxAttempts,
|
|
265
|
+
retryInMs: delay,
|
|
266
|
+
}, "ms-channel-notifier: publish failed, retrying");
|
|
267
|
+
await this.sleep(delay);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
169
270
|
}
|
|
170
271
|
}
|
|
171
272
|
function pickSessionUpdate(update) {
|
|
@@ -183,4 +284,70 @@ function pickContentText(content) {
|
|
|
183
284
|
function pickString(v) {
|
|
184
285
|
return typeof v === "string" ? v : "";
|
|
185
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Extract diagnosable structured fields from an unknown thrown value.
|
|
289
|
+
*
|
|
290
|
+
* Fixes the historical `[object Object]` / bare `fetch failed` blind
|
|
291
|
+
* spot: a Node `fetch` rejection is a `TypeError` whose `.message` is
|
|
292
|
+
* just "fetch failed" — the real reason (ECONNREFUSED, ENOTFOUND,
|
|
293
|
+
* UND_ERR_*, socket timeout) lives on `.cause`. `MessagingError`s from
|
|
294
|
+
* the SDK carry `.status` / `.code`. We surface all of it.
|
|
295
|
+
*/
|
|
296
|
+
function describeError(err) {
|
|
297
|
+
if (err instanceof Error) {
|
|
298
|
+
const out = { err: err.message, errName: err.name };
|
|
299
|
+
const anyErr = err;
|
|
300
|
+
if (typeof anyErr.status === "number")
|
|
301
|
+
out.status = anyErr.status;
|
|
302
|
+
if (typeof anyErr.code === "string")
|
|
303
|
+
out.code = anyErr.code;
|
|
304
|
+
if (anyErr.cause !== undefined)
|
|
305
|
+
out.cause = describeCause(anyErr.cause);
|
|
306
|
+
return out;
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
return { err: JSON.stringify(err) };
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return { err: String(err) };
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function describeCause(cause) {
|
|
316
|
+
if (cause instanceof Error) {
|
|
317
|
+
const code = cause.code;
|
|
318
|
+
return typeof code === "string"
|
|
319
|
+
? `${cause.name}: ${cause.message} (${code})`
|
|
320
|
+
: `${cause.name}: ${cause.message}`;
|
|
321
|
+
}
|
|
322
|
+
try {
|
|
323
|
+
return JSON.stringify(cause);
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
return String(cause);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Decide how to handle a `messages.send` failure:
|
|
331
|
+
* - "duplicate" — server already has this id (409); treat as success.
|
|
332
|
+
* - "fatal" — permanent client error (4xx other than 408/429);
|
|
333
|
+
* retrying can never succeed.
|
|
334
|
+
* - "retry" — transient (network / 5xx / 408 / 429 / unknown);
|
|
335
|
+
* worth another attempt.
|
|
336
|
+
*/
|
|
337
|
+
function classifyError(err) {
|
|
338
|
+
const status = err?.status;
|
|
339
|
+
if (typeof status === "number") {
|
|
340
|
+
if (status === 409)
|
|
341
|
+
return "duplicate";
|
|
342
|
+
if (status === 408 || status === 429)
|
|
343
|
+
return "retry";
|
|
344
|
+
if (status >= 400 && status < 500)
|
|
345
|
+
return "fatal";
|
|
346
|
+
return "retry";
|
|
347
|
+
}
|
|
348
|
+
// No HTTP status → network/transport error (fetch failed, abort,
|
|
349
|
+
// DNS, connection refused). These are exactly the transient blips we
|
|
350
|
+
// want to ride through.
|
|
351
|
+
return "retry";
|
|
352
|
+
}
|
|
186
353
|
//# sourceMappingURL=ms-channel-notifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ms-channel-notifier.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/ms-channel-notifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;
|
|
1
|
+
{"version":3,"file":"ms-channel-notifier.js","sourceRoot":"","sources":["../../../src/plugins/message-bus/ms-channel-notifier.ts"],"names":[],"mappings":"AAAA;;;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C7C,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,GAAY;IACjC,MAAM,MAAM,GAAI,GAA4B,EAAE,MAAM,CAAC;IACrD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,WAAW,CAAC;QACvC,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,OAAO,CAAC;QACrD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG;YAAE,OAAO,OAAO,CAAC;QAClD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,iEAAiE;IACjE,qEAAqE;IACrE,wBAAwB;IACxB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -8,15 +8,16 @@
|
|
|
8
8
|
*
|
|
9
9
|
* - ACP / Bridge / HTTP transports
|
|
10
10
|
* - SessionManager / TaskRunner accounting
|
|
11
|
-
* - the
|
|
11
|
+
* - the two-layer orchestrator vs single-layer details
|
|
12
12
|
*
|
|
13
13
|
* Plugins (ACP, HTTP debug, agent-sync, ...) interact with the core
|
|
14
14
|
* indirectly through `AgentHost`. The host owns the IAgentCore instance
|
|
15
15
|
* and dispatches events; plugins never call `IAgentCore.run` directly.
|
|
16
16
|
*
|
|
17
17
|
* Implementations:
|
|
18
|
-
* - `adapters/agentcore-
|
|
19
|
-
*
|
|
18
|
+
* - `adapters/agentcore-runner.ts` — AgentRunner Hybrid Plan-Act (default)
|
|
19
|
+
* - `adapters/agentcore-orchestrator.ts` — two-layer OrchestratorAgent
|
|
20
|
+
* (outer tool-calling LLM, inner autoglm VLM via mobile_use; `--orchestrator`)
|
|
20
21
|
* - `adapters/agentcore-inner-loop.ts` — single-layer fallback that wraps
|
|
21
22
|
* `vlm-inner-loop.ts` (selected by `--legacy-inner`)
|
|
22
23
|
*/
|
|
@@ -119,7 +120,7 @@ export interface AgentCoreRunCallbacks {
|
|
|
119
120
|
export interface AgentCoreRunResult {
|
|
120
121
|
/** Final user-facing reply. */
|
|
121
122
|
finalMessage: string;
|
|
122
|
-
/** Number of inner steps observed (0 for the
|
|
123
|
+
/** Number of inner steps observed (0 for the orchestrator adapter — opaque tools). */
|
|
123
124
|
steps: number;
|
|
124
125
|
/** True iff the run terminated due to abort / timeout. */
|
|
125
126
|
cancelled: boolean;
|
|
@@ -128,7 +129,7 @@ export interface AgentCoreRunResult {
|
|
|
128
129
|
export interface AgentCoreRunOptions extends AgentCoreRunCallbacks {
|
|
129
130
|
/** Natural language task / prompt. */
|
|
130
131
|
task: string;
|
|
131
|
-
/** Soft cap on inner steps (legacy adapter);
|
|
132
|
+
/** Soft cap on inner steps (legacy adapter); orchestrator may ignore. */
|
|
132
133
|
maxSteps?: number;
|
|
133
134
|
abortSignal?: AbortSignal;
|
|
134
135
|
}
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
* shortcut's `execute(...)` body but are never advertised as
|
|
32
32
|
* outer-LLM tools. The convention is enforced by inspection:
|
|
33
33
|
* if you need to add a new shortcut that calls these, do so
|
|
34
|
-
* from inside `services/shortcuts/*.ts` only
|
|
35
|
-
* file-level comment in `pi-context.ts`.
|
|
34
|
+
* from inside `services/shortcuts/*.ts` only.
|
|
36
35
|
*
|
|
37
36
|
* Error contract:
|
|
38
37
|
*
|
|
@@ -94,8 +93,7 @@ export type ShortcutResult<T = unknown> = ShortcutSuccess<T> | ShortcutFailure;
|
|
|
94
93
|
* JSON schema fragment for a shortcut's parameter object. Kept as
|
|
95
94
|
* `unknown` here so callers can supply either a TypeBox / Zod schema
|
|
96
95
|
* or a hand-rolled JSON Schema; the registry forwards the value
|
|
97
|
-
* unchanged to the outer LLM tool descriptor
|
|
98
|
-
* `.pi/extensions/android-tools.ts`). Validation happens inside each
|
|
96
|
+
* unchanged to the outer LLM tool descriptor. Validation happens inside each
|
|
99
97
|
* shortcut's `execute` body — there is no central validator, both
|
|
100
98
|
* because the runtimes (TypeBox vs Zod vs raw JSON Schema) differ in
|
|
101
99
|
* how they expose `validate(input)` and because the plan intentionally
|
|
@@ -139,8 +137,7 @@ export type ShortcutPlatform = "android" | "desktop" | "any";
|
|
|
139
137
|
/**
|
|
140
138
|
* Concrete shortcut. The execute method is given a ready-built
|
|
141
139
|
* `ShortcutContext` so individual shortcuts don't have to hand-roll
|
|
142
|
-
* MCP / device wiring
|
|
143
|
-
* honest — see D9).
|
|
140
|
+
* MCP / device wiring.
|
|
144
141
|
*/
|
|
145
142
|
export interface Shortcut<TArgs = unknown, TOut = unknown> {
|
|
146
143
|
readonly descriptor: ShortcutDescriptor;
|
package/dist/shortcuts/types.js
CHANGED
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
* shortcut's `execute(...)` body but are never advertised as
|
|
32
32
|
* outer-LLM tools. The convention is enforced by inspection:
|
|
33
33
|
* if you need to add a new shortcut that calls these, do so
|
|
34
|
-
* from inside `services/shortcuts/*.ts` only
|
|
35
|
-
* file-level comment in `pi-context.ts`.
|
|
34
|
+
* from inside `services/shortcuts/*.ts` only.
|
|
36
35
|
*
|
|
37
36
|
* Error contract:
|
|
38
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shortcuts/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shortcuts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beeos-ai/device-agent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
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",
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"README.md",
|
|
25
25
|
"LICENSE",
|
|
26
|
-
"CHANGELOG.md"
|
|
27
|
-
".pi"
|
|
26
|
+
"CHANGELOG.md"
|
|
28
27
|
],
|
|
29
28
|
"publishConfig": {
|
|
30
29
|
"access": "public"
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
"@beeos-ai/message-sdk": "^1.0.0",
|
|
57
56
|
"@fastify/cors": "^11.2.0",
|
|
58
57
|
"@fastify/multipart": "^10.0.0",
|
|
59
|
-
"@mariozechner/pi-coding-agent": "0.70.2",
|
|
60
58
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
61
59
|
"dotenv": "^16.5.0",
|
|
62
60
|
"fastify": "^5.8.5",
|
|
@@ -73,7 +71,7 @@
|
|
|
73
71
|
"tsx": "^4.19.0",
|
|
74
72
|
"typescript": "^5.8.0",
|
|
75
73
|
"vitest": "^4.1.5",
|
|
76
|
-
"@beeos-ai/device-mcp-server": "0.4.
|
|
74
|
+
"@beeos-ai/device-mcp-server": "0.4.3"
|
|
77
75
|
},
|
|
78
76
|
"scripts": {
|
|
79
77
|
"build": "tsc -p tsconfig.json && chmod +x dist/inbound/cli/main.js",
|
|
@@ -82,7 +80,6 @@
|
|
|
82
80
|
"test": "vitest run",
|
|
83
81
|
"test:watch": "vitest",
|
|
84
82
|
"test:cov": "vitest run --coverage",
|
|
85
|
-
"chat": "tsx src/chat.ts",
|
|
86
83
|
"run:wechat-fixture": "tsx scripts/synthesize-wechat-fixture.ts",
|
|
87
84
|
"record:wechat-fixture": "tsx scripts/record-wechat-fixture.ts",
|
|
88
85
|
"legacy:test:mobile": "tsx scripts/legacy/test-mobile-use.ts",
|