@beeos-ai/device-agent 0.9.10 → 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/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 +2 -5
- 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
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter — PiOrchestratorAgent (two-layer outer orchestrator).
|
|
3
|
-
*
|
|
4
|
-
* Wraps `@mariozechner/pi-coding-agent`'s `AgentSession` so it can be
|
|
5
|
-
* plugged into the `IAgentCore` slot. The outer layer is the LLM that
|
|
6
|
-
* pi drives; the inner layer is whatever extensions are loaded from
|
|
7
|
-
* `<projectRoot>/.pi/extensions/` (e.g. `mobile_use`, `ground`,
|
|
8
|
-
* `ui_xml`). The adapter is **transport-agnostic** — it only knows about
|
|
9
|
-
* pi events and `AgentHost` callbacks.
|
|
10
|
-
*
|
|
11
|
-
* Key responsibilities:
|
|
12
|
-
* - Lazy session bootstrap (extension/skill scanning, model resolution)
|
|
13
|
-
* on first `run()` call.
|
|
14
|
-
* - Map pi's session events to `IAgentCore` callbacks:
|
|
15
|
-
* `message_update / text_delta` → `onText`
|
|
16
|
-
* `tool_execution_start/update/end` → `onTool` (start/update/end)
|
|
17
|
-
* `message_end (assistant role)` → captures the final assistant text
|
|
18
|
-
* - Translate `setModel(provider, model)` into pi-ai's `getModel()` and
|
|
19
|
-
* forward to `session.setModel`. Hot-swap is best-effort — when model
|
|
20
|
-
* resolution fails we keep the previous model and surface a warning.
|
|
21
|
-
* - Honor `abortSignal` by calling `session.abort()`.
|
|
22
|
-
* - Map ARouter / OpenRouter / OpenAI / Anthropic / Google base URLs to
|
|
23
|
-
* pi-ai's known provider env vars (e.g. `OPENROUTER_API_KEY`) so
|
|
24
|
-
* callers can pass a single `outer.apiKey` without exporting
|
|
25
|
-
* provider-specific env names.
|
|
26
|
-
*
|
|
27
|
-
* NOT responsibilities:
|
|
28
|
-
* - Loading extensions (caller passes the resourceLoader options).
|
|
29
|
-
* - Setting up the device — pi extensions read device handles from
|
|
30
|
-
* process env / DEVAGENT_HTTP_URL like before.
|
|
31
|
-
*/
|
|
32
|
-
import type { AgentCoreRunOptions, AgentCoreRunResult, IAgentCore } from "../ports/agent-core.js";
|
|
33
|
-
import type { Logger } from "../logger/index.js";
|
|
34
|
-
import type { IGrounder } from "../grounding/grounder.js";
|
|
35
|
-
import type { IMcpRuntime } from "../mcp-client/runtime.js";
|
|
36
|
-
import type { ShortcutInvoker, ShortcutResourceFacade } from "../shortcuts/index.js";
|
|
37
|
-
export interface PiOuterConfig {
|
|
38
|
-
/** API key for the outer LLM. Mapped to `OPENROUTER_API_KEY` etc. */
|
|
39
|
-
apiKey?: string;
|
|
40
|
-
/** Base URL — used to infer the pi-ai provider. Default ARouter. */
|
|
41
|
-
baseUrl?: string;
|
|
42
|
-
/** Upstream model id (e.g. `moonshotai/kimi-k2.6`). */
|
|
43
|
-
model?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Optional explicit pi-ai provider tag (`openrouter`, `openai`, …).
|
|
46
|
-
* When empty the provider is inferred from `baseUrl`.
|
|
47
|
-
*/
|
|
48
|
-
provider?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Minimal AgentSession surface that the adapter actually consumes.
|
|
52
|
-
* Mirrors `@mariozechner/pi-coding-agent` so we can swap in a fake in
|
|
53
|
-
* unit tests without pulling pi-ai's heavy types into the test boundary.
|
|
54
|
-
*/
|
|
55
|
-
export interface PiAgentSessionLike {
|
|
56
|
-
prompt(text: string): Promise<void>;
|
|
57
|
-
abort(): Promise<void>;
|
|
58
|
-
setModel(model: unknown): Promise<void>;
|
|
59
|
-
subscribe(listener: (event: PiSessionEvent) => void | Promise<void>): () => void;
|
|
60
|
-
dispose(): void;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Subset of pi's `AgentSessionEvent` we care about. Defined locally so
|
|
64
|
-
* tests don't need to import pi types and so the adapter is robust to
|
|
65
|
-
* upstream additions.
|
|
66
|
-
*/
|
|
67
|
-
export type PiSessionEvent = {
|
|
68
|
-
type: "message_start";
|
|
69
|
-
message: PiMessageLike;
|
|
70
|
-
} | {
|
|
71
|
-
type: "message_update";
|
|
72
|
-
message: PiMessageLike;
|
|
73
|
-
assistantMessageEvent: PiAssistantEvent;
|
|
74
|
-
} | {
|
|
75
|
-
type: "message_end";
|
|
76
|
-
message: PiMessageLike;
|
|
77
|
-
} | {
|
|
78
|
-
type: "tool_execution_start";
|
|
79
|
-
toolCallId: string;
|
|
80
|
-
toolName: string;
|
|
81
|
-
args: unknown;
|
|
82
|
-
} | {
|
|
83
|
-
type: "tool_execution_update";
|
|
84
|
-
toolCallId: string;
|
|
85
|
-
toolName: string;
|
|
86
|
-
args: unknown;
|
|
87
|
-
partialResult: unknown;
|
|
88
|
-
} | {
|
|
89
|
-
type: "tool_execution_end";
|
|
90
|
-
toolCallId: string;
|
|
91
|
-
toolName: string;
|
|
92
|
-
result: unknown;
|
|
93
|
-
isError: boolean;
|
|
94
|
-
} | {
|
|
95
|
-
type: string;
|
|
96
|
-
[k: string]: unknown;
|
|
97
|
-
};
|
|
98
|
-
interface PiMessageLike {
|
|
99
|
-
role: string;
|
|
100
|
-
content: unknown;
|
|
101
|
-
}
|
|
102
|
-
type PiAssistantEvent = {
|
|
103
|
-
type: "text_delta";
|
|
104
|
-
delta: string;
|
|
105
|
-
[k: string]: unknown;
|
|
106
|
-
} | {
|
|
107
|
-
type: "thinking_delta";
|
|
108
|
-
delta: string;
|
|
109
|
-
[k: string]: unknown;
|
|
110
|
-
} | {
|
|
111
|
-
type: string;
|
|
112
|
-
[k: string]: unknown;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Test seam — provide a custom session factory. Default factory loads
|
|
116
|
-
* `@mariozechner/pi-coding-agent` lazily so building tests / standalone
|
|
117
|
-
* binaries that skip the orchestrator never imports pi-ai at all.
|
|
118
|
-
*/
|
|
119
|
-
export interface PiSessionFactory {
|
|
120
|
-
(config: PiSessionFactoryConfig): Promise<PiAgentSessionLike>;
|
|
121
|
-
}
|
|
122
|
-
export interface PiSessionFactoryConfig {
|
|
123
|
-
projectRoot: string;
|
|
124
|
-
systemPrompt?: string;
|
|
125
|
-
/** Resolved pi-ai Model object (already URL-rewritten for ARouter). */
|
|
126
|
-
model?: unknown;
|
|
127
|
-
}
|
|
128
|
-
export interface PiOrchestratorAgentOptions {
|
|
129
|
-
/** Project root passed to pi's `DefaultResourceLoader`. */
|
|
130
|
-
projectRoot: string;
|
|
131
|
-
/** Outer-layer LLM config. */
|
|
132
|
-
outer: PiOuterConfig;
|
|
133
|
-
/**
|
|
134
|
-
* Optional override for pi's system prompt. Defaults to
|
|
135
|
-
* `ORCHESTRATOR_SYSTEM_PROMPT` (see `orchestrator-system-prompt.ts`).
|
|
136
|
-
*/
|
|
137
|
-
systemPrompt?: string;
|
|
138
|
-
/** Structured logger; falls back to console.warn. */
|
|
139
|
-
logger?: Pick<Logger, "warn" | "info" | "debug">;
|
|
140
|
-
/** Inject a custom session factory (used by tests). */
|
|
141
|
-
createSession?: PiSessionFactory;
|
|
142
|
-
/** Override pi-ai `getModel`. Used by tests to skip the heavy import. */
|
|
143
|
-
resolveModel?: ModelResolver;
|
|
144
|
-
/**
|
|
145
|
-
* Resolves the active `IMcpRuntime` on every tool call. Typically
|
|
146
|
-
* `() => mcpClient` (the sibling `device-mcp-server` HTTP client) or an
|
|
147
|
-
* `InProcMcpClient` for local CLI usage. Resolved lazily so an ACP
|
|
148
|
-
* device switch (or autospawn restart) is reflected immediately on the
|
|
149
|
-
* next `mobile_use` / `ui_xml` / `ground` invocation.
|
|
150
|
-
*/
|
|
151
|
-
mcpProvider?: () => IMcpRuntime;
|
|
152
|
-
/**
|
|
153
|
-
* Lazily build the grounder used by the `ground` extension. Called the
|
|
154
|
-
* first time the extension reads `getGrounder()` within a session.
|
|
155
|
-
* Typical implementation: `() => new HTTPGrounder(config.grounder)`.
|
|
156
|
-
*/
|
|
157
|
-
grounderFactory?: () => IGrounder;
|
|
158
|
-
/**
|
|
159
|
-
* Run a `mobile_use` task end-to-end and return the final assistant
|
|
160
|
-
* message. Wraps `InnerLoopVlm.runTask`. Letting the bootstrap layer
|
|
161
|
-
* supply this keeps the heavy `OpenAIClient` instance shared with the
|
|
162
|
-
* legacy single-layer path (and lets tests stub it out).
|
|
163
|
-
*/
|
|
164
|
-
mobileUseRunner?: (task: string, maxSteps: number, abortSignal?: AbortSignal) => Promise<string>;
|
|
165
|
-
/**
|
|
166
|
-
* Optional UI-XML formatter. When omitted the adapter calls
|
|
167
|
-
* `mcp.uiDump({ format: "raw" })` and feeds the result through
|
|
168
|
-
* `formatUiXmlToolOutput` — same behaviour the legacy `queryUiXml`
|
|
169
|
-
* used to provide on top of the raw `Device`. Tests can override to
|
|
170
|
-
* skip the dump path entirely.
|
|
171
|
-
*/
|
|
172
|
-
uiXmlRunner?: (query?: string) => Promise<string>;
|
|
173
|
-
/**
|
|
174
|
-
* Active shortcut runtime (Phase 2 of the GUI-Shortcut Hybrid Plan).
|
|
175
|
-
* When set, the orchestrator extension renders one outer-LLM tool
|
|
176
|
-
* per registered shortcut. When omitted, only the legacy
|
|
177
|
-
* `mobile_use` / `ground` / `ui_xml` triad is exposed and any
|
|
178
|
-
* extension that calls `getShortcutKB()` will throw — that's
|
|
179
|
-
* intentional, the bootstrap layer is responsible for wiring this.
|
|
180
|
-
*/
|
|
181
|
-
shortcutInvoker?: ShortcutInvoker;
|
|
182
|
-
/**
|
|
183
|
-
* Optional resource facade used by `ShortcutInvoker` callers (the
|
|
184
|
-
* `download_to_device` builtin in particular). The bootstrap layer
|
|
185
|
-
* supplies a lazy factory because the resource layer is constructed
|
|
186
|
-
* AFTER the agent core in `bootstrap.ts`. Returning `undefined`
|
|
187
|
-
* means the `download_to_device` shortcut will surface
|
|
188
|
-
* `permission_denied` to the LLM, which is preferable to silently
|
|
189
|
-
* misbehaving — but bootstrap should normally wire a facade.
|
|
190
|
-
*/
|
|
191
|
-
shortcutResourcesFactory?: () => ShortcutResourceFacade | undefined;
|
|
192
|
-
}
|
|
193
|
-
export interface ModelResolver {
|
|
194
|
-
(provider: string, modelId: string, baseUrl: string): unknown | undefined;
|
|
195
|
-
}
|
|
196
|
-
export declare class PiOrchestratorAgent implements IAgentCore {
|
|
197
|
-
private session;
|
|
198
|
-
private starting;
|
|
199
|
-
private outer;
|
|
200
|
-
private readonly projectRoot;
|
|
201
|
-
private readonly systemPrompt;
|
|
202
|
-
private readonly logger;
|
|
203
|
-
private readonly createSessionFactory;
|
|
204
|
-
private readonly resolveModelFn;
|
|
205
|
-
private readonly mcpProvider?;
|
|
206
|
-
private readonly grounderFactory?;
|
|
207
|
-
private readonly mobileUseRunner?;
|
|
208
|
-
private readonly uiXmlRunner?;
|
|
209
|
-
private readonly shortcutInvoker?;
|
|
210
|
-
private readonly shortcutResourcesFactory?;
|
|
211
|
-
private cachedGrounder;
|
|
212
|
-
constructor(opts: PiOrchestratorAgentOptions);
|
|
213
|
-
get modelName(): string;
|
|
214
|
-
get providerName(): string | undefined;
|
|
215
|
-
run(opts: AgentCoreRunOptions): Promise<AgentCoreRunResult>;
|
|
216
|
-
setModel(provider: string, model: string): Promise<void>;
|
|
217
|
-
/** Tear down the underlying pi session. Idempotent. */
|
|
218
|
-
dispose(): Promise<void>;
|
|
219
|
-
private buildExtensionContext;
|
|
220
|
-
private ensureSession;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Map our generic outer config to pi-ai's env-var contract. pi-ai reads
|
|
224
|
-
* provider-specific keys (e.g. `OPENROUTER_API_KEY`) from `process.env`,
|
|
225
|
-
* so we transparently set them when the caller hands us `outer.apiKey`
|
|
226
|
-
* + a recognised baseUrl. Never overwrites a key the caller already set.
|
|
227
|
-
*
|
|
228
|
-
* Recognised hosts:
|
|
229
|
-
* - openrouter.ai / arouter.ai → OPENROUTER_API_KEY
|
|
230
|
-
* - api.openai.com → OPENAI_API_KEY
|
|
231
|
-
* - api.anthropic.com → ANTHROPIC_API_KEY
|
|
232
|
-
* - generativelanguage.googleapis.com → GEMINI_API_KEY
|
|
233
|
-
*/
|
|
234
|
-
export declare function applyOuterEnvMapping(outer: PiOuterConfig): void;
|
|
235
|
-
/** Infer the pi-ai provider tag from a base URL. */
|
|
236
|
-
export declare function inferPiProvider(baseUrl: string): string;
|
|
237
|
-
export {};
|