Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

sdk: v0.3.1 — package READMEs (npm + PyPI) + Moonshot/kimi-latest

Rach Pradhan6b8e78c9f464
diff --git a/sdk/README.md b/sdk/README.md
index e60413b2..846ff533 100644
--- a/sdk/README.md
+++ b/sdk/README.md
@@ -17,9 +17,9 @@ python3 sdk/generate.py --harness ./zig-out/bin/graff
graff --schema | python3 sdk/generate.py
```
-On every release tag the `sdk` GitHub Action rebuilds, regenerates, fails if the
-committed SDKs are stale, and publishes to npm/PyPI when the registry token
-secrets are present (`NPM_TOKEN`, `PYPI_TOKEN`).
+On every `sdk-v*` tag the `sdk` GitHub Action rebuilds, regenerates, fails if the
+committed SDKs are stale, and publishes to npm/PyPI via OIDC trusted publishing
+(no registry tokens required).
## Usage
@@ -43,7 +43,7 @@ TypeScript — the API mirrors [`@codegraff/sdk`](https://www.npmjs.com/package/
(`runAgent` one-shot, `Harness.init` long-lived, `.session()`, `.chat()`/`.ask()`):
```ts
-import { Harness, runAgent } from "@graff-new/sdk"; // or "./harness.ts"
+import { Harness, runAgent } from "@codegraff/sdk"; // or "./harness.ts"
// one-shot, streamed (parallel to codegraff's runAgent)
for await (const ev of runAgent({ prompt: "summarize README.md", model: "gpt-5.5", yolo: true })) {
@@ -76,7 +76,7 @@ instead. Same method surface, same event stream:
```ts
// fetch + Web Streams only — works on Cloudflare Workers, Deno, Bun,
// browsers, and Node >= 18
-import { RemoteHarness, runAgentRemote } from "@graff-new/sdk/remote";
+import { RemoteHarness, runAgentRemote } from "@codegraff/sdk/remote";
for await (const ev of runAgentRemote({ url: "https://my-bridge.example", token, yolo: true, prompt: "summarize README.md" })) {
if (ev.type === "text") console.log(ev.text);
diff --git a/sdk/py/README.md b/sdk/py/README.md
new file mode 100644
index 00000000..5f173dd9
--- /dev/null
+++ b/sdk/py/README.md
@@ -0,0 +1,84 @@
+# codegraff
+
+Python client for the [codegraff](https://github.com/justrach/codegraff) agent.
+It drives the `graff` binary over its `--json` stdio protocol, with constants
+auto-generated from `graff --schema`.
+
+## Install
+
+```sh
+pip install codegraff
+```
+
+> **Note the package / module name mismatch:** the PyPI package is `codegraff`,
+> but the importable module is `harness_sdk`:
+>
+> ```python
+> from harness_sdk import Harness
+> ```
+
+### Prerequisite: the `graff` binary
+
+The SDK spawns the `graff` binary as a subprocess, so it must be installed:
+
+```sh
+curl -fsSL https://github.com/justrach/codegraff/releases/latest/download/install.sh | sh
+```
+
+If `graff` isn't on your `PATH`, point at it explicitly with the `binary`
+argument (`Harness(binary="./zig-out/bin/graff")`).
+
+## Quick start
+
+```python
+from harness_sdk import Harness
+
+with Harness(yolo=True, model="gpt-5.5") as h:
+ # one-shot: ask() returns just the final text
+ print(h.ask("what is 2+2?"))
+
+ # streamed: chat() iterates event dicts
+ for ev in h.chat("read foo.txt"):
+ print(ev["type"], ev)
+
+# replace or extend the system prompt
+with Harness(yolo=True, system_prompt="You are a code-review bot. Only report bugs.") as bot:
+ print(bot.ask("review main.py"))
+```
+
+`Harness` accepts `yolo`, `model`, `cwd`, `system_prompt`, `binary`, and more.
+`model` may be a model name **or** a provider id (e.g. `"codex"`, `"moonshot"`).
+Also exported: `MODELS` and `PROVIDERS`.
+
+## Events
+
+`chat()` yields event dicts, each with a `type`:
+
+- `text` — assistant text delta
+- `tool_call` — the agent invoked a tool (`name`, `input`)
+- `tool_result` — a tool returned
+- `ask_user` — the agent needs input; answer it with the `call_id`
+- `turn` — turn finished; carries the final text, `context_tokens`, and `cost_usd`
+- `error` — something went wrong
+
+## Remote (no local binary)
+
+Edge / serverless runtimes can't spawn a subprocess. Run `graff serve` somewhere
+and drive it over HTTP (stdlib `urllib` only):
+
+```python
+from harness_sdk import RemoteHarness
+
+with RemoteHarness("http://127.0.0.1:8787", token="...", yolo=True) as h:
+ print(h.ask("what is 2+2?"))
+```
+
+## Links
+
+- Repository: <https://github.com/justrach/codegraff>
+- This package (PyPI): <https://pypi.org/project/codegraff/>
+- TypeScript sibling (npm): <https://www.npmjs.com/package/@codegraff/sdk>
+
+## License
+
+BSD-3-Clause
diff --git a/sdk/py/harness_sdk.py b/sdk/py/harness_sdk.py
index f23293fe..711de14d 100644
--- a/sdk/py/harness_sdk.py
+++ b/sdk/py/harness_sdk.py
@@ -13,9 +13,9 @@ import urllib.error
import urllib.request
from typing import Iterator, Optional
-MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.4", "gpt-5.4-pro", "gpt-5.5", "grok-4.3", "grok-build", "kimi-k2.6", "kimi-k2.7", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3"]
+MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.4", "gpt-5.4-pro", "gpt-5.5", "grok-4.3", "grok-build", "kimi-k2.6", "kimi-k2.7", "kimi-latest", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3"]
TOOLS = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "codedb", "todo_write", "todo_read", "ask_user", "attempt_completion", "subagent", "workflow"]
-PROVIDERS = ["anthropic", "codegraff", "deepseek", "openai", "minimax", "xiaomi", "kimi", "xai", "zai", "codex"]
+PROVIDERS = ["anthropic", "codegraff", "deepseek", "openai", "minimax", "xiaomi", "kimi", "moonshot", "xai", "zai", "codex"]
def _sdk_install_id() -> str:
diff --git a/sdk/py/pyproject.toml b/sdk/py/pyproject.toml
index a6b469be..6996bcdf 100644
--- a/sdk/py/pyproject.toml
+++ b/sdk/py/pyproject.toml
@@ -4,7 +4,8 @@ build-backend = "setuptools.build_meta"
[project]
name = "codegraff"
-version = "0.3.0"
+version = "0.3.1"
+readme = "README.md"
description = "Python client for the codegraff agent — drives `graff --json` over stdio. Constants auto-generated from `graff --schema`."
requires-python = ">=3.8"
license = { text = "BSD-3-Clause" }
diff --git a/sdk/ts/README.md b/sdk/ts/README.md
new file mode 100644
index 00000000..e1bc62cb
--- /dev/null
+++ b/sdk/ts/README.md
@@ -0,0 +1,87 @@
+# @codegraff/sdk
+
+TypeScript / Node SDK for the [codegraff](https://github.com/justrach/codegraff)
+agent. It drives the `graff` binary over its `--json` stdio protocol, and the
+types are auto-generated from `graff --schema`.
+
+## Install
+
+```sh
+npm install @codegraff/sdk
+```
+
+### Prerequisite: the `graff` binary
+
+The SDK spawns the `graff` binary as a subprocess, so it must be installed:
+
+```sh
+curl -fsSL https://github.com/justrach/codegraff/releases/latest/download/install.sh | sh
+```
+
+If `graff` isn't on your `PATH`, point at it explicitly with the `binary` option
+(`Harness.init({ binary: "./zig-out/bin/graff" })`).
+
+## Quick start
+
+```ts
+import { Harness, runAgent } from "@codegraff/sdk";
+
+// one-shot, streamed
+for await (const ev of runAgent({ prompt: "summarize README.md", model: "gpt-5.5", yolo: true })) {
+ if (ev.type === "text") process.stdout.write(ev.text);
+ if (ev.type === "tool_call") console.log("→", ev.name, ev.input);
+ if (ev.type === "turn") console.log("\ncost $", ev.cost_usd);
+}
+
+// long-lived, multi-turn session
+const harness = Harness.init({ model: "claude-opus-4-8", yolo: true });
+const session = harness.session();
+console.log(await session.ask("what files are here?")); // returns final text
+for await (const ev of session.send("ask me a follow-up before continuing")) {
+ if (ev.type === "ask_user") session.answer({ text: "continue", callId: ev.call_id });
+}
+session.close();
+```
+
+`Harness.init` accepts `{ model, yolo, cwd, env, binary, system_prompt, args }`.
+`model` may be a model name **or** a provider id (e.g. `"codex"`, `"moonshot"`).
+Also exported: `MODELS` and `PROVIDERS`.
+
+## Events
+
+Both `runAgent` and `session.send` yield an `AsyncGenerator<Event>`:
+
+- `text` — assistant text delta
+- `tool_call` — the agent invoked a tool (`name`, `input`)
+- `tool_result` — a tool returned
+- `ask_user` — the agent needs input; answer it with `session.answer({ text, callId })`
+- `turn` — turn finished; carries the final `text`, `context_tokens`, and `cost_usd`
+- `error` — something went wrong
+
+## Remote (edge runtimes)
+
+Edge runtimes can't spawn a subprocess. Run `graff serve` somewhere and drive it
+over HTTP with fetch + Web Streams (works on Cloudflare Workers, Deno, Bun,
+browsers, Node >= 18):
+
+```ts
+import { RemoteHarness, runAgentRemote } from "@codegraff/sdk/remote";
+
+for await (const ev of runAgentRemote({ url: "https://my-bridge.example", token, prompt: "summarize README.md" })) {
+ if (ev.type === "text") console.log(ev.text);
+}
+
+const h = RemoteHarness.init({ url: "http://127.0.0.1:8787", token, yolo: true });
+console.log(await h.ask("what files are here?"));
+await h.close();
+```
+
+## Links
+
+- Repository: <https://github.com/justrach/codegraff>
+- This package (npm): <https://www.npmjs.com/package/@codegraff/sdk>
+- Python sibling (PyPI): <https://pypi.org/project/codegraff/>
+
+## License
+
+BSD-3-Clause
diff --git a/sdk/ts/harness.ts b/sdk/ts/harness.ts
index 93144d64..77e9f55e 100644
--- a/sdk/ts/harness.ts
+++ b/sdk/ts/harness.ts
@@ -10,9 +10,9 @@ import { createInterface } from "node:readline";
export const HARNESS_VERSION = "0.4";
-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.4" | "gpt-5.4-pro" | "gpt-5.5" | "grok-4.3" | "grok-build" | "kimi-k2.6" | "kimi-k2.7" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3";
+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.4" | "gpt-5.4-pro" | "gpt-5.5" | "grok-4.3" | "grok-build" | "kimi-k2.6" | "kimi-k2.7" | "kimi-latest" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3";
export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "codedb" | "todo_write" | "todo_read" | "ask_user" | "attempt_completion" | "subagent" | "workflow";
-export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kimi" | "xai" | "zai" | "codex";
+export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kimi" | "moonshot" | "xai" | "zai" | "codex";
/** Events streamed by `harness --json` (one JSON object per stdout line), each
* discriminated by `type` — the analogue of codegraff's AgentEvent stream.
@@ -387,5 +387,5 @@ export async function* runAgent(opts: RunAgentOptions): AsyncGenerator<Event> {
}
}
-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.4", "gpt-5.4-pro", "gpt-5.5", "grok-4.3", "grok-build", "kimi-k2.6", "kimi-k2.7", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3"];
+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.4", "gpt-5.4-pro", "gpt-5.5", "grok-4.3", "grok-build", "kimi-k2.6", "kimi-k2.7", "kimi-latest", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3"];
export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "codedb", "todo_write", "todo_read", "ask_user", "attempt_completion", "subagent", "workflow"];
diff --git a/sdk/ts/package.json b/sdk/ts/package.json
index 8f8bc6d1..ba3112b2 100644
--- a/sdk/ts/package.json
+++ b/sdk/ts/package.json
@@ -1,6 +1,6 @@
{
"name": "@codegraff/sdk",
- "version": "0.3.0",
+ "version": "0.3.1",
"description": "TypeScript / Node SDK for the codegraff agent — drives `graff --json` over stdio. Types auto-generated from `graff --schema`.",
"type": "module",
"main": "harness.ts",
@@ -25,7 +25,7 @@
},
"homepage": "https://codegraff.com",
"keywords": ["codegraff", "graff", "agent", "llm", "harness", "sdk"],
- "files": ["harness.ts", "remote.ts"],
+ "files": ["harness.ts", "remote.ts", "README.md"],
"engines": { "node": ">=18" },
"license": "BSD-3-Clause"
}
diff --git a/sdk/ts/remote.ts b/sdk/ts/remote.ts
index 60f71c20..bca0cd6c 100644
--- a/sdk/ts/remote.ts
+++ b/sdk/ts/remote.ts
@@ -9,9 +9,9 @@
export const HARNESS_VERSION = "0.4";
-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.4" | "gpt-5.4-pro" | "gpt-5.5" | "grok-4.3" | "grok-build" | "kimi-k2.6" | "kimi-k2.7" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3";
+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.4" | "gpt-5.4-pro" | "gpt-5.5" | "grok-4.3" | "grok-build" | "kimi-k2.6" | "kimi-k2.7" | "kimi-latest" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3";
export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "codedb" | "todo_write" | "todo_read" | "ask_user" | "attempt_completion" | "subagent" | "workflow";
-export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kimi" | "xai" | "zai" | "codex";
+export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kimi" | "moonshot" | "xai" | "zai" | "codex";
/** Events streamed by the bridge (same `--json` contract as the stdio SDK).
* Forward compatibility: a newer (edge) harness may stream event types not
@@ -226,5 +226,5 @@ export async function* runAgentRemote(opts: RunAgentRemoteOptions): AsyncGenerat
}
}
-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.4", "gpt-5.4-pro", "gpt-5.5", "grok-4.3", "grok-build", "kimi-k2.6", "kimi-k2.7", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3"];
+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.4", "gpt-5.4-pro", "gpt-5.5", "grok-4.3", "grok-build", "kimi-k2.6", "kimi-k2.7", "kimi-latest", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3"];
export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "codedb", "todo_write", "todo_read", "ask_user", "attempt_completion", "subagent", "workflow"];