@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
|
@@ -215,27 +215,6 @@ CREATE TABLE note_agent_contexts (
|
|
|
215
215
|
CREATE INDEX idx_note_agent_contexts_generated
|
|
216
216
|
ON note_agent_contexts(generated_at DESC);
|
|
217
217
|
|
|
218
|
-
CREATE TABLE memory_files (
|
|
219
|
-
file_id TEXT PRIMARY KEY,
|
|
220
|
-
user_id TEXT NOT NULL,
|
|
221
|
-
path TEXT NOT NULL,
|
|
222
|
-
mtime_ms INTEGER NOT NULL,
|
|
223
|
-
content_hash TEXT NOT NULL,
|
|
224
|
-
UNIQUE(user_id, path)
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
CREATE TABLE memory_chunks (
|
|
228
|
-
chunk_id TEXT PRIMARY KEY,
|
|
229
|
-
file_id TEXT NOT NULL,
|
|
230
|
-
start_line INTEGER NOT NULL,
|
|
231
|
-
end_line INTEGER NOT NULL,
|
|
232
|
-
content TEXT NOT NULL,
|
|
233
|
-
FOREIGN KEY (file_id) REFERENCES memory_files(file_id) ON DELETE CASCADE
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
CREATE INDEX idx_memory_chunks_file
|
|
237
|
-
ON memory_chunks(file_id, start_line);
|
|
238
|
-
|
|
239
218
|
CREATE VIRTUAL TABLE notes_fts USING fts5(
|
|
240
219
|
content,
|
|
241
220
|
note_id UNINDEXED,
|
|
@@ -409,27 +388,6 @@ CREATE INDEX idx_knowledge_sync_runs_source_started
|
|
|
409
388
|
CREATE INDEX idx_knowledge_sync_runs_status_started
|
|
410
389
|
ON knowledge_sync_runs(status, started_at DESC);
|
|
411
390
|
|
|
412
|
-
CREATE TABLE memory_relations (
|
|
413
|
-
relation_id TEXT PRIMARY KEY,
|
|
414
|
-
from_record_id TEXT NOT NULL,
|
|
415
|
-
relation_type TEXT NOT NULL,
|
|
416
|
-
to_record_id TEXT NOT NULL,
|
|
417
|
-
confidence REAL NOT NULL,
|
|
418
|
-
valid_from INTEGER,
|
|
419
|
-
valid_to INTEGER,
|
|
420
|
-
created_at INTEGER NOT NULL,
|
|
421
|
-
updated_at INTEGER NOT NULL,
|
|
422
|
-
UNIQUE(from_record_id, relation_type, to_record_id),
|
|
423
|
-
FOREIGN KEY(from_record_id) REFERENCES memory_records(record_id) ON DELETE CASCADE,
|
|
424
|
-
FOREIGN KEY(to_record_id) REFERENCES memory_records(record_id) ON DELETE CASCADE
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
CREATE INDEX idx_memory_relations_from
|
|
428
|
-
ON memory_relations(from_record_id, relation_type);
|
|
429
|
-
|
|
430
|
-
CREATE INDEX idx_memory_relations_to
|
|
431
|
-
ON memory_relations(to_record_id, relation_type);
|
|
432
|
-
|
|
433
391
|
CREATE TABLE connector_catalog_entries (
|
|
434
392
|
connector_id TEXT PRIMARY KEY,
|
|
435
393
|
provider TEXT NOT NULL,
|
|
@@ -581,16 +539,6 @@ CREATE TABLE knowledge_consumer_watermarks (
|
|
|
581
539
|
PRIMARY KEY(consumer_id, source_instance_id)
|
|
582
540
|
);
|
|
583
541
|
|
|
584
|
-
CREATE VIRTUAL TABLE memory_fts USING fts5(
|
|
585
|
-
content,
|
|
586
|
-
chunk_id UNINDEXED,
|
|
587
|
-
user_id UNINDEXED,
|
|
588
|
-
path UNINDEXED,
|
|
589
|
-
start_line UNINDEXED,
|
|
590
|
-
end_line UNINDEXED,
|
|
591
|
-
tokenize='unicode61'
|
|
592
|
-
);
|
|
593
|
-
|
|
594
542
|
CREATE TABLE local_apps (
|
|
595
543
|
app_id TEXT PRIMARY KEY,
|
|
596
544
|
extension_id TEXT NOT NULL UNIQUE,
|
|
@@ -190,13 +190,6 @@ CREATE TABLE scene_mail_sources (
|
|
|
190
190
|
UNIQUE(owner_id, workspace_id, account_id, thread_id)
|
|
191
191
|
);
|
|
192
192
|
|
|
193
|
-
CREATE TABLE scene_model_usage (
|
|
194
|
-
run_id TEXT NOT NULL REFERENCES scene_runs(id), lease_epoch INTEGER NOT NULL,
|
|
195
|
-
provider TEXT NOT NULL, model TEXT NOT NULL, input_tokens INTEGER NOT NULL,
|
|
196
|
-
output_tokens INTEGER NOT NULL, total_tokens INTEGER NOT NULL, estimated_cost REAL NOT NULL,
|
|
197
|
-
recorded_at INTEGER NOT NULL, PRIMARY KEY(run_id, lease_epoch)
|
|
198
|
-
);
|
|
199
|
-
|
|
200
193
|
CREATE TABLE scene_connector_usage (
|
|
201
194
|
owner_id TEXT NOT NULL, workspace_id TEXT NOT NULL, account_id TEXT NOT NULL,
|
|
202
195
|
utc_day INTEGER NOT NULL, request_count INTEGER NOT NULL,
|
|
@@ -51,6 +51,14 @@ export declare function listActiveSessionInputRuns(): Array<{
|
|
|
51
51
|
conversationId: string;
|
|
52
52
|
runId: string;
|
|
53
53
|
}>;
|
|
54
|
+
/** Durable active runs with the claimed input metadata needed by runtime policy surfaces. */
|
|
55
|
+
export declare function listActiveSessionInputExecutions(): Array<{
|
|
56
|
+
conversationId: string;
|
|
57
|
+
runId: string;
|
|
58
|
+
origin: TurnOrigin;
|
|
59
|
+
taskRunId?: string;
|
|
60
|
+
startedAt: number;
|
|
61
|
+
}>;
|
|
54
62
|
export declare function findSessionInput(conversationId: string, clientMessageId: string): SessionInput | undefined;
|
|
55
63
|
export declare function getSessionInputById(conversationId: string, id: string): SessionInput | undefined;
|
|
56
64
|
export declare class SessionInstanceChangedError extends Error {
|
|
@@ -65,6 +65,23 @@ function listActiveSessionInputRuns() {
|
|
|
65
65
|
runId: row.active_run_id
|
|
66
66
|
}));
|
|
67
67
|
}
|
|
68
|
+
/** Durable active runs with the claimed input metadata needed by runtime policy surfaces. */
|
|
69
|
+
function listActiveSessionInputExecutions() {
|
|
70
|
+
return getSqliteDatabase().prepare(`SELECT runtime.conversation_id, runtime.active_run_id,
|
|
71
|
+
input.origin_json, input.task_run_id, input.updated_at_ms
|
|
72
|
+
FROM session_input_runtime runtime
|
|
73
|
+
LEFT JOIN session_inputs input ON input.id = runtime.active_input_id
|
|
74
|
+
WHERE runtime.active_run_id IS NOT NULL`).all().map((row) => ({
|
|
75
|
+
conversationId: row.conversation_id,
|
|
76
|
+
runId: row.active_run_id,
|
|
77
|
+
origin: row.origin_json ? turnOriginSchema.parse(JSON.parse(row.origin_json)) : {
|
|
78
|
+
type: "system",
|
|
79
|
+
source: "internal"
|
|
80
|
+
},
|
|
81
|
+
...row.task_run_id ? { taskRunId: row.task_run_id } : {},
|
|
82
|
+
startedAt: row.updated_at_ms ?? Date.now()
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
68
85
|
function findSessionInput(conversationId, clientMessageId) {
|
|
69
86
|
const row = getSqliteDatabase().prepare(`${SELECT_INPUTS} WHERE conversation_id = ? AND client_message_id = ?`).get(conversationId, clientMessageId);
|
|
70
87
|
return row ? mapInput(row) : void 0;
|
|
@@ -188,4 +205,4 @@ var init_session_input_repository = __esmMin((() => {
|
|
|
188
205
|
}));
|
|
189
206
|
//#endregion
|
|
190
207
|
init_session_input_repository();
|
|
191
|
-
export { SessionInstanceChangedError, bumpSessionInputRevision, cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, init_session_input_repository, insertSessionInput, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus };
|
|
208
|
+
export { SessionInstanceChangedError, bumpSessionInputRevision, cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, init_session_input_repository, insertSessionInput, listActiveSessionInputExecutions, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import type { SessionMetadata } from '../../session/types.js';
|
|
3
3
|
import { type SessionRow } from './row-mappers.js';
|
|
4
|
-
export declare const SESSION_COLUMNS = "\n s.conversation_id, s.agent_id, s.active_transcript_id, s.status, s.name, s.tags_json,\n s.created_at, s.updated_at, s.last_accessed_at, s.session_started_at, s.last_interaction_at,\n s.source_channel, s.source_chat_id, s.session_type, s.hidden_from_session_list,\n s.parent_conversation_id, s.workflow_run_id, s.workflow_definition_id, s.workflow_agent_id, s.workflow_agent_label,\n s.project_id, s.routing_json, s.custom_data_json,\n s.message_count, s.estimated_tokens, s.compacted_count,\n s.last_flushed_at, s.flush_count,\n
|
|
4
|
+
export declare const SESSION_COLUMNS = "\n s.conversation_id, s.agent_id, s.active_transcript_id, s.status, s.name, s.tags_json,\n s.created_at, s.updated_at, s.last_accessed_at, s.session_started_at, s.last_interaction_at,\n s.source_channel, s.source_chat_id, s.session_type, s.hidden_from_session_list,\n s.parent_conversation_id, s.workflow_run_id, s.workflow_definition_id, s.workflow_agent_id, s.workflow_agent_label,\n s.project_id, s.routing_json, s.custom_data_json,\n s.message_count, s.estimated_tokens, s.compacted_count,\n s.last_flushed_at, s.flush_count,\n t.cwd AS cwd\n";
|
|
5
5
|
export declare const SESSION_FROM_JOIN = "\n FROM sessions s\n LEFT JOIN transcripts t ON t.transcript_id = s.active_transcript_id\n";
|
|
6
6
|
export declare function readSessionRow(db: DatabaseSync, conversationId: string): SessionRow | undefined;
|
|
7
7
|
/** Read metadata without importing session lifecycle operations. */
|
|
@@ -22,7 +22,6 @@ var init_session_read_repository = __esmMin((() => {
|
|
|
22
22
|
s.project_id, s.routing_json, s.custom_data_json,
|
|
23
23
|
s.message_count, s.estimated_tokens, s.compacted_count,
|
|
24
24
|
s.last_flushed_at, s.flush_count,
|
|
25
|
-
s.thinking_level, s.verbose_level,
|
|
26
25
|
t.cwd AS cwd
|
|
27
26
|
`;
|
|
28
27
|
SESSION_FROM_JOIN = `
|
|
@@ -21,10 +21,6 @@ export declare function resetSessionRecord(conversationId: string, cwd: string):
|
|
|
21
21
|
} | null;
|
|
22
22
|
export declare function deleteSessionRecord(conversationId: string): boolean;
|
|
23
23
|
export declare function listSessionsByAgent(agentId: string): SessionMetadata[];
|
|
24
|
-
export declare function getSessionPersistedLevels(conversationId: string): {
|
|
25
|
-
thinkingLevel: string | null;
|
|
26
|
-
verboseLevel: string | null;
|
|
27
|
-
} | null;
|
|
28
24
|
export declare function findConversationIdByTranscriptId(transcriptId: string): string | null;
|
|
29
25
|
export declare function getGlobalSessionStats(): ReturnType<typeof buildGlobalSessionStats>;
|
|
30
26
|
export declare function resolveSessionAgentId(conversationId: string): string;
|
|
@@ -4,6 +4,7 @@ import { validateConversationId, validateTranscriptId } from "../../../packages/
|
|
|
4
4
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
5
5
|
import { init_session_instance_repository, readCurrentTranscriptId } from "./session-instance-repository.js";
|
|
6
6
|
import { buildDefaultSessionMetadata, init_session_metadata } from "./session-metadata.js";
|
|
7
|
+
import { init_timestamps, optionalTimestampToMs } from "./timestamps.js";
|
|
7
8
|
import { buildGlobalSessionStats, init_row_mappers, metadataToSessionInsert, sessionRowToMetadata } from "./row-mappers.js";
|
|
8
9
|
import { cancelConnectionObjective, init_connection_wait_repository } from "./connection-wait-repository.js";
|
|
9
10
|
import { init_changes, notifyUserContextChange } from "../../user-context/changes.js";
|
|
@@ -21,17 +22,15 @@ function insertSessionAndTranscript(db, conversationId, transcriptId, cwd, metad
|
|
|
21
22
|
parent_conversation_id, workflow_run_id, workflow_definition_id, workflow_agent_id, workflow_agent_label,
|
|
22
23
|
project_id, routing_json, custom_data_json,
|
|
23
24
|
message_count, estimated_tokens, compacted_count,
|
|
24
|
-
last_flushed_at, flush_count
|
|
25
|
-
thinking_level, verbose_level
|
|
25
|
+
last_flushed_at, flush_count
|
|
26
26
|
) VALUES (
|
|
27
27
|
?, ?, ?, ?, ?,
|
|
28
28
|
?, ?, ?, ?, ?,
|
|
29
29
|
?, ?, ?, ?,
|
|
30
30
|
?, ?, ?, ?, ?,
|
|
31
31
|
?, ?, ?,
|
|
32
|
-
?, ?, ?, ?, ?,
|
|
33
|
-
|
|
34
|
-
)`).run(row.conversationId, row.agentId, row.transcriptId, row.status, row.name, row.tagsJson, row.createdAt, row.updatedAt, row.lastAccessedAt, row.sessionStartedAt, row.lastInteractionAt, row.sourceChannel, row.sourceChatId, row.sessionType, row.hiddenFromSessionList, row.parentConversationId, row.workflowRunId, row.workflowDefinitionId, row.workflowAgentId, row.workflowAgentLabel, row.projectId, row.routingJson, row.customDataJson, row.messageCount, row.estimatedTokens, row.compactedCount, row.lastFlushedAt, row.flushCount, row.thinkingLevel, row.verboseLevel);
|
|
32
|
+
?, ?, ?, ?, ?, ?
|
|
33
|
+
)`).run(row.conversationId, row.agentId, row.transcriptId, row.status, row.name, row.tagsJson, row.createdAt, row.updatedAt, row.lastAccessedAt, row.sessionStartedAt, row.lastInteractionAt, row.sourceChannel, row.sourceChatId, row.sessionType, row.hiddenFromSessionList, row.parentConversationId, row.workflowRunId, row.workflowDefinitionId, row.workflowAgentId, row.workflowAgentLabel, row.projectId, row.routingJson, row.customDataJson, row.messageCount, row.estimatedTokens, row.compactedCount, row.lastFlushedAt, row.flushCount);
|
|
35
34
|
const now = Date.now();
|
|
36
35
|
db.prepare(`INSERT INTO transcripts (transcript_id, conversation_id, status, created_at, cwd)
|
|
37
36
|
VALUES (?, ?, 'active', ?, ?)`).run(transcriptId, conversationId, now, cwd);
|
|
@@ -224,10 +223,8 @@ function patchSessionMetadata(conversationId, updates) {
|
|
|
224
223
|
estimated_tokens = ?,
|
|
225
224
|
compacted_count = ?,
|
|
226
225
|
last_flushed_at = ?,
|
|
227
|
-
flush_count =
|
|
228
|
-
|
|
229
|
-
verbose_level = ?
|
|
230
|
-
WHERE conversation_id = ?`).run(merged.status, merged.name ?? null, JSON.stringify(merged.tags ?? []), Date.parse(merged.updatedAt) || now, Date.parse(merged.lastAccessedAt) || now, merged.sessionStartedAt ? Date.parse(merged.sessionStartedAt) : existing.session_started_at, merged.lastInteractionAt ? Date.parse(merged.lastInteractionAt) : existing.last_interaction_at, merged.sourceChannel, merged.sourceChatId, merged.sessionType, merged.hiddenFromSessionList ? 1 : 0, merged.parentConversationId ?? null, merged.workflowRunId ?? null, merged.workflowDefinitionId ?? null, merged.workflowAgentId ?? null, merged.workflowAgentLabel ?? null, merged.projectId ?? null, merged.routing ? JSON.stringify(merged.routing) : null, merged.customData ? JSON.stringify(merged.customData) : null, merged.messageCount, merged.estimatedTokens, merged.compactedCount, merged.lastFlushedAt ?? null, merged.flushCount ?? 0, existing.thinking_level, existing.verbose_level, conversationId);
|
|
226
|
+
flush_count = ?
|
|
227
|
+
WHERE conversation_id = ?`).run(merged.status, merged.name ?? null, JSON.stringify(merged.tags ?? []), Date.parse(merged.updatedAt) || now, Date.parse(merged.lastAccessedAt) || now, merged.sessionStartedAt ? Date.parse(merged.sessionStartedAt) : existing.session_started_at, merged.lastInteractionAt ? Date.parse(merged.lastInteractionAt) : existing.last_interaction_at, merged.sourceChannel, merged.sourceChatId, merged.sessionType, merged.hiddenFromSessionList ? 1 : 0, merged.parentConversationId ?? null, merged.workflowRunId ?? null, merged.workflowDefinitionId ?? null, merged.workflowAgentId ?? null, merged.workflowAgentLabel ?? null, merged.projectId ?? null, merged.routing ? JSON.stringify(merged.routing) : null, merged.customData ? JSON.stringify(merged.customData) : null, merged.messageCount, merged.estimatedTokens, merged.compactedCount, optionalTimestampToMs(merged.lastFlushedAt), merged.flushCount ?? 0, conversationId);
|
|
231
228
|
const row = readSessionRow(db, conversationId);
|
|
232
229
|
if (!row) throw new Error(`Session not found after patch: ${conversationId}`);
|
|
233
230
|
return sessionRowToMetadata(conversationId, row);
|
|
@@ -308,14 +305,6 @@ function listSessionsByAgent(agentId) {
|
|
|
308
305
|
WHERE s.agent_id = ?
|
|
309
306
|
ORDER BY s.updated_at DESC`).all(agentId.toLowerCase()).map((row) => sessionRowToMetadata(row.conversation_id, row));
|
|
310
307
|
}
|
|
311
|
-
function getSessionPersistedLevels(conversationId) {
|
|
312
|
-
const row = getSqliteDatabase().prepare(`SELECT thinking_level, verbose_level FROM sessions WHERE conversation_id = ?`).get(conversationId);
|
|
313
|
-
if (!row) return null;
|
|
314
|
-
return {
|
|
315
|
-
thinkingLevel: row.thinking_level,
|
|
316
|
-
verboseLevel: row.verbose_level
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
308
|
function findConversationIdByTranscriptId(transcriptId) {
|
|
320
309
|
return getSqliteDatabase().prepare(`SELECT conversation_id FROM sessions WHERE active_transcript_id = ?`).get(transcriptId)?.conversation_id ?? null;
|
|
321
310
|
}
|
|
@@ -335,6 +324,7 @@ var init_session_repository = __esmMin((() => {
|
|
|
335
324
|
init_session_metadata();
|
|
336
325
|
init_session_instance_repository();
|
|
337
326
|
init_row_mappers();
|
|
327
|
+
init_timestamps();
|
|
338
328
|
init_transaction();
|
|
339
329
|
init_session_identity_sql();
|
|
340
330
|
init_fts();
|
|
@@ -342,4 +332,4 @@ var init_session_repository = __esmMin((() => {
|
|
|
342
332
|
}));
|
|
343
333
|
//#endregion
|
|
344
334
|
init_session_repository();
|
|
345
|
-
export { deleteSessionRecord, ensureSessionInTransaction, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats, getSessionMetadata,
|
|
335
|
+
export { deleteSessionRecord, ensureSessionInTransaction, ensureSessionRecord, findConversationIdByTranscriptId, getCurrentTranscriptId, getGlobalSessionStats, getSessionMetadata, incrementSessionStatsOnAppend, init_session_repository, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, readCurrentTranscriptId, resetSessionRecord, resolveSessionAgentId, updateSessionStats };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function timestampToMs(value: string): number;
|
|
2
|
+
export declare function optionalTimestampToMs(value: string | undefined): number | null;
|
|
3
|
+
export declare function timestampToIso(value: number): string;
|
|
4
|
+
export declare function optionalTimestampToIso(value: number | null): string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region src/storage/sqlite/timestamps.ts
|
|
3
|
+
function timestampToMs(value) {
|
|
4
|
+
const timestamp = Date.parse(value);
|
|
5
|
+
if (!Number.isFinite(timestamp)) throw new Error(`Invalid ISO timestamp: ${value}`);
|
|
6
|
+
return timestamp;
|
|
7
|
+
}
|
|
8
|
+
function optionalTimestampToMs(value) {
|
|
9
|
+
return value === void 0 ? null : timestampToMs(value);
|
|
10
|
+
}
|
|
11
|
+
function timestampToIso(value) {
|
|
12
|
+
return new Date(value).toISOString();
|
|
13
|
+
}
|
|
14
|
+
function optionalTimestampToIso(value) {
|
|
15
|
+
return value === null ? void 0 : timestampToIso(value);
|
|
16
|
+
}
|
|
17
|
+
var init_timestamps = __esmMin((() => {}));
|
|
18
|
+
//#endregion
|
|
19
|
+
init_timestamps();
|
|
20
|
+
export { init_timestamps, optionalTimestampToIso, optionalTimestampToMs, timestampToIso, timestampToMs };
|
|
@@ -52,6 +52,7 @@ export declare function paginateTranscriptMessages(conversationId: string, optio
|
|
|
52
52
|
total: number;
|
|
53
53
|
startSeq: number;
|
|
54
54
|
endSeq: number;
|
|
55
|
+
revision: number;
|
|
55
56
|
};
|
|
56
57
|
export declare function listCompactionBoundaries(conversationId: string): CompactionBoundarySummary[];
|
|
57
58
|
export declare function restoreBeforeCompactionBoundary(conversationId: string, compactionId: string): void;
|
|
@@ -50,24 +50,27 @@ function withSessionInputContextMetadata(db, conversationId, row) {
|
|
|
50
50
|
const turnId = typeof message.turnId === "string" ? message.turnId.trim() : "";
|
|
51
51
|
if (!turnId) return row;
|
|
52
52
|
const metadata = message.metadata && typeof message.metadata === "object" && !Array.isArray(message.metadata) ? message.metadata : {};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
WHERE conversation_id = ? AND run_id = ? AND context_refs_json IS NOT NULL
|
|
53
|
+
const input = db.prepare(`SELECT client_message_id, context_refs_json FROM session_inputs
|
|
54
|
+
WHERE conversation_id = ? AND run_id = ?
|
|
56
55
|
LIMIT 1`).get(conversationId, turnId);
|
|
57
56
|
if (!input) return row;
|
|
57
|
+
let sourceContexts = metadata.sourceContexts;
|
|
58
58
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
metadata: {
|
|
64
|
-
...metadata,
|
|
65
|
-
sourceContexts
|
|
66
|
-
}
|
|
67
|
-
};
|
|
59
|
+
if ((!Array.isArray(sourceContexts) || sourceContexts.length === 0) && input.context_refs_json) {
|
|
60
|
+
const parsed = JSON.parse(input.context_refs_json);
|
|
61
|
+
if (Array.isArray(parsed) && parsed.length > 0) sourceContexts = parsed;
|
|
62
|
+
}
|
|
68
63
|
} catch {
|
|
69
|
-
|
|
64
|
+
sourceContexts = metadata.sourceContexts;
|
|
70
65
|
}
|
|
66
|
+
return {
|
|
67
|
+
...message,
|
|
68
|
+
metadata: {
|
|
69
|
+
...metadata,
|
|
70
|
+
clientMessageId: input.client_message_id,
|
|
71
|
+
...Array.isArray(sourceContexts) && sourceContexts.length > 0 ? { sourceContexts } : {}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
71
74
|
}
|
|
72
75
|
function appendTranscriptEntry(conversationId, row, opts) {
|
|
73
76
|
if (isRuntimeOnlyTranscriptMessage(row)) throw new Error("Runtime-only messages cannot be persisted in a session transcript");
|
|
@@ -281,7 +284,8 @@ function paginateTranscriptMessages(conversationId, options = {}) {
|
|
|
281
284
|
messages: [],
|
|
282
285
|
total: 0,
|
|
283
286
|
startSeq: 0,
|
|
284
|
-
endSeq: 0
|
|
287
|
+
endSeq: 0,
|
|
288
|
+
revision: 0
|
|
285
289
|
};
|
|
286
290
|
const db = getSqliteDatabase();
|
|
287
291
|
const kinds = options.includeContext ? ["message", "context"] : ["message"];
|
|
@@ -293,6 +297,9 @@ function paginateTranscriptMessages(conversationId, options = {}) {
|
|
|
293
297
|
FROM transcript_entries e
|
|
294
298
|
JOIN transcripts t ON t.transcript_id = e.transcript_id
|
|
295
299
|
WHERE ${transcriptWhere} AND e.entry_kind IN (${kindPlaceholders})`).get(transcriptArg, ...kinds).total;
|
|
300
|
+
const revisionRow = db.prepare(`SELECT COALESCE(MAX(seq), 0) AS revision
|
|
301
|
+
FROM transcript_entries
|
|
302
|
+
WHERE transcript_id = ? AND entry_kind IN (${kindPlaceholders})`).get(transcriptId, ...kinds);
|
|
296
303
|
const limit = Math.min(200, Math.max(1, Math.trunc(options.limit ?? 50)));
|
|
297
304
|
const offset = Math.max(0, Math.trunc(options.offset ?? 0));
|
|
298
305
|
let rows;
|
|
@@ -324,7 +331,8 @@ function paginateTranscriptMessages(conversationId, options = {}) {
|
|
|
324
331
|
messages: buildSessionContextForLlm(storedRows),
|
|
325
332
|
total,
|
|
326
333
|
startSeq: rows[0]?.seq ?? 0,
|
|
327
|
-
endSeq: rows[rows.length - 1]?.seq ?? 0
|
|
334
|
+
endSeq: rows[rows.length - 1]?.seq ?? 0,
|
|
335
|
+
revision: revisionRow.revision
|
|
328
336
|
};
|
|
329
337
|
}
|
|
330
338
|
function listCompactionBoundaries(conversationId) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
3
|
+
import { init_timestamps, timestampToIso } from "./timestamps.js";
|
|
3
4
|
import { DEFAULT_USER_TRUST_LEVEL, init_trust_policy, isUserTrustLevel } from "../../user-context/trust-policy.js";
|
|
4
5
|
//#region src/storage/sqlite/user-trust-repository.ts
|
|
5
6
|
function fromRow(row) {
|
|
6
7
|
return {
|
|
7
8
|
principalId: row.principal_id,
|
|
8
9
|
defaultActionLevel: isUserTrustLevel(row.default_action_level) ? row.default_action_level : DEFAULT_USER_TRUST_LEVEL,
|
|
9
|
-
updatedAt: row.updated_at
|
|
10
|
+
updatedAt: timestampToIso(row.updated_at)
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
function getUserTrustPolicy(principalId = "local-owner") {
|
|
@@ -17,7 +18,7 @@ function getUserTrustPolicy(principalId = "local-owner") {
|
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
function setUserTrustPolicy(defaultActionLevel, principalId = "local-owner") {
|
|
20
|
-
const updatedAt =
|
|
21
|
+
const updatedAt = Date.now();
|
|
21
22
|
return runSqliteWriteTransaction((db) => {
|
|
22
23
|
db.prepare(`
|
|
23
24
|
INSERT INTO user_trust_policies (principal_id, default_action_level, updated_at)
|
|
@@ -31,6 +32,7 @@ function setUserTrustPolicy(defaultActionLevel, principalId = "local-owner") {
|
|
|
31
32
|
}
|
|
32
33
|
var init_user_trust_repository = __esmMin((() => {
|
|
33
34
|
init_trust_policy();
|
|
35
|
+
init_timestamps();
|
|
34
36
|
init_transaction();
|
|
35
37
|
}));
|
|
36
38
|
//#endregion
|
|
@@ -101,8 +101,8 @@ export declare const TaskMutationOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObj
|
|
|
101
101
|
ok: z.ZodLiteral<false>;
|
|
102
102
|
reason: z.ZodEnum<{
|
|
103
103
|
blocked: "blocked";
|
|
104
|
-
not_found: "not_found";
|
|
105
104
|
conflict: "conflict";
|
|
105
|
+
not_found: "not_found";
|
|
106
106
|
invalid_transition: "invalid_transition";
|
|
107
107
|
}>;
|
|
108
108
|
model: z.ZodOptional<z.ZodObject<{
|
|
@@ -51,7 +51,7 @@ function toHomeAutomation(automation) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
function effectiveAutomationTimeoutSeconds(run, automation) {
|
|
54
|
-
return ("timeoutSeconds" in run.actionSnapshot ? run.actionSnapshot.timeoutSeconds : void 0) ?? automation?.reliability?.
|
|
54
|
+
return ("timeoutSeconds" in run.actionSnapshot ? run.actionSnapshot.timeoutSeconds : void 0) ?? automation?.reliability?.executionTimeoutSeconds ?? 1800;
|
|
55
55
|
}
|
|
56
56
|
function attentionDetail(kind, status, locale, timeoutSeconds) {
|
|
57
57
|
const isChinese = locale?.toLowerCase().startsWith("zh") ?? false;
|
|
@@ -327,7 +327,7 @@ var HomeQueryService = class {
|
|
|
327
327
|
const projectsById = new Map(projects.items.map((project) => [project.id, project]));
|
|
328
328
|
const activeWorkflowRuns = workflowRuns.filter((run) => run.status === "queued" || run.status === "running").map(toHomeWorkflowRun);
|
|
329
329
|
const failedWorkflowRuns = workflowRuns.filter((run) => run.status === "failed" || run.status === "timeout").slice(0, 5).map(toHomeWorkflowRun);
|
|
330
|
-
const upcomingAutomations = automations.filter((automation) => automation.notificationPolicy !== "none").map(toHomeAutomation).filter((automation) => Boolean(automation)).sort((a, b) => Date.parse(a.nextRunAt) - Date.parse(b.nextRunAt));
|
|
330
|
+
const upcomingAutomations = automations.filter((automation) => automation.delivery.notificationPolicy !== "none").map(toHomeAutomation).filter((automation) => Boolean(automation)).sort((a, b) => Date.parse(a.nextRunAt) - Date.parse(b.nextRunAt));
|
|
331
331
|
const latestAutomationRuns = [...automationRuns].sort((left, right) => right.createdAtMs - left.createdAtMs).filter((run, index, all) => all.findIndex((candidate) => candidate.automationId === run.automationId) === index);
|
|
332
332
|
const automationsById = new Map(automations.map((automation) => [automation.id, automation]));
|
|
333
333
|
const decisionCandidates = [...activeTasks.map((task) => decisionFromTask(this.#projector.project(task), task.projectId ? projectsById.get(task.projectId)?.name : void 0, locale)).filter((item) => Boolean(item)), ...connectorApprovals.filter((approval) => Date.parse(approval.expiresAt) > nowMs).map((approval) => ({
|
|
@@ -354,7 +354,7 @@ var HomeQueryService = class {
|
|
|
354
354
|
href: `/workflows?runId=${encodeURIComponent(run.id)}`,
|
|
355
355
|
updatedAt: run.completedAtMs ?? run.startedAtMs ?? run.createdAtMs,
|
|
356
356
|
conversationId: run.conversationId
|
|
357
|
-
})), ...latestAutomationRuns.filter((run) => run.status === "failed" || run.status === "timeout").filter((run) => automationsById.get(run.automationId)?.notificationPolicy !== "none").filter((run) => !isHomeAttentionAcknowledged("automation_run", run.id)).map((run) => ({
|
|
357
|
+
})), ...latestAutomationRuns.filter((run) => run.status === "failed" || run.status === "timeout").filter((run) => automationsById.get(run.automationId)?.delivery.notificationPolicy !== "none").filter((run) => !isHomeAttentionAcknowledged("automation_run", run.id)).map((run) => ({
|
|
358
358
|
id: `automation_run:${run.id}`,
|
|
359
359
|
kind: "automation_run",
|
|
360
360
|
runId: run.id,
|
|
@@ -69,7 +69,7 @@ var ModelTaskContractPlanner = class {
|
|
|
69
69
|
apiKey: await resolveModelCallApiKey(model),
|
|
70
70
|
maxTokens: 2e3,
|
|
71
71
|
temperature: 0
|
|
72
|
-
})).content));
|
|
72
|
+
}, void 0, { operation: "task.plan_contract" })).content));
|
|
73
73
|
return planned ? {
|
|
74
74
|
...planned,
|
|
75
75
|
objective: fallback.objective
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AiPricingSnapshot, AiUsageCostSource, AiUsageModel } from './types.js';
|
|
2
|
+
export declare function pricingSnapshot(model: AiUsageModel): AiPricingSnapshot;
|
|
3
|
+
export declare function classifyCostSource(model: AiUsageModel): AiUsageCostSource;
|
|
4
|
+
export declare function dollarsToMicrousd(value: number | undefined): number | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/usage/cost.ts
|
|
2
|
+
function isLocalBaseUrl(baseUrl) {
|
|
3
|
+
if (!baseUrl) return false;
|
|
4
|
+
try {
|
|
5
|
+
const host = new URL(baseUrl).hostname.toLowerCase();
|
|
6
|
+
return host === "localhost" || host === "::1" || host === "[::1]" || host.startsWith("127.") || host.startsWith("10.") || host.startsWith("192.168.") || /^172\.(1[6-9]|2\d|3[0-1])\./.test(host);
|
|
7
|
+
} catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function pricingSnapshot(model) {
|
|
12
|
+
return {
|
|
13
|
+
input: model.cost?.input ?? 0,
|
|
14
|
+
output: model.cost?.output ?? 0,
|
|
15
|
+
cacheRead: model.cost?.cacheRead ?? 0,
|
|
16
|
+
cacheWrite: model.cost?.cacheWrite ?? 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function classifyCostSource(model) {
|
|
20
|
+
if (isLocalBaseUrl(model.baseUrl)) return "local";
|
|
21
|
+
return Object.values(pricingSnapshot(model)).some((price) => price > 0) ? "model_catalog" : "unknown";
|
|
22
|
+
}
|
|
23
|
+
function dollarsToMicrousd(value) {
|
|
24
|
+
if (value === void 0 || !Number.isFinite(value) || value < 0) return void 0;
|
|
25
|
+
return Math.round(value * 1e6);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { classifyCostSource, dollarsToMicrousd, pricingSnapshot };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AssistantMessage, AssistantMessageEventStream } from '@earendil-works/pi-ai/compat';
|
|
2
|
+
import type { AiUsageContext, AiUsageFinish, AiUsageModel } from './types.js';
|
|
3
|
+
export type AiUsageCall = {
|
|
4
|
+
id: string;
|
|
5
|
+
finish: (result: AiUsageFinish) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function continuesAfterTool(messages: readonly {
|
|
8
|
+
role?: string;
|
|
9
|
+
}[]): boolean;
|
|
10
|
+
export declare function startAiUsageCall(model: AiUsageModel, context: AiUsageContext): AiUsageCall | undefined;
|
|
11
|
+
export declare function observeAiUsageStream(stream: AssistantMessageEventStream, call: AiUsageCall | undefined): AssistantMessageEventStream;
|
|
12
|
+
export declare function trackAiUsageStream(model: AiUsageModel, context: AiUsageContext, create: () => AssistantMessageEventStream | Promise<AssistantMessageEventStream>): AssistantMessageEventStream | Promise<AssistantMessageEventStream>;
|
|
13
|
+
export declare function finishAiUsageFromMessage(call: AiUsageCall | undefined, message: AssistantMessage): void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { init_connection, isXopcDatabaseOpen } from "../storage/sqlite/connection.js";
|
|
4
|
+
import { finishAiUsageEvent, insertAiUsageEvent } from "../storage/sqlite/ai-usage-repository.js";
|
|
5
|
+
import { classifyCostSource, dollarsToMicrousd, pricingSnapshot } from "./cost.js";
|
|
6
|
+
import { resolveAiUsageScenario } from "./scenario-registry.js";
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
//#region src/usage/recorder.ts
|
|
9
|
+
init_connection();
|
|
10
|
+
init_logger();
|
|
11
|
+
const log = createLogger("AiUsage");
|
|
12
|
+
function continuesAfterTool(messages) {
|
|
13
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
14
|
+
const role = messages[index]?.role;
|
|
15
|
+
if (role === "system") continue;
|
|
16
|
+
return role === "toolResult";
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
function startAiUsageCall(model, context) {
|
|
21
|
+
if (!isXopcDatabaseOpen()) return void 0;
|
|
22
|
+
const operation = context.operation;
|
|
23
|
+
const scenario = resolveAiUsageScenario(operation);
|
|
24
|
+
const id = randomUUID();
|
|
25
|
+
const startedAt = Date.now();
|
|
26
|
+
const costSource = classifyCostSource(model);
|
|
27
|
+
try {
|
|
28
|
+
insertAiUsageEvent({
|
|
29
|
+
id,
|
|
30
|
+
traceId: context.traceId ?? context.runId ?? id,
|
|
31
|
+
parentEventId: context.parentEventId,
|
|
32
|
+
conversationId: context.conversationId,
|
|
33
|
+
runId: context.runId,
|
|
34
|
+
agentId: context.agentId,
|
|
35
|
+
category: scenario.category,
|
|
36
|
+
operation,
|
|
37
|
+
trigger: context.trigger ?? scenario.trigger,
|
|
38
|
+
reasonKey: scenario.reasonKey,
|
|
39
|
+
provider: model.provider,
|
|
40
|
+
model: model.id,
|
|
41
|
+
status: "running",
|
|
42
|
+
startedAt,
|
|
43
|
+
costSource,
|
|
44
|
+
pricingSnapshot: costSource === "unknown" ? void 0 : pricingSnapshot(model)
|
|
45
|
+
});
|
|
46
|
+
} catch (err) {
|
|
47
|
+
log.error({
|
|
48
|
+
err,
|
|
49
|
+
operation,
|
|
50
|
+
provider: model.provider,
|
|
51
|
+
modelId: model.id
|
|
52
|
+
}, "Failed to start AI usage record");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let completed = false;
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
finish(result) {
|
|
59
|
+
if (completed) return;
|
|
60
|
+
completed = true;
|
|
61
|
+
try {
|
|
62
|
+
finishAiUsageEvent(id, {
|
|
63
|
+
...result,
|
|
64
|
+
estimatedCostMicrousd: costSource === "local" ? 0 : costSource === "unknown" ? void 0 : dollarsToMicrousd(result.usage?.cost.total)
|
|
65
|
+
});
|
|
66
|
+
} catch (err) {
|
|
67
|
+
log.error({
|
|
68
|
+
err,
|
|
69
|
+
usageEventId: id,
|
|
70
|
+
operation
|
|
71
|
+
}, "Failed to finish AI usage record");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function finishFromMessage(call, message) {
|
|
77
|
+
if (!call) return;
|
|
78
|
+
const status = message.stopReason === "aborted" ? "aborted" : message.stopReason === "error" ? "failed" : "succeeded";
|
|
79
|
+
call.finish({
|
|
80
|
+
status,
|
|
81
|
+
usage: message.usage,
|
|
82
|
+
errorSummary: message.errorMessage
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function observeAiUsageStream(stream, call) {
|
|
86
|
+
if (!call) return stream;
|
|
87
|
+
stream.result().then((message) => finishFromMessage(call, message), (error) => call.finish({
|
|
88
|
+
status: "failed",
|
|
89
|
+
errorSummary: error instanceof Error ? error.message : String(error)
|
|
90
|
+
}));
|
|
91
|
+
return stream;
|
|
92
|
+
}
|
|
93
|
+
function trackAiUsageStream(model, context, create) {
|
|
94
|
+
const call = startAiUsageCall(model, context);
|
|
95
|
+
try {
|
|
96
|
+
const created = create();
|
|
97
|
+
if (created instanceof Promise) return created.then((stream) => observeAiUsageStream(stream, call), (error) => {
|
|
98
|
+
call?.finish({
|
|
99
|
+
status: "failed",
|
|
100
|
+
errorSummary: error instanceof Error ? error.message : String(error)
|
|
101
|
+
});
|
|
102
|
+
throw error;
|
|
103
|
+
});
|
|
104
|
+
return observeAiUsageStream(created, call);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
call?.finish({
|
|
107
|
+
status: "failed",
|
|
108
|
+
errorSummary: error instanceof Error ? error.message : String(error)
|
|
109
|
+
});
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function finishAiUsageFromMessage(call, message) {
|
|
114
|
+
finishFromMessage(call, message);
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { continuesAfterTool, finishAiUsageFromMessage, observeAiUsageStream, startAiUsageCall, trackAiUsageStream };
|