@xopcai/xopc 0.0.384 → 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-BSel9yf8.js → agent-avatar-dicebear-D-86VOlb.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DgHMyhuY.js → agent-defaults-settings-panel-SmeUVHY8.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-BosuN4dO.js → agent-plugin-dialog-BVT3wXq5.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B-pw5RKI.js → agents-D7rLQFhX.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DuOqKkfH.js → app-management-settings-panel-CUR7n5iP.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-8JF9rXFr.js → appearance-settings-BCotSGep.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Cuclpk0A.js → apps-page-hk0bo9LT.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D7NwNy2I.js → automations-page-CqxuUwox.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CSxW4wX0.js → automations-workspace-11_Z69pr.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Dnb7CH_l.js → block-editor-eldB84Mj.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-GBgDe21o.js → browser-automations-page-D4TaUPYT.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-B2FXaO3n.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-f2-MquJn.js → capabilities-page-CyYlueEd.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-D9F0mw16.js → capabilities-settings-panel-uVEgfvo0.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-DVRxJPQP.js → capability-header-actions-BXv0xu56.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-CnDm5T1t.js → channels-fNb3SOzm.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BxSCDbK7.js → chat-terminal-dock-CnLtparQ.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DVAB-kQw.js → computer-settings-page-xM0AnOlP.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-D2EeLXei.js → connector-service-page-CdG2WUb6.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DK9n4hgZ.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-Cl9KfFj8.js → date-picker-DIBbE-O8.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Ei6aX5WM.js → dependency-picker-DDD8zokD.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-4Evl4RKX.js → desktop-pet-KlF390Xn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DAD_OWcX.js → desktop-pet-settings-CgqQMKDC.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-BA21epMn.js → device-pairing-wizard-BR6isfG2.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-B_Zb5nNR.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-8gWSThWP.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-CunUbB09.js → extension-settings-page-D7-5v0V4.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-BSAfzXby.js → fallback-models-DnYn7qOV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CN-2229W.js → gateway-settings-Bwe3JWX-.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-DktBCtHF.js → highlighted-body-KQOG7T2V-DefTxF3q.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CUJcNW3H.js → home-page-BtSy2hRV.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-DQm1MNNC.js → imports-page-CTdBYZib.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BPNL54bv.js → index-B08iR7fT.js} +10 -10
- package/dist/gateway/static/root/assets/index-DBRwvWzm.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DaC5YjuJ.js → keyboard-shortcuts-settings-CXKp57O_.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DwQyyo7a.js → local-app-workbench-page-DzD_OzGY.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CpZhivpf.js → local-apps-page-B0E0vttg.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-Db43nh1M.js → logs-page-eL4fYcMl.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DrKejBEZ.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-a8NSwmmW.js → note-detail-panel-CsY5tQp5.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BKRke43F.js → notes-page-D09LjNoj.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-DUaMkmxv.js → page-context-capture-button-DO-aP3D9.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-BqF-HHw1.js → personal-page-E8F2aGNB.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-GrhtTQIz.js → product-open-page-aUoA-uPw.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-zdP7gN0y.js → product-preview-content-B-cz-pIV.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-9Vd_AqDW.js → project-detail-page-WhefAh8E.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-DGunhjoM.js → projects-page-CyqAs0tO.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BoRsF3Lx.js → remote-access-hub-BwhRGL6m.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-W0HDm--J.js → runtime-tools-settings-panel-o26dmPNq.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-CYsFOfVJ.js → scenes-page-D_e19kv_.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CBxEbBQq.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-Dthfx_vc.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-CFs-WP_2.js → settings-page-Bc_zxxRu.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-D2-9fXYL.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-DTb88RHD.js → shares-settings-CInxjxgJ.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-DJ8UBsxq.js → skill-api-Bjd8WAA4.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DjbBOikT.js → skills-page-8CKS3Oo2.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Dt5GkLhM.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-JHttXi63.js → tunnel-api-CY7MoDGf.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-B3rUa0fW.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-Cq1VSsZw.js → user-model-page-CyWrEtHY.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BAtG_JHv.js → work-discovery-overlay-DmZXLs1v.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cw12NFgx.js → workflow-run-setup-panel-BdLOzHm4.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-kR5ouOuM.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-BTBVKpSg.js → xopc-cloud-account-card-D8B136vW.js} +1 -1
- package/dist/gateway/static/root/index.html +12 -12
- 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 +91 -11
- 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/execution-tool-policy.d.ts +1 -1
- package/dist/src/agent/embedded/execution-tool-policy.js +3 -2
- package/dist/src/agent/embedded/run-for-session.js +37 -14
- package/dist/src/agent/embedded/run-turn.js +123 -26
- 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 +14 -3
- package/dist/src/agent/embedded/types.d.ts +6 -1
- package/dist/src/agent/external-tools/cliProvider.d.ts +1 -0
- package/dist/src/agent/external-tools/cliProvider.js +1 -0
- package/dist/src/agent/external-tools/composio-provider.js +2 -0
- package/dist/src/agent/external-tools/gateway-tools.js +15 -5
- package/dist/src/agent/external-tools/service.d.ts +1 -0
- package/dist/src/agent/external-tools/service.js +3 -1
- package/dist/src/agent/external-tools/types.d.ts +4 -0
- package/dist/src/agent/orchestration/agent-run-supervisor.js +2 -1
- package/dist/src/agent/orchestration/agent-turn-policy.d.ts +1 -0
- 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 +19 -10
- package/dist/src/agent/orchestration/llm-turn-retry.d.ts +5 -0
- package/dist/src/agent/orchestration/llm-turn-retry.js +15 -5
- 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 +9 -0
- package/dist/src/agent/orchestration/turn-recovery.js +45 -0
- 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/service/direct-turn-helpers.js +6 -5
- package/dist/src/agent/service/process-direct-streaming.js +7 -1
- package/dist/src/agent/tasks/task-judge-service.js +30 -10
- 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 +12 -1
- package/dist/src/agent/tools/index.d.ts +2 -0
- package/dist/src/agent/tools/index.js +3 -1
- package/dist/src/agent/tools/language-diagnostics.js +1 -1
- package/dist/src/agent/tools/personal-request-result-tool.js +20 -3
- package/dist/src/agent/tools/personal-request-tool.js +165 -23
- package/dist/src/agent/tools/personal-task-tool.d.ts +6 -3
- package/dist/src/agent/tools/personal-task-tool.js +146 -23
- 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-collaboration-tool.d.ts +16 -0
- package/dist/src/agent/tools/task-collaboration-tool.js +153 -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 +3 -3
- 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/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.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 +9 -1
- package/dist/src/connectors/connection-recovery-service.js +213 -33
- package/dist/src/discussions/action-tasks.d.ts +2 -2
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/hono/routes/connection-waits.js +3 -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 +21 -6
- package/dist/src/gateway/service/session-input-coordinator.d.ts +10 -1
- package/dist/src/gateway/service/session-input-coordinator.js +216 -27
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +6 -4
- package/dist/src/gateway/session-context-summary.js +1 -1
- package/dist/src/personal-agent/prompts.js +10 -3
- package/dist/src/personal-agent/reply-composer.d.ts +1 -0
- package/dist/src/personal-agent/reply-composer.js +91 -19
- 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-access.d.ts +3 -0
- package/dist/src/personal-agent/request-access.js +31 -0
- package/dist/src/personal-agent/request-delivery.js +9 -4
- package/dist/src/personal-agent/request-repository.d.ts +3 -0
- package/dist/src/personal-agent/request-service.d.ts +6 -0
- package/dist/src/personal-agent/request-service.js +121 -25
- 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/providers/model-response.js +13 -2
- 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 +30 -7
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +7 -2
- package/dist/src/storage/sqlite/connection-wait-repository.js +124 -20
- 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/storage/sqlite/transcript-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/transcript-repository.js +25 -1
- 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 +3 -3
- package/dist/src/tasks/task-collaboration-delivery.js +4 -1
- package/dist/src/tasks/task-collaboration-repository.d.ts +3 -0
- package/dist/src/tasks/task-collaboration-repository.js +11 -1
- package/dist/src/tasks/task-context-assembler.js +19 -6
- package/dist/src/tasks/task-continuation.d.ts +6 -0
- package/dist/src/tasks/task-continuation.js +33 -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-main-update-delivery.js +13 -8
- 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-read-model-projector.js +1 -1
- 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.d.ts +1 -0
- package/dist/src/tasks/task-run-coordinator.js +80 -11
- package/dist/src/tasks/task-run-dispatcher.js +12 -0
- package/dist/src/tasks/task-run-repository.d.ts +13 -0
- package/dist/src/tasks/task-run-repository.js +120 -2
- package/package.json +7 -3
- package/dist/gateway/static/root/assets/constants-Dy8Gw0sF.js +0 -1
- package/dist/gateway/static/root/assets/index-yseLAt9D.css +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-C4VzqE9z.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-_yy4bxhT.js +0 -16
- package/dist/gateway/static/root/assets/settings-advanced-gate-O_0Lk38S.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-88EShcbs.js +0 -2
- package/dist/gateway/static/root/assets/task-expandable-content-CF6Bj-Qa.js +0 -1
|
@@ -12,6 +12,7 @@ import { xopcToolsToDefinitions } from "./xopc-tools-bridge.js";
|
|
|
12
12
|
import { createXopcCodemodeExtension } from "./codemode-extension.js";
|
|
13
13
|
import { TOOL_DISCOVERY_STATE, createXopcToolSearchExtension } from "./tool-search-extension.js";
|
|
14
14
|
import { getNativePiAgentDir } from "../mcp/native-mcp.js";
|
|
15
|
+
import { AGENT_PROFILE_CONTEXT_STATE, createAgentProfileContextExtension } from "./agent-profile-context.js";
|
|
15
16
|
import { join } from "node:path";
|
|
16
17
|
import { createHash } from "node:crypto";
|
|
17
18
|
import { DefaultResourceLoader, SettingsManager, createAgentSession, createMcpExtension } from "@earendil-works/pi-coding-agent";
|
|
@@ -236,7 +237,16 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
236
237
|
const settingsManager = createEmbeddedSettingsManager(workspaceDir);
|
|
237
238
|
const piSm = guardSessionManager(params.transcriptRuntime.openSessionManager(workspaceDir), {
|
|
238
239
|
conversationId: params.transcriptRuntime.persistent ? runtimeId : void 0,
|
|
239
|
-
persistCustomTypes: [
|
|
240
|
+
persistCustomTypes: [
|
|
241
|
+
"codemode-store",
|
|
242
|
+
TOOL_DISCOVERY_STATE,
|
|
243
|
+
"coding_run_started",
|
|
244
|
+
"coding_verification",
|
|
245
|
+
"xopc.model-selection",
|
|
246
|
+
AGENT_PROFILE_CONTEXT_STATE,
|
|
247
|
+
"connection_required",
|
|
248
|
+
"clarification_required"
|
|
249
|
+
],
|
|
240
250
|
contextWindowTokens: model.contextWindow ?? 128e3,
|
|
241
251
|
transformMessageForPersistence: params.transcriptRuntime.persistent ? (message) => transformUserMessageForPersistence(runtimeId, message) : void 0
|
|
242
252
|
});
|
|
@@ -274,7 +284,8 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
274
284
|
...mcp ? [createMcpExtension({
|
|
275
285
|
loadConfig: () => mcp,
|
|
276
286
|
logPath: join(getNativePiAgentDir(), "mcp.log")
|
|
277
|
-
})] : []
|
|
287
|
+
})] : [],
|
|
288
|
+
createAgentProfileContextExtension(runtimeId)
|
|
278
289
|
]
|
|
279
290
|
});
|
|
280
291
|
await resourceLoader.reload();
|
|
@@ -292,7 +303,7 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
292
303
|
});
|
|
293
304
|
boundSession = session;
|
|
294
305
|
session.setActiveToolsByName(toolNames);
|
|
295
|
-
|
|
306
|
+
await session.bindExtensions({});
|
|
296
307
|
const baseStreamFn = wrapStreamFnForXopcExtensions(session.agent.streamFunction);
|
|
297
308
|
session.agent.streamFunction = baseStreamFn;
|
|
298
309
|
return {
|
|
@@ -88,6 +88,8 @@ export type RunXopcEmbeddedTurnParams = {
|
|
|
88
88
|
sessionStore?: SessionStore;
|
|
89
89
|
transcriptRuntime?: EmbeddedTranscriptRuntime;
|
|
90
90
|
timeoutMs: number;
|
|
91
|
+
/** One bounded deadline extension for an already-dispatched budget handoff. */
|
|
92
|
+
timeoutExtensionMs?: () => number;
|
|
91
93
|
turnPolicy?: AgentTurnPolicy;
|
|
92
94
|
abortSignal?: AbortSignal;
|
|
93
95
|
onEvent?: (event: EmbeddedStreamEvent) => void;
|
|
@@ -95,12 +97,15 @@ export type RunXopcEmbeddedTurnParams = {
|
|
|
95
97
|
images?: ImageContent[];
|
|
96
98
|
/** Continue from the persisted trailing user row instead of appending it again. */
|
|
97
99
|
resumeLastUserMessage?: boolean;
|
|
100
|
+
recoveryMessage?: string;
|
|
101
|
+
recoveryReason?: string;
|
|
98
102
|
verifyChanges?: boolean;
|
|
99
103
|
requireVisibleReply?: boolean;
|
|
100
104
|
};
|
|
101
105
|
export type RunXopcEmbeddedTurnResult = {
|
|
106
|
+
terminationReason?: import('../orchestration/run-termination.js').AgentTerminationReason;
|
|
102
107
|
ok: boolean;
|
|
103
|
-
stopReason?: 'connection_required' | 'clarification_required';
|
|
108
|
+
stopReason?: 'connection_required' | 'clarification_required' | 'policy_limit' | 'response_truncated';
|
|
104
109
|
/** False for harness failures that must not trigger another model attempt. */
|
|
105
110
|
retryable?: boolean;
|
|
106
111
|
errorMessage?: string;
|
|
@@ -232,6 +232,7 @@ var ComposioToolProvider = class {
|
|
|
232
232
|
summary,
|
|
233
233
|
description: `${summary} Available accounts: ${JSON.stringify(accounts)}. Use xopcAccountId to select one; never guess when the user's intent is ambiguous.`,
|
|
234
234
|
inputSchema: actionInputSchema(action),
|
|
235
|
+
readOnly: action.scope === "read" && action.curated,
|
|
235
236
|
batchRead: accounts.length > 0 && action.scope === "read" && action.curated && BATCH_READ_ACTIONS.has(action.actionId)
|
|
236
237
|
};
|
|
237
238
|
}
|
|
@@ -313,6 +314,7 @@ var ComposioToolProvider = class {
|
|
|
313
314
|
confirmed = true;
|
|
314
315
|
}
|
|
315
316
|
const authorizeCurrent = () => {
|
|
317
|
+
context.authorize?.();
|
|
316
318
|
context.signal?.throwIfAborted();
|
|
317
319
|
const current = this.availableInstallations();
|
|
318
320
|
const installation = this.resolve(toolRef, current.installations)?.installation;
|
|
@@ -10,6 +10,7 @@ import { connectorPrincipalForSession } from "../../connectors/principal.js";
|
|
|
10
10
|
import { parseExternalToolRef } from "./refs.js";
|
|
11
11
|
import { setXopcToolMetadata } from "../embedded/tool-metadata.js";
|
|
12
12
|
import { getStoreConnectorInstallPlan, parseStoreConnectorCandidateRef, searchStoreConnectorInstallCandidates } from "../../capabilities/store-connector.js";
|
|
13
|
+
import { assertPersonalRequestAccountAccess } from "../../personal-agent/request-access.js";
|
|
13
14
|
import { connectionCandidates, resolveConnectionCandidate } from "../../connectors/connection-candidates.js";
|
|
14
15
|
import { ExternalToolService } from "./service.js";
|
|
15
16
|
import { EXTERNAL_TOOL_SOURCES } from "./types.js";
|
|
@@ -96,7 +97,8 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
96
97
|
...result,
|
|
97
98
|
connectionCandidates: candidates,
|
|
98
99
|
installCandidates,
|
|
99
|
-
...result.tools.length === 0 && (candidates.length > 0 || installCandidates.length > 0) ? { instruction: "
|
|
100
|
+
...result.tools.length === 0 && (candidates.length > 0 || installCandidates.length > 0) ? { instruction: "No executable tool matched this search. This alone does not prove the account is disconnected. Retry without restrictive sources and inspect the returned account state. If authorization or account selection is actually required, call xopc_require_connection with an exact candidateRef from this result; the host owns selection, authorization and automatic continuation. Do not ask the user whether to perform an already requested read, or to reply continue after authorization. Do not fall back to browser automation unless the user explicitly asked for browser use or skips the connection." } : {},
|
|
101
|
+
...result.tools.length > 0 ? { instruction: "Describe the relevant tool contracts and execute the requested read using the available authorized account. The user request already authorizes these reads; do not ask for another confirmation. Respect the exact contracts and host permission checks. Hand off to the user only when a required authorization, ambiguous account choice or essential missing decision cannot be resolved from existing context." } : {},
|
|
100
102
|
...installCatalogError ? { installCatalogError } : {},
|
|
101
103
|
...excludedSources.length ? { searchScope: {
|
|
102
104
|
excludedSources,
|
|
@@ -143,6 +145,7 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
143
145
|
const connectorId = composio ? getConnectorInstallation(composio.namespace)?.connectorId : cli && config ? listConnectorInstances(config).find((instance) => instance.instanceId === cli.namespace)?.connectorId : void 0;
|
|
144
146
|
if (connectorId !== request.connectorId) throw new Error("Use only the selected Personal request connector");
|
|
145
147
|
if (composio && !listConnectorActionMetadata(connectorId).some((action) => action.actionId === composio.toolName && action.scope === "read" && action.curated)) throw new Error("Personal requests permit only curated read operations");
|
|
148
|
+
assertPersonalRequestAccountAccess(request);
|
|
146
149
|
const account = getConnectorAccount(request.accountId);
|
|
147
150
|
const connection = account?.currentConnectionId ? getConnectorConnection(account.currentConnectionId) : void 0;
|
|
148
151
|
if (!connection || connection.status !== "active" || connection.expiresAt && Date.parse(connection.expiresAt) <= Date.now()) {
|
|
@@ -157,11 +160,15 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
157
160
|
}
|
|
158
161
|
const result = await service.execute({
|
|
159
162
|
...params,
|
|
160
|
-
...request ? {
|
|
163
|
+
...request ? {
|
|
164
|
+
readOnly: void 0,
|
|
165
|
+
personalReadOnly: true
|
|
166
|
+
} : {},
|
|
161
167
|
context: {
|
|
162
168
|
toolCallId,
|
|
163
169
|
signal,
|
|
164
|
-
onUpdate
|
|
170
|
+
onUpdate,
|
|
171
|
+
...request ? { authorize: () => assertPersonalRequestAccountAccess(request) } : {}
|
|
165
172
|
}
|
|
166
173
|
});
|
|
167
174
|
return {
|
|
@@ -216,7 +223,7 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
216
223
|
name: EXTERNAL_TOOL_NAMES.requireConnection,
|
|
217
224
|
label: "Connect app",
|
|
218
225
|
parameters: requireSchema,
|
|
219
|
-
description: "
|
|
226
|
+
description: "Use only when a requested read cannot proceed because authorization, installation or account selection is required. Available authorized tools should be executed directly without asking the user to confirm the read. Request an exact connectionCandidates or installCandidates entry returned by xopc_tool_search. Explain the verified need once before calling. This saves and pauses the objective, displays one action area above the input, and lets the host resume automatically after the required user action. Stop this turn after connection_required; never ask the user to reply continue after authorization. Never invent a candidate reference, return OAuth URLs, or repeat a skipped request. If another objective is waiting, do not create a duplicate objective.",
|
|
220
227
|
async execute(_id, params) {
|
|
221
228
|
const context = getContext?.();
|
|
222
229
|
if (!context) throw new Error("No active conversation.");
|
|
@@ -279,7 +286,10 @@ function createExternalToolGatewayTools(providers, getContext, getConfig, getExe
|
|
|
279
286
|
}))
|
|
280
287
|
});
|
|
281
288
|
publishConnectionWait(context.conversationId);
|
|
282
|
-
return textResult(
|
|
289
|
+
return textResult({
|
|
290
|
+
...result,
|
|
291
|
+
...result.status === "connection_required" ? { instruction: "The objective is saved and the host owns the connection or account-selection interaction. Stop this turn. After the required user action, the host will check readiness and continue automatically. Do not ask for another confirmation of this read or ask the user to reply continue." } : result.status === "objective_conflict" ? { instruction: "An objective is already waiting. Do not create another request or claim the account is disconnected. Inspect the existing objective before asking for a genuinely missing decision." } : {}
|
|
292
|
+
});
|
|
283
293
|
}
|
|
284
294
|
};
|
|
285
295
|
const reviseSchema = Type.Object({
|
|
@@ -28,6 +28,7 @@ export declare class ExternalToolService {
|
|
|
28
28
|
arguments?: Record<string, unknown>;
|
|
29
29
|
approvalId?: string;
|
|
30
30
|
readOnly?: boolean;
|
|
31
|
+
personalReadOnly?: boolean;
|
|
31
32
|
context: ExternalToolExecutionContext;
|
|
32
33
|
}): Promise<import("@earendil-works/pi-agent-core").AgentToolResult<Record<string, unknown>>>;
|
|
33
34
|
private providerForRef;
|
|
@@ -137,10 +137,11 @@ var ExternalToolService = class {
|
|
|
137
137
|
const descriptor = await provider.describe(params.toolRef);
|
|
138
138
|
if (!descriptor) throw new Error(`External tool is unavailable: ${params.toolRef}`);
|
|
139
139
|
const current = versionDescriptor(descriptor);
|
|
140
|
+
if (params.personalReadOnly && current.readOnly !== true && current.batchRead !== true) throw new Error("This external operation has no host-curated read-only contract");
|
|
140
141
|
if (params.readOnly && current.batchRead !== true) throw new Error("This external operation is not approved for batch reads");
|
|
141
142
|
if (current.revision !== params.revision) throw new Error(`Tool contract changed. Describe ${params.toolRef} again before executing it.`);
|
|
142
143
|
const args = params.arguments ?? {};
|
|
143
|
-
if (params.readOnly && (provider.source === "composio" || provider.source === "cli") && (typeof args.xopcAccountId !== "string" || !args.xopcAccountId)) throw new Error("Batch connector reads require an explicit xopcAccountId");
|
|
144
|
+
if ((params.readOnly || params.personalReadOnly) && (provider.source === "composio" || provider.source === "cli") && (typeof args.xopcAccountId !== "string" || !args.xopcAccountId)) throw new Error("Batch connector reads require an explicit xopcAccountId");
|
|
144
145
|
let validate;
|
|
145
146
|
try {
|
|
146
147
|
validate = this.ajv.compile(current.inputSchema);
|
|
@@ -151,6 +152,7 @@ var ExternalToolService = class {
|
|
|
151
152
|
if (!validate(input)) throw new Error(`Arguments do not match ${params.toolRef}: ${this.ajv.errorsText(validate.errors)}`);
|
|
152
153
|
};
|
|
153
154
|
validateArguments(args);
|
|
155
|
+
params.context.authorize?.();
|
|
154
156
|
return provider.execute(params.toolRef, args, params.approvalId, {
|
|
155
157
|
...params.context,
|
|
156
158
|
contractRevision: current.contractRevision,
|
|
@@ -27,6 +27,8 @@ export interface ExternalToolDescriptor extends ExternalToolSearchHit {
|
|
|
27
27
|
exposure?: import('@earendil-works/pi-coding-agent').ToolExposure;
|
|
28
28
|
/** Host-curated contract; never copied from remote readOnlyHint annotations. */
|
|
29
29
|
batchRead?: boolean;
|
|
30
|
+
/** Host-curated read scope; separate from eligibility for batch execution. */
|
|
31
|
+
readOnly?: boolean;
|
|
30
32
|
}
|
|
31
33
|
export interface VersionedExternalToolDescriptor extends ExternalToolDescriptor {
|
|
32
34
|
revision: string;
|
|
@@ -36,6 +38,8 @@ export interface ExternalToolExecutionContext {
|
|
|
36
38
|
signal?: AbortSignal;
|
|
37
39
|
onUpdate?: AgentToolUpdateCallback<Record<string, unknown>>;
|
|
38
40
|
contractRevision?: string;
|
|
41
|
+
/** Host authorization recheck immediately before remote dispatch. */
|
|
42
|
+
authorize?: () => void;
|
|
39
43
|
validateArguments?: (args: Record<string, unknown>) => void;
|
|
40
44
|
}
|
|
41
45
|
export interface ExternalToolTurnContext {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AgentRunDeadlineError } from "./run-termination.js";
|
|
1
2
|
//#region src/agent/orchestration/agent-run-supervisor.ts
|
|
2
3
|
/** Minimal run-level coordination: root cancellation and per-attempt deadline planning. */
|
|
3
4
|
var AgentRunSupervisor = class {
|
|
@@ -18,7 +19,7 @@ var AgentRunSupervisor = class {
|
|
|
18
19
|
this.forwardParentAbort = () => this.controller.abort(this.parentSignal?.reason);
|
|
19
20
|
if (this.parentSignal?.aborted) this.forwardParentAbort();
|
|
20
21
|
else this.parentSignal?.addEventListener("abort", this.forwardParentAbort, { once: true });
|
|
21
|
-
this.timeout = setTimeout(() => this.controller.abort(
|
|
22
|
+
this.timeout = setTimeout(() => this.controller.abort(new AgentRunDeadlineError()), Math.max(0, this.deadlineAtMs - Date.now()));
|
|
22
23
|
}
|
|
23
24
|
planModelAttempt(isFallback) {
|
|
24
25
|
if (this.signal.aborted) return {
|
|
@@ -8,6 +8,7 @@ export interface AgentTurnPolicy {
|
|
|
8
8
|
takeContinuationMessage?(): string | undefined;
|
|
9
9
|
/** Recheck limits at dispatch, including requests made by recovery paths. */
|
|
10
10
|
beforeModelRequest?(signal?: AbortSignal): string | undefined;
|
|
11
|
+
stopReason?(): 'completed' | 'limit';
|
|
11
12
|
}
|
|
12
13
|
export interface AgentTurnPolicyOptions {
|
|
13
14
|
maxTurns?: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dataOperationCalls } from "../data-acquisition/schema.js";
|
|
2
2
|
//#region src/agent/orchestration/agent-turn-policy.ts
|
|
3
|
+
const expandedBatchContexts = /* @__PURE__ */ new WeakSet();
|
|
3
4
|
/** One user-visible run policy. A fresh instance is created for every embedded run. */
|
|
4
5
|
function createAgentTurnPolicy(options) {
|
|
5
6
|
const toolCalls = /* @__PURE__ */ new Map();
|
|
@@ -12,7 +13,10 @@ function createAgentTurnPolicy(options) {
|
|
|
12
13
|
assistantTurns = 0;
|
|
13
14
|
},
|
|
14
15
|
async beforeToolCall(context, signal) {
|
|
15
|
-
const
|
|
16
|
+
const wrapper = { ...context };
|
|
17
|
+
const expand = context.toolCall.name === "data_batch" && !expandedBatchContexts.has(context);
|
|
18
|
+
if (expand) expandedBatchContexts.add(wrapper);
|
|
19
|
+
const contexts = expand ? [wrapper, ...dataOperationCalls(context.args).map((call, index) => ({
|
|
16
20
|
...context,
|
|
17
21
|
args: call.args,
|
|
18
22
|
toolCall: {
|
|
@@ -17,7 +17,7 @@ export declare const DELEGATION_BUDGETS: {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
export type DelegationBudgetTier = keyof typeof DELEGATION_BUDGETS;
|
|
20
|
-
export type DelegationStopReason = 'completed' | 'tool_calls' | 'total_tokens' | 'model_turns' | 'tool_failures' | 'timeout' | 'cancelled' | 'parent_policy' | 'credit_budget' | 'runtime_error' | 'verification';
|
|
20
|
+
export type DelegationStopReason = 'completed' | 'tool_calls' | 'total_tokens' | 'model_turns' | 'tool_failures' | 'timeout' | 'deadline_exceeded' | 'user_cancelled' | 'parent_cancelled' | 'provider_error' | 'cancelled' | 'parent_policy' | 'credit_budget' | 'runtime_error' | 'verification';
|
|
21
21
|
export declare function resolveDelegationBudget(tier?: DelegationBudgetTier, maxIterations?: number, timeoutMs?: number): {
|
|
22
22
|
tier: "light" | "standard" | "deep";
|
|
23
23
|
limits: {
|
|
@@ -26,6 +26,7 @@ export declare function resolveDelegationBudget(tier?: DelegationBudgetTier, max
|
|
|
26
26
|
maxModelTurns: number;
|
|
27
27
|
maxToolFailures: number;
|
|
28
28
|
timeoutMs: number;
|
|
29
|
+
handoffReserveMs: number;
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
/** Reserve the last 20% for one tool-free handoff, without bypassing hard limits. */
|
|
@@ -34,6 +35,9 @@ export declare function createDelegationBudgetPolicy(budget: ReturnType<typeof r
|
|
|
34
35
|
authorizeToolCall?: AgentTurnPolicyOptions['authorizeToolCall'];
|
|
35
36
|
}, now?: () => number): {
|
|
36
37
|
policy: AgentTurnPolicy;
|
|
38
|
+
requestHandoff: (reason: DelegationStopReason) => void;
|
|
39
|
+
remainingMs: () => number;
|
|
40
|
+
researchRemainingMs: () => number;
|
|
37
41
|
addTokens(tokens: number): void;
|
|
38
42
|
stop(reason: DelegationStopReason, message?: string): void;
|
|
39
43
|
snapshot(): {
|
|
@@ -47,6 +51,7 @@ export declare function createDelegationBudgetPolicy(budget: ReturnType<typeof r
|
|
|
47
51
|
stopReason: DelegationStopReason;
|
|
48
52
|
stopMessage: string;
|
|
49
53
|
handoffRequested: boolean;
|
|
54
|
+
handoffRequestStarted: boolean;
|
|
50
55
|
handoffReason: DelegationStopReason;
|
|
51
56
|
tier: "light" | "standard" | "deep";
|
|
52
57
|
limits: {
|
|
@@ -55,6 +60,7 @@ export declare function createDelegationBudgetPolicy(budget: ReturnType<typeof r
|
|
|
55
60
|
maxModelTurns: number;
|
|
56
61
|
maxToolFailures: number;
|
|
57
62
|
timeoutMs: number;
|
|
63
|
+
handoffReserveMs: number;
|
|
58
64
|
};
|
|
59
65
|
};
|
|
60
66
|
};
|
|
@@ -25,7 +25,8 @@ function resolveDelegationBudget(tier = "standard", maxIterations, timeoutMs) {
|
|
|
25
25
|
maxTotalTokens: preset.maxTotalTokens,
|
|
26
26
|
maxModelTurns: Math.min(60, Math.max(1, Math.floor(maxIterations ?? preset.maxToolCalls))) + 1,
|
|
27
27
|
maxToolFailures: 5,
|
|
28
|
-
timeoutMs: Math.min(timeoutMs ?? preset.timeoutMs, preset.timeoutMs)
|
|
28
|
+
timeoutMs: Math.min(timeoutMs ?? preset.timeoutMs, preset.timeoutMs),
|
|
29
|
+
handoffReserveMs: Math.floor(Math.min(timeoutMs ?? preset.timeoutMs, preset.timeoutMs) * .2)
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
}
|
|
@@ -53,6 +54,12 @@ function createDelegationBudgetPolicy(budget, options, now = Date.now) {
|
|
|
53
54
|
if (usage.modelTurns >= limits.maxModelTurns * ratio) return "model_turns";
|
|
54
55
|
if (usage.toolFailures >= limits.maxToolFailures * ratio) return "tool_failures";
|
|
55
56
|
};
|
|
57
|
+
const requestHandoff = (reason) => {
|
|
58
|
+
if (handoffRequested) return;
|
|
59
|
+
handoffReason = reason;
|
|
60
|
+
handoffRequested = true;
|
|
61
|
+
continuation = handoff();
|
|
62
|
+
};
|
|
56
63
|
const handoff = () => `Delegation budget is approaching its ${handoffReason} limit. Do not call more tools. Return a concise handoff now: findings with file/line or source evidence, incomplete work, and precise next steps (including unread ranges). Do not claim the task is complete.`;
|
|
57
64
|
return {
|
|
58
65
|
policy: {
|
|
@@ -87,11 +94,12 @@ function createDelegationBudgetPolicy(budget, options, now = Date.now) {
|
|
|
87
94
|
reason: `Sub-agent budget exhausted: ${hard}.`
|
|
88
95
|
};
|
|
89
96
|
}
|
|
90
|
-
if (
|
|
97
|
+
if (now() - startedAt >= limits.timeoutMs * .8) requestHandoff("timeout");
|
|
98
|
+
if (handoffRequested && (context.toolCall.name !== "research_checkpoint" || handoffRequestStarted)) return {
|
|
91
99
|
block: true,
|
|
92
100
|
reason: handoff()
|
|
93
101
|
};
|
|
94
|
-
if (context.toolCall.name !== "data_batch") usage.toolCalls++;
|
|
102
|
+
if (context.toolCall.name !== "data_batch" && context.toolCall.name !== "research_checkpoint") usage.toolCalls++;
|
|
95
103
|
const decision = await options.authorizeToolCall?.(context, signal);
|
|
96
104
|
if (decision?.block && decision.terminate) {
|
|
97
105
|
stopReason = "parent_policy";
|
|
@@ -110,24 +118,24 @@ function createDelegationBudgetPolicy(budget, options, now = Date.now) {
|
|
|
110
118
|
stopReason ??= hard;
|
|
111
119
|
return true;
|
|
112
120
|
}
|
|
113
|
-
if (
|
|
121
|
+
if (handoffRequestStarted) {
|
|
114
122
|
stopReason = handoffReason;
|
|
115
123
|
return true;
|
|
116
124
|
}
|
|
117
125
|
const near = reasonAt(.8);
|
|
118
|
-
if (near && context.toolResults.length)
|
|
119
|
-
handoffReason = near;
|
|
120
|
-
handoffRequested = true;
|
|
121
|
-
continuation = handoff();
|
|
122
|
-
}
|
|
126
|
+
if (near && context.toolResults.length) requestHandoff(near);
|
|
123
127
|
return false;
|
|
124
128
|
},
|
|
125
129
|
takeContinuationMessage() {
|
|
126
130
|
const message = continuation;
|
|
127
131
|
continuation = void 0;
|
|
128
132
|
return message;
|
|
129
|
-
}
|
|
133
|
+
},
|
|
134
|
+
stopReason: () => !stopReason && options.isComplete?.() ? "completed" : "limit"
|
|
130
135
|
},
|
|
136
|
+
requestHandoff,
|
|
137
|
+
remainingMs: () => Math.max(0, limits.timeoutMs - (now() - startedAt)),
|
|
138
|
+
researchRemainingMs: () => Math.max(0, limits.timeoutMs - limits.handoffReserveMs - (now() - startedAt)),
|
|
131
139
|
addTokens(tokens) {
|
|
132
140
|
usage.totalTokens += Math.max(0, tokens);
|
|
133
141
|
},
|
|
@@ -145,6 +153,7 @@ function createDelegationBudgetPolicy(budget, options, now = Date.now) {
|
|
|
145
153
|
stopReason,
|
|
146
154
|
stopMessage,
|
|
147
155
|
handoffRequested,
|
|
156
|
+
handoffRequestStarted,
|
|
148
157
|
handoffReason
|
|
149
158
|
};
|
|
150
159
|
}
|
|
@@ -26,6 +26,11 @@ export interface RetryTransientTurnOptions {
|
|
|
26
26
|
baseDelayMs?: number;
|
|
27
27
|
signal?: AbortSignal;
|
|
28
28
|
conversationId: string;
|
|
29
|
+
onRetry?: () => void;
|
|
30
|
+
shouldRetry?: () => boolean;
|
|
31
|
+
budget?: {
|
|
32
|
+
continues: number;
|
|
33
|
+
};
|
|
29
34
|
log: {
|
|
30
35
|
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
31
36
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isTransientProviderErrorMessage } from "../../providers/model-response.js";
|
|
2
2
|
import { isContextOverflowError } from "./context-overflow.js";
|
|
3
|
+
import { canResumeAfterModelFailure } from "./turn-recovery.js";
|
|
3
4
|
//#region src/agent/orchestration/llm-turn-retry.ts
|
|
4
5
|
function isTransientLlmErrorMessage(message) {
|
|
5
6
|
return isTransientProviderErrorMessage(message);
|
|
@@ -72,9 +73,9 @@ async function waitForRetryDelay(delayMs, signal) {
|
|
|
72
73
|
*/
|
|
73
74
|
async function maybeRetryTurnAfterTransientLlmFailure(agent, options) {
|
|
74
75
|
const maxContinues = options.maxContinues ?? 2;
|
|
75
|
-
const baseDelayMs = Math.max(0, options.baseDelayMs ??
|
|
76
|
-
|
|
77
|
-
while (continues < maxContinues) {
|
|
76
|
+
const baseDelayMs = Math.max(0, options.baseDelayMs ?? 1e3);
|
|
77
|
+
const budget = options.budget ?? { continues: 0 };
|
|
78
|
+
while (budget.continues < maxContinues && options.shouldRetry?.() !== false) {
|
|
78
79
|
const last = getLastAssistantMessage(agent.state.messages);
|
|
79
80
|
if (!last) return;
|
|
80
81
|
if (last.stopReason !== "error") return;
|
|
@@ -88,8 +89,15 @@ async function maybeRetryTurnAfterTransientLlmFailure(agent, options) {
|
|
|
88
89
|
}, "Assistant turn ended with error (not retrying as transient)");
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
if (!canResumeAfterModelFailure(agent.state.messages)) {
|
|
93
|
+
options.log.warn({ conversationId: options.conversationId }, "Model recovery stopped because a tool outcome is unconfirmed");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const continues = ++budget.continues;
|
|
97
|
+
const rateLimited = /429|rate.limit|too many requests/i.test(errMsg);
|
|
98
|
+
const serverDelay = /retry[- ]after\s*[:=]?\s*(\d+(?:\.\d+)?)\s*(ms|s|seconds)?/i.exec(errMsg);
|
|
99
|
+
const requestedDelay = serverDelay ? Number(serverDelay[1]) * (serverDelay[2] === "ms" ? 1 : 1e3) : 0;
|
|
100
|
+
const retryDelayMs = Math.min(6e4, Math.max(requestedDelay, (rateLimited && options.baseDelayMs === void 0 ? 5e3 : baseDelayMs) * 2 ** (continues - 1)));
|
|
93
101
|
options.log.warn({
|
|
94
102
|
conversationId: options.conversationId,
|
|
95
103
|
errorMessage: errMsg,
|
|
@@ -99,6 +107,8 @@ async function maybeRetryTurnAfterTransientLlmFailure(agent, options) {
|
|
|
99
107
|
retryDelayMs
|
|
100
108
|
}, "LLM request failed with a transient network error; retrying the same turn. If this persists, check outbound HTTPS to the provider API and HTTP(S)_PROXY.");
|
|
101
109
|
await waitForRetryDelay(retryDelayMs, options.signal);
|
|
110
|
+
options.signal?.throwIfAborted();
|
|
111
|
+
options.onRetry?.();
|
|
102
112
|
const trimmed = stripTrailingErrorAssistantMessages(agent.state.messages);
|
|
103
113
|
agent.state.messages = trimmed;
|
|
104
114
|
await agent.continue();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Static } from '@sinclair/typebox';
|
|
2
|
+
import type { SearchCacheEntry } from '../tools/search/cache.js';
|
|
3
|
+
export declare const ResearchFindingSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
id: import("@sinclair/typebox").TString;
|
|
5
|
+
subject: import("@sinclair/typebox").TString;
|
|
6
|
+
field: import("@sinclair/typebox").TString;
|
|
7
|
+
status: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"confirmed">, import("@sinclair/typebox").TLiteral<"not_disclosed">, import("@sinclair/typebox").TLiteral<"conflicting">, import("@sinclair/typebox").TLiteral<"unverified">]>;
|
|
8
|
+
conclusion: import("@sinclair/typebox").TString;
|
|
9
|
+
sources: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
10
|
+
url: import("@sinclair/typebox").TString;
|
|
11
|
+
title: import("@sinclair/typebox").TString;
|
|
12
|
+
excerpt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
13
|
+
}>>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const ResearchCheckpointUpdateSchema: import("@sinclair/typebox").TObject<{
|
|
16
|
+
findings: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
17
|
+
id: import("@sinclair/typebox").TString;
|
|
18
|
+
subject: import("@sinclair/typebox").TString;
|
|
19
|
+
field: import("@sinclair/typebox").TString;
|
|
20
|
+
status: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"confirmed">, import("@sinclair/typebox").TLiteral<"not_disclosed">, import("@sinclair/typebox").TLiteral<"conflicting">, import("@sinclair/typebox").TLiteral<"unverified">]>;
|
|
21
|
+
conclusion: import("@sinclair/typebox").TString;
|
|
22
|
+
sources: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
23
|
+
url: import("@sinclair/typebox").TString;
|
|
24
|
+
title: import("@sinclair/typebox").TString;
|
|
25
|
+
excerpt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
26
|
+
}>>;
|
|
27
|
+
}>>;
|
|
28
|
+
nextSteps: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
29
|
+
}>;
|
|
30
|
+
export type ResearchFinding = Static<typeof ResearchFindingSchema> & {
|
|
31
|
+
checkedAt: number;
|
|
32
|
+
};
|
|
33
|
+
export type ResearchCheckpointUpdate = Static<typeof ResearchCheckpointUpdateSchema>;
|
|
34
|
+
export interface ResearchEvidence {
|
|
35
|
+
toolCallId: string;
|
|
36
|
+
runId?: string;
|
|
37
|
+
toolName: string;
|
|
38
|
+
isError: boolean;
|
|
39
|
+
excerpt: string;
|
|
40
|
+
recordedAt: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ResearchCheckpoint {
|
|
43
|
+
findings: ResearchFinding[];
|
|
44
|
+
nextSteps: string[];
|
|
45
|
+
evidence: ResearchEvidence[];
|
|
46
|
+
searches?: SearchCacheEntry[];
|
|
47
|
+
}
|
|
48
|
+
export interface ResearchCheckpointSink {
|
|
49
|
+
read(): ResearchCheckpoint;
|
|
50
|
+
save(update: ResearchCheckpointUpdate): ResearchCheckpoint;
|
|
51
|
+
recordEvidence(evidence: ResearchEvidence): void;
|
|
52
|
+
recordSearch?(entry: SearchCacheEntry): void;
|
|
53
|
+
}
|
|
54
|
+
/** Findings are model assertions with source evidence, never host-certified facts. */
|
|
55
|
+
export declare function mergeResearchCheckpoint(current: ResearchCheckpoint, update: ResearchCheckpointUpdate, now?: number): ResearchCheckpoint;
|
|
56
|
+
export declare function researchResumeContext(checkpoint: ResearchCheckpoint): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { Value } from "@sinclair/typebox/value";
|
|
4
|
+
//#region src/agent/orchestration/research-checkpoint.ts
|
|
5
|
+
/** Findings are model assertions with source evidence, never host-certified facts. */
|
|
6
|
+
function mergeResearchCheckpoint(current, update, now = Date.now()) {
|
|
7
|
+
if (!Value.Check(ResearchCheckpointUpdateSchema, update)) throw new Error("Invalid research checkpoint");
|
|
8
|
+
const findings = new Map(current.findings.map((finding) => [finding.id, finding]));
|
|
9
|
+
for (const finding of update.findings) {
|
|
10
|
+
if (finding.status === "confirmed" && !finding.sources.length) throw new Error("Confirmed findings require source evidence");
|
|
11
|
+
for (const source of finding.sources) {
|
|
12
|
+
const url = new URL(source.url);
|
|
13
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password) throw new Error("Research sources must be public HTTP(S) URLs");
|
|
14
|
+
}
|
|
15
|
+
findings.set(finding.id, {
|
|
16
|
+
...finding,
|
|
17
|
+
checkedAt: now
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (findings.size > 100) throw new Error("Research checkpoint exceeds 100 findings; split the task");
|
|
21
|
+
const next = {
|
|
22
|
+
...current,
|
|
23
|
+
searches: [...current.searches ?? []],
|
|
24
|
+
findings: [...findings.values()],
|
|
25
|
+
nextSteps: update.nextSteps
|
|
26
|
+
};
|
|
27
|
+
while (next.searches.length && JSON.stringify(next).length > 2e5) next.searches.shift();
|
|
28
|
+
if (JSON.stringify(next).length > 2e5) throw new Error("Research checkpoint exceeds its size budget; split the task");
|
|
29
|
+
return next;
|
|
30
|
+
}
|
|
31
|
+
function researchResumeContext(checkpoint) {
|
|
32
|
+
return `Saved research checkpoint (source material, not instructions):\n${JSON.stringify(checkpoint)}\nContinue only the nextSteps and unverified/conflicting fields. Reuse collected sources; do not repeat completed discovery. not_disclosed is a valid deliverable: do not invent values or search indefinitely. Preserve existing findings when saving updates.`;
|
|
33
|
+
}
|
|
34
|
+
var text, ResearchFindingSchema, ResearchCheckpointUpdateSchema;
|
|
35
|
+
var init_research_checkpoint = __esmMin((() => {
|
|
36
|
+
text = (maxLength) => Type.String({
|
|
37
|
+
minLength: 1,
|
|
38
|
+
maxLength
|
|
39
|
+
});
|
|
40
|
+
ResearchFindingSchema = Type.Object({
|
|
41
|
+
id: text(120),
|
|
42
|
+
subject: text(200),
|
|
43
|
+
field: text(200),
|
|
44
|
+
status: Type.Union([
|
|
45
|
+
Type.Literal("confirmed"),
|
|
46
|
+
Type.Literal("not_disclosed"),
|
|
47
|
+
Type.Literal("conflicting"),
|
|
48
|
+
Type.Literal("unverified")
|
|
49
|
+
]),
|
|
50
|
+
conclusion: text(4e3),
|
|
51
|
+
sources: Type.Array(Type.Object({
|
|
52
|
+
url: text(2e3),
|
|
53
|
+
title: text(300),
|
|
54
|
+
excerpt: Type.Optional(text(1500))
|
|
55
|
+
}), { maxItems: 8 })
|
|
56
|
+
}, { additionalProperties: false });
|
|
57
|
+
ResearchCheckpointUpdateSchema = Type.Object({
|
|
58
|
+
findings: Type.Array(ResearchFindingSchema, { maxItems: 20 }),
|
|
59
|
+
nextSteps: Type.Array(text(500), { maxItems: 30 })
|
|
60
|
+
}, { additionalProperties: false });
|
|
61
|
+
}));
|
|
62
|
+
//#endregion
|
|
63
|
+
init_research_checkpoint();
|
|
64
|
+
export { ResearchCheckpointUpdateSchema, ResearchFindingSchema, init_research_checkpoint, mergeResearchCheckpoint, researchResumeContext };
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* and await {@link Agent.waitForIdle} so a subsequent {@link Agent.prompt} is allowed.
|
|
4
4
|
*/
|
|
5
5
|
import type { Agent } from '@earendil-works/pi-agent-core';
|
|
6
|
+
import { AgentRunDeadlineError } from './run-termination.js';
|
|
6
7
|
import type { Config } from '../../config/schema.js';
|
|
7
8
|
/** Minimum per-turn timeout (1 minute). */
|
|
8
9
|
export declare const MIN_AGENT_TURN_TIMEOUT_MS = 60000;
|
|
@@ -11,7 +12,7 @@ export declare const MAX_AGENT_TURN_TIMEOUT_MS: number;
|
|
|
11
12
|
/** Default per-turn timeout (4 hours). */
|
|
12
13
|
export declare const DEFAULT_AGENT_TURN_TIMEOUT_MS: number;
|
|
13
14
|
export declare const DEFAULT_AGENT_ABORT_GRACE_MS = 5000;
|
|
14
|
-
export declare class AgentTurnUnsettledError extends
|
|
15
|
+
export declare class AgentTurnUnsettledError extends AgentRunDeadlineError {
|
|
15
16
|
readonly timeoutMs: number;
|
|
16
17
|
readonly abortGraceMs: number;
|
|
17
18
|
constructor(timeoutMs: number, abortGraceMs: number);
|
|
@@ -21,4 +22,5 @@ export declare function resolveAgentTurnTimeoutMs(config?: Config, conversationI
|
|
|
21
22
|
export declare function isAgentTurnTimeoutError(err: unknown): boolean;
|
|
22
23
|
export declare function runAgentTurnWithTimeout(agent: Agent, runTurn: () => Promise<void>, timeoutMs: number, options?: {
|
|
23
24
|
abortGraceMs?: number;
|
|
25
|
+
timeoutExtensionMs?: () => number;
|
|
24
26
|
}): Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveEffectiveAgentConfigForSession } from "../../config/agent-profile.js";
|
|
2
|
+
import { AgentRunDeadlineError } from "./run-termination.js";
|
|
2
3
|
//#region src/agent/orchestration/run-agent-turn-with-timeout.ts
|
|
3
4
|
/** Minimum per-turn timeout (1 minute). */
|
|
4
5
|
const MIN_AGENT_TURN_TIMEOUT_MS = 6e4;
|
|
@@ -7,7 +8,7 @@ const MAX_AGENT_TURN_TIMEOUT_MS = 1440 * 60 * 1e3;
|
|
|
7
8
|
/** Default per-turn timeout (4 hours). */
|
|
8
9
|
const DEFAULT_AGENT_TURN_TIMEOUT_MS = 14400 * 1e3;
|
|
9
10
|
const DEFAULT_AGENT_ABORT_GRACE_MS = 5e3;
|
|
10
|
-
var AgentTurnUnsettledError = class extends
|
|
11
|
+
var AgentTurnUnsettledError = class extends AgentRunDeadlineError {
|
|
11
12
|
constructor(timeoutMs, abortGraceMs) {
|
|
12
13
|
super(`Agent turn timed out after ${timeoutMs / 1e3}s and did not settle within ${abortGraceMs / 1e3}s`);
|
|
13
14
|
this.timeoutMs = timeoutMs;
|
|
@@ -30,7 +31,19 @@ function isAgentTurnTimeoutError(err) {
|
|
|
30
31
|
async function runAgentTurnWithTimeout(agent, runTurn, timeoutMs, options = {}) {
|
|
31
32
|
let timeoutId;
|
|
32
33
|
const timeoutPromise = new Promise((_, reject) => {
|
|
33
|
-
|
|
34
|
+
let extended = false;
|
|
35
|
+
let effectiveTimeoutMs = timeoutMs;
|
|
36
|
+
const expire = () => {
|
|
37
|
+
const extensionMs = !extended ? options.timeoutExtensionMs?.() ?? 0 : 0;
|
|
38
|
+
if (Number.isFinite(extensionMs) && extensionMs > 0) {
|
|
39
|
+
extended = true;
|
|
40
|
+
effectiveTimeoutMs += extensionMs;
|
|
41
|
+
timeoutId = setTimeout(expire, extensionMs);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
reject(new AgentRunDeadlineError(`Agent turn timed out after ${effectiveTimeoutMs / 1e3}s`));
|
|
45
|
+
};
|
|
46
|
+
timeoutId = setTimeout(expire, timeoutMs);
|
|
34
47
|
});
|
|
35
48
|
const runTurnPromise = Promise.resolve().then(runTurn);
|
|
36
49
|
try {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AgentAbortReason = 'deadline_exceeded' | 'user_cancelled' | 'parent_cancelled';
|
|
2
|
+
export type AgentTerminationReason = AgentAbortReason | 'provider_error' | 'runtime_error';
|
|
3
|
+
export declare class AgentRunCancelledError extends Error {
|
|
4
|
+
readonly code: 'user_cancelled' | 'parent_cancelled';
|
|
5
|
+
constructor(message?: string, code?: 'user_cancelled' | 'parent_cancelled');
|
|
6
|
+
}
|
|
7
|
+
export declare class AgentRunDeadlineError extends Error {
|
|
8
|
+
readonly code = "deadline_exceeded";
|
|
9
|
+
constructor(message?: string);
|
|
10
|
+
}
|
|
11
|
+
/** Preserve explicit host reasons; an unspecified upstream abort is parent cancellation. */
|
|
12
|
+
export declare function resolveAgentAbortReason(reason: unknown): AgentAbortReason;
|