@vellumai/cli 0.7.3 → 0.8.0

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib/local.ts +37 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/cli",
3
- "version": "0.7.3",
3
+ "version": "0.8.0",
4
4
  "description": "CLI tools for vellum-assistant",
5
5
  "type": "module",
6
6
  "exports": {
package/src/lib/local.ts CHANGED
@@ -840,6 +840,42 @@ export function isGatewayWatchModeAvailable(): boolean {
840
840
  }
841
841
  }
842
842
 
843
+ /**
844
+ * Write (or overwrite) a shell wrapper at `<workspace>/bin/assistant` that
845
+ * pre-injects the three instance-specific env vars before exec-ing the real
846
+ * assistant binary from the app bundle.
847
+ *
848
+ * This lets developers invoke `<workspace>/bin/assistant <command>` directly
849
+ * from the terminal without manually setting env vars. Only created when a
850
+ * compiled `assistant` binary is present adjacent to the CLI executable (i.e.
851
+ * inside a desktop app bundle) — a no-op in source/watch mode.
852
+ *
853
+ * The wrapper is idempotent: safe to call on every daemon wake.
854
+ */
855
+ function writeAssistantWrapper(resources: LocalInstanceResources): void {
856
+ const assistantBinary = join(dirname(process.execPath), "assistant");
857
+ if (!existsSync(assistantBinary)) return;
858
+
859
+ const workspaceDir = join(resources.instanceDir, ".vellum", "workspace");
860
+ const protectedDir = join(resources.instanceDir, ".vellum", "protected");
861
+ const binDir = join(workspaceDir, "bin");
862
+
863
+ mkdirSync(binDir, { recursive: true });
864
+ const wrapperPath = join(binDir, "assistant");
865
+ writeFileSync(
866
+ wrapperPath,
867
+ [
868
+ "#!/bin/sh",
869
+ `export VELLUM_WORKSPACE_DIR="${workspaceDir}"`,
870
+ `export CREDENTIAL_SECURITY_DIR="${protectedDir}"`,
871
+ `export GATEWAY_SECURITY_DIR="${protectedDir}"`,
872
+ `exec "${assistantBinary}" "$@"`,
873
+ "",
874
+ ].join("\n"),
875
+ { mode: 0o755 },
876
+ );
877
+ }
878
+
843
879
  // NOTE: startLocalDaemon() is the CLI-side daemon lifecycle manager.
844
880
  // It should eventually converge with
845
881
  // assistant/src/daemon/daemon-control.ts::startDaemon which is the
@@ -850,6 +886,7 @@ export async function startLocalDaemon(
850
886
  options?: DaemonStartOptions,
851
887
  ): Promise<void> {
852
888
  warnIfLegacyWorkspaceFallbackDetected(resources);
889
+ writeAssistantWrapper(resources);
853
890
 
854
891
  const foreground = options?.foreground ?? false;
855
892
  // Check for a compiled daemon binary adjacent to the CLI executable.