History

Add executor generate: typed TypeScript client for the tool catalog

Running executor generate against an instance writes one self-contained TypeScript file: a dependency-free Proxy-based runtime client plus full input/output types for every visible tool, so client.github.org.main.issues.create({ title }) is typed end to end and executes through the server's /api/executions endpoint (auth, policies, approvals included). New pieces: - tools.export SDK surface + GET /tools/export: the bulk schema-bearing catalog read (schemas + trimmed shared $defs, grouped per connection, policy-filtered), one request regardless of catalog size. - compileToolChunkTypeScript: compiles many tools per compiler pass. Per-tool passes pay fixed overhead thousands of times and one whole-catalog pass is super-linear (30s+ at 10k tools); 200-tool chunks generate a 10k-tool catalog in ~400ms. - generateToolProxySource: assembles the generated file (type-only namespaces per connection, ExecutorTools path tree, embedded runtime). - executor generate CLI command with --output/--integration/--connection/ --include-static, reusing the server-target and auth machinery. Tested down to the wire: generated source is typechecked with the real compiler (valid calls accept, invalid reject), the transpiled runtime is imported and run against a fake fetch (completed/paused/injection paths), and a scale test ingests a 10,000-operation OpenAPI spec through addSpec and proves export + generate + strict typecheck hold up with regression tripwires on time.

Rhys Sullivan committed 4 months ago

Commit dabe51f1 parent e39dbcf14 files · +1733 −5Browse files

Showing the changes to apps/docs (1 of 14 files). Show all

Unified · Split

apps/docs/local/cli.mdx+25−0
@@ -109,3 +109,28 @@ resume it: · 108 unmodified lines
109```bash109```bash
110executor resume --execution-id exec_123110executor resume --execution-id exec_123
111```111```
112
113## Generate a typed client
114
115`executor generate` writes a single self-contained TypeScript file with full
116input/output types for every tool in your catalog, plus a dependency-free
117runtime client. Drop it into any TypeScript project and every call is typed
118end to end, while still executing through Executor (auth, policies, and
119approvals included):
120
121```bash
122executor generate # writes executor.gen.ts
123executor generate -o src/executor.ts # custom output path
124executor generate --integration github # only one integration
125```
126
127```ts
128import { createExecutorClient } from "./executor.gen";
129
130const executor = createExecutorClient(); // EXECUTOR_API_KEY / EXECUTOR_AUTH_TOKEN
131const created = await executor.github.org.main.issues.create({ title: "Hi" });
132if (created.ok) console.log(created.data.number);
133```
134
135Calls that pause for approval throw `ExecutorPausedError` with the approval
136URL. Re-run `executor generate` whenever your catalog changes.