@gajae-code/coding-agent 0.11.7 → 0.11.9

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 (213) hide show
  1. package/CHANGELOG.md +73 -1
  2. package/dist/types/cli/args.d.ts +0 -2
  3. package/dist/types/cli.d.ts +1 -0
  4. package/dist/types/config/keybindings.d.ts +33 -3
  5. package/dist/types/config/model-profile-activation.d.ts +4 -3
  6. package/dist/types/config/model-profile-contract.d.ts +38 -0
  7. package/dist/types/config/model-profiles.d.ts +2 -3
  8. package/dist/types/config/settings-schema.d.ts +15 -2
  9. package/dist/types/edit/modes/patch.d.ts +13 -0
  10. package/dist/types/edit/path-mutation-lock.d.ts +15 -0
  11. package/dist/types/eval/py/executor.d.ts +1 -1
  12. package/dist/types/eval/py/tool-bridge.d.ts +1 -2
  13. package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +12 -5
  14. package/dist/types/gjc-runtime/deep-interview-draft.d.ts +8 -0
  15. package/dist/types/gjc-runtime/deep-interview-payload.d.ts +41 -0
  16. package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +32 -17
  17. package/dist/types/gjc-runtime/deep-interview-repair.d.ts +17 -0
  18. package/dist/types/gjc-runtime/deep-interview-state.d.ts +135 -4
  19. package/dist/types/gjc-runtime/repository-binding.d.ts +63 -0
  20. package/dist/types/gjc-runtime/state-writer.d.ts +44 -0
  21. package/dist/types/gjc-runtime/ultragoal-guard.d.ts +1 -0
  22. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +24 -0
  23. package/dist/types/gjc-runtime/workflow-manifest.d.ts +5 -3
  24. package/dist/types/main.d.ts +8 -0
  25. package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +2 -1
  26. package/dist/types/modes/components/tool-status-header.d.ts +3 -2
  27. package/dist/types/modes/components/welcome.d.ts +4 -0
  28. package/dist/types/modes/controllers/command-controller.d.ts +2 -0
  29. package/dist/types/modes/controllers/selector-controller.d.ts +2 -1
  30. package/dist/types/modes/interactive-mode.d.ts +5 -2
  31. package/dist/types/modes/prompt-action-autocomplete.d.ts +6 -1
  32. package/dist/types/modes/prompt-suggestion-controller.d.ts +35 -0
  33. package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +2 -2
  34. package/dist/types/modes/types.d.ts +3 -0
  35. package/dist/types/modes/utils/hotkeys-markdown.d.ts +2 -1
  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/runtime-mcp/redaction.d.ts +2 -0
  40. package/dist/types/sdk/broker/broker.d.ts +2 -0
  41. package/dist/types/sdk/broker/lifecycle.d.ts +6 -0
  42. package/dist/types/sdk/bus/chat-daemon-control.d.ts +7 -1
  43. package/dist/types/sdk/bus/config-commands.d.ts +2 -2
  44. package/dist/types/sdk/bus/config.d.ts +2 -0
  45. package/dist/types/sdk/bus/conversation-store.d.ts +1 -0
  46. package/dist/types/sdk/bus/index.d.ts +25 -0
  47. package/dist/types/sdk/bus/notification-orchestration.d.ts +1 -0
  48. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +105 -0
  49. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +15 -3
  50. package/dist/types/sdk/bus/telegram-daemon-control.d.ts +5 -1
  51. package/dist/types/sdk/bus/telegram-daemon.d.ts +128 -1
  52. package/dist/types/sdk/bus/telegram-reference.d.ts +2 -0
  53. package/dist/types/sdk/host/control/operations.d.ts +1 -1
  54. package/dist/types/sdk/host/host.d.ts +1 -1
  55. package/dist/types/sdk/host/query/handlers.d.ts +9 -0
  56. package/dist/types/sdk/index.d.ts +2 -0
  57. package/dist/types/sdk/prompt-status.d.ts +88 -0
  58. package/dist/types/sdk/session-directory.d.ts +1 -1
  59. package/dist/types/sdk/startup-capability.d.ts +3 -0
  60. package/dist/types/session/agent-session.d.ts +2 -0
  61. package/dist/types/session/internal/managed-session-scope.d.ts +22 -3
  62. package/dist/types/session/internal/managed-session-storage.d.ts +24 -4
  63. package/dist/types/session/internal/native-publish-outcome.d.ts +48 -0
  64. package/dist/types/session/session-manager.d.ts +5 -1
  65. package/dist/types/session/session-storage.d.ts +31 -0
  66. package/dist/types/skill-state/active-state.d.ts +4 -0
  67. package/dist/types/task/index.d.ts +3 -1
  68. package/dist/types/task/receipt.d.ts +2 -0
  69. package/dist/types/task/types.d.ts +94 -0
  70. package/dist/types/tools/ask.d.ts +454 -174
  71. package/dist/types/tools/image-gen.d.ts +47 -1
  72. package/dist/types/tools/index.d.ts +4 -0
  73. package/dist/types/utils/prompt-suggestion.d.ts +33 -0
  74. package/package.json +8 -8
  75. package/scripts/capture-platform-shortcut-labels-showcase.ts +342 -0
  76. package/scripts/dogfood-repository-binding.ts +209 -0
  77. package/scripts/generate-sdk-operation-inventory.ts +2 -0
  78. package/scripts/run-test-manifest.ts +4 -4
  79. package/src/cli/args.ts +2 -92
  80. package/src/cli/mcp-cli.ts +4 -21
  81. package/src/cli/notify-cli.ts +5 -38
  82. package/src/cli.ts +50 -0
  83. package/src/commands/deep-interview.ts +9 -4
  84. package/src/commands/sdk.ts +2 -2
  85. package/src/commit/agentic/index.ts +3 -3
  86. package/src/commit/map-reduce/index.ts +2 -2
  87. package/src/config/keybindings.ts +157 -24
  88. package/src/config/model-profile-activation.ts +7 -18
  89. package/src/config/model-profile-contract.ts +161 -0
  90. package/src/config/model-profiles.ts +2 -3
  91. package/src/config/model-registry.ts +11 -1
  92. package/src/config/settings-schema.ts +17 -2
  93. package/src/coordinator-mcp/model-preset.ts +21 -74
  94. package/src/defaults/gjc/skills/deep-interview/SKILL.md +80 -165
  95. package/src/defaults/gjc/skills/ralplan/SKILL.md +3 -1
  96. package/src/edit/index.ts +3 -6
  97. package/src/edit/modes/patch.ts +38 -1
  98. package/src/edit/modes/replace.ts +42 -0
  99. package/src/edit/path-mutation-lock.ts +112 -0
  100. package/src/eval/py/executor.ts +30 -11
  101. package/src/eval/py/prelude.py +2 -2
  102. package/src/eval/py/tool-bridge.ts +34 -18
  103. package/src/extensibility/gjc-plugins/runtime-adapters.ts +2 -1
  104. package/src/gjc-runtime/deep-interview-ambiguity.ts +68 -47
  105. package/src/gjc-runtime/deep-interview-draft.ts +842 -0
  106. package/src/gjc-runtime/deep-interview-payload.ts +262 -0
  107. package/src/gjc-runtime/deep-interview-recorder.ts +294 -226
  108. package/src/gjc-runtime/deep-interview-repair.ts +1674 -0
  109. package/src/gjc-runtime/deep-interview-runtime.ts +264 -103
  110. package/src/gjc-runtime/deep-interview-state.ts +916 -4
  111. package/src/gjc-runtime/launch-tmux.ts +1 -1
  112. package/src/gjc-runtime/managed-owner-supervisor.ts +83 -4
  113. package/src/gjc-runtime/ralplan-runtime.ts +78 -4
  114. package/src/gjc-runtime/repository-binding.ts +267 -0
  115. package/src/gjc-runtime/session-state-sidecar.ts +25 -9
  116. package/src/gjc-runtime/state-writer.ts +166 -2
  117. package/src/gjc-runtime/tmux-owner-isolation.ts +2 -1
  118. package/src/gjc-runtime/tmux-sessions.ts +45 -6
  119. package/src/gjc-runtime/ultragoal-guard.ts +5 -5
  120. package/src/gjc-runtime/ultragoal-runtime.ts +181 -19
  121. package/src/gjc-runtime/workflow-manifest.generated.json +386 -1
  122. package/src/gjc-runtime/workflow-manifest.ts +191 -5
  123. package/src/internal-urls/docs-index.generated.ts +8 -6
  124. package/src/internal-urls/local-protocol.ts +33 -16
  125. package/src/internal-urls/mcp-protocol.ts +73 -11
  126. package/src/main.ts +25 -10
  127. package/src/modes/DESIGN.md +5 -0
  128. package/src/modes/acp/acp-agent.ts +50 -16
  129. package/src/modes/components/model-selector.ts +42 -8
  130. package/src/modes/components/plan-preview-overlay.ts +1 -1
  131. package/src/modes/components/runtime-mcp-add-wizard.ts +5 -0
  132. package/src/modes/components/tool-status-header.ts +20 -4
  133. package/src/modes/components/welcome.ts +32 -20
  134. package/src/modes/controllers/command-controller.ts +97 -54
  135. package/src/modes/controllers/event-controller.ts +10 -0
  136. package/src/modes/controllers/input-controller.ts +7 -2
  137. package/src/modes/controllers/runtime-mcp-command-controller.ts +29 -6
  138. package/src/modes/controllers/selector-controller.ts +46 -54
  139. package/src/modes/interactive-mode.ts +70 -36
  140. package/src/modes/prompt-action-autocomplete.ts +32 -13
  141. package/src/modes/prompt-suggestion-controller.ts +96 -0
  142. package/src/modes/shared/agent-wire/workflow-gate-broker.ts +2 -2
  143. package/src/modes/types.ts +3 -0
  144. package/src/modes/utils/hotkeys-markdown.ts +64 -36
  145. package/src/modes/utils/ui-helpers.ts +5 -3
  146. package/src/prompts/agents/architect.md +0 -1
  147. package/src/prompts/agents/critic.md +0 -1
  148. package/src/prompts/system/prompt-suggestion-system.md +32 -0
  149. package/src/prompts/system/system-prompt.md +7 -4
  150. package/src/prompts/tools/cron.md +3 -1
  151. package/src/runtime-mcp/json-rpc.ts +7 -4
  152. package/src/runtime-mcp/manager.ts +51 -53
  153. package/src/runtime-mcp/oauth-flow.ts +0 -72
  154. package/src/runtime-mcp/plugin-network-boundary.ts +101 -0
  155. package/src/runtime-mcp/redaction.ts +30 -0
  156. package/src/runtime-mcp/transports/http.ts +13 -6
  157. package/src/sdk/broker/broker.ts +34 -20
  158. package/src/sdk/broker/lifecycle.ts +185 -36
  159. package/src/sdk/broker/session-index.ts +11 -1
  160. package/src/sdk/bus/chat-daemon-control.ts +20 -5
  161. package/src/sdk/bus/config-commands.ts +2 -2
  162. package/src/sdk/bus/config.ts +9 -1
  163. package/src/sdk/bus/conversation-store.ts +40 -6
  164. package/src/sdk/bus/index.ts +240 -65
  165. package/src/sdk/bus/lifecycle-commands.ts +47 -3
  166. package/src/sdk/bus/lifecycle-control-runtime.ts +11 -2
  167. package/src/sdk/bus/lifecycle-orchestrator.ts +32 -1
  168. package/src/sdk/bus/notification-orchestration.ts +12 -0
  169. package/src/sdk/bus/notification-service.ts +27 -2
  170. package/src/sdk/bus/prompt-reconciliation.ts +239 -0
  171. package/src/sdk/bus/recent-activity.ts +90 -26
  172. package/src/sdk/bus/telegram-daemon-contract.ts +15 -3
  173. package/src/sdk/bus/telegram-daemon-control.ts +145 -33
  174. package/src/sdk/bus/telegram-daemon.ts +853 -112
  175. package/src/sdk/bus/telegram-reference.ts +20 -2
  176. package/src/sdk/cli/session-cli.ts +15 -2
  177. package/src/sdk/host/control/dispatch.ts +1 -1
  178. package/src/sdk/host/control/operations.ts +1 -1
  179. package/src/sdk/host/host.ts +2 -6
  180. package/src/sdk/host/query/handlers.ts +70 -5
  181. package/src/sdk/index.ts +12 -0
  182. package/src/sdk/prompt-status.ts +97 -0
  183. package/src/sdk/protocol/operation-inventory.generated.json +47 -0
  184. package/src/sdk/protocol/operation-registry.ts +18 -4
  185. package/src/sdk/session-directory.ts +5 -1
  186. package/src/sdk/session.ts +2 -0
  187. package/src/sdk/startup-capability.ts +9 -1
  188. package/src/session/agent-session.ts +138 -5
  189. package/src/session/blob-store.ts +7 -2
  190. package/src/session/internal/managed-session-scope.ts +998 -133
  191. package/src/session/internal/managed-session-storage.ts +268 -203
  192. package/src/session/internal/native-publish-outcome.ts +266 -0
  193. package/src/session/session-manager.ts +406 -360
  194. package/src/session/session-storage.ts +151 -11
  195. package/src/skill-state/active-state.ts +10 -0
  196. package/src/task/executor.ts +13 -5
  197. package/src/task/gjc-command.ts +2 -2
  198. package/src/task/index.ts +121 -15
  199. package/src/task/receipt.ts +3 -0
  200. package/src/task/types.ts +34 -3
  201. package/src/tools/ask.ts +199 -88
  202. package/src/tools/ast-edit.ts +2 -2
  203. package/src/tools/bash-pty-selection.ts +2 -2
  204. package/src/tools/browser/screenshot-format.ts +6 -1
  205. package/src/tools/cron.ts +1 -1
  206. package/src/tools/image-gen.ts +178 -6
  207. package/src/tools/index.ts +4 -0
  208. package/src/tools/render-utils.ts +7 -1
  209. package/src/utils/edit-mode.ts +2 -2
  210. package/src/utils/prompt-suggestion.ts +265 -0
  211. package/src/utils/sixel.ts +3 -3
  212. package/src/web/insane/url-guard.ts +3 -1
  213. package/src/web/scrapers/docs-rs.ts +30 -5
@@ -0,0 +1,14 @@
1
+ import { type AddressResolver } from "../web/insane/url-guard";
2
+ import type { MCPHttpServerConfig, MCPSseServerConfig } from "./types";
3
+ /** Mark an in-memory plugin-bundle remote MCP config for connection-bound public-network enforcement. */
4
+ export declare function bindPluginMcpToPublicNetwork<T extends MCPHttpServerConfig | MCPSseServerConfig>(config: T): T;
5
+ /** The marker is an internal symbol, so persisted user MCP configs cannot opt into or forge this path. */
6
+ export declare function isPluginMcpPublicNetworkBound(config: MCPHttpServerConfig | MCPSseServerConfig): boolean;
7
+ /**
8
+ * Fetch a plugin-bundle MCP request through a DNS-pinned public address. Every
9
+ * redirect is handled manually and revalidated before the next connection.
10
+ */
11
+ export declare function fetchPluginMcpRequest(rawUrl: string, init: BunFetchRequestInit, options?: {
12
+ resolver?: AddressResolver;
13
+ maxRedirects?: number;
14
+ }): Promise<Response>;
@@ -0,0 +1,2 @@
1
+ export declare function redactMCPEndpoint(value: string | undefined): string | undefined;
2
+ export declare function redactMCPDiagnosticValue(value: unknown): unknown;
@@ -1,4 +1,5 @@
1
1
  import type { NativeDirectoryTreeSnapshot } from "@gajae-code/natives";
2
+ import type { ModelProfileErrorDetails } from "../../config/model-profile-contract";
2
3
  import { type DirectoryMigrationPolicy } from "../session-directory";
3
4
  import { type BrokerDiscovery, type RedactedBrokerDiscovery } from "./discovery";
4
5
  import { type LifecycleDurableEffectsReceipt, LifecycleLedger, type LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
@@ -93,6 +94,7 @@ export type BrokerResponse = {
93
94
  error: {
94
95
  code: BrokerErrorCode;
95
96
  message: string;
97
+ details?: ModelProfileErrorDetails;
96
98
  endpoint?: "unavailable";
97
99
  cleanup?: BrokerCleanupEvidence;
98
100
  };
@@ -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;
@@ -9,7 +9,13 @@ export type ChatDaemonAction = "stop" | "reload";
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
11
  * `kill -9`. Generation 8 adopts Windows expected-identity ACL verification and
12
- * repair for shared native authority.
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. Generation 12 refreshes retained
17
+ * native path and process authority semantics. Generation 13 rejects special
18
+ * files before retained native authority opens.
13
19
  */
14
20
  export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
15
21
  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. */
@@ -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
  /**
@@ -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;
@@ -24,7 +24,19 @@ export declare const NOTIFICATION_PROTOCOL_VERSION = 3;
24
24
  * legacy stopped-lock reclamation in generation 14, Windows expected-identity
25
25
  * ACL verification and repair in generation 15, identity-fenced stale endpoint
26
26
  * startup recovery in generation 16, Telegram topic recovery authority fencing
27
- * in generation 17, and fail-closed blank-token validation plus lifecycle-startup
28
- * stop fencing in generation 18.
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).
39
+ * Generation 27 refreshes retained native path and process authority semantics.
40
+ * Generation 28 rejects special files before retained native authority opens.
29
41
  */
30
- export declare const DAEMON_GENERATION = 18;
42
+ export declare const DAEMON_GENERATION = 28;
@@ -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. */
@@ -4,6 +4,7 @@ import type { DaemonRuntimeInfo } from "../../daemon/control-types";
4
4
  import { HEARTBEAT_TTL_MS } from "./daemon-paths";
5
5
  import { type DaemonTransitionLock, type NotificationEndpointFile, type NotificationEndpointFileIdentity, type NotificationExactUnlinkResult } from "./notification-service";
6
6
  import { type DaemonProcessReference } from "./telegram-daemon-control";
7
+ import { type TelegramSetupPreflight } from "./telegram-setup";
7
8
  export { DAEMON_GENERATION, NOTIFICATION_PROTOCOL_VERSION } from "./telegram-daemon-contract";
8
9
  import { type ControlServerLike, type LifecycleControlServerFactory } from "./lifecycle-control-runtime";
9
10
  import type { OrchestratorDeps } from "./lifecycle-orchestrator";
@@ -55,6 +56,10 @@ export interface TelegramDaemonFs {
55
56
  chmod(path: string, mode: number): Promise<void>;
56
57
  stat?(path: string): Promise<{
57
58
  mtimeMs: number;
59
+ size?: number;
60
+ dev?: number;
61
+ ino?: number;
62
+ ctimeMs?: number;
58
63
  }>;
59
64
  readEndpointFile?(path: string): Promise<NotificationEndpointFile>;
60
65
  exactUnlink?(path: string, identity: NotificationEndpointFileIdentity): Promise<NotificationExactUnlinkResult>;
@@ -102,6 +107,21 @@ export declare const ASK_SELECTED_ACK_CAPABILITY = "ask_selected_ack_v1";
102
107
  export declare const ASK_CONTROLS_CAPABILITY = "ask_controls_v1";
103
108
  /** Capability required for tool lifecycle and reasoning-summary frames. */
104
109
  export declare const TOOL_ACTIVITY_CAPABILITY = "tool_activity_v1";
110
+ /**
111
+ * File-lock options whose acquisition budget covers the full reload-reservation
112
+ * critical section: the in-lock freshness poll plus the controller's
113
+ * graceful+kill+readiness sequence, with headroom. A contender must be able to
114
+ * wait out a legitimate slow reload and then attach, never fail startup.
115
+ */
116
+ export declare function reloadReservationLockOptions(input: {
117
+ freshnessWaitMs: number;
118
+ readinessTimeoutMs: number;
119
+ retryDelayMs?: number;
120
+ }): {
121
+ staleMs: number;
122
+ retries: number;
123
+ retryDelayMs: number;
124
+ };
105
125
  export declare const BTW_QUESTION_MAX_UNICODE_SCALARS = 4096;
106
126
  export declare const BTW_QUESTION_MAX_UTF8_BYTES = 16384;
107
127
  export declare function endpointAuthorityDigest(url: string, token: string, connectionIdentity?: string): string;
@@ -137,12 +157,22 @@ type LegacyOwnershipLockMetadata = {
137
157
  incarnation?: string;
138
158
  startedAt: number;
139
159
  };
160
+ type V010OwnershipLockMetadata = {
161
+ size: 0;
162
+ mtimeMs?: number;
163
+ dev?: number;
164
+ ino?: number;
165
+ ctimeMs?: number;
166
+ };
140
167
  type OwnershipLockRead = {
141
168
  kind: "missing";
142
169
  } | {
143
170
  kind: "malformed";
144
171
  raw: string;
145
172
  mtimeMs?: number;
173
+ } | {
174
+ kind: "v010";
175
+ metadata: V010OwnershipLockMetadata;
146
176
  } | {
147
177
  kind: "legacy";
148
178
  metadata: LegacyOwnershipLockMetadata;
@@ -188,7 +218,84 @@ export declare function unregisterNotificationRoot(input: {
188
218
  sessionId: string;
189
219
  fs?: TelegramDaemonFs;
190
220
  }): Promise<UnregisterNotificationRootResult>;
221
+ /**
222
+ * Leak artifact prefixes left when native exact-unlink cleanup is retained
223
+ * (#2956). Nothing previously reaped these; they accumulate in the notifications
224
+ * directory across ownership transitions.
225
+ */
226
+ export declare const NOTIFICATION_LEAK_ARTIFACT_PREFIXES: readonly [".gjc-delete-daemon-transition-", ".gjc-exact-unlink-placeholder-", ".gjc-delete-notification-endpoint-"];
227
+ /** Grace window before a leak artifact is reaped (covers in-flight unlinks). */
228
+ export declare const NOTIFICATION_LEAK_ARTIFACT_GRACE_MS: number;
229
+ /** True when a path is permanently gone (not a transient I/O blip). */
230
+ export declare function isPermanentMissingPathError(error: unknown): boolean;
231
+ export declare function isNotificationLeakArtifactName(name: string): boolean;
232
+ /**
233
+ * Drop permanently missing scan roots from the durable registry under the roots
234
+ * lock. Session map entries that pointed only at those roots are removed too.
235
+ */
236
+ export declare function pruneMissingNotificationRoots(input: {
237
+ settings: Settings;
238
+ fs?: TelegramDaemonFs;
239
+ /** When set, only these roots are considered; otherwise every registered root is probed. */
240
+ candidates?: readonly string[];
241
+ }): Promise<{
242
+ pruned: string[];
243
+ remaining: number;
244
+ }>;
245
+ /**
246
+ * Reap retained exact-unlink / ownership-transition quarantine files older than
247
+ * the grace window from the notifications directory.
248
+ */
249
+ export declare function reapStaleNotificationArtifacts(input: {
250
+ settings: Settings;
251
+ fs?: TelegramDaemonFs;
252
+ now?: () => number;
253
+ graceMs?: number;
254
+ }): Promise<{
255
+ removed: string[];
256
+ skipped: number;
257
+ }>;
258
+ /**
259
+ * Startup / ownership self-heal: prune dead roots and reap leak artifacts so
260
+ * `gjc daemon reload` recovers a degraded install without manual surgery (#2956).
261
+ */
262
+ export declare function healTelegramDaemonNotificationState(input: {
263
+ settings: Settings;
264
+ fs?: TelegramDaemonFs;
265
+ now?: () => number;
266
+ graceMs?: number;
267
+ }): Promise<{
268
+ prunedRoots: string[];
269
+ removedArtifacts: string[];
270
+ }>;
191
271
  export declare function hasSafeDaemonStateShape(state: unknown): state is DaemonState;
272
+ type ParentDaemonStateBase = Omit<DaemonState, "incarnation" | "acquisitionId" | "ownershipPhase" | "generation" | "launcherPid"> & {
273
+ incarnation?: undefined;
274
+ acquisitionId?: undefined;
275
+ ownershipPhase?: undefined;
276
+ generation?: unknown;
277
+ launcherPid?: undefined;
278
+ };
279
+ type GenerationAbsentParentDaemonState = Omit<ParentDaemonStateBase, "generation"> & {
280
+ generation?: undefined;
281
+ };
282
+ type Generation3ReleaseDaemonState = Omit<ParentDaemonStateBase, "generation"> & {
283
+ generation: 3;
284
+ };
285
+ export type LegacyParentDaemonState = GenerationAbsentParentDaemonState | Generation3ReleaseDaemonState;
286
+ export interface AttestedLegacyDaemonOwner {
287
+ state: LegacyParentDaemonState;
288
+ incarnation: string;
289
+ }
290
+ /** Revalidate the exact two-observation legacy proof immediately before signaling. */
291
+ export declare function readAttestedLegacyDaemonOwner(input: {
292
+ settings: Settings;
293
+ fs?: TelegramDaemonFs;
294
+ now?: () => number;
295
+ pidIncarnation?: (pid: number) => string | undefined;
296
+ tokenFingerprint: string;
297
+ chatId: string;
298
+ }): Promise<AttestedLegacyDaemonOwner | undefined>;
192
299
  /** True for a physically live owner with this configuration, including legacy generations. */
193
300
  export declare function isPhysicalMatchingOwner(input: {
194
301
  state: DaemonState | undefined;
@@ -197,7 +304,7 @@ export declare function isPhysicalMatchingOwner(input: {
197
304
  pidAlive: (pid: number) => boolean;
198
305
  pidIncarnation?: (pid: number) => string | undefined;
199
306
  }): boolean;
200
- /** True only for a signalable legacy owner or this generation's ready bound child. */
307
+ /** True only for a fully-provenanced modern owner outside the generation-3 parent schema. */
201
308
  export declare function isSignalableMatchingOwner(input: {
202
309
  state: DaemonState | undefined;
203
310
  tokenFingerprint: string;
@@ -246,6 +353,7 @@ export declare function acquireDaemonOwnership(input: {
246
353
  provisional?: boolean;
247
354
  reason?: "identity_mismatch";
248
355
  reloadRequired?: boolean;
356
+ legacyReloadRequired?: boolean;
249
357
  }>;
250
358
  export declare function renewDaemonHeartbeat(input: {
251
359
  settings: Settings;
@@ -322,6 +430,8 @@ export declare function confirmTelegramDaemonSpawn(input: {
322
430
  sleep?: (ms: number) => Promise<void>;
323
431
  waitStepMs?: number;
324
432
  timeoutMs?: number;
433
+ /** Retain an unproven no-PID child lease during a successor handoff. */
434
+ preserveOnUnprovenChildExit?: boolean;
325
435
  }): Promise<boolean>;
326
436
  export declare function releaseDaemonOwnership(input: {
327
437
  settings: Settings;
@@ -339,6 +449,22 @@ export declare function releaseDaemonOwnership(input: {
339
449
  export declare function readDaemonState(settings: Pick<Settings, "getAgentDir">, fs?: TelegramDaemonFs): Promise<DaemonState | undefined>;
340
450
  /** Read the persisted notification roots list. */
341
451
  export declare function readDaemonRoots(settings: Pick<Settings, "getAgentDir">, fs?: TelegramDaemonFs): Promise<string[]>;
452
+ /** Injectable readers for {@link resolveTelegramSetupPreflight}, defaulting to the real OS/state probes. */
453
+ export interface ResolveTelegramSetupPreflightDeps {
454
+ readDaemonState?: (settings: Settings) => Promise<DaemonState | undefined>;
455
+ pidAlive?: (pid: number) => boolean;
456
+ pidIncarnation?: (pid: number) => string | undefined;
457
+ }
458
+ /**
459
+ * Build the Telegram setup preflight from persisted daemon state. The daemon is
460
+ * reported live ONLY when its PID is alive AND its current process incarnation
461
+ * still matches the persisted incarnation. Skipping the incarnation check makes
462
+ * a stale state file whose PID has been recycled by an unrelated process
463
+ * masquerade as a live owner, which wrongly blocks discovery pairing. Both the
464
+ * `notify setup` CLI and the /settings Notifications tab share this resolver so
465
+ * pairing behaves identically on both surfaces.
466
+ */
467
+ export declare function resolveTelegramSetupPreflight(settings: Settings, deps?: ResolveTelegramSetupPreflightDeps): Promise<TelegramSetupPreflight>;
342
468
  export interface TelegramSpawnOwnerInput {
343
469
  settings: Settings;
344
470
  roots?: string[];
@@ -363,6 +489,7 @@ export type TelegramSpawnOwnerResult = {
363
489
  runtime: DaemonRuntimeInfo;
364
490
  warnings: string[];
365
491
  reloadRequired?: boolean;
492
+ legacyReloadRequired?: boolean;
366
493
  } | {
367
494
  result: "blocked";
368
495
  runtime: DaemonRuntimeInfo;
@@ -73,6 +73,7 @@ export declare function buildActionMessage(action: {
73
73
  id: string;
74
74
  question?: string;
75
75
  options?: string[];
76
+ recommendedIndex?: unknown;
76
77
  controls?: readonly TelegramActionControl[];
77
78
  summary?: string;
78
79
  }): RenderedMessage;
@@ -81,6 +82,7 @@ export declare function buildActionMarkdown(action: {
81
82
  kind: "ask" | "idle";
82
83
  question?: string;
83
84
  options?: string[];
85
+ recommendedIndex?: unknown;
84
86
  summary?: string;
85
87
  }): string;
86
88
  /** Send Telegram HTML text chunks sequentially so long messages preserve order. */
@@ -5,7 +5,7 @@ export type ControlInput = Record<string, unknown>;
5
5
  * AgentSession and its controllers without exposing those concrete types here.
6
6
  */
7
7
  export interface ControlSurface {
8
- prompt(text: string, images?: ControlValue): Promise<ControlValue> | ControlValue;
8
+ prompt(text: string, images?: ControlValue, clientRef?: string): Promise<ControlValue> | ControlValue;
9
9
  steer(text: string): Promise<ControlValue> | ControlValue;
10
10
  followUp(text: string): Promise<ControlValue> | ControlValue;
11
11
  abort(): Promise<ControlValue> | ControlValue;
@@ -13,7 +13,7 @@ export interface SessionSdkHostOptions extends HostEndpointAdapters {
13
13
  onProviderDefinitionsRemoved?: (capability: string) => void;
14
14
  onReverseCancel?: (requestId: string, reason: "provider_disconnected" | "lease_released") => void;
15
15
  /** Best-effort capabilities mirrored from the native transport for out-of-band consumers. */
16
- connectionCapabilities?: (connectionId: string) => ReadonlySet<string>;
16
+ connectionCapabilities?: (connectionId: string) => ReadonlySet<string> | undefined;
17
17
  }
18
18
  /** SDK hosting is independent of notification configuration. Only root sessions host an endpoint. */
19
19
  export declare function shouldHostSdk(_settings: unknown, isTopLevel: boolean, env?: NodeJS.ProcessEnv): boolean;
@@ -31,6 +31,14 @@ export interface SessionSurface {
31
31
  totalBytes: number;
32
32
  } | undefined>;
33
33
  getJobs(): unknown | Promise<unknown>;
34
+ /** Q26 keyed lookup of a submitted prompt's authoritative reconciliation status. */
35
+ getPromptStatus?(selector: {
36
+ commandId?: string;
37
+ turnId?: string;
38
+ clientRef?: string;
39
+ }): unknown | Promise<unknown>;
40
+ /** Q27 effective model-profile catalog from the live session registry. */
41
+ getModelProfiles?(): unknown[] | Promise<unknown[]>;
34
42
  /** Query rows backed by the session's installed binding map. */
35
43
  installedQueries?: ReadonlySet<string>;
36
44
  }
@@ -57,6 +65,7 @@ export interface QueryResponse {
57
65
  code: string;
58
66
  message: string;
59
67
  restartQuery?: boolean;
68
+ details?: unknown;
60
69
  };
61
70
  }
62
71
  export declare class QueryHandlers {
@@ -1,7 +1,9 @@
1
+ export { MODEL_PROFILE_DISCOVERY_QUERY, MODEL_PROFILE_ERROR_DETAIL_MAX_BYTES, type ModelProfileCatalogItem, type ModelProfileErrorCode, type ModelProfileErrorDetails, ModelProfileRegistryError, type ModelProfileRegistryErrorDetails, type UnknownModelProfileDetails, UnknownModelProfileError, } from "../config/model-profile-contract";
1
2
  export * as bus from "./bus";
2
3
  export * from "./client";
3
4
  export * as host from "./host";
4
5
  export * as mcp from "./mcp";
5
6
  export type { Q10CurrentThinkingLevel, Q10Model, Q10SettableThinkingLevel, Q10ThinkingCapabilities, Q10ThinkingEffort, Q10ThinkingMode, } from "./models";
7
+ export * from "./prompt-status";
6
8
  export * from "./session";
7
9
  export * from "./session-directory";