@xopcai/xopc 0.0.368 → 0.0.370

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 (516) hide show
  1. package/README.md +59 -174
  2. package/README.zh-CN.md +59 -174
  3. package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js +131 -0
  4. package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js +30 -0
  5. package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js +252 -0
  6. package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js +16 -0
  7. package/dist/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js +66 -0
  8. package/dist/browser-ext/_locales/en/messages.json +30 -1
  9. package/dist/browser-ext/_locales/zh_CN/messages.json +30 -1
  10. package/dist/browser-ext/dist/assets/{auth-beGtbLPS.js → page-context-BeworyNB.js} +1331 -1355
  11. package/dist/browser-ext/dist/assets/{sidepanel-BT0ojEzG.css → sidepanel-Ccl0eSa1.css} +43 -0
  12. package/dist/browser-ext/dist/background.js +680 -182
  13. package/dist/browser-ext/dist/sidepanel.html +2 -2
  14. package/dist/browser-ext/dist/sidepanel.js +393 -194
  15. package/dist/browser-ext/manifest.json +2 -8
  16. package/dist/extensions/telegram/xopc.extension.json +1 -1
  17. package/dist/gateway/static/root/assets/{activity-store-D9ZMh5ZR.js → activity-store-BQ3PMp2q.js} +1 -1
  18. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bj3rvcTm.js → agent-avatar-dicebear-C61i1QbX.js} +1 -1
  19. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-0fCR1DHx.js +1 -0
  20. package/dist/gateway/static/root/assets/agent-plugin-dialog-Di99mUTT.js +1 -0
  21. package/dist/gateway/static/root/assets/agents-BRZZmYH_.js +66 -0
  22. package/dist/gateway/static/root/assets/{agents-admin-api-B5QDepbW.js → agents-admin-api-HBZvVyzF.js} +1 -1
  23. package/dist/gateway/static/root/assets/{app-management-settings-panel-2rTEtB_X.js → app-management-settings-panel-noqqxkds.js} +1 -1
  24. package/dist/gateway/static/root/assets/{appearance-settings-BPVBS80k.js → appearance-settings-DG8QN0gR.js} +1 -1
  25. package/dist/gateway/static/root/assets/{apps-page-1FuKlZYP.js → apps-page-CgiyzFYo.js} +1 -1
  26. package/dist/gateway/static/root/assets/{archive-plugin-BbT1O7oK.js → archive-plugin-BO3I9zRP.js} +1 -1
  27. package/dist/gateway/static/root/assets/{automations-page-DjwP_h8h.js → automations-page-CgAcRFDS.js} +1 -1
  28. package/dist/gateway/static/root/assets/automations-workspace-BIkxIpab.js +6 -0
  29. package/dist/gateway/static/root/assets/{binary-plugins-gS7Wg68v.js → binary-plugins-gFD7vH9R.js} +1 -1
  30. package/dist/gateway/static/root/assets/{block-editor-DbwMaivP.js → block-editor-B1VE-jAe.js} +2 -2
  31. package/dist/gateway/static/root/assets/browser-automation-inputs-DxRoKFun.js +1 -0
  32. package/dist/gateway/static/root/assets/browser-automations-page-CIjyMS6f.js +3 -0
  33. package/dist/gateway/static/root/assets/browser-settings-page-BMAivBfp.js +3 -0
  34. package/dist/gateway/static/root/assets/{capabilities-Lswa0hv8.js → capabilities-CY4SiHcP.js} +1 -1
  35. package/dist/gateway/static/root/assets/{capabilities-Dd1PZRQw.js → capabilities-gjQtMhKu.js} +1 -1
  36. package/dist/gateway/static/root/assets/capabilities-page-DRdcfo68.js +2 -0
  37. package/dist/gateway/static/root/assets/{capabilities-settings-panel-DTHR1DrJ.js → capabilities-settings-panel-ZuL6pWjM.js} +4 -4
  38. package/dist/gateway/static/root/assets/{capability-header-actions-494dnJsj.js → capability-header-actions-D0GC1FEv.js} +1 -1
  39. package/dist/gateway/static/root/assets/channels-CgE22Pzd.js +1 -0
  40. package/dist/gateway/static/root/assets/{chat-terminal-dock-Bl7-Zk-x.js → chat-terminal-dock-CEjh1utz.js} +2 -2
  41. package/dist/gateway/static/root/assets/{computer-settings-page-ByExKr_6.js → computer-settings-page-vFHJAmQr.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connector-service-page-BK_5aFxO.js → connector-service-page-DTrwZ4kV.js} +1 -1
  43. package/dist/gateway/static/root/assets/connectors-page-DRcMiTWu.js +1 -0
  44. package/dist/gateway/static/root/assets/copy-text-row-C1gaJwlZ.js +1 -0
  45. package/dist/gateway/static/root/assets/{date-picker-BXJv6472.js → date-picker-NfGIPSYY.js} +1 -1
  46. package/dist/gateway/static/root/assets/dependency-picker-CqguveUi.js +1 -0
  47. package/dist/gateway/static/root/assets/{desktop-pet-DWNEC3mk.js → desktop-pet-CTx1zkJm.js} +1 -1
  48. package/dist/gateway/static/root/assets/{desktop-pet-settings-BYwlxGiN.js → desktop-pet-settings-BRDS3EGc.js} +1 -1
  49. package/dist/gateway/static/root/assets/{device-pairing-wizard-BAc4F35b.js → device-pairing-wizard-Du4Ciuyw.js} +1 -1
  50. package/dist/gateway/static/root/assets/{directory-picker-path-field-D26tSY8Z.js → directory-picker-path-field-CjstlxFl.js} +1 -1
  51. package/dist/gateway/static/root/assets/{extension-debug-page-xYIGNegB.js → extension-debug-page-BfAtjhoK.js} +1 -1
  52. package/dist/gateway/static/root/assets/{extension-page-BoQ1-3AW.js → extension-page-BJmudejr.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-provider-Cw_JU6RR.js → extension-provider-Br6LXyIj.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-settings-page-BH5TFGPe.js → extension-settings-page-UvmHniyz.js} +1 -1
  55. package/dist/gateway/static/root/assets/{fallback-models-04Wqmw14.js → fallback-models-euw9MGdt.js} +1 -1
  56. package/dist/gateway/static/root/assets/{gateway-config-swr-CNf0ZeRw.js → gateway-config-swr-7RKqgU_U.js} +1 -1
  57. package/dist/gateway/static/root/assets/gateway-realtime-F6D4A7N5.js +1 -0
  58. package/dist/gateway/static/root/assets/gateway-realtime-store-BheKaO6d.js +1 -0
  59. package/dist/gateway/static/root/assets/{gateway-settings-BqvCJVUC.js → gateway-settings-C7roPHh1.js} +1 -1
  60. package/dist/gateway/static/root/assets/{gateway-startup-retry-DIxHacUw.js → gateway-startup-retry-jiV5sbEX.js} +1 -1
  61. package/dist/gateway/static/root/assets/home-page-BGNCTtM3.js +2 -0
  62. package/dist/gateway/static/root/assets/{image-generation-api-CS0q0Kto.js → image-generation-api-DO4mXb6I.js} +1 -1
  63. package/dist/gateway/static/root/assets/{imports-page-n_rSLo6b.js → imports-page-DxCoT0VV.js} +1 -1
  64. package/dist/gateway/static/root/assets/index-BGBkIIzM.css +1 -0
  65. package/dist/gateway/static/root/assets/index-FCEE325-.js +106 -0
  66. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-tVkrHbYF.js → keyboard-shortcuts-settings-CnLln9Ds.js} +1 -1
  67. package/dist/gateway/static/root/assets/{local-app-workbench-page-L8tYuas0.js → local-app-workbench-page-yXRkSrEj.js} +1 -1
  68. package/dist/gateway/static/root/assets/{local-apps-page-SSJ9B1bH.js → local-apps-page-D46buzTk.js} +1 -1
  69. package/dist/gateway/static/root/assets/local-session-drafts-pox8evDV.js +1 -0
  70. package/dist/gateway/static/root/assets/{locale-store-D6_rF-qT.js → locale-store-COVscAqC.js} +1 -1
  71. package/dist/gateway/static/root/assets/logs-page-DmcCHnH0.js +2 -0
  72. package/dist/gateway/static/root/assets/management-settings-khN1ThNL.js +1 -0
  73. package/dist/gateway/static/root/assets/{markdown-view-_xwUuKce.js → markdown-view-B_qnAcW2.js} +1 -1
  74. package/dist/gateway/static/root/assets/{media-plugins-C631CDu4.js → media-plugins-C0Pc-wSY.js} +1 -1
  75. package/dist/gateway/static/root/assets/messages-Bb2GK-Nj.js +3 -0
  76. package/dist/gateway/static/root/assets/models-hub-cache-DyPPksMP.js +1 -0
  77. package/dist/gateway/static/root/assets/note-detail-panel-C_t58yha.js +5 -0
  78. package/dist/gateway/static/root/assets/{notes-api-vIZWQ9Yt.js → notes-api-sBgBcyLW.js} +1 -1
  79. package/dist/gateway/static/root/assets/notes-page-BJ0QS6xx.js +8 -0
  80. package/dist/gateway/static/root/assets/{page-context-capture-button-BlPDM7GM.js → page-context-capture-button-DfRODHv1.js} +1 -1
  81. package/dist/gateway/static/root/assets/personal-page-CiiXwwQE.js +1 -0
  82. package/dist/gateway/static/root/assets/{product-open-page-BJjWvoER.js → product-open-page-_Bp6HRmm.js} +1 -1
  83. package/dist/gateway/static/root/assets/{product-preview-content-CEd4E7Gf.js → product-preview-content-BUdiO0Ct.js} +1 -1
  84. package/dist/gateway/static/root/assets/project-detail-page-Clb-fXYk.js +1 -0
  85. package/dist/gateway/static/root/assets/{projects-page-lszV8HuS.js → projects-page-D9JEEqhh.js} +1 -1
  86. package/dist/gateway/static/root/assets/{registry-api-uJnjqTcn.js → registry-api-Bh9UBb-f.js} +1 -1
  87. package/dist/gateway/static/root/assets/remote-access-hub-CmyTq3_l.js +1 -0
  88. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CjnNQYW8.js → runtime-tools-settings-panel-B1_inj8L.js} +1 -1
  89. package/dist/gateway/static/root/assets/{scenes-page-B3T3dDOR.js → scenes-page-CUNAZN2_.js} +2 -2
  90. package/dist/gateway/static/root/assets/{schema-form-DT3c4Vd_.js → schema-form-CfT-9UVw.js} +1 -1
  91. package/dist/gateway/static/root/assets/{send-session-input-CICkGwn-.js → send-session-input-BW40VHiL.js} +1 -1
  92. package/dist/gateway/static/root/assets/{session-api-BcQodoAu.js → session-api-yjpEz4pP.js} +1 -1
  93. package/dist/gateway/static/root/assets/session-manager-BqlvrjPE.js +16 -0
  94. package/dist/gateway/static/root/assets/sessions-page-CXZKScvu.js +1 -0
  95. package/dist/gateway/static/root/assets/settings-advanced-gate-B2vKXmzg.js +1 -0
  96. package/dist/gateway/static/root/assets/{settings-page-D-PZjcss.js → settings-page-1h3vyueg.js} +1 -1
  97. package/dist/gateway/static/root/assets/setup-status-panel-Cqc7UlZy.js +1 -0
  98. package/dist/gateway/static/root/assets/{share-link-dialog-CWS8EkJS.js → share-link-dialog-HCHM8qnf.js} +1 -1
  99. package/dist/gateway/static/root/assets/{share-preview-page-23NJAKiq.js → share-preview-page-Ce6FNWt1.js} +1 -1
  100. package/dist/gateway/static/root/assets/{shares-api-iKhHbvBD.js → shares-api-c0dfWz6h.js} +1 -1
  101. package/dist/gateway/static/root/assets/shares-settings-Dh5jisCK.js +1 -0
  102. package/dist/gateway/static/root/assets/{skill-api-C-MWdQwl.js → skill-api-deDZeQS8.js} +1 -1
  103. package/dist/gateway/static/root/assets/{skill-reload-api-iy02aB13.js → skill-reload-api-Ge5XymHa.js} +1 -1
  104. package/dist/gateway/static/root/assets/skills-page-DZozl9U_.js +2 -0
  105. package/dist/gateway/static/root/assets/system-settings-panel-CtzyMxqq.js +1 -0
  106. package/dist/gateway/static/root/assets/{task-detail-page-B2SIEyhZ.js → task-detail-page-5f_V0h-p.js} +2 -2
  107. package/dist/gateway/static/root/assets/{task-expandable-content-D2LRR4BC.js → task-expandable-content-hYcgCEE3.js} +1 -1
  108. package/dist/gateway/static/root/assets/{theme-store-BJfhz-Zq.js → theme-store-BOfCKgl6.js} +1 -1
  109. package/dist/gateway/static/root/assets/{tracing-settings-page-aHD56iaS.js → tracing-settings-page-DDWFXcST.js} +1 -1
  110. package/dist/gateway/static/root/assets/{tunnel-api-BCf8CfTC.js → tunnel-api-vMtlbJ-m.js} +1 -1
  111. package/dist/gateway/static/root/assets/{usage-page-B4XUkuJd.js → usage-page-B1-BCW8U.js} +1 -1
  112. package/dist/gateway/static/root/assets/{use-autosave-BnnTw9RE.js → use-autosave-CSckcjFx.js} +1 -1
  113. package/dist/gateway/static/root/assets/{use-composer-attachments-Itczg0y1.js → use-composer-attachments-DJya1hIL.js} +1 -1
  114. package/dist/gateway/static/root/assets/use-file-preview-expanded-C5ONO7sF.js +2 -0
  115. package/dist/gateway/static/root/assets/user-model-page-D4BSq9HJ.js +2 -0
  116. package/dist/gateway/static/root/assets/{voice-api-key-field-BphJku8x.js → voice-api-key-field-GEw5x2fU.js} +1 -1
  117. package/dist/gateway/static/root/assets/{voice-config-api-B4u4coFj.js → voice-config-api-3yyVwXln.js} +1 -1
  118. package/dist/gateway/static/root/assets/{work-discovery-overlay-jgOEP1xw.js → work-discovery-overlay-CjiNYJV5.js} +1 -1
  119. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-N69crzRu.js → workflow-run-setup-panel-DJOetXvm.js} +2 -2
  120. package/dist/gateway/static/root/assets/workflows-page-CcAPFh2R.js +6 -0
  121. package/dist/gateway/static/root/assets/{workspace-api-Lzv6GDO8.js → workspace-api-WhbMvdBE.js} +2 -2
  122. package/dist/gateway/static/root/index.html +32 -34
  123. package/dist/package.js +1 -1
  124. package/dist/packages/browser-control-contract/src/automation.js +213 -0
  125. package/dist/packages/browser-control-contract/src/index.js +43 -12
  126. package/dist/packages/endpoint-tools-client/src/index.js +189 -0
  127. package/dist/packages/endpoint-tools-protocol/src/bridge.js +105 -0
  128. package/dist/packages/endpoint-tools-protocol/src/index.js +93 -2
  129. package/dist/packages/endpoint-tools-protocol/src/location.js +109 -0
  130. package/dist/packages/gateway-contract/src/gateway-scopes.js +3 -1
  131. package/dist/packages/gateway-contract/src/notifications.js +1 -0
  132. package/dist/packages/gateway-contract/src/session-input-command.js +30 -5
  133. package/dist/packages/realtime-protocol/src/voice.js +9 -3
  134. package/dist/src/agent/agent-manager.js +22 -26
  135. package/dist/src/agent/coding/repository-instructions.js +8 -1
  136. package/dist/src/agent/embedded/codemode-extension.d.ts +7 -0
  137. package/dist/src/agent/embedded/codemode-extension.js +232 -0
  138. package/dist/src/agent/embedded/codemode-output.d.ts +2 -0
  139. package/dist/src/agent/embedded/codemode-output.js +34 -0
  140. package/dist/src/agent/embedded/external-tool-discovery.d.ts +6 -0
  141. package/dist/src/agent/embedded/external-tool-discovery.js +60 -0
  142. package/dist/src/agent/embedded/model-runtime.js +5 -2
  143. package/dist/src/agent/embedded/run-for-session.js +10 -1
  144. package/dist/src/agent/embedded/run-turn.js +10 -3
  145. package/dist/src/agent/embedded/session-runner.d.ts +9 -1
  146. package/dist/src/agent/embedded/session-runner.js +111 -23
  147. package/dist/src/agent/embedded/session-tool-result-guard.d.ts +2 -0
  148. package/dist/src/agent/embedded/session-tool-result-guard.js +17 -0
  149. package/dist/src/agent/embedded/subscribe-session.js +14 -4
  150. package/dist/src/agent/embedded/tool-metadata.d.ts +15 -0
  151. package/dist/src/agent/embedded/tool-metadata.js +38 -0
  152. package/dist/src/agent/embedded/tool-search-extension.d.ts +5 -0
  153. package/dist/src/agent/embedded/tool-search-extension.js +31 -0
  154. package/dist/src/agent/embedded/types.d.ts +7 -0
  155. package/dist/src/agent/embedded/xopc-tools-bridge.js +6 -0
  156. package/dist/src/agent/external-tools/endpoint-provider.d.ts +1 -1
  157. package/dist/src/agent/external-tools/endpoint-provider.js +148 -56
  158. package/dist/src/agent/external-tools/extension-provider.js +8 -1
  159. package/dist/src/agent/external-tools/gateway-tools.d.ts +1 -1
  160. package/dist/src/agent/external-tools/gateway-tools.js +45 -22
  161. package/dist/src/agent/external-tools/index.js +46 -14
  162. package/dist/src/agent/external-tools/memory-provider.js +8 -1
  163. package/dist/src/agent/external-tools/read-policy.js +2 -1
  164. package/dist/src/agent/external-tools/service.d.ts +2 -0
  165. package/dist/src/agent/external-tools/service.js +25 -3
  166. package/dist/src/agent/external-tools/tool-registry.d.ts +14 -0
  167. package/dist/src/agent/external-tools/tool-registry.js +14 -0
  168. package/dist/src/agent/external-tools/types.d.ts +8 -1
  169. package/dist/src/agent/external-tools/types.js +0 -1
  170. package/dist/src/agent/mcp/config.d.ts +18 -0
  171. package/dist/src/agent/mcp/{bundle-mcp-config.js → config.js} +8 -25
  172. package/dist/src/agent/mcp/native-mcp.d.ts +6 -0
  173. package/dist/src/agent/mcp/native-mcp.js +73 -0
  174. package/dist/src/agent/service.js +2 -5
  175. package/dist/src/agent/skills/installer.js +1 -1
  176. package/dist/src/agent/skills/skill-manager.js +1 -1
  177. package/dist/src/agent/skills/skill-sources.js +1 -1
  178. package/dist/src/agent/source-context/index.d.ts +0 -1
  179. package/dist/src/agent/source-context/index.js +1 -2
  180. package/dist/src/agent/source-context/injector.js +1 -0
  181. package/dist/src/agent/source-context/types.d.ts +2 -2
  182. package/dist/src/agent/source-context/types.js +1 -1
  183. package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
  184. package/dist/src/agent/tool-manuals/browser.js +3 -3
  185. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +1 -1
  186. package/dist/src/agent/tools/browser/tool/schemas.d.ts +0 -13
  187. package/dist/src/agent/tools/browser/tool/schemas.js +0 -4
  188. package/dist/src/agent/tools/browser-automation-tool.d.ts +74 -1
  189. package/dist/src/agent/tools/browser-automation-tool.js +52 -6
  190. package/dist/src/agent/tools/cli-clarify.js +1 -1
  191. package/dist/src/agent/tools/codemode-permissions.d.ts +4 -0
  192. package/dist/src/agent/tools/codemode-permissions.js +23 -0
  193. package/dist/src/agent/tools/dataBatch.js +3 -1
  194. package/dist/src/agent/tools/delegation-parent-policy.js +1 -4
  195. package/dist/src/agent/tools/factory.js +4 -3
  196. package/dist/src/agent/transcript/provider-capabilities.js +0 -1
  197. package/dist/src/agent/transcript/transcript-policy.js +1 -2
  198. package/dist/src/agent-config/schema.d.ts +28 -0
  199. package/dist/src/agent-config/schema.js +7 -0
  200. package/dist/src/auth/credentials.js +7 -20
  201. package/dist/src/auth/model-credential-store.js +11 -4
  202. package/dist/src/auth/oauth/index.d.ts +1 -1
  203. package/dist/src/auth/oauth/index.js +3 -3
  204. package/dist/src/auth/oauth/openai.d.ts +2 -0
  205. package/dist/src/auth/oauth/openai.js +90 -0
  206. package/dist/src/auth/oauth/registry.js +3 -3
  207. package/dist/src/auth/oauth/types.d.ts +1 -0
  208. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  209. package/dist/src/auth/sync-provider-auth.js +5 -0
  210. package/dist/src/automations/capabilities/write.d.ts +2 -0
  211. package/dist/src/automations/domain/types.d.ts +11 -0
  212. package/dist/src/automations/domain/validation.d.ts +4 -0
  213. package/dist/src/automations/domain/validation.js +1 -0
  214. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -0
  215. package/dist/src/automations/service/action-executor.js +11 -3
  216. package/dist/src/automations/service/automation-service.d.ts +1 -0
  217. package/dist/src/automations/service/automation-service.js +13 -1
  218. package/dist/src/bootstrap/application-state.js +1 -1
  219. package/dist/src/browser/automations/repository.d.ts +4 -0
  220. package/dist/src/browser/automations/repository.js +27 -6
  221. package/dist/src/browser/automations/runner.js +101 -9
  222. package/dist/src/browser/automations/runtime-service.js +4 -3
  223. package/dist/src/browser/automations/schema.d.ts +84 -1
  224. package/dist/src/browser/automations/schema.js +68 -2
  225. package/dist/src/browser/automations/service.d.ts +78 -1
  226. package/dist/src/browser/automations/service.js +36 -4
  227. package/dist/src/browser/automations/types.d.ts +19 -4
  228. package/dist/src/browser/drivers/extension-driver.d.ts +5 -5
  229. package/dist/src/browser/drivers/extension-driver.js +10 -10
  230. package/dist/src/browser/drivers/playwright-driver.js +46 -0
  231. package/dist/src/browser/index.d.ts +1 -2
  232. package/dist/src/browser/index.js +2 -3
  233. package/dist/src/browser/policy/browser-policy.d.ts +0 -1
  234. package/dist/src/browser/policy/browser-policy.js +1 -4
  235. package/dist/src/browser/providers/index.d.ts +1 -1
  236. package/dist/src/browser/providers/index.js +2 -2
  237. package/dist/src/browser/providers/realtime-extension.d.ts +1 -1
  238. package/dist/src/browser/providers/realtime-extension.js +5 -1
  239. package/dist/src/browser/recordings/service.d.ts +22 -0
  240. package/dist/src/browser/recordings/service.js +160 -0
  241. package/dist/src/browser/runtime/browser-runtime.d.ts +1 -1
  242. package/dist/src/browser/runtime/browser-runtime.js +19 -56
  243. package/dist/src/chat-commands/builtins/model.js +2 -2
  244. package/dist/src/cli/command-manifest.js +1 -1
  245. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  246. package/dist/src/cli/commands/extension-agent-plugin.js +0 -19
  247. package/dist/src/cli/commands/mcp.js +36 -2
  248. package/dist/src/cli/commands/models.js +1 -1
  249. package/dist/src/cli/utils/oauth-login.js +2 -2
  250. package/dist/src/computer/runtime.js +2 -2
  251. package/dist/src/config/index.js +3 -3
  252. package/dist/src/config/mcp-config-normalize.d.ts +0 -3
  253. package/dist/src/config/mcp-config-normalize.js +2 -22
  254. package/dist/src/config/models-json.d.ts +0 -5
  255. package/dist/src/config/models-json.js +13 -4
  256. package/dist/src/config/paths.d.ts +0 -1
  257. package/dist/src/config/paths.js +1 -4
  258. package/dist/src/config/schema.d.ts +142 -48
  259. package/dist/src/config/schema.js +64 -47
  260. package/dist/src/connectors/auth-provider-registry.d.ts +1 -1
  261. package/dist/src/connectors/auth-provider-registry.js +1 -21
  262. package/dist/src/connectors/china-catalog.js +5 -5
  263. package/dist/src/connectors/connection-recovery-service.d.ts +1 -6
  264. package/dist/src/connectors/connection-recovery-service.js +3 -105
  265. package/dist/src/connectors/health.d.ts +1 -2
  266. package/dist/src/connectors/health.js +2 -101
  267. package/dist/src/connectors/types.d.ts +1 -1
  268. package/dist/src/endpoint-tools/binding-service.d.ts +2 -0
  269. package/dist/src/endpoint-tools/binding-service.js +14 -2
  270. package/dist/src/endpoint-tools/bridge-host.d.ts +15 -0
  271. package/dist/src/endpoint-tools/bridge-host.js +166 -0
  272. package/dist/src/endpoint-tools/bridge.d.ts +27 -0
  273. package/dist/src/endpoint-tools/bridge.js +88 -0
  274. package/dist/src/endpoint-tools/capability-catalog.d.ts +2 -0
  275. package/dist/src/endpoint-tools/capability-catalog.js +8 -0
  276. package/dist/src/endpoint-tools/grant-service.d.ts +69 -0
  277. package/dist/src/endpoint-tools/grant-service.js +113 -0
  278. package/dist/src/endpoint-tools/index.js +1 -1
  279. package/dist/src/endpoint-tools/invocation-service.js +6 -2
  280. package/dist/src/endpoint-tools/location-task.d.ts +22 -0
  281. package/dist/src/endpoint-tools/location-task.js +114 -0
  282. package/dist/src/endpoint-tools/policy.js +20 -4
  283. package/dist/src/endpoint-tools/registry.d.ts +2 -0
  284. package/dist/src/endpoint-tools/registry.js +9 -0
  285. package/dist/src/endpoint-tools/result-projector.d.ts +15 -0
  286. package/dist/src/endpoint-tools/result-projector.js +31 -0
  287. package/dist/src/endpoint-tools/runtime.d.ts +2 -0
  288. package/dist/src/endpoint-tools/runtime.js +15 -2
  289. package/dist/src/endpoint-tools/target-resolver.d.ts +12 -0
  290. package/dist/src/endpoint-tools/target-resolver.js +27 -0
  291. package/dist/src/endpoint-tools/turn-context.d.ts +6 -0
  292. package/dist/src/endpoint-tools/turn-context.js +29 -0
  293. package/dist/src/extensions/agent-plugins/auth.d.ts +0 -2
  294. package/dist/src/extensions/agent-plugins/auth.js +2 -19
  295. package/dist/src/extensions/agent-plugins/credentials.js +3 -19
  296. package/dist/src/extensions/agent-plugins/inventory.d.ts +2 -2
  297. package/dist/src/extensions/agent-plugins/mcp-adapter.js +1 -5
  298. package/dist/src/extensions/agent-plugins/source-http-fetch.d.ts +2 -0
  299. package/dist/src/{agent/mcp/plugin-http-fetch.js → extensions/agent-plugins/source-http-fetch.js} +7 -7
  300. package/dist/src/extensions/agent-plugins/sources.js +2 -2
  301. package/dist/src/extensions/agent-plugins/store.js +1 -3
  302. package/dist/src/extensions/agent-plugins/validation.d.ts +0 -4
  303. package/dist/src/extensions/agent-plugins/validation.js +13 -20
  304. package/dist/src/gateway/agents-admin.d.ts +5 -0
  305. package/dist/src/gateway/agents-admin.js +56 -1
  306. package/dist/src/gateway/chat-stream/mapper.js +9 -0
  307. package/dist/src/gateway/chat-stream/protocol.d.ts +4 -4
  308. package/dist/src/gateway/hono/lib/config-payload.d.ts +9 -4
  309. package/dist/src/gateway/hono/lib/config-payload.js +2 -5
  310. package/dist/src/gateway/hono/oauth-async.js +9 -2
  311. package/dist/src/gateway/hono/routes/agent-plugins.js +4 -9
  312. package/dist/src/gateway/hono/routes/agents.js +4 -3
  313. package/dist/src/gateway/hono/routes/browser-automations.js +23 -7
  314. package/dist/src/gateway/hono/routes/browser-recordings.d.ts +3 -0
  315. package/dist/src/gateway/hono/routes/browser-recordings.js +78 -0
  316. package/dist/src/gateway/hono/routes/browser.js +1 -34
  317. package/dist/src/gateway/hono/routes/connection-waits.js +2 -5
  318. package/dist/src/gateway/hono/routes/connectors.js +5 -60
  319. package/dist/src/gateway/hono/routes/device-authorizations.d.ts +3 -0
  320. package/dist/src/gateway/hono/routes/device-authorizations.js +74 -0
  321. package/dist/src/gateway/hono/routes/device-push.js +1 -0
  322. package/dist/src/gateway/hono/routes/endpoint-compatibility.js +7 -0
  323. package/dist/src/gateway/hono/routes/endpoint-tools.d.ts +1 -0
  324. package/dist/src/gateway/hono/routes/endpoint-tools.js +53 -3
  325. package/dist/src/gateway/hono/routes/home.js +1 -1
  326. package/dist/src/gateway/hono/routes/lazy-bundles.js +25 -1
  327. package/dist/src/gateway/hono/routes/mcp.d.ts +1 -1
  328. package/dist/src/gateway/hono/routes/mcp.js +11 -237
  329. package/dist/src/gateway/hono/routes/personal-agent.js +35 -0
  330. package/dist/src/gateway/hono/routes/session-command-handler.js +11 -1
  331. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +8 -2
  332. package/dist/src/gateway/hono/routes/session-input-handler.js +25 -1
  333. package/dist/src/gateway/hono/routes/voice.js +5 -2
  334. package/dist/src/gateway/security/gateway-scopes.js +3 -1
  335. package/dist/src/gateway/service/agent-runner.js +1 -0
  336. package/dist/src/gateway/service/config-coordinator.js +2 -5
  337. package/dist/src/gateway/service/marketplace-service.js +2 -2
  338. package/dist/src/gateway/service/run-gateway-agent.js +13 -5
  339. package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -1
  340. package/dist/src/gateway/service/session-input-coordinator.js +29 -9
  341. package/dist/src/gateway/service/sessions-api.js +0 -6
  342. package/dist/src/gateway/service.js +3 -12
  343. package/dist/src/gateway/session-reset-service.js +0 -6
  344. package/dist/src/home-intelligence/generator.d.ts +2 -0
  345. package/dist/src/home-intelligence/generator.js +53 -4
  346. package/dist/src/home-intelligence/host.d.ts +2 -1
  347. package/dist/src/home-intelligence/host.js +23 -3
  348. package/dist/src/imports/compatibility.js +12 -10
  349. package/dist/src/mcp/channel-bridge.js +1 -1
  350. package/dist/src/migrations/cloud-public-models.js +1 -0
  351. package/dist/src/notifications/clarification.d.ts +5 -0
  352. package/dist/src/notifications/clarification.js +66 -0
  353. package/dist/src/notifications/device-store.js +1 -0
  354. package/dist/src/notifications/harmony-push.d.ts +1 -0
  355. package/dist/src/notifications/harmony-push.js +3 -1
  356. package/dist/src/notifications/planner.d.ts +1 -0
  357. package/dist/src/notifications/service.d.ts +2 -2
  358. package/dist/src/notifications/service.js +20 -4
  359. package/dist/src/notifications/store.d.ts +2 -0
  360. package/dist/src/notifications/store.js +7 -1
  361. package/dist/src/notifications/types.d.ts +1 -0
  362. package/dist/src/notifications/types.js +1 -0
  363. package/dist/src/providers/env-keys.js +1 -1
  364. package/dist/src/providers/index.js +26 -24
  365. package/dist/src/providers/model-call.d.ts +0 -2
  366. package/dist/src/providers/model-call.js +2 -6
  367. package/dist/src/providers/model-registry.js +4 -2
  368. package/dist/src/providers/model-supplements.d.ts +3 -3
  369. package/dist/src/providers/model-supplements.js +6 -27
  370. package/dist/src/providers/presentation.js +3 -8
  371. package/dist/src/providers/prompt-cache-plan.js +1 -1
  372. package/dist/src/providers/provider-auth-service.d.ts +1 -1
  373. package/dist/src/providers/provider-auth-service.js +7 -2
  374. package/dist/src/providers/provider-policy.d.ts +3 -0
  375. package/dist/src/providers/provider-policy.js +14 -0
  376. package/dist/src/providers/register-runtime-providers.js +6 -1
  377. package/dist/src/realtime/runtime.js +1 -1
  378. package/dist/src/session/store.js +7 -1
  379. package/dist/src/session/transcript-events.d.ts +5 -0
  380. package/dist/src/session/transcript-events.js +1 -0
  381. package/dist/src/session/types.d.ts +2 -0
  382. package/dist/src/storage/sqlite/clarification-wait-repository.js +1 -0
  383. package/dist/src/storage/sqlite/device-grant-audit-repository.d.ts +11 -0
  384. package/dist/src/storage/sqlite/device-grant-audit-repository.js +10 -0
  385. package/dist/src/storage/sqlite/endpoint-device-settings-repository.d.ts +7 -0
  386. package/dist/src/storage/sqlite/endpoint-device-settings-repository.js +17 -0
  387. package/dist/src/storage/sqlite/migrations/238_browser_record_replay.sql +45 -0
  388. package/dist/src/storage/sqlite/migrations/239_clarification_notifications.sql +26 -0
  389. package/dist/src/storage/sqlite/migrations/240_device_settings.sql +5 -0
  390. package/dist/src/storage/sqlite/migrations/241_device_grant_audit.sql +13 -0
  391. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  392. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  393. package/dist/src/storage/sqlite/schema.js +1 -1
  394. package/dist/src/storage/sqlite/session-input-repository.d.ts +1 -0
  395. package/dist/src/storage/sqlite/session-input-repository.js +5 -1
  396. package/dist/src/tasks/home-query-service.d.ts +1 -1
  397. package/dist/src/tasks/home-query-service.js +6 -2
  398. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  399. package/dist/src/tui/xopc-tui-keybindings.d.ts +4 -4
  400. package/dist/src/voice/dashscope/streaming-tts-stream.d.ts +2 -1
  401. package/dist/src/voice/dashscope/streaming-tts-stream.js +135 -79
  402. package/dist/src/voice/realtime/agentEngine.js +78 -1
  403. package/dist/src/voice/realtime/speakable-segmenter.d.ts +2 -0
  404. package/dist/src/voice/realtime/speakable-segmenter.js +30 -0
  405. package/dist/src/voice/tts/providers/alibaba-speech.js +17 -1
  406. package/dist/src/voice/tts/speak-core.d.ts +3 -0
  407. package/dist/src/voice/tts/speak-core.js +21 -1
  408. package/dist/src/voice/tts/speech-provider-types.d.ts +8 -0
  409. package/package.json +18 -7
  410. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-D0tD3kCe.js +0 -1
  411. package/dist/gateway/static/root/assets/agent-plugin-dialog-BjdgKCnk.js +0 -1
  412. package/dist/gateway/static/root/assets/agents-CWXKzX5L.js +0 -66
  413. package/dist/gateway/static/root/assets/automations-workspace-C9ZT6TAU.js +0 -6
  414. package/dist/gateway/static/root/assets/browser-automation-inputs-CXG_JveC.js +0 -1
  415. package/dist/gateway/static/root/assets/browser-automations-page-CJc7OKR3.js +0 -3
  416. package/dist/gateway/static/root/assets/browser-settings-page-BjaTEUR8.js +0 -3
  417. package/dist/gateway/static/root/assets/capabilities-page-djBsC_tG.js +0 -2
  418. package/dist/gateway/static/root/assets/channels-BaYRJtz3.js +0 -1
  419. package/dist/gateway/static/root/assets/connectors-page-DyqRwSH2.js +0 -2
  420. package/dist/gateway/static/root/assets/copy-text-row-BHDs3cBa.js +0 -1
  421. package/dist/gateway/static/root/assets/dependency-picker-CWbbhKZa.js +0 -1
  422. package/dist/gateway/static/root/assets/dist-Che_jiQF.js +0 -1
  423. package/dist/gateway/static/root/assets/gateway-realtime-C4KtwMY3.js +0 -1
  424. package/dist/gateway/static/root/assets/gateway-realtime-store-ChZUzVbe.js +0 -1
  425. package/dist/gateway/static/root/assets/home-page-DhPPLbdD.js +0 -2
  426. package/dist/gateway/static/root/assets/index-CK4O2xMa.css +0 -1
  427. package/dist/gateway/static/root/assets/index-DpLD-7Hc.js +0 -106
  428. package/dist/gateway/static/root/assets/link-2-D_ZKYUW7.js +0 -1
  429. package/dist/gateway/static/root/assets/local-session-drafts-B_McurIj.js +0 -1
  430. package/dist/gateway/static/root/assets/logs-page-BWD63eg1.js +0 -2
  431. package/dist/gateway/static/root/assets/management-settings-aKSibklM.js +0 -1
  432. package/dist/gateway/static/root/assets/messages-Bnx3GMDB.js +0 -3
  433. package/dist/gateway/static/root/assets/models-hub-cache-Di83uIPw.js +0 -1
  434. package/dist/gateway/static/root/assets/note-detail-panel-B_fve3_2.js +0 -5
  435. package/dist/gateway/static/root/assets/notes-page-DnChyp8S.js +0 -8
  436. package/dist/gateway/static/root/assets/personal-page-BM2qAgg_.js +0 -1
  437. package/dist/gateway/static/root/assets/project-detail-page-DM4_VLNX.js +0 -1
  438. package/dist/gateway/static/root/assets/remote-access-hub-O6j9CWX0.js +0 -1
  439. package/dist/gateway/static/root/assets/session-manager-B0tOE4qz.js +0 -16
  440. package/dist/gateway/static/root/assets/sessions-page-BIixHXlQ.js +0 -1
  441. package/dist/gateway/static/root/assets/settings-advanced-gate-49SUEWPh.js +0 -1
  442. package/dist/gateway/static/root/assets/setup-status-panel-Ce3gTbT3.js +0 -1
  443. package/dist/gateway/static/root/assets/shares-settings-CNEZjF66.js +0 -1
  444. package/dist/gateway/static/root/assets/skills-page-BndNdYsJ.js +0 -2
  445. package/dist/gateway/static/root/assets/system-settings-panel-EpZeMlvp.js +0 -1
  446. package/dist/gateway/static/root/assets/use-file-preview-expanded-DJ5vyrvM.js +0 -2
  447. package/dist/gateway/static/root/assets/user-model-page-Bz5lkFG9.js +0 -2
  448. package/dist/gateway/static/root/assets/workflows-page-CPCgOfHh.js +0 -6
  449. package/dist/src/agent/embedded/system-prompt-override.d.ts +0 -2
  450. package/dist/src/agent/embedded/system-prompt-override.js +0 -21
  451. package/dist/src/agent/external-tools/mcp-provider.d.ts +0 -32
  452. package/dist/src/agent/external-tools/mcp-provider.js +0 -208
  453. package/dist/src/agent/mcp/bundle-mcp-config.d.ts +0 -20
  454. package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +0 -79
  455. package/dist/src/agent/mcp/bundle-mcp-gateway.js +0 -93
  456. package/dist/src/agent/mcp/bundle-mcp-names.d.ts +0 -1
  457. package/dist/src/agent/mcp/bundle-mcp-names.js +0 -25
  458. package/dist/src/agent/mcp/bundle-mcp-policy.d.ts +0 -1
  459. package/dist/src/agent/mcp/bundle-mcp-policy.js +0 -6
  460. package/dist/src/agent/mcp/bundle-mcp-runtime.d.ts +0 -46
  461. package/dist/src/agent/mcp/bundle-mcp-runtime.js +0 -571
  462. package/dist/src/agent/mcp/bundle-mcp-tools.d.ts +0 -2
  463. package/dist/src/agent/mcp/bundle-mcp-tools.js +0 -2
  464. package/dist/src/agent/mcp/bundle-mcp-types.d.ts +0 -76
  465. package/dist/src/agent/mcp/bundle-mcp-types.js +0 -1
  466. package/dist/src/agent/mcp/embedded-mcp.d.ts +0 -10
  467. package/dist/src/agent/mcp/embedded-mcp.js +0 -14
  468. package/dist/src/agent/mcp/index.d.ts +0 -5
  469. package/dist/src/agent/mcp/index.js +0 -12
  470. package/dist/src/agent/mcp/mcp-config-shared.d.ts +0 -8
  471. package/dist/src/agent/mcp/mcp-config-shared.js +0 -39
  472. package/dist/src/agent/mcp/mcp-http.d.ts +0 -23
  473. package/dist/src/agent/mcp/mcp-http.js +0 -67
  474. package/dist/src/agent/mcp/mcp-resource-id.d.ts +0 -6
  475. package/dist/src/agent/mcp/mcp-resource-id.js +0 -19
  476. package/dist/src/agent/mcp/mcp-stdio-transport.d.ts +0 -26
  477. package/dist/src/agent/mcp/mcp-stdio-transport.js +0 -120
  478. package/dist/src/agent/mcp/mcp-stdio.d.ts +0 -18
  479. package/dist/src/agent/mcp/mcp-stdio.js +0 -35
  480. package/dist/src/agent/mcp/mcp-transport-config.d.ts +0 -28
  481. package/dist/src/agent/mcp/mcp-transport-config.js +0 -91
  482. package/dist/src/agent/mcp/mcp-transport.d.ts +0 -17
  483. package/dist/src/agent/mcp/mcp-transport.js +0 -141
  484. package/dist/src/agent/mcp/oauth/index.d.ts +0 -6
  485. package/dist/src/agent/mcp/oauth/index.js +0 -6
  486. package/dist/src/agent/mcp/oauth/mcp-oauth-errors.d.ts +0 -5
  487. package/dist/src/agent/mcp/oauth/mcp-oauth-errors.js +0 -14
  488. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.d.ts +0 -30
  489. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +0 -276
  490. package/dist/src/agent/mcp/oauth/mcp-oauth-provider.d.ts +0 -33
  491. package/dist/src/agent/mcp/oauth/mcp-oauth-provider.js +0 -103
  492. package/dist/src/agent/mcp/oauth/mcp-oauth-session.d.ts +0 -31
  493. package/dist/src/agent/mcp/oauth/mcp-oauth-session.js +0 -181
  494. package/dist/src/agent/mcp/oauth/mcp-oauth-store.d.ts +0 -12
  495. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +0 -91
  496. package/dist/src/agent/mcp/oauth/mcp-oauth-types.d.ts +0 -22
  497. package/dist/src/agent/mcp/oauth/mcp-oauth-types.js +0 -1
  498. package/dist/src/agent/mcp/plugin-http-fetch.d.ts +0 -2
  499. package/dist/src/agent/source-context/mcp-resource-context.d.ts +0 -8
  500. package/dist/src/agent/source-context/mcp-resource-context.js +0 -30
  501. package/dist/src/auth/oauth/openai-codex.d.ts +0 -9
  502. package/dist/src/auth/oauth/openai-codex.js +0 -414
  503. package/dist/src/browser/policy/approval-store.d.ts +0 -17
  504. package/dist/src/browser/policy/approval-store.js +0 -62
  505. package/dist/src/browser/providers/extension-ws-acquire.d.ts +0 -19
  506. package/dist/src/browser/providers/extension-ws-acquire.js +0 -78
  507. package/dist/src/browser/providers/extension.d.ts +0 -61
  508. package/dist/src/browser/providers/extension.js +0 -378
  509. package/dist/src/connectors/plugin-mcp-recovery.d.ts +0 -28
  510. package/dist/src/connectors/plugin-mcp-recovery.js +0 -90
  511. package/dist/src/extensions/agent-plugins/connection.d.ts +0 -8
  512. package/dist/src/extensions/agent-plugins/connection.js +0 -41
  513. package/dist/src/extensions/agent-plugins/health.d.ts +0 -4
  514. package/dist/src/extensions/agent-plugins/health.js +0 -48
  515. package/dist/src/extensions/agent-plugins/plugin-oauth-scope.d.ts +0 -1
  516. package/dist/src/extensions/agent-plugins/plugin-oauth-scope.js +0 -8
@@ -0,0 +1,90 @@
1
+ import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
2
+ import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
3
+ import { init_paths, resolveCredentialsDir } from "../../config/paths.js";
4
+ import { init_oauth_provider_lock, withOAuthProviderLock } from "../oauth-provider-lock.js";
5
+ import { init_register_bundled_oauth_flows, registerBundledOAuthFlows } from "../../providers/register-bundled-oauth-flows.js";
6
+ import { join } from "node:path";
7
+ import { randomUUID } from "node:crypto";
8
+ import { readFile } from "node:fs/promises";
9
+ import { openaiProvider } from "@earendil-works/pi-ai/providers/openai";
10
+ //#region src/auth/oauth/openai.ts
11
+ async function getDeviceId(signal) {
12
+ return withOAuthProviderLock("openai-device-id", async () => {
13
+ const path = join(resolveCredentialsDir(), "openai-device-id");
14
+ try {
15
+ const id = (await readFile(path, "utf8")).trim();
16
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) throw new Error("Invalid OpenAI installation device ID");
17
+ return id;
18
+ } catch (error) {
19
+ if (error.code !== "ENOENT") throw error;
20
+ const id = randomUUID();
21
+ await writeTextAtomic(path, id);
22
+ return id;
23
+ }
24
+ }, { signal });
25
+ }
26
+ function getOpenaiOAuth() {
27
+ registerBundledOAuthFlows();
28
+ const oauth = openaiProvider().auth.oauth;
29
+ if (!oauth) throw new Error("OpenAI ChatGPT OAuth is unavailable");
30
+ return oauth;
31
+ }
32
+ function fromPiCredential({ type: _type, ...credentials }) {
33
+ return credentials;
34
+ }
35
+ function toAuthInteraction(callbacks) {
36
+ return {
37
+ signal: callbacks.signal ?? new AbortController().signal,
38
+ async prompt(prompt) {
39
+ if (prompt.type === "select") return await callbacks.onSelect({
40
+ message: prompt.message,
41
+ options: [...prompt.options]
42
+ }) ?? "";
43
+ return callbacks.onPrompt({
44
+ message: prompt.message,
45
+ placeholder: prompt.placeholder,
46
+ signal: prompt.signal
47
+ });
48
+ },
49
+ notify(event) {
50
+ if (event.type === "auth_url") callbacks.onAuth({
51
+ url: event.url,
52
+ instructions: event.instructions
53
+ });
54
+ else if (event.type === "device_code") callbacks.onDeviceCode(event);
55
+ else callbacks.onProgress?.(event.message);
56
+ }
57
+ };
58
+ }
59
+ var openaiOAuthProvider;
60
+ var init_openai = __esmMin((() => {
61
+ init_paths();
62
+ init_write_file_atomic();
63
+ init_oauth_provider_lock();
64
+ init_register_bundled_oauth_flows();
65
+ openaiOAuthProvider = {
66
+ id: "openai",
67
+ name: "OpenAI (ChatGPT subscription)",
68
+ usesCallbackServer: true,
69
+ loginMethods: ["browser"],
70
+ async login(callbacks) {
71
+ const deviceId = await getDeviceId(callbacks.signal);
72
+ return fromPiCredential(await getOpenaiOAuth().login(toAuthInteraction(callbacks), {
73
+ getDeviceId: () => deviceId,
74
+ agentName: "xopc"
75
+ }));
76
+ },
77
+ async refreshToken(credentials, signal) {
78
+ return fromPiCredential(await getOpenaiOAuth().refresh({
79
+ ...credentials,
80
+ type: "oauth"
81
+ }, signal ?? new AbortController().signal));
82
+ },
83
+ getApiKey(credentials) {
84
+ return credentials.access;
85
+ }
86
+ };
87
+ }));
88
+ //#endregion
89
+ init_openai();
90
+ export { init_openai, openaiOAuthProvider };
@@ -8,7 +8,7 @@ import { init_google_gemini_cli } from "./google-gemini-cli.js";
8
8
  import { init_kimi_coding, kimiCodingOAuthProvider } from "./kimi-coding.js";
9
9
  import { init_minimax_cn, minimaxCnOAuthProvider } from "./minimax-cn.js";
10
10
  import { init_minimax, minimaxOAuthProvider } from "./minimax.js";
11
- import { init_openai_codex, openaiCodexOAuthProvider } from "./openai-codex.js";
11
+ import { init_openai, openaiOAuthProvider } from "./openai.js";
12
12
  import { init_xopc_cloud, xopcCloudOAuthProvider, xopcShareOAuthProvider, xopcTunnelOAuthProvider } from "./xopc-cloud.js";
13
13
  //#region src/auth/oauth/registry.ts
14
14
  function definition(provider, purpose, displayName = provider.name) {
@@ -44,7 +44,7 @@ var init_registry = __esmMin((() => {
44
44
  init_kimi_coding();
45
45
  init_minimax_cn();
46
46
  init_minimax();
47
- init_openai_codex();
47
+ init_openai();
48
48
  init_xopc_cloud();
49
49
  OAUTH_PROVIDER_DEFINITIONS = {
50
50
  "xopc-cloud": {
@@ -69,7 +69,7 @@ var init_registry = __esmMin((() => {
69
69
  "github-copilot": definition(githubCopilotOAuthProvider, "models"),
70
70
  "google-gemini-cli": definition(geminiCliOAuthProvider, "models"),
71
71
  "google-antigravity": definition(antigravityOAuthProvider, "models"),
72
- "openai-codex": definition(openaiCodexOAuthProvider, "models")
72
+ openai: definition(openaiOAuthProvider, "models")
73
73
  };
74
74
  }));
75
75
  //#endregion
@@ -15,6 +15,7 @@ export type OAuthPrompt = {
15
15
  message: string;
16
16
  placeholder?: string;
17
17
  allowEmpty?: boolean;
18
+ signal?: AbortSignal;
18
19
  };
19
20
  export type OAuthAuthInfo = {
20
21
  url: string;
@@ -3,8 +3,8 @@ import { generatePKCE, init_pkce } from "./pkce.js";
3
3
  import { init_resolution, resolveConnectedPlatformEndpoint } from "../../platform/resolution.js";
4
4
  import { hostname } from "node:os";
5
5
  import { randomBytes } from "node:crypto";
6
- import http from "node:http";
7
6
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
7
+ import http from "node:http";
8
8
  //#region src/auth/oauth/xopc-cloud.ts
9
9
  function consoleUrl() {
10
10
  return (process.env.XOPC_CONSOLE_URL ?? resolveConnectedPlatformEndpoint("authorizationServer") ?? DEFAULT_CONSOLE_URL).replace(/\/+$/, "");
@@ -1,6 +1,7 @@
1
1
  import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
2
2
  import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveOAuthPath } from "../config/paths.js";
3
3
  import { init_registry, isOAuthOnlyProvider } from "./oauth/registry.js";
4
+ import { assertCurrentModelProvider, init_provider_policy } from "../providers/provider-policy.js";
4
5
  import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
5
6
  import { existsSync, readFileSync } from "node:fs";
6
7
  //#region src/auth/sync-provider-auth.ts
@@ -81,6 +82,7 @@ function readOAuthAccessTokenSync(provider) {
81
82
  */
82
83
  function resolveProviderApiKeySync(provider) {
83
84
  const normalized = provider.toLowerCase();
85
+ assertCurrentModelProvider(normalized);
84
86
  if (isOAuthOnlyProvider(normalized)) return readOAuthAccessTokenSync(normalized);
85
87
  const fromAgent = readApiKeyFromProfilesFile(resolveAgentAuthProfilesPath(getDefaultAgentId()), normalized);
86
88
  if (fromAgent) return fromAgent;
@@ -91,6 +93,7 @@ function resolveProviderApiKeySync(provider) {
91
93
  /** Resolve one agent's private credential, then the shared credential and OAuth token. */
92
94
  function resolveProviderApiKeyForAgentSync(provider, agentId, _config) {
93
95
  const normalized = provider.toLowerCase();
96
+ assertCurrentModelProvider(normalized);
94
97
  if (isOAuthOnlyProvider(normalized)) return readOAuthAccessTokenSync(normalized);
95
98
  if (agentId?.trim()) {
96
99
  const fromAgent = readApiKeyFromProfilesFile(resolveAgentAuthProfilesPath(agentId.trim()), normalized);
@@ -105,6 +108,7 @@ function resolveProviderApiKeyForAgentSync(provider, agentId, _config) {
105
108
  * matching async CredentialResolver resolution (excluding env — callers check env separately).
106
109
  */
107
110
  function hasProviderAuthOnDiskSync(provider) {
111
+ assertCurrentModelProvider(provider.toLowerCase());
108
112
  if (isOAuthOnlyProvider(provider.toLowerCase())) return hasOAuthTokenSync(provider);
109
113
  if (hasApiKeyInProfilesFile(resolveAgentAuthProfilesPath(getDefaultAgentId()), provider)) return true;
110
114
  if (hasApiKeyInProfilesFile(resolveAuthProfilesPath(), provider)) return true;
@@ -114,6 +118,7 @@ function hasProviderAuthOnDiskSync(provider) {
114
118
  var init_sync_provider_auth = __esmMin((() => {
115
119
  init_paths();
116
120
  init_resolve_route();
121
+ init_provider_policy();
117
122
  init_registry();
118
123
  }));
119
124
  //#endregion
@@ -31,6 +31,7 @@ export declare const AutomationCreateCapabilityInputSchema: z.ZodObject<{
31
31
  }, z.core.$strict>, z.ZodObject<{
32
32
  kind: z.ZodLiteral<"browser_automation">;
33
33
  automationId: z.ZodString;
34
+ revision: z.ZodOptional<z.ZodNumber>;
34
35
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
36
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
36
37
  }, z.core.$strict>, z.ZodObject<{
@@ -231,6 +232,7 @@ export declare const AutomationUpdatePatchSchema: z.ZodObject<{
231
232
  }, z.core.$strict>, z.ZodObject<{
232
233
  kind: z.ZodLiteral<"browser_automation">;
233
234
  automationId: z.ZodString;
235
+ revision: z.ZodOptional<z.ZodNumber>;
234
236
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
235
237
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
236
238
  }, z.core.$strict>, z.ZodObject<{
@@ -48,6 +48,7 @@ export type AutomationAction = {
48
48
  } | {
49
49
  kind: 'browser_automation';
50
50
  automationId: string;
51
+ revision?: number;
51
52
  inputs?: Record<string, unknown>;
52
53
  timeoutSeconds?: number;
53
54
  } | {
@@ -342,8 +343,18 @@ export interface AutomationDeps {
342
343
  prepareAgentSession?: (input: PrepareAutomationAgentSessionInput) => Promise<void>;
343
344
  workflowRunService?: WorkflowRunServiceLike;
344
345
  browserAutomationService?: {
346
+ get(id: string): {
347
+ revision: number;
348
+ verified: boolean;
349
+ } | null;
350
+ versions(id: string): {
351
+ revision: number;
352
+ verified: boolean;
353
+ }[];
345
354
  runAndWait(automationId: string, inputs: Record<string, unknown>, signal?: AbortSignal, context?: {
346
355
  triggerEvent?: AutomationEvent;
356
+ revision?: number;
357
+ clientRequestId?: string;
347
358
  }): Promise<{
348
359
  id: string;
349
360
  status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
@@ -61,6 +61,7 @@ export declare const AutomationActionSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
61
61
  }, z.core.$strict>, z.ZodObject<{
62
62
  kind: z.ZodLiteral<"browser_automation">;
63
63
  automationId: z.ZodString;
64
+ revision: z.ZodOptional<z.ZodNumber>;
64
65
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
65
66
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
66
67
  }, z.core.$strict>, z.ZodObject<{
@@ -281,6 +282,7 @@ export declare const AutomationSchema: z.ZodObject<{
281
282
  }, z.core.$strict>, z.ZodObject<{
282
283
  kind: z.ZodLiteral<"browser_automation">;
283
284
  automationId: z.ZodString;
285
+ revision: z.ZodOptional<z.ZodNumber>;
284
286
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
285
287
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
286
288
  }, z.core.$strict>, z.ZodObject<{
@@ -480,6 +482,7 @@ export declare const CreateAutomationSchema: z.ZodObject<{
480
482
  }, z.core.$strict>, z.ZodObject<{
481
483
  kind: z.ZodLiteral<"browser_automation">;
482
484
  automationId: z.ZodString;
485
+ revision: z.ZodOptional<z.ZodNumber>;
483
486
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
484
487
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
485
488
  }, z.core.$strict>, z.ZodObject<{
@@ -706,6 +709,7 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
706
709
  }, z.core.$strict>, z.ZodObject<{
707
710
  kind: z.ZodLiteral<"browser_automation">;
708
711
  automationId: z.ZodString;
712
+ revision: z.ZodOptional<z.ZodNumber>;
709
713
  inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
710
714
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
711
715
  }, z.core.$strict>, z.ZodObject<{
@@ -95,6 +95,7 @@ const AutomationActionSchema = z.discriminatedUnion("kind", [
95
95
  z.object({
96
96
  kind: z.literal("browser_automation"),
97
97
  automationId: nonEmptyString.max(100),
98
+ revision: z.number().int().positive().optional(),
98
99
  inputs: z.record(z.string(), z.unknown()).optional(),
99
100
  timeoutSeconds: z.number().int().min(1).max(86400).optional()
100
101
  }).strict(),
@@ -60,6 +60,7 @@ export declare function buildAutomationDraftResponse(draft: GeneratedAutomationD
60
60
  } | {
61
61
  kind: "browser_automation";
62
62
  automationId: string;
63
+ revision?: number;
63
64
  inputs?: Record<string, unknown>;
64
65
  timeoutSeconds?: number;
65
66
  } | {
@@ -77,7 +77,7 @@ var AutomationActionExecutor = class {
77
77
  mode: "idempotent",
78
78
  key: "run_id"
79
79
  }, (input, action) => this.executeWorkflow(input.automation, action, input.run, input.signal, input.hooks, input.context));
80
- this.register("browser_automation", { mode: "never" }, (input, action) => this.executeBrowserAutomation(input.automation, action, input.signal, input.hooks, input.context));
80
+ this.register("browser_automation", { mode: "never" }, (input, action) => this.executeBrowserAutomation(input.automation, action, input.signal, input.hooks, input.context, input.run.id));
81
81
  this.register("task_command", {
82
82
  mode: "idempotent",
83
83
  key: "run_id"
@@ -186,7 +186,7 @@ var AutomationActionExecutor = class {
186
186
  })).summary ?? "System action completed"
187
187
  };
188
188
  }
189
- async executeBrowserAutomation(automation, action, signal, hooks, context) {
189
+ async executeBrowserAutomation(automation, action, signal, hooks, context, executionRunId) {
190
190
  await hooks.onRunPatch?.({ currentPhase: "action" });
191
191
  const safetyMode = automation.safety?.mode ?? "auto_apply";
192
192
  if (safetyMode !== "auto_apply") return {
@@ -198,7 +198,15 @@ var AutomationActionExecutor = class {
198
198
  status: "failed",
199
199
  error: "Browser automation is not available"
200
200
  };
201
- const run = context.triggerEvent ? await service.runAndWait(action.automationId, action.inputs ?? {}, signal, { triggerEvent: context.triggerEvent }) : await service.runAndWait(action.automationId, action.inputs ?? {}, signal);
201
+ if (action.revision === void 0 || !service.versions(action.automationId).some((item) => item.revision === action.revision && item.verified)) return {
202
+ status: "failed",
203
+ error: "The scheduled browser automation version has not been verified."
204
+ };
205
+ const run = await service.runAndWait(action.automationId, action.inputs ?? {}, signal, {
206
+ revision: action.revision,
207
+ clientRequestId: `schedule:${executionRunId}:${action.revision}`,
208
+ ...context.triggerEvent ? { triggerEvent: context.triggerEvent } : {}
209
+ });
202
210
  if (run.status === "succeeded") return {
203
211
  status: "succeeded",
204
212
  summary: `Browser automation ${action.automationId} completed: ${JSON.stringify(run.result ?? null).slice(0, 3500)}`
@@ -31,6 +31,7 @@ export declare class AutomationService {
31
31
  /** SQLite-only creation; scheduling starts after the caller commits. */
32
32
  createAtomically(input: CreateAutomationInput): Automation;
33
33
  private applyCreate;
34
+ private pinBrowserVersion;
34
35
  list(options?: {
35
36
  projectId?: string;
36
37
  }): Promise<Automation[]>;
@@ -114,12 +114,23 @@ var AutomationService = class {
114
114
  createdAtMs: now,
115
115
  updatedAtMs: now
116
116
  });
117
+ this.pinBrowserVersion(automation);
117
118
  if (getAutomation(automation.id)) throw new AutomationAlreadyExistsError(automation.id);
118
119
  automation.updatedAtMs = Math.max(automation.updatedAtMs, (getDeletedAutomationRevision(automation.id) ?? -1) + 1);
119
120
  automation.state.nextRunAtMs = computeNextAutomationRunAtMs(automation, now);
120
121
  saveAutomation(automation);
121
122
  return automation;
122
123
  }
124
+ pinBrowserVersion(automation) {
125
+ if (automation.action.kind !== "browser_automation") return;
126
+ const browser = this.deps.browserAutomationService;
127
+ if (!browser) throw new Error("Browser automation service is unavailable.");
128
+ const action = automation.action;
129
+ const version = action.revision === void 0 ? browser.get(action.automationId) : browser.versions(action.automationId).find((item) => item.revision === action.revision);
130
+ if (!version) throw new Error("Browser automation version not found.");
131
+ if (automation.enabled && !version.verified) throw new Error("Run and verify this browser automation before scheduling it.");
132
+ action.revision = version.revision;
133
+ }
123
134
  async list(options) {
124
135
  return listAutomations(options);
125
136
  }
@@ -154,6 +165,7 @@ var AutomationService = class {
154
165
  ...parsed.state ?? {}
155
166
  }
156
167
  });
168
+ this.pinBrowserVersion(next);
157
169
  if ("enabled" in parsed || "trigger" in parsed) next.state.nextRunAtMs = computeNextAutomationRunAtMs(next, now);
158
170
  saveAutomation(next);
159
171
  return next;
@@ -559,7 +571,7 @@ var AutomationService = class {
559
571
  let artifacts;
560
572
  const triggerEvent = listAutomationRunEvents(run.id).map(readAutomationEventFromRunEvent).find((item) => item !== null);
561
573
  try {
562
- const maxAttempts = Math.max(1, (automation.reliability?.retryCount ?? 0) + 1);
574
+ const maxAttempts = automation.action.kind === "browser_automation" ? 1 : Math.max(1, (automation.reliability?.retryCount ?? 0) + 1);
563
575
  let task;
564
576
  for (let attempt = 1;; attempt += 1) {
565
577
  run = {
@@ -2,9 +2,9 @@ import { requireXopcDatabase } from "../storage/sqlite/connection.js";
2
2
  import { init_sqlite } from "../storage/sqlite/index.js";
3
3
  import { AgentCatalogService } from "../agent-catalog/service.js";
4
4
  import { ensureStarterAgentsInitialized } from "../agent/starter-agents.js";
5
- import { migrateIdentityMarkdownToCatalog } from "../agent-catalog/migrations/identity-markdown-cutover.js";
6
5
  import { cutoverLegacyAgentConfig } from "../agent-catalog/migrations/legacy-config-cutover.js";
7
6
  import "../agent-catalog/index.js";
7
+ import { migrateIdentityMarkdownToCatalog } from "../agent-catalog/migrations/identity-markdown-cutover.js";
8
8
  import { migrateCloudPublicModelsSync } from "../migrations/cloud-public-models.js";
9
9
  import { runBootstrapMigrationsSync } from "../migrations/runner.js";
10
10
  //#region src/bootstrap/application-state.ts
@@ -2,6 +2,10 @@ import type { BrowserAutomation, BrowserAutomationRun, BrowserAutomationRunEvent
2
2
  export declare const listBrowserAutomations: () => BrowserAutomation[];
3
3
  export declare const getBrowserAutomation: (id: string) => BrowserAutomation | null;
4
4
  export declare function saveBrowserAutomation(value: BrowserAutomation): void;
5
+ export declare function getBrowserAutomationVersion(id: string, revision: number): BrowserAutomation | null;
6
+ export declare function listBrowserAutomationVersions(id: string): BrowserAutomation[];
7
+ export declare function verifyBrowserAutomationRun(run: BrowserAutomationRun): void;
8
+ export declare function findBrowserAutomationRunByRequest(requestId: string): BrowserAutomationRun | null;
5
9
  export declare const deleteBrowserAutomation: (id: string) => boolean;
6
10
  export declare function saveBrowserAutomationRun(value: BrowserAutomationRun): void;
7
11
  export declare const getBrowserAutomationRun: (id: string) => BrowserAutomationRun | null;
@@ -2,9 +2,10 @@ import { getSqliteDatabase, runSqliteWriteTransaction } from "../../storage/sqli
2
2
  import { init_sqlite } from "../../storage/sqlite/index.js";
3
3
  //#region src/browser/automations/repository.ts
4
4
  init_sqlite();
5
- const AUTOMATION_SELECT = "SELECT automation_id, revision, status, definition_json, created_at_ms, updated_at_ms FROM browser_automations";
6
- const RUN_SELECT = "SELECT run_id, automation_id, automation_revision, definition_json, status, inputs_json, result_json, error, created_at_ms, started_at_ms, ended_at_ms, duration_ms FROM browser_automation_runs";
5
+ const AUTOMATION_SELECT = "SELECT a.*, EXISTS(SELECT 1 FROM browser_automation_verifications v WHERE v.automation_id=a.automation_id AND v.revision=a.revision) AS verified FROM browser_automations a";
6
+ const RUN_SELECT = "SELECT client_request_id, business_outcome, run_id, automation_id, automation_revision, definition_json, status, inputs_json, result_json, error, created_at_ms, started_at_ms, ended_at_ms, duration_ms FROM browser_automation_runs";
7
7
  const parseAutomation = (row) => ({
8
+ verified: !!row.verified,
8
9
  id: row.automation_id,
9
10
  revision: row.revision,
10
11
  status: row.status,
@@ -13,6 +14,8 @@ const parseAutomation = (row) => ({
13
14
  updatedAtMs: row.updated_at_ms
14
15
  });
15
16
  const parseRun = (row) => ({
17
+ clientRequestId: row.client_request_id ?? void 0,
18
+ businessOutcome: row.business_outcome ?? void 0,
16
19
  id: row.run_id,
17
20
  automationId: row.automation_id,
18
21
  automationRevision: row.automation_revision,
@@ -28,15 +31,33 @@ const parseRun = (row) => ({
28
31
  });
29
32
  const listBrowserAutomations = () => getSqliteDatabase().prepare(`${AUTOMATION_SELECT} ORDER BY updated_at_ms DESC`).all().map(parseAutomation);
30
33
  const getBrowserAutomation = (id) => {
31
- const row = getSqliteDatabase().prepare(`${AUTOMATION_SELECT} WHERE automation_id = ?`).get(id);
34
+ const row = getSqliteDatabase().prepare(`${AUTOMATION_SELECT} WHERE a.automation_id = ?`).get(id);
32
35
  return row ? parseAutomation(row) : null;
33
36
  };
34
37
  function saveBrowserAutomation(value) {
35
- runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_automations (automation_id, revision, status, definition_json, created_at_ms, updated_at_ms) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(automation_id) DO UPDATE SET revision=excluded.revision, status=excluded.status, definition_json=excluded.definition_json, updated_at_ms=excluded.updated_at_ms").run(value.id, value.revision, value.status, JSON.stringify(value.definition), value.createdAtMs, value.updatedAtMs));
38
+ runSqliteWriteTransaction((db) => {
39
+ db.prepare("INSERT INTO browser_automations (automation_id, revision, status, definition_json, created_at_ms, updated_at_ms) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(automation_id) DO UPDATE SET revision=excluded.revision, status=excluded.status, definition_json=excluded.definition_json, updated_at_ms=excluded.updated_at_ms").run(value.id, value.revision, value.status, JSON.stringify(value.definition), value.createdAtMs, value.updatedAtMs);
40
+ db.prepare("INSERT OR IGNORE INTO browser_automation_versions (automation_id, revision, definition_json, created_at_ms) VALUES (?, ?, ?, ?)").run(value.id, value.revision, JSON.stringify(value.definition), value.updatedAtMs);
41
+ });
42
+ }
43
+ function getBrowserAutomationVersion(id, revision) {
44
+ const row = getSqliteDatabase().prepare("SELECT v.*, a.status, a.created_at_ms, v.created_at_ms AS updated_at_ms, EXISTS(SELECT 1 FROM browser_automation_verifications p WHERE p.automation_id=v.automation_id AND p.revision=v.revision) AS verified FROM browser_automation_versions v JOIN browser_automations a USING(automation_id) WHERE v.automation_id=? AND v.revision=?").get(id, revision);
45
+ return row ? parseAutomation(row) : null;
46
+ }
47
+ function listBrowserAutomationVersions(id) {
48
+ return getSqliteDatabase().prepare("SELECT revision FROM browser_automation_versions WHERE automation_id=? ORDER BY revision DESC").all(id).map((row) => getBrowserAutomationVersion(id, row.revision));
49
+ }
50
+ function verifyBrowserAutomationRun(run) {
51
+ if (run.status !== "succeeded" || run.businessOutcome !== "verified") return;
52
+ runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_automation_verifications (automation_id, revision, run_id, verified_at_ms) VALUES (?, ?, ?, ?) ON CONFLICT(automation_id, revision) DO UPDATE SET run_id=excluded.run_id, verified_at_ms=excluded.verified_at_ms").run(run.automationId, run.automationRevision, run.id, run.endedAtMs));
53
+ }
54
+ function findBrowserAutomationRunByRequest(requestId) {
55
+ const row = getSqliteDatabase().prepare(`${RUN_SELECT} WHERE client_request_id=?`).get(requestId);
56
+ return row ? parseRun(row) : null;
36
57
  }
37
58
  const deleteBrowserAutomation = (id) => runSqliteWriteTransaction((db) => db.prepare("DELETE FROM browser_automations WHERE automation_id = ?").run(id).changes > 0);
38
59
  function saveBrowserAutomationRun(value) {
39
- runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_automation_runs (run_id, automation_id, automation_revision, definition_json, status, inputs_json, result_json, error, created_at_ms, started_at_ms, ended_at_ms, duration_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(run_id) DO UPDATE SET status=excluded.status, result_json=excluded.result_json, error=excluded.error, started_at_ms=excluded.started_at_ms, ended_at_ms=excluded.ended_at_ms, duration_ms=excluded.duration_ms").run(value.id, value.automationId, value.automationRevision, JSON.stringify(value.definition), value.status, JSON.stringify(value.inputs), value.result === void 0 ? null : JSON.stringify(value.result), value.error ?? null, value.createdAtMs, value.startedAtMs ?? null, value.endedAtMs ?? null, value.durationMs ?? null));
60
+ runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_automation_runs (run_id, automation_id, automation_revision, definition_json, status, inputs_json, result_json, error, created_at_ms, started_at_ms, ended_at_ms, duration_ms, client_request_id, business_outcome) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(run_id) DO UPDATE SET status=excluded.status, result_json=excluded.result_json, error=excluded.error, started_at_ms=excluded.started_at_ms, ended_at_ms=excluded.ended_at_ms, duration_ms=excluded.duration_ms, business_outcome=excluded.business_outcome").run(value.id, value.automationId, value.automationRevision, JSON.stringify(value.definition), value.status, JSON.stringify(value.inputs), value.result === void 0 ? null : JSON.stringify(value.result), value.error ?? null, value.createdAtMs, value.startedAtMs ?? null, value.endedAtMs ?? null, value.durationMs ?? null, value.clientRequestId ?? null, value.businessOutcome ?? null));
40
61
  }
41
62
  const getBrowserAutomationRun = (id) => {
42
63
  const row = getSqliteDatabase().prepare(`${RUN_SELECT} WHERE run_id = ?`).get(id);
@@ -58,4 +79,4 @@ const listBrowserAutomationRunEvents = (runId) => getSqliteDatabase().prepare("S
58
79
  createdAtMs: row.created_at_ms
59
80
  }));
60
81
  //#endregion
61
- export { appendBrowserAutomationRunEvent, deleteBrowserAutomation, getBrowserAutomation, getBrowserAutomationRun, hasActiveBrowserAutomationRuns, listActiveBrowserAutomationRuns, listBrowserAutomationRunEvents, listBrowserAutomationRuns, listBrowserAutomations, nextBrowserAutomationRunEventSeq, saveBrowserAutomation, saveBrowserAutomationRun };
82
+ export { appendBrowserAutomationRunEvent, deleteBrowserAutomation, findBrowserAutomationRunByRequest, getBrowserAutomation, getBrowserAutomationRun, getBrowserAutomationVersion, hasActiveBrowserAutomationRuns, listActiveBrowserAutomationRuns, listBrowserAutomationRunEvents, listBrowserAutomationRuns, listBrowserAutomationVersions, listBrowserAutomations, nextBrowserAutomationRunEventSeq, saveBrowserAutomation, saveBrowserAutomationRun, verifyBrowserAutomationRun };
@@ -30,6 +30,26 @@ async function runBrowserAutomation(input) {
30
30
  sessionId = observation?.sessionId;
31
31
  }
32
32
  if (step.action === "navigate") assertAllowedDomain(input.definition.allowedDomains, render(step.url, values));
33
+ if ("target" in step && step.target) {
34
+ const resolved = await input.runtime.execute(input.taskKey, {
35
+ action: "resolve",
36
+ sessionId,
37
+ semanticTarget: step.target
38
+ }, input.signal);
39
+ if (!resolved.ok) {
40
+ input.onStep({
41
+ index,
42
+ action: step.action,
43
+ status: "failed",
44
+ result: resolved
45
+ });
46
+ return resolved;
47
+ }
48
+ observation = resolved.receipt.observation;
49
+ sessionId = observation?.sessionId ?? sessionId;
50
+ }
51
+ if (observation) assertAllowedDomain(input.definition.allowedDomains, observation.url);
52
+ if (step.action === "click" && observation?.nodes[0]?.href) assertAllowedDomain(input.definition.allowedDomains, observation.nodes[0].href);
33
53
  const action = buildAction(step, values, observation, sessionId);
34
54
  const result = await input.runtime.execute(input.taskKey, action, input.signal);
35
55
  if (!result.ok) {
@@ -43,7 +63,7 @@ async function runBrowserAutomation(input) {
43
63
  }
44
64
  observation = result.receipt.observation ?? observation;
45
65
  sessionId = observation?.sessionId ?? sessionId;
46
- if (step.action === "navigate") assertAllowedDomain(input.definition.allowedDomains, observation?.url ?? render(step.url, values));
66
+ if (observation) assertAllowedDomain(input.definition.allowedDomains, observation.url);
47
67
  input.onStep({
48
68
  index,
49
69
  action: step.action,
@@ -61,16 +81,80 @@ async function runBrowserAutomation(input) {
61
81
  return result;
62
82
  }
63
83
  }
64
- return {
65
- ok: true,
66
- receipt: {
67
- action: "sequence",
68
- risk: input.definition.risk,
69
- durationMs: Date.now() - startedAt,
70
- verified: true,
71
- observation
84
+ const readField = async (spec) => {
85
+ if (spec.target) {
86
+ const result = await input.runtime.execute(input.taskKey, {
87
+ action: "resolve",
88
+ sessionId,
89
+ semanticTarget: spec.target
90
+ }, input.signal);
91
+ if (!result.ok) return void 0;
92
+ observation = result.receipt.observation;
93
+ } else {
94
+ const result = await input.runtime.execute(input.taskKey, {
95
+ action: "observe",
96
+ sessionId,
97
+ visual: "never"
98
+ }, input.signal);
99
+ if (!result.ok) return void 0;
100
+ observation = result.receipt.observation;
72
101
  }
102
+ if (!observation) return void 0;
103
+ assertAllowedDomain(input.definition.allowedDomains, observation.url);
104
+ const node = observation.nodes[0];
105
+ if (spec.field === "url") return observation.url;
106
+ if (spec.field === "title") return observation.title;
107
+ if (spec.field === "checked") return node?.states.includes("checked");
108
+ if (spec.field === "text") return node?.description ?? node?.name;
109
+ return node?.[spec.field];
73
110
  };
111
+ try {
112
+ for (const assertion of input.definition.successCriteria ?? []) {
113
+ const deadline = Date.now() + 1e4;
114
+ let passed = false;
115
+ do {
116
+ if (input.signal.aborted) return automationFailure("INVALID_INPUT", "Run cancelled.", observation);
117
+ const actual = await readField(assertion);
118
+ passed = assertion.equals !== void 0 ? actual === (typeof assertion.equals === "string" ? render(assertion.equals, values) : assertion.equals) : typeof actual === "string" && actual.includes(render(assertion.includes, values));
119
+ if (!passed) await new Promise((resolve) => setTimeout(resolve, 200));
120
+ } while (!passed && Date.now() < deadline);
121
+ if (!passed) return {
122
+ ok: false,
123
+ error: {
124
+ code: "EXPECTATION_FAILED",
125
+ message: "The business result did not match its success criteria.",
126
+ observation
127
+ }
128
+ };
129
+ }
130
+ const outputs = {};
131
+ for (const [name, spec] of Object.entries(input.definition.outputs ?? {})) {
132
+ const value = await readField(spec);
133
+ if (typeof value !== "string" || !value) return {
134
+ ok: false,
135
+ error: {
136
+ code: "EXPECTATION_FAILED",
137
+ message: `Output ${name} is unavailable.`,
138
+ observation
139
+ }
140
+ };
141
+ outputs[name] = value;
142
+ }
143
+ return {
144
+ ok: true,
145
+ receipt: {
146
+ action: "sequence",
147
+ risk: input.definition.risk,
148
+ durationMs: Date.now() - startedAt,
149
+ verified: !!input.definition.successCriteria?.length,
150
+ businessOutcome: input.definition.successCriteria?.length ? "verified" : "completed",
151
+ outputs,
152
+ observation
153
+ }
154
+ };
155
+ } catch (error) {
156
+ return automationFailure("BLOCKED_URL", error, observation);
157
+ }
74
158
  }
75
159
  function buildAction(step, inputs, observation, sessionId) {
76
160
  if (step.action === "navigate") return {
@@ -98,6 +182,13 @@ function buildAction(step, inputs, observation, sessionId) {
98
182
  submit: step.submit,
99
183
  expect: step.expect
100
184
  };
185
+ case "check": return {
186
+ action: "check",
187
+ sessionId,
188
+ revision,
189
+ ref,
190
+ checked: step.checked
191
+ };
101
192
  case "select": return {
102
193
  action: "select",
103
194
  sessionId,
@@ -149,6 +240,7 @@ function resolveBrowserAutomationInputs(definition, provided) {
149
240
  for (const [name, spec] of Object.entries(definition.inputs)) {
150
241
  const value = values[name] ?? spec.default;
151
242
  if (value === void 0 && spec.required) throw new Error(`Missing required automation input: ${name}`);
243
+ if (value !== void 0 && spec.choices && !spec.choices.includes(value)) throw new Error(`Automation input ${name} is not an allowed choice.`);
152
244
  if (value !== void 0 && typeof value !== spec.type) throw new Error(`Automation input ${name} must be ${spec.type}.`);
153
245
  if (values[name] === void 0 && value !== void 0) values[name] = value;
154
246
  }
@@ -10,8 +10,8 @@ function createRuntimeBrowserAutomationService(deps) {
10
10
  allowedUploadRoots: [process.cwd()],
11
11
  emit: deps.emit
12
12
  });
13
- return new BrowserAutomationService(async ({ definition, inputs, signal, onStep }) => {
14
- const taskKey = `browser-automation:${crypto.randomUUID()}`;
13
+ return new BrowserAutomationService(async ({ runId, definition, inputs, signal, onStep }) => {
14
+ const taskKey = `browser-automation:${runId}`;
15
15
  try {
16
16
  const result = await runBrowserAutomation({
17
17
  definition,
@@ -23,7 +23,8 @@ function createRuntimeBrowserAutomationService(deps) {
23
23
  });
24
24
  return result.ok ? {
25
25
  ok: true,
26
- result: result.receipt
26
+ result: result.receipt.outputs ?? {},
27
+ businessOutcome: result.receipt.businessOutcome
27
28
  } : {
28
29
  ok: false,
29
30
  error: "error" in result ? result.error.message : "Browser automation failed."