@vellumai/cli 0.3.2 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "CLI tools for vellum-assistant",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,8 +1,10 @@
1
1
  import { randomBytes } from "crypto";
2
- import { existsSync, readFileSync, unlinkSync, writeFileSync } from "fs";
3
- import { createRequire } from "module";
2
+ import { existsSync, unlinkSync, writeFileSync } from "fs";
4
3
  import { homedir, tmpdir, userInfo } from "os";
5
- import { dirname, join } from "path";
4
+ import { join } from "path";
5
+
6
+ // Direct import — bun embeds this at compile time so it works in compiled binaries.
7
+ import cliPkg from "../../package.json";
6
8
 
7
9
  import { buildOpenclawStartupScript } from "../adapters/openclaw";
8
10
  import { loadAllAssistants, saveAssistantEntry } from "../lib/assistant-config";
@@ -569,27 +571,7 @@ async function hatchLocal(species: Species, name: string | null, daemonOnly: boo
569
571
  }
570
572
 
571
573
  function getCliVersion(): string {
572
- // Strategy 1: createRequire — works in Bun dev (source tree).
573
- try {
574
- const require = createRequire(import.meta.url);
575
- const pkg = require("../../package.json") as { version?: string };
576
- if (pkg.version) return pkg.version;
577
- } catch {
578
- // Fall through to next strategy.
579
- }
580
-
581
- // Strategy 2: Read package.json adjacent to the compiled binary.
582
- try {
583
- const binPkg = join(dirname(process.execPath), "package.json");
584
- if (existsSync(binPkg)) {
585
- const pkg = JSON.parse(readFileSync(binPkg, "utf-8")) as { version?: string };
586
- if (pkg.version) return pkg.version;
587
- }
588
- } catch {
589
- // Fall through.
590
- }
591
-
592
- return "unknown";
574
+ return cliPkg.version ?? "unknown";
593
575
  }
594
576
 
595
577
  export async function hatch(): Promise<void> {
package/src/index.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
+ import { createRequire } from "node:module";
4
+ import { dirname, join } from "node:path";
5
+ import { spawn } from "node:child_process";
3
6
  import { client } from "./commands/client";
4
7
  import { hatch } from "./commands/hatch";
5
8
  import { ps } from "./commands/ps";
@@ -23,7 +26,7 @@ async function main() {
23
26
  const commandName = args[0];
24
27
 
25
28
  if (!commandName || commandName === "--help" || commandName === "-h") {
26
- console.log("Usage: vellum-cli <command> [options]");
29
+ console.log("Usage: vellum <command> [options]");
27
30
  console.log("");
28
31
  console.log("Commands:");
29
32
  console.log(" client Connect to a hatched assistant");
@@ -38,9 +41,30 @@ async function main() {
38
41
  const command = commands[commandName as CommandName];
39
42
 
40
43
  if (!command) {
41
- console.error(`Error: Unknown command '${commandName}'`);
42
- console.error("Run 'vellum-cli --help' for usage information.");
43
- process.exit(1);
44
+ try {
45
+ const require = createRequire(import.meta.url);
46
+ const assistantPkgPath = require.resolve(
47
+ "@vellumai/assistant/package.json"
48
+ );
49
+ const assistantEntry = join(
50
+ dirname(assistantPkgPath),
51
+ "src",
52
+ "index.ts"
53
+ );
54
+ const child = spawn("bun", ["run", assistantEntry, ...args], {
55
+ stdio: "inherit",
56
+ });
57
+ child.on("exit", (code) => {
58
+ process.exit(code ?? 1);
59
+ });
60
+ } catch {
61
+ console.error(`Unknown command: ${commandName}`);
62
+ console.error(
63
+ "Install the full stack with: bun install -g vellum"
64
+ );
65
+ process.exit(1);
66
+ }
67
+ return;
44
68
  }
45
69
 
46
70
  try {
package/src/lib/local.ts CHANGED
@@ -294,7 +294,7 @@ export async function startGateway(): Promise<string> {
294
294
  }
295
295
 
296
296
  console.log("🌐 Starting gateway...");
297
- const gatewayDir = resolveGatewayDir();
297
+
298
298
  // Only auto-configure default routing when the workspace has exactly one
299
299
  // assistant. In multi-assistant deployments, falling back to "default"
300
300
  // would silently deliver unmapped Telegram chats to whichever assistant was
@@ -331,12 +331,34 @@ export async function startGateway(): Promise<string> {
331
331
  console.log(` Ingress URL: ${ingressPublicBaseUrl}`);
332
332
  }
333
333
 
334
- const gateway = spawn("bun", ["run", "src/index.ts"], {
335
- cwd: gatewayDir,
336
- detached: true,
337
- stdio: "ignore",
338
- env: gatewayEnv,
339
- });
334
+ let gateway;
335
+
336
+ if (process.env.VELLUM_DESKTOP_APP) {
337
+ // Desktop app: spawn the compiled gateway binary directly (mirrors daemon pattern).
338
+ const gatewayBinary = join(dirname(process.execPath), "vellum-gateway");
339
+ if (!existsSync(gatewayBinary)) {
340
+ throw new Error(
341
+ `vellum-gateway binary not found at ${gatewayBinary}.\n` +
342
+ " Ensure the gateway binary is bundled alongside the CLI in the app bundle.",
343
+ );
344
+ }
345
+
346
+ gateway = spawn(gatewayBinary, [], {
347
+ detached: true,
348
+ stdio: "ignore",
349
+ env: gatewayEnv,
350
+ });
351
+ } else {
352
+ // Source tree / bunx: resolve the gateway source directory and run via bun.
353
+ const gatewayDir = resolveGatewayDir();
354
+ gateway = spawn("bun", ["run", "src/index.ts"], {
355
+ cwd: gatewayDir,
356
+ detached: true,
357
+ stdio: "ignore",
358
+ env: gatewayEnv,
359
+ });
360
+ }
361
+
340
362
  gateway.unref();
341
363
 
342
364
  if (gateway.pid) {