@xopcai/xopc 0.0.307 → 0.0.309
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/_locales/en/messages.json +8 -0
- package/dist/browser-ext/_locales/zh_CN/messages.json +8 -0
- package/dist/browser-ext/dist/assets/{sidepanel-BbSQr-6P.css → sidepanel-DD6GEMvc.css} +16 -0
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +537 -96
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-wgSB2HYK.js → activity-store-XKNYlFUI.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CZeQo09T.js → agent-avatar-dicebear-1S2TFECE.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-f0-YFMUz.js +1 -0
- package/dist/gateway/static/root/assets/{agents-BlrHMbRx.js → agents-CPqUMtCL.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BKHmTb0w.js → api-BEUEE4f2.js} +1 -1
- package/dist/gateway/static/root/assets/api-CN4id43t.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Bzw4fQP8.js → app-management-settings-panel-CgVBSqzu.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-8GZpUXva.js → appearance-settings-CoWdCokb.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BkQQtIxH.js → apps-page-CexHOcWg.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CQ2NaoHb.js → archive-plugin-C3ZA6LRS.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BFi1H7yJ.js → attachment-load-CdgS6_zy.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CDBXcii_.js → automations-page-BtHL2hpg.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-onJPfmO6.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-D07eWmOx.js → binary-plugins-CiDhtq_H.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CtVnjyYU.js → block-editor-Br00T83w.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BzkJog8e.js → browser-automation-inputs-D2tILykA.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-DyrSbDdG.js → browser-automations-page-BVuEmryB.js} +1 -1
- package/dist/gateway/static/root/assets/browser-settings-page-BgVTyPFY.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Dra8wj1S.js +8 -0
- package/dist/gateway/static/root/assets/{channels-settings-DAD9qE3J.js → channels-settings-CkxiMDJ4.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-B2JwuTjG.js → channels-status-swr-Dtder4G_.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B62SZdAo.js → chat-terminal-dock-JsMtzDao.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-ClSresNq.js → computer-settings-page-DHerePwo.js} +1 -1
- package/dist/gateway/static/root/assets/connector-service-page-DZFNUTiN.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-cl9ZrV4D.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-CTMi_tql.js → cron-expression-DAhdv_Xv.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B71AJK50.js → date-picker-PacO1m3a.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DlyGK-kA.js → dependency-picker-B-BcuG1y.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DGkbTE8_.js → desktop-pet-CdBBhhdY.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BY8r9j66.js → desktop-pet-settings-Gy03NgMI.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-DzRrgd59.js → device-pairing-wizard-aV25nKag.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-L8Mm1n3A.js → extension-debug-page-BFp5eKtY.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CFc4vSNU.js → extension-page-DL3vyyH6.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-B5zWyHr3.js → extension-settings-page-BXtvdAsY.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-B6wHa6ZI.js → gateway-config-swr-xAOGtenO.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-B53R0CA4.js → gateway-realtime-BuaTsMSi.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BG95uGVW.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-D7qmTH4R.js → gateway-settings-Dcr2Ikeh.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DRzGnEV-.js → gateway-startup-retry-BwDxKHd4.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-Glsl3X5b.js → heartbeat-settings-DOy3alvT.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-CDm3dGVy.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-Ck_pyDom.js → image-generation-api-wGMeI_yW.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-ByBX7ome.js → imports-page-zexFT5Rq.js} +1 -1
- package/dist/gateway/static/root/assets/index-D-vczw_0.css +1 -0
- package/dist/gateway/static/root/assets/index-DJo4DimT.js +79 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C45RlO8a.js → keyboard-shortcuts-settings-CutG9zLh.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DP0x2jpR.js → local-app-workbench-page-CwLvTwjn.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-C_AQc2bI.js → local-apps-page-CJy6I7Dt.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-msTfRK8P.js → locale-store-DPZ79W1-.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DvM8Pyok.js → logs-page-egGcPHNi.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-D1uwSutV.js → management-settings-BQhIOELc.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BInabSKf.js → markdown-view-p2P5hP1U.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C4mhf13f.js → media-plugins-CsBylqlN.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BiYTyLJr.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-c2k5Uz6X.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BLQWJMhf.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-1go_BtX1.js → page-tabs-ChQ4jJFs.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DmoSC0j1.js → preview-open-alternatives-9B5W7nVE.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-xAjKTIID.js → proactive-page-iOjI0d_e.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-gmi5LLwM.js → product-open-page-BADxWEdP.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BcxbQn2M.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BuSvld0O.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BSWtko7U.js → registry-api-B_e_nZSN.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CFS8LQKW.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ClkOoxDl.js → runtime-tools-settings-panel-D-pwiIyp.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BuEmLiaU.js → schema-form-IWmb05DX.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DZjc__ok.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C1SM5B93.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Dor39QON.js → settings-form-section-B0veRBZs.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Xj-yvIc8.js → settings-page-CxRWyWYe.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-D9Rl7Tec.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BFWZoXdm.js → share-preview-page-CirpgkfD.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CwCThBs0.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DG6VGbOX.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BdRJ2vnL.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-Ii8qeXhs.js → skills-page.utils-B42mpWKV.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Di6OSO-0.js → system-settings-panel-DXIZpAvU.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-QXo9LJly.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-1SZ-HFHX.js → theme-store-BFbj_2Tu.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DDOlOYlj.js → tunnel-api-Db2guRdW.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CQ8uWNnB.js → use-autosave-DDY9qoXZ.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CzPmMkaO.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-COTzshjL.js → voice-api-key-field-BZbKQ8HT.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DgJML_uM.js → voice-config-api-SKCeQLrH.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-_URrXbi4.js → work-discovery-overlay-BRVTTXNG.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CALs-1nd.js → workflow-run-setup-panel-D2kuwv5e.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CQXtiYtq.js +6 -0
- package/dist/gateway/static/root/index.html +12 -12
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/notifications.js +1 -1
- package/dist/packages/gateway-contract/src/sessions.js +6 -1
- package/dist/src/agent/agent-manager.js +29 -4
- package/dist/src/agent/background-review/prompts.js +3 -1
- package/dist/src/agent/child-agent-factory.d.ts +1 -0
- package/dist/src/agent/child-agent-factory.js +18 -4
- package/dist/src/agent/coding/repository-instructions.d.ts +4 -0
- package/dist/src/agent/coding/repository-instructions.js +46 -2
- package/dist/src/agent/context/execution-context.js +4 -4
- package/dist/src/agent/data-acquisition/git.d.ts +17 -0
- package/dist/src/agent/data-acquisition/git.js +100 -0
- package/dist/src/agent/data-acquisition/render.d.ts +7 -0
- package/dist/src/agent/data-acquisition/render.js +79 -0
- package/dist/src/agent/data-acquisition/scheduler.d.ts +12 -0
- package/dist/src/agent/data-acquisition/scheduler.js +53 -0
- package/dist/src/agent/data-acquisition/schema.d.ts +75 -0
- package/dist/src/agent/data-acquisition/schema.js +206 -0
- package/dist/src/agent/data-acquisition/service.d.ts +10 -0
- package/dist/src/agent/data-acquisition/service.js +292 -0
- package/dist/src/agent/data-acquisition/types.d.ts +37 -0
- package/dist/src/agent/data-acquisition/types.js +5 -0
- package/dist/src/agent/embedded/run-turn.js +16 -4
- package/dist/src/agent/embedded/session-runner.d.ts +1 -0
- package/dist/src/agent/embedded/session-runner.js +3 -0
- package/dist/src/agent/embedded/tool-result-truncation.js +11 -0
- package/dist/src/agent/embedded/xopc-tools-bridge.js +2 -1
- package/dist/src/agent/external-tools/composio-provider.js +12 -1
- package/dist/src/agent/external-tools/gateway-tools.js +2 -1
- package/dist/src/agent/external-tools/index.js +8 -1
- package/dist/src/agent/external-tools/read-policy.d.ts +6 -0
- package/dist/src/agent/external-tools/read-policy.js +21 -0
- package/dist/src/agent/external-tools/service.d.ts +1 -0
- package/dist/src/agent/external-tools/service.js +4 -1
- package/dist/src/agent/external-tools/types.d.ts +2 -0
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -1
- package/dist/src/agent/memory/compaction-promotion.js +4 -3
- package/dist/src/agent/orchestration/agent-turn-policy.js +25 -10
- package/dist/src/agent/orchestration/delegation-scope.d.ts +9 -0
- package/dist/src/agent/orchestration/delegation-scope.js +11 -0
- package/dist/src/agent/prompt/sections/tooling.js +3 -1
- package/dist/src/agent/prompt/subagent-context.js +4 -2
- package/dist/src/agent/sandbox/fileAccess.d.ts +2 -0
- package/dist/src/agent/sandbox/fileAccess.js +31 -2
- package/dist/src/agent/tools/dataBatch.d.ts +4 -0
- package/dist/src/agent/tools/dataBatch.js +50 -0
- package/dist/src/agent/tools/delegate-tool.d.ts +6 -3
- package/dist/src/agent/tools/delegate-tool.js +65 -48
- package/dist/src/agent/tools/delegation-parent-policy.d.ts +7 -0
- package/dist/src/agent/tools/delegation-parent-policy.js +41 -0
- package/dist/src/agent/tools/delegation-policy.d.ts +16 -0
- package/dist/src/agent/tools/delegation-policy.js +93 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +42 -3
- package/dist/src/agent/tools/fetch-text.d.ts +7 -0
- package/dist/src/agent/tools/fetch-text.js +86 -0
- package/dist/src/agent/tools/find.js +1 -1
- package/dist/src/agent/tools/grep.js +11 -23
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +1 -1
- package/dist/src/agent/tools/knowledge-memory-tool.js +13 -5
- package/dist/src/agent/tools/read.js +7 -5
- package/dist/src/agent/tools/repository-search.d.ts +12 -2
- package/dist/src/agent/tools/repository-search.js +127 -74
- package/dist/src/agent/tools/user-context-tool.js +17 -7
- package/dist/src/agent/tools/web.js +19 -28
- package/dist/src/agent/workflow/subagent-runner.js +25 -3
- package/dist/src/agent/workflow/workflow-child-tools.js +13 -8
- package/dist/src/agent-config/schema.d.ts +7 -0
- package/dist/src/agent-config/schema.js +2 -0
- package/dist/src/chat-commands/builtins/understanding.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/config/schema.d.ts +6 -4
- package/dist/src/config/schema.js +2 -2
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
- package/dist/src/connectors/connected-source-understanding.js +1 -0
- package/dist/src/connectors/learning-coordinator.js +31 -9
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/heartbeat/service.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -2
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/context-sources.js +0 -23
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/projects.js +8 -0
- package/dist/src/gateway/hono/routes/sessions.js +141 -13
- package/dist/src/gateway/hono/routes/user-model-refresh.d.ts +5 -0
- package/dist/src/gateway/hono/routes/user-model-refresh.js +128 -0
- package/dist/src/gateway/hono/routes/user-model.js +12 -5
- package/dist/src/gateway/hono/routes/work-discovery.js +0 -30
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
- package/dist/src/knowledge-memory/index.js +2 -2
- package/dist/src/knowledge-memory/repository.d.ts +7 -0
- package/dist/src/knowledge-memory/repository.js +58 -8
- package/dist/src/memory-maintenance/service.js +61 -31
- package/dist/src/migrations/memory-config.d.ts +2 -0
- package/dist/src/migrations/memory-config.js +77 -0
- package/dist/src/migrations/runner.js +2 -2
- package/dist/src/notifications/planner.js +5 -5
- package/dist/src/notifications/service.d.ts +2 -2
- package/dist/src/notifications/service.js +1 -1
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/184_memory_suppressions.sql +12 -0
- package/dist/src/storage/sqlite/migrations/185_understanding_refresh_batches.sql +6 -0
- package/dist/src/storage/sqlite/migrations/186_sidebar_layout.sql +16 -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/schema.js +1 -1
- package/dist/src/storage/sqlite/sidebar-layout-repository.d.ts +12 -0
- package/dist/src/storage/sqlite/sidebar-layout-repository.js +53 -0
- package/dist/src/user-context/config.d.ts +4 -9
- package/dist/src/user-context/config.js +7 -27
- package/dist/src/user-context/memory-suppression.d.ts +7 -0
- package/dist/src/user-context/memory-suppression.js +23 -0
- package/dist/src/user-context/relationship-continuity.js +1 -1
- package/dist/src/user-context/sources/refresh-service.d.ts +48 -0
- package/dist/src/user-context/sources/refresh-service.js +221 -0
- package/dist/src/user-context/sources/repository.js +1 -1
- package/dist/src/user-model/bootstrap.js +27 -24
- package/dist/src/user-model/capture/executor.d.ts +1 -1
- package/dist/src/user-model/capture/executor.js +17 -11
- package/dist/src/user-model/capture/semantic.js +1 -1
- package/dist/src/user-model/domain.d.ts +6 -2
- package/dist/src/user-model/index.js +3 -3
- package/dist/src/user-model/profile.js +1 -1
- package/dist/src/user-model/repository.d.ts +4 -1
- package/dist/src/user-model/repository.js +96 -6
- package/dist/src/user-model/usage-policy.d.ts +2 -0
- package/dist/src/user-model/usage-policy.js +6 -2
- package/dist/src/work-discovery/project-understanding.js +2 -1
- package/dist/src/work-discovery/service.d.ts +8 -24
- package/dist/src/work-discovery/service.js +138 -180
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +0 -1
- package/dist/gateway/static/root/assets/api-DFOlahZv.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +0 -8
- package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +0 -2
- package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +0 -1
- package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +0 -1
- package/dist/gateway/static/root/assets/index-RBCkv8a_.js +0 -79
- package/dist/gateway/static/root/assets/index-cFU4S35z.css +0 -1
- package/dist/gateway/static/root/assets/messages-F74LVAiU.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BE9JXz4U.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +0 -6
- package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +0 -2
- package/dist/src/migrations/knowledge-memory-read-policy-config.js +0 -48
|
@@ -40,7 +40,9 @@ Rules:
|
|
|
40
40
|
- Set selfContained=false and list unresolvedReferences for unresolved pronouns or references.
|
|
41
41
|
- Omit temporary reactions and one-off task instructions.
|
|
42
42
|
- Never include passwords, credentials, regulated identifiers, or speculative diagnoses.
|
|
43
|
-
-
|
|
43
|
+
- Use user_explicit only for a fact or preference the user directly states, user_observed for repeated behavior, and system_inferred for synthesis. No separate remember command is required for an ordinary direct statement.
|
|
44
|
+
- A project-specific choice stays scoped to that project. Do not generalize it into a global preference.
|
|
45
|
+
- Existing memory, assistant output, repeated summaries, and lack of objection are not new supporting evidence.
|
|
44
46
|
- If evidence is insufficient, return candidates=[] and explain abstentionReason.
|
|
45
47
|
${targets}`;
|
|
46
48
|
}
|
|
@@ -30,6 +30,7 @@ export interface DelegateChildProgressHooks {
|
|
|
30
30
|
}) => void;
|
|
31
31
|
}
|
|
32
32
|
export interface DelegateChildHandleOptions {
|
|
33
|
+
authorizeToolCall?: import('./orchestration/agent-turn-policy.js').AgentTurnPolicyOptions['authorizeToolCall'];
|
|
33
34
|
workspace: string;
|
|
34
35
|
goal: string;
|
|
35
36
|
context?: string;
|
|
@@ -29,14 +29,20 @@ function createDelegateChildHandle(options) {
|
|
|
29
29
|
agentId: options.agentId,
|
|
30
30
|
getConfig: options.getConfig,
|
|
31
31
|
toolExecutorConfig: options.toolExecutorConfig,
|
|
32
|
-
browserConversationId: options.requesterConversationId ?? conversationId
|
|
32
|
+
browserConversationId: options.requesterConversationId ?? options.conversationId
|
|
33
33
|
}).filter((tool) => allow.has(tool.name));
|
|
34
34
|
const limit = Math.min(60, Math.max(1, Math.floor(options.maxIterations)));
|
|
35
35
|
let toolIterations = 0, exhausted = false, tokens = 0;
|
|
36
|
+
let terminationReason;
|
|
36
37
|
const policy = createAgentTurnPolicy({
|
|
37
38
|
maxTurns: limit + 1,
|
|
38
39
|
maxToolFailures: 5,
|
|
39
|
-
authorizeToolCall: async () => {
|
|
40
|
+
authorizeToolCall: async (context, signal) => {
|
|
41
|
+
const { toolCall } = context;
|
|
42
|
+
if (!allow.has(toolCall.name)) return {
|
|
43
|
+
block: true,
|
|
44
|
+
reason: "Tool is outside the delegated capability set."
|
|
45
|
+
};
|
|
40
46
|
if (toolIterations >= limit || tokens >= 1e5) {
|
|
41
47
|
exhausted = true;
|
|
42
48
|
return {
|
|
@@ -45,7 +51,15 @@ function createDelegateChildHandle(options) {
|
|
|
45
51
|
reason: "Sub-agent budget exhausted."
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
|
-
toolIterations++;
|
|
54
|
+
if (toolCall.name !== "data_batch") toolIterations++;
|
|
55
|
+
const decision = await options.authorizeToolCall?.(context, signal);
|
|
56
|
+
if (decision?.block) {
|
|
57
|
+
if (decision.terminate) {
|
|
58
|
+
exhausted = true;
|
|
59
|
+
terminationReason = decision.reason;
|
|
60
|
+
}
|
|
61
|
+
return decision;
|
|
62
|
+
}
|
|
49
63
|
}
|
|
50
64
|
});
|
|
51
65
|
const baseStop = policy.shouldStopAfterTurn;
|
|
@@ -118,7 +132,7 @@ function createDelegateChildHandle(options) {
|
|
|
118
132
|
const proof = verification?.type === "custom" ? verification.data : void 0;
|
|
119
133
|
const unverified = options.verifyChanges && proof?.changed && (!proof.evidence.some((item) => item.kind === "check" && item.status === "passed") || proof.evidence.some((item) => item.status !== "passed"));
|
|
120
134
|
return {
|
|
121
|
-
summary: result.lastAssistantText || result.errorMessage || (exhausted ? "Sub-agent budget exhausted." : "(no final response)"),
|
|
135
|
+
summary: [result.lastAssistantText || result.errorMessage, terminationReason].filter(Boolean).join("\n\n") || (exhausted ? "Sub-agent budget exhausted." : "(no final response)"),
|
|
122
136
|
toolIterations,
|
|
123
137
|
messages: await runtime.loadMessages(),
|
|
124
138
|
status: controller.signal.aborted ? "cancelled" : !result.ok ? "failed" : exhausted || unverified ? "partial" : "success",
|
|
@@ -8,5 +8,9 @@ export declare class RepositoryInstructions {
|
|
|
8
8
|
private constructor();
|
|
9
9
|
static open(workspace: string): Promise<RepositoryInstructions>;
|
|
10
10
|
forTool(name: string, input: unknown): Promise<string>;
|
|
11
|
+
forDataResult(content: Array<{
|
|
12
|
+
type: string;
|
|
13
|
+
text?: string;
|
|
14
|
+
}>): Promise<string>;
|
|
11
15
|
load(path: string, directory: boolean): Promise<string>;
|
|
12
16
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { validateDataBatch } from "../data-acquisition/schema.js";
|
|
2
|
+
import { isDataBatchResult } from "../data-acquisition/render.js";
|
|
3
|
+
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
2
4
|
import { execFile } from "node:child_process";
|
|
3
5
|
import { promisify } from "node:util";
|
|
4
6
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
@@ -35,6 +37,22 @@ var RepositoryInstructions = class RepositoryInstructions {
|
|
|
35
37
|
return new RepositoryInstructions(root, canonicalWorkspace);
|
|
36
38
|
}
|
|
37
39
|
async forTool(name, input) {
|
|
40
|
+
if (name === "data_batch") {
|
|
41
|
+
validateDataBatch(input);
|
|
42
|
+
const sections = [];
|
|
43
|
+
for (const operation of input.operations) {
|
|
44
|
+
const paths = operation.kind === "file_read" || operation.kind === "git_read" ? [operation.path] : operation.kind === "file_search" ? operation.paths : operation.kind === "git_recent" ? operation.paths ?? ["."] : [];
|
|
45
|
+
for (const path of paths) {
|
|
46
|
+
let directory = false;
|
|
47
|
+
try {
|
|
48
|
+
directory = (await stat(resolve(this.workspace, path))).isDirectory();
|
|
49
|
+
} catch {}
|
|
50
|
+
const section = await this.load(path, directory);
|
|
51
|
+
if (section && !sections.includes(section)) sections.push(section);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return sections.join("\n\n");
|
|
55
|
+
}
|
|
38
56
|
const args = input && typeof input === "object" ? input : {};
|
|
39
57
|
if (name === "apply_patch") {
|
|
40
58
|
const paths = [...String(args.patch ?? "").matchAll(/^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/gm)].map((match) => match[1].trim());
|
|
@@ -44,8 +62,34 @@ var RepositoryInstructions = class RepositoryInstructions {
|
|
|
44
62
|
if (name === "exec_command" || name === "managed_job" && args.action === "start") return this.load(typeof args.cwd === "string" ? args.cwd : ".", true);
|
|
45
63
|
return "";
|
|
46
64
|
}
|
|
65
|
+
async forDataResult(content) {
|
|
66
|
+
const sections = /* @__PURE__ */ new Set();
|
|
67
|
+
for (const block of content) {
|
|
68
|
+
if (block.type !== "text" || !block.text) continue;
|
|
69
|
+
let result;
|
|
70
|
+
try {
|
|
71
|
+
result = JSON.parse(block.text);
|
|
72
|
+
} catch {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!isDataBatchResult(result)) continue;
|
|
76
|
+
for (const fragment of result.fragments) {
|
|
77
|
+
if (fragment.source.kind !== "file") continue;
|
|
78
|
+
const section = await this.load(fragment.source.resource, false);
|
|
79
|
+
if (section) sections.add(section);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return [...sections].join("\n\n");
|
|
83
|
+
}
|
|
47
84
|
async load(path, directory) {
|
|
48
|
-
|
|
85
|
+
let target = resolve(this.workspace, path);
|
|
86
|
+
try {
|
|
87
|
+
target = await realpath(target);
|
|
88
|
+
} catch {
|
|
89
|
+
try {
|
|
90
|
+
target = resolve(await realpath(dirname(target)), basename(target));
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
49
93
|
if (!inside(this.root, target)) return "";
|
|
50
94
|
const leaf = directory ? target : dirname(target);
|
|
51
95
|
const directories = [];
|
|
@@ -5,7 +5,7 @@ import "../../knowledge-memory/index.js";
|
|
|
5
5
|
import { retrievalLexicalSimilarity } from "../../retrieval/textFeatures.js";
|
|
6
6
|
import { calculateExecutionValue } from "../../user-model/importance.js";
|
|
7
7
|
import { listUserAssertions } from "../../user-model/repository.js";
|
|
8
|
-
import {
|
|
8
|
+
import { canUseAssertion } from "../../user-model/usage-policy.js";
|
|
9
9
|
import { getExecutionContextFeedbackScores } from "./audit.js";
|
|
10
10
|
import { buildUserContextBlock } from "../memory/context-fence.js";
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
@@ -63,7 +63,7 @@ function rankAssertion(assertion, query, asOf, feedbackScore) {
|
|
|
63
63
|
].filter(Boolean);
|
|
64
64
|
return {
|
|
65
65
|
assertion,
|
|
66
|
-
usage: assertion.
|
|
66
|
+
usage: assertion.authority === "user_explicit" ? "confirmed" : "working_assumption",
|
|
67
67
|
score: assertion.status === "candidate" ? score - .05 : score,
|
|
68
68
|
reasons
|
|
69
69
|
};
|
|
@@ -125,7 +125,7 @@ function buildExecutionContext(request) {
|
|
|
125
125
|
const rankedAssertions = includeUserModel ? listUserAssertions({
|
|
126
126
|
statuses: ["active", "candidate"],
|
|
127
127
|
limit: 1e3
|
|
128
|
-
}).filter((item) => scopeVisible(getAssertionScope(item.slotId), request)).filter((item) => applicabilityVisible(item.applicability, request)).filter((item) => (item
|
|
128
|
+
}).filter((item) => scopeVisible(getAssertionScope(item.slotId), request)).filter((item) => applicabilityVisible(item.applicability, request)).filter((item) => canUseAssertion(item, asOf)).map((item) => rankAssertion(item, request.query, asOf, feedbackScores.get(`assertion:${item.id}`) ?? 0)).filter((item) => item.score >= .12 || item.reasons.includes("high_consequence")).sort((left, right) => right.score - left.score) : [];
|
|
129
129
|
const assertions = [...rankedAssertions.filter((item) => item.usage === "confirmed"), ...rankedAssertions.filter((item) => item.usage === "working_assumption")].slice(0, assertionLimit);
|
|
130
130
|
const maxKnowledge = Math.max(0, Math.min(100, request.maxKnowledge ?? 12));
|
|
131
131
|
const knowledge = request.includeKnowledge === false || maxKnowledge === 0 ? [] : searchKnowledgeItems({
|
|
@@ -165,7 +165,7 @@ function renderExecutionContext(context) {
|
|
|
165
165
|
const confirmedAssertions = context.assertions.filter((item) => item.usage === "confirmed");
|
|
166
166
|
const workingAssumptions = context.assertions.filter((item) => item.usage === "working_assumption");
|
|
167
167
|
if (confirmedAssertions.length) sections.push(`Confirmed user context:\n${confirmedAssertions.map((item) => `- ${item.assertion.statement}`).join("\n")}`);
|
|
168
|
-
if (workingAssumptions.length) sections.push(`Working assumptions (may be wrong; adapt quietly, never present them as confirmed facts, and accept corrections immediately):\n${workingAssumptions.map((item) => `- ${item.assertion.statement} (confidence ${item.assertion.confidence.toFixed(2)})`).join("\n")}`);
|
|
168
|
+
if (workingAssumptions.length) sections.push(`Working assumptions (may be wrong; never authorize actions; current user instructions take precedence; adapt quietly, never present them as confirmed facts, and accept corrections immediately):\n${workingAssumptions.map((item) => `- ${item.assertion.statement} (confidence ${item.assertion.confidence.toFixed(2)})`).join("\n")}`);
|
|
169
169
|
const confirmedGoals = context.goals.filter((goal) => goal.usage === "confirmed");
|
|
170
170
|
const assumedGoals = context.goals.filter((goal) => goal.usage === "working_assumption");
|
|
171
171
|
if (confirmedGoals.length) sections.push(`Confirmed goals:\n${confirmedGoals.map((goal) => `- ${goal.title}: ${goal.desiredOutcome}`).join("\n")}`);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type GitDataOperation = {
|
|
2
|
+
kind: 'git_recent';
|
|
3
|
+
paths?: string[];
|
|
4
|
+
since?: string;
|
|
5
|
+
until?: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'git_read';
|
|
8
|
+
path: string;
|
|
9
|
+
commit: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function readGitData(workspace: string, operation: GitDataOperation, signal: AbortSignal, onRequest: () => void): Promise<{
|
|
12
|
+
text: string;
|
|
13
|
+
resource: string;
|
|
14
|
+
revision: string;
|
|
15
|
+
exhausted: boolean;
|
|
16
|
+
reason: string;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { runProcess } from "../../process/run-process.js";
|
|
2
|
+
import { evaluateExecPolicy } from "../sandbox/exec-policy.js";
|
|
3
|
+
import { checkedFilePath } from "../sandbox/fileAccess.js";
|
|
4
|
+
import { dataScheduler } from "./scheduler.js";
|
|
5
|
+
import { relative, resolve, sep } from "node:path";
|
|
6
|
+
//#region src/agent/data-acquisition/git.ts
|
|
7
|
+
async function readGitData(workspace, operation, signal, onRequest) {
|
|
8
|
+
const cwd = checkedFilePath(workspace, workspace, "read");
|
|
9
|
+
const policy = evaluateExecPolicy({
|
|
10
|
+
command: "git log",
|
|
11
|
+
cwd,
|
|
12
|
+
workspaceRoot: workspace
|
|
13
|
+
});
|
|
14
|
+
if (!policy.allowed) throw new Error(`Sandbox: ${policy.reason}`);
|
|
15
|
+
const env = Object.fromEntries(Object.entries(policy.sanitizedEnv).filter(([key]) => !key.startsWith("GIT_")));
|
|
16
|
+
env.GIT_CONFIG_NOSYSTEM = "1";
|
|
17
|
+
env.GIT_CONFIG_GLOBAL = process.platform === "win32" ? "NUL" : "/dev/null";
|
|
18
|
+
env.GIT_OPTIONAL_LOCKS = "0";
|
|
19
|
+
const run = async (args) => dataScheduler.run(cwd, signal, async () => {
|
|
20
|
+
onRequest();
|
|
21
|
+
const result = await runProcess({
|
|
22
|
+
program: "git",
|
|
23
|
+
args: [
|
|
24
|
+
"--no-pager",
|
|
25
|
+
"--literal-pathspecs",
|
|
26
|
+
"-c",
|
|
27
|
+
"core.fsmonitor=false",
|
|
28
|
+
"-c",
|
|
29
|
+
"core.hooksPath=/dev/null",
|
|
30
|
+
...args
|
|
31
|
+
],
|
|
32
|
+
cwd,
|
|
33
|
+
env,
|
|
34
|
+
signal,
|
|
35
|
+
timeoutMs: 5e3,
|
|
36
|
+
maxOutputBytes: 64 * 1024,
|
|
37
|
+
terminationPolicy: "tree"
|
|
38
|
+
});
|
|
39
|
+
signal.throwIfAborted();
|
|
40
|
+
if (result.exitCode !== 0 || result.timedOut) throw new Error(result.stderr || "Git data is unavailable");
|
|
41
|
+
return result;
|
|
42
|
+
});
|
|
43
|
+
if (operation.kind === "git_read") {
|
|
44
|
+
const target = checkedFilePath(workspace, resolve(workspace, operation.path), "read");
|
|
45
|
+
const path = relative((await run(["rev-parse", "--show-toplevel"])).stdout.trim(), target).split(sep).join("/");
|
|
46
|
+
if (path.startsWith("../") || path === "..") throw new Error("Git file must be inside the repository");
|
|
47
|
+
const result = await run([
|
|
48
|
+
"show",
|
|
49
|
+
"--no-ext-diff",
|
|
50
|
+
"--no-textconv",
|
|
51
|
+
`${operation.commit}:${path}`
|
|
52
|
+
]);
|
|
53
|
+
if (result.stdout.includes("\0")) throw new Error("Git object is binary; use a format-specific tool");
|
|
54
|
+
return {
|
|
55
|
+
text: result.stdout,
|
|
56
|
+
resource: target,
|
|
57
|
+
revision: operation.commit,
|
|
58
|
+
exhausted: !result.outputTruncated,
|
|
59
|
+
reason: result.outputTruncated ? "output_budget" : void 0
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const paths = (operation.paths ?? ["."]).map((path) => checkedFilePath(workspace, resolve(workspace, path), "read"));
|
|
63
|
+
for (const value of [operation.since, operation.until]) if (value && !Number.isFinite(Date.parse(value))) throw new Error("Invalid Git date");
|
|
64
|
+
const head = (await run([
|
|
65
|
+
"rev-parse",
|
|
66
|
+
"--verify",
|
|
67
|
+
"HEAD"
|
|
68
|
+
])).stdout.trim();
|
|
69
|
+
const shallow = (await run(["rev-parse", "--is-shallow-repository"])).stdout.trim() === "true";
|
|
70
|
+
const recent = await run([
|
|
71
|
+
"log",
|
|
72
|
+
"--no-ext-diff",
|
|
73
|
+
"--no-textconv",
|
|
74
|
+
"--format=%H %cI %s",
|
|
75
|
+
"-21",
|
|
76
|
+
...operation.since ? [`--since=${operation.since}`] : [],
|
|
77
|
+
...operation.until ? [`--until=${operation.until}`] : [],
|
|
78
|
+
"HEAD",
|
|
79
|
+
"--",
|
|
80
|
+
...paths
|
|
81
|
+
]);
|
|
82
|
+
const rows = recent.stdout.trim().split("\n").filter(Boolean);
|
|
83
|
+
const dirty = (await run([
|
|
84
|
+
"status",
|
|
85
|
+
"--porcelain",
|
|
86
|
+
"--untracked-files=normal",
|
|
87
|
+
"--",
|
|
88
|
+
...paths
|
|
89
|
+
])).stdout.length > 0;
|
|
90
|
+
const omitted = recent.outputTruncated || rows.length > 20;
|
|
91
|
+
return {
|
|
92
|
+
text: `HEAD: ${head}\nDirty worktree: ${dirty}\nShallow history: ${shallow}\n${rows.slice(0, 20).join("\n")}`,
|
|
93
|
+
resource: cwd,
|
|
94
|
+
revision: head,
|
|
95
|
+
exhausted: !omitted && !shallow,
|
|
96
|
+
reason: omitted ? "output_budget" : shallow ? "shallow_history" : void 0
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { readGitData };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DataBatchResult } from './types.js';
|
|
2
|
+
/** Keep a valid envelope and explicit omissions even under a second context reduction. */
|
|
3
|
+
export declare function renderDataBatch(input: DataBatchResult, maxChars?: number): {
|
|
4
|
+
text: string;
|
|
5
|
+
result: DataBatchResult;
|
|
6
|
+
};
|
|
7
|
+
export declare function isDataBatchResult(value: unknown): value is DataBatchResult;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DATA_MAX_CHARS } from "./types.js";
|
|
2
|
+
//#region src/agent/data-acquisition/render.ts
|
|
3
|
+
/** Keep a valid envelope and explicit omissions even under a second context reduction. */
|
|
4
|
+
function renderDataBatch(input, maxChars = DATA_MAX_CHARS) {
|
|
5
|
+
const result = structuredClone(input);
|
|
6
|
+
const omitted = /* @__PURE__ */ new Set();
|
|
7
|
+
const encode = () => JSON.stringify(result);
|
|
8
|
+
const mark = () => {
|
|
9
|
+
for (const operation of result.operations) {
|
|
10
|
+
operation.fragmentIds = operation.fragmentIds.filter((id) => result.fragments.some((fragment) => fragment.id === id));
|
|
11
|
+
if (omitted.has(operation.id)) {
|
|
12
|
+
operation.outputOmitted = true;
|
|
13
|
+
if (operation.status === "ok") operation.status = "partial";
|
|
14
|
+
operation.reason ??= "output_budget";
|
|
15
|
+
if (operation.kind === "file_read") {
|
|
16
|
+
const original = input.fragments.find((fragment) => fragment.operationIds.includes(operation.id));
|
|
17
|
+
const kept = result.fragments.find((fragment) => fragment.operationIds.includes(operation.id));
|
|
18
|
+
if (original?.startLine !== void 0) operation.next = {
|
|
19
|
+
path: original.source.resource,
|
|
20
|
+
startLine: kept?.endLine !== void 0 ? kept.endLine + 1 : original.startLine,
|
|
21
|
+
maxLines: operation.next?.maxLines ?? 120
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
let text = encode();
|
|
28
|
+
while (text.length > maxChars || Buffer.byteLength(text) > 32768) {
|
|
29
|
+
const nonempty = result.fragments.filter((fragment) => fragment.text.length > 0);
|
|
30
|
+
if (nonempty.length) {
|
|
31
|
+
for (const fragment of nonempty) {
|
|
32
|
+
fragment.operationIds.forEach((id) => omitted.add(id));
|
|
33
|
+
const lines = fragment.text.split("\n");
|
|
34
|
+
if (lines.length > 1) {
|
|
35
|
+
fragment.text = lines.slice(0, Math.floor(lines.length / 2)).join("\n");
|
|
36
|
+
if (fragment.startLine !== void 0) fragment.endLine = fragment.startLine + fragment.text.split("\n").length - 1;
|
|
37
|
+
} else fragment.text = "";
|
|
38
|
+
}
|
|
39
|
+
result.fragments = result.fragments.filter((fragment) => fragment.text.length > 0);
|
|
40
|
+
} else {
|
|
41
|
+
for (const operation of result.operations) {
|
|
42
|
+
operation.scope = "";
|
|
43
|
+
operation.reason = operation.reason?.slice(0, 80);
|
|
44
|
+
delete operation.next;
|
|
45
|
+
}
|
|
46
|
+
mark();
|
|
47
|
+
for (const operation of result.operations) delete operation.next;
|
|
48
|
+
text = encode();
|
|
49
|
+
if (text.length <= maxChars && Buffer.byteLength(text) <= 32768) break;
|
|
50
|
+
text = JSON.stringify({
|
|
51
|
+
status: "partial",
|
|
52
|
+
reason: "output_budget",
|
|
53
|
+
operations: result.operations.map((op) => ({
|
|
54
|
+
id: op.id,
|
|
55
|
+
status: op.status
|
|
56
|
+
}))
|
|
57
|
+
});
|
|
58
|
+
if (text.length > maxChars) text = "{\"status\":\"partial\"}";
|
|
59
|
+
if (text.length > maxChars) text = "";
|
|
60
|
+
return {
|
|
61
|
+
text,
|
|
62
|
+
result
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
mark();
|
|
66
|
+
text = encode();
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
text,
|
|
70
|
+
result
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function isDataBatchResult(value) {
|
|
74
|
+
if (!value || typeof value !== "object") return false;
|
|
75
|
+
const item = value;
|
|
76
|
+
return item.schemaVersion === 1 && Array.isArray(item.operations) && item.operations.length <= 8 && item.operations.every((op) => op && typeof op.id === "string" && Array.isArray(op.fragmentIds) && typeof op.scope === "string") && Array.isArray(item.fragments) && item.fragments.length <= 256 && item.fragments.every((fragment) => fragment && typeof fragment.text === "string" && Array.isArray(fragment.operationIds) && fragment.source && typeof fragment.source.kind === "string" && typeof fragment.source.resource === "string");
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { isDataBatchResult, renderDataBatch };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Shared limits across batches and callers; queued cancellation never consumes a permit. */
|
|
2
|
+
export declare class DataScheduler {
|
|
3
|
+
private readonly totalLimit;
|
|
4
|
+
private readonly resourceLimit;
|
|
5
|
+
private readonly running;
|
|
6
|
+
private readonly queue;
|
|
7
|
+
private active;
|
|
8
|
+
constructor(totalLimit?: number, resourceLimit?: number);
|
|
9
|
+
run<T>(key: string, signal: AbortSignal | undefined, task: () => Promise<T>): Promise<T>;
|
|
10
|
+
private drain;
|
|
11
|
+
}
|
|
12
|
+
export declare const dataScheduler: DataScheduler;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/agent/data-acquisition/scheduler.ts
|
|
2
|
+
/** Shared limits across batches and callers; queued cancellation never consumes a permit. */
|
|
3
|
+
var DataScheduler = class {
|
|
4
|
+
running = /* @__PURE__ */ new Map();
|
|
5
|
+
queue = [];
|
|
6
|
+
active = 0;
|
|
7
|
+
constructor(totalLimit = 8, resourceLimit = 4) {
|
|
8
|
+
this.totalLimit = totalLimit;
|
|
9
|
+
this.resourceLimit = resourceLimit;
|
|
10
|
+
}
|
|
11
|
+
run(key, signal, task) {
|
|
12
|
+
signal?.throwIfAborted();
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const item = {
|
|
15
|
+
key,
|
|
16
|
+
signal,
|
|
17
|
+
abort: () => {
|
|
18
|
+
const index = this.queue.indexOf(item);
|
|
19
|
+
if (index !== -1) this.queue.splice(index, 1);
|
|
20
|
+
reject(signal?.reason ?? /* @__PURE__ */ new Error("Data operation cancelled"));
|
|
21
|
+
},
|
|
22
|
+
start: () => {
|
|
23
|
+
signal?.removeEventListener("abort", item.abort);
|
|
24
|
+
this.active++;
|
|
25
|
+
this.running.set(key, (this.running.get(key) ?? 0) + 1);
|
|
26
|
+
Promise.resolve().then(() => {
|
|
27
|
+
signal?.throwIfAborted();
|
|
28
|
+
return task();
|
|
29
|
+
}).then(resolve, reject).finally(() => {
|
|
30
|
+
this.active--;
|
|
31
|
+
const count = (this.running.get(key) ?? 1) - 1;
|
|
32
|
+
if (count) this.running.set(key, count);
|
|
33
|
+
else this.running.delete(key);
|
|
34
|
+
this.drain();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
signal?.addEventListener("abort", item.abort, { once: true });
|
|
39
|
+
this.queue.push(item);
|
|
40
|
+
this.drain();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
drain() {
|
|
44
|
+
while (this.active < this.totalLimit) {
|
|
45
|
+
const index = this.queue.findIndex((item) => (this.running.get(item.key) ?? 0) < this.resourceLimit);
|
|
46
|
+
if (index === -1) return;
|
|
47
|
+
this.queue.splice(index, 1)[0].start();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const dataScheduler = new DataScheduler();
|
|
52
|
+
//#endregion
|
|
53
|
+
export { DataScheduler, dataScheduler };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type Static } from '@sinclair/typebox';
|
|
2
|
+
export declare const DataBatchSchema: import("@sinclair/typebox").TObject<{
|
|
3
|
+
operations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
4
|
+
id: import("@sinclair/typebox").TString;
|
|
5
|
+
kind: import("@sinclair/typebox").TLiteral<"file_read">;
|
|
6
|
+
path: import("@sinclair/typebox").TString;
|
|
7
|
+
startLine: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
8
|
+
maxLines: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
9
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
10
|
+
id: import("@sinclair/typebox").TString;
|
|
11
|
+
kind: import("@sinclair/typebox").TLiteral<"file_search">;
|
|
12
|
+
paths: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
13
|
+
patterns: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
14
|
+
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
15
|
+
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
16
|
+
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
|
+
contextLines: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
18
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
19
|
+
id: import("@sinclair/typebox").TString;
|
|
20
|
+
kind: import("@sinclair/typebox").TLiteral<"git_recent">;
|
|
21
|
+
paths: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
22
|
+
since: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
23
|
+
until: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
25
|
+
id: import("@sinclair/typebox").TString;
|
|
26
|
+
kind: import("@sinclair/typebox").TLiteral<"git_read">;
|
|
27
|
+
path: import("@sinclair/typebox").TString;
|
|
28
|
+
commit: import("@sinclair/typebox").TString;
|
|
29
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
30
|
+
id: import("@sinclair/typebox").TString;
|
|
31
|
+
kind: import("@sinclair/typebox").TLiteral<"knowledge_search">;
|
|
32
|
+
query: import("@sinclair/typebox").TString;
|
|
33
|
+
maxResults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
34
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
35
|
+
id: import("@sinclair/typebox").TString;
|
|
36
|
+
kind: import("@sinclair/typebox").TLiteral<"knowledge_get">;
|
|
37
|
+
knowledgeId: import("@sinclair/typebox").TString;
|
|
38
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
39
|
+
id: import("@sinclair/typebox").TString;
|
|
40
|
+
kind: import("@sinclair/typebox").TLiteral<"web_search">;
|
|
41
|
+
query: import("@sinclair/typebox").TString;
|
|
42
|
+
count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
43
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
44
|
+
id: import("@sinclair/typebox").TString;
|
|
45
|
+
kind: import("@sinclair/typebox").TLiteral<"web_fetch">;
|
|
46
|
+
url: import("@sinclair/typebox").TString;
|
|
47
|
+
maxChars: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
48
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
49
|
+
id: import("@sinclair/typebox").TString;
|
|
50
|
+
kind: import("@sinclair/typebox").TLiteral<"external_read">;
|
|
51
|
+
toolRef: import("@sinclair/typebox").TString;
|
|
52
|
+
revision: import("@sinclair/typebox").TString;
|
|
53
|
+
arguments: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>;
|
|
54
|
+
}>]>>;
|
|
55
|
+
}>;
|
|
56
|
+
export type DataBatchArgs = Static<typeof DataBatchSchema>;
|
|
57
|
+
export type DataOperation = DataBatchArgs['operations'][number];
|
|
58
|
+
export declare const DATA_OPERATION_TOOLS: {
|
|
59
|
+
readonly file_read: "read_file";
|
|
60
|
+
readonly file_search: "grep";
|
|
61
|
+
readonly git_recent: "exec_command";
|
|
62
|
+
readonly git_read: "exec_command";
|
|
63
|
+
readonly knowledge_search: "knowledge_search";
|
|
64
|
+
readonly knowledge_get: "knowledge_get";
|
|
65
|
+
readonly web_search: "web_search";
|
|
66
|
+
readonly web_fetch: "web_fetch";
|
|
67
|
+
readonly external_read: "xopc_tool_execute";
|
|
68
|
+
};
|
|
69
|
+
export declare function nativeDataArgs(op: DataOperation): Record<string, unknown>;
|
|
70
|
+
/** Expose each underlying access to existing approval, hook and call-limit policies. */
|
|
71
|
+
export declare function dataOperationCalls(args: unknown): Array<{
|
|
72
|
+
name: string;
|
|
73
|
+
args: Record<string, unknown>;
|
|
74
|
+
}>;
|
|
75
|
+
export declare function validateDataBatch(args: unknown): asserts args is DataBatchArgs;
|