@plasm_lang/vercel-agent 0.3.102 → 0.3.104

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasm_lang/vercel-agent",
3
- "version": "0.3.102",
3
+ "version": "0.3.104",
4
4
  "description": "Catalog-native TypeScript agent framework (Plasm CGS/CML, Vercel AI SDK, Nitro-oriented)",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -64,7 +64,7 @@
64
64
  "dependencies": {
65
65
  "@ai-sdk/otel": "^1.0.3",
66
66
  "@opentelemetry/api": "^1.9.0",
67
- "@plasm_lang/engine": "^0.3.102",
67
+ "@plasm_lang/engine": "^0.3.104",
68
68
  "@vercel/blob": "^0.27.3",
69
69
  "@vercel/connect": "^0.2.6",
70
70
  "@vercel/kv": "^3.0.0",
@@ -0,0 +1,93 @@
1
+ import { createRequire } from "node:module";
2
+ import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+
5
+ import { isVercelBuildEnvironment } from "./paths.js";
6
+
7
+ const ENGINE_PACKAGES = [
8
+ "@plasm_lang/engine",
9
+ "@plasm_lang/engine-linux-x64-gnu",
10
+ "@plasm_lang/engine-linux-x64-musl",
11
+ "@plasm_lang/engine-darwin-arm64",
12
+ "@plasm_lang/engine-darwin-x64",
13
+ ] as const;
14
+
15
+ const VERCEL_ENGINE_PACKAGES = [
16
+ "@plasm_lang/engine",
17
+ "@plasm_lang/engine-linux-x64-gnu",
18
+ "@plasm_lang/engine-linux-x64-musl",
19
+ ] as const;
20
+
21
+ function scopedPackageDest(funcDir: string, pkg: string): string {
22
+ const slash = pkg.indexOf("/");
23
+ const scope = pkg.slice(0, slash);
24
+ const name = pkg.slice(slash + 1);
25
+ return path.join(funcDir, "node_modules", scope, name);
26
+ }
27
+
28
+ /** Copy native engine packages into the traced Vercel function `node_modules`. */
29
+ export async function copyNativeEnginePackages(
30
+ projectRoot: string,
31
+ funcDir: string,
32
+ ): Promise<void> {
33
+ const require = createRequire(path.join(projectRoot, "package.json"));
34
+
35
+ let enginePkgJson: string;
36
+ try {
37
+ enginePkgJson = require.resolve("@plasm_lang/engine/package.json");
38
+ } catch {
39
+ return;
40
+ }
41
+
42
+ const engineDir = path.dirname(enginePkgJson);
43
+ const engineRequire = createRequire(path.join(engineDir, "package.json"));
44
+ const packagesToCopy = isVercelBuildEnvironment()
45
+ ? [...VERCEL_ENGINE_PACKAGES]
46
+ : [...ENGINE_PACKAGES];
47
+ const copied: Array<{ pkg: string; version: string; dest: string }> = [];
48
+
49
+ for (const pkg of packagesToCopy) {
50
+ let pkgJsonPath: string;
51
+ try {
52
+ pkgJsonPath =
53
+ pkg === "@plasm_lang/engine"
54
+ ? enginePkgJson
55
+ : engineRequire.resolve(`${pkg}/package.json`);
56
+ } catch {
57
+ continue;
58
+ }
59
+
60
+ const srcDir = path.dirname(pkgJsonPath);
61
+ const destDir = scopedPackageDest(funcDir, pkg);
62
+ await mkdir(path.dirname(destDir), { recursive: true });
63
+ await cp(srcDir, destDir, { recursive: true, force: true });
64
+
65
+ const raw = await readFile(pkgJsonPath, "utf8");
66
+ const version = (JSON.parse(raw) as { version?: string }).version ?? "0.0.0";
67
+ copied.push({ pkg, version, dest: destDir });
68
+ }
69
+
70
+ if (!copied.some((entry) => entry.pkg === "@plasm_lang/engine")) {
71
+ return;
72
+ }
73
+
74
+ const funcPackagePath = path.join(funcDir, "package.json");
75
+ let funcPackage: { dependencies?: Record<string, string> } = {};
76
+ try {
77
+ funcPackage = JSON.parse(await readFile(funcPackagePath, "utf8")) as {
78
+ dependencies?: Record<string, string>;
79
+ };
80
+ } catch {
81
+ funcPackage = { type: "module", private: true, dependencies: {} };
82
+ }
83
+
84
+ const dependencies = { ...(funcPackage.dependencies ?? {}) };
85
+ for (const { pkg, version } of copied) {
86
+ dependencies[pkg] = version;
87
+ }
88
+ await writeFile(
89
+ funcPackagePath,
90
+ `${JSON.stringify({ ...funcPackage, dependencies }, null, 2)}\n`,
91
+ "utf8",
92
+ );
93
+ }
@@ -1,6 +1,7 @@
1
1
  import { access, cp } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
 
4
+ import { copyNativeEnginePackages } from "./copy-native-engine-packages.js";
4
5
  import { vercelOutputDir } from "./paths.js";
5
6
 
6
7
  async function pathExists(p: string): Promise<boolean> {
@@ -24,6 +25,8 @@ export async function copyVercelFunctionAssets(options: {
24
25
 
25
26
  await cp(options.agentRoot, path.join(funcDir, "agent"), { recursive: true });
26
27
 
28
+ await copyNativeEnginePackages(options.projectRoot, funcDir);
29
+
27
30
  const libDir = path.join(options.projectRoot, "lib");
28
31
  if (await pathExists(libDir)) {
29
32
  await cp(libDir, path.join(funcDir, "lib"), { recursive: true });
@@ -20,6 +20,10 @@ const SERVER_TRACE_DEPS = [
20
20
  "@ai-sdk/otel",
21
21
  "@opentelemetry/api",
22
22
  "@plasm_lang/engine",
23
+ "@plasm_lang/engine-linux-x64-gnu",
24
+ "@plasm_lang/engine-linux-x64-musl",
25
+ "@plasm_lang/engine-darwin-arm64",
26
+ "@plasm_lang/engine-darwin-x64",
23
27
  "@plasm_lang/vercel-agent",
24
28
  "@vercel/functions",
25
29
  "@vercel/blob",