@anthropic-ai/claude-agent-sdk 0.1.76 → 0.2.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.
@@ -4,32 +4,18 @@
4
4
  * This file is the single source of truth for sandbox configuration types.
5
5
  * Both the SDK and the settings validation import from here.
6
6
  */
7
- import { z } from 'zod';
7
+ import { z } from 'zod/v4';
8
8
  /**
9
9
  * Network configuration schema for sandbox.
10
10
  */
11
11
  export declare const SandboxNetworkConfigSchema: z.ZodOptional<z.ZodObject<{
12
- allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
- allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
12
+ allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
14
  allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
15
15
  allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
16
16
  httpProxyPort: z.ZodOptional<z.ZodNumber>;
17
17
  socksProxyPort: z.ZodOptional<z.ZodNumber>;
18
- }, "strip", z.ZodTypeAny, {
19
- allowedDomains?: string[];
20
- allowUnixSockets?: string[];
21
- allowAllUnixSockets?: boolean;
22
- allowLocalBinding?: boolean;
23
- httpProxyPort?: number;
24
- socksProxyPort?: number;
25
- }, {
26
- allowedDomains?: string[];
27
- allowUnixSockets?: string[];
28
- allowAllUnixSockets?: boolean;
29
- allowLocalBinding?: boolean;
30
- httpProxyPort?: number;
31
- socksProxyPort?: number;
32
- }>>;
18
+ }, z.core.$strip>>;
33
19
  /**
34
20
  * Sandbox settings schema.
35
21
  */
@@ -38,119 +24,21 @@ export declare const SandboxSettingsSchema: z.ZodObject<{
38
24
  autoAllowBashIfSandboxed: z.ZodOptional<z.ZodBoolean>;
39
25
  allowUnsandboxedCommands: z.ZodOptional<z.ZodBoolean>;
40
26
  network: z.ZodOptional<z.ZodObject<{
41
- allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
42
- allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
27
+ allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
+ allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
29
  allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
44
30
  allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
45
31
  httpProxyPort: z.ZodOptional<z.ZodNumber>;
46
32
  socksProxyPort: z.ZodOptional<z.ZodNumber>;
47
- }, "strip", z.ZodTypeAny, {
48
- allowedDomains?: string[];
49
- allowUnixSockets?: string[];
50
- allowAllUnixSockets?: boolean;
51
- allowLocalBinding?: boolean;
52
- httpProxyPort?: number;
53
- socksProxyPort?: number;
54
- }, {
55
- allowedDomains?: string[];
56
- allowUnixSockets?: string[];
57
- allowAllUnixSockets?: boolean;
58
- allowLocalBinding?: boolean;
59
- httpProxyPort?: number;
60
- socksProxyPort?: number;
61
- }>>;
62
- ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
33
+ }, z.core.$strip>>;
34
+ ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
63
35
  enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
64
- excludedCommands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
36
+ excludedCommands: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
37
  ripgrep: z.ZodOptional<z.ZodObject<{
66
38
  command: z.ZodString;
67
- args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
68
- }, "strip", z.ZodTypeAny, {
69
- command?: string;
70
- args?: string[];
71
- }, {
72
- command?: string;
73
- args?: string[];
74
- }>>;
75
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
76
- enabled: z.ZodOptional<z.ZodBoolean>;
77
- autoAllowBashIfSandboxed: z.ZodOptional<z.ZodBoolean>;
78
- allowUnsandboxedCommands: z.ZodOptional<z.ZodBoolean>;
79
- network: z.ZodOptional<z.ZodObject<{
80
- allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
81
- allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
82
- allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
83
- allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
84
- httpProxyPort: z.ZodOptional<z.ZodNumber>;
85
- socksProxyPort: z.ZodOptional<z.ZodNumber>;
86
- }, "strip", z.ZodTypeAny, {
87
- allowedDomains?: string[];
88
- allowUnixSockets?: string[];
89
- allowAllUnixSockets?: boolean;
90
- allowLocalBinding?: boolean;
91
- httpProxyPort?: number;
92
- socksProxyPort?: number;
93
- }, {
94
- allowedDomains?: string[];
95
- allowUnixSockets?: string[];
96
- allowAllUnixSockets?: boolean;
97
- allowLocalBinding?: boolean;
98
- httpProxyPort?: number;
99
- socksProxyPort?: number;
100
- }>>;
101
- ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
102
- enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
103
- excludedCommands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
104
- ripgrep: z.ZodOptional<z.ZodObject<{
105
- command: z.ZodString;
106
- args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
107
- }, "strip", z.ZodTypeAny, {
108
- command?: string;
109
- args?: string[];
110
- }, {
111
- command?: string;
112
- args?: string[];
113
- }>>;
114
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
115
- enabled: z.ZodOptional<z.ZodBoolean>;
116
- autoAllowBashIfSandboxed: z.ZodOptional<z.ZodBoolean>;
117
- allowUnsandboxedCommands: z.ZodOptional<z.ZodBoolean>;
118
- network: z.ZodOptional<z.ZodObject<{
119
- allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
120
- allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
121
- allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
122
- allowLocalBinding: z.ZodOptional<z.ZodBoolean>;
123
- httpProxyPort: z.ZodOptional<z.ZodNumber>;
124
- socksProxyPort: z.ZodOptional<z.ZodNumber>;
125
- }, "strip", z.ZodTypeAny, {
126
- allowedDomains?: string[];
127
- allowUnixSockets?: string[];
128
- allowAllUnixSockets?: boolean;
129
- allowLocalBinding?: boolean;
130
- httpProxyPort?: number;
131
- socksProxyPort?: number;
132
- }, {
133
- allowedDomains?: string[];
134
- allowUnixSockets?: string[];
135
- allowAllUnixSockets?: boolean;
136
- allowLocalBinding?: boolean;
137
- httpProxyPort?: number;
138
- socksProxyPort?: number;
139
- }>>;
140
- ignoreViolations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
141
- enableWeakerNestedSandbox: z.ZodOptional<z.ZodBoolean>;
142
- excludedCommands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
143
- ripgrep: z.ZodOptional<z.ZodObject<{
144
- command: z.ZodString;
145
- args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
146
- }, "strip", z.ZodTypeAny, {
147
- command?: string;
148
- args?: string[];
149
- }, {
150
- command?: string;
151
- args?: string[];
152
- }>>;
153
- }, z.ZodTypeAny, "passthrough">>;
39
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
40
+ }, z.core.$strip>>;
41
+ }, z.core.$loose>;
154
42
  export type SandboxSettings = z.infer<typeof SandboxSettingsSchema>;
155
43
  export type SandboxNetworkConfig = NonNullable<z.infer<typeof SandboxNetworkConfigSchema>>;
156
44
  export type SandboxIgnoreViolations = NonNullable<SandboxSettings['ignoreViolations']>;
@@ -0,0 +1,2 @@
1
+ export * from './coreTypes.js';
2
+ export * from './controlTypes.generated.js';
@@ -1,105 +1,135 @@
1
- import { type AccountInfo, type PermissionMode, type SDKMessage, type SDKUserMessage, type HookInput, type HookEvent, type PermissionUpdate, type ModelInfo, type SlashCommand, type AgentDefinition, type McpServerConfigForProcessTransport } from './agentSdkTypes.js';
1
+ /**
2
+ * AUTO-GENERATED - DO NOT EDIT
3
+ *
4
+ * This file is auto-generated from Zod schemas in controlSchemas.ts.
5
+ * To modify these types, edit the Zod schemas and run:
6
+ *
7
+ * bun scripts/generate-sdk-types.ts
8
+ */
2
9
  import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
10
+ import type * as coreTypes from './coreTypes.js';
11
+ export type ControlErrorResponse = {
12
+ subtype: 'error';
13
+ request_id: string;
14
+ error: string;
15
+ pending_permission_requests?: SDKControlRequest[];
16
+ };
17
+ export type ControlResponse = {
18
+ subtype: 'success';
19
+ request_id: string;
20
+ response?: Record<string, unknown>;
21
+ };
22
+ /**
23
+ * Cancels a currently open control request.
24
+ */
25
+ export type SDKControlCancelRequest = {
26
+ type: 'control_cancel_request';
27
+ request_id: string;
28
+ };
3
29
  export type SDKControlInitializeRequest = {
4
30
  subtype: 'initialize';
5
- hooks?: Partial<Record<HookEvent, SDKHookCallbackMatcher[]>>;
31
+ hooks?: Partial<Record<coreTypes.HookEvent, SDKHookCallbackMatcher[]>>;
6
32
  sdkMcpServers?: string[];
7
33
  jsonSchema?: Record<string, unknown>;
8
34
  systemPrompt?: string;
9
35
  appendSystemPrompt?: string;
10
- agents?: Record<string, AgentDefinition>;
36
+ agents?: Record<string, coreTypes.AgentDefinition>;
11
37
  };
12
38
  export type SDKControlInitializeResponse = {
13
- commands: SlashCommand[];
39
+ commands: coreTypes.SlashCommand[];
14
40
  output_style: string;
15
41
  available_output_styles: string[];
16
- models: ModelInfo[];
17
- account: AccountInfo;
42
+ models: coreTypes.ModelInfo[];
43
+ /** Information about the logged in user's account. */
44
+ account: coreTypes.AccountInfo;
18
45
  };
19
46
  export type SDKControlInterruptRequest = {
20
47
  subtype: 'interrupt';
21
48
  };
49
+ export type SDKControlMcpMessageRequest = {
50
+ subtype: 'mcp_message';
51
+ server_name: string;
52
+ message: JSONRPCMessage;
53
+ };
54
+ export type SDKControlMcpSetServersRequest = {
55
+ subtype: 'mcp_set_servers';
56
+ servers: Record<string, coreTypes.McpServerConfigForProcessTransport>;
57
+ };
58
+ export type SDKControlMcpSetServersResponse = {
59
+ added: string[];
60
+ removed: string[];
61
+ errors: Record<string, string>;
62
+ };
63
+ export type SDKControlMcpStatusRequest = {
64
+ subtype: 'mcp_status';
65
+ };
22
66
  export type SDKControlPermissionRequest = {
23
67
  subtype: 'can_use_tool';
24
68
  tool_name: string;
25
69
  input: Record<string, unknown>;
26
- permission_suggestions?: PermissionUpdate[];
70
+ permission_suggestions?: coreTypes.PermissionUpdate[];
27
71
  blocked_path?: string;
28
72
  decision_reason?: string;
29
73
  tool_use_id: string;
30
74
  agent_id?: string;
31
75
  };
32
- export type SDKControlSetPermissionModeRequest = {
33
- subtype: 'set_permission_mode';
34
- mode: PermissionMode;
76
+ export type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlMcpSetServersRequest;
77
+ export type SDKControlRequest = {
78
+ type: 'control_request';
79
+ request_id: string;
80
+ request: SDKControlRequestInner;
35
81
  };
36
- export type SDKControlSetModelRequest = {
37
- subtype: 'set_model';
38
- model?: string;
82
+ export type SDKControlResponse = {
83
+ type: 'control_response';
84
+ response: ControlResponse | ControlErrorResponse;
85
+ };
86
+ export type SDKControlRewindFilesRequest = {
87
+ subtype: 'rewind_files';
88
+ user_message_id: string;
89
+ dry_run?: boolean;
90
+ };
91
+ /**
92
+ * Result of a rewindFiles operation.
93
+ */
94
+ export type SDKControlRewindFilesResponse = {
95
+ canRewind: boolean;
96
+ error?: string;
97
+ filesChanged?: string[];
98
+ insertions?: number;
99
+ deletions?: number;
39
100
  };
40
101
  export type SDKControlSetMaxThinkingTokensRequest = {
41
102
  subtype: 'set_max_thinking_tokens';
42
103
  max_thinking_tokens: number | null;
43
104
  };
44
- export type SDKControlMcpStatusRequest = {
45
- subtype: 'mcp_status';
105
+ export type SDKControlSetModelRequest = {
106
+ subtype: 'set_model';
107
+ model?: string;
46
108
  };
47
- export type SDKControlRewindFilesRequest = {
48
- subtype: 'rewind_files';
49
- user_message_id: string;
109
+ export type SDKControlSetPermissionModeRequest = {
110
+ subtype: 'set_permission_mode';
111
+ /** 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. */
112
+ mode: coreTypes.PermissionMode;
50
113
  };
114
+ /**
115
+ * Configuration for matching and routing hook callbacks.
116
+ */
51
117
  export type SDKHookCallbackMatcher = {
52
118
  matcher?: string;
53
119
  hookCallbackIds: string[];
54
- /** Timeout in seconds for all hooks in this matcher */
55
120
  timeout?: number;
56
121
  };
57
122
  export type SDKHookCallbackRequest = {
58
123
  subtype: 'hook_callback';
59
124
  callback_id: string;
60
- input: HookInput;
125
+ input: coreTypes.HookInput;
61
126
  tool_use_id?: string;
62
127
  };
63
- export type SDKControlMcpMessageRequest = {
64
- subtype: 'mcp_message';
65
- server_name: string;
66
- message: JSONRPCMessage;
67
- };
68
- export type SDKControlMcpSetServersRequest = {
69
- subtype: 'mcp_set_servers';
70
- servers: Record<string, McpServerConfigForProcessTransport>;
71
- };
72
- export type SDKControlMcpSetServersResponse = {
73
- added: string[];
74
- removed: string[];
75
- errors: Record<string, string>;
76
- };
77
- export type SDKControlRequest = {
78
- type: 'control_request';
79
- request_id: string;
80
- request: SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlMcpStatusRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlMcpSetServersRequest;
81
- };
82
- export type SDKControlResponse = {
83
- type: 'control_response';
84
- response: ControlResponse | ControlErrorResponse;
85
- };
86
- export type ControlResponse = {
87
- subtype: 'success';
88
- request_id: string;
89
- response?: Record<string, unknown>;
90
- };
91
- export type ControlErrorResponse = {
92
- subtype: 'error';
93
- request_id: string;
94
- error: string;
95
- pending_permission_requests?: SDKControlRequest[];
96
- };
97
- export type SDKControlCancelRequest = {
98
- type: 'control_cancel_request';
99
- request_id: string;
100
- };
128
+ /**
129
+ * Keep-alive message to maintain WebSocket connection.
130
+ */
101
131
  export type SDKKeepAliveMessage = {
102
132
  type: 'keep_alive';
103
133
  };
104
- export type StdoutMessage = SDKMessage | SDKControlResponse | SDKControlRequest | SDKControlCancelRequest | SDKKeepAliveMessage;
105
- export type StdinMessage = SDKUserMessage | SDKControlRequest | SDKControlResponse | SDKKeepAliveMessage;
134
+ export type StdinMessage = coreTypes.SDKUserMessage | SDKControlRequest | SDKControlResponse | SDKKeepAliveMessage;
135
+ export type StdoutMessage = coreTypes.SDKMessage | SDKControlResponse | SDKControlRequest | SDKControlCancelRequest | SDKKeepAliveMessage;
@@ -0,0 +1,5 @@
1
+ export * from './coreTypes.generated.js';
2
+ export type { SandboxSettings, SandboxNetworkConfig, SandboxIgnoreViolations, } from '../sandboxTypes.js';
3
+ export type { NonNullableUsage } from './sdkUtilityTypes.js';
4
+ export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "SubagentStart", "SubagentStop", "PreCompact", "PermissionRequest"];
5
+ export declare const EXIT_REASONS: readonly ["clear", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"];