@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.
- package/cli.js +1474 -1466
- package/entrypoints/agentSdkTypes.d.ts +1041 -0
- package/entrypoints/sdkControlTypes.d.ts +96 -0
- package/package.json +1 -1
- package/sdk-tools.d.ts +14 -25
- package/sdk.d.ts +1 -1008
- package/sdk.mjs +121 -70
- package/transport/processTransportTypes.d.ts +60 -0
- package/transport/transport.d.ts +30 -0
- /package/{sandboxTypes.d.ts → entrypoints/sandboxTypes.d.ts} +0 -0
|
@@ -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
package/sdk-tools.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
export type ToolInputSchemas =
|
|
12
12
|
| AgentInput
|
|
13
13
|
| BashInput
|
|
14
|
-
|
|
|
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
|
|
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
|
|
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
|
|
90
|
+
export interface TaskOutputInput {
|
|
92
91
|
/**
|
|
93
|
-
* The ID
|
|
92
|
+
* The task ID to get output from
|
|
94
93
|
*/
|
|
95
|
-
|
|
94
|
+
task_id: string;
|
|
96
95
|
/**
|
|
97
|
-
*
|
|
96
|
+
* Whether to wait for completion
|
|
98
97
|
*/
|
|
99
|
-
|
|
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
|
|
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
|
-
}
|