@tea-agent/loop-agent 0.1.0-fe-test.5 → 0.1.0-fe-test.6
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/AGENTS.md +1 -1
- package/CHANGELOG.md +441 -2525
- package/README.md +19 -12
- package/dist/adapters/loop-agent.js +34 -0
- package/dist/application/dag/args.js +8 -0
- package/dist/application/dag/run-dag.js +5 -0
- package/dist/application/evaluation/budget.js +40 -1
- package/dist/application/evaluation/corpus-hash.js +10 -15
- package/dist/application/evaluation/corpus.js +2 -1
- package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
- package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
- package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
- package/dist/application/evaluation/frontend-pair-registration.js +143 -0
- package/dist/application/evaluation/frontend-paired-summary.js +150 -0
- package/dist/application/evaluation/frontend-run-observation.js +144 -0
- package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
- package/dist/application/evaluation/types.js +45 -12
- package/dist/application/task-lifecycle/advance.js +64 -15
- package/dist/application/task-lifecycle/observe.js +69 -30
- package/dist/application/task-lifecycle/plan-transitions.js +5 -4
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +18 -5
- package/dist/cli/program.js +8 -5
- package/dist/cli/update/init-surface-notifier.js +2 -0
- package/dist/cli/update/policy.js +2 -0
- package/dist/commands/client-recovery.js +20 -55
- package/dist/commands/cursor-prompt.js +2 -0
- package/dist/commands/dag-approve.js +2 -0
- package/dist/commands/dag-final-verification.js +2 -0
- package/dist/commands/dag-init-hybrid.js +2 -0
- package/dist/commands/dag-reconcile-tasks.js +2 -0
- package/dist/commands/dag-reject.js +2 -0
- package/dist/commands/dag-report.js +2 -0
- package/dist/commands/dag-rerun.js +2 -0
- package/dist/commands/dag-resume.js +2 -0
- package/dist/commands/dag-workflow-compile.js +2 -0
- package/dist/commands/dag-workflow-plan.js +2 -0
- package/dist/commands/dag-workflow-validate.js +2 -0
- package/dist/commands/delegate.js +2 -0
- package/dist/commands/examples.js +2 -0
- package/dist/commands/import-prd.js +2 -0
- package/dist/commands/init-legacy-audit.js +330 -0
- package/dist/commands/init-model-catalog.js +2 -0
- package/dist/commands/init-upgrade.js +644 -104
- package/dist/commands/init.js +700 -338
- package/dist/commands/instructions.js +2 -0
- package/dist/commands/knowledge.js +2 -0
- package/dist/commands/loop-benchmark.js +2 -0
- package/dist/commands/operator-guide.js +99 -0
- package/dist/commands/operator.js +16 -3
- package/dist/commands/pi-prompt.js +2 -0
- package/dist/commands/pi-reuse-benchmark.js +2 -0
- package/dist/commands/promote-run.js +2 -0
- package/dist/commands/stats.js +1 -1
- package/dist/commands/study-init.js +2 -0
- package/dist/commands/task-advance.js +32 -0
- package/dist/commands/task-source-prepare.js +18 -2
- package/dist/commands/worktree-create.js +2 -0
- package/dist/commands/worktree-remove.js +2 -0
- package/dist/executors/dag-pi/guards.js +4 -0
- package/dist/executors/dag-pi/model-config.js +30 -0
- package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
- package/dist/executors/dag-pi/plan/facts.js +180 -0
- package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
- package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
- package/dist/executors/dag-pi/plan/record-tools.js +861 -0
- package/dist/executors/dag-pi/plan/schema.js +129 -0
- package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
- package/dist/executors/dag-pi/sessions/index.js +6 -0
- package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
- package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
- package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
- package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
- package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
- package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
- package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
- package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
- package/dist/executors/dag-pi-executor.js +1516 -3181
- package/dist/executors/pi-executor.js +112 -4
- package/dist/executors/pi-sdk-executor.js +258 -44
- package/dist/executors/pi-writer-tool-policy.js +60 -4
- package/dist/executors/playwright-cli-launcher.js +31 -45
- package/dist/executors/shell-executor.js +313 -48
- package/dist/executors/shell-presets.js +1 -1
- package/dist/executors/shell-verification.js +3 -0
- package/dist/executors/shell-write-guard.js +77 -102
- package/dist/governance/exec-plans.js +16 -4
- package/dist/governance/harness.js +2 -7
- package/dist/governance/manifest-types.js +28 -9
- package/dist/governance/project-capability-scanner.js +263 -0
- package/dist/governance/project-config.js +96 -0
- package/dist/governance/resource-catalog.js +151 -0
- package/dist/infrastructure/console/app-data.js +12 -2
- package/dist/infrastructure/console/operation-store.js +48 -14
- package/dist/infrastructure/evaluation/corpus-store.js +37 -12
- package/dist/shared/artifacts-core.js +2 -0
- package/dist/shared/backend-dogfood-preflight.js +47 -0
- package/dist/shared/dag-failure-category.js +9 -0
- package/dist/shared/file-identity.js +23 -0
- package/dist/shared/frontend-execution-policy.js +23 -0
- package/dist/shared/git-progress.js +2 -0
- package/dist/shared/git-workspace-status.js +482 -0
- package/dist/shared/one-shot-prompt-args.js +2 -0
- package/dist/shared/operator/capabilities.js +185 -0
- package/dist/shared/package-metadata.js +29 -11
- package/dist/shared/path-safety.js +2 -2
- package/dist/shared/pi-context-pressure/extension.js +49 -16
- package/dist/shared/pi-context-pressure/index.js +1 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +4 -0
- package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
- package/dist/shared/pi-provider-recovery.js +182 -0
- package/dist/shared/pi-retry-settings.js +40 -0
- package/dist/shared/reference-context.js +2 -0
- package/dist/shared/update/npm-client.js +49 -1
- package/dist/shared/wizard-local-telemetry.js +51 -0
- package/dist/task/config-types.js +51 -2
- package/dist/task/contract/apply.js +36 -2
- package/dist/task/contract/project.js +22 -0
- package/dist/task/contract/recover.js +6 -0
- package/dist/task/contract/schema.js +12 -0
- package/dist/task/frontend-preflight.js +1 -1
- package/dist/task/source-prepare/artifact-meta.js +9 -2
- package/dist/task/source-prepare/build-draft.js +61 -0
- package/dist/task/source-prepare/fragment-inventory.js +4 -1
- package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
- package/dist/task/source-prepare/ledger-review.js +6 -9
- package/dist/task/source-prepare/parse-intent.js +165 -14
- package/dist/task/source-prepare/path-policy.js +17 -7
- package/dist/task/source-prepare/prepare.js +6 -1
- package/dist/task/source-prepare/semantic-intake.js +33 -28
- package/dist/task/source-prepare/source-execution.js +65 -0
- package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
- package/dist/task/source-prepare/source-provider-budget.js +290 -0
- package/dist/task/source-references.js +48 -23
- package/dist/task/task-demand-routing.js +5 -2
- package/dist/worker/cli.js +3 -5
- package/dist/worker/console/chat/assistant-content.js +5 -13
- package/dist/worker/console/chat/browser-automation.js +937 -0
- package/dist/worker/console/chat/browser-content.js +74 -0
- package/dist/worker/console/chat/browser-diagnostics.js +250 -0
- package/dist/worker/console/chat/browser-evaluation.js +58 -0
- package/dist/worker/console/chat/browser-operation-queue.js +19 -0
- package/dist/worker/console/chat/browser-pick.js +113 -0
- package/dist/worker/console/chat/browser-policy.js +113 -0
- package/dist/worker/console/chat/browser-routes.js +329 -0
- package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
- package/dist/worker/console/chat/browser-storage.js +89 -0
- package/dist/worker/console/chat/chat-event-store.js +73 -18
- package/dist/worker/console/chat/context-insights.js +788 -0
- package/dist/worker/console/chat/conversation-nodes.js +383 -0
- package/dist/worker/console/chat/db-connections.js +854 -0
- package/dist/worker/console/chat/explore-tools.js +18 -2
- package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
- package/dist/worker/console/chat/pet/pet-persist.js +109 -0
- package/dist/worker/console/chat/pet/pet-registry.js +142 -0
- package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
- package/dist/worker/console/chat/pet/pet-routes.js +125 -0
- package/dist/worker/console/chat/pet/pet-service.js +262 -0
- package/dist/worker/console/chat/pet/pet-state.js +99 -0
- package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
- package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
- package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
- package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
- package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
- package/dist/worker/console/chat/pi-runtime.js +793 -1230
- package/dist/worker/console/chat/provider-error.js +0 -12
- package/dist/worker/console/chat/repo-browser.js +132 -6
- package/dist/worker/console/chat/repo-preview-kind.js +155 -0
- package/dist/worker/console/chat/resource-loader.js +4 -1
- package/dist/worker/console/chat/routes.js +861 -148
- package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
- package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
- package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
- package/dist/worker/console/chat/scm-routes.js +217 -0
- package/dist/worker/console/chat/scm-service.js +283 -0
- package/dist/worker/console/chat/scm-tools.js +111 -0
- package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
- package/dist/worker/console/chat/session-catalog.js +32 -0
- package/dist/worker/console/chat/session-mode-view.js +49 -0
- package/dist/worker/console/chat/session-mode.js +224 -0
- package/dist/worker/console/chat/session-store.js +232 -32
- package/dist/worker/console/chat/shortcuts.js +13 -0
- package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
- package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
- package/dist/worker/console/chat/subagents/index.js +5 -0
- package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
- package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
- package/dist/worker/console/chat/subagents/types.js +13 -0
- package/dist/worker/console/chat/terminal-routes.js +216 -0
- package/dist/worker/console/chat/terminal-sessions.js +348 -0
- package/dist/worker/console/chat/terminal-tools.js +211 -0
- package/dist/worker/console/chat/timeline-message-order.js +22 -0
- package/dist/worker/console/chat/tool-preview.js +136 -0
- package/dist/worker/console/chat/tools.js +69 -1
- package/dist/worker/console/chat/turn-order.js +13 -0
- package/dist/worker/console/chat/turn-process.js +210 -36
- package/dist/worker/console/chat/user-turn-outline.js +19 -0
- package/dist/worker/console/console-shutdown.js +34 -0
- package/dist/worker/console/console-update-and-init.js +1 -19
- package/dist/worker/console/console-update-runtime.js +7 -22
- package/dist/worker/console/dag-confirmation.js +3 -0
- package/dist/worker/console/dag-execution-receipt.js +3 -0
- package/dist/worker/console/interview/tools.js +1 -0
- package/dist/worker/console/operator-actions.js +95 -4
- package/dist/worker/console/operator-user-error.js +28 -1
- package/dist/worker/console/pi-readiness.js +4 -4
- package/dist/worker/console/prd-intake-bridge.js +47 -1
- package/dist/worker/console/recovery-cta.js +14 -14
- package/dist/worker/console/routes.js +13 -0
- package/dist/worker/console/scheduled-goal-host.js +98 -0
- package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
- package/dist/worker/console/server.js +33 -31
- package/dist/worker/console/static/app-icon.svg +39 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
- package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
- package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
- package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
- package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
- package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
- package/dist/worker/console/static/index.html +5 -2
- package/dist/worker/console/static/manifest.webmanifest +19 -0
- package/dist/worker/console/static/pets/ember/pet.json +167 -0
- package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
- package/dist/worker/console/static-src/app/console-types.js +9 -1
- package/dist/worker/console/static-src/chat-view-types.js +1 -1
- package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
- package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
- package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
- package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
- package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
- package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
- package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
- package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
- package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
- package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
- package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
- package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
- package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
- package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
- package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
- package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
- package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
- package/dist/worker/console/static-src/prd-file-import.js +3 -1
- package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
- package/dist/worker/console/workspace-context.js +54 -1
- package/dist/worker/console/workspace-initialization.js +218 -0
- package/dist/worker/delivery/git-transaction.js +2 -0
- package/dist/worker/delivery/package.js +4 -1
- package/dist/worker/feature/fullstack-validate.js +2 -0
- package/dist/worker/loop-agent/loop-agent-client.js +8 -2
- package/dist/worker/materialize/harness-task-lineage.js +4 -2
- package/dist/worker/materialize/harness-task-materializer.js +4 -1
- package/dist/worker/metrics/projector.js +1 -1
- package/dist/worker/observability/event-store.js +4 -1
- package/dist/worker/observability/read-model.js +27 -3
- package/dist/worker/observe/node-context-insights.js +479 -0
- package/dist/worker/observe/node-transparency.js +103 -72
- package/dist/worker/observe/routes.js +24 -1
- package/dist/worker/observe/static/console-theme.css +178 -0
- package/dist/worker/observe/static/console-theme.js +74 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
- package/dist/worker/observe/static/dom.js +20 -1
- package/dist/worker/observe/static/format-pool.d.ts +2 -0
- package/dist/worker/observe/static/format-pool.js +6 -0
- package/dist/worker/observe/static/format.js +7 -0
- package/dist/worker/observe/static/inspect-workspace.js +34 -7
- package/dist/worker/observe/static/inspector-submission.js +32 -0
- package/dist/worker/observe/static/kpi.js +1 -0
- package/dist/worker/observe/static/operator-chrome.css +85 -0
- package/dist/worker/observe/static/operator-chrome.js +13 -1
- package/dist/worker/observe/static/relations.js +2 -0
- package/dist/worker/observe/static/router.js +13 -0
- package/dist/worker/observe/static/run-processing.js +2 -0
- package/dist/worker/observe/static/shell-chrome.js +36 -3
- package/dist/worker/observe/static/state.js +35 -2
- package/dist/worker/observe/static/styles.css +263 -39
- package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
- package/dist/worker/observe/static/task-failure-labels.js +67 -0
- package/dist/worker/observe/static/task-history.js +12 -0
- package/dist/worker/observe/static/views/batch.js +6 -13
- package/dist/worker/observe/static/views/dag-graph.js +50 -3
- package/dist/worker/observe/static/views/dag-inspector.js +742 -268
- package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
- package/dist/worker/observe/static/views/dag.d.ts +6 -0
- package/dist/worker/observe/static/views/dag.js +49 -11
- package/dist/worker/observe/static/views/dags.js +2 -0
- package/dist/worker/observe/static/views/dashboard.js +21 -12
- package/dist/worker/observe/static/views/failures.js +21 -11
- package/dist/worker/observe/static/views/feature.js +11 -29
- package/dist/worker/observe/static/views/pool.js +37 -28
- package/dist/worker/observe/static/views/run.js +48 -5
- package/dist/worker/observe/static/views/session-timeline.js +189 -240
- package/dist/worker/observe/static/views/task.js +81 -62
- package/dist/worker/outcomes/declared-artifacts.js +2 -0
- package/dist/worker/preflight.js +3 -0
- package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
- package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
- package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
- package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
- package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
- package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
- package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
- package/dist/worker/task-spec/validate.js +4 -1
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
- package/dist/workflows/dag/backend-test-layout.js +27 -7
- package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
- package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
- package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
- package/dist/workflows/dag/budget-enforcement.js +82 -3
- package/dist/workflows/dag/checkpoint.js +686 -0
- package/dist/workflows/dag/dag-retry-schema.js +14 -0
- package/dist/workflows/dag/decision-envelope.js +2 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
- package/dist/workflows/dag/final-verification.js +45 -10
- package/dist/workflows/dag/frontend-capacity.js +9 -0
- package/dist/workflows/dag/frontend-closeout.js +5 -1
- package/dist/workflows/dag/frontend-committed-facts.js +461 -0
- package/dist/workflows/dag/frontend-contract-facts.js +133 -0
- package/dist/workflows/dag/frontend-design-policy.js +107 -21
- package/dist/workflows/dag/frontend-durable-tools.js +225 -0
- package/dist/workflows/dag/frontend-execution-groups.js +24 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
- package/dist/workflows/dag/frontend-input-projection.js +76 -0
- package/dist/workflows/dag/frontend-plan-canary.js +103 -0
- package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
- package/dist/workflows/dag/frontend-plan-progress.js +92 -0
- package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
- package/dist/workflows/dag/frontend-plan-render.js +21 -5
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
- package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
- package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
- package/dist/workflows/dag/frontend-recovery-run.js +148 -47
- package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
- package/dist/workflows/dag/frontend-repair.js +79 -76
- package/dist/workflows/dag/frontend-review-context.js +71 -69
- package/dist/workflows/dag/frontend-review-scopes.js +237 -0
- package/dist/workflows/dag/frontend-risk.js +101 -12
- package/dist/workflows/dag/frontend-root-observation.js +261 -0
- package/dist/workflows/dag/frontend-session-budget.js +376 -0
- package/dist/workflows/dag/frontend-session-context.js +10 -0
- package/dist/workflows/dag/frontend-shape-facts.js +12 -2
- package/dist/workflows/dag/frontend-shape.js +27 -32
- package/dist/workflows/dag/frontend-test-case-checklist.js +12 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +21 -2
- package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
- package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
- package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
- package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
- package/dist/workflows/dag/frontend-test-layout.js +41 -12
- package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
- package/dist/workflows/dag/frontend-verification-trace.js +65 -48
- package/dist/workflows/dag/frontend-writer-admission.js +6 -48
- package/dist/workflows/dag/frontend-writer-status.js +0 -23
- package/dist/workflows/dag/hybrid/sources.js +1831 -0
- package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
- package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
- package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
- package/dist/workflows/dag/hybrid/templates/index.js +8 -0
- package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
- package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
- package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
- package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
- package/dist/workflows/dag/hybrid/types.js +32 -0
- package/dist/workflows/dag/init-hybrid.js +57 -7167
- package/dist/workflows/dag/interrupt-request.js +2 -0
- package/dist/workflows/dag/lifecycle.js +11 -2
- package/dist/workflows/dag/node-execution.js +257 -247
- package/dist/workflows/dag/output-protocol.js +1 -0
- package/dist/workflows/dag/prompt.js +4 -0
- package/dist/workflows/dag/reconcile-run.js +2 -0
- package/dist/workflows/dag/repair-artifact.js +3 -1
- package/dist/workflows/dag/report.js +2 -0
- package/dist/workflows/dag/rerun-feedback.js +36 -4
- package/dist/workflows/dag/rerun-plan.js +106 -4
- package/dist/workflows/dag/rerun-run.js +7 -0
- package/dist/workflows/dag/rerun-task.js +75 -1
- package/dist/workflows/dag/retry-policy.js +34 -10
- package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
- package/dist/workflows/dag/runner.js +38 -1074
- package/dist/workflows/dag/scheduler.js +2 -4
- package/dist/workflows/dag/skill-instructions.js +102 -32
- package/dist/workflows/dag/skill-snapshot.js +3 -0
- package/dist/workflows/dag/skills.js +7 -7
- package/dist/workflows/dag/structured-output-repair.js +4 -1
- package/dist/workflows/dag/terminal-status.js +502 -0
- package/dist/workflows/dag/test-artifact-namespace.js +73 -0
- package/dist/workflows/dag/types.js +58 -7
- package/dist/workflows/dag/validate.js +38 -13
- package/dist/workflows/dag/workspace-checkpoint.js +79 -1
- package/dist/workflows/loop/benchmark.js +11 -8
- package/docs/README.md +2 -1
- package/docs/architecture/dag-execution.md +4 -4
- package/docs/architecture/runtime-boundaries.md +29 -23
- package/docs/governance/README.md +1 -0
- package/docs/governance/harness-methodology-verification.md +11 -0
- package/docs/init-surface.manifest.json +44 -295
- package/docs/operations/README.md +4 -0
- package/docs/templates/README.md +5 -5
- package/docs/templates/agent-dag.base.json +9 -9
- package/docs/templates/agent-dag.final-verification.json +6 -6
- package/docs/templates/agent-dag.schema.json +2 -2
- package/docs/templates/agent-dag.supervised-implementation.json +12 -12
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
- package/docs/templates/backend-test-dag.json +708 -703
- package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-design-contract.md +4 -4
- package/docs/templates/frontend-implementation-contract.schema.json +99 -22
- package/docs/templates/frontend-implementation-dag.json +7 -7
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-case.example.md +2 -0
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.json +46 -37
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
- package/docs/templates/hybrid-dag.json +9 -9
- package/docs/templates/knowledge-sync-dag.json +8 -8
- package/harness.json +1 -1
- package/package.json +27 -8
- package/resource-catalog.v1.json +1981 -0
- package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
- package/resources/init-history/legacy-surface.v1.json +33 -0
- package/skills/fe-test-ui-scout/SKILL.md +4 -4
- package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
- package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
- package/skills/frontend-contract/SKILL.md +2 -1
- package/skills/frontend-contract/references/contract-protocol.md +22 -4
- package/skills/frontend-design-review/SKILL.md +16 -18
- package/skills/frontend-design-review/references/review-checklist.md +3 -4
- package/skills/frontend-plan/SKILL.md +25 -3
- package/skills/frontend-plan/references/decision-contract.md +117 -8
- package/skills/frontend-plan/references/design-decisions.md +32 -0
- package/skills/frontend-review/SKILL.md +29 -36
- package/skills/frontend-review/references/review-findings.md +8 -3
- package/skills/frontend-scout/references/scout-evidence.md +4 -0
- package/skills/init-update/SKILL.md +34 -0
- package/skills/init-update/agents/openai.yaml +6 -0
- package/skills/loop-agent/references/command-reference.md +8 -0
- package/skills/loop-agent/references/hybrid-dag.md +1 -1
- package/skills/playwright-cli/SKILL.md +1 -1
- package/skills/playwright-cli-case-generator/SKILL.md +7 -5
- package/dist/commands/new-task.js +0 -5
- package/dist/commands/status.js +0 -57
- package/dist/commands/task-contract.js +0 -269
- package/dist/shared/prompts.js +0 -26
- package/dist/task/config.js +0 -2
- package/dist/task/contract/validate-draft.js +0 -106
- package/dist/task/goal.js +0 -3
- package/dist/task/index.js +0 -12
- package/dist/task/lifecycle.js +0 -1
- package/dist/task/operator/capabilities.js +0 -6
- package/dist/task/operator/envelope.js +0 -2
- package/dist/task/operator/index.js +0 -5
- package/dist/task/operator/registry.js +0 -2
- package/dist/task/paths.js +0 -1
- package/dist/task/source-state.js +0 -1
- package/dist/task/subagent-guidance.js +0 -1
- package/dist/worker/console/chat/sift-bridge.js +0 -1
- package/dist/worker/console/index.js +0 -20
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
- package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
- package/dist/worker/scheduler/index.js +0 -25
- package/dist/workflows/dag/facts.js +0 -4
- package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
- package/dist/workflows/dag/index.js +0 -6
- package/dist/workflows/dynamic/index.js +0 -7
- /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pet service — console orchestration half, adapted from @linxin666/dsh-pet
|
|
3
|
+
* service.ts. Subscribes to the chat event ring, projects turn activity
|
|
4
|
+
* onto the pet state machine, settles the treat ledger lazily, and serves
|
|
5
|
+
* the read/interact API the dock UI calls.
|
|
6
|
+
* @module loop-agent/console/chat/pet/pet-service
|
|
7
|
+
*/
|
|
8
|
+
import { PetStateMachine, } from "./pet-state.js";
|
|
9
|
+
import { applyPetInteraction, applyPetTurnReward, petAffinityViewOf, settlePetTreatGrants, consumePetTreat, } from "./pet-affinity.js";
|
|
10
|
+
import { builtinPetRemark, } from "./pet-remarks.js";
|
|
11
|
+
import { DEFAULT_PET_ID, PET_DISPLAY_INSET_MAX, PET_DISPLAY_SIZE_MAX, PET_DISPLAY_SIZE_MIN, loadPetPersist, savePetPersist, } from "./pet-persist.js";
|
|
12
|
+
const PET_BUBBLE_MAX = 120;
|
|
13
|
+
function bubbleText(value) {
|
|
14
|
+
if (typeof value !== "string")
|
|
15
|
+
return undefined;
|
|
16
|
+
const trimmed = value.trim();
|
|
17
|
+
if (trimmed === "")
|
|
18
|
+
return undefined;
|
|
19
|
+
return trimmed.slice(0, PET_BUBBLE_MAX);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* PetService — one instance per workspace context. The active session is the
|
|
23
|
+
* one the operator last interacted with (prompt/switch); its events drive
|
|
24
|
+
* the pet. All state is persisted to <dataDir>/pet.json atomically.
|
|
25
|
+
*/
|
|
26
|
+
export class PetService {
|
|
27
|
+
chatEvents;
|
|
28
|
+
registry;
|
|
29
|
+
dataDir;
|
|
30
|
+
now;
|
|
31
|
+
machine = new PetStateMachine();
|
|
32
|
+
persist;
|
|
33
|
+
unsubscribes = new Set();
|
|
34
|
+
activeSessionId;
|
|
35
|
+
lastInteractionBubble;
|
|
36
|
+
rewardedTurnIds = new Set();
|
|
37
|
+
constructor(chatEvents, registry, dataDir, now = Date.now) {
|
|
38
|
+
this.chatEvents = chatEvents;
|
|
39
|
+
this.registry = registry;
|
|
40
|
+
this.dataDir = dataDir;
|
|
41
|
+
this.now = now;
|
|
42
|
+
this.persist = loadPetPersist(dataDir);
|
|
43
|
+
}
|
|
44
|
+
/** Currently selected pet id, clamped to the registry. */
|
|
45
|
+
selectedPetId() {
|
|
46
|
+
return this.registry.has(this.persist.petId)
|
|
47
|
+
? this.persist.petId
|
|
48
|
+
: (this.registry.keys().next().value ?? DEFAULT_PET_ID);
|
|
49
|
+
}
|
|
50
|
+
petName() {
|
|
51
|
+
const id = this.selectedPetId();
|
|
52
|
+
return this.persist.names[id] ?? this.registry.get(id)?.manifest.displayName ?? id;
|
|
53
|
+
}
|
|
54
|
+
display() {
|
|
55
|
+
return { ...this.persist.display };
|
|
56
|
+
}
|
|
57
|
+
/** Point the pet at a session (the one the operator is watching). */
|
|
58
|
+
focusSession(sessionId) {
|
|
59
|
+
if (this.activeSessionId === sessionId)
|
|
60
|
+
return;
|
|
61
|
+
for (const off of this.unsubscribes)
|
|
62
|
+
off();
|
|
63
|
+
this.unsubscribes.clear();
|
|
64
|
+
this.activeSessionId = sessionId;
|
|
65
|
+
this.rewardedTurnIds.clear();
|
|
66
|
+
if (sessionId === undefined) {
|
|
67
|
+
this.machine.onSessionDisposed();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.machine.onSessionActive();
|
|
71
|
+
// Replay recent history so a refocus lands on the real phase.
|
|
72
|
+
const recent = this.chatEvents.snapshot(sessionId).slice(-40);
|
|
73
|
+
for (const event of recent)
|
|
74
|
+
this.project(event, false);
|
|
75
|
+
const off = this.chatEvents.subscribe(sessionId, (event) => {
|
|
76
|
+
this.project(event);
|
|
77
|
+
});
|
|
78
|
+
this.unsubscribes.add(off);
|
|
79
|
+
}
|
|
80
|
+
/** Project one chat ring event onto the machine (pure dispatch). */
|
|
81
|
+
project(event, reward = true) {
|
|
82
|
+
switch (event.kind) {
|
|
83
|
+
case "agent_start":
|
|
84
|
+
case "step_start": {
|
|
85
|
+
this.machine.onActivity({ phase: "thinking" });
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "user_message": {
|
|
89
|
+
this.machine.onActivity({ phase: "waiting" });
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "message_update":
|
|
93
|
+
case "message_end": {
|
|
94
|
+
// Assistant text landing: short ack reads as thinking (more
|
|
95
|
+
// work may follow), a substantive reply reads as review.
|
|
96
|
+
const data = event.data;
|
|
97
|
+
const text = typeof data.text === "string" ? data.text : "";
|
|
98
|
+
this.machine.onActivity({
|
|
99
|
+
phase: text.length > 80 ? "review" : "thinking",
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case "tool_call": {
|
|
104
|
+
const data = event.data;
|
|
105
|
+
const toolName = typeof data.toolName === "string" && data.toolName !== ""
|
|
106
|
+
? data.toolName
|
|
107
|
+
: "工具";
|
|
108
|
+
this.machine.onActivity({
|
|
109
|
+
phase: "tool",
|
|
110
|
+
line: `${toolName} 进行中`,
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case "tool_result": {
|
|
115
|
+
const data = event.data;
|
|
116
|
+
const failed = data.isError === true;
|
|
117
|
+
const toolName = typeof data.toolName === "string" && data.toolName !== ""
|
|
118
|
+
? data.toolName
|
|
119
|
+
: "工具";
|
|
120
|
+
this.machine.onActivity(failed
|
|
121
|
+
? { phase: "failed", line: `${toolName} 出错了` }
|
|
122
|
+
: { phase: "tool", line: `${toolName} 完成` });
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "agent_end":
|
|
126
|
+
case "agent_settled": {
|
|
127
|
+
// A settled agent turn: reward exactly once even when both lifecycle
|
|
128
|
+
// events are present in the durable ring.
|
|
129
|
+
if (reward && !this.rewardedTurnIds.has(event.turnId)) {
|
|
130
|
+
this.rewardedTurnIds.add(event.turnId);
|
|
131
|
+
this.persist.affinity = applyPetTurnReward(this.persist.affinity);
|
|
132
|
+
this.save();
|
|
133
|
+
}
|
|
134
|
+
this.machine.onActivity({ phase: "done" });
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "turn_error":
|
|
138
|
+
case "turn_max_tokens":
|
|
139
|
+
case "model_retry": {
|
|
140
|
+
this.machine.onActivity({ phase: "failed" });
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Full read view (settles treats lazily first). */
|
|
148
|
+
view() {
|
|
149
|
+
const settle = settlePetTreatGrants(this.persist.treats, this.persist.affinity.turns, this.now());
|
|
150
|
+
if (settle.ledger !== this.persist.treats) {
|
|
151
|
+
this.persist.treats = settle.ledger;
|
|
152
|
+
this.save();
|
|
153
|
+
}
|
|
154
|
+
const state = this.machine.render();
|
|
155
|
+
const bubble = this.lastInteractionBubble !== undefined &&
|
|
156
|
+
this.now() - this.lastInteractionBubble.at < 4000
|
|
157
|
+
? this.lastInteractionBubble.text
|
|
158
|
+
: undefined;
|
|
159
|
+
return {
|
|
160
|
+
ok: true,
|
|
161
|
+
sessionActive: state.sessionActive,
|
|
162
|
+
state: bubble === undefined ? state : { ...state, bubble },
|
|
163
|
+
affinity: petAffinityViewOf(this.persist.affinity, this.now()),
|
|
164
|
+
treats: this.persist.treats.treats,
|
|
165
|
+
petId: this.selectedPetId(),
|
|
166
|
+
petName: this.petName(),
|
|
167
|
+
display: this.display(),
|
|
168
|
+
pets: [...this.registry.entries()].map(([id, entry]) => ({
|
|
169
|
+
id,
|
|
170
|
+
displayName: entry.manifest.displayName,
|
|
171
|
+
})),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** One user interaction (pet/feed). */
|
|
175
|
+
interact(kind) {
|
|
176
|
+
let reaction;
|
|
177
|
+
let delta = 0;
|
|
178
|
+
let accepted = false;
|
|
179
|
+
if (kind === "feed") {
|
|
180
|
+
const consume = consumePetTreat(this.persist.treats);
|
|
181
|
+
if (!consume.ok) {
|
|
182
|
+
reaction = builtinPetRemark("noTreats");
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.persist.treats = consume.ledger;
|
|
186
|
+
const outcome = applyPetInteraction(this.persist.affinity, "feed", this.now());
|
|
187
|
+
this.persist.affinity = outcome.affinity;
|
|
188
|
+
delta = outcome.delta;
|
|
189
|
+
accepted = outcome.accepted;
|
|
190
|
+
reaction = outcome.reaction;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const outcome = applyPetInteraction(this.persist.affinity, "pet", this.now());
|
|
195
|
+
this.persist.affinity = outcome.affinity;
|
|
196
|
+
delta = outcome.delta;
|
|
197
|
+
accepted = outcome.accepted;
|
|
198
|
+
reaction = outcome.reaction;
|
|
199
|
+
}
|
|
200
|
+
this.lastInteractionBubble = { text: reaction, at: this.now() };
|
|
201
|
+
this.save();
|
|
202
|
+
return {
|
|
203
|
+
ok: true,
|
|
204
|
+
reaction,
|
|
205
|
+
delta,
|
|
206
|
+
accepted,
|
|
207
|
+
affinity: petAffinityViewOf(this.persist.affinity, this.now()),
|
|
208
|
+
treats: this.persist.treats.treats,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/** Update display config (clamped) and persist. */
|
|
212
|
+
setDisplay(patch) {
|
|
213
|
+
const current = this.persist.display;
|
|
214
|
+
const next = {
|
|
215
|
+
visible: typeof patch.visible === "boolean"
|
|
216
|
+
? patch.visible
|
|
217
|
+
: current.visible,
|
|
218
|
+
size: Math.round(Math.min(PET_DISPLAY_SIZE_MAX, Math.max(PET_DISPLAY_SIZE_MIN, typeof patch.size === "number" && Number.isFinite(patch.size)
|
|
219
|
+
? patch.size
|
|
220
|
+
: current.size))),
|
|
221
|
+
right: Math.round(Math.min(PET_DISPLAY_INSET_MAX, Math.max(0, typeof patch.right === "number" && Number.isFinite(patch.right)
|
|
222
|
+
? patch.right
|
|
223
|
+
: current.right))),
|
|
224
|
+
bottom: Math.round(Math.min(PET_DISPLAY_INSET_MAX, Math.max(0, typeof patch.bottom === "number" && Number.isFinite(patch.bottom)
|
|
225
|
+
? patch.bottom
|
|
226
|
+
: current.bottom))),
|
|
227
|
+
};
|
|
228
|
+
this.persist.display = next;
|
|
229
|
+
this.save();
|
|
230
|
+
return { ...next };
|
|
231
|
+
}
|
|
232
|
+
/** Select another pet from the registry. */
|
|
233
|
+
selectPet(petId) {
|
|
234
|
+
if (!this.registry.has(petId))
|
|
235
|
+
return false;
|
|
236
|
+
this.persist.petId = petId;
|
|
237
|
+
this.save();
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
/** Rename the selected pet (persisted per-pet). */
|
|
241
|
+
renamePet(name) {
|
|
242
|
+
const trimmed = name.trim().slice(0, 20);
|
|
243
|
+
if (trimmed === "")
|
|
244
|
+
return this.petName();
|
|
245
|
+
this.persist.names[this.selectedPetId()] = trimmed;
|
|
246
|
+
this.save();
|
|
247
|
+
return trimmed;
|
|
248
|
+
}
|
|
249
|
+
save() {
|
|
250
|
+
try {
|
|
251
|
+
savePetPersist(this.persist, this.dataDir);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
// Persist failures never break the pet runtime.
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
dispose() {
|
|
258
|
+
for (const off of this.unsubscribes)
|
|
259
|
+
off();
|
|
260
|
+
this.unsubscribes.clear();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pet state machine — ported from @linxin666/dsh-pet (BSD-3-Clause) state.ts.
|
|
3
|
+
* Pure, clock-injected: maps console chat activity phases onto the 9-track
|
|
4
|
+
* spritesheet animation contract, with one-shot celebration/failure windows.
|
|
5
|
+
* No storage, no side effects — persistence and routes live elsewhere.
|
|
6
|
+
* @module loop-agent/console/chat/pet/pet-state
|
|
7
|
+
*/
|
|
8
|
+
export const defaultPetStateConfig = {
|
|
9
|
+
celebrateMs: 2400,
|
|
10
|
+
failureMs: 2400,
|
|
11
|
+
};
|
|
12
|
+
/** Map one activity phase onto the animation contract. */
|
|
13
|
+
export function animationForPhase(phase) {
|
|
14
|
+
switch (phase) {
|
|
15
|
+
case "thinking":
|
|
16
|
+
return "running";
|
|
17
|
+
case "tool":
|
|
18
|
+
return "running-right";
|
|
19
|
+
case "review":
|
|
20
|
+
return "review";
|
|
21
|
+
case "waiting":
|
|
22
|
+
return "waiting";
|
|
23
|
+
case "done":
|
|
24
|
+
return "jumping";
|
|
25
|
+
case "failed":
|
|
26
|
+
return "failed";
|
|
27
|
+
case "idle":
|
|
28
|
+
return "idle";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** The spritesheet row index for one animation track. */
|
|
32
|
+
export function petAnimationRow(animation) {
|
|
33
|
+
const rows = {
|
|
34
|
+
idle: 0,
|
|
35
|
+
"running-right": 1,
|
|
36
|
+
"running-left": 2,
|
|
37
|
+
waving: 3,
|
|
38
|
+
jumping: 4,
|
|
39
|
+
failed: 5,
|
|
40
|
+
waiting: 6,
|
|
41
|
+
running: 7,
|
|
42
|
+
review: 8,
|
|
43
|
+
};
|
|
44
|
+
return rows[animation];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* PetStateMachine — holds only the latest input snapshot and terminal-state
|
|
48
|
+
* timing; no storage, no side effects.
|
|
49
|
+
*/
|
|
50
|
+
export class PetStateMachine {
|
|
51
|
+
now;
|
|
52
|
+
phase = "idle";
|
|
53
|
+
line;
|
|
54
|
+
sessionActive = false;
|
|
55
|
+
doneAt;
|
|
56
|
+
failedAt;
|
|
57
|
+
config;
|
|
58
|
+
constructor(config = defaultPetStateConfig, now = Date.now) {
|
|
59
|
+
this.now = now;
|
|
60
|
+
this.config = { ...defaultPetStateConfig, ...config };
|
|
61
|
+
}
|
|
62
|
+
onActivity(input) {
|
|
63
|
+
this.phase = input.phase;
|
|
64
|
+
this.line = input.line;
|
|
65
|
+
this.doneAt = input.phase === "done" ? this.now() : undefined;
|
|
66
|
+
this.failedAt = input.phase === "failed" ? this.now() : undefined;
|
|
67
|
+
}
|
|
68
|
+
onSessionActive() {
|
|
69
|
+
this.sessionActive = true;
|
|
70
|
+
}
|
|
71
|
+
onSessionDisposed() {
|
|
72
|
+
this.sessionActive = false;
|
|
73
|
+
this.phase = "idle";
|
|
74
|
+
this.line = undefined;
|
|
75
|
+
this.doneAt = undefined;
|
|
76
|
+
this.failedAt = undefined;
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
const nowMs = this.now();
|
|
80
|
+
let animation = animationForPhase(this.phase);
|
|
81
|
+
const doneSettled = this.phase === "done" &&
|
|
82
|
+
this.doneAt !== undefined &&
|
|
83
|
+
nowMs - this.doneAt >= this.config.celebrateMs;
|
|
84
|
+
const failedSettled = this.phase === "failed" &&
|
|
85
|
+
this.failedAt !== undefined &&
|
|
86
|
+
nowMs - this.failedAt >= this.config.failureMs;
|
|
87
|
+
if (doneSettled || failedSettled)
|
|
88
|
+
animation = "idle";
|
|
89
|
+
const settled = this.phase === "idle" || doneSettled || failedSettled;
|
|
90
|
+
const bubble = settled ? undefined : this.line;
|
|
91
|
+
return {
|
|
92
|
+
animation,
|
|
93
|
+
...(bubble === undefined ? {} : { bubble }),
|
|
94
|
+
animationStartedAt: nowMs,
|
|
95
|
+
phase: this.phase,
|
|
96
|
+
sessionActive: this.sessionActive,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi-mode loop isolation for loop-agent init projections.
|
|
3
|
+
*
|
|
4
|
+
* Pi mode ("自由对话") should not auto-load the governance AGENTS.md managed
|
|
5
|
+
* block that `loop-agent init` writes into a target project, nor the loop-agent
|
|
6
|
+
* built-in skills it mirrors into `<cwd>/.agents/skills/`. Manual `/skills:name`
|
|
7
|
+
* invocation and third-party/custom project skills must stay available; the
|
|
8
|
+
* Workflow mode is untouched (isolation applied only for `sessionMode ===
|
|
9
|
+
* "pi"`).
|
|
10
|
+
*
|
|
11
|
+
* Everything here is a pure function over discovered resources + persisted
|
|
12
|
+
* auto-invocation prefs, so it is trivially unit-testable.
|
|
13
|
+
*/
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { skillResourceId, } from "./resource-preferences-store.js";
|
|
16
|
+
/** init.ts `MANAGED_BLOCK_START` / `MANAGED_BLOCK_END` (docs/templates/init-managed-agents.md). */
|
|
17
|
+
export const LOOP_AGENTS_MANAGED_BLOCK_START = "<!-- LOOP_AGENT_INIT_START -->";
|
|
18
|
+
export const LOOP_AGENTS_MANAGED_BLOCK_END = "<!-- LOOP_AGENT_INIT_END -->";
|
|
19
|
+
/**
|
|
20
|
+
* Built-in skill directory names that `loop-agent init` mirrors from the
|
|
21
|
+
* package's `skills/` into a target project's `.agents/skills/`.
|
|
22
|
+
*
|
|
23
|
+
* MUST be kept in sync with the repo-root `skills/` directory; a CI check
|
|
24
|
+
* asserts they match (see `scripts/check-loop-builtin-skills.sh`).
|
|
25
|
+
*/
|
|
26
|
+
export const LOOP_BUILTIN_SKILL_DIR_NAMES = [
|
|
27
|
+
"agent-worker",
|
|
28
|
+
"ai-engineering-context",
|
|
29
|
+
"analyze-product-dependencies",
|
|
30
|
+
"analyze-product-requirements",
|
|
31
|
+
"browser-tools",
|
|
32
|
+
"code-review-core",
|
|
33
|
+
"codebase-scout",
|
|
34
|
+
"fe-test-ui-scout",
|
|
35
|
+
"frontend-bounded-implement",
|
|
36
|
+
"frontend-contract",
|
|
37
|
+
"frontend-design-review",
|
|
38
|
+
"frontend-plan",
|
|
39
|
+
"frontend-review",
|
|
40
|
+
"frontend-scout",
|
|
41
|
+
"frontend-verification",
|
|
42
|
+
"grill-me",
|
|
43
|
+
"grill-with-docs",
|
|
44
|
+
"improve-codebase-architecture",
|
|
45
|
+
"init-capability-evolution",
|
|
46
|
+
"init-update",
|
|
47
|
+
"local-jacoco-coverage",
|
|
48
|
+
"loop-agent",
|
|
49
|
+
"playwright-cli",
|
|
50
|
+
"playwright-cli-case-generator",
|
|
51
|
+
"requesting-code-review",
|
|
52
|
+
"systematic-debugging",
|
|
53
|
+
"test-driven-development",
|
|
54
|
+
"using-git-worktrees",
|
|
55
|
+
"verification-before-completion",
|
|
56
|
+
"webapp-testing",
|
|
57
|
+
];
|
|
58
|
+
/* Case-insensitive set for fast membership (paths are compared lower-cased). */
|
|
59
|
+
const LOOP_BUILTIN_SKILL_NAMES_LOWER = new Set(LOOP_BUILTIN_SKILL_DIR_NAMES.map((name) => name.toLowerCase()));
|
|
60
|
+
/** Normalize to forward slashes + lower case for Windows/macOS path compares. */
|
|
61
|
+
function normalizeForCompare(value) {
|
|
62
|
+
return value.replace(/\\/g, "/").toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Strip the loop-agent init managed block (inclusive of both markers) from an
|
|
66
|
+
* AGENTS.md content string.
|
|
67
|
+
*
|
|
68
|
+
* Returns the content unchanged when no valid marker pair is present (missing
|
|
69
|
+
* either marker, or END before START), so user-authored AGENTS.md and non-loop
|
|
70
|
+
* roots are never touched.
|
|
71
|
+
*/
|
|
72
|
+
export function stripLoopManagedBlock(content) {
|
|
73
|
+
const start = content.indexOf(LOOP_AGENTS_MANAGED_BLOCK_START);
|
|
74
|
+
if (start < 0)
|
|
75
|
+
return content;
|
|
76
|
+
const end = content.indexOf(LOOP_AGENTS_MANAGED_BLOCK_END, start + LOOP_AGENTS_MANAGED_BLOCK_START.length);
|
|
77
|
+
if (end < 0)
|
|
78
|
+
return content;
|
|
79
|
+
const endPos = end + LOOP_AGENTS_MANAGED_BLOCK_END.length;
|
|
80
|
+
const before = content.slice(0, start).trimEnd();
|
|
81
|
+
const after = content.slice(endPos).trimStart();
|
|
82
|
+
return `${before}${before && after ? "\n\n" : ""}${after}`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* True when a discovered skill is a loop-agent init projection: its file path
|
|
86
|
+
* is under `<cwd>/.agents/skills/<builtin-name>/` for a name in the builtin
|
|
87
|
+
* whitelist. Global user skills (`~/.agents/skills`, `~/.pi/agent/skills`) and
|
|
88
|
+
* third-party project skills outside the whitelist return false.
|
|
89
|
+
*/
|
|
90
|
+
export function isLoopInitProjectedSkill(skill, cwd) {
|
|
91
|
+
if (!skill?.filePath)
|
|
92
|
+
return false;
|
|
93
|
+
const cwdNorm = normalizeForCompare(path.resolve(cwd));
|
|
94
|
+
const fileNorm = normalizeForCompare(path.resolve(skill.filePath));
|
|
95
|
+
const prefix = `${cwdNorm}/.agents/skills/`;
|
|
96
|
+
if (!fileNorm.startsWith(prefix))
|
|
97
|
+
return false;
|
|
98
|
+
const rest = fileNorm.slice(prefix.length);
|
|
99
|
+
const topSeg = rest.split("/")[0];
|
|
100
|
+
if (!topSeg)
|
|
101
|
+
return false;
|
|
102
|
+
return LOOP_BUILTIN_SKILL_NAMES_LOWER.has(topSeg);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Pi-mode default isolation over skills: for skills that are loop init
|
|
106
|
+
* projections, default `disableModelInvocation` to true UNLESS the user has
|
|
107
|
+
* EXPLICITLY tuned auto-invocation ON for that resource id in the persisted
|
|
108
|
+
* prefs. Explicitly ON wins over the Pi default; explicit OFF is treated as the
|
|
109
|
+
* Pi default. Non-loop skills pass through untouched.
|
|
110
|
+
*/
|
|
111
|
+
export function applyPiModeSkillIsolation(skills, prefs, cwd) {
|
|
112
|
+
return skills.map((skill) => {
|
|
113
|
+
if (!isLoopInitProjectedSkill(skill, cwd))
|
|
114
|
+
return skill;
|
|
115
|
+
const id = skillResourceId(skill);
|
|
116
|
+
const pref = prefs.skills[id];
|
|
117
|
+
if (pref?.autoInvocationEnabled === true)
|
|
118
|
+
return skill;
|
|
119
|
+
if (skill.disableModelInvocation === true)
|
|
120
|
+
return skill;
|
|
121
|
+
return { ...skill, disableModelInvocation: true };
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Skills with side-effecting workflows remain manual in every chat mode. */
|
|
125
|
+
export function applyManualOnlySkillPolicy(skills) {
|
|
126
|
+
return skills.map((skill) => skill.name === "init-update" && skill.disableModelInvocation !== true
|
|
127
|
+
? { ...skill, disableModelInvocation: true }
|
|
128
|
+
: skill);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Build the pi-mode loop isolation resource-loader option fragments.
|
|
132
|
+
*
|
|
133
|
+
* - When `enabled` (session mode pi): returns an `agentsFilesOverride` that
|
|
134
|
+
* strips the loop-agent managed AGENTS.md block, and wraps the given
|
|
135
|
+
* `skillsOverride` so it ALSO applies Pi-mode default isolation after the
|
|
136
|
+
* persisted auto-invocation prefs.
|
|
137
|
+
* - When disabled (workflow): returns ONLY the provided `skillsOverride`
|
|
138
|
+
* unchanged, so workflow session behavior is byte-for-byte identical to today.
|
|
139
|
+
*/
|
|
140
|
+
export function buildPiModeLoopIsolationOptions(options) {
|
|
141
|
+
if (!options.enabled) {
|
|
142
|
+
return {
|
|
143
|
+
skillsOverride: (current) => {
|
|
144
|
+
const withPrefs = options.skillsOverride(current);
|
|
145
|
+
return {
|
|
146
|
+
skills: applyManualOnlySkillPolicy(withPrefs.skills),
|
|
147
|
+
diagnostics: withPrefs.diagnostics,
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const { cwd, readPreferences } = options;
|
|
153
|
+
const agentsFilesOverride = (current) => ({
|
|
154
|
+
agentsFiles: current.agentsFiles.map((file) => ({
|
|
155
|
+
...file,
|
|
156
|
+
content: stripLoopManagedBlock(file.content),
|
|
157
|
+
})),
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
agentsFilesOverride,
|
|
161
|
+
skillsOverride: (current) => {
|
|
162
|
+
const prefs = readPreferences() ?? { schemaVersion: 1, skills: {} };
|
|
163
|
+
const withPrefs = options.skillsOverride(current);
|
|
164
|
+
return {
|
|
165
|
+
skills: applyPiModeSkillIsolation(applyManualOnlySkillPolicy(withPrefs.skills), prefs, cwd),
|
|
166
|
+
diagnostics: current.diagnostics,
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-bound ask_user_question custom tool.
|
|
3
|
+
* ConsolePiRuntime supplies the sessionId and UserQuestionRegistry.
|
|
4
|
+
*/
|
|
5
|
+
const ASK_USER_QUESTION_DESCRIPTION = "Ask the user concise questions when a confirmation, choice, or missing detail is required before proceeding. " +
|
|
6
|
+
"The tool pauses until the user answers. Use it instead of writing questions as ordinary assistant text. " +
|
|
7
|
+
"Send one or more questions with stable ids; recommended options should be first and end with (Recommended).";
|
|
8
|
+
export async function buildAskUserQuestionTool(options) {
|
|
9
|
+
const [{ Type }, { defineTool }] = await Promise.all([
|
|
10
|
+
import("typebox"),
|
|
11
|
+
import("@earendil-works/pi-coding-agent"),
|
|
12
|
+
]);
|
|
13
|
+
return defineTool({
|
|
14
|
+
name: "ask_user_question",
|
|
15
|
+
label: "Ask user",
|
|
16
|
+
description: ASK_USER_QUESTION_DESCRIPTION,
|
|
17
|
+
promptSnippet: ASK_USER_QUESTION_DESCRIPTION,
|
|
18
|
+
parameters: Type.Object({
|
|
19
|
+
questions: Type.Array(Type.Object({
|
|
20
|
+
id: Type.String({ description: "Stable question id echoed in the answer." }),
|
|
21
|
+
question: Type.String({ description: "Specific user-facing question." }),
|
|
22
|
+
header: Type.Optional(Type.String({ description: "Optional short heading." })),
|
|
23
|
+
detail: Type.Optional(Type.String({ description: "Optional Markdown context shown below the question." })),
|
|
24
|
+
options: Type.Optional(Type.Array(Type.Object({
|
|
25
|
+
label: Type.String({ description: "Short user-facing option label." }),
|
|
26
|
+
description: Type.Optional(Type.String({ description: "One sentence explaining impact or tradeoff." })),
|
|
27
|
+
}, { additionalProperties: false }))),
|
|
28
|
+
multi_select: Type.Optional(Type.Boolean({ description: "Allow more than one option." })),
|
|
29
|
+
}, { additionalProperties: false }), { minItems: 1, maxItems: 20 }),
|
|
30
|
+
}, { additionalProperties: false }),
|
|
31
|
+
async execute(toolCallId, params, signal) {
|
|
32
|
+
const answer = await options.registry.ask({
|
|
33
|
+
sessionId: options.sessionId,
|
|
34
|
+
toolCallId,
|
|
35
|
+
questions: params.questions,
|
|
36
|
+
signal,
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: "text", text: JSON.stringify(answer) }],
|
|
40
|
+
details: answer,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|