@andorra-labs/code 0.1.9 → 0.1.11

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 (212) hide show
  1. package/README.md +28 -208
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/agent-execution.js +56 -0
  4. package/dist/src/app-server/protocol.d.ts +109 -1
  5. package/dist/src/app-server/protocol.js +8 -1
  6. package/dist/src/app-server.d.ts +59 -1
  7. package/dist/src/app-server.js +418 -63
  8. package/dist/src/auth/index.d.ts +1 -1
  9. package/dist/src/auth/index.js +1 -1
  10. package/dist/src/auth/store.d.ts +17 -1
  11. package/dist/src/auth/store.js +25 -2
  12. package/dist/src/automation-service.js +1 -1
  13. package/dist/src/browser-session.d.ts +8 -0
  14. package/dist/src/browser-session.js +27 -1
  15. package/dist/src/browser-ui/app.js +255 -33
  16. package/dist/src/browser-ui/index.html +9 -9
  17. package/dist/src/browser-ui/style.css +110 -65
  18. package/dist/src/browser-ui/tokens.css +27 -26
  19. package/dist/src/cli.js +10 -5
  20. package/dist/src/coding-tools.d.ts +24 -0
  21. package/dist/src/coding-tools.js +71 -8
  22. package/dist/src/command-screens.js +1 -1
  23. package/dist/src/commands.d.ts +1 -1
  24. package/dist/src/commands.js +2 -2
  25. package/dist/src/completion-gates.d.ts +42 -7
  26. package/dist/src/completion-gates.js +55 -9
  27. package/dist/src/completion.d.ts +9 -1
  28. package/dist/src/completion.js +20 -2
  29. package/dist/src/dashboard-view.js +2 -2
  30. package/dist/src/deadline.js +4 -0
  31. package/dist/src/decision/checks.js +1 -1
  32. package/dist/src/file-diff.d.ts +105 -0
  33. package/dist/src/file-diff.js +244 -0
  34. package/dist/src/graph-manager-chat.js +4 -4
  35. package/dist/src/graph-runner.js +39 -2
  36. package/dist/src/graph-sync.d.ts +8 -0
  37. package/dist/src/graph-sync.js +54 -3
  38. package/dist/src/graph-tool.js +1 -1
  39. package/dist/src/graph-ui/app.js +303 -129
  40. package/dist/src/graph-ui/controls.css +43 -22
  41. package/dist/src/graph-ui/controls.js +31 -1
  42. package/dist/src/graph-ui/embed.js +56 -7
  43. package/dist/src/graph-ui/icons.js +5 -0
  44. package/dist/src/graph-ui/index.html +3 -3
  45. package/dist/src/graph-ui/manager-state.js +2 -2
  46. package/dist/src/graph-ui/manager.css +19 -18
  47. package/dist/src/graph-ui/manager.js +5 -5
  48. package/dist/src/graph-ui/skill-picker.js +5 -5
  49. package/dist/src/graph-ui/studio-canvas.js +16 -16
  50. package/dist/src/graph-ui/studio.css +18 -15
  51. package/dist/src/graph-ui/studio.js +99 -42
  52. package/dist/src/graph-ui/style.css +125 -80
  53. package/dist/src/graph-ui/theme.js +2 -2
  54. package/dist/src/graph-ui/tokens.css +33 -29
  55. package/dist/src/graphs.d.ts +10 -3
  56. package/dist/src/graphs.js +15 -4
  57. package/dist/src/mcp.d.ts +75 -0
  58. package/dist/src/mcp.js +240 -8
  59. package/dist/src/membership-errors.d.ts +7 -1
  60. package/dist/src/membership-errors.js +9 -3
  61. package/dist/src/provider-keys.d.ts +5 -1
  62. package/dist/src/provider-keys.js +7 -3
  63. package/dist/src/provider-settings.d.ts +4 -1
  64. package/dist/src/provider-settings.js +46 -5
  65. package/dist/src/pull-requests.d.ts +42 -6
  66. package/dist/src/pull-requests.js +11 -3
  67. package/dist/src/qa/guidance.js +6 -19
  68. package/dist/src/qa/index.d.ts +0 -2
  69. package/dist/src/qa/index.js +0 -2
  70. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  71. package/dist/src/qa/profile/QaProfile.js +6 -2
  72. package/dist/src/qa/tools.d.ts +19 -1
  73. package/dist/src/qa/tools.js +20 -145
  74. package/dist/src/react-runtime.js +134 -16
  75. package/dist/src/read-document-doc.d.ts +20 -0
  76. package/dist/src/read-document-doc.js +524 -0
  77. package/dist/src/read-document-docx.d.ts +21 -0
  78. package/dist/src/read-document-docx.js +584 -0
  79. package/dist/src/read-document-text.d.ts +29 -0
  80. package/dist/src/read-document-text.js +67 -0
  81. package/dist/src/read-document-tool.d.ts +48 -0
  82. package/dist/src/read-document-tool.js +162 -0
  83. package/dist/src/read-document.d.ts +78 -0
  84. package/dist/src/read-document.js +353 -0
  85. package/dist/src/read-image.d.ts +29 -2
  86. package/dist/src/read-image.js +42 -17
  87. package/dist/src/remote/engine-pool.js +18 -6
  88. package/dist/src/runtime.d.ts +19 -0
  89. package/dist/src/runtime.js +10 -1
  90. package/dist/src/screen-selection.d.ts +38 -0
  91. package/dist/src/screen-selection.js +103 -0
  92. package/dist/src/session-changes.d.ts +122 -0
  93. package/dist/src/session-changes.js +804 -0
  94. package/dist/src/side-panel.d.ts +6 -1
  95. package/dist/src/side-panel.js +12 -10
  96. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  97. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  98. package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
  99. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  100. package/dist/src/skills/bundled/provenance.json +4 -4
  101. package/dist/src/skills/runtime-skills.js +3 -3
  102. package/dist/src/stall-recovery.d.ts +15 -0
  103. package/dist/src/stall-recovery.js +17 -0
  104. package/dist/src/telemetry/schema.d.ts +1 -1
  105. package/dist/src/telemetry/schema.js +1 -2
  106. package/dist/src/terminal-ui.d.ts +64 -20
  107. package/dist/src/terminal-ui.js +312 -82
  108. package/dist/src/time-limit.d.ts +53 -0
  109. package/dist/src/time-limit.js +79 -0
  110. package/dist/src/tool-diff-stats.d.ts +9 -0
  111. package/dist/src/tool-diff-stats.js +20 -0
  112. package/dist/src/tool-names.d.ts +1 -1
  113. package/dist/src/tool-result-filter.js +1 -1
  114. package/dist/src/tools.js +118 -9
  115. package/dist/src/transcript.d.ts +11 -0
  116. package/dist/src/transcript.js +15 -3
  117. package/dist/src/types.d.ts +12 -0
  118. package/dist/src/usage-analytics.d.ts +3 -1
  119. package/dist/src/usage-analytics.js +16 -2
  120. package/package.json +6 -26
  121. package/dist/src/qa/api/http-runner.d.ts +0 -3
  122. package/dist/src/qa/api/http-runner.js +0 -47
  123. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  124. package/dist/src/qa/git/ChangeDetector.js +0 -177
  125. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  126. package/dist/src/qa/git/DiffReviewer.js +0 -115
  127. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  128. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  129. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  130. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  131. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  132. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  133. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  134. package/dist/src/qa/runners/CommandRunner.js +0 -96
  135. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  136. package/dist/src/qa/runners/TestRunner.js +0 -66
  137. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  138. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  139. package/dist/src/qa/runtime-detect.d.ts +0 -10
  140. package/dist/src/qa/runtime-detect.js +0 -72
  141. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  142. package/dist/src/qa/security/DependencyScanner.js +0 -167
  143. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  144. package/dist/src/qa/security/SecretScanner.js +0 -55
  145. package/docs/README.md +0 -36
  146. package/docs/agents/README.md +0 -62
  147. package/docs/agents/install-for-agents.md +0 -56
  148. package/docs/agents/mcp-server.md +0 -212
  149. package/docs/agents/subagent-mode.md +0 -149
  150. package/docs/concepts/README.md +0 -47
  151. package/docs/concepts/jev-actionable-routing.md +0 -113
  152. package/docs/concepts/jev-decision-thresholds.md +0 -412
  153. package/docs/concepts/jev-efficiency.md +0 -217
  154. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  155. package/docs/concepts/limits.md +0 -52
  156. package/docs/concepts/memory.md +0 -10
  157. package/docs/concepts/security.md +0 -50
  158. package/docs/concepts/workspace-instructions.md +0 -29
  159. package/docs/getting-started/README.md +0 -82
  160. package/docs/getting-started/accounts.md +0 -78
  161. package/docs/getting-started/configure-providers.md +0 -132
  162. package/docs/guides/README.md +0 -13
  163. package/docs/guides/browser.md +0 -39
  164. package/docs/guides/desktop-app.md +0 -414
  165. package/docs/guides/extensions.md +0 -102
  166. package/docs/guides/graph-builder.md +0 -116
  167. package/docs/guides/headless.md +0 -46
  168. package/docs/guides/tui.md +0 -75
  169. package/docs/guides/update.md +0 -70
  170. package/docs/guides/web-search.md +0 -51
  171. package/docs/guides/windows-code-signing.md +0 -319
  172. package/docs/llms.txt +0 -45
  173. package/docs/reference/README.md +0 -7
  174. package/docs/reference/cli.md +0 -76
  175. package/docs/reference/config.md +0 -91
  176. package/docs/reference/slash-commands.md +0 -59
  177. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  178. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  179. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  180. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  181. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  182. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  183. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  184. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  185. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  186. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  187. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  188. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  189. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  190. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  191. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  192. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  193. package/scripts/jev-efficiency-eval.mjs +0 -187
  194. package/scripts/jev-efficiency-live.mjs +0 -193
  195. package/scripts/zcode-engine-replay.mjs +0 -223
  196. package/tests/agent-centric-mcp-test-plan.md +0 -208
  197. package/tests/analytics-settings-test-plan.md +0 -165
  198. package/tests/browser-cli-smoke.mjs +0 -276
  199. package/tests/browser-test-plan.md +0 -280
  200. package/tests/chat-side-panel-test-plan.md +0 -309
  201. package/tests/decision-engine-test-plan.md +0 -163
  202. package/tests/default-active-jev-test-plan.md +0 -85
  203. package/tests/harness-extensions-test-plan.md +0 -113
  204. package/tests/jev-all-decisions-test-plan.md +0 -156
  205. package/tests/jev-efficiency/criteria.json +0 -158
  206. package/tests/jev-efficiency/workloads.mjs +0 -242
  207. package/tests/jev-efficiency-test-plan.md +0 -198
  208. package/tests/permissions-sandbox-probe.mjs +0 -74
  209. package/tests/permissions-test-plan.md +0 -191
  210. package/tests/product-telemetry-test-plan.md +0 -536
  211. package/tests/thinking-stream-preview-test-plan.md +0 -136
  212. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -0,0 +1,38 @@
1
+ /** One screen cell, 1-based like the terminal's own mouse reports. */
2
+ export interface ScreenCell {
3
+ row: number;
4
+ column: number;
5
+ }
6
+ /**
7
+ * A drag selection in screen coordinates.
8
+ *
9
+ * `limit` is the last column the selection may reach: a drag that starts in the chat column stops
10
+ * at its edge, so the side panel drawn beside it is never copied along with the transcript.
11
+ */
12
+ export interface ScreenSelection {
13
+ anchor: ScreenCell;
14
+ head: ScreenCell;
15
+ limit?: number;
16
+ }
17
+ /** The selection's two ends in reading order. */
18
+ export declare function orderedSelection(selection: ScreenSelection): [ScreenCell, ScreenCell];
19
+ /** Whether the selection covers nothing but the cell it started on. */
20
+ export declare function emptySelection(selection: ScreenSelection): boolean;
21
+ /**
22
+ * The inclusive column span the selection covers on one row, or undefined when it misses the row.
23
+ *
24
+ * A selection reads like text: the first row runs from its start to the edge, the last row from
25
+ * the edge to its end, and every row between is taken whole.
26
+ */
27
+ export declare function selectedSpan(selection: ScreenSelection, row: number): [number, number] | undefined;
28
+ /**
29
+ * Draw one row with the selected columns in reverse video.
30
+ *
31
+ * The row keeps its own colors. Reverse video is re-asserted after every escape inside the span,
32
+ * because a color reset there would otherwise end the highlight early.
33
+ */
34
+ export declare function highlightRow(line: string, from: number, to: number): string;
35
+ /** The plain text the selection covers, one line per screen row, trailing blanks dropped. */
36
+ export declare function selectedText(rows: readonly string[], selection: ScreenSelection): string;
37
+ /** The run of non-blank cells under a cell, as a selection; undefined on blank space. */
38
+ export declare function wordAt(rows: readonly string[], cell: ScreenCell): ScreenSelection | undefined;
@@ -0,0 +1,103 @@
1
+ import stringWidth from 'string-width';
2
+ const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
3
+ /** A CSI sequence (colors, cursor moves) or an OSC string, matched at the start of the text. */
4
+ const ESCAPE = /^(?:\x1b\[[0-?]*[ -/]*[@-~]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\))/;
5
+ /**
6
+ * Split one drawn row into escape sequences and graphemes, each grapheme with the columns it covers.
7
+ *
8
+ * A zero-width grapheme takes the column of the cell before it, so it travels with that cell.
9
+ */
10
+ function pieces(line) {
11
+ const result = [];
12
+ let column = 1, rest = line;
13
+ while (rest) {
14
+ const escape = ESCAPE.exec(rest);
15
+ if (escape) {
16
+ result.push({ text: escape[0], escape: true, from: column, to: column - 1 });
17
+ rest = rest.slice(escape[0].length);
18
+ continue;
19
+ }
20
+ const next = rest.indexOf('\x1b', 1);
21
+ const run = rest.startsWith('\x1b') ? rest.slice(0, 1) : next < 0 ? rest : rest.slice(0, next);
22
+ rest = rest.slice(run.length);
23
+ for (const { segment } of segmenter.segment(run)) {
24
+ const width = stringWidth(segment);
25
+ if (width === 0)
26
+ result.push({ text: segment, escape: false, from: column - 1, to: column - 1 });
27
+ else {
28
+ result.push({ text: segment, escape: false, from: column, to: column + width - 1 });
29
+ column += width;
30
+ }
31
+ }
32
+ }
33
+ return result;
34
+ }
35
+ /** The selection's two ends in reading order. */
36
+ export function orderedSelection(selection) {
37
+ const { anchor, head } = selection;
38
+ return anchor.row < head.row || (anchor.row === head.row && anchor.column <= head.column) ? [anchor, head] : [head, anchor];
39
+ }
40
+ /** Whether the selection covers nothing but the cell it started on. */
41
+ export function emptySelection(selection) {
42
+ return selection.anchor.row === selection.head.row && selection.anchor.column === selection.head.column;
43
+ }
44
+ /**
45
+ * The inclusive column span the selection covers on one row, or undefined when it misses the row.
46
+ *
47
+ * A selection reads like text: the first row runs from its start to the edge, the last row from
48
+ * the edge to its end, and every row between is taken whole.
49
+ */
50
+ export function selectedSpan(selection, row) {
51
+ const [start, end] = orderedSelection(selection);
52
+ if (row < start.row || row > end.row)
53
+ return undefined;
54
+ const edge = selection.limit ?? Number.MAX_SAFE_INTEGER;
55
+ const from = row === start.row ? start.column : 1, to = Math.min(edge, row === end.row ? end.column : edge);
56
+ return from <= to ? [from, to] : undefined;
57
+ }
58
+ /**
59
+ * Draw one row with the selected columns in reverse video.
60
+ *
61
+ * The row keeps its own colors. Reverse video is re-asserted after every escape inside the span,
62
+ * because a color reset there would otherwise end the highlight early.
63
+ */
64
+ export function highlightRow(line, from, to) {
65
+ let out = '', inside = false;
66
+ for (const piece of pieces(line)) {
67
+ if (piece.escape) {
68
+ out += piece.text + (inside ? '\x1b[7m' : '');
69
+ continue;
70
+ }
71
+ const selected = piece.to >= from && piece.from <= to;
72
+ if (selected !== inside) {
73
+ out += selected ? '\x1b[7m' : '\x1b[27m';
74
+ inside = selected;
75
+ }
76
+ out += piece.text;
77
+ }
78
+ return inside ? out + '\x1b[27m' : out;
79
+ }
80
+ /** The plain text the selection covers, one line per screen row, trailing blanks dropped. */
81
+ export function selectedText(rows, selection) {
82
+ const [start, end] = orderedSelection(selection);
83
+ const lines = [];
84
+ for (let row = start.row; row <= end.row; row++) {
85
+ const span = selectedSpan(selection, row);
86
+ const text = span ? pieces(rows[row - 1] ?? '').filter(piece => !piece.escape && piece.to >= span[0] && piece.from <= span[1]).map(piece => piece.text).join('') : '';
87
+ lines.push(text.trimEnd());
88
+ }
89
+ return lines.join('\n');
90
+ }
91
+ /** The run of non-blank cells under a cell, as a selection; undefined on blank space. */
92
+ export function wordAt(rows, cell) {
93
+ const cells = pieces(rows[cell.row - 1] ?? '').filter(piece => !piece.escape && piece.to >= piece.from);
94
+ const at = cells.findIndex(piece => piece.from <= cell.column && piece.to >= cell.column);
95
+ if (at < 0 || !/\S/u.test(cells[at].text))
96
+ return undefined;
97
+ let first = at, last = at;
98
+ while (first > 0 && /\S/u.test(cells[first - 1].text))
99
+ first--;
100
+ while (last < cells.length - 1 && /\S/u.test(cells[last + 1].text))
101
+ last++;
102
+ return { anchor: { row: cell.row, column: cells[first].from }, head: { row: cell.row, column: cells[last].to } };
103
+ }
@@ -0,0 +1,122 @@
1
+ import type { AppServerSessionChanges, AppServerSessionChangesKept, AppServerSessionChangesUndone, AppServerSessionFileChange } from './app-server/protocol.js';
2
+ /**
3
+ * The files an agent changed in a session since the person last reviewed them, with Keep and Undo.
4
+ *
5
+ * Every write an agent makes to a workspace file passes one function (`atomicWrite` in `tools.ts`), and a
6
+ * delegated change lands through one more (`applyLanding`). Both report here, before and after: before, so
7
+ * the content the file held can be kept as its baseline the first time the agent touches it; after, so the
8
+ * store knows what the agent's write left. Between two reviews the baseline never moves — a file edited ten
9
+ * times has one entry, and its diff is the file's whole change, not the last call's.
10
+ *
11
+ * Keep makes the file as it is the new baseline: it leaves the pending set and its stored original is
12
+ * dropped. Undo puts the baseline back — the earlier content, or no file at all for one the agent created,
13
+ * or the file again for one a landing removed — but only while the file is still what the agent left: a file
14
+ * something else changed afterwards is reported as a conflict instead of being overwritten, unless the
15
+ * caller asks with `force`.
16
+ *
17
+ * The record lives in the configuration home beside the session (`session-changes/<id>/`), not in the
18
+ * workspace and not in Git: it works for a folder that is no repository, needs no index, and survives an
19
+ * app restart and a resumed session. Engines sharing a home can all read and change it — the desktop runs a
20
+ * process per task and browses with another — so every change happens under the session's store lock, and
21
+ * the revision it carries orders every answer and event across those processes.
22
+ */
23
+ /** Past this size a file's earlier content is not kept: the change is listed, and Undo refuses the file. */
24
+ export declare const BASELINE_BYTE_LIMIT: number;
25
+ /** Diff lines `list` returns per file unless asked for another bound. */
26
+ export declare const LIST_DIFF_LINES = 200;
27
+ /** The most diff lines one answer may ask for per file. */
28
+ export declare const MAX_DIFF_LINES = 20000;
29
+ /** Session ids name files, so only the characters a session id is made of are accepted. */
30
+ export declare function sessionChangesId(id: string): string;
31
+ export declare const sessionChangesRoot: (home: string) => string;
32
+ /**
33
+ * One write (or one landing of several files) as the review record sees it.
34
+ *
35
+ * The write's own mutation of the disk happens between `begin` and `commit`, and those hold the session's
36
+ * review lock — the one Keep and Undo take — so an Undo can never observe a file, have an agent write land on
37
+ * it, and then restore over that write: either the Undo finishes first and the write lands on the restored
38
+ * file (and is recorded against it), or the write lands first and the Undo sees it.
39
+ *
40
+ * - `begin` takes the lock and reads what each file holds now, which becomes its original the first time it
41
+ * changes. Call it right before the mutation, after anything that can wait on a person (an approval).
42
+ * - `commit` records what the mutation left and releases the lock; `abort` releases it for a write that did
43
+ * not land. Exactly one of them must follow a `begin` that resolved.
44
+ *
45
+ * None of them may fail the write: a record that cannot be made is a change the review does not list, not a
46
+ * lost edit. They reject only when the lock could not be taken (`begin`), which the writer treats as
47
+ * "write unrecorded".
48
+ */
49
+ export interface FileWriteRecording {
50
+ begin(): Promise<void>;
51
+ commit(): Promise<void>;
52
+ abort(): Promise<void>;
53
+ }
54
+ /**
55
+ * Where a run's tools report their writes. `beforeWrite` is called with the canonical paths a mutation will
56
+ * write or remove, before any folder is created for them; it answers nothing when none of the paths is one
57
+ * this recorder tracks.
58
+ */
59
+ export interface FileChangeRecorder {
60
+ beforeWrite(targets: string | readonly string[]): Promise<FileWriteRecording | undefined>;
61
+ }
62
+ export declare class SessionChangeStore {
63
+ private readonly home;
64
+ private readonly baselineLimit;
65
+ private readonly beforeRestore?;
66
+ /**
67
+ * Both options exist for tests: `baselineLimit` is the size past which an original is not kept, and
68
+ * `beforeRestore` runs inside an Undo, under its lock, after it has checked the files and before it writes.
69
+ */
70
+ constructor(home: string, options?: {
71
+ baselineLimit?: number;
72
+ beforeRestore?: () => Promise<void>;
73
+ beginMemory?: number;
74
+ });
75
+ /** Test seam: the bytes of originals one write holds in memory before the rest go to the store. */
76
+ private readonly beginMemory;
77
+ /**
78
+ * The recorder a run's tools report their writes to. Only files inside `root` (the run's workspace folder)
79
+ * are tracked: a delegated subagent writes in a worktree of its own, and its change reaches the workspace
80
+ * through the landing, which reports the files it lands.
81
+ *
82
+ * `review` answers, as a write lands, whether the person reviews this run's writes. A run that does not
83
+ * ask (Full Access) adds no file to the pending set: its writes are kept as they land, and nothing waits
84
+ * on a Keep. A file already pending from a reviewed write stays tracked, so its entry and its Undo still
85
+ * describe what is on disk.
86
+ */
87
+ recorder(sessionId: string, workspace: string, onChange: (changes: AppServerSessionChanges) => void, onError?: (error: unknown) => void, review?: () => boolean): FileChangeRecorder;
88
+ /** Records what a landed write left, for each file it wrote. The caller holds the session's lock. */
89
+ private recordWrites;
90
+ /** Updates one file's entry in `state`; answers whether the pending set changed. */
91
+ private recordWrite;
92
+ /** The pending set as the last write, Keep or Undo left it, without reading the files. */
93
+ pending(sessionId: string): Promise<AppServerSessionChanges>;
94
+ /** Each pending file with its diff from the earlier content to the file as it is now, `maxLines` per file. */
95
+ list(sessionId: string, maxLines?: number): Promise<AppServerSessionChanges>;
96
+ /** One pending file with its diff, up to `maxLines`; null when the file is not pending. */
97
+ get(sessionId: string, relative: string, maxLines?: number): Promise<{
98
+ revision: number;
99
+ change: AppServerSessionFileChange | null;
100
+ }>;
101
+ /** A stored entry measured against the disk now; nothing when the file is back to its baseline. */
102
+ private fresh;
103
+ /** Accepts the named files (every pending file when `paths` is omitted): each leaves the pending set as it is. */
104
+ keep(sessionId: string, paths?: readonly string[]): Promise<AppServerSessionChangesKept>;
105
+ /**
106
+ * Restores the named files (every pending file when `paths` is omitted) to their content before the first
107
+ * unreviewed change. A file whose disk content is no longer what the agent left is a conflict: without
108
+ * `force` one such conflict reverts nothing, so a multi-file Undo never leaves the folder half restored by
109
+ * choice. A file whose original was too large to keep is reported and stays pending either way.
110
+ *
111
+ * The check and the restore run under the lock of every file restored, the lock any session's agent write
112
+ * holds from just before its rename until it is recorded (`FileWriteRecording`), so no write — of this
113
+ * session or another one editing the same folder — can land between them.
114
+ */
115
+ undo(sessionId: string, paths?: readonly string[], force?: boolean): Promise<AppServerSessionChangesUndone>;
116
+ /** Undo of `targets`, whose file locks and the session's lock the caller holds. */
117
+ private undoLocked;
118
+ /** Puts one file back to its baseline. Refuses a path whose folders now lead outside the workspace. */
119
+ private restore;
120
+ /** Forgets the session's record and its stored originals, as a deleted session must. */
121
+ remove(sessionId: string): Promise<void>;
122
+ }