@bastani/atomic 0.9.84 → 0.9.85-alpha.1

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 (183) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/broker.ts +25 -7
  4. package/dist/builtin/intercom/broker/spawn.ts +83 -17
  5. package/dist/builtin/intercom/index.bundle.mjs +89 -26
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/web-access/package.json +1 -1
  10. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  11. package/dist/builtin/workflows/package.json +1 -1
  12. package/dist/builtin/workflows/src/authoring.d.ts +1 -1
  13. package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
  14. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
  15. package/dist/builtin/workflows/src/index.js +48 -9
  16. package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
  17. package/dist/config.d.ts +3 -2
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +4 -3
  20. package/dist/config.js.map +1 -1
  21. package/dist/core/agent-session-export.d.ts +2 -2
  22. package/dist/core/agent-session-export.d.ts.map +1 -1
  23. package/dist/core/agent-session-export.js +4 -5
  24. package/dist/core/agent-session-export.js.map +1 -1
  25. package/dist/core/agent-session-services.js +1 -1
  26. package/dist/core/agent-session-services.js.map +1 -1
  27. package/dist/core/agent-session-summary.d.ts.map +1 -1
  28. package/dist/core/agent-session-summary.js +8 -1
  29. package/dist/core/agent-session-summary.js.map +1 -1
  30. package/dist/core/agent-session-tree.d.ts.map +1 -1
  31. package/dist/core/agent-session-tree.js +3 -6
  32. package/dist/core/agent-session-tree.js.map +1 -1
  33. package/dist/core/builtin-resource-loader.d.ts.map +1 -1
  34. package/dist/core/builtin-resource-loader.js +1 -1
  35. package/dist/core/builtin-resource-loader.js.map +1 -1
  36. package/dist/core/extensions/loader-core.d.ts +6 -2
  37. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  38. package/dist/core/extensions/loader-core.js +13 -9
  39. package/dist/core/extensions/loader-core.js.map +1 -1
  40. package/dist/core/extensions/loader-discovery.js +1 -1
  41. package/dist/core/extensions/loader-discovery.js.map +1 -1
  42. package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
  43. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  44. package/dist/core/extensions/loader-virtual-modules.js +133 -78
  45. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  46. package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
  47. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
  48. package/dist/core/extensions/ts-source-specifiers.js +18 -2
  49. package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
  50. package/dist/core/mandatory-resource-loader.d.ts +5 -2
  51. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  52. package/dist/core/mandatory-resource-loader.js +17 -12
  53. package/dist/core/mandatory-resource-loader.js.map +1 -1
  54. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  55. package/dist/core/model-fallback-failures.js +10 -3
  56. package/dist/core/model-fallback-failures.js.map +1 -1
  57. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  58. package/dist/core/resource-loader-extensions.js +1 -1
  59. package/dist/core/resource-loader-extensions.js.map +1 -1
  60. package/dist/core/resource-loader-reload.js +1 -1
  61. package/dist/core/resource-loader-reload.js.map +1 -1
  62. package/dist/core/resume/blueprint/resume.d.ts +4 -4
  63. package/dist/core/resume/blueprint/resume.js +4 -4
  64. package/dist/core/resume/blueprint/resume.js.map +1 -1
  65. package/dist/core/resume/session-resume.d.ts +6 -3
  66. package/dist/core/resume/session-resume.d.ts.map +1 -1
  67. package/dist/core/resume/session-resume.js +159 -37
  68. package/dist/core/resume/session-resume.js.map +1 -1
  69. package/dist/core/sdk.js +1 -1
  70. package/dist/core/sdk.js.map +1 -1
  71. package/dist/core/session-manager-core.d.ts +10 -4
  72. package/dist/core/session-manager-core.d.ts.map +1 -1
  73. package/dist/core/session-manager-core.js +23 -6
  74. package/dist/core/session-manager-core.js.map +1 -1
  75. package/dist/core/session-manager-entries.d.ts +2 -2
  76. package/dist/core/session-manager-entries.d.ts.map +1 -1
  77. package/dist/core/session-manager-entries.js +2 -1
  78. package/dist/core/session-manager-entries.js.map +1 -1
  79. package/dist/core/session-manager-history.d.ts +13 -1
  80. package/dist/core/session-manager-history.d.ts.map +1 -1
  81. package/dist/core/session-manager-history.js +21 -1
  82. package/dist/core/session-manager-history.js.map +1 -1
  83. package/dist/core/session-manager-types.d.ts +3 -1
  84. package/dist/core/session-manager-types.d.ts.map +1 -1
  85. package/dist/core/session-manager-types.js.map +1 -1
  86. package/dist/core/session-manager.d.ts +1 -1
  87. package/dist/core/session-manager.d.ts.map +1 -1
  88. package/dist/core/session-manager.js +1 -1
  89. package/dist/core/session-manager.js.map +1 -1
  90. package/dist/core/session-worktree-snapshots.d.ts +61 -4
  91. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  92. package/dist/core/session-worktree-snapshots.js +261 -28
  93. package/dist/core/session-worktree-snapshots.js.map +1 -1
  94. package/dist/core/storage/session/entry-structure.js +31 -1
  95. package/dist/core/storage/session/entry-structure.js.map +1 -1
  96. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  97. package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
  98. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  99. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  100. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
  101. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  102. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
  103. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
  104. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
  105. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
  106. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  107. package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
  108. package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
  109. package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
  110. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  111. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  112. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
  113. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  114. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
  115. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  116. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
  117. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  118. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
  119. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
  120. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
  121. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  122. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
  123. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  124. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
  125. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  126. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  127. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
  128. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  129. package/dist/core/tools/read.d.ts +1 -0
  130. package/dist/core/tools/read.d.ts.map +1 -1
  131. package/dist/core/tools/read.js +13 -14
  132. package/dist/core/tools/read.js.map +1 -1
  133. package/dist/core/worktree-snapshot/index.d.ts +2 -2
  134. package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
  135. package/dist/core/worktree-snapshot/index.js +1 -1
  136. package/dist/core/worktree-snapshot/index.js.map +1 -1
  137. package/dist/core/worktree-snapshot/records.d.ts +6 -0
  138. package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
  139. package/dist/core/worktree-snapshot/records.js +18 -4
  140. package/dist/core/worktree-snapshot/records.js.map +1 -1
  141. package/dist/core/worktree-snapshot/restore.d.ts +24 -1
  142. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  143. package/dist/core/worktree-snapshot/restore.js +443 -72
  144. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  145. package/dist/core/worktree-snapshot/types.d.ts +44 -0
  146. package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
  147. package/dist/core/worktree-snapshot/types.js.map +1 -1
  148. package/dist/index.d.ts +2 -2
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +2 -2
  151. package/dist/index.js.map +1 -1
  152. package/dist/modes/interactive/components/tool-execution.js +2 -1
  153. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  154. package/dist/modes/interactive/interactive-slash-commands.js +4 -1
  155. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  156. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  157. package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
  158. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  159. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  160. package/dist/modes/rpc/rpc-command-handler.js +11 -2
  161. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  162. package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
  163. package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
  164. package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
  165. package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
  166. package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
  167. package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
  168. package/dist/modes/rpc/rpc-types.d.ts +11 -1
  169. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  170. package/dist/modes/rpc/rpc-types.js.map +1 -1
  171. package/docs/environment-variables.md +1 -1
  172. package/docs/guides/resume-on-any-machine.md +6 -4
  173. package/docs/intercom/operations.md +4 -0
  174. package/docs/rpc/protocol.md +2 -2
  175. package/docs/sdk/reference.md +3 -0
  176. package/docs/sdk.md +2 -2
  177. package/docs/session-format.md +11 -2
  178. package/docs/sessions.md +4 -2
  179. package/docs/settings.md +1 -1
  180. package/docs/workflows/api-reference.md +2 -2
  181. package/docs/worktree-snapshots.md +13 -5
  182. package/npm-shrinkwrap.json +32 -32
  183. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * RPC protocol types for headless operation.\n *\n * Commands are sent as JSON lines on stdin.\n * Responses and events are emitted as JSON lines on stdout.\n */\n\nimport type {\n\tAuthInfoLink,\n\tCredential,\n\tOAuthAuthInfo,\n\tOAuthDeviceCodeInfo,\n\tOAuthPrompt,\n\tOAuthSelectPrompt,\n} from \"@bastani/pi-ai\";\nimport type { Api, ImageContent, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type {\n\tClearedQueue,\n\tCompactionReason,\n\tPromptDisposition,\n\tQueuedInputDisposition,\n\tSessionRecoveryReport,\n\tSessionStats,\n} from \"../../core/agent-session.js\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { SerializedBackgroundCompactionState } from \"../../core/compaction/background-compaction.ts\";\nimport type { SerializedBackgroundCompactionError } from \"../../core/compaction/background-compaction-errors.ts\";\nimport type { VerbatimCompactionResult } from \"../../core/compaction/index.ts\";\nimport type { SerializedDebugError } from \"../../core/debug-errors.ts\";\nimport type { ResourceOverlap } from \"../../core/diagnostics.ts\";\nimport type { SessionRecoveryReason } from \"../../core/extensions/index.js\";\nimport type {\n\tWorkflowRunDetail,\n\tWorkflowRunFilterStatus,\n\tWorkflowRunSummary,\n} from \"../../core/extensions/workflow-run-control.js\";\nimport type { ModelFallbackReason } from \"../../core/model-resolver-types.ts\";\nimport type { CredentialSynchronizationOperation } from \"../../core/model-runtime.js\";\nimport type { OAuthProviderMetadata } from \"../../core/oauth-login.ts\";\nimport type { AuthStatus } from \"../../core/provider-composer.ts\";\nimport type { SerializedMissingSessionCwdError } from \"../../core/session-cwd.ts\";\nimport type { SessionEntry, SessionInfo, SessionSummaryEntry, SessionTreeNode } from \"../../core/session-manager.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\nimport type { ToolStatusReport } from \"../../core/tool-status.js\";\nimport type { QuestionAnswer, QuestionParams } from \"../../core/tools/ask-user-question/tool/types.js\";\nimport type { JsonAgentSessionEvent } from \"../json-event.ts\";\n\n// ============================================================================\n// RPC Commands (stdin)\n// ============================================================================\n\n/** A line a resume shows the user, carried from the engine that prepared the resume to the host that renders it. */\nexport interface RpcResumeNotice {\n\treadonly type: \"info\" | \"warning\";\n\treadonly message: string;\n}\n\nexport interface RpcModelCatalog {\n\tmodels: Model<Api>[];\n\tscopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Extension-registered providers that offer API-key login (`login_provider`). */\n\tcustomAuthProviders: Array<{ id: string; name: string }>;\n\toauthProviders?: OAuthProviderMetadata[];\n\t/** Auth status of extension-registered providers that is not a stored credential (environment, configured key, runtime key). */\n\tproviderAuthStatuses?: Array<{ provider: string; status: AuthStatus }>;\n}\n\nexport interface RpcModelRefreshResult extends RpcModelCatalog {\n\taborted: boolean;\n\terrors: Array<{ provider: string; message: string }>;\n}\n/**\n * The host supplied the API key through the login input form, so echoing it\n * back over the stdout pipe would make this response a second credential\n * egress. Only the metadata a caller needs to confirm the login travels.\n */\nexport type RpcLoginProviderResult =\n\t| (RpcModelCatalog & {\n\t\t\tprovider: string;\n\t\t\tcancelled: false;\n\t\t\ttype: \"api_key\";\n\t })\n\t| { provider: string; cancelled: true };\n\nexport type RpcOAuthLoginProviderResult =\n\t| (RpcModelCatalog & { provider: string; cancelled: false })\n\t| { provider: string; cancelled: true };\n\nexport type RpcSessionInfo = Omit<SessionInfo, \"created\" | \"modified\"> & {\n\tcreated: string;\n\tmodified: string;\n};\n\nexport type RpcCommand =\n\t// Prompting\n\t| { id?: string; type: \"prompt\"; message: string; images?: ImageContent[]; streamingBehavior?: \"steer\" | \"followUp\" }\n\t| { id?: string; type: \"steer\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"follow_up\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"abort\" }\n\t| { id?: string; type: \"new_session\"; parentSession?: string }\n\t| { id?: string; type: \"delete_session\"; sessionId?: string }\n\n\t// State\n\t| { id?: string; type: \"get_state\" }\n\t| { id?: string; type: \"get_session_summary\" }\n\t| { id?: string; type: \"list_sessions\" }\n\t| { id?: string; type: \"list_workflow_runs\"; status?: WorkflowRunFilterStatus }\n\t| { id?: string; type: \"get_workflow_run_summary\"; runId: string }\n\t| { id?: string; type: \"open_task_inspector\"; taskId?: string }\n\n\t// Model\n\t| { id?: string; type: \"set_model\"; provider: string; modelId: string; persist?: boolean }\n\t| { id?: string; type: \"cycle_model\"; direction?: \"forward\" | \"backward\"; persist?: boolean }\n\t| { id?: string; type: \"get_available_models\"; allowPartialResources?: boolean }\n\t| { id?: string; type: \"login_provider\"; provider: string; authType?: \"api_key\" | \"oauth\"; loginId?: string }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"save_provider_credential\";\n\t\t\tprovider: string;\n\t\t\tcredential: Credential;\n\t\t\t/** Fetch the remote catalog before publishing the credential. Defaults to true. */\n\t\t\trefreshCatalog?: boolean;\n\t }\n\t| { id?: string; type: \"cancel_login_provider\"; provider: string; loginId?: string }\n\t| { id?: string; type: \"logout_provider\"; provider: string }\n\t| { id?: string; type: \"refresh_models\"; timeoutMs?: number; force?: boolean; allowNetwork?: boolean }\n\n\t// Thinking\n\t| { id?: string; type: \"set_thinking_level\"; level: ThinkingLevel; persist?: boolean }\n\t| { id?: string; type: \"cycle_thinking_level\" }\n\t| { id?: string; type: \"get_available_thinking_levels\" }\n\n\t// Queue modes\n\t| { id?: string; type: \"set_steering_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\t| { id?: string; type: \"set_follow_up_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\n\t// Compaction\n\t| { id?: string; type: \"compact\" }\n\t| { id?: string; type: \"set_auto_compaction\"; enabled: boolean }\n\t| { id?: string; type: \"set_background_compaction\"; enabled: boolean }\n\t| { id?: string; type: \"set_background_compaction_threshold\"; percent: number }\n\t| { id?: string; type: \"abort_compaction\" }\n\n\t// Extension UI\n\t| { id?: string; type: \"set_extension_ui_capabilities\"; questionnaire?: boolean }\n\n\t// Debug\n\t| { id?: string; type: \"set_debug\"; enabled: boolean }\n\n\t// Retry\n\t| { id?: string; type: \"set_auto_retry\"; enabled: boolean }\n\t| { id?: string; type: \"abort_retry\" }\n\t| { id?: string; type: \"clear_queue\" }\n\t| { id?: string; type: \"pause_queued_messages\" }\n\t| { id?: string; type: \"resume_queued_messages\" }\n\n\t// Bash\n\t| { id?: string; type: \"bash\"; command: string; excludeFromContext?: boolean }\n\t| { id?: string; type: \"user_bash\"; command: string; excludeFromContext?: boolean }\n\t| { id?: string; type: \"abort_bash\"; requestId?: string }\n\n\t// Session\n\t| { id?: string; type: \"get_session_stats\" }\n\t| { id?: string; type: \"get_tools\" }\n\t| { id?: string; type: \"export_html\"; outputPath?: string }\n\t| { id?: string; type: \"switch_session\"; sessionId: string; cwdOverride?: string; sessionDirectory?: string }\n\t| { id?: string; type: \"import_session\"; inputPath: string; cwdOverride?: string }\n\t| { id?: string; type: \"fork\"; entryId: string }\n\t| { id?: string; type: \"clone\" }\n\t| { id?: string; type: \"get_fork_messages\" }\n\t| { id?: string; type: \"get_entries\"; since?: string }\n\t| { id?: string; type: \"get_tree\" }\n\t| { id?: string; type: \"get_last_assistant_text\" }\n\t| { id?: string; type: \"set_session_name\"; name: string }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"navigate_tree\";\n\t\t\ttargetId: string;\n\t\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string };\n\t }\n\t| { id?: string; type: \"set_label\"; entryId: string; label?: string }\n\t| { id?: string; type: \"reload\" }\n\t| { id?: string; type: \"start_pending_recovery\"; reason?: SessionRecoveryReason }\n\t| { id?: string; type: \"get_shortcuts\" }\n\t| { id?: string; type: \"invoke_shortcut\"; key: string }\n\n\t// Messages\n\t| { id?: string; type: \"get_messages\" }\n\n\t// Commands and their live argument completions\n\t| { id?: string; type: \"get_commands\" }\n\t| { id?: string; type: \"get_command_completions\"; commandName: string; argumentPrefix: string };\n// ============================================================================\n// RPC Argument Completion\n// ============================================================================\n\nexport interface RpcAutocompleteItem {\n\tvalue: string;\n\tlabel: string;\n\tdescription?: string;\n}\n\n// RPC Slash Command (for get_commands response)\n// ============================================================================\n\n/** A command available for invocation via prompt */\nexport interface RpcSlashCommand {\n\t/** Command name (without leading slash) */\n\tname: string;\n\t/** Human-readable description */\n\tdescription?: string;\n\t/** Whether the engine can evaluate argument completions for this command. */\n\thasArgumentCompletions?: boolean;\n\t/** What kind of command this is */\n\tsource: \"extension\" | \"prompt\" | \"skill\";\n\t/** Source metadata for the owning resource */\n\tsourceInfo: SourceInfo;\n}\n\n// ============================================================================\n// RPC State\n// ============================================================================\n\nexport interface RpcResourceExtension {\n\tpath: string;\n\tsourceInfo?: SourceInfo;\n\thidden: boolean;\n}\n\nexport interface RpcSessionState {\n\tmodel?: Model<Api>;\n\tmodelFallbackMessage?: string;\n\tmodelFallbackReason?: ModelFallbackReason;\n\tthinkingLevel: ThinkingLevel;\n\tisStreaming: boolean;\n\tisCompacting: boolean;\n\tcompactionReason?: CompactionReason;\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\tsessionLocation?: string;\n\tsessionId: string;\n\tsessionName?: string;\n\tautoCompactionEnabled: boolean;\n\t/** Background compaction state (#4330), the same shape workflow stage status carries. */\n\tcompaction: SerializedBackgroundCompactionState;\n\tbackgroundCompactionEnabled: boolean;\n\tbackgroundCompactionThresholdPercent: number;\n\tmessageCount: number;\n\tpendingMessageCount: number;\n\tqueuedMessagesPaused: boolean;\n\t/** Authoritative engine trust state; absent on older RPC peers. */\n\tprojectTrusted?: boolean;\n\tresourceOverlaps?: ResourceOverlap[];\n\tresourceExtensions?: RpcResourceExtension[];\n}\n\nexport interface RpcLogoutProviderResult {\n\tprovider: string;\n\tauthStatus: AuthStatus;\n\tmodels: Model<Api>[];\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n}\n\n// ============================================================================\n// RPC Responses (stdout)\n// ============================================================================\n\n// Success responses with data\nexport type RpcResponse =\n\t// Prompting\n\t| { id?: string; type: \"response\"; command: \"prompt\"; success: true; data: { disposition: PromptDisposition } }\n\t| { id?: string; type: \"response\"; command: \"steer\"; success: true; data: { disposition: QueuedInputDisposition } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"follow_up\";\n\t\t\tsuccess: true;\n\t\t\tdata: { disposition: QueuedInputDisposition };\n\t }\n\t| { id?: string; type: \"response\"; command: \"abort\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"new_session\"; success: true; data: { cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"delete_session\"; success: true }\n\n\t// State\n\t| { id?: string; type: \"response\"; command: \"get_state\"; success: true; data: RpcSessionState }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_session_summary\";\n\t\t\tsuccess: true;\n\t\t\tdata: { summary: SessionSummaryEntry | null };\n\t }\n\t| { id?: string; type: \"response\"; command: \"list_sessions\"; success: true; data: { sessions: RpcSessionInfo[] } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"list_workflow_runs\";\n\t\t\tsuccess: true;\n\t\t\tdata: { runs: readonly WorkflowRunSummary[] };\n\t }\n\t| { id?: string; type: \"response\"; command: \"get_workflow_run_summary\"; success: true; data: WorkflowRunDetail }\n\t| { id?: string; type: \"response\"; command: \"open_task_inspector\"; success: true }\n\n\t// Model\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"set_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: Model<Api>;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: { model: Model<Api>; thinkingLevel: ThinkingLevel; isScoped: boolean } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_models\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcModelCatalog;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"refresh_models\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcModelRefreshResult;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"login_provider\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcLoginProviderResult | RpcOAuthLoginProviderResult;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"save_provider_credential\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcModelCatalog;\n\t }\n\t| { id?: string; type: \"response\"; command: \"cancel_login_provider\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"logout_provider\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcLogoutProviderResult;\n\t }\n\n\t// Thinking — data-less success remains valid for older clients; isolated persist\n\t// reads the optional ACK when present.\n\t| { id?: string; type: \"response\"; command: \"set_thinking_level\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"set_thinking_level\";\n\t\t\tsuccess: true;\n\t\t\tdata: { level: ThinkingLevel; provider?: string; modelId?: string };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_thinking_level\";\n\t\t\tsuccess: true;\n\t\t\tdata: { level: ThinkingLevel } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_thinking_levels\";\n\t\t\tsuccess: true;\n\t\t\tdata: { levels: ThinkingLevel[] };\n\t }\n\n\t// Queue modes\n\t| { id?: string; type: \"response\"; command: \"set_steering_mode\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_follow_up_mode\"; success: true }\n\n\t// Compaction\n\t| { id?: string; type: \"response\"; command: \"compact\"; success: true; data: VerbatimCompactionResult }\n\t| { id?: string; type: \"response\"; command: \"set_auto_compaction\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_background_compaction\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_background_compaction_threshold\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_compaction\"; success: true }\n\n\t// Extension UI\n\t| { id?: string; type: \"response\"; command: \"set_extension_ui_capabilities\"; success: true }\n\n\t// Debug\n\t| { id?: string; type: \"response\"; command: \"set_debug\"; success: true }\n\n\t// Retry\n\t| { id?: string; type: \"response\"; command: \"set_auto_retry\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_retry\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"clear_queue\";\n\t\t\tsuccess: true;\n\t\t\tdata: ClearedQueue;\n\t }\n\t| { id?: string; type: \"response\"; command: \"pause_queued_messages\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"resume_queued_messages\"; success: true; data: { released: boolean } }\n\n\t// Bash\n\t| { id?: string; type: \"response\"; command: \"bash\"; success: true; data: BashResult }\n\t| { id?: string; type: \"response\"; command: \"user_bash\"; success: true; data: BashResult }\n\t| { id?: string; type: \"response\"; command: \"abort_bash\"; success: true }\n\n\t// Session\n\t| { id?: string; type: \"response\"; command: \"get_session_stats\"; success: true; data: SessionStats }\n\t| { id?: string; type: \"response\"; command: \"get_tools\"; success: true; data: ToolStatusReport }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"import_session\";\n\t\t\tsuccess: true;\n\t\t\tdata: { cancelled: boolean; notices?: readonly RpcResumeNotice[] };\n\t }\n\t| { id?: string; type: \"response\"; command: \"export_html\"; success: true; data: { path: string } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"switch_session\";\n\t\t\tsuccess: true;\n\t\t\tdata: { cancelled: boolean; notices?: readonly RpcResumeNotice[] };\n\t }\n\t| { id?: string; type: \"response\"; command: \"fork\"; success: true; data: { text: string; cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"clone\"; success: true; data: { cancelled: boolean } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_fork_messages\";\n\t\t\tsuccess: true;\n\t\t\tdata: { messages: Array<{ entryId: string; text: string }> };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_entries\";\n\t\t\tsuccess: true;\n\t\t\tdata: { entries: SessionEntry[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_tree\";\n\t\t\tsuccess: true;\n\t\t\tdata: { tree: SessionTreeNode[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_last_assistant_text\";\n\t\t\tsuccess: true;\n\t\t\tdata: { text: string | null };\n\t }\n\t| { id?: string; type: \"response\"; command: \"set_session_name\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"navigate_tree\";\n\t\t\tsuccess: true;\n\t\t\tdata: { cancelled: boolean; editorText?: string };\n\t }\n\t| { id?: string; type: \"response\"; command: \"set_label\"; success: true; data: { entryId: string } }\n\t| { id?: string; type: \"response\"; command: \"reload\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"start_pending_recovery\"; success: true; data: SessionRecoveryReport }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_shortcuts\";\n\t\t\tsuccess: true;\n\t\t\tdata: { shortcuts: Array<{ key: string; description?: string }> };\n\t }\n\t| { id?: string; type: \"response\"; command: \"invoke_shortcut\"; success: true }\n\n\t// Messages\n\t| { id?: string; type: \"response\"; command: \"get_messages\"; success: true; data: { messages: AgentMessage[] } }\n\n\t// Commands\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_commands\";\n\t\t\tsuccess: true;\n\t\t\tdata: { commands: RpcSlashCommand[] };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_command_completions\";\n\t\t\tsuccess: true;\n\t\t\tdata: { completions: RpcAutocompleteItem[] | null };\n\t }\n\n\t// Error response (any command can fail)\n\t| ({\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: string;\n\t\t\tsuccess: false;\n\t\t\terror: string;\n\t } & RpcErrorDetails);\n\n/** Typed failure details an error response may carry, rehydrated by the RPC client. */\nexport type RpcErrorDetails =\n\t| { errorCode?: undefined; errorDetails?: undefined }\n\t| {\n\t\t\terrorCode: \"credential_synchronization\";\n\t\t\terrorDetails: { providerId: string; operation: CredentialSynchronizationOperation };\n\t }\n\t| { errorCode: \"debug_error\"; errorDetails: SerializedDebugError }\n\t// A rejected background compaction command keeps its typed error (#4330)\n\t| { errorCode: \"background_compaction\"; errorDetails: SerializedBackgroundCompactionError }\n\t// A resume or import whose session's working directory is gone keeps its typed error, so the host can offer\n\t// to continue or fork instead of reporting a failure\n\t| { errorCode: \"missing_session_cwd\"; errorDetails: SerializedMissingSessionCwdError };\n\n// ============================================================================\n// RPC Events (stdout)\n// ============================================================================\n\n/** Events streamed by RPC mode as session activity occurs. */\nexport type RpcEvent = JsonAgentSessionEvent;\n\n// ============================================================================\n// Extension UI Events (stdout)\n// ============================================================================\ntype RpcOAuthUIEnvelope = { type: \"extension_ui_request\"; id: string; provider: string; loginId: string };\n\nexport type RpcExtensionUIRequest =\n\t| { type: \"extension_ui_request\"; id: string; method: \"select\"; title: string; options: string[]; timeout?: number }\n\t| { type: \"extension_ui_request\"; id: string; method: \"confirm\"; title: string; message: string; timeout?: number }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"input\";\n\t\t\ttitle: string;\n\t\t\tplaceholder?: string;\n\t\t\ttimeout?: number;\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"editor\"; title: string; prefill?: string }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"questionnaire\";\n\t\t\tquestions: QuestionParams[\"questions\"];\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"notify\";\n\t\t\tmessage: string;\n\t\t\tnotifyType?: \"info\" | \"warning\" | \"error\";\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setStatus\";\n\t\t\tstatusKey: string;\n\t\t\tstatusText: string | undefined;\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setWidget\";\n\t\t\twidgetKey: string;\n\t\t\twidgetLines: string[] | undefined;\n\t\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\";\n\t\t\twidgetScroll?: { maxHeight: number; maxHeightFraction?: number };\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"setTitle\"; title: string }\n\t| { type: \"extension_ui_request\"; id: string; method: \"set_editor_text\"; text: string }\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_auth\"; info: OAuthAuthInfo })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_device_code\"; info: OAuthDeviceCodeInfo })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_progress\"; message: string })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_info\"; message: string; links: AuthInfoLink[] })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_prompt\"; prompt: OAuthPrompt })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_select\"; prompt: OAuthSelectPrompt })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_manual_code\" })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_manual_code_cancel\" });\n\n// ============================================================================\n// Extension UI Commands (stdin)\n// ============================================================================\n\n/** Response to an extension UI request */\nexport type RpcExtensionUIResponse =\n\t| { type: \"extension_ui_response\"; id: string; value: string }\n\t| { type: \"extension_ui_response\"; id: string; confirmed: boolean }\n\t| { type: \"extension_ui_response\"; id: string; answers: QuestionAnswer[] }\n\t| { type: \"extension_ui_response\"; id: string; cancelled: true };\n\n// ============================================================================\n// Helper type for extracting command types\n// ============================================================================\n\nexport type RpcCommandType = RpcCommand[\"type\"];\n"]}
1
+ {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","sourcesContent":["/**\n * RPC protocol types for headless operation.\n *\n * Commands are sent as JSON lines on stdin.\n * Responses and events are emitted as JSON lines on stdout.\n */\n\nimport type {\n\tAuthInfoLink,\n\tCredential,\n\tOAuthAuthInfo,\n\tOAuthDeviceCodeInfo,\n\tOAuthPrompt,\n\tOAuthSelectPrompt,\n} from \"@bastani/pi-ai\";\nimport type { Api, ImageContent, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type {\n\tClearedQueue,\n\tCompactionReason,\n\tPromptDisposition,\n\tQueuedInputDisposition,\n\tSessionRecoveryReport,\n\tSessionStats,\n} from \"../../core/agent-session.js\";\nimport type { BashResult } from \"../../core/bash-executor.ts\";\nimport type { SerializedBackgroundCompactionState } from \"../../core/compaction/background-compaction.ts\";\nimport type { SerializedBackgroundCompactionError } from \"../../core/compaction/background-compaction-errors.ts\";\nimport type { VerbatimCompactionResult } from \"../../core/compaction/index.ts\";\nimport type { SerializedDebugError } from \"../../core/debug-errors.ts\";\nimport type { ResourceOverlap } from \"../../core/diagnostics.ts\";\nimport type { SessionRecoveryReason } from \"../../core/extensions/index.js\";\nimport type {\n\tWorkflowRunDetail,\n\tWorkflowRunFilterStatus,\n\tWorkflowRunSummary,\n} from \"../../core/extensions/workflow-run-control.js\";\nimport type { ModelFallbackReason } from \"../../core/model-resolver-types.ts\";\nimport type { CredentialSynchronizationOperation } from \"../../core/model-runtime.js\";\nimport type { OAuthProviderMetadata } from \"../../core/oauth-login.ts\";\nimport type { AuthStatus } from \"../../core/provider-composer.ts\";\nimport type { SerializedMissingSessionCwdError } from \"../../core/session-cwd.ts\";\nimport type {\n\tBranchSummaryEntry,\n\tSessionEntry,\n\tSessionInfo,\n\tSessionSummaryEntry,\n\tSessionTreeNode,\n} from \"../../core/session-manager.ts\";\nimport type { SourceInfo } from \"../../core/source-info.ts\";\nimport type { ToolStatusReport } from \"../../core/tool-status.js\";\nimport type { QuestionAnswer, QuestionParams } from \"../../core/tools/ask-user-question/tool/types.js\";\nimport type { JsonAgentSessionEvent } from \"../json-event.ts\";\n\n// ============================================================================\n// RPC Commands (stdin)\n// ============================================================================\n\n/** A line a resume shows the user, carried from the engine that prepared the resume to the host that renders it. */\nexport interface RpcResumeNotice {\n\treadonly type: \"info\" | \"warning\";\n\treadonly message: string;\n}\n\nexport interface RpcModelCatalog {\n\tmodels: Model<Api>[];\n\tscopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Extension-registered providers that offer API-key login (`login_provider`). */\n\tcustomAuthProviders: Array<{ id: string; name: string }>;\n\toauthProviders?: OAuthProviderMetadata[];\n\t/** Auth status of extension-registered providers that is not a stored credential (environment, configured key, runtime key). */\n\tproviderAuthStatuses?: Array<{ provider: string; status: AuthStatus }>;\n}\n\nexport interface RpcModelRefreshResult extends RpcModelCatalog {\n\taborted: boolean;\n\terrors: Array<{ provider: string; message: string }>;\n}\n/**\n * The host supplied the API key through the login input form, so echoing it\n * back over the stdout pipe would make this response a second credential\n * egress. Only the metadata a caller needs to confirm the login travels.\n */\nexport type RpcLoginProviderResult =\n\t| (RpcModelCatalog & {\n\t\t\tprovider: string;\n\t\t\tcancelled: false;\n\t\t\ttype: \"api_key\";\n\t })\n\t| { provider: string; cancelled: true };\n\nexport type RpcOAuthLoginProviderResult =\n\t| (RpcModelCatalog & { provider: string; cancelled: false })\n\t| { provider: string; cancelled: true };\n\nexport type RpcSessionInfo = Omit<SessionInfo, \"created\" | \"modified\"> & {\n\tcreated: string;\n\tmodified: string;\n};\n\nexport type RpcCommand =\n\t// Prompting\n\t| { id?: string; type: \"prompt\"; message: string; images?: ImageContent[]; streamingBehavior?: \"steer\" | \"followUp\" }\n\t| { id?: string; type: \"steer\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"follow_up\"; message: string; images?: ImageContent[] }\n\t| { id?: string; type: \"abort\" }\n\t| { id?: string; type: \"new_session\"; parentSession?: string }\n\t| { id?: string; type: \"delete_session\"; sessionId?: string }\n\n\t// State\n\t| { id?: string; type: \"get_state\" }\n\t| { id?: string; type: \"get_session_summary\" }\n\t| { id?: string; type: \"list_sessions\" }\n\t| { id?: string; type: \"list_workflow_runs\"; status?: WorkflowRunFilterStatus }\n\t| { id?: string; type: \"get_workflow_run_summary\"; runId: string }\n\t| { id?: string; type: \"open_task_inspector\"; taskId?: string }\n\n\t// Model\n\t| { id?: string; type: \"set_model\"; provider: string; modelId: string; persist?: boolean }\n\t| { id?: string; type: \"cycle_model\"; direction?: \"forward\" | \"backward\"; persist?: boolean }\n\t| { id?: string; type: \"get_available_models\"; allowPartialResources?: boolean }\n\t| { id?: string; type: \"login_provider\"; provider: string; authType?: \"api_key\" | \"oauth\"; loginId?: string }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"save_provider_credential\";\n\t\t\tprovider: string;\n\t\t\tcredential: Credential;\n\t\t\t/** Fetch the remote catalog before publishing the credential. Defaults to true. */\n\t\t\trefreshCatalog?: boolean;\n\t }\n\t| { id?: string; type: \"cancel_login_provider\"; provider: string; loginId?: string }\n\t| { id?: string; type: \"logout_provider\"; provider: string }\n\t| { id?: string; type: \"refresh_models\"; timeoutMs?: number; force?: boolean; allowNetwork?: boolean }\n\n\t// Thinking\n\t| { id?: string; type: \"set_thinking_level\"; level: ThinkingLevel; persist?: boolean }\n\t| { id?: string; type: \"cycle_thinking_level\" }\n\t| { id?: string; type: \"get_available_thinking_levels\" }\n\n\t// Queue modes\n\t| { id?: string; type: \"set_steering_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\t| { id?: string; type: \"set_follow_up_mode\"; mode: \"all\" | \"one-at-a-time\" }\n\n\t// Compaction\n\t| { id?: string; type: \"compact\" }\n\t| { id?: string; type: \"set_auto_compaction\"; enabled: boolean }\n\t| { id?: string; type: \"set_background_compaction\"; enabled: boolean }\n\t| { id?: string; type: \"set_background_compaction_threshold\"; percent: number }\n\t| { id?: string; type: \"abort_compaction\" }\n\t| { id?: string; type: \"abort_branch_summary\" }\n\n\t// Extension UI\n\t| { id?: string; type: \"set_extension_ui_capabilities\"; questionnaire?: boolean }\n\n\t// Debug\n\t| { id?: string; type: \"set_debug\"; enabled: boolean }\n\n\t// Retry\n\t| { id?: string; type: \"set_auto_retry\"; enabled: boolean }\n\t| { id?: string; type: \"abort_retry\" }\n\t| { id?: string; type: \"clear_queue\" }\n\t| { id?: string; type: \"pause_queued_messages\" }\n\t| { id?: string; type: \"resume_queued_messages\" }\n\n\t// Bash\n\t| { id?: string; type: \"bash\"; command: string; excludeFromContext?: boolean }\n\t| { id?: string; type: \"user_bash\"; command: string; excludeFromContext?: boolean }\n\t| { id?: string; type: \"abort_bash\"; requestId?: string }\n\n\t// Session\n\t| { id?: string; type: \"get_session_stats\" }\n\t| { id?: string; type: \"get_tools\" }\n\t| { id?: string; type: \"export_html\"; outputPath?: string }\n\t| { id?: string; type: \"switch_session\"; sessionId: string; cwdOverride?: string; sessionDirectory?: string }\n\t| { id?: string; type: \"import_session\"; inputPath: string; cwdOverride?: string }\n\t| { id?: string; type: \"fork\"; entryId: string }\n\t| { id?: string; type: \"clone\" }\n\t| { id?: string; type: \"get_fork_messages\" }\n\t| { id?: string; type: \"get_entries\"; since?: string }\n\t| { id?: string; type: \"get_tree\" }\n\t| { id?: string; type: \"get_last_assistant_text\" }\n\t| { id?: string; type: \"set_session_name\"; name: string }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"navigate_tree\";\n\t\t\ttargetId: string;\n\t\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string };\n\t }\n\t| { id?: string; type: \"set_label\"; entryId: string; label?: string }\n\t| { id?: string; type: \"reload\" }\n\t| { id?: string; type: \"start_pending_recovery\"; reason?: SessionRecoveryReason }\n\t| { id?: string; type: \"get_shortcuts\" }\n\t| { id?: string; type: \"invoke_shortcut\"; key: string }\n\n\t// Messages\n\t| { id?: string; type: \"get_messages\" }\n\n\t// Commands and their live argument completions\n\t| { id?: string; type: \"get_commands\" }\n\t| { id?: string; type: \"get_command_completions\"; commandName: string; argumentPrefix: string };\n// ============================================================================\n// RPC Argument Completion\n// ============================================================================\n\nexport interface RpcAutocompleteItem {\n\tvalue: string;\n\tlabel: string;\n\tdescription?: string;\n}\n\n// RPC Slash Command (for get_commands response)\n// ============================================================================\n\n/** A command available for invocation via prompt */\nexport interface RpcSlashCommand {\n\t/** Command name (without leading slash) */\n\tname: string;\n\t/** Human-readable description */\n\tdescription?: string;\n\t/** Whether the engine can evaluate argument completions for this command. */\n\thasArgumentCompletions?: boolean;\n\t/** What kind of command this is */\n\tsource: \"extension\" | \"prompt\" | \"skill\";\n\t/** Source metadata for the owning resource */\n\tsourceInfo: SourceInfo;\n}\n\n// ============================================================================\n// RPC State\n// ============================================================================\n\nexport interface RpcResourceExtension {\n\tpath: string;\n\tsourceInfo?: SourceInfo;\n\thidden: boolean;\n}\n\nexport interface RpcSessionState {\n\tmodel?: Model<Api>;\n\tmodelFallbackMessage?: string;\n\tmodelFallbackReason?: ModelFallbackReason;\n\tthinkingLevel: ThinkingLevel;\n\tisStreaming: boolean;\n\tisCompacting: boolean;\n\tcompactionReason?: CompactionReason;\n\tsteeringMode: \"all\" | \"one-at-a-time\";\n\tfollowUpMode: \"all\" | \"one-at-a-time\";\n\tsessionLocation?: string;\n\tsessionId: string;\n\tsessionName?: string;\n\tautoCompactionEnabled: boolean;\n\t/** Background compaction state (#4330), the same shape workflow stage status carries. */\n\tcompaction: SerializedBackgroundCompactionState;\n\tbackgroundCompactionEnabled: boolean;\n\tbackgroundCompactionThresholdPercent: number;\n\tmessageCount: number;\n\tpendingMessageCount: number;\n\tqueuedMessagesPaused: boolean;\n\t/** Authoritative engine trust state; absent on older RPC peers. */\n\tprojectTrusted?: boolean;\n\tresourceOverlaps?: ResourceOverlap[];\n\tresourceExtensions?: RpcResourceExtension[];\n}\n\nexport interface RpcLogoutProviderResult {\n\tprovider: string;\n\tauthStatus: AuthStatus;\n\tmodels: Model<Api>[];\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n}\n\n// ============================================================================\n// RPC Responses (stdout)\n// ============================================================================\n\n// Success responses with data\nexport type RpcResponse =\n\t// Prompting\n\t| { id?: string; type: \"response\"; command: \"prompt\"; success: true; data: { disposition: PromptDisposition } }\n\t| { id?: string; type: \"response\"; command: \"steer\"; success: true; data: { disposition: QueuedInputDisposition } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"follow_up\";\n\t\t\tsuccess: true;\n\t\t\tdata: { disposition: QueuedInputDisposition };\n\t }\n\t| { id?: string; type: \"response\"; command: \"abort\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"new_session\"; success: true; data: { cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"delete_session\"; success: true }\n\n\t// State\n\t| { id?: string; type: \"response\"; command: \"get_state\"; success: true; data: RpcSessionState }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_session_summary\";\n\t\t\tsuccess: true;\n\t\t\tdata: { summary: SessionSummaryEntry | null };\n\t }\n\t| { id?: string; type: \"response\"; command: \"list_sessions\"; success: true; data: { sessions: RpcSessionInfo[] } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"list_workflow_runs\";\n\t\t\tsuccess: true;\n\t\t\tdata: { runs: readonly WorkflowRunSummary[] };\n\t }\n\t| { id?: string; type: \"response\"; command: \"get_workflow_run_summary\"; success: true; data: WorkflowRunDetail }\n\t| { id?: string; type: \"response\"; command: \"open_task_inspector\"; success: true }\n\n\t// Model\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"set_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: Model<Api>;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_model\";\n\t\t\tsuccess: true;\n\t\t\tdata: { model: Model<Api>; thinkingLevel: ThinkingLevel; isScoped: boolean } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_models\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcModelCatalog;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"refresh_models\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcModelRefreshResult;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"login_provider\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcLoginProviderResult | RpcOAuthLoginProviderResult;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"save_provider_credential\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcModelCatalog;\n\t }\n\t| { id?: string; type: \"response\"; command: \"cancel_login_provider\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"logout_provider\";\n\t\t\tsuccess: true;\n\t\t\tdata: RpcLogoutProviderResult;\n\t }\n\n\t// Thinking — data-less success remains valid for older clients; isolated persist\n\t// reads the optional ACK when present.\n\t| { id?: string; type: \"response\"; command: \"set_thinking_level\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"set_thinking_level\";\n\t\t\tsuccess: true;\n\t\t\tdata: { level: ThinkingLevel; provider?: string; modelId?: string };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"cycle_thinking_level\";\n\t\t\tsuccess: true;\n\t\t\tdata: { level: ThinkingLevel } | null;\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_available_thinking_levels\";\n\t\t\tsuccess: true;\n\t\t\tdata: { levels: ThinkingLevel[] };\n\t }\n\n\t// Queue modes\n\t| { id?: string; type: \"response\"; command: \"set_steering_mode\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_follow_up_mode\"; success: true }\n\n\t// Compaction\n\t| { id?: string; type: \"response\"; command: \"compact\"; success: true; data: VerbatimCompactionResult }\n\t| { id?: string; type: \"response\"; command: \"set_auto_compaction\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_background_compaction\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"set_background_compaction_threshold\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_compaction\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_branch_summary\"; success: true }\n\n\t// Extension UI\n\t| { id?: string; type: \"response\"; command: \"set_extension_ui_capabilities\"; success: true }\n\n\t// Debug\n\t| { id?: string; type: \"response\"; command: \"set_debug\"; success: true }\n\n\t// Retry\n\t| { id?: string; type: \"response\"; command: \"set_auto_retry\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"abort_retry\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"clear_queue\";\n\t\t\tsuccess: true;\n\t\t\tdata: ClearedQueue;\n\t }\n\t| { id?: string; type: \"response\"; command: \"pause_queued_messages\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"resume_queued_messages\"; success: true; data: { released: boolean } }\n\n\t// Bash\n\t| { id?: string; type: \"response\"; command: \"bash\"; success: true; data: BashResult }\n\t| { id?: string; type: \"response\"; command: \"user_bash\"; success: true; data: BashResult }\n\t| { id?: string; type: \"response\"; command: \"abort_bash\"; success: true }\n\n\t// Session\n\t| { id?: string; type: \"response\"; command: \"get_session_stats\"; success: true; data: SessionStats }\n\t| { id?: string; type: \"response\"; command: \"get_tools\"; success: true; data: ToolStatusReport }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"import_session\";\n\t\t\tsuccess: true;\n\t\t\tdata: { cancelled: boolean; notices?: readonly RpcResumeNotice[] };\n\t }\n\t| { id?: string; type: \"response\"; command: \"export_html\"; success: true; data: { path: string } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"switch_session\";\n\t\t\tsuccess: true;\n\t\t\tdata: { cancelled: boolean; notices?: readonly RpcResumeNotice[] };\n\t }\n\t| { id?: string; type: \"response\"; command: \"fork\"; success: true; data: { text: string; cancelled: boolean } }\n\t| { id?: string; type: \"response\"; command: \"clone\"; success: true; data: { cancelled: boolean } }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_fork_messages\";\n\t\t\tsuccess: true;\n\t\t\tdata: { messages: Array<{ entryId: string; text: string }> };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_entries\";\n\t\t\tsuccess: true;\n\t\t\tdata: { entries: SessionEntry[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_tree\";\n\t\t\tsuccess: true;\n\t\t\tdata: { tree: SessionTreeNode[]; leafId: string | null };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_last_assistant_text\";\n\t\t\tsuccess: true;\n\t\t\tdata: { text: string | null };\n\t }\n\t| { id?: string; type: \"response\"; command: \"set_session_name\"; success: true }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"navigate_tree\";\n\t\t\tsuccess: true;\n\t\t\tdata: { cancelled: boolean; aborted?: boolean; editorText?: string; summaryEntry?: BranchSummaryEntry };\n\t }\n\t| { id?: string; type: \"response\"; command: \"set_label\"; success: true; data: { entryId: string } }\n\t| { id?: string; type: \"response\"; command: \"reload\"; success: true }\n\t| { id?: string; type: \"response\"; command: \"start_pending_recovery\"; success: true; data: SessionRecoveryReport }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_shortcuts\";\n\t\t\tsuccess: true;\n\t\t\tdata: { shortcuts: Array<{ key: string; description?: string }> };\n\t }\n\t| { id?: string; type: \"response\"; command: \"invoke_shortcut\"; success: true }\n\n\t// Messages\n\t| { id?: string; type: \"response\"; command: \"get_messages\"; success: true; data: { messages: AgentMessage[] } }\n\n\t// Commands\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_commands\";\n\t\t\tsuccess: true;\n\t\t\tdata: { commands: RpcSlashCommand[] };\n\t }\n\t| {\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: \"get_command_completions\";\n\t\t\tsuccess: true;\n\t\t\tdata: { completions: RpcAutocompleteItem[] | null };\n\t }\n\n\t// Error response (any command can fail)\n\t| ({\n\t\t\tid?: string;\n\t\t\ttype: \"response\";\n\t\t\tcommand: string;\n\t\t\tsuccess: false;\n\t\t\terror: string;\n\t } & RpcErrorDetails);\n\n/** Typed failure details an error response may carry, rehydrated by the RPC client. */\nexport type RpcErrorDetails =\n\t| { errorCode?: undefined; errorDetails?: undefined }\n\t| {\n\t\t\terrorCode: \"credential_synchronization\";\n\t\t\terrorDetails: { providerId: string; operation: CredentialSynchronizationOperation };\n\t }\n\t| { errorCode: \"debug_error\"; errorDetails: SerializedDebugError }\n\t// A rejected background compaction command keeps its typed error (#4330)\n\t| { errorCode: \"background_compaction\"; errorDetails: SerializedBackgroundCompactionError }\n\t// A resume or import whose session's working directory is gone keeps its typed error, so the host can offer\n\t// to continue or fork instead of reporting a failure\n\t| { errorCode: \"missing_session_cwd\"; errorDetails: SerializedMissingSessionCwdError };\n\n// ============================================================================\n// RPC Events (stdout)\n// ============================================================================\n\n/** Events streamed by RPC mode as session activity occurs. */\nexport type RpcEvent = JsonAgentSessionEvent;\n\n// ============================================================================\n// Extension UI Events (stdout)\n// ============================================================================\ntype RpcOAuthUIEnvelope = { type: \"extension_ui_request\"; id: string; provider: string; loginId: string };\n\nexport type RpcExtensionUIRequest =\n\t| { type: \"extension_ui_request\"; id: string; method: \"select\"; title: string; options: string[]; timeout?: number }\n\t| { type: \"extension_ui_request\"; id: string; method: \"confirm\"; title: string; message: string; timeout?: number }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"input\";\n\t\t\ttitle: string;\n\t\t\tplaceholder?: string;\n\t\t\ttimeout?: number;\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"editor\"; title: string; prefill?: string }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"questionnaire\";\n\t\t\tquestions: QuestionParams[\"questions\"];\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"notify\";\n\t\t\tmessage: string;\n\t\t\tnotifyType?: \"info\" | \"warning\" | \"error\";\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setStatus\";\n\t\t\tstatusKey: string;\n\t\t\tstatusText: string | undefined;\n\t }\n\t| {\n\t\t\ttype: \"extension_ui_request\";\n\t\t\tid: string;\n\t\t\tmethod: \"setWidget\";\n\t\t\twidgetKey: string;\n\t\t\twidgetLines: string[] | undefined;\n\t\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\";\n\t\t\twidgetScroll?: { maxHeight: number; maxHeightFraction?: number };\n\t }\n\t| { type: \"extension_ui_request\"; id: string; method: \"setTitle\"; title: string }\n\t| { type: \"extension_ui_request\"; id: string; method: \"set_editor_text\"; text: string }\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_auth\"; info: OAuthAuthInfo })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_device_code\"; info: OAuthDeviceCodeInfo })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_progress\"; message: string })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_info\"; message: string; links: AuthInfoLink[] })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_prompt\"; prompt: OAuthPrompt })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_select\"; prompt: OAuthSelectPrompt })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_manual_code\" })\n\t| (RpcOAuthUIEnvelope & { method: \"oauth_manual_code_cancel\" });\n\n// ============================================================================\n// Extension UI Commands (stdin)\n// ============================================================================\n\n/** Response to an extension UI request */\nexport type RpcExtensionUIResponse =\n\t| { type: \"extension_ui_response\"; id: string; value: string }\n\t| { type: \"extension_ui_response\"; id: string; confirmed: boolean }\n\t| { type: \"extension_ui_response\"; id: string; answers: QuestionAnswer[] }\n\t| { type: \"extension_ui_response\"; id: string; cancelled: true };\n\n// ============================================================================\n// Helper type for extracting command types\n// ============================================================================\n\nexport type RpcCommandType = RpcCommand[\"type\"];\n"]}
@@ -6,7 +6,7 @@ Atomic accepts environment variables for configuration, provider credentials, an
6
6
 
7
7
  | Atomic variable | Legacy alias | Purpose |
8
8
  |---|---|---|
9
- | `ATOMIC_CODING_AGENT_DIR` | `PI_CODING_AGENT_DIR` | Agent/config directory; default `~/.atomic/agent` |
9
+ | `ATOMIC_CODING_AGENT_DIR` | `PI_CODING_AGENT_DIR` | Agent/config directory; default `~/.atomic/agent`. Read each time a session or extension load starts, so caches under it, such as the extension transpile cache, follow the value in effect for that load. An SDK session's `agentDir` option takes precedence |
10
10
  | `ATOMIC_CODING_AGENT_SESSION_DIR` | None | Non-empty value selects a JSONL session directory; `--session-dir` and `--no-session` take precedence. Without a selection, sessions use the shared local SQLite database. |
11
11
  | `ATOMIC_PACKAGE_DIR` | `PI_PACKAGE_DIR` | Package directory override |
12
12
  | `ATOMIC_OFFLINE` | `PI_OFFLINE` | Disable automatic network activity, including update checks, package updates, telemetry, model catalog refreshes, and downloads of `fd`, `rg`, and [git](/getting-started/installation#git) |
@@ -26,6 +26,7 @@ Resume as usual, with `atomic --session <id>`, `atomic --resume` or `/resume`. W
26
26
 
27
27
  - If you start Atomic inside a checkout of the same repository and its files match what the session recorded, the session continues there.
28
28
  - Otherwise Atomic restores the recorded state into a new worktree under `~/.atomic/agent/worktree-snapshots` and continues there. It never writes into an existing checkout. One line names the new worktree.
29
+ - If the recorded state cannot be rebuilt exactly, for example because unpushed commits touch files that are never recorded (`.env`, keys), a remote is unreachable, or a snapshot blob is missing, the session still opens with its whole conversation. Atomic restores the best state it can reach: the recorded commit with the uncommitted changes that apply, else the closest commit it can fetch (the last pushed commit, an earlier snapshot's commit, or the branch tip), else nothing, and then the session continues in its recorded directory, or in the directory you started from when that is not on this machine. One notice says what was restored, what is missing and what to do, for example push the missing commits from the original machine and `/resume` again. `/session snapshot` shows the same. See [Resuming](/worktree-snapshots#resuming).
29
30
  - If you start `atomic` inside a checkout of the same repository that differs from the recording and has uncommitted or untracked changes, Atomic asks whether to restore a fresh worktree (the default), continue in your checkout as it is, or cancel. `/resume` and non-interactive modes such as `-p` do not ask; they restore a fresh worktree. A clean checkout that differs, such as a fresh clone at another commit, is left alone without asking, and a fresh worktree is restored. A checkout where the recorded edits were committed counts as matching.
30
31
  - A session that worked in several checkouts gets each of them back where it can, also when it worked from a directory outside all of them: the checkout you started in is used for its repository, and every other recorded checkout that is missing here is restored. Only the checkout the session works in has to be restorable. Any other checkout that is missing or changed never stops the resume: one the session worked in on this machine (a sibling worktree, for example) and that changed since continues as it is, and one that cannot be restored is left out. Each checkout that is left out or kept as it is gets a warning that names its path and why, for example `Continuing without restoring /tmp/probe (snapshot 3f2a9c1d7b04): it does not exist on this node, and Git is unavailable here (not-installed), which restoring it needs`. If you choose to continue in a checkout that differs, the other checkouts are not restored, and a warning names those that are missing here.
31
32
 
@@ -126,16 +127,17 @@ The first turn of a resumed session carries each applicable blueprint's `mainten
126
127
 
127
128
  ## What can stop a resume
128
129
 
129
- Missing setup is checked in one pass before anything is restored: the storage adapter and its token (for a session resumed with `atomic`) and Git. A machine without Git gets a portable Git automatically, as it does for other Git work; only when that is impossible, for example in offline mode or when the download fails, does `git-unavailable` stop the resume. Every missing piece is reported together, with the command that fixes it. For a session, only the checkout it works in can stop the resume this way: when that checkout must be restored and Git is unavailable, the resume stops. For any other checkout, Git being unavailable is a warning that names its path and why. A blueprint is never one of them: it is built after the restore and cannot stop the resume.
130
+ Missing setup is checked in one pass before anything is restored: the storage adapter and its token (for a session resumed with `atomic`) and Git. A machine without Git gets a portable Git automatically, as it does for other Git work; only when that is impossible, for example in offline mode or when the download fails, does `git-unavailable` stop the resume. Every missing piece is reported together, with the command that fixes it. For a session, Git being unavailable never stops the resume: the session continues without restoring its checkouts, in its recorded directory or the directory you started from, with one notice per checkout that names its path and why. A session resume stops only when the session cannot be read, when a snapshot record fails the security checks (`invalid-snapshot`, for example a remote with credentials or a Git remote helper), or when a restore would write into a directory that holds other files (`unsafe-target`). A blueprint is never one of them: it is built after the restore and cannot stop the resume.
130
131
 
131
132
  | Error | Code | When it happens | What to do |
132
133
  |---|---|---|---|
133
134
  | `ResumeNotFoundError` | `not-found` | The session id matches nothing this machine can read. With reason `local-storage-not-joined`, this machine uses local storage only. | Join the machine's sessions with `atomic storage join <url> --token-file <path>`. `atomic team join` keeps sessions on each machine: on a machine joined that way, run `atomic team leave` first. With reason `shared-miss`, check the id and that every machine uses the same storage and prefix. |
134
- | `ResumePreconditionError` | `preconditions-unmet` | Setup the resume needs is missing. Every missing piece is listed in `problems`: `adapter-not-installed`, `credential-missing`, `credential-unreadable`, `git-unavailable`; a piece that belongs to one checkout names it in `checkout`. With `git-unavailable`, its `cause` is the `GitUnavailableError` that says why. | Run each listed fix, for example `atomic install npm:@bastani/atomic-storage-libsql`, write the token file, or unset offline mode or install Git. |
135
- | `GitUnavailableError` | `not-installed`, `unsupported-platform`, `offline`, `checksum-mismatch`, `download-failed`, `install-failed` | A checkout must be verified or restored and no Git can be started or provisioned. | Do what its hint says, for example unset `ATOMIC_OFFLINE` or install Git with the command it names. |
135
+ | `ResumePreconditionError` | `preconditions-unmet` | Setup the resume needs is missing. Every missing piece is listed in `problems`: `adapter-not-installed`, `credential-missing`, `credential-unreadable`, `git-unavailable`; a piece that belongs to one checkout names it in `checkout`. With `git-unavailable` (workflow runs; a session continues without its checkouts instead), its `cause` is the `GitUnavailableError` that says why. | Run each listed fix, for example `atomic install npm:@bastani/atomic-storage-libsql`, write the token file, or unset offline mode or install Git. |
136
+ | `GitUnavailableError` | `not-installed`, `unsupported-platform`, `offline`, `checksum-mismatch`, `download-failed`, `install-failed` | A workflow run's checkout must be verified or restored and no Git can be started or provisioned. A session continues without its checkouts instead. | Do what its hint says, for example unset `ATOMIC_OFFLINE` or install Git with the command it names. |
136
137
  | `ResumeCatalogUnavailableError` | `catalog-unavailable` | The shared storage could not be reached while looking the session or run up, for example because the connection was refused or broke. Retryable. Any other storage failure, such as a missing token file, is reported as that storage error itself. | Check connectivity with `atomic storage status` and resume again. |
137
138
  | `ResumeCatalogTimeoutError` | `catalog-timeout` | The shared storage did not answer the lookup within 15 seconds, for example during a network partition. `subject` is `session` or `run`. Retryable. A partition that starts later in the resume is reported when the connection gives up. | Check connectivity with `atomic storage status` and resume again. |
138
- | `WorkspaceDriftError` | `tree-drift` | The recorded state cannot be rebuilt, for example because unpushed commits touch files that are never recorded (`.env`, keys), a snapshot blob is missing, or the disk is full. The message names what the restore could not do (the commits, blob, remote or full volume) and the fix. | Do what the message says; for unpushed commits, push them from the original machine, or continue there. |
139
+ | `WorkspaceDriftError` | `tree-drift` | A workflow run's recorded state cannot be rebuilt, for example because unpushed commits touch files that are never recorded (`.env`, keys), a snapshot blob is missing, or the disk is full. The message names what the restore could not do (the commits, blob, remote or full volume) and the fix. A session resume does not stop for these; it restores what it can, with a notice. | Do what the message says; for unpushed commits, push them from the original machine, or continue there. |
140
+ | `WorkspaceRestoreError` | `invalid-snapshot` | A snapshot record names a remote with credentials, a Git remote helper (`ext::`), another scheme than `https`, `http`, `ssh`, `git` or `file`, or holds a value Atomic never writes. Nothing is fetched or run. | Resume only sessions and runs from storage you trust, or export the session again on the machine that recorded it. |
139
141
 
140
142
  Secret values never appear in these messages; they name the environment variable or file instead. The classes, their codes and the `isResume…Error` guards are exported from `@bastani/atomic`.
141
143
 
@@ -119,6 +119,10 @@ Custom hosts may declare an optional `recipientPurpose` on session registration
119
119
 
120
120
  Configuration and diagnostics live in `~/.atomic/agent/intercom/`, or under `ATOMIC_CODING_AGENT_DIR`. The legacy `PI_CODING_AGENT_DIR` applies when the Atomic variable is unset. Edit `config.json` for [Intercom settings](/intercom/reference#configuration).
121
121
 
122
+ A local broker keeps these files in that directory: `broker.pid` and, outside Windows, `broker.sock` while it runs, which it removes when it exits; `broker.log` from the session that started it; and `delivered-messages.sqlite` with its `delivered-messages.key`, which a broker creates when the first session registers and keeps so that a restarted broker still recognizes messages it already delivered. A broker that exits without serving a session leaves no delivered-message files.
123
+
124
+ Disposing a session cancels a broker start it has not launched yet, and waits for a broker it already launched to finish starting, stopping it if it does not start in time. Once `dispose()` resolves, nothing that session started writes into the agent directory, so a host that uses a temporary `ATOMIC_CODING_AGENT_DIR` can remove it then. On Windows a running broker keeps `broker.log` open, so the directory can be removed only once the broker has exited, about five seconds after its last session.
125
+
122
126
  When startup fails, read the `broker.log` path printed in the error. Ordinary diagnostics are capped at 8 KiB per broker. The next spawn keeps a bounded copy in `broker.log.previous`; `broker-watchdog.log` separately retains the latest automatic termination's time, PID, and reason. Preserve these files when reporting repeated stalls or restarts. They live under the Intercom directory above.
123
127
 
124
128
  ## Workflow and Subagent Notifications
@@ -13,7 +13,7 @@ These read-only commands do not start a model turn. Stored summaries remain avai
13
13
 
14
14
  | Command | Response `data` | TypeScript `RpcClient` method |
15
15
  | --- | --- | --- |
16
- | `{"type":"get_session_summary"}` | `{ summary: SessionSummaryEntry \| null }`, including `summary` and `summarizedThroughId` | `getSessionSummary()` |
16
+ | `{"type":"get_session_summary"}` | `{ summary: SessionSummaryEntry \| null }`, including `summary` and `summarizedThroughId`; always `null` for an unsaved (`--no-session`) session | `getSessionSummary()` |
17
17
  | `{"type":"list_sessions"}` | `{ sessions: RpcSessionInfo[] }` for the current project/session directory, including `summary` and `summarizedThroughId`; `created` and `modified` are ISO strings | `listSessions()` |
18
18
  | `{"type":"list_workflow_runs"}` | `{ runs: WorkflowRunSummary[] }`, including live runs and current-project resumable and completed history | `listWorkflowRuns(status?)` |
19
19
  | `{"type":"get_workflow_run_summary","runId":"<uuid>"}` | `WorkflowRunDetail` for that run | `getWorkflowRunSummary(runId)` |
@@ -1039,7 +1039,7 @@ Response:
1039
1039
 
1040
1040
  #### get_last_assistant_text
1041
1041
 
1042
- Get the text content of the last assistant message.
1042
+ Get the text content of the last assistant message. Messages without text from an aborted or failed turn, or that only call tools, are skipped.
1043
1043
 
1044
1044
  ```json
1045
1045
  {"type": "get_last_assistant_text"}
@@ -42,6 +42,9 @@ Atomic reads primary `.atomic` locations first and legacy `.pi` locations for co
42
42
  - Custom models (`models.json`)
43
43
  - Credentials (`auth.json`)
44
44
  - Sessions (`sessions/`)
45
+ - The TypeScript extension transpile cache (`cache/jiti/`)
46
+
47
+ `agentDir` is per session, not per process. Each session's extension loads cache their transpiled output under that session's `agentDir`. Without the option, a session uses `ATOMIC_CODING_AGENT_DIR` as set when it is created. Sessions in one process can use different agent directories. Extension loads never create the agent directory: when it doesn't exist, including after you remove it while the process runs, loads skip the cache.
45
48
 
46
49
  When you pass a custom `ResourceLoader`, `cwd` and `agentDir` no longer control resource discovery. They still influence session naming and tool path resolution.
47
50
 
package/docs/sdk.md CHANGED
@@ -332,7 +332,7 @@ Web provider configuration caches are session-local. Configuration discovery and
332
332
 
333
333
  ### Stored session summaries
334
334
 
335
- `session.sessionSummary` returns the current branch's latest `SessionSummaryEntry`, or `undefined` when none is available. Read `summary` for the generated text and `summarizedThroughId` for the last message it describes. `SessionManager.list()` and `SessionManager.listAll()` expose those same fields on each `SessionInfo`. Stored summaries remain readable when `sessionSummary.enabled` is false; that setting controls generation only.
335
+ `session.sessionSummary` returns the current branch's latest `SessionSummaryEntry`, or `undefined` when none is available. Read `summary` for the generated text and `summarizedThroughId` for the last message it describes. `SessionManager.list()` and `SessionManager.listAll()` expose those same fields on each `SessionInfo`. Stored summaries remain readable when `sessionSummary.enabled` is false; that setting controls generation only. Summaries are generated only for saved sessions; a session on `SessionManager.inMemory()` never generates one.
336
336
 
337
337
  ### Worktree snapshots
338
338
 
@@ -675,7 +675,7 @@ Shared loaders, event buses, settings, and `SessionManager` instances do not sha
675
675
 
676
676
  #### Session replacement and deferred cleanup
677
677
 
678
- `await runtime.dispose()` refuses new replacements and waits for pending factories, startup, and cleanup. It also waits up to three seconds, counted from the start of disposal, for an OAuth token exchange still in flight, so a token the provider already rotated is saved before your host exits. No successor is published after closure. Host callbacks must settle independently of disposal. Call `runtime.dispose({ fromSignal: true })` when the host is shutting down because of `SIGTERM` or `SIGHUP`, so `session_shutdown` handlers receive `fromSignal: true` and can tell it from an explicit quit.
678
+ `await runtime.dispose()` refuses new replacements and waits for pending factories, startup, and cleanup. It also waits up to three seconds, counted from the start of disposal, for an OAuth token exchange still in flight, so a token the provider already rotated is saved before your host exits. No successor is published after closure. Host callbacks must settle independently of disposal. Disposal also cancels or waits for an Intercom broker start the session began, so a host can remove a temporary agent directory once disposal resolves; see [Intercom operations](/intercom/operations#how-it-works). Call `runtime.dispose({ fromSignal: true })` when the host is shutting down because of `SIGTERM` or `SIGHUP`, so `session_shutdown` handlers receive `fromSignal: true` and can tell it from an explicit quit.
679
679
 
680
680
  An extension command may await `ctx.newSession()`, `ctx.fork()`, `ctx.switchSession()`, or `session.reload()`. Its old generation remains owned until the command continuation finishes, and final disposal waits for that cleanup. Do not await disposal inside the continuation it must drain. Concurrent replacements are supported, and deferred cleanup failures remain visible.
681
681
 
@@ -316,6 +316,12 @@ Atomic records one of its own: when the oversized result of an agent released wh
316
316
 
317
317
  `hash` is the SHA-256 of the stored bytes and `bytes` their size. In exported files `data` also has `base64`, the bytes themselves, each blob once; importing or forking the file checks every one against its `hash`, stores it with the new session and drops the field.
318
318
 
319
+ `/tree` without a summary records its move with a `custom` entry of `customType: "atomic.leaf"` and no `data`. Its parent is the selected entry, or it has `parentId: null` when the move reset the leaf to an empty conversation. When it is the session's last entry, the session reopens at its parent instead of at the entry itself. It contributes nothing to context and `getTree()` and `getChildren()` omit it. A reader that takes a session's last entry as its leaf follows the selected branch either way; older Atomic versions load it as an ordinary custom entry.
320
+
321
+ ```json
322
+ {"type":"custom","id":"j0k1l2m3","parentId":"c3d4e5f6","timestamp":"2024-12-03T14:22:00.000Z","customType":"atomic.leaf"}
323
+ ```
324
+
319
325
  ### CustomMessageEntry
320
326
 
321
327
  Extension-injected messages that DO participate in LLM context.
@@ -375,6 +381,8 @@ The repository state of one checkout at the end of a turn that called a file-wri
375
381
 
376
382
  - `snapshot`: Present when the state changed. An entry without it refers to the earlier entry whose snapshot has the same `snapshotId`.
377
383
  - `restore`: Present on the entry written when a resume restored the snapshot into a new worktree: `{ "from", "to", "snapshotId", "tree", "restoredAt" }`. Later resumes map `from` to `to`.
384
+ - `restore.degraded`: Present when the resume restored less than the snapshot (#4733): `{ "stage": "partial-changes" | "closest-commit", "head", "tree", "basis"?, "missingLinks", "missingPaths", "missingCommits", "cause", "causeReason"?, "hint" }`. `head` and `tree` are what the worktree holds; `basis` (`pushed-base`, `earlier-snapshot` or `branch-tip`) says where a `closest-commit` restore's commit came from.
385
+ - `unrestored`: Present on an entry written when a resume continued without restoring the checkout at `root` (#4733), never together with `restore`: `{ "snapshotId", "continuedIn", "place": "recorded" | "launch", "cause", "causeReason"?, "detail", "hint", "at" }`.
378
386
  - `restoreWarnings`: Optional, only with `restore`: what that restore reported beyond the snapshot record, `{ "code": "lfs-objects-unavailable", "paths": [...] }` or `{ "code": "stale-restore-retained", "path": "...", "kind": "worktree" | "record" | "records-directory" }`.
379
387
  - `blobs`: Present only in exported files: base64 patch and bundle content keyed by SHA-256. Import verifies and stores them, then drops this field.
380
388
 
@@ -511,8 +519,9 @@ for (const stage of stages.filter((session) => session.internal)) {
511
519
  - `getTree()` - Get full tree structure
512
520
  - `getChildren(parentId)` - Get direct children
513
521
  - `getLabel(id)` - Get label for entry
514
- - `branch(entryId)` - Move leaf to earlier entry
515
- - `resetLeaf()` - Reset leaf to null (before any entries)
522
+ - `branch(entryId)` - Move leaf to earlier entry, in memory only; the session reopens at its last entry
523
+ - `resetLeaf()` - Reset leaf to null (before any entries), in memory only
524
+ - `recordBranch(entryId | null)` - Move the leaf like `branch()` (or `resetLeaf()` for `null`) and save the move, so the session reopens there
516
525
  - `branchWithSummary(entryId, summary, details?, fromHook?)` - Branch with context summary
517
526
 
518
527
  ### Instance Methods - Context & Info
package/docs/sessions.md CHANGED
@@ -113,7 +113,7 @@ An extension that calls `ctx.switchSession()` is asked the same way only when At
113
113
 
114
114
  Known limitation: at startup in the default interactive mode, choosing **Continue** ends with `Stored session working directory does not exist`. Choose **Fork** instead, or start Atomic from a directory that exists and open the session with `/resume`, where **Continue** works.
115
115
 
116
- A session that recorded [worktree snapshots](/worktree-snapshots) is checked against its last snapshot when it resumes. When its checkout is still the one it worked in on this machine, the session continues there without any notice, even when the checkout changed since the snapshot. When its checkout does not exist on this machine, or another clone sits at its path, Atomic restores the snapshot into a fresh worktree under `~/.atomic/agent/worktree-snapshots/`, prints one line naming it, and runs the session there. A session an earlier resume moved into such a worktree, and that did no work there since, returns to the checkout it came from once that checkout is back on this machine. `/session snapshot` shows the recorded snapshots and how they differ from the current tree.
116
+ A session that recorded [worktree snapshots](/worktree-snapshots) is checked against its last snapshot when it resumes. When its checkout is still the one it worked in on this machine, the session continues there without any notice, even when the checkout changed since the snapshot. When its checkout does not exist on this machine, or another clone sits at its path, Atomic restores the snapshot into a fresh worktree under `~/.atomic/agent/worktree-snapshots/`, prints one line naming it, and runs the session there. A session an earlier resume moved into such a worktree, and that did no work there since, returns to the checkout it came from once that checkout is back on this machine. A resume always opens the session: when the snapshot cannot be restored exactly, for example because its unpushed commits are not on any remote or Git is unavailable, Atomic restores the closest state it can, or continues without the checkout, and shows one notice saying what is missing and what to do (see [Worktree snapshots](/worktree-snapshots#resuming)). `/session snapshot` shows the recorded snapshots, how they differ from the current tree, and what a resume could not restore.
117
117
 
118
118
  When resuming takes a noticeable while, for example to load a long history or check several checkouts, the terminal lists the steps (`Loading the session history (0.6 s)…`, `Checking 6 checkouts against the session's snapshots…`, `Restoring … from snapshot …`) before the TUI appears. A history of 100,000 entries or more is announced before it is read (`Loading the session history (150000 entries)…`); any other step that blocks the terminal is listed with its duration as soon as it ends. Quick resumes print nothing.
119
119
 
@@ -160,7 +160,7 @@ Each row shows a short generated description of what the session was about in it
160
160
 
161
161
  A summary describes the conversation up to a specific message and remains visible as newer messages arrive. A later branch summary retires it. "No summary available." means no summary has been generated for the current branch, generation failed, or it is still in flight. The session name and first message are never displaced by a summary, and the column only appears once at least one listed session has a summary. Summaries are also searchable along with the rest of the session text.
162
162
 
163
- Generation is best-effort and never blocks a turn or quitting. Opening or resuming a session in interactive or RPC mode also schedules generation if its summary is missing or stale. Atomic skips very short sessions, workflow stage sessions, and `--print` and JSON modes. It cancels generation when you send the next message, switch sessions, or quit; failures are silent. Set `sessionSummary.enabled` to `false` to disable it.
163
+ Generation is best-effort and never blocks a turn or quitting. Opening or resuming a session in interactive or RPC mode also schedules generation if its summary is missing or stale. Atomic generates summaries only for saved sessions, so `--no-session` sessions never send a summary request. It also skips very short sessions, workflow stage sessions, and `--print` and JSON modes. The summary request's tokens and cost count toward the footer usage and `/session` as soon as the summary is saved. It cancels generation when you send the next message, switch sessions, or quit; failures are silent. Set `sessionSummary.enabled` to `false` to disable it.
164
164
 
165
165
  You can search, navigate, or cancel while the picker loads sessions. Closing it cancels the scan.
166
166
 
@@ -253,6 +253,8 @@ Selecting an assistant, tool, compaction, or other non-user entry:
253
253
 
254
254
  Selecting the root user message resets the leaf to an empty conversation and places the original prompt in the editor.
255
255
 
256
+ The chat, the tree's current marker, `/session`, and the context indicator switch to the selected branch as soon as you navigate. The move is saved, so quitting, resuming, or continuing the session before you send another message reopens it on the selected branch, and the abandoned turns stay out of the next request. Workflow runs started on the abandoned branch keep running and stay listed for the session. While a branch summary is being generated, Escape cancels it and reopens the tree at your selection.
257
+
256
258
  ## `/tree`, `/fork`, and `/clone`
257
259
 
258
260
  | Feature | `/tree` | `/fork` | `/clone` |
package/docs/settings.md CHANGED
@@ -378,7 +378,7 @@ Both fields must be non-negative safe integers, including ordinary settings. Inv
378
378
 
379
379
  | Setting | Type | Default | Description |
380
380
  |---------|------|---------|-------------|
381
- | `sessionSummary.enabled` | boolean | `true` | Generate a one-line summary of each session for the `/resume` picker once the agent goes idle |
381
+ | `sessionSummary.enabled` | boolean | `true` | Generate a one-line summary of each saved session for the `/resume` picker once the agent goes idle. `--no-session` sessions never generate one |
382
382
 
383
383
  ### Resume
384
384
 
@@ -2464,12 +2464,12 @@ function listForkPoints(runId: string, options?: ListForkPointsOptions): AsyncIt
2464
2464
  interface ForkPoint {
2465
2465
  stagePath: string;
2466
2466
  sessionId?: string; // the stage's agent session, when it ran one
2467
- entryId?: string; // the last entry of that session
2467
+ entryId?: string; // the entry that session continues from
2468
2468
  completedAt: number;
2469
2469
  }
2470
2470
  ```
2471
2471
 
2472
- Lists the completed stages of a durable run that `forkRun` can fork from, in completion order. It only reads: the run is not claimed. `sessionId` and `entryId` are present for stages that ran an agent session and feed `forkFromSessionId` / `forkFromEntryId`; `entryId` is the last entry recorded in that session, which can be a label or other metadata entry rather than a message. Options select the journal (`journal`, `store`), the directory, and the `sourceSessionStore` that holds the run's stage sessions (omitted: the run's project store). Worker conversations absent from that store are read automatically from the journal. A session missing from both rejects with `ForkSessionNotFoundError`; a store that cannot be read rejects with the retryable `ForkSessionUnavailableError`. A nested run's id rejects with `ForkSourceNotFoundError` (`reason: "not-root"`) naming its root run.
2472
+ Lists the completed stages of a durable run that `forkRun` can fork from, in completion order. It only reads: the run is not claimed. `sessionId` and `entryId` are present for stages that ran an agent session and feed `forkFromSessionId` / `forkFromEntryId`; `entryId` is the entry that session continues from: its last entry, which can be a label or other metadata entry rather than a message, or the entry `/tree` last moved the session to without a summary. Options select the journal (`journal`, `store`), the directory, and the `sourceSessionStore` that holds the run's stage sessions (omitted: the run's project store). Worker conversations absent from that store are read automatically from the journal. A session missing from both rejects with `ForkSessionNotFoundError`; a store that cannot be read rejects with the retryable `ForkSessionUnavailableError`. A nested run's id rejects with `ForkSourceNotFoundError` (`reason: "not-root"`) naming its root run.
2473
2473
 
2474
2474
  ### Fork errors
2475
2475
 
@@ -72,17 +72,24 @@ When a session resumes, Atomic checks every checkout the session recorded a snap
72
72
  - A session that an earlier resume moved into a restored worktree, and that has not worked in it since, returns to the checkout it was restored from when that checkout is on this machine again, with a notice that says whether it still matches the snapshot.
73
73
  - If another checkout drifted, or the checkout that contains the working directory does not exist on this machine, belongs to another clone, or is no longer a repository with commits, Atomic restores its snapshot automatically into a fresh worktree under `~/.atomic/agent/worktree-snapshots/worktrees/`, prints one line per restored checkout, and continues the session there. Your own checkout is never written to. The lines, and any restore warnings, appear at startup and after `/resume` or `/import` in the TUI, and the session records the warnings with each restore.
74
74
  - A checkout other than the one that contains the session's working directory never stops the resume. One the session worked in on this machine (a sibling worktree, for example) that changed since its snapshot continues as it is. One that is missing, or that another clone holds at its path, is restored into a fresh worktree when Git is available. One that cannot be checked or restored is left out, and a warning names its path, its snapshot and why. Each restored worktree then gets its [blueprints](/guides/resume-on-any-machine) built, and a blueprint step that fails never leaves a checkout out or removes its worktree: it is a warning, and the resume continues.
75
- - If the snapshot of a checkout that contains the session's working directory cannot be restored (for example, its unpushed commits touched denied paths, a remote is unreachable, or a blob is missing), nothing is restored for those checkouts and the resume fails with `WorkspaceDriftError` (`reason: "restore-failed"`). Its message names what failed (the commits, remote, or blob), its `hint` is the fix, `restoreCode` is the failure's code, and `cause` is the typed failure. A session that refers to a snapshot it holds no record of fails with `snapshot-not-found`. In the TUI, a `/resume` or `/import` that fails this way shows the error and keeps the current session.
75
+ - A resume always opens the session with its full conversation. When a checkout's snapshot cannot be restored exactly (its unpushed commits touched denied paths or were too large to record, a remote is unreachable, a blob is missing or damaged, or a change set does not apply), Atomic restores the best state this machine can reach into a fresh worktree, trying in order:
76
+ 1. the recorded `HEAD` with the snapshot's change sets that apply, each one whole or not at all, up to the first that does not;
77
+ 2. else the commit closest to the recorded `HEAD` that it can fetch from the recorded remotes: the pushed commit the snapshot's unpushed commits were built on, when the bundle is readable, then the commit of an earlier snapshot of the same checkout, then the tip of the recorded branch (the remote's default branch for a detached `HEAD`);
78
+ 3. else nothing: the session continues in its recorded working directory, used as it is and never written to, or, when that directory is not on this machine, in the directory the resume started from. Git being unavailable on this machine, and a session that refers to a snapshot it holds no record of, end here too.
79
+
80
+ Each such checkout gets one notice, at startup and after `/resume` or `/import`, that says what was restored, what is missing (commits, change sets and the files they touch) and the next step, for example `Restored /work/app into ~/.atomic/agent/worktree-snapshots/worktrees/… at 3f2a9c1d7b04, the tip of branch main on its remote, instead of the recorded commit 8e0b51c2a7d6, the closest commit available here. Not restored: 1 commit (8e0b51c2a7d6) and the snapshot's uncommitted changes of snapshot 5c1d…. Push commit 8e0b51c2a7d6… (with its history) to a recorded remote, then retry.` A resume that restores everything shows no such notice. The session records the outcome on the restore entry (`restore.degraded`) or, when nothing was restored, as an `unrestored` entry, and `/session snapshot` shows it under the checkout. A later snapshot in a partly restored worktree records the tree and commit it holds, never the original snapshot's, so it never presents a partial restore as the original state; the original snapshot stays the checkout's latest until then, and a later resume on a machine that can reach it restores it fully.
81
+
82
+ Only three things refuse a resume: a session that cannot be read, a snapshot record that fails the security checks below (`invalid-snapshot`, for example a remote with credentials or a Git remote helper), and a restore target that holds other files (`unsafe-target`). Restores never write into an existing checkout, and a checkout with uncommitted changes is used only when you choose it. A refused resume fails with that error; in the TUI, a `/resume` or `/import` that fails this way shows the error and keeps the current session.
76
83
 
77
84
  A working directory reached through a symbolic link is matched by the directory the link points at, because snapshot roots are Git's physical top-level directories.
78
85
 
79
- Restored worktrees share one object store per repository on each host (`~/.atomic/agent/worktree-snapshots/repositories/`), so many restores of one base cost about one base plus their deltas. The session records the old-to-new root mapping (`SessionManager.getWorktreeRootMappings()`), and later resumes keep using the new root.
86
+ Restored worktrees share one object store per repository on each host (`~/.atomic/agent/worktree-snapshots/repositories/`), so many restores of one base cost about one base plus their deltas. That store has the snapshot's recorded remotes, the first named `origin`, the next `origin-2`, and so on, with the credential-free URLs the snapshot recorded, so `git fetch` and `git push` work in a restored worktree once you have access. Remotes are configured only when every recorded remote is a local path, an scp-like `host:path`, or an `https`, `http`, `ssh`, `git` or `file` URL without credentials; otherwise, and for a repository without remotes, the store has none. Commits a recorded remote is known to have, the ones the restore fetched and those the snapshot recorded as pushed, get remote-tracking refs under `refs/remotes/atomic/pushed/`. A snapshot captured in a restored worktree therefore records the same remotes and bundles only the commits that are really unpushed, so a session can move across any number of machines; commits that only a bundle carried stay unpushed. The session records the old-to-new root mapping (`SessionManager.getWorktreeRootMappings()`), and later resumes keep using the new root.
80
87
 
81
88
  A checkout matches its snapshot when every file of the recorded tree has the recorded content and `HEAD` is the recorded commit; `verifyWorktree` checks exactly that, while resume also accepts a `HEAD` that descends from the recorded commit over the same tree. Unchanged recorded files are compared even when this host's excludes or size settings would leave them out; those settings only decide whether a file the snapshot never had counts as a change. A recorded file whose content changed and that is now left out, for example because it grew past `snapshots.maxFileBytes` or is listed in `.atomic/snapshot-ignore`, counts as drift. A checkout whose repository does not hold the recorded tree is treated as drifted and restored.
82
89
 
83
90
  A restore builds the worktree under a staging directory, verifies it there, and only then moves it to its final path, so a final path never holds an unverified worktree. If the process is killed mid-restore, the staging worktree stays behind with a crash record under `~/.atomic/agent/worktree-snapshots/restores/`. The next restore or `removeRestoredWorktree` on that host removes it once the crash record's lock is stale, 30 seconds after the process stopped. A leftover that cannot be removed is reported once as the `stale-restore-retained` warning naming its path, with `kind` saying what it is: a staging or nested `worktree` (remove it with `removeRestoredWorktree` or delete the directory), a crash `record` file that cannot be read (delete the file), or the crash-record directory itself, `records-directory` (make it readable or remove it).
84
91
 
85
- Snapshot records come from storage and from imported session files, so restore and verification check each record before running anything. Remotes must be URLs or paths (never a value starting with `-`, never control characters), and commits, trees, blob hashes, and the snapshot id must have the form Atomic writes. A record that does not fails with `invalid-snapshot`, which names the field but not its value. Restore fetches only over `https`, `http`, `ssh`, `git`, and local paths; Git remote helpers such as `ext::` are refused.
92
+ Snapshot records come from storage and from imported session files, so restore and verification check each record before running anything. Remotes must be local paths, scp-like `host:path` remotes, or `https`, `http`, `ssh`, `git` or `file` URLs without credentials (never a value starting with `-`, never control characters, never a Git remote helper such as `ext::`), and commits, trees, blob hashes, and the snapshot id must have the form Atomic writes. A record that does not fails with `invalid-snapshot`, which names the field but not its value. Restore fetches only over `https`, `http`, `ssh`, `git`, and local paths.
86
93
 
87
94
  Restore fetches never wait for input. On Linux and macOS they run without a terminal, so an unknown host key, a passphrase, or a credential prompt fails at once as `commits-unavailable` (`reason: "not-fetched"`) instead of waiting. Unless you configured your own ssh command (`GIT_SSH_COMMAND`, `GIT_SSH`, or `core.sshCommand`), ssh runs with `BatchMode=yes` and a 15-second connect timeout. To fix such a failure, run `git ls-remote <remote>` once yourself to accept the host key or unlock the key, then resume again.
88
95
 
@@ -144,8 +151,9 @@ if (capture.status === "captured" || capture.status === "unchanged") {
144
151
 
145
152
  - `captureWorktreeSnapshot(dir, { settings?, previous?, blobs?, signal? })` resolves `captured`, `unchanged`, `disabled`, or `unavailable` with the typed reason (`GitUnavailableError` or `WorkspaceSnapshotError`).
146
153
  - `restoreWorktreeSnapshot(bindingOrSnapshot, { into?, blobs?, snapshots?, storeDir?, onWarning?, signal?, git? })` resolves to the path of a new, verified worktree. `git` (`{ path, env }`) runs that Git executable for the restore instead of the one snapshot operations resolve. `into` must be a new or empty directory. A binding is restored from a matching entry of `snapshots`, or from a host whose object store already holds its tree. Restore checks the target and every blob before writing, and removes what it created when it fails. `onWarning` receives `omitted-content`, `filters`, `lfs-objects-unavailable` (LFS files left as pointers), and `stale-restore-retained` (an interrupted earlier restore that could not be cleaned up, with its `kind`).
154
+ - `restoreDegradedWorktree(snapshot, failure, { blobs?, storeDir?, candidates?, onWarning?, signal?, git? })` restores the best state of `snapshot` this host can reach after `restoreWorktree` rejected with `failure` (a `WorkspaceRestoreError` that `isDegradableRestoreFailure` accepts: `blob-missing`, `blob-corrupt`, `commits-unavailable`, `delta-failed` or `tree-mismatch`), as a resume does: the recorded `HEAD` with the change sets that apply, else the closest commit it can fetch, trying the snapshot's pushed base, then `candidates` (commit ids, nearest first), then the recorded branch's tip. It resolves `{ path, degraded, warnings }`, where `degraded` (`WorktreeDegradedRestore`) says what the worktree holds (`stage`, `head`, `tree`, `basis`) and what is missing (`missingLinks`, `missingPaths`, `missingCommits`, with the failure's `cause` and `hint`). It rejects with `failure` when no commit is reachable, and with `invalid-snapshot` for a record that fails the security checks.
147
155
  - `verifyWorktree(binding, dir, { settings?, signal? })` resolves to the checkout's current binding when its `HEAD` and tree match, and rejects with `WorkspaceDriftError` otherwise.
148
- - `openSessionInWorktree(sessionManager, { settings, storeDir?, signal?, beforeRecord?, pendingMappings?, keepInPlace? })` checks every recorded checkout and restores drifted or missing ones without building blueprints. It resolves `{ sessionManager, notices }` with the session reopened where it continues and one notice per restored checkout, followed by its warnings. `beforeRecord(mappings)` runs once every checkout is restored, with the mappings of the restored ones (none when nothing needed restoring), and before any restore is recorded in the session; when it rejects, nothing is recorded and the restored worktrees are removed. `pendingMappings` names checkouts already here that the session continues in: they count as recorded while deciding what to restore, and are recorded with the restores only when everything succeeded. `keepInPlace` is a set of checkout roots, after the session's recorded restores, to continue in as they are without verifying them. `resumeSessionWorktree` does the same without reopening the session. For normal SDK resume, pass the stored session directly to `createAgentSession({ sessionManager })`, which checks restore prerequisites and builds blueprints as described in [Resume on any machine](/guides/resume-on-any-machine).
156
+ - `openSessionInWorktree(sessionManager, { settings, storeDir?, signal?, beforeRecord?, pendingMappings?, keepInPlace? })` checks every recorded checkout and restores drifted or missing ones without building blueprints. It resolves `{ sessionManager, notices }` with the session reopened where it continues and one notice per restored checkout, followed by its warnings. `beforeRecord(mappings)` runs once every checkout is restored, with the mappings of the restored ones (none when nothing needed restoring), and before any restore is recorded in the session; when it rejects, nothing is recorded and the restored worktrees are removed. `pendingMappings` names checkouts already here that the session continues in: they count as recorded while deciding what to restore, and are recorded with the restores only when everything succeeded. `keepInPlace` is a set of checkout roots, after the session's recorded restores, to continue in as they are without verifying them. A checkout whose exact restore fails is restored as `restoreDegradedWorktree` does, and recorded with `restore.degraded`; one of which nothing can be restored, or that `cannotRestore` (roots to the reason, such as a `GitUnavailableError`) names, is left out and recorded as `unrestored`, and the session continues in its recorded directory, or in `fallbackCwd` when that is not here. The result lists those in `unrestored`. With `skipMissingRecords`, a checkout whose latest snapshot the session holds no record of is left out and listed in `missingRecords` instead of failing with `snapshot-not-found`. Only `invalid-snapshot`, `unsafe-target`, and failures that are not about a checkout reject. `resumeSessionWorktree` does the same without reopening the session. For normal SDK resume, pass the stored session directly to `createAgentSession({ sessionManager })`, which checks restore prerequisites and builds blueprints as described in [Resume on any machine](/guides/resume-on-any-machine).
149
157
  - `isHeadOnlyAdvance(driftError, signal?)` resolves `true` when a `WorkspaceDriftError` from `verifyWorktree` only moved `HEAD` forward over the recorded tree, the case resume continues in place.
150
158
  - `canonicalizeWorktreePath(path)` resolves the symbolic links in the existing part of a path and keeps the rest, the form snapshot roots are compared in.
151
159
  - `removeRestoredWorktree(path, { storeDir?, onWarning?, signal? })` removes a worktree a restore created, for rolling back a restore of several checkouts. It refuses any other path, including a regular file.
@@ -174,6 +182,6 @@ Every error except `GitUnavailableError` extends `WorkspaceError`, the family th
174
182
  | `WorkspaceRestoreError` | `tree-mismatch` | The materialized worktree's tree differs from the snapshot | `target`, `expectedTree`, `actualTree` | Check the repository's `.gitattributes` filters on this host, then retry |
175
183
  | `WorkspaceRestoreError` | `unsafe-target` | `into` exists and is not an empty directory (`reason: "not-empty"`), or `removeRestoredWorktree` was given a path no restore created (`reason: "not-restored"`) | `target`, `reason` | Choose a new or empty directory, or omit `into`; remove only paths a restore returned |
176
184
  | `WorkspaceRestoreError` | `unwritable-path` | A restore or `removeRestoredWorktree` could not write a directory or file it needs, for example because the disk is full or the directory is read-only | `target`, `snapshotId`; `cause` holds the filesystem error | Free space on that volume, or make the path and its parent writable, then retry |
177
- | `WorkspaceRestoreError` | `invalid-snapshot` | A snapshot or binding record has a value Atomic never writes: a remote starting with `-` or holding control characters, or a malformed commit, tree, blob hash, or id | `snapshotId` (when the id itself is valid), `field`, `reason` (`unsafe-remote`, `invalid-object-id`, `invalid-snapshot-id`, `invalid-blob-hash`) | Restore only sessions and runs from storage you trust, or export the session again on the machine that recorded it |
185
+ | `WorkspaceRestoreError` | `invalid-snapshot` | A snapshot or binding record has a value Atomic never writes: a remote starting with `-`, holding control characters or credentials, naming a Git remote helper, or using another scheme than `https`, `http`, `ssh`, `git` or `file`, or a malformed commit, tree, blob hash, or id | `snapshotId` (when the id itself is valid), `field`, `reason` (`unsafe-remote`, `invalid-object-id`, `invalid-snapshot-id`, `invalid-blob-hash`) | Restore only sessions and runs from storage you trust, or export the session again on the machine that recorded it |
178
186
  | `WorkspaceDriftError` | `tree-drift` | A checkout no longer matches the snapshot work would resume from, and it could not be restored | `root`, `expectedHead`, `actualHead`, `expectedTree`, `actualTree`, `snapshotId`; with `reason: "restore-failed"`, `restoreCode` and the failure as `cause` | Follow the hint: after a failed restore it is the failure's own fix |
179
187
  | `WorkspaceCollectionError` | `collection-failed` | Collecting unreferenced snapshot content failed in the database; nothing a retained snapshot needs was deleted. `retryable: true` | `table`, `phase` (`claim`, `index`, `sweep`, `record`), `deleted` (blobs deleted before the failure); `cause` holds the storage error | Check that the database is writable, has free space and is not locked by a stopped process. Collection retries after `snapshots.collectIntervalSeconds`, or call `collectSnapshotGarbage` |
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.84",
3
+ "version": "0.9.85-alpha.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bastani/atomic",
9
- "version": "0.9.84",
9
+ "version": "0.9.85-alpha.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@bastani/atomic-natives": "0.9.84",
13
- "@bastani/pi-ai": "0.9.84",
12
+ "@bastani/atomic-natives": "0.9.85-alpha.1",
13
+ "@bastani/pi-ai": "0.9.85-alpha.1",
14
14
  "@earendil-works/pi-agent-core": "1.5.2",
15
15
  "@earendil-works/pi-codemode": "1.5.2",
16
16
  "@earendil-works/pi-tui": "1.5.2",
@@ -427,18 +427,18 @@
427
427
  }
428
428
  },
429
429
  "node_modules/@bastani/atomic-natives": {
430
- "version": "0.9.84",
431
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.84.tgz",
430
+ "version": "0.9.85-alpha.1",
431
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.85-alpha.1.tgz",
432
432
  "license": "MIT",
433
433
  "optionalDependencies": {
434
- "@bastani/atomic-natives-darwin-arm64": "0.9.84",
435
- "@bastani/atomic-natives-darwin-x64": "0.9.84",
436
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.84",
437
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.84",
438
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.84",
439
- "@bastani/atomic-natives-linux-x64-musl": "0.9.84",
440
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.84",
441
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.84"
434
+ "@bastani/atomic-natives-darwin-arm64": "0.9.85-alpha.1",
435
+ "@bastani/atomic-natives-darwin-x64": "0.9.85-alpha.1",
436
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.85-alpha.1",
437
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.85-alpha.1",
438
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.85-alpha.1",
439
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.85-alpha.1",
440
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.85-alpha.1",
441
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.85-alpha.1"
442
442
  },
443
443
  "engines": {
444
444
  "bun": ">=1.4.2",
@@ -446,8 +446,8 @@
446
446
  }
447
447
  },
448
448
  "node_modules/@bastani/atomic-natives-darwin-arm64": {
449
- "version": "0.9.84",
450
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.84.tgz",
449
+ "version": "0.9.85-alpha.1",
450
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.85-alpha.1.tgz",
451
451
  "license": "MIT",
452
452
  "os": [
453
453
  "darwin"
@@ -458,8 +458,8 @@
458
458
  "optional": true
459
459
  },
460
460
  "node_modules/@bastani/atomic-natives-darwin-x64": {
461
- "version": "0.9.84",
462
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.84.tgz",
461
+ "version": "0.9.85-alpha.1",
462
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.85-alpha.1.tgz",
463
463
  "license": "MIT",
464
464
  "os": [
465
465
  "darwin"
@@ -470,8 +470,8 @@
470
470
  "optional": true
471
471
  },
472
472
  "node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
473
- "version": "0.9.84",
474
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.84.tgz",
473
+ "version": "0.9.85-alpha.1",
474
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.85-alpha.1.tgz",
475
475
  "license": "MIT",
476
476
  "os": [
477
477
  "linux"
@@ -485,8 +485,8 @@
485
485
  "optional": true
486
486
  },
487
487
  "node_modules/@bastani/atomic-natives-linux-arm64-musl": {
488
- "version": "0.9.84",
489
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.84.tgz",
488
+ "version": "0.9.85-alpha.1",
489
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.85-alpha.1.tgz",
490
490
  "license": "MIT",
491
491
  "os": [
492
492
  "linux"
@@ -500,8 +500,8 @@
500
500
  "optional": true
501
501
  },
502
502
  "node_modules/@bastani/atomic-natives-linux-x64-gnu": {
503
- "version": "0.9.84",
504
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.84.tgz",
503
+ "version": "0.9.85-alpha.1",
504
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.85-alpha.1.tgz",
505
505
  "license": "MIT",
506
506
  "os": [
507
507
  "linux"
@@ -515,8 +515,8 @@
515
515
  "optional": true
516
516
  },
517
517
  "node_modules/@bastani/atomic-natives-linux-x64-musl": {
518
- "version": "0.9.84",
519
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.84.tgz",
518
+ "version": "0.9.85-alpha.1",
519
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.85-alpha.1.tgz",
520
520
  "license": "MIT",
521
521
  "os": [
522
522
  "linux"
@@ -530,8 +530,8 @@
530
530
  "optional": true
531
531
  },
532
532
  "node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
533
- "version": "0.9.84",
534
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.84.tgz",
533
+ "version": "0.9.85-alpha.1",
534
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.85-alpha.1.tgz",
535
535
  "license": "MIT",
536
536
  "os": [
537
537
  "win32"
@@ -542,8 +542,8 @@
542
542
  "optional": true
543
543
  },
544
544
  "node_modules/@bastani/atomic-natives-win32-x64-msvc": {
545
- "version": "0.9.84",
546
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.84.tgz",
545
+ "version": "0.9.85-alpha.1",
546
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.85-alpha.1.tgz",
547
547
  "license": "MIT",
548
548
  "os": [
549
549
  "win32"
@@ -554,8 +554,8 @@
554
554
  "optional": true
555
555
  },
556
556
  "node_modules/@bastani/pi-ai": {
557
- "version": "0.9.84",
558
- "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.84.tgz",
557
+ "version": "0.9.85-alpha.1",
558
+ "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.85-alpha.1.tgz",
559
559
  "license": "MIT",
560
560
  "dependencies": {
561
561
  "@anthropic-ai/sdk": "0.129.0",