@agent-compose/sdk 0.2.2 → 0.2.3

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/dist/index.js CHANGED
@@ -597,7 +597,7 @@ async function bundle(path, label) {
597
597
  const bun = globalThis;
598
598
  if (!bun.Bun?.build)
599
599
  throw new Error("bundleWorkflow requires the Bun runtime (Bun.build)");
600
- const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "bun" });
600
+ const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "node" });
601
601
  if (!result.success) {
602
602
  throw new Error(`Failed to bundle ${label}:
603
603
  ${result.logs.map((l) => l.message).join(`
@@ -597,7 +597,7 @@ async function bundle(path, label) {
597
597
  const bun = globalThis;
598
598
  if (!bun.Bun?.build)
599
599
  throw new Error("bundleWorkflow requires the Bun runtime (Bun.build)");
600
- const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "bun" });
600
+ const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "node" });
601
601
  if (!result.success) {
602
602
  throw new Error(`Failed to bundle ${label}:
603
603
  ${result.logs.map((l) => l.message).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-compose/sdk",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Client library for agent-compose — define agents, runtimes, and workflows, and invoke them against an agent-compose server.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,21 @@ async function bundle(path: string, label: string): Promise<string> {
29
29
  // Use globalThis to access Bun without a compile-time dependency on @types/bun.
30
30
  const bun = globalThis as unknown as { Bun?: { build(opts: { entrypoints: string[]; format: string; target: string }): Promise<{ success: boolean; outputs: { text(): Promise<string> }[]; logs: { message: string }[] }> } };
31
31
  if (!bun.Bun?.build) throw new Error("bundleWorkflow requires the Bun runtime (Bun.build)");
32
- const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "bun" });
32
+ // target: "node" — the bundle runs inside the Vercel sandbox under Node 22+.
33
+ //
34
+ // Bun's `target: "bun"` emits `var __require = import.meta.require;` for any
35
+ // module that needs CJS interop (e.g. workflows importing `ai`, `@ai-sdk/*`,
36
+ // or anything with a CommonJS dependency in its resolution tree). That shim
37
+ // is undefined under Node, so the bundle crashes at evaluation with
38
+ // `__require is not a function` *before* the runner emits its first
39
+ // heartbeat — the run looks like "sandbox lease expired" from the server
40
+ // side, with no other signal. `target: "node"` emits a Node-compatible
41
+ // shim (`module.createRequire(import.meta.url)`) so CJS interop works.
42
+ //
43
+ // Pure-ESM workflows (e.g. only importing `@agent-compose/sdk`) bundled
44
+ // identically under either target — that's why this bug stayed hidden
45
+ // until the first workflow that pulled CJS deps got dispatched.
46
+ const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "node" });
33
47
  if (!result.success) {
34
48
  throw new Error(`Failed to bundle ${label}:\n${result.logs.map((l) => l.message).join("\n")}`);
35
49
  }