clawd-code-sdk 0.6.0__tar.gz → 0.6.2__tar.gz
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.
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/.gitignore +3 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/PKG-INFO +1 -1
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/pyproject.toml +2 -2
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/__init__.py +13 -7
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/__init__.py +25 -22
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/control.py +20 -4
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/hooks.py +22 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/input_types.py +3 -7
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/mcp.py +0 -1
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/messages.py +3 -4
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/options.py +63 -36
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/output_types.py +1 -12
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/prompts.py +28 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/server_info.py +3 -0
- clawd_code_sdk-0.6.2/src/clawd_code_sdk/models/settings.py +1324 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/system_messages.py +1 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_transport.py +26 -20
- clawd_code_sdk-0.6.0/src/clawd_code_sdk/models/sandbox.py +0 -88
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/LICENSE +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/README.md +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_bundled/.gitignore +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_errors.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_internal/__init__.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_internal/message_parser.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_internal/query.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_internal/transport/__init__.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_internal/transport/subprocess_cli.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/_version.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/anthropic_types.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/client.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/list_sessions.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/mcp_utils.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/agents.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/base.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/content_blocks.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/permissions.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/prompt_requests.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/models/thinking.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/py.typed +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/query.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/session.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/storage/ARCHITECTURE.md +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/storage/__init__.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/storage/helpers.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/storage/models.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/storage/replay.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/src/clawd_code_sdk/usage.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/__init__.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/conftest.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/__init__.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_agents_and_settings.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_dynamic_control.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_hook_events.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_hooks.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_include_partial_messages.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_mcp_tools.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_sdk_mcp_tools.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_slash_commands.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_stderr_callback.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_structured_output.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_subagent_invocation.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/e2e/test_tool_permissions.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/mcp_server.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/mock_claude_server.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_changelog.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_client.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_errors.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_image.png +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_integration.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_message_parser.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_sdk_mcp_integration.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_session.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_streaming_client.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_subprocess_buffering.py +0 -0
- {clawd_code_sdk-0.6.0 → clawd_code_sdk-0.6.2}/tests/test_tool_callbacks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clawd-code-sdk
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Python SDK for Claude Code
|
|
5
5
|
Project-URL: Documentation, https://github.com/phil65/claude-agent-sdk-python
|
|
6
6
|
Project-URL: Homepage, https://github.com/phil65/claude-agent-sdk-python
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "clawd-code-sdk"
|
|
3
|
-
version = "0.6.
|
|
3
|
+
version = "0.6.2"
|
|
4
4
|
description = "Python SDK for Claude Code"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.13"
|
|
@@ -239,7 +239,7 @@ max-complexity = 15
|
|
|
239
239
|
"__init__.py" = ["E402", "I001"]
|
|
240
240
|
"scripts/*" = ["INP001", "PLR2004"]
|
|
241
241
|
"*tests/*" = ["D100", "PLR2004"]
|
|
242
|
-
"
|
|
242
|
+
"src/clawd_code_sdk/models/settings.py" = ["ALL"]
|
|
243
243
|
"docs/examples/**/*.py" = [
|
|
244
244
|
"TC001",
|
|
245
245
|
] # Examples don't need TYPE_CHECKING imports
|
|
@@ -67,9 +67,12 @@ from .models import (
|
|
|
67
67
|
ResultErrorMessage,
|
|
68
68
|
ResultMessage,
|
|
69
69
|
ResultSuccessMessage,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
ClaudeCodeSettings,
|
|
71
|
+
Filesystem,
|
|
72
|
+
Hooks,
|
|
73
|
+
Network,
|
|
74
|
+
Permissions,
|
|
75
|
+
Sandbox,
|
|
73
76
|
SdkBeta,
|
|
74
77
|
SdkPluginConfig,
|
|
75
78
|
SettingSource,
|
|
@@ -142,6 +145,8 @@ __all__ = [
|
|
|
142
145
|
# Tool callbacks
|
|
143
146
|
"CanUseTool",
|
|
144
147
|
"ClaudeAgentOptions",
|
|
148
|
+
# Settings / sandbox
|
|
149
|
+
"ClaudeCodeSettings",
|
|
145
150
|
"ClaudeSDKClient",
|
|
146
151
|
# Errors
|
|
147
152
|
"ClaudeSDKError",
|
|
@@ -151,6 +156,7 @@ __all__ = [
|
|
|
151
156
|
"ContinueLatest",
|
|
152
157
|
"ConversationTurn",
|
|
153
158
|
"DocumentMediaType",
|
|
159
|
+
"Filesystem",
|
|
154
160
|
"FromPR",
|
|
155
161
|
"HookCallback",
|
|
156
162
|
"HookContext",
|
|
@@ -159,6 +165,7 @@ __all__ = [
|
|
|
159
165
|
"HookJSONOutput",
|
|
160
166
|
"HookMatcher",
|
|
161
167
|
"HookMatcherConfig",
|
|
168
|
+
"Hooks",
|
|
162
169
|
"ImageMediaType",
|
|
163
170
|
"InitSystemMessage",
|
|
164
171
|
"InvalidRequestError",
|
|
@@ -166,6 +173,7 @@ __all__ = [
|
|
|
166
173
|
"McpSdkServerConfig",
|
|
167
174
|
"McpServerConfig",
|
|
168
175
|
"Message",
|
|
176
|
+
"Network",
|
|
169
177
|
"NewSession",
|
|
170
178
|
"NotificationHookInput",
|
|
171
179
|
"NotificationHookSpecificOutput",
|
|
@@ -178,6 +186,7 @@ __all__ = [
|
|
|
178
186
|
"PermissionResultAllow",
|
|
179
187
|
"PermissionResultDeny",
|
|
180
188
|
"PermissionUpdate",
|
|
189
|
+
"Permissions",
|
|
181
190
|
"PlainTextMediaType",
|
|
182
191
|
"PostToolUseFailureHookInput",
|
|
183
192
|
"PostToolUseFailureHookSpecificOutput",
|
|
@@ -192,10 +201,7 @@ __all__ = [
|
|
|
192
201
|
"ResultSuccessMessage",
|
|
193
202
|
"ResumeSession",
|
|
194
203
|
"SDKSessionInfo",
|
|
195
|
-
"
|
|
196
|
-
"SandboxNetworkConfig",
|
|
197
|
-
# Sandbox support
|
|
198
|
-
"SandboxSettings",
|
|
204
|
+
"Sandbox",
|
|
199
205
|
# Beta support
|
|
200
206
|
"SdkBeta",
|
|
201
207
|
"SdkMcpTool",
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
"""Type definitions for Claude SDK.
|
|
2
|
-
|
|
3
|
-
This package re-exports all types for backwards compatibility.
|
|
4
|
-
Types are organized into submodules:
|
|
5
|
-
- base: Type aliases, literals, and thinking configuration
|
|
6
|
-
- agents: Agent definitions and presets
|
|
7
|
-
- permissions: Permission system types
|
|
8
|
-
- hooks: Hook system types (inputs, outputs, matchers, callbacks)
|
|
9
|
-
- mcp: MCP server and plugin configuration
|
|
10
|
-
- sandbox: Sandbox configuration
|
|
11
|
-
- messages: Content blocks, message types, and stream events
|
|
12
|
-
- options: ClaudeAgentOptions
|
|
13
|
-
- control: SDK control protocol types
|
|
14
|
-
"""
|
|
1
|
+
"""Type definitions for Claude SDK."""
|
|
15
2
|
|
|
16
3
|
from __future__ import annotations
|
|
17
4
|
|
|
@@ -49,6 +36,8 @@ from .control import (
|
|
|
49
36
|
SDKControlResponse,
|
|
50
37
|
SDKControlRewindFilesRequest,
|
|
51
38
|
SDKControlSetPermissionModeRequest,
|
|
39
|
+
SDKControlSetProactiveRequest,
|
|
40
|
+
SDKControlGetSettingsRequest,
|
|
52
41
|
SDKControlStopTaskRequest,
|
|
53
42
|
SDKHookCallbackRequest,
|
|
54
43
|
control_request_adapter,
|
|
@@ -99,6 +88,7 @@ from .hooks import (
|
|
|
99
88
|
UserPromptSubmitHookSpecificOutput,
|
|
100
89
|
WorktreeCreateHookInput,
|
|
101
90
|
WorktreeRemoveHookInput,
|
|
91
|
+
InstructionsLoadedHookInput,
|
|
102
92
|
)
|
|
103
93
|
from .input_types import (
|
|
104
94
|
TOOL_INPUT_TYPES,
|
|
@@ -127,7 +117,6 @@ from .input_types import (
|
|
|
127
117
|
WebSearchInput,
|
|
128
118
|
)
|
|
129
119
|
from .mcp import (
|
|
130
|
-
JSONRPC_VERSION,
|
|
131
120
|
JSONRPCError,
|
|
132
121
|
JSONRPCErrorResponse,
|
|
133
122
|
JSONRPCMessage,
|
|
@@ -158,7 +147,6 @@ from .output_types import (
|
|
|
158
147
|
AgentOutputTextContent,
|
|
159
148
|
AgentOutputUsage,
|
|
160
149
|
AgentServerToolUse,
|
|
161
|
-
AgentSubAgentEnteredOutput,
|
|
162
150
|
AskUserQuestionItem,
|
|
163
151
|
AskUserQuestionOutput,
|
|
164
152
|
BashOutput,
|
|
@@ -249,6 +237,7 @@ from .prompts import (
|
|
|
249
237
|
UserDocumentPrompt,
|
|
250
238
|
PlainTextMediaType,
|
|
251
239
|
UserDocumentURLPrompt,
|
|
240
|
+
UserFilePrompt,
|
|
252
241
|
UserImagePrompt,
|
|
253
242
|
UserImageURLPrompt,
|
|
254
243
|
UserPlainTextDocumentPrompt,
|
|
@@ -265,6 +254,7 @@ from .options import (
|
|
|
265
254
|
NewSession,
|
|
266
255
|
ResumeSession,
|
|
267
256
|
SessionConfig,
|
|
257
|
+
ToolConfig,
|
|
268
258
|
resolve_session_config,
|
|
269
259
|
)
|
|
270
260
|
from .permissions import (
|
|
@@ -281,7 +271,14 @@ from .permissions import (
|
|
|
281
271
|
PermissionUpdateDestination,
|
|
282
272
|
ToolPermissionContext,
|
|
283
273
|
)
|
|
284
|
-
from .
|
|
274
|
+
from .settings import (
|
|
275
|
+
ClaudeCodeSettings,
|
|
276
|
+
Filesystem,
|
|
277
|
+
Hooks,
|
|
278
|
+
Network,
|
|
279
|
+
Permissions,
|
|
280
|
+
Sandbox,
|
|
281
|
+
)
|
|
285
282
|
from .server_info import ClaudeCodeAgentInfo, ClaudeCodeServerInfo, ClaudeCodeCommandInfo
|
|
286
283
|
from .system_messages import (
|
|
287
284
|
system_message_adapter,
|
|
@@ -307,7 +304,6 @@ from .system_messages import (
|
|
|
307
304
|
Message = MiscMessages | SystemMessageUnion
|
|
308
305
|
|
|
309
306
|
__all__ = [
|
|
310
|
-
"JSONRPC_VERSION",
|
|
311
307
|
"TOOL_INPUT_TYPES",
|
|
312
308
|
"TOOL_USE_RESULT_TYPES",
|
|
313
309
|
"AgentAsyncLaunchedOutput",
|
|
@@ -322,7 +318,6 @@ __all__ = [
|
|
|
322
318
|
"AgentOutputTextContent",
|
|
323
319
|
"AgentOutputUsage",
|
|
324
320
|
"AgentServerToolUse",
|
|
325
|
-
"AgentSubAgentEnteredOutput",
|
|
326
321
|
"ApiKeySource",
|
|
327
322
|
"AskUserQuestion",
|
|
328
323
|
"AskUserQuestionInput",
|
|
@@ -347,6 +342,7 @@ __all__ = [
|
|
|
347
342
|
"ClaudeCodeAgentInfo",
|
|
348
343
|
"ClaudeCodeCommandInfo",
|
|
349
344
|
"ClaudeCodeServerInfo",
|
|
345
|
+
"ClaudeCodeSettings",
|
|
350
346
|
"CommandHookHandler",
|
|
351
347
|
"CompactBoundarySystemMessage",
|
|
352
348
|
"ConfigOutput",
|
|
@@ -378,6 +374,7 @@ __all__ = [
|
|
|
378
374
|
"FileReadInput",
|
|
379
375
|
"FileWriteInput",
|
|
380
376
|
"FilesPersistedSystemMessage",
|
|
377
|
+
"Filesystem",
|
|
381
378
|
"FromPR",
|
|
382
379
|
"GitDiff",
|
|
383
380
|
"GlobInput",
|
|
@@ -396,8 +393,10 @@ __all__ = [
|
|
|
396
393
|
"HookResponseSystemMessage",
|
|
397
394
|
"HookSpecificOutput",
|
|
398
395
|
"HookStartedSystemMessage",
|
|
396
|
+
"Hooks",
|
|
399
397
|
"ImageMediaType",
|
|
400
398
|
"InitSystemMessage",
|
|
399
|
+
"InstructionsLoadedHookInput",
|
|
401
400
|
"JSONRPCError",
|
|
402
401
|
"JSONRPCErrorResponse",
|
|
403
402
|
"JSONRPCMessage",
|
|
@@ -427,6 +426,7 @@ __all__ = [
|
|
|
427
426
|
"Message",
|
|
428
427
|
"MiscMessages",
|
|
429
428
|
"ModelUsage",
|
|
429
|
+
"Network",
|
|
430
430
|
"NewSession",
|
|
431
431
|
"NotebookEditInput",
|
|
432
432
|
"NotebookEditOutput",
|
|
@@ -444,6 +444,7 @@ __all__ = [
|
|
|
444
444
|
"PermissionRuleValue",
|
|
445
445
|
"PermissionUpdate",
|
|
446
446
|
"PermissionUpdateDestination",
|
|
447
|
+
"Permissions",
|
|
447
448
|
"PlainTextMediaType",
|
|
448
449
|
"PostToolUseFailureHookInput",
|
|
449
450
|
"PostToolUseFailureHookSpecificOutput",
|
|
@@ -482,6 +483,7 @@ __all__ = [
|
|
|
482
483
|
"ResultSuccessMessage",
|
|
483
484
|
"ResumeSession",
|
|
484
485
|
"SDKControlElicitationRequest",
|
|
486
|
+
"SDKControlGetSettingsRequest",
|
|
485
487
|
"SDKControlInitializeRequest",
|
|
486
488
|
"SDKControlInterruptRequest",
|
|
487
489
|
"SDKControlMcpMessageRequest",
|
|
@@ -492,13 +494,12 @@ __all__ = [
|
|
|
492
494
|
"SDKControlResponse",
|
|
493
495
|
"SDKControlRewindFilesRequest",
|
|
494
496
|
"SDKControlSetPermissionModeRequest",
|
|
497
|
+
"SDKControlSetProactiveRequest",
|
|
495
498
|
"SDKControlStopTaskRequest",
|
|
496
499
|
"SDKHookCallbackRequest",
|
|
497
500
|
"SDKPermissionDenial",
|
|
498
501
|
"SDKSessionInfo",
|
|
499
|
-
"
|
|
500
|
-
"SandboxNetworkConfig",
|
|
501
|
-
"SandboxSettings",
|
|
502
|
+
"Sandbox",
|
|
502
503
|
"SdkBeta",
|
|
503
504
|
"SdkPluginConfig",
|
|
504
505
|
"SessionConfig",
|
|
@@ -541,6 +542,7 @@ __all__ = [
|
|
|
541
542
|
"TodoWriteInput",
|
|
542
543
|
"TodoWriteOutput",
|
|
543
544
|
"TodoWriteToolUseResult",
|
|
545
|
+
"ToolConfig",
|
|
544
546
|
"ToolInput",
|
|
545
547
|
"ToolPermissionContext",
|
|
546
548
|
"ToolProgressMessage",
|
|
@@ -555,6 +557,7 @@ __all__ = [
|
|
|
555
557
|
"Usage",
|
|
556
558
|
"UserDocumentPrompt",
|
|
557
559
|
"UserDocumentURLPrompt",
|
|
560
|
+
"UserFilePrompt",
|
|
558
561
|
"UserImagePrompt",
|
|
559
562
|
"UserImageURLPrompt",
|
|
560
563
|
"UserMessage",
|
|
@@ -7,10 +7,10 @@ from typing import Annotated, Any, Literal, TypedDict
|
|
|
7
7
|
|
|
8
8
|
from pydantic import Discriminator, TypeAdapter
|
|
9
9
|
|
|
10
|
-
from .agents import AgentDefinition # noqa: TC001
|
|
11
|
-
from .base import ElicitationMode, PermissionMode # noqa: TC001
|
|
12
|
-
from .hooks import HookEvent, HookInput # noqa: TC001
|
|
13
|
-
from .mcp import ExternalMcpServerConfig, JSONRPCMessage # noqa: TC001
|
|
10
|
+
from clawd_code_sdk.models.agents import AgentDefinition # noqa: TC001
|
|
11
|
+
from clawd_code_sdk.models.base import ElicitationMode, PermissionMode # noqa: TC001
|
|
12
|
+
from clawd_code_sdk.models.hooks import HookEvent, HookInput # noqa: TC001
|
|
13
|
+
from clawd_code_sdk.models.mcp import ExternalMcpServerConfig, JSONRPCMessage # noqa: TC001
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
# SDK Control Protocol
|
|
@@ -206,6 +206,20 @@ class SDKControlElicitationRequest:
|
|
|
206
206
|
requested_schema: dict[str, Any] | None = None
|
|
207
207
|
|
|
208
208
|
|
|
209
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
210
|
+
class SDKControlGetSettingsRequest:
|
|
211
|
+
"""Returns the effective merged settings and the raw per-source settings."""
|
|
212
|
+
|
|
213
|
+
subtype: Literal["get_settings"] = "get_settings"
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@dataclass(frozen=True, slots=True, kw_only=True)
|
|
217
|
+
class SDKControlSetProactiveRequest:
|
|
218
|
+
"""Sets proactive mode configuration."""
|
|
219
|
+
|
|
220
|
+
subtype: Literal["set_proactive"] = "set_proactive"
|
|
221
|
+
|
|
222
|
+
|
|
209
223
|
ControlRequestUnion = Annotated[
|
|
210
224
|
SDKControlInterruptRequest
|
|
211
225
|
| SDKControlPermissionRequest
|
|
@@ -224,8 +238,10 @@ ControlRequestUnion = Annotated[
|
|
|
224
238
|
| SDKControlMcpClearAuthRequest
|
|
225
239
|
| SDKControlMcpOAuthCallbackUrlRequest
|
|
226
240
|
| SDKControlRemoteControlRequest
|
|
241
|
+
| SDKControlSetProactiveRequest
|
|
227
242
|
| SDKControlStopTaskRequest
|
|
228
243
|
| SDKControlApplyFlagSettingsRequest
|
|
244
|
+
| SDKControlGetSettingsRequest
|
|
229
245
|
| SDKControlElicitationRequest,
|
|
230
246
|
Discriminator("subtype"),
|
|
231
247
|
]
|
|
@@ -38,6 +38,7 @@ HookEvent = Literal[
|
|
|
38
38
|
"ConfigChange",
|
|
39
39
|
"WorktreeCreate",
|
|
40
40
|
"WorktreeRemove",
|
|
41
|
+
"InstructionsLoaded",
|
|
41
42
|
]
|
|
42
43
|
|
|
43
44
|
|
|
@@ -143,6 +144,8 @@ class PreToolUseHookInput(BaseHookInput):
|
|
|
143
144
|
tool_name: str
|
|
144
145
|
tool_input: dict[str, Any]
|
|
145
146
|
tool_use_id: str
|
|
147
|
+
agent_id: NotRequired[str]
|
|
148
|
+
agent_type: NotRequired[str]
|
|
146
149
|
|
|
147
150
|
|
|
148
151
|
class PostToolUseHookInput(BaseHookInput):
|
|
@@ -153,6 +156,8 @@ class PostToolUseHookInput(BaseHookInput):
|
|
|
153
156
|
tool_input: dict[str, Any]
|
|
154
157
|
tool_response: Any
|
|
155
158
|
tool_use_id: str
|
|
159
|
+
agent_id: NotRequired[str]
|
|
160
|
+
agent_type: NotRequired[str]
|
|
156
161
|
|
|
157
162
|
|
|
158
163
|
class PostToolUseFailureHookInput(BaseHookInput):
|
|
@@ -164,6 +169,8 @@ class PostToolUseFailureHookInput(BaseHookInput):
|
|
|
164
169
|
tool_use_id: str
|
|
165
170
|
error: str
|
|
166
171
|
is_interrupt: NotRequired[bool]
|
|
172
|
+
agent_id: NotRequired[str]
|
|
173
|
+
agent_type: NotRequired[str]
|
|
167
174
|
|
|
168
175
|
|
|
169
176
|
class UserPromptSubmitHookInput(BaseHookInput):
|
|
@@ -222,6 +229,8 @@ class PermissionRequestHookInput(BaseHookInput):
|
|
|
222
229
|
tool_name: str
|
|
223
230
|
tool_input: dict[str, Any]
|
|
224
231
|
permission_suggestions: NotRequired[list[Any]]
|
|
232
|
+
agent_id: NotRequired[str]
|
|
233
|
+
agent_type: NotRequired[str]
|
|
225
234
|
|
|
226
235
|
|
|
227
236
|
class SessionStartHookInput(BaseHookInput):
|
|
@@ -313,6 +322,18 @@ class ElicitationResultHookInput(BaseHookInput):
|
|
|
313
322
|
content: NotRequired[dict[str, Any]]
|
|
314
323
|
|
|
315
324
|
|
|
325
|
+
class InstructionsLoadedHookInput(BaseHookInput):
|
|
326
|
+
"""Input data for InstructionsLoaded hook events."""
|
|
327
|
+
|
|
328
|
+
hook_event_name: Literal["InstructionsLoaded"]
|
|
329
|
+
file_path: str
|
|
330
|
+
memory_type: Literal["User", "Project", "Local", "Managed"]
|
|
331
|
+
load_reason: Literal["session_start", "nested_traversal", "path_glob_match", "include"]
|
|
332
|
+
globs: NotRequired[list[str]]
|
|
333
|
+
trigger_file_path: NotRequired[str]
|
|
334
|
+
parent_file_path: NotRequired[str]
|
|
335
|
+
|
|
336
|
+
|
|
316
337
|
# Union type for all hook inputs
|
|
317
338
|
HookInput = (
|
|
318
339
|
PreToolUseHookInput
|
|
@@ -333,6 +354,7 @@ HookInput = (
|
|
|
333
354
|
| ElicitationHookInput
|
|
334
355
|
| ElicitationResultHookInput
|
|
335
356
|
| ConfigChangeHookInput
|
|
357
|
+
| InstructionsLoadedHookInput
|
|
336
358
|
| WorktreeCreateHookInput
|
|
337
359
|
| WorktreeRemoveHookInput
|
|
338
360
|
)
|
|
@@ -10,7 +10,7 @@ from typing import Literal, NotRequired, TypedDict
|
|
|
10
10
|
|
|
11
11
|
from pydantic import ConfigDict, with_config
|
|
12
12
|
|
|
13
|
-
from clawd_code_sdk.models.base import
|
|
13
|
+
from clawd_code_sdk.models.base import PermissionMode # noqa: TC001
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
_extra_allow = with_config(ConfigDict(extra="allow"))
|
|
@@ -28,16 +28,10 @@ class AgentInput(TypedDict):
|
|
|
28
28
|
"""The task for the agent to perform."""
|
|
29
29
|
subagent_type: str
|
|
30
30
|
"""The type of specialized agent to use for this task."""
|
|
31
|
-
model: NotRequired[ModelName]
|
|
32
|
-
"""Optional model to use for the agent."""
|
|
33
31
|
resume: NotRequired[str]
|
|
34
32
|
"""Optional agent ID to resume from in order to continue from the previous exec transcript."""
|
|
35
33
|
run_in_background: NotRequired[bool]
|
|
36
34
|
"""Whether to run the agent in the background."""
|
|
37
|
-
max_turns: NotRequired[int]
|
|
38
|
-
"""Maximum number of agentic turns (API round-trips) before stopping.
|
|
39
|
-
|
|
40
|
-
Used internally for warmup."""
|
|
41
35
|
name: NotRequired[str]
|
|
42
36
|
"""Name for the spawned agent."""
|
|
43
37
|
team_name: NotRequired[str]
|
|
@@ -54,6 +48,8 @@ class AskUserQuestionOption(TypedDict):
|
|
|
54
48
|
"""Display text for this option (1-5 words)."""
|
|
55
49
|
description: str
|
|
56
50
|
"""Explanation of what this option means."""
|
|
51
|
+
preview: NotRequired[str]
|
|
52
|
+
"""Optional preview content rendered when this option is focused."""
|
|
57
53
|
|
|
58
54
|
|
|
59
55
|
@_extra_allow
|
|
@@ -18,13 +18,11 @@ from clawd_code_sdk._errors import (
|
|
|
18
18
|
RateLimitError,
|
|
19
19
|
ServerError,
|
|
20
20
|
)
|
|
21
|
-
from clawd_code_sdk.models.base import FastModeState
|
|
21
|
+
from clawd_code_sdk.models.base import FastModeState, StopReason, ToolName # noqa: TC001
|
|
22
22
|
from clawd_code_sdk.models.content_blocks import ContentBlock, TextBlock
|
|
23
|
+
from clawd_code_sdk.models.input_types import ToolInput # noqa: TC001
|
|
23
24
|
from clawd_code_sdk.models.output_types import ToolUseResult
|
|
24
25
|
|
|
25
|
-
from .base import StopReason, ToolName # noqa: TC001
|
|
26
|
-
from .input_types import ToolInput # noqa: TC001
|
|
27
|
-
|
|
28
26
|
|
|
29
27
|
# Message types
|
|
30
28
|
AssistantMessageError = Literal[
|
|
@@ -183,6 +181,7 @@ class UserMessage(BaseMessage):
|
|
|
183
181
|
) = None
|
|
184
182
|
isReplay: bool | None = None # noqa: N815
|
|
185
183
|
isSynthetic: bool | None = None # noqa: N815
|
|
184
|
+
priority: Literal["now", "next", "later"] | None = None
|
|
186
185
|
|
|
187
186
|
def parse_command_output(self) -> str | None:
|
|
188
187
|
"""Extract output from legacy XML-tagged command output in user messages."""
|
|
@@ -13,19 +13,32 @@ if TYPE_CHECKING:
|
|
|
13
13
|
from collections.abc import Callable, Sequence
|
|
14
14
|
|
|
15
15
|
from clawd_code_sdk.models import OnElicitation, OnUserQuestion
|
|
16
|
-
from clawd_code_sdk.models.
|
|
17
|
-
|
|
18
|
-
from .
|
|
19
|
-
from .
|
|
20
|
-
from .
|
|
21
|
-
from .
|
|
22
|
-
from .
|
|
23
|
-
from .sandbox import SandboxSettings
|
|
24
|
-
from .thinking import ThinkingConfig
|
|
16
|
+
from clawd_code_sdk.models.agents import AgentDefinition, ToolsPreset
|
|
17
|
+
from clawd_code_sdk.models.base import ModelName, PermissionMode, ReasoningEffort, SettingSource
|
|
18
|
+
from clawd_code_sdk.models.hooks import HookEvent, HookMatcher
|
|
19
|
+
from clawd_code_sdk.models.mcp import McpServerConfig, SdkPluginConfig
|
|
20
|
+
from clawd_code_sdk.models.permissions import CanUseTool
|
|
21
|
+
from clawd_code_sdk.models.settings import ClaudeCodeSettings, Sandbox
|
|
22
|
+
from clawd_code_sdk.models.thinking import ThinkingConfig
|
|
25
23
|
|
|
26
24
|
logger = logging.getLogger(__name__)
|
|
27
25
|
|
|
28
26
|
|
|
27
|
+
@dataclass(kw_only=True)
|
|
28
|
+
class AskUserQuestionToolConfig:
|
|
29
|
+
"""Configuration for the AskUserQuestion tool."""
|
|
30
|
+
|
|
31
|
+
preview_format: Literal["markdown", "html"] | None = None
|
|
32
|
+
"""Content format for the preview field on question options."""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(kw_only=True)
|
|
36
|
+
class ToolConfig:
|
|
37
|
+
"""Per-tool configuration for built-in tools."""
|
|
38
|
+
|
|
39
|
+
ask_user_question: AskUserQuestionToolConfig | None = None
|
|
40
|
+
|
|
41
|
+
|
|
29
42
|
# ============================================================================
|
|
30
43
|
# Session configuration
|
|
31
44
|
# ============================================================================
|
|
@@ -222,11 +235,17 @@ class ClaudeAgentOptions:
|
|
|
222
235
|
cwd: str | Path | None = None
|
|
223
236
|
"""The working directory for the agent."""
|
|
224
237
|
# Settings
|
|
225
|
-
settings: str | None = None
|
|
226
|
-
"""
|
|
238
|
+
settings: str | Path | ClaudeCodeSettings | None = None
|
|
239
|
+
"""Settings configuration.
|
|
240
|
+
|
|
241
|
+
Accepts:
|
|
242
|
+
- A ``str`` or ``Path``: interpreted as a path to a settings JSON file.
|
|
243
|
+
- A ``ClaudeCodeSettings`` instance: serialized to JSON automatically.
|
|
244
|
+
- ``None``: no explicit settings.
|
|
245
|
+
"""
|
|
227
246
|
setting_sources: list[SettingSource] | None = None
|
|
228
247
|
"""List of sources to load settings from."""
|
|
229
|
-
sandbox:
|
|
248
|
+
sandbox: Sandbox | None = None
|
|
230
249
|
"""Sandbox configuration for bash command isolation.
|
|
231
250
|
|
|
232
251
|
Filesystem and network restrictions are derived from permission rules (Read/Edit/WebFetch),
|
|
@@ -271,6 +290,11 @@ class ClaudeAgentOptions:
|
|
|
271
290
|
When enabled, files can be rewound to their state at any user message
|
|
272
291
|
using `ClaudeSDKClient.rewind_files()`.
|
|
273
292
|
"""
|
|
293
|
+
# TODO: tool_config is defined in upstream sdk.d.ts Options but not yet
|
|
294
|
+
# present in the CC settings JSON schema. Uncomment once settings.py is
|
|
295
|
+
# regenerated with the toolConfig field so it flows through --settings.
|
|
296
|
+
# tool_config: ToolConfig | None = None
|
|
297
|
+
# """Per-tool configuration for built-in tools."""
|
|
274
298
|
agent: str | None = None
|
|
275
299
|
"""Agent name for the main thread. The agent must be defined in `agents` or settings."""
|
|
276
300
|
context_1m: bool = False
|
|
@@ -283,41 +307,44 @@ class ClaudeAgentOptions:
|
|
|
283
307
|
"""Enable the experimental agent teams feature."""
|
|
284
308
|
|
|
285
309
|
def build_settings_value(self) -> str | None:
|
|
286
|
-
"""Build settings value, merging sandbox
|
|
310
|
+
"""Build the CLI ``--settings`` value, merging sandbox if provided.
|
|
287
311
|
|
|
288
|
-
Returns
|
|
289
|
-
|
|
290
|
-
- A file path (if only settings path is provided without sandbox)
|
|
291
|
-
- None if neither settings nor sandbox is provided
|
|
312
|
+
Returns:
|
|
313
|
+
A JSON string, a file path, or None.
|
|
292
314
|
"""
|
|
293
315
|
import anyenv
|
|
294
316
|
|
|
317
|
+
from clawd_code_sdk.models.settings import ClaudeCodeSettings as _Settings
|
|
318
|
+
|
|
295
319
|
has_settings = self.settings is not None
|
|
296
320
|
has_sandbox = self.sandbox is not None
|
|
297
321
|
|
|
298
322
|
if not has_settings and not has_sandbox:
|
|
299
323
|
return None
|
|
300
324
|
|
|
301
|
-
#
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
with settings_path.open(encoding="utf-8") as f:
|
|
318
|
-
settings_obj = json.load(f)
|
|
325
|
+
# Resolve settings to a dict (or pass through as file path)
|
|
326
|
+
settings_obj: dict[str, Any] | None = None
|
|
327
|
+
|
|
328
|
+
match self.settings:
|
|
329
|
+
case _Settings() as model:
|
|
330
|
+
settings_obj = model.model_dump(by_alias=True, exclude_none=True)
|
|
331
|
+
case str() | Path() as path:
|
|
332
|
+
if has_sandbox:
|
|
333
|
+
# Need to load file to merge sandbox into it
|
|
334
|
+
settings_path = Path(path)
|
|
335
|
+
if settings_path.exists():
|
|
336
|
+
with settings_path.open(encoding="utf-8") as f:
|
|
337
|
+
settings_obj = json.load(f)
|
|
338
|
+
else:
|
|
339
|
+
logger.warning("Settings file not found: %s", settings_path)
|
|
340
|
+
settings_obj = {}
|
|
319
341
|
else:
|
|
320
|
-
|
|
342
|
+
# No sandbox to merge, pass file path directly to CLI
|
|
343
|
+
return str(path)
|
|
344
|
+
case None:
|
|
345
|
+
settings_obj = {}
|
|
346
|
+
|
|
347
|
+
assert settings_obj is not None
|
|
321
348
|
|
|
322
349
|
# Merge sandbox settings
|
|
323
350
|
if has_sandbox:
|
|
@@ -108,18 +108,7 @@ class AgentAsyncLaunchedOutput(TypedDict):
|
|
|
108
108
|
"""Whether the calling agent has Read/Bash tools to check progress."""
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
"""Output from the Task tool when entering a sub-agent context."""
|
|
113
|
-
|
|
114
|
-
status: Literal["sub_agent_entered"]
|
|
115
|
-
"""Indicates a sub-agent context was entered."""
|
|
116
|
-
description: str
|
|
117
|
-
"""Description of the sub-agent task."""
|
|
118
|
-
message: str
|
|
119
|
-
"""Status message."""
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
AgentOutput = AgentCompletedOutput | AgentAsyncLaunchedOutput | AgentSubAgentEnteredOutput
|
|
111
|
+
AgentOutput = AgentCompletedOutput | AgentAsyncLaunchedOutput
|
|
123
112
|
|
|
124
113
|
|
|
125
114
|
# ---------------------------------------------------------------------------
|
|
@@ -151,6 +151,33 @@ class UserPlainTextDocumentPrompt:
|
|
|
151
151
|
return block
|
|
152
152
|
|
|
153
153
|
|
|
154
|
+
@dataclass
|
|
155
|
+
class UserFilePrompt:
|
|
156
|
+
"""A user prompt referencing a file uploaded via the Anthropic Files API."""
|
|
157
|
+
|
|
158
|
+
file_id: str
|
|
159
|
+
"""Anthropic file identifier (e.g. 'file_abc123')."""
|
|
160
|
+
title: str | None = None
|
|
161
|
+
"""Optional document title."""
|
|
162
|
+
context: str | None = None
|
|
163
|
+
"""Optional context about the document."""
|
|
164
|
+
|
|
165
|
+
def to_content_block(self) -> dict[str, Any]:
|
|
166
|
+
"""Return the Anthropic API content block dict."""
|
|
167
|
+
block: dict[str, Any] = {
|
|
168
|
+
"type": "document",
|
|
169
|
+
"source": {
|
|
170
|
+
"type": "file",
|
|
171
|
+
"file_id": self.file_id,
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
if self.title is not None:
|
|
175
|
+
block["title"] = self.title
|
|
176
|
+
if self.context is not None:
|
|
177
|
+
block["context"] = self.context
|
|
178
|
+
return block
|
|
179
|
+
|
|
180
|
+
|
|
154
181
|
UserPrompt = (
|
|
155
182
|
UserTextPrompt
|
|
156
183
|
| UserImagePrompt
|
|
@@ -158,5 +185,6 @@ UserPrompt = (
|
|
|
158
185
|
| UserDocumentPrompt
|
|
159
186
|
| UserDocumentURLPrompt
|
|
160
187
|
| UserPlainTextDocumentPrompt
|
|
188
|
+
| UserFilePrompt
|
|
161
189
|
)
|
|
162
190
|
"""Union type for all user prompt dataclasses."""
|
|
@@ -34,6 +34,9 @@ class ClaudeCodeModelInfo(ClaudeCodeBaseModel):
|
|
|
34
34
|
supports_adaptive_thinking: bool | None = None
|
|
35
35
|
"""Whether the model supports adaptive thinking."""
|
|
36
36
|
|
|
37
|
+
supports_fast_mode: bool | None = None
|
|
38
|
+
"""Whether the model supports fast mode."""
|
|
39
|
+
|
|
37
40
|
|
|
38
41
|
class ClaudeCodeCommandInfo(ClaudeCodeBaseModel):
|
|
39
42
|
"""Information about an available slash command from Claude Code."""
|