heyhank 0.1.0

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 (199) hide show
  1. package/README.md +40 -0
  2. package/bin/cli.ts +168 -0
  3. package/bin/ctl.ts +528 -0
  4. package/bin/generate-token.ts +28 -0
  5. package/dist/apple-touch-icon.png +0 -0
  6. package/dist/assets/AgentsPage-BPhirnCe.js +7 -0
  7. package/dist/assets/AssistantPage-DJ-cMQfb.js +1 -0
  8. package/dist/assets/CronManager-DDbz-yiT.js +1 -0
  9. package/dist/assets/HelpPage-DMfkzERp.js +1 -0
  10. package/dist/assets/IntegrationsPage-CrOitCmJ.js +1 -0
  11. package/dist/assets/MediaPage-CE5rdvkC.js +1 -0
  12. package/dist/assets/PlatformDashboard-Do6F0O2p.js +1 -0
  13. package/dist/assets/Playground-Fc5cdc5p.js +109 -0
  14. package/dist/assets/ProcessPanel-CslEiZkI.js +2 -0
  15. package/dist/assets/PromptsPage-D2EhsdNO.js +4 -0
  16. package/dist/assets/RunsPage-C5BZF5Rx.js +1 -0
  17. package/dist/assets/SandboxManager-a1AVI5q2.js +8 -0
  18. package/dist/assets/SettingsPage-DirhjQrJ.js +51 -0
  19. package/dist/assets/SocialMediaPage-DBuM28vD.js +1 -0
  20. package/dist/assets/TailscalePage-CHiFhZXF.js +1 -0
  21. package/dist/assets/TelephonyPage-x0VV0fOo.js +1 -0
  22. package/dist/assets/TerminalPage-Drwyrnfd.js +1 -0
  23. package/dist/assets/gemini-audio-t-TSU-To.js +17 -0
  24. package/dist/assets/gemini-live-client-C7rqAW7G.js +166 -0
  25. package/dist/assets/index-C8M_PUmX.css +32 -0
  26. package/dist/assets/index-CEqZnThB.js +204 -0
  27. package/dist/assets/sw-register-LSSpj6RU.js +1 -0
  28. package/dist/assets/time-ago-B6r_l9u1.js +1 -0
  29. package/dist/assets/workbox-window.prod.es5-BIl4cyR9.js +2 -0
  30. package/dist/favicon-32-original.png +0 -0
  31. package/dist/favicon-32.png +0 -0
  32. package/dist/favicon.ico +0 -0
  33. package/dist/favicon.svg +8 -0
  34. package/dist/fonts/MesloLGSNerdFontMono-Bold.woff2 +0 -0
  35. package/dist/fonts/MesloLGSNerdFontMono-Regular.woff2 +0 -0
  36. package/dist/heyhank-mascot-poster.png +0 -0
  37. package/dist/heyhank-mascot.mp4 +0 -0
  38. package/dist/heyhank-mascot.webm +0 -0
  39. package/dist/icon-192-original.png +0 -0
  40. package/dist/icon-192.png +0 -0
  41. package/dist/icon-512-original.png +0 -0
  42. package/dist/icon-512.png +0 -0
  43. package/dist/index.html +21 -0
  44. package/dist/logo-192.png +0 -0
  45. package/dist/logo-512.png +0 -0
  46. package/dist/logo-codex.svg +14 -0
  47. package/dist/logo-docker.svg +4 -0
  48. package/dist/logo-original.png +0 -0
  49. package/dist/logo.png +0 -0
  50. package/dist/logo.svg +14 -0
  51. package/dist/manifest.json +24 -0
  52. package/dist/push-sw.js +34 -0
  53. package/dist/sw.js +1 -0
  54. package/dist/workbox-d2a0910a.js +1 -0
  55. package/package.json +109 -0
  56. package/server/agent-cron-migrator.ts +85 -0
  57. package/server/agent-executor.ts +357 -0
  58. package/server/agent-store.ts +185 -0
  59. package/server/agent-timeout.ts +107 -0
  60. package/server/agent-types.ts +122 -0
  61. package/server/ai-validation-settings.ts +37 -0
  62. package/server/ai-validator.ts +181 -0
  63. package/server/anthropic-provider-migration.ts +48 -0
  64. package/server/assistant-store.ts +272 -0
  65. package/server/auth-manager.ts +150 -0
  66. package/server/auto-approve.ts +153 -0
  67. package/server/auto-namer.ts +36 -0
  68. package/server/backend-adapter.ts +54 -0
  69. package/server/cache-headers.ts +61 -0
  70. package/server/calendar-service.ts +434 -0
  71. package/server/claude-adapter.ts +889 -0
  72. package/server/claude-container-auth.ts +30 -0
  73. package/server/claude-session-discovery.ts +157 -0
  74. package/server/claude-session-history.ts +410 -0
  75. package/server/cli-launcher.ts +1303 -0
  76. package/server/codex-adapter.ts +3027 -0
  77. package/server/codex-container-auth.ts +24 -0
  78. package/server/codex-home.ts +27 -0
  79. package/server/codex-ws-proxy.cjs +226 -0
  80. package/server/commands-discovery.ts +81 -0
  81. package/server/constants.ts +7 -0
  82. package/server/container-manager.ts +1053 -0
  83. package/server/cost-tracker.ts +222 -0
  84. package/server/cron-scheduler.ts +243 -0
  85. package/server/cron-store.ts +148 -0
  86. package/server/cron-types.ts +63 -0
  87. package/server/email-service.ts +354 -0
  88. package/server/env-manager.ts +161 -0
  89. package/server/event-bus-types.ts +75 -0
  90. package/server/event-bus.ts +124 -0
  91. package/server/execution-store.ts +170 -0
  92. package/server/federation/node-connection.ts +190 -0
  93. package/server/federation/node-manager.ts +366 -0
  94. package/server/federation/node-store.ts +86 -0
  95. package/server/federation/node-types.ts +121 -0
  96. package/server/fs-utils.ts +15 -0
  97. package/server/git-utils.ts +421 -0
  98. package/server/github-pr.ts +379 -0
  99. package/server/google-media.ts +342 -0
  100. package/server/image-pull-manager.ts +279 -0
  101. package/server/index.ts +491 -0
  102. package/server/internal-ai.ts +237 -0
  103. package/server/kill-switch.ts +99 -0
  104. package/server/llm-providers.ts +342 -0
  105. package/server/logger.ts +259 -0
  106. package/server/mcp-registry.ts +401 -0
  107. package/server/message-bus.ts +271 -0
  108. package/server/message-delivery.ts +128 -0
  109. package/server/metrics-collector.ts +350 -0
  110. package/server/metrics-types.ts +108 -0
  111. package/server/middleware/managed-auth.ts +195 -0
  112. package/server/novnc-proxy.ts +99 -0
  113. package/server/path-resolver.ts +186 -0
  114. package/server/paths.ts +13 -0
  115. package/server/pr-poller.ts +162 -0
  116. package/server/prompt-manager.ts +211 -0
  117. package/server/protocol/claude-upstream/README.md +19 -0
  118. package/server/protocol/claude-upstream/sdk.d.ts.txt +1943 -0
  119. package/server/protocol/codex-upstream/ClientNotification.ts.txt +5 -0
  120. package/server/protocol/codex-upstream/ClientRequest.ts.txt +60 -0
  121. package/server/protocol/codex-upstream/README.md +18 -0
  122. package/server/protocol/codex-upstream/ServerNotification.ts.txt +41 -0
  123. package/server/protocol/codex-upstream/ServerRequest.ts.txt +16 -0
  124. package/server/protocol/codex-upstream/v2/DynamicToolCallParams.ts.txt +6 -0
  125. package/server/protocol/codex-upstream/v2/DynamicToolCallResponse.ts.txt +6 -0
  126. package/server/protocol-monitor.ts +50 -0
  127. package/server/provider-manager.ts +111 -0
  128. package/server/provider-registry.ts +393 -0
  129. package/server/push-notifications.ts +221 -0
  130. package/server/recorder.ts +374 -0
  131. package/server/recording-hub/compat-validator.ts +284 -0
  132. package/server/recording-hub/diagnostics.ts +299 -0
  133. package/server/recording-hub/hub-config.ts +19 -0
  134. package/server/recording-hub/hub-routes.ts +236 -0
  135. package/server/recording-hub/hub-store.ts +265 -0
  136. package/server/recording-hub/replay-adapter.ts +207 -0
  137. package/server/relay-client.ts +320 -0
  138. package/server/reminder-scheduler.ts +38 -0
  139. package/server/replay.ts +78 -0
  140. package/server/routes/agent-routes.ts +264 -0
  141. package/server/routes/assistant-routes.ts +90 -0
  142. package/server/routes/cron-routes.ts +103 -0
  143. package/server/routes/env-routes.ts +95 -0
  144. package/server/routes/federation-routes.ts +76 -0
  145. package/server/routes/fs-routes.ts +622 -0
  146. package/server/routes/git-routes.ts +97 -0
  147. package/server/routes/llm-routes.ts +166 -0
  148. package/server/routes/media-routes.ts +135 -0
  149. package/server/routes/metrics-routes.ts +13 -0
  150. package/server/routes/platform-routes.ts +1379 -0
  151. package/server/routes/prompt-routes.ts +67 -0
  152. package/server/routes/provider-routes.ts +109 -0
  153. package/server/routes/sandbox-routes.ts +127 -0
  154. package/server/routes/settings-routes.ts +285 -0
  155. package/server/routes/skills-routes.ts +100 -0
  156. package/server/routes/socialmedia-routes.ts +208 -0
  157. package/server/routes/system-routes.ts +228 -0
  158. package/server/routes/tailscale-routes.ts +22 -0
  159. package/server/routes/telephony-routes.ts +259 -0
  160. package/server/routes.ts +1379 -0
  161. package/server/sandbox-manager.ts +168 -0
  162. package/server/service.ts +718 -0
  163. package/server/session-creation-service.ts +457 -0
  164. package/server/session-git-info.ts +104 -0
  165. package/server/session-names.ts +67 -0
  166. package/server/session-orchestrator.ts +824 -0
  167. package/server/session-state-machine.ts +207 -0
  168. package/server/session-store.ts +146 -0
  169. package/server/session-types.ts +511 -0
  170. package/server/settings-manager.ts +149 -0
  171. package/server/shared-context.ts +157 -0
  172. package/server/socialmedia/adapter.ts +15 -0
  173. package/server/socialmedia/adapters/ayrshare-adapter.ts +169 -0
  174. package/server/socialmedia/adapters/buffer-adapter.ts +299 -0
  175. package/server/socialmedia/adapters/postiz-adapter.ts +298 -0
  176. package/server/socialmedia/manager.ts +227 -0
  177. package/server/socialmedia/store.ts +98 -0
  178. package/server/socialmedia/types.ts +89 -0
  179. package/server/tailscale-manager.ts +451 -0
  180. package/server/telephony/audio-bridge.ts +331 -0
  181. package/server/telephony/call-manager.ts +457 -0
  182. package/server/telephony/call-types.ts +108 -0
  183. package/server/telephony/telephony-store.ts +119 -0
  184. package/server/terminal-manager.ts +240 -0
  185. package/server/update-checker.ts +192 -0
  186. package/server/usage-limits.ts +225 -0
  187. package/server/web-push.d.ts +51 -0
  188. package/server/worktree-tracker.ts +84 -0
  189. package/server/ws-auth.ts +41 -0
  190. package/server/ws-bridge-browser-ingest.ts +72 -0
  191. package/server/ws-bridge-browser.ts +112 -0
  192. package/server/ws-bridge-cli-ingest.ts +81 -0
  193. package/server/ws-bridge-codex.ts +266 -0
  194. package/server/ws-bridge-controls.ts +20 -0
  195. package/server/ws-bridge-persist.ts +66 -0
  196. package/server/ws-bridge-publish.ts +79 -0
  197. package/server/ws-bridge-replay.ts +61 -0
  198. package/server/ws-bridge-types.ts +121 -0
  199. package/server/ws-bridge.ts +1240 -0
@@ -0,0 +1,1943 @@
1
+ import type { BetaMessage } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
2
+ import type { BetaRawMessageStreamEvent } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
3
+ import type { BetaUsage } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
4
+ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
5
+ import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
6
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
+ import type { MessageParam } from '@anthropic-ai/sdk/resources';
8
+ import type { Readable } from 'stream';
9
+ import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
10
+ import type { UUID } from 'crypto';
11
+ import type { Writable } from 'stream';
12
+ import { z } from 'zod/v4';
13
+ import type { ZodRawShape } from 'zod';
14
+ import type { ZodRawShape as ZodRawShape_2 } from 'zod/v4';
15
+
16
+ export declare class AbortError extends Error {
17
+ }
18
+
19
+ /**
20
+ * Information about the logged in user's account.
21
+ */
22
+ export declare type AccountInfo = {
23
+ email?: string;
24
+ organization?: string;
25
+ subscriptionType?: string;
26
+ tokenSource?: string;
27
+ apiKeySource?: string;
28
+ };
29
+
30
+ /**
31
+ * Definition for a custom subagent that can be invoked via the Task tool.
32
+ */
33
+ export declare type AgentDefinition = {
34
+ /**
35
+ * Natural language description of when to use this agent
36
+ */
37
+ description: string;
38
+ /**
39
+ * Array of allowed tool names. If omitted, inherits all tools from parent
40
+ */
41
+ tools?: string[];
42
+ /**
43
+ * Array of tool names to explicitly disallow for this agent
44
+ */
45
+ disallowedTools?: string[];
46
+ /**
47
+ * The agent's system prompt
48
+ */
49
+ prompt: string;
50
+ /**
51
+ * Model to use for this agent. If omitted or 'inherit', uses the main model
52
+ */
53
+ model?: 'sonnet' | 'opus' | 'haiku' | 'inherit';
54
+ mcpServers?: AgentMcpServerSpec[];
55
+ /**
56
+ * Experimental: Critical reminder added to system prompt
57
+ */
58
+ criticalSystemReminder_EXPERIMENTAL?: string;
59
+ /**
60
+ * Array of skill names to preload into the agent context
61
+ */
62
+ skills?: string[];
63
+ /**
64
+ * Maximum number of agentic turns (API round-trips) before stopping
65
+ */
66
+ maxTurns?: number;
67
+ };
68
+
69
+ export declare type AgentMcpServerSpec = string | Record<string, McpServerConfigForProcessTransport>;
70
+
71
+ export declare type AnyZodRawShape = ZodRawShape | ZodRawShape_2;
72
+
73
+ export declare type ApiKeySource = 'user' | 'project' | 'org' | 'temporary';
74
+
75
+ export declare type AsyncHookJSONOutput = {
76
+ async: true;
77
+ asyncTimeout?: number;
78
+ };
79
+
80
+ export declare type BaseHookInput = {
81
+ session_id: string;
82
+ transcript_path: string;
83
+ cwd: string;
84
+ permission_mode?: string;
85
+ };
86
+
87
+ export declare type BaseOutputFormat = {
88
+ type: OutputFormatType;
89
+ };
90
+
91
+ /**
92
+ * Permission callback function for controlling tool usage.
93
+ * Called before each tool execution to determine if it should be allowed.
94
+ */
95
+ export declare type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
96
+ /** Signaled if the operation should be aborted. */
97
+ signal: AbortSignal;
98
+ /**
99
+ * Suggestions for updating permissions so that the user will not be
100
+ * prompted again for this tool during this session.
101
+ *
102
+ * Typically if presenting the user an option 'always allow' or similar,
103
+ * then this full set of suggestions should be returned as the
104
+ * `updatedPermissions` in the PermissionResult.
105
+ */
106
+ suggestions?: PermissionUpdate[];
107
+ /**
108
+ * The file path that triggered the permission request, if applicable.
109
+ * For example, when a Bash command tries to access a path outside allowed directories.
110
+ */
111
+ blockedPath?: string;
112
+ /** Explains why this permission request was triggered. */
113
+ decisionReason?: string;
114
+ /**
115
+ * Unique identifier for this specific tool call within the assistant message.
116
+ * Multiple tool calls in the same assistant message will have different toolUseIDs.
117
+ */
118
+ toolUseID: string;
119
+ /** If running within the context of a sub-agent, the sub-agent's ID. */
120
+ agentID?: string;
121
+ }) => Promise<PermissionResult>;
122
+
123
+ /**
124
+ * Config scope for settings.
125
+ */
126
+ export declare type ConfigScope = 'local' | 'user' | 'project';
127
+
128
+ declare type ControlErrorResponse = {
129
+ subtype: 'error';
130
+ request_id: string;
131
+ error: string;
132
+ pending_permission_requests?: SDKControlRequest[];
133
+ };
134
+
135
+ declare type ControlResponse = {
136
+ subtype: 'success';
137
+ request_id: string;
138
+ response?: Record<string, unknown>;
139
+ };
140
+
141
+ declare namespace coreTypes {
142
+ export {
143
+ SandboxSettings,
144
+ SandboxNetworkConfig,
145
+ SandboxIgnoreViolations,
146
+ NonNullableUsage,
147
+ HOOK_EVENTS,
148
+ EXIT_REASONS,
149
+ AccountInfo,
150
+ AgentDefinition,
151
+ AgentMcpServerSpec,
152
+ ApiKeySource,
153
+ AsyncHookJSONOutput,
154
+ BaseHookInput,
155
+ BaseOutputFormat,
156
+ ConfigScope,
157
+ ExitReason,
158
+ HookEvent,
159
+ HookInput,
160
+ HookJSONOutput,
161
+ JsonSchemaOutputFormat,
162
+ McpClaudeAIProxyServerConfig,
163
+ McpHttpServerConfig,
164
+ McpSSEServerConfig,
165
+ McpSdkServerConfig,
166
+ McpServerConfigForProcessTransport,
167
+ McpServerStatusConfig,
168
+ McpServerStatus,
169
+ McpSetServersResult,
170
+ McpStdioServerConfig,
171
+ ModelInfo,
172
+ ModelUsage,
173
+ NotificationHookInput,
174
+ NotificationHookSpecificOutput,
175
+ OutputFormat,
176
+ OutputFormatType,
177
+ PermissionBehavior,
178
+ PermissionMode,
179
+ PermissionRequestHookInput,
180
+ PermissionRequestHookSpecificOutput,
181
+ PermissionResult,
182
+ PermissionRuleValue,
183
+ PermissionUpdateDestination,
184
+ PermissionUpdate,
185
+ PostToolUseFailureHookInput,
186
+ PostToolUseFailureHookSpecificOutput,
187
+ PostToolUseHookInput,
188
+ PostToolUseHookSpecificOutput,
189
+ PreCompactHookInput,
190
+ PreToolUseHookInput,
191
+ PreToolUseHookSpecificOutput,
192
+ RewindFilesResult,
193
+ SDKAssistantMessageError,
194
+ SDKAssistantMessage,
195
+ SDKAuthStatusMessage,
196
+ SDKCompactBoundaryMessage,
197
+ SDKFilesPersistedEvent,
198
+ SDKHookProgressMessage,
199
+ SDKHookResponseMessage,
200
+ SDKHookStartedMessage,
201
+ SDKMessage,
202
+ SDKPartialAssistantMessage,
203
+ SDKPermissionDenial,
204
+ SDKResultError,
205
+ SDKResultMessage,
206
+ SDKResultSuccess,
207
+ SDKStatusMessage,
208
+ SDKStatus,
209
+ SDKSystemMessage,
210
+ SDKTaskNotificationMessage,
211
+ SDKToolProgressMessage,
212
+ SDKToolUseSummaryMessage,
213
+ SDKUserMessageReplay,
214
+ SDKUserMessage,
215
+ SdkBeta,
216
+ SdkPluginConfig,
217
+ SessionEndHookInput,
218
+ SessionStartHookInput,
219
+ SessionStartHookSpecificOutput,
220
+ SettingSource,
221
+ SetupHookInput,
222
+ SetupHookSpecificOutput,
223
+ SlashCommand,
224
+ StopHookInput,
225
+ SubagentStartHookInput,
226
+ SubagentStartHookSpecificOutput,
227
+ SubagentStopHookInput,
228
+ SyncHookJSONOutput,
229
+ TaskCompletedHookInput,
230
+ TeammateIdleHookInput,
231
+ UserPromptSubmitHookInput,
232
+ UserPromptSubmitHookSpecificOutput
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Creates an MCP server instance that can be used with the SDK transport.
238
+ * This allows SDK users to define custom tools that run in the same process.
239
+ *
240
+ * If your SDK MCP calls will run longer than 60s, override CLAUDE_CODE_STREAM_CLOSE_TIMEOUT
241
+ */
242
+ export declare function createSdkMcpServer(_options: CreateSdkMcpServerOptions): McpSdkServerConfigWithInstance;
243
+
244
+ declare type CreateSdkMcpServerOptions = {
245
+ name: string;
246
+ version?: string;
247
+ tools?: Array<SdkMcpToolDefinition<any>>;
248
+ };
249
+
250
+ export declare const EXIT_REASONS: readonly ["clear", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"];
251
+
252
+ export declare type ExitReason = 'clear' | 'logout' | 'prompt_input_exit' | 'other' | 'bypass_permissions_disabled';
253
+
254
+ export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest", "Setup", "TeammateIdle", "TaskCompleted"];
255
+
256
+ /**
257
+ * Hook callback function for responding to events during execution.
258
+ */
259
+ export declare type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
260
+ signal: AbortSignal;
261
+ }) => Promise<HookJSONOutput>;
262
+
263
+ /**
264
+ * Hook callback matcher containing hook callbacks and optional pattern matching.
265
+ */
266
+ export declare interface HookCallbackMatcher {
267
+ matcher?: string;
268
+ hooks: HookCallback[];
269
+ /** Timeout in seconds for all hooks in this matcher */
270
+ timeout?: number;
271
+ }
272
+
273
+ export declare type HookEvent = 'PreToolUse' | 'PostToolUse' | 'PostToolUseFailure' | 'Notification' | 'UserPromptSubmit' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'SubagentStart' | 'SubagentStop' | 'PreCompact' | 'PermissionRequest' | 'Setup' | 'TeammateIdle' | 'TaskCompleted';
274
+
275
+ export declare type HookInput = PreToolUseHookInput | PostToolUseHookInput | PostToolUseFailureHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStartHookInput | SubagentStopHookInput | PreCompactHookInput | PermissionRequestHookInput | SetupHookInput | TeammateIdleHookInput | TaskCompletedHookInput;
276
+
277
+ export declare type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
278
+
279
+ export declare type InferShape<T extends AnyZodRawShape> = {
280
+ [K in keyof T]: T[K] extends {
281
+ _output: infer O;
282
+ } ? O : never;
283
+ } & {};
284
+
285
+ export declare type JsonSchemaOutputFormat = {
286
+ type: 'json_schema';
287
+ schema: Record<string, unknown>;
288
+ };
289
+
290
+ export declare type McpClaudeAIProxyServerConfig = {
291
+ type: 'claudeai-proxy';
292
+ url: string;
293
+ id: string;
294
+ };
295
+
296
+ export declare type McpHttpServerConfig = {
297
+ type: 'http';
298
+ url: string;
299
+ headers?: Record<string, string>;
300
+ };
301
+
302
+ export declare type McpSdkServerConfig = {
303
+ type: 'sdk';
304
+ name: string;
305
+ };
306
+
307
+ /**
308
+ * MCP SDK server config with an actual McpServer instance.
309
+ * Not serializable - contains a live McpServer object.
310
+ */
311
+ export declare type McpSdkServerConfigWithInstance = McpSdkServerConfig & {
312
+ instance: McpServer;
313
+ };
314
+
315
+ /**
316
+ * Union of all MCP server config types, including those with non-serializable instances.
317
+ */
318
+ export declare type McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfigWithInstance;
319
+
320
+ export declare type McpServerConfigForProcessTransport = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig | McpSdkServerConfig;
321
+
322
+ /**
323
+ * Status information for an MCP server connection.
324
+ */
325
+ export declare type McpServerStatus = {
326
+ /**
327
+ * Server name as configured
328
+ */
329
+ name: string;
330
+ /**
331
+ * Current connection status
332
+ */
333
+ status: 'connected' | 'failed' | 'needs-auth' | 'pending' | 'disabled';
334
+ /**
335
+ * Server information (available when connected)
336
+ */
337
+ serverInfo?: {
338
+ name: string;
339
+ version: string;
340
+ };
341
+ /**
342
+ * Error message (available when status is 'failed')
343
+ */
344
+ error?: string;
345
+ /**
346
+ * Server configuration (includes URL for HTTP/SSE servers)
347
+ */
348
+ config?: McpServerStatusConfig;
349
+ /**
350
+ * Configuration scope (e.g., project, user, local, claudeai, managed)
351
+ */
352
+ scope?: string;
353
+ /**
354
+ * Tools provided by this server (available when connected)
355
+ */
356
+ tools?: {
357
+ name: string;
358
+ description?: string;
359
+ annotations?: {
360
+ readOnly?: boolean;
361
+ destructive?: boolean;
362
+ openWorld?: boolean;
363
+ };
364
+ }[];
365
+ };
366
+
367
+ export declare type McpServerStatusConfig = McpServerConfigForProcessTransport | McpClaudeAIProxyServerConfig;
368
+
369
+ /**
370
+ * Result of a setMcpServers operation.
371
+ */
372
+ export declare type McpSetServersResult = {
373
+ /**
374
+ * Names of servers that were added
375
+ */
376
+ added: string[];
377
+ /**
378
+ * Names of servers that were removed
379
+ */
380
+ removed: string[];
381
+ /**
382
+ * Map of server names to error messages for servers that failed to connect
383
+ */
384
+ errors: Record<string, string>;
385
+ };
386
+
387
+ export declare type McpSSEServerConfig = {
388
+ type: 'sse';
389
+ url: string;
390
+ headers?: Record<string, string>;
391
+ };
392
+
393
+ export declare type McpStdioServerConfig = {
394
+ type?: 'stdio';
395
+ command: string;
396
+ args?: string[];
397
+ env?: Record<string, string>;
398
+ };
399
+
400
+ /**
401
+ * Information about an available model.
402
+ */
403
+ export declare type ModelInfo = {
404
+ /**
405
+ * Model identifier to use in API calls
406
+ */
407
+ value: string;
408
+ /**
409
+ * Human-readable display name
410
+ */
411
+ displayName: string;
412
+ /**
413
+ * Description of the model's capabilities
414
+ */
415
+ description: string;
416
+ };
417
+
418
+ export declare type ModelUsage = {
419
+ inputTokens: number;
420
+ outputTokens: number;
421
+ cacheReadInputTokens: number;
422
+ cacheCreationInputTokens: number;
423
+ webSearchRequests: number;
424
+ costUSD: number;
425
+ contextWindow: number;
426
+ maxOutputTokens: number;
427
+ };
428
+
429
+ export declare type NonNullableUsage = {
430
+ [K in keyof BetaUsage]: NonNullable<BetaUsage[K]>;
431
+ };
432
+
433
+ export declare type NotificationHookInput = BaseHookInput & {
434
+ hook_event_name: 'Notification';
435
+ message: string;
436
+ title?: string;
437
+ notification_type: string;
438
+ };
439
+
440
+ export declare type NotificationHookSpecificOutput = {
441
+ hookEventName: 'Notification';
442
+ additionalContext?: string;
443
+ };
444
+
445
+ /**
446
+ * Options for the query function.
447
+ * Contains callbacks and other non-serializable fields.
448
+ */
449
+ export declare type Options = {
450
+ /**
451
+ * Controller for cancelling the query. When aborted, the query will stop
452
+ * and clean up resources.
453
+ */
454
+ abortController?: AbortController;
455
+ /**
456
+ * Additional directories Claude can access beyond the current working directory.
457
+ * Paths should be absolute.
458
+ */
459
+ additionalDirectories?: string[];
460
+ /**
461
+ * Agent name for the main thread. When specified, the agent's system prompt,
462
+ * tool restrictions, and model will be applied to the main conversation.
463
+ * The agent must be defined either in the `agents` option or in settings.
464
+ *
465
+ * This is equivalent to the `--agent` CLI flag.
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * agent: 'code-reviewer',
470
+ * agents: {
471
+ * 'code-reviewer': {
472
+ * description: 'Reviews code for best practices',
473
+ * prompt: 'You are a code reviewer...'
474
+ * }
475
+ * }
476
+ * ```
477
+ */
478
+ agent?: string;
479
+ /**
480
+ * Programmatically define custom subagents that can be invoked via the Task tool.
481
+ * Keys are agent names, values are agent definitions.
482
+ *
483
+ * @example
484
+ * ```typescript
485
+ * agents: {
486
+ * 'test-runner': {
487
+ * description: 'Runs tests and reports results',
488
+ * prompt: 'You are a test runner...',
489
+ * tools: ['Read', 'Grep', 'Glob', 'Bash']
490
+ * }
491
+ * }
492
+ * ```
493
+ */
494
+ agents?: Record<string, AgentDefinition>;
495
+ /**
496
+ * List of tool names that are auto-allowed without prompting for permission.
497
+ * These tools will execute automatically without asking the user for approval.
498
+ * To restrict which tools are available, use the `tools` option instead.
499
+ */
500
+ allowedTools?: string[];
501
+ /**
502
+ * Custom permission handler for controlling tool usage. Called before each
503
+ * tool execution to determine if it should be allowed, denied, or prompt the user.
504
+ */
505
+ canUseTool?: CanUseTool;
506
+ /**
507
+ * Continue the most recent conversation in the current directory instead of starting a new one.
508
+ * Mutually exclusive with `resume`.
509
+ */
510
+ continue?: boolean;
511
+ /**
512
+ * Current working directory for the session. Defaults to `process.cwd()`.
513
+ */
514
+ cwd?: string;
515
+ /**
516
+ * List of tool names that are disallowed. These tools will be removed
517
+ * from the model's context and cannot be used, even if they would
518
+ * otherwise be allowed.
519
+ */
520
+ disallowedTools?: string[];
521
+ /**
522
+ * Specify the base set of available built-in tools.
523
+ * - `string[]` - Array of specific tool names (e.g., `['Bash', 'Read', 'Edit']`)
524
+ * - `[]` (empty array) - Disable all built-in tools
525
+ * - `{ type: 'preset'; preset: 'claude_code' }` - Use all default Claude Code tools
526
+ */
527
+ tools?: string[] | {
528
+ type: 'preset';
529
+ preset: 'claude_code';
530
+ };
531
+ /**
532
+ * Environment variables to pass to the Claude Code process.
533
+ * Defaults to `process.env`.
534
+ *
535
+ * SDK consumers can identify their app/library to include in the User-Agent header by setting:
536
+ * - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * env: { CLAUDE_AGENT_SDK_CLIENT_APP: 'my-app/1.0.0' }
541
+ * ```
542
+ */
543
+ env?: {
544
+ [envVar: string]: string | undefined;
545
+ };
546
+ /**
547
+ * JavaScript runtime to use for executing Claude Code.
548
+ * Auto-detected if not specified.
549
+ */
550
+ executable?: 'bun' | 'deno' | 'node';
551
+ /**
552
+ * Additional arguments to pass to the JavaScript runtime executable.
553
+ */
554
+ executableArgs?: string[];
555
+ /**
556
+ * Additional CLI arguments to pass to Claude Code.
557
+ * Keys are argument names (without --), values are argument values.
558
+ * Use `null` for boolean flags.
559
+ */
560
+ extraArgs?: Record<string, string | null>;
561
+ /**
562
+ * Fallback model to use if the primary model fails or is unavailable.
563
+ */
564
+ fallbackModel?: string;
565
+ /**
566
+ * Enable file checkpointing to track file changes during the session.
567
+ * When enabled, files can be rewound to their state at any user message
568
+ * using `Query.rewindFiles()`.
569
+ *
570
+ * File checkpointing creates backups of files before they are modified,
571
+ * allowing you to restore them to previous states.
572
+ */
573
+ enableFileCheckpointing?: boolean;
574
+ /**
575
+ * When true, resumed sessions will fork to a new session ID rather than
576
+ * continuing the previous session. Use with `resume`.
577
+ */
578
+ forkSession?: boolean;
579
+ /**
580
+ * Enable beta features. Currently supported:
581
+ * - `'context-1m-2025-08-07'` - Enable 1M token context window (Sonnet 4/4.5 only)
582
+ *
583
+ * @see https://docs.anthropic.com/en/api/beta-headers
584
+ */
585
+ betas?: SdkBeta[];
586
+ /**
587
+ * Hook callbacks for responding to various events during execution.
588
+ * Hooks can modify behavior, add context, or implement custom logic.
589
+ *
590
+ * @example
591
+ * ```typescript
592
+ * hooks: {
593
+ * PreToolUse: [{
594
+ * hooks: [async (input) => ({ continue: true })]
595
+ * }]
596
+ * }
597
+ * ```
598
+ */
599
+ hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
600
+ /**
601
+ * When false, disables session persistence to disk. Sessions will not be
602
+ * saved to ~/.claude/projects/ and cannot be resumed later. Useful for
603
+ * ephemeral or automated workflows where session history is not needed.
604
+ *
605
+ * @default true
606
+ */
607
+ persistSession?: boolean;
608
+ /**
609
+ * Include partial/streaming message events in the output.
610
+ * When true, `SDKPartialAssistantMessage` events will be emitted during streaming.
611
+ */
612
+ includePartialMessages?: boolean;
613
+ /**
614
+ * Controls Claude's thinking/reasoning behavior.
615
+ *
616
+ * - `{ type: 'adaptive' }` — Claude decides when and how much to think (Opus 4.6+).
617
+ * This is the default for models that support it.
618
+ * - `{ type: 'enabled', budgetTokens: number }` — Fixed thinking token budget (older models)
619
+ * - `{ type: 'disabled' }` — No extended thinking
620
+ *
621
+ * When set, takes precedence over the deprecated `maxThinkingTokens`.
622
+ *
623
+ * @see https://docs.anthropic.com/en/docs/build-with-claude/adaptive-thinking
624
+ */
625
+ thinking?: {
626
+ type: 'adaptive';
627
+ } | {
628
+ type: 'enabled';
629
+ budgetTokens: number;
630
+ } | {
631
+ type: 'disabled';
632
+ };
633
+ /**
634
+ * Controls how much effort Claude puts into its response.
635
+ * Works with adaptive thinking to guide thinking depth.
636
+ *
637
+ * - `'low'` — Minimal thinking, fastest responses
638
+ * - `'medium'` — Moderate thinking
639
+ * - `'high'` — Deep reasoning (default)
640
+ * - `'max'` — Maximum effort (Opus 4.6 only)
641
+ *
642
+ * @see https://docs.anthropic.com/en/docs/build-with-claude/effort
643
+ */
644
+ effort?: 'low' | 'medium' | 'high' | 'max';
645
+ /**
646
+ * Maximum number of tokens the model can use for its thinking/reasoning process.
647
+ * Helps control cost and latency for complex tasks.
648
+ *
649
+ * @deprecated Use `thinking` instead. On Opus 4.6, this is treated as on/off
650
+ * (0 = disabled, any other value = adaptive). For explicit control, use
651
+ * `thinking: { type: 'adaptive' }` or `thinking: { type: 'enabled', budgetTokens: N }`.
652
+ */
653
+ maxThinkingTokens?: number;
654
+ /**
655
+ * Maximum number of conversation turns before the query stops.
656
+ * A turn consists of a user message and assistant response.
657
+ */
658
+ maxTurns?: number;
659
+ /**
660
+ * Maximum budget in USD for the query. The query will stop if this
661
+ * budget is exceeded, returning an `error_max_budget_usd` result.
662
+ */
663
+ maxBudgetUsd?: number;
664
+ /**
665
+ * MCP (Model Context Protocol) server configurations.
666
+ * Keys are server names, values are server configurations.
667
+ *
668
+ * @example
669
+ * ```typescript
670
+ * mcpServers: {
671
+ * 'my-server': {
672
+ * command: 'node',
673
+ * args: ['./my-mcp-server.js']
674
+ * }
675
+ * }
676
+ * ```
677
+ */
678
+ mcpServers?: Record<string, McpServerConfig>;
679
+ /**
680
+ * Claude model to use. Defaults to the CLI default model.
681
+ * Examples: 'claude-sonnet-4-6', 'claude-opus-4-20250514'
682
+ */
683
+ model?: string;
684
+ /**
685
+ * Output format configuration for structured responses.
686
+ * When specified, the agent will return structured data matching the schema.
687
+ *
688
+ * @example
689
+ * ```typescript
690
+ * outputFormat: {
691
+ * type: 'json_schema',
692
+ * schema: { type: 'object', properties: { result: { type: 'string' } } }
693
+ * }
694
+ * ```
695
+ */
696
+ outputFormat?: OutputFormat;
697
+ /**
698
+ * Path to the Claude Code executable. Uses the built-in executable if not specified.
699
+ */
700
+ pathToClaudeCodeExecutable?: string;
701
+ /**
702
+ * Permission mode for the session.
703
+ * - `'default'` - Standard permission behavior, prompts for dangerous operations
704
+ * - `'acceptEdits'` - Auto-accept file edit operations
705
+ * - `'bypassPermissions'` - Bypass all permission checks (requires `allowDangerouslySkipPermissions`)
706
+ * - `'plan'` - Planning mode, no execution of tools
707
+ * - `'dontAsk'` - Don't prompt for permissions, deny if not pre-approved
708
+ */
709
+ permissionMode?: PermissionMode;
710
+ /**
711
+ * Must be set to `true` when using `permissionMode: 'bypassPermissions'`.
712
+ * This is a safety measure to ensure intentional bypassing of permissions.
713
+ */
714
+ allowDangerouslySkipPermissions?: boolean;
715
+ /**
716
+ * MCP tool name to use for permission prompts. When set, permission requests
717
+ * will be routed through this MCP tool instead of the default handler.
718
+ */
719
+ permissionPromptToolName?: string;
720
+ /**
721
+ * Load plugins for this session. Plugins provide custom commands, agents,
722
+ * skills, and hooks that extend Claude Code's capabilities.
723
+ *
724
+ * Currently only local plugins are supported via the 'local' type.
725
+ *
726
+ * @example
727
+ * ```typescript
728
+ * plugins: [
729
+ * { type: 'local', path: './my-plugin' },
730
+ * { type: 'local', path: '/absolute/path/to/plugin' }
731
+ * ]
732
+ * ```
733
+ */
734
+ plugins?: SdkPluginConfig[];
735
+ /**
736
+ * Session ID to resume. Loads the conversation history from the specified session.
737
+ */
738
+ resume?: string;
739
+ /**
740
+ * Use a specific session ID for the conversation instead of an auto-generated one.
741
+ * Must be a valid UUID. Cannot be used with `continue` or `resume` unless
742
+ * `forkSession` is also set (to specify a custom ID for the forked session).
743
+ */
744
+ sessionId?: string;
745
+ /**
746
+ * When resuming, only resume messages up to and including the message with this UUID.
747
+ * Use with `resume`. This allows you to resume from a specific point in the conversation.
748
+ * The message ID should be from `SDKAssistantMessage.uuid`.
749
+ */
750
+ resumeSessionAt?: string;
751
+ /**
752
+ * Sandbox settings for command execution isolation.
753
+ *
754
+ * When enabled, commands are executed in a sandboxed environment that restricts
755
+ * filesystem and network access. This provides an additional security layer.
756
+ *
757
+ * **Important:** Filesystem and network restrictions are configured via permission
758
+ * rules, not via these sandbox settings:
759
+ * - Filesystem access: Use `Read` and `Edit` permission rules
760
+ * - Network access: Use `WebFetch` permission rules
761
+ *
762
+ * These sandbox settings control sandbox behavior (enabled, auto-allow, etc.),
763
+ * while the actual access restrictions come from your permission configuration.
764
+ *
765
+ * @example Enable sandboxing with auto-allow
766
+ * ```typescript
767
+ * sandbox: {
768
+ * enabled: true,
769
+ * autoAllowBashIfSandboxed: true
770
+ * }
771
+ * ```
772
+ *
773
+ * @example Configure network options (not restrictions)
774
+ * ```typescript
775
+ * sandbox: {
776
+ * enabled: true,
777
+ * network: {
778
+ * allowLocalBinding: true,
779
+ * allowUnixSockets: ['/var/run/docker.sock']
780
+ * }
781
+ * }
782
+ * ```
783
+ *
784
+ * @see https://docs.anthropic.com/en/docs/claude-code/settings#sandbox-settings
785
+ */
786
+ sandbox?: SandboxSettings;
787
+ /**
788
+ * Control which filesystem settings to load.
789
+ * - `'user'` - Global user settings (`~/.claude/settings.json`)
790
+ * - `'project'` - Project settings (`.claude/settings.json`)
791
+ * - `'local'` - Local settings (`.claude/settings.local.json`)
792
+ *
793
+ * When omitted or empty, no filesystem settings are loaded (SDK isolation mode).
794
+ * Must include `'project'` to load CLAUDE.md files.
795
+ */
796
+ settingSources?: SettingSource[];
797
+ /**
798
+ * Enable debug mode for the Claude Code process.
799
+ * When true, enables verbose debug logging (equivalent to `--debug` CLI flag).
800
+ * Debug logs are written to a file (see `debugFile` option) or to stderr.
801
+ *
802
+ * You can also capture debug output via the `stderr` callback.
803
+ */
804
+ debug?: boolean;
805
+ /**
806
+ * Write debug logs to a specific file path.
807
+ * Implicitly enables debug mode. Equivalent to `--debug-file <path>` CLI flag.
808
+ */
809
+ debugFile?: string;
810
+ /**
811
+ * Callback for stderr output from the Claude Code process.
812
+ * Useful for debugging and logging.
813
+ */
814
+ stderr?: (data: string) => void;
815
+ /**
816
+ * Enforce strict validation of MCP server configurations.
817
+ * When true, invalid configurations will cause errors instead of warnings.
818
+ */
819
+ strictMcpConfig?: boolean;
820
+ /**
821
+ * System prompt configuration.
822
+ * - `string` - Use a custom system prompt
823
+ * - `{ type: 'preset', preset: 'claude_code' }` - Use Claude Code's default system prompt
824
+ * - `{ type: 'preset', preset: 'claude_code', append: '...' }` - Use default prompt with appended instructions
825
+ *
826
+ * @example Custom prompt
827
+ * ```typescript
828
+ * systemPrompt: 'You are a helpful coding assistant.'
829
+ * ```
830
+ *
831
+ * @example Default with additions
832
+ * ```typescript
833
+ * systemPrompt: {
834
+ * type: 'preset',
835
+ * preset: 'claude_code',
836
+ * append: 'Always explain your reasoning.'
837
+ * }
838
+ * ```
839
+ */
840
+ systemPrompt?: string | {
841
+ type: 'preset';
842
+ preset: 'claude_code';
843
+ append?: string;
844
+ };
845
+ /**
846
+ * Custom function to spawn the Claude Code process.
847
+ * Use this to run Claude Code in VMs, containers, or remote environments.
848
+ *
849
+ * When provided, this function is called instead of the default local spawn.
850
+ * The default behavior checks if the executable exists before spawning.
851
+ *
852
+ * @example
853
+ * ```typescript
854
+ * spawnClaudeCodeProcess: (options) => {
855
+ * // Custom spawn logic for VM execution
856
+ * // options contains: command, args, cwd, env, signal
857
+ * return myVMProcess; // Must satisfy SpawnedProcess interface
858
+ * }
859
+ * ```
860
+ */
861
+ spawnClaudeCodeProcess?: (options: SpawnOptions) => SpawnedProcess;
862
+ };
863
+
864
+ export declare type OutputFormat = JsonSchemaOutputFormat;
865
+
866
+ export declare type OutputFormatType = 'json_schema';
867
+
868
+ export declare type PermissionBehavior = 'allow' | 'deny' | 'ask';
869
+
870
+ /**
871
+ * Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'delegate' - Delegate mode, restricts team leader to only Teammate and Task tools. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved.
872
+ */
873
+ export declare type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'delegate' | 'dontAsk';
874
+
875
+ export declare type PermissionRequestHookInput = BaseHookInput & {
876
+ hook_event_name: 'PermissionRequest';
877
+ tool_name: string;
878
+ tool_input: unknown;
879
+ permission_suggestions?: PermissionUpdate[];
880
+ };
881
+
882
+ export declare type PermissionRequestHookSpecificOutput = {
883
+ hookEventName: 'PermissionRequest';
884
+ decision: {
885
+ behavior: 'allow';
886
+ updatedInput?: Record<string, unknown>;
887
+ updatedPermissions?: PermissionUpdate[];
888
+ } | {
889
+ behavior: 'deny';
890
+ message?: string;
891
+ interrupt?: boolean;
892
+ };
893
+ };
894
+
895
+ export declare type PermissionResult = {
896
+ behavior: 'allow';
897
+ updatedInput?: Record<string, unknown>;
898
+ updatedPermissions?: PermissionUpdate[];
899
+ toolUseID?: string;
900
+ } | {
901
+ behavior: 'deny';
902
+ message: string;
903
+ interrupt?: boolean;
904
+ toolUseID?: string;
905
+ };
906
+
907
+ export declare type PermissionRuleValue = {
908
+ toolName: string;
909
+ ruleContent?: string;
910
+ };
911
+
912
+ export declare type PermissionUpdate = {
913
+ type: 'addRules';
914
+ rules: PermissionRuleValue[];
915
+ behavior: PermissionBehavior;
916
+ destination: PermissionUpdateDestination;
917
+ } | {
918
+ type: 'replaceRules';
919
+ rules: PermissionRuleValue[];
920
+ behavior: PermissionBehavior;
921
+ destination: PermissionUpdateDestination;
922
+ } | {
923
+ type: 'removeRules';
924
+ rules: PermissionRuleValue[];
925
+ behavior: PermissionBehavior;
926
+ destination: PermissionUpdateDestination;
927
+ } | {
928
+ type: 'setMode';
929
+ mode: PermissionMode;
930
+ destination: PermissionUpdateDestination;
931
+ } | {
932
+ type: 'addDirectories';
933
+ directories: string[];
934
+ destination: PermissionUpdateDestination;
935
+ } | {
936
+ type: 'removeDirectories';
937
+ directories: string[];
938
+ destination: PermissionUpdateDestination;
939
+ };
940
+
941
+ export declare type PermissionUpdateDestination = 'userSettings' | 'projectSettings' | 'localSettings' | 'session' | 'cliArg';
942
+
943
+ export declare type PostToolUseFailureHookInput = BaseHookInput & {
944
+ hook_event_name: 'PostToolUseFailure';
945
+ tool_name: string;
946
+ tool_input: unknown;
947
+ tool_use_id: string;
948
+ error: string;
949
+ is_interrupt?: boolean;
950
+ };
951
+
952
+ export declare type PostToolUseFailureHookSpecificOutput = {
953
+ hookEventName: 'PostToolUseFailure';
954
+ additionalContext?: string;
955
+ };
956
+
957
+ export declare type PostToolUseHookInput = BaseHookInput & {
958
+ hook_event_name: 'PostToolUse';
959
+ tool_name: string;
960
+ tool_input: unknown;
961
+ tool_response: unknown;
962
+ tool_use_id: string;
963
+ };
964
+
965
+ export declare type PostToolUseHookSpecificOutput = {
966
+ hookEventName: 'PostToolUse';
967
+ additionalContext?: string;
968
+ updatedMCPToolOutput?: unknown;
969
+ };
970
+
971
+ export declare type PreCompactHookInput = BaseHookInput & {
972
+ hook_event_name: 'PreCompact';
973
+ trigger: 'manual' | 'auto';
974
+ custom_instructions: string | null;
975
+ };
976
+
977
+ export declare type PreToolUseHookInput = BaseHookInput & {
978
+ hook_event_name: 'PreToolUse';
979
+ tool_name: string;
980
+ tool_input: unknown;
981
+ tool_use_id: string;
982
+ };
983
+
984
+ export declare type PreToolUseHookSpecificOutput = {
985
+ hookEventName: 'PreToolUse';
986
+ permissionDecision?: 'allow' | 'deny' | 'ask';
987
+ permissionDecisionReason?: string;
988
+ updatedInput?: Record<string, unknown>;
989
+ additionalContext?: string;
990
+ };
991
+
992
+ /**
993
+ * Query interface with methods for controlling query execution.
994
+ * Extends AsyncGenerator and has methods, so not serializable.
995
+ */
996
+ export declare interface Query extends AsyncGenerator<SDKMessage, void> {
997
+ /**
998
+ * Control Requests
999
+ * The following methods are control requests, and are only supported when
1000
+ * streaming input/output is used.
1001
+ */
1002
+ /**
1003
+ * Interrupt the current query execution. The query will stop processing
1004
+ * and return control to the caller.
1005
+ */
1006
+ interrupt(): Promise<void>;
1007
+ /**
1008
+ * Change the permission mode for the current session.
1009
+ * Only available in streaming input mode.
1010
+ *
1011
+ * @param mode - The new permission mode to set
1012
+ */
1013
+ setPermissionMode(mode: PermissionMode): Promise<void>;
1014
+ /**
1015
+ * Change the model used for subsequent responses.
1016
+ * Only available in streaming input mode.
1017
+ *
1018
+ * @param model - The model identifier to use, or undefined to use the default
1019
+ */
1020
+ setModel(model?: string): Promise<void>;
1021
+ /**
1022
+ * Set the maximum number of thinking tokens the model is allowed to use
1023
+ * when generating its response. This can be used to limit the amount of
1024
+ * tokens the model uses for its response, which can help control cost and
1025
+ * latency.
1026
+ *
1027
+ * Use `null` to clear any previously set limit and allow the model to
1028
+ * use the default maximum thinking tokens.
1029
+ *
1030
+ * @deprecated Use the `thinking` option in `query()` instead. On Opus 4.6,
1031
+ * this is treated as on/off (0 = disabled, any other value = adaptive).
1032
+ * For explicit control, use `thinking: { type: 'adaptive' }` or
1033
+ * `thinking: { type: 'enabled', budgetTokens: N }`.
1034
+ *
1035
+ * @param maxThinkingTokens - Maximum tokens for thinking, or null to clear the limit
1036
+ */
1037
+ setMaxThinkingTokens(maxThinkingTokens: number | null): Promise<void>;
1038
+ /**
1039
+ * Get the full initialization result, including supported commands, models,
1040
+ * account info, and output style configuration.
1041
+ *
1042
+ * @returns The complete initialization response
1043
+ */
1044
+ initializationResult(): Promise<SDKControlInitializeResponse>;
1045
+ /**
1046
+ * Get the list of available skills for the current session.
1047
+ *
1048
+ * @returns Array of available skills with their names and descriptions
1049
+ */
1050
+ supportedCommands(): Promise<SlashCommand[]>;
1051
+ /**
1052
+ * Get the list of available models.
1053
+ *
1054
+ * @returns Array of model information including display names and descriptions
1055
+ */
1056
+ supportedModels(): Promise<ModelInfo[]>;
1057
+ /**
1058
+ * Get the current status of all configured MCP servers.
1059
+ *
1060
+ * @returns Array of MCP server statuses (connected, failed, needs-auth, pending)
1061
+ */
1062
+ mcpServerStatus(): Promise<McpServerStatus[]>;
1063
+ /**
1064
+ * Get information about the authenticated account.
1065
+ *
1066
+ * @returns Account information including email, organization, and subscription type
1067
+ */
1068
+ accountInfo(): Promise<AccountInfo>;
1069
+ /**
1070
+ * Rewind tracked files to their state at a specific user message.
1071
+ * Requires file checkpointing to be enabled via the `enableFileCheckpointing` option.
1072
+ *
1073
+ * @param userMessageId - UUID of the user message to rewind to
1074
+ * @param options - Options object with optional `dryRun` boolean to preview changes without modifying files
1075
+ * @returns Object with canRewind boolean, optional error message, and file change statistics
1076
+ */
1077
+ rewindFiles(userMessageId: string, options?: {
1078
+ dryRun?: boolean;
1079
+ }): Promise<RewindFilesResult>;
1080
+ /**
1081
+ * Reconnect an MCP server by name.
1082
+ * Throws on failure.
1083
+ *
1084
+ * @param serverName - The name of the MCP server to reconnect
1085
+ */
1086
+ reconnectMcpServer(serverName: string): Promise<void>;
1087
+ /**
1088
+ * Enable or disable an MCP server by name.
1089
+ * Throws on failure.
1090
+ *
1091
+ * @param serverName - The name of the MCP server to toggle
1092
+ * @param enabled - Whether the server should be enabled
1093
+ */
1094
+ toggleMcpServer(serverName: string, enabled: boolean): Promise<void>;
1095
+ /**
1096
+ * Dynamically set the MCP servers for this session.
1097
+ * This replaces the current set of dynamically-added MCP servers with the provided set.
1098
+ * Servers that are removed will be disconnected, and new servers will be connected.
1099
+ *
1100
+ * Supports both process-based servers (stdio, sse, http) and SDK servers (in-process).
1101
+ * SDK servers are handled locally in the SDK process, while process-based servers
1102
+ * are managed by the CLI subprocess.
1103
+ *
1104
+ * Note: This only affects servers added dynamically via this method or the SDK.
1105
+ * Servers configured via settings files are not affected.
1106
+ *
1107
+ * @param servers - Record of server name to configuration. Pass an empty object to remove all dynamic servers.
1108
+ * @returns Information about which servers were added, removed, and any connection errors
1109
+ */
1110
+ setMcpServers(servers: Record<string, McpServerConfig>): Promise<McpSetServersResult>;
1111
+ /**
1112
+ * Stream input messages to the query.
1113
+ * Used internally for multi-turn conversations.
1114
+ *
1115
+ * @param stream - Async iterable of user messages to send
1116
+ */
1117
+ streamInput(stream: AsyncIterable<SDKUserMessage>): Promise<void>;
1118
+ /**
1119
+ * Stop a running task. A task_notification with status 'stopped' will be emitted.
1120
+ * @param taskId - The task ID from task_notification events
1121
+ */
1122
+ stopTask(taskId: string): Promise<void>;
1123
+ /**
1124
+ * Close the query and terminate the underlying process.
1125
+ * This forcefully ends the query, cleaning up all resources including
1126
+ * pending requests, MCP transports, and the CLI subprocess.
1127
+ *
1128
+ * Use this when you need to abort a query that is still running.
1129
+ * After calling close(), no further messages will be received.
1130
+ */
1131
+ close(): void;
1132
+ }
1133
+
1134
+ export declare function query(_params: {
1135
+ prompt: string | AsyncIterable<SDKUserMessage>;
1136
+ options?: Options;
1137
+ }): Query;
1138
+
1139
+ /**
1140
+ * Result of a rewindFiles operation.
1141
+ */
1142
+ export declare type RewindFilesResult = {
1143
+ canRewind: boolean;
1144
+ error?: string;
1145
+ filesChanged?: string[];
1146
+ insertions?: number;
1147
+ deletions?: number;
1148
+ };
1149
+
1150
+ export declare type SandboxIgnoreViolations = NonNullable<SandboxSettings['ignoreViolations']>;
1151
+
1152
+ export declare type SandboxNetworkConfig = NonNullable<z.infer<typeof SandboxNetworkConfigSchema>>;
1153
+
1154
+ /**
1155
+ * Network configuration schema for sandbox.
1156
+ */
1157
+ declare const SandboxNetworkConfigSchema: z.ZodOptional<z.ZodObject<{
1158
+ allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
1159
+ allowManagedDomainsOnly: z.ZodOptional<z.ZodBoolean>;
1160
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
1161
+ allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
1162
+ allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
1163
+ httpProxyPort: z.ZodOptional<z.ZodNumber>;
1164
+ socksProxyPort: z.ZodOptional<z.ZodNumber>;
1165
+ }, z.core.$strip>>;
1166
+
1167
+ export declare type SandboxSettings = z.infer<typeof SandboxSettingsSchema>;
1168
+
1169
+ /**
1170
+ * Sandbox settings schema.
1171
+ */
1172
+ declare const SandboxSettingsSchema: z.ZodObject<{
1173
+ enabled: z.ZodOptional<z.ZodBoolean>;
1174
+ autoAllowBashIfSandboxed: z.ZodOptional<z.ZodBoolean>;
1175
+ allowUnsandboxedCommands: z.ZodOptional<z.ZodBoolean>;
1176
+ network: z.ZodOptional<z.ZodObject<{
1177
+ allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
1178
+ allowManagedDomainsOnly: z.ZodOptional<z.ZodBoolean>;
1179
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
1180
+ allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
1181
+ allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
1182
+ httpProxyPort: z.ZodOptional<z.ZodNumber>;
1183
+ socksProxyPort: z.ZodOptional<z.ZodNumber>;
1184
+ }, z.core.$strip>>;
1185
+ ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
1186
+ enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
1187
+ excludedCommands: z.ZodOptional<z.ZodArray<z.ZodString>>;
1188
+ ripgrep: z.ZodOptional<z.ZodObject<{
1189
+ command: z.ZodString;
1190
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
1191
+ }, z.core.$strip>>;
1192
+ }, z.core.$loose>;
1193
+
1194
+ export declare type SDKAssistantMessage = {
1195
+ type: 'assistant';
1196
+ message: BetaMessage;
1197
+ parent_tool_use_id: string | null;
1198
+ error?: SDKAssistantMessageError;
1199
+ uuid: UUID;
1200
+ session_id: string;
1201
+ };
1202
+
1203
+ export declare type SDKAssistantMessageError = 'authentication_failed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'server_error' | 'unknown' | 'max_output_tokens';
1204
+
1205
+ export declare type SDKAuthStatusMessage = {
1206
+ type: 'auth_status';
1207
+ isAuthenticating: boolean;
1208
+ output: string[];
1209
+ error?: string;
1210
+ uuid: UUID;
1211
+ session_id: string;
1212
+ };
1213
+
1214
+ export declare type SdkBeta = 'context-1m-2025-08-07';
1215
+
1216
+ export declare type SDKCompactBoundaryMessage = {
1217
+ type: 'system';
1218
+ subtype: 'compact_boundary';
1219
+ compact_metadata: {
1220
+ trigger: 'manual' | 'auto';
1221
+ pre_tokens: number;
1222
+ };
1223
+ uuid: UUID;
1224
+ session_id: string;
1225
+ };
1226
+
1227
+ /**
1228
+ * Cancels a currently open control request.
1229
+ */
1230
+ declare type SDKControlCancelRequest = {
1231
+ type: 'control_cancel_request';
1232
+ request_id: string;
1233
+ };
1234
+
1235
+ /**
1236
+ * Initializes the SDK session with hooks, MCP servers, and agent configuration.
1237
+ */
1238
+ declare type SDKControlInitializeRequest = {
1239
+ subtype: 'initialize';
1240
+ hooks?: Partial<Record<coreTypes.HookEvent, SDKHookCallbackMatcher[]>>;
1241
+ sdkMcpServers?: string[];
1242
+ jsonSchema?: Record<string, unknown>;
1243
+ systemPrompt?: string;
1244
+ appendSystemPrompt?: string;
1245
+ agents?: Record<string, coreTypes.AgentDefinition>;
1246
+ };
1247
+
1248
+ /**
1249
+ * Response from session initialization with available commands, models, and account info.
1250
+ */
1251
+ declare type SDKControlInitializeResponse = {
1252
+ commands: coreTypes.SlashCommand[];
1253
+ output_style: string;
1254
+ available_output_styles: string[];
1255
+ models: coreTypes.ModelInfo[];
1256
+ /**
1257
+ * Information about the logged in user's account.
1258
+ */
1259
+ account: coreTypes.AccountInfo;
1260
+
1261
+ };
1262
+
1263
+ /**
1264
+ * Interrupts the currently running conversation turn.
1265
+ */
1266
+ declare type SDKControlInterruptRequest = {
1267
+ subtype: 'interrupt';
1268
+ };
1269
+
1270
+ /**
1271
+ * Sends a JSON-RPC message to a specific MCP server.
1272
+ */
1273
+ declare type SDKControlMcpMessageRequest = {
1274
+ subtype: 'mcp_message';
1275
+ server_name: string;
1276
+ message: JSONRPCMessage;
1277
+ };
1278
+
1279
+ /**
1280
+ * Reconnects a disconnected or failed MCP server.
1281
+ */
1282
+ declare type SDKControlMcpReconnectRequest = {
1283
+ subtype: 'mcp_reconnect';
1284
+ serverName: string;
1285
+ };
1286
+
1287
+ /**
1288
+ * Replaces the set of dynamically managed MCP servers.
1289
+ */
1290
+ declare type SDKControlMcpSetServersRequest = {
1291
+ subtype: 'mcp_set_servers';
1292
+ servers: Record<string, coreTypes.McpServerConfigForProcessTransport>;
1293
+ };
1294
+
1295
+ /**
1296
+ * Requests the current status of all MCP server connections.
1297
+ */
1298
+ declare type SDKControlMcpStatusRequest = {
1299
+ subtype: 'mcp_status';
1300
+ };
1301
+
1302
+ /**
1303
+ * Enables or disables an MCP server.
1304
+ */
1305
+ declare type SDKControlMcpToggleRequest = {
1306
+ subtype: 'mcp_toggle';
1307
+ serverName: string;
1308
+ enabled: boolean;
1309
+ };
1310
+
1311
+ /**
1312
+ * Requests permission to use a tool with the given input.
1313
+ */
1314
+ declare type SDKControlPermissionRequest = {
1315
+ subtype: 'can_use_tool';
1316
+ tool_name: string;
1317
+ input: Record<string, unknown>;
1318
+ permission_suggestions?: coreTypes.PermissionUpdate[];
1319
+ blocked_path?: string;
1320
+ decision_reason?: string;
1321
+ tool_use_id: string;
1322
+ agent_id?: string;
1323
+ description?: string;
1324
+ };
1325
+
1326
+ declare type SDKControlRequest = {
1327
+ type: 'control_request';
1328
+ request_id: string;
1329
+ request: SDKControlRequestInner;
1330
+ };
1331
+
1332
+ declare type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlMcpSetServersRequest | SDKControlMcpReconnectRequest | SDKControlMcpToggleRequest | SDKControlStopTaskRequest;
1333
+
1334
+ declare type SDKControlResponse = {
1335
+ type: 'control_response';
1336
+ response: ControlResponse | ControlErrorResponse;
1337
+ };
1338
+
1339
+ /**
1340
+ * Rewinds file changes made since a specific user message.
1341
+ */
1342
+ declare type SDKControlRewindFilesRequest = {
1343
+ subtype: 'rewind_files';
1344
+ user_message_id: string;
1345
+ dry_run?: boolean;
1346
+ };
1347
+
1348
+ /**
1349
+ * Sets the maximum number of thinking tokens for extended thinking.
1350
+ */
1351
+ declare type SDKControlSetMaxThinkingTokensRequest = {
1352
+ subtype: 'set_max_thinking_tokens';
1353
+ max_thinking_tokens: number | null;
1354
+ };
1355
+
1356
+ /**
1357
+ * Sets the model to use for subsequent conversation turns.
1358
+ */
1359
+ declare type SDKControlSetModelRequest = {
1360
+ subtype: 'set_model';
1361
+ model?: string;
1362
+ };
1363
+
1364
+ /**
1365
+ * Sets the permission mode for tool execution handling.
1366
+ */
1367
+ declare type SDKControlSetPermissionModeRequest = {
1368
+ subtype: 'set_permission_mode';
1369
+ /**
1370
+ * Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'delegate' - Delegate mode, restricts team leader to only Teammate and Task tools. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved.
1371
+ */
1372
+ mode: coreTypes.PermissionMode;
1373
+ };
1374
+
1375
+ /**
1376
+ * Stops a running task.
1377
+ */
1378
+ declare type SDKControlStopTaskRequest = {
1379
+ subtype: 'stop_task';
1380
+ task_id: string;
1381
+ };
1382
+
1383
+ export declare type SDKFilesPersistedEvent = {
1384
+ type: 'system';
1385
+ subtype: 'files_persisted';
1386
+ files: {
1387
+ filename: string;
1388
+ file_id: string;
1389
+ }[];
1390
+ failed: {
1391
+ filename: string;
1392
+ error: string;
1393
+ }[];
1394
+ processed_at: string;
1395
+ uuid: UUID;
1396
+ session_id: string;
1397
+ };
1398
+
1399
+ /**
1400
+ * Configuration for matching and routing hook callbacks.
1401
+ */
1402
+ declare type SDKHookCallbackMatcher = {
1403
+ matcher?: string;
1404
+ hookCallbackIds: string[];
1405
+ timeout?: number;
1406
+ };
1407
+
1408
+ /**
1409
+ * Delivers a hook callback with its input data.
1410
+ */
1411
+ declare type SDKHookCallbackRequest = {
1412
+ subtype: 'hook_callback';
1413
+ callback_id: string;
1414
+ input: coreTypes.HookInput;
1415
+ tool_use_id?: string;
1416
+ };
1417
+
1418
+ export declare type SDKHookProgressMessage = {
1419
+ type: 'system';
1420
+ subtype: 'hook_progress';
1421
+ hook_id: string;
1422
+ hook_name: string;
1423
+ hook_event: string;
1424
+ stdout: string;
1425
+ stderr: string;
1426
+ output: string;
1427
+ uuid: UUID;
1428
+ session_id: string;
1429
+ };
1430
+
1431
+ export declare type SDKHookResponseMessage = {
1432
+ type: 'system';
1433
+ subtype: 'hook_response';
1434
+ hook_id: string;
1435
+ hook_name: string;
1436
+ hook_event: string;
1437
+ output: string;
1438
+ stdout: string;
1439
+ stderr: string;
1440
+ exit_code?: number;
1441
+ outcome: 'success' | 'error' | 'cancelled';
1442
+ uuid: UUID;
1443
+ session_id: string;
1444
+ };
1445
+
1446
+ export declare type SDKHookStartedMessage = {
1447
+ type: 'system';
1448
+ subtype: 'hook_started';
1449
+ hook_id: string;
1450
+ hook_name: string;
1451
+ hook_event: string;
1452
+ uuid: UUID;
1453
+ session_id: string;
1454
+ };
1455
+
1456
+ /**
1457
+ * Keep-alive message to maintain WebSocket connection.
1458
+ */
1459
+ declare type SDKKeepAliveMessage = {
1460
+ type: 'keep_alive';
1461
+ };
1462
+
1463
+ /**
1464
+ * MCP tool definition for SDK servers.
1465
+ * Contains a handler function, so not serializable.
1466
+ * Supports both Zod 3 and Zod 4 schemas.
1467
+ */
1468
+ export declare type SdkMcpToolDefinition<Schema extends AnyZodRawShape = AnyZodRawShape> = {
1469
+ name: string;
1470
+ description: string;
1471
+ inputSchema: Schema;
1472
+ annotations?: ToolAnnotations;
1473
+ handler: (args: InferShape<Schema>, extra: unknown) => Promise<CallToolResult>;
1474
+ };
1475
+
1476
+ export declare type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage | SDKPartialAssistantMessage | SDKCompactBoundaryMessage | SDKStatusMessage | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKToolProgressMessage | SDKAuthStatusMessage | SDKTaskNotificationMessage | SDKFilesPersistedEvent | SDKToolUseSummaryMessage;
1477
+
1478
+ export declare type SDKPartialAssistantMessage = {
1479
+ type: 'stream_event';
1480
+ event: BetaRawMessageStreamEvent;
1481
+ parent_tool_use_id: string | null;
1482
+ uuid: UUID;
1483
+ session_id: string;
1484
+ };
1485
+
1486
+ export declare type SDKPermissionDenial = {
1487
+ tool_name: string;
1488
+ tool_use_id: string;
1489
+ tool_input: Record<string, unknown>;
1490
+ };
1491
+
1492
+ /**
1493
+ * Configuration for loading a plugin.
1494
+ */
1495
+ export declare type SdkPluginConfig = {
1496
+ /**
1497
+ * Plugin type. Currently only 'local' is supported
1498
+ */
1499
+ type: 'local';
1500
+ /**
1501
+ * Absolute or relative path to the plugin directory
1502
+ */
1503
+ path: string;
1504
+ };
1505
+
1506
+ export declare type SDKResultError = {
1507
+ type: 'result';
1508
+ subtype: 'error_during_execution' | 'error_max_turns' | 'error_max_budget_usd' | 'error_max_structured_output_retries';
1509
+ duration_ms: number;
1510
+ duration_api_ms: number;
1511
+ is_error: boolean;
1512
+ num_turns: number;
1513
+ stop_reason: string | null;
1514
+ total_cost_usd: number;
1515
+ usage: NonNullableUsage;
1516
+ modelUsage: Record<string, ModelUsage>;
1517
+ permission_denials: SDKPermissionDenial[];
1518
+ errors: string[];
1519
+ uuid: UUID;
1520
+ session_id: string;
1521
+ };
1522
+
1523
+ export declare type SDKResultMessage = SDKResultSuccess | SDKResultError;
1524
+
1525
+ export declare type SDKResultSuccess = {
1526
+ type: 'result';
1527
+ subtype: 'success';
1528
+ duration_ms: number;
1529
+ duration_api_ms: number;
1530
+ is_error: boolean;
1531
+ num_turns: number;
1532
+ result: string;
1533
+ stop_reason: string | null;
1534
+ total_cost_usd: number;
1535
+ usage: NonNullableUsage;
1536
+ modelUsage: Record<string, ModelUsage>;
1537
+ permission_denials: SDKPermissionDenial[];
1538
+ structured_output?: unknown;
1539
+ uuid: UUID;
1540
+ session_id: string;
1541
+ };
1542
+
1543
+ /**
1544
+ * V2 API - UNSTABLE
1545
+ * Session interface for multi-turn conversations.
1546
+ * Has methods, so not serializable.
1547
+ * @alpha
1548
+ */
1549
+ export declare interface SDKSession {
1550
+ /**
1551
+ * The session ID. Available after receiving the first message.
1552
+ * For resumed sessions, available immediately.
1553
+ * Throws if accessed before the session is initialized.
1554
+ */
1555
+ readonly sessionId: string;
1556
+ /** Send a message to the agent */
1557
+ send(message: string | SDKUserMessage): Promise<void>;
1558
+ /** Stream messages from the agent */
1559
+ stream(): AsyncGenerator<SDKMessage, void>;
1560
+ /** Close the session */
1561
+ close(): void;
1562
+ /** Async disposal support (calls close if not already closed) */
1563
+ [Symbol.asyncDispose](): Promise<void>;
1564
+ }
1565
+
1566
+ /**
1567
+ * V2 API - UNSTABLE
1568
+ * Options for creating a session.
1569
+ * @alpha
1570
+ */
1571
+ export declare type SDKSessionOptions = {
1572
+ /** Model to use */
1573
+ model: string;
1574
+ /** Path to Claude Code executable */
1575
+ pathToClaudeCodeExecutable?: string;
1576
+ /** Executable to use (node, bun) */
1577
+ executable?: 'node' | 'bun';
1578
+ /** Arguments to pass to executable */
1579
+ executableArgs?: string[];
1580
+ /**
1581
+ * Environment variables to pass to the Claude Code process.
1582
+ * Defaults to `process.env`.
1583
+ *
1584
+ * SDK consumers can identify their app/library to include in the User-Agent header by setting:
1585
+ * - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
1586
+ */
1587
+ env?: {
1588
+ [envVar: string]: string | undefined;
1589
+ };
1590
+ /**
1591
+ * List of tool names that are auto-allowed without prompting for permission.
1592
+ * These tools will execute automatically without asking the user for approval.
1593
+ */
1594
+ allowedTools?: string[];
1595
+ /**
1596
+ * List of tool names that are disallowed. These tools will be removed
1597
+ * from the model's context and cannot be used.
1598
+ */
1599
+ disallowedTools?: string[];
1600
+ /**
1601
+ * Custom permission handler for controlling tool usage. Called before each
1602
+ * tool execution to determine if it should be allowed, denied, or prompt the user.
1603
+ */
1604
+ canUseTool?: CanUseTool;
1605
+ /**
1606
+ * Hook callbacks for responding to various events during execution.
1607
+ */
1608
+ hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
1609
+ /**
1610
+ * Permission mode for the session.
1611
+ * - `'default'` - Standard permission behavior, prompts for dangerous operations
1612
+ * - `'acceptEdits'` - Auto-accept file edit operations
1613
+ * - `'plan'` - Planning mode, no execution of tools
1614
+ * - `'dontAsk'` - Don't prompt for permissions, deny if not pre-approved
1615
+ */
1616
+ permissionMode?: PermissionMode;
1617
+ };
1618
+
1619
+ export declare type SDKStatus = 'compacting' | null;
1620
+
1621
+ export declare type SDKStatusMessage = {
1622
+ type: 'system';
1623
+ subtype: 'status';
1624
+ status: SDKStatus;
1625
+ permissionMode?: PermissionMode;
1626
+ uuid: UUID;
1627
+ session_id: string;
1628
+ };
1629
+
1630
+ export declare type SDKSystemMessage = {
1631
+ type: 'system';
1632
+ subtype: 'init';
1633
+ agents?: string[];
1634
+ apiKeySource: ApiKeySource;
1635
+ betas?: string[];
1636
+ claude_code_version: string;
1637
+ cwd: string;
1638
+ tools: string[];
1639
+ mcp_servers: {
1640
+ name: string;
1641
+ status: string;
1642
+ }[];
1643
+ model: string;
1644
+ /**
1645
+ * Permission mode for controlling how tool executions are handled. 'default' - Standard behavior, prompts for dangerous operations. 'acceptEdits' - Auto-accept file edit operations. 'bypassPermissions' - Bypass all permission checks (requires allowDangerouslySkipPermissions). 'plan' - Planning mode, no actual tool execution. 'delegate' - Delegate mode, restricts team leader to only Teammate and Task tools. 'dontAsk' - Don't prompt for permissions, deny if not pre-approved.
1646
+ */
1647
+ permissionMode: PermissionMode;
1648
+ slash_commands: string[];
1649
+ output_style: string;
1650
+ skills: string[];
1651
+ plugins: {
1652
+ name: string;
1653
+ path: string;
1654
+ }[];
1655
+ uuid: UUID;
1656
+ session_id: string;
1657
+ };
1658
+
1659
+ export declare type SDKTaskNotificationMessage = {
1660
+ type: 'system';
1661
+ subtype: 'task_notification';
1662
+ task_id: string;
1663
+ status: 'completed' | 'failed' | 'stopped';
1664
+ output_file: string;
1665
+ summary: string;
1666
+ uuid: UUID;
1667
+ session_id: string;
1668
+ };
1669
+
1670
+ export declare type SDKToolProgressMessage = {
1671
+ type: 'tool_progress';
1672
+ tool_use_id: string;
1673
+ tool_name: string;
1674
+ parent_tool_use_id: string | null;
1675
+ elapsed_time_seconds: number;
1676
+ uuid: UUID;
1677
+ session_id: string;
1678
+ };
1679
+
1680
+ export declare type SDKToolUseSummaryMessage = {
1681
+ type: 'tool_use_summary';
1682
+ summary: string;
1683
+ preceding_tool_use_ids: string[];
1684
+ uuid: UUID;
1685
+ session_id: string;
1686
+ };
1687
+
1688
+ export declare type SDKUserMessage = {
1689
+ type: 'user';
1690
+ message: MessageParam;
1691
+ parent_tool_use_id: string | null;
1692
+ isSynthetic?: boolean;
1693
+ tool_use_result?: unknown;
1694
+ uuid?: UUID;
1695
+ session_id: string;
1696
+ };
1697
+
1698
+ export declare type SDKUserMessageReplay = {
1699
+ type: 'user';
1700
+ message: MessageParam;
1701
+ parent_tool_use_id: string | null;
1702
+ isSynthetic?: boolean;
1703
+ tool_use_result?: unknown;
1704
+ uuid: UUID;
1705
+ session_id: string;
1706
+ isReplay: true;
1707
+ };
1708
+
1709
+ export declare type SessionEndHookInput = BaseHookInput & {
1710
+ hook_event_name: 'SessionEnd';
1711
+ reason: ExitReason;
1712
+ };
1713
+
1714
+ export declare type SessionStartHookInput = BaseHookInput & {
1715
+ hook_event_name: 'SessionStart';
1716
+ source: 'startup' | 'resume' | 'clear' | 'compact';
1717
+ agent_type?: string;
1718
+ model?: string;
1719
+ };
1720
+
1721
+ export declare type SessionStartHookSpecificOutput = {
1722
+ hookEventName: 'SessionStart';
1723
+ additionalContext?: string;
1724
+ };
1725
+
1726
+ /**
1727
+ * Source for loading filesystem-based settings. 'user' - Global user settings (~/.claude/settings.json). 'project' - Project settings (.claude/settings.json). 'local' - Local settings (.claude/settings.local.json).
1728
+ */
1729
+ export declare type SettingSource = 'user' | 'project' | 'local';
1730
+
1731
+ export declare type SetupHookInput = BaseHookInput & {
1732
+ hook_event_name: 'Setup';
1733
+ trigger: 'init' | 'maintenance';
1734
+ };
1735
+
1736
+ export declare type SetupHookSpecificOutput = {
1737
+ hookEventName: 'Setup';
1738
+ additionalContext?: string;
1739
+ };
1740
+
1741
+ /**
1742
+ * Information about an available skill (invoked via /command syntax).
1743
+ */
1744
+ export declare type SlashCommand = {
1745
+ /**
1746
+ * Skill name (without the leading slash)
1747
+ */
1748
+ name: string;
1749
+ /**
1750
+ * Description of what the skill does
1751
+ */
1752
+ description: string;
1753
+ /**
1754
+ * Hint for skill arguments (e.g., "<file>")
1755
+ */
1756
+ argumentHint: string;
1757
+ };
1758
+
1759
+ /**
1760
+ * Represents a spawned process with stdin/stdout streams and lifecycle management.
1761
+ * Implementers provide this interface to abstract the process spawning mechanism.
1762
+ * ChildProcess already satisfies this interface.
1763
+ */
1764
+ export declare interface SpawnedProcess {
1765
+ /** Writable stream for sending data to the process stdin */
1766
+ stdin: Writable;
1767
+ /** Readable stream for receiving data from the process stdout */
1768
+ stdout: Readable;
1769
+ /** Whether the process has been killed */
1770
+ readonly killed: boolean;
1771
+ /** Exit code if the process has exited, null otherwise */
1772
+ readonly exitCode: number | null;
1773
+ /**
1774
+ * Kill the process with the given signal
1775
+ * @param signal - The signal to send (e.g., 'SIGTERM', 'SIGKILL')
1776
+ */
1777
+ kill(signal: NodeJS.Signals): boolean;
1778
+ /**
1779
+ * Register a callback for when the process exits
1780
+ * @param event - Must be 'exit'
1781
+ * @param listener - Callback receiving exit code and signal
1782
+ */
1783
+ on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
1784
+ /**
1785
+ * Register a callback for process errors
1786
+ * @param event - Must be 'error'
1787
+ * @param listener - Callback receiving the error
1788
+ */
1789
+ on(event: 'error', listener: (error: Error) => void): void;
1790
+ /**
1791
+ * Register a one-time callback for when the process exits
1792
+ */
1793
+ once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
1794
+ once(event: 'error', listener: (error: Error) => void): void;
1795
+ /**
1796
+ * Remove an event listener
1797
+ */
1798
+ off(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): void;
1799
+ off(event: 'error', listener: (error: Error) => void): void;
1800
+ }
1801
+
1802
+ /**
1803
+ * Options passed to the spawn function.
1804
+ */
1805
+ export declare interface SpawnOptions {
1806
+ /** Command to execute */
1807
+ command: string;
1808
+ /** Arguments to pass to the command */
1809
+ args: string[];
1810
+ /** Working directory */
1811
+ cwd?: string;
1812
+ /** Environment variables */
1813
+ env: {
1814
+ [envVar: string]: string | undefined;
1815
+ };
1816
+ /** Abort signal for cancellation */
1817
+ signal: AbortSignal;
1818
+ }
1819
+
1820
+ declare type StdoutMessage = coreTypes.SDKMessage | coreTypes.SDKStreamlinedTextMessage | coreTypes.SDKStreamlinedToolUseSummaryMessage | SDKControlResponse | SDKControlRequest | SDKControlCancelRequest | SDKKeepAliveMessage;
1821
+
1822
+ export declare type StopHookInput = BaseHookInput & {
1823
+ hook_event_name: 'Stop';
1824
+ stop_hook_active: boolean;
1825
+ };
1826
+
1827
+ export declare type SubagentStartHookInput = BaseHookInput & {
1828
+ hook_event_name: 'SubagentStart';
1829
+ agent_id: string;
1830
+ agent_type: string;
1831
+ };
1832
+
1833
+ export declare type SubagentStartHookSpecificOutput = {
1834
+ hookEventName: 'SubagentStart';
1835
+ additionalContext?: string;
1836
+ };
1837
+
1838
+ export declare type SubagentStopHookInput = BaseHookInput & {
1839
+ hook_event_name: 'SubagentStop';
1840
+ stop_hook_active: boolean;
1841
+ agent_id: string;
1842
+ agent_transcript_path: string;
1843
+ agent_type: string;
1844
+ };
1845
+
1846
+ export declare type SyncHookJSONOutput = {
1847
+ continue?: boolean;
1848
+ suppressOutput?: boolean;
1849
+ stopReason?: string;
1850
+ decision?: 'approve' | 'block';
1851
+ systemMessage?: string;
1852
+ reason?: string;
1853
+ hookSpecificOutput?: PreToolUseHookSpecificOutput | UserPromptSubmitHookSpecificOutput | SessionStartHookSpecificOutput | SetupHookSpecificOutput | SubagentStartHookSpecificOutput | PostToolUseHookSpecificOutput | PostToolUseFailureHookSpecificOutput | NotificationHookSpecificOutput | PermissionRequestHookSpecificOutput;
1854
+ };
1855
+
1856
+ export declare type TaskCompletedHookInput = BaseHookInput & {
1857
+ hook_event_name: 'TaskCompleted';
1858
+ task_id: string;
1859
+ task_subject: string;
1860
+ task_description?: string;
1861
+ teammate_name?: string;
1862
+ team_name?: string;
1863
+ };
1864
+
1865
+ export declare type TeammateIdleHookInput = BaseHookInput & {
1866
+ hook_event_name: 'TeammateIdle';
1867
+ teammate_name: string;
1868
+ team_name: string;
1869
+ };
1870
+
1871
+ export declare function tool<Schema extends AnyZodRawShape>(_name: string, _description: string, _inputSchema: Schema, _handler: (args: InferShape<Schema>, extra: unknown) => Promise<CallToolResult>, _extras?: {
1872
+ annotations?: ToolAnnotations;
1873
+ }): SdkMcpToolDefinition<Schema>;
1874
+
1875
+ /**
1876
+ * Transport interface for Claude Code SDK communication
1877
+ * Abstracts the communication layer to support both process and WebSocket transports
1878
+ */
1879
+ export declare interface Transport {
1880
+ /**
1881
+ * Write data to the transport
1882
+ * May be async for network-based transports
1883
+ */
1884
+ write(data: string): void | Promise<void>;
1885
+ /**
1886
+ * Close the transport connection and clean up resources
1887
+ * This also closes stdin if still open (eliminating need for endInput)
1888
+ */
1889
+ close(): void;
1890
+ /**
1891
+ * Check if transport is ready for communication
1892
+ */
1893
+ isReady(): boolean;
1894
+ /**
1895
+ * Read and parse messages from the transport
1896
+ * Each transport handles its own protocol and error checking
1897
+ */
1898
+ readMessages(): AsyncGenerator<StdoutMessage, void, unknown>;
1899
+ /**
1900
+ * End the input stream
1901
+ */
1902
+ endInput(): void;
1903
+ }
1904
+
1905
+ /**
1906
+ * V2 API - UNSTABLE
1907
+ * Create a persistent session for multi-turn conversations.
1908
+ * @alpha
1909
+ */
1910
+ export declare function unstable_v2_createSession(_options: SDKSessionOptions): SDKSession;
1911
+
1912
+ /**
1913
+ * V2 API - UNSTABLE
1914
+ * One-shot convenience function for single prompts.
1915
+ * @alpha
1916
+ *
1917
+ * @example
1918
+ * ```typescript
1919
+ * const result = await unstable_v2_prompt("What files are here?", {
1920
+ * model: 'claude-sonnet-4-6'
1921
+ * })
1922
+ * ```
1923
+ */
1924
+ export declare function unstable_v2_prompt(_message: string, _options: SDKSessionOptions): Promise<SDKResultMessage>;
1925
+
1926
+ /**
1927
+ * V2 API - UNSTABLE
1928
+ * Resume an existing session by ID.
1929
+ * @alpha
1930
+ */
1931
+ export declare function unstable_v2_resumeSession(_sessionId: string, _options: SDKSessionOptions): SDKSession;
1932
+
1933
+ export declare type UserPromptSubmitHookInput = BaseHookInput & {
1934
+ hook_event_name: 'UserPromptSubmit';
1935
+ prompt: string;
1936
+ };
1937
+
1938
+ export declare type UserPromptSubmitHookSpecificOutput = {
1939
+ hookEventName: 'UserPromptSubmit';
1940
+ additionalContext?: string;
1941
+ };
1942
+
1943
+ export { }