-
Notifications
You must be signed in to change notification settings - Fork 8
ci: verify harness runtime in Cloudflare Workers #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ai-sdk-tool/harness": patch | ||
| --- | ||
|
|
||
| Verify the runtime subpath in a real Cloudflare Worker bundle and keep optional Node-only MCP and skills modules out of edge bundles unless those features are configured. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { createAgentRuntime, defineAgent } from "@ai-sdk-tool/harness/runtime"; | ||
|
|
||
| export default { | ||
| async fetch() { | ||
| if ("process" in globalThis) { | ||
| return json({ ok: false, error: "process global is present" }, 500); | ||
| } | ||
|
|
||
| const runtime = await createAgentRuntime({ | ||
| name: "cf-worker-edge-smoke", | ||
| cwd: "/", | ||
| agents: [ | ||
| defineAgent({ | ||
| name: "bot", | ||
| agent: { model: {}, instructions: "edge smoke" }, | ||
| }), | ||
| ], | ||
| }); | ||
|
|
||
| try { | ||
| const session = await runtime.openSession({ | ||
| sessionId: "cf-worker-edge-smoke-session", | ||
| }); | ||
| return json({ | ||
| ok: session.sessionId === "cf-worker-edge-smoke-session", | ||
| sessionId: session.sessionId, | ||
| }); | ||
| } finally { | ||
| await runtime.close(); | ||
| } | ||
| }, | ||
| }; | ||
|
|
||
| function json(body, status = 200) { | ||
| return new Response(JSON.stringify(body), { | ||
| headers: { "content-type": "application/json" }, | ||
| status, | ||
| }); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema": "../../../node_modules/wrangler/config-schema.json", | ||
| "name": "plugsuits-harness-runtime-edge-smoke", | ||
| "main": "./worker.mjs", | ||
| "compatibility_date": "2026-04-27", | ||
| "workers_dev": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ import type { | |
| DefinedAgent, | ||
| } from "./types"; | ||
|
|
||
| const SKILLS_MODULE = "../skills.js"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
|
|
||
| const getDefaultCwd = (): string => { | ||
| if (typeof process === "undefined") { | ||
| return "/"; | ||
|
|
@@ -29,7 +31,9 @@ const getDefaultCwd = (): string => { | |
| const loadConfiguredSkills = async ( | ||
| config: AgentSkillsConfig | ||
| ): Promise<SkillInfo[]> => { | ||
| const { SkillsEngine } = await import("../skills"); | ||
| const { SkillsEngine }: typeof import("../skills") = await import( | ||
| SKILLS_MODULE | ||
| ); | ||
| return await new SkillsEngine(config).loadAllSkills(); | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces
"./mcp-init.js"in source TS, which conflicts with the rootAGENTS.mdguideline requiring extensionless source imports and risks module-not-found errors for source-condition users/toolchains that don’t map.jsback to.ts; that failure path is triggered specifically whenconfig.mcpis provided. Keep the source import extensionless and apply extension fixes in compileddistinstead.Useful? React with 👍 / 👎.