@koed-labs/server 0.10.3 → 1.0.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/README.md +3 -3
- package/bin/koed.js +1 -1
- package/package.json +2 -2
- package/vendor/chunk-273NMYXE.js +605 -0
- package/vendor/{chunk-VPC5NLZG.js → chunk-4DHYSJJT.js} +1 -1
- package/vendor/{chunk-HK2H3MVE.js → chunk-53ZFCDHP.js} +4 -0
- package/vendor/{chunk-YCDEMYY6.js → chunk-54UL4U2E.js} +261 -110
- package/vendor/{chunk-X6M525ZJ.js → chunk-64AST7WZ.js} +5 -5
- package/vendor/{chunk-JKOG52PE.js → chunk-7FSHVVTZ.js} +1 -1
- package/vendor/chunk-7HLNJ2BI.js +1669 -0
- package/vendor/chunk-ALJUSOF7.js +175 -0
- package/vendor/{chunk-A6WMU2GG.js → chunk-AOZ3LMTF.js} +5 -4
- package/vendor/{chunk-KUIWH33N.js → chunk-AVQCUFYQ.js} +1 -1
- package/vendor/{chunk-JJNLH5GA.js → chunk-BYN6KXNP.js} +21 -19
- package/vendor/{chunk-PY5LYLV7.js → chunk-DWWMBGHX.js} +26 -21
- package/vendor/chunk-E6YVGIEW.js +12518 -0
- package/vendor/{chunk-C3N4N5HR.js → chunk-EEBIYWTE.js} +26 -21
- package/vendor/{chunk-YOFI4PCH.js → chunk-F77ZTTNS.js} +7 -1
- package/vendor/{chunk-RVYJKKWA.js → chunk-F7AMEDDU.js} +5 -4
- package/vendor/{chunk-473OA62O.js → chunk-FSNLU46W.js} +218 -12497
- package/vendor/{chunk-2S3OGPUC.js → chunk-GY5GATZL.js} +2 -2
- package/vendor/chunk-ILQVLZ2I.js +50 -0
- package/vendor/{chunk-QIIKMG3M.js → chunk-IY2HRXOZ.js} +1 -5
- package/vendor/{chunk-ZUGNCQZE.js → chunk-JYK6UL6D.js} +22 -8
- package/vendor/chunk-KG3RANR4.js +75 -0
- package/vendor/{chunk-YJ6XUZT6.js → chunk-KRBZZ6GS.js} +23 -16
- package/vendor/{chunk-AFLKCQHF.js → chunk-L4RD3TAZ.js} +2 -2
- package/vendor/{chunk-XNFVSVBS.js → chunk-LHUMBHG7.js} +1 -1
- package/vendor/{chunk-J2L726BC.js → chunk-NGV45YWB.js} +3 -3
- package/vendor/{chunk-A4NKL2PK.js → chunk-OG7G6DIR.js} +1 -1
- package/vendor/{chunk-DXTAWHY3.js → chunk-OZU6JFB4.js} +8 -7
- package/vendor/chunk-QV3WPU7A.js +8 -0
- package/vendor/{chunk-ZXX4ZNJY.js → chunk-S6HD3MDU.js} +3 -2
- package/vendor/{chunk-NEWIOOM6.js → chunk-SQZ2OSP6.js} +3 -2
- package/vendor/{chunk-G4IIVVJO.js → chunk-T6UB5PNX.js} +70 -2
- package/vendor/{chunk-SKVYP7NY.js → chunk-T7OGE5E5.js} +8 -8
- package/vendor/{chunk-GELDEJJ2.js → chunk-TIBYKMRW.js} +173 -51
- package/vendor/{chunk-HFM6ROJL.js → chunk-TISYUUEJ.js} +1 -1
- package/vendor/{chunk-K2EIFEQF.js → chunk-TSAYTRX3.js} +1 -1
- package/vendor/{chunk-PT3AUPGE.js → chunk-UB6JCVQ3.js} +3 -1
- package/vendor/{chunk-NM5NXCVM.js → chunk-UCOHFZ77.js} +626 -996
- package/vendor/{chunk-2BWTLF7A.js → chunk-UIMUUIH7.js} +45 -21
- package/vendor/{chunk-HZJK5RWC.js → chunk-USHFSJT7.js} +695 -280
- package/vendor/chunk-VGL5AZN5.js +152 -0
- package/vendor/{chunk-TSRPHKAC.js → chunk-VLP72QWX.js} +16 -42
- package/vendor/chunk-W6632NOX.js +14 -0
- package/vendor/{chunk-YJWREXN6.js → chunk-WBMO7YCO.js} +1 -1
- package/vendor/chunk-XCO3RV3Z.js +11 -0
- package/vendor/chunk-XKXSC6YS.js +373 -0
- package/vendor/{chunk-YK4F4VY2.js → chunk-Y6GE52OP.js} +51 -30
- package/vendor/{chunk-UI5RLBKQ.js → chunk-YZLQZU5E.js} +17 -1
- package/vendor/chunk-ZKKWLLPU.js +18 -0
- package/vendor/cli.js +1 -1
- package/vendor/component-manifest-catalog.js +2 -1
- package/vendor/control-plane.js +11 -6
- package/vendor/chunk-2DA7EFZV.js +0 -924
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
productionNativeRuntimeCatalog
|
|
4
|
+
} from "./chunk-QV3WPU7A.js";
|
|
5
|
+
import {
|
|
6
|
+
external_exports
|
|
7
|
+
} from "./chunk-FSNLU46W.js";
|
|
8
|
+
|
|
9
|
+
// packages/koed-server/dist/native-runtime-catalog.js
|
|
10
|
+
var digest = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
11
|
+
var version = external_exports.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/).refine((value) => value.split(".").every((part) => Number.isSafeInteger(Number(part))));
|
|
12
|
+
var target = external_exports.object({
|
|
13
|
+
platform: external_exports.literal("linux"),
|
|
14
|
+
architecture: external_exports.literal("x64"),
|
|
15
|
+
libc: external_exports.object({ family: external_exports.literal("glibc"), minimumVersion: external_exports.literal("2.35") }).strict()
|
|
16
|
+
}).strict();
|
|
17
|
+
var llamaCpp = external_exports.object({
|
|
18
|
+
version: external_exports.string().regex(/^b\d+$/),
|
|
19
|
+
revision: external_exports.string().regex(/^[a-f0-9]{40}$/)
|
|
20
|
+
}).strict();
|
|
21
|
+
var contracts = external_exports.object({ layout: external_exports.literal(1), embedding: external_exports.literal(1) }).strict();
|
|
22
|
+
var shared = {
|
|
23
|
+
recipeId: digest,
|
|
24
|
+
runtimeVersion: version,
|
|
25
|
+
url: external_exports.string(),
|
|
26
|
+
sha256: digest,
|
|
27
|
+
manifestSha256: digest,
|
|
28
|
+
target
|
|
29
|
+
};
|
|
30
|
+
var size = (maximum) => external_exports.number().int().positive().max(maximum);
|
|
31
|
+
var retainedUrl = (kind, pin) => {
|
|
32
|
+
const prefix = "https://github.com/koed-labs/koed/releases/download/";
|
|
33
|
+
const [tag, archive, ...extra] = pin.url.slice(prefix.length).split("/");
|
|
34
|
+
return pin.url.startsWith(prefix) && extra.length === 0 && archive === `koed-native-${kind}-${pin.recipeId}-linux-x64.tar.gz` && (tag === `native-${kind}-${pin.recipeId}` || /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(tag ?? ""));
|
|
35
|
+
};
|
|
36
|
+
var corePin = external_exports.object({
|
|
37
|
+
...shared,
|
|
38
|
+
archiveBytes: size(5e7),
|
|
39
|
+
expandedBytes: size(1e8),
|
|
40
|
+
contracts: contracts.extend({ postgres: external_exports.literal(1) }),
|
|
41
|
+
components: external_exports.object({
|
|
42
|
+
postgres: external_exports.object({
|
|
43
|
+
major: external_exports.literal(17),
|
|
44
|
+
version: external_exports.string().regex(/^17\.\d+$/)
|
|
45
|
+
}).strict(),
|
|
46
|
+
pgvector: external_exports.object({ version: external_exports.literal("0.8.3") }).strict(),
|
|
47
|
+
llamaCpp
|
|
48
|
+
}).strict()
|
|
49
|
+
}).strict().refine((pin) => retainedUrl("core", pin), "Native core URL does not identify the retained recipe release.");
|
|
50
|
+
var cudaPin = external_exports.object({
|
|
51
|
+
...shared,
|
|
52
|
+
archiveBytes: size(75e7),
|
|
53
|
+
expandedBytes: size(16e8),
|
|
54
|
+
contracts,
|
|
55
|
+
llamaCpp,
|
|
56
|
+
cuda: external_exports.object({
|
|
57
|
+
toolkitVersion: external_exports.literal("12.4"),
|
|
58
|
+
minimumDriverLinux: external_exports.literal("550.54.14"),
|
|
59
|
+
architectures: external_exports.array(external_exports.union([
|
|
60
|
+
external_exports.literal(75),
|
|
61
|
+
external_exports.literal(80),
|
|
62
|
+
external_exports.literal(86),
|
|
63
|
+
external_exports.literal(89),
|
|
64
|
+
external_exports.literal(90)
|
|
65
|
+
])).min(1).max(5).refine((values) => new Set(values).size === values.length)
|
|
66
|
+
}).strict()
|
|
67
|
+
}).strict().refine((pin) => retainedUrl("cuda", pin), "Native CUDA URL does not identify the retained recipe release.");
|
|
68
|
+
var nativeKind = (pin) => "components" in pin ? "core" : "cuda";
|
|
69
|
+
var compatibleCuda = (core, cuda) => core.target.platform === "linux" && "revision" in core.components.llamaCpp && core.components.llamaCpp.revision === cuda.llamaCpp.revision && core.components.llamaCpp.version === cuda.llamaCpp.version && core.contracts.layout === cuda.contracts.layout && core.contracts.embedding === cuda.contracts.embedding;
|
|
70
|
+
var compareNativeVersions = (left, right) => {
|
|
71
|
+
const a = version.parse(left).split(".").map(Number);
|
|
72
|
+
const b = version.parse(right).split(".").map(Number);
|
|
73
|
+
for (let index = 0; index < 3; index++) {
|
|
74
|
+
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
75
|
+
if (difference !== 0)
|
|
76
|
+
return Math.sign(difference);
|
|
77
|
+
}
|
|
78
|
+
return 0;
|
|
79
|
+
};
|
|
80
|
+
var catalog = external_exports.object({
|
|
81
|
+
schemaVersion: external_exports.literal(1),
|
|
82
|
+
minimumCoreVersion: version,
|
|
83
|
+
core: corePin,
|
|
84
|
+
cuda: cudaPin.nullable()
|
|
85
|
+
}).strict().refine((value) => !value.cuda || compatibleCuda(value.core, value.cuda), "Pinned CUDA add-on does not match the core revision and contracts.").refine((value) => compareNativeVersions(value.core.runtimeVersion, value.minimumCoreVersion) >= 0, "Pinned native core is below the compiled minimum runtime version.");
|
|
86
|
+
var macCorePin = external_exports.object({
|
|
87
|
+
...corePin.shape,
|
|
88
|
+
target: external_exports.object({
|
|
89
|
+
platform: external_exports.literal("macos"),
|
|
90
|
+
architecture: external_exports.literal("arm64"),
|
|
91
|
+
minimumVersion: external_exports.literal("14.0")
|
|
92
|
+
}).strict(),
|
|
93
|
+
components: external_exports.object({
|
|
94
|
+
postgres: external_exports.object({
|
|
95
|
+
major: external_exports.literal(17),
|
|
96
|
+
version: external_exports.string().regex(/^17\.\d+$/)
|
|
97
|
+
}).strict(),
|
|
98
|
+
pgvector: external_exports.object({ version: external_exports.literal("0.8.3") }).strict(),
|
|
99
|
+
llamaCpp: external_exports.object({ version: external_exports.string().regex(/^b\d+$/) }).strict()
|
|
100
|
+
}).strict()
|
|
101
|
+
}).strict().refine((pin) => {
|
|
102
|
+
const prefix = "https://github.com/koed-labs/koed/releases/download/";
|
|
103
|
+
const [tag, archive, ...extra] = pin.url.slice(prefix.length).split("/");
|
|
104
|
+
return pin.url.startsWith(prefix) && extra.length === 0 && archive === `koed-native-core-${pin.recipeId}-macos-arm64.tar.gz` && (tag === `native-core-${pin.recipeId}` || /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(tag ?? ""));
|
|
105
|
+
}, "Native macOS core URL does not identify the retained recipe release.");
|
|
106
|
+
var macCatalog = external_exports.object({
|
|
107
|
+
schemaVersion: external_exports.literal(1),
|
|
108
|
+
minimumCoreVersion: version,
|
|
109
|
+
core: macCorePin,
|
|
110
|
+
cuda: external_exports.null()
|
|
111
|
+
}).strict().refine((value) => compareNativeVersions(value.core.runtimeVersion, value.minimumCoreVersion) >= 0);
|
|
112
|
+
var compiledCatalog = external_exports.object({
|
|
113
|
+
schemaVersion: external_exports.literal(2),
|
|
114
|
+
linux: catalog.nullable(),
|
|
115
|
+
macos: macCatalog.nullable()
|
|
116
|
+
}).strict();
|
|
117
|
+
function validateCompiledNativeRuntimeCatalog(value) {
|
|
118
|
+
const result = compiledCatalog.safeParse(value);
|
|
119
|
+
if (!result.success)
|
|
120
|
+
throw new Error(`Invalid compiled native runtime catalog: ${result.error.message}`);
|
|
121
|
+
return result.data;
|
|
122
|
+
}
|
|
123
|
+
function selectNativeRuntimeCatalog(value, platform, architecture) {
|
|
124
|
+
if (!(platform === "linux" && architecture === "x64" || platform === "darwin" && architecture === "arm64"))
|
|
125
|
+
throw new Error("Unsupported release runtime host. Requires Linux x64 or macOS arm64.");
|
|
126
|
+
const isLegacy = typeof value === "object" && value !== null && "schemaVersion" in value && value.schemaVersion === 1;
|
|
127
|
+
const compiled = isLegacy ? { linux: validateNativeRuntimeCatalog(value), macos: null } : validateCompiledNativeRuntimeCatalog(value);
|
|
128
|
+
const selected = platform === "linux" ? compiled.linux : compiled.macos;
|
|
129
|
+
if (!selected)
|
|
130
|
+
throw new Error("This Control Plane has no reviewed native runtime pin for this host. Use a trusted release with native runtime support.");
|
|
131
|
+
return selected;
|
|
132
|
+
}
|
|
133
|
+
var validateNativeRuntimeCatalog = (value) => {
|
|
134
|
+
const parsed = catalog.safeParse(value);
|
|
135
|
+
if (!parsed.success)
|
|
136
|
+
throw new Error(`Invalid compiled native runtime catalog: ${parsed.error.message}`);
|
|
137
|
+
return parsed.data;
|
|
138
|
+
};
|
|
139
|
+
var getNativeRuntimeCatalog = () => {
|
|
140
|
+
if (productionNativeRuntimeCatalog === null)
|
|
141
|
+
throw new Error("This Control Plane has no reviewed native runtime pin. Use a trusted release with native runtime support.");
|
|
142
|
+
return selectNativeRuntimeCatalog(productionNativeRuntimeCatalog, process.platform, process.arch);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
nativeKind,
|
|
147
|
+
compatibleCuda,
|
|
148
|
+
compareNativeVersions,
|
|
149
|
+
selectNativeRuntimeCatalog,
|
|
150
|
+
validateNativeRuntimeCatalog,
|
|
151
|
+
getNativeRuntimeCatalog
|
|
152
|
+
};
|
|
@@ -4,20 +4,18 @@ import {
|
|
|
4
4
|
} from "./chunk-QT24SAW6.js";
|
|
5
5
|
import {
|
|
6
6
|
applyPersistedLocalPorts
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
readActiveRuntimeState
|
|
10
|
-
} from "./chunk-G4IIVVJO.js";
|
|
11
|
-
import {
|
|
12
|
-
require_proper_lockfile
|
|
13
|
-
} from "./chunk-7NXKPDF3.js";
|
|
7
|
+
} from "./chunk-TISYUUEJ.js";
|
|
14
8
|
import {
|
|
15
9
|
loadRepoEnv,
|
|
16
10
|
resolveApiUrl
|
|
17
11
|
} from "./chunk-W2HNI6AA.js";
|
|
12
|
+
import {
|
|
13
|
+
readActiveRuntimeState,
|
|
14
|
+
withFileLock
|
|
15
|
+
} from "./chunk-T6UB5PNX.js";
|
|
16
|
+
import "./chunk-7NXKPDF3.js";
|
|
18
17
|
import {
|
|
19
18
|
deriveLocalProjectId,
|
|
20
|
-
external_exports,
|
|
21
19
|
fetchBoundedJsonObject,
|
|
22
20
|
hmacProjectValue,
|
|
23
21
|
isLoopbackHostname,
|
|
@@ -28,16 +26,17 @@ import {
|
|
|
28
26
|
repositoryChangeInputSchema,
|
|
29
27
|
repositoryIdentityMatches,
|
|
30
28
|
repositoryIdentitySchema
|
|
31
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-E6YVGIEW.js";
|
|
32
30
|
import {
|
|
33
|
-
|
|
34
|
-
} from "./chunk-
|
|
31
|
+
external_exports
|
|
32
|
+
} from "./chunk-FSNLU46W.js";
|
|
33
|
+
import "./chunk-BTS4ZTF3.js";
|
|
35
34
|
|
|
36
35
|
// packages/koed-server/dist/project-metadata.js
|
|
37
36
|
import { execFile as nodeExecFile } from "node:child_process";
|
|
38
37
|
import { randomUUID } from "node:crypto";
|
|
39
|
-
import { existsSync, mkdirSync
|
|
40
|
-
import path, { dirname as
|
|
38
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, statSync as statSync2, rmSync } from "node:fs";
|
|
39
|
+
import path, { dirname as dirname2, relative, resolve as resolve2 } from "node:path";
|
|
41
40
|
|
|
42
41
|
// packages/koed-server/dist/git-project-probe.js
|
|
43
42
|
import { execFile } from "node:child_process";
|
|
@@ -305,38 +304,13 @@ var lookupAcceptedProjectSelection = async (paths, checkout, deps = {}) => {
|
|
|
305
304
|
} : void 0;
|
|
306
305
|
};
|
|
307
306
|
|
|
308
|
-
// packages/koed-server/dist/project-metadata-lock.js
|
|
309
|
-
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
310
|
-
import { mkdirSync } from "node:fs";
|
|
311
|
-
import { dirname as dirname2 } from "node:path";
|
|
312
|
-
var withProjectMetadataLock = (file, operation) => {
|
|
313
|
-
mkdirSync(dirname2(file), { recursive: true, mode: 448 });
|
|
314
|
-
const deadline = Date.now() + 5e3;
|
|
315
|
-
let release;
|
|
316
|
-
while (true) {
|
|
317
|
-
try {
|
|
318
|
-
release = import_proper_lockfile.default.lockSync(file, { realpath: false, stale: 3e4 });
|
|
319
|
-
break;
|
|
320
|
-
} catch (error) {
|
|
321
|
-
if (error.code !== "ELOCKED" || Date.now() >= deadline)
|
|
322
|
-
throw error;
|
|
323
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
try {
|
|
327
|
-
return operation();
|
|
328
|
-
} finally {
|
|
329
|
-
release();
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
|
|
333
307
|
// packages/koed-server/dist/project-metadata.js
|
|
334
308
|
var depsWithDefaults = (deps = {}) => ({
|
|
335
309
|
existsSync: deps.existsSync ?? existsSync,
|
|
336
310
|
readFileSync: deps.readFileSync ?? readFileSync,
|
|
337
311
|
writeFileSync: deps.writeFileSync ?? writeFileSync,
|
|
338
312
|
renameSync: deps.renameSync ?? renameSync,
|
|
339
|
-
mkdirSync: deps.mkdirSync ??
|
|
313
|
+
mkdirSync: deps.mkdirSync ?? mkdirSync,
|
|
340
314
|
statSync: deps.statSync ?? statSync2,
|
|
341
315
|
lookupAssociatedSelection: deps.lookupAssociatedSelection ?? lookupAcceptedProjectSelection,
|
|
342
316
|
execFile: deps.execFile ?? nodeExecFile,
|
|
@@ -407,20 +381,20 @@ var readStoreUnlocked = (paths, deps) => {
|
|
|
407
381
|
throw new Error("Project metadata config is malformed.", { cause: error });
|
|
408
382
|
}
|
|
409
383
|
};
|
|
410
|
-
var updateStore = (paths, deps, mutate) =>
|
|
384
|
+
var updateStore = (paths, deps, mutate) => withFileLock(paths.projectMetadataPath, () => {
|
|
411
385
|
const store = readStoreUnlocked(paths, deps);
|
|
412
386
|
const result = mutate(store);
|
|
413
387
|
writeStore(paths, store, deps);
|
|
414
388
|
return result;
|
|
415
389
|
});
|
|
416
|
-
var readStore = (paths, deps) =>
|
|
390
|
+
var readStore = (paths, deps) => withFileLock(paths.projectMetadataPath, () => {
|
|
417
391
|
const store = readStoreUnlocked(paths, deps);
|
|
418
392
|
if (!deps.existsSync(paths.projectMetadataPath))
|
|
419
393
|
writeStore(paths, store, deps);
|
|
420
394
|
return store;
|
|
421
395
|
});
|
|
422
396
|
var writeStore = (paths, store, deps) => {
|
|
423
|
-
deps.mkdirSync(
|
|
397
|
+
deps.mkdirSync(dirname2(paths.projectMetadataPath), {
|
|
424
398
|
recursive: true,
|
|
425
399
|
mode: 448
|
|
426
400
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
checkCudaHost,
|
|
4
|
+
validateStagedCuda
|
|
5
|
+
} from "./chunk-XKXSC6YS.js";
|
|
6
|
+
import "./chunk-JYK6UL6D.js";
|
|
7
|
+
import "./chunk-VGL5AZN5.js";
|
|
8
|
+
import "./chunk-QV3WPU7A.js";
|
|
9
|
+
import "./chunk-FSNLU46W.js";
|
|
10
|
+
import "./chunk-BTS4ZTF3.js";
|
|
11
|
+
export {
|
|
12
|
+
checkCudaHost,
|
|
13
|
+
validateStagedCuda
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
validateManifestCatalog
|
|
4
|
+
} from "./chunk-IY2HRXOZ.js";
|
|
5
|
+
|
|
6
|
+
// packages/koed-server/dist/component-manifest-catalog-data.js
|
|
7
|
+
var productionComponentManifestCatalog = validateManifestCatalog({ "schemaVersion": 2, "productVersion": "1.0.0", "entries": [{ "component": "base", "manifestSha256": "0cf17d418882012bbcc43df60e2856e88b477f01f970b588658d40f7542d42d3", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "base", "manifestSha256": "eda39274ee6e865716b2e7ae21bc77bdc23e9c6ccaf15342f1a084e1c11fae00", "target": { "platform": "macos", "architecture": "arm64" } }, { "component": "privacy", "variant": "cpu", "manifestSha256": "c5d623196ed957adf7eb9cc5b9a9b75e1e51a393b4878288a46bc40b13ef8602", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "privacy", "variant": "cuda", "manifestSha256": "7b487834eccc09a12d516c6da63db691214cac4d52c72484afe9461e11759bbf", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "privacy", "manifestSha256": "832b587bd1f17047519031d6a5e56e4406c2ac322bea4fdeff7f98fbc7d5a51f", "target": { "platform": "macos", "architecture": "arm64" } }] });
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
productionComponentManifestCatalog
|
|
11
|
+
};
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
collectLocalModelStatus
|
|
4
|
+
} from "./chunk-JYK6UL6D.js";
|
|
5
|
+
import {
|
|
6
|
+
compareNativeVersions
|
|
7
|
+
} from "./chunk-VGL5AZN5.js";
|
|
8
|
+
import {
|
|
9
|
+
external_exports
|
|
10
|
+
} from "./chunk-FSNLU46W.js";
|
|
11
|
+
|
|
12
|
+
// packages/koed-server/dist/runtime-release-validation.js
|
|
13
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
14
|
+
import { dirname, join, resolve } from "node:path";
|
|
15
|
+
|
|
16
|
+
// packages/koed-server/dist/native-validation-process.js
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { request } from "node:http";
|
|
19
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
20
|
+
async function withNativeProbe(binary, args, context, action, observeOutput) {
|
|
21
|
+
context.signal.throwIfAborted();
|
|
22
|
+
const child = spawn(binary, args, {
|
|
23
|
+
cwd: context.cwd,
|
|
24
|
+
env: context.env,
|
|
25
|
+
detached: true,
|
|
26
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
27
|
+
});
|
|
28
|
+
let output = "";
|
|
29
|
+
const append = (chunk) => {
|
|
30
|
+
output = (output + chunk).slice(-64 * 1024);
|
|
31
|
+
observeOutput?.(output);
|
|
32
|
+
};
|
|
33
|
+
child.stdout.setEncoding("utf8").on("data", append);
|
|
34
|
+
child.stderr.setEncoding("utf8").on("data", append);
|
|
35
|
+
const ended = new AbortController();
|
|
36
|
+
const killGroup = () => {
|
|
37
|
+
if (child.pid) {
|
|
38
|
+
try {
|
|
39
|
+
process.kill(-child.pid, "SIGKILL");
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error.code !== "ESRCH")
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
let exited = false;
|
|
47
|
+
child.once("error", (error) => {
|
|
48
|
+
append(error.message);
|
|
49
|
+
ended.abort(error);
|
|
50
|
+
});
|
|
51
|
+
child.once("exit", () => {
|
|
52
|
+
killGroup();
|
|
53
|
+
exited = true;
|
|
54
|
+
ended.abort(new Error("Native probe exited."));
|
|
55
|
+
});
|
|
56
|
+
const stop = () => {
|
|
57
|
+
if (!exited)
|
|
58
|
+
killGroup();
|
|
59
|
+
};
|
|
60
|
+
const closed = new Promise((done) => child.once("close", done));
|
|
61
|
+
context.signal.addEventListener("abort", stop, { once: true });
|
|
62
|
+
try {
|
|
63
|
+
return await action({
|
|
64
|
+
closed,
|
|
65
|
+
log: () => output,
|
|
66
|
+
lifetime: AbortSignal.any([context.signal, ended.signal])
|
|
67
|
+
});
|
|
68
|
+
} finally {
|
|
69
|
+
context.signal.removeEventListener("abort", stop);
|
|
70
|
+
stop();
|
|
71
|
+
await closed;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function nativeCommand(binary, args, context) {
|
|
75
|
+
const signal = AbortSignal.any([context.signal, AbortSignal.timeout(1e4)]);
|
|
76
|
+
return withNativeProbe(binary, args, { ...context, signal }, async (probe) => {
|
|
77
|
+
const code = await probe.closed;
|
|
78
|
+
signal.throwIfAborted();
|
|
79
|
+
if (code !== 0)
|
|
80
|
+
throw new Error(probe.log().trim().slice(-1500) || `Exited with code ${code}.`);
|
|
81
|
+
return probe.log().trim();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function socketRequest(socketPath, path, signal, body) {
|
|
85
|
+
return new Promise((done, fail) => {
|
|
86
|
+
const req = request({
|
|
87
|
+
socketPath,
|
|
88
|
+
path,
|
|
89
|
+
signal,
|
|
90
|
+
agent: false,
|
|
91
|
+
method: body ? "POST" : "GET",
|
|
92
|
+
headers: body ? { "Content-Type": "application/json" } : {}
|
|
93
|
+
}, (res) => {
|
|
94
|
+
const chunks = [];
|
|
95
|
+
let bytes = 0;
|
|
96
|
+
res.on("error", fail);
|
|
97
|
+
res.on("data", (chunk) => {
|
|
98
|
+
bytes += chunk.length;
|
|
99
|
+
if (bytes > 1024 * 1024)
|
|
100
|
+
res.destroy(new Error("Validation response exceeded 1 MiB."));
|
|
101
|
+
else
|
|
102
|
+
chunks.push(chunk);
|
|
103
|
+
});
|
|
104
|
+
res.on("end", () => done({
|
|
105
|
+
status: res.statusCode ?? 0,
|
|
106
|
+
body: Buffer.concat(chunks).toString("utf8")
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
req.on("error", fail);
|
|
110
|
+
req.end(body);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async function requestProbeEmbeddings(socket, inputs2, signal) {
|
|
114
|
+
const startup = AbortSignal.any([signal, AbortSignal.timeout(4e4)]);
|
|
115
|
+
for (; ; ) {
|
|
116
|
+
startup.throwIfAborted();
|
|
117
|
+
try {
|
|
118
|
+
const health = await socketRequest(socket, "/health", startup);
|
|
119
|
+
if (health.status === 200)
|
|
120
|
+
break;
|
|
121
|
+
if (health.status !== 503)
|
|
122
|
+
throw new Error(`Embedding health check returned HTTP ${health.status}.`);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (!["ENOENT", "ECONNREFUSED"].includes(error.code ?? ""))
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
await delay(100, void 0, { signal: startup });
|
|
128
|
+
}
|
|
129
|
+
const result = await socketRequest(socket, "/v1/embeddings", signal, JSON.stringify({ model: "qualification", input: inputs2 }));
|
|
130
|
+
if (result.status !== 200)
|
|
131
|
+
throw new Error(`Embedding request returned HTTP ${result.status}.`);
|
|
132
|
+
return JSON.parse(result.body);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// packages/koed-server/dist/nvidia-smi.js
|
|
136
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
137
|
+
var candidates = [
|
|
138
|
+
"/usr/bin/nvidia-smi",
|
|
139
|
+
"/bin/nvidia-smi",
|
|
140
|
+
"/usr/local/bin/nvidia-smi",
|
|
141
|
+
"/usr/local/nvidia/bin/nvidia-smi",
|
|
142
|
+
"/usr/lib/wsl/lib/nvidia-smi"
|
|
143
|
+
];
|
|
144
|
+
function resolveNvidiaSmi() {
|
|
145
|
+
for (const candidate of candidates) {
|
|
146
|
+
try {
|
|
147
|
+
if (!statSync(candidate).isFile())
|
|
148
|
+
continue;
|
|
149
|
+
accessSync(candidate, constants.X_OK);
|
|
150
|
+
return candidate;
|
|
151
|
+
} catch {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// packages/koed-server/dist/runtime-release-validation.js
|
|
158
|
+
var minimumDriver = "550.54.14";
|
|
159
|
+
var minimumCosine = 0.999;
|
|
160
|
+
var inputs = [
|
|
161
|
+
"The train arrives at noon.",
|
|
162
|
+
"A red kite is flying over the lake.",
|
|
163
|
+
"Measure twice, cut once."
|
|
164
|
+
];
|
|
165
|
+
var NativeValidationError = class extends Error {
|
|
166
|
+
reason;
|
|
167
|
+
constructor(reason, message2) {
|
|
168
|
+
super(message2);
|
|
169
|
+
this.reason = reason;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
async function checkCudaHost(signal, nvidiaSmi = resolveNvidiaSmi()) {
|
|
173
|
+
const context = {
|
|
174
|
+
cwd: "/",
|
|
175
|
+
env: { PATH: "/usr/bin:/bin", LANG: "C", LC_ALL: "C" },
|
|
176
|
+
signal
|
|
177
|
+
};
|
|
178
|
+
let driverVersion;
|
|
179
|
+
try {
|
|
180
|
+
if (!nvidiaSmi)
|
|
181
|
+
throw new Error("NVIDIA driver tools are not available.");
|
|
182
|
+
const output = await nativeCommand(nvidiaSmi, ["--query-gpu=driver_version", "--format=csv,noheader"], context);
|
|
183
|
+
const versions = new Set(output.split(/\r?\n/).map((row) => row.trim()));
|
|
184
|
+
driverVersion = [...versions][0] ?? "";
|
|
185
|
+
if (versions.size !== 1 || !/^\d{1,4}\.\d{1,4}(\.\d{1,4})?$/.test(driverVersion))
|
|
186
|
+
throw new Error("No consistent NVIDIA driver version was reported.");
|
|
187
|
+
} catch (error) {
|
|
188
|
+
context.signal.throwIfAborted();
|
|
189
|
+
throw new NativeValidationError("cuda_device_unavailable", `Cannot query the NVIDIA GPU driver: ${message(error)}`);
|
|
190
|
+
}
|
|
191
|
+
const [major, minor, patch = 0] = driverVersion.split(".").map(Number);
|
|
192
|
+
if (compareNativeVersions(`${major}.${minor}.${patch}`, minimumDriver) < 0)
|
|
193
|
+
throw new NativeValidationError("cuda_driver_too_old", `NVIDIA driver ${driverVersion} is older than required ${minimumDriver}.`);
|
|
194
|
+
const loaded = await nativeCommand(process.execPath, [
|
|
195
|
+
"-p",
|
|
196
|
+
String.raw`process.report.getReport().sharedObjects.some(p => /\/libcuda\.so(?:\.\d+)*$/.test(p))`
|
|
197
|
+
], {
|
|
198
|
+
...context,
|
|
199
|
+
// Desktop also calls this probe from Electron main. Its executable must
|
|
200
|
+
// run as Node, just as it does for the private server supervisor.
|
|
201
|
+
env: {
|
|
202
|
+
...context.env,
|
|
203
|
+
ELECTRON_RUN_AS_NODE: "1",
|
|
204
|
+
LD_PRELOAD: "libcuda.so.1"
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
if (loaded !== "true")
|
|
208
|
+
throw new NativeValidationError("cuda_driver_library_unavailable", "The host loader could not load libcuda.so.1.");
|
|
209
|
+
return driverVersion;
|
|
210
|
+
}
|
|
211
|
+
async function discover(root, context) {
|
|
212
|
+
const driverVersion = await checkCudaHost(context.signal);
|
|
213
|
+
const binary = resolve(root, "llama.cpp/cuda/llama-server");
|
|
214
|
+
try {
|
|
215
|
+
const listing = await nativeCommand(binary, ["--list-devices"], {
|
|
216
|
+
...context,
|
|
217
|
+
env: { ...context.env, LD_LIBRARY_PATH: dirname(binary) }
|
|
218
|
+
});
|
|
219
|
+
const match = /^\s*(CUDA\d+):[ \t]+([^\r\n]+)/m.exec(listing);
|
|
220
|
+
if (!match)
|
|
221
|
+
throw new Error("The staged binary listed no CUDA device.");
|
|
222
|
+
return { driverVersion, device: match[1], description: match[2].trim() };
|
|
223
|
+
} catch (error) {
|
|
224
|
+
context.signal.throwIfAborted();
|
|
225
|
+
throw new NativeValidationError("cuda_device_unavailable", `CUDA device discovery failed: ${message(error)}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
229
|
+
var responseSchema = external_exports.object({
|
|
230
|
+
data: external_exports.array(external_exports.object({
|
|
231
|
+
index: external_exports.number().int(),
|
|
232
|
+
embedding: external_exports.array(external_exports.number().finite()).min(1)
|
|
233
|
+
})).length(inputs.length)
|
|
234
|
+
});
|
|
235
|
+
function vectors(body) {
|
|
236
|
+
const parsed = responseSchema.safeParse(body);
|
|
237
|
+
if (!parsed.success)
|
|
238
|
+
throw new NativeValidationError("vector_agreement_failed", "Expected one finite, nonempty embedding per test input.");
|
|
239
|
+
const rows = parsed.data.data.sort((a, b) => a.index - b.index);
|
|
240
|
+
if (rows.some((row, index) => row.index !== index))
|
|
241
|
+
throw new NativeValidationError("vector_agreement_failed", "The embedding response did not identify each input exactly once.");
|
|
242
|
+
return rows.map((row) => row.embedding);
|
|
243
|
+
}
|
|
244
|
+
async function embed(root, model, device, context) {
|
|
245
|
+
const backend = device ? "cuda" : "cpu";
|
|
246
|
+
const binary = resolve(root, `llama.cpp/${backend}/llama-server`);
|
|
247
|
+
const socket = join(context.cwd, `${backend}.sock`);
|
|
248
|
+
const args = [
|
|
249
|
+
"--model",
|
|
250
|
+
model,
|
|
251
|
+
"--alias",
|
|
252
|
+
"qualification",
|
|
253
|
+
"--embedding",
|
|
254
|
+
"--pooling",
|
|
255
|
+
"last",
|
|
256
|
+
"--ctx-size",
|
|
257
|
+
"2048",
|
|
258
|
+
"--batch-size",
|
|
259
|
+
"512",
|
|
260
|
+
"--ubatch-size",
|
|
261
|
+
"512",
|
|
262
|
+
"--parallel",
|
|
263
|
+
"1",
|
|
264
|
+
"--threads",
|
|
265
|
+
"2",
|
|
266
|
+
"--threads-batch",
|
|
267
|
+
"2",
|
|
268
|
+
"--n-gpu-layers",
|
|
269
|
+
device ? "all" : "0",
|
|
270
|
+
"--device",
|
|
271
|
+
device ?? "none",
|
|
272
|
+
"--fit",
|
|
273
|
+
"off",
|
|
274
|
+
"--host",
|
|
275
|
+
socket,
|
|
276
|
+
"-lv",
|
|
277
|
+
"4"
|
|
278
|
+
];
|
|
279
|
+
let offloaded = false, allocationFailed = false;
|
|
280
|
+
return withNativeProbe(binary, args, { ...context, env: { ...context.env, LD_LIBRARY_PATH: dirname(binary) } }, async (probe) => {
|
|
281
|
+
try {
|
|
282
|
+
const result = vectors(await requestProbeEmbeddings(socket, inputs, probe.lifetime));
|
|
283
|
+
if (device && !offloaded)
|
|
284
|
+
throw new NativeValidationError("cuda_offload_unconfirmed", "The staged server did not confirm GPU layer offload.");
|
|
285
|
+
return result;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
context.signal.throwIfAborted();
|
|
288
|
+
if (probe.lifetime.aborted)
|
|
289
|
+
await probe.closed;
|
|
290
|
+
const log = probe.log();
|
|
291
|
+
if (device && allocationFailed)
|
|
292
|
+
throw new NativeValidationError("cuda_memory_pressure", "CUDA ran out of VRAM during validation. Check nvidia-smi for competing GPU workloads and retry.");
|
|
293
|
+
if (error instanceof NativeValidationError)
|
|
294
|
+
throw error;
|
|
295
|
+
throw new NativeValidationError("inference_failed", `${backend.toUpperCase()} embedding probe failed: ${message(error)} ${log.slice(-650).trim()}`);
|
|
296
|
+
}
|
|
297
|
+
}, (tail) => {
|
|
298
|
+
offloaded ||= /offloaded [1-9]\d*\/\d+ layers to GPU/i.test(tail);
|
|
299
|
+
allocationFailed ||= /out of memory|cudaErrorMemoryAllocation|cudaMalloc.*fail/i.test(tail);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function compare(cpu, gpu) {
|
|
303
|
+
const dimensions = cpu[0].length;
|
|
304
|
+
return cpu.map((left, i) => {
|
|
305
|
+
const right = gpu[i];
|
|
306
|
+
if (left.length !== dimensions || right.length !== dimensions)
|
|
307
|
+
throw new NativeValidationError("vector_agreement_failed", `Embedding dimensions differ for input ${i + 1}.`);
|
|
308
|
+
let dot = 0, normA = 0, normB = 0;
|
|
309
|
+
for (let j = 0; j < dimensions; j++) {
|
|
310
|
+
const a = left[j], b = right[j];
|
|
311
|
+
dot += a * b;
|
|
312
|
+
normA += a * a;
|
|
313
|
+
normB += b * b;
|
|
314
|
+
}
|
|
315
|
+
const cosine = dot / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
316
|
+
if (!Number.isFinite(cosine) || cosine < minimumCosine)
|
|
317
|
+
throw new NativeValidationError("vector_agreement_failed", `CPU/GPU agreement failed for input ${i + 1}: cosine ${cosine}; required ${minimumCosine}.`);
|
|
318
|
+
return { dimensions, cosine };
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
async function validateStagedCuda(paths, root, environment, options) {
|
|
322
|
+
const signal = AbortSignal.any([
|
|
323
|
+
options.signal,
|
|
324
|
+
AbortSignal.timeout(12e4)
|
|
325
|
+
]);
|
|
326
|
+
const cwd = mkdtempSync("/tmp/koed-native-probe-");
|
|
327
|
+
try {
|
|
328
|
+
const env = {
|
|
329
|
+
PATH: "/usr/bin:/bin",
|
|
330
|
+
LANG: "C",
|
|
331
|
+
LC_ALL: "C",
|
|
332
|
+
HOME: cwd,
|
|
333
|
+
TMPDIR: cwd
|
|
334
|
+
};
|
|
335
|
+
for (const key of ["CUDA_VISIBLE_DEVICES", "CUDA_DEVICE_ORDER"])
|
|
336
|
+
if (environment[key] !== void 0)
|
|
337
|
+
env[key] = environment[key];
|
|
338
|
+
const context = { cwd, env, signal };
|
|
339
|
+
const device = await discover(root, context);
|
|
340
|
+
const model = await collectLocalModelStatus(paths, "embedding", environment, signal);
|
|
341
|
+
signal.throwIfAborted();
|
|
342
|
+
if (model.state === "missing" && !options.requireModel)
|
|
343
|
+
return {
|
|
344
|
+
ok: true,
|
|
345
|
+
scope: "device-only",
|
|
346
|
+
...device,
|
|
347
|
+
message: "CUDA device discovery passed. Install the embedding model for inference validation."
|
|
348
|
+
};
|
|
349
|
+
if (model.state !== "installed")
|
|
350
|
+
throw new NativeValidationError(`model_${model.state}`, model.message);
|
|
351
|
+
const cpu = await embed(root, model.modelPath, null, context);
|
|
352
|
+
const gpu = await embed(root, model.modelPath, device.device, context);
|
|
353
|
+
const agreement = compare(cpu, gpu);
|
|
354
|
+
signal.throwIfAborted();
|
|
355
|
+
return {
|
|
356
|
+
ok: true,
|
|
357
|
+
scope: "inference",
|
|
358
|
+
...device,
|
|
359
|
+
modelSha256: model.sha256,
|
|
360
|
+
minimumCosine,
|
|
361
|
+
agreement,
|
|
362
|
+
message: "CUDA device discovery, GPU offload and CPU/GPU embedding agreement passed."
|
|
363
|
+
};
|
|
364
|
+
} finally {
|
|
365
|
+
rmSync(cwd, { recursive: true, force: true });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export {
|
|
370
|
+
nativeCommand,
|
|
371
|
+
checkCudaHost,
|
|
372
|
+
validateStagedCuda
|
|
373
|
+
};
|