claude-agent-sdk 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
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.
Potentially problematic release.
This version of claude-agent-sdk might be problematic. Click here for more details.
- claude_agent_sdk/__init__.py +2 -0
- claude_agent_sdk/_internal/query.py +9 -3
- claude_agent_sdk/_version.py +1 -1
- claude_agent_sdk/types.py +65 -9
- {claude_agent_sdk-0.1.1.dist-info → claude_agent_sdk-0.1.2.dist-info}/METADATA +1 -1
- {claude_agent_sdk-0.1.1.dist-info → claude_agent_sdk-0.1.2.dist-info}/RECORD +8 -8
- {claude_agent_sdk-0.1.1.dist-info → claude_agent_sdk-0.1.2.dist-info}/WHEEL +0 -0
- {claude_agent_sdk-0.1.1.dist-info → claude_agent_sdk-0.1.2.dist-info}/licenses/LICENSE +0 -0
claude_agent_sdk/__init__.py
CHANGED
|
@@ -23,6 +23,7 @@ from .types import (
|
|
|
23
23
|
ContentBlock,
|
|
24
24
|
HookCallback,
|
|
25
25
|
HookContext,
|
|
26
|
+
HookJSONOutput,
|
|
26
27
|
HookMatcher,
|
|
27
28
|
McpSdkServerConfig,
|
|
28
29
|
McpServerConfig,
|
|
@@ -308,6 +309,7 @@ __all__ = [
|
|
|
308
309
|
"PermissionUpdate",
|
|
309
310
|
"HookCallback",
|
|
310
311
|
"HookContext",
|
|
312
|
+
"HookJSONOutput",
|
|
311
313
|
"HookMatcher",
|
|
312
314
|
# Agent support
|
|
313
315
|
"AgentDefinition",
|
|
@@ -195,6 +195,7 @@ class Query:
|
|
|
195
195
|
|
|
196
196
|
if subtype == "can_use_tool":
|
|
197
197
|
permission_request: SDKControlPermissionRequest = request_data # type: ignore[assignment]
|
|
198
|
+
original_input = permission_request["input"]
|
|
198
199
|
# Handle tool permission request
|
|
199
200
|
if not self.can_use_tool:
|
|
200
201
|
raise Exception("canUseTool callback is not provided")
|
|
@@ -213,9 +214,14 @@ class Query:
|
|
|
213
214
|
|
|
214
215
|
# Convert PermissionResult to expected dict format
|
|
215
216
|
if isinstance(response, PermissionResultAllow):
|
|
216
|
-
response_data = {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
response_data = {
|
|
218
|
+
"behavior": "allow",
|
|
219
|
+
"updatedInput": (
|
|
220
|
+
response.updated_input
|
|
221
|
+
if response.updated_input is not None
|
|
222
|
+
else original_input
|
|
223
|
+
),
|
|
224
|
+
}
|
|
219
225
|
if response.updated_permissions is not None:
|
|
220
226
|
response_data["updatedPermissions"] = [
|
|
221
227
|
permission.to_dict()
|
claude_agent_sdk/_version.py
CHANGED
claude_agent_sdk/types.py
CHANGED
|
@@ -157,18 +157,74 @@ HookEvent = (
|
|
|
157
157
|
)
|
|
158
158
|
|
|
159
159
|
|
|
160
|
+
# Hook-specific output types
|
|
161
|
+
class PreToolUseHookSpecificOutput(TypedDict):
|
|
162
|
+
"""Hook-specific output for PreToolUse events."""
|
|
163
|
+
|
|
164
|
+
hookEventName: Literal["PreToolUse"]
|
|
165
|
+
permissionDecision: NotRequired[Literal["allow", "deny", "ask"]]
|
|
166
|
+
permissionDecisionReason: NotRequired[str]
|
|
167
|
+
updatedInput: NotRequired[dict[str, Any]]
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class PostToolUseHookSpecificOutput(TypedDict):
|
|
171
|
+
"""Hook-specific output for PostToolUse events."""
|
|
172
|
+
|
|
173
|
+
hookEventName: Literal["PostToolUse"]
|
|
174
|
+
additionalContext: NotRequired[str]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class UserPromptSubmitHookSpecificOutput(TypedDict):
|
|
178
|
+
"""Hook-specific output for UserPromptSubmit events."""
|
|
179
|
+
|
|
180
|
+
hookEventName: Literal["UserPromptSubmit"]
|
|
181
|
+
additionalContext: NotRequired[str]
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class SessionStartHookSpecificOutput(TypedDict):
|
|
185
|
+
"""Hook-specific output for SessionStart events."""
|
|
186
|
+
|
|
187
|
+
hookEventName: Literal["SessionStart"]
|
|
188
|
+
additionalContext: NotRequired[str]
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
HookSpecificOutput = (
|
|
192
|
+
PreToolUseHookSpecificOutput
|
|
193
|
+
| PostToolUseHookSpecificOutput
|
|
194
|
+
| UserPromptSubmitHookSpecificOutput
|
|
195
|
+
| SessionStartHookSpecificOutput
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
|
|
160
199
|
# See https://docs.anthropic.com/en/docs/claude-code/hooks#advanced%3A-json-output
|
|
161
|
-
# for documentation of the output types.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
200
|
+
# for documentation of the output types.
|
|
201
|
+
class AsyncHookJSONOutput(TypedDict):
|
|
202
|
+
"""Async hook output that defers hook execution."""
|
|
203
|
+
|
|
204
|
+
async_: Literal[True] # Using async_ to avoid Python keyword
|
|
205
|
+
asyncTimeout: NotRequired[int]
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class SyncHookJSONOutput(TypedDict):
|
|
209
|
+
"""Synchronous hook output with control and decision fields."""
|
|
210
|
+
|
|
211
|
+
# Common control fields
|
|
212
|
+
continue_: NotRequired[bool] # Using continue_ to avoid Python keyword
|
|
213
|
+
suppressOutput: NotRequired[bool]
|
|
214
|
+
stopReason: NotRequired[str]
|
|
215
|
+
|
|
216
|
+
# Decision fields
|
|
217
|
+
# Note: "approve" is deprecated for PreToolUse (use permissionDecision instead)
|
|
218
|
+
# For other hooks, only "block" is meaningful
|
|
165
219
|
decision: NotRequired[Literal["block"]]
|
|
166
|
-
# Optionally add a system message that is not visible to Claude but saved in
|
|
167
|
-
# the chat transcript.
|
|
168
220
|
systemMessage: NotRequired[str]
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
221
|
+
reason: NotRequired[str]
|
|
222
|
+
|
|
223
|
+
# Hook-specific outputs
|
|
224
|
+
hookSpecificOutput: NotRequired[HookSpecificOutput]
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput
|
|
172
228
|
|
|
173
229
|
|
|
174
230
|
@dataclass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: claude-agent-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Python SDK for Claude Code
|
|
5
5
|
Project-URL: Homepage, https://github.com/anthropics/claude-agent-sdk-python
|
|
6
6
|
Project-URL: Documentation, https://docs.anthropic.com/en/docs/claude-code/sdk
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
claude_agent_sdk/__init__.py,sha256=
|
|
1
|
+
claude_agent_sdk/__init__.py,sha256=QRRGe-x2Hi5OhaWijWFmkdNj8KGTCWZSLnY1joHxRvo,11626
|
|
2
2
|
claude_agent_sdk/_errors.py,sha256=nSdJNNeszvXG1PfnXd2sQpVNORqMct-MfPaiM3XeJL4,1579
|
|
3
|
-
claude_agent_sdk/_version.py,sha256=
|
|
3
|
+
claude_agent_sdk/_version.py,sha256=gH3XIeCoHbr7H3mMURVo0sN_jBTdSnmewcxVv7F24Kc,71
|
|
4
4
|
claude_agent_sdk/client.py,sha256=Bye3QKb-iTg6Yq34ZPGHzaMg1isT9RvyHs5TkC2jWDI,13926
|
|
5
5
|
claude_agent_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
claude_agent_sdk/query.py,sha256=WebhztsMZPdaxyy1LBEZv4_j23vjp_ceX9DtrBsZqCA,4530
|
|
7
|
-
claude_agent_sdk/types.py,sha256=
|
|
7
|
+
claude_agent_sdk/types.py,sha256=x_0tT1ZfisSUrcMdyWRIrrPNe1gWW1zU-T8onoMauxY,13308
|
|
8
8
|
claude_agent_sdk/_internal/__init__.py,sha256=zDdgjqp8SI9mTnwZbP2Be-w4LWlv4a3kA-TS2i75jsM,39
|
|
9
9
|
claude_agent_sdk/_internal/client.py,sha256=Z06Fj4t5mHkKHKBUwxmHMTEo7lzs3X4_D_c-xq6Wg4I,4603
|
|
10
10
|
claude_agent_sdk/_internal/message_parser.py,sha256=xxpOU3E8X21FCoy2OtLWKfEQr3AFYM454qJt6Xa0tmc,6475
|
|
11
|
-
claude_agent_sdk/_internal/query.py,sha256=
|
|
11
|
+
claude_agent_sdk/_internal/query.py,sha256=miJS8pS215PFXirmdfgS2D5FFz4G9Dk25IHyeXUPeqQ,21165
|
|
12
12
|
claude_agent_sdk/_internal/transport/__init__.py,sha256=sv8Iy1b9YmPlXu4XsdN98gJIlyrLtwq8PKQyF4qnQLk,1978
|
|
13
13
|
claude_agent_sdk/_internal/transport/subprocess_cli.py,sha256=ViZxmHoAx3NdFNgLUFgNYuCjJZdVqKk2sxHlB57Z2ng,19097
|
|
14
|
-
claude_agent_sdk-0.1.
|
|
15
|
-
claude_agent_sdk-0.1.
|
|
16
|
-
claude_agent_sdk-0.1.
|
|
17
|
-
claude_agent_sdk-0.1.
|
|
14
|
+
claude_agent_sdk-0.1.2.dist-info/METADATA,sha256=ZcJHSdWOTUETMnexdpm_QhqiyZfJP8nSj3XnIKDJ7D0,9648
|
|
15
|
+
claude_agent_sdk-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
claude_agent_sdk-0.1.2.dist-info/licenses/LICENSE,sha256=zr3eio-57lnl6q7RlXi_gIWqcEdWIlnDHzjyJcJvaBI,1070
|
|
17
|
+
claude_agent_sdk-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|