@telora/daemon 0.18.70 → 0.18.78

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 (53) hide show
  1. package/build-info.json +5 -3
  2. package/dist/completion/team-completion.d.ts.map +1 -1
  3. package/dist/completion/team-completion.js +6 -0
  4. package/dist/completion/team-completion.js.map +1 -1
  5. package/dist/directive/close-loop-stage.d.ts.map +1 -1
  6. package/dist/directive/close-loop-stage.js +4 -0
  7. package/dist/directive/close-loop-stage.js.map +1 -1
  8. package/dist/directive/directive-dispatch.d.ts +2 -2
  9. package/dist/directive/directive-dispatch.d.ts.map +1 -1
  10. package/dist/directive/directive-dispatch.js +7 -5
  11. package/dist/directive/directive-dispatch.js.map +1 -1
  12. package/dist/directive/directive-queue.d.ts +15 -0
  13. package/dist/directive/directive-queue.d.ts.map +1 -1
  14. package/dist/directive/directive-queue.js.map +1 -1
  15. package/dist/directive-executor.d.ts.map +1 -1
  16. package/dist/directive-executor.js +6 -1
  17. package/dist/directive-executor.js.map +1 -1
  18. package/dist/focus-executor.d.ts +46 -8
  19. package/dist/focus-executor.d.ts.map +1 -1
  20. package/dist/focus-executor.js +149 -63
  21. package/dist/focus-executor.js.map +1 -1
  22. package/dist/host-control/capability.d.ts.map +1 -1
  23. package/dist/host-control/capability.js +24 -7
  24. package/dist/host-control/capability.js.map +1 -1
  25. package/dist/host-control/catalog.d.ts +27 -0
  26. package/dist/host-control/catalog.d.ts.map +1 -1
  27. package/dist/host-control/catalog.js +82 -8
  28. package/dist/host-control/catalog.js.map +1 -1
  29. package/dist/host-control/index.d.ts +2 -0
  30. package/dist/host-control/index.d.ts.map +1 -1
  31. package/dist/host-control/index.js +1 -0
  32. package/dist/host-control/index.js.map +1 -1
  33. package/dist/host-control/load.d.ts +66 -21
  34. package/dist/host-control/load.d.ts.map +1 -1
  35. package/dist/host-control/load.js +84 -23
  36. package/dist/host-control/load.js.map +1 -1
  37. package/dist/host-control/sizing.d.ts +12 -0
  38. package/dist/host-control/sizing.d.ts.map +1 -1
  39. package/dist/host-control/sizing.js +54 -5
  40. package/dist/host-control/sizing.js.map +1 -1
  41. package/dist/host-control/swap-manager.d.ts +94 -0
  42. package/dist/host-control/swap-manager.d.ts.map +1 -0
  43. package/dist/host-control/swap-manager.js +156 -0
  44. package/dist/host-control/swap-manager.js.map +1 -0
  45. package/dist/model-resolution.d.ts +31 -0
  46. package/dist/model-resolution.d.ts.map +1 -0
  47. package/dist/model-resolution.js +33 -0
  48. package/dist/model-resolution.js.map +1 -0
  49. package/dist/prompt-sections/persona-sections.d.ts +1 -1
  50. package/dist/prompt-sections/persona-sections.d.ts.map +1 -1
  51. package/dist/prompt-sections/persona-sections.js +22 -1
  52. package/dist/prompt-sections/persona-sections.js.map +1 -1
  53. package/package.json +1 -1
@@ -20,6 +20,33 @@
20
20
  import type { LoadableCatalog, LoadableModel } from './types.js';
21
21
  /** The control-surface path (under the host ROOT, not `/v1`) for the full catalog. */
22
22
  export declare const HOST_CONTROL_CATALOG_PATH = "/api/models/local";
23
+ /**
24
+ * TTL (ms) for the last-known-controllable catalog cache. A controllable host's
25
+ * catalog is stable over a pass; caching it means ONE slow/timed-out probe does
26
+ * not silently downgrade a managed host to the `/v1/models` floor (which would
27
+ * skip the swap and spawn against whatever is loaded). Bounded so a genuinely
28
+ * removed model / decommissioned host eventually re-probes. 5 minutes ~= 10
29
+ * focus-poll ticks.
30
+ */
31
+ export declare const HOST_CONTROL_CATALOG_CACHE_TTL_MS = 300000;
32
+ /**
33
+ * Return the fresh last-known controllable catalog for a host root, or null when
34
+ * absent or expired. `nowMs` is injectable for deterministic TTL tests.
35
+ */
36
+ export declare function getCachedControllableCatalog(root: string, nowMs?: number): LoadableCatalog | null;
37
+ /**
38
+ * Cache a CONTROLLABLE catalog for a host root. A non-controllable (floor)
39
+ * catalog is never cached -- only a positive control-surface read is worth
40
+ * retaining across a transient probe failure.
41
+ */
42
+ export declare function cacheControllableCatalog(root: string, catalog: LoadableCatalog, nowMs?: number): void;
43
+ /** Test-only: clear the per-host catalog cache between cases. */
44
+ export declare function __resetHostControlCatalogCache(): void;
45
+ /**
46
+ * True when a captured load path is an HF-cache snapshot directory rather than a
47
+ * loadable model file/path. Pure + exported for unit testing.
48
+ */
49
+ export declare function isHfCacheSnapshotPath(path: string): boolean;
23
50
  /**
24
51
  * Normalize a control-surface catalog payload into clean `LoadableModel`
25
52
  * entries. Pure + DEFENSIVE: tolerates a bare array or a wrapped container,
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/host-control/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjE,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAgD7D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,EAAE,CAkBvE;AAYD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,eAAe,CAAC,CAwB1B"}
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/host-control/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAUH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjE,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,SAAU,CAAC;AAUzD;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAmB,GACzB,eAAe,GAAG,IAAI,CAQxB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,EACxB,KAAK,GAAE,MAAmB,GACzB,IAAI,CAGN;AAED,iEAAiE;AACjE,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAkCD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AA2BD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,EAAE,CAsBvE;AAYD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,eAAe,CAAC,CAwC1B"}
@@ -18,9 +18,48 @@
18
18
  * live-shape reconciliation.
19
19
  */
20
20
  import { fetchModels } from '../discovery-poll.js';
21
- import { hostGet, hostRootFromBaseUrl, HOST_CONTROL_FETCH_TIMEOUT_MS, HostControlError, } from './client.js';
21
+ import { hostGet, hostRootFromBaseUrl, HOST_CONTROL_FETCH_TIMEOUT_MS, HOST_CONTROL_ERROR_UNREACHABLE, HostControlError, } from './client.js';
22
22
  /** The control-surface path (under the host ROOT, not `/v1`) for the full catalog. */
23
23
  export const HOST_CONTROL_CATALOG_PATH = '/api/models/local';
24
+ /**
25
+ * TTL (ms) for the last-known-controllable catalog cache. A controllable host's
26
+ * catalog is stable over a pass; caching it means ONE slow/timed-out probe does
27
+ * not silently downgrade a managed host to the `/v1/models` floor (which would
28
+ * skip the swap and spawn against whatever is loaded). Bounded so a genuinely
29
+ * removed model / decommissioned host eventually re-probes. 5 minutes ~= 10
30
+ * focus-poll ticks.
31
+ */
32
+ export const HOST_CONTROL_CATALOG_CACHE_TTL_MS = 300_000;
33
+ /** Per-host (keyed by host root) last-known controllable catalog. */
34
+ const hostCatalogCache = new Map();
35
+ /**
36
+ * Return the fresh last-known controllable catalog for a host root, or null when
37
+ * absent or expired. `nowMs` is injectable for deterministic TTL tests.
38
+ */
39
+ export function getCachedControllableCatalog(root, nowMs = Date.now()) {
40
+ const entry = hostCatalogCache.get(root);
41
+ if (!entry)
42
+ return null;
43
+ if (nowMs - entry.cachedAtMs > HOST_CONTROL_CATALOG_CACHE_TTL_MS) {
44
+ hostCatalogCache.delete(root);
45
+ return null;
46
+ }
47
+ return entry.catalog;
48
+ }
49
+ /**
50
+ * Cache a CONTROLLABLE catalog for a host root. A non-controllable (floor)
51
+ * catalog is never cached -- only a positive control-surface read is worth
52
+ * retaining across a transient probe failure.
53
+ */
54
+ export function cacheControllableCatalog(root, catalog, nowMs = Date.now()) {
55
+ if (!catalog.controllable)
56
+ return;
57
+ hostCatalogCache.set(root, { catalog, cachedAtMs: nowMs });
58
+ }
59
+ /** Test-only: clear the per-host catalog cache between cases. */
60
+ export function __resetHostControlCatalogCache() {
61
+ hostCatalogCache.clear();
62
+ }
24
63
  /**
25
64
  * Candidate keys that may carry the array of catalog entries. The live host
26
65
  * (Unsloth Studio) returned a bare array under `/api/models/local`; other hosts
@@ -39,6 +78,23 @@ const ID_KEYS = ['id', 'model', 'name'];
39
78
  * Delivery 2 can resolve id -> path to load the model.
40
79
  */
41
80
  const MODEL_PATH_KEYS = ['model_path', 'modelPath', 'path', 'file', 'gguf_path'];
81
+ /**
82
+ * HuggingFace-cache snapshot directory pattern. The HF cache lays a downloaded
83
+ * model out under a `models--<org>--<name>` directory (e.g. the live Unsloth
84
+ * host's `path`: `C:\Users\...\models--unsloth--gemma-4-12B-it-qat-GGUF`). That
85
+ * directory is NOT a loadable `model_path` for Unsloth `/v1/load` -- the host
86
+ * returns HTTP 500 for it and HTTP 200 for the entry's repo id. So we recognize
87
+ * such a path and treat it as a non-path, letting `resolveModelPath` fall back
88
+ * to the entry id (the repo id). Matches `\` or `/` separators (Windows hosts).
89
+ */
90
+ const HF_CACHE_SNAPSHOT_RE = /models--[^/\\]+--/;
91
+ /**
92
+ * True when a captured load path is an HF-cache snapshot directory rather than a
93
+ * loadable model file/path. Pure + exported for unit testing.
94
+ */
95
+ export function isHfCacheSnapshotPath(path) {
96
+ return HF_CACHE_SNAPSHOT_RE.test(path);
97
+ }
42
98
  /** Read the first string-valued key present on an object, trimmed; '' if none. */
43
99
  function firstString(obj, keys) {
44
100
  for (const key of keys) {
@@ -83,7 +139,11 @@ export function normalizeLocalCatalog(payload) {
83
139
  const id = firstString(obj, ID_KEYS);
84
140
  if (!id)
85
141
  continue; // an entry with no usable id is unselectable -- drop it.
86
- const modelPath = firstString(obj, MODEL_PATH_KEYS) || null;
142
+ const rawPath = firstString(obj, MODEL_PATH_KEYS) || null;
143
+ // An HF-cache snapshot dir (`models--<org>--<name>`) is NOT a loadable
144
+ // model_path -- Unsloth /v1/load 500s on it. Drop it to null so the entry's
145
+ // repo id becomes the load target (resolveModelPath falls back to the id).
146
+ const modelPath = rawPath && isHfCacheSnapshotPath(rawPath) ? null : rawPath;
87
147
  const existing = byId.get(id);
88
148
  if (!existing) {
89
149
  byId.set(id, { id, modelPath });
@@ -130,15 +190,29 @@ export async function readLoadableCatalog(baseUrl, apiKey) {
130
190
  });
131
191
  const models = normalizeLocalCatalog(payload);
132
192
  if (models.length > 0) {
133
- return { controllable: true, ids: models.map((m) => m.id), models };
193
+ const catalog = { controllable: true, ids: models.map((m) => m.id), models };
194
+ // Cache the positive read so a later transient probe failure can retain it.
195
+ cacheControllableCatalog(root, catalog);
196
+ return catalog;
134
197
  }
135
- // Well-formed but empty (or no usable ids): not a usable control catalog --
136
- // fall through to the floor so the picklist still offers the loaded model.
198
+ // Well-formed but empty (or no usable ids): a DEFINITIVE not-controllable
199
+ // answer (e.g. a plain OpenAI endpoint) -- fall through to the floor. Do NOT
200
+ // use a stale cache here: the host actively answered "no catalog".
137
201
  }
138
202
  catch (err) {
139
- // Fail-safe: any control-surface error means "not controllable here". Log the
140
- // rich detail daemon-side (address-free dbMessage available for categorizing)
141
- // and fall through to the floor. Never break a plain endpoint.
203
+ // A TRANSIENT failure (timeout / network unreachable) must not silently
204
+ // downgrade a known-controllable host to the floor -- that skips the swap
205
+ // exactly when the host is busy cold-loading. Retain the last-known
206
+ // controllable catalog if we have a fresh one.
207
+ if (err instanceof HostControlError && err.dbMessage === HOST_CONTROL_ERROR_UNREACHABLE) {
208
+ const cached = getCachedControllableCatalog(root);
209
+ if (cached) {
210
+ console.log(`[host-control] catalog probe failed transiently; using last-known controllable catalog for ${root}`);
211
+ return cached;
212
+ }
213
+ }
214
+ // No cache to fall back on (or a definitive non-2xx status error): log and
215
+ // fall through to the floor. Never break a plain endpoint.
142
216
  const detail = err instanceof HostControlError ? err.message : err.message;
143
217
  console.log(`[host-control] catalog read fell back to /v1/models floor: ${detail}`);
144
218
  }
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/host-control/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,6BAA6B,EAC7B,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,sFAAsF;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AAEzE;;;GAGG;AACH,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAEjD;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAU,CAAC;AAE1F,kFAAkF;AAClF,SAAS,WAAW,CAAC,GAA4B,EAAE,IAAuB;IACxE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,GAAG,CAAC,GAA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AAC;YACtB,MAAM,OAAO,GAAoB,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;YAC9F,4EAA4E;YAC5E,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACxC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,0EAA0E;QAC1E,6EAA6E;QAC7E,mEAAmE;IACrE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,wEAAwE;QACxE,0EAA0E;QAC1E,oEAAoE;QACpE,+CAA+C;QAC/C,IAAI,GAAG,YAAY,gBAAgB,IAAI,GAAG,CAAC,SAAS,KAAK,8BAA8B,EAAE,CAAC;YACxF,MAAM,MAAM,GAAG,4BAA4B,CAAC,IAAI,CAAC,CAAC;YAClD,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CACT,8FAA8F,IAAI,EAAE,CACrG,CAAC;gBACF,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,2EAA2E;QAC3E,2DAA2D;QAC3D,MAAM,MAAM,GAAG,GAAG,YAAY,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAE,GAAa,CAAC,OAAO,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,8DAA8D,MAAM,EAAE,CAAC,CAAC;IACtF,CAAC;IACD,wEAAwE;IACxE,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
@@ -13,6 +13,8 @@ export { detectHostCapability, isControllableCatalogPayload } from './capability
13
13
  export { readLoadableCatalog, normalizeLocalCatalog, HOST_CONTROL_CATALOG_PATH, } from './catalog.js';
14
14
  export { loadModel, unloadModel, getStatus, resolveModelPath, decideSwap, ensureLoaded, normalizeStatus, DEFAULT_MAX_SEQ_LENGTH, HOST_CONTROL_LOAD_PATH, HOST_CONTROL_UNLOAD_PATH, HOST_CONTROL_STATUS_PATH, HOST_CONTROL_LOAD_READY_TIMEOUT_MS, HOST_CONTROL_LOAD_POLL_INTERVAL_MS, HOST_CONTROL_ERROR_LOAD_TIMEOUT, } from './load.js';
15
15
  export type { EnsureLoadedOptions } from './load.js';
16
+ export { observeHostSwap, claimResidentHost, releaseHostByFocus, hostSwapKey, __resetHostSwapManager, } from './swap-manager.js';
17
+ export type { HostSwapObservation, HostSwapPhase } from './swap-manager.js';
16
18
  export { getHardware, getKvCacheEstimate, normalizeHardware, normalizeKvCacheEstimate, computeSafeMaxSeqLength, resolveSafeLoadOptions, CODEX_TURN1_FLOOR, VRAM_SAFETY_MARGIN_MB, KV_CACHE_MB_PER_TOKEN, KV_QUANT_FOOTPRINT_FACTOR, KV_QUANT_CACHE_TYPE, MAX_SEQ_LENGTH_CEILING, HOST_CONTROL_HARDWARE_PATH, HOST_CONTROL_KV_CACHE_PATH, } from './sizing.js';
17
19
  export type { SafeLoadSizingHints } from './sizing.js';
18
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host-control/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,UAAU,EACV,eAAe,EACf,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,+BAA+B,EAC/B,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host-control/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,UAAU,EACV,eAAe,EACf,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,+BAA+B,EAC/B,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -10,5 +10,6 @@ export { hostGet, hostPost, hostRootFromBaseUrl, HostControlError, HOST_CONTROL_
10
10
  export { detectHostCapability, isControllableCatalogPayload } from './capability.js';
11
11
  export { readLoadableCatalog, normalizeLocalCatalog, HOST_CONTROL_CATALOG_PATH, } from './catalog.js';
12
12
  export { loadModel, unloadModel, getStatus, resolveModelPath, decideSwap, ensureLoaded, normalizeStatus, DEFAULT_MAX_SEQ_LENGTH, HOST_CONTROL_LOAD_PATH, HOST_CONTROL_UNLOAD_PATH, HOST_CONTROL_STATUS_PATH, HOST_CONTROL_LOAD_READY_TIMEOUT_MS, HOST_CONTROL_LOAD_POLL_INTERVAL_MS, HOST_CONTROL_ERROR_LOAD_TIMEOUT, } from './load.js';
13
+ export { observeHostSwap, claimResidentHost, releaseHostByFocus, hostSwapKey, __resetHostSwapManager, } from './swap-manager.js';
13
14
  export { getHardware, getKvCacheEstimate, normalizeHardware, normalizeKvCacheEstimate, computeSafeMaxSeqLength, resolveSafeLoadOptions, CODEX_TURN1_FLOOR, VRAM_SAFETY_MARGIN_MB, KV_CACHE_MB_PER_TOKEN, KV_QUANT_FOOTPRINT_FACTOR, KV_QUANT_CACHE_TYPE, MAX_SEQ_LENGTH_CEILING, HOST_CONTROL_HARDWARE_PATH, HOST_CONTROL_KV_CACHE_PATH, } from './sizing.js';
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host-control/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,OAAO,EACL,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,+BAA+B,EAC/B,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host-control/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,OAAO,EACL,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,+BAA+B,EAC/B,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kCAAkC,EAClC,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,aAAa,CAAC"}
@@ -44,17 +44,19 @@ export declare const DEFAULT_MAX_SEQ_LENGTH = 16384;
44
44
  */
45
45
  export declare const HOST_CONTROL_LOAD_READY_TIMEOUT_MS = 180000;
46
46
  /**
47
- * Timeout (ms) for the `POST /v1/load` request ITSELF. Some hosts block the
48
- * `/v1/load` response until the cold load completes (e.g. a 12B GGUF swap on a
49
- * single GPU takes well over 5s); inheriting the generic 5s
50
- * `HOST_CONTROL_FETCH_TIMEOUT_MS` would abort that POST before the
51
- * `/v1/status` readiness poll is ever reached, so the swap is skipped and the
52
- * daemon deadlocks in a spawn-retry loop. We give the load POST its own budget
53
- * sized to the readiness budget so a synchronously-loading host runs the load
54
- * to completion; the `/v1/status` poll -- NOT this POST -- remains the real
55
- * ceiling. Operators may override via `TELORA_HOST_CONTROL_LOAD_TIMEOUT_MS`
56
- * (declared in `@telora/daemon-core`'s env-config); the value is plumbed in by
57
- * the caller (focus-executor) and this constant is the in-code default.
47
+ * Timeout (ms) for the model-MUTATION POSTs themselves -- both `POST /v1/load`
48
+ * AND `POST /v1/unload`. Some hosts block the response until the cold load (or
49
+ * the evict) completes (e.g. a 12B GGUF swap on a single GPU takes well over
50
+ * 5s); inheriting the generic 5s `HOST_CONTROL_FETCH_TIMEOUT_MS` would abort the
51
+ * POST before the `/v1/status` readiness poll is ever reached, so the swap is
52
+ * skipped and the daemon deadlocks in a spawn-retry loop. The evict_then_load
53
+ * path has the SAME failure mode on the unload POST, so both mutation POSTs use
54
+ * this budget. We size it to the readiness budget so a synchronously-loading
55
+ * host runs the operation to completion; the `/v1/status` poll -- NOT these
56
+ * POSTs -- remains the real ceiling. Operators may override via
57
+ * `TELORA_HOST_CONTROL_LOAD_TIMEOUT_MS` (declared in `@telora/daemon-core`'s
58
+ * env-config); the value is plumbed in by the caller (focus-executor) and this
59
+ * constant is the in-code default.
58
60
  */
59
61
  export declare const HOST_CONTROL_LOAD_POST_TIMEOUT_MS = 180000;
60
62
  /** Interval between `/v1/status` readiness polls while waiting for a load. */
@@ -83,18 +85,56 @@ export declare function normalizeStatus(payload: unknown): HostStatus;
83
85
  * `HostControlError` on any failure.
84
86
  */
85
87
  export declare function loadModel(baseUrl: string, params: LoadModelParams, apiKey?: string | null, loadTimeoutMs?: number): Promise<void>;
86
- /** Issue an unload (`POST /v1/unload`) -- evicts whatever is currently resident. */
87
- export declare function unloadModel(baseUrl: string, apiKey?: string | null): Promise<void>;
88
+ /**
89
+ * Issue an unload (`POST /v1/unload`) -- evicts whatever is currently resident.
90
+ * `unloadTimeoutMs` bounds the POST itself. A host that blocks `/v1/unload`
91
+ * until the eviction completes can take well over the generic 5s fetch timeout
92
+ * for a large model (a 12B GGUF evict), so this defaults to the same load-scoped
93
+ * `HOST_CONTROL_LOAD_POST_TIMEOUT_MS` as `loadModel` rather than the 5s default;
94
+ * otherwise the evict_then_load path aborts mid-evict and the daemon re-enters
95
+ * the same spawn-retry deadlock the load-scoped timeout exists to prevent.
96
+ * Throws `HostControlError` on any failure.
97
+ */
98
+ export declare function unloadModel(baseUrl: string, apiKey?: string | null, unloadTimeoutMs?: number): Promise<void>;
88
99
  /** Read current host status (`GET /v1/status`), normalized to a typed shape. */
89
100
  export declare function getStatus(baseUrl: string, apiKey?: string | null): Promise<HostStatus>;
90
101
  /**
91
- * Resolve a chosen local_models `model` id to the host's `model_path` by reading
92
- * the loadable catalog (D1) and matching by id. Returns null when the host is
93
- * not controllable, the id is not in the catalog, or the matching entry carries
94
- * no modelPath (a floor entry). The caller treats null as "cannot load" and
95
- * skips the swap.
102
+ * Resolve a chosen local_models `model` id to the host's `/v1/load` target by
103
+ * reading the loadable catalog (D1) and matching by id.
104
+ *
105
+ * - A matching entry that carries a real `modelPath` -> that path (the original
106
+ * contract; a llama.cpp-family host serving an on-disk gguf path).
107
+ * - A matching entry with NO usable `modelPath` on a CONTROLLABLE host -> the
108
+ * entry id itself. On the Unsloth control surface the entry id IS the HF repo
109
+ * id, which `/v1/load` accepts as `model_path` (HTTP 200), whereas the entry's
110
+ * `path` is a non-loadable HF-cache snapshot dir (dropped to null in
111
+ * `normalizeLocalCatalog`). Falling back to the id is what lets the swap load.
112
+ * - No match, or a path-less match on the `/v1/models` FLOOR (non-controllable)
113
+ * host -> null. On the floor the id is only the loaded model name, never a
114
+ * load target, so the caller still treats null as "cannot load" and skips the
115
+ * swap exactly as before.
96
116
  */
97
117
  export declare function resolveModelPath(baseUrl: string, modelId: string, apiKey?: string | null): Promise<string | null>;
118
+ /**
119
+ * Strip a single leading `<org>/` segment from a model id. Hosts disagree on id
120
+ * FORM: the registry / `/v1/models` catalog reports an org-prefixed id
121
+ * (`yuxinlu1/gemma-4-12B-agentic-...`) while `/v1/status` (and the Unsloth
122
+ * Studio UI) report the SAME loaded model unprefixed (`gemma-4-12B-agentic-...`).
123
+ * We strip exactly ONE leading segment up to and including the first `/`; an id
124
+ * with no `/` is returned unchanged. Pure + exported for unit testing.
125
+ */
126
+ export declare function stripModelOrgPrefix(id: string): string;
127
+ /**
128
+ * Compare two model ids tolerantly across the org-prefix discrepancy between a
129
+ * host's endpoints (see `stripModelOrgPrefix`). Matches when the ids are equal
130
+ * raw, OR when one equals the other with a single leading `<org>/` stripped
131
+ * (the incident shape: `/v1/status` reports `gemma-...` while the registry holds
132
+ * `yuxinlu1/gemma-...`). Deliberately NOT a both-sides-stripped compare, so two
133
+ * genuinely different org-prefixed models with the same basename
134
+ * (`orgA/model` vs `orgB/model`) do NOT false-positive as resident. Pure +
135
+ * exported for unit testing the resident-recognition boundary.
136
+ */
137
+ export declare function modelIdsMatch(a: string, b: string): boolean;
98
138
  /**
99
139
  * PURE swap decision over the current vs target resident model. Extracted from
100
140
  * `ensureLoaded` so the core single-GPU swap logic is unit-testable with NO HTTP:
@@ -107,6 +147,8 @@ export declare function resolveModelPath(baseUrl: string, modelId: string, apiKe
107
147
  * `current.ready` gates the noop (a resident-but-not-ready target still needs a
108
148
  * poll, but no reload -- treated as 'load' here so `ensureLoaded` re-issues +
109
149
  * polls; the host treats a load of the resident model as a fast no-op/confirm).
150
+ * Resident recognition uses `modelIdsMatch` so an org-prefix difference between
151
+ * the registry id (target) and the `/v1/status` id (current) still no-ops.
110
152
  */
111
153
  export declare function decideSwap(input: {
112
154
  current: {
@@ -128,9 +170,12 @@ export interface EnsureLoadedOptions {
128
170
  /** Override the ready-poll interval (ms). Defaults to the module constant. */
129
171
  pollIntervalMs?: number;
130
172
  /**
131
- * Override the timeout (ms) for the `POST /v1/load` request itself. Defaults
132
- * to `HOST_CONTROL_LOAD_POST_TIMEOUT_MS` so a synchronously-loading host is
133
- * not cut at the generic 5s fetch timeout before readiness polling begins.
173
+ * Override the timeout (ms) for the model-MUTATION POSTs -- both `POST /v1/load`
174
+ * AND the `POST /v1/unload` issued on the evict_then_load path. Defaults to
175
+ * `HOST_CONTROL_LOAD_POST_TIMEOUT_MS` so a synchronously-loading/evicting host
176
+ * is not cut at the generic 5s fetch timeout before readiness polling begins.
177
+ * A slow evict has the same 5s-abort failure mode as a slow load, so both
178
+ * mutation POSTs share this load-scoped budget.
134
179
  */
135
180
  loadTimeoutMs?: number;
136
181
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/host-control/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAc,YAAY,EAAE,MAAM,YAAY,CAAC;AAExF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAC9C,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAClD,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,SAAU,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iCAAiC,SAAqC,CAAC;AAEpF,8EAA8E;AAC9E,eAAO,MAAM,kCAAkC,OAAQ,CAAC;AAExD,mFAAmF;AACnF,eAAO,MAAM,+BAA+B,0CAA0C,CAAC;AAoCvF;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAA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;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,mBAAwB,EAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,IAAI,CAAC,CA8Df"}
@@ -45,17 +45,19 @@ export const DEFAULT_MAX_SEQ_LENGTH = 16384;
45
45
  */
46
46
  export const HOST_CONTROL_LOAD_READY_TIMEOUT_MS = 180_000;
47
47
  /**
48
- * Timeout (ms) for the `POST /v1/load` request ITSELF. Some hosts block the
49
- * `/v1/load` response until the cold load completes (e.g. a 12B GGUF swap on a
50
- * single GPU takes well over 5s); inheriting the generic 5s
51
- * `HOST_CONTROL_FETCH_TIMEOUT_MS` would abort that POST before the
52
- * `/v1/status` readiness poll is ever reached, so the swap is skipped and the
53
- * daemon deadlocks in a spawn-retry loop. We give the load POST its own budget
54
- * sized to the readiness budget so a synchronously-loading host runs the load
55
- * to completion; the `/v1/status` poll -- NOT this POST -- remains the real
56
- * ceiling. Operators may override via `TELORA_HOST_CONTROL_LOAD_TIMEOUT_MS`
57
- * (declared in `@telora/daemon-core`'s env-config); the value is plumbed in by
58
- * the caller (focus-executor) and this constant is the in-code default.
48
+ * Timeout (ms) for the model-MUTATION POSTs themselves -- both `POST /v1/load`
49
+ * AND `POST /v1/unload`. Some hosts block the response until the cold load (or
50
+ * the evict) completes (e.g. a 12B GGUF swap on a single GPU takes well over
51
+ * 5s); inheriting the generic 5s `HOST_CONTROL_FETCH_TIMEOUT_MS` would abort the
52
+ * POST before the `/v1/status` readiness poll is ever reached, so the swap is
53
+ * skipped and the daemon deadlocks in a spawn-retry loop. The evict_then_load
54
+ * path has the SAME failure mode on the unload POST, so both mutation POSTs use
55
+ * this budget. We size it to the readiness budget so a synchronously-loading
56
+ * host runs the operation to completion; the `/v1/status` poll -- NOT these
57
+ * POSTs -- remains the real ceiling. Operators may override via
58
+ * `TELORA_HOST_CONTROL_LOAD_TIMEOUT_MS` (declared in `@telora/daemon-core`'s
59
+ * env-config); the value is plumbed in by the caller (focus-executor) and this
60
+ * constant is the in-code default.
59
61
  */
60
62
  export const HOST_CONTROL_LOAD_POST_TIMEOUT_MS = HOST_CONTROL_LOAD_READY_TIMEOUT_MS;
61
63
  /** Interval between `/v1/status` readiness polls while waiting for a load. */
@@ -153,9 +155,21 @@ export async function loadModel(baseUrl, params, apiKey, loadTimeoutMs = HOST_CO
153
155
  timeoutMs: loadTimeoutMs,
154
156
  });
155
157
  }
156
- /** Issue an unload (`POST /v1/unload`) -- evicts whatever is currently resident. */
157
- export async function unloadModel(baseUrl, apiKey) {
158
- await hostPost(controlUrl(baseUrl, HOST_CONTROL_UNLOAD_PATH), {}, { apiKey });
158
+ /**
159
+ * Issue an unload (`POST /v1/unload`) -- evicts whatever is currently resident.
160
+ * `unloadTimeoutMs` bounds the POST itself. A host that blocks `/v1/unload`
161
+ * until the eviction completes can take well over the generic 5s fetch timeout
162
+ * for a large model (a 12B GGUF evict), so this defaults to the same load-scoped
163
+ * `HOST_CONTROL_LOAD_POST_TIMEOUT_MS` as `loadModel` rather than the 5s default;
164
+ * otherwise the evict_then_load path aborts mid-evict and the daemon re-enters
165
+ * the same spawn-retry deadlock the load-scoped timeout exists to prevent.
166
+ * Throws `HostControlError` on any failure.
167
+ */
168
+ export async function unloadModel(baseUrl, apiKey, unloadTimeoutMs = HOST_CONTROL_LOAD_POST_TIMEOUT_MS) {
169
+ await hostPost(controlUrl(baseUrl, HOST_CONTROL_UNLOAD_PATH), {}, {
170
+ apiKey,
171
+ timeoutMs: unloadTimeoutMs,
172
+ });
159
173
  }
160
174
  /** Read current host status (`GET /v1/status`), normalized to a typed shape. */
161
175
  export async function getStatus(baseUrl, apiKey) {
@@ -163,16 +177,55 @@ export async function getStatus(baseUrl, apiKey) {
163
177
  return normalizeStatus(payload);
164
178
  }
165
179
  /**
166
- * Resolve a chosen local_models `model` id to the host's `model_path` by reading
167
- * the loadable catalog (D1) and matching by id. Returns null when the host is
168
- * not controllable, the id is not in the catalog, or the matching entry carries
169
- * no modelPath (a floor entry). The caller treats null as "cannot load" and
170
- * skips the swap.
180
+ * Resolve a chosen local_models `model` id to the host's `/v1/load` target by
181
+ * reading the loadable catalog (D1) and matching by id.
182
+ *
183
+ * - A matching entry that carries a real `modelPath` -> that path (the original
184
+ * contract; a llama.cpp-family host serving an on-disk gguf path).
185
+ * - A matching entry with NO usable `modelPath` on a CONTROLLABLE host -> the
186
+ * entry id itself. On the Unsloth control surface the entry id IS the HF repo
187
+ * id, which `/v1/load` accepts as `model_path` (HTTP 200), whereas the entry's
188
+ * `path` is a non-loadable HF-cache snapshot dir (dropped to null in
189
+ * `normalizeLocalCatalog`). Falling back to the id is what lets the swap load.
190
+ * - No match, or a path-less match on the `/v1/models` FLOOR (non-controllable)
191
+ * host -> null. On the floor the id is only the loaded model name, never a
192
+ * load target, so the caller still treats null as "cannot load" and skips the
193
+ * swap exactly as before.
171
194
  */
172
195
  export async function resolveModelPath(baseUrl, modelId, apiKey) {
173
196
  const catalog = await readLoadableCatalog(baseUrl, apiKey);
174
197
  const match = catalog.models.find((m) => m.id === modelId);
175
- return match?.modelPath ?? null;
198
+ if (!match)
199
+ return null;
200
+ if (match.modelPath)
201
+ return match.modelPath;
202
+ // Path-less entry: fall back to the repo id only when the host is controllable.
203
+ return catalog.controllable ? match.id : null;
204
+ }
205
+ /**
206
+ * Strip a single leading `<org>/` segment from a model id. Hosts disagree on id
207
+ * FORM: the registry / `/v1/models` catalog reports an org-prefixed id
208
+ * (`yuxinlu1/gemma-4-12B-agentic-...`) while `/v1/status` (and the Unsloth
209
+ * Studio UI) report the SAME loaded model unprefixed (`gemma-4-12B-agentic-...`).
210
+ * We strip exactly ONE leading segment up to and including the first `/`; an id
211
+ * with no `/` is returned unchanged. Pure + exported for unit testing.
212
+ */
213
+ export function stripModelOrgPrefix(id) {
214
+ const slash = id.indexOf('/');
215
+ return slash === -1 ? id : id.slice(slash + 1);
216
+ }
217
+ /**
218
+ * Compare two model ids tolerantly across the org-prefix discrepancy between a
219
+ * host's endpoints (see `stripModelOrgPrefix`). Matches when the ids are equal
220
+ * raw, OR when one equals the other with a single leading `<org>/` stripped
221
+ * (the incident shape: `/v1/status` reports `gemma-...` while the registry holds
222
+ * `yuxinlu1/gemma-...`). Deliberately NOT a both-sides-stripped compare, so two
223
+ * genuinely different org-prefixed models with the same basename
224
+ * (`orgA/model` vs `orgB/model`) do NOT false-positive as resident. Pure +
225
+ * exported for unit testing the resident-recognition boundary.
226
+ */
227
+ export function modelIdsMatch(a, b) {
228
+ return a === b || stripModelOrgPrefix(a) === b || a === stripModelOrgPrefix(b);
176
229
  }
177
230
  /**
178
231
  * PURE swap decision over the current vs target resident model. Extracted from
@@ -186,11 +239,13 @@ export async function resolveModelPath(baseUrl, modelId, apiKey) {
186
239
  * `current.ready` gates the noop (a resident-but-not-ready target still needs a
187
240
  * poll, but no reload -- treated as 'load' here so `ensureLoaded` re-issues +
188
241
  * polls; the host treats a load of the resident model as a fast no-op/confirm).
242
+ * Resident recognition uses `modelIdsMatch` so an org-prefix difference between
243
+ * the registry id (target) and the `/v1/status` id (current) still no-ops.
189
244
  */
190
245
  export function decideSwap(input) {
191
246
  const { current, target } = input;
192
247
  let action;
193
- if (current.modelId === target) {
248
+ if (current.modelId !== null && modelIdsMatch(current.modelId, target)) {
194
249
  action = current.ready ? 'noop' : 'load';
195
250
  }
196
251
  else if (current.modelId !== null) {
@@ -234,7 +289,9 @@ export async function ensureLoaded(baseUrl, modelId, opts = {}, apiKey) {
234
289
  if (decision.action === 'noop')
235
290
  return;
236
291
  if (decision.action === 'evict_then_load') {
237
- await unloadModel(baseUrl, apiKey);
292
+ // Same load-scoped budget as the load POST: a slow evict on a synchronously-
293
+ // evicting host must not be cut at the generic 5s fetch timeout.
294
+ await unloadModel(baseUrl, apiKey, loadTimeoutMs);
238
295
  }
239
296
  const modelPath = await resolveModelPath(baseUrl, modelId, apiKey);
240
297
  if (!modelPath) {
@@ -252,8 +309,12 @@ export async function ensureLoaded(baseUrl, modelId, opts = {}, apiKey) {
252
309
  const deadline = now() + readyTimeoutMs;
253
310
  for (;;) {
254
311
  const polled = await getStatus(baseUrl, apiKey);
255
- if (polled.loadedModelId === modelId && polled.ready)
312
+ // Org-prefix-tolerant match: `/v1/status` may report the loaded id unprefixed
313
+ // while `modelId` (the registry id) carries the `<org>/` prefix -- an exact
314
+ // compare here would never resolve and the poll would always time out.
315
+ if (polled.loadedModelId !== null && modelIdsMatch(polled.loadedModelId, modelId) && polled.ready) {
256
316
  return;
317
+ }
257
318
  if (now() >= deadline) {
258
319
  throw new HostControlError(`Model "${modelId}" did not reach ready within ${readyTimeoutMs}ms`, HOST_CONTROL_ERROR_LOAD_TIMEOUT);
259
320
  }
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/host-control/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAClD,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MA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,CAChC,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC,cAAc,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -25,6 +25,18 @@
25
25
  * "no sizing data" and falls back to the fixed floor default, never breaking a
26
26
  * swap that previously worked.
27
27
  */
28
+ /**
29
+ * Timeout (ms) for the sizing reads (`/api/system/hardware`,
30
+ * `/api/models/kv-cache-estimate`). These inherited the generic 5s
31
+ * `HOST_CONTROL_FETCH_TIMEOUT_MS`, but a host that is BUSY cold-loading a model
32
+ * (exactly when a swap sizes the next load) can take longer than 5s to answer a
33
+ * hardware query -- so the read timed out and `resolveSafeLoadOptions` fell back
34
+ * to the fixed 16384 default, reporting sizing "unavailable" on a host that
35
+ * actually exposes it. A tolerant budget removes that false fallback. The read
36
+ * is still best-effort: a genuine miss (endpoint absent / unsupported) returns
37
+ * fast (4xx) and degrades safely to the fixed default.
38
+ */
39
+ export declare const HOST_CONTROL_SIZING_TIMEOUT_MS = 15000;
28
40
  import type { HostHardware, KvCacheEstimate, KvCacheEstimateParams, SafeMaxSeqInput, SafeMaxSeqResult } from './types.js';
29
41
  /**
30
42
  * The control-surface path (under the host ROOT, not `/v1`) for GPU hardware
@@ -1 +1 @@
1
- {"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../src/host-control/sizing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE1H;;;GAGG;AACH,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,0BAA0B,kCAAkC,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;;;;;;;;;;;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