Skip to content

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

Python

sdk: ship graff-core.wasm in @codegraff/sdk; pin the wasm surface to ReleaseSmall

Rach Pradhan398af938932f
diff --git a/build.zig b/build.zig
index 7ecfc028..9e4fe512 100644
--- a/build.zig
+++ b/build.zig
@@ -239,6 +239,9 @@ pub fn build(b: *std.Build) void {
libgraff_step.dependOn(&b.addInstallArtifact(libgraff, .{}).step);
_ = b.option([]const u8, "wasm-surface", "wasm surface: core (use `zig build wasm-core`)");
+ // Pinned ReleaseSmall regardless of the global optimize: the wasm surface
+ // ships in @codegraff/sdk for JS hosts, so size is the axis that matters
+ // (vercel-labs/fx pins it the same way). -Doptimize still overrides.
const wasm = b.addExecutable(.{
.name = "graff-core",
.root_module = b.createModule(.{
@@ -247,7 +250,7 @@ pub fn build(b: *std.Build) void {
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
- .optimize = optimize,
+ .optimize = if (optimize == .Debug) .ReleaseSmall else optimize,
.strip = true,
}),
});
diff --git a/sdk/ts/embed.ts b/sdk/ts/embed.ts
index 954c794d..ed1e28d5 100644
--- a/sdk/ts/embed.ts
+++ b/sdk/ts/embed.ts
@@ -55,6 +55,15 @@ function takeOut(core: GraffCoreExports): string {
return text;
}
+/**
+ * Path to the graff-core.wasm shipped inside this package (npm `files`),
+ * resolved relative to the compiled embed module. JS hosts can pass this as
+ * `wasm` — or bring their own bytes/URL for sandboxed environments.
+ */
+export function bundledWasmPath(): string {
+ return new URL("../graff-core.wasm", import.meta.url).pathname;
+}
+
async function compileWasm(
wasm: CreateGraffAgentOptions["wasm"],
): Promise<WebAssembly.Module> {
diff --git a/sdk/ts/graff-core.wasm b/sdk/ts/graff-core.wasm
new file mode 100755
index 00000000..7e09d82c
Binary files /dev/null and b/sdk/ts/graff-core.wasm differ
diff --git a/sdk/ts/package.json b/sdk/ts/package.json
index bd1d8a01..15c6bf99 100644
--- a/sdk/ts/package.json
+++ b/sdk/ts/package.json
@@ -1,7 +1,7 @@
{
"name": "@codegraff/sdk",
- "version": "0.4.1",
- "description": "TypeScript / Node SDK for the codegraff agent — drives `graff --json` over stdio. Types auto-generated from `graff --schema`.",
+ "version": "0.4.2",
+ "description": "TypeScript / Node SDK for the codegraff agent \u2014 drives `graff --json` over stdio. Types auto-generated from `graff --schema`.",
"type": "module",
"main": "dist/harness.js",
"types": "dist/harness.d.ts",
@@ -31,7 +31,8 @@
"import": "./dist/embed.js",
"default": "./dist/embed.js"
},
- "./package.json": "./package.json"
+ "./package.json": "./package.json",
+ "./core.wasm": "./graff-core.wasm"
},
"repository": {
"type": "git",
@@ -39,17 +40,30 @@
"directory": "sdk/ts"
},
"homepage": "https://codegraff.com",
- "keywords": ["codegraff", "graff", "agent", "llm", "harness", "sdk"],
- "files": ["dist", "README.md"],
- "engines": { "node": ">=18" },
+ "keywords": [
+ "codegraff",
+ "graff",
+ "agent",
+ "llm",
+ "harness",
+ "sdk"
+ ],
+ "files": [
+ "dist",
+ "graff-core.wasm",
+ "README.md"
+ ],
+ "engines": {
+ "node": ">=18"
+ },
"license": "Apache-2.0",
"optionalDependencies": {
- "@codegraff/graff-darwin-arm64": "0.4.0",
- "@codegraff/graff-darwin-x64": "0.4.0",
- "@codegraff/graff-linux-arm64": "0.4.0",
- "@codegraff/graff-linux-x64": "0.4.0",
- "@codegraff/graff-win32-arm64": "0.4.0",
- "@codegraff/graff-win32-x64": "0.4.0"
+ "@codegraff/graff-darwin-arm64": "0.4.1",
+ "@codegraff/graff-darwin-x64": "0.4.1",
+ "@codegraff/graff-linux-arm64": "0.4.1",
+ "@codegraff/graff-linux-x64": "0.4.1",
+ "@codegraff/graff-win32-arm64": "0.4.1",
+ "@codegraff/graff-win32-x64": "0.4.1"
},
"scripts": {
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",