@cloudflare/codemode 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/runtime.md CHANGED
@@ -24,6 +24,8 @@ const runtime = createCodemodeRuntime({
24
24
  | Handle method | Purpose |
25
25
  | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
26
26
  | `runtime.tool(options?)` | The single model-facing AI SDK tool, `codemode({ code })` |
27
+ | `runtime.execute({ code })` | Run code directly from a non-AI-SDK host, such as an MCP tool handler |
28
+ | `runtime.search(query)` / `runtime.describe(target)` | Search connector methods and snippets, then fetch one target's on-demand TypeScript documentation |
27
29
  | `runtime.pending(executionId?)` | Actions awaiting approval — drives approval UIs; no id aggregates all paused runs |
28
30
  | `runtime.approve({ executionId })` | Approve the pending action and continue via replay |
29
31
  | `runtime.reject({ seq, executionId })` | Reject a pending action; ends the execution. Returns `false` if it was a no-op (action no longer pending — approved or rejected elsewhere) |
@@ -34,6 +36,20 @@ const runtime = createCodemodeRuntime({
34
36
  | `runtime.saveSnippet(name, opts?)` | Promote an execution's script to a reusable [snippet](./snippets.md) |
35
37
  | `runtime.snippets()` / `runtime.deleteSnippet(name)` | List / remove saved snippets |
36
38
 
39
+ `execute()`, `search()`, and `describe()` expose the same runtime to hosts that are not using the AI SDK. For example, an MCP server can register separate `search` and `execute` tools without reaching through `runtime.tool().execute` or duplicating connector discovery:
40
+
41
+ ```ts
42
+ server.registerTool("search", searchOptions, async ({ query }) =>
43
+ toMcpResult(await runtime.search(query))
44
+ );
45
+
46
+ server.registerTool("execute", executeOptions, async ({ code }) =>
47
+ toMcpResult(await runtime.execute({ code }))
48
+ );
49
+ ```
50
+
51
+ Search and describe results mark methods with `requiresApproval: true` when their connector annotation requires it.
52
+
37
53
  ## The sandbox API (`codemode.*`)
38
54
 
39
55
  The runtime also provides the model's API. Inside the sandbox, `codemode` is a global with four methods — discover, learn, do-once, reuse:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/codemode",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Code Mode: use LLMs to generate executable code that performs tool calls",
5
5
  "repository": {
6
6
  "directory": "packages/codemode",
@@ -18,14 +18,14 @@
18
18
  "@modelcontextprotocol/sdk": "1.29.0",
19
19
  "@playwright/test": "^1.61.1",
20
20
  "@tanstack/ai": "0.38.0",
21
- "ai": "^6.0.202",
21
+ "ai": "^7.0.0",
22
22
  "vitest": "4.1.9",
23
23
  "zod": "^4.4.3"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.25.0",
27
27
  "@tanstack/ai": ">=0.8.0 <1.0.0",
28
- "ai": "^6.0.0",
28
+ "ai": "^6.0.0 || ^7.0.0",
29
29
  "zod": "^4.0.0"
30
30
  },
31
31
  "peerDependenciesMeta": {