dotcode-sdk 0.1.0__py3-none-any.whl → 0.2.0__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.
dotcode_sdk/__init__.py CHANGED
@@ -8,38 +8,61 @@ Built by Gravicode Studios, led by Kang Fadhil.
8
8
  Example::
9
9
 
10
10
  import asyncio
11
- from dotcode_sdk import DotCodeClient
11
+ from dataclasses import dataclass
12
+ from typing import Annotated
13
+ from dotcode_sdk import DotCodeClient, PermissionHandler, define_tool
14
+ from dotcode_sdk.events import AssistantTextDeltaEvent
15
+
16
+ @dataclass
17
+ class WeatherParams:
18
+ city: Annotated[str, "City name"]
19
+
20
+ @define_tool(description="Weather for a city")
21
+ async def get_weather(params: WeatherParams) -> str:
22
+ return f"{params.city}: sunny"
12
23
 
13
24
  async def main():
14
25
  async with DotCodeClient() as client:
15
- session = await client.create_session(model="openai:gpt-5")
16
- result = await session.send("Summarize README.md")
17
- print(result["result"])
26
+ async with await client.create_session(model="openai:gpt-5", tools=[get_weather],
27
+ on_permission_request=PermissionHandler.approve_all) as session:
28
+ session.on(AssistantTextDeltaEvent, lambda e: print(e.text, end=""))
29
+ result = await session.send_and_wait("Weather in Bogor?")
30
+ print(result.cost_usd)
18
31
 
19
32
  asyncio.run(main())
20
33
  """
21
34
 
22
- from .client import DotCodeClient, Session, DotCodeError, tool, PROTOCOL_VERSION
35
+ from .client import PROTOCOL_VERSION, DotCodeClient, DotCodeError, DotCodeSession
36
+ from .events import (
37
+ AssistantMessageEvent, AssistantTextDeltaEvent, AssistantThinkingDeltaEvent, ContextCompactedEvent, ErrorEvent,
38
+ ModeChangedEvent, ModelChangedEvent, ModelFallbackEvent, NoticeEvent, RetryEvent, SessionEvent,
39
+ SubagentCompletedEvent, SubagentStartedEvent, TodoItem, TodoUpdatedEvent, ToolCompletedEvent, ToolProgressEvent,
40
+ ToolStartedEvent, TurnCompletedEvent, UnknownEvent, Usage, UsageUpdatedEvent, UserMessageEvent,
41
+ )
42
+ from .schema import ToolArgumentError, schema_for
43
+ from .tools import BinaryResult, Tool, ToolInvocation, ToolResult, define_tool
23
44
  from .types import (
24
- AgentEvent,
25
- PermissionDecision,
26
- PermissionRequest,
27
- SendResult,
28
- Tool,
29
- UserQuestion,
45
+ Attachment, BuiltinTool, ExitPlanModeRequest, ExitPlanModeResult, FileAttachment, ImageAttachment, Invocation,
46
+ McpHttpServer, McpStdioServer, ModelInfo, PermissionDecision, PermissionDecisionApproveAlways,
47
+ PermissionDecisionApproveForSession, PermissionDecisionApproveOnce, PermissionDecisionReject, PermissionHandler,
48
+ PermissionMode, PermissionRequest, ProviderConfig, QuestionOption, ReasoningEffort, SendResult, SessionMetadata,
49
+ SystemMessageConfig, ToolInfo, UserInputRequest, UserQuestion, UserQuestionAnswer,
30
50
  )
31
51
 
32
52
  __all__ = [
33
- "DotCodeClient",
34
- "Session",
35
- "DotCodeError",
36
- "tool",
37
- "PROTOCOL_VERSION",
38
- "AgentEvent",
39
- "PermissionDecision",
40
- "PermissionRequest",
41
- "SendResult",
42
- "Tool",
43
- "UserQuestion",
53
+ "PROTOCOL_VERSION", "DotCodeClient", "DotCodeError", "DotCodeSession",
54
+ "define_tool", "Tool", "ToolInvocation", "ToolResult", "BinaryResult", "ToolArgumentError", "schema_for",
55
+ "PermissionHandler", "PermissionRequest", "PermissionDecision", "PermissionDecisionApproveOnce",
56
+ "PermissionDecisionApproveForSession", "PermissionDecisionApproveAlways", "PermissionDecisionReject",
57
+ "UserInputRequest", "UserQuestion", "QuestionOption", "UserQuestionAnswer", "ExitPlanModeRequest",
58
+ "ExitPlanModeResult", "Invocation",
59
+ "BuiltinTool", "PermissionMode", "ReasoningEffort", "ProviderConfig", "McpStdioServer", "McpHttpServer",
60
+ "SystemMessageConfig", "Attachment", "FileAttachment", "ImageAttachment",
61
+ "SendResult", "SessionMetadata", "ModelInfo", "ToolInfo", "Usage", "TodoItem",
62
+ "SessionEvent", "UserMessageEvent", "AssistantTextDeltaEvent", "AssistantThinkingDeltaEvent",
63
+ "AssistantMessageEvent", "ToolStartedEvent", "ToolProgressEvent", "ToolCompletedEvent", "TodoUpdatedEvent",
64
+ "SubagentStartedEvent", "SubagentCompletedEvent", "ContextCompactedEvent", "UsageUpdatedEvent",
65
+ "ModelChangedEvent", "ModelFallbackEvent", "RetryEvent", "NoticeEvent", "ErrorEvent", "ModeChangedEvent",
66
+ "TurnCompletedEvent", "UnknownEvent",
44
67
  ]
45
- __version__ = "0.1.0"
68
+ __version__ = "0.2.0"