@xopcai/xopc 0.0.331 → 0.0.333
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0BtF24E.js → agent-avatar-dicebear-DiI2O7lC.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CVp3J969.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-DbvLXQO2.js → agent-plugin-dialog-CacyndrS.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DXYZSuUV.js +70 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-fwzTRJfP.js → app-management-settings-panel-BcszTlqr.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-v_GGe8UZ.js → appearance-settings-B1XPe8qz.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-C9ZMEuuA.js → apps-page-ZqANbUZv.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-B6EgADeH.js → archive-plugin-MjUsJcNb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B4H_IFeX.js → attachment-load-DHa-BI9a.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-UlVCvg4r.js → automations-page-Dsjivdxs.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B37vs5tk.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BxTSx30f.js → binary-plugins-DQYcuBHP.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CVzdrpjl.js → block-editor-Bx0uXbJP.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-1ZIPGDeq.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-CBVD8k6O.js → browser-automations-page-CCjYipHc.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CSv4rvmx.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-BnO9LV7U.js +1 -0
- package/dist/gateway/static/root/assets/{capabilities-page-BAT7Vvb8.js → capabilities-page-BfvDvIY1.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CoW7-ESq.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-EETjXmkG.js → capability-header-actions-D_hbWRRF.js} +1 -1
- package/dist/gateway/static/root/assets/channels-BhMaRh1x.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DCqm9j9W.js → chat-terminal-dock-Fnum_IEm.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CxFWdovV.js → computer-settings-page-DI1zfCTA.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-wxsEhmlU.js → connector-service-page-CiGDAubm.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-Ono0Pha1.js +2 -0
- package/dist/gateway/static/root/assets/{date-picker-h_OS6uBR.js → date-picker-D-JhzZyW.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DNgSSH3z.js → dependency-picker-DpD3xaEB.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CflvPnB-.js → desktop-pet-CCoDxKqh.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CXy0X5Js.js → desktop-pet-settings-GxndKfCx.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-BDMiJcsK.js → device-pairing-wizard-B71w3ptm.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BqkOh13m.js → directory-picker-path-field-CUzjJvjs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-VT4s-9pK.js → extension-debug-page-BtDY8ntX.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CBSeGhGA.js → extension-page-D9_XF-XC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DRB6uOo8.js → extension-settings-page-CjhUFAaC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-cR-tz7-Q.js → gateway-config-swr-CgIjCxM8.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-lF-FpnZy.js → gateway-settings-BWaCnwT1.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-6jLRcQsu.js → gateway-startup-retry-i-1lTrwY.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BTjGLngn.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CSSkwsyC.js → image-generation-api-gilc-u7M.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DGkOijwE.js → imports-page-BEtq5BRU.js} +1 -1
- package/dist/gateway/static/root/assets/index-DHL16aYZ.js +121 -0
- package/dist/gateway/static/root/assets/index-N1e6PDwx.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-iU6c2zg1.js → keyboard-shortcuts-settings-JUYY_18v.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-uI7mtoVz.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-C0BWC8D2.js → local-apps-page-BlYESNqz.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Dpoi-r-_.js → logs-page-BbLQreeN.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-c4krhYU7.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-BEeXMfDw.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C8E_F2F_.js → media-plugins-DEFN1I73.js} +1 -1
- package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel--09xGxyE.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-DsxcVBXF.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-qqWG_gs_.js → page-context-capture-button-D43aVpCj.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-b3lheKy4.js → page-tabs-BhYBCqls.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-0Q4rTfGX.js → preview-open-alternatives-CP8agNlc.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-jnJZCrKQ.js → product-open-page-CU7fRhfT.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-U-EdDfAW.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-r96k_2wB.js → projects-page-DUOKZLt7.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BIpltJ47.js → registry-api-BvVx0G1o.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-B1d8pB_y.js → remote-access-hub-fVPQe5YS.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Do_iF13W.js → runtime-tools-settings-panel-Czvzsuj_.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-C0-WHOY3.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-Cfft26Je.js → schema-form-B9Ni5O93.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DdXvW09N.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BtF83fBY.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-iI0MTyuU.js → settings-form-section-jquf1P7n.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C2Ka9oJm.js → settings-page-DPomsvba.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-nnmS_p5h.js → setup-status-panel-BvVlqpHf.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D0Knvtlp.js → share-preview-page-b9DI0N1J.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-R_qwc4DN.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-BuZKcy9b.js → skill-api-Bu7-3w-L.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CNJAQ_e-.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DcxWxIrR.js → skills-page-D7XPEQu_.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CMG0ZAsd.js → system-settings-panel-BwFR0Uci.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-PFjGW2g1.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DGYA6GyO.js → tunnel-api-PfucxMP3.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-t_zdQHcy.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CDemMoSX.js → use-autosave-DLyy2wHz.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-OyfPVfB9.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CXArY4t5.js → voice-api-key-field-CQDY5EBK.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-ujEySjyc.js → voice-config-api-Bwy3Al3J.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Dk5KsKOm.js → work-discovery-overlay-CJzqJ47I.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DNpdaI-2.js → workflow-run-setup-panel-sCOk-esV.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DYBGjN7C.js +6 -0
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +59 -14
- package/dist/packages/gateway-contract/src/capabilities.js +106 -8
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/gateway-contract/src/scenes.js +7 -6
- package/dist/packages/gateway-contract/src/sessions.js +2 -1
- package/dist/packages/gateway-contract/src/usage.js +6 -0
- package/dist/src/agent/agent-manager.js +13 -7
- package/dist/src/agent/background-review/run-background-review.js +7 -2
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +7 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
- package/dist/src/agent/external-tools/gateway-tools.js +44 -11
- package/dist/src/agent/external-tools/index.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
- package/dist/src/agent/memory/compaction.js +4 -0
- package/dist/src/agent/orchestration/agent-orchestrator.js +0 -21
- package/dist/src/agent/service/btw-query.js +8 -2
- package/dist/src/agent/service.js +3 -3
- package/dist/src/agent/skills/filesystem-watcher.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +4 -0
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
- package/dist/src/agent/tools/automation-tool.d.ts +4 -1
- package/dist/src/agent/tools/automation-tool.js +42 -4
- package/dist/src/agent/tools/session-search-tool.js +1 -1
- package/dist/src/agent/tools/web-extract.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +50 -9
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/ai-assist/text-assist.js +5 -1
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/api/routes.js +65 -0
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/read.js +24 -0
- package/dist/src/automations/capabilities/write.d.ts +69 -14
- package/dist/src/automations/capabilities/write.js +78 -5
- package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
- package/dist/src/automations/delivery/delivery-router.js +318 -0
- package/dist/src/automations/delivery/index.d.ts +1 -0
- package/dist/src/automations/delivery/index.js +2 -0
- package/dist/src/automations/domain/defaults.d.ts +0 -1
- package/dist/src/automations/domain/defaults.js +2 -2
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +180 -7
- package/dist/src/automations/domain/validation.d.ts +172 -22
- package/dist/src/automations/domain/validation.js +82 -13
- package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
- package/dist/src/automations/draft/automation-draft-service.js +6 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +31 -3
- package/dist/src/automations/draft/automation-draft-validator.js +5 -4
- package/dist/src/automations/events/event-catalog.d.ts +14 -0
- package/dist/src/automations/events/event-catalog.js +117 -0
- package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
- package/dist/src/automations/events/event-dispatcher.js +140 -0
- package/dist/src/automations/events/event-repository.d.ts +59 -0
- package/dist/src/automations/events/event-repository.js +361 -0
- package/dist/src/automations/events/index.d.ts +3 -0
- package/dist/src/automations/events/index.js +4 -0
- package/dist/src/automations/index.d.ts +3 -1
- package/dist/src/automations/index.js +9 -3
- package/dist/src/automations/service/action-executor.d.ts +20 -1
- package/dist/src/automations/service/action-executor.js +80 -24
- package/dist/src/automations/service/automation-service.d.ts +21 -4
- package/dist/src/automations/service/automation-service.js +150 -100
- package/dist/src/automations/storage/automation-repository.js +7 -7
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +26 -1
- package/dist/src/automations/storage/index.js +2 -2
- package/dist/src/automations/webhook-secrets.d.ts +1 -0
- package/dist/src/automations/webhook-secrets.js +16 -0
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/capabilities/store-connector.d.ts +17 -1
- package/dist/src/capabilities/store-connector.js +69 -3
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/connectors.js +4 -3
- package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/flow.js +5 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/config/schema.js +5 -1
- package/dist/src/connectors/approval-resume.js +1 -1
- package/dist/src/connectors/cli/store.js +1 -1
- package/dist/src/connectors/composio-backends.js +14 -4
- package/dist/src/connectors/composio-managed-events.d.ts +5 -2
- package/dist/src/connectors/composio-managed-events.js +4 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
- package/dist/src/connectors/connection-recovery-service.js +89 -4
- package/dist/src/discussions/analyzer.js +4 -4
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/home-intelligence-automation-reconciler.d.ts +3 -0
- package/dist/src/gateway/home-intelligence-automation-reconciler.js +52 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -4
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
- package/dist/src/gateway/hono/routes/home.js +0 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
- package/dist/src/gateway/hono/routes/scenes.js +57 -41
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +15 -0
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/update.js +6 -1
- package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
- package/dist/src/gateway/hono/routes/usage.js +61 -0
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +21 -15
- package/dist/src/gateway/scenes/host.js +27 -14
- package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/active-execution.d.ts +19 -0
- package/dist/src/gateway/service/active-execution.js +16 -0
- package/dist/src/gateway/service/agent-runner.d.ts +4 -0
- package/dist/src/gateway/service/agent-runner.js +19 -1
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
- package/dist/src/gateway/service/run-gateway-agent.js +9 -1
- package/dist/src/gateway/service/sessions-api.d.ts +13 -0
- package/dist/src/gateway/service/sessions-api.js +23 -0
- package/dist/src/gateway/service.d.ts +7 -3
- package/dist/src/gateway/service.js +108 -89
- package/dist/src/gateway/side-chat/run-service.js +10 -7
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +4 -1
- package/dist/src/home-intelligence/host.d.ts +1 -1
- package/dist/src/home-intelligence/host.js +2 -10
- package/dist/src/home-intelligence/notification.js +1 -1
- package/dist/src/home-intelligence/repository.d.ts +1 -1
- package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
- package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
- package/dist/src/infra/update-check.d.ts +8 -4
- package/dist/src/infra/update-check.js +43 -41
- package/dist/src/infra/update-startup.d.ts +7 -1
- package/dist/src/infra/update-startup.js +15 -6
- package/dist/src/local-apps/service.js +2 -2
- package/dist/src/memory-maintenance/index.js +2 -2
- package/dist/src/memory-maintenance/schedule.d.ts +0 -3
- package/dist/src/memory-maintenance/schedule.js +1 -8
- package/dist/src/notes/service.js +2 -3
- package/dist/src/projects/project-service.js +1 -2
- package/dist/src/projects/project-skill-service.js +2 -2
- package/dist/src/providers/model-call.d.ts +3 -2
- package/dist/src/providers/model-call.js +30 -5
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/scenes/activationAdapter.d.ts +19 -0
- package/dist/src/scenes/activationAdapter.js +1 -0
- package/dist/src/scenes/agentExecutor.js +3 -10
- package/dist/src/scenes/contracts.d.ts +3 -9
- package/dist/src/scenes/contracts.js +1 -0
- package/dist/src/scenes/execution.d.ts +9 -3
- package/dist/src/scenes/execution.js +12 -11
- package/dist/src/scenes/httpServices.d.ts +5 -2
- package/dist/src/scenes/mailContext.d.ts +4 -0
- package/dist/src/scenes/mailContext.js +9 -0
- package/dist/src/scenes/maintenance.js +1 -5
- package/dist/src/scenes/metrics.d.ts +0 -6
- package/dist/src/scenes/metrics.js +0 -11
- package/dist/src/scenes/registry.d.ts +11 -0
- package/dist/src/scenes/registry.js +28 -0
- package/dist/src/scenes/repository.d.ts +6 -3
- package/dist/src/scenes/repository.js +43 -5
- package/dist/src/scenes/service.d.ts +2 -1
- package/dist/src/scenes/service.js +9 -7
- package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
- package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
- package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
- package/dist/src/scenes/taskFollowUp/service.js +86 -28
- package/dist/src/scenes/templates.d.ts +2 -2
- package/dist/src/scenes/userNotes.d.ts +3 -0
- package/dist/src/scenes/userNotes.js +6 -0
- package/dist/src/session/client-history.d.ts +3 -0
- package/dist/src/session/client-history.js +10 -5
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/resolve-session.js +4 -3
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/session/store.js +3 -2
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
- package/dist/src/storage/sqlite/connector-repository.js +36 -34
- package/dist/src/storage/sqlite/index.d.ts +2 -2
- package/dist/src/storage/sqlite/index.js +3 -3
- package/dist/src/storage/sqlite/migrations/208_automation_management.sql +2 -0
- package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
- package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
- package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
- package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
- package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
- package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
- package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
- package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
- package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
- package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
- package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
- package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
- package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
- package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
- package/dist/src/storage/sqlite/row-mappers.js +6 -6
- package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
- package/dist/src/storage/sqlite/scenes-schema.js +0 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +0 -52
- package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
- package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
- package/dist/src/storage/sqlite/session-input-repository.js +18 -1
- package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-read-repository.js +0 -1
- package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
- package/dist/src/storage/sqlite/session-repository.js +8 -18
- package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
- package/dist/src/storage/sqlite/timestamps.js +20 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/transcript-repository.js +23 -15
- package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.d.ts +1 -1
- package/dist/src/tasks/home-query-service.js +4 -3
- package/dist/src/tasks/task-contract-planner.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/usage/cost.d.ts +4 -0
- package/dist/src/usage/cost.js +28 -0
- package/dist/src/usage/recorder.d.ts +13 -0
- package/dist/src/usage/recorder.js +117 -0
- package/dist/src/usage/scenario-registry.d.ts +8 -0
- package/dist/src/usage/scenario-registry.js +117 -0
- package/dist/src/usage/types.d.ts +55 -0
- package/dist/src/usage/types.js +1 -0
- package/dist/src/user-context/config.d.ts +9 -0
- package/dist/src/user-context/config.js +13 -4
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/tts/summarize.js +1 -1
- package/dist/src/work-discovery/analyzer.js +2 -2
- package/dist/src/work-discovery/investigator.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +15 -2
- package/package.json +6 -6
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DgP5DEJF.js +0 -1
- package/dist/gateway/static/root/assets/agents-Bh4XNLyk.js +0 -70
- package/dist/gateway/static/root/assets/automations-workspace-C7VS-yb7.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-CC43CC43.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DPETQOfF.js +0 -8
- package/dist/gateway/static/root/assets/channels-CwA619os.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-l7goF6QS.js +0 -2
- package/dist/gateway/static/root/assets/home-page-DSaXXoLm.js +0 -1
- package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
- package/dist/gateway/static/root/assets/index-D99vN3es.js +0 -121
- package/dist/gateway/static/root/assets/local-app-workbench-page-rH33N8I9.js +0 -1
- package/dist/gateway/static/root/assets/management-settings-RFDLaquR.js +0 -1
- package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-DI7CIjmM.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BkqnU-Jh.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-BvvcTH2F.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-DK316w9a.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-EIk8iJTK.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DcOsdz78.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BcaxGQLC.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Cb_CUL-U.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-Cvr1qUTW.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-VXfz3rE7.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DDNDLdId.js +0 -6
- package/dist/src/automations/product-events.d.ts +0 -5
- package/dist/src/automations/product-events.js +0 -19
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { AiUsageEvent, AiUsageFinish } from '../../usage/types.js';
|
|
2
|
+
export declare const AI_USAGE_RETENTION_MS: number;
|
|
3
|
+
export declare function insertAiUsageEvent(event: AiUsageEvent): void;
|
|
4
|
+
export declare function finishAiUsageEvent(id: string, finish: AiUsageFinish & {
|
|
5
|
+
estimatedCostMicrousd?: number;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function markStaleAiUsageEventsUnknown(cutoffMs: number, now?: number): number;
|
|
8
|
+
export declare function pruneAiUsageEvents(cutoffMs: number): number;
|
|
9
|
+
export declare function getAiUsageEvent(id: string): Record<string, unknown> | undefined;
|
|
10
|
+
export type AiUsageQuery = {
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
category?: string;
|
|
14
|
+
provider?: string;
|
|
15
|
+
model?: string;
|
|
16
|
+
agentId?: string;
|
|
17
|
+
conversationId?: string;
|
|
18
|
+
};
|
|
19
|
+
export type AiUsageTotals = {
|
|
20
|
+
calls: number;
|
|
21
|
+
succeededCalls: number;
|
|
22
|
+
failedCalls: number;
|
|
23
|
+
unknownCostCalls: number;
|
|
24
|
+
inputTokens: number;
|
|
25
|
+
outputTokens: number;
|
|
26
|
+
cacheReadTokens: number;
|
|
27
|
+
cacheWriteTokens: number;
|
|
28
|
+
totalTokens: number;
|
|
29
|
+
knownCostUsd: string;
|
|
30
|
+
costCompleteness: 'complete' | 'partial' | 'unknown';
|
|
31
|
+
};
|
|
32
|
+
export declare function summarizeAiUsage(query: AiUsageQuery): {
|
|
33
|
+
totals: AiUsageTotals;
|
|
34
|
+
byCategory: Array<{
|
|
35
|
+
key: string;
|
|
36
|
+
totals: AiUsageTotals;
|
|
37
|
+
}>;
|
|
38
|
+
byModel: Array<{
|
|
39
|
+
key: string;
|
|
40
|
+
provider: string;
|
|
41
|
+
model: string;
|
|
42
|
+
totals: AiUsageTotals;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
export declare function listAiUsageEvents(query: AiUsageQuery & {
|
|
46
|
+
limit?: number;
|
|
47
|
+
before?: {
|
|
48
|
+
startedAt: number;
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
}): {
|
|
52
|
+
items: {
|
|
53
|
+
id: string;
|
|
54
|
+
traceId: string;
|
|
55
|
+
parentEventId: string;
|
|
56
|
+
conversationId: string;
|
|
57
|
+
runId: string;
|
|
58
|
+
agentId: string;
|
|
59
|
+
category: string;
|
|
60
|
+
operation: string;
|
|
61
|
+
trigger: string;
|
|
62
|
+
reasonKey: string;
|
|
63
|
+
provider: string;
|
|
64
|
+
model: string;
|
|
65
|
+
status: string;
|
|
66
|
+
startedAt: number;
|
|
67
|
+
finishedAt: number;
|
|
68
|
+
durationMs: number;
|
|
69
|
+
inputTokens: number;
|
|
70
|
+
outputTokens: number;
|
|
71
|
+
cacheReadTokens: number;
|
|
72
|
+
cacheWriteTokens: number;
|
|
73
|
+
reasoningTokens: number;
|
|
74
|
+
totalTokens: number;
|
|
75
|
+
estimatedCostUsd: string;
|
|
76
|
+
costSource: string;
|
|
77
|
+
pricingSnapshot: Record<string, number>;
|
|
78
|
+
errorSummary: string;
|
|
79
|
+
}[];
|
|
80
|
+
nextCursor: string;
|
|
81
|
+
};
|
|
82
|
+
export declare function getAiUsageEventView(id: string): {
|
|
83
|
+
id: string;
|
|
84
|
+
traceId: string;
|
|
85
|
+
parentEventId: string;
|
|
86
|
+
conversationId: string;
|
|
87
|
+
runId: string;
|
|
88
|
+
agentId: string;
|
|
89
|
+
category: string;
|
|
90
|
+
operation: string;
|
|
91
|
+
trigger: string;
|
|
92
|
+
reasonKey: string;
|
|
93
|
+
provider: string;
|
|
94
|
+
model: string;
|
|
95
|
+
status: string;
|
|
96
|
+
startedAt: number;
|
|
97
|
+
finishedAt: number;
|
|
98
|
+
durationMs: number;
|
|
99
|
+
inputTokens: number;
|
|
100
|
+
outputTokens: number;
|
|
101
|
+
cacheReadTokens: number;
|
|
102
|
+
cacheWriteTokens: number;
|
|
103
|
+
reasoningTokens: number;
|
|
104
|
+
totalTokens: number;
|
|
105
|
+
estimatedCostUsd: string;
|
|
106
|
+
costSource: string;
|
|
107
|
+
pricingSnapshot: Record<string, number>;
|
|
108
|
+
errorSummary: string;
|
|
109
|
+
};
|
|
110
|
+
export declare function listAiUsageTrace(traceId: string): {
|
|
111
|
+
id: string;
|
|
112
|
+
traceId: string;
|
|
113
|
+
parentEventId: string;
|
|
114
|
+
conversationId: string;
|
|
115
|
+
runId: string;
|
|
116
|
+
agentId: string;
|
|
117
|
+
category: string;
|
|
118
|
+
operation: string;
|
|
119
|
+
trigger: string;
|
|
120
|
+
reasonKey: string;
|
|
121
|
+
provider: string;
|
|
122
|
+
model: string;
|
|
123
|
+
status: string;
|
|
124
|
+
startedAt: number;
|
|
125
|
+
finishedAt: number;
|
|
126
|
+
durationMs: number;
|
|
127
|
+
inputTokens: number;
|
|
128
|
+
outputTokens: number;
|
|
129
|
+
cacheReadTokens: number;
|
|
130
|
+
cacheWriteTokens: number;
|
|
131
|
+
reasoningTokens: number;
|
|
132
|
+
totalTokens: number;
|
|
133
|
+
estimatedCostUsd: string;
|
|
134
|
+
costSource: string;
|
|
135
|
+
pricingSnapshot: Record<string, number>;
|
|
136
|
+
errorSummary: string;
|
|
137
|
+
}[];
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
+
//#region src/storage/sqlite/ai-usage-repository.ts
|
|
3
|
+
init_transaction();
|
|
4
|
+
const ERROR_SUMMARY_LIMIT = 512;
|
|
5
|
+
const AI_USAGE_RETENTION_MS = 4320 * 60 * 60 * 1e3;
|
|
6
|
+
function boundedError(value) {
|
|
7
|
+
if (!value) return void 0;
|
|
8
|
+
return value.replace(/Bearer\s+[A-Za-z0-9._~+/-]+/gi, "Bearer [REDACTED]").replace(/(api[_-]?key|token|secret)\s*[=:]\s*[^\s,;]+/gi, "$1=[REDACTED]").slice(0, ERROR_SUMMARY_LIMIT);
|
|
9
|
+
}
|
|
10
|
+
function insertAiUsageEvent(event) {
|
|
11
|
+
runSqliteWriteTransaction((db) => {
|
|
12
|
+
db.prepare(`INSERT INTO ai_usage_events (
|
|
13
|
+
id, trace_id, parent_event_id, conversation_id, run_id, agent_id,
|
|
14
|
+
category, operation, trigger_kind, reason_key, provider, model, status,
|
|
15
|
+
started_at, finished_at, duration_ms, input_tokens, output_tokens,
|
|
16
|
+
cache_read_tokens, cache_write_tokens, reasoning_tokens, total_tokens,
|
|
17
|
+
estimated_cost_microusd, cost_source, pricing_snapshot_json, error_summary,
|
|
18
|
+
created_at, updated_at
|
|
19
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(event.id, event.traceId, event.parentEventId ?? null, event.conversationId ?? null, event.runId ?? null, event.agentId ?? null, event.category, event.operation, event.trigger, event.reasonKey, event.provider, event.model, event.status, event.startedAt, event.finishedAt ?? null, event.durationMs ?? null, event.inputTokens ?? null, event.outputTokens ?? null, event.cacheReadTokens ?? null, event.cacheWriteTokens ?? null, event.reasoningTokens ?? null, event.totalTokens ?? null, event.estimatedCostMicrousd ?? null, event.costSource, event.pricingSnapshot ? JSON.stringify(event.pricingSnapshot) : null, boundedError(event.errorSummary) ?? null, event.startedAt, event.startedAt);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function finishAiUsageEvent(id, finish) {
|
|
23
|
+
const finishedAt = finish.finishedAt ?? Date.now();
|
|
24
|
+
const usage = finish.usage;
|
|
25
|
+
runSqliteWriteTransaction((db) => {
|
|
26
|
+
db.prepare(`UPDATE ai_usage_events SET
|
|
27
|
+
status = ?, finished_at = ?, duration_ms = MAX(0, ? - started_at),
|
|
28
|
+
input_tokens = ?, output_tokens = ?, cache_read_tokens = ?, cache_write_tokens = ?,
|
|
29
|
+
reasoning_tokens = ?, total_tokens = ?, estimated_cost_microusd = ?,
|
|
30
|
+
error_summary = ?, updated_at = ?
|
|
31
|
+
WHERE id = ? AND status = 'running'`).run(finish.status, finishedAt, finishedAt, usage?.input ?? null, usage?.output ?? null, usage?.cacheRead ?? null, usage?.cacheWrite ?? null, usage?.reasoning ?? null, usage?.totalTokens ?? null, finish.estimatedCostMicrousd ?? null, boundedError(finish.errorSummary) ?? null, finishedAt, id);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function markStaleAiUsageEventsUnknown(cutoffMs, now = Date.now()) {
|
|
35
|
+
return runSqliteWriteTransaction((db) => Number(db.prepare(`UPDATE ai_usage_events
|
|
36
|
+
SET status = 'unknown', finished_at = ?, duration_ms = MAX(0, ? - started_at), updated_at = ?
|
|
37
|
+
WHERE status = 'running' AND started_at < ?`).run(now, now, now, cutoffMs).changes));
|
|
38
|
+
}
|
|
39
|
+
function pruneAiUsageEvents(cutoffMs) {
|
|
40
|
+
return runSqliteWriteTransaction((db) => Number(db.prepare(`DELETE FROM ai_usage_events
|
|
41
|
+
WHERE status <> 'running' AND started_at < ?`).run(cutoffMs).changes));
|
|
42
|
+
}
|
|
43
|
+
function getAiUsageEvent(id) {
|
|
44
|
+
return getSqliteDatabase().prepare("SELECT * FROM ai_usage_events WHERE id = ?").get(id);
|
|
45
|
+
}
|
|
46
|
+
function queryWhere(query) {
|
|
47
|
+
const clauses = ["started_at >= ?", "started_at < ?"];
|
|
48
|
+
const values = [query.from, query.to];
|
|
49
|
+
for (const [key, column] of [
|
|
50
|
+
["category", "category"],
|
|
51
|
+
["provider", "provider"],
|
|
52
|
+
["model", "model"],
|
|
53
|
+
["agentId", "agent_id"],
|
|
54
|
+
["conversationId", "conversation_id"]
|
|
55
|
+
]) {
|
|
56
|
+
const value = query[key];
|
|
57
|
+
if (typeof value === "string" && value) {
|
|
58
|
+
clauses.push(`${column} = ?`);
|
|
59
|
+
values.push(value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
sql: clauses.join(" AND "),
|
|
64
|
+
values
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function usd(microusd) {
|
|
68
|
+
return (microusd / 1e6).toFixed(6).replace(/0+$/, "").replace(/\.$/, "") || "0";
|
|
69
|
+
}
|
|
70
|
+
function totalsFromRow(row) {
|
|
71
|
+
const calls = Number(row.calls ?? 0);
|
|
72
|
+
const unknownCostCalls = Number(row.unknown_cost_calls ?? 0);
|
|
73
|
+
return {
|
|
74
|
+
calls,
|
|
75
|
+
succeededCalls: Number(row.succeeded_calls ?? 0),
|
|
76
|
+
failedCalls: Number(row.failed_calls ?? 0),
|
|
77
|
+
unknownCostCalls,
|
|
78
|
+
inputTokens: Number(row.input_tokens ?? 0),
|
|
79
|
+
outputTokens: Number(row.output_tokens ?? 0),
|
|
80
|
+
cacheReadTokens: Number(row.cache_read_tokens ?? 0),
|
|
81
|
+
cacheWriteTokens: Number(row.cache_write_tokens ?? 0),
|
|
82
|
+
totalTokens: Number(row.total_tokens ?? 0),
|
|
83
|
+
knownCostUsd: usd(Number(row.known_cost_microusd ?? 0)),
|
|
84
|
+
costCompleteness: calls === 0 || unknownCostCalls === calls ? "unknown" : unknownCostCalls > 0 ? "partial" : "complete"
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const TOTALS_SQL = `COUNT(*) AS calls,
|
|
88
|
+
SUM(CASE WHEN status = 'succeeded' THEN 1 ELSE 0 END) AS succeeded_calls,
|
|
89
|
+
SUM(CASE WHEN status IN ('failed', 'aborted', 'unknown') THEN 1 ELSE 0 END) AS failed_calls,
|
|
90
|
+
SUM(CASE WHEN cost_source <> 'local' AND estimated_cost_microusd IS NULL THEN 1 ELSE 0 END) AS unknown_cost_calls,
|
|
91
|
+
COALESCE(SUM(input_tokens), 0) AS input_tokens,
|
|
92
|
+
COALESCE(SUM(output_tokens), 0) AS output_tokens,
|
|
93
|
+
COALESCE(SUM(cache_read_tokens), 0) AS cache_read_tokens,
|
|
94
|
+
COALESCE(SUM(cache_write_tokens), 0) AS cache_write_tokens,
|
|
95
|
+
COALESCE(SUM(total_tokens), 0) AS total_tokens,
|
|
96
|
+
COALESCE(SUM(estimated_cost_microusd), 0) AS known_cost_microusd`;
|
|
97
|
+
function summarizeAiUsage(query) {
|
|
98
|
+
const { sql, values } = queryWhere(query);
|
|
99
|
+
const db = getSqliteDatabase();
|
|
100
|
+
return {
|
|
101
|
+
totals: totalsFromRow(db.prepare(`SELECT ${TOTALS_SQL} FROM ai_usage_events WHERE ${sql}`).get(...values)),
|
|
102
|
+
byCategory: db.prepare(`SELECT category AS key, ${TOTALS_SQL} FROM ai_usage_events
|
|
103
|
+
WHERE ${sql} GROUP BY category ORDER BY known_cost_microusd DESC, calls DESC`).all(...values).map((row) => ({
|
|
104
|
+
key: String(row.key),
|
|
105
|
+
totals: totalsFromRow(row)
|
|
106
|
+
})),
|
|
107
|
+
byModel: db.prepare(`SELECT provider || '/' || model AS key, provider, model, ${TOTALS_SQL}
|
|
108
|
+
FROM ai_usage_events WHERE ${sql} GROUP BY provider, model
|
|
109
|
+
ORDER BY known_cost_microusd DESC, calls DESC`).all(...values).map((row) => ({
|
|
110
|
+
key: String(row.key),
|
|
111
|
+
provider: String(row.provider),
|
|
112
|
+
model: String(row.model),
|
|
113
|
+
totals: totalsFromRow(row)
|
|
114
|
+
}))
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function eventFromRow(row) {
|
|
118
|
+
const pricingSnapshot = typeof row.pricing_snapshot_json === "string" ? JSON.parse(row.pricing_snapshot_json) : void 0;
|
|
119
|
+
return {
|
|
120
|
+
id: String(row.id),
|
|
121
|
+
traceId: String(row.trace_id),
|
|
122
|
+
parentEventId: row.parent_event_id ? String(row.parent_event_id) : void 0,
|
|
123
|
+
conversationId: row.conversation_id ? String(row.conversation_id) : void 0,
|
|
124
|
+
runId: row.run_id ? String(row.run_id) : void 0,
|
|
125
|
+
agentId: row.agent_id ? String(row.agent_id) : void 0,
|
|
126
|
+
category: String(row.category),
|
|
127
|
+
operation: String(row.operation),
|
|
128
|
+
trigger: String(row.trigger_kind),
|
|
129
|
+
reasonKey: String(row.reason_key),
|
|
130
|
+
provider: String(row.provider),
|
|
131
|
+
model: String(row.model),
|
|
132
|
+
status: String(row.status),
|
|
133
|
+
startedAt: Number(row.started_at),
|
|
134
|
+
finishedAt: row.finished_at === null ? void 0 : Number(row.finished_at),
|
|
135
|
+
durationMs: row.duration_ms === null ? void 0 : Number(row.duration_ms),
|
|
136
|
+
inputTokens: row.input_tokens === null ? void 0 : Number(row.input_tokens),
|
|
137
|
+
outputTokens: row.output_tokens === null ? void 0 : Number(row.output_tokens),
|
|
138
|
+
cacheReadTokens: row.cache_read_tokens === null ? void 0 : Number(row.cache_read_tokens),
|
|
139
|
+
cacheWriteTokens: row.cache_write_tokens === null ? void 0 : Number(row.cache_write_tokens),
|
|
140
|
+
reasoningTokens: row.reasoning_tokens === null ? void 0 : Number(row.reasoning_tokens),
|
|
141
|
+
totalTokens: row.total_tokens === null ? void 0 : Number(row.total_tokens),
|
|
142
|
+
estimatedCostUsd: row.estimated_cost_microusd === null ? void 0 : usd(Number(row.estimated_cost_microusd)),
|
|
143
|
+
costSource: String(row.cost_source),
|
|
144
|
+
pricingSnapshot,
|
|
145
|
+
errorSummary: row.error_summary ? String(row.error_summary) : void 0
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function listAiUsageEvents(query) {
|
|
149
|
+
const { sql, values } = queryWhere(query);
|
|
150
|
+
const clauses = [sql];
|
|
151
|
+
if (query.before) {
|
|
152
|
+
clauses.push("(started_at < ? OR (started_at = ? AND id < ?))");
|
|
153
|
+
values.push(query.before.startedAt, query.before.startedAt, query.before.id);
|
|
154
|
+
}
|
|
155
|
+
const limit = Math.min(200, Math.max(1, query.limit ?? 50));
|
|
156
|
+
const rows = getSqliteDatabase().prepare(`SELECT * FROM ai_usage_events WHERE ${clauses.join(" AND ")}
|
|
157
|
+
ORDER BY started_at DESC, id DESC LIMIT ?`).all(...values, limit + 1);
|
|
158
|
+
const hasMore = rows.length > limit;
|
|
159
|
+
const items = rows.slice(0, limit).map(eventFromRow);
|
|
160
|
+
const last = items.at(-1);
|
|
161
|
+
return {
|
|
162
|
+
items,
|
|
163
|
+
nextCursor: hasMore && last ? `${last.startedAt}:${last.id}` : void 0
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function getAiUsageEventView(id) {
|
|
167
|
+
const row = getAiUsageEvent(id);
|
|
168
|
+
return row ? eventFromRow(row) : void 0;
|
|
169
|
+
}
|
|
170
|
+
function listAiUsageTrace(traceId) {
|
|
171
|
+
return getSqliteDatabase().prepare(`SELECT * FROM ai_usage_events WHERE trace_id = ?
|
|
172
|
+
ORDER BY started_at ASC, id ASC`).all(traceId).map(eventFromRow);
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
export { AI_USAGE_RETENTION_MS, finishAiUsageEvent, getAiUsageEvent, getAiUsageEventView, insertAiUsageEvent, listAiUsageEvents, listAiUsageTrace, markStaleAiUsageEventsUnknown, pruneAiUsageEvents, summarizeAiUsage };
|
|
@@ -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, timestampToIso } from "./timestamps.js";
|
|
3
4
|
//#region src/storage/sqlite/connector-account-repository.ts
|
|
4
5
|
function parseIdentity(value) {
|
|
5
6
|
try {
|
|
@@ -22,8 +23,8 @@ function fromRow(row) {
|
|
|
22
23
|
label: row.label ?? void 0,
|
|
23
24
|
enabled: row.enabled === 1,
|
|
24
25
|
allowedAgentIds: row.allowed_agent_ids_json === null ? null : JSON.parse(row.allowed_agent_ids_json),
|
|
25
|
-
createdAt: row.created_at,
|
|
26
|
-
updatedAt: row.updated_at
|
|
26
|
+
createdAt: timestampToIso(row.created_at),
|
|
27
|
+
updatedAt: timestampToIso(row.updated_at)
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
function mergeAccountSourceData(db, connectorId, sourceAccountId, targetAccountId) {
|
|
@@ -83,7 +84,7 @@ function updateConnectorAccount(id, patch) {
|
|
|
83
84
|
const account = getConnectorAccount(id);
|
|
84
85
|
if (!account) throw new Error("Connector account not found.");
|
|
85
86
|
getSqliteDatabase().prepare(`UPDATE connector_accounts
|
|
86
|
-
SET label = ?, enabled = ?, allowed_agent_ids_json = ?, updated_at = ? WHERE id = ?`).run(patch.label === void 0 ? account.label ?? null : patch.label.trim() || null, patch.enabled ?? account.enabled ? 1 : 0, patch.allowedAgentIds === void 0 ? account.allowedAgentIds === null ? null : JSON.stringify(account.allowedAgentIds) : patch.allowedAgentIds === null ? null : JSON.stringify([...new Set(patch.allowedAgentIds)]),
|
|
87
|
+
SET label = ?, enabled = ?, allowed_agent_ids_json = ?, updated_at = ? WHERE id = ?`).run(patch.label === void 0 ? account.label ?? null : patch.label.trim() || null, patch.enabled ?? account.enabled ? 1 : 0, patch.allowedAgentIds === void 0 ? account.allowedAgentIds === null ? null : JSON.stringify(account.allowedAgentIds) : patch.allowedAgentIds === null ? null : JSON.stringify([...new Set(patch.allowedAgentIds)]), Date.now(), id);
|
|
87
88
|
return getConnectorAccount(id);
|
|
88
89
|
}
|
|
89
90
|
function listConnectorAccounts(options = {}) {
|
|
@@ -101,7 +102,7 @@ function listConnectorAccounts(options = {}) {
|
|
|
101
102
|
return getSqliteDatabase().prepare(`SELECT * FROM connector_accounts${where} ORDER BY updated_at DESC`).all(...values).map(fromRow);
|
|
102
103
|
}
|
|
103
104
|
function refreshConnectorAccountCurrent(accountId) {
|
|
104
|
-
const now =
|
|
105
|
+
const now = Date.now();
|
|
105
106
|
runSqliteWriteTransaction((db) => {
|
|
106
107
|
const primary = db.prepare(`
|
|
107
108
|
SELECT id FROM connector_connections
|
|
@@ -119,7 +120,7 @@ function refreshConnectorAccountCurrent(accountId) {
|
|
|
119
120
|
return getConnectorAccount(accountId);
|
|
120
121
|
}
|
|
121
122
|
function reconcileConnectorAccount(input) {
|
|
122
|
-
const now =
|
|
123
|
+
const now = Date.now();
|
|
123
124
|
return getConnectorAccount(runSqliteWriteTransaction((db) => {
|
|
124
125
|
const connection = db.prepare(`SELECT c.account_id, c.connector_id, c.principal_id, a.backend_id FROM connector_connections c
|
|
125
126
|
JOIN connector_accounts a ON a.id = c.account_id WHERE c.id = ?`).get(input.connectionId);
|
|
@@ -165,6 +166,7 @@ function reconcileConnectorAccount(input) {
|
|
|
165
166
|
}));
|
|
166
167
|
}
|
|
167
168
|
var init_connector_account_repository = __esmMin((() => {
|
|
169
|
+
init_timestamps();
|
|
168
170
|
init_transaction();
|
|
169
171
|
}));
|
|
170
172
|
//#endregion
|
|
@@ -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';
|