negotium 0.16.5 → 0.17.0
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 +136 -53
- package/dist/agent-helpers.js.map +9 -9
- package/dist/{chunk-8h0fya43.js → chunk-61n4gy9n.js} +1 -1
- package/dist/{chunk-krz6n9jm.js → chunk-7hdtbre6.js} +49 -18
- package/dist/{chunk-krz6n9jm.js.map → chunk-7hdtbre6.js.map} +4 -4
- package/dist/{chunk-f536ex89.js → chunk-93tfzcmm.js} +3 -3
- package/dist/{chunk-f536ex89.js.map → chunk-93tfzcmm.js.map} +2 -2
- package/dist/hosted-agent.js +70 -33
- package/dist/hosted-agent.js.map +7 -7
- package/dist/main.js +302 -99
- package/dist/main.js.map +17 -17
- package/dist/mcp-factories.js +135 -52
- package/dist/mcp-factories.js.map +9 -9
- package/dist/prompts.js +2 -2
- package/dist/prompts.js.map +2 -2
- package/dist/registry.js +3 -3
- package/dist/rollout.js +2 -2
- package/dist/runtime/src/agents/claude-provider.ts +20 -1
- package/dist/runtime/src/agents/codex-provider.ts +17 -6
- package/dist/runtime/src/agents/index.ts +3 -0
- package/dist/runtime/src/node-host.ts +1 -0
- package/dist/runtime/src/platform/mcp-config.ts +101 -21
- package/dist/runtime/src/platform/paths.ts +16 -2
- package/dist/runtime/src/prompts/builders.ts +1 -1
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +2 -2
- package/dist/runtime-helpers.js.map +3 -3
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +25 -13
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-8h0fya43.js.map → chunk-61n4gy9n.js.map} +0 -0
package/dist/agent-helpers.js
CHANGED
|
@@ -19,11 +19,22 @@ var __require = import.meta.require;
|
|
|
19
19
|
|
|
20
20
|
// ../../packages/core/src/platform/paths.ts
|
|
21
21
|
import { existsSync, realpathSync } from "fs";
|
|
22
|
-
import { isAbsolute, relative, resolve, sep } from "path";
|
|
22
|
+
import { dirname, isAbsolute, relative, resolve, sep } from "path";
|
|
23
23
|
function normalizeExistingOrResolved(filePath) {
|
|
24
24
|
const resolved = resolve(filePath);
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
if (existsSync(resolved))
|
|
27
|
+
return realpathSync(resolved);
|
|
28
|
+
let ancestor = resolved;
|
|
29
|
+
for (;; ) {
|
|
30
|
+
const parent = dirname(ancestor);
|
|
31
|
+
if (parent === ancestor)
|
|
32
|
+
return resolved;
|
|
33
|
+
ancestor = parent;
|
|
34
|
+
if (existsSync(ancestor)) {
|
|
35
|
+
return resolve(realpathSync(ancestor), relative(ancestor, resolved));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
27
38
|
} catch {
|
|
28
39
|
return resolved;
|
|
29
40
|
}
|
|
@@ -186,7 +197,7 @@ import {
|
|
|
186
197
|
} from "fs";
|
|
187
198
|
import { createRequire } from "module";
|
|
188
199
|
import { homedir } from "os";
|
|
189
|
-
import { dirname, join, resolve as resolve3 } from "path";
|
|
200
|
+
import { dirname as dirname2, join, resolve as resolve3 } from "path";
|
|
190
201
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
191
202
|
function envText(envKey) {
|
|
192
203
|
return readEnvText(process.env, envKey);
|
|
@@ -197,7 +208,7 @@ function resolveStateDir() {
|
|
|
197
208
|
return configured ? resolve3(configured) : resolve3(HOME, ".negotium");
|
|
198
209
|
}
|
|
199
210
|
function resolveProjectRoot() {
|
|
200
|
-
const moduleDir =
|
|
211
|
+
const moduleDir = dirname2(fileURLToPath(import.meta.url));
|
|
201
212
|
const packagedRuntime = resolve3(moduleDir, "runtime");
|
|
202
213
|
if (existsSync2(resolve3(packagedRuntime, "src")))
|
|
203
214
|
return packagedRuntime;
|
|
@@ -217,7 +228,7 @@ function resolveDependencyBin(name) {
|
|
|
217
228
|
if (existsSync2(path))
|
|
218
229
|
return path;
|
|
219
230
|
}
|
|
220
|
-
const parent =
|
|
231
|
+
const parent = dirname2(dir);
|
|
221
232
|
if (parent === dir)
|
|
222
233
|
return resolve3(binDir, name);
|
|
223
234
|
dir = parent;
|
|
@@ -325,7 +336,7 @@ function resolveTopicWorkspaceDir(topicId) {
|
|
|
325
336
|
function loadOrCreateLocalSecret(envKey, filename, options = {}) {
|
|
326
337
|
const envValue = envText(envKey);
|
|
327
338
|
const secretFile = resolve3(SECRETS_DIR, filename);
|
|
328
|
-
mkdirSync(
|
|
339
|
+
mkdirSync(dirname2(secretFile), { recursive: true });
|
|
329
340
|
if (envValue) {
|
|
330
341
|
if (options.persistEnvValue) {
|
|
331
342
|
writeFileSync(secretFile, `${envValue}
|
|
@@ -1024,9 +1035,12 @@ function backgroundBashTransport(agent, port, userId, topic) {
|
|
|
1024
1035
|
}
|
|
1025
1036
|
function refreshForumCatalogViews() {
|
|
1026
1037
|
const { all, required, optional } = classifyForumMcpServers(MCP_CATALOG);
|
|
1027
|
-
|
|
1038
|
+
const nodeNames = nodeMcpEntries.map((entry) => entry.key);
|
|
1039
|
+
const allWithNodeEntries = [...new Set([...all, ...nodeNames])];
|
|
1040
|
+
const optionalWithNodeEntries = [...new Set([...optional, ...nodeNames])];
|
|
1041
|
+
allForumMcpServerNames.splice(0, allForumMcpServerNames.length, ...allWithNodeEntries);
|
|
1028
1042
|
requiredForumMcpServers.splice(0, requiredForumMcpServers.length, ...required);
|
|
1029
|
-
optionalForumMcpServers.splice(0, optionalForumMcpServers.length, ...
|
|
1043
|
+
optionalForumMcpServers.splice(0, optionalForumMcpServers.length, ...optionalWithNodeEntries);
|
|
1030
1044
|
}
|
|
1031
1045
|
function isReservedRuntimeMcpServerName(name) {
|
|
1032
1046
|
return Object.hasOwn(MCP_CATALOG, name) || nodeMcpEntries.some((entry) => entry.key === name);
|
|
@@ -1041,12 +1055,22 @@ function mergeHostMcpServers(base, hostMcpServers) {
|
|
|
1041
1055
|
}
|
|
1042
1056
|
return { ...base, ...hostMcpServers };
|
|
1043
1057
|
}
|
|
1044
|
-
function buildNodeMcpSpecs(agent, filter) {
|
|
1058
|
+
function buildNodeMcpSpecs(agent, filter, ctx) {
|
|
1045
1059
|
const out = {};
|
|
1046
1060
|
for (const entry of nodeMcpEntries) {
|
|
1047
1061
|
if (!filter(entry.key))
|
|
1048
1062
|
continue;
|
|
1049
|
-
|
|
1063
|
+
if (entry.kind === "http") {
|
|
1064
|
+
out[entry.key] = longLivedHttpMcp(agent, entry.port);
|
|
1065
|
+
continue;
|
|
1066
|
+
}
|
|
1067
|
+
if (entry.kind === "http-instance") {
|
|
1068
|
+
const port = resolvedNodeMcpPorts.get(entry)?.get(nodeMcpInstanceKey(ctx));
|
|
1069
|
+
if (port !== undefined)
|
|
1070
|
+
out[entry.key] = longLivedHttpMcp(agent, port);
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
out[entry.key] = {
|
|
1050
1074
|
command: entry.command,
|
|
1051
1075
|
args: entry.args ?? [],
|
|
1052
1076
|
...entry.env ? { env: entry.env } : {}
|
|
@@ -1054,6 +1078,42 @@ function buildNodeMcpSpecs(agent, filter) {
|
|
|
1054
1078
|
}
|
|
1055
1079
|
return out;
|
|
1056
1080
|
}
|
|
1081
|
+
function nodeMcpInstanceKey(ctx) {
|
|
1082
|
+
return ctx.topicId ?? `user:${ctx.userId}:session:${ctx.session}`;
|
|
1083
|
+
}
|
|
1084
|
+
async function prepareNodeMcpServersForQuery(opts) {
|
|
1085
|
+
if (opts.toolPolicy || opts.sessionType === "cron" || nodeMcpEntries.every((entry) => entry.kind !== "http-instance")) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
const forum = !["dm", "ephemeral", "manager"].includes(opts.sessionType ?? "forum");
|
|
1089
|
+
const enabled = opts.mcpEnabled ?? null;
|
|
1090
|
+
const instanceKey = nodeMcpInstanceKey({
|
|
1091
|
+
topicId: opts.topicId,
|
|
1092
|
+
userId: opts.userId || "local",
|
|
1093
|
+
session: opts.session || "default"
|
|
1094
|
+
});
|
|
1095
|
+
await Promise.all(nodeMcpEntries.map(async (entry) => {
|
|
1096
|
+
if (entry.kind !== "http-instance")
|
|
1097
|
+
return;
|
|
1098
|
+
if (forum && enabled !== null && !enabled.includes(entry.key))
|
|
1099
|
+
return;
|
|
1100
|
+
let ports = resolvedNodeMcpPorts.get(entry);
|
|
1101
|
+
if (!ports) {
|
|
1102
|
+
ports = new Map;
|
|
1103
|
+
resolvedNodeMcpPorts.set(entry, ports);
|
|
1104
|
+
}
|
|
1105
|
+
try {
|
|
1106
|
+
const port = await entry.ensurePort(instanceKey);
|
|
1107
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
1108
|
+
throw new Error(`invalid port ${port}`);
|
|
1109
|
+
}
|
|
1110
|
+
ports.set(instanceKey, port);
|
|
1111
|
+
} catch (err) {
|
|
1112
|
+
ports.delete(instanceKey);
|
|
1113
|
+
logger.warn({ err, key: entry.key, instanceKey }, "node mcp: failed to prepare instance-scoped server");
|
|
1114
|
+
}
|
|
1115
|
+
}));
|
|
1116
|
+
}
|
|
1057
1117
|
function buildScope(scope, ctx, filter = () => true) {
|
|
1058
1118
|
const out = {};
|
|
1059
1119
|
for (const [name, entry] of Object.entries(MCP_CATALOG)) {
|
|
@@ -1067,14 +1127,15 @@ function buildScope(scope, ctx, filter = () => true) {
|
|
|
1067
1127
|
out[name] = spec;
|
|
1068
1128
|
}
|
|
1069
1129
|
if (scope !== "cron") {
|
|
1070
|
-
Object.assign(out, buildNodeMcpSpecs(ctx.agent, filter));
|
|
1130
|
+
Object.assign(out, buildNodeMcpSpecs(ctx.agent, filter, ctx));
|
|
1071
1131
|
}
|
|
1072
1132
|
return out;
|
|
1073
1133
|
}
|
|
1074
1134
|
function getDmMcpServers(opts) {
|
|
1075
1135
|
return buildScope("dm", {
|
|
1076
1136
|
userId: opts.userId,
|
|
1077
|
-
session: "dm",
|
|
1137
|
+
session: opts.session ?? "dm",
|
|
1138
|
+
topicId: opts.topicId,
|
|
1078
1139
|
agent: opts.agent,
|
|
1079
1140
|
playwrightPort: opts.playwrightPort,
|
|
1080
1141
|
playwrightCapability: opts.playwrightCapability
|
|
@@ -1211,6 +1272,8 @@ function getMcpServersForQuery(opts) {
|
|
|
1211
1272
|
if (opts.sessionType === "dm" || opts.sessionType === "ephemeral") {
|
|
1212
1273
|
return getDmMcpServers({
|
|
1213
1274
|
userId: opts.userId || "local",
|
|
1275
|
+
session: opts.session,
|
|
1276
|
+
topicId: opts.topicId,
|
|
1214
1277
|
agent: opts.agent,
|
|
1215
1278
|
playwrightPort: opts.playwrightPort,
|
|
1216
1279
|
playwrightCapability: opts.playwrightCapability
|
|
@@ -1262,7 +1325,7 @@ function getMcpServersForQuery(opts) {
|
|
|
1262
1325
|
peerBridge: opts.peerBridge
|
|
1263
1326
|
});
|
|
1264
1327
|
}
|
|
1265
|
-
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, cuaRsMcpPort, cuaRsMcpToken, MCP_CATALOG, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers
|
|
1328
|
+
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, cuaRsMcpPort, cuaRsMcpToken, MCP_CATALOG, nodeMcpEntries, resolvedNodeMcpPorts, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers;
|
|
1266
1329
|
var init_mcp_config = __esm(() => {
|
|
1267
1330
|
init_canonical_bridge_config();
|
|
1268
1331
|
init_runtime_spec();
|
|
@@ -1497,12 +1560,13 @@ var init_mcp_config = __esm(() => {
|
|
|
1497
1560
|
}
|
|
1498
1561
|
}
|
|
1499
1562
|
};
|
|
1563
|
+
nodeMcpEntries = [];
|
|
1564
|
+
resolvedNodeMcpPorts = new WeakMap;
|
|
1500
1565
|
allForumMcpServerNames = [];
|
|
1501
1566
|
requiredForumMcpServers = [];
|
|
1502
1567
|
REQUIRED_FORUM_MCP_SERVERS = requiredForumMcpServers;
|
|
1503
1568
|
optionalForumMcpServers = [];
|
|
1504
1569
|
refreshForumCatalogViews();
|
|
1505
|
-
nodeMcpEntries = [];
|
|
1506
1570
|
});
|
|
1507
1571
|
|
|
1508
1572
|
// ../../packages/core/src/storage/sqlite.ts
|
|
@@ -1570,7 +1634,7 @@ var init_sqlite = __esm(async () => {
|
|
|
1570
1634
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1571
1635
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
1572
1636
|
import { homedir as homedir2 } from "os";
|
|
1573
|
-
import { dirname as
|
|
1637
|
+
import { dirname as dirname3, join as join2, resolve as resolve4 } from "path";
|
|
1574
1638
|
function storageState() {
|
|
1575
1639
|
const holder = globalThis;
|
|
1576
1640
|
const existing = holder[STORAGE_HOST_STATE];
|
|
@@ -1649,7 +1713,7 @@ function defaultDatabase() {
|
|
|
1649
1713
|
return state.fallbackDatabase;
|
|
1650
1714
|
if (state.fallbackDatabase)
|
|
1651
1715
|
closeDatabase(state.fallbackDatabase);
|
|
1652
|
-
mkdirSync2(
|
|
1716
|
+
mkdirSync2(dirname3(path), { recursive: true });
|
|
1653
1717
|
state.fallbackDatabase = new Database(path, { create: true });
|
|
1654
1718
|
state.fallbackDatabasePath = path;
|
|
1655
1719
|
initializeDatabase(state.fallbackDatabase);
|
|
@@ -1927,7 +1991,7 @@ var init_vault = __esm(async () => {
|
|
|
1927
1991
|
|
|
1928
1992
|
// ../../packages/core/src/agents/execution-host.ts
|
|
1929
1993
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1930
|
-
import { dirname as
|
|
1994
|
+
import { dirname as dirname4 } from "path";
|
|
1931
1995
|
function activeHost() {
|
|
1932
1996
|
const scoped = scopedHost.getStore();
|
|
1933
1997
|
if (scoped)
|
|
@@ -1962,7 +2026,7 @@ function hostedCodexAuthFilePath() {
|
|
|
1962
2026
|
return activeHost().codexAuthFilePath();
|
|
1963
2027
|
}
|
|
1964
2028
|
function hostedCodexHomePath() {
|
|
1965
|
-
return
|
|
2029
|
+
return dirname4(hostedCodexAuthFilePath());
|
|
1966
2030
|
}
|
|
1967
2031
|
var defaultHost, hostRegistrations, scopedHost;
|
|
1968
2032
|
var init_execution_host = __esm(async () => {
|
|
@@ -2247,7 +2311,7 @@ import {
|
|
|
2247
2311
|
unlinkSync as unlinkSync2,
|
|
2248
2312
|
writeFileSync as writeFileSync2
|
|
2249
2313
|
} from "fs";
|
|
2250
|
-
import { dirname as
|
|
2314
|
+
import { dirname as dirname5 } from "path";
|
|
2251
2315
|
function readJsonlLines(filePath) {
|
|
2252
2316
|
return readFileSync2(filePath, "utf-8").trim().split(`
|
|
2253
2317
|
`).filter(Boolean);
|
|
@@ -2288,7 +2352,7 @@ function appendJsonlEntry(filePath, entry) {
|
|
|
2288
2352
|
`);
|
|
2289
2353
|
}
|
|
2290
2354
|
function appendJsonlLine(filePath, line) {
|
|
2291
|
-
mkdirSync5(
|
|
2355
|
+
mkdirSync5(dirname5(filePath), { recursive: true });
|
|
2292
2356
|
const lockPath = `${filePath}${LOCK_SUFFIX}`;
|
|
2293
2357
|
const payload = line.endsWith(`
|
|
2294
2358
|
`) ? line : `${line}
|
|
@@ -2319,7 +2383,7 @@ function appendJsonlLine(filePath, line) {
|
|
|
2319
2383
|
}
|
|
2320
2384
|
}
|
|
2321
2385
|
function writeJsonlFile(filePath, entries) {
|
|
2322
|
-
const dir =
|
|
2386
|
+
const dir = dirname5(filePath);
|
|
2323
2387
|
mkdirSync5(dir, { recursive: true });
|
|
2324
2388
|
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2325
2389
|
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
@@ -2587,7 +2651,7 @@ var init_claude_registry = __esm(() => {
|
|
|
2587
2651
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2588
2652
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
2589
2653
|
import { existsSync as existsSync5, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync2, unlinkSync as unlinkSync4 } from "fs";
|
|
2590
|
-
import { basename, dirname as
|
|
2654
|
+
import { basename, dirname as dirname6, join as join6, resolve as resolve6 } from "path";
|
|
2591
2655
|
function codexSessionsDir() {
|
|
2592
2656
|
return join6(hostedCodexHomePath(), "sessions");
|
|
2593
2657
|
}
|
|
@@ -2670,7 +2734,7 @@ function canonicalFilePath(path) {
|
|
|
2670
2734
|
return realpathSync3(absolute);
|
|
2671
2735
|
} catch {
|
|
2672
2736
|
try {
|
|
2673
|
-
return join6(realpathSync3(
|
|
2737
|
+
return join6(realpathSync3(dirname6(absolute)), basename(absolute));
|
|
2674
2738
|
} catch {
|
|
2675
2739
|
return absolute;
|
|
2676
2740
|
}
|
|
@@ -3119,7 +3183,7 @@ var init_codex = __esm(async () => {
|
|
|
3119
3183
|
});
|
|
3120
3184
|
|
|
3121
3185
|
// ../../packages/core/src/version.ts
|
|
3122
|
-
var NEGOTIUM_VERSION = "0.
|
|
3186
|
+
var NEGOTIUM_VERSION = "0.17.0";
|
|
3123
3187
|
|
|
3124
3188
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
3125
3189
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -3137,7 +3201,7 @@ import {
|
|
|
3137
3201
|
} from "fs";
|
|
3138
3202
|
import { createRequire as createRequire2 } from "module";
|
|
3139
3203
|
import { tmpdir } from "os";
|
|
3140
|
-
import { dirname as
|
|
3204
|
+
import { dirname as dirname7, join as join7 } from "path";
|
|
3141
3205
|
function readPackageVersion(packageJsonPath) {
|
|
3142
3206
|
const parsed = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
|
|
3143
3207
|
if (typeof parsed.version !== "string" || !parsed.version.trim()) {
|
|
@@ -3146,7 +3210,7 @@ function readPackageVersion(packageJsonPath) {
|
|
|
3146
3210
|
return parsed.version;
|
|
3147
3211
|
}
|
|
3148
3212
|
function codexCliScriptPath() {
|
|
3149
|
-
return join7(
|
|
3213
|
+
return join7(dirname7(bundledCodexPackagePath), "bin", "codex.js");
|
|
3150
3214
|
}
|
|
3151
3215
|
function parseCodexModelCache(contents, sourcePath) {
|
|
3152
3216
|
let parsed;
|
|
@@ -3187,7 +3251,7 @@ function writePrivateFileAtomic(path, contents) {
|
|
|
3187
3251
|
}
|
|
3188
3252
|
}
|
|
3189
3253
|
function bundledCodexModelCachePath(authFilePath) {
|
|
3190
|
-
return join7(
|
|
3254
|
+
return join7(dirname7(authFilePath), NEGOTIUM_MODEL_CACHE);
|
|
3191
3255
|
}
|
|
3192
3256
|
async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
3193
3257
|
const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
|
|
@@ -3273,7 +3337,7 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
3273
3337
|
});
|
|
3274
3338
|
}
|
|
3275
3339
|
async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
3276
|
-
const sourceHome =
|
|
3340
|
+
const sourceHome = dirname7(authFilePath);
|
|
3277
3341
|
const isolatedHome = mkdtempSync(join7(tmpdir(), "negotium-codex-models-"));
|
|
3278
3342
|
const isolatedCachePath = join7(isolatedHome, "models_cache.json");
|
|
3279
3343
|
try {
|
|
@@ -3293,7 +3357,7 @@ async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
|
3293
3357
|
}
|
|
3294
3358
|
}
|
|
3295
3359
|
async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexModelCache) {
|
|
3296
|
-
const codexHome =
|
|
3360
|
+
const codexHome = dirname7(authFilePath);
|
|
3297
3361
|
const configuredCachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE;
|
|
3298
3362
|
if (configuredCachePath) {
|
|
3299
3363
|
if (!existsSync6(configuredCachePath)) {
|
|
@@ -3322,7 +3386,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
3322
3386
|
return bundledCachePath;
|
|
3323
3387
|
}
|
|
3324
3388
|
function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
|
|
3325
|
-
const codexHome =
|
|
3389
|
+
const codexHome = dirname7(authFilePath);
|
|
3326
3390
|
const outputPath = join7(codexHome, NEGOTIUM_MODEL_CATALOG);
|
|
3327
3391
|
const parsed = readCodexModelCache(sourcePath).parsed;
|
|
3328
3392
|
const models = parsed.models.map((model, index) => {
|
|
@@ -3739,7 +3803,7 @@ function sanitizeId(id) {
|
|
|
3739
3803
|
|
|
3740
3804
|
// ../../packages/core/src/storage/tasks.ts
|
|
3741
3805
|
import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync7, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
3742
|
-
import { dirname as
|
|
3806
|
+
import { dirname as dirname8, join as join10 } from "path";
|
|
3743
3807
|
function safeTaskScopeKey(scopeKey) {
|
|
3744
3808
|
const safe = sanitizeFileName(scopeKey);
|
|
3745
3809
|
if (!safe || safe === "." || safe === "..") {
|
|
@@ -3851,7 +3915,7 @@ import {
|
|
|
3851
3915
|
unlinkSync as unlinkSync7,
|
|
3852
3916
|
writeFileSync as writeFileSync7
|
|
3853
3917
|
} from "fs";
|
|
3854
|
-
import { dirname as
|
|
3918
|
+
import { dirname as dirname9, join as join11 } from "path";
|
|
3855
3919
|
function conversationDir(_userId) {
|
|
3856
3920
|
return join11(resolveStorageDataDir(), "conversations");
|
|
3857
3921
|
}
|
|
@@ -3889,7 +3953,7 @@ function appendConversationEventStrict(userId, topicName, agent, event) {
|
|
|
3889
3953
|
event
|
|
3890
3954
|
};
|
|
3891
3955
|
const line = JSON.stringify(entry);
|
|
3892
|
-
mkdirSync9(
|
|
3956
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
3893
3957
|
appendJsonlLine(path, line);
|
|
3894
3958
|
const activePath = getActiveConversationPath(userId, topicName);
|
|
3895
3959
|
if (existsSync10(activePath)) {
|
|
@@ -3907,7 +3971,7 @@ function appendRawConversationEventStrict(userId, topicName, agent, event) {
|
|
|
3907
3971
|
agent,
|
|
3908
3972
|
event
|
|
3909
3973
|
};
|
|
3910
|
-
mkdirSync9(
|
|
3974
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
3911
3975
|
appendJsonlLine(path, JSON.stringify(entry));
|
|
3912
3976
|
}
|
|
3913
3977
|
function readConversationPath(path) {
|
|
@@ -3948,7 +4012,7 @@ function replaceRawConversationStrict(userId, topicName, entries) {
|
|
|
3948
4012
|
}
|
|
3949
4013
|
function replaceConversationPathStrict(path, entries) {
|
|
3950
4014
|
const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
3951
|
-
mkdirSync9(
|
|
4015
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
3952
4016
|
try {
|
|
3953
4017
|
writeFileSync7(tempPath, entries.length > 0 ? `${entries.map((entry) => JSON.stringify(entry)).join(`
|
|
3954
4018
|
`)}
|
|
@@ -4630,9 +4694,19 @@ var init_claude_provider = __esm(async () => {
|
|
|
4630
4694
|
"ScheduleWakeup",
|
|
4631
4695
|
"CronCreate",
|
|
4632
4696
|
"CronList",
|
|
4633
|
-
"CronDelete"
|
|
4697
|
+
"CronDelete",
|
|
4698
|
+
"RemoteTrigger"
|
|
4699
|
+
];
|
|
4700
|
+
CLAUDE_NATIVE_AGENT_TOOLS = [
|
|
4701
|
+
"Task",
|
|
4702
|
+
"Agent",
|
|
4703
|
+
"TaskOutput",
|
|
4704
|
+
"TaskStop",
|
|
4705
|
+
"ListAgents",
|
|
4706
|
+
"SendMessage",
|
|
4707
|
+
"TeamCreate",
|
|
4708
|
+
"TeamDelete"
|
|
4634
4709
|
];
|
|
4635
|
-
CLAUDE_NATIVE_AGENT_TOOLS = ["Task", "Agent", "TaskOutput", "TaskStop"];
|
|
4636
4710
|
CLAUDE_IMAGE_MAX_BYTES = 10 * 1024 * 1024;
|
|
4637
4711
|
CLAUDE_IMAGE_MIME_TYPES = new Set([
|
|
4638
4712
|
"image/jpeg",
|
|
@@ -4892,7 +4966,7 @@ import { existsSync as existsSync12 } from "fs";
|
|
|
4892
4966
|
import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
|
|
4893
4967
|
import { createServer } from "net";
|
|
4894
4968
|
import { tmpdir as tmpdir2 } from "os";
|
|
4895
|
-
import { dirname as
|
|
4969
|
+
import { dirname as dirname10, join as join12, resolve as resolve8 } from "path";
|
|
4896
4970
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4897
4971
|
function evaluateCodexVaultPreToolUse(input, userId, operations) {
|
|
4898
4972
|
if (operations.referencesSensitiveStorage(input.tool_input)) {
|
|
@@ -4921,7 +4995,7 @@ function shellQuote(value) {
|
|
|
4921
4995
|
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
4922
4996
|
}
|
|
4923
4997
|
function hookClientPath() {
|
|
4924
|
-
const moduleDir =
|
|
4998
|
+
const moduleDir = dirname10(fileURLToPath2(import.meta.url));
|
|
4925
4999
|
const adjacent = resolve8(moduleDir, "codex-vault-hook.mjs");
|
|
4926
5000
|
if (existsSync12(adjacent))
|
|
4927
5001
|
return adjacent;
|
|
@@ -5570,7 +5644,7 @@ __export(exports_codex_provider, {
|
|
|
5570
5644
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
5571
5645
|
import { existsSync as existsSync13, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
|
|
5572
5646
|
import { homedir as homedir6 } from "os";
|
|
5573
|
-
import { dirname as
|
|
5647
|
+
import { dirname as dirname11, isAbsolute as isAbsolute3, join as join13, relative as relative2, resolve as resolve10 } from "path";
|
|
5574
5648
|
import { Codex } from "@openai/codex-sdk";
|
|
5575
5649
|
function sameCodexUsage(usage, total) {
|
|
5576
5650
|
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;
|
|
@@ -5598,7 +5672,7 @@ function codexMcpServerName(name) {
|
|
|
5598
5672
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
5599
5673
|
}
|
|
5600
5674
|
function globalCodexMcpServerNames(authFilePath) {
|
|
5601
|
-
const configPath = join13(
|
|
5675
|
+
const configPath = join13(dirname11(authFilePath), "config.toml");
|
|
5602
5676
|
if (!existsSync13(configPath))
|
|
5603
5677
|
return [];
|
|
5604
5678
|
try {
|
|
@@ -5978,7 +6052,14 @@ async function* codexProvider(opts) {
|
|
|
5978
6052
|
codexPathOverride: vaultHook.codexPathOverride,
|
|
5979
6053
|
...codexEnvironment ? { env: codexEnvironment } : {},
|
|
5980
6054
|
config: {
|
|
5981
|
-
|
|
6055
|
+
agents: { enabled: false },
|
|
6056
|
+
features: {
|
|
6057
|
+
hooks: true,
|
|
6058
|
+
goals: false,
|
|
6059
|
+
multi_agent: false,
|
|
6060
|
+
multi_agent_v2: false,
|
|
6061
|
+
enable_fanout: false
|
|
6062
|
+
},
|
|
5982
6063
|
hooks: vaultHook.hooks,
|
|
5983
6064
|
model_catalog_json: codexModelCatalogPath,
|
|
5984
6065
|
mcp_servers: codexMcpServers,
|
|
@@ -6504,6 +6585,7 @@ async function* runAgent(opts) {
|
|
|
6504
6585
|
return;
|
|
6505
6586
|
}
|
|
6506
6587
|
}
|
|
6588
|
+
await prepareNodeMcpServersForQuery(dispatchOpts);
|
|
6507
6589
|
const taskScope = resolveTaskEventScope(dispatchOpts);
|
|
6508
6590
|
const stream = taskScope ? withTaskSnapshots(dispatchAgent(dispatchOpts), taskScope) : dispatchAgent(dispatchOpts);
|
|
6509
6591
|
for await (const event of stream) {
|
|
@@ -6517,6 +6599,7 @@ var loadClaudeProvider, loadCodexProvider, loadMaestroProvider;
|
|
|
6517
6599
|
var init_agents = __esm(async () => {
|
|
6518
6600
|
init_claude();
|
|
6519
6601
|
init_logger();
|
|
6602
|
+
init_mcp_config();
|
|
6520
6603
|
init_types();
|
|
6521
6604
|
await __promiseAll([
|
|
6522
6605
|
init_execution_host(),
|
|
@@ -7205,7 +7288,7 @@ function buildRuntimeToolSection(opts, extensions) {
|
|
|
7205
7288
|
"A subagent starts fresh but inherits this room's agent, model, and effective topic memory; include all required context, paths, and acceptance criteria in `task`.",
|
|
7206
7289
|
"Subagents run asynchronously. Choose one result path: `auto` returns the final body to the direct parent; `tell` requires child `tell_session` to its recipient and does not auto-return the body; `status-only` returns lifecycle without content. Runtime length alone does not justify `status-only`. Do not wait or poll; continue or finish the turn."
|
|
7207
7290
|
] : [];
|
|
7208
|
-
const nativeTaskPolicyLine = agentKind === "claude" ? `Do not use provider-native todo/task/subagent tools such as "TodoWrite", "Task", "Agent", "TaskCreate", "TaskUpdate", "TaskList", "TaskOutput", or "TaskStop"; they are disabled or not shared across agents.${canSpawnSubagents ? " For delegation, use the runtime spawn_subagent tool instead." : ""}` : agentKind === "maestro" ? `Do not use provider-native task-store tools such as "TaskCreate", "TaskUpdate", "TaskList", "TaskGet", "TaskOutput", or "TaskStop"; they are disabled or not shared across agents. Do not use the Maestro "Agent" sub-agent tool either; it is disabled.${canSpawnSubagents ? " Use the runtime spawn_subagent tool for delegation so work is visible in its own room and reporting follows report_mode." : " Delegation is unavailable in this room."}` : 'Do not use provider-native todo/plan surfaces such as "todo_list" or "update_plan"; they are ignored or not shared across agents.';
|
|
7291
|
+
const nativeTaskPolicyLine = agentKind === "claude" ? `Do not use provider-native todo/task/subagent tools such as "TodoWrite", "Task", "Agent", "TaskCreate", "TaskUpdate", "TaskList", "TaskOutput", or "TaskStop"; they are disabled or not shared across agents.${canSpawnSubagents ? " For delegation, use the runtime spawn_subagent tool instead." : ""}` : agentKind === "maestro" ? `Do not use provider-native task-store tools such as "TaskCreate", "TaskUpdate", "TaskList", "TaskGet", "TaskOutput", or "TaskStop"; they are disabled or not shared across agents. Do not use the Maestro "Agent" sub-agent tool either; it is disabled.${canSpawnSubagents ? " Use the runtime spawn_subagent tool for delegation so work is visible in its own room and reporting follows report_mode." : " Delegation is unavailable in this room."}` : 'Do not use provider-native goal/todo/plan surfaces such as "create_goal", "get_goal", "update_goal", "todo_list", or "update_plan"; they are disabled, ignored, or not shared across agents.';
|
|
7209
7292
|
const visualSection = visualTools ? [
|
|
7210
7293
|
visualToolLine,
|
|
7211
7294
|
mermaidToolLine,
|
|
@@ -8483,7 +8566,7 @@ var init_api_topics = __esm(async () => {
|
|
|
8483
8566
|
});
|
|
8484
8567
|
|
|
8485
8568
|
// ../../packages/core/src/storage/wiki.ts
|
|
8486
|
-
import { basename as basename3, dirname as
|
|
8569
|
+
import { basename as basename3, dirname as dirname12, join as join15 } from "path";
|
|
8487
8570
|
function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
|
|
8488
8571
|
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join15(workspaceDir, "wiki");
|
|
8489
8572
|
}
|
|
@@ -11726,11 +11809,11 @@ import {
|
|
|
11726
11809
|
unlinkSync as unlinkSync11,
|
|
11727
11810
|
writeFileSync as writeFileSync9
|
|
11728
11811
|
} from "fs";
|
|
11729
|
-
import { dirname as
|
|
11812
|
+
import { dirname as dirname13, join as join20, resolve as resolve16 } from "path";
|
|
11730
11813
|
function removeDefaultProfileDataDir(userDataDir) {
|
|
11731
11814
|
const root = resolve16(BROWSER_PROFILES_DIR);
|
|
11732
11815
|
const target = resolve16(userDataDir);
|
|
11733
|
-
if (
|
|
11816
|
+
if (dirname13(target) !== root) {
|
|
11734
11817
|
throw new Error(`Refusing to delete browser profile outside managed root: ${target}`);
|
|
11735
11818
|
}
|
|
11736
11819
|
const existed = existsSync19(target);
|
|
@@ -12310,7 +12393,7 @@ async function cloneProfileForChild(opts) {
|
|
|
12310
12393
|
if (existsSync19(dstDir)) {
|
|
12311
12394
|
rmSync3(dstDir, { recursive: true, force: true });
|
|
12312
12395
|
}
|
|
12313
|
-
mkdirSync11(
|
|
12396
|
+
mkdirSync11(dirname13(dstDir), { recursive: true });
|
|
12314
12397
|
if (process.platform === "darwin") {
|
|
12315
12398
|
try {
|
|
12316
12399
|
execFileSync7("cp", ["-cR", srcDir, dstDir], { stdio: "pipe" });
|
|
@@ -12911,7 +12994,7 @@ var init_idle_compact = __esm(async () => {
|
|
|
12911
12994
|
|
|
12912
12995
|
// ../../packages/core/src/agents/topic-cleanup.ts
|
|
12913
12996
|
import { mkdirSync as mkdirSync13, renameSync as renameSync6, unlinkSync as unlinkSync12, writeFileSync as writeFileSync11 } from "fs";
|
|
12914
|
-
import { dirname as
|
|
12997
|
+
import { dirname as dirname14 } from "path";
|
|
12915
12998
|
function collectSessionIdsByAgent(entries, extraSessions = []) {
|
|
12916
12999
|
const out = new Map;
|
|
12917
13000
|
for (const e of entries) {
|
|
@@ -12977,7 +13060,7 @@ function createTopicLogMaintenance(host) {
|
|
|
12977
13060
|
const path = runtimeHost.activeConversationPath(opts.userId, opts.topicName);
|
|
12978
13061
|
const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
12979
13062
|
try {
|
|
12980
|
-
mkdirSync13(
|
|
13063
|
+
mkdirSync13(dirname14(path), { recursive: true });
|
|
12981
13064
|
writeFileSync11(tempPath, retained.length > 0 ? `${retained.map((entry) => JSON.stringify(entry)).join(`
|
|
12982
13065
|
`)}
|
|
12983
13066
|
` : "", { flag: "wx" });
|
|
@@ -14844,7 +14927,7 @@ import {
|
|
|
14844
14927
|
unlinkSync as unlinkSync16,
|
|
14845
14928
|
writeFileSync as writeFileSync14
|
|
14846
14929
|
} from "fs";
|
|
14847
|
-
import { dirname as
|
|
14930
|
+
import { dirname as dirname15, join as join27 } from "path";
|
|
14848
14931
|
function pendingAskDir(userId) {
|
|
14849
14932
|
const rawUserId = String(userId);
|
|
14850
14933
|
const safeUserId = /^[A-Za-z0-9][A-Za-z0-9_.@-]{0,255}$/.test(rawUserId) && !rawUserId.includes("..") ? rawUserId : `sha256-${createHash9("sha256").update(rawUserId).digest("hex")}`;
|
|
@@ -14867,7 +14950,7 @@ function legacyPendingAskPath(key) {
|
|
|
14867
14950
|
}
|
|
14868
14951
|
const dir = pendingAskDir(key.userId);
|
|
14869
14952
|
const candidate = join27(dir, `${key.from}___${key.to}.pending`);
|
|
14870
|
-
return
|
|
14953
|
+
return dirname15(candidate) === dir ? candidate : null;
|
|
14871
14954
|
}
|
|
14872
14955
|
function parsePendingAskFilename(fileName) {
|
|
14873
14956
|
if (!fileName.endsWith(".pending"))
|
|
@@ -17330,7 +17413,7 @@ var init_turn_session = __esm(async () => {
|
|
|
17330
17413
|
|
|
17331
17414
|
// ../../packages/core/src/storage/app-settings.ts
|
|
17332
17415
|
import { existsSync as existsSync20, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
17333
|
-
import { dirname as
|
|
17416
|
+
import { dirname as dirname16, join as join29 } from "path";
|
|
17334
17417
|
function settingsFile() {
|
|
17335
17418
|
return join29(resolveStorageDataDir(), "otium-settings.json");
|
|
17336
17419
|
}
|
|
@@ -20886,4 +20969,4 @@ export {
|
|
|
20886
20969
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
20887
20970
|
};
|
|
20888
20971
|
|
|
20889
|
-
//# debugId=
|
|
20972
|
+
//# debugId=B662EA253049A7FE64756E2164756E21
|