negotium 0.4.0 → 0.4.2

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.
@@ -1017,7 +1017,7 @@ var init_claude_registry = __esm(() => {
1017
1017
  });
1018
1018
 
1019
1019
  // ../../packages/core/src/version.ts
1020
- var NEGOTIUM_VERSION = "0.4.0";
1020
+ var NEGOTIUM_VERSION = "0.4.2";
1021
1021
 
1022
1022
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
1023
1023
  import { spawn } from "child_process";
@@ -1699,7 +1699,8 @@ var init_mcp_catalog_policy = __esm(() => {
1699
1699
  "system-health": { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
1700
1700
  "background-bash": { scopes: ["forum"], forumRequired: true },
1701
1701
  "agent-health": { scopes: ["forum", "manager", "cron"], forumRequired: true },
1702
- vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true }
1702
+ vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
1703
+ "cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false }
1703
1704
  };
1704
1705
  });
1705
1706
 
@@ -1711,6 +1712,9 @@ function browserOwnerCapability(capability, owner) {
1711
1712
  var init_capability = () => {};
1712
1713
 
1713
1714
  // ../../packages/core/src/platform/mcp-config.ts
1715
+ import { accessSync as accessSync2, constants as fsConstants } from "fs";
1716
+ import { homedir as homedir4 } from "os";
1717
+ import { join as join6 } from "path";
1714
1718
  function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
1715
1719
  if (agent === "codex") {
1716
1720
  return {
@@ -1823,6 +1827,27 @@ function backgroundBashTransport(agent, port, userId, topic) {
1823
1827
  }
1824
1828
  return { type: "sse", url: `http://127.0.0.1:${port}/sse`, headers };
1825
1829
  }
1830
+ function cuaRsArgs() {
1831
+ const raw = envText("NEGOTIUM_CUA_RS_ALLOW_HID")?.trim().toLowerCase();
1832
+ const on = raw === "1" || raw === "true" || raw === "yes";
1833
+ return on ? ["--allow-hid"] : [];
1834
+ }
1835
+ function resolveCuaRsBinary(platform = process.platform) {
1836
+ if (platform !== "darwin")
1837
+ return null;
1838
+ const candidates = [
1839
+ envText("NEGOTIUM_CUA_RS_BIN"),
1840
+ join6(homedir4(), ".local", "bin", "cua-rs"),
1841
+ "/usr/local/bin/cua-rs"
1842
+ ].filter((p) => Boolean(p));
1843
+ for (const candidate of candidates) {
1844
+ try {
1845
+ accessSync2(candidate, fsConstants.X_OK);
1846
+ return candidate;
1847
+ } catch {}
1848
+ }
1849
+ return null;
1850
+ }
1826
1851
  function refreshForumCatalogViews() {
1827
1852
  const { all, required, optional } = classifyForumMcpServers(MCP_CATALOG);
1828
1853
  allForumMcpServerNames.splice(0, allForumMcpServerNames.length, ...all);
@@ -2256,6 +2281,15 @@ var init_mcp_config = __esm(() => {
2256
2281
  args.push("--list-only=true");
2257
2282
  return buildBuiltinMcpServer("vault", { ...ctx, userId: vaultUserId ?? userId }, () => buildStdioMcpServer(agent, VAULT_SERVER, args));
2258
2283
  }
2284
+ },
2285
+ "cua-rs": {
2286
+ ...commonRuntimeMcpPolicy("cua-rs"),
2287
+ build() {
2288
+ const bin = resolveCuaRsBinary();
2289
+ if (!bin)
2290
+ return null;
2291
+ return { command: bin, args: cuaRsArgs() };
2292
+ }
2259
2293
  }
2260
2294
  };
2261
2295
  allForumMcpServerNames = [];
@@ -2268,8 +2302,8 @@ var init_mcp_config = __esm(() => {
2268
2302
 
2269
2303
  // ../../packages/core/src/storage/storage-host.ts
2270
2304
  import { mkdirSync as mkdirSync6 } from "fs";
2271
- import { homedir as homedir4 } from "os";
2272
- import { dirname as dirname5, join as join6, resolve as resolve5 } from "path";
2305
+ import { homedir as homedir5 } from "os";
2306
+ import { dirname as dirname5, join as join7, resolve as resolve5 } from "path";
2273
2307
  function storageState() {
2274
2308
  const holder = globalThis;
2275
2309
  const existing = holder[STORAGE_HOST_STATE];
@@ -2297,23 +2331,23 @@ function envPath(name, fallback) {
2297
2331
  return resolve5(value2 || fallback);
2298
2332
  }
2299
2333
  function defaultStateDir() {
2300
- return envPath("NEGOTIUM_STATE_DIR", join6(homedir4(), ".negotium"));
2334
+ return envPath("NEGOTIUM_STATE_DIR", join7(homedir5(), ".negotium"));
2301
2335
  }
2302
2336
  function defaultDataDir() {
2303
- return envPath("NEGOTIUM_DATA_DIR", join6(defaultStateDir(), "data"));
2337
+ return envPath("NEGOTIUM_DATA_DIR", join7(defaultStateDir(), "data"));
2304
2338
  }
2305
2339
  function defaultLogDir() {
2306
- return envPath("NEGOTIUM_LOG_DIR", join6(defaultStateDir(), "logs"));
2340
+ return envPath("NEGOTIUM_LOG_DIR", join7(defaultStateDir(), "logs"));
2307
2341
  }
2308
2342
  function defaultWorkspaceDir() {
2309
- return envPath("NEGOTIUM_WORKSPACE_DIR", join6(defaultStateDir(), "workspace"));
2343
+ return envPath("NEGOTIUM_WORKSPACE_DIR", join7(defaultStateDir(), "workspace"));
2310
2344
  }
2311
2345
  function defaultSessionAsksDir() {
2312
- const runDir = envPath("NEGOTIUM_RUN_DIR", join6(defaultStateDir(), "runtime"));
2313
- return join6(runDir, "session-asks");
2346
+ const runDir = envPath("NEGOTIUM_RUN_DIR", join7(defaultStateDir(), "runtime"));
2347
+ return join7(runDir, "session-asks");
2314
2348
  }
2315
2349
  function defaultSessionsDatabasePath() {
2316
- return envPath("SESSIONS_DB_PATH", join6(resolveStorageDataDir(), "sessions.db"));
2350
+ return envPath("SESSIONS_DB_PATH", join7(resolveStorageDataDir(), "sessions.db"));
2317
2351
  }
2318
2352
  function isSqliteBusy(error) {
2319
2353
  const message = error instanceof Error ? error.message : String(error);
@@ -2370,7 +2404,7 @@ function resolveStorageWorkspaceDir() {
2370
2404
  return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
2371
2405
  }
2372
2406
  function resolveStorageSharedWikiDir() {
2373
- return storageState().configuredHost.sharedWikiDir ?? join6(resolveStorageWorkspaceDir(), "wiki");
2407
+ return storageState().configuredHost.sharedWikiDir ?? join7(resolveStorageWorkspaceDir(), "wiki");
2374
2408
  }
2375
2409
  function registerStorageSchemaInitializer(initialize, priority = 100) {
2376
2410
  const initializers = storageState().schemaInitializers;
@@ -2480,7 +2514,7 @@ var init_vault_crypto = __esm(() => {
2480
2514
 
2481
2515
  // ../../packages/core/src/storage/vault.ts
2482
2516
  import { chmodSync as chmodSync4, mkdirSync as mkdirSync7 } from "fs";
2483
- import { join as join7 } from "path";
2517
+ import { join as join8 } from "path";
2484
2518
  function initializeVaultDatabase(database) {
2485
2519
  database.exec("PRAGMA journal_mode = WAL");
2486
2520
  database.exec("PRAGMA busy_timeout = 5000");
@@ -2515,8 +2549,8 @@ function initializeVaultDatabase(database) {
2515
2549
  }
2516
2550
  }
2517
2551
  function openVaultDatabase(dataDir) {
2518
- const vaultDir = join7(dataDir, "vault");
2519
- const path = join7(vaultDir, "vault.db");
2552
+ const vaultDir = join8(dataDir, "vault");
2553
+ const path = join8(vaultDir, "vault.db");
2520
2554
  mkdirSync7(vaultDir, { recursive: true, mode: 448 });
2521
2555
  const database = new Database(path, { create: true });
2522
2556
  chmodSync4(path, 384);
@@ -2682,14 +2716,14 @@ var init_execution_host = __esm(async () => {
2682
2716
  // ../../packages/core/src/agents/rollout/codex.ts
2683
2717
  import { randomBytes as randomBytes4 } from "crypto";
2684
2718
  import { existsSync as existsSync7, readFileSync as readFileSync7, realpathSync as realpathSync2, statSync as statSync3, unlinkSync as unlinkSync7 } from "fs";
2685
- import { basename as basename2, dirname as dirname7, join as join8, resolve as resolve6 } from "path";
2719
+ import { basename as basename2, dirname as dirname7, join as join9, resolve as resolve6 } from "path";
2686
2720
  function codexSessionsDir() {
2687
- return join8(hostedCodexHomePath(), "sessions");
2721
+ return join9(hostedCodexHomePath(), "sessions");
2688
2722
  }
2689
2723
  function loadCodexShell() {
2690
2724
  if (_shellCache)
2691
2725
  return _shellCache;
2692
- const raw = readFileSync7(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
2726
+ const raw = readFileSync7(join9(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
2693
2727
  const lines = parseJsonlText(raw);
2694
2728
  if (lines.length < 5) {
2695
2729
  throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
@@ -2756,8 +2790,8 @@ function codexRolloutPath(threadId, fallback) {
2756
2790
  const hh = String(createdAt.getHours()).padStart(2, "0");
2757
2791
  const min = String(createdAt.getMinutes()).padStart(2, "0");
2758
2792
  const ss = String(createdAt.getSeconds()).padStart(2, "0");
2759
- const dir = join8(codexSessionsDir(), yyyy, mm, dd);
2760
- return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
2793
+ const dir = join9(codexSessionsDir(), yyyy, mm, dd);
2794
+ return join9(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
2761
2795
  }
2762
2796
  function canonicalFilePath(path) {
2763
2797
  const absolute = resolve6(path);
@@ -2765,7 +2799,7 @@ function canonicalFilePath(path) {
2765
2799
  return realpathSync2(absolute);
2766
2800
  } catch {
2767
2801
  try {
2768
- return join8(realpathSync2(dirname7(absolute)), basename2(absolute));
2802
+ return join9(realpathSync2(dirname7(absolute)), basename2(absolute));
2769
2803
  } catch {
2770
2804
  return absolute;
2771
2805
  }
@@ -2995,19 +3029,19 @@ function latestCodexRolloutPath(threadId) {
2995
3029
  try {
2996
3030
  if (buckets) {
2997
3031
  for (const bucket of buckets) {
2998
- const dir = join8(sessionsDir, bucket);
3032
+ const dir = join9(sessionsDir, bucket);
2999
3033
  if (!existsSync7(dir))
3000
3034
  continue;
3001
3035
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
3002
3036
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
3003
- candidates.push(join8(dir, rel));
3037
+ candidates.push(join9(dir, rel));
3004
3038
  }
3005
3039
  }
3006
3040
  }
3007
3041
  if (candidates.length === 0) {
3008
3042
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
3009
3043
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
3010
- candidates.push(join8(sessionsDir, rel));
3044
+ candidates.push(join9(sessionsDir, rel));
3011
3045
  }
3012
3046
  }
3013
3047
  return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
@@ -3128,13 +3162,13 @@ function sweepPriorRolloutsForThread(threadId) {
3128
3162
  return;
3129
3163
  }
3130
3164
  for (const bucket of buckets) {
3131
- const dir = join8(sessionsDir, bucket);
3165
+ const dir = join9(sessionsDir, bucket);
3132
3166
  if (!existsSync7(dir))
3133
3167
  continue;
3134
3168
  try {
3135
3169
  const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
3136
3170
  for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
3137
- const fullPath = join8(dir, rel);
3171
+ const fullPath = join9(dir, rel);
3138
3172
  try {
3139
3173
  unlinkSync7(fullPath);
3140
3174
  } catch (e) {
@@ -3152,7 +3186,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
3152
3186
  try {
3153
3187
  const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
3154
3188
  for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
3155
- const fullPath = join8(sessionsDir, rel);
3189
+ const fullPath = join9(sessionsDir, rel);
3156
3190
  try {
3157
3191
  unlinkSync7(fullPath);
3158
3192
  } catch (e) {
@@ -3330,7 +3364,7 @@ var init_codex_app_server = __esm(async () => {
3330
3364
 
3331
3365
  // ../../packages/core/src/agents/codex-registry.ts
3332
3366
  import { existsSync as existsSync8, unlinkSync as unlinkSync8 } from "fs";
3333
- import { join as join9 } from "path";
3367
+ import { join as join10 } from "path";
3334
3368
  var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
3335
3369
  var init_codex_registry = __esm(async () => {
3336
3370
  await init_codex_app_server();
@@ -3373,7 +3407,7 @@ var init_codex_registry = __esm(async () => {
3373
3407
  async cleanupRollouts({ sessionIds }) {
3374
3408
  if (sessionIds.length === 0)
3375
3409
  return;
3376
- const sessionsDir = join9(hostedCodexHomePath(), "sessions");
3410
+ const sessionsDir = join10(hostedCodexHomePath(), "sessions");
3377
3411
  if (!existsSync8(sessionsDir))
3378
3412
  return;
3379
3413
  const failures = [];
@@ -3381,7 +3415,7 @@ var init_codex_registry = __esm(async () => {
3381
3415
  try {
3382
3416
  const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
3383
3417
  for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
3384
- const path = join9(sessionsDir, rel);
3418
+ const path = join10(sessionsDir, rel);
3385
3419
  try {
3386
3420
  unlinkSync8(path);
3387
3421
  } catch (e) {
@@ -3406,16 +3440,16 @@ var init_codex_registry = __esm(async () => {
3406
3440
  // ../../packages/core/src/agents/maestro-registry.ts
3407
3441
  import { randomUUID as randomUUID4 } from "crypto";
3408
3442
  import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
3409
- import { homedir as homedir5 } from "os";
3410
- import { join as join10, resolve as resolve7 } from "path";
3443
+ import { homedir as homedir6 } from "os";
3444
+ import { join as join11, resolve as resolve7 } from "path";
3411
3445
  function maestroSessionsDir() {
3412
- return join10(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join10(homedir5(), ".maestro"), "sessions");
3446
+ return join11(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join11(homedir6(), ".maestro"), "sessions");
3413
3447
  }
3414
3448
  function maestroSessionPath(sessionId) {
3415
- return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
3449
+ return join11(maestroSessionsDir(), `${sessionId}.jsonl`);
3416
3450
  }
3417
3451
  function maestroActiveSessionPath(sessionId) {
3418
- return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
3452
+ return join11(maestroSessionsDir(), `${sessionId}.active.jsonl`);
3419
3453
  }
3420
3454
  function existingCreatedAt(path) {
3421
3455
  if (!existsSync9(path))
@@ -5858,13 +5892,13 @@ var init_browser_processes = __esm(async () => {
5858
5892
  });
5859
5893
 
5860
5894
  // ../../packages/core/src/platform/playwright/headed-launch.ts
5861
- import { accessSync as accessSync2, constants as constants2 } from "fs";
5895
+ import { accessSync as accessSync3, constants as constants2 } from "fs";
5862
5896
  import { delimiter, isAbsolute, resolve as resolve9 } from "path";
5863
5897
  function findExecutableOnPath(command, environment = process.env) {
5864
5898
  const candidates = isAbsolute(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve9(directory, command));
5865
5899
  for (const candidate of candidates) {
5866
5900
  try {
5867
- accessSync2(candidate, constants2.X_OK);
5901
+ accessSync3(candidate, constants2.X_OK);
5868
5902
  return candidate;
5869
5903
  } catch {}
5870
5904
  }
@@ -5963,7 +5997,7 @@ import { randomBytes as randomBytes5, timingSafeEqual as timingSafeEqual2 } from
5963
5997
  import { chmodSync as chmodSync5 } from "fs";
5964
5998
  import { createServer as createServer2 } from "net";
5965
5999
  import { tmpdir as tmpdir2 } from "os";
5966
- import { join as join13 } from "path";
6000
+ import { join as join14 } from "path";
5967
6001
  function deepMapStrings(value2, transform) {
5968
6002
  if (typeof value2 === "string")
5969
6003
  return transform(value2);
@@ -6050,7 +6084,7 @@ function authorized(actual, expected) {
6050
6084
  }
6051
6085
  async function createBrowserVaultBroker(userId) {
6052
6086
  const token = randomBytes5(32).toString("hex");
6053
- const socketPath = join13(process.platform === "win32" ? tmpdir2() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes5(8).toString("hex")}.sock`);
6087
+ const socketPath = join14(process.platform === "win32" ? tmpdir2() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes5(8).toString("hex")}.sock`);
6054
6088
  const retainedForms = new Map;
6055
6089
  const leases = new Map;
6056
6090
  const sockets = new Set;
@@ -6259,7 +6293,7 @@ import {
6259
6293
  unlinkSync as unlinkSync11,
6260
6294
  writeFileSync as writeFileSync8
6261
6295
  } from "fs";
6262
- import { dirname as dirname9, join as join14, resolve as resolve10 } from "path";
6296
+ import { dirname as dirname9, join as join15, resolve as resolve10 } from "path";
6263
6297
  function removeDefaultProfileDataDir(userDataDir) {
6264
6298
  const root = resolve10(BROWSER_PROFILES_DIR);
6265
6299
  const target = resolve10(userDataDir);
@@ -6349,14 +6383,14 @@ function portFileName(instanceKey) {
6349
6383
  function writePortFile(instanceKey, port) {
6350
6384
  try {
6351
6385
  mkdirSync10(managerHost.portsDir, { recursive: true });
6352
- writeFileSync8(join14(managerHost.portsDir, portFileName(instanceKey)), String(port));
6386
+ writeFileSync8(join15(managerHost.portsDir, portFileName(instanceKey)), String(port));
6353
6387
  } catch (e) {
6354
6388
  logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
6355
6389
  }
6356
6390
  }
6357
6391
  function deletePortFile(instanceKey) {
6358
6392
  try {
6359
- unlinkSync11(join14(managerHost.portsDir, portFileName(instanceKey)));
6393
+ unlinkSync11(join15(managerHost.portsDir, portFileName(instanceKey)));
6360
6394
  } catch (e) {
6361
6395
  if (e.code === "ENOENT")
6362
6396
  return;
@@ -7417,16 +7451,16 @@ import {
7417
7451
  unlinkSync as unlinkSync12,
7418
7452
  writeFileSync as writeFileSync9
7419
7453
  } from "fs";
7420
- import { dirname as dirname10, join as join15 } from "path";
7454
+ import { dirname as dirname10, join as join16 } from "path";
7421
7455
  function conversationDir(_userId) {
7422
- return join15(resolveStorageDataDir(), "conversations");
7456
+ return join16(resolveStorageDataDir(), "conversations");
7423
7457
  }
7424
7458
  function topicFilename(topicName) {
7425
7459
  const t = sanitizeTopicName(topicName, true);
7426
7460
  return `${t}.jsonl`;
7427
7461
  }
7428
7462
  function getConversationPath(userId, topicName) {
7429
- return join15(conversationDir(userId), topicFilename(topicName));
7463
+ return join16(conversationDir(userId), topicFilename(topicName));
7430
7464
  }
7431
7465
  function getActiveConversationPath(userId, topicName) {
7432
7466
  const rawPath = getConversationPath(userId, topicName);
@@ -7649,7 +7683,7 @@ RULES:
7649
7683
 
7650
7684
  // ../../packages/core/src/storage/tasks.ts
7651
7685
  import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync13, renameSync as renameSync7, statSync as statSync4, writeFileSync as writeFileSync10 } from "fs";
7652
- import { dirname as dirname11, join as join16 } from "path";
7686
+ import { dirname as dirname11, join as join17 } from "path";
7653
7687
  function safeTaskScopeKey(scopeKey) {
7654
7688
  const safe = sanitizeFileName(scopeKey);
7655
7689
  if (!safe || safe === "." || safe === "..") {
@@ -7661,7 +7695,7 @@ function taskScopeKey(opts) {
7661
7695
  return opts.topicId?.trim() || opts.session || "default";
7662
7696
  }
7663
7697
  function getTaskFilePath(userId, scopeKey) {
7664
- return join16(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
7698
+ return join17(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
7665
7699
  }
7666
7700
  function readTasks(userId, scopeKey) {
7667
7701
  const path = getTaskFilePath(userId, scopeKey);
@@ -8629,7 +8663,7 @@ import { existsSync as existsSync17 } from "fs";
8629
8663
  import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
8630
8664
  import { createServer as createServer3 } from "net";
8631
8665
  import { tmpdir as tmpdir3 } from "os";
8632
- import { dirname as dirname12, join as join17, resolve as resolve11 } from "path";
8666
+ import { dirname as dirname12, join as join18, resolve as resolve11 } from "path";
8633
8667
  import { fileURLToPath as fileURLToPath2 } from "url";
8634
8668
  function evaluateCodexVaultPreToolUse(input, userId, operations) {
8635
8669
  if (operations.referencesSensitiveStorage(input.tool_input)) {
@@ -8667,9 +8701,11 @@ function hookClientPath() {
8667
8701
  return packaged;
8668
8702
  throw new Error("Codex Vault hook client is missing from this installation");
8669
8703
  }
8670
- function privateCodexWrapper(codexScript) {
8704
+ function privateCodexWrapper(codexScript, socketPath, token) {
8671
8705
  return [
8672
8706
  "#!/bin/sh",
8707
+ `export ${HOOK_SOCKET_ENV}=${shellQuote(socketPath)}`,
8708
+ `export ${HOOK_TOKEN_ENV}=${shellQuote(token)}`,
8673
8709
  'if [ "$1" = "exec" ]; then',
8674
8710
  " shift",
8675
8711
  ` exec ${shellQuote(process.execPath)} ${shellQuote(codexScript)} exec --dangerously-bypass-hook-trust "$@"`,
@@ -8680,10 +8716,10 @@ function privateCodexWrapper(codexScript) {
8680
8716
  `);
8681
8717
  }
8682
8718
  async function createCodexVaultHookBridge(userId) {
8683
- const root = await mkdtemp(join17(tmpdir3(), "negotium-codex-vault-"));
8719
+ const root = await mkdtemp(join18(tmpdir3(), "negotium-codex-vault-"));
8684
8720
  await chmod(root, 448);
8685
- const socketPath = join17(root, "hook.sock");
8686
- const wrapperPath = join17(root, "codex-with-hooks");
8721
+ const socketPath = join18(root, "hook.sock");
8722
+ const wrapperPath = join18(root, "codex-with-hooks");
8687
8723
  const token = randomBytes7(32).toString("hex");
8688
8724
  const connections = new Set;
8689
8725
  const server = createServer3((socket) => {
@@ -8732,15 +8768,13 @@ async function createCodexVaultHookBridge(userId) {
8732
8768
  });
8733
8769
  });
8734
8770
  await chmod(socketPath, 384);
8735
- await writeFile(wrapperPath, privateCodexWrapper(codexCliScriptPath()), { mode: 448 });
8736
- const command = [
8737
- shellQuote(process.execPath),
8738
- shellQuote(hookClientPath()),
8739
- shellQuote(socketPath),
8740
- shellQuote(token)
8741
- ].join(" ");
8771
+ await writeFile(wrapperPath, privateCodexWrapper(codexCliScriptPath(), socketPath, token), {
8772
+ mode: 448
8773
+ });
8774
+ const command = [shellQuote(process.execPath), shellQuote(hookClientPath())].join(" ");
8742
8775
  return {
8743
8776
  codexPathOverride: wrapperPath,
8777
+ environment: { [HOOK_SOCKET_ENV]: socketPath, [HOOK_TOKEN_ENV]: token },
8744
8778
  hooks: {
8745
8779
  PreToolUse: [
8746
8780
  {
@@ -8769,7 +8803,7 @@ async function createCodexVaultHookBridge(userId) {
8769
8803
  throw error;
8770
8804
  }
8771
8805
  }
8772
- var MAX_HOOK_REQUEST_BYTES, SENSITIVE_STORAGE_DENIAL = "Runtime secret storage access is not permitted";
8806
+ var MAX_HOOK_REQUEST_BYTES, SENSITIVE_STORAGE_DENIAL = "Runtime secret storage access is not permitted", HOOK_SOCKET_ENV = "NEGOTIUM_CODEX_VAULT_HOOK_SOCKET", HOOK_TOKEN_ENV = "NEGOTIUM_CODEX_VAULT_HOOK_TOKEN";
8773
8807
  var init_codex_vault_hook_bridge = __esm(async () => {
8774
8808
  init_codex_native_multi_agent();
8775
8809
  await init_execution_host();
@@ -9302,8 +9336,8 @@ __export(exports_codex_provider, {
9302
9336
  });
9303
9337
  import { execFileSync as execFileSync6 } from "child_process";
9304
9338
  import { existsSync as existsSync18, readFileSync as readFileSync16, realpathSync as realpathSync4, statSync as statSync6 } from "fs";
9305
- import { homedir as homedir6 } from "os";
9306
- import { dirname as dirname13, isAbsolute as isAbsolute3, join as join18, relative as relative2, resolve as resolve13 } from "path";
9339
+ import { homedir as homedir7 } from "os";
9340
+ import { dirname as dirname13, isAbsolute as isAbsolute3, join as join19, relative as relative2, resolve as resolve13 } from "path";
9307
9341
  import { Codex } from "@openai/codex-sdk";
9308
9342
  function sameCodexUsage(usage, total) {
9309
9343
  return usage.input_tokens === total.inputTokens && usage.output_tokens === total.outputTokens && (usage.cached_input_tokens ?? 0) === total.cachedInputTokens && (usage.cache_write_input_tokens ?? 0) === total.cacheWriteInputTokens;
@@ -9331,7 +9365,7 @@ function codexMcpServerName(name) {
9331
9365
  return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
9332
9366
  }
9333
9367
  function globalCodexMcpServerNames(authFilePath) {
9334
- const configPath = join18(dirname13(authFilePath), "config.toml");
9368
+ const configPath = join19(dirname13(authFilePath), "config.toml");
9335
9369
  if (!existsSync18(configPath))
9336
9370
  return [];
9337
9371
  try {
@@ -9689,7 +9723,7 @@ async function* codexProvider(opts) {
9689
9723
  mcpServerCount: Object.keys(codexMcpServers).length
9690
9724
  }, "codexProvider: starting turn");
9691
9725
  const hostedCodexHome = hostedCodexHomePath();
9692
- const inheritedCodexHome = process.env.CODEX_HOME || join18(homedir6(), ".codex");
9726
+ const inheritedCodexHome = process.env.CODEX_HOME || join19(homedir7(), ".codex");
9693
9727
  const codexEnvironment = scopedBrowserCapability || resolve13(hostedCodexHome) !== resolve13(inheritedCodexHome) ? {
9694
9728
  ...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
9695
9729
  CODEX_HOME: hostedCodexHome,
@@ -9883,7 +9917,10 @@ async function* codexProvider(opts) {
9883
9917
  yield fileEvent;
9884
9918
  }
9885
9919
  } else if (item.type === "error") {
9886
- yield { type: "error", content: String(item.message ?? "") };
9920
+ const message = String(item.message ?? "");
9921
+ if (message !== CODEX_HOOK_TRUST_BYPASS_NOTICE) {
9922
+ yield { type: "error", content: message };
9923
+ }
9887
9924
  }
9888
9925
  break;
9889
9926
  }
@@ -9974,7 +10011,7 @@ async function* codexProvider(opts) {
9974
10011
  await vaultHook.close();
9975
10012
  }
9976
10013
  }
9977
- var CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_FILE_LIMIT = 200, CODEX_DIFF_BASELINE_BYTE_LIMIT, CODEX_STARTUP_TIMEOUT_MS = 90000;
10014
+ var CODEX_HOOK_TRUST_BYPASS_NOTICE = "`--dangerously-bypass-hook-trust` is enabled. Enabled hooks may run without review for this invocation.", CODEX_MCP_SERVER_NAME_OVERRIDES, CODEX_DIFF_FILE_LIMIT, CODEX_DIFF_BASELINE_FILE_LIMIT = 200, CODEX_DIFF_BASELINE_BYTE_LIMIT, CODEX_STARTUP_TIMEOUT_MS = 90000;
9978
10015
  var init_codex_provider = __esm(async () => {
9979
10016
  init_codex_native_multi_agent();
9980
10017
  init_codex_tree_kill();
@@ -10145,8 +10182,8 @@ var init_maestro_provider = __esm(async () => {
10145
10182
 
10146
10183
  // ../../packages/core/src/agents/index.ts
10147
10184
  import { existsSync as existsSync19 } from "fs";
10148
- import { homedir as homedir7 } from "os";
10149
- import { join as join19 } from "path";
10185
+ import { homedir as homedir8 } from "os";
10186
+ import { join as join20 } from "path";
10150
10187
  async function* dispatchAgent(opts) {
10151
10188
  switch (opts.agent) {
10152
10189
  case "claude": {
@@ -10180,11 +10217,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
10180
10217
  switch (agent) {
10181
10218
  case "claude": {
10182
10219
  const encodedCwd = encodeClaudeCwd(cwd);
10183
- const path = join19(homedir7(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
10220
+ const path = join20(homedir8(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
10184
10221
  return !existsSync19(path);
10185
10222
  }
10186
10223
  case "codex": {
10187
- const sessionsDir = join19(hostedCodexHomePath(), "sessions");
10224
+ const sessionsDir = join20(hostedCodexHomePath(), "sessions");
10188
10225
  const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
10189
10226
  for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
10190
10227
  return false;
@@ -10708,9 +10745,9 @@ var init_api_topic_brief = __esm(async () => {
10708
10745
  });
10709
10746
 
10710
10747
  // ../../packages/core/src/storage/wiki.ts
10711
- import { basename as basename3, dirname as dirname14, join as join20 } from "path";
10748
+ import { basename as basename3, dirname as dirname14, join as join21 } from "path";
10712
10749
  function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
10713
- return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join20(workspaceDir, "wiki");
10750
+ return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join21(workspaceDir, "wiki");
10714
10751
  }
10715
10752
  var init_wiki = __esm(async () => {
10716
10753
  await init_storage_host();
@@ -10719,7 +10756,7 @@ var init_wiki = __esm(async () => {
10719
10756
  // ../../packages/core/src/agents/archiver.ts
10720
10757
  import { randomUUID as randomUUID9 } from "crypto";
10721
10758
  import { existsSync as existsSync20, readdirSync as readdirSync5, readFileSync as readFileSync18, statSync as statSync7 } from "fs";
10722
- import { join as join21 } from "path";
10759
+ import { join as join22 } from "path";
10723
10760
  function resolveMemoryLanguage() {
10724
10761
  const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
10725
10762
  return override && override.length > 0 ? override : resolveOutputLanguage();
@@ -10970,10 +11007,10 @@ function distillOneLine(summaryMd) {
10970
11007
  return "";
10971
11008
  }
10972
11009
  function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
10973
- const dir = join21(storage.getWikiDir(), "summaries");
11010
+ const dir = join22(storage.getWikiDir(), "summaries");
10974
11011
  if (!storage.fileExists(dir))
10975
11012
  return null;
10976
- const predicted = join21(dir, wikiSummaryFilename(date, topicTitle, topicId));
11013
+ const predicted = join22(dir, wikiSummaryFilename(date, topicTitle, topicId));
10977
11014
  if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
10978
11015
  return predicted;
10979
11016
  let best = null;
@@ -10981,7 +11018,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
10981
11018
  if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
10982
11019
  continue;
10983
11020
  }
10984
- const p = join21(dir, f);
11021
+ const p = join22(dir, f);
10985
11022
  try {
10986
11023
  const m = storage.fileModifiedAt(p);
10987
11024
  if (m >= sinceMs && (!best || m > best.mtime))
@@ -11185,13 +11222,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
11185
11222
 
11186
11223
  // ../../packages/core/src/storage/topic-archive.ts
11187
11224
  import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync11 } from "fs";
11188
- import { join as join22 } from "path";
11225
+ import { join as join23 } from "path";
11189
11226
  function archiveTopicMessages(topicId, topicTitle, options = {}) {
11190
11227
  const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
11191
11228
  if (rows.length === 0)
11192
11229
  return null;
11193
11230
  const safeTopic = sanitizeTopicName(topicTitle, true);
11194
- const archiveDir = join22(getSharedWikiDir(), "archive");
11231
+ const archiveDir = join23(getSharedWikiDir(), "archive");
11195
11232
  mkdirSync13(archiveDir, { recursive: true });
11196
11233
  const date = new Date().toISOString().slice(0, 10);
11197
11234
  const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
@@ -11204,7 +11241,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
11204
11241
  let path;
11205
11242
  while (true) {
11206
11243
  filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
11207
- path = join22(archiveDir, filename);
11244
+ path = join23(archiveDir, filename);
11208
11245
  try {
11209
11246
  writeFileSync11(path, body, { flag: "wx" });
11210
11247
  break;
@@ -11249,7 +11286,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
11249
11286
  const entries = readRawConversation(userId, topicTitle);
11250
11287
  if (entries.length === 0)
11251
11288
  return null;
11252
- const archiveDir = join22(getSharedWikiDir(), "archive");
11289
+ const archiveDir = join23(getSharedWikiDir(), "archive");
11253
11290
  mkdirSync13(archiveDir, { recursive: true });
11254
11291
  const safeTopic = sanitizeTopicName(topicTitle, true);
11255
11292
  const date = new Date().toISOString().slice(0, 10);
@@ -11277,7 +11314,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
11277
11314
  let counter = 1;
11278
11315
  while (true) {
11279
11316
  const suffix = counter === 1 ? "" : `_${counter}`;
11280
- const path = join22(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
11317
+ const path = join23(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
11281
11318
  try {
11282
11319
  writeFileSync11(path, body, { flag: "wx" });
11283
11320
  logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
@@ -11826,7 +11863,7 @@ var init_usage_alert = __esm(() => {
11826
11863
  import { randomUUID as randomUUID10 } from "crypto";
11827
11864
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync13 } from "fs";
11828
11865
  import { tmpdir as tmpdir4 } from "os";
11829
- import { join as join23 } from "path";
11866
+ import { join as join24 } from "path";
11830
11867
  function previousCompactedSummary(entries) {
11831
11868
  for (let index = entries.length - 2;index >= 0; index -= 1) {
11832
11869
  const request = entries[index]?.event;
@@ -11956,7 +11993,7 @@ function formatCompactElapsed(startedAt) {
11956
11993
  async function summarizeTopicContext(request) {
11957
11994
  const startedAt = Date.now();
11958
11995
  const sessionIds = [];
11959
- const compactCwd = mkdtempSync2(join23(tmpdir4(), "negotium-compact-"));
11996
+ const compactCwd = mkdtempSync2(join24(tmpdir4(), "negotium-compact-"));
11960
11997
  const abortController = new AbortController;
11961
11998
  const relayAbort = () => abortController.abort(request.signal?.reason);
11962
11999
  if (request.signal?.aborted)
@@ -11983,7 +12020,7 @@ async function summarizeTopicContext(request) {
11983
12020
  let error = "";
11984
12021
  let toolViolation = false;
11985
12022
  let compactionLogCalls = 0;
11986
- const compactionLogPath = join23(compactCwd, "conversation.log");
12023
+ const compactionLogPath = join24(compactCwd, "conversation.log");
11987
12024
  try {
11988
12025
  const compactionMcp = useCompactionLog ? {
11989
12026
  compact_log: {
@@ -12602,14 +12639,14 @@ var init_derive = __esm(async () => {
12602
12639
  });
12603
12640
 
12604
12641
  // ../../packages/core/src/query/session-inbox-path.ts
12605
- import { join as join24 } from "path";
12642
+ import { join as join25 } from "path";
12606
12643
  function sessionInboxPath(userId, topicId) {
12607
12644
  const key = Buffer.from(topicId, "utf8").toString("base64url");
12608
- return join24(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
12645
+ return join25(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
12609
12646
  }
12610
12647
  function scheduledSessionInboxPath(userId, topicId) {
12611
12648
  const key = Buffer.from(topicId, "utf8").toString("base64url");
12612
- return join24(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
12649
+ return join25(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
12613
12650
  }
12614
12651
  var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
12615
12652
  var init_session_inbox_path = __esm(() => {
@@ -12618,13 +12655,13 @@ var init_session_inbox_path = __esm(() => {
12618
12655
 
12619
12656
  // ../../packages/core/src/query/session-inbox-cleanup.ts
12620
12657
  import { unlinkSync as unlinkSync15 } from "fs";
12621
- import { basename as basename4, join as join25 } from "path";
12658
+ import { basename as basename4, join as join26 } from "path";
12622
12659
  function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
12623
12660
  const live = sessionInboxPath(userId, topicId);
12624
12661
  const scheduled = scheduledSessionInboxPath(userId, topicId);
12625
12662
  const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
12626
12663
  if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename4(legacyTopicTitle) === legacyTopicTitle) {
12627
- const legacyBase = join25(SESSION_INBOX_DIR, userId, legacyTopicTitle);
12664
+ const legacyBase = join26(SESSION_INBOX_DIR, userId, legacyTopicTitle);
12628
12665
  for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
12629
12666
  candidates.add(`${legacyBase}${suffix}`);
12630
12667
  }
@@ -12650,16 +12687,16 @@ var init_session_inbox_cleanup = __esm(() => {
12650
12687
 
12651
12688
  // ../../packages/core/src/query/state.ts
12652
12689
  import { mkdirSync as mkdirSync16, renameSync as renameSync9, unlinkSync as unlinkSync16, writeFileSync as writeFileSync14 } from "fs";
12653
- import { basename as basename5, join as join26 } from "path";
12690
+ import { basename as basename5, join as join27 } from "path";
12654
12691
  function createQueryStateStore(options) {
12655
12692
  const sanitize = options.sanitizeTopicId ?? sanitizeId;
12656
- const queryStateDirPath = (userId) => join26(options.usersLogDir, String(userId), "active-queries");
12657
- const queryStateFile = (userId, topicId) => join26(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
12693
+ const queryStateDirPath = (userId) => join27(options.usersLogDir, String(userId), "active-queries");
12694
+ const queryStateFile = (userId, topicId) => join27(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
12658
12695
  const legacyQueryStateFile = (userId, topicName) => {
12659
12696
  if (!topicName || topicName === "." || topicName === ".." || basename5(topicName) !== topicName) {
12660
12697
  return null;
12661
12698
  }
12662
- return join26(queryStateDirPath(userId), `${topicName}.json`);
12699
+ return join27(queryStateDirPath(userId), `${topicName}.json`);
12663
12700
  };
12664
12701
  return {
12665
12702
  write(userId, topicId, topicName, task) {
@@ -12820,29 +12857,29 @@ import {
12820
12857
  unlinkSync as unlinkSync17,
12821
12858
  writeFileSync as writeFileSync15
12822
12859
  } from "fs";
12823
- import { dirname as dirname16, join as join27 } from "path";
12860
+ import { dirname as dirname16, join as join28 } from "path";
12824
12861
  function pendingAskDir(userId) {
12825
12862
  const rawUserId = String(userId);
12826
12863
  const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash5("sha256").update(rawUserId).digest("hex")}`;
12827
- return join27(resolveStorageSessionAsksDir(), safeUserId);
12864
+ return join28(resolveStorageSessionAsksDir(), safeUserId);
12828
12865
  }
12829
12866
  function encodeAskKey(key) {
12830
12867
  return JSON.stringify([key.from, key.to]);
12831
12868
  }
12832
12869
  function pendingAskPath(key) {
12833
12870
  const digest = createHash5("sha256").update(encodeAskKey(key)).digest("hex");
12834
- return join27(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
12871
+ return join28(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
12835
12872
  }
12836
12873
  function v2PendingAskPath(key) {
12837
12874
  const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
12838
- return join27(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
12875
+ return join28(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
12839
12876
  }
12840
12877
  function legacyPendingAskPath(key) {
12841
12878
  if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
12842
12879
  return null;
12843
12880
  }
12844
12881
  const dir = pendingAskDir(key.userId);
12845
- const candidate = join27(dir, `${key.from}___${key.to}.pending`);
12882
+ const candidate = join28(dir, `${key.from}___${key.to}.pending`);
12846
12883
  return dirname16(candidate) === dir ? candidate : null;
12847
12884
  }
12848
12885
  function parsePendingAskFilename(fileName) {
@@ -13083,7 +13120,7 @@ function listPendingAsksForCaller(args) {
13083
13120
  const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
13084
13121
  if (!parsed)
13085
13122
  continue;
13086
- const path = join27(dir, fileName);
13123
+ const path = join28(dir, fileName);
13087
13124
  const record = readPendingAskFile(path, {
13088
13125
  userId: args.userId,
13089
13126
  from: parsed.from,
@@ -13125,7 +13162,7 @@ function deletePendingAsksForTopic(args) {
13125
13162
  }
13126
13163
  let deleted = 0;
13127
13164
  for (const fileName of files) {
13128
- const path = join27(dir, fileName);
13165
+ const path = join28(dir, fileName);
13129
13166
  const parsed = parsePendingAskFilename(fileName);
13130
13167
  const record = readPendingAskFile(path, {
13131
13168
  userId: args.userId,
@@ -13563,7 +13600,7 @@ var init_self_schedules = __esm(async () => {
13563
13600
  // ../../packages/core/src/storage/token-stats.ts
13564
13601
  import { createHash as createHash6 } from "crypto";
13565
13602
  import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync16 } from "fs";
13566
- import { join as join28 } from "path";
13603
+ import { join as join29 } from "path";
13567
13604
  function emptyBucket() {
13568
13605
  return {
13569
13606
  inputTokens: 0,
@@ -13582,7 +13619,7 @@ function queriesPath(userId) {
13582
13619
  const fileId = tokenStatsFileId(userId);
13583
13620
  const logDir = resolveStorageLogDir();
13584
13621
  mkdirSync18(logDir, { recursive: true });
13585
- return join28(logDir, `token-queries-${fileId}.jsonl`);
13622
+ return join29(logDir, `token-queries-${fileId}.jsonl`);
13586
13623
  }
13587
13624
  function loadRecords(userId) {
13588
13625
  try {
@@ -13984,7 +14021,7 @@ var init_lifecycle = __esm(async () => {
13984
14021
  // ../../packages/core/src/runtime/attachments.ts
13985
14022
  import { randomUUID as randomUUID13 } from "crypto";
13986
14023
  import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17 } from "fs";
13987
- import { basename as basename6, join as join29 } from "path";
14024
+ import { basename as basename6, join as join30 } from "path";
13988
14025
  function workspaceCwdFor(topicId) {
13989
14026
  return resolveTopicWorkspaceDir(topicId);
13990
14027
  }
@@ -13997,7 +14034,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
13997
14034
  if (!attachmentIds?.length)
13998
14035
  return [];
13999
14036
  const out = [];
14000
- const destDir = join29(workspaceCwdFor(topicId), "attachments", queryId);
14037
+ const destDir = join30(workspaceCwdFor(topicId), "attachments", queryId);
14001
14038
  for (const rawId of attachmentIds) {
14002
14039
  if (typeof rawId !== "string")
14003
14040
  continue;
@@ -14014,7 +14051,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
14014
14051
  mkdirSync19(destDir, { recursive: true });
14015
14052
  const index = String(out.length + 1).padStart(2, "0");
14016
14053
  const safeName = safeAttachmentFilename(attachment.filename, fileId);
14017
- const destPath = join29(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
14054
+ const destPath = join30(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
14018
14055
  copyFileSync2(sourcePath, destPath);
14019
14056
  out.push({
14020
14057
  id: attachment.id,
@@ -14044,10 +14081,10 @@ function promptWithAttachments(prompt, attachments) {
14044
14081
  return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
14045
14082
  }
14046
14083
  function ingestAttachment(args) {
14047
- const destDir = join29(UPLOADS_DIR, args.topicId);
14084
+ const destDir = join30(UPLOADS_DIR, args.topicId);
14048
14085
  mkdirSync19(destDir, { recursive: true });
14049
14086
  const safeName = safeAttachmentFilename(args.filename, "upload");
14050
- const destPath = join29(destDir, `${Date.now()}-${randomUUID13().slice(0, 8)}-${safeName}`);
14087
+ const destPath = join30(destDir, `${Date.now()}-${randomUUID13().slice(0, 8)}-${safeName}`);
14051
14088
  if (args.sourcePath !== undefined) {
14052
14089
  copyFileSync2(args.sourcePath, destPath);
14053
14090
  } else if (args.bytes !== undefined) {
@@ -15882,9 +15919,9 @@ var init_turn_session = __esm(async () => {
15882
15919
 
15883
15920
  // ../../packages/core/src/storage/app-settings.ts
15884
15921
  import { existsSync as existsSync21, mkdirSync as mkdirSync20, readFileSync as readFileSync20, writeFileSync as writeFileSync18 } from "fs";
15885
- import { dirname as dirname17, join as join30 } from "path";
15922
+ import { dirname as dirname17, join as join31 } from "path";
15886
15923
  function settingsFile() {
15887
- return join30(resolveStorageDataDir(), "otium-settings.json");
15924
+ return join31(resolveStorageDataDir(), "otium-settings.json");
15888
15925
  }
15889
15926
  function getGlobalAiName() {
15890
15927
  const path = settingsFile();
@@ -15979,7 +16016,7 @@ __export(exports_turn_runner, {
15979
16016
  });
15980
16017
  import { randomUUID as randomUUID16 } from "crypto";
15981
16018
  import { existsSync as existsSync22, mkdirSync as mkdirSync21, readdirSync as readdirSync7, statSync as statSync10 } from "fs";
15982
- import { join as join31 } from "path";
16019
+ import { join as join32 } from "path";
15983
16020
  function withDefaultPlaywright(configuredMcp, isManager) {
15984
16021
  if (isManager)
15985
16022
  return configuredMcp;
@@ -16034,7 +16071,7 @@ function appendAskReplyMessage(topicId, text2, agentType) {
16034
16071
  return message;
16035
16072
  }
16036
16073
  function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
16037
- const preferred = join31(directory, preferredFilename);
16074
+ const preferred = join32(directory, preferredFilename);
16038
16075
  if (preferExact && existsSync22(preferred))
16039
16076
  return preferred;
16040
16077
  let newestLegacyId = null;
@@ -16045,7 +16082,7 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
16045
16082
  const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
16046
16083
  if (!titleMatch && !legacyIdMatch)
16047
16084
  continue;
16048
- const path = join31(directory, filename);
16085
+ const path = join32(directory, filename);
16049
16086
  const mtimeMs = statSync10(path).mtimeMs;
16050
16087
  if (titleMatch) {
16051
16088
  if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
@@ -16059,9 +16096,9 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
16059
16096
  return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
16060
16097
  }
16061
16098
  function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
16062
- const briefFile = resolveWikiMirrorPath(join31(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
16099
+ const briefFile = resolveWikiMirrorPath(join32(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
16063
16100
  const hasBriefFile = existsSync22(briefFile) && statSync10(briefFile).isFile();
16064
- const latestSummaryCandidate = resolveWikiMirrorPath(join31(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
16101
+ const latestSummaryCandidate = resolveWikiMirrorPath(join32(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
16065
16102
  const latestSummaryFile = existsSync22(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
16066
16103
  return { briefFile, hasBriefFile, latestSummaryFile };
16067
16104
  }
@@ -17259,8 +17296,8 @@ __export(exports_auth_check, {
17259
17296
  });
17260
17297
  import { execFileSync as execFileSync7 } from "child_process";
17261
17298
  import { existsSync as existsSync23 } from "fs";
17262
- import { homedir as homedir8, platform } from "os";
17263
- import { join as join32 } from "path";
17299
+ import { homedir as homedir9, platform } from "os";
17300
+ import { join as join33 } from "path";
17264
17301
  function hasMaestroCredential(host, key, userId) {
17265
17302
  if (userId && host.getVaultValue(userId, key)?.trim())
17266
17303
  return true;
@@ -17280,7 +17317,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
17280
17317
  case "claude": {
17281
17318
  if (host.environment.ANTHROPIC_API_KEY)
17282
17319
  return { ok: true };
17283
- const path = join32(host.homeDirectory(), ".claude", ".credentials.json");
17320
+ const path = join33(host.homeDirectory(), ".claude", ".credentials.json");
17284
17321
  if (host.operatingSystem() === "darwin") {
17285
17322
  if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
17286
17323
  return { ok: true };
@@ -17333,7 +17370,7 @@ var init_auth_check = __esm(async () => {
17333
17370
  codexAuthFilePath,
17334
17371
  exists: existsSync23,
17335
17372
  environment: process.env,
17336
- homeDirectory: homedir8,
17373
+ homeDirectory: homedir9,
17337
17374
  operatingSystem: platform,
17338
17375
  hasMacOsCredential(service) {
17339
17376
  try {
@@ -20211,7 +20248,7 @@ init_jsonl();
20211
20248
  init_mcp_helpers();
20212
20249
  import { spawn as spawn4 } from "child_process";
20213
20250
  import { existsSync as existsSync10, readdirSync as readdirSync3 } from "fs";
20214
- import { join as join11 } from "path";
20251
+ import { join as join12 } from "path";
20215
20252
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
20216
20253
  import { z } from "zod";
20217
20254
  function signalProcessTree(child, signal) {
@@ -20464,7 +20501,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
20464
20501
  server.tool("list_active_queries", "\uD604\uC7AC \uC0AC\uC6A9\uC790 \uBC94\uC704\uC5D0\uC11C \uC2E4\uD589 \uC911\uC778 \uD1A0\uD53D \uCFFC\uB9AC \uBAA9\uB85D\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4.", {}, async () => {
20465
20502
  if (!context.userId)
20466
20503
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
20467
- const stateDir = join11(USERS_LOG_DIR, context.userId, "active-queries");
20504
+ const stateDir = join12(USERS_LOG_DIR, context.userId, "active-queries");
20468
20505
  if (!existsSync10(stateDir))
20469
20506
  return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
20470
20507
  let files;
@@ -20477,7 +20514,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
20477
20514
  const entries = files.flatMap((file) => {
20478
20515
  if (!file.endsWith(".json"))
20479
20516
  return [];
20480
- const state = readJsonFile(join11(stateDir, file));
20517
+ const state = readJsonFile(join12(stateDir, file));
20481
20518
  if (!state)
20482
20519
  return [];
20483
20520
  const sinceMs = new Date(state.since).getTime();
@@ -20612,7 +20649,7 @@ import { z as z3 } from "zod";
20612
20649
  init_logger();
20613
20650
  await init_storage_host();
20614
20651
  import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync7 } from "fs";
20615
- import { dirname as dirname8, join as join12 } from "path";
20652
+ import { dirname as dirname8, join as join13 } from "path";
20616
20653
  var DECISION_STATUS_VALUES = [
20617
20654
  "proposed",
20618
20655
  "accepted",
@@ -20631,7 +20668,7 @@ function decisionScopeKey(opts) {
20631
20668
  return opts.topicId?.trim() || opts.session || "default";
20632
20669
  }
20633
20670
  function getDecisionFilePath(userId, scopeKey) {
20634
- return join12(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
20671
+ return join13(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
20635
20672
  }
20636
20673
  function readDecisions(userId, scopeKey) {
20637
20674
  const path = getDecisionFilePath(userId, scopeKey);
@@ -21361,4 +21398,4 @@ export {
21361
21398
  createAgentHealthMcpServer
21362
21399
  };
21363
21400
 
21364
- //# debugId=3C9958DCA4DDE01364756E2164756E21
21401
+ //# debugId=1DC9C5A25C04420964756E2164756E21