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