Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3502202
feat: implement Python SDK v5
varin-nair-factory Aug 12, 2026
a5d7ff9
refactor: make in-process MCP server deps an optional extra
varin-nair-factory Aug 12, 2026
d7829de
refactor: remove low-level client dependency on the high-level layer
varin-nair-factory Aug 12, 2026
ff343c5
refactor: consolidate wire/public converters into one module
varin-nair-factory Aug 12, 2026
77fc086
refactor: share lifecycle cancellation idioms and drop the module tes…
varin-nair-factory Aug 12, 2026
b13d365
refactor: construct replacement successors explicitly
varin-nair-factory Aug 12, 2026
bd15e8e
refactor: split request/response operations out of session.py
varin-nair-factory Aug 12, 2026
5dadc39
refactor: narrow the pyright suppression in client.py
varin-nair-factory Aug 12, 2026
beb21f0
refactor: hold SDK MCP server runtime state in a weak-keyed registry
varin-nair-factory Aug 12, 2026
fc3905c
refactor: deduplicate the aware-datetime check and terminal-result seal
varin-nair-factory Aug 12, 2026
2d65639
docs: tighten the Python SDK reference
varin-nair-factory Aug 12, 2026
12cb8a1
docs: streamline the SDK reference intro and core contract
varin-nair-factory Aug 12, 2026
78e33a8
docs: tighten the models and sessions reference sections
varin-nair-factory Aug 12, 2026
2a3d349
docs: clarify session handlers, resume, and source schemas
varin-nair-factory Aug 12, 2026
6ba05f2
docs: clarify the streaming and results reference section
varin-nair-factory Aug 12, 2026
f43eabb
docs: clarify the inputs and outputs reference section
varin-nair-factory Aug 12, 2026
5fe0732
docs: clarify the permissions and user input reference section
varin-nair-factory Aug 12, 2026
6938009
docs: clarify the tools and extensions reference section
varin-nair-factory Aug 12, 2026
9611d7c
examples: drop the offline dry-run flag from runnable examples
varin-nair-factory Aug 12, 2026
dfe6aab
examples: add a live tour of every stream event type
varin-nair-factory Aug 12, 2026
79ca034
docs: clarify the session lifecycle and modes reference sections
varin-nair-factory Aug 12, 2026
cd2a80d
docs: clarify the operations section and drop Mission mentions
varin-nair-factory Aug 12, 2026
ee8d389
docs: remove the low-level API from the public documentation
varin-nair-factory Aug 13, 2026
fc9af1e
docs: remove custom transport from the public surface
varin-nair-factory Aug 13, 2026
f841053
docs: tighten the API index and limitations sections
varin-nair-factory Aug 13, 2026
7870f04
examples: raise live-turn timeouts to 180 seconds
varin-nair-factory Aug 13, 2026
f7139bd
fix: accept any iterable for tool overrides and forward the mime hint
varin-nair-factory Aug 13, 2026
15a4824
fix: make success guarantee structured output when requested
varin-nair-factory Aug 13, 2026
e92b6c4
fix: only enforce the output guarantee when output was requested
varin-nair-factory Aug 13, 2026
5187fdf
docs: state where the default model lives and how bad IDs fail
varin-nair-factory Aug 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
426 changes: 113 additions & 313 deletions README.md

Large diffs are not rendered by default.

1,768 changes: 1,768 additions & 0 deletions docs/python-sdk-reference.md

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions examples/attachments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Send local image and document attachments in one turn."""

from __future__ import annotations

import asyncio
import base64
import tempfile
from pathlib import Path

from droid_sdk import Document, Image, run


def minimal_pdf() -> bytes:
content = b"BT /F1 12 Tf 72 720 Td (Offline PDF example.) Tj ET"
objects = (
b"<< /Type /Catalog /Pages 2 0 R >>",
b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
(
b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] "
b"/Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>"
),
b"<< /Length "
+ str(len(content)).encode()
+ b" >>\nstream\n"
+ content
+ b"\nendstream",
b"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
)
data = bytearray(b"%PDF-1.4\n%\xe2\xe3\xcf\xd3\n")
offsets = [0]
for number, value in enumerate(objects, start=1):
offsets.append(len(data))
data.extend(f"{number} 0 obj\n".encode())
data.extend(value)
data.extend(b"\nendobj\n")
xref = len(data)
data.extend(f"xref\n0 {len(objects) + 1}\n".encode())
data.extend(b"0000000000 65535 f \n")
for offset in offsets[1:]:
data.extend(f"{offset:010} 00000 n \n".encode())
data.extend(
(
f"trailer\n<< /Size {len(objects) + 1} /Root 1 0 R >>\n"
f"startxref\n{xref}\n%%EOF\n"
).encode()
)
return bytes(data)


async def main() -> None:
png = base64.b64decode(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAQ0lEQVR4AcXB"
"AQEAAAiDMKR/5xuD7QYjJDGJSUxiEpOYxCQmMYlJTGISk5jEJCYxiUlMYhKT"
"mMQkJjGJSUxiEpOYxB4w4wI+9B/igQAAAABJRU5ErkJggg=="
)
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
text_path = root / "notes.txt"
pdf_path = root / "report.pdf"
image_path = root / "pixel.png"
text_path.write_text("Offline attachment example.\n", encoding="utf-8")
pdf_path.write_bytes(minimal_pdf())
image_path.write_bytes(png)

result = await run(
"Describe the attached red square and summarize both files.",
images=[Image.from_path(image_path)],
files=[Document.from_path(text_path), Document.from_path(pdf_path)],
timeout=180,
)
print(result.text)


if __name__ == "__main__":
asyncio.run(main())
62 changes: 62 additions & 0 deletions examples/interaction_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Exercise interaction response helpers without starting Droid."""

from droid_sdk import (
PermissionOption,
PermissionRequest,
Question,
QuestionRequest,
ToolConfirmationOutcome,
)


def main() -> None:
permission = PermissionRequest(
actions=(),
options=(
PermissionOption(
label="Proceed once",
value=ToolConfirmationOutcome.PROCEED_ONCE,
),
PermissionOption(
label="Cancel",
value=ToolConfirmationOutcome.CANCEL,
),
),
)
response = permission.respond(
ToolConfirmationOutcome.PROCEED_ONCE,
comment="Approved by the offline example.",
)

single = Question(
index=1,
topic="Language",
question="Which language?",
options=("Python", "TypeScript"),
)
multiple = Question(
index=2,
topic="Checks",
question="Which checks?",
options=("tests", "lint", "types"),
multi_select=True,
)
questionnaire = QuestionRequest(
tool_call_id="offline-tool-call",
questions=(single, multiple),
)
answers = questionnaire.submit(
(
single.answer("Python"),
multiple.answer_multiple(("tests", "types")),
)
)
cancelled = questionnaire.cancel()

print(response)
print(answers)
print(cancelled)


if __name__ == "__main__":
main()
46 changes: 46 additions & 0 deletions examples/interactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Permission and question handlers with safe cancellation defaults."""

from __future__ import annotations

import asyncio

from droid_sdk import (
InteractionHandlers,
PermissionRequest,
PermissionResponse,
QuestionRequest,
QuestionResponse,
Session,
ToolConfirmationOutcome,
)


def permission(request: PermissionRequest) -> PermissionResponse:
return request.respond(ToolConfirmationOutcome.CANCEL)


async def question(request: QuestionRequest) -> QuestionResponse:
answers = [
item.answer(item.options[0] if item.options else "none")
for item in request.questions
]
return request.submit(answers)


async def main() -> None:
handlers = InteractionHandlers(
on_permission=permission,
on_question=question,
)
async with Session(interactions=handlers) as session:
async with session.stream(
"Ask one multiple-choice question, then stop.",
timeout=60,
) as stream:
async for _ in stream:
pass
print(stream.result.subtype)


if __name__ == "__main__":
asyncio.run(main())
Loading