@tea-agent/loop-agent 0.39.0-next.12 → 0.39.0-next.13

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/build-stamp.json +2 -2
  3. package/dist/shared/operator/capabilities.js +65 -8
  4. package/dist/worker/console/chat/pi-runtime.js +11 -9
  5. package/dist/worker/console/chat/semantic-activity.js +17 -5
  6. package/dist/worker/console/operator-actions.js +74 -0
  7. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CRpBFiPS.js → abnfDiagram-N423BO3Z-Hfsot6rP.js} +1 -1
  8. package/dist/worker/console/static/assets/{arc-CFq00qel.js → arc-YGwEASin.js} +1 -1
  9. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-Dk_urLIc.js → architectureDiagram-T3A2C74G-CmOM0F92.js} +1 -1
  10. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CLM5ocwZ.js → blockDiagram-VBNYF7ZC-DDLuaHC5.js} +1 -1
  11. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-CWYcPCa3.js → c4Diagram-5PPSVZJV-B0Um43W4.js} +1 -1
  12. package/dist/worker/console/static/assets/channel-Dp_2Aqf1.js +1 -0
  13. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-XILOozrE.js → chunk-2GRJ4B5K-DvBN4JZc.js} +1 -1
  14. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-M4A5lfjn.js → chunk-2Q5K7J3B-B1UVgW4E.js} +1 -1
  15. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-CHq6wHgP.js → chunk-5RXB4S5H-Cf0GgXzX.js} +1 -1
  16. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-COevfhfp.js → chunk-5VM5RSS4-DbNA24sj.js} +1 -1
  17. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-CN1D-iO4.js → chunk-6Q2QTUOP-Bi_0Be06.js} +1 -1
  18. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-C6qAAYuy.js → chunk-GF5L2VYU-C8pPGvRd.js} +1 -1
  19. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-DzjF9LjT.js → chunk-JWPE2WC7-BitQY8Z-.js} +1 -1
  20. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B4vicTaj.js → chunk-KBJHAD2P-U67GCiEo.js} +1 -1
  21. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-D5nkzM8K.js → chunk-RYQCIY6F-IoJwXPBA.js} +1 -1
  22. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CUgkbah9.js → chunk-XXDRQBXY-YDZ_UHgE.js} +1 -1
  23. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL--CODy37j.js +1 -0
  24. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE--CODy37j.js +1 -0
  25. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-faupYrw-.js → cose-bilkent-JH36ORCC-CUZgsiRC.js} +1 -1
  26. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-Bev9OTKA.js → cynefin-VYW2F7L2-COmCh4pT.js} +1 -1
  27. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-A0iHnoJm.js → cynefinDiagram-MW4NZA55-Ta6FSm68.js} +1 -1
  28. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-Bboc-8dL.js → dagre-VZM6K2ZE-UdcR-VW9.js} +1 -1
  29. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CZcV9H_a.js → diagram-7IWD3JNH-DybcO3Et.js} +1 -1
  30. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-I1kV6LGQ.js → diagram-B4RE2ZJO-wErDFWLw.js} +1 -1
  31. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-BaSON7dV.js → diagram-LBJQPF4R-DkVHZWqz.js} +1 -1
  32. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-KUeIAdtX.js → diagram-Q27KOJAE-DdqWs7QN.js} +1 -1
  33. package/dist/worker/console/static/assets/{diagram-UB23O5K3-DylPuZu-.js → diagram-UB23O5K3-C9dMVmDo.js} +1 -1
  34. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-DcWoMdm7.js → ebnfDiagram-BXEA7PRR-B2T2WcBK.js} +1 -1
  35. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BxJOdF_H.js → erDiagram-JOGREHBK-Bt9rjDFq.js} +1 -1
  36. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-DHxQgLL0.js → flowDiagram-UKHOOZJN-U8ic_tvi.js} +1 -1
  37. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-CVz9xzIE.js → ganttDiagram-PKOTCBZU-BfQJdQoO.js} +1 -1
  38. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-D4C2Yvbd.js → gitGraphDiagram-DS77QQ5N-CpMftH4O.js} +1 -1
  39. package/dist/worker/console/static/assets/{index-amy_wpJL.js → index-DKPXBrdc.js} +3 -3
  40. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-Dr3ejwyd.js → infoDiagram-6WML65LV-DzqWXNO_.js} +1 -1
  41. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-2kJbNO0g.js → ishikawaDiagram-WSZJBQD7-CJmGQ5Yp.js} +1 -1
  42. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CMfF4VjJ.js → journeyDiagram-NVQOT4AX-ChPtKFLz.js} +1 -1
  43. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DNN-Q1z3.js → kanban-definition-27J2QSJJ-PRe7wB5u.js} +1 -1
  44. package/dist/worker/console/static/assets/{linear-OB4Y8pOn.js → linear-DpKX6QNp.js} +1 -1
  45. package/dist/worker/console/static/assets/{mermaid.core-DFSjahzL.js → mermaid.core-Dnl76b7Y.js} +5 -5
  46. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-D1WNklJu.js → mindmap-definition-FAOFIHXS-S9PCXc3J.js} +1 -1
  47. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-Be2wdQXD.js → pegDiagram-VL7TDLO6-Du8e-FSX.js} +1 -1
  48. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-hhWe5f6C.js → pieDiagram-7S7Q4E2Y-CY6OmHTc.js} +1 -1
  49. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BT597AoO.js → quadrantDiagram-CIZ2JOQS-C65GPhpj.js} +1 -1
  50. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-BjqVRkNc.js → railroadDiagram-AXF67PYL-U6IUiTCL.js} +1 -1
  51. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-D964n5d3.js → requirementDiagram-LRYGKXZP-D-I_9Qhi.js} +1 -1
  52. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-_aPpr_hL.js → sankeyDiagram-W5VNT64P-B57Fhed0.js} +1 -1
  53. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BY0YUKL1.js → sequenceDiagram-SI44F4Z6-CJOtiw21.js} +1 -1
  54. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-CgpnvQ-_.js → sizeCapture-X5ZJPWSS-FyX8zxSh.js} +1 -1
  55. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-BfWR9Od2.js → stateDiagram-OKZ733FA-eF-pbs9t.js} +1 -1
  56. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-B-mvnLEc.js +1 -0
  57. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-CWDqlFt_.js → swimlanes-SLNWSIFB-CcfkA-Dq.js} +2 -2
  58. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-JtpBmIv4.js +8 -0
  59. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-DjURY-Nw.js → timeline-definition-Z64GVDOM-DH8FjnOK.js} +1 -1
  60. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-D1nP5tpF.js → vennDiagram-T6HMQDX7-beoTagJg.js} +1 -1
  61. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BfRbqp6h.js → wardleyDiagram-T6FBY63Y-CQSfw4cK.js} +1 -1
  62. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D8FzmnEz.js → xychartDiagram-ELKLHX3M-CQgzQ6jn.js} +1 -1
  63. package/dist/worker/console/static/index.html +1 -1
  64. package/package.json +1 -1
  65. package/dist/worker/console/static/assets/channel-Dpjb6BMm.js +0 -1
  66. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-Cv4CdaZH.js +0 -1
  67. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-Cv4CdaZH.js +0 -1
  68. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI--1Trd-FO.js +0 -1
  69. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BepA9ids.js +0 -8
package/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ### 改进
6
6
 
7
+ - Operator Chat 恢复工具对齐真实能力:系统提示改用 `dagReport` / `dagRerunPlan` / `dagRerun` / `standaloneTaskRerun` / `workerTaskRetry` 真名,不再写 `operator_*` 或把 `dagResume` 当成模型可执行项;`dagDoctor` / `dagStatus` / `workerPoolDoctor` 改为 typed `runId`/`taskId`,不再让模型猜 CLI `args[]`。ADR 0013 自定义 base prompt 上限由 1900 统一调整为 2500(2026-08-18,废止 0.8×2498 比例),预算用于写清节点续跑 / 整单重生 / Worker 重排队分流,以及多轮迭代恢复纪律(先一句话总结上一轮错误、修根因不修症状、禁止原样重交、同错两轮后停下报告)。
8
+
7
9
  - Operator Chat 对齐 pi-web:建会话不再传封闭 `tools` 白名单(避免 SDK 把扩展 MCP 工具滤出 registry),创建后 `bindExtensions` 发 `session_start`,再钉激活集。扩展注册的 MCP 工具可被模型调用;`apply_patch` / `full-tools` / `shell` / `coding-chat` 仍排除。
8
10
  - 对话侧栏 Plugins 右侧新增只读 MCP 弹窗:展示 `mcp.json` 配置的服务,以及当前会话真正注册/激活的 MCP 工具;没有配置也没有工具时保持真实空态。
9
11
  - 对话侧栏原 Packages 入口改名为 Plugins,与 pi-web / Pi 用户面一致;内部仍是 package inventory。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "version": "0.37.0",
4
- "gitSha": "eae9755e07946ca86dc6ce15fd69e9bb6f0680df",
5
- "builtAt": "2026-08-18T13:47:49.649Z"
4
+ "gitSha": "ef39870bd2294f451bb85ef7a6ee599ebcd887a4",
5
+ "builtAt": "2026-08-18T16:37:19.124Z"
6
6
  }
@@ -63,8 +63,6 @@ const officialAction = (action, cli, kind, coverage) => ({
63
63
  });
64
64
  const OFFICIAL_ACTIONS = [
65
65
  ...[
66
- ["dagDoctor", "loop-agent dag doctor", "read", "model-callable"],
67
- ["dagStatus", "loop-agent dag status", "read", "model-callable"],
68
66
  [
69
67
  "dagDecisionInspect",
70
68
  "loop-agent dag decision inspect",
@@ -284,7 +282,6 @@ const OFFICIAL_ACTIONS = [
284
282
  "long-running",
285
283
  "advanced",
286
284
  ],
287
- ["workerPoolDoctor", "agent-worker pool doctor", "read", "model-callable"],
288
285
  [
289
286
  "workerPoolMarkFailed",
290
287
  "agent-worker pool mark-failed",
@@ -1079,7 +1076,7 @@ export function buildOperatorCapabilitiesDocument() {
1079
1076
  "CONTROLLER_MISMATCH",
1080
1077
  "INVALID_INPUT",
1081
1078
  ],
1082
- description: "Consume a single-use execution receipt and execute the reviewed DAG (prefer task advance --approve-gate when gate token present). accepted/queued/running/operationId are NOT completion — supervise via operationGet/status/dagReport/dagDoctor/operationWait.",
1079
+ description: "Consume a single-use executionId from prepareDagExecution and execute the reviewed DAG. Do not pass a DAG path and do not bash `task advance --approve-gate`. accepted/queued/running/operationId are NOT completion — supervise via operationGet/status/dagReport/dagDoctor/operationWait.",
1083
1080
  inputParams: [
1084
1081
  {
1085
1082
  name: "executionId",
@@ -1102,7 +1099,7 @@ export function buildOperatorCapabilitiesDocument() {
1102
1099
  resultSchemaVersion: 1,
1103
1100
  envelopeSchemaVersion: 1,
1104
1101
  requiredErrorCodes: ["INVALID_INPUT", "NOT_FOUND"],
1105
- description: "Read-only R1 subgraph plan (no mutation). Call before dagRerun. Prefer primaryFailure.nodeId from dagReport. If eligible=false (writer/decision/fingerprint, unsafe shell, worker-managed, workspace/controller drift), do not force execute — Worker-owned runs use workerTaskRetry; standalone runs use standaloneTaskRerun or same-task advance after fixing the root cause (contract changes must be adopted first). Returns planHash required by execute.",
1102
+ description: "Read-only check: can this failed run continue from fromNode? Call after dagReport; pass primaryFailure.nodeId. Does not execute. eligible=true returns planHash for dagRerun. eligible=false: Worker/Task Pool Failed workerTaskRetry; standalone Console run standaloneTaskRerun after any required contract adopt. Do not call dagRerun or invent a new task.",
1106
1103
  inputParams: [
1107
1104
  {
1108
1105
  name: "runId",
@@ -1132,7 +1129,7 @@ export function buildOperatorCapabilitiesDocument() {
1132
1129
  "BINDING_DRIFT",
1133
1130
  "INVALID_INPUT",
1134
1131
  ],
1135
- description: "Execute R1 continuation from effective node. Requires planHash from a fresh dagRerunPlan (eligible=true). Prefer this over new task / standaloneTaskRerun for provider flake and safe downstream failures. Server enforces planHash/binding/fingerprint freshness.",
1132
+ description: "Continue the same DAG from fromNode. Requires a fresh dagRerunPlan with eligible=true and that exact planHash. Prefer this for provider flake / safe downstream failures. Not a full task regenerate (that is standaloneTaskRerun). Server rejects stale planHash or binding drift.",
1136
1133
  inputParams: [
1137
1134
  {
1138
1135
  name: "runId",
@@ -1498,7 +1495,7 @@ export function buildOperatorCapabilitiesDocument() {
1498
1495
  "INVALID_INPUT",
1499
1496
  "HUMAN_CONFIRMATION_REQUIRED",
1500
1497
  ],
1501
- description: "Full standalone task regenerate validate execute with parent lineage. Only when node rerun plan is ineligible or primaryRecovery recommends rerun-task; the server checks read-only run facts before accepting. Regeneration reuses the CURRENT contract snapshot: if the failure requires contract changes (e.g. allowing a catalog index path), first update the contract (re-import PRD, or adopt externally-edited sources via `task contract adopt`) BEFORE calling this action, otherwise the regenerated DAG repeats the same failure.",
1498
+ description: "Regenerate the whole standalone DAG from the CURRENT contract, then validate and execute a new run (parent lineage kept). This is NOT continue-from-failed-node that is dagRerun. Server rejects the call when dagRerunPlan is eligible, when primaryRecovery.humanRequired=true, or when run facts do not recommend rerun-task. Adopt contract changes before calling or the new DAG repeats the same failure.",
1502
1499
  inputParams: [
1503
1500
  {
1504
1501
  name: "runId",
@@ -1542,7 +1539,7 @@ export function buildOperatorCapabilitiesDocument() {
1542
1539
  "INVALID_INPUT",
1543
1540
  "HUMAN_CONFIRMATION_REQUIRED",
1544
1541
  ],
1545
- description: "Requeue failed Task Pool task (Failed → Ready) via in-package pool store. Only when read-only validation confirms the task exists in Failed state; the server checks this before accepting.",
1542
+ description: "Requeue a Worker Task Pool task Failed → Ready. Not a DAG node rerun (use dagRerun) and not a standalone DAG regenerate (use standaloneTaskRerun). Confirm with workerPoolDoctor first; server accepts only Failed pool tasks. Pass featureId when known it must match the pool record.",
1546
1543
  inputParams: [
1547
1544
  {
1548
1545
  name: "taskId",
@@ -1568,6 +1565,66 @@ export function buildOperatorCapabilitiesDocument() {
1568
1565
  modelCallable: "always",
1569
1566
  humanConfirmation: "none",
1570
1567
  },
1568
+ {
1569
+ action: "dagDoctor",
1570
+ cli: "loop-agent dag doctor [--run-id <id>] --json",
1571
+ kind: "read",
1572
+ inputSchemaVersion: 1,
1573
+ resultSchemaVersion: 1,
1574
+ envelopeSchemaVersion: 1,
1575
+ requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
1576
+ description: "Diagnose DAG run health. Omit runId for a repo-wide inventory (active/paused/completed + health issues). Pass runId for one run's liveness, heartbeat, failure node, and recovery hints. Use this to supervise stalls; it does not mutate the run.",
1577
+ inputParams: [
1578
+ {
1579
+ name: "runId",
1580
+ type: "string",
1581
+ required: false,
1582
+ description: "optional dag run id; omit to inventory all runs, pass to diagnose one run",
1583
+ },
1584
+ ],
1585
+ modelCallable: "always",
1586
+ humanConfirmation: "none",
1587
+ },
1588
+ {
1589
+ action: "dagStatus",
1590
+ cli: "loop-agent dag status --run-id <id>",
1591
+ kind: "read",
1592
+ inputSchemaVersion: 1,
1593
+ resultSchemaVersion: 1,
1594
+ envelopeSchemaVersion: 1,
1595
+ requiredErrorCodes: ["NOT_FOUND", "INVALID_INPUT"],
1596
+ description: "Read one DAG run's live status, current node, and liveness. Requires runId. Complements dagReport (terminal handoff) and dagDoctor (health diagnosis). Does not mutate the run.",
1597
+ inputParams: [
1598
+ {
1599
+ name: "runId",
1600
+ type: "string",
1601
+ required: true,
1602
+ description: "dag run id",
1603
+ },
1604
+ ],
1605
+ modelCallable: "always",
1606
+ humanConfirmation: "none",
1607
+ },
1608
+ {
1609
+ action: "workerPoolDoctor",
1610
+ cli: "agent-worker pool doctor --repo . --json",
1611
+ kind: "read",
1612
+ inputSchemaVersion: 1,
1613
+ resultSchemaVersion: 1,
1614
+ envelopeSchemaVersion: 1,
1615
+ requiredErrorCodes: ["INVALID_INPUT", "NOT_FOUND"],
1616
+ description: "Read-only Task Pool inventory (legacy + v2). Use before workerTaskRetry to confirm the task exists and status is Failed. Optional taskId filters the returned inventory to that task.",
1617
+ inputParams: [
1618
+ {
1619
+ name: "taskId",
1620
+ type: "string",
1621
+ required: false,
1622
+ description: "optional task id to focus the inventory",
1623
+ },
1624
+ ],
1625
+ modelCallable: "always",
1626
+ humanConfirmation: "none",
1627
+ },
1571
1628
  ...OFFICIAL_ACTIONS,
1572
1629
  ];
1573
1630
  return {
@@ -45,24 +45,26 @@ import { RUNTIME_CONTEXT_TEXT_MAX, redactRuntimeText, } from "./runtime-context.
45
45
  * Project governance (operator-only policy, allowedPaths/forbiddenPaths,
46
46
  * writer writeSet, taskKind routing, verification matrix, DAG recovery
47
47
  * commands, closeout) lives in the loaded target-project AGENTS.md. The
48
- * prompt below covers: Operator identity, the real tool surface (operator_*
49
- * first + Pi tools, obey AGENTS.md), denied non-Pi runtimes, safe-* probes,
50
- * init/init-upgrade fallback for uninitialized repos, DAG supervision with
51
- * 15/30/60s adaptive polling (operationGet/status/dagReport/dagDoctor), R2
52
- * recovery (fresh eligible dagRerunPlan → dagRerun; ineligible → same-task
53
- * rerun/advance, resume, Worker retry) and G2 bounded writeSet auto-approval.
48
+ * prompt below covers: Operator identity, the real tool surface (typed
49
+ * operator tools first + Pi tools, obey AGENTS.md), denied non-Pi runtimes,
50
+ * safe-* probes, init/init-upgrade fallback for uninitialized repos, DAG
51
+ * supervision with 60/90/120/180s adaptive polling
52
+ * (operationGet/status/dagReport/dagDoctor/operationWait), R2 recovery
53
+ * (dagReport dagRerunPlan dagRerun; ineligible standaloneTaskRerun or
54
+ * workerTaskRetry, never dagResume) and G2 bounded writeSet auto-approval.
54
55
  *
55
56
  * The old Human Gate tutorial paragraphs (prepare + browser Human Gate,
56
57
  * "confirmDagConfirmation is a human-only action", the long "Recovery default
57
58
  * order" table) are REMOVED — bounded DAGs start and recover autonomously
58
- * (AC-01: ≤ 1900 chars and 80% of the 2498-char baseline).
59
+ * (AC-01: ≤ 2500 chars; 2498-slimming ratio retired 2026-08-18).
59
60
  */
60
61
  export const OPERATOR_CHAT_SYSTEM_PROMPT_BASE = [
61
62
  "You are General Operator Chat.",
62
- "Use operator_* tools first. Pi read/write/edit/bash/grep/find/ls are available; obey repository AGENTS.md. apply_patch, full-tools, shell and coding-chat are denied. Prefer safe-read/safe-grep for sensitive probes.",
63
+ "Use operator tools first (dagReport, dagRerunPlan, dagRerun). Pi read/write/edit/bash/grep/find/ls are available; obey repository AGENTS.md. apply_patch, full-tools, shell and coding-chat are denied. Prefer safe-read/safe-grep for probes.",
63
64
  "No harness and asked to init: `loop-agent init instructions --repo-root .`, then `loop-agent init --repo-root . --profile full --merge`; verify with doctor, inspect and docs audit. Updates: `loop-agent init upgrade --repo-root . --json` until stable; `loop-agent init check-update` is read-only.",
64
65
  "Long DAGs: prepareDagExecution → runDag → operationId. Never foreground-Bash task advance, tail/head pipes or nohup/Start-Process/start; do not end on accepted/queued/running or an operationId — NOT completion. Supervise operationGet/status/dagReport/dagDoctor/operationWait with 60s → 90s → 120s → 180s backoff; reset to 60s on state change; 30-60s re-checks when stall suspected. Every operationWait continuation MUST use afterSeq=previous nextSeq (prefer recommendedNextCall); never reuse an older cursor. Heartbeats are not meaningful progress.",
65
- "On failure consume terminal runSummary first. If progress exists, wait; else use a fresh dagRerunPlan; when ineligible use same-task rerun/advance, resume, or Worker retry. A run-failed task without an open gate is terminal: do not re-advance a run-failed task. Before run start, two identical lifecycleState/blocker/revision/DAG-hash observations mean no progress: stop and report after one bounded probe; never loop identical bash/read/grep. Auto-approve only bounded writeSet inside allowedPaths, outside forbiddenPaths, with structured verification.",
66
+ "On failure consume terminal runSummary first. If progress exists, wait; else dagReport then dagRerunPlan(fromNode=primaryFailure.nodeId); eligible dagRerun (node rerun only: reruns the failed subgraph, keeps prior successes). If plan ineligible (unsafe-shell subgraph, binding/workspace drift): Worker Failed → workerTaskRetry; standalone → standaloneTaskRerun after contract adopt (regenerates the whole task, not node continue). Do not call dagResume. A run-failed task without an open gate is terminal: do not re-advance a run-failed task. Before run start, two identical lifecycleState/blocker/revision/DAG-hash observations mean no progress: stop and report after one bounded probe; never loop identical bash/read/grep. Auto-approve only bounded writeSet inside allowedPaths, outside forbiddenPaths, with structured verification.",
67
+ "Iterate toward the goal in bounded rounds: first summarize the previous round's error in one line (wrong fix, wrong node, or environment), fix its root cause — not the symptom — then rerun the failed node with a fresh plan. Never resubmit an unchanged fix; after two rounds failing the same way, stop and report evidence and remaining routes.",
66
68
  "Continue until success, user stop, or no safe recovery remains; then stop and report failure/evidence. Never create a new task for a transient failure or replace repair-pi with direct edits.",
67
69
  ].join("\n");
68
70
  /** Compose the inspectable system prompt actually injected into Operator Chat. */
@@ -39,9 +39,11 @@ const OPERATION_TITLES = {
39
39
  dagDoctor: "执行诊断",
40
40
  dagReport: "执行结果",
41
41
  dagRerunPlan: "恢复评估",
42
+ dagRerun: "从节点续跑",
42
43
  dagInterruptEligibility: "中止资格",
43
- standaloneTaskRerun: "恢复执行",
44
- workerTaskRetry: "重试任务",
44
+ standaloneTaskRerun: "完整重跑任务",
45
+ workerTaskRetry: "重试 Worker 任务",
46
+ workerPoolDoctor: "任务池诊断",
45
47
  promoteRun: "任务推进",
46
48
  status: "任务状态",
47
49
  };
@@ -96,10 +98,20 @@ const TOOL_SEMANTICS = {
96
98
  success: "中止资格已经确认",
97
99
  error: "当前运行不能协作中止",
98
100
  },
101
+ dagRerun: {
102
+ running: "正在从失败节点续跑",
103
+ success: "已经从失败节点继续执行",
104
+ error: "从失败节点续跑时遇到问题",
105
+ },
99
106
  standaloneTaskRerun: {
100
- running: "正在从失败位置恢复执行",
101
- success: "已经从失败位置继续执行",
102
- error: "从失败位置恢复执行时遇到问题",
107
+ running: "正在完整重跑整单任务",
108
+ success: "已经启动完整重跑",
109
+ error: "完整重跑任务时遇到问题",
110
+ },
111
+ workerPoolDoctor: {
112
+ running: "正在读取任务池状态",
113
+ success: "任务池状态已经读取",
114
+ error: "读取任务池状态时遇到问题",
103
115
  },
104
116
  promoteRun: {
105
117
  running: "正在推进任务状态",
@@ -672,6 +672,80 @@ export async function dispatchOperatorAction(ctx, req) {
672
672
  const body = await runReadCli(ctx, ["dag", "report", "--run-id", runId, "--json"], "dag report");
673
673
  return { kind: "sync", status: body.ok ? 200 : 400, body };
674
674
  }
675
+ case "dagDoctor": {
676
+ const runId = str(p.runId) ?? str(p.dagRunId);
677
+ const args = ["dag", "doctor"];
678
+ if (runId)
679
+ args.push("--run-id", runId);
680
+ const body = await runReadCli(ctx, args, "dag doctor");
681
+ return { kind: "sync", status: body.ok ? 200 : 400, body };
682
+ }
683
+ case "dagStatus": {
684
+ const runId = str(p.runId) ?? str(p.dagRunId);
685
+ if (!runId)
686
+ return invalid(action, "runId is required");
687
+ const body = await runReadCli(ctx, ["dag", "status", "--run-id", runId], "dag status");
688
+ return { kind: "sync", status: body.ok ? 200 : 400, body };
689
+ }
690
+ case "workerPoolDoctor": {
691
+ const taskId = str(p.taskId);
692
+ const run = ctx.runCommand ??
693
+ ((args, options) => ctx.client.runExternal
694
+ ? ctx.client.runExternal(resolveSiblingAgentWorkerBin(), args, options)
695
+ : ctx.client.run(args, options));
696
+ let result;
697
+ try {
698
+ result = await run(["pool", "doctor", "--repo", ctx.repoRoot, "--json"], {
699
+ cwd: ctx.repoRoot,
700
+ artifactName: "read-pool-doctor",
701
+ expectJson: true,
702
+ });
703
+ }
704
+ catch (error) {
705
+ return {
706
+ kind: "error",
707
+ status: 400,
708
+ body: operatorFailed({
709
+ command: action,
710
+ outcome: "invalid",
711
+ code: "INVALID_INPUT",
712
+ message: `cannot read pool doctor facts: ${error instanceof Error ? error.message : String(error)}`,
713
+ }),
714
+ };
715
+ }
716
+ if (!result.ok || result.exitCode !== 0 || !result.json) {
717
+ return {
718
+ kind: "error",
719
+ status: 400,
720
+ body: operatorFailed({
721
+ command: action,
722
+ outcome: "invalid",
723
+ code: "INVALID_INPUT",
724
+ message: summarizeReadCliFailure(result),
725
+ }),
726
+ };
727
+ }
728
+ const inventory = result.json;
729
+ if (!taskId) {
730
+ return {
731
+ kind: "sync",
732
+ status: 200,
733
+ body: operatorSucceeded(action, inventory),
734
+ };
735
+ }
736
+ const v2 = (inventory.v2 ?? []).filter((entry) => entry.taskId === taskId);
737
+ const legacy = (inventory.legacy ?? []).filter((entry) => entry.taskId === taskId);
738
+ return {
739
+ kind: "sync",
740
+ status: 200,
741
+ body: operatorSucceeded(action, {
742
+ ...inventory,
743
+ v2,
744
+ legacy,
745
+ focusedTaskId: taskId,
746
+ }),
747
+ };
748
+ }
675
749
  case "status": {
676
750
  const taskId = str(p.taskId);
677
751
  if (!taskId) {
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-CN1D-iO4.js";import{p as f}from"./chunk-JWPE2WC7-DzjF9LjT.js";import{_ as n,l as o}from"./mermaid.core-DFSjahzL.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-Bev9OTKA.js";import"./index-amy_wpJL.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-Bi_0Be06.js";import{p as f}from"./chunk-JWPE2WC7-BitQY8Z-.js";import{_ as n,l as o}from"./mermaid.core-Dnl76b7Y.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-COmCh4pT.js";import"./index-DKPXBrdc.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-DFSjahzL.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-Dnl76b7Y.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};