@anthropic-ai/claude-code 1.0.84 → 1.0.86

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-code",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "main": "sdk.mjs",
5
5
  "types": "sdk.d.ts",
6
6
  "bin": {
package/sdk-tools.d.ts CHANGED
@@ -67,6 +67,10 @@ export interface BashInput {
67
67
  * Output: Creates directory 'foo'
68
68
  */
69
69
  description?: string;
70
+ /**
71
+ * Set to true to run this command in the background. Use BashOutput to read the output later.
72
+ */
73
+ run_in_background?: boolean;
70
74
  /**
71
75
  * whether to run this command in sandboxed mode: command run in this mode may not write to the filesystem or use the network, but they can read files, analyze data, and report back to you. When possible, run commands (e.g. grep) in this mode to present a smoother experience for the human, who isn't prompted to approve commands run in sandbox mode. If you run a command in sandbox mode and it looks like it fails because it needs write access after all, try again in non-sandbox mode
72
76
  */
@@ -299,7 +303,6 @@ export interface TodoWriteInput {
299
303
  todos: {
300
304
  content: string;
301
305
  status: "pending" | "in_progress" | "completed";
302
- id: string;
303
306
  }[];
304
307
  }
305
308
  export interface WebFetchInput {
package/sdk.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Message as APIAssistantMessage, MessageParam as APIUserMessage, Usage } from '@anthropic-ai/sdk/resources/index.mjs';
2
+ import type { UUID } from 'crypto';
2
3
  export type NonNullableUsage = {
3
4
  [K in keyof Usage]: NonNullable<Usage[K]>;
4
5
  };
@@ -31,6 +32,87 @@ export type PermissionResult = {
31
32
  export type CanUseTool = (toolName: string, input: Record<string, unknown>, options: {
32
33
  signal: AbortSignal;
33
34
  }) => Promise<PermissionResult>;
35
+ export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStop", "PreCompact"];
36
+ export type HookEvent = (typeof HOOK_EVENTS)[number];
37
+ export type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
38
+ signal: AbortSignal;
39
+ }) => Promise<HookJSONOutput>;
40
+ export interface HookCallbackMatcher {
41
+ matcher?: string;
42
+ hooks: HookCallback[];
43
+ }
44
+ export type BaseHookInput = {
45
+ session_id: string;
46
+ transcript_path: string;
47
+ cwd: string;
48
+ };
49
+ export type PreToolUseHookInput = BaseHookInput & {
50
+ hook_event_name: 'PreToolUse';
51
+ tool_name: string;
52
+ tool_input: unknown;
53
+ };
54
+ export type PostToolUseHookInput = BaseHookInput & {
55
+ hook_event_name: 'PostToolUse';
56
+ tool_name: string;
57
+ tool_input: unknown;
58
+ tool_response: unknown;
59
+ };
60
+ export type NotificationHookInput = BaseHookInput & {
61
+ hook_event_name: 'Notification';
62
+ message: string;
63
+ title?: string;
64
+ };
65
+ export type UserPromptSubmitHookInput = BaseHookInput & {
66
+ hook_event_name: 'UserPromptSubmit';
67
+ prompt: string;
68
+ };
69
+ export type SessionStartHookInput = BaseHookInput & {
70
+ hook_event_name: 'SessionStart';
71
+ source: 'startup' | 'resume' | 'clear' | 'compact';
72
+ };
73
+ export type StopHookInput = BaseHookInput & {
74
+ hook_event_name: 'Stop';
75
+ stop_hook_active: boolean;
76
+ };
77
+ export type SubagentStopHookInput = BaseHookInput & {
78
+ hook_event_name: 'SubagentStop';
79
+ stop_hook_active: boolean;
80
+ };
81
+ export type PreCompactHookInput = BaseHookInput & {
82
+ hook_event_name: 'PreCompact';
83
+ trigger: 'manual' | 'auto';
84
+ custom_instructions: string | null;
85
+ };
86
+ export declare const EXIT_REASONS: string[];
87
+ export type ExitReason = (typeof EXIT_REASONS)[number];
88
+ export type SessionEndHookInput = BaseHookInput & {
89
+ hook_event_name: 'SessionEnd';
90
+ reason: ExitReason;
91
+ };
92
+ export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStopHookInput | PreCompactHookInput;
93
+ export interface HookJSONOutput {
94
+ continue?: boolean;
95
+ suppressOutput?: boolean;
96
+ stopReason?: string;
97
+ decision?: 'approve' | 'block';
98
+ systemMessage?: string;
99
+ permissionDecision?: 'allow' | 'deny' | 'ask';
100
+ reason?: string;
101
+ hookSpecificOutput?: {
102
+ hookEventName: 'PreToolUse';
103
+ permissionDecision?: 'allow' | 'deny' | 'ask';
104
+ permissionDecisionReason?: string;
105
+ } | {
106
+ hookEventName: 'UserPromptSubmit';
107
+ additionalContext?: string;
108
+ } | {
109
+ hookEventName: 'SessionStart';
110
+ additionalContext?: string;
111
+ } | {
112
+ hookEventName: 'PostToolUse';
113
+ additionalContext?: string;
114
+ };
115
+ }
34
116
  export type Options = {
35
117
  abortController?: AbortController;
36
118
  additionalDirectories?: string[];
@@ -45,6 +127,7 @@ export type Options = {
45
127
  executable?: 'bun' | 'deno' | 'node';
46
128
  executableArgs?: string[];
47
129
  fallbackModel?: string;
130
+ hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
48
131
  maxThinkingTokens?: number;
49
132
  maxTurns?: number;
50
133
  mcpServers?: Record<string, McpServerConfig>;
@@ -57,24 +140,31 @@ export type Options = {
57
140
  strictMcpConfig?: boolean;
58
141
  };
59
142
  export type PermissionMode = 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan';
60
- export type SDKUserMessage = {
143
+ type SDKMessageBase = {
144
+ uuid: UUID;
145
+ session_id: string;
146
+ };
147
+ type SDKUserMessageContent = {
61
148
  type: 'user';
62
149
  message: APIUserMessage;
63
150
  parent_tool_use_id: string | null;
151
+ };
152
+ export type SDKUserMessage = SDKUserMessageContent & {
153
+ uuid?: UUID;
64
154
  session_id: string;
65
155
  };
66
- export type SDKAssistantMessage = {
156
+ export type SDKUserMessageReplay = SDKMessageBase & SDKUserMessageContent;
157
+ export type SDKAssistantMessage = SDKMessageBase & {
67
158
  type: 'assistant';
68
159
  message: APIAssistantMessage;
69
160
  parent_tool_use_id: string | null;
70
- session_id: string;
71
161
  };
72
162
  export type SDKPermissionDenial = {
73
163
  tool_name: string;
74
164
  tool_use_id: string;
75
165
  tool_input: Record<string, unknown>;
76
166
  };
77
- export type SDKResultMessage = {
167
+ export type SDKResultMessage = (SDKMessageBase & {
78
168
  type: 'result';
79
169
  subtype: 'success';
80
170
  duration_ms: number;
@@ -82,28 +172,25 @@ export type SDKResultMessage = {
82
172
  is_error: boolean;
83
173
  num_turns: number;
84
174
  result: string;
85
- session_id: string;
86
175
  total_cost_usd: number;
87
176
  usage: NonNullableUsage;
88
177
  permission_denials: SDKPermissionDenial[];
89
- } | {
178
+ }) | (SDKMessageBase & {
90
179
  type: 'result';
91
180
  subtype: 'error_max_turns' | 'error_during_execution';
92
181
  duration_ms: number;
93
182
  duration_api_ms: number;
94
183
  is_error: boolean;
95
184
  num_turns: number;
96
- session_id: string;
97
185
  total_cost_usd: number;
98
186
  usage: NonNullableUsage;
99
187
  permission_denials: SDKPermissionDenial[];
100
- };
101
- export type SDKSystemMessage = {
188
+ });
189
+ export type SDKSystemMessage = SDKMessageBase & {
102
190
  type: 'system';
103
191
  subtype: 'init';
104
192
  apiKeySource: ApiKeySource;
105
193
  cwd: string;
106
- session_id: string;
107
194
  tools: string[];
108
195
  mcp_servers: {
109
196
  name: string;
@@ -112,14 +199,20 @@ export type SDKSystemMessage = {
112
199
  model: string;
113
200
  permissionMode: PermissionMode;
114
201
  slash_commands: string[];
202
+ output_style: string;
115
203
  };
116
- export type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKResultMessage | SDKSystemMessage;
204
+ export type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage;
117
205
  export interface Query extends AsyncGenerator<SDKMessage, void> {
118
206
  /**
119
207
  * Interrupt the query.
120
208
  * Only supported when streaming input is used.
121
209
  */
122
210
  interrupt(): Promise<void>;
211
+ /**
212
+ * Sets the permission mode.
213
+ * Only supported when streaming input is used.
214
+ */
215
+ setPermissionMode(mode: PermissionMode): Promise<void>;
123
216
  }
124
217
  /**
125
218
  * Query Claude Code
@@ -142,3 +235,4 @@ export declare function query({ prompt, options, }: {
142
235
  }): Query;
143
236
  export declare class AbortError extends Error {
144
237
  }
238
+ export {};