@gajae-code/coding-agent 0.12.0 → 0.12.2

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 (247) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/dist/types/async/job-manager.d.ts +17 -3
  3. package/dist/types/config/settings-schema.d.ts +56 -2
  4. package/dist/types/exa/mcp-client.d.ts +10 -1
  5. package/dist/types/exec/bash-executor.d.ts +45 -12
  6. package/dist/types/extensibility/extensions/types.d.ts +16 -2
  7. package/dist/types/extensibility/gjc-plugins/index.d.ts +12 -2
  8. package/dist/types/extensibility/gjc-plugins/installer.d.ts +63 -7
  9. package/dist/types/extensibility/gjc-plugins/lifecycle-reconciliation.d.ts +55 -0
  10. package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +64 -0
  11. package/dist/types/extensibility/gjc-plugins/runtime-quarantine.d.ts +67 -0
  12. package/dist/types/extensibility/gjc-plugins/session-validation.d.ts +3 -1
  13. package/dist/types/extensibility/gjc-plugins/types.d.ts +124 -0
  14. package/dist/types/gjc-runtime/launch-tmux.d.ts +1 -0
  15. package/dist/types/gjc-runtime/ralplan-review-conflicts.d.ts +114 -0
  16. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +23 -3
  17. package/dist/types/gjc-runtime/team-launch.d.ts +1 -1
  18. package/dist/types/gjc-runtime/team-runtime.d.ts +25 -0
  19. package/dist/types/gjc-runtime/team-worker-heartbeat.d.ts +43 -0
  20. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +10 -0
  21. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +37 -80
  22. package/dist/types/modes/acp/acp-agent.d.ts +2 -19
  23. package/dist/types/modes/components/gjc-bundle-settings.d.ts +34 -0
  24. package/dist/types/modes/components/irc-sidebar.d.ts +16 -0
  25. package/dist/types/modes/components/notifications-settings-editor.d.ts +1 -0
  26. package/dist/types/modes/components/session-observer-overlay.d.ts +18 -0
  27. package/dist/types/modes/components/settings-selector.d.ts +9 -0
  28. package/dist/types/modes/components/status-line/gh.d.ts +5 -0
  29. package/dist/types/modes/components/transcript-viewer-overlay.d.ts +18 -1
  30. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  31. package/dist/types/modes/controllers/event-controller.d.ts +1 -1
  32. package/dist/types/modes/controllers/extension-ui-controller.d.ts +2 -1
  33. package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
  34. package/dist/types/modes/interactive-mode.d.ts +9 -0
  35. package/dist/types/modes/theme/theme.d.ts +3 -1
  36. package/dist/types/modes/types.d.ts +32 -0
  37. package/dist/types/reminders/star-reminder.d.ts +3 -13
  38. package/dist/types/runtime-mcp/manager.d.ts +1 -0
  39. package/dist/types/sdk/acp/adapter.d.ts +3 -1
  40. package/dist/types/sdk/broker/transport.d.ts +2 -0
  41. package/dist/types/sdk/bus/attachment-registry.d.ts +1 -0
  42. package/dist/types/sdk/bus/chat-daemon-control.d.ts +5 -1
  43. package/dist/types/sdk/bus/config.d.ts +6 -2
  44. package/dist/types/sdk/bus/index.d.ts +29 -0
  45. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +8 -1
  46. package/dist/types/sdk/bus/lifecycle-control-runtime.d.ts +4 -0
  47. package/dist/types/sdk/bus/reconciliation-store.d.ts +7 -3
  48. package/dist/types/sdk/bus/rich-draft.d.ts +1 -0
  49. package/dist/types/sdk/bus/rich-render.d.ts +2 -0
  50. package/dist/types/sdk/bus/telegram-adoption-intent.d.ts +165 -0
  51. package/dist/types/sdk/bus/telegram-cli.d.ts +12 -0
  52. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +12 -4
  53. package/dist/types/sdk/bus/telegram-daemon.d.ts +25 -1
  54. package/dist/types/sdk/bus/telegram-reference.d.ts +11 -1
  55. package/dist/types/sdk/bus/threaded-render.d.ts +3 -2
  56. package/dist/types/sdk/bus/topic-registry.d.ts +11 -1
  57. package/dist/types/sdk/host/query/revision-store.d.ts +2 -0
  58. package/dist/types/sdk/host/reverse-leases.d.ts +1 -1
  59. package/dist/types/sdk/prompt-status.d.ts +23 -3
  60. package/dist/types/sdk/session.d.ts +6 -0
  61. package/dist/types/session/agent-session.d.ts +40 -2
  62. package/dist/types/session/artifacts.d.ts +8 -0
  63. package/dist/types/session/blob-store.d.ts +57 -4
  64. package/dist/types/session/internal/managed-session-storage.d.ts +30 -4
  65. package/dist/types/session/session-manager.d.ts +23 -6
  66. package/dist/types/session/session-storage.d.ts +4 -0
  67. package/dist/types/session/streaming-output.d.ts +36 -7
  68. package/dist/types/setup/credential-import.d.ts +12 -0
  69. package/dist/types/skill-state/active-state.d.ts +12 -0
  70. package/dist/types/skill-state/workflow-hud.d.ts +6 -0
  71. package/dist/types/task/executor.d.ts +3 -2
  72. package/dist/types/task/index.d.ts +7 -1
  73. package/dist/types/task/output-manager.d.ts +1 -0
  74. package/dist/types/task/provider-retry-status.d.ts +8 -0
  75. package/dist/types/task/receipt.d.ts +9 -1
  76. package/dist/types/task/types.d.ts +23 -0
  77. package/dist/types/tools/ask-answer-registry.d.ts +2 -2
  78. package/dist/types/tools/bash-interactive.d.ts +4 -1
  79. package/dist/types/tools/bash.d.ts +3 -1
  80. package/dist/types/tools/image-gen.d.ts +4 -0
  81. package/dist/types/tools/index.d.ts +6 -0
  82. package/dist/types/tools/output-meta.d.ts +23 -2
  83. package/dist/types/tools/path-utils.d.ts +1 -0
  84. package/dist/types/tools/read.d.ts +0 -6
  85. package/dist/types/tools/review.d.ts +5 -7
  86. package/dist/types/tools/subagent.d.ts +2 -0
  87. package/dist/types/utils/gh.d.ts +13 -0
  88. package/dist/types/utils/image-resize.d.ts +1 -0
  89. package/dist/types/web/search/providers/kimi.d.ts +2 -0
  90. package/dist/types/web/search/providers/searxng.d.ts +7 -0
  91. package/dist/types/web/search/providers/xai.d.ts +2 -0
  92. package/package.json +10 -8
  93. package/scripts/acp-conformance-agent.ts +218 -0
  94. package/scripts/capture-gjc-bundle-settings.ts +306 -0
  95. package/scripts/dogfood-ralplan-review-conflicts.ts +272 -0
  96. package/scripts/generate-sdk-operation-inventory.ts +5 -0
  97. package/scripts/resident-memory-bench.ts +1341 -0
  98. package/scripts/run-acp-conformance.ts +290 -0
  99. package/src/async/job-manager.ts +99 -39
  100. package/src/cli/fast-help.ts +1 -1
  101. package/src/cli/plugin-cli.ts +176 -18
  102. package/src/commands/team.ts +19 -1
  103. package/src/config/file-lock.ts +11 -2
  104. package/src/config/settings-schema.ts +53 -2
  105. package/src/coordinator-mcp/question-gate-codec.ts +1 -1
  106. package/src/coordinator-mcp/server.ts +5 -12
  107. package/src/debug/index.ts +42 -17
  108. package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -0
  109. package/src/defaults/gjc/skills/ralplan/SKILL.md +25 -20
  110. package/src/defaults/gjc/skills/team/SKILL.md +2 -0
  111. package/src/defaults/gjc/skills/ultragoal/SKILL.md +39 -26
  112. package/src/defaults/gjc/skills/ultragoal/validation-batch-contracts.md +12 -0
  113. package/src/defaults/gjc-defaults.ts +4 -4
  114. package/src/exa/mcp-client.ts +12 -3
  115. package/src/exec/bash-executor.ts +144 -27
  116. package/src/extensibility/extensions/runner.ts +15 -0
  117. package/src/extensibility/extensions/types.ts +18 -1
  118. package/src/extensibility/gjc-plugins/constrained-hooks.ts +8 -2
  119. package/src/extensibility/gjc-plugins/index.ts +19 -2
  120. package/src/extensibility/gjc-plugins/installer.ts +189 -50
  121. package/src/extensibility/gjc-plugins/lifecycle-reconciliation.ts +199 -0
  122. package/src/extensibility/gjc-plugins/lifecycle.ts +626 -0
  123. package/src/extensibility/gjc-plugins/observability.ts +3 -3
  124. package/src/extensibility/gjc-plugins/prompt-appendix.ts +5 -1
  125. package/src/extensibility/gjc-plugins/runtime-adapters.ts +12 -2
  126. package/src/extensibility/gjc-plugins/runtime-quarantine.ts +121 -0
  127. package/src/extensibility/gjc-plugins/schema.ts +84 -12
  128. package/src/extensibility/gjc-plugins/session-validation.ts +9 -3
  129. package/src/extensibility/gjc-plugins/types.ts +141 -0
  130. package/src/extensibility/gjc-plugins/validation.ts +9 -0
  131. package/src/gjc-runtime/launch-tmux.ts +25 -6
  132. package/src/gjc-runtime/launch-worktree.ts +103 -1
  133. package/src/gjc-runtime/ledger-event-renderer.ts +1 -0
  134. package/src/gjc-runtime/managed-owner-admission.ts +1 -1
  135. package/src/gjc-runtime/ralplan-review-conflicts.ts +472 -0
  136. package/src/gjc-runtime/ralplan-runtime.ts +491 -27
  137. package/src/gjc-runtime/team-launch.ts +8 -0
  138. package/src/gjc-runtime/team-runtime.ts +140 -32
  139. package/src/gjc-runtime/team-worker-heartbeat.ts +149 -0
  140. package/src/gjc-runtime/tmux-owner-isolation.ts +10 -0
  141. package/src/gjc-runtime/tmux-sessions.ts +58 -13
  142. package/src/gjc-runtime/ultragoal-evidence.ts +6 -74
  143. package/src/gjc-runtime/ultragoal-runtime.ts +635 -612
  144. package/src/gjc-runtime/workflow-manifest.generated.json +37 -99
  145. package/src/gjc-runtime/workflow-manifest.ts +21 -70
  146. package/src/internal-urls/docs-index.generated.ts +16 -16
  147. package/src/modes/DESIGN.md +104 -0
  148. package/src/modes/acp/acp-agent.ts +298 -186
  149. package/src/modes/components/gjc-bundle-settings.ts +508 -0
  150. package/src/modes/components/irc-sidebar.ts +30 -1
  151. package/src/modes/components/notifications-settings-editor.ts +12 -1
  152. package/src/modes/components/oauth-selector.ts +68 -30
  153. package/src/modes/components/session-observer-overlay.ts +305 -86
  154. package/src/modes/components/settings-selector.ts +56 -5
  155. package/src/modes/components/status-line/gh.ts +16 -0
  156. package/src/modes/components/tool-status-header.ts +3 -15
  157. package/src/modes/components/transcript-viewer-overlay.ts +99 -24
  158. package/src/modes/controllers/command-controller.ts +42 -34
  159. package/src/modes/controllers/event-controller.ts +27 -16
  160. package/src/modes/controllers/extension-ui-controller.ts +193 -34
  161. package/src/modes/controllers/selector-controller.ts +160 -22
  162. package/src/modes/interactive-mode.ts +189 -62
  163. package/src/modes/jobs-observer.ts +1 -1
  164. package/src/modes/runtime-init.ts +3 -0
  165. package/src/modes/theme/theme.ts +11 -9
  166. package/src/modes/types.ts +88 -0
  167. package/src/prompts/agent-fragments/ralplan-persistence.md +4 -3
  168. package/src/prompts/system/eager-todo.md +8 -4
  169. package/src/prompts/system/system-prompt.md +11 -4
  170. package/src/prompts/tools/bash.md +5 -5
  171. package/src/prompts/tools/search-tool-bm25.md +5 -0
  172. package/src/prompts/tools/task.md +1 -1
  173. package/src/reminders/star-reminder.ts +4 -42
  174. package/src/runtime-mcp/manager.ts +19 -4
  175. package/src/sdk/acp/adapter.ts +22 -6
  176. package/src/sdk/broker/lifecycle.ts +18 -13
  177. package/src/sdk/broker/transport.ts +35 -3
  178. package/src/sdk/bus/attachment-registry.ts +5 -1
  179. package/src/sdk/bus/chat-daemon-cli.ts +4 -39
  180. package/src/sdk/bus/chat-daemon-control.ts +7 -3
  181. package/src/sdk/bus/config.ts +18 -2
  182. package/src/sdk/bus/index.ts +661 -126
  183. package/src/sdk/bus/kind-aware-reconciliation.ts +148 -73
  184. package/src/sdk/bus/lifecycle-commands.ts +4 -1
  185. package/src/sdk/bus/lifecycle-control-runtime.ts +403 -88
  186. package/src/sdk/bus/reconciliation-store.ts +95 -16
  187. package/src/sdk/bus/rich-draft.ts +1 -1
  188. package/src/sdk/bus/rich-render.ts +2 -2
  189. package/src/sdk/bus/telegram-adoption-intent.ts +574 -0
  190. package/src/sdk/bus/telegram-cli.ts +33 -8
  191. package/src/sdk/bus/telegram-daemon-cli.ts +1 -0
  192. package/src/sdk/bus/telegram-daemon-contract.ts +12 -4
  193. package/src/sdk/bus/telegram-daemon.ts +916 -23
  194. package/src/sdk/bus/telegram-reference.ts +40 -3
  195. package/src/sdk/bus/threaded-render.ts +48 -3
  196. package/src/sdk/bus/topic-registry.ts +20 -0
  197. package/src/sdk/host/query/revision-store.ts +36 -2
  198. package/src/sdk/host/reverse-leases.ts +44 -7
  199. package/src/sdk/prompt-status.ts +16 -3
  200. package/src/sdk/protocol/operation-inventory.generated.json +33 -0
  201. package/src/sdk/session.ts +89 -9
  202. package/src/session/agent-session.ts +844 -173
  203. package/src/session/artifacts.ts +22 -0
  204. package/src/session/auth-broker-config.ts +10 -3
  205. package/src/session/blob-store.ts +915 -24
  206. package/src/session/internal/managed-session-scope.ts +200 -111
  207. package/src/session/internal/managed-session-storage.ts +492 -62
  208. package/src/session/session-manager.ts +1614 -435
  209. package/src/session/session-storage.ts +38 -45
  210. package/src/session/streaming-output.ts +238 -68
  211. package/src/setup/credential-import.ts +75 -13
  212. package/src/skill-state/active-state.ts +32 -0
  213. package/src/skill-state/workflow-hud.ts +17 -0
  214. package/src/skill-state/workflow-mutation-guard.ts +496 -2
  215. package/src/task/executor.ts +122 -39
  216. package/src/task/index.ts +280 -45
  217. package/src/task/output-manager.ts +24 -14
  218. package/src/task/provider-retry-status.ts +16 -0
  219. package/src/task/receipt.ts +34 -8
  220. package/src/task/render.ts +6 -2
  221. package/src/task/types.ts +108 -0
  222. package/src/tools/ask-answer-registry.ts +12 -6
  223. package/src/tools/ask.ts +86 -55
  224. package/src/tools/ast-edit.ts +1 -0
  225. package/src/tools/ast-grep.ts +1 -0
  226. package/src/tools/bash-interactive.ts +8 -3
  227. package/src/tools/bash.ts +503 -60
  228. package/src/tools/find.ts +1 -0
  229. package/src/tools/image-gen.ts +29 -5
  230. package/src/tools/index.ts +6 -0
  231. package/src/tools/output-meta.ts +108 -14
  232. package/src/tools/path-utils.ts +3 -2
  233. package/src/tools/read.ts +18 -0
  234. package/src/tools/review.ts +5 -7
  235. package/src/tools/search.ts +1 -0
  236. package/src/tools/subagent-render.ts +6 -2
  237. package/src/tools/subagent.ts +6 -0
  238. package/src/tools/telegram-send.ts +6 -3
  239. package/src/utils/gh.ts +39 -0
  240. package/src/utils/image-resize.ts +3 -0
  241. package/src/web/search/providers/anthropic.ts +4 -4
  242. package/src/web/search/providers/kimi.ts +15 -5
  243. package/src/web/search/providers/searxng.ts +47 -4
  244. package/src/web/search/providers/xai.ts +7 -2
  245. package/dist/types/gjc-runtime/ultragoal-pipeline.d.ts +0 -23
  246. package/src/defaults/gjc/skills/ultragoal/pipeline-validation-contracts.md +0 -30
  247. package/src/gjc-runtime/ultragoal-pipeline.ts +0 -306
@@ -28,6 +28,7 @@ export interface NotificationSettingsSnapshot {
28
28
  botToken?: string;
29
29
  chatId?: string;
30
30
  activation?: Record<string, unknown>;
31
+ sound: "all" | "important" | "none";
31
32
  btw: {
32
33
  enabled: boolean;
33
34
  };
@@ -105,6 +106,7 @@ export interface NotificationConfig {
105
106
  * (those carrying {@link SPAWN_PROVENANCE_ENV}) unless they explicitly opt in.
106
107
  */
107
108
  sessionScope: "all" | "primary";
109
+ sound: "all" | "important" | "none";
108
110
  idleTimeoutMs: number;
109
111
  btw: {
110
112
  enabled: boolean;
@@ -177,7 +179,7 @@ export declare function isTelegramConfigured(cfg: NotificationConfig): cfg is No
177
179
  chatId: string;
178
180
  };
179
181
  /** Is Discord configured with all credentials and routing identifiers required by its daemon. */
180
- export declare function isDiscordConfigured(cfg: NotificationConfig): cfg is NotificationConfig & {
182
+ export declare function isDiscordConfigured(cfg: Pick<NotificationConfig, "enabled" | "discord">): cfg is Pick<NotificationConfig, "enabled"> & {
181
183
  discord: {
182
184
  botToken: string;
183
185
  applicationId: string;
@@ -186,7 +188,7 @@ export declare function isDiscordConfigured(cfg: NotificationConfig): cfg is Not
186
188
  };
187
189
  };
188
190
  /** Is Slack configured with both SDK tokens and its workspace/channel routing identifiers. */
189
- export declare function isSlackConfigured(cfg: NotificationConfig): cfg is NotificationConfig & {
191
+ export declare function isSlackConfigured(cfg: Pick<NotificationConfig, "enabled" | "slack">): cfg is Pick<NotificationConfig, "enabled"> & {
190
192
  slack: {
191
193
  botToken: string;
192
194
  appToken: string;
@@ -286,6 +288,8 @@ export interface RedactableAction {
286
288
  workflowGateId?: string;
287
289
  question?: string;
288
290
  options?: string[];
291
+ /** Selected zero-based option positions for transport-specific multi-select rendering. */
292
+ selectedOptionIndices?: number[];
289
293
  summary?: string;
290
294
  /** Optional zero-based recommendation into the authoritative raw options. */
291
295
  recommendedIndex?: number;
@@ -26,6 +26,7 @@ import type { AgentSessionEvent } from "../../session/agent-session";
26
26
  import type { AskAnswerSourceResult, AskRemoteControl } from "../../tools";
27
27
  import { SessionSdkHost } from "../host";
28
28
  import { CursorRegistry, RevisionStore } from "../host/query";
29
+ import { type SdkPromptTerminalOutcome } from "../prompt-status";
29
30
  import { type SdkStartupFailure } from "../startup-capability";
30
31
  import { type NotificationConfig } from "./config";
31
32
  import { NotificationSessionController } from "./session-control";
@@ -348,6 +349,23 @@ interface SessionRuntime {
348
349
  commandId: string;
349
350
  turnId: string;
350
351
  };
352
+ /** Binds the executing Agent run to a correlated prompt so cleanup targets only it. */
353
+ bindPromptExecutionHandle: (correlation: {
354
+ commandId: string;
355
+ turnId: string;
356
+ }, handle: string | undefined) => void;
357
+ /** Reads the durable non-terminal claim for a correlated prompt, if any. */
358
+ peekPromptPendingOutcome: (correlation: {
359
+ commandId: string;
360
+ turnId: string;
361
+ }) => SdkPromptTerminalOutcome | undefined;
362
+ /** Claims, fences, finalizes, and publishes exactly one normalized prompt terminal. */
363
+ terminalizePrompt: (correlation: {
364
+ commandId: string;
365
+ turnId: string;
366
+ }, outcome: SdkPromptTerminalOutcome, extra?: {
367
+ finalText?: string;
368
+ }) => Promise<void>;
351
369
  /** Records a correlated prompt terminal boundary after agent unwind. */
352
370
  /** Atomically claims a correlated prompt terminal boundary after agent unwind. */
353
371
  recordPromptTerminal: (correlation: {
@@ -379,6 +397,7 @@ interface SessionRuntime {
379
397
  commandId?: string;
380
398
  turnId?: string;
381
399
  finalText?: string;
400
+ outcome?: SdkPromptTerminalOutcome;
382
401
  } | {
383
402
  type: "agent_failed";
384
403
  sessionId: string;
@@ -388,6 +407,7 @@ interface SessionRuntime {
388
407
  code: string;
389
408
  message: string;
390
409
  };
410
+ outcome?: SdkPromptTerminalOutcome;
391
411
  }) => void;
392
412
  /** Publishes one canonical agent-wire event to the client that owns the active prompt. */
393
413
  emitPromptEvent: (event: AgentSessionEvent) => void;
@@ -446,6 +466,15 @@ type SessionStartResult = {
446
466
  failure?: SdkStartupFailure;
447
467
  suppressExtensionError?: boolean;
448
468
  };
469
+ /**
470
+ * Whether the notifications control channel is enabled.
471
+ *
472
+ * Trusted sources only: enabling it opens the session control/answer channel, so
473
+ * a repository must not be able to turn it on. `$env` merges the caller's
474
+ * `cwd/.env` into `process.env`; the sibling resolvers in `config.ts` and
475
+ * `session-control.ts` already read an injected env record rather than the merged
476
+ * view, and this direct read was the outlier.
477
+ */
449
478
  export declare function notificationsEnabled(): boolean;
450
479
  /** Workflow-gate answer shape. */
451
480
  interface GateAnswer {
@@ -2,7 +2,8 @@
2
2
  * Kind-aware invocation reconciliation (prompt | skill) with optional durable store.
3
3
  * Preserves Q26 admit/first-terminal/capacity/TTL semantics; indexes and caps are per-kind.
4
4
  */
5
- import { type PromptCorrelation, type PromptReconciliationStatus, type TurnPromptReconciliation } from "./prompt-reconciliation";
5
+ import type { PromptReconciliationStatus, SdkPromptTerminalOutcome, TurnPromptReconciliation } from "../prompt-status";
6
+ import { type PromptCorrelation } from "./prompt-reconciliation";
6
7
  import type { ReconciliationKind, ReconciliationStore } from "./reconciliation-store";
7
8
  export type { ReconciliationKind };
8
9
  export interface KindCorrelation extends PromptCorrelation {
@@ -20,6 +21,12 @@ export interface KindAwareReconciliation {
20
21
  type: "agent_failed";
21
22
  error: unknown;
22
23
  }): Promise<void>;
24
+ claimPendingOutcome(correlation: PromptCorrelation, outcome: SdkPromptTerminalOutcome): Promise<SdkPromptTerminalOutcome>;
25
+ finalizePromptOutcome(correlation: PromptCorrelation, outcome?: SdkPromptTerminalOutcome, recordError?: {
26
+ code: string;
27
+ message: string;
28
+ }): Promise<void>;
29
+ peekPendingOutcome(correlation: PromptCorrelation): SdkPromptTerminalOutcome | undefined;
23
30
  lookup(kind: ReconciliationKind, selector: {
24
31
  commandId?: string;
25
32
  turnId?: string;
@@ -48,6 +48,8 @@ export declare function buildCreateArgv(frame: SessionCreateFrame, _ids: {
48
48
  /** Real daemon-safe tmux launcher: canonical owner-isolation plan + GJC tags. */
49
49
  export declare function daemonSpawnCreate(env?: NodeJS.ProcessEnv, opts?: {
50
50
  ownerIsolationProbe?: OwnerIsolationProbe;
51
+ platform?: NodeJS.Platform;
52
+ processIncarnation?: (pid: number) => string | undefined;
51
53
  }): (frame: SessionCreateFrame, ids: {
52
54
  lifecycleRequestId: string;
53
55
  intendedSessionId: string;
@@ -73,6 +75,8 @@ export declare function daemonResumeSession(env?: NodeJS.ProcessEnv, opts?: {
73
75
  sessionsRoot?: string;
74
76
  listSessions?: (env: NodeJS.ProcessEnv) => GjcTmuxSessionStatus[];
75
77
  ownerIsolationProbe?: OwnerIsolationProbe;
78
+ platform?: NodeJS.Platform;
79
+ processIncarnation?: (pid: number) => string | undefined;
76
80
  }): (target: {
77
81
  sessionIdOrPrefix: string;
78
82
  path?: string;
@@ -1,4 +1,5 @@
1
- import type { PromptCorrelation, PromptReconciliationStatus } from "./prompt-reconciliation";
1
+ import type { PromptReconciliationStatus, SdkPromptTerminalOutcome } from "../prompt-status";
2
+ import type { PromptCorrelation } from "./prompt-reconciliation";
2
3
  export declare const RECONCILIATION_STORE_VERSION = 1;
3
4
  export declare const RECONCILIATION_SESSION_ID_PATTERN: RegExp;
4
5
  export declare const RECONCILIATION_DIR_NAME = ".sdk-reconciliation";
@@ -14,6 +15,8 @@ export interface DurableReconciliationRecord extends PromptCorrelation {
14
15
  acceptedAt: number;
15
16
  startedAt?: number;
16
17
  terminalAt?: number;
18
+ outcome?: SdkPromptTerminalOutcome;
19
+ pendingOutcome?: SdkPromptTerminalOutcome;
17
20
  /** Skill-only safe token; never skill args bodies. */
18
21
  skillName?: string;
19
22
  }
@@ -43,8 +46,9 @@ export declare function isSafeReconciliationSessionId(sessionId: string): boolea
43
46
  /** Derive private store path; throws if sessionId is unsafe (path escape). */
44
47
  export declare function reconciliationStorePath(sessionFile: string, sessionId: string): string;
45
48
  /**
46
- * Settle non-terminal durable records after process death: failed/process_restart.
47
- * Meaning: reconciliation incomplete — not proof of agent failure.
49
+ * Settle non-terminal durable records after process death.
50
+ * Prompt records preserve a durable pending outcome; skills retain the existing
51
+ * reconciliation-incomplete result.
48
52
  */
49
53
  export declare function settleProcessRestart(records: DurableReconciliationRecord[], now: number): DurableReconciliationRecord[];
50
54
  export interface ReconciliationStore {
@@ -63,6 +63,7 @@ export declare class DraftStreamState {
63
63
  export declare function deliverDraft(botApi: BotApi, base: {
64
64
  chat_id: string | number;
65
65
  message_thread_id?: number;
66
+ disable_notification?: true;
66
67
  }, draftId: number, raw: string, log?: {
67
68
  warn(msg: string): void;
68
69
  }): Promise<void>;
@@ -43,6 +43,7 @@ export declare function shouldPromoteRich(input: {
43
43
  export declare function deliverRichWithFallback(botApi: BotApi, base: {
44
44
  chat_id: string | number;
45
45
  message_thread_id?: number;
46
+ disable_notification?: true;
46
47
  }, send: ThreadedSend, signal: AbortSignal, fallbackDeliver: () => Promise<void>, log?: {
47
48
  warn(msg: string): void;
48
49
  }): Promise<number | undefined>;
@@ -55,6 +56,7 @@ export declare function deliverRichWithFallback(botApi: BotApi, base: {
55
56
  export declare function deliverRichActionWithFallback(botApi: BotApi, base: {
56
57
  chat_id: string | number;
57
58
  message_thread_id?: number;
59
+ disable_notification?: true;
58
60
  }, opts: {
59
61
  markdown: string;
60
62
  replyMarkup?: unknown;
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Durable, non-routable sidecar store for "adopt a user-created Telegram forum
3
+ * topic into a preallocated session" intents.
4
+ *
5
+ * When a user creates a new forum topic, the daemon first records durable
6
+ * pending-topic authorization. After folder selection it preallocates an
7
+ * `intendedSessionId` and records an adoption intent here *before* spawning.
8
+ * Later, the authenticated `ensureTopic` create callback reads that intent and
9
+ * returns the user's existing topicId to `TopicRegistry.getOrCreateTopic`, which
10
+ * is the only authority that commits a topic binding. This keeps the intent out
11
+ * of routing/endpoint authority until commit, so a failed spawn or a late socket
12
+ * never deletes the user's topic and never strands a duplicate.
13
+ *
14
+ * Invariants (see `pending-approval.md`):
15
+ * - One file per intent, named `<intendedSessionId>.adoption-intent.json` under
16
+ * the daemon notifications dir. Sweep touches files only; never the Telegram API.
17
+ * - Only `{ intendedSessionId, topicId, chatId, target, createdAt, expiresAt }`
18
+ * is persisted. Bot/control tokens and endpoint digests are never stored.
19
+ * - Owner-only dir (0o700) and 0o600 files; atomic temp→fsync→chmod→rename→parent sync.
20
+ * - `tryClaim` is a synchronous, in-memory claim keyed by topicId; it excludes a
21
+ * second `intendedSessionId` from winning the same topic across awaits. It
22
+ * does not delete the sidecar; `releaseClaim` re-enables retry on commit failure.
23
+ */
24
+ import type { SessionCreateTarget } from "./index";
25
+ /** Persisted document version. */
26
+ export declare const TELEGRAM_ADOPTION_INTENT_VERSION = 1;
27
+ export type TelegramAdoptionTarget = Extract<SessionCreateTarget, {
28
+ kind: "existing_path";
29
+ }>;
30
+ /** Default intent TTL (configurable at write time). Plan starts at 10 minutes. */
31
+ export declare const DEFAULT_ADOPTION_INTENT_TTL_MS: number;
32
+ /**
33
+ * Minimal async filesystem surface the store needs. Structurally a subset of the
34
+ * daemon's `TelegramDaemonFs` / `ConversationStoreFs`, so the daemon can pass its
35
+ * own `fs` straight through and tests can inject a fake. `open`/`sync`/`close`
36
+ * mirror `ConversationStoreFileHandle` so the atomic fsync path reuses the same
37
+ * shape as the conversation store.
38
+ */
39
+ export interface AdoptionIntentFs {
40
+ mkdir(directory: string, options: {
41
+ recursive: true;
42
+ mode: number;
43
+ }): Promise<unknown>;
44
+ chmod(target: string, mode: number): Promise<void>;
45
+ readFile(file: string, encoding: "utf8"): Promise<string>;
46
+ writeFile(file: string, data: string, options: {
47
+ mode: number;
48
+ }): Promise<void>;
49
+ rename(from: string, to: string): Promise<void>;
50
+ unlink(file: string): Promise<unknown>;
51
+ readdir(directory: string): Promise<readonly string[]>;
52
+ open(file: string, flags: string): Promise<AdoptionIntentFileHandle>;
53
+ }
54
+ export interface AdoptionIntentFileHandle {
55
+ sync(): Promise<void>;
56
+ close(): Promise<void>;
57
+ }
58
+ /** What gets persisted per intent. No tokens, no digests. */
59
+ export interface TelegramAdoptionIntent {
60
+ intendedSessionId: string;
61
+ topicId: number;
62
+ chatId: string;
63
+ target: TelegramAdoptionTarget;
64
+ createdAt: number;
65
+ expiresAt: number;
66
+ }
67
+ /** Durable authorization that a topic was observed through forum_topic_created. */
68
+ export interface TelegramPendingTopic {
69
+ topicId: number;
70
+ chatId: string;
71
+ createdAt: number;
72
+ expiresAt: number;
73
+ }
74
+ /** Compose the per-intent sidecar path. Public so callers/tests can inspect it. */
75
+ export declare function adoptionIntentFilePath(agentDir: string, intendedSessionId: string): string;
76
+ /** Compose the sidecar path for a user-created topic awaiting a folder choice. */
77
+ export declare function pendingTopicFilePath(agentDir: string, topicId: number): string;
78
+ /** Build a fresh intent with `createdAt`/`expiresAt` derived from `now`/`ttlMs`. */
79
+ export declare function buildAdoptionIntent(input: {
80
+ intendedSessionId: string;
81
+ topicId: number;
82
+ chatId: string;
83
+ target: TelegramAdoptionTarget;
84
+ now?: number;
85
+ ttlMs?: number;
86
+ }): TelegramAdoptionIntent;
87
+ /** Test-only: filename suffix used to recognize intent sidecars in a directory listing. */
88
+ export declare const ADOPTION_INTENT_FILENAME_SUFFIX = ".adoption-intent.json";
89
+ export declare const PENDING_TOPIC_FILENAME_SUFFIX = ".pending-topic.json";
90
+ /**
91
+ * Durable, non-routable adoption-intent store. Owns durable sidecar files and
92
+ * the synchronous in-memory topicId claim table. The daemon owns Telegram and
93
+ * lifecycle wiring; this store never calls the Telegram API.
94
+ */
95
+ export declare class TelegramAdoptionIntentStore {
96
+ #private;
97
+ constructor(input: {
98
+ agentDir: string;
99
+ fs?: AdoptionIntentFs;
100
+ now?: () => number;
101
+ platform?: NodeJS.Platform;
102
+ });
103
+ /** Directory holding the sidecar files. */
104
+ get directory(): string;
105
+ /** In-memory lookup by intendedSessionId (no disk read). undefined if absent/expired. */
106
+ bySession(intendedSessionId: string): TelegramAdoptionIntent | undefined;
107
+ /** In-memory lookup of the (single) non-expired intent for a topicId. */
108
+ byTopic(topicId: number): TelegramAdoptionIntent | undefined;
109
+ /** `true` if a non-expired intent already references `topicId`. */
110
+ hasNonExpiredTopic(topicId: number): boolean;
111
+ /** Durable authorization for an observed user-created topic, if still live. */
112
+ pendingTopic(topicId: number): TelegramPendingTopic | undefined;
113
+ hasPendingTopic(topicId: number, chatId: string): boolean;
114
+ /**
115
+ * Synchronously claim `topicId` for `intendedSessionId`. Returns false if a
116
+ * *different* non-expired intendedSessionId already holds the claim (or has a
117
+ * non-expired intent for the topic). Same intendedSessionId re-claiming its
118
+ * own topic is idempotent and succeeds. The claim is in-memory only; it never
119
+ * deletes the sidecar, so a commit failure can `releaseClaim` and retry.
120
+ */
121
+ tryClaim(topicId: number, intendedSessionId: string): boolean;
122
+ /** Release a claim held by `intendedSessionId` on `topicId`. No-op otherwise. */
123
+ releaseClaim(topicId: number, intendedSessionId: string): void;
124
+ /**
125
+ * Durable write of one intent: temp→write→fsync→chmod(0600)→atomic rename→
126
+ * chmod(final, 0600)→parent-dir fsync, then track it in memory. The dir is
127
+ * created owner-only (0700). chmod-ing the final path after the rename makes
128
+ * the 0600 contract durable regardless of whether the platform's rename
129
+ * preserves the source mode (POSIX does; some test/network filesystems and
130
+ * the in-memory test double model rename as copy+delete and would otherwise
131
+ * drop it). The rename is still the atomic commit point; the final chmod only
132
+ * tightens permissions on the already-durable file. The in-memory map is only
133
+ * mutated after the atomic persist succeeds. Rejects (does not swallow) so the
134
+ * daemon can decide fail-closed behavior.
135
+ */
136
+ put(intent: TelegramAdoptionIntent): Promise<void>;
137
+ /** Persist authorization for a topic observed through forum_topic_created. */
138
+ putPendingTopic(pendingTopic: TelegramPendingTopic): Promise<void>;
139
+ /**
140
+ * Read a single intent sidecar from disk and track it if it is non-expired
141
+ * and well-formed. Returns the parsed intent (or undefined). Used by
142
+ * `rehydrate`; callers normally use `rehydrate` / `bySession`.
143
+ */
144
+ readIntent(intendedSessionId: string): Promise<TelegramAdoptionIntent | undefined>;
145
+ readPendingTopic(topicId: number): Promise<TelegramPendingTopic | undefined>;
146
+ /**
147
+ * Rehydrate all non-expired intents from the notifications dir. Files are the
148
+ * only source: missing/corrupt/expired entries are skipped (never thrown).
149
+ * Returns the count of live intents loaded.
150
+ */
151
+ rehydrate(): Promise<number>;
152
+ /**
153
+ * Remove a single intent sidecar and drop its in-memory entry. Safe to call
154
+ * after a successful registry commit or a definite spawn failure. Missing
155
+ * files are not an error. Never calls the Telegram API.
156
+ */
157
+ remove(intendedSessionId: string): Promise<void>;
158
+ /** Remove a pending-topic authorization after an adoption intent is durable. */
159
+ removePendingTopic(topicId: number): Promise<void>;
160
+ /**
161
+ * Sweep expired intent sidecars from disk. Touches files only. Returns the
162
+ * count of expired sidecars removed. Safe to run at startup and periodically.
163
+ */
164
+ sweepExpired(): Promise<number>;
165
+ }
@@ -16,4 +16,16 @@
16
16
  * If neither --endpoint-file nor --session-id is given, the newest endpoint file
17
17
  * under <repo>/.gjc/state/sdk/ is used.
18
18
  */
19
+ import { type TelegramNotificationSound } from "./telegram-reference";
20
+ interface CliArgs {
21
+ botToken?: string;
22
+ chatId?: string;
23
+ endpointFile?: string;
24
+ sessionId?: string;
25
+ repo: string;
26
+ apiBase?: string;
27
+ sound: TelegramNotificationSound;
28
+ force: boolean;
29
+ }
30
+ export declare function parseArgs(argv: string[]): CliArgs;
19
31
  export {};
@@ -38,12 +38,20 @@ export declare const NOTIFICATION_PROTOCOL_VERSION = 3;
38
38
  * Generation 29 adds serving-epoch compatibility, sidecar heartbeat, root GC,
39
39
  * and Bot API cooldown structural fixes (#2956, #2960, #3048).
40
40
  * Generation 30 adds opt-in tool activity delivery, closed lifecycle phases,
41
- * and capability-versioned mixed-host compatibility.
41
+ * and capability-versioned mixed-host compatibility. Generation 31 rolls out
42
+ * non-Linux direct tmux lifecycle cleanup semantics. Generation 32 applies
43
+ * Telegram sound-notification policy across daemon delivery paths. Generation
44
+ * 33 adds action-bound multi-select state rendering and replay-safe option
45
+ * snapshots. Generation 34 converts non-photo image formats (including WebP)
46
+ * into Telegram-compatible photo uploads when possible. Generation 35 adds
47
+ * user-created topic adoption (forum-topic folder picker). Generation 36 binds
48
+ * managed-session replacement to exact native filesystem authority.
42
49
  */
43
- export declare const DAEMON_GENERATION = 30;
50
+ export declare const DAEMON_GENERATION = 36;
44
51
  /**
45
52
  * Serving-compatibility boundary for daemon lifecycle requests. Epoch 1 covers
46
53
  * all builds published before this field existed; epoch 2 covered generation 29;
47
- * bump this to force serving convergence and reload of compatible live predecessors.
54
+ * epoch 3 covered generation 30; bump this to force serving convergence and
55
+ * reload of compatible live predecessors.
48
56
  */
49
- export declare const SERVING_EPOCH = 3;
57
+ export declare const SERVING_EPOCH = 4;
@@ -62,6 +62,7 @@ export interface TelegramDaemonFs {
62
62
  dev?: number;
63
63
  ino?: number;
64
64
  ctimeMs?: number;
65
+ isDirectory?: () => boolean;
65
66
  }>;
66
67
  readEndpointFile?(path: string): Promise<NotificationEndpointFile>;
67
68
  exactUnlink?(path: string, identity: NotificationEndpointFileIdentity): Promise<NotificationExactUnlinkResult>;
@@ -722,6 +723,8 @@ export interface TelegramDaemonOptions {
722
723
  enabled: boolean;
723
724
  };
724
725
  idleTimeoutMs?: number;
726
+ /** TTL for durable topic-adoption intents (default 10 minutes). Observed, not a fixed contract. */
727
+ adoptionIntentTtlMs?: number;
725
728
  scanIntervalMs?: number;
726
729
  pid?: number;
727
730
  /** Liveness probe for skipping dead-PID endpoint records in {@link TelegramNotificationDaemon.scanRoots}. */
@@ -758,6 +761,8 @@ export interface TelegramDaemonOptions {
758
761
  toolActivity?: {
759
762
  enabled: boolean;
760
763
  };
764
+ /** Controls which Telegram sends play an audible notification. Defaults to all. */
765
+ sound?: "all" | "important" | "none";
761
766
  /**
762
767
  * Per-session Telegram forum-topic naming. `nameTemplate` supports the
763
768
  * `{repo}`, `{branch}`, and `{title}` placeholders; unset preserves the
@@ -958,7 +963,7 @@ export declare class TelegramNotificationDaemon {
958
963
  private reserveSeenUpdateId;
959
964
  private releaseSeenUpdateId;
960
965
  scanRoots(): Promise<void>;
961
- connectSession(sessionId: string, url: string, token: string): void;
966
+ connectSession(sessionId: string, url: string, token: string): SessionSocket;
962
967
  /**
963
968
  * Start ack-based liveness for a session whose server advertised the
964
969
  * `client_ping_pong` capability. Each interval drops the session when no pong
@@ -1030,6 +1035,16 @@ export declare class TelegramNotificationDaemon {
1030
1035
  private deleteTopic;
1031
1036
  private persistTopics;
1032
1037
  loadTopics(): Promise<void>;
1038
+ /**
1039
+ * Rehydrate durable adoption intents after restart, then reconcile: a
1040
+ * non-expired sidecar whose target session already has a committed topic
1041
+ * record is a stale leftover (commit succeeded but sidecar cleanup failed)
1042
+ * and is removed safely without touching the user topic.
1043
+ */
1044
+ loadAdoptionIntents(): Promise<void>;
1045
+ /** Periodic sweep of expired adoption-intent sidecars (files only; no Telegram API). */
1046
+ private startAdoptionSweepTimer;
1047
+ private stopAdoptionSweepTimer;
1033
1048
  /** Retry crash-interrupted topic deletes; only a definite Telegram result clears the durable fence. */
1034
1049
  private reconcilePendingTopicDeletes;
1035
1050
  /** Download one Telegram file with the Bot API's 20 MiB ceiling and one end-to-end deadline. */
@@ -1117,6 +1132,15 @@ export declare class TelegramNotificationDaemon {
1117
1132
  handleSessionMessage(session: SessionSocket, msg: any): Promise<void>;
1118
1133
  private answerCallbackQueryBestEffort;
1119
1134
  private sendStaleGuidance;
1135
+ /**
1136
+ * Consume a user-created forum topic (`forum_topic_created` service message)
1137
+ * before edited/text routing. Authenticates the chat, user, privacy, and
1138
+ * lifecycle state; offers home, recent folders, or explicit path entry. The
1139
+ * selected path (or an exact `/session_create path <dir>`) creates a session
1140
+ * that adopts this topic — never a duplicate topic. Non-routable durable
1141
+ * intents prevent duplicate creation across concurrent first frames.
1142
+ */
1143
+ private handleForumTopicCreatedUpdate;
1120
1144
  /** Consume Telegram forum-topic rename service messages before text routing. */
1121
1145
  private handleForumTopicEdited;
1122
1146
  private processTelegramUpdate;
@@ -85,8 +85,17 @@ export declare function buildActionMarkdown(action: {
85
85
  recommendedIndex?: unknown;
86
86
  summary?: string;
87
87
  }): string;
88
+ export type TelegramNotificationSound = "all" | "important" | "none";
89
+ export type TelegramDeliveryLane = "ask" | "idle" | "live" | "finalized";
90
+ /**
91
+ * Resolve Telegram's optional silent-delivery flag. `finalChunk` silences
92
+ * non-final actionable chunks under the `important` policy; `undefined`
93
+ * intentionally omits the field so Telegram uses its normal audible delivery
94
+ * behavior.
95
+ */
96
+ export declare function telegramDisableNotification(sound: TelegramNotificationSound | undefined, lane: TelegramDeliveryLane, finalChunk?: boolean): true | undefined;
88
97
  /** Send Telegram HTML text chunks sequentially so long messages preserve order. */
89
- export declare function sendTelegramHtmlChunks(send: TelegramSend, chatId: string, text: string, inlineKeyboard?: InlineButton[][]): Promise<void>;
98
+ export declare function sendTelegramHtmlChunks(send: TelegramSend, chatId: string, text: string, inlineKeyboard?: InlineButton[][], sound?: TelegramNotificationSound, lane?: TelegramDeliveryLane): Promise<void>;
90
99
  /** A protocol `reply` frame the client should send to the server. */
91
100
  export interface ReplyFrame {
92
101
  type: "reply";
@@ -128,6 +137,7 @@ export interface TelegramReferenceOptions {
128
137
  endpointFile: string;
129
138
  apiBase?: string;
130
139
  fetchImpl?: typeof fetch;
140
+ sound?: TelegramNotificationSound;
131
141
  }
132
142
  /**
133
143
  * Run the reference bridge until the WebSocket closes. Sends `action_needed` to
@@ -14,13 +14,13 @@ export interface ThreadedSend {
14
14
  method: "sendMessage" | "sendPhoto" | "sendDocument";
15
15
  /** Rate-limit lane for prioritisation/fairness. */
16
16
  lane: RateLimitLane;
17
- /** Message text (sendMessage) or photo caption (sendPhoto). */
17
+ /** Message text (sendMessage) or media caption (sendPhoto/sendDocument). */
18
18
  text?: string;
19
19
  /** Base64 image bytes for sendPhoto. */
20
20
  photoBase64?: string;
21
21
  /** Base64 file bytes for sendDocument. */
22
22
  documentBase64?: string;
23
- /** Image MIME type for sendPhoto. */
23
+ /** Uploaded media MIME type. */
24
24
  mime?: string;
25
25
  /** Suggested document filename. */
26
26
  fileName?: string;
@@ -83,6 +83,7 @@ interface ThreadedFrame {
83
83
  status?: unknown;
84
84
  message?: unknown;
85
85
  }
86
+ export declare function supportsTelegramPhotoUpload(mime: string | undefined): boolean;
86
87
  /** Format the one-time identity header as pinned bullets. */
87
88
  export declare function formatIdentityHeader(frame: {
88
89
  repo?: unknown;
@@ -42,6 +42,8 @@ export interface TopicRecord {
42
42
  creationLeaseEpoch?: number;
43
43
  /** An uncertain delete fences future creation and inbound routing. */
44
44
  authorityState?: "active" | "delete_pending";
45
+ /** Provenance for topics created by the user and adopted by GJC. Missing means daemon-created. */
46
+ topicOrigin?: "user_created";
45
47
  /** Telegram chat and endpoint authority last proven to use this topic. */
46
48
  chatId?: string;
47
49
  /** Canonical endpoint tuple (URL + token) that currently holds the lease. */
@@ -129,6 +131,14 @@ export declare class TopicRegistry {
129
131
  authorityEpoch(sessionId: string): number;
130
132
  /** Whether this session has an active, unambiguous topic authority. */
131
133
  isActiveUnambiguous(sessionId: string): boolean;
134
+ /**
135
+ * Pure read-only availability check for user-topic adoption. Rejects invalid
136
+ * ids and any id already committed, delete-pending/fenced, staged, or
137
+ * ambiguous, without mutating maps, epochs, or persistence. Used inside the
138
+ * {@link getOrCreateTopic} create callback to fail-closed before adopting a
139
+ * user-created topic id.
140
+ */
141
+ isTopicIdAvailable(topicId: string): boolean;
132
142
  /**
133
143
  * Resolve endpoint authority for identity-less replay. An endpoint may bootstrap
134
144
  * only when no committed, staged, or pre-create claim can own it; malformed
@@ -153,7 +163,7 @@ export declare class TopicRegistry {
153
163
  * Return the existing active topic for `sessionId`, or create one via
154
164
  * `create` (called only on first use).
155
165
  */
156
- getOrCreateTopic(sessionId: string, create: () => Promise<unknown>, now?: () => number, name?: string, binding?: TopicEndpointBinding, commit?: () => Promise<void>, transientClaimant?: object): Promise<TopicRecord>;
166
+ getOrCreateTopic(sessionId: string, create: () => Promise<unknown>, now?: () => number, name?: string, binding?: TopicEndpointBinding, commit?: () => Promise<void>, transientClaimant?: object, topicOrigin?: TopicRecord["topicOrigin"]): Promise<TopicRecord>;
157
167
  /** Mark the identity header as sent for a session. Idempotent. */
158
168
  markIdentitySent(sessionId: string): void;
159
169
  /** Whether the identity header still needs sending for this session. */
@@ -1,3 +1,5 @@
1
+ /** Test seam: spill directories currently tracked for postmortem cleanup. */
2
+ export declare function trackedSpillDirectoriesForTest(): string[];
1
3
  export declare const MAX_REVISIONS_PER_RESOURCE = 8;
2
4
  export declare const MAX_PINNED_REVISIONS = 128;
3
5
  export declare const MAX_MEMORY_BYTES: number;
@@ -33,7 +33,7 @@ export declare class ReverseLeaseRuntime {
33
33
  heartbeat(connectionId: string, leaseId: string): ProviderLease;
34
34
  release(connectionId: string, leaseId: string, handoffTo?: string): ProviderLease;
35
35
  disconnect(connectionId: string): void;
36
- request(capability: string, method: string, payload: unknown): Promise<unknown>;
36
+ request(capability: string, method: string, payload: unknown, signal?: AbortSignal): Promise<unknown>;
37
37
  respond(connectionId: string, id: string, leaseId: string, result: unknown, error?: {
38
38
  code: string;
39
39
  message: string;
@@ -17,8 +17,10 @@
17
17
  * prior outcome unknown — callers MUST NOT reuse a clientRef as a retry
18
18
  * mechanism and MUST treat `unknown` as uncertainty, not proof of
19
19
  * non-execution.
20
- * - The durability floor is the live session process: after restart or
21
- * retained-record eviction, a lookup honestly reports `unknown`.
20
+ * - Prompt records survive process restart: an active prompt is finalized from its
21
+ * durable pending outcome, or as `prompt_failed` when it has none. Only skill
22
+ * records settle as `process_restart`, and a lookup reports `unknown` only after
23
+ * retained-record TTL/capacity eviction.
22
24
  * - Q26 tracks prompts accepted through the SDK control surface (which always
23
25
  * carries a requesting connection); submissions without a delivery owner are
24
26
  * outside the reconciliation contract and hold no reservation.
@@ -34,8 +36,24 @@ export interface TurnPromptInput {
34
36
  images?: TurnPromptImageInput[];
35
37
  clientRef?: string;
36
38
  }
37
- /** Terminal outcome is preserved exactly; active records never age into terminal. */
39
+ /**
40
+ * Terminal outcome is preserved exactly; active records never age into terminal. A
41
+ * prompt that is active at process restart is finalized from its durable pending
42
+ * outcome (or `prompt_failed` when it has none), so it never reports as unknown.
43
+ */
38
44
  export type PromptReconciliationStatus = "accepted" | "in_flight" | "terminal_ok" | "failed";
45
+ export type SdkPromptStopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
46
+ export type SdkPromptFailureCode = "prompt_failed" | "prompt_deadline_exceeded";
47
+ export type SdkPromptTerminalOutcome = {
48
+ kind: "stopped";
49
+ reason: SdkPromptStopReason;
50
+ provenance: "agent" | "client_cancel";
51
+ } | {
52
+ kind: "failed";
53
+ code: SdkPromptFailureCode;
54
+ message: string;
55
+ provenance: "agent_failed" | "deadline";
56
+ };
39
57
  /** Exactly one selector per lookup. */
40
58
  export type TurnPromptStatusSelector = {
41
59
  clientRef: string;
@@ -63,6 +81,7 @@ export interface TurnPromptReconciliationTerminalOk extends TurnPromptReconcilia
63
81
  startedAt?: number;
64
82
  /** Epoch milliseconds of the terminal transition. */
65
83
  terminalAt: number;
84
+ outcome?: SdkPromptTerminalOutcome;
66
85
  }
67
86
  export interface TurnPromptReconciliationFailed extends TurnPromptReconciliationIdentity {
68
87
  status: "failed";
@@ -73,6 +92,7 @@ export interface TurnPromptReconciliationFailed extends TurnPromptReconciliation
73
92
  code: string;
74
93
  message: string;
75
94
  };
95
+ outcome?: SdkPromptTerminalOutcome;
76
96
  }
77
97
  export interface TurnPromptReconciliationUnknown {
78
98
  status: "unknown";