@namzu/cli 26.3.0 → 27.0.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 (321) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/README.md +49 -34
  3. package/dist/bin.js +7 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/checkpoints/store.d.ts +17 -4
  6. package/dist/checkpoints/store.d.ts.map +1 -1
  7. package/dist/checkpoints/store.js +20 -5
  8. package/dist/checkpoints/store.js.map +1 -1
  9. package/dist/cli.js +2 -2
  10. package/dist/cli.js.map +1 -1
  11. package/dist/commands/acp.d.ts +23 -1
  12. package/dist/commands/acp.d.ts.map +1 -1
  13. package/dist/commands/acp.js +41 -2
  14. package/dist/commands/acp.js.map +1 -1
  15. package/dist/commands/drain.d.ts +69 -2
  16. package/dist/commands/drain.d.ts.map +1 -1
  17. package/dist/commands/drain.js +214 -134
  18. package/dist/commands/drain.js.map +1 -1
  19. package/dist/commands/eval.js +1 -1
  20. package/dist/commands/eval.js.map +1 -1
  21. package/dist/commands/provider-wait.d.ts +5 -5
  22. package/dist/commands/provider-wait.d.ts.map +1 -1
  23. package/dist/commands/provider-wait.js +2 -2
  24. package/dist/commands/resident.d.ts.map +1 -1
  25. package/dist/commands/resident.js +2 -1
  26. package/dist/commands/resident.js.map +1 -1
  27. package/dist/commands/run-flags.d.ts +7 -7
  28. package/dist/commands/run-flags.js +4 -4
  29. package/dist/commands/run-stream.d.ts +16 -12
  30. package/dist/commands/run-stream.d.ts.map +1 -1
  31. package/dist/commands/run-stream.js +142 -98
  32. package/dist/commands/run-stream.js.map +1 -1
  33. package/dist/commands/run.d.ts +6 -4
  34. package/dist/commands/run.d.ts.map +1 -1
  35. package/dist/commands/run.js +129 -45
  36. package/dist/commands/run.js.map +1 -1
  37. package/dist/commands/serve.js +2 -2
  38. package/dist/commands/serve.js.map +1 -1
  39. package/dist/commands/state.js +8 -8
  40. package/dist/commands/state.js.map +1 -1
  41. package/dist/config/load.d.ts +1 -1
  42. package/dist/config/load.d.ts.map +1 -1
  43. package/dist/config/load.js +17 -5
  44. package/dist/config/load.js.map +1 -1
  45. package/dist/config/run-limits.d.ts +20 -8
  46. package/dist/config/run-limits.d.ts.map +1 -1
  47. package/dist/config/run-limits.js +28 -46
  48. package/dist/config/run-limits.js.map +1 -1
  49. package/dist/config/schema.d.ts +44 -19
  50. package/dist/config/schema.d.ts.map +1 -1
  51. package/dist/config/schema.js.map +1 -1
  52. package/dist/config/tool-result-screens.js +1 -1
  53. package/dist/context/directories.d.ts +37 -0
  54. package/dist/context/directories.d.ts.map +1 -0
  55. package/dist/context/directories.js +69 -0
  56. package/dist/context/directories.js.map +1 -0
  57. package/dist/context/environment.d.ts +55 -0
  58. package/dist/context/environment.d.ts.map +1 -1
  59. package/dist/context/environment.js +96 -0
  60. package/dist/context/environment.js.map +1 -1
  61. package/dist/context/project-tracker.d.ts +3 -3
  62. package/dist/context/project-tracker.d.ts.map +1 -1
  63. package/dist/context/project-tracker.js +3 -3
  64. package/dist/context/project-tracker.js.map +1 -1
  65. package/dist/context/project.d.ts +1 -1
  66. package/dist/context/project.js +1 -1
  67. package/dist/context/sandbox.d.ts +22 -3
  68. package/dist/context/sandbox.d.ts.map +1 -1
  69. package/dist/context/sandbox.js +42 -4
  70. package/dist/context/sandbox.js.map +1 -1
  71. package/dist/doctor/checks/chain.d.ts +1 -1
  72. package/dist/doctor/checks/chain.js +5 -5
  73. package/dist/doctor/checks/chain.js.map +1 -1
  74. package/dist/doctor/checks/invariants.d.ts +2 -2
  75. package/dist/doctor/checks/invariants.js +5 -5
  76. package/dist/doctor/checks/invariants.js.map +1 -1
  77. package/dist/doctor/checks/logging.js +1 -1
  78. package/dist/doctor/checks/logging.js.map +1 -1
  79. package/dist/doctor/checks/sandbox.js +1 -1
  80. package/dist/doctor/checks/sandbox.js.map +1 -1
  81. package/dist/doctor/checks/session-export.d.ts +1 -1
  82. package/dist/doctor/checks/session-export.js +2 -2
  83. package/dist/doctor/checks/session-export.js.map +1 -1
  84. package/dist/doctor/checks/telemetry.d.ts +1 -1
  85. package/dist/doctor/checks/telemetry.js +1 -1
  86. package/dist/doctor/registry.js +2 -2
  87. package/dist/doctor/registry.js.map +1 -1
  88. package/dist/exit-codes.d.ts +2 -2
  89. package/dist/exit-codes.js +2 -2
  90. package/dist/integrations/mcp/servers.d.ts +1 -1
  91. package/dist/integrations/providers/chain-capabilities.d.ts +6 -6
  92. package/dist/integrations/providers/chain-capabilities.js +8 -8
  93. package/dist/integrations/providers/chain-capabilities.js.map +1 -1
  94. package/dist/integrations/providers/register.d.ts +1 -1
  95. package/dist/integrations/providers/register.js +1 -1
  96. package/dist/integrations/providers/registry.d.ts +1 -1
  97. package/dist/integrations/resident/inspection.d.ts +4 -1
  98. package/dist/integrations/resident/inspection.d.ts.map +1 -1
  99. package/dist/integrations/resident/inspection.js +53 -34
  100. package/dist/integrations/resident/inspection.js.map +1 -1
  101. package/dist/integrations/resident/learning-storage.d.ts +7 -2
  102. package/dist/integrations/resident/learning-storage.d.ts.map +1 -1
  103. package/dist/integrations/resident/learning-storage.js +12 -8
  104. package/dist/integrations/resident/learning-storage.js.map +1 -1
  105. package/dist/integrations/resident/runner-store.d.ts +1 -1
  106. package/dist/integrations/resident/runner-store.d.ts.map +1 -1
  107. package/dist/integrations/resident/runner-store.js +5 -2
  108. package/dist/integrations/resident/runner-store.js.map +1 -1
  109. package/dist/integrations/resident/runner-worker.js +1 -0
  110. package/dist/integrations/resident/runner-worker.js.map +1 -1
  111. package/dist/integrations/resident/session-log-reads.d.ts +37 -0
  112. package/dist/integrations/resident/session-log-reads.d.ts.map +1 -0
  113. package/dist/integrations/resident/session-log-reads.js +125 -0
  114. package/dist/integrations/resident/session-log-reads.js.map +1 -0
  115. package/dist/integrations/resident/session-step.d.ts +2 -0
  116. package/dist/integrations/resident/session-step.d.ts.map +1 -1
  117. package/dist/integrations/resident/session-step.js +15 -13
  118. package/dist/integrations/resident/session-step.js.map +1 -1
  119. package/dist/integrations/resident/storage.d.ts +23 -1
  120. package/dist/integrations/resident/storage.d.ts.map +1 -1
  121. package/dist/integrations/resident/storage.js +60 -17
  122. package/dist/integrations/resident/storage.js.map +1 -1
  123. package/dist/integrations/resident/tool-evidence.d.ts +4 -2
  124. package/dist/integrations/resident/tool-evidence.d.ts.map +1 -1
  125. package/dist/integrations/resident/tool-evidence.js +36 -30
  126. package/dist/integrations/resident/tool-evidence.js.map +1 -1
  127. package/dist/integrations/resident/verification.d.ts +2 -2
  128. package/dist/integrations/resident/verification.d.ts.map +1 -1
  129. package/dist/integrations/resident/verification.js +4 -4
  130. package/dist/integrations/resident/verification.js.map +1 -1
  131. package/dist/integrations/sessions/checkpoint-view.d.ts +13 -0
  132. package/dist/integrations/sessions/checkpoint-view.d.ts.map +1 -0
  133. package/dist/integrations/sessions/checkpoint-view.js +48 -0
  134. package/dist/integrations/sessions/checkpoint-view.js.map +1 -0
  135. package/dist/integrations/sessions/context-inventory.js +1 -1
  136. package/dist/integrations/sessions/context-inventory.js.map +1 -1
  137. package/dist/integrations/sessions/conversation-search.d.ts +16 -20
  138. package/dist/integrations/sessions/conversation-search.d.ts.map +1 -1
  139. package/dist/integrations/sessions/conversation-search.js +305 -731
  140. package/dist/integrations/sessions/conversation-search.js.map +1 -1
  141. package/dist/integrations/sessions/evidence-page-validation.d.ts +4 -4
  142. package/dist/integrations/sessions/evidence-page-validation.d.ts.map +1 -1
  143. package/dist/integrations/sessions/evidence-page-validation.js +1 -1
  144. package/dist/integrations/sessions/evidence-page-validation.js.map +1 -1
  145. package/dist/integrations/sessions/evidence-recall.d.ts +40 -2
  146. package/dist/integrations/sessions/evidence-recall.d.ts.map +1 -1
  147. package/dist/integrations/sessions/evidence-recall.js +41 -97
  148. package/dist/integrations/sessions/evidence-recall.js.map +1 -1
  149. package/dist/integrations/sessions/store.d.ts +153 -85
  150. package/dist/integrations/sessions/store.d.ts.map +1 -1
  151. package/dist/integrations/sessions/store.js +414 -484
  152. package/dist/integrations/sessions/store.js.map +1 -1
  153. package/dist/integrations/sessions/task-context.d.ts +15 -2
  154. package/dist/integrations/sessions/task-context.d.ts.map +1 -1
  155. package/dist/integrations/sessions/task-context.js +34 -11
  156. package/dist/integrations/sessions/task-context.js.map +1 -1
  157. package/dist/integrations/sessions/transcript-export.d.ts +13 -6
  158. package/dist/integrations/sessions/transcript-export.d.ts.map +1 -1
  159. package/dist/integrations/sessions/transcript-export.js +148 -263
  160. package/dist/integrations/sessions/transcript-export.js.map +1 -1
  161. package/dist/integrations/state/home.d.ts +4 -16
  162. package/dist/integrations/state/home.d.ts.map +1 -1
  163. package/dist/integrations/state/home.js +6 -42
  164. package/dist/integrations/state/home.js.map +1 -1
  165. package/dist/integrations/state/project.d.ts +6 -7
  166. package/dist/integrations/state/project.d.ts.map +1 -1
  167. package/dist/integrations/state/project.js +7 -9
  168. package/dist/integrations/state/project.js.map +1 -1
  169. package/dist/integrations/state/report.d.ts +27 -41
  170. package/dist/integrations/state/report.d.ts.map +1 -1
  171. package/dist/integrations/state/report.js +172 -464
  172. package/dist/integrations/state/report.js.map +1 -1
  173. package/dist/integrations/state/retention.d.ts +18 -0
  174. package/dist/integrations/state/retention.d.ts.map +1 -0
  175. package/dist/integrations/state/retention.js +18 -0
  176. package/dist/integrations/state/retention.js.map +1 -0
  177. package/dist/integrations/subagents/activity.d.ts +36 -31
  178. package/dist/integrations/subagents/activity.d.ts.map +1 -1
  179. package/dist/integrations/subagents/activity.js +27 -23
  180. package/dist/integrations/subagents/activity.js.map +1 -1
  181. package/dist/integrations/subagents/batches.d.ts +91 -0
  182. package/dist/integrations/subagents/batches.d.ts.map +1 -0
  183. package/dist/integrations/subagents/batches.js +172 -0
  184. package/dist/integrations/subagents/batches.js.map +1 -0
  185. package/dist/integrations/subagents/parent.d.ts +26 -11
  186. package/dist/integrations/subagents/parent.d.ts.map +1 -1
  187. package/dist/integrations/subagents/parent.js +13 -28
  188. package/dist/integrations/subagents/parent.js.map +1 -1
  189. package/dist/integrations/subagents/policy.d.ts +2 -2
  190. package/dist/integrations/subagents/policy.d.ts.map +1 -1
  191. package/dist/integrations/subagents/policy.js +2 -2
  192. package/dist/integrations/subagents/policy.js.map +1 -1
  193. package/dist/integrations/subagents/replay.d.ts +91 -26
  194. package/dist/integrations/subagents/replay.d.ts.map +1 -1
  195. package/dist/integrations/subagents/replay.js +216 -114
  196. package/dist/integrations/subagents/replay.js.map +1 -1
  197. package/dist/integrations/subagents/runtime.d.ts +50 -26
  198. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  199. package/dist/integrations/subagents/runtime.js +132 -126
  200. package/dist/integrations/subagents/runtime.js.map +1 -1
  201. package/dist/integrations/subagents/saved-agents.d.ts +57 -0
  202. package/dist/integrations/subagents/saved-agents.d.ts.map +1 -0
  203. package/dist/integrations/subagents/saved-agents.js +102 -0
  204. package/dist/integrations/subagents/saved-agents.js.map +1 -0
  205. package/dist/integrations/subagents/slash.d.ts +55 -0
  206. package/dist/integrations/subagents/slash.d.ts.map +1 -0
  207. package/dist/integrations/subagents/slash.js +45 -0
  208. package/dist/integrations/subagents/slash.js.map +1 -0
  209. package/dist/integrations/telemetry/session-export.d.ts +6 -6
  210. package/dist/integrations/telemetry/session-export.d.ts.map +1 -1
  211. package/dist/integrations/telemetry/session-export.js +2 -2
  212. package/dist/memory/presentation.d.ts +11 -0
  213. package/dist/memory/presentation.d.ts.map +1 -1
  214. package/dist/memory/presentation.js +25 -0
  215. package/dist/memory/presentation.js.map +1 -1
  216. package/dist/memory/store.d.ts +13 -7
  217. package/dist/memory/store.d.ts.map +1 -1
  218. package/dist/memory/store.js +37 -11
  219. package/dist/memory/store.js.map +1 -1
  220. package/dist/memory/typed.d.ts +116 -0
  221. package/dist/memory/typed.d.ts.map +1 -0
  222. package/dist/memory/typed.js +336 -0
  223. package/dist/memory/typed.js.map +1 -0
  224. package/dist/permissions/checks.d.ts +1 -1
  225. package/dist/permissions/checks.js +1 -1
  226. package/dist/permissions/headless-trust.d.ts +2 -2
  227. package/dist/permissions/headless-trust.d.ts.map +1 -1
  228. package/dist/permissions/headless-trust.js +3 -3
  229. package/dist/permissions/headless-trust.js.map +1 -1
  230. package/dist/permissions/mode.d.ts +4 -4
  231. package/dist/permissions/mode.js +1 -1
  232. package/dist/permissions/rules.d.ts +1 -1
  233. package/dist/permissions/rules.js +1 -1
  234. package/dist/termination.d.ts +75 -0
  235. package/dist/termination.d.ts.map +1 -0
  236. package/dist/termination.js +143 -0
  237. package/dist/termination.js.map +1 -0
  238. package/dist/tui/AgentExplorer.d.ts +2 -2
  239. package/dist/tui/AgentExplorer.js +4 -4
  240. package/dist/tui/AgentExplorer.js.map +1 -1
  241. package/dist/tui/App.d.ts +9 -1
  242. package/dist/tui/App.d.ts.map +1 -1
  243. package/dist/tui/App.js +452 -303
  244. package/dist/tui/App.js.map +1 -1
  245. package/dist/tui/LiveActivity.d.ts +1 -1
  246. package/dist/tui/LiveActivity.d.ts.map +1 -1
  247. package/dist/tui/PermissionOverlay.d.ts +8 -0
  248. package/dist/tui/PermissionOverlay.d.ts.map +1 -1
  249. package/dist/tui/PermissionOverlay.js +25 -2
  250. package/dist/tui/PermissionOverlay.js.map +1 -1
  251. package/dist/tui/Picker.js +1 -1
  252. package/dist/tui/agent.d.ts +208 -132
  253. package/dist/tui/agent.d.ts.map +1 -1
  254. package/dist/tui/agent.js +523 -313
  255. package/dist/tui/agent.js.map +1 -1
  256. package/dist/tui/conversation-evidence-view.js +3 -3
  257. package/dist/tui/conversation-evidence-view.js.map +1 -1
  258. package/dist/tui/conversation-history.d.ts +4 -21
  259. package/dist/tui/conversation-history.d.ts.map +1 -1
  260. package/dist/tui/conversation-history.js +4 -28
  261. package/dist/tui/conversation-history.js.map +1 -1
  262. package/dist/tui/index.d.ts.map +1 -1
  263. package/dist/tui/index.js +27 -1
  264. package/dist/tui/index.js.map +1 -1
  265. package/dist/tui/log-pane.js +1 -1
  266. package/dist/tui/markdownParser.d.ts +1 -1
  267. package/dist/tui/markdownParser.js +1 -1
  268. package/dist/tui/permission-review.d.ts +16 -0
  269. package/dist/tui/permission-review.d.ts.map +1 -1
  270. package/dist/tui/permission-review.js +25 -2
  271. package/dist/tui/permission-review.js.map +1 -1
  272. package/dist/tui/slashCommands.d.ts +29 -40
  273. package/dist/tui/slashCommands.d.ts.map +1 -1
  274. package/dist/tui/slashCommands.js +70 -61
  275. package/dist/tui/slashCommands.js.map +1 -1
  276. package/dist/tui/{run-interruption.d.ts → turn-interruption.d.ts} +4 -4
  277. package/dist/tui/turn-interruption.d.ts.map +1 -0
  278. package/dist/tui/{run-interruption.js → turn-interruption.js} +20 -20
  279. package/dist/tui/turn-interruption.js.map +1 -0
  280. package/dist/tui/turn-limits-settings.d.ts +39 -0
  281. package/dist/tui/turn-limits-settings.d.ts.map +1 -0
  282. package/dist/tui/{run-limits-settings.js → turn-limits-settings.js} +18 -18
  283. package/dist/tui/turn-limits-settings.js.map +1 -0
  284. package/dist/tui/types.d.ts +3 -3
  285. package/dist/tui/types.d.ts.map +1 -1
  286. package/dist/user-commands/store.d.ts +1 -1
  287. package/dist/user-commands/store.js +1 -1
  288. package/package.json +7 -7
  289. package/dist/integrations/sessions/compaction-evidence.d.ts +0 -5
  290. package/dist/integrations/sessions/compaction-evidence.d.ts.map +0 -1
  291. package/dist/integrations/sessions/compaction-evidence.js +0 -59
  292. package/dist/integrations/sessions/compaction-evidence.js.map +0 -1
  293. package/dist/integrations/sessions/database.d.ts +0 -5
  294. package/dist/integrations/sessions/database.d.ts.map +0 -1
  295. package/dist/integrations/sessions/database.js +0 -34
  296. package/dist/integrations/sessions/database.js.map +0 -1
  297. package/dist/integrations/sessions/paths.d.ts +0 -7
  298. package/dist/integrations/sessions/paths.d.ts.map +0 -1
  299. package/dist/integrations/sessions/paths.js +0 -14
  300. package/dist/integrations/sessions/paths.js.map +0 -1
  301. package/dist/integrations/sessions/run-discovery.d.ts +0 -24
  302. package/dist/integrations/sessions/run-discovery.d.ts.map +0 -1
  303. package/dist/integrations/sessions/run-discovery.js +0 -142
  304. package/dist/integrations/sessions/run-discovery.js.map +0 -1
  305. package/dist/integrations/sessions/turn-evidence.d.ts +0 -129
  306. package/dist/integrations/sessions/turn-evidence.d.ts.map +0 -1
  307. package/dist/integrations/sessions/turn-evidence.js +0 -517
  308. package/dist/integrations/sessions/turn-evidence.js.map +0 -1
  309. package/dist/integrations/subagents/history.d.ts +0 -26
  310. package/dist/integrations/subagents/history.d.ts.map +0 -1
  311. package/dist/integrations/subagents/history.js +0 -76
  312. package/dist/integrations/subagents/history.js.map +0 -1
  313. package/dist/integrations/subagents/runs.d.ts +0 -72
  314. package/dist/integrations/subagents/runs.d.ts.map +0 -1
  315. package/dist/integrations/subagents/runs.js +0 -155
  316. package/dist/integrations/subagents/runs.js.map +0 -1
  317. package/dist/tui/run-interruption.d.ts.map +0 -1
  318. package/dist/tui/run-interruption.js.map +0 -1
  319. package/dist/tui/run-limits-settings.d.ts +0 -39
  320. package/dist/tui/run-limits-settings.d.ts.map +0 -1
  321. package/dist/tui/run-limits-settings.js.map +0 -1
@@ -1,37 +1,73 @@
1
- import { type DelegatedChildRun, type Logger } from '@namzu/sdk';
1
+ import { type ChildSessionSummary, type Logger, type SessionEvent, type SessionIndex, type SessionLocator, type SessionPaths, type SessionRecord, type TurnExecutionStatus } from '@namzu/sdk';
2
2
  import { type SubagentActivity } from './activity.js';
3
- /** Where a conversation's own runs and its children's evidence both live. */
3
+ /**
4
+ * Child summaries one listing considers.
5
+ *
6
+ * The index answers `listChildren` from one query, so this no longer bounds a
7
+ * directory scan. It bounds what one listing does with the answer: a
8
+ * conversation that delegated tens of thousands of times is still summarised
9
+ * from its most recent work rather than from its whole history. Children are
10
+ * taken newest first, so past this many it is the OLDEST that stop being
11
+ * counted.
12
+ */
13
+ export declare const MAX_CONSIDERED_CHILDREN = 2000;
14
+ /**
15
+ * Children replayed into one monitor, matching the live monitor's own
16
+ * retention. Replay walks the newest first and stops at this many, so a
17
+ * conversation that delegated thousands of times opens its most recent work
18
+ * instead of its whole history.
19
+ */
20
+ export declare const MAX_REPLAYED_CHILDREN = 80;
21
+ /** The parts of the session index a saved-children reader asks. */
22
+ export type SavedChildIndex = Pick<SessionIndex, 'refresh' | 'listChildren'>;
23
+ /** Where a conversation's delegated children are recorded. */
4
24
  export interface SavedChildScope {
5
- /** The `sessions/` directory holding this project's session directories. */
6
- readonly sessionsRoot: string;
7
- /** The conversation whose parent runs own the children being looked for. */
8
- readonly sessionId: string;
25
+ /**
26
+ * The index over the project's logs. The conversation's own log is
27
+ * refreshed before it is asked, so a child spawned a moment ago is listed.
28
+ */
29
+ readonly index: SavedChildIndex;
30
+ /** The project layout the conversation's log lives in. */
31
+ readonly paths: SessionPaths;
32
+ /** The conversation whose turns spawned the children being looked for. */
33
+ readonly session: SessionLocator;
9
34
  readonly maxChildren?: number;
10
35
  readonly log?: Logger;
11
36
  }
37
+ /** One child as the parent's log records it, plus where its own log is. */
38
+ export interface SavedChild extends ChildSessionSummary {
39
+ /** `<parent-session-dir>/subagents/<child-id>.jsonl`, derived from checked ids, never from `path`. */
40
+ readonly logPath: string;
41
+ }
12
42
  /**
13
- * Every delegated child saved under one conversation's parent runs, newest
14
- * first.
43
+ * Up to `limit` of a conversation's children, newest first.
15
44
  *
16
- * Two directory shapes have to meet here. A conversation's own runs are
17
- * `<sessionsRoot>/<sessionId>/runs/<runId>`, which is where the parent run
18
- * ids come from after a restart has forgotten them. A child's evidence is
19
- * `<sessionsRoot>/<childSessionId>/runs/<parentRunId>/children/<childRunId>`,
20
- * under the child's session and not the parent's — so finding a child means
21
- * asking every session directory whether it holds a `runs/` entry named after
22
- * one of this conversation's runs.
45
+ * The parent's log is the record of which children it spawned
46
+ * (`child_session_spawned`) and how each one ended (`child_session_ended`);
47
+ * the index derives {@link ChildSessionSummary} from exactly those records.
48
+ * The parent's log is refreshed first. A refresh that fails is reported and
49
+ * the index is asked anyway: a listing that is one child short is better than
50
+ * none, and the next refresh catches up.
23
51
  *
24
- * That ordering is deliberate: one `readdir` per session directory answers
25
- * the question for all of that directory's children at once, where probing
26
- * each parent run inside each session directory would multiply the two
27
- * counts. A child session directory holds exactly one parent run id, so the
28
- * inner listing runs only where there is something to list.
29
- *
30
- * READ-ONLY throughout. Nothing here creates a directory, and in particular
31
- * nothing binds a `RunDiskStore`, which would mint the run directory it was
32
- * asked about.
52
+ * Nothing here writes a log, a meta file or a session directory. The only
53
+ * write is the refresh, which brings the rebuildable index up to date with a
54
+ * log it already derives from.
33
55
  */
34
- export declare function listSavedChildren(scope: SavedChildScope): Promise<readonly DelegatedChildRun[]>;
56
+ export declare function readSavedChildren(scope: SavedChildScope, limit: number): Promise<readonly SavedChild[]>;
57
+ /**
58
+ * The newest `limit` children, as {@link readSavedChildren}, plus how many
59
+ * children the index lists in all, so a bounded listing can say exactly how
60
+ * many it left out.
61
+ */
62
+ export declare function readSavedChildrenPage(scope: SavedChildScope, limit: number): Promise<{
63
+ readonly children: readonly SavedChild[];
64
+ readonly total: number;
65
+ }>;
66
+ /**
67
+ * Every delegated child one conversation's turns spawned, in launch order,
68
+ * bounded to the newest {@link MAX_REPLAYED_CHILDREN}.
69
+ */
70
+ export declare function listSavedChildren(scope: SavedChildScope): Promise<readonly SavedChild[]>;
35
71
  /**
36
72
  * Replays saved children into the display shape the live monitor publishes.
37
73
  *
@@ -40,7 +76,36 @@ export declare function listSavedChildren(scope: SavedChildScope): Promise<reado
40
76
  * {@link SubagentActivity.replayed} so no surface offers to act on work that
41
77
  * finished in another process.
42
78
  */
43
- export declare function replaySavedChildren(children: readonly DelegatedChildRun[], log?: Logger): Promise<readonly SubagentActivity[]>;
79
+ export declare function replaySavedChildren(children: readonly SavedChild[], log?: Logger): Promise<readonly SubagentActivity[]>;
44
80
  /** Discovery and replay in one call, for a host that wants the whole list. */
45
81
  export declare function replaySavedChildrenFor(scope: SavedChildScope): Promise<readonly SubagentActivity[]>;
82
+ /** What one child's own log says, projected for the monitor. */
83
+ interface ChildLogEvidence {
84
+ readonly events: readonly SessionEvent[];
85
+ readonly partial: boolean;
86
+ readonly agentId?: string;
87
+ readonly model?: string;
88
+ readonly prompt?: string;
89
+ /** The child's last settled turn, for a child whose parent never recorded an ending. */
90
+ readonly terminal?: {
91
+ readonly status: TurnExecutionStatus;
92
+ readonly tokens: number;
93
+ readonly at: number;
94
+ };
95
+ }
96
+ /**
97
+ * A child's records as the live stream would have delivered them.
98
+ *
99
+ * Persisted events pass through unchanged: a record IS its event plus the
100
+ * envelope, and the projection reads only the event's own fields. An
101
+ * assistant `message` record stands in for the `text_delta`s that produced it
102
+ * (deltas are ephemeral and never reach a log), with any later
103
+ * `message_replaced` applied first, so a replay shows the answer the parent
104
+ * was given and never a raw one a guardrail or review replaced. Every other
105
+ * record-only type (checkpoints, decisions, audit, compaction) has no row.
106
+ */
107
+ export declare function projectChildLog(records: readonly SessionRecord[]): Omit<ChildLogEvidence, 'partial'>;
108
+ /** Milliseconds since the epoch of an ISO timestamp; NaN for a missing or unreadable one. */
109
+ export declare function timeOf(iso: string | undefined): number;
110
+ export {};
46
111
  //# sourceMappingURL=replay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/integrations/subagents/replay.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,MAAM,EAKX,MAAM,YAAY,CAAA;AAEnB,OAAO,EACN,KAAK,gBAAgB,EAGrB,MAAM,eAAe,CAAA;AA2BtB,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iB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CAAA;QACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KACnB,CAAA;CACD;AA4CD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC9B,OAAO,EAAE,SAAS,aAAa,EAAE,GAC/B,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CA+DnC;AAmCD,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEtD"}
@@ -1,81 +1,85 @@
1
- import { readdir } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { RunDiskStore, readRunEventsIn, } from '@namzu/sdk';
1
+ import { SESSION_EVENT_TYPES, asSessionId, readSessionLog, } from '@namzu/sdk';
4
2
  import { SubagentActivityMonitor, } from './activity.js';
5
3
  /**
6
- * Session directories scanned when looking for a conversation's saved
7
- * children.
4
+ * Child summaries one listing considers.
8
5
  *
9
- * Each delegated child is given its OWN session directory, so the children of
10
- * one parent run are spread across as many of them as the parent launched
11
- * children. A long-lived project accumulates those, and a scan with no
12
- * ceiling would grow with the whole estate rather than with the conversation
13
- * being opened. The scan is one `readdir` per directory and stops here.
14
- *
15
- * It is a bound, not a policy. Entries come back in the order the filesystem
16
- * lists them, so past this many directories WHICH children are found stops
17
- * being predictable — which is an argument for a prune command, not a
18
- * substitute for one.
6
+ * The index answers `listChildren` from one query, so this no longer bounds a
7
+ * directory scan. It bounds what one listing does with the answer: a
8
+ * conversation that delegated tens of thousands of times is still summarised
9
+ * from its most recent work rather than from its whole history. Children are
10
+ * taken newest first, so past this many it is the OLDEST that stop being
11
+ * counted.
19
12
  */
20
- const MAX_SCANNED_SESSION_DIRECTORIES = 2_000;
13
+ export const MAX_CONSIDERED_CHILDREN = 2_000;
21
14
  /**
22
15
  * Children replayed into one monitor, matching the live monitor's own
23
16
  * retention. Replay walks the newest first and stops at this many, so a
24
17
  * conversation that delegated thousands of times opens its most recent work
25
18
  * instead of its whole history.
26
19
  */
27
- const MAX_REPLAYED_CHILDREN = 80;
20
+ export const MAX_REPLAYED_CHILDREN = 80;
28
21
  /**
29
- * Every delegated child saved under one conversation's parent runs, newest
30
- * first.
31
- *
32
- * Two directory shapes have to meet here. A conversation's own runs are
33
- * `<sessionsRoot>/<sessionId>/runs/<runId>`, which is where the parent run
34
- * ids come from after a restart has forgotten them. A child's evidence is
35
- * `<sessionsRoot>/<childSessionId>/runs/<parentRunId>/children/<childRunId>`,
36
- * under the child's session and not the parent's — so finding a child means
37
- * asking every session directory whether it holds a `runs/` entry named after
38
- * one of this conversation's runs.
22
+ * Up to `limit` of a conversation's children, newest first.
39
23
  *
40
- * That ordering is deliberate: one `readdir` per session directory answers
41
- * the question for all of that directory's children at once, where probing
42
- * each parent run inside each session directory would multiply the two
43
- * counts. A child session directory holds exactly one parent run id, so the
44
- * inner listing runs only where there is something to list.
24
+ * The parent's log is the record of which children it spawned
25
+ * (`child_session_spawned`) and how each one ended (`child_session_ended`);
26
+ * the index derives {@link ChildSessionSummary} from exactly those records.
27
+ * The parent's log is refreshed first. A refresh that fails is reported and
28
+ * the index is asked anyway: a listing that is one child short is better than
29
+ * none, and the next refresh catches up.
45
30
  *
46
- * READ-ONLY throughout. Nothing here creates a directory, and in particular
47
- * nothing binds a `RunDiskStore`, which would mint the run directory it was
48
- * asked about.
31
+ * Nothing here writes a log, a meta file or a session directory. The only
32
+ * write is the refresh, which brings the rebuildable index up to date with a
33
+ * log it already derives from.
49
34
  */
50
- export async function listSavedChildren(scope) {
51
- const parentRunIds = new Set(await directoryNames(join(scope.sessionsRoot, scope.sessionId, 'runs')));
52
- if (parentRunIds.size === 0)
53
- return [];
54
- const sessionIds = await directoryNames(scope.sessionsRoot);
35
+ export async function readSavedChildren(scope, limit) {
36
+ return (await readSavedChildrenPage(scope, limit)).children;
37
+ }
38
+ /**
39
+ * The newest `limit` children, as {@link readSavedChildren}, plus how many
40
+ * children the index lists in all, so a bounded listing can say exactly how
41
+ * many it left out.
42
+ */
43
+ export async function readSavedChildrenPage(scope, limit) {
44
+ const sessionId = asSessionId(scope.session.sessionId);
45
+ try {
46
+ await scope.index.refresh({
47
+ slug: scope.paths.slug,
48
+ logPath: scope.paths.sessionLog(scope.session),
49
+ sessionId,
50
+ });
51
+ }
52
+ catch (error) {
53
+ scope.log?.warn('The conversation log could not be refreshed in the session index', {
54
+ 'namzu.subagent.replay.session_id': sessionId,
55
+ 'namzu.subagent.replay.error': errorMessage(error),
56
+ });
57
+ }
58
+ const children = [...(await scope.index.listChildren(sessionId))];
59
+ children.sort((left, right) => sortTime(right.spawnedAt) - sortTime(left.spawnedAt));
55
60
  const found = [];
56
- for (const sessionId of sessionIds.slice(0, MAX_SCANNED_SESSION_DIRECTORIES)) {
57
- const runsDir = join(scope.sessionsRoot, sessionId, 'runs');
58
- for (const runId of await directoryNames(runsDir)) {
59
- if (!parentRunIds.has(runId))
60
- continue;
61
- try {
62
- found.push(...(await RunDiskStore.listChildren(runsDir, runId)));
63
- }
64
- catch (error) {
65
- // One unreadable parent directory is not a reason to report that a
66
- // conversation delegated nothing. Named so the operator can find it.
67
- scope.log?.warn('Saved delegated children could not be listed', {
68
- 'namzu.subagent.replay.runs_dir': runsDir,
69
- 'namzu.subagent.replay.parent_run_id': runId,
70
- 'namzu.subagent.replay.error': errorMessage(error),
71
- });
72
- }
61
+ for (const child of children.slice(0, Math.max(0, limit))) {
62
+ try {
63
+ found.push({ ...child, logPath: scope.paths.subagentLog(scope.session, child.sessionId) });
64
+ }
65
+ catch (error) {
66
+ // A child id the layout refuses is not a path to read. Named so the
67
+ // operator can find the record that carried it.
68
+ scope.log?.warn('A saved child names an id the session layout refuses', {
69
+ 'namzu.subagent.replay.child_session_id': String(child.sessionId),
70
+ 'namzu.subagent.replay.error': errorMessage(error),
71
+ });
73
72
  }
74
73
  }
75
- // Newest first so the cap keeps the most recent work, then back into launch
76
- // order, which is the order the cockpit lists a cohort in.
77
- found.sort((left, right) => (right.startedAt ?? 0) - (left.startedAt ?? 0));
78
- return found.slice(0, scope.maxChildren ?? MAX_REPLAYED_CHILDREN).reverse();
74
+ return { children: found, total: children.length };
75
+ }
76
+ /**
77
+ * Every delegated child one conversation's turns spawned, in launch order,
78
+ * bounded to the newest {@link MAX_REPLAYED_CHILDREN}.
79
+ */
80
+ export async function listSavedChildren(scope) {
81
+ const newestFirst = await readSavedChildren(scope, scope.maxChildren ?? MAX_REPLAYED_CHILDREN);
82
+ return [...newestFirst].reverse();
79
83
  }
80
84
  /**
81
85
  * Replays saved children into the display shape the live monitor publishes.
@@ -88,23 +92,32 @@ export async function listSavedChildren(scope) {
88
92
  export async function replaySavedChildren(children, log) {
89
93
  const monitor = new SubagentActivityMonitor({ replay: true });
90
94
  for (const child of children) {
91
- const evidence = await readChildEvidence(child, log);
95
+ const evidence = await readChildLog(child, log);
96
+ const ended = child.endedAt !== undefined;
97
+ const status = ended ? child.status : evidence.terminal?.status;
98
+ const tokens = ended ? child.tokens : evidence.terminal?.tokens;
99
+ const completedAt = ended ? timeOf(child.endedAt) : evidence.terminal?.at;
100
+ const startedAt = timeOf(child.spawnedAt);
92
101
  monitor.replay({
93
- agentId: child.agentId ?? child.agentName ?? child.id,
94
- description: child.agentName ?? child.agentId ?? child.id,
95
- ...(child.model ? { model: child.model } : {}),
96
- runId: child.id,
97
- // A parent run is the display group a live cohort is keyed by, and
98
- // the batch a child belonged to is not recorded on disk. Grouping
99
- // every saved child of one parent run together is the coarsest
100
- // answer that is still true; splitting them by anything else would
101
- // invent a boundary the evidence does not have.
102
- workflowId: child.parentRunId,
103
- batchId: `saved:${child.parentRunId}`,
104
- ...(child.status ? { status: activityStatus(child.status) } : {}),
105
- ...(child.totalTokens !== undefined ? { tokens: child.totalTokens } : {}),
106
- ...(child.startedAt !== undefined ? { startedAt: child.startedAt } : {}),
107
- ...(child.endedAt !== undefined ? { completedAt: child.endedAt } : {}),
102
+ agentId: evidence.agentId ?? child.kind,
103
+ description: child.description,
104
+ ...(evidence.prompt !== undefined ? { prompt: evidence.prompt } : {}),
105
+ ...(evidence.model ? { model: evidence.model } : {}),
106
+ sessionId: child.sessionId,
107
+ // The parent turn is the display group a live cohort is keyed by
108
+ // (`workflowId` on a live row is the invoking turn's id), so a saved
109
+ // child groups under the same identity it had while it ran.
110
+ workflowId: child.parentTurnId,
111
+ batchId: child.batch?.batchId ?? `saved:${child.parentTurnId}`,
112
+ // The labels the parent recorded on `child_session_spawned.batch`:
113
+ // unlike a live-only annotation these survive the process, so a
114
+ // saved child comes back under the workflow and phase it ran in.
115
+ ...(child.batch?.name ? { workflow: child.batch.name } : {}),
116
+ ...(child.batch?.phase ? { phase: child.batch.phase } : {}),
117
+ ...(status ? { status: activityStatus(status) } : {}),
118
+ ...(tokens !== undefined ? { tokens } : {}),
119
+ ...(Number.isFinite(startedAt) ? { startedAt } : {}),
120
+ ...(completedAt !== undefined && Number.isFinite(completedAt) ? { completedAt } : {}),
108
121
  ...(evidence.partial ? { partial: true } : {}),
109
122
  }, evidence.events);
110
123
  }
@@ -114,49 +127,139 @@ export async function replaySavedChildren(children, log) {
114
127
  export async function replaySavedChildrenFor(scope) {
115
128
  return replaySavedChildren(await listSavedChildren(scope), scope.log);
116
129
  }
130
+ const LIVE_EVENT_TYPES = new Set(SESSION_EVENT_TYPES);
117
131
  /**
118
- * One child's durable events, and whether all of them could be read.
132
+ * One child's log as the events the live monitor projects, and whether all
133
+ * of it could be read.
119
134
  *
120
- * Read strictly first, then tolerantly. The strict pass is not about
121
- * refusing damaged evidence — it is the only way to LEARN that the evidence
122
- * is damaged, because the tolerant reader's whole job is to skip a torn
123
- * record and carry on, which leaves a truncated transcript indistinguishable
124
- * from a short one. A replay that quietly showed four rows of a forty-row run
125
- * would be the most misleading thing this view could do, so the damage is
126
- * reported instead: the rows that survive are shown, and the transcript says
127
- * it is partial.
135
+ * Read tolerantly, once. A tolerant read stops at the first break in the
136
+ * hash chain and says so (`intact: false`), and a torn final line is counted
137
+ * in `tornBytes`, so the read itself tells a damaged log from a short one. A
138
+ * replay that quietly showed four rows of a forty-row session would be the
139
+ * most misleading thing this view could do, so the damage is reported
140
+ * instead: the rows that survive are shown, and the transcript says it is
141
+ * partial.
128
142
  *
129
- * A transcript that cannot be read AT ALL — an unreadable file, or a
130
- * compaction archive beside it that the tolerant read cannot skip past
131
- * either — is the same answer taken to its limit: no rows, and partial. It is
132
- * not a reason to leave the child out of the listing. `run.json` still
133
- * records what the run did and when, dropping the row would say this child
134
- * never existed, and a row that shows the facts it has under a notice saying
135
- * the record is incomplete is the honest version of the same information.
143
+ * A log that cannot be read AT ALL — a missing file, or a path that is not a
144
+ * file — is the same answer taken to its limit: no rows, and partial. It is
145
+ * not a reason to leave the child out of the listing. The parent's log still
146
+ * records that the child was spawned and how it ended, dropping the row
147
+ * would say this child never existed, and a row that shows the facts it has
148
+ * under a notice saying the record is incomplete is the honest version of the
149
+ * same information.
136
150
  */
137
- async function readChildEvidence(child, log) {
138
- try {
139
- return { events: await readRunEventsIn(child.dir, { integrity: 'strict' }), partial: false };
140
- }
141
- catch {
142
- // Falls through to the tolerant read below.
143
- }
151
+ async function readChildLog(child, log) {
152
+ let entries;
153
+ let partial;
144
154
  try {
145
- return { events: await readRunEventsIn(child.dir), partial: true };
155
+ const read = await readSessionLog(child.logPath, {
156
+ mode: 'tolerant',
157
+ sessionId: child.sessionId,
158
+ });
159
+ entries = read.entries;
160
+ partial = !read.intact || read.tornBytes > 0 || read.entries.length === 0;
146
161
  }
147
162
  catch (error) {
148
- log?.warn('Saved child transcript could not be read', {
149
- 'namzu.subagent.replay.child_dir': child.dir,
163
+ log?.warn('Saved child log could not be read', {
164
+ 'namzu.subagent.replay.child_log': child.logPath,
150
165
  'namzu.subagent.replay.error': errorMessage(error),
151
166
  });
152
167
  return { events: [], partial: true };
153
168
  }
169
+ return { ...projectChildLog(entries.map((entry) => entry.record)), partial };
154
170
  }
155
171
  /**
156
- * A saved run status as the display status the monitor projects.
172
+ * A child's records as the live stream would have delivered them.
173
+ *
174
+ * Persisted events pass through unchanged: a record IS its event plus the
175
+ * envelope, and the projection reads only the event's own fields. An
176
+ * assistant `message` record stands in for the `text_delta`s that produced it
177
+ * (deltas are ephemeral and never reach a log), with any later
178
+ * `message_replaced` applied first, so a replay shows the answer the parent
179
+ * was given and never a raw one a guardrail or review replaced. Every other
180
+ * record-only type (checkpoints, decisions, audit, compaction) has no row.
181
+ */
182
+ export function projectChildLog(records) {
183
+ const replacements = new Map();
184
+ for (const record of records) {
185
+ if (record.type === 'message_replaced')
186
+ replacements.set(record.targetMessageId, record.content);
187
+ }
188
+ const events = [];
189
+ let agentId;
190
+ let model;
191
+ let prompt;
192
+ let terminal;
193
+ for (const record of records) {
194
+ switch (record.type) {
195
+ case 'session_started':
196
+ agentId ??= record.agent.id || record.agent.name || undefined;
197
+ continue;
198
+ case 'message': {
199
+ if (record.role === 'user' && record.kind === 'prompt' && prompt === undefined) {
200
+ const text = messageText(record.content);
201
+ if (text !== undefined)
202
+ prompt = text;
203
+ continue;
204
+ }
205
+ if (record.role !== 'assistant' || record.turnId === undefined)
206
+ continue;
207
+ const text = messageText(replacements.get(record.messageId) ?? record.content);
208
+ if (!text)
209
+ continue;
210
+ events.push({
211
+ type: 'text_delta',
212
+ sessionId: record.sessionId,
213
+ turnId: record.turnId,
214
+ iteration: 0,
215
+ messageId: record.messageId,
216
+ text,
217
+ });
218
+ continue;
219
+ }
220
+ case 'turn_started':
221
+ model ??= record.config.model || undefined;
222
+ break;
223
+ case 'turn_completed':
224
+ terminal = {
225
+ status: record.settlement.status,
226
+ tokens: record.settlement.usage.totalTokens,
227
+ at: timeOf(record.ts),
228
+ };
229
+ break;
230
+ case 'turn_failed':
231
+ terminal = {
232
+ status: 'failed',
233
+ tokens: record.settlement.usage.totalTokens,
234
+ at: timeOf(record.ts),
235
+ };
236
+ break;
237
+ default:
238
+ break;
239
+ }
240
+ if (LIVE_EVENT_TYPES.has(record.type))
241
+ events.push(record);
242
+ }
243
+ return {
244
+ events,
245
+ ...(agentId ? { agentId } : {}),
246
+ ...(model ? { model } : {}),
247
+ ...(prompt !== undefined ? { prompt } : {}),
248
+ ...(terminal ? { terminal } : {}),
249
+ };
250
+ }
251
+ /** The plain text of a message body, when it has one. */
252
+ function messageText(content) {
253
+ if (typeof content !== 'object' || content === null)
254
+ return undefined;
255
+ const body = content.content;
256
+ return typeof body === 'string' ? body : undefined;
257
+ }
258
+ /**
259
+ * A saved turn status as the display status the monitor projects.
157
260
  *
158
261
  * `running` survives as `working` rather than being rewritten to a terminal
159
- * value: a process killed mid-run genuinely did not record an ending, and
262
+ * value: a process killed mid-turn genuinely did not record an ending, and
160
263
  * claiming one would be a different lie from the one this view exists to
161
264
  * avoid. Nothing is attached to the row either way — `replayed` is what says
162
265
  * that, on every replayed row regardless of status.
@@ -177,15 +280,14 @@ function activityStatus(status) {
177
280
  return 'cancelled';
178
281
  }
179
282
  }
180
- /** Directory entries by name; an absent directory lists as nothing. */
181
- async function directoryNames(dir) {
182
- try {
183
- const entries = await readdir(dir, { withFileTypes: true });
184
- return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
185
- }
186
- catch {
187
- return [];
188
- }
283
+ /** Milliseconds since the epoch of an ISO timestamp; NaN for a missing or unreadable one. */
284
+ export function timeOf(iso) {
285
+ return iso === undefined ? Number.NaN : Date.parse(iso);
286
+ }
287
+ /** {@link timeOf} for ordering: an unreadable time sorts as the oldest. */
288
+ function sortTime(iso) {
289
+ const time = timeOf(iso);
290
+ return Number.isFinite(time) ? time : 0;
189
291
  }
190
292
  function errorMessage(error) {
191
293
  return error instanceof Error ? error.message : String(error);
@@ -1 +1 @@
1
- {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/integrations/subagents/replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAIN,YAAY,EAEZ,eA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