@oh-my-pi/pi-coding-agent 15.12.4 → 15.13.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 (291) hide show
  1. package/CHANGELOG.md +304 -6
  2. package/dist/cli.js +1015 -881
  3. package/dist/types/async/job-manager.d.ts +15 -0
  4. package/dist/types/autolearn/controller.d.ts +25 -0
  5. package/dist/types/autolearn/managed-skills.d.ts +45 -0
  6. package/dist/types/autoresearch/state.d.ts +1 -1
  7. package/dist/types/autoresearch/types.d.ts +1 -1
  8. package/dist/types/cli/args.d.ts +19 -1
  9. package/dist/types/cli/session-picker.d.ts +1 -1
  10. package/dist/types/cli/setup-cli.d.ts +1 -1
  11. package/dist/types/cli/setup-model-picker.d.ts +14 -0
  12. package/dist/types/collab/protocol.d.ts +1 -1
  13. package/dist/types/commands/say.d.ts +24 -0
  14. package/dist/types/config/keybindings.d.ts +3 -3
  15. package/dist/types/config/model-registry.d.ts +10 -0
  16. package/dist/types/config/models-config-schema.d.ts +12 -0
  17. package/dist/types/config/models-config.d.ts +8 -2
  18. package/dist/types/config/settings-schema.d.ts +261 -58
  19. package/dist/types/export/html/index.d.ts +2 -1
  20. package/dist/types/extensibility/extensions/model-api.d.ts +17 -0
  21. package/dist/types/extensibility/extensions/runner.d.ts +3 -1
  22. package/dist/types/extensibility/extensions/types.d.ts +47 -1
  23. package/dist/types/extensibility/hooks/index.d.ts +2 -1
  24. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +9 -0
  25. package/dist/types/extensibility/plugins/loader.d.ts +11 -0
  26. package/dist/types/extensibility/shared-events.d.ts +1 -1
  27. package/dist/types/extensibility/skills.d.ts +10 -0
  28. package/dist/types/goals/guided-setup.d.ts +18 -0
  29. package/dist/types/goals/state.d.ts +1 -1
  30. package/dist/types/hindsight/transcript.d.ts +1 -1
  31. package/dist/types/index.d.ts +5 -0
  32. package/dist/types/internal-urls/local-protocol.d.ts +4 -2
  33. package/dist/types/main.d.ts +4 -3
  34. package/dist/types/mcp/startup-events.d.ts +11 -0
  35. package/dist/types/memories/index.d.ts +7 -0
  36. package/dist/types/memory-backend/local-backend.d.ts +4 -3
  37. package/dist/types/mnemopi/config.d.ts +4 -4
  38. package/dist/types/modes/components/agent-hub.d.ts +6 -0
  39. package/dist/types/modes/components/assistant-message.d.ts +1 -2
  40. package/dist/types/modes/components/compaction-summary-message.d.ts +15 -1
  41. package/dist/types/modes/components/custom-editor.d.ts +39 -1
  42. package/dist/types/modes/components/custom-editor.test.d.ts +1 -0
  43. package/dist/types/modes/components/session-selector.d.ts +1 -1
  44. package/dist/types/modes/components/tool-execution.d.ts +26 -16
  45. package/dist/types/modes/components/transcript-container.d.ts +23 -2
  46. package/dist/types/modes/components/tree-selector.d.ts +1 -1
  47. package/dist/types/modes/components/usage-row.d.ts +3 -0
  48. package/dist/types/modes/controllers/command-controller.d.ts +2 -2
  49. package/dist/types/modes/controllers/input-controller.d.ts +14 -0
  50. package/dist/types/modes/controllers/selector-controller.d.ts +3 -1
  51. package/dist/types/modes/gradient-highlight.d.ts +9 -4
  52. package/dist/types/modes/image-references.d.ts +6 -0
  53. package/dist/types/modes/interactive-mode.d.ts +27 -3
  54. package/dist/types/modes/magic-keywords.d.ts +13 -1
  55. package/dist/types/modes/rpc/rpc-mode.d.ts +35 -1
  56. package/dist/types/modes/rpc/rpc-types.d.ts +9 -1
  57. package/dist/types/modes/runtime-init.d.ts +4 -0
  58. package/dist/types/modes/theme/theme.d.ts +13 -2
  59. package/dist/types/modes/types.d.ts +8 -2
  60. package/dist/types/modes/utils/ui-helpers.d.ts +1 -1
  61. package/dist/types/registry/agent-registry.d.ts +17 -0
  62. package/dist/types/secrets/obfuscator.d.ts +1 -1
  63. package/dist/types/session/agent-session.d.ts +14 -2
  64. package/dist/types/session/indexed-session-storage.d.ts +3 -4
  65. package/dist/types/session/session-context.d.ts +39 -0
  66. package/dist/types/session/session-entries.d.ts +159 -0
  67. package/dist/types/session/session-listing.d.ts +69 -0
  68. package/dist/types/session/session-loader.d.ts +16 -0
  69. package/dist/types/session/session-manager.d.ts +82 -474
  70. package/dist/types/session/session-migrations.d.ts +12 -0
  71. package/dist/types/session/session-paths.d.ts +25 -0
  72. package/dist/types/session/session-persistence.d.ts +8 -0
  73. package/dist/types/session/session-storage.d.ts +11 -12
  74. package/dist/types/session/snapcompact-inline.d.ts +12 -1
  75. package/dist/types/session/snapcompact-savings-journal.d.ts +46 -0
  76. package/dist/types/session/tool-choice-queue.d.ts +6 -6
  77. package/dist/types/stt/asr-client.d.ts +90 -0
  78. package/dist/types/stt/asr-protocol.d.ts +97 -0
  79. package/dist/types/stt/asr-worker.d.ts +2 -0
  80. package/dist/types/stt/downloader.d.ts +38 -0
  81. package/dist/types/stt/endpointer.d.ts +59 -0
  82. package/dist/types/stt/index.d.ts +5 -1
  83. package/dist/types/stt/models.d.ts +120 -0
  84. package/dist/types/stt/recorder.d.ts +17 -0
  85. package/dist/types/stt/stt-controller.d.ts +6 -0
  86. package/dist/types/stt/transcriber.d.ts +5 -7
  87. package/dist/types/stt/wav.d.ts +29 -0
  88. package/dist/types/system-prompt.d.ts +4 -0
  89. package/dist/types/task/executor.d.ts +2 -0
  90. package/dist/types/task/index.d.ts +9 -1
  91. package/dist/types/task/types.d.ts +36 -0
  92. package/dist/types/tools/bash.d.ts +2 -2
  93. package/dist/types/tools/eval-render.d.ts +1 -1
  94. package/dist/types/tools/index.d.ts +11 -1
  95. package/dist/types/tools/irc.d.ts +1 -0
  96. package/dist/types/tools/learn.d.ts +51 -0
  97. package/dist/types/tools/manage-skill.d.ts +40 -0
  98. package/dist/types/tools/plan-mode-guard.d.ts +10 -0
  99. package/dist/types/tools/renderers.d.ts +7 -11
  100. package/dist/types/tools/ssh.d.ts +1 -1
  101. package/dist/types/tools/todo.d.ts +1 -1
  102. package/dist/types/tools/tts.d.ts +25 -0
  103. package/dist/types/tools/write.d.ts +1 -1
  104. package/dist/types/tts/downloader.d.ts +20 -0
  105. package/dist/types/tts/index.d.ts +8 -0
  106. package/dist/types/tts/models.d.ts +82 -0
  107. package/dist/types/tts/player.d.ts +32 -0
  108. package/dist/types/tts/runtime.d.ts +6 -0
  109. package/dist/types/tts/streaming-player.d.ts +41 -0
  110. package/dist/types/tts/tts-client.d.ts +93 -0
  111. package/dist/types/tts/tts-protocol.d.ts +95 -0
  112. package/dist/types/tts/tts-worker.d.ts +2 -0
  113. package/dist/types/tts/vocalizer.d.ts +41 -0
  114. package/dist/types/tts/wav.d.ts +8 -0
  115. package/dist/types/utils/tool-choice.d.ts +8 -0
  116. package/dist/types/utils/tools-manager.d.ts +2 -1
  117. package/dist/types/utils/tools-manager.test.d.ts +1 -0
  118. package/dist/types/web/scrapers/github.d.ts +1 -1
  119. package/package.json +15 -14
  120. package/src/async/job-manager.ts +49 -0
  121. package/src/autolearn/controller.ts +139 -0
  122. package/src/autolearn/managed-skills.ts +257 -0
  123. package/src/autoresearch/state.ts +1 -1
  124. package/src/autoresearch/types.ts +1 -1
  125. package/src/cli/args.ts +56 -2
  126. package/src/cli/session-picker.ts +2 -1
  127. package/src/cli/setup-cli.ts +148 -47
  128. package/src/cli/setup-model-picker.ts +43 -0
  129. package/src/cli-commands.ts +1 -0
  130. package/src/cli.ts +45 -13
  131. package/src/collab/host.ts +1 -1
  132. package/src/collab/protocol.ts +1 -1
  133. package/src/commands/say.ts +102 -0
  134. package/src/commands/setup.ts +1 -1
  135. package/src/commit/agentic/tools/analyze-file.ts +3 -0
  136. package/src/config/keybindings.ts +2 -2
  137. package/src/config/model-discovery.ts +11 -5
  138. package/src/config/model-registry.ts +64 -9
  139. package/src/config/models-config-schema.ts +4 -1
  140. package/src/config/models-config.ts +2 -1
  141. package/src/config/settings-schema.ts +248 -32
  142. package/src/config/settings.ts +10 -0
  143. package/src/discovery/builtin.ts +23 -1
  144. package/src/discovery/claude-plugins.ts +44 -5
  145. package/src/discovery/helpers.ts +41 -1
  146. package/src/eval/__tests__/budget-bridge.test.ts +1 -1
  147. package/src/eval/js/shared/prelude.txt +69 -17
  148. package/src/export/html/index.ts +3 -6
  149. package/src/extensibility/extensions/model-api.ts +41 -0
  150. package/src/extensibility/extensions/runner.ts +4 -0
  151. package/src/extensibility/extensions/types.ts +52 -1
  152. package/src/extensibility/extensions/wrapper.ts +41 -5
  153. package/src/extensibility/hooks/index.ts +2 -1
  154. package/src/extensibility/plugins/legacy-pi-compat.ts +43 -13
  155. package/src/extensibility/plugins/loader.ts +30 -19
  156. package/src/extensibility/plugins/manager.ts +221 -90
  157. package/src/extensibility/shared-events.ts +1 -1
  158. package/src/extensibility/skills.ts +96 -15
  159. package/src/goals/guided-setup.ts +133 -0
  160. package/src/goals/state.ts +1 -1
  161. package/src/hindsight/transcript.ts +1 -1
  162. package/src/index.ts +5 -0
  163. package/src/internal-urls/docs-index.generated.ts +10 -10
  164. package/src/internal-urls/history-protocol.ts +1 -1
  165. package/src/internal-urls/local-protocol.ts +29 -7
  166. package/src/main.ts +27 -7
  167. package/src/mcp/startup-events.ts +21 -0
  168. package/src/mcp/transports/stdio.ts +2 -1
  169. package/src/memories/index.ts +146 -11
  170. package/src/memory-backend/local-backend.ts +11 -5
  171. package/src/mnemopi/backend.ts +1 -0
  172. package/src/mnemopi/config.ts +26 -10
  173. package/src/modes/acp/acp-agent.ts +3 -5
  174. package/src/modes/components/agent-hub.ts +49 -4
  175. package/src/modes/components/assistant-message.ts +4 -37
  176. package/src/modes/components/compaction-summary-message.ts +125 -26
  177. package/src/modes/components/custom-editor.test.ts +96 -0
  178. package/src/modes/components/custom-editor.ts +164 -8
  179. package/src/modes/components/session-selector.ts +1 -1
  180. package/src/modes/components/settings-defs.ts +7 -0
  181. package/src/modes/components/tool-execution.ts +82 -43
  182. package/src/modes/components/transcript-container.ts +70 -1
  183. package/src/modes/components/tree-selector.ts +1 -1
  184. package/src/modes/components/usage-row.ts +18 -0
  185. package/src/modes/components/user-message.ts +4 -2
  186. package/src/modes/controllers/command-controller.ts +14 -4
  187. package/src/modes/controllers/event-controller.ts +78 -11
  188. package/src/modes/controllers/extension-ui-controller.ts +6 -0
  189. package/src/modes/controllers/input-controller.ts +258 -27
  190. package/src/modes/controllers/selector-controller.ts +12 -2
  191. package/src/modes/gradient-highlight.ts +21 -9
  192. package/src/modes/image-references.ts +20 -0
  193. package/src/modes/interactive-mode.ts +286 -40
  194. package/src/modes/magic-keywords.ts +27 -5
  195. package/src/modes/rpc/rpc-mode.ts +146 -14
  196. package/src/modes/rpc/rpc-subagents.ts +2 -2
  197. package/src/modes/rpc/rpc-types.ts +8 -2
  198. package/src/modes/runtime-init.ts +28 -3
  199. package/src/modes/theme/theme.ts +98 -50
  200. package/src/modes/types.ts +6 -2
  201. package/src/modes/utils/hotkeys-markdown.ts +1 -1
  202. package/src/modes/utils/ui-helpers.ts +34 -6
  203. package/src/priority.json +5 -1
  204. package/src/prompts/agents/task.md +1 -0
  205. package/src/prompts/goals/guided-goal-interview.md +8 -0
  206. package/src/prompts/goals/guided-goal-system.md +12 -0
  207. package/src/prompts/memories/read-path.md +6 -0
  208. package/src/prompts/system/autolearn-guidance-learn.md +1 -0
  209. package/src/prompts/system/autolearn-guidance.md +7 -0
  210. package/src/prompts/system/autolearn-nudge.md +3 -0
  211. package/src/prompts/system/eager-task.md +7 -0
  212. package/src/prompts/system/eager-todo.md +11 -6
  213. package/src/prompts/system/subagent-system-prompt.md +4 -0
  214. package/src/prompts/system/system-prompt.md +10 -5
  215. package/src/prompts/system/title-marker-instruction.md +1 -0
  216. package/src/prompts/system/title-system-marker.md +16 -0
  217. package/src/prompts/tools/job.md +1 -0
  218. package/src/prompts/tools/learn.md +7 -0
  219. package/src/prompts/tools/manage-skill.md +9 -0
  220. package/src/prompts/tools/task.md +3 -0
  221. package/src/registry/agent-registry.ts +30 -0
  222. package/src/sdk.ts +88 -24
  223. package/src/secrets/obfuscator.ts +1 -1
  224. package/src/session/agent-session.ts +209 -87
  225. package/src/session/history-storage.ts +2 -2
  226. package/src/session/indexed-session-storage.ts +7 -17
  227. package/src/session/session-context.ts +352 -0
  228. package/src/session/session-entries.ts +194 -0
  229. package/src/session/session-listing.ts +588 -0
  230. package/src/session/session-loader.ts +106 -0
  231. package/src/session/session-manager.ts +933 -3145
  232. package/src/session/session-migrations.ts +78 -0
  233. package/src/session/session-paths.ts +193 -0
  234. package/src/session/session-persistence.ts +131 -0
  235. package/src/session/session-storage.ts +91 -50
  236. package/src/session/snapcompact-inline.ts +21 -1
  237. package/src/session/snapcompact-savings-journal.ts +113 -0
  238. package/src/session/tool-choice-queue.ts +23 -11
  239. package/src/slash-commands/builtin-registry.ts +25 -3
  240. package/src/stt/asr-client.ts +520 -0
  241. package/src/stt/asr-protocol.ts +65 -0
  242. package/src/stt/asr-worker.ts +790 -0
  243. package/src/stt/downloader.ts +107 -47
  244. package/src/stt/endpointer.ts +259 -0
  245. package/src/stt/index.ts +5 -1
  246. package/src/stt/models.ts +150 -0
  247. package/src/stt/recorder.ts +247 -60
  248. package/src/stt/stt-controller.ts +201 -22
  249. package/src/stt/transcriber.ts +37 -68
  250. package/src/stt/wav.ts +173 -0
  251. package/src/system-prompt.ts +8 -0
  252. package/src/task/agents.ts +1 -2
  253. package/src/task/executor.ts +49 -15
  254. package/src/task/index.ts +60 -6
  255. package/src/task/render.ts +83 -8
  256. package/src/task/types.ts +53 -0
  257. package/src/tools/ask.ts +8 -0
  258. package/src/tools/bash.ts +4 -3
  259. package/src/tools/eval-render.ts +4 -3
  260. package/src/tools/index.ts +40 -4
  261. package/src/tools/irc.ts +10 -2
  262. package/src/tools/job.ts +14 -2
  263. package/src/tools/learn.ts +144 -0
  264. package/src/tools/manage-skill.ts +104 -0
  265. package/src/tools/plan-mode-guard.ts +53 -19
  266. package/src/tools/renderers.ts +7 -11
  267. package/src/tools/ssh.ts +4 -3
  268. package/src/tools/todo.ts +1 -1
  269. package/src/tools/tts.ts +203 -92
  270. package/src/tools/write.ts +18 -2
  271. package/src/tts/downloader.ts +64 -0
  272. package/src/tts/index.ts +8 -0
  273. package/src/tts/models.ts +137 -0
  274. package/src/tts/player.ts +137 -0
  275. package/src/tts/runtime.ts +21 -0
  276. package/src/tts/streaming-player.ts +266 -0
  277. package/src/tts/tts-client.ts +647 -0
  278. package/src/tts/tts-protocol.ts +60 -0
  279. package/src/tts/tts-worker.ts +497 -0
  280. package/src/tts/vocalizer.ts +162 -0
  281. package/src/tts/wav.ts +58 -0
  282. package/src/utils/title-generator.ts +48 -5
  283. package/src/utils/tool-choice.ts +16 -0
  284. package/src/utils/tools-manager.test.ts +25 -0
  285. package/src/utils/tools-manager.ts +19 -1
  286. package/src/web/scrapers/github.ts +96 -0
  287. package/src/web/search/index.ts +13 -0
  288. package/src/web/search/providers/searxng.ts +13 -1
  289. package/dist/types/stt/setup.d.ts +0 -18
  290. package/src/stt/setup.ts +0 -52
  291. package/src/stt/transcribe.py +0 -70
@@ -1,297 +1,12 @@
1
- import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
2
1
  import type { ImageContent, Message, MessageAttribution, ServiceTier, TextContent } from "@oh-my-pi/pi-ai";
3
2
  import { ArtifactManager } from "./artifacts";
4
3
  import { type BlobPutOptions, type BlobPutResult } from "./blob-store";
5
4
  import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
6
- import type { SessionStorage } from "./session-storage";
7
- export declare const CURRENT_SESSION_VERSION = 3;
8
- export interface SessionHeader {
9
- type: "session";
10
- version?: number;
11
- id: string;
12
- title?: string;
13
- titleSource?: "auto" | "user";
14
- timestamp: string;
15
- cwd: string;
16
- parentSession?: string;
17
- }
18
- export interface NewSessionOptions {
19
- parentSession?: string;
20
- /** Skip flushing the current session and delete it instead of saving. */
21
- drop?: boolean;
22
- }
23
- export interface SessionEntryBase {
24
- type: string;
25
- id: string;
26
- parentId: string | null;
27
- timestamp: string;
28
- }
29
- export interface SessionMessageEntry extends SessionEntryBase {
30
- type: "message";
31
- message: AgentMessage;
32
- }
33
- export interface ThinkingLevelChangeEntry extends SessionEntryBase {
34
- type: "thinking_level_change";
35
- thinkingLevel?: string | null;
36
- }
37
- export interface ModelChangeEntry extends SessionEntryBase {
38
- type: "model_change";
39
- /** Model in "provider/modelId" format */
40
- model: string;
41
- /** Role: "default", "smol", "slow", etc. Undefined treated as "default" */
42
- role?: string;
43
- }
44
- export interface ServiceTierChangeEntry extends SessionEntryBase {
45
- type: "service_tier_change";
46
- serviceTier: ServiceTier | null;
47
- }
48
- export interface CompactionEntry<T = unknown> extends SessionEntryBase {
49
- type: "compaction";
50
- summary: string;
51
- shortSummary?: string;
52
- firstKeptEntryId: string;
53
- tokensBefore: number;
54
- /** Extension-specific data (e.g., ArtifactIndex, version markers for structured compaction) */
55
- details?: T;
56
- /** Hook-provided data to persist across compaction */
57
- preserveData?: Record<string, unknown>;
58
- /** True if generated by an extension, undefined/false if pi-generated (backward compatible) */
59
- fromExtension?: boolean;
60
- }
61
- export interface BranchSummaryEntry<T = unknown> extends SessionEntryBase {
62
- type: "branch_summary";
63
- fromId: string;
64
- summary: string;
65
- /** Extension-specific data (not sent to LLM) */
66
- details?: T;
67
- /** True if generated by an extension, false if pi-generated */
68
- fromExtension?: boolean;
69
- }
70
- /**
71
- * Custom entry for extensions to store extension-specific data in the session.
72
- * Use customType to identify your extension's entries.
73
- *
74
- * Purpose: Persist extension state across session reloads. On reload, extensions can
75
- * scan entries for their customType and reconstruct internal state.
76
- *
77
- * Does NOT participate in LLM context (ignored by buildSessionContext).
78
- * For injecting content into context, see CustomMessageEntry.
79
- */
80
- export interface CustomEntry<T = unknown> extends SessionEntryBase {
81
- type: "custom";
82
- customType: string;
83
- data?: T;
84
- }
85
- /** Label entry for user-defined bookmarks/markers on entries. */
86
- export interface LabelEntry extends SessionEntryBase {
87
- type: "label";
88
- targetId: string;
89
- label: string | undefined;
90
- }
91
- /** TTSR injection entry - tracks which time-traveling rules have been injected this session. */
92
- export interface TtsrInjectionEntry extends SessionEntryBase {
93
- type: "ttsr_injection";
94
- /** Names of rules that were injected */
95
- injectedRules: string[];
96
- }
97
- /** Persisted MCP discovery selection state for a session branch. */
98
- export interface MCPToolSelectionEntry extends SessionEntryBase {
99
- type: "mcp_tool_selection";
100
- /** MCP tool names selected for visibility in discovery mode. */
101
- selectedToolNames: string[];
102
- }
103
- /** Session init entry - captures initial context for subagent sessions (debugging/replay). */
104
- export interface SessionInitEntry extends SessionEntryBase {
105
- type: "session_init";
106
- /** Full system prompt sent to the model */
107
- systemPrompt: string;
108
- /** Initial task/user message */
109
- task: string;
110
- /** Tools available to the agent */
111
- tools: string[];
112
- /** Output schema if structured output was requested */
113
- outputSchema?: unknown;
114
- }
115
- /** Mode change entry - tracks agent mode transitions (e.g. plan mode). */
116
- export interface ModeChangeEntry extends SessionEntryBase {
117
- type: "mode_change";
118
- /** Current mode name, or "none" when exiting a mode */
119
- mode: string;
120
- /** Optional mode-specific data (e.g. plan file path) */
121
- data?: Record<string, unknown>;
122
- }
123
- /**
124
- * Custom message entry for extensions to inject messages into LLM context.
125
- * Use customType to identify your extension's entries.
126
- *
127
- * Unlike CustomEntry, this DOES participate in LLM context.
128
- * The content participates in LLM context through convertToLlm().
129
- * Use details for extension-specific metadata (not sent to LLM).
130
- *
131
- * display controls TUI rendering:
132
- * - false: hidden entirely
133
- * - true: rendered with distinct styling (different from user messages)
134
- */
135
- export interface CustomMessageEntry<T = unknown> extends SessionEntryBase {
136
- type: "custom_message";
137
- customType: string;
138
- content: string | (TextContent | ImageContent)[];
139
- details?: T;
140
- display: boolean;
141
- /** Who initiated this message for billing/attribution semantics. */
142
- attribution?: MessageAttribution;
143
- }
144
- /** Session entry - has id/parentId for tree structure (returned by "read" methods in SessionManager) */
145
- export type SessionEntry = SessionMessageEntry | ThinkingLevelChangeEntry | ModelChangeEntry | ServiceTierChangeEntry | CompactionEntry | BranchSummaryEntry | CustomEntry | CustomMessageEntry | LabelEntry | TtsrInjectionEntry | MCPToolSelectionEntry | SessionInitEntry | ModeChangeEntry;
146
- /** Raw file entry (includes header) */
147
- export type FileEntry = SessionHeader | SessionEntry;
148
- /** Tree node for getTree() - defensive copy of session structure */
149
- export interface SessionTreeNode {
150
- entry: SessionEntry;
151
- children: SessionTreeNode[];
152
- /** Resolved label for this entry, if any */
153
- label?: string;
154
- }
155
- export interface SessionContext {
156
- messages: AgentMessage[];
157
- thinkingLevel?: string;
158
- serviceTier?: ServiceTier;
159
- /** Model roles: { default: "provider/modelId", small: "provider/modelId", ... } */
160
- models: Record<string, string>;
161
- /** Names of TTSR rules that have been injected this session */
162
- injectedTtsrRules: string[];
163
- /** MCP tool names selected through discovery for this session branch. */
164
- selectedMCPToolNames: string[];
165
- /** Whether this branch contains an explicit persisted MCP selection entry. */
166
- hasPersistedMCPToolSelection: boolean;
167
- /** Active mode (e.g. "plan") or "none" if no special mode is active */
168
- mode: string;
169
- /** Mode-specific data from the last mode_change entry */
170
- modeData?: Record<string, unknown>;
171
- }
172
- export declare const EPHEMERAL_MODEL_CHANGE_ROLE = "fallback";
173
- /** Lists session model strings to try when restoring, in fallback order. */
174
- export declare function getRestorableSessionModels(models: Readonly<Record<string, string>>, lastModelChangeRole: string | undefined): string[];
175
- /**
176
- * Coarse lifecycle status of a session, derived from its last persisted message.
177
- *
178
- * - `complete` — the last assistant turn ended with no unanswered tool calls, i.e.
179
- * the agent yielded control back to the user.
180
- * - `interrupted` — work was cut off mid-flight: a trailing assistant turn with
181
- * pending tool calls, a trailing tool result the agent never continued from, or
182
- * a length-truncated turn.
183
- * - `aborted` — the last assistant turn was cancelled by the user.
184
- * - `error` — the last assistant turn ended in an error.
185
- * - `pending` — a trailing user message with no assistant reply persisted after it.
186
- * - `unknown` — status could not be determined (empty/header-only session, or the
187
- * final message was larger than the tail window that was read).
188
- */
189
- export type SessionStatus = "complete" | "interrupted" | "aborted" | "error" | "pending" | "unknown";
190
- export interface SessionInfo {
191
- path: string;
192
- id: string;
193
- /** Working directory where the session was started. Empty string for old sessions. */
194
- cwd: string;
195
- title?: string;
196
- /** Path to the parent session (if this session was forked). */
197
- parentSessionPath?: string;
198
- created: Date;
199
- modified: Date;
200
- messageCount: number;
201
- /** File size in bytes on disk; used for compact list rendering. */
202
- size: number;
203
- firstMessage: string;
204
- allMessagesText: string;
205
- /**
206
- * Coarse lifecycle status from the session's last persisted message. Optional:
207
- * synthesized {@link SessionInfo}s (cross-project stubs, tests) leave it unset.
208
- */
209
- status?: SessionStatus;
210
- }
5
+ import { type BuildSessionContextOptions, type SessionContext } from "./session-context";
6
+ import { type NewSessionOptions, type SessionEntry, type SessionHeader, type SessionTreeNode, type UsageStatistics } from "./session-entries";
7
+ import { type SessionInfo } from "./session-listing";
8
+ import { type SessionStorage } from "./session-storage";
211
9
  export type ReadonlySessionManager = Pick<SessionManager, "getCwd" | "getSessionDir" | "getSessionId" | "getSessionFile" | "getSessionName" | "getArtifactsDir" | "getArtifactManager" | "allocateArtifactPath" | "saveArtifact" | "getArtifactPath" | "getLeafId" | "getLeafEntry" | "getEntry" | "getLabel" | "getBranch" | "getHeader" | "getEntries" | "getTree" | "getUsageStatistics" | "putBlob" | "putBlobSync">;
212
- /** Exported for testing */
213
- export declare function migrateSessionEntries(entries: FileEntry[]): void;
214
- /** Exported for compaction.test.ts */
215
- export declare function parseSessionEntries(content: string): FileEntry[];
216
- export declare function getLatestCompactionEntry(entries: SessionEntry[]): CompactionEntry | null;
217
- export interface BuildSessionContextOptions {
218
- /**
219
- * Build the full-history display transcript instead of the LLM context:
220
- * every path entry in chronological order, with each compaction emitted
221
- * inline as a `compactionSummary` message at the position it fired rather
222
- * than replacing the history before it. Display-only — never send the
223
- * result to a provider.
224
- */
225
- transcript?: boolean;
226
- }
227
- /**
228
- * Build the session context from entries using tree traversal.
229
- * If leafId is provided, walks from that entry to root.
230
- * Handles compaction and branch summaries along the path.
231
- */
232
- export declare function buildSessionContext(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, options?: BuildSessionContextOptions): SessionContext;
233
- /** Exported for testing */
234
- export declare function loadEntriesFromFile(filePath: string, storage?: SessionStorage): Promise<FileEntry[]>;
235
- /**
236
- * Read-only message view of a session file: load entries, migrate to the
237
- * current version, resolve blob refs, and build the context along the
238
- * persisted leaf path (last entry). Does NOT create a writer or take the
239
- * session lock — safe to call against a file another session is writing.
240
- */
241
- export declare function loadSessionMessagesReadOnly(filePath: string): Promise<AgentMessage[]>;
242
- declare class RecentSessionInfo {
243
- #private;
244
- readonly path: string;
245
- readonly mtime: number;
246
- constructor(path: string, mtime: number, header: Record<string, unknown>, firstPrompt?: string);
247
- /** Display name. Falls back to a timestamp-based label, never the raw UUID. */
248
- get fullName(): string;
249
- /**
250
- * Display name without an arbitrary length cap. The renderer is responsible for
251
- * width-aware truncation so adjacent fields (e.g. the relative time) stay visible.
252
- */
253
- get name(): string;
254
- /** Human-readable relative time (e.g., "2 hours ago") */
255
- get timeAgo(): string;
256
- }
257
- /**
258
- * Promote orphaned `<basename>.jsonl.<snowflake>.bak` backups created by
259
- * `#replaceSessionFileAfterEperm` back to their primary path when the primary
260
- * is missing. This runs once per session-dir scan, before the main `*.jsonl`
261
- * glob, so a crash between the two renames in the EPERM-rewrite path does not
262
- * leave the user's last good state stranded outside the loader's view.
263
- *
264
- * Exported for testing.
265
- */
266
- export declare function recoverOrphanedBackups(sessionDir: string, storage: SessionStorage): Promise<void>;
267
- /** Exported for testing */
268
- export declare function findMostRecentSession(sessionDir: string, storage?: SessionStorage): Promise<string | null>;
269
- /** Get recent sessions for display in welcome screen (which reserves WELCOME_SESSION_SLOTS rows) */
270
- export declare function getRecentSessions(sessionDir: string, limit?: number, storage?: SessionStorage): Promise<RecentSessionInfo[]>;
271
- /**
272
- * Manages conversation sessions as append-only trees stored in JSONL files.
273
- *
274
- * Each session entry has an id and parentId forming a tree structure. The "leaf"
275
- * pointer tracks the current position. Appending creates a child of the current leaf.
276
- * Branching moves the leaf to an earlier entry, allowing new branches without
277
- * modifying history.
278
- *
279
- * Use buildSessionContext() to get the resolved message list for the LLM, which
280
- * handles compaction summaries and follows the path from root to current leaf.
281
- */
282
- export interface UsageStatistics {
283
- input: number;
284
- output: number;
285
- cacheRead: number;
286
- cacheWrite: number;
287
- premiumRequests: number;
288
- cost: number;
289
- }
290
- export interface ResolvedSessionMatch {
291
- session: SessionInfo;
292
- scope: "local" | "global";
293
- }
294
- export declare function resolveResumableSession(sessionArg: string, cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<ResolvedSessionMatch | undefined>;
295
10
  interface SessionManagerStateSnapshot {
296
11
  cwd: string;
297
12
  sessionDir: string;
@@ -299,93 +14,81 @@ interface SessionManagerStateSnapshot {
299
14
  sessionName: string | undefined;
300
15
  titleSource: "auto" | "user" | undefined;
301
16
  sessionFile: string | undefined;
302
- flushed: boolean;
303
- needsFullRewriteOnNextPersist: boolean;
304
- fileEntries: FileEntry[];
17
+ onDisk: boolean;
18
+ needsRewrite: boolean;
19
+ header: SessionHeader;
20
+ entries: SessionEntry[];
305
21
  }
22
+ /**
23
+ * Stores and navigates an append-only conversation journal.
24
+ *
25
+ * A session is a JSONL file: one header line followed by entries. Entries form a
26
+ * tree by `(id, parentId)`, and the mutable leaf pointer selects which path is
27
+ * active for future appends and for LLM context construction.
28
+ *
29
+ * Durability is software-crash safe but not power-loss safe: appends are handed
30
+ * to the OS synchronously in-body (so an entry survives an OOM/SIGKILL the
31
+ * instant `appendMessage` returns) but never `fsync`'d. Full-file rewrites go
32
+ * through the storage layer's atomic temp-write+rename so a crash mid-rewrite
33
+ * cannot truncate the prior good file.
34
+ */
306
35
  export declare class SessionManager {
307
36
  #private;
308
- private cwd;
309
- private sessionDir;
310
- private readonly persist;
311
- private readonly storage;
312
37
  /**
313
38
  * Collab replication tap: invoked for every appended entry with the
314
39
  * in-memory (pre-blob-externalization) entry, so inline images survive.
315
- * Failures are swallowed — a broadcast error must never break persistence.
316
40
  */
317
41
  onEntryAppended?: (entry: SessionEntry) => void;
318
42
  private constructor();
319
- /** Puts a binary blob into the blob store and returns the blob reference */
43
+ /** Puts a binary blob into the blob store and returns the blob reference. */
320
44
  putBlob(data: Buffer, options?: BlobPutOptions): Promise<BlobPutResult>;
321
45
  /** Synchronous variant of {@link putBlob} for rebuild-only render paths. */
322
46
  putBlobSync(data: Buffer, options?: BlobPutOptions): BlobPutResult;
323
47
  captureState(): SessionManagerStateSnapshot;
324
48
  restoreState(snapshot: SessionManagerStateSnapshot): void;
325
- /** Switch to a different session file (used for resume and branching) */
49
+ /** Switch to a different session file (resume / branch). */
326
50
  setSessionFile(sessionFile: string): Promise<void>;
327
- /** Start a new session. Closes any existing writer first. */
51
+ /** Start a new session. Drains and closes any existing writer first. */
328
52
  newSession(options?: NewSessionOptions): Promise<string | undefined>;
329
- /** Delete a session file and its artifacts. Drains the persist writer first to avoid EPERM on Windows. ENOENT is treated as success. */
53
+ /** Delete a session file and its artifact directory. ENOENT is treated as success. */
330
54
  dropSession(sessionPath: string): Promise<void>;
331
55
  /**
332
- * Fork the current session, creating a new session file with the same entries.
333
- * Returns both the old and new session file paths for artifact copying.
334
- * @returns { oldSessionFile, newSessionFile } or undefined if not persisting
56
+ * Fork the current session into a new file with the same entries.
57
+ * @returns the old and new session file paths, or undefined when not persisting.
335
58
  */
336
59
  fork(): Promise<{
337
60
  oldSessionFile: string;
338
61
  newSessionFile: string;
339
62
  } | undefined>;
340
63
  /**
341
- * Move the session to a new working directory.
342
- * Moves session files and artifacts on disk, updates all internal references,
343
- * and rewrites the session header with the new cwd. When provided,
344
- * `targetSessionDir` is used instead of deriving the default directory for
345
- * the new cwd (for `--continue --session-dir` / `--resume --session-dir`).
64
+ * Move the session to a new working directory: relocate the session file and
65
+ * artifacts on disk, update internal references, and rewrite the header cwd.
346
66
  */
347
67
  moveTo(newCwd: string, targetSessionDir?: string): Promise<void>;
348
- isPersisted(): boolean;
349
68
  /**
350
- * Force-persist all current entries to disk, even when no assistant message exists yet.
351
- * Used by ACP mode where session/new must create a discoverable session immediately.
69
+ * Force the session onto disk even with no assistant message yet (ACP
70
+ * session/new must create a discoverable file immediately).
352
71
  */
353
72
  ensureOnDisk(): Promise<void>;
354
- /** Flush pending writes to disk. Call before switching sessions or on shutdown. */
73
+ /** Flush pending writes. Call before switching sessions or on shutdown. */
355
74
  flush(): Promise<void>;
356
75
  /**
357
- * Synchronously flush all in-memory entries to disk and fsync.
358
- * Use when the process may exit before an async flush settles (e.g. Ctrl+C
359
- * in the TUI, where raw mode consumes the keystroke so postmortem's SIGINT
360
- * handler never fires).
361
- *
362
- * Hot path: the persist writer is open and flushed, so a single fsyncSync
363
- * pushes the page-cache data to physical disk.
364
- *
365
- * Cold path: entries are only in memory (session just started, or a rewrite
366
- * is pending). Writes all entries to a temp file, fsyncs, and atomically
367
- * renames over the session file — then re-opens an append writer so the
368
- * hot path resumes on subsequent `_persist` calls.
76
+ * Synchronously flush all in-memory entries to disk. Use when the process may
77
+ * exit before an async flush settles (Ctrl+C in the TUI). Software-crash
78
+ * durable; not atomic and not power-loss safe a same-process crash never
79
+ * lands mid-`writeFileSync`.
369
80
  */
370
81
  flushSync(): void;
371
- /** Close the persistent writer after flushing all pending data. */
82
+ /** Flush, then close the append writer. */
372
83
  close(): Promise<void>;
373
84
  getCwd(): string;
374
- /** Get usage statistics across all assistant messages in the session. */
375
85
  getUsageStatistics(): UsageStatistics;
376
86
  /**
377
87
  * Open a new per-turn budget window: snapshot the cumulative output baseline,
378
- * reset the eval-subagent counter, and set the (optional) ceiling. Called once
379
- * per real user message; `total` is null when no `+Nk` directive was present.
88
+ * reset the eval-subagent counter, and set the (optional) ceiling.
380
89
  */
381
90
  beginTurnBudget(total: number | null, hard: boolean): void;
382
- /** Record output tokens consumed by an eval-spawned subagent in the current turn. */
383
91
  recordEvalSubagentOutput(output: number): void;
384
- /**
385
- * Current turn budget for the eval `budget` helper: the ceiling (null = none),
386
- * output tokens spent this turn (main loop + eval-spawned subagents, no
387
- * double-count), and whether the ceiling is hard.
388
- */
389
92
  getTurnBudget(): {
390
93
  total: number | null;
391
94
  spent: number;
@@ -394,114 +97,67 @@ export declare class SessionManager {
394
97
  getSessionDir(): string;
395
98
  getSessionId(): string;
396
99
  getSessionFile(): string | undefined;
397
- /**
398
- * Returns the session artifacts directory path (session file path without .jsonl).
399
- * Returns null when the session is not persisted to a file.
400
- * When this session has adopted an external ArtifactManager (subagent case),
401
- * returns that manager's directory so reads/writes land in the shared parent
402
- * dir instead of a private (non-existent) subdir.
403
- */
404
100
  getArtifactsDir(): string | null;
405
- /**
406
- * Adopt an externally-owned ArtifactManager. Used by subagents to share
407
- * the parent session's artifact directory and ID counter.
408
- */
409
101
  adoptArtifactManager(manager: ArtifactManager): void;
410
- /**
411
- * Returns the ArtifactManager this session writes through. Lazily creates
412
- * one bound to the current session file unless an external manager was
413
- * adopted via `adoptArtifactManager`. Returns null only for non-persistent
414
- * sessions with no adopted manager.
415
- */
416
102
  getArtifactManager(): ArtifactManager | null;
417
- /**
418
- * Allocate a new artifact path and ID for the current session.
419
- * Returns an empty object when the session is not persisted.
420
- */
421
103
  allocateArtifactPath(toolType: string): Promise<{
422
104
  id?: string;
423
105
  path?: string;
424
106
  }>;
425
- /**
426
- * Save artifact content under the current session and return artifact ID.
427
- * Returns an artifact ID for all sessions (file-backed for persistent, in-memory fallback otherwise).
428
- */
429
107
  saveArtifact(content: string, toolType: string): Promise<string | undefined>;
430
- /**
431
- * Resolve an artifact ID to an on-disk path for the current session.
432
- * Returns null when missing or when the session is not persisted.
433
- */
434
108
  getArtifactPath(id: string): Promise<string | null>;
435
- /**
436
- * Persist (or clear) the current editor draft so the next resume of this
437
- * session can restore it. Empty text deletes any stale draft. No-op when the
438
- * session is not persisted.
439
- */
440
109
  saveDraft(text: string): Promise<void>;
441
- /**
442
- * Read and remove the saved draft. Returns the previously-saved text, or
443
- * null when no draft is pending. Single-shot: a successful read removes the
444
- * sidecar so a subsequent resume does not re-restore the same text.
445
- */
446
110
  consumeDraft(): Promise<string | null>;
447
- /** The source that set the session name: "user" (manual /rename or RPC) or "auto" (generated title). */
111
+ /** The source that set the session name: "user" (manual/RPC) or "auto" (generated title). */
448
112
  get titleSource(): "auto" | "user" | undefined;
449
113
  getSessionName(): string | undefined;
450
114
  onSessionNameChanged(cb: () => void): () => void;
451
115
  /**
452
116
  * Set the session display name.
453
- * @param source - "user" for explicit renames (/rename command, RPC); "auto" for generated titles.
454
- * Auto-generated titles are silently ignored when the user has already set a name.
117
+ * @param source "user" for explicit renames; "auto" for generated titles.
118
+ * Auto titles are ignored once the user has set a name.
455
119
  */
456
120
  setSessionName(name: string, source?: "auto" | "user"): Promise<boolean>;
457
- _persist(entry: SessionEntry): void;
458
121
  /**
459
122
  * Append a foreign (host-authored) entry verbatim, preserving its
460
- * `id`/`parentId` — no id minting. Used by collab guests to mirror the
461
- * host session into the local replica file.
123
+ * `id`/`parentId`. Used by collab guests to mirror the host session.
462
124
  */
463
125
  ingestReplicatedEntry(entry: SessionEntry): void;
464
126
  /**
465
127
  * Snapshot the session for collab replication: the live header plus a deep
466
- * copy of every entry (the host mutates entries in place on
467
- * truncation/rewrite paths, so guests must not share references).
128
+ * copy of every entry (the host mutates entries in place on rewrite paths, so
129
+ * guests must not share references).
468
130
  */
469
131
  snapshotForReplication(): {
470
132
  header: SessionHeader;
471
133
  entries: SessionEntry[];
472
134
  };
473
- /** Append a message as child of current leaf, then advance leaf. Returns entry id.
474
- * Does not allow writing CompactionSummaryMessage and BranchSummaryMessage directly.
475
- * Reason: we want these to be top-level entries in the session, not message session entries,
476
- * so it is easier to find them.
477
- * These need to be appended via appendCompaction() and appendBranchSummary() methods.
135
+ /**
136
+ * Append a message as a child of the current leaf, then advance the leaf.
137
+ * CompactionSummaryMessage / BranchSummaryMessage are rejected here they are
138
+ * top-level entries via appendCompaction()/branchWithSummary().
478
139
  */
479
140
  appendMessage(message: Message | CustomMessage | HookMessage | BashExecutionMessage | PythonExecutionMessage | FileMentionMessage): string;
480
- /** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
481
141
  appendThinkingLevelChange(thinkingLevel?: string): string;
482
142
  appendServiceTierChange(serviceTier: ServiceTier | null): string;
483
- /** Append a mode change as child of current leaf, then advance leaf. Returns entry id. */
484
143
  appendModeChange(mode: string, data?: Record<string, unknown>): string;
485
144
  /**
486
- * Append a model change as child of current leaf, then advance leaf. Returns entry id.
145
+ * Append a model change as a child of the current leaf, then advance the leaf.
487
146
  * @param model Model in "provider/modelId" format
488
147
  * @param role Optional role (default: "default")
489
148
  */
490
149
  appendModelChange(model: string, role?: string): string;
491
- /** Append session init metadata (for subagent debugging/replay). Returns entry id. */
492
150
  appendSessionInit(init: {
493
151
  systemPrompt: string;
494
152
  task: string;
495
153
  tools: string[];
496
154
  outputSchema?: unknown;
497
155
  }): string;
498
- /** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */
499
156
  appendCompaction<T = unknown>(summary: string, shortSummary: string | undefined, firstKeptEntryId: string, tokensBefore: number, details?: T, fromExtension?: boolean, preserveData?: Record<string, unknown>): string;
500
- /** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */
501
157
  appendCustomEntry(customType: string, data?: unknown): string;
502
158
  /**
503
- * Rewrite the session file after in-place entry updates.
504
- * Use sparingly (e.g., pruning old tool outputs).
159
+ * Rewrite the session file after in-place entry updates (e.g. pruning old tool
160
+ * outputs). Use sparingly.
505
161
  */
506
162
  rewriteEntries(): Promise<void>;
507
163
  /**
@@ -511,143 +167,95 @@ export declare class SessionManager {
511
167
  * @param display Whether to show in TUI (true = styled display, false = hidden)
512
168
  * @param details Optional extension-specific metadata (not sent to LLM)
513
169
  * @param attribution Who initiated this message for billing/attribution semantics
514
- * @returns Entry id
515
170
  */
516
171
  appendCustomMessageEntry<T = unknown>(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details?: T, attribution?: MessageAttribution): string;
517
172
  /**
518
173
  * Append an MCP tool selection entry recording the discovery-selected MCP tools.
519
- * @param selectedToolNames MCP tool names selected for this branch
520
- * @returns Entry id
521
174
  */
522
175
  appendMCPToolSelection(selectedToolNames: string[]): string;
523
- /**
524
- * Append a TTSR injection entry recording which rules were injected.
525
- * @param ruleNames Names of rules that were injected
526
- * @returns Entry id
527
- */
176
+ /** Append a TTSR injection entry recording which rules were injected. */
528
177
  appendTtsrInjection(ruleNames: string[]): string;
529
- /**
530
- * Get all unique TTSR rule names that have been injected in the current branch.
531
- * Scans from root to current leaf for ttsr_injection entries.
532
- */
178
+ /** All unique TTSR rule names injected on the current branch (root → leaf). */
533
179
  getInjectedTtsrRules(): string[];
534
180
  getLeafId(): string | null;
535
181
  getLeafEntry(): SessionEntry | undefined;
536
182
  /**
537
- * Get the most recent model role from the current session path.
538
- * Returns undefined if no model change has been recorded.
183
+ * The most recent model role on the current branch, or undefined when no
184
+ * model change has been recorded.
539
185
  */
540
186
  getLastModelChangeRole(): string | undefined;
541
187
  getEntry(id: string): SessionEntry | undefined;
542
- /**
543
- * Get all direct children of an entry.
544
- */
188
+ /** All direct children of an entry. */
545
189
  getChildren(parentId: string): SessionEntry[];
546
- /**
547
- * Get the label for an entry, if any.
548
- */
549
190
  getLabel(id: string): string | undefined;
550
191
  /**
551
- * Set or clear a label on an entry.
552
- * Labels are user-defined markers for bookmarking/navigation.
553
- * Pass undefined or empty string to clear the label.
192
+ * Set or clear a label on an entry. Pass undefined/empty to clear.
554
193
  */
555
194
  appendLabelChange(targetId: string, label: string | undefined): string;
556
195
  /**
557
- * Walk from entry to root, returning all entries in path order.
558
- * Includes all entry types (messages, compaction, model changes, etc.).
559
- * Use buildSessionContext() to get the resolved messages for the LLM.
196
+ * Walk from an entry to root, returning entries in path order. Includes all
197
+ * entry types; use buildSessionContext() for the resolved LLM messages.
560
198
  */
561
199
  getBranch(fromId?: string): SessionEntry[];
562
200
  /**
563
- * Build the session context (what gets sent to the LLM), or — with
564
- * `{ transcript: true }` the full-history display transcript.
565
- * Uses tree traversal from current leaf.
201
+ * Build the session context (LLM messages), or — with `{ transcript: true }` —
202
+ * the full-history display transcript, from the current leaf path.
566
203
  */
567
204
  buildSessionContext(options?: BuildSessionContextOptions): SessionContext;
568
- /** Strip stale OpenAI Responses assistant replay metadata from loaded in-memory entries. */
205
+ /** Strip stale OpenAI Responses assistant replay metadata from loaded entries. */
569
206
  sanitizeLoadedOpenAIResponsesReplayMetadata(): boolean;
570
- /**
571
- * Get session header.
572
- */
573
207
  getHeader(): SessionHeader | null;
574
- /**
575
- * Get all session entries (excludes header). Returns a shallow copy.
576
- * The session is append-only: use appendXXX() to add entries, branch() to
577
- * change the leaf pointer. Entries cannot be modified or deleted.
578
- */
208
+ /** All session entries (excludes header). Returns a shallow copy. */
579
209
  getEntries(): SessionEntry[];
580
210
  /**
581
- * Get the session as a tree structure. Returns a shallow defensive copy of all entries.
582
- * A well-formed session has exactly one root (first entry with parentId === null).
583
- * Orphaned entries (broken parent chain) are also returned as roots.
211
+ * The session as a tree. A well-formed session has exactly one root; orphaned
212
+ * entries (broken parent chain) are returned as roots too.
584
213
  */
585
214
  getTree(): SessionTreeNode[];
586
215
  /**
587
- * Start a new branch from an earlier entry.
588
- * Moves the leaf pointer to the specified entry. The next appendXXX() call
589
- * will create a child of that entry, forming a new branch. Existing entries
590
- * are not modified or deleted.
216
+ * Move the leaf to an earlier entry so the next append forms a new branch.
217
+ * Existing entries are never modified or deleted.
591
218
  */
592
219
  branch(branchFromId: string): void;
593
- /**
594
- * Reset the leaf pointer to null (before any entries).
595
- * The next appendXXX() call will create a new root entry (parentId = null).
596
- * Use this when navigating to re-edit the first user message.
597
- */
220
+ /** Reset the leaf to null so the next append creates a new root entry. */
598
221
  resetLeaf(): void;
599
- /**
600
- * Start a new branch with a summary of the abandoned path.
601
- * Same as branch(), but also appends a branch_summary entry that captures
602
- * context from the abandoned conversation path.
603
- */
222
+ /** Like branch(), but also records a branch_summary of the abandoned path. */
604
223
  branchWithSummary(branchFromId: string | null, summary: string, details?: unknown, fromExtension?: boolean): string;
605
224
  /**
606
- * Create a new session file containing only the path from root to the specified leaf.
607
- * Useful for extracting a single conversation path from a branched session.
608
- * Returns the new session file path, or undefined if not persisting.
225
+ * Create a new session file containing only the path from root to `leafId`.
226
+ * Returns the new file path, or undefined when not persisting.
609
227
  */
610
228
  createBranchedSession(leafId: string): string | undefined;
611
- /**
612
- * Resolve the canonical default session directory for a cwd.
613
- */
229
+ /** Resolve the canonical default session directory for a cwd. */
614
230
  static getDefaultSessionDir(cwd: string, agentDir?: string, storage?: SessionStorage): string;
615
231
  /**
616
232
  * Create a new session.
617
- * @param cwd Working directory (stored in session header)
618
- * @param sessionDir Optional session directory. If omitted, uses default (~/.omp/agent/sessions/<encoded-cwd>/).
233
+ * @param cwd Working directory (stored in the session header)
234
+ * @param sessionDir Optional session directory; defaults to the cwd-derived dir.
619
235
  */
620
236
  static create(cwd: string, sessionDir?: string, storage?: SessionStorage): SessionManager;
621
237
  /**
622
- * Fork a session into the current project directory.
623
- * Copies history from another session file while creating a new session file in the current sessionDir.
238
+ * Fork a session into the current project directory: copy history from another
239
+ * session file while creating a fresh session file in this sessionDir.
624
240
  */
625
241
  static forkFrom(sourcePath: string, cwd: string, sessionDir?: string, storage?: SessionStorage, options?: {
626
242
  suppressBreadcrumb?: boolean;
627
243
  }): Promise<SessionManager>;
628
244
  /**
629
245
  * Open a specific session file.
630
- * @param path Path to session file
631
- * @param sessionDir Optional session directory for /new or /branch. If omitted, derives from file's parent.
246
+ * @param sessionDir Optional dir for /new or /branch; defaults to the file's parent.
632
247
  */
633
248
  static open(filePath: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionManager>;
634
- /**
635
- * Continue the most recent session, or create new if none.
636
- * @param cwd Working directory
637
- * @param sessionDir Optional session directory. If omitted, uses default (~/.omp/agent/sessions/<encoded-cwd>/).
638
- */
249
+ /** Continue the most recent session, or create a new one if none exists. */
639
250
  static continueRecent(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionManager>;
640
- /** Create an in-memory session (no file persistence) */
251
+ /** Create an in-memory session (no file persistence). */
641
252
  static inMemory(cwd?: string, storage?: SessionStorage): SessionManager;
642
253
  /**
643
- * List all sessions.
644
- * @param cwd Working directory (used to compute default session directory)
645
- * @param sessionDir Optional session directory. If omitted, uses default (~/.omp/agent/sessions/<encoded-cwd>/).
254
+ * List sessions for a project directory.
255
+ * @param sessionDir Optional dir; defaults to the cwd-derived dir.
646
256
  */
647
257
  static list(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
648
- /**
649
- * List all sessions across all project directories.
650
- */
258
+ /** List all sessions across all project directories. */
651
259
  static listAll(storage?: SessionStorage): Promise<SessionInfo[]>;
652
260
  }
653
261
  export {};