@vellumai/assistant 0.10.4-dev.202607010918.ba1a70c → 0.10.4-dev.202607011113.fffc936

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/assistant",
3
- "version": "0.10.4-dev.202607010918.ba1a70c",
3
+ "version": "0.10.4-dev.202607011113.fffc936",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,6 +31,7 @@ import {
31
31
  } from "../persistence/conversation-crud.js";
32
32
  import { getDb } from "../persistence/db-connection.js";
33
33
  import { initializeDb } from "../persistence/db-init.js";
34
+ import { startEmbeddingRuntimeManager } from "../persistence/embeddings/embedding-runtime-manager.js";
34
35
  import { startConsentRefresh } from "../platform/consent-cache.js";
35
36
  import { syncWorkspaceIdentityToPlatform } from "../platform/sync-identity.js";
36
37
  import { runMemoryStartup } from "../plugins/defaults/memory/startup.js";
@@ -879,30 +880,7 @@ export async function runDaemon(): Promise<void> {
879
880
  log.warn({ err }, "Assistant symlink installation failed — continuing");
880
881
  }
881
882
 
882
- // Download embedding runtime in background (non-blocking).
883
- // If download fails, local embeddings gracefully fall back to cloud backends.
884
- void (async () => {
885
- try {
886
- const { EmbeddingRuntimeManager } =
887
- await import("../persistence/embeddings/embedding-runtime-manager.js");
888
- const runtimeManager = new EmbeddingRuntimeManager();
889
- if (!runtimeManager.isReady()) {
890
- log.info("Downloading embedding runtime in background...");
891
- await runtimeManager.ensureInstalled();
892
- // Reset the sticky local-backend failure flag so auto mode retries
893
- // local embeddings without evicting a worker that may already be live.
894
- const { resetLocalEmbeddingFailureState } =
895
- await import("../persistence/embeddings/embedding-backend.js");
896
- resetLocalEmbeddingFailureState();
897
- log.info("Embedding runtime download complete");
898
- }
899
- } catch (err) {
900
- log.warn(
901
- { err },
902
- "Embedding runtime download failed — local embeddings will use cloud fallback",
903
- );
904
- }
905
- })();
883
+ startEmbeddingRuntimeManager();
906
884
 
907
885
  startWorkspaceHeartbeatService();
908
886
 
@@ -571,3 +571,34 @@ export class EmbeddingRuntimeManager {
571
571
  }
572
572
  }
573
573
  }
574
+
575
+ /**
576
+ * Download the local embedding runtime in the background (non-blocking).
577
+ *
578
+ * Pre-warms the runtime (bun binary + ONNX worker scripts) so the first local
579
+ * embed doesn't pay the download cost inline. A no-op when the runtime is
580
+ * already installed. Failures are swallowed with a warning: local embeddings
581
+ * fall back to cloud backends, so a failed download must never block or crash
582
+ * daemon startup. Returns immediately; the download proceeds on its own.
583
+ */
584
+ export function startEmbeddingRuntimeManager(): void {
585
+ void (async () => {
586
+ try {
587
+ const runtimeManager = new EmbeddingRuntimeManager();
588
+ if (runtimeManager.isReady()) return;
589
+ log.info("Downloading embedding runtime in background...");
590
+ await runtimeManager.ensureInstalled();
591
+ // Reset the sticky local-backend failure flag so auto mode retries
592
+ // local embeddings without evicting a worker that may already be live.
593
+ const { resetLocalEmbeddingFailureState } =
594
+ await import("./embedding-backend.js");
595
+ resetLocalEmbeddingFailureState();
596
+ log.info("Embedding runtime download complete");
597
+ } catch (err) {
598
+ log.warn(
599
+ { err },
600
+ "Embedding runtime download failed — local embeddings will use cloud fallback",
601
+ );
602
+ }
603
+ })();
604
+ }
@@ -7,15 +7,15 @@
7
7
  * - `hasManagedProxyPrereqs()` — true when the daemon has the credentials
8
8
  * it needs to act as a managed-proxy client, i.e. this is a managed
9
9
  * deployment.
10
- * - `getDaemonRuntimeMode()` — `"docker"` vs `"bare-metal"`, identifying
11
- * where the daemon process is running.
10
+ * - `getIsContainerized()` — true when the daemon runs inside a container
11
+ * (`IS_CONTAINERIZED`), identifying where the daemon process is running.
12
12
  *
13
13
  * Folding both into a single helper keeps callers from repeating the
14
14
  * combination logic.
15
15
  */
16
16
 
17
+ import { getIsContainerized } from "../../config/env-registry.js";
17
18
  import { hasManagedProxyPrereqs } from "../../providers/platform-proxy/context.js";
18
- import { getDaemonRuntimeMode } from "../runtime-mode.js";
19
19
 
20
20
  export type VBundleOriginMode =
21
21
  | "managed"
@@ -26,14 +26,14 @@ export type VBundleOriginMode =
26
26
  * Returns the origin mode for the current daemon.
27
27
  *
28
28
  * Managed-proxy prereqs win first (a managed deployment is always
29
- * "managed" regardless of where the daemon process runs); otherwise docker
30
- * → "self-hosted-remote", bare-metal → "self-hosted-local".
29
+ * "managed" regardless of where the daemon process runs); otherwise
30
+ * containerized → "self-hosted-remote", bare-metal → "self-hosted-local".
31
31
  */
32
32
  export async function getOriginMode(): Promise<VBundleOriginMode> {
33
33
  if (await hasManagedProxyPrereqs()) {
34
34
  return "managed";
35
35
  }
36
- if (getDaemonRuntimeMode() === "docker") {
36
+ if (getIsContainerized()) {
37
37
  return "self-hosted-remote";
38
38
  }
39
39
  return "self-hosted-local";
@@ -1,62 +0,0 @@
1
- /**
2
- * Tests for `getDaemonRuntimeMode()` — ensures the helper reflects
3
- * `IS_CONTAINERIZED` environment state via the existing truthy-check
4
- * semantics shared with `getIsContainerized()`.
5
- */
6
-
7
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
8
-
9
- import { getDaemonRuntimeMode } from "../runtime-mode.js";
10
-
11
- describe("getDaemonRuntimeMode", () => {
12
- let savedIsContainerized: string | undefined;
13
-
14
- beforeEach(() => {
15
- savedIsContainerized = process.env.IS_CONTAINERIZED;
16
- });
17
-
18
- afterEach(() => {
19
- if (savedIsContainerized === undefined) {
20
- delete process.env.IS_CONTAINERIZED;
21
- } else {
22
- process.env.IS_CONTAINERIZED = savedIsContainerized;
23
- }
24
- });
25
-
26
- test("returns 'docker' when IS_CONTAINERIZED=true", () => {
27
- process.env.IS_CONTAINERIZED = "true";
28
- expect(getDaemonRuntimeMode()).toBe("docker");
29
- });
30
-
31
- test("returns 'docker' when IS_CONTAINERIZED=1", () => {
32
- // Matches the existing truthy-check in getIsContainerized(), which
33
- // treats "1" as equivalent to "true" for boolean env flags.
34
- process.env.IS_CONTAINERIZED = "1";
35
- expect(getDaemonRuntimeMode()).toBe("docker");
36
- });
37
-
38
- test("returns 'bare-metal' when IS_CONTAINERIZED is unset", () => {
39
- delete process.env.IS_CONTAINERIZED;
40
- expect(getDaemonRuntimeMode()).toBe("bare-metal");
41
- });
42
-
43
- test("returns 'bare-metal' when IS_CONTAINERIZED=false", () => {
44
- process.env.IS_CONTAINERIZED = "false";
45
- expect(getDaemonRuntimeMode()).toBe("bare-metal");
46
- });
47
-
48
- test("returns 'bare-metal' when IS_CONTAINERIZED=0", () => {
49
- process.env.IS_CONTAINERIZED = "0";
50
- expect(getDaemonRuntimeMode()).toBe("bare-metal");
51
- });
52
-
53
- test("returns 'bare-metal' when IS_CONTAINERIZED is an empty string", () => {
54
- process.env.IS_CONTAINERIZED = "";
55
- expect(getDaemonRuntimeMode()).toBe("bare-metal");
56
- });
57
-
58
- test("returns 'bare-metal' for arbitrary non-truthy values", () => {
59
- process.env.IS_CONTAINERIZED = "yes";
60
- expect(getDaemonRuntimeMode()).toBe("bare-metal");
61
- });
62
- });
@@ -1,38 +0,0 @@
1
- /**
2
- * Daemon runtime-mode detection.
3
- *
4
- * Exposes a single well-named helper `getDaemonRuntimeMode()` that returns
5
- * `"docker"` when the daemon is running inside a container and
6
- * `"bare-metal"` otherwise.
7
- *
8
- * Under the hood this delegates to `getIsContainerized()` from the env
9
- * registry, which accepts the standard truthy values for `IS_CONTAINERIZED`
10
- * (`"true"` or `"1"`). Keeping the check in the registry avoids duplicating
11
- * the env-parsing semantics across modules.
12
- *
13
- * The mode-named API (rather than a boolean) exists to make downstream
14
- * switch/branch code read naturally — e.g. `if (mode === "docker") { ... }`
15
- * is clearer than `if (isContainerized) { ... }` when the behavior depends
16
- * on the specific deployment shape, and it leaves room for additional
17
- * runtime modes in the future without renaming every callsite.
18
- *
19
- * The `DaemonRuntimeMode` type is declared here, alongside the resolver
20
- * that produces it. `"docker"` describes a daemon running inside a
21
- * container; `"bare-metal"` describes a daemon running directly on the
22
- * host.
23
- */
24
-
25
- import { getIsContainerized } from "../config/env-registry.js";
26
-
27
- export type DaemonRuntimeMode = "bare-metal" | "docker";
28
-
29
- /**
30
- * Returns the deployment mode the daemon is currently running under.
31
- *
32
- * - `"docker"` when `IS_CONTAINERIZED` is set to a truthy value
33
- * (`"true"` or `"1"`).
34
- * - `"bare-metal"` otherwise.
35
- */
36
- export function getDaemonRuntimeMode(): DaemonRuntimeMode {
37
- return getIsContainerized() ? "docker" : "bare-metal";
38
- }