SDK Quickstart
DotCraft ships SDKs for TypeScript, .NET, and Python.
Install
bash
npm install @dotcraft/sdkbash
dotnet add package DotCraft.Sdkbash
pip install dotcraft1. Connect
local discovers or starts the local Hub and ensures an AppServer for your workspace. Use remote to connect to a known AppServer WebSocket instead.
ts
import { DotCraft } from "@dotcraft/sdk";
const dotcraft = await DotCraft.local({ workspacePath: "/path/to/workspace" });csharp
using DotCraft.Sdk.AppServer;
await using var client = await DotCraftClient.ConnectLocalAsync(
"/path/to/workspace",
new DotCraftLocalClientOptions { ClientName = "my-app", ClientVersion = "0.1.0" });python
from dotcraft import DotCraft, LocalOptions
dotcraft = await DotCraft.connect_local(LocalOptions(workspace_path="/path/to/workspace"))2. Start a thread
A thread is a persistent conversation. Start a fresh one, or reuse an existing one for an identity with getOrCreate / get_or_create.
ts
const thread = await dotcraft.threads.start({ userId: "me" });csharp
var thread = await client.Threads.StartAsync(
new DotCraftThreadStartRequest(new SessionIdentity("my-app", Environment.UserName)));python
thread = await dotcraft.threads.start(user_id="me")3. Run a turn
run submits input and waits for the turn to finish, returning the merged assistant reply.
ts
const result = await thread.run("Summarize this project.");
console.log(result.text);csharp
var result = await thread.RunAsync("Summarize this project.");
Console.WriteLine(result.Text);python
result = await thread.run("Summarize this project.")
print(result.text)4. Stream events
runStreamed yields normalized events as they arrive — text deltas, item lifecycle, and the terminal turn.
ts
for await (const event of thread.runStreamed("And list the open questions.")) {
if (event.type === "agent_message_delta") {
process.stdout.write(event.delta ?? "");
}
}csharp
await foreach (var runEvent in thread.RunStreamedAsync("And list the open questions."))
{
if (runEvent.Type == DotCraftRunEventTypes.AgentMessageDelta)
{
Console.Write(runEvent.Params.GetProperty("delta").GetString());
}
}python
async for event in thread.run_streamed("And list the open questions."):
if event.type == "agent_message_delta":
print(event.params["delta"], end="", flush=True)Next steps
- Threads & runs — thread lifecycle, run options, and the normalized event model.
- Tools & approvals — runtime dynamic tools and approval / user-input callbacks.
- Channel adapters — build external channels (TypeScript and Python).
- Reference cards: TypeScript · .NET · Python.