@bendyline/gezel-inference 1.0.5 → 1.0.7

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 (144) hide show
  1. package/dist/cache/controller.d.ts +2 -0
  2. package/dist/cache/controller.js +38 -5
  3. package/dist/catalog/chat-models/index.json +1 -1
  4. package/dist/catalog/chat-models/lf/lfm3-1.7b-q4/manifest.json +114 -0
  5. package/dist/catalog/chat-models/lf/lfm3-1.7b-q4/versions/1.0.0/manifest.json +15 -0
  6. package/dist/catalog/chat-models/raw-index.json +1 -1
  7. package/dist/catalog/image-loras/index.json +1 -0
  8. package/dist/catalog/image-loras/kr/krea-2-ink-wash/manifest.json +31 -0
  9. package/dist/catalog/image-loras/kr/krea-2-ink-wash/versions/1.0.0/manifest.json +15 -0
  10. package/dist/catalog/image-loras/kr/krea-2-isometric-3d/manifest.json +32 -0
  11. package/dist/catalog/image-loras/kr/krea-2-isometric-3d/versions/1.0.0/manifest.json +15 -0
  12. package/dist/catalog/image-loras/kr/krea-2-kids-drawing/manifest.json +31 -0
  13. package/dist/catalog/image-loras/kr/krea-2-kids-drawing/versions/1.0.0/manifest.json +15 -0
  14. package/dist/catalog/image-loras/kr/krea-2-pixel-art/manifest.json +31 -0
  15. package/dist/catalog/image-loras/kr/krea-2-pixel-art/versions/1.0.0/manifest.json +15 -0
  16. package/dist/catalog/image-loras/kr/krea-2-soft-watercolor/manifest.json +31 -0
  17. package/dist/catalog/image-loras/kr/krea-2-soft-watercolor/versions/1.0.0/manifest.json +15 -0
  18. package/dist/catalog/image-loras/kr/krea-2-turbo-4step/manifest.json +31 -0
  19. package/dist/catalog/image-loras/kr/krea-2-turbo-4step/versions/1.0.0/manifest.json +15 -0
  20. package/dist/catalog/image-loras/mo/moss-image-gouache/manifest.json +29 -0
  21. package/dist/catalog/image-loras/mo/moss-image-gouache/versions/1.0.0/manifest.json +15 -0
  22. package/dist/catalog/image-loras/mo/moss-image-sft-4step/manifest.json +30 -0
  23. package/dist/catalog/image-loras/mo/moss-image-sft-4step/versions/1.0.0/manifest.json +15 -0
  24. package/dist/catalog/image-loras/qw/qwen-image-edit-2511-lightning/manifest.json +31 -0
  25. package/dist/catalog/image-loras/qw/qwen-image-edit-2511-lightning/versions/1.0.0/manifest.json +15 -0
  26. package/dist/catalog/image-loras/raw-index.json +1 -0
  27. package/dist/catalog/image-loras/sd/sdxl-3d-render/manifest.json +29 -0
  28. package/dist/catalog/image-loras/sd/sdxl-3d-render/versions/1.0.0/manifest.json +15 -0
  29. package/dist/catalog/image-loras/sd/sdxl-coloring-book/manifest.json +30 -0
  30. package/dist/catalog/image-loras/sd/sdxl-coloring-book/versions/1.0.0/manifest.json +15 -0
  31. package/dist/catalog/image-loras/sd/sdxl-papercut/manifest.json +29 -0
  32. package/dist/catalog/image-loras/sd/sdxl-papercut/versions/1.0.0/manifest.json +15 -0
  33. package/dist/catalog/image-loras/sd/sdxl-pixel-art/manifest.json +29 -0
  34. package/dist/catalog/image-loras/sd/sdxl-pixel-art/versions/1.0.0/manifest.json +15 -0
  35. package/dist/catalog/image-models/fl/flux-2-klein-4b-q4/manifest.json +3 -0
  36. package/dist/catalog/image-models/index.json +1 -1
  37. package/dist/catalog/image-models/qw/qwen-image-edit-2511-q4/manifest.json +44 -0
  38. package/dist/catalog/image-models/qw/qwen-image-edit-2511-q4/versions/1.0.0/manifest.json +36 -0
  39. package/dist/catalog/image-models/raw-index.json +1 -1
  40. package/dist/catalog/knowledge-catalogs/index.json +1 -1
  41. package/dist/catalog/knowledge-catalogs/raw-index.json +1 -1
  42. package/dist/catalog/knowledge-catalogs/wi/wikipedia-arts/versions/2026.10.2/manifest.json +181 -0
  43. package/dist/catalog/knowledge-catalogs/wi/wikipedia-astronomy/versions/2026.10.2/manifest.json +181 -0
  44. package/dist/catalog/knowledge-catalogs/wi/wikipedia-biology/versions/2026.10.2/manifest.json +217 -0
  45. package/dist/catalog/knowledge-catalogs/wi/wikipedia-business/versions/2026.10.2/manifest.json +197 -0
  46. package/dist/catalog/knowledge-catalogs/wi/wikipedia-film-tv/versions/2026.10.2/manifest.json +197 -0
  47. package/dist/catalog/knowledge-catalogs/wi/wikipedia-food-drink/versions/2026.10.2/manifest.json +185 -0
  48. package/dist/catalog/knowledge-catalogs/wi/wikipedia-games/versions/2026.10.2/manifest.json +181 -0
  49. package/dist/catalog/knowledge-catalogs/wi/wikipedia-general/manifest.json +55 -0
  50. package/dist/catalog/knowledge-catalogs/wi/wikipedia-general/versions/2026.10.2/manifest.json +165 -0
  51. package/dist/catalog/knowledge-catalogs/wi/wikipedia-geography/versions/2026.10.2/manifest.json +217 -0
  52. package/dist/catalog/knowledge-catalogs/wi/wikipedia-history/versions/2026.10.2/manifest.json +217 -0
  53. package/dist/catalog/knowledge-catalogs/wi/wikipedia-language/versions/2026.10.2/manifest.json +181 -0
  54. package/dist/catalog/knowledge-catalogs/wi/wikipedia-law/versions/2026.10.2/manifest.json +185 -0
  55. package/dist/catalog/knowledge-catalogs/wi/wikipedia-literature/versions/2026.10.2/manifest.json +193 -0
  56. package/dist/catalog/knowledge-catalogs/wi/wikipedia-mathematics/versions/2026.10.2/manifest.json +189 -0
  57. package/dist/catalog/knowledge-catalogs/wi/wikipedia-medicine/versions/2026.10.2/manifest.json +185 -0
  58. package/dist/catalog/knowledge-catalogs/wi/wikipedia-military/versions/2026.10.2/manifest.json +189 -0
  59. package/dist/catalog/knowledge-catalogs/wi/wikipedia-music/versions/2026.10.2/manifest.json +197 -0
  60. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-arts/versions/2026.10.2/manifest.json +209 -0
  61. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-business/versions/2026.10.2/manifest.json +189 -0
  62. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-entertainment/versions/2026.10.2/manifest.json +201 -0
  63. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-military/versions/2026.10.2/manifest.json +185 -0
  64. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-other/versions/2026.10.2/manifest.json +165 -0
  65. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-politics/versions/2026.10.2/manifest.json +197 -0
  66. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-religion/versions/2026.10.2/manifest.json +201 -0
  67. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-science/versions/2026.10.2/manifest.json +205 -0
  68. package/dist/catalog/knowledge-catalogs/wi/wikipedia-people-sports/versions/2026.10.2/manifest.json +237 -0
  69. package/dist/catalog/knowledge-catalogs/wi/wikipedia-politics/versions/2026.10.2/manifest.json +197 -0
  70. package/dist/catalog/knowledge-catalogs/wi/wikipedia-religion-philosophy/versions/2026.10.2/manifest.json +189 -0
  71. package/dist/catalog/knowledge-catalogs/wi/wikipedia-science/versions/2026.10.2/manifest.json +185 -0
  72. package/dist/catalog/knowledge-catalogs/wi/wikipedia-sports/versions/2026.10.2/manifest.json +193 -0
  73. package/dist/catalog/knowledge-catalogs/wi/wikipedia-technology/versions/2026.10.2/manifest.json +185 -0
  74. package/dist/catalog/knowledge-catalogs/wi/wikipedia-transportation/versions/2026.10.2/manifest.json +189 -0
  75. package/dist/catalog/provenance.json +2 -1
  76. package/dist/engine-components.js +2 -2
  77. package/dist/engines/electron-native-reuse.d.ts +7 -1
  78. package/dist/engines/electron-native-reuse.js +12 -4
  79. package/dist/engines/native-file-manifest.json +546 -406
  80. package/dist/engines/native-manifest.d.ts +4 -4
  81. package/dist/engines/native-manifest.js +36 -36
  82. package/dist/engines/resolver.d.ts +1 -1
  83. package/dist/engines/resolver.js +48 -51
  84. package/dist/http/auth-context.d.ts +12 -0
  85. package/dist/http/routes/image-ensure-routes.d.ts +4 -0
  86. package/dist/http/routes/image-ensure-routes.js +102 -0
  87. package/dist/http/routes/v1-image-styles.d.ts +5 -0
  88. package/dist/http/routes/v1-image-styles.js +91 -0
  89. package/dist/http/routes/v1-images.d.ts +1 -0
  90. package/dist/http/routes/v1-images.js +15 -93
  91. package/dist/inference-service.js +2 -1
  92. package/dist/knowledge/worker-host.js +2 -0
  93. package/dist/machine-engine/inspect-runtime.js +12 -3
  94. package/dist/memory/embed-core.js +3 -0
  95. package/dist/memory/embeddings.js +2 -0
  96. package/dist/models/image-fit.js +2 -2
  97. package/dist/models/weight-facts.d.ts +5 -0
  98. package/dist/models/weight-facts.js +5 -2
  99. package/dist/providers/ds4/build-provider.js +1 -1
  100. package/dist/providers/ds4/residency.js +3 -3
  101. package/dist/providers/image/img2img-support.d.ts +36 -1
  102. package/dist/providers/image/img2img-support.js +30 -1
  103. package/dist/providers/image/local-engine.d.ts +1 -0
  104. package/dist/providers/image/local-engine.js +8 -2
  105. package/dist/providers/image/local-factory.d.ts +10 -1
  106. package/dist/providers/image/local-factory.js +33 -6
  107. package/dist/providers/image/mock.d.ts +8 -1
  108. package/dist/providers/image/mock.js +46 -1
  109. package/dist/providers/image/pull-registry.d.ts +25 -3
  110. package/dist/providers/image/pull-registry.js +96 -34
  111. package/dist/providers/image/sd-cpp.d.ts +63 -4
  112. package/dist/providers/image/sd-cpp.js +361 -38
  113. package/dist/providers/image/types.d.ts +76 -4
  114. package/dist/providers/image/types.js +8 -0
  115. package/dist/providers/llama-cpp/build-provider.js +3 -2
  116. package/dist/providers/llama-cpp/cache-adapter.d.ts +3 -0
  117. package/dist/providers/llama-cpp/cache-adapter.js +18 -4
  118. package/dist/providers/llama-cpp/devices.js +2 -2
  119. package/dist/providers/llama-cpp/engine-flags.d.ts +5 -0
  120. package/dist/providers/llama-cpp/engine-flags.js +5 -2
  121. package/dist/providers/llama-cpp/provider.js +20 -4
  122. package/dist/providers/mlx/provider.js +13 -4
  123. package/dist/providers/mlx/python/gezel_mlx_server.py +9 -2
  124. package/dist/providers/mlx/python/spec_decode.py +44 -5
  125. package/dist/providers/native/capacity-broker.d.ts +1 -1
  126. package/dist/providers/native/capacity-broker.js +8 -8
  127. package/dist/providers/native/capacity-budget.js +5 -4
  128. package/dist/providers/native/device-capacity-ledger.d.ts +2 -0
  129. package/dist/providers/native/device-capacity-ledger.js +36 -5
  130. package/dist/providers/native/device-capacity.js +4 -3
  131. package/dist/providers/native/local-engine-runtime.js +4 -4
  132. package/dist/providers/native/process-identity.d.ts +2 -0
  133. package/dist/providers/native/process-identity.js +70 -0
  134. package/dist/relevance/relevance-core.js +2 -0
  135. package/dist/relevance/relevance-model.js +2 -0
  136. package/dist/relevance/settings.js +2 -2
  137. package/dist/runtime-lock.d.ts +43 -5
  138. package/dist/runtime-lock.js +189 -26
  139. package/dist/system/host-memory.d.ts +46 -0
  140. package/dist/system/host-memory.js +89 -0
  141. package/dist/system/memory.js +5 -4
  142. package/dist/transformers-cache.js +2 -0
  143. package/dist/utils/download-common.d.ts +1 -1
  144. package/package.json +8 -8
@@ -0,0 +1,89 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { availableParallelism, cpus, freemem, totalmem } from 'node:os';
3
+ function readTrimmed(path) {
4
+ try {
5
+ return readFileSync(path, 'utf8').trim();
6
+ }
7
+ catch {
8
+ return undefined;
9
+ }
10
+ }
11
+ const nodeProbe = {
12
+ totalmem,
13
+ freemem,
14
+ constrainedMemory: () => typeof process.constrainedMemory === 'function' ? process.constrainedMemory() : undefined,
15
+ availableMemory: () => typeof process.availableMemory === 'function' ? process.availableMemory() : undefined,
16
+ availableParallelism,
17
+ hostCpuCount: () => cpus().length,
18
+ readFile: (path) => (process.platform === 'linux' ? readTrimmed(path) : undefined),
19
+ };
20
+ /**
21
+ * The cgroup memory limit when it is below the host's RAM, else null.
22
+ * Node reads cgroup v1 and v2; "no limit" comes back as 0 or as a value at
23
+ * or above physical RAM, depending on the libuv release.
24
+ */
25
+ export function containerMemoryLimitBytes(probe = nodeProbe) {
26
+ const host = probe.totalmem();
27
+ const limit = probe.constrainedMemory();
28
+ if (typeof limit === 'number' && Number.isFinite(limit) && limit > 0 && limit < host) {
29
+ return limit;
30
+ }
31
+ return null;
32
+ }
33
+ /** RAM this process may use: host RAM, or the container's limit when lower. */
34
+ export function totalMemoryBytes(probe = nodeProbe) {
35
+ return containerMemoryLimitBytes(probe) ?? probe.totalmem();
36
+ }
37
+ /** Free RAM, never more than the container's limit leaves. */
38
+ export function freeMemoryBytes(probe = nodeProbe) {
39
+ return capToContainer(probe.freemem(), probe);
40
+ }
41
+ /**
42
+ * Caps a host-wide free-memory reading (`MemAvailable`, `vm_stat`) to what
43
+ * the container still has. Unchanged outside a container.
44
+ */
45
+ export function capToContainer(hostFreeBytes, probe = nodeProbe) {
46
+ if (containerMemoryLimitBytes(probe) === null)
47
+ return hostFreeBytes;
48
+ const available = probe.availableMemory();
49
+ if (typeof available !== 'number' || !Number.isFinite(available) || available < 0) {
50
+ return hostFreeBytes;
51
+ }
52
+ return Math.min(hostFreeBytes, available);
53
+ }
54
+ /**
55
+ * CPUs this process may keep busy: the scheduler's CPU set, further capped
56
+ * by a cgroup v2 `cpu.max` quota (or v1 `cfs_quota_us`) rounded up.
57
+ */
58
+ export function availableCpuCount(probe = nodeProbe) {
59
+ const cpus = Math.max(1, probe.availableParallelism());
60
+ const quota = cgroupCpuQuota(probe);
61
+ return quota === null ? cpus : Math.max(1, Math.min(cpus, Math.ceil(quota)));
62
+ }
63
+ export function cgroupCpuQuota(probe = nodeProbe) {
64
+ const v2 = probe.readFile('/sys/fs/cgroup/cpu.max');
65
+ if (v2) {
66
+ const [max, period] = v2.split(/\s+/);
67
+ const quota = Number(max);
68
+ const per = Number(period);
69
+ if (max !== 'max' && quota > 0 && per > 0)
70
+ return quota / per;
71
+ return null;
72
+ }
73
+ const v1Quota = Number(probe.readFile('/sys/fs/cgroup/cpu/cpu.cfs_quota_us'));
74
+ const v1Period = Number(probe.readFile('/sys/fs/cgroup/cpu/cpu.cfs_period_us'));
75
+ if (v1Quota > 0 && v1Period > 0)
76
+ return v1Quota / v1Period;
77
+ return null;
78
+ }
79
+ /**
80
+ * The CPUs a container (a `--cpus` quota or a `--cpuset-cpus` set) leaves this
81
+ * process when that is fewer than the host has, else null. Engines that size
82
+ * their own thread pool from the host's cores, as llama.cpp does, oversubscribe
83
+ * such a limit badly: 32 threads under a 4-CPU quota spend most of each period
84
+ * throttled. Measured in a 4-CPU container: a 0.8B model decoded at 3.7 t/s.
85
+ */
86
+ export function containerCpuLimit(probe = nodeProbe) {
87
+ const allowed = availableCpuCount(probe);
88
+ return allowed < probe.hostCpuCount() ? allowed : null;
89
+ }
@@ -1,11 +1,12 @@
1
1
  import { execFile } from 'node:child_process';
2
- import { freemem, platform as osPlatform, totalmem } from 'node:os';
2
+ import { platform as osPlatform } from 'node:os';
3
3
  import { promisify } from 'node:util';
4
4
  import { readDeviceSystemFacts, windowsHeadlessSpawnOptions, } from '@bendyline/gezel/native';
5
5
  import { detectLlamaGpuVram, } from '../providers/llama-cpp/devices.js';
6
6
  import { autoDetectBudgetBytes, computeCapacityBudget, setDetectedGpuVramBytes, } from '../providers/native/capacity-budget.js';
7
7
  import { readAmdgpuAdapters } from './amdgpu-adapters.js';
8
8
  import { gpuCarveOutBytes, gpuVendorFromPciId, linuxGpuAddressableBytes, linuxGpuCarveOutBytes, matchGpuAdapter, } from './gpu-carve-out.js';
9
+ import { freeMemoryBytes, totalMemoryBytes } from './host-memory.js';
9
10
  const exec = promisify(execFile);
10
11
  let cachedMemoryProfile = null;
11
12
  let pendingMemoryProfile = null;
@@ -25,7 +26,7 @@ let pendingMemoryProfile = null;
25
26
  */
26
27
  export async function detectMemoryProfile() {
27
28
  const plat = osPlatform();
28
- const totalRam = totalmem();
29
+ const totalRam = totalMemoryBytes();
29
30
  if (plat === 'darwin') {
30
31
  setDetectedGpuVramBytes(null);
31
32
  return {
@@ -311,7 +312,7 @@ export function sampleMachineMemoryUsage(opts) {
311
312
  const residentModels = opts.residentModels ?? [];
312
313
  const sampledAt = opts.sampledAt ?? new Date().toISOString();
313
314
  if (mainMemory) {
314
- const freeRamBytes = clamp(finiteNonNegative(opts.darwinSystemMemory?.freeBytes ?? opts.freeRamBytes ?? freemem()), 0, totalRamBytes);
315
+ const freeRamBytes = clamp(finiteNonNegative(opts.darwinSystemMemory?.freeBytes ?? opts.freeRamBytes ?? freeMemoryBytes()), 0, totalRamBytes);
315
316
  const cachedBytes = opts.darwinSystemMemory
316
317
  ? clamp(finiteNonNegative(opts.darwinSystemMemory.cachedBytes), 0, totalRamBytes - freeRamBytes)
317
318
  : null;
@@ -512,7 +513,7 @@ function clamp(value, min, max) {
512
513
  * held back only ~3 GiB for the OS, so a 95 GB chat model and a 10 GB image
513
514
  * model were co-admitted and the image engine died with a CUDA OOM at init.
514
515
  */
515
- export function parseNvidiaMemoryProbe(stdout, systemRamBytes = totalmem()) {
516
+ export function parseNvidiaMemoryProbe(stdout, systemRamBytes = totalMemoryBytes()) {
516
517
  const devices = [];
517
518
  for (const rawLine of stdout.split(/\r?\n/)) {
518
519
  // GPU names can theoretically contain commas. Split on the final field,
@@ -19,6 +19,7 @@ import { createReadStream } from 'node:fs';
19
19
  import { mkdir, open, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
20
20
  import { basename, dirname, join, resolve } from 'node:path';
21
21
  import { createLogger } from '@bendyline/gezel';
22
+ import { disableOnnxRuntimeTelemetry } from '@bendyline/gezel/native';
22
23
  import { isPathInside } from './fs/safe-paths.js';
23
24
  const log = createLogger('service');
24
25
  /**
@@ -330,6 +331,7 @@ export function isMissingModule(err, specifier) {
330
331
  return new RegExp(String.raw `Cannot find (?:package|module) '${escaped}'`).test(err.message);
331
332
  }
332
333
  async function defaultLoadEnv() {
334
+ disableOnnxRuntimeTelemetry();
333
335
  const mod = (await import('@huggingface/transformers'));
334
336
  return mod.env;
335
337
  }
@@ -14,7 +14,7 @@ export declare const downloadLog: import("@bendyline/gezel").Logger;
14
14
  * transparent about who we are is the right posture for a third-party client
15
15
  * fetching public weights on the user's behalf.
16
16
  */
17
- export declare const GEZEL_DOWNLOAD_UA = "gezel/0.0.0 (+https://github.com/bendyline/gezel)";
17
+ export declare const GEZEL_DOWNLOAD_UA: string;
18
18
  /**
19
19
  * Headers for an HF control-plane request. An optional operator token raises
20
20
  * public-model rate limits, but is never forwarded to Xet/CAS/CDN hosts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-inference",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Gezel's on-device inference runtime: native engines, local model management, embeddings, knowledge search, and OpenAI-compatible routes.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -73,16 +73,16 @@
73
73
  "!dist/**/__pycache__"
74
74
  ],
75
75
  "dependencies": {
76
- "@bendyline/gezel": "1.2.10",
77
- "@bendyline/gezel-catalog": "1.2.10",
78
- "@bendyline/gezel-client": "1.2.10",
79
- "@bendyline/gezel-knowledge": "1.2.9",
80
- "hono": "4.13.9",
76
+ "@bendyline/gezel": "1.2.12",
77
+ "@bendyline/gezel-catalog": "1.2.12",
78
+ "@bendyline/gezel-client": "1.2.12",
79
+ "@bendyline/gezel-knowledge": "1.2.10",
80
+ "hono": "4.13.14",
81
81
  "tar": "7.5.21",
82
- "undici": "8.11.2",
82
+ "undici": "8.12.3",
83
83
  "yauzl": "^3.4.0",
84
84
  "yazl": "^3.3.1",
85
- "zod": "^4.4.3"
85
+ "zod": "4.6.7"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@huggingface/transformers": "^4.3.1"