@xopcai/xopc 0.0.412 → 0.0.414
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BrGZdh5N.js → agent-avatar-dicebear-ClobpdW3.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-mf0jgEPE.js +1 -0
- package/dist/gateway/static/root/assets/agents-CKhZ4UYQ.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-uGDeJR1f.js → agents-admin-api-CeBkHnl8.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-CLunLNGp.js +1 -0
- package/dist/gateway/static/root/assets/app-window-DXFNqt_0.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-DBEgoE9g.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-BZ_MaQJf.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DAmsio91.js → archive-plugin-JElK4Goq.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BVutrwON.js → automations-page-CZ0UqwyU.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CHUDHNVL.js +8 -0
- package/dist/gateway/static/root/assets/{binary-plugins-41QCRAxz.js → binary-plugins-CXFawow6.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BQ8AA-Ot.js → block-editor-BoduwSYI.js} +30 -30
- package/dist/gateway/static/root/assets/{browser-automation-inputs-D4-vQc4g.js → browser-automation-inputs-D1pDgMJu.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-DStDm9y1.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-6I4oetKt.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-Bpeh6E22.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-C-EecWbS.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BQoCPk3x.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-CDgI-YZF.js → capability-header-actions-BasrAWA0.js} +1 -1
- package/dist/gateway/static/root/assets/channels-BKf_-Mdt.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CUkCx_9x.js → chat-terminal-dock-CwQbzcZ_.js} +2 -2
- package/dist/gateway/static/root/assets/chevron-down-ccbiQQz_.js +1 -0
- package/dist/gateway/static/root/assets/computer-settings-page-DNWeJKfF.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-49mgdRET.js → connector-service-page-CxHgC5RM.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CUBg8spT.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-BpBjADAk.js → date-picker-CXxLbLJb.js} +1 -1
- package/dist/gateway/static/root/assets/dependency-picker-DVuWMrSj.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-KbVLtAlO.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-settings-BDlg9g4s.js +1 -0
- package/dist/gateway/static/root/assets/device-pairing-wizard-PmP_vGem.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DwXqp_iu.js → directory-picker-path-field-a7xEodzo.js} +1 -1
- package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
- package/dist/gateway/static/root/assets/extension-debug-page-CHelH5u_.js +1 -0
- package/dist/gateway/static/root/assets/{extension-page-Bri62YsN.js → extension-page-CrVHmS9-.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-CiMybi0r.js +1 -0
- package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
- package/dist/gateway/static/root/assets/folder-open-CyzJ19I9.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-BVqYVaGy.js → gateway-config-swr-DF_HV6NP.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-CY1LBGBS.js → gateway-realtime-DMAzNlm-.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-CoIgC1Al.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-DnrQ28E2.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CPKGkr6D.js → gateway-startup-retry-B91CBTzO.js} +1 -1
- package/dist/gateway/static/root/assets/highlight-code-AMjU04kR.js +1 -0
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-Ci1QpkBn.js → highlighted-body-KQOG7T2V-8ACAVktj.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-pTwVME-g.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-N5MYXlxr.js → image-generation-api-CVBaWmrV.js} +1 -1
- package/dist/gateway/static/root/assets/imports-page-C5IP3e6d.js +1 -0
- package/dist/gateway/static/root/assets/index-BLL0wKRZ.css +1 -0
- package/dist/gateway/static/root/assets/index-ygkHNYyo.js +710 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BhU6VYvd.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-Cwl6EvuX.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-BjzaB1ls.js → local-apps-page-DcP1Bdlk.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-BCaC-1rH.js → local-session-drafts-DvmwiLUx.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DAgpZxAS.js → locale-store-JogcXC4J.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CS3hcTOq.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-DC-Y_-GP.js +1 -0
- package/dist/gateway/static/root/assets/{media-plugins-8mlDAjD6.js → media-plugins-BnPpcJ2J.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-vckgHpON.js +1 -0
- package/dist/gateway/static/root/assets/{messages-DMXSIJUO.js → messages-RzwPiQNL.js} +2 -2
- package/dist/gateway/static/root/assets/note-detail-panel-C7u4dxEk.js +5 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-jvqYtySx.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-Bs7F5Hpf.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-DO_yhXS1.js +1 -0
- package/dist/gateway/static/root/assets/personal-page-BexL2-PQ.js +1 -0
- package/dist/gateway/static/root/assets/personal-settings-panel-BKA4fbYH.js +1 -0
- package/dist/gateway/static/root/assets/phone-dependencies-card-ChFtdFhA.js +1 -0
- package/dist/gateway/static/root/assets/phone-model-picker-CZoIAQ1j.js +1 -0
- package/dist/gateway/static/root/assets/phone-settings-page-DRyK0nHH.js +1 -0
- package/dist/gateway/static/root/assets/plugin-details-dialog-B-N61jJH.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-n6Shdp3u.js → preview-open-alternatives-FGqN-mQx.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BPF5rRTI.js → product-open-page-CwnHLfdL.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-BOsGPNbw.js → product-preview-content-BD6k5hF9.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DtKmFBml.js +7 -0
- package/dist/gateway/static/root/assets/projects-page-CFZIz9mc.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-B6kqbuw8.js → registry-api-BGqSwITi.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CWEc7W0m.js +1 -0
- package/dist/gateway/static/root/assets/runtime-tools-api-CSm5SpnR.js +5 -0
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-q_oswAdV.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-cXD1BC02.js → schema-form-DoVn5jJK.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-D6-Vz8xK.js → session-api-DTxZyMta.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-DWbcMHcj.js → session-manager-B2HDomj4.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BuPqNxpd.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-QTVDCGJG.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BXeszXR7.js → settings-form-section-Ce8vVv-9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CNmh4YmR.js → settings-page-DP2w3ejC.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-Dx5S-Msc.js → settings-page-header-CYpuTXUW.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-layout-B20AfmFG.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-ZmlE8jIE.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CS9cOCgX.js → share-preview-page-DV4dKrmG.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CtNxWqW-.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-B5lDCuOH.js → skill-api-DTdejInH.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Egaf8PqZ.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-C6FKxf4J.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-Baxkhov7.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-C77-rpkt.js +2 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-HJO1BlJm.js → task-result-evidence-DIGSC4qF.js} +1 -1
- package/dist/gateway/static/root/assets/tracing-settings-page-BaU8frtc.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DXU94F2Y.js → tunnel-api-BCcOUsqu.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-BFeIbpbi.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-B1z_TIBu.js → use-autosave-C1X47WVb.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-u8zY5jea.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-HOLjEhh3.js → voice-api-key-field-Bk4DQMTw.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CPKzUb4R.js → voice-config-api-D7xsWrdh.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-C9RklDaR.js → work-discovery-overlay-B7_NmTB5.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-CWwGTBib.js → xopc-cloud-account-card-CJ_akAvc.js} +1 -1
- package/dist/gateway/static/root/index.html +19 -14
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/capabilities.js +1 -0
- package/dist/src/agent/background-review/prompts.js +4 -3
- package/dist/src/agent/embedded/run-turn.js +1 -1
- package/dist/src/agent/embedded/xopc-stream-bridge.js +7 -3
- package/dist/src/agent/prompt/system-prompt.js +1 -1
- package/dist/src/agent/tool-manuals/index.js +7 -0
- package/dist/src/agent/tool-manuals/phone.d.ts +1 -0
- package/dist/src/agent/tool-manuals/phone.js +16 -0
- package/dist/src/agent/tools/factory.js +15 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +1 -1
- package/dist/src/agent/tools/personal-task-tool.d.ts +2 -1
- package/dist/src/agent/tools/personal-task-tool.js +43 -20
- package/dist/src/agent/tools/phone-use-tool.d.ts +8 -0
- package/dist/src/agent/tools/phone-use-tool.js +49 -0
- package/dist/src/agent/tools/session-recall-tool.js +2 -1
- package/dist/src/agent/tools/session-search-tool.js +11 -5
- package/dist/src/agent/tools/user-context-tool.js +1 -1
- package/dist/src/agent-config/index.js +2 -2
- package/dist/src/agent-config/resolver.js +5 -0
- package/dist/src/agent-config/schema.d.ts +24 -0
- package/dist/src/agent-config/schema.js +5 -2
- package/dist/src/cli/command-manifest.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension.js +2 -2
- package/dist/src/cli/commands/runtime.js +32 -4
- package/dist/src/computer/diagnostics.d.ts +1 -1
- package/dist/src/config/models-json.d.ts +36 -0
- package/dist/src/config/models-json.js +9 -0
- package/dist/src/config/schema.d.ts +12 -0
- package/dist/src/config/schema.js +6 -2
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +7 -1
- package/dist/src/gateway/agent-builtin-tools.js +7 -0
- package/dist/src/gateway/global-defaults-admin.js +2 -0
- package/dist/src/gateway/hono/lib/config-payload.d.ts +8 -0
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/models.js +3 -0
- package/dist/src/gateway/hono/routes/phone-dependencies.d.ts +3 -0
- package/dist/src/gateway/hono/routes/phone-dependencies.js +137 -0
- package/dist/src/gateway/hono/routes/phone.d.ts +4 -0
- package/dist/src/gateway/hono/routes/phone.js +466 -0
- package/dist/src/gateway/hono/routes/runtime-tools.js +2 -0
- package/dist/src/gateway/server.js +1 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +8 -0
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.d.ts +2 -0
- package/dist/src/gateway/service.js +12 -7
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/knowledge-memory/repository.js +5 -0
- package/dist/src/memory-learning/forget-capture.js +12 -3
- package/dist/src/memory-learning/forgotten-history.d.ts +4 -0
- package/dist/src/memory-learning/forgotten-history.js +71 -4
- package/dist/src/memory-learning/work-capture.d.ts +1 -0
- package/dist/src/memory-learning/work-capture.js +28 -17
- package/dist/src/personal-agent/prompts.js +3 -2
- package/dist/src/phone/adb-driver.d.ts +38 -0
- package/dist/src/phone/adb-driver.js +392 -0
- package/dist/src/phone/app-access.d.ts +10 -0
- package/dist/src/phone/app-access.js +21 -0
- package/dist/src/phone/applications.d.ts +4 -0
- package/dist/src/phone/applications.js +49 -0
- package/dist/src/phone/cloud-adb.d.ts +35 -0
- package/dist/src/phone/cloud-adb.js +273 -0
- package/dist/src/phone/cloud-phones.d.ts +29 -0
- package/dist/src/phone/cloud-phones.js +142 -0
- package/dist/src/phone/cloud-scrcpy.d.ts +20 -0
- package/dist/src/phone/cloud-scrcpy.js +123 -0
- package/dist/src/phone/contracts.d.ts +212 -0
- package/dist/src/phone/contracts.js +116 -0
- package/dist/src/phone/interactive-session.d.ts +34 -0
- package/dist/src/phone/interactive-session.js +164 -0
- package/dist/src/phone/live-provider.d.ts +57 -0
- package/dist/src/phone/live-provider.js +18 -0
- package/dist/src/phone/live-state.d.ts +28 -0
- package/dist/src/phone/live-state.js +71 -0
- package/dist/src/phone/model-adapter.d.ts +31 -0
- package/dist/src/phone/model-adapter.js +350 -0
- package/dist/src/phone/repository.d.ts +19 -0
- package/dist/src/phone/repository.js +101 -0
- package/dist/src/phone/runtime.d.ts +88 -0
- package/dist/src/phone/runtime.js +924 -0
- package/dist/src/phone/scrcpy-assets.d.ts +4 -0
- package/dist/src/phone/scrcpy-assets.js +16 -0
- package/dist/src/phone/scrcpy.d.ts +59 -0
- package/dist/src/phone/scrcpy.js +337 -0
- package/dist/src/phone/stream-gateway.d.ts +26 -0
- package/dist/src/phone/stream-gateway.js +210 -0
- package/dist/src/process/phone-process.d.ts +4 -0
- package/dist/src/process/phone-process.js +38 -0
- package/dist/src/providers/extension-stream-bridge.js +8 -1
- package/dist/src/providers/model-call.js +6 -2
- package/dist/src/providers/model-catalog-persistence.js +3 -0
- package/dist/src/providers/model-catalog-types.d.ts +3 -0
- package/dist/src/providers/model-reference-auditor.js +5 -1
- package/dist/src/providers/model-registry.js +3 -0
- package/dist/src/runtime-tools/archive.d.ts +2 -2
- package/dist/src/runtime-tools/downloader.d.ts +2 -2
- package/dist/src/runtime-tools/errors.d.ts +3 -3
- package/dist/src/runtime-tools/phone-dependencies.d.ts +40 -0
- package/dist/src/runtime-tools/phone-dependencies.js +188 -0
- package/dist/src/runtime-tools/phone-dependency-catalog.d.ts +16 -0
- package/dist/src/runtime-tools/phone-dependency-catalog.js +51 -0
- package/dist/src/runtime-tools/types.d.ts +1 -0
- package/dist/src/storage/sqlite/context-extraction-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/context-extraction-repository.js +12 -2
- package/dist/src/tasks/task-research-result.js +19 -2
- package/dist/src/usage/cloud-receipts.d.ts +5 -1
- package/dist/src/usage/cloud-receipts.js +10 -4
- package/dist/src/usage/cloud-wire.d.ts +37 -0
- package/dist/src/usage/cloud-wire.js +181 -0
- package/dist/src/usage/recorder.js +5 -4
- package/dist/src/user-model/capture/semantic.js +2 -2
- package/dist/src/voice/platform-catalog.d.ts +3 -0
- package/package.json +10 -5
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BjZpom5V.js +0 -1
- package/dist/gateway/static/root/assets/agents-s3ws5Qi-.js +0 -77
- package/dist/gateway/static/root/assets/app-management-settings-panel-C6DHuX0L.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-DYGY92Yr.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-PpT_YMmD.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-G6-9IYbR.js +0 -8
- package/dist/gateway/static/root/assets/browser-automations-page-o3jNFlCb.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-G0dVwiX4.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-B9b5KCBb.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-BZQanmZY.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D-YadSx_.js +0 -8
- package/dist/gateway/static/root/assets/channels-3WX3f0bR.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-CuZrL9gL.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Bjj2wAeG.js +0 -1
- package/dist/gateway/static/root/assets/dependency-picker-R8kdHLr3.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-BpiosRqb.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-9h6evrKB.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-CZ5lwiLE.js +0 -1
- package/dist/gateway/static/root/assets/extension-debug-page-Bj93A2Gn.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BSo6vRhS.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-Dafw95ol.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DgEwWJwz.js +0 -1
- package/dist/gateway/static/root/assets/highlight-code-CSFBakwF.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BKj-aPsL.js +0 -2
- package/dist/gateway/static/root/assets/imports-page-YfaRnpk1.js +0 -1
- package/dist/gateway/static/root/assets/index-CiDVRMmX.js +0 -710
- package/dist/gateway/static/root/assets/index-caRW34rg.css +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BTQcPOix.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-kCZ_fbSZ.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-5Jt3uqYt.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-DOQMLPrI.js +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-B4nztFE4.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-1wsKlkk3.js +0 -5
- package/dist/gateway/static/root/assets/note-image-lightbox-B82cToeV.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-DKREWOku.js +0 -8
- package/dist/gateway/static/root/assets/page-context-capture-button-oSJIFF3E.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-CoqQTkkS.js +0 -1
- package/dist/gateway/static/root/assets/personal-settings-panel-BgcJLmZN.js +0 -1
- package/dist/gateway/static/root/assets/plugin-details-dialog-CdOJ3Tir.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-ZADyvA7-.js +0 -7
- package/dist/gateway/static/root/assets/projects-page-BkRe6Z8S.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CCGf5kF4.js +0 -1
- package/dist/gateway/static/root/assets/runtime-tools-api-CY3R7unQ.js +0 -5
- package/dist/gateway/static/root/assets/runtime-tools-settings-panel-BxaxVlwM.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-B81rRu2-.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DLHGV-I-.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-gEqkJWyw.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-D9Ul96XW.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-NLAaNaDn.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-dWeFt-6J.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-DdDsFdCh.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DO3FM--W.js +0 -2
- package/dist/gateway/static/root/assets/tracing-settings-page-Dm3yToJ1.js +0 -1
- package/dist/gateway/static/root/assets/usage-page-DJJhACRJ.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-DnZ4qFaO.js +0 -2
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { PhoneError, init_contracts } from "./contracts.js";
|
|
2
|
+
import { SCRCPY_VERSION } from "../runtime-tools/phone-dependency-catalog.js";
|
|
3
|
+
import { readScrcpyServer } from "./scrcpy-assets.js";
|
|
4
|
+
import { ScrcpyProvider, ScrcpyVideoParser } from "./scrcpy.js";
|
|
5
|
+
import { CloudAdbConnection } from "./cloud-adb.js";
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
8
|
+
import { ReadableStream } from "@yume-chan/stream-extra";
|
|
9
|
+
//#region src/phone/cloud-scrcpy.ts
|
|
10
|
+
init_contracts();
|
|
11
|
+
/** Dedicated authenticated ADB transport: no host ADB key, server or port forwarding. */
|
|
12
|
+
var CloudScrcpyProvider = class extends ScrcpyProvider {
|
|
13
|
+
connection;
|
|
14
|
+
process;
|
|
15
|
+
video;
|
|
16
|
+
control;
|
|
17
|
+
writer;
|
|
18
|
+
remote = "";
|
|
19
|
+
scid = "";
|
|
20
|
+
constructor(endpoint, key, onFailure, connect = (address, credential) => new CloudAdbConnection(address, credential)) {
|
|
21
|
+
super(onFailure);
|
|
22
|
+
this.endpoint = endpoint;
|
|
23
|
+
this.connection = connect(endpoint, key);
|
|
24
|
+
}
|
|
25
|
+
foreground(signal) {
|
|
26
|
+
return this.connection.driver().foreground(this.endpoint, signal);
|
|
27
|
+
}
|
|
28
|
+
async startTransport() {
|
|
29
|
+
const timer = setTimeout(() => this.connection.close(), 2e4);
|
|
30
|
+
try {
|
|
31
|
+
const binary = await readScrcpyServer();
|
|
32
|
+
const adb = await this.connection.client();
|
|
33
|
+
if (this.closing) throw new Error("Video closed");
|
|
34
|
+
this.scid = (randomBytes(4).readUInt32BE() & 2147483647).toString(16);
|
|
35
|
+
const socketName = `scrcpy_${this.scid.padStart(8, "0")}`;
|
|
36
|
+
this.remote = `/data/local/tmp/xopc-${socketName}.jar`;
|
|
37
|
+
const sync = await adb.sync();
|
|
38
|
+
try {
|
|
39
|
+
await sync.write({
|
|
40
|
+
filename: this.remote,
|
|
41
|
+
permission: 384,
|
|
42
|
+
file: new ReadableStream({ start(controller) {
|
|
43
|
+
controller.enqueue(binary);
|
|
44
|
+
controller.close();
|
|
45
|
+
} })
|
|
46
|
+
});
|
|
47
|
+
} finally {
|
|
48
|
+
await sync.dispose();
|
|
49
|
+
}
|
|
50
|
+
if (this.closing) throw new Error("Video closed");
|
|
51
|
+
this.process = await adb.createSocket(`exec:CLASSPATH=${this.remote} app_process / com.genymobile.scrcpy.Server ${SCRCPY_VERSION} scid=${this.scid} tunnel_forward=true audio=false control=true cleanup=false max_size=960 max_fps=30 video_bit_rate=2000000 video_codec=h264 video_codec_options=i-frame-interval=1 send_dummy_byte=false send_device_meta=false send_codec_meta=true send_frame_meta=true clipboard_autosync=false`);
|
|
52
|
+
this.drain(this.process);
|
|
53
|
+
for (let attempt = 0; attempt < 60; attempt++) {
|
|
54
|
+
if (this.closing) throw new Error("Video closed");
|
|
55
|
+
try {
|
|
56
|
+
this.video = await adb.createSocket(`localabstract:${socketName}`);
|
|
57
|
+
break;
|
|
58
|
+
} catch {
|
|
59
|
+
await setTimeout$1(50);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!this.video) throw new Error("Scrcpy connection timed out");
|
|
63
|
+
this.control = await adb.createSocket(`localabstract:${socketName}`);
|
|
64
|
+
this.writer = this.control.writable.getWriter();
|
|
65
|
+
this.drain(this.control);
|
|
66
|
+
this.readVideo(this.video);
|
|
67
|
+
} finally {
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async drain(socket) {
|
|
72
|
+
try {
|
|
73
|
+
for await (const _chunk of socket.readable);
|
|
74
|
+
} catch {}
|
|
75
|
+
if (!this.closing) this.fail();
|
|
76
|
+
}
|
|
77
|
+
async readVideo(socket) {
|
|
78
|
+
const parser = new ScrcpyVideoParser();
|
|
79
|
+
try {
|
|
80
|
+
for await (const chunk of socket.readable) parser.push(Buffer.from(chunk), (packet) => this.packet(packet));
|
|
81
|
+
} catch {}
|
|
82
|
+
if (!this.closing) this.fail();
|
|
83
|
+
}
|
|
84
|
+
async write(buffer) {
|
|
85
|
+
if (!this.writer) throw new PhoneError("PHONE_INPUT_DISCONNECTED", "Cloud phone input channel unavailable");
|
|
86
|
+
const timer = setTimeout(() => this.connection.close(), 2e3);
|
|
87
|
+
try {
|
|
88
|
+
await this.writer.write(buffer);
|
|
89
|
+
} finally {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async cleanup() {
|
|
94
|
+
try {
|
|
95
|
+
await this.revoke().catch(() => {});
|
|
96
|
+
this.writer?.releaseLock();
|
|
97
|
+
this.writer = void 0;
|
|
98
|
+
await Promise.allSettled([
|
|
99
|
+
this.video?.close(),
|
|
100
|
+
this.control?.close(),
|
|
101
|
+
this.process?.close()
|
|
102
|
+
]);
|
|
103
|
+
if (this.scid) {
|
|
104
|
+
const command = (...args) => this.connection.command("", [
|
|
105
|
+
"-s",
|
|
106
|
+
this.endpoint,
|
|
107
|
+
"shell",
|
|
108
|
+
...args
|
|
109
|
+
], void 0, 3e3);
|
|
110
|
+
const processes = await command("ps", "-A", "-o", "PID,ARGS").catch(() => Buffer.alloc(0));
|
|
111
|
+
for (const line of processes.toString().split("\n")) {
|
|
112
|
+
const pid = /^\s*(\d+)\s+/.exec(line)?.[1];
|
|
113
|
+
if (pid && line.includes("com.genymobile.scrcpy.Server ") && new RegExp(`(?:^|\\s)scid=${this.scid}(?:\\s|$)`).test(line)) await command("kill", "-TERM", pid).catch(() => {});
|
|
114
|
+
}
|
|
115
|
+
if (this.remote) await command("rm", "-f", this.remote).catch(() => {});
|
|
116
|
+
}
|
|
117
|
+
} finally {
|
|
118
|
+
this.connection.dispose();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { CloudScrcpyProvider };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PhoneProfileSchema: z.ZodEnum<{
|
|
3
|
+
"autoglm-phone-v1": "autoglm-phone-v1";
|
|
4
|
+
"structured-phone-v1": "structured-phone-v1";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const PhoneModelMetadataSchema: z.ZodObject<{
|
|
7
|
+
profile: z.ZodEnum<{
|
|
8
|
+
"autoglm-phone-v1": "autoglm-phone-v1";
|
|
9
|
+
"structured-phone-v1": "structured-phone-v1";
|
|
10
|
+
}>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const MOCK_PHONE_MODEL = "phone-mock/settings-about";
|
|
13
|
+
export declare const MOCK_PHONE_GOAL = "Open Android Settings and inspect About phone";
|
|
14
|
+
export declare const PhoneConfigSchema: z.ZodPrefault<z.ZodObject<{
|
|
15
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
adbPath: z.ZodOptional<z.ZodString>;
|
|
17
|
+
maxActionsPerSession: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
maxModelRequests: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
maxOperationDurationMs: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
maxSessionDurationMs: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
}, z.core.$strict>>;
|
|
22
|
+
export type PhoneConfig = z.infer<typeof PhoneConfigSchema>;
|
|
23
|
+
export declare const PhoneDeviceSchema: z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
serial: z.ZodString;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
28
|
+
appAccess: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
all: "all";
|
|
30
|
+
selected: "selected";
|
|
31
|
+
}>>;
|
|
32
|
+
allowedApps: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
33
|
+
connection: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
kind: z.ZodLiteral<"aliyun-adb">;
|
|
35
|
+
endpoint: z.ZodString;
|
|
36
|
+
credentialId: z.ZodString;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
createdAt: z.ZodNumber;
|
|
39
|
+
revision: z.ZodNumber;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
export type PhoneDevice = z.infer<typeof PhoneDeviceSchema>;
|
|
42
|
+
export type PhoneApplication = {
|
|
43
|
+
packageName: string;
|
|
44
|
+
label: string;
|
|
45
|
+
};
|
|
46
|
+
export type DiscoveredPhone = {
|
|
47
|
+
serial: string;
|
|
48
|
+
state: string;
|
|
49
|
+
name: string;
|
|
50
|
+
emulator: boolean;
|
|
51
|
+
};
|
|
52
|
+
export declare const PhoneActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"launch">;
|
|
54
|
+
package: z.ZodString;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"tap">;
|
|
57
|
+
point: z.ZodArray<z.ZodNumber>;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"doubleTap">;
|
|
60
|
+
point: z.ZodArray<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
+
type: z.ZodLiteral<"longPress">;
|
|
63
|
+
point: z.ZodArray<z.ZodNumber>;
|
|
64
|
+
durationMs: z.ZodDefault<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
type: z.ZodLiteral<"swipe">;
|
|
67
|
+
start: z.ZodArray<z.ZodNumber>;
|
|
68
|
+
end: z.ZodArray<z.ZodNumber>;
|
|
69
|
+
durationMs: z.ZodDefault<z.ZodNumber>;
|
|
70
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
71
|
+
type: z.ZodLiteral<"typeText">;
|
|
72
|
+
text: z.ZodString;
|
|
73
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
74
|
+
type: z.ZodEnum<{
|
|
75
|
+
home: "home";
|
|
76
|
+
back: "back";
|
|
77
|
+
}>;
|
|
78
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"wait">;
|
|
80
|
+
durationMs: z.ZodNumber;
|
|
81
|
+
}, z.core.$strict>], "type">;
|
|
82
|
+
export type PhoneAction = z.infer<typeof PhoneActionSchema>;
|
|
83
|
+
export declare const PhoneDecisionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
84
|
+
kind: z.ZodLiteral<"action">;
|
|
85
|
+
action: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
86
|
+
type: z.ZodLiteral<"launch">;
|
|
87
|
+
package: z.ZodString;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"tap">;
|
|
90
|
+
point: z.ZodArray<z.ZodNumber>;
|
|
91
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
92
|
+
type: z.ZodLiteral<"doubleTap">;
|
|
93
|
+
point: z.ZodArray<z.ZodNumber>;
|
|
94
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
95
|
+
type: z.ZodLiteral<"longPress">;
|
|
96
|
+
point: z.ZodArray<z.ZodNumber>;
|
|
97
|
+
durationMs: z.ZodDefault<z.ZodNumber>;
|
|
98
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
99
|
+
type: z.ZodLiteral<"swipe">;
|
|
100
|
+
start: z.ZodArray<z.ZodNumber>;
|
|
101
|
+
end: z.ZodArray<z.ZodNumber>;
|
|
102
|
+
durationMs: z.ZodDefault<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
104
|
+
type: z.ZodLiteral<"typeText">;
|
|
105
|
+
text: z.ZodString;
|
|
106
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
107
|
+
type: z.ZodEnum<{
|
|
108
|
+
home: "home";
|
|
109
|
+
back: "back";
|
|
110
|
+
}>;
|
|
111
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
112
|
+
type: z.ZodLiteral<"wait">;
|
|
113
|
+
durationMs: z.ZodNumber;
|
|
114
|
+
}, z.core.$strict>], "type">;
|
|
115
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
116
|
+
kind: z.ZodLiteral<"complete">;
|
|
117
|
+
summary: z.ZodString;
|
|
118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
119
|
+
kind: z.ZodLiteral<"needsUser">;
|
|
120
|
+
reason: z.ZodString;
|
|
121
|
+
}, z.core.$strict>], "kind">;
|
|
122
|
+
export type PhoneDecision = z.infer<typeof PhoneDecisionSchema>;
|
|
123
|
+
export type PhoneElement = {
|
|
124
|
+
text: string;
|
|
125
|
+
description: string;
|
|
126
|
+
resourceId: string;
|
|
127
|
+
clickable: boolean;
|
|
128
|
+
focused: boolean;
|
|
129
|
+
password: boolean;
|
|
130
|
+
editable?: boolean;
|
|
131
|
+
bounds: [number, number, number, number];
|
|
132
|
+
};
|
|
133
|
+
export type PhoneObservation = {
|
|
134
|
+
frameId: string;
|
|
135
|
+
capturedAt: number;
|
|
136
|
+
width: number;
|
|
137
|
+
height: number;
|
|
138
|
+
rotation: number;
|
|
139
|
+
package: string;
|
|
140
|
+
frame: Buffer;
|
|
141
|
+
elements: PhoneElement[];
|
|
142
|
+
};
|
|
143
|
+
export declare const PhoneInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
144
|
+
op: z.ZodLiteral<"discover">;
|
|
145
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
146
|
+
op: z.ZodLiteral<"open">;
|
|
147
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
148
|
+
mode: z.ZodEnum<{
|
|
149
|
+
observe: "observe";
|
|
150
|
+
control: "control";
|
|
151
|
+
}>;
|
|
152
|
+
appPackage: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
154
|
+
op: z.ZodLiteral<"observe">;
|
|
155
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
156
|
+
op: z.ZodEnum<{
|
|
157
|
+
run: "run";
|
|
158
|
+
step: "step";
|
|
159
|
+
}>;
|
|
160
|
+
goal: z.ZodString;
|
|
161
|
+
scenario: z.ZodOptional<z.ZodLiteral<"settings-about">>;
|
|
162
|
+
expectText: z.ZodOptional<z.ZodString>;
|
|
163
|
+
maxActions: z.ZodDefault<z.ZodNumber>;
|
|
164
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
165
|
+
op: z.ZodEnum<{
|
|
166
|
+
cancel: "cancel";
|
|
167
|
+
status: "status";
|
|
168
|
+
close: "close";
|
|
169
|
+
pause: "pause";
|
|
170
|
+
resume: "resume";
|
|
171
|
+
}>;
|
|
172
|
+
}, z.core.$strict>], "op">;
|
|
173
|
+
export type PhoneInput = z.infer<typeof PhoneInputSchema>;
|
|
174
|
+
export type PhoneStatus = 'ready' | 'running' | 'paused' | 'needs_user' | 'completed' | 'cancelled' | 'closed' | 'failed' | 'outcome_unknown';
|
|
175
|
+
export type PhoneReport = {
|
|
176
|
+
sessionId: string;
|
|
177
|
+
deviceId: string;
|
|
178
|
+
deviceName: string;
|
|
179
|
+
owner: string;
|
|
180
|
+
agentId: string;
|
|
181
|
+
modelRef: string;
|
|
182
|
+
mock: boolean;
|
|
183
|
+
mode: 'observe' | 'control';
|
|
184
|
+
status: PhoneStatus;
|
|
185
|
+
actions: number;
|
|
186
|
+
humanActions?: number;
|
|
187
|
+
modelRequests: number;
|
|
188
|
+
createdAt: number;
|
|
189
|
+
updatedAt: number;
|
|
190
|
+
verified: boolean;
|
|
191
|
+
verificationLevel: 'none' | 'ui';
|
|
192
|
+
stopReason?: string;
|
|
193
|
+
errorCode?: string;
|
|
194
|
+
facts?: string[];
|
|
195
|
+
foregroundApp?: string;
|
|
196
|
+
message?: string;
|
|
197
|
+
steps: Array<{
|
|
198
|
+
action: PhoneAction['type'];
|
|
199
|
+
at: number;
|
|
200
|
+
dispatch: 'completed' | 'unknown';
|
|
201
|
+
actor?: 'agent' | 'human';
|
|
202
|
+
}>;
|
|
203
|
+
controlOwner?: 'agent' | 'human' | 'none';
|
|
204
|
+
controlEpoch?: number;
|
|
205
|
+
handoff?: 'idle' | 'acquiring' | 'returning';
|
|
206
|
+
currentAction?: PhoneAction['type'];
|
|
207
|
+
};
|
|
208
|
+
export declare class PhoneError extends Error {
|
|
209
|
+
readonly code: string;
|
|
210
|
+
readonly status: 400 | 403 | 404 | 409 | 500 | 502;
|
|
211
|
+
constructor(code: string, message: string, status?: 400 | 403 | 404 | 409 | 500 | 502);
|
|
212
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/phone/contracts.ts
|
|
4
|
+
var PhoneProfileSchema, PhoneModelMetadataSchema, MOCK_PHONE_MODEL, MOCK_PHONE_GOAL, PhoneConfigSchema, PhoneDeviceSchema, Point, PhoneActionSchema, PhoneDecisionSchema, PhoneInputSchema, PhoneError;
|
|
5
|
+
var init_contracts = __esmMin((() => {
|
|
6
|
+
PhoneProfileSchema = z.enum(["autoglm-phone-v1", "structured-phone-v1"]);
|
|
7
|
+
PhoneModelMetadataSchema = z.object({ profile: PhoneProfileSchema }).strict();
|
|
8
|
+
MOCK_PHONE_MODEL = "phone-mock/settings-about";
|
|
9
|
+
MOCK_PHONE_GOAL = "Open Android Settings and inspect About phone";
|
|
10
|
+
PhoneConfigSchema = z.object({
|
|
11
|
+
enabled: z.boolean().default(false),
|
|
12
|
+
adbPath: z.string().min(1).optional(),
|
|
13
|
+
maxActionsPerSession: z.number().int().min(1).max(80).default(40),
|
|
14
|
+
maxModelRequests: z.number().int().min(1).max(120).default(60),
|
|
15
|
+
maxOperationDurationMs: z.number().int().min(1e3).max(9e5).default(3e5),
|
|
16
|
+
maxSessionDurationMs: z.number().int().min(1e3).max(9e5).default(9e5)
|
|
17
|
+
}).strict().prefault({});
|
|
18
|
+
PhoneDeviceSchema = z.object({
|
|
19
|
+
id: z.string().uuid(),
|
|
20
|
+
serial: z.string().min(1).max(200),
|
|
21
|
+
name: z.string().trim().min(1).max(100),
|
|
22
|
+
enabled: z.boolean().default(true),
|
|
23
|
+
appAccess: z.enum(["all", "selected"]).optional(),
|
|
24
|
+
allowedApps: z.array(z.string().regex(/^[a-zA-Z][\w]*(?:\.[\w]+)+$/)).max(500).default([]),
|
|
25
|
+
connection: z.object({
|
|
26
|
+
kind: z.literal("aliyun-adb"),
|
|
27
|
+
endpoint: z.string().max(200),
|
|
28
|
+
credentialId: z.string().uuid()
|
|
29
|
+
}).strict().optional(),
|
|
30
|
+
createdAt: z.number(),
|
|
31
|
+
revision: z.number().int().positive()
|
|
32
|
+
}).strict();
|
|
33
|
+
Point = z.array(z.number().finite().min(0).max(1e3)).length(2);
|
|
34
|
+
PhoneActionSchema = z.discriminatedUnion("type", [
|
|
35
|
+
z.object({
|
|
36
|
+
type: z.literal("launch"),
|
|
37
|
+
package: z.string().regex(/^[a-zA-Z][\w]*(?:\.[\w]+)+$/)
|
|
38
|
+
}).strict(),
|
|
39
|
+
z.object({
|
|
40
|
+
type: z.literal("tap"),
|
|
41
|
+
point: Point
|
|
42
|
+
}).strict(),
|
|
43
|
+
z.object({
|
|
44
|
+
type: z.literal("doubleTap"),
|
|
45
|
+
point: Point
|
|
46
|
+
}).strict(),
|
|
47
|
+
z.object({
|
|
48
|
+
type: z.literal("longPress"),
|
|
49
|
+
point: Point,
|
|
50
|
+
durationMs: z.number().int().min(100).max(3e3).default(800)
|
|
51
|
+
}).strict(),
|
|
52
|
+
z.object({
|
|
53
|
+
type: z.literal("swipe"),
|
|
54
|
+
start: Point,
|
|
55
|
+
end: Point,
|
|
56
|
+
durationMs: z.number().int().min(100).max(2e3).default(500)
|
|
57
|
+
}).strict(),
|
|
58
|
+
z.object({
|
|
59
|
+
type: z.literal("typeText"),
|
|
60
|
+
text: z.string().min(1).max(4e3)
|
|
61
|
+
}).strict(),
|
|
62
|
+
z.object({ type: z.enum(["back", "home"]) }).strict(),
|
|
63
|
+
z.object({
|
|
64
|
+
type: z.literal("wait"),
|
|
65
|
+
durationMs: z.number().int().min(100).max(3e3)
|
|
66
|
+
}).strict()
|
|
67
|
+
]);
|
|
68
|
+
PhoneDecisionSchema = z.discriminatedUnion("kind", [
|
|
69
|
+
z.object({
|
|
70
|
+
kind: z.literal("action"),
|
|
71
|
+
action: PhoneActionSchema
|
|
72
|
+
}).strict(),
|
|
73
|
+
z.object({
|
|
74
|
+
kind: z.literal("complete"),
|
|
75
|
+
summary: z.string().max(1e3)
|
|
76
|
+
}).strict(),
|
|
77
|
+
z.object({
|
|
78
|
+
kind: z.literal("needsUser"),
|
|
79
|
+
reason: z.string().max(1e3)
|
|
80
|
+
}).strict()
|
|
81
|
+
]);
|
|
82
|
+
PhoneInputSchema = z.discriminatedUnion("op", [
|
|
83
|
+
z.object({ op: z.literal("discover") }).strict(),
|
|
84
|
+
z.object({
|
|
85
|
+
op: z.literal("open"),
|
|
86
|
+
deviceId: z.string().uuid().optional(),
|
|
87
|
+
mode: z.enum(["observe", "control"]),
|
|
88
|
+
appPackage: z.string().regex(/^[a-zA-Z][\w]*(?:\.[\w]+)+$/).optional()
|
|
89
|
+
}).strict(),
|
|
90
|
+
z.object({ op: z.literal("observe") }).strict(),
|
|
91
|
+
z.object({
|
|
92
|
+
op: z.enum(["run", "step"]),
|
|
93
|
+
goal: z.string().trim().min(1).max(2e3),
|
|
94
|
+
scenario: z.literal("settings-about").optional(),
|
|
95
|
+
expectText: z.string().min(1).max(200).optional(),
|
|
96
|
+
maxActions: z.number().int().min(1).max(12).default(6)
|
|
97
|
+
}).strict(),
|
|
98
|
+
z.object({ op: z.enum([
|
|
99
|
+
"status",
|
|
100
|
+
"pause",
|
|
101
|
+
"resume",
|
|
102
|
+
"cancel",
|
|
103
|
+
"close"
|
|
104
|
+
]) }).strict()
|
|
105
|
+
]);
|
|
106
|
+
PhoneError = class extends Error {
|
|
107
|
+
constructor(code, message, status = 400) {
|
|
108
|
+
super(message);
|
|
109
|
+
this.code = code;
|
|
110
|
+
this.status = status;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}));
|
|
114
|
+
//#endregion
|
|
115
|
+
init_contracts();
|
|
116
|
+
export { MOCK_PHONE_GOAL, MOCK_PHONE_MODEL, PhoneActionSchema, PhoneConfigSchema, PhoneDecisionSchema, PhoneDeviceSchema, PhoneError, PhoneInputSchema, PhoneModelMetadataSchema, PhoneProfileSchema, init_contracts };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PhoneInteractiveProvider, PhonePointer, PhoneVideoPacket } from './live-provider.js';
|
|
2
|
+
/** Shared device source with bounded video gating and ordered, fenced input. */
|
|
3
|
+
export declare class PhoneInteractiveSession {
|
|
4
|
+
readonly provider: PhoneInteractiveProvider;
|
|
5
|
+
private checkScreen;
|
|
6
|
+
private authorize;
|
|
7
|
+
private onGesture;
|
|
8
|
+
private viewers;
|
|
9
|
+
private queue;
|
|
10
|
+
private pending;
|
|
11
|
+
private seq;
|
|
12
|
+
private packets;
|
|
13
|
+
private bytes;
|
|
14
|
+
private checkedAt;
|
|
15
|
+
private allowed;
|
|
16
|
+
private closed;
|
|
17
|
+
private timer?;
|
|
18
|
+
private unsubscribe?;
|
|
19
|
+
private config?;
|
|
20
|
+
private started?;
|
|
21
|
+
private gesture?;
|
|
22
|
+
private verification?;
|
|
23
|
+
constructor(provider: PhoneInteractiveProvider, checkScreen: () => Promise<void>, authorize: (client: string, epoch: number) => void, onGesture?: (action: 'tap' | 'longPress' | 'swipe') => void);
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
private verifyScreen;
|
|
26
|
+
private poll;
|
|
27
|
+
subscribe(client: string, packet: (packet: PhoneVideoPacket) => void, fault: (code: string) => void): () => void;
|
|
28
|
+
input(client: string, input: PhonePointer): Promise<void>;
|
|
29
|
+
revoke(): Promise<void>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
get viewerCount(): number;
|
|
32
|
+
verifyGeometry(version: number): boolean;
|
|
33
|
+
authorizeClient(client: string, epoch: number): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { PhoneError, init_contracts } from "./contracts.js";
|
|
2
|
+
//#region src/phone/interactive-session.ts
|
|
3
|
+
init_contracts();
|
|
4
|
+
/** Shared device source with bounded video gating and ordered, fenced input. */
|
|
5
|
+
var PhoneInteractiveSession = class {
|
|
6
|
+
viewers = /* @__PURE__ */ new Map();
|
|
7
|
+
queue = Promise.resolve();
|
|
8
|
+
pending = 0;
|
|
9
|
+
seq = /* @__PURE__ */ new Map();
|
|
10
|
+
packets = [];
|
|
11
|
+
bytes = 0;
|
|
12
|
+
checkedAt = 0;
|
|
13
|
+
allowed = false;
|
|
14
|
+
closed = false;
|
|
15
|
+
timer;
|
|
16
|
+
unsubscribe;
|
|
17
|
+
config;
|
|
18
|
+
started;
|
|
19
|
+
gesture;
|
|
20
|
+
verification;
|
|
21
|
+
constructor(provider, checkScreen, authorize, onGesture = () => {}) {
|
|
22
|
+
this.provider = provider;
|
|
23
|
+
this.checkScreen = checkScreen;
|
|
24
|
+
this.authorize = authorize;
|
|
25
|
+
this.onGesture = onGesture;
|
|
26
|
+
}
|
|
27
|
+
start() {
|
|
28
|
+
return this.started ??= (async () => {
|
|
29
|
+
await this.checkScreen();
|
|
30
|
+
this.checkedAt = Date.now();
|
|
31
|
+
this.allowed = true;
|
|
32
|
+
this.unsubscribe = this.provider.subscribe((packet) => {
|
|
33
|
+
if (packet.config) this.config = packet;
|
|
34
|
+
this.packets.push(packet);
|
|
35
|
+
this.bytes += packet.data.length;
|
|
36
|
+
if (this.bytes > 2 * 1024 * 1024) {
|
|
37
|
+
this.packets = [];
|
|
38
|
+
this.bytes = 0;
|
|
39
|
+
for (const viewer of this.viewers.values()) viewer.key = false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
await this.provider.start();
|
|
43
|
+
this.poll();
|
|
44
|
+
})();
|
|
45
|
+
}
|
|
46
|
+
verifyScreen() {
|
|
47
|
+
return this.verification ??= this.checkScreen().then(() => {
|
|
48
|
+
this.checkedAt = Date.now();
|
|
49
|
+
this.allowed = true;
|
|
50
|
+
}, (error) => {
|
|
51
|
+
this.allowed = false;
|
|
52
|
+
throw error;
|
|
53
|
+
}).finally(() => {
|
|
54
|
+
this.verification = void 0;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async poll() {
|
|
58
|
+
if (this.closed) return;
|
|
59
|
+
const packets = this.packets;
|
|
60
|
+
this.packets = [];
|
|
61
|
+
this.bytes = 0;
|
|
62
|
+
try {
|
|
63
|
+
const wasAllowed = this.allowed;
|
|
64
|
+
await this.verifyScreen();
|
|
65
|
+
if (this.closed) return;
|
|
66
|
+
if (!wasAllowed) this.provider.refresh();
|
|
67
|
+
for (const packet of packets) for (const viewer of this.viewers.values()) {
|
|
68
|
+
if (packet.geometry && packet.geometry.version !== this.provider.geometry.version) continue;
|
|
69
|
+
if (packet.config) {
|
|
70
|
+
viewer.key = false;
|
|
71
|
+
viewer.packet(packet);
|
|
72
|
+
} else if (packet.key || viewer.key) {
|
|
73
|
+
if (!viewer.key && this.config) viewer.packet(this.config);
|
|
74
|
+
viewer.key = true;
|
|
75
|
+
viewer.packet(packet);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
this.allowed = false;
|
|
80
|
+
this.packets = [];
|
|
81
|
+
this.bytes = 0;
|
|
82
|
+
await this.revoke().catch(() => {});
|
|
83
|
+
const code = error instanceof PhoneError ? error.code : "PHONE_VIDEO_DISCONNECTED";
|
|
84
|
+
for (const viewer of this.viewers.values()) {
|
|
85
|
+
viewer.key = false;
|
|
86
|
+
viewer.fault(code);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!this.closed) this.timer = setTimeout(() => void this.poll(), 35);
|
|
90
|
+
}
|
|
91
|
+
subscribe(client, packet, fault) {
|
|
92
|
+
if (this.viewers.has(client) || this.viewers.size >= 4) throw new PhoneError("PHONE_VIEW_BUSY", "Phone viewer connection limit reached", 409);
|
|
93
|
+
this.viewers.set(client, {
|
|
94
|
+
packet,
|
|
95
|
+
fault,
|
|
96
|
+
key: false
|
|
97
|
+
});
|
|
98
|
+
this.provider.refresh();
|
|
99
|
+
return () => {
|
|
100
|
+
this.viewers.delete(client);
|
|
101
|
+
this.seq.delete(client);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
input(client, input) {
|
|
105
|
+
this.authorize(client, input.epoch);
|
|
106
|
+
if (this.closed || !this.allowed) throw new PhoneError("PHONE_SCREEN_UNVERIFIED", "Wait for an authorized phone frame", 409);
|
|
107
|
+
if (input.seq <= (this.seq.get(client) ?? 0)) throw new PhoneError("PHONE_INPUT_SEQUENCE", "Stale input sequence", 409);
|
|
108
|
+
if (this.pending >= 8) throw new PhoneError("PHONE_INPUT_BACKPRESSURE", "Input queue full; release and start a new gesture", 409);
|
|
109
|
+
this.seq.set(client, input.seq);
|
|
110
|
+
this.pending++;
|
|
111
|
+
const work = this.queue.catch(() => {}).then(async () => {
|
|
112
|
+
this.authorize(client, input.epoch);
|
|
113
|
+
if (Date.now() - this.checkedAt > 300) await this.verifyScreen();
|
|
114
|
+
this.authorize(client, input.epoch);
|
|
115
|
+
if (!this.allowed || this.closed) throw new PhoneError("PHONE_APP_DENIED", "Phone screen is unavailable", 403);
|
|
116
|
+
await this.provider.pointer(input);
|
|
117
|
+
if (input.phase === "down") this.gesture = {
|
|
118
|
+
x: input.x,
|
|
119
|
+
y: input.y,
|
|
120
|
+
at: Date.now()
|
|
121
|
+
};
|
|
122
|
+
else if (input.phase === "up" || input.phase === "cancel") {
|
|
123
|
+
const start = this.gesture;
|
|
124
|
+
this.gesture = void 0;
|
|
125
|
+
if (start) this.onGesture(Math.hypot(start.x - input.x, start.y - input.y) > 18 ? "swipe" : Date.now() - start.at > 600 ? "longPress" : "tap");
|
|
126
|
+
}
|
|
127
|
+
}).finally(() => {
|
|
128
|
+
this.pending--;
|
|
129
|
+
});
|
|
130
|
+
this.queue = work;
|
|
131
|
+
return work;
|
|
132
|
+
}
|
|
133
|
+
async revoke() {
|
|
134
|
+
const work = this.queue.catch(() => {}).then(async () => {
|
|
135
|
+
await this.provider.revoke();
|
|
136
|
+
this.gesture = void 0;
|
|
137
|
+
});
|
|
138
|
+
this.queue = work;
|
|
139
|
+
await work;
|
|
140
|
+
}
|
|
141
|
+
async close() {
|
|
142
|
+
if (this.closed) return;
|
|
143
|
+
this.closed = true;
|
|
144
|
+
clearTimeout(this.timer);
|
|
145
|
+
await this.revoke().catch(() => {});
|
|
146
|
+
this.unsubscribe?.();
|
|
147
|
+
for (const viewer of this.viewers.values()) viewer.fault("PHONE_VIDEO_ENDED");
|
|
148
|
+
this.viewers.clear();
|
|
149
|
+
this.packets = [];
|
|
150
|
+
this.config = void 0;
|
|
151
|
+
await this.provider.close();
|
|
152
|
+
}
|
|
153
|
+
get viewerCount() {
|
|
154
|
+
return this.viewers.size;
|
|
155
|
+
}
|
|
156
|
+
verifyGeometry(version) {
|
|
157
|
+
return this.allowed && Date.now() - this.checkedAt < 300 && version === this.provider.geometry.version;
|
|
158
|
+
}
|
|
159
|
+
authorizeClient(client, epoch) {
|
|
160
|
+
this.authorize(client, epoch);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
//#endregion
|
|
164
|
+
export { PhoneInteractiveSession };
|