@xopcai/xopc 0.0.468 → 0.0.470
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/sidepanel.js +5 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agents-CIV2R_El.js → agents-DZftplJc.js} +3 -3
- package/dist/gateway/static/root/assets/{api-Cl08_xtM.js → api-BnS9d0p6.js} +1 -1
- package/dist/gateway/static/root/assets/{app-link-BkEO3eBe.js → app-link-CauYDM-y.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CncU5JvR.js → apps-page-CXKTWj1s.js} +1 -1
- package/dist/gateway/static/root/assets/arrow-down-to-line-C5D8Vt-L.js +1 -0
- package/dist/gateway/static/root/assets/{attachment-load-DrVGNxJm.js → attachment-load-C9iZLUHv.js} +1 -1
- package/dist/gateway/static/root/assets/attachment-preview-renderer-_6GhoCYk.js +12 -0
- package/dist/gateway/static/root/assets/attachment-utils-core-BPYdUI6y.js +1 -0
- package/dist/gateway/static/root/assets/{automation-task-card-sR61FFLn.js → automation-task-card-BNT3n0qu.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BNzj3R7A.js → automations-page-DqrAOReO.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BYmFhO8E.js +9 -0
- package/dist/gateway/static/root/assets/binary-plugins-CnFVuJtL.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-B4Yqbxab.js → block-editor-jy5CCmhH.js} +9 -9
- package/dist/gateway/static/root/assets/{capabilities-CBSMm_jo.js → capabilities-CaJjMTli.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-YmBD7oK8.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-page-XgIRdqCb.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DfyND0IO.js +8 -0
- package/dist/gateway/static/root/assets/channels-DwUmMnA1.js +1 -0
- package/dist/gateway/static/root/assets/{chat-chart-block-CS-cORJt.js → chat-chart-block-B_c5sy7q.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-DfFXhDRv.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D6LH3W5H.js → chat-terminal-dock-Dn7Cm1O4.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-CxeXJKxg.js → connected-providers-grid-DUHMZjyV.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-Bsec3-eZ.js → connector-service-page-DLbBblN2.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-C0ZCUtxF.js → connectors-page-HHGB3r3Q.js} +1 -1
- package/dist/gateway/static/root/assets/constants-D5Z-mUto.js +1 -0
- package/dist/gateway/static/root/assets/{device-pairing-wizard-diuSsk-H.js → device-pairing-wizard-eWeHH6Ru.js} +1 -1
- package/dist/gateway/static/root/assets/extension-authoritative-grants-BqtUnmq-.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DrpE2lQ3.js → extension-debug-page-DIAyDA-a.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-hr60GwXQ.js → extension-iframe-host-CCe4R7L7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-aoF3x4-X.js → extension-message-router-BD0ZamBV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BfM8zli6.js → extension-page-C09dlV3J.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BcSgVeKW.js → extension-provider-BhluafoX.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Db5t2Mz0.js → extension-settings-page-CB8KLYoG.js} +1 -1
- package/dist/gateway/static/root/assets/file-CStvVK2S.js +1 -0
- package/dist/gateway/static/root/assets/{file-BqMS_3DT.js → file-code-corner-byQA1VfD.js} +1 -1
- package/dist/gateway/static/root/assets/file-icon-N6WjUhq_.js +1 -0
- package/dist/gateway/static/root/assets/file-tree-CYUkQR1t.js +1 -0
- package/dist/gateway/static/root/assets/{home-page-DsS2UT08.js → home-page-8KwhWlYt.js} +3 -3
- package/dist/gateway/static/root/assets/index-CQNwlXpQ.js +11 -0
- package/dist/gateway/static/root/assets/index-CZUfwwLp.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-0_PeJJqO.js → install-connector-dialog-BZjodnUC.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DmzgjJNj.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-yBqRl5Bi.js → local-apps-page-Ct8z2B7R.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CH9amuGc.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-D9HGIYXx.js → management-settings-CUQd0FJ3.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CiGdWuN3.js → markdown-view-Dm01GIXv.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C2lp7UmI.js → media-plugins-jsWNdARw.js} +1 -1
- package/dist/gateway/static/root/assets/models-hub-cache-B2QcrY4n.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-DeFb2HEC.js +7 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-DUzoWZEe.js +1 -0
- package/dist/gateway/static/root/assets/notes-api-BMSPkAm8.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-nvqpOeHp.js +8 -0
- package/dist/gateway/static/root/assets/{oauth-provider-connect-BW7zcXfb.js → oauth-provider-connect-BexlZuZ4.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-Cw58-5P3.js → page-context-capture-button-Cn4zi3Mt.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-1-lflHAx.js +1 -0
- package/dist/gateway/static/root/assets/personal-avatar-CM3vUGhL.js +1 -0
- package/dist/gateway/static/root/assets/personal-avatar-DsEp8QJ7.css +1 -0
- package/dist/gateway/static/root/assets/personal-page-HFjWZacf.js +1 -0
- package/dist/gateway/static/root/assets/{personal-profile-settings-CDrzvI35.js → personal-profile-settings-CNI5Eor6.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CoZ3qWSr.js → personal-settings-panel-BcrpYRn9.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-UHVwbC3H.js → phone-model-connection-DKvOEjWH.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-fS2IT-dK.js → phone-settings-page-DvX6okzz.js} +1 -1
- package/dist/gateway/static/root/assets/playback-coordinator-CWHIf0wr.js +1 -0
- package/dist/gateway/static/root/assets/presentation-D-Ui_vVA.js +1 -0
- package/dist/gateway/static/root/assets/preview-runtime-RnBDP-Lq.js +15 -0
- package/dist/gateway/static/root/assets/product-automation-feedback-xAcXeJM2.js +7 -0
- package/dist/gateway/static/root/assets/product-delivery-4gEqUIsK.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-BMJ2x5m3.js → product-open-page-DXwOPgRP.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-lkkZPvMa.js → product-preview-content-DiQbeaCK.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-DtUBJGs5.js → product-preview-modal-BU7Qojpq.js} +2 -2
- package/dist/gateway/static/root/assets/project-detail-page-Dr5_WPRB.js +7 -0
- package/dist/gateway/static/root/assets/{projects-page-Dua6taaG.js → projects-page-DGATZB23.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-B6eZLEnh.js → providers-api-BXa2Aheb.js} +1 -1
- package/dist/gateway/static/root/assets/recording-upload-CQdhrRq3.js +1 -0
- package/dist/gateway/static/root/assets/{remote-access-hub-Dy3-oGK1.js → remote-access-hub-_7tmWand.js} +1 -1
- package/dist/gateway/static/root/assets/right-workspace-store-NXMrEuwH.js +1 -0
- package/dist/gateway/static/root/assets/route-preload-D-pdVwIK.js +2 -0
- package/dist/gateway/static/root/assets/routine-panel-rjq-8nZ8.js +2 -0
- package/dist/gateway/static/root/assets/scan-search-CSIGkseh.js +1 -0
- package/dist/gateway/static/root/assets/{service-recommendation-list-CsU74h1b.js → service-recommendation-list-2UOjV0Mx.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-BVS3zxRZ.js +22 -0
- package/dist/gateway/static/root/assets/{settings-page-ByFNIBfp.js → settings-page-bCW4rave.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-Bsn4Wa4p.js → setup-interaction-page-BYXDX0F2.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CstjOb7g.js → setup-status-panel-Bhda3jS2.js} +1 -1
- package/dist/gateway/static/root/assets/share-preview-page-nzWjWhqF.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-LB3SYKFS.js +1 -0
- package/dist/gateway/static/root/assets/sheet-C2H8iR8Y.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-CkkHufmv.js → skills-page-CfhEcU8L.js} +1 -1
- package/dist/gateway/static/root/assets/space-api-DaKpHc_7.js +1 -0
- package/dist/gateway/static/root/assets/space-page-BXyQdUvp.js +2 -0
- package/dist/gateway/static/root/assets/star-BuMAkjC9.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-gffrDRvW.js +3 -0
- package/dist/gateway/static/root/assets/task-header-title-DwtjUOBg.js +1 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-dtN1sSjU.js → task-result-evidence-Bmgta9z9.js} +1 -1
- package/dist/gateway/static/root/assets/tasks-BIehlq7k.js +1 -0
- package/dist/gateway/static/root/assets/turn-outcome-BSbEJx8h.js +1 -0
- package/dist/gateway/static/root/assets/use-composer-attachments-sszsCdh5.js +2 -0
- package/dist/gateway/static/root/assets/use-file-preview-expanded-D4b4fDeu.js +1 -0
- package/dist/gateway/static/root/assets/use-personal-profile-CNPszzzT.js +1 -0
- package/dist/gateway/static/root/assets/use-personal-work-C-rw8XVO.js +1 -0
- package/dist/gateway/static/root/assets/{use-realtime-voice-lRHVixh4.js → use-realtime-voice-cugjs8cK.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-DrWnW1aA.js → use-workspace-tree-Crfx5ctU.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-Bw1_PGdD.js → user-model-page-BvnLbTYx.js} +1 -1
- package/dist/gateway/static/root/assets/video-generation-Cec49Jwg.js +1 -0
- package/dist/gateway/static/root/assets/voice-player-store-DZGlzjva.js +1 -0
- package/dist/gateway/static/root/assets/voice-settings-BzfNK5Jm.js +1 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DcZS4OMj.js → work-discovery-overlay-DpEYgcG2.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-CZF9iWPT.js → work-discovery-page-DappIHQq.js} +1 -1
- package/dist/gateway/static/root/assets/workspace-api-g-wCKoQU.js +2 -0
- package/dist/gateway/static/root/assets/workspace-file-preview-dialog-DxaxVC3q.js +1 -0
- package/dist/gateway/static/root/assets/workspace-preview-store-DoIjn_2j.js +1 -0
- package/dist/gateway/static/root/index.html +90 -77
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +7 -0
- package/dist/packages/gateway-contract/src/capabilities.js +1 -1
- package/dist/packages/gateway-contract/src/clarifications.js +20 -2
- package/dist/packages/gateway-contract/src/index.js +6 -4
- package/dist/packages/gateway-contract/src/space.js +23 -0
- package/dist/packages/gateway-contract/src/task-lifecycle.js +1 -0
- package/dist/packages/gateway-contract/src/task-result-delivery.js +1 -0
- package/dist/packages/gateway-contract/src/task-runs.js +1 -0
- package/dist/packages/gateway-contract/src/tasks.js +118 -6
- package/dist/packages/gateway-contract/src/turn-outcome.js +16 -2
- package/dist/packages/gateway-contract/src/video-generation.js +29 -4
- package/dist/src/agent/agent-manager.js +2 -2
- package/dist/src/agent/embedded/agent-profile-context.js +1 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
- package/dist/src/agent/orchestration/delegation-budget.d.ts +2 -2
- package/dist/src/agent/orchestration/turn-recovery.d.ts +12 -3
- package/dist/src/agent/orchestration/turn-recovery.js +25 -6
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/service/webchat-tts.js +1 -1
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +1 -1
- package/dist/src/agent/tools/apply-patch.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -0
- package/dist/src/agent/tools/language-diagnostics.js +1 -1
- package/dist/src/agent/tools/personal-task-tool.d.ts +1 -0
- package/dist/src/agent/tools/personal-task-tool.js +12 -7
- package/dist/src/agent/tools/publish-artifacts.js +2 -1
- package/dist/src/agent/tools/review-workspace.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -0
- package/dist/src/agent/tools/tool-media.d.ts +3 -1
- package/dist/src/agent/tools/tool-media.js +2 -0
- package/dist/src/agent/tools/xopc-use-tool.js +21 -4
- package/dist/src/agent-catalog/test-support.js +1 -1
- package/dist/src/agent-matching/delegation-service.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/write.d.ts +30 -6
- package/dist/src/automations/capabilities/write.js +2 -2
- package/dist/src/automations/configuration-conversation.js +1 -1
- package/dist/src/automations/domain/types.d.ts +6 -0
- package/dist/src/automations/domain/validation.d.ts +60 -12
- package/dist/src/automations/domain/validation.js +7 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +12 -3
- package/dist/src/automations/draft/automation-draft-validator.js +1 -0
- package/dist/src/automations/service/action-executor.js +14 -2
- package/dist/src/automations/service/automation-service.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/computer/diagnostics.d.ts +9 -9
- package/dist/src/computer/errors.d.ts +2 -2
- package/dist/src/computer/evaluation.d.ts +7 -7
- package/dist/src/computer/runtime.d.ts +4 -4
- package/dist/src/config/schema.d.ts +2 -2
- package/dist/src/discussions/action-tasks.d.ts +2 -2
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/extensions/agent-plugins/inventory.d.ts +2 -2
- package/dist/src/extensions/agent-plugins/setup.d.ts +3 -3
- package/dist/src/gateway/hono/routes/commands-skills.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +2 -2
- package/dist/src/gateway/hono/routes/context-sources.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/music-generation.js +2 -0
- package/dist/src/gateway/hono/routes/personal-agent.js +214 -5
- package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
- package/dist/src/gateway/hono/routes/space.d.ts +3 -0
- package/dist/src/gateway/hono/routes/space.js +105 -0
- package/dist/src/gateway/hono/routes/tasks.js +27 -28
- package/dist/src/gateway/hono/routes/video-generation.js +8 -5
- package/dist/src/gateway/html-preview-shell.d.ts +1 -1
- package/dist/src/gateway/html-preview-shell.js +3 -0
- package/dist/src/gateway/media-access.js +2 -2
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +10 -3
- package/dist/src/gateway/session-context-summary.js +1 -1
- package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +2 -0
- package/dist/src/gateway/xopc-cloud-capability-setup.js +18 -1
- package/dist/src/home-intelligence/follow-ups.js +2 -1
- package/dist/src/home-intelligence/routines.js +1 -1
- package/dist/src/local-apps/automation-proposals.d.ts +54 -12
- package/dist/src/local-apps/capabilities/projections.d.ts +7 -7
- package/dist/src/local-apps/preview-fixtures.d.ts +1 -1
- package/dist/src/media/session-references.d.ts +4 -1
- package/dist/src/media/session-references.js +40 -8
- package/dist/src/music-generation/artifact.js +3 -1
- package/dist/src/music-generation/providers.js +26 -15
- package/dist/src/music-generation/repository.js +8 -1
- package/dist/src/music-generation/xopc-cloud.d.ts +2 -0
- package/dist/src/music-generation/xopc-cloud.js +38 -0
- package/dist/src/personal-agent/capability-service.js +1 -1
- package/dist/src/personal-agent/proactivity/service.js +1 -1
- package/dist/src/personal-agent/prompt-context.js +1 -1
- package/dist/src/personal-agent/prompts.js +1 -1
- package/dist/src/personal-agent/reply-composer.js +16 -7
- package/dist/src/personal-agent/repository.js +1 -1
- package/dist/src/personal-agent/request-delivery.js +17 -7
- package/dist/src/personal-agent/request-service.js +6 -10
- package/dist/src/personal-agent/result-extraction.js +13 -13
- package/dist/src/personal-agent/schedules.d.ts +9 -0
- package/dist/src/personal-agent/schedules.js +44 -0
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/providers/model-catalog-persistence.js +6 -1
- package/dist/src/providers/model-catalog-store.js +1 -0
- package/dist/src/providers/model-catalog-types.d.ts +2 -0
- package/dist/src/providers/xopc-cloud-media-manifest.d.ts +24 -0
- package/dist/src/providers/xopc-cloud-media-manifest.js +28 -0
- package/dist/src/providers/xopc-cloud-media.d.ts +28 -0
- package/dist/src/providers/xopc-cloud-media.js +67 -0
- package/dist/src/providers/xopc-cloud-model-source.js +4 -0
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/runtime-tools/manager.js +1 -1
- package/dist/src/runtime-tools/phone-dependencies.js +1 -1
- package/dist/src/session/client-history.d.ts +4 -1
- package/dist/src/session/client-history.js +18 -0
- package/dist/src/session/compact-history.js +30 -1
- package/dist/src/session/turn-outcome-projector.js +1 -1
- package/dist/src/space/ingest.d.ts +36 -0
- package/dist/src/space/ingest.js +149 -0
- package/dist/src/space/repository.d.ts +39 -0
- package/dist/src/space/repository.js +325 -0
- package/dist/src/space/worker.d.ts +14 -0
- package/dist/src/space/worker.js +199 -0
- package/dist/src/storage/sqlite/clarification-wait-repository.js +7 -4
- package/dist/src/storage/sqlite/row-mappers.d.ts +1 -0
- package/dist/src/storage/sqlite/row-mappers.js +9 -2
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +8 -7
- package/dist/src/storage/sqlite/schema.sql +103 -0
- package/dist/src/storage/sqlite/transcript-repository.js +8 -0
- package/dist/src/storage/sqlite/upgrades/279_task_model_cutover.sql +288 -0
- package/dist/src/storage/sqlite/upgrades/280_space.sql +61 -0
- package/dist/src/tasks/capabilities/management.d.ts +15 -2
- package/dist/src/tasks/capabilities/management.js +8 -2
- package/dist/src/tasks/capabilities/read.js +14 -2
- package/dist/src/tasks/capabilities/relations.d.ts +13 -7
- package/dist/src/tasks/capabilities/write.d.ts +118 -2
- package/dist/src/tasks/capabilities/write.js +2 -0
- package/dist/src/tasks/home-query-service.js +7 -9
- package/dist/src/tasks/task-allocation-service.js +2 -2
- package/dist/src/tasks/task-application-service.d.ts +8 -2
- package/dist/src/tasks/task-application-service.js +94 -27
- package/dist/src/tasks/task-collaboration-repository.js +12 -1
- package/dist/src/tasks/task-context-assembler.js +9 -3
- package/dist/src/tasks/task-contract-planner.js +1 -3
- package/dist/src/tasks/task-conversation-summary.d.ts +33 -2
- package/dist/src/tasks/task-conversation-summary.js +3 -1
- package/dist/src/tasks/task-criterion-review-repository.d.ts +31 -2
- package/dist/src/tasks/task-criterion-review-repository.js +70 -23
- package/dist/src/tasks/task-deliverables.d.ts +7 -0
- package/dist/src/tasks/task-deliverables.js +112 -0
- package/dist/src/tasks/task-handoff-service.js +1 -1
- package/dist/src/tasks/task-instruction-sequence.js +10 -3
- package/dist/src/tasks/task-json-acceptance.js +3 -5
- package/dist/src/tasks/task-origin-repository.d.ts +99 -1
- package/dist/src/tasks/task-origin-repository.js +67 -5
- package/dist/src/tasks/task-read-model-projector.d.ts +4 -1
- package/dist/src/tasks/task-read-model-projector.js +123 -9
- package/dist/src/tasks/task-repository.d.ts +4 -1
- package/dist/src/tasks/task-repository.js +34 -11
- package/dist/src/tasks/task-research-repair.d.ts +2 -2
- package/dist/src/tasks/task-research-result.d.ts +1 -0
- package/dist/src/tasks/task-research-result.js +13 -3
- package/dist/src/tasks/task-result-delivery-repository.d.ts +4 -3
- package/dist/src/tasks/task-result-delivery-repository.js +35 -17
- package/dist/src/tasks/task-result-delivery-service.js +22 -7
- package/dist/src/tasks/task-result-versions.d.ts +11 -0
- package/dist/src/tasks/task-result-versions.js +34 -0
- package/dist/src/tasks/task-run-coordinator.js +28 -15
- package/dist/src/tasks/task-run-dispatcher.js +29 -4
- package/dist/src/tasks/task-run-repository.d.ts +2 -0
- package/dist/src/tasks/task-run-repository.js +62 -19
- package/dist/src/tasks/task-workspace-verification.d.ts +16 -0
- package/dist/src/tasks/task-workspace-verification.js +95 -0
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/video-generation/artifact.js +3 -1
- package/dist/src/video-generation/drafts.js +4 -0
- package/dist/src/video-generation/providers.d.ts +1 -0
- package/dist/src/video-generation/providers.js +37 -5
- package/dist/src/video-generation/repository.js +8 -1
- package/dist/src/video-generation/settings.d.ts +1 -0
- package/dist/src/video-generation/settings.js +10 -4
- package/dist/src/voice/realtime/runtime.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/attachment-preview-renderer-DdOEgexg.js +0 -12
- package/dist/gateway/static/root/assets/attachment-utils-core-BIOUBrpT.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BWpA-X_S.js +0 -9
- package/dist/gateway/static/root/assets/binary-plugins-BjEE5sVq.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-EmBa4Blq.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-BQf7oyqc.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-hlByP8SE.js +0 -8
- package/dist/gateway/static/root/assets/channels-oyMymJDx.js +0 -1
- package/dist/gateway/static/root/assets/chat-page-hcsqrv-7.js +0 -71
- package/dist/gateway/static/root/assets/constants-Bg1wM2nv.js +0 -1
- package/dist/gateway/static/root/assets/extension-authoritative-grants-CVQ7q0DU.js +0 -1
- package/dist/gateway/static/root/assets/file-tree-CFlZnV3Y.js +0 -1
- package/dist/gateway/static/root/assets/index-DFa0pZhC.js +0 -11
- package/dist/gateway/static/root/assets/index-DHPaL7Ku.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-OSinc6m6.js +0 -1
- package/dist/gateway/static/root/assets/local-apps-DeqzkJiF.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-BJxQ_Jd5.js +0 -2
- package/dist/gateway/static/root/assets/models-hub-cache-CmdULYFt.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CVEG1JdF.js +0 -7
- package/dist/gateway/static/root/assets/note-image-lightbox-WA8FiHsm.js +0 -1
- package/dist/gateway/static/root/assets/notes-api-BQXOYFQ5.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-Cc-c1Yhg.js +0 -8
- package/dist/gateway/static/root/assets/page-header-store-DwFwq_lI.js +0 -1
- package/dist/gateway/static/root/assets/personal-avatar-B-Oes3ef.js +0 -1
- package/dist/gateway/static/root/assets/personal-avatar-BUCb7OiW.css +0 -1
- package/dist/gateway/static/root/assets/personal-page-DWPu-iwK.js +0 -1
- package/dist/gateway/static/root/assets/phone-DdhTnt6X.js +0 -1
- package/dist/gateway/static/root/assets/product-automation-feedback-DrBclzH1.js +0 -7
- package/dist/gateway/static/root/assets/product-delivery-CnvCn9L-.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-DGFUj6jS.js +0 -7
- package/dist/gateway/static/root/assets/recording-upload-DXxD6grq.js +0 -1
- package/dist/gateway/static/root/assets/right-workspace-store-BzXnZDK5.js +0 -1
- package/dist/gateway/static/root/assets/route-preload-8KCgPcjp.js +0 -2
- package/dist/gateway/static/root/assets/routine-panel-BALhliq6.js +0 -2
- package/dist/gateway/static/root/assets/session-manager-Cby6Nkib.js +0 -25
- package/dist/gateway/static/root/assets/share-preview-page-9pOnypJv.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-CJdVDQqf.js +0 -1
- package/dist/gateway/static/root/assets/star-CnYNmpLd.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BjBkKeIf.js +0 -3
- package/dist/gateway/static/root/assets/tasks-BTLabOMp.js +0 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-BEYkb8cs.js +0 -2
- package/dist/gateway/static/root/assets/use-file-preview-expanded-CQeo2Ztn.js +0 -15
- package/dist/gateway/static/root/assets/use-personal-profile-CKm5FaTl.js +0 -1
- package/dist/gateway/static/root/assets/video-generation-D08uZbsu.js +0 -1
- package/dist/gateway/static/root/assets/voice-settings-CssuMBjt.js +0 -1
- package/dist/gateway/static/root/assets/with-selector-xonYxPoM.js +0 -1
- package/dist/gateway/static/root/assets/workspace-api-BfApIXLw.js +0 -2
- package/dist/gateway/static/root/assets/workspace-file-preview-dialog-BRhsCs1S.js +0 -1
- package/dist/gateway/static/root/assets/workspace-preview-store-BrofEVle.js +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { parseTurnOutcome } from "../../packages/gateway-contract/src/turn-outcome.js";
|
|
2
|
+
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
3
|
+
import { tryParseMediaUri } from "../media/uri.js";
|
|
4
|
+
import { mimeTypeFromMediaPath, resolveMediaBufferPath } from "../media/store.js";
|
|
5
|
+
import { lstatSync } from "node:fs";
|
|
6
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
+
//#region src/space/ingest.ts
|
|
8
|
+
init_src();
|
|
9
|
+
const SPACE_VIDEO_MAX_BYTES = 256 * 1024 * 1024;
|
|
10
|
+
function insertOrigin(db, origin, itemId, versionId) {
|
|
11
|
+
db.prepare(`INSERT INTO space_origins(source_key, item_id, version_id, kind, conversation_id, transcript_id,
|
|
12
|
+
entry_id, project_id, task_id, automation_run_id, label) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(origin.key, itemId, versionId, origin.kind, origin.conversationId, origin.transcriptId ?? null, origin.entryId ?? null, origin.projectId ?? null, origin.taskId ?? null, origin.automationRunId ?? null, origin.label ?? null);
|
|
13
|
+
}
|
|
14
|
+
function archiveSpaceContent(db, origin, identity, title, content, userInitiated = false) {
|
|
15
|
+
const receipt = db.prepare("SELECT item_id FROM space_origins WHERE source_key = ?").get(origin.key);
|
|
16
|
+
if (receipt) {
|
|
17
|
+
if (!userInitiated) return receipt.item_id;
|
|
18
|
+
if (typeof receipt.item_id === "string") {
|
|
19
|
+
db.prepare("UPDATE space_items SET trashed_at = NULL, revision = revision + 1 WHERE id = ? AND trashed_at IS NOT NULL").run(receipt.item_id);
|
|
20
|
+
return receipt.item_id;
|
|
21
|
+
}
|
|
22
|
+
db.prepare("DELETE FROM space_origins WHERE source_key = ?").run(origin.key);
|
|
23
|
+
}
|
|
24
|
+
const mediaKey = content.mediaId ? `media:${content.mediaId}` : void 0;
|
|
25
|
+
if (!userInitiated && mediaKey && db.prepare("SELECT 1 FROM space_origins WHERE source_key = ? AND item_id IS NULL").get(mediaKey)) return null;
|
|
26
|
+
const existing = db.prepare(`SELECT i.id, v.created_at
|
|
27
|
+
FROM space_items i JOIN space_versions v ON v.id = i.current_version_id WHERE i.identity_key = ?`).get(identity);
|
|
28
|
+
const itemId = existing?.id ?? randomUUID();
|
|
29
|
+
const sameMedia = content.mediaId ? db.prepare("SELECT id FROM space_versions WHERE item_id = ? AND media_id = ?").get(itemId, content.mediaId)?.id : void 0;
|
|
30
|
+
if (sameMedia) {
|
|
31
|
+
insertOrigin(db, origin, itemId, String(sameMedia));
|
|
32
|
+
return itemId;
|
|
33
|
+
}
|
|
34
|
+
const versionId = randomUUID();
|
|
35
|
+
if (!existing) db.prepare("INSERT INTO space_items(id, identity_key, title, kind, current_version_id, updated_at) VALUES (?, ?, ?, ?, ?, ?)").run(itemId, identity, title.slice(0, 240), content.kind, versionId, origin.createdAt);
|
|
36
|
+
const ordinal = Number(db.prepare("SELECT COALESCE(MAX(ordinal), 0) + 1 AS ordinal FROM space_versions WHERE item_id = ?").get(itemId)?.ordinal);
|
|
37
|
+
db.prepare(`INSERT INTO space_versions(id, item_id, ordinal, file_name, mime_type, size_bytes, media_id, body, sha256, created_at)
|
|
38
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(versionId, itemId, ordinal, content.fileName, content.mimeType, content.size, content.mediaId ?? null, content.body ?? null, content.sha256 ?? null, origin.createdAt);
|
|
39
|
+
if (existing && origin.createdAt >= Number(existing.created_at)) db.prepare("UPDATE space_items SET current_version_id = ?, updated_at = ?, revision = revision + 1 WHERE id = ?").run(versionId, origin.createdAt, itemId);
|
|
40
|
+
insertOrigin(db, origin, itemId, versionId);
|
|
41
|
+
if (mediaKey && !db.prepare("SELECT 1 FROM space_origins WHERE source_key = ?").get(mediaKey)) insertOrigin(db, {
|
|
42
|
+
...origin,
|
|
43
|
+
key: mediaKey
|
|
44
|
+
}, itemId, versionId);
|
|
45
|
+
return itemId;
|
|
46
|
+
}
|
|
47
|
+
function spaceMarkdown(title, body) {
|
|
48
|
+
return {
|
|
49
|
+
fileName: `${title.replace(/[\\/\u0000-\u001f]/g, "_").slice(0, 120)}.md`,
|
|
50
|
+
mimeType: "text/markdown",
|
|
51
|
+
size: Buffer.byteLength(body),
|
|
52
|
+
kind: "document",
|
|
53
|
+
body,
|
|
54
|
+
sha256: createHash("sha256").update(body).digest("hex")
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function archiveFile(db, origin, file) {
|
|
58
|
+
if (file.availability !== "available" || file.location !== "artifact_store" || !file.uri) return;
|
|
59
|
+
const media = tryParseMediaUri(file.uri);
|
|
60
|
+
if (media?.bucket !== "outbound") return;
|
|
61
|
+
if (media.id === ".." || media.id === ".") return;
|
|
62
|
+
const path = resolveMediaBufferPath(media.id, media.bucket);
|
|
63
|
+
const stat = safeMediaStat(path);
|
|
64
|
+
if (!stat?.isFile() || stat.size > 52428800 || file.sizeBytes !== void 0 && file.sizeBytes !== stat.size) return;
|
|
65
|
+
const identity = db.prepare("SELECT i.identity_key FROM space_versions v JOIN space_items i ON i.id = v.item_id WHERE v.media_id = ? LIMIT 1").get(media.id)?.identity_key;
|
|
66
|
+
archiveSpaceContent(db, origin, typeof identity === "string" ? identity : `media:${media.id}`, file.title, {
|
|
67
|
+
kind: file.kind,
|
|
68
|
+
mediaId: media.id,
|
|
69
|
+
fileName: file.title,
|
|
70
|
+
mimeType: file.mimeType ?? mimeTypeFromMediaPath(path),
|
|
71
|
+
size: stat.size,
|
|
72
|
+
sha256: file.sha256
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function archiveSpaceTurn(db, source) {
|
|
76
|
+
const outcome = parseTurnOutcome(source.outcome);
|
|
77
|
+
if (!outcome?.deliverables.length) return;
|
|
78
|
+
if (db.prepare("SELECT 1 FROM task_runs WHERE conversation_id = ? LIMIT 1").get(source.conversationId)) return;
|
|
79
|
+
const session = db.prepare("SELECT name, project_id FROM sessions WHERE conversation_id = ?").get(source.conversationId);
|
|
80
|
+
if (!session) return;
|
|
81
|
+
const automation = db.prepare(`SELECT run_id, automation_name FROM automation_runs WHERE conversation_id = ?
|
|
82
|
+
AND COALESCE(started_at_ms, created_at_ms) <= ? AND (ended_at_ms IS NULL OR ended_at_ms >= ?)
|
|
83
|
+
ORDER BY created_at_ms DESC LIMIT 1`).get(source.conversationId, source.createdAt, source.createdAt - 5e3);
|
|
84
|
+
for (const file of outcome.deliverables) archiveFile(db, {
|
|
85
|
+
...source,
|
|
86
|
+
key: `turn:${source.entryId}:${file.artifactId}`,
|
|
87
|
+
kind: automation ? "automation" : "chat",
|
|
88
|
+
projectId: session.project_id ?? void 0,
|
|
89
|
+
label: automation?.automation_name ?? session.name ?? void 0,
|
|
90
|
+
automationRunId: automation?.run_id
|
|
91
|
+
}, file);
|
|
92
|
+
}
|
|
93
|
+
function archiveSpaceTaskDelivery(db, delivery, entryId) {
|
|
94
|
+
const project = db.prepare("SELECT project_id FROM tasks WHERE task_id = ?").get(delivery.taskId);
|
|
95
|
+
const origin = {
|
|
96
|
+
kind: "task",
|
|
97
|
+
conversationId: delivery.conversationId,
|
|
98
|
+
transcriptId: delivery.originTranscriptId,
|
|
99
|
+
entryId,
|
|
100
|
+
projectId: project?.project_id ?? void 0,
|
|
101
|
+
taskId: delivery.taskId,
|
|
102
|
+
label: delivery.taskTitle,
|
|
103
|
+
createdAt: delivery.createdAt
|
|
104
|
+
};
|
|
105
|
+
for (const file of delivery.outcome.deliverables) archiveFile(db, {
|
|
106
|
+
...origin,
|
|
107
|
+
key: `delivery:${delivery.deliveryId}:${file.artifactId}`
|
|
108
|
+
}, file);
|
|
109
|
+
const body = (delivery.text ?? delivery.outcome.research?.finalText)?.trim();
|
|
110
|
+
if (body && body !== "NO_REPLY") archiveSpaceContent(db, {
|
|
111
|
+
...origin,
|
|
112
|
+
key: `delivery-body:${delivery.deliveryId}`
|
|
113
|
+
}, `task-body:${delivery.taskId}`, delivery.taskTitle, spaceMarkdown(delivery.taskTitle, body));
|
|
114
|
+
}
|
|
115
|
+
function safeMediaStat(path) {
|
|
116
|
+
try {
|
|
117
|
+
return lstatSync(path, { throwIfNoEntry: false });
|
|
118
|
+
} catch {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function archiveSpaceGeneratedMedia(db, kind, id) {
|
|
123
|
+
const job = kind === "music" ? db.prepare("SELECT conversation_id, transcript_id, title, work_id, created_at FROM music_generation_jobs WHERE id = ? AND state = 'completed'").get(id) : db.prepare("SELECT conversation_id, transcript_id, prompt AS title, created_at FROM video_generation_jobs WHERE id = ? AND state = 'completed'").get(id);
|
|
124
|
+
if (!job || !/^[a-f0-9-]{32,64}$/i.test(id)) return;
|
|
125
|
+
const conversationId = String(job.conversation_id);
|
|
126
|
+
const session = db.prepare("SELECT name, project_id FROM sessions WHERE conversation_id = ?").get(conversationId);
|
|
127
|
+
if (!session) return;
|
|
128
|
+
const mediaId = kind === "music" ? `music-${id}.mp3` : `wan-${id}.mp4`;
|
|
129
|
+
const stat = safeMediaStat(resolveMediaBufferPath(mediaId, "outbound"));
|
|
130
|
+
if (!stat?.isFile() || !stat.size || stat.size > 268435456) return;
|
|
131
|
+
const title = String(job.title).trim().slice(0, 120) || (kind === "music" ? "Music" : "Video");
|
|
132
|
+
archiveSpaceContent(db, {
|
|
133
|
+
key: `generation:${kind}:${id}`,
|
|
134
|
+
kind: "chat",
|
|
135
|
+
conversationId,
|
|
136
|
+
transcriptId: String(job.transcript_id),
|
|
137
|
+
createdAt: Number(job.created_at),
|
|
138
|
+
projectId: session.project_id ?? void 0,
|
|
139
|
+
label: session.name ?? void 0
|
|
140
|
+
}, kind === "music" ? `music-work:${String(job.work_id)}` : `media:${mediaId}`, title, {
|
|
141
|
+
fileName: `${title.replace(/[\\/\u0000-\u001f]/g, "_")}.${kind === "music" ? "mp3" : "mp4"}`,
|
|
142
|
+
mimeType: kind === "music" ? "audio/mpeg" : "video/mp4",
|
|
143
|
+
size: stat.size,
|
|
144
|
+
kind: kind === "music" ? "audio" : "video",
|
|
145
|
+
mediaId
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { SPACE_VIDEO_MAX_BYTES, archiveSpaceContent, archiveSpaceGeneratedMedia, archiveSpaceTaskDelivery, archiveSpaceTurn, spaceMarkdown };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SpaceArtifactLink, SpaceDetail, SpaceList, SpaceVersion, SpaceVersionLink } from '@xopcai/gateway-contract';
|
|
2
|
+
import { parseByteRange } from '../media-shared/http/byte-range.js';
|
|
3
|
+
export declare const SPACE_TRASH_RETENTION_MS: number;
|
|
4
|
+
export declare function getSpaceItem(id: string): SpaceDetail | null;
|
|
5
|
+
type ListInput = {
|
|
6
|
+
view: 'all' | 'favorites' | 'trash';
|
|
7
|
+
q?: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
projectId?: string;
|
|
10
|
+
taskId?: string;
|
|
11
|
+
cursor?: string;
|
|
12
|
+
versionTargetFor?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function spaceHanPairs(text: string): string;
|
|
15
|
+
export declare function listSpaceItems(input: ListInput): SpaceList;
|
|
16
|
+
type SpaceLink = {
|
|
17
|
+
id: string;
|
|
18
|
+
versionId?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function findSpaceArtifact(mediaId: string): SpaceArtifactLink | null;
|
|
21
|
+
export declare function saveSpaceVersion(id: string, sourceVersionId: string, revision: number): SpaceVersionLink | 'missing' | 'conflict';
|
|
22
|
+
export declare function findSpaceTaskDelivery(deliveryId: string): SpaceLink | null;
|
|
23
|
+
export declare function saveSpaceReply(conversationId: string, reference: string | {
|
|
24
|
+
turnId: string;
|
|
25
|
+
}): string | null;
|
|
26
|
+
export declare function changeSpaceItem(id: string, revision: number, patch: {
|
|
27
|
+
title?: string;
|
|
28
|
+
favorite?: boolean;
|
|
29
|
+
trash?: boolean;
|
|
30
|
+
}): 'ok' | 'missing' | 'conflict';
|
|
31
|
+
export declare function purgeSpaceItem(id: string, revision: number): 'ok' | 'missing' | 'conflict';
|
|
32
|
+
type SpaceContent = {
|
|
33
|
+
body: Uint8Array<ArrayBuffer> | ReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
34
|
+
version: SpaceVersion;
|
|
35
|
+
range: ReturnType<typeof parseByteRange>;
|
|
36
|
+
size: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function readSpaceContent(itemId: string, versionId: string, rangeHeader?: string): Promise<SpaceContent | null>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { resolveMediaBufferPath } from "../media/store.js";
|
|
3
|
+
import { archiveSpaceContent, spaceMarkdown } from "./ingest.js";
|
|
4
|
+
import { escapeFts5Query, escapeSqlLike, init_fts } from "../storage/sqlite/fts.js";
|
|
5
|
+
import { parseByteRange } from "../media-shared/http/byte-range.js";
|
|
6
|
+
import { constants, lstatSync } from "node:fs";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { open } from "node:fs/promises";
|
|
9
|
+
import { Readable } from "node:stream";
|
|
10
|
+
//#region src/space/repository.ts
|
|
11
|
+
init_fts();
|
|
12
|
+
init_transaction();
|
|
13
|
+
const SPACE_TRASH_RETENTION_MS = 720 * 60 * 6e4;
|
|
14
|
+
const itemSelect = `SELECT v.id, v.ordinal, v.file_name, v.mime_type, v.size_bytes, v.created_at, v.index_status,
|
|
15
|
+
i.id AS item_id, i.title, i.kind, i.favorite, i.trashed_at, i.updated_at, i.revision`;
|
|
16
|
+
const itemJoin = "FROM space_items i JOIN space_versions v ON v.id = i.current_version_id";
|
|
17
|
+
function version(row) {
|
|
18
|
+
return {
|
|
19
|
+
id: row.id,
|
|
20
|
+
ordinal: row.ordinal,
|
|
21
|
+
fileName: row.file_name,
|
|
22
|
+
mimeType: row.mime_type,
|
|
23
|
+
sizeBytes: row.size_bytes,
|
|
24
|
+
createdAt: row.created_at,
|
|
25
|
+
indexStatus: row.index_status
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function origins(id) {
|
|
29
|
+
return getSqliteDatabase().prepare(`SELECT o.*, CASE WHEN o.kind = 'task'
|
|
30
|
+
THEN EXISTS(SELECT 1 FROM tasks WHERE task_id = o.task_id)
|
|
31
|
+
WHEN o.kind = 'automation' THEN EXISTS(SELECT 1 FROM automation_runs WHERE run_id = o.automation_run_id)
|
|
32
|
+
ELSE EXISTS(SELECT 1 FROM sessions s WHERE s.conversation_id = o.conversation_id)
|
|
33
|
+
AND (o.entry_id IS NULL OR EXISTS(SELECT 1 FROM transcript_entries e WHERE e.entry_id = o.entry_id)) END AS available
|
|
34
|
+
FROM space_origins o WHERE o.item_id = ? AND o.source_key NOT LIKE 'media:%'
|
|
35
|
+
ORDER BY available DESC, CASE o.kind WHEN 'task' THEN 0 WHEN 'automation' THEN 1 ELSE 2 END, o.rowid DESC LIMIT 30`).all(id).map((row) => ({
|
|
36
|
+
kind: row.kind,
|
|
37
|
+
versionId: row.version_id ?? void 0,
|
|
38
|
+
conversationId: row.conversation_id,
|
|
39
|
+
transcriptId: row.transcript_id ?? void 0,
|
|
40
|
+
entryId: row.entry_id ?? void 0,
|
|
41
|
+
projectId: row.project_id ?? void 0,
|
|
42
|
+
taskId: row.task_id ?? void 0,
|
|
43
|
+
automationRunId: row.automation_run_id ?? void 0,
|
|
44
|
+
label: row.label ?? void 0,
|
|
45
|
+
available: Boolean(row.available)
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
function item(row, origin) {
|
|
49
|
+
return {
|
|
50
|
+
id: row.item_id,
|
|
51
|
+
title: row.title,
|
|
52
|
+
kind: row.kind,
|
|
53
|
+
favorite: Boolean(row.favorite),
|
|
54
|
+
trashedAt: row.trashed_at,
|
|
55
|
+
updatedAt: row.updated_at,
|
|
56
|
+
revision: row.revision,
|
|
57
|
+
currentVersion: version(row),
|
|
58
|
+
origin,
|
|
59
|
+
...row.hit_body !== void 0 && row.hit_body !== null ? { hit: {
|
|
60
|
+
text: row.hit_body,
|
|
61
|
+
locator: JSON.parse(row.hit_locator ?? "{}")
|
|
62
|
+
} } : {}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function getSpaceItem(id) {
|
|
66
|
+
const db = getSqliteDatabase();
|
|
67
|
+
const row = db.prepare(`${itemSelect} ${itemJoin} WHERE i.id = ?`).get(id);
|
|
68
|
+
if (!row) return null;
|
|
69
|
+
const source = origins(id);
|
|
70
|
+
return {
|
|
71
|
+
...item(row, source[0]),
|
|
72
|
+
origins: source,
|
|
73
|
+
versions: db.prepare("SELECT * FROM space_versions WHERE item_id = ? ORDER BY created_at DESC, ordinal DESC").all(id).map(version)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function versionKind(kind) {
|
|
77
|
+
return kind === "pdf" ? "document" : kind;
|
|
78
|
+
}
|
|
79
|
+
function versionSource(versionId) {
|
|
80
|
+
return getSqliteDatabase().prepare(`SELECT v.item_id, v.media_id, v.size_bytes, i.kind, i.favorite,
|
|
81
|
+
NOT EXISTS(SELECT 1 FROM space_versions other WHERE other.item_id = v.item_id AND other.id != v.id) AS standalone
|
|
82
|
+
FROM space_versions v JOIN space_items i ON i.id = v.item_id
|
|
83
|
+
WHERE v.id = ? AND v.media_id IS NOT NULL AND i.trashed_at IS NULL`).get(versionId);
|
|
84
|
+
}
|
|
85
|
+
function spaceHanPairs(text) {
|
|
86
|
+
const terms = /* @__PURE__ */ new Set();
|
|
87
|
+
for (const match of text.matchAll(/\p{Script=Han}{2,}/gu)) {
|
|
88
|
+
const characters = Array.from(match[0]);
|
|
89
|
+
for (let index = 1; index < characters.length; index++) terms.add(characters[index - 1] + characters[index]);
|
|
90
|
+
}
|
|
91
|
+
return [...terms].join(" ");
|
|
92
|
+
}
|
|
93
|
+
function listSpaceItems(input) {
|
|
94
|
+
const db = getSqliteDatabase();
|
|
95
|
+
const q = input.q?.normalize("NFKC").trim().toLowerCase().slice(0, 160) ?? "";
|
|
96
|
+
const pattern = `%${escapeSqlLike(q)}%`;
|
|
97
|
+
const filters = [input.view === "trash" ? "i.trashed_at IS NOT NULL" : "i.trashed_at IS NULL"];
|
|
98
|
+
const params = [];
|
|
99
|
+
if (input.versionTargetFor) {
|
|
100
|
+
const source = versionSource(input.versionTargetFor);
|
|
101
|
+
if (!source?.standalone || input.view === "trash") return { items: [] };
|
|
102
|
+
filters.push("i.id != ? AND CASE i.kind WHEN 'pdf' THEN 'document' ELSE i.kind END = ?");
|
|
103
|
+
params.push(source.item_id, versionKind(String(source.kind)));
|
|
104
|
+
}
|
|
105
|
+
if (input.view === "favorites") filters.push("i.favorite = 1");
|
|
106
|
+
if (input.kind === "document") filters.push("i.kind IN ('document', 'pdf')");
|
|
107
|
+
else if (input.kind === "file") filters.push("i.kind IN ('file', 'site')");
|
|
108
|
+
else if (input.kind) {
|
|
109
|
+
filters.push("i.kind = ?");
|
|
110
|
+
params.push(input.kind);
|
|
111
|
+
}
|
|
112
|
+
if (input.projectId) {
|
|
113
|
+
filters.push("EXISTS(SELECT 1 FROM space_origins o WHERE o.item_id = i.id AND o.project_id = ?)");
|
|
114
|
+
params.push(input.projectId);
|
|
115
|
+
}
|
|
116
|
+
if (input.taskId) {
|
|
117
|
+
filters.push("EXISTS(SELECT 1 FROM space_origins o WHERE o.item_id = i.id AND o.task_id = ?)");
|
|
118
|
+
params.push(input.taskId);
|
|
119
|
+
}
|
|
120
|
+
const index = Array.from(q).length >= 3 ? "space_search" : /^\p{Script=Han}{2}$/u.test(q) ? "space_search_short" : null;
|
|
121
|
+
const titleMatch = "(xopc_space_search_text(i.title) LIKE ? ESCAPE '\\' OR xopc_space_search_text(v.file_name) LIKE ? ESCAPE '\\')";
|
|
122
|
+
const matchCte = index ? `WITH matches AS (
|
|
123
|
+
SELECT version_id, body, locator, row_number() OVER (PARTITION BY version_id ORDER BY rowid) AS hit_number
|
|
124
|
+
FROM ${index} WHERE ${index} MATCH ?${index === "space_search_short" ? " AND instr(body, ?) > 0" : ""}
|
|
125
|
+
)` : "";
|
|
126
|
+
const searchJoin = index ? "LEFT JOIN matches m ON m.version_id = v.id AND m.hit_number = 1" : "";
|
|
127
|
+
const rank = q ? `CASE WHEN xopc_space_search_text(i.title) = ? OR xopc_space_search_text(v.file_name) = ? THEN 0
|
|
128
|
+
WHEN ${titleMatch} THEN 1 ${index ? "WHEN m.version_id IS NOT NULL THEN 2" : ""} ELSE 3 END` : "0";
|
|
129
|
+
if (q) {
|
|
130
|
+
filters.push(`(${titleMatch} OR EXISTS(SELECT 1 FROM space_origins o WHERE o.item_id = i.id AND xopc_space_search_text(o.label) LIKE ? ESCAPE '\\')${index ? " OR m.version_id IS NOT NULL" : ""})`);
|
|
131
|
+
params.push(pattern, pattern, pattern);
|
|
132
|
+
}
|
|
133
|
+
let cursor;
|
|
134
|
+
if (input.cursor) try {
|
|
135
|
+
const parsed = JSON.parse(Buffer.from(input.cursor, "base64url").toString("utf8"));
|
|
136
|
+
if (Array.isArray(parsed) && parsed.length === 3 && Number.isInteger(parsed[0]) && Number.isSafeInteger(parsed[1]) && typeof parsed[2] === "string") cursor = [
|
|
137
|
+
parsed[0],
|
|
138
|
+
parsed[1],
|
|
139
|
+
parsed[2]
|
|
140
|
+
];
|
|
141
|
+
} catch {}
|
|
142
|
+
const bindings = index ? [escapeFts5Query(q), ...index === "space_search_short" ? [q] : []] : [];
|
|
143
|
+
if (q) bindings.push(q, q, pattern, pattern);
|
|
144
|
+
bindings.push(...params);
|
|
145
|
+
if (cursor) bindings.push(cursor[0], cursor[0], cursor[1], cursor[1], cursor[2]);
|
|
146
|
+
const pageSize = 40;
|
|
147
|
+
const rows = db.prepare(`${matchCte} SELECT * FROM (
|
|
148
|
+
${itemSelect}, ${rank} AS rank ${index ? ", m.body AS hit_body, m.locator AS hit_locator" : ""}
|
|
149
|
+
${itemJoin} ${searchJoin} WHERE ${filters.join(" AND ")}
|
|
150
|
+
) ${cursor ? "WHERE rank > ? OR (rank = ? AND (updated_at < ? OR (updated_at = ? AND item_id < ?)))" : ""}
|
|
151
|
+
ORDER BY rank ASC, updated_at DESC, item_id DESC LIMIT ?`).all(...bindings, pageSize + 1);
|
|
152
|
+
const last = rows[pageSize - 1];
|
|
153
|
+
const nextCursor = rows.length > pageSize && last ? Buffer.from(JSON.stringify([
|
|
154
|
+
last.rank,
|
|
155
|
+
last.updated_at,
|
|
156
|
+
last.item_id
|
|
157
|
+
])).toString("base64url") : void 0;
|
|
158
|
+
return {
|
|
159
|
+
items: rows.slice(0, pageSize).map((row) => item(row, origins(row.item_id)[0])),
|
|
160
|
+
nextCursor
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function findSpaceArtifact(mediaId) {
|
|
164
|
+
const row = getSqliteDatabase().prepare(`SELECT i.id, v.id AS version_id,
|
|
165
|
+
NOT EXISTS(SELECT 1 FROM space_versions other WHERE other.item_id = v.item_id AND other.id != v.id) AS standalone
|
|
166
|
+
FROM space_versions v JOIN space_items i ON i.id = v.item_id
|
|
167
|
+
WHERE v.media_id = ? AND i.trashed_at IS NULL LIMIT 1`).get(mediaId);
|
|
168
|
+
return typeof row?.id === "string" ? {
|
|
169
|
+
id: row.id,
|
|
170
|
+
versionId: String(row.version_id),
|
|
171
|
+
canSaveAsVersion: Boolean(row.standalone)
|
|
172
|
+
} : null;
|
|
173
|
+
}
|
|
174
|
+
function saveSpaceVersion(id, sourceVersionId, revision) {
|
|
175
|
+
return runSqliteWriteTransaction((db) => {
|
|
176
|
+
const source = versionSource(sourceVersionId);
|
|
177
|
+
const target = db.prepare(`SELECT i.kind, i.revision, v.created_at FROM space_items i
|
|
178
|
+
JOIN space_versions v ON v.id = i.current_version_id WHERE i.id = ? AND i.trashed_at IS NULL`).get(id);
|
|
179
|
+
if (!source || !target) return "missing";
|
|
180
|
+
if (source.item_id === id) return source.standalone ? "conflict" : {
|
|
181
|
+
id,
|
|
182
|
+
versionId: sourceVersionId
|
|
183
|
+
};
|
|
184
|
+
if (!source.standalone || target.revision !== revision || versionKind(String(source.kind)) !== versionKind(String(target.kind))) return "conflict";
|
|
185
|
+
try {
|
|
186
|
+
const stat = lstatSync(resolveMediaBufferPath(String(source.media_id), "outbound"), { throwIfNoEntry: false });
|
|
187
|
+
if (!stat?.isFile() || stat.size !== source.size_bytes) return "missing";
|
|
188
|
+
} catch {
|
|
189
|
+
return "missing";
|
|
190
|
+
}
|
|
191
|
+
const updatedAt = Math.max(Date.now(), Number(target.created_at));
|
|
192
|
+
const nextOrdinal = db.prepare("SELECT MAX(ordinal) + 1 AS ordinal FROM space_versions WHERE item_id = ?").get(id)?.ordinal ?? 1;
|
|
193
|
+
db.prepare("UPDATE space_versions SET item_id = ?, ordinal = ?, created_at = ? WHERE id = ?").run(id, nextOrdinal, updatedAt, sourceVersionId);
|
|
194
|
+
db.prepare("UPDATE space_origins SET item_id = ? WHERE version_id = ?").run(id, sourceVersionId);
|
|
195
|
+
db.prepare(`UPDATE space_items SET current_version_id = ?, kind = ?, favorite = MAX(favorite, ?),
|
|
196
|
+
updated_at = ?, revision = revision + 1 WHERE id = ?`).run(sourceVersionId, source.kind, source.favorite, updatedAt, id);
|
|
197
|
+
db.prepare("DELETE FROM space_items WHERE id = ?").run(source.item_id);
|
|
198
|
+
return {
|
|
199
|
+
id,
|
|
200
|
+
versionId: sourceVersionId
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function findSpaceTaskDelivery(deliveryId) {
|
|
205
|
+
const id = deliveryId.replace(/^reply:/, "");
|
|
206
|
+
const row = getSqliteDatabase().prepare(`SELECT i.id, o.version_id FROM space_origins o JOIN space_items i ON i.id = o.item_id
|
|
207
|
+
WHERE i.trashed_at IS NULL AND (o.source_key = ? OR o.source_key LIKE ? ESCAPE '\\')
|
|
208
|
+
ORDER BY o.source_key = ? DESC, i.updated_at DESC LIMIT 1`).get(`delivery-body:${id}`, `${escapeSqlLike(`delivery:${id}:`)}%`, `delivery-body:${id}`);
|
|
209
|
+
return typeof row?.id === "string" ? {
|
|
210
|
+
id: row.id,
|
|
211
|
+
versionId: typeof row.version_id === "string" ? row.version_id : void 0
|
|
212
|
+
} : null;
|
|
213
|
+
}
|
|
214
|
+
function saveSpaceReply(conversationId, reference) {
|
|
215
|
+
return runSqliteWriteTransaction((db) => {
|
|
216
|
+
const byEntry = typeof reference === "string";
|
|
217
|
+
const row = db.prepare(`SELECT e.entry_id, e.payload_json, e.transcript_id, e.created_at, s.name, s.project_id
|
|
218
|
+
FROM transcript_entries e JOIN transcripts t ON t.transcript_id = e.transcript_id
|
|
219
|
+
JOIN sessions s ON s.conversation_id = t.conversation_id
|
|
220
|
+
WHERE ${byEntry ? "e.entry_id = ?" : "json_extract(e.payload_json, '$.turnId') = ?"}
|
|
221
|
+
AND t.conversation_id = ? AND e.role = 'assistant' AND e.entry_kind = 'message'
|
|
222
|
+
ORDER BY e.created_at DESC, e.seq DESC LIMIT 1`).get(byEntry ? reference : reference.turnId, conversationId);
|
|
223
|
+
if (!row) return null;
|
|
224
|
+
const message = JSON.parse(String(row.payload_json));
|
|
225
|
+
if (message.metadata?.hiddenFromClient || message.stopReason === "aborted" || message.stopReason === "error") return null;
|
|
226
|
+
const body = typeof message.content === "string" ? message.content.trim() : Array.isArray(message.content) ? message.content.filter((block) => block?.type === "text" && block.presentation !== "narration" && typeof block.text === "string").map((block) => block.text).join("\n\n").trim() : "";
|
|
227
|
+
if (!body || body === "NO_REPLY") return null;
|
|
228
|
+
const title = body.split("\n").find((line) => line.trim())?.replace(/^#+\s*/, "").trim().slice(0, 100) || "Chat reply";
|
|
229
|
+
const entryId = String(row.entry_id);
|
|
230
|
+
const key = `reply:${entryId}`;
|
|
231
|
+
return archiveSpaceContent(db, {
|
|
232
|
+
key,
|
|
233
|
+
kind: "chat",
|
|
234
|
+
conversationId,
|
|
235
|
+
entryId,
|
|
236
|
+
transcriptId: String(row.transcript_id),
|
|
237
|
+
createdAt: Date.now(),
|
|
238
|
+
label: row.name ?? void 0,
|
|
239
|
+
projectId: row.project_id ?? void 0
|
|
240
|
+
}, key, title, spaceMarkdown(title, body), true);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function changeSpaceItem(id, revision, patch) {
|
|
244
|
+
return runSqliteWriteTransaction((db) => {
|
|
245
|
+
const row = db.prepare("SELECT revision, trashed_at FROM space_items WHERE id = ?").get(id);
|
|
246
|
+
if (!row) return "missing";
|
|
247
|
+
if (row.revision !== revision) return "conflict";
|
|
248
|
+
if (row.trashed_at !== null && patch.trash !== false) return "conflict";
|
|
249
|
+
if (row.trashed_at === null && patch.trash === false) return "conflict";
|
|
250
|
+
db.prepare(`UPDATE space_items SET title = COALESCE(?, title), favorite = COALESCE(?, favorite),
|
|
251
|
+
trashed_at = CASE ? WHEN 1 THEN ? WHEN 0 THEN NULL ELSE trashed_at END, revision = revision + 1
|
|
252
|
+
WHERE id = ?`).run(patch.title ?? null, patch.favorite === void 0 ? null : Number(patch.favorite), patch.trash === void 0 ? null : Number(patch.trash), Date.now(), id);
|
|
253
|
+
return "ok";
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function purgeSpaceItem(id, revision) {
|
|
257
|
+
return runSqliteWriteTransaction((db) => {
|
|
258
|
+
const row = db.prepare("SELECT revision, trashed_at FROM space_items WHERE id = ?").get(id);
|
|
259
|
+
if (!row) return "missing";
|
|
260
|
+
if (row.revision !== revision || row.trashed_at === null) return "conflict";
|
|
261
|
+
db.prepare("DELETE FROM space_search WHERE version_id IN (SELECT id FROM space_versions WHERE item_id = ?)").run(id);
|
|
262
|
+
db.prepare("DELETE FROM space_search_short WHERE version_id IN (SELECT id FROM space_versions WHERE item_id = ?)").run(id);
|
|
263
|
+
db.prepare("INSERT OR IGNORE INTO space_media_cleanup SELECT media_id FROM space_versions WHERE item_id = ? AND media_id IS NOT NULL").run(id);
|
|
264
|
+
db.prepare("DELETE FROM space_items WHERE id = ?").run(id);
|
|
265
|
+
return "ok";
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
async function readSpaceContent(itemId, versionId, rangeHeader) {
|
|
269
|
+
const row = getSqliteDatabase().prepare("SELECT * FROM space_versions WHERE item_id = ? AND id = ?").get(itemId, versionId);
|
|
270
|
+
if (!row) return null;
|
|
271
|
+
const size = row.size_bytes;
|
|
272
|
+
const range = parseByteRange(rangeHeader, size);
|
|
273
|
+
const metadata = {
|
|
274
|
+
version: version(row),
|
|
275
|
+
size,
|
|
276
|
+
range
|
|
277
|
+
};
|
|
278
|
+
if (range === "invalid") return {
|
|
279
|
+
...metadata,
|
|
280
|
+
body: null
|
|
281
|
+
};
|
|
282
|
+
if (row.body !== null) {
|
|
283
|
+
const bytes = Uint8Array.from(Buffer.from(row.body));
|
|
284
|
+
return {
|
|
285
|
+
...metadata,
|
|
286
|
+
body: range ? bytes.subarray(range.start, range.end + 1) : bytes
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
if (!row.media_id) return null;
|
|
290
|
+
try {
|
|
291
|
+
const handle = await open(resolveMediaBufferPath(row.media_id, "outbound"), constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
292
|
+
let handedOff = false;
|
|
293
|
+
try {
|
|
294
|
+
const stat = await handle.stat();
|
|
295
|
+
if (!stat.isFile() || stat.size !== size || stat.size > (row.mime_type === "video/mp4" ? 268435456 : 52428800)) return null;
|
|
296
|
+
if (!row.sha256) {
|
|
297
|
+
const stream = handle.createReadStream(range ?? void 0);
|
|
298
|
+
const body = Readable.toWeb(stream);
|
|
299
|
+
handedOff = true;
|
|
300
|
+
return {
|
|
301
|
+
...metadata,
|
|
302
|
+
body
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const bytes = new Uint8Array(size);
|
|
306
|
+
let offset = 0;
|
|
307
|
+
while (offset < bytes.length) {
|
|
308
|
+
const { bytesRead } = await handle.read(bytes, offset, bytes.length - offset, offset);
|
|
309
|
+
if (!bytesRead) return null;
|
|
310
|
+
offset += bytesRead;
|
|
311
|
+
}
|
|
312
|
+
if (createHash("sha256").update(bytes).digest("hex") !== row.sha256) return null;
|
|
313
|
+
return {
|
|
314
|
+
...metadata,
|
|
315
|
+
body: range ? bytes.subarray(range.start, range.end + 1) : bytes
|
|
316
|
+
};
|
|
317
|
+
} finally {
|
|
318
|
+
if (!handedOff) await handle.close();
|
|
319
|
+
}
|
|
320
|
+
} catch {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
//#endregion
|
|
325
|
+
export { SPACE_TRASH_RETENTION_MS, changeSpaceItem, findSpaceArtifact, findSpaceTaskDelivery, getSpaceItem, listSpaceItems, purgeSpaceItem, readSpaceContent, saveSpaceReply, saveSpaceVersion, spaceHanPairs };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class SpaceWorker {
|
|
2
|
+
private timer?;
|
|
3
|
+
private parser?;
|
|
4
|
+
private maintenance?;
|
|
5
|
+
private indexing?;
|
|
6
|
+
private preferNewest;
|
|
7
|
+
private checkedPdfRecovery;
|
|
8
|
+
start(): void;
|
|
9
|
+
stop(): Promise<void>;
|
|
10
|
+
private tick;
|
|
11
|
+
private maintain;
|
|
12
|
+
private indexNext;
|
|
13
|
+
private index;
|
|
14
|
+
}
|