negotium 0.4.2 → 0.4.4
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/agent-helpers.js +143 -165
- package/dist/agent-helpers.js.map +6 -6
- package/dist/background-bash.js +2 -2
- package/dist/background-bash.js.map +2 -2
- package/dist/browser-runtime.js +2 -2
- package/dist/browser-runtime.js.map +2 -2
- package/dist/{chunk-238qj1qy.js → chunk-dttcv3n7.js} +27 -52
- package/dist/{chunk-238qj1qy.js.map → chunk-dttcv3n7.js.map} +5 -5
- package/dist/hosted-agent.js +50 -73
- package/dist/hosted-agent.js.map +7 -7
- package/dist/main.js +190 -127
- package/dist/main.js.map +8 -8
- package/dist/mcp-factories.js +125 -147
- package/dist/mcp-factories.js.map +6 -6
- package/dist/prompts.js +2 -2
- package/dist/prompts.js.map +2 -2
- package/dist/query-runtime.js +2 -2
- package/dist/query-runtime.js.map +2 -2
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/codex-provider.ts +12 -6
- package/dist/runtime/src/node-host.ts +5 -1
- package/dist/runtime/src/platform/config.ts +1 -1
- package/dist/runtime/src/platform/mcp-config.ts +19 -44
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +2 -2
- package/dist/runtime-helpers.js.map +2 -2
- package/dist/types/packages/core/src/platform/config.d.ts +1 -1
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +1 -9
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +2 -2
- package/dist/vault.js.map +2 -2
- package/install-browser-rs.mjs +3 -3
- package/package.json +1 -1
package/dist/agent-helpers.js
CHANGED
|
@@ -335,7 +335,7 @@ function resolveDefaultModel(agent, registryDefaultModel) {
|
|
|
335
335
|
function codexAuthFilePath() {
|
|
336
336
|
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
|
|
337
337
|
}
|
|
338
|
-
var HOME, PROJECT_ROOT, STATE_DIR_ENV, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.1.
|
|
338
|
+
var HOME, PROJECT_ROOT, STATE_DIR_ENV, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.1.22", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.7", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, BROWSER_MCP_SSE_PROXY_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, _envMaxTellDepth, MAX_TELL_DEPTH;
|
|
339
339
|
var init_config = __esm(() => {
|
|
340
340
|
init_config_helpers();
|
|
341
341
|
init_logger();
|
|
@@ -841,9 +841,6 @@ function browserOwnerCapability(capability, owner) {
|
|
|
841
841
|
var init_capability = () => {};
|
|
842
842
|
|
|
843
843
|
// ../../packages/core/src/platform/mcp-config.ts
|
|
844
|
-
import { accessSync as accessSync2, constants as fsConstants } from "fs";
|
|
845
|
-
import { homedir as homedir2 } from "os";
|
|
846
|
-
import { join as join2 } from "path";
|
|
847
844
|
function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
|
|
848
845
|
if (agent === "codex") {
|
|
849
846
|
return {
|
|
@@ -941,6 +938,9 @@ function playwrightTransport(port, owner, capability, agent) {
|
|
|
941
938
|
function longLivedHttpMcp(agent, port) {
|
|
942
939
|
return agent === "codex" ? { url: `http://127.0.0.1:${port}/mcp` } : { type: "sse", url: `http://127.0.0.1:${port}/sse` };
|
|
943
940
|
}
|
|
941
|
+
function cuaRsHttpMcp(port) {
|
|
942
|
+
return { type: "http", url: `http://127.0.0.1:${port}/mcp` };
|
|
943
|
+
}
|
|
944
944
|
function backgroundBashTransport(agent, port, userId, topic) {
|
|
945
945
|
const capability = bgBashContextCapability(userId, topic);
|
|
946
946
|
const headers = {
|
|
@@ -956,27 +956,6 @@ function backgroundBashTransport(agent, port, userId, topic) {
|
|
|
956
956
|
}
|
|
957
957
|
return { type: "sse", url: `http://127.0.0.1:${port}/sse`, headers };
|
|
958
958
|
}
|
|
959
|
-
function cuaRsArgs() {
|
|
960
|
-
const raw = envText("NEGOTIUM_CUA_RS_ALLOW_HID")?.trim().toLowerCase();
|
|
961
|
-
const on = raw === "1" || raw === "true" || raw === "yes";
|
|
962
|
-
return on ? ["--allow-hid"] : [];
|
|
963
|
-
}
|
|
964
|
-
function resolveCuaRsBinary(platform = process.platform) {
|
|
965
|
-
if (platform !== "darwin")
|
|
966
|
-
return null;
|
|
967
|
-
const candidates = [
|
|
968
|
-
envText("NEGOTIUM_CUA_RS_BIN"),
|
|
969
|
-
join2(homedir2(), ".local", "bin", "cua-rs"),
|
|
970
|
-
"/usr/local/bin/cua-rs"
|
|
971
|
-
].filter((p) => Boolean(p));
|
|
972
|
-
for (const candidate of candidates) {
|
|
973
|
-
try {
|
|
974
|
-
accessSync2(candidate, fsConstants.X_OK);
|
|
975
|
-
return candidate;
|
|
976
|
-
} catch {}
|
|
977
|
-
}
|
|
978
|
-
return null;
|
|
979
|
-
}
|
|
980
959
|
function refreshForumCatalogViews() {
|
|
981
960
|
const { all, required, optional } = classifyForumMcpServers(MCP_CATALOG);
|
|
982
961
|
allForumMcpServerNames.splice(0, allForumMcpServerNames.length, ...all);
|
|
@@ -1195,7 +1174,7 @@ function getMcpServersForQuery(opts) {
|
|
|
1195
1174
|
peerBridge: opts.peerBridge
|
|
1196
1175
|
});
|
|
1197
1176
|
}
|
|
1198
|
-
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, CODEX_BROWSER_CAPABILITY_ENV = "NEGOTIUM_BROWSER_CAPABILITY", MCP_CATALOG, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers, nodeMcpEntries;
|
|
1177
|
+
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, CODEX_BROWSER_CAPABILITY_ENV = "NEGOTIUM_BROWSER_CAPABILITY", cuaRsMcpPort, MCP_CATALOG, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers, nodeMcpEntries;
|
|
1199
1178
|
var init_mcp_config = __esm(() => {
|
|
1200
1179
|
init_canonical_bridge_config();
|
|
1201
1180
|
init_runtime_spec();
|
|
@@ -1414,10 +1393,7 @@ var init_mcp_config = __esm(() => {
|
|
|
1414
1393
|
"cua-rs": {
|
|
1415
1394
|
...commonRuntimeMcpPolicy("cua-rs"),
|
|
1416
1395
|
build() {
|
|
1417
|
-
|
|
1418
|
-
if (!bin)
|
|
1419
|
-
return null;
|
|
1420
|
-
return { command: bin, args: cuaRsArgs() };
|
|
1396
|
+
return cuaRsMcpPort ? cuaRsHttpMcp(cuaRsMcpPort) : null;
|
|
1421
1397
|
}
|
|
1422
1398
|
}
|
|
1423
1399
|
};
|
|
@@ -1484,8 +1460,8 @@ var init_sqlite = __esm(async () => {
|
|
|
1484
1460
|
|
|
1485
1461
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1486
1462
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
1487
|
-
import { homedir as
|
|
1488
|
-
import { dirname as dirname2, join as
|
|
1463
|
+
import { homedir as homedir2 } from "os";
|
|
1464
|
+
import { dirname as dirname2, join as join2, resolve as resolve3 } from "path";
|
|
1489
1465
|
function storageState() {
|
|
1490
1466
|
const holder = globalThis;
|
|
1491
1467
|
const existing = holder[STORAGE_HOST_STATE];
|
|
@@ -1513,23 +1489,23 @@ function envPath(name, fallback) {
|
|
|
1513
1489
|
return resolve3(value || fallback);
|
|
1514
1490
|
}
|
|
1515
1491
|
function defaultStateDir() {
|
|
1516
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
1492
|
+
return envPath("NEGOTIUM_STATE_DIR", join2(homedir2(), ".negotium"));
|
|
1517
1493
|
}
|
|
1518
1494
|
function defaultDataDir() {
|
|
1519
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
1495
|
+
return envPath("NEGOTIUM_DATA_DIR", join2(defaultStateDir(), "data"));
|
|
1520
1496
|
}
|
|
1521
1497
|
function defaultLogDir() {
|
|
1522
|
-
return envPath("NEGOTIUM_LOG_DIR",
|
|
1498
|
+
return envPath("NEGOTIUM_LOG_DIR", join2(defaultStateDir(), "logs"));
|
|
1523
1499
|
}
|
|
1524
1500
|
function defaultWorkspaceDir() {
|
|
1525
|
-
return envPath("NEGOTIUM_WORKSPACE_DIR",
|
|
1501
|
+
return envPath("NEGOTIUM_WORKSPACE_DIR", join2(defaultStateDir(), "workspace"));
|
|
1526
1502
|
}
|
|
1527
1503
|
function defaultSessionAsksDir() {
|
|
1528
|
-
const runDir = envPath("NEGOTIUM_RUN_DIR",
|
|
1529
|
-
return
|
|
1504
|
+
const runDir = envPath("NEGOTIUM_RUN_DIR", join2(defaultStateDir(), "runtime"));
|
|
1505
|
+
return join2(runDir, "session-asks");
|
|
1530
1506
|
}
|
|
1531
1507
|
function defaultSessionsDatabasePath() {
|
|
1532
|
-
return envPath("SESSIONS_DB_PATH",
|
|
1508
|
+
return envPath("SESSIONS_DB_PATH", join2(resolveStorageDataDir(), "sessions.db"));
|
|
1533
1509
|
}
|
|
1534
1510
|
function isSqliteBusy(error) {
|
|
1535
1511
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1586,7 +1562,7 @@ function resolveStorageWorkspaceDir() {
|
|
|
1586
1562
|
return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
1587
1563
|
}
|
|
1588
1564
|
function resolveStorageSharedWikiDir() {
|
|
1589
|
-
return storageState().configuredHost.sharedWikiDir ??
|
|
1565
|
+
return storageState().configuredHost.sharedWikiDir ?? join2(resolveStorageWorkspaceDir(), "wiki");
|
|
1590
1566
|
}
|
|
1591
1567
|
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
1592
1568
|
const initializers = storageState().schemaInitializers;
|
|
@@ -1696,7 +1672,7 @@ var init_vault_crypto = __esm(() => {
|
|
|
1696
1672
|
|
|
1697
1673
|
// ../../packages/core/src/storage/vault.ts
|
|
1698
1674
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync3 } from "fs";
|
|
1699
|
-
import { join as
|
|
1675
|
+
import { join as join3 } from "path";
|
|
1700
1676
|
function initializeVaultDatabase(database) {
|
|
1701
1677
|
database.exec("PRAGMA journal_mode = WAL");
|
|
1702
1678
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -1731,8 +1707,8 @@ function initializeVaultDatabase(database) {
|
|
|
1731
1707
|
}
|
|
1732
1708
|
}
|
|
1733
1709
|
function openVaultDatabase(dataDir) {
|
|
1734
|
-
const vaultDir =
|
|
1735
|
-
const path =
|
|
1710
|
+
const vaultDir = join3(dataDir, "vault");
|
|
1711
|
+
const path = join3(vaultDir, "vault.db");
|
|
1736
1712
|
mkdirSync3(vaultDir, { recursive: true, mode: 448 });
|
|
1737
1713
|
const database = new Database(path, { create: true });
|
|
1738
1714
|
chmodSync2(path, 384);
|
|
@@ -2239,12 +2215,12 @@ var init_jsonl = __esm(() => {
|
|
|
2239
2215
|
// ../../packages/core/src/agents/rollout/claude.ts
|
|
2240
2216
|
import { randomUUID } from "crypto";
|
|
2241
2217
|
import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
2242
|
-
import { homedir as
|
|
2243
|
-
import { join as
|
|
2218
|
+
import { homedir as homedir3 } from "os";
|
|
2219
|
+
import { join as join4 } from "path";
|
|
2244
2220
|
function loadClaudeAttachments() {
|
|
2245
2221
|
if (_attachmentsCache)
|
|
2246
2222
|
return _attachmentsCache;
|
|
2247
|
-
const raw = readFileSync3(
|
|
2223
|
+
const raw = readFileSync3(join4(FIXTURES_DIR, "claude-attachments.jsonl"), "utf8");
|
|
2248
2224
|
const lines = parseJsonlText(raw);
|
|
2249
2225
|
if (lines.length < 2) {
|
|
2250
2226
|
throw new Error(`loadClaudeAttachments: expected >=2 entries in claude-attachments.jsonl, got ${lines.length}`);
|
|
@@ -2345,8 +2321,8 @@ function writeClaudeRollout(opts) {
|
|
|
2345
2321
|
});
|
|
2346
2322
|
lastUuid = assistantUuid;
|
|
2347
2323
|
}
|
|
2348
|
-
const projectsDir =
|
|
2349
|
-
const path =
|
|
2324
|
+
const projectsDir = join4(homedir3(), ".claude", "projects", encodeClaudeCwd(opts.cwd));
|
|
2325
|
+
const path = join4(projectsDir, `${sessionId}.jsonl`);
|
|
2350
2326
|
writeJsonlFile(path, lines);
|
|
2351
2327
|
logger.info({ sessionId, path, pairs: pairs.length }, "writeClaudeRollout: synthetic rollout placed");
|
|
2352
2328
|
return { sessionId, rolloutPath: path };
|
|
@@ -2360,8 +2336,8 @@ var init_claude = __esm(() => {
|
|
|
2360
2336
|
|
|
2361
2337
|
// ../../packages/core/src/agents/claude-registry.ts
|
|
2362
2338
|
import { existsSync as existsSync3, mkdirSync as mkdirSync6, readdirSync, renameSync as renameSync2, unlinkSync as unlinkSync3 } from "fs";
|
|
2363
|
-
import { homedir as
|
|
2364
|
-
import { join as
|
|
2339
|
+
import { homedir as homedir4 } from "os";
|
|
2340
|
+
import { join as join5 } from "path";
|
|
2365
2341
|
var ALIAS_MAP, VALID_ALIASES, VALID_EFFORTS, claudeRegistry, claudeRegistryOperations;
|
|
2366
2342
|
var init_claude_registry = __esm(() => {
|
|
2367
2343
|
init_claude();
|
|
@@ -2408,11 +2384,11 @@ var init_claude_registry = __esm(() => {
|
|
|
2408
2384
|
const result = await forkSession(parentSessionId, {
|
|
2409
2385
|
...title ? { title } : {}
|
|
2410
2386
|
});
|
|
2411
|
-
const projectsRoot =
|
|
2412
|
-
const destDir =
|
|
2413
|
-
const destPath =
|
|
2387
|
+
const projectsRoot = join5(homedir4(), ".claude", "projects");
|
|
2388
|
+
const destDir = join5(projectsRoot, encodeClaudeCwd(cwd));
|
|
2389
|
+
const destPath = join5(destDir, `${result.sessionId}.jsonl`);
|
|
2414
2390
|
if (!existsSync3(destPath)) {
|
|
2415
|
-
const sourcePath = readdirSync(projectsRoot).map((d) =>
|
|
2391
|
+
const sourcePath = readdirSync(projectsRoot).map((d) => join5(projectsRoot, d, `${result.sessionId}.jsonl`)).find((p) => existsSync3(p));
|
|
2416
2392
|
if (!sourcePath) {
|
|
2417
2393
|
throw new Error(`claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`);
|
|
2418
2394
|
}
|
|
@@ -2425,10 +2401,10 @@ var init_claude_registry = __esm(() => {
|
|
|
2425
2401
|
};
|
|
2426
2402
|
},
|
|
2427
2403
|
async cleanupRollouts({ cwd, sessionIds }) {
|
|
2428
|
-
const projectsDir =
|
|
2404
|
+
const projectsDir = join5(homedir4(), ".claude", "projects", encodeClaudeCwd(cwd));
|
|
2429
2405
|
const failures = [];
|
|
2430
2406
|
for (const sid of sessionIds) {
|
|
2431
|
-
const path =
|
|
2407
|
+
const path = join5(projectsDir, `${sid}.jsonl`);
|
|
2432
2408
|
try {
|
|
2433
2409
|
unlinkSync3(path);
|
|
2434
2410
|
} catch (e) {
|
|
@@ -2446,7 +2422,7 @@ var init_claude_registry = __esm(() => {
|
|
|
2446
2422
|
});
|
|
2447
2423
|
|
|
2448
2424
|
// ../../packages/core/src/version.ts
|
|
2449
|
-
var NEGOTIUM_VERSION = "0.4.
|
|
2425
|
+
var NEGOTIUM_VERSION = "0.4.4";
|
|
2450
2426
|
|
|
2451
2427
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
2452
2428
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -2464,7 +2440,7 @@ import {
|
|
|
2464
2440
|
} from "fs";
|
|
2465
2441
|
import { createRequire as createRequire2 } from "module";
|
|
2466
2442
|
import { tmpdir } from "os";
|
|
2467
|
-
import { dirname as dirname5, join as
|
|
2443
|
+
import { dirname as dirname5, join as join6 } from "path";
|
|
2468
2444
|
function readPackageVersion(packageJsonPath) {
|
|
2469
2445
|
const parsed = JSON.parse(readFileSync4(packageJsonPath, "utf8"));
|
|
2470
2446
|
if (typeof parsed.version !== "string" || !parsed.version.trim()) {
|
|
@@ -2473,7 +2449,7 @@ function readPackageVersion(packageJsonPath) {
|
|
|
2473
2449
|
return parsed.version;
|
|
2474
2450
|
}
|
|
2475
2451
|
function codexCliScriptPath() {
|
|
2476
|
-
return
|
|
2452
|
+
return join6(dirname5(bundledCodexPackagePath), "bin", "codex.js");
|
|
2477
2453
|
}
|
|
2478
2454
|
function parseCodexModelCache(contents, sourcePath) {
|
|
2479
2455
|
let parsed;
|
|
@@ -2514,7 +2490,7 @@ function writePrivateFileAtomic(path, contents) {
|
|
|
2514
2490
|
}
|
|
2515
2491
|
}
|
|
2516
2492
|
function bundledCodexModelCachePath(authFilePath) {
|
|
2517
|
-
return
|
|
2493
|
+
return join6(dirname5(authFilePath), NEGOTIUM_MODEL_CACHE);
|
|
2518
2494
|
}
|
|
2519
2495
|
async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
2520
2496
|
const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
|
|
@@ -2600,15 +2576,15 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
2600
2576
|
}
|
|
2601
2577
|
async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
2602
2578
|
const sourceHome = dirname5(authFilePath);
|
|
2603
|
-
const isolatedHome = mkdtempSync(
|
|
2604
|
-
const isolatedCachePath =
|
|
2579
|
+
const isolatedHome = mkdtempSync(join6(tmpdir(), "negotium-codex-models-"));
|
|
2580
|
+
const isolatedCachePath = join6(isolatedHome, "models_cache.json");
|
|
2605
2581
|
try {
|
|
2606
|
-
const isolatedAuthPath =
|
|
2582
|
+
const isolatedAuthPath = join6(isolatedHome, "auth.json");
|
|
2607
2583
|
copyFileSync(authFilePath, isolatedAuthPath);
|
|
2608
2584
|
chmodSync3(isolatedAuthPath, 384);
|
|
2609
|
-
const sourceConfigPath =
|
|
2585
|
+
const sourceConfigPath = join6(sourceHome, "config.toml");
|
|
2610
2586
|
if (existsSync4(sourceConfigPath)) {
|
|
2611
|
-
const isolatedConfigPath =
|
|
2587
|
+
const isolatedConfigPath = join6(isolatedHome, "config.toml");
|
|
2612
2588
|
copyFileSync(sourceConfigPath, isolatedConfigPath);
|
|
2613
2589
|
chmodSync3(isolatedConfigPath, 384);
|
|
2614
2590
|
}
|
|
@@ -2629,7 +2605,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
2629
2605
|
return configuredCachePath;
|
|
2630
2606
|
}
|
|
2631
2607
|
const bundledCachePath = bundledCodexModelCachePath(authFilePath);
|
|
2632
|
-
const sharedCachePath =
|
|
2608
|
+
const sharedCachePath = join6(codexHome, "models_cache.json");
|
|
2633
2609
|
if (existsSync4(sharedCachePath)) {
|
|
2634
2610
|
try {
|
|
2635
2611
|
const shared = readCompatibleCodexModelCache(sharedCachePath);
|
|
@@ -2649,7 +2625,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
2649
2625
|
}
|
|
2650
2626
|
function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
|
|
2651
2627
|
const codexHome = dirname5(authFilePath);
|
|
2652
|
-
const outputPath =
|
|
2628
|
+
const outputPath = join6(codexHome, NEGOTIUM_MODEL_CATALOG);
|
|
2653
2629
|
const parsed = readCodexModelCache(sourcePath).parsed;
|
|
2654
2630
|
const models = parsed.models.map((model, index) => {
|
|
2655
2631
|
if (!model || typeof model !== "object" || Array.isArray(model)) {
|
|
@@ -2677,14 +2653,14 @@ var init_codex_native_multi_agent = __esm(() => {
|
|
|
2677
2653
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2678
2654
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
2679
2655
|
import { existsSync as existsSync5, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync2, unlinkSync as unlinkSync5 } from "fs";
|
|
2680
|
-
import { basename, dirname as dirname6, join as
|
|
2656
|
+
import { basename, dirname as dirname6, join as join7, resolve as resolve5 } from "path";
|
|
2681
2657
|
function codexSessionsDir() {
|
|
2682
|
-
return
|
|
2658
|
+
return join7(hostedCodexHomePath(), "sessions");
|
|
2683
2659
|
}
|
|
2684
2660
|
function loadCodexShell() {
|
|
2685
2661
|
if (_shellCache)
|
|
2686
2662
|
return _shellCache;
|
|
2687
|
-
const raw = readFileSync5(
|
|
2663
|
+
const raw = readFileSync5(join7(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
2688
2664
|
const lines = parseJsonlText(raw);
|
|
2689
2665
|
if (lines.length < 5) {
|
|
2690
2666
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -2751,8 +2727,8 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
2751
2727
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
2752
2728
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
2753
2729
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
2754
|
-
const dir =
|
|
2755
|
-
return
|
|
2730
|
+
const dir = join7(codexSessionsDir(), yyyy, mm, dd);
|
|
2731
|
+
return join7(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
2756
2732
|
}
|
|
2757
2733
|
function canonicalFilePath(path) {
|
|
2758
2734
|
const absolute = resolve5(path);
|
|
@@ -2760,7 +2736,7 @@ function canonicalFilePath(path) {
|
|
|
2760
2736
|
return realpathSync2(absolute);
|
|
2761
2737
|
} catch {
|
|
2762
2738
|
try {
|
|
2763
|
-
return
|
|
2739
|
+
return join7(realpathSync2(dirname6(absolute)), basename(absolute));
|
|
2764
2740
|
} catch {
|
|
2765
2741
|
return absolute;
|
|
2766
2742
|
}
|
|
@@ -2990,19 +2966,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
2990
2966
|
try {
|
|
2991
2967
|
if (buckets) {
|
|
2992
2968
|
for (const bucket of buckets) {
|
|
2993
|
-
const dir =
|
|
2969
|
+
const dir = join7(sessionsDir, bucket);
|
|
2994
2970
|
if (!existsSync5(dir))
|
|
2995
2971
|
continue;
|
|
2996
2972
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
2997
2973
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
2998
|
-
candidates.push(
|
|
2974
|
+
candidates.push(join7(dir, rel));
|
|
2999
2975
|
}
|
|
3000
2976
|
}
|
|
3001
2977
|
}
|
|
3002
2978
|
if (candidates.length === 0) {
|
|
3003
2979
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3004
2980
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3005
|
-
candidates.push(
|
|
2981
|
+
candidates.push(join7(sessionsDir, rel));
|
|
3006
2982
|
}
|
|
3007
2983
|
}
|
|
3008
2984
|
return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
|
|
@@ -3123,13 +3099,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
3123
3099
|
return;
|
|
3124
3100
|
}
|
|
3125
3101
|
for (const bucket of buckets) {
|
|
3126
|
-
const dir =
|
|
3102
|
+
const dir = join7(sessionsDir, bucket);
|
|
3127
3103
|
if (!existsSync5(dir))
|
|
3128
3104
|
continue;
|
|
3129
3105
|
try {
|
|
3130
3106
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3131
3107
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3132
|
-
const fullPath =
|
|
3108
|
+
const fullPath = join7(dir, rel);
|
|
3133
3109
|
try {
|
|
3134
3110
|
unlinkSync5(fullPath);
|
|
3135
3111
|
} catch (e) {
|
|
@@ -3147,7 +3123,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
3147
3123
|
try {
|
|
3148
3124
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3149
3125
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3150
|
-
const fullPath =
|
|
3126
|
+
const fullPath = join7(sessionsDir, rel);
|
|
3151
3127
|
try {
|
|
3152
3128
|
unlinkSync5(fullPath);
|
|
3153
3129
|
} catch (e) {
|
|
@@ -3325,7 +3301,7 @@ var init_codex_app_server = __esm(async () => {
|
|
|
3325
3301
|
|
|
3326
3302
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
3327
3303
|
import { existsSync as existsSync6, unlinkSync as unlinkSync6 } from "fs";
|
|
3328
|
-
import { join as
|
|
3304
|
+
import { join as join8 } from "path";
|
|
3329
3305
|
var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
|
|
3330
3306
|
var init_codex_registry = __esm(async () => {
|
|
3331
3307
|
await init_codex_app_server();
|
|
@@ -3368,7 +3344,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3368
3344
|
async cleanupRollouts({ sessionIds }) {
|
|
3369
3345
|
if (sessionIds.length === 0)
|
|
3370
3346
|
return;
|
|
3371
|
-
const sessionsDir =
|
|
3347
|
+
const sessionsDir = join8(hostedCodexHomePath(), "sessions");
|
|
3372
3348
|
if (!existsSync6(sessionsDir))
|
|
3373
3349
|
return;
|
|
3374
3350
|
const failures = [];
|
|
@@ -3376,7 +3352,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3376
3352
|
try {
|
|
3377
3353
|
const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
|
|
3378
3354
|
for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3379
|
-
const path =
|
|
3355
|
+
const path = join8(sessionsDir, rel);
|
|
3380
3356
|
try {
|
|
3381
3357
|
unlinkSync6(path);
|
|
3382
3358
|
} catch (e) {
|
|
@@ -3401,16 +3377,16 @@ var init_codex_registry = __esm(async () => {
|
|
|
3401
3377
|
// ../../packages/core/src/agents/maestro-registry.ts
|
|
3402
3378
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
3403
3379
|
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
3404
|
-
import { homedir as
|
|
3405
|
-
import { join as
|
|
3380
|
+
import { homedir as homedir5 } from "os";
|
|
3381
|
+
import { join as join9, resolve as resolve6 } from "path";
|
|
3406
3382
|
function maestroSessionsDir() {
|
|
3407
|
-
return
|
|
3383
|
+
return join9(process.env.MAESTRO_DATA_DIR ? resolve6(process.env.MAESTRO_DATA_DIR) : join9(homedir5(), ".maestro"), "sessions");
|
|
3408
3384
|
}
|
|
3409
3385
|
function maestroSessionPath(sessionId) {
|
|
3410
|
-
return
|
|
3386
|
+
return join9(maestroSessionsDir(), `${sessionId}.jsonl`);
|
|
3411
3387
|
}
|
|
3412
3388
|
function maestroActiveSessionPath(sessionId) {
|
|
3413
|
-
return
|
|
3389
|
+
return join9(maestroSessionsDir(), `${sessionId}.active.jsonl`);
|
|
3414
3390
|
}
|
|
3415
3391
|
function existingCreatedAt(path) {
|
|
3416
3392
|
if (!existsSync7(path))
|
|
@@ -3586,7 +3562,7 @@ function sanitizeId(id) {
|
|
|
3586
3562
|
|
|
3587
3563
|
// ../../packages/core/src/storage/tasks.ts
|
|
3588
3564
|
import { existsSync as existsSync8, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
3589
|
-
import { dirname as dirname7, join as
|
|
3565
|
+
import { dirname as dirname7, join as join10 } from "path";
|
|
3590
3566
|
function safeTaskScopeKey(scopeKey) {
|
|
3591
3567
|
const safe = sanitizeFileName(scopeKey);
|
|
3592
3568
|
if (!safe || safe === "." || safe === "..") {
|
|
@@ -3598,7 +3574,7 @@ function taskScopeKey(opts) {
|
|
|
3598
3574
|
return opts.topicId?.trim() || opts.session || "default";
|
|
3599
3575
|
}
|
|
3600
3576
|
function getTaskFilePath(userId, scopeKey) {
|
|
3601
|
-
return
|
|
3577
|
+
return join10(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
|
|
3602
3578
|
}
|
|
3603
3579
|
function readTasks(userId, scopeKey) {
|
|
3604
3580
|
const path = getTaskFilePath(userId, scopeKey);
|
|
@@ -3674,16 +3650,16 @@ import {
|
|
|
3674
3650
|
unlinkSync as unlinkSync7,
|
|
3675
3651
|
writeFileSync as writeFileSync7
|
|
3676
3652
|
} from "fs";
|
|
3677
|
-
import { dirname as dirname8, join as
|
|
3653
|
+
import { dirname as dirname8, join as join11 } from "path";
|
|
3678
3654
|
function conversationDir(_userId) {
|
|
3679
|
-
return
|
|
3655
|
+
return join11(resolveStorageDataDir(), "conversations");
|
|
3680
3656
|
}
|
|
3681
3657
|
function topicFilename(topicName) {
|
|
3682
3658
|
const t = sanitizeTopicName(topicName, true);
|
|
3683
3659
|
return `${t}.jsonl`;
|
|
3684
3660
|
}
|
|
3685
3661
|
function getConversationPath(userId, topicName) {
|
|
3686
|
-
return
|
|
3662
|
+
return join11(conversationDir(userId), topicFilename(topicName));
|
|
3687
3663
|
}
|
|
3688
3664
|
function getActiveConversationPath(userId, topicName) {
|
|
3689
3665
|
const rawPath = getConversationPath(userId, topicName);
|
|
@@ -4617,7 +4593,7 @@ import { existsSync as existsSync11 } from "fs";
|
|
|
4617
4593
|
import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
|
|
4618
4594
|
import { createServer } from "net";
|
|
4619
4595
|
import { tmpdir as tmpdir2 } from "os";
|
|
4620
|
-
import { dirname as dirname9, join as
|
|
4596
|
+
import { dirname as dirname9, join as join12, resolve as resolve7 } from "path";
|
|
4621
4597
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4622
4598
|
function evaluateCodexVaultPreToolUse(input, userId, operations) {
|
|
4623
4599
|
if (operations.referencesSensitiveStorage(input.tool_input)) {
|
|
@@ -4670,10 +4646,10 @@ function privateCodexWrapper(codexScript, socketPath, token) {
|
|
|
4670
4646
|
`);
|
|
4671
4647
|
}
|
|
4672
4648
|
async function createCodexVaultHookBridge(userId) {
|
|
4673
|
-
const root = await mkdtemp(
|
|
4649
|
+
const root = await mkdtemp(join12(tmpdir2(), "negotium-codex-vault-"));
|
|
4674
4650
|
await chmod(root, 448);
|
|
4675
|
-
const socketPath =
|
|
4676
|
-
const wrapperPath =
|
|
4651
|
+
const socketPath = join12(root, "hook.sock");
|
|
4652
|
+
const wrapperPath = join12(root, "codex-with-hooks");
|
|
4677
4653
|
const token = randomBytes5(32).toString("hex");
|
|
4678
4654
|
const connections = new Set;
|
|
4679
4655
|
const server = createServer((socket) => {
|
|
@@ -5290,8 +5266,8 @@ __export(exports_codex_provider, {
|
|
|
5290
5266
|
});
|
|
5291
5267
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
5292
5268
|
import { existsSync as existsSync12, readFileSync as readFileSync11, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
|
|
5293
|
-
import { homedir as
|
|
5294
|
-
import { dirname as dirname10, isAbsolute as isAbsolute2, join as
|
|
5269
|
+
import { homedir as homedir6 } from "os";
|
|
5270
|
+
import { dirname as dirname10, isAbsolute as isAbsolute2, join as join13, relative, resolve as resolve9 } from "path";
|
|
5295
5271
|
import { Codex } from "@openai/codex-sdk";
|
|
5296
5272
|
function sameCodexUsage(usage, total) {
|
|
5297
5273
|
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;
|
|
@@ -5319,7 +5295,7 @@ function codexMcpServerName(name) {
|
|
|
5319
5295
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
5320
5296
|
}
|
|
5321
5297
|
function globalCodexMcpServerNames(authFilePath) {
|
|
5322
|
-
const configPath =
|
|
5298
|
+
const configPath = join13(dirname10(authFilePath), "config.toml");
|
|
5323
5299
|
if (!existsSync12(configPath))
|
|
5324
5300
|
return [];
|
|
5325
5301
|
try {
|
|
@@ -5359,15 +5335,16 @@ function withCodexMcpServerOverrides(_name, server) {
|
|
|
5359
5335
|
};
|
|
5360
5336
|
}
|
|
5361
5337
|
function toCodexMcpServers(claudeShape) {
|
|
5362
|
-
const
|
|
5338
|
+
const disabledStdio = () => ({
|
|
5363
5339
|
command: process.execPath,
|
|
5364
5340
|
args: ["-e", "process.exit(0)"],
|
|
5365
5341
|
enabled: false
|
|
5366
5342
|
});
|
|
5367
5343
|
const out = {
|
|
5368
|
-
playwright:
|
|
5369
|
-
"browser-rs":
|
|
5370
|
-
patchright:
|
|
5344
|
+
playwright: disabledStdio(),
|
|
5345
|
+
"browser-rs": disabledStdio(),
|
|
5346
|
+
patchright: disabledStdio(),
|
|
5347
|
+
"cua-rs": disabledStdio()
|
|
5371
5348
|
};
|
|
5372
5349
|
for (const [name, srv] of Object.entries(claudeShape)) {
|
|
5373
5350
|
if (!srv || typeof srv !== "object")
|
|
@@ -5677,7 +5654,7 @@ async function* codexProvider(opts) {
|
|
|
5677
5654
|
mcpServerCount: Object.keys(codexMcpServers).length
|
|
5678
5655
|
}, "codexProvider: starting turn");
|
|
5679
5656
|
const hostedCodexHome = hostedCodexHomePath();
|
|
5680
|
-
const inheritedCodexHome = process.env.CODEX_HOME ||
|
|
5657
|
+
const inheritedCodexHome = process.env.CODEX_HOME || join13(homedir6(), ".codex");
|
|
5681
5658
|
const codexEnvironment = scopedBrowserCapability || resolve9(hostedCodexHome) !== resolve9(inheritedCodexHome) ? {
|
|
5682
5659
|
...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
|
|
5683
5660
|
CODEX_HOME: hostedCodexHome,
|
|
@@ -5977,7 +5954,8 @@ var init_codex_provider = __esm(async () => {
|
|
|
5977
5954
|
init_logger();
|
|
5978
5955
|
init_mcp_config();
|
|
5979
5956
|
CODEX_MCP_SERVER_NAME_OVERRIDES = {
|
|
5980
|
-
playwright: "otium_playwright"
|
|
5957
|
+
playwright: "otium_playwright",
|
|
5958
|
+
"cua-rs": "otium_cua_rs"
|
|
5981
5959
|
};
|
|
5982
5960
|
CODEX_DIFF_FILE_LIMIT = 512 * 1024;
|
|
5983
5961
|
CODEX_DIFF_BASELINE_BYTE_LIMIT = 16 * 1024 * 1024;
|
|
@@ -6136,8 +6114,8 @@ var init_maestro_provider = __esm(async () => {
|
|
|
6136
6114
|
|
|
6137
6115
|
// ../../packages/core/src/agents/index.ts
|
|
6138
6116
|
import { existsSync as existsSync13 } from "fs";
|
|
6139
|
-
import { homedir as
|
|
6140
|
-
import { join as
|
|
6117
|
+
import { homedir as homedir7 } from "os";
|
|
6118
|
+
import { join as join14 } from "path";
|
|
6141
6119
|
async function* dispatchAgent(opts) {
|
|
6142
6120
|
switch (opts.agent) {
|
|
6143
6121
|
case "claude": {
|
|
@@ -6171,11 +6149,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
|
|
|
6171
6149
|
switch (agent) {
|
|
6172
6150
|
case "claude": {
|
|
6173
6151
|
const encodedCwd = encodeClaudeCwd(cwd);
|
|
6174
|
-
const path =
|
|
6152
|
+
const path = join14(homedir7(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
|
|
6175
6153
|
return !existsSync13(path);
|
|
6176
6154
|
}
|
|
6177
6155
|
case "codex": {
|
|
6178
|
-
const sessionsDir =
|
|
6156
|
+
const sessionsDir = join14(hostedCodexHomePath(), "sessions");
|
|
6179
6157
|
const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
|
|
6180
6158
|
for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
6181
6159
|
return false;
|
|
@@ -7430,9 +7408,9 @@ var init_api_topic_brief = __esm(async () => {
|
|
|
7430
7408
|
});
|
|
7431
7409
|
|
|
7432
7410
|
// ../../packages/core/src/storage/wiki.ts
|
|
7433
|
-
import { basename as basename2, dirname as dirname11, join as
|
|
7411
|
+
import { basename as basename2, dirname as dirname11, join as join15 } from "path";
|
|
7434
7412
|
function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
|
|
7435
|
-
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() :
|
|
7413
|
+
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join15(workspaceDir, "wiki");
|
|
7436
7414
|
}
|
|
7437
7415
|
var init_wiki = __esm(async () => {
|
|
7438
7416
|
await init_storage_host();
|
|
@@ -8267,7 +8245,7 @@ var init_personal_general = __esm(async () => {
|
|
|
8267
8245
|
// ../../packages/core/src/agents/archiver.ts
|
|
8268
8246
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
8269
8247
|
import { existsSync as existsSync14, readdirSync as readdirSync2, readFileSync as readFileSync13, statSync as statSync6 } from "fs";
|
|
8270
|
-
import { join as
|
|
8248
|
+
import { join as join16 } from "path";
|
|
8271
8249
|
function resolveMemoryLanguage() {
|
|
8272
8250
|
const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
|
|
8273
8251
|
return override && override.length > 0 ? override : resolveOutputLanguage();
|
|
@@ -8518,10 +8496,10 @@ function distillOneLine(summaryMd) {
|
|
|
8518
8496
|
return "";
|
|
8519
8497
|
}
|
|
8520
8498
|
function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
8521
|
-
const dir =
|
|
8499
|
+
const dir = join16(storage.getWikiDir(), "summaries");
|
|
8522
8500
|
if (!storage.fileExists(dir))
|
|
8523
8501
|
return null;
|
|
8524
|
-
const predicted =
|
|
8502
|
+
const predicted = join16(dir, wikiSummaryFilename(date, topicTitle, topicId));
|
|
8525
8503
|
if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
|
|
8526
8504
|
return predicted;
|
|
8527
8505
|
let best = null;
|
|
@@ -8529,7 +8507,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
|
8529
8507
|
if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
|
|
8530
8508
|
continue;
|
|
8531
8509
|
}
|
|
8532
|
-
const p =
|
|
8510
|
+
const p = join16(dir, f);
|
|
8533
8511
|
try {
|
|
8534
8512
|
const m = storage.fileModifiedAt(p);
|
|
8535
8513
|
if (m >= sinceMs && (!best || m > best.mtime))
|
|
@@ -8656,8 +8634,8 @@ __export(exports_auth_check, {
|
|
|
8656
8634
|
});
|
|
8657
8635
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
8658
8636
|
import { existsSync as existsSync15 } from "fs";
|
|
8659
|
-
import { homedir as
|
|
8660
|
-
import { join as
|
|
8637
|
+
import { homedir as homedir8, platform } from "os";
|
|
8638
|
+
import { join as join17 } from "path";
|
|
8661
8639
|
function hasMaestroCredential(host, key, userId) {
|
|
8662
8640
|
if (userId && host.getVaultValue(userId, key)?.trim())
|
|
8663
8641
|
return true;
|
|
@@ -8677,7 +8655,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
|
|
|
8677
8655
|
case "claude": {
|
|
8678
8656
|
if (host.environment.ANTHROPIC_API_KEY)
|
|
8679
8657
|
return { ok: true };
|
|
8680
|
-
const path =
|
|
8658
|
+
const path = join17(host.homeDirectory(), ".claude", ".credentials.json");
|
|
8681
8659
|
if (host.operatingSystem() === "darwin") {
|
|
8682
8660
|
if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
|
|
8683
8661
|
return { ok: true };
|
|
@@ -8730,7 +8708,7 @@ var init_auth_check = __esm(async () => {
|
|
|
8730
8708
|
codexAuthFilePath,
|
|
8731
8709
|
exists: existsSync15,
|
|
8732
8710
|
environment: process.env,
|
|
8733
|
-
homeDirectory:
|
|
8711
|
+
homeDirectory: homedir8,
|
|
8734
8712
|
operatingSystem: platform,
|
|
8735
8713
|
hasMacOsCredential(service) {
|
|
8736
8714
|
try {
|
|
@@ -9438,13 +9416,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
|
|
|
9438
9416
|
|
|
9439
9417
|
// ../../packages/core/src/storage/topic-archive.ts
|
|
9440
9418
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8 } from "fs";
|
|
9441
|
-
import { join as
|
|
9419
|
+
import { join as join18 } from "path";
|
|
9442
9420
|
function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
9443
9421
|
const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
|
|
9444
9422
|
if (rows.length === 0)
|
|
9445
9423
|
return null;
|
|
9446
9424
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
9447
|
-
const archiveDir =
|
|
9425
|
+
const archiveDir = join18(getSharedWikiDir(), "archive");
|
|
9448
9426
|
mkdirSync10(archiveDir, { recursive: true });
|
|
9449
9427
|
const date = new Date().toISOString().slice(0, 10);
|
|
9450
9428
|
const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
|
|
@@ -9457,7 +9435,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
|
9457
9435
|
let path;
|
|
9458
9436
|
while (true) {
|
|
9459
9437
|
filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
|
|
9460
|
-
path =
|
|
9438
|
+
path = join18(archiveDir, filename);
|
|
9461
9439
|
try {
|
|
9462
9440
|
writeFileSync8(path, body, { flag: "wx" });
|
|
9463
9441
|
break;
|
|
@@ -9502,7 +9480,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
9502
9480
|
const entries = readRawConversation(userId, topicTitle);
|
|
9503
9481
|
if (entries.length === 0)
|
|
9504
9482
|
return null;
|
|
9505
|
-
const archiveDir =
|
|
9483
|
+
const archiveDir = join18(getSharedWikiDir(), "archive");
|
|
9506
9484
|
mkdirSync10(archiveDir, { recursive: true });
|
|
9507
9485
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
9508
9486
|
const date = new Date().toISOString().slice(0, 10);
|
|
@@ -9530,7 +9508,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
9530
9508
|
let counter = 1;
|
|
9531
9509
|
while (true) {
|
|
9532
9510
|
const suffix = counter === 1 ? "" : `_${counter}`;
|
|
9533
|
-
const path =
|
|
9511
|
+
const path = join18(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
|
|
9534
9512
|
try {
|
|
9535
9513
|
writeFileSync8(path, body, { flag: "wx" });
|
|
9536
9514
|
logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
|
|
@@ -10863,13 +10841,13 @@ var init_browser_processes = __esm(async () => {
|
|
|
10863
10841
|
});
|
|
10864
10842
|
|
|
10865
10843
|
// ../../packages/core/src/platform/playwright/headed-launch.ts
|
|
10866
|
-
import { accessSync as
|
|
10844
|
+
import { accessSync as accessSync2, constants as constants2 } from "fs";
|
|
10867
10845
|
import { delimiter, isAbsolute as isAbsolute4, resolve as resolve14 } from "path";
|
|
10868
10846
|
function findExecutableOnPath(command, environment = process.env) {
|
|
10869
10847
|
const candidates = isAbsolute4(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve14(directory, command));
|
|
10870
10848
|
for (const candidate of candidates) {
|
|
10871
10849
|
try {
|
|
10872
|
-
|
|
10850
|
+
accessSync2(candidate, constants2.X_OK);
|
|
10873
10851
|
return candidate;
|
|
10874
10852
|
} catch {}
|
|
10875
10853
|
}
|
|
@@ -10968,7 +10946,7 @@ import { randomBytes as randomBytes6, timingSafeEqual as timingSafeEqual2 } from
|
|
|
10968
10946
|
import { chmodSync as chmodSync4 } from "fs";
|
|
10969
10947
|
import { createServer as createServer3 } from "net";
|
|
10970
10948
|
import { tmpdir as tmpdir3 } from "os";
|
|
10971
|
-
import { join as
|
|
10949
|
+
import { join as join19 } from "path";
|
|
10972
10950
|
function deepMapStrings2(value, transform) {
|
|
10973
10951
|
if (typeof value === "string")
|
|
10974
10952
|
return transform(value);
|
|
@@ -11055,7 +11033,7 @@ function authorized(actual, expected) {
|
|
|
11055
11033
|
}
|
|
11056
11034
|
async function createBrowserVaultBroker(userId) {
|
|
11057
11035
|
const token = randomBytes6(32).toString("hex");
|
|
11058
|
-
const socketPath =
|
|
11036
|
+
const socketPath = join19(process.platform === "win32" ? tmpdir3() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes6(8).toString("hex")}.sock`);
|
|
11059
11037
|
const retainedForms = new Map;
|
|
11060
11038
|
const leases = new Map;
|
|
11061
11039
|
const sockets = new Set;
|
|
@@ -11264,7 +11242,7 @@ import {
|
|
|
11264
11242
|
unlinkSync as unlinkSync11,
|
|
11265
11243
|
writeFileSync as writeFileSync9
|
|
11266
11244
|
} from "fs";
|
|
11267
|
-
import { dirname as dirname12, join as
|
|
11245
|
+
import { dirname as dirname12, join as join20, resolve as resolve15 } from "path";
|
|
11268
11246
|
function removeDefaultProfileDataDir(userDataDir) {
|
|
11269
11247
|
const root = resolve15(BROWSER_PROFILES_DIR);
|
|
11270
11248
|
const target = resolve15(userDataDir);
|
|
@@ -11354,14 +11332,14 @@ function portFileName(instanceKey) {
|
|
|
11354
11332
|
function writePortFile(instanceKey, port) {
|
|
11355
11333
|
try {
|
|
11356
11334
|
mkdirSync11(managerHost.portsDir, { recursive: true });
|
|
11357
|
-
writeFileSync9(
|
|
11335
|
+
writeFileSync9(join20(managerHost.portsDir, portFileName(instanceKey)), String(port));
|
|
11358
11336
|
} catch (e) {
|
|
11359
11337
|
logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
|
|
11360
11338
|
}
|
|
11361
11339
|
}
|
|
11362
11340
|
function deletePortFile(instanceKey) {
|
|
11363
11341
|
try {
|
|
11364
|
-
unlinkSync11(
|
|
11342
|
+
unlinkSync11(join20(managerHost.portsDir, portFileName(instanceKey)));
|
|
11365
11343
|
} catch (e) {
|
|
11366
11344
|
if (e.code === "ENOENT")
|
|
11367
11345
|
return;
|
|
@@ -12520,7 +12498,7 @@ var init_runtime_turn_requests = __esm(async () => {
|
|
|
12520
12498
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
12521
12499
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "fs";
|
|
12522
12500
|
import { tmpdir as tmpdir4 } from "os";
|
|
12523
|
-
import { join as
|
|
12501
|
+
import { join as join21 } from "path";
|
|
12524
12502
|
function previousCompactedSummary(entries) {
|
|
12525
12503
|
for (let index = entries.length - 2;index >= 0; index -= 1) {
|
|
12526
12504
|
const request = entries[index]?.event;
|
|
@@ -12650,7 +12628,7 @@ function formatCompactElapsed(startedAt) {
|
|
|
12650
12628
|
async function summarizeTopicContext(request) {
|
|
12651
12629
|
const startedAt = Date.now();
|
|
12652
12630
|
const sessionIds = [];
|
|
12653
|
-
const compactCwd = mkdtempSync2(
|
|
12631
|
+
const compactCwd = mkdtempSync2(join21(tmpdir4(), "negotium-compact-"));
|
|
12654
12632
|
const abortController = new AbortController;
|
|
12655
12633
|
const relayAbort = () => abortController.abort(request.signal?.reason);
|
|
12656
12634
|
if (request.signal?.aborted)
|
|
@@ -12677,7 +12655,7 @@ async function summarizeTopicContext(request) {
|
|
|
12677
12655
|
let error = "";
|
|
12678
12656
|
let toolViolation = false;
|
|
12679
12657
|
let compactionLogCalls = 0;
|
|
12680
|
-
const compactionLogPath =
|
|
12658
|
+
const compactionLogPath = join21(compactCwd, "conversation.log");
|
|
12681
12659
|
try {
|
|
12682
12660
|
const compactionMcp = useCompactionLog ? {
|
|
12683
12661
|
compact_log: {
|
|
@@ -13296,14 +13274,14 @@ var init_derive = __esm(async () => {
|
|
|
13296
13274
|
});
|
|
13297
13275
|
|
|
13298
13276
|
// ../../packages/core/src/query/session-inbox-path.ts
|
|
13299
|
-
import { join as
|
|
13277
|
+
import { join as join22 } from "path";
|
|
13300
13278
|
function sessionInboxPath(userId, topicId) {
|
|
13301
13279
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
13302
|
-
return
|
|
13280
|
+
return join22(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
|
|
13303
13281
|
}
|
|
13304
13282
|
function scheduledSessionInboxPath(userId, topicId) {
|
|
13305
13283
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
13306
|
-
return
|
|
13284
|
+
return join22(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
|
|
13307
13285
|
}
|
|
13308
13286
|
var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
|
|
13309
13287
|
var init_session_inbox_path = __esm(() => {
|
|
@@ -13312,13 +13290,13 @@ var init_session_inbox_path = __esm(() => {
|
|
|
13312
13290
|
|
|
13313
13291
|
// ../../packages/core/src/query/session-inbox-cleanup.ts
|
|
13314
13292
|
import { unlinkSync as unlinkSync14 } from "fs";
|
|
13315
|
-
import { basename as basename3, join as
|
|
13293
|
+
import { basename as basename3, join as join23 } from "path";
|
|
13316
13294
|
function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
|
|
13317
13295
|
const live = sessionInboxPath(userId, topicId);
|
|
13318
13296
|
const scheduled = scheduledSessionInboxPath(userId, topicId);
|
|
13319
13297
|
const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
|
|
13320
13298
|
if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename3(legacyTopicTitle) === legacyTopicTitle) {
|
|
13321
|
-
const legacyBase =
|
|
13299
|
+
const legacyBase = join23(SESSION_INBOX_DIR, userId, legacyTopicTitle);
|
|
13322
13300
|
for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
|
|
13323
13301
|
candidates.add(`${legacyBase}${suffix}`);
|
|
13324
13302
|
}
|
|
@@ -13344,16 +13322,16 @@ var init_session_inbox_cleanup = __esm(() => {
|
|
|
13344
13322
|
|
|
13345
13323
|
// ../../packages/core/src/query/state.ts
|
|
13346
13324
|
import { mkdirSync as mkdirSync14, renameSync as renameSync7, unlinkSync as unlinkSync15, writeFileSync as writeFileSync12 } from "fs";
|
|
13347
|
-
import { basename as basename4, join as
|
|
13325
|
+
import { basename as basename4, join as join24 } from "path";
|
|
13348
13326
|
function createQueryStateStore(options) {
|
|
13349
13327
|
const sanitize = options.sanitizeTopicId ?? sanitizeId;
|
|
13350
|
-
const queryStateDirPath = (userId) =>
|
|
13351
|
-
const queryStateFile = (userId, topicId) =>
|
|
13328
|
+
const queryStateDirPath = (userId) => join24(options.usersLogDir, String(userId), "active-queries");
|
|
13329
|
+
const queryStateFile = (userId, topicId) => join24(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
|
|
13352
13330
|
const legacyQueryStateFile = (userId, topicName) => {
|
|
13353
13331
|
if (!topicName || topicName === "." || topicName === ".." || basename4(topicName) !== topicName) {
|
|
13354
13332
|
return null;
|
|
13355
13333
|
}
|
|
13356
|
-
return
|
|
13334
|
+
return join24(queryStateDirPath(userId), `${topicName}.json`);
|
|
13357
13335
|
};
|
|
13358
13336
|
return {
|
|
13359
13337
|
write(userId, topicId, topicName, task) {
|
|
@@ -13514,29 +13492,29 @@ import {
|
|
|
13514
13492
|
unlinkSync as unlinkSync16,
|
|
13515
13493
|
writeFileSync as writeFileSync13
|
|
13516
13494
|
} from "fs";
|
|
13517
|
-
import { dirname as dirname14, join as
|
|
13495
|
+
import { dirname as dirname14, join as join25 } from "path";
|
|
13518
13496
|
function pendingAskDir(userId) {
|
|
13519
13497
|
const rawUserId = String(userId);
|
|
13520
13498
|
const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash6("sha256").update(rawUserId).digest("hex")}`;
|
|
13521
|
-
return
|
|
13499
|
+
return join25(resolveStorageSessionAsksDir(), safeUserId);
|
|
13522
13500
|
}
|
|
13523
13501
|
function encodeAskKey(key) {
|
|
13524
13502
|
return JSON.stringify([key.from, key.to]);
|
|
13525
13503
|
}
|
|
13526
13504
|
function pendingAskPath(key) {
|
|
13527
13505
|
const digest = createHash6("sha256").update(encodeAskKey(key)).digest("hex");
|
|
13528
|
-
return
|
|
13506
|
+
return join25(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
|
|
13529
13507
|
}
|
|
13530
13508
|
function v2PendingAskPath(key) {
|
|
13531
13509
|
const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
|
|
13532
|
-
return
|
|
13510
|
+
return join25(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
|
|
13533
13511
|
}
|
|
13534
13512
|
function legacyPendingAskPath(key) {
|
|
13535
13513
|
if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
|
|
13536
13514
|
return null;
|
|
13537
13515
|
}
|
|
13538
13516
|
const dir = pendingAskDir(key.userId);
|
|
13539
|
-
const candidate =
|
|
13517
|
+
const candidate = join25(dir, `${key.from}___${key.to}.pending`);
|
|
13540
13518
|
return dirname14(candidate) === dir ? candidate : null;
|
|
13541
13519
|
}
|
|
13542
13520
|
function parsePendingAskFilename(fileName) {
|
|
@@ -13777,7 +13755,7 @@ function listPendingAsksForCaller(args) {
|
|
|
13777
13755
|
const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
|
|
13778
13756
|
if (!parsed)
|
|
13779
13757
|
continue;
|
|
13780
|
-
const path =
|
|
13758
|
+
const path = join25(dir, fileName);
|
|
13781
13759
|
const record = readPendingAskFile(path, {
|
|
13782
13760
|
userId: args.userId,
|
|
13783
13761
|
from: parsed.from,
|
|
@@ -13819,7 +13797,7 @@ function deletePendingAsksForTopic(args) {
|
|
|
13819
13797
|
}
|
|
13820
13798
|
let deleted = 0;
|
|
13821
13799
|
for (const fileName of files) {
|
|
13822
|
-
const path =
|
|
13800
|
+
const path = join25(dir, fileName);
|
|
13823
13801
|
const parsed = parsePendingAskFilename(fileName);
|
|
13824
13802
|
const record = readPendingAskFile(path, {
|
|
13825
13803
|
userId: args.userId,
|
|
@@ -14219,7 +14197,7 @@ body{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;background:var(--
|
|
|
14219
14197
|
// ../../packages/core/src/storage/token-stats.ts
|
|
14220
14198
|
import { createHash as createHash7 } from "crypto";
|
|
14221
14199
|
import { mkdirSync as mkdirSync16, writeFileSync as writeFileSync14 } from "fs";
|
|
14222
|
-
import { join as
|
|
14200
|
+
import { join as join26 } from "path";
|
|
14223
14201
|
function tokenStatsFileId(userId) {
|
|
14224
14202
|
const rawUserId = String(userId);
|
|
14225
14203
|
return /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash7("sha256").update(rawUserId).digest("hex")}`;
|
|
@@ -14228,7 +14206,7 @@ function queriesPath(userId) {
|
|
|
14228
14206
|
const fileId = tokenStatsFileId(userId);
|
|
14229
14207
|
const logDir = resolveStorageLogDir();
|
|
14230
14208
|
mkdirSync16(logDir, { recursive: true });
|
|
14231
|
-
return
|
|
14209
|
+
return join26(logDir, `token-queries-${fileId}.jsonl`);
|
|
14232
14210
|
}
|
|
14233
14211
|
function estimateUsageCost(agent, model, usage) {
|
|
14234
14212
|
const prices = TOKEN_PRICES[`${agent}:${model}`];
|
|
@@ -14544,7 +14522,7 @@ var init_lifecycle = __esm(async () => {
|
|
|
14544
14522
|
// ../../packages/core/src/runtime/attachments.ts
|
|
14545
14523
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
14546
14524
|
import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
14547
|
-
import { basename as basename5, join as
|
|
14525
|
+
import { basename as basename5, join as join27 } from "path";
|
|
14548
14526
|
function workspaceCwdFor(topicId) {
|
|
14549
14527
|
return resolveTopicWorkspaceDir(topicId);
|
|
14550
14528
|
}
|
|
@@ -14557,7 +14535,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
14557
14535
|
if (!attachmentIds?.length)
|
|
14558
14536
|
return [];
|
|
14559
14537
|
const out = [];
|
|
14560
|
-
const destDir =
|
|
14538
|
+
const destDir = join27(workspaceCwdFor(topicId), "attachments", queryId);
|
|
14561
14539
|
for (const rawId of attachmentIds) {
|
|
14562
14540
|
if (typeof rawId !== "string")
|
|
14563
14541
|
continue;
|
|
@@ -14574,7 +14552,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
14574
14552
|
mkdirSync17(destDir, { recursive: true });
|
|
14575
14553
|
const index = String(out.length + 1).padStart(2, "0");
|
|
14576
14554
|
const safeName = safeAttachmentFilename(attachment.filename, fileId);
|
|
14577
|
-
const destPath =
|
|
14555
|
+
const destPath = join27(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
|
|
14578
14556
|
copyFileSync2(sourcePath, destPath);
|
|
14579
14557
|
out.push({
|
|
14580
14558
|
id: attachment.id,
|
|
@@ -14604,10 +14582,10 @@ function promptWithAttachments(prompt, attachments) {
|
|
|
14604
14582
|
return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
|
|
14605
14583
|
}
|
|
14606
14584
|
function ingestAttachment(args) {
|
|
14607
|
-
const destDir =
|
|
14585
|
+
const destDir = join27(UPLOADS_DIR, args.topicId);
|
|
14608
14586
|
mkdirSync17(destDir, { recursive: true });
|
|
14609
14587
|
const safeName = safeAttachmentFilename(args.filename, "upload");
|
|
14610
|
-
const destPath =
|
|
14588
|
+
const destPath = join27(destDir, `${Date.now()}-${randomUUID14().slice(0, 8)}-${safeName}`);
|
|
14611
14589
|
if (args.sourcePath !== undefined) {
|
|
14612
14590
|
copyFileSync2(args.sourcePath, destPath);
|
|
14613
14591
|
} else if (args.bytes !== undefined) {
|
|
@@ -15896,9 +15874,9 @@ var init_turn_session = __esm(async () => {
|
|
|
15896
15874
|
|
|
15897
15875
|
// ../../packages/core/src/storage/app-settings.ts
|
|
15898
15876
|
import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
15899
|
-
import { dirname as dirname15, join as
|
|
15877
|
+
import { dirname as dirname15, join as join28 } from "path";
|
|
15900
15878
|
function settingsFile() {
|
|
15901
|
-
return
|
|
15879
|
+
return join28(resolveStorageDataDir(), "otium-settings.json");
|
|
15902
15880
|
}
|
|
15903
15881
|
function getGlobalAiName() {
|
|
15904
15882
|
const path = settingsFile();
|
|
@@ -15993,7 +15971,7 @@ __export(exports_turn_runner, {
|
|
|
15993
15971
|
});
|
|
15994
15972
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
15995
15973
|
import { existsSync as existsSync20, mkdirSync as mkdirSync19, readdirSync as readdirSync5, statSync as statSync10 } from "fs";
|
|
15996
|
-
import { join as
|
|
15974
|
+
import { join as join29 } from "path";
|
|
15997
15975
|
function withDefaultPlaywright(configuredMcp, isManager) {
|
|
15998
15976
|
if (isManager)
|
|
15999
15977
|
return configuredMcp;
|
|
@@ -16048,7 +16026,7 @@ function appendAskReplyMessage(topicId, text2, agentType) {
|
|
|
16048
16026
|
return message;
|
|
16049
16027
|
}
|
|
16050
16028
|
function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
|
|
16051
|
-
const preferred =
|
|
16029
|
+
const preferred = join29(directory, preferredFilename);
|
|
16052
16030
|
if (preferExact && existsSync20(preferred))
|
|
16053
16031
|
return preferred;
|
|
16054
16032
|
let newestLegacyId = null;
|
|
@@ -16059,7 +16037,7 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
16059
16037
|
const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
|
|
16060
16038
|
if (!titleMatch && !legacyIdMatch)
|
|
16061
16039
|
continue;
|
|
16062
|
-
const path =
|
|
16040
|
+
const path = join29(directory, filename);
|
|
16063
16041
|
const mtimeMs = statSync10(path).mtimeMs;
|
|
16064
16042
|
if (titleMatch) {
|
|
16065
16043
|
if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
|
|
@@ -16073,9 +16051,9 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
16073
16051
|
return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
|
|
16074
16052
|
}
|
|
16075
16053
|
function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
|
|
16076
|
-
const briefFile = resolveWikiMirrorPath(
|
|
16054
|
+
const briefFile = resolveWikiMirrorPath(join29(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
|
|
16077
16055
|
const hasBriefFile = existsSync20(briefFile) && statSync10(briefFile).isFile();
|
|
16078
|
-
const latestSummaryCandidate = resolveWikiMirrorPath(
|
|
16056
|
+
const latestSummaryCandidate = resolveWikiMirrorPath(join29(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
|
|
16079
16057
|
const latestSummaryFile = existsSync20(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
|
|
16080
16058
|
return { briefFile, hasBriefFile, latestSummaryFile };
|
|
16081
16059
|
}
|
|
@@ -19167,4 +19145,4 @@ export {
|
|
|
19167
19145
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
19168
19146
|
};
|
|
19169
19147
|
|
|
19170
|
-
//# debugId=
|
|
19148
|
+
//# debugId=A291748F3D8D465364756E2164756E21
|