@cloudflare/codemode 0.3.7 → 0.4.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/LICENSE +21 -0
- package/README.md +251 -7
- package/dist/ai.d.ts +50 -7
- package/dist/ai.js +93 -5
- package/dist/ai.js.map +1 -1
- package/dist/base-B2amchZA.d.ts +239 -0
- package/dist/base-CHRR_a5j.js +156 -0
- package/dist/base-CHRR_a5j.js.map +1 -0
- package/dist/browser.d.ts +6 -6
- package/dist/browser.js +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/{executor-BRm90XJT.d.ts → executor-BIs2dr7X.d.ts} +48 -10
- package/dist/index.d.ts +608 -8
- package/dist/index.js +1690 -17
- package/dist/index.js.map +1 -1
- package/dist/{json-schema-types-CVt4X9cw.js → json-schema-types-BGjW4KPy.js} +1 -1
- package/dist/{json-schema-types-CVt4X9cw.js.map → json-schema-types-BGjW4KPy.js.map} +1 -1
- package/dist/{json-schema-types-1OL3uao0.d.ts → json-schema-types-Cb2wClAd.d.ts} +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +4 -3
- package/dist/mcp.js.map +1 -1
- package/dist/{resolve-DdyeEp3l.js → resolve-34dC47Il.js} +1 -1
- package/dist/{resolve-DdyeEp3l.js.map → resolve-34dC47Il.js.map} +1 -1
- package/dist/{resolve-DtfaKmms.d.ts → resolve-CBr_VoPl.d.ts} +4 -4
- package/dist/{run-code-5x8S5YWt.js → run-code-aKHcTgf9.js} +4 -4
- package/dist/run-code-aKHcTgf9.js.map +1 -0
- package/dist/{shared-TyFN6W7_.d.ts → shared-Ce-zCEBP.d.ts} +3 -3
- package/dist/{shared-xjl2irqK.js → shared-SMjV5yN4.js} +1 -1
- package/dist/{shared-xjl2irqK.js.map → shared-SMjV5yN4.js.map} +1 -1
- package/dist/tanstack-ai.d.ts +3 -3
- package/dist/tanstack-ai.js +4 -4
- package/dist/tanstack-ai.js.map +1 -1
- package/dist/vite.d.ts +7 -0
- package/dist/vite.js +122 -0
- package/dist/vite.js.map +1 -0
- package/package.json +19 -14
- package/dist/run-code-5x8S5YWt.js.map +0 -1
package/dist/vite.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { dirname, relative, resolve } from "node:path";
|
|
2
|
+
import { readdirSync, statSync } from "node:fs";
|
|
3
|
+
//#region src/vite.ts
|
|
4
|
+
/**
|
|
5
|
+
* Codemode Vite plugin — handles `type: "connectors"` import attributes.
|
|
6
|
+
*
|
|
7
|
+
* Usage in vite.config.ts:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import codemode from "@cloudflare/codemode/vite";
|
|
10
|
+
* export default { plugins: [codemode()] };
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Then import a directory of *.codemode.ts files:
|
|
14
|
+
* ```ts
|
|
15
|
+
* import connectors from "./connectors" with { type: "connectors" };
|
|
16
|
+
* // pass connectors to createCodemodeRuntime({ ctx, executor, connectors })
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Or import a single connector file:
|
|
20
|
+
* ```ts
|
|
21
|
+
* import connectors from "./github.codemode" with { type: "connectors" };
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* The plugin:
|
|
25
|
+
* 1. Discovers *.codemode.{ts,js} files in the referenced directory
|
|
26
|
+
* 2. Generates a module that re-exports each connector class
|
|
27
|
+
* 3. Auto-exports connector classes from the worker entry for ctx.exports access
|
|
28
|
+
*/
|
|
29
|
+
const CODEMODE_PATTERN = /\.codemode\.[tj]sx?$/;
|
|
30
|
+
const VIRTUAL_PREFIX = "\0codemode-connectors:";
|
|
31
|
+
const PUBLIC_PREFIX = "__codemode_connectors__:";
|
|
32
|
+
function codemodeVitePlugin() {
|
|
33
|
+
let projectRoot;
|
|
34
|
+
function transformCode(code, id) {
|
|
35
|
+
let result = code;
|
|
36
|
+
let changed = false;
|
|
37
|
+
if (code.includes("type: \"connectors\"") || code.includes("type: 'connectors'")) {
|
|
38
|
+
const next = code.replace(/from\s+(["'])([^"']+)\1\s+with\s+\{\s*type\s*:\s*(["'])connectors\3\s*\}/g, (_match, quote, source) => {
|
|
39
|
+
const resolved = resolve(dirname(id), source);
|
|
40
|
+
return `from ${quote}${PUBLIC_PREFIX}${encodeURIComponent(resolved)}${quote}`;
|
|
41
|
+
});
|
|
42
|
+
if (next !== code) {
|
|
43
|
+
result = next;
|
|
44
|
+
changed = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (isWorkerEntry(id, projectRoot)) {
|
|
48
|
+
const files = findCodemodeFiles(resolve(projectRoot, "src"));
|
|
49
|
+
const lines = [];
|
|
50
|
+
lines.push("export { CodemodeRuntime } from \"@cloudflare/codemode\";");
|
|
51
|
+
for (const file of files) lines.push(`export * from ${JSON.stringify(file)};`);
|
|
52
|
+
result = `${result}\n\n// Auto-exported by @cloudflare/codemode/vite\n${lines.join("\n")}\n`;
|
|
53
|
+
changed = true;
|
|
54
|
+
}
|
|
55
|
+
return changed ? {
|
|
56
|
+
code: result,
|
|
57
|
+
map: null
|
|
58
|
+
} : null;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
name: "@cloudflare/codemode/vite",
|
|
62
|
+
enforce: "pre",
|
|
63
|
+
configResolved(config) {
|
|
64
|
+
projectRoot = config.root;
|
|
65
|
+
},
|
|
66
|
+
transform(code, id) {
|
|
67
|
+
return transformCode(code, id);
|
|
68
|
+
},
|
|
69
|
+
resolveId(source, importer, options) {
|
|
70
|
+
if (source.startsWith(PUBLIC_PREFIX)) return `${VIRTUAL_PREFIX}${decodeURIComponent(source.slice(24))}`;
|
|
71
|
+
if (options.attributes?.type !== "connectors") return null;
|
|
72
|
+
if (!importer) return null;
|
|
73
|
+
return `${VIRTUAL_PREFIX}${resolve(dirname(importer), source)}`;
|
|
74
|
+
},
|
|
75
|
+
load(id) {
|
|
76
|
+
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
77
|
+
const target = id.slice(21);
|
|
78
|
+
const files = findCodemodeFiles(target);
|
|
79
|
+
if (files.length === 0) return "export default [];\n";
|
|
80
|
+
for (const file of files) this.addWatchFile(file);
|
|
81
|
+
if (statSync(target, { throwIfNoEntry: false })?.isDirectory()) this.addWatchFile(target);
|
|
82
|
+
const lines = [];
|
|
83
|
+
for (const file of files) lines.push(`export * from ${JSON.stringify(file)};`);
|
|
84
|
+
return lines.join("\n") + "\n";
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function isWorkerEntry(id, root) {
|
|
89
|
+
const rel = relative(root, id).replace(/\\/g, "/");
|
|
90
|
+
return /^src\/(server|index|worker)\.[tj]sx?$/.test(rel);
|
|
91
|
+
}
|
|
92
|
+
function findCodemodeFiles(target) {
|
|
93
|
+
let stat = statSync(target, { throwIfNoEntry: false });
|
|
94
|
+
if (!stat) {
|
|
95
|
+
for (const ext of [
|
|
96
|
+
".ts",
|
|
97
|
+
".tsx",
|
|
98
|
+
".js",
|
|
99
|
+
".jsx"
|
|
100
|
+
]) {
|
|
101
|
+
const withExt = target + ext;
|
|
102
|
+
if (statSync(withExt, { throwIfNoEntry: false })?.isFile()) return [withExt];
|
|
103
|
+
}
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
if (stat.isFile() && CODEMODE_PATTERN.test(target)) return [target];
|
|
107
|
+
if (!stat.isDirectory()) return [];
|
|
108
|
+
const results = [];
|
|
109
|
+
function walk(dir) {
|
|
110
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
111
|
+
const full = resolve(dir, entry.name);
|
|
112
|
+
if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist") walk(full);
|
|
113
|
+
else if (entry.isFile() && CODEMODE_PATTERN.test(entry.name)) results.push(full);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
walk(target);
|
|
117
|
+
return results;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { codemodeVitePlugin as default };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * Codemode Vite plugin — handles `type: \"connectors\"` import attributes.\n *\n * Usage in vite.config.ts:\n * ```ts\n * import codemode from \"@cloudflare/codemode/vite\";\n * export default { plugins: [codemode()] };\n * ```\n *\n * Then import a directory of *.codemode.ts files:\n * ```ts\n * import connectors from \"./connectors\" with { type: \"connectors\" };\n * // pass connectors to createCodemodeRuntime({ ctx, executor, connectors })\n * ```\n *\n * Or import a single connector file:\n * ```ts\n * import connectors from \"./github.codemode\" with { type: \"connectors\" };\n * ```\n *\n * The plugin:\n * 1. Discovers *.codemode.{ts,js} files in the referenced directory\n * 2. Generates a module that re-exports each connector class\n * 3. Auto-exports connector classes from the worker entry for ctx.exports access\n */\nimport { resolve, dirname, relative } from \"node:path\";\nimport { readdirSync, statSync } from \"node:fs\";\nimport type { Plugin } from \"vite\";\n\nconst CODEMODE_PATTERN = /\\.codemode\\.[tj]sx?$/;\nconst VIRTUAL_PREFIX = \"\\0codemode-connectors:\";\nconst PUBLIC_PREFIX = \"__codemode_connectors__:\";\n\nexport default function codemodeVitePlugin(): Plugin {\n let projectRoot: string;\n\n // Rewrites `from \"./x\" with { type: \"connectors\" }` → virtual module ref.\n // Also appends re-exports to the worker entry so connectors land in ctx.exports.\n function transformCode(\n code: string,\n id: string\n ): { code: string; map: null } | null {\n let result = code;\n let changed = false;\n\n // 1. Rewrite `with { type: \"connectors\" }` imports\n if (\n code.includes('type: \"connectors\"') ||\n code.includes(\"type: 'connectors'\")\n ) {\n const next = code.replace(\n /from\\s+([\"'])([^\"']+)\\1\\s+with\\s+\\{\\s*type\\s*:\\s*([\"'])connectors\\3\\s*\\}/g,\n (_match, quote: string, source: string) => {\n const resolved = resolve(dirname(id), source);\n return `from ${quote}${PUBLIC_PREFIX}${encodeURIComponent(resolved)}${quote}`;\n }\n );\n if (next !== code) {\n result = next;\n changed = true;\n }\n }\n\n // 2. Append codemode exports to the worker entry\n if (isWorkerEntry(id, projectRoot)) {\n const srcDir = resolve(projectRoot, \"src\");\n const files = findCodemodeFiles(srcDir);\n const lines: string[] = [];\n\n // Auto-export CodemodeRuntime for facet spawning\n lines.push('export { CodemodeRuntime } from \"@cloudflare/codemode\";');\n\n // Auto-export connector classes from *.codemode.ts files\n for (const file of files) {\n lines.push(`export * from ${JSON.stringify(file)};`);\n }\n\n result = `${result}\\n\\n// Auto-exported by @cloudflare/codemode/vite\\n${lines.join(\"\\n\")}\\n`;\n changed = true;\n }\n\n return changed ? { code: result, map: null } : null;\n }\n\n return {\n name: \"@cloudflare/codemode/vite\",\n enforce: \"pre\" as const,\n\n configResolved(config) {\n projectRoot = config.root;\n },\n\n transform(code, id) {\n return transformCode(code, id);\n },\n\n resolveId(source, importer, options) {\n if (source.startsWith(PUBLIC_PREFIX)) {\n return `${VIRTUAL_PREFIX}${decodeURIComponent(source.slice(PUBLIC_PREFIX.length))}`;\n }\n\n const attributes = (options as { attributes?: Record<string, string> })\n .attributes;\n if (attributes?.type !== \"connectors\") return null;\n if (!importer) return null;\n const resolved = resolve(dirname(importer), source);\n return `${VIRTUAL_PREFIX}${resolved}`;\n },\n\n load(id) {\n if (!id.startsWith(VIRTUAL_PREFIX)) return null;\n const target = id.slice(VIRTUAL_PREFIX.length);\n\n const files = findCodemodeFiles(target);\n if (files.length === 0) {\n return \"export default [];\\n\";\n }\n\n for (const file of files) {\n this.addWatchFile(file);\n }\n const stat = statSync(target, { throwIfNoEntry: false });\n if (stat?.isDirectory()) {\n this.addWatchFile(target);\n }\n\n // Re-export all connector classes from discovered files\n const lines: string[] = [];\n for (const file of files) {\n lines.push(`export * from ${JSON.stringify(file)};`);\n }\n\n return lines.join(\"\\n\") + \"\\n\";\n }\n };\n}\n\nfunction isWorkerEntry(id: string, root: string): boolean {\n const rel = relative(root, id).replace(/\\\\/g, \"/\");\n return /^src\\/(server|index|worker)\\.[tj]sx?$/.test(rel);\n}\n\nfunction findCodemodeFiles(target: string): string[] {\n let stat = statSync(target, { throwIfNoEntry: false });\n\n // Try adding extensions if the target doesn't exist as-is\n if (!stat) {\n for (const ext of [\".ts\", \".tsx\", \".js\", \".jsx\"]) {\n const withExt = target + ext;\n const extStat = statSync(withExt, { throwIfNoEntry: false });\n if (extStat?.isFile()) {\n return [withExt];\n }\n }\n return [];\n }\n\n if (stat.isFile() && CODEMODE_PATTERN.test(target)) {\n return [target];\n }\n\n if (!stat.isDirectory()) return [];\n const results: string[] = [];\n\n function walk(dir: string) {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = resolve(dir, entry.name);\n if (\n entry.isDirectory() &&\n entry.name !== \"node_modules\" &&\n entry.name !== \"dist\"\n ) {\n walk(full);\n } else if (entry.isFile() && CODEMODE_PATTERN.test(entry.name)) {\n results.push(full);\n }\n }\n }\n\n walk(target);\n return results;\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/codemode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Code Mode: use LLMs to generate executable code that performs tool calls",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/codemode",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@types/json-schema": "^7.0.15",
|
|
15
|
-
"acorn": "^8.
|
|
15
|
+
"acorn": "^8.17.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
19
19
|
"@playwright/test": "^1.60.0",
|
|
20
|
-
"@tanstack/ai": "^0.
|
|
21
|
-
"ai": "^6.0.
|
|
22
|
-
"vitest": "4.1.
|
|
20
|
+
"@tanstack/ai": "^0.28.0",
|
|
21
|
+
"ai": "^6.0.202",
|
|
22
|
+
"vitest": "4.1.8",
|
|
23
23
|
"zod": "^4.4.3"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
@@ -68,15 +68,13 @@
|
|
|
68
68
|
"types": "./dist/browser.d.ts",
|
|
69
69
|
"import": "./dist/browser.js",
|
|
70
70
|
"require": "./dist/browser.js"
|
|
71
|
+
},
|
|
72
|
+
"./vite": {
|
|
73
|
+
"types": "./dist/vite.d.ts",
|
|
74
|
+
"import": "./dist/vite.js",
|
|
75
|
+
"require": "./dist/vite.js"
|
|
71
76
|
}
|
|
72
77
|
},
|
|
73
|
-
"scripts": {
|
|
74
|
-
"build": "tsx ./scripts/build.ts",
|
|
75
|
-
"test": "vitest run && vitest run --config vitest.browser.config.ts",
|
|
76
|
-
"test:e2e": "npx playwright test --config e2e/playwright.config.ts",
|
|
77
|
-
"test:watch": "vitest",
|
|
78
|
-
"test:browser": "vitest run --config vitest.browser.config.ts"
|
|
79
|
-
},
|
|
80
78
|
"keywords": [
|
|
81
79
|
"cloudflare",
|
|
82
80
|
"agents",
|
|
@@ -90,5 +88,12 @@
|
|
|
90
88
|
"files": [
|
|
91
89
|
"dist",
|
|
92
90
|
"README.md"
|
|
93
|
-
]
|
|
94
|
-
|
|
91
|
+
],
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "tsx ./scripts/build.ts",
|
|
94
|
+
"test": "vitest run && vitest run --config vitest.runtime.config.ts && vitest run --config vitest.browser.config.ts",
|
|
95
|
+
"test:e2e": "playwright test --config e2e/playwright.config.ts",
|
|
96
|
+
"test:watch": "vitest",
|
|
97
|
+
"test:browser": "vitest run --config vitest.browser.config.ts"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-code-5x8S5YWt.js","names":[],"sources":["../src/run-code.ts"],"sourcesContent":["import type { CodeOutput } from \"./shared\";\nimport type { Executor, ResolvedProvider } from \"./executor\";\nimport { normalizeCode } from \"./normalize\";\n\nexport async function runCode({\n code,\n executor,\n providers\n}: {\n code: string;\n executor: Executor;\n providers: ResolvedProvider[];\n}): Promise<CodeOutput> {\n const executeResult = await executor.execute(normalizeCode(code), providers);\n\n if (executeResult.error) {\n const logCtx = executeResult.logs?.length\n ? `\\n\\nConsole output:\\n${executeResult.logs.join(\"\\n\")}`\n : \"\";\n throw new Error(`Code execution failed: ${executeResult.error}${logCtx}`);\n }\n\n return executeResult.logs?.length\n ? { result: executeResult.result, logs: executeResult.logs }\n : { result: executeResult.result };\n}\n"],"mappings":";;AAIA,eAAsB,QAAQ,EAC5B,MACA,UACA,aAKsB;CACtB,MAAM,gBAAgB,MAAM,SAAS,QAAQ,cAAc,IAAI,GAAG,SAAS;CAE3E,IAAI,cAAc,OAAO;EACvB,MAAM,SAAS,cAAc,MAAM,SAC/B,wBAAwB,cAAc,KAAK,KAAK,IAAI,MACpD;EACJ,MAAM,IAAI,MAAM,0BAA0B,cAAc,QAAQ,QAAQ;CAC1E;CAEA,OAAO,cAAc,MAAM,SACvB;EAAE,QAAQ,cAAc;EAAQ,MAAM,cAAc;CAAK,IACzD,EAAE,QAAQ,cAAc,OAAO;AACrC"}
|