@gajae-code/coding-agent 0.11.6 → 0.11.8

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 (259) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/types/capability/index.d.ts +10 -20
  3. package/dist/types/capability/types.d.ts +3 -0
  4. package/dist/types/cli/args.d.ts +0 -2
  5. package/dist/types/commands/daemon.d.ts +2 -2
  6. package/dist/types/commands/sdk.d.ts +20 -2
  7. package/dist/types/config/keybindings.d.ts +34 -4
  8. package/dist/types/config/model-profile-activation.d.ts +4 -3
  9. package/dist/types/config/model-profile-contract.d.ts +38 -0
  10. package/dist/types/config/settings-schema.d.ts +70 -7
  11. package/dist/types/edit/modes/patch.d.ts +13 -0
  12. package/dist/types/edit/path-mutation-lock.d.ts +15 -0
  13. package/dist/types/eval/py/executor.d.ts +1 -1
  14. package/dist/types/eval/py/runner-artifact.d.ts +8 -0
  15. package/dist/types/eval/py/tool-bridge.d.ts +1 -2
  16. package/dist/types/gjc-runtime/repository-binding.d.ts +63 -0
  17. package/dist/types/gjc-runtime/ultragoal-guard.d.ts +6 -5
  18. package/dist/types/gjc-runtime/ultragoal-receipt-freshness.d.ts +20 -0
  19. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +43 -5
  20. package/dist/types/main.d.ts +32 -1
  21. package/dist/types/modes/components/btw-panel.d.ts +1 -0
  22. package/dist/types/modes/components/model-selector.d.ts +2 -0
  23. package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +2 -1
  24. package/dist/types/modes/components/tool-status-header.d.ts +4 -2
  25. package/dist/types/modes/components/welcome.d.ts +2 -0
  26. package/dist/types/modes/controllers/btw-controller.d.ts +5 -0
  27. package/dist/types/modes/controllers/command-controller.d.ts +2 -0
  28. package/dist/types/modes/controllers/selector-controller.d.ts +2 -1
  29. package/dist/types/modes/interactive-mode.d.ts +7 -2
  30. package/dist/types/modes/prompt-action-autocomplete.d.ts +6 -1
  31. package/dist/types/modes/prompt-suggestion-controller.d.ts +35 -0
  32. package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +2 -2
  33. package/dist/types/modes/types.d.ts +4 -0
  34. package/dist/types/modes/utils/hotkeys-markdown.d.ts +2 -1
  35. package/dist/types/runtime-mcp/content-limits.d.ts +7 -0
  36. package/dist/types/runtime-mcp/manager.d.ts +1 -1
  37. package/dist/types/runtime-mcp/oauth-flow.d.ts +0 -5
  38. package/dist/types/runtime-mcp/plugin-network-boundary.d.ts +14 -0
  39. package/dist/types/sdk/broker/broker.d.ts +2 -0
  40. package/dist/types/sdk/broker/lifecycle.d.ts +6 -0
  41. package/dist/types/sdk/bus/chat-daemon-control.d.ts +6 -1
  42. package/dist/types/sdk/bus/config-commands.d.ts +2 -2
  43. package/dist/types/sdk/bus/config.d.ts +2 -0
  44. package/dist/types/sdk/bus/conversation-store.d.ts +1 -0
  45. package/dist/types/sdk/bus/index.d.ts +26 -1
  46. package/dist/types/sdk/bus/lifecycle-commands.d.ts +5 -4
  47. package/dist/types/sdk/bus/notification-orchestration.d.ts +1 -0
  48. package/dist/types/sdk/bus/notification-service.d.ts +34 -0
  49. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +105 -0
  50. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +18 -3
  51. package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -1
  52. package/dist/types/sdk/bus/telegram-daemon.d.ts +189 -4
  53. package/dist/types/sdk/bus/telegram-reference.d.ts +2 -0
  54. package/dist/types/sdk/bus/topic-registry.d.ts +88 -2
  55. package/dist/types/sdk/client/discovery.d.ts +2 -0
  56. package/dist/types/sdk/client/liveness.d.ts +7 -0
  57. package/dist/types/sdk/host/control/operations.d.ts +1 -1
  58. package/dist/types/sdk/host/host.d.ts +1 -1
  59. package/dist/types/sdk/host/query/handlers.d.ts +9 -0
  60. package/dist/types/sdk/index.d.ts +2 -0
  61. package/dist/types/sdk/prompt-status.d.ts +88 -0
  62. package/dist/types/sdk/session-directory.d.ts +1 -1
  63. package/dist/types/sdk/startup-capability.d.ts +3 -0
  64. package/dist/types/sdk/transport/auth-preface.d.ts +9 -0
  65. package/dist/types/sdk/transport/index.d.ts +12 -0
  66. package/dist/types/sdk/transport/relay.d.ts +43 -0
  67. package/dist/types/sdk/transport/serve-cli.d.ts +4 -0
  68. package/dist/types/sdk/transport/socket.d.ts +7 -0
  69. package/dist/types/sdk/transport/stdio.d.ts +3 -0
  70. package/dist/types/session/agent-session.d.ts +30 -5
  71. package/dist/types/session/btw-contract.d.ts +16 -0
  72. package/dist/types/session/internal/managed-session-scope.d.ts +32 -9
  73. package/dist/types/session/internal/managed-session-storage.d.ts +27 -10
  74. package/dist/types/session/internal/native-publish-outcome.d.ts +48 -0
  75. package/dist/types/session/session-manager.d.ts +25 -4
  76. package/dist/types/session/session-storage.d.ts +18 -0
  77. package/dist/types/setup/credential-import.d.ts +5 -1
  78. package/dist/types/setup/provider-onboarding.d.ts +2 -0
  79. package/dist/types/ssh/utils.d.ts +1 -0
  80. package/dist/types/task/discovery.d.ts +3 -1
  81. package/dist/types/task/index.d.ts +3 -1
  82. package/dist/types/task/receipt.d.ts +2 -0
  83. package/dist/types/task/types.d.ts +94 -0
  84. package/dist/types/tools/ask.d.ts +454 -174
  85. package/dist/types/tools/fetch.d.ts +5 -8
  86. package/dist/types/tools/image-gen.d.ts +63 -1
  87. package/dist/types/tools/index.d.ts +4 -0
  88. package/dist/types/tools/skill-discovery.d.ts +7 -0
  89. package/dist/types/tools/sqlite-reader.d.ts +7 -0
  90. package/dist/types/utils/prompt-suggestion.d.ts +33 -0
  91. package/dist/types/utils/shell-snapshot.d.ts +12 -0
  92. package/dist/types/web/insane/bridge.d.ts +1 -0
  93. package/dist/types/web/insane/url-guard.d.ts +17 -0
  94. package/package.json +8 -8
  95. package/scripts/capture-platform-shortcut-labels-showcase.ts +342 -0
  96. package/scripts/dogfood-repository-binding.ts +209 -0
  97. package/scripts/generate-sdk-operation-inventory.ts +4 -0
  98. package/scripts/run-test-manifest.ts +4 -4
  99. package/src/capability/index.ts +50 -42
  100. package/src/capability/types.ts +3 -0
  101. package/src/cli/args.ts +2 -92
  102. package/src/cli/notify-cli.ts +5 -38
  103. package/src/cli/setup-cli.ts +10 -4
  104. package/src/cli.ts +52 -9
  105. package/src/commands/daemon.ts +22 -5
  106. package/src/commands/sdk.ts +44 -11
  107. package/src/config/keybindings.ts +158 -25
  108. package/src/config/model-profile-activation.ts +7 -18
  109. package/src/config/model-profile-contract.ts +161 -0
  110. package/src/config/model-profiles.ts +18 -0
  111. package/src/config/model-registry.ts +11 -1
  112. package/src/config/settings-schema.ts +73 -7
  113. package/src/coordinator-mcp/model-preset.ts +21 -74
  114. package/src/defaults/gjc/skills/deep-interview/SKILL.md +2 -2
  115. package/src/defaults/gjc/skills/ralplan/SKILL.md +3 -1
  116. package/src/defaults/gjc/skills/ultragoal/SKILL.md +42 -1
  117. package/src/discovery/ssh.ts +12 -1
  118. package/src/edit/index.ts +3 -6
  119. package/src/edit/modes/patch.ts +38 -1
  120. package/src/edit/modes/replace.ts +42 -0
  121. package/src/edit/path-mutation-lock.ts +112 -0
  122. package/src/eval/py/executor.ts +30 -11
  123. package/src/eval/py/kernel.ts +1 -21
  124. package/src/eval/py/prelude.py +2 -2
  125. package/src/eval/py/runner-artifact.ts +84 -0
  126. package/src/eval/py/tool-bridge.ts +34 -18
  127. package/src/extensibility/gjc-plugins/runtime-adapters.ts +2 -1
  128. package/src/extensibility/plugins/marketplace/fetcher.ts +191 -7
  129. package/src/gjc-runtime/launch-tmux.ts +1 -1
  130. package/src/gjc-runtime/managed-owner-supervisor.ts +83 -4
  131. package/src/gjc-runtime/ralplan-runtime.ts +75 -3
  132. package/src/gjc-runtime/repository-binding.ts +267 -0
  133. package/src/gjc-runtime/session-state-sidecar.ts +25 -9
  134. package/src/gjc-runtime/tmux-owner-isolation.ts +2 -1
  135. package/src/gjc-runtime/tmux-sessions.ts +45 -6
  136. package/src/gjc-runtime/ultragoal-guard.ts +93 -15
  137. package/src/gjc-runtime/ultragoal-receipt-freshness.ts +103 -0
  138. package/src/gjc-runtime/ultragoal-runtime.ts +456 -31
  139. package/src/gjc-runtime/workflow-manifest.generated.json +58 -0
  140. package/src/gjc-runtime/workflow-manifest.ts +23 -0
  141. package/src/internal-urls/docs-index.generated.ts +12 -10
  142. package/src/internal-urls/local-protocol.ts +64 -21
  143. package/src/internal-urls/mcp-protocol.ts +73 -11
  144. package/src/main.ts +111 -37
  145. package/src/modes/DESIGN.md +5 -0
  146. package/src/modes/acp/acp-agent.ts +50 -16
  147. package/src/modes/action-registry.ts +1 -1
  148. package/src/modes/components/btw-panel.ts +82 -16
  149. package/src/modes/components/model-selector.ts +73 -11
  150. package/src/modes/components/plan-preview-overlay.ts +1 -1
  151. package/src/modes/components/runtime-mcp-add-wizard.ts +5 -0
  152. package/src/modes/components/tool-status-header.ts +25 -4
  153. package/src/modes/components/welcome.ts +22 -18
  154. package/src/modes/controllers/btw-controller.ts +119 -36
  155. package/src/modes/controllers/command-controller.ts +97 -54
  156. package/src/modes/controllers/event-controller.ts +10 -0
  157. package/src/modes/controllers/input-controller.ts +38 -2
  158. package/src/modes/controllers/runtime-mcp-command-controller.ts +29 -6
  159. package/src/modes/controllers/selector-controller.ts +149 -63
  160. package/src/modes/interactive-mode.ts +57 -34
  161. package/src/modes/prompt-action-autocomplete.ts +32 -13
  162. package/src/modes/prompt-suggestion-controller.ts +96 -0
  163. package/src/modes/shared/agent-wire/workflow-gate-broker.ts +2 -2
  164. package/src/modes/types.ts +4 -0
  165. package/src/modes/utils/hotkeys-markdown.ts +64 -36
  166. package/src/modes/utils/ui-helpers.ts +5 -3
  167. package/src/prompts/agents/architect.md +0 -1
  168. package/src/prompts/agents/critic.md +0 -1
  169. package/src/prompts/system/btw-user.md +3 -8
  170. package/src/prompts/system/prompt-suggestion-system.md +32 -0
  171. package/src/prompts/system/system-prompt.md +6 -4
  172. package/src/prompts/tools/cron.md +3 -1
  173. package/src/prompts/tools/skill-discovery.md +1 -0
  174. package/src/runtime-mcp/client.ts +41 -55
  175. package/src/runtime-mcp/content-limits.ts +71 -0
  176. package/src/runtime-mcp/json-rpc.ts +23 -9
  177. package/src/runtime-mcp/manager.ts +51 -53
  178. package/src/runtime-mcp/oauth-flow.ts +0 -72
  179. package/src/runtime-mcp/plugin-network-boundary.ts +101 -0
  180. package/src/runtime-mcp/transports/http.ts +63 -22
  181. package/src/sdk/broker/broker.ts +34 -20
  182. package/src/sdk/broker/lifecycle.ts +185 -36
  183. package/src/sdk/bus/chat-daemon-control.ts +19 -5
  184. package/src/sdk/bus/config-commands.ts +2 -2
  185. package/src/sdk/bus/config.ts +9 -1
  186. package/src/sdk/bus/conversation-store.ts +40 -6
  187. package/src/sdk/bus/index.ts +244 -70
  188. package/src/sdk/bus/lifecycle-commands.ts +63 -10
  189. package/src/sdk/bus/lifecycle-control-runtime.ts +11 -2
  190. package/src/sdk/bus/lifecycle-orchestrator.ts +32 -1
  191. package/src/sdk/bus/notification-orchestration.ts +12 -0
  192. package/src/sdk/bus/notification-service.ts +68 -20
  193. package/src/sdk/bus/prompt-reconciliation.ts +239 -0
  194. package/src/sdk/bus/recent-activity.ts +90 -26
  195. package/src/sdk/bus/telegram-daemon-contract.ts +18 -3
  196. package/src/sdk/bus/telegram-daemon-control.ts +147 -35
  197. package/src/sdk/bus/telegram-daemon.ts +2463 -450
  198. package/src/sdk/bus/telegram-reference.ts +20 -2
  199. package/src/sdk/bus/topic-registry.ts +451 -12
  200. package/src/sdk/cli/session-cli.ts +15 -2
  201. package/src/sdk/client/discovery.ts +19 -3
  202. package/src/sdk/client/liveness.ts +49 -0
  203. package/src/sdk/host/control/dispatch.ts +1 -1
  204. package/src/sdk/host/control/operations.ts +1 -1
  205. package/src/sdk/host/host.ts +2 -6
  206. package/src/sdk/host/query/handlers.ts +70 -5
  207. package/src/sdk/index.ts +12 -0
  208. package/src/sdk/prompt-status.ts +97 -0
  209. package/src/sdk/protocol/operation-inventory.generated.json +58 -0
  210. package/src/sdk/protocol/operation-registry.ts +18 -4
  211. package/src/sdk/session-directory.ts +5 -1
  212. package/src/sdk/session.ts +31 -5
  213. package/src/sdk/startup-capability.ts +9 -1
  214. package/src/sdk/transport/auth-preface.ts +82 -0
  215. package/src/sdk/transport/index.ts +18 -0
  216. package/src/sdk/transport/relay.ts +252 -0
  217. package/src/sdk/transport/serve-cli.ts +105 -0
  218. package/src/sdk/transport/socket.ts +197 -0
  219. package/src/sdk/transport/stdio.ts +17 -0
  220. package/src/session/agent-session.ts +292 -154
  221. package/src/session/blob-store.ts +25 -7
  222. package/src/session/btw-contract.ts +59 -0
  223. package/src/session/internal/managed-session-scope.ts +1163 -137
  224. package/src/session/internal/managed-session-storage.ts +397 -234
  225. package/src/session/internal/native-publish-outcome.ts +266 -0
  226. package/src/session/session-manager.ts +620 -403
  227. package/src/session/session-storage.ts +128 -11
  228. package/src/setup/credential-import.ts +28 -3
  229. package/src/setup/provider-onboarding.ts +30 -1
  230. package/src/setup/provider-presets.json +2 -1
  231. package/src/slash-commands/builtin-registry.ts +1 -1
  232. package/src/ssh/utils.ts +14 -0
  233. package/src/task/discovery.ts +8 -2
  234. package/src/task/gjc-command.ts +2 -2
  235. package/src/task/index.ts +121 -15
  236. package/src/task/receipt.ts +3 -0
  237. package/src/task/types.ts +34 -3
  238. package/src/tools/ask.ts +199 -89
  239. package/src/tools/ast-edit.ts +2 -2
  240. package/src/tools/bash-pty-selection.ts +2 -2
  241. package/src/tools/browser/screenshot-format.ts +6 -1
  242. package/src/tools/cron.ts +1 -1
  243. package/src/tools/fetch.ts +13 -131
  244. package/src/tools/image-gen.ts +476 -23
  245. package/src/tools/index.ts +4 -0
  246. package/src/tools/read.ts +2 -0
  247. package/src/tools/render-utils.ts +7 -1
  248. package/src/tools/skill-discovery.ts +39 -3
  249. package/src/tools/sqlite-reader.ts +63 -5
  250. package/src/utils/edit-mode.ts +2 -2
  251. package/src/utils/pasted-image-path.ts +15 -6
  252. package/src/utils/prompt-suggestion.ts +265 -0
  253. package/src/utils/shell-snapshot.ts +173 -63
  254. package/src/utils/sixel.ts +3 -3
  255. package/src/web/insane/bridge.ts +5 -1
  256. package/src/web/insane/url-guard.ts +140 -27
  257. package/src/web/scrapers/docs-rs.ts +30 -5
  258. package/src/web/scrapers/types.ts +19 -49
  259. package/src/web/scrapers/utils.ts +12 -26
@@ -70,6 +70,7 @@ export interface SessionLifecycleLaunchRequest {
70
70
  }
71
71
  export declare function readSessionLifecycleLaunchRequest(value: string | undefined, now?: number): SessionLifecycleLaunchRequest;
72
72
  type CleanupEvidence = BrokerCleanupEvidence;
73
+ export declare function validateBrokerModelPresetForTest(agentDir: string, requestedProfile: string): string | BrokerResponse;
73
74
  export declare function setProcessIncarnationForTest(broker: Broker, value: ((pid: number) => string | undefined) | undefined): void;
74
75
  /** The child writes this only after its endpoint and semantic ready event are both live. */
75
76
  export declare function writeSessionLifecycleReady(root: string, id: string, effectMarker: string): Promise<void>;
@@ -79,6 +80,11 @@ export interface LifecycleTranscriptEvidence {
79
80
  }
80
81
  /** The child writes bounded startup diagnostics before exiting without readiness. */
81
82
  export declare function writeSessionLifecycleFailure(root: string, id: string, effectMarker: string, failure: SdkStartupFailure, rollback: SdkStartupRollbackResult, transcript?: LifecycleTranscriptEvidence, ownerIncarnation?: string): Promise<void>;
83
+ export declare function readSessionLifecycleFailureForTest(root: string, id: string, expected: {
84
+ pid: number;
85
+ effectMarker: string;
86
+ incarnation: string;
87
+ }): Promise<SdkStartupFailure | undefined>;
82
88
  export interface LifecycleExecutionOutcome {
83
89
  response: BrokerResponse;
84
90
  durableEffects?: LifecycleDurableEffectsReceipt;
@@ -8,7 +8,12 @@ export type ChatDaemonAction = "stop" | "reload";
8
8
  * Generation 6 carries the retained managed filesystem authority boundary.
9
9
  * Generation 7 restores macOS daemon signaling (kill(2) with a start-time
10
10
  * incarnation recheck) so a live/hung owner can be replaced without an external
11
- * `kill -9`.
11
+ * `kill -9`. Generation 8 adopts Windows expected-identity ACL verification and
12
+ * repair for shared native authority. Generation 9 refreshes the shared native
13
+ * authority declaration contract with bounded frame-delivery acknowledgement.
14
+ * Generation 11 accepts typed retained exact-unlink cleanup authority — a
15
+ * concrete detached quarantine plus a proven-absent canonical lock pathname —
16
+ * when deleting an observed owner-lock lease.
12
17
  */
13
18
  export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
14
19
  export declare function chatDaemonGeneration(kind: ChatDaemonKind): number;
@@ -5,8 +5,8 @@
5
5
  * removed), but the user can still adjust per-surface behaviour from inside a
6
6
  * session thread with small slash commands:
7
7
  *
8
- * - `/verbose` switch the mirror to bounded tool-owned summaries + provider-displayable reasoning summaries
9
- * - `/lean` switch back to lean (assistant text + tool names)
8
+ * - `/verbose` switch the mirror to per-turn assistant text + tool summaries + reasoning summaries
9
+ * - `/lean` settled assistant answer at idle + immediate ask lead-ins (no intermediate tool-turn flood)
10
10
  * - `/verbosity lean|verbose`
11
11
  * - `/redact on|off` toggle redaction of streamed content
12
12
  *
@@ -287,6 +287,8 @@ export interface RedactableAction {
287
287
  question?: string;
288
288
  options?: string[];
289
289
  summary?: string;
290
+ /** Optional zero-based recommendation into the authoritative raw options. */
291
+ recommendedIndex?: number;
290
292
  }
291
293
  /**
292
294
  * When redact is true, strip sensitive content for remote delivery:
@@ -56,6 +56,7 @@ export declare class ConversationStore<T extends ConversationRecord> {
56
56
  pidAlive?: (pid: number) => boolean;
57
57
  sleep?: (ms: number) => Promise<void>;
58
58
  lockTimeoutMs?: number;
59
+ platform?: NodeJS.Platform;
59
60
  });
60
61
  get filePath(): string;
61
62
  load(): Promise<ConversationStoreDocument<T>>;
@@ -204,6 +204,7 @@ interface UnattendedGatePresentation {
204
204
  question: string;
205
205
  options: string[];
206
206
  controls: readonly AskRemoteControl[];
207
+ recommendedIndex?: number;
207
208
  multi: boolean;
208
209
  allowEmpty: boolean;
209
210
  navigationLabel?: "Next" | "Done";
@@ -343,6 +344,21 @@ interface SessionRuntime {
343
344
  commandId: string;
344
345
  turnId: string;
345
346
  } | undefined) => boolean;
347
+ /** Transitions the authoritative reconciliation record at lifecycle ingress; terminal outcomes settle once. */
348
+ notePromptReconciliation: (correlation: {
349
+ commandId: string;
350
+ turnId: string;
351
+ } | undefined, frame: {
352
+ type: "agent_start" | "agent_end";
353
+ } | {
354
+ type: "agent_failed";
355
+ error: unknown;
356
+ }) => void;
357
+ /** Settles and emits one sanitized correlated prompt failure. */
358
+ emitPromptFailure: (correlation: {
359
+ commandId: string;
360
+ turnId: string;
361
+ }, error: unknown) => void;
346
362
  /** Records correlated lifecycle frames for replay and delivers them only to the accepted requester after acknowledgement. */
347
363
  emitPromptLifecycle: (correlation: {
348
364
  commandId: string;
@@ -385,6 +401,15 @@ interface SessionRuntime {
385
401
  text?: string;
386
402
  messageRef?: string;
387
403
  };
404
+ /**
405
+ * Lean-mode deferred final answer: latest assistant text observed at `turn_end`,
406
+ * emitted once at `agent_end` so intermediate tool-turn narration does not flood
407
+ * remote clients. Cleared after flush or when replaced by a newer turn.
408
+ */
409
+ pendingSettled?: {
410
+ text: string;
411
+ messageRef?: string;
412
+ };
388
413
  /** Durable gates emitted while ownership is provisional; presented only after stable activation. */
389
414
  deferredGatePresentations: Array<() => void>;
390
415
  /** SDK control frames received during provisional ownership; replayed only after stable activation. */
@@ -494,7 +519,7 @@ export declare function createNotificationsExtension(api: ExtensionAPI, options?
494
519
  /** Whether this host mode can own the root SDK endpoint. Default: true. */
495
520
  sdkHostModeSupported?: boolean;
496
521
  onSdkRequest?: (kind: "control" | "query", connectionId: string, frame: Record<string, unknown>) => void;
497
- runEphemeralTurn?: (promptText: string, signal: AbortSignal) => Promise<{
522
+ runBtwTurn?: (question: string, signal: AbortSignal) => Promise<{
498
523
  replyText: string;
499
524
  }>;
500
525
  /** Observes settlement of optional session-branch startup after reconciliation completes. */
@@ -62,8 +62,9 @@ export declare function normalizeLifecyclePath(value: string): string | undefine
62
62
  /**
63
63
  * Map a lifecycle response/error to a user-facing Telegram message (G010).
64
64
  *
65
- * Only derives text from sessionId, mode, reason, a safe message, and candidate
66
- * {sessionId,path} — never a token or prompt. Each error reason gets tailored,
67
- * actionable copy; an "in progress" pending response is surfaced distinctly.
65
+ * Only derives text from sessionId, mode, reason, a safe message, the originating
66
+ * lifecycle verb, and candidate {sessionId,path} — never a token or prompt. Each
67
+ * error reason gets tailored, actionable copy; an "in progress" pending response
68
+ * is surfaced distinctly.
68
69
  */
69
- export declare function formatLifecycleOutcome(r: SessionLifecycleResponse): string;
70
+ export declare function formatLifecycleOutcome(r: SessionLifecycleResponse, verb?: LifecycleCommandVerb): string;
@@ -30,6 +30,7 @@ export interface ProposedTelegramIdentityPreflightInput {
30
30
  deps?: {
31
31
  fs?: TelegramDaemonFs;
32
32
  pidAlive?: (pid: number) => boolean;
33
+ pidIncarnation?: (pid: number) => string | undefined;
33
34
  };
34
35
  }
35
36
  /**
@@ -74,6 +74,40 @@ export interface NotificationStatusReport {
74
74
  export declare function buildNotificationStatusReport(settings: Settings): NotificationStatusReport;
75
75
  /** Render a status report as human-readable lines (no secrets). */
76
76
  export declare function formatNotificationStatusReport(report: NotificationStatusReport): string;
77
+ export interface NotificationEndpointView {
78
+ sessionId: string;
79
+ pid: number | undefined;
80
+ stale: boolean;
81
+ }
82
+ export type NotificationEndpointLiveness = "live" | "dead" | "unknown";
83
+ /**
84
+ * Classification used by recovery and startup takeover. A file is an endpoint
85
+ * only when it has endpoint authority fields; lifecycle/audit records are never
86
+ * candidates for endpoint cleanup.
87
+ */
88
+ export type NotificationEndpointClassification = {
89
+ kind: "endpoint";
90
+ view: NotificationEndpointView;
91
+ liveness: NotificationEndpointLiveness;
92
+ identity: NotificationEndpointFileIdentity;
93
+ } | {
94
+ kind: "non-endpoint";
95
+ } | {
96
+ kind: "unreadable";
97
+ };
98
+ /**
99
+ * Classify an endpoint using owner-proof semantics. An endpoint is only `dead`
100
+ * with positive proof: an explicit `stale` tombstone, or a recorded pid that is
101
+ * confirmed not alive. A PID-less endpoint is `unknown` (not provably dead) and
102
+ * must never be treated as dead — removing it could delete a live session's
103
+ * discovery file that simply omitted a pid.
104
+ */
105
+ export declare function notificationEndpointLiveness(view: NotificationEndpointView, pidAlive: (pid: number) => boolean): NotificationEndpointLiveness;
106
+ /**
107
+ * Read and classify one endpoint candidate. The returned identity belongs to
108
+ * exactly the bytes inspected and is required for any later deletion.
109
+ */
110
+ export declare function classifyNotificationEndpoint(fs: Pick<NotificationServiceFs, "readEndpointFile">, file: string, pidAlive: (pid: number) => boolean): Promise<NotificationEndpointClassification>;
77
111
  export type HealthLevel = "ok" | "warn" | "error";
78
112
  export interface HealthCheck {
79
113
  name: string;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Bounded authoritative reconciliation state for Q26 `turn.prompt_status`.
3
+ *
4
+ * Separate from the lifecycle delivery buffers (promptSubmissions /
5
+ * promptTerminalTombstones), which exist to deliver frames and intentionally
6
+ * forget outcomes. This record preserves accepted/in_flight/terminal_ok/failed
7
+ * plus bounded sanitized failure metadata so a caller can reconcile a prior
8
+ * `turn.prompt` after disconnect/reconnect.
9
+ *
10
+ * Semantics (public contract, mirrored in sdk/prompt-status.ts):
11
+ * - Active records are NEVER converted to terminal by age or capacity.
12
+ * - Terminal records are retained for TERMINAL_TTL_MS and bounded to
13
+ * TERMINAL_CAPACITY, evicted oldest-terminal-first by terminalAt; only then
14
+ * does a lookup honestly report `unknown`.
15
+ * - The durability floor is the live session process: restart means `unknown`.
16
+ * - The clientRef index is session-runtime scoped; a ref conflicts only while
17
+ * retained and must never be reused as a retry mechanism.
18
+ * - Terminal transitions settle once: the first terminal outcome wins.
19
+ */
20
+ export declare const PROMPT_RECONCILIATION_ACTIVE_CAPACITY = 128;
21
+ export declare const PROMPT_RECONCILIATION_TERMINAL_CAPACITY = 256;
22
+ export declare const PROMPT_RECONCILIATION_TERMINAL_TTL_MS: number;
23
+ export declare const PROMPT_FAILURE_CODE_MAX = 64;
24
+ export type PromptReconciliationStatus = "accepted" | "in_flight" | "terminal_ok" | "failed";
25
+ export interface PromptCorrelation {
26
+ commandId: string;
27
+ turnId: string;
28
+ }
29
+ export interface PromptReconciliationRecord extends PromptCorrelation {
30
+ clientRef?: string;
31
+ status: PromptReconciliationStatus;
32
+ error?: {
33
+ code: string;
34
+ message: string;
35
+ };
36
+ acceptedAt: number;
37
+ startedAt?: number;
38
+ terminalAt?: number;
39
+ }
40
+ export type TurnPromptReconciliation = {
41
+ status: "accepted";
42
+ commandId: string;
43
+ turnId: string;
44
+ clientRef?: string;
45
+ acceptedAt: number;
46
+ } | {
47
+ status: "in_flight";
48
+ commandId: string;
49
+ turnId: string;
50
+ clientRef?: string;
51
+ acceptedAt: number;
52
+ startedAt: number;
53
+ } | {
54
+ status: "terminal_ok";
55
+ commandId: string;
56
+ turnId: string;
57
+ clientRef?: string;
58
+ acceptedAt: number;
59
+ startedAt?: number;
60
+ terminalAt: number;
61
+ } | {
62
+ status: "failed";
63
+ commandId: string;
64
+ turnId: string;
65
+ clientRef?: string;
66
+ acceptedAt: number;
67
+ startedAt?: number;
68
+ terminalAt: number;
69
+ error: {
70
+ code: string;
71
+ message: string;
72
+ };
73
+ } | {
74
+ status: "unknown";
75
+ };
76
+ export interface PromptReconciliation {
77
+ /** Fail-closed admission BEFORE any execution; holds an identity-bound reservation. */
78
+ admit(clientRef?: string): void;
79
+ /** Discard one admission reservation without creating a record (rejection/cancellation). */
80
+ releaseAdmission(clientRef?: string): void;
81
+ /** Transition a reservation into the accepted record at preflight acceptance. */
82
+ noteAccepted(correlation: PromptCorrelation, clientRef?: string): void;
83
+ /** Lifecycle transition; terminal outcomes settle exactly once. */
84
+ noteTransition(correlation: PromptCorrelation | undefined, frame: {
85
+ type: "agent_start" | "agent_end";
86
+ } | {
87
+ type: "agent_failed";
88
+ error: unknown;
89
+ }): void;
90
+ lookup(selector: {
91
+ commandId?: string;
92
+ turnId?: string;
93
+ clientRef?: string;
94
+ }): TurnPromptReconciliation;
95
+ cleanup(): void;
96
+ activeCount(): number;
97
+ }
98
+ /** Safe-token code capped at 64; arbitrary failure text is never retained. */
99
+ export declare function sanitizePromptFailure(error: unknown): {
100
+ code: string;
101
+ message: string;
102
+ };
103
+ export declare function createPromptReconciliation(options?: {
104
+ now?: () => number;
105
+ }): PromptReconciliation;
@@ -19,7 +19,22 @@ export declare const NOTIFICATION_PROTOCOL_VERSION = 3;
19
19
  * confirmed-dead owner's lock in generation 10, legacy stopped-tombstone
20
20
  * reclamation in generation 11, force-escalated SIGKILL of an unresponsive
21
21
  * older-generation owner during automatic generation-upgrade reload in
22
- * generation 12, and restored macOS daemon signaling (kill(2) with a start-time
23
- * incarnation recheck, replacing the darwin no-op) in generation 13.
22
+ * generation 12, restored macOS daemon signaling (kill(2) with a start-time
23
+ * incarnation recheck, replacing the darwin no-op) in generation 13, retained
24
+ * legacy stopped-lock reclamation in generation 14, Windows expected-identity
25
+ * ACL verification and repair in generation 15, identity-fenced stale endpoint
26
+ * startup recovery in generation 16, Telegram topic recovery authority fencing
27
+ * in generation 17, fail-closed blank-token validation plus lifecycle-startup
28
+ * stop fencing in generation 18, recommended ask metadata rendering in
29
+ * generation 19, authoritative terminal session-close delivery and cleanup
30
+ * fencing, attested generation-bearing pre-incarnation owner handoff in
31
+ * generation 20, guarded modern generation-absent predecessor signaling in
32
+ * generation 21, dead Windows v0.10 owner replacement in generation 22, and
33
+ * retained native cleanup authority revalidation in generation 23, and typed
34
+ * retained exact-unlink cleanup authority acceptance (concrete detached
35
+ * quarantine plus proven canonical absence) in generation 24.
36
+ * Generation 25 adds startup dead-root prune + leak-artifact self-heal
37
+ * on TelegramNotificationDaemon.run (#2958). Generation 26 adds bounded reload
38
+ * cooldown and lazy Telegram topic lifecycle safeguards (#2956, #2960, #2984).
24
39
  */
25
- export declare const DAEMON_GENERATION = 13;
40
+ export declare const DAEMON_GENERATION = 26;
@@ -24,8 +24,11 @@ export declare function writeTelegramControlRequest(settings: Settings, request:
24
24
  export declare function clearTelegramControlRequest(settings: Settings, requestId?: string, fsImpl?: TelegramDaemonFs): Promise<void>;
25
25
  export interface DaemonProcessReference {
26
26
  incarnation: string;
27
+ /** Whether the platform delivers the requested signal cooperatively or as a hard termination. */
28
+ termination: "cooperative" | "hard";
27
29
  signalRoot(signal: NodeJS.Signals): void;
28
30
  }
31
+ export declare function defaultProcessReference(pid: number, platform?: NodeJS.Platform): DaemonProcessReference | undefined;
29
32
  export interface TelegramDaemonControlDeps {
30
33
  fs?: TelegramDaemonFs;
31
34
  now?: () => number;
@@ -58,6 +61,7 @@ export type TelegramGenerationReloadResult = {
58
61
  operation: DaemonOperationResult;
59
62
  };
60
63
  export declare class TelegramDaemonController implements BuiltInDaemonController {
64
+ #private;
61
65
  private readonly settings;
62
66
  private readonly deps;
63
67
  readonly kind: "telegram";
@@ -81,7 +85,7 @@ export declare class TelegramDaemonController implements BuiltInDaemonController
81
85
  private signalCapturedOwner;
82
86
  private result;
83
87
  reload(opts?: DaemonOperationOptions): Promise<DaemonOperationResult>;
84
- reloadForGenerationUpgrade(opts?: DaemonOperationOptions): Promise<TelegramGenerationReloadResult>;
88
+ reloadForGenerationUpgrade(opts?: DaemonOperationOptions, attestedLegacyUpgrade?: boolean): Promise<TelegramGenerationReloadResult>;
85
89
  stop(opts?: DaemonOperationOptions): Promise<DaemonOperationResult>;
86
90
  private stopOrReload;
87
91
  /** Clear only our exact control request; a successor request must survive. */