@gajae-code/coding-agent 0.8.1 → 0.9.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 (253) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/types/append-only-mode.d.ts +31 -0
  3. package/dist/types/capability/rule.d.ts +8 -0
  4. package/dist/types/cli/completion-cli.d.ts +41 -0
  5. package/dist/types/cli/config-cli.d.ts +1 -0
  6. package/dist/types/cli/fixture-report.d.ts +20 -0
  7. package/dist/types/cli/fixture-report.test.d.ts +1 -0
  8. package/dist/types/cli/nofile-limit.d.ts +11 -0
  9. package/dist/types/cli/notify-cli.d.ts +7 -0
  10. package/dist/types/cli/update-cli.d.ts +22 -0
  11. package/dist/types/cli.d.ts +124 -1
  12. package/dist/types/commands/completion.d.ts +29 -0
  13. package/dist/types/commands/config.d.ts +3 -0
  14. package/dist/types/commands/deep-interview.d.ts +3 -0
  15. package/dist/types/config/file-lock.d.ts +7 -6
  16. package/dist/types/config/keybindings.d.ts +2 -2
  17. package/dist/types/config/model-profile-activation.d.ts +6 -0
  18. package/dist/types/config/settings-schema.d.ts +105 -1
  19. package/dist/types/config/settings.d.ts +8 -0
  20. package/dist/types/discovery/index.d.ts +1 -0
  21. package/dist/types/export/html/template.generated.d.ts +1 -1
  22. package/dist/types/export/ttsr.d.ts +14 -3
  23. package/dist/types/extensibility/extensions/runner.d.ts +2 -1
  24. package/dist/types/extensibility/extensions/types.d.ts +8 -0
  25. package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +39 -0
  26. package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +10 -1
  27. package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -1
  28. package/dist/types/gjc-runtime/deep-interview-state.d.ts +17 -2
  29. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +7 -0
  30. package/dist/types/gjc-runtime/state-writer.d.ts +3 -0
  31. package/dist/types/gjc-runtime/team-runtime.d.ts +28 -1
  32. package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +42 -0
  33. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +120 -13
  34. package/dist/types/goals/runtime.d.ts +1 -0
  35. package/dist/types/hooks/native-skill-hook.d.ts +12 -0
  36. package/dist/types/main.d.ts +4 -1
  37. package/dist/types/modes/components/assistant-message.d.ts +5 -1
  38. package/dist/types/modes/components/model-selector.d.ts +4 -0
  39. package/dist/types/modes/components/queued-message-selector.d.ts +12 -0
  40. package/dist/types/modes/components/settings-selector.d.ts +2 -0
  41. package/dist/types/modes/components/status-line.d.ts +9 -0
  42. package/dist/types/modes/controllers/command-controller.d.ts +1 -0
  43. package/dist/types/modes/controllers/event-controller.d.ts +5 -0
  44. package/dist/types/modes/controllers/input-controller.d.ts +1 -3
  45. package/dist/types/modes/interactive-mode.d.ts +2 -0
  46. package/dist/types/modes/print-mode.d.ts +13 -1
  47. package/dist/types/modes/prompt-action-autocomplete.d.ts +1 -1
  48. package/dist/types/modes/rpc/rpc-types.d.ts +14 -0
  49. package/dist/types/modes/shared/agent-wire/event-contract.d.ts +19 -0
  50. package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +23 -1
  51. package/dist/types/modes/types.d.ts +1 -0
  52. package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
  53. package/dist/types/notifications/config.d.ts +14 -1
  54. package/dist/types/notifications/daemon-paths.d.ts +1 -0
  55. package/dist/types/notifications/index.d.ts +6 -3
  56. package/dist/types/notifications/lifecycle-commands.d.ts +11 -3
  57. package/dist/types/notifications/telegram-daemon.d.ts +23 -3
  58. package/dist/types/notifications/telegram-reference.d.ts +0 -5
  59. package/dist/types/notifications/threaded-render.d.ts +6 -0
  60. package/dist/types/runtime-api-key.d.ts +7 -0
  61. package/dist/types/sdk.d.ts +3 -0
  62. package/dist/types/session/agent-session.d.ts +53 -1
  63. package/dist/types/session/agent-storage.d.ts +1 -0
  64. package/dist/types/session/file-mention-pruning.d.ts +8 -0
  65. package/dist/types/session/messages.d.ts +4 -0
  66. package/dist/types/session/session-manager.d.ts +17 -1
  67. package/dist/types/skill-state/active-state.d.ts +18 -1
  68. package/dist/types/system-prompt.d.ts +18 -2
  69. package/dist/types/task/executor.d.ts +3 -0
  70. package/dist/types/task/fork-context-budget.d.ts +7 -0
  71. package/dist/types/task/token-log.d.ts +30 -0
  72. package/dist/types/task/token-log.test.d.ts +1 -0
  73. package/dist/types/tools/bisect.d.ts +81 -0
  74. package/dist/types/tools/computer.d.ts +2 -2
  75. package/dist/types/tools/index.d.ts +1 -0
  76. package/dist/types/tools/search.d.ts +2 -2
  77. package/dist/types/utils/file-mentions.d.ts +14 -0
  78. package/dist/types/utils/git.d.ts +32 -0
  79. package/dist/types/web/scrapers/youtube.d.ts +8 -0
  80. package/dist/types/workflow/workflow-intent-diff.d.ts +8 -2
  81. package/dist/types/workflow/workflow-intent-report-consumer.d.ts +50 -0
  82. package/dist/types/workflow/workflow-intent-report-schema.d.ts +2 -0
  83. package/dist/types/workflow/workflow-intent-report.d.ts +48 -0
  84. package/package.json +7 -7
  85. package/src/append-only-mode.ts +58 -0
  86. package/src/autoresearch/prompt.md +1 -1
  87. package/src/autoresearch/tools/log-experiment.ts +1 -1
  88. package/src/capability/rule.ts +9 -0
  89. package/src/cli/completion-cli.ts +234 -0
  90. package/src/cli/config-cli.ts +61 -9
  91. package/src/cli/fast-help.ts +1 -0
  92. package/src/cli/fixture-report.test.ts +230 -0
  93. package/src/cli/fixture-report.ts +171 -0
  94. package/src/cli/nofile-limit.ts +48 -0
  95. package/src/cli/notify-cli.ts +91 -7
  96. package/src/cli/update-cli.ts +85 -9
  97. package/src/cli.ts +29 -1
  98. package/src/commands/completion.ts +84 -0
  99. package/src/commands/config.ts +2 -0
  100. package/src/commands/contribution-prep.ts +1 -1
  101. package/src/commands/deep-interview.ts +2 -1
  102. package/src/config/file-lock.ts +73 -34
  103. package/src/config/keybindings.ts +2 -2
  104. package/src/config/model-profile-activation.ts +65 -0
  105. package/src/config/model-registry.ts +14 -2
  106. package/src/config/settings-schema.ts +68 -1
  107. package/src/config/settings.ts +22 -0
  108. package/src/coordinator-mcp/server.ts +34 -8
  109. package/src/defaults/gjc/skills/deep-interview/SKILL.md +50 -18
  110. package/src/defaults/gjc/skills/ralplan/SKILL.md +40 -99
  111. package/src/defaults/gjc/skills/team/SKILL.md +17 -14
  112. package/src/defaults/gjc/skills/ultragoal/SKILL.md +59 -4
  113. package/src/defaults/gjc/skills/ultragoal/pipeline-validation-contracts.md +30 -0
  114. package/src/defaults/gjc-defaults.ts +9 -0
  115. package/src/discovery/helpers.ts +10 -0
  116. package/src/discovery/index.ts +1 -0
  117. package/src/export/html/template.generated.ts +1 -1
  118. package/src/export/html/template.js +60 -2
  119. package/src/export/ttsr.ts +96 -18
  120. package/src/extensibility/extensions/runner.ts +183 -219
  121. package/src/extensibility/extensions/types.ts +9 -0
  122. package/src/extensibility/gjc-plugins/runtime-adapters.ts +156 -44
  123. package/src/gjc-runtime/deep-interview-ambiguity.ts +206 -0
  124. package/src/gjc-runtime/deep-interview-recorder.ts +62 -8
  125. package/src/gjc-runtime/deep-interview-runtime.ts +210 -2
  126. package/src/gjc-runtime/deep-interview-state.ts +44 -2
  127. package/src/gjc-runtime/session-state-sidecar.ts +263 -20
  128. package/src/gjc-runtime/state-runtime.ts +12 -2
  129. package/src/gjc-runtime/state-writer.ts +15 -0
  130. package/src/gjc-runtime/team-runtime.ts +187 -15
  131. package/src/gjc-runtime/ultragoal-guard.ts +55 -66
  132. package/src/gjc-runtime/ultragoal-receipt-freshness.ts +315 -0
  133. package/src/gjc-runtime/ultragoal-runtime.ts +1663 -159
  134. package/src/gjc-runtime/workflow-manifest.generated.json +113 -2
  135. package/src/gjc-runtime/workflow-manifest.ts +74 -1
  136. package/src/goals/runtime.ts +10 -2
  137. package/src/hindsight/backend.ts +1 -3
  138. package/src/hooks/native-skill-hook.ts +124 -4
  139. package/src/internal-urls/docs-index.generated.ts +16 -7
  140. package/src/main.ts +95 -43
  141. package/src/memories/index.ts +12 -1
  142. package/src/modes/components/assistant-message.ts +241 -82
  143. package/src/modes/components/custom-editor.ts +1 -0
  144. package/src/modes/components/model-selector.ts +54 -11
  145. package/src/modes/components/queued-message-selector.ts +92 -0
  146. package/src/modes/components/settings-selector.ts +4 -0
  147. package/src/modes/components/status-line.ts +167 -54
  148. package/src/modes/components/tool-execution.ts +44 -19
  149. package/src/modes/components/welcome.ts +160 -44
  150. package/src/modes/controllers/command-controller.ts +40 -4
  151. package/src/modes/controllers/event-controller.ts +66 -47
  152. package/src/modes/controllers/extension-ui-controller.ts +4 -10
  153. package/src/modes/controllers/input-controller.ts +180 -18
  154. package/src/modes/controllers/selector-controller.ts +122 -27
  155. package/src/modes/interactive-mode.ts +51 -16
  156. package/src/modes/print-mode.ts +43 -4
  157. package/src/modes/prompt-action-autocomplete.ts +21 -20
  158. package/src/modes/rpc/rpc-mode.ts +29 -3
  159. package/src/modes/rpc/rpc-types.ts +9 -0
  160. package/src/modes/shared/agent-wire/command-validation.ts +4 -0
  161. package/src/modes/shared/agent-wire/event-contract.ts +22 -0
  162. package/src/modes/shared/agent-wire/event-envelope.ts +82 -0
  163. package/src/modes/shared/agent-wire/scopes.ts +1 -0
  164. package/src/modes/types.ts +1 -0
  165. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  166. package/src/modes/utils/ui-helpers.ts +19 -6
  167. package/src/notifications/config.ts +25 -5
  168. package/src/notifications/daemon-paths.ts +2 -0
  169. package/src/notifications/index.ts +117 -14
  170. package/src/notifications/lifecycle-commands.ts +37 -7
  171. package/src/notifications/lifecycle-orchestrator.ts +19 -6
  172. package/src/notifications/telegram-daemon-cli.ts +2 -2
  173. package/src/notifications/telegram-daemon-control.ts +5 -3
  174. package/src/notifications/telegram-daemon.ts +302 -51
  175. package/src/notifications/telegram-reference.ts +0 -16
  176. package/src/notifications/threaded-render.ts +17 -1
  177. package/src/prompts/agents/architect.md +19 -10
  178. package/src/prompts/agents/critic.md +16 -18
  179. package/src/prompts/agents/executor.md +14 -11
  180. package/src/prompts/agents/planner.md +18 -13
  181. package/src/prompts/ci-green-request.md +3 -8
  182. package/src/prompts/goals/goal-continuation.md +0 -5
  183. package/src/prompts/goals/goal-mode-active.md +0 -5
  184. package/src/prompts/system/agent-creation-architect.md +2 -2
  185. package/src/prompts/system/plan-mode-active.md +1 -1
  186. package/src/prompts/system/plan-mode-subagent.md +3 -3
  187. package/src/prompts/system/project-prompt.md +0 -13
  188. package/src/prompts/system/subagent-system-prompt.md +3 -2
  189. package/src/prompts/system/system-prompt.md +29 -19
  190. package/src/prompts/system/volatile-project-context.md +10 -0
  191. package/src/prompts/system/web-search.md +4 -7
  192. package/src/prompts/tools/apply-patch.md +6 -0
  193. package/src/prompts/tools/ast-edit.md +1 -0
  194. package/src/prompts/tools/bash.md +1 -1
  195. package/src/prompts/tools/bisect.md +22 -0
  196. package/src/prompts/tools/browser.md +1 -1
  197. package/src/prompts/tools/computer.md +2 -2
  198. package/src/prompts/tools/cron.md +0 -2
  199. package/src/prompts/tools/eval.md +2 -2
  200. package/src/prompts/tools/find.md +1 -1
  201. package/src/prompts/tools/github.md +6 -6
  202. package/src/prompts/tools/goal.md +1 -3
  203. package/src/prompts/tools/image-gen.md +12 -5
  204. package/src/prompts/tools/irc.md +5 -4
  205. package/src/prompts/tools/job.md +2 -2
  206. package/src/prompts/tools/lsp.md +1 -1
  207. package/src/prompts/tools/monitor.md +2 -2
  208. package/src/prompts/tools/patch.md +2 -2
  209. package/src/prompts/tools/replace.md +2 -21
  210. package/src/prompts/tools/rewind.md +1 -1
  211. package/src/prompts/tools/search-tool-bm25.md +1 -11
  212. package/src/prompts/tools/search.md +1 -1
  213. package/src/prompts/tools/skill.md +3 -2
  214. package/src/prompts/tools/ssh.md +2 -1
  215. package/src/prompts/tools/subagent.md +2 -2
  216. package/src/prompts/tools/task.md +4 -5
  217. package/src/prompts/tools/todo-write.md +1 -1
  218. package/src/prompts/tools/vim.md +1 -0
  219. package/src/prompts/tools/web-search.md +2 -0
  220. package/src/prompts/tools/write.md +8 -2
  221. package/src/runtime-api-key.ts +16 -0
  222. package/src/sdk.ts +52 -28
  223. package/src/session/agent-session.ts +951 -132
  224. package/src/session/agent-storage.ts +4 -0
  225. package/src/session/file-mention-pruning.ts +64 -0
  226. package/src/session/messages.ts +4 -0
  227. package/src/session/session-manager.ts +103 -4
  228. package/src/skill-state/active-state.ts +141 -5
  229. package/src/skill-state/deep-interview-mutation-guard.ts +67 -3
  230. package/src/slash-commands/builtin-registry.ts +218 -71
  231. package/src/system-prompt.ts +57 -16
  232. package/src/task/executor.ts +132 -24
  233. package/src/task/fork-context-advisory.ts +2 -7
  234. package/src/task/fork-context-budget.ts +9 -0
  235. package/src/task/index.ts +13 -6
  236. package/src/task/output-manager.ts +20 -8
  237. package/src/task/receipt.ts +26 -7
  238. package/src/task/token-log.test.ts +188 -0
  239. package/src/task/token-log.ts +179 -0
  240. package/src/tools/bisect.ts +367 -0
  241. package/src/tools/computer.ts +246 -43
  242. package/src/tools/index.ts +3 -0
  243. package/src/tools/output-meta.ts +116 -4
  244. package/src/tools/search.ts +8 -2
  245. package/src/tools/skill.ts +15 -0
  246. package/src/tools/telegram-send.ts +6 -0
  247. package/src/utils/file-mentions.ts +39 -7
  248. package/src/utils/git.ts +73 -0
  249. package/src/web/scrapers/youtube.ts +24 -12
  250. package/src/workflow/workflow-intent-diff.ts +29 -6
  251. package/src/workflow/workflow-intent-report-consumer.ts +221 -0
  252. package/src/workflow/workflow-intent-report-schema.ts +129 -0
  253. package/src/workflow/workflow-intent-report.ts +135 -0
@@ -23,6 +23,7 @@ export declare class CommandController {
23
23
  handleContextCommand(): void;
24
24
  handleMemoryCommand(text: string): Promise<void>;
25
25
  handleClearCommand(): Promise<void>;
26
+ handleContextClearCommand(): Promise<void>;
26
27
  handleDropCommand(): Promise<void>;
27
28
  handleForkCommand(): Promise<void>;
28
29
  handleMoveCommand(targetPath: string): Promise<void>;
@@ -1,5 +1,10 @@
1
1
  import type { InteractiveModeContext } from "../../modes/types";
2
2
  import type { AgentSessionEvent } from "../../session/agent-session";
3
+ /** Test-only performance counters for advisory baseline tests. */
4
+ export declare const __eventControllerPerfCounters: {
5
+ messageUpdateContentVisits: number;
6
+ reset(): void;
7
+ };
3
8
  export declare class EventController {
4
9
  #private;
5
10
  private ctx;
@@ -14,9 +14,7 @@ export declare class InputController {
14
14
  handleFollowUp(): Promise<void>;
15
15
  /** Send editor text explicitly as a queued next-turn message. */
16
16
  handleQueueSubmit(): Promise<void>;
17
- restoreLatestQueuedMessageToEditor(options?: {
18
- currentText?: string;
19
- }): number;
17
+ restoreLatestQueuedMessageToEditor(): number;
20
18
  restoreQueuedMessagesToEditor(options?: {
21
19
  abort?: boolean;
22
20
  currentText?: string;
@@ -27,6 +27,7 @@ import { type WelcomeLogoMode } from "./components/welcome";
27
27
  import { OAuthManualInputManager } from "./oauth-manual-input";
28
28
  import type { Theme } from "./theme/theme";
29
29
  import type { CompactionQueuedMessage, InteractiveModeContext, SubmittedUserInput, TodoItem, TodoPhase } from "./types";
30
+ export declare const DEFAULT_COMPOSER_PLACEHOLDER: string;
30
31
  export type WelcomeBannerSettingMode = "auto" | "unicode" | "square" | "ascii";
31
32
  export declare function resolveWelcomeLogoMode(mode: WelcomeBannerSettingMode, env?: Record<string, string | undefined>, platform?: NodeJS.Platform): WelcomeLogoMode;
32
33
  /** Options for creating an InteractiveMode instance (for future API use) */
@@ -189,6 +190,7 @@ export declare class InteractiveMode implements InteractiveModeContext {
189
190
  handleToolsCommand(): void;
190
191
  handleContextCommand(): void;
191
192
  handleClearCommand(): Promise<void>;
193
+ handleContextClearCommand(): Promise<void>;
192
194
  handleDropCommand(): Promise<void>;
193
195
  handleForkCommand(): Promise<void>;
194
196
  handleMoveCommand(targetPath: string): Promise<void>;
@@ -5,7 +5,7 @@
5
5
  * - `gjc -p "prompt"` - text output
6
6
  * - `gjc --mode json "prompt"` - JSON event stream
7
7
  */
8
- import type { ImageContent } from "@gajae-code/ai";
8
+ import { type ImageContent } from "@gajae-code/ai";
9
9
  import type { AgentSession } from "../session/agent-session";
10
10
  /**
11
11
  * Options for print mode.
@@ -26,6 +26,18 @@ export interface PrintModeOptions {
26
26
  */
27
27
  suppressProcessExit?: boolean;
28
28
  }
29
+ /**
30
+ * Exit code used when a non-interactive **text-mode** run (`gjc -p`) terminates
31
+ * because the model context window is exhausted and automatic compaction could
32
+ * not bring the request under the limit. Distinct from the generic failure code
33
+ * (1) so text-mode callers can detect context exhaustion specifically instead of
34
+ * parsing the raw provider error string.
35
+ *
36
+ * Scope: text-mode final-response path only. JSON mode (`--mode json`) streams
37
+ * events from the subscription and does not run this terminal-error branch, so
38
+ * it is intentionally NOT covered by this exit code.
39
+ */
40
+ export declare const CONTEXT_OVERFLOW_EXIT_CODE = 2;
29
41
  /**
30
42
  * Run in print (single-shot) mode.
31
43
  * Sends prompts to the agent and outputs the result.
@@ -1,4 +1,4 @@
1
- import type { AutocompleteItem, AutocompleteProvider, SlashCommand } from "@gajae-code/tui";
1
+ import { type AutocompleteItem, type AutocompleteProvider, type SlashCommand } from "@gajae-code/tui";
2
2
  import type { KeybindingsManager } from "../config/keybindings";
3
3
  interface PromptActionDefinition {
4
4
  id: string;
@@ -12,6 +12,7 @@ import type { ContextUsage } from "../../extensibility/extensions/types";
12
12
  import type { SessionStats } from "../../session/agent-session";
13
13
  import type { TodoPhase } from "../../tools/todo-write";
14
14
  export type RpcGetStateInclude = "tools" | "dumpTools" | "systemPrompt";
15
+ export type RpcCapability = "compact_message_update";
15
16
  export type RpcCommand = {
16
17
  id?: string;
17
18
  type: "prompt";
@@ -59,6 +60,10 @@ export type RpcCommand = {
59
60
  } | {
60
61
  id?: string;
61
62
  type: "get_pending_workflow_gates";
63
+ } | {
64
+ id?: string;
65
+ type: "set_capabilities";
66
+ capabilities: RpcCapability[];
62
67
  } | {
63
68
  id?: string;
64
69
  type: "set_model";
@@ -258,6 +263,15 @@ export type RpcResponse = {
258
263
  data: {
259
264
  gates: RpcWorkflowGate[];
260
265
  };
266
+ } | {
267
+ id?: string;
268
+ type: "response";
269
+ command: "set_capabilities";
270
+ success: true;
271
+ data: {
272
+ acceptedCapabilities: RpcCapability[];
273
+ unsupported: string[];
274
+ };
261
275
  } | {
262
276
  id?: string;
263
277
  type: "response";
@@ -13,6 +13,7 @@
13
13
  * an `AgentSessionEvent` variant fails typecheck until it is registered, and so
14
14
  * conformance tests can assert fixture coverage equals the registry exactly.
15
15
  */
16
+ import type { AssistantMessageEvent } from "@gajae-code/ai";
16
17
  import type { AgentSessionEvent } from "../../../session/agent-session";
17
18
  /** Wire protocol version. Bump on breaking envelope/semantic changes. */
18
19
  export declare const AGENT_WIRE_PROTOCOL_VERSION: 2;
@@ -29,6 +30,23 @@ export interface AgentWireEventPayload {
29
30
  event_type: AgentWireEventType;
30
31
  event: AgentSessionEvent;
31
32
  }
33
+ export type AgentWireCompactAssistantMessageEvent = AssistantMessageEvent extends infer TEvent ? TEvent extends {
34
+ type: string;
35
+ } ? Omit<TEvent, "partial" | "message" | "error"> : never : never;
36
+ export interface AgentWireCompactMessageUpdatePayload {
37
+ event_type: "message_update";
38
+ /** Compact RPC opt-in payload: delta-only update plus minimal routing metadata. */
39
+ compact: true;
40
+ message_id: string | null;
41
+ content_index: number | null;
42
+ assistantMessageEvent: AgentWireCompactAssistantMessageEvent;
43
+ /** Full message checkpoint, snapshotted synchronously when this frame is enqueued. */
44
+ checkpoint_message?: Extract<AgentSessionEvent, {
45
+ type: "message_update";
46
+ }>["message"];
47
+ checkpoint_reason?: "periodic";
48
+ }
49
+ export type AgentWireEventFramePayload = AgentWireEventPayload | AgentWireCompactMessageUpdatePayload;
32
50
  /**
33
51
  * Bounded observed-signal vocabulary surfaced to owner control planes. Mirrors
34
52
  * the Harness `ObservedSignal` set; the Harness type aliases this in a later
@@ -82,3 +100,4 @@ export interface AgentWireFrameEnvelope<TType extends AgentWireFrameType = Agent
82
100
  }
83
101
  /** An `AgentSessionEvent` serialized into a versioned wire frame. */
84
102
  export type AgentWireEventFrame = AgentWireFrameEnvelope<"event", AgentWireEventPayload>;
103
+ export type AgentWireCompactEventFrame = AgentWireFrameEnvelope<"event", AgentWireEventFramePayload>;
@@ -1,5 +1,6 @@
1
1
  import type { AgentSessionEvent } from "../../../session/agent-session";
2
- import { type AgentWireEventFrame, type AgentWireEventPayload, type AgentWireEventType, type AgentWireFrameEnvelope, type AgentWireFrameType } from "./event-contract";
2
+ import { type AgentWireCompactAssistantMessageEvent, type AgentWireCompactEventFrame, type AgentWireEventFrame, type AgentWireEventPayload, type AgentWireEventType, type AgentWireFrameEnvelope, type AgentWireFrameType } from "./event-contract";
3
+ export declare const AGENT_WIRE_COMPACT_MESSAGE_UPDATE_CHECKPOINT_INTERVAL = 32;
3
4
  /**
4
5
  * Resolve the stable wire event-type for an `AgentSessionEvent`.
5
6
  *
@@ -27,6 +28,27 @@ export type BridgeFrameSequencer = AgentWireFrameSequencer;
27
28
  export declare function toAgentWireEventFrame(event: AgentSessionEvent, sequencer: AgentWireFrameSequencer): AgentWireEventFrame;
28
29
  /** Build the rich event payload (renderer-facing) for an `AgentSessionEvent`. */
29
30
  export declare function toAgentWireEventPayload(event: AgentSessionEvent): AgentWireEventPayload;
31
+ export declare function sanitizeAssistantMessageEventForCompact(assistantMessageEvent: Extract<AgentSessionEvent, {
32
+ type: "message_update";
33
+ }>["assistantMessageEvent"]): AgentWireCompactAssistantMessageEvent;
34
+ export interface AgentWireCompactMessageUpdateOptions {
35
+ checkpointInterval?: number;
36
+ }
37
+ /**
38
+ * Stateful compact event serializer for opt-in RPC clients.
39
+ *
40
+ * Only `message_update` changes shape: it carries the immutable provider delta
41
+ * plus message/content identifiers, with periodic full-message checkpoints that
42
+ * are cloned synchronously before the caller returns to the event loop. All other
43
+ * event variants remain canonical full event frames so legacy bridge/RPC behavior
44
+ * and terminal `message_end` reconstruction are unchanged.
45
+ */
46
+ export declare class AgentWireCompactEventEncoder {
47
+ #private;
48
+ constructor(sequencer: AgentWireFrameSequencer, options?: AgentWireCompactMessageUpdateOptions);
49
+ frame(event: AgentSessionEvent): AgentWireCompactEventFrame;
50
+ }
51
+ export declare function toAgentWireCompactEventFrame(event: AgentSessionEvent, encoder: AgentWireCompactEventEncoder): AgentWireCompactEventFrame;
30
52
  /** Back-compat alias for {@link toAgentWireEventFrame}. */
31
53
  export declare const toBridgeEventFrame: typeof toAgentWireEventFrame;
32
54
  /**
@@ -198,6 +198,7 @@ export interface InteractiveModeContext {
198
198
  handleDumpCommand(): void;
199
199
  handleDebugTranscriptCommand(): Promise<void>;
200
200
  handleClearCommand(): Promise<void>;
201
+ handleContextClearCommand(): Promise<void>;
201
202
  handleDropCommand(): Promise<void>;
202
203
  handleForkCommand(): Promise<void>;
203
204
  handleBashCommand(command: string, excludeFromContext?: boolean): Promise<void>;
@@ -6,6 +6,7 @@ import type { SessionContext } from "../../session/session-manager";
6
6
  interface RenderInitialMessagesOptions {
7
7
  preserveExistingChat?: boolean;
8
8
  }
9
+ export declare function argsWithPartialJson(args: unknown, partialJson: unknown): unknown;
9
10
  export declare class UiHelpers {
10
11
  #private;
11
12
  private ctx;
@@ -17,12 +17,24 @@ export interface NotificationConfig {
17
17
  }
18
18
  /** Read typed config from Settings. */
19
19
  export declare function getNotificationConfig(settings: Settings): NotificationConfig;
20
+ export declare function hasNonBlankValue(value: string | undefined): boolean;
21
+ /** Is Telegram configured with usable non-blank boundary credentials? */
22
+ export declare function isTelegramConfigured(cfg: NotificationConfig): cfg is NotificationConfig & {
23
+ botToken: string;
24
+ chatId: string;
25
+ };
20
26
  /** Is global config sufficient for auto-on (enabled + at least one configured adapter)? */
21
27
  export declare function isGloballyConfigured(cfg: NotificationConfig): boolean;
22
28
  /** Resolve whether the notifications extension should be registered at SDK startup. */
23
29
  export declare function shouldRegisterNotificationsExtension(input: {
24
30
  env: NodeJS.ProcessEnv;
25
31
  cfg?: NotificationConfig;
32
+ /** Task recursion depth; helper/subagent sessions must not spawn remote surfaces. */
33
+ taskDepth?: number;
34
+ /** Parent subagent id/prefix; present for helper/subagent sessions even when depth is omitted. */
35
+ parentTaskPrefix?: string;
36
+ /** Role-agent type/name; present for task sessions even if depth metadata is lost. */
37
+ currentAgentType?: string;
26
38
  }): boolean;
27
39
  /**
28
40
  * Resolve whether THIS session should run notifications.
@@ -61,7 +73,8 @@ export interface RedactableAction {
61
73
  * When redact is false, return the action unchanged.
62
74
  *
63
75
  * Redaction still applies to streamed content frames (turn_stream, context_update,
64
- * image_attachment) which are suppressed at their emit sites, not here.
76
+ * image_attachment) which are suppressed at their emit sites, not here. Explicit
77
+ * `telegram_send` file attachments are rejected before the file is read or forwarded.
65
78
  */
66
79
  export declare function buildRedactedAction(action: RedactableAction, opts: {
67
80
  redact: boolean;
@@ -5,5 +5,6 @@ export interface DaemonPaths {
5
5
  roots: string;
6
6
  steal: string;
7
7
  aliases: string;
8
+ seenUpdates: string;
8
9
  }
9
10
  export declare function daemonPaths(agentDir: string): DaemonPaths;
@@ -17,7 +17,8 @@
17
17
  * Enable with Settings notifications config, `GJC_NOTIFICATIONS=1` (a token is
18
18
  * generated), or `GJC_NOTIFICATIONS_TOKEN`.
19
19
  */
20
- import type { ExtensionFactory } from "../extensibility/extensions";
20
+ import { Settings } from "../config/settings";
21
+ import type { ExtensionAPI } from "../extensibility/extensions";
21
22
  /** Where a `session_create` should run. Discriminated by `kind`. */
22
23
  export type SessionCreateTarget = {
23
24
  kind: "existing_path";
@@ -69,7 +70,7 @@ export interface SessionCloseFrame {
69
70
  chatId: string;
70
71
  token: string;
71
72
  target: SessionCloseTarget;
72
- /** Hard-kill even if a live pane is attached (GJC-managed only). */
73
+ /** Required force-only close flag; false/omitted is rejected by daemon policy. */
73
74
  force?: boolean;
74
75
  }
75
76
  /** Resume a session (reattach if alive, else cold-restart from history). */
@@ -173,4 +174,6 @@ export interface SessionReadyFrame {
173
174
  */
174
175
  export declare function readGitRepoName(cwd: string): string | undefined;
175
176
  export declare function notificationsEnabled(): boolean;
176
- export declare const createNotificationsExtension: ExtensionFactory;
177
+ export declare function createNotificationsExtension(api: ExtensionAPI, options?: {
178
+ settings?: Settings;
179
+ }): void;
@@ -23,8 +23,13 @@ export type ParsedLifecycleCommand = {
23
23
  } | {
24
24
  kind: "none";
25
25
  };
26
- /** True when the text begins a /session_* command (cheap pre-gate). */
27
- export declare function isLifecycleCommandText(text: string | undefined): boolean;
26
+ /** True when the text begins with any /session_* token, regardless of addressability. */
27
+ export declare function isLifecycleCommandLikeText(text: string | undefined): boolean;
28
+ /** True when the text begins an addressable /session_* command (cheap pre-gate). */
29
+ export declare function isLifecycleCommandText(text: string | undefined, ctx?: {
30
+ chatType?: string;
31
+ botUsername?: string;
32
+ }): boolean;
28
33
  /**
29
34
  * Parse a paired-chat message into a lifecycle command. Returns `none` for
30
35
  * non-lifecycle text, `usage`/`reject` for malformed input (no side effect), or
@@ -33,7 +38,10 @@ export declare function isLifecycleCommandText(text: string | undefined): boolea
33
38
  * The caller MUST have already enforced paired-chat authorization; this function
34
39
  * performs grammar + target validation only.
35
40
  */
36
- export declare function parseLifecycleCommand(text: string | undefined): ParsedLifecycleCommand;
41
+ export declare function parseLifecycleCommand(text: string | undefined, ctx?: {
42
+ chatType?: string;
43
+ botUsername?: string;
44
+ }): ParsedLifecycleCommand;
37
45
  /** The canonical usage text (exported for the daemon's help replies). */
38
46
  export declare function lifecycleUsage(): string;
39
47
  /**
@@ -3,8 +3,8 @@ import type { Settings } from "../config/settings";
3
3
  import type { DaemonRuntimeInfo } from "../daemon/control-types";
4
4
  import { type ControlServerLike, type LifecycleControlServerFactory } from "./lifecycle-control-runtime";
5
5
  import { NotificationOperatorRuntime, OperatorBackoffPolicy } from "./operator-runtime";
6
- import { type AliasTable, type CallbackRoute, type PendingAsk } from "./telegram-reference";
7
- export type EnsureDaemonResult = "owner_spawned" | "attached" | "disabled";
6
+ import { type AliasTable, type CallbackRoute } from "./telegram-reference";
7
+ export type EnsureDaemonResult = "owner_spawned" | "attached" | "disabled" | "blocked";
8
8
  export interface DaemonState {
9
9
  pid: number;
10
10
  ownerId: string;
@@ -95,6 +95,8 @@ export declare function acquireDaemonOwnership(input: {
95
95
  acquired: boolean;
96
96
  ownerId?: string;
97
97
  attached?: boolean;
98
+ blocked?: boolean;
99
+ reason?: "identity_mismatch";
98
100
  }>;
99
101
  export declare function renewDaemonHeartbeat(input: {
100
102
  settings: Settings;
@@ -252,6 +254,8 @@ export declare class TelegramNotificationDaemon {
252
254
  private readonly opts;
253
255
  readonly aliasTable: AliasTable;
254
256
  readonly messageRoutes: Map<string | number, CallbackRoute | Omit<CallbackRoute, "answer">>;
257
+ /** Telegram message id backing each streamed `${sessionId}:${coalesceKey}`, for in-place edits. */
258
+ private readonly liveMessages;
255
259
  readonly sessions: Map<string, SessionSocket>;
256
260
  private readonly runtime;
257
261
  private readonly sessionRouter;
@@ -276,6 +280,8 @@ export declare class TelegramNotificationDaemon {
276
280
  private readonly flatIdentitySent;
277
281
  /** Cached result of whether the paired chat is a private chat (flat-fallback gate). */
278
282
  private pairedChatPrivate;
283
+ /** Bot username from getMe, cached once at owner startup for group/forum command targeting. */
284
+ private botUsername;
279
285
  /** Sessions whose agent loop is currently busy (drives the typing indicator). */
280
286
  private get busy();
281
287
  /** Inbound update id → originating Telegram message, for delivery reactions. */
@@ -317,12 +323,17 @@ export declare class TelegramNotificationDaemon {
317
323
  /** Build an authenticated lifecycle frame from a parsed command + identity. */
318
324
  private buildLifecycleFrame;
319
325
  private handleLifecycleCommand;
326
+ private refreshBotIdentity;
320
327
  /** Map a lifecycle response/error to a user-facing message (G010 surfacing). */
321
328
  private formatLifecycleResponse;
322
329
  constructor(opts: TelegramDaemonOptions);
323
330
  private createSessionRouter;
324
331
  loadAliases(): Promise<void>;
325
332
  persistAliases(): Promise<void>;
333
+ loadSeenUpdateIds(): Promise<void>;
334
+ persistSeenUpdateIds(): Promise<void>;
335
+ private pruneSeenUpdateIds;
336
+ private rememberSeenUpdateId;
326
337
  scanRoots(): Promise<void>;
327
338
  connectSession(sessionId: string, url: string, token: string): void;
328
339
  /**
@@ -340,12 +351,15 @@ export declare class TelegramNotificationDaemon {
340
351
  * the socket. `scanRoots()` then reconnects the session.
341
352
  */
342
353
  private dropSession;
354
+ private deleteMessageRoutes;
343
355
  private static readonly THREADED_FRAMES;
344
356
  private topicNameFor;
345
357
  private topicIdentityKey;
346
358
  private topicIdentityBase;
347
359
  private topicOwnerForIdentity;
360
+ private sessionCanClaimIdentity;
348
361
  private submitThreadedFrame;
362
+ private existingTopicForPrivateChat;
349
363
  private rememberPendingThreadedFrame;
350
364
  private flushPendingThreadedFrames;
351
365
  private ensureTopic;
@@ -363,6 +377,12 @@ export declare class TelegramNotificationDaemon {
363
377
  private cleanupAllAttachmentDirs;
364
378
  private resolveInboundAttachment;
365
379
  private flushPool;
380
+ /**
381
+ * Track the Telegram message id backing a streamed `(sessionId, coalesceKey)`
382
+ * so later live/finalized frames edit it in place. Evicts this session's stale
383
+ * same-category entries (e.g. prior turns) so the map stays bounded.
384
+ */
385
+ private recordLiveMessage;
366
386
  private deliverFlatFallback;
367
387
  private pairedChatIsPrivate;
368
388
  private notifyThreadedFallback;
@@ -376,7 +396,7 @@ export declare class TelegramNotificationDaemon {
376
396
  private startTypingTimer;
377
397
  private stopTypingTimer;
378
398
  handleSessionMessage(session: SessionSocket, msg: any): Promise<void>;
379
- pendingBySession: (sessionId?: string) => PendingAsk[];
399
+ private answerCallbackQueryBestEffort;
380
400
  private sendStaleGuidance;
381
401
  handleTelegramUpdate(update: unknown): Promise<void>;
382
402
  pollOnce(signal?: AbortSignal): Promise<number>;
@@ -81,14 +81,9 @@ export type RouteDecision = ({
81
81
  } | {
82
82
  kind: "ignore";
83
83
  };
84
- export interface PendingAsk {
85
- sessionId: string;
86
- actionId: string;
87
- }
88
84
  export interface RouteInboundContext {
89
85
  aliasTable: Pick<AliasTable, "get">;
90
86
  messageRoutes: Map<string | number, CallbackRoute | Omit<CallbackRoute, "answer">>;
91
- pendingBySession: (sessionId?: string) => PendingAsk[];
92
87
  pairedChatId: string;
93
88
  }
94
89
  /** Route a Telegram update to a session/action without I/O. Fail closed under ambiguity. */
@@ -28,6 +28,12 @@ export interface ThreadedSend {
28
28
  coalesceKey?: string;
29
29
  /** True for the one-time identity header (the daemon pins it once). */
30
30
  identity?: boolean;
31
+ /**
32
+ * When true the daemon may deliver this as an in-place edit of the message
33
+ * previously sent under the same `(sessionId, coalesceKey)` instead of a new
34
+ * message. Set for streamed turn frames so live + finalized share one message.
35
+ */
36
+ editable?: boolean;
31
37
  }
32
38
  interface ThreadedFrame {
33
39
  type?: unknown;
@@ -0,0 +1,7 @@
1
+ export interface RuntimeApiKeyTarget {
2
+ setRuntimeApiKey(provider: string, apiKey: string): void;
3
+ }
4
+ export interface RuntimeApiKeyModel {
5
+ provider: string;
6
+ }
7
+ export declare function applyCliRuntimeApiKeyOverride(target: RuntimeApiKeyTarget, apiKey: string | undefined, model: RuntimeApiKeyModel | undefined): void;
@@ -1,5 +1,6 @@
1
1
  import { type AgentTelemetryConfig, type ThinkingLevel } from "@gajae-code/agent-core";
2
2
  import { type Model, type ProviderSessionState } from "@gajae-code/ai";
3
+ import { createAppendOnlyContextManager, providerSupportsAppendOnlyAuto, resolveAppendOnlyMode } from "./append-only-mode";
3
4
  import { type Rule } from "./capability/rule";
4
5
  import { ModelRegistry } from "./config/model-registry";
5
6
  import { type ScopedModelSelection } from "./config/model-resolver";
@@ -241,5 +242,7 @@ export interface BuildSystemPromptOptions {
241
242
  * as separate entries so providers can cache prompt prefixes without concatenating blocks.
242
243
  */
243
244
  export declare function buildSystemPrompt(options?: BuildSystemPromptOptions): Promise<BuildSystemPromptResult>;
245
+ export { createAppendOnlyContextManager, providerSupportsAppendOnlyAuto, resolveAppendOnlyMode };
244
246
  export declare function createPluginHooksExtension(hooks: ConstrainedPluginHook[]): ExtensionFactory;
247
+ export declare function resolveIntentTracingEnabled(intentTracingSetting: boolean | undefined, hasUI: boolean): boolean;
245
248
  export declare function createAgentSession(options?: CreateAgentSessionOptions): Promise<CreateAgentSessionResult>;
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { type Agent, type AgentEvent, type AgentMessage, type AgentState, type AgentTool, type StablePrefixSnapshot, ThinkingLevel } from "@gajae-code/agent-core";
16
16
  import { type CompactionResult, type EmergencyCompactionSample } from "@gajae-code/agent-core/compaction";
17
- import type { AssistantMessage, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolChoice, UsageReport } from "@gajae-code/ai";
17
+ import type { AssistantMessage, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolCall, ToolChoice, UsageReport } from "@gajae-code/ai";
18
18
  export interface ForkContextSeedMetadata {
19
19
  sourceSessionId: string;
20
20
  parentMessageCount: number;
@@ -75,6 +75,7 @@ import { type DiscoverableTool, type DiscoverableToolSearchIndex } from "../tool
75
75
  import type { AskAnswerSource, ToolSession } from "../tools";
76
76
  import type { CheckpointState } from "../tools/checkpoint";
77
77
  import { type TodoItem, type TodoPhase } from "../tools/todo-write";
78
+ import { type WorkspaceTree } from "../workspace-tree";
78
79
  import type { ClientBridge } from "./client-bridge";
79
80
  import { type ContributionPrepOptions, type ContributionPrepResult } from "./contribution-prep";
80
81
  import { type CustomMessage } from "./messages";
@@ -200,6 +201,8 @@ export interface AgentSessionConfig {
200
201
  rebuildSystemPrompt?: (toolNames: string[], tools: Map<string, AgentTool>) => Promise<{
201
202
  systemPrompt: string[];
202
203
  }>;
204
+ /** Initial workspace tree snapshot used for the first volatile per-turn context message. */
205
+ workspaceTree?: WorkspaceTree;
203
206
  /** Rebuild the SSH tool from current capability discovery results. */
204
207
  reloadSshTool?: () => Promise<AgentTool | null>;
205
208
  requestedToolNames?: ReadonlySet<string>;
@@ -317,6 +320,13 @@ export interface SessionStats {
317
320
  premiumRequests: number;
318
321
  cost: number;
319
322
  }
323
+ export type QueuedMessageEditMode = "steer" | "followUp";
324
+ export interface QueuedMessageEditEntry {
325
+ id: string;
326
+ text: string;
327
+ mode: QueuedMessageEditMode;
328
+ label: string;
329
+ }
320
330
  /** A custom message contributed at the before-agent-start point. */
321
331
  export type BeforeAgentStartInternalMessage = Pick<CustomMessage, "customType" | "content" | "display" | "details" | "attribution">;
322
332
  /**
@@ -329,6 +339,33 @@ export type BeforeAgentStartContributor = (event: {
329
339
  images?: ImageContent[];
330
340
  sessionId: string | undefined;
331
341
  }) => Promise<BeforeAgentStartInternalMessage | undefined>;
342
+ export declare class WorkerIntegrationRequestScheduler {
343
+ #private;
344
+ readonly request: () => Promise<void>;
345
+ constructor(request: () => Promise<void>);
346
+ enqueue(): void;
347
+ flush(): Promise<void>;
348
+ }
349
+ export type StreamingEditParsedToolCall = {
350
+ toolCall: ToolCall;
351
+ path: string;
352
+ resolvedPath: string;
353
+ diff?: string;
354
+ op?: string;
355
+ rename?: string;
356
+ };
357
+ export type StreamingEditParsedCacheEntry = {
358
+ version: string;
359
+ parsed: StreamingEditParsedToolCall | undefined;
360
+ };
361
+ export declare function getStreamingEditToolCallForEvent(event: AgentEvent, cache: Map<string, StreamingEditParsedCacheEntry>, resolvePath: (filePath: string) => string | undefined): StreamingEditParsedToolCall | undefined;
362
+ /** Test-only counters for AgentSession event fan-out hot-path assertions. */
363
+ export declare const __agentSessionPerfCounters: {
364
+ listenerSnapshotRebuilds: number;
365
+ messageUpdateExtensionQueues: number;
366
+ reset(): void;
367
+ };
368
+ export declare function buildContextInjectionSignature(kind: string, parts: readonly string[]): string;
332
369
  export declare class AgentSession {
333
370
  #private;
334
371
  readonly agent: Agent;
@@ -337,6 +374,13 @@ export declare class AgentSession {
337
374
  readonly taskDepth: number;
338
375
  readonly yieldQueue: YieldQueue;
339
376
  readonly configWarnings: string[];
377
+ readonly streamingEditDebugCounters: {
378
+ guardRuns: number;
379
+ processedChars: number;
380
+ checkedRemovedLines: number;
381
+ fullChecks: number;
382
+ nonEditDeterminations: number;
383
+ };
340
384
  readonly rawSseDebugBuffer: RawSseDebugBuffer;
341
385
  constructor(config: AgentSessionConfig);
342
386
  /** Model registry for API key resolution and model discovery */
@@ -670,6 +714,9 @@ export declare class AgentSession {
670
714
  steering: readonly string[];
671
715
  followUp: readonly string[];
672
716
  };
717
+ getQueuedMessageEntries(): QueuedMessageEditEntry[];
718
+ removeQueuedMessageForEditing(id: string): string | undefined;
719
+ moveQueuedMessageForEditing(id: string, direction: "up" | "down"): boolean;
673
720
  /**
674
721
  * Pop the newest queued message across steering and follow-up queues.
675
722
  * Used by dequeue keybinding to restore messages to editor one at a time.
@@ -706,6 +753,11 @@ export declare class AgentSession {
706
753
  * @returns true if completed, false if cancelled by hook
707
754
  */
708
755
  newSession(options?: NewSessionOptions): Promise<boolean>;
756
+ /**
757
+ * Clear active conversational/model context while preserving the current
758
+ * session identity and durable history trail.
759
+ */
760
+ clearContext(): Promise<boolean>;
709
761
  /**
710
762
  * Set a display name for the current session.
711
763
  */
@@ -93,6 +93,7 @@ export declare class AgentStorage {
93
93
  * Sets a cached value with expiry time (unix seconds).
94
94
  */
95
95
  setCache(key: string, value: string, expiresAtSec: number): void;
96
+ deleteCachePrefix(prefix: string): void;
96
97
  /**
97
98
  * Deletes expired cache entries. Call periodically for cleanup.
98
99
  */
@@ -0,0 +1,8 @@
1
+ import type { SessionEntry, SessionMessageEntry } from "./session-manager";
2
+ export interface FileMentionPruneResult {
3
+ changed: SessionMessageEntry[];
4
+ bytesSaved: number;
5
+ }
6
+ /** Notice injected in place of a superseded file-mention body. */
7
+ export declare function stalefileMentionNotice(path: string): string;
8
+ export declare function pruneStaleFileMentions(entries: readonly SessionEntry[], resolveAbs: (path: string) => string): FileMentionPruneResult;
@@ -129,6 +129,10 @@ export interface FileMentionMessage {
129
129
  /** Why the file contents were omitted from auto-read. */
130
130
  skippedReason?: "tooLarge";
131
131
  image?: ImageContent;
132
+ /** Set when this mention duplicated a recently shown path (compact note, no full body). */
133
+ duplicate?: boolean;
134
+ /** Set when a stale entry was pruned to a digest notice (never silently deleted). */
135
+ pruned?: boolean;
132
136
  }>;
133
137
  timestamp: number;
134
138
  }
@@ -1,5 +1,6 @@
1
1
  import type { AgentMessage } from "@gajae-code/agent-core";
2
2
  import type { ImageContent, Message, MessageAttribution, ServiceTier, TextContent } from "@gajae-code/ai";
3
+ import type { TtsrInjectionRecord } from "../export/ttsr";
3
4
  import { ArtifactManager } from "./artifacts";
4
5
  import { type BlobPutResult, BlobStore } from "./blob-store";
5
6
  import { type BashExecutionMessage, type CustomMessage, type FileMentionMessage, type HookMessage, type PythonExecutionMessage } from "./messages";
@@ -141,6 +142,10 @@ export interface TtsrInjectionEntry extends SessionEntryBase {
141
142
  type: "ttsr_injection";
142
143
  /** Names of rules that were injected */
143
144
  injectedRules: string[];
145
+ /** Rich rule injection records with repeat state. */
146
+ injectedRuleRecords?: TtsrInjectionRecord[];
147
+ /** TTSR manager message count when this injection was recorded. */
148
+ ttsrMessageCount?: number;
144
149
  }
145
150
  /** Persisted MCP discovery selection state for a session branch. */
146
151
  export interface MCPToolSelectionEntry extends SessionEntryBase {
@@ -212,6 +217,10 @@ export interface SessionContext {
212
217
  models: Record<string, string>;
213
218
  /** Names of TTSR rules that have been injected this session */
214
219
  injectedTtsrRules: string[];
220
+ /** Rich TTSR rule injection records for repeat resume. */
221
+ injectedTtsrRuleRecords?: TtsrInjectionRecord[];
222
+ /** TTSR manager message count for repeat resume. */
223
+ ttsrMessageCount?: number;
215
224
  /** MCP tool names selected through discovery for this session branch. */
216
225
  selectedMCPToolNames: string[];
217
226
  /** Whether this branch contains an explicit persisted MCP selection entry. */
@@ -477,6 +486,13 @@ export declare class SessionManager {
477
486
  appendCompaction<T = unknown>(summary: string, shortSummary: string | undefined, firstKeptEntryId: string, tokensBefore: number, details?: T, fromExtension?: boolean, preserveData?: Record<string, unknown>): string;
478
487
  /** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */
479
488
  appendCustomEntry(customType: string, data?: unknown): string;
489
+ /**
490
+ * Append a root marker that starts a fresh active branch without changing the
491
+ * session id or deleting earlier durable entries. Subsequent messages descend
492
+ * from this marker, so provider context is clear while history remains
493
+ * available for diagnostics/export.
494
+ */
495
+ appendContextClearEntry(data?: Record<string, unknown>): string;
480
496
  /**
481
497
  * Write mutated message entries back into the canonical entry store by id.
482
498
  *
@@ -511,7 +527,7 @@ export declare class SessionManager {
511
527
  * @param ruleNames Names of rules that were injected
512
528
  * @returns Entry id
513
529
  */
514
- appendTtsrInjection(ruleNames: string[]): string;
530
+ appendTtsrInjection(ruleNames: string[], records?: TtsrInjectionRecord[], ttsrMessageCount?: number): string;
515
531
  /**
516
532
  * Get all unique TTSR rule names that have been injected in the current branch.
517
533
  * Scans from root to current leaf for ttsr_injection entries.