@tea-agent/loop-agent 0.35.1-beta.3 → 0.35.1

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 (48) hide show
  1. package/AGENTS.md +0 -2
  2. package/CHANGELOG.md +25 -24
  3. package/bin/loop-agent.js +1 -37
  4. package/dist/application/dag/generate-task-dag.js +4 -1
  5. package/dist/application/task-lifecycle/advance.js +14 -0
  6. package/dist/cli/program.js +2 -2
  7. package/dist/commands/task-advance.js +1 -0
  8. package/dist/executors/dag-pi-executor.js +0 -44
  9. package/dist/shared/package-metadata.js +0 -42
  10. package/dist/task/config-types.js +2 -0
  11. package/dist/task/contract/project.js +3 -0
  12. package/dist/task/contract/schema.js +1 -0
  13. package/dist/task/source-prepare/build-draft.js +7 -0
  14. package/dist/task/source-prepare/semantic-intake.js +37 -10
  15. package/dist/task/task-demand-routing.js +10 -0
  16. package/dist/worker/console/operator-actions.js +72 -6
  17. package/dist/worker/console/prd-intake-bridge.js +10 -3
  18. package/dist/worker/console/prd-reference-discovery.js +124 -0
  19. package/dist/worker/console/static/assets/{index-hJqCPs_g.css → index-HX1pbOyl.css} +1 -1
  20. package/dist/worker/console/static/assets/{index-CvsQgALl.js → index-M0BLEBfh.js} +25 -25
  21. package/dist/worker/console/static/index.html +2 -2
  22. package/dist/worker/console/static-src/app/useOperatorActions.js +19 -1
  23. package/dist/worker/console/static-src/app/useRecoveryConsole.js +0 -5
  24. package/dist/worker/console/static-src/app/useTaskWizard.js +12 -0
  25. package/dist/worker/loop-agent/loop-agent-client.js +3 -17
  26. package/dist/worker/observability/read-model.js +0 -20
  27. package/dist/worker/preflight.js +1 -2
  28. package/dist/workflows/dag/backend-test-scenario-param.js +23 -33
  29. package/dist/workflows/dag/dynamic-runtime/shared.js +1 -9
  30. package/dist/workflows/dag/frontend-implementation-contract.js +39 -233
  31. package/dist/workflows/dag/frontend-prewrite-gate.js +61 -364
  32. package/dist/workflows/dag/frontend-repair.js +18 -219
  33. package/dist/workflows/dag/frontend-verification-trace.js +32 -47
  34. package/dist/workflows/dag/init-hybrid.js +26 -49
  35. package/dist/workflows/dag/node-execution.js +0 -89
  36. package/dist/workflows/dag/recovery-recommendation.js +0 -58
  37. package/dist/workflows/dag/runner.js +11 -245
  38. package/dist/workflows/dag/scheduler.js +3 -257
  39. package/dist/workflows/dag/types.js +2 -130
  40. package/package.json +2 -2
  41. package/dist/build-stamp.json +0 -6
  42. package/dist/workflows/dag/contract-output-registry.js +0 -14
  43. package/dist/workflows/dag/contract-validator-registrations.js +0 -8
  44. package/dist/workflows/dag/frontend-recovery-plan.js +0 -73
  45. package/dist/workflows/dag/frontend-recovery-root-manifest.js +0 -123
  46. package/dist/workflows/dag/frontend-recovery-run.js +0 -539
  47. package/dist/workflows/dag/frontend-writer-recovery.js +0 -106
  48. package/dist/workflows/dag/frontend-writer-rollback.js +0 -821
@@ -1,106 +0,0 @@
1
- import path from "node:path";
2
- import { readFile } from "node:fs/promises";
3
- import { getDagRunDir } from "./lifecycle.js";
4
- import { captureWriterBaseline, readJournalFile, restoreJournal, sha256HexBytes, writeJournalFile, } from "./frontend-writer-rollback.js";
5
- /**
6
- * Phase 5: writer transient partial-write recovery — compose the phase-4 rollback
7
- * journal with the phase-3 staged child handoff. A frontend writer attempt is
8
- * snapshotted before the provider call so a transient partial write can be rolled
9
- * back to the pre-attempt baseline, then recovered by a staged child that re-runs
10
- * `frontend-implement-pi`.
11
- *
12
- * The runner remains the single-writer coordinator: it captures the baseline via
13
- * {@link captureFrontendWriterAttemptIntent} before the writer provider call, and
14
- * on a transient partial write runs {@link rollbackFrontendWriter} before writing
15
- * the recovery intent and staging the child.
16
- */
17
- /** Rollback intent path inside a run dir (written before the writer provider call). */
18
- export const FRONTEND_WRITER_ROLLBACK_INTENT_REL = ".runtime/frontend-writer-rollback.json";
19
- export function frontendWriterRollbackIntentAbsPath(runDir) {
20
- return path.join(runDir, FRONTEND_WRITER_ROLLBACK_INTENT_REL);
21
- }
22
- /**
23
- * AC/P1-9: capture the writeSet baseline and persist the attempt intent BEFORE
24
- * the writer provider call. Returns the intent path. Callers must fail the
25
- * attempt closed if this throws (no baseline → no rollback → no recovery).
26
- */
27
- export async function captureFrontendWriterAttemptIntent(input) {
28
- const baseline = await captureWriterBaseline(input.cwd, input.writeSet);
29
- const intentPath = frontendWriterRollbackIntentAbsPath(input.runDir);
30
- await writeJournalFile(intentPath, baseline);
31
- return intentPath;
32
- }
33
- /**
34
- * Record the writer attempt's changed paths and per-path attempt hashes into the
35
- * rollback intent AFTER the provider call. This is what makes restoreJournal able
36
- * to CAS-restore: it compares each changed path's current hash against the
37
- * recorded attempt hash before writing back the baseline.
38
- */
39
- export async function recordFrontendWriterAttempt(input) {
40
- const intentPath = frontendWriterRollbackIntentAbsPath(input.runDir);
41
- const snapshot = await readJournalFile(intentPath);
42
- if (!snapshot)
43
- return; // no baseline was captured; nothing to record
44
- const changed = [...new Set(input.changedPaths)].sort((a, b) => a.localeCompare(b));
45
- const fileHashes = {};
46
- for (const rel of changed) {
47
- try {
48
- const bytes = await readFile(path.join(input.cwd, rel));
49
- fileHashes[rel] = sha256HexBytes(bytes);
50
- }
51
- catch {
52
- fileHashes[rel] = "absent";
53
- }
54
- }
55
- snapshot.attemptChangedPaths = changed;
56
- snapshot.attemptFileHashes = fileHashes;
57
- await writeJournalFile(intentPath, snapshot);
58
- }
59
- /**
60
- * Restore the parent workspace to its pre-attempt baseline using the phase-4 CAS
61
- * journal. This must run BEFORE the recovery intent is written and the child is
62
- * staged (rollback commit point): a blocked rollback short-circuits to
63
- * `auto-recovery-blocked` and never stages a child.
64
- */
65
- export async function rollbackFrontendWriter(input) {
66
- const parentRunDir = getDagRunDir(input.cwd, "active", input.parentRunId);
67
- const snapshot = await readJournalFile(frontendWriterRollbackIntentAbsPath(parentRunDir));
68
- if (!snapshot) {
69
- return {
70
- ok: false,
71
- state: "missing-intent",
72
- reason: "auto-recovery-blocked: writer rollback intent missing (baseline was not captured before the provider call)",
73
- };
74
- }
75
- const result = await restoreJournal(snapshot, { repoRoot: input.cwd });
76
- if (result.state !== "completed") {
77
- return {
78
- ok: false,
79
- state: "blocked",
80
- reason: result.blockedReason ?? "auto-recovery-blocked",
81
- };
82
- }
83
- return {
84
- ok: true,
85
- state: "completed",
86
- restoredPaths: result.restoredPaths,
87
- snapshot,
88
- };
89
- }
90
- /**
91
- * Transient failure categories that indicate a writer may have partially written
92
- * before the attempt was interrupted. Clean-timeout (zero writes) is handled by
93
- * the retry policy and never reaches terminal aggregation as a recovery trigger.
94
- */
95
- const TRANSIENT_WRITER_FAILURE_CATEGORIES = new Set([
96
- "timeout",
97
- "network",
98
- "rate-limit",
99
- "unavailable",
100
- "terminated",
101
- "disconnect",
102
- "provider-error",
103
- ]);
104
- export function isFrontendWriterTransientPartialWrite(input) {
105
- return TRANSIENT_WRITER_FAILURE_CATEGORIES.has(input.failureCategory ?? "");
106
- }