@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
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Public DTO contract for Q26 `turn.prompt_status` and the `clientRef`
3
+ * correlation field on `turn.prompt`.
4
+ *
5
+ * Semantics:
6
+ * - `turn.prompt` remains ordered and non-idempotent. An envelope
7
+ * `idempotencyKey` is ignored for replay/conflict purposes on ordered
8
+ * operations (no replay cache, no `idempotency_conflict`).
9
+ * - `clientRef` is a caller-chosen correlation key (trimmed, non-empty,
10
+ * 1..PROMPT_CLIENT_REF_MAX_LENGTH chars; one fresh value per logical prompt)
11
+ * mapped to the generated commandId/turnId at preflight acceptance so a
12
+ * caller can reconcile after a lost acknowledgement frame.
13
+ * - The clientRef index is scoped to one live session runtime: identical refs
14
+ * may coexist in different sessions, lookups never cross sessions, a ref
15
+ * conflicts only while its record is retained (`client_ref_conflict`), and
16
+ * after terminal TTL/capacity eviction a ref may be admitted again with the
17
+ * prior outcome unknown — callers MUST NOT reuse a clientRef as a retry
18
+ * mechanism and MUST treat `unknown` as uncertainty, not proof of
19
+ * non-execution.
20
+ * - The durability floor is the live session process: after restart or
21
+ * retained-record eviction, a lookup honestly reports `unknown`.
22
+ * - Q26 tracks prompts accepted through the SDK control surface (which always
23
+ * carries a requesting connection); submissions without a delivery owner are
24
+ * outside the reconciliation contract and hold no reservation.
25
+ */
26
+ export declare const PROMPT_CLIENT_REF_MAX_LENGTH = 128;
27
+ export interface TurnPromptImageInput {
28
+ data: string;
29
+ mimeType?: string;
30
+ }
31
+ /** Public input contract for ordered `turn.prompt`. */
32
+ export interface TurnPromptInput {
33
+ text: string;
34
+ images?: TurnPromptImageInput[];
35
+ clientRef?: string;
36
+ }
37
+ /** Terminal outcome is preserved exactly; active records never age into terminal. */
38
+ export type PromptReconciliationStatus = "accepted" | "in_flight" | "terminal_ok" | "failed";
39
+ /** Exactly one selector per lookup. */
40
+ export type TurnPromptStatusSelector = {
41
+ clientRef: string;
42
+ } | {
43
+ commandId: string;
44
+ turnId: string;
45
+ };
46
+ interface TurnPromptReconciliationIdentity {
47
+ commandId: string;
48
+ turnId: string;
49
+ clientRef?: string;
50
+ /** Epoch milliseconds of preflight acceptance. */
51
+ acceptedAt: number;
52
+ }
53
+ export interface TurnPromptReconciliationAccepted extends TurnPromptReconciliationIdentity {
54
+ status: "accepted";
55
+ }
56
+ export interface TurnPromptReconciliationInFlight extends TurnPromptReconciliationIdentity {
57
+ status: "in_flight";
58
+ /** Epoch milliseconds of the agent_start transition. */
59
+ startedAt: number;
60
+ }
61
+ export interface TurnPromptReconciliationTerminalOk extends TurnPromptReconciliationIdentity {
62
+ status: "terminal_ok";
63
+ startedAt?: number;
64
+ /** Epoch milliseconds of the terminal transition. */
65
+ terminalAt: number;
66
+ }
67
+ export interface TurnPromptReconciliationFailed extends TurnPromptReconciliationIdentity {
68
+ status: "failed";
69
+ startedAt?: number;
70
+ terminalAt: number;
71
+ /** Bounded, sanitized failure detail (code safe-token ≤64, message ≤512). */
72
+ error: {
73
+ code: string;
74
+ message: string;
75
+ };
76
+ }
77
+ export interface TurnPromptReconciliationUnknown {
78
+ status: "unknown";
79
+ }
80
+ export type TurnPromptReconciliation = TurnPromptReconciliationAccepted | TurnPromptReconciliationInFlight | TurnPromptReconciliationTerminalOk | TurnPromptReconciliationFailed | TurnPromptReconciliationUnknown;
81
+ /** Result of a successful `turn.prompt` preflight acknowledgement. */
82
+ export interface TurnPromptAcceptedResult {
83
+ commandId: string;
84
+ turnId: string;
85
+ accepted: true;
86
+ clientRef?: string;
87
+ }
88
+ export {};
@@ -20,7 +20,7 @@ export type ResolveManagedSessionScopeResult = {
20
20
  scope: ManagedSessionScope;
21
21
  } | {
22
22
  kind: "error";
23
- code: "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid";
23
+ code: "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid" | "atomic_unavailable" | "durability_not_provable" | "durability_failed" | "invalid_request";
24
24
  message: string;
25
25
  };
26
26
  export interface LogicalSessionCandidate {
@@ -1,9 +1,12 @@
1
+ import { type ModelProfileErrorCode, type ModelProfileErrorDetails } from "../config/model-profile-contract";
1
2
  export type SdkStartupPhase = "registration" | "startup";
2
3
  export type SdkStartupReason = "disabled" | "ineligible" | "factory_absent" | "runner_absent" | "pending" | "failed";
3
4
  export interface SdkStartupFailure {
4
5
  phase: SdkStartupPhase;
5
6
  reason: SdkStartupReason;
6
7
  message: string;
8
+ code?: ModelProfileErrorCode;
9
+ details?: ModelProfileErrorDetails;
7
10
  }
8
11
  export type SdkStartupResult = {
9
12
  status: "started";
@@ -0,0 +1,9 @@
1
+ import type * as net from "node:net";
2
+ type AuthFailureCode = "auth_missing" | "auth_malformed" | "auth_invalid" | "auth_oversize" | "auth_timeout" | "unsupported_version";
3
+ export declare class AuthPrefaceError extends Error {
4
+ readonly code: AuthFailureCode;
5
+ constructor(code: AuthFailureCode);
6
+ }
7
+ /** Consumes the one-shot socket authentication preface and leaves later bytes readable. */
8
+ export declare function authenticatePreface(socket: net.Socket, token: string): Promise<Buffer>;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ export { DEFAULT_PENDING_CEILING_BYTES, MIN_PENDING_CEILING_BYTES, REQUEST_FRAME_BYTES, } from "./relay";
2
+ export { startSocketServe } from "./socket";
3
+ export { startStdioServe } from "./stdio";
4
+ export type ServeOptions = {
5
+ url: string;
6
+ token: string;
7
+ pendingCeilingBytes: number;
8
+ };
9
+ export type ServeHandle = {
10
+ close(): Promise<void>;
11
+ readonly done: Promise<void>;
12
+ };
@@ -0,0 +1,43 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+ export declare const REQUEST_FRAME_BYTES: number;
3
+ export declare const DEFAULT_PENDING_CEILING_BYTES: number;
4
+ export declare const MIN_PENDING_CEILING_BYTES: number;
5
+ export type RelayDirection = "downstream->ws" | "ws->downstream";
6
+ export type TransportError = {
7
+ type: "transport_error";
8
+ code: "frame_oversize" | "pending_overflow" | "protocol_error";
9
+ direction?: RelayDirection;
10
+ };
11
+ export type RelayPair = {
12
+ close(): Promise<void>;
13
+ readonly done: Promise<void>;
14
+ };
15
+ export declare class RelayOpenAbortedError extends Error {
16
+ constructor();
17
+ }
18
+ export type RelayWebSocketEvent = {
19
+ data?: unknown;
20
+ };
21
+ export type RelayWebSocket = {
22
+ readonly bufferedAmount: number;
23
+ readonly readyState: number;
24
+ close(): void;
25
+ send(data: string): void;
26
+ addEventListener(type: string, listener: (event: RelayWebSocketEvent) => void, options?: {
27
+ once?: boolean;
28
+ }): void;
29
+ removeEventListener(type: string, listener: (event: RelayWebSocketEvent) => void): void;
30
+ };
31
+ export type RelayOptions = {
32
+ url: string;
33
+ token: string;
34
+ pendingCeilingBytes: number;
35
+ downstream: Readable;
36
+ downstreamSink: Writable;
37
+ initialDownstreamBytes?: Buffer;
38
+ onTransportError: (error: TransportError) => void;
39
+ webSocketFactory?: (url: string) => RelayWebSocket;
40
+ signal?: AbortSignal;
41
+ };
42
+ /** Starts a dedicated raw-WebSocket relay for exactly one downstream stream. */
43
+ export declare function startRelayPair(options: RelayOptions): Promise<RelayPair>;
@@ -0,0 +1,4 @@
1
+ /** Resolves the pending ceiling with flag > env > default precedence; exported for tests. */
2
+ export declare function resolveServePendingCeiling(flagValue: string | undefined, envValue: string | undefined): number;
3
+ /** Attaches a stdio or Unix-socket relay to one live SDK session endpoint. */
4
+ export declare function runSdkServe(argv: string[]): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { ServeHandle, ServeOptions } from "./index";
2
+ import type { RelayOptions } from "./relay";
3
+ /** Serves authenticated SDK JSONL clients over a private Unix-domain socket. */
4
+ export declare function startSocketServe(options: ServeOptions & {
5
+ socketPath: string;
6
+ webSocketFactory?: RelayOptions["webSocketFactory"];
7
+ }): Promise<ServeHandle>;
@@ -0,0 +1,3 @@
1
+ import type { ServeHandle, ServeOptions } from "./index";
2
+ /** Serves one parent-owned JSONL connection over the process standard streams. */
3
+ export declare function startStdioServe(options: ServeOptions): Promise<ServeHandle>;
@@ -15,6 +15,7 @@
15
15
  import { type Agent, type AgentContext, type AgentEvent, type AgentLoopConfig, type AgentMessage, type AgentState, type AgentTool, type MidRunMaintenanceOutcome, type StablePrefixSnapshot, ThinkingLevel } from "@gajae-code/agent-core";
16
16
  import { type CompactionResult, type EmergencyCompactionSample } from "@gajae-code/agent-core/compaction";
17
17
  import type { AssistantMessage, Effort, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ServiceTier, SimpleStreamOptions, TextContent, ToolCall, ToolChoice, Usage, UsageReport } from "@gajae-code/ai";
18
+ import { type BtwTextExchange } from "./btw-contract";
18
19
  export interface ForkContextSeedMetadata {
19
20
  sourceSessionId: string;
20
21
  parentMessageCount: number;
@@ -392,8 +393,29 @@ interface EphemeralTurnBaseArgs {
392
393
  onTextDelta?: (delta: string) => void;
393
394
  signal?: AbortSignal;
394
395
  }
395
- export type EphemeralTurnArgs = (EphemeralTurnBaseArgs & {
396
+ export interface BtwRoleTextMessage {
397
+ role: "user" | "assistant";
398
+ text: string;
399
+ }
400
+ export interface BtwConversationScope {
401
+ model: Model;
402
+ systemPrompt: string[];
403
+ messages: BtwRoleTextMessage[];
404
+ thinkingLevel: ThinkingLevel;
405
+ hideThinkingSummary: boolean;
406
+ serviceTier: ServiceTier | undefined;
407
+ credentialSessionId: string;
408
+ providerAffinitySessionId: string;
409
+ sideSessionId: string;
410
+ }
411
+ export interface BtwTurnCapture {
412
+ question: string;
413
+ scope: BtwConversationScope | undefined;
414
+ }
415
+ export type EphemeralTurnArgs = (Omit<EphemeralTurnBaseArgs, "promptText"> & {
396
416
  purpose: "btw";
417
+ turn: BtwTurnCapture;
418
+ contextExchanges?: readonly BtwTextExchange[];
397
419
  }) | (EphemeralTurnBaseArgs & {
398
420
  purpose?: "background";
399
421
  /** Internal caller-supplied, non-persistent context such as the IRC roster. */
@@ -520,6 +542,8 @@ export declare class AgentSession {
520
542
  * recorded or the mode-state file is missing/unreadable; callers should
521
543
  * treat undefined as a non-terminal phase (refuses to chain). */
522
544
  getActiveSkillPhase(): string | undefined;
545
+ /** Provider-facing ask metadata must expose only the active deep-interview phase. */
546
+ getDeepInterviewAskStage(): "topology" | "post-topology" | undefined;
523
547
  /** Peek the in-flight directive's invocation handler for use by the resolve tool. */
524
548
  peekQueueInvoker(): ((input: unknown) => Promise<unknown> | unknown) | undefined;
525
549
  peekStandingResolveHandler(): ((input: unknown) => Promise<unknown> | unknown) | undefined;
@@ -1271,11 +1295,12 @@ export declare class AgentSession {
1271
1295
  timestamp?: number;
1272
1296
  }): void;
1273
1297
  emitSubagentSteerRelayObservation(record: CustomMessage): void;
1298
+ createBtwConversationScope(instruction: string): BtwConversationScope;
1274
1299
  /**
1275
- * Run a single ephemeral side-channel turn against this session's current
1276
- * model + system prompt + history. No tools are used and session history is
1277
- * not modified. Background turns retain the IRC/session behavior used by
1278
- * autoreplies; `/btw` turns use an isolated committed-context policy.
1300
+ * Run a single ephemeral side-channel turn without modifying session history.
1301
+ * Background turns retain IRC/session behavior. `/btw` turns require a
1302
+ * pre-frozen, visible-text-only scope and bypass extension context transforms,
1303
+ * provider observability hooks, and session persistence surfaces.
1279
1304
  */
1280
1305
  runEphemeralTurn(args: EphemeralTurnArgs): Promise<EphemeralTurnResult>;
1281
1306
  /**
@@ -0,0 +1,16 @@
1
+ export declare const BTW_MAX_CONTEXT_TURNS = 12;
2
+ export declare const BTW_MAX_CONTEXT_UTF8_BYTES: number;
3
+ export declare const BTW_MAX_QUESTION_UTF8_BYTES: number;
4
+ export declare const BTW_MAX_ANSWER_UTF8_BYTES: number;
5
+ export declare const BTW_MAX_ERROR_UTF8_BYTES: number;
6
+ export declare const BTW_STREAM_IDLE_TIMEOUT_MS = 30000;
7
+ export declare const BTW_STREAM_TOTAL_TIMEOUT_MS = 120000;
8
+ export interface BtwTextExchange {
9
+ question: string;
10
+ answer: string;
11
+ }
12
+ export declare function utf8ByteLength(text: string): number;
13
+ export declare function truncateUtf8(text: string, maxBytes: number): string;
14
+ export declare function sanitizeBtwError(text: string): string;
15
+ export declare function exchangeUtf8Bytes(exchange: BtwTextExchange): number;
16
+ export declare function boundBtwExchanges(exchanges: readonly BtwTextExchange[]): BtwTextExchange[];
@@ -1,5 +1,6 @@
1
1
  import * as native from "@gajae-code/natives";
2
2
  import type { ResumeSessionIdentity } from "../session-manager";
3
+ import { type ManagedDirectoryRoot, type ManagedSessionSecurityPolicy } from "./managed-session-storage";
3
4
  export declare const MANAGED_SESSION_LAYOUT_VERSION: 2;
4
5
  export declare const MANAGED_SESSION_IDENTITY_VERSION: 1;
5
6
  export declare const MANAGED_SESSION_BINDING_FILE = ".gjc-managed-session-scope.v2.json";
@@ -15,14 +16,24 @@ export interface ManagedScope {
15
16
  directoryPath: string;
16
17
  platform: "posix" | "win32";
17
18
  }
19
+ /**
20
+ * Opaque managed writer authority captured by a trusted destination. The open
21
+ * transaction must use this authority rather than reacquiring its root from a
22
+ * pathname after resume inspection.
23
+ */
24
+ export interface ManagedCandidateWriteAuthority {
25
+ readonly rootAuthority: ManagedDirectoryRoot;
26
+ readonly retainedAuthority?: native.RecoveryFsRoot;
27
+ readonly retainedDirectory?: string;
28
+ }
18
29
  export declare function managedDirectoryAuthorityForScope(scope: ManagedScope): native.RecoveryFsRoot | undefined;
19
30
  export declare function managedDirectoryIdentityForScope(scope: ManagedScope): {
20
31
  dev: bigint;
21
32
  ino: bigint;
22
33
  };
23
- export declare function managedRootForScope(scope: ManagedScope): import("./managed-session-storage").ManagedDirectoryRoot;
34
+ export declare function managedRootForScope(scope: ManagedScope): ManagedDirectoryRoot;
24
35
  export type ManagedMigrationPolicy = "copy-retain" | "disabled";
25
- export type ManagedScopeErrorCode = "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid";
36
+ export type ManagedScopeErrorCode = "cwd_missing" | "cwd_not_directory" | "identity_unavailable" | "network_unsupported" | "sessions_root_unavailable" | "binding_conflict" | "binding_invalid" | "atomic_unavailable" | "invalid_request" | "durability_failed" | "durability_not_provable";
26
37
  export type ManagedScopeResolution = {
27
38
  kind: "resolved";
28
39
  scope: ManagedScope;
@@ -30,6 +41,10 @@ export type ManagedScopeResolution = {
30
41
  kind: "error";
31
42
  code: ManagedScopeErrorCode;
32
43
  message: string;
44
+ cause?: {
45
+ readonly classification: string;
46
+ readonly diagnostic?: string;
47
+ };
33
48
  };
34
49
  export interface ManagedCandidate {
35
50
  sessionId: string;
@@ -52,7 +67,7 @@ export type ManagedCandidateListing = {
52
67
  code: "scan_failed" | "unsafe_root" | "invalid_candidate";
53
68
  message: string;
54
69
  };
55
- export type ManagedOpenFailure = "migration_busy" | "binding_conflict" | "binding_invalid" | "destination_conflict" | "source_changed" | "unsafe_artifacts" | "durability_failed" | "migration_retired" | "legacy_migration_disabled" | "managed_storage_unsupported";
70
+ export type ManagedOpenFailure = "migration_busy" | "binding_conflict" | "binding_invalid" | "destination_conflict" | "source_changed" | "unsafe_artifacts" | "durability_failed" | "atomic_unavailable" | "invalid_request" | "durability_not_provable" | "migration_retired" | "legacy_migration_disabled" | "managed_storage_unsupported";
56
71
  export type ManagedOpenCandidateResult = {
57
72
  kind: "opened";
58
73
  path: string;
@@ -69,6 +84,11 @@ export type ManagedDeleteCandidateResult = {
69
84
  } | {
70
85
  kind: "already_deleted";
71
86
  tombstonePath: string;
87
+ } | {
88
+ kind: "cleanup_pending";
89
+ tombstonePath: string;
90
+ phase: "artifacts" | "transcript";
91
+ message: string;
72
92
  } | {
73
93
  kind: "error";
74
94
  code: ManagedOpenFailure;
@@ -86,24 +106,27 @@ export declare const computeManagedScopeDigest: typeof scopeDigest;
86
106
  * attacker-plantable component below the root.
87
107
  */
88
108
  export declare function canonicalizeTrustedPath(target: string): string;
89
- export declare function resolveManagedScope(input: {
109
+ interface ManagedScopeInput {
90
110
  cwd: string;
91
111
  agentDir: string;
92
112
  sessionsRoot: string;
93
- }): ManagedScopeResolution;
94
- export declare function ensureManagedScope(scope: ManagedScope): Promise<ManagedScopeResolution>;
113
+ }
114
+ export declare function resolveManagedScope(input: ManagedScopeInput): ManagedScopeResolution;
115
+ /** Resolve a scope for a synchronous write without mutating an existing ACL mismatch. */
116
+ export declare function resolveManagedScopeForWrite(input: ManagedScopeInput): ManagedScopeResolution;
117
+ export declare function ensureManagedScope(scope: ManagedScope, policy?: ManagedSessionSecurityPolicy): Promise<ManagedScopeResolution>;
95
118
  /** Synchronously create and validate the v2 binding before a default session writer exists. */
96
- export declare function prepareManagedSessionScopeForWriteSync(scope: ManagedScope): ManagedScopeResolution;
119
+ export declare function prepareManagedSessionScopeForWriteSync(scope: ManagedScope, policy?: ManagedSessionSecurityPolicy, authority?: ManagedCandidateWriteAuthority): ManagedScopeResolution;
97
120
  export declare function listManagedCandidates(scope: ManagedScope): ManagedCandidateListing;
98
121
  /** Resume tombstoned cleanup under its original operation lease without restoring retired candidates. */
99
122
  export declare function reconcileManagedTombstones(scope: ManagedScope): Promise<void>;
100
123
  /** Create the v2 binding and private write protocol directories before managed writes. */
101
- export declare function prepareManagedSessionScopeForWrite(scope: ManagedScope): Promise<ManagedScopeResolution>;
124
+ export declare function prepareManagedSessionScopeForWrite(scope: ManagedScope, policy?: ManagedSessionSecurityPolicy, authority?: ManagedCandidateWriteAuthority, expectedCandidate?: ManagedCandidate, expectedIdentity?: ResumeSessionIdentity): Promise<ManagedScopeResolution>;
102
125
  /**
103
126
  * Open a validated candidate for mutation. Legacy transcripts are copied exactly once
104
127
  * into v2 and retained at their original location; no transcript data is merged.
105
128
  */
106
- export declare function openManagedCandidateForWrite(scope: ManagedScope, candidate: ManagedCandidate, migrationPolicy?: ManagedMigrationPolicy): Promise<ManagedOpenCandidateResult>;
129
+ export declare function openManagedCandidateForWrite(scope: ManagedScope, candidate: ManagedCandidate, expectedIdentityOrMigrationPolicy?: ResumeSessionIdentity | ManagedMigrationPolicy, migrationPolicy?: ManagedMigrationPolicy, authority?: ManagedCandidateWriteAuthority): Promise<ManagedOpenCandidateResult>;
107
130
  /** Tombstone a verified managed candidate before exact-identity deletion. */
108
131
  export declare function deleteManagedSessionCandidate(scope: ManagedScope, candidate: ManagedCandidate): Promise<ManagedDeleteCandidateResult>;
109
132
  export {};
@@ -1,9 +1,18 @@
1
1
  import { type NativeDirectoryTreeSnapshot, type NativeOwnerOnlySecurityResult, type RecoveryFsRoot } from "@gajae-code/natives";
2
+ import { type NativePublishOutcome } from "./native-publish-outcome";
2
3
  export declare const MANAGED_ARTIFACT_MAX_DEPTH = 32;
3
4
  export declare const MANAGED_ARTIFACT_MAX_FILES = 10000;
4
5
  export declare const MANAGED_ARTIFACT_MAX_FILE_BYTES: number;
5
6
  export declare const MANAGED_ARTIFACT_MAX_TOTAL_BYTES: number;
6
- export type ManagedStorageFailure = "migration_busy" | "binding_conflict" | "binding_invalid" | "destination_conflict" | "source_changed" | "unsafe_artifacts" | "durability_failed" | "migration_retired" | "managed_storage_unsupported";
7
+ export declare class ManagedPublishError extends Error {
8
+ readonly classification: "destination_conflict" | "atomic_unavailable" | "invalid_request" | "durability_not_provable" | "identity_mismatch" | "io_error" | "durability_failed";
9
+ readonly diagnostic: string;
10
+ constructor(classification: ManagedPublishError["classification"], outcome: NativePublishOutcome);
11
+ }
12
+ /** Cleanup is safe only when the native move reports that it did not commit. */
13
+ export declare function mayCleanManagedTreeStaging(error: unknown): boolean;
14
+ export type ManagedSessionSecurityPolicy = "default" | "windows-existing-verify-first";
15
+ export type ManagedStorageFailure = "migration_busy" | "binding_conflict" | "binding_invalid" | "destination_conflict" | "source_changed" | "unsafe_artifacts" | "durability_failed" | "atomic_unavailable" | "durability_not_provable" | "migration_retired" | "managed_storage_unsupported";
7
16
  export interface ManagedStorageLock {
8
17
  path: string;
9
18
  attemptId: string;
@@ -28,6 +37,13 @@ export interface ManagedDirectoryRoot {
28
37
  readonly dev: bigint;
29
38
  readonly ino: bigint;
30
39
  }
40
+ /**
41
+ * Establish the first managed directory beneath a potentially shared ancestor.
42
+ * The ancestor is used only to create the managed chain; every component from
43
+ * `configuredRoot` downward is independently type, symlink, owner, mode, and
44
+ * ACL checked. This deliberately does not impose owner-only policy on `/tmp`.
45
+ */
46
+ export declare function prepareManagedDirectoryRoot(configuredRoot: string, policy?: ManagedSessionSecurityPolicy): ManagedDirectoryRoot;
31
47
  export declare function managedDirectoryRoot(configuredRoot: string): ManagedDirectoryRoot;
32
48
  export declare function retainManagedDirectoryAuthority(root: ManagedDirectoryRoot, directory: string, expected?: {
33
49
  dev: bigint;
@@ -40,10 +56,11 @@ export declare class ManagedSessionDescendantStore {
40
56
  constructor(root: ManagedDirectoryRoot, baseDir: string, retained?: {
41
57
  authority: RecoveryFsRoot;
42
58
  authorityBaseDir: string;
43
- });
59
+ }, policy?: ManagedSessionSecurityPolicy);
44
60
  get dir(): string;
45
61
  get rootAuthority(): ManagedDirectoryRoot;
46
62
  get subtreeRootAuthority(): ManagedDirectoryRoot;
63
+ get securityPolicy(): ManagedSessionSecurityPolicy;
47
64
  deriveSubtree(relativePath: string): ManagedSessionDescendantStore;
48
65
  retainAuthority(): RecoveryFsRoot | undefined;
49
66
  assertBound(): void;
@@ -66,27 +83,27 @@ export declare class ManagedSessionDescendantStore {
66
83
  captureTree(relativePath: string): NativeDirectoryTreeSnapshot;
67
84
  /** Copy an exact captured tree into an absent managed destination. */
68
85
  importTree(sourceRelativePath: string, destinationRelativePath: string, snapshot: NativeDirectoryTreeSnapshot): Promise<void>;
69
- moveTreeNoReplace(sourceRelativePath: string, destinationRelativePath: string, expected: NativeDirectoryTreeSnapshot): void;
86
+ moveTreeNoReplace(sourceRelativePath: string, destinationRelativePath: string, expected: NativeDirectoryTreeSnapshot): NativeDirectoryTreeSnapshot;
70
87
  removeTreeExpected(relativePath: string, expected: NativeDirectoryTreeSnapshot): void;
71
88
  fsyncTree(): NativeDirectoryTreeSnapshot;
72
89
  }
73
90
  export declare function shouldFsyncManagedDirectory(platform?: NodeJS.Platform): boolean;
74
91
  /** Create a managed directory and fail closed unless its owner-only mode/ACL verifies. */
75
- export declare function ensureManagedDirectory(pathname: string, root?: ManagedDirectoryRoot): void;
92
+ export declare function ensureManagedDirectory(pathname: string, root?: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): void;
76
93
  /** Captures a bounded prefix from one no-follow descriptor and rechecks the pathname before use. */
77
94
  export declare function captureManagedFilePrefixNoFollow(pathname: string, maxBytes: number): ManagedFileSnapshot;
78
95
  /** Captures header/hash/copy input from one no-follow descriptor and rechecks the pathname before use. */
79
96
  export declare function captureManagedFileNoFollow(pathname: string): ManagedFileSnapshot;
80
97
  /** Atomically publishes bytes without replacing an existing destination. */
81
- export declare function publishManagedFileNoReplace(destination: string, bytes: Uint8Array, assertOwned?: () => void, root?: ManagedDirectoryRoot): Promise<void>;
82
- export declare function publishManagedFileNoReplaceSync(destination: string, bytes: Uint8Array, root?: ManagedDirectoryRoot): void;
98
+ export declare function publishManagedFileNoReplace(destination: string, bytes: Uint8Array, assertOwned?: () => void, root?: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): Promise<void>;
99
+ export declare function publishManagedFileNoReplaceSync(destination: string, bytes: Uint8Array, root?: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): void;
83
100
  /** Replace one managed regular file while retaining the secured staging fd through publication. */
84
- export declare function replaceManagedFileSync(destination: string, bytes: Uint8Array, root: ManagedDirectoryRoot): void;
85
- export declare function replaceManagedFile(destination: string, bytes: Uint8Array, root: ManagedDirectoryRoot): Promise<void>;
101
+ export declare function replaceManagedFileSync(destination: string, bytes: Uint8Array, root: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): void;
102
+ export declare function replaceManagedFile(destination: string, bytes: Uint8Array, root: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): Promise<void>;
86
103
  /** Copy the exact bytes captured from one no-follow source descriptor. */
87
- export declare function copyManagedFileNoReplace(source: string, destination: string, snapshot?: ManagedFileSnapshot, root?: ManagedDirectoryRoot): Promise<void>;
104
+ export declare function copyManagedFileNoReplace(source: string, destination: string, snapshot?: ManagedFileSnapshot, root?: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): Promise<void>;
88
105
  /** Acquire a lease lock with bounded wait, heartbeats, conservative stale reclaim, and fencing. */
89
- export declare function acquireManagedLock(locksDirectory: string, name: string, root?: ManagedDirectoryRoot): Promise<ManagedStorageLock>;
106
+ export declare function acquireManagedLock(locksDirectory: string, name: string, root?: ManagedDirectoryRoot, policy?: ManagedSessionSecurityPolicy): Promise<ManagedStorageLock>;
90
107
  /** Bounds a no-follow artifact tree before it can be copied or deleted. */
91
108
  export declare function validateManagedArtifactTree(root: string): void;
92
109
  /** Flush a copied managed artifact tree, including empty directories, before publishing its receipt. */
@@ -0,0 +1,48 @@
1
+ export type NativePublishMutationState = "not_committed" | "committed" | "unknown";
2
+ export type NativePublishDurabilityState = "not_attempted" | "proven" | "not_provable";
3
+ export type NativePublishReason = "none" | "destination_exists" | "atomic_unavailable" | "cross_device" | "permission_denied" | "io_failure" | "interrupted" | "invalid_request" | "identity_violation" | "durability_not_provable" | "unknown";
4
+ export type NativePublishOperation = "direct_rename" | "retained_file" | "retained_tree";
5
+ export type NativePublishPrimitive = "renameat2_noreplace" | "renameatx_np_excl" | "windows_rename_noreplace" | "unsupported" | "unknown";
6
+ export type NativePublishPhase = "preflight" | "file_sync" | "rename" | "source_parent_sync" | "destination_parent_sync" | "terminal_identity" | "complete" | "unknown";
7
+ type SyncFailure = {
8
+ phase: Exclude<NativePublishPhase, "preflight" | "file_sync" | "rename" | "complete" | "unknown">;
9
+ parentRole: "source" | "destination" | "shared" | "staged_file";
10
+ osCode?: number;
11
+ kind: "unsupported" | "io" | "permission" | "other";
12
+ };
13
+ type PublishDiagnostic = {
14
+ schemaVersion: 1;
15
+ collectionState: "complete" | "partial" | "unavailable";
16
+ osCode?: number;
17
+ syncFailures?: readonly SyncFailure[];
18
+ };
19
+ export type NativePublishIdentity = {
20
+ readonly dev: string;
21
+ readonly ino: string;
22
+ readonly size: string;
23
+ readonly mtimeNs: string;
24
+ readonly ctimeNs: string;
25
+ readonly sha256?: string;
26
+ };
27
+ export type NativePublishOutcome = {
28
+ readonly ok: boolean;
29
+ readonly code?: string;
30
+ readonly identity?: NativePublishIdentity;
31
+ readonly mutationState: NativePublishMutationState;
32
+ readonly durabilityState: NativePublishDurabilityState;
33
+ readonly reason: NativePublishReason;
34
+ readonly primitive: NativePublishPrimitive;
35
+ readonly phase: NativePublishPhase;
36
+ readonly diagnostic: PublishDiagnostic;
37
+ };
38
+ /**
39
+ * Treat incompatible native results as an unknown mutation; never infer safety from legacy fields.
40
+ * Retained descriptor operations have a stricter contract than direct rename: a reported success
41
+ * includes the terminal identity and all required durability evidence.
42
+ */
43
+ export declare function classifyNativePublishOutcome(value: unknown, operation?: NativePublishOperation): NativePublishOutcome;
44
+ /** Only a fully validated pre-mutation result permits exact cleanup of current staging. */
45
+ export declare function mayCleanCurrentStaging(outcome: NativePublishOutcome): boolean;
46
+ /** Stable, bounded text for startup errors. Native paths and messages are intentionally excluded. */
47
+ export declare function formatNativePublishDiagnostic(outcome: NativePublishOutcome): string;
48
+ export {};
@@ -553,7 +553,7 @@ export interface ResolvedSessionMatch {
553
553
  session: SessionInfo;
554
554
  scope: "local" | "global";
555
555
  }
556
- export declare function resolveResumableSession(sessionArg: string, cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<ResolvedSessionMatch | undefined>;
556
+ export declare function resolveResumableSession(sessionArg: string, cwd: string, sessionDir?: string, storage?: SessionStorage, managedAgentDir?: string): Promise<ResolvedSessionMatch | undefined>;
557
557
  interface SessionManagerStateSnapshot {
558
558
  sessionId: string;
559
559
  sessionName: string | undefined;
@@ -649,6 +649,8 @@ export declare class SessionManager {
649
649
  /** Get usage statistics across all assistant messages in the session. */
650
650
  getUsageStatistics(): UsageStatistics;
651
651
  getSessionDir(): string;
652
+ /** Lists picker candidates within this manager's captured destination authority. */
653
+ listForResumePickerReadOnly(): Promise<SessionInfo[]>;
652
654
  getSessionId(): string;
653
655
  getSessionFile(): string | undefined;
654
656
  /**
@@ -901,8 +903,12 @@ export declare class SessionManager {
901
903
  static managedDestination(cwd: string, agentDir?: string, storage?: SessionStorage): SessionDestination;
902
904
  static explicitDestination(directory: string): SessionDestination;
903
905
  static create(cwd: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage): SessionManager;
906
+ /** Prepare a selected candidate using this manager's captured managed destination authority. */
907
+ prepareManagedCandidateForWrite(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy, expectedIdentity?: ResumeSessionIdentity): Promise<string>;
908
+ /** Prepare a managed candidate and retain its exact post-preparation identity for the next adoption. */
909
+ prepareManagedCandidateForStrictAdoption(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy, expectedIdentity: ResumeSessionIdentity): Promise<string>;
904
910
  /** Resolve a default-managed candidate through binding validation and copy-retain migration before mutation. */
905
- static prepareManagedCandidateForWrite(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy): Promise<string>;
911
+ static prepareManagedCandidateForWrite(filePath: string, migrationPolicy: SessionDirectoryMigrationPolicy, destination: SessionDestination, expectedIdentity?: ResumeSessionIdentity): Promise<string>;
906
912
  /**
907
913
  * Fork a session into the current project directory.
908
914
  * Copies history from another session file while creating a new session file in the current sessionDir.
@@ -916,7 +922,15 @@ export declare class SessionManager {
916
922
  static open(filePath: string, destinationInput?: SessionDestinationInput, storage?: SessionStorage, migrationPolicy?: SessionDirectoryMigrationPolicy): Promise<SessionManager>;
917
923
  static openNestedManaged(filePath: string, destination: SessionDestination, store: ManagedSessionDescendantStore, storage?: SessionStorage): Promise<SessionManager>;
918
924
  /**
919
- * List sessions for the resume picker without recovery or other maintenance writes.
925
+ * List default-managed sessions for the resume picker without recovery or other
926
+ * maintenance writes. This is the only picker inventory that includes legacy
927
+ * sibling directories.
928
+ */
929
+ static listManagedForResumePickerReadOnly(cwd: string, managedAgentDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
930
+ /**
931
+ * List sessions from an explicitly supplied picker directory without recovery
932
+ * or other maintenance writes. Unlike managed inventory, this never scans
933
+ * legacy sibling directories.
920
934
  */
921
935
  static listForResumePickerReadOnly(cwd: string, sessionDir?: string, storage?: SessionStorage): Promise<SessionInfo[]>;
922
936
  /** Tombstone and exact-delete a default-managed candidate. */
@@ -966,7 +980,13 @@ export declare class SessionManager {
966
980
  /**
967
981
  * List all sessions across all project directories.
968
982
  */
969
- static listAll(storage?: SessionStorage): Promise<SessionInfo[]>;
983
+ static listAll(storage?: SessionStorage, managedAgentDir?: string): Promise<SessionInfo[]>;
984
+ /**
985
+ * Strict inventory bound to this manager's captured session authority. Managed
986
+ * managers include authorized legacy and current candidates; explicit managers
987
+ * authorize only their exact directory.
988
+ */
989
+ inventorySessionsStrict(): StrictInventoryResult;
970
990
  /**
971
991
  * Strict raw scoped inventory for ACP authorization. Enumerates the scoped
972
992
  * session directory without suppressing any root/scan/lstat/read/parse/stat/
@@ -977,6 +997,7 @@ export declare class SessionManager {
977
997
  static inventorySessionsStrict(cwd: string, options?: {
978
998
  sessionDir?: string;
979
999
  storage?: SessionStorage;
1000
+ destination?: SessionDestination;
980
1001
  }): StrictInventoryResult;
981
1002
  /**
982
1003
  * Propagate the storage-layer verified hard delete bound to exact identity evidence.
@@ -184,6 +184,18 @@ export interface VerifiedSessionDeleteTarget {
184
184
  detachedArtifactsPath?: string;
185
185
  /** Identity-bound quarantine path retained when transcript unlink deferred cleanup. */
186
186
  detachedTranscriptPath?: string;
187
+ /** Native-retained publisher successor observed during transcript cleanup. */
188
+ retainedTranscriptSuccessorPath?: string;
189
+ /** Native-retained exchange placeholder observed during transcript cleanup. */
190
+ retainedTranscriptPlaceholderPath?: string;
191
+ /** Native-retained transcript entry whose identity could not be verified. */
192
+ retainedTranscriptUnknownPath?: string;
193
+ /** Native-retained publisher successor observed during cleanup. */
194
+ retainedArtifactsSuccessorPath?: string;
195
+ /** Native-retained exchange placeholder observed during cleanup. */
196
+ retainedArtifactsPlaceholderPath?: string;
197
+ /** Native-retained entry whose identity could not be verified. */
198
+ retainedArtifactsUnknownPath?: string;
187
199
  /** Caller-published, no-replace quarantine pathname for the next artifact detach. */
188
200
  plannedArtifactsPath?: string;
189
201
  /** Caller-published, no-replace quarantine pathname for the next transcript detach. */
@@ -215,6 +227,9 @@ export type VerifiedSessionDeleteResult = {
215
227
  artifactsTree: NativeDirectoryTreeSnapshot;
216
228
  /** Transcript identity (unchanged) for retry binding. */
217
229
  transcriptIdentity: SessionStorageFileIdentity;
230
+ retainedSuccessorPath?: string;
231
+ retainedPlaceholderPath?: string;
232
+ retainedUnknownPath?: string;
218
233
  } | {
219
234
  kind: "cleanup_pending";
220
235
  phase: "transcript";
@@ -223,6 +238,9 @@ export type VerifiedSessionDeleteResult = {
223
238
  transcriptIdentity: SessionStorageFileIdentity;
224
239
  /** Optional identity-bound transcript quarantine path for restart cleanup. */
225
240
  detachedTranscriptPath?: string;
241
+ retainedSuccessorPath?: string;
242
+ retainedPlaceholderPath?: string;
243
+ retainedUnknownPath?: string;
226
244
  };
227
245
  type NativeDirectoryTreeEntry = {
228
246
  relativePath: string;