@koed-labs/server 0.0.0-stage → 0.10.3
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/LICENSE +201 -0
- package/README.md +64 -2
- package/bin/koed.js +7 -0
- package/package.json +26 -4
- package/third-party-notices.json +92 -0
- package/vendor/chunk-2BWTLF7A.js +13883 -0
- package/vendor/chunk-2DA7EFZV.js +924 -0
- package/vendor/chunk-2S3OGPUC.js +58 -0
- package/vendor/chunk-473OA62O.js +26827 -0
- package/vendor/chunk-6JRWGOQG.js +236 -0
- package/vendor/chunk-7NOQSX4T.js +14 -0
- package/vendor/chunk-7NXKPDF3.js +1586 -0
- package/vendor/chunk-A4NKL2PK.js +153 -0
- package/vendor/chunk-A6WMU2GG.js +48 -0
- package/vendor/chunk-AFLKCQHF.js +73 -0
- package/vendor/chunk-BTS4ZTF3.js +43 -0
- package/vendor/chunk-C3N4N5HR.js +108 -0
- package/vendor/chunk-DXTAWHY3.js +25 -0
- package/vendor/chunk-G4IIVVJO.js +56 -0
- package/vendor/chunk-GELDEJJ2.js +4337 -0
- package/vendor/chunk-HFM6ROJL.js +188 -0
- package/vendor/chunk-HK2H3MVE.js +328 -0
- package/vendor/chunk-HZJK5RWC.js +5088 -0
- package/vendor/chunk-J2L726BC.js +2497 -0
- package/vendor/chunk-JBGD4JLR.js +3779 -0
- package/vendor/chunk-JJNLH5GA.js +2470 -0
- package/vendor/chunk-JKOG52PE.js +128 -0
- package/vendor/chunk-K2EIFEQF.js +89 -0
- package/vendor/chunk-KUIWH33N.js +16 -0
- package/vendor/chunk-NEWIOOM6.js +34 -0
- package/vendor/chunk-NM5NXCVM.js +2404 -0
- package/vendor/chunk-PT3AUPGE.js +459 -0
- package/vendor/chunk-PY5LYLV7.js +143 -0
- package/vendor/chunk-QIIKMG3M.js +103 -0
- package/vendor/chunk-QT24SAW6.js +110 -0
- package/vendor/chunk-RVYJKKWA.js +22 -0
- package/vendor/chunk-SKVYP7NY.js +1647 -0
- package/vendor/chunk-TSRPHKAC.js +780 -0
- package/vendor/chunk-UI5RLBKQ.js +30 -0
- package/vendor/chunk-VPC5NLZG.js +259 -0
- package/vendor/chunk-W2HNI6AA.js +75 -0
- package/vendor/chunk-X6M525ZJ.js +20 -0
- package/vendor/chunk-XIZVLPHZ.js +18 -0
- package/vendor/chunk-XNFVSVBS.js +242 -0
- package/vendor/chunk-YCDEMYY6.js +2076 -0
- package/vendor/chunk-YJ6XUZT6.js +292 -0
- package/vendor/chunk-YJWREXN6.js +26020 -0
- package/vendor/chunk-YK4F4VY2.js +173 -0
- package/vendor/chunk-YOFI4PCH.js +36 -0
- package/vendor/chunk-ZUGNCQZE.js +247 -0
- package/vendor/chunk-ZXX4ZNJY.js +21 -0
- package/vendor/cli.js +7 -0
- package/vendor/component-manifest-catalog.js +8 -0
- package/vendor/control-plane.js +23 -0
- package/vendor/package.json +1 -0
- package/vendor/privacy-service-bootstrap.js +6 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
createCliServiceContext,
|
|
4
|
+
printJson
|
|
5
|
+
} from "./chunk-YCDEMYY6.js";
|
|
6
|
+
import {
|
|
7
|
+
evaluateAiClientReadiness
|
|
8
|
+
} from "./chunk-HZJK5RWC.js";
|
|
9
|
+
import "./chunk-QT24SAW6.js";
|
|
10
|
+
import "./chunk-SKVYP7NY.js";
|
|
11
|
+
import "./chunk-HFM6ROJL.js";
|
|
12
|
+
import "./chunk-AFLKCQHF.js";
|
|
13
|
+
import "./chunk-NM5NXCVM.js";
|
|
14
|
+
import "./chunk-G4IIVVJO.js";
|
|
15
|
+
import "./chunk-JKOG52PE.js";
|
|
16
|
+
import "./chunk-A4NKL2PK.js";
|
|
17
|
+
import "./chunk-QIIKMG3M.js";
|
|
18
|
+
import "./chunk-2DA7EFZV.js";
|
|
19
|
+
import "./chunk-VPC5NLZG.js";
|
|
20
|
+
import "./chunk-YJWREXN6.js";
|
|
21
|
+
import "./chunk-J2L726BC.js";
|
|
22
|
+
import "./chunk-2S3OGPUC.js";
|
|
23
|
+
import "./chunk-XNFVSVBS.js";
|
|
24
|
+
import "./chunk-7NXKPDF3.js";
|
|
25
|
+
import "./chunk-K2EIFEQF.js";
|
|
26
|
+
import "./chunk-UI5RLBKQ.js";
|
|
27
|
+
import "./chunk-W2HNI6AA.js";
|
|
28
|
+
import "./chunk-473OA62O.js";
|
|
29
|
+
import "./chunk-ZUGNCQZE.js";
|
|
30
|
+
import "./chunk-BTS4ZTF3.js";
|
|
31
|
+
|
|
32
|
+
// packages/koed-server/dist/cli-integration-operations.js
|
|
33
|
+
var runIntegrationCommand = async (command, options, dependencies) => {
|
|
34
|
+
const { collectStatus, setupCoreIntegration, setup, setupClaudeIntegration, setupPiIntegration, removeClaudeIntegration, removePiIntegration, removeCodexIntegrationFn, repairCodex, stdout, stderr } = createCliServiceContext(dependencies);
|
|
35
|
+
const subcommand = options.client;
|
|
36
|
+
const wantsJson = options.json;
|
|
37
|
+
try {
|
|
38
|
+
if (command === "setup" && subcommand === "core") {
|
|
39
|
+
const result = await setupCoreIntegration();
|
|
40
|
+
if (wantsJson) {
|
|
41
|
+
printJson(stdout, result);
|
|
42
|
+
} else {
|
|
43
|
+
stdout.write(result.ok ? "Koed core setup completed.\n" : `${result.error ?? "Koed core setup failed."}
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
return result.ok ? 0 : 1;
|
|
47
|
+
}
|
|
48
|
+
if (command === "setup" && subcommand === "codex") {
|
|
49
|
+
const withoutGuidance = Boolean(options.withoutMemoryGuidance);
|
|
50
|
+
const withGuidance = Boolean(options.withMemoryGuidance);
|
|
51
|
+
if (withoutGuidance && withGuidance) {
|
|
52
|
+
throw new Error("Use only one of --with-memory-guidance or --without-memory-guidance.");
|
|
53
|
+
}
|
|
54
|
+
const deferredRecall = Boolean(options.deferredRecall);
|
|
55
|
+
const blockingRecall = Boolean(options.blockingRecall);
|
|
56
|
+
if (deferredRecall && blockingRecall)
|
|
57
|
+
throw new Error("Use only one of --deferred-recall or --blocking-recall.");
|
|
58
|
+
if (deferredRecall || blockingRecall) {
|
|
59
|
+
stderr.write("Legacy recall flags are deprecated; select delivery_mode on memory_answer instead.\n");
|
|
60
|
+
}
|
|
61
|
+
const result = await setup({
|
|
62
|
+
environment: {
|
|
63
|
+
...process.env,
|
|
64
|
+
...withoutGuidance || withGuidance ? {
|
|
65
|
+
KOED_CODEX_GLOBAL_MEMORY_GUIDANCE_ENABLED: String(withGuidance)
|
|
66
|
+
} : {},
|
|
67
|
+
...deferredRecall || blockingRecall ? { KOED_CODEX_STOP_DELIVERY: deferredRecall ? "1" : "0" } : {}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (wantsJson) {
|
|
71
|
+
printJson(stdout, result);
|
|
72
|
+
} else {
|
|
73
|
+
stdout.write(result.ok ? "Codex setup completed.\n" : `${result.error ?? "Codex setup failed."}
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
return result.ok ? 0 : 1;
|
|
77
|
+
}
|
|
78
|
+
if (command === "setup" && subcommand === "pi") {
|
|
79
|
+
const result = await setupPiIntegration();
|
|
80
|
+
if (wantsJson) {
|
|
81
|
+
printJson(stdout, result);
|
|
82
|
+
} else {
|
|
83
|
+
stdout.write(result.ok ? result.authenticationState === "authenticated" ? "Pi setup completed.\n" : "Pi profile configured. Authenticate at least one model through Pi, then refresh capabilities; Pi-executed work remains unavailable until authentication.\n" : `${result.error ?? "Pi setup failed."}
|
|
84
|
+
`);
|
|
85
|
+
}
|
|
86
|
+
return result.ok ? 0 : 1;
|
|
87
|
+
}
|
|
88
|
+
if (command === "setup" && subcommand === "claude") {
|
|
89
|
+
const result = await (options.backgroundRecall ? setupClaudeIntegration(void 0, void 0, {
|
|
90
|
+
backgroundRecall: true
|
|
91
|
+
}) : setupClaudeIntegration());
|
|
92
|
+
if (wantsJson) {
|
|
93
|
+
printJson(stdout, result);
|
|
94
|
+
} else {
|
|
95
|
+
stdout.write(result.ok ? result.authenticationState === "authenticated" ? "Claude Code setup completed. Restart Claude Code before verifying capture and recall.\n" : "Claude Code profile configured. Run `claude auth login`, then refresh capabilities; Claude-executed work remains unavailable until sign-in.\n" : `${result.error ?? "Claude Code setup failed."}
|
|
96
|
+
`);
|
|
97
|
+
}
|
|
98
|
+
if (!wantsJson && result.backgroundRecall)
|
|
99
|
+
stdout.write(`${result.backgroundRecall.message}
|
|
100
|
+
`);
|
|
101
|
+
return result.ok ? 0 : 1;
|
|
102
|
+
}
|
|
103
|
+
if (command === "repair" && subcommand === "codex") {
|
|
104
|
+
const result = await repairCodex();
|
|
105
|
+
if (wantsJson) {
|
|
106
|
+
printJson(stdout, result);
|
|
107
|
+
} else {
|
|
108
|
+
stdout.write(result.ok ? "Codex integration repaired. Restart Codex and trust updated hooks if prompted.\n" : `${result.error ?? "Codex integration repair failed."}
|
|
109
|
+
`);
|
|
110
|
+
}
|
|
111
|
+
return result.ok ? 0 : 1;
|
|
112
|
+
}
|
|
113
|
+
if (command === "check" && subcommand) {
|
|
114
|
+
const status = await collectStatus(void 0, void 0, {
|
|
115
|
+
capabilitiesRefreshedSince: options.capabilitiesRefreshedSince
|
|
116
|
+
});
|
|
117
|
+
const components = {
|
|
118
|
+
codex: status.codex,
|
|
119
|
+
claude: status.claudeCode,
|
|
120
|
+
pi: status.pi
|
|
121
|
+
};
|
|
122
|
+
const readiness = components[subcommand] ? status.aiClients?.[subcommand] : void 0;
|
|
123
|
+
if (!components[subcommand])
|
|
124
|
+
throw new Error("check client must be codex, claude, or pi.");
|
|
125
|
+
const result = {
|
|
126
|
+
client: subcommand,
|
|
127
|
+
readiness: readiness ?? null,
|
|
128
|
+
...options.includeStatus ? { status } : {},
|
|
129
|
+
...evaluateAiClientReadiness(readiness)
|
|
130
|
+
};
|
|
131
|
+
if (wantsJson)
|
|
132
|
+
printJson(stdout, result);
|
|
133
|
+
else
|
|
134
|
+
stdout.write(`${result.message}
|
|
135
|
+
`);
|
|
136
|
+
return result.ok ? 0 : 1;
|
|
137
|
+
}
|
|
138
|
+
if (command === "repair" && subcommand) {
|
|
139
|
+
const result = subcommand === "codex" ? await repairCodex() : subcommand === "claude" ? await setupClaudeIntegration() : subcommand === "pi" ? await setupPiIntegration() : null;
|
|
140
|
+
if (!result)
|
|
141
|
+
throw new Error("repair client must be codex, claude, or pi.");
|
|
142
|
+
if (wantsJson)
|
|
143
|
+
printJson(stdout, result);
|
|
144
|
+
else
|
|
145
|
+
stdout.write(`${result.ok ? "AI Client integration repaired." : result.error ?? "AI Client integration repair failed."}
|
|
146
|
+
`);
|
|
147
|
+
return result.ok ? 0 : 1;
|
|
148
|
+
}
|
|
149
|
+
if (command === "remove" && subcommand) {
|
|
150
|
+
const result = subcommand === "codex" ? removeCodexIntegrationFn() : subcommand === "claude" ? removeClaudeIntegration() : subcommand === "pi" ? removePiIntegration() : null;
|
|
151
|
+
if (!result)
|
|
152
|
+
throw new Error("remove client must be codex, claude, or pi.");
|
|
153
|
+
if (wantsJson)
|
|
154
|
+
printJson(stdout, result);
|
|
155
|
+
else
|
|
156
|
+
stdout.write(`${result.ok ? "AI Client integration removed." : result.error ?? "AI Client integration removal failed."}
|
|
157
|
+
`);
|
|
158
|
+
return result.ok ? 0 : 1;
|
|
159
|
+
}
|
|
160
|
+
throw new Error("Unknown AI Client integration operation.");
|
|
161
|
+
} catch (error) {
|
|
162
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
163
|
+
if (wantsJson)
|
|
164
|
+
printJson(stdout, { ok: false, error: message });
|
|
165
|
+
else
|
|
166
|
+
stderr.write(`${message}
|
|
167
|
+
`);
|
|
168
|
+
return 1;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
export {
|
|
172
|
+
runIntegrationCommand
|
|
173
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
activateServerPackage,
|
|
4
|
+
assertPackageMigrationCompatible,
|
|
5
|
+
cleanupServerPackages,
|
|
6
|
+
collectServerPackageStatus,
|
|
7
|
+
extractVerifiedPackageArchive,
|
|
8
|
+
installServerPackage,
|
|
9
|
+
isVersionDowngrade,
|
|
10
|
+
packageExtractionLimits,
|
|
11
|
+
packageProvenanceSchemaVersion,
|
|
12
|
+
requiredPackageRuntimeFiles,
|
|
13
|
+
sha256File,
|
|
14
|
+
standalonePackageId,
|
|
15
|
+
standalonePackageKind,
|
|
16
|
+
standalonePackageSchemaVersion,
|
|
17
|
+
validateServerPackageRoot
|
|
18
|
+
} from "./chunk-2DA7EFZV.js";
|
|
19
|
+
import "./chunk-BTS4ZTF3.js";
|
|
20
|
+
export {
|
|
21
|
+
activateServerPackage,
|
|
22
|
+
assertPackageMigrationCompatible,
|
|
23
|
+
cleanupServerPackages,
|
|
24
|
+
collectServerPackageStatus,
|
|
25
|
+
extractVerifiedPackageArchive,
|
|
26
|
+
installServerPackage,
|
|
27
|
+
isVersionDowngrade,
|
|
28
|
+
packageExtractionLimits,
|
|
29
|
+
packageProvenanceSchemaVersion,
|
|
30
|
+
requiredPackageRuntimeFiles,
|
|
31
|
+
sha256File,
|
|
32
|
+
standalonePackageId,
|
|
33
|
+
standalonePackageKind,
|
|
34
|
+
standalonePackageSchemaVersion,
|
|
35
|
+
validateServerPackageRoot
|
|
36
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/local-models-runtime.js
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { createReadStream, createWriteStream, existsSync, mkdirSync, renameSync, rmSync, statSync } from "node:fs";
|
|
6
|
+
import { Readable, Transform } from "node:stream";
|
|
7
|
+
import { pipeline } from "node:stream/promises";
|
|
8
|
+
import { basename, dirname, resolve } from "node:path";
|
|
9
|
+
var MODEL_DEFINITIONS = {
|
|
10
|
+
embedding: {
|
|
11
|
+
key: "qwen3-0.6b",
|
|
12
|
+
filename: "Qwen3-Embedding-0.6B-Q8_0.gguf",
|
|
13
|
+
urlEnv: "KOED_EMBEDDING_MODEL_URL",
|
|
14
|
+
sha256Env: "KOED_EMBEDDING_MODEL_SHA256",
|
|
15
|
+
pathEnv: "KOED_EMBEDDING_MODEL_PATH",
|
|
16
|
+
defaultUrl: "https://huggingface.co/Qwen/Qwen3-Embedding-0.6B-GGUF/resolve/main/Qwen3-Embedding-0.6B-Q8_0.gguf",
|
|
17
|
+
defaultSha256: "06507c7b42688469c4e7298b0a1e16deff06caf291cf0a5b278c308249c3e439"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var localModelKinds = ["embedding"];
|
|
21
|
+
var trimEnv = (environment, name) => {
|
|
22
|
+
const value = environment[name]?.trim();
|
|
23
|
+
return value ? value : void 0;
|
|
24
|
+
};
|
|
25
|
+
var dependencyMode = (environment) => {
|
|
26
|
+
const value = trimEnv(environment, "KOED_DEPENDENCY_MODE");
|
|
27
|
+
if (value === "bundled-local" || value === "external") {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return void 0;
|
|
31
|
+
};
|
|
32
|
+
var modelDownloadBlockedAction = (manifest) => `External dependency mode does not download model assets. Switch to bundled-local mode or set ${manifest.pathEnv} to an existing model file.`;
|
|
33
|
+
var normalizeSha256 = (value) => {
|
|
34
|
+
const normalized = value?.trim().toLowerCase();
|
|
35
|
+
if (!normalized) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
if (!/^[a-f0-9]{64}$/.test(normalized)) {
|
|
39
|
+
throw new Error("Model SHA-256 must be 64 lowercase or uppercase hex characters.");
|
|
40
|
+
}
|
|
41
|
+
return normalized;
|
|
42
|
+
};
|
|
43
|
+
var resolveLocalModelManifest = (paths, kind = "embedding", environment = process.env) => {
|
|
44
|
+
const definition = MODEL_DEFINITIONS[kind];
|
|
45
|
+
const explicitPath = trimEnv(environment, definition.pathEnv);
|
|
46
|
+
return {
|
|
47
|
+
kind,
|
|
48
|
+
key: definition.key,
|
|
49
|
+
filename: definition.filename,
|
|
50
|
+
modelPath: explicitPath ? resolve(explicitPath) : resolve(paths.modelsDir, definition.filename),
|
|
51
|
+
urlEnv: definition.urlEnv,
|
|
52
|
+
sha256Env: definition.sha256Env,
|
|
53
|
+
pathEnv: definition.pathEnv,
|
|
54
|
+
url: trimEnv(environment, definition.urlEnv) ?? definition.defaultUrl,
|
|
55
|
+
sha256: normalizeSha256(trimEnv(environment, definition.sha256Env) ?? definition.defaultSha256),
|
|
56
|
+
defaultUrl: definition.defaultUrl,
|
|
57
|
+
defaultSha256: definition.defaultSha256
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
var sha256File = async (path) => {
|
|
61
|
+
const hash = createHash("sha256");
|
|
62
|
+
await pipeline(createReadStream(path), hash);
|
|
63
|
+
return hash.digest("hex");
|
|
64
|
+
};
|
|
65
|
+
var collectLocalModelStatus = async (paths, kind = "embedding", environment = process.env) => {
|
|
66
|
+
const manifest = resolveLocalModelManifest(paths, kind, environment);
|
|
67
|
+
const mode = dependencyMode(environment);
|
|
68
|
+
if (!existsSync(manifest.modelPath)) {
|
|
69
|
+
return {
|
|
70
|
+
state: "missing",
|
|
71
|
+
message: `${manifest.key} model is not installed at ${manifest.modelPath}.`,
|
|
72
|
+
action: mode === "external" ? modelDownloadBlockedAction(manifest) : `Run koed models install --kind ${kind}. Override ${manifest.urlEnv} and ${manifest.sha256Env} only when using a custom model artifact.`,
|
|
73
|
+
modelPath: manifest.modelPath,
|
|
74
|
+
manifest
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const sizeBytes = statSync(manifest.modelPath).size;
|
|
78
|
+
if (!manifest.sha256) {
|
|
79
|
+
return {
|
|
80
|
+
state: "not_configured",
|
|
81
|
+
message: `${manifest.key} model exists, but ${manifest.sha256Env} is not configured for verification.`,
|
|
82
|
+
action: `Set ${manifest.sha256Env} to verify installed model checksum.`,
|
|
83
|
+
modelPath: manifest.modelPath,
|
|
84
|
+
sizeBytes,
|
|
85
|
+
manifest
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const actual = await sha256File(manifest.modelPath);
|
|
89
|
+
if (actual !== manifest.sha256) {
|
|
90
|
+
return {
|
|
91
|
+
state: "checksum_mismatch",
|
|
92
|
+
message: `${manifest.key} model checksum mismatch.`,
|
|
93
|
+
action: `Remove ${manifest.modelPath}, verify ${manifest.sha256Env}, then run koed models install --kind ${kind}.`,
|
|
94
|
+
modelPath: manifest.modelPath,
|
|
95
|
+
sizeBytes,
|
|
96
|
+
sha256: actual,
|
|
97
|
+
manifest
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
state: "installed",
|
|
102
|
+
message: `${manifest.key} model is installed and checksum verified.`,
|
|
103
|
+
modelPath: manifest.modelPath,
|
|
104
|
+
sizeBytes,
|
|
105
|
+
sha256: actual,
|
|
106
|
+
manifest
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
var installLocalModel = async (paths, kind = "embedding", environment = process.env, { fetch: fetcher = globalThis.fetch.bind(globalThis), onProgress } = {}) => {
|
|
110
|
+
const manifest = resolveLocalModelManifest(paths, kind, environment);
|
|
111
|
+
const mode = dependencyMode(environment);
|
|
112
|
+
if (mode === "external") {
|
|
113
|
+
return {
|
|
114
|
+
ok: false,
|
|
115
|
+
state: "not_configured",
|
|
116
|
+
message: `${manifest.key} model downloads are disabled in external dependency mode.`,
|
|
117
|
+
action: modelDownloadBlockedAction(manifest),
|
|
118
|
+
modelPath: manifest.modelPath,
|
|
119
|
+
manifest
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (!manifest.url) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
state: "not_configured",
|
|
126
|
+
message: `${manifest.urlEnv} is required to install ${manifest.key}.`,
|
|
127
|
+
action: `Set ${manifest.urlEnv} to HTTPS model artifact URL.`,
|
|
128
|
+
modelPath: manifest.modelPath,
|
|
129
|
+
manifest
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (!manifest.sha256) {
|
|
133
|
+
return {
|
|
134
|
+
ok: false,
|
|
135
|
+
state: "not_configured",
|
|
136
|
+
message: `${manifest.sha256Env} is required before installing ${manifest.key}.`,
|
|
137
|
+
action: `Set ${manifest.sha256Env} to expected SHA-256 checksum.`,
|
|
138
|
+
modelPath: manifest.modelPath,
|
|
139
|
+
manifest
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
if (new URL(manifest.url).protocol !== "https:") {
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
state: "not_configured",
|
|
147
|
+
message: `${manifest.urlEnv} must be an HTTPS URL.`,
|
|
148
|
+
action: `Set ${manifest.urlEnv} to a trusted HTTPS model artifact URL.`,
|
|
149
|
+
modelPath: manifest.modelPath,
|
|
150
|
+
manifest
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
state: "not_configured",
|
|
157
|
+
message: `${manifest.urlEnv} must be a valid HTTPS URL.`,
|
|
158
|
+
action: `Set ${manifest.urlEnv} to a trusted HTTPS model artifact URL.`,
|
|
159
|
+
modelPath: manifest.modelPath,
|
|
160
|
+
manifest
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
mkdirSync(dirname(manifest.modelPath), { recursive: true, mode: 448 });
|
|
164
|
+
const tempPath = resolve(paths.cacheDir, `${basename(manifest.modelPath)}.${process.pid}.download`);
|
|
165
|
+
mkdirSync(paths.cacheDir, { recursive: true, mode: 448 });
|
|
166
|
+
rmSync(tempPath, { force: true });
|
|
167
|
+
const response = await fetcher(manifest.url);
|
|
168
|
+
if (!response.ok || !response.body) {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
state: "missing",
|
|
172
|
+
message: `Could not download ${manifest.key}: HTTP ${response.status}.`,
|
|
173
|
+
action: `Check ${manifest.urlEnv}, network access, and artifact permissions.`,
|
|
174
|
+
modelPath: manifest.modelPath,
|
|
175
|
+
manifest
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const contentLength = Number.parseInt(response.headers.get("content-length") ?? "", 10);
|
|
179
|
+
const totalBytes = Number.isSafeInteger(contentLength) && contentLength >= 0 ? contentLength : null;
|
|
180
|
+
let completedBytes = 0;
|
|
181
|
+
let lastReportedBytes = 0;
|
|
182
|
+
let lastReportedAt = 0;
|
|
183
|
+
onProgress?.({
|
|
184
|
+
completedBytes: 0,
|
|
185
|
+
phase: "downloading",
|
|
186
|
+
totalBytes
|
|
187
|
+
});
|
|
188
|
+
const progress = new Transform({
|
|
189
|
+
transform(chunk, _encoding, callback) {
|
|
190
|
+
completedBytes += chunk.byteLength;
|
|
191
|
+
const now = Date.now();
|
|
192
|
+
if (completedBytes === totalBytes || completedBytes - lastReportedBytes >= 1048576 || now - lastReportedAt >= 250) {
|
|
193
|
+
lastReportedBytes = completedBytes;
|
|
194
|
+
lastReportedAt = now;
|
|
195
|
+
onProgress?.({
|
|
196
|
+
completedBytes,
|
|
197
|
+
phase: "downloading",
|
|
198
|
+
totalBytes
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
callback(null, chunk);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
await pipeline(Readable.fromWeb(response.body), progress, createWriteStream(tempPath, { mode: 384 }));
|
|
205
|
+
onProgress?.({
|
|
206
|
+
completedBytes,
|
|
207
|
+
phase: "verifying",
|
|
208
|
+
totalBytes
|
|
209
|
+
});
|
|
210
|
+
const actual = await sha256File(tempPath);
|
|
211
|
+
if (actual !== manifest.sha256) {
|
|
212
|
+
rmSync(tempPath, { force: true });
|
|
213
|
+
return {
|
|
214
|
+
ok: false,
|
|
215
|
+
state: "checksum_mismatch",
|
|
216
|
+
message: `${manifest.key} downloaded checksum mismatch.`,
|
|
217
|
+
action: `Verify ${manifest.sha256Env} and ${manifest.urlEnv}.`,
|
|
218
|
+
modelPath: manifest.modelPath,
|
|
219
|
+
sha256: actual,
|
|
220
|
+
manifest
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
renameSync(tempPath, manifest.modelPath);
|
|
224
|
+
const sizeBytes = statSync(manifest.modelPath).size;
|
|
225
|
+
const status = {
|
|
226
|
+
state: "installed",
|
|
227
|
+
message: `${manifest.key} model is installed and checksum verified.`,
|
|
228
|
+
modelPath: manifest.modelPath,
|
|
229
|
+
sizeBytes,
|
|
230
|
+
sha256: actual,
|
|
231
|
+
manifest
|
|
232
|
+
};
|
|
233
|
+
onProgress?.({
|
|
234
|
+
completedBytes: sizeBytes,
|
|
235
|
+
phase: "complete",
|
|
236
|
+
totalBytes: sizeBytes
|
|
237
|
+
});
|
|
238
|
+
return { ok: true, ...status };
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
localModelKinds,
|
|
243
|
+
resolveLocalModelManifest,
|
|
244
|
+
sha256File,
|
|
245
|
+
collectLocalModelStatus,
|
|
246
|
+
installLocalModel
|
|
247
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
PRIVACY_MODEL_FILES,
|
|
4
|
+
PRIVACY_MODEL_ID,
|
|
5
|
+
PRIVACY_MODEL_REVISION,
|
|
6
|
+
collectPrivacyModelStatus,
|
|
7
|
+
installPrivacyModel,
|
|
8
|
+
materializePrivacyModelCacheEntry,
|
|
9
|
+
resolvePrivacyModelPaths
|
|
10
|
+
} from "./chunk-VPC5NLZG.js";
|
|
11
|
+
import "./chunk-473OA62O.js";
|
|
12
|
+
import "./chunk-BTS4ZTF3.js";
|
|
13
|
+
export {
|
|
14
|
+
PRIVACY_MODEL_FILES,
|
|
15
|
+
PRIVACY_MODEL_ID,
|
|
16
|
+
PRIVACY_MODEL_REVISION,
|
|
17
|
+
collectPrivacyModelStatus,
|
|
18
|
+
installPrivacyModel,
|
|
19
|
+
materializePrivacyModelCacheEntry,
|
|
20
|
+
resolvePrivacyModelPaths
|
|
21
|
+
};
|
package/vendor/cli.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
if (Number(process.versions.node.split(".")[0]) !== 24) { console.error(`@koed-labs/server requires Node.js >=24 <25; found ${process.versions.node}.`); process.exit(1); }
|
|
3
|
+
const { runKoedServerCli, shouldExitPackagedSupervisor } = await import("./control-plane.js");
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
const exitCode = await runKoedServerCli(args);
|
|
6
|
+
if (shouldExitPackagedSupervisor(args)) process.exit(exitCode);
|
|
7
|
+
process.exitCode = exitCode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
productionComponentManifestCatalog
|
|
4
|
+
} from "./chunk-QIIKMG3M.js";
|
|
5
|
+
import "./chunk-BTS4ZTF3.js";
|
|
6
|
+
export {
|
|
7
|
+
productionComponentManifestCatalog
|
|
8
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
isKoedServerCliEntrypoint,
|
|
4
|
+
runKoedServerCli,
|
|
5
|
+
shouldExitPackagedSupervisor
|
|
6
|
+
} from "./chunk-GELDEJJ2.js";
|
|
7
|
+
import {
|
|
8
|
+
startKoedServerDaemon
|
|
9
|
+
} from "./chunk-JKOG52PE.js";
|
|
10
|
+
import "./chunk-A4NKL2PK.js";
|
|
11
|
+
import {
|
|
12
|
+
productionComponentManifestCatalog
|
|
13
|
+
} from "./chunk-QIIKMG3M.js";
|
|
14
|
+
import "./chunk-K2EIFEQF.js";
|
|
15
|
+
import "./chunk-UI5RLBKQ.js";
|
|
16
|
+
import "./chunk-BTS4ZTF3.js";
|
|
17
|
+
export {
|
|
18
|
+
isKoedServerCliEntrypoint,
|
|
19
|
+
productionComponentManifestCatalog,
|
|
20
|
+
runKoedServerCli,
|
|
21
|
+
shouldExitPackagedSupervisor,
|
|
22
|
+
startKoedServerDaemon
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
const [entry, cacheDir] = process.argv.slice(2);
|
|
3
|
+
if (!entry || !cacheDir)
|
|
4
|
+
throw new Error("Privacy Service bootstrap requires entry and cache directory");
|
|
5
|
+
process.env.KOED_PRIVACY_TRANSFORMERS_CACHE = cacheDir;
|
|
6
|
+
await import(pathToFileURL(entry).href);
|