@anthropic-ai/claude-agent-sdk 0.1.43 → 0.1.45

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 (5) hide show
  1. package/cli.js +1843 -1680
  2. package/package.json +1 -1
  3. package/sdk-tools.d.ts +2 -2
  4. package/sdk.d.ts +29 -3
  5. package/sdk.mjs +12 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-agent-sdk",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "main": "sdk.mjs",
5
5
  "types": "sdk.d.ts",
6
6
  "engines": {
package/sdk-tools.d.ts CHANGED
@@ -27,7 +27,7 @@ export type ToolInputSchemas =
27
27
  | TodoWriteInput
28
28
  | WebFetchInput
29
29
  | WebSearchInput
30
- | MultipleChoiceQuestionInput;
30
+ | AskUserQuestionInput;
31
31
 
32
32
  export interface AgentInput {
33
33
  /**
@@ -301,7 +301,7 @@ export interface WebSearchInput {
301
301
  */
302
302
  blocked_domains?: string[];
303
303
  }
304
- export interface MultipleChoiceQuestionInput {
304
+ export interface AskUserQuestionInput {
305
305
  /**
306
306
  * Questions to ask the user (1-4 questions)
307
307
  *
package/sdk.d.ts CHANGED
@@ -16,6 +16,15 @@ export type ModelUsage = {
16
16
  costUSD: number;
17
17
  contextWindow: number;
18
18
  };
19
+ export type OutputFormatType = 'json_schema';
20
+ export type BaseOutputFormat = {
21
+ type: OutputFormatType;
22
+ };
23
+ export type JsonSchemaOutputFormat = BaseOutputFormat & {
24
+ type: 'json_schema';
25
+ schema: Record<string, unknown>;
26
+ };
27
+ export type OutputFormat = JsonSchemaOutputFormat;
19
28
  export type ApiKeySource = 'user' | 'project' | 'org' | 'temporary';
20
29
  export type ConfigScope = 'local' | 'user' | 'project';
21
30
  export type McpStdioServerConfig = {
@@ -149,8 +158,10 @@ export type CanUseTool = (toolName: string, input: Record<string, unknown>, opti
149
158
  * Multiple tool calls in the same assistant message will have different toolUseIDs.
150
159
  */
151
160
  toolUseID: string;
161
+ /** If running within the context of a sub-agent, the sub-agent's ID. */
162
+ agentID?: string;
152
163
  }) => Promise<PermissionResult>;
153
- export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact"];
164
+ export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest"];
154
165
  export type HookEvent = (typeof HOOK_EVENTS)[number];
155
166
  export type HookCallback = (input: HookInput, toolUseID: string | undefined, options: {
156
167
  signal: AbortSignal;
@@ -173,6 +184,11 @@ export type PreToolUseHookInput = BaseHookInput & {
173
184
  tool_input: unknown;
174
185
  tool_use_id: string;
175
186
  };
187
+ export type PermissionRequestHookInput = BaseHookInput & {
188
+ hook_event_name: 'PermissionRequest';
189
+ tool_name: string;
190
+ tool_input: unknown;
191
+ };
176
192
  export type PostToolUseHookInput = BaseHookInput & {
177
193
  hook_event_name: 'PostToolUse';
178
194
  tool_name: string;
@@ -220,7 +236,7 @@ export type SessionEndHookInput = BaseHookInput & {
220
236
  hook_event_name: 'SessionEnd';
221
237
  reason: ExitReason;
222
238
  };
223
- export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStartHookInput | SubagentStopHookInput | PreCompactHookInput;
239
+ export type HookInput = PreToolUseHookInput | PostToolUseHookInput | NotificationHookInput | UserPromptSubmitHookInput | SessionStartHookInput | SessionEndHookInput | StopHookInput | SubagentStartHookInput | SubagentStopHookInput | PreCompactHookInput | PermissionRequestHookInput;
224
240
  export type AsyncHookJSONOutput = {
225
241
  async: true;
226
242
  asyncTimeout?: number;
@@ -250,6 +266,16 @@ export type SyncHookJSONOutput = {
250
266
  hookEventName: 'PostToolUse';
251
267
  additionalContext?: string;
252
268
  updatedMCPToolOutput?: unknown;
269
+ } | {
270
+ hookEventName: 'PermissionRequest';
271
+ decision: {
272
+ behavior: 'allow';
273
+ updatedInput?: Record<string, unknown>;
274
+ } | {
275
+ behavior: 'deny';
276
+ message?: string;
277
+ interrupt?: boolean;
278
+ };
253
279
  };
254
280
  };
255
281
  export type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
@@ -512,7 +538,7 @@ export type Options = {
512
538
  maxBudgetUsd?: number;
513
539
  mcpServers?: Record<string, McpServerConfig>;
514
540
  model?: string;
515
- outputSchema?: Record<string, unknown>;
541
+ outputFormat?: OutputFormat;
516
542
  pathToClaudeCodeExecutable?: string;
517
543
  permissionMode?: PermissionMode;
518
544
  allowDangerouslySkipPermissions?: boolean;
package/sdk.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://docs.claude.com/en/docs/claude-code/legal-and-compliance.
3
3
 
4
- // Version: 0.1.43
4
+ // Version: 0.1.45
5
5
 
6
6
  // Want to see the unminified source? We're hiring!
7
7
  // https://job-boards.greenhouse.io/anthropic/jobs/4816199008
@@ -6351,7 +6351,8 @@ var HOOK_EVENTS = [
6351
6351
  "Stop",
6352
6352
  "SubagentStart",
6353
6353
  "SubagentStop",
6354
- "PreCompact"
6354
+ "PreCompact",
6355
+ "PermissionRequest"
6355
6356
  ];
6356
6357
  var EXIT_REASONS = [
6357
6358
  "clear",
@@ -6404,7 +6405,7 @@ class ProcessTransport {
6404
6405
  maxBudgetUsd,
6405
6406
  model,
6406
6407
  fallbackModel,
6407
- outputSchema,
6408
+ jsonSchema,
6408
6409
  permissionMode,
6409
6410
  allowDangerouslySkipPermissions,
6410
6411
  permissionPromptToolName,
@@ -6440,8 +6441,8 @@ class ProcessTransport {
6440
6441
  }
6441
6442
  if (model)
6442
6443
  args.push("--model", model);
6443
- if (outputSchema) {
6444
- args.push("--output-schema", JSON.stringify(outputSchema));
6444
+ if (jsonSchema) {
6445
+ args.push("--json-schema", JSON.stringify(jsonSchema));
6445
6446
  }
6446
6447
  if (env.DEBUG)
6447
6448
  args.push("--debug-to-stderr");
@@ -7676,7 +7677,8 @@ class Query {
7676
7677
  suggestions: request.request.permission_suggestions,
7677
7678
  blockedPath: request.request.blocked_path,
7678
7679
  decisionReason: request.request.decision_reason,
7679
- toolUseID: request.request.tool_use_id
7680
+ toolUseID: request.request.tool_use_id,
7681
+ agentID: request.request.agent_id
7680
7682
  });
7681
7683
  return {
7682
7684
  ...result,
@@ -14820,7 +14822,7 @@ function query({
14820
14822
  const dirname2 = join3(filename, "..");
14821
14823
  pathToClaudeCodeExecutable = join3(dirname2, "cli.js");
14822
14824
  }
14823
- process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.43";
14825
+ process.env.CLAUDE_AGENT_SDK_VERSION = "0.1.45";
14824
14826
  const {
14825
14827
  abortController = createAbortController(),
14826
14828
  additionalDirectories = [],
@@ -14843,7 +14845,7 @@ function query({
14843
14845
  maxBudgetUsd,
14844
14846
  mcpServers,
14845
14847
  model,
14846
- outputSchema,
14848
+ outputFormat,
14847
14849
  permissionMode = "default",
14848
14850
  allowDangerouslySkipPermissions = false,
14849
14851
  permissionPromptToolName,
@@ -14853,6 +14855,7 @@ function query({
14853
14855
  stderr,
14854
14856
  strictMcpConfig
14855
14857
  } = rest;
14858
+ const jsonSchema = outputFormat?.type === "json_schema" ? outputFormat.schema : undefined;
14856
14859
  let processEnv = env;
14857
14860
  if (!processEnv) {
14858
14861
  processEnv = { ...process.env };
@@ -14898,7 +14901,7 @@ function query({
14898
14901
  maxBudgetUsd,
14899
14902
  model,
14900
14903
  fallbackModel,
14901
- outputSchema,
14904
+ jsonSchema,
14902
14905
  permissionMode,
14903
14906
  allowDangerouslySkipPermissions,
14904
14907
  permissionPromptToolName,