@xopcai/xopc 0.0.331 → 0.0.333
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-B0BtF24E.js → agent-avatar-dicebear-DiI2O7lC.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CVp3J969.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-DbvLXQO2.js → agent-plugin-dialog-CacyndrS.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DXYZSuUV.js +70 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-fwzTRJfP.js → app-management-settings-panel-BcszTlqr.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-v_GGe8UZ.js → appearance-settings-B1XPe8qz.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-C9ZMEuuA.js → apps-page-ZqANbUZv.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-B6EgADeH.js → archive-plugin-MjUsJcNb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B4H_IFeX.js → attachment-load-DHa-BI9a.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-UlVCvg4r.js → automations-page-Dsjivdxs.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B37vs5tk.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BxTSx30f.js → binary-plugins-DQYcuBHP.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CVzdrpjl.js → block-editor-Bx0uXbJP.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-1ZIPGDeq.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-CBVD8k6O.js → browser-automations-page-CCjYipHc.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CSv4rvmx.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-BnO9LV7U.js +1 -0
- package/dist/gateway/static/root/assets/{capabilities-page-BAT7Vvb8.js → capabilities-page-BfvDvIY1.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CoW7-ESq.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-EETjXmkG.js → capability-header-actions-D_hbWRRF.js} +1 -1
- package/dist/gateway/static/root/assets/channels-BhMaRh1x.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DCqm9j9W.js → chat-terminal-dock-Fnum_IEm.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CxFWdovV.js → computer-settings-page-DI1zfCTA.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-wxsEhmlU.js → connector-service-page-CiGDAubm.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-Ono0Pha1.js +2 -0
- package/dist/gateway/static/root/assets/{date-picker-h_OS6uBR.js → date-picker-D-JhzZyW.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DNgSSH3z.js → dependency-picker-DpD3xaEB.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CflvPnB-.js → desktop-pet-CCoDxKqh.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CXy0X5Js.js → desktop-pet-settings-GxndKfCx.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-BDMiJcsK.js → device-pairing-wizard-B71w3ptm.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BqkOh13m.js → directory-picker-path-field-CUzjJvjs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-VT4s-9pK.js → extension-debug-page-BtDY8ntX.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CBSeGhGA.js → extension-page-D9_XF-XC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DRB6uOo8.js → extension-settings-page-CjhUFAaC.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-settings-lF-FpnZy.js → gateway-settings-BWaCnwT1.js} +1 -1
- 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-BTjGLngn.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-DGkOijwE.js → imports-page-BEtq5BRU.js} +1 -1
- package/dist/gateway/static/root/assets/index-DHL16aYZ.js +121 -0
- package/dist/gateway/static/root/assets/index-N1e6PDwx.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-iU6c2zg1.js → keyboard-shortcuts-settings-JUYY_18v.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-uI7mtoVz.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-C0BWC8D2.js → local-apps-page-BlYESNqz.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Dpoi-r-_.js → logs-page-BbLQreeN.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-c4krhYU7.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-BEeXMfDw.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C8E_F2F_.js → media-plugins-DEFN1I73.js} +1 -1
- package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel--09xGxyE.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-DsxcVBXF.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-qqWG_gs_.js → page-context-capture-button-D43aVpCj.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-b3lheKy4.js → page-tabs-BhYBCqls.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-0Q4rTfGX.js → preview-open-alternatives-CP8agNlc.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-jnJZCrKQ.js → product-open-page-CU7fRhfT.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-U-EdDfAW.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-r96k_2wB.js → projects-page-DUOKZLt7.js} +1 -1
- 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-B1d8pB_y.js → remote-access-hub-fVPQe5YS.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Do_iF13W.js → runtime-tools-settings-panel-Czvzsuj_.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-C0-WHOY3.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-Cfft26Je.js → schema-form-B9Ni5O93.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DdXvW09N.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BtF83fBY.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-iI0MTyuU.js → settings-form-section-jquf1P7n.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C2Ka9oJm.js → settings-page-DPomsvba.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-nnmS_p5h.js → setup-status-panel-BvVlqpHf.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D0Knvtlp.js → share-preview-page-b9DI0N1J.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-R_qwc4DN.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-BuZKcy9b.js → skill-api-Bu7-3w-L.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CNJAQ_e-.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DcxWxIrR.js → skills-page-D7XPEQu_.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CMG0ZAsd.js → system-settings-panel-BwFR0Uci.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-PFjGW2g1.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DGYA6GyO.js → tunnel-api-PfucxMP3.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-t_zdQHcy.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CDemMoSX.js → use-autosave-DLyy2wHz.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-OyfPVfB9.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CXArY4t5.js → voice-api-key-field-CQDY5EBK.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-Dk5KsKOm.js → work-discovery-overlay-CJzqJ47I.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DNpdaI-2.js → workflow-run-setup-panel-sCOk-esV.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DYBGjN7C.js +6 -0
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +59 -14
- package/dist/packages/gateway-contract/src/capabilities.js +106 -8
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/gateway-contract/src/scenes.js +7 -6
- package/dist/packages/gateway-contract/src/sessions.js +2 -1
- package/dist/packages/gateway-contract/src/usage.js +6 -0
- package/dist/src/agent/agent-manager.js +13 -7
- package/dist/src/agent/background-review/run-background-review.js +7 -2
- package/dist/src/agent/bootstrap/filter-bootstrap-files.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 +44 -11
- package/dist/src/agent/external-tools/index.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- 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/orchestration/agent-orchestrator.js +0 -21
- package/dist/src/agent/service/btw-query.js +8 -2
- package/dist/src/agent/service.js +3 -3
- 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 +4 -0
- 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 +5 -1
- 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 +69 -14
- package/dist/src/automations/capabilities/write.js +78 -5
- 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 +2 -2
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +180 -7
- package/dist/src/automations/domain/validation.d.ts +172 -22
- package/dist/src/automations/domain/validation.js +82 -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 +31 -3
- package/dist/src/automations/draft/automation-draft-validator.js +5 -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 -24
- 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 +7 -7
- 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/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/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/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/config/schema.js +5 -1
- package/dist/src/connectors/approval-resume.js +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-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/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.d.ts +3 -0
- package/dist/src/gateway/home-intelligence-automation-reconciler.js +52 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -4
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
- package/dist/src/gateway/hono/routes/home.js +0 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- 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-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +15 -0
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/update.js +6 -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 +1 -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 +21 -15
- 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 +9 -1
- 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 +7 -3
- package/dist/src/gateway/service.js +108 -89
- 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 +4 -1
- package/dist/src/home-intelligence/host.d.ts +1 -1
- package/dist/src/home-intelligence/host.js +2 -10
- package/dist/src/home-intelligence/notification.js +1 -1
- package/dist/src/home-intelligence/repository.d.ts +1 -1
- package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
- package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
- package/dist/src/infra/update-check.d.ts +8 -4
- package/dist/src/infra/update-check.js +43 -41
- package/dist/src/infra/update-startup.d.ts +7 -1
- package/dist/src/infra/update-startup.js +15 -6
- package/dist/src/local-apps/service.js +2 -2
- package/dist/src/memory-maintenance/index.js +2 -2
- package/dist/src/memory-maintenance/schedule.d.ts +0 -3
- package/dist/src/memory-maintenance/schedule.js +1 -8
- package/dist/src/notes/service.js +2 -3
- package/dist/src/projects/project-service.js +1 -2
- package/dist/src/projects/project-skill-service.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/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 -2
- 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/208_automation_management.sql +2 -0
- 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/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-input-repository.d.ts +8 -0
- package/dist/src/storage/sqlite/session-input-repository.js +18 -1
- 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 +4 -3
- package/dist/src/tasks/task-contract-planner.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- 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/user-context/config.d.ts +9 -0
- package/dist/src/user-context/config.js +13 -4
- 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/workflows/service/workflow-run-service.js +15 -2
- package/package.json +6 -6
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DgP5DEJF.js +0 -1
- package/dist/gateway/static/root/assets/agents-Bh4XNLyk.js +0 -70
- package/dist/gateway/static/root/assets/automations-workspace-C7VS-yb7.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-CC43CC43.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DPETQOfF.js +0 -8
- package/dist/gateway/static/root/assets/channels-CwA619os.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-l7goF6QS.js +0 -2
- package/dist/gateway/static/root/assets/home-page-DSaXXoLm.js +0 -1
- package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
- package/dist/gateway/static/root/assets/index-D99vN3es.js +0 -121
- package/dist/gateway/static/root/assets/local-app-workbench-page-rH33N8I9.js +0 -1
- package/dist/gateway/static/root/assets/management-settings-RFDLaquR.js +0 -1
- package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-DI7CIjmM.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BkqnU-Jh.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-BvvcTH2F.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-DK316w9a.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-EIk8iJTK.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DcOsdz78.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BcaxGQLC.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Cb_CUL-U.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-Cvr1qUTW.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-VXfz3rE7.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DDNDLdId.js +0 -6
- package/dist/src/automations/product-events.d.ts +0 -5
- package/dist/src/automations/product-events.js +0 -19
|
@@ -66,14 +66,22 @@ function registerSceneRoutes(authenticated, deps) {
|
|
|
66
66
|
idempotencyKey: c.req.header("Idempotency-Key") ?? randomUUID()
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const template = (key, version) => deps.scenes.repository.getTemplate(key, version);
|
|
70
|
+
const adapterTarget = (key, version) => {
|
|
71
|
+
const manifest = template(key, version);
|
|
72
|
+
return manifest.execution.kind === "agent" ? void 0 : {
|
|
73
|
+
manifest,
|
|
74
|
+
adapter: deps.scenes.activationAdapters.get(manifest.execution.kind)
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
app.get("/source-providers", (c) => c.json({ providers: deps.scenes.sourceProviders.providers() }));
|
|
78
|
+
app.get("/source-providers/:provider/accounts", (c) => c.json({ accounts: deps.scenes.sourceProviders.get(c.req.param("provider")).listAccounts?.(principal(c)) ?? [] }));
|
|
71
79
|
app.post("/source-providers/:provider/resolve-link", deps.strictRateLimitMiddleware, async (c) => {
|
|
72
80
|
const input = z.strictObject({
|
|
73
81
|
accountId: z.string().min(1).max(200),
|
|
74
82
|
url: z.string().url().max(2e3)
|
|
75
83
|
}).parse(await c.req.json());
|
|
76
|
-
const source = deps.scenes.
|
|
84
|
+
const source = deps.scenes.sourceProviders.get(c.req.param("provider"));
|
|
77
85
|
if (!source?.resolveLink) return c.json({ error: "source_resolution_unavailable" }, 422);
|
|
78
86
|
const reference = await source.resolveLink(principal(c), input.accountId, input.url, AbortSignal.any([c.req.raw.signal, AbortSignal.timeout(3e4)]));
|
|
79
87
|
return c.json({ source: {
|
|
@@ -81,48 +89,21 @@ function registerSceneRoutes(authenticated, deps) {
|
|
|
81
89
|
reference
|
|
82
90
|
} });
|
|
83
91
|
});
|
|
84
|
-
app.get("/
|
|
85
|
-
|
|
86
|
-
if (!
|
|
87
|
-
return c.json(await
|
|
92
|
+
app.get("/resources/projects/:projectId/branches", async (c) => {
|
|
93
|
+
const owner = deps.scenes.activationAdapters.list().find((item) => item.listProjectBranches);
|
|
94
|
+
if (!owner?.listProjectBranches) return c.json({ error: "branch_inventory_unavailable" }, 503);
|
|
95
|
+
return c.json(await owner.listProjectBranches(principal(c), c.req.param("projectId")));
|
|
88
96
|
});
|
|
89
|
-
app.post("/
|
|
97
|
+
app.post("/resources/branch-links", deps.strictRateLimitMiddleware, async (c) => {
|
|
90
98
|
const input = z.strictObject({
|
|
91
99
|
projectId: z.string().min(1).max(200),
|
|
92
100
|
taskId: z.string().uuid(),
|
|
93
101
|
branchRef: z.string().startsWith("refs/heads/").max(300),
|
|
94
102
|
expectedSha: z.string().regex(/^[a-f0-9]{40,64}$/)
|
|
95
103
|
}).parse(await c.req.json());
|
|
96
|
-
|
|
97
|
-
return c.json(
|
|
98
|
-
|
|
99
|
-
app.post("/task-follow-ups/preflight", deps.strictRateLimitMiddleware, async (c) => {
|
|
100
|
-
if (!deps.scenes.followUps) return c.json({ error: "task_follow_up_unavailable" }, 503);
|
|
101
|
-
return c.json(await deps.scenes.followUps.preflight(principal(c), await c.req.json()));
|
|
102
|
-
});
|
|
103
|
-
app.post("/task-follow-ups", deps.strictRateLimitMiddleware, async (c) => {
|
|
104
|
-
if (!deps.scenes.followUps) return c.json({ error: "task_follow_up_unavailable" }, 503);
|
|
105
|
-
return c.json(await deps.scenes.followUps.create(principal(c), await c.req.json()), 201);
|
|
106
|
-
});
|
|
107
|
-
app.get("/task-follow-ups/:id", (c) => {
|
|
108
|
-
if (!deps.scenes.followUps) return c.json({ error: "task_follow_up_unavailable" }, 503);
|
|
109
|
-
return c.json(deps.scenes.followUps.get(principal(c), c.req.param("id")));
|
|
110
|
-
});
|
|
111
|
-
app.patch("/task-follow-ups/:id", deps.strictRateLimitMiddleware, async (c) => {
|
|
112
|
-
const input = z.union([z.strictObject({
|
|
113
|
-
expectedRevision: z.number().int().positive(),
|
|
114
|
-
status: z.enum([
|
|
115
|
-
"active",
|
|
116
|
-
"paused",
|
|
117
|
-
"archived"
|
|
118
|
-
])
|
|
119
|
-
}), z.strictObject({
|
|
120
|
-
expectedRevision: z.number().int().positive(),
|
|
121
|
-
configuration: z.unknown()
|
|
122
|
-
})]).parse(await c.req.json());
|
|
123
|
-
if (!deps.scenes.followUps) return c.json({ error: "task_follow_up_unavailable" }, 503);
|
|
124
|
-
if ("configuration" in input) return c.json(await deps.scenes.followUps.configure(principal(c), c.req.param("id"), input.expectedRevision, input.configuration));
|
|
125
|
-
return c.json(await deps.scenes.followUps.transition(principal(c), c.req.param("id"), input.expectedRevision, input.status));
|
|
104
|
+
const owner = deps.scenes.activationAdapters.list().find((item) => item.associateBranch);
|
|
105
|
+
if (!owner?.associateBranch) return c.json({ error: "branch_inventory_unavailable" }, 503);
|
|
106
|
+
return c.json(await owner.associateBranch(principal(c), input));
|
|
126
107
|
});
|
|
127
108
|
app.post("/browser/prepare", deps.strictRateLimitMiddleware, (c) => c.json(deps.scenes.browser.prepare()));
|
|
128
109
|
app.post("/browser/subscriptions", deps.strictRateLimitMiddleware, async (c) => c.json(deps.scenes.browser.register(principal(c), await c.req.json()), 201));
|
|
@@ -160,7 +141,14 @@ function registerSceneRoutes(authenticated, deps) {
|
|
|
160
141
|
key: c.req.param("key"),
|
|
161
142
|
version: c.req.param("version")
|
|
162
143
|
})));
|
|
163
|
-
app.post("/preflight", deps.strictRateLimitMiddleware, async (c) =>
|
|
144
|
+
app.post("/preflight", deps.strictRateLimitMiddleware, async (c) => {
|
|
145
|
+
const body = await c.req.json();
|
|
146
|
+
if (typeof body.templateKey === "string" && typeof body.templateVersion === "string") {
|
|
147
|
+
const target = adapterTarget(body.templateKey, body.templateVersion);
|
|
148
|
+
if (target) return c.json(await target.adapter.preflight(principal(c), target.manifest, body.configuration));
|
|
149
|
+
}
|
|
150
|
+
return c.json(await read(c, "xopc.scenes.preflight", body));
|
|
151
|
+
});
|
|
164
152
|
app.get("/activations", async (c) => {
|
|
165
153
|
return c.json(await read(c, "xopc.scenes.list", {
|
|
166
154
|
...c.req.query(),
|
|
@@ -169,14 +157,42 @@ function registerSceneRoutes(authenticated, deps) {
|
|
|
169
157
|
});
|
|
170
158
|
app.post("/activations", deps.strictRateLimitMiddleware, async (c) => {
|
|
171
159
|
requestIdentity.parse(c.req.header("Idempotency-Key"));
|
|
172
|
-
|
|
160
|
+
const body = await c.req.json();
|
|
161
|
+
if (typeof body.templateKey === "string" && typeof body.templateVersion === "string") {
|
|
162
|
+
const target = adapterTarget(body.templateKey, body.templateVersion);
|
|
163
|
+
if (target) return c.json(await target.adapter.create(principal(c), target.manifest, body.configuration), 201);
|
|
164
|
+
}
|
|
165
|
+
return c.json(await write(c, "xopc.scenes.start", body), 201);
|
|
173
166
|
});
|
|
174
167
|
app.get("/activations/:id", async (c) => {
|
|
175
168
|
const { activation } = ProductReadContracts["xopc.scenes.get"].output.parse(await read(c, "xopc.scenes.get", { id: c.req.param("id") }));
|
|
176
|
-
|
|
169
|
+
const manifest = template(activation.templateKey, activation.templateVersion);
|
|
170
|
+
const activationAdapter = manifest.execution.kind === "agent" ? void 0 : deps.scenes.activationAdapters.get(manifest.execution.kind);
|
|
171
|
+
return c.json({
|
|
172
|
+
activation,
|
|
173
|
+
template: manifest,
|
|
174
|
+
...activationAdapter ? { details: activationAdapter.get(principal(c), activation.id) } : {}
|
|
175
|
+
});
|
|
177
176
|
});
|
|
178
177
|
app.patch("/activations/:id", deps.strictRateLimitMiddleware, async (c) => {
|
|
179
178
|
const body = await c.req.json();
|
|
179
|
+
const activation = deps.scenes.repository.getActivation(principal(c), c.req.param("id"));
|
|
180
|
+
const manifest = template(activation.templateKey, activation.templateVersion);
|
|
181
|
+
if (manifest.execution.kind !== "agent") {
|
|
182
|
+
const input = z.union([z.strictObject({
|
|
183
|
+
expectedRevision: z.number().int().positive(),
|
|
184
|
+
status: z.enum([
|
|
185
|
+
"active",
|
|
186
|
+
"paused",
|
|
187
|
+
"archived"
|
|
188
|
+
])
|
|
189
|
+
}), z.strictObject({
|
|
190
|
+
expectedRevision: z.number().int().positive(),
|
|
191
|
+
configuration: z.unknown()
|
|
192
|
+
})]).parse(body);
|
|
193
|
+
const execution = deps.scenes.activationAdapters.get(manifest.execution.kind);
|
|
194
|
+
return c.json("configuration" in input ? await execution.configure(principal(c), activation.id, input.expectedRevision, input.configuration) : await execution.transition(principal(c), activation.id, input.expectedRevision, input.status));
|
|
195
|
+
}
|
|
180
196
|
if (!(typeof body === "object" && body !== null && Object.hasOwn(body, "status"))) return c.json(await write(c, "xopc.scenes.configure", {
|
|
181
197
|
...body,
|
|
182
198
|
id: c.req.param("id")
|
|
@@ -4,9 +4,9 @@ import { parseUserTurnDocument, userTurnDocumentRefIds } from "../../../../packa
|
|
|
4
4
|
import { browserPageContextsInputSchema } from "../../../../packages/gateway-contract/src/browser-page-context.js";
|
|
5
5
|
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
6
6
|
import { endpointTurnClaimSchema, init_src as init_src$1 } from "../../../../packages/endpoint-tools-protocol/src/index.js";
|
|
7
|
+
import { init_providers, resolveModel } from "../../../providers/index.js";
|
|
7
8
|
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
8
9
|
import "../../../capabilities/runtime/dispatcher.js";
|
|
9
|
-
import { init_providers, resolveModel } from "../../../providers/index.js";
|
|
10
10
|
import { validateWebchatAttachments, validateWebchatContent } from "../../chat-limits.js";
|
|
11
11
|
import { isTaskDestructiveCommand } from "../../../session/reset-triggers.js";
|
|
12
12
|
import { parseSlashCommand } from "../../../chat-commands/command-parse.js";
|
|
@@ -109,6 +109,15 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
109
109
|
payload: { runs: service.sessions.listActiveRuns() }
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
|
+
authenticated.get("/api/runtime/quit-impact", async (c) => {
|
|
113
|
+
const blocked = ensureGatewayReadyForSessions(c, service, "sessions.list");
|
|
114
|
+
if (blocked) return blocked;
|
|
115
|
+
c.header("Cache-Control", "no-store");
|
|
116
|
+
return c.json({
|
|
117
|
+
ok: true,
|
|
118
|
+
payload: await service.sessions.getQuitImpact()
|
|
119
|
+
});
|
|
120
|
+
});
|
|
112
121
|
authenticated.get("/api/sidebar/chat-list", async (c) => {
|
|
113
122
|
const blocked = ensureGatewayReadyForSessions(c, service, "sessions.list");
|
|
114
123
|
if (blocked) return blocked;
|
|
@@ -564,6 +573,12 @@ function registerSessionsRoutes(authenticated, deps) {
|
|
|
564
573
|
includeContextRows: true
|
|
565
574
|
});
|
|
566
575
|
if (!result) return c.json({ error: "Session not found" }, 404);
|
|
576
|
+
const revision = result.pagination.revision;
|
|
577
|
+
if (typeof revision === "number") {
|
|
578
|
+
const etag = `"${result.session.transcriptId ?? key}:${revision}"`;
|
|
579
|
+
c.header("ETag", etag);
|
|
580
|
+
if (c.req.header("If-None-Match") === etag) return c.body(null, 304);
|
|
581
|
+
}
|
|
567
582
|
return c.json(result);
|
|
568
583
|
});
|
|
569
584
|
authenticated.get("/api/sessions/:key/timeline", async (c) => {
|
|
@@ -5,9 +5,9 @@ import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
|
5
5
|
import { enqueueTaskChangedEvent, init_task_change_events } from "../../../tasks/task-change-events.js";
|
|
6
6
|
import { TaskRepository, init_task_repository } from "../../../tasks/task-repository.js";
|
|
7
7
|
import { TaskRunRepository, init_task_run_repository } from "../../../tasks/task-run-repository.js";
|
|
8
|
+
import { TaskConversationRepository } from "../../../tasks/task-conversation-repository.js";
|
|
8
9
|
import { CapabilityError } from "../../../capabilities/runtime/errors.js";
|
|
9
10
|
import "../../../capabilities/runtime/dispatcher.js";
|
|
10
|
-
import { TaskConversationRepository } from "../../../tasks/task-conversation-repository.js";
|
|
11
11
|
import { TaskContextMutationOutputSchema } from "../../../tasks/capabilities/relations.js";
|
|
12
12
|
import { TaskDeleteOutputSchema } from "../../../tasks/capabilities/management.js";
|
|
13
13
|
import { TaskMutationOutputSchema } from "../../../tasks/capabilities/write.js";
|
|
@@ -32,13 +32,18 @@ function registerUpdateRoutes(authenticated, deps) {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
authenticated.post("/api/update/check", strictRateLimitMiddleware, async (c) => {
|
|
35
|
-
await runGatewayUpdateCheck({
|
|
35
|
+
const checkResult = await runGatewayUpdateCheck({
|
|
36
36
|
config: loadConfig(service.getHealth().configPath),
|
|
37
37
|
force: true,
|
|
38
38
|
onUpdateAvailableChange: (update) => {
|
|
39
39
|
service.emit("update.available", update);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
if (checkResult.ok === false) return c.json({
|
|
43
|
+
ok: false,
|
|
44
|
+
error: "update-check-failed",
|
|
45
|
+
message: `Could not check npm for updates: ${checkResult.error}`
|
|
46
|
+
}, 502);
|
|
42
47
|
const result = getUpdateAvailable();
|
|
43
48
|
return c.json({
|
|
44
49
|
ok: true,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getAiUsageEventView, listAiUsageEvents, listAiUsageTrace, summarizeAiUsage } from "../../../storage/sqlite/ai-usage-repository.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { Hono } from "hono";
|
|
4
|
+
//#region src/gateway/hono/routes/usage.ts
|
|
5
|
+
const MAX_RANGE_MS = 366 * 24 * 60 * 60 * 1e3;
|
|
6
|
+
const DEFAULT_RANGE_MS = 10080 * 60 * 1e3;
|
|
7
|
+
const filtersSchema = z.object({
|
|
8
|
+
from: z.coerce.number().int().nonnegative().optional(),
|
|
9
|
+
to: z.coerce.number().int().positive().optional(),
|
|
10
|
+
category: z.string().trim().min(1).max(80).optional(),
|
|
11
|
+
provider: z.string().trim().min(1).max(120).optional(),
|
|
12
|
+
model: z.string().trim().min(1).max(240).optional(),
|
|
13
|
+
agentId: z.string().trim().min(1).max(200).optional(),
|
|
14
|
+
conversationId: z.string().trim().min(1).max(200).optional()
|
|
15
|
+
});
|
|
16
|
+
function parseFilters(value) {
|
|
17
|
+
const parsed = filtersSchema.parse(value);
|
|
18
|
+
const to = parsed.to ?? Date.now() + 1;
|
|
19
|
+
const from = parsed.from ?? to - DEFAULT_RANGE_MS;
|
|
20
|
+
if (from >= to || to - from > MAX_RANGE_MS) throw new Error("invalid_usage_range");
|
|
21
|
+
return {
|
|
22
|
+
...parsed,
|
|
23
|
+
from,
|
|
24
|
+
to
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function parseCursor(value) {
|
|
28
|
+
if (!value) return void 0;
|
|
29
|
+
const separator = value.indexOf(":");
|
|
30
|
+
const startedAt = Number(value.slice(0, separator));
|
|
31
|
+
const id = value.slice(separator + 1);
|
|
32
|
+
if (separator < 1 || !Number.isSafeInteger(startedAt) || startedAt < 0 || !id) throw new Error("invalid_usage_cursor");
|
|
33
|
+
return {
|
|
34
|
+
startedAt,
|
|
35
|
+
id
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function registerUsageRoutes(authenticated, _deps) {
|
|
39
|
+
const app = new Hono();
|
|
40
|
+
app.onError((error, c) => {
|
|
41
|
+
if (error instanceof z.ZodError || error.message.startsWith("invalid_usage_")) return c.json({ error: "invalid_usage_query" }, 400);
|
|
42
|
+
throw error;
|
|
43
|
+
});
|
|
44
|
+
app.get("/summary", (c) => c.json(summarizeAiUsage(parseFilters(c.req.query()))));
|
|
45
|
+
app.get("/events", (c) => {
|
|
46
|
+
const limit = z.coerce.number().int().min(1).max(200).optional().parse(c.req.query("limit"));
|
|
47
|
+
return c.json(listAiUsageEvents({
|
|
48
|
+
...parseFilters(c.req.query()),
|
|
49
|
+
limit,
|
|
50
|
+
before: parseCursor(c.req.query("cursor"))
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
53
|
+
app.get("/events/:id", (c) => {
|
|
54
|
+
const event = getAiUsageEventView(c.req.param("id"));
|
|
55
|
+
return event ? c.json({ event }) : c.json({ error: "usage_event_not_found" }, 404);
|
|
56
|
+
});
|
|
57
|
+
app.get("/traces/:traceId", (c) => c.json({ events: listAiUsageTrace(c.req.param("traceId")) }));
|
|
58
|
+
authenticated.route("/api/usage", app);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { registerUsageRoutes };
|
|
@@ -101,7 +101,7 @@ async function refineTranscript(raw, config, signal) {
|
|
|
101
101
|
maxTokens: Math.min(raw.length * 3, 4096),
|
|
102
102
|
temperature: .2,
|
|
103
103
|
signal: mergedSignal
|
|
104
|
-
});
|
|
104
|
+
}, void 0, { operation: "voice.select" });
|
|
105
105
|
let out = "";
|
|
106
106
|
if (Array.isArray(result.content)) {
|
|
107
107
|
for (const c of result.content) if (c && typeof c === "object" && c.type === "text") out += String(c.text || "");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { normalizeAgentId } from "../agent-catalog/id.js";
|
|
2
2
|
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
3
|
-
import { init_agent_scope } from "../agent/agent-scope.js";
|
|
4
|
-
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
5
3
|
import { ConfigSchema, init_schema } from "../config/schema.js";
|
|
4
|
+
import { init_agent_scope } from "../agent/agent-scope.js";
|
|
6
5
|
import { resolveEffectiveAgentConfigForAgent } from "../config/agent-profile.js";
|
|
7
6
|
import { fetchWithTimeoutGuarded } from "../media-shared/http/provider-http.js";
|
|
8
7
|
import "../media-shared/http/index.js";
|
|
8
|
+
import { AgentCatalogService } from "../agent-catalog/service.js";
|
|
9
9
|
import { getImageGenerationProvider, listImageGenerationProvidersSummary } from "../agent/image/generation/provider-registry.js";
|
|
10
10
|
//#region src/gateway/image-generation-setup.ts
|
|
11
11
|
init_repository();
|
package/dist/src/gateway/lock.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import fs$1 from "node:fs/promises";
|
|
5
4
|
import net from "node:net";
|
|
5
|
+
import fs$1 from "node:fs/promises";
|
|
6
6
|
import { homedir } from "os";
|
|
7
7
|
//#region src/gateway/lock.ts
|
|
8
8
|
/**
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { init_agent_scope, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agent/agent-scope.js";
|
|
3
|
-
import { maintenanceInstruction, resolveMemoryMaintenanceSchedules } from "../memory-maintenance/schedule.js";
|
|
1
|
+
import { resolveMemoryMaintenanceSchedules } from "../memory-maintenance/schedule.js";
|
|
4
2
|
import "../memory-maintenance/index.js";
|
|
5
3
|
//#region src/gateway/memory-maintenance-automation-reconciler.ts
|
|
6
|
-
init_agent_scope();
|
|
7
4
|
const AUTOMATION_IDS = [
|
|
8
5
|
"system-memory-temporal-sweep",
|
|
9
6
|
"system-memory-daily-reconciliation",
|
|
@@ -17,8 +14,6 @@ async function reconcileMemoryMaintenanceAutomations(input) {
|
|
|
17
14
|
};
|
|
18
15
|
const schedules = resolveMemoryMaintenanceSchedules(input.config);
|
|
19
16
|
const enabledIds = new Set(schedules.map((item) => item.automationId));
|
|
20
|
-
const agentId = normalizeAgentId(resolveDefaultAgentId());
|
|
21
|
-
const workingDirectory = resolveAgentWorkspaceDir(agentId);
|
|
22
17
|
for (const id of AUTOMATION_IDS) {
|
|
23
18
|
if (enabledIds.has(id)) continue;
|
|
24
19
|
if ((await input.automationService.get(id))?.enabled) {
|
|
@@ -36,11 +31,8 @@ async function reconcileMemoryMaintenanceAutomations(input) {
|
|
|
36
31
|
}
|
|
37
32
|
};
|
|
38
33
|
const action = {
|
|
39
|
-
kind: "
|
|
40
|
-
|
|
41
|
-
instruction: maintenanceInstruction(schedule.jobType),
|
|
42
|
-
workingDirectory,
|
|
43
|
-
timeoutSeconds: 300
|
|
34
|
+
kind: "system",
|
|
35
|
+
capability: `memory.${schedule.jobType}`
|
|
44
36
|
};
|
|
45
37
|
const next = {
|
|
46
38
|
name: schedule.name,
|
|
@@ -50,8 +42,17 @@ async function reconcileMemoryMaintenanceAutomations(input) {
|
|
|
50
42
|
action,
|
|
51
43
|
safety: { mode: "auto_apply" },
|
|
52
44
|
conversationMode: "continuous",
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
delivery: {
|
|
46
|
+
notificationPolicy: "none",
|
|
47
|
+
destinations: []
|
|
48
|
+
},
|
|
49
|
+
reliability: { disableAfterConsecutiveFailures: 3 },
|
|
50
|
+
management: {
|
|
51
|
+
owner: "memory-maintenance",
|
|
52
|
+
editable: ["enabled", "trigger"],
|
|
53
|
+
runnable: true,
|
|
54
|
+
deletable: false
|
|
55
|
+
}
|
|
55
56
|
};
|
|
56
57
|
const current = await input.automationService.get(schedule.automationId);
|
|
57
58
|
if (!current) {
|
|
@@ -62,8 +63,13 @@ async function reconcileMemoryMaintenanceAutomations(input) {
|
|
|
62
63
|
result.created += 1;
|
|
63
64
|
continue;
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
const reconciled = current.management ? {
|
|
67
|
+
...next,
|
|
68
|
+
enabled: current.enabled,
|
|
69
|
+
trigger: current.trigger
|
|
70
|
+
} : next;
|
|
71
|
+
if (current.name !== reconciled.name || current.description !== next.description || current.enabled !== reconciled.enabled || JSON.stringify(current.trigger) !== JSON.stringify(reconciled.trigger) || JSON.stringify(current.action) !== JSON.stringify(action) || current.safety?.mode !== "auto_apply" || current.delivery.notificationPolicy !== "none" || JSON.stringify(current.management) !== JSON.stringify(next.management)) {
|
|
72
|
+
await input.automationService.update(schedule.automationId, reconciled);
|
|
67
73
|
result.updated += 1;
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -13,6 +13,7 @@ import { SceneMailObservationService } from "../../scenes/mailObservations.js";
|
|
|
13
13
|
import { maintainSceneStorage } from "../../scenes/maintenance.js";
|
|
14
14
|
import { SceneMetrics } from "../../scenes/metrics.js";
|
|
15
15
|
import { resolveSceneModelRef } from "../../scenes/model.js";
|
|
16
|
+
import { SceneCapabilityRegistry } from "../../scenes/registry.js";
|
|
16
17
|
import { SceneResultNotifications } from "../../scenes/resultNotifications.js";
|
|
17
18
|
import { SceneRuntime } from "../../scenes/runtime.js";
|
|
18
19
|
import { familyPlanTemplate, mailFollowUpTemplate } from "../../scenes/templates.js";
|
|
@@ -20,8 +21,8 @@ import { SceneUserNotesProvider } from "../../scenes/userNotes.js";
|
|
|
20
21
|
import { createSceneBrowserDispatcher } from "./browserNotifications.js";
|
|
21
22
|
import { GatewaySceneMailContext } from "./mailContext.js";
|
|
22
23
|
import { SlackThreadSource } from "./slackThreadSource.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
24
|
+
import { SceneSourceRegistry, decisionLogTemplate, taskFollowUpTemplate } from "../../scenes/taskFollowUp/contracts.js";
|
|
25
|
+
import { SceneTaskExecutionService } from "../../scenes/taskFollowUp/service.js";
|
|
25
26
|
//#region src/gateway/scenes/host.ts
|
|
26
27
|
init_providers();
|
|
27
28
|
init_scenes_schema();
|
|
@@ -47,30 +48,39 @@ var GatewaySceneHost = class {
|
|
|
47
48
|
const repository = new SceneRepository(db);
|
|
48
49
|
repository.installTemplate(mailFollowUpTemplate);
|
|
49
50
|
repository.installTemplate(familyPlanTemplate);
|
|
51
|
+
repository.installTemplate(taskFollowUpTemplate);
|
|
52
|
+
repository.installTemplate(decisionLogTemplate);
|
|
50
53
|
const mail = input.mail ?? new GatewaySceneMailContext(db, clock);
|
|
51
|
-
const providers = [mail, new SceneUserNotesProvider(db, clock)];
|
|
54
|
+
const providers = new SceneCapabilityRegistry([mail, new SceneUserNotesProvider(db, clock)]);
|
|
52
55
|
const authorize = (activation) => {
|
|
53
56
|
if (activation.ownerId !== input.principal.ownerId || activation.workspaceId !== input.principal.workspaceId) return {
|
|
54
57
|
accountIds: [],
|
|
55
58
|
contextProviders: [],
|
|
56
59
|
effectHandlers: []
|
|
57
60
|
};
|
|
58
|
-
const
|
|
61
|
+
const grants = providers.list().flatMap((provider) => {
|
|
62
|
+
const accountIds = provider.authorization?.(activation) ?? null;
|
|
63
|
+
return accountIds === null ? [] : [{
|
|
64
|
+
id: provider.id,
|
|
65
|
+
accountIds
|
|
66
|
+
}];
|
|
67
|
+
});
|
|
59
68
|
return {
|
|
60
|
-
accountIds,
|
|
61
|
-
contextProviders:
|
|
69
|
+
accountIds: [...new Set(grants.flatMap((grant) => grant.accountIds))],
|
|
70
|
+
contextProviders: grants.map((grant) => grant.id),
|
|
62
71
|
effectHandlers: []
|
|
63
72
|
};
|
|
64
73
|
};
|
|
65
74
|
const grant = async (activation) => authorize(activation);
|
|
66
75
|
const executor = input.executor ?? new SceneAgentExecutor(() => resolveModel(resolveSceneModelRef(input.config())));
|
|
67
|
-
const
|
|
68
|
-
const
|
|
76
|
+
const sourceProviders = new SceneSourceRegistry([new SlackThreadSource(db)]);
|
|
77
|
+
const activationAdapters = new SceneCapabilityRegistry([new SceneTaskExecutionService(db, {
|
|
69
78
|
config: input.config,
|
|
70
|
-
sources:
|
|
71
|
-
});
|
|
79
|
+
sources: sourceProviders
|
|
80
|
+
})]);
|
|
72
81
|
this.http = {
|
|
73
|
-
|
|
82
|
+
activationAdapters,
|
|
83
|
+
sourceProviders,
|
|
74
84
|
repository,
|
|
75
85
|
mail,
|
|
76
86
|
mailDiscovery: mail instanceof GatewaySceneMailContext ? mail : void 0,
|
|
@@ -99,7 +109,10 @@ var GatewaySceneHost = class {
|
|
|
99
109
|
assertSceneStorageReady(this.db);
|
|
100
110
|
this.runtime.start();
|
|
101
111
|
const poll = () => {
|
|
102
|
-
this.http.
|
|
112
|
+
for (const adapter of this.http.activationAdapters.list()) adapter.tick().catch((err) => log.error({
|
|
113
|
+
err,
|
|
114
|
+
adapter: adapter.id
|
|
115
|
+
}, "Scene adapter check failed"));
|
|
103
116
|
try {
|
|
104
117
|
if (this.clock() >= this.nextMaintenanceAt) {
|
|
105
118
|
maintainSceneStorage(this.db, this.clock());
|
|
@@ -118,7 +131,7 @@ var GatewaySceneHost = class {
|
|
|
118
131
|
tick() {
|
|
119
132
|
if (this.stopped) return Promise.reject(/* @__PURE__ */ new Error("Scene host stopped"));
|
|
120
133
|
if (this.active) return this.active;
|
|
121
|
-
const work = Promise.all([this.runtime.tick(), this.http.
|
|
134
|
+
const work = Promise.all([this.runtime.tick(), ...this.http.activationAdapters.list().map((adapter) => adapter.tick())]).then(() => {
|
|
122
135
|
if (!this.stopped) this.notifications.drain();
|
|
123
136
|
});
|
|
124
137
|
this.active = work.finally(() => {
|
|
@@ -131,7 +144,7 @@ var GatewaySceneHost = class {
|
|
|
131
144
|
this.stopped = true;
|
|
132
145
|
if (this.timer) clearInterval(this.timer);
|
|
133
146
|
this.timer = void 0;
|
|
134
|
-
await this.http.
|
|
147
|
+
await Promise.all(this.http.activationAdapters.list().map((adapter) => adapter.stop()));
|
|
135
148
|
await this.runtime.stop();
|
|
136
149
|
await this.browserDispatcher.stop();
|
|
137
150
|
await this.active?.catch(() => void 0);
|
|
@@ -2,7 +2,7 @@ import type { DatabaseSync } from 'node:sqlite';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ComposioSessionsAdapter } from '../../connectors/composio-sessions.js';
|
|
4
4
|
import { type ScenePrincipal } from '../../scenes/contracts.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { SceneSourceAdapter, SourceSnapshot } from '../../scenes/taskFollowUp/contracts.js';
|
|
6
6
|
export declare const slackThreadSchema: z.ZodObject<{
|
|
7
7
|
accountId: z.ZodString;
|
|
8
8
|
teamId: z.ZodString;
|
|
@@ -16,7 +16,7 @@ export declare function parseSlackThreadUrl(value: string): {
|
|
|
16
16
|
threadTs: string;
|
|
17
17
|
};
|
|
18
18
|
/** Read-only connector adapter. Account policy is rechecked before and after every page. */
|
|
19
|
-
export declare class SlackThreadSource implements
|
|
19
|
+
export declare class SlackThreadSource implements SceneSourceAdapter {
|
|
20
20
|
private readonly db;
|
|
21
21
|
private readonly adapter;
|
|
22
22
|
readonly id = "slack_thread";
|
|
@@ -22,6 +22,7 @@ function requiredGatewayScope(method, path) {
|
|
|
22
22
|
if (method === "GET" && path === "/api/connectors/approvals") return "sessions.read";
|
|
23
23
|
if (method === "POST" && path === "/api/connectors/approvals/respond") return "sessions.write";
|
|
24
24
|
if (path === "/api/agent" || path.startsWith("/api/agent/")) return "agents.run";
|
|
25
|
+
if (path.startsWith("/api/usage")) return "gateway.admin";
|
|
25
26
|
if (path.startsWith("/api/agents") || path.startsWith("/api/models")) return methodScope(method, "agents.read", "gateway.admin");
|
|
26
27
|
if (path.startsWith("/api/sessions") || path.startsWith("/api/side-chats")) return methodScope(method, "sessions.read", "sessions.write");
|
|
27
28
|
if (path.startsWith("/api/tasks")) return methodScope(method, "tasks.read", "tasks.write");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
|
|
2
|
+
export type ActiveExecutionKind = 'chat' | 'side-chat' | 'task' | 'workflow' | 'automation';
|
|
3
|
+
export type ActiveExecutionInitiator = 'user' | 'background';
|
|
4
|
+
export type ActiveExecution = {
|
|
5
|
+
conversationId: string;
|
|
6
|
+
runId: string;
|
|
7
|
+
kind: ActiveExecutionKind;
|
|
8
|
+
initiator: ActiveExecutionInitiator;
|
|
9
|
+
phase: 'running';
|
|
10
|
+
startedAt: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function describeActiveExecution(input: {
|
|
13
|
+
conversationId: string;
|
|
14
|
+
runId: string;
|
|
15
|
+
origin: TurnOrigin;
|
|
16
|
+
taskRunId?: string;
|
|
17
|
+
kind?: ActiveExecutionKind;
|
|
18
|
+
startedAt?: number;
|
|
19
|
+
}): ActiveExecution;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/gateway/service/active-execution.ts
|
|
2
|
+
function describeActiveExecution(input) {
|
|
3
|
+
const { origin } = input;
|
|
4
|
+
const background = origin.type === "system" && (origin.source === "automation" || origin.source === "heartbeat" || origin.source === "internal");
|
|
5
|
+
const kind = input.kind ?? (origin.type === "system" && origin.source === "automation" ? "automation" : origin.type === "system" && origin.source === "workflow" ? "workflow" : input.taskRunId ? "task" : "chat");
|
|
6
|
+
return {
|
|
7
|
+
conversationId: input.conversationId,
|
|
8
|
+
runId: input.runId,
|
|
9
|
+
kind,
|
|
10
|
+
initiator: background ? "background" : "user",
|
|
11
|
+
phase: "running",
|
|
12
|
+
startedAt: input.startedAt ?? Date.now()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { describeActiveExecution };
|
|
@@ -7,6 +7,7 @@ import type { ChannelManager } from '../../channels/manager.js';
|
|
|
7
7
|
import type { SessionIndex } from '../../session/index.js';
|
|
8
8
|
import { type ClarificationStreamEvent } from '../ephemeral-clarification-waiter.js';
|
|
9
9
|
import type { ClarifyRequestPayload, ClarifyRequestResult } from '../../agent/tools/clarify-tool.js';
|
|
10
|
+
import { type ActiveExecution, type ActiveExecutionKind } from './active-execution.js';
|
|
10
11
|
import type { UserTurnAttachment, UserTurnInput } from '../user-turn-input.js';
|
|
11
12
|
import type { AgentSourceContext, TurnContextRef } from '../../agent/source-context/types.js';
|
|
12
13
|
import { SessionInputCoordinator, type ReplaceLatestTurnInput, type SubmitSessionInput } from './session-input-coordinator.js';
|
|
@@ -33,6 +34,7 @@ export declare class GatewayAgentRunner {
|
|
|
33
34
|
private readonly ephemeralClarifications;
|
|
34
35
|
/** Maps webchat session key → active `runId` for `clarify` tool routing. */
|
|
35
36
|
private readonly activeWebchatRunBySession;
|
|
37
|
+
private readonly activeExecutionBySession;
|
|
36
38
|
private readonly externalStreamBySession;
|
|
37
39
|
private readonly externalClarificationResponses;
|
|
38
40
|
readonly inputs: SessionInputCoordinator;
|
|
@@ -45,9 +47,11 @@ export declare class GatewayAgentRunner {
|
|
|
45
47
|
conversationId: string;
|
|
46
48
|
runId: string;
|
|
47
49
|
}>;
|
|
50
|
+
listActiveExecutions(): ActiveExecution[];
|
|
48
51
|
disposeClarifications(): void;
|
|
49
52
|
registerExternalWebchatRun(conversationId: string, runId: string, publish: (event: ClarificationStreamEvent) => void, options?: {
|
|
50
53
|
beforeClarificationResponse?: () => boolean;
|
|
54
|
+
kind?: ActiveExecutionKind;
|
|
51
55
|
}): void;
|
|
52
56
|
unregisterExternalWebchatRun(conversationId: string, runId: string): void;
|
|
53
57
|
cancelClarificationForRun(runId: string): void;
|