@xopcai/xopc 0.0.332 → 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-C2wg3xC_.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-BeNnu1Ts.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-etFSkfzl.js → app-management-settings-panel-BcszTlqr.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DKmU2VAP.js → appearance-settings-B1XPe8qz.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DVNySL58.js → apps-page-ZqANbUZv.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-D0z_Fr2G.js → archive-plugin-MjUsJcNb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DNCDbeOX.js → attachment-load-DHa-BI9a.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B7_C-p66.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-BYn2hScX.js → binary-plugins-DQYcuBHP.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-ChWW8Z9L.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-BV00BXRb.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-v0WkhV5o.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-vmx35sbu.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-C41mXCAi.js → chat-terminal-dock-Fnum_IEm.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-BJkqok2G.js → computer-settings-page-DI1zfCTA.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BKCZMmwm.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-CrOV4Ynd.js → date-picker-D-JhzZyW.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CqADAHZp.js → dependency-picker-DpD3xaEB.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bab-iWED.js → desktop-pet-CCoDxKqh.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BqgzLOdi.js → desktop-pet-settings-GxndKfCx.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DFg7FDPf.js → device-pairing-wizard-B71w3ptm.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-hqJ9sFCR.js → directory-picker-path-field-CUzjJvjs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DX3PFhRE.js → extension-debug-page-BtDY8ntX.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DkREdHLs.js → extension-page-D9_XF-XC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-wF-HNTM-.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-Du-Dos9O.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-B80Cv043.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-BgoFaTwv.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-HO6OQlQT.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-CjzR9Rpj.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-Dlj6TD3M.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-BArPtqp5.js → page-context-capture-button-D43aVpCj.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-vqI30Yrg.js → page-tabs-BhYBCqls.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B-mwPBJW.js → preview-open-alternatives-CP8agNlc.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-D--sj_uN.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-DBsBwAQ6.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-BurdDY0m.js → remote-access-hub-fVPQe5YS.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CAnb0PNY.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-BKj6wIMb.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-78ycUHfv.js → settings-form-section-jquf1P7n.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BOdxIVzo.js → settings-page-DPomsvba.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CbKHBjrU.js → setup-status-panel-BvVlqpHf.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DyLfktib.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-CiBGQ0Jg.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-C35VKjhb.js → skills-page-D7XPEQu_.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CyJUeREH.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-Day9zhKi.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-Bj9hC6ML.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-fWRD6B8r.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-CnxdvIk8.js → work-discovery-overlay-CJzqJ47I.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DlWNN1VA.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 +44 -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 +9 -3
- package/dist/src/agent/background-review/run-background-review.js +6 -1
- package/dist/src/agent/embedded/run-turn.js +7 -1
- 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/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.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 +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 +49 -8
- package/dist/src/ai-assist/text-assist.js +5 -1
- package/dist/src/automations/api/routes.js +65 -0
- 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/capabilities/store-connector.d.ts +17 -1
- package/dist/src/capabilities/store-connector.js +69 -3
- 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/skills.js +1 -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/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/home-intelligence-automation-reconciler.js +4 -1
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
- 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/sessions.js +15 -0
- 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/memory-maintenance-automation-reconciler.js +5 -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 +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 +6 -3
- package/dist/src/gateway/service.js +82 -85
- package/dist/src/gateway/side-chat/run-service.js +10 -7
- package/dist/src/home-intelligence/generator.js +4 -1
- package/dist/src/home-intelligence/host.js +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/local-apps/service.js +1 -1
- 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/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/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/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/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/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 +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/automations-workspace-BMgJvdcv.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-xwTmuZjS.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-CHA-sTAZ.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DefBGjhV.js +0 -8
- 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/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/management-settings-Dk_gTJb9.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/project-detail-page-BFUdtWXF.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/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/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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
3
|
+
import { init_timestamps, optionalTimestampToIso, optionalTimestampToMs, timestampToIso, timestampToMs } from "./timestamps.js";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
//#region src/storage/sqlite/connector-repository.ts
|
|
5
6
|
function parseStringArray(value) {
|
|
@@ -28,8 +29,8 @@ function installationFromRow(row) {
|
|
|
28
29
|
maxScope: row.max_scope,
|
|
29
30
|
confirmationPolicy: row.confirmation_policy,
|
|
30
31
|
selectedAccountIds: row.selected_account_ids_json === "null" ? null : parseStringArray(row.selected_account_ids_json),
|
|
31
|
-
createdAt: row.created_at,
|
|
32
|
-
updatedAt: row.updated_at
|
|
32
|
+
createdAt: timestampToIso(row.created_at),
|
|
33
|
+
updatedAt: timestampToIso(row.updated_at)
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
function connectionFromRow(row) {
|
|
@@ -45,12 +46,12 @@ function connectionFromRow(row) {
|
|
|
45
46
|
identity: parseObject(row.identity_json),
|
|
46
47
|
status: row.status,
|
|
47
48
|
isDefault: row.is_default === 1,
|
|
48
|
-
connectedAt: row.connected_at
|
|
49
|
-
expiresAt: row.expires_at
|
|
49
|
+
connectedAt: optionalTimestampToIso(row.connected_at),
|
|
50
|
+
expiresAt: optionalTimestampToIso(row.expires_at),
|
|
50
51
|
lastError: row.last_error ?? void 0,
|
|
51
52
|
metadata: parseObject(row.metadata_json),
|
|
52
|
-
createdAt: row.created_at,
|
|
53
|
-
updatedAt: row.updated_at
|
|
53
|
+
createdAt: timestampToIso(row.created_at),
|
|
54
|
+
updatedAt: timestampToIso(row.updated_at)
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
function actionFromRow(row) {
|
|
@@ -62,7 +63,7 @@ function actionFromRow(row) {
|
|
|
62
63
|
curated: row.curated === 1,
|
|
63
64
|
inputSchema: row.input_schema_json == null ? void 0 : JSON.parse(row.input_schema_json),
|
|
64
65
|
schemaVersion: row.schema_version ?? void 0,
|
|
65
|
-
cachedAt: row.cached_at
|
|
66
|
+
cachedAt: timestampToIso(row.cached_at)
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
function auditFromRow(row) {
|
|
@@ -80,7 +81,7 @@ function auditFromRow(row) {
|
|
|
80
81
|
resultStatus: row.result_status,
|
|
81
82
|
durationMs: row.duration_ms ?? void 0,
|
|
82
83
|
errorCode: row.error_code ?? void 0,
|
|
83
|
-
createdAt: row.created_at
|
|
84
|
+
createdAt: timestampToIso(row.created_at)
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
function catalogFromRow(row) {
|
|
@@ -91,8 +92,8 @@ function catalogFromRow(row) {
|
|
|
91
92
|
connectorId: row.connector_id,
|
|
92
93
|
provider: row.provider,
|
|
93
94
|
definition,
|
|
94
|
-
fetchedAt: row.fetched_at,
|
|
95
|
-
expiresAt: row.expires_at
|
|
95
|
+
fetchedAt: timestampToIso(row.fetched_at),
|
|
96
|
+
expiresAt: optionalTimestampToIso(row.expires_at)
|
|
96
97
|
};
|
|
97
98
|
} catch {
|
|
98
99
|
return;
|
|
@@ -112,10 +113,10 @@ function approvalFromRow(row) {
|
|
|
112
113
|
argumentsHash: row.arguments_hash,
|
|
113
114
|
argumentsPreview: parseObject(row.arguments_preview_json),
|
|
114
115
|
status: row.status,
|
|
115
|
-
expiresAt: row.expires_at,
|
|
116
|
-
createdAt: row.created_at,
|
|
117
|
-
decidedAt: row.decided_at
|
|
118
|
-
consumedAt: row.consumed_at
|
|
116
|
+
expiresAt: timestampToIso(row.expires_at),
|
|
117
|
+
createdAt: timestampToIso(row.created_at),
|
|
118
|
+
decidedAt: optionalTimestampToIso(row.decided_at),
|
|
119
|
+
consumedAt: optionalTimestampToIso(row.consumed_at)
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
122
|
function createConnectorApproval(input) {
|
|
@@ -132,7 +133,7 @@ function createConnectorApproval(input) {
|
|
|
132
133
|
scope, arguments_hash, arguments_preview_json, status, expires_at, created_at,
|
|
133
134
|
decided_at, consumed_at, wait_id
|
|
134
135
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
135
|
-
`).run(record.id, record.principalId, record.connectorId, record.connectionId ?? null, record.agentId ?? null, record.conversationId ?? null, record.actionId, record.scope, record.argumentsHash, JSON.stringify(record.argumentsPreview), record.status, record.expiresAt, record.createdAt, record.decidedAt
|
|
136
|
+
`).run(record.id, record.principalId, record.connectorId, record.connectionId ?? null, record.agentId ?? null, record.conversationId ?? null, record.actionId, record.scope, record.argumentsHash, JSON.stringify(record.argumentsPreview), record.status, timestampToMs(record.expiresAt), timestampToMs(record.createdAt), optionalTimestampToMs(record.decidedAt), optionalTimestampToMs(record.consumedAt), record.waitId ?? null);
|
|
136
137
|
});
|
|
137
138
|
return record;
|
|
138
139
|
}
|
|
@@ -163,11 +164,11 @@ function decideConnectorApproval(id, decision, now = /* @__PURE__ */ new Date())
|
|
|
163
164
|
return runSqliteWriteTransaction((db) => {
|
|
164
165
|
const current = db.prepare("SELECT * FROM connector_approvals WHERE id = ?").get(id);
|
|
165
166
|
if (!current) return void 0;
|
|
166
|
-
if (current.status !== "pending" ||
|
|
167
|
-
if (current.status === "pending") db.prepare("UPDATE connector_approvals SET status = 'expired', decided_at = ? WHERE id = ?").run(now.
|
|
167
|
+
if (current.status !== "pending" || current.expires_at <= now.getTime()) {
|
|
168
|
+
if (current.status === "pending") db.prepare("UPDATE connector_approvals SET status = 'expired', decided_at = ? WHERE id = ?").run(now.getTime(), id);
|
|
168
169
|
return approvalFromRow(db.prepare("SELECT * FROM connector_approvals WHERE id = ?").get(id));
|
|
169
170
|
}
|
|
170
|
-
db.prepare("UPDATE connector_approvals SET status = ?, decided_at = ? WHERE id = ?").run(decision, now.
|
|
171
|
+
db.prepare("UPDATE connector_approvals SET status = ?, decided_at = ? WHERE id = ?").run(decision, now.getTime(), id);
|
|
171
172
|
return approvalFromRow(db.prepare("SELECT * FROM connector_approvals WHERE id = ?").get(id));
|
|
172
173
|
});
|
|
173
174
|
}
|
|
@@ -175,11 +176,11 @@ function consumeConnectorApproval(id, argumentsHash, now = /* @__PURE__ */ new D
|
|
|
175
176
|
return runSqliteWriteTransaction((db) => {
|
|
176
177
|
const current = db.prepare("SELECT * FROM connector_approvals WHERE id = ?").get(id);
|
|
177
178
|
if (!current || current.arguments_hash !== argumentsHash) return void 0;
|
|
178
|
-
if (current.status !== "approved" ||
|
|
179
|
-
if (current.status === "approved" &&
|
|
179
|
+
if (current.status !== "approved" || current.expires_at <= now.getTime()) {
|
|
180
|
+
if (current.status === "approved" && current.expires_at <= now.getTime()) db.prepare("UPDATE connector_approvals SET status = 'expired' WHERE id = ?").run(id);
|
|
180
181
|
return;
|
|
181
182
|
}
|
|
182
|
-
db.prepare("UPDATE connector_approvals SET status = 'consumed', consumed_at = ? WHERE id = ? AND status = 'approved'").run(now.
|
|
183
|
+
db.prepare("UPDATE connector_approvals SET status = 'consumed', consumed_at = ? WHERE id = ? AND status = 'approved'").run(now.getTime(), id);
|
|
183
184
|
return approvalFromRow(db.prepare("SELECT * FROM connector_approvals WHERE id = ?").get(id));
|
|
184
185
|
});
|
|
185
186
|
}
|
|
@@ -193,7 +194,7 @@ function upsertConnectorCatalogEntry(input) {
|
|
|
193
194
|
definition_json = excluded.definition_json,
|
|
194
195
|
fetched_at = excluded.fetched_at,
|
|
195
196
|
expires_at = excluded.expires_at
|
|
196
|
-
`).run(input.connectorId, input.provider, JSON.stringify(input.definition), input.fetchedAt, input.expiresAt
|
|
197
|
+
`).run(input.connectorId, input.provider, JSON.stringify(input.definition), timestampToMs(input.fetchedAt), optionalTimestampToMs(input.expiresAt));
|
|
197
198
|
});
|
|
198
199
|
return input;
|
|
199
200
|
}
|
|
@@ -204,7 +205,7 @@ function replaceConnectorCatalogEntries(provider, entries) {
|
|
|
204
205
|
INSERT INTO connector_catalog_entries (connector_id, provider, definition_json, fetched_at, expires_at)
|
|
205
206
|
VALUES (?, ?, ?, ?, ?)
|
|
206
207
|
`);
|
|
207
|
-
for (const entry of entries) insert.run(entry.connectorId, provider, JSON.stringify(entry.definition), entry.fetchedAt, entry.expiresAt
|
|
208
|
+
for (const entry of entries) insert.run(entry.connectorId, provider, JSON.stringify(entry.definition), timestampToMs(entry.fetchedAt), optionalTimestampToMs(entry.expiresAt));
|
|
208
209
|
});
|
|
209
210
|
return entries;
|
|
210
211
|
}
|
|
@@ -219,7 +220,7 @@ function listCachedConnectorCatalogEntries(provider) {
|
|
|
219
220
|
});
|
|
220
221
|
}
|
|
221
222
|
function upsertConnectorInstallation(input) {
|
|
222
|
-
const now =
|
|
223
|
+
const now = Date.now();
|
|
223
224
|
return runSqliteWriteTransaction((db) => {
|
|
224
225
|
db.prepare(`
|
|
225
226
|
INSERT INTO connector_installations (
|
|
@@ -235,7 +236,7 @@ function upsertConnectorInstallation(input) {
|
|
|
235
236
|
confirmation_policy = excluded.confirmation_policy,
|
|
236
237
|
selected_account_ids_json = excluded.selected_account_ids_json,
|
|
237
238
|
updated_at = excluded.updated_at
|
|
238
|
-
`).run(input.id, input.connectorId, input.principalId, input.enabled ? 1 : 0, JSON.stringify(input.allowedAgentIds), input.maxScope, input.confirmationPolicy, JSON.stringify(input.selectedAccountIds), input.createdAt
|
|
239
|
+
`).run(input.id, input.connectorId, input.principalId, input.enabled ? 1 : 0, JSON.stringify(input.allowedAgentIds), input.maxScope, input.confirmationPolicy, JSON.stringify(input.selectedAccountIds), input.createdAt ? timestampToMs(input.createdAt) : now, input.updatedAt ? timestampToMs(input.updatedAt) : now);
|
|
239
240
|
return getConnectorInstallation(input.id);
|
|
240
241
|
});
|
|
241
242
|
}
|
|
@@ -250,7 +251,7 @@ function deleteConnectorInstallation(id) {
|
|
|
250
251
|
return runSqliteWriteTransaction((db) => db.prepare("DELETE FROM connector_installations WHERE id = ?").run(id).changes > 0);
|
|
251
252
|
}
|
|
252
253
|
function upsertConnectorConnection(input) {
|
|
253
|
-
const now =
|
|
254
|
+
const now = Date.now();
|
|
254
255
|
return runSqliteWriteTransaction((db) => {
|
|
255
256
|
const accountId = db.prepare("SELECT account_id FROM connector_connections WHERE id = ?").get(input.id)?.account_id ?? input.accountId ?? `account:${input.id}`;
|
|
256
257
|
db.prepare(`
|
|
@@ -258,7 +259,7 @@ function upsertConnectorConnection(input) {
|
|
|
258
259
|
id, connector_id, principal_id, identity_json, current_connection_id, created_at, updated_at
|
|
259
260
|
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
260
261
|
ON CONFLICT(id) DO NOTHING
|
|
261
|
-
`).run(accountId, input.connectorId, input.principalId, JSON.stringify(input.identity), input.id, input.createdAt
|
|
262
|
+
`).run(accountId, input.connectorId, input.principalId, JSON.stringify(input.identity), input.id, input.createdAt ? timestampToMs(input.createdAt) : now, input.updatedAt ? timestampToMs(input.updatedAt) : now);
|
|
262
263
|
if (input.isDefault) db.prepare("UPDATE connector_connections SET is_default = 0 WHERE principal_id = ? AND connector_id = ? AND id <> ?").run(input.principalId, input.connectorId, input.id);
|
|
263
264
|
db.prepare(`
|
|
264
265
|
INSERT INTO connector_connections (
|
|
@@ -282,7 +283,7 @@ function upsertConnectorConnection(input) {
|
|
|
282
283
|
last_error = excluded.last_error,
|
|
283
284
|
metadata_json = excluded.metadata_json,
|
|
284
285
|
updated_at = excluded.updated_at
|
|
285
|
-
`).run(input.id, accountId, input.installationId ?? null, input.connectorId, input.provider, input.principalId, input.providerConnectionId, input.alias ?? null, JSON.stringify(input.identity), input.status, input.isDefault ? 1 : 0, input.connectedAt
|
|
286
|
+
`).run(input.id, accountId, input.installationId ?? null, input.connectorId, input.provider, input.principalId, input.providerConnectionId, input.alias ?? null, JSON.stringify(input.identity), input.status, input.isDefault ? 1 : 0, optionalTimestampToMs(input.connectedAt), optionalTimestampToMs(input.expiresAt), input.lastError ?? null, JSON.stringify(input.metadata), input.createdAt ? timestampToMs(input.createdAt) : now, input.updatedAt ? timestampToMs(input.updatedAt) : now);
|
|
286
287
|
return getConnectorConnection(input.id);
|
|
287
288
|
});
|
|
288
289
|
}
|
|
@@ -320,7 +321,7 @@ function upsertConnectorActionMetadata(input) {
|
|
|
320
321
|
input_schema_json = excluded.input_schema_json,
|
|
321
322
|
schema_version = excluded.schema_version,
|
|
322
323
|
cached_at = excluded.cached_at
|
|
323
|
-
`).run(input.connectorId, input.actionId, input.toolkit ?? null, input.scope, input.curated ? 1 : 0, input.inputSchema === void 0 ? null : JSON.stringify(input.inputSchema), input.schemaVersion ?? null, input.cachedAt);
|
|
324
|
+
`).run(input.connectorId, input.actionId, input.toolkit ?? null, input.scope, input.curated ? 1 : 0, input.inputSchema === void 0 ? null : JSON.stringify(input.inputSchema), input.schemaVersion ?? null, timestampToMs(input.cachedAt));
|
|
324
325
|
return input;
|
|
325
326
|
});
|
|
326
327
|
}
|
|
@@ -339,7 +340,7 @@ function appendConnectorExecutionAudit(input) {
|
|
|
339
340
|
id, installation_id, connection_id, connector_id, principal_id, agent_id,
|
|
340
341
|
conversation_id, action_id, scope, decision, result_status, duration_ms, error_code, created_at
|
|
341
342
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
342
|
-
`).run(record.id, record.installationId ?? null, record.connectionId ?? null, record.connectorId, record.principalId, record.agentId ?? null, record.conversationId ?? null, record.actionId, record.scope, record.decision, record.resultStatus, record.durationMs ?? null, record.errorCode ?? null, record.createdAt);
|
|
343
|
+
`).run(record.id, record.installationId ?? null, record.connectionId ?? null, record.connectorId, record.principalId, record.agentId ?? null, record.conversationId ?? null, record.actionId, record.scope, record.decision, record.resultStatus, record.durationMs ?? null, record.errorCode ?? null, timestampToMs(record.createdAt));
|
|
343
344
|
});
|
|
344
345
|
return record;
|
|
345
346
|
}
|
|
@@ -367,18 +368,18 @@ function claimConnectorWebhookDelivery(input) {
|
|
|
367
368
|
INSERT INTO connector_webhook_deliveries (
|
|
368
369
|
id, provider, payload_hash, status, attempts, received_at, processing_at
|
|
369
370
|
) VALUES (?, ?, ?, 'processing', 1, ?, ?)
|
|
370
|
-
`).run(input.id, input.provider, input.payloadHash, now.
|
|
371
|
+
`).run(input.id, input.provider, input.payloadHash, now.getTime(), now.getTime());
|
|
371
372
|
return "claimed";
|
|
372
373
|
}
|
|
373
374
|
if (current.payload_hash !== input.payloadHash) throw new Error("Webhook delivery id was reused with a different payload.");
|
|
374
375
|
if (current.status === "processed") return "processed";
|
|
375
376
|
const leaseMs = input.leaseMs ?? 5 * 6e4;
|
|
376
|
-
if (current.status === "processing" && current.processing_at &&
|
|
377
|
+
if (current.status === "processing" && current.processing_at && current.processing_at + leaseMs > now.getTime()) return "in_flight";
|
|
377
378
|
db.prepare(`
|
|
378
379
|
UPDATE connector_webhook_deliveries
|
|
379
380
|
SET status = 'processing', attempts = attempts + 1, processing_at = ?, last_error = NULL
|
|
380
381
|
WHERE id = ?
|
|
381
|
-
`).run(now.
|
|
382
|
+
`).run(now.getTime(), input.id);
|
|
382
383
|
return "claimed";
|
|
383
384
|
});
|
|
384
385
|
}
|
|
@@ -388,7 +389,7 @@ function completeConnectorWebhookDelivery(id, now = /* @__PURE__ */ new Date())
|
|
|
388
389
|
UPDATE connector_webhook_deliveries
|
|
389
390
|
SET status = 'processed', processed_at = ?, processing_at = NULL, last_error = NULL
|
|
390
391
|
WHERE id = ?
|
|
391
|
-
`).run(now.
|
|
392
|
+
`).run(now.getTime(), id);
|
|
392
393
|
});
|
|
393
394
|
}
|
|
394
395
|
function releaseConnectorWebhookDelivery(id, error) {
|
|
@@ -402,6 +403,7 @@ function releaseConnectorWebhookDelivery(id, error) {
|
|
|
402
403
|
});
|
|
403
404
|
}
|
|
404
405
|
var init_connector_repository = __esmMin((() => {
|
|
406
|
+
init_timestamps();
|
|
405
407
|
init_transaction();
|
|
406
408
|
}));
|
|
407
409
|
//#endregion
|
|
@@ -14,7 +14,7 @@ export { claimContextExtractionRun, finishContextExtractionRun, getContextExtrac
|
|
|
14
14
|
export { createCollaborationRule, getCollaborationRule, listCollaborationRules, setCollaborationRuleStatus, type CollaborationRule, } from './collaboration-rule-repository.js';
|
|
15
15
|
export { createContextEvidence, type ContextEvidence } from './context-evidence-repository.js';
|
|
16
16
|
export { getUserPerson, getUserPeopleIndexState, listUserPeople, mergeUserPeople, replaceUserPeopleIndex, summarizeUserPeople, updateUserPerson, } from './user-people-repository.js';
|
|
17
|
-
export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, getSessionInputById, insertSessionInput, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus, type SessionInput, type SessionInputDelivery, type SessionInputPayload, type SessionInputState, type SessionInputStatus, } from './session-input-repository.js';
|
|
17
|
+
export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, getSessionInputById, insertSessionInput, listActiveSessionInputExecutions, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus, type SessionInput, type SessionInputDelivery, type SessionInputPayload, type SessionInputState, type SessionInputStatus, } from './session-input-repository.js';
|
|
18
18
|
export { consumeClarificationApproval, consumeClarificationResume, createClarificationWait, getActiveClarification, getClarification, getClarificationResumeInput, getClarificationSnapshot, isClarificationSuspended, resolveClarification, supersedeActiveClarification, type CreateClarificationInput, type ResolveClarificationInput, type ResolveClarificationResult, } from './clarification-wait-repository.js';
|
|
19
19
|
export { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget, type ReplaceLatestSessionTurnInput, type ReplaceLatestSessionTurnResult, } from './session-turn-replace-repository.js';
|
|
20
20
|
export { acknowledgeHomeAttention, isHomeAttentionAcknowledged, type HomeAttentionSubjectKind, } from './home-attention-repository.js';
|
|
@@ -26,7 +26,7 @@ export { getInteractionState, setInteractionState, updateInteractionStateFromMes
|
|
|
26
26
|
export { getSessionTaskPlan, setSessionTaskPlan, type SessionTaskPlan, type SessionTaskPlanItem, type SessionTaskPlanItemStatus, } from './session-task-plan-repository.js';
|
|
27
27
|
export { buildDefaultSessionMetadata, type SessionMetadataSeed, } from './session-metadata.js';
|
|
28
28
|
export { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow, type SessionConfigRow, type SessionRow, type TranscriptEntryRow, } from './row-mappers.js';
|
|
29
|
-
export { deleteSessionRecord, ensureSessionRecord, getCurrentTranscriptId, getGlobalSessionStats, findConversationIdByTranscriptId,
|
|
29
|
+
export { deleteSessionRecord, ensureSessionRecord, getCurrentTranscriptId, getGlobalSessionStats, findConversationIdByTranscriptId, getSessionMetadata, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats, } from './session-repository.js';
|
|
30
30
|
export { getSidebarLayout, replaceSidebarLayout, sortBySidebarLayout, SidebarLayoutConflictError, type SidebarLayout, } from './sidebar-layout-repository.js';
|
|
31
31
|
export { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, listCompactionBoundaries, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, loadCompactionSourceSnapshot, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript, type CompactionSourceSnapshot, type SessionTranscriptRecallMatch, type TranscriptSourceEntry, } from './transcript-repository.js';
|
|
32
32
|
export { deleteNoteRecord, getNoteRecord, listNoteRecords, upsertNoteRecord, } from './notes-repository.js';
|
|
@@ -17,7 +17,7 @@ import { claimContextExtractionRun, finishContextExtractionRun, getContextExtrac
|
|
|
17
17
|
import { createCollaborationRule, getCollaborationRule, init_collaboration_rule_repository, listCollaborationRules, setCollaborationRuleStatus } from "./collaboration-rule-repository.js";
|
|
18
18
|
import { createContextEvidence, init_context_evidence_repository } from "./context-evidence-repository.js";
|
|
19
19
|
import { getUserPeopleIndexState, getUserPerson, init_user_people_repository, listUserPeople, mergeUserPeople, replaceUserPeopleIndex, summarizeUserPeople, updateUserPerson } from "./user-people-repository.js";
|
|
20
|
-
import { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, init_session_input_repository, insertSessionInput, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus } from "./session-input-repository.js";
|
|
20
|
+
import { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, init_session_input_repository, insertSessionInput, listActiveSessionInputExecutions, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus } from "./session-input-repository.js";
|
|
21
21
|
import { consumeClarificationApproval, consumeClarificationResume, createClarificationWait, getActiveClarification, getClarification, getClarificationResumeInput, getClarificationSnapshot, init_clarification_wait_repository, isClarificationSuspended, resolveClarification, supersedeActiveClarification } from "./clarification-wait-repository.js";
|
|
22
22
|
import { buildDefaultSessionMetadata, init_session_metadata } from "./session-metadata.js";
|
|
23
23
|
import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, init_row_mappers, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
@@ -31,7 +31,7 @@ import { getInteractionState, init_interaction_state_repository, setInteractionS
|
|
|
31
31
|
import { getConnectorAccount, init_connector_account_repository, listConnectorAccounts, reconcileConnectorAccount, refreshConnectorAccountCurrent } from "./connector-account-repository.js";
|
|
32
32
|
import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeConnectorWebhookDelivery, consumeConnectorApproval, createConnectorApproval, decideConnectorApproval, deleteConnectorConnection, deleteConnectorInstallation, getCachedConnectorCatalogEntry, getConnectorApproval, getConnectorConnection, getConnectorInstallation, init_connector_repository, listCachedConnectorCatalogEntries, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation } from "./connector-repository.js";
|
|
33
33
|
import { getSessionMetadata } from "./session-read-repository.js";
|
|
34
|
-
import { deleteSessionRecord, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats,
|
|
34
|
+
import { deleteSessionRecord, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats, incrementSessionStatsOnAppend, init_session_repository, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
|
|
35
35
|
import { getSessionTaskPlan, init_session_task_plan_repository, setSessionTaskPlan } from "./session-task-plan-repository.js";
|
|
36
36
|
import { SidebarLayoutConflictError, getSidebarLayout, init_sidebar_layout_repository, replaceSidebarLayout, sortBySidebarLayout } from "./sidebar-layout-repository.js";
|
|
37
37
|
import { appendCompactionBoundaryIfUnchanged, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, findLatestAssistantTranscriptEntryId, init_transcript_repository, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "./transcript-repository.js";
|
|
@@ -87,4 +87,4 @@ var init_sqlite = __esmMin((() => {
|
|
|
87
87
|
}));
|
|
88
88
|
//#endregion
|
|
89
89
|
init_sqlite();
|
|
90
|
-
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, SCHEMA_META_SCHEMA_VERSION_KEY, SidebarLayoutConflictError, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, applyPendingMigrations, authenticateDeviceAccessToken, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRefreshProofMessage, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, clearGatewayIdentityForTest, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeClarificationApproval, consumeClarificationResume, consumeConnectorApproval, countKnowledgeSourceItems, createClarificationWait, createCollaborationRule, createConnectorApproval, createContextEvidence, createDevice, createDevicePairingSetup, createEndpointPrincipal, createObjectLinkRecord, decideConnectorApproval, deleteBrowserTabBinding, deleteBrowserTabBindingsByEndpoint, deleteBrowserTabBindingsByPrincipal, deleteConnectorConnection, deleteConnectorInstallation, deleteEndpointSessionBinding, deleteEndpointSessionBindingsByPrincipal, deleteKnowledgeSourceItems, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, enqueueConnectorLearningJob, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findConversationIdByTranscriptId, findLatestAssistantTranscriptEntryId, findSessionInput, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActiveClarification, getActivityEventRecord, getBrowserTabBinding, getBrowserTabBindingById, getCachedConnectorCatalogEntry, getClarification, getClarificationResumeInput, getClarificationSnapshot, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextExtractionRun, getCurrentTranscriptId, getDevice, getEndpointPrincipal, getEndpointSessionBinding, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getNoteAgentContextRecord, getNoteRecord, getOrCreateGatewayIdentity, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata,
|
|
90
|
+
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, DatabaseSchemaTooOldError, SCHEMA_META_SCHEMA_VERSION_KEY, SidebarLayoutConflictError, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMediaToAssistantTranscriptEntry, appendTranscriptEntry, applyPendingMigrations, authenticateDeviceAccessToken, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRefreshProofMessage, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, clearGatewayIdentityForTest, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeClarificationApproval, consumeClarificationResume, consumeConnectorApproval, countKnowledgeSourceItems, createClarificationWait, createCollaborationRule, createConnectorApproval, createContextEvidence, createDevice, createDevicePairingSetup, createEndpointPrincipal, createObjectLinkRecord, decideConnectorApproval, deleteBrowserTabBinding, deleteBrowserTabBindingsByEndpoint, deleteBrowserTabBindingsByPrincipal, deleteConnectorConnection, deleteConnectorInstallation, deleteEndpointSessionBinding, deleteEndpointSessionBindingsByPrincipal, deleteKnowledgeSourceItems, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, enqueueConnectorLearningJob, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findConversationIdByTranscriptId, findLatestAssistantTranscriptEntryId, findSessionInput, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActiveClarification, getActivityEventRecord, getBrowserTabBinding, getBrowserTabBindingById, getCachedConnectorCatalogEntry, getClarification, getClarificationResumeInput, getClarificationSnapshot, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextExtractionRun, getCurrentTranscriptId, getDevice, getEndpointPrincipal, getEndpointSessionBinding, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getNoteAgentContextRecord, getNoteRecord, getOrCreateGatewayIdentity, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionTaskPlan, getSidebarLayout, getSqliteDatabase, getUserPeopleIndexState, getUserPerson, getUserTrustPolicy, getXopcDatabase, hasSessionConfig, incrementSessionStatsOnAppend, init_sqlite, insertSessionInput, inspectSchemaMigrationStatus, isClarificationSuspended, isDevicePairingSetupActive, isHomeAttentionAcknowledged, isXopcDatabaseOpen, issueDeviceTokenPair, listActiveSessionInputExecutions, listActiveSessionInputRuns, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextExtractionOutputs, listContextExtractionRuns, listDevices, listEndpointPrincipals, listEndpointToolInvocationAuditPage, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listUserPeople, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, mergeUserPeople, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceSidebarLayout, replaceTranscriptRows, replaceUserPeopleIndex, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveClarification, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, revokeDevice, revokeEndpointPrincipal, rotateDeviceRefreshToken, runSqliteWriteTransaction, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setBrowserTabBinding, setCollaborationRuleStatus, setConnectorLearningPaused, setEndpointSessionBinding, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUserTrustPolicy, signGatewayPayload, sortBySidebarLayout, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeUserPeople, supersedeActiveClarification, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateSessionConfig, updateSessionStats, updateUserPerson, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
CREATE TABLE automation_events (
|
|
2
|
+
event_id TEXT PRIMARY KEY,
|
|
3
|
+
event_type TEXT NOT NULL,
|
|
4
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
5
|
+
source TEXT NOT NULL,
|
|
6
|
+
subject_kind TEXT,
|
|
7
|
+
subject_id TEXT,
|
|
8
|
+
occurred_at_ms INTEGER NOT NULL,
|
|
9
|
+
ingested_at_ms INTEGER NOT NULL,
|
|
10
|
+
correlation_id TEXT NOT NULL,
|
|
11
|
+
causation_id TEXT,
|
|
12
|
+
root_event_id TEXT NOT NULL,
|
|
13
|
+
chain_depth INTEGER NOT NULL DEFAULT 0 CHECK(chain_depth BETWEEN 0 AND 32),
|
|
14
|
+
dedupe_key TEXT,
|
|
15
|
+
trust TEXT NOT NULL CHECK(trust IN ('system', 'user', 'connector', 'untrusted_webhook')),
|
|
16
|
+
payload_json TEXT NOT NULL,
|
|
17
|
+
projected_at_ms INTEGER,
|
|
18
|
+
projection_attempts INTEGER NOT NULL DEFAULT 0,
|
|
19
|
+
projection_error TEXT
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE UNIQUE INDEX idx_automation_events_source_dedupe
|
|
23
|
+
ON automation_events(source, dedupe_key)
|
|
24
|
+
WHERE dedupe_key IS NOT NULL;
|
|
25
|
+
|
|
26
|
+
CREATE INDEX idx_automation_events_projection
|
|
27
|
+
ON automation_events(projected_at_ms, ingested_at_ms);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE automation_event_deliveries (
|
|
30
|
+
event_id TEXT NOT NULL,
|
|
31
|
+
automation_id TEXT NOT NULL,
|
|
32
|
+
status TEXT NOT NULL CHECK(status IN ('pending', 'queued', 'completed', 'failed', 'cancelled', 'skipped')),
|
|
33
|
+
run_id TEXT,
|
|
34
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
35
|
+
next_attempt_at_ms INTEGER NOT NULL,
|
|
36
|
+
last_error TEXT,
|
|
37
|
+
created_at_ms INTEGER NOT NULL,
|
|
38
|
+
updated_at_ms INTEGER NOT NULL,
|
|
39
|
+
PRIMARY KEY(event_id, automation_id),
|
|
40
|
+
FOREIGN KEY(event_id) REFERENCES automation_events(event_id) ON DELETE CASCADE
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
CREATE UNIQUE INDEX idx_automation_event_deliveries_run
|
|
44
|
+
ON automation_event_deliveries(run_id)
|
|
45
|
+
WHERE run_id IS NOT NULL;
|
|
46
|
+
|
|
47
|
+
CREATE INDEX idx_automation_event_deliveries_pending
|
|
48
|
+
ON automation_event_deliveries(status, next_attempt_at_ms, created_at_ms);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
UPDATE automations
|
|
2
|
+
SET reliability_json = json_remove(
|
|
3
|
+
json_set(
|
|
4
|
+
reliability_json,
|
|
5
|
+
'$.executionTimeoutSeconds',
|
|
6
|
+
COALESCE(
|
|
7
|
+
json_extract(reliability_json, '$.executionTimeoutSeconds'),
|
|
8
|
+
json_extract(reliability_json, '$.timeoutSeconds')
|
|
9
|
+
)
|
|
10
|
+
),
|
|
11
|
+
'$.timeoutSeconds'
|
|
12
|
+
)
|
|
13
|
+
WHERE reliability_json IS NOT NULL
|
|
14
|
+
AND json_type(reliability_json, '$.timeoutSeconds') IS NOT NULL;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
CREATE TABLE automation_result_deliveries (
|
|
2
|
+
run_id TEXT NOT NULL,
|
|
3
|
+
destination_key TEXT NOT NULL,
|
|
4
|
+
kind TEXT NOT NULL,
|
|
5
|
+
status TEXT NOT NULL CHECK(status IN ('pending', 'delivering', 'delivered', 'failed')),
|
|
6
|
+
config_json TEXT NOT NULL,
|
|
7
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
8
|
+
next_attempt_at_ms INTEGER NOT NULL,
|
|
9
|
+
last_error TEXT,
|
|
10
|
+
created_at_ms INTEGER NOT NULL,
|
|
11
|
+
updated_at_ms INTEGER NOT NULL,
|
|
12
|
+
PRIMARY KEY(run_id, destination_key)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE INDEX idx_automation_result_deliveries_pending
|
|
16
|
+
ON automation_result_deliveries(status, next_attempt_at_ms, created_at_ms);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
ALTER TABLE automations ADD COLUMN delivery_json TEXT;
|
|
2
|
+
|
|
3
|
+
UPDATE automations
|
|
4
|
+
SET delivery_json = json_patch(
|
|
5
|
+
json_object('notificationPolicy', notification_policy),
|
|
6
|
+
CASE WHEN completion_webhook_url IS NULL
|
|
7
|
+
THEN json('{}')
|
|
8
|
+
ELSE json_object('completionWebhookUrl', completion_webhook_url)
|
|
9
|
+
END
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
UPDATE automation_run_requests
|
|
13
|
+
SET automation_json = json_remove(
|
|
14
|
+
json_set(
|
|
15
|
+
automation_json,
|
|
16
|
+
'$.delivery',
|
|
17
|
+
json_patch(
|
|
18
|
+
json_object('notificationPolicy', COALESCE(json_extract(automation_json, '$.notificationPolicy'), 'attention')),
|
|
19
|
+
CASE WHEN json_extract(automation_json, '$.completionWebhookUrl') IS NULL
|
|
20
|
+
THEN json('{}')
|
|
21
|
+
ELSE json_object('completionWebhookUrl', json_extract(automation_json, '$.completionWebhookUrl'))
|
|
22
|
+
END
|
|
23
|
+
)
|
|
24
|
+
),
|
|
25
|
+
'$.notificationPolicy',
|
|
26
|
+
'$.completionWebhookUrl'
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
ALTER TABLE automations DROP COLUMN notification_policy;
|
|
30
|
+
ALTER TABLE automations DROP COLUMN completion_webhook_url;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
ALTER TABLE automation_event_deliveries RENAME TO automation_event_deliveries_v212;
|
|
2
|
+
ALTER TABLE automation_events RENAME TO automation_events_v212;
|
|
3
|
+
|
|
4
|
+
CREATE TABLE automation_events (
|
|
5
|
+
event_id TEXT PRIMARY KEY,
|
|
6
|
+
event_type TEXT NOT NULL,
|
|
7
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
8
|
+
source TEXT NOT NULL,
|
|
9
|
+
subject_kind TEXT,
|
|
10
|
+
subject_id TEXT,
|
|
11
|
+
occurred_at_ms INTEGER NOT NULL,
|
|
12
|
+
ingested_at_ms INTEGER NOT NULL,
|
|
13
|
+
correlation_id TEXT NOT NULL,
|
|
14
|
+
causation_id TEXT,
|
|
15
|
+
root_event_id TEXT NOT NULL,
|
|
16
|
+
chain_depth INTEGER NOT NULL DEFAULT 0 CHECK(chain_depth BETWEEN 0 AND 32),
|
|
17
|
+
dedupe_key TEXT,
|
|
18
|
+
trust TEXT NOT NULL CHECK(trust IN ('system', 'user', 'connector', 'untrusted_webhook')),
|
|
19
|
+
payload_json TEXT NOT NULL,
|
|
20
|
+
projection_status TEXT NOT NULL DEFAULT 'pending'
|
|
21
|
+
CHECK(projection_status IN ('pending', 'projecting', 'retrying', 'projected', 'dead_letter')),
|
|
22
|
+
projected_at_ms INTEGER,
|
|
23
|
+
projection_attempts INTEGER NOT NULL DEFAULT 0,
|
|
24
|
+
projection_next_attempt_at_ms INTEGER NOT NULL DEFAULT 0,
|
|
25
|
+
projection_error TEXT,
|
|
26
|
+
projection_owner TEXT,
|
|
27
|
+
projection_lease_until_ms INTEGER
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
INSERT INTO automation_events (
|
|
31
|
+
event_id, event_type, schema_version, source, subject_kind, subject_id,
|
|
32
|
+
occurred_at_ms, ingested_at_ms, correlation_id, causation_id, root_event_id,
|
|
33
|
+
chain_depth, dedupe_key, trust, payload_json, projection_status,
|
|
34
|
+
projected_at_ms, projection_attempts, projection_next_attempt_at_ms, projection_error
|
|
35
|
+
)
|
|
36
|
+
SELECT event_id, event_type, schema_version, source, subject_kind, subject_id,
|
|
37
|
+
occurred_at_ms, ingested_at_ms, correlation_id, causation_id, root_event_id,
|
|
38
|
+
chain_depth, dedupe_key, trust, payload_json,
|
|
39
|
+
CASE WHEN projected_at_ms IS NULL THEN 'pending' ELSE 'projected' END,
|
|
40
|
+
projected_at_ms, projection_attempts, 0, projection_error
|
|
41
|
+
FROM automation_events_v212;
|
|
42
|
+
|
|
43
|
+
CREATE TABLE automation_event_deliveries (
|
|
44
|
+
event_id TEXT NOT NULL,
|
|
45
|
+
automation_id TEXT NOT NULL,
|
|
46
|
+
status TEXT NOT NULL CHECK(status IN ('pending', 'retrying', 'queued', 'completed', 'failed', 'cancelled', 'skipped', 'dead_letter')),
|
|
47
|
+
run_id TEXT,
|
|
48
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
49
|
+
next_attempt_at_ms INTEGER NOT NULL,
|
|
50
|
+
last_error TEXT,
|
|
51
|
+
lease_owner TEXT,
|
|
52
|
+
lease_until_ms INTEGER,
|
|
53
|
+
created_at_ms INTEGER NOT NULL,
|
|
54
|
+
updated_at_ms INTEGER NOT NULL,
|
|
55
|
+
PRIMARY KEY(event_id, automation_id),
|
|
56
|
+
FOREIGN KEY(event_id) REFERENCES automation_events(event_id) ON DELETE CASCADE
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
INSERT INTO automation_event_deliveries (
|
|
60
|
+
event_id, automation_id, status, run_id, attempts, next_attempt_at_ms,
|
|
61
|
+
last_error, created_at_ms, updated_at_ms
|
|
62
|
+
)
|
|
63
|
+
SELECT event_id, automation_id, status, run_id, attempts, next_attempt_at_ms,
|
|
64
|
+
last_error, created_at_ms, updated_at_ms
|
|
65
|
+
FROM automation_event_deliveries_v212;
|
|
66
|
+
|
|
67
|
+
DROP TABLE automation_event_deliveries_v212;
|
|
68
|
+
DROP TABLE automation_events_v212;
|
|
69
|
+
|
|
70
|
+
CREATE UNIQUE INDEX idx_automation_events_source_dedupe
|
|
71
|
+
ON automation_events(source, dedupe_key)
|
|
72
|
+
WHERE dedupe_key IS NOT NULL;
|
|
73
|
+
CREATE INDEX idx_automation_events_projection
|
|
74
|
+
ON automation_events(projection_status, projection_next_attempt_at_ms, ingested_at_ms);
|
|
75
|
+
CREATE UNIQUE INDEX idx_automation_event_deliveries_run
|
|
76
|
+
ON automation_event_deliveries(run_id)
|
|
77
|
+
WHERE run_id IS NOT NULL;
|
|
78
|
+
CREATE INDEX idx_automation_event_deliveries_pending
|
|
79
|
+
ON automation_event_deliveries(status, next_attempt_at_ms, created_at_ms);
|
|
80
|
+
|
|
81
|
+
ALTER TABLE automation_result_deliveries RENAME TO automation_result_deliveries_v212;
|
|
82
|
+
|
|
83
|
+
CREATE TABLE automation_results (
|
|
84
|
+
run_id TEXT PRIMARY KEY,
|
|
85
|
+
result_id TEXT NOT NULL UNIQUE,
|
|
86
|
+
result_json TEXT NOT NULL CHECK(json_valid(result_json)),
|
|
87
|
+
created_at_ms INTEGER NOT NULL,
|
|
88
|
+
FOREIGN KEY(run_id) REFERENCES automation_runs(run_id) ON DELETE CASCADE
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
INSERT INTO automation_results (run_id, result_id, result_json, created_at_ms)
|
|
92
|
+
SELECT DISTINCT d.run_id, 'result:' || d.run_id,
|
|
93
|
+
json_object(
|
|
94
|
+
'schemaVersion', 1,
|
|
95
|
+
'resultId', 'result:' || d.run_id,
|
|
96
|
+
'runId', d.run_id,
|
|
97
|
+
'automationId', r.automation_id,
|
|
98
|
+
'status', r.status,
|
|
99
|
+
'artifacts', json_array(),
|
|
100
|
+
'correlationId', d.run_id,
|
|
101
|
+
'rootEventId', d.run_id,
|
|
102
|
+
'createdAtMs', r.created_at_ms,
|
|
103
|
+
'completedAtMs', COALESCE(r.ended_at_ms, d.created_at_ms)
|
|
104
|
+
),
|
|
105
|
+
d.created_at_ms
|
|
106
|
+
FROM automation_result_deliveries_v212 d
|
|
107
|
+
JOIN automation_runs r ON r.run_id = d.run_id;
|
|
108
|
+
|
|
109
|
+
CREATE TABLE automation_result_deliveries (
|
|
110
|
+
delivery_id TEXT NOT NULL UNIQUE,
|
|
111
|
+
run_id TEXT NOT NULL,
|
|
112
|
+
destination_key TEXT NOT NULL,
|
|
113
|
+
kind TEXT NOT NULL,
|
|
114
|
+
status TEXT NOT NULL CHECK(status IN ('pending', 'delivering', 'retrying', 'delivered', 'dead_letter')),
|
|
115
|
+
config_json TEXT NOT NULL,
|
|
116
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
117
|
+
next_attempt_at_ms INTEGER NOT NULL,
|
|
118
|
+
last_error TEXT,
|
|
119
|
+
lease_owner TEXT,
|
|
120
|
+
lease_until_ms INTEGER,
|
|
121
|
+
created_at_ms INTEGER NOT NULL,
|
|
122
|
+
updated_at_ms INTEGER NOT NULL,
|
|
123
|
+
PRIMARY KEY(run_id, destination_key),
|
|
124
|
+
FOREIGN KEY(run_id) REFERENCES automation_results(run_id) ON DELETE CASCADE
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
INSERT INTO automation_result_deliveries (
|
|
128
|
+
delivery_id, run_id, destination_key, kind, status, config_json, attempts,
|
|
129
|
+
next_attempt_at_ms, last_error, created_at_ms, updated_at_ms
|
|
130
|
+
)
|
|
131
|
+
SELECT lower(hex(randomblob(16))), run_id, destination_key, kind,
|
|
132
|
+
CASE status
|
|
133
|
+
WHEN 'delivered' THEN 'delivered'
|
|
134
|
+
WHEN 'failed' THEN 'dead_letter'
|
|
135
|
+
WHEN 'pending' THEN 'pending'
|
|
136
|
+
ELSE 'retrying'
|
|
137
|
+
END,
|
|
138
|
+
CASE WHEN kind = 'webhook' THEN json_object(
|
|
139
|
+
'key', destination_key,
|
|
140
|
+
'kind', 'webhook',
|
|
141
|
+
'endpoint', COALESCE(json_extract(config_json, '$.endpoint'), json_extract(config_json, '$.url')),
|
|
142
|
+
'secretId', COALESCE(json_extract(config_json, '$.secretId'), 'completion_webhook')
|
|
143
|
+
) ELSE json_object('key', destination_key, 'kind', kind) END,
|
|
144
|
+
attempts, next_attempt_at_ms, last_error, created_at_ms, updated_at_ms
|
|
145
|
+
FROM automation_result_deliveries_v212
|
|
146
|
+
WHERE run_id IN (SELECT run_id FROM automation_results);
|
|
147
|
+
|
|
148
|
+
DROP TABLE automation_result_deliveries_v212;
|
|
149
|
+
CREATE INDEX idx_automation_result_deliveries_pending
|
|
150
|
+
ON automation_result_deliveries(status, next_attempt_at_ms, created_at_ms);
|
|
151
|
+
|
|
152
|
+
UPDATE automations
|
|
153
|
+
SET delivery_json = json_object(
|
|
154
|
+
'notificationPolicy', COALESCE(json_extract(delivery_json, '$.notificationPolicy'), 'attention'),
|
|
155
|
+
'destinations', CASE WHEN json_extract(delivery_json, '$.completionWebhookUrl') IS NULL
|
|
156
|
+
THEN json_array(json_object('key', 'gateway_event', 'kind', 'gateway_event'))
|
|
157
|
+
ELSE json_array(
|
|
158
|
+
json_object('key', 'gateway_event', 'kind', 'gateway_event'),
|
|
159
|
+
json_object(
|
|
160
|
+
'key', 'completion_webhook',
|
|
161
|
+
'kind', 'webhook',
|
|
162
|
+
'endpoint', json_extract(delivery_json, '$.completionWebhookUrl'),
|
|
163
|
+
'secretId', 'completion_webhook'
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
END
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
UPDATE automation_run_requests
|
|
170
|
+
SET automation_json = json_set(
|
|
171
|
+
automation_json,
|
|
172
|
+
'$.delivery',
|
|
173
|
+
json_object(
|
|
174
|
+
'notificationPolicy', COALESCE(json_extract(automation_json, '$.delivery.notificationPolicy'), 'attention'),
|
|
175
|
+
'destinations', CASE WHEN json_extract(automation_json, '$.delivery.completionWebhookUrl') IS NULL
|
|
176
|
+
THEN json_array(json_object('key', 'gateway_event', 'kind', 'gateway_event'))
|
|
177
|
+
ELSE json_array(
|
|
178
|
+
json_object('key', 'gateway_event', 'kind', 'gateway_event'),
|
|
179
|
+
json_object(
|
|
180
|
+
'key', 'completion_webhook',
|
|
181
|
+
'kind', 'webhook',
|
|
182
|
+
'endpoint', json_extract(automation_json, '$.delivery.completionWebhookUrl'),
|
|
183
|
+
'secretId', 'completion_webhook'
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
END
|
|
187
|
+
)
|
|
188
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
CREATE TABLE ai_usage_events (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
trace_id TEXT NOT NULL,
|
|
4
|
+
parent_event_id TEXT,
|
|
5
|
+
conversation_id TEXT,
|
|
6
|
+
run_id TEXT,
|
|
7
|
+
agent_id TEXT,
|
|
8
|
+
category TEXT NOT NULL,
|
|
9
|
+
operation TEXT NOT NULL,
|
|
10
|
+
trigger_kind TEXT NOT NULL,
|
|
11
|
+
reason_key TEXT NOT NULL,
|
|
12
|
+
provider TEXT NOT NULL,
|
|
13
|
+
model TEXT NOT NULL,
|
|
14
|
+
status TEXT NOT NULL CHECK(status IN ('running', 'succeeded', 'failed', 'aborted', 'unknown')),
|
|
15
|
+
started_at INTEGER NOT NULL,
|
|
16
|
+
finished_at INTEGER,
|
|
17
|
+
duration_ms INTEGER,
|
|
18
|
+
input_tokens INTEGER,
|
|
19
|
+
output_tokens INTEGER,
|
|
20
|
+
cache_read_tokens INTEGER,
|
|
21
|
+
cache_write_tokens INTEGER,
|
|
22
|
+
reasoning_tokens INTEGER,
|
|
23
|
+
total_tokens INTEGER,
|
|
24
|
+
estimated_cost_microusd INTEGER,
|
|
25
|
+
cost_source TEXT NOT NULL CHECK(cost_source IN ('model_catalog', 'local', 'unknown')),
|
|
26
|
+
pricing_snapshot_json TEXT,
|
|
27
|
+
error_summary TEXT,
|
|
28
|
+
created_at INTEGER NOT NULL,
|
|
29
|
+
updated_at INTEGER NOT NULL
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
CREATE INDEX idx_ai_usage_events_started
|
|
33
|
+
ON ai_usage_events(started_at DESC, id DESC);
|
|
34
|
+
CREATE INDEX idx_ai_usage_events_conversation
|
|
35
|
+
ON ai_usage_events(conversation_id, started_at DESC);
|
|
36
|
+
CREATE INDEX idx_ai_usage_events_trace
|
|
37
|
+
ON ai_usage_events(trace_id, started_at ASC);
|
|
38
|
+
CREATE INDEX idx_ai_usage_events_agent
|
|
39
|
+
ON ai_usage_events(agent_id, started_at DESC);
|
|
40
|
+
CREATE INDEX idx_ai_usage_events_category
|
|
41
|
+
ON ai_usage_events(category, started_at DESC);
|