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/mcp-factories.js
CHANGED
|
@@ -313,7 +313,7 @@ function resolveDefaultModel(agent, registryDefaultModel) {
|
|
|
313
313
|
function codexAuthFilePath() {
|
|
314
314
|
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
|
|
315
315
|
}
|
|
316
|
-
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.
|
|
316
|
+
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;
|
|
317
317
|
var init_config = __esm(() => {
|
|
318
318
|
init_config_helpers();
|
|
319
319
|
init_logger();
|
|
@@ -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.
|
|
1020
|
+
var NEGOTIUM_VERSION = "0.4.4";
|
|
1021
1021
|
|
|
1022
1022
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
1023
1023
|
import { spawn } from "child_process";
|
|
@@ -1712,9 +1712,6 @@ function browserOwnerCapability(capability, owner) {
|
|
|
1712
1712
|
var init_capability = () => {};
|
|
1713
1713
|
|
|
1714
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";
|
|
1718
1715
|
function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
|
|
1719
1716
|
if (agent === "codex") {
|
|
1720
1717
|
return {
|
|
@@ -1812,6 +1809,9 @@ function playwrightTransport(port, owner, capability, agent) {
|
|
|
1812
1809
|
function longLivedHttpMcp(agent, port) {
|
|
1813
1810
|
return agent === "codex" ? { url: `http://127.0.0.1:${port}/mcp` } : { type: "sse", url: `http://127.0.0.1:${port}/sse` };
|
|
1814
1811
|
}
|
|
1812
|
+
function cuaRsHttpMcp(port) {
|
|
1813
|
+
return { type: "http", url: `http://127.0.0.1:${port}/mcp` };
|
|
1814
|
+
}
|
|
1815
1815
|
function backgroundBashTransport(agent, port, userId, topic) {
|
|
1816
1816
|
const capability = bgBashContextCapability(userId, topic);
|
|
1817
1817
|
const headers = {
|
|
@@ -1827,27 +1827,6 @@ function backgroundBashTransport(agent, port, userId, topic) {
|
|
|
1827
1827
|
}
|
|
1828
1828
|
return { type: "sse", url: `http://127.0.0.1:${port}/sse`, headers };
|
|
1829
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
|
-
}
|
|
1851
1830
|
function refreshForumCatalogViews() {
|
|
1852
1831
|
const { all, required, optional } = classifyForumMcpServers(MCP_CATALOG);
|
|
1853
1832
|
allForumMcpServerNames.splice(0, allForumMcpServerNames.length, ...all);
|
|
@@ -2066,7 +2045,7 @@ function getMcpServersForQuery(opts) {
|
|
|
2066
2045
|
peerBridge: opts.peerBridge
|
|
2067
2046
|
});
|
|
2068
2047
|
}
|
|
2069
|
-
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;
|
|
2048
|
+
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;
|
|
2070
2049
|
var init_mcp_config = __esm(() => {
|
|
2071
2050
|
init_canonical_bridge_config();
|
|
2072
2051
|
init_runtime_spec();
|
|
@@ -2285,10 +2264,7 @@ var init_mcp_config = __esm(() => {
|
|
|
2285
2264
|
"cua-rs": {
|
|
2286
2265
|
...commonRuntimeMcpPolicy("cua-rs"),
|
|
2287
2266
|
build() {
|
|
2288
|
-
|
|
2289
|
-
if (!bin)
|
|
2290
|
-
return null;
|
|
2291
|
-
return { command: bin, args: cuaRsArgs() };
|
|
2267
|
+
return cuaRsMcpPort ? cuaRsHttpMcp(cuaRsMcpPort) : null;
|
|
2292
2268
|
}
|
|
2293
2269
|
}
|
|
2294
2270
|
};
|
|
@@ -2302,8 +2278,8 @@ var init_mcp_config = __esm(() => {
|
|
|
2302
2278
|
|
|
2303
2279
|
// ../../packages/core/src/storage/storage-host.ts
|
|
2304
2280
|
import { mkdirSync as mkdirSync6 } from "fs";
|
|
2305
|
-
import { homedir as
|
|
2306
|
-
import { dirname as dirname5, join as
|
|
2281
|
+
import { homedir as homedir4 } from "os";
|
|
2282
|
+
import { dirname as dirname5, join as join6, resolve as resolve5 } from "path";
|
|
2307
2283
|
function storageState() {
|
|
2308
2284
|
const holder = globalThis;
|
|
2309
2285
|
const existing = holder[STORAGE_HOST_STATE];
|
|
@@ -2331,23 +2307,23 @@ function envPath(name, fallback) {
|
|
|
2331
2307
|
return resolve5(value2 || fallback);
|
|
2332
2308
|
}
|
|
2333
2309
|
function defaultStateDir() {
|
|
2334
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
2310
|
+
return envPath("NEGOTIUM_STATE_DIR", join6(homedir4(), ".negotium"));
|
|
2335
2311
|
}
|
|
2336
2312
|
function defaultDataDir() {
|
|
2337
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
2313
|
+
return envPath("NEGOTIUM_DATA_DIR", join6(defaultStateDir(), "data"));
|
|
2338
2314
|
}
|
|
2339
2315
|
function defaultLogDir() {
|
|
2340
|
-
return envPath("NEGOTIUM_LOG_DIR",
|
|
2316
|
+
return envPath("NEGOTIUM_LOG_DIR", join6(defaultStateDir(), "logs"));
|
|
2341
2317
|
}
|
|
2342
2318
|
function defaultWorkspaceDir() {
|
|
2343
|
-
return envPath("NEGOTIUM_WORKSPACE_DIR",
|
|
2319
|
+
return envPath("NEGOTIUM_WORKSPACE_DIR", join6(defaultStateDir(), "workspace"));
|
|
2344
2320
|
}
|
|
2345
2321
|
function defaultSessionAsksDir() {
|
|
2346
|
-
const runDir = envPath("NEGOTIUM_RUN_DIR",
|
|
2347
|
-
return
|
|
2322
|
+
const runDir = envPath("NEGOTIUM_RUN_DIR", join6(defaultStateDir(), "runtime"));
|
|
2323
|
+
return join6(runDir, "session-asks");
|
|
2348
2324
|
}
|
|
2349
2325
|
function defaultSessionsDatabasePath() {
|
|
2350
|
-
return envPath("SESSIONS_DB_PATH",
|
|
2326
|
+
return envPath("SESSIONS_DB_PATH", join6(resolveStorageDataDir(), "sessions.db"));
|
|
2351
2327
|
}
|
|
2352
2328
|
function isSqliteBusy(error) {
|
|
2353
2329
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2404,7 +2380,7 @@ function resolveStorageWorkspaceDir() {
|
|
|
2404
2380
|
return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
2405
2381
|
}
|
|
2406
2382
|
function resolveStorageSharedWikiDir() {
|
|
2407
|
-
return storageState().configuredHost.sharedWikiDir ??
|
|
2383
|
+
return storageState().configuredHost.sharedWikiDir ?? join6(resolveStorageWorkspaceDir(), "wiki");
|
|
2408
2384
|
}
|
|
2409
2385
|
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
2410
2386
|
const initializers = storageState().schemaInitializers;
|
|
@@ -2514,7 +2490,7 @@ var init_vault_crypto = __esm(() => {
|
|
|
2514
2490
|
|
|
2515
2491
|
// ../../packages/core/src/storage/vault.ts
|
|
2516
2492
|
import { chmodSync as chmodSync4, mkdirSync as mkdirSync7 } from "fs";
|
|
2517
|
-
import { join as
|
|
2493
|
+
import { join as join7 } from "path";
|
|
2518
2494
|
function initializeVaultDatabase(database) {
|
|
2519
2495
|
database.exec("PRAGMA journal_mode = WAL");
|
|
2520
2496
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -2549,8 +2525,8 @@ function initializeVaultDatabase(database) {
|
|
|
2549
2525
|
}
|
|
2550
2526
|
}
|
|
2551
2527
|
function openVaultDatabase(dataDir) {
|
|
2552
|
-
const vaultDir =
|
|
2553
|
-
const path =
|
|
2528
|
+
const vaultDir = join7(dataDir, "vault");
|
|
2529
|
+
const path = join7(vaultDir, "vault.db");
|
|
2554
2530
|
mkdirSync7(vaultDir, { recursive: true, mode: 448 });
|
|
2555
2531
|
const database = new Database(path, { create: true });
|
|
2556
2532
|
chmodSync4(path, 384);
|
|
@@ -2716,14 +2692,14 @@ var init_execution_host = __esm(async () => {
|
|
|
2716
2692
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2717
2693
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
2718
2694
|
import { existsSync as existsSync7, readFileSync as readFileSync7, realpathSync as realpathSync2, statSync as statSync3, unlinkSync as unlinkSync7 } from "fs";
|
|
2719
|
-
import { basename as basename2, dirname as dirname7, join as
|
|
2695
|
+
import { basename as basename2, dirname as dirname7, join as join8, resolve as resolve6 } from "path";
|
|
2720
2696
|
function codexSessionsDir() {
|
|
2721
|
-
return
|
|
2697
|
+
return join8(hostedCodexHomePath(), "sessions");
|
|
2722
2698
|
}
|
|
2723
2699
|
function loadCodexShell() {
|
|
2724
2700
|
if (_shellCache)
|
|
2725
2701
|
return _shellCache;
|
|
2726
|
-
const raw = readFileSync7(
|
|
2702
|
+
const raw = readFileSync7(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
2727
2703
|
const lines = parseJsonlText(raw);
|
|
2728
2704
|
if (lines.length < 5) {
|
|
2729
2705
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -2790,8 +2766,8 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
2790
2766
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
2791
2767
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
2792
2768
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
2793
|
-
const dir =
|
|
2794
|
-
return
|
|
2769
|
+
const dir = join8(codexSessionsDir(), yyyy, mm, dd);
|
|
2770
|
+
return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
2795
2771
|
}
|
|
2796
2772
|
function canonicalFilePath(path) {
|
|
2797
2773
|
const absolute = resolve6(path);
|
|
@@ -2799,7 +2775,7 @@ function canonicalFilePath(path) {
|
|
|
2799
2775
|
return realpathSync2(absolute);
|
|
2800
2776
|
} catch {
|
|
2801
2777
|
try {
|
|
2802
|
-
return
|
|
2778
|
+
return join8(realpathSync2(dirname7(absolute)), basename2(absolute));
|
|
2803
2779
|
} catch {
|
|
2804
2780
|
return absolute;
|
|
2805
2781
|
}
|
|
@@ -3029,19 +3005,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
3029
3005
|
try {
|
|
3030
3006
|
if (buckets) {
|
|
3031
3007
|
for (const bucket of buckets) {
|
|
3032
|
-
const dir =
|
|
3008
|
+
const dir = join8(sessionsDir, bucket);
|
|
3033
3009
|
if (!existsSync7(dir))
|
|
3034
3010
|
continue;
|
|
3035
3011
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3036
3012
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3037
|
-
candidates.push(
|
|
3013
|
+
candidates.push(join8(dir, rel));
|
|
3038
3014
|
}
|
|
3039
3015
|
}
|
|
3040
3016
|
}
|
|
3041
3017
|
if (candidates.length === 0) {
|
|
3042
3018
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3043
3019
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3044
|
-
candidates.push(
|
|
3020
|
+
candidates.push(join8(sessionsDir, rel));
|
|
3045
3021
|
}
|
|
3046
3022
|
}
|
|
3047
3023
|
return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
|
|
@@ -3162,13 +3138,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
3162
3138
|
return;
|
|
3163
3139
|
}
|
|
3164
3140
|
for (const bucket of buckets) {
|
|
3165
|
-
const dir =
|
|
3141
|
+
const dir = join8(sessionsDir, bucket);
|
|
3166
3142
|
if (!existsSync7(dir))
|
|
3167
3143
|
continue;
|
|
3168
3144
|
try {
|
|
3169
3145
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3170
3146
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3171
|
-
const fullPath =
|
|
3147
|
+
const fullPath = join8(dir, rel);
|
|
3172
3148
|
try {
|
|
3173
3149
|
unlinkSync7(fullPath);
|
|
3174
3150
|
} catch (e) {
|
|
@@ -3186,7 +3162,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
3186
3162
|
try {
|
|
3187
3163
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3188
3164
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3189
|
-
const fullPath =
|
|
3165
|
+
const fullPath = join8(sessionsDir, rel);
|
|
3190
3166
|
try {
|
|
3191
3167
|
unlinkSync7(fullPath);
|
|
3192
3168
|
} catch (e) {
|
|
@@ -3364,7 +3340,7 @@ var init_codex_app_server = __esm(async () => {
|
|
|
3364
3340
|
|
|
3365
3341
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
3366
3342
|
import { existsSync as existsSync8, unlinkSync as unlinkSync8 } from "fs";
|
|
3367
|
-
import { join as
|
|
3343
|
+
import { join as join9 } from "path";
|
|
3368
3344
|
var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
|
|
3369
3345
|
var init_codex_registry = __esm(async () => {
|
|
3370
3346
|
await init_codex_app_server();
|
|
@@ -3407,7 +3383,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3407
3383
|
async cleanupRollouts({ sessionIds }) {
|
|
3408
3384
|
if (sessionIds.length === 0)
|
|
3409
3385
|
return;
|
|
3410
|
-
const sessionsDir =
|
|
3386
|
+
const sessionsDir = join9(hostedCodexHomePath(), "sessions");
|
|
3411
3387
|
if (!existsSync8(sessionsDir))
|
|
3412
3388
|
return;
|
|
3413
3389
|
const failures = [];
|
|
@@ -3415,7 +3391,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3415
3391
|
try {
|
|
3416
3392
|
const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
|
|
3417
3393
|
for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3418
|
-
const path =
|
|
3394
|
+
const path = join9(sessionsDir, rel);
|
|
3419
3395
|
try {
|
|
3420
3396
|
unlinkSync8(path);
|
|
3421
3397
|
} catch (e) {
|
|
@@ -3440,16 +3416,16 @@ var init_codex_registry = __esm(async () => {
|
|
|
3440
3416
|
// ../../packages/core/src/agents/maestro-registry.ts
|
|
3441
3417
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
3442
3418
|
import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
3443
|
-
import { homedir as
|
|
3444
|
-
import { join as
|
|
3419
|
+
import { homedir as homedir5 } from "os";
|
|
3420
|
+
import { join as join10, resolve as resolve7 } from "path";
|
|
3445
3421
|
function maestroSessionsDir() {
|
|
3446
|
-
return
|
|
3422
|
+
return join10(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join10(homedir5(), ".maestro"), "sessions");
|
|
3447
3423
|
}
|
|
3448
3424
|
function maestroSessionPath(sessionId) {
|
|
3449
|
-
return
|
|
3425
|
+
return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
|
|
3450
3426
|
}
|
|
3451
3427
|
function maestroActiveSessionPath(sessionId) {
|
|
3452
|
-
return
|
|
3428
|
+
return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
|
|
3453
3429
|
}
|
|
3454
3430
|
function existingCreatedAt(path) {
|
|
3455
3431
|
if (!existsSync9(path))
|
|
@@ -5892,13 +5868,13 @@ var init_browser_processes = __esm(async () => {
|
|
|
5892
5868
|
});
|
|
5893
5869
|
|
|
5894
5870
|
// ../../packages/core/src/platform/playwright/headed-launch.ts
|
|
5895
|
-
import { accessSync as
|
|
5871
|
+
import { accessSync as accessSync2, constants as constants2 } from "fs";
|
|
5896
5872
|
import { delimiter, isAbsolute, resolve as resolve9 } from "path";
|
|
5897
5873
|
function findExecutableOnPath(command, environment = process.env) {
|
|
5898
5874
|
const candidates = isAbsolute(command) ? [command] : (environment.PATH ?? "").split(delimiter).filter(Boolean).map((directory) => resolve9(directory, command));
|
|
5899
5875
|
for (const candidate of candidates) {
|
|
5900
5876
|
try {
|
|
5901
|
-
|
|
5877
|
+
accessSync2(candidate, constants2.X_OK);
|
|
5902
5878
|
return candidate;
|
|
5903
5879
|
} catch {}
|
|
5904
5880
|
}
|
|
@@ -5997,7 +5973,7 @@ import { randomBytes as randomBytes5, timingSafeEqual as timingSafeEqual2 } from
|
|
|
5997
5973
|
import { chmodSync as chmodSync5 } from "fs";
|
|
5998
5974
|
import { createServer as createServer2 } from "net";
|
|
5999
5975
|
import { tmpdir as tmpdir2 } from "os";
|
|
6000
|
-
import { join as
|
|
5976
|
+
import { join as join13 } from "path";
|
|
6001
5977
|
function deepMapStrings(value2, transform) {
|
|
6002
5978
|
if (typeof value2 === "string")
|
|
6003
5979
|
return transform(value2);
|
|
@@ -6084,7 +6060,7 @@ function authorized(actual, expected) {
|
|
|
6084
6060
|
}
|
|
6085
6061
|
async function createBrowserVaultBroker(userId) {
|
|
6086
6062
|
const token = randomBytes5(32).toString("hex");
|
|
6087
|
-
const socketPath =
|
|
6063
|
+
const socketPath = join13(process.platform === "win32" ? tmpdir2() : "/tmp", `negotium-browser-vault-${process.pid}-${randomBytes5(8).toString("hex")}.sock`);
|
|
6088
6064
|
const retainedForms = new Map;
|
|
6089
6065
|
const leases = new Map;
|
|
6090
6066
|
const sockets = new Set;
|
|
@@ -6293,7 +6269,7 @@ import {
|
|
|
6293
6269
|
unlinkSync as unlinkSync11,
|
|
6294
6270
|
writeFileSync as writeFileSync8
|
|
6295
6271
|
} from "fs";
|
|
6296
|
-
import { dirname as dirname9, join as
|
|
6272
|
+
import { dirname as dirname9, join as join14, resolve as resolve10 } from "path";
|
|
6297
6273
|
function removeDefaultProfileDataDir(userDataDir) {
|
|
6298
6274
|
const root = resolve10(BROWSER_PROFILES_DIR);
|
|
6299
6275
|
const target = resolve10(userDataDir);
|
|
@@ -6383,14 +6359,14 @@ function portFileName(instanceKey) {
|
|
|
6383
6359
|
function writePortFile(instanceKey, port) {
|
|
6384
6360
|
try {
|
|
6385
6361
|
mkdirSync10(managerHost.portsDir, { recursive: true });
|
|
6386
|
-
writeFileSync8(
|
|
6362
|
+
writeFileSync8(join14(managerHost.portsDir, portFileName(instanceKey)), String(port));
|
|
6387
6363
|
} catch (e) {
|
|
6388
6364
|
logger.warn({ err: e, instanceKey, port }, "Failed to save playwright port file");
|
|
6389
6365
|
}
|
|
6390
6366
|
}
|
|
6391
6367
|
function deletePortFile(instanceKey) {
|
|
6392
6368
|
try {
|
|
6393
|
-
unlinkSync11(
|
|
6369
|
+
unlinkSync11(join14(managerHost.portsDir, portFileName(instanceKey)));
|
|
6394
6370
|
} catch (e) {
|
|
6395
6371
|
if (e.code === "ENOENT")
|
|
6396
6372
|
return;
|
|
@@ -7451,16 +7427,16 @@ import {
|
|
|
7451
7427
|
unlinkSync as unlinkSync12,
|
|
7452
7428
|
writeFileSync as writeFileSync9
|
|
7453
7429
|
} from "fs";
|
|
7454
|
-
import { dirname as dirname10, join as
|
|
7430
|
+
import { dirname as dirname10, join as join15 } from "path";
|
|
7455
7431
|
function conversationDir(_userId) {
|
|
7456
|
-
return
|
|
7432
|
+
return join15(resolveStorageDataDir(), "conversations");
|
|
7457
7433
|
}
|
|
7458
7434
|
function topicFilename(topicName) {
|
|
7459
7435
|
const t = sanitizeTopicName(topicName, true);
|
|
7460
7436
|
return `${t}.jsonl`;
|
|
7461
7437
|
}
|
|
7462
7438
|
function getConversationPath(userId, topicName) {
|
|
7463
|
-
return
|
|
7439
|
+
return join15(conversationDir(userId), topicFilename(topicName));
|
|
7464
7440
|
}
|
|
7465
7441
|
function getActiveConversationPath(userId, topicName) {
|
|
7466
7442
|
const rawPath = getConversationPath(userId, topicName);
|
|
@@ -7683,7 +7659,7 @@ RULES:
|
|
|
7683
7659
|
|
|
7684
7660
|
// ../../packages/core/src/storage/tasks.ts
|
|
7685
7661
|
import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync13, renameSync as renameSync7, statSync as statSync4, writeFileSync as writeFileSync10 } from "fs";
|
|
7686
|
-
import { dirname as dirname11, join as
|
|
7662
|
+
import { dirname as dirname11, join as join16 } from "path";
|
|
7687
7663
|
function safeTaskScopeKey(scopeKey) {
|
|
7688
7664
|
const safe = sanitizeFileName(scopeKey);
|
|
7689
7665
|
if (!safe || safe === "." || safe === "..") {
|
|
@@ -7695,7 +7671,7 @@ function taskScopeKey(opts) {
|
|
|
7695
7671
|
return opts.topicId?.trim() || opts.session || "default";
|
|
7696
7672
|
}
|
|
7697
7673
|
function getTaskFilePath(userId, scopeKey) {
|
|
7698
|
-
return
|
|
7674
|
+
return join16(resolveStorageDataDir(), "tasks", `${safeTaskScopeKey(scopeKey)}.json`);
|
|
7699
7675
|
}
|
|
7700
7676
|
function readTasks(userId, scopeKey) {
|
|
7701
7677
|
const path = getTaskFilePath(userId, scopeKey);
|
|
@@ -8663,7 +8639,7 @@ import { existsSync as existsSync17 } from "fs";
|
|
|
8663
8639
|
import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
|
|
8664
8640
|
import { createServer as createServer3 } from "net";
|
|
8665
8641
|
import { tmpdir as tmpdir3 } from "os";
|
|
8666
|
-
import { dirname as dirname12, join as
|
|
8642
|
+
import { dirname as dirname12, join as join17, resolve as resolve11 } from "path";
|
|
8667
8643
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8668
8644
|
function evaluateCodexVaultPreToolUse(input, userId, operations) {
|
|
8669
8645
|
if (operations.referencesSensitiveStorage(input.tool_input)) {
|
|
@@ -8716,10 +8692,10 @@ function privateCodexWrapper(codexScript, socketPath, token) {
|
|
|
8716
8692
|
`);
|
|
8717
8693
|
}
|
|
8718
8694
|
async function createCodexVaultHookBridge(userId) {
|
|
8719
|
-
const root = await mkdtemp(
|
|
8695
|
+
const root = await mkdtemp(join17(tmpdir3(), "negotium-codex-vault-"));
|
|
8720
8696
|
await chmod(root, 448);
|
|
8721
|
-
const socketPath =
|
|
8722
|
-
const wrapperPath =
|
|
8697
|
+
const socketPath = join17(root, "hook.sock");
|
|
8698
|
+
const wrapperPath = join17(root, "codex-with-hooks");
|
|
8723
8699
|
const token = randomBytes7(32).toString("hex");
|
|
8724
8700
|
const connections = new Set;
|
|
8725
8701
|
const server = createServer3((socket) => {
|
|
@@ -9336,8 +9312,8 @@ __export(exports_codex_provider, {
|
|
|
9336
9312
|
});
|
|
9337
9313
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
9338
9314
|
import { existsSync as existsSync18, readFileSync as readFileSync16, realpathSync as realpathSync4, statSync as statSync6 } from "fs";
|
|
9339
|
-
import { homedir as
|
|
9340
|
-
import { dirname as dirname13, isAbsolute as isAbsolute3, join as
|
|
9315
|
+
import { homedir as homedir6 } from "os";
|
|
9316
|
+
import { dirname as dirname13, isAbsolute as isAbsolute3, join as join18, relative as relative2, resolve as resolve13 } from "path";
|
|
9341
9317
|
import { Codex } from "@openai/codex-sdk";
|
|
9342
9318
|
function sameCodexUsage(usage, total) {
|
|
9343
9319
|
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;
|
|
@@ -9365,7 +9341,7 @@ function codexMcpServerName(name) {
|
|
|
9365
9341
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
9366
9342
|
}
|
|
9367
9343
|
function globalCodexMcpServerNames(authFilePath) {
|
|
9368
|
-
const configPath =
|
|
9344
|
+
const configPath = join18(dirname13(authFilePath), "config.toml");
|
|
9369
9345
|
if (!existsSync18(configPath))
|
|
9370
9346
|
return [];
|
|
9371
9347
|
try {
|
|
@@ -9405,15 +9381,16 @@ function withCodexMcpServerOverrides(_name, server) {
|
|
|
9405
9381
|
};
|
|
9406
9382
|
}
|
|
9407
9383
|
function toCodexMcpServers(claudeShape) {
|
|
9408
|
-
const
|
|
9384
|
+
const disabledStdio = () => ({
|
|
9409
9385
|
command: process.execPath,
|
|
9410
9386
|
args: ["-e", "process.exit(0)"],
|
|
9411
9387
|
enabled: false
|
|
9412
9388
|
});
|
|
9413
9389
|
const out = {
|
|
9414
|
-
playwright:
|
|
9415
|
-
"browser-rs":
|
|
9416
|
-
patchright:
|
|
9390
|
+
playwright: disabledStdio(),
|
|
9391
|
+
"browser-rs": disabledStdio(),
|
|
9392
|
+
patchright: disabledStdio(),
|
|
9393
|
+
"cua-rs": disabledStdio()
|
|
9417
9394
|
};
|
|
9418
9395
|
for (const [name, srv] of Object.entries(claudeShape)) {
|
|
9419
9396
|
if (!srv || typeof srv !== "object")
|
|
@@ -9723,7 +9700,7 @@ async function* codexProvider(opts) {
|
|
|
9723
9700
|
mcpServerCount: Object.keys(codexMcpServers).length
|
|
9724
9701
|
}, "codexProvider: starting turn");
|
|
9725
9702
|
const hostedCodexHome = hostedCodexHomePath();
|
|
9726
|
-
const inheritedCodexHome = process.env.CODEX_HOME ||
|
|
9703
|
+
const inheritedCodexHome = process.env.CODEX_HOME || join18(homedir6(), ".codex");
|
|
9727
9704
|
const codexEnvironment = scopedBrowserCapability || resolve13(hostedCodexHome) !== resolve13(inheritedCodexHome) ? {
|
|
9728
9705
|
...Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string")),
|
|
9729
9706
|
CODEX_HOME: hostedCodexHome,
|
|
@@ -10023,7 +10000,8 @@ var init_codex_provider = __esm(async () => {
|
|
|
10023
10000
|
init_logger();
|
|
10024
10001
|
init_mcp_config();
|
|
10025
10002
|
CODEX_MCP_SERVER_NAME_OVERRIDES = {
|
|
10026
|
-
playwright: "otium_playwright"
|
|
10003
|
+
playwright: "otium_playwright",
|
|
10004
|
+
"cua-rs": "otium_cua_rs"
|
|
10027
10005
|
};
|
|
10028
10006
|
CODEX_DIFF_FILE_LIMIT = 512 * 1024;
|
|
10029
10007
|
CODEX_DIFF_BASELINE_BYTE_LIMIT = 16 * 1024 * 1024;
|
|
@@ -10182,8 +10160,8 @@ var init_maestro_provider = __esm(async () => {
|
|
|
10182
10160
|
|
|
10183
10161
|
// ../../packages/core/src/agents/index.ts
|
|
10184
10162
|
import { existsSync as existsSync19 } from "fs";
|
|
10185
|
-
import { homedir as
|
|
10186
|
-
import { join as
|
|
10163
|
+
import { homedir as homedir7 } from "os";
|
|
10164
|
+
import { join as join19 } from "path";
|
|
10187
10165
|
async function* dispatchAgent(opts) {
|
|
10188
10166
|
switch (opts.agent) {
|
|
10189
10167
|
case "claude": {
|
|
@@ -10217,11 +10195,11 @@ async function resolveSessionFileMissing(agent, sessionId, cwd) {
|
|
|
10217
10195
|
switch (agent) {
|
|
10218
10196
|
case "claude": {
|
|
10219
10197
|
const encodedCwd = encodeClaudeCwd(cwd);
|
|
10220
|
-
const path =
|
|
10198
|
+
const path = join19(homedir7(), ".claude", "projects", encodedCwd, `${sessionId}.jsonl`);
|
|
10221
10199
|
return !existsSync19(path);
|
|
10222
10200
|
}
|
|
10223
10201
|
case "codex": {
|
|
10224
|
-
const sessionsDir =
|
|
10202
|
+
const sessionsDir = join19(hostedCodexHomePath(), "sessions");
|
|
10225
10203
|
const glob = new Bun.Glob(`**/rollout-*-${sessionId}.jsonl`);
|
|
10226
10204
|
for await (const _rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
10227
10205
|
return false;
|
|
@@ -10745,9 +10723,9 @@ var init_api_topic_brief = __esm(async () => {
|
|
|
10745
10723
|
});
|
|
10746
10724
|
|
|
10747
10725
|
// ../../packages/core/src/storage/wiki.ts
|
|
10748
|
-
import { basename as basename3, dirname as dirname14, join as
|
|
10726
|
+
import { basename as basename3, dirname as dirname14, join as join20 } from "path";
|
|
10749
10727
|
function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
|
|
10750
|
-
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() :
|
|
10728
|
+
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join20(workspaceDir, "wiki");
|
|
10751
10729
|
}
|
|
10752
10730
|
var init_wiki = __esm(async () => {
|
|
10753
10731
|
await init_storage_host();
|
|
@@ -10756,7 +10734,7 @@ var init_wiki = __esm(async () => {
|
|
|
10756
10734
|
// ../../packages/core/src/agents/archiver.ts
|
|
10757
10735
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
10758
10736
|
import { existsSync as existsSync20, readdirSync as readdirSync5, readFileSync as readFileSync18, statSync as statSync7 } from "fs";
|
|
10759
|
-
import { join as
|
|
10737
|
+
import { join as join21 } from "path";
|
|
10760
10738
|
function resolveMemoryLanguage() {
|
|
10761
10739
|
const override = process.env.NEGOTIUM_MEMORY_LANG?.trim();
|
|
10762
10740
|
return override && override.length > 0 ? override : resolveOutputLanguage();
|
|
@@ -11007,10 +10985,10 @@ function distillOneLine(summaryMd) {
|
|
|
11007
10985
|
return "";
|
|
11008
10986
|
}
|
|
11009
10987
|
function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
11010
|
-
const dir =
|
|
10988
|
+
const dir = join21(storage.getWikiDir(), "summaries");
|
|
11011
10989
|
if (!storage.fileExists(dir))
|
|
11012
10990
|
return null;
|
|
11013
|
-
const predicted =
|
|
10991
|
+
const predicted = join21(dir, wikiSummaryFilename(date, topicTitle, topicId));
|
|
11014
10992
|
if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
|
|
11015
10993
|
return predicted;
|
|
11016
10994
|
let best = null;
|
|
@@ -11018,7 +10996,7 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
|
11018
10996
|
if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
|
|
11019
10997
|
continue;
|
|
11020
10998
|
}
|
|
11021
|
-
const p =
|
|
10999
|
+
const p = join21(dir, f);
|
|
11022
11000
|
try {
|
|
11023
11001
|
const m = storage.fileModifiedAt(p);
|
|
11024
11002
|
if (m >= sinceMs && (!best || m > best.mtime))
|
|
@@ -11222,13 +11200,13 @@ function formatTopicArchiveTranscriptRecord(row, topicTitle, index) {
|
|
|
11222
11200
|
|
|
11223
11201
|
// ../../packages/core/src/storage/topic-archive.ts
|
|
11224
11202
|
import { mkdirSync as mkdirSync13, writeFileSync as writeFileSync11 } from "fs";
|
|
11225
|
-
import { join as
|
|
11203
|
+
import { join as join22 } from "path";
|
|
11226
11204
|
function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
11227
11205
|
const rows = options.afterRowid !== undefined ? getMessagesForTopicAfterRowid(topicId, options.afterRowid) : getAllMessagesForTopic(topicId);
|
|
11228
11206
|
if (rows.length === 0)
|
|
11229
11207
|
return null;
|
|
11230
11208
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
11231
|
-
const archiveDir =
|
|
11209
|
+
const archiveDir = join22(getSharedWikiDir(), "archive");
|
|
11232
11210
|
mkdirSync13(archiveDir, { recursive: true });
|
|
11233
11211
|
const date = new Date().toISOString().slice(0, 10);
|
|
11234
11212
|
const reasonSuffix = options.reason && options.reason !== "delete" ? `_${options.reason}` : "";
|
|
@@ -11241,7 +11219,7 @@ function archiveTopicMessages(topicId, topicTitle, options = {}) {
|
|
|
11241
11219
|
let path;
|
|
11242
11220
|
while (true) {
|
|
11243
11221
|
filename = `${safeTopic}_${date}${reasonSuffix}${counter === 1 ? "" : `_${counter}`}.jsonl`;
|
|
11244
|
-
path =
|
|
11222
|
+
path = join22(archiveDir, filename);
|
|
11245
11223
|
try {
|
|
11246
11224
|
writeFileSync11(path, body, { flag: "wx" });
|
|
11247
11225
|
break;
|
|
@@ -11286,7 +11264,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
11286
11264
|
const entries = readRawConversation(userId, topicTitle);
|
|
11287
11265
|
if (entries.length === 0)
|
|
11288
11266
|
return null;
|
|
11289
|
-
const archiveDir =
|
|
11267
|
+
const archiveDir = join22(getSharedWikiDir(), "archive");
|
|
11290
11268
|
mkdirSync13(archiveDir, { recursive: true });
|
|
11291
11269
|
const safeTopic = sanitizeTopicName(topicTitle, true);
|
|
11292
11270
|
const date = new Date().toISOString().slice(0, 10);
|
|
@@ -11314,7 +11292,7 @@ function archiveConversationEvents(topicId, topicTitle, userId, options = {}) {
|
|
|
11314
11292
|
let counter = 1;
|
|
11315
11293
|
while (true) {
|
|
11316
11294
|
const suffix = counter === 1 ? "" : `_${counter}`;
|
|
11317
|
-
const path =
|
|
11295
|
+
const path = join22(archiveDir, `${safeTopic}_${date}${reasonSuffix}_events${suffix}.jsonl`);
|
|
11318
11296
|
try {
|
|
11319
11297
|
writeFileSync11(path, body, { flag: "wx" });
|
|
11320
11298
|
logger.info({ topicId, topicTitle, archive: path, eventCount: entries.length }, "archiveConversationEvents: archived raw conversation events");
|
|
@@ -11863,7 +11841,7 @@ var init_usage_alert = __esm(() => {
|
|
|
11863
11841
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
11864
11842
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync13 } from "fs";
|
|
11865
11843
|
import { tmpdir as tmpdir4 } from "os";
|
|
11866
|
-
import { join as
|
|
11844
|
+
import { join as join23 } from "path";
|
|
11867
11845
|
function previousCompactedSummary(entries) {
|
|
11868
11846
|
for (let index = entries.length - 2;index >= 0; index -= 1) {
|
|
11869
11847
|
const request = entries[index]?.event;
|
|
@@ -11993,7 +11971,7 @@ function formatCompactElapsed(startedAt) {
|
|
|
11993
11971
|
async function summarizeTopicContext(request) {
|
|
11994
11972
|
const startedAt = Date.now();
|
|
11995
11973
|
const sessionIds = [];
|
|
11996
|
-
const compactCwd = mkdtempSync2(
|
|
11974
|
+
const compactCwd = mkdtempSync2(join23(tmpdir4(), "negotium-compact-"));
|
|
11997
11975
|
const abortController = new AbortController;
|
|
11998
11976
|
const relayAbort = () => abortController.abort(request.signal?.reason);
|
|
11999
11977
|
if (request.signal?.aborted)
|
|
@@ -12020,7 +11998,7 @@ async function summarizeTopicContext(request) {
|
|
|
12020
11998
|
let error = "";
|
|
12021
11999
|
let toolViolation = false;
|
|
12022
12000
|
let compactionLogCalls = 0;
|
|
12023
|
-
const compactionLogPath =
|
|
12001
|
+
const compactionLogPath = join23(compactCwd, "conversation.log");
|
|
12024
12002
|
try {
|
|
12025
12003
|
const compactionMcp = useCompactionLog ? {
|
|
12026
12004
|
compact_log: {
|
|
@@ -12639,14 +12617,14 @@ var init_derive = __esm(async () => {
|
|
|
12639
12617
|
});
|
|
12640
12618
|
|
|
12641
12619
|
// ../../packages/core/src/query/session-inbox-path.ts
|
|
12642
|
-
import { join as
|
|
12620
|
+
import { join as join24 } from "path";
|
|
12643
12621
|
function sessionInboxPath(userId, topicId) {
|
|
12644
12622
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
12645
|
-
return
|
|
12623
|
+
return join24(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${JSONL_SUFFIX}`);
|
|
12646
12624
|
}
|
|
12647
12625
|
function scheduledSessionInboxPath(userId, topicId) {
|
|
12648
12626
|
const key = Buffer.from(topicId, "utf8").toString("base64url");
|
|
12649
|
-
return
|
|
12627
|
+
return join24(SESSION_INBOX_DIR, userId, `${TOPIC_ID_FILE_PREFIX}${key}${SCHEDULE_SUFFIX}`);
|
|
12650
12628
|
}
|
|
12651
12629
|
var TOPIC_ID_FILE_PREFIX = "topic-id-", JSONL_SUFFIX = ".jsonl", SCHEDULE_SUFFIX = ".schedule";
|
|
12652
12630
|
var init_session_inbox_path = __esm(() => {
|
|
@@ -12655,13 +12633,13 @@ var init_session_inbox_path = __esm(() => {
|
|
|
12655
12633
|
|
|
12656
12634
|
// ../../packages/core/src/query/session-inbox-cleanup.ts
|
|
12657
12635
|
import { unlinkSync as unlinkSync15 } from "fs";
|
|
12658
|
-
import { basename as basename4, join as
|
|
12636
|
+
import { basename as basename4, join as join25 } from "path";
|
|
12659
12637
|
function cleanupSessionInboxFiles(userId, topicId, legacyTopicTitle) {
|
|
12660
12638
|
const live = sessionInboxPath(userId, topicId);
|
|
12661
12639
|
const scheduled = scheduledSessionInboxPath(userId, topicId);
|
|
12662
12640
|
const candidates = new Set([live, `${live}.processing`, scheduled, `${scheduled}.processing`]);
|
|
12663
12641
|
if (legacyTopicTitle && legacyTopicTitle !== "." && legacyTopicTitle !== ".." && basename4(legacyTopicTitle) === legacyTopicTitle) {
|
|
12664
|
-
const legacyBase =
|
|
12642
|
+
const legacyBase = join25(SESSION_INBOX_DIR, userId, legacyTopicTitle);
|
|
12665
12643
|
for (const suffix of [".jsonl", ".jsonl.processing", ".schedule", ".schedule.processing"]) {
|
|
12666
12644
|
candidates.add(`${legacyBase}${suffix}`);
|
|
12667
12645
|
}
|
|
@@ -12687,16 +12665,16 @@ var init_session_inbox_cleanup = __esm(() => {
|
|
|
12687
12665
|
|
|
12688
12666
|
// ../../packages/core/src/query/state.ts
|
|
12689
12667
|
import { mkdirSync as mkdirSync16, renameSync as renameSync9, unlinkSync as unlinkSync16, writeFileSync as writeFileSync14 } from "fs";
|
|
12690
|
-
import { basename as basename5, join as
|
|
12668
|
+
import { basename as basename5, join as join26 } from "path";
|
|
12691
12669
|
function createQueryStateStore(options) {
|
|
12692
12670
|
const sanitize = options.sanitizeTopicId ?? sanitizeId;
|
|
12693
|
-
const queryStateDirPath = (userId) =>
|
|
12694
|
-
const queryStateFile = (userId, topicId) =>
|
|
12671
|
+
const queryStateDirPath = (userId) => join26(options.usersLogDir, String(userId), "active-queries");
|
|
12672
|
+
const queryStateFile = (userId, topicId) => join26(queryStateDirPath(userId), `${sanitize(topicId)}.json`);
|
|
12695
12673
|
const legacyQueryStateFile = (userId, topicName) => {
|
|
12696
12674
|
if (!topicName || topicName === "." || topicName === ".." || basename5(topicName) !== topicName) {
|
|
12697
12675
|
return null;
|
|
12698
12676
|
}
|
|
12699
|
-
return
|
|
12677
|
+
return join26(queryStateDirPath(userId), `${topicName}.json`);
|
|
12700
12678
|
};
|
|
12701
12679
|
return {
|
|
12702
12680
|
write(userId, topicId, topicName, task) {
|
|
@@ -12857,29 +12835,29 @@ import {
|
|
|
12857
12835
|
unlinkSync as unlinkSync17,
|
|
12858
12836
|
writeFileSync as writeFileSync15
|
|
12859
12837
|
} from "fs";
|
|
12860
|
-
import { dirname as dirname16, join as
|
|
12838
|
+
import { dirname as dirname16, join as join27 } from "path";
|
|
12861
12839
|
function pendingAskDir(userId) {
|
|
12862
12840
|
const rawUserId = String(userId);
|
|
12863
12841
|
const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash5("sha256").update(rawUserId).digest("hex")}`;
|
|
12864
|
-
return
|
|
12842
|
+
return join27(resolveStorageSessionAsksDir(), safeUserId);
|
|
12865
12843
|
}
|
|
12866
12844
|
function encodeAskKey(key) {
|
|
12867
12845
|
return JSON.stringify([key.from, key.to]);
|
|
12868
12846
|
}
|
|
12869
12847
|
function pendingAskPath(key) {
|
|
12870
12848
|
const digest = createHash5("sha256").update(encodeAskKey(key)).digest("hex");
|
|
12871
|
-
return
|
|
12849
|
+
return join27(pendingAskDir(key.userId), `${ASK_FILENAME_PREFIX}${digest}.pending`);
|
|
12872
12850
|
}
|
|
12873
12851
|
function v2PendingAskPath(key) {
|
|
12874
12852
|
const encoded = Buffer.from(encodeAskKey(key), "utf8").toString("base64url");
|
|
12875
|
-
return
|
|
12853
|
+
return join27(pendingAskDir(key.userId), `${V2_ASK_FILENAME_PREFIX}${encoded}.pending`);
|
|
12876
12854
|
}
|
|
12877
12855
|
function legacyPendingAskPath(key) {
|
|
12878
12856
|
if (key.from.includes("/") || key.from.includes("\\") || key.to.includes("/") || key.to.includes("\\") || key.from.includes("\x00") || key.to.includes("\x00")) {
|
|
12879
12857
|
return null;
|
|
12880
12858
|
}
|
|
12881
12859
|
const dir = pendingAskDir(key.userId);
|
|
12882
|
-
const candidate =
|
|
12860
|
+
const candidate = join27(dir, `${key.from}___${key.to}.pending`);
|
|
12883
12861
|
return dirname16(candidate) === dir ? candidate : null;
|
|
12884
12862
|
}
|
|
12885
12863
|
function parsePendingAskFilename(fileName) {
|
|
@@ -13120,7 +13098,7 @@ function listPendingAsksForCaller(args) {
|
|
|
13120
13098
|
const parsed = isV3 ? { from: args.from, to: "" } : parsePendingAskFilename(fileName);
|
|
13121
13099
|
if (!parsed)
|
|
13122
13100
|
continue;
|
|
13123
|
-
const path =
|
|
13101
|
+
const path = join27(dir, fileName);
|
|
13124
13102
|
const record = readPendingAskFile(path, {
|
|
13125
13103
|
userId: args.userId,
|
|
13126
13104
|
from: parsed.from,
|
|
@@ -13162,7 +13140,7 @@ function deletePendingAsksForTopic(args) {
|
|
|
13162
13140
|
}
|
|
13163
13141
|
let deleted = 0;
|
|
13164
13142
|
for (const fileName of files) {
|
|
13165
|
-
const path =
|
|
13143
|
+
const path = join27(dir, fileName);
|
|
13166
13144
|
const parsed = parsePendingAskFilename(fileName);
|
|
13167
13145
|
const record = readPendingAskFile(path, {
|
|
13168
13146
|
userId: args.userId,
|
|
@@ -13600,7 +13578,7 @@ var init_self_schedules = __esm(async () => {
|
|
|
13600
13578
|
// ../../packages/core/src/storage/token-stats.ts
|
|
13601
13579
|
import { createHash as createHash6 } from "crypto";
|
|
13602
13580
|
import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync16 } from "fs";
|
|
13603
|
-
import { join as
|
|
13581
|
+
import { join as join28 } from "path";
|
|
13604
13582
|
function emptyBucket() {
|
|
13605
13583
|
return {
|
|
13606
13584
|
inputTokens: 0,
|
|
@@ -13619,7 +13597,7 @@ function queriesPath(userId) {
|
|
|
13619
13597
|
const fileId = tokenStatsFileId(userId);
|
|
13620
13598
|
const logDir = resolveStorageLogDir();
|
|
13621
13599
|
mkdirSync18(logDir, { recursive: true });
|
|
13622
|
-
return
|
|
13600
|
+
return join28(logDir, `token-queries-${fileId}.jsonl`);
|
|
13623
13601
|
}
|
|
13624
13602
|
function loadRecords(userId) {
|
|
13625
13603
|
try {
|
|
@@ -14021,7 +13999,7 @@ var init_lifecycle = __esm(async () => {
|
|
|
14021
13999
|
// ../../packages/core/src/runtime/attachments.ts
|
|
14022
14000
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
14023
14001
|
import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17 } from "fs";
|
|
14024
|
-
import { basename as basename6, join as
|
|
14002
|
+
import { basename as basename6, join as join29 } from "path";
|
|
14025
14003
|
function workspaceCwdFor(topicId) {
|
|
14026
14004
|
return resolveTopicWorkspaceDir(topicId);
|
|
14027
14005
|
}
|
|
@@ -14034,7 +14012,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
14034
14012
|
if (!attachmentIds?.length)
|
|
14035
14013
|
return [];
|
|
14036
14014
|
const out = [];
|
|
14037
|
-
const destDir =
|
|
14015
|
+
const destDir = join29(workspaceCwdFor(topicId), "attachments", queryId);
|
|
14038
14016
|
for (const rawId of attachmentIds) {
|
|
14039
14017
|
if (typeof rawId !== "string")
|
|
14040
14018
|
continue;
|
|
@@ -14051,7 +14029,7 @@ function materializePromptAttachments(topicId, queryId, attachmentIds) {
|
|
|
14051
14029
|
mkdirSync19(destDir, { recursive: true });
|
|
14052
14030
|
const index = String(out.length + 1).padStart(2, "0");
|
|
14053
14031
|
const safeName = safeAttachmentFilename(attachment.filename, fileId);
|
|
14054
|
-
const destPath =
|
|
14032
|
+
const destPath = join29(destDir, `${index}-${fileId.slice(0, 8)}-${safeName}`);
|
|
14055
14033
|
copyFileSync2(sourcePath, destPath);
|
|
14056
14034
|
out.push({
|
|
14057
14035
|
id: attachment.id,
|
|
@@ -14081,10 +14059,10 @@ function promptWithAttachments(prompt, attachments) {
|
|
|
14081
14059
|
return composeAttachmentPrompt(prompt, attachments.map(({ filename, path }) => attachmentPromptLine(filename, path)));
|
|
14082
14060
|
}
|
|
14083
14061
|
function ingestAttachment(args) {
|
|
14084
|
-
const destDir =
|
|
14062
|
+
const destDir = join29(UPLOADS_DIR, args.topicId);
|
|
14085
14063
|
mkdirSync19(destDir, { recursive: true });
|
|
14086
14064
|
const safeName = safeAttachmentFilename(args.filename, "upload");
|
|
14087
|
-
const destPath =
|
|
14065
|
+
const destPath = join29(destDir, `${Date.now()}-${randomUUID13().slice(0, 8)}-${safeName}`);
|
|
14088
14066
|
if (args.sourcePath !== undefined) {
|
|
14089
14067
|
copyFileSync2(args.sourcePath, destPath);
|
|
14090
14068
|
} else if (args.bytes !== undefined) {
|
|
@@ -15919,9 +15897,9 @@ var init_turn_session = __esm(async () => {
|
|
|
15919
15897
|
|
|
15920
15898
|
// ../../packages/core/src/storage/app-settings.ts
|
|
15921
15899
|
import { existsSync as existsSync21, mkdirSync as mkdirSync20, readFileSync as readFileSync20, writeFileSync as writeFileSync18 } from "fs";
|
|
15922
|
-
import { dirname as dirname17, join as
|
|
15900
|
+
import { dirname as dirname17, join as join30 } from "path";
|
|
15923
15901
|
function settingsFile() {
|
|
15924
|
-
return
|
|
15902
|
+
return join30(resolveStorageDataDir(), "otium-settings.json");
|
|
15925
15903
|
}
|
|
15926
15904
|
function getGlobalAiName() {
|
|
15927
15905
|
const path = settingsFile();
|
|
@@ -16016,7 +15994,7 @@ __export(exports_turn_runner, {
|
|
|
16016
15994
|
});
|
|
16017
15995
|
import { randomUUID as randomUUID16 } from "crypto";
|
|
16018
15996
|
import { existsSync as existsSync22, mkdirSync as mkdirSync21, readdirSync as readdirSync7, statSync as statSync10 } from "fs";
|
|
16019
|
-
import { join as
|
|
15997
|
+
import { join as join31 } from "path";
|
|
16020
15998
|
function withDefaultPlaywright(configuredMcp, isManager) {
|
|
16021
15999
|
if (isManager)
|
|
16022
16000
|
return configuredMcp;
|
|
@@ -16071,7 +16049,7 @@ function appendAskReplyMessage(topicId, text2, agentType) {
|
|
|
16071
16049
|
return message;
|
|
16072
16050
|
}
|
|
16073
16051
|
function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
|
|
16074
|
-
const preferred =
|
|
16052
|
+
const preferred = join31(directory, preferredFilename);
|
|
16075
16053
|
if (preferExact && existsSync22(preferred))
|
|
16076
16054
|
return preferred;
|
|
16077
16055
|
let newestLegacyId = null;
|
|
@@ -16082,7 +16060,7 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
16082
16060
|
const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
|
|
16083
16061
|
if (!titleMatch && !legacyIdMatch)
|
|
16084
16062
|
continue;
|
|
16085
|
-
const path =
|
|
16063
|
+
const path = join31(directory, filename);
|
|
16086
16064
|
const mtimeMs = statSync10(path).mtimeMs;
|
|
16087
16065
|
if (titleMatch) {
|
|
16088
16066
|
if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
|
|
@@ -16096,9 +16074,9 @@ function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, ma
|
|
|
16096
16074
|
return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
|
|
16097
16075
|
}
|
|
16098
16076
|
function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
|
|
16099
|
-
const briefFile = resolveWikiMirrorPath(
|
|
16077
|
+
const briefFile = resolveWikiMirrorPath(join31(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
|
|
16100
16078
|
const hasBriefFile = existsSync22(briefFile) && statSync10(briefFile).isFile();
|
|
16101
|
-
const latestSummaryCandidate = resolveWikiMirrorPath(
|
|
16079
|
+
const latestSummaryCandidate = resolveWikiMirrorPath(join31(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
|
|
16102
16080
|
const latestSummaryFile = existsSync22(latestSummaryCandidate) && statSync10(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
|
|
16103
16081
|
return { briefFile, hasBriefFile, latestSummaryFile };
|
|
16104
16082
|
}
|
|
@@ -17296,8 +17274,8 @@ __export(exports_auth_check, {
|
|
|
17296
17274
|
});
|
|
17297
17275
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
17298
17276
|
import { existsSync as existsSync23 } from "fs";
|
|
17299
|
-
import { homedir as
|
|
17300
|
-
import { join as
|
|
17277
|
+
import { homedir as homedir8, platform } from "os";
|
|
17278
|
+
import { join as join32 } from "path";
|
|
17301
17279
|
function hasMaestroCredential(host, key, userId) {
|
|
17302
17280
|
if (userId && host.getVaultValue(userId, key)?.trim())
|
|
17303
17281
|
return true;
|
|
@@ -17317,7 +17295,7 @@ function checkAgentAuth(agent, host = defaultAgentAuthHost, userId) {
|
|
|
17317
17295
|
case "claude": {
|
|
17318
17296
|
if (host.environment.ANTHROPIC_API_KEY)
|
|
17319
17297
|
return { ok: true };
|
|
17320
|
-
const path =
|
|
17298
|
+
const path = join32(host.homeDirectory(), ".claude", ".credentials.json");
|
|
17321
17299
|
if (host.operatingSystem() === "darwin") {
|
|
17322
17300
|
if (host.hasMacOsCredential("Claude Code-credentials") || host.exists(path)) {
|
|
17323
17301
|
return { ok: true };
|
|
@@ -17370,7 +17348,7 @@ var init_auth_check = __esm(async () => {
|
|
|
17370
17348
|
codexAuthFilePath,
|
|
17371
17349
|
exists: existsSync23,
|
|
17372
17350
|
environment: process.env,
|
|
17373
|
-
homeDirectory:
|
|
17351
|
+
homeDirectory: homedir8,
|
|
17374
17352
|
operatingSystem: platform,
|
|
17375
17353
|
hasMacOsCredential(service) {
|
|
17376
17354
|
try {
|
|
@@ -20248,7 +20226,7 @@ init_jsonl();
|
|
|
20248
20226
|
init_mcp_helpers();
|
|
20249
20227
|
import { spawn as spawn4 } from "child_process";
|
|
20250
20228
|
import { existsSync as existsSync10, readdirSync as readdirSync3 } from "fs";
|
|
20251
|
-
import { join as
|
|
20229
|
+
import { join as join11 } from "path";
|
|
20252
20230
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20253
20231
|
import { z } from "zod";
|
|
20254
20232
|
function signalProcessTree(child, signal) {
|
|
@@ -20501,7 +20479,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
|
|
|
20501
20479
|
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 () => {
|
|
20502
20480
|
if (!context.userId)
|
|
20503
20481
|
return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
|
|
20504
|
-
const stateDir =
|
|
20482
|
+
const stateDir = join11(USERS_LOG_DIR, context.userId, "active-queries");
|
|
20505
20483
|
if (!existsSync10(stateDir))
|
|
20506
20484
|
return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
|
|
20507
20485
|
let files;
|
|
@@ -20514,7 +20492,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
|
|
|
20514
20492
|
const entries = files.flatMap((file) => {
|
|
20515
20493
|
if (!file.endsWith(".json"))
|
|
20516
20494
|
return [];
|
|
20517
|
-
const state = readJsonFile(
|
|
20495
|
+
const state = readJsonFile(join11(stateDir, file));
|
|
20518
20496
|
if (!state)
|
|
20519
20497
|
return [];
|
|
20520
20498
|
const sinceMs = new Date(state.since).getTime();
|
|
@@ -20649,7 +20627,7 @@ import { z as z3 } from "zod";
|
|
|
20649
20627
|
init_logger();
|
|
20650
20628
|
await init_storage_host();
|
|
20651
20629
|
import { existsSync as existsSync11, mkdirSync as mkdirSync9, readFileSync as readFileSync10, renameSync as renameSync5, writeFileSync as writeFileSync7 } from "fs";
|
|
20652
|
-
import { dirname as dirname8, join as
|
|
20630
|
+
import { dirname as dirname8, join as join12 } from "path";
|
|
20653
20631
|
var DECISION_STATUS_VALUES = [
|
|
20654
20632
|
"proposed",
|
|
20655
20633
|
"accepted",
|
|
@@ -20668,7 +20646,7 @@ function decisionScopeKey(opts) {
|
|
|
20668
20646
|
return opts.topicId?.trim() || opts.session || "default";
|
|
20669
20647
|
}
|
|
20670
20648
|
function getDecisionFilePath(userId, scopeKey) {
|
|
20671
|
-
return
|
|
20649
|
+
return join12(resolveStorageDataDir(), "decisions", `${safeDecisionScopeKey(scopeKey)}.json`);
|
|
20672
20650
|
}
|
|
20673
20651
|
function readDecisions(userId, scopeKey) {
|
|
20674
20652
|
const path = getDecisionFilePath(userId, scopeKey);
|
|
@@ -21398,4 +21376,4 @@ export {
|
|
|
21398
21376
|
createAgentHealthMcpServer
|
|
21399
21377
|
};
|
|
21400
21378
|
|
|
21401
|
-
//# debugId=
|
|
21379
|
+
//# debugId=F3DE37975B0D9ECE64756E2164756E21
|