@kl-c/matrixos 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -2145,7 +2145,7 @@ var package_default;
2145
2145
  var init_package = __esm(() => {
2146
2146
  package_default = {
2147
2147
  name: "@kl-c/matrixos",
2148
- version: "0.1.22",
2148
+ version: "0.1.24",
2149
2149
  description: "MaTrixOS \u2014 Agentic OS for OpenCode. Personalizable, communicating, self-improving, resilient.",
2150
2150
  main: "./dist/index.js",
2151
2151
  types: "dist/index.d.ts",
@@ -67023,6 +67023,48 @@ var require_src = __commonJS((exports, module2) => {
67023
67023
  module2.exports = { cursor, scroll, erase, beep };
67024
67024
  });
67025
67025
 
67026
+ // packages/omo-opencode/src/cli/config-manager/write-gateway-env.ts
67027
+ import { existsSync as existsSync26, mkdirSync as mkdirSync9, readFileSync as readFileSync15, writeFileSync as writeFileSync6, chmodSync as chmodSync3 } from "fs";
67028
+ import { join as join26 } from "path";
67029
+ function writeGatewayEnvToken(key, token) {
67030
+ const configDir = getConfigDir();
67031
+ if (!existsSync26(configDir))
67032
+ mkdirSync9(configDir, { recursive: true });
67033
+ const envPath = join26(configDir, GATEWAY_ENV_FILENAME);
67034
+ const entries = new Map;
67035
+ if (existsSync26(envPath)) {
67036
+ const existing = readFileSync15(envPath, "utf-8");
67037
+ for (const rawLine of existing.split(`
67038
+ `)) {
67039
+ const line = rawLine.trim();
67040
+ if (line.length === 0 || line.startsWith("#"))
67041
+ continue;
67042
+ const withoutExport = line.replace(/^(export\s+)/i, "");
67043
+ const eqIndex = withoutExport.indexOf("=");
67044
+ if (eqIndex === -1)
67045
+ continue;
67046
+ const k = withoutExport.slice(0, eqIndex).trim();
67047
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(k))
67048
+ continue;
67049
+ entries.set(k, withoutExport.slice(eqIndex + 1).trim());
67050
+ }
67051
+ }
67052
+ entries.set(key, token);
67053
+ const next = [...entries.entries()].map(([k, v]) => `${k}=${v}`).join(`
67054
+ `) + `
67055
+ `;
67056
+ writeFileSync6(envPath, next, { mode: 384 });
67057
+ chmodSync3(envPath, 384);
67058
+ return envPath;
67059
+ }
67060
+ function writeGatewayEnv(token) {
67061
+ return writeGatewayEnvToken("TELEGRAM_BOT_TOKEN", token);
67062
+ }
67063
+ var GATEWAY_ENV_FILENAME = ".klc-gateway.env";
67064
+ var init_write_gateway_env = __esm(() => {
67065
+ init_config_context();
67066
+ });
67067
+
67026
67068
  // node_modules/.bun/zod@4.4.3/node_modules/zod/v4/core/core.js
67027
67069
  function $constructor(name2, initializer, params) {
67028
67070
  function init(inst, def) {
@@ -107521,7 +107563,7 @@ var require_filesystem = __commonJS((exports2, module2) => {
107521
107563
  var LDD_PATH = "/usr/bin/ldd";
107522
107564
  var SELF_PATH = "/proc/self/exe";
107523
107565
  var MAX_LENGTH = 2048;
107524
- var readFileSync44 = (path18) => {
107566
+ var readFileSync45 = (path18) => {
107525
107567
  const fd = fs17.openSync(path18, "r");
107526
107568
  const buffer = Buffer.alloc(MAX_LENGTH);
107527
107569
  const bytesRead = fs17.readSync(fd, buffer, 0, MAX_LENGTH, 0);
@@ -107544,7 +107586,7 @@ var require_filesystem = __commonJS((exports2, module2) => {
107544
107586
  module2.exports = {
107545
107587
  LDD_PATH,
107546
107588
  SELF_PATH,
107547
- readFileSync: readFileSync44,
107589
+ readFileSync: readFileSync45,
107548
107590
  readFile
107549
107591
  };
107550
107592
  });
@@ -107587,7 +107629,7 @@ var require_elf = __commonJS((exports2, module2) => {
107587
107629
  var require_detect_libc = __commonJS((exports2, module2) => {
107588
107630
  var childProcess = __require("child_process");
107589
107631
  var { isLinux, getReport } = require_process();
107590
- var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync44 } = require_filesystem();
107632
+ var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync45 } = require_filesystem();
107591
107633
  var { interpreterPath } = require_elf();
107592
107634
  var cachedFamilyInterpreter;
107593
107635
  var cachedFamilyFilesystem;
@@ -107678,7 +107720,7 @@ var require_detect_libc = __commonJS((exports2, module2) => {
107678
107720
  }
107679
107721
  cachedFamilyFilesystem = null;
107680
107722
  try {
107681
- const lddContent = readFileSync44(LDD_PATH);
107723
+ const lddContent = readFileSync45(LDD_PATH);
107682
107724
  cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
107683
107725
  } catch (e) {}
107684
107726
  return cachedFamilyFilesystem;
@@ -107701,7 +107743,7 @@ var require_detect_libc = __commonJS((exports2, module2) => {
107701
107743
  }
107702
107744
  cachedFamilyInterpreter = null;
107703
107745
  try {
107704
- const selfContent = readFileSync44(SELF_PATH);
107746
+ const selfContent = readFileSync45(SELF_PATH);
107705
107747
  const path18 = interpreterPath(selfContent);
107706
107748
  cachedFamilyInterpreter = familyFromInterpreterPath(path18);
107707
107749
  } catch (e) {}
@@ -107763,7 +107805,7 @@ var require_detect_libc = __commonJS((exports2, module2) => {
107763
107805
  }
107764
107806
  cachedVersionFilesystem = null;
107765
107807
  try {
107766
- const lddContent = readFileSync44(LDD_PATH);
107808
+ const lddContent = readFileSync45(LDD_PATH);
107767
107809
  const versionMatch = lddContent.match(RE_GLIBC_VERSION);
107768
107810
  if (versionMatch) {
107769
107811
  cachedVersionFilesystem = versionMatch[1];
@@ -117579,19 +117621,19 @@ __export(exports_generate, {
117579
117621
  executeGenerateCommand: () => executeGenerateCommand,
117580
117622
  ProfileNotFoundError: () => ProfileNotFoundError
117581
117623
  });
117582
- import { existsSync as existsSync70, readFileSync as readFileSync54, realpathSync as realpathSync10 } from "fs";
117583
- import { dirname as dirname28, isAbsolute as isAbsolute6, join as join75, resolve as resolve16 } from "path";
117624
+ import { existsSync as existsSync70, readFileSync as readFileSync56, realpathSync as realpathSync10 } from "fs";
117625
+ import { dirname as dirname28, isAbsolute as isAbsolute6, join as join76, resolve as resolve16 } from "path";
117584
117626
  function profilesDirFor(opts) {
117585
117627
  if (opts.profilesDir)
117586
117628
  return opts.profilesDir;
117587
117629
  if (opts.cwd)
117588
- return join75(opts.cwd, PROFILES_RELATIVE);
117589
- return join75(REPO_ROOT, PROFILES_RELATIVE);
117630
+ return join76(opts.cwd, PROFILES_RELATIVE);
117631
+ return join76(REPO_ROOT, PROFILES_RELATIVE);
117590
117632
  }
117591
117633
  function loadProfile(name2, options = {}) {
117592
117634
  const fs21 = options.fs ?? defaultFS2;
117593
117635
  const dir = profilesDirFor(options);
117594
- const path27 = join75(dir, `${name2}.json`);
117636
+ const path27 = join76(dir, `${name2}.json`);
117595
117637
  if (!fs21.existsSync(path27)) {
117596
117638
  throw new ProfileNotFoundError(name2);
117597
117639
  }
@@ -117604,7 +117646,7 @@ function listProfiles(options = {}) {
117604
117646
  const known = options.knownNames ?? ["trader", "plumber"];
117605
117647
  const out = [];
117606
117648
  for (const name2 of known) {
117607
- const path27 = join75(dir, `${name2}.json`);
117649
+ const path27 = join76(dir, `${name2}.json`);
117608
117650
  if (fs21.existsSync(path27)) {
117609
117651
  try {
117610
117652
  const raw = JSON.parse(fs21.readFileSync(path27, "utf-8"));
@@ -117677,7 +117719,7 @@ var init_generate = __esm(() => {
117677
117719
  init_src4();
117678
117720
  init_src4();
117679
117721
  REPO_ROOT = resolve16(dirname28(new URL(import.meta.url).pathname), "..", "..", "..", "..", "..");
117680
- defaultFS2 = { existsSync: existsSync70, readFileSync: readFileSync54, realpathSync: realpathSync10 };
117722
+ defaultFS2 = { existsSync: existsSync70, readFileSync: readFileSync56, realpathSync: realpathSync10 };
117681
117723
  ProfileNotFoundError = class ProfileNotFoundError extends Error {
117682
117724
  profileName;
117683
117725
  constructor(profileName) {
@@ -117829,8 +117871,8 @@ var exports_profile_resolve = {};
117829
117871
  __export(exports_profile_resolve, {
117830
117872
  executeProfileResolveCommand: () => executeProfileResolveCommand
117831
117873
  });
117832
- import { existsSync as existsSync72, readdirSync as readdirSync15, readFileSync as readFileSync55 } from "fs";
117833
- import { join as join77, resolve as resolve17, dirname as dirname29 } from "path";
117874
+ import { existsSync as existsSync72, readdirSync as readdirSync15, readFileSync as readFileSync57 } from "fs";
117875
+ import { join as join78, resolve as resolve17, dirname as dirname29 } from "path";
117834
117876
  function executeProfileResolveCommand(args) {
117835
117877
  if (args.options.help) {
117836
117878
  return {
@@ -117855,7 +117897,7 @@ function executeProfileResolveCommand(args) {
117855
117897
  ` };
117856
117898
  }
117857
117899
  const name2 = nameRaw.endsWith(".json") ? nameRaw.slice(0, -5) : nameRaw;
117858
- const profilesDir = join77(REPO_ROOT2, PROFILES_RELATIVE2);
117900
+ const profilesDir = join78(REPO_ROOT2, PROFILES_RELATIVE2);
117859
117901
  if (!existsSync72(profilesDir)) {
117860
117902
  return { exitCode: 1, stdout: `error: profiles directory not found at ${profilesDir}
117861
117903
  ` };
@@ -117875,8 +117917,8 @@ function executeProfileResolveCommand(args) {
117875
117917
  const registry2 = {};
117876
117918
  for (const file3 of profileFiles) {
117877
117919
  try {
117878
- const filePath = join77(profilesDir, file3);
117879
- const raw = JSON.parse(readFileSync55(filePath, "utf-8"));
117920
+ const filePath = join78(profilesDir, file3);
117921
+ const raw = JSON.parse(readFileSync57(filePath, "utf-8"));
117880
117922
  const profile2 = ProfileSchema.parse(raw);
117881
117923
  registry2[profile2.name] = profile2;
117882
117924
  } catch {}
@@ -117938,8 +117980,8 @@ __export(exports_export, {
117938
117980
  getShell: () => getShell,
117939
117981
  executeExportCommand: () => executeExportCommand
117940
117982
  });
117941
- import { existsSync as existsSync73, readFileSync as readFileSync56, writeFileSync as writeFileSync25, copyFileSync as copyFileSync7, realpathSync as realpathSync11, mkdirSync as mkdirSync26 } from "fs";
117942
- import { isAbsolute as isAbsolute7, join as join78, resolve as resolve18, dirname as dirname30 } from "path";
117983
+ import { existsSync as existsSync73, readFileSync as readFileSync58, writeFileSync as writeFileSync25, copyFileSync as copyFileSync7, realpathSync as realpathSync11, mkdirSync as mkdirSync26 } from "fs";
117984
+ import { isAbsolute as isAbsolute7, join as join79, resolve as resolve18, dirname as dirname30 } from "path";
117943
117985
  import { spawnSync as spawnSync3 } from "child_process";
117944
117986
  function setShell(shell) {
117945
117987
  activeShell = shell;
@@ -117980,7 +118022,7 @@ function executeExportCommand(args) {
117980
118022
  return { exitCode: 1, stdout: `error: generate failed: ${message}
117981
118023
  ` };
117982
118024
  }
117983
- const pkgPath = join78(absoluteTargetDir, "package.json");
118025
+ const pkgPath = join79(absoluteTargetDir, "package.json");
117984
118026
  let pkg;
117985
118027
  try {
117986
118028
  pkg = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
@@ -118020,7 +118062,7 @@ ${packResult.stdout}
118020
118062
  return { exitCode: 1, stdout: `error: npm pack produced no tarball name in output
118021
118063
  ` };
118022
118064
  }
118023
- let tgzPath = join78(absoluteTargetDir, tgzName);
118065
+ let tgzPath = join79(absoluteTargetDir, tgzName);
118024
118066
  if (args.options.output) {
118025
118067
  const outputPath = args.options.output;
118026
118068
  const absoluteOutput = isAbsolute7(outputPath) ? outputPath : resolve18(process.cwd(), outputPath);
@@ -118062,7 +118104,7 @@ var init_export = __esm(() => {
118062
118104
  activeShell = defaultShell;
118063
118105
  defaultExportFS = {
118064
118106
  existsSync: existsSync73,
118065
- readFileSync: readFileSync56,
118107
+ readFileSync: readFileSync58,
118066
118108
  writeFileSync: writeFileSync25,
118067
118109
  copyFileSync: copyFileSync7,
118068
118110
  realpathSync: realpathSync11,
@@ -118070,6 +118112,107 @@ var init_export = __esm(() => {
118070
118112
  };
118071
118113
  });
118072
118114
 
118115
+ // packages/omo-opencode/src/cli/gateway-set-token.ts
118116
+ var exports_gateway_set_token = {};
118117
+ __export(exports_gateway_set_token, {
118118
+ executeGatewaySetTokenCommand: () => executeGatewaySetTokenCommand
118119
+ });
118120
+ function isValidType(type2) {
118121
+ return VALID_TYPES.includes(type2);
118122
+ }
118123
+ async function readMaskedToken(prompt) {
118124
+ return new Promise((resolve19, reject) => {
118125
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
118126
+ reject(new Error("Interactive mode requires a TTY. Use --token <value> instead."));
118127
+ return;
118128
+ }
118129
+ process.stdout.write(prompt);
118130
+ process.stdin.setRawMode(true);
118131
+ process.stdin.resume();
118132
+ process.stdin.setEncoding("utf8");
118133
+ let token = "";
118134
+ const onData = (data) => {
118135
+ const chunk = typeof data === "string" ? data : data.toString("utf8");
118136
+ for (const char of chunk) {
118137
+ const code = char.charCodeAt(0);
118138
+ if (code === 13 || code === 10) {
118139
+ process.stdout.write(`
118140
+ `);
118141
+ process.stdin.setRawMode(false);
118142
+ process.stdin.pause();
118143
+ process.stdin.off("data", onData);
118144
+ resolve19(token);
118145
+ return;
118146
+ }
118147
+ if (code === 127 || code === 8) {
118148
+ if (token.length > 0) {
118149
+ token = token.slice(0, -1);
118150
+ process.stdout.write("\b \b");
118151
+ }
118152
+ continue;
118153
+ }
118154
+ if (code === 3) {
118155
+ process.stdin.setRawMode(false);
118156
+ process.stdin.pause();
118157
+ process.stdin.off("data", onData);
118158
+ process.stdout.write(`
118159
+ `);
118160
+ reject(new Error("Cancelled."));
118161
+ return;
118162
+ }
118163
+ if (code >= 32) {
118164
+ token += char;
118165
+ }
118166
+ }
118167
+ };
118168
+ process.stdin.on("data", onData);
118169
+ });
118170
+ }
118171
+ async function executeGatewaySetTokenCommand(args) {
118172
+ const type2 = args.options.type;
118173
+ if (!isValidType(type2)) {
118174
+ return {
118175
+ exitCode: 1,
118176
+ stdout: `error: invalid type "${type2}". Valid types: ${VALID_TYPES.join(", ")}
118177
+ `
118178
+ };
118179
+ }
118180
+ let token;
118181
+ if (args.options.interactive || !args.options.token) {
118182
+ try {
118183
+ token = await readMaskedToken(`Token ${type2} bot: `);
118184
+ } catch (err) {
118185
+ const message = err instanceof Error ? err.message : String(err);
118186
+ return { exitCode: 1, stdout: `error: ${message}
118187
+ ` };
118188
+ }
118189
+ } else {
118190
+ token = args.options.token;
118191
+ }
118192
+ if (!token || token.length === 0) {
118193
+ return { exitCode: 1, stdout: `error: token is required
118194
+ ` };
118195
+ }
118196
+ try {
118197
+ const envPath = writeGatewayEnvToken(TYPE_TO_KEY[type2], token);
118198
+ return { exitCode: 0, stdout: `${envPath}
118199
+ ` };
118200
+ } catch (err) {
118201
+ const message = err instanceof Error ? err.message : String(err);
118202
+ return { exitCode: 1, stdout: `error: ${message}
118203
+ ` };
118204
+ }
118205
+ }
118206
+ var VALID_TYPES, TYPE_TO_KEY;
118207
+ var init_gateway_set_token = __esm(() => {
118208
+ init_write_gateway_env();
118209
+ VALID_TYPES = ["telegram", "discord"];
118210
+ TYPE_TO_KEY = {
118211
+ telegram: "TELEGRAM_BOT_TOKEN",
118212
+ discord: "DISCORD_BOT_TOKEN"
118213
+ };
118214
+ });
118215
+
118073
118216
  // packages/omo-opencode/src/cli/rgpd-command.ts
118074
118217
  var exports_rgpd_command = {};
118075
118218
  __export(exports_rgpd_command, {
@@ -120669,24 +120812,9 @@ var i2 = `${styleText2("gray", S_BAR)} `;
120669
120812
  // packages/omo-opencode/src/cli/tui-installer.ts
120670
120813
  init_shared();
120671
120814
  init_config_manager();
120815
+ init_write_gateway_env();
120672
120816
  var import_picocolors4 = __toESM(require_picocolors(), 1);
120673
120817
 
120674
- // packages/omo-opencode/src/cli/config-manager/write-gateway-env.ts
120675
- init_config_context();
120676
- import { existsSync as existsSync26, mkdirSync as mkdirSync9, writeFileSync as writeFileSync6, chmodSync as chmodSync3 } from "fs";
120677
- import { join as join26 } from "path";
120678
- var GATEWAY_ENV_FILENAME = ".klc-gateway.env";
120679
- function writeGatewayEnv(token) {
120680
- const configDir = getConfigDir();
120681
- if (!existsSync26(configDir))
120682
- mkdirSync9(configDir, { recursive: true });
120683
- const envPath = join26(configDir, GATEWAY_ENV_FILENAME);
120684
- writeFileSync6(envPath, `TELEGRAM_BOT_TOKEN=${token}
120685
- `, { mode: 384 });
120686
- chmodSync3(envPath, 384);
120687
- return envPath;
120688
- }
120689
-
120690
120818
  // packages/omo-opencode/src/cli/tui-install-prompts.ts
120691
120819
  init_model_fallback();
120692
120820
 
@@ -122088,6 +122216,13 @@ init_zod();
122088
122216
  var CronConfigSchema = exports_external.object({
122089
122217
  enabled: exports_external.boolean().default(true)
122090
122218
  }).strict();
122219
+ // packages/omo-opencode/src/config/schema/dashboard.ts
122220
+ init_zod();
122221
+ var DashboardConfigSchema = exports_external.object({
122222
+ enabled: exports_external.boolean().optional(),
122223
+ port: exports_external.number().int().min(1).max(65535).optional(),
122224
+ gateway_passphrase: exports_external.string().optional()
122225
+ });
122091
122226
  // packages/omo-opencode/src/config/schema/default-mode.ts
122092
122227
  init_zod();
122093
122228
  var DefaultModeConfigSchema = exports_external.object({
@@ -122595,6 +122730,7 @@ var OhMyOpenCodeConfigSchema = exports_external.object({
122595
122730
  morpheus: MorpheusConfigSchema.optional(),
122596
122731
  start_work: StartWorkConfigSchema.optional(),
122597
122732
  gateway: GatewayConfigSectionSchema,
122733
+ dashboard: DashboardConfigSchema.optional(),
122598
122734
  watchdog: WatchdogConfigSchema.optional(),
122599
122735
  egress: EgressConfigSectionSchema,
122600
122736
  cron: CronConfigSchema.optional(),
@@ -123474,7 +123610,7 @@ var BOULDER_STATE_PATH = `${BOULDER_DIR}/${BOULDER_FILE}`;
123474
123610
  var NOTEPAD_DIR = "notepads";
123475
123611
  var NOTEPAD_BASE_PATH = `${BOULDER_DIR}/${NOTEPAD_DIR}`;
123476
123612
  // packages/boulder-state/src/top-level-task.ts
123477
- import { existsSync as existsSync30, readFileSync as readFileSync16 } from "fs";
123613
+ import { existsSync as existsSync30, readFileSync as readFileSync17 } from "fs";
123478
123614
  var TODO_HEADING_PATTERN = /^##\s+TODOs\b/i;
123479
123615
  var FINAL_VERIFICATION_HEADING_PATTERN = /^##\s+Final Verification Wave\b/i;
123480
123616
  var SECOND_LEVEL_HEADING_PATTERN = /^##\s+/;
@@ -123501,7 +123637,7 @@ function readCurrentTopLevelTask(planPath) {
123501
123637
  return null;
123502
123638
  }
123503
123639
  try {
123504
- const content = readFileSync16(planPath, "utf-8");
123640
+ const content = readFileSync17(planPath, "utf-8");
123505
123641
  const lines = content.split(/\r?\n/);
123506
123642
  let section = "other";
123507
123643
  for (const line of lines) {
@@ -123553,7 +123689,7 @@ function resolveBoulderPlanPathForWork(directory, work) {
123553
123689
  return resolveBoulderPlanPath(directory, work);
123554
123690
  }
123555
123691
  // packages/boulder-state/src/storage/plan-progress.ts
123556
- import { existsSync as existsSync32, readFileSync as readFileSync17, readdirSync as readdirSync4, statSync as statSync5 } from "fs";
123692
+ import { existsSync as existsSync32, readFileSync as readFileSync18, readdirSync as readdirSync4, statSync as statSync5 } from "fs";
123557
123693
  var TODO_HEADING_PATTERN2 = /^##\s+TODOs\b/i;
123558
123694
  var FINAL_VERIFICATION_HEADING_PATTERN2 = /^##\s+Final Verification Wave\b/i;
123559
123695
  var SECOND_LEVEL_HEADING_PATTERN2 = /^##\s+/;
@@ -123566,7 +123702,7 @@ function getPlanProgress(planPath) {
123566
123702
  return { total: 0, completed: 0, isComplete: false };
123567
123703
  }
123568
123704
  try {
123569
- const content = readFileSync17(planPath, "utf-8");
123705
+ const content = readFileSync18(planPath, "utf-8");
123570
123706
  const lines = content.split(/\r?\n/);
123571
123707
  const hasStructuredSections = lines.some((line) => TODO_HEADING_PATTERN2.test(line) || FINAL_VERIFICATION_HEADING_PATTERN2.test(line));
123572
123708
  if (hasStructuredSections) {
@@ -123682,14 +123818,14 @@ function selectMirrorWork(state) {
123682
123818
  return sorted[0] ?? null;
123683
123819
  }
123684
123820
  // packages/boulder-state/src/storage/read-state.ts
123685
- import { existsSync as existsSync33, readFileSync as readFileSync18 } from "fs";
123821
+ import { existsSync as existsSync33, readFileSync as readFileSync19 } from "fs";
123686
123822
  function readBoulderState(directory) {
123687
123823
  const filePath = getBoulderFilePath(directory);
123688
123824
  if (!existsSync33(filePath)) {
123689
123825
  return null;
123690
123826
  }
123691
123827
  try {
123692
- const content = readFileSync18(filePath, "utf-8");
123828
+ const content = readFileSync19(filePath, "utf-8");
123693
123829
  const parsed = JSON.parse(content);
123694
123830
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
123695
123831
  return null;
@@ -123755,7 +123891,7 @@ init_state();
123755
123891
  // packages/omo-opencode/src/features/run-continuation-state/constants.ts
123756
123892
  var CONTINUATION_MARKER_DIR = ".omo/run-continuation";
123757
123893
  // packages/omo-opencode/src/features/run-continuation-state/storage.ts
123758
- import { existsSync as existsSync34, mkdirSync as mkdirSync11, readFileSync as readFileSync19, rmSync as rmSync2, writeFileSync as writeFileSync8 } from "fs";
123894
+ import { existsSync as existsSync34, mkdirSync as mkdirSync11, readFileSync as readFileSync20, rmSync as rmSync2, writeFileSync as writeFileSync8 } from "fs";
123759
123895
  import { join as join30 } from "path";
123760
123896
  function getMarkerPath(directory, sessionID) {
123761
123897
  return join30(directory, CONTINUATION_MARKER_DIR, `${sessionID}.json`);
@@ -123765,7 +123901,7 @@ function readContinuationMarker(directory, sessionID) {
123765
123901
  if (!existsSync34(markerPath))
123766
123902
  return null;
123767
123903
  try {
123768
- const raw = readFileSync19(markerPath, "utf-8");
123904
+ const raw = readFileSync20(markerPath, "utf-8");
123769
123905
  const parsed = JSON.parse(raw);
123770
123906
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
123771
123907
  return null;
@@ -123830,7 +123966,7 @@ async function isSessionInBoulderLineage(input) {
123830
123966
  // packages/omo-opencode/src/hooks/the-operator/session-last-agent.ts
123831
123967
  init_shared();
123832
123968
  init_compaction_marker();
123833
- import { readFileSync as readFileSync20, readdirSync as readdirSync5 } from "fs";
123969
+ import { readFileSync as readFileSync21, readdirSync as readdirSync5 } from "fs";
123834
123970
  import { join as join31 } from "path";
123835
123971
  var defaultSessionLastAgentDeps = {
123836
123972
  getMessageDir,
@@ -123891,7 +124027,7 @@ async function getLastAgentFromSession(sessionID, client3, deps = {}) {
123891
124027
  try {
123892
124028
  const messages = readdirSync5(messageDir).filter((fileName) => fileName.endsWith(".json")).map((fileName) => {
123893
124029
  try {
123894
- const content = readFileSync20(join31(messageDir, fileName), "utf-8");
124030
+ const content = readFileSync21(join31(messageDir, fileName), "utf-8");
123895
124031
  const parsed = JSON.parse(content);
123896
124032
  return {
123897
124033
  fileName,
@@ -123934,7 +124070,7 @@ init_agent_display_names();
123934
124070
 
123935
124071
  // packages/omo-opencode/src/hooks/ralph-loop/storage.ts
123936
124072
  init_frontmatter2();
123937
- import { existsSync as existsSync35, readFileSync as readFileSync21, writeFileSync as writeFileSync9, unlinkSync as unlinkSync5, mkdirSync as mkdirSync12 } from "fs";
124073
+ import { existsSync as existsSync35, readFileSync as readFileSync22, writeFileSync as writeFileSync9, unlinkSync as unlinkSync5, mkdirSync as mkdirSync12 } from "fs";
123938
124074
  import { dirname as dirname12, join as join32 } from "path";
123939
124075
 
123940
124076
  // packages/omo-opencode/src/hooks/ralph-loop/constants.ts
@@ -123952,7 +124088,7 @@ function readState(directory, customPath) {
123952
124088
  return null;
123953
124089
  }
123954
124090
  try {
123955
- const content = readFileSync21(filePath, "utf-8");
124091
+ const content = readFileSync22(filePath, "utf-8");
123956
124092
  const { data, body } = parseFrontmatter(content);
123957
124093
  const active = data.active;
123958
124094
  const iteration = data.iteration;
@@ -124527,7 +124663,7 @@ function createTimestampedStdoutController(stdout2 = process.stdout) {
124527
124663
  // packages/telemetry-core/src/activity-state.ts
124528
124664
  init_atomic_write();
124529
124665
  init_xdg_data_dir();
124530
- import { existsSync as existsSync36, mkdirSync as mkdirSync13, readFileSync as readFileSync22 } from "fs";
124666
+ import { existsSync as existsSync36, mkdirSync as mkdirSync13, readFileSync as readFileSync23 } from "fs";
124531
124667
  import { basename as basename6, join as join33 } from "path";
124532
124668
  var POSTHOG_ACTIVITY_STATE_FILE = "posthog-activity.json";
124533
124669
  function resolveTelemetryStateDir(product, options = {}) {
@@ -124571,7 +124707,7 @@ function readPostHogActivityState(stateDir, diagnostics) {
124571
124707
  return {};
124572
124708
  }
124573
124709
  try {
124574
- const stateContent = readFileSync22(stateFilePath, "utf-8");
124710
+ const stateContent = readFileSync23(stateFilePath, "utf-8");
124575
124711
  const stateJson = JSON.parse(stateContent);
124576
124712
  if (!isPostHogActivityState(stateJson)) {
124577
124713
  return {};
@@ -131690,7 +131826,7 @@ async function getLocalVersion(options = {}) {
131690
131826
  }
131691
131827
  }
131692
131828
  // packages/omo-opencode/src/cli/doctor/checks/system.ts
131693
- import { existsSync as existsSync47, readFileSync as readFileSync32 } from "fs";
131829
+ import { existsSync as existsSync47, readFileSync as readFileSync33 } from "fs";
131694
131830
 
131695
131831
  // packages/omo-opencode/src/cli/doctor/checks/system-binary.ts
131696
131832
  init_extract_semver();
@@ -131886,7 +132022,7 @@ function compareVersions3(current, minimum) {
131886
132022
 
131887
132023
  // packages/omo-opencode/src/cli/doctor/checks/system-plugin.ts
131888
132024
  init_shared();
131889
- import { existsSync as existsSync45, readFileSync as readFileSync30 } from "fs";
132025
+ import { existsSync as existsSync45, readFileSync as readFileSync31 } from "fs";
131890
132026
  function detectConfigPath() {
131891
132027
  const paths2 = getOpenCodeConfigPaths({ binary: "opencode", version: null });
131892
132028
  if (existsSync45(paths2.configJsonc))
@@ -131937,7 +132073,7 @@ function getPluginInfo() {
131937
132073
  };
131938
132074
  }
131939
132075
  try {
131940
- const content = readFileSync30(configPath, "utf-8");
132076
+ const content = readFileSync31(configPath, "utf-8");
131941
132077
  const parsedConfig = parseJsonc(content);
131942
132078
  const pluginEntry = findPluginEntry2(parsedConfig.plugin ?? []);
131943
132079
  if (!pluginEntry) {
@@ -131979,7 +132115,7 @@ init_file_utils2();
131979
132115
  init_checker();
131980
132116
  init_auto_update_checker();
131981
132117
  init_package_json_locator();
131982
- import { existsSync as existsSync46, readFileSync as readFileSync31, readdirSync as readdirSync7 } from "fs";
132118
+ import { existsSync as existsSync46, readFileSync as readFileSync32, readdirSync as readdirSync7 } from "fs";
131983
132119
  import { createRequire as createRequire2 } from "module";
131984
132120
  import { homedir as homedir11 } from "os";
131985
132121
  import { join as join41 } from "path";
@@ -132011,7 +132147,7 @@ function readPackageJson(filePath) {
132011
132147
  if (!existsSync46(filePath))
132012
132148
  return null;
132013
132149
  try {
132014
- const content = readFileSync31(filePath, "utf-8");
132150
+ const content = readFileSync32(filePath, "utf-8");
132015
132151
  return parseJsonc(content);
132016
132152
  } catch (error51) {
132017
132153
  if (!(error51 instanceof Error)) {
@@ -132145,7 +132281,7 @@ var defaultDeps6 = {
132145
132281
  getLatestPluginVersion,
132146
132282
  getSuggestedInstallTag,
132147
132283
  configExists: existsSync47,
132148
- readConfigFile: (path14) => readFileSync32(path14, "utf-8"),
132284
+ readConfigFile: (path14) => readFileSync33(path14, "utf-8"),
132149
132285
  parseConfigContent: (content) => parseJsonc(content)
132150
132286
  };
132151
132287
  var BUN_POSTINSTALL_HELPER_PACKAGE_NAME = "@code-yeongyu/comment-checker";
@@ -132290,7 +132426,7 @@ async function checkSystem(deps = defaultDeps6) {
132290
132426
 
132291
132427
  // packages/omo-opencode/src/config/validate.ts
132292
132428
  init_src();
132293
- import { readFileSync as readFileSync33 } from "fs";
132429
+ import { readFileSync as readFileSync34 } from "fs";
132294
132430
  import { homedir as homedir12 } from "os";
132295
132431
  import { dirname as dirname18, relative as relative5 } from "path";
132296
132432
  init_shared();
@@ -132335,7 +132471,7 @@ function schemaMessages(configPath, rawConfig) {
132335
132471
  }
132336
132472
  function parseLayerConfig(configPath) {
132337
132473
  try {
132338
- const content = readFileSync33(configPath, "utf-8");
132474
+ const content = readFileSync34(configPath, "utf-8");
132339
132475
  const rawConfig = parseJsonc(content);
132340
132476
  if (!isPlainRecord(rawConfig)) {
132341
132477
  return {
@@ -132404,7 +132540,7 @@ function validatePluginConfig(directory) {
132404
132540
 
132405
132541
  // packages/omo-opencode/src/cli/doctor/checks/model-resolution-cache.ts
132406
132542
  init_shared();
132407
- import { existsSync as existsSync48, readFileSync as readFileSync34 } from "fs";
132543
+ import { existsSync as existsSync48, readFileSync as readFileSync35 } from "fs";
132408
132544
  import { homedir as homedir13 } from "os";
132409
132545
  import { join as join42 } from "path";
132410
132546
  function getUserConfigDir2() {
@@ -132423,7 +132559,7 @@ function loadCustomProviderNames() {
132423
132559
  if (!existsSync48(configPath))
132424
132560
  continue;
132425
132561
  try {
132426
- const content = readFileSync34(configPath, "utf-8");
132562
+ const content = readFileSync35(configPath, "utf-8");
132427
132563
  const data = parseJsonc(content);
132428
132564
  if (data?.provider && typeof data.provider === "object") {
132429
132565
  return Object.keys(data.provider);
@@ -132447,7 +132583,7 @@ function loadAvailableModelsFromCache() {
132447
132583
  return { providers: [], modelCount: 0, cacheExists: false };
132448
132584
  }
132449
132585
  try {
132450
- const content = readFileSync34(cacheFile, "utf-8");
132586
+ const content = readFileSync35(cacheFile, "utf-8");
132451
132587
  const data = parseJsonc(content);
132452
132588
  const cacheProviders = Object.keys(data);
132453
132589
  let modelCount = 0;
@@ -132474,7 +132610,7 @@ init_model_capabilities2();
132474
132610
  // packages/omo-opencode/src/cli/doctor/checks/model-resolution-config.ts
132475
132611
  init_shared();
132476
132612
  init_plugin_identity();
132477
- import { readFileSync as readFileSync35 } from "fs";
132613
+ import { readFileSync as readFileSync36 } from "fs";
132478
132614
  import { join as join43 } from "path";
132479
132615
  var PROJECT_CONFIG_DIR = join43(process.cwd(), ".opencode");
132480
132616
  function loadOmoConfig() {
@@ -132484,7 +132620,7 @@ function loadOmoConfig() {
132484
132620
  });
132485
132621
  if (projectDetected.format !== "none") {
132486
132622
  try {
132487
- const content = readFileSync35(projectDetected.path, "utf-8");
132623
+ const content = readFileSync36(projectDetected.path, "utf-8");
132488
132624
  return parseJsonc(content);
132489
132625
  } catch (error51) {
132490
132626
  if (error51 instanceof Error) {
@@ -132500,7 +132636,7 @@ function loadOmoConfig() {
132500
132636
  });
132501
132637
  if (userDetected.format !== "none") {
132502
132638
  try {
132503
- const content = readFileSync35(userDetected.path, "utf-8");
132639
+ const content = readFileSync36(userDetected.path, "utf-8");
132504
132640
  return parseJsonc(content);
132505
132641
  } catch (error51) {
132506
132642
  if (error51 instanceof Error) {
@@ -133081,13 +133217,13 @@ async function getGhCliInfo(dependencies = {}) {
133081
133217
  }
133082
133218
 
133083
133219
  // packages/omo-opencode/src/cli/doctor/checks/tools-lsp.ts
133084
- import { readFileSync as readFileSync37 } from "fs";
133220
+ import { readFileSync as readFileSync38 } from "fs";
133085
133221
  import { join as join47 } from "path";
133086
133222
 
133087
133223
  // packages/omo-opencode/src/mcp/lsp.ts
133088
133224
  init_zod();
133089
133225
  init_opencode_config_dir();
133090
- import { existsSync as existsSync50, readFileSync as readFileSync36 } from "fs";
133226
+ import { existsSync as existsSync50, readFileSync as readFileSync37 } from "fs";
133091
133227
  import { delimiter as delimiter3, dirname as dirname20, resolve as resolve10 } from "path";
133092
133228
  import { fileURLToPath as fileURLToPath6 } from "url";
133093
133229
 
@@ -133231,7 +133367,7 @@ function findBootstrapRoot(candidates, pathExists) {
133231
133367
  }
133232
133368
  function readDaemonPackageVersion(root) {
133233
133369
  try {
133234
- const packageJson = JSON.parse(readFileSync36(resolve10(root, PACKAGE_REL, "package.json"), "utf-8"));
133370
+ const packageJson = JSON.parse(readFileSync37(resolve10(root, PACKAGE_REL, "package.json"), "utf-8"));
133235
133371
  return DaemonPackageSchema.parse(packageJson).version;
133236
133372
  } catch (error51) {
133237
133373
  if (!(error51 instanceof Error))
@@ -133308,7 +133444,7 @@ function readOmoConfig(configDirectory) {
133308
133444
  return null;
133309
133445
  }
133310
133446
  try {
133311
- const content = readFileSync37(detected.path, "utf-8");
133447
+ const content = readFileSync38(detected.path, "utf-8");
133312
133448
  return parseJsonc(content);
133313
133449
  } catch (error51) {
133314
133450
  if (!(error51 instanceof Error)) {
@@ -133338,7 +133474,7 @@ function getInstalledLspServers(options = {}) {
133338
133474
 
133339
133475
  // packages/omo-opencode/src/cli/doctor/checks/tools-mcp.ts
133340
133476
  init_shared();
133341
- import { existsSync as existsSync51, readFileSync as readFileSync38 } from "fs";
133477
+ import { existsSync as existsSync51, readFileSync as readFileSync39 } from "fs";
133342
133478
  import { homedir as homedir16 } from "os";
133343
133479
  import { join as join48 } from "path";
133344
133480
  var BUILTIN_MCP_SERVERS = ["websearch", "context7", "grep_app", "lsp"];
@@ -133355,7 +133491,7 @@ function loadUserMcpConfig() {
133355
133491
  if (!existsSync51(configPath))
133356
133492
  continue;
133357
133493
  try {
133358
- const content = readFileSync38(configPath, "utf-8");
133494
+ const content = readFileSync39(configPath, "utf-8");
133359
133495
  const config4 = parseJsonc(content);
133360
133496
  if (config4.mcpServers) {
133361
133497
  Object.assign(servers, config4.mcpServers);
@@ -133489,7 +133625,7 @@ async function checkTools() {
133489
133625
  }
133490
133626
 
133491
133627
  // packages/omo-opencode/src/cli/doctor/checks/telemetry.ts
133492
- import { existsSync as existsSync52, readFileSync as readFileSync39 } from "fs";
133628
+ import { existsSync as existsSync52, readFileSync as readFileSync40 } from "fs";
133493
133629
  function isTelemetryState(value) {
133494
133630
  return value !== null && typeof value === "object" && !Array.isArray(value);
133495
133631
  }
@@ -133499,7 +133635,7 @@ function readLastActiveDay(stateFilePath) {
133499
133635
  }
133500
133636
  let parsed;
133501
133637
  try {
133502
- parsed = JSON.parse(readFileSync39(stateFilePath, "utf-8"));
133638
+ parsed = JSON.parse(readFileSync40(stateFilePath, "utf-8"));
133503
133639
  } catch (error51) {
133504
133640
  if (error51 instanceof Error) {
133505
133641
  return "unreadable";
@@ -133574,7 +133710,7 @@ function expandHomeDirectory(directoryPath) {
133574
133710
  // packages/omo-opencode/src/cli/doctor/checks/team-mode.ts
133575
133711
  init_shared();
133576
133712
  init_plugin_identity();
133577
- import { readFileSync as readFileSync40, promises as fs14 } from "fs";
133713
+ import { readFileSync as readFileSync41, promises as fs14 } from "fs";
133578
133714
  import path15 from "path";
133579
133715
  async function checkTeamMode() {
133580
133716
  const config4 = loadTeamModeConfig();
@@ -133611,7 +133747,7 @@ function loadTeamModeConfig() {
133611
133747
  if (!configPath)
133612
133748
  return { team_mode: undefined };
133613
133749
  try {
133614
- return parseJsonc(readFileSync40(configPath, "utf-8"));
133750
+ return parseJsonc(readFileSync41(configPath, "utf-8"));
133615
133751
  } catch (error51) {
133616
133752
  if (error51 instanceof Error) {
133617
133753
  return { team_mode: undefined };
@@ -134043,7 +134179,7 @@ import {
134043
134179
  existsSync as existsSync55,
134044
134180
  mkdirSync as mkdirSync15,
134045
134181
  readdirSync as readdirSync8,
134046
- readFileSync as readFileSync42,
134182
+ readFileSync as readFileSync43,
134047
134183
  renameSync as renameSync7,
134048
134184
  unlinkSync as unlinkSync8,
134049
134185
  writeFileSync as writeFileSync13
@@ -134076,7 +134212,7 @@ function getOpenCodeCliConfigDir(env2 = process.env) {
134076
134212
  }
134077
134213
 
134078
134214
  // packages/mcp-client-core/src/mcp-oauth/storage-index.ts
134079
- import { chmodSync as chmodSync4, existsSync as existsSync54, readFileSync as readFileSync41, renameSync as renameSync6, writeFileSync as writeFileSync12 } from "fs";
134215
+ import { chmodSync as chmodSync4, existsSync as existsSync54, readFileSync as readFileSync42, renameSync as renameSync6, writeFileSync as writeFileSync12 } from "fs";
134080
134216
  import { join as join50 } from "path";
134081
134217
  var INDEX_FILE_NAME = "index.json";
134082
134218
  function isTokenIndex(value) {
@@ -134092,7 +134228,7 @@ function readTokenIndex(storageDir) {
134092
134228
  if (!existsSync54(indexPath))
134093
134229
  return {};
134094
134230
  try {
134095
- const parsed = JSON.parse(readFileSync41(indexPath, "utf-8"));
134231
+ const parsed = JSON.parse(readFileSync42(indexPath, "utf-8"));
134096
134232
  return isTokenIndex(parsed) ? parsed : {};
134097
134233
  } catch (readError) {
134098
134234
  if (!(readError instanceof Error))
@@ -134202,7 +134338,7 @@ function readTokenFile(filePath) {
134202
134338
  if (!existsSync55(filePath))
134203
134339
  return null;
134204
134340
  try {
134205
- const parsed = JSON.parse(readFileSync42(filePath, "utf-8"));
134341
+ const parsed = JSON.parse(readFileSync43(filePath, "utf-8"));
134206
134342
  return isOAuthTokenData(parsed) ? parsed : null;
134207
134343
  } catch (readError) {
134208
134344
  if (!(readError instanceof Error))
@@ -134215,7 +134351,7 @@ function readLegacyStore() {
134215
134351
  if (!existsSync55(filePath))
134216
134352
  return null;
134217
134353
  try {
134218
- const parsed = JSON.parse(readFileSync42(filePath, "utf-8"));
134354
+ const parsed = JSON.parse(readFileSync43(filePath, "utf-8"));
134219
134355
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
134220
134356
  return null;
134221
134357
  const result = {};
@@ -135028,7 +135164,7 @@ function createEmbeddingPort() {
135028
135164
  // packages/learning-loop/src/codebase-scanner.ts
135029
135165
  var import_picomatch = __toESM(require_picomatch2(), 1);
135030
135166
  import { createHash as createHash5 } from "crypto";
135031
- import { readdirSync as readdirSync9, readFileSync as readFileSync44, statSync as statSync7, existsSync as existsSync57 } from "fs";
135167
+ import { readdirSync as readdirSync9, readFileSync as readFileSync45, statSync as statSync7, existsSync as existsSync57 } from "fs";
135032
135168
  import { join as join52, relative as relative6, extname as extname3 } from "path";
135033
135169
  var EXT_TO_LANG = {
135034
135170
  ts: "typescript",
@@ -135096,7 +135232,7 @@ function defaultFs() {
135096
135232
  return readdirSync9(path18);
135097
135233
  },
135098
135234
  readFile(path18) {
135099
- return readFileSync44(path18, "utf-8");
135235
+ return readFileSync45(path18, "utf-8");
135100
135236
  },
135101
135237
  stat(path18) {
135102
135238
  const s = statSync7(path18);
@@ -135449,7 +135585,7 @@ function formatSearchResults(result) {
135449
135585
  }
135450
135586
 
135451
135587
  // packages/learning-loop/src/improvement.ts
135452
- import { existsSync as existsSync58, mkdirSync as mkdirSync17, readFileSync as readFileSync45, writeFileSync as writeFileSync15 } from "fs";
135588
+ import { existsSync as existsSync58, mkdirSync as mkdirSync17, readFileSync as readFileSync46, writeFileSync as writeFileSync15 } from "fs";
135453
135589
  import { join as join53, basename as basename10 } from "path";
135454
135590
  function createImprovementStore(improvementsDir) {
135455
135591
  if (!existsSync58(improvementsDir)) {
@@ -135476,7 +135612,7 @@ function createImprovementStore(improvementsDir) {
135476
135612
  function get(id) {
135477
135613
  const filePath = join53(improvementsDir, `${id}.json`);
135478
135614
  try {
135479
- const raw = readFileSync45(filePath, "utf-8");
135615
+ const raw = readFileSync46(filePath, "utf-8");
135480
135616
  return JSON.parse(raw);
135481
135617
  } catch {
135482
135618
  return null;
@@ -137930,10 +138066,10 @@ playwright-cli close
137930
138066
  allowedTools: ["Bash(playwright-cli:*)"]
137931
138067
  };
137932
138068
  // packages/skills-loader-core/src/features/builtin-skills/skill-file-loader.ts
137933
- import { readFileSync as readFileSync48 } from "fs";
138069
+ import { readFileSync as readFileSync49 } from "fs";
137934
138070
  import { join as join63 } from "path";
137935
138071
  init_src();
137936
- function createSharedSkillTemplateLoader(readFile3 = readFileSync48, skillsRootPath = sharedSkillsRootPath()) {
138072
+ function createSharedSkillTemplateLoader(readFile3 = readFileSync49, skillsRootPath = sharedSkillsRootPath()) {
137937
138073
  const cache = new Map;
137938
138074
  return (skillName) => {
137939
138075
  const cached2 = cache.get(skillName);
@@ -140293,7 +140429,7 @@ import {
140293
140429
  existsSync as existsSync65,
140294
140430
  mkdirSync as mkdirSync20,
140295
140431
  copyFileSync as copyFileSync3,
140296
- readFileSync as readFileSync49,
140432
+ readFileSync as readFileSync50,
140297
140433
  writeFileSync as writeFileSync18,
140298
140434
  readdirSync as readdirSync10,
140299
140435
  statSync as statSync8,
@@ -140310,7 +140446,7 @@ async function snapshotCli(options = {}) {
140310
140446
  const realFs = {
140311
140447
  existsSync: existsSync65,
140312
140448
  mkdirSync: mkdirSync20,
140313
- readFileSync: readFileSync49,
140449
+ readFileSync: readFileSync50,
140314
140450
  writeFileSync: writeFileSync18,
140315
140451
  copyFileSync: copyFileSync3,
140316
140452
  readdirSync: readdirSync10,
@@ -140376,7 +140512,7 @@ import {
140376
140512
  existsSync as existsSync66,
140377
140513
  mkdirSync as mkdirSync21,
140378
140514
  copyFileSync as copyFileSync4,
140379
- readFileSync as readFileSync50,
140515
+ readFileSync as readFileSync51,
140380
140516
  writeFileSync as writeFileSync19,
140381
140517
  readdirSync as readdirSync11,
140382
140518
  statSync as statSync9,
@@ -140389,7 +140525,7 @@ async function restoreCli(options) {
140389
140525
  const realFs = {
140390
140526
  existsSync: existsSync66,
140391
140527
  mkdirSync: mkdirSync21,
140392
- readFileSync: readFileSync50,
140528
+ readFileSync: readFileSync51,
140393
140529
  writeFileSync: writeFileSync19,
140394
140530
  copyFileSync: copyFileSync4,
140395
140531
  readdirSync: readdirSync11,
@@ -140404,7 +140540,7 @@ async function restoreCli(options) {
140404
140540
  try {
140405
140541
  restoreSnapshot(options.state, { snapshotDir, fs: realFs });
140406
140542
  const manifestPath = path19.join(snapshotDir, options.state, "manifest.json");
140407
- const raw = readFileSync50(manifestPath).toString("utf-8");
140543
+ const raw = readFileSync51(manifestPath).toString("utf-8");
140408
140544
  const parsed = JSON.parse(raw);
140409
140545
  const fileCount = typeof parsed === "object" && parsed !== null && "files" in parsed && Array.isArray(parsed.files) ? parsed.files.length : 0;
140410
140546
  if (options.json) {
@@ -140428,7 +140564,7 @@ import {
140428
140564
  existsSync as existsSync67,
140429
140565
  mkdirSync as mkdirSync22,
140430
140566
  copyFileSync as copyFileSync5,
140431
- readFileSync as readFileSync51,
140567
+ readFileSync as readFileSync52,
140432
140568
  writeFileSync as writeFileSync20,
140433
140569
  readdirSync as readdirSync12,
140434
140570
  statSync as statSync10,
@@ -140451,7 +140587,7 @@ async function snapshotListCli(options) {
140451
140587
  const realFs = {
140452
140588
  existsSync: existsSync67,
140453
140589
  mkdirSync: mkdirSync22,
140454
- readFileSync: readFileSync51,
140590
+ readFileSync: readFileSync52,
140455
140591
  writeFileSync: writeFileSync20,
140456
140592
  copyFileSync: copyFileSync5,
140457
140593
  readdirSync: readdirSync12,
@@ -140482,7 +140618,7 @@ import {
140482
140618
  existsSync as existsSync68,
140483
140619
  mkdirSync as mkdirSync23,
140484
140620
  copyFileSync as copyFileSync6,
140485
- readFileSync as readFileSync52,
140621
+ readFileSync as readFileSync53,
140486
140622
  writeFileSync as writeFileSync21,
140487
140623
  readdirSync as readdirSync13,
140488
140624
  statSync as statSync11,
@@ -140495,7 +140631,7 @@ async function snapshotPruneCli(options = {}) {
140495
140631
  const realFs = {
140496
140632
  existsSync: existsSync68,
140497
140633
  mkdirSync: mkdirSync23,
140498
- readFileSync: readFileSync52,
140634
+ readFileSync: readFileSync53,
140499
140635
  writeFileSync: writeFileSync21,
140500
140636
  copyFileSync: copyFileSync6,
140501
140637
  readdirSync: readdirSync13,
@@ -141016,6 +141152,7 @@ async function traceCli(sessionId, options = {}) {
141016
141152
 
141017
141153
  // packages/omo-opencode/src/cli/dashboard.ts
141018
141154
  import * as path25 from "path";
141155
+ import { readFileSync as readFileSync55 } from "fs";
141019
141156
 
141020
141157
  // packages/omo-opencode/src/features/dashboard/data-provider.ts
141021
141158
  import * as os12 from "os";
@@ -141575,6 +141712,7 @@ function createDataProvider(config4) {
141575
141712
  }
141576
141713
 
141577
141714
  // packages/omo-opencode/src/features/dashboard/server.ts
141715
+ init_write_gateway_env();
141578
141716
  var MIME = {
141579
141717
  ".html": "text/html; charset=utf-8",
141580
141718
  ".css": "text/css; charset=utf-8",
@@ -141598,8 +141736,8 @@ function createDashboardServer(dataProvider, config4) {
141598
141736
  const path25 = url3.pathname;
141599
141737
  const corsHeaders = {
141600
141738
  "Access-Control-Allow-Origin": "*",
141601
- "Access-Control-Allow-Methods": "GET, OPTIONS",
141602
- "Access-Control-Allow-Headers": "Content-Type"
141739
+ "Access-Control-Allow-Methods": "GET, POST, PUT, OPTIONS",
141740
+ "Access-Control-Allow-Headers": "Content-Type, x-passphrase"
141603
141741
  };
141604
141742
  if (req.method === "OPTIONS") {
141605
141743
  return new Response(null, { headers: corsHeaders });
@@ -141671,6 +141809,30 @@ function createDashboardServer(dataProvider, config4) {
141671
141809
  return Response.json(dataProvider.getMemory(), { headers: jsonHeaders });
141672
141810
  case "/api/skills":
141673
141811
  return Response.json(dataProvider.getSkills(), { headers: jsonHeaders });
141812
+ case "/api/gateway/token": {
141813
+ if (req.method !== "POST") {
141814
+ return new Response("Method Not Allowed", { status: 405, headers: corsHeaders });
141815
+ }
141816
+ const body = await req.json();
141817
+ const type2 = body.type;
141818
+ const token = body.token;
141819
+ const passphrase = body.passphrase;
141820
+ if (type2 !== "telegram" && type2 !== "discord") {
141821
+ return Response.json({ error: "Invalid type. Must be 'telegram' or 'discord'" }, { status: 400, headers: jsonHeaders });
141822
+ }
141823
+ if (typeof token !== "string" || token.length === 0) {
141824
+ return Response.json({ error: "Missing or empty token" }, { status: 400, headers: jsonHeaders });
141825
+ }
141826
+ if (!config4.gatewayPassphrase) {
141827
+ return Response.json({ error: "Passphrase not configured" }, { status: 400, headers: jsonHeaders });
141828
+ }
141829
+ if (passphrase !== config4.gatewayPassphrase) {
141830
+ return Response.json({ error: "Invalid passphrase" }, { status: 401, headers: jsonHeaders });
141831
+ }
141832
+ const key = type2 === "telegram" ? "TELEGRAM_BOT_TOKEN" : "DISCORD_BOT_TOKEN";
141833
+ const envPath = writeGatewayEnvToken(key, token);
141834
+ return Response.json({ ok: true, path: envPath }, { headers: jsonHeaders });
141835
+ }
141674
141836
  default:
141675
141837
  return new Response("Not Found", { status: 404, headers: corsHeaders });
141676
141838
  }
@@ -141706,21 +141868,36 @@ function createDashboardServer(dataProvider, config4) {
141706
141868
  server2 = null;
141707
141869
  },
141708
141870
  get port() {
141709
- return config4.port;
141871
+ return server2?.port ?? config4.port;
141710
141872
  }
141711
141873
  };
141712
141874
  }
141713
141875
 
141714
141876
  // packages/omo-opencode/src/cli/dashboard.ts
141877
+ init_config_context();
141878
+ init_jsonc_parser2();
141879
+ function loadGatewayPassphrase() {
141880
+ try {
141881
+ const configDir = getConfigDir();
141882
+ const configPath = path25.join(configDir, "matrixos.jsonc");
141883
+ const raw = readFileSync55(configPath, "utf-8");
141884
+ const config4 = parseJsonc(raw);
141885
+ const dashboard2 = config4.dashboard;
141886
+ return typeof dashboard2?.gateway_passphrase === "string" ? dashboard2.gateway_passphrase : undefined;
141887
+ } catch {
141888
+ return;
141889
+ }
141890
+ }
141715
141891
  async function dashboardCli(options) {
141716
141892
  const port = options.port ?? 9123;
141717
141893
  const host = options.host ?? "0.0.0.0";
141718
141894
  const frontendDir = path25.resolve(import.meta.dir, "../features/dashboard/frontend");
141895
+ const gatewayPassphrase = loadGatewayPassphrase();
141719
141896
  console.log(`[dashboard] starting MaTrixOS dashboard on http://${host}:${port}`);
141720
141897
  console.log(`[dashboard] frontend: ${frontendDir}`);
141721
141898
  try {
141722
141899
  const dataProvider = createDataProvider();
141723
- const server2 = createDashboardServer(dataProvider, { port, host, frontendDir });
141900
+ const server2 = createDashboardServer(dataProvider, { port, host, frontendDir, gatewayPassphrase });
141724
141901
  server2.start();
141725
141902
  console.log(`[dashboard] ready \u2014 http://${host}:${port}`);
141726
141903
  if (!options.daemon) {
@@ -141747,11 +141924,11 @@ async function dashboardCli(options) {
141747
141924
  }
141748
141925
 
141749
141926
  // packages/omo-opencode/src/cli/architect.ts
141750
- import { join as join73 } from "path";
141927
+ import { join as join74 } from "path";
141751
141928
  var IMPROVEMENTS_DIR = ".matrixos/improvements";
141752
141929
  function getStore(directory) {
141753
141930
  const baseDir = directory ?? process.cwd();
141754
- return createImprovementStore(join73(baseDir, IMPROVEMENTS_DIR));
141931
+ return createImprovementStore(join74(baseDir, IMPROVEMENTS_DIR));
141755
141932
  }
141756
141933
  async function architectReview(options) {
141757
141934
  const store4 = getStore(options.directory);
@@ -142225,6 +142402,20 @@ program2.command("export [name]").description("Export a mini-OS profile as a sta
142225
142402
  process.exit(result.exitCode);
142226
142403
  });
142227
142404
  program2.addCommand(createMcpOAuthCommand());
142405
+ var gateway = program2.command("gateway").description("Gateway configuration \u2014 bot token management");
142406
+ gateway.command("set-token <type>").description("Securely write a bot token to .klc-gateway.env (chmod 600). Valid types: telegram, discord").option("-t, --token <value>", "Token value (non-interactive)").option("-i, --interactive", "Prompt for token with masked input").addHelpText("after", `
142407
+ Examples:
142408
+ $ matrixos gateway set-token telegram --token "123:ABC"
142409
+ $ matrixos gateway set-token discord -i
142410
+ `).action(async (type2, options) => {
142411
+ const { executeGatewaySetTokenCommand: executeGatewaySetTokenCommand2 } = await Promise.resolve().then(() => (init_gateway_set_token(), exports_gateway_set_token));
142412
+ const result = await executeGatewaySetTokenCommand2({
142413
+ positional: [type2],
142414
+ options: { type: type2, token: options.token, interactive: options.interactive ?? false }
142415
+ });
142416
+ process.stdout.write(result.stdout);
142417
+ process.exit(result.exitCode);
142418
+ });
142228
142419
  function runCli() {
142229
142420
  program2.parse();
142230
142421
  }