@koed-labs/server 1.0.0 → 1.3.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 (44) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/vendor/{chunk-W2HNI6AA.js → chunk-26D2DYEJ.js} +12 -2
  4. package/vendor/{chunk-S6HD3MDU.js → chunk-2XVGC6KN.js} +2 -2
  5. package/vendor/chunk-2YCDKSKW.js +45 -0
  6. package/vendor/{chunk-T7OGE5E5.js → chunk-4QETHLFK.js} +3 -3
  7. package/vendor/{chunk-E6YVGIEW.js → chunk-5ZYY6GLX.js} +728 -34
  8. package/vendor/{chunk-BYN6KXNP.js → chunk-AAAVAB5Q.js} +5 -5
  9. package/vendor/{chunk-UCOHFZ77.js → chunk-B25G2HFV.js} +2 -2
  10. package/vendor/{chunk-F77ZTTNS.js → chunk-BRPU557N.js} +3 -3
  11. package/vendor/{chunk-QV3WPU7A.js → chunk-BTBSSNAR.js} +1 -1
  12. package/vendor/{chunk-ILQVLZ2I.js → chunk-BYN4THYX.js} +5 -5
  13. package/vendor/{chunk-64AST7WZ.js → chunk-BYZDN2WK.js} +5 -2
  14. package/vendor/{chunk-XKXSC6YS.js → chunk-CLI4TFKY.js} +21 -13
  15. package/vendor/{chunk-W6632NOX.js → chunk-CZKIP3UJ.js} +4 -3
  16. package/vendor/{chunk-DWWMBGHX.js → chunk-DNHKSXD5.js} +19 -18
  17. package/vendor/{chunk-AOZ3LMTF.js → chunk-F7BTC7UR.js} +3 -2
  18. package/vendor/{chunk-USHFSJT7.js → chunk-FZAIOBQQ.js} +11 -9
  19. package/vendor/{chunk-NGV45YWB.js → chunk-GBQXRSSZ.js} +4 -4
  20. package/vendor/{chunk-7FSHVVTZ.js → chunk-HFGCZ76G.js} +7 -1
  21. package/vendor/{chunk-4DHYSJJT.js → chunk-HN2X7VA2.js} +1 -1
  22. package/vendor/{chunk-54UL4U2E.js → chunk-IHVJNZXT.js} +101 -33
  23. package/vendor/{chunk-EEBIYWTE.js → chunk-JHHI5KG6.js} +19 -18
  24. package/vendor/{chunk-TIBYKMRW.js → chunk-JLYGPZYP.js} +38 -45
  25. package/vendor/{chunk-XCO3RV3Z.js → chunk-K2KUQRHT.js} +1 -1
  26. package/vendor/{chunk-Y6GE52OP.js → chunk-KB3MFZD7.js} +20 -19
  27. package/vendor/{chunk-L4RD3TAZ.js → chunk-LLJV6XQ6.js} +14 -8
  28. package/vendor/{chunk-KG3RANR4.js → chunk-LVUQ5N23.js} +1 -1
  29. package/vendor/{chunk-KRBZZ6GS.js → chunk-O5NAIZP3.js} +9 -9
  30. package/vendor/{chunk-SQZ2OSP6.js → chunk-OFNOMEVX.js} +2 -2
  31. package/vendor/{chunk-273NMYXE.js → chunk-PAPGIBPA.js} +8 -7
  32. package/vendor/{chunk-VLP72QWX.js → chunk-PMDFTON3.js} +116 -64
  33. package/vendor/{chunk-GY5GATZL.js → chunk-RBD4HLDB.js} +7 -2
  34. package/vendor/{chunk-F7AMEDDU.js → chunk-SANHAZJM.js} +4 -4
  35. package/vendor/{chunk-WBMO7YCO.js → chunk-SQNSVJ3W.js} +1 -1
  36. package/vendor/{chunk-VGL5AZN5.js → chunk-TCL6KGG7.js} +1 -1
  37. package/vendor/{chunk-7NOQSX4T.js → chunk-UKBULNBO.js} +5 -3
  38. package/vendor/{chunk-OZU6JFB4.js → chunk-XSNPYCS5.js} +6 -5
  39. package/vendor/{chunk-LHUMBHG7.js → chunk-XYC3MIS6.js} +1 -1
  40. package/vendor/{chunk-UIMUUIH7.js → chunk-YHXEFDZV.js} +14 -14
  41. package/vendor/{chunk-7HLNJ2BI.js → chunk-YLFOTZFU.js} +1 -1
  42. package/vendor/{chunk-ALJUSOF7.js → chunk-YY7NMZGD.js} +79 -1
  43. package/vendor/component-manifest-catalog.js +1 -1
  44. package/vendor/control-plane.js +7 -4
@@ -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-LLJV6XQ6.js";
6
6
  import {
7
7
  redeemPairingLink
8
- } from "./chunk-NGV45YWB.js";
8
+ } from "./chunk-GBQXRSSZ.js";
9
9
  import {
10
10
  bundledPdsSecretProviderEnvironment
11
- } from "./chunk-GY5GATZL.js";
11
+ } from "./chunk-RBD4HLDB.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-4QETHLFK.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-FZAIOBQQ.js";
44
45
  import {
45
46
  resolveActiveIntegrationApiToken,
46
47
  resolveLocalApiToken,
@@ -50,17 +51,19 @@ 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-XYC3MIS6.js";
60
63
  import {
61
64
  maintainSupervisorLog,
62
65
  startKoedServerDaemon
63
- } from "./chunk-7FSHVVTZ.js";
66
+ } from "./chunk-HFGCZ76G.js";
64
67
  import {
65
68
  ensureKoedHome,
66
69
  resolveKoedServerPaths
@@ -71,8 +74,9 @@ import {
71
74
  import {
72
75
  environmentWithRepoEnv,
73
76
  loadRepoEnv,
74
- resolveApiUrl
75
- } from "./chunk-W2HNI6AA.js";
77
+ resolveApiUrl,
78
+ withAbsoluteEnvPath
79
+ } from "./chunk-26D2DYEJ.js";
76
80
  import {
77
81
  assertKoedAppRuntimeAvailable,
78
82
  resolveKoedAppRuntime,
@@ -92,7 +96,7 @@ import {
92
96
  validateDesktopRuntimeCapability,
93
97
  withLifecycleLock,
94
98
  withSourceNativeStartLock
95
- } from "./chunk-UCOHFZ77.js";
99
+ } from "./chunk-B25G2HFV.js";
96
100
  import {
97
101
  isProcessRunning,
98
102
  isRuntimeGenerationState,
@@ -102,11 +106,11 @@ import {
102
106
  import {
103
107
  listUpstreamBackends,
104
108
  refreshUpstreamBackendCapabilities
105
- } from "./chunk-WBMO7YCO.js";
109
+ } from "./chunk-SQNSVJ3W.js";
106
110
  import {
107
111
  createPdsApplicationSecretStore,
108
112
  isPrivateNetworkIpv4Address
109
- } from "./chunk-E6YVGIEW.js";
113
+ } from "./chunk-5ZYY6GLX.js";
110
114
 
111
115
  // packages/koed-server/dist/personal-device-request.js
112
116
  import { createHash as createHash2, randomBytes as randomBytes2, randomUUID as randomUUID2 } from "node:crypto";
@@ -668,7 +672,7 @@ var stopPid = (label, pid, deps) => {
668
672
  return { stoppedPids: [], missingPids: [pid], errors: [] };
669
673
  if (!identityMatches())
670
674
  return identityError();
671
- const target = deps.processGroup ? -pid : pid;
675
+ const target = deps.processGroup && pid > 1 ? -pid : pid;
672
676
  try {
673
677
  deps.kill(target, "SIGTERM");
674
678
  if (waitForPidExit(target, deps)) {
@@ -708,7 +712,6 @@ var stopKoedServer = ({ environment = process.env, existsSync: pathExists = node
708
712
  const paths = resolveKoedServerPaths(environment);
709
713
  const waitForExitMs = requestedWait ?? 5e3;
710
714
  const releaseManaged = hasReleaseRuntime(paths);
711
- const runtimeEnvironment = environmentWithRepoEnv(paths.repoRoot, environment);
712
715
  const runtime = readRuntimeState(paths.runtimeStatePath, {
713
716
  existsSync: pathExists,
714
717
  readFileSync: readFile
@@ -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);
@@ -904,17 +907,28 @@ var stopKoedServer = ({ environment = process.env, existsSync: pathExists = node
904
907
  }
905
908
  }
906
909
  if (canSignalFallbackProcesses() && shouldStopNativePostgres(runtime)) {
907
- const stopped = stopLocalPostgresRuntime(paths, runtimeEnvironment, {
908
- existsSync: pathExists,
909
- spawnSync
910
- });
911
- if (stopped.ok) {
912
- stoppedServices.push("postgres-native");
913
- } else {
910
+ let runtimeEnvironment;
911
+ try {
912
+ runtimeEnvironment = environmentWithRepoEnv(paths.repoRoot, environment);
913
+ } catch (error) {
914
914
  errors.push({
915
915
  target: "postgres-native",
916
- error: stopped.error ?? stopped.message
916
+ error: error instanceof Error ? error.message : String(error)
917
+ });
918
+ }
919
+ if (runtimeEnvironment) {
920
+ const stopped = stopLocalPostgresRuntime(paths, runtimeEnvironment, {
921
+ existsSync: pathExists,
922
+ spawnSync
917
923
  });
924
+ if (stopped.ok) {
925
+ stoppedServices.push("postgres-native");
926
+ } else {
927
+ errors.push({
928
+ target: "postgres-native",
929
+ error: stopped.error ?? stopped.message
930
+ });
931
+ }
918
932
  }
919
933
  }
920
934
  }
@@ -989,7 +1003,7 @@ var startDetached = ({ environment = process.env, spawn = nodeSpawn, startComman
989
1003
  const child = spawn(process.execPath, [startCommand, "start"], {
990
1004
  cwd: cwd ?? environment.KOED_REPO_ROOT ?? process.cwd(),
991
1005
  detached: true,
992
- env: environment,
1006
+ env: withAbsoluteEnvPath(environment),
993
1007
  stdio: "ignore"
994
1008
  });
995
1009
  if (!child.pid) {
@@ -1169,6 +1183,43 @@ function observeRuntimeLifecycle(paths, { resolveProcessIdentity: resolveProcess
1169
1183
  }
1170
1184
  var runtimeOwnedBy = (observation, owner) => Boolean(observation.owner && observation.owner.kind === owner.kind && observation.owner.installationId === owner.installationId);
1171
1185
 
1186
+ // packages/koed-server/dist/process-priority.js
1187
+ import { getPriority as nodeGetPriority, setPriority as nodeSetPriority } from "node:os";
1188
+ var BACKGROUND_NICE_ENV = "KOED_BACKGROUND_NICE";
1189
+ var DEFAULT_BACKGROUND_NICE = resourceProfileValues("balanced", 1).backgroundNice;
1190
+ var MAX_NICE = 19;
1191
+ var nodeProcessPriority = {
1192
+ getPriority: (pid) => nodeGetPriority(pid),
1193
+ setPriority: (pid, priority) => nodeSetPriority(pid, priority)
1194
+ };
1195
+ var resolveBackgroundNice = (environment, warn = console.warn) => {
1196
+ const raw = environment[BACKGROUND_NICE_ENV]?.trim();
1197
+ if (!raw)
1198
+ return DEFAULT_BACKGROUND_NICE;
1199
+ if (!/^\d+$/.test(raw) || Number(raw) > MAX_NICE) {
1200
+ warn(`${BACKGROUND_NICE_ENV} must be an integer from 0 to ${MAX_NICE}; using ${DEFAULT_BACKGROUND_NICE}.`);
1201
+ return DEFAULT_BACKGROUND_NICE;
1202
+ }
1203
+ const value = Number(raw);
1204
+ return value === 0 ? null : value;
1205
+ };
1206
+ var lowerBackgroundServicePriority = (environment, api = nodeProcessPriority, warn = console.warn) => {
1207
+ const target = resolveBackgroundNice(environment, warn);
1208
+ if (target === null)
1209
+ return { applied: false, reason: "disabled" };
1210
+ try {
1211
+ const current = api.getPriority(0);
1212
+ if (current >= target) {
1213
+ return { applied: false, reason: "already_lower", priority: current };
1214
+ }
1215
+ api.setPriority(0, target);
1216
+ return { applied: true, priority: target };
1217
+ } catch (error) {
1218
+ warn(`Could not lower Koed background service priority: ${error instanceof Error ? error.message : String(error)}`);
1219
+ return { applied: false, reason: "failed" };
1220
+ }
1221
+ };
1222
+
1172
1223
  // packages/koed-server/dist/start.js
1173
1224
  var localRuntimeFailureDetails = (details) => {
1174
1225
  if (!details || typeof details !== "object" || Array.isArray(details)) {
@@ -1372,7 +1423,7 @@ var localServiceEnv = (environment, repoEnv, apiToken, paths) => {
1372
1423
  MODEL_PATH: serverConfig.dependencyMode === "bundled-local" ? localEmbeddingModelPath : environment.EMBEDDING_MODEL_PATH ?? environment.MODEL_PATH,
1373
1424
  LLAMA_SERVER_BINARY: environment.LLAMA_SERVER_BINARY ?? repoEnv.EMBEDDING_LLAMA_SERVER_BINARY ?? environment.EMBEDDING_LLAMA_SERVER_BINARY,
1374
1425
  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,
1426
+ 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
1427
  LLAMA_N_BATCH: environment.EMBEDDING_LLAMA_N_BATCH ?? environment.LLAMA_N_BATCH ?? repoEnv.EMBEDDING_LLAMA_N_BATCH,
1377
1428
  LLAMA_BATCH_TOKEN_HEADROOM: environment.EMBEDDING_LLAMA_BATCH_TOKEN_HEADROOM ?? environment.LLAMA_BATCH_TOKEN_HEADROOM ?? repoEnv.EMBEDDING_LLAMA_BATCH_TOKEN_HEADROOM,
1378
1429
  LLAMA_N_UBATCH: environment.EMBEDDING_LLAMA_N_UBATCH ?? environment.LLAMA_N_UBATCH ?? repoEnv.EMBEDDING_LLAMA_N_UBATCH,
@@ -1403,7 +1454,10 @@ var waitForChildExit = (child, timeoutMs) => new Promise((resolveExit) => {
1403
1454
  const timeout = setTimeout(() => finish(false), timeoutMs);
1404
1455
  child.once("exit", onExit);
1405
1456
  });
1457
+ var isSignalableProcessGroup = (pid) => Number.isSafeInteger(pid) && pid > 1;
1406
1458
  var processGroupAlive = (pid) => {
1459
+ if (!isSignalableProcessGroup(pid))
1460
+ return false;
1407
1461
  try {
1408
1462
  process.kill(-pid, 0);
1409
1463
  return true;
@@ -1440,7 +1494,7 @@ var stopChildProcess = async (child, timeoutMs = 5e3, label = "managed child", p
1440
1494
  return;
1441
1495
  const pid = child.pid;
1442
1496
  const exited = () => child.exitCode != null || child.signalCode != null;
1443
- if (!privateGroup) {
1497
+ if (!privateGroup || !isSignalableProcessGroup(pid)) {
1444
1498
  if (exited())
1445
1499
  return;
1446
1500
  child.kill("SIGTERM");
@@ -1660,6 +1714,13 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1660
1714
  });
1661
1715
  }
1662
1716
  const config = startupConfig;
1717
+ if (config.runtimeMode !== "external") {
1718
+ environment = applyResourceProfile(environment, config.resourceProfile, {
1719
+ explicit: repoEnv,
1720
+ overrides: config.resourceOverrides
1721
+ });
1722
+ console.log(`Koed resource profile: ${config.resourceProfile}.`);
1723
+ }
1663
1724
  const initialServiceEnv = localServiceEnv(environment, repoEnv, apiToken, paths);
1664
1725
  const useBundledLocalDependencies = config.dependencyMode === "bundled-local";
1665
1726
  const teamCollaborationEnabled = effectiveRuntimeConfig.teamEnabled;
@@ -1740,14 +1801,14 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1740
1801
  ];
1741
1802
  for (const name of shutdownOrder) {
1742
1803
  try {
1743
- await stopChildProcess(managedChildren[name], 5e3, name, name === "embeddingService" && Boolean(paths.nativeSelectionRoot));
1804
+ await stopChildProcess(managedChildren[name], 5e3, name, name === "embeddingService" && embeddingServiceLeadsProcessGroup(paths));
1744
1805
  } catch (error) {
1745
1806
  cleanupErrors.push(error instanceof Error ? error.message : String(error));
1746
1807
  }
1747
1808
  }
1748
1809
  if (nativeEmbeddingProcess && !Object.values(managedChildren).includes(nativeEmbeddingProcess)) {
1749
1810
  try {
1750
- await stopChildProcess(nativeEmbeddingProcess, 5e3, "embeddingService", Boolean(paths.nativeSelectionRoot));
1811
+ await stopChildProcess(nativeEmbeddingProcess, 5e3, "embeddingService", embeddingServiceLeadsProcessGroup(paths));
1751
1812
  } catch (error) {
1752
1813
  cleanupErrors.push(error instanceof Error ? error.message : String(error));
1753
1814
  }
@@ -1815,6 +1876,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1815
1876
  signal?.addEventListener("abort", shutdown, { once: true });
1816
1877
  process.on("SIGINT", shutdown);
1817
1878
  process.on("SIGTERM", shutdown);
1879
+ process.on("SIGHUP", shutdown);
1818
1880
  const stopSupervisorLogMaintenance = maintainSupervisorLog(refreshedEnv);
1819
1881
  let sourceRuntimeLeaseAcquired = false;
1820
1882
  let startupReady = false;
@@ -1829,7 +1891,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1829
1891
  assertKoedAppRuntimeAvailable(appRuntime, paths);
1830
1892
  }
1831
1893
  if (useBundledLocalDependencies && hasReleaseRuntime(paths) && !(hasCompletePostgresOverride(refreshedEnv) && nativeLlamaServerOverride(refreshedEnv))) {
1832
- const { resolveSelectedCoreForStart } = await import("./chunk-273NMYXE.js");
1894
+ const { resolveSelectedCoreForStart } = await import("./chunk-PAPGIBPA.js");
1833
1895
  const admitSelection = () => resolveSelectedCoreForStart(paths, refreshedEnv, !nativeLlamaServerOverride(refreshedEnv));
1834
1896
  const selected = generationPin ? admitSelection() : withSourceNativeStartLock(paths, admitSelection);
1835
1897
  if (selected)
@@ -1846,6 +1908,11 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1846
1908
  emitStartupMilestone("source_runtime_verification_complete");
1847
1909
  }
1848
1910
  startupPhase = "service dependency validation and startup";
1911
+ if (config.runtimeMode !== "external") {
1912
+ const priority = lowerBackgroundServicePriority(refreshedEnv);
1913
+ if (priority.applied)
1914
+ console.log(`Koed background services run at nice ${priority.priority} (${BACKGROUND_NICE_ENV}).`);
1915
+ }
1849
1916
  if (config.dependencyMode === "external") {
1850
1917
  const queueBackend = requiredRuntime.queue;
1851
1918
  const requiredExternalServices = [
@@ -1912,7 +1979,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1912
1979
  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
1980
  manageChild("api", api);
1914
1981
  emitStartupMilestone("api_process_spawned");
1915
- const embeddingIdentity = paths.nativeSelectionRoot && nativeEmbeddingProcess?.pid ? resolveProcessIdentity(nativeEmbeddingProcess.pid) : null;
1982
+ const embeddingIdentity = embeddingServiceLeadsProcessGroup(paths) && nativeEmbeddingProcess?.pid ? resolveProcessIdentity(nativeEmbeddingProcess.pid) : null;
1916
1983
  const runtime = {
1917
1984
  pid: process.pid,
1918
1985
  startedAt: supervisorStartedAt,
@@ -1925,7 +1992,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
1925
1992
  claudeTranscriptWatcherEnabled: config.claudeTranscriptWatcherEnabled,
1926
1993
  piTranscriptWatcherEnabled: config.piTranscriptWatcherEnabled,
1927
1994
  services: [...runtimeServices, "api"],
1928
- // The release-managed Embedding Service leads a private process group.
1995
+ // The native Embedding Service leads a private process group.
1929
1996
  // koed stop signals that group only while its leader keeps this identity.
1930
1997
  ...embeddingIdentity ? { processIdentities: { embeddingService: embeddingIdentity } } : {},
1931
1998
  processes: {
@@ -2055,6 +2122,7 @@ var startKoedServer = async ({ environment = process.env, pollIntervalMs = 500,
2055
2122
  stopSupervisorLogMaintenance();
2056
2123
  process.off("SIGINT", shutdown);
2057
2124
  process.off("SIGTERM", shutdown);
2125
+ process.off("SIGHUP", shutdown);
2058
2126
  signal?.removeEventListener("abort", shutdown);
2059
2127
  managedProcessMonitor.dispose();
2060
2128
  if (runtimeStateWritten) {
@@ -4,33 +4,34 @@ import {
4
4
  createCliServiceContext,
5
5
  deviceRequestCommand,
6
6
  printJson
7
- } from "./chunk-54UL4U2E.js";
8
- import "./chunk-L4RD3TAZ.js";
9
- import "./chunk-NGV45YWB.js";
10
- import "./chunk-GY5GATZL.js";
7
+ } from "./chunk-IHVJNZXT.js";
8
+ import "./chunk-LLJV6XQ6.js";
9
+ import "./chunk-GBQXRSSZ.js";
10
+ import "./chunk-RBD4HLDB.js";
11
+ import "./chunk-2YCDKSKW.js";
11
12
  import "./chunk-JYK6UL6D.js";
12
- import "./chunk-T7OGE5E5.js";
13
- import "./chunk-USHFSJT7.js";
13
+ import "./chunk-4QETHLFK.js";
14
+ import "./chunk-FZAIOBQQ.js";
14
15
  import "./chunk-QT24SAW6.js";
15
16
  import "./chunk-TISYUUEJ.js";
16
- import "./chunk-ALJUSOF7.js";
17
- import "./chunk-LHUMBHG7.js";
18
- import "./chunk-7FSHVVTZ.js";
17
+ import "./chunk-YY7NMZGD.js";
18
+ import "./chunk-XYC3MIS6.js";
19
+ import "./chunk-HFGCZ76G.js";
19
20
  import "./chunk-TSAYTRX3.js";
20
21
  import "./chunk-YZLQZU5E.js";
21
- import "./chunk-W2HNI6AA.js";
22
+ import "./chunk-26D2DYEJ.js";
22
23
  import "./chunk-OG7G6DIR.js";
23
- import "./chunk-UCOHFZ77.js";
24
+ import "./chunk-B25G2HFV.js";
24
25
  import "./chunk-T6UB5PNX.js";
25
26
  import "./chunk-7NXKPDF3.js";
26
- import "./chunk-XCO3RV3Z.js";
27
- import "./chunk-7HLNJ2BI.js";
28
- import "./chunk-VGL5AZN5.js";
29
- import "./chunk-QV3WPU7A.js";
27
+ import "./chunk-K2KUQRHT.js";
28
+ import "./chunk-YLFOTZFU.js";
29
+ import "./chunk-TCL6KGG7.js";
30
+ import "./chunk-BTBSSNAR.js";
30
31
  import "./chunk-IY2HRXOZ.js";
31
- import "./chunk-4DHYSJJT.js";
32
- import "./chunk-WBMO7YCO.js";
33
- import "./chunk-E6YVGIEW.js";
32
+ import "./chunk-HN2X7VA2.js";
33
+ import "./chunk-SQNSVJ3W.js";
34
+ import "./chunk-5ZYY6GLX.js";
34
35
  import "./chunk-FSNLU46W.js";
35
36
  import "./chunk-BTS4ZTF3.js";
36
37
 
@@ -5,6 +5,10 @@ import {
5
5
  import {
6
6
  resolveKoedControlPlaneVersion
7
7
  } from "./chunk-OG7G6DIR.js";
8
+ import {
9
+ personalDeviceSyncFeatureEnvironmentName,
10
+ resolvePersonalDeviceSyncEnabled
11
+ } from "./chunk-5ZYY6GLX.js";
8
12
 
9
13
  // packages/koed-server/dist/cli.js
10
14
  import { realpathSync } from "node:fs";
@@ -3547,7 +3551,7 @@ var registerPersonalSyncCommands = (program2, dependencies, complete, advanced,
3547
3551
  const pair = program2.command("pair", { hidden }).description("Connect this device through Koed Desktop").option("--device-label <name>", "Device display name").option("--detach", "Return after creating the request").option("--json", "Emit JSON progress records");
3548
3552
  const pairAction = async (operation, options) => {
3549
3553
  const input = { ...pair.opts(), ...options };
3550
- complete(await withCliService(() => import("./chunk-EEBIYWTE.js"), (service) => service.runPairCommand(operation, input, dependencies), dependencies, input.json));
3554
+ complete(await withCliService(() => import("./chunk-JHHI5KG6.js"), (service) => service.runPairCommand(operation, input, dependencies), dependencies, input.json));
3551
3555
  };
3552
3556
  pair.action(async (options) => pairAction(void 0, options));
3553
3557
  for (const operation of ["status", "cancel"])
@@ -3569,7 +3573,7 @@ var registerPersonalSyncCommands = (program2, dependencies, complete, advanced,
3569
3573
  const stdout = dependencies.stdout ?? process.stdout;
3570
3574
  const stderr = dependencies.stderr ?? process.stderr;
3571
3575
  try {
3572
- const operation = dependencies.runPersonalSync ?? (await import("./chunk-OZU6JFB4.js")).runPersonalSyncCommand;
3576
+ const operation = dependencies.runPersonalSync ?? (await import("./chunk-XSNPYCS5.js")).runPersonalSyncCommand;
3573
3577
  const result = await operation(args, (dependencies.resolvePaths ?? resolveKoedServerPaths)(), process.env);
3574
3578
  stdout.write(options.json ? `${JSON.stringify(result, null, 2)}
3575
3579
  ` : `${result.message}
@@ -3650,7 +3654,7 @@ var registerRemoteCommands = (program2, dependencies, complete) => {
3650
3654
  }));
3651
3655
  return;
3652
3656
  }
3653
- complete(await withCliService(() => import("./chunk-UIMUUIH7.js"), (service) => service.runRemoteMcpOperation(operation, input, {
3657
+ complete(await withCliService(() => import("./chunk-YHXEFDZV.js"), (service) => service.runRemoteMcpOperation(operation, input, {
3654
3658
  environment: dependencies.remoteEnvironment,
3655
3659
  stdout: dependencies.stdout ?? process.stdout,
3656
3660
  stderr: dependencies.stderr ?? process.stderr
@@ -3686,12 +3690,12 @@ var registerInternalCommands = (program2, dependencies, complete) => {
3686
3690
  complete(1);
3687
3691
  return;
3688
3692
  }
3689
- complete(await withCliService(() => import("./chunk-AOZ3LMTF.js"), (service) => service.runSecretProviderCommand(operation, reference, dependencies), dependencies, false));
3693
+ complete(await withCliService(() => import("./chunk-F7BTC7UR.js"), (service) => service.runSecretProviderCommand(operation, reference, dependencies), dependencies, false));
3690
3694
  });
3691
3695
  const desktop = program2.command("desktop", { hidden: true }).description("Internal Desktop commands");
3692
3696
  desktop.action(() => desktop.outputHelp());
3693
3697
  desktop.command("collaboration-broker").action(async () => {
3694
- complete(await withCliService(() => import("./chunk-BYN6KXNP.js"), async (service) => {
3698
+ complete(await withCliService(() => import("./chunk-AAAVAB5Q.js"), async (service) => {
3695
3699
  try {
3696
3700
  await service.runDesktopCollaborationBrokerProcess();
3697
3701
  return 0;
@@ -3743,7 +3747,7 @@ var registerComponentCommands = (program2, dependencies, complete) => {
3743
3747
  command.action(async (options) => {
3744
3748
  let service;
3745
3749
  try {
3746
- service = await import("./chunk-KRBZZ6GS.js");
3750
+ service = await import("./chunk-O5NAIZP3.js");
3747
3751
  } catch {
3748
3752
  complete(reportMissingCliService(dependencies, options.json));
3749
3753
  return;
@@ -3774,7 +3778,7 @@ var registerIntegrationCommands = (program2, dependencies, complete) => {
3774
3778
  if (operation === "check")
3775
3779
  command.option("--capabilities-refreshed-since <value>", "Minimum capability refresh timestamp").option("--include-status", "Include complete service status in the result");
3776
3780
  command.action(async (options) => {
3777
- complete(await withCliService(() => import("./chunk-Y6GE52OP.js"), (service) => service.runIntegrationCommand(operation, { ...options, client }, dependencies), dependencies, options.json));
3781
+ complete(await withCliService(() => import("./chunk-KB3MFZD7.js"), (service) => service.runIntegrationCommand(operation, { ...options, client }, dependencies), dependencies, options.json));
3778
3782
  });
3779
3783
  }
3780
3784
  }
@@ -3791,7 +3795,7 @@ var registerLifecycleCommands = (program2, dependencies, complete) => {
3791
3795
  };
3792
3796
  const bind = (command, operation, identityAction) => {
3793
3797
  command.option("--json", "Emit JSON output").action(async (options) => {
3794
- complete(await withCliService(() => import("./chunk-DWWMBGHX.js"), (service) => service.runLifecycleCommand(operation, { ...options, identityAction }, dependencies), dependencies, options.json));
3798
+ complete(await withCliService(() => import("./chunk-DNHKSXD5.js"), (service) => service.runLifecycleCommand(operation, { ...options, identityAction }, dependencies), dependencies, options.json));
3795
3799
  });
3796
3800
  };
3797
3801
  for (const operation of Object.keys(descriptions)) {
@@ -3871,10 +3875,10 @@ var registerUpstreamCommands = (program2, dependencies, complete) => {
3871
3875
  const paths = (dependencies.resolvePaths ?? resolveKoedServerPaths)();
3872
3876
  let result;
3873
3877
  if (command === list) {
3874
- const execute = dependencies.listUpstreams ?? (await import("./chunk-SQZ2OSP6.js")).listUpstreamBackends;
3878
+ const execute = dependencies.listUpstreams ?? (await import("./chunk-OFNOMEVX.js")).listUpstreamBackends;
3875
3879
  result = execute(paths);
3876
3880
  } else if (command === register) {
3877
- const execute = dependencies.registerUpstream ?? (await import("./chunk-SQZ2OSP6.js")).registerUpstreamBackend;
3881
+ const execute = dependencies.registerUpstream ?? (await import("./chunk-OFNOMEVX.js")).registerUpstreamBackend;
3878
3882
  result = execute(paths, {
3879
3883
  url: required(options.url, "--url"),
3880
3884
  id: options.id,
@@ -3884,7 +3888,7 @@ var registerUpstreamCommands = (program2, dependencies, complete) => {
3884
3888
  } else {
3885
3889
  const id = required(options.id, "--id");
3886
3890
  if (command === refresh) {
3887
- const execute = dependencies.refreshUpstream ?? (await import("./chunk-SQZ2OSP6.js")).refreshUpstreamBackendCapabilities;
3891
+ const execute = dependencies.refreshUpstream ?? (await import("./chunk-OFNOMEVX.js")).refreshUpstreamBackendCapabilities;
3888
3892
  result = await execute(paths, id);
3889
3893
  } else if (command === policy) {
3890
3894
  const update = {};
@@ -3896,28 +3900,28 @@ var registerUpstreamCommands = (program2, dependencies, complete) => {
3896
3900
  throw new Error(`--${flag} must be enabled or disabled.`);
3897
3901
  update[key] = value;
3898
3902
  }
3899
- const execute = dependencies.updateUpstreamPolicy ?? (await import("./chunk-SQZ2OSP6.js")).updateUpstreamBackendRoutePolicy;
3903
+ const execute = dependencies.updateUpstreamPolicy ?? (await import("./chunk-OFNOMEVX.js")).updateUpstreamBackendRoutePolicy;
3900
3904
  result = execute(paths, id, update);
3901
3905
  } else if (command === activate) {
3902
- const execute = dependencies.activateUpstream ?? (await import("./chunk-SQZ2OSP6.js")).setActiveUpstreamBackend;
3906
+ const execute = dependencies.activateUpstream ?? (await import("./chunk-OFNOMEVX.js")).setActiveUpstreamBackend;
3903
3907
  result = execute(paths, id);
3904
3908
  } else if (command === remove) {
3905
- const execute = dependencies.removeUpstream ?? (await import("./chunk-SQZ2OSP6.js")).removeUpstreamBackend;
3909
+ const execute = dependencies.removeUpstream ?? (await import("./chunk-OFNOMEVX.js")).removeUpstreamBackend;
3906
3910
  result = execute(paths, id);
3907
3911
  } else if (command === disconnect) {
3908
- const execute = dependencies.disconnectUpstream ?? (await import("./chunk-F7AMEDDU.js")).disconnectUpstreamBackendEnrollment;
3912
+ const execute = dependencies.disconnectUpstream ?? (await import("./chunk-SANHAZJM.js")).disconnectUpstreamBackendEnrollment;
3909
3913
  result = await execute(paths, id);
3910
3914
  } else if (command === start) {
3911
- const execute = dependencies.startUpstreamEnroll ?? (await import("./chunk-F7AMEDDU.js")).startUpstreamEnrollment;
3915
+ const execute = dependencies.startUpstreamEnroll ?? (await import("./chunk-SANHAZJM.js")).startUpstreamEnrollment;
3912
3916
  result = await execute(paths, id, {
3913
3917
  memoryAnswers: Boolean(options.memoryAnswers || options.enableMemoryAnswers),
3914
3918
  sourceOwnerPrincipalId: required(options.sourceOwnerPrincipalId, "--source-owner-principal-id")
3915
3919
  });
3916
3920
  } else if (command === status) {
3917
- const execute = dependencies.getUpstreamEnrollStatus ?? (await import("./chunk-F7AMEDDU.js")).getUpstreamEnrollmentStatus;
3921
+ const execute = dependencies.getUpstreamEnrollStatus ?? (await import("./chunk-SANHAZJM.js")).getUpstreamEnrollmentStatus;
3918
3922
  result = await execute(paths, id);
3919
3923
  } else {
3920
- const execute = dependencies.cancelUpstreamEnroll ?? (await import("./chunk-F7AMEDDU.js")).cancelUpstreamEnrollment;
3924
+ const execute = dependencies.cancelUpstreamEnroll ?? (await import("./chunk-SANHAZJM.js")).cancelUpstreamEnrollment;
3921
3925
  result = await execute(paths, id);
3922
3926
  }
3923
3927
  }
@@ -3978,22 +3982,22 @@ var registerProjectCommands = (program2, dependencies, complete) => {
3978
3982
  const paths = (dependencies.resolvePaths ?? resolveKoedServerPaths)();
3979
3983
  let result;
3980
3984
  if (command === discover) {
3981
- const execute = dependencies.discoverProjectMetadata ?? (await import("./chunk-VLP72QWX.js")).discoverProjectMetadata;
3985
+ const execute = dependencies.discoverProjectMetadata ?? (await import("./chunk-PMDFTON3.js")).discoverProjectMetadata;
3982
3986
  result = await execute(paths, {
3983
3987
  cwd: options.cwd ?? process.cwd(),
3984
3988
  aiClientSource: options.codex ? "codex" : void 0
3985
3989
  });
3986
3990
  } else if (command === list) {
3987
- const execute = dependencies.listProjectMetadata ?? (await import("./chunk-VLP72QWX.js")).listProjectMetadata;
3991
+ const execute = dependencies.listProjectMetadata ?? (await import("./chunk-PMDFTON3.js")).listProjectMetadata;
3988
3992
  result = execute(paths);
3989
3993
  } else if (command === show) {
3990
- const execute = dependencies.getProjectMetadataForCwd ?? (await import("./chunk-VLP72QWX.js")).getProjectMetadataForCwd;
3994
+ const execute = dependencies.getProjectMetadataForCwd ?? (await import("./chunk-PMDFTON3.js")).getProjectMetadataForCwd;
3991
3995
  result = execute(paths, options.cwd ?? process.cwd());
3992
3996
  } else if (command === forget) {
3993
- const execute = dependencies.forgetProjectMetadata ?? (await import("./chunk-VLP72QWX.js")).forgetProjectMetadata;
3997
+ const execute = dependencies.forgetProjectMetadata ?? (await import("./chunk-PMDFTON3.js")).forgetProjectMetadata;
3994
3998
  result = execute(paths, required2(options.localProjectId, "--local-project-id"));
3995
3999
  } else if (command === anchor) {
3996
- const { setProjectRepositoryAnchor } = await import("./chunk-VLP72QWX.js");
4000
+ const { setProjectRepositoryAnchor } = await import("./chunk-PMDFTON3.js");
3997
4001
  result = await setProjectRepositoryAnchor(paths, {
3998
4002
  localProjectId: required2(options.localProjectId, "--local-project-id"),
3999
4003
  expectedCheckoutId: required2(options.checkoutId, "--checkout-id"),
@@ -4057,7 +4061,7 @@ var registerPackageCommands = (program2, dependencies, complete) => {
4057
4061
  let result;
4058
4062
  switch (command.name()) {
4059
4063
  case "status": {
4060
- const execute = dependencies.collectPackageStatus ?? (await import("./chunk-F77ZTTNS.js")).collectServerPackageStatus;
4064
+ const execute = dependencies.collectPackageStatus ?? (await import("./chunk-BRPU557N.js")).collectServerPackageStatus;
4061
4065
  result = execute(paths);
4062
4066
  break;
4063
4067
  }
@@ -4084,20 +4088,20 @@ var registerPackageCommands = (program2, dependencies, complete) => {
4084
4088
  input.trustPolicy = policy;
4085
4089
  if (options.allowDowngrade)
4086
4090
  input.allowDowngrade = true;
4087
- const execute = dependencies.installPackage ?? (await import("./chunk-F77ZTTNS.js")).installServerPackage;
4091
+ const execute = dependencies.installPackage ?? (await import("./chunk-BRPU557N.js")).installServerPackage;
4088
4092
  result = await execute(paths, input);
4089
4093
  break;
4090
4094
  }
4091
4095
  case "activate": {
4092
4096
  const version = required3(options.version, "--version");
4093
- const execute = dependencies.activatePackage ?? (await import("./chunk-F77ZTTNS.js")).activateServerPackage;
4097
+ const execute = dependencies.activatePackage ?? (await import("./chunk-BRPU557N.js")).activateServerPackage;
4094
4098
  result = execute(paths, version, {
4095
4099
  allowDowngrade: Boolean(options.allowDowngrade)
4096
4100
  });
4097
4101
  break;
4098
4102
  }
4099
4103
  default: {
4100
- const execute = dependencies.cleanupPackages ?? (await import("./chunk-F77ZTTNS.js")).cleanupServerPackages;
4104
+ const execute = dependencies.cleanupPackages ?? (await import("./chunk-BRPU557N.js")).cleanupServerPackages;
4101
4105
  result = execute(paths, Number.parseInt(options.keep ?? "1", 10));
4102
4106
  }
4103
4107
  }
@@ -4139,7 +4143,7 @@ var runModelCommand = async (operation, options, dependencies) => {
4139
4143
  if (options.kind !== "embedding" && options.kind !== "privacy")
4140
4144
  throw new Error("--kind must be embedding or privacy.");
4141
4145
  const paths = (dependencies.resolvePaths ?? resolveKoedServerPaths)();
4142
- const loadEnvironment = dependencies.loadEnvironment ?? (await import("./chunk-7NOQSX4T.js")).loadRepoEnv;
4146
+ const loadEnvironment = dependencies.loadEnvironment ?? (await import("./chunk-UKBULNBO.js")).loadRepoEnv;
4143
4147
  const environment = {
4144
4148
  ...loadEnvironment(paths.repoRoot),
4145
4149
  ...Object.fromEntries(Object.entries(process.env).filter(([, value]) => value?.trim()))
@@ -4147,10 +4151,10 @@ var runModelCommand = async (operation, options, dependencies) => {
4147
4151
  let result;
4148
4152
  if (options.kind === "privacy") {
4149
4153
  if (operation === "status") {
4150
- const execute = dependencies.collectPrivacyModelStatus ?? (await import("./chunk-S6HD3MDU.js")).collectPrivacyModelStatus;
4154
+ const execute = dependencies.collectPrivacyModelStatus ?? (await import("./chunk-2XVGC6KN.js")).collectPrivacyModelStatus;
4151
4155
  result = await execute(paths);
4152
4156
  } else {
4153
- const execute = dependencies.installPrivacyModel ?? (await import("./chunk-S6HD3MDU.js")).installPrivacyModel;
4157
+ const execute = dependencies.installPrivacyModel ?? (await import("./chunk-2XVGC6KN.js")).installPrivacyModel;
4154
4158
  const files = /* @__PURE__ */ new Map();
4155
4159
  result = options.progressJson ? await execute(paths, environment, void 0, {
4156
4160
  progress: (event) => {
@@ -4223,7 +4227,7 @@ var runRuntimeCommand = async (operation, options, dependencies) => {
4223
4227
  if (operation === "install" && options.dependencyMode !== "bundled-local")
4224
4228
  throw new Error("runtime install requires --dependency-mode bundled-local.");
4225
4229
  const paths = (dependencies.resolvePaths ?? resolveKoedServerPaths)();
4226
- const loadEnvironment = dependencies.loadEnvironment ?? (await import("./chunk-7NOQSX4T.js")).loadRepoEnv;
4230
+ const loadEnvironment = dependencies.loadEnvironment ?? (await import("./chunk-UKBULNBO.js")).loadRepoEnv;
4227
4231
  const environment = {
4228
4232
  ...loadEnvironment(paths.repoRoot),
4229
4233
  ...Object.fromEntries(
@@ -4235,7 +4239,7 @@ var runRuntimeCommand = async (operation, options, dependencies) => {
4235
4239
  if (options.provider === "release") {
4236
4240
  if (dependencies.desktopRuntimeCapability)
4237
4241
  throw new Error("Use Koed Desktop to manage its runtime.");
4238
- const release = await import("./chunk-273NMYXE.js");
4242
+ const release = await import("./chunk-PAPGIBPA.js");
4239
4243
  if (operation === "validate") {
4240
4244
  if (!options.runtimeRoot?.trim())
4241
4245
  throw new Error("Provide a trusted staged runtime directory.");
@@ -4243,9 +4247,9 @@ var runRuntimeCommand = async (operation, options, dependencies) => {
4243
4247
  release.assertReleaseHost();
4244
4248
  if (process.platform === "darwin")
4245
4249
  throw new Error("CUDA runtime validation is not supported on macOS.");
4246
- const { withStoppedRuntime } = await import("./chunk-ILQVLZ2I.js");
4250
+ const { withStoppedRuntime } = await import("./chunk-BYN4THYX.js");
4247
4251
  const { resolveKoedRuntimeOwner } = await import("./chunk-ZKKWLLPU.js");
4248
- const { validateStagedCuda } = await import("./chunk-W6632NOX.js");
4252
+ const { validateStagedCuda } = await import("./chunk-CZKIP3UJ.js");
4249
4253
  result = await withRuntimeCancellation((signal) => withStoppedRuntime(paths, resolveKoedRuntimeOwner(), () => validateStagedCuda(paths, root, environment, {
4250
4254
  signal,
4251
4255
  requireModel: options.requireModel === true
@@ -4307,21 +4311,10 @@ var registerRuntimeCommands = (program2, dependencies, complete) => {
4307
4311
  };
4308
4312
 
4309
4313
  // packages/koed-server/dist/personal-device-sync-feature.js
4310
- var personalDeviceSyncFeatureEnvironmentName = "KOED_PERSONAL_DEVICE_SYNC_ENABLED";
4311
4314
  var personalDeviceSyncCommandNames = [
4312
4315
  "pair",
4313
4316
  "personal-sync"
4314
4317
  ];
4315
- var resolvePersonalDeviceSyncEnabled = (environment = process.env) => {
4316
- const configured = environment[personalDeviceSyncFeatureEnvironmentName];
4317
- if (configured === void 0 || configured === "")
4318
- return false;
4319
- if (configured === "true")
4320
- return true;
4321
- if (configured === "false")
4322
- return false;
4323
- throw new Error(`${personalDeviceSyncFeatureEnvironmentName} must be exactly "true" or "false"`);
4324
- };
4325
4318
 
4326
4319
  // packages/koed-server/dist/cli-command-tree.js
4327
4320
  var runCommandTree = async (args, dependencies = {}) => {