dotcode-sdk 0.1.0__tar.gz → 0.2.0__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.
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: dotcode-sdk
3
+ Version: 0.2.0
4
+ Summary: Python SDK for DotCode — embed a multi-LLM coding agent (Anthropic, OpenAI, Azure, Gemini, DeepSeek, Ollama) in your app. By Gravicode Studios, led by Kang Fadhil.
5
+ Author: Gravicode Studios (Kang Fadhil)
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/DotNetVibeCoderz/Vibe_Dev
8
+ Project-URL: Repository, https://github.com/DotNetVibeCoderz/Vibe_Dev
9
+ Keywords: ai,agent,coding-agent,llm,claude,openai,gemini,deepseek,ollama,mcp,dotcode
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Topic :: Software Development
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Provides-Extra: pydantic
19
+ Requires-Dist: pydantic>=2; extra == "pydantic"
20
+ Dynamic: license-file
21
+
22
+ # DotCode SDK — Python
23
+
24
+ Embed the [DotCode](https://github.com/DotNetVibeCoderz/Vibe_Dev) coding agent in your application and drive it with **any LLM** (Anthropic, OpenAI, Azure OpenAI, Gemini, DeepSeek, Ollama, OpenAI-compatible). The SDK talks JSON-RPC to a `dotcode serve` process.
25
+
26
+ *Built by Gravicode Studios, led by Kang Fadhil.* · 🇮🇩 Dokumentasi Bahasa Indonesia: [docs/id/sdk.md](https://github.com/DotNetVibeCoderz/Vibe_Dev/blob/main/DotCode/docs/id/sdk.md)
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install dotcode-sdk
32
+ ```
33
+
34
+ The SDK needs the `dotcode` CLI: put it on `PATH` or set `DOTCODE_CLI_PATH` (a path to `dotcode.dll` is started with `dotnet`). Configure providers with environment variables (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `DEEPSEEK_API_KEY`, …), `~/.dotcode/settings.json`, or per session with the typed `providers` option.
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ import asyncio
40
+ from dataclasses import dataclass
41
+ from typing import Annotated
42
+ from dotcode_sdk import DotCodeClient, PermissionHandler, ToolCompletedEvent, AssistantTextDeltaEvent, define_tool
43
+
44
+ @dataclass
45
+ class WeatherParams: # parameters are a class, never a hand-written JSON schema
46
+ city: Annotated[str, "City name"]
47
+
48
+ @define_tool(description="Weather for a city")
49
+ async def get_weather(params: WeatherParams) -> str:
50
+ return f"{params.city}: 24°C" # a typo like params.cty is flagged by mypy/pyright
51
+
52
+ async def main():
53
+ async with DotCodeClient() as client: # spawns `dotcode serve`
54
+ async with await client.create_session(
55
+ model="deepseek:deepseek-v4-flash",
56
+ tools=[get_weather],
57
+ on_permission_request=PermissionHandler.approve_all,
58
+ ) as session:
59
+ session.on(AssistantTextDeltaEvent, lambda e: print(e.text, end=""))
60
+ session.on(ToolCompletedEvent, lambda e: print(f"
61
+ ✔ {e.name}: {e.summary}"))
62
+ result = await session.send_and_wait("What's the weather in Bogor?")
63
+ print(result.cost_usd)
64
+
65
+ asyncio.run(main())
66
+ ```
67
+
68
+ Parameter classes can be `@dataclass`es, `TypedDict`s or pydantic models (`pip install dotcode-sdk[pydantic]`).
69
+ Arguments are validated and converted before your handler runs; mismatches are reported back to the model.
70
+ Options, events (`match event: case ToolCompletedEvent(name=n): ...`), permission decisions, built-in tool names
71
+ (`BuiltinTool.READ`, `BuiltinTool.BASH.rule("npm test:*")`) and providers (`ProviderConfig(type="ollama")`) are
72
+ all typed, and the package ships `py.typed`.
73
+
74
+ ## API
75
+
76
+ | | |
77
+ |---|---|
78
+ | `DotCodeClient` | `start()`, `create_session(...)`, `resume_session(id, fork=..., ...)`, `list_sessions()`, `list_models()`, `ping()`, `stop()`, `force_stop()` |
79
+ | `DotCodeSession` | `send(prompt)` (returns once dispatched), `send_and_wait(prompt, timeout=)`, `stream(prompt)`, `on(handler)` / `on(EventClass, handler)`, `abort()`, `set_model()`, `set_permission_mode()`, `set_reasoning_effort()`, `compact()`, `clear()`, `get_messages()`, `list_tools()`, `disconnect()` |
80
+ | Tools | `@define_tool(description=..., read_only=...)`; handlers take `(params)`, `(params, invocation)`, `(invocation)` or nothing and return a string, a `ToolResult` or any JSON value |
81
+ | Permissions | `PermissionHandler.approve_all` / `reject_all`, or return `PermissionDecisionApproveOnce()`, `PermissionDecisionApproveForSession()`, `PermissionDecisionApproveAlways(rule)`, `PermissionDecisionReject(feedback)`; sessions are deny-by-default without a handler |
82
+ | Other handlers | `on_user_input_request` (AskUserQuestion), `on_exit_plan_mode` (plan review), `on_event` |
83
+ | Options | `model`, `fallback_model`, `working_directory`, `permission_mode`, `reasoning_effort`, `system_message`, `available_tools`, `allowed_tools`, `excluded_tools`, `mcp_servers` (`McpStdioServer` / `McpHttpServer`), `providers` (BYOK), `max_turns`, `persist_session`, `worktree`, `disable_mcp` |
84
+
85
+ Full guide: [docs/en/sdk.md](https://github.com/DotNetVibeCoderz/Vibe_Dev/blob/main/DotCode/docs/en/sdk.md) · Protocol: [schema/protocol.schema.json](https://github.com/DotNetVibeCoderz/Vibe_Dev/blob/main/DotCode/schema/protocol.schema.json)
86
+
87
+ License: MIT
@@ -0,0 +1,66 @@
1
+ # DotCode SDK — Python
2
+
3
+ Embed the [DotCode](https://github.com/DotNetVibeCoderz/Vibe_Dev) coding agent in your application and drive it with **any LLM** (Anthropic, OpenAI, Azure OpenAI, Gemini, DeepSeek, Ollama, OpenAI-compatible). The SDK talks JSON-RPC to a `dotcode serve` process.
4
+
5
+ *Built by Gravicode Studios, led by Kang Fadhil.* · 🇮🇩 Dokumentasi Bahasa Indonesia: [docs/id/sdk.md](https://github.com/DotNetVibeCoderz/Vibe_Dev/blob/main/DotCode/docs/id/sdk.md)
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install dotcode-sdk
11
+ ```
12
+
13
+ The SDK needs the `dotcode` CLI: put it on `PATH` or set `DOTCODE_CLI_PATH` (a path to `dotcode.dll` is started with `dotnet`). Configure providers with environment variables (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `DEEPSEEK_API_KEY`, …), `~/.dotcode/settings.json`, or per session with the typed `providers` option.
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ import asyncio
19
+ from dataclasses import dataclass
20
+ from typing import Annotated
21
+ from dotcode_sdk import DotCodeClient, PermissionHandler, ToolCompletedEvent, AssistantTextDeltaEvent, define_tool
22
+
23
+ @dataclass
24
+ class WeatherParams: # parameters are a class, never a hand-written JSON schema
25
+ city: Annotated[str, "City name"]
26
+
27
+ @define_tool(description="Weather for a city")
28
+ async def get_weather(params: WeatherParams) -> str:
29
+ return f"{params.city}: 24°C" # a typo like params.cty is flagged by mypy/pyright
30
+
31
+ async def main():
32
+ async with DotCodeClient() as client: # spawns `dotcode serve`
33
+ async with await client.create_session(
34
+ model="deepseek:deepseek-v4-flash",
35
+ tools=[get_weather],
36
+ on_permission_request=PermissionHandler.approve_all,
37
+ ) as session:
38
+ session.on(AssistantTextDeltaEvent, lambda e: print(e.text, end=""))
39
+ session.on(ToolCompletedEvent, lambda e: print(f"
40
+ ✔ {e.name}: {e.summary}"))
41
+ result = await session.send_and_wait("What's the weather in Bogor?")
42
+ print(result.cost_usd)
43
+
44
+ asyncio.run(main())
45
+ ```
46
+
47
+ Parameter classes can be `@dataclass`es, `TypedDict`s or pydantic models (`pip install dotcode-sdk[pydantic]`).
48
+ Arguments are validated and converted before your handler runs; mismatches are reported back to the model.
49
+ Options, events (`match event: case ToolCompletedEvent(name=n): ...`), permission decisions, built-in tool names
50
+ (`BuiltinTool.READ`, `BuiltinTool.BASH.rule("npm test:*")`) and providers (`ProviderConfig(type="ollama")`) are
51
+ all typed, and the package ships `py.typed`.
52
+
53
+ ## API
54
+
55
+ | | |
56
+ |---|---|
57
+ | `DotCodeClient` | `start()`, `create_session(...)`, `resume_session(id, fork=..., ...)`, `list_sessions()`, `list_models()`, `ping()`, `stop()`, `force_stop()` |
58
+ | `DotCodeSession` | `send(prompt)` (returns once dispatched), `send_and_wait(prompt, timeout=)`, `stream(prompt)`, `on(handler)` / `on(EventClass, handler)`, `abort()`, `set_model()`, `set_permission_mode()`, `set_reasoning_effort()`, `compact()`, `clear()`, `get_messages()`, `list_tools()`, `disconnect()` |
59
+ | Tools | `@define_tool(description=..., read_only=...)`; handlers take `(params)`, `(params, invocation)`, `(invocation)` or nothing and return a string, a `ToolResult` or any JSON value |
60
+ | Permissions | `PermissionHandler.approve_all` / `reject_all`, or return `PermissionDecisionApproveOnce()`, `PermissionDecisionApproveForSession()`, `PermissionDecisionApproveAlways(rule)`, `PermissionDecisionReject(feedback)`; sessions are deny-by-default without a handler |
61
+ | Other handlers | `on_user_input_request` (AskUserQuestion), `on_exit_plan_mode` (plan review), `on_event` |
62
+ | Options | `model`, `fallback_model`, `working_directory`, `permission_mode`, `reasoning_effort`, `system_message`, `available_tools`, `allowed_tools`, `excluded_tools`, `mcp_servers` (`McpStdioServer` / `McpHttpServer`), `providers` (BYOK), `max_turns`, `persist_session`, `worktree`, `disable_mcp` |
63
+
64
+ Full guide: [docs/en/sdk.md](https://github.com/DotNetVibeCoderz/Vibe_Dev/blob/main/DotCode/docs/en/sdk.md) · Protocol: [schema/protocol.schema.json](https://github.com/DotNetVibeCoderz/Vibe_Dev/blob/main/DotCode/schema/protocol.schema.json)
65
+
66
+ License: MIT
@@ -1,27 +1,33 @@
1
- [build-system]
2
- requires = ["setuptools>=68", "wheel"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "dotcode-sdk"
7
- version = "0.1.0"
8
- description = "Python SDK for DotCode — embed a multi-LLM coding agent (Anthropic, OpenAI, Azure, Gemini, DeepSeek, Ollama) in your app. By Gravicode Studios, led by Kang Fadhil."
9
- readme = "README.md"
10
- requires-python = ">=3.9"
11
- license = { text = "MIT" }
12
- authors = [{ name = "Gravicode Studios (Kang Fadhil)" }]
13
- keywords = ["ai", "agent", "coding-agent", "llm", "claude", "openai", "gemini", "deepseek", "ollama", "mcp", "dotcode"]
14
- classifiers = [
15
- "Programming Language :: Python :: 3",
16
- "License :: OSI Approved :: MIT License",
17
- "Operating System :: OS Independent",
18
- "Framework :: AsyncIO",
19
- "Topic :: Software Development",
20
- ]
21
-
22
- [project.urls]
23
- Homepage = "https://github.com/DotNetVibeCoderz/Vibe_Dev"
24
- Repository = "https://github.com/DotNetVibeCoderz/Vibe_Dev"
25
-
26
- [tool.setuptools.packages.find]
27
- where = ["src"]
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dotcode-sdk"
7
+ version = "0.2.0"
8
+ description = "Python SDK for DotCode — embed a multi-LLM coding agent (Anthropic, OpenAI, Azure, Gemini, DeepSeek, Ollama) in your app. By Gravicode Studios, led by Kang Fadhil."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Gravicode Studios (Kang Fadhil)" }]
13
+ keywords = ["ai", "agent", "coding-agent", "llm", "claude", "openai", "gemini", "deepseek", "ollama", "mcp", "dotcode"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Framework :: AsyncIO",
19
+ "Topic :: Software Development",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/DotNetVibeCoderz/Vibe_Dev"
24
+ Repository = "https://github.com/DotNetVibeCoderz/Vibe_Dev"
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+
29
+ [tool.setuptools.package-data]
30
+ dotcode_sdk = ["py.typed"]
31
+
32
+ [project.optional-dependencies]
33
+ pydantic = ["pydantic>=2"]
@@ -0,0 +1,68 @@
1
+ """DotCode SDK for Python.
2
+
3
+ Embed the DotCode multi-LLM coding agent (Anthropic, OpenAI, Azure, Gemini, DeepSeek, Ollama, …) in your
4
+ Python application. The SDK talks JSON-RPC to a ``dotcode serve`` child process.
5
+
6
+ Built by Gravicode Studios, led by Kang Fadhil.
7
+
8
+ Example::
9
+
10
+ import asyncio
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"
23
+
24
+ async def main():
25
+ async with DotCodeClient() as client:
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)
31
+
32
+ asyncio.run(main())
33
+ """
34
+
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
44
+ from .types import (
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,
50
+ )
51
+
52
+ __all__ = [
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",
67
+ ]
68
+ __version__ = "0.2.0"