@koed-labs/server 1.0.0 → 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.
Files changed (41) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/vendor/chunk-2YCDKSKW.js +45 -0
  4. package/vendor/{chunk-F7AMEDDU.js → chunk-355BP3MF.js} +4 -4
  5. package/vendor/{chunk-WBMO7YCO.js → chunk-3VNLZCMB.js} +1 -1
  6. package/vendor/{chunk-EEBIYWTE.js → chunk-7YXEB2CR.js} +17 -16
  7. package/vendor/{chunk-LHUMBHG7.js → chunk-A2TMTAAS.js} +1 -1
  8. package/vendor/{chunk-VLP72QWX.js → chunk-AJPFOTVX.js} +1 -1
  9. package/vendor/{chunk-W6632NOX.js → chunk-BDJR6CKS.js} +4 -3
  10. package/vendor/{chunk-DWWMBGHX.js → chunk-BMHMNUNK.js} +17 -16
  11. package/vendor/{chunk-BYN6KXNP.js → chunk-CSDTMMRL.js} +4 -4
  12. package/vendor/{chunk-TIBYKMRW.js → chunk-CX73L6YS.js} +36 -43
  13. package/vendor/{chunk-273NMYXE.js → chunk-D4XZTNLU.js} +8 -7
  14. package/vendor/{chunk-64AST7WZ.js → chunk-DQ5SIGZZ.js} +3 -1
  15. package/vendor/{chunk-4DHYSJJT.js → chunk-G54Q5W6M.js} +1 -1
  16. package/vendor/{chunk-GY5GATZL.js → chunk-GEIN6UIL.js} +7 -2
  17. package/vendor/{chunk-VGL5AZN5.js → chunk-H7ETSD25.js} +1 -1
  18. package/vendor/{chunk-OZU6JFB4.js → chunk-HG47LAWW.js} +5 -4
  19. package/vendor/{chunk-Y6GE52OP.js → chunk-HXL36SED.js} +18 -17
  20. package/vendor/{chunk-UCOHFZ77.js → chunk-I5XO5FL4.js} +2 -2
  21. package/vendor/{chunk-XKXSC6YS.js → chunk-J7LW6JFY.js} +21 -13
  22. package/vendor/{chunk-KRBZZ6GS.js → chunk-JG7OELJM.js} +8 -8
  23. package/vendor/{chunk-KG3RANR4.js → chunk-KBECHDUE.js} +1 -1
  24. package/vendor/{chunk-AOZ3LMTF.js → chunk-KH4UBONI.js} +3 -2
  25. package/vendor/{chunk-7HLNJ2BI.js → chunk-MFPPURFE.js} +1 -1
  26. package/vendor/{chunk-F77ZTTNS.js → chunk-MHFYPBCL.js} +3 -3
  27. package/vendor/{chunk-54UL4U2E.js → chunk-TAQWNZVD.js} +77 -20
  28. package/vendor/{chunk-ILQVLZ2I.js → chunk-TMCW2P6G.js} +5 -5
  29. package/vendor/{chunk-QV3WPU7A.js → chunk-ULLAURFV.js} +1 -1
  30. package/vendor/{chunk-T7OGE5E5.js → chunk-ULUSFNAE.js} +3 -3
  31. package/vendor/{chunk-E6YVGIEW.js → chunk-VWB3VEOL.js} +468 -12
  32. package/vendor/{chunk-UIMUUIH7.js → chunk-XPSPPLX5.js} +13 -13
  33. package/vendor/{chunk-L4RD3TAZ.js → chunk-XSOQ2U5H.js} +2 -2
  34. package/vendor/{chunk-USHFSJT7.js → chunk-XTQYFCVY.js} +10 -8
  35. package/vendor/{chunk-NGV45YWB.js → chunk-XW7AXRDI.js} +3 -3
  36. package/vendor/{chunk-SQZ2OSP6.js → chunk-Y5OJXAUF.js} +2 -2
  37. package/vendor/{chunk-XCO3RV3Z.js → chunk-YDZEMIAH.js} +1 -1
  38. package/vendor/{chunk-S6HD3MDU.js → chunk-YOMK7KMB.js} +2 -2
  39. package/vendor/{chunk-ALJUSOF7.js → chunk-YY7NMZGD.js} +79 -1
  40. package/vendor/component-manifest-catalog.js +1 -1
  41. package/vendor/control-plane.js +5 -3
@@ -6,14 +6,15 @@ import {
6
6
  personalSyncProviderEnvironment,
7
7
  redeemPairingLink,
8
8
  runPersonalSyncCommand
9
- } from "./chunk-NGV45YWB.js";
10
- import "./chunk-GY5GATZL.js";
11
- import "./chunk-LHUMBHG7.js";
9
+ } from "./chunk-XW7AXRDI.js";
10
+ import "./chunk-GEIN6UIL.js";
11
+ import "./chunk-2YCDKSKW.js";
12
+ import "./chunk-A2TMTAAS.js";
12
13
  import "./chunk-TSAYTRX3.js";
13
14
  import "./chunk-YZLQZU5E.js";
14
15
  import "./chunk-W2HNI6AA.js";
15
16
  import "./chunk-7NXKPDF3.js";
16
- import "./chunk-E6YVGIEW.js";
17
+ import "./chunk-VWB3VEOL.js";
17
18
  import "./chunk-FSNLU46W.js";
18
19
  import "./chunk-BTS4ZTF3.js";
19
20
  export {
@@ -2,40 +2,41 @@ import { createRequire as createKoedRequire } from "node:module"; const require
2
2
  import {
3
3
  createCliServiceContext,
4
4
  printJson
5
- } from "./chunk-54UL4U2E.js";
6
- import "./chunk-L4RD3TAZ.js";
7
- import "./chunk-NGV45YWB.js";
8
- import "./chunk-GY5GATZL.js";
5
+ } from "./chunk-TAQWNZVD.js";
6
+ import "./chunk-XSOQ2U5H.js";
7
+ import "./chunk-XW7AXRDI.js";
8
+ import "./chunk-GEIN6UIL.js";
9
+ import "./chunk-2YCDKSKW.js";
9
10
  import "./chunk-JYK6UL6D.js";
10
- import "./chunk-T7OGE5E5.js";
11
+ import "./chunk-ULUSFNAE.js";
11
12
  import {
12
13
  connectAiClientAfterSetup,
13
14
  disconnectAiClientThenRemove,
14
15
  verifyAiClientIntegration
15
- } from "./chunk-KG3RANR4.js";
16
+ } from "./chunk-KBECHDUE.js";
16
17
  import {
17
18
  evaluateAiClientReadiness
18
- } from "./chunk-USHFSJT7.js";
19
+ } from "./chunk-XTQYFCVY.js";
19
20
  import "./chunk-QT24SAW6.js";
20
21
  import "./chunk-TISYUUEJ.js";
21
- import "./chunk-ALJUSOF7.js";
22
- import "./chunk-LHUMBHG7.js";
22
+ import "./chunk-YY7NMZGD.js";
23
+ import "./chunk-A2TMTAAS.js";
23
24
  import "./chunk-7FSHVVTZ.js";
24
25
  import "./chunk-TSAYTRX3.js";
25
26
  import "./chunk-YZLQZU5E.js";
26
27
  import "./chunk-W2HNI6AA.js";
27
28
  import "./chunk-OG7G6DIR.js";
28
- import "./chunk-UCOHFZ77.js";
29
+ import "./chunk-I5XO5FL4.js";
29
30
  import "./chunk-T6UB5PNX.js";
30
31
  import "./chunk-7NXKPDF3.js";
31
- import "./chunk-XCO3RV3Z.js";
32
- import "./chunk-7HLNJ2BI.js";
33
- import "./chunk-VGL5AZN5.js";
34
- import "./chunk-QV3WPU7A.js";
32
+ import "./chunk-YDZEMIAH.js";
33
+ import "./chunk-MFPPURFE.js";
34
+ import "./chunk-H7ETSD25.js";
35
+ import "./chunk-ULLAURFV.js";
35
36
  import "./chunk-IY2HRXOZ.js";
36
- import "./chunk-4DHYSJJT.js";
37
- import "./chunk-WBMO7YCO.js";
38
- import "./chunk-E6YVGIEW.js";
37
+ import "./chunk-G54Q5W6M.js";
38
+ import "./chunk-3VNLZCMB.js";
39
+ import "./chunk-VWB3VEOL.js";
39
40
  import "./chunk-FSNLU46W.js";
40
41
  import "./chunk-BTS4ZTF3.js";
41
42
 
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-T6UB5PNX.js";
5
5
  import {
6
6
  productionComponentManifestCatalog
7
- } from "./chunk-XCO3RV3Z.js";
7
+ } from "./chunk-YDZEMIAH.js";
8
8
  import {
9
9
  canonicalArtifactJson,
10
10
  extractVerifiedPackageArchive,
@@ -13,7 +13,7 @@ import {
13
13
  verifyComponent,
14
14
  verifyComponentManifestPin,
15
15
  verifyExtractedComponent
16
- } from "./chunk-7HLNJ2BI.js";
16
+ } from "./chunk-MFPPURFE.js";
17
17
  import {
18
18
  lookupManifestPin,
19
19
  validateManifestCatalog
@@ -1,10 +1,13 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
+ import {
3
+ privateNodeLauncher
4
+ } from "./chunk-2YCDKSKW.js";
2
5
  import {
3
6
  collectLocalModelStatus
4
7
  } from "./chunk-JYK6UL6D.js";
5
8
  import {
6
9
  compareNativeVersions
7
- } from "./chunk-VGL5AZN5.js";
10
+ } from "./chunk-H7ETSD25.js";
8
11
  import {
9
12
  external_exports
10
13
  } from "./chunk-FSNLU46W.js";
@@ -191,19 +194,24 @@ async function checkCudaHost(signal, nvidiaSmi = resolveNvidiaSmi()) {
191
194
  const [major, minor, patch = 0] = driverVersion.split(".").map(Number);
192
195
  if (compareNativeVersions(`${major}.${minor}.${patch}`, minimumDriver) < 0)
193
196
  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"
197
+ const loaded = await nativeCommand(
198
+ // The probe environment is restricted, so use the private Node launcher.
199
+ privateNodeLauncher(),
200
+ [
201
+ "-p",
202
+ String.raw`process.report.getReport().sharedObjects.some(p => /\/libcuda\.so(?:\.\d+)*$/.test(p))`
203
+ ],
204
+ {
205
+ ...context,
206
+ // Desktop also calls this probe from Electron main. Its executable must
207
+ // run as Node, just as it does for the private server supervisor.
208
+ env: {
209
+ ...context.env,
210
+ ELECTRON_RUN_AS_NODE: "1",
211
+ LD_PRELOAD: "libcuda.so.1"
212
+ }
205
213
  }
206
- });
214
+ );
207
215
  if (loaded !== "true")
208
216
  throw new NativeValidationError("cuda_driver_library_unavailable", "The host loader could not load libcuda.so.1.");
209
217
  return driverVersion;
@@ -2,8 +2,8 @@ import { createRequire as createKoedRequire } from "node:module"; const require
2
2
  import {
3
3
  calculateRuntimeRequirements,
4
4
  resolveEffectiveRuntimeConfig
5
- } from "./chunk-L4RD3TAZ.js";
6
- import "./chunk-ALJUSOF7.js";
5
+ } from "./chunk-XSOQ2U5H.js";
6
+ import "./chunk-YY7NMZGD.js";
7
7
  import {
8
8
  resolveKoedServerPaths
9
9
  } from "./chunk-TSAYTRX3.js";
@@ -28,19 +28,19 @@ import {
28
28
  resolveComponentManifestPinTarget,
29
29
  stageComponent,
30
30
  stageGeneration
31
- } from "./chunk-UCOHFZ77.js";
31
+ } from "./chunk-I5XO5FL4.js";
32
32
  import "./chunk-T6UB5PNX.js";
33
33
  import "./chunk-7NXKPDF3.js";
34
34
  import {
35
35
  productionComponentManifestCatalog
36
- } from "./chunk-XCO3RV3Z.js";
37
- import "./chunk-7HLNJ2BI.js";
38
- import "./chunk-VGL5AZN5.js";
39
- import "./chunk-QV3WPU7A.js";
36
+ } from "./chunk-YDZEMIAH.js";
37
+ import "./chunk-MFPPURFE.js";
38
+ import "./chunk-H7ETSD25.js";
39
+ import "./chunk-ULLAURFV.js";
40
40
  import {
41
41
  validateManifestCatalog
42
42
  } from "./chunk-IY2HRXOZ.js";
43
- import "./chunk-E6YVGIEW.js";
43
+ import "./chunk-VWB3VEOL.js";
44
44
  import "./chunk-FSNLU46W.js";
45
45
  import "./chunk-BTS4ZTF3.js";
46
46
 
@@ -3,7 +3,7 @@ import {
3
3
  aiClientConnectionRevision,
4
4
  grantAiClientConnection,
5
5
  revokeAiClientConnection
6
- } from "./chunk-USHFSJT7.js";
6
+ } from "./chunk-XTQYFCVY.js";
7
7
 
8
8
  // packages/koed-server/dist/ai-client-authorization.js
9
9
  var clientNames = {
@@ -1,10 +1,11 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
2
  import {
3
3
  runApplicationSecretProvider
4
- } from "./chunk-GY5GATZL.js";
4
+ } from "./chunk-GEIN6UIL.js";
5
+ import "./chunk-2YCDKSKW.js";
5
6
  import "./chunk-TSAYTRX3.js";
6
7
  import "./chunk-YZLQZU5E.js";
7
- import "./chunk-E6YVGIEW.js";
8
+ import "./chunk-VWB3VEOL.js";
8
9
  import "./chunk-FSNLU46W.js";
9
10
  import "./chunk-BTS4ZTF3.js";
10
11
 
@@ -1,7 +1,7 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
2
  import {
3
3
  nativeKind
4
- } from "./chunk-VGL5AZN5.js";
4
+ } from "./chunk-H7ETSD25.js";
5
5
  import {
6
6
  lookupManifestPin
7
7
  } from "./chunk-IY2HRXOZ.js";
@@ -16,9 +16,9 @@ import {
16
16
  standalonePackageKind,
17
17
  standalonePackageSchemaVersion,
18
18
  validateServerPackageRoot
19
- } from "./chunk-7HLNJ2BI.js";
20
- import "./chunk-VGL5AZN5.js";
21
- import "./chunk-QV3WPU7A.js";
19
+ } from "./chunk-MFPPURFE.js";
20
+ import "./chunk-H7ETSD25.js";
21
+ import "./chunk-ULLAURFV.js";
22
22
  import "./chunk-IY2HRXOZ.js";
23
23
  import "./chunk-FSNLU46W.js";
24
24
  import "./chunk-BTS4ZTF3.js";
@@ -2,23 +2,24 @@ import { createRequire as createKoedRequire } from "node:module"; const require
2
2
  import {
3
3
  calculateRuntimeRequirements,
4
4
  resolveEffectiveRuntimeConfig
5
- } from "./chunk-L4RD3TAZ.js";
5
+ } from "./chunk-XSOQ2U5H.js";
6
6
  import {
7
7
  redeemPairingLink
8
- } from "./chunk-NGV45YWB.js";
8
+ } from "./chunk-XW7AXRDI.js";
9
9
  import {
10
10
  bundledPdsSecretProviderEnvironment
11
- } from "./chunk-GY5GATZL.js";
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-T7OGE5E5.js";
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,
@@ -40,7 +41,7 @@ import {
40
41
  startLocalPostgresRuntime,
41
42
  startLocalPrivacyRuntime,
42
43
  stopLocalPostgresRuntime
43
- } from "./chunk-USHFSJT7.js";
44
+ } from "./chunk-XTQYFCVY.js";
44
45
  import {
45
46
  resolveActiveIntegrationApiToken,
46
47
  resolveLocalApiToken,
@@ -50,13 +51,15 @@ import {
50
51
  allocateAndPersistLocalPorts
51
52
  } from "./chunk-TISYUUEJ.js";
52
53
  import {
53
- resolveKoedServerConfig
54
- } from "./chunk-ALJUSOF7.js";
54
+ applyResourceProfile,
55
+ resolveKoedServerConfig,
56
+ resourceProfileValues
57
+ } from "./chunk-YY7NMZGD.js";
55
58
  import {
56
59
  ensureDeviceIdentity,
57
60
  inspectDeviceIdentityStatus,
58
61
  rotateDeviceIdentity
59
- } from "./chunk-LHUMBHG7.js";
62
+ } from "./chunk-A2TMTAAS.js";
60
63
  import {
61
64
  maintainSupervisorLog,
62
65
  startKoedServerDaemon
@@ -92,7 +95,7 @@ import {
92
95
  validateDesktopRuntimeCapability,
93
96
  withLifecycleLock,
94
97
  withSourceNativeStartLock
95
- } from "./chunk-UCOHFZ77.js";
98
+ } from "./chunk-I5XO5FL4.js";
96
99
  import {
97
100
  isProcessRunning,
98
101
  isRuntimeGenerationState,
@@ -102,11 +105,11 @@ import {
102
105
  import {
103
106
  listUpstreamBackends,
104
107
  refreshUpstreamBackendCapabilities
105
- } from "./chunk-WBMO7YCO.js";
108
+ } from "./chunk-3VNLZCMB.js";
106
109
  import {
107
110
  createPdsApplicationSecretStore,
108
111
  isPrivateNetworkIpv4Address
109
- } from "./chunk-E6YVGIEW.js";
112
+ } from "./chunk-VWB3VEOL.js";
110
113
 
111
114
  // packages/koed-server/dist/personal-device-request.js
112
115
  import { createHash as createHash2, randomBytes as randomBytes2, randomUUID as randomUUID2 } from "node:crypto";
@@ -668,7 +671,7 @@ var stopPid = (label, pid, deps) => {
668
671
  return { stoppedPids: [], missingPids: [pid], errors: [] };
669
672
  if (!identityMatches())
670
673
  return identityError();
671
- const target = deps.processGroup ? -pid : pid;
674
+ const target = deps.processGroup && pid > 1 ? -pid : pid;
672
675
  try {
673
676
  deps.kill(target, "SIGTERM");
674
677
  if (waitForPidExit(target, deps)) {
@@ -891,7 +894,7 @@ var stopKoedServer = ({ environment = process.env, existsSync: pathExists = node
891
894
  expectedProcessIdentity: embeddingIdentity,
892
895
  resolveProcessIdentity: resolveProcessIdentity2
893
896
  } : {},
894
- processGroup: releaseManaged && embeddingIdentity !== void 0 && checkPid(embeddingPid) && resolveProcessIdentity2(embeddingPid) === embeddingIdentity && isProcessGroupLeader(embeddingPid)
897
+ processGroup: embeddingPid > 1 && embeddingIdentity !== void 0 && checkPid(embeddingPid) && resolveProcessIdentity2(embeddingPid) === embeddingIdentity && isProcessGroupLeader(embeddingPid)
895
898
  });
896
899
  stoppedPids.push(...stopped.stoppedPids);
897
900
  missingPids.push(...stopped.missingPids);
@@ -1169,6 +1172,43 @@ function observeRuntimeLifecycle(paths, { resolveProcessIdentity: resolveProcess
1169
1172
  }
1170
1173
  var runtimeOwnedBy = (observation, owner) => Boolean(observation.owner && observation.owner.kind === owner.kind && observation.owner.installationId === owner.installationId);
1171
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
+
1172
1212
  // packages/koed-server/dist/start.js
1173
1213
  var localRuntimeFailureDetails = (details) => {
1174
1214
  if (!details || typeof details !== "object" || Array.isArray(details)) {
@@ -1372,7 +1412,7 @@ var localServiceEnv = (environment, repoEnv, apiToken, paths) => {
1372
1412
  MODEL_PATH: serverConfig.dependencyMode === "bundled-local" ? localEmbeddingModelPath : environment.EMBEDDING_MODEL_PATH ?? environment.MODEL_PATH,
1373
1413
  LLAMA_SERVER_BINARY: environment.LLAMA_SERVER_BINARY ?? repoEnv.EMBEDDING_LLAMA_SERVER_BINARY ?? environment.EMBEDDING_LLAMA_SERVER_BINARY,
1374
1414
  LLAMA_N_CTX: environment.EMBEDDING_LLAMA_N_CTX ?? environment.LLAMA_N_CTX ?? repoEnv.EMBEDDING_LLAMA_N_CTX,
1375
- LLAMA_N_THREADS: environment.EMBEDDING_LLAMA_N_THREADS ?? environment.LLAMA_N_THREADS ?? repoEnv.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,
1376
1416
  LLAMA_N_BATCH: environment.EMBEDDING_LLAMA_N_BATCH ?? environment.LLAMA_N_BATCH ?? repoEnv.EMBEDDING_LLAMA_N_BATCH,
1377
1417
  LLAMA_BATCH_TOKEN_HEADROOM: environment.EMBEDDING_LLAMA_BATCH_TOKEN_HEADROOM ?? environment.LLAMA_BATCH_TOKEN_HEADROOM ?? repoEnv.EMBEDDING_LLAMA_BATCH_TOKEN_HEADROOM,
1378
1418
  LLAMA_N_UBATCH: environment.EMBEDDING_LLAMA_N_UBATCH ?? environment.LLAMA_N_UBATCH ?? repoEnv.EMBEDDING_LLAMA_N_UBATCH,
@@ -1403,7 +1443,10 @@ var waitForChildExit = (child, timeoutMs) => new Promise((resolveExit) => {
1403
1443
  const timeout = setTimeout(() => finish(false), timeoutMs);
1404
1444
  child.once("exit", onExit);
1405
1445
  });
1446
+ var isSignalableProcessGroup = (pid) => Number.isSafeInteger(pid) && pid > 1;
1406
1447
  var processGroupAlive = (pid) => {
1448
+ if (!isSignalableProcessGroup(pid))
1449
+ return false;
1407
1450
  try {
1408
1451
  process.kill(-pid, 0);
1409
1452
  return true;
@@ -1440,7 +1483,7 @@ var stopChildProcess = async (child, timeoutMs = 5e3, label = "managed child", p
1440
1483
  return;
1441
1484
  const pid = child.pid;
1442
1485
  const exited = () => child.exitCode != null || child.signalCode != null;
1443
- if (!privateGroup) {
1486
+ if (!privateGroup || !isSignalableProcessGroup(pid)) {
1444
1487
  if (exited())
1445
1488
  return;
1446
1489
  child.kill("SIGTERM");
@@ -1660,6 +1703,13 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1660
1703
  });
1661
1704
  }
1662
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
+ }
1663
1713
  const initialServiceEnv = localServiceEnv(environment, repoEnv, apiToken, paths);
1664
1714
  const useBundledLocalDependencies = config.dependencyMode === "bundled-local";
1665
1715
  const teamCollaborationEnabled = effectiveRuntimeConfig.teamEnabled;
@@ -1740,14 +1790,14 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1740
1790
  ];
1741
1791
  for (const name of shutdownOrder) {
1742
1792
  try {
1743
- await stopChildProcess(managedChildren[name], 5e3, name, name === "embeddingService" && Boolean(paths.nativeSelectionRoot));
1793
+ await stopChildProcess(managedChildren[name], 5e3, name, name === "embeddingService" && embeddingServiceLeadsProcessGroup(paths));
1744
1794
  } catch (error) {
1745
1795
  cleanupErrors.push(error instanceof Error ? error.message : String(error));
1746
1796
  }
1747
1797
  }
1748
1798
  if (nativeEmbeddingProcess && !Object.values(managedChildren).includes(nativeEmbeddingProcess)) {
1749
1799
  try {
1750
- await stopChildProcess(nativeEmbeddingProcess, 5e3, "embeddingService", Boolean(paths.nativeSelectionRoot));
1800
+ await stopChildProcess(nativeEmbeddingProcess, 5e3, "embeddingService", embeddingServiceLeadsProcessGroup(paths));
1751
1801
  } catch (error) {
1752
1802
  cleanupErrors.push(error instanceof Error ? error.message : String(error));
1753
1803
  }
@@ -1815,6 +1865,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1815
1865
  signal?.addEventListener("abort", shutdown, { once: true });
1816
1866
  process.on("SIGINT", shutdown);
1817
1867
  process.on("SIGTERM", shutdown);
1868
+ process.on("SIGHUP", shutdown);
1818
1869
  const stopSupervisorLogMaintenance = maintainSupervisorLog(refreshedEnv);
1819
1870
  let sourceRuntimeLeaseAcquired = false;
1820
1871
  let startupReady = false;
@@ -1829,7 +1880,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1829
1880
  assertKoedAppRuntimeAvailable(appRuntime, paths);
1830
1881
  }
1831
1882
  if (useBundledLocalDependencies && hasReleaseRuntime(paths) && !(hasCompletePostgresOverride(refreshedEnv) && nativeLlamaServerOverride(refreshedEnv))) {
1832
- const { resolveSelectedCoreForStart } = await import("./chunk-273NMYXE.js");
1883
+ const { resolveSelectedCoreForStart } = await import("./chunk-D4XZTNLU.js");
1833
1884
  const admitSelection = () => resolveSelectedCoreForStart(paths, refreshedEnv, !nativeLlamaServerOverride(refreshedEnv));
1834
1885
  const selected = generationPin ? admitSelection() : withSourceNativeStartLock(paths, admitSelection);
1835
1886
  if (selected)
@@ -1846,6 +1897,11 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1846
1897
  emitStartupMilestone("source_runtime_verification_complete");
1847
1898
  }
1848
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
+ }
1849
1905
  if (config.dependencyMode === "external") {
1850
1906
  const queueBackend = requiredRuntime.queue;
1851
1907
  const requiredExternalServices = [
@@ -1912,7 +1968,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1912
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"));
1913
1969
  manageChild("api", api);
1914
1970
  emitStartupMilestone("api_process_spawned");
1915
- const embeddingIdentity = paths.nativeSelectionRoot && nativeEmbeddingProcess?.pid ? resolveProcessIdentity(nativeEmbeddingProcess.pid) : null;
1971
+ const embeddingIdentity = embeddingServiceLeadsProcessGroup(paths) && nativeEmbeddingProcess?.pid ? resolveProcessIdentity(nativeEmbeddingProcess.pid) : null;
1916
1972
  const runtime = {
1917
1973
  pid: process.pid,
1918
1974
  startedAt: supervisorStartedAt,
@@ -1925,7 +1981,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1925
1981
  claudeTranscriptWatcherEnabled: config.claudeTranscriptWatcherEnabled,
1926
1982
  piTranscriptWatcherEnabled: config.piTranscriptWatcherEnabled,
1927
1983
  services: [...runtimeServices, "api"],
1928
- // The release-managed Embedding Service leads a private process group.
1984
+ // The native Embedding Service leads a private process group.
1929
1985
  // koed stop signals that group only while its leader keeps this identity.
1930
1986
  ...embeddingIdentity ? { processIdentities: { embeddingService: embeddingIdentity } } : {},
1931
1987
  processes: {
@@ -2055,6 +2111,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
2055
2111
  stopSupervisorLogMaintenance();
2056
2112
  process.off("SIGINT", shutdown);
2057
2113
  process.off("SIGTERM", shutdown);
2114
+ process.off("SIGHUP", shutdown);
2058
2115
  signal?.removeEventListener("abort", shutdown);
2059
2116
  managedProcessMonitor.dispose();
2060
2117
  if (runtimeStateWritten) {
@@ -18,13 +18,13 @@ import {
18
18
  withLifecycleLock,
19
19
  withSourceNativeStartLock,
20
20
  withStoppedRuntime
21
- } from "./chunk-UCOHFZ77.js";
21
+ } from "./chunk-I5XO5FL4.js";
22
22
  import "./chunk-T6UB5PNX.js";
23
23
  import "./chunk-7NXKPDF3.js";
24
- import "./chunk-XCO3RV3Z.js";
25
- import "./chunk-7HLNJ2BI.js";
26
- import "./chunk-VGL5AZN5.js";
27
- import "./chunk-QV3WPU7A.js";
24
+ import "./chunk-YDZEMIAH.js";
25
+ import "./chunk-MFPPURFE.js";
26
+ import "./chunk-H7ETSD25.js";
27
+ import "./chunk-ULLAURFV.js";
28
28
  import "./chunk-IY2HRXOZ.js";
29
29
  import "./chunk-FSNLU46W.js";
30
30
  import "./chunk-BTS4ZTF3.js";
@@ -1,7 +1,7 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
2
 
3
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.0.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.0.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.0.0", "core": { "recipeId": "ec948b5a248b7077990175488b0c0165998a0ebbd11f37339433f44b4d68c8ff", "runtimeVersion": "1.0.0", "url": "https://github.com/koed-labs/koed/releases/download/v1.0.0/koed-native-core-ec948b5a248b7077990175488b0c0165998a0ebbd11f37339433f44b4d68c8ff-macos-arm64.tar.gz", "sha256": "9e7ee080a41caeee6513b866bb1ef446de2cc4aedfd2d5ef010b1377f2673390", "manifestSha256": "71a86c5cb72abd432250bb28c7523e44865289c9d6de7f8ab1ad7bf416d8d415", "target": { "platform": "macos", "architecture": "arm64", "minimumVersion": "14.0" }, "archiveBytes": 35071036, "expandedBytes": 76669484, "contracts": { "layout": 1, "embedding": 1, "postgres": 1 }, "components": { "postgres": { "major": 17, "version": "17.6" }, "pgvector": { "version": "0.8.3" }, "llamaCpp": { "version": "b10514" } } }, "cuda": null } };
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
5
 
6
6
  export {
7
7
  productionNativeRuntimeCatalog
@@ -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-LHUMBHG7.js";
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-WBMO7YCO.js";
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-E6YVGIEW.js";
33
+ } from "./chunk-VWB3VEOL.js";
34
34
  import {
35
35
  __toESM
36
36
  } from "./chunk-BTS4ZTF3.js";