clawd-code-sdk 1.2.3__tar.gz → 1.2.4__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.3 → clawd_code_sdk-1.2.4}/PKG-INFO +1 -1
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/pyproject.toml +1 -1
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/client.py +10 -3
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/__init__.py +8 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/context_usage.py +47 -2
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/control.py +15 -0
- clawd_code_sdk-1.2.4/tests/test_get_usage.py +91 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/.gitignore +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/LICENSE +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/README.md +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/__init__.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_bundled/.gitignore +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_errors.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/__init__.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/mcp_compat.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/query.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/sdk_mcp_bridge.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/session_mutations.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/sessions.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/transport/__init__.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/transport/subprocess_cli.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/transport/subprocess_utils.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_version.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/anthropic_stream.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/instrumentation.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/list_sessions.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/mcp_utils.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/agents.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/anthropic_types.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/base.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/content_blocks.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/hooks.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/input_types.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/mcp.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/messages.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/options.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/output_types.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/permissions.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/prompt_requests.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/prompts.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/server_info.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/session.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/settings.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/system_messages.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/thinking.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/models/usage.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/py.typed +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/session.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/storage/ARCHITECTURE.md +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/storage/__init__.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/storage/helpers.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/storage/models.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/storage/replay.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/usage.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/__init__.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/conftest.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/__init__.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_agents_and_settings.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_dynamic_control.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_hook_events.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_hooks.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_include_partial_messages.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_mcp_resources.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_mcp_tools.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_sdk_mcp_resources.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_sdk_mcp_tools.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_slash_commands.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_stderr_callback.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_storage_parsing.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_structured_output.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_subagent_invocation.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/e2e/test_tool_permissions.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/mcp_server.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/mock_claude_server.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_api_content_blocks.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_changelog.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_client.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_elicitation_mcp_conversion.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_errors.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_image.png +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_integration.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_line_framing.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_message_parser.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_result_error.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_sandbox_settings.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_sdk_0_3_types.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_sdk_mcp_integration.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_session.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_session_mutations.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_sessions.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_streaming_client.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_subprocess_buffering.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_tool_callbacks.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/tests/test_transport.py +0 -0
- {clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/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.4
|
|
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
|
|
@@ -39,6 +39,7 @@ from clawd_code_sdk.models import (
|
|
|
39
39
|
SDKControlGetTaskOutputRequest,
|
|
40
40
|
SDKControlGetTaskOutputResponse,
|
|
41
41
|
SDKControlGetUsageRequest,
|
|
42
|
+
SDKControlGetUsageResponse,
|
|
42
43
|
SDKControlInitializeRequest,
|
|
43
44
|
SDKControlInterruptRequest,
|
|
44
45
|
SDKControlInterruptResponse,
|
|
@@ -629,11 +630,17 @@ class ClaudeSDKClient:
|
|
|
629
630
|
result = await query._send_control_request(request)
|
|
630
631
|
return SDKControlGetTaskOutputResponse.model_validate(result)
|
|
631
632
|
|
|
632
|
-
async def get_usage(self, *, skip_behaviors: bool =
|
|
633
|
-
"""Get
|
|
633
|
+
async def get_usage(self, *, skip_behaviors: bool = True) -> SDKControlGetUsageResponse:
|
|
634
|
+
"""Get session usage and plan rate-limit windows (experimental, shape may change).
|
|
635
|
+
|
|
636
|
+
Args:
|
|
637
|
+
skip_behaviors: Skip the (slow) scan of local transcripts that fills
|
|
638
|
+
``behaviors``.
|
|
639
|
+
"""
|
|
634
640
|
query = self._ensure_connected()
|
|
635
641
|
request = SDKControlGetUsageRequest(skip_behaviors=skip_behaviors or None)
|
|
636
|
-
|
|
642
|
+
result = await query._send_control_request(request)
|
|
643
|
+
return SDKControlGetUsageResponse.model_validate(result)
|
|
637
644
|
|
|
638
645
|
async def get_binary_version(self) -> dict[str, Any]:
|
|
639
646
|
"""Get version info of the running Claude Code binary."""
|
|
@@ -49,12 +49,16 @@ from .context_usage import (
|
|
|
49
49
|
SDKContextUsage,
|
|
50
50
|
SDKUsageReport,
|
|
51
51
|
ContextUsageMcpInstructions,
|
|
52
|
+
ModelScopedUsageWindow,
|
|
53
|
+
UsageRateLimits,
|
|
54
|
+
UsageWindow,
|
|
52
55
|
)
|
|
53
56
|
from .control import (
|
|
54
57
|
SDKControlInterruptResponse,
|
|
55
58
|
SDKControlBackgroundTasksRequest,
|
|
56
59
|
SDKControlGetTaskOutputRequest,
|
|
57
60
|
SDKControlGetTaskOutputResponse,
|
|
61
|
+
SDKControlGetUsageResponse,
|
|
58
62
|
SDKControlGetUsageRequest,
|
|
59
63
|
SDKControlGetBinaryVersionRequest,
|
|
60
64
|
SDKControlListModelsRequest,
|
|
@@ -674,6 +678,7 @@ __all__ = [
|
|
|
674
678
|
"MiscMessages",
|
|
675
679
|
"ModelRefusalFallbackMessage",
|
|
676
680
|
"ModelRefusalNoFallbackMessage",
|
|
681
|
+
"ModelScopedUsageWindow",
|
|
677
682
|
"ModelUsage",
|
|
678
683
|
"Network",
|
|
679
684
|
"NewSession",
|
|
@@ -762,6 +767,7 @@ __all__ = [
|
|
|
762
767
|
"SDKControlGetTaskOutputRequest",
|
|
763
768
|
"SDKControlGetTaskOutputResponse",
|
|
764
769
|
"SDKControlGetUsageRequest",
|
|
770
|
+
"SDKControlGetUsageResponse",
|
|
765
771
|
"SDKControlInitializeRequest",
|
|
766
772
|
"SDKControlInterruptRequest",
|
|
767
773
|
"SDKControlInterruptResponse",
|
|
@@ -872,6 +878,8 @@ __all__ = [
|
|
|
872
878
|
"TriggerMetadata",
|
|
873
879
|
"URLPDFSource",
|
|
874
880
|
"Usage",
|
|
881
|
+
"UsageRateLimits",
|
|
882
|
+
"UsageWindow",
|
|
875
883
|
"UserContentBlock",
|
|
876
884
|
"UserDocumentPrompt",
|
|
877
885
|
"UserDocumentURLPrompt",
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import Literal
|
|
6
6
|
|
|
7
|
-
from pydantic import Field
|
|
7
|
+
from pydantic import ConfigDict, Field
|
|
8
8
|
|
|
9
9
|
from clawd_code_sdk.models.base import ClaudeCodeBaseModel
|
|
10
10
|
from clawd_code_sdk.models.usage import ModelUsage, Usage
|
|
@@ -274,6 +274,7 @@ class UsageReportDisplayName(ClaudeCodeBaseModel):
|
|
|
274
274
|
"""Wrapper holding a display name."""
|
|
275
275
|
|
|
276
276
|
display_name: str
|
|
277
|
+
id: str | None = None
|
|
277
278
|
|
|
278
279
|
|
|
279
280
|
class UsageReportLimitScope(ClaudeCodeBaseModel):
|
|
@@ -296,7 +297,13 @@ class UsageReportLimit(ClaudeCodeBaseModel):
|
|
|
296
297
|
|
|
297
298
|
|
|
298
299
|
class UsageReportExtraUsage(ClaudeCodeBaseModel):
|
|
299
|
-
"""Extra (overage) usage state.
|
|
300
|
+
"""Extra (overage) usage state.
|
|
301
|
+
|
|
302
|
+
Passed through from the claude.ai usage endpoint, which adds fields freely; unknown
|
|
303
|
+
fields are ignored even in strict (test) mode.
|
|
304
|
+
"""
|
|
305
|
+
|
|
306
|
+
model_config = ConfigDict(extra="ignore")
|
|
300
307
|
|
|
301
308
|
is_enabled: bool
|
|
302
309
|
monthly_limit: float | None
|
|
@@ -312,6 +319,44 @@ class UsageReportRateLimits(ClaudeCodeBaseModel):
|
|
|
312
319
|
extra_usage: UsageReportExtraUsage | None = None
|
|
313
320
|
|
|
314
321
|
|
|
322
|
+
class UsageWindow(ClaudeCodeBaseModel):
|
|
323
|
+
"""Utilization of one plan rate-limit window."""
|
|
324
|
+
|
|
325
|
+
model_config = ConfigDict(extra="ignore") # server-defined, see UsageReportExtraUsage
|
|
326
|
+
|
|
327
|
+
utilization: float | None
|
|
328
|
+
"""Percentage of the window used, 0-100."""
|
|
329
|
+
resets_at: str | None
|
|
330
|
+
"""ISO 8601 timestamp of the window's reset."""
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class ModelScopedUsageWindow(UsageWindow):
|
|
334
|
+
"""Per-model weekly window."""
|
|
335
|
+
|
|
336
|
+
display_name: str
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class UsageRateLimits(ClaudeCodeBaseModel):
|
|
340
|
+
"""Plan rate-limit windows from the claude.ai usage endpoint.
|
|
341
|
+
|
|
342
|
+
Only the fields documented by the TypeScript SDK are modelled; the endpoint carries
|
|
343
|
+
many experimental extras, which are ignored.
|
|
344
|
+
"""
|
|
345
|
+
|
|
346
|
+
model_config = ConfigDict(extra="ignore")
|
|
347
|
+
|
|
348
|
+
five_hour: UsageWindow | None = None
|
|
349
|
+
seven_day: UsageWindow | None = None
|
|
350
|
+
seven_day_oauth_apps: UsageWindow | None = None
|
|
351
|
+
seven_day_opus: UsageWindow | None = None
|
|
352
|
+
seven_day_sonnet: UsageWindow | None = None
|
|
353
|
+
model_scoped: list[ModelScopedUsageWindow] | None = None
|
|
354
|
+
"""Per-model weekly windows (absent when unknown, empty when there are none)."""
|
|
355
|
+
extra_usage: UsageReportExtraUsage | None = None
|
|
356
|
+
limits: list[UsageReportLimit] | None = None
|
|
357
|
+
"""The server's usage rows, in the server's order (render verbatim)."""
|
|
358
|
+
|
|
359
|
+
|
|
315
360
|
class SDKUsageReport(ClaudeCodeBaseModel):
|
|
316
361
|
"""Session usage report (same data as /usage)."""
|
|
317
362
|
|
|
@@ -15,6 +15,7 @@ from clawd_code_sdk.models.base import (
|
|
|
15
15
|
ModelName,
|
|
16
16
|
PermissionMode,
|
|
17
17
|
)
|
|
18
|
+
from clawd_code_sdk.models.context_usage import UsageRateLimits, UsageReportSession
|
|
18
19
|
from clawd_code_sdk.models.hooks import HookEvent, HookInput
|
|
19
20
|
from clawd_code_sdk.models.mcp import (
|
|
20
21
|
ExternalMcpServerConfig,
|
|
@@ -671,6 +672,20 @@ class SDKControlGetUsageRequest(_ControlBase):
|
|
|
671
672
|
skip_behaviors: bool | None = None
|
|
672
673
|
|
|
673
674
|
|
|
675
|
+
class SDKControlGetUsageResponse(ClaudeCodeBaseModel):
|
|
676
|
+
"""Structured /usage data: session totals and plan rate-limit windows. Experimental."""
|
|
677
|
+
|
|
678
|
+
session: UsageReportSession
|
|
679
|
+
"""Cost and usage accumulated by the current session."""
|
|
680
|
+
subscription_type: str | None
|
|
681
|
+
"""claude.ai plan (e.g. "pro", "max"), None without a subscription."""
|
|
682
|
+
rate_limits_available: bool
|
|
683
|
+
"""False when plan limits do not apply (API key, Bedrock, Vertex, ...)."""
|
|
684
|
+
rate_limits: UsageRateLimits | None
|
|
685
|
+
behaviors: dict[str, Any] | None = None
|
|
686
|
+
"""What contributes to usage, from a scan of local transcripts (None if skipped)."""
|
|
687
|
+
|
|
688
|
+
|
|
674
689
|
class SDKControlGetBinaryVersionRequest(_ControlBase):
|
|
675
690
|
"""Requests the version of the running Claude Code binary."""
|
|
676
691
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""The get_usage control response (real response shape, trimmed)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from clawd_code_sdk.models import SDKControlGetUsageResponse
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
WINDOW_EXTRAS = {"limit_dollars": None, "used_dollars": None, "locked_reason": None}
|
|
11
|
+
|
|
12
|
+
RESPONSE: dict[str, Any] = {
|
|
13
|
+
"session": {
|
|
14
|
+
"total_cost_usd": 0,
|
|
15
|
+
"total_api_duration_ms": 0,
|
|
16
|
+
"total_duration_ms": 475,
|
|
17
|
+
"total_lines_added": 0,
|
|
18
|
+
"total_lines_removed": 0,
|
|
19
|
+
"model_usage": {},
|
|
20
|
+
},
|
|
21
|
+
"subscription_type": "pro",
|
|
22
|
+
"rate_limits_available": True,
|
|
23
|
+
"rate_limits": {
|
|
24
|
+
"five_hour": {
|
|
25
|
+
"utilization": 66,
|
|
26
|
+
"resets_at": "2026-11-20T09:39:59.762577+00:00",
|
|
27
|
+
**WINDOW_EXTRAS,
|
|
28
|
+
},
|
|
29
|
+
"seven_day": {
|
|
30
|
+
"utilization": 35,
|
|
31
|
+
"resets_at": "2026-11-22T12:59:59.762597+00:00",
|
|
32
|
+
**WINDOW_EXTRAS,
|
|
33
|
+
},
|
|
34
|
+
"seven_day_opus": None,
|
|
35
|
+
"extra_usage": {
|
|
36
|
+
"is_enabled": False,
|
|
37
|
+
"monthly_limit": None,
|
|
38
|
+
"used_credits": None,
|
|
39
|
+
"utilization": None,
|
|
40
|
+
"currency": None,
|
|
41
|
+
"spend_limit_reached": False,
|
|
42
|
+
},
|
|
43
|
+
"limits": [
|
|
44
|
+
{
|
|
45
|
+
"kind": "session",
|
|
46
|
+
"group": "session",
|
|
47
|
+
"percent": 66,
|
|
48
|
+
"resets_at": "2026-11-20T09:39:59.762577+00:00",
|
|
49
|
+
"severity": "normal",
|
|
50
|
+
"is_active": True,
|
|
51
|
+
"scope": None,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"kind": "weekly_scoped",
|
|
55
|
+
"group": "weekly",
|
|
56
|
+
"percent": 0,
|
|
57
|
+
"resets_at": "2026-11-22T13:00:00+00:00",
|
|
58
|
+
"severity": "normal",
|
|
59
|
+
"is_active": False,
|
|
60
|
+
"scope": {"model": {"id": None, "display_name": "Fable"}, "surface": None},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
"model_scoped": [
|
|
64
|
+
{"display_name": "Fable", "utilization": 0, "resets_at": "2026-11-22T13:00:00+00:00"}
|
|
65
|
+
],
|
|
66
|
+
# Undocumented, experimental fields are ignored
|
|
67
|
+
"pace": {"status": "on_track"},
|
|
68
|
+
"spend": {"percent": 0},
|
|
69
|
+
},
|
|
70
|
+
"behaviors": None,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_parses_real_response() -> None:
|
|
75
|
+
usage = SDKControlGetUsageResponse.model_validate(RESPONSE)
|
|
76
|
+
assert usage.subscription_type == "pro"
|
|
77
|
+
limits = usage.rate_limits
|
|
78
|
+
assert limits is not None
|
|
79
|
+
assert limits.five_hour is not None
|
|
80
|
+
assert limits.five_hour.utilization == 66
|
|
81
|
+
assert limits.seven_day_opus is None
|
|
82
|
+
assert limits.model_scoped is not None
|
|
83
|
+
assert limits.model_scoped[0].display_name == "Fable"
|
|
84
|
+
assert limits.limits is not None
|
|
85
|
+
assert [row.kind for row in limits.limits] == ["session", "weekly_scoped"]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_without_plan_limits() -> None:
|
|
89
|
+
data = {**RESPONSE, "subscription_type": None, "rate_limits_available": False}
|
|
90
|
+
usage = SDKControlGetUsageResponse.model_validate({**data, "rate_limits": None})
|
|
91
|
+
assert usage.rate_limits is None
|
|
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.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/sdk_mcp_bridge.py
RENAMED
|
File without changes
|
{clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/src/clawd_code_sdk/_internal/session_mutations.py
RENAMED
|
File without changes
|
|
File without changes
|
{clawd_code_sdk-1.2.3 → clawd_code_sdk-1.2.4}/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
|
|
File without changes
|
|
File without changes
|