@beeos-ai/device-agent 0.4.2 → 0.5.0
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/.pi/extensions/android-tools.ts +146 -15
- package/LICENSE +201 -0
- package/dist/adapters/agent-gateway-client.d.ts +37 -0
- package/dist/adapters/agent-gateway-client.js +45 -0
- package/dist/adapters/agent-gateway-client.js.map +1 -1
- package/dist/adapters/agentcore-pi.d.ts +22 -0
- package/dist/adapters/agentcore-pi.js +48 -0
- package/dist/adapters/agentcore-pi.js.map +1 -1
- package/dist/adapters/device-android-adb.d.ts +47 -0
- package/dist/adapters/device-android-adb.js +50 -0
- package/dist/adapters/device-android-adb.js.map +1 -1
- package/dist/adapters/device-desktop.d.ts +12 -0
- package/dist/adapters/device-desktop.js +31 -0
- package/dist/adapters/device-desktop.js.map +1 -1
- package/dist/agent-runtime/adapters/base.d.ts +20 -0
- package/dist/agent-runtime/adapters/base.js.map +1 -1
- package/dist/agent-runtime/agent-runner.d.ts +4 -2
- package/dist/agent-runtime/agent-runner.js.map +1 -1
- package/dist/agent-runtime/core.d.ts +60 -0
- package/dist/agent-runtime/core.js +190 -9
- package/dist/agent-runtime/core.js.map +1 -1
- package/dist/agent-runtime/feedback.d.ts +56 -0
- package/dist/agent-runtime/feedback.js +54 -0
- package/dist/agent-runtime/feedback.js.map +1 -0
- package/dist/agent-runtime/index.d.ts +1 -0
- package/dist/agent-runtime/index.js +1 -0
- package/dist/agent-runtime/index.js.map +1 -1
- package/dist/agent-runtime/plan-executor.js +24 -0
- package/dist/agent-runtime/plan-executor.js.map +1 -1
- package/dist/agent-runtime/planner/base.d.ts +10 -0
- package/dist/agent-runtime/planner/base.js.map +1 -1
- package/dist/agent-runtime/planner/llm-planner.js +1 -0
- package/dist/agent-runtime/planner/llm-planner.js.map +1 -1
- package/dist/agent-runtime/planner/prompts.d.ts +3 -0
- package/dist/agent-runtime/planner/prompts.js +12 -0
- package/dist/agent-runtime/planner/prompts.js.map +1 -1
- package/dist/agent-runtime/reflection.d.ts +25 -6
- package/dist/agent-runtime/reflection.js +64 -22
- package/dist/agent-runtime/reflection.js.map +1 -1
- package/dist/agent-runtime/reflectors/policy.d.ts +10 -4
- package/dist/agent-runtime/reflectors/policy.js +19 -6
- package/dist/agent-runtime/reflectors/policy.js.map +1 -1
- package/dist/agent-runtime/shortcuts/fs-store.d.ts +41 -0
- package/dist/agent-runtime/shortcuts/fs-store.js +122 -0
- package/dist/agent-runtime/shortcuts/fs-store.js.map +1 -0
- package/dist/agent-runtime/shortcuts/in-memory-store.d.ts +20 -0
- package/dist/agent-runtime/shortcuts/in-memory-store.js +64 -0
- package/dist/agent-runtime/shortcuts/in-memory-store.js.map +1 -0
- package/dist/agent-runtime/shortcuts/index.d.ts +10 -0
- package/dist/agent-runtime/shortcuts/index.js +10 -0
- package/dist/agent-runtime/shortcuts/index.js.map +1 -0
- package/dist/agent-runtime/shortcuts/types.d.ts +69 -0
- package/dist/agent-runtime/shortcuts/types.js +17 -0
- package/dist/agent-runtime/shortcuts/types.js.map +1 -0
- package/dist/app/agent-host.d.ts +83 -0
- package/dist/app/agent-host.js +345 -32
- package/dist/app/agent-host.js.map +1 -1
- package/dist/app/session-manager.d.ts +33 -4
- package/dist/app/session-manager.js +27 -5
- package/dist/app/session-manager.js.map +1 -1
- package/dist/bootstrap.js +187 -3
- package/dist/bootstrap.js.map +1 -1
- package/dist/config/loader.js +22 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +18 -0
- package/dist/config/schema.js +118 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/inbound/acp/handlers/session.js.map +1 -1
- package/dist/mcp-client/client.d.ts +6 -0
- package/dist/mcp-client/client.js +11 -0
- package/dist/mcp-client/client.js.map +1 -1
- package/dist/mcp-client/runtime.d.ts +13 -0
- package/dist/orchestrator-system-prompt.d.ts +26 -0
- package/dist/orchestrator-system-prompt.js +118 -2
- package/dist/orchestrator-system-prompt.js.map +1 -1
- package/dist/pi-context.d.ts +50 -0
- package/dist/pi-context.js.map +1 -1
- package/dist/ports/device.d.ts +18 -0
- package/dist/resources/augmenter.d.ts +48 -0
- package/dist/resources/augmenter.js +126 -0
- package/dist/resources/augmenter.js.map +1 -0
- package/dist/resources/cache.d.ts +57 -0
- package/dist/resources/cache.js +107 -0
- package/dist/resources/cache.js.map +1 -0
- package/dist/resources/index.d.ts +17 -0
- package/dist/resources/index.js +15 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/lifecycle/disk-pressure.d.ts +75 -0
- package/dist/resources/lifecycle/disk-pressure.js +148 -0
- package/dist/resources/lifecycle/disk-pressure.js.map +1 -0
- package/dist/resources/lifecycle/index.d.ts +7 -0
- package/dist/resources/lifecycle/index.js +7 -0
- package/dist/resources/lifecycle/index.js.map +1 -0
- package/dist/resources/lifecycle/manager.d.ts +38 -0
- package/dist/resources/lifecycle/manager.js +205 -0
- package/dist/resources/lifecycle/manager.js.map +1 -0
- package/dist/resources/lifecycle/sweeper.d.ts +36 -0
- package/dist/resources/lifecycle/sweeper.js +179 -0
- package/dist/resources/lifecycle/sweeper.js.map +1 -0
- package/dist/resources/lifecycle/types.d.ts +180 -0
- package/dist/resources/lifecycle/types.js +46 -0
- package/dist/resources/lifecycle/types.js.map +1 -0
- package/dist/resources/parsers.d.ts +28 -0
- package/dist/resources/parsers.js +88 -0
- package/dist/resources/parsers.js.map +1 -0
- package/dist/resources/registry.d.ts +47 -0
- package/dist/resources/registry.js +107 -0
- package/dist/resources/registry.js.map +1 -0
- package/dist/resources/resolvers/beeos-file-resolver.d.ts +62 -0
- package/dist/resources/resolvers/beeos-file-resolver.js +109 -0
- package/dist/resources/resolvers/beeos-file-resolver.js.map +1 -0
- package/dist/resources/resolvers/errors.d.ts +11 -0
- package/dist/resources/resolvers/errors.js +23 -0
- package/dist/resources/resolvers/errors.js.map +1 -0
- package/dist/resources/resolvers/mime-table.d.ts +41 -0
- package/dist/resources/resolvers/mime-table.js +92 -0
- package/dist/resources/resolvers/mime-table.js.map +1 -0
- package/dist/resources/resolvers/url-resolver.d.ts +85 -0
- package/dist/resources/resolvers/url-resolver.js +495 -0
- package/dist/resources/resolvers/url-resolver.js.map +1 -0
- package/dist/resources/shortcut-facade.d.ts +51 -0
- package/dist/resources/shortcut-facade.js +72 -0
- package/dist/resources/shortcut-facade.js.map +1 -0
- package/dist/resources/telemetry.d.ts +52 -0
- package/dist/resources/telemetry.js +59 -0
- package/dist/resources/telemetry.js.map +1 -0
- package/dist/resources/types.d.ts +249 -0
- package/dist/resources/types.js +29 -0
- package/dist/resources/types.js.map +1 -0
- package/dist/shortcuts/builtins/download-to-device.d.ts +83 -0
- package/dist/shortcuts/builtins/download-to-device.js +125 -0
- package/dist/shortcuts/builtins/download-to-device.js.map +1 -0
- package/dist/shortcuts/builtins/find-app-package.d.ts +79 -0
- package/dist/shortcuts/builtins/find-app-package.js +168 -0
- package/dist/shortcuts/builtins/find-app-package.js.map +1 -0
- package/dist/shortcuts/builtins/index.d.ts +32 -0
- package/dist/shortcuts/builtins/index.js +37 -0
- package/dist/shortcuts/builtins/index.js.map +1 -0
- package/dist/shortcuts/builtins/open-deeplink.d.ts +68 -0
- package/dist/shortcuts/builtins/open-deeplink.js +142 -0
- package/dist/shortcuts/builtins/open-deeplink.js.map +1 -0
- package/dist/shortcuts/builtins/set-clipboard.d.ts +65 -0
- package/dist/shortcuts/builtins/set-clipboard.js +112 -0
- package/dist/shortcuts/builtins/set-clipboard.js.map +1 -0
- package/dist/shortcuts/index.d.ts +11 -0
- package/dist/shortcuts/index.js +11 -0
- package/dist/shortcuts/index.js.map +1 -0
- package/dist/shortcuts/registry.d.ts +56 -0
- package/dist/shortcuts/registry.js +70 -0
- package/dist/shortcuts/registry.js.map +1 -0
- package/dist/shortcuts/router.d.ts +91 -0
- package/dist/shortcuts/router.js +158 -0
- package/dist/shortcuts/router.js.map +1 -0
- package/dist/shortcuts/types.d.ts +219 -0
- package/dist/shortcuts/types.js +46 -0
- package/dist/shortcuts/types.js.map +1 -0
- package/package.json +24 -25
- 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/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":"client.js","sourceRoot":"","sources":["../../src/mcp-client/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,mBAAmB,GAUpB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAmBlC;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC;AACjD,CAAC;AAED,MAAM,OAAO,SAAS;IACH,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,SAAS,CAAU;IACnB,SAAS,CAAe;IAEzC,YAAY,OA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C9C,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS;IACzB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -31,4 +31,17 @@ export interface IMcpRuntime {
|
|
|
31
31
|
installApk?(path: string): Promise<void>;
|
|
32
32
|
/** Run a shell command on the sandbox. Optional. */
|
|
33
33
|
executeCommand?(body: string, opts?: ExecuteCommandOptions): Promise<ExecuteCommandResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Write `bytes` to an absolute device-local `path`. Optional.
|
|
36
|
+
*
|
|
37
|
+
* Used by the Resource Resolution Layer to push downloaded URL
|
|
38
|
+
* payloads onto the device before the VLM ever sees the prompt.
|
|
39
|
+
* Implementations:
|
|
40
|
+
* - real `McpClient` → `callTool("file_write", { path, contentB64 })`
|
|
41
|
+
* - `InProcMcpClient` is allowed to throw `"unsupported"` (the
|
|
42
|
+
* legacy in-process bridge does not have a generic file-write
|
|
43
|
+
* primitive; production paths always go through the sibling
|
|
44
|
+
* `device-mcp-server` HTTP service).
|
|
45
|
+
*/
|
|
46
|
+
fileWrite?(path: string, bytes: Buffer): Promise<void>;
|
|
34
47
|
}
|
|
@@ -2,5 +2,31 @@
|
|
|
2
2
|
* Outer orchestrator system prompts (pi-coding-agent).
|
|
3
3
|
* Per-tool details live in tool `description` / schema, not here.
|
|
4
4
|
* Select via ORCH_LANG env var: "cn" (default) | "en".
|
|
5
|
+
*
|
|
6
|
+
* Phase 2 (GUI-Shortcut Hybrid Plan, MAS-Bench 2025 SOTA):
|
|
7
|
+
* The prompt below now codifies three GENERIC heuristics for
|
|
8
|
+
* choosing between GUI primitives (`mobile_use`) and structured
|
|
9
|
+
* shortcuts (`download_to_device`, `set_clipboard`, `open_deeplink`,
|
|
10
|
+
* `find_app_package`):
|
|
11
|
+
*
|
|
12
|
+
* 1. **prefer-shortcut-when-applicable** — when a structured
|
|
13
|
+
* shortcut covers the user's need, call it before resorting
|
|
14
|
+
* to mobile_use. Shortcuts complete in O(1) ADB calls vs
|
|
15
|
+
* mobile_use's O(N) screenshot loop.
|
|
16
|
+
* 2. **avoid-misuse** — shortcuts are not free-form. Never
|
|
17
|
+
* invent shortcut arguments; respect the JSON schema. If a
|
|
18
|
+
* shortcut's pre-conditions don't hold (no URL, no installed
|
|
19
|
+
* app), fall back to mobile_use rather than fabricating an
|
|
20
|
+
* argument.
|
|
21
|
+
* 3. **shortcut-failure-fallback-to-mobile_use** — every
|
|
22
|
+
* shortcut returns a structured `{ok:false, code:"..."}`
|
|
23
|
+
* result on failure (`app_not_found`, `intent_rejected`,
|
|
24
|
+
* `timeout`, `unsupported_platform`, …). When you see one,
|
|
25
|
+
* switch to `mobile_use` for the same goal. Do NOT retry
|
|
26
|
+
* the same shortcut with the same args.
|
|
27
|
+
*
|
|
28
|
+
* The prompt is **app-agnostic** by construction — no app names,
|
|
29
|
+
* no package names, no GUI path hints. The shortcuts themselves
|
|
30
|
+
* are also app-agnostic (e.g. `open_deeplink` accepts any URI).
|
|
5
31
|
*/
|
|
6
32
|
export declare const ORCHESTRATOR_SYSTEM_PROMPT: string;
|
|
@@ -2,7 +2,73 @@
|
|
|
2
2
|
* Outer orchestrator system prompts (pi-coding-agent).
|
|
3
3
|
* Per-tool details live in tool `description` / schema, not here.
|
|
4
4
|
* Select via ORCH_LANG env var: "cn" (default) | "en".
|
|
5
|
+
*
|
|
6
|
+
* Phase 2 (GUI-Shortcut Hybrid Plan, MAS-Bench 2025 SOTA):
|
|
7
|
+
* The prompt below now codifies three GENERIC heuristics for
|
|
8
|
+
* choosing between GUI primitives (`mobile_use`) and structured
|
|
9
|
+
* shortcuts (`download_to_device`, `set_clipboard`, `open_deeplink`,
|
|
10
|
+
* `find_app_package`):
|
|
11
|
+
*
|
|
12
|
+
* 1. **prefer-shortcut-when-applicable** — when a structured
|
|
13
|
+
* shortcut covers the user's need, call it before resorting
|
|
14
|
+
* to mobile_use. Shortcuts complete in O(1) ADB calls vs
|
|
15
|
+
* mobile_use's O(N) screenshot loop.
|
|
16
|
+
* 2. **avoid-misuse** — shortcuts are not free-form. Never
|
|
17
|
+
* invent shortcut arguments; respect the JSON schema. If a
|
|
18
|
+
* shortcut's pre-conditions don't hold (no URL, no installed
|
|
19
|
+
* app), fall back to mobile_use rather than fabricating an
|
|
20
|
+
* argument.
|
|
21
|
+
* 3. **shortcut-failure-fallback-to-mobile_use** — every
|
|
22
|
+
* shortcut returns a structured `{ok:false, code:"..."}`
|
|
23
|
+
* result on failure (`app_not_found`, `intent_rejected`,
|
|
24
|
+
* `timeout`, `unsupported_platform`, …). When you see one,
|
|
25
|
+
* switch to `mobile_use` for the same goal. Do NOT retry
|
|
26
|
+
* the same shortcut with the same args.
|
|
27
|
+
*
|
|
28
|
+
* The prompt is **app-agnostic** by construction — no app names,
|
|
29
|
+
* no package names, no GUI path hints. The shortcuts themselves
|
|
30
|
+
* are also app-agnostic (e.g. `open_deeplink` accepts any URI).
|
|
5
31
|
*/
|
|
32
|
+
const HEURISTICS_CN = `\
|
|
33
|
+
## Hybrid 动作空间启发式(GUI + Shortcut)
|
|
34
|
+
|
|
35
|
+
工具分两类:
|
|
36
|
+
- **GUI 原语**:\`mobile_use\` / \`ground\` / \`ui_xml\`(视觉推理,O(N) 步骤)
|
|
37
|
+
- **Shortcut**:\`download_to_device\` / \`set_clipboard\` / \`open_deeplink\` / \`find_app_package\`(结构化输入,O(1) 调用)
|
|
38
|
+
|
|
39
|
+
三条通用启发式(**与具体 App 无关**):
|
|
40
|
+
|
|
41
|
+
1. **能用 shortcut 就先用 shortcut**:
|
|
42
|
+
- 任务里出现 URL → 先 \`download_to_device\` 把文件落到设备
|
|
43
|
+
- 任务里出现长文本 / 含 emoji → 先 \`set_clipboard\` 再让 GUI 粘贴
|
|
44
|
+
- 任务里有可识别的 deeplink(\`xx://\`、\`geo:\`、\`https://\`) → 先 \`open_deeplink\`
|
|
45
|
+
- 需要包名 → 先 \`find_app_package\` 模糊查询
|
|
46
|
+
- shortcut 不成立时(无 URL、无文本、无 deeplink)→ 直接走 \`mobile_use\`
|
|
47
|
+
|
|
48
|
+
2. **不要伪造 shortcut 参数**:
|
|
49
|
+
- 严格按工具 \`parameters\` schema 调用
|
|
50
|
+
- 不知道某个参数的真实值时(如不知道目标 deeplink)→ 不要瞎猜,直接 \`mobile_use\`
|
|
51
|
+
|
|
52
|
+
3. **shortcut 失败 → fallback \`mobile_use\`**:
|
|
53
|
+
- shortcut 返回 \`{ok:false, code:"..."}\` 是结构化失败信号,不是异常
|
|
54
|
+
- 常见失败码:\`app_not_found\`(未安装目标应用)、\`intent_rejected\`(系统拒绝)、\`timeout\`、\`unsupported_platform\`(设备不是 Android 或 desktop 不支持)
|
|
55
|
+
- 看到失败码后**用同样的目标任务调用 \`mobile_use\`**,不要用同样参数重试 shortcut
|
|
56
|
+
|
|
57
|
+
4. **「发布 / 分享 / 上传」类任务的执行路径(app-agnostic, first-principles):**
|
|
58
|
+
|
|
59
|
+
当任务里同时出现 **「发 / 发布 / 分享 / 上传 / post / share / upload」** + **资源**(URL / 文件路径 / 长文本 / 媒体)时:
|
|
60
|
+
- **Intent = 主动创建新内容并把资源附加到目标 App 的内容流**,**不是**在已有内容里查找该资源
|
|
61
|
+
- 标准 GUI 路径(在任何 App 都通用):\`进入目标 App → 找到「+ / 创建 / 拍摄 / 编辑 / 发布」入口 → 选择 / 插入资源 → 写文案 → 提交\`
|
|
62
|
+
- **禁止**在已有内容流(feed / timeline / 列表 / 收件箱 / 个人主页)里 swipe / 浏览 / 查找该资源——这条路径根本不会成功,资源是你刚下载的,不在任何人的 timeline 里
|
|
63
|
+
- 反复触发 \`pre-sanity blocked: blind_swipe\` 是**强信号**:你**进错了页面**,停止 swipe,立刻调用 \`ui_xml\` 看清当前 Activity,然后 \`mobile_use\` 跳到正确的「创建入口」(如长按相机图标 / 点击右上角 + 号 / 拉起底部抽屉等),而不是继续滑动
|
|
64
|
+
|
|
65
|
+
**关于资源在相册 / picker 里的位置(强约束)**:\`Resources prepared\` 块里 \`mtime=now\` 意味着该资源是**刚刚**下载到设备的(已 trigger MediaScanner 写入 MediaStore)。Android 系统的相册 / 图片 picker / 文件管理器**默认按 \`date_added\` 倒序**排列,因此该资源一定出现在**最前面(第一张 / 第一行 / 最近列表的顶部)**。
|
|
66
|
+
|
|
67
|
+
- **MUST**: 进入 picker 后**第一个动作必须是 tap 第一项**(左上角第一个缩略图 / 列表第一行)。仅当第一项明显不是目标 MIME 类型(例如期望 image/webp 但第一项是视频缩略图)才考虑后续策略。
|
|
68
|
+
- **MUST NOT — 反搜索**:**绝不**在 picker 里通过文件名 / 关键字 / 文字搜索来找该资源。资源的文件名是机器生成的 \`beeos_<时间戳>_<hash>.<扩展名>\`,picker 的搜索功能基于平台元数据索引(人脸 / 地点 / 物体 OCR),用文件名搜索必然 0 结果。
|
|
69
|
+
- **MUST NOT — 反识图**:**不要识别图片内容**(如"这看起来是蜂巢/风景/头像")然后用关键字去搜索。**任务里的 URL 已经是 unique reference**,文件已落到 \`Resources prepared\` 块里给出的具体路径,picker 第一项就是它。"识图→搜索"是反模式,比"直接 tap 第一项"慢 10 倍且永远找不到。
|
|
70
|
+
|
|
71
|
+
`;
|
|
6
72
|
const CN = `\
|
|
7
73
|
# Android 手机自动化编排 Agent
|
|
8
74
|
|
|
@@ -12,10 +78,15 @@ const CN = `\
|
|
|
12
78
|
|
|
13
79
|
| 工具 | 适用场景 |
|
|
14
80
|
|------|----------|
|
|
15
|
-
| \`mobile_use\` |
|
|
81
|
+
| \`mobile_use\` | **GUI 主路径**。多步视觉操作交给它,内部跑 VLM 截图→推理→执行闭环。 |
|
|
16
82
|
| \`ground\` | 需要**精确像素坐标**时:补救 \`mobile_use\` 误触,或配合 adb 手动执行点击。 |
|
|
17
83
|
| \`ui_xml\` | 需要**查看控件树**(resource-id / bounds / clickable)时:调试或确认当前页面状态。 |
|
|
84
|
+
| \`download_to_device\` | 任务里带 URL,需要把文件落到设备相册 / 下载目录时使用。 |
|
|
85
|
+
| \`set_clipboard\` | 长文本 / 含 emoji 的输入:写到剪贴板再让 GUI 粘贴比直接键盘输入更可靠。 |
|
|
86
|
+
| \`open_deeplink\` | 已知 deeplink URI 时:直接跳转目标页,跳过多步导航。 |
|
|
87
|
+
| \`find_app_package\` | 通过 App 名片段查询包名(用于生成 deeplink、\`monkey\` 启动等)。 |
|
|
18
88
|
|
|
89
|
+
${HEURISTICS_CN}
|
|
19
90
|
## 调用规则
|
|
20
91
|
|
|
21
92
|
**\`mobile_use\`**
|
|
@@ -39,6 +110,46 @@ const CN = `\
|
|
|
39
110
|
## 交流
|
|
40
111
|
|
|
41
112
|
用户问你是否具备某工具(如 \`mobile_use\`)时,明确回答可否并一句话说明用途;禁止仅用「hi」等无信息回复。
|
|
113
|
+
`;
|
|
114
|
+
const HEURISTICS_EN = `\
|
|
115
|
+
## Hybrid action-space heuristics (GUI + Shortcut)
|
|
116
|
+
|
|
117
|
+
Tools split into two camps:
|
|
118
|
+
- **GUI primitives** — \`mobile_use\` / \`ground\` / \`ui_xml\` (visual reasoning, O(N) steps)
|
|
119
|
+
- **Shortcuts** — \`download_to_device\` / \`set_clipboard\` / \`open_deeplink\` / \`find_app_package\` (structured input, O(1) calls)
|
|
120
|
+
|
|
121
|
+
Three generic heuristics (**app-agnostic**):
|
|
122
|
+
|
|
123
|
+
1. **Prefer shortcuts when applicable**
|
|
124
|
+
- Task contains a URL → call \`download_to_device\` first to land the file on the device
|
|
125
|
+
- Task contains long / emoji-heavy text → use \`set_clipboard\` then have the GUI paste
|
|
126
|
+
- Task contains a recognisable deeplink URI (\`xx://\`, \`geo:\`, \`https://\`) → \`open_deeplink\` first
|
|
127
|
+
- Need a package name → \`find_app_package\` substring lookup
|
|
128
|
+
- When no shortcut applies (no URL, no text, no deeplink) → go straight to \`mobile_use\`
|
|
129
|
+
|
|
130
|
+
2. **Do not fabricate shortcut arguments**
|
|
131
|
+
- Strict adherence to each tool's \`parameters\` JSON schema
|
|
132
|
+
- When a parameter's true value is unknown (e.g. you don't know the target deeplink) → do NOT guess, call \`mobile_use\` instead
|
|
133
|
+
|
|
134
|
+
3. **Shortcut failure → fall back to \`mobile_use\`**
|
|
135
|
+
- A shortcut return of \`{ok:false, code:"..."}\` is a structured signal, not an exception
|
|
136
|
+
- Common codes: \`app_not_found\` (target app not installed), \`intent_rejected\` (OS refused), \`timeout\`, \`unsupported_platform\` (device is not Android, or desktop can't handle the asset)
|
|
137
|
+
- On failure, **call \`mobile_use\` for the same goal**. Never retry the same shortcut with the same arguments.
|
|
138
|
+
|
|
139
|
+
4. **Intent classification for "post / share / upload" tasks (app-agnostic, first-principles):**
|
|
140
|
+
|
|
141
|
+
When the task contains **"post / share / upload / 发 / 发布 / 分享 / 上传"** + **a resource** (URL / file path / long text / media):
|
|
142
|
+
- **Intent = create new content and attach the resource to the target app's content stream**, NOT find that resource inside existing content
|
|
143
|
+
- Universal GUI path (works in every app): \`enter target app → locate "+ / create / camera / compose / publish" entry → select/insert the resource → write copy → submit\`
|
|
144
|
+
- **Never** swipe through feeds / timelines / lists / inboxes / profiles searching for the resource — that path can never succeed; the resource was just downloaded and is not in anyone's timeline
|
|
145
|
+
- Repeated \`pre-sanity blocked: blind_swipe\` is a **strong signal that you are on the wrong screen**. Stop swiping, call \`ui_xml\` to read the current Activity, then \`mobile_use\` to jump to the correct "create entry" (long-press the camera icon, tap the top-right "+", pull a bottom sheet, etc.). Do NOT keep scrolling.
|
|
146
|
+
|
|
147
|
+
**Resource position inside gallery / picker (hard constraint)**: \`mtime=now\` in the \`Resources prepared\` block means the resource was **just** downloaded to the device (MediaScanner has registered it in MediaStore). Android's gallery / image picker / file manager **sorts by \`date_added\` DESC by default**, so the resource is **always at the very top — first thumbnail / first row / top of "Recent"**.
|
|
148
|
+
|
|
149
|
+
- **MUST**: Once a picker is open, the **first action must be tap the first item** (top-left thumbnail / first list row). Only consider alternatives if the first item is obviously the wrong MIME (e.g. expected image/webp but the first slot is a video).
|
|
150
|
+
- **MUST NOT — anti-search**: **NEVER** search for the resource by filename / keyword / text inside a picker. The filename is machine-generated (\`beeos_<timestamp>_<hash>.<ext>\`), and picker search uses platform metadata indices (faces / places / object OCR), so a filename query yields 0 results.
|
|
151
|
+
- **MUST NOT — anti-vision-recognition**: **Do not look at the picture and try to recognise its content** ("this looks like a beehive / landscape / avatar") and then search by keyword. The URL in the task is already a **unique reference**, and the file is at the exact path shown in \`Resources prepared\`. The picker's first item *is* it. "Recognise → search" is an anti-pattern: 10× slower than "tap first item" and it will never succeed.
|
|
152
|
+
|
|
42
153
|
`;
|
|
43
154
|
const EN = `\
|
|
44
155
|
# Android device orchestration agent
|
|
@@ -49,10 +160,15 @@ const EN = `\
|
|
|
49
160
|
|
|
50
161
|
| Tool | When to use |
|
|
51
162
|
|------|-------------|
|
|
52
|
-
| \`mobile_use\` | **
|
|
163
|
+
| \`mobile_use\` | **GUI main path.** Multi-step visual operations; runs a VLM screenshot→reason→act loop autonomously. |
|
|
53
164
|
| \`ground\` | When you need **exact pixel coords**: recover from a mis-tap, or feed coords to adb manually. |
|
|
54
165
|
| \`ui_xml\` | When you need the **view hierarchy** (resource-id / bounds / clickable): debug or verify screen state. |
|
|
166
|
+
| \`download_to_device\` | Task references a URL and the result must land on the device (image / video / pdf / apk). |
|
|
167
|
+
| \`set_clipboard\` | Long / emoji-heavy text input — clipboard + GUI paste beats keystroke-by-keystroke entry. |
|
|
168
|
+
| \`open_deeplink\` | Known deeplink URI — jump straight to the target screen and skip GUI navigation. |
|
|
169
|
+
| \`find_app_package\` | Substring-lookup of installed package names (input for deeplink generation, \`monkey\`-launch, etc.). |
|
|
55
170
|
|
|
171
|
+
${HEURISTICS_EN}
|
|
56
172
|
## Calling rules
|
|
57
173
|
|
|
58
174
|
**\`mobile_use\`**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-system-prompt.js","sourceRoot":"","sources":["../src/orchestrator-system-prompt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"orchestrator-system-prompt.js","sourceRoot":"","sources":["../src/orchestrator-system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCrB,CAAC;AAEF,MAAM,EAAE,GAAG;;;;;;;;;;;;;;;;;EAiBT,aAAa;;;;;;;;;;;;;;;;;;;;;;;;CAwBd,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCrB,CAAC;AAEF,MAAM,EAAE,GAAG;;;;;;;;;;;;;;;;;EAiBT,aAAa;;;;;;;;;;;;;;;;;;;;;;;;CAwBd,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC"}
|
package/dist/pi-context.d.ts
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import type { IMcpRuntime } from "./mcp-client/runtime.js";
|
|
31
31
|
import type { IGrounder } from "./grounding/grounder.js";
|
|
32
|
+
import type { ShortcutInvoker, ShortcutResourceFacade } from "./shortcuts/index.js";
|
|
32
33
|
export type { IGrounder };
|
|
33
34
|
export interface PiExtensionContext {
|
|
34
35
|
/**
|
|
@@ -58,6 +59,55 @@ export interface PiExtensionContext {
|
|
|
58
59
|
* result through `formatUiXmlToolOutput`.
|
|
59
60
|
*/
|
|
60
61
|
getUiXml(query?: string): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* The active shortcut invoker. The outer-LLM extension uses
|
|
64
|
+
* `getShortcutKB().registry.list()` to enumerate shortcuts (one
|
|
65
|
+
* descriptor → one outer-LLM tool) and `getShortcutKB().invoke(id, …)`
|
|
66
|
+
* to dispatch a call. Throws when no shortcut runtime is wired (e.g.
|
|
67
|
+
* tests that don't need the hybrid action space).
|
|
68
|
+
*/
|
|
69
|
+
getShortcutKB(): ShortcutInvoker;
|
|
70
|
+
/**
|
|
71
|
+
* Optional resource facade for shortcut runtime callers (chiefly
|
|
72
|
+
* `download_to_device`). Implementations return `undefined` when
|
|
73
|
+
* the bootstrap layer has not wired a resolver — in that case the
|
|
74
|
+
* shortcut surfaces `permission_denied` to the LLM, which is the
|
|
75
|
+
* intended fail-soft behaviour.
|
|
76
|
+
*
|
|
77
|
+
* The .pi extension passes the result of this accessor into the
|
|
78
|
+
* `InvokeCallerContext.resources` field on every shortcut invoke,
|
|
79
|
+
* so all shortcut implementations see the *same* facade as the
|
|
80
|
+
* AgentHost auto-trigger and consequently share the same cache.
|
|
81
|
+
*/
|
|
82
|
+
getShortcutResources?(): ShortcutResourceFacade | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* INTERNAL-ONLY. Runs a shell command on the active device through
|
|
85
|
+
* the same MCP runtime `getMcpClient()` returns. Provided as a
|
|
86
|
+
* convenience for shortcut implementations that need a one-liner
|
|
87
|
+
* exec; calling it from a `pi.registerTool({ execute })` body is a
|
|
88
|
+
* code-review failure (see comment block above).
|
|
89
|
+
*
|
|
90
|
+
* Implementations MUST honor `abortSignal` and surface a structured
|
|
91
|
+
* `{ stdout, stderr, exitCode }` so callers can map exit codes to
|
|
92
|
+
* `ShortcutErrorCode` deterministically.
|
|
93
|
+
*/
|
|
94
|
+
runShell(command: string, opts?: {
|
|
95
|
+
timeoutMs?: number;
|
|
96
|
+
abortSignal?: AbortSignal;
|
|
97
|
+
}): Promise<{
|
|
98
|
+
stdout: string;
|
|
99
|
+
stderr: string;
|
|
100
|
+
exitCode: number;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* INTERNAL-ONLY. Push raw bytes to an absolute device-local path via
|
|
104
|
+
* the MCP runtime's `fileWrite`. Used by `download_to_device` (and
|
|
105
|
+
* any future shortcut that needs to materialise a file on the
|
|
106
|
+
* device) — never wrap this in an outer-LLM tool. Throws when the
|
|
107
|
+
* active runtime does not implement `fileWrite` (e.g. legacy
|
|
108
|
+
* in-process bridges).
|
|
109
|
+
*/
|
|
110
|
+
pushFile(path: string, bytes: Buffer): Promise<void>;
|
|
61
111
|
}
|
|
62
112
|
/**
|
|
63
113
|
* Install (or clear, when `ctx` is `null`) the context that
|
package/dist/pi-context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-context.js","sourceRoot":"","sources":["../src/pi-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;
|
|
1
|
+
{"version":3,"file":"pi-context.js","sourceRoot":"","sources":["../src/pi-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AA+HH,IAAI,MAAM,GAA8B,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAA8B;IAClE,MAAM,GAAG,GAAG,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,8FAA8F;YAC5F,6CAA6C,CAChD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/ports/device.d.ts
CHANGED
|
@@ -50,4 +50,22 @@ export interface IDevice {
|
|
|
50
50
|
install(path: string): Promise<void>;
|
|
51
51
|
/** Run an arbitrary shell command and return stdout. */
|
|
52
52
|
shell(command: string): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve a device-local well-known directory for a given content
|
|
55
|
+
* MIME type. Used by the Resource Resolution Layer to land
|
|
56
|
+
* downloaded URL payloads in a directory the device's gallery /
|
|
57
|
+
* file picker / installer naturally surfaces.
|
|
58
|
+
*
|
|
59
|
+
* Implementations:
|
|
60
|
+
* - Android: `/sdcard/Pictures` (image/*), `/sdcard/Movies`
|
|
61
|
+
* (video/*), `/sdcard/Music` (audio/*), `/sdcard/Download`
|
|
62
|
+
* (application/*, text/*).
|
|
63
|
+
* - Desktop: `~/Pictures`, `~/Movies`, `~/Music`, `~/Downloads`.
|
|
64
|
+
* `application/vnd.android.package-archive` rejects with
|
|
65
|
+
* `unsupported_platform` since desktop has no APK installer.
|
|
66
|
+
*
|
|
67
|
+
* The path returned is absolute, with no trailing slash. Callers
|
|
68
|
+
* append the filename themselves with `/`.
|
|
69
|
+
*/
|
|
70
|
+
resolveWellKnownDir(mime: string): Promise<string>;
|
|
53
71
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Context Augmenter — inject "Resources prepared" preamble into
|
|
3
|
+
* the original task without prescribing any GUI path.
|
|
4
|
+
*
|
|
5
|
+
* Output format (pinned by unit tests; do NOT change without updating
|
|
6
|
+
* `resource-augmented-prompt-contains-source-url-and-resource-identity`
|
|
7
|
+
* and the corresponding fixture):
|
|
8
|
+
*
|
|
9
|
+
* Resources prepared:
|
|
10
|
+
* - <remotePath> (<mime>, <humanSize>, mtime=now, source URL: <sourceUrl>)
|
|
11
|
+
* - …
|
|
12
|
+
*
|
|
13
|
+
* The original task references the resource(s) above by URL. The
|
|
14
|
+
* resource(s) have been made available at the path(s) shown.
|
|
15
|
+
*
|
|
16
|
+
* Resource usage rules (anti-pattern guard, app-agnostic):
|
|
17
|
+
* - Do NOT search by filename or recognised content keyword. …
|
|
18
|
+
* - The resource is at the top of any default-newest-first picker. …
|
|
19
|
+
* - Do NOT recognise the resource visually then query its content. …
|
|
20
|
+
*
|
|
21
|
+
* Original task: <verbatim original task>
|
|
22
|
+
*
|
|
23
|
+
* Design constraints derived from MAS-Bench / Mobile-Agent-V3.5 / Anthropic
|
|
24
|
+
* Computer Use prompt-engineering research:
|
|
25
|
+
*
|
|
26
|
+
* - Identity-explicit: every line in `Resources prepared` MUST link
|
|
27
|
+
* a source identifier (URL) to a device-local path. This is the
|
|
28
|
+
* exact constraint that keeps the VLM from confusing two visually
|
|
29
|
+
* identical resources.
|
|
30
|
+
* - GUI-neutral (positive direction): NEVER suggest "tap the first
|
|
31
|
+
* photo", "open the gallery", or any other concrete GUI step.
|
|
32
|
+
* Resource preparation is an orthogonal concern from GUI execution;
|
|
33
|
+
* coupling them collapses the layered design.
|
|
34
|
+
* - GUI-neutral (negative direction allowed): we DO inject anti-pattern
|
|
35
|
+
* guards — "do not search by filename", "do not recognise content
|
|
36
|
+
* visually then search". These are NOT GUI steps (they tell the
|
|
37
|
+
* model what *not* to do, regardless of which app it lands in),
|
|
38
|
+
* and empirically the outer LLM ignores the equivalent rules in
|
|
39
|
+
* system prompt because user-message priority dominates. Pinning
|
|
40
|
+
* the guard alongside the resource line keeps it at task-priority.
|
|
41
|
+
* - Preserve the original task verbatim: the VLM's reasoning is
|
|
42
|
+
* calibrated against the user's exact wording. Re-paraphrasing
|
|
43
|
+
* subtly biases the agent.
|
|
44
|
+
*/
|
|
45
|
+
import type { ResolvedAsset, TaskContextAugmenter } from "./types.js";
|
|
46
|
+
export declare class ResourceContextAugmenter implements TaskContextAugmenter {
|
|
47
|
+
augment(originalTask: string, assets: readonly ResolvedAsset[]): string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Context Augmenter — inject "Resources prepared" preamble into
|
|
3
|
+
* the original task without prescribing any GUI path.
|
|
4
|
+
*
|
|
5
|
+
* Output format (pinned by unit tests; do NOT change without updating
|
|
6
|
+
* `resource-augmented-prompt-contains-source-url-and-resource-identity`
|
|
7
|
+
* and the corresponding fixture):
|
|
8
|
+
*
|
|
9
|
+
* Resources prepared:
|
|
10
|
+
* - <remotePath> (<mime>, <humanSize>, mtime=now, source URL: <sourceUrl>)
|
|
11
|
+
* - …
|
|
12
|
+
*
|
|
13
|
+
* The original task references the resource(s) above by URL. The
|
|
14
|
+
* resource(s) have been made available at the path(s) shown.
|
|
15
|
+
*
|
|
16
|
+
* Resource usage rules (anti-pattern guard, app-agnostic):
|
|
17
|
+
* - Do NOT search by filename or recognised content keyword. …
|
|
18
|
+
* - The resource is at the top of any default-newest-first picker. …
|
|
19
|
+
* - Do NOT recognise the resource visually then query its content. …
|
|
20
|
+
*
|
|
21
|
+
* Original task: <verbatim original task>
|
|
22
|
+
*
|
|
23
|
+
* Design constraints derived from MAS-Bench / Mobile-Agent-V3.5 / Anthropic
|
|
24
|
+
* Computer Use prompt-engineering research:
|
|
25
|
+
*
|
|
26
|
+
* - Identity-explicit: every line in `Resources prepared` MUST link
|
|
27
|
+
* a source identifier (URL) to a device-local path. This is the
|
|
28
|
+
* exact constraint that keeps the VLM from confusing two visually
|
|
29
|
+
* identical resources.
|
|
30
|
+
* - GUI-neutral (positive direction): NEVER suggest "tap the first
|
|
31
|
+
* photo", "open the gallery", or any other concrete GUI step.
|
|
32
|
+
* Resource preparation is an orthogonal concern from GUI execution;
|
|
33
|
+
* coupling them collapses the layered design.
|
|
34
|
+
* - GUI-neutral (negative direction allowed): we DO inject anti-pattern
|
|
35
|
+
* guards — "do not search by filename", "do not recognise content
|
|
36
|
+
* visually then search". These are NOT GUI steps (they tell the
|
|
37
|
+
* model what *not* to do, regardless of which app it lands in),
|
|
38
|
+
* and empirically the outer LLM ignores the equivalent rules in
|
|
39
|
+
* system prompt because user-message priority dominates. Pinning
|
|
40
|
+
* the guard alongside the resource line keeps it at task-priority.
|
|
41
|
+
* - Preserve the original task verbatim: the VLM's reasoning is
|
|
42
|
+
* calibrated against the user's exact wording. Re-paraphrasing
|
|
43
|
+
* subtly biases the agent.
|
|
44
|
+
*/
|
|
45
|
+
const HEADER = "Resources prepared:";
|
|
46
|
+
const FOOTER = "The original task references the resource(s) above by URL. The resource(s) have been made available at the path(s) shown.";
|
|
47
|
+
/**
|
|
48
|
+
* Anti-pattern guard injected next to the resource line so it inherits
|
|
49
|
+
* the task's priority (system-prompt-level rules get overridden by the
|
|
50
|
+
* user task at runtime; we observed this empirically with AutoGLM and
|
|
51
|
+
* other open-weights orchestrators).
|
|
52
|
+
*
|
|
53
|
+
* The guard is **app-agnostic** and **does not prescribe a GUI step**:
|
|
54
|
+
* it states facts about how the resource is identified, plus negative
|
|
55
|
+
* rules about which retrieval strategies will fail. The model is still
|
|
56
|
+
* free to choose the GUI path.
|
|
57
|
+
*/
|
|
58
|
+
const RESOURCE_USAGE_RULES = [
|
|
59
|
+
"Resource usage rules (these prepared resources, app-agnostic):",
|
|
60
|
+
"- The resource's identity is the PATH + source URL above, NOT its visual content. Do not recognise it visually (faces, objects, scenery) and then search by keyword.",
|
|
61
|
+
"- Each resource was written to the device just now (mtime=now) and the platform media index has been updated. In any media picker / gallery / file manager that uses the platform's default newest-first ordering, the resource is at the very top of the listing.",
|
|
62
|
+
"- Do NOT search inside a picker by the filename — it is machine-generated (`beeos_<ts>_<hash>.<ext>`) and will not match. Do NOT search by recognised content keywords either — picker search uses the platform's metadata index (faces / places / OCR), which the freshly-added resource is unlikely to have entries in yet.",
|
|
63
|
+
"- Do NOT browse feeds, timelines, profiles, or inboxes looking for this resource — it is not in anyone's content stream; you just placed it on the device.",
|
|
64
|
+
].join("\n");
|
|
65
|
+
export class ResourceContextAugmenter {
|
|
66
|
+
augment(originalTask, assets) {
|
|
67
|
+
if (!assets || assets.length === 0)
|
|
68
|
+
return originalTask;
|
|
69
|
+
const lines = [];
|
|
70
|
+
lines.push(HEADER);
|
|
71
|
+
for (const a of assets) {
|
|
72
|
+
const sizeStr = formatBytes(a.sizeBytes);
|
|
73
|
+
lines.push(`- ${a.remotePath} (${a.mime}, ${sizeStr}, mtime=now, ${formatSource(a)})`);
|
|
74
|
+
}
|
|
75
|
+
lines.push("");
|
|
76
|
+
lines.push(FOOTER);
|
|
77
|
+
lines.push("");
|
|
78
|
+
lines.push(RESOURCE_USAGE_RULES);
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push(`Original task: ${originalTask}`);
|
|
81
|
+
return lines.join("\n");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Render the `source:` clause of a resource line.
|
|
86
|
+
*
|
|
87
|
+
* For pasted URL refs we keep the original wording (`source URL: <url>`)
|
|
88
|
+
* — the URL is the user's natural identifier and several existing test
|
|
89
|
+
* pins / heuristics anchor on this exact phrase.
|
|
90
|
+
*
|
|
91
|
+
* For uploaded files (`beeos-file://<fileId>`) the presigned download
|
|
92
|
+
* URL must NEVER reach the LLM context — it carries a SigV4 token that
|
|
93
|
+
* (a) leaks into logs, (b) is short-lived and meaningless to the model.
|
|
94
|
+
* We surface the opaque `beeos-file://<fileId>` identifier instead and
|
|
95
|
+
* tag it as `uploaded file` so the model understands it cannot be
|
|
96
|
+
* fetched again from a public URL.
|
|
97
|
+
*/
|
|
98
|
+
function formatSource(a) {
|
|
99
|
+
if (a.ref.kind === "beeos-file") {
|
|
100
|
+
return `source: uploaded file beeos-file://${a.ref.fileId}`;
|
|
101
|
+
}
|
|
102
|
+
const url = a.sourceUrl || (a.ref.kind === "url" ? a.ref.url : "");
|
|
103
|
+
return `source URL: ${url}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Format a byte count as a short human string (1024-based, two
|
|
107
|
+
* significant digits). Pinned in tests so the augmented preamble is
|
|
108
|
+
* stable across locales / Node versions.
|
|
109
|
+
*/
|
|
110
|
+
function formatBytes(bytes) {
|
|
111
|
+
if (!isFinite(bytes) || bytes < 0)
|
|
112
|
+
return "0B";
|
|
113
|
+
if (bytes < 1024)
|
|
114
|
+
return `${bytes}B`;
|
|
115
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
116
|
+
let value = bytes / 1024;
|
|
117
|
+
let unitIndex = 0;
|
|
118
|
+
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
119
|
+
value /= 1024;
|
|
120
|
+
unitIndex++;
|
|
121
|
+
}
|
|
122
|
+
// Two significant digits, no trailing zero.
|
|
123
|
+
const formatted = value < 10 ? value.toFixed(1) : Math.round(value).toString();
|
|
124
|
+
return `${formatted}${units[unitIndex]}`;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=augmenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augmenter.js","sourceRoot":"","sources":["../../src/resources/augmenter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,MAAM,MAAM,GAAG,qBAAqB,CAAC;AACrC,MAAM,MAAM,GACV,2HAA2H,CAAC;AAE9H;;;;;;;;;;GAUG;AACH,MAAM,oBAAoB,GAAG;IAC3B,gEAAgE;IAChE,sKAAsK;IACtK,oQAAoQ;IACpQ,+TAA+T;IAC/T,4JAA4J;CAC7J,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,OAAO,wBAAwB;IACnC,OAAO,CAAC,YAAoB,EAAE,MAAgC;QAC5D,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,YAAY,CAAC;QACxD,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACzC,KAAK,CAAC,IAAI,CACR,KAAK,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,IAAI,KAAK,OAAO,gBAAgB,YAAY,CAAC,CAAC,CAAC,GAAG,CAC3E,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf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I,CAAC;QACd,SAAS,EAAE,CAAC;IACd,CAAC;IACD,4CAA4C;IAC5C,MAAM,SAAS,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/E,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Resolution Cache — keyed by SHA-256(url), value is a
|
|
3
|
+
* `ResolvedAsset`. Cache hits MUST validate the device-side file is
|
|
4
|
+
* still there before reuse.
|
|
5
|
+
*
|
|
6
|
+
* Why an in-memory cache and not skill memory?
|
|
7
|
+
* - Skill memory is per-app GUI sequences (see ADR 001). Resolutions
|
|
8
|
+
* are app-agnostic and have a much shorter natural lifetime
|
|
9
|
+
* (TTL=7d) — different concern, different data shape.
|
|
10
|
+
* - The cache lives for the AgentHost lifetime; we deliberately do
|
|
11
|
+
* NOT persist it to disk for Phase 1. A future plan may add an FS
|
|
12
|
+
* mirror under `~/.beeos/device-agent/resources-cache/` once the
|
|
13
|
+
* access pattern stabilises.
|
|
14
|
+
*
|
|
15
|
+
* Cache validation:
|
|
16
|
+
* When a hit is returned, the consumer is REQUIRED to call
|
|
17
|
+
* `validateAlive(asset, mcp)` to confirm the device-side file still
|
|
18
|
+
* exists (operators occasionally clear `/sdcard/Pictures/` between
|
|
19
|
+
* tasks). On a missing file, the cache entry is invalidated and the
|
|
20
|
+
* resolution is re-run.
|
|
21
|
+
*/
|
|
22
|
+
import type { IMcpRuntime } from "../mcp-client/runtime.js";
|
|
23
|
+
import type { ResolvedAsset } from "./types.js";
|
|
24
|
+
export interface ResourceCacheOptions {
|
|
25
|
+
/** Per-entry TTL in ms. Default 7 days. */
|
|
26
|
+
ttlMs?: number;
|
|
27
|
+
/** Soft cap on stored bytes (sum of `sizeBytes`). Default 500 MB. */
|
|
28
|
+
maxBytes?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class ResourceResolutionCache {
|
|
31
|
+
private readonly ttlMs;
|
|
32
|
+
private readonly maxBytes;
|
|
33
|
+
private readonly entries;
|
|
34
|
+
constructor(opts?: ResourceCacheOptions);
|
|
35
|
+
/** Stable cache key — SHA-256 of the URL. */
|
|
36
|
+
static keyForUrl(url: string): string;
|
|
37
|
+
get(key: string, now?: number): ResolvedAsset | undefined;
|
|
38
|
+
set(key: string, asset: ResolvedAsset, now?: number): void;
|
|
39
|
+
invalidate(key: string): void;
|
|
40
|
+
size(): number;
|
|
41
|
+
totalBytes(): number;
|
|
42
|
+
/** Test helper — visible-for-spec, not for production callers. */
|
|
43
|
+
__debug(): {
|
|
44
|
+
size: number;
|
|
45
|
+
totalBytes: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Verify the device-side file referenced by a cached entry is still
|
|
49
|
+
* present. Returns `true` iff `ls <remotePath>` succeeds with non-
|
|
50
|
+
* empty output (or an explicit success exit code).
|
|
51
|
+
*
|
|
52
|
+
* MUST be called by every consumer that hits the cache before
|
|
53
|
+
* returning the asset to upstream code.
|
|
54
|
+
*/
|
|
55
|
+
static validateAlive(asset: ResolvedAsset, mcp: IMcpRuntime): Promise<boolean>;
|
|
56
|
+
private evictIfNeeded;
|
|
57
|
+
}
|