agent-nuvira 1.44.0 → 1.45.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.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * CheckpointStore — persist and restore orchestration state for `--resume`.
3
+ *
4
+ * Assessment item #6 ("maintain continuity"): serialize intermediate state so
5
+ * subtasks can resume on another model without loss. After every task batch the
6
+ * orchestrator saves a snapshot of the ContextVault (task plan with per-step
7
+ * statuses, artifacts, file changes, metadata) to disk. A later run with
8
+ * `--resume <id>` rehydrates the vault and continues from the first pending
9
+ * step — completed steps are never re-run, so a crash / quota kill / token
10
+ * expiry mid-pipeline doesn't restart the whole plan.
11
+ *
12
+ * Checkpoints are JSON-serialized (JSON.stringify drops function fields like
13
+ * `onRateLimit` automatically), keyed by a deterministic id derived from
14
+ * `goal + workingDirectory` plus an optional explicit id. Persisted to
15
+ * `~/.buff/memory/checkpoints/` (honors BUFF_MEMORY_DIR). All reads/writes are
16
+ * best-effort — a corrupt or missing checkpoint must never crash a run.
17
+ */
18
+ import type { AgentContext } from './agent.js';
19
+ /** Lightweight checkpoint metadata (used for listing). */
20
+ export interface CheckpointMeta {
21
+ id: string;
22
+ goal: string;
23
+ workingDirectory: string;
24
+ savedAt: number;
25
+ tasksCompleted: number;
26
+ tasksTotal: number;
27
+ }
28
+ /** A full checkpoint on disk: metadata + the rehydratable context snapshot. */
29
+ export interface CheckpointFile extends CheckpointMeta {
30
+ context: AgentContext;
31
+ }
32
+ /**
33
+ * Deterministic checkpoint id for a goal + working directory. Two runs of the
34
+ * same goal in the same directory map to the same id, so `--resume` without an
35
+ * explicit id finds the latest checkpoint for that goal.
36
+ */
37
+ export declare function checkpointIdFor(goal: string, workingDirectory: string): string;
38
+ /**
39
+ * Save a checkpoint. Returns the checkpoint id, or null if the write failed
40
+ * (best-effort — checkpointing must never break the pipeline, and the caller
41
+ * can log the failure honestly instead of claiming a save that didn't happen).
42
+ *
43
+ * @param context The vault context to snapshot (task plan with statuses, etc.)
44
+ * @param id Optional explicit id; defaults to a hash of goal + cwd
45
+ */
46
+ export declare function saveCheckpoint(context: AgentContext, id?: string): string | null;
47
+ /** Load a checkpoint by id (null if missing/corrupt). */
48
+ export declare function loadCheckpoint(id: string): CheckpointFile | null;
49
+ /** List all saved checkpoints, newest first (for `buff execute --checkpoint-list`). */
50
+ export declare function listCheckpoints(): CheckpointMeta[];
51
+ //# sourceMappingURL=checkpoint-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-store.d.ts","sourceRoot":"","sources":["../../src/agents/checkpoint-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAa/C,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,OAAO,EAAE,YAAY,CAAC;CACvB;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAM9E;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsBhF;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAUhE;AAED,uFAAuF;AACvF,wBAAgB,eAAe,IAAI,cAAc,EAAE,CA0BlD"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * CheckpointStore — persist and restore orchestration state for `--resume`.
3
+ *
4
+ * Assessment item #6 ("maintain continuity"): serialize intermediate state so
5
+ * subtasks can resume on another model without loss. After every task batch the
6
+ * orchestrator saves a snapshot of the ContextVault (task plan with per-step
7
+ * statuses, artifacts, file changes, metadata) to disk. A later run with
8
+ * `--resume <id>` rehydrates the vault and continues from the first pending
9
+ * step — completed steps are never re-run, so a crash / quota kill / token
10
+ * expiry mid-pipeline doesn't restart the whole plan.
11
+ *
12
+ * Checkpoints are JSON-serialized (JSON.stringify drops function fields like
13
+ * `onRateLimit` automatically), keyed by a deterministic id derived from
14
+ * `goal + workingDirectory` plus an optional explicit id. Persisted to
15
+ * `~/.buff/memory/checkpoints/` (honors BUFF_MEMORY_DIR). All reads/writes are
16
+ * best-effort — a corrupt or missing checkpoint must never crash a run.
17
+ */
18
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
19
+ import { join } from 'node:path';
20
+ import { homedir } from 'node:os';
21
+ import { createHash } from 'node:crypto';
22
+ // ─── Storage ────────────────────────────────────────────────────────────────
23
+ const DEFAULT_MEMORY_DIR = join(homedir(), '.buff', 'memory');
24
+ function checkpointsDir() {
25
+ const base = process.env.BUFF_MEMORY_DIR || DEFAULT_MEMORY_DIR;
26
+ return join(base, 'checkpoints');
27
+ }
28
+ // ─── Helpers ────────────────────────────────────────────────────────────────
29
+ /**
30
+ * Deterministic checkpoint id for a goal + working directory. Two runs of the
31
+ * same goal in the same directory map to the same id, so `--resume` without an
32
+ * explicit id finds the latest checkpoint for that goal.
33
+ */
34
+ export function checkpointIdFor(goal, workingDirectory) {
35
+ const hash = createHash('sha1')
36
+ .update(`${workingDirectory}\u0000${goal}`)
37
+ .digest('hex')
38
+ .slice(0, 12);
39
+ return `cp-${hash}`;
40
+ }
41
+ /**
42
+ * Save a checkpoint. Returns the checkpoint id, or null if the write failed
43
+ * (best-effort — checkpointing must never break the pipeline, and the caller
44
+ * can log the failure honestly instead of claiming a save that didn't happen).
45
+ *
46
+ * @param context The vault context to snapshot (task plan with statuses, etc.)
47
+ * @param id Optional explicit id; defaults to a hash of goal + cwd
48
+ */
49
+ export function saveCheckpoint(context, id) {
50
+ try {
51
+ const dir = checkpointsDir();
52
+ if (!existsSync(dir))
53
+ mkdirSync(dir, { recursive: true });
54
+ const cid = id || checkpointIdFor(context.goal, context.workingDirectory);
55
+ const tasks = context.taskPlan ?? [];
56
+ const file = {
57
+ id: cid,
58
+ goal: context.goal,
59
+ workingDirectory: context.workingDirectory,
60
+ savedAt: Date.now(),
61
+ tasksCompleted: tasks.filter((t) => t.status === 'completed').length,
62
+ tasksTotal: tasks.length,
63
+ // JSON round-trip drops function fields (onRateLimit) — safe to persist.
64
+ context,
65
+ };
66
+ writeFileSync(join(dir, `${cid}.json`), JSON.stringify(file, null, 2), 'utf-8');
67
+ return cid;
68
+ }
69
+ catch {
70
+ // Best-effort — checkpointing must never break the pipeline.
71
+ return null;
72
+ }
73
+ }
74
+ /** Load a checkpoint by id (null if missing/corrupt). */
75
+ export function loadCheckpoint(id) {
76
+ try {
77
+ const path = join(checkpointsDir(), `${id}.json`);
78
+ if (!existsSync(path))
79
+ return null;
80
+ const data = JSON.parse(readFileSync(path, 'utf-8'));
81
+ if (!data || typeof data !== 'object' || !data.context)
82
+ return null;
83
+ return data;
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
89
+ /** List all saved checkpoints, newest first (for `buff execute --checkpoint-list`). */
90
+ export function listCheckpoints() {
91
+ try {
92
+ const dir = checkpointsDir();
93
+ if (!existsSync(dir))
94
+ return [];
95
+ return readdirSync(dir)
96
+ .filter((f) => f.endsWith('.json'))
97
+ .map((f) => {
98
+ try {
99
+ const data = JSON.parse(readFileSync(join(dir, f), 'utf-8'));
100
+ return {
101
+ id: data.id,
102
+ goal: data.goal,
103
+ workingDirectory: data.workingDirectory,
104
+ savedAt: data.savedAt,
105
+ tasksCompleted: data.tasksCompleted,
106
+ tasksTotal: data.tasksTotal,
107
+ };
108
+ }
109
+ catch {
110
+ return null;
111
+ }
112
+ })
113
+ .filter((c) => c !== null)
114
+ .sort((a, b) => b.savedAt - a.savedAt);
115
+ }
116
+ catch {
117
+ return [];
118
+ }
119
+ }
120
+ //# sourceMappingURL=checkpoint-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-store.js","sourceRoot":"","sources":["../../src/agents/checkpoint-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,+EAA+E;AAE/E,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAE9D,SAAS,cAAc;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,kBAAkB,CAAC;IAC/D,OAAO,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACnC,CAAC;AAmBD,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,gBAAwB;IACpE,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC;SAC5B,MAAM,CAAC,GAAG,gBAAgB,SAAS,IAAI,EAAE,CAAC;SAC1C,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,OAAqB,EAAE,EAAW;IAC/D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QA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;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -43,7 +43,14 @@ export declare class ContextVault {
43
43
  setMeta(key: string, value: unknown): void;
44
44
  /** Retrieve a metadata value */
45
45
  getMeta<T = unknown>(key: string): T | undefined;
46
- /** Get a serialisable snapshot (handy for logging / Phase 2 persistence) */
46
+ /** Get a serialisable snapshot (handy for logging / checkpoint persistence) */
47
47
  snapshot(): AgentContext;
48
+ /**
49
+ * Rehydrate a vault from a previously saved snapshot (checkpoint resume).
50
+ * Restores the goal, task plan (with per-step statuses), artifacts,
51
+ * conversations, file changes, and metadata so a resumed pipeline continues
52
+ * from the first pending step instead of restarting the whole plan.
53
+ */
54
+ static fromSnapshot(snapshot: AgentContext): ContextVault;
48
55
  }
49
56
  //# sourceMappingURL=context-vault.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-vault.d.ts","sourceRoot":"","sources":["../../src/agents/context-vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAgB,UAAU,EAAE,MAAM,YAAY,CAAC;AAe7F;;GAEG;AACH,qBAAa,YAAY;IACvB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;gBAEnB,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAMlD,iCAAiC;IACjC,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;IAIpC,2CAA2C;IAC3C,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAUnF,6DAA6D;IAC7D,gBAAgB,IAAI,QAAQ,EAAE;IAU9B,iDAAiD;IACjD,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,mCAAmC;IACnC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAID,qCAAq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IAUnF,6DAA6D;IAC7D,gBAAgB,IAAI,QAAQ,EAAE;IAU9B,iDAAiD;IACjD,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,mCAAmC;IACnC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAID,qCAAqC;IACrC,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IAIzC,4DAA4D;IAC5D,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE;IAO9C,oCAAoC;IACpC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAS3D,yDAAyD;IACzD,kBAAkB,IAAI,MAAM;IAQ5B,2BAA2B;IAC3B,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAUvC,2BAA2B;IAC3B,cAAc,IAAI,UAAU,EAAE;IAI9B,+CAA+C;IAC/C,cAAc,IAAI,MAAM;IAYxB,6BAA6B;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAI1C,gCAAgC;IAChC,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAMhD,+EAA+E;IAC/E,QAAQ,IAAI,YAAY;IAIxB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY;CAS1D"}
@@ -126,9 +126,24 @@ export class ContextVault {
126
126
  return this.context.metadata[key];
127
127
  }
128
128
  // ─── Snapshot ───────────────────────────────────────────────────────────
129
- /** Get a serialisable snapshot (handy for logging / Phase 2 persistence) */
129
+ /** Get a serialisable snapshot (handy for logging / checkpoint persistence) */
130
130
  snapshot() {
131
131
  return structuredClone(this.context);
132
132
  }
133
+ /**
134
+ * Rehydrate a vault from a previously saved snapshot (checkpoint resume).
135
+ * Restores the goal, task plan (with per-step statuses), artifacts,
136
+ * conversations, file changes, and metadata so a resumed pipeline continues
137
+ * from the first pending step instead of restarting the whole plan.
138
+ */
139
+ static fromSnapshot(snapshot) {
140
+ const vault = new ContextVault(snapshot.goal, snapshot.workingDirectory);
141
+ vault.context.taskPlan = snapshot.taskPlan ?? [];
142
+ vault.context.artifacts = snapshot.artifacts ?? [];
143
+ vault.context.conversations = snapshot.conversations ?? [];
144
+ vault.context.fileChanges = snapshot.fileChanges ?? [];
145
+ vault.context.metadata = snapshot.metadata ?? {};
146
+ return vault;
147
+ }
133
148
  }
134
149
  //# sourceMappingURL=context-vault.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-vault.js","sourceRoot":"","sources":["../../src/agents/context-vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,4BAA4B;AAC5B,SAAS,kBAAkB,CAAC,IAAY,EAAE,gBAAwB;IAChE,OAAO;QACL,IAAI;QACJ,gBAAgB;QAChB,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,EAAE;QACjB,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB,oCAAoC;IAC3B,OAAO,CAAe;IAE/B,YAAY,IAAY,EAAE,gBAAwB;QAChD,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED,2EAA2E;IAE3E,iCAAiC;IACjC,WAAW,CAAC,KAAiB;QAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,2CAA2C;IAC3C,gBAAgB,CAAC,MAAc,EAAE,MAA0B,EAAE,MAAe;QAC1E,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK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IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC;QAC7C,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAED,2EAA2E;IAE3E,6BAA6B;IAC7B,OAAO,CAAC,GAAW,EAAE,KAAc;QACjC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACrC,CAAC;IAED,gCAAgC;IAChC,OAAO,CAAc,GAAW;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB,CAAC;IACrD,CAAC;IAED,2EAA2E;IAE3E,+EAA+E;IAC/E,QAAQ;QACN,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,QAAsB;QACxC,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACzE,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;QACjD,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC;QACnD,KAAK,CAAC,OAAO,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAC;QAC3D,KAAK,CAAC,OAAO,CAAC,WAAW,GAAG,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC;QACvD,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -96,6 +96,26 @@ export interface OrchestratorOptions {
96
96
  stop(): void;
97
97
  start(text?: string): void;
98
98
  };
99
+ /**
100
+ * Save a checkpoint after every task batch so the pipeline can be resumed
101
+ * later with `--resume` (or a fresh run of the same goal). Checkpoints live
102
+ * in ~/.buff/memory/checkpoints/ and let a crash / quota kill / token expiry
103
+ * mid-pipeline continue from the first pending step instead of restarting.
104
+ * Default: false. Implied true when resumeCheckpointId is set.
105
+ */
106
+ checkpoint?: boolean;
107
+ /**
108
+ * Resume a previously saved pipeline from a checkpoint id (or the auto id
109
+ * for goal + cwd). Completed steps are skipped; execution continues from the
110
+ * first pending step with its dependencies satisfied.
111
+ */
112
+ resumeCheckpointId?: string;
113
+ /**
114
+ * True when the user explicitly asked to RESUME (bare `--resume` with no id
115
+ * included). Lets the orchestrator warn when no checkpoint matches the auto
116
+ * id (e.g. a reworded goal) instead of silently starting a fresh pipeline.
117
+ */
118
+ resumeRequested?: boolean;
99
119
  }
100
120
  /** The final result of an orchestration session */
101
121
  export interface OrchestrationResult {
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/agents/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAOrD,OAAO,KAAK,EAA0B,QAAQ,EAAe,MAAM,YAAY,CAAC;AAOhF,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAuB,KAAK,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAyD/F,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qCAAqC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC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;IACtE,+DAA+D;IAC/D,OAAO,CAAC,KAAK,CAWX;gBAEU,aAAa,CAAC,EAAE,aAAa,EAAE,cAAc,CAAC,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,YAAY;IAO5H;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA0lB5F,OAAO,CAAC,iBAAiB;YAuCX,QAAQ;IActB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;YA4GhB,iBAAiB;IA+S/B,OAAO,CAAC,oBAAoB;IA0D5B;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IA4ClC,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,+BAA+B;IAsDvC,OAAO,CAAC,2BAA2B;IA0BnC;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,WAAW;CAwBpB"}
@@ -24,6 +24,7 @@ import { ConfigManager } from '../config/manager.js';
24
24
  import { showModelPicker } from '../cli/model-picker.js';
25
25
  import { logger } from '../utils/logger.js';
26
26
  import { ContextVault } from './context-vault.js';
27
+ import { saveCheckpoint, loadCheckpoint, checkpointIdFor } from './checkpoint-store.js';
27
28
  import { buildProjectFileTree, truncateTree } from './utils/file-tree.js';
28
29
  import { cleanupSandbox } from './agents/tester.js';
29
30
  import { getMCPManager, resetMCPManager } from '../mcp/manager.js';
@@ -123,7 +124,46 @@ export class Orchestrator {
123
124
  */
124
125
  async execute(goal, options = {}) {
125
126
  const startTime = Date.now();
126
- const vault = new ContextVault(goal, process.cwd());
127
+ // ── Checkpoint resume: rehydrate a saved vault instead of starting fresh ──
128
+ // Assessment item #6 (continuity): if a previous run saved a checkpoint for
129
+ // this goal, `--resume` continues from the first pending step — completed
130
+ // steps are never re-run, and the resumed provider/model can differ.
131
+ const checkpointId = checkpointIdFor(goal, process.cwd());
132
+ const resumeId = options.resumeCheckpointId || checkpointId;
133
+ // SAVE checkpoints whenever the user opted in (--checkpoint, or implied by
134
+ // any --resume so a resumed run keeps checkpointing forward — including
135
+ // direct API callers that only set resumeRequested).
136
+ const checkpointEnabled = options.checkpoint === true ||
137
+ !!options.resumeCheckpointId ||
138
+ options.resumeRequested === true;
139
+ // LOAD only when the user explicitly asked to RESUME (bare --resume or an
140
+ // explicit id). Plain `--checkpoint` must NEVER silently resume a stale
141
+ // checkpoint from a previous run of the same goal — that would re-enter a
142
+ // completed plan and skip every task.
143
+ const resumeWanted = options.resumeRequested === true || !!options.resumeCheckpointId;
144
+ let resumed = false;
145
+ let vault;
146
+ if (resumeWanted) {
147
+ const saved = loadCheckpoint(resumeId);
148
+ if (saved) {
149
+ vault = ContextVault.fromSnapshot(saved.context);
150
+ resumed = true;
151
+ const done = saved.context.taskPlan.filter((s) => s.status === 'completed').length;
152
+ if (options.verbose) {
153
+ logger.info(` ♻️ Resumed from checkpoint '${resumeId}' — ${done}/${saved.context.taskPlan.length} steps already complete`);
154
+ }
155
+ }
156
+ else {
157
+ // Resume explicitly requested but no checkpoint found — warn (a
158
+ // reworded goal silently misses the auto id) and start fresh with
159
+ // checkpointing on, so a later crash can still be resumed.
160
+ logger.warn(` ⚠️ No checkpoint found for '${resumeId}' — starting a fresh pipeline (run with --checkpoint to save one)`);
161
+ vault = new ContextVault(goal, process.cwd());
162
+ }
163
+ }
164
+ else {
165
+ vault = new ContextVault(goal, process.cwd());
166
+ }
127
167
  // Reset execution telemetry for this pipeline (shared accumulator used by
128
168
  // createLLMProvider, executeSingleTask, and buildResult).
129
169
  this.stats = {
@@ -144,7 +184,10 @@ export class Orchestrator {
144
184
  // Matches executeSingleTask's rule: an explicit --model always wins.
145
185
  const autoRoutingActive = (options.autoRouteModels === true && !options.model) ||
146
186
  isAutoModel(options.model) || isAutoProvider(options.provider);
147
- const plannerRoutingDecision = autoRoutingActive
187
+ // On RESUME the restored vault already carries the routingContext from the
188
+ // original run — recomputing it here would overwrite the checkpointed
189
+ // metadata (and the planner isn't re-run anyway, so the override is moot).
190
+ const plannerRoutingDecision = autoRoutingActive && !resumed
148
191
  ? this.resolveAutoRoutingDecision({ agentType: 'planner', description: goal }, options)
149
192
  : undefined;
150
193
  if (plannerRoutingDecision) {
@@ -161,7 +204,18 @@ export class Orchestrator {
161
204
  const defaultCallLLM = autoRoutingActive
162
205
  ? this.createAutoRoutedLLM({ agentType: 'planner', description: goal }, options)
163
206
  : this.createLLMProvider(options);
164
- const agentResults = [];
207
+ // On resume, seed the report with the steps already finished in the original
208
+ // run (completed/failed) so the final agent breakdown is complete — these
209
+ // steps are never re-executed, but they still count toward the summary.
210
+ const agentResults = resumed
211
+ ? vault.context.taskPlan
212
+ .filter((s) => s.status === 'completed' || s.status === 'failed')
213
+ .map((s) => ({
214
+ agent: s.agentType,
215
+ success: s.status === 'completed',
216
+ summary: s.result || (s.status === 'completed' ? 'Completed (previous run)' : 'Failed (previous run)'),
217
+ }))
218
+ : [];
165
219
  const contextFiles = [];
166
220
  // ── Emit: pipeline started event ───────────────────────────────────
167
221
  this.eventBus.emit(EventNames.ORCHESTRATOR_PIPELINE_STARTED, {
@@ -274,7 +328,18 @@ export class Orchestrator {
274
328
  // `--auto-route` / autoRouteModels enables per-task AutoModelRouter
275
329
  // routing in executeSingleTask (no static map needed).
276
330
  // ── 4. Planner (or pre-built plan from workflow template) ────────────
277
- if (options.prefillPlan && options.prefillPlan.length > 0) {
331
+ // When resuming from a checkpoint the plan is already in the vault — skip
332
+ // the planner entirely (no re-plan, no re-gather) and continue execution.
333
+ if (resumed && vault.context.taskPlan.length > 0) {
334
+ if (options.verbose) {
335
+ logger.highlight('\n♻️ Resuming existing plan from checkpoint...');
336
+ for (const step of vault.context.taskPlan) {
337
+ const icon = step.status === 'completed' ? '✅' : step.status === 'failed' ? '❌' : '⏳';
338
+ logger.info(` ${icon} [${step.agentType}] ${step.description}`);
339
+ }
340
+ }
341
+ }
342
+ else if (options.prefillPlan && options.prefillPlan.length > 0) {
278
343
  for (const step of options.prefillPlan) {
279
344
  vault.context.taskPlan.push({ ...step });
280
345
  }
@@ -418,6 +483,42 @@ export class Orchestrator {
418
483
  await this.executeSingleTask(task, vault, options, agentResults, contextFiles, defaultCallLLM, strategy);
419
484
  }
420
485
  }
486
+ // ── Checkpoint after every task batch ──────────────────────────────
487
+ // Persist the vault (per-step statuses, artifacts, file changes) so a
488
+ // crash / quota kill / token expiry mid-pipeline can `--resume` from
489
+ // here instead of restarting the whole plan (assessment item #6).
490
+ // Guarded by !vault.isComplete: in-progress states are saved per batch,
491
+ // and the terminal state is persisted once by the final save below —
492
+ // no redundant double-write on the completing iteration.
493
+ if (checkpointEnabled && !vault.isComplete) {
494
+ try {
495
+ const cid = saveCheckpoint(vault.context, resumeId);
496
+ if (cid && options.verbose) {
497
+ const done = vault.context.taskPlan.filter((s) => s.status === 'completed').length;
498
+ logger.debug(` 💾 Checkpoint saved (${cid}): ${done}/${vault.context.taskPlan.length} steps complete`);
499
+ }
500
+ }
501
+ catch {
502
+ // Best-effort — checkpointing must never break the pipeline
503
+ }
504
+ }
505
+ }
506
+ // ── 5b. Final checkpoint (pipeline completing) ────────────────────────
507
+ // Save once more after the loop so the newest on-disk checkpoint reflects
508
+ // the COMPLETED state (including the final batch). Without this, the last
509
+ // saved checkpoint would show the final step still 'pending', and a
510
+ // --resume after a successful run would re-execute it.
511
+ if (checkpointEnabled) {
512
+ try {
513
+ const cid = saveCheckpoint(vault.context, resumeId);
514
+ if (cid && options.verbose) {
515
+ const done = vault.context.taskPlan.filter((s) => s.status === 'completed').length;
516
+ logger.debug(` 💾 Final checkpoint saved (${cid}): ${done}/${vault.context.taskPlan.length} steps complete`);
517
+ }
518
+ }
519
+ catch {
520
+ // Best-effort — checkpointing must never break the pipeline
521
+ }
421
522
  }
422
523
  // ── 6. Clean up sandbox if any ────────────────────────────────────────
423
524
  const sandboxPath = vault.getMeta('sandboxPath');