@xopcai/xopc 0.0.332 → 0.0.334
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/dist/assets/{auth-DocRzRlS.js → auth-Cjj5SuoT.js} +49 -39
- package/dist/browser-ext/dist/background.js +1 -1
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +240 -36
- 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-C2wg3xC_.js → agent-avatar-dicebear-B73q7mlz.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-B9L2YIXz.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BeNnu1Ts.js → agent-plugin-dialog-COOjsvea.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CCj1JnLu.js +70 -0
- package/dist/gateway/static/root/assets/agents-admin-api-Cuqi5xZn.js +2 -0
- package/dist/gateway/static/root/assets/{app-link-C6gA5Nck.js → app-link-DRL0YnPs.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-etFSkfzl.js → app-management-settings-panel-CckioKud.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DKmU2VAP.js → appearance-settings-DDiPIr_Q.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-Azqy8vfo.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-D0z_Fr2G.js → archive-plugin-Dtyr0RhX.js} +1 -1
- package/dist/gateway/static/root/assets/attachment-load-qjPpQzYY.js +1 -0
- package/dist/gateway/static/root/assets/attachment-utils-core-BIOUBrpT.js +1 -0
- package/dist/gateway/static/root/assets/{automations-page-B7_C-p66.js → automations-page-g3SrFkTC.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B0nW2nZD.js +7 -0
- package/dist/gateway/static/root/assets/binary-plugins-BwKQVxsU.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-ChWW8Z9L.js → block-editor-DD9d5pCt.js} +29 -29
- package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-D2gNdS3e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BV00BXRb.js → browser-automations-page-BKqqJR7P.js} +2 -2
- package/dist/gateway/static/root/assets/{browser-settings-page-xwTmuZjS.js → browser-settings-page-BZH9bZbk.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-CHk4RZl4.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-CfWaVH-6.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C5FcWsSe.js +8 -0
- package/dist/gateway/static/root/assets/capability-header-actions-Bd66yEOa.js +1 -0
- package/dist/gateway/static/root/assets/channels-DIU5Gq4o.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C41mXCAi.js → chat-terminal-dock-B0nPDJyj.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-BJkqok2G.js → computer-settings-page-D7PxxaoG.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BKCZMmwm.js → connector-service-page-BZH4SeQg.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BC81R_fz.js +2 -0
- package/dist/gateway/static/root/assets/{turn-outcome-D0SnyZ3Z.js → constants-Co2_smKQ.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-CDEVYjXI.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-CqADAHZp.js → dependency-picker-AInmpSwC.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bab-iWED.js → desktop-pet-Sjgnlq8M.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BqgzLOdi.js → desktop-pet-settings-BWn0rrhr.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DFg7FDPf.js → device-pairing-wizard-BtW837_d.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-hqJ9sFCR.js → directory-picker-path-field-2CpmDx_D.js} +1 -1
- package/dist/gateway/static/root/assets/dist-CKkafhaS.js +1 -0
- package/dist/gateway/static/root/assets/dist-io9jFpN72.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DX3PFhRE.js → extension-debug-page-WWJFj9Z5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DkREdHLs.js → extension-page-DL00dFRr.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-wF-HNTM-.js → extension-settings-page-CN-agjPk.js} +1 -1
- package/dist/gateway/static/root/assets/{files-BK6enEvD.js → files-Bw4SBGdM.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-cR-tz7-Q.js → gateway-config-swr-CgIjCxM8.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-Ciq4c7KT.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-BHeHN26R.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-4oD6fhAm.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-6jLRcQsu.js → gateway-startup-retry-i-1lTrwY.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-nEpyJUBY.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CSSkwsyC.js → image-generation-api-gilc-u7M.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-B80Cv043.js → imports-page-BivdeiQ5.js} +1 -1
- package/dist/gateway/static/root/assets/index-BioG1pRD.js +106 -0
- package/dist/gateway/static/root/assets/index-DbLEkdNg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BgoFaTwv.js → keyboard-shortcuts-settings-B_8AJTFr.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CRtZQrmz.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-HO6OQlQT.js → local-apps-page-DclxpoqR.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-Bpja8nC6.js → local-apps-yys1VChX.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-DkolHmyp.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DX8TxkRl.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-5WFufZ4g.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-DYJnwlDr.js} +1 -1
- package/dist/gateway/static/root/assets/media-plugins-DlJDvwLK.js +1 -0
- package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-GF5Q9Fqy.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-E8o4_Ty9.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-CiCmfRTw.js +1 -0
- package/dist/gateway/static/root/assets/{page-tabs-vqI30Yrg.js → page-tabs-Cwp3fGVM.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-0p9PIHRy.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B-mwPBJW.js → preview-open-alternatives-DJ5xqGeu.js} +1 -1
- package/dist/gateway/static/root/assets/{product-delivery-bv3z8Xkh.js → product-delivery-BAks11S4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-D--sj_uN.js → product-open-page-CcGwNePw.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-6hhRBkmC.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DUOzRaFI.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BIpltJ47.js → registry-api-BvVx0G1o.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BWpWUXiE.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CAnb0PNY.js → runtime-tools-settings-panel-C6eDCNHz.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-pF7Lmqnk.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-BKj6wIMb.js → schema-form-D8W8q_ez.js} +1 -1
- package/dist/gateway/static/root/assets/{schemas-88fK3zzl.js → schemas-CObaziC7.js} +3 -3
- package/dist/gateway/static/root/assets/session-api-BAyUr97V.js +1 -0
- package/dist/gateway/static/root/assets/session-manager-BAy2sR2Q.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-BDKDqqf9.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C9cJWlAq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-78ycUHfv.js → settings-form-section-B0cAj0nq.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BOdxIVzo.js → settings-page-DZVVTFxs.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DZCPVx9c.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-BkPNyV8c.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-Bqlv5JBi.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-CiBGQ0Jg.js → skill-api-C0dufzQC.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-3JF2OTBz.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DB4lR4om.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CyJUeREH.js → system-settings-panel-xjrlhdUz.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CB6M7wSs.js +1 -0
- package/dist/gateway/static/root/assets/{tasks-CDR_RVbQ.js → tasks-QQJXsiER.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Day9zhKi.js → tunnel-api--68MQEWM.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-OLZ00eqD.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-Bj9hC6ML.js → use-autosave-DsnHYpTv.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CoePFpHD.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-fWRD6B8r.js → voice-api-key-field-CvIXutQp.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-ujEySjyc.js → voice-config-api-Bwy3Al3J.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CnxdvIk8.js → work-discovery-overlay-By5_7MLR.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DlWNN1VA.js → workflow-run-setup-panel-HSMDxDXV.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DElQ47Da.js +6 -0
- package/dist/gateway/static/root/index.html +27 -21
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +44 -14
- package/dist/packages/gateway-contract/src/capabilities.js +120 -10
- package/dist/packages/gateway-contract/src/index.js +8 -2
- package/dist/packages/gateway-contract/src/scenes.js +7 -6
- package/dist/packages/gateway-contract/src/session-command-rejection.js +19 -0
- package/dist/packages/gateway-contract/src/session-input-command.js +109 -0
- package/dist/packages/gateway-contract/src/sessions.js +2 -7
- package/dist/packages/gateway-contract/src/usage.js +6 -0
- package/dist/src/agent/agent-manager.js +15 -9
- package/dist/src/agent/background-review/run-background-review.js +8 -3
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +7 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
- package/dist/src/agent/external-tools/gateway-tools.js +45 -11
- package/dist/src/agent/external-tools/index.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
- package/dist/src/agent/memory/compaction.js +4 -0
- package/dist/src/agent/service/btw-query.js +8 -2
- package/dist/src/agent/service/process-direct-streaming.js +4 -2
- package/dist/src/agent/service.js +5 -5
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/filesystem-watcher.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +7 -3
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
- package/dist/src/agent/tools/automation-tool.d.ts +4 -1
- package/dist/src/agent/tools/automation-tool.js +42 -4
- package/dist/src/agent/tools/session-search-tool.js +1 -1
- package/dist/src/agent/tools/web-extract.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +50 -9
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/ai-assist/text-assist.js +6 -2
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/api/routes.js +65 -0
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/read.js +24 -0
- package/dist/src/automations/capabilities/write.d.ts +52 -14
- package/dist/src/automations/capabilities/write.js +52 -3
- package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
- package/dist/src/automations/delivery/delivery-router.js +318 -0
- package/dist/src/automations/delivery/index.d.ts +1 -0
- package/dist/src/automations/delivery/index.js +2 -0
- package/dist/src/automations/domain/defaults.d.ts +0 -1
- package/dist/src/automations/domain/defaults.js +1 -1
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +158 -7
- package/dist/src/automations/domain/validation.d.ts +104 -22
- package/dist/src/automations/domain/validation.js +66 -13
- package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
- package/dist/src/automations/draft/automation-draft-service.js +6 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +22 -3
- package/dist/src/automations/draft/automation-draft-validator.js +4 -4
- package/dist/src/automations/events/event-catalog.d.ts +14 -0
- package/dist/src/automations/events/event-catalog.js +117 -0
- package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
- package/dist/src/automations/events/event-dispatcher.js +140 -0
- package/dist/src/automations/events/event-repository.d.ts +59 -0
- package/dist/src/automations/events/event-repository.js +361 -0
- package/dist/src/automations/events/index.d.ts +3 -0
- package/dist/src/automations/events/index.js +4 -0
- package/dist/src/automations/index.d.ts +3 -1
- package/dist/src/automations/index.js +9 -3
- package/dist/src/automations/service/action-executor.d.ts +20 -1
- package/dist/src/automations/service/action-executor.js +80 -40
- package/dist/src/automations/service/automation-service.d.ts +21 -4
- package/dist/src/automations/service/automation-service.js +150 -100
- package/dist/src/automations/storage/automation-repository.js +4 -5
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +26 -1
- package/dist/src/automations/storage/index.js +2 -2
- package/dist/src/automations/webhook-secrets.d.ts +1 -0
- package/dist/src/automations/webhook-secrets.js +16 -0
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/capabilities/store-connector.d.ts +17 -1
- package/dist/src/capabilities/store-connector.js +69 -3
- package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/connectors.js +4 -3
- package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +2 -2
- package/dist/src/cli/commands/doctor/flow.js +5 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/connectors/approval-resume.js +1 -1
- package/dist/src/connectors/cli/authorization.d.ts +1 -1
- package/dist/src/connectors/cli/store.d.ts +1 -1
- package/dist/src/connectors/cli/store.js +1 -1
- package/dist/src/connectors/composio-backends.js +14 -4
- package/dist/src/connectors/composio-managed-events.d.ts +5 -2
- package/dist/src/connectors/composio-managed-events.js +4 -1
- package/dist/src/connectors/connection-candidates.js +53 -15
- package/dist/src/connectors/connection-capabilities.js +5 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
- package/dist/src/connectors/connection-recovery-service.js +89 -4
- package/dist/src/discussions/analyzer.js +4 -4
- package/dist/src/execution-environments/local-worktree-manager.js +10 -1
- package/dist/src/execution-environments/session-environment-service.d.ts +3 -0
- package/dist/src/execution-environments/session-environment-service.js +28 -4
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/home-intelligence-automation-reconciler.js +4 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +6 -2
- package/dist/src/gateway/hono/routes/browser-session.js +4 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +9 -2
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
- package/dist/src/gateway/hono/routes/files.js +3 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
- package/dist/src/gateway/hono/routes/models.js +17 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -4
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
- package/dist/src/gateway/hono/routes/scenes.js +57 -41
- package/dist/src/gateway/hono/routes/session-command-handler.d.ts +5 -0
- package/dist/src/gateway/hono/routes/session-command-handler.js +189 -0
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +14 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +2 -2
- package/dist/src/gateway/hono/routes/sessions.js +15 -168
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/tui.js +2 -1
- package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
- package/dist/src/gateway/hono/routes/usage.js +61 -0
- package/dist/src/gateway/hono/routes/voice.js +10 -1
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +5 -2
- package/dist/src/gateway/resolve-webchat-session-key.d.ts +1 -1
- package/dist/src/gateway/resolve-webchat-session-key.js +2 -2
- package/dist/src/gateway/scenes/host.js +27 -14
- package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/active-execution.d.ts +19 -0
- package/dist/src/gateway/service/active-execution.js +16 -0
- package/dist/src/gateway/service/agent-runner.d.ts +4 -0
- package/dist/src/gateway/service/agent-runner.js +19 -1
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
- package/dist/src/gateway/service/run-gateway-agent.js +10 -2
- package/dist/src/gateway/service/session-command-service.d.ts +34 -0
- package/dist/src/gateway/service/session-command-service.js +81 -0
- package/dist/src/gateway/service/session-input-coordinator.d.ts +21 -0
- package/dist/src/gateway/service/session-input-coordinator.js +41 -0
- package/dist/src/gateway/service/session-preparation-worker.d.ts +15 -0
- package/dist/src/gateway/service/session-preparation-worker.js +125 -0
- package/dist/src/gateway/service/sessions-api.d.ts +13 -0
- package/dist/src/gateway/service/sessions-api.js +23 -0
- package/dist/src/gateway/service.d.ts +30 -3
- package/dist/src/gateway/service.js +89 -79
- package/dist/src/gateway/side-chat/promotion-service.js +0 -1
- package/dist/src/gateway/side-chat/run-service.js +10 -7
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +5 -2
- package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
- package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
- package/dist/src/local-apps/service.js +2 -2
- package/dist/src/mcp/channel-bridge.js +12 -2
- package/dist/src/notes/capabilities/read.js +2 -2
- package/dist/src/notes/service.d.ts +4 -1
- package/dist/src/notes/service.js +13 -11
- package/dist/src/projects/project-service.js +1 -2
- package/dist/src/projects/project-skill-service.js +2 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-call.d.ts +3 -2
- package/dist/src/providers/model-call.js +30 -5
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/scenes/activationAdapter.d.ts +19 -0
- package/dist/src/scenes/activationAdapter.js +1 -0
- package/dist/src/scenes/agentExecutor.js +3 -10
- package/dist/src/scenes/contracts.d.ts +3 -9
- package/dist/src/scenes/contracts.js +1 -0
- package/dist/src/scenes/execution.d.ts +9 -3
- package/dist/src/scenes/execution.js +12 -11
- package/dist/src/scenes/httpServices.d.ts +5 -2
- package/dist/src/scenes/mailContext.d.ts +4 -0
- package/dist/src/scenes/mailContext.js +9 -0
- package/dist/src/scenes/maintenance.js +1 -5
- package/dist/src/scenes/metrics.d.ts +0 -6
- package/dist/src/scenes/metrics.js +0 -11
- package/dist/src/scenes/registry.d.ts +11 -0
- package/dist/src/scenes/registry.js +28 -0
- package/dist/src/scenes/repository.d.ts +6 -3
- package/dist/src/scenes/repository.js +43 -5
- package/dist/src/scenes/service.d.ts +2 -1
- package/dist/src/scenes/service.js +9 -7
- package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
- package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
- package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
- package/dist/src/scenes/taskFollowUp/service.js +86 -28
- package/dist/src/scenes/templates.d.ts +2 -2
- package/dist/src/scenes/userNotes.d.ts +3 -0
- package/dist/src/scenes/userNotes.js +6 -0
- package/dist/src/session/client-history.d.ts +3 -0
- package/dist/src/session/client-history.js +10 -5
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/resolve-session.js +4 -3
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/session/store.js +3 -3
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
- package/dist/src/storage/sqlite/connector-repository.js +36 -34
- package/dist/src/storage/sqlite/index.d.ts +2 -2
- package/dist/src/storage/sqlite/index.js +3 -3
- package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
- package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
- package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
- package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
- package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
- package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
- package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
- package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
- package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
- package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
- package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
- package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
- package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
- package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
- package/dist/src/storage/sqlite/migrations/223_session_creation_receipts.sql +59 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
- package/dist/src/storage/sqlite/row-mappers.js +6 -6
- package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
- package/dist/src/storage/sqlite/scenes-schema.js +0 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +0 -52
- package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
- package/dist/src/storage/sqlite/session-creation-repository.d.ts +50 -0
- package/dist/src/storage/sqlite/session-creation-repository.js +166 -0
- package/dist/src/storage/sqlite/session-input-repository.d.ts +12 -2
- package/dist/src/storage/sqlite/session-input-repository.js +25 -2
- package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-read-repository.js +0 -1
- package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
- package/dist/src/storage/sqlite/session-repository.js +8 -18
- package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
- package/dist/src/storage/sqlite/timestamps.js +20 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/transcript-repository.js +23 -15
- package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.d.ts +1 -1
- package/dist/src/tasks/home-query-service.js +3 -3
- package/dist/src/tasks/task-contract-planner.js +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +5 -0
- package/dist/src/tui/backends/embedded-backend.js +266 -20
- package/dist/src/tui/backends/embedded-drafts.d.ts +22 -0
- package/dist/src/tui/backends/embedded-drafts.js +53 -0
- package/dist/src/tui/backends/gateway-realtime-backend.d.ts +10 -0
- package/dist/src/tui/backends/gateway-realtime-backend.js +214 -33
- package/dist/src/tui/tui-backend.d.ts +1 -1
- package/dist/src/tui/tui-chat-input-state.d.ts +1 -0
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-session-format.js +0 -1
- package/dist/src/tui/tui-startup-resources.d.ts +1 -0
- package/dist/src/tui/tui-startup-resources.js +2 -2
- package/dist/src/tui/tui-types.d.ts +0 -1
- package/dist/src/tui/tui.js +69 -29
- package/dist/src/usage/cost.d.ts +4 -0
- package/dist/src/usage/cost.js +28 -0
- package/dist/src/usage/recorder.d.ts +13 -0
- package/dist/src/usage/recorder.js +117 -0
- package/dist/src/usage/scenario-registry.d.ts +8 -0
- package/dist/src/usage/scenario-registry.js +117 -0
- package/dist/src/usage/types.d.ts +55 -0
- package/dist/src/usage/types.js +1 -0
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/tts/summarize.js +1 -1
- package/dist/src/work-discovery/analyzer.js +2 -2
- package/dist/src/work-discovery/investigator.js +1 -1
- package/dist/src/work-discovery/service.js +3 -6
- package/dist/src/workflows/service/workflow-run-service.js +16 -3
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Se1Z72VG.js +0 -1
- package/dist/gateway/static/root/assets/agents-udIitwV8.js +0 -70
- package/dist/gateway/static/root/assets/apps-page-DVNySL58.js +0 -1
- package/dist/gateway/static/root/assets/attachment-load-DNCDbeOX.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BMgJvdcv.js +0 -7
- package/dist/gateway/static/root/assets/binary-plugins-BYn2hScX.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-CHA-sTAZ.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-v0WkhV5o.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DefBGjhV.js +0 -8
- package/dist/gateway/static/root/assets/capability-header-actions-vmx35sbu.js +0 -1
- package/dist/gateway/static/root/assets/channels-Eo4ONF5X.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DZYgogQw.js +0 -2
- package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +0 -1
- package/dist/gateway/static/root/assets/date-picker-CrOV4Ynd.js +0 -1
- package/dist/gateway/static/root/assets/dist-3h6cXXhT.js +0 -1
- package/dist/gateway/static/root/assets/dist-Che_jiQF.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Du-Dos9O.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D7YoMHq4.js +0 -1
- package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
- package/dist/gateway/static/root/assets/index-DalslRUx.js +0 -121
- package/dist/gateway/static/root/assets/local-app-workbench-page-BKL5UZAj.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CjzR9Rpj.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-Dk_gTJb9.js +0 -1
- package/dist/gateway/static/root/assets/media-plugins-Dlj6TD3M.js +0 -1
- package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-BebJPjjk.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CmS_hvz8.js +0 -8
- package/dist/gateway/static/root/assets/page-context-capture-button-BArPtqp5.js +0 -1
- package/dist/gateway/static/root/assets/popover-select-DcsFzD_i.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BFUdtWXF.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DBsBwAQ6.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BurdDY0m.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-Cj8xtr5t.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-BCsjgkCs.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BLL7csOJ.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CbKHBjrU.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-DyLfktib.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-BzvSNouj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BHnru0F5.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C35VKjhb.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-Bd1_Fguk.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-DuYzuR1T.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-B45YDiEw.js +0 -6
- package/dist/src/automations/product-events.d.ts +0 -5
- package/dist/src/automations/product-events.js +0 -19
- package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -9
- package/dist/src/tui/tui-empty-session-cleanup.js +0 -19
- /package/dist/gateway/static/root/assets/{dist-CI_fqRk-.js → dist-CI_fqRk-2.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
2
|
+
import { extractAssistantText, getAssistantMessageErrorReason } from "../providers/model-response.js";
|
|
2
3
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
3
4
|
import { completeWithResolvedCredentials, isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
4
|
-
import { extractAssistantText, getAssistantMessageErrorReason } from "../providers/model-response.js";
|
|
5
5
|
import { resolveModelSelector } from "../config/agent-model-intents.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
//#region src/home-intelligence/generator.ts
|
|
@@ -182,7 +182,7 @@ var HomeAdviceGenerator = class {
|
|
|
182
182
|
maxTokens: 3e3,
|
|
183
183
|
temperature: .1,
|
|
184
184
|
signal: requestSignal
|
|
185
|
-
});
|
|
185
|
+
}, void 0, { operation: "home.generate_advice" });
|
|
186
186
|
const raw = extractHomeResponseText(response);
|
|
187
187
|
let result;
|
|
188
188
|
try {
|
|
@@ -205,6 +205,9 @@ var HomeAdviceGenerator = class {
|
|
|
205
205
|
maxTokens: 3e3,
|
|
206
206
|
temperature: 0,
|
|
207
207
|
signal: requestSignal
|
|
208
|
+
}, void 0, {
|
|
209
|
+
operation: "home.generate_advice",
|
|
210
|
+
trigger: "retry"
|
|
208
211
|
});
|
|
209
212
|
try {
|
|
210
213
|
result = HomeModelResultSchema.parse(parseJson(extractHomeResponseText(corrected)));
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { automationEventPublisher } from "../automations/events/event-repository.js";
|
|
2
3
|
//#region src/infra/domain-outbox-dispatcher.ts
|
|
3
4
|
init_transaction();
|
|
4
5
|
var DomainOutboxDispatcher = class {
|
|
5
|
-
constructor(publish) {
|
|
6
|
-
this.publish = publish;
|
|
7
|
-
}
|
|
8
6
|
drain(limit = 100, subjectKind) {
|
|
9
|
-
const rows = getSqliteDatabase().prepare(`SELECT event_id, event_type, payload_json, created_at, subject_kind, operation_id
|
|
7
|
+
const rows = getSqliteDatabase().prepare(`SELECT event_id, event_type, payload_json, created_at, subject_kind, subject_id, operation_id
|
|
10
8
|
FROM domain_outbox WHERE published_at IS NULL AND (? IS NULL OR subject_kind = ?)
|
|
11
|
-
ORDER BY created_at,
|
|
9
|
+
ORDER BY created_at, rowid LIMIT ?`).all(subjectKind ?? null, subjectKind ?? null, Math.max(1, Math.min(500, Math.floor(limit))));
|
|
12
10
|
let published = 0;
|
|
13
11
|
for (const row of rows) try {
|
|
14
12
|
const payload = JSON.parse(row.payload_json);
|
|
15
|
-
|
|
13
|
+
automationEventPublisher.publish({
|
|
14
|
+
id: row.event_id,
|
|
16
15
|
type: row.event_type,
|
|
17
16
|
source: row.subject_kind === "note" ? "notes" : row.subject_kind === "project" ? "projects" : row.subject_kind === "scene" ? "scenes" : row.subject_kind === "local_app" ? "local_apps" : "tasks",
|
|
17
|
+
schemaVersion: 1,
|
|
18
|
+
subject: {
|
|
19
|
+
kind: row.subject_kind,
|
|
20
|
+
id: row.subject_id
|
|
21
|
+
},
|
|
18
22
|
payload: {
|
|
19
23
|
...payload,
|
|
20
24
|
sourceEventId: row.event_id,
|
|
21
25
|
...row.operation_id ? { operationId: row.operation_id } : {}
|
|
22
26
|
},
|
|
23
|
-
occurredAtMs: row.created_at
|
|
27
|
+
occurredAtMs: row.created_at,
|
|
28
|
+
correlationId: typeof payload.correlationId === "string" ? payload.correlationId : row.event_id,
|
|
29
|
+
causationId: typeof payload.causationId === "string" ? payload.causationId : void 0,
|
|
30
|
+
dedupeKey: row.event_id,
|
|
31
|
+
trust: "system"
|
|
24
32
|
});
|
|
25
33
|
runSqliteWriteTransaction((db) => {
|
|
26
34
|
db.prepare(`UPDATE domain_outbox SET published_at = ?, attempts = attempts + 1
|
|
@@ -5,10 +5,10 @@ import { currentOperationId, init_operation_context } from "../infra/operation-c
|
|
|
5
5
|
import { afterSqliteCommit, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
6
6
|
import { ExtensionCapabilityBindingsSchema, extensionCapabilityPermissions } from "../../packages/gateway-contract/src/extension-capabilities.js";
|
|
7
7
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
8
|
+
import { CapabilityError } from "../capabilities/runtime/errors.js";
|
|
8
9
|
import { init_paths, resolveExtensionsDir } from "../config/paths.js";
|
|
9
10
|
import { LocalAppStore } from "./store.js";
|
|
10
11
|
import { slugifyProjectName } from "../projects/project-store.js";
|
|
11
|
-
import { CapabilityError } from "../capabilities/runtime/errors.js";
|
|
12
12
|
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
13
13
|
import { validateLocalAppCapabilityContracts } from "./capabilities/contracts.js";
|
|
14
14
|
import { buildLocalAppFixGuidance } from "./fix-guidance.js";
|
|
@@ -511,7 +511,7 @@ var LocalAppService = class {
|
|
|
511
511
|
});
|
|
512
512
|
}
|
|
513
513
|
flushAcceptanceEvents() {
|
|
514
|
-
new DomainOutboxDispatcher(
|
|
514
|
+
new DomainOutboxDispatcher().drain(100, "local_app");
|
|
515
515
|
}
|
|
516
516
|
releaseRoot(appId) {
|
|
517
517
|
return join(resolveStateDir(), "local-apps", "releases", appId);
|
|
@@ -144,10 +144,20 @@ var XopcChannelBridge = class {
|
|
|
144
144
|
return null;
|
|
145
145
|
}
|
|
146
146
|
async sendMessage(params) {
|
|
147
|
-
|
|
147
|
+
const client = this.client;
|
|
148
|
+
const path = `/api/sessions/${encodeURIComponent(params.conversationId)}`;
|
|
149
|
+
const [detail, config] = await Promise.all([client.getJson(path), client.getJson(`${path}/agent-config`)]);
|
|
150
|
+
return client.postJson(`/api/sessions/${encodeURIComponent(params.conversationId)}/inputs`, {
|
|
151
|
+
kind: "append",
|
|
148
152
|
clientMessageId: crypto.randomUUID(),
|
|
153
|
+
expectedTranscriptId: detail.session.transcriptId,
|
|
154
|
+
configVersion: config.configVersion,
|
|
149
155
|
delivery: "next",
|
|
150
|
-
content: params.text
|
|
156
|
+
input: { content: params.text },
|
|
157
|
+
origin: {
|
|
158
|
+
type: "system",
|
|
159
|
+
source: "cli"
|
|
160
|
+
}
|
|
151
161
|
});
|
|
152
162
|
}
|
|
153
163
|
listPendingApprovals() {
|
|
@@ -20,8 +20,8 @@ function registerNoteReadCapabilities(dispatcher, getNotes) {
|
|
|
20
20
|
id: "xopc.notes.preview_edit",
|
|
21
21
|
description: "Build a local edit suggestion without modifying the note or calling a model.",
|
|
22
22
|
...ProductReadContracts["xopc.notes.preview_edit"],
|
|
23
|
-
async execute({ id, instruction, markdown }) {
|
|
24
|
-
const result = await getNotes().createAiEditPatch(id, instruction, markdown);
|
|
23
|
+
async execute({ id, instruction, markdown, context }) {
|
|
24
|
+
const result = await getNotes().createAiEditPatch(id, instruction, markdown, context?.range);
|
|
25
25
|
if (!result) throw new CapabilityError("NOT_FOUND", "Note not found");
|
|
26
26
|
return ProductReadContracts["xopc.notes.preview_edit"].output.parse(result);
|
|
27
27
|
}
|
|
@@ -23,7 +23,10 @@ export declare class NotesService {
|
|
|
23
23
|
note: Note | null;
|
|
24
24
|
conflict: boolean;
|
|
25
25
|
}>;
|
|
26
|
-
createAiEditPatch(id: string, instruction: string, markdownOverride?: string
|
|
26
|
+
createAiEditPatch(id: string, instruction: string, markdownOverride?: string, requestedRange?: {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
}): Promise<{
|
|
27
30
|
message: string;
|
|
28
31
|
patch: NoteAiPatch;
|
|
29
32
|
} | null>;
|
|
@@ -7,9 +7,8 @@ import { init_note_markdown, parseNoteMarkdown } from "./note-markdown.js";
|
|
|
7
7
|
import { init_notes_repository, listNoteProjectSummaries } from "../storage/sqlite/notes-repository.js";
|
|
8
8
|
import { changedFieldsFromPatch, emitActivity, previewText, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
|
|
9
9
|
import { getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
10
|
-
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
11
|
-
import { publishAutomationProductEvent } from "../automations/product-events.js";
|
|
12
10
|
import { completeWithResolvedCredentials } from "../providers/model-call.js";
|
|
11
|
+
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
13
12
|
import { partitionAttachmentsByReference } from "./note-attachment-sync.js";
|
|
14
13
|
import { buildNoteAgentContextArtifact, getCachedNoteAgentContextArtifact } from "./agent-context.js";
|
|
15
14
|
import { revokeNoteShareRecords } from "../share/note-share-revocation.js";
|
|
@@ -153,7 +152,7 @@ async function buildAiCatalysisReport(note, config) {
|
|
|
153
152
|
role: "user",
|
|
154
153
|
content: buildCatalysisPrompt(note),
|
|
155
154
|
timestamp: Date.now()
|
|
156
|
-
}] }, { temperature: .2 });
|
|
155
|
+
}] }, { temperature: .2 }, void 0, { operation: "note.generate" });
|
|
157
156
|
let responseText = "";
|
|
158
157
|
if (Array.isArray(response.content)) {
|
|
159
158
|
for (const part of response.content) if (part && typeof part === "object" && part.type === "text") responseText += String(part.text || "");
|
|
@@ -173,7 +172,7 @@ var NotesService = class {
|
|
|
173
172
|
flushCommittedEffects() {
|
|
174
173
|
this.store.drainAttachmentCleanup();
|
|
175
174
|
this.store.drainDeletionCleanup();
|
|
176
|
-
new DomainOutboxDispatcher(
|
|
175
|
+
new DomainOutboxDispatcher().drain(100, "note");
|
|
177
176
|
}
|
|
178
177
|
async quickCapture(markdown, source, idempotencyKey) {
|
|
179
178
|
const note = this.quickCaptureAtomically(markdown, source, idempotencyKey);
|
|
@@ -334,19 +333,22 @@ var NotesService = class {
|
|
|
334
333
|
throw error;
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
|
-
async createAiEditPatch(id, instruction, markdownOverride) {
|
|
336
|
+
async createAiEditPatch(id, instruction, markdownOverride, requestedRange) {
|
|
338
337
|
const note = await this.store.getNote(id);
|
|
339
338
|
if (!note) return null;
|
|
340
339
|
const source = markdownOverride ?? note.markdown;
|
|
341
|
-
const
|
|
340
|
+
const start = Math.max(0, Math.min(source.length, requestedRange?.start ?? 0));
|
|
341
|
+
const end = Math.max(start, Math.min(source.length, requestedRange?.end ?? source.length));
|
|
342
|
+
const target = source.slice(start, end);
|
|
343
|
+
const parsed = parseNoteMarkdown(target, id);
|
|
342
344
|
const wantsTodos = /待办|todo|task|行动|提醒/i.test(instruction);
|
|
343
345
|
const wantsSummary = /摘要|总结|summary|压缩/i.test(instruction);
|
|
344
346
|
let generated = "";
|
|
345
347
|
if (wantsTodos) {
|
|
346
|
-
const lines =
|
|
348
|
+
const lines = target.split(/\n|。|;|;/).map((line) => line.trim()).filter(Boolean);
|
|
347
349
|
generated = (lines.length ? lines : [parsed.plainText]).slice(0, 12).map((line) => `- [ ] ${line.replace(/^[-*\d.\s\[\]x]+/i, "").trim()}`).join("\n");
|
|
348
350
|
} else if (wantsSummary) generated = `> [!SUMMARY]\n> ${parsed.plainText.slice(0, 220)}`;
|
|
349
|
-
else generated = `${
|
|
351
|
+
else generated = `${target.trimEnd()}\n\n## AI 整理\n\n${instruction.trim()}`;
|
|
350
352
|
return {
|
|
351
353
|
message: "AI edit patch generated",
|
|
352
354
|
patch: {
|
|
@@ -354,9 +356,9 @@ var NotesService = class {
|
|
|
354
356
|
summary: instruction,
|
|
355
357
|
operations: [{
|
|
356
358
|
type: "replaceRange",
|
|
357
|
-
from:
|
|
358
|
-
to:
|
|
359
|
-
markdown: generated ||
|
|
359
|
+
from: start,
|
|
360
|
+
to: end,
|
|
361
|
+
markdown: generated || target
|
|
360
362
|
}]
|
|
361
363
|
}
|
|
362
364
|
};
|
|
@@ -8,7 +8,6 @@ import { enqueueProjectChanged } from "./project-change-events.js";
|
|
|
8
8
|
import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, canonicalWorkspacePath, inferProjectNameFromWorkspaceRoot, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, resolveWorkspaceProjectRoot, workspaceDirectoryExists } from "./workspace-project.js";
|
|
9
9
|
import { drainProjectWorkspaceCreation, queueProjectWorkspaceCreation } from "./project-workspace-creation.js";
|
|
10
10
|
import { DomainOutboxDispatcher } from "../infra/domain-outbox-dispatcher.js";
|
|
11
|
-
import { publishAutomationProductEvent } from "../automations/product-events.js";
|
|
12
11
|
import { listPendingProjectUnderstandingRuns } from "../work-discovery/repository.js";
|
|
13
12
|
import { inferProjectExecutionMode } from "./project-kind.js";
|
|
14
13
|
import { bindSessionToProject, listProjectConversationIds, unbindSessionFromProject } from "./session-bind.js";
|
|
@@ -280,7 +279,7 @@ var ProjectService = class {
|
|
|
280
279
|
}
|
|
281
280
|
flushCommittedEffects(projectId) {
|
|
282
281
|
drainProjectWorkspaceCreation(projectId);
|
|
283
|
-
new DomainOutboxDispatcher(
|
|
282
|
+
new DomainOutboxDispatcher().drain(100, "project");
|
|
284
283
|
}
|
|
285
284
|
listUpdates(projectId, limit) {
|
|
286
285
|
return this.store.listUpdates(projectId, limit);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
|
|
2
|
-
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../agent/skills/workspace-skills-dir.js";
|
|
3
|
-
import { loadSkills, loadWorkspaceSkillInventory } from "../agent/skills/index.js";
|
|
4
2
|
import { removeSkillsLockEntry } from "../agent/skills/hub-lock.js";
|
|
5
3
|
import { deleteManagedSkill, installSkillFromZip, isValidSkillId } from "../agent/skills/managed-store.js";
|
|
4
|
+
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../agent/skills/workspace-skills-dir.js";
|
|
5
|
+
import { loadSkills, loadWorkspaceSkillInventory } from "../agent/skills/index.js";
|
|
6
6
|
import { pullSkillFromSource } from "../agent/skills/hub-pull.js";
|
|
7
7
|
import { downloadFromMarketplace } from "../agent/skills/skills-marketplace.js";
|
|
8
8
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
2
1
|
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
2
|
+
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
3
3
|
import { getDefaultAuthProfileStore } from "./auth-profile-store.js";
|
|
4
4
|
//#region src/providers/auth-runtime/resolve-auth.ts
|
|
5
5
|
init_env_keys();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __esmMin, __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
|
-
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
4
|
-
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
5
3
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
6
4
|
import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
7
5
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
6
|
+
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
8
7
|
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
8
|
+
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
10
|
import { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Api, type AssistantMessage, type Context, type Model, type SimpleStreamOptions } from '@earendil-works/pi-ai/compat';
|
|
2
2
|
import type { CredentialResolverOptions } from '../auth/credentials.js';
|
|
3
|
+
import type { AiUsageContext } from '../usage/types.js';
|
|
3
4
|
export declare function isLocalModelBaseUrl(baseUrl: string | undefined): boolean;
|
|
4
5
|
/** Codex Responses rejects the temperature request parameter. */
|
|
5
6
|
export declare function supportsModelTemperature(model: Model<Api>): boolean;
|
|
@@ -8,10 +9,10 @@ export declare function resolveModelCallOptions(model: Model<Api>, options?: Sim
|
|
|
8
9
|
/**
|
|
9
10
|
* Complete a one-shot request with xopc credential resolution and extension-provider routing.
|
|
10
11
|
*/
|
|
11
|
-
export declare function completeWithResolvedCredentials(model: Model<Api>, context: Context, options
|
|
12
|
+
export declare function completeWithResolvedCredentials(model: Model<Api>, context: Context, options: SimpleStreamOptions, credentialOptions: CredentialResolverOptions | undefined, usageContext: AiUsageContext): Promise<AssistantMessage>;
|
|
12
13
|
/**
|
|
13
14
|
* Start a model stream with xopc credential resolution and extension-provider routing.
|
|
14
15
|
* Callers that need live visible output should consume the returned stream before calling
|
|
15
16
|
* its `result()` method.
|
|
16
17
|
*/
|
|
17
|
-
export declare function createResolvedModelStream(model: Model<Api>, context: Context, options
|
|
18
|
+
export declare function createResolvedModelStream(model: Model<Api>, context: Context, options: SimpleStreamOptions, credentialOptions: CredentialResolverOptions | undefined, usageContext: AiUsageContext): Promise<import("@earendil-works/pi-ai/compat").AssistantMessageEventStream>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { init_constants } from "./constants.js";
|
|
2
2
|
import { getApiKey, init_providers } from "./index.js";
|
|
3
3
|
import { createExtensionAwareStreamFn } from "./extension-stream-bridge.js";
|
|
4
|
+
import { finishAiUsageFromMessage, observeAiUsageStream, startAiUsageCall } from "../usage/recorder.js";
|
|
4
5
|
import { completeSimple, normalizeContext } from "@earendil-works/pi-ai/compat";
|
|
5
6
|
//#region src/providers/model-call.ts
|
|
6
7
|
init_constants();
|
|
@@ -40,19 +41,43 @@ async function resolveModelCallOptions(model, options = {}, credentialOptions) {
|
|
|
40
41
|
/**
|
|
41
42
|
* Complete a one-shot request with xopc credential resolution and extension-provider routing.
|
|
42
43
|
*/
|
|
43
|
-
async function completeWithResolvedCredentials(model, context, options
|
|
44
|
+
async function completeWithResolvedCredentials(model, context, options, credentialOptions, usageContext) {
|
|
44
45
|
const resolvedOptions = await resolveModelCallOptions(model, options, credentialOptions);
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const usageCall = startAiUsageCall(model, usageContext);
|
|
47
|
+
try {
|
|
48
|
+
if (model.baseUrl === "extension://provider-plugin") {
|
|
49
|
+
const result = await (await createExtensionAwareStreamFn()(model, normalizeContext(context), resolvedOptions)).result();
|
|
50
|
+
finishAiUsageFromMessage(usageCall, result);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
const result = await completeSimple(model, context, resolvedOptions);
|
|
54
|
+
finishAiUsageFromMessage(usageCall, result);
|
|
55
|
+
return result;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
usageCall?.finish({
|
|
58
|
+
status: "failed",
|
|
59
|
+
errorSummary: error instanceof Error ? error.message : String(error)
|
|
60
|
+
});
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
47
63
|
}
|
|
48
64
|
/**
|
|
49
65
|
* Start a model stream with xopc credential resolution and extension-provider routing.
|
|
50
66
|
* Callers that need live visible output should consume the returned stream before calling
|
|
51
67
|
* its `result()` method.
|
|
52
68
|
*/
|
|
53
|
-
async function createResolvedModelStream(model, context, options
|
|
69
|
+
async function createResolvedModelStream(model, context, options, credentialOptions, usageContext) {
|
|
54
70
|
const resolvedOptions = await resolveModelCallOptions(model, options, credentialOptions);
|
|
55
|
-
|
|
71
|
+
const usageCall = startAiUsageCall(model, usageContext);
|
|
72
|
+
try {
|
|
73
|
+
return observeAiUsageStream(await createExtensionAwareStreamFn()(model, normalizeContext(context), resolvedOptions), usageCall);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
usageCall?.finish({
|
|
76
|
+
status: "failed",
|
|
77
|
+
errorSummary: error instanceof Error ? error.message : String(error)
|
|
78
|
+
});
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
56
81
|
}
|
|
57
82
|
//#endregion
|
|
58
83
|
export { completeWithResolvedCredentials, createResolvedModelStream, isLocalModelBaseUrl, resolveModelCallApiKey, resolveModelCallOptions, supportsModelTemperature };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { init_paths_state, resolveXopcCloudCatalogCachePath } from "../config/paths-state.js";
|
|
3
|
-
import { ComputerProfileSchema, init_src } from "../../packages/computer-control-contract/src/index.js";
|
|
4
3
|
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
4
|
+
import { ComputerProfileSchema, init_src } from "../../packages/computer-control-contract/src/index.js";
|
|
5
5
|
import { voiceManifestSchema } from "../../packages/realtime-protocol/src/voice-catalog.js";
|
|
6
6
|
import { init_voice } from "../../packages/realtime-protocol/src/voice.js";
|
|
7
7
|
import { readFileSync, rmSync } from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
3
2
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
3
|
+
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
4
4
|
import { XOPC_CLOUD_PROVIDER_ID, init_xopc_cloud_config, resolveXopcModelRouterUrl } from "./xopc-cloud-config.js";
|
|
5
5
|
//#region src/providers/register-runtime-providers.ts
|
|
6
6
|
function registerRuntimeProvider(modelRuntime, source) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ScenePrincipal, SceneTemplate } from './contracts.js';
|
|
2
|
+
/** Extension point for activation shapes that need more than the core read-only setup. */
|
|
3
|
+
export interface SceneActivationAdapter {
|
|
4
|
+
id: string;
|
|
5
|
+
preflight(principal: ScenePrincipal, template: SceneTemplate, configuration: unknown): Promise<{
|
|
6
|
+
ready: boolean;
|
|
7
|
+
missing: string[];
|
|
8
|
+
}>;
|
|
9
|
+
create(principal: ScenePrincipal, template: SceneTemplate, configuration: unknown): Promise<unknown>;
|
|
10
|
+
get(principal: ScenePrincipal, activationId: string): unknown;
|
|
11
|
+
configure(principal: ScenePrincipal, activationId: string, expectedRevision: number, configuration: unknown): Promise<unknown>;
|
|
12
|
+
transition(principal: ScenePrincipal, activationId: string, expectedRevision: number, status: 'active' | 'paused' | 'archived'): Promise<unknown>;
|
|
13
|
+
tick(): Promise<void>;
|
|
14
|
+
stop(): Promise<void>;
|
|
15
|
+
executeTask?(runId: string, conversationId: string): Promise<boolean>;
|
|
16
|
+
allowsTaskNotification?(taskId: string): boolean;
|
|
17
|
+
listProjectBranches?(principal: ScenePrincipal, projectId: string): Promise<unknown>;
|
|
18
|
+
associateBranch?(principal: ScenePrincipal, input: unknown): Promise<unknown>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../auth/sync-provider-auth.js";
|
|
2
2
|
import { getApiKeySync, init_providers } from "../providers/index.js";
|
|
3
3
|
import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
|
|
4
|
+
import { trackAiUsageStream } from "../usage/recorder.js";
|
|
4
5
|
import { readOnlyResultSchema } from "./execution.js";
|
|
5
6
|
import { Agent } from "@earendil-works/pi-agent-core";
|
|
6
7
|
//#region src/scenes/agentExecutor.ts
|
|
@@ -25,10 +26,10 @@ var SceneAgentExecutor = class {
|
|
|
25
26
|
},
|
|
26
27
|
streamFn: (model, context, options) => {
|
|
27
28
|
if (++calls > 1) throw new Error("Scene executor permits one model call");
|
|
28
|
-
return stream(model, context, {
|
|
29
|
+
return trackAiUsageStream(model, input.usage, () => stream(model, context, {
|
|
29
30
|
...options,
|
|
30
31
|
maxTokens: input.template.execution.limits.maxOutputTokens
|
|
31
|
-
});
|
|
32
|
+
}));
|
|
32
33
|
},
|
|
33
34
|
getApiKey: (provider) => resolveProviderApiKeySync(provider) ?? getApiKeySync(provider) ?? ""
|
|
34
35
|
});
|
|
@@ -42,14 +43,6 @@ var SceneAgentExecutor = class {
|
|
|
42
43
|
}));
|
|
43
44
|
input.signal.throwIfAborted();
|
|
44
45
|
const response = agent.state.messages.findLast((message) => message.role === "assistant");
|
|
45
|
-
if (response?.role === "assistant") input.onUsage?.({
|
|
46
|
-
provider: response.provider,
|
|
47
|
-
model: response.model,
|
|
48
|
-
inputTokens: response.usage.input,
|
|
49
|
-
outputTokens: response.usage.output,
|
|
50
|
-
totalTokens: response.usage.totalTokens,
|
|
51
|
-
estimatedCost: response.usage.cost.total
|
|
52
|
-
});
|
|
53
46
|
if (!response || response.role !== "assistant" || response.stopReason !== "stop") throw new Error("Scene model did not complete a read-only result");
|
|
54
47
|
if (response.content.some((block) => block.type === "toolCall")) throw new Error("Scene model attempted an unavailable tool");
|
|
55
48
|
const text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
|
|
@@ -2,14 +2,8 @@ export { sceneOutcomeKinds, activationStatuses, sceneScopeSchema, sceneTemplateS
|
|
|
2
2
|
import { type SceneTemplate, type ScenePermission, type ActivationStatus } from '@xopcai/gateway-contract';
|
|
3
3
|
/** Stable JSON hashing binds approvals and immutable versions to exact content. */
|
|
4
4
|
export declare function sceneContentHash(value: unknown): string;
|
|
5
|
-
export declare function validateTemplate(value: unknown, registered: Pick<ScenePermission, 'contextProviders' | 'effectHandlers'>
|
|
5
|
+
export declare function validateTemplate(value: unknown, registered: Pick<ScenePermission, 'contextProviders' | 'effectHandlers'> & {
|
|
6
|
+
executionAdapters?: string[];
|
|
7
|
+
}): SceneTemplate;
|
|
6
8
|
export declare function intersectPermissions(...permissions: ScenePermission[]): ScenePermission;
|
|
7
9
|
export declare function canTransitionActivation(from: ActivationStatus, to: ActivationStatus): boolean;
|
|
8
|
-
export type SceneModelUsage = {
|
|
9
|
-
provider: string;
|
|
10
|
-
model: string;
|
|
11
|
-
inputTokens: number;
|
|
12
|
-
outputTokens: number;
|
|
13
|
-
totalTokens: number;
|
|
14
|
-
estimatedCost: number;
|
|
15
|
-
};
|
|
@@ -18,6 +18,7 @@ function validateTemplate(value, registered) {
|
|
|
18
18
|
const template = sceneTemplateSchema.parse(value);
|
|
19
19
|
for (const provider of template.contextProviders) if (!registered.contextProviders.includes(provider)) throw new Error(`Unknown scene context provider: ${provider}`);
|
|
20
20
|
for (const handler of template.allowedEffectHandlers) if (!registered.effectHandlers.includes(handler)) throw new Error(`Unknown scene effect handler: ${handler}`);
|
|
21
|
+
if (registered.executionAdapters && !registered.executionAdapters.includes(template.execution.kind)) throw new Error(`Unknown scene execution adapter: ${template.execution.kind}`);
|
|
21
22
|
return template;
|
|
22
23
|
}
|
|
23
24
|
function intersectPermissions(...permissions) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import
|
|
2
|
+
import type { AiUsageContext } from '../usage/types.js';
|
|
3
|
+
import { type SceneActivation, type ScenePermission, type SceneTemplate } from './contracts.js';
|
|
3
4
|
import { SceneRepository } from './repository.js';
|
|
5
|
+
import { SceneCapabilityRegistry } from './registry.js';
|
|
4
6
|
export declare const readOnlyResultSchema: z.ZodObject<{
|
|
5
7
|
kind: z.ZodEnum<{
|
|
6
8
|
artifact: "artifact";
|
|
@@ -27,6 +29,10 @@ export interface SceneEvidence {
|
|
|
27
29
|
}
|
|
28
30
|
export interface SceneContextProvider {
|
|
29
31
|
id: string;
|
|
32
|
+
setupIssues?(activation: SceneActivation): string[];
|
|
33
|
+
authorization?(activation: SceneActivation): string[] | null;
|
|
34
|
+
tracksHealth?: boolean;
|
|
35
|
+
requiresAccountIdentity?: boolean;
|
|
30
36
|
read(input: {
|
|
31
37
|
activation: SceneActivation;
|
|
32
38
|
subjectId: string;
|
|
@@ -41,7 +47,7 @@ export interface SceneReadOnlyExecutor {
|
|
|
41
47
|
goal: string;
|
|
42
48
|
evidence: SceneEvidence[];
|
|
43
49
|
signal: AbortSignal;
|
|
44
|
-
|
|
50
|
+
usage: AiUsageContext;
|
|
45
51
|
}): Promise<unknown>;
|
|
46
52
|
}
|
|
47
53
|
/** Runs one durable claim without exposing messaging, filesystem or write tools. */
|
|
@@ -51,6 +57,6 @@ export declare class SceneExecutionService {
|
|
|
51
57
|
private readonly executor;
|
|
52
58
|
private readonly authorize;
|
|
53
59
|
private readonly clock;
|
|
54
|
-
constructor(repository: SceneRepository, providers:
|
|
60
|
+
constructor(repository: SceneRepository, providers: SceneCapabilityRegistry<SceneContextProvider>, executor: SceneReadOnlyExecutor, authorize: (activation: SceneActivation) => Promise<ScenePermission>, clock?: () => number);
|
|
55
61
|
runNext(worker: string, outerSignal?: AbortSignal): Promise<'idle' | 'completed' | 'discarded' | 'failed' | 'deferred'>;
|
|
56
62
|
}
|
|
@@ -36,7 +36,6 @@ var SceneExecutionService = class {
|
|
|
36
36
|
this.executor = executor;
|
|
37
37
|
this.authorize = authorize;
|
|
38
38
|
this.clock = clock;
|
|
39
|
-
if (new Set(providers.map((provider) => provider.id)).size !== providers.length) throw new Error("Duplicate scene context providers");
|
|
40
39
|
}
|
|
41
40
|
async runNext(worker, outerSignal) {
|
|
42
41
|
outerSignal?.throwIfAborted();
|
|
@@ -46,6 +45,7 @@ var SceneExecutionService = class {
|
|
|
46
45
|
if (!runInput) return "discarded";
|
|
47
46
|
const { activation, subjectId, accountId, notBefore } = runInput;
|
|
48
47
|
const template = this.repository.getTemplate(activation.templateKey, activation.templateVersion);
|
|
48
|
+
if (template.execution.kind !== "agent") throw new SceneExecutionRejected("executor_unavailable");
|
|
49
49
|
if (!this.repository.renewLease(claim, this.clock(), template.execution.limits.timeoutSeconds * 1e3 + 5e3)) return "discarded";
|
|
50
50
|
const controller = new AbortController();
|
|
51
51
|
const abort = () => controller.abort(outerSignal?.reason);
|
|
@@ -69,7 +69,7 @@ var SceneExecutionService = class {
|
|
|
69
69
|
try {
|
|
70
70
|
granted = await this.authorize(activation);
|
|
71
71
|
} catch (error) {
|
|
72
|
-
if (template.contextProviders.
|
|
72
|
+
if (template.contextProviders.some((id) => this.providers.get(id).tracksHealth)) this.repository.recordSourceHealth(activation, sceneSourceFailureReason(error), this.clock(), this.clock() + 6e4);
|
|
73
73
|
throw error;
|
|
74
74
|
}
|
|
75
75
|
assertCurrent();
|
|
@@ -80,12 +80,11 @@ var SceneExecutionService = class {
|
|
|
80
80
|
});
|
|
81
81
|
const evidence = [];
|
|
82
82
|
for (const providerId of template.contextProviders) {
|
|
83
|
+
const provider = this.providers.get(providerId);
|
|
83
84
|
if (!permissions.contextProviders.includes(providerId)) {
|
|
84
|
-
if (
|
|
85
|
+
if (provider.tracksHealth) this.repository.recordSourceHealth(activation, "needs_permission", this.clock(), this.clock() + 6e4);
|
|
85
86
|
throw new SceneExecutionRejected("needs_permission");
|
|
86
87
|
}
|
|
87
|
-
const provider = this.providers.find((item) => item.id === providerId);
|
|
88
|
-
if (!provider) throw new SceneExecutionRejected("provider_unavailable");
|
|
89
88
|
let items;
|
|
90
89
|
try {
|
|
91
90
|
items = await provider.read({
|
|
@@ -96,11 +95,11 @@ var SceneExecutionService = class {
|
|
|
96
95
|
signal: controller.signal
|
|
97
96
|
});
|
|
98
97
|
} catch (error) {
|
|
99
|
-
if (
|
|
98
|
+
if (provider.tracksHealth && !outerSignal?.aborted) this.repository.recordSourceHealth(activation, sceneSourceFailureReason(error), this.clock(), this.clock() + 6e4);
|
|
100
99
|
throw error;
|
|
101
100
|
}
|
|
102
101
|
assertCurrent();
|
|
103
|
-
if (
|
|
102
|
+
if (provider.requiresAccountIdentity && items.some((item) => item.accountId === void 0)) throw new SceneExecutionRejected("missing_account_identity");
|
|
104
103
|
if (items.some((item) => !evidenceAllowed(item, activation, permissions, this.clock()))) throw new SceneExecutionRejected("unauthorized_or_stale_evidence");
|
|
105
104
|
evidence.push(...items);
|
|
106
105
|
}
|
|
@@ -108,7 +107,7 @@ var SceneExecutionService = class {
|
|
|
108
107
|
if (new Set(evidence.map((item) => item.id)).size !== evidence.length) throw new SceneExecutionRejected("duplicate_evidence");
|
|
109
108
|
evidence.sort((left, right) => left.id.localeCompare(right.id));
|
|
110
109
|
const fingerprint = sceneContentHash(evidence.map(({ freshUntil: _freshUntil, ...item }) => item));
|
|
111
|
-
if (template.contextProviders.
|
|
110
|
+
if (template.contextProviders.some((id) => this.providers.get(id).tracksHealth)) this.repository.recordSourceHealth(activation, null, this.clock());
|
|
112
111
|
return {
|
|
113
112
|
evidence,
|
|
114
113
|
fingerprint,
|
|
@@ -137,9 +136,11 @@ var SceneExecutionService = class {
|
|
|
137
136
|
goal: activation.goal,
|
|
138
137
|
evidence: snapshot.evidence,
|
|
139
138
|
signal: controller.signal,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
usage: {
|
|
140
|
+
operation: "scene.execute",
|
|
141
|
+
traceId: claim.id,
|
|
142
|
+
runId: claim.id,
|
|
143
|
+
...activation.scope.kind === "conversation" ? { conversationId: activation.scope.id } : {}
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
146
|
assertCurrent();
|
|
@@ -6,10 +6,13 @@ import type { SceneApplicationService } from './service.js';
|
|
|
6
6
|
import type { SceneMailContextProvider } from './mailContext.js';
|
|
7
7
|
import type { ScenePreferenceService } from './preferences.js';
|
|
8
8
|
import type { SceneMetrics } from './metrics.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { SceneActivationAdapter } from './activationAdapter.js';
|
|
10
|
+
import type { SceneCapabilityRegistry } from './registry.js';
|
|
11
|
+
import type { SceneSourceRegistry } from './taskFollowUp/contracts.js';
|
|
10
12
|
/** An explicitly installed scene domain; never resolves to the old runtime. */
|
|
11
13
|
export interface SceneHttpServices {
|
|
12
|
-
|
|
14
|
+
activationAdapters: SceneCapabilityRegistry<SceneActivationAdapter>;
|
|
15
|
+
sourceProviders: SceneSourceRegistry;
|
|
13
16
|
repository: SceneRepository;
|
|
14
17
|
application: SceneApplicationService;
|
|
15
18
|
inbox: SceneInboxService;
|
|
@@ -6,7 +6,11 @@ export declare class SceneMailContextProvider implements SceneContextProvider {
|
|
|
6
6
|
private readonly db;
|
|
7
7
|
private readonly clock;
|
|
8
8
|
readonly id = "mail";
|
|
9
|
+
readonly tracksHealth = true;
|
|
10
|
+
readonly requiresAccountIdentity = true;
|
|
9
11
|
constructor(db: DatabaseSync, clock?: () => number);
|
|
12
|
+
setupIssues(activation: SceneActivation): string[];
|
|
13
|
+
authorization(activation: SceneActivation): string[] | null;
|
|
10
14
|
/** Resolve current account grants for the exact delegated source, including reconnects and revocation. */
|
|
11
15
|
authorizedAccounts(activation: SceneActivation): string[];
|
|
12
16
|
/** Picker metadata only; choosing an item still requires explicit activation consent. */
|
|
@@ -11,10 +11,19 @@ const accountPolicy = `a.enabled = 1 AND installation.enabled = 1 AND c.status =
|
|
|
11
11
|
/** Reads a bounded, account-scoped thread from synchronized connector knowledge. */
|
|
12
12
|
var SceneMailContextProvider = class {
|
|
13
13
|
id = "mail";
|
|
14
|
+
tracksHealth = true;
|
|
15
|
+
requiresAccountIdentity = true;
|
|
14
16
|
constructor(db, clock = Date.now) {
|
|
15
17
|
this.db = db;
|
|
16
18
|
this.clock = clock;
|
|
17
19
|
}
|
|
20
|
+
setupIssues(activation) {
|
|
21
|
+
return activation.scope.kind === "objects" && activation.scope.ids.length === 1 && activation.permissions.accountIds.length === 1 ? [] : ["one_mail_thread_and_account"];
|
|
22
|
+
}
|
|
23
|
+
authorization(activation) {
|
|
24
|
+
const accounts = this.authorizedAccounts(activation);
|
|
25
|
+
return accounts.length ? accounts : null;
|
|
26
|
+
}
|
|
18
27
|
/** Resolve current account grants for the exact delegated source, including reconnects and revocation. */
|
|
19
28
|
authorizedAccounts(activation) {
|
|
20
29
|
if (activation.scope.kind !== "objects" || activation.scope.ids.length !== 1) return [];
|