@anthropic-ai/claude-agent-sdk 0.1.63 → 0.1.65

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.
@@ -0,0 +1,96 @@
1
+ import { type AccountInfo, type PermissionMode, type SDKMessage, type SDKUserMessage, type HookInput, type HookEvent, type PermissionUpdate, type ModelInfo, type SlashCommand, type AgentDefinition } from './agentSdkTypes.js';
2
+ import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
3
+ export type SDKControlInitializeRequest = {
4
+ subtype: 'initialize';
5
+ hooks?: Partial<Record<HookEvent, SDKHookCallbackMatcher[]>>;
6
+ sdkMcpServers?: string[];
7
+ jsonSchema?: Record<string, unknown>;
8
+ systemPrompt?: string;
9
+ appendSystemPrompt?: string;
10
+ agents?: Record<string, AgentDefinition>;
11
+ };
12
+ export type SDKControlInitializeResponse = {
13
+ commands: SlashCommand[];
14
+ output_style: string;
15
+ available_output_styles: string[];
16
+ models: ModelInfo[];
17
+ account: AccountInfo;
18
+ };
19
+ export type SDKControlInterruptRequest = {
20
+ subtype: 'interrupt';
21
+ };
22
+ export type SDKControlPermissionRequest = {
23
+ subtype: 'can_use_tool';
24
+ tool_name: string;
25
+ input: Record<string, unknown>;
26
+ permission_suggestions?: PermissionUpdate[];
27
+ blocked_path?: string;
28
+ decision_reason?: string;
29
+ tool_use_id: string;
30
+ agent_id?: string;
31
+ };
32
+ export type SDKControlSetPermissionModeRequest = {
33
+ subtype: 'set_permission_mode';
34
+ mode: PermissionMode;
35
+ };
36
+ export type SDKControlSetModelRequest = {
37
+ subtype: 'set_model';
38
+ model?: string;
39
+ };
40
+ export type SDKControlSetMaxThinkingTokensRequest = {
41
+ subtype: 'set_max_thinking_tokens';
42
+ max_thinking_tokens: number | null;
43
+ };
44
+ export type SDKControlMcpStatusRequest = {
45
+ subtype: 'mcp_status';
46
+ };
47
+ export type SDKControlRewindFilesRequest = {
48
+ subtype: 'rewind_files';
49
+ user_message_id: string;
50
+ };
51
+ export type SDKHookCallbackMatcher = {
52
+ matcher?: string;
53
+ hookCallbackIds: string[];
54
+ /** Timeout in seconds for all hooks in this matcher */
55
+ timeout?: number;
56
+ };
57
+ export type SDKHookCallbackRequest = {
58
+ subtype: 'hook_callback';
59
+ callback_id: string;
60
+ input: HookInput;
61
+ tool_use_id?: string;
62
+ };
63
+ export type SDKControlMcpMessageRequest = {
64
+ subtype: 'mcp_message';
65
+ server_name: string;
66
+ message: JSONRPCMessage;
67
+ };
68
+ export type SDKControlRequest = {
69
+ type: 'control_request';
70
+ request_id: string;
71
+ request: SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest;
72
+ };
73
+ export type SDKControlResponse = {
74
+ type: 'control_response';
75
+ response: ControlResponse | ControlErrorResponse;
76
+ };
77
+ export type ControlResponse = {
78
+ subtype: 'success';
79
+ request_id: string;
80
+ response?: Record<string, unknown>;
81
+ };
82
+ export type ControlErrorResponse = {
83
+ subtype: 'error';
84
+ request_id: string;
85
+ error: string;
86
+ pending_permission_requests?: SDKControlRequest[];
87
+ };
88
+ export type SDKControlCancelRequest = {
89
+ type: 'control_cancel_request';
90
+ request_id: string;
91
+ };
92
+ export type SDKKeepAliveMessage = {
93
+ type: 'keep_alive';
94
+ };
95
+ export type StdoutMessage = SDKMessage | SDKControlResponse | SDKControlRequest | SDKControlCancelRequest | SDKKeepAliveMessage;
96
+ export type StdinMessage = SDKUserMessage | SDKControlRequest | SDKControlResponse | SDKKeepAliveMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthropic-ai/claude-agent-sdk",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
4
4
  "main": "sdk.mjs",
5
5
  "types": "sdk.d.ts",
6
6
  "engines": {
package/sdk-tools.d.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  export type ToolInputSchemas =
12
12
  | AgentInput
13
13
  | BashInput
14
- | BashOutputInput
14
+ | TaskOutputInput
15
15
  | ExitPlanModeInput
16
16
  | FileEditInput
17
17
  | FileReadInput
@@ -26,8 +26,7 @@ export type ToolInputSchemas =
26
26
  | TodoWriteInput
27
27
  | WebFetchInput
28
28
  | WebSearchInput
29
- | AskUserQuestionInput
30
- | AgentOutputInput;
29
+ | AskUserQuestionInput;
31
30
 
32
31
  export interface AgentInput {
33
32
  /**
@@ -51,7 +50,7 @@ export interface AgentInput {
51
50
  */
52
51
  resume?: string;
53
52
  /**
54
- * Set to true to run this agent in the background. Use AgentOutputTool to read the output later.
53
+ * Set to true to run this agent in the background. Use TaskOutput to read the output later.
55
54
  */
56
55
  run_in_background?: boolean;
57
56
  }
@@ -80,7 +79,7 @@ export interface BashInput {
80
79
  */
81
80
  description?: string;
82
81
  /**
83
- * Set to true to run this command in the background. Use BashOutput to read the output later.
82
+ * Set to true to run this command in the background. Use TaskOutput to read the output later.
84
83
  */
85
84
  run_in_background?: boolean;
86
85
  /**
@@ -88,15 +87,19 @@ export interface BashInput {
88
87
  */
89
88
  dangerouslyDisableSandbox?: boolean;
90
89
  }
91
- export interface BashOutputInput {
90
+ export interface TaskOutputInput {
92
91
  /**
93
- * The ID of the background shell to retrieve output from
92
+ * The task ID to get output from
94
93
  */
95
- bash_id: string;
94
+ task_id: string;
96
95
  /**
97
- * Optional regular expression to filter the output lines. Only lines matching this regex will be included in the result. Any lines that do not match will no longer be available to read.
96
+ * Whether to wait for completion
98
97
  */
99
- filter?: string;
98
+ block?: boolean;
99
+ /**
100
+ * Max wait time in ms
101
+ */
102
+ timeout?: number;
100
103
  }
101
104
  export interface ExitPlanModeInput {
102
105
  /**
@@ -203,7 +206,7 @@ export interface GrepInput {
203
206
  */
204
207
  type?: string;
205
208
  /**
206
- * Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults based on "cap" experiment value: 0 (unlimited), 20, or 100.
209
+ * Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to 0 (unlimited).
207
210
  */
208
211
  head_limit?: number;
209
212
  /**
@@ -1489,17 +1492,3 @@ export interface AskUserQuestionInput {
1489
1492
  [k: string]: string;
1490
1493
  };
1491
1494
  }
1492
- export interface AgentOutputInput {
1493
- /**
1494
- * The agent ID to retrieve results for
1495
- */
1496
- agentId: string;
1497
- /**
1498
- * Whether to block until results are ready
1499
- */
1500
- block?: boolean;
1501
- /**
1502
- * Maximum time to wait in seconds
1503
- */
1504
- wait_up_to?: number;
1505
- }