@xopcai/xopc 0.0.161 → 0.0.163
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/README.md +4 -2
- package/README.zh-CN.md +4 -2
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-o7GRljfD.js → activity-store-Xj95LzTv.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-9R3szLMc.js → agent-avatar-dicebear-C-QeUFwU.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DVKlWKJE.js +2 -0
- package/dist/gateway/static/root/assets/{api-jSTqFMq9.js → api-BTLmAm1_.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D81cyE76.js → app-management-settings-panel-zc6Gf-S5.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Ct6bZQCV.js → appearance-settings-0fMLnOWn.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BZXEJDIV.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CfD7AZKn.js → archive-plugin-DOiR_E21.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CP_Gaxt3.js → attachment-load-BxmYl1D1.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BGKM_NDZ.js → automation-suggestion-card-BhZOirad.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-B8CnkoXv.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-IPr2EVnS.js → binary-plugins-DTTKsvgk.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-B6aHEGA6.js → block-editor-C7se7iqg.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-BCPWKI9V.js +8 -0
- package/dist/gateway/static/root/assets/browser-workflow-inputs-kxmStCcv.js +1 -0
- package/dist/gateway/static/root/assets/browser-workflows-page-CwYf9OM_.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C7lr_mX2.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CCX9-LjU.js → capability-presets-api-BZKh2cWX.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Ble9kHRu.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-MmLMLDWf.js → channel-recipient-api-r7tdbnJE.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-CtQQQHrv.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-_VirfMKW.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BbjzIs87.js → connector-logo-BpnQYAxA.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BXWJSJeY.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-CYH5ZSXy.js → desktop-pet-B86W4a5c.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DQLqGLc0.js → desktop-pet-settings-uv8Grtgk.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ClsiXhmz.js → directory-picker-path-field-C4TTvf7p.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CjMPPdzg.js → dreaming-settings-CzJAUPvM.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-57eizjhB.js → extension-debug-page-Ci2mOYUt.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CsbSb3u1.js → extension-page-DeXdmhXQ.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-C93vaOsU.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-DIPJuzBZ.js → gateway-config-api-C31Hlblp.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CDLqAQY7.js → gateway-settings-D3zS6RZh.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DrfSJtvT.js → gateway-startup-retry-CSRvCqxh.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CWp2b7__.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-Dtm29FxD.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-lGC10UkU.js → goals-config-api-D4wYNRrf.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-jMzBJs6e.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-BWq0pdrA.js → goals-settings-Bx2jVvhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-D4o8BJVv.js → heartbeat-settings-BEIF1eXy.js} +1 -1
- package/dist/gateway/static/root/assets/index-BXtJvaQl.css +1 -0
- package/dist/gateway/static/root/assets/index-HZdBKfk_.js +199 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-6T2QYehS.js → keyboard-shortcuts-settings-DOEDpvTM.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CseW9jD3.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DCjg2K9f.js → local-apps-page-B0OpGpxv.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dar-xqQr.js → locale-store-Ys6RP7Be.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DVqPbth5.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-rt1XO43g.js → markdown-split-CEZwysCH.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bwo8CJuh.js → media-plugins-CpGKE7B0.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BzI9Wx30.js +5 -0
- package/dist/gateway/static/root/assets/{notes-page-Dp-pkX7d.js → notes-page-CdiuDZ5a.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-mrc3xtpn.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-CzZ4iKOb.js → page-tabs-BkH5AVV2.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-3E_Qa-58.js → preview-open-alternatives-CQai8f9D.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2T48Sbt.js → product-open-page-B2kSdB2b.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CfhPJLkH.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BfMoKjdm.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CrDtcsZ9.js +1 -0
- package/dist/gateway/static/root/assets/save-bar-controls-NGYnO7n7.js +1 -0
- package/dist/gateway/static/root/assets/schedule-field-nLOphnv3.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-DC-iU5IG.js → schema-form-D0e90ndE.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-D3DbF3dV.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BZp0O2dH.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CNqF6IwY.js → settings-form-section-X2Sl-EAk.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkvwitK_.js → settings-loading-skeleton-DOnUabm7.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-C4UUNi1n.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-DWvNgISx.js → settings-page-layout-C1yYqbT6.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-84iao4DZ.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DGpSPW-n.js → share-preview-page-Cfy_pH7V.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DtcwQvRG.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-L7j5Gc8Z.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-1Ps8PjsP.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-8TxxSbUw.js → system-settings-panel-Da81RJ6G.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-B5FzMWOx.js → theme-store-DflSp9o4.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-BIkOW-2L.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-DEGtSA5h.js → typed-models-lib--HptwFcD.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BDU6FneG.js → use-channel-catalog-CMHY4ZfW.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-BYAAs2iW.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-nvIZerol.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-J35JkJ7_.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-C4wYDYqV.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DMvitV6c.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cwi8Pz7n.js → workflow-run-setup-panel-D96MHABy.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-JMN0nMbM.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/client-error-format.d.ts +1 -1
- package/dist/src/agent/client-error-format.js +9 -5
- package/dist/src/agent/embedded/run-for-session.js +38 -31
- package/dist/src/agent/embedded/session-runner.d.ts +1 -0
- package/dist/src/agent/embedded/session-runner.js +12 -4
- package/dist/src/agent/failover-error.d.ts +1 -1
- package/dist/src/agent/image/generation/openai-compatible-image-provider.d.ts +2 -6
- package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -3
- package/dist/src/agent/image/generation/provider-registry.d.ts +5 -46
- package/dist/src/agent/image/generation/provider-registry.js +24 -73
- package/dist/{extensions/dashscope/src/image-generation-provider.d.ts → src/agent/image/generation/providers/dashscope.d.ts} +3 -6
- package/dist/{extensions/dashscope/src/image-generation-provider.js → src/agent/image/generation/providers/dashscope.js} +36 -59
- package/dist/{extensions/fal/src/image-generation-provider.d.ts → src/agent/image/generation/providers/fal.d.ts} +1 -1
- package/dist/{extensions/fal/src/image-generation-provider.js → src/agent/image/generation/providers/fal.js} +19 -29
- package/dist/{extensions/google/src/image-generation-provider.d.ts → src/agent/image/generation/providers/google.d.ts} +2 -2
- package/dist/{extensions/google/src/image-generation-provider.js → src/agent/image/generation/providers/google.js} +23 -30
- package/dist/{extensions/minimax/src/image-generation-provider.d.ts → src/agent/image/generation/providers/minimax.d.ts} +2 -5
- package/dist/{extensions/minimax/src/image-generation-provider.js → src/agent/image/generation/providers/minimax.js} +35 -51
- package/dist/{extensions/openai/src/image-generation-provider.d.ts → src/agent/image/generation/providers/openai.d.ts} +2 -2
- package/dist/{extensions/openai/src/image-generation-provider.js → src/agent/image/generation/providers/openai.js} +13 -38
- package/dist/src/agent/image/generation/runtime-types.d.ts +1 -0
- package/dist/src/agent/image/generation/runtime.d.ts +1 -3
- package/dist/src/agent/image/generation/runtime.js +6 -6
- package/dist/src/agent/image/generation/types.d.ts +23 -3
- package/dist/src/agent/image/index.d.ts +1 -1
- package/dist/src/agent/image/index.js +2 -2
- package/dist/src/agent/media-generation/runtime-shared.d.ts +2 -0
- package/dist/src/agent/media-generation/runtime-shared.js +1 -0
- package/dist/src/agent/outcomes/task-evaluation.d.ts +20 -0
- package/dist/src/agent/outcomes/task-evaluation.js +48 -0
- package/dist/src/agent/outcomes/task-verifier.d.ts +29 -0
- package/dist/src/agent/outcomes/task-verifier.js +71 -0
- package/dist/src/agent/prompt/memory/index.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +32 -1
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +1 -7
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +2 -73
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +1 -13
- package/dist/src/agent/tools/browser/tool/schemas.js +1 -9
- package/dist/src/agent/tools/browser-recipe-tool.d.ts +12 -0
- package/dist/src/agent/tools/browser-recipe-tool.js +113 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +6 -1
- package/dist/src/agent/tools/image-generate-tool.d.ts +2 -0
- package/dist/src/agent/tools/image-generate-tool.js +14 -7
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/auth/sync-provider-auth.d.ts +3 -0
- package/dist/src/auth/sync-provider-auth.js +12 -1
- package/dist/src/automations/domain/types.d.ts +13 -0
- package/dist/src/automations/domain/validation.d.ts +44 -24
- package/dist/src/automations/domain/validation.js +27 -18
- package/dist/src/automations/draft/automation-draft-validator.d.ts +6 -1
- package/dist/src/automations/draft/automation-draft-validator.js +1 -0
- package/dist/src/automations/service/action-executor.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +22 -0
- package/dist/src/browser/index.d.ts +0 -1
- package/dist/src/browser/index.js +1 -2
- package/dist/src/browser/pipeline/runner.d.ts +9 -2
- package/dist/src/browser/pipeline/runner.js +151 -105
- package/dist/src/browser/pipeline/schema.d.ts +21 -15
- package/dist/src/browser/pipeline/schema.js +93 -99
- package/dist/src/browser/recipes/index.d.ts +3 -0
- package/dist/src/browser/recipes/index.js +3 -0
- package/dist/src/browser/recipes/repository.d.ts +13 -0
- package/dist/src/browser/recipes/repository.js +81 -0
- package/dist/src/browser/recipes/runtime-service.d.ts +6 -0
- package/dist/src/browser/recipes/runtime-service.js +30 -0
- package/dist/src/browser/recipes/service.d.ts +36 -0
- package/dist/src/browser/recipes/service.js +186 -0
- package/dist/src/browser/recipes/types.d.ts +36 -0
- package/dist/src/cli/commands/browser-cli-helpers.js +6 -12
- package/dist/src/cli/commands/browser.js +4 -3
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/models.js +2 -5
- package/dist/src/cli/commands/onboard/model.js +3 -2
- package/dist/src/cli/commands/setup-shared/types.d.ts +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/models-json.d.ts +6 -0
- package/dist/src/config/models-json.js +2 -6
- package/dist/src/config/schema.d.ts +29 -18
- package/dist/src/config/schema.js +44 -33
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/app.js +12 -6
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/lib/safe-providers-config.d.ts +0 -3
- package/dist/src/gateway/hono/lib/safe-providers-config.js +1 -3
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
- package/dist/src/gateway/hono/routes/browser-workflows.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-workflows.js +78 -0
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -11
- package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
- package/dist/src/gateway/hono/routes/home.js +1 -0
- package/dist/src/gateway/hono/routes/index.js +4 -0
- package/dist/src/gateway/hono/routes/interaction-state.d.ts +3 -0
- package/dist/src/gateway/hono/routes/interaction-state.js +45 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +17 -2
- package/dist/src/gateway/hono/routes/memory.js +33 -4
- package/dist/src/gateway/hono/routes/models.js +151 -129
- package/dist/src/gateway/hono/routes/task-outcomes.d.ts +3 -0
- package/dist/src/gateway/hono/routes/task-outcomes.js +109 -0
- package/dist/src/gateway/hono/routes/you.d.ts +10 -2
- package/dist/src/gateway/hono/routes/you.js +184 -28
- package/dist/src/gateway/image-generation-setup.d.ts +40 -0
- package/dist/src/gateway/image-generation-setup.js +130 -0
- package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
- package/dist/src/gateway/rate-limit/buckets.js +12 -0
- package/dist/src/gateway/service/run-gateway-agent.js +84 -0
- package/dist/src/gateway/service.d.ts +6 -0
- package/dist/src/gateway/service.js +24 -0
- package/dist/src/media-shared/http/private-network.d.ts +1 -1
- package/dist/src/media-shared/http/private-network.js +1 -1
- package/dist/src/proactive/insight-repository.d.ts +2 -0
- package/dist/src/proactive/insight-repository.js +5 -2
- package/dist/src/proactive/run-processor.js +22 -1
- package/dist/src/proactive/types.d.ts +2 -0
- package/dist/src/proactive/value-score.d.ts +13 -0
- package/dist/src/proactive/value-score.js +30 -0
- package/dist/src/providers/auth-runtime/resolve-api-key.d.ts +2 -4
- package/dist/src/providers/auth-runtime/resolve-api-key.js +2 -4
- package/dist/src/providers/auth-runtime/resolve-auth.d.ts +3 -4
- package/dist/src/providers/auth-runtime/resolve-auth.js +18 -18
- package/dist/src/providers/domestic-presets.d.ts +22 -0
- package/dist/src/providers/domestic-presets.js +25 -0
- package/dist/src/providers/model-catalog-store.d.ts +71 -0
- package/dist/src/providers/model-catalog-store.js +102 -0
- package/dist/src/providers/model-catalog-sync-service.d.ts +41 -0
- package/dist/src/providers/model-catalog-sync-service.js +142 -0
- package/dist/src/providers/model-reference-auditor.d.ts +14 -0
- package/dist/src/providers/model-reference-auditor.js +71 -0
- package/dist/src/providers/model-registry.d.ts +4 -1
- package/dist/src/providers/model-registry.js +35 -2
- package/dist/src/providers/presentation.js +2 -0
- package/dist/src/providers/xopc-cloud-connection.d.ts +51 -0
- package/dist/src/providers/xopc-cloud-connection.js +196 -0
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +2 -2
- package/dist/src/session/session-title.d.ts +2 -0
- package/dist/src/session/session-title.js +24 -3
- package/dist/src/share/share-types.js +5 -5
- package/dist/src/share/site-share-types.d.ts +1 -1
- package/dist/src/share/site-share-types.js +5 -5
- package/dist/src/storage/sqlite/index.d.ts +3 -0
- package/dist/src/storage/sqlite/index.js +4 -1
- package/dist/src/storage/sqlite/interaction-state-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/interaction-state-repository.js +60 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
- package/dist/src/storage/sqlite/migrations/053_browser_recipes.sql +45 -0
- package/dist/src/storage/sqlite/migrations/054_task_outcomes.sql +24 -0
- package/dist/src/storage/sqlite/migrations/055_relationship_settings.sql +14 -0
- package/dist/src/storage/sqlite/migrations/056_task_verification.sql +6 -0
- package/dist/src/storage/sqlite/migrations/057_interaction_states.sql +11 -0
- package/dist/src/storage/sqlite/migrations/058_proactive_value.sql +3 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +17 -0
- package/dist/src/storage/sqlite/relationship-settings-repository.js +64 -0
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +46 -0
- package/dist/src/storage/sqlite/task-outcome-repository.d.ts +90 -0
- package/dist/src/storage/sqlite/task-outcome-repository.js +138 -0
- package/dist/src/user-context/interaction-state.d.ts +13 -0
- package/dist/src/user-context/interaction-state.js +69 -0
- package/dist/src/user-context/memory-use-audit.d.ts +10 -0
- package/dist/src/user-context/memory-use-audit.js +25 -0
- package/dist/src/user-context/personal-playbook.d.ts +11 -0
- package/dist/src/user-context/personal-playbook.js +41 -0
- package/dist/src/user-context/projection.d.ts +4 -0
- package/dist/src/user-context/projection.js +5 -1
- package/dist/src/user-context/relationship-continuity.d.ts +14 -0
- package/dist/src/user-context/relationship-continuity.js +51 -0
- package/package.json +5 -7
- package/dist/extensions/dashscope/src/index.d.ts +0 -4
- package/dist/extensions/dashscope/src/index.js +0 -2
- package/dist/extensions/dashscope/xopc.extension.json +0 -15
- package/dist/extensions/fal/src/index.d.ts +0 -4
- package/dist/extensions/fal/src/index.js +0 -2
- package/dist/extensions/fal/xopc.extension.json +0 -14
- package/dist/extensions/google/src/index.d.ts +0 -4
- package/dist/extensions/google/src/index.js +0 -2
- package/dist/extensions/google/xopc.extension.json +0 -14
- package/dist/extensions/minimax/src/index.d.ts +0 -4
- package/dist/extensions/minimax/src/index.js +0 -2
- package/dist/extensions/minimax/xopc.extension.json +0 -15
- package/dist/extensions/openai/src/index.d.ts +0 -4
- package/dist/extensions/openai/src/index.js +0 -2
- package/dist/extensions/openai/xopc.extension.json +0 -14
- package/dist/gateway/static/root/assets/action-boundary-settings-panel-BIVBUiNT.js +0 -1
- package/dist/gateway/static/root/assets/agents-_qbUaYbs.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-0sPqD0FK.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BxWBuBsE.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C499b9AH.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dva9SiPK.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-DNAU7u9o.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CIOH7tgn.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-TwiBp8vY.js +0 -2
- package/dist/gateway/static/root/assets/extension-settings-page-DKA9-lyP.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Q3B0E-0s.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-C5VAK04G.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BJb-5IYw.js +0 -2
- package/dist/gateway/static/root/assets/index-CkUHH170.css +0 -1
- package/dist/gateway/static/root/assets/index-vq_cJZJC.js +0 -199
- package/dist/gateway/static/root/assets/local-app-workbench-page-euH17Kvb.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-CyYCBqym.js +0 -7
- package/dist/gateway/static/root/assets/messages-CxySDn9d.js +0 -5
- package/dist/gateway/static/root/assets/models-hub-panel-DObxxjc9.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-CCb4RXcZ.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BvEcriRC.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B_e79MRJ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DGcqnYfR.js +0 -1
- package/dist/gateway/static/root/assets/save-bar-controls-CkeKasGm.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-TkqUL3wm.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DQZhrDJ8.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BkdeN99Y.js +0 -1
- package/dist/gateway/static/root/assets/settings-collapsible-section-Dpqth3oA.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-qPG7I2zd.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-lwRAh9aw.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BGj9IVUr.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B2UBAs5U.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DdjzFZ8I.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BTTZpAGV.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DuDQd-WU.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BUVkVCsW.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DeEPPu4n.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DQNUyTUq.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BIy4wrzO.js +0 -11
- package/dist/src/agent/image/generation/bundled-registry.d.ts +0 -18
- package/dist/src/agent/image/generation/bundled-registry.js +0 -35
- package/dist/src/agent/image/generation/bundled.d.ts +0 -10
- package/dist/src/agent/image/generation/bundled.js +0 -15
- package/dist/src/agent/image/generation/image-provider-ui.d.ts +0 -20
- package/dist/src/browser/pipeline/source.d.ts +0 -9
- package/dist/src/browser/pipeline/source.js +0 -77
- package/dist/src/gateway/image-capabilities.d.ts +0 -28
- package/dist/src/gateway/image-capabilities.js +0 -78
- package/dist/src/generated/bundled-image-generation-providers.d.ts +0 -14
- package/dist/src/generated/bundled-image-generation-providers.js +0 -17
- /package/dist/src/{agent/image/generation/image-provider-ui.js → browser/recipes/types.js} +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
|
|
2
|
+
import { init_write_file_atomic, writeTextAtomicSync } from "../infra/write-file-atomic.js";
|
|
3
|
+
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
4
|
+
import { getModelRegistry, init_model_registry } from "./model-registry.js";
|
|
5
|
+
import { getCredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
6
|
+
import { hostname } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
10
|
+
//#region src/providers/xopc-cloud-connection.ts
|
|
11
|
+
init_credentials();
|
|
12
|
+
init_paths_state();
|
|
13
|
+
init_write_file_atomic();
|
|
14
|
+
init_model_catalog_store();
|
|
15
|
+
init_model_registry();
|
|
16
|
+
const DEFAULT_CONSOLE_URL = "https://console.xopc.ai";
|
|
17
|
+
const DEFAULT_ROUTER_URL = "https://router.xopc.ai/v1";
|
|
18
|
+
const CONNECTION_TTL_MS = 5 * 6e4;
|
|
19
|
+
var XopcCloudHttpError = class extends Error {
|
|
20
|
+
constructor(message, status, code) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.name = "XopcCloudHttpError";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function normalizedBaseUrl(value) {
|
|
28
|
+
return value.trim().replace(/\/+$/, "");
|
|
29
|
+
}
|
|
30
|
+
function parseJson(value, message) {
|
|
31
|
+
if (!value || typeof value !== "object") throw new Error(message);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
var XopcCloudConnectionService = class {
|
|
35
|
+
pending = /* @__PURE__ */ new Map();
|
|
36
|
+
fetchImpl;
|
|
37
|
+
consoleUrl;
|
|
38
|
+
routerUrl;
|
|
39
|
+
deviceIdPath;
|
|
40
|
+
catalogStore;
|
|
41
|
+
credentials;
|
|
42
|
+
refreshModels;
|
|
43
|
+
now;
|
|
44
|
+
constructor(options = {}) {
|
|
45
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
46
|
+
this.consoleUrl = normalizedBaseUrl(options.consoleUrl ?? process.env.XOPC_CONSOLE_URL ?? DEFAULT_CONSOLE_URL);
|
|
47
|
+
this.routerUrl = normalizedBaseUrl(options.routerUrl ?? process.env.XOPC_MODEL_ROUTER_URL ?? DEFAULT_ROUTER_URL);
|
|
48
|
+
this.deviceIdPath = options.deviceIdPath ?? join(resolveStateDir(), "xopc-cloud-device.json");
|
|
49
|
+
this.catalogStore = options.catalogStore ?? getModelCatalogStore();
|
|
50
|
+
this.credentials = options.credentials ?? getCredentialResolver();
|
|
51
|
+
this.refreshModels = options.refreshModels ?? (() => getModelRegistry().refresh());
|
|
52
|
+
this.now = options.now ?? Date.now;
|
|
53
|
+
}
|
|
54
|
+
async start(clientType) {
|
|
55
|
+
const verifier = randomBytes(32).toString("base64url");
|
|
56
|
+
const codeChallenge = createHash("sha256").update(verifier).digest("base64url");
|
|
57
|
+
const response = await this.fetchImpl(`${this.consoleUrl}/api/v1/models/connect/requests`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: { "content-type": "application/json" },
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
codeChallenge,
|
|
62
|
+
deviceId: this.getOrCreateDeviceId(),
|
|
63
|
+
deviceName: hostname() || "XOPC device",
|
|
64
|
+
clientType
|
|
65
|
+
}),
|
|
66
|
+
signal: AbortSignal.timeout(15e3)
|
|
67
|
+
});
|
|
68
|
+
const body = parseJson(await response.json().catch(() => null), "XOPC Console returned an invalid response");
|
|
69
|
+
if (!response.ok || typeof body.requestId !== "string" || typeof body.authorizationUrl !== "string") throw new Error("Unable to start XOPC model connection");
|
|
70
|
+
const authorizationUrl = new URL(body.authorizationUrl);
|
|
71
|
+
if (authorizationUrl.origin !== new URL(this.consoleUrl).origin) throw new Error("XOPC Console returned an unsafe authorization URL");
|
|
72
|
+
const expiresIn = typeof body.expiresIn === "number" ? body.expiresIn : CONNECTION_TTL_MS / 1e3;
|
|
73
|
+
this.pending.set(body.requestId, {
|
|
74
|
+
verifier,
|
|
75
|
+
expiresAt: this.now() + expiresIn * 1e3
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
requestId: body.requestId,
|
|
79
|
+
authorizationUrl: authorizationUrl.href,
|
|
80
|
+
expiresIn,
|
|
81
|
+
pollInterval: typeof body.pollInterval === "number" ? body.pollInterval : 2
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async poll(requestId) {
|
|
85
|
+
const pending = this.pending.get(requestId);
|
|
86
|
+
if (!pending) throw new Error("Connection request is not active");
|
|
87
|
+
if (pending.expiresAt <= this.now()) {
|
|
88
|
+
this.pending.delete(requestId);
|
|
89
|
+
throw new Error("Connection request expired");
|
|
90
|
+
}
|
|
91
|
+
const tokenResponse = await this.fetchImpl(`${this.consoleUrl}/api/v1/models/connect/token`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "content-type": "application/json" },
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
requestId,
|
|
96
|
+
codeVerifier: pending.verifier
|
|
97
|
+
}),
|
|
98
|
+
signal: AbortSignal.timeout(15e3)
|
|
99
|
+
});
|
|
100
|
+
if (tokenResponse.status === 202) return { status: "pending" };
|
|
101
|
+
const token = parseJson(await tokenResponse.json().catch(() => null), "XOPC Console returned an invalid token response");
|
|
102
|
+
if (!tokenResponse.ok || token.providerId !== "xopc-cloud" || typeof token.apiKey !== "string") throw new Error("Unable to complete XOPC model connection");
|
|
103
|
+
const catalog = await this.fetchCatalog(token.apiKey);
|
|
104
|
+
if (!catalog) throw new Error("XOPC model catalog was not available");
|
|
105
|
+
await this.install(token.apiKey, catalog, true);
|
|
106
|
+
this.pending.delete(requestId);
|
|
107
|
+
return {
|
|
108
|
+
status: "connected",
|
|
109
|
+
modelCount: catalog.models.length,
|
|
110
|
+
models: catalog.models.map((model) => model.id),
|
|
111
|
+
recommendedModel: catalog.recommendedModel
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async refreshCatalog() {
|
|
115
|
+
const apiKey = await this.credentials.revealGatewayStoredApiKey("xopc-cloud");
|
|
116
|
+
if (!apiKey) return { status: "disconnected" };
|
|
117
|
+
const previous = this.catalogStore.getSource("xopc-cloud");
|
|
118
|
+
const catalog = await this.fetchCatalog(apiKey, previous?.etag);
|
|
119
|
+
if (!catalog) {
|
|
120
|
+
if (previous) this.catalogStore.saveSource("xopc-cloud", {
|
|
121
|
+
...previous,
|
|
122
|
+
lastSuccessAt: this.now()
|
|
123
|
+
});
|
|
124
|
+
return { status: "unchanged" };
|
|
125
|
+
}
|
|
126
|
+
await this.install(apiKey, catalog, false);
|
|
127
|
+
return {
|
|
128
|
+
status: "updated",
|
|
129
|
+
modelCount: catalog.models.length
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
getOrCreateDeviceId() {
|
|
133
|
+
if (existsSync(this.deviceIdPath)) try {
|
|
134
|
+
const value = JSON.parse(readFileSync(this.deviceIdPath, "utf8"));
|
|
135
|
+
if (typeof value.deviceId === "string" && value.deviceId.length >= 16) return value.deviceId;
|
|
136
|
+
} catch {}
|
|
137
|
+
const deviceId = randomBytes(32).toString("base64url");
|
|
138
|
+
writeTextAtomicSync(this.deviceIdPath, JSON.stringify({ deviceId }), { mode: 384 });
|
|
139
|
+
return deviceId;
|
|
140
|
+
}
|
|
141
|
+
async fetchCatalog(apiKey, etag) {
|
|
142
|
+
const headers = new Headers({ authorization: `Bearer ${apiKey}` });
|
|
143
|
+
if (etag) headers.set("if-none-match", etag);
|
|
144
|
+
const response = await this.fetchImpl(`${this.routerUrl}/catalog`, {
|
|
145
|
+
headers,
|
|
146
|
+
signal: AbortSignal.timeout(15e3)
|
|
147
|
+
});
|
|
148
|
+
if (response.status === 304) return null;
|
|
149
|
+
const rawBody = await response.json().catch(() => null);
|
|
150
|
+
if (!response.ok) {
|
|
151
|
+
const body = rawBody && typeof rawBody === "object" ? rawBody : null;
|
|
152
|
+
const errorBody = body?.error && typeof body.error === "object" ? body.error : null;
|
|
153
|
+
const code = typeof errorBody?.code === "string" ? errorBody.code : void 0;
|
|
154
|
+
throw new XopcCloudHttpError(response.status === 401 || response.status === 403 ? "XOPC Model Service authorization expired. Reconnect the service." : "Unable to load the XOPC model catalog", response.status, code);
|
|
155
|
+
}
|
|
156
|
+
const catalog = parseJson(rawBody, "XOPC model catalog returned an invalid response");
|
|
157
|
+
if (!Array.isArray(catalog.models)) throw new Error("Unable to load the XOPC model catalog");
|
|
158
|
+
const models = catalog.models.flatMap((item) => {
|
|
159
|
+
if (!item || typeof item !== "object") return [];
|
|
160
|
+
const value = item;
|
|
161
|
+
if (typeof value.id !== "string" || !value.id.trim() || value.id.includes("/")) return [];
|
|
162
|
+
return [{
|
|
163
|
+
id: value.id,
|
|
164
|
+
name: typeof value.name === "string" && value.name.trim() ? value.name : value.id,
|
|
165
|
+
maxOutputTokens: typeof value.maxOutputTokens === "number" && value.maxOutputTokens > 0 ? value.maxOutputTokens : null
|
|
166
|
+
}];
|
|
167
|
+
});
|
|
168
|
+
if (models.length === 0) throw new Error("No XOPC models are currently available");
|
|
169
|
+
return {
|
|
170
|
+
models,
|
|
171
|
+
recommendedModel: typeof catalog.recommendedModel === "string" ? catalog.recommendedModel : null,
|
|
172
|
+
etag: response.headers.get("etag")
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async install(apiKey, catalog, saveCredential) {
|
|
176
|
+
const previousKey = await this.credentials.revealGatewayStoredApiKey("xopc-cloud");
|
|
177
|
+
if (saveCredential) await this.credentials.saveApiKey("xopc-cloud", apiKey, { envVar: null });
|
|
178
|
+
try {
|
|
179
|
+
this.catalogStore.replaceSourceModels("xopc-cloud", {
|
|
180
|
+
providerId: "xopc-cloud",
|
|
181
|
+
baseUrl: this.routerUrl,
|
|
182
|
+
api: "openai-completions",
|
|
183
|
+
etag: catalog.etag,
|
|
184
|
+
recommendedModel: catalog.recommendedModel,
|
|
185
|
+
lastSuccessAt: this.now()
|
|
186
|
+
}, catalog.models);
|
|
187
|
+
} catch (err) {
|
|
188
|
+
if (saveCredential) if (previousKey) await this.credentials.saveApiKey("xopc-cloud", previousKey, { envVar: null });
|
|
189
|
+
else await this.credentials.deleteProfile("xopc-cloud:default");
|
|
190
|
+
throw err;
|
|
191
|
+
}
|
|
192
|
+
this.refreshModels();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
export { XopcCloudConnectionService, XopcCloudHttpError };
|
|
@@ -17,7 +17,7 @@ export { initSessionTurn, type InitSessionTurnOptions, type InitSessionTurnResul
|
|
|
17
17
|
export { DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, bareResetAckMessage, matchResetTriggers, resolveResetTriggers, shouldSkipResetOverlapCommand, stripLeadingEnvelopeTimestamp, type ResetTriggerMatch, } from './reset-triggers.js';
|
|
18
18
|
export type { CompactionConfig, CompactionResult } from '../agent/memory/compaction.js';
|
|
19
19
|
export type { WindowConfig } from '../agent/memory/window.js';
|
|
20
|
-
export { maybeSetProvisionalSessionTitle, maybeRefineSessionTitleWithLlm, generateSessionTitleFromMessages, sanitizeSessionTitle, provisionalTitleFromUserText, fallbackTitleFromMessages, getSessionTitleSource, shouldRefineSessionTitleWithLlm, isWebchatSessionKey, shouldAutoTitleSessionKey, type SessionTitleSource, } from './session-title.js';
|
|
20
|
+
export { maybeSetProvisionalSessionTitle, maybeRefineSessionTitleWithLlm, generateSessionTitleFromMessages, sanitizeSessionTitle, sanitizeGeneratedSessionTitle, provisionalTitleFromUserText, fallbackTitleFromMessages, getSessionTitleSource, shouldRefineSessionTitleWithLlm, isWebchatSessionKey, shouldAutoTitleSessionKey, type SessionTitleSource, } from './session-title.js';
|
|
21
21
|
export { messagesToClientHistory, flattenMessageContent, type ClientHistoryMessage } from './client-history.js';
|
|
22
22
|
export { XOPC_SESSION_TRANSCRIPT_TYPE, CURRENT_SESSION_TRANSCRIPT_VERSION, } from './transcript-format.js';
|
|
23
23
|
export { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray, type TranscriptStoredRow, type XopcTranscriptContextEntry, } from './session-context-for-llm.js';
|
|
@@ -2,7 +2,7 @@ import { SessionStatus } from "./types.js";
|
|
|
2
2
|
import { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
3
3
|
import { effectiveWorkspacePathForSession, normalizeWorkingDirectoryInput, projectWorkspacePath } from "./session-workspace.js";
|
|
4
4
|
import { emitSessionTranscriptUpdate, onSessionTranscriptUpdate } from "./transcript-events.js";
|
|
5
|
-
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
5
|
+
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
6
6
|
import { normalizeCompactionCheckpointId } from "./compaction-checkpoints.js";
|
|
7
7
|
import { flattenMessageContent, messagesToClientHistory } from "./client-history.js";
|
|
8
8
|
import { SessionStore } from "./store.js";
|
|
@@ -18,4 +18,4 @@ import { resolveSession, resolveSessionKeyForRequest } from "./resolve-session.j
|
|
|
18
18
|
import { DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, bareResetAckMessage, matchResetTriggers, resolveResetTriggers, shouldSkipResetOverlapCommand, stripLeadingEnvelopeTimestamp } from "./reset-triggers.js";
|
|
19
19
|
import { initSessionTurn } from "./init-session-turn.js";
|
|
20
20
|
import { CURRENT_SESSION_TRANSCRIPT_VERSION, XOPC_SESSION_TRANSCRIPT_TYPE } from "./transcript-format.js";
|
|
21
|
-
export { CURRENT_SESSION_TRANSCRIPT_VERSION, DEFAULT_IDLE_MINUTES, DEFAULT_RESET_AT_HOUR, DEFAULT_RESET_MODE, DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, SessionConfigStore, SessionIndex, SessionStatus, SessionStore, XOPC_SESSION_TRANSCRIPT_TYPE, applySessionPatchToMetadata, bareResetAckMessage, buildSessionContextForLlm, effectiveWorkspacePathForSession, emitSessionTranscriptUpdate, evaluateSessionFreshness, fallbackTitleFromMessages, flattenMessageContent, generateSessionTitleFromMessages, getSessionTitleSource, initSessionTurn, isTranscriptContextEntry, isWebchatSessionKey, matchResetTriggers, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, mergeLlmMessagesPreservingContextRows, messagesToClientHistory, normalizeCompactionCheckpointId, normalizeWorkingDirectoryInput, onSessionTranscriptUpdate, projectWorkspacePath, provisionalTitleFromUserText, resolveChannelResetConfig, resolveDailyResetAtMs, resolveEffectiveReasoningLevel, resolveEffectiveThinkingLevel, resolveReasoningLevel, resolveResetTriggers, resolveSession, resolveSessionKeyForRequest, resolveSessionLifecycleTimestamps, resolveSessionResetPolicy, resolveSessionResetType, resolveThinkingLevel, resolveVerboseLevel, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm, shouldSkipResetOverlapCommand, shouldSkipWebchatInboundByAbortCutoff, stripLeadingEnvelopeTimestamp, transcriptRowsFromJsonArray };
|
|
21
|
+
export { CURRENT_SESSION_TRANSCRIPT_VERSION, DEFAULT_IDLE_MINUTES, DEFAULT_RESET_AT_HOUR, DEFAULT_RESET_MODE, DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, SessionConfigStore, SessionIndex, SessionStatus, SessionStore, XOPC_SESSION_TRANSCRIPT_TYPE, applySessionPatchToMetadata, bareResetAckMessage, buildSessionContextForLlm, effectiveWorkspacePathForSession, emitSessionTranscriptUpdate, evaluateSessionFreshness, fallbackTitleFromMessages, flattenMessageContent, generateSessionTitleFromMessages, getSessionTitleSource, initSessionTurn, isTranscriptContextEntry, isWebchatSessionKey, matchResetTriggers, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, mergeLlmMessagesPreservingContextRows, messagesToClientHistory, normalizeCompactionCheckpointId, normalizeWorkingDirectoryInput, onSessionTranscriptUpdate, projectWorkspacePath, provisionalTitleFromUserText, resolveChannelResetConfig, resolveDailyResetAtMs, resolveEffectiveReasoningLevel, resolveEffectiveThinkingLevel, resolveReasoningLevel, resolveResetTriggers, resolveSession, resolveSessionKeyForRequest, resolveSessionLifecycleTimestamps, resolveSessionResetPolicy, resolveSessionResetType, resolveThinkingLevel, resolveVerboseLevel, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm, shouldSkipResetOverlapCommand, shouldSkipWebchatInboundByAbortCutoff, stripLeadingEnvelopeTimestamp, transcriptRowsFromJsonArray };
|
|
@@ -7,6 +7,8 @@ export declare function isWebchatSessionKey(sessionKey: string): boolean;
|
|
|
7
7
|
/** Whether to run LLM/fallback session naming for this key (excludes cron, heartbeat). */
|
|
8
8
|
export declare function shouldAutoTitleSessionKey(sessionKey: string): boolean;
|
|
9
9
|
export declare function sanitizeSessionTitle(raw: string): string;
|
|
10
|
+
/** Strip leading reasoning blocks emitted as raw text by some model providers. */
|
|
11
|
+
export declare function sanitizeGeneratedSessionTitle(raw: string): string;
|
|
10
12
|
export type SessionTitleSource = 'provisional' | 'llm' | 'user';
|
|
11
13
|
export declare function getSessionTitleSource(meta: {
|
|
12
14
|
customData?: Record<string, unknown>;
|
|
@@ -86,6 +86,23 @@ function sanitizeSessionTitle(raw) {
|
|
|
86
86
|
if (s.length > MAX_TITLE_LEN) s = s.slice(0, MAX_TITLE_LEN - 1).trimEnd() + "…";
|
|
87
87
|
return s;
|
|
88
88
|
}
|
|
89
|
+
/** Strip leading reasoning blocks emitted as raw text by some model providers. */
|
|
90
|
+
function sanitizeGeneratedSessionTitle(raw) {
|
|
91
|
+
let s = raw.trim();
|
|
92
|
+
while (s) {
|
|
93
|
+
const opening = s.match(/^<\s*(think|analysis|reasoning)\s*>/i);
|
|
94
|
+
if (!opening) break;
|
|
95
|
+
const tag = opening[1]?.toLowerCase();
|
|
96
|
+
if (!tag) return "";
|
|
97
|
+
const remainder = s.slice(opening[0].length);
|
|
98
|
+
const closing = new RegExp(`<\\s*\\/\\s*${tag}\\s*>`, "i").exec(remainder);
|
|
99
|
+
if (!closing) return "";
|
|
100
|
+
s = remainder.slice(closing.index + closing[0].length).trim();
|
|
101
|
+
}
|
|
102
|
+
s = s.replace(/^(?:<\s*\/\s*(?:think|analysis|reasoning)\s*>\s*)+/i, "").trim();
|
|
103
|
+
if (/^<\s*\/?\s*(?:think|analysis|reasoning)\s*>$/i.test(s)) return "";
|
|
104
|
+
return sanitizeSessionTitle(s);
|
|
105
|
+
}
|
|
89
106
|
function getSessionTitleSource(meta) {
|
|
90
107
|
const raw = meta?.customData?.titleSource;
|
|
91
108
|
if (raw === "provisional" || raw === "llm" || raw === "user") return raw;
|
|
@@ -159,7 +176,7 @@ Title:`,
|
|
|
159
176
|
if (Array.isArray(result.content)) {
|
|
160
177
|
for (const c of result.content) if (c && typeof c === "object" && c.type === "text") text += String(c.text || "");
|
|
161
178
|
}
|
|
162
|
-
const cleaned =
|
|
179
|
+
const cleaned = sanitizeGeneratedSessionTitle(text);
|
|
163
180
|
return cleaned.length > 0 ? cleaned : null;
|
|
164
181
|
} catch (err) {
|
|
165
182
|
log.warn({ err }, "Session title LLM call failed");
|
|
@@ -171,7 +188,11 @@ function shouldRefineSessionTitleWithLlm(meta) {
|
|
|
171
188
|
if (!meta) return false;
|
|
172
189
|
const source = getSessionTitleSource(meta);
|
|
173
190
|
if (source === "user") return false;
|
|
174
|
-
if (meta.name?.trim())
|
|
191
|
+
if (meta.name?.trim()) {
|
|
192
|
+
if (source === "provisional") return true;
|
|
193
|
+
if (source === "llm") return sanitizeGeneratedSessionTitle(meta.name).length === 0;
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
175
196
|
return true;
|
|
176
197
|
}
|
|
177
198
|
function canAutoWriteTitle(meta) {
|
|
@@ -269,4 +290,4 @@ async function maybeRefineSessionTitleWithLlm(sessionStore, sessionKey, modelRef
|
|
|
269
290
|
}
|
|
270
291
|
}
|
|
271
292
|
//#endregion
|
|
272
|
-
export { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm };
|
|
293
|
+
export { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm };
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const SHARE_CONFIG_DEFAULTS = {
|
|
4
4
|
enabled: true,
|
|
5
5
|
defaultTtlMs: 864e5,
|
|
6
|
-
maxTtlMs:
|
|
7
|
-
maxActiveShares:
|
|
8
|
-
maxFileSize:
|
|
6
|
+
maxTtlMs: 2592e6,
|
|
7
|
+
maxActiveShares: 500,
|
|
8
|
+
maxFileSize: 524288e3,
|
|
9
9
|
inlinePreviewMimes: [
|
|
10
10
|
"image/png",
|
|
11
11
|
"image/jpeg",
|
|
@@ -20,8 +20,8 @@ const SHARE_CONFIG_DEFAULTS = {
|
|
|
20
20
|
],
|
|
21
21
|
directory: {
|
|
22
22
|
enabled: true,
|
|
23
|
-
maxFolderSize:
|
|
24
|
-
maxFileCount:
|
|
23
|
+
maxFolderSize: 2147483648,
|
|
24
|
+
maxFileCount: 1e4,
|
|
25
25
|
maxDepth: 20,
|
|
26
26
|
listingCacheMs: 6e4,
|
|
27
27
|
zipConcurrency: 1
|
|
@@ -60,7 +60,7 @@ export interface CreateSiteShareParams {
|
|
|
60
60
|
path?: string;
|
|
61
61
|
/** Proxy: full upstream URL (must be loopback or whitelisted). */
|
|
62
62
|
upstreamUrl?: string;
|
|
63
|
-
/** Default
|
|
63
|
+
/** Default 24h. */
|
|
64
64
|
ttlMs?: number;
|
|
65
65
|
/** Optional friendly description. */
|
|
66
66
|
description?: string;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
const SITE_SHARE_CONFIG_DEFAULTS = {
|
|
3
3
|
enabled: true,
|
|
4
4
|
publicHostSuffix: "share.xopc.ai",
|
|
5
|
-
defaultTtlMs:
|
|
6
|
-
maxTtlMs:
|
|
7
|
-
maxActiveSites:
|
|
5
|
+
defaultTtlMs: 864e5,
|
|
6
|
+
maxTtlMs: 2592e6,
|
|
7
|
+
maxActiveSites: 50,
|
|
8
8
|
static: {
|
|
9
9
|
enabled: true,
|
|
10
|
-
maxRootDirSize:
|
|
11
|
-
maxFileCount:
|
|
10
|
+
maxRootDirSize: 1073741824,
|
|
11
|
+
maxFileCount: 2e4,
|
|
12
12
|
rewriteEnabledByDefault: false
|
|
13
13
|
},
|
|
14
14
|
proxy: {
|
|
@@ -5,6 +5,9 @@ export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, } from './m
|
|
|
5
5
|
export { discoverSqlMigrations, listRegisteredMigrationTargets } from './migrations/discover.js';
|
|
6
6
|
export { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest, type OpenXopcDatabaseOptions, type XopcDatabase, } from './connection.js';
|
|
7
7
|
export { getSqliteDatabase, runSqliteWriteTransaction } from './transaction.js';
|
|
8
|
+
export { getInteractionState, setInteractionState, updateInteractionStateFromMessage, type InteractionState, } from './interaction-state-repository.js';
|
|
9
|
+
export { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings, type RelationshipSettings, type SupportMode, } from './relationship-settings-repository.js';
|
|
10
|
+
export { completeTaskOutcome, findTaskOutcomeForAssistant, getTaskOutcome, listTaskOutcomes, setTaskOutcomeFeedback, startTaskOutcome, summarizeTaskOutcomes, updateTaskOutcome, type TaskContract, type TaskEvidence, type TaskFeedbackOutcome, type TaskOutcome, type TaskOutcomeMetrics, type TaskOutcomeStatus, } from './task-outcome-repository.js';
|
|
8
11
|
export { buildDefaultSessionMetadata, type SessionMetadataSeed, } from './session-metadata.js';
|
|
9
12
|
export { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow, type SessionConfigRow, type SessionRow, type TranscriptEntryRow, } from './row-mappers.js';
|
|
10
13
|
export { deleteSessionRecord, ensureSessionRecord, getCurrentSessionId, getGlobalSessionStats, findSessionKeyBySessionId, getSessionPersistedLevels, getSessionMetadata, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats, } from './session-repository.js';
|
|
@@ -6,6 +6,9 @@ import { XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION, applyPendingMi
|
|
|
6
6
|
import { ensureXopcDatabaseSchema } from "./schema.js";
|
|
7
7
|
import { closeXopcDatabase, getXopcDatabase, isXopcDatabaseOpen, openXopcDatabase, requireXopcDatabase, resetXopcDatabaseSingletonForTest } from "./connection.js";
|
|
8
8
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
9
|
+
import { getInteractionState, setInteractionState, updateInteractionStateFromMessage } from "./interaction-state-repository.js";
|
|
10
|
+
import { buildRelationshipPrompt, getRelationshipSettings, isProactiveSupportAllowed, updateRelationshipSettings } from "./relationship-settings-repository.js";
|
|
11
|
+
import { completeTaskOutcome, findTaskOutcomeForAssistant, getTaskOutcome, listTaskOutcomes, setTaskOutcomeFeedback, startTaskOutcome, summarizeTaskOutcomes, updateTaskOutcome } from "./task-outcome-repository.js";
|
|
9
12
|
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
10
13
|
import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
11
14
|
import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getCurrentSessionId, getGlobalSessionStats, getSessionMetadata, getSessionPersistedLevels, incrementSessionStatsOnAppend, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord, resolveSessionAgentId, updateSessionStats } from "./session-repository.js";
|
|
@@ -21,4 +24,4 @@ import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeC
|
|
|
21
24
|
import { getUserTrustPolicy, setUserTrustPolicy } from "./user-trust-repository.js";
|
|
22
25
|
import { consumeMemoryReferenceConsent, decideMemoryReferenceConsent, ensureMemoryReferenceConsentRequest, hasMemoryReferenceConsent, listMemoryReferenceConsents, revokeMemoryReferenceConsent } from "./memory-reference-consent-repository.js";
|
|
23
26
|
import { getUserProfilePromptState, setUserProfilePromptState } from "./user-profile-setup-repository.js";
|
|
24
|
-
export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, USER_UNDERSTANDING_REMEDIATION_POLICY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, buildDefaultSessionMetadata, buildGlobalSessionStats, captureCompactionCheckpoint, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, classifyStoredRow, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeMemoryReferenceConsent, createConnectorApproval, createObjectLinkRecord, decideConnectorApproval, decideMemoryReferenceConsent, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, ensureMemoryReferenceConsentRequest, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findLatestMemoryInjectTrace, findSessionKeyBySessionId, finishKnowledgeSyncRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCompactionCheckpointDetail, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getCurrentSessionId, getGlobalSessionStats, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getNoteAgentContextRecord, getNoteRecord, getSessionConfig, getSessionMetadata, getSessionPersistedLevels, getSqliteDatabase, getUserProfilePromptState, getUserTrustPolicy, getXopcDatabase, hasMemoryReferenceConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, inspectSchemaMigrationStatus, isXopcDatabaseOpen, listActivityRecords, listCachedConnectorCatalogEntries, listCompactionCheckpoints, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemoryReferenceConsents, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, loadCheckpointRows, loadLlmMessagesForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, readSchemaVersion, readSchemaVersionForTest, recordActivityEvent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreCompactionCheckpoint, revokeMemoryReferenceConsent, runSqliteWriteTransaction, searchMemoryIndex, searchMemoryRecords, sessionConfigRowToConfig, sessionRowToMetadata, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setLatestMemoryInjectFeedback, setMemoryProviderState, setMemoryTraceFeedback, setSessionConfig, setUserProfilePromptState, setUserTrustPolicy, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUserUnderstandingQuality, syncMemoryIndex, transcriptEntryRowToStoredRow, updateSessionConfig, updateSessionStats, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord };
|
|
27
|
+
export { DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, USER_UNDERSTANDING_REMEDIATION_POLICY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, captureCompactionCheckpoint, claimConnectorWebhookDelivery, claimKnowledgeSourceItems, classifyStoredRow, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, completeTaskOutcome, consumeConnectorApproval, consumeMemoryReferenceConsent, createConnectorApproval, createObjectLinkRecord, decideConnectorApproval, decideMemoryReferenceConsent, deleteConnectorConnection, deleteConnectorInstallation, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteNoteAgentContextRecord, deleteNoteRecord, deleteSessionConfig, deleteSessionRecord, discoverSqlMigrations, ensureMemoryReferenceConsentRequest, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findLatestMemoryInjectTrace, findSessionKeyBySessionId, findTaskOutcomeForAssistant, finishKnowledgeSyncRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCompactionCheckpointDetail, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getCurrentSessionId, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionMetadata, getSessionPersistedLevels, getSqliteDatabase, getTaskOutcome, getUserProfilePromptState, getUserTrustPolicy, getXopcDatabase, hasMemoryReferenceConsent, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, inspectSchemaMigrationStatus, isProactiveSupportAllowed, isXopcDatabaseOpen, listActivityRecords, listCachedConnectorCatalogEntries, listCompactionCheckpoints, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemoryReferenceConsents, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTaskOutcomes, loadCheckpointRows, loadLlmMessagesForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, readSchemaVersion, readSchemaVersionForTest, recordActivityEvent, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreCompactionCheckpoint, revokeMemoryReferenceConsent, runSqliteWriteTransaction, searchMemoryIndex, searchMemoryRecords, sessionConfigRowToConfig, sessionRowToMetadata, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setLatestMemoryInjectFeedback, setMemoryProviderState, setMemoryTraceFeedback, setSessionConfig, setTaskOutcomeFeedback, setUserProfilePromptState, setUserTrustPolicy, startKnowledgeSyncRun, startTaskOutcome, summarizeMemoryRecallFeedback, summarizeTaskOutcomes, summarizeUserUnderstandingQuality, syncMemoryIndex, transcriptEntryRowToStoredRow, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateTaskOutcome, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type InteractionStateSignal } from '../../user-context/interaction-state.js';
|
|
2
|
+
export interface InteractionState extends InteractionStateSignal {
|
|
3
|
+
sessionKey: string;
|
|
4
|
+
expiresAt: number;
|
|
5
|
+
updatedAt: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function getInteractionState(sessionKey: string, now?: number): InteractionState | undefined;
|
|
8
|
+
export declare function setInteractionState(input: {
|
|
9
|
+
sessionKey: string;
|
|
10
|
+
signal: InteractionStateSignal;
|
|
11
|
+
now?: number;
|
|
12
|
+
}): InteractionState;
|
|
13
|
+
export declare function updateInteractionStateFromMessage(input: {
|
|
14
|
+
sessionKey: string;
|
|
15
|
+
message: string;
|
|
16
|
+
now?: number;
|
|
17
|
+
}): InteractionState;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
+
import { inferInteractionState } from "../../user-context/interaction-state.js";
|
|
3
|
+
//#region src/storage/sqlite/interaction-state-repository.ts
|
|
4
|
+
const STATE_TTL_MS = 360 * 60 * 1e3;
|
|
5
|
+
function fromRow(row) {
|
|
6
|
+
return {
|
|
7
|
+
sessionKey: row.session_key,
|
|
8
|
+
supportNeed: row.support_need,
|
|
9
|
+
...row.emotion_hypothesis ? { emotionHypothesis: row.emotion_hypothesis } : {},
|
|
10
|
+
confidence: row.confidence,
|
|
11
|
+
source: row.source,
|
|
12
|
+
repairStatus: row.repair_status,
|
|
13
|
+
...row.repair_reason ? { repairReason: row.repair_reason } : {},
|
|
14
|
+
expiresAt: row.expires_at,
|
|
15
|
+
updatedAt: row.updated_at
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getInteractionState(sessionKey, now = Date.now()) {
|
|
19
|
+
const row = getSqliteDatabase().prepare(`SELECT session_key, support_need, emotion_hypothesis, confidence, source,
|
|
20
|
+
repair_status, repair_reason, expires_at, updated_at
|
|
21
|
+
FROM interaction_states WHERE session_key = ? AND expires_at > ?`).get(sessionKey, now);
|
|
22
|
+
return row ? fromRow(row) : void 0;
|
|
23
|
+
}
|
|
24
|
+
function setInteractionState(input) {
|
|
25
|
+
const now = input.now ?? Date.now();
|
|
26
|
+
const expiresAt = now + STATE_TTL_MS;
|
|
27
|
+
runSqliteWriteTransaction((db) => {
|
|
28
|
+
db.prepare(`INSERT INTO interaction_states (
|
|
29
|
+
session_key, support_need, emotion_hypothesis, confidence, source,
|
|
30
|
+
repair_status, repair_reason, expires_at, updated_at
|
|
31
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
32
|
+
ON CONFLICT(session_key) DO UPDATE SET
|
|
33
|
+
support_need = excluded.support_need,
|
|
34
|
+
emotion_hypothesis = excluded.emotion_hypothesis,
|
|
35
|
+
confidence = excluded.confidence,
|
|
36
|
+
source = excluded.source,
|
|
37
|
+
repair_status = excluded.repair_status,
|
|
38
|
+
repair_reason = excluded.repair_reason,
|
|
39
|
+
expires_at = excluded.expires_at,
|
|
40
|
+
updated_at = excluded.updated_at`).run(input.sessionKey, input.signal.supportNeed, input.signal.emotionHypothesis ?? null, input.signal.confidence, input.signal.source, input.signal.repairStatus, input.signal.repairReason ?? null, expiresAt, now);
|
|
41
|
+
});
|
|
42
|
+
return getInteractionState(input.sessionKey, now);
|
|
43
|
+
}
|
|
44
|
+
function updateInteractionStateFromMessage(input) {
|
|
45
|
+
const now = input.now ?? Date.now();
|
|
46
|
+
const previous = getInteractionState(input.sessionKey, now);
|
|
47
|
+
const inferred = inferInteractionState(input.message);
|
|
48
|
+
const signal = previous?.repairStatus === "needed" && inferred.repairStatus === "none" ? {
|
|
49
|
+
...inferred,
|
|
50
|
+
repairStatus: "needed",
|
|
51
|
+
repairReason: previous.repairReason
|
|
52
|
+
} : inferred;
|
|
53
|
+
return setInteractionState({
|
|
54
|
+
sessionKey: input.sessionKey,
|
|
55
|
+
signal,
|
|
56
|
+
now
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { getInteractionState, setInteractionState, updateInteractionStateFromMessage };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSqliteDatabase, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
|
-
import { buildFts5SearchQuery, fts5RankToScore, memoryLexicalSimilarity } from "./fts.js";
|
|
3
2
|
import { LOCAL_USER_ID } from "../../user-context/owner.js";
|
|
3
|
+
import { buildFts5SearchQuery, fts5RankToScore, memoryLexicalSimilarity } from "./fts.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
//#region src/storage/sqlite/memory-records-repository.ts
|
|
6
6
|
const USER_UNDERSTANDING_REMEDIATION_POLICY = {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS browser_recipes (
|
|
2
|
+
recipe_id TEXT PRIMARY KEY,
|
|
3
|
+
revision INTEGER NOT NULL,
|
|
4
|
+
name TEXT NOT NULL,
|
|
5
|
+
description TEXT,
|
|
6
|
+
status TEXT NOT NULL CHECK (status IN ('published', 'disabled')),
|
|
7
|
+
yaml_source TEXT NOT NULL,
|
|
8
|
+
risk_level TEXT NOT NULL CHECK (risk_level IN ('read_only', 'account_write', 'sensitive')),
|
|
9
|
+
domains_json TEXT NOT NULL,
|
|
10
|
+
created_at_ms INTEGER NOT NULL,
|
|
11
|
+
updated_at_ms INTEGER NOT NULL
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE TABLE IF NOT EXISTS browser_recipe_runs (
|
|
15
|
+
run_id TEXT PRIMARY KEY,
|
|
16
|
+
recipe_id TEXT NOT NULL,
|
|
17
|
+
recipe_revision INTEGER NOT NULL,
|
|
18
|
+
recipe_yaml TEXT NOT NULL,
|
|
19
|
+
status TEXT NOT NULL CHECK (status IN ('queued', 'running', 'succeeded', 'failed', 'cancelled')),
|
|
20
|
+
args_json TEXT NOT NULL,
|
|
21
|
+
result_json TEXT,
|
|
22
|
+
error TEXT,
|
|
23
|
+
created_at_ms INTEGER NOT NULL,
|
|
24
|
+
started_at_ms INTEGER,
|
|
25
|
+
ended_at_ms INTEGER,
|
|
26
|
+
duration_ms INTEGER,
|
|
27
|
+
FOREIGN KEY (recipe_id) REFERENCES browser_recipes(recipe_id) ON DELETE CASCADE
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE INDEX IF NOT EXISTS idx_browser_recipe_runs_recipe_created
|
|
31
|
+
ON browser_recipe_runs(recipe_id, created_at_ms DESC);
|
|
32
|
+
|
|
33
|
+
CREATE TABLE IF NOT EXISTS browser_recipe_run_events (
|
|
34
|
+
event_id TEXT PRIMARY KEY,
|
|
35
|
+
run_id TEXT NOT NULL,
|
|
36
|
+
seq INTEGER NOT NULL,
|
|
37
|
+
type TEXT NOT NULL,
|
|
38
|
+
data_json TEXT,
|
|
39
|
+
created_at_ms INTEGER NOT NULL,
|
|
40
|
+
UNIQUE(run_id, seq),
|
|
41
|
+
FOREIGN KEY (run_id) REFERENCES browser_recipe_runs(run_id) ON DELETE CASCADE
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE INDEX IF NOT EXISTS idx_browser_recipe_run_events_run_seq
|
|
45
|
+
ON browser_recipe_run_events(run_id, seq ASC);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
CREATE TABLE task_outcomes (
|
|
2
|
+
run_id TEXT PRIMARY KEY,
|
|
3
|
+
session_key TEXT NOT NULL,
|
|
4
|
+
channel TEXT NOT NULL,
|
|
5
|
+
objective TEXT NOT NULL,
|
|
6
|
+
status TEXT NOT NULL CHECK (status IN ('running', 'succeeded', 'failed', 'cancelled')),
|
|
7
|
+
summary TEXT,
|
|
8
|
+
contract_json TEXT,
|
|
9
|
+
evidence_json TEXT NOT NULL DEFAULT '[]',
|
|
10
|
+
feedback_outcome TEXT CHECK (feedback_outcome IN ('helpful', 'not_helpful')),
|
|
11
|
+
feedback_reason TEXT,
|
|
12
|
+
needs_correction INTEGER CHECK (needs_correction IN (0, 1)),
|
|
13
|
+
support_fit INTEGER CHECK (support_fit IN (0, 1)),
|
|
14
|
+
started_at INTEGER NOT NULL,
|
|
15
|
+
completed_at INTEGER,
|
|
16
|
+
updated_at INTEGER NOT NULL,
|
|
17
|
+
FOREIGN KEY (session_key) REFERENCES sessions(session_key) ON DELETE CASCADE
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
CREATE INDEX idx_task_outcomes_session_started
|
|
21
|
+
ON task_outcomes(session_key, started_at DESC);
|
|
22
|
+
|
|
23
|
+
CREATE INDEX idx_task_outcomes_status_started
|
|
24
|
+
ON task_outcomes(status, started_at DESC);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
CREATE TABLE relationship_settings (
|
|
2
|
+
owner_id TEXT PRIMARY KEY CHECK (owner_id = 'local-owner'),
|
|
3
|
+
support_mode TEXT NOT NULL CHECK (support_mode IN ('efficient', 'coach', 'companion', 'auto')),
|
|
4
|
+
proactive_enabled INTEGER NOT NULL CHECK (proactive_enabled IN (0, 1)),
|
|
5
|
+
quiet_start TEXT,
|
|
6
|
+
quiet_end TEXT,
|
|
7
|
+
allowed_topics_json TEXT NOT NULL,
|
|
8
|
+
blocked_topics_json TEXT NOT NULL,
|
|
9
|
+
updated_at INTEGER NOT NULL
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
INSERT INTO relationship_settings (
|
|
13
|
+
owner_id, support_mode, proactive_enabled, allowed_topics_json, blocked_topics_json, updated_at
|
|
14
|
+
) VALUES ('local-owner', 'auto', 0, '[]', '[]', unixepoch() * 1000);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
ALTER TABLE task_outcomes ADD COLUMN verification_status TEXT NOT NULL DEFAULT 'unverified'
|
|
2
|
+
CHECK (verification_status IN ('passed', 'failed', 'unverified'));
|
|
3
|
+
ALTER TABLE task_outcomes ADD COLUMN verification_json TEXT NOT NULL DEFAULT '{"checks":[]}';
|
|
4
|
+
ALTER TABLE task_outcomes ADD COLUMN failure_code TEXT;
|
|
5
|
+
ALTER TABLE task_outcomes ADD COLUMN failure_phase TEXT;
|
|
6
|
+
ALTER TABLE task_outcomes ADD COLUMN recovery_action TEXT;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
CREATE TABLE interaction_states (
|
|
2
|
+
session_key TEXT PRIMARY KEY REFERENCES sessions(session_key) ON DELETE CASCADE,
|
|
3
|
+
support_need TEXT NOT NULL CHECK (support_need IN ('listen', 'clarify', 'advise', 'act', 'unknown')),
|
|
4
|
+
emotion_hypothesis TEXT,
|
|
5
|
+
confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
|
|
6
|
+
source TEXT NOT NULL CHECK (source IN ('explicit', 'inferred')),
|
|
7
|
+
repair_status TEXT NOT NULL CHECK (repair_status IN ('none', 'needed', 'repaired')),
|
|
8
|
+
repair_reason TEXT,
|
|
9
|
+
expires_at INTEGER NOT NULL,
|
|
10
|
+
updated_at INTEGER NOT NULL
|
|
11
|
+
);
|
|
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
|
|
|
3
3
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
4
4
|
export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
5
5
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
6
|
-
export declare const XOPC_DB_SCHEMA_VERSION =
|
|
6
|
+
export declare const XOPC_DB_SCHEMA_VERSION = 58;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|
|
@@ -12,7 +12,7 @@ const log = createLogger("Sqlite:Migrations");
|
|
|
12
12
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
13
13
|
const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
14
14
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
15
|
-
const XOPC_DB_SCHEMA_VERSION =
|
|
15
|
+
const XOPC_DB_SCHEMA_VERSION = 58;
|
|
16
16
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
function resolveMigrationsDir(override) {
|
|
18
18
|
if (override) return override;
|
|
@@ -46,7 +46,7 @@ function applySingleMigration(db, migration) {
|
|
|
46
46
|
* Each step runs in its own transaction and updates schema_meta on success.
|
|
47
47
|
*/
|
|
48
48
|
function applyPendingMigrations(db, options = {}) {
|
|
49
|
-
const targetVersion = options.targetVersion ??
|
|
49
|
+
const targetVersion = options.targetVersion ?? 58;
|
|
50
50
|
let currentVersion = readSchemaVersion(db);
|
|
51
51
|
if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
|
|
52
52
|
if (currentVersion >= targetVersion) return currentVersion;
|
|
@@ -62,7 +62,7 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
/** Inspect schema version without mutating the database. */
|
|
64
64
|
function inspectSchemaMigrationStatus(db, options = {}) {
|
|
65
|
-
const appVersion = options.targetVersion ??
|
|
65
|
+
const appVersion = options.targetVersion ?? 58;
|
|
66
66
|
const dbVersion = readSchemaVersion(db);
|
|
67
67
|
if (dbVersion > appVersion) return {
|
|
68
68
|
dbVersion,
|
|
@@ -19,7 +19,7 @@ const log = createLogger('Sqlite:Migrations');
|
|
|
19
19
|
export const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
20
20
|
|
|
21
21
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
22
|
-
export const XOPC_DB_SCHEMA_VERSION =
|
|
22
|
+
export const XOPC_DB_SCHEMA_VERSION = 58;
|
|
23
23
|
|
|
24
24
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
25
25
|
|