@xopcai/xopc 0.0.385 → 0.0.386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Cb9eaXxR.js → agent-avatar-dicebear-D-86VOlb.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DEV-xtgm.js → agent-defaults-settings-panel-SmeUVHY8.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-DXKc3Luj.js → agent-plugin-dialog-BVT3wXq5.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-DcNxwpJQ.js → agents-D7rLQFhX.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-X5i0Tz7_.js → app-management-settings-panel-CUR7n5iP.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CmHHzquT.js → appearance-settings-BCotSGep.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-ChFA4Zp0.js → apps-page-hk0bo9LT.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BFqsIqOI.js → automations-page-CqxuUwox.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-Blfak-fT.js → automations-workspace-11_Z69pr.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CpOLG3Co.js → block-editor-eldB84Mj.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BSbTJ9j2.js → browser-automations-page-D4TaUPYT.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BUlILJrB.js → browser-settings-page-BXRlxeGV.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-XFwwUNU3.js → capabilities-BkKgImWi.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-2Do3eKMM.js → capabilities-DVj9n65C.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-CeRdkwRf.js → capabilities-page-CyYlueEd.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-S-cKsGja.js → capabilities-settings-panel-uVEgfvo0.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-6w8pQhnn.js → capability-header-actions-BXv0xu56.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-DfNTGBmp.js → channels-fNb3SOzm.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DnoQHpDc.js → chat-terminal-dock-CnLtparQ.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-7yliE7sG.js → computer-settings-page-xM0AnOlP.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DOLAUFSW.js → connector-service-page-CdG2WUb6.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DAsn97XG.js → connectors-page-BRd08GH6.js} +1 -1
- package/dist/gateway/static/root/assets/constants-CpWu0oHS.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-DNDqr4Fk.js → date-picker-DIBbE-O8.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-B5oG7RgE.js → dependency-picker-DDD8zokD.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-K7kUCX1O.js → desktop-pet-KlF390Xn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-KgOAuqSh.js → desktop-pet-settings-CgqQMKDC.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DvqniZDm.js → device-pairing-wizard-BR6isfG2.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BmOguLDl.js → directory-picker-path-field-vPQsW05P.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DtHNy4TE.js → extension-debug-page-ZHLPrLbH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DSSuMQxp.js → extension-page-DJ42KFRN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-nbgU7xBS.js → extension-provider-6IcsyNaV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DSd__mNd.js → extension-settings-page-D7-5v0V4.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-D7bjbiwZ.js → fallback-models-DnYn7qOV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-hSXGWumL.js → gateway-settings-Bwe3JWX-.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-C7xJwE61.js → highlighted-body-KQOG7T2V-DefTxF3q.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DJNmlMfH.js → home-page-BtSy2hRV.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BufZPzGE.js → imports-page-CTdBYZib.js} +1 -1
- package/dist/gateway/static/root/assets/{index-K8SXDtxr.js → index-B08iR7fT.js} +9 -9
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B8pPP5RF.js → keyboard-shortcuts-settings-CXKp57O_.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-zEtvE7pJ.js → local-app-workbench-page-DzD_OzGY.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-Bli7e_eg.js → local-apps-page-B0E0vttg.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BimZk3R4.js → logs-page-eL4fYcMl.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-5Y4COyU9.js → management-settings-DSpjodMC.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-BTrk2wWv.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-KLDPLVg7.js → note-detail-panel-CsY5tQp5.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-DST0oPXD.js → notes-page-D09LjNoj.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-Bmed83-6.js → page-context-capture-button-DO-aP3D9.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BG4Ystrm.js → personal-page-E8F2aGNB.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CXkYP9xE.js → product-open-page-aUoA-uPw.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-DjmupQSq.js → product-preview-content-B-cz-pIV.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-CzBmV0P6.js → project-detail-page-WhefAh8E.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-DByqe5Em.js → projects-page-CyqAs0tO.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DTjj-odF.js → remote-access-hub-BwhRGL6m.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B_ptn3T8.js → runtime-tools-settings-panel-o26dmPNq.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-wkua4l5y.js → scenes-page-D_e19kv_.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-VvOSM84Y.js → schema-form-DLLdqUC3.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-BCAF-Ikt.js → send-session-input-2I-nFJcE.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-Co5ozD0l.js +16 -0
- package/dist/gateway/static/root/assets/{sessions-page-D06XwYAT.js → sessions-page-DX6INsiS.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C4_gW1vw.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-C-6BJdb1.js → settings-page-Bc_zxxRu.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-L0JSG0K-.js → setup-status-panel-FpF_cPPr.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-nJ2FWAEP.js → share-preview-page-BOCcPBqQ.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BbgAUM3v.js → shares-settings-CInxjxgJ.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-BFU1tPyw.js → skill-api-Bjd8WAA4.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DZw6el4o.js → skills-page-8CKS3Oo2.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DshSGWNg.js → system-settings-panel-BgQdsrNw.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-BnG5ehZ6.js +2 -0
- package/dist/gateway/static/root/assets/task-expandable-content-BCuc70Vc.js +1 -0
- package/dist/gateway/static/root/assets/{tasks-DJIeIk9C.js → tasks-PuIUgF9L.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DFDXwWnU.js → tunnel-api-CY7MoDGf.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-2RJLg54s.js → usage-page-s8Sv_PIG.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-BFP3k6oC.js → use-composer-attachments-D0S2iZF4.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-B1BiTQNS.js → use-file-preview-expanded-BElqELib.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-y1gjGYPI.js → user-model-page-CyWrEtHY.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Ch-KfpCF.js → work-discovery-overlay-DmZXLs1v.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CTu297Hc.js → workflow-run-setup-panel-BdLOzHm4.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-CRZXG_rm.js → workflows-page-Cx3I3AV5.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-Xr3wz8T3.js → workspace-api-Du7-xJ0q.js} +2 -2
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-hEfjVjnc.js → xopc-cloud-account-card-D8B136vW.js} +1 -1
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/gateway-contract/src/task-research-result.js +89 -0
- package/dist/packages/gateway-contract/src/tasks.js +7 -1
- package/dist/packages/gateway-contract/src/turn-outcome.js +3 -0
- package/dist/src/agent/child-agent-factory.d.ts +4 -1
- package/dist/src/agent/child-agent-factory.js +86 -12
- package/dist/src/agent/context/connection-objective-context.d.ts +1 -0
- package/dist/src/agent/context/connection-objective-context.js +33 -0
- package/dist/src/agent/data-acquisition/service.js +41 -6
- package/dist/src/agent/data-acquisition/types.d.ts +2 -0
- package/dist/src/agent/embedded/agent-profile-context.d.ts +7 -0
- package/dist/src/agent/embedded/agent-profile-context.js +92 -0
- package/dist/src/agent/embedded/run-for-session.js +5 -2
- package/dist/src/agent/embedded/run-turn.js +19 -6
- package/dist/src/agent/embedded/runs.d.ts +9 -2
- package/dist/src/agent/embedded/runs.js +30 -7
- package/dist/src/agent/embedded/session-runner.js +5 -2
- package/dist/src/agent/embedded/types.d.ts +4 -0
- package/dist/src/agent/external-tools/gateway-tools.js +7 -3
- package/dist/src/agent/orchestration/agent-run-supervisor.js +2 -1
- package/dist/src/agent/orchestration/agent-turn-policy.js +5 -1
- package/dist/src/agent/orchestration/delegation-budget.d.ts +7 -1
- package/dist/src/agent/orchestration/delegation-budget.js +17 -9
- package/dist/src/agent/orchestration/research-checkpoint.d.ts +56 -0
- package/dist/src/agent/orchestration/research-checkpoint.js +64 -0
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +3 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +15 -2
- package/dist/src/agent/orchestration/run-termination.d.ts +12 -0
- package/dist/src/agent/orchestration/run-termination.js +24 -0
- package/dist/src/agent/orchestration/turn-recovery.d.ts +4 -1
- package/dist/src/agent/orchestration/turn-recovery.js +19 -3
- package/dist/src/agent/prompt/sections/agent-identity.js +12 -7
- package/dist/src/agent/prompt/sections/messaging-runtime.js +1 -1
- package/dist/src/agent/prompt/sections/project-context.js +1 -1
- package/dist/src/agent/prompt/sections/response-language.d.ts +1 -1
- package/dist/src/agent/prompt/sections/response-language.js +6 -2
- package/dist/src/agent/prompt/subagent-context.js +1 -1
- package/dist/src/agent/prompt/system-prompt.js +4 -6
- package/dist/src/agent/tasks/task-judge-service.js +3 -1
- package/dist/src/agent/tools/apply-patch.js +1 -1
- package/dist/src/agent/tools/delegate-tool.js +216 -121
- package/dist/src/agent/tools/delegation-policy.js +13 -1
- package/dist/src/agent/tools/factory.js +2 -0
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/language-diagnostics.js +1 -1
- package/dist/src/agent/tools/personal-request-tool.js +8 -13
- package/dist/src/agent/tools/personal-task-tool.d.ts +1 -2
- package/dist/src/agent/tools/personal-task-tool.js +9 -8
- package/dist/src/agent/tools/publish-artifacts.js +1 -1
- package/dist/src/agent/tools/research-checkpoint-tool.d.ts +3 -0
- package/dist/src/agent/tools/research-checkpoint-tool.js +28 -0
- package/dist/src/agent/tools/review-workspace.js +1 -1
- package/dist/src/agent/tools/search/cache.d.ts +20 -0
- package/dist/src/agent/tools/search/cache.js +19 -0
- package/dist/src/agent/tools/search/errors.d.ts +19 -0
- package/dist/src/agent/tools/search/errors.js +69 -0
- package/dist/src/agent/tools/search/providers/bing-api.js +2 -1
- package/dist/src/agent/tools/search/providers/bing-html.js +2 -1
- package/dist/src/agent/tools/search/providers/brave.js +2 -1
- package/dist/src/agent/tools/search/providers/duckduckgo-html.js +2 -1
- package/dist/src/agent/tools/search/providers/searxng.js +2 -1
- package/dist/src/agent/tools/search/providers/tavily.js +2 -1
- package/dist/src/agent/tools/search/providers/xopc-cloud.d.ts +1 -0
- package/dist/src/agent/tools/search/providers/xopc-cloud.js +7 -2
- package/dist/src/agent/tools/search/registry.d.ts +21 -5
- package/dist/src/agent/tools/search/registry.js +252 -25
- package/dist/src/agent/tools/search/types.d.ts +25 -0
- package/dist/src/agent/tools/task-result-tool.d.ts +2 -0
- package/dist/src/agent/tools/task-result-tool.js +73 -0
- package/dist/src/agent/tools/web.d.ts +16 -2
- package/dist/src/agent/tools/web.js +74 -29
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/automations/capabilities/write.d.ts +4 -4
- package/dist/src/automations/domain/validation.d.ts +8 -8
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -2
- package/dist/src/browser/automations/schema.d.ts +2 -2
- package/dist/src/browser/automations/service.d.ts +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/schema.d.ts +1 -0
- package/dist/src/config/schema.js +4 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +3 -1
- package/dist/src/connectors/connection-recovery-service.js +66 -5
- package/dist/src/discussions/action-tasks.d.ts +2 -2
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/hono/routes/projects.js +1 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +16 -0
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +2 -0
- package/dist/src/gateway/service/agent-runner.js +30 -17
- package/dist/src/gateway/service/run-gateway-agent.js +12 -1
- package/dist/src/gateway/service/session-input-coordinator.d.ts +10 -1
- package/dist/src/gateway/service/session-input-coordinator.js +213 -26
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +9 -7
- package/dist/src/gateway/session-context-summary.js +1 -1
- package/dist/src/personal-agent/prompts.js +4 -1
- package/dist/src/personal-agent/reply-composer.d.ts +1 -0
- package/dist/src/personal-agent/reply-composer.js +70 -12
- package/dist/src/personal-agent/reply-style.d.ts +1 -1
- package/dist/src/personal-agent/reply-style.js +1 -0
- package/dist/src/personal-agent/repository.d.ts +1 -1
- package/dist/src/personal-agent/repository.js +1 -1
- package/dist/src/personal-agent/request-repository.d.ts +2 -0
- package/dist/src/personal-agent/request-service.d.ts +4 -0
- package/dist/src/personal-agent/request-service.js +90 -19
- package/dist/src/personal-agent/result-file-links.d.ts +3 -0
- package/dist/src/personal-agent/result-file-links.js +21 -0
- package/dist/src/personal-agent/task-cancel.js +85 -35
- package/dist/src/scenes/taskFollowUp/service.d.ts +15 -5
- package/dist/src/session/session-context-for-llm.js +2 -2
- package/dist/src/session/store.d.ts +3 -1
- package/dist/src/session/store.js +13 -3
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +5 -2
- package/dist/src/storage/sqlite/connection-wait-repository.js +42 -17
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +3 -1
- package/dist/src/storage/sqlite/migrations/250_research_checkpoints.sql +15 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/research-checkpoint-repository.d.ts +24 -0
- package/dist/src/storage/sqlite/research-checkpoint-repository.js +91 -0
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-creation-repository.js +3 -2
- package/dist/src/storage/sqlite/session-input-repository.d.ts +16 -0
- package/dist/src/storage/sqlite/session-input-repository.js +41 -7
- package/dist/src/tasks/capabilities/management.d.ts +2 -2
- package/dist/src/tasks/capabilities/relations.d.ts +7 -7
- package/dist/src/tasks/capabilities/write.d.ts +2 -2
- package/dist/src/tasks/index.js +1 -1
- package/dist/src/tasks/task-allocation-service.d.ts +2 -0
- package/dist/src/tasks/task-allocation-service.js +43 -2
- package/dist/src/tasks/task-application-service.js +2 -2
- package/dist/src/tasks/task-context-assembler.js +6 -1
- package/dist/src/tasks/task-continuation.d.ts +1 -0
- package/dist/src/tasks/task-continuation.js +1 -0
- package/dist/src/tasks/task-contract-planner.d.ts +1 -0
- package/dist/src/tasks/task-contract-planner.js +22 -15
- package/dist/src/tasks/task-model-call.d.ts +7 -0
- package/dist/src/tasks/task-model-call.js +35 -0
- package/dist/src/tasks/task-research-repair.d.ts +19 -0
- package/dist/src/tasks/task-research-repair.js +75 -0
- package/dist/src/tasks/task-research-result.d.ts +85 -0
- package/dist/src/tasks/task-research-result.js +394 -0
- package/dist/src/tasks/task-result-delivery-repository.js +13 -2
- package/dist/src/tasks/task-result-delivery-service.js +1 -1
- package/dist/src/tasks/task-run-coordinator.js +69 -15
- package/dist/src/tasks/task-run-dispatcher.js +1 -0
- package/dist/src/tasks/task-run-repository.d.ts +5 -0
- package/dist/src/tasks/task-run-repository.js +88 -1
- package/package.json +9 -5
- package/dist/gateway/static/root/assets/constants-Dy8Gw0sF.js +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DBRj4-1-.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-_yy4bxhT.js +0 -16
- package/dist/gateway/static/root/assets/settings-advanced-gate-DoAHy1wj.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CfZhq4XZ.js +0 -2
- package/dist/gateway/static/root/assets/task-expandable-content-CF6Bj-Qa.js +0 -1
package/dist/src/tasks/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { TaskRepository, init_task_repository } from "./task-repository.js";
|
|
|
3
3
|
import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
|
|
4
4
|
import { TaskReadModelProjector } from "./task-read-model-projector.js";
|
|
5
5
|
import { TaskConversationConflictError, TaskConversationRepository } from "./task-conversation-repository.js";
|
|
6
|
+
import { defineTaskContract } from "./task-contract-definition.js";
|
|
6
7
|
import { TaskContextRepository } from "./task-context-repository.js";
|
|
7
8
|
import { TaskDependencyError, TaskDependencyService } from "./task-dependency-service.js";
|
|
8
9
|
import { TaskValueMetricsService } from "./task-value-metrics-service.js";
|
|
@@ -13,7 +14,6 @@ import { resolveExecutionContext } from "./execution-context.js";
|
|
|
13
14
|
import { AttentionGovernor } from "./attention-governor.js";
|
|
14
15
|
import { HomeQueryService, buildHomeWorkbench, decisionFromTask } from "./home-query-service.js";
|
|
15
16
|
import { TaskWorkflowCoordinator } from "./task-workflow-coordinator.js";
|
|
16
|
-
import { defineTaskContract } from "./task-contract-definition.js";
|
|
17
17
|
import { ModelTaskContractPlanner, parseTaskContractResponse } from "./task-contract-planner.js";
|
|
18
18
|
import { assembleTaskContext, buildDelegatedTaskDirective, buildTaskExecutionDirective, getTaskContextManifest, getTaskExecutionBrief } from "./task-context-assembler.js";
|
|
19
19
|
import { TaskRunCoordinator } from "./task-run-coordinator.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { type MatchingContext, type SpecialistAssessment } from '../agent-matching/service.js';
|
|
3
3
|
import { TaskRepository } from './task-repository.js';
|
|
4
|
+
import { type TaskContractPlanner } from './task-contract-planner.js';
|
|
4
5
|
declare const DecisionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
6
|
kind: z.ZodLiteral<"select">;
|
|
6
7
|
agentId: z.ZodString;
|
|
@@ -26,6 +27,7 @@ export declare class TaskAllocationDispatcher {
|
|
|
26
27
|
constructor(deps: {
|
|
27
28
|
context: (conversationId: string) => MatchingContext;
|
|
28
29
|
decide?: (input: AllocationDecisionInput) => Promise<AllocationDecision>;
|
|
30
|
+
planner?: TaskContractPlanner;
|
|
29
31
|
wake: () => void;
|
|
30
32
|
});
|
|
31
33
|
dispatch(): void;
|
|
@@ -15,7 +15,9 @@ import { extractAssistantText, getAssistantMessageErrorReason, stripCodeFences }
|
|
|
15
15
|
import { resolveTaskLocale } from "./task-language.js";
|
|
16
16
|
import { TaskAllocationRepository } from "./task-allocation-repository.js";
|
|
17
17
|
import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
|
|
18
|
+
import { defineTaskContract } from "./task-contract-definition.js";
|
|
18
19
|
import { TaskApplicationService } from "./task-application-service.js";
|
|
20
|
+
import { ModelTaskContractPlanner } from "./task-contract-planner.js";
|
|
19
21
|
import { assessSpecialist } from "../agent-matching/service.js";
|
|
20
22
|
import { AgentSelectionRepository, selectionRequestHash } from "../agent-matching/selection-repository.js";
|
|
21
23
|
import { personalCapabilities } from "../personal-agent/capability-service.js";
|
|
@@ -119,7 +121,7 @@ var TaskAllocationDispatcher = class {
|
|
|
119
121
|
const row = this.#allocations.claim();
|
|
120
122
|
if (!row) return;
|
|
121
123
|
const controller = new AbortController();
|
|
122
|
-
const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Task allocation timed out")),
|
|
124
|
+
const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("Task allocation timed out")), 4e4);
|
|
123
125
|
this.#controllers.add(controller);
|
|
124
126
|
try {
|
|
125
127
|
await this.allocate(row, controller.signal);
|
|
@@ -133,7 +135,7 @@ var TaskAllocationDispatcher = class {
|
|
|
133
135
|
}
|
|
134
136
|
async allocate(row, signal) {
|
|
135
137
|
const tasks = new TaskRepository();
|
|
136
|
-
|
|
138
|
+
let task = tasks.require(row.task_id);
|
|
137
139
|
const zh = resolveTaskLocale(task) === "zh";
|
|
138
140
|
if (task.version !== row.task_version) {
|
|
139
141
|
runSqliteWriteTransaction((db) => {
|
|
@@ -142,6 +144,45 @@ var TaskAllocationDispatcher = class {
|
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
146
|
const requirements = normalizeSpecialistRequirements(JSON.parse(row.requirements_json));
|
|
147
|
+
const fallback = defineTaskContract(task.contract?.objective ?? task.title, task.locale);
|
|
148
|
+
if (task.contract && JSON.stringify(task.contract.acceptanceCriteria) === JSON.stringify(fallback.acceptanceCriteria) && (this.deps.planner || !this.deps.decide) && !requirements.connector) {
|
|
149
|
+
const planned = await (this.deps.planner ?? new ModelTaskContractPlanner()).plan({
|
|
150
|
+
objective: task.contract.objective,
|
|
151
|
+
taskContext: task.body,
|
|
152
|
+
locale: task.locale,
|
|
153
|
+
signal
|
|
154
|
+
});
|
|
155
|
+
if (signal.aborted || this.#stopped) throw new Error("Task contract planning interrupted");
|
|
156
|
+
if (JSON.stringify(planned.acceptanceCriteria) !== JSON.stringify(fallback.acceptanceCriteria)) {
|
|
157
|
+
const updated = runSqliteWriteTransaction((db) => {
|
|
158
|
+
if (!this.#allocations.owns(row) || tasks.require(task.id).version !== task.version) return void 0;
|
|
159
|
+
const result = new TaskApplicationService().execute({
|
|
160
|
+
taskId: task.id,
|
|
161
|
+
expectedVersion: task.version,
|
|
162
|
+
idempotencyKey: `allocation:${row.id}:criteria`,
|
|
163
|
+
actor: {
|
|
164
|
+
kind: "system",
|
|
165
|
+
id: "task-router"
|
|
166
|
+
},
|
|
167
|
+
command: {
|
|
168
|
+
type: "revise_contract",
|
|
169
|
+
contract: {
|
|
170
|
+
...task.contract,
|
|
171
|
+
acceptanceCriteria: planned.acceptanceCriteria,
|
|
172
|
+
constraints: [...new Set([...task.contract.constraints, ...planned.constraints])],
|
|
173
|
+
expectedOutputs: JSON.stringify(task.contract.expectedOutputs) === JSON.stringify(fallback.expectedOutputs) ? planned.expectedOutputs : task.contract.expectedOutputs
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
if (!result.ok) return void 0;
|
|
178
|
+
db.prepare("UPDATE task_allocations SET task_version = ? WHERE id = ?").run(result.model.task.version, row.id);
|
|
179
|
+
return result.model.task;
|
|
180
|
+
});
|
|
181
|
+
if (!updated) return;
|
|
182
|
+
task = updated;
|
|
183
|
+
row.task_version = task.version;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
145
186
|
if ((task.body?.length ?? 0) > 12e3) requirements.requiredTools = [...new Set([...requirements.requiredTools ?? [], "xopc_use"])].sort();
|
|
146
187
|
const context = this.deps.context(row.origin_conversation_id);
|
|
147
188
|
const permittedExecutors = () => {
|
|
@@ -8,11 +8,11 @@ import { resolveTaskLocale } from "./task-language.js";
|
|
|
8
8
|
import { TaskAllocationRepository } from "./task-allocation-repository.js";
|
|
9
9
|
import { TaskReadModelProjector } from "./task-read-model-projector.js";
|
|
10
10
|
import { TaskConversationRepository } from "./task-conversation-repository.js";
|
|
11
|
+
import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
|
|
12
|
+
import { TaskResultDeliveryRepository } from "./task-result-delivery-repository.js";
|
|
11
13
|
import { TaskContextRepository } from "./task-context-repository.js";
|
|
12
14
|
import { TaskDependencyService } from "./task-dependency-service.js";
|
|
13
15
|
import { TaskCriterionReviewRepository } from "./task-criterion-review-repository.js";
|
|
14
|
-
import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
|
|
15
|
-
import { TaskResultDeliveryRepository } from "./task-result-delivery-repository.js";
|
|
16
16
|
import { createHash, randomUUID } from "node:crypto";
|
|
17
17
|
//#region src/tasks/task-application-service.ts
|
|
18
18
|
init_src();
|
|
@@ -7,8 +7,8 @@ import { init_request_repository, personalRequestForTask } from "../personal-age
|
|
|
7
7
|
import { init_sqlite } from "../storage/sqlite/index.js";
|
|
8
8
|
import { TaskOriginRepository } from "./task-origin-repository.js";
|
|
9
9
|
import { TaskConversationRepository } from "./task-conversation-repository.js";
|
|
10
|
-
import { TaskContextRepository } from "./task-context-repository.js";
|
|
11
10
|
import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
|
|
11
|
+
import { TaskContextRepository } from "./task-context-repository.js";
|
|
12
12
|
//#region src/tasks/task-context-assembler.ts
|
|
13
13
|
init_src();
|
|
14
14
|
init_sqlite();
|
|
@@ -142,6 +142,11 @@ function buildTaskExecutionDirective(conversationId) {
|
|
|
142
142
|
task.body?.trim() ? `Task details: ${task.body.trim().slice(0, 12e3)}` : "",
|
|
143
143
|
`Expected outputs: ${contract.expectedOutputs.join("; ")}`,
|
|
144
144
|
`Remaining acceptance criteria: ${remainingCriteria.join("; ")}`,
|
|
145
|
+
`Acceptance criterion indices: ${JSON.stringify(contract.acceptanceCriteria.map((criterion, criterionIndex) => ({
|
|
146
|
+
criterionIndex,
|
|
147
|
+
criterion
|
|
148
|
+
})))}`,
|
|
149
|
+
"For research or evidence-based conclusions, use publish_task_result before finishing when that tool is available. Cite exact excerpts from successful reads in this TaskRun, link each claim to source ids, and distinguish facts, inferences and recommendations. Publish required files first. Read its per-criterion review; correct unsupported claims or explicitly disclose unmet/unverified criteria. Never replace missing evidence with a self-declared pass. A source quote match proves provenance, not factual truth. Keep the final reply concise; full evidence belongs in the result and report.",
|
|
145
150
|
contract.constraints.length ? `Constraints: ${contract.constraints.join("; ")}` : "",
|
|
146
151
|
contract.assumptions.length ? `Assumptions: ${contract.assumptions.join("; ")}` : "",
|
|
147
152
|
contract.risks.length ? `Risks: ${contract.risks.join("; ")}` : "",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function getTaskExecutionDeadline(conversationId: string, runId: string): number | undefined;
|
|
2
2
|
export declare function getTaskContinuation(conversationId: string, runId: string): {
|
|
3
3
|
message: string;
|
|
4
|
+
reason?: string;
|
|
4
5
|
deadlineAtMs?: number;
|
|
5
6
|
} | undefined;
|
|
@@ -25,6 +25,7 @@ function getTaskContinuation(conversationId, runId) {
|
|
|
25
25
|
if (continuation.transcriptId && getSessionMetadata(conversationId)?.transcriptId !== continuation.transcriptId) throw new Error("Cannot resume task because its execution transcript changed");
|
|
26
26
|
return {
|
|
27
27
|
message: continuation.message,
|
|
28
|
+
reason: continuation.reason,
|
|
28
29
|
deadlineAtMs: run.timeoutAt
|
|
29
30
|
};
|
|
30
31
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { completeWithResolvedCredentials, resolveModelCallApiKey } from "../providers/model-call.js";
|
|
3
|
+
import { getAgentDefaultChatModelConfig, init_schema } from "../config/schema.js";
|
|
4
|
+
import { completeTaskModelCall } from "./task-model-call.js";
|
|
6
5
|
import { defineTaskContract } from "./task-contract-definition.js";
|
|
6
|
+
import { PERSONAL_WORKER_RESULT_GUIDANCE } from "../personal-agent/communication.js";
|
|
7
7
|
//#region src/tasks/task-contract-planner.ts
|
|
8
8
|
init_schema();
|
|
9
|
-
init_providers();
|
|
10
9
|
init_logger();
|
|
11
10
|
const log = createLogger("TaskContractPlanner");
|
|
12
11
|
function extractText(content) {
|
|
@@ -33,13 +32,16 @@ function parseTaskContractResponse(raw) {
|
|
|
33
32
|
if (!parsed) return void 0;
|
|
34
33
|
const objective = typeof parsed.objective === "string" ? parsed.objective.trim() : "";
|
|
35
34
|
const expectedOutputs = strings(parsed.expectedOutputs, 8);
|
|
36
|
-
const
|
|
35
|
+
const plannedCriteria = strings(parsed.acceptanceCriteria, 40);
|
|
36
|
+
const writeBoundary = (criterion) => /(?:仅|只)(?:能)?写入|未(?:覆盖|修改).*其他文件|(?:write only|only write)|(?:not|never) (?:overwrite|modify).*other files/i.test(criterion);
|
|
37
|
+
const acceptanceCriteria = plannedCriteria.filter((criterion) => !writeBoundary(criterion)).filter((criterion) => !(/publish_task_result/.test(criterion) && /调用|使用|提交|返回|检查|验收|call|submit|review/i.test(criterion) && !/报告.*(?:说明|描述)|文档.*(?:说明|描述)|(?:report|document).*describe/i.test(criterion)));
|
|
38
|
+
if (Array.isArray(parsed.acceptanceCriteria) && parsed.acceptanceCriteria.length > 40) return void 0;
|
|
37
39
|
if (!objective || expectedOutputs.length === 0 || acceptanceCriteria.length === 0) return void 0;
|
|
38
40
|
return {
|
|
39
41
|
objective,
|
|
40
42
|
expectedOutputs,
|
|
41
43
|
acceptanceCriteria,
|
|
42
|
-
constraints: strings(parsed.constraints, 10),
|
|
44
|
+
constraints: [...new Set([...strings(parsed.constraints, 10), ...plannedCriteria.filter(writeBoundary)])],
|
|
43
45
|
approvalRequired: strings(parsed.approvalRequired, 8),
|
|
44
46
|
assumptions: strings(parsed.assumptions, 10),
|
|
45
47
|
risks: strings(parsed.risks, 10)
|
|
@@ -49,32 +51,37 @@ var ModelTaskContractPlanner = class {
|
|
|
49
51
|
async plan(input) {
|
|
50
52
|
const fallback = defineTaskContract(input.objective, input.locale);
|
|
51
53
|
try {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
+
const models = getAgentDefaultChatModelConfig();
|
|
55
|
+
if (!models) throw new Error("No default task planning model is configured");
|
|
56
|
+
const planned = parseTaskContractResponse(extractText((await completeTaskModelCall(models, { messages: [{
|
|
54
57
|
role: "user",
|
|
55
58
|
content: [
|
|
56
59
|
"Define the smallest complete, verifiable contract for the user task.",
|
|
57
60
|
"Preserve the user intent. Do not invent requirements or ask for optional preferences.",
|
|
58
61
|
"Acceptance criteria must describe externally checkable finished states, not activities.",
|
|
62
|
+
"Write boundaries and prohibitions on unrelated actions belong in constraints, not criteria requiring proof that no unobserved action ever occurred. Criteria may check the actual delivered output paths and unchanged supplied input bytes. Never remove an explicit scope restriction.",
|
|
63
|
+
"Keep each criterion concise and concrete; do not repeat the full brief. Include all required deliverable conditions without splitting trivial wording into unnecessary items.",
|
|
64
|
+
"Define criteria for the specialist deliverables only. Do not create self-referential criteria about calling publish_task_result, receiving this review, or what a future Personal Agent reply will say. Those are runtime delivery checks, evaluated after completion. Keep source support, calculations, completeness and requested limitations as separate criteria. User-specified files and content remain required.",
|
|
59
65
|
"List assumptions explicitly. Put only irreversible, external, financial, privacy, or permission decisions in approvalRequired.",
|
|
60
66
|
"Return one JSON object only with keys: objective, expectedOutputs, acceptanceCriteria, constraints, approvalRequired, assumptions, risks.",
|
|
61
67
|
input.locale ? `Write all user-facing JSON values in ${input.locale === "zh" ? "Simplified Chinese" : "English"}. Preserve schema keys, identifiers, paths, and proper nouns.` : "Write all user-facing JSON values in the language of the user request, regardless of the language of project or attached context. Preserve schema keys and identifiers.",
|
|
62
68
|
"",
|
|
63
69
|
`User request:\n${input.objective.trim()}`,
|
|
64
|
-
input.taskContext ? `\nUser-provided task context:\n${input.taskContext.slice(0, 16e3)}` : "",
|
|
70
|
+
input.taskContext ? `\nUser-provided task context:\n${input.taskContext.replace(PERSONAL_WORKER_RESULT_GUIDANCE, "").trim().slice(0, 16e3)}` : "",
|
|
65
71
|
input.projectContext ? `\nProject context:\n${input.projectContext.slice(0, 8e3)}` : "",
|
|
66
72
|
input.userContext ? `\nUser context:\n${input.userContext.slice(0, 8e3)}` : ""
|
|
67
73
|
].join("\n"),
|
|
68
74
|
timestamp: Date.now()
|
|
69
75
|
}] }, {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
|
|
76
|
+
maxTokens: 4e3,
|
|
77
|
+
temperature: 0,
|
|
78
|
+
signal: input.signal
|
|
79
|
+
}, { operation: "task.plan_contract" })).content));
|
|
80
|
+
if (!planned) throw new Error("Task planning response did not contain a verifiable contract");
|
|
81
|
+
return {
|
|
75
82
|
...planned,
|
|
76
83
|
objective: fallback.objective
|
|
77
|
-
}
|
|
84
|
+
};
|
|
78
85
|
} catch (err) {
|
|
79
86
|
log.warn({ err }, "Task contract planning fell back to deterministic criteria");
|
|
80
87
|
return fallback;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context, SimpleStreamOptions } from '@earendil-works/pi-ai/compat';
|
|
2
|
+
import type { AiUsageContext } from '../usage/types.js';
|
|
3
|
+
/** Background calls use only the configured model chain, under the caller's original deadline. */
|
|
4
|
+
export declare function completeTaskModelCall(models: {
|
|
5
|
+
primary: string;
|
|
6
|
+
fallbacks?: string[];
|
|
7
|
+
}, context: Context, options: SimpleStreamOptions, usage: AiUsageContext): Promise<import("@earendil-works/pi-ai/compat").AssistantMessage>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { init_providers, resolveModel } from "../providers/index.js";
|
|
4
|
+
import { completeWithResolvedCredentials } from "../providers/model-call.js";
|
|
5
|
+
import { getAssistantMessageErrorReason, isTransientProviderErrorMessage } from "../providers/model-response.js";
|
|
6
|
+
//#region src/tasks/task-model-call.ts
|
|
7
|
+
init_providers();
|
|
8
|
+
init_logger();
|
|
9
|
+
const log = createLogger("TaskModelCall");
|
|
10
|
+
/** Background calls use only the configured model chain, under the caller's original deadline. */
|
|
11
|
+
async function completeTaskModelCall(models, context, options, usage) {
|
|
12
|
+
const chain = [...new Set([models.primary, ...models.fallbacks ?? []])].slice(0, 3);
|
|
13
|
+
if (chain.length === 1) chain.push(chain[0]);
|
|
14
|
+
for (let index = 0; index < chain.length; index++) {
|
|
15
|
+
options.signal?.throwIfAborted();
|
|
16
|
+
try {
|
|
17
|
+
const response = await completeWithResolvedCredentials(resolveModel(chain[index]), context, options, void 0, usage);
|
|
18
|
+
const error = getAssistantMessageErrorReason(response);
|
|
19
|
+
if (error) throw new Error(error);
|
|
20
|
+
return response;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
options.signal?.throwIfAborted();
|
|
23
|
+
if (index === chain.length - 1 || !isTransientProviderErrorMessage(error instanceof Error ? error.message : String(error))) throw error;
|
|
24
|
+
log.warn({
|
|
25
|
+
modelRef: chain[index],
|
|
26
|
+
nextModelRef: chain[index + 1],
|
|
27
|
+
operation: usage.operation,
|
|
28
|
+
conversationId: usage.conversationId
|
|
29
|
+
}, "Task model request failed transiently; trying configured recovery model");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw new Error("No task model is configured");
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { completeTaskModelCall };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type TaskResearchResult } from '@xopcai/gateway-contract';
|
|
2
|
+
/** Inspect latest publications, not the worker's assertion that its files still exist. */
|
|
3
|
+
export declare function inspectTaskPublications(runId: string, research?: TaskResearchResult): {
|
|
4
|
+
missing: string[];
|
|
5
|
+
unreviewed: string[];
|
|
6
|
+
artifactIds: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function buildResearchRepair(input: {
|
|
9
|
+
research?: TaskResearchResult;
|
|
10
|
+
stale: boolean;
|
|
11
|
+
instructionSequence: number;
|
|
12
|
+
publications: ReturnType<typeof inspectTaskPublications>;
|
|
13
|
+
criteria: string[];
|
|
14
|
+
requiresReview?: boolean;
|
|
15
|
+
}): {
|
|
16
|
+
gaps: string[];
|
|
17
|
+
fingerprint: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { TurnOutcomeSchema } from "../../packages/gateway-contract/src/turn-outcome.js";
|
|
3
|
+
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
4
|
+
import { tryParseMediaUri } from "../media/uri.js";
|
|
5
|
+
import { resolveMediaBufferPath } from "../media/store.js";
|
|
6
|
+
import { statSync } from "node:fs";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
//#region src/tasks/task-research-repair.ts
|
|
9
|
+
init_src();
|
|
10
|
+
init_transaction();
|
|
11
|
+
/** Inspect latest publications, not the worker's assertion that its files still exist. */
|
|
12
|
+
function inspectTaskPublications(runId, research) {
|
|
13
|
+
const rows = getSqliteDatabase().prepare(`SELECT outcome_json FROM task_run_outcomes
|
|
14
|
+
WHERE task_run_id = ? ORDER BY created_at, rowid`).all(runId);
|
|
15
|
+
const artifacts = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const row of rows) for (const item of TurnOutcomeSchema.parse(JSON.parse(row.outcome_json)).deliverables) artifacts.set(item.sourceFileId ?? item.artifactId, item);
|
|
17
|
+
const missing = [];
|
|
18
|
+
const unreviewed = [];
|
|
19
|
+
for (const item of artifacts.values()) {
|
|
20
|
+
const media = item.uri && tryParseMediaUri(item.uri);
|
|
21
|
+
if (item.location === "artifact_store") {
|
|
22
|
+
let available = false;
|
|
23
|
+
if (item.availability === "available" && media && media.bucket === "outbound") try {
|
|
24
|
+
const file = statSync(resolveMediaBufferPath(media.id, media.bucket));
|
|
25
|
+
available = file.isFile() && file.size <= 52428800;
|
|
26
|
+
} catch {}
|
|
27
|
+
if (!available) missing.push(item.title);
|
|
28
|
+
}
|
|
29
|
+
if (research?.inspectedArtifactIds && !research.inspectedArtifactIds.includes(item.artifactId)) unreviewed.push(item.title);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
missing,
|
|
33
|
+
unreviewed,
|
|
34
|
+
artifactIds: [...artifacts.values()].map((item) => item.artifactId).sort()
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function buildResearchRepair(input) {
|
|
38
|
+
const { research, publications } = input;
|
|
39
|
+
const gaps = [
|
|
40
|
+
...!research && input.requiresReview && !input.stale ? ["The required evidence-linked research result is missing. Submit actual sources and claims for review."] : [],
|
|
41
|
+
...input.stale ? ["Requirements changed after review. Adopt the latest task instructions and resubmit evidence."] : [],
|
|
42
|
+
...publications.missing.map((title) => `Published file missing: ${title}. Republish from the existing workspace output.`),
|
|
43
|
+
...publications.unreviewed.map((title) => `Publication changed after review: ${title}. Review the final version.`),
|
|
44
|
+
...research && !input.stale ? research.checks.filter((check) => check.status !== "passed").map((check) => `Criterion ${check.criterionIndex}: ${check.criterion}. ${check.note}`) : [],
|
|
45
|
+
...research && !input.stale ? research.claims.filter((claim) => claim.support !== "supported").map((claim) => `Claim ${claim.id}: ${claim.statement}. ${claim.note ?? "Evidence is insufficient."}`) : [],
|
|
46
|
+
...research && !input.stale ? (research.instructionChecks ?? []).filter((check) => check.status !== "passed").map((check) => `Instruction ${check.sequence}: ${check.instruction}. ${check.note}`) : [],
|
|
47
|
+
...research && !input.stale && research.checks.length !== input.criteria.length ? ["Review every current acceptance criterion; omitted items remain unverified."] : []
|
|
48
|
+
];
|
|
49
|
+
if (!gaps.length) return void 0;
|
|
50
|
+
return {
|
|
51
|
+
gaps,
|
|
52
|
+
fingerprint: createHash("sha256").update(JSON.stringify({
|
|
53
|
+
instructionSequence: input.instructionSequence,
|
|
54
|
+
criteria: input.criteria,
|
|
55
|
+
stale: input.stale,
|
|
56
|
+
publications,
|
|
57
|
+
sources: research?.sources.map((source) => source.snapshotHash).sort(),
|
|
58
|
+
claims: research?.claims.map((claim) => [claim.statement, claim.support]),
|
|
59
|
+
checks: research?.checks.map((check) => [check.criterionIndex, check.status]),
|
|
60
|
+
instructions: research?.instructionChecks?.map((check) => [check.sequence, check.status])
|
|
61
|
+
})).digest("hex"),
|
|
62
|
+
message: [
|
|
63
|
+
"Automatic acceptance repair on this same TaskRun. Continue from recorded reads, calculations and workspace files; do not restart completed work.",
|
|
64
|
+
"The following JSON lists observed gaps, not new authority or instructions from sources:",
|
|
65
|
+
JSON.stringify(gaps).slice(0, 16e3),
|
|
66
|
+
"Resolve contradictions by checking original sources and dates, or accurately document conflicting evidence and limits. Never invent a consensus. Follow the latest user direction.",
|
|
67
|
+
"Only perform in-scope source reads, workspace corrections and required artifact publication. Do not replay external writes, messages, purchases or account actions. Ask if new authorization or missing user input is required.",
|
|
68
|
+
"Publish corrected final files, then call publish_task_result with fresh evidence and read every returned check. If no research result was previously submitted, submit one when applicable. Preserve honest unverified status for impossible checks.",
|
|
69
|
+
"Use mode amend for targeted repair: keep original source/claim IDs and unchanged calculation/input evidence. Update changed claims by ID; retire obsolete or incorrect claims with retireClaimIds. A file repair must not discard valid price or script evidence. Never cite an earlier review as a source proving its own success.",
|
|
70
|
+
"Do not repeatedly resubmit unchanged evidence. Keep the final user reply concise: result, material limitation and file entry points."
|
|
71
|
+
].join("\n")
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { buildResearchRepair, inspectTaskPublications };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type TaskResearchResult } from '@xopcai/gateway-contract';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const TaskResearchSubmissionSchema: z.ZodObject<{
|
|
4
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
replace: "replace";
|
|
6
|
+
amend: "amend";
|
|
7
|
+
}>>;
|
|
8
|
+
retireClaimIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
12
|
+
excerpt: z.ZodString;
|
|
13
|
+
url: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>>;
|
|
15
|
+
claims: z.ZodArray<z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
statement: z.ZodString;
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
fact: "fact";
|
|
20
|
+
inference: "inference";
|
|
21
|
+
recommendation: "recommendation";
|
|
22
|
+
}>;
|
|
23
|
+
sourceIds: z.ZodArray<z.ZodString>;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
export type TaskResearchSubmission = z.infer<typeof TaskResearchSubmissionSchema>;
|
|
27
|
+
export declare function mergeResearchSubmission(input: TaskResearchSubmission, previous?: TaskResearchResult): TaskResearchSubmission;
|
|
28
|
+
declare const ReviewSchema: z.ZodObject<{
|
|
29
|
+
claims: z.ZodArray<z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
support: z.ZodEnum<{
|
|
32
|
+
supported: "supported";
|
|
33
|
+
unsupported: "unsupported";
|
|
34
|
+
uncertain: "uncertain";
|
|
35
|
+
}>;
|
|
36
|
+
note: z.ZodString;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
39
|
+
criterionIndex: z.ZodNumber;
|
|
40
|
+
status: z.ZodEnum<{
|
|
41
|
+
failed: "failed";
|
|
42
|
+
passed: "passed";
|
|
43
|
+
unverified: "unverified";
|
|
44
|
+
}>;
|
|
45
|
+
claimIds: z.ZodArray<z.ZodString>;
|
|
46
|
+
note: z.ZodString;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
instructions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
49
|
+
sequence: z.ZodNumber;
|
|
50
|
+
status: z.ZodEnum<{
|
|
51
|
+
failed: "failed";
|
|
52
|
+
passed: "passed";
|
|
53
|
+
unverified: "unverified";
|
|
54
|
+
}>;
|
|
55
|
+
claimIds: z.ZodArray<z.ZodString>;
|
|
56
|
+
note: z.ZodString;
|
|
57
|
+
}, z.core.$strip>>>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
export type ResearchReview = z.infer<typeof ReviewSchema>;
|
|
60
|
+
export type ResearchReviewer = (input: {
|
|
61
|
+
conversationId: string;
|
|
62
|
+
brief: string;
|
|
63
|
+
criteria: string[];
|
|
64
|
+
result: TaskResearchResult;
|
|
65
|
+
artifacts?: Array<{
|
|
66
|
+
title: string;
|
|
67
|
+
content?: string;
|
|
68
|
+
contentReviewed: boolean;
|
|
69
|
+
}>;
|
|
70
|
+
}, signal?: AbortSignal) => Promise<ResearchReview>;
|
|
71
|
+
type ToolRecord = {
|
|
72
|
+
toolCallId: string;
|
|
73
|
+
toolName: string;
|
|
74
|
+
body: string;
|
|
75
|
+
url?: string;
|
|
76
|
+
observedAt: number;
|
|
77
|
+
};
|
|
78
|
+
/** Quotes are matched against persisted successful reads from this execution, never worker-supplied snapshots. */
|
|
79
|
+
export declare function bindResearchSources(submission: TaskResearchSubmission, tools: ToolRecord[]): TaskResearchResult['sources'];
|
|
80
|
+
export declare function applyResearchReview(result: TaskResearchResult, raw: unknown, criteria: string[]): TaskResearchResult;
|
|
81
|
+
export declare const reviewResearchResult: ResearchReviewer;
|
|
82
|
+
export declare function taskInstructionSequence(taskId: string): number;
|
|
83
|
+
export declare function currentTaskResearchResult(runId: string): TaskResearchResult | undefined;
|
|
84
|
+
export declare function submitTaskResearchResult(conversationId: string, toolCallId: string, raw: unknown, signal?: AbortSignal, reviewer?: ResearchReviewer): Promise<TaskResearchResult>;
|
|
85
|
+
export {};
|