@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.
Files changed (47) hide show
  1. package/README.md +3 -3
  2. package/bin/koed.js +1 -1
  3. package/package.json +2 -2
  4. package/vendor/chunk-2YCDKSKW.js +45 -0
  5. package/vendor/{chunk-TG26CZGQ.js → chunk-355BP3MF.js} +4 -4
  6. package/vendor/{chunk-RCR4XPE3.js → chunk-3VNLZCMB.js} +1 -1
  7. package/vendor/{chunk-NVTMIAAF.js → chunk-7YXEB2CR.js} +18 -17
  8. package/vendor/{chunk-SRKIBFOE.js → chunk-A2TMTAAS.js} +1 -1
  9. package/vendor/{chunk-PL3LWC5C.js → chunk-AJPFOTVX.js} +1 -1
  10. package/vendor/{chunk-O7DW2VAV.js → chunk-BDJR6CKS.js} +4 -3
  11. package/vendor/{chunk-Z5WCAUA6.js → chunk-BMHMNUNK.js} +18 -17
  12. package/vendor/{chunk-C5SNDPAP.js → chunk-CSDTMMRL.js} +4 -4
  13. package/vendor/{chunk-FYYRFX4U.js → chunk-CX73L6YS.js} +67 -38
  14. package/vendor/{chunk-VGIYSDNU.js → chunk-D4XZTNLU.js} +117 -33
  15. package/vendor/{chunk-W2OJZZ6X.js → chunk-DQ5SIGZZ.js} +4 -2
  16. package/vendor/{chunk-4OO6VAU3.js → chunk-G54Q5W6M.js} +1 -1
  17. package/vendor/{chunk-EA4QDDQA.js → chunk-GEIN6UIL.js} +7 -2
  18. package/vendor/{chunk-QRKHHWJJ.js → chunk-H7ETSD25.js} +51 -3
  19. package/vendor/{chunk-NOU7RHYZ.js → chunk-HG47LAWW.js} +5 -4
  20. package/vendor/{chunk-C4V72GXC.js → chunk-HXL36SED.js} +19 -18
  21. package/vendor/{chunk-FN3HUUO2.js → chunk-I5XO5FL4.js} +73 -13
  22. package/vendor/{chunk-TVYEB2GN.js → chunk-J7LW6JFY.js} +48 -10
  23. package/vendor/{chunk-OCILJ737.js → chunk-JG7OELJM.js} +9 -9
  24. package/vendor/{chunk-6KS67EQE.js → chunk-KBECHDUE.js} +1 -1
  25. package/vendor/{chunk-2XKSVKQA.js → chunk-KH4UBONI.js} +3 -2
  26. package/vendor/{chunk-ZIOKV2X6.js → chunk-MFPPURFE.js} +113 -33
  27. package/vendor/{chunk-GFASBPV2.js → chunk-MHFYPBCL.js} +3 -3
  28. package/vendor/{chunk-V67IQB7H.js → chunk-OG7G6DIR.js} +1 -1
  29. package/vendor/{chunk-WDFERJG3.js → chunk-TAQWNZVD.js} +109 -33
  30. package/vendor/{chunk-HC76426R.js → chunk-TMCW2P6G.js} +7 -5
  31. package/vendor/chunk-ULLAURFV.js +8 -0
  32. package/vendor/{chunk-WPIEF4LY.js → chunk-ULUSFNAE.js} +3 -3
  33. package/vendor/{chunk-ZOHNXUDY.js → chunk-VWB3VEOL.js} +493 -20
  34. package/vendor/{chunk-LRP66XEY.js → chunk-XPSPPLX5.js} +14 -14
  35. package/vendor/{chunk-SHLRINKO.js → chunk-XSOQ2U5H.js} +2 -2
  36. package/vendor/{chunk-EDPNYIX5.js → chunk-XTQYFCVY.js} +146 -89
  37. package/vendor/{chunk-CHMH4LH5.js → chunk-XW7AXRDI.js} +3 -3
  38. package/vendor/{chunk-SNKWETM5.js → chunk-Y5OJXAUF.js} +2 -2
  39. package/vendor/chunk-YDZEMIAH.js +11 -0
  40. package/vendor/{chunk-BUIM2M4R.js → chunk-YOMK7KMB.js} +2 -2
  41. package/vendor/{chunk-ALJUSOF7.js → chunk-YY7NMZGD.js} +79 -1
  42. package/vendor/{chunk-BGENSONI.js → chunk-ZKKWLLPU.js} +1 -1
  43. package/vendor/cli.js +1 -1
  44. package/vendor/component-manifest-catalog.js +1 -1
  45. package/vendor/control-plane.js +6 -4
  46. package/vendor/chunk-7EGSY3E4.js +0 -8
  47. package/vendor/chunk-ZUDSZGVO.js +0 -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
  noteAiClientConnectionRevision
4
- } from "./chunk-6KS67EQE.js";
4
+ } from "./chunk-KBECHDUE.js";
5
5
  import {
6
6
  configureCodexIntegrationForRemoteBackend,
7
7
  grantAiClientConnection,
@@ -17,13 +17,13 @@ import {
17
17
  revokeAiClientConnection,
18
18
  setupClaude,
19
19
  setupPi
20
- } from "./chunk-EDPNYIX5.js";
20
+ } from "./chunk-XTQYFCVY.js";
21
21
  import "./chunk-QT24SAW6.js";
22
22
  import "./chunk-TISYUUEJ.js";
23
23
  import {
24
24
  resolveKoedServerConfig
25
- } from "./chunk-ALJUSOF7.js";
26
- import "./chunk-SRKIBFOE.js";
25
+ } from "./chunk-YY7NMZGD.js";
26
+ import "./chunk-A2TMTAAS.js";
27
27
  import {
28
28
  resolveKoedServerPaths
29
29
  } from "./chunk-TSAYTRX3.js";
@@ -31,24 +31,24 @@ import "./chunk-YZLQZU5E.js";
31
31
  import "./chunk-W2HNI6AA.js";
32
32
  import {
33
33
  resolveKoedAppRuntime
34
- } from "./chunk-V67IQB7H.js";
35
- import "./chunk-FN3HUUO2.js";
34
+ } from "./chunk-OG7G6DIR.js";
35
+ import "./chunk-I5XO5FL4.js";
36
36
  import {
37
37
  isProcessRunning
38
38
  } from "./chunk-T6UB5PNX.js";
39
39
  import {
40
40
  require_proper_lockfile
41
41
  } from "./chunk-7NXKPDF3.js";
42
- import "./chunk-ZUDSZGVO.js";
43
- import "./chunk-ZIOKV2X6.js";
44
- import "./chunk-QRKHHWJJ.js";
45
- import "./chunk-7EGSY3E4.js";
42
+ import "./chunk-YDZEMIAH.js";
43
+ import "./chunk-MFPPURFE.js";
44
+ import "./chunk-H7ETSD25.js";
45
+ import "./chunk-ULLAURFV.js";
46
46
  import "./chunk-IY2HRXOZ.js";
47
- import "./chunk-4OO6VAU3.js";
48
- import "./chunk-RCR4XPE3.js";
47
+ import "./chunk-G54Q5W6M.js";
48
+ import "./chunk-3VNLZCMB.js";
49
49
  import {
50
50
  isTeamMemoryAnswerTaskCapability
51
- } from "./chunk-ZOHNXUDY.js";
51
+ } from "./chunk-VWB3VEOL.js";
52
52
  import {
53
53
  NEVER,
54
54
  ZodIssueCode,
@@ -13890,7 +13890,7 @@ var runRemoteMcpOperation = async (command, input, options) => {
13890
13890
  }
13891
13891
  };
13892
13892
  var runRemoteMcpCommand = async (args, options) => {
13893
- const { runKoedServerCli } = await import("./chunk-W2OJZZ6X.js");
13893
+ const { runKoedServerCli } = await import("./chunk-DQ5SIGZZ.js");
13894
13894
  return runKoedServerCli(["remote", ...args], {
13895
13895
  stdout: options.stdout,
13896
13896
  stderr: options.stderr,
@@ -1,13 +1,13 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
2
  import {
3
3
  resolveKoedServerConfig
4
- } from "./chunk-ALJUSOF7.js";
4
+ } from "./chunk-YY7NMZGD.js";
5
5
  import {
6
6
  parseEnvFile
7
7
  } from "./chunk-W2HNI6AA.js";
8
8
  import {
9
9
  resolveTeamCollaborationEnabled
10
- } from "./chunk-ZOHNXUDY.js";
10
+ } from "./chunk-VWB3VEOL.js";
11
11
 
12
12
  // packages/koed-server/dist/effective-runtime-config.js
13
13
  import { existsSync, readFileSync } from "node:fs";
@@ -11,10 +11,10 @@ import {
11
11
  import {
12
12
  resolveKoedServerConfig,
13
13
  writeCodexGlobalMemoryGuidancePreference
14
- } from "./chunk-ALJUSOF7.js";
14
+ } from "./chunk-YY7NMZGD.js";
15
15
  import {
16
16
  inspectDeviceIdentityStatus
17
- } from "./chunk-SRKIBFOE.js";
17
+ } from "./chunk-A2TMTAAS.js";
18
18
  import {
19
19
  ensureKoedHome,
20
20
  resolveKoedServerPaths
@@ -34,7 +34,7 @@ import {
34
34
  resolveKoedAppRuntimeForExecution,
35
35
  resolveKoedControlPlaneVersion,
36
36
  resolveKoedRuntimeOwner
37
- } from "./chunk-V67IQB7H.js";
37
+ } from "./chunk-OG7G6DIR.js";
38
38
  import {
39
39
  pinDesktopBundleGenerationForStart,
40
40
  pinGenerationForStart,
@@ -43,7 +43,7 @@ import {
43
43
  readDesktopBundleGeneration,
44
44
  resolveDesktopRuntimeOwner,
45
45
  validateDesktopRuntimeCapability
46
- } from "./chunk-FN3HUUO2.js";
46
+ } from "./chunk-I5XO5FL4.js";
47
47
  import {
48
48
  applyActiveRuntimeUrls,
49
49
  isProcessRunning,
@@ -55,10 +55,10 @@ import {
55
55
  import {
56
56
  collectPrivacyModelStatus,
57
57
  resolvePrivacyModelPaths
58
- } from "./chunk-4OO6VAU3.js";
58
+ } from "./chunk-G54Q5W6M.js";
59
59
  import {
60
60
  collectUpstreamRegistryStatus
61
- } from "./chunk-RCR4XPE3.js";
61
+ } from "./chunk-3VNLZCMB.js";
62
62
  import {
63
63
  DESKTOP_LOCAL_CREDENTIAL_OPERATION_FAMILIES,
64
64
  LOCAL_PERSONAL_USER_EMAIL,
@@ -74,7 +74,7 @@ import {
74
74
  storeDesktopLocalCredential,
75
75
  summarizeHistoricalIngestionState,
76
76
  upgradeDesktopLocalCredential
77
- } from "./chunk-ZOHNXUDY.js";
77
+ } from "./chunk-VWB3VEOL.js";
78
78
  import {
79
79
  __toESM
80
80
  } from "./chunk-BTS4ZTF3.js";
@@ -443,6 +443,9 @@ var resolveLocalEmbeddingRuntimePaths = (paths, environment = process.env, exist
443
443
  const llama = llamaOverride ? {
444
444
  path: resolve(llamaOverride),
445
445
  artifactSource: "explicit-override"
446
+ } : paths.nativeSelectionRoot ? {
447
+ path: koedRuntimeLlamaServer,
448
+ artifactSource: "koed-home-runtime"
446
449
  } : chooseRuntimePath([
447
450
  {
448
451
  path: koedRuntimeLlamaServer,
@@ -569,6 +572,7 @@ var collectLocalEmbeddingRuntimeStatus = async (paths, environment = process.env
569
572
  };
570
573
  }
571
574
  };
575
+ var embeddingServiceLeadsProcessGroup = (paths, platform = process.platform) => Boolean(paths.nativeSelectionRoot) || platform !== "win32";
572
576
  var startLocalEmbeddingRuntime = (paths, environment = process.env, dependencies = {}) => {
573
577
  const exists = dependencies.existsSync ?? existsSync3;
574
578
  const spawn = dependencies.spawn ?? nodeSpawn;
@@ -584,8 +588,8 @@ var startLocalEmbeddingRuntime = (paths, environment = process.env, dependencies
584
588
  }
585
589
  const child = spawn(process.execPath, [runtime.serviceEntry], {
586
590
  cwd: runtime.appDir,
587
- // The release supervisor can stop its owned llama-server descendants together.
588
- ...paths.nativeSelectionRoot ? { detached: true } : {},
591
+ // koed-server stops its owned llama-server descendants with the group.
592
+ ...embeddingServiceLeadsProcessGroup(paths) ? { detached: true } : {},
589
593
  env,
590
594
  stdio: "inherit"
591
595
  });
@@ -832,7 +836,7 @@ var resolvePostgresBinDir = (paths, environment = process.env, exists = existsSy
832
836
  return { binDir: resolve4(override), artifactSource: "explicit-override" };
833
837
  }
834
838
  const koedRuntimeDir = resolve4(paths.nativeSelectionRoot ?? resolve4(paths.koedHome, "runtime"), "postgres", "bin");
835
- if (hasAnyPostgresBinary(koedRuntimeDir, exists)) {
839
+ if (paths.nativeSelectionRoot || hasAnyPostgresBinary(koedRuntimeDir, exists)) {
836
840
  return { binDir: koedRuntimeDir, artifactSource: "koed-home-runtime" };
837
841
  }
838
842
  const packagedRuntimeRoot = resolvePackagedKoedRuntimeRoot(environment);
@@ -1775,7 +1779,7 @@ var setupPi = async (environment = process.env, spawnSync = nodeSpawnSync2, opti
1775
1779
  models: []
1776
1780
  }, void 0, options.desktopRuntimeCapability) : resolveKoedAppRuntime(paths, environment);
1777
1781
  const sourceCandidates = runtime.kind === "source" ? [resolve7(runtime.root, "packages/mcp-server/integrations/pi")] : [
1778
- resolve7(runtime.root, "node_modules/@koed/mcp-server/integrations/pi"),
1782
+ resolve7(runtime.root, "node_modules/@koed-labs/mcp-server/integrations/pi"),
1779
1783
  resolve7(runtime.root, "mcp-server/integrations/pi")
1780
1784
  ];
1781
1785
  const source = sourceCandidates.find(existsSync8);
@@ -3460,7 +3464,7 @@ var inspectMcp = async (environment, paths, deps) => {
3460
3464
  const cliPath = appRuntime.mcpCli;
3461
3465
  if (!deps.existsSync(cliPath)) {
3462
3466
  const authenticatedGenerationMissing = appRuntime.missing.some((entry) => entry.startsWith("authenticated "));
3463
- return notConfigured(authenticatedGenerationMissing ? "No active authenticated Koed app-runtime generation is available." : appRuntime.kind === "packaged" ? "Packaged MCP Server artifact was not found." : "MCP Server build output was not found.", authenticatedGenerationMissing ? "Install and activate a compatible signed Koed app-runtime generation; status does not install or activate components." : appRuntime.kind === "packaged" ? "Install a compatible signed Koed app-runtime generation containing MCP Server and Supported Capture Hook artifacts." : "Run pnpm --filter @koed/mcp-server build or koed setup core --json.", {
3467
+ return notConfigured(authenticatedGenerationMissing ? "No active authenticated Koed app-runtime generation is available." : appRuntime.kind === "packaged" ? "Packaged MCP Server artifact was not found." : "MCP Server build output was not found.", authenticatedGenerationMissing ? "Install and activate a compatible signed Koed app-runtime generation; status does not install or activate components." : appRuntime.kind === "packaged" ? "Install a compatible signed Koed app-runtime generation containing MCP Server and Supported Capture Hook artifacts." : "Run pnpm --filter @koed-labs/mcp-server build or koed setup core --json.", {
3464
3468
  artifactSource: appRuntime.artifactSource,
3465
3469
  runtimeRoot: appRuntime.root,
3466
3470
  missing: appRuntime.missing
@@ -4512,11 +4516,122 @@ var collectKoedServerDoctor = async (environment = process.env, dependencies = {
4512
4516
  };
4513
4517
  };
4514
4518
 
4519
+ // packages/koed-server/dist/codex-config-block.mjs
4520
+ import { basename as basename2, dirname as dirname10, isAbsolute as isAbsolute3, join as join4 } from "node:path";
4521
+ function codexConfigSections({ nodeCommand, mcpName, mcpCliPath, captureHookPath, koedHome }) {
4522
+ const hookCommand = [
4523
+ nodeCommand,
4524
+ captureHookPath,
4525
+ "--koed-home",
4526
+ koedHome,
4527
+ "--memory-tool",
4528
+ `mcp__${mcpName}__memory_answer`
4529
+ ].map((value) => JSON.stringify(value)).join(" ");
4530
+ const hookEvents = [
4531
+ ["PreToolUse", 10],
4532
+ ["SessionStart", 10],
4533
+ ["UserPromptSubmit", 10],
4534
+ ["PostToolUse", 10],
4535
+ ["Stop", 30],
4536
+ ["SubagentStart", 10],
4537
+ ["SubagentStop", 30]
4538
+ ];
4539
+ const hookBlocks = hookEvents.map(([eventName, timeout]) => `[[hooks.${eventName}]]
4540
+ ${eventName === "PreToolUse" ? `matcher = ${JSON.stringify(`mcp__${mcpName}__memory_answer`)}
4541
+ ` : ""}[[hooks.${eventName}.hooks]]
4542
+ type = "command"
4543
+ command = ${JSON.stringify(hookCommand)}
4544
+ timeout = ${timeout}`).join("\n\n");
4545
+ const header = `mcp_servers.${mcpName}`;
4546
+ const tables = [
4547
+ `[${header}]
4548
+ command = ${JSON.stringify(nodeCommand)}
4549
+ args = [${JSON.stringify(mcpCliPath)}]
4550
+ enabled = true`,
4551
+ ...[
4552
+ "memory_answer",
4553
+ "memory_answer_result",
4554
+ "memory_answer_cancel",
4555
+ "memory_workspaces"
4556
+ ].map((tool) => `[${header}.tools.${tool}]
4557
+ approval_mode = "approve"`),
4558
+ `[${header}.env]
4559
+ KOED_HOME = ${JSON.stringify(koedHome)}`
4560
+ ];
4561
+ return { tables, hooks: hookBlocks };
4562
+ }
4563
+ function renderCodexBlock(config) {
4564
+ const { tables, hooks } = codexConfigSections(config);
4565
+ return `# >>> koed
4566
+ ${tables.join("\n\n")}
4567
+
4568
+ ${hooks}
4569
+ # <<< koed
4570
+ `;
4571
+ }
4572
+ function stripReorderedCodexBlock(content, config) {
4573
+ if (!content.trimEnd().endsWith("# <<< koed") || /^\s*# >>> koed\s*$/m.test(content))
4574
+ return content;
4575
+ if ((content.match(/^[\t ]*# <<< koed[\t ]*\r?$/gm) ?? []).length !== 1 || /"""|'''/.test(content))
4576
+ return content;
4577
+ const header = `[mcp_servers.${config.mcpName}]`;
4578
+ const tables = content.split(/(?=^\[)/m);
4579
+ const server = tables.find((table) => table.split(/\r?\n/, 1)[0] === header);
4580
+ if (!server)
4581
+ return content;
4582
+ let cli;
4583
+ let command;
4584
+ try {
4585
+ const args = JSON.parse(/^args = (.+)$/m.exec(server)?.[1] ?? "");
4586
+ command = JSON.parse(/^command = (.+)$/m.exec(server)?.[1] ?? "");
4587
+ if (!Array.isArray(args) || args.length !== 1 || typeof command !== "string")
4588
+ return content;
4589
+ cli = args[0];
4590
+ } catch {
4591
+ return content;
4592
+ }
4593
+ if (typeof cli !== "string" || !isAbsolute3(cli) || basename2(cli) !== "cli.js" || basename2(dirname10(cli)) !== "dist" || basename2(dirname10(dirname10(cli))) !== "mcp-server")
4594
+ return content;
4595
+ const captureHookPath = join4(dirname10(cli), "capture-hook.js");
4596
+ const expected = codexConfigSections({
4597
+ ...config,
4598
+ nodeCommand: command,
4599
+ mcpCliPath: cli,
4600
+ captureHookPath
4601
+ });
4602
+ const newline = server.includes("\r\n") ? "\r\n" : "\n";
4603
+ const hooks = (expected.hooks + "\n# <<< koed").replaceAll("\n", newline);
4604
+ const trimmed = content.trimEnd();
4605
+ if (!trimmed.endsWith(newline + hooks))
4606
+ return content;
4607
+ const beforeHooks = content.slice(0, trimmed.length - hooks.length);
4608
+ if (beforeHooks.includes(captureHookPath))
4609
+ return content;
4610
+ const expectedTables = new Map(expected.tables.map((table) => [table.split("\n", 1)[0], table]));
4611
+ const retained = [];
4612
+ for (const table of beforeHooks.split(/(?=^\[)/m)) {
4613
+ const name = table.split(/\r?\n/, 1)[0];
4614
+ if (name !== header && !name.startsWith(header.slice(0, -1) + ".")) {
4615
+ retained.push(table);
4616
+ continue;
4617
+ }
4618
+ const expectedTable = expectedTables.get(name);
4619
+ const actual = table.trimEnd().replaceAll("\r\n", "\n");
4620
+ if (!expectedTable)
4621
+ return content;
4622
+ const matchesImplicitEnabled = name === header && actual === expectedTable.replace("\nenabled = true", "");
4623
+ if (actual !== expectedTable && !matchesImplicitEnabled)
4624
+ return content;
4625
+ expectedTables.delete(name);
4626
+ }
4627
+ return expectedTables.size === 0 ? retained.join("") : content;
4628
+ }
4629
+
4515
4630
  // packages/koed-server/dist/setup.js
4516
4631
  import { spawnSync as nodeSpawnSync5 } from "node:child_process";
4517
4632
  import { chmodSync as nodeChmodSync, existsSync as nodeExistsSync, mkdirSync as nodeMkdirSync, readFileSync as nodeReadFileSync, statSync as nodeStatSync, unlinkSync as nodeUnlinkSync, writeFileSync as nodeWriteFileSync } from "node:fs";
4518
4633
  import { homedir as homedir5 } from "node:os";
4519
- import { dirname as dirname10, resolve as resolve15 } from "node:path";
4634
+ import { dirname as dirname11, resolve as resolve15 } from "node:path";
4520
4635
 
4521
4636
  // packages/koed-server/dist/local-service-secrets.js
4522
4637
  import { randomBytes } from "node:crypto";
@@ -4731,7 +4846,7 @@ var restoreManagedFile = (path2, snapshot, existsSync13, writeFileSync8, mkdirSy
4731
4846
  nodeUnlinkSync(path2);
4732
4847
  return;
4733
4848
  }
4734
- mkdirSync8(dirname10(path2), { recursive: true, mode: 448 });
4849
+ mkdirSync8(dirname11(path2), { recursive: true, mode: 448 });
4735
4850
  writeFileSync8(path2, snapshot.content, { mode: snapshot.mode ?? 384 });
4736
4851
  if (snapshot.mode !== null)
4737
4852
  nodeChmodSync(path2, snapshot.mode);
@@ -4749,7 +4864,6 @@ var configureCodexIntegration = ({ paths, environment, apiUrl, readFileSync: rea
4749
4864
  const codexConfigPath = resolve15(environment.CODEX_CONFIG_PATH ?? `${environment.CODEX_HOME ?? `${homedir5()}/.codex`}/config.toml`);
4750
4865
  const codexInstructionsPath = resolveCodexGlobalInstructionsPath(environment);
4751
4866
  const existing = existsSync13(codexConfigPath) ? String(readFileSync8(codexConfigPath, "utf8")) : "";
4752
- const withoutPrevious = stripCodexOwnershipBlock(existing);
4753
4867
  if (!/^[A-Za-z0-9_-]+$/.test(mcpName))
4754
4868
  throw new Error("MEMORY_MCP_NAME must be a TOML bare server name.");
4755
4869
  const guidancePath = resolveCodexGuidancePath(runtime.mcpCli);
@@ -4764,60 +4878,20 @@ var configureCodexIntegration = ({ paths, environment, apiUrl, readFileSync: rea
4764
4878
  } else {
4765
4879
  nextInstructions = removeManagedCodexGuidance(existingInstructions);
4766
4880
  }
4767
- const markerStart = "# >>> koed";
4768
- const markerEnd = "# <<< koed";
4769
- const hookCommand = [
4881
+ const config = {
4770
4882
  nodeCommand,
4771
- runtime.captureHook,
4772
- "--koed-home",
4773
- paths.koedHome,
4774
- "--memory-tool",
4775
- `mcp__${mcpName}__memory_answer`
4776
- ].map(tomlString).join(" ");
4777
- const hookEvents = [
4778
- ["PreToolUse", 10],
4779
- ["SessionStart", 10],
4780
- ["UserPromptSubmit", 10],
4781
- ["PostToolUse", 10],
4782
- ["Stop", 30],
4783
- ["SubagentStart", 10],
4784
- ["SubagentStop", 30]
4785
- ];
4786
- const hookBlocks = hookEvents.map(([eventName, timeout]) => `[[hooks.${eventName}]]
4787
- ${eventName === "PreToolUse" ? `matcher = ${tomlString(`mcp__${mcpName}__memory_answer`)}
4788
- ` : ""}[[hooks.${eventName}.hooks]]
4789
- type = "command"
4790
- command = ${tomlString(hookCommand)}
4791
- timeout = ${timeout}`).join("\n\n");
4792
- const koedBlock = `${markerStart}
4793
- [mcp_servers.${mcpName}]
4794
- command = ${tomlString(nodeCommand)}
4795
- args = [${tomlString(runtime.mcpCli)}]
4796
- enabled = true
4797
-
4798
- [mcp_servers.${mcpName}.tools.memory_answer]
4799
- approval_mode = "approve"
4800
-
4801
- [mcp_servers.${mcpName}.tools.memory_answer_result]
4802
- approval_mode = "approve"
4803
-
4804
- [mcp_servers.${mcpName}.tools.memory_answer_cancel]
4805
- approval_mode = "approve"
4806
-
4807
- [mcp_servers.${mcpName}.tools.memory_workspaces]
4808
- approval_mode = "approve"
4809
-
4810
- [mcp_servers.${mcpName}.env]
4811
- KOED_HOME = ${tomlString(paths.koedHome)}
4812
-
4813
- ${hookBlocks}
4814
- ${markerEnd}
4815
- `;
4816
- mkdirSync8(dirname10(codexConfigPath), { recursive: true, mode: 448 });
4883
+ mcpName,
4884
+ mcpCliPath: runtime.mcpCli,
4885
+ captureHookPath: runtime.captureHook,
4886
+ koedHome: paths.koedHome
4887
+ };
4888
+ const withoutPrevious = stripCodexOwnershipBlock(stripReorderedCodexBlock(existing, config));
4889
+ const koedBlock = renderCodexBlock(config);
4890
+ mkdirSync8(dirname11(codexConfigPath), { recursive: true, mode: 448 });
4817
4891
  writeFileSync8(codexConfigPath, `${withoutPrevious.trimEnd()}
4818
4892
 
4819
4893
  ${koedBlock}`);
4820
- mkdirSync8(dirname10(codexInstructionsPath), { recursive: true, mode: 448 });
4894
+ mkdirSync8(dirname11(codexInstructionsPath), { recursive: true, mode: 448 });
4821
4895
  if (nextInstructions !== existingInstructions) {
4822
4896
  writeFileSync8(codexInstructionsPath, nextInstructions, { mode: 384 });
4823
4897
  }
@@ -4886,13 +4960,13 @@ var removeCodexIntegration = ({ environment = process.env, readFileSync: readFil
4886
4960
  }
4887
4961
  const nextInstructions = instructionsSnapshot.content === null ? null : removeManagedCodexGuidance(instructionsSnapshot.content);
4888
4962
  if (nextConfig !== configSnapshot.content && nextConfig !== null) {
4889
- mkdirSync8(dirname10(codexConfigPath), { recursive: true, mode: 448 });
4963
+ mkdirSync8(dirname11(codexConfigPath), { recursive: true, mode: 448 });
4890
4964
  writeFileSync8(codexConfigPath, nextConfig, {
4891
4965
  mode: configSnapshot.mode ?? 384
4892
4966
  });
4893
4967
  }
4894
4968
  if (nextInstructions !== instructionsSnapshot.content && nextInstructions !== null) {
4895
- mkdirSync8(dirname10(codexInstructionsPath), {
4969
+ mkdirSync8(dirname11(codexInstructionsPath), {
4896
4970
  recursive: true,
4897
4971
  mode: 448
4898
4972
  });
@@ -5034,7 +5108,6 @@ var configureCodexProfile = ({ environment = process.env, readFileSync: readFile
5034
5108
  stdout: result.stdout,
5035
5109
  action: "Restart Codex and trust updated hooks if prompted. New sessions will be captured after Codex reloads this config."
5036
5110
  };
5037
- writeSetupVerification(paths, repaired, writeFileSync8);
5038
5111
  return repaired;
5039
5112
  } catch (error) {
5040
5113
  const failures = [error instanceof Error ? error.message : String(error)];
@@ -5069,7 +5142,6 @@ var configureCodexProfile = ({ environment = process.env, readFileSync: readFile
5069
5142
  error: failures.join(" "),
5070
5143
  action: "Review the reported failure, fix the Codex integration artifacts, then run the Codex-specific repair action again."
5071
5144
  };
5072
- writeSetupVerification(paths, failed, writeFileSync8);
5073
5145
  return failed;
5074
5146
  }
5075
5147
  };
@@ -5238,18 +5310,10 @@ var runSetupBootstrap = (context, spawnSync) => {
5238
5310
  ...output,
5239
5311
  ok: false,
5240
5312
  state: "needs_attention",
5241
- error: `Codex setup failed with exit code ${result.status ?? 1}.`,
5313
+ error: output.stderr?.includes("Codex Koed ownership markers are duplicated or incomplete.") ? "Codex config.toml has incomplete or duplicate Koed markers. Review the Koed MCP Server and Capture Hook entries before retrying." : `Codex setup failed with exit code ${result.status ?? 1}.`,
5242
5314
  action: "Review stdout/stderr, fix the reported client setup failure, then rerun koed setup codex --json."
5243
5315
  };
5244
5316
  };
5245
- var writeSetupVerification = (paths, result, writeFileSync8, successMessage = "Koed core setup completed.") => {
5246
- writeFileSync8(paths.lastVerificationPath, `${JSON.stringify({
5247
- ok: result.ok,
5248
- checkedAt: result.checkedAt,
5249
- message: result.ok ? successMessage : result.error
5250
- }, null, 2)}
5251
- `, { mode: 384 });
5252
- };
5253
5317
  var setupCore = async (options = {}) => {
5254
5318
  const environment = options.environment ?? process.env;
5255
5319
  const prepared = prepareSetupCodex(environment, options, "core");
@@ -5301,11 +5365,8 @@ var setupCore = async (options = {}) => {
5301
5365
  var setupCodex = async (options = {}) => {
5302
5366
  const core = await setupCore(options);
5303
5367
  const writeFileSync8 = options.writeFileSync ?? nodeWriteFileSync;
5304
- if (!core.ok) {
5305
- const paths2 = resolveKoedServerPaths(options.environment ?? process.env);
5306
- writeSetupVerification(paths2, core, writeFileSync8, "Codex setup completed.");
5368
+ if (!core.ok)
5307
5369
  return core;
5308
- }
5309
5370
  const environment = options.environment ?? process.env;
5310
5371
  const paths = resolveKoedServerPaths(environment);
5311
5372
  if (environment.KOED_CODEX_GLOBAL_MEMORY_GUIDANCE_ENABLED === "true" || environment.KOED_CODEX_GLOBAL_MEMORY_GUIDANCE_ENABLED === "false") {
@@ -5342,10 +5403,8 @@ var setupCodex = async (options = {}) => {
5342
5403
  });
5343
5404
  }
5344
5405
  const prepared = prepareSetupCodex(environment, options);
5345
- if (!prepared.ok) {
5346
- writeSetupVerification(prepared.paths, prepared.result, writeFileSync8);
5406
+ if (!prepared.ok)
5347
5407
  return prepared.result;
5348
- }
5349
5408
  const { context } = prepared;
5350
5409
  try {
5351
5410
  assertAiClientRegistryWritable(context.childEnv);
@@ -5360,7 +5419,6 @@ var setupCodex = async (options = {}) => {
5360
5419
  error: error instanceof Error ? error.message : String(error),
5361
5420
  action: "Fix malformed AI Client registry, then rerun Codex setup."
5362
5421
  };
5363
- writeSetupVerification(context.paths, failed, writeFileSync8, "Codex setup completed.");
5364
5422
  return failed;
5365
5423
  }
5366
5424
  let codexExecutablePath;
@@ -5377,7 +5435,6 @@ var setupCodex = async (options = {}) => {
5377
5435
  error: error instanceof Error ? error.message : String(error),
5378
5436
  action: "Install Codex or set MEMORY_CODEX_APP_SERVER_BINARY, then rerun Codex setup."
5379
5437
  };
5380
- writeSetupVerification(context.paths, failed, writeFileSync8, "Codex setup completed.");
5381
5438
  return failed;
5382
5439
  }
5383
5440
  persistSetupApiToken(context);
@@ -5402,11 +5459,9 @@ var setupCodex = async (options = {}) => {
5402
5459
  error: error instanceof Error ? error.message : String(error),
5403
5460
  action: "Fix the Codex-specific registration, then rerun koed setup codex --json."
5404
5461
  };
5405
- writeSetupVerification(context.paths, failed, writeFileSync8, "Codex setup completed.");
5406
5462
  return failed;
5407
5463
  }
5408
5464
  }
5409
- writeSetupVerification(context.paths, result, writeFileSync8, "Codex setup completed.");
5410
5465
  return result;
5411
5466
  };
5412
5467
 
@@ -5414,6 +5469,7 @@ export {
5414
5469
  hasCompletePostgresOverride,
5415
5470
  stopLocalPostgresRuntime,
5416
5471
  startLocalPostgresRuntime,
5472
+ localServiceSecretsPath,
5417
5473
  ensurePackagedLocalServiceSecrets,
5418
5474
  pinAndResolvePackagedRuntime,
5419
5475
  resolveCodexExecutablePath,
@@ -5435,6 +5491,7 @@ export {
5435
5491
  grantAiClientConnection,
5436
5492
  revokeAiClientConnection,
5437
5493
  nativeLlamaServerOverride,
5494
+ embeddingServiceLeadsProcessGroup,
5438
5495
  startLocalEmbeddingRuntime,
5439
5496
  startLocalPrivacyRuntime,
5440
5497
  inspectPi,
@@ -1,10 +1,10 @@
1
1
  import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
2
  import {
3
3
  runApplicationSecretProvider
4
- } from "./chunk-EA4QDDQA.js";
4
+ } from "./chunk-GEIN6UIL.js";
5
5
  import {
6
6
  ensureDeviceIdentity
7
- } from "./chunk-SRKIBFOE.js";
7
+ } from "./chunk-A2TMTAAS.js";
8
8
  import {
9
9
  loadRepoEnv,
10
10
  resolveApiUrl
@@ -27,7 +27,7 @@ import {
27
27
  signPdsRecord,
28
28
  validatePdsGroupStatement,
29
29
  validatePdsKeyBundle
30
- } from "./chunk-ZOHNXUDY.js";
30
+ } from "./chunk-VWB3VEOL.js";
31
31
 
32
32
  // packages/koed-server/dist/personal-sync.js
33
33
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as createHash2, generateKeyPairSync, randomBytes as randomBytes2, randomUUID as randomUUID2, scryptSync, sign } from "node:crypto";
@@ -12,10 +12,10 @@ import {
12
12
  updateUpstreamBackendRoutePolicy,
13
13
  upstreamBackendAdvertisesCapability,
14
14
  upstreamBackendSupportsTeamMemoryAnswerTasks
15
- } from "./chunk-RCR4XPE3.js";
15
+ } from "./chunk-3VNLZCMB.js";
16
16
  import {
17
17
  isTeamMemoryAnswerTaskCapability
18
- } from "./chunk-ZOHNXUDY.js";
18
+ } from "./chunk-VWB3VEOL.js";
19
19
  import "./chunk-FSNLU46W.js";
20
20
  import "./chunk-BTS4ZTF3.js";
21
21
  export {
@@ -0,0 +1,11 @@
1
+ import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
+ import {
3
+ validateManifestCatalog
4
+ } from "./chunk-IY2HRXOZ.js";
5
+
6
+ // packages/koed-server/dist/component-manifest-catalog-data.js
7
+ var productionComponentManifestCatalog = validateManifestCatalog({ "schemaVersion": 2, "productVersion": "1.2.0", "entries": [{ "component": "base", "manifestSha256": "4ef8f77745b76f102c40465d5be451ec12108d0ed511ed0d2dfe53e0b8880508", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "base", "manifestSha256": "164d6e7c0791b218cc885f5e2d01719f242574e1ab7721fa704b08e558524d4d", "target": { "platform": "macos", "architecture": "arm64" } }, { "component": "privacy", "variant": "cpu", "manifestSha256": "1c19d70c442fce3b9305e63eeed7c9558d38d349dfff8d198fcdaff40044e254", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "privacy", "variant": "cuda", "manifestSha256": "dd5d2ca420974e284d84a0f152e3883d52a4d936672539c5b05697bce0779cde", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "privacy", "manifestSha256": "d8b3fabe90ecb4aa8c179f4628793dd6e775795ec38c4484201b12a3a720787f", "target": { "platform": "macos", "architecture": "arm64" } }] });
8
+
9
+ export {
10
+ productionComponentManifestCatalog
11
+ };
@@ -7,8 +7,8 @@ import {
7
7
  installPrivacyModel,
8
8
  materializePrivacyModelCacheEntry,
9
9
  resolvePrivacyModelPaths
10
- } from "./chunk-4OO6VAU3.js";
11
- import "./chunk-ZOHNXUDY.js";
10
+ } from "./chunk-G54Q5W6M.js";
11
+ import "./chunk-VWB3VEOL.js";
12
12
  import "./chunk-FSNLU46W.js";
13
13
  import "./chunk-BTS4ZTF3.js";
14
14
  export {