@atomic-chat/core 0.18.4 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-daemon.js +5 -0
- package/dist/app-daemon.js.map +1 -1
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +5 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/client/control-client.d.ts +18 -1
- package/dist/client/control-client.js +27 -0
- package/dist/client/control-client.js.map +1 -1
- package/dist/cloud/registry.js +1 -0
- package/dist/cloud/registry.js.map +1 -1
- package/dist/config/paths.d.ts +4 -0
- package/dist/config/paths.js +13 -0
- package/dist/config/paths.js.map +1 -1
- package/dist/contracts/control-api.d.ts +9 -0
- package/dist/contracts/diffusion.d.ts +17 -7
- package/dist/contracts/diffusion.js.map +1 -1
- package/dist/contracts/engine-builds.d.ts +1 -1
- package/dist/contracts/engine-builds.js +1 -1
- package/dist/contracts/engine-builds.js.map +1 -1
- package/dist/contracts/engines.d.ts +1 -1
- package/dist/contracts/engines.js +2 -0
- package/dist/contracts/engines.js.map +1 -1
- package/dist/contracts/errors.d.ts +9 -1
- package/dist/contracts/errors.js.map +1 -1
- package/dist/contracts/events.d.ts +3 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/litert-lm.d.ts +97 -0
- package/dist/contracts/litert-lm.js +17 -0
- package/dist/contracts/litert-lm.js.map +1 -0
- package/dist/contracts/model-yml.d.ts +31 -0
- package/dist/contracts/model-yml.js +5 -0
- package/dist/contracts/model-yml.js.map +1 -1
- package/dist/contracts/session.d.ts +5 -1
- package/dist/contracts/session.js.map +1 -1
- package/dist/contracts/settings.d.ts +10 -1
- package/dist/contracts/settings.js.map +1 -1
- package/dist/core/atomic-core.d.ts +6 -1
- package/dist/core/atomic-core.js +6 -0
- package/dist/core/atomic-core.js.map +1 -1
- package/dist/core/create.js +141 -20
- package/dist/core/create.js.map +1 -1
- package/dist/diffusion/args.d.ts +8 -0
- package/dist/diffusion/args.js +10 -0
- package/dist/diffusion/args.js.map +1 -1
- package/dist/diffusion/compat.d.ts +3 -3
- package/dist/diffusion/compat.js +15 -10
- package/dist/diffusion/compat.js.map +1 -1
- package/dist/diffusion/recipe.d.ts +19 -2
- package/dist/diffusion/recipe.js +43 -20
- package/dist/diffusion/recipe.js.map +1 -1
- package/dist/diffusion/remote-job.js +6 -7
- package/dist/diffusion/remote-job.js.map +1 -1
- package/dist/diffusion/service.d.ts +1 -0
- package/dist/diffusion/service.js +4 -2
- package/dist/diffusion/service.js.map +1 -1
- package/dist/diffusion/video-history.js +3 -2
- package/dist/diffusion/video-history.js.map +1 -1
- package/dist/diffusion/video-recipe.d.ts +4 -1
- package/dist/diffusion/video-recipe.js +15 -11
- package/dist/diffusion/video-recipe.js.map +1 -1
- package/dist/diffusion/workflow.d.ts +2 -1
- package/dist/diffusion/workflow.js +3 -1
- package/dist/diffusion/workflow.js.map +1 -1
- package/dist/downloads/archive.d.ts +2 -1
- package/dist/downloads/archive.js +3 -2
- package/dist/downloads/archive.js.map +1 -1
- package/dist/engine-builds/engines.d.ts +22 -5
- package/dist/engine-builds/engines.js +44 -7
- package/dist/engine-builds/engines.js.map +1 -1
- package/dist/engine-builds/litert-lm.d.ts +29 -0
- package/dist/engine-builds/litert-lm.js +119 -0
- package/dist/engine-builds/litert-lm.js.map +1 -0
- package/dist/engine-builds/manifest.d.ts +55 -1
- package/dist/engine-builds/manifest.js +114 -1
- package/dist/engine-builds/manifest.js.map +1 -1
- package/dist/engine-builds/order.d.ts +2 -1
- package/dist/engine-builds/order.js +3 -1
- package/dist/engine-builds/order.js.map +1 -1
- package/dist/engine-builds/select.d.ts +19 -1
- package/dist/engine-builds/select.js +45 -0
- package/dist/engine-builds/select.js.map +1 -1
- package/dist/engine-builds/service.d.ts +8 -5
- package/dist/engine-builds/service.js +11 -4
- package/dist/engine-builds/service.js.map +1 -1
- package/dist/engines/service.d.ts +3 -1
- package/dist/engines/service.js +4 -1
- package/dist/engines/service.js.map +1 -1
- package/dist/host/recipes/executor-io-windows.d.ts +10 -1
- package/dist/host/recipes/executor-io-windows.js +9 -3
- package/dist/host/recipes/executor-io-windows.js.map +1 -1
- package/dist/router/resolve.d.ts +25 -4
- package/dist/router/resolve.js +34 -3
- package/dist/router/resolve.js.map +1 -1
- package/dist/runtime/environment/host-exec.d.ts +2 -0
- package/dist/runtime/environment/host-exec.js +15 -4
- package/dist/runtime/environment/host-exec.js.map +1 -1
- package/dist/runtime/litert-lm/accelerators.d.ts +54 -0
- package/dist/runtime/litert-lm/accelerators.js +176 -0
- package/dist/runtime/litert-lm/accelerators.js.map +1 -0
- package/dist/runtime/litert-lm/check.d.ts +44 -0
- package/dist/runtime/litert-lm/check.js +113 -0
- package/dist/runtime/litert-lm/check.js.map +1 -0
- package/dist/runtime/litert-lm/host/args.d.ts +47 -0
- package/dist/runtime/litert-lm/host/args.js +108 -0
- package/dist/runtime/litert-lm/host/args.js.map +1 -0
- package/dist/runtime/litert-lm/host/ffi-bun.d.ts +16 -0
- package/dist/runtime/litert-lm/host/ffi-bun.js +535 -0
- package/dist/runtime/litert-lm/host/ffi-bun.js.map +1 -0
- package/dist/runtime/litert-lm/host/library.d.ts +113 -0
- package/dist/runtime/litert-lm/host/library.js +38 -0
- package/dist/runtime/litert-lm/host/library.js.map +1 -0
- package/dist/runtime/litert-lm/host/openai.d.ts +97 -0
- package/dist/runtime/litert-lm/host/openai.js +355 -0
- package/dist/runtime/litert-lm/host/openai.js.map +1 -0
- package/dist/runtime/litert-lm/host/pool.d.ts +51 -0
- package/dist/runtime/litert-lm/host/pool.js +114 -0
- package/dist/runtime/litert-lm/host/pool.js.map +1 -0
- package/dist/runtime/litert-lm/host/run.d.ts +48 -0
- package/dist/runtime/litert-lm/host/run.js +169 -0
- package/dist/runtime/litert-lm/host/run.js.map +1 -0
- package/dist/runtime/litert-lm/host/server.d.ts +28 -0
- package/dist/runtime/litert-lm/host/server.js +242 -0
- package/dist/runtime/litert-lm/host/server.js.map +1 -0
- package/dist/runtime/litert-lm/host-process.d.ts +44 -0
- package/dist/runtime/litert-lm/host-process.js +99 -0
- package/dist/runtime/litert-lm/host-process.js.map +1 -0
- package/dist/runtime/litert-lm/index.d.ts +10 -0
- package/dist/runtime/litert-lm/index.js +11 -0
- package/dist/runtime/litert-lm/index.js.map +1 -0
- package/dist/runtime/litert-lm/litert-host.d.ts +17 -0
- package/dist/runtime/litert-lm/litert-host.js +22 -0
- package/dist/runtime/litert-lm/litert-host.js.map +1 -0
- package/dist/runtime/litert-lm/model-yml.d.ts +8 -0
- package/dist/runtime/litert-lm/model-yml.js +67 -0
- package/dist/runtime/litert-lm/model-yml.js.map +1 -0
- package/dist/runtime/litert-lm/npu.d.ts +11 -0
- package/dist/runtime/litert-lm/npu.js +24 -0
- package/dist/runtime/litert-lm/npu.js.map +1 -0
- package/dist/runtime/litert-lm/runtime.d.ts +99 -0
- package/dist/runtime/litert-lm/runtime.js +354 -0
- package/dist/runtime/litert-lm/runtime.js.map +1 -0
- package/dist/runtime/shared/external-sessions.js +1 -0
- package/dist/runtime/shared/external-sessions.js.map +1 -1
- package/dist/server/control/router.js +2 -0
- package/dist/server/control/router.js.map +1 -1
- package/dist/server/control/routes/litert-lm.d.ts +11 -0
- package/dist/server/control/routes/litert-lm.js +33 -0
- package/dist/server/control/routes/litert-lm.js.map +1 -0
- package/dist/server/control/routes/public-server.js +22 -0
- package/dist/server/control/routes/public-server.js.map +1 -1
- package/dist/server/control/types.d.ts +16 -1
- package/dist/server/control/types.js.map +1 -1
- package/dist/server/http.js +3 -0
- package/dist/server/http.js.map +1 -1
- package/dist/server/public/errors.d.ts +17 -0
- package/dist/server/public/errors.js +28 -0
- package/dist/server/public/errors.js.map +1 -1
- package/dist/server/public/forward.d.ts +20 -1
- package/dist/server/public/forward.js +64 -14
- package/dist/server/public/forward.js.map +1 -1
- package/dist/server/public/listing.d.ts +6 -0
- package/dist/server/public/listing.js +25 -3
- package/dist/server/public/listing.js.map +1 -1
- package/dist/server/public/responses.js +21 -10
- package/dist/server/public/responses.js.map +1 -1
- package/dist/server/public/subscription.js +2 -2
- package/dist/server/public/subscription.js.map +1 -1
- package/dist/server/public/types.d.ts +5 -0
- package/dist/server/public/videos-params.js +6 -1
- package/dist/server/public/videos-params.js.map +1 -1
- package/dist/settings/schema/litert-lm.json +37 -0
- package/dist/settings/schema.js +9 -0
- package/dist/settings/schema.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
|
@@ -8,7 +8,6 @@ import type { EngineBuildId, EngineBuildRef } from '../contracts/index.js';
|
|
|
8
8
|
import type { HardwareFacts } from '../hardware/index.js';
|
|
9
9
|
import type { BuildArchive } from './install.js';
|
|
10
10
|
import type { ManifestOf } from './manifest.js';
|
|
11
|
-
import type { FoundryLocalHostPlatform } from './select.js';
|
|
12
11
|
/** One build on disk as the service sees it. */
|
|
13
12
|
export interface Build extends EngineBuildRef {
|
|
14
13
|
/** For a bundled MLX build, `resources-dir`; otherwise the build's own directory. */
|
|
@@ -17,7 +16,19 @@ export interface Build extends EngineBuildRef {
|
|
|
17
16
|
published_at: string | null;
|
|
18
17
|
/** Foundry Local: the C API version recorded at install; `null` when unknown. */
|
|
19
18
|
c_api_version?: number | null;
|
|
19
|
+
/** LiteRT-LM: the binding number recorded at install; `null` when unknown. */
|
|
20
|
+
abi?: number | null;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Which build of an engine with one archive per platform this host runs, or why none
|
|
24
|
+
* (`foundryLocalHostPlatform`, `liteRtLmHostPlatform`).
|
|
25
|
+
*/
|
|
26
|
+
export type EngineHostPlatform = {
|
|
27
|
+
platform: string;
|
|
28
|
+
} | {
|
|
29
|
+
platform: null;
|
|
30
|
+
reason: string;
|
|
31
|
+
};
|
|
21
32
|
/** What a row may read from the service's dependencies. */
|
|
22
33
|
export interface EngineContext {
|
|
23
34
|
/** This engine's `<data>/…/backends`. */
|
|
@@ -27,10 +38,13 @@ export interface EngineContext {
|
|
|
27
38
|
platform: NodeJS.Platform;
|
|
28
39
|
hardware: () => Promise<Pick<HardwareFacts, 'osType' | 'arch' | 'cpuExtensions' | 'gpus'>>;
|
|
29
40
|
log?: ((level: 'info' | 'warn', message: string) => void) | undefined;
|
|
30
|
-
/** Which
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
41
|
+
/** Which build of this engine the host runs, for the engines that are one archive per platform. */
|
|
42
|
+
hostPlatform: EngineHostPlatform;
|
|
43
|
+
/**
|
|
44
|
+
* This core's own host mode run against an unpacked build (`foundry-host probe`, `litert-host
|
|
45
|
+
* probe`); throws `ENGINE_INSTALL_FAILED` with what it printed. Absent where this core has none.
|
|
46
|
+
*/
|
|
47
|
+
hostProbe?: ((buildDir: string) => Promise<void>) | undefined;
|
|
34
48
|
}
|
|
35
49
|
export interface HostChoice {
|
|
36
50
|
/** What this host would install, best first. */
|
|
@@ -52,6 +66,8 @@ export interface BuildRecordInfo {
|
|
|
52
66
|
publishedAt: string | null;
|
|
53
67
|
/** Foundry Local: the release's C API version. */
|
|
54
68
|
cApiVersion: number | null;
|
|
69
|
+
/** LiteRT-LM: the release's binding number. */
|
|
70
|
+
abi: number | null;
|
|
55
71
|
}
|
|
56
72
|
export interface EngineDescriptor<M> {
|
|
57
73
|
/** The release an install takes from the manifest, and the order key it carries. */
|
|
@@ -59,6 +75,7 @@ export interface EngineDescriptor<M> {
|
|
|
59
75
|
tag: string;
|
|
60
76
|
published_at: string | null;
|
|
61
77
|
c_api_version?: number;
|
|
78
|
+
abi?: number;
|
|
62
79
|
};
|
|
63
80
|
hostChoice(ctx: EngineContext, manifest: M | null): Promise<HostChoice>;
|
|
64
81
|
/** The build's archive first, companions after; all unpack into one directory. */
|
|
@@ -8,9 +8,10 @@ import { AtomicCoreError } from '../contracts/index.js';
|
|
|
8
8
|
import { listInstalledBackends, prepareSdcppTree, writeInstallRecord } from '../diffusion/install.js';
|
|
9
9
|
import { listDownloadedMlx, probeMlxServer, readBundledMlx, writeMlxInstallRecord } from './builds.js';
|
|
10
10
|
import { listFoundryLocalBuilds, prepareFoundryLocalTree, writeFoundryLocalInstallRecord, } from './foundry-local.js';
|
|
11
|
-
import {
|
|
11
|
+
import { listLiteRtLmBuilds, prepareLiteRtLmTree, writeLiteRtLmInstallRecord } from './litert-lm.js';
|
|
12
|
+
import { FOUNDRY_LOCAL_C_API_VERSIONS, foundryLocalAssetUrl, mlxAssetUrl, sdcppAssetUrl, SUPPORTED_LITERT_LM_ABI, } from './manifest.js';
|
|
12
13
|
import { compareBuilds } from './order.js';
|
|
13
|
-
import { backendKindOf, companionFor, foundryLocalHostChoice, mlxHostChoice, readFailedBackends, rememberFailedBackend, sdcppHostChoice, sdcppHostOf, } from './select.js';
|
|
14
|
+
import { backendKindOf, companionFor, foundryLocalHostChoice, liteRtLmHostChoice, mlxHostChoice, readFailedBackends, rememberFailedBackend, sdcppHostChoice, sdcppHostOf, } from './select.js';
|
|
14
15
|
const pin = (asset) => ({
|
|
15
16
|
...(asset.sha256 !== undefined ? { sha256: asset.sha256 } : {}),
|
|
16
17
|
...(asset.size !== undefined ? { size: asset.size } : {}),
|
|
@@ -74,7 +75,7 @@ const mlx = {
|
|
|
74
75
|
.filter((asset) => asset.backend === backendId)
|
|
75
76
|
.map((asset) => ({ ...pin(asset), url: mlxAssetUrl(manifest, asset), name: asset.name })),
|
|
76
77
|
probe: (staging, ctx) => probeMlxServer(staging, { platform: ctx.platform }),
|
|
77
|
-
record: (staging, { cApiVersion: _cApiVersion, ...info }) => writeMlxInstallRecord(staging, info),
|
|
78
|
+
record: (staging, { cApiVersion: _cApiVersion, abi: _abi, ...info }) => writeMlxInstallRecord(staging, info),
|
|
78
79
|
async builds(ctx) {
|
|
79
80
|
const out = (await listDownloadedMlx(ctx.root)).map((record) => ({
|
|
80
81
|
tag: record.tag,
|
|
@@ -107,7 +108,7 @@ const foundryLocal = {
|
|
|
107
108
|
const newest = manifest.releases[0];
|
|
108
109
|
return { tag: newest.tag, published_at: newest.published_at, c_api_version: newest.c_api_version };
|
|
109
110
|
},
|
|
110
|
-
hostChoice: async (ctx, manifest) => foundryLocalHostChoice(ctx.
|
|
111
|
+
hostChoice: async (ctx, manifest) => foundryLocalHostChoice(ctx.hostPlatform, manifest?.releases[0] ?? null),
|
|
111
112
|
archives(manifest, backendId) {
|
|
112
113
|
const release = manifest.releases[0];
|
|
113
114
|
const asset = release?.assets.find((candidate) => candidate.platform === backendId);
|
|
@@ -117,11 +118,11 @@ const foundryLocal = {
|
|
|
117
118
|
},
|
|
118
119
|
prepare: (staging, ctx) => prepareFoundryLocalTree(staging, ctx.platform),
|
|
119
120
|
async probe(staging, ctx) {
|
|
120
|
-
if (!ctx.
|
|
121
|
+
if (!ctx.hostProbe)
|
|
121
122
|
throw new AtomicCoreError('ENGINE_INSTALL_FAILED', 'This core has no Foundry Local host to check the build with.');
|
|
122
|
-
await ctx.
|
|
123
|
+
await ctx.hostProbe(staging);
|
|
123
124
|
},
|
|
124
|
-
record: (staging, info) => writeFoundryLocalInstallRecord(staging, info),
|
|
125
|
+
record: (staging, { abi: _abi, ...info }) => writeFoundryLocalInstallRecord(staging, info),
|
|
125
126
|
async builds(ctx) {
|
|
126
127
|
return (await listFoundryLocalBuilds(ctx.root)).map((record) => ({
|
|
127
128
|
tag: record.tag,
|
|
@@ -136,9 +137,45 @@ const foundryLocal = {
|
|
|
136
137
|
/** The newest by `published_at` among the builds whose C API this core's host binds (design D2). */
|
|
137
138
|
active: (builds) => newest('foundry-local', builds.filter((build) => build.c_api_version != null && FOUNDRY_LOCAL_C_API_VERSIONS.includes(build.c_api_version))),
|
|
138
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* LiteRT-LM (change `add-litert-lm-runtime`, task 4.4): the host's wheel of the newest release; the
|
|
142
|
+
* native part of it goes to `lib/`, `litert-host probe --lib <staging>` of this core proves it loads.
|
|
143
|
+
*/
|
|
144
|
+
const liteRtLm = {
|
|
145
|
+
release: (manifest) => {
|
|
146
|
+
const newest = manifest.releases[0];
|
|
147
|
+
return { tag: newest.version, published_at: newest.published_at, abi: newest.abi };
|
|
148
|
+
},
|
|
149
|
+
hostChoice: async (ctx, manifest) => liteRtLmHostChoice(ctx.hostPlatform, manifest?.releases[0] ?? null),
|
|
150
|
+
archives(manifest, backendId) {
|
|
151
|
+
const asset = manifest.releases[0]?.assets.find((candidate) => candidate.platform === backendId);
|
|
152
|
+
return asset ? [{ url: asset.url, name: asset.name, sha256: asset.sha256, size: asset.size }] : [];
|
|
153
|
+
},
|
|
154
|
+
prepare: (staging) => prepareLiteRtLmTree(staging),
|
|
155
|
+
async probe(staging, ctx) {
|
|
156
|
+
if (!ctx.hostProbe)
|
|
157
|
+
throw new AtomicCoreError('ENGINE_INSTALL_FAILED', 'This core has no LiteRT-LM host to check the build with.');
|
|
158
|
+
await ctx.hostProbe(staging);
|
|
159
|
+
},
|
|
160
|
+
record: (staging, { cApiVersion: _cApiVersion, ...info }) => writeLiteRtLmInstallRecord(staging, info),
|
|
161
|
+
async builds(ctx) {
|
|
162
|
+
return (await listLiteRtLmBuilds(ctx.root)).map((record) => ({
|
|
163
|
+
tag: record.tag,
|
|
164
|
+
backend_id: record.backendId,
|
|
165
|
+
origin: 'downloaded',
|
|
166
|
+
dir: record.dir,
|
|
167
|
+
installed_at_ms: record.installedAtMs,
|
|
168
|
+
published_at: record.publishedAt,
|
|
169
|
+
abi: record.abi,
|
|
170
|
+
}));
|
|
171
|
+
},
|
|
172
|
+
/** The newest by `published_at` among the builds whose ABI this core's host binds (design D2). */
|
|
173
|
+
active: (builds) => newest('litert-lm', builds.filter((build) => build.abi != null && SUPPORTED_LITERT_LM_ABI.includes(build.abi))),
|
|
174
|
+
};
|
|
139
175
|
export const ENGINE_DESCRIPTORS = {
|
|
140
176
|
'sd-cpp': sdcpp,
|
|
141
177
|
'mlx': mlx,
|
|
142
178
|
'foundry-local': foundryLocal,
|
|
179
|
+
'litert-lm': liteRtLm,
|
|
143
180
|
};
|
|
144
181
|
//# sourceMappingURL=engines.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/engine-builds/engines.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAErG,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGtG,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/engine-builds/engines.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAErG,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGtG,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AACpG,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,uBAAuB,GACxB,MAAM,eAAe,CAAA;AAQtB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EACL,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb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AAE,YAAY,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC;IACtG,KAAK,CAAC,MAAM,CAAC,GAAG;QACd,OAAO,CAAC,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC3D,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,UAAU,EAAE,MAAM,CAAC,SAAS;YAC5B,MAAM,EAAE,YAAY;YACpB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,eAAe,EAAE,MAAM,CAAC,aAAa;YACrC,YAAY,EAAE,MAAM,CAAC,WAAW;YAChC,GAAG,EAAE,MAAM,CAAC,GAAG;SAChB,CAAC,CAAC,CAAA;IACL,CAAC;IACD,kGAAkG;IAClG,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CACjB,MAAM,CACJ,WAAW,EACX,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAC3F;CACJ,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAA8D;IAC3F,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,GAAG;IACV,eAAe,EAAE,YAAY;IAC7B,WAAW,EAAE,QAAQ;CACtB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What is particular to LiteRT-LM builds (openspec change `add-litert-lm-runtime`, design D2): a build
|
|
3
|
+
* is a `litert-lm-api` wheel from PyPI, which is a zip. Only the native part of its `litert_lm/`
|
|
4
|
+
* package is kept, under `lib/` — the library, on Windows its DirectX companions and the Intel NPU
|
|
5
|
+
* dispatch library under `vendors/` — without the Python bindings and `*.dist-info` (task 4.2). Each
|
|
6
|
+
* build records the `abi` it was published with, which decides whether this core's host binds it.
|
|
7
|
+
*/
|
|
8
|
+
/** The library's file name on `platform`; `null` where LiteRT-LM has none. */
|
|
9
|
+
export declare function liteRtLmLibraryFile(platform: NodeJS.Platform): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Turn an unpacked wheel into a build: the native files of `litert_lm/` move to `lib/` with their
|
|
12
|
+
* relative paths, everything else goes. Wheels carry `0777`; libraries become `0755`. Throws
|
|
13
|
+
* `ENGINE_INSTALL_FAILED` when the wheel holds no LiteRT-LM library at all.
|
|
14
|
+
*/
|
|
15
|
+
export declare function prepareLiteRtLmTree(staging: string): Promise<void>;
|
|
16
|
+
export interface LiteRtLmInstallRecord {
|
|
17
|
+
/** The LiteRT-LM version, `X.Y.Z`. */
|
|
18
|
+
tag: string;
|
|
19
|
+
backendId: string;
|
|
20
|
+
sha256: string | null;
|
|
21
|
+
installedAtMs: number;
|
|
22
|
+
publishedAt: string | null;
|
|
23
|
+
abi: number | null;
|
|
24
|
+
dir: string;
|
|
25
|
+
}
|
|
26
|
+
/** The marker, then `install.json` without `dir`. */
|
|
27
|
+
export declare function writeLiteRtLmInstallRecord(dir: string, record: Omit<LiteRtLmInstallRecord, 'dir'>): Promise<void>;
|
|
28
|
+
/** Every marked `<root>/<version>/<platform>/` with a record and its library, newest install first. */
|
|
29
|
+
export declare function listLiteRtLmBuilds(root: string): Promise<LiteRtLmInstallRecord[]>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What is particular to LiteRT-LM builds (openspec change `add-litert-lm-runtime`, design D2): a build
|
|
3
|
+
* is a `litert-lm-api` wheel from PyPI, which is a zip. Only the native part of its `litert_lm/`
|
|
4
|
+
* package is kept, under `lib/` — the library, on Windows its DirectX companions and the Intel NPU
|
|
5
|
+
* dispatch library under `vendors/` — without the Python bindings and `*.dist-info` (task 4.2). Each
|
|
6
|
+
* build records the `abi` it was published with, which decides whether this core's host binds it.
|
|
7
|
+
*/
|
|
8
|
+
import { chmod, mkdir, readdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { dirname, join, relative } from 'node:path';
|
|
10
|
+
import { AtomicCoreError } from '../contracts/index.js';
|
|
11
|
+
import { INSTALL_RECORD, OWNER_MARKER } from '../diffusion/install.js';
|
|
12
|
+
import { isDateTime } from './manifest.js';
|
|
13
|
+
/** The wheel's package; everything else in it is Python metadata. */
|
|
14
|
+
const PACKAGE_DIR = 'litert_lm';
|
|
15
|
+
/** Native files of the package: libraries anywhere, and every file under `vendors/`. */
|
|
16
|
+
const NATIVE_RE = /\.(dylib|so|dll)$/;
|
|
17
|
+
const LIBRARY_FILE = {
|
|
18
|
+
darwin: 'liblitert-lm.dylib',
|
|
19
|
+
linux: 'liblitert-lm.so',
|
|
20
|
+
win32: 'litert-lm.dll',
|
|
21
|
+
};
|
|
22
|
+
/** The library's file name on `platform`; `null` where LiteRT-LM has none. */
|
|
23
|
+
export function liteRtLmLibraryFile(platform) {
|
|
24
|
+
return LIBRARY_FILE[platform] ?? null;
|
|
25
|
+
}
|
|
26
|
+
const exists = (path) => stat(path).then(() => true, () => false);
|
|
27
|
+
async function nativeFiles(dir, at = dir) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const entry of await readdir(at, { withFileTypes: true })) {
|
|
30
|
+
const path = join(at, entry.name);
|
|
31
|
+
const rel = relative(dir, path).split('\\').join('/');
|
|
32
|
+
if (entry.isDirectory())
|
|
33
|
+
out.push(...(await nativeFiles(dir, path)));
|
|
34
|
+
else if (rel.startsWith('vendors/') || NATIVE_RE.test(entry.name))
|
|
35
|
+
out.push(rel);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Turn an unpacked wheel into a build: the native files of `litert_lm/` move to `lib/` with their
|
|
41
|
+
* relative paths, everything else goes. Wheels carry `0777`; libraries become `0755`. Throws
|
|
42
|
+
* `ENGINE_INSTALL_FAILED` when the wheel holds no LiteRT-LM library at all.
|
|
43
|
+
*/
|
|
44
|
+
export async function prepareLiteRtLmTree(staging) {
|
|
45
|
+
const pkg = join(staging, PACKAGE_DIR);
|
|
46
|
+
const keep = (await exists(pkg)) ? await nativeFiles(pkg) : [];
|
|
47
|
+
if (!keep.some((rel) => Object.values(LIBRARY_FILE).includes(rel)))
|
|
48
|
+
throw new AtomicCoreError('ENGINE_INSTALL_FAILED', 'The LiteRT-LM wheel holds no LiteRT-LM library.');
|
|
49
|
+
const lib = join(staging, 'lib');
|
|
50
|
+
for (const rel of keep) {
|
|
51
|
+
const to = join(lib, rel);
|
|
52
|
+
await mkdir(dirname(to), { recursive: true });
|
|
53
|
+
await rename(join(pkg, rel), to);
|
|
54
|
+
await chmod(to, 0o755).catch(() => { });
|
|
55
|
+
}
|
|
56
|
+
for (const name of await readdir(staging))
|
|
57
|
+
if (name !== 'lib')
|
|
58
|
+
await rm(join(staging, name), { recursive: true, force: true });
|
|
59
|
+
}
|
|
60
|
+
/** The marker, then `install.json` without `dir`. */
|
|
61
|
+
export async function writeLiteRtLmInstallRecord(dir, record) {
|
|
62
|
+
await writeFile(join(dir, OWNER_MARKER), 'atomic-chat\n');
|
|
63
|
+
const file = {
|
|
64
|
+
tag: record.tag,
|
|
65
|
+
backendId: record.backendId,
|
|
66
|
+
sha256: record.sha256,
|
|
67
|
+
installedAtMs: record.installedAtMs,
|
|
68
|
+
publishedAt: record.publishedAt,
|
|
69
|
+
abi: record.abi,
|
|
70
|
+
};
|
|
71
|
+
await writeFile(join(dir, INSTALL_RECORD), JSON.stringify(file, null, 2));
|
|
72
|
+
}
|
|
73
|
+
async function readLiteRtLmInstallRecord(dir) {
|
|
74
|
+
let raw;
|
|
75
|
+
try {
|
|
76
|
+
raw = JSON.parse(await readFile(join(dir, INSTALL_RECORD), 'utf8'));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
|
|
82
|
+
return undefined;
|
|
83
|
+
const { tag, backendId, sha256, installedAtMs, publishedAt, abi } = raw;
|
|
84
|
+
if (typeof tag !== 'string' ||
|
|
85
|
+
typeof backendId !== 'string' ||
|
|
86
|
+
typeof installedAtMs !== 'number' ||
|
|
87
|
+
!Number.isSafeInteger(installedAtMs))
|
|
88
|
+
return undefined;
|
|
89
|
+
return {
|
|
90
|
+
tag,
|
|
91
|
+
backendId,
|
|
92
|
+
sha256: typeof sha256 === 'string' ? sha256 : null,
|
|
93
|
+
installedAtMs,
|
|
94
|
+
publishedAt: isDateTime(publishedAt) ? publishedAt : null,
|
|
95
|
+
abi: typeof abi === 'number' && Number.isSafeInteger(abi) ? abi : null,
|
|
96
|
+
dir,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async function hasLibrary(dir) {
|
|
100
|
+
for (const name of Object.values(LIBRARY_FILE))
|
|
101
|
+
if (await exists(join(dir, 'lib', name)))
|
|
102
|
+
return true;
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
/** Every marked `<root>/<version>/<platform>/` with a record and its library, newest install first. */
|
|
106
|
+
export async function listLiteRtLmBuilds(root) {
|
|
107
|
+
const out = [];
|
|
108
|
+
for (const tag of await readdir(root).catch(() => []))
|
|
109
|
+
for (const backend of await readdir(join(root, tag)).catch(() => [])) {
|
|
110
|
+
const dir = join(root, tag, backend);
|
|
111
|
+
if (!(await exists(join(dir, OWNER_MARKER))))
|
|
112
|
+
continue;
|
|
113
|
+
const record = await readLiteRtLmInstallRecord(dir);
|
|
114
|
+
if (record && (await hasLibrary(dir)))
|
|
115
|
+
out.push(record);
|
|
116
|
+
}
|
|
117
|
+
return out.sort((a, b) => b.installedAtMs - a.installedAtMs);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=litert-lm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"litert-lm.js","sourceRoot":"","sources":["../../src/engine-builds/litert-lm.ts"],"names":[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C,EAAc,CAAC;QAC/D,KAAK,MAAM,OAAO,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAc,CAAC,EAAE,CAAC;YACjF,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;YACpC,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;gBAAE,SAAQ;YACtD,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,GAAG,CAAC,CAAA;YACnD,IAAI,MAAM,IAAI,CAAC,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACzD,CAAC;IACH,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC,CAAA;AAC9D,CAAC"}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* (stable-diffusion.cpp, which the desktop used to read itself) and `backends/mlx-manifest.json`
|
|
4
4
|
* (the mlx-vlm fork's `mlx-server`), openspec change `move-sdcpp-mlx-install-to-core` design D6;
|
|
5
5
|
* `backends/foundry-local-manifest.json` (Microsoft Foundry Local releases), change
|
|
6
|
-
* `add-foundry-local` design D2.
|
|
6
|
+
* `add-foundry-local` design D2; `backends/litert-lm-manifest.json` (Google's LiteRT-LM wheels on PyPI),
|
|
7
|
+
* change `add-litert-lm-runtime` design D2.
|
|
7
8
|
*
|
|
8
9
|
* The source follows the house pattern of `PrismCatalogService` and `cached-document.ts`: conf main
|
|
9
10
|
* over `fetch` with an 8 s budget and the request's proxy, an `ATOMIC_*_MANIFEST_URL` override that
|
|
@@ -23,9 +24,15 @@ import type { EngineBuildId, ProxyConfig } from '../contracts/index.js';
|
|
|
23
24
|
* against another one is not offered.
|
|
24
25
|
*/
|
|
25
26
|
export declare const FOUNDRY_LOCAL_C_API_VERSIONS: readonly number[];
|
|
27
|
+
/**
|
|
28
|
+
* The `abi` numbers this core's `litert-host` binds (change `add-litert-lm-runtime`, design D2). The
|
|
29
|
+
* number is ours, not Google's: it moves when the C functions `ffi-bun.ts` reads change.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SUPPORTED_LITERT_LM_ABI: readonly number[];
|
|
26
32
|
export declare const SDCPP_MANIFEST_URL = "https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/sdcpp-manifest.json";
|
|
27
33
|
export declare const MLX_MANIFEST_URL = "https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/mlx-manifest.json";
|
|
28
34
|
export declare const FOUNDRY_LOCAL_MANIFEST_URL = "https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/foundry-local-manifest.json";
|
|
35
|
+
export declare const LITERT_LM_MANIFEST_URL = "https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/litert-lm-manifest.json";
|
|
29
36
|
export declare const ENGINE_MANIFEST_TIMEOUT_MS = 8000;
|
|
30
37
|
/** A fetched manifest is reused for this long unless the caller forces a re-read. */
|
|
31
38
|
export declare const ENGINE_MANIFEST_TTL_MS: number;
|
|
@@ -90,6 +97,46 @@ export interface FoundryLocalAcceptance {
|
|
|
90
97
|
/** The C API versions this core's `foundry-host` speaks. */
|
|
91
98
|
cApiVersions: readonly number[];
|
|
92
99
|
}
|
|
100
|
+
export declare const LITERT_LM_PLATFORMS: readonly ["macos-arm64", "linux-x64", "linux-arm64", "win-x64"];
|
|
101
|
+
export type LiteRtLmPlatform = (typeof LITERT_LM_PLATFORMS)[number];
|
|
102
|
+
/** One `litert-lm-api` wheel. The URL is explicit: PyPI paths carry hash folders (design D2). */
|
|
103
|
+
export interface LiteRtLmAsset {
|
|
104
|
+
platform: LiteRtLmPlatform;
|
|
105
|
+
url: string;
|
|
106
|
+
name: string;
|
|
107
|
+
size: number;
|
|
108
|
+
sha256: string;
|
|
109
|
+
}
|
|
110
|
+
/** The `openvino` wheel an Intel NPU variant needs (design D3); only `win-x64`. */
|
|
111
|
+
export interface LiteRtLmAccelerator {
|
|
112
|
+
id: 'openvino';
|
|
113
|
+
platform: 'win-x64';
|
|
114
|
+
version: string;
|
|
115
|
+
url: string;
|
|
116
|
+
name: string;
|
|
117
|
+
size: number;
|
|
118
|
+
sha256: string;
|
|
119
|
+
}
|
|
120
|
+
export interface LiteRtLmRelease {
|
|
121
|
+
/** Google's LiteRT-LM version, `X.Y.Z`. */
|
|
122
|
+
version: string;
|
|
123
|
+
/** The order builds of this engine have. */
|
|
124
|
+
published_at: string;
|
|
125
|
+
min_core_version: string;
|
|
126
|
+
/** Our binding number; see `SUPPORTED_LITERT_LM_ABI`. */
|
|
127
|
+
abi: number;
|
|
128
|
+
notes_url?: string;
|
|
129
|
+
assets: LiteRtLmAsset[];
|
|
130
|
+
accelerators: LiteRtLmAccelerator[];
|
|
131
|
+
}
|
|
132
|
+
/** The releases this core can install, newest first; never empty. */
|
|
133
|
+
export interface LiteRtLmManifest {
|
|
134
|
+
releases: LiteRtLmRelease[];
|
|
135
|
+
}
|
|
136
|
+
export interface LiteRtLmAcceptance {
|
|
137
|
+
coreVersion: string;
|
|
138
|
+
abis: readonly number[];
|
|
139
|
+
}
|
|
93
140
|
/** A conf date-time this core can order by: RFC 3339 shape and a real calendar date. */
|
|
94
141
|
export declare function isDateTime(value: unknown): value is string;
|
|
95
142
|
/** `backends/sdcpp-manifest.json`, or throw why it is not one. */
|
|
@@ -103,6 +150,12 @@ export declare function parseMlxManifest(data: unknown): MlxManifest;
|
|
|
103
150
|
* schema version, a document without a valid repository, or no release left to install.
|
|
104
151
|
*/
|
|
105
152
|
export declare function parseFoundryLocalManifest(data: unknown, accept: FoundryLocalAcceptance): FoundryLocalManifest;
|
|
153
|
+
/**
|
|
154
|
+
* `backends/litert-lm-manifest.json`: strict per field, lenient per record — a release, wheel or
|
|
155
|
+
* accelerator that does not parse is skipped, as is a release for a newer core or an `abi` this core
|
|
156
|
+
* does not bind (spec `litert-lm-runtime`). Throws for another schema version or no release left.
|
|
157
|
+
*/
|
|
158
|
+
export declare function parseLiteRtLmManifest(data: unknown, accept: LiteRtLmAcceptance): LiteRtLmManifest;
|
|
106
159
|
/** An asset core may download and run: pinned by both `sha256` and `size`. */
|
|
107
160
|
export declare function assetInstallable(asset: {
|
|
108
161
|
sha256?: string;
|
|
@@ -125,6 +178,7 @@ export interface ManifestOf {
|
|
|
125
178
|
'sd-cpp': SdcppManifest;
|
|
126
179
|
'mlx': MlxManifest;
|
|
127
180
|
'foundry-local': FoundryLocalManifest;
|
|
181
|
+
'litert-lm': LiteRtLmManifest;
|
|
128
182
|
}
|
|
129
183
|
export declare function manifestKinds(layout: DataLayout): {
|
|
130
184
|
[K in EngineBuildId]: ManifestKind<ManifestOf[K]>;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* (stable-diffusion.cpp, which the desktop used to read itself) and `backends/mlx-manifest.json`
|
|
4
4
|
* (the mlx-vlm fork's `mlx-server`), openspec change `move-sdcpp-mlx-install-to-core` design D6;
|
|
5
5
|
* `backends/foundry-local-manifest.json` (Microsoft Foundry Local releases), change
|
|
6
|
-
* `add-foundry-local` design D2.
|
|
6
|
+
* `add-foundry-local` design D2; `backends/litert-lm-manifest.json` (Google's LiteRT-LM wheels on PyPI),
|
|
7
|
+
* change `add-litert-lm-runtime` design D2.
|
|
7
8
|
*
|
|
8
9
|
* The source follows the house pattern of `PrismCatalogService` and `cached-document.ts`: conf main
|
|
9
10
|
* over `fetch` with an 8 s budget and the request's proxy, an `ATOMIC_*_MANIFEST_URL` override that
|
|
@@ -26,9 +27,15 @@ import { CORE_VERSION } from '../version.js';
|
|
|
26
27
|
* against another one is not offered.
|
|
27
28
|
*/
|
|
28
29
|
export const FOUNDRY_LOCAL_C_API_VERSIONS = [2];
|
|
30
|
+
/**
|
|
31
|
+
* The `abi` numbers this core's `litert-host` binds (change `add-litert-lm-runtime`, design D2). The
|
|
32
|
+
* number is ours, not Google's: it moves when the C functions `ffi-bun.ts` reads change.
|
|
33
|
+
*/
|
|
34
|
+
export const SUPPORTED_LITERT_LM_ABI = [1];
|
|
29
35
|
export const SDCPP_MANIFEST_URL = 'https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/sdcpp-manifest.json';
|
|
30
36
|
export const MLX_MANIFEST_URL = 'https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/mlx-manifest.json';
|
|
31
37
|
export const FOUNDRY_LOCAL_MANIFEST_URL = 'https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/foundry-local-manifest.json';
|
|
38
|
+
export const LITERT_LM_MANIFEST_URL = 'https://raw.githubusercontent.com/AtomicBot-ai/atomic-chat-conf/main/backends/litert-lm-manifest.json';
|
|
32
39
|
export const ENGINE_MANIFEST_TIMEOUT_MS = 8_000;
|
|
33
40
|
/** A fetched manifest is reused for this long unless the caller forces a re-read. */
|
|
34
41
|
export const ENGINE_MANIFEST_TTL_MS = 60 * 60 * 1000;
|
|
@@ -40,6 +47,7 @@ export const FOUNDRY_LOCAL_PLATFORMS = [
|
|
|
40
47
|
'linux-x64',
|
|
41
48
|
'linux-arm64',
|
|
42
49
|
];
|
|
50
|
+
export const LITERT_LM_PLATFORMS = ['macos-arm64', 'linux-x64', 'linux-arm64', 'win-x64'];
|
|
43
51
|
const SDCPP_TAG_RE = /^master-[0-9]+-[0-9a-f]{7}(-a[0-9a-f]{7})?$/;
|
|
44
52
|
const MLX_TAG_RE = /^mlxvlm-macos-arm64-[0-9a-f]{7,40}$/;
|
|
45
53
|
const BACKEND_ID_RE = /^[a-z0-9.-]+$/;
|
|
@@ -48,6 +56,9 @@ const ASSET_NAME_RE = /^[A-Za-z0-9._-]+\.(zip|tar\.gz|tgz)$/;
|
|
|
48
56
|
const FOUNDRY_LOCAL_TAG_RE = /^v\d+\.\d+\.\d+$/;
|
|
49
57
|
const FOUNDRY_LOCAL_ASSET_NAME_RE = /^foundry-local-[a-z0-9-]+\.(zip|tgz)$/;
|
|
50
58
|
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
59
|
+
const PYPI_URL_RE = /^https:\/\/files\.pythonhosted\.org\/\S+$/;
|
|
60
|
+
const LITERT_LM_WHEEL_RE = /^litert_lm_api-[0-9.]+-[A-Za-z0-9._-]+\.whl$/;
|
|
61
|
+
const OPENVINO_WHEEL_RE = /^openvino-[A-Za-z0-9._-]+\.whl$/;
|
|
51
62
|
const REPO_RE = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
|
|
52
63
|
const SHA256_RE = /^[0-9a-f]{64}$/;
|
|
53
64
|
/** RFC 3339 with a zone; `Date.parse` alone accepts far more. */
|
|
@@ -211,6 +222,101 @@ export function parseFoundryLocalManifest(data, accept) {
|
|
|
211
222
|
throw new Error(`the Foundry Local manifest lists no release this core can install (core ${accept.coreVersion}, C API ${accept.cApiVersions.join('/')})`);
|
|
212
223
|
return { upstream_repo: repo, releases };
|
|
213
224
|
}
|
|
225
|
+
/** The fields every wheel shares, or `null`; the URL must end in the name it downloads as. */
|
|
226
|
+
function parseWheel(raw, nameRe) {
|
|
227
|
+
const { url, name, size, sha256 } = raw;
|
|
228
|
+
if (typeof name !== 'string' || !nameRe.test(name))
|
|
229
|
+
return null;
|
|
230
|
+
if (typeof url !== 'string' || !PYPI_URL_RE.test(url) || !url.endsWith(`/${name}`))
|
|
231
|
+
return null;
|
|
232
|
+
if (typeof size !== 'number' || !Number.isSafeInteger(size) || size <= 0)
|
|
233
|
+
return null;
|
|
234
|
+
if (typeof sha256 !== 'string' || !SHA256_RE.test(sha256))
|
|
235
|
+
return null;
|
|
236
|
+
return { url, name, size, sha256 };
|
|
237
|
+
}
|
|
238
|
+
function parseLiteRtLmAsset(raw) {
|
|
239
|
+
if (!isRecord(raw))
|
|
240
|
+
return null;
|
|
241
|
+
const platform = raw['platform'];
|
|
242
|
+
if (!LITERT_LM_PLATFORMS.some((known) => known === platform))
|
|
243
|
+
return null;
|
|
244
|
+
const wheel = parseWheel(raw, LITERT_LM_WHEEL_RE);
|
|
245
|
+
return wheel ? { platform: platform, ...wheel } : null;
|
|
246
|
+
}
|
|
247
|
+
function parseLiteRtLmAccelerator(raw) {
|
|
248
|
+
if (!isRecord(raw))
|
|
249
|
+
return null;
|
|
250
|
+
const { id, platform, version } = raw;
|
|
251
|
+
if (id !== 'openvino' || platform !== 'win-x64')
|
|
252
|
+
return null;
|
|
253
|
+
if (typeof version !== 'string' || !SEMVER_RE.test(version))
|
|
254
|
+
return null;
|
|
255
|
+
const wheel = parseWheel(raw, OPENVINO_WHEEL_RE);
|
|
256
|
+
return wheel ? { id, platform, version, ...wheel } : null;
|
|
257
|
+
}
|
|
258
|
+
/** One release, or `null` when a field is not what the conf schema says. */
|
|
259
|
+
function parseLiteRtLmRelease(raw) {
|
|
260
|
+
if (!isRecord(raw))
|
|
261
|
+
return null;
|
|
262
|
+
const { version, published_at, min_core_version, abi, notes_url } = raw;
|
|
263
|
+
if (typeof version !== 'string' || !SEMVER_RE.test(version))
|
|
264
|
+
return null;
|
|
265
|
+
if (!isDateTime(published_at))
|
|
266
|
+
return null;
|
|
267
|
+
if (typeof min_core_version !== 'string' || !SEMVER_RE.test(min_core_version))
|
|
268
|
+
return null;
|
|
269
|
+
if (typeof abi !== 'number' || !Number.isSafeInteger(abi) || abi < 1)
|
|
270
|
+
return null;
|
|
271
|
+
if (!Array.isArray(raw['assets']))
|
|
272
|
+
return null;
|
|
273
|
+
const assets = [];
|
|
274
|
+
for (const item of raw['assets']) {
|
|
275
|
+
const asset = parseLiteRtLmAsset(item);
|
|
276
|
+
if (asset && !assets.some((known) => known.platform === asset.platform))
|
|
277
|
+
assets.push(asset);
|
|
278
|
+
}
|
|
279
|
+
if (assets.length === 0)
|
|
280
|
+
return null;
|
|
281
|
+
const accelerators = [];
|
|
282
|
+
for (const item of Array.isArray(raw['accelerators']) ? raw['accelerators'] : []) {
|
|
283
|
+
const accelerator = parseLiteRtLmAccelerator(item);
|
|
284
|
+
// conf's check refuses an id listed twice; here the first one wins.
|
|
285
|
+
if (accelerator && !accelerators.some((known) => known.id === accelerator.id))
|
|
286
|
+
accelerators.push(accelerator);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
version,
|
|
290
|
+
published_at,
|
|
291
|
+
min_core_version,
|
|
292
|
+
abi,
|
|
293
|
+
...(typeof notes_url === 'string' && /^https:\/\/\S+$/.test(notes_url) ? { notes_url } : {}),
|
|
294
|
+
assets,
|
|
295
|
+
accelerators,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* `backends/litert-lm-manifest.json`: strict per field, lenient per record — a release, wheel or
|
|
300
|
+
* accelerator that does not parse is skipped, as is a release for a newer core or an `abi` this core
|
|
301
|
+
* does not bind (spec `litert-lm-runtime`). Throws for another schema version or no release left.
|
|
302
|
+
*/
|
|
303
|
+
export function parseLiteRtLmManifest(data, accept) {
|
|
304
|
+
if (!isRecord(data))
|
|
305
|
+
throw new Error('the LiteRT-LM manifest is not an object');
|
|
306
|
+
if (data['schema_version'] !== 1)
|
|
307
|
+
throw new Error(`the LiteRT-LM manifest has schema_version ${JSON.stringify(data['schema_version'])}, not 1`);
|
|
308
|
+
if (!Array.isArray(data['releases']))
|
|
309
|
+
throw new Error('the LiteRT-LM manifest has no releases array');
|
|
310
|
+
const releases = data['releases']
|
|
311
|
+
.map(parseLiteRtLmRelease)
|
|
312
|
+
.filter((release) => release !== null)
|
|
313
|
+
.filter((release) => compareVersions(release.min_core_version, accept.coreVersion) <= 0 &&
|
|
314
|
+
accept.abis.includes(release.abi))
|
|
315
|
+
.sort((a, b) => Date.parse(b.published_at) - Date.parse(a.published_at));
|
|
316
|
+
if (releases.length === 0)
|
|
317
|
+
throw new Error(`the LiteRT-LM manifest lists no release this core can install (core ${accept.coreVersion}, ABI ${accept.abis.join('/')})`);
|
|
318
|
+
return { releases };
|
|
319
|
+
}
|
|
214
320
|
/** An asset core may download and run: pinned by both `sha256` and `size`. */
|
|
215
321
|
export function assetInstallable(asset) {
|
|
216
322
|
return typeof asset.sha256 === 'string' && typeof asset.size === 'number';
|
|
@@ -254,6 +360,13 @@ export function manifestKinds(layout) {
|
|
|
254
360
|
}),
|
|
255
361
|
cacheFile: join(layout.provider('foundry-local').root, 'foundry-local-manifest.cache.json'),
|
|
256
362
|
},
|
|
363
|
+
'litert-lm': {
|
|
364
|
+
label: 'LiteRT-LM manifest',
|
|
365
|
+
url: LITERT_LM_MANIFEST_URL,
|
|
366
|
+
urlEnv: 'ATOMIC_LITERT_LM_MANIFEST_URL',
|
|
367
|
+
parse: (data) => parseLiteRtLmManifest(data, { coreVersion: CORE_VERSION, abis: SUPPORTED_LITERT_LM_ABI }),
|
|
368
|
+
cacheFile: join(layout.provider('litert-lm').root, 'litert-lm-manifest.cache.json'),
|
|
369
|
+
},
|
|
257
370
|
};
|
|
258
371
|
}
|
|
259
372
|
export class EngineManifestSource {
|