@esso0428/pi-subagents 0.15.5 → 0.15.7

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 (234) hide show
  1. package/CHANGELOG.md +10 -19
  2. package/README.md +5 -5
  3. package/dist/agent-history-list.d.ts +19 -0
  4. package/dist/agent-history-list.d.ts.map +1 -0
  5. package/dist/agent-history-list.js +69 -0
  6. package/dist/agent-history-list.js.map +1 -0
  7. package/dist/agent-history.d.ts +2 -1
  8. package/dist/agent-history.d.ts.map +1 -0
  9. package/dist/agent-history.js +32 -34
  10. package/dist/agent-history.js.map +1 -0
  11. package/dist/agent-manager.d.ts +24 -8
  12. package/dist/agent-manager.d.ts.map +1 -0
  13. package/dist/agent-manager.js +171 -93
  14. package/dist/agent-manager.js.map +1 -0
  15. package/dist/agent-runner.d.ts +1 -0
  16. package/dist/agent-runner.d.ts.map +1 -0
  17. package/dist/agent-runner.js +75 -86
  18. package/dist/agent-runner.js.map +1 -0
  19. package/dist/agent-types.d.ts +1 -0
  20. package/dist/agent-types.d.ts.map +1 -0
  21. package/dist/agent-types.js +28 -45
  22. package/dist/agent-types.js.map +1 -0
  23. package/dist/context.d.ts +1 -0
  24. package/dist/context.d.ts.map +1 -0
  25. package/dist/context.js +3 -6
  26. package/dist/context.js.map +1 -0
  27. package/dist/cross-extension-rpc.d.ts +1 -0
  28. package/dist/cross-extension-rpc.d.ts.map +1 -0
  29. package/dist/cross-extension-rpc.js +6 -9
  30. package/dist/cross-extension-rpc.js.map +1 -0
  31. package/dist/custom-agents.d.ts +1 -0
  32. package/dist/custom-agents.d.ts.map +1 -0
  33. package/dist/custom-agents.js +16 -18
  34. package/dist/custom-agents.js.map +1 -0
  35. package/dist/default-agents.d.ts +1 -0
  36. package/dist/default-agents.d.ts.map +1 -0
  37. package/dist/default-agents.js +2 -4
  38. package/dist/default-agents.js.map +1 -0
  39. package/dist/enabled-models.d.ts +1 -0
  40. package/dist/enabled-models.d.ts.map +1 -0
  41. package/dist/enabled-models.js +12 -16
  42. package/dist/enabled-models.js.map +1 -0
  43. package/dist/env.d.ts +1 -0
  44. package/dist/env.d.ts.map +1 -0
  45. package/dist/env.js +2 -4
  46. package/dist/env.js.map +1 -0
  47. package/dist/group-join.d.ts +1 -0
  48. package/dist/group-join.d.ts.map +1 -0
  49. package/dist/group-join.js +2 -5
  50. package/dist/group-join.js.map +1 -0
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +306 -292
  54. package/dist/index.js.map +1 -0
  55. package/dist/invocation-config.d.ts +1 -0
  56. package/dist/invocation-config.d.ts.map +1 -0
  57. package/dist/invocation-config.js +3 -6
  58. package/dist/invocation-config.js.map +1 -0
  59. package/dist/memory.d.ts +1 -0
  60. package/dist/memory.d.ts.map +1 -0
  61. package/dist/memory.js +25 -34
  62. package/dist/memory.js.map +1 -0
  63. package/dist/model-resolver.d.ts +1 -0
  64. package/dist/model-resolver.d.ts.map +1 -0
  65. package/dist/model-resolver.js +2 -4
  66. package/dist/model-resolver.js.map +1 -0
  67. package/dist/nico-overrides.d.ts +1 -0
  68. package/dist/nico-overrides.d.ts.map +1 -0
  69. package/dist/nico-overrides.js +15 -20
  70. package/dist/nico-overrides.js.map +1 -0
  71. package/dist/output-file.d.ts +1 -0
  72. package/dist/output-file.d.ts.map +1 -0
  73. package/dist/output-file.js +17 -22
  74. package/dist/output-file.js.map +1 -0
  75. package/dist/prompts.d.ts +1 -0
  76. package/dist/prompts.d.ts.map +1 -0
  77. package/dist/prompts.js +2 -4
  78. package/dist/prompts.js.map +1 -0
  79. package/dist/schedule-store.d.ts +1 -0
  80. package/dist/schedule-store.d.ts.map +1 -0
  81. package/dist/schedule-store.js +17 -21
  82. package/dist/schedule-store.js.map +1 -0
  83. package/dist/schedule.d.ts +1 -0
  84. package/dist/schedule.d.ts.map +1 -0
  85. package/dist/schedule.js +9 -12
  86. package/dist/schedule.js.map +1 -0
  87. package/dist/settings.d.ts +1 -0
  88. package/dist/settings.d.ts.map +1 -0
  89. package/dist/settings.js +16 -23
  90. package/dist/settings.js.map +1 -0
  91. package/dist/skill-loader.d.ts +1 -0
  92. package/dist/skill-loader.d.ts.map +1 -0
  93. package/dist/skill-loader.js +21 -23
  94. package/dist/skill-loader.js.map +1 -0
  95. package/dist/status-note.d.ts +1 -0
  96. package/dist/status-note.d.ts.map +1 -0
  97. package/dist/status-note.js +2 -4
  98. package/dist/status-note.js.map +1 -0
  99. package/dist/types.d.ts +5 -1
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +2 -4
  102. package/dist/types.js.map +1 -0
  103. package/dist/ui/agent-widget.d.ts +2 -5
  104. package/dist/ui/agent-widget.d.ts.map +1 -0
  105. package/dist/ui/agent-widget.js +29 -51
  106. package/dist/ui/agent-widget.js.map +1 -0
  107. package/dist/ui/ccstyle/diff/ansi-utils.d.ts +11 -0
  108. package/dist/ui/ccstyle/diff/ansi-utils.d.ts.map +1 -0
  109. package/dist/ui/ccstyle/diff/ansi-utils.js +145 -0
  110. package/dist/ui/ccstyle/diff/ansi-utils.js.map +1 -0
  111. package/dist/ui/ccstyle/diff/diff-presentation.d.ts +12 -0
  112. package/dist/ui/ccstyle/diff/diff-presentation.d.ts.map +1 -0
  113. package/dist/ui/ccstyle/diff/diff-presentation.js +49 -0
  114. package/dist/ui/ccstyle/diff/diff-presentation.js.map +1 -0
  115. package/dist/ui/ccstyle/diff/diff-renderer.d.ts +46 -0
  116. package/dist/ui/ccstyle/diff/diff-renderer.d.ts.map +1 -0
  117. package/dist/ui/ccstyle/diff/diff-renderer.js +2044 -0
  118. package/dist/ui/ccstyle/diff/diff-renderer.js.map +1 -0
  119. package/dist/ui/ccstyle/diff/line-width-safety.d.ts +12 -0
  120. package/dist/ui/ccstyle/diff/line-width-safety.d.ts.map +1 -0
  121. package/dist/ui/ccstyle/diff/line-width-safety.js +59 -0
  122. package/dist/ui/ccstyle/diff/line-width-safety.js.map +1 -0
  123. package/dist/ui/ccstyle/diff/render-utils.d.ts +6 -0
  124. package/dist/ui/ccstyle/diff/render-utils.d.ts.map +1 -0
  125. package/dist/ui/ccstyle/diff/render-utils.js +25 -0
  126. package/dist/ui/ccstyle/diff/render-utils.js.map +1 -0
  127. package/dist/ui/ccstyle/diff/types.d.ts +22 -0
  128. package/dist/ui/ccstyle/diff/types.d.ts.map +1 -0
  129. package/dist/ui/ccstyle/diff/types.js +10 -0
  130. package/dist/ui/ccstyle/diff/types.js.map +1 -0
  131. package/dist/ui/ccstyle/diff/write-display-utils.d.ts +2 -0
  132. package/dist/ui/ccstyle/diff/write-display-utils.d.ts.map +1 -0
  133. package/dist/ui/ccstyle/diff/write-display-utils.js +12 -0
  134. package/dist/ui/ccstyle/diff/write-display-utils.js.map +1 -0
  135. package/dist/ui/ccstyle/tool-renderer.d.ts +17 -0
  136. package/dist/ui/ccstyle/tool-renderer.d.ts.map +1 -0
  137. package/dist/ui/ccstyle/tool-renderer.js +58 -0
  138. package/dist/ui/ccstyle/tool-renderer.js.map +1 -0
  139. package/dist/ui/ccstyle/tool-result.d.ts +24 -0
  140. package/dist/ui/ccstyle/tool-result.d.ts.map +1 -0
  141. package/dist/ui/ccstyle/tool-result.js +193 -0
  142. package/dist/ui/ccstyle/tool-result.js.map +1 -0
  143. package/dist/ui/conversation-blocks.d.ts +46 -0
  144. package/dist/ui/conversation-blocks.d.ts.map +1 -0
  145. package/dist/ui/conversation-blocks.js +306 -0
  146. package/dist/ui/conversation-blocks.js.map +1 -0
  147. package/dist/ui/conversation-nvim.d.ts +8 -0
  148. package/dist/ui/conversation-nvim.d.ts.map +1 -0
  149. package/dist/ui/conversation-nvim.js +117 -0
  150. package/dist/ui/conversation-nvim.js.map +1 -0
  151. package/dist/ui/conversation-role.d.ts +13 -0
  152. package/dist/ui/conversation-role.d.ts.map +1 -0
  153. package/dist/ui/conversation-role.js +39 -0
  154. package/dist/ui/conversation-role.js.map +1 -0
  155. package/dist/ui/conversation-search.d.ts +39 -0
  156. package/dist/ui/conversation-search.d.ts.map +1 -0
  157. package/dist/ui/conversation-search.js +124 -0
  158. package/dist/ui/conversation-search.js.map +1 -0
  159. package/dist/ui/conversation-timeline.d.ts +62 -0
  160. package/dist/ui/conversation-timeline.d.ts.map +1 -0
  161. package/dist/ui/conversation-timeline.js +263 -0
  162. package/dist/ui/conversation-timeline.js.map +1 -0
  163. package/dist/ui/conversation-viewer.d.ts +62 -20
  164. package/dist/ui/conversation-viewer.d.ts.map +1 -0
  165. package/dist/ui/conversation-viewer.js +449 -224
  166. package/dist/ui/conversation-viewer.js.map +1 -0
  167. package/dist/ui/fleet-list.d.ts +24 -11
  168. package/dist/ui/fleet-list.d.ts.map +1 -0
  169. package/dist/ui/fleet-list.js +86 -78
  170. package/dist/ui/fleet-list.js.map +1 -0
  171. package/dist/ui/schedule-menu.d.ts +1 -0
  172. package/dist/ui/schedule-menu.d.ts.map +1 -0
  173. package/dist/ui/schedule-menu.js +2 -4
  174. package/dist/ui/schedule-menu.js.map +1 -0
  175. package/dist/ui/viewer-keys.d.ts +1 -0
  176. package/dist/ui/viewer-keys.d.ts.map +1 -0
  177. package/dist/ui/viewer-keys.js +8 -10
  178. package/dist/ui/viewer-keys.js.map +1 -0
  179. package/dist/usage.d.ts +1 -0
  180. package/dist/usage.d.ts.map +1 -0
  181. package/dist/usage.js +5 -10
  182. package/dist/usage.js.map +1 -0
  183. package/dist/worktree.d.ts +1 -0
  184. package/dist/worktree.d.ts.map +1 -0
  185. package/dist/worktree.js +27 -31
  186. package/dist/worktree.js.map +1 -0
  187. package/dist/write-execution.d.ts +42 -0
  188. package/dist/write-execution.d.ts.map +1 -0
  189. package/dist/write-execution.js +138 -0
  190. package/dist/write-execution.js.map +1 -0
  191. package/package.json +1 -1
  192. package/src/agent-history-list.ts +91 -0
  193. package/src/agent-history.ts +12 -17
  194. package/src/agent-manager.ts +169 -81
  195. package/src/agent-runner.ts +12 -13
  196. package/src/index.ts +117 -98
  197. package/src/output-file.ts +1 -1
  198. package/src/types.ts +4 -1
  199. package/src/ui/agent-widget.ts +3 -9
  200. package/src/ui/ccstyle/ATTRIBUTION.md +37 -0
  201. package/src/ui/ccstyle/diff/ansi-utils.ts +168 -0
  202. package/src/ui/ccstyle/diff/diff-presentation.ts +70 -0
  203. package/src/ui/ccstyle/diff/diff-renderer.ts +3148 -0
  204. package/src/ui/ccstyle/diff/line-width-safety.ts +92 -0
  205. package/src/ui/ccstyle/diff/render-utils.ts +32 -0
  206. package/src/ui/ccstyle/diff/types.ts +33 -0
  207. package/src/ui/ccstyle/diff/write-display-utils.ts +12 -0
  208. package/src/ui/ccstyle/tool-renderer.ts +71 -0
  209. package/src/ui/ccstyle/tool-result.ts +238 -0
  210. package/src/ui/conversation-blocks.ts +404 -0
  211. package/src/ui/conversation-nvim.ts +127 -0
  212. package/src/ui/conversation-role.ts +45 -0
  213. package/src/ui/conversation-search.ts +161 -0
  214. package/src/ui/conversation-timeline.ts +315 -0
  215. package/src/ui/conversation-viewer.ts +418 -210
  216. package/src/ui/fleet-list.ts +73 -52
  217. package/src/write-execution.ts +180 -0
  218. package/test/agent-history-list.test.ts +121 -0
  219. package/test/agent-manager-history.test.ts +59 -58
  220. package/test/agent-menu-history-navigation.test.ts +86 -0
  221. package/test/output-file-history.test.ts +50 -0
  222. package/test/ui/conversation-blocks.test.ts +103 -0
  223. package/test/ui/conversation-diff.test.ts +91 -0
  224. package/test/ui/conversation-search.test.ts +55 -0
  225. package/test/ui/conversation-viewer.test.ts +182 -0
  226. package/test/ui/fleet-list.test.ts +131 -0
  227. package/test/write-execution.test.ts +83 -0
  228. package/tsconfig.json +16 -0
  229. package/vitest.temp.config.mts +6 -0
  230. package/dist/ui/markdown-result.d.ts +0 -3
  231. package/dist/ui/markdown-result.js +0 -53
  232. package/src/ui/markdown-result.ts +0 -56
  233. package/test/agent-history.test.ts +0 -63
  234. package/test/ui/markdown-result.test.ts +0 -45
package/CHANGELOG.md CHANGED
@@ -7,30 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.15.5] - 2026-09-11
11
-
12
- ### Fixed
13
- - **The Running agents menu no longer advertises dead-end metadata.** Its summary count now uses the same live-session or existing-transcript filter as the detail list, so Enter does not open an empty list for stale restored records.
14
-
15
- ## [0.15.4] - 2026-09-11
16
-
17
- ### Fixed
18
- - **Unavailable history records no longer load the subagent panels.** Reload-restored metadata is shown in AgentWidget, FleetView, and `/agents` only when its project-local transcript still exists; stale records remain available through the normal session result/history data without creating a dead-end Enter target.
19
-
20
- ## [0.15.3] - 2026-09-11
10
+ ## [0.15.7] - 2026-09-12
21
11
 
22
12
  ### Added
23
- - **Reload-safe transcript history.** Agents now keep a project-local copy under `.pi-subagents/agent-transcripts/`; terminal records persist a relative locator and `/agents`/FleetView can open a read-only history viewer after reload. The shared `.pi-subagents/.gitignore` is created with `*` to keep private transcripts out of git.
13
+ - **Conversation history now uses a viewer-local component timeline** with semantic USER/ASSISTANT/tool headers, visible search input, model/thinking metadata, keyboard and normalized mouse tool expansion, and ccstyle-compatible bounded tool/diff cards.
14
+ - **Durable edit/write result metadata is rendered after history reload** without rereading the current file; older Pi hosts use a safe local fallback.
24
15
 
25
- ## [0.15.2] - 2026-09-10
26
-
27
- ### Added
28
- - **Completed subagent records survive session reloads.** On `session_start`, the extension now reconstructs validated terminal records persisted as `subagents:record` entries. Restored records retain their result and status for `get_subagent_result`, but never pretend to have a live child session; running and queued records are ignored, and duplicate IDs use the newest branch entry.
16
+ ### Fixed
17
+ - **Terminal agent records retain durable history stubs after TTL cleanup**, while live session handles are released; duplicate history/menu labels now resolve to the exact selected record.
29
18
 
30
- ## [0.15.1] - 2026-09-10
19
+ ## [0.15.6] - 2026-09-11
31
20
 
32
- ### Added
33
- - **Markdown-rendered subagent results.** Expanded foreground results and background completion notifications now render headings, lists, inline code, and fenced code through pi's Markdown renderer. Display output is capped to keep terminal notifications bounded; use `get_subagent_result` for the complete result.
21
+ ### Fixed
22
+ - **FleetView stays within a six-row budget** while preserving full-roster keyboard navigation, selected-row visibility, overflow indicators, and prompt-area separation.
23
+ - **Agent history and live FleetView are routed separately**, keeping terminal records in the read-only history viewer instead of treating them as active sessions.
24
+ - **Pi 0.85.1 model-runtime type compatibility** is restored without changing the legacy fallback path.
34
25
 
35
26
  ## [0.14.3] - 2026-07-23
36
27
 
package/README.md CHANGED
@@ -28,7 +28,7 @@ https://github.com/user-attachments/assets/8685261b-9338-4fea-8dfe-1c590d5df543
28
28
  - **Git worktree isolation** — run agents in isolated repo copies; changes auto-committed to branches on completion
29
29
  - **Skill preloading** — inject named skills into agent system prompts, discovered from `.pi/skills/`, `.agents/skills/`, and global locations (Pi-standard `<name>/SKILL.md` directory layout supported)
30
30
  - **Tool denylist** — block specific tools via `disallowed_tools` frontmatter
31
- - **Styled completion notifications** — background agent results render as themed, compact notification boxes (icon, stats, result preview) instead of raw XML. Expanded results render headings, lists, inline code, and fenced code as Markdown, with a bounded display to keep the TUI responsive. Group completions render each agent individually
31
+ - **Styled completion notifications** — background agent results render as themed, compact notification boxes (icon, stats, result preview) instead of raw XML. Expandable to show full output. Group completions render each agent individually
32
32
  - **Event bus** — lifecycle events (`subagents:created`, `started`, `completed`, `failed`, `steered`, `compacted`) emitted via `pi.events`, enabling other extensions to react to sub-agent activity
33
33
  - **Cross-extension RPC** — other pi extensions can spawn and stop subagents via the `pi.events` event bus (`subagents:rpc:ping`, `subagents:rpc:spawn`, `subagents:rpc:stop`). Standardized reply envelopes with protocol versioning. Emits `subagents:ready` on session start
34
34
  - **Schedule subagents** — pass `schedule` to the `Agent` tool to fire on cron / interval / one-shot. Session-scoped jobs with PID-locked persistence; results land via the same `subagent-notification` followUp path as manual background completions; manage via `/agents → Scheduled jobs`
@@ -138,9 +138,9 @@ Individual agent results render Claude Code-style in the conversation:
138
138
  | **Error** | `✗ ↻3 · 3 tool uses · 12.4k token (8%)` / `⎿ Error: timeout` |
139
139
  | **Aborted** | `✗ ↻55≤50 · 55 tool uses · 102.3k token (95% · ⇊3)` / `⎿ Aborted (max turns exceeded)` |
140
140
 
141
- Completed results can be expanded (ctrl+o in pi) to show the agent output inline with Markdown formatting. Expanded output is capped at 50 rendered lines (background notification results at 30 lines) and ends with a marker when more output is available; use `get_subagent_result` for the complete result.
141
+ Completed results can be expanded (ctrl+o in pi) to show the full agent output inline.
142
142
 
143
- By default, foreground and background agents stream their full conversation to two per-subagent transcripts: the existing temporary JSON-lines file at `<os-tmpdir>/pi-subagents-<uid>/<cwd>/<session>/tasks/<agent-id>.output` (owner-only `0700`, cleared on reboot), plus a durable copy at `<cwd>/.pi-subagents/agent-transcripts/<agent-id>_<agent-type>_transcript.jsonl`. The project-local `.pi-subagents/.gitignore` contains `*` so these private transcripts are not accidentally uploaded to git. After `/reload`, terminal records use the durable locator to open a read-only history viewer. Set `output_transcript: false` on a custom agent, or `outputTranscript: false` in `subagents.json`, to suppress both transcript files. This governs **only** the transcript: it is independent of `persist_session` (the pi session on disk), and it does not affect `isolation: worktree` or `memory:`. Background agent completion notifications render as styled boxes:
143
+ By default, foreground and background agents each stream their full conversation to a per-subagent transcript — a JSON-lines file at `<os-tmpdir>/pi-subagents-<uid>/<cwd>/<session>/tasks/<agent-id>.output` (owner-only `0700`, cleared on reboot). Set `output_transcript: false` on a custom agent to write no transcript path or file for it, or set `outputTranscript: false` in `subagents.json` to make transcripts opt-in for the whole project (frontmatter overrides the project default). This governs **only** the transcript: it is independent of `persist_session` (the pi session on disk), and it does not affect `isolation: worktree` (which commits the agent's work to a git branch) or `memory:` (durable files) — set those accordingly if the goal is to keep a run off disk entirely. Background agent completion notifications render as styled boxes:
144
144
 
145
145
  ```
146
146
  ✓ Find auth files completed
@@ -222,7 +222,7 @@ All fields are optional — sensible defaults for everything.
222
222
  | `thinking` | inherit | off, minimal, low, medium, high, xhigh, max — actual availability depends on your pi version and model; pi clamps unsupported levels down |
223
223
  | `max_turns` | unlimited | Max agentic turns before graceful shutdown. `0` or omit for unlimited |
224
224
  | `persist_session` | `false` | Persist this subagent as a normal pi session instead of keeping the session in memory only. The subagent's `.output` transcript is still written either way unless `output_transcript: false` |
225
- | `output_transcript` | `true` (or `subagents.json` `outputTranscript`) | Write the temporary `.output` transcript and durable `.pi-subagents/agent-transcripts/` copy; when set, overrides the `subagents.json` `outputTranscript` default. Set `false` to write neither. Governs only the transcript — independent of `persist_session`, `isolation: worktree`, and `memory:` |
225
+ | `output_transcript` | `true` (or `subagents.json` `outputTranscript`) | Write this subagent's `.output` transcript; when set, overrides the `subagents.json` `outputTranscript` default. Set `false` to write no transcript file or path. Governs only the transcript — independent of `persist_session`, `isolation: worktree`, and `memory:` |
226
226
  | `session_dir` | pi default | Optional session directory when `persist_session: true`; omitted uses pi's normal session location, and relative paths resolve from the agent cwd |
227
227
  | `prompt_mode` | `replace` | `replace`: body is the full system prompt (no AGENTS.md / CLAUDE.md inheritance). `append`: body appended to parent's prompt (agent acts as a "parent twin" — inherits parent's AGENTS.md / CLAUDE.md) |
228
228
  | `inherit_context` | `false` | Fork parent conversation into agent |
@@ -508,7 +508,7 @@ Runtime tuning values set via `/agents` → Settings (max concurrency, default m
508
508
 
509
509
  **Disable defaults** (`disableDefaultAgents`, default `false`): when on, the three built-in agents (general-purpose, Explore, Plan) are not registered — only your project/global custom agents are advertised and spawnable. User-defined agents are unaffected, including ones that override a default by name. The Agent tool's type list updates on the next pi session (the tool schema is registered at startup).
510
510
 
511
- **Output transcript** (`outputTranscript`, default `true`): the project/global default for writing each subagent's temporary `.output` transcript and durable project-local history copy under `.pi-subagents/agent-transcripts/`. Toggle via `/agents → Settings → Output transcript`, or set `false` in `subagents.json` to make both transcripts opt-in project-wide. A custom agent's `output_transcript` frontmatter overrides this per agent. Applied live at spawn time. Governs only the transcript, not `persist_session`, worktree commits, or memory files.
511
+ **Output transcript** (`outputTranscript`, default `true`): the project/global default for writing each subagent's `.output` transcript. Toggle via `/agents → Settings → Output transcript`, or set `false` in `subagents.json` to make transcripts opt-in project-wide — useful when run transcripts shouldn't sit on disk for backup or DLP tooling to pick up. A custom agent's `output_transcript` frontmatter overrides this per agent. Applied live at spawn time. Governs only the transcript, not `persist_session`, worktree commits, or memory files.
512
512
 
513
513
  **Tool description** (`toolDescriptionMode`, default `"full"`): which Agent tool description the LLM sees. `"full"` is the rich Claude Code-style prompt (~1,400 tokens with the default agents); `"compact"` is ~75% smaller — one-line agent type list, terse usage notes — for small/local models where tool-spec tokens are expensive. Per-option details stay in the parameter descriptions in every mode (the parameter schema is never customizable). Applies on the next pi session.
514
514
 
@@ -0,0 +1,19 @@
1
+ /** Helpers for separating openable active agents from terminal history. */
2
+ import type { AgentRecord } from "./types.js";
3
+ export type AgentHistoryStatus = "completed" | "steered" | "stopped" | "aborted" | "error";
4
+ /** Return whether a record status represents a terminal agent run. */
5
+ export declare function isTerminalAgentStatus(status: string): status is AgentHistoryStatus;
6
+ /** Return whether an active record has a live session that can be opened. */
7
+ export declare function canOpenActiveAgent(record: AgentRecord): boolean;
8
+ /** Return whether a terminal record has an in-memory or durable conversation. */
9
+ export declare function canOpenAgentHistory(record: AgentRecord, cwd: string | undefined): boolean;
10
+ /** Split records into openable active and terminal-history buckets. */
11
+ export declare function splitAgentRecords(records: readonly AgentRecord[], cwd: string | undefined): {
12
+ active: AgentRecord[];
13
+ history: AgentRecord[];
14
+ };
15
+ /** Format a bounded, single-line history menu option. */
16
+ export declare function formatAgentHistoryOption(record: AgentRecord, now: number): string;
17
+ /** Build the visible status-section labels for the agents menu. */
18
+ export declare function buildAgentStatusMenuEntries(records: readonly AgentRecord[], cwd: string | undefined): string[];
19
+ //# sourceMappingURL=agent-history-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history-list.d.ts","sourceRoot":"","sources":["../src/agent-history-list.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAG3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAUZ,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,kBAAkB,CAElF;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAG/D;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIzF;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB;IAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,CAanD;AAWD,yDAAyD;AACzD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CASjF;AAED,mEAAmE;AACnE,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,MAAM,EAAE,CAMV"}
@@ -0,0 +1,69 @@
1
+ /** Helpers for separating openable active agents from terminal history. */
2
+ import { hasAgentHistory } from "./agent-history.js";
3
+ import { getAgentConfig } from "./agent-types.js";
4
+ import { formatDuration, getDisplayName } from "./ui/agent-widget.js";
5
+ const TERMINAL_STATUSES = new Set([
6
+ "completed",
7
+ "steered",
8
+ "stopped",
9
+ "aborted",
10
+ "error",
11
+ ]);
12
+ /** Return whether a record status represents a terminal agent run. */
13
+ export function isTerminalAgentStatus(status) {
14
+ return TERMINAL_STATUSES.has(status);
15
+ }
16
+ /** Return whether an active record has a live session that can be opened. */
17
+ export function canOpenActiveAgent(record) {
18
+ return (record.status === "running" || record.status === "queued")
19
+ && record.session !== undefined;
20
+ }
21
+ /** Return whether a terminal record has an in-memory or durable conversation. */
22
+ export function canOpenAgentHistory(record, cwd) {
23
+ if (!isTerminalAgentStatus(record.status))
24
+ return false;
25
+ return record.session !== undefined
26
+ || (cwd !== undefined && hasAgentHistory(cwd, record.transcriptPath));
27
+ }
28
+ /** Split records into openable active and terminal-history buckets. */
29
+ export function splitAgentRecords(records, cwd) {
30
+ const active = [];
31
+ const history = [];
32
+ for (const record of records) {
33
+ if (canOpenActiveAgent(record)) {
34
+ active.push(record);
35
+ }
36
+ else if (canOpenAgentHistory(record, cwd)) {
37
+ history.push(record);
38
+ }
39
+ }
40
+ return { active, history };
41
+ }
42
+ const DESCRIPTION_LIMIT = 72;
43
+ const LABEL_LIMIT = 140;
44
+ function boundedDescription(description) {
45
+ const line = description.split("\n").find((part) => part.trim())?.trim() ?? "";
46
+ if (line.length <= DESCRIPTION_LIMIT)
47
+ return line;
48
+ return `${line.slice(0, DESCRIPTION_LIMIT - 1)}…`;
49
+ }
50
+ /** Format a bounded, single-line history menu option. */
51
+ export function formatAgentHistoryOption(record, now) {
52
+ const duration = formatDuration(record.startedAt, record.completedAt ?? now);
53
+ // Unit consumers may format persisted records before the registry has been
54
+ // initialized; preserve the persisted type instead of falling back to
55
+ // general-purpose's generic display name in that case.
56
+ const displayName = getAgentConfig(record.type)?.displayName
57
+ ?? (record.type === "general-purpose" ? getDisplayName(record.type) : record.type);
58
+ const option = `[${record.status}] ${displayName} · ${boundedDescription(record.description)} · ${duration}`;
59
+ return option.length <= LABEL_LIMIT ? option : `${option.slice(0, LABEL_LIMIT - 1)}…`;
60
+ }
61
+ /** Build the visible status-section labels for the agents menu. */
62
+ export function buildAgentStatusMenuEntries(records, cwd) {
63
+ const { active, history } = splitAgentRecords(records, cwd);
64
+ return [
65
+ ...(active.length > 0 ? [`Running agents (${active.length})`] : []),
66
+ ...(history.length > 0 ? [`Agent history (${history.length})`] : []),
67
+ ];
68
+ }
69
+ //# sourceMappingURL=agent-history-list.js.map
@@ -0,0 +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kB,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,QAAQ,EAAE,CAAC;IAC7G,OAAO,MAAM,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC;AACxF,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,2BAA2B,CACzC,OAA+B,EAC/B,GAAuB;IAEvB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5D,OAAO;QACL,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACrE,CAAC;AACJ,CAAC"}
@@ -9,7 +9,7 @@ import type { AgentSession } from "@earendil-works/pi-coding-agent";
9
9
  */
10
10
  export declare function ensureSubagentsGitignore(cwd: string): string;
11
11
  /** Return the durable transcript path for an agent. */
12
- export declare function createAgentHistoryPath(cwd: string, agentId: string, agentType?: string): string;
12
+ export declare function createAgentHistoryPath(cwd: string, agentId: string): string;
13
13
  /** Return the project-relative path stored in the parent session record. */
14
14
  export declare function agentHistoryLocator(cwd: string, historyPath: string): string;
15
15
  /** Resolve only paths in this package's project-local transcript namespace. */
@@ -22,3 +22,4 @@ export declare function hasAgentHistory(cwd: string, locator: string | undefined
22
22
  * damaged entry cannot hide the rest of a history.
23
23
  */
24
24
  export declare function readAgentHistory(cwd: string, locator: string): AgentSession["messages"] | undefined;
25
+ //# sourceMappingURL=agent-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history.d.ts","sourceRoot":"","sources":["../src/agent-history.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAe5D;AAED,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAM3E;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,+EAA+E;AAC/E,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWxF;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIjF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CA2BnG"}
@@ -1,14 +1,6 @@
1
- "use strict";
2
1
  /** Durable, project-local transcript storage for subagents. */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ensureSubagentsGitignore = ensureSubagentsGitignore;
5
- exports.createAgentHistoryPath = createAgentHistoryPath;
6
- exports.agentHistoryLocator = agentHistoryLocator;
7
- exports.resolveAgentHistoryPath = resolveAgentHistoryPath;
8
- exports.hasAgentHistory = hasAgentHistory;
9
- exports.readAgentHistory = readAgentHistory;
10
- const node_fs_1 = require("node:fs");
11
- const node_path_1 = require("node:path");
2
+ import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
3
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
12
4
  const SUBAGENTS_DIR = ".pi-subagents";
13
5
  const TRANSCRIPTS_DIR = "agent-transcripts";
14
6
  const MAX_HISTORY_BYTES = 20 * 1024 * 1024;
@@ -19,65 +11,70 @@ const MAX_HISTORY_BYTES = 20 * 1024 * 1024;
19
11
  * existing user-owned rules and makes concurrent callers harmless (duplicate
20
12
  * `*` rules are semantically equivalent).
21
13
  */
22
- function ensureSubagentsGitignore(cwd) {
23
- const directory = (0, node_path_1.join)(cwd, SUBAGENTS_DIR);
24
- (0, node_fs_1.mkdirSync)(directory, { recursive: true });
25
- const path = (0, node_path_1.join)(directory, ".gitignore");
14
+ export function ensureSubagentsGitignore(cwd) {
15
+ const directory = join(cwd, SUBAGENTS_DIR);
16
+ mkdirSync(directory, { recursive: true });
17
+ const path = join(directory, ".gitignore");
26
18
  let content = "";
27
19
  try {
28
- content = (0, node_fs_1.readFileSync)(path, "utf8");
20
+ content = readFileSync(path, "utf8");
29
21
  }
30
22
  catch {
31
23
  // The append below also creates a missing file.
32
24
  }
33
25
  if (!content.split(/\r?\n/).some((line) => line.trim() === "*")) {
34
26
  const separator = content.length > 0 && !/[\r\n]$/.test(content) ? "\n" : "";
35
- (0, node_fs_1.appendFileSync)(path, `${separator}*\n`, "utf8");
27
+ appendFileSync(path, `${separator}*\n`, "utf8");
36
28
  }
37
29
  return path;
38
30
  }
39
31
  /** Return the durable transcript path for an agent. */
40
- function createAgentHistoryPath(cwd, agentId, agentType = "agent") {
32
+ export function createAgentHistoryPath(cwd, agentId) {
41
33
  ensureSubagentsGitignore(cwd);
42
- const directory = (0, node_path_1.join)(cwd, SUBAGENTS_DIR, TRANSCRIPTS_DIR);
43
- (0, node_fs_1.mkdirSync)(directory, { recursive: true });
34
+ const directory = join(cwd, SUBAGENTS_DIR, TRANSCRIPTS_DIR);
35
+ mkdirSync(directory, { recursive: true });
44
36
  const safeId = agentId.replace(/[^A-Za-z0-9._-]+/g, "-") || "agent";
45
- const safeType = agentType.replace(/[^A-Za-z0-9._-]+/g, "-") || "agent";
46
- return (0, node_path_1.join)(directory, `${safeId}_${safeType}_transcript.jsonl`);
37
+ return join(directory, `${safeId}.jsonl`);
47
38
  }
48
39
  /** Return the project-relative path stored in the parent session record. */
49
- function agentHistoryLocator(cwd, historyPath) {
50
- return (0, node_path_1.relative)(cwd, historyPath).split(node_path_1.sep).join("/");
40
+ export function agentHistoryLocator(cwd, historyPath) {
41
+ return relative(cwd, historyPath).split(sep).join("/");
51
42
  }
52
43
  /** Resolve only paths in this package's project-local transcript namespace. */
53
- function resolveAgentHistoryPath(cwd, locator) {
54
- if (!locator || (0, node_path_1.isAbsolute)(locator))
44
+ export function resolveAgentHistoryPath(cwd, locator) {
45
+ // Locators are persisted data, not arbitrary paths. Reject traversal syntax
46
+ // before resolving so a path which normalizes back inside the namespace is
47
+ // still not accepted as an unsafe locator.
48
+ if (!locator || isAbsolute(locator) || locator.includes("\0") || locator.includes("\\"))
55
49
  return undefined;
56
- const root = (0, node_path_1.resolve)(cwd, SUBAGENTS_DIR, TRANSCRIPTS_DIR);
57
- const candidate = (0, node_path_1.resolve)(cwd, locator);
58
- if (candidate !== root && !candidate.startsWith(`${root}${node_path_1.sep}`))
50
+ const segments = locator.split("/");
51
+ if (segments.some((segment) => segment === ".." || segment === ""))
52
+ return undefined;
53
+ const root = resolve(cwd, SUBAGENTS_DIR, TRANSCRIPTS_DIR);
54
+ const candidate = resolve(cwd, locator);
55
+ if (candidate !== root && !candidate.startsWith(`${root}${sep}`))
59
56
  return undefined;
60
57
  return candidate;
61
58
  }
62
59
  /** Return true only when a valid project-local transcript file exists. */
63
- function hasAgentHistory(cwd, locator) {
60
+ export function hasAgentHistory(cwd, locator) {
64
61
  if (!locator)
65
62
  return false;
66
63
  const path = resolveAgentHistoryPath(cwd, locator);
67
- return path !== undefined && (0, node_fs_1.existsSync)(path);
64
+ return path !== undefined && existsSync(path);
68
65
  }
69
66
  /**
70
67
  * Read persisted transcript entries into the message shape used by the live
71
68
  * conversation viewer. Malformed lines and unknown records are skipped so one
72
69
  * damaged entry cannot hide the rest of a history.
73
70
  */
74
- function readAgentHistory(cwd, locator) {
71
+ export function readAgentHistory(cwd, locator) {
75
72
  const path = resolveAgentHistoryPath(cwd, locator);
76
- if (!path)
73
+ if (!path || !existsSync(path))
77
74
  return undefined;
78
75
  let raw;
79
76
  try {
80
- raw = (0, node_fs_1.readFileSync)(path, "utf8");
77
+ raw = readFileSync(path, "utf8");
81
78
  }
82
79
  catch {
83
80
  return undefined;
@@ -90,7 +87,7 @@ function readAgentHistory(cwd, locator) {
90
87
  continue;
91
88
  try {
92
89
  const entry = JSON.parse(line);
93
- const message = entry.message;
90
+ const message = entry?.message;
94
91
  if (!message || typeof message !== "object")
95
92
  continue;
96
93
  const role = message.role;
@@ -104,3 +101,4 @@ function readAgentHistory(cwd, locator) {
104
101
  }
105
102
  return messages.length > 0 ? messages : undefined;
106
103
  }
104
+ //# sourceMappingURL=agent-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-history.js","sourceRoot":"","sources":["../src/agent-history.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrE,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAC3C,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,G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AAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAEjD,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,GAAG,iBAAiB;QAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAE1E,MAAM,QAAQ,GAA6B,EAAE,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAC3B,IAAI,CAAC;YACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,OAAO,GAAI,KAAsC,EAAE,OAAO,CAAC;YACjE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;gBAAE,SAAS;YACtD,MAAM,IAAI,GAAI,OAA8B,CAAC,IAAI,CAAC;YAClD,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,SAAS;YACvC,QAAQ,CAAC,IAAI,CAAC,OAA2C,CAAC,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,4CAA4C;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC"}
@@ -16,6 +16,26 @@ export type CompactionInfo = {
16
16
  reason: "manual" | "threshold" | "overflow";
17
17
  tokensBefore: number;
18
18
  };
19
+ type RestorableAgentStatus = "completed" | "steered" | "stopped" | "aborted" | "error";
20
+ /** Validate one persisted terminal record without constructing runtime handles. */
21
+ export declare function isRestorableAgentRecord(value: unknown): value is {
22
+ id: string;
23
+ type: string;
24
+ description: string;
25
+ status: RestorableAgentStatus;
26
+ startedAt: number;
27
+ completedAt: number;
28
+ result?: string;
29
+ error?: string;
30
+ toolUses?: number;
31
+ lifetimeUsage?: {
32
+ input: number;
33
+ output: number;
34
+ cacheWrite: number;
35
+ };
36
+ transcriptPath?: string;
37
+ invocation?: AgentInvocation;
38
+ };
19
39
  interface SpawnOptions {
20
40
  description: string;
21
41
  model?: Model<any>;
@@ -121,15 +141,10 @@ export declare class AgentManager {
121
141
  */
122
142
  steer(id: string, message: string): boolean;
123
143
  getRecord(id: string): AgentRecord | undefined;
124
- /**
125
- * Restore terminal records persisted in a parent session.
126
- *
127
- * Restored records deliberately have no live session, promise, or abort
128
- * controller. Invalid data is ignored because session entries are persisted
129
- * extension data and may have been written by an older version.
130
- */
131
- restoreCompleted(records: readonly unknown[]): void;
132
144
  listAgents(): AgentRecord[];
145
+ /** Restore terminal records persisted by a parent branch without runtime handles. */
146
+ restoreCompleted(records: readonly unknown[]): void;
147
+ private createRestoredRecord;
133
148
  abort(id: string): boolean;
134
149
  /** Dispose a record's session and remove it from the map. */
135
150
  private removeRecord;
@@ -150,3 +165,4 @@ export declare class AgentManager {
150
165
  dispose(): void;
151
166
  }
152
167
  export {};
168
+ //# sourceMappingURL=agent-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-manager.d.ts","sourceRoot":"","sources":["../src/agent-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,Y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