@mlx-node/server 0.0.9 → 0.0.12

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/dist/chat-session-warm-reuse.d.ts +10 -12
  2. package/dist/chat-session-warm-reuse.d.ts.map +1 -1
  3. package/dist/chat-session-warm-reuse.js +10 -12
  4. package/dist/endpoints/messages.d.ts +2 -2
  5. package/dist/endpoints/messages.d.ts.map +1 -1
  6. package/dist/endpoints/messages.js +492 -349
  7. package/dist/endpoints/responses.d.ts +1 -1
  8. package/dist/endpoints/responses.d.ts.map +1 -1
  9. package/dist/endpoints/responses.js +1149 -1055
  10. package/dist/handler.d.ts.map +1 -1
  11. package/dist/handler.js +1 -1
  12. package/dist/health.d.ts +4 -6
  13. package/dist/health.d.ts.map +1 -1
  14. package/dist/host/discover.d.ts +1 -2
  15. package/dist/host/discover.d.ts.map +1 -1
  16. package/dist/host/discover.js +3 -6
  17. package/dist/host/index.d.ts +6 -1
  18. package/dist/host/index.d.ts.map +1 -1
  19. package/dist/host/index.js +3 -2
  20. package/dist/index.d.ts +2 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -9
  23. package/dist/mappers/anthropic-request.d.ts.map +1 -1
  24. package/dist/mappers/anthropic-request.js +5 -1
  25. package/dist/mappers/request.d.ts +12 -2
  26. package/dist/mappers/request.d.ts.map +1 -1
  27. package/dist/mappers/request.js +26 -2
  28. package/dist/model-work-coordinator.d.ts +50 -0
  29. package/dist/model-work-coordinator.d.ts.map +1 -1
  30. package/dist/model-work-coordinator.js +161 -0
  31. package/dist/registry.d.ts +15 -0
  32. package/dist/registry.d.ts.map +1 -1
  33. package/dist/registry.js +51 -0
  34. package/dist/server.d.ts +21 -3
  35. package/dist/server.d.ts.map +1 -1
  36. package/dist/server.js +30 -6
  37. package/dist/session-registry.d.ts +266 -86
  38. package/dist/session-registry.d.ts.map +1 -1
  39. package/dist/session-registry.js +421 -107
  40. package/dist/streaming.d.ts +37 -2
  41. package/dist/streaming.d.ts.map +1 -1
  42. package/dist/streaming.js +122 -1
  43. package/dist/transport-visibility.d.ts +5 -4
  44. package/dist/transport-visibility.d.ts.map +1 -1
  45. package/dist/transport-visibility.js +5 -4
  46. package/dist/types-anthropic.d.ts +7 -0
  47. package/dist/types-anthropic.d.ts.map +1 -1
  48. package/dist/types.d.ts +9 -0
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +4 -4
  51. package/dist/presets.d.ts +0 -82
  52. package/dist/presets.d.ts.map +0 -1
  53. package/dist/presets.js +0 -98
@@ -7,19 +7,17 @@
7
7
  * and nothing re-exports it. Callers are the two server endpoints —
8
8
  * `endpoints/responses.ts` (tier-1 / tier-2 HIT branch) and
9
9
  * `endpoints/messages.ts` (`getOrCreateWarmAny` HIT branch) — each
10
- * invoking the helper exclusively under a `SessionRegistry` HIT gate.
10
+ * invoking the helper only when native cache reuse is authorized: either a
11
+ * `SessionRegistry` hit or a block-paged model whose allocator validates
12
+ * reusable prefixes by content hash and isolates live cache owners.
11
13
  *
12
- * Why this helper exists at all: `ChatSession.reset()` is the safe
13
- * public wipeit always calls `model.resetCaches()` because the
14
- * underlying `SessionCapableModel` is shared across every session
15
- * lifetime via the native `ModelRegistry`. A partial wipe that leaves
16
- * the shared native KV cache intact without the HIT gate would leak a
17
- * previous (unrelated) request's cached prefix into the next
18
- * `chat_session_start_sync` call. The server's warm-lease replay path
19
- * DOES have that HIT gate — the registry's own `getOrCreate` hit
20
- * signal is the authoritative proof that the native cache genuinely
21
- * belongs to this chain — so a JS-state-only reset that preserves the
22
- * native cache is correct there and only there.
14
+ * Why this helper exists at all: public `ChatSession.reset()` invalidates the
15
+ * current session's native state owner-scoped on block-paged models and
16
+ * model-wide on exclusive/flat models. A warm registry HIT instead needs to
17
+ * preserve the already-authorized native prefix while clearing only the JS
18
+ * conversation wrapper. Warm leases provide the ownership gate; block-paged
19
+ * adapters provide the content-verification gate. A JS-state-only reset is
20
+ * valid in either case.
23
21
  *
24
22
  * Fields accessed: `inFlight`, `history`, `lastImagesKey`, `lastAudioKey`, `turnCount`,
25
23
  * `unresolvedOkToolCallCount`, `needsFullReplay`, `defaultConfig`, `activeTools`.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-warm-reuse.d.ts","sourceRoot":"","sources":["../src/chat-session-warm-reuse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAc,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAqBjF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sCAAsC,CAAC,CAAC,SAAS,mBAAmB,EACxF,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
1
+ {"version":3,"file":"chat-session-warm-reuse.d.ts","sourceRoot":"","sources":["../src/chat-session-warm-reuse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAc,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAqBjF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sCAAsC,CAAC,CAAC,SAAS,mBAAmB,EACxF,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -7,19 +7,17 @@
7
7
  * and nothing re-exports it. Callers are the two server endpoints —
8
8
  * `endpoints/responses.ts` (tier-1 / tier-2 HIT branch) and
9
9
  * `endpoints/messages.ts` (`getOrCreateWarmAny` HIT branch) — each
10
- * invoking the helper exclusively under a `SessionRegistry` HIT gate.
10
+ * invoking the helper only when native cache reuse is authorized: either a
11
+ * `SessionRegistry` hit or a block-paged model whose allocator validates
12
+ * reusable prefixes by content hash and isolates live cache owners.
11
13
  *
12
- * Why this helper exists at all: `ChatSession.reset()` is the safe
13
- * public wipeit always calls `model.resetCaches()` because the
14
- * underlying `SessionCapableModel` is shared across every session
15
- * lifetime via the native `ModelRegistry`. A partial wipe that leaves
16
- * the shared native KV cache intact without the HIT gate would leak a
17
- * previous (unrelated) request's cached prefix into the next
18
- * `chat_session_start_sync` call. The server's warm-lease replay path
19
- * DOES have that HIT gate — the registry's own `getOrCreate` hit
20
- * signal is the authoritative proof that the native cache genuinely
21
- * belongs to this chain — so a JS-state-only reset that preserves the
22
- * native cache is correct there and only there.
14
+ * Why this helper exists at all: public `ChatSession.reset()` invalidates the
15
+ * current session's native state owner-scoped on block-paged models and
16
+ * model-wide on exclusive/flat models. A warm registry HIT instead needs to
17
+ * preserve the already-authorized native prefix while clearing only the JS
18
+ * conversation wrapper. Warm leases provide the ownership gate; block-paged
19
+ * adapters provide the content-verification gate. A JS-state-only reset is
20
+ * valid in either case.
23
21
  *
24
22
  * Fields accessed: `inFlight`, `history`, `lastImagesKey`, `lastAudioKey`, `turnCount`,
25
23
  * `unresolvedOkToolCallCount`, `needsFullReplay`, `defaultConfig`, `activeTools`.
@@ -31,7 +31,7 @@
31
31
  * * **Non-paged path** (Qwen3.5 dense + MoE — default-off pending a
32
32
  * perf decision; the Qianfan-OCR VLM — no adapter wired). Each
33
33
  * request looks up the warm slot via
34
- * `SessionRegistry.getOrCreateWarmAny(requestedSystem)`. On a
34
+ * `SessionRegistry.getOrCreateWarmAny(requestedSystem, cacheSalt)`. On a
35
35
  * HIT we keep the underlying native KV cache alive
36
36
  * (`resetPreservingNativeCacheForWarmReuse` wipes only JS-side
37
37
  * session state) so the native `verify_cache_prefix_direct` can
@@ -58,7 +58,7 @@
58
58
  */
59
59
  import type { IncomingMessage, ServerResponse } from 'node:http';
60
60
  import type { IdleSweeper } from '../idle-sweeper.js';
61
- import type { ModelWorkCoordinator } from '../model-work-coordinator.js';
61
+ import { type ModelWorkCoordinator } from '../model-work-coordinator.js';
62
62
  import type { ModelRegistry } from '../registry.js';
63
63
  import type { AnthropicMessagesRequest } from '../types-anthropic.js';
64
64
  export declare function handleCreateMessage(res: ServerResponse, body: AnthropicMessagesRequest, registry: ModelRegistry, httpReq?: IncomingMessage, idleSweeper?: IdleSweeper | null, resolveModel?: (name: string) => Promise<void>, modelWorkCoordinator?: ModelWorkCoordinator): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/endpoints/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAajE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgBtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAepD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAg3BtE,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,wBAAwB,EAC9B,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,EAChC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC9C,oBAAoB,CAAC,EAAE,oBAAoB,GAC1C,OAAO,CAAC,IAAI,CAAC,CAioBf"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/endpoints/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAajE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgBtD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAsBpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AA64BtE,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,wBAAwB,EAC9B,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,EAChC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC9C,oBAAoB,CAAC,EAAE,oBAAoB,GAC1C,OAAO,CAAC,IAAI,CAAC,CAiwBf"}