@xopcai/xopc 0.0.332 → 0.0.334
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/dist/assets/{auth-DocRzRlS.js → auth-Cjj5SuoT.js} +49 -39
- package/dist/browser-ext/dist/background.js +1 -1
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +240 -36
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C2wg3xC_.js → agent-avatar-dicebear-B73q7mlz.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-B9L2YIXz.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BeNnu1Ts.js → agent-plugin-dialog-COOjsvea.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CCj1JnLu.js +70 -0
- package/dist/gateway/static/root/assets/agents-admin-api-Cuqi5xZn.js +2 -0
- package/dist/gateway/static/root/assets/{app-link-C6gA5Nck.js → app-link-DRL0YnPs.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-etFSkfzl.js → app-management-settings-panel-CckioKud.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DKmU2VAP.js → appearance-settings-DDiPIr_Q.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-Azqy8vfo.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-D0z_Fr2G.js → archive-plugin-Dtyr0RhX.js} +1 -1
- package/dist/gateway/static/root/assets/attachment-load-qjPpQzYY.js +1 -0
- package/dist/gateway/static/root/assets/attachment-utils-core-BIOUBrpT.js +1 -0
- package/dist/gateway/static/root/assets/{automations-page-B7_C-p66.js → automations-page-g3SrFkTC.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-B0nW2nZD.js +7 -0
- package/dist/gateway/static/root/assets/binary-plugins-BwKQVxsU.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-ChWW8Z9L.js → block-editor-DD9d5pCt.js} +29 -29
- package/dist/gateway/static/root/assets/{browser-automation-inputs-C5s1yHOu.js → browser-automation-inputs-D2gNdS3e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BV00BXRb.js → browser-automations-page-BKqqJR7P.js} +2 -2
- package/dist/gateway/static/root/assets/{browser-settings-page-xwTmuZjS.js → browser-settings-page-BZH9bZbk.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-CHk4RZl4.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-CfWaVH-6.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C5FcWsSe.js +8 -0
- package/dist/gateway/static/root/assets/capability-header-actions-Bd66yEOa.js +1 -0
- package/dist/gateway/static/root/assets/channels-DIU5Gq4o.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C41mXCAi.js → chat-terminal-dock-B0nPDJyj.js} +2 -2
- package/dist/gateway/static/root/assets/{computer-settings-page-BJkqok2G.js → computer-settings-page-D7PxxaoG.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BKCZMmwm.js → connector-service-page-BZH4SeQg.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BC81R_fz.js +2 -0
- package/dist/gateway/static/root/assets/{turn-outcome-D0SnyZ3Z.js → constants-Co2_smKQ.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-CDEVYjXI.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-CqADAHZp.js → dependency-picker-AInmpSwC.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bab-iWED.js → desktop-pet-Sjgnlq8M.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BqgzLOdi.js → desktop-pet-settings-BWn0rrhr.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DFg7FDPf.js → device-pairing-wizard-BtW837_d.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-hqJ9sFCR.js → directory-picker-path-field-2CpmDx_D.js} +1 -1
- package/dist/gateway/static/root/assets/dist-CKkafhaS.js +1 -0
- package/dist/gateway/static/root/assets/dist-io9jFpN72.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DX3PFhRE.js → extension-debug-page-WWJFj9Z5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DkREdHLs.js → extension-page-DL00dFRr.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-wF-HNTM-.js → extension-settings-page-CN-agjPk.js} +1 -1
- package/dist/gateway/static/root/assets/{files-BK6enEvD.js → files-Bw4SBGdM.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-cR-tz7-Q.js → gateway-config-swr-CgIjCxM8.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-Ciq4c7KT.js +1 -0
- package/dist/gateway/static/root/assets/gateway-realtime-store-BHeHN26R.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-4oD6fhAm.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-6jLRcQsu.js → gateway-startup-retry-i-1lTrwY.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-nEpyJUBY.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-CSSkwsyC.js → image-generation-api-gilc-u7M.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-B80Cv043.js → imports-page-BivdeiQ5.js} +1 -1
- package/dist/gateway/static/root/assets/index-BioG1pRD.js +106 -0
- package/dist/gateway/static/root/assets/index-DbLEkdNg.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BgoFaTwv.js → keyboard-shortcuts-settings-B_8AJTFr.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CRtZQrmz.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-HO6OQlQT.js → local-apps-page-DclxpoqR.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-Bpja8nC6.js → local-apps-yys1VChX.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-DkolHmyp.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-wNXWkWu5.js → locale-store-BY30D6tg.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DX8TxkRl.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-5WFufZ4g.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DlT9KqwF.js → markdown-view-DYJnwlDr.js} +1 -1
- package/dist/gateway/static/root/assets/media-plugins-DlJDvwLK.js +1 -0
- package/dist/gateway/static/root/assets/messages-_6IXbP2u.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-GF5Q9Fqy.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-E8o4_Ty9.js +8 -0
- package/dist/gateway/static/root/assets/page-context-capture-button-CiCmfRTw.js +1 -0
- package/dist/gateway/static/root/assets/{page-tabs-vqI30Yrg.js → page-tabs-Cwp3fGVM.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-0p9PIHRy.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B-mwPBJW.js → preview-open-alternatives-DJ5xqGeu.js} +1 -1
- package/dist/gateway/static/root/assets/{product-delivery-bv3z8Xkh.js → product-delivery-BAks11S4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-D--sj_uN.js → product-open-page-CcGwNePw.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-6hhRBkmC.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DUOzRaFI.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BIpltJ47.js → registry-api-BvVx0G1o.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BWpWUXiE.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CAnb0PNY.js → runtime-tools-settings-panel-C6eDCNHz.js} +2 -2
- package/dist/gateway/static/root/assets/scenes-page-pF7Lmqnk.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-BKj6wIMb.js → schema-form-D8W8q_ez.js} +1 -1
- package/dist/gateway/static/root/assets/{schemas-88fK3zzl.js → schemas-CObaziC7.js} +3 -3
- package/dist/gateway/static/root/assets/session-api-BAyUr97V.js +1 -0
- package/dist/gateway/static/root/assets/session-manager-BAy2sR2Q.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-BDKDqqf9.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C9cJWlAq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-78ycUHfv.js → settings-form-section-B0cAj0nq.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BOdxIVzo.js → settings-page-DZVVTFxs.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DZCPVx9c.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-BkPNyV8c.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-Bqlv5JBi.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-CiBGQ0Jg.js → skill-api-C0dufzQC.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-3JF2OTBz.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DB4lR4om.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CyJUeREH.js → system-settings-panel-xjrlhdUz.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CB6M7wSs.js +1 -0
- package/dist/gateway/static/root/assets/{tasks-CDR_RVbQ.js → tasks-QQJXsiER.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Day9zhKi.js → tunnel-api--68MQEWM.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-OLZ00eqD.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-Bj9hC6ML.js → use-autosave-DsnHYpTv.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CoePFpHD.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-fWRD6B8r.js → voice-api-key-field-CvIXutQp.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-ujEySjyc.js → voice-config-api-Bwy3Al3J.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CnxdvIk8.js → work-discovery-overlay-By5_7MLR.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DlWNN1VA.js → workflow-run-setup-panel-HSMDxDXV.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DElQ47Da.js +6 -0
- package/dist/gateway/static/root/index.html +27 -21
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +44 -14
- package/dist/packages/gateway-contract/src/capabilities.js +120 -10
- package/dist/packages/gateway-contract/src/index.js +8 -2
- package/dist/packages/gateway-contract/src/scenes.js +7 -6
- package/dist/packages/gateway-contract/src/session-command-rejection.js +19 -0
- package/dist/packages/gateway-contract/src/session-input-command.js +109 -0
- package/dist/packages/gateway-contract/src/sessions.js +2 -7
- package/dist/packages/gateway-contract/src/usage.js +6 -0
- package/dist/src/agent/agent-manager.js +15 -9
- package/dist/src/agent/background-review/run-background-review.js +8 -3
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +7 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/external-tools/gateway-tools.d.ts +2 -1
- package/dist/src/agent/external-tools/gateway-tools.js +45 -11
- package/dist/src/agent/external-tools/index.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
- package/dist/src/agent/memory/compaction.js +4 -0
- package/dist/src/agent/service/btw-query.js +8 -2
- package/dist/src/agent/service/process-direct-streaming.js +4 -2
- package/dist/src/agent/service.js +5 -5
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/filesystem-watcher.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +2 -2
- package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +7 -3
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +5 -4
- package/dist/src/agent/tools/automation-tool.d.ts +4 -1
- package/dist/src/agent/tools/automation-tool.js +42 -4
- package/dist/src/agent/tools/session-search-tool.js +1 -1
- package/dist/src/agent/tools/web-extract.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +50 -9
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/ai-assist/text-assist.js +6 -2
- package/dist/src/auth/credentials.js +1 -1
- package/dist/src/auth/oauth-provider-lock.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/automations/api/routes.js +65 -0
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/read.js +24 -0
- package/dist/src/automations/capabilities/write.d.ts +52 -14
- package/dist/src/automations/capabilities/write.js +52 -3
- package/dist/src/automations/delivery/delivery-router.d.ts +50 -0
- package/dist/src/automations/delivery/delivery-router.js +318 -0
- package/dist/src/automations/delivery/index.d.ts +1 -0
- package/dist/src/automations/delivery/index.js +2 -0
- package/dist/src/automations/domain/defaults.d.ts +0 -1
- package/dist/src/automations/domain/defaults.js +1 -1
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +158 -7
- package/dist/src/automations/domain/validation.d.ts +104 -22
- package/dist/src/automations/domain/validation.js +66 -13
- package/dist/src/automations/draft/automation-draft-prompt.js +3 -4
- package/dist/src/automations/draft/automation-draft-service.js +6 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +22 -3
- package/dist/src/automations/draft/automation-draft-validator.js +4 -4
- package/dist/src/automations/events/event-catalog.d.ts +14 -0
- package/dist/src/automations/events/event-catalog.js +117 -0
- package/dist/src/automations/events/event-dispatcher.d.ts +27 -0
- package/dist/src/automations/events/event-dispatcher.js +140 -0
- package/dist/src/automations/events/event-repository.d.ts +59 -0
- package/dist/src/automations/events/event-repository.js +361 -0
- package/dist/src/automations/events/index.d.ts +3 -0
- package/dist/src/automations/events/index.js +4 -0
- package/dist/src/automations/index.d.ts +3 -1
- package/dist/src/automations/index.js +9 -3
- package/dist/src/automations/service/action-executor.d.ts +20 -1
- package/dist/src/automations/service/action-executor.js +80 -40
- package/dist/src/automations/service/automation-service.d.ts +21 -4
- package/dist/src/automations/service/automation-service.js +150 -100
- package/dist/src/automations/storage/automation-repository.js +4 -5
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +26 -1
- package/dist/src/automations/storage/index.js +2 -2
- package/dist/src/automations/webhook-secrets.d.ts +1 -0
- package/dist/src/automations/webhook-secrets.js +16 -0
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/capabilities/store-connector.d.ts +17 -1
- package/dist/src/capabilities/store-connector.js +69 -3
- package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/chat-commands/builtins/config.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/connectors.js +4 -3
- package/dist/src/cli/commands/doctor/checks/automation-integrity.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/automation-integrity.js +55 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.d.ts +2 -0
- package/dist/src/cli/commands/doctor/checks/database-relations.js +81 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +2 -2
- package/dist/src/cli/commands/doctor/flow.js +5 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.js +1 -1
- package/dist/src/connectors/approval-resume.js +1 -1
- package/dist/src/connectors/cli/authorization.d.ts +1 -1
- package/dist/src/connectors/cli/store.d.ts +1 -1
- package/dist/src/connectors/cli/store.js +1 -1
- package/dist/src/connectors/composio-backends.js +14 -4
- package/dist/src/connectors/composio-managed-events.d.ts +5 -2
- package/dist/src/connectors/composio-managed-events.js +4 -1
- package/dist/src/connectors/connection-candidates.js +53 -15
- package/dist/src/connectors/connection-capabilities.js +5 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +2 -1
- package/dist/src/connectors/connection-recovery-service.js +89 -4
- package/dist/src/discussions/analyzer.js +4 -4
- package/dist/src/execution-environments/local-worktree-manager.js +10 -1
- package/dist/src/execution-environments/session-environment-service.d.ts +3 -0
- package/dist/src/execution-environments/session-environment-service.js +28 -4
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/home-intelligence-automation-reconciler.js +4 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +6 -2
- package/dist/src/gateway/hono/routes/browser-session.js +4 -2
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +9 -2
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -2
- package/dist/src/gateway/hono/routes/files.js +3 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
- package/dist/src/gateway/hono/routes/models.js +17 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -4
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/public-gateway.js +93 -3
- package/dist/src/gateway/hono/routes/scenes.js +57 -41
- package/dist/src/gateway/hono/routes/session-command-handler.d.ts +5 -0
- package/dist/src/gateway/hono/routes/session-command-handler.js +189 -0
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +14 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +2 -2
- package/dist/src/gateway/hono/routes/sessions.js +15 -168
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/tui.js +2 -1
- package/dist/src/gateway/hono/routes/usage.d.ts +3 -0
- package/dist/src/gateway/hono/routes/usage.js +61 -0
- package/dist/src/gateway/hono/routes/voice.js +10 -1
- package/dist/src/gateway/image-generation-setup.js +2 -2
- package/dist/src/gateway/lock.js +1 -1
- package/dist/src/gateway/memory-maintenance-automation-reconciler.js +5 -2
- package/dist/src/gateway/resolve-webchat-session-key.d.ts +1 -1
- package/dist/src/gateway/resolve-webchat-session-key.js +2 -2
- package/dist/src/gateway/scenes/host.js +27 -14
- package/dist/src/gateway/scenes/slackThreadSource.d.ts +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/active-execution.d.ts +19 -0
- package/dist/src/gateway/service/active-execution.js +16 -0
- package/dist/src/gateway/service/agent-runner.d.ts +4 -0
- package/dist/src/gateway/service/agent-runner.js +19 -1
- package/dist/src/gateway/service/marketplace-service.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
- package/dist/src/gateway/service/run-gateway-agent.js +10 -2
- package/dist/src/gateway/service/session-command-service.d.ts +34 -0
- package/dist/src/gateway/service/session-command-service.js +81 -0
- package/dist/src/gateway/service/session-input-coordinator.d.ts +21 -0
- package/dist/src/gateway/service/session-input-coordinator.js +41 -0
- package/dist/src/gateway/service/session-preparation-worker.d.ts +15 -0
- package/dist/src/gateway/service/session-preparation-worker.js +125 -0
- package/dist/src/gateway/service/sessions-api.d.ts +13 -0
- package/dist/src/gateway/service/sessions-api.js +23 -0
- package/dist/src/gateway/service.d.ts +30 -3
- package/dist/src/gateway/service.js +89 -79
- package/dist/src/gateway/side-chat/promotion-service.js +0 -1
- package/dist/src/gateway/side-chat/run-service.js +10 -7
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/generator.js +5 -2
- package/dist/src/infra/domain-outbox-dispatcher.d.ts +0 -3
- package/dist/src/infra/domain-outbox-dispatcher.js +15 -7
- package/dist/src/local-apps/service.js +2 -2
- package/dist/src/mcp/channel-bridge.js +12 -2
- package/dist/src/notes/capabilities/read.js +2 -2
- package/dist/src/notes/service.d.ts +4 -1
- package/dist/src/notes/service.js +13 -11
- package/dist/src/projects/project-service.js +1 -2
- package/dist/src/projects/project-skill-service.js +2 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-call.d.ts +3 -2
- package/dist/src/providers/model-call.js +30 -5
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/scenes/activationAdapter.d.ts +19 -0
- package/dist/src/scenes/activationAdapter.js +1 -0
- package/dist/src/scenes/agentExecutor.js +3 -10
- package/dist/src/scenes/contracts.d.ts +3 -9
- package/dist/src/scenes/contracts.js +1 -0
- package/dist/src/scenes/execution.d.ts +9 -3
- package/dist/src/scenes/execution.js +12 -11
- package/dist/src/scenes/httpServices.d.ts +5 -2
- package/dist/src/scenes/mailContext.d.ts +4 -0
- package/dist/src/scenes/mailContext.js +9 -0
- package/dist/src/scenes/maintenance.js +1 -5
- package/dist/src/scenes/metrics.d.ts +0 -6
- package/dist/src/scenes/metrics.js +0 -11
- package/dist/src/scenes/registry.d.ts +11 -0
- package/dist/src/scenes/registry.js +28 -0
- package/dist/src/scenes/repository.d.ts +6 -3
- package/dist/src/scenes/repository.js +43 -5
- package/dist/src/scenes/service.d.ts +2 -1
- package/dist/src/scenes/service.js +9 -7
- package/dist/src/scenes/taskFollowUp/contracts.d.ts +37 -7
- package/dist/src/scenes/taskFollowUp/contracts.js +36 -17
- package/dist/src/scenes/taskFollowUp/service.d.ts +35 -7
- package/dist/src/scenes/taskFollowUp/service.js +86 -28
- package/dist/src/scenes/templates.d.ts +2 -2
- package/dist/src/scenes/userNotes.d.ts +3 -0
- package/dist/src/scenes/userNotes.js +6 -0
- package/dist/src/session/client-history.d.ts +3 -0
- package/dist/src/session/client-history.js +10 -5
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/resolve-session.js +4 -3
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/session/store.js +3 -3
- package/dist/src/storage/sqlite/ai-usage-repository.d.ts +137 -0
- package/dist/src/storage/sqlite/ai-usage-repository.js +175 -0
- package/dist/src/storage/sqlite/connector-account-repository.js +7 -5
- package/dist/src/storage/sqlite/connector-repository.js +36 -34
- package/dist/src/storage/sqlite/index.d.ts +2 -2
- package/dist/src/storage/sqlite/index.js +3 -3
- package/dist/src/storage/sqlite/migrations/209_automation_event_hub.sql +48 -0
- package/dist/src/storage/sqlite/migrations/210_remove_legacy_automation_timeout.sql +14 -0
- package/dist/src/storage/sqlite/migrations/211_automation_result_deliveries.sql +16 -0
- package/dist/src/storage/sqlite/migrations/212_automation_delivery_policy.sql +30 -0
- package/dist/src/storage/sqlite/migrations/213_automation_reliability_contract.sql +188 -0
- package/dist/src/storage/sqlite/migrations/214_ai_usage_ledger.sql +41 -0
- package/dist/src/storage/sqlite/migrations/215_scene_execution_adapters.sql +6 -0
- package/dist/src/storage/sqlite/migrations/216_remove_scene_model_usage.sql +1 -0
- package/dist/src/storage/sqlite/migrations/217_remove_legacy_memory_tables.sql +4 -0
- package/dist/src/storage/sqlite/migrations/218_core_relation_indexes.sql +26 -0
- package/dist/src/storage/sqlite/migrations/219_json_contracts.sql +123 -0
- package/dist/src/storage/sqlite/migrations/220_normalize_timestamps.sql +339 -0
- package/dist/src/storage/sqlite/migrations/221_ai_usage_retention_index.sql +2 -0
- package/dist/src/storage/sqlite/migrations/222_session_config_authority.sql +13 -0
- package/dist/src/storage/sqlite/migrations/223_session_creation_receipts.sql +59 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/row-mappers.d.ts +3 -7
- package/dist/src/storage/sqlite/row-mappers.js +6 -6
- package/dist/src/storage/sqlite/scenes-schema.d.ts +1 -1
- package/dist/src/storage/sqlite/scenes-schema.js +0 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +0 -52
- package/dist/src/storage/sqlite/schemas/scenes.sql +0 -7
- package/dist/src/storage/sqlite/session-creation-repository.d.ts +50 -0
- package/dist/src/storage/sqlite/session-creation-repository.js +166 -0
- package/dist/src/storage/sqlite/session-input-repository.d.ts +12 -2
- package/dist/src/storage/sqlite/session-input-repository.js +25 -2
- package/dist/src/storage/sqlite/session-read-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-read-repository.js +0 -1
- package/dist/src/storage/sqlite/session-repository.d.ts +0 -4
- package/dist/src/storage/sqlite/session-repository.js +8 -18
- package/dist/src/storage/sqlite/timestamps.d.ts +4 -0
- package/dist/src/storage/sqlite/timestamps.js +20 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/transcript-repository.js +23 -15
- package/dist/src/storage/sqlite/user-trust-repository.js +4 -2
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.d.ts +1 -1
- package/dist/src/tasks/home-query-service.js +3 -3
- package/dist/src/tasks/task-contract-planner.js +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +5 -0
- package/dist/src/tui/backends/embedded-backend.js +266 -20
- package/dist/src/tui/backends/embedded-drafts.d.ts +22 -0
- package/dist/src/tui/backends/embedded-drafts.js +53 -0
- package/dist/src/tui/backends/gateway-realtime-backend.d.ts +10 -0
- package/dist/src/tui/backends/gateway-realtime-backend.js +214 -33
- package/dist/src/tui/tui-backend.d.ts +1 -1
- package/dist/src/tui/tui-chat-input-state.d.ts +1 -0
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-session-format.js +0 -1
- package/dist/src/tui/tui-startup-resources.d.ts +1 -0
- package/dist/src/tui/tui-startup-resources.js +2 -2
- package/dist/src/tui/tui-types.d.ts +0 -1
- package/dist/src/tui/tui.js +69 -29
- package/dist/src/usage/cost.d.ts +4 -0
- package/dist/src/usage/cost.js +28 -0
- package/dist/src/usage/recorder.d.ts +13 -0
- package/dist/src/usage/recorder.js +117 -0
- package/dist/src/usage/scenario-registry.d.ts +8 -0
- package/dist/src/usage/scenario-registry.js +117 -0
- package/dist/src/usage/types.d.ts +55 -0
- package/dist/src/usage/types.js +1 -0
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/tts/summarize.js +1 -1
- package/dist/src/work-discovery/analyzer.js +2 -2
- package/dist/src/work-discovery/investigator.js +1 -1
- package/dist/src/work-discovery/service.js +3 -6
- package/dist/src/workflows/service/workflow-run-service.js +16 -3
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Se1Z72VG.js +0 -1
- package/dist/gateway/static/root/assets/agents-udIitwV8.js +0 -70
- package/dist/gateway/static/root/assets/apps-page-DVNySL58.js +0 -1
- package/dist/gateway/static/root/assets/attachment-load-DNCDbeOX.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BMgJvdcv.js +0 -7
- package/dist/gateway/static/root/assets/binary-plugins-BYn2hScX.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-CHA-sTAZ.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-v0WkhV5o.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DefBGjhV.js +0 -8
- package/dist/gateway/static/root/assets/capability-header-actions-vmx35sbu.js +0 -1
- package/dist/gateway/static/root/assets/channels-Eo4ONF5X.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DZYgogQw.js +0 -2
- package/dist/gateway/static/root/assets/conversation-identity-Cw0n9uzK.js +0 -1
- package/dist/gateway/static/root/assets/date-picker-CrOV4Ynd.js +0 -1
- package/dist/gateway/static/root/assets/dist-3h6cXXhT.js +0 -1
- package/dist/gateway/static/root/assets/dist-Che_jiQF.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Du-Dos9O.js +0 -1
- package/dist/gateway/static/root/assets/home-page-D7YoMHq4.js +0 -1
- package/dist/gateway/static/root/assets/index-BEw0xrde.css +0 -1
- package/dist/gateway/static/root/assets/index-DalslRUx.js +0 -121
- package/dist/gateway/static/root/assets/local-app-workbench-page-BKL5UZAj.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CjzR9Rpj.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-Dk_gTJb9.js +0 -1
- package/dist/gateway/static/root/assets/media-plugins-Dlj6TD3M.js +0 -1
- package/dist/gateway/static/root/assets/messages-fmf0dnr4.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-BebJPjjk.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CmS_hvz8.js +0 -8
- package/dist/gateway/static/root/assets/page-context-capture-button-BArPtqp5.js +0 -1
- package/dist/gateway/static/root/assets/popover-select-DcsFzD_i.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BFUdtWXF.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DBsBwAQ6.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BurdDY0m.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-Cj8xtr5t.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-BCsjgkCs.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BLL7csOJ.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CbKHBjrU.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-DyLfktib.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-BzvSNouj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BHnru0F5.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C35VKjhb.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-Bd1_Fguk.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-DuYzuR1T.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-B45YDiEw.js +0 -6
- package/dist/src/automations/product-events.d.ts +0 -5
- package/dist/src/automations/product-events.js +0 -19
- package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -9
- package/dist/src/tui/tui-empty-session-cleanup.js +0 -19
- /package/dist/gateway/static/root/assets/{dist-CI_fqRk-.js → dist-CI_fqRk-2.js} +0 -0
package/dist/src/tui/tui.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { version } from "../../package.js";
|
|
2
2
|
import { resolveStateDir, resolveXopcDatabasePath } from "../config/paths-state.js";
|
|
3
|
-
import { init_agent_session_key, normalizeAgentId } from "../routing/agent-session-key.js";
|
|
4
|
-
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
5
3
|
import { init_paths } from "../config/paths.js";
|
|
4
|
+
import { init_agent_session_key, normalizeAgentId } from "../routing/agent-session-key.js";
|
|
6
5
|
import { getAllModels, getAllProviders, getApiKey, init_providers, isProviderConfiguredSync } from "../providers/index.js";
|
|
6
|
+
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
7
7
|
import { isTerminalWorkflowRunStatus } from "../workflows/domain/run.js";
|
|
8
8
|
import "../workflows/domain/index.js";
|
|
9
9
|
import { ProjectTrustStore, hasTrustRequiringProjectResources } from "../project-trust/trust-store.js";
|
|
@@ -26,7 +26,6 @@ import { transcriptTreeEntryIdToRowNumber } from "./tui-transcript-tree.js";
|
|
|
26
26
|
import { formatTuiCompactionResult, formatTuiShareResult } from "./tui-command-formatters.js";
|
|
27
27
|
import { formatTuiStartupText } from "./tui-startup-text.js";
|
|
28
28
|
import { createTuiCommandHandler, getSlashCommands } from "./tui-commands.js";
|
|
29
|
-
import { GENERATED_TUI_SESSION_SHELL_PATCH, cleanupAbandonedTuiSessions, deleteGeneratedTuiSessionIfEmpty } from "./tui-empty-session-cleanup.js";
|
|
30
29
|
import { extensionCustomMessageContentToText, extensionCustomMessageToTurnText, extensionUserMessageContentToText } from "./tui-extension-user-message.js";
|
|
31
30
|
import { resolveFdPath } from "./tui-fd-path.js";
|
|
32
31
|
import { createBackspaceDeduper, drainAndStopTuiSafely, isIgnorableTuiStopError, resolveCtrlCAction, stopTuiSafely } from "./tui-lifecycle.js";
|
|
@@ -45,6 +44,7 @@ import { installTuiStdioFilter } from "./tui-stdio-filter.js";
|
|
|
45
44
|
import { createEditorSubmitHandler, createSubmitBurstCoalescer, shouldEnableWindowsGitBashPasteFallback } from "./tui-submit.js";
|
|
46
45
|
import { withTuiSuspended } from "./tui-suspend.js";
|
|
47
46
|
import { createInitialState } from "./tui-types.js";
|
|
47
|
+
import { TuiDraftFileStore } from "./backends/embedded-drafts.js";
|
|
48
48
|
import { EmbeddedBackend } from "./backends/embedded-backend.js";
|
|
49
49
|
import { GatewayRealtimeBackend } from "./backends/gateway-realtime-backend.js";
|
|
50
50
|
import { ChatLog } from "./components/chat-log.js";
|
|
@@ -196,7 +196,6 @@ async function runTui(opts) {
|
|
|
196
196
|
const generatedStartupConversationId = !opts.session?.trim() ? startup.conversationId : null;
|
|
197
197
|
const generatedStartupConversationIds = new Set(generatedStartupConversationId ? [generatedStartupConversationId] : []);
|
|
198
198
|
const isGeneratedTuiConversationId = (id) => generatedStartupConversationIds.has(id);
|
|
199
|
-
let startupSessionHadUserTurn = false;
|
|
200
199
|
const startupWorkingDirectory = resolveStartupWorkingDirectory(opts, isLocalMode);
|
|
201
200
|
const implicitTrustedWorkspace = startupWorkingDirectory ?? (isLocalMode ? process.cwd() : void 0);
|
|
202
201
|
const projectTrustStore = new ProjectTrustStore();
|
|
@@ -392,6 +391,7 @@ async function runTui(opts) {
|
|
|
392
391
|
tui.requestRender();
|
|
393
392
|
};
|
|
394
393
|
editor.onChange = (text) => {
|
|
394
|
+
scheduleComposerDraftSave();
|
|
395
395
|
const trimmed = text.trimStart();
|
|
396
396
|
const nextExclude = trimmed.startsWith("!!");
|
|
397
397
|
const nextBash = editorMode === "shell" || trimmed.startsWith("!");
|
|
@@ -401,6 +401,37 @@ async function runTui(opts) {
|
|
|
401
401
|
updateEditorBorderColor();
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
|
+
let composerDrafts;
|
|
405
|
+
let composerDraftTimer;
|
|
406
|
+
const saveComposerDraft = () => {
|
|
407
|
+
if (!composerDrafts) return;
|
|
408
|
+
try {
|
|
409
|
+
const text = editor.getText();
|
|
410
|
+
if (text || pendingImageAttachments.length) composerDrafts.save(state.currentConversationId, {
|
|
411
|
+
text,
|
|
412
|
+
attachments: pendingImageAttachments
|
|
413
|
+
});
|
|
414
|
+
else composerDrafts.remove(state.currentConversationId);
|
|
415
|
+
} catch (error) {
|
|
416
|
+
chatLog.addSystem(`Draft could not be saved: ${String(error)}`);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
const scheduleComposerDraftSave = () => {
|
|
420
|
+
clearTimeout(composerDraftTimer);
|
|
421
|
+
composerDraftTimer = setTimeout(saveComposerDraft, 300);
|
|
422
|
+
};
|
|
423
|
+
const restoreComposerDraft = () => {
|
|
424
|
+
if (!composerDrafts || editor.getText() || pendingImageAttachments.length) return;
|
|
425
|
+
try {
|
|
426
|
+
const saved = composerDrafts.read(state.currentConversationId);
|
|
427
|
+
if (saved) {
|
|
428
|
+
pendingImageAttachments = saved.attachments;
|
|
429
|
+
editor.setText(saved.text);
|
|
430
|
+
}
|
|
431
|
+
} catch (error) {
|
|
432
|
+
chatLog.addSystem(`Draft could not be restored: ${String(error)}`);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
404
435
|
const copyDefaultEditorAppHandlers = (target) => {
|
|
405
436
|
const customEditor = target;
|
|
406
437
|
if (!(customEditor.actionHandlers instanceof Map)) return;
|
|
@@ -558,7 +589,7 @@ async function runTui(opts) {
|
|
|
558
589
|
}
|
|
559
590
|
};
|
|
560
591
|
const getAvailableProviderCount = () => getAllProviders().filter((provider) => isProviderConfiguredSync(provider)).length;
|
|
561
|
-
const getExtensionSystemPrompt = () =>
|
|
592
|
+
const getExtensionSystemPrompt = () => resolveEffectiveAgentProfile(currentAgentId).customInstructions ?? "";
|
|
562
593
|
const waitForTuiIdle = async () => {
|
|
563
594
|
while (state.activeRunId != null || state.isCompacting || state.activityStatus === "sending" || state.activityStatus === "waiting" || state.activityStatus === "streaming" || state.activityStatus === "running" || state.activityStatus === "compacting") await new Promise((resolveDelay) => setTimeout(resolveDelay, 50));
|
|
564
595
|
};
|
|
@@ -952,6 +983,8 @@ async function runTui(opts) {
|
|
|
952
983
|
let exitResult = { exitReason: "exit" };
|
|
953
984
|
const requestExit = (options) => {
|
|
954
985
|
if (state.exitRequested) return;
|
|
986
|
+
clearTimeout(composerDraftTimer);
|
|
987
|
+
saveComposerDraft();
|
|
955
988
|
state.exitRequested = true;
|
|
956
989
|
if (elapsedTimerId) {
|
|
957
990
|
clearInterval(elapsedTimerId);
|
|
@@ -963,21 +996,15 @@ async function runTui(opts) {
|
|
|
963
996
|
}
|
|
964
997
|
tui.terminal.setProgress(false);
|
|
965
998
|
(async () => {
|
|
966
|
-
const removedEmptyStartupSessions = /* @__PURE__ */ new Set();
|
|
967
|
-
if (!state.activeRunId) for (const conversationId of generatedStartupConversationIds) {
|
|
968
|
-
if (conversationId === state.currentConversationId && startupSessionHadUserTurn) continue;
|
|
969
|
-
if (await deleteGeneratedTuiSessionIfEmpty(client, conversationId).catch(() => false)) removedEmptyStartupSessions.add(conversationId);
|
|
970
|
-
}
|
|
971
999
|
client.stop();
|
|
972
1000
|
await drainAndStopTuiSafely(tui);
|
|
973
1001
|
restoreStdio();
|
|
974
|
-
|
|
975
|
-
if (options?.showResumeHint !== false && !currentSessionWasRemoved) process.stdout.write(`\nTo resume this session: ${formatTuiResumeCommand(opts, state.currentConversationId)}\n`);
|
|
1002
|
+
if (options?.showResumeHint !== false) process.stdout.write(`\nTo resume this session: ${formatTuiResumeCommand(opts, state.currentConversationId)}\n`);
|
|
976
1003
|
finishTui?.();
|
|
977
1004
|
process.exit(0);
|
|
978
1005
|
})();
|
|
979
1006
|
};
|
|
980
|
-
const { refreshSessionInfo, loadHistory: loadSessionHistory, loadHistoryWindow, setSession, abortActive, resetCurrentSession, clearChatForSessionSwitch } = createSessionActions({
|
|
1007
|
+
const { refreshSessionInfo, loadHistory: loadSessionHistory, loadHistoryWindow, setSession: changeSession, abortActive, resetCurrentSession, clearChatForSessionSwitch } = createSessionActions({
|
|
981
1008
|
client,
|
|
982
1009
|
chatLog,
|
|
983
1010
|
tui,
|
|
@@ -992,6 +1019,15 @@ async function runTui(opts) {
|
|
|
992
1019
|
},
|
|
993
1020
|
onSessionInfoChange: () => persistCurrentNewSessionContext()
|
|
994
1021
|
});
|
|
1022
|
+
const setSession = async (key) => {
|
|
1023
|
+
clearTimeout(composerDraftTimer);
|
|
1024
|
+
saveComposerDraft();
|
|
1025
|
+
pendingImageAttachments = [];
|
|
1026
|
+
editor.setText("");
|
|
1027
|
+
clearTimeout(composerDraftTimer);
|
|
1028
|
+
await changeSession(key);
|
|
1029
|
+
restoreComposerDraft();
|
|
1030
|
+
};
|
|
995
1031
|
const persistCurrentNewSessionContext = () => {
|
|
996
1032
|
const current = getTuiNewSessionPreferences(tuiSettings, newSessionPreferenceKey);
|
|
997
1033
|
const normalizedProjectId = state.sessionInfo.projectId?.trim() || null;
|
|
@@ -1012,8 +1048,7 @@ async function runTui(opts) {
|
|
|
1012
1048
|
if (initialAgentConfig || projectId) {
|
|
1013
1049
|
await client.patchSession(state.currentConversationId, {
|
|
1014
1050
|
...initialAgentConfig,
|
|
1015
|
-
...projectId ? { projectId } : {}
|
|
1016
|
-
...isGeneratedTuiConversationId(state.currentConversationId) ? GENERATED_TUI_SESSION_SHELL_PATCH : {}
|
|
1051
|
+
...projectId ? { projectId } : {}
|
|
1017
1052
|
});
|
|
1018
1053
|
await refreshSessionInfo();
|
|
1019
1054
|
}
|
|
@@ -1050,10 +1085,7 @@ async function runTui(opts) {
|
|
|
1050
1085
|
const applyStartupWorkingDirectory = async () => {
|
|
1051
1086
|
if (startupWorkingDirectoryApplied || !startupWorkingDirectory) return;
|
|
1052
1087
|
startupWorkingDirectoryApplied = true;
|
|
1053
|
-
await client.patchSession(state.currentConversationId, {
|
|
1054
|
-
workingDirectory: startupWorkingDirectory,
|
|
1055
|
-
...isGeneratedTuiConversationId(state.currentConversationId) ? GENERATED_TUI_SESSION_SHELL_PATCH : {}
|
|
1056
|
-
});
|
|
1088
|
+
await client.patchSession(state.currentConversationId, { workingDirectory: startupWorkingDirectory });
|
|
1057
1089
|
state.sessionInfo.effectiveWorkspacePath = startupWorkingDirectory;
|
|
1058
1090
|
state.sessionInfo.workingDirectoryLocked = true;
|
|
1059
1091
|
};
|
|
@@ -1073,18 +1105,13 @@ async function runTui(opts) {
|
|
|
1073
1105
|
generatedStartupConversationIds.add(targetConversationId);
|
|
1074
1106
|
await setSession(targetConversationId);
|
|
1075
1107
|
currentAgentId = projectAgentId;
|
|
1076
|
-
if (isGeneratedTuiConversationId(state.currentConversationId)) await client.patchSession(state.currentConversationId, GENERATED_TUI_SESSION_SHELL_PATCH);
|
|
1077
1108
|
await client.patchSession(state.currentConversationId, {
|
|
1078
1109
|
projectId: result.project.id,
|
|
1079
|
-
workingDirectory: startupWorkingDirectory
|
|
1080
|
-
...isGeneratedTuiConversationId(state.currentConversationId) ? GENERATED_TUI_SESSION_SHELL_PATCH : {}
|
|
1110
|
+
workingDirectory: startupWorkingDirectory
|
|
1081
1111
|
});
|
|
1082
1112
|
state.sessionInfo.effectiveWorkspacePath = startupWorkingDirectory;
|
|
1083
1113
|
state.sessionInfo.workingDirectoryLocked = true;
|
|
1084
|
-
} else await client.patchSession(state.currentConversationId, {
|
|
1085
|
-
projectId: result.project.id,
|
|
1086
|
-
...isGeneratedTuiConversationId(state.currentConversationId) ? GENERATED_TUI_SESSION_SHELL_PATCH : {}
|
|
1087
|
-
});
|
|
1114
|
+
} else await client.patchSession(state.currentConversationId, { projectId: result.project.id });
|
|
1088
1115
|
const verb = result.created ? "Created project" : "Using project";
|
|
1089
1116
|
chatLog.addStatus(theme.dim(`${verb}: ${result.project.name}`));
|
|
1090
1117
|
};
|
|
@@ -1531,7 +1558,6 @@ async function runTui(opts) {
|
|
|
1531
1558
|
return;
|
|
1532
1559
|
}
|
|
1533
1560
|
chatLog.addUser(userDisplayContentForAttachments(text, attachments));
|
|
1534
|
-
startupSessionHadUserTurn = true;
|
|
1535
1561
|
sessionSnapshot.appendMessage("user", messageText);
|
|
1536
1562
|
lastRetryMessageText = messageText;
|
|
1537
1563
|
markRunSending(state);
|
|
@@ -1686,11 +1712,19 @@ async function runTui(opts) {
|
|
|
1686
1712
|
tui.requestRender();
|
|
1687
1713
|
};
|
|
1688
1714
|
const retryLastMessage = async () => {
|
|
1689
|
-
const
|
|
1715
|
+
const interrupted = state.chatInputState.inputs.find((input) => input.status === "interrupted");
|
|
1716
|
+
const message = interrupted?.content.trim() || lastRetryMessageText?.trim();
|
|
1690
1717
|
if (!message) {
|
|
1691
1718
|
chatLog.addSystem("No previous user message to retry.");
|
|
1692
1719
|
return;
|
|
1693
1720
|
}
|
|
1721
|
+
if (interrupted) {
|
|
1722
|
+
if (pendingImageAttachments.length || pendingNextTurnCustomMessages.length) {
|
|
1723
|
+
chatLog.addSystem("Send or clear the current attachments and context before retrying an interrupted input.");
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1726
|
+
pendingImageAttachments = interrupted.attachments ?? [];
|
|
1727
|
+
}
|
|
1694
1728
|
if (state.activeRunId) await abortActive({ clearUi: false });
|
|
1695
1729
|
sendMessage(message);
|
|
1696
1730
|
};
|
|
@@ -2112,8 +2146,10 @@ async function runTui(opts) {
|
|
|
2112
2146
|
});
|
|
2113
2147
|
defaultEditor.onAction("app.editor.external", openExternalEditor);
|
|
2114
2148
|
defaultEditor.onPasteImage = () => {
|
|
2149
|
+
const conversationId = state.currentConversationId;
|
|
2115
2150
|
(async () => {
|
|
2116
2151
|
const image = await readClipboardImage();
|
|
2152
|
+
if (conversationId !== state.currentConversationId) return;
|
|
2117
2153
|
if (!image) {
|
|
2118
2154
|
chatLog.addStatus(theme.dim("No image found on clipboard."));
|
|
2119
2155
|
tui.requestRender();
|
|
@@ -2138,6 +2174,7 @@ async function runTui(opts) {
|
|
|
2138
2174
|
name,
|
|
2139
2175
|
size: image.bytes.byteLength
|
|
2140
2176
|
});
|
|
2177
|
+
scheduleComposerDraftSave();
|
|
2141
2178
|
chatLog.addStatus(theme.dim(`Attached image: ${name} (${pendingImageAttachments.length} pending). Send a message to include it.`));
|
|
2142
2179
|
tui.requestRender();
|
|
2143
2180
|
})();
|
|
@@ -2269,6 +2306,10 @@ async function runTui(opts) {
|
|
|
2269
2306
|
setConnectionStatus(isLocalMode ? "local ready" : "gateway connected");
|
|
2270
2307
|
touchStreamingActivity();
|
|
2271
2308
|
(async () => {
|
|
2309
|
+
if (!composerDrafts) {
|
|
2310
|
+
composerDrafts = new TuiDraftFileStore(await client.getComposerDraftDirectory());
|
|
2311
|
+
restoreComposerDraft();
|
|
2312
|
+
}
|
|
2272
2313
|
if (!startupConversationCreated) {
|
|
2273
2314
|
await client.createConversation(currentAgentId, state.currentConversationId);
|
|
2274
2315
|
startupConversationCreated = true;
|
|
@@ -2314,7 +2355,6 @@ async function runTui(opts) {
|
|
|
2314
2355
|
} catch {}
|
|
2315
2356
|
await refreshModelChoices();
|
|
2316
2357
|
await loadSessionHistory({ merge: true });
|
|
2317
|
-
cleanupAbandonedTuiSessions(client, state.currentConversationId).catch(() => {});
|
|
2318
2358
|
showStartupCardOnce();
|
|
2319
2359
|
refreshStartupResources().then(() => {
|
|
2320
2360
|
updateFooter();
|
|
@@ -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 };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//#region src/usage/scenario-registry.ts
|
|
2
|
+
const SCENARIOS = {
|
|
3
|
+
"agent.answer": {
|
|
4
|
+
category: "chat",
|
|
5
|
+
reasonKey: "usage.reason.agentAnswer",
|
|
6
|
+
trigger: "user"
|
|
7
|
+
},
|
|
8
|
+
"agent.continue_after_tool": {
|
|
9
|
+
category: "tool_loop",
|
|
10
|
+
reasonKey: "usage.reason.continueAfterTool",
|
|
11
|
+
trigger: "agent"
|
|
12
|
+
},
|
|
13
|
+
"agent.background_review": {
|
|
14
|
+
category: "delegation",
|
|
15
|
+
reasonKey: "usage.reason.backgroundReview",
|
|
16
|
+
trigger: "agent"
|
|
17
|
+
},
|
|
18
|
+
"session.compact": {
|
|
19
|
+
category: "compaction",
|
|
20
|
+
reasonKey: "usage.reason.sessionCompaction",
|
|
21
|
+
trigger: "system"
|
|
22
|
+
},
|
|
23
|
+
"session.generate_title": {
|
|
24
|
+
category: "session_title",
|
|
25
|
+
reasonKey: "usage.reason.sessionTitle",
|
|
26
|
+
trigger: "system"
|
|
27
|
+
},
|
|
28
|
+
"media.understand_image": {
|
|
29
|
+
category: "image_understanding",
|
|
30
|
+
reasonKey: "usage.reason.imageUnderstanding",
|
|
31
|
+
trigger: "user"
|
|
32
|
+
},
|
|
33
|
+
"tool.web_extract": {
|
|
34
|
+
category: "web_extract",
|
|
35
|
+
reasonKey: "usage.reason.webExtract",
|
|
36
|
+
trigger: "agent"
|
|
37
|
+
},
|
|
38
|
+
"tool.session_search_summarize": {
|
|
39
|
+
category: "session_search",
|
|
40
|
+
reasonKey: "usage.reason.sessionSearch",
|
|
41
|
+
trigger: "agent"
|
|
42
|
+
},
|
|
43
|
+
"note.generate": {
|
|
44
|
+
category: "note_generation",
|
|
45
|
+
reasonKey: "usage.reason.noteGeneration",
|
|
46
|
+
trigger: "user"
|
|
47
|
+
},
|
|
48
|
+
"automation.generate_draft": {
|
|
49
|
+
category: "automation",
|
|
50
|
+
reasonKey: "usage.reason.automationDraft",
|
|
51
|
+
trigger: "user"
|
|
52
|
+
},
|
|
53
|
+
"scene.execute": {
|
|
54
|
+
category: "scene",
|
|
55
|
+
reasonKey: "usage.reason.sceneExecution",
|
|
56
|
+
trigger: "scheduled"
|
|
57
|
+
},
|
|
58
|
+
"task.plan_contract": {
|
|
59
|
+
category: "task_planning",
|
|
60
|
+
reasonKey: "usage.reason.taskPlanning",
|
|
61
|
+
trigger: "agent"
|
|
62
|
+
},
|
|
63
|
+
"task.judge_result": {
|
|
64
|
+
category: "task_judging",
|
|
65
|
+
reasonKey: "usage.reason.taskJudging",
|
|
66
|
+
trigger: "agent"
|
|
67
|
+
},
|
|
68
|
+
"voice.summarize_for_tts": {
|
|
69
|
+
category: "voice_summary",
|
|
70
|
+
reasonKey: "usage.reason.voiceSummary",
|
|
71
|
+
trigger: "user"
|
|
72
|
+
},
|
|
73
|
+
"voice.select": {
|
|
74
|
+
category: "voice_summary",
|
|
75
|
+
reasonKey: "usage.reason.voiceSelection",
|
|
76
|
+
trigger: "user"
|
|
77
|
+
},
|
|
78
|
+
"home.generate_advice": {
|
|
79
|
+
category: "home_intelligence",
|
|
80
|
+
reasonKey: "usage.reason.homeAdvice",
|
|
81
|
+
trigger: "system"
|
|
82
|
+
},
|
|
83
|
+
"work_discovery.analyze": {
|
|
84
|
+
category: "work_discovery",
|
|
85
|
+
reasonKey: "usage.reason.workDiscovery",
|
|
86
|
+
trigger: "user"
|
|
87
|
+
},
|
|
88
|
+
"work_discovery.investigate": {
|
|
89
|
+
category: "work_discovery",
|
|
90
|
+
reasonKey: "usage.reason.workInvestigation",
|
|
91
|
+
trigger: "user"
|
|
92
|
+
},
|
|
93
|
+
"discussion.analyze": {
|
|
94
|
+
category: "discussion_analysis",
|
|
95
|
+
reasonKey: "usage.reason.discussionAnalysis",
|
|
96
|
+
trigger: "user"
|
|
97
|
+
},
|
|
98
|
+
"text_assist.generate": {
|
|
99
|
+
category: "other",
|
|
100
|
+
reasonKey: "usage.reason.textAssist",
|
|
101
|
+
trigger: "user"
|
|
102
|
+
},
|
|
103
|
+
"user_model.interpret": {
|
|
104
|
+
category: "other",
|
|
105
|
+
reasonKey: "usage.reason.userModelInterpretation",
|
|
106
|
+
trigger: "system"
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
function resolveAiUsageScenario(operation) {
|
|
110
|
+
return SCENARIOS[operation] ?? {
|
|
111
|
+
category: "other",
|
|
112
|
+
reasonKey: "usage.reason.other",
|
|
113
|
+
trigger: "system"
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { resolveAiUsageScenario };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Model, Api, Usage } from '@earendil-works/pi-ai/compat';
|
|
2
|
+
export type AiUsageStatus = 'running' | 'succeeded' | 'failed' | 'aborted' | 'unknown';
|
|
3
|
+
export type AiUsageTrigger = 'user' | 'scheduled' | 'system' | 'agent' | 'retry';
|
|
4
|
+
export type AiUsageCostSource = 'model_catalog' | 'local' | 'unknown';
|
|
5
|
+
export type AiUsageCategory = 'chat' | 'tool_loop' | 'delegation' | 'compaction' | 'session_title' | 'image_understanding' | 'web_extract' | 'session_search' | 'note_generation' | 'automation' | 'scene' | 'task_planning' | 'task_judging' | 'voice_summary' | 'home_intelligence' | 'work_discovery' | 'discussion_analysis' | 'other';
|
|
6
|
+
export type AiUsageContext = {
|
|
7
|
+
operation: string;
|
|
8
|
+
trigger?: AiUsageTrigger;
|
|
9
|
+
traceId?: string;
|
|
10
|
+
parentEventId?: string;
|
|
11
|
+
conversationId?: string;
|
|
12
|
+
runId?: string;
|
|
13
|
+
agentId?: string;
|
|
14
|
+
};
|
|
15
|
+
export type AiPricingSnapshot = {
|
|
16
|
+
input: number;
|
|
17
|
+
output: number;
|
|
18
|
+
cacheRead: number;
|
|
19
|
+
cacheWrite: number;
|
|
20
|
+
};
|
|
21
|
+
export type AiUsageEvent = {
|
|
22
|
+
id: string;
|
|
23
|
+
traceId: string;
|
|
24
|
+
parentEventId?: string;
|
|
25
|
+
conversationId?: string;
|
|
26
|
+
runId?: string;
|
|
27
|
+
agentId?: string;
|
|
28
|
+
category: AiUsageCategory;
|
|
29
|
+
operation: string;
|
|
30
|
+
trigger: AiUsageTrigger;
|
|
31
|
+
reasonKey: string;
|
|
32
|
+
provider: string;
|
|
33
|
+
model: string;
|
|
34
|
+
status: AiUsageStatus;
|
|
35
|
+
startedAt: number;
|
|
36
|
+
finishedAt?: number;
|
|
37
|
+
durationMs?: number;
|
|
38
|
+
inputTokens?: number;
|
|
39
|
+
outputTokens?: number;
|
|
40
|
+
cacheReadTokens?: number;
|
|
41
|
+
cacheWriteTokens?: number;
|
|
42
|
+
reasoningTokens?: number;
|
|
43
|
+
totalTokens?: number;
|
|
44
|
+
estimatedCostMicrousd?: number;
|
|
45
|
+
costSource: AiUsageCostSource;
|
|
46
|
+
pricingSnapshot?: AiPricingSnapshot;
|
|
47
|
+
errorSummary?: string;
|
|
48
|
+
};
|
|
49
|
+
export type AiUsageFinish = {
|
|
50
|
+
status: Exclude<AiUsageStatus, 'running'>;
|
|
51
|
+
usage?: Usage;
|
|
52
|
+
errorSummary?: string;
|
|
53
|
+
finishedAt?: number;
|
|
54
|
+
};
|
|
55
|
+
export type AiUsageModel = Pick<Model<Api>, 'provider' | 'id' | 'baseUrl' | 'cost'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { init_agent_scope, resolveAgentProfileDir } from "../../agent/agent-scope.js";
|
|
2
|
-
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
3
2
|
import { DEFAULT_IDENTITY_FILENAME, DEFAULT_SOUL_FILENAME } from "../../agent/context/workspace.js";
|
|
3
|
+
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
4
4
|
import { loadProfileBootstrapFiles } from "../../agent/bootstrap/load-bootstrap-files.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { statSync } from "node:fs";
|
|
@@ -71,7 +71,7 @@ async function summarizeForTts(options) {
|
|
|
71
71
|
maxTokens: Math.min(Math.ceil(targetLength / 2), 4096),
|
|
72
72
|
temperature: .3,
|
|
73
73
|
signal: mergedSignal
|
|
74
|
-
});
|
|
74
|
+
}, void 0, { operation: "voice.summarize_for_tts" });
|
|
75
75
|
let out = "";
|
|
76
76
|
if (Array.isArray(result.content)) {
|
|
77
77
|
for (const c of result.content) if (c && typeof c === "object" && c.type === "text") out += String(c.text || "");
|
|
@@ -229,7 +229,7 @@ async function analyzeWorkContext(input) {
|
|
|
229
229
|
maxTokens: input.projectOverviewOnly ? 2e3 : WORK_ANALYSIS_MAX_TOKENS,
|
|
230
230
|
temperature: .1,
|
|
231
231
|
signal: input.signal
|
|
232
|
-
});
|
|
232
|
+
}, void 0, { operation: "work_discovery.analyze" });
|
|
233
233
|
const raw = extractText(response.content);
|
|
234
234
|
const parsed = parseJson(raw);
|
|
235
235
|
if (!parsed) throw invalidJsonError("Analysis", response, raw);
|
|
@@ -324,7 +324,7 @@ async function analyzeUnderstandingBatch(input) {
|
|
|
324
324
|
maxTokens: 3e3,
|
|
325
325
|
temperature: .1,
|
|
326
326
|
signal: input.signal
|
|
327
|
-
});
|
|
327
|
+
}, void 0, { operation: "work_discovery.analyze" });
|
|
328
328
|
const raw = extractText(response.content);
|
|
329
329
|
const parsed = parseJson(raw);
|
|
330
330
|
if (!parsed) throw invalidJsonError("Understanding source analysis", response, raw);
|
|
@@ -132,7 +132,7 @@ async function chooseAction(input) {
|
|
|
132
132
|
maxTokens: 1200,
|
|
133
133
|
temperature: .1,
|
|
134
134
|
signal: input.signal
|
|
135
|
-
})).content)), new Set(input.snapshot.structure.sampledPaths));
|
|
135
|
+
}, void 0, { operation: "work_discovery.investigate" })).content)), new Set(input.snapshot.structure.sampledPaths));
|
|
136
136
|
}
|
|
137
137
|
function contentHash(content) {
|
|
138
138
|
return createHash("sha256").update(content).digest("hex");
|
|
@@ -8,15 +8,15 @@ import { ActivityService } from "../activity/service.js";
|
|
|
8
8
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
9
9
|
import { init_session_key, resolveConversationId } from "../routing/session-key.js";
|
|
10
10
|
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
11
|
-
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
12
11
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
12
|
+
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
13
|
+
import { resolveEffectiveAgentProfile } from "../config/agent-profile.js";
|
|
13
14
|
import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
|
|
14
15
|
import "../knowledge-memory/index.js";
|
|
15
16
|
import { createWorkDiscoveryRun, getProjectUnderstandingRun, getWorkDiscoveryOnboardingState, getWorkDiscoveryRun, getWorkDiscoveryRunByIdempotencyKey, listPendingProjectUnderstandingRuns, setWorkDiscoveryFeedback, setWorkDiscoveryOnboardingState, updateWorkDiscoveryRun } from "./repository.js";
|
|
16
17
|
import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
|
|
17
18
|
import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
|
|
18
19
|
import "../user-model/index.js";
|
|
19
|
-
import { isLocalModelBaseUrl } from "../providers/model-call.js";
|
|
20
20
|
import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
|
|
21
21
|
import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
|
|
22
22
|
import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
|
|
@@ -237,10 +237,7 @@ function sessionMetadata(agentId, peerId) {
|
|
|
237
237
|
peerKind: "direct",
|
|
238
238
|
peerId
|
|
239
239
|
},
|
|
240
|
-
customData: {
|
|
241
|
-
workDiscovery: true,
|
|
242
|
-
genericNewChatShell: false
|
|
243
|
-
}
|
|
240
|
+
customData: { workDiscovery: true }
|
|
244
241
|
};
|
|
245
242
|
}
|
|
246
243
|
function errorCode(error) {
|