@koed-labs/server 0.11.1 → 1.2.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-2YCDKSKW.js +45 -0
- package/vendor/{chunk-TG26CZGQ.js → chunk-355BP3MF.js} +4 -4
- package/vendor/{chunk-RCR4XPE3.js → chunk-3VNLZCMB.js} +1 -1
- package/vendor/{chunk-NVTMIAAF.js → chunk-7YXEB2CR.js} +18 -17
- package/vendor/{chunk-SRKIBFOE.js → chunk-A2TMTAAS.js} +1 -1
- package/vendor/{chunk-PL3LWC5C.js → chunk-AJPFOTVX.js} +1 -1
- package/vendor/{chunk-O7DW2VAV.js → chunk-BDJR6CKS.js} +4 -3
- package/vendor/{chunk-Z5WCAUA6.js → chunk-BMHMNUNK.js} +18 -17
- package/vendor/{chunk-C5SNDPAP.js → chunk-CSDTMMRL.js} +4 -4
- package/vendor/{chunk-FYYRFX4U.js → chunk-CX73L6YS.js} +67 -38
- package/vendor/{chunk-VGIYSDNU.js → chunk-D4XZTNLU.js} +117 -33
- package/vendor/{chunk-W2OJZZ6X.js → chunk-DQ5SIGZZ.js} +4 -2
- package/vendor/{chunk-4OO6VAU3.js → chunk-G54Q5W6M.js} +1 -1
- package/vendor/{chunk-EA4QDDQA.js → chunk-GEIN6UIL.js} +7 -2
- package/vendor/{chunk-QRKHHWJJ.js → chunk-H7ETSD25.js} +51 -3
- package/vendor/{chunk-NOU7RHYZ.js → chunk-HG47LAWW.js} +5 -4
- package/vendor/{chunk-C4V72GXC.js → chunk-HXL36SED.js} +19 -18
- package/vendor/{chunk-FN3HUUO2.js → chunk-I5XO5FL4.js} +73 -13
- package/vendor/{chunk-TVYEB2GN.js → chunk-J7LW6JFY.js} +48 -10
- package/vendor/{chunk-OCILJ737.js → chunk-JG7OELJM.js} +9 -9
- package/vendor/{chunk-6KS67EQE.js → chunk-KBECHDUE.js} +1 -1
- package/vendor/{chunk-2XKSVKQA.js → chunk-KH4UBONI.js} +3 -2
- package/vendor/{chunk-ZIOKV2X6.js → chunk-MFPPURFE.js} +113 -33
- package/vendor/{chunk-GFASBPV2.js → chunk-MHFYPBCL.js} +3 -3
- package/vendor/{chunk-V67IQB7H.js → chunk-OG7G6DIR.js} +1 -1
- package/vendor/{chunk-WDFERJG3.js → chunk-TAQWNZVD.js} +109 -33
- package/vendor/{chunk-HC76426R.js → chunk-TMCW2P6G.js} +7 -5
- package/vendor/chunk-ULLAURFV.js +8 -0
- package/vendor/{chunk-WPIEF4LY.js → chunk-ULUSFNAE.js} +3 -3
- package/vendor/{chunk-ZOHNXUDY.js → chunk-VWB3VEOL.js} +493 -20
- package/vendor/{chunk-LRP66XEY.js → chunk-XPSPPLX5.js} +14 -14
- package/vendor/{chunk-SHLRINKO.js → chunk-XSOQ2U5H.js} +2 -2
- package/vendor/{chunk-EDPNYIX5.js → chunk-XTQYFCVY.js} +146 -89
- package/vendor/{chunk-CHMH4LH5.js → chunk-XW7AXRDI.js} +3 -3
- package/vendor/{chunk-SNKWETM5.js → chunk-Y5OJXAUF.js} +2 -2
- package/vendor/chunk-YDZEMIAH.js +11 -0
- package/vendor/{chunk-BUIM2M4R.js → chunk-YOMK7KMB.js} +2 -2
- package/vendor/{chunk-ALJUSOF7.js → chunk-YY7NMZGD.js} +79 -1
- package/vendor/{chunk-BGENSONI.js → chunk-ZKKWLLPU.js} +1 -1
- package/vendor/cli.js +1 -1
- package/vendor/component-manifest-catalog.js +1 -1
- package/vendor/control-plane.js +6 -4
- package/vendor/chunk-7EGSY3E4.js +0 -8
- package/vendor/chunk-ZUDSZGVO.js +0 -11
|
@@ -74,7 +74,7 @@ var packagedRuntime = (selection, requirements, exists) => {
|
|
|
74
74
|
const mcpCli = resolve(root, "mcp-server/dist/cli.js");
|
|
75
75
|
const localAiRuntime = resolve(root, "mcp-server/dist/local-runtime-cli.js");
|
|
76
76
|
const captureHook = resolve(root, "mcp-server/dist/capture-hook.js");
|
|
77
|
-
const dbPackageRoot = resolve(root, "node_modules/@koed/db");
|
|
77
|
+
const dbPackageRoot = resolve(root, "node_modules/@koed-labs/db");
|
|
78
78
|
const required = [
|
|
79
79
|
...selection ? [] : ["authenticated base generation"],
|
|
80
80
|
...requirements.processes.includes("api") ? [apiEntry] : [],
|
|
@@ -2,26 +2,28 @@ import { createRequire as createKoedRequire } from "node:module"; const require
|
|
|
2
2
|
import {
|
|
3
3
|
calculateRuntimeRequirements,
|
|
4
4
|
resolveEffectiveRuntimeConfig
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XSOQ2U5H.js";
|
|
6
6
|
import {
|
|
7
7
|
redeemPairingLink
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XW7AXRDI.js";
|
|
9
9
|
import {
|
|
10
10
|
bundledPdsSecretProviderEnvironment
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GEIN6UIL.js";
|
|
12
12
|
import {
|
|
13
13
|
resolveLocalModelManifest
|
|
14
14
|
} from "./chunk-JYK6UL6D.js";
|
|
15
15
|
import {
|
|
16
16
|
invalidateUpstreamEnrollmentReferences
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ULUSFNAE.js";
|
|
18
18
|
import {
|
|
19
19
|
collectKoedServerDoctor,
|
|
20
20
|
collectKoedServerStartupStatus,
|
|
21
21
|
collectKoedServerStatus,
|
|
22
|
+
embeddingServiceLeadsProcessGroup,
|
|
22
23
|
ensurePackagedLocalServiceSecrets,
|
|
23
24
|
hasCompletePostgresOverride,
|
|
24
25
|
koedServerStartupBlockingComponentIds,
|
|
26
|
+
localServiceSecretsPath,
|
|
25
27
|
migrateKoedOwnedCodexRegistrationBestEffort,
|
|
26
28
|
nativeLlamaServerOverride,
|
|
27
29
|
pinAndResolvePackagedRuntime,
|
|
@@ -39,7 +41,7 @@ import {
|
|
|
39
41
|
startLocalPostgresRuntime,
|
|
40
42
|
startLocalPrivacyRuntime,
|
|
41
43
|
stopLocalPostgresRuntime
|
|
42
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-XTQYFCVY.js";
|
|
43
45
|
import {
|
|
44
46
|
resolveActiveIntegrationApiToken,
|
|
45
47
|
resolveLocalApiToken,
|
|
@@ -49,13 +51,15 @@ import {
|
|
|
49
51
|
allocateAndPersistLocalPorts
|
|
50
52
|
} from "./chunk-TISYUUEJ.js";
|
|
51
53
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
applyResourceProfile,
|
|
55
|
+
resolveKoedServerConfig,
|
|
56
|
+
resourceProfileValues
|
|
57
|
+
} from "./chunk-YY7NMZGD.js";
|
|
54
58
|
import {
|
|
55
59
|
ensureDeviceIdentity,
|
|
56
60
|
inspectDeviceIdentityStatus,
|
|
57
61
|
rotateDeviceIdentity
|
|
58
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-A2TMTAAS.js";
|
|
59
63
|
import {
|
|
60
64
|
maintainSupervisorLog,
|
|
61
65
|
startKoedServerDaemon
|
|
@@ -77,20 +81,21 @@ import {
|
|
|
77
81
|
resolveKoedAppRuntime,
|
|
78
82
|
resolveKoedAppRuntimeExecution,
|
|
79
83
|
resolveKoedRuntimeOwner
|
|
80
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-OG7G6DIR.js";
|
|
81
85
|
import {
|
|
82
86
|
acquireKoedServerSupervisorLock,
|
|
83
87
|
observeStoppedRuntime,
|
|
84
88
|
readCurrentRuntimeOwner,
|
|
85
89
|
readSupervisorLock,
|
|
86
90
|
releaseKoedServerSupervisorLock,
|
|
91
|
+
removeStaleGenerationPin,
|
|
87
92
|
removeStaleRuntimeRecords,
|
|
88
93
|
resolveDesktopRuntimeOwner,
|
|
89
94
|
resolveProcessIdentity,
|
|
90
95
|
validateDesktopRuntimeCapability,
|
|
91
96
|
withLifecycleLock,
|
|
92
97
|
withSourceNativeStartLock
|
|
93
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-I5XO5FL4.js";
|
|
94
99
|
import {
|
|
95
100
|
isProcessRunning,
|
|
96
101
|
isRuntimeGenerationState,
|
|
@@ -100,11 +105,11 @@ import {
|
|
|
100
105
|
import {
|
|
101
106
|
listUpstreamBackends,
|
|
102
107
|
refreshUpstreamBackendCapabilities
|
|
103
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-3VNLZCMB.js";
|
|
104
109
|
import {
|
|
105
110
|
createPdsApplicationSecretStore,
|
|
106
111
|
isPrivateNetworkIpv4Address
|
|
107
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-VWB3VEOL.js";
|
|
108
113
|
|
|
109
114
|
// packages/koed-server/dist/personal-device-request.js
|
|
110
115
|
import { createHash as createHash2, randomBytes as randomBytes2, randomUUID as randomUUID2 } from "node:crypto";
|
|
@@ -666,7 +671,7 @@ var stopPid = (label, pid, deps) => {
|
|
|
666
671
|
return { stoppedPids: [], missingPids: [pid], errors: [] };
|
|
667
672
|
if (!identityMatches())
|
|
668
673
|
return identityError();
|
|
669
|
-
const target = deps.processGroup ? -pid : pid;
|
|
674
|
+
const target = deps.processGroup && pid > 1 ? -pid : pid;
|
|
670
675
|
try {
|
|
671
676
|
deps.kill(target, "SIGTERM");
|
|
672
677
|
if (waitForPidExit(target, deps)) {
|
|
@@ -788,7 +793,7 @@ var stopKoedServer = ({ environment = process.env, existsSync: pathExists = node
|
|
|
788
793
|
const lock = readLock(supervisorLockPath);
|
|
789
794
|
const supervisorRunning = runtime.pid > 0 && checkPid(runtime.pid);
|
|
790
795
|
const processIdentity = supervisorRunning ? resolveProcessIdentity2(runtime.pid) : null;
|
|
791
|
-
if (ownerPinRequired && !pin || pinExists && !pin || pin !== null && (pin.pid !== runtime.pid || !ownersMatch(pin.owner, owner) || lock?.pid !== runtime.pid || !lock.processIdentity || pin.processIdentity !== lock.processIdentity || supervisorRunning && processIdentity !== pin.processIdentity)) {
|
|
796
|
+
if (lock?.sourceOwner && !ownersMatch(lock.sourceOwner, owner) || ownerPinRequired && !pin || pinExists && !pin || pin !== null && (pin.pid !== runtime.pid || !ownersMatch(pin.owner, owner) || lock?.pid !== runtime.pid || !lock.processIdentity || pin.processIdentity !== lock.processIdentity || supervisorRunning && processIdentity !== pin.processIdentity)) {
|
|
792
797
|
supervisorLockMatches = false;
|
|
793
798
|
errors.push({
|
|
794
799
|
target: `supervisor (${runtime.pid})`,
|
|
@@ -828,7 +833,7 @@ var stopKoedServer = ({ environment = process.env, existsSync: pathExists = node
|
|
|
828
833
|
checkPid,
|
|
829
834
|
// Let the supervisor finish its bounded per-child shutdown before falling
|
|
830
835
|
// back to direct PID signals, which cannot reach llama-server descendants.
|
|
831
|
-
waitForExitMs: requestedWait ??
|
|
836
|
+
waitForExitMs: requestedWait ?? 6e4,
|
|
832
837
|
pollIntervalMs,
|
|
833
838
|
sleepSync
|
|
834
839
|
});
|
|
@@ -889,7 +894,7 @@ var stopKoedServer = ({ environment = process.env, existsSync: pathExists = node
|
|
|
889
894
|
expectedProcessIdentity: embeddingIdentity,
|
|
890
895
|
resolveProcessIdentity: resolveProcessIdentity2
|
|
891
896
|
} : {},
|
|
892
|
-
processGroup:
|
|
897
|
+
processGroup: embeddingPid > 1 && embeddingIdentity !== void 0 && checkPid(embeddingPid) && resolveProcessIdentity2(embeddingPid) === embeddingIdentity && isProcessGroupLeader(embeddingPid)
|
|
893
898
|
});
|
|
894
899
|
stoppedPids.push(...stopped.stoppedPids);
|
|
895
900
|
missingPids.push(...stopped.missingPids);
|
|
@@ -1109,7 +1114,7 @@ import { existsSync as existsSync3, mkdirSync as mkdirSync3 } from "node:fs";
|
|
|
1109
1114
|
import { dirname, resolve as resolve4 } from "node:path";
|
|
1110
1115
|
|
|
1111
1116
|
// packages/koed-server/dist/runtime-lifecycle.js
|
|
1112
|
-
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
1117
|
+
import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
1113
1118
|
import { resolve as resolve3 } from "node:path";
|
|
1114
1119
|
var readJson = (path) => {
|
|
1115
1120
|
try {
|
|
@@ -1149,22 +1154,61 @@ function observeRuntimeLifecycle(paths, { resolveProcessIdentity: resolveProcess
|
|
|
1149
1154
|
message: "Koed is not running."
|
|
1150
1155
|
};
|
|
1151
1156
|
const epoch = `${lock.pid}:${identity}`;
|
|
1152
|
-
const
|
|
1157
|
+
const pinPath = paths.generationStatePath ?? resolve3(paths.runDir, "runtime-generation.json");
|
|
1158
|
+
const pin = readJson(pinPath);
|
|
1153
1159
|
const pinned = isRuntimeGenerationState(pin) && pin.pid === lock.pid && pin.processIdentity === identity ? pin : null;
|
|
1154
1160
|
const runtime = readJson(paths.runtimeStatePath);
|
|
1155
|
-
const
|
|
1161
|
+
const owner = pinned?.owner ?? (!lstatSync2(pinPath, { throwIfNoEntry: false }) ? lock.sourceOwner : null);
|
|
1162
|
+
const running = !!owner && runtime?.pid === lock.pid;
|
|
1156
1163
|
return {
|
|
1157
1164
|
state: running ? "running" : "starting",
|
|
1158
1165
|
epoch,
|
|
1159
1166
|
message: running ? "Koed is running." : "Koed is starting.",
|
|
1160
1167
|
pid: lock.pid,
|
|
1161
1168
|
processIdentity: identity,
|
|
1162
|
-
owner:
|
|
1169
|
+
owner: owner ? { ...owner } : null,
|
|
1163
1170
|
...pinned ? { generationId: pinned.generationId } : {}
|
|
1164
1171
|
};
|
|
1165
1172
|
}
|
|
1166
1173
|
var runtimeOwnedBy = (observation, owner) => Boolean(observation.owner && observation.owner.kind === owner.kind && observation.owner.installationId === owner.installationId);
|
|
1167
1174
|
|
|
1175
|
+
// packages/koed-server/dist/process-priority.js
|
|
1176
|
+
import { getPriority as nodeGetPriority, setPriority as nodeSetPriority } from "node:os";
|
|
1177
|
+
var BACKGROUND_NICE_ENV = "KOED_BACKGROUND_NICE";
|
|
1178
|
+
var DEFAULT_BACKGROUND_NICE = resourceProfileValues("balanced", 1).backgroundNice;
|
|
1179
|
+
var MAX_NICE = 19;
|
|
1180
|
+
var nodeProcessPriority = {
|
|
1181
|
+
getPriority: (pid) => nodeGetPriority(pid),
|
|
1182
|
+
setPriority: (pid, priority) => nodeSetPriority(pid, priority)
|
|
1183
|
+
};
|
|
1184
|
+
var resolveBackgroundNice = (environment, warn = console.warn) => {
|
|
1185
|
+
const raw = environment[BACKGROUND_NICE_ENV]?.trim();
|
|
1186
|
+
if (!raw)
|
|
1187
|
+
return DEFAULT_BACKGROUND_NICE;
|
|
1188
|
+
if (!/^\d+$/.test(raw) || Number(raw) > MAX_NICE) {
|
|
1189
|
+
warn(`${BACKGROUND_NICE_ENV} must be an integer from 0 to ${MAX_NICE}; using ${DEFAULT_BACKGROUND_NICE}.`);
|
|
1190
|
+
return DEFAULT_BACKGROUND_NICE;
|
|
1191
|
+
}
|
|
1192
|
+
const value = Number(raw);
|
|
1193
|
+
return value === 0 ? null : value;
|
|
1194
|
+
};
|
|
1195
|
+
var lowerBackgroundServicePriority = (environment, api = nodeProcessPriority, warn = console.warn) => {
|
|
1196
|
+
const target = resolveBackgroundNice(environment, warn);
|
|
1197
|
+
if (target === null)
|
|
1198
|
+
return { applied: false, reason: "disabled" };
|
|
1199
|
+
try {
|
|
1200
|
+
const current = api.getPriority(0);
|
|
1201
|
+
if (current >= target) {
|
|
1202
|
+
return { applied: false, reason: "already_lower", priority: current };
|
|
1203
|
+
}
|
|
1204
|
+
api.setPriority(0, target);
|
|
1205
|
+
return { applied: true, priority: target };
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
warn(`Could not lower Koed background service priority: ${error instanceof Error ? error.message : String(error)}`);
|
|
1208
|
+
return { applied: false, reason: "failed" };
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1168
1212
|
// packages/koed-server/dist/start.js
|
|
1169
1213
|
var localRuntimeFailureDetails = (details) => {
|
|
1170
1214
|
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
@@ -1368,7 +1412,7 @@ var localServiceEnv = (environment, repoEnv, apiToken, paths) => {
|
|
|
1368
1412
|
MODEL_PATH: serverConfig.dependencyMode === "bundled-local" ? localEmbeddingModelPath : environment.EMBEDDING_MODEL_PATH ?? environment.MODEL_PATH,
|
|
1369
1413
|
LLAMA_SERVER_BINARY: environment.LLAMA_SERVER_BINARY ?? repoEnv.EMBEDDING_LLAMA_SERVER_BINARY ?? environment.EMBEDDING_LLAMA_SERVER_BINARY,
|
|
1370
1414
|
LLAMA_N_CTX: environment.EMBEDDING_LLAMA_N_CTX ?? environment.LLAMA_N_CTX ?? repoEnv.EMBEDDING_LLAMA_N_CTX,
|
|
1371
|
-
LLAMA_N_THREADS: environment.EMBEDDING_LLAMA_N_THREADS
|
|
1415
|
+
LLAMA_N_THREADS: environment.EMBEDDING_LLAMA_N_THREADS?.trim() || environment.LLAMA_N_THREADS?.trim() || repoEnv.EMBEDDING_LLAMA_N_THREADS?.trim() || repoEnv.LLAMA_N_THREADS?.trim() || void 0,
|
|
1372
1416
|
LLAMA_N_BATCH: environment.EMBEDDING_LLAMA_N_BATCH ?? environment.LLAMA_N_BATCH ?? repoEnv.EMBEDDING_LLAMA_N_BATCH,
|
|
1373
1417
|
LLAMA_BATCH_TOKEN_HEADROOM: environment.EMBEDDING_LLAMA_BATCH_TOKEN_HEADROOM ?? environment.LLAMA_BATCH_TOKEN_HEADROOM ?? repoEnv.EMBEDDING_LLAMA_BATCH_TOKEN_HEADROOM,
|
|
1374
1418
|
LLAMA_N_UBATCH: environment.EMBEDDING_LLAMA_N_UBATCH ?? environment.LLAMA_N_UBATCH ?? repoEnv.EMBEDDING_LLAMA_N_UBATCH,
|
|
@@ -1399,7 +1443,10 @@ var waitForChildExit = (child, timeoutMs) => new Promise((resolveExit) => {
|
|
|
1399
1443
|
const timeout = setTimeout(() => finish(false), timeoutMs);
|
|
1400
1444
|
child.once("exit", onExit);
|
|
1401
1445
|
});
|
|
1446
|
+
var isSignalableProcessGroup = (pid) => Number.isSafeInteger(pid) && pid > 1;
|
|
1402
1447
|
var processGroupAlive = (pid) => {
|
|
1448
|
+
if (!isSignalableProcessGroup(pid))
|
|
1449
|
+
return false;
|
|
1403
1450
|
try {
|
|
1404
1451
|
process.kill(-pid, 0);
|
|
1405
1452
|
return true;
|
|
@@ -1436,7 +1483,7 @@ var stopChildProcess = async (child, timeoutMs = 5e3, label = "managed child", p
|
|
|
1436
1483
|
return;
|
|
1437
1484
|
const pid = child.pid;
|
|
1438
1485
|
const exited = () => child.exitCode != null || child.signalCode != null;
|
|
1439
|
-
if (!privateGroup) {
|
|
1486
|
+
if (!privateGroup || !isSignalableProcessGroup(pid)) {
|
|
1440
1487
|
if (exited())
|
|
1441
1488
|
return;
|
|
1442
1489
|
child.kill("SIGTERM");
|
|
@@ -1521,12 +1568,16 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1521
1568
|
const startupId = randomBytes3(12).toString("hex");
|
|
1522
1569
|
const startupStartedAt = process.hrtime.bigint();
|
|
1523
1570
|
const emitStartupMilestone = (milestone) => {
|
|
1524
|
-
|
|
1571
|
+
const line = JSON.stringify({
|
|
1525
1572
|
event: "koed.supervisor.startup",
|
|
1526
1573
|
startupId,
|
|
1527
1574
|
milestone,
|
|
1528
1575
|
elapsedMs: Number(process.hrtime.bigint() - startupStartedAt) / 1e6
|
|
1529
|
-
})
|
|
1576
|
+
});
|
|
1577
|
+
console.log(line);
|
|
1578
|
+
if (process.env.KOED_SUPERVISOR_STARTUP_TRACE === "1")
|
|
1579
|
+
process.stderr.write(`${line}
|
|
1580
|
+
`);
|
|
1530
1581
|
};
|
|
1531
1582
|
emitStartupMilestone("supervisor_entry");
|
|
1532
1583
|
const execution = resolveKoedAppRuntimeExecution();
|
|
@@ -1549,6 +1600,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1549
1600
|
assertObservedOwner(observeRuntimeLifecycle(paths));
|
|
1550
1601
|
ensureKoedHome(paths);
|
|
1551
1602
|
const supervisorLock = acquireKoedServerSupervisorLock(paths, {
|
|
1603
|
+
...execution === "source" ? { sourceOwner: resolveKoedRuntimeOwner() } : {},
|
|
1552
1604
|
exclusive: (action) => withLifecycleLock(paths, action)
|
|
1553
1605
|
});
|
|
1554
1606
|
if (!supervisorLock.acquired) {
|
|
@@ -1580,6 +1632,12 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1580
1632
|
throw error;
|
|
1581
1633
|
}
|
|
1582
1634
|
};
|
|
1635
|
+
if (execution === "source") {
|
|
1636
|
+
startupPhase = "stale generation pin cleanup";
|
|
1637
|
+
await initializeUnderSupervisorLock(() => {
|
|
1638
|
+
removeStaleGenerationPin(paths);
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1583
1641
|
startupPhase = "device identity initialization";
|
|
1584
1642
|
await initializeUnderSupervisorLock(() => ensureDeviceIdentity(paths, { environment }));
|
|
1585
1643
|
const supervisorStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1594,10 +1652,11 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1594
1652
|
};
|
|
1595
1653
|
const desktopManagedLocal = environment.KOED_AUTO_PORTS === "1";
|
|
1596
1654
|
const startupConfig = effectiveRuntimeConfig.config;
|
|
1655
|
+
const bundledPersonal = startupConfig.runtimeMode === "local-personal" && startupConfig.dependencyMode === "bundled-local";
|
|
1597
1656
|
startupPhase = "packaged local service secrets";
|
|
1598
|
-
environment = await initializeUnderSupervisorLock(() => ensurePackagedLocalServiceSecrets(paths, execution === "packaged" ||
|
|
1657
|
+
environment = await initializeUnderSupervisorLock(() => ensurePackagedLocalServiceSecrets(paths, execution === "packaged" || bundledPersonal, environment));
|
|
1599
1658
|
mkdirSync3(paths.logsDir, { recursive: true, mode: 448 });
|
|
1600
|
-
if (
|
|
1659
|
+
if (bundledPersonal && environment.KOED_AUTO_PORTS === void 0) {
|
|
1601
1660
|
environment = { ...environment, KOED_AUTO_PORTS: "1" };
|
|
1602
1661
|
}
|
|
1603
1662
|
const portAllocationEnvironment = { ...environment };
|
|
@@ -1644,6 +1703,13 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1644
1703
|
});
|
|
1645
1704
|
}
|
|
1646
1705
|
const config = startupConfig;
|
|
1706
|
+
if (config.runtimeMode !== "external") {
|
|
1707
|
+
environment = applyResourceProfile(environment, config.resourceProfile, {
|
|
1708
|
+
explicit: repoEnv,
|
|
1709
|
+
overrides: config.resourceOverrides
|
|
1710
|
+
});
|
|
1711
|
+
console.log(`Koed resource profile: ${config.resourceProfile}.`);
|
|
1712
|
+
}
|
|
1647
1713
|
const initialServiceEnv = localServiceEnv(environment, repoEnv, apiToken, paths);
|
|
1648
1714
|
const useBundledLocalDependencies = config.dependencyMode === "bundled-local";
|
|
1649
1715
|
const teamCollaborationEnabled = effectiveRuntimeConfig.teamEnabled;
|
|
@@ -1661,7 +1727,10 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1661
1727
|
const childEnv = initialServiceEnv;
|
|
1662
1728
|
if (execution === "source") {
|
|
1663
1729
|
startupPhase = "source environment preparation";
|
|
1664
|
-
runCommand(paths, "Prepare Koed environment", process.execPath, [
|
|
1730
|
+
runCommand(paths, "Prepare Koed environment", process.execPath, [
|
|
1731
|
+
resolve4(paths.repoRoot, "scripts/setup-env.mjs"),
|
|
1732
|
+
...bundledPersonal ? ["--local-service-secrets", localServiceSecretsPath(paths)] : []
|
|
1733
|
+
], childEnv, spawnSync);
|
|
1665
1734
|
}
|
|
1666
1735
|
startupPhase = "refreshed repository environment and credentials";
|
|
1667
1736
|
const refreshedRepoEnv = await initializeUnderSupervisorLock(() => execution === "source" || environment.KOED_ENV_PATH?.trim() ? loadRepoEnv(paths.repoRoot, environment) : {});
|
|
@@ -1721,14 +1790,14 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1721
1790
|
];
|
|
1722
1791
|
for (const name of shutdownOrder) {
|
|
1723
1792
|
try {
|
|
1724
|
-
await stopChildProcess(managedChildren[name], 5e3, name, name === "embeddingService" &&
|
|
1793
|
+
await stopChildProcess(managedChildren[name], 5e3, name, name === "embeddingService" && embeddingServiceLeadsProcessGroup(paths));
|
|
1725
1794
|
} catch (error) {
|
|
1726
1795
|
cleanupErrors.push(error instanceof Error ? error.message : String(error));
|
|
1727
1796
|
}
|
|
1728
1797
|
}
|
|
1729
1798
|
if (nativeEmbeddingProcess && !Object.values(managedChildren).includes(nativeEmbeddingProcess)) {
|
|
1730
1799
|
try {
|
|
1731
|
-
await stopChildProcess(nativeEmbeddingProcess, 5e3, "embeddingService",
|
|
1800
|
+
await stopChildProcess(nativeEmbeddingProcess, 5e3, "embeddingService", embeddingServiceLeadsProcessGroup(paths));
|
|
1732
1801
|
} catch (error) {
|
|
1733
1802
|
cleanupErrors.push(error instanceof Error ? error.message : String(error));
|
|
1734
1803
|
}
|
|
@@ -1796,6 +1865,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1796
1865
|
signal?.addEventListener("abort", shutdown, { once: true });
|
|
1797
1866
|
process.on("SIGINT", shutdown);
|
|
1798
1867
|
process.on("SIGTERM", shutdown);
|
|
1868
|
+
process.on("SIGHUP", shutdown);
|
|
1799
1869
|
const stopSupervisorLogMaintenance = maintainSupervisorLog(refreshedEnv);
|
|
1800
1870
|
let sourceRuntimeLeaseAcquired = false;
|
|
1801
1871
|
let startupReady = false;
|
|
@@ -1810,7 +1880,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1810
1880
|
assertKoedAppRuntimeAvailable(appRuntime, paths);
|
|
1811
1881
|
}
|
|
1812
1882
|
if (useBundledLocalDependencies && hasReleaseRuntime(paths) && !(hasCompletePostgresOverride(refreshedEnv) && nativeLlamaServerOverride(refreshedEnv))) {
|
|
1813
|
-
const { resolveSelectedCoreForStart } = await import("./chunk-
|
|
1883
|
+
const { resolveSelectedCoreForStart } = await import("./chunk-D4XZTNLU.js");
|
|
1814
1884
|
const admitSelection = () => resolveSelectedCoreForStart(paths, refreshedEnv, !nativeLlamaServerOverride(refreshedEnv));
|
|
1815
1885
|
const selected = generationPin ? admitSelection() : withSourceNativeStartLock(paths, admitSelection);
|
|
1816
1886
|
if (selected)
|
|
@@ -1827,6 +1897,11 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1827
1897
|
emitStartupMilestone("source_runtime_verification_complete");
|
|
1828
1898
|
}
|
|
1829
1899
|
startupPhase = "service dependency validation and startup";
|
|
1900
|
+
if (config.runtimeMode !== "external") {
|
|
1901
|
+
const priority = lowerBackgroundServicePriority(refreshedEnv);
|
|
1902
|
+
if (priority.applied)
|
|
1903
|
+
console.log(`Koed background services run at nice ${priority.priority} (${BACKGROUND_NICE_ENV}).`);
|
|
1904
|
+
}
|
|
1830
1905
|
if (config.dependencyMode === "external") {
|
|
1831
1906
|
const queueBackend = requiredRuntime.queue;
|
|
1832
1907
|
const requiredExternalServices = [
|
|
@@ -1893,7 +1968,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1893
1968
|
const api = appRuntime.kind === "packaged" ? spawnManagedProcess(paths, "API", process.execPath, [appRuntime.apiEntry], appProcessEnvironment(refreshedEnv), spawn, resolve4(appRuntime.root, "api")) : spawnManagedProcess(paths, "API", process.execPath, [resolve4(paths.repoRoot, "apps/api/dist/index.js")], appProcessEnvironment(refreshedEnv), spawn, resolve4(paths.repoRoot, "apps/api"));
|
|
1894
1969
|
manageChild("api", api);
|
|
1895
1970
|
emitStartupMilestone("api_process_spawned");
|
|
1896
|
-
const embeddingIdentity = paths
|
|
1971
|
+
const embeddingIdentity = embeddingServiceLeadsProcessGroup(paths) && nativeEmbeddingProcess?.pid ? resolveProcessIdentity(nativeEmbeddingProcess.pid) : null;
|
|
1897
1972
|
const runtime = {
|
|
1898
1973
|
pid: process.pid,
|
|
1899
1974
|
startedAt: supervisorStartedAt,
|
|
@@ -1906,7 +1981,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
1906
1981
|
claudeTranscriptWatcherEnabled: config.claudeTranscriptWatcherEnabled,
|
|
1907
1982
|
piTranscriptWatcherEnabled: config.piTranscriptWatcherEnabled,
|
|
1908
1983
|
services: [...runtimeServices, "api"],
|
|
1909
|
-
// The
|
|
1984
|
+
// The native Embedding Service leads a private process group.
|
|
1910
1985
|
// koed stop signals that group only while its leader keeps this identity.
|
|
1911
1986
|
...embeddingIdentity ? { processIdentities: { embeddingService: embeddingIdentity } } : {},
|
|
1912
1987
|
processes: {
|
|
@@ -2009,7 +2084,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
2009
2084
|
}
|
|
2010
2085
|
emitStartupMilestone("core_services_ready");
|
|
2011
2086
|
startupReady = true;
|
|
2012
|
-
onReady?.();
|
|
2087
|
+
onReady?.(refreshedEnv);
|
|
2013
2088
|
console.log(JSON.stringify(status, null, 2));
|
|
2014
2089
|
emitStartupMilestone("final_supervisor_status_emitted");
|
|
2015
2090
|
console.log("Koed server supervisor is running. Press Ctrl-C to stop local app processes.");
|
|
@@ -2036,6 +2111,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
|
|
|
2036
2111
|
stopSupervisorLogMaintenance();
|
|
2037
2112
|
process.off("SIGINT", shutdown);
|
|
2038
2113
|
process.off("SIGTERM", shutdown);
|
|
2114
|
+
process.off("SIGHUP", shutdown);
|
|
2039
2115
|
signal?.removeEventListener("abort", shutdown);
|
|
2040
2116
|
managedProcessMonitor.dispose();
|
|
2041
2117
|
if (runtimeStateWritten) {
|
|
@@ -13,17 +13,18 @@ import {
|
|
|
13
13
|
readCurrentRuntimeOwner,
|
|
14
14
|
readDesktopBundleGeneration,
|
|
15
15
|
readDesktopGenerationForCapability,
|
|
16
|
+
removeStaleGenerationPin,
|
|
16
17
|
stageDesktopBundleForRecovery,
|
|
17
18
|
withLifecycleLock,
|
|
18
19
|
withSourceNativeStartLock,
|
|
19
20
|
withStoppedRuntime
|
|
20
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-I5XO5FL4.js";
|
|
21
22
|
import "./chunk-T6UB5PNX.js";
|
|
22
23
|
import "./chunk-7NXKPDF3.js";
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-YDZEMIAH.js";
|
|
25
|
+
import "./chunk-MFPPURFE.js";
|
|
26
|
+
import "./chunk-H7ETSD25.js";
|
|
27
|
+
import "./chunk-ULLAURFV.js";
|
|
27
28
|
import "./chunk-IY2HRXOZ.js";
|
|
28
29
|
import "./chunk-FSNLU46W.js";
|
|
29
30
|
import "./chunk-BTS4ZTF3.js";
|
|
@@ -41,6 +42,7 @@ export {
|
|
|
41
42
|
readCurrentRuntimeOwner,
|
|
42
43
|
readDesktopBundleGeneration,
|
|
43
44
|
readDesktopGenerationForCapability,
|
|
45
|
+
removeStaleGenerationPin,
|
|
44
46
|
stageDesktopBundleForRecovery,
|
|
45
47
|
withLifecycleLock,
|
|
46
48
|
withSourceNativeStartLock,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/native-runtime-catalog-data.mjs
|
|
4
|
+
var productionNativeRuntimeCatalog = { "schemaVersion": 2, "linux": { "schemaVersion": 1, "minimumCoreVersion": "0.10.3", "core": { "recipeId": "f4ff165a91e23eae1278c93ee7a72376cc4e7418eea30c16ee6561cde66690e6", "runtimeVersion": "1.0.0", "url": "https://github.com/koed-labs/koed/releases/download/v1.2.0/koed-native-core-f4ff165a91e23eae1278c93ee7a72376cc4e7418eea30c16ee6561cde66690e6-linux-x64.tar.gz", "sha256": "1e46555a37e69f20838fc7a78340e8519146fa20e8eb269261e638291dcbd98e", "manifestSha256": "4a6d8968f6505e6338d66f9bc039635fcc5a42c0ac39494f07be17fc6f43bc7d", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } }, "archiveBytes": 23988967, "expandedBytes": 56990678, "contracts": { "layout": 1, "embedding": 1, "postgres": 1 }, "components": { "postgres": { "major": 17, "version": "17.6" }, "pgvector": { "version": "0.8.3" }, "llamaCpp": { "version": "b10514", "revision": "7221e24f579efbb5fd2a2ced1fffaef1aff2fe0d" } } }, "cuda": { "recipeId": "16722edc4647561a6615063cd1ad29bcf4da8ec9bc2666847069441f592a7f93", "runtimeVersion": "1.0.0", "url": "https://github.com/koed-labs/koed/releases/download/v1.2.0/koed-native-cuda-16722edc4647561a6615063cd1ad29bcf4da8ec9bc2666847069441f592a7f93-linux-x64.tar.gz", "sha256": "b63eca8bb05e1ef37e38bcd3d70edda3edb9b0fe984a35e9f18aa77fb4b07188", "manifestSha256": "47de6e6876ead9bf052477249f0a7ccaffba615de5daf9506a87ef9c4055eba6", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } }, "archiveBytes": 711354383, "expandedBytes": 1467990043, "contracts": { "layout": 1, "embedding": 1 }, "llamaCpp": { "version": "b10514", "revision": "7221e24f579efbb5fd2a2ced1fffaef1aff2fe0d" }, "cuda": { "toolkitVersion": "12.4", "minimumDriverLinux": "550.54.14", "architectures": [75, 80, 86, 89, 90] } } }, "macos": { "schemaVersion": 1, "minimumCoreVersion": "1.2.0", "core": { "recipeId": "03c2e355a13e37504d3d269359f7ea3acee2c4afa5a125e36f7e5320d420e1bc", "runtimeVersion": "1.2.0", "url": "https://github.com/koed-labs/koed/releases/download/v1.2.0/koed-native-core-03c2e355a13e37504d3d269359f7ea3acee2c4afa5a125e36f7e5320d420e1bc-macos-arm64.tar.gz", "sha256": "0376f902c532df3b87481f203c7dabc63a196d0c4f931dcb0ffa4d31a81f7a54", "manifestSha256": "e05929de629a07e90336e1b69fc5f22d0411480541a744cbfa59e6d385788f80", "target": { "platform": "macos", "architecture": "arm64", "minimumVersion": "14.0" }, "archiveBytes": 34684910, "expandedBytes": 74679686, "contracts": { "layout": 1, "embedding": 1, "postgres": 1 }, "components": { "postgres": { "major": 17, "version": "17.6" }, "pgvector": { "version": "0.8.3" }, "llamaCpp": { "version": "b10514" } } }, "cuda": null } };
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
productionNativeRuntimeCatalog
|
|
8
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
ensureDeviceIdentity
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-A2TMTAAS.js";
|
|
5
5
|
import {
|
|
6
6
|
require_proper_lockfile
|
|
7
7
|
} from "./chunk-7NXKPDF3.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
upstreamBackendAdvertisesCapability,
|
|
20
20
|
upstreamBackendSupportsTeamMemoryAnswerTasks,
|
|
21
21
|
upstreamDisconnectCleanupPending
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-3VNLZCMB.js";
|
|
23
23
|
import {
|
|
24
24
|
assertSecureHttpTransport,
|
|
25
25
|
deleteLocalEdgeClientCredential,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
storeLocalEdgeClientCredential,
|
|
31
31
|
storeUpstreamCredentialSecret,
|
|
32
32
|
upstreamCredentialReferenceFor
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-VWB3VEOL.js";
|
|
34
34
|
import {
|
|
35
35
|
__toESM
|
|
36
36
|
} from "./chunk-BTS4ZTF3.js";
|