@tea-agent/loop-agent 0.35.0 → 0.35.1-beta.0

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 (152) hide show
  1. package/AGENTS.md +108 -108
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +165 -165
  4. package/bin/agent-worker.js +0 -0
  5. package/bin/loop-agent.js +21 -21
  6. package/dist/application/task-lifecycle/advance.js +1 -0
  7. package/dist/commands/cursor-prompt.js +6 -6
  8. package/dist/commands/init-upgrade.js +351 -19
  9. package/dist/commands/init.js +14 -67
  10. package/dist/commands/loop-benchmark.js +11 -11
  11. package/dist/commands/pi-reuse-benchmark.js +16 -16
  12. package/dist/commands/run-dag-progress.js +14 -0
  13. package/dist/commands/task-advance.js +33 -3
  14. package/dist/shared/operator/capabilities.js +38 -1
  15. package/dist/sidecars/cursor-prompt/executor.js +1 -1
  16. package/dist/worker/console/chat/pi-runtime.js +41 -25
  17. package/dist/worker/console/chat/routes.js +27 -4
  18. package/dist/worker/console/operation-runner.js +24 -0
  19. package/dist/worker/console/operation-wait.js +241 -0
  20. package/dist/worker/console/operator-actions.js +58 -0
  21. package/dist/worker/console/static/assets/{index-hJqCPs_g.css → index-Dups4sSM.css} +1 -1
  22. package/dist/worker/console/static/assets/index-SjjjZnV3.js +56 -0
  23. package/dist/worker/console/static/index.html +2 -2
  24. package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +141 -0
  25. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +13 -2
  26. package/dist/worker/console/static-src/operator-chat/useComposer.js +30 -7
  27. package/dist/worker/observe/static/copy.js +67 -67
  28. package/dist/worker/observe/static/dag-layout.d.ts +36 -36
  29. package/dist/worker/observe/static/dom.js +220 -220
  30. package/dist/worker/observe/static/relations.js +133 -133
  31. package/dist/worker/observe/static/run-processing.js +148 -148
  32. package/dist/worker/observe/static/views/batch.js +227 -227
  33. package/dist/worker/observe/static/views/failures.js +143 -143
  34. package/dist/worker/observe/static/views/feature.js +492 -492
  35. package/dist/worker/observe/static/views/run.js +453 -453
  36. package/dist/worker/observe/static/views/shell.js +7 -7
  37. package/dist/worker/observe/static/views/timeline.js +163 -163
  38. package/dist/workflows/dag/canvas-observer.js +275 -275
  39. package/docs/architecture/evolution.md +73 -73
  40. package/docs/architecture/system-overview.md +100 -100
  41. package/docs/architecture/worker-and-feature.md +122 -122
  42. package/docs/skills/README.md +7 -7
  43. package/docs/templates/adr.md +60 -60
  44. package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
  45. package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
  46. package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
  47. package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
  48. package/docs/templates/agent-dag-report.schema.json +473 -473
  49. package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
  50. package/docs/templates/backend-test-result.schema.json +99 -99
  51. package/docs/templates/evaluation/agents-map-slim-v1.md +87 -87
  52. package/docs/templates/evaluation/agents-map-verbose-v0.md +153 -153
  53. package/docs/templates/feature-spec.md +53 -53
  54. package/docs/templates/frontend-design-contract.md +42 -42
  55. package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -17
  56. package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -16
  57. package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -16
  58. package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -16
  59. package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -16
  60. package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -16
  61. package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -21
  62. package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -29
  63. package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -28
  64. package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -28
  65. package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -29
  66. package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -27
  67. package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -28
  68. package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -28
  69. package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -27
  70. package/docs/templates/frontend-eval/metrics.md +138 -138
  71. package/docs/templates/frontend-eval/smoke-targets.md +53 -53
  72. package/docs/templates/frontend-task-constraints.md +35 -35
  73. package/docs/templates/frontend-task-requirement.md +70 -70
  74. package/docs/templates/init-evolution-review.md +35 -35
  75. package/docs/templates/init-managed-agents.md +156 -154
  76. package/docs/templates/interactive-ui-round2-experiment.md +66 -66
  77. package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -118
  78. package/docs/templates/knowledge-sync-dag.json +178 -178
  79. package/docs/templates/knowledge-sync-draft.schema.json +71 -71
  80. package/docs/templates/product-line/closeout.yaml +9 -9
  81. package/docs/templates/product-line/design.md +13 -13
  82. package/docs/templates/product-line/links.md +10 -10
  83. package/docs/templates/product-line/requirement.md +17 -17
  84. package/docs/templates/product-line/test-plan.md +7 -7
  85. package/docs/templates/project-start-checklist.md +9 -9
  86. package/docs/templates/qa-report.md +48 -48
  87. package/docs/templates/sprint-contract.md +29 -29
  88. package/docs/templates/worker-dogfood-evidence.md +80 -80
  89. package/docs/templates/worker-dogfood-setup.md +68 -68
  90. package/harness.json +5 -2
  91. package/package.json +1 -1
  92. package/scripts/kb-bootstrap-init-skeleton.sh +0 -0
  93. package/scripts/kb-graph-incremental-prepare.mjs +0 -0
  94. package/scripts/kb-graph-materialize.mjs +105 -105
  95. package/scripts/kb-graph-promote.mjs +164 -164
  96. package/scripts/kb-query.mjs +554 -554
  97. package/skills/agent-worker/SKILL.md +48 -48
  98. package/skills/agent-worker/references/agent-worker-operator.md +159 -159
  99. package/skills/ai-engineering-context/SKILL.md +48 -48
  100. package/skills/analyze-product-dependencies/scripts/test-validators.mjs +0 -0
  101. package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +0 -0
  102. package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +0 -0
  103. package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +0 -0
  104. package/skills/analyze-product-requirements/scripts/compute-source-identity.mjs +0 -0
  105. package/skills/analyze-product-requirements/scripts/test-validators.mjs +0 -0
  106. package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +0 -0
  107. package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +0 -0
  108. package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +0 -0
  109. package/skills/browser-tools/browser-content.js +103 -103
  110. package/skills/browser-tools/browser-cookies.js +35 -35
  111. package/skills/browser-tools/browser-eval.js +53 -53
  112. package/skills/browser-tools/browser-hn-scraper.js +108 -108
  113. package/skills/browser-tools/browser-nav.js +44 -44
  114. package/skills/browser-tools/browser-pick.js +162 -162
  115. package/skills/browser-tools/browser-screenshot.js +34 -34
  116. package/skills/browser-tools/browser-start.js +86 -86
  117. package/skills/browser-tools/package-lock.json +2556 -2556
  118. package/skills/browser-tools/package.json +19 -19
  119. package/skills/code-review-core/SKILL.md +20 -20
  120. package/skills/codebase-scout/SKILL.md +19 -19
  121. package/skills/grill-me/SKILL.md +10 -10
  122. package/skills/local-jacoco-coverage/scripts/run-coverage-analysis.sh +0 -0
  123. package/skills/local-jacoco-coverage/scripts/start-jacoco-agent.sh +0 -0
  124. package/skills/loop-agent/SKILL.md +1 -0
  125. package/skills/loop-agent/references/command-reference.md +641 -639
  126. package/skills/loop-agent/references/docs-converge.md +126 -126
  127. package/skills/loop-agent/references/learned/README.md +21 -21
  128. package/skills/loop-agent/references/pi-prompt.md +23 -23
  129. package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -84
  130. package/skills/playwright-cli/references/element-attributes.md +23 -23
  131. package/skills/playwright-cli/references/playwright-tests.md +39 -39
  132. package/skills/playwright-cli/references/request-mocking.md +87 -87
  133. package/skills/playwright-cli/references/running-code.md +241 -241
  134. package/skills/playwright-cli/references/session-management.md +225 -225
  135. package/skills/playwright-cli/references/storage-state.md +275 -275
  136. package/skills/playwright-cli/references/test-generation.md +433 -433
  137. package/skills/requesting-code-review/SKILL.md +101 -101
  138. package/skills/requesting-code-review/code-reviewer.md +168 -168
  139. package/skills/systematic-debugging/CREATION-LOG.md +119 -119
  140. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
  141. package/skills/systematic-debugging/condition-based-waiting.md +115 -115
  142. package/skills/systematic-debugging/defense-in-depth.md +122 -122
  143. package/skills/systematic-debugging/find-polluter.sh +63 -63
  144. package/skills/systematic-debugging/root-cause-tracing.md +169 -169
  145. package/skills/systematic-debugging/test-academic.md +14 -14
  146. package/skills/systematic-debugging/test-pressure-1.md +58 -58
  147. package/skills/systematic-debugging/test-pressure-2.md +68 -68
  148. package/skills/systematic-debugging/test-pressure-3.md +69 -69
  149. package/skills/using-git-worktrees/SKILL.md +215 -215
  150. package/skills/verification-before-completion/SKILL.md +154 -154
  151. package/skills/webapp-testing/SKILL.md +19 -19
  152. package/dist/worker/console/static/assets/index-fsjzREob.js +0 -56
@@ -0,0 +1,241 @@
1
+ import { projectOperationEventSummary, projectOperationForChat, } from "./chat/chat-event-store.js";
2
+ import { isTerminalOperationState, } from "./operation-store.js";
3
+ /**
4
+ * P2: read-only event-driven long poll on the canonical operation event ring
5
+ * (2026-08-13 Operator Chat long-run supervision). Server contract bounds:
6
+ * the model-facing `maxWaitMs` is clamped to [minWaitMs, maxWaitMsBound];
7
+ * defaults allow the 60–180s model supervision cadence and tests may inject
8
+ * short bounds.
9
+ */
10
+ export const DEFAULT_OPERATION_WAIT_MIN_MS = 60_000;
11
+ export const DEFAULT_OPERATION_WAIT_MAX_MS = 180_000;
12
+ export class OperationWaitError extends Error {
13
+ code;
14
+ constructor(code, message) {
15
+ super(message);
16
+ this.code = code;
17
+ this.name = "OperationWaitError";
18
+ }
19
+ }
20
+ function isFocusedOperation(operation) {
21
+ return (isTerminalOperationState(operation.state) ||
22
+ operation.state === "needs-reconcile");
23
+ }
24
+ function settledSummary(input) {
25
+ const projectedEvents = input.newEvents.length > 0
26
+ ? input.newEvents.map(projectOperationEventSummary)
27
+ : [];
28
+ const nextSeq = input.newEvents.length > 0
29
+ ? input.newEvents[input.newEvents.length - 1].seq
30
+ : input.afterSeq;
31
+ return {
32
+ operationId: input.operationId,
33
+ state: input.operation.state,
34
+ changed: input.changed,
35
+ timedOut: input.timedOut,
36
+ events: projectedEvents,
37
+ nextSeq,
38
+ operation: projectOperationForChat(input.operation),
39
+ };
40
+ }
41
+ /**
42
+ * Deterministic read-only wait over the canonical operation event stream
43
+ * (AC-003 / AC-004). Completion paths:
44
+ * - existing events (seq > afterSeq) → immediate (changed: true);
45
+ * - operation terminal/needs-reconcile with unconsumed events → immediate summary (changed: true);
46
+ * - operation terminal/needs-reconcile with no new events → immediate summary (changed: false);
47
+ * - EVENT_CURSOR_EXPIRED when the cursor fell out of the retained ring;
48
+ * - first subscribed event/state change → immediate settle;
49
+ * - maxWaitMs elapsed with no change → timedOut: true summary (not a failure).
50
+ *
51
+ * Race safety: the listener is registered BEFORE listFrom, closing the
52
+ * listFrom/subscribe gap; every path settles exactly once through a guarded
53
+ * `finish`, and listener + timer are always cleaned up on settle.
54
+ */
55
+ export async function waitForOperationChange(input) {
56
+ const operationId = input.operationId?.trim();
57
+ if (!operationId) {
58
+ throw new OperationWaitError("INVALID_INPUT", "operationId is required");
59
+ }
60
+ if (!Number.isInteger(input.afterSeq) || input.afterSeq < 0) {
61
+ throw new OperationWaitError("INVALID_INPUT", "afterSeq must be a non-negative integer");
62
+ }
63
+ const minWaitMs = input.minWaitMs ?? DEFAULT_OPERATION_WAIT_MIN_MS;
64
+ const maxWaitMsBound = input.maxWaitMsBound ?? DEFAULT_OPERATION_WAIT_MAX_MS;
65
+ if (!Number.isFinite(minWaitMs) ||
66
+ !Number.isFinite(maxWaitMsBound) ||
67
+ minWaitMs < 0 ||
68
+ maxWaitMsBound < minWaitMs) {
69
+ throw new OperationWaitError("INVALID_INPUT", "invalid wait bounds");
70
+ }
71
+ const rawMaxWaitMs = input.maxWaitMs ?? maxWaitMsBound;
72
+ if (!Number.isFinite(rawMaxWaitMs) || rawMaxWaitMs < 0) {
73
+ throw new OperationWaitError("INVALID_INPUT", "maxWaitMs must be a non-negative number");
74
+ }
75
+ const maxWaitMs = Math.max(minWaitMs, Math.min(maxWaitMsBound, Math.floor(rawMaxWaitMs)));
76
+ const afterSeq = input.afterSeq;
77
+ const operation = await input.operations.get(operationId);
78
+ if (!operation) {
79
+ throw new OperationWaitError("NOT_FOUND", `operation not found: ${operationId}`);
80
+ }
81
+ const events = input.events;
82
+ if (isFocusedOperation(operation)) {
83
+ // Flush unconsumed events before the terminal summary (AC-002): the
84
+ // caller's cursor must advance past every retained canonical event.
85
+ const listed = events.listFrom(operationId, afterSeq);
86
+ if ("error" in listed) {
87
+ throw new OperationWaitError("EVENT_CURSOR_EXPIRED", "event cursor expired; re-read operation snapshot");
88
+ }
89
+ if (listed.events.length > 0) {
90
+ return settledSummary({
91
+ operationId,
92
+ operation,
93
+ afterSeq,
94
+ changed: true,
95
+ timedOut: false,
96
+ newEvents: listed.events,
97
+ });
98
+ }
99
+ return settledSummary({
100
+ operationId,
101
+ operation,
102
+ afterSeq,
103
+ changed: false,
104
+ timedOut: false,
105
+ newEvents: [],
106
+ });
107
+ }
108
+ return new Promise((resolve, reject) => {
109
+ let settled = false;
110
+ let timer;
111
+ let unsubscribe;
112
+ const cleanup = () => {
113
+ if (timer !== undefined) {
114
+ clearTimeout(timer);
115
+ timer = undefined;
116
+ }
117
+ if (unsubscribe) {
118
+ unsubscribe();
119
+ unsubscribe = undefined;
120
+ }
121
+ };
122
+ const finish = (result) => {
123
+ if (settled)
124
+ return;
125
+ settled = true;
126
+ cleanup();
127
+ if (result instanceof OperationWaitError)
128
+ reject(result);
129
+ else
130
+ resolve(result);
131
+ };
132
+ const settleWithEvent = (event) => {
133
+ // Future-cursor guard (AC-003): events at or below the caller's
134
+ // afterSeq are already consumed and must not settle this wait.
135
+ if (event.seq <= afterSeq)
136
+ return;
137
+ // Listener path: async re-read of the operation for a fresh summary.
138
+ void (async () => {
139
+ try {
140
+ const current = await input.operations.get(operationId);
141
+ finish(settledSummary({
142
+ operationId,
143
+ operation: current ?? operation,
144
+ afterSeq,
145
+ changed: true,
146
+ timedOut: false,
147
+ newEvents: [event],
148
+ }));
149
+ }
150
+ catch (error) {
151
+ finish(error instanceof OperationWaitError
152
+ ? error
153
+ : new OperationWaitError("INVALID_INPUT", error instanceof Error ? error.message : String(error)));
154
+ }
155
+ })();
156
+ };
157
+ // Terminal recheck before subscribing: events landing during this await
158
+ // are still in the ring and are caught by listFrom below.
159
+ void (async () => {
160
+ try {
161
+ const current = await input.operations.get(operationId);
162
+ if (current && isFocusedOperation(current)) {
163
+ // Same terminal flush as the initial path (AC-002): events
164
+ // landing during the await are still in the retained ring.
165
+ const listed = events.listFrom(operationId, afterSeq);
166
+ if ("error" in listed) {
167
+ finish(new OperationWaitError("EVENT_CURSOR_EXPIRED", "event cursor expired; re-read operation snapshot"));
168
+ return;
169
+ }
170
+ if (listed.events.length > 0) {
171
+ finish(settledSummary({
172
+ operationId,
173
+ operation: current,
174
+ afterSeq,
175
+ changed: true,
176
+ timedOut: false,
177
+ newEvents: listed.events,
178
+ }));
179
+ return;
180
+ }
181
+ finish(settledSummary({
182
+ operationId,
183
+ operation: current,
184
+ afterSeq,
185
+ changed: false,
186
+ timedOut: false,
187
+ newEvents: [],
188
+ }));
189
+ return;
190
+ }
191
+ // Subscribe BEFORE listFrom: any event appended after this point
192
+ // reaches the listener, closing the listFrom/subscribe race.
193
+ unsubscribe = events.subscribe(operationId, settleWithEvent);
194
+ const listed = events.listFrom(operationId, afterSeq);
195
+ if ("error" in listed) {
196
+ finish(new OperationWaitError("EVENT_CURSOR_EXPIRED", "event cursor expired; re-read operation snapshot"));
197
+ return;
198
+ }
199
+ if (listed.events.length > 0) {
200
+ finish(settledSummary({
201
+ operationId,
202
+ operation: current ?? operation,
203
+ afterSeq,
204
+ changed: true,
205
+ timedOut: false,
206
+ newEvents: listed.events,
207
+ }));
208
+ return;
209
+ }
210
+ // No events: arm the bounded wait; the listener settles on the
211
+ // first new event/state change, the timer settles on timeout.
212
+ timer = setTimeout(() => {
213
+ void (async () => {
214
+ try {
215
+ const latest = await input.operations.get(operationId);
216
+ finish(settledSummary({
217
+ operationId,
218
+ operation: latest ?? operation,
219
+ afterSeq,
220
+ changed: false,
221
+ timedOut: true,
222
+ newEvents: [],
223
+ }));
224
+ }
225
+ catch (error) {
226
+ finish(error instanceof OperationWaitError
227
+ ? error
228
+ : new OperationWaitError("INVALID_INPUT", error instanceof Error ? error.message : String(error)));
229
+ }
230
+ })();
231
+ }, maxWaitMs);
232
+ timer.unref?.();
233
+ }
234
+ catch (error) {
235
+ finish(error instanceof OperationWaitError
236
+ ? error
237
+ : new OperationWaitError("INVALID_INPUT", error instanceof Error ? error.message : String(error)));
238
+ }
239
+ })();
240
+ });
241
+ }
@@ -19,6 +19,7 @@ import { deriveTaskIdentityFromPrd, nextTaskIdRevision, } from "./prd-identity.j
19
19
  import { appendEngineeringCliArgs, buildDraftFromTaskIntake, parseEngineeringBoundaryFromParams, } from "./prd-intake-bridge.js";
20
20
  import { resolveSiblingAgentWorkerBin } from "./sibling-controller.js";
21
21
  import { projectOperationEventSummary, projectOperationForChat, } from "./chat/chat-event-store.js";
22
+ import { OperationWaitError, waitForOperationChange, } from "./operation-wait.js";
22
23
  import { MutationGateReceiptStore } from "./mutation-gate-receipt-store.js";
23
24
  import { assessAutonomousExecutionEligibility, deriveEligibilityFactsFromDagSpec, } from "./dag-execution-receipt.js";
24
25
  import { issueHumanGateToken, mutationGatePayloadHash, verifyHumanGateToken, } from "./human-gate-token.js";
@@ -516,6 +517,63 @@ export async function dispatchOperatorAction(ctx, req) {
516
517
  }),
517
518
  };
518
519
  }
520
+ case "operationWait": {
521
+ const operationId = str(p.operationId);
522
+ if (!operationId)
523
+ return invalid(action, "operationId is required");
524
+ const rawAfterSeq = p.afterSeq ?? 0;
525
+ const afterSeq = typeof rawAfterSeq === "number" ? rawAfterSeq : Number(rawAfterSeq);
526
+ const rawMaxWaitMs = p.maxWaitMs;
527
+ const maxWaitMs = typeof rawMaxWaitMs === "number"
528
+ ? rawMaxWaitMs
529
+ : rawMaxWaitMs === undefined
530
+ ? undefined
531
+ : Number(rawMaxWaitMs);
532
+ try {
533
+ const result = await waitForOperationChange({
534
+ operations: ctx.operations,
535
+ events: ctx.events,
536
+ operationId,
537
+ afterSeq,
538
+ maxWaitMs,
539
+ });
540
+ return {
541
+ kind: "sync",
542
+ status: 200,
543
+ body: operatorSucceeded(action, result),
544
+ };
545
+ }
546
+ catch (error) {
547
+ if (error instanceof OperationWaitError) {
548
+ if (error.code === "NOT_FOUND") {
549
+ return {
550
+ kind: "error",
551
+ status: 404,
552
+ body: operatorFailed({
553
+ command: action,
554
+ outcome: "not-found",
555
+ code: "NOT_FOUND",
556
+ message: error.message,
557
+ }),
558
+ };
559
+ }
560
+ if (error.code === "EVENT_CURSOR_EXPIRED") {
561
+ return {
562
+ kind: "error",
563
+ status: 410,
564
+ body: operatorFailed({
565
+ command: action,
566
+ outcome: "blocked",
567
+ code: "EVENT_CURSOR_EXPIRED",
568
+ message: error.message,
569
+ }),
570
+ };
571
+ }
572
+ return invalid(action, error.message);
573
+ }
574
+ throw error;
575
+ }
576
+ }
519
577
  case "inspect": {
520
578
  const body = await runReadCli(ctx, ["inspect", "--json"], "inspect");
521
579
  return { kind: "sync", status: body.ok ? 200 : 400, body };