clawd-code-sdk 1.2.2__tar.gz → 1.2.3__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-1.2.2 → clawd_code_sdk-1.2.3}/PKG-INFO +2 -2
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/pyproject.toml +2 -2
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/anthropic_stream.py +11 -4
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/__init__.py +18 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/content_blocks.py +152 -5
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/messages.py +9 -1
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/storage/replay.py +66 -3
- clawd_code_sdk-1.2.3/tests/test_api_content_blocks.py +183 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/.gitignore +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/LICENSE +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/README.md +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/__init__.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_bundled/.gitignore +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_errors.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/__init__.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/mcp_compat.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/query.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/sdk_mcp_bridge.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/session_mutations.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/sessions.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/transport/__init__.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/transport/subprocess_cli.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/transport/subprocess_utils.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_version.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/client.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/instrumentation.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/list_sessions.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/mcp_utils.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/agents.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/anthropic_types.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/base.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/context_usage.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/control.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/hooks.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/input_types.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/mcp.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/options.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/output_types.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/permissions.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/prompt_requests.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/prompts.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/server_info.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/session.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/settings.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/system_messages.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/thinking.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/models/usage.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/py.typed +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/session.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/storage/ARCHITECTURE.md +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/storage/__init__.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/storage/helpers.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/storage/models.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/usage.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/__init__.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/conftest.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/__init__.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_agents_and_settings.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_dynamic_control.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_hook_events.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_hooks.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_include_partial_messages.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_mcp_resources.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_mcp_tools.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_sdk_mcp_resources.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_sdk_mcp_tools.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_slash_commands.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_stderr_callback.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_storage_parsing.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_structured_output.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_subagent_invocation.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/e2e/test_tool_permissions.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/mcp_server.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/mock_claude_server.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_changelog.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_client.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_elicitation_mcp_conversion.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_errors.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_image.png +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_integration.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_line_framing.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_message_parser.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_result_error.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_sandbox_settings.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_sdk_0_3_types.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_sdk_mcp_integration.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_session.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_session_mutations.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_sessions.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_streaming_client.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_subprocess_buffering.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_tool_callbacks.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_transport.py +0 -0
- {clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/tests/test_transport_close.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: clawd-code-sdk
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
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
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
18
|
Classifier: Typing :: Typed
|
|
19
19
|
Requires-Python: >=3.13
|
|
20
|
-
Requires-Dist: anthropic>=
|
|
20
|
+
Requires-Dist: anthropic>=2.9.0
|
|
21
21
|
Requires-Dist: anyenv>=2.0.15
|
|
22
22
|
Requires-Dist: anyio>=4.0.0
|
|
23
23
|
Requires-Dist: jsonschema>=4.20.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "clawd-code-sdk"
|
|
3
|
-
version = "1.2.
|
|
3
|
+
version = "1.2.3"
|
|
4
4
|
description = "Python SDK for Claude Code"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.13"
|
|
@@ -19,7 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Typing :: Typed",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
-
"anthropic>=
|
|
22
|
+
"anthropic>=2.9.0", # BetaFallbackBlock / BetaMCPToolListingBlock
|
|
23
23
|
"anyenv>=2.0.15",
|
|
24
24
|
"anyio>=4.0.0",
|
|
25
25
|
"logfire>=4.31.0",
|
|
@@ -42,6 +42,7 @@ from clawd_code_sdk.models.content_blocks import (
|
|
|
42
42
|
TextBlock,
|
|
43
43
|
ThinkingBlock,
|
|
44
44
|
ToolUseBlock,
|
|
45
|
+
is_server_block,
|
|
45
46
|
)
|
|
46
47
|
|
|
47
48
|
|
|
@@ -54,6 +55,7 @@ if TYPE_CHECKING:
|
|
|
54
55
|
)
|
|
55
56
|
|
|
56
57
|
from clawd_code_sdk.models import Message
|
|
58
|
+
from clawd_code_sdk.models.content_blocks import AssistantContentBlock, ServerContentBlock
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
async def to_anthropic_events(
|
|
@@ -171,9 +173,14 @@ def _synthesize_events(
|
|
|
171
173
|
|
|
172
174
|
|
|
173
175
|
def _to_anthropic_block(
|
|
174
|
-
block:
|
|
175
|
-
) -> ATextBlock | AThinkingBlock | AToolUseBlock | None:
|
|
176
|
-
"""Convert a content block to its Anthropic start-event form (empty content).
|
|
176
|
+
block: AssistantContentBlock,
|
|
177
|
+
) -> ATextBlock | AThinkingBlock | AToolUseBlock | ServerContentBlock | None:
|
|
178
|
+
"""Convert a content block to its Anthropic start-event form (empty content).
|
|
179
|
+
|
|
180
|
+
API-produced blocks already are Anthropic models and are sent complete.
|
|
181
|
+
"""
|
|
182
|
+
if is_server_block(block):
|
|
183
|
+
return block
|
|
177
184
|
match block:
|
|
178
185
|
case TextBlock():
|
|
179
186
|
return ATextBlock(type="text", text="")
|
|
@@ -186,7 +193,7 @@ def _to_anthropic_block(
|
|
|
186
193
|
|
|
187
194
|
|
|
188
195
|
def _to_anthropic_delta(
|
|
189
|
-
block:
|
|
196
|
+
block: AssistantContentBlock,
|
|
190
197
|
) -> BetaTextDelta | BetaThinkingDelta | BetaInputJSONDeltaType | None:
|
|
191
198
|
"""Convert a content block's content into a single delta event."""
|
|
192
199
|
from anthropic.types.beta import BetaInputJSONDelta
|
|
@@ -306,7 +306,16 @@ from .content_blocks import (
|
|
|
306
306
|
AssistantContentBlock,
|
|
307
307
|
AssistantMessageContent,
|
|
308
308
|
ContentBlock,
|
|
309
|
+
Base64PDFSource,
|
|
310
|
+
ContentDocumentSource,
|
|
311
|
+
DocumentBlock,
|
|
312
|
+
DocumentSource,
|
|
313
|
+
FileDocumentSource,
|
|
309
314
|
ImageBlock,
|
|
315
|
+
PlainTextSource,
|
|
316
|
+
SERVER_CONTENT_BLOCK_TYPES,
|
|
317
|
+
ServerContentBlock,
|
|
318
|
+
URLPDFSource,
|
|
310
319
|
ImageSource,
|
|
311
320
|
MessageParam,
|
|
312
321
|
TextBlock,
|
|
@@ -487,6 +496,7 @@ If not provided, elicitation requests will be declined automatically.
|
|
|
487
496
|
"""
|
|
488
497
|
|
|
489
498
|
__all__ = [
|
|
499
|
+
"SERVER_CONTENT_BLOCK_TYPES",
|
|
490
500
|
"TOOL_INPUT_TYPES",
|
|
491
501
|
"TOOL_USE_RESULT_TYPES",
|
|
492
502
|
"APIRetrySystemMessage",
|
|
@@ -518,6 +528,7 @@ __all__ = [
|
|
|
518
528
|
"AsyncHookJSONOutput",
|
|
519
529
|
"AuthStatusMessage",
|
|
520
530
|
"BackgroundTasksChangedMessage",
|
|
531
|
+
"Base64PDFSource",
|
|
521
532
|
"BaseHookInput",
|
|
522
533
|
"BaseResultMessage",
|
|
523
534
|
"BaseSessionConfig",
|
|
@@ -539,6 +550,7 @@ __all__ = [
|
|
|
539
550
|
"CompactBoundarySystemMessage",
|
|
540
551
|
"ConfigOutput",
|
|
541
552
|
"ContentBlock",
|
|
553
|
+
"ContentDocumentSource",
|
|
542
554
|
"ContextUsageAgent",
|
|
543
555
|
"ContextUsageAttachmentBreakdown",
|
|
544
556
|
"ContextUsageCategory",
|
|
@@ -563,7 +575,9 @@ __all__ = [
|
|
|
563
575
|
"CwdChangedHookInput",
|
|
564
576
|
"CwdChangedHookSpecificOutput",
|
|
565
577
|
"DirectoryAddedHookInput",
|
|
578
|
+
"DocumentBlock",
|
|
566
579
|
"DocumentMediaType",
|
|
580
|
+
"DocumentSource",
|
|
567
581
|
"EditOutput",
|
|
568
582
|
"ElicitationAction",
|
|
569
583
|
"ElicitationCompleteMessage",
|
|
@@ -584,6 +598,7 @@ __all__ = [
|
|
|
584
598
|
"FastModeState",
|
|
585
599
|
"FileChangedHookInput",
|
|
586
600
|
"FileChangedHookSpecificOutput",
|
|
601
|
+
"FileDocumentSource",
|
|
587
602
|
"FileEditInput",
|
|
588
603
|
"FileReadInput",
|
|
589
604
|
"FileWriteInput",
|
|
@@ -686,6 +701,7 @@ __all__ = [
|
|
|
686
701
|
"PermissionUpdateDestination",
|
|
687
702
|
"Permissions",
|
|
688
703
|
"PlainTextMediaType",
|
|
704
|
+
"PlainTextSource",
|
|
689
705
|
"PluginInstallSystemMessage",
|
|
690
706
|
"PostCompactHookInput",
|
|
691
707
|
"PostModelSwitchHookInput",
|
|
@@ -792,6 +808,7 @@ __all__ = [
|
|
|
792
808
|
"Sandbox",
|
|
793
809
|
"SdkBeta",
|
|
794
810
|
"SdkPluginConfig",
|
|
811
|
+
"ServerContentBlock",
|
|
795
812
|
"SessionConfig",
|
|
796
813
|
"SessionEndHookInput",
|
|
797
814
|
"SessionKey",
|
|
@@ -853,6 +870,7 @@ __all__ = [
|
|
|
853
870
|
"ToolUseSummaryMessage",
|
|
854
871
|
"ToolsPreset",
|
|
855
872
|
"TriggerMetadata",
|
|
873
|
+
"URLPDFSource",
|
|
856
874
|
"Usage",
|
|
857
875
|
"UserContentBlock",
|
|
858
876
|
"UserDocumentPrompt",
|
|
@@ -8,9 +8,26 @@ therefore serves both purposes, avoiding a redundant conversion layer.
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
10
|
from collections.abc import Sequence
|
|
11
|
-
from typing import TYPE_CHECKING, Annotated, Any, Literal, assert_never, cast
|
|
11
|
+
from typing import TYPE_CHECKING, Annotated, Any, Literal, TypeIs, assert_never, cast, get_args
|
|
12
12
|
|
|
13
13
|
from anthropic.types import Model
|
|
14
|
+
from anthropic.types.beta import (
|
|
15
|
+
BetaAdvisorToolResultBlock,
|
|
16
|
+
BetaBashCodeExecutionToolResultBlock,
|
|
17
|
+
BetaCodeExecutionToolResultBlock,
|
|
18
|
+
BetaCompactionBlock,
|
|
19
|
+
BetaContainerUploadBlock,
|
|
20
|
+
BetaFallbackBlock,
|
|
21
|
+
BetaMCPToolListingBlock,
|
|
22
|
+
BetaMCPToolResultBlock,
|
|
23
|
+
BetaMCPToolUseBlock,
|
|
24
|
+
BetaRedactedThinkingBlock,
|
|
25
|
+
BetaServerToolUseBlock,
|
|
26
|
+
BetaTextEditorCodeExecutionToolResultBlock,
|
|
27
|
+
BetaToolSearchToolResultBlock,
|
|
28
|
+
BetaWebFetchToolResultBlock,
|
|
29
|
+
BetaWebSearchToolResultBlock,
|
|
30
|
+
)
|
|
14
31
|
from anthropic.types.beta.beta_tool_use_block import Caller
|
|
15
32
|
from pydantic import BaseModel, ConfigDict, Discriminator
|
|
16
33
|
|
|
@@ -21,6 +38,7 @@ from clawd_code_sdk.models.base import ClaudeCodeBaseModel, StopReason, ToolName
|
|
|
21
38
|
if TYPE_CHECKING:
|
|
22
39
|
from logfire._internal.integrations.llm_providers.semconv import (
|
|
23
40
|
BlobPart,
|
|
41
|
+
MessagePart,
|
|
24
42
|
ReasoningPart,
|
|
25
43
|
TextPart,
|
|
26
44
|
ToolCallPart,
|
|
@@ -148,24 +166,153 @@ class ImageBlock(BaseContentBlock):
|
|
|
148
166
|
)
|
|
149
167
|
|
|
150
168
|
|
|
169
|
+
class Base64PDFSource(BaseContentBlock):
|
|
170
|
+
"""Base64-encoded PDF document."""
|
|
171
|
+
|
|
172
|
+
type: Literal["base64"] = "base64"
|
|
173
|
+
media_type: Literal["application/pdf"] = "application/pdf"
|
|
174
|
+
data: str
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class PlainTextSource(BaseContentBlock):
|
|
178
|
+
"""Plain text document."""
|
|
179
|
+
|
|
180
|
+
type: Literal["text"] = "text"
|
|
181
|
+
media_type: Literal["text/plain"] = "text/plain"
|
|
182
|
+
data: str
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class URLPDFSource(BaseContentBlock):
|
|
186
|
+
"""PDF document referenced by URL."""
|
|
187
|
+
|
|
188
|
+
type: Literal["url"] = "url"
|
|
189
|
+
url: str
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class FileDocumentSource(BaseContentBlock):
|
|
193
|
+
"""Document uploaded through the Files API."""
|
|
194
|
+
|
|
195
|
+
type: Literal["file"] = "file"
|
|
196
|
+
file_id: str
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class ContentDocumentSource(BaseContentBlock):
|
|
200
|
+
"""Document made of content blocks (text / images)."""
|
|
201
|
+
|
|
202
|
+
type: Literal["content"] = "content"
|
|
203
|
+
content: str | list[dict[str, Any]]
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
type DocumentSource = Annotated[
|
|
207
|
+
Base64PDFSource | PlainTextSource | URLPDFSource | FileDocumentSource | ContentDocumentSource,
|
|
208
|
+
Discriminator("type"),
|
|
209
|
+
]
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class DocumentBlock(BaseContentBlock):
|
|
213
|
+
"""Document content block (e.g. an attached PDF) in a user message."""
|
|
214
|
+
|
|
215
|
+
type: Literal["document"] = "document"
|
|
216
|
+
source: DocumentSource
|
|
217
|
+
title: str | None = None
|
|
218
|
+
context: str | None = None
|
|
219
|
+
citations: dict[str, Any] | None = None
|
|
220
|
+
|
|
221
|
+
|
|
151
222
|
# =============================================================================
|
|
152
223
|
# Unions and adapters
|
|
153
224
|
# =============================================================================
|
|
154
225
|
|
|
226
|
+
type ServerContentBlock = (
|
|
227
|
+
BetaRedactedThinkingBlock
|
|
228
|
+
| BetaServerToolUseBlock
|
|
229
|
+
| BetaWebSearchToolResultBlock
|
|
230
|
+
| BetaWebFetchToolResultBlock
|
|
231
|
+
| BetaAdvisorToolResultBlock
|
|
232
|
+
| BetaCodeExecutionToolResultBlock
|
|
233
|
+
| BetaBashCodeExecutionToolResultBlock
|
|
234
|
+
| BetaTextEditorCodeExecutionToolResultBlock
|
|
235
|
+
| BetaToolSearchToolResultBlock
|
|
236
|
+
| BetaMCPToolUseBlock
|
|
237
|
+
| BetaMCPToolResultBlock
|
|
238
|
+
| BetaContainerUploadBlock
|
|
239
|
+
| BetaCompactionBlock
|
|
240
|
+
| BetaFallbackBlock
|
|
241
|
+
| BetaMCPToolListingBlock
|
|
242
|
+
)
|
|
243
|
+
"""Assistant content blocks produced by the API itself (server tools, MCP connector, ...).
|
|
244
|
+
|
|
245
|
+
These use the Anthropic SDK's models directly; clawd has no extra behaviour for them.
|
|
246
|
+
"""
|
|
247
|
+
|
|
248
|
+
SERVER_CONTENT_BLOCK_TYPES: tuple[type[BaseModel], ...] = get_args(ServerContentBlock.__value__)
|
|
249
|
+
"""Runtime tuple of :data:`ServerContentBlock` members (for ``isinstance`` checks)."""
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def is_server_block(block: object) -> TypeIs[ServerContentBlock]:
|
|
253
|
+
"""Whether a content block was produced by the API itself (see :data:`ServerContentBlock`)."""
|
|
254
|
+
return isinstance(block, SERVER_CONTENT_BLOCK_TYPES)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def server_block_to_otel(block: ServerContentBlock) -> MessagePart | None:
|
|
258
|
+
"""OpenTelemetry semconv part for an API-produced block (None if it has no equivalent)."""
|
|
259
|
+
from logfire._internal.integrations.llm_providers.semconv import (
|
|
260
|
+
ReasoningPart,
|
|
261
|
+
ToolCallPart,
|
|
262
|
+
ToolCallResponsePart,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
match block:
|
|
266
|
+
case BetaRedactedThinkingBlock():
|
|
267
|
+
return ReasoningPart(type="reasoning", content="[redacted]")
|
|
268
|
+
case (
|
|
269
|
+
BetaServerToolUseBlock(id=tool_id, name=name, input=input_)
|
|
270
|
+
| BetaMCPToolUseBlock(id=tool_id, name=name, input=input_)
|
|
271
|
+
):
|
|
272
|
+
return ToolCallPart(type="tool_call", id=tool_id, name=name, arguments=input_)
|
|
273
|
+
case (
|
|
274
|
+
BetaWebSearchToolResultBlock(tool_use_id=tool_id)
|
|
275
|
+
| BetaWebFetchToolResultBlock(tool_use_id=tool_id)
|
|
276
|
+
| BetaAdvisorToolResultBlock(tool_use_id=tool_id)
|
|
277
|
+
| BetaCodeExecutionToolResultBlock(tool_use_id=tool_id)
|
|
278
|
+
| BetaBashCodeExecutionToolResultBlock(tool_use_id=tool_id)
|
|
279
|
+
| BetaTextEditorCodeExecutionToolResultBlock(tool_use_id=tool_id)
|
|
280
|
+
| BetaToolSearchToolResultBlock(tool_use_id=tool_id)
|
|
281
|
+
| BetaMCPToolResultBlock(tool_use_id=tool_id)
|
|
282
|
+
):
|
|
283
|
+
response = block.model_dump(mode="json", exclude={"type", "tool_use_id"})
|
|
284
|
+
return ToolCallResponsePart(type="tool_call_response", id=tool_id, response=response)
|
|
285
|
+
case (
|
|
286
|
+
BetaContainerUploadBlock()
|
|
287
|
+
| BetaCompactionBlock()
|
|
288
|
+
| BetaFallbackBlock()
|
|
289
|
+
| BetaMCPToolListingBlock()
|
|
290
|
+
):
|
|
291
|
+
return None
|
|
292
|
+
case _ as unreachable:
|
|
293
|
+
assert_never(unreachable)
|
|
294
|
+
|
|
295
|
+
|
|
155
296
|
AssistantContentBlock = Annotated[
|
|
156
|
-
TextBlock | ThinkingBlock | ToolUseBlock,
|
|
297
|
+
TextBlock | ThinkingBlock | ToolUseBlock | ServerContentBlock,
|
|
157
298
|
Discriminator("type"),
|
|
158
299
|
]
|
|
159
|
-
"""Content blocks that appear in assistant messages."""
|
|
300
|
+
"""Content blocks that appear in assistant messages (any Messages API block type)."""
|
|
160
301
|
|
|
161
302
|
UserContentBlock = Annotated[
|
|
162
|
-
TextBlock | ToolResultBlock | ImageBlock,
|
|
303
|
+
TextBlock | ToolResultBlock | ImageBlock | DocumentBlock,
|
|
163
304
|
Discriminator("type"),
|
|
164
305
|
]
|
|
165
306
|
"""Content blocks that appear in user messages."""
|
|
166
307
|
|
|
167
308
|
ContentBlock = Annotated[
|
|
168
|
-
TextBlock
|
|
309
|
+
TextBlock
|
|
310
|
+
| ThinkingBlock
|
|
311
|
+
| ToolUseBlock
|
|
312
|
+
| ToolResultBlock
|
|
313
|
+
| ImageBlock
|
|
314
|
+
| DocumentBlock
|
|
315
|
+
| ServerContentBlock,
|
|
169
316
|
Discriminator("type"),
|
|
170
317
|
]
|
|
171
318
|
"""All content block types (used for storage/JSONL which doesn't distinguish by role)."""
|
|
@@ -404,7 +404,15 @@ class AssistantMessage(BaseModel):
|
|
|
404
404
|
"""Convert SDK content block objects into semconv OutputMessages."""
|
|
405
405
|
from logfire._internal.integrations.llm_providers.semconv import OutputMessage
|
|
406
406
|
|
|
407
|
-
|
|
407
|
+
from clawd_code_sdk.models.content_blocks import is_server_block, server_block_to_otel
|
|
408
|
+
|
|
409
|
+
parts: list[MessagePart] = []
|
|
410
|
+
for block in self.content:
|
|
411
|
+
if is_server_block(block):
|
|
412
|
+
if (part := server_block_to_otel(block)) is not None:
|
|
413
|
+
parts.append(part)
|
|
414
|
+
else:
|
|
415
|
+
parts.append(block.to_otel())
|
|
408
416
|
return OutputMessage(role="assistant", parts=parts)
|
|
409
417
|
|
|
410
418
|
|
|
@@ -54,11 +54,32 @@ from __future__ import annotations
|
|
|
54
54
|
import json as _json
|
|
55
55
|
from typing import TYPE_CHECKING, assert_never
|
|
56
56
|
|
|
57
|
-
from anthropic.types.beta import
|
|
57
|
+
from anthropic.types.beta import (
|
|
58
|
+
BetaAdvisorToolResultBlock,
|
|
59
|
+
BetaBashCodeExecutionToolResultBlock,
|
|
60
|
+
BetaCodeExecutionToolResultBlock,
|
|
61
|
+
BetaCompactionBlock,
|
|
62
|
+
BetaContainerUploadBlock,
|
|
63
|
+
BetaFallbackBlock,
|
|
64
|
+
BetaMCPToolListingBlock,
|
|
65
|
+
BetaMCPToolResultBlock,
|
|
66
|
+
BetaMCPToolUseBlock,
|
|
67
|
+
BetaMessage,
|
|
68
|
+
BetaRawContentBlockStartEvent,
|
|
69
|
+
BetaRawMessageStartEvent,
|
|
70
|
+
BetaRedactedThinkingBlock,
|
|
71
|
+
BetaServerToolUseBlock,
|
|
72
|
+
BetaTextEditorCodeExecutionToolResultBlock,
|
|
73
|
+
BetaToolSearchToolResultBlock,
|
|
74
|
+
BetaUsage,
|
|
75
|
+
BetaWebFetchToolResultBlock,
|
|
76
|
+
BetaWebSearchToolResultBlock,
|
|
77
|
+
)
|
|
58
78
|
|
|
59
79
|
from clawd_code_sdk.models import (
|
|
60
80
|
AssistantMessage,
|
|
61
81
|
AssistantMessageContent,
|
|
82
|
+
DocumentBlock,
|
|
62
83
|
ImageBlock,
|
|
63
84
|
MessageParam,
|
|
64
85
|
ResultErrorMessage,
|
|
@@ -184,8 +205,30 @@ def _make_block_start(
|
|
|
184
205
|
yield StreamEvent.block_start_tool_use(
|
|
185
206
|
tool_use_id=block_id, name=name, index=index, session_id=session_id, uuid=uuid
|
|
186
207
|
)
|
|
187
|
-
case ToolResultBlock() | ImageBlock():
|
|
208
|
+
case ToolResultBlock() | ImageBlock() | DocumentBlock():
|
|
188
209
|
return
|
|
210
|
+
case (
|
|
211
|
+
BetaRedactedThinkingBlock()
|
|
212
|
+
| BetaServerToolUseBlock()
|
|
213
|
+
| BetaWebSearchToolResultBlock()
|
|
214
|
+
| BetaWebFetchToolResultBlock()
|
|
215
|
+
| BetaAdvisorToolResultBlock()
|
|
216
|
+
| BetaCodeExecutionToolResultBlock()
|
|
217
|
+
| BetaBashCodeExecutionToolResultBlock()
|
|
218
|
+
| BetaTextEditorCodeExecutionToolResultBlock()
|
|
219
|
+
| BetaToolSearchToolResultBlock()
|
|
220
|
+
| BetaMCPToolUseBlock()
|
|
221
|
+
| BetaMCPToolResultBlock()
|
|
222
|
+
| BetaContainerUploadBlock()
|
|
223
|
+
| BetaCompactionBlock()
|
|
224
|
+
| BetaFallbackBlock()
|
|
225
|
+
| BetaMCPToolListingBlock()
|
|
226
|
+
):
|
|
227
|
+
# API-produced blocks arrive complete in their content_block_start.
|
|
228
|
+
event = BetaRawContentBlockStartEvent(
|
|
229
|
+
type="content_block_start", index=index, content_block=block
|
|
230
|
+
)
|
|
231
|
+
yield StreamEvent(event=event, session_id=session_id, uuid=uuid)
|
|
189
232
|
case _ as unreachable:
|
|
190
233
|
assert_never(unreachable)
|
|
191
234
|
|
|
@@ -220,7 +263,27 @@ def _make_block_delta(
|
|
|
220
263
|
session_id=session_id,
|
|
221
264
|
uuid=uuid,
|
|
222
265
|
)
|
|
223
|
-
|
|
266
|
+
# Results, images, documents and API-produced blocks carry no deltas.
|
|
267
|
+
case (
|
|
268
|
+
ToolResultBlock()
|
|
269
|
+
| ImageBlock()
|
|
270
|
+
| DocumentBlock()
|
|
271
|
+
| BetaRedactedThinkingBlock()
|
|
272
|
+
| BetaServerToolUseBlock()
|
|
273
|
+
| BetaWebSearchToolResultBlock()
|
|
274
|
+
| BetaWebFetchToolResultBlock()
|
|
275
|
+
| BetaAdvisorToolResultBlock()
|
|
276
|
+
| BetaCodeExecutionToolResultBlock()
|
|
277
|
+
| BetaBashCodeExecutionToolResultBlock()
|
|
278
|
+
| BetaTextEditorCodeExecutionToolResultBlock()
|
|
279
|
+
| BetaToolSearchToolResultBlock()
|
|
280
|
+
| BetaMCPToolUseBlock()
|
|
281
|
+
| BetaMCPToolResultBlock()
|
|
282
|
+
| BetaContainerUploadBlock()
|
|
283
|
+
| BetaCompactionBlock()
|
|
284
|
+
| BetaFallbackBlock()
|
|
285
|
+
| BetaMCPToolListingBlock()
|
|
286
|
+
):
|
|
224
287
|
return
|
|
225
288
|
case _ as unreachable:
|
|
226
289
|
assert_never(unreachable)
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"""Parsing of every Messages API content block type in assistant and user messages."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, get_args
|
|
6
|
+
|
|
7
|
+
from anthropic.types.beta import BetaContentBlock
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from clawd_code_sdk.anthropic_stream import _synthesize_events
|
|
11
|
+
from clawd_code_sdk.models import (
|
|
12
|
+
SERVER_CONTENT_BLOCK_TYPES,
|
|
13
|
+
AssistantMessage,
|
|
14
|
+
DocumentBlock,
|
|
15
|
+
TextBlock,
|
|
16
|
+
ThinkingBlock,
|
|
17
|
+
ToolUseBlock,
|
|
18
|
+
UserMessage,
|
|
19
|
+
message_adapter,
|
|
20
|
+
)
|
|
21
|
+
from clawd_code_sdk.models.content_blocks import is_server_block, server_block_to_otel
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
SERVER_BLOCKS: dict[str, dict[str, Any]] = {
|
|
25
|
+
"redacted_thinking": {"type": "redacted_thinking", "data": "EmwKAhgBEgy3va3pzix/LafPsn4a"},
|
|
26
|
+
"server_tool_use": {
|
|
27
|
+
"type": "server_tool_use",
|
|
28
|
+
"id": "srvtoolu_01",
|
|
29
|
+
"name": "web_search",
|
|
30
|
+
"input": {"query": "python 3.14"},
|
|
31
|
+
},
|
|
32
|
+
"web_search_tool_result": {
|
|
33
|
+
"type": "web_search_tool_result",
|
|
34
|
+
"tool_use_id": "srvtoolu_01",
|
|
35
|
+
"content": [
|
|
36
|
+
{
|
|
37
|
+
"type": "web_search_result",
|
|
38
|
+
"title": "Python 3.14",
|
|
39
|
+
"url": "https://python.org",
|
|
40
|
+
"encrypted_content": "abc",
|
|
41
|
+
"page_age": None,
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
"web_fetch_tool_result": {
|
|
46
|
+
"type": "web_fetch_tool_result",
|
|
47
|
+
"tool_use_id": "srvtoolu_02",
|
|
48
|
+
"content": {"type": "web_fetch_tool_result_error", "error_code": "url_not_accessible"},
|
|
49
|
+
},
|
|
50
|
+
"code_execution_tool_result": {
|
|
51
|
+
"type": "code_execution_tool_result",
|
|
52
|
+
"tool_use_id": "srvtoolu_03",
|
|
53
|
+
"content": {
|
|
54
|
+
"type": "code_execution_result",
|
|
55
|
+
"stdout": "1",
|
|
56
|
+
"stderr": "",
|
|
57
|
+
"return_code": 0,
|
|
58
|
+
"content": [],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
"mcp_tool_use": {
|
|
62
|
+
"type": "mcp_tool_use",
|
|
63
|
+
"id": "mcptoolu_01",
|
|
64
|
+
"name": "search",
|
|
65
|
+
"server_name": "docs",
|
|
66
|
+
"input": {"q": "x"},
|
|
67
|
+
},
|
|
68
|
+
"mcp_tool_result": {
|
|
69
|
+
"type": "mcp_tool_result",
|
|
70
|
+
"tool_use_id": "mcptoolu_01",
|
|
71
|
+
"is_error": False,
|
|
72
|
+
"content": [{"type": "text", "text": "found"}],
|
|
73
|
+
},
|
|
74
|
+
"container_upload": {"type": "container_upload", "file_id": "file_01"},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _assistant(*blocks: dict[str, Any]) -> dict[str, Any]:
|
|
79
|
+
return {
|
|
80
|
+
"type": "assistant",
|
|
81
|
+
"session_id": "s",
|
|
82
|
+
"uuid": "u",
|
|
83
|
+
"parent_tool_use_id": None,
|
|
84
|
+
"message": {
|
|
85
|
+
"id": "msg_01",
|
|
86
|
+
"type": "message",
|
|
87
|
+
"role": "assistant",
|
|
88
|
+
"model": "claude-sonnet-5",
|
|
89
|
+
"stop_reason": None,
|
|
90
|
+
"stop_sequence": None,
|
|
91
|
+
"content": list(blocks),
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@pytest.mark.parametrize("block_type", sorted(SERVER_BLOCKS))
|
|
97
|
+
def test_assistant_message_accepts_api_block(block_type: str) -> None:
|
|
98
|
+
message = message_adapter.validate_python(_assistant(SERVER_BLOCKS[block_type]))
|
|
99
|
+
assert isinstance(message, AssistantMessage)
|
|
100
|
+
(block,) = message.content
|
|
101
|
+
assert is_server_block(block)
|
|
102
|
+
assert block.type == block_type
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_every_anthropic_content_block_type_is_accepted() -> None:
|
|
106
|
+
"""New Messages API block types must fail here, not at runtime."""
|
|
107
|
+
own = {TextBlock, ThinkingBlock, ToolUseBlock}
|
|
108
|
+
own_types = {cls.model_fields["type"].default for cls in own}
|
|
109
|
+
covered = own_types | {cls.model_fields["type"].default for cls in SERVER_CONTENT_BLOCK_TYPES}
|
|
110
|
+
api_types = {
|
|
111
|
+
cls.model_fields["type"].default for cls in get_args(get_args(BetaContentBlock)[0])
|
|
112
|
+
}
|
|
113
|
+
assert api_types <= covered
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_mixed_assistant_content_keeps_order() -> None:
|
|
117
|
+
data = _assistant(
|
|
118
|
+
{"type": "thinking", "thinking": "hmm", "signature": "sig"},
|
|
119
|
+
SERVER_BLOCKS["server_tool_use"],
|
|
120
|
+
SERVER_BLOCKS["web_search_tool_result"],
|
|
121
|
+
{"type": "text", "text": "Done."},
|
|
122
|
+
)
|
|
123
|
+
message = message_adapter.validate_python(data)
|
|
124
|
+
assert isinstance(message, AssistantMessage)
|
|
125
|
+
assert [b.type for b in message.content] == [
|
|
126
|
+
"thinking",
|
|
127
|
+
"server_tool_use",
|
|
128
|
+
"web_search_tool_result",
|
|
129
|
+
"text",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_api_blocks_convert_to_stream_events_and_otel() -> None:
|
|
134
|
+
message = message_adapter.validate_python(
|
|
135
|
+
_assistant(SERVER_BLOCKS["server_tool_use"], SERVER_BLOCKS["web_search_tool_result"])
|
|
136
|
+
)
|
|
137
|
+
assert isinstance(message, AssistantMessage)
|
|
138
|
+
events = _synthesize_events(message)
|
|
139
|
+
starts = [e for e in events if e.type == "content_block_start"]
|
|
140
|
+
assert [s.content_block.type for s in starts] == ["server_tool_use", "web_search_tool_result"]
|
|
141
|
+
tool_use, tool_result = message.content
|
|
142
|
+
assert is_server_block(tool_use)
|
|
143
|
+
assert is_server_block(tool_result)
|
|
144
|
+
call = server_block_to_otel(tool_use)
|
|
145
|
+
response = server_block_to_otel(tool_result)
|
|
146
|
+
assert call is not None
|
|
147
|
+
assert call["type"] == "tool_call"
|
|
148
|
+
assert response is not None
|
|
149
|
+
assert response["type"] == "tool_call_response"
|
|
150
|
+
otel = message.to_otel()
|
|
151
|
+
assert [p["type"] for p in otel["parts"]] == ["tool_call", "tool_call_response"]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@pytest.mark.parametrize(
|
|
155
|
+
"source",
|
|
156
|
+
[
|
|
157
|
+
{"type": "base64", "media_type": "application/pdf", "data": "JVBERi0x"},
|
|
158
|
+
{"type": "text", "media_type": "text/plain", "data": "hello"},
|
|
159
|
+
{"type": "url", "url": "https://example.com/a.pdf"},
|
|
160
|
+
{"type": "file", "file_id": "file_01"},
|
|
161
|
+
],
|
|
162
|
+
)
|
|
163
|
+
def test_user_message_accepts_document(source: dict[str, Any]) -> None:
|
|
164
|
+
data = {
|
|
165
|
+
"type": "user",
|
|
166
|
+
"session_id": "s",
|
|
167
|
+
"uuid": "u",
|
|
168
|
+
"parent_tool_use_id": None,
|
|
169
|
+
"message": {
|
|
170
|
+
"role": "user",
|
|
171
|
+
"content": [
|
|
172
|
+
{"type": "document", "source": source, "title": "Spec"},
|
|
173
|
+
{"type": "text", "text": "Summarize this"},
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
message = message_adapter.validate_python(data)
|
|
178
|
+
assert isinstance(message, UserMessage)
|
|
179
|
+
assert not isinstance(message.content, str)
|
|
180
|
+
document = message.content[0]
|
|
181
|
+
assert isinstance(document, DocumentBlock)
|
|
182
|
+
assert document.source.type == source["type"]
|
|
183
|
+
assert document.title == "Spec"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/sdk_mcp_bridge.py
RENAMED
|
File without changes
|
{clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/session_mutations.py
RENAMED
|
File without changes
|
|
File without changes
|
{clawd_code_sdk-1.2.2 → clawd_code_sdk-1.2.3}/src/clawd_code_sdk/_internal/transport/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|