@xopcai/xopc 0.0.468 → 0.0.469
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-CZUfwwLp.css +1 -0
- package/dist/gateway/static/root/assets/index-D5hovYIw.js +11 -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
|
@@ -5,12 +5,13 @@ import { TurnOutcomeSchema } from "../../packages/gateway-contract/src/turn-outc
|
|
|
5
5
|
import { TaskResultDeliverySchema } from "../../packages/gateway-contract/src/task-result-delivery.js";
|
|
6
6
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
7
7
|
import { TaskRepository, init_task_repository } from "./task-repository.js";
|
|
8
|
+
import { init_task_instruction_sequence, taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
9
|
+
import { finalizedTaskResultId, init_task_result_versions, recordTaskResultVersion } from "./task-result-versions.js";
|
|
8
10
|
import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
|
|
9
11
|
import { init_request_repository, personalRequestForTask } from "../personal-agent/request-repository.js";
|
|
10
12
|
import { TaskConversationRepository } from "./task-conversation-repository.js";
|
|
11
13
|
import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
|
|
12
14
|
import { hasPersonalResultFileLinks, sanitizePersonalResultFileLinks } from "../personal-agent/result-file-links.js";
|
|
13
|
-
import { taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
14
15
|
import { finalReplyCharacterLimit } from "./task-final-reply.js";
|
|
15
16
|
import { randomUUID } from "node:crypto";
|
|
16
17
|
//#region src/tasks/task-result-delivery-repository.ts
|
|
@@ -20,6 +21,8 @@ init_task_run_repository();
|
|
|
20
21
|
init_logger();
|
|
21
22
|
init_request_repository();
|
|
22
23
|
init_task_repository();
|
|
24
|
+
init_task_instruction_sequence();
|
|
25
|
+
init_task_result_versions();
|
|
23
26
|
const log = createLogger("TaskResultDelivery");
|
|
24
27
|
const queuedListeners = /* @__PURE__ */ new Set();
|
|
25
28
|
function onTaskResultQueued(listener) {
|
|
@@ -30,7 +33,7 @@ function onTaskResultQueued(listener) {
|
|
|
30
33
|
}
|
|
31
34
|
var TaskResultDeliveryRepository = class {
|
|
32
35
|
/** Only cards persisted in this conversation's current transcript confirm file delivery. */
|
|
33
|
-
fileDeliveryState(taskId, conversationId) {
|
|
36
|
+
fileDeliveryState(taskId, conversationId, includeArtifact = false) {
|
|
34
37
|
const db = getSqliteDatabase();
|
|
35
38
|
const run = new TaskRunRepository().getLatestRoot(taskId);
|
|
36
39
|
const row = run && db.prepare(`SELECT payload_json, status, message_entry_id FROM task_result_deliveries
|
|
@@ -45,14 +48,21 @@ var TaskResultDeliveryRepository = class {
|
|
|
45
48
|
status: "stale",
|
|
46
49
|
availableFileCount: 0
|
|
47
50
|
};
|
|
48
|
-
const
|
|
51
|
+
const availableFiles = delivery.outcome.deliverables.filter((item) => item.availability === "available");
|
|
52
|
+
const availableFileCount = availableFiles.length;
|
|
49
53
|
const inCurrentTranscript = row.message_entry_id && db.prepare(`SELECT 1 FROM transcript_entries entry
|
|
50
54
|
JOIN sessions session ON session.active_transcript_id = entry.transcript_id
|
|
51
55
|
WHERE entry.entry_id = ? AND session.conversation_id = ?`).get(row.message_entry_id, conversationId);
|
|
56
|
+
const artifact = includeArtifact && row.status === "delivered" && inCurrentTranscript ? availableFiles.find((item) => item.uri && item.capabilities.some((capability) => [
|
|
57
|
+
"open",
|
|
58
|
+
"preview",
|
|
59
|
+
"download"
|
|
60
|
+
].includes(capability)) && (!item.expiresAt || Date.parse(item.expiresAt) > Date.now())) : void 0;
|
|
52
61
|
return {
|
|
53
62
|
status: row.status === "delivered" && (!availableFileCount || !inCurrentTranscript) ? "not_delivered" : row.status,
|
|
54
63
|
availableFileCount: row.status === "delivered" && inCurrentTranscript ? availableFileCount : 0,
|
|
55
|
-
resultId: delivery.deliveryId
|
|
64
|
+
resultId: delivery.deliveryId,
|
|
65
|
+
...artifact ? { artifact } : {}
|
|
56
66
|
};
|
|
57
67
|
}
|
|
58
68
|
capture(runId, value) {
|
|
@@ -62,20 +72,27 @@ var TaskResultDeliveryRepository = class {
|
|
|
62
72
|
changeSet: void 0
|
|
63
73
|
});
|
|
64
74
|
if (outcome.deliverables.length > 50 || JSON.stringify(outcome).length > 256e3) throw new Error("Task outcome exceeds delivery limits");
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
runSqliteWriteTransaction((db) => {
|
|
76
|
+
const run = new TaskRunRepository().get(runId);
|
|
77
|
+
if (!run || ![
|
|
78
|
+
"running",
|
|
79
|
+
"waiting",
|
|
80
|
+
"verifying"
|
|
81
|
+
].includes(run.status)) return;
|
|
82
|
+
const state = new TaskConversationRepository().getState(run.taskId);
|
|
83
|
+
if (!state || state.activeConversationId !== run.conversationId) return;
|
|
84
|
+
if (db.prepare(`INSERT INTO task_run_outcomes
|
|
74
85
|
(task_run_id, outcome_id, assignment_epoch, outcome_json, created_at)
|
|
75
|
-
VALUES (?, ?, ?, ?, ?) ON CONFLICT(task_run_id, outcome_id) DO NOTHING`).run(runId, outcome.outcomeId, state.assignmentEpoch, JSON.stringify(outcome), Date.now())
|
|
86
|
+
VALUES (?, ?, ?, ?, ?) ON CONFLICT(task_run_id, outcome_id) DO NOTHING`).run(runId, outcome.outcomeId, state.assignmentEpoch, JSON.stringify(outcome), Date.now()).changes) recordTaskResultVersion({
|
|
87
|
+
runId,
|
|
88
|
+
assignmentEpoch: state.assignmentEpoch,
|
|
89
|
+
outcomeId: outcome.outcomeId,
|
|
90
|
+
instructionSequence: outcome.research?.instructionSequence ?? run.instructionSequenceAtStart ?? 0
|
|
91
|
+
});
|
|
92
|
+
});
|
|
76
93
|
}
|
|
77
94
|
/** Called inside the run completion transaction, after stale receipts are rejected. */
|
|
78
|
-
enqueue(runId, summary, status, resultText, hostArtifact) {
|
|
95
|
+
enqueue(runId, summary, status, resultText, hostArtifact, incompleteWorkspace = false) {
|
|
79
96
|
const db = getSqliteDatabase();
|
|
80
97
|
const run = new TaskRunRepository().get(runId);
|
|
81
98
|
if (!run || run.parentRunId) return false;
|
|
@@ -92,7 +109,7 @@ var TaskResultDeliveryRepository = class {
|
|
|
92
109
|
const research = hostArtifact?.sha256 ? void 0 : [...outcomes].reverse().find((outcome) => outcome.research)?.research;
|
|
93
110
|
const task = new TaskRepository().require(run.taskId);
|
|
94
111
|
const validResearch = research && research.contractVersion === task.latestContractVersion && research.instructionSequence === taskInstructionSequence(task.id) ? research : void 0;
|
|
95
|
-
const selectionRequired =
|
|
112
|
+
const selectionRequired = task.contract?.resultPolicy === "selected";
|
|
96
113
|
const researchGap = selectionRequired && !research && !hostArtifact?.sha256 || Boolean(research && (!validResearch || !validResearch.checks.length || validResearch.checks.length !== task.contract?.acceptanceCriteria.length || validResearch.checks.some((check) => check.status !== "passed") || validResearch.instructionChecks?.some((check) => check.status !== "passed") || validResearch.claims.some((claim) => claim.support !== "supported")));
|
|
97
114
|
const artifacts = /* @__PURE__ */ new Map();
|
|
98
115
|
for (const outcome of outcomes) for (const item of outcome.deliverables) artifacts.set(item.sourceFileId ?? item.artifactId, item);
|
|
@@ -119,7 +136,7 @@ var TaskResultDeliveryRepository = class {
|
|
|
119
136
|
evidence: [],
|
|
120
137
|
changeSet: void 0,
|
|
121
138
|
summary: replyTooLong ? void 0 : summary,
|
|
122
|
-
status: selectedManifest ? status === "failed" || researchGap || selectedMissing || unpublishedFile || replyTooLong || deliverables.some((item) => item.availability !== "available") ? "partial" : "succeeded" : latest.status === "failed" ? "failed" : status === "failed" || latest.status === "partial" || hostArtifact && !verifiedArtifact || unpublishedFile || replyTooLong || researchGap || deliverables.some((item) => item.availability !== "available") ? "partial" : "succeeded"
|
|
139
|
+
status: incompleteWorkspace ? "partial" : selectedManifest ? status === "failed" || researchGap || selectedMissing || unpublishedFile || replyTooLong || deliverables.some((item) => item.availability !== "available") ? "partial" : "succeeded" : latest.status === "failed" ? "failed" : status === "failed" || latest.status === "partial" || hostArtifact && !verifiedArtifact || unpublishedFile || replyTooLong || researchGap || deliverables.some((item) => item.availability !== "available") ? "partial" : "succeeded"
|
|
123
140
|
};
|
|
124
141
|
const now = Date.now();
|
|
125
142
|
const previous = db.prepare(`SELECT delivery_id, payload_json FROM task_result_deliveries WHERE task_run_id IN
|
|
@@ -141,6 +158,7 @@ var TaskResultDeliveryRepository = class {
|
|
|
141
158
|
deliveryId: randomUUID(),
|
|
142
159
|
taskId: run.taskId,
|
|
143
160
|
taskRunId: runId,
|
|
161
|
+
taskResultId: finalizedTaskResultId(runId),
|
|
144
162
|
taskTitle: origin.title,
|
|
145
163
|
conversationId: origin.conversation_id,
|
|
146
164
|
originTranscriptId: origin.origin_transcript_id,
|
|
@@ -3,7 +3,12 @@ import { init_logger } from "../utils/logger.js";
|
|
|
3
3
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
4
4
|
import { TaskResultDeliverySchema } from "../../packages/gateway-contract/src/task-result-delivery.js";
|
|
5
5
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
6
|
+
import { tryParseMediaUri } from "../media/uri.js";
|
|
7
|
+
import { resolveMediaBufferPath } from "../media/store.js";
|
|
8
|
+
import { archiveSpaceTaskDelivery } from "../space/ingest.js";
|
|
9
|
+
import { enqueueTaskChangedEvent, init_task_change_events } from "./task-change-events.js";
|
|
6
10
|
import { TaskRepository, init_task_repository } from "./task-repository.js";
|
|
11
|
+
import { taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
7
12
|
import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
|
|
8
13
|
import { init_request_repository, personalRequestForTask } from "../personal-agent/request-repository.js";
|
|
9
14
|
import { appendTranscriptEntry } from "../storage/sqlite/transcript-repository.js";
|
|
@@ -11,10 +16,7 @@ import { getPersonalAgentByConversation } from "../personal-agent/repository.js"
|
|
|
11
16
|
import { emitSessionTranscriptUpdate } from "../session/transcript-events.js";
|
|
12
17
|
import { resolveTaskLocale } from "./task-language.js";
|
|
13
18
|
import { TaskConversationRepository } from "./task-conversation-repository.js";
|
|
14
|
-
import { taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
15
19
|
import { TaskResultDeliveryRepository } from "./task-result-delivery-repository.js";
|
|
16
|
-
import { tryParseMediaUri } from "../media/uri.js";
|
|
17
|
-
import { resolveMediaBufferPath } from "../media/store.js";
|
|
18
20
|
import { warmPersonalResult } from "../personal-agent/result-reader.js";
|
|
19
21
|
import "./task-research-result.js";
|
|
20
22
|
import { recordPersonalPerformance } from "../personal-agent/performance.js";
|
|
@@ -29,6 +31,7 @@ init_logger();
|
|
|
29
31
|
init_request_repository();
|
|
30
32
|
init_task_repository();
|
|
31
33
|
init_task_run_repository();
|
|
34
|
+
init_task_change_events();
|
|
32
35
|
const log = createLogger("TaskResultDelivery");
|
|
33
36
|
async function materializedArtifact(item) {
|
|
34
37
|
const { workspaceRelativePath: _path, thumbnailUrl: _thumbnail, ...artifact } = item;
|
|
@@ -99,8 +102,8 @@ var TaskResultDeliveryService = class {
|
|
|
99
102
|
const run = new TaskRunRepository().get(delivery.taskRunId);
|
|
100
103
|
const state = new TaskConversationRepository().getState(delivery.taskId);
|
|
101
104
|
const session = db.prepare("SELECT active_transcript_id FROM sessions WHERE conversation_id = ?").get(delivery.conversationId);
|
|
102
|
-
const task = db.prepare("SELECT resolution FROM tasks WHERE task_id = ?").get(delivery.taskId);
|
|
103
|
-
if (delivery.instructionSequence !== void 0 && delivery.instructionSequence !== taskInstructionSequence(delivery.taskId) || !session || !run || !["succeeded", "failed"].includes(run.status) || task.resolution && task.resolution !== "done" || new TaskRunRepository().getLatestRoot(delivery.taskId)?.id !== run.id || state?.assignmentEpoch !== delivery.assignmentEpoch || state.activeConversationId !== run.conversationId) {
|
|
105
|
+
const task = db.prepare("SELECT resolution, latest_contract_version FROM tasks WHERE task_id = ?").get(delivery.taskId);
|
|
106
|
+
if (delivery.instructionSequence !== void 0 && delivery.instructionSequence !== taskInstructionSequence(delivery.taskId) || !session || !run || !["succeeded", "failed"].includes(run.status) || delivery.contractVersion !== void 0 && delivery.contractVersion !== task.latest_contract_version || task.resolution && task.resolution !== "done" || new TaskRunRepository().getLatestRoot(delivery.taskId)?.id !== run.id || state?.assignmentEpoch !== delivery.assignmentEpoch || state.activeConversationId !== run.conversationId) {
|
|
104
107
|
db.prepare("UPDATE task_result_deliveries SET status = 'stale' WHERE delivery_id = ?").run(row.delivery_id);
|
|
105
108
|
return false;
|
|
106
109
|
}
|
|
@@ -110,7 +113,8 @@ var TaskResultDeliveryService = class {
|
|
|
110
113
|
deliverables,
|
|
111
114
|
status: deliverables.length > 0 && available === 0 ? "failed" : available < deliverables.length ? "partial" : delivery.outcome.status
|
|
112
115
|
};
|
|
113
|
-
const
|
|
116
|
+
const currentTask = new TaskRepository().require(delivery.taskId);
|
|
117
|
+
const statusText = resolveTaskLocale(currentTask) === "zh" ? `${delivery.taskTitle}:${outcome.status === "failed" ? "请求未完成" : outcome.status === "partial" ? "部分内容已完成" : deliverables.length ? "成果已生成" : "结果已返回"}。` : `${delivery.taskTitle}: ${outcome.status === "failed" ? "Request incomplete" : outcome.status === "partial" ? "Partial results ready" : deliverables.length ? "Results ready" : "Result returned"}.`;
|
|
114
118
|
const personal = getPersonalAgentByConversation(delivery.conversationId);
|
|
115
119
|
if (personal) warmPersonalResult(delivery.conversationId, delivery.deliveryId);
|
|
116
120
|
if (personal && (delivery.text || !outcome.research?.finalText) && !personalRequestForTask(delivery.taskId)) enqueuePersonalReply({
|
|
@@ -119,7 +123,7 @@ var TaskResultDeliveryService = class {
|
|
|
119
123
|
outcome
|
|
120
124
|
},
|
|
121
125
|
report: delivery.text?.trim() || delivery.outcome.summary?.trim() || statusText,
|
|
122
|
-
objective:
|
|
126
|
+
objective: currentTask.contract?.objective ?? delivery.taskTitle
|
|
123
127
|
});
|
|
124
128
|
const content = personal || !delivery.text ? statusText : delivery.text === outcome.research?.finalText ? delivery.text : `${statusText}\n\n${delivery.text}`;
|
|
125
129
|
const details = {
|
|
@@ -140,6 +144,17 @@ var TaskResultDeliveryService = class {
|
|
|
140
144
|
...delivery,
|
|
141
145
|
outcome
|
|
142
146
|
}), entry?.entry_id ?? null, Date.now(), row.delivery_id);
|
|
147
|
+
archiveSpaceTaskDelivery(db, {
|
|
148
|
+
...delivery,
|
|
149
|
+
outcome
|
|
150
|
+
}, entry?.entry_id);
|
|
151
|
+
if (deliverables.length && currentTask.phase === "review") enqueueTaskChangedEvent(db, {
|
|
152
|
+
taskId: currentTask.id,
|
|
153
|
+
projectId: currentTask.projectId,
|
|
154
|
+
version: currentTask.version,
|
|
155
|
+
changedFields: ["acceptance", "receipts"],
|
|
156
|
+
source: "runtime"
|
|
157
|
+
});
|
|
143
158
|
return true;
|
|
144
159
|
})) continue;
|
|
145
160
|
const saved = getSqliteDatabase().prepare("SELECT message_entry_id, delivered_at FROM task_result_deliveries WHERE delivery_id = ?").get(row.delivery_id);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TaskResultVersion } from '@xopcai/gateway-contract';
|
|
2
|
+
export declare function finalizedTaskResultId(runId: string): string | undefined;
|
|
3
|
+
export declare function recordTaskResultVersion(input: {
|
|
4
|
+
runId: string;
|
|
5
|
+
assignmentEpoch: number;
|
|
6
|
+
instructionSequence: number;
|
|
7
|
+
outcomeId?: string;
|
|
8
|
+
finalizedAt?: number;
|
|
9
|
+
workspaceFiles?: unknown[];
|
|
10
|
+
}): void;
|
|
11
|
+
export declare function listTaskResultVersions(taskId: string): TaskResultVersion[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
3
|
+
//#region src/tasks/task-result-versions.ts
|
|
4
|
+
function finalizedTaskResultId(runId) {
|
|
5
|
+
return getSqliteDatabase().prepare("SELECT result_id FROM task_results WHERE run_id = ? AND finalized_at IS NOT NULL").get(runId)?.result_id;
|
|
6
|
+
}
|
|
7
|
+
function recordTaskResultVersion(input) {
|
|
8
|
+
getSqliteDatabase().prepare(`INSERT INTO task_results
|
|
9
|
+
(result_id, run_id, version, assignment_epoch, instruction_sequence, outcome_id, finalized_at, workspace_files_json)
|
|
10
|
+
SELECT ? || ':' || next.version, ?, next.version, ?, ?, ?, ?, ?
|
|
11
|
+
FROM (SELECT COALESCE(MAX(version), 0) + 1 AS version FROM task_results WHERE run_id = ?) next`).run(input.runId, input.runId, input.assignmentEpoch, input.instructionSequence, input.outcomeId ?? null, input.finalizedAt ?? null, JSON.stringify(input.workspaceFiles ?? []), input.runId);
|
|
12
|
+
}
|
|
13
|
+
function listTaskResultVersions(taskId) {
|
|
14
|
+
return getSqliteDatabase().prepare(`SELECT result.result_id AS id, result.run_id AS runId, result.version,
|
|
15
|
+
run.contract_version AS contractVersion, result.assignment_epoch AS assignmentEpoch,
|
|
16
|
+
result.instruction_sequence AS instructionSequence, result.outcome_id AS outcomeId, result.finalized_at AS finalizedAt
|
|
17
|
+
FROM task_results result JOIN task_runs run ON run.run_id = result.run_id
|
|
18
|
+
WHERE run.task_id = ? ORDER BY run.queued_at DESC, run.rowid DESC, result.version DESC LIMIT 100`).all(taskId).map((row) => ({
|
|
19
|
+
id: String(row.id),
|
|
20
|
+
runId: String(row.runId),
|
|
21
|
+
version: Number(row.version),
|
|
22
|
+
contractVersion: Number(row.contractVersion),
|
|
23
|
+
assignmentEpoch: Number(row.assignmentEpoch),
|
|
24
|
+
instructionSequence: Number(row.instructionSequence),
|
|
25
|
+
...row.outcomeId !== null ? { outcomeId: String(row.outcomeId) } : {},
|
|
26
|
+
...row.finalizedAt !== null ? { finalizedAt: Number(row.finalizedAt) } : {}
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
var init_task_result_versions = __esmMin((() => {
|
|
30
|
+
init_transaction();
|
|
31
|
+
}));
|
|
32
|
+
//#endregion
|
|
33
|
+
init_task_result_versions();
|
|
34
|
+
export { finalizedTaskResultId, init_task_result_versions, listTaskResultVersions, recordTaskResultVersion };
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import { init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { taskCheckId } from "../../packages/gateway-contract/src/tasks.js";
|
|
3
|
+
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
2
4
|
import { TaskRepository, init_task_repository } from "./task-repository.js";
|
|
5
|
+
import { taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
6
|
+
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
3
7
|
import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
|
|
4
8
|
import { loadTranscriptRowsForSession } from "../storage/sqlite/transcript-repository.js";
|
|
5
9
|
import "../storage/sqlite/index.js";
|
|
6
|
-
import { AgentCatalogRepository, init_repository } from "../agent-catalog/repository.js";
|
|
7
10
|
import { isTransientProviderErrorMessage } from "../providers/model-response.js";
|
|
8
|
-
import { ACCEPTANCE_REPAIR_READ_TOOLS,
|
|
11
|
+
import { ACCEPTANCE_REPAIR_READ_TOOLS, RECOVERY_READ_TOOLS, findUnconfirmedToolEffect } from "../agent/orchestration/turn-recovery.js";
|
|
9
12
|
import { isPersonalConversation } from "../personal-agent/repository.js";
|
|
10
13
|
import { resolveTaskLocale } from "./task-language.js";
|
|
11
14
|
import { TaskAllocationRepository } from "./task-allocation-repository.js";
|
|
12
|
-
import { TaskOriginRepository } from "./task-origin-repository.js";
|
|
13
15
|
import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
|
|
14
|
-
import { taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
15
16
|
import { isChatReplyOutput } from "./task-final-reply.js";
|
|
16
17
|
import { TaskResultDeliveryRepository } from "./task-result-delivery-repository.js";
|
|
18
|
+
import { TaskOriginRepository } from "./task-origin-repository.js";
|
|
17
19
|
import { TaskContextRepository } from "./task-context-repository.js";
|
|
18
20
|
import { getTaskHandoff } from "./task-handoff.js";
|
|
19
21
|
import { TaskApplicationService } from "./task-application-service.js";
|
|
20
22
|
import { savedExecutionRequirements } from "./task-execution-capabilities.js";
|
|
21
23
|
import { currentTaskJsonAcceptance, verifyTaskJsonPublication } from "./task-json-acceptance.js";
|
|
22
24
|
import { personalRequestReviewSnapshot } from "../personal-agent/request-verification.js";
|
|
23
|
-
import { currentTaskResearchResult } from "./task-research-result.js";
|
|
25
|
+
import { currentTaskResearchResult, verifiesTaskInstructions } from "./task-research-result.js";
|
|
24
26
|
import { buildResearchRepair, inspectTaskPublications } from "./task-research-repair.js";
|
|
25
27
|
//#region src/tasks/task-run-coordinator.ts
|
|
28
|
+
init_src();
|
|
26
29
|
init_repository();
|
|
27
30
|
init_transaction();
|
|
28
31
|
init_task_repository();
|
|
@@ -180,12 +183,19 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
180
183
|
const task = new TaskRepository().require(run.taskId);
|
|
181
184
|
const research = currentTaskResearchResult(run.id);
|
|
182
185
|
const personalSnapshot = personalRequestReviewSnapshot(task.id, run.id);
|
|
183
|
-
const
|
|
186
|
+
const instructionSequence = taskInstructionSequence(task.id);
|
|
187
|
+
const instructionsChanged = instructionSequence !== (run.instructionSequenceAtStart ?? 0);
|
|
188
|
+
const currentResearch = research && (!personalSnapshot || personalSnapshot.hash && personalSnapshot.hash === research.personalResultHash) && research.contractVersion === task.latestContractVersion && research.instructionSequence === instructionSequence ? research : void 0;
|
|
184
189
|
const emptySuccess = input.status === "succeeded" && !hasAssistantResult && !hasBoardResult && !currentResearch?.finalText && !this.#hasDeliverables && this.#evidence.length === 0;
|
|
185
190
|
const zh = resolveTaskLocale(task) === "zh";
|
|
186
191
|
const status = emptySuccess ? "failed" : input.status;
|
|
187
|
-
const recoveryOptions = {
|
|
188
|
-
|
|
192
|
+
const recoveryOptions = {
|
|
193
|
+
allowFailedReadTools: ACCEPTANCE_REPAIR_READ_TOOLS,
|
|
194
|
+
allowMissingReadTools: RECOVERY_READ_TOOLS
|
|
195
|
+
};
|
|
196
|
+
let recoveryCheck;
|
|
197
|
+
const unconfirmedEffect = () => (recoveryCheck ??= { effect: run.conversationId ? findUnconfirmedToolEffect(loadTranscriptRowsForSession(run.conversationId), recoveryOptions) : void 0 }).effect;
|
|
198
|
+
const unconfirmedEffects = status === "failed" ? unconfirmedEffect() : void 0;
|
|
189
199
|
const systemSummaries = {
|
|
190
200
|
"Message processed": "消息已处理",
|
|
191
201
|
Interrupted: "执行已中断",
|
|
@@ -194,10 +204,10 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
194
204
|
const resultSummary = status === "succeeded" && currentResearch?.finalText ? currentResearch.finalText : status === "succeeded" && hasAssistantResult && /^Message processed(?: successfully)?$/.test(input.summary) ? input.assistantText.trim() : input.summary;
|
|
195
205
|
const summary = emptySuccess ? zh ? "助手执行未返回结果或证据" : "Agent run returned no result or evidence" : zh ? systemSummaries[resultSummary] ?? resultSummary : resultSummary;
|
|
196
206
|
const publications = inspectTaskPublications(run.id, currentResearch);
|
|
197
|
-
const
|
|
207
|
+
const directionsReviewed = instructionsChanged && currentResearch && verifiesTaskInstructions(task.id, currentResearch) && !publications.missing.length && !publications.unreviewed.length && (currentResearch.finalText || personalSnapshot?.content || currentResearch.finalArtifactIds?.length) && (currentResearch.finalArtifactIds ?? []).every((id) => currentResearch.inspectedArtifactIds?.includes(id));
|
|
198
208
|
const jsonSpec = status === "succeeded" && !personalSnapshot && !instructionSequence && task.contract?.expectedOutputs.length === 1 && /^[A-Za-z0-9_.-]+\.json$/i.test(task.contract.expectedOutputs[0] ?? "") ? currentTaskJsonAcceptance(task, getTaskHandoff(task.id)) : void 0;
|
|
199
209
|
const publicationCandidate = status === "succeeded" && (!research || jsonSpec) && !personalSnapshot && !instructionSequence ? unreviewedLocalPublication(task, run, publications) : void 0;
|
|
200
|
-
const publication = publicationCandidate && run.conversationId &&
|
|
210
|
+
const publication = publicationCandidate && run.conversationId && !unconfirmedEffect() ? publicationCandidate : void 0;
|
|
201
211
|
const structuralCheck = publication && jsonSpec ? verifyTaskJsonPublication(jsonSpec, publication, zh) : void 0;
|
|
202
212
|
const hostArtifact = publication && (!jsonSpec || structuralCheck) ? {
|
|
203
213
|
id: publication.artifactId,
|
|
@@ -207,15 +217,15 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
207
217
|
const repair = hostArtifact ? void 0 : buildResearchRepair({
|
|
208
218
|
publicationStructureGap: jsonSpec ? zh ? `发布符合全部约定结构的 ${jsonSpec.file}。宿主会直接检查文件名、JSON 格式及约定的对象数量和字段。` : `Publish ${jsonSpec.file} with the agreed JSON structure. The host checks the actual file name, JSON syntax, and any required object count and fields.` : void 0,
|
|
209
219
|
research: currentResearch,
|
|
210
|
-
stale: Boolean(research && !currentResearch),
|
|
220
|
+
stale: Boolean(research && !currentResearch || instructionsChanged && !directionsReviewed),
|
|
211
221
|
instructionSequence,
|
|
212
222
|
publications,
|
|
213
223
|
criteria: task.contract?.acceptanceCriteria ?? [],
|
|
214
224
|
resultFingerprint: personalSnapshot?.hash,
|
|
215
225
|
requiresFinalText: !personalSnapshot && task.contract?.expectedOutputs.some(isChatReplyOutput),
|
|
216
|
-
requiresReview: !jsonSpec && (task.contract?.acceptancePolicy === "verified_auto" ||
|
|
226
|
+
requiresReview: !jsonSpec && (task.contract?.acceptancePolicy === "verified_auto" || task.contract?.resultPolicy === "selected")
|
|
217
227
|
});
|
|
218
|
-
const repairBlocked =
|
|
228
|
+
const repairBlocked = repair ? unconfirmedEffect() : void 0;
|
|
219
229
|
if (status === "failed" && isTransientProviderErrorMessage(input.summary) && !unconfirmedEffects && this.#runs.scheduleContinuation({
|
|
220
230
|
runId: run.id,
|
|
221
231
|
expectedVersion: run.version,
|
|
@@ -242,6 +252,7 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
242
252
|
const checks = structuralCheck?.checks ?? currentResearch?.checks.map((check) => ({
|
|
243
253
|
criterion: check.criterion,
|
|
244
254
|
status: check.status,
|
|
255
|
+
checkId: taskCheckId(task.id, run.contractVersion, check.criterionIndex),
|
|
245
256
|
evidenceTitles: check.claimIds.map((id) => `Research claim: ${id}`),
|
|
246
257
|
note: check.note,
|
|
247
258
|
method: currentResearch.review === "model_reviewed" ? "model_reviewed" : "unverified"
|
|
@@ -265,8 +276,10 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
265
276
|
this.#application.completeRun({
|
|
266
277
|
runId: run.id,
|
|
267
278
|
expectedRunVersion: run.version,
|
|
268
|
-
resultText: hostArtifact ? publicationText : input.assistantText,
|
|
279
|
+
resultText: hostArtifact ? publicationText : directionsReviewed ? currentResearch?.finalText : input.assistantText,
|
|
280
|
+
...directionsReviewed ? { reviewedInstructionSequence: instructionSequence } : {},
|
|
269
281
|
hostArtifact,
|
|
282
|
+
...unconfirmedEffects || repairBlocked ? { unconfirmedEffect: unconfirmedEffects ?? repairBlocked } : {},
|
|
270
283
|
receipt: {
|
|
271
284
|
status: finalStatus,
|
|
272
285
|
summary: hostArtifact ? publicationText : summary,
|
|
@@ -281,7 +294,7 @@ var TaskRunCoordinator = class TaskRunCoordinator {
|
|
|
281
294
|
checks: [...checks, ...instructionChecks]
|
|
282
295
|
},
|
|
283
296
|
remainingWork: repair ? repair.gaps : emptySuccess ? [task.contract?.objective ?? (zh ? "完成任务" : "Complete the task")] : achieved ? [] : status === "succeeded" ? currentResearch ? [...currentResearch.checks.filter((check) => check.status !== "passed").map((check) => check.criterion), ...currentResearch.claims.filter((claim) => claim.support !== "supported").map((claim) => claim.note ?? claim.statement)] : task.contract?.acceptanceCriteria ?? [] : [],
|
|
284
|
-
needsUser: unconfirmedEffects || repairBlocked,
|
|
297
|
+
needsUser: Boolean(unconfirmedEffects || repairBlocked),
|
|
285
298
|
...repairBlocked ? { nextAction: zh ? "先确认上次未确认操作的实际影响,再继续补查。" : "Confirm the effects of the unconfirmed operation before repair." } : {},
|
|
286
299
|
completionVerdict: achieved ? "achieved" : status === "succeeded" ? "partial" : "not_achieved",
|
|
287
300
|
...finalStatus === "failed" ? { failure: {
|
|
@@ -4,7 +4,7 @@ import { TaskRepository, init_task_repository } from "./task-repository.js";
|
|
|
4
4
|
import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
|
|
5
5
|
import { loadTranscriptRowsForSession } from "../storage/sqlite/transcript-repository.js";
|
|
6
6
|
import "../storage/sqlite/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { RECOVERY_READ_TOOLS, findUnconfirmedToolEffect } from "../agent/orchestration/turn-recovery.js";
|
|
8
8
|
import { resolveTaskLocale } from "./task-language.js";
|
|
9
9
|
import { TaskApplicationService } from "./task-application-service.js";
|
|
10
10
|
import { runInIndependentAgentExecution } from "../agent/independent-execution.js";
|
|
@@ -48,7 +48,8 @@ var TaskRunDispatcher = class {
|
|
|
48
48
|
for (const run of this.#runs.listExpiredLeasedRunning()) {
|
|
49
49
|
if (this.#activeRunIds.has(run.id)) continue;
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
const unconfirmedEffect = run.conversationId ? findUnconfirmedToolEffect(loadTranscriptRowsForSession(run.conversationId), { allowMissingReadTools: RECOVERY_READ_TOOLS }) : void 0;
|
|
52
|
+
if (run.conversationId && !unconfirmedEffect && this.#runs.scheduleContinuation({
|
|
52
53
|
runId: run.id,
|
|
53
54
|
expectedVersion: run.version,
|
|
54
55
|
reason: "process_restart",
|
|
@@ -58,6 +59,7 @@ var TaskRunDispatcher = class {
|
|
|
58
59
|
this.#application.completeRun({
|
|
59
60
|
runId: run.id,
|
|
60
61
|
expectedRunVersion: run.version,
|
|
62
|
+
unconfirmedEffect,
|
|
61
63
|
terminalCode: "execution_interrupted",
|
|
62
64
|
terminalMessage: zh ? "任务执行已停止,结果尚未确认" : "Task execution stopped before its result could be confirmed",
|
|
63
65
|
receipt: {
|
|
@@ -112,8 +114,31 @@ var TaskRunDispatcher = class {
|
|
|
112
114
|
}
|
|
113
115
|
}) : run)) continue;
|
|
114
116
|
const agentId = typeof run.executorRef.agentId === "string" ? run.executorRef.agentId : void 0;
|
|
115
|
-
const conversationId = await this.deps.ensureSession(task.id, run.id, agentId);
|
|
117
|
+
const conversationId = task.latestContractVersion === run.contractVersion ? await this.deps.ensureSession(task.id, run.id, agentId) : void 0;
|
|
116
118
|
if (this.#stopped) return;
|
|
119
|
+
if (!conversationId || this.#tasks.get(task.id)?.latestContractVersion !== run.contractVersion) {
|
|
120
|
+
const summary = resolveTaskLocale(task) === "zh" ? "任务要求已更新,本次执行未启动。" : "Task requirements changed before execution.";
|
|
121
|
+
const current = this.#runs.get(run.id);
|
|
122
|
+
if (!current) continue;
|
|
123
|
+
this.#application.completeRun({
|
|
124
|
+
runId: current.id,
|
|
125
|
+
expectedRunVersion: current.version,
|
|
126
|
+
terminalCode: "spec_superseded",
|
|
127
|
+
receipt: {
|
|
128
|
+
status: "cancelled",
|
|
129
|
+
summary,
|
|
130
|
+
changes: [],
|
|
131
|
+
evidence: [],
|
|
132
|
+
verification: {
|
|
133
|
+
status: "unverified",
|
|
134
|
+
checks: []
|
|
135
|
+
},
|
|
136
|
+
remainingWork: [],
|
|
137
|
+
needsUser: false
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
117
142
|
this.deps.validateExecutor?.(task.id, agentId);
|
|
118
143
|
this.#activeRunIds.add(run.id);
|
|
119
144
|
const heartbeat = setInterval(() => {
|
|
@@ -129,7 +154,7 @@ var TaskRunDispatcher = class {
|
|
|
129
154
|
heartbeat.unref?.();
|
|
130
155
|
this.#heartbeats.add(heartbeat);
|
|
131
156
|
try {
|
|
132
|
-
await this.deps.runAgent(run.id, conversationId, buildTaskRunMessage(task.contract?.objective ?? task.title, run.trigger, task.
|
|
157
|
+
await this.deps.runAgent(run.id, conversationId, buildTaskRunMessage(task.contract?.objective ?? task.title, run.trigger, task.contract?.brief, task.id));
|
|
133
158
|
} finally {
|
|
134
159
|
clearInterval(heartbeat);
|
|
135
160
|
this.#heartbeats.delete(heartbeat);
|
|
@@ -74,6 +74,8 @@ export declare class TaskRunRepository {
|
|
|
74
74
|
actor?: ActorRef;
|
|
75
75
|
terminalCode?: string;
|
|
76
76
|
terminalMessage?: string;
|
|
77
|
+
reviewedInstructionSequence?: number;
|
|
78
|
+
workspaceFiles?: unknown[];
|
|
77
79
|
now?: number;
|
|
78
80
|
}): TaskRun | undefined;
|
|
79
81
|
getReceipt(runId: string): TaskRunReceipt | undefined;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
3
|
+
import { taskCheckId } from "../../packages/gateway-contract/src/tasks.js";
|
|
4
|
+
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
3
5
|
import { enqueueTaskAttentionRequiredEvent, enqueueTaskChangedEvent, init_task_change_events } from "./task-change-events.js";
|
|
4
6
|
import { TaskRepository, init_task_repository } from "./task-repository.js";
|
|
7
|
+
import { init_task_instruction_sequence, taskInstructionSequence } from "./task-instruction-sequence.js";
|
|
8
|
+
import { init_task_result_versions, recordTaskResultVersion } from "./task-result-versions.js";
|
|
9
|
+
import { init_task_workspace_verification, inspectTaskWorkspace } from "./task-workspace-verification.js";
|
|
5
10
|
import { randomUUID } from "node:crypto";
|
|
6
11
|
//#region src/tasks/task-run-repository.ts
|
|
7
12
|
function parseJson(value) {
|
|
@@ -22,6 +27,7 @@ function fromRow(row) {
|
|
|
22
27
|
...row.causation_id ? { causationId: row.causation_id } : {},
|
|
23
28
|
idempotencyKey: row.idempotency_key,
|
|
24
29
|
contractVersion: row.contract_version,
|
|
30
|
+
...row.instruction_sequence_at_start === null ? {} : { instructionSequenceAtStart: row.instruction_sequence_at_start },
|
|
25
31
|
...row.context_snapshot_id ? { contextSnapshotId: row.context_snapshot_id } : {},
|
|
26
32
|
...row.policy_snapshot_json ? { policySnapshot: parseJson(row.policy_snapshot_json) } : {},
|
|
27
33
|
...row.conversation_id ? { conversationId: row.conversation_id } : {},
|
|
@@ -76,9 +82,13 @@ function receiptFromRow(row) {
|
|
|
76
82
|
}
|
|
77
83
|
var ACTIVE_RUN_STATUSES, CANCELLED_ACTIVE_RUNS, TaskRunRepository;
|
|
78
84
|
var init_task_run_repository = __esmMin((() => {
|
|
85
|
+
init_src();
|
|
79
86
|
init_transaction();
|
|
80
87
|
init_task_change_events();
|
|
81
88
|
init_task_repository();
|
|
89
|
+
init_task_instruction_sequence();
|
|
90
|
+
init_task_result_versions();
|
|
91
|
+
init_task_workspace_verification();
|
|
82
92
|
ACTIVE_RUN_STATUSES = [
|
|
83
93
|
"queued",
|
|
84
94
|
"running",
|
|
@@ -143,12 +153,12 @@ var init_task_run_repository = __esmMin((() => {
|
|
|
143
153
|
getActiveRoot(taskId) {
|
|
144
154
|
const row = getSqliteDatabase().prepare(`SELECT * FROM task_runs WHERE task_id = ? AND parent_run_id IS NULL
|
|
145
155
|
AND status IN ('queued', 'running', 'waiting', 'verifying')
|
|
146
|
-
ORDER BY queued_at DESC LIMIT 1`).get(taskId);
|
|
156
|
+
ORDER BY queued_at DESC, rowid DESC LIMIT 1`).get(taskId);
|
|
147
157
|
return row ? fromRow(row) : void 0;
|
|
148
158
|
}
|
|
149
159
|
getLatestRoot(taskId) {
|
|
150
160
|
const row = getSqliteDatabase().prepare(`SELECT * FROM task_runs WHERE task_id = ? AND parent_run_id IS NULL
|
|
151
|
-
ORDER BY queued_at DESC LIMIT 1`).get(taskId);
|
|
161
|
+
ORDER BY queued_at DESC, rowid DESC LIMIT 1`).get(taskId);
|
|
152
162
|
return row ? fromRow(row) : void 0;
|
|
153
163
|
}
|
|
154
164
|
listByTask(taskId, limit = 100) {
|
|
@@ -180,21 +190,30 @@ var init_task_run_repository = __esmMin((() => {
|
|
|
180
190
|
}
|
|
181
191
|
start(input) {
|
|
182
192
|
const now = input.now ?? Date.now();
|
|
183
|
-
return
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
return runSqliteWriteTransaction(() => {
|
|
194
|
+
const run = this.get(input.runId);
|
|
195
|
+
if (!run || run.version !== input.expectedVersion || run.status !== "queued") return void 0;
|
|
196
|
+
const workspaceBaseline = inspectTaskWorkspace(new TaskRepository().require(run.taskId));
|
|
197
|
+
return this.transition({
|
|
198
|
+
runId: input.runId,
|
|
199
|
+
expectedVersion: input.expectedVersion,
|
|
200
|
+
from: ["queued"],
|
|
201
|
+
to: "running",
|
|
202
|
+
fields: {
|
|
203
|
+
context_snapshot_id: input.contextSnapshotId,
|
|
204
|
+
policy_snapshot_json: JSON.stringify({
|
|
205
|
+
...input.policySnapshot,
|
|
206
|
+
...workspaceBaseline.length ? { workspaceBaseline } : {}
|
|
207
|
+
}),
|
|
208
|
+
instruction_sequence_at_start: taskInstructionSequence(run.taskId),
|
|
209
|
+
conversation_id: input.conversationId ?? null,
|
|
210
|
+
started_at: now,
|
|
211
|
+
heartbeat_at: now,
|
|
212
|
+
timeout_at: input.timeoutAt ?? null
|
|
213
|
+
},
|
|
214
|
+
actor: input.actor ?? { kind: "system" },
|
|
215
|
+
now
|
|
216
|
+
});
|
|
198
217
|
});
|
|
199
218
|
}
|
|
200
219
|
setStatus(input) {
|
|
@@ -309,11 +328,34 @@ var init_task_run_repository = __esmMin((() => {
|
|
|
309
328
|
if (db.prepare(`UPDATE task_runs SET status = ?, completed_at = ?, terminal_code = ?,
|
|
310
329
|
terminal_message = ?, lease_owner = NULL, lease_expires_at = NULL,
|
|
311
330
|
version = version + 1 WHERE run_id = ? AND version = ?`).run(input.receipt.status, now, input.terminalCode ?? null, input.terminalMessage ?? null, input.runId, input.expectedVersion).changes === 0) return void 0;
|
|
331
|
+
const criteria = new TaskRepository().getContract(run.taskId, run.contractVersion)?.acceptanceCriteria ?? [];
|
|
332
|
+
const checks = input.receipt.verification.checks.map((check) => {
|
|
333
|
+
const index = check.checkId ? criteria.findIndex((text, position) => text === check.criterion && taskCheckId(run.taskId, run.contractVersion, position) === check.checkId) : criteria.indexOf(check.criterion) === criteria.lastIndexOf(check.criterion) ? criteria.indexOf(check.criterion) : -1;
|
|
334
|
+
return {
|
|
335
|
+
...check,
|
|
336
|
+
checkId: index >= 0 ? taskCheckId(run.taskId, run.contractVersion, index) : void 0
|
|
337
|
+
};
|
|
338
|
+
});
|
|
312
339
|
db.prepare(`INSERT INTO task_run_receipts (
|
|
313
340
|
run_id, status, summary, changes_json, evidence_json, verification_json,
|
|
314
341
|
remaining_work_json, next_action, needs_user, completion_verdict,
|
|
315
342
|
failure_json, judgment_json, context_trace_id, finalized_at
|
|
316
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.runId, input.receipt.status, input.receipt.summary, JSON.stringify(input.receipt.changes), JSON.stringify(input.receipt.evidence), JSON.stringify(
|
|
343
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.runId, input.receipt.status, input.receipt.summary, JSON.stringify(input.receipt.changes), JSON.stringify(input.receipt.evidence), JSON.stringify({
|
|
344
|
+
...input.receipt.verification,
|
|
345
|
+
checks
|
|
346
|
+
}), JSON.stringify(input.receipt.remainingWork), input.receipt.nextAction ?? null, input.receipt.needsUser ? 1 : 0, input.receipt.completionVerdict ?? null, input.receipt.failure ? JSON.stringify(input.receipt.failure) : null, input.receipt.judgment ? JSON.stringify(input.receipt.judgment) : null, input.receipt.contextTraceId ?? null, now);
|
|
347
|
+
if (!run.parentRunId && input.receipt.status === "succeeded") {
|
|
348
|
+
const state = db.prepare("SELECT active_conversation_id, assignment_epoch FROM task_conversation_state WHERE task_id = ?").get(run.taskId);
|
|
349
|
+
const currentSequence = taskInstructionSequence(run.taskId);
|
|
350
|
+
const sequence = input.reviewedInstructionSequence === currentSequence ? currentSequence : run.instructionSequenceAtStart ?? (currentSequence === 0 ? 0 : void 0);
|
|
351
|
+
if (sequence !== void 0 && (!run.conversationId || !state?.active_conversation_id || state.active_conversation_id === run.conversationId)) recordTaskResultVersion({
|
|
352
|
+
runId: run.id,
|
|
353
|
+
assignmentEpoch: state?.assignment_epoch ?? 0,
|
|
354
|
+
instructionSequence: sequence,
|
|
355
|
+
finalizedAt: now,
|
|
356
|
+
workspaceFiles: input.workspaceFiles
|
|
357
|
+
});
|
|
358
|
+
}
|
|
317
359
|
this.appendEvent(db, input.runId, `task_run.${input.receipt.status}`, { completionVerdict: input.receipt.completionVerdict }, input.actor ?? { kind: "system" }, now);
|
|
318
360
|
return this.get(input.runId);
|
|
319
361
|
});
|
|
@@ -457,7 +499,8 @@ var init_task_run_repository = __esmMin((() => {
|
|
|
457
499
|
"heartbeat_at",
|
|
458
500
|
"timeout_at",
|
|
459
501
|
"lease_owner",
|
|
460
|
-
"lease_expires_at"
|
|
502
|
+
"lease_expires_at",
|
|
503
|
+
"instruction_sequence_at_start"
|
|
461
504
|
]);
|
|
462
505
|
const entries = Object.entries(input.fields);
|
|
463
506
|
for (const [column] of entries) if (!allowedColumns.has(column)) throw new Error(`Unsupported TaskRun field: ${column}`);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Task } from '@xopcai/gateway-contract';
|
|
2
|
+
type WorkspaceTask = Pick<Task, 'id' | 'contract' | 'projectId' | 'delegateAgentId'>;
|
|
3
|
+
type WorkspaceObservation = {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
relativePath: string;
|
|
6
|
+
root?: string;
|
|
7
|
+
fingerprint?: string;
|
|
8
|
+
status: 'present' | 'missing' | 'unavailable';
|
|
9
|
+
};
|
|
10
|
+
export type TaskWorkspaceFile = WorkspaceObservation & {
|
|
11
|
+
verified: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function inspectTaskWorkspace(task: WorkspaceTask): WorkspaceObservation[];
|
|
14
|
+
export declare function verifyTaskWorkspace(task: WorkspaceTask, baseline: unknown): TaskWorkspaceFile[];
|
|
15
|
+
export declare function taskWorkspaceStillVerified(task: WorkspaceTask, observed: TaskWorkspaceFile[]): boolean;
|
|
16
|
+
export {};
|