@beeos-ai/device-agent 0.15.0 → 0.16.1

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.
Files changed (240) hide show
  1. package/README.md +35 -0
  2. package/dist/adapters/agent-gateway-client.d.ts +6 -68
  3. package/dist/adapters/agent-gateway-client.js +7 -67
  4. package/dist/adapters/agent-gateway-client.js.map +1 -1
  5. package/dist/adapters/device-compat.d.ts +1 -2
  6. package/dist/adapters/device-compat.js +2 -52
  7. package/dist/adapters/device-compat.js.map +1 -1
  8. package/dist/agent-runtime/action-guard.js +92 -17
  9. package/dist/agent-runtime/action-guard.js.map +1 -1
  10. package/dist/agent-runtime/adapters/base.d.ts +13 -9
  11. package/dist/agent-runtime/adapters/base.js.map +1 -1
  12. package/dist/agent-runtime/adapters/general-flash.d.ts +3 -3
  13. package/dist/agent-runtime/adapters/general-flash.js +2 -2
  14. package/dist/agent-runtime/adapters/general-flash.js.map +1 -1
  15. package/dist/agent-runtime/adapters/native-tools.d.ts +56 -0
  16. package/dist/agent-runtime/adapters/native-tools.js +416 -0
  17. package/dist/agent-runtime/adapters/native-tools.js.map +1 -0
  18. package/dist/agent-runtime/adapters/openai.d.ts +1 -2
  19. package/dist/agent-runtime/adapters/openai.js +5 -5
  20. package/dist/agent-runtime/adapters/openai.js.map +1 -1
  21. package/dist/agent-runtime/adapters/pro.d.ts +7 -37
  22. package/dist/agent-runtime/adapters/pro.js +7 -249
  23. package/dist/agent-runtime/adapters/pro.js.map +1 -1
  24. package/dist/agent-runtime/advanced/app-card.js +9 -2
  25. package/dist/agent-runtime/advanced/app-card.js.map +1 -1
  26. package/dist/agent-runtime/advanced/subgoal-verifier.d.ts +1 -0
  27. package/dist/agent-runtime/advanced/subgoal-verifier.js +30 -36
  28. package/dist/agent-runtime/advanced/subgoal-verifier.js.map +1 -1
  29. package/dist/agent-runtime/advanced/task-state.js +4 -9
  30. package/dist/agent-runtime/advanced/task-state.js.map +1 -1
  31. package/dist/agent-runtime/agent-runner.d.ts +2 -11
  32. package/dist/agent-runtime/agent-runner.js +69 -34
  33. package/dist/agent-runtime/agent-runner.js.map +1 -1
  34. package/dist/agent-runtime/core.d.ts +24 -46
  35. package/dist/agent-runtime/core.js +161 -228
  36. package/dist/agent-runtime/core.js.map +1 -1
  37. package/dist/agent-runtime/execution-checks.d.ts +40 -0
  38. package/dist/agent-runtime/execution-checks.js +133 -0
  39. package/dist/agent-runtime/execution-checks.js.map +1 -0
  40. package/dist/agent-runtime/execution-mode.d.ts +1 -8
  41. package/dist/agent-runtime/execution-mode.js +10 -30
  42. package/dist/agent-runtime/execution-mode.js.map +1 -1
  43. package/dist/agent-runtime/feedback.d.ts +4 -28
  44. package/dist/agent-runtime/feedback.js +4 -26
  45. package/dist/agent-runtime/feedback.js.map +1 -1
  46. package/dist/agent-runtime/form-prerequisites.d.ts +3 -0
  47. package/dist/agent-runtime/form-prerequisites.js +52 -0
  48. package/dist/agent-runtime/form-prerequisites.js.map +1 -0
  49. package/dist/agent-runtime/index.d.ts +2 -8
  50. package/dist/agent-runtime/index.js +2 -8
  51. package/dist/agent-runtime/index.js.map +1 -1
  52. package/dist/agent-runtime/{modes/orchestrator → knowledge}/app-guide.d.ts +1 -1
  53. package/dist/agent-runtime/{modes/orchestrator → knowledge}/app-guide.js +1 -1
  54. package/dist/agent-runtime/knowledge/app-guide.js.map +1 -0
  55. package/dist/agent-runtime/models/base.d.ts +3 -1
  56. package/dist/agent-runtime/models/client.js +30 -9
  57. package/dist/agent-runtime/models/client.js.map +1 -1
  58. package/dist/agent-runtime/models/reasoning.d.ts +10 -0
  59. package/dist/agent-runtime/models/reasoning.js +29 -0
  60. package/dist/agent-runtime/models/reasoning.js.map +1 -0
  61. package/dist/agent-runtime/models/runtime-registry.d.ts +2 -1
  62. package/dist/agent-runtime/models/runtime-registry.js +4 -2
  63. package/dist/agent-runtime/models/runtime-registry.js.map +1 -1
  64. package/dist/agent-runtime/models/vlm/autoglm.js +6 -2
  65. package/dist/agent-runtime/models/vlm/autoglm.js.map +1 -1
  66. package/dist/agent-runtime/models/vlm/base.js +1 -12
  67. package/dist/agent-runtime/models/vlm/base.js.map +1 -1
  68. package/dist/agent-runtime/models/vlm/index.d.ts +0 -4
  69. package/dist/agent-runtime/models/vlm/index.js +0 -4
  70. package/dist/agent-runtime/models/vlm/index.js.map +1 -1
  71. package/dist/agent-runtime/modes/hybrid/index.d.ts +2 -12
  72. package/dist/agent-runtime/modes/hybrid/index.js +10 -27
  73. package/dist/agent-runtime/modes/hybrid/index.js.map +1 -1
  74. package/dist/agent-runtime/modes/hybrid/planner/base.d.ts +4 -44
  75. package/dist/agent-runtime/modes/hybrid/planner/base.js +3 -21
  76. package/dist/agent-runtime/modes/hybrid/planner/base.js.map +1 -1
  77. package/dist/agent-runtime/modes/hybrid/planner/llm-planner.d.ts +1 -1
  78. package/dist/agent-runtime/modes/hybrid/planner/llm-planner.js +9 -6
  79. package/dist/agent-runtime/modes/hybrid/planner/llm-planner.js.map +1 -1
  80. package/dist/agent-runtime/modes/hybrid/planner/prompts.d.ts +1 -17
  81. package/dist/agent-runtime/modes/hybrid/planner/prompts.js +65 -160
  82. package/dist/agent-runtime/modes/hybrid/planner/prompts.js.map +1 -1
  83. package/dist/agent-runtime/plan-executor.d.ts +13 -14
  84. package/dist/agent-runtime/plan-executor.js +236 -122
  85. package/dist/agent-runtime/plan-executor.js.map +1 -1
  86. package/dist/agent-runtime/pro-memory.js +1 -1
  87. package/dist/agent-runtime/pro-memory.js.map +1 -1
  88. package/dist/agent-runtime/pro-operator.js +8 -2
  89. package/dist/agent-runtime/pro-operator.js.map +1 -1
  90. package/dist/agent-runtime/pro-perception.d.ts +1 -0
  91. package/dist/agent-runtime/pro-perception.js +4 -2
  92. package/dist/agent-runtime/pro-perception.js.map +1 -1
  93. package/dist/agent-runtime/pro-target-check.d.ts +2 -2
  94. package/dist/agent-runtime/pro-target-check.js +102 -17
  95. package/dist/agent-runtime/pro-target-check.js.map +1 -1
  96. package/dist/agent-runtime/prompts/operator.d.ts +2 -0
  97. package/dist/agent-runtime/prompts/operator.js +69 -0
  98. package/dist/agent-runtime/prompts/operator.js.map +1 -0
  99. package/dist/agent-runtime/prompts/verification.d.ts +2 -0
  100. package/dist/agent-runtime/prompts/verification.js +52 -0
  101. package/dist/agent-runtime/prompts/verification.js.map +1 -0
  102. package/dist/agent-runtime/skills/replay.d.ts +4 -14
  103. package/dist/agent-runtime/skills/replay.js +46 -27
  104. package/dist/agent-runtime/skills/replay.js.map +1 -1
  105. package/dist/agent-runtime/tool-batch.d.ts +10 -0
  106. package/dist/agent-runtime/tool-batch.js +51 -0
  107. package/dist/agent-runtime/tool-batch.js.map +1 -0
  108. package/dist/agent-runtime/visual-state.d.ts +2 -0
  109. package/dist/agent-runtime/visual-state.js +24 -0
  110. package/dist/agent-runtime/visual-state.js.map +1 -0
  111. package/dist/agent-runtime/vlm.d.ts +1 -1
  112. package/dist/agent-runtime/vlm.js +1 -1
  113. package/dist/api.js +3 -1
  114. package/dist/api.js.map +1 -1
  115. package/dist/app/agent-host.js +6 -2
  116. package/dist/app/agent-host.js.map +1 -1
  117. package/dist/app/multi-device-host.js +4 -5
  118. package/dist/app/multi-device-host.js.map +1 -1
  119. package/dist/app/session-manager.d.ts +3 -45
  120. package/dist/app/session-manager.js +8 -9
  121. package/dist/app/session-manager.js.map +1 -1
  122. package/dist/bootstrap.js +25 -84
  123. package/dist/bootstrap.js.map +1 -1
  124. package/dist/config/loader.js +12 -1
  125. package/dist/config/loader.js.map +1 -1
  126. package/dist/config/schema.d.ts +7 -2
  127. package/dist/config/schema.js +8 -5
  128. package/dist/config/schema.js.map +1 -1
  129. package/dist/core/abortable-read.d.ts +1 -0
  130. package/dist/core/abortable-read.js +24 -0
  131. package/dist/core/abortable-read.js.map +1 -0
  132. package/dist/device/ui-xml.d.ts +4 -0
  133. package/dist/device/ui-xml.js +35 -13
  134. package/dist/device/ui-xml.js.map +1 -1
  135. package/dist/fleet/adapters/process/node-process-manager.d.ts +2 -1
  136. package/dist/fleet/adapters/process/node-process-manager.js +11 -19
  137. package/dist/fleet/adapters/process/node-process-manager.js.map +1 -1
  138. package/dist/inbound/acp/handlers/models.js +11 -8
  139. package/dist/inbound/acp/handlers/models.js.map +1 -1
  140. package/dist/inbound/acp/handlers/session.d.ts +1 -4
  141. package/dist/inbound/acp/handlers/session.js +3 -6
  142. package/dist/inbound/acp/handlers/session.js.map +1 -1
  143. package/dist/inbound/bma/agent.d.ts +47 -0
  144. package/dist/inbound/bma/agent.js +130 -0
  145. package/dist/inbound/bma/agent.js.map +1 -0
  146. package/dist/inbound/bma/command.d.ts +15 -0
  147. package/dist/inbound/bma/command.js +98 -0
  148. package/dist/inbound/bma/command.js.map +1 -0
  149. package/dist/inbound/bma/model-proxy.d.ts +22 -0
  150. package/dist/inbound/bma/model-proxy.js +130 -0
  151. package/dist/inbound/bma/model-proxy.js.map +1 -0
  152. package/dist/inbound/cli/main.js +12 -2
  153. package/dist/inbound/cli/main.js.map +1 -1
  154. package/dist/inbound/cli/run-artifacts.js +16 -7
  155. package/dist/inbound/cli/run-artifacts.js.map +1 -1
  156. package/dist/inbound/cli/run-command.d.ts +7 -0
  157. package/dist/inbound/cli/run-command.js +37 -29
  158. package/dist/inbound/cli/run-command.js.map +1 -1
  159. package/dist/index.d.ts +1 -10
  160. package/dist/index.js +1 -6
  161. package/dist/index.js.map +1 -1
  162. package/dist/mcp-client/autospawn.d.ts +7 -9
  163. package/dist/mcp-client/autospawn.js +16 -12
  164. package/dist/mcp-client/autospawn.js.map +1 -1
  165. package/dist/mcp-client/client.d.ts +6 -3
  166. package/dist/mcp-client/client.js +31 -13
  167. package/dist/mcp-client/client.js.map +1 -1
  168. package/dist/mcp-client/runtime.d.ts +5 -2
  169. package/dist/plugins/agent-sync/index.d.ts +32 -17
  170. package/dist/plugins/agent-sync/index.js +223 -232
  171. package/dist/plugins/agent-sync/index.js.map +1 -1
  172. package/dist/plugins/message-bus/inbound.d.ts +0 -32
  173. package/dist/plugins/message-bus/inbound.js +3 -0
  174. package/dist/plugins/message-bus/inbound.js.map +1 -1
  175. package/dist/plugins/message-bus/ms-channel-notifier.d.ts +1 -0
  176. package/dist/plugins/message-bus/ms-channel-notifier.js +16 -8
  177. package/dist/plugins/message-bus/ms-channel-notifier.js.map +1 -1
  178. package/dist/plugins/native-chat/deadline.d.ts +2 -0
  179. package/dist/plugins/native-chat/deadline.js +16 -0
  180. package/dist/plugins/native-chat/deadline.js.map +1 -0
  181. package/dist/plugins/native-chat/index.d.ts +46 -0
  182. package/dist/plugins/native-chat/index.js +331 -0
  183. package/dist/plugins/native-chat/index.js.map +1 -0
  184. package/dist/plugins/native-chat/reply-stream.d.ts +50 -0
  185. package/dist/plugins/native-chat/reply-stream.js +81 -0
  186. package/dist/plugins/native-chat/reply-stream.js.map +1 -0
  187. package/dist/plugins/native-chat/session-notifier.d.ts +16 -0
  188. package/dist/plugins/native-chat/session-notifier.js +130 -0
  189. package/dist/plugins/native-chat/session-notifier.js.map +1 -0
  190. package/dist/ports/agent-core.d.ts +2 -0
  191. package/dist/ports/agent-host.d.ts +2 -0
  192. package/dist/ports/agent-host.js +0 -21
  193. package/dist/ports/agent-host.js.map +1 -1
  194. package/dist/ports/device.d.ts +0 -1
  195. package/dist/ports/device.js +0 -1
  196. package/dist/ports/device.js.map +1 -1
  197. package/dist/runtime-authority/device-prompt.gen.d.ts +54 -0
  198. package/dist/runtime-authority/device-prompt.gen.js +19 -0
  199. package/dist/runtime-authority/device-prompt.gen.js.map +1 -0
  200. package/dist/types.d.ts +10 -0
  201. package/dist/types.js +1 -0
  202. package/dist/types.js.map +1 -1
  203. package/package.json +7 -5
  204. package/dist/adapters/device-desktop.d.ts +0 -49
  205. package/dist/adapters/device-desktop.js +0 -132
  206. package/dist/adapters/device-desktop.js.map +0 -1
  207. package/dist/agent-runtime/factory.d.ts +0 -24
  208. package/dist/agent-runtime/factory.js +0 -25
  209. package/dist/agent-runtime/factory.js.map +0 -1
  210. package/dist/agent-runtime/models/vlm/guiowl.d.ts +0 -1
  211. package/dist/agent-runtime/models/vlm/guiowl.js +0 -249
  212. package/dist/agent-runtime/models/vlm/guiowl.js.map +0 -1
  213. package/dist/agent-runtime/models/vlm/maiui.d.ts +0 -1
  214. package/dist/agent-runtime/models/vlm/maiui.js +0 -142
  215. package/dist/agent-runtime/models/vlm/maiui.js.map +0 -1
  216. package/dist/agent-runtime/models/vlm/qwen38.d.ts +0 -1
  217. package/dist/agent-runtime/models/vlm/qwen38.js +0 -241
  218. package/dist/agent-runtime/models/vlm/qwen38.js.map +0 -1
  219. package/dist/agent-runtime/models/vlm/qwenvl.d.ts +0 -1
  220. package/dist/agent-runtime/models/vlm/qwenvl.js +0 -202
  221. package/dist/agent-runtime/models/vlm/qwenvl.js.map +0 -1
  222. package/dist/agent-runtime/modes/orchestrator/app-guide.js.map +0 -1
  223. package/dist/agent-runtime/modes/orchestrator/index.d.ts +0 -41
  224. package/dist/agent-runtime/modes/orchestrator/index.js +0 -218
  225. package/dist/agent-runtime/modes/orchestrator/index.js.map +0 -1
  226. package/dist/agent-runtime/modes/orchestrator/prompt.d.ts +0 -7
  227. package/dist/agent-runtime/modes/orchestrator/prompt.js +0 -53
  228. package/dist/agent-runtime/modes/orchestrator/prompt.js.map +0 -1
  229. package/dist/agent-runtime/reflection.d.ts +0 -100
  230. package/dist/agent-runtime/reflection.js +0 -241
  231. package/dist/agent-runtime/reflection.js.map +0 -1
  232. package/dist/agent-runtime/reflectors/action-reflector.d.ts +0 -97
  233. package/dist/agent-runtime/reflectors/action-reflector.js +0 -234
  234. package/dist/agent-runtime/reflectors/action-reflector.js.map +0 -1
  235. package/dist/agent-runtime/reflectors/policy.d.ts +0 -56
  236. package/dist/agent-runtime/reflectors/policy.js +0 -111
  237. package/dist/agent-runtime/reflectors/policy.js.map +0 -1
  238. package/dist/agent-runtime/reflectors/trajectory-reflector.d.ts +0 -93
  239. package/dist/agent-runtime/reflectors/trajectory-reflector.js +0 -224
  240. package/dist/agent-runtime/reflectors/trajectory-reflector.js.map +0 -1
@@ -43,13 +43,13 @@ export interface ModelUsage {
43
43
  * - `"skipped"` — pre-action sanity check vetoed dispatch
44
44
  * - `"terminal"` — `done` / `fail` / `call_for_user` short-circuited the loop
45
45
  *
46
- * Used by reflectors and the planner replan path to decide whether to
47
- * fire follow-up reasoning. Optional for backwards compatibility — older
46
+ * Used by execution checks and the planner replan path to decide whether to
47
+ * recover or replan. Optional for backwards compatibility — older
48
48
  * test fixtures predate the field.
49
49
  */
50
50
  export type StepOutcome = "ok" | "act_failed" | "predict_failed" | "skipped" | "terminal";
51
51
  export interface StepHistory {
52
- /** Task-local raw observation evidence, not actor narration. */
52
+ /** Task-local observed evidence (UI facts may be compacted), not actor narration. */
53
53
  evidence?: {
54
54
  uiDump?: string;
55
55
  screenshotB64?: string;
@@ -70,20 +70,22 @@ export interface StepHistory {
70
70
  /**
71
71
  * Outcome of this step's action dispatch. See {@link StepOutcome}.
72
72
  * Optional so existing test fixtures keep validating; new code paths
73
- * (reflectors, replan context) MUST populate it.
73
+ * (execution checks, replan context) MUST populate it.
74
74
  */
75
75
  actionResult?: StepOutcome;
76
+ /** False only when dispatch was prevented; undefined preserves legacy history. */
77
+ actionDispatched?: boolean;
76
78
  /**
77
79
  * Adapter-reported confidence in `[0, 1]` for this step's prediction.
78
80
  * Copied from `Prediction.confidence`. Optional — adapters that can't
79
- * estimate confidence (no logprob support) leave it undefined and the
80
- * reflector falls back to its whitelist-only trigger.
81
+ * estimate confidence (no logprob support) leave it undefined.
82
+ * Confidence alone is not task-completion evidence.
81
83
  */
82
84
  confidence?: number;
83
85
  /**
84
86
  * Populated only when `actionResult === "act_failed"` — the MCP error
85
- * message / status. Reflectors splice this into their prompt so the
86
- * grounder can see *why* the previous step failed on retry.
87
+ * message / status, so the operator and replan context retain the
88
+ * actual reason the previous step failed.
87
89
  */
88
90
  actErrorMessage?: string;
89
91
  /**
@@ -93,7 +95,7 @@ export interface StepHistory {
93
95
  * adapters that consume `uiDump` produce a non-empty value, and pure-
94
96
  * vision flows leave it `undefined`.
95
97
  *
96
- * Used by `HierarchicalReflector.maybeBlockAction` to detect "repeat
98
+ * Used by `ExecutionChecks.maybeBlockAction` to detect "repeat
97
99
  * action with no screen progress" via equality with
98
100
  * {@link screenStateHashAfter}.
99
101
  */
@@ -108,6 +110,8 @@ export interface StepHistory {
108
110
  screenStateHashAfter?: string;
109
111
  }
110
112
  export interface Prediction {
113
+ /** Validated ordered native calls; never execute concurrently on a device. */
114
+ actions?: Action[];
111
115
  toolResult?: unknown;
112
116
  /** Predicted next action. Use `done` / `fail` / `call_for_user` to stop. */
113
117
  action: Action;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/agent-runtime/adapters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoLH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,OAA4C,EAAE;IAE9C,OAAO;QACL,MAAM;QACN,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;QAC/B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG;QACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE;QACxD,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;QACnC,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/agent-runtime/adapters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwLH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,OAA4C,EAAE;IAE9C,OAAO;QACL,MAAM;QACN,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,EAAE;QAC/B,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,IAAI,GAAG;QACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE;QACxD,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;QACnC,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
- import { ProModelAdapter } from "./pro.js";
1
+ import { NativeToolOperator } from "./native-tools.js";
2
2
  /** General models share the native tool transport, without Pro orchestration. */
3
- export declare class GeneralFlashAdapter extends ProModelAdapter {
3
+ export declare class GeneralFlashAdapter extends NativeToolOperator {
4
4
  readonly retryObservation = true;
5
- constructor(opts: ConstructorParameters<typeof ProModelAdapter>[0]);
5
+ constructor(opts: ConstructorParameters<typeof NativeToolOperator>[0]);
6
6
  }
@@ -1,6 +1,6 @@
1
- import { ProModelAdapter } from "./pro.js";
1
+ import { NativeToolOperator } from "./native-tools.js";
2
2
  /** General models share the native tool transport, without Pro orchestration. */
3
- export class GeneralFlashAdapter extends ProModelAdapter {
3
+ export class GeneralFlashAdapter extends NativeToolOperator {
4
4
  retryObservation = true;
5
5
  constructor(opts) {
6
6
  super({ ...opts, profile: "flash" });
@@ -1 +1 @@
1
- {"version":3,"file":"general-flash.js","sourceRoot":"","sources":["../../../src/agent-runtime/adapters/general-flash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,iFAAiF;AACjF,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAC7C,gBAAgB,GAAG,IAAI,CAAC;IACjC,YAAY,IAAsD;QAChE,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;CACF"}
1
+ {"version":3,"file":"general-flash.js","sourceRoot":"","sources":["../../../src/agent-runtime/adapters/general-flash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,iFAAiF;AACjF,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IAChD,gBAAgB,GAAG,IAAI,CAAC;IACjC,YAAY,IAAyD;QACnE,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,56 @@
1
+ import { type Action, type Observation } from "@beeos-ai/device-common";
2
+ import type { ModelClient } from "../models/base.js";
3
+ import { type ImageTransport } from "../models/image/transport.js";
4
+ import type { McpToolSchema } from "../../mcp-client/runtime.js";
5
+ import { type IModelAdapter, type PredictOptions, type StepHistory } from "./base.js";
6
+ export interface ProCall {
7
+ id: string;
8
+ name: string;
9
+ arguments: string;
10
+ }
11
+ export declare function proCalls(action: Action): ProCall[];
12
+ export declare function proTools(tools: McpToolSchema[], observation: Observation): McpToolSchema[];
13
+ export declare class NativeToolOperator implements IModelAdapter {
14
+ readonly name: string;
15
+ readonly nativeTools = true;
16
+ readonly consumesUiDump = true;
17
+ readonly observationProfile: {
18
+ readonly defaultMode: "hybrid";
19
+ readonly supportedModes: readonly ["vision", "xml", "hybrid"];
20
+ };
21
+ readonly modelName: string;
22
+ private readonly client;
23
+ private readonly transport;
24
+ private readonly clients;
25
+ private readonly profile;
26
+ private guard?;
27
+ private readonly guardOptions;
28
+ private readonly actionGuardEnabled;
29
+ constructor(opts: {
30
+ client?: ModelClient;
31
+ modelName?: string;
32
+ apiKey?: string;
33
+ baseUrl?: string;
34
+ imageTransport?: ImageTransport;
35
+ profile?: "pro" | "flash";
36
+ actionGuardEnabled?: boolean;
37
+ });
38
+ supportsEnv(env: Observation["env"]): boolean;
39
+ checkAction(action: Action, observation: Observation, intent: string, signal?: AbortSignal): Promise<import("../action-guard.js").ActionVerdict>;
40
+ predictAction(observation: Observation, history: StepHistory[], opts?: PredictOptions): Promise<{
41
+ toolResult: {
42
+ ok: boolean;
43
+ executed: boolean;
44
+ error: {};
45
+ } | undefined;
46
+ actions: Action[];
47
+ action: Action;
48
+ rationale: string;
49
+ confidence: number;
50
+ usage: import("./base.js").ModelUsage;
51
+ rawResponse: string;
52
+ modelInput?: unknown;
53
+ }>;
54
+ }
55
+ /** @deprecated Use NativeToolOperator; this is an execution protocol, not a model-specific adapter. */
56
+ export { NativeToolOperator as NativeToolAdapter };
@@ -0,0 +1,416 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { MAX_TOOL_CALLS_PER_TURN, MAX_CLICK_SEQUENCE_LENGTH } from "@beeos-ai/device-common";
3
+ import { OpenAIClient } from "../models/client.js";
4
+ import { DataUrlTransport } from "../models/image/transport.js";
5
+ import { makePrediction } from "./base.js";
6
+ import { observationToScreenInfo } from "./openai.js";
7
+ import { proFallbackModels, withProFallback } from "../models/pro-fallback.js";
8
+ import { buildProFrame } from "../pro-perception.js";
9
+ import { ActionGuard } from "../action-guard.js";
10
+ import { FLASH_SYSTEM, PRO_SYSTEM as SYSTEM } from "../prompts/operator.js";
11
+ const WRITES = new Set(["tap", "click_sequence", "click", "double_tap", "double_click", "long_press", "drag", "swipe", "scroll", "type", "key", "back", "home", "launch_app"]);
12
+ const READS = new Set(["list_apps", "device_info", "list_elements"]);
13
+ const BOUNDED_READS = new Set(["take_note", "search_memory", "list_state", "find_target", "list_elements", "list_apps", "device_info"]);
14
+ export function proCalls(action) {
15
+ return action.payload?._proCalls ?? [];
16
+ }
17
+ function hasBrokenFinish(calls) {
18
+ return (calls ?? []).some(call => {
19
+ if (call.name !== "finish")
20
+ return false;
21
+ try {
22
+ const message = JSON.parse(call.arguments).message;
23
+ // Orphan wrapper tags also appear in incomplete native finish messages.
24
+ // Ask for the missing answer, rather than stripping the tag and accepting it.
25
+ if (typeof message !== "string")
26
+ return false;
27
+ const closing = message.match(/<\/(parameter|invoke|tool_call|function_call|p|div|span|li|ul|ol|h[1-6])>\s*$/i);
28
+ return !!closing && !new RegExp(`<${closing[1]}(?:\\s|>)`, "i").test(message);
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ });
34
+ }
35
+ function localTool(name, description, properties, required) {
36
+ return { name, description, inputSchema: { type: "object", properties, required, additionalProperties: false } };
37
+ }
38
+ export function proTools(tools, observation) {
39
+ const hasTextIndex = !!observation.uiDump || (Array.isArray(observation.extra?.ocrText) && observation.extra.ocrText.length > 0);
40
+ const mobileTap = observation.env === "mobile" && tools.some((t) => t.name === "tap" && t.inputSchema);
41
+ const mobileDoubleTap = observation.env === "mobile" && tools.some((t) => t.name === "double_tap" && t.inputSchema);
42
+ const selected = tools.filter((t) => t.inputSchema && (WRITES.has(t.name) || READS.has(t.name)))
43
+ // The shared catalog also advertises desktop click; Android dispatches tap.
44
+ .filter((t) => !mobileTap || t.name !== "click")
45
+ .filter((t) => !mobileDoubleTap || t.name !== "double_click")
46
+ .filter((t) => t.name !== "list_elements" || !!observation.uiDump)
47
+ .map((t) => {
48
+ const schema = structuredClone(t.inputSchema);
49
+ const properties = { ...(schema.properties ?? {}) };
50
+ delete properties.device;
51
+ if (WRITES.has(t.name))
52
+ properties.intent = { type: "string", maxLength: 500,
53
+ description: "Brief intended operation and target label grounded in the CURRENT screen; used only for independent action verification." };
54
+ const description = observation.env === "mobile" && t.name === "launch_app"
55
+ ? `${t.description ?? "Launch an app."} Pass the requested app's package OR display name directly. If the display name fails to resolve, identify its package with list_apps; do not substitute an unrelated launcher icon.`
56
+ : observation.env === "mobile" && t.name === "type"
57
+ ? `${t.description ?? "Type text."} On Android ADB this REPLACES all text in the focused field (clears it first). Focus the field, then pass the complete desired value; do not manually select/delete its old text or split the replacement into chunks. Use submit=false unless submission is intended.`
58
+ : t.description;
59
+ return { ...t, description, inputSchema: { ...schema, properties,
60
+ required: (schema.required ?? []).filter((k) => k !== "device"), additionalProperties: false } };
61
+ });
62
+ return [...selected,
63
+ localTool("wait", "Wait for a transition, then observe again.", { durationMs: { type: "integer", minimum: 0, maximum: 30000 } }, ["durationMs"]),
64
+ localTool("take_note", "Save task-local facts and processed item identifiers.", { note: { type: "string", maxLength: 4000 } }, ["note"]),
65
+ localTool("search_memory", "Search only this task's prior observations and notes.", { query: { type: "string", maxLength: 500 } }, ["query"]),
66
+ localTool("list_state", "Read this task's observed list traversal state; seen does not mean processed.", {}, []),
67
+ ...(hasTextIndex ? [localTool("find_target", "Find text in the current XML/OCR index. No matches do not prove absence in the screenshot.", { query: { type: "string", maxLength: 500 } }, ["query"])] : []),
68
+ localTool("finish", "Complete, fail, or request user help. Write a concise user-facing result grounded in observed evidence. " +
69
+ "Include ALL requested deliverables (e.g. title, author, every requested summary point or sample price), not just a claim that reading/searching finished. Use plain text or Markdown, never HTML/XML wrapper tags. " +
70
+ "Preserve requested facts, values and blockers. Do not include sub-task numbering, frame IDs, XML/resource IDs, coordinates or dispatch logs. " +
71
+ "Store technical evidence in take_note instead; do not claim independent verification.", {
72
+ status: { type: "string", enum: ["done", "fail", "call_for_user"] }, message: { type: "string", maxLength: 4000,
73
+ description: "Brief user-facing outcome in the user's language, including requested data. Not a technical evidence dump or per-step completion report." },
74
+ }, ["status", "message"]),
75
+ ];
76
+ }
77
+ /** Validate the server-advertised JSON Schema before constructing a device action. */
78
+ function validate(value, schema, path = "arguments") {
79
+ if (schema.anyOf) {
80
+ for (const branch of schema.anyOf) {
81
+ try {
82
+ validate(value, branch, path);
83
+ return;
84
+ }
85
+ catch { /* try next union branch */ }
86
+ }
87
+ throw new Error(`${path}: no matching schema branch`);
88
+ }
89
+ const type = schema.type;
90
+ if (type === "object") {
91
+ if (!value || typeof value !== "object" || Array.isArray(value))
92
+ throw new Error(`${path}: object required`);
93
+ const object = value;
94
+ const properties = schema.properties ?? {};
95
+ for (const key of schema.required ?? [])
96
+ if (!(key in object))
97
+ throw new Error(`${path}.${key}: required`);
98
+ for (const [key, v] of Object.entries(object)) {
99
+ if (!Object.hasOwn(properties, key))
100
+ throw new Error(`${path}.${key}: unknown argument`);
101
+ validate(v, properties[key], `${path}.${key}`);
102
+ }
103
+ }
104
+ else if (type === "array") {
105
+ if (!Array.isArray(value))
106
+ throw new Error(`${path}: array required`);
107
+ if (typeof schema.minItems === "number" && value.length < schema.minItems || typeof schema.maxItems === "number" && value.length > schema.maxItems)
108
+ throw new Error(`${path}: invalid array length`);
109
+ for (const v of value)
110
+ validate(v, schema.items, path);
111
+ }
112
+ else if (type === "number" || type === "integer") {
113
+ if (typeof value !== "number" || !Number.isFinite(value) || (type === "integer" && !Number.isInteger(value)))
114
+ throw new Error(`${path}: ${type} required`);
115
+ if (typeof schema.minimum === "number" && value < schema.minimum || typeof schema.maximum === "number" && value > schema.maximum || typeof schema.exclusiveMinimum === "number" && value <= schema.exclusiveMinimum)
116
+ throw new Error(`${path}: out of range`);
117
+ }
118
+ else if (type && typeof value !== type)
119
+ throw new Error(`${path}: ${type} required`);
120
+ if (schema.enum && !schema.enum.includes(value))
121
+ throw new Error(`${path}: invalid enum`);
122
+ if (typeof value === "string" && typeof schema.maxLength === "number" && value.length > schema.maxLength)
123
+ throw new Error(`${path}: too long`);
124
+ }
125
+ export class NativeToolOperator {
126
+ name;
127
+ nativeTools = true;
128
+ consumesUiDump = true;
129
+ observationProfile = { defaultMode: "hybrid", supportedModes: ["vision", "xml", "hybrid"] };
130
+ modelName;
131
+ client;
132
+ transport;
133
+ clients;
134
+ profile;
135
+ guard;
136
+ guardOptions;
137
+ actionGuardEnabled;
138
+ constructor(opts) {
139
+ this.actionGuardEnabled = opts.actionGuardEnabled ?? false;
140
+ this.profile = opts.profile ?? "pro";
141
+ this.name = this.profile === "flash" ? "openai:general-flash" : "openai:pro-tools";
142
+ this.client = opts.client ?? new OpenAIClient({ ...opts, adapter: "general", maxRetries: 0 });
143
+ this.modelName = this.client.modelName;
144
+ this.guardOptions = { modelName: this.modelName, baseUrl: opts.baseUrl, apiKey: opts.apiKey };
145
+ this.clients = new Map([[this.modelName, this.client]]);
146
+ if (this.profile === "pro" && opts.apiKey && opts.baseUrl) {
147
+ for (const modelName of proFallbackModels(this.modelName, "operator", opts.baseUrl)) {
148
+ this.clients.set(modelName, new OpenAIClient({ apiKey: opts.apiKey, baseUrl: opts.baseUrl, modelName, adapter: "general", maxRetries: 0 }));
149
+ }
150
+ }
151
+ this.transport = opts.imageTransport ?? new DataUrlTransport();
152
+ }
153
+ supportsEnv(env) { return env === "mobile"; }
154
+ async checkAction(action, observation, intent, signal) {
155
+ signal?.throwIfAborted();
156
+ if (!this.actionGuardEnabled) {
157
+ return { decision: "allow", reason: "Model-based ActionGuard disabled by local configuration",
158
+ usage: { inputTokens: 0, outputTokens: 0 } };
159
+ }
160
+ try {
161
+ this.guard ??= new ActionGuard(this.guardOptions);
162
+ return await this.guard.check(action, observation, intent, signal);
163
+ }
164
+ catch (error) {
165
+ signal?.throwIfAborted();
166
+ return { decision: "handoff", reason: `Safety checker unavailable: ${String(error)}`,
167
+ usage: { inputTokens: 0, outputTokens: 0 } };
168
+ }
169
+ }
170
+ async predictAction(observation, history, opts = {}) {
171
+ opts.signal?.throwIfAborted();
172
+ // Semantic safety review is per-action. Keep the fast-path sequence
173
+ // unavailable when independent review is required; never silently bypass it.
174
+ const definitions = proTools(opts.mcpTools ?? [], observation)
175
+ .filter(tool => !this.actionGuardEnabled || tool.name !== "click_sequence");
176
+ const frame = buildProFrame(observation);
177
+ if (definitions.some((t) => t.name === "tap") && frame.targets.length > 0) {
178
+ definitions.push(localTool("tap_target", "Tap an exact complete target ID from the CURRENT observation index; copy it including the frame prefix. Never abbreviate it to X12 or reuse a previous frame's ID.", { targetId: {
179
+ type: "string", enum: frame.targets.map((target) => target.id),
180
+ description: "Opaque complete ID including frame prefix, copied exactly from the CURRENT TARGET INDEX.",
181
+ },
182
+ intent: { type: "string", maxLength: 500 } }, ["targetId"]));
183
+ }
184
+ const readLimit = history.length >= 2 && history.slice(-2).every((entry) => entry.action && proCalls(entry.action)[0] && BOUNDED_READS.has(proCalls(entry.action)[0].name));
185
+ if (readLimit) {
186
+ for (let i = definitions.length - 1; i >= 0; i--) {
187
+ if (BOUNDED_READS.has(definitions[i].name))
188
+ definitions.splice(i, 1);
189
+ }
190
+ }
191
+ const messages = [
192
+ { role: "system", content: this.profile === "flash" ? FLASH_SYSTEM : SYSTEM },
193
+ { role: "user", content: `Original task for this entire run: ${observation.task}\nContinue from the recorded actions and observations below; this is NOT a new assignment on each turn.` },
194
+ ];
195
+ const replayHistory = history.slice(this.profile === "flash" ? -16 : -32);
196
+ // Never cut an assistant multi-call envelope away from its first outcome.
197
+ while (replayHistory[0]?.action?.payload._proBatchId &&
198
+ history.find((h) => h.action?.payload._proBatchId === replayHistory[0]?.action?.payload._proBatchId) !== replayHistory[0])
199
+ replayHistory.shift();
200
+ // Keep task-local visual evidence without replaying an unbounded image history.
201
+ // During navigation, competing historical screens can mis-ground taps.
202
+ // Replay milestone images after Home (final-state audit), not during taps.
203
+ const replayMilestoneImages = this.profile === "flash" && history.at(-1)?.action?.type === "home";
204
+ const visualHistory = new Set(replayMilestoneImages
205
+ ? replayHistory.filter((entry) => entry.evidence?.screenshotB64).slice(-3) : []);
206
+ const replayed = new Set();
207
+ const replayModels = new Map();
208
+ for (const entry of replayHistory) {
209
+ if (!entry.action)
210
+ continue;
211
+ const calls = proCalls(entry.action);
212
+ if (!calls.length)
213
+ continue;
214
+ if (visualHistory.has(entry)) {
215
+ const previous = await observationToScreenInfo({ ...observation, uiDump: undefined,
216
+ screenshotB64: entry.evidence.screenshotB64 }, this.transport);
217
+ opts.signal?.throwIfAborted();
218
+ if (previous.imageRef)
219
+ messages.push({ role: "user", content: [
220
+ { type: "text", text: `Historical observation BEFORE step ${entry.stepIdx}; not the current screen. Use only to assess prior milestones, never for current coordinates or target IDs.` },
221
+ { type: "image_url", image_url: { url: previous.imageRef.url } },
222
+ ] });
223
+ }
224
+ const batchId = entry.action.payload._proBatchId;
225
+ if (batchId && replayed.has(batchId))
226
+ continue;
227
+ if (batchId)
228
+ replayed.add(batchId);
229
+ const batchCalls = entry.action.payload._proBatchCalls ?? calls;
230
+ messages.push({ role: "assistant", content: String(entry.action.payload?._proContent || entry.rationale),
231
+ ...(typeof entry.action.payload?._proReasoningContent === "string"
232
+ ? { reasoning_content: entry.action.payload._proReasoningContent } : {}), tool_calls: batchCalls.map((c) => ({
233
+ id: c.id, type: "function", function: { name: c.name, arguments: c.arguments },
234
+ })) });
235
+ replayModels.set(messages.at(-1), String(entry.action.payload._proModel ?? this.modelName));
236
+ for (const call of batchCalls) {
237
+ const result = replayHistory.find((item) => item.action && item.action.payload._proBatchId === batchId && proCalls(item.action).some((c) => c.id === call.id));
238
+ messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify(result
239
+ ? result.toolResult ?? { outcome: result.actionResult, error: result.actErrorMessage,
240
+ executed: result.actionDispatched !== false, instruction: "Dispatch is not proof of task completion." }
241
+ : { ok: false, executed: false, error: "Batch stopped before this call; reobserve before retrying." }).slice(0, 12000) });
242
+ }
243
+ }
244
+ const screen = await observationToScreenInfo(observation, this.transport);
245
+ opts.signal?.throwIfAborted();
246
+ // Use a resolution-independent visual contract, never infer the coordinate
247
+ // system from a model's numeric values. XML IDs still resolve on the device.
248
+ const imageCoordinates = !!screen.imageSize;
249
+ if (imageCoordinates) {
250
+ if (!(screen.width > 0 && screen.height > 0))
251
+ throw new Error("Device dimensions unavailable for Vision coordinates");
252
+ messages[0].content = this.profile === "flash" ? FLASH_SYSTEM.replace("Otherwise use absolute DEVICE pixel coordinates grounded in the supplied screenshot, never resized image coordinates or guesses.", "Otherwise use normalized 0-1000 coordinates on the CURRENT screenshot: x=0 is left, x=1000 right, y=0 top, y=1000 bottom. Runtime converts to device pixels. Never send screenshot/device pixels.") : SYSTEM.replace("Coordinates are absolute DEVICE pixels, not normalized coordinates or resized image pixels.", "Coordinate tools use normalized 0-1000 coordinates on the CURRENT screenshot: x=0 left, x=1000 right, y=0 top, y=1000 bottom. Runtime converts to device pixels. Use tap_target IDs for XML controls. Never send screenshot/device pixels.");
253
+ }
254
+ const coordinateAxes = { x: "x", y: "y", x1: "x", y1: "y", x2: "x", y2: "y" };
255
+ if (imageCoordinates) {
256
+ for (const tool of definitions) {
257
+ if (!WRITES.has(tool.name))
258
+ continue;
259
+ const properties = tool.name === "click_sequence"
260
+ ? tool.inputSchema.properties.points.items.properties
261
+ : tool.inputSchema.properties;
262
+ for (const [key, axis] of Object.entries(coordinateAxes)) {
263
+ if (!properties[key])
264
+ continue;
265
+ properties[key] = { ...properties[key], minimum: 0,
266
+ maximum: 1000,
267
+ description: `Normalized CURRENT screenshot ${axis} coordinate in [0,1000]; 0=${axis === "x" ? "left" : "top"}, 1000=${axis === "x" ? "right" : "bottom"}. NOT pixels.` };
268
+ }
269
+ }
270
+ }
271
+ const tools = definitions.map((t) => ({ type: "function", function: {
272
+ name: t.name, description: t.description, parameters: t.inputSchema,
273
+ } }));
274
+ const content = [{ type: "text", text: `CURRENT observation for the SAME ongoing task. Prior successful actions and saved observations remain valid; continue from their outcomes, do not restart the original instructions.\nTask context: ${JSON.stringify(observation.extra?.taskContext ?? null)}\nDevice pixels: ${screen.width}x${screen.height}\nCurrent app: ${screen.currentApp}\n` +
275
+ (imageCoordinates ? `CURRENT screenshot pixels: ${screen.imageSize.width}x${screen.imageSize.height}. Coordinate tools use NORMALIZED 0-1000 on BOTH axes, NOT pixels. Center is (500,500); bottom-right is (1000,1000). Do not scale them yourself; runtime converts them. XML bounds and indexed centers remain DEVICE pixels: use tap_target with their ID, never copy those coordinates into tap. This overrides the default device-coordinate policy.\n`
276
+ : "") +
277
+ (screen.uiXml ? `UI hierarchy (absolute device bounds):\n${screen.uiXml.slice(0, 16000)}\n` : "No XML available.\n") +
278
+ (opts.contextInstruction ?? "") +
279
+ (readLimit ? "\nRead-only query limit reached. Use the supplied current screen and prior tool results to act, wait for a transition, or finish honestly; do not query the same information again. Safety checks still apply." : "") }];
280
+ if (screen.imageRef)
281
+ content.push({ type: "image_url", image_url: { url: screen.imageRef.url } });
282
+ messages.push({ role: "user", content });
283
+ let selectedModel = this.modelName;
284
+ const response = await withProFallback([...this.clients.keys()], async (model) => {
285
+ selectedModel = model;
286
+ // Reasoning state is model-specific; actual tool outcomes remain portable.
287
+ const input = messages.map((message) => {
288
+ if (message.role !== "assistant")
289
+ return message;
290
+ const source = replayModels.get(message) ?? this.modelName;
291
+ if (source === model)
292
+ return message;
293
+ const { reasoning_content: _reasoning, ...portable } = message;
294
+ return portable;
295
+ });
296
+ const client = this.clients.get(model);
297
+ const options = { signal: opts.signal, nativeTools: tools, onTextDelta: opts.hooks?.onText, maxTokens: 8192 };
298
+ const first = await client.request(input, options);
299
+ opts.signal?.throwIfAborted();
300
+ if (first.finishReason === "content_filter")
301
+ throw new Error(`${this.profile} operator: model response was blocked by the provider; no actions executed`);
302
+ const brokenFinish = hasBrokenFinish(first.toolCalls);
303
+ if (first.toolCalls?.length && first.finishReason !== "length" && !brokenFinish)
304
+ return first;
305
+ // Correct model output once on the SAME observation. Never dispatch text
306
+ // or replay an earlier phone action to recover a missing native call.
307
+ const corrected = await client.request([...input, {
308
+ role: "user", content: (brokenFinish
309
+ ? "Your finish.message ended with an orphan XML/HTML wrapper tag and was NOT accepted. Return a clean, COMPLETE user-facing answer containing every requested fact and summary point in finish.message, not only a claim that the task finished. Use plain text or Markdown, no XML/HTML wrapper tags. "
310
+ : first.finishReason === "length"
311
+ ? "Your last response exhausted its output budget and dispatched NO action. Return a short native tool call without repeating analysis. "
312
+ : "Your last response had no native tool call and dispatched NO action. ") +
313
+ "Earlier successful actions remain valid. Use the current screen above and return native tool calls now. " +
314
+ "If the assignment is already satisfied, call finish; do not repeat completed device actions. " +
315
+ "Do not repeat analysis or emit textual commands.",
316
+ }], { ...options, maxTokens: first.finishReason === "length" ? 16384 : options.maxTokens });
317
+ return { ...corrected, usage: {
318
+ inputTokens: (first.usage?.inputTokens ?? 0) + (corrected.usage?.inputTokens ?? 0),
319
+ outputTokens: (first.usage?.outputTokens ?? 0) + (corrected.usage?.outputTokens ?? 0),
320
+ } };
321
+ }, opts.signal);
322
+ opts.signal?.throwIfAborted();
323
+ if (response.finishReason === "length") {
324
+ throw new Error(`${this.profile} operator: model ${selectedModel} exhausted its output budget (finish_reason=length); truncated native tool calls were NOT executed`);
325
+ }
326
+ if (response.finishReason === "content_filter")
327
+ throw new Error(`${this.profile} operator: model response was blocked by the provider; no actions executed`);
328
+ if (hasBrokenFinish(response.toolCalls))
329
+ throw new Error(`${this.profile} operator: final answer contains an orphan XML/HTML wrapper after one correction; completion was NOT accepted`);
330
+ const calls = response.toolCalls ?? [];
331
+ const protocolError = !calls.length ? "model returned no native tool calls after one correction; textual commands are not executed"
332
+ : calls.length > MAX_TOOL_CALLS_PER_TURN ? `model exceeded the ${MAX_TOOL_CALLS_PER_TURN}-call batch limit`
333
+ : calls.some((c) => typeof c.id !== "string" || !c.id.trim()) ? "native tool call ID is missing"
334
+ : new Set(calls.map((c) => c.id)).size !== calls.length ? "native tool call IDs are duplicated" : undefined;
335
+ if (protocolError)
336
+ throw new Error(`${this.profile} operator: ${protocolError}; no actions executed`);
337
+ const actions = [];
338
+ const batchId = randomUUID();
339
+ for (const call of calls) {
340
+ let action;
341
+ let rejected;
342
+ try {
343
+ // Preserve every call ID, including rejected and subsequently skipped calls.
344
+ const spec = definitions.find((t) => t.name === call.name);
345
+ if (!spec)
346
+ throw new Error("Tool is not available for this device/observation mode");
347
+ const rawArgs = JSON.parse(call.arguments);
348
+ validate(rawArgs, spec.inputSchema);
349
+ const args = structuredClone(rawArgs);
350
+ if (imageCoordinates && call.name === "click_sequence") {
351
+ args.points = args.points.map(p => ({
352
+ x: Math.min(screen.width - 1, Math.round(p.x * screen.width / 1000)),
353
+ y: Math.min(screen.height - 1, Math.round(p.y * screen.height / 1000)),
354
+ }));
355
+ }
356
+ if (imageCoordinates && WRITES.has(call.name)) {
357
+ for (const [key, axis] of Object.entries(coordinateAxes)) {
358
+ if (typeof args[key] !== "number")
359
+ continue;
360
+ const size = axis === "x" ? screen.width : screen.height;
361
+ args[key] = Math.min(size - 1, Math.round(args[key] * size / 1000));
362
+ }
363
+ }
364
+ // Intent is actor narration, never a backend argument or permission.
365
+ const deviceCall = WRITES.has(call.name) || call.name === "tap_target";
366
+ const intent = deviceCall && typeof args.intent === "string" ? args.intent : undefined;
367
+ if (deviceCall)
368
+ delete args.intent;
369
+ if (call.name === "tap_target") {
370
+ const target = frame.targets.find((target) => target.id === args.targetId);
371
+ if (!target)
372
+ throw new Error("Target ID is absent or stale; use the current target index");
373
+ const x = Math.floor((target.bounds[0] + target.bounds[2]) / 2);
374
+ const y = Math.floor((target.bounds[1] + target.bounds[3]) / 2);
375
+ action = { type: "tap", target: { kind: "point", x, y }, payload: { _coordSystem: "absolute", _proMcp: "tap", _proDispatchArgs: { x, y },
376
+ ...(target.xmlPath ? { _proTarget: { identity: target.identity, bounds: target.bounds, xmlPath: target.xmlPath } } : {}),
377
+ ...(intent ? { _proIntent: intent } : {}) } };
378
+ }
379
+ else if (call.name === "click_sequence") {
380
+ const points = args.points;
381
+ if (points.length < 2 || points.length > MAX_CLICK_SEQUENCE_LENGTH || points.some((p) => p.x >= observation.screenW || p.y >= observation.screenH))
382
+ throw new Error("Sequence requires 2-4 in-screen pixel coordinates");
383
+ action = { type: "tap", target: { kind: "point", ...points[0] }, payload: { _coordSystem: "absolute", _proSequence: points, ...(intent ? { _proIntent: intent } : {}) } };
384
+ }
385
+ else if (call.name === "finish")
386
+ action = { type: args.status, payload: { message: args.message } };
387
+ else if (call.name === "wait")
388
+ action = { type: "wait", payload: args };
389
+ else if (!WRITES.has(call.name))
390
+ action = { type: "take_note", payload: { ...args, _proLocal: call.name } };
391
+ else {
392
+ const type = call.name === "double_tap" ? "double_click" : call.name;
393
+ action = { type, payload: { ...args, _coordSystem: "absolute", _proMcp: call.name, _proDispatchArgs: args,
394
+ ...(intent ? { _proIntent: intent } : {}) } };
395
+ if (typeof args.x === "number" && typeof args.y === "number")
396
+ action.target = { kind: "point", x: args.x, y: args.y };
397
+ if (typeof args.x1 === "number")
398
+ action.target = { kind: "box", x1: args.x1, y1: args.y1, x2: args.x2, y2: args.y2 };
399
+ }
400
+ }
401
+ catch (e) {
402
+ rejected = e.message;
403
+ action = { type: "take_note", payload: { _proRejected: rejected } };
404
+ }
405
+ action.payload = { ...action.payload, _proModel: selectedModel, _proCalls: [call], _proBatchCalls: calls, _proBatchId: batchId, _proContent: response.rawContent,
406
+ ...(response.reasoningContent ? { _proReasoningContent: response.reasoningContent } : {}) };
407
+ actions.push(action);
408
+ }
409
+ return { ...makePrediction(actions[0], { rationale: response.thinking || String(actions[0].payload?._proIntent ?? ""), rawResponse: JSON.stringify(response), modelInput: messages,
410
+ usage: response.usage ?? { inputTokens: 0, outputTokens: 0 },
411
+ }), toolResult: actions[0].payload._proRejected ? { ok: false, executed: false, error: actions[0].payload._proRejected } : undefined, actions };
412
+ }
413
+ }
414
+ /** @deprecated Use NativeToolOperator; this is an execution protocol, not a model-specific adapter. */
415
+ export { NativeToolOperator as NativeToolAdapter };
416
+ //# sourceMappingURL=native-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-tools.js","sourceRoot":"","sources":["../../../src/agent-runtime/adapters/native-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA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