@tea-agent/loop-agent 0.52.0 → 0.53.0-next.2

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 (148) hide show
  1. package/CHANGELOG.md +62 -4
  2. package/dist/build-stamp.json +3 -3
  3. package/dist/executors/dag-pi/plan/finalize-tools.js +13 -0
  4. package/dist/executors/dag-pi/plan/record-tools.js +37 -11
  5. package/dist/executors/dag-pi/sessions/plan-batches.js +1 -1
  6. package/dist/executors/dag-pi/sessions/segmented-plan.js +28 -20
  7. package/dist/executors/dag-pi/tools/plan-decision-tools.js +2 -1
  8. package/dist/executors/dag-pi-executor.js +50 -5
  9. package/dist/executors/pi-executor.js +12 -0
  10. package/dist/executors/pi-sdk-executor.js +2 -2
  11. package/dist/shared/frontend-execution-policy.js +28 -2
  12. package/dist/shared/pi-context-pressure/compaction-policy.js +22 -34
  13. package/dist/shared/pi-context-pressure/index.js +1 -1
  14. package/dist/task/config-types.js +2 -2
  15. package/dist/task/source-prepare/prepare.js +1 -1
  16. package/dist/task/source-prepare/semantic-intake.js +2 -2
  17. package/dist/task/source-prepare/source-fidelity-pi.js +2 -1
  18. package/dist/worker/console/automation-actions.js +62 -7
  19. package/dist/worker/console/chat/api-workbench-core.js +131 -4
  20. package/dist/worker/console/chat/api-workbench-schema.js +278 -0
  21. package/dist/worker/console/chat/api-workbench-spring.js +333 -0
  22. package/dist/worker/console/chat/api-workbench.js +88 -2
  23. package/dist/worker/console/chat/human-gate-card.js +16 -1
  24. package/dist/worker/console/chat/image-cache.js +39 -8
  25. package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +120 -5
  26. package/dist/worker/console/chat/pi-runtime.js +2 -3
  27. package/dist/worker/console/chat/provider-error.js +12 -2
  28. package/dist/worker/console/chat/repo-walk.js +8 -0
  29. package/dist/worker/console/chat/routes.js +125 -13
  30. package/dist/worker/console/chat/todo-diff.js +90 -0
  31. package/dist/worker/console/chat/turn-process.js +3 -0
  32. package/dist/worker/console/network-proxy-settings.js +67 -1
  33. package/dist/worker/console/operator-actions.js +25 -0
  34. package/dist/worker/console/pi-compaction-settings.js +16 -13
  35. package/dist/worker/console/server.js +20 -0
  36. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CR1jj_rz.js → abnfDiagram-N423BO3Z-9YdcTSkA.js} +1 -1
  37. package/dist/worker/console/static/assets/{arc-CjxcQfEu.js → arc-5o9a24RM.js} +1 -1
  38. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-D-3u2qFL.js → architectureDiagram-T3A2C74G-kk-Y4K8w.js} +1 -1
  39. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bdr7gWVo.js → blockDiagram-VBNYF7ZC-BuMyp-i-.js} +1 -1
  40. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-hQHNe5T3.js → c4Diagram-5PPSVZJV-BnAbUXQM.js} +1 -1
  41. package/dist/worker/console/static/assets/channel-DzpJs7JM.js +1 -0
  42. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-BEg_su6q.js → chunk-2GRJ4B5K-sQ2VjuFx.js} +1 -1
  43. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-DZnV6VTC.js → chunk-2Q5K7J3B-CbkqzTV8.js} +1 -1
  44. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Dg0LzAqO.js → chunk-5RXB4S5H-CaP8JTC3.js} +1 -1
  45. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-D2vqr52W.js → chunk-5VM5RSS4-D7yUFtwu.js} +1 -1
  46. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D8We_g6R.js → chunk-6Q2QTUOP-zowLlgmO.js} +1 -1
  47. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DbEU8drD.js → chunk-GF5L2VYU-KGzLFdSC.js} +1 -1
  48. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Boi8TJYN.js → chunk-JWPE2WC7-DuVIxg_I.js} +1 -1
  49. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CjJmKa9f.js → chunk-KBJHAD2P-CXP8iZrQ.js} +1 -1
  50. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-C-KV-ag7.js → chunk-RYQCIY6F-DASfOCYV.js} +1 -1
  51. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DZlTonsZ.js → chunk-XXDRQBXY-DFwLDf-r.js} +1 -1
  52. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-ClK7LSSv.js +1 -0
  53. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-ClK7LSSv.js +1 -0
  54. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-BIvFe3yn.js → cose-bilkent-JH36ORCC-CIrJSuNM.js} +1 -1
  55. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-BOBPfv8u.js → cynefinDiagram-MW4NZA55-BrI5M-XP.js} +1 -1
  56. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BF54orLO.js → dagre-VZM6K2ZE-BEJlUQi2.js} +1 -1
  57. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CxjAP2AP.js → diagram-7IWD3JNH-Buw7nAqS.js} +1 -1
  58. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BXYkuNGt.js → diagram-B4RE2ZJO-DHURLBbb.js} +1 -1
  59. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-DQTu-2Iy.js → diagram-LBJQPF4R-CEFuptxk.js} +1 -1
  60. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-DNURuIYc.js → diagram-Q27KOJAE-Cejgl71p.js} +1 -1
  61. package/dist/worker/console/static/assets/{diagram-UB23O5K3-D69uANY8.js → diagram-UB23O5K3-Bwxq3Xoa.js} +1 -1
  62. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-C658EcrV.js → ebnfDiagram-BXEA7PRR-i4NNenm0.js} +1 -1
  63. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BRccYtAl.js → erDiagram-JOGREHBK-BaSp03BR.js} +1 -1
  64. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-DnIR4sLs.js → flowDiagram-UKHOOZJN-CQtgCCPg.js} +1 -1
  65. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Bo3eWFVC.js → ganttDiagram-PKOTCBZU-DkS9Vbt8.js} +1 -1
  66. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-EyWDCNU_.js → gitGraphDiagram-DS77QQ5N-Dm64UQgY.js} +1 -1
  67. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-B0Eld9u0.js → infoDiagram-6WML65LV-BpcLrRRV.js} +1 -1
  68. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsJQiJ27.js → ishikawaDiagram-WSZJBQD7-DFjxaE3Q.js} +1 -1
  69. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-fpE0yqjC.js → journeyDiagram-NVQOT4AX-G6kuLGYK.js} +1 -1
  70. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-Dq9IrDdT.js → kanban-definition-27J2QSJJ-DistDdnp.js} +1 -1
  71. package/dist/worker/console/static/assets/{linear-CFV4BDyf.js → linear-Cadcj4Jf.js} +1 -1
  72. package/dist/worker/console/static/assets/main-CKu0wCrM.js +654 -0
  73. package/dist/worker/console/static/assets/main-DpBoCiky.css +1 -0
  74. package/dist/worker/console/static/assets/{mermaid.core-BMMXqtrB.js → mermaid.core-CVqQBsGx.js} +4 -4
  75. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-DurrK_Gi.js → mindmap-definition-FAOFIHXS-oIAAXLn3.js} +1 -1
  76. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-CzZayNy2.js → pegDiagram-VL7TDLO6-BgBPFLA0.js} +1 -1
  77. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-B1W7Y0cE.js → pieDiagram-7S7Q4E2Y-RTyZdL9S.js} +1 -1
  78. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BdbL83CU.js → quadrantDiagram-CIZ2JOQS-BHEYQMZx.js} +1 -1
  79. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-W-bQpd18.js → railroadDiagram-AXF67PYL-B2JIrks2.js} +1 -1
  80. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-C9bi4tQJ.js → requirementDiagram-LRYGKXZP-TJ5_MWbY.js} +1 -1
  81. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-D4kO56Wd.js → sankeyDiagram-W5VNT64P-BzjUsr0j.js} +1 -1
  82. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CIbesK1e.js → sequenceDiagram-SI44F4Z6-DrmrPPVE.js} +1 -1
  83. package/dist/worker/console/static/assets/{sheet-workbook-kFN3yUBr.js → sheet-workbook-DCQgjy0Q.js} +1 -1
  84. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-Dk4XAK7C.js → sizeCapture-X5ZJPWSS-BLp8F5fC.js} +1 -1
  85. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Bz9B6UZ7.js → stateDiagram-OKZ733FA-5MNm447q.js} +1 -1
  86. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-gP-t-MQJ.js +1 -0
  87. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-qLEds93n.js → swimlanes-SLNWSIFB-Cs2RUkNq.js} +2 -2
  88. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-D6MJJUTV.js +8 -0
  89. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-C9rVFC0h.js → timeline-definition-Z64GVDOM-BoeTHoWc.js} +1 -1
  90. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-CoKJ9hU0.js → vennDiagram-T6HMQDX7-DFWej-Mm.js} +1 -1
  91. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-tHz_S7-L.js → wardleyDiagram-T6FBY63Y-BcD0_2m5.js} +1 -1
  92. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-DKzKYnvG.js → xychartDiagram-ELKLHX3M-y4PQYZiq.js} +1 -1
  93. package/dist/worker/console/static/index.html +2 -2
  94. package/dist/worker/console/static-src/markdown-incremental.js +138 -0
  95. package/dist/worker/console/static-src/operator-chat/automation-catalog-model.js +43 -0
  96. package/dist/worker/console/static-src/operator-chat/composer-drop.js +138 -0
  97. package/dist/worker/console/static-src/operator-chat/composer-image-paths.js +25 -5
  98. package/dist/worker/console/static-src/operator-chat/composer-image-preview.js +115 -0
  99. package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +44 -2
  100. package/dist/worker/console/static-src/operator-chat/composer-upload.js +115 -0
  101. package/dist/worker/console/static-src/operator-chat/gate-expiry.js +43 -0
  102. package/dist/worker/console/static-src/operator-chat/process-label.js +15 -2
  103. package/dist/worker/console/static-src/operator-chat/schedule-relative-time.js +54 -0
  104. package/dist/worker/console/static-src/operator-chat/schedule-rule-summary.js +213 -0
  105. package/dist/worker/console/static-src/operator-chat/tasks-model.js +4 -0
  106. package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +8 -0
  107. package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +12 -0
  108. package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +51 -0
  109. package/dist/worker/console/static-src/operator-chat/useChatStream.js +22 -2
  110. package/dist/worker/console/static-src/operator-chat/useChatThread.js +15 -1
  111. package/dist/worker/console/static-src/operator-chat/useComposer.js +290 -21
  112. package/dist/worker/console/static-src/operator-chat/useSessionAutomationCounts.js +98 -0
  113. package/dist/worker/console/static-src/pages/api-request-template.js +144 -0
  114. package/dist/worker/console/static-src/session-search-shortcut.js +38 -0
  115. package/dist/worker/console/version-notes-comparison.js +52 -0
  116. package/dist/worker/console/version-notes.js +16 -1
  117. package/dist/worker/console/workspace-context.js +10 -0
  118. package/dist/worker/observe/static/console-theme.css +50 -3
  119. package/dist/worker/observe/static/console-theme.js +86 -1
  120. package/dist/worker/scheduler/automation-across-workspaces.js +120 -0
  121. package/dist/workflows/dag/checkpoint.js +6 -1
  122. package/dist/workflows/dag/frontend-committed-facts.js +38 -5
  123. package/dist/workflows/dag/frontend-design-policy.js +22 -0
  124. package/dist/workflows/dag/frontend-implementation-contract.js +39 -12
  125. package/dist/workflows/dag/frontend-imported-run-artifacts.js +126 -0
  126. package/dist/workflows/dag/frontend-recovery-run.js +7 -110
  127. package/dist/workflows/dag/frontend-test-framework-adapters.js +14 -0
  128. package/dist/workflows/dag/frontend-verification-trace.js +20 -8
  129. package/dist/workflows/dag/frontend-writer-reuse.js +104 -0
  130. package/dist/workflows/dag/frontend-writer-status.js +0 -4
  131. package/dist/workflows/dag/hybrid/templates/frontend.js +15 -8
  132. package/dist/workflows/dag/init-hybrid.js +1 -1
  133. package/dist/workflows/dag/reconcile-run.js +11 -1
  134. package/dist/workflows/dag/recovery-lease.js +23 -0
  135. package/dist/workflows/dag/rerun-feedback.js +4 -2
  136. package/dist/workflows/dag/rerun-run.js +40 -0
  137. package/dist/workflows/dag/runner.js +11 -0
  138. package/dist/workflows/dag/terminal-status.js +2 -1
  139. package/docs/README.md +1 -0
  140. package/docs/operations/README.md +1 -0
  141. package/package.json +3 -3
  142. package/dist/worker/console/static/assets/channel-CBlJfald.js +0 -1
  143. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-mNUYCdDo.js +0 -1
  144. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-mNUYCdDo.js +0 -1
  145. package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +0 -1
  146. package/dist/worker/console/static/assets/main-Dwhb3ZRq.js +0 -645
  147. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BBRlxIq8.js +0 -1
  148. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CRBvOMCQ.js +0 -8
@@ -15,22 +15,15 @@ export const PI_DEFAULT_RESERVE_TOKENS = 16_384;
15
15
  * far more often than intended. A fixed conservative reservation avoids that.
16
16
  */
17
17
  export const DEFAULT_RESERVED_COMPLETION_TOKENS = 8_192;
18
- /** DSH defaults, adopted verbatim. See `compaction-basic/src/config.ts`. */
19
- export const DEFAULT_THRESHOLD_RATIO = 0.8;
20
- /*
21
- * 20,000 instead of DSH's 65,536.
22
- *
23
- * DSH's value is an absolute distance from the top, chosen for its large
24
- * windows. On a 150k window it costs 43.7% of the budget, so the `min()` term
25
- * that actually decides the trigger is the headroom, not `thresholdRatio`:
26
- * the line landed on 50.8% and the configured 80% never applied. At 20,000 the
27
- * ratio term wins again (trigger = 120,000 = 80.0%), which is what the ratio
28
- * field promises.
18
+ /**
19
+ * Fraction of the window at which compaction triggers.
29
20
  *
30
- * Still an absolute value on purpose: a deployment whose gateway rejects below
31
- * the declared window raises this to pull the trigger under the real ceiling.
21
+ * 0.85 rather than DSH's 0.8: the ratio is now the ONLY thing that decides the
22
+ * trigger, so it has to express what an operator actually wants. At 0.85 a 128K
23
+ * window compacts at 109K and a 150K window at 128K, which is the reading
24
+ * operators give the number.
32
25
  */
33
- export const DEFAULT_HEADROOM_TOKENS = 20_000;
26
+ export const DEFAULT_THRESHOLD_RATIO = 0.85;
34
27
  export const DEFAULT_RETAIN_RATIO = 0.16;
35
28
  export function parseCompactionPolicy(env = process.env) {
36
29
  const diagnostics = [];
@@ -40,9 +33,6 @@ export function parseCompactionPolicy(env = process.env) {
40
33
  const ratio = parseBoundedNumber(env.HARNESS_COMPACTION_THRESHOLD_RATIO, DEFAULT_THRESHOLD_RATIO, 0.05, 1);
41
34
  if (ratio.diagnostic)
42
35
  diagnostics.push(ratio.diagnostic);
43
- const headroom = parseBoundedNumber(env.HARNESS_COMPACTION_HEADROOM_TOKENS, DEFAULT_HEADROOM_TOKENS, 0, 10_000_000);
44
- if (headroom.diagnostic)
45
- diagnostics.push(headroom.diagnostic);
46
36
  const retain = parseBoundedNumber(env.HARNESS_COMPACTION_RETAIN_RATIO, DEFAULT_RETAIN_RATIO, 0.01, 0.99);
47
37
  if (retain.diagnostic)
48
38
  diagnostics.push(retain.diagnostic);
@@ -52,7 +42,6 @@ export function parseCompactionPolicy(env = process.env) {
52
42
  return {
53
43
  mode: modeResult.mode,
54
44
  thresholdRatio: ratio.value,
55
- headroomTokens: headroom.value,
56
45
  retainRatio: retain.value,
57
46
  reservedCompletionTokens: reserved.value,
58
47
  diagnostics,
@@ -64,9 +53,7 @@ export function parseCompactionPolicy(env = process.env) {
64
53
  * Mirrors DSH's `resolveCompactSpec`:
65
54
  *
66
55
  * messageBudget = contextWindow - reservedCompletion
67
- * pressureBudget = messageBudget - headroomTokens
68
- * thresholdTokens = min(contextWindow × thresholdRatio, pressureBudget)
69
- * retainTokens = messageBudget × retainRatio
56
+ * thresholdTokens = min(contextWindow × thresholdRatio, messageBudget)
70
57
  *
71
58
  * DSH throws when the window cannot support the policy, because it is a
72
59
  * library and the host can fix its configuration. The Console must keep the
@@ -99,19 +86,20 @@ export function resolveCompactSpec(contextWindow, policy) {
99
86
  diagnostics: ["reserved-completion-exhausts-window"],
100
87
  };
101
88
  }
102
- const pressureBudget = messageBudget - policy.headroomTokens;
103
- if (pressureBudget <= 0) {
104
- const thresholdTokens = Math.max(0, declared - PI_DEFAULT_RESERVE_TOKENS);
105
- return {
106
- thresholdTokens,
107
- retainTokens: Math.max(0, Math.floor(thresholdTokens * policy.retainRatio)),
108
- contextWindow: declared,
109
- messageBudgetTokens: messageBudget,
110
- fallback: true,
111
- diagnostics: ["headroom-exhausts-message-budget"],
112
- };
113
- }
114
- const thresholdTokens = Math.floor(Math.min(declared * policy.thresholdRatio, pressureBudget));
89
+ /*
90
+ * The ratio decides, bounded only by what the window can physically hold.
91
+ *
92
+ * thresholdTokens = min(contextWindow × thresholdRatio, messageBudget)
93
+ *
94
+ * There used to be a second subtraction here: an absolute `headroomTokens` taken
95
+ * off the message budget before the ratio applied. It made the ratio unreachable —
96
+ * a 128K window configured at 100% triggered at 48K because the default headroom
97
+ * was 65,536 — and it was redundant besides: `reservedCompletionTokens` already
98
+ * covers the output a summarization needs. Two knobs that fight over the same line,
99
+ * where the one an operator can reason about always lost, is not a configuration
100
+ * worth keeping. Only the ratio remains.
101
+ */
102
+ const thresholdTokens = Math.floor(Math.min(declared * policy.thresholdRatio, messageBudget));
115
103
  if (thresholdTokens <= 0) {
116
104
  return {
117
105
  thresholdTokens: 0,
@@ -1,5 +1,5 @@
1
1
  export { isContextOverflow, CONTEXT_OVERFLOW_PHRASES, OVERFLOW_FIXTURES, NORMALIZED_OVERFLOW_PREFIX, shouldRewriteAssistantOverflow, normalizeOverflowErrorMessage, buildGeneratedOverflowClassifierSource, } from "./overflow.js";
2
- export { parseCompactionPolicy, resolveCompactSpec, piReserveTokensFor, conservativeTokenEstimate, projectPromptPressure, applyProcessCompactionOverride, inMemoryCompactionSettings, PI_DEFAULT_RESERVE_TOKENS, DEFAULT_THRESHOLD_RATIO, DEFAULT_HEADROOM_TOKENS, DEFAULT_RETAIN_RATIO, DEFAULT_RESERVED_COMPLETION_TOKENS, } from "./compaction-policy.js";
2
+ export { parseCompactionPolicy, resolveCompactSpec, piReserveTokensFor, conservativeTokenEstimate, projectPromptPressure, applyProcessCompactionOverride, inMemoryCompactionSettings, PI_DEFAULT_RESERVE_TOKENS, DEFAULT_THRESHOLD_RATIO, DEFAULT_RETAIN_RATIO, DEFAULT_RESERVED_COMPLETION_TOKENS, } from "./compaction-policy.js";
3
3
  export { buildOverflowCheckpoint, normalizeCompactionPreparation, } from "./checkpoint.js";
4
4
  export { deriveCompactionAccounting, readCompactionAccounting, } from "./compaction-accounting.js";
5
5
  export { PI_TOOL_RESULT_PRUNE_MARKER, DEFAULT_PI_TOOL_RESULT_PRUNE_CONFIG, resolvePiToolResultPruneConfig, parsePiToolResultPruneConfig, piCodePointLength, prunePiToolResultMessages, } from "./tool-result-pruner.js";
@@ -404,8 +404,8 @@ const taskConfigObjectSchema = z.object({
404
404
  * default; raise to 2-3 for more tolerance of transient verify failures). */
405
405
  frontendRecovery: z
406
406
  .object({
407
- /** Frozen request quota across the original run and recovery lineage; not a model capacity. */
408
- maxProviderRequests: z.number().int().positive().optional(),
407
+ /** Task-lifetime request quota; null explicitly disables admission, omitted defaults to 1024. */
408
+ maxProviderRequests: z.number().int().positive().nullable().optional(),
409
409
  maxContinuations: z
410
410
  .number()
411
411
  .int()
@@ -781,7 +781,7 @@ async function prepareTaskSourceInExecution(input) {
781
781
  // A previously ordinary intake may only become frontend after deterministic
782
782
  // source classification. Admit its observed requests before further work;
783
783
  // dry-run must remain read-only.
784
- if (input.mode === "apply") {
784
+ if (input.mode === "apply" && existingTaskConfig?.frontendRecovery?.maxProviderRequests !== null) {
785
785
  await openTaskSourceProviderBudget({ repoRoot, taskId, maxProviderRequests: existingTaskConfig?.frontendRecovery?.maxProviderRequests ?? 1024 });
786
786
  }
787
787
  // An imported PRD is materialized under sourceIntegrity rather than copied
@@ -601,7 +601,7 @@ export async function runSemanticIntake(input) {
601
601
  const result = await observeSourceExecution({ repoRoot: input.repoRoot, taskId: input.taskId, taskKind: input.flags.taskKind ?? input.taskKind, phase: "semantic-intake", inputIdentity: { documents: input.documents, flags: input.flags, title: input.title } }, () => runSemanticIntakeInExecution(input));
602
602
  // Classification happens after the request. Admit only complete observed
603
603
  // usage, after its source execution has closed, if the result selects frontend.
604
- if (result.ok && result.draft.taskKind === "frontend-implementation" && input.fixtureAssistantText === undefined) {
604
+ if (result.ok && result.draft.taskKind === "frontend-implementation" && input.fixtureAssistantText === undefined && config.frontendRecovery?.maxProviderRequests !== null) {
605
605
  await openTaskSourceProviderBudget({ ...input, maxProviderRequests: config.frontendRecovery?.maxProviderRequests ?? 1024 });
606
606
  }
607
607
  return result;
@@ -681,7 +681,7 @@ async function runSemanticIntakeInExecution(input) {
681
681
  }
682
682
  const config = await loadTaskConfig(input.repoRoot, input.taskId);
683
683
  const taskKind = input.flags.taskKind ?? input.taskKind ?? config.taskKind;
684
- const reserveProviderRequest = taskKind === "frontend-implementation" ? await openTaskSourceProviderBudget({
684
+ const reserveProviderRequest = taskKind === "frontend-implementation" && config.frontendRecovery?.maxProviderRequests !== null ? await openTaskSourceProviderBudget({
685
685
  repoRoot: input.repoRoot, taskId: input.taskId,
686
686
  maxProviderRequests: config.frontendRecovery?.maxProviderRequests ?? 1024,
687
687
  }) : undefined;
@@ -435,6 +435,7 @@ export async function resolveProductionSourceFidelityPi(input) {
435
435
  if (effectiveTaskKind !== SOURCE_FIDELITY_TASK_KIND)
436
436
  return undefined;
437
437
  const config = await loadTaskConfig(input.repoRoot, input.taskId);
438
- const reserveProviderRequest = await openTaskSourceProviderBudget({ ...input, maxProviderRequests: config.frontendRecovery?.maxProviderRequests ?? 1024 });
438
+ const reserveProviderRequest = config.frontendRecovery?.maxProviderRequests === null ? undefined
439
+ : await openTaskSourceProviderBudget({ ...input, maxProviderRequests: config.frontendRecovery?.maxProviderRequests ?? 1024 });
439
440
  return createProductionSourceFidelityPi({ repoRoot: input.repoRoot, taskId: input.taskId, reserveProviderRequest });
440
441
  }
@@ -2,6 +2,23 @@ import { automationActionSchemas } from "../../shared/automation/actions.js";
2
2
  import { ScheduleError } from "../../shared/automation/time.js";
3
3
  import { scheduledGoalHash } from "../scheduler/scheduled-goal-store.js";
4
4
  import { getScheduledGoalBooking } from "./chat/scheduled-goal-booking.js";
5
+ /**
6
+ * The scope to use against a store that may belong to another workspace.
7
+ *
8
+ * `visible()` admits everything under the `workspace` scope and only the session's
9
+ * own tasks under `session`. When a task was located in a different repository,
10
+ * the caller's session does not live there, so a `session` scope would hide the
11
+ * very task we just found. Crossing repositories therefore reads under
12
+ * `workspace`; staying inside the caller's own store keeps whatever scope the
13
+ * caller chose.
14
+ *
15
+ * @param callerScope - the scope the caller asked with.
16
+ * @param owner - the resolved store, when a different workspace owns it.
17
+ * @returns the scope to read with.
18
+ */
19
+ function scopeFor(callerScope, owner) {
20
+ return owner === undefined ? callerScope : { kind: "workspace" };
21
+ }
5
22
  /** Typed service shared by root-model tools and the authenticated workspace UI.
6
23
  * No request parameter can select owner, workspace, repository or confirmation. */
7
24
  export async function executeAutomationAction(action, input, deps) {
@@ -20,12 +37,32 @@ export async function executeAutomationAction(action, input, deps) {
20
37
  if (action === "schedule_list") {
21
38
  const request = automationActionSchemas.schedule_list.parse(input);
22
39
  if (request.id) {
23
- const task = await store.getTask(scope, request.id);
24
- return { task, history: await store.history(scope, request.id, request.cursor, request.limit),
25
- ...(task.executionKind === "workflow-goal" ? { booking: await getScheduledGoalBooking(task.id, store) } : {}) };
40
+ /*
41
+ * The detail may belong to any workspace in the list, so the store is
42
+ * resolved from the id first. Falling back to the caller's store keeps the
43
+ * single-repository behaviour when nothing is registered for the lookup.
44
+ */
45
+ const owner = deps.storeForTask ? await deps.storeForTask(request.id) : undefined;
46
+ if (deps.storeForTask && !owner)
47
+ throw new ScheduleError("schedule_not_found");
48
+ const readStore = owner ?? store;
49
+ const task = await readStore.getTask(scopeFor(scope, owner), request.id);
50
+ return { task, history: await readStore.history(scopeFor(scope, owner), request.id, request.cursor, request.limit),
51
+ ...(task.executionKind === "workflow-goal" ? { booking: await getScheduledGoalBooking(task.id, readStore) } : {}) };
26
52
  }
27
53
  const query = request.search?.toLocaleLowerCase() ?? "";
28
- const all = await store.listTasks(scope);
54
+ /*
55
+ * The list spans every registered workspace.
56
+ *
57
+ * Each task is stored in its own repository's ledger, so a single-store read
58
+ * only answers for one workspace — which is why switching workspace used to
59
+ * hide the others' tasks entirely. The aggregation names the workspace on
60
+ * every row instead. A workspace whose ledger cannot be read is reported
61
+ * rather than dropped silently.
62
+ */
63
+ const across = deps.listAcrossWorkspaces ? await deps.listAcrossWorkspaces() : undefined;
64
+ const all = across ? across.tasks : await store.listTasks(scope);
65
+ const failedWorkspaceIds = across?.failedWorkspaceIds.length ? [...across.failedWorkspaceIds] : undefined;
29
66
  const reminderCounts = new Map();
30
67
  for (const task of all)
31
68
  if (task.executionKind === "pi-reminder" && task.view === "enabled")
@@ -34,18 +71,36 @@ export async function executeAutomationAction(action, input, deps) {
34
71
  const tasks = all.filter(task => (!request.view || request.view === "all" || task.view === request.view)
35
72
  && (!query || [task.title, task.prompt, task.id, task.owner.sessionId].some(value => value.toLocaleLowerCase().includes(query))));
36
73
  const start = request.cursor ?? 0, limit = request.limit ?? 30;
37
- return { tasks: tasks.slice(start, start + limit), total: tasks.length, counts, activeReminders: Object.fromEntries(reminderCounts), ...(start + limit < tasks.length ? { nextCursor: start + limit } : {}) };
74
+ return {
75
+ tasks: tasks.slice(start, start + limit), total: tasks.length, counts,
76
+ activeReminders: Object.fromEntries(reminderCounts),
77
+ ...(failedWorkspaceIds ? { failedWorkspaceIds } : {}),
78
+ ...(start + limit < tasks.length ? { nextCursor: start + limit } : {}),
79
+ };
38
80
  }
39
81
  if (action === "schedule_update") {
40
82
  const request = automationActionSchemas.schedule_update.parse(input);
41
- const result = await store.updateTask(scope, request.id, request.expectedRecord, request.changes);
83
+ /*
84
+ * Writes are resolved the same way reads are: the id decides the ledger. A
85
+ * task listed from another workspace has to be editable there, otherwise the
86
+ * row is clickable and then refuses.
87
+ */
88
+ const owner = deps.storeForTask ? await deps.storeForTask(request.id) : undefined;
89
+ if (deps.storeForTask && !owner)
90
+ throw new ScheduleError("schedule_not_found");
91
+ const writeStore = owner ?? store;
92
+ const result = await writeStore.updateTask(scopeFor(scope, owner), request.id, request.expectedRecord, request.changes);
42
93
  deps.onChanged?.();
43
94
  return result;
44
95
  }
45
96
  if (action === "schedule_delete") {
46
97
  const request = automationActionSchemas.schedule_delete.parse(input);
47
98
  const confirmed = deps.deleteConsent?.id === request.id && deps.deleteConsent.expectedHash === scheduledGoalHash(request.expectedRecord);
48
- const result = await store.deleteTask(scope, request.id, request.expectedRecord, confirmed);
99
+ const owner = deps.storeForTask ? await deps.storeForTask(request.id) : undefined;
100
+ if (deps.storeForTask && !owner)
101
+ throw new ScheduleError("schedule_not_found");
102
+ const writeStore = owner ?? store;
103
+ const result = await writeStore.deleteTask(scopeFor(scope, owner), request.id, request.expectedRecord, confirmed);
49
104
  deps.onChanged?.();
50
105
  return result;
51
106
  }
@@ -1,4 +1,6 @@
1
+ import { createHash } from "node:crypto";
1
2
  import { resolveRequestTemplate } from "./api-workbench-templates.js";
3
+ import { projectRequestBody, projectResponses } from "./api-workbench-schema.js";
2
4
  import { ApiWorkbenchCollections } from "./api-workbench-collections.js";
3
5
  import { parseAssertions, evaluateAssertions, parseExtractions, extractScalars } from "./api-workbench-assertions.js";
4
6
  import { STATUS_CODES } from "node:http";
@@ -14,7 +16,7 @@ export { ApiWorkbenchCoreError, parseEnvironmentsPayload } from "./api-workbench
14
16
  * workspace-owned history, durable environments and credential references.
15
17
  * HTTP and model tools share the same injected service.
16
18
  */
17
- import { open, readFile, stat } from "node:fs/promises";
19
+ import { open, readFile, readdir, stat } from "node:fs/promises";
18
20
  import path from "node:path";
19
21
  import { walkRepoFiles } from "./repo-walk.js";
20
22
  import { parse as parseYaml } from "yaml";
@@ -119,12 +121,24 @@ function collectParameters(operation) {
119
121
  if (location !== "path" && location !== "query" && location !== "header" && location !== "cookie")
120
122
  continue;
121
123
  const schema = record.schema && typeof record.schema === "object" ? record.schema : undefined;
124
+ /*
125
+ * The example travels with the parameter so the panel can prefill it.
126
+ *
127
+ * `@Parameter(example = "v1")` lands on the parameter object; a plain
128
+ * `@Schema(example = …)` on the parameter's schema. Both are checked, because
129
+ * springdoc emits whichever the author wrote.
130
+ */
131
+ const example = typeof record.example === "string" ? record.example
132
+ : schema !== undefined && typeof schema.example === "string" ? schema.example
133
+ : schema !== undefined && schema.example !== undefined ? JSON.stringify(schema.example)
134
+ : undefined;
122
135
  parameters.push({
123
136
  name,
124
137
  in: location,
125
138
  required: record.required === true,
126
139
  ...(schema && typeof schema.type === "string" ? { type: schema.type } : {}),
127
140
  ...(typeof record.description === "string" ? { description: record.description } : {}),
141
+ ...(example !== undefined && example !== "" ? { example } : {}),
128
142
  });
129
143
  }
130
144
  return parameters;
@@ -145,6 +159,17 @@ function endpointsFromSpec(spec, specId) {
145
159
  continue;
146
160
  const operation = rawOperation;
147
161
  const summary = typeof operation.summary === "string" ? operation.summary : typeof operation.description === "string" ? operation.description.split("\n")[0] : undefined;
162
+ /*
163
+ * The body half comes from the document's own components.
164
+ *
165
+ * springdoc reflects over the Java type system, so field types, required
166
+ * flags, descriptions, examples and ranges are already resolved here. A
167
+ * source-level scan cannot reconstruct them, which is why a Spring project
168
+ * is worth the cost of generating a document rather than parsing its code.
169
+ */
170
+ const components = specComponents(spec);
171
+ const requestBody = projectRequestBody(operation, components);
172
+ const responses = projectResponses(operation, components);
148
173
  endpoints.push({
149
174
  id: endpointId(specId, method, endpointPath),
150
175
  specId,
@@ -153,6 +178,8 @@ function endpointsFromSpec(spec, specId) {
153
178
  ...(summary ? { summary: summary.slice(0, 200) } : {}),
154
179
  ...(typeof operation.operationId === "string" ? { operationId: operation.operationId } : {}),
155
180
  parameters: collectParameters(operation),
181
+ ...(requestBody ? { requestBody } : {}),
182
+ ...(responses.length > 0 ? { responses } : {}),
156
183
  });
157
184
  if (endpoints.length >= MAX_ENDPOINTS_PER_SPEC)
158
185
  return endpoints;
@@ -160,6 +187,29 @@ function endpointsFromSpec(spec, specId) {
160
187
  }
161
188
  return endpoints;
162
189
  }
190
+ /**
191
+ * The document's reusable schemas.
192
+ *
193
+ * OpenAPI 3 keeps them under `components.schemas`; Swagger 2 called the same map
194
+ * `definitions`. Both shapes appear in the wild, so both are read.
195
+ *
196
+ * @param spec - the parsed document.
197
+ * @returns the schema map, or undefined when the document defines none.
198
+ */
199
+ function specComponents(spec) {
200
+ const components = spec.components;
201
+ if (components !== null && typeof components === "object" && !Array.isArray(components)) {
202
+ const schemas = components.schemas;
203
+ if (schemas !== null && typeof schemas === "object" && !Array.isArray(schemas)) {
204
+ return schemas;
205
+ }
206
+ }
207
+ const definitions = spec.definitions;
208
+ if (definitions !== null && typeof definitions === "object" && !Array.isArray(definitions)) {
209
+ return definitions;
210
+ }
211
+ return undefined;
212
+ }
163
213
  function specInfo(spec) {
164
214
  const info = spec.info;
165
215
  if (!info || typeof info !== "object" || Array.isArray(info))
@@ -369,6 +419,44 @@ function isCodeScanEligible(repoRelative) {
369
419
  return false;
370
420
  return true;
371
421
  }
422
+ /**
423
+ * A cheap digest of everything the scan would read.
424
+ *
425
+ * The panel scans once when it mounts, so an endpoint added in the editor stays
426
+ * invisible until someone presses 重新扫描 — while the model's tools, which rescan on
427
+ * every call, see it immediately. This is what lets the panel notice on its own.
428
+ *
429
+ * `path:size:mtime` only — no file contents are read. Sizes and mtimes change on every
430
+ * edit an editor makes, including ones that leave the length equal, and stat is orders
431
+ * of magnitude cheaper than the parse that follows.
432
+ *
433
+ * It covers exactly the files the scan consumes, so a change to an unrelated file (a
434
+ * README, a lock file, a test) does not trigger a rescan.
435
+ *
436
+ * @param repoRoot - workspace root.
437
+ * @returns a stable hex digest, or an empty string when the walk failed.
438
+ */
439
+ export async function computeScanFingerprint(repoRoot) {
440
+ const walked = await walkRepoFiles(repoRoot, { maxFiles: 20000 });
441
+ const parts = [];
442
+ for (const file of walked) {
443
+ const relative = file.repoRelative.replace(/\\/g, "/");
444
+ // Same eligibility the scan applies: spec files by name, code routes by rule.
445
+ if (!isSpecBasename(relative) && !isCodeScanEligible(relative))
446
+ continue;
447
+ try {
448
+ const info = await stat(file.abs);
449
+ parts.push(`${relative}:${info.size}:${Math.floor(info.mtimeMs)}`);
450
+ }
451
+ catch {
452
+ // A file that vanished mid-walk will show up as absent on the next check.
453
+ parts.push(`${relative}:missing`);
454
+ }
455
+ }
456
+ // Sorted so two walks over the same tree cannot disagree on order.
457
+ parts.sort();
458
+ return createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 32);
459
+ }
372
460
  function codeScanPriority(repoRelative) {
373
461
  const normalized = repoRelative.replace(/\\/g, "/").toLowerCase();
374
462
  const base = normalized.split("/").pop() ?? "";
@@ -418,8 +506,23 @@ async function scanCodeRoutes(walked) {
418
506
  }));
419
507
  return { endpoints, filesRead };
420
508
  }
421
- /** Shared scan entry: repo spec discovery + code-route scan. Read-only. */
422
- export async function scanSpecsSnapshot(repoRoot) {
509
+ /**
510
+ * Shared scan entry: repo spec discovery + code-route scan + generated documents.
511
+ *
512
+ * `generatedDir` holds OpenAPI documents produced by running a Spring project
513
+ * (`api-workbench-spring.ts`). They are read from the Console's own storage rather
514
+ * than the repository, because the file is derived and regenerable — writing into
515
+ * the user's source tree is not this feature's call to make.
516
+ *
517
+ * Generated documents sort first: when a Spring project supplies a document, its
518
+ * reflection-accurate paths should be what the panel shows, with the static scan
519
+ * remaining as the fallback it was meant to be.
520
+ *
521
+ * @param repoRoot - workspace root.
522
+ * @param options - optional generated-document directory.
523
+ * @returns specs, scan statistics, and the scan time.
524
+ */
525
+ export async function scanSpecsSnapshot(repoRoot, options = {}) {
423
526
  const stats = { ...EMPTY_SCAN_STATS };
424
527
  const walked = await walkRepoFiles(repoRoot, { maxFiles: 20000 });
425
528
  stats.walkTruncated = walked.length >= 20000;
@@ -441,6 +544,26 @@ export async function scanSpecsSnapshot(repoRoot) {
441
544
  stats.matchedByContent = probed.length;
442
545
  const specFiles = [...byName, ...probed].slice(0, MAX_SPEC_CANDIDATES_PER_SCAN);
443
546
  const specs = await Promise.all(specFiles.map((file) => parseSpecFile(file.abs, file.repoRelative, specFileFormat(file.repoRelative))));
547
+ /*
548
+ * Documents produced by running a Spring project come first.
549
+ *
550
+ * They carry the request and response schemas that springdoc resolved from the
551
+ * Java type system; the static scan below stays as the fallback for projects that
552
+ * cannot be built or run.
553
+ */
554
+ if (options.generatedDir !== undefined) {
555
+ try {
556
+ const names = (await readdir(options.generatedDir)).filter((name) => name.endsWith(".json")).sort();
557
+ const generated = await Promise.all(names.slice(0, 12).map(async (name) => {
558
+ const abs = path.join(options.generatedDir, name);
559
+ return parseSpecFile(abs, `generated/${name}`, "json");
560
+ }));
561
+ specs.unshift(...generated.filter((spec) => spec.endpoints.length > 0));
562
+ }
563
+ catch {
564
+ // No generated directory yet is the normal first-run case.
565
+ }
566
+ }
444
567
  const codeScan = await scanCodeRoutes(walked);
445
568
  stats.codeEndpoints = codeScan.endpoints.length;
446
569
  stats.codeFiles = codeScan.filesRead;
@@ -454,7 +577,11 @@ export async function scanSpecsSnapshot(repoRoot) {
454
577
  endpoints: codeScan.endpoints,
455
578
  });
456
579
  }
457
- return { specs, stats, scannedAt: new Date().toISOString() };
580
+ /*
581
+ * The fingerprint travels with the scan so a later cheap check can tell whether
582
+ * anything this read has changed.
583
+ */
584
+ return { specs, stats, scannedAt: new Date().toISOString(), fingerprint: await computeScanFingerprint(repoRoot) };
458
585
  }
459
586
  export function parseQueryParams(raw) {
460
587
  if (raw === undefined)