perchai-cli 2.4.93 → 2.4.95

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.
Files changed (3) hide show
  1. package/bin/perch +17 -0
  2. package/dist/perch.mjs +806 -803
  3. package/package.json +1 -1
package/bin/perch CHANGED
@@ -9,6 +9,23 @@
9
9
  // CJS. If the re-exec cannot run for any reason, we fall through and start
10
10
  // in-process rather than fail to launch.
11
11
  (async () => {
12
+ // Publish the CLI version into the environment so the runtime can send a
13
+ // distinctive User-Agent on model calls. Set before the re-exec so the child
14
+ // inherits it. Best effort: a missing version degrades to "unknown", never a
15
+ // failed launch.
16
+ if (!process.env.PERCH_CLI_VERSION) {
17
+ try {
18
+ const { readFileSync } = await import("node:fs");
19
+ const { dirname, join } = await import("node:path");
20
+ const pkg = JSON.parse(
21
+ readFileSync(join(dirname(process.argv[1] ?? ""), "..", "package.json"), "utf8"),
22
+ );
23
+ if (pkg && pkg.version) process.env.PERCH_CLI_VERSION = String(pkg.version);
24
+ } catch {
25
+ // Version is a nice-to-have; the agent string still identifies the binary.
26
+ }
27
+ }
28
+
12
29
  const raised =
13
30
  process.env.PERCH_CLI_HEAP_REEXEC === "1" ||
14
31
  /--max[-_]old[-_]space[-_]size/.test(process.env.NODE_OPTIONS ?? "");