@atomic-chat/core 0.13.2 → 0.13.6

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 (115) hide show
  1. package/dist/cli/main.d.ts +1 -1
  2. package/dist/core/atomic-core.d.ts +3 -1
  3. package/dist/core/atomic-core.js +1 -0
  4. package/dist/core/atomic-core.js.map +1 -1
  5. package/dist/core/create.js +6 -0
  6. package/dist/core/create.js.map +1 -1
  7. package/dist/core/prism.d.ts +2 -0
  8. package/dist/core/prism.js +1 -0
  9. package/dist/core/prism.js.map +1 -1
  10. package/dist/core/public-server.js +3 -2
  11. package/dist/core/public-server.js.map +1 -1
  12. package/dist/core/tensorrt-llm.d.ts +169 -0
  13. package/dist/core/tensorrt-llm.js +428 -0
  14. package/dist/core/tensorrt-llm.js.map +1 -0
  15. package/dist/core/types.d.ts +16 -0
  16. package/dist/core/types.js.map +1 -1
  17. package/dist/decision/process.d.ts +4 -0
  18. package/dist/decision/process.js +10 -1
  19. package/dist/decision/process.js.map +1 -1
  20. package/dist/diffusion/args.d.ts +3 -2
  21. package/dist/diffusion/args.js +21 -4
  22. package/dist/diffusion/args.js.map +1 -1
  23. package/dist/diffusion/compat.d.ts +1 -1
  24. package/dist/diffusion/compat.js +6 -2
  25. package/dist/diffusion/compat.js.map +1 -1
  26. package/dist/diffusion/jobs.js +4 -0
  27. package/dist/diffusion/jobs.js.map +1 -1
  28. package/dist/diffusion/tracker.d.ts +6 -0
  29. package/dist/diffusion/tracker.js +11 -0
  30. package/dist/diffusion/tracker.js.map +1 -1
  31. package/dist/diffusion/validate.js +2 -2
  32. package/dist/diffusion/validate.js.map +1 -1
  33. package/dist/diffusion/workflow.d.ts +8 -2
  34. package/dist/diffusion/workflow.js +13 -5
  35. package/dist/diffusion/workflow.js.map +1 -1
  36. package/dist/downloads/downloader.d.ts +22 -0
  37. package/dist/downloads/downloader.js +57 -2
  38. package/dist/downloads/downloader.js.map +1 -1
  39. package/dist/downloads/segmented.d.ts +40 -0
  40. package/dist/downloads/segmented.js +170 -0
  41. package/dist/downloads/segmented.js.map +1 -0
  42. package/dist/embedding/process.d.ts +4 -0
  43. package/dist/embedding/process.js +10 -1
  44. package/dist/embedding/process.js.map +1 -1
  45. package/dist/models/compatibility/inspect.d.ts +11 -2
  46. package/dist/models/compatibility/inspect.js +44 -13
  47. package/dist/models/compatibility/inspect.js.map +1 -1
  48. package/dist/models/compatibility/service.d.ts +3 -0
  49. package/dist/models/compatibility/service.js +1 -0
  50. package/dist/models/compatibility/service.js.map +1 -1
  51. package/dist/models/gguf/tensors.d.ts +1 -0
  52. package/dist/models/gguf/tensors.js +4 -1
  53. package/dist/models/gguf/tensors.js.map +1 -1
  54. package/dist/runtime/managed-text/adapter.d.ts +17 -0
  55. package/dist/runtime/managed-text/adapter.js.map +1 -1
  56. package/dist/runtime/managed-text/lifecycle.d.ts +8 -0
  57. package/dist/runtime/managed-text/lifecycle.js +38 -1
  58. package/dist/runtime/managed-text/lifecycle.js.map +1 -1
  59. package/dist/runtime/managed-text/readiness.d.ts +21 -1
  60. package/dist/runtime/managed-text/readiness.js +64 -0
  61. package/dist/runtime/managed-text/readiness.js.map +1 -1
  62. package/dist/runtime/shared/ports.d.ts +10 -0
  63. package/dist/runtime/shared/ports.js +30 -0
  64. package/dist/runtime/shared/ports.js.map +1 -1
  65. package/dist/runtime/tensorrt-llm/adapter.d.ts +1 -4
  66. package/dist/runtime/tensorrt-llm/adapter.js +28 -11
  67. package/dist/runtime/tensorrt-llm/adapter.js.map +1 -1
  68. package/dist/runtime/tensorrt-llm/check.js +1 -0
  69. package/dist/runtime/tensorrt-llm/check.js.map +1 -1
  70. package/dist/runtime/tensorrt-llm/compatibility.d.ts +30 -6
  71. package/dist/runtime/tensorrt-llm/compatibility.js +41 -9
  72. package/dist/runtime/tensorrt-llm/compatibility.js.map +1 -1
  73. package/dist/runtime/tensorrt-llm/cuda-graphs.d.ts +32 -0
  74. package/dist/runtime/tensorrt-llm/cuda-graphs.js +33 -0
  75. package/dist/runtime/tensorrt-llm/cuda-graphs.js.map +1 -0
  76. package/dist/runtime/tensorrt-llm/delete.d.ts +15 -0
  77. package/dist/runtime/tensorrt-llm/delete.js +60 -0
  78. package/dist/runtime/tensorrt-llm/delete.js.map +1 -0
  79. package/dist/runtime/tensorrt-llm/engine.js +11 -5
  80. package/dist/runtime/tensorrt-llm/engine.js.map +1 -1
  81. package/dist/runtime/tensorrt-llm/guest-files.d.ts +8 -0
  82. package/dist/runtime/tensorrt-llm/guest-files.js +49 -0
  83. package/dist/runtime/tensorrt-llm/guest-files.js.map +1 -0
  84. package/dist/runtime/tensorrt-llm/kv-cache.d.ts +16 -0
  85. package/dist/runtime/tensorrt-llm/kv-cache.js +21 -1
  86. package/dist/runtime/tensorrt-llm/kv-cache.js.map +1 -1
  87. package/dist/runtime/tensorrt-llm/location.d.ts +20 -0
  88. package/dist/runtime/tensorrt-llm/location.js +48 -0
  89. package/dist/runtime/tensorrt-llm/location.js.map +1 -0
  90. package/dist/runtime/tensorrt-llm/model-dir.d.ts +38 -0
  91. package/dist/runtime/tensorrt-llm/model-dir.js +137 -0
  92. package/dist/runtime/tensorrt-llm/model-dir.js.map +1 -0
  93. package/dist/runtime/tensorrt-llm/quant-format.d.ts +65 -0
  94. package/dist/runtime/tensorrt-llm/quant-format.js +189 -0
  95. package/dist/runtime/tensorrt-llm/quant-format.js.map +1 -0
  96. package/dist/runtime/tensorrt-llm/registry.d.ts +26 -0
  97. package/dist/runtime/tensorrt-llm/registry.js +68 -0
  98. package/dist/runtime/tensorrt-llm/registry.js.map +1 -0
  99. package/dist/runtime/tensorrt-llm/runtime.d.ts +130 -0
  100. package/dist/runtime/tensorrt-llm/runtime.js +395 -0
  101. package/dist/runtime/tensorrt-llm/runtime.js.map +1 -0
  102. package/dist/server/control/router.js +1 -1
  103. package/dist/server/control/router.js.map +1 -1
  104. package/dist/server/control/types.d.ts +5 -1
  105. package/dist/server/control/types.js.map +1 -1
  106. package/dist/server/public/gates.d.ts +6 -1
  107. package/dist/server/public/gates.js +7 -3
  108. package/dist/server/public/gates.js.map +1 -1
  109. package/dist/server/public/index.d.ts +1 -0
  110. package/dist/server/public/index.js +9 -6
  111. package/dist/server/public/index.js.map +1 -1
  112. package/dist/server/public/types.d.ts +7 -0
  113. package/dist/version.d.ts +1 -1
  114. package/dist/version.js +1 -1
  115. package/package.json +2 -2
@@ -0,0 +1,428 @@
1
+ /**
2
+ * Composition of the `tensorrt-llm` provider for `create.ts` (task 2.14): offered only on Linux, on
3
+ * the managed-text lifecycle built over the core's one Docker executor and journal — the startup
4
+ * handle the managed environment (task 2.6) wires, reconciles and hands its setup and removal too,
5
+ * never a second pair — the desktop deployment, this scope's managed paths,
6
+ * `selinuxDataRoot = <data>`, and the public server's live trusted-hosts array.
7
+ *
8
+ * What it shares with the managed environment rather than duplicating: the installation records
9
+ * (`InstallationStore`, the one reader of that format), the Linux machine (`LinuxHost`, which is the
10
+ * `ATOMIC_MANAGED_TEST_HOST` stand-in machine in the e2e suite, so that hook is read in one place),
11
+ * and, the other way round, `unloadEngineSessions`: a removal of the engine holds its loads off and
12
+ * unloads its loaded model first, through `tensorrtLlmSessionUnloader` and the facade's own unload.
13
+ *
14
+ * `wireTensorrtLlmModelCheck` (task 2.16) composes `POST /models/tensorrt-llm/check`'s deps
15
+ * separately from the runtime above: it shares the installation records, the descriptor provider and
16
+ * `LinuxHost.probeDeps`, but deliberately never touches `containers`/Docker (`check.ts`'s own file
17
+ * banner explains why) and is offered even when the runtime itself would refuse every load.
18
+ *
19
+ * `tensorrtLlmModelDeleter` (task 2.24) is `DELETE /models/tensorrt-llm/:id`: the same hold-and-unload
20
+ * through the facade as the engine removal's unloader, for one model, then its files.
21
+ */
22
+ import { AtomicCoreError } from '../contracts/index.js';
23
+ import { RECONCILE_BUDGET_MS, RECONCILE_CALL_TIMEOUT_MS, RECONCILE_STARTUP_STOP_TIMEOUT_SECONDS, createDockerExec, guestRealpath, reconcileExecutions, } from '../runtime/container/index.js';
24
+ import { guestProbeDeps, localhostForwardingError, parseWslConfig, TENSORRT_LLM_ENGINE_ID, } from '../runtime/environment/index.js';
25
+ import { ManagedTextAdapterRegistry, ManagedTextLifecycle, createDesktopManagedDeployment, createWslManagedDeployment, } from '../runtime/managed-text/index.js';
26
+ import { TensorrtLlmModelRegistry, TensorrtLlmRuntime, checkTensorrtLlmModel, containerPlatformFor, deleteTensorrtLlmModelFiles, guestModelFiles, guestModelsRoot, linuxModelLocation, probeTensorrtLlmGpus, probeTensorrtLlmGpusAndMemory, probeTensorrtLlmHost, readTensorrtLlmModel, resolveReadyInstallation, tensorrtLlmAdapter, windowsModelLocation, } from '../runtime/tensorrt-llm/index.js';
27
+ import { ensureGuestScope, guestScopePaths, WSL_LOCALHOST_MOUNT, } from '../runtime/wsl/index.js';
28
+ /** The recorded distribution and its transport; null before the import. */
29
+ async function windowsDistribution(context) {
30
+ const record = await context.records.read();
31
+ return record === null ? null : { record, transport: context.wsl.distribution(record.distribution.name) };
32
+ }
33
+ async function windowsGuest(context, layout) {
34
+ const record = await context.records.read();
35
+ if (record === null)
36
+ return null;
37
+ const name = record.distribution.name;
38
+ const key = await context.scopeKey();
39
+ return {
40
+ record,
41
+ transport: context.wsl.distribution(name),
42
+ key,
43
+ paths: guestScopePaths(layout.managed, name, key, context.mount),
44
+ modelsRoot: (context.mount ?? WSL_LOCALHOST_MOUNT).hostPath(name, guestModelsRoot(key)),
45
+ };
46
+ }
47
+ const notImported = () => new AtomicCoreError('MANAGED_ADAPTER_UNAVAILABLE', 'TensorRT-LLM runs in Atomic Chat’s WSL distribution, which is not set up on this computer yet.');
48
+ /** Windows on x64 only: no WSL GPU path for ARM (spec `tensorrt-llm-desktop`). */
49
+ const windowsX64 = (platform, arch, context) => platform === 'win32' && arch === 'x64' && context !== undefined;
50
+ /** The provider, or null where it is not offered: everywhere but Linux and Windows x64. */
51
+ export function wireTensorrtLlm(options) {
52
+ if (options.windows !== undefined && windowsX64(options.platform, options.arch, options.windows)) {
53
+ return wireWindowsTensorrtLlm(options, options.windows);
54
+ }
55
+ if (options.platform !== 'linux')
56
+ return null;
57
+ const adapters = new ManagedTextAdapterRegistry();
58
+ adapters.register(tensorrtLlmAdapter);
59
+ const deployment = createDesktopManagedDeployment();
60
+ /** The lifecycle and the executor it was built over: the load path's probe asks the same one. */
61
+ let built = null;
62
+ // Asked at every load, through the handle: a host with no docker CLI when core started gets one
63
+ // from the setup's privileged step, and the next load finds it (the handle wires it then).
64
+ const lifecycle = async () => {
65
+ if (built !== null)
66
+ return built.lifecycle;
67
+ const containers = await options.containers.resolve();
68
+ if (containers === null)
69
+ return null;
70
+ // Two loads that raced here built nothing twice: the first to resume assigns, the second reuses.
71
+ built ??= {
72
+ exec: containers.exec,
73
+ lifecycle: new ManagedTextLifecycle({
74
+ provider: 'tensorrt-llm',
75
+ adapters,
76
+ exec: containers.exec,
77
+ deployment,
78
+ journal: containers.journal,
79
+ paths: options.layout.managed,
80
+ instanceId: options.instanceId,
81
+ scope: options.scope,
82
+ allowedHosts: options.trustedHosts,
83
+ selinuxDataRoot: options.layout.root,
84
+ emit: options.emit,
85
+ log: options.log,
86
+ ...(options.containerUser === null ? {} : { containerUser: options.containerUser }),
87
+ }),
88
+ };
89
+ return built.lifecycle;
90
+ };
91
+ const platform = containerPlatformFor(options.arch);
92
+ return new TensorrtLlmRuntime({
93
+ lifecycle,
94
+ readyInstallation: () => resolveReadyInstallation({
95
+ installations: options.installations,
96
+ descriptors: options.descriptors,
97
+ platform,
98
+ }),
99
+ // Probed fresh at every load, never read off the environment snapshot: that view is only as new
100
+ // as the last setup or removal probe (and empty after a restart), while a card can disappear
101
+ // between two loads (spec "Выбранная карта исчезла"). An unanswered `docker info` refuses the load.
102
+ // Through the lifecycle's own executor: `TensorrtLlmRuntime` asks for host facts only once the
103
+ // lifecycle resolved, so it is always there (final review T-288 removed a dead fallback).
104
+ hostFacts: () => probeTensorrtLlmHost({
105
+ exec: options.host.probeDeps.exec,
106
+ docker: built.exec,
107
+ nvidiaSmi: 'nvidia-smi',
108
+ readFile: options.host.probeDeps.readFile,
109
+ }),
110
+ model: (modelId) => readTensorrtLlmModel(options.layout.provider('tensorrt-llm').modelsDir, modelId),
111
+ settings: options.settings,
112
+ ...(options.claimGpu ? { claimGpu: options.claimGpu } : {}),
113
+ });
114
+ }
115
+ /**
116
+ * The Windows provider (change `add-tensorrt-llm-windows`, tasks 2.6–2.8): the same lifecycle and
117
+ * runtime as Linux, over the WSL guest — the core's one executor (the guest's docker, from the handle),
118
+ * this scope's folder in the guest for heartbeats, caches and the watchdog, the WSL deployment (a port
119
+ * Docker picks, forwarding checked), `realpath` in the guest, uid 1000 for the container, the
120
+ * distribution held while a model loads or is loaded; the host facts of a load read in the guest
121
+ * (its `nvidia-smi`, the VM's memory); models under the scope's guest root.
122
+ */
123
+ function wireWindowsTensorrtLlm(options, context) {
124
+ const adapters = new ManagedTextAdapterRegistry();
125
+ adapters.register(tensorrtLlmAdapter);
126
+ let built = null;
127
+ const lifecycle = async () => {
128
+ if (built !== null)
129
+ return built.lifecycle;
130
+ const guest = await windowsGuest(context, options.layout);
131
+ if (guest === null)
132
+ throw notImported();
133
+ const containers = await options.containers.resolve();
134
+ if (containers === null)
135
+ return null;
136
+ await ensureGuestScope(guest.transport, guest.key);
137
+ const deployment = windowsDeployment(context, guest, containers.exec);
138
+ const name = guest.record.distribution.name;
139
+ built ??= {
140
+ exec: containers.exec,
141
+ guest,
142
+ lifecycle: new ManagedTextLifecycle({
143
+ provider: 'tensorrt-llm',
144
+ adapters,
145
+ exec: containers.exec,
146
+ deployment,
147
+ journal: containers.journal,
148
+ paths: guest.paths,
149
+ instanceId: options.instanceId,
150
+ scope: options.scope,
151
+ allowedHosts: options.trustedHosts,
152
+ // SELinux is not enforcing in Atomic Chat's Ubuntu guest; never used, but must be in the guest.
153
+ selinuxDataRoot: guest.paths.root,
154
+ emit: options.emit,
155
+ log: options.log,
156
+ createContainerDeps: { realpath: guestRealpath(guest.transport) },
157
+ containerUser: { uid: 1000, gid: 1000 },
158
+ keeper: context.keeper(name),
159
+ }),
160
+ };
161
+ return built.lifecycle;
162
+ };
163
+ const platform = containerPlatformFor(options.arch);
164
+ return new TensorrtLlmRuntime({
165
+ lifecycle,
166
+ readyInstallation: () => resolveReadyInstallation({
167
+ installations: options.installations,
168
+ descriptors: options.descriptors,
169
+ platform,
170
+ }),
171
+ hostFacts: () => {
172
+ const current = built;
173
+ const deps = guestProbeDeps(current.guest.transport);
174
+ return probeTensorrtLlmHost({
175
+ exec: deps.exec,
176
+ docker: current.exec,
177
+ nvidiaSmi: 'nvidia-smi',
178
+ readFile: deps.readFile,
179
+ });
180
+ },
181
+ model: async (modelId) => {
182
+ const guest = await windowsGuest(context, options.layout);
183
+ if (guest === null)
184
+ throw notImported();
185
+ return readTensorrtLlmModel(guest.modelsRoot, modelId);
186
+ },
187
+ settings: options.settings,
188
+ ...(options.claimGpu ? { claimGpu: options.claimGpu } : {}),
189
+ });
190
+ }
191
+ /**
192
+ * The WSL deployment of one guest (task 2.7): its mounts through the context's mount, the engine probed
193
+ * inside the guest as root, and the forwarding error built from `.wslconfig` as it reads at that moment.
194
+ */
195
+ export function windowsDeployment(context, guest, exec) {
196
+ return createWslManagedDeployment({
197
+ distribution: guest.record.distribution.name,
198
+ ...(context.mount === undefined ? {} : { mount: context.mount }),
199
+ exec,
200
+ runInGuest: (argv) => guest.transport.exec(argv, { user: 'root', timeoutMs: 10_000 }),
201
+ forwardingError: async () => localhostForwardingError(parseWslConfig(await context.host.probeDeps.readWslConfig().catch(() => null))),
202
+ });
203
+ }
204
+ /** The retried reconcile's executor where the wired one already is the guest's (Windows). */
205
+ export const wiredExec = (wired) => wired.exec;
206
+ /**
207
+ * `GET /models/tensorrt-llm/location` (change `add-tensorrt-llm-windows`, task 2.8): `<data>/tensorrt-llm/models`
208
+ * on Linux; the scope's folder in the WSL guest on Windows (`MANAGED_ADAPTER_UNAVAILABLE` before the import).
209
+ */
210
+ export function tensorrtLlmModelLocation(platform, layout, windows) {
211
+ if (platform === 'win32' && windows !== undefined) {
212
+ return () => windowsModelLocation({
213
+ records: windows.records,
214
+ scopeKey: windows.scopeKey,
215
+ transport: (name) => windows.wsl.distribution(name),
216
+ volumeFreeBytes: (path) => windows.host.freeDiskBytes(path),
217
+ ...(windows.mount === undefined ? {} : { mount: windows.mount }),
218
+ });
219
+ }
220
+ return () => linuxModelLocation(layout.provider('tensorrt-llm').modelsDir);
221
+ }
222
+ /** The `tensorrt-llm` model registry: the data folder's root on Linux, the guest root (once it exists) on Windows. */
223
+ export function tensorrtLlmModelRegistry(platform, layout, windows) {
224
+ if (platform === 'win32' && windows !== undefined) {
225
+ return new TensorrtLlmModelRegistry(async () => (await windowsGuest(windows, layout))?.modelsRoot ?? null);
226
+ }
227
+ return new TensorrtLlmModelRegistry(layout.provider('tensorrt-llm').modelsDir);
228
+ }
229
+ /** `windowsModelFiles` bound to one context and layout: the deleter's `windowsFiles` on Windows. */
230
+ export function windowsModelFilesFor(windows, layout) {
231
+ return () => windowsModelFiles(windows, layout);
232
+ }
233
+ /** Windows: where a model's files and caches are, and how to size and remove them (in the guest). */
234
+ export async function windowsModelFiles(windows, layout) {
235
+ const guest = await windowsGuest(windows, layout);
236
+ if (guest === null)
237
+ throw notImported();
238
+ return { paths: guest.paths, files: guestModelFiles(guest.transport, windows.mount) };
239
+ }
240
+ /**
241
+ * `POST /models/tensorrt-llm/check` (task 2.16): `null` off Linux, where the provider is not offered
242
+ * at all. Available even when the engine is not installed yet — the check falls back to the latest
243
+ * cached descriptor itself (`check.ts`) — and never asks Docker anything, unlike `wireTensorrtLlm`'s
244
+ * own `hostFacts` above.
245
+ */
246
+ export function wireTensorrtLlmModelCheck(platform, options) {
247
+ const windows = options.windows;
248
+ if (windows !== undefined && windowsX64(platform, options.arch ?? 'x64', windows)) {
249
+ return (body) => checkTensorrtLlmModel(body, {
250
+ installations: options.installations,
251
+ descriptors: options.descriptors,
252
+ // The guest's cards and the WSL VM's memory once the distribution exists (design D11); before
253
+ // that, the cards Windows sees, with no memory to compare against.
254
+ hostFacts: async () => {
255
+ const guest = await windowsDistribution(windows);
256
+ if (guest === null) {
257
+ const gpus = await probeTensorrtLlmGpus({
258
+ exec: windows.host.probeDeps.exec,
259
+ nvidiaSmi: `${windows.host.probeDeps.systemRoot}\\System32\\nvidia-smi.exe`,
260
+ });
261
+ return { gpus, memory: { availableBytes: 0, totalBytes: 0 } };
262
+ }
263
+ const deps = guestProbeDeps(guest.transport);
264
+ return probeTensorrtLlmGpusAndMemory({
265
+ exec: deps.exec,
266
+ nvidiaSmi: 'nvidia-smi',
267
+ readFile: deps.readFile,
268
+ });
269
+ },
270
+ settings: options.settings,
271
+ wslVm: async () => ({
272
+ memory_setting: parseWslConfig(await windows.host.probeDeps.readWslConfig().catch(() => null))
273
+ .memory,
274
+ }),
275
+ });
276
+ }
277
+ if (platform !== 'linux')
278
+ return null;
279
+ return (body) => checkTensorrtLlmModel(body, {
280
+ installations: options.installations,
281
+ descriptors: options.descriptors,
282
+ hostFacts: () => probeTensorrtLlmGpusAndMemory({
283
+ exec: options.host.probeDeps.exec,
284
+ nvidiaSmi: 'nvidia-smi',
285
+ readFile: options.host.probeDeps.readFile,
286
+ }),
287
+ settings: options.settings,
288
+ });
289
+ }
290
+ /**
291
+ * What GPU residency must see of the containers a previous core left (task 2.15; carry-forward from
292
+ * 2.12/2.14): startup reconcile could not confirm them stopped — the stop went unconfirmed, a docker
293
+ * call failed, or its time budget ran out — so they may still be running and holding a GPU. Which one
294
+ * is not recorded, so each holds every card, as `stop-unconfirmed`, under its engine id and container
295
+ * id, with the remedy a refusal names. Evicting one runs the reconcile again, bounded like the startup
296
+ * one (a short deadline per docker call, a short `--time`, a total budget), over this scope's journal
297
+ * only — this instance's own records are never touched — and it is released only once Docker confirms
298
+ * it gone.
299
+ */
300
+ export function leftoverContainers(options) {
301
+ let latest = null;
302
+ const unresolved = (result) => [
303
+ ...result.unconfirmed,
304
+ ...result.failed,
305
+ ...result.skipped,
306
+ ];
307
+ const boundedExec = options.exec ??
308
+ ((wired) => createDockerExec({
309
+ dockerPath: wired.dockerPath,
310
+ dockerConfigDir: options.dockerConfigDir,
311
+ timeoutMs: RECONCILE_CALL_TIMEOUT_MS,
312
+ }));
313
+ const retry = async (wired) => {
314
+ const budget = new AbortController();
315
+ const budgetMs = options.budgetMs ?? RECONCILE_BUDGET_MS;
316
+ if (budgetMs <= 0)
317
+ budget.abort();
318
+ const timer = setTimeout(() => budget.abort(), Math.max(budgetMs, 0));
319
+ timer.unref?.();
320
+ try {
321
+ return await reconcileExecutions(wired.journal, options.instanceId, boundedExec(wired), options.log, RECONCILE_STARTUP_STOP_TIMEOUT_SECONDS, budget.signal);
322
+ }
323
+ finally {
324
+ clearTimeout(timer);
325
+ }
326
+ };
327
+ return () => {
328
+ const wired = options.containers.current();
329
+ if (wired === null)
330
+ return [];
331
+ return unresolved(latest ?? wired.reconciled).map((record) => ({
332
+ provider: record.engine_id,
333
+ model_id: record.container_id,
334
+ cards: 'all',
335
+ auxiliary: false,
336
+ state: 'stop-unconfirmed',
337
+ remedy: `Start Docker, or remove container ${record.container_id} yourself ` +
338
+ `(docker rm -f ${record.container_id}); the next load retries the stop.`,
339
+ evict: async () => {
340
+ latest = await retry(wired);
341
+ if (unresolved(latest).some((left) => left.container_id === record.container_id)) {
342
+ throw new Error(`Docker did not confirm container ${record.container_id} stopped.`);
343
+ }
344
+ },
345
+ }));
346
+ };
347
+ }
348
+ /**
349
+ * The managed environment's `unloadEngineSessions` (spec "Удаление при загруженной модели"): before
350
+ * a removal touches the engine's image, loads of `tensorrt-llm` are held off (`holdOffLoads`) and
351
+ * every model holding a card is unloaded with its container's stop confirmed — through the facade's
352
+ * own `unload`, as a client's unload or GPU residency would, so each model's cross-process claim is
353
+ * released and a load still pending is cancelled rather than queued behind (final review M-1). The
354
+ * hold lasts until the removal calls `release`. An unconfirmed stop rejects with
355
+ * `MANAGED_STOP_UNCONFIRMED`, which fails the removal with nothing removed, and lifts the hold at
356
+ * once. `runtime` and `sessions` are read at removal time: the provider is registered after the
357
+ * environment is wired, and the facade after both.
358
+ */
359
+ export function tensorrtLlmSessionUnloader(runtime, sessions) {
360
+ return async (engineId) => {
361
+ if (engineId !== TENSORRT_LLM_ENGINE_ID)
362
+ return { unloaded: 0 };
363
+ const provider = runtime();
364
+ if (!(provider instanceof TensorrtLlmRuntime))
365
+ return { unloaded: 0 };
366
+ const release = provider.holdOffLoads();
367
+ try {
368
+ const facade = sessions();
369
+ const models = provider.residentModels();
370
+ for (const modelId of models) {
371
+ facade.cancelLoad(TENSORRT_LLM_ENGINE_ID, modelId);
372
+ const result = await facade.unload(TENSORRT_LLM_ENGINE_ID, modelId);
373
+ if (!result.success) {
374
+ throw new AtomicCoreError('MANAGED_STOP_UNCONFIRMED', result.error ?? `The unload of ${modelId} failed.`, modelId);
375
+ }
376
+ }
377
+ return { unloaded: models.length, release };
378
+ }
379
+ catch (error) {
380
+ release();
381
+ throw error;
382
+ }
383
+ };
384
+ }
385
+ /**
386
+ * `DELETE /models/tensorrt-llm/:id` (task 2.24, design D12a, spec `tensorrt-llm-models` "Модель
387
+ * удаляется через core"). The id must be one the registry lists — exactly, never percent-decoded or
388
+ * resolved as a path — else `MODEL_NOT_FOUND`: a client's wrong id is an error, not a success. Loads
389
+ * of that model are held off for the whole deletion; a load in flight is cancelled and the model
390
+ * unloaded through the facade, as a client's unload would be, so its cross-process claim is released.
391
+ * Only once Docker confirmed the stop are the files touched; an unconfirmed stop rejects with
392
+ * `MANAGED_STOP_UNCONFIRMED` and removes nothing.
393
+ */
394
+ export function tensorrtLlmModelDeleter(options) {
395
+ return async (modelId) => {
396
+ const provider = options.runtime();
397
+ if (!(provider instanceof TensorrtLlmRuntime)) {
398
+ throw new AtomicCoreError('PROVIDER_NOT_FOUND', 'tensorrt-llm is not available in this build.', TENSORRT_LLM_ENGINE_ID);
399
+ }
400
+ const model = (await options.registry.list()).find((entry) => entry.id === modelId);
401
+ if (model === undefined) {
402
+ throw new AtomicCoreError('MODEL_NOT_FOUND', `No tensorrt-llm model has the id '${modelId}'.`, modelId);
403
+ }
404
+ const release = provider.holdOffModel(modelId);
405
+ try {
406
+ const facade = options.sessions();
407
+ const cancelled = facade.cancelLoad(TENSORRT_LLM_ENGINE_ID, modelId);
408
+ const result = await facade.unload(TENSORRT_LLM_ENGINE_ID, modelId);
409
+ if (!result.success || provider.residentModels().includes(modelId)) {
410
+ throw new AtomicCoreError('MANAGED_STOP_UNCONFIRMED', result.error ?? `The container of ${modelId} did not confirm its stop; nothing was deleted.`, modelId);
411
+ }
412
+ const guest = options.windowsFiles === undefined ? null : await options.windowsFiles();
413
+ const files = guest === null
414
+ ? await deleteTensorrtLlmModelFiles(options.paths, model)
415
+ : await deleteTensorrtLlmModelFiles(guest.paths, model, guest.files);
416
+ return {
417
+ model_id: modelId,
418
+ was_loaded: cancelled || result.was_loaded === true,
419
+ freed_bytes: files.freedBytes,
420
+ engine_caches_removed: files.engineCachesRemoved,
421
+ };
422
+ }
423
+ finally {
424
+ release();
425
+ }
426
+ };
427
+ }
428
+ //# sourceMappingURL=tensorrt-llm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tensorrt-llm.js","sourceRoot":"","sources":["../../src/core/tensorrt-llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAQvD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,sCAAsC,EACtC,gBAAgB,EAChB,aAAa,EACb,mBAAmB,GACpB,MAAM,+BAA+B,CAAA;AAStC,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,cAAc,EACd,sBAAsB,GACvB,MAAM,iCAAiC,CAAA;AASxC,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EACL,wBAA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EAAE,CAAA;QACX,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -44,6 +44,22 @@ export interface AtomicCoreOptions {
44
44
  * system directories (`/usr/bin`, `/usr/local/bin`, `/bin`), never `PATH`; `null` means none.
45
45
  */
46
46
  dockerPath?: string | null;
47
+ /**
48
+ * The host's keyring for the public API (a terminal that hands every client its own key), read for
49
+ * every request: a client must present one of these, and a revoked key is refused on the next
50
+ * request. An empty list refuses every client; `undefined` keeps `server.api_key`.
51
+ */
52
+ publicApiKeys?: () => readonly string[] | undefined;
53
+ /**
54
+ * Parallel byte-range streams for a hash-pinned file of at least 32 MiB (at most 4); one when
55
+ * unset. A server without ranges falls back to one stream.
56
+ */
57
+ downloadStreams?: number;
58
+ /**
59
+ * How long reading a remote GGUF header for a model check may take in all (a terminal that must not
60
+ * hang on a slow or broken mirror); past it the check goes on without the header. Unset waits.
61
+ */
62
+ remoteGgufTimeoutMs?: number;
47
63
  fetch?: typeof fetch;
48
64
  env?: NodeJS.ProcessEnv;
49
65
  /** 'owner' takes the instance lock; 'auto' is the same today — attaching is the CLI's job. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AA0EA,MAAM,CAAC,MAAM,cAAc,GAAoB,mBAAmB,CAAA"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AA0FA,MAAM,CAAC,MAAM,cAAc,GAAoB,mBAAmB,CAAA"}
@@ -64,4 +64,8 @@ export interface SpawnDecisionDeps {
64
64
  }
65
65
  /** The error for a process that died before it was ready: the engine's own last lines in the details. */
66
66
  export declare function earlyExitError(exit: ExitInfo, tail: readonly string[]): AtomicCoreError;
67
+ /**
68
+ * Start the decision model, on another port when the one picked was taken before the engine could
69
+ * bind it (`retryOnTakenPort`): an exit while loading that says so is that race, not the model.
70
+ */
67
71
  export declare function spawnDecisionServer(spec: DecisionServerSpec, deps: SpawnDecisionDeps): Promise<DecisionProcessHandle>;
@@ -12,7 +12,7 @@
12
12
  import { randomBytes } from 'node:crypto';
13
13
  import { dirname } from 'node:path';
14
14
  import { AtomicCoreError } from '../contracts/index.js';
15
- import { backendOutputReporter, buildProcessEnv, discoverCudaPaths, nodeCudaProbeEnv, randomFreePort, spawnManaged, } from '../runtime/shared/index.js';
15
+ import { backendOutputReporter, buildProcessEnv, discoverCudaPaths, exitedOnTakenPort, nodeCudaProbeEnv, randomFreePort, retryOnTakenPort, spawnManaged, } from '../runtime/shared/index.js';
16
16
  import { buildDecisionArgs, buildUpstreamDecisionArgs, commandSummary, decisionEnv, DECISION_HOST, withoutDecisionEnv, } from './args.js';
17
17
  import { UPSTREAM_DECISION_DEFAULT_CTX } from './model-facts.js';
18
18
  import { checkReadiness, READINESS_REQUEST_TIMEOUT_MS } from './readiness.js';
@@ -39,7 +39,16 @@ function describeExit(exit) {
39
39
  export function earlyExitError(exit, tail) {
40
40
  return new AtomicCoreError('MODEL_LOAD_FAILED', `The decision model exited with ${describeExit(exit)} while loading.`, tail.slice(-20).join('\n') || undefined);
41
41
  }
42
+ /**
43
+ * Start the decision model, on another port when the one picked was taken before the engine could
44
+ * bind it (`retryOnTakenPort`): an exit while loading that says so is that race, not the model.
45
+ */
42
46
  export async function spawnDecisionServer(spec, deps) {
47
+ return retryOnTakenPort(() => spawnDecisionServerOnce(spec, deps), (error) => error instanceof AtomicCoreError &&
48
+ error.code === 'MODEL_LOAD_FAILED' &&
49
+ exitedOnTakenPort(error.details), (attempt) => deps.log?.('warn', `the decision model's port was taken while it started; retrying (${attempt})`));
50
+ }
51
+ async function spawnDecisionServerOnce(spec, deps) {
43
52
  const platform = deps.platform ?? process.platform;
44
53
  const baseEnv = withoutDecisionEnv(deps.env ?? process.env);
45
54
  const log = deps.log ?? (() => { });
@@ -1 +1 @@
1
- {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/decision/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OA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pp/v1/img_gen` body. The whole batch goes in one request; guidance is split the way
87
87
  * sd.cpp expects (CFG → `txt_cfg`, FLUX distilled → `distilled_guidance`). Only set keys are sent,
88
- * so the server's own defaults apply to the rest. The workflow decides which images go in. sd.cpp
89
- * resizes the init image to `width`×`height` itself, which is how Upscale works.
88
+ * so the server's own defaults apply to the rest. `custom_sigmas` goes in when the family ships a
89
+ * fixed schedule for exactly this many steps (Qwen Image 2.1 Turbo). The workflow decides which
90
+ * images go in. sd.cpp resizes the init image to `width`×`height` itself, which is how Upscale works.
90
91
  *
91
92
  * sd.cpp reads integers with `is_number_integer()` and floats with `is_number()`, so `1` for a
92
93
  * `cfgScale` of 1.0 is accepted (checked in its `common.cpp`).
@@ -152,11 +152,24 @@ export const VAE_TILING_AREA = 1024 * 1024;
152
152
  * about 2 GB of that, the point past which a single-graph decode stops being safe anywhere.
153
153
  */
154
154
  export const VIDEO_VAE_TILING_PIXEL_FRAMES = VAE_TILING_AREA * 8;
155
+ /**
156
+ * A distilled family's fixed schedule as sd.cpp takes it, or undefined when the request asks for
157
+ * another step count and sd.cpp builds its own. The catalog lists one sigma per step; sd.cpp runs
158
+ * `custom_sigmas.length - 1` steps (`GenerationRequest` in its `src/pipeline/request.cpp`), so the
159
+ * closing 0 is appended here. Without it the last step never runs and the output keeps the noise of
160
+ * the last listed sigma.
161
+ */
162
+ function customSigmas(defaults, steps) {
163
+ if (defaults.sigmas === undefined || defaults.sigmas.length !== steps)
164
+ return undefined;
165
+ return [...defaults.sigmas, 0];
166
+ }
155
167
  /**
156
168
  * The `POST /sdcpp/v1/img_gen` body. The whole batch goes in one request; guidance is split the way
157
169
  * sd.cpp expects (CFG → `txt_cfg`, FLUX distilled → `distilled_guidance`). Only set keys are sent,
158
- * so the server's own defaults apply to the rest. The workflow decides which images go in. sd.cpp
159
- * resizes the init image to `width`×`height` itself, which is how Upscale works.
170
+ * so the server's own defaults apply to the rest. `custom_sigmas` goes in when the family ships a
171
+ * fixed schedule for exactly this many steps (Qwen Image 2.1 Turbo). The workflow decides which
172
+ * images go in. sd.cpp resizes the init image to `width`×`height` itself, which is how Upscale works.
160
173
  *
161
174
  * sd.cpp reads integers with `is_number_integer()` and floats with `is_number()`, so `1` for a
162
175
  * `cfgScale` of 1.0 is accepted (checked in its `common.cpp`).
@@ -173,6 +186,9 @@ export function buildImgGenRequest(request, defaults, seed, inputs) {
173
186
  const shift = request.flowShift ?? defaults.flowShift;
174
187
  if (shift !== undefined)
175
188
  sampleParams['flow_shift'] = shift;
189
+ const sigmas = customSigmas(defaults, request.steps);
190
+ if (sigmas !== undefined)
191
+ sampleParams['custom_sigmas'] = sigmas;
176
192
  sampleParams['guidance'] = guidance;
177
193
  const body = {
178
194
  prompt: request.prompt,
@@ -218,8 +234,9 @@ export function buildVidGenRequest(request, defaults, seed, inputs, tiling) {
218
234
  const shift = request.flowShift ?? defaults.flowShift;
219
235
  if (shift !== undefined)
220
236
  sampleParams['flow_shift'] = shift;
221
- if (defaults.sigmas !== undefined && defaults.sigmas.length === request.steps)
222
- sampleParams['custom_sigmas'] = [...defaults.sigmas];
237
+ const sigmas = customSigmas(defaults, request.steps);
238
+ if (sigmas !== undefined)
239
+ sampleParams['custom_sigmas'] = sigmas;
223
240
  sampleParams['guidance'] = guidance;
224
241
  const video = defaults.video;
225
242
  const body = {