negotium 0.16.5 → 0.18.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 +138 -194
- package/dist/agent-helpers.js.map +15 -17
- package/dist/background-bash.js.map +1 -1
- package/dist/browser-runtime.js.map +1 -1
- package/dist/{chunk-8h0fya43.js → chunk-axa09pgx.js} +1 -1
- package/dist/{chunk-f536ex89.js → chunk-kgwgwc3r.js} +3 -3
- package/dist/{chunk-f536ex89.js.map → chunk-kgwgwc3r.js.map} +2 -2
- package/dist/{chunk-krz6n9jm.js → chunk-th3a0ew7.js} +51 -27
- package/dist/{chunk-krz6n9jm.js.map → chunk-th3a0ew7.js.map} +6 -6
- package/dist/hosted-agent.js +72 -42
- package/dist/hosted-agent.js.map +9 -9
- package/dist/main.js +323 -487
- package/dist/main.js.map +29 -32
- package/dist/mcp-factories.js +139 -145
- package/dist/mcp-factories.js.map +13 -13
- package/dist/media.js.map +1 -1
- package/dist/prompts.js +2 -2
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js.map +1 -1
- package/dist/registry.js +3 -3
- package/dist/rollout.js +2 -2
- package/dist/runtime/src/agents/archiver.ts +0 -4
- 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/agents/public-helpers.ts +0 -8
- package/dist/runtime/src/application/topic-service.ts +1 -11
- package/dist/runtime/src/index.ts +2 -6
- package/dist/runtime/src/mcp/runtime-spec.ts +0 -6
- package/dist/runtime/src/mcp/wiki-server.ts +2 -146
- package/dist/runtime/src/mcp-runtime-host.ts +0 -3
- package/dist/runtime/src/node-host.ts +1 -0
- package/dist/runtime/src/platform/mcp-config.ts +102 -31
- package/dist/runtime/src/platform/paths.ts +16 -2
- package/dist/runtime/src/prompts/agents/wiki-archiver.md +3 -27
- package/dist/runtime/src/prompts/builders.ts +1 -1
- package/dist/runtime/src/storage/storage-public.ts +0 -2
- package/dist/runtime/src/topics/create.ts +6 -59
- package/dist/runtime/src/types.ts +0 -6
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +2 -2
- package/dist/runtime-helpers.js.map +4 -4
- package/dist/storage.js +1 -81
- package/dist/storage.js.map +4 -5
- package/dist/types/packages/core/src/agents/public-helpers.d.ts +0 -1
- package/dist/types/packages/core/src/mcp/runtime-spec.d.ts +0 -2
- package/dist/types/packages/core/src/mcp/wiki-server.d.ts +0 -20
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +25 -16
- package/dist/types/packages/core/src/storage/storage-public.d.ts +0 -2
- package/dist/types/packages/core/src/types.d.ts +0 -6
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js.map +1 -1
- package/package.json +1 -1
- package/dist/runtime/src/agents/topic-defaults.ts +0 -128
- package/dist/runtime/src/storage/topic-default-assignments.ts +0 -140
- package/dist/types/packages/core/src/agents/topic-defaults.d.ts +0 -41
- package/dist/types/packages/core/src/storage/topic-default-assignments.d.ts +0 -34
- /package/dist/{chunk-8h0fya43.js.map → chunk-axa09pgx.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}
|
|
@@ -560,8 +571,7 @@ function hostedMcpCacheIdentity(surface, ctx) {
|
|
|
560
571
|
case "skills":
|
|
561
572
|
semanticContext = {
|
|
562
573
|
userId: ctx.userId,
|
|
563
|
-
topicId: ctx.wikiTopicId ?? ctx.topicId ?? null
|
|
564
|
-
memoryKey: ctx.wikiMemoryKey ?? null
|
|
574
|
+
topicId: ctx.wikiTopicId ?? ctx.topicId ?? null
|
|
565
575
|
};
|
|
566
576
|
break;
|
|
567
577
|
case "vault":
|
|
@@ -949,7 +959,6 @@ function buildBuiltinMcpServer(surface, ctx, stdio) {
|
|
|
949
959
|
...ctx.topicId ? { topicId: ctx.topicId } : {},
|
|
950
960
|
...ctx.queryId ? { queryId: ctx.queryId } : {},
|
|
951
961
|
...ctx.wikiTopicId ? { wikiTopicId: ctx.wikiTopicId } : {},
|
|
952
|
-
...ctx.wikiMemoryKey ? { wikiMemoryKey: ctx.wikiMemoryKey } : {},
|
|
953
962
|
...ctx.subagentParentTopicId ? { subagentParentTopicId: ctx.subagentParentTopicId } : {},
|
|
954
963
|
...ctx.threadRootId ? { threadRootId: ctx.threadRootId } : {},
|
|
955
964
|
cwd: ctx.cwd ?? (ctx.topicId ? resolveTopicWorkspaceDir(ctx.topicId) : process.cwd()),
|
|
@@ -1024,9 +1033,12 @@ function backgroundBashTransport(agent, port, userId, topic) {
|
|
|
1024
1033
|
}
|
|
1025
1034
|
function refreshForumCatalogViews() {
|
|
1026
1035
|
const { all, required, optional } = classifyForumMcpServers(MCP_CATALOG);
|
|
1027
|
-
|
|
1036
|
+
const nodeNames = nodeMcpEntries.map((entry) => entry.key);
|
|
1037
|
+
const allWithNodeEntries = [...new Set([...all, ...nodeNames])];
|
|
1038
|
+
const optionalWithNodeEntries = [...new Set([...optional, ...nodeNames])];
|
|
1039
|
+
allForumMcpServerNames.splice(0, allForumMcpServerNames.length, ...allWithNodeEntries);
|
|
1028
1040
|
requiredForumMcpServers.splice(0, requiredForumMcpServers.length, ...required);
|
|
1029
|
-
optionalForumMcpServers.splice(0, optionalForumMcpServers.length, ...
|
|
1041
|
+
optionalForumMcpServers.splice(0, optionalForumMcpServers.length, ...optionalWithNodeEntries);
|
|
1030
1042
|
}
|
|
1031
1043
|
function isReservedRuntimeMcpServerName(name) {
|
|
1032
1044
|
return Object.hasOwn(MCP_CATALOG, name) || nodeMcpEntries.some((entry) => entry.key === name);
|
|
@@ -1041,12 +1053,22 @@ function mergeHostMcpServers(base, hostMcpServers) {
|
|
|
1041
1053
|
}
|
|
1042
1054
|
return { ...base, ...hostMcpServers };
|
|
1043
1055
|
}
|
|
1044
|
-
function buildNodeMcpSpecs(agent, filter) {
|
|
1056
|
+
function buildNodeMcpSpecs(agent, filter, ctx) {
|
|
1045
1057
|
const out = {};
|
|
1046
1058
|
for (const entry of nodeMcpEntries) {
|
|
1047
1059
|
if (!filter(entry.key))
|
|
1048
1060
|
continue;
|
|
1049
|
-
|
|
1061
|
+
if (entry.kind === "http") {
|
|
1062
|
+
out[entry.key] = longLivedHttpMcp(agent, entry.port);
|
|
1063
|
+
continue;
|
|
1064
|
+
}
|
|
1065
|
+
if (entry.kind === "http-instance") {
|
|
1066
|
+
const port = resolvedNodeMcpPorts.get(entry)?.get(nodeMcpInstanceKey(ctx));
|
|
1067
|
+
if (port !== undefined)
|
|
1068
|
+
out[entry.key] = longLivedHttpMcp(agent, port);
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
out[entry.key] = {
|
|
1050
1072
|
command: entry.command,
|
|
1051
1073
|
args: entry.args ?? [],
|
|
1052
1074
|
...entry.env ? { env: entry.env } : {}
|
|
@@ -1054,6 +1076,42 @@ function buildNodeMcpSpecs(agent, filter) {
|
|
|
1054
1076
|
}
|
|
1055
1077
|
return out;
|
|
1056
1078
|
}
|
|
1079
|
+
function nodeMcpInstanceKey(ctx) {
|
|
1080
|
+
return ctx.topicId ?? `user:${ctx.userId}:session:${ctx.session}`;
|
|
1081
|
+
}
|
|
1082
|
+
async function prepareNodeMcpServersForQuery(opts) {
|
|
1083
|
+
if (opts.toolPolicy || opts.sessionType === "cron" || nodeMcpEntries.every((entry) => entry.kind !== "http-instance")) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const forum = !["dm", "ephemeral", "manager"].includes(opts.sessionType ?? "forum");
|
|
1087
|
+
const enabled = opts.mcpEnabled ?? null;
|
|
1088
|
+
const instanceKey = nodeMcpInstanceKey({
|
|
1089
|
+
topicId: opts.topicId,
|
|
1090
|
+
userId: opts.userId || "local",
|
|
1091
|
+
session: opts.session || "default"
|
|
1092
|
+
});
|
|
1093
|
+
await Promise.all(nodeMcpEntries.map(async (entry) => {
|
|
1094
|
+
if (entry.kind !== "http-instance")
|
|
1095
|
+
return;
|
|
1096
|
+
if (forum && enabled !== null && !enabled.includes(entry.key))
|
|
1097
|
+
return;
|
|
1098
|
+
let ports = resolvedNodeMcpPorts.get(entry);
|
|
1099
|
+
if (!ports) {
|
|
1100
|
+
ports = new Map;
|
|
1101
|
+
resolvedNodeMcpPorts.set(entry, ports);
|
|
1102
|
+
}
|
|
1103
|
+
try {
|
|
1104
|
+
const port = await entry.ensurePort(instanceKey);
|
|
1105
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
1106
|
+
throw new Error(`invalid port ${port}`);
|
|
1107
|
+
}
|
|
1108
|
+
ports.set(instanceKey, port);
|
|
1109
|
+
} catch (err) {
|
|
1110
|
+
ports.delete(instanceKey);
|
|
1111
|
+
logger.warn({ err, key: entry.key, instanceKey }, "node mcp: failed to prepare instance-scoped server");
|
|
1112
|
+
}
|
|
1113
|
+
}));
|
|
1114
|
+
}
|
|
1057
1115
|
function buildScope(scope, ctx, filter = () => true) {
|
|
1058
1116
|
const out = {};
|
|
1059
1117
|
for (const [name, entry] of Object.entries(MCP_CATALOG)) {
|
|
@@ -1067,14 +1125,15 @@ function buildScope(scope, ctx, filter = () => true) {
|
|
|
1067
1125
|
out[name] = spec;
|
|
1068
1126
|
}
|
|
1069
1127
|
if (scope !== "cron") {
|
|
1070
|
-
Object.assign(out, buildNodeMcpSpecs(ctx.agent, filter));
|
|
1128
|
+
Object.assign(out, buildNodeMcpSpecs(ctx.agent, filter, ctx));
|
|
1071
1129
|
}
|
|
1072
1130
|
return out;
|
|
1073
1131
|
}
|
|
1074
1132
|
function getDmMcpServers(opts) {
|
|
1075
1133
|
return buildScope("dm", {
|
|
1076
1134
|
userId: opts.userId,
|
|
1077
|
-
session: "dm",
|
|
1135
|
+
session: opts.session ?? "dm",
|
|
1136
|
+
topicId: opts.topicId,
|
|
1078
1137
|
agent: opts.agent,
|
|
1079
1138
|
playwrightPort: opts.playwrightPort,
|
|
1080
1139
|
playwrightCapability: opts.playwrightCapability
|
|
@@ -1112,7 +1171,6 @@ function getForumMcpServers(opts) {
|
|
|
1112
1171
|
subagentParentTopicId,
|
|
1113
1172
|
queryId,
|
|
1114
1173
|
wikiTopicId,
|
|
1115
|
-
wikiMemoryKey,
|
|
1116
1174
|
agent,
|
|
1117
1175
|
cwd,
|
|
1118
1176
|
model,
|
|
@@ -1146,7 +1204,6 @@ function getForumMcpServers(opts) {
|
|
|
1146
1204
|
subagentParentTopicId,
|
|
1147
1205
|
queryId,
|
|
1148
1206
|
wikiTopicId,
|
|
1149
|
-
wikiMemoryKey,
|
|
1150
1207
|
agent,
|
|
1151
1208
|
cwd,
|
|
1152
1209
|
model,
|
|
@@ -1211,6 +1268,8 @@ function getMcpServersForQuery(opts) {
|
|
|
1211
1268
|
if (opts.sessionType === "dm" || opts.sessionType === "ephemeral") {
|
|
1212
1269
|
return getDmMcpServers({
|
|
1213
1270
|
userId: opts.userId || "local",
|
|
1271
|
+
session: opts.session,
|
|
1272
|
+
topicId: opts.topicId,
|
|
1214
1273
|
agent: opts.agent,
|
|
1215
1274
|
playwrightPort: opts.playwrightPort,
|
|
1216
1275
|
playwrightCapability: opts.playwrightCapability
|
|
@@ -1243,7 +1302,6 @@ function getMcpServersForQuery(opts) {
|
|
|
1243
1302
|
subagentParentTopicId: opts.subagentParentTopicId,
|
|
1244
1303
|
queryId: opts.queryId,
|
|
1245
1304
|
wikiTopicId: opts.wikiTopicId,
|
|
1246
|
-
wikiMemoryKey: opts.wikiMemoryKey,
|
|
1247
1305
|
agent: opts.agent,
|
|
1248
1306
|
cwd: opts.cwd,
|
|
1249
1307
|
model: opts.model,
|
|
@@ -1262,7 +1320,7 @@ function getMcpServersForQuery(opts) {
|
|
|
1262
1320
|
peerBridge: opts.peerBridge
|
|
1263
1321
|
});
|
|
1264
1322
|
}
|
|
1265
|
-
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, cuaRsMcpPort, cuaRsMcpToken, MCP_CATALOG, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers
|
|
1323
|
+
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, cuaRsMcpPort, cuaRsMcpToken, MCP_CATALOG, nodeMcpEntries, resolvedNodeMcpPorts, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers;
|
|
1266
1324
|
var init_mcp_config = __esm(() => {
|
|
1267
1325
|
init_canonical_bridge_config();
|
|
1268
1326
|
init_runtime_spec();
|
|
@@ -1423,7 +1481,7 @@ var init_mcp_config = __esm(() => {
|
|
|
1423
1481
|
wiki: {
|
|
1424
1482
|
...commonRuntimeMcpPolicy("wiki"),
|
|
1425
1483
|
build(ctx) {
|
|
1426
|
-
const { userId, session, topicId, queryId, wikiTopicId,
|
|
1484
|
+
const { userId, session, topicId, queryId, wikiTopicId, agent, peerBridge } = ctx;
|
|
1427
1485
|
if (peerBridge) {
|
|
1428
1486
|
if (!topicId || !queryId)
|
|
1429
1487
|
return null;
|
|
@@ -1442,8 +1500,6 @@ var init_mcp_config = __esm(() => {
|
|
|
1442
1500
|
const resolvedWikiTopicId = wikiTopicId ?? topicId ?? (session !== "dm" ? session : undefined);
|
|
1443
1501
|
if (resolvedWikiTopicId)
|
|
1444
1502
|
args.push(`--topic-id=${resolvedWikiTopicId}`);
|
|
1445
|
-
if (wikiMemoryKey)
|
|
1446
|
-
args.push(`--memory-key=${wikiMemoryKey}`);
|
|
1447
1503
|
args.push("--surface=wiki");
|
|
1448
1504
|
return buildBuiltinMcpServer("wiki", { ...ctx, wikiTopicId: resolvedWikiTopicId }, () => buildStdioMcpServer(agent, WIKI_SERVER, args));
|
|
1449
1505
|
}
|
|
@@ -1497,12 +1553,13 @@ var init_mcp_config = __esm(() => {
|
|
|
1497
1553
|
}
|
|
1498
1554
|
}
|
|
1499
1555
|
};
|
|
1556
|
+
nodeMcpEntries = [];
|
|
1557
|
+
resolvedNodeMcpPorts = new WeakMap;
|
|
1500
1558
|
allForumMcpServerNames = [];
|
|
1501
1559
|
requiredForumMcpServers = [];
|
|
1502
1560
|
REQUIRED_FORUM_MCP_SERVERS = requiredForumMcpServers;
|
|
1503
1561
|
optionalForumMcpServers = [];
|
|
1504
1562
|
refreshForumCatalogViews();
|
|
1505
|
-
nodeMcpEntries = [];
|
|
1506
1563
|
});
|
|
1507
1564
|
|
|
1508
1565
|
// ../../packages/core/src/storage/sqlite.ts
|
|
@@ -1570,7 +1627,7 @@ var init_sqlite = __esm(async () => {
|
|
|
1570
1627
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1571
1628
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
1572
1629
|
import { homedir as homedir2 } from "os";
|
|
1573
|
-
import { dirname as
|
|
1630
|
+
import { dirname as dirname3, join as join2, resolve as resolve4 } from "path";
|
|
1574
1631
|
function storageState() {
|
|
1575
1632
|
const holder = globalThis;
|
|
1576
1633
|
const existing = holder[STORAGE_HOST_STATE];
|
|
@@ -1649,7 +1706,7 @@ function defaultDatabase() {
|
|
|
1649
1706
|
return state.fallbackDatabase;
|
|
1650
1707
|
if (state.fallbackDatabase)
|
|
1651
1708
|
closeDatabase(state.fallbackDatabase);
|
|
1652
|
-
mkdirSync2(
|
|
1709
|
+
mkdirSync2(dirname3(path), { recursive: true });
|
|
1653
1710
|
state.fallbackDatabase = new Database(path, { create: true });
|
|
1654
1711
|
state.fallbackDatabasePath = path;
|
|
1655
1712
|
initializeDatabase(state.fallbackDatabase);
|
|
@@ -1927,7 +1984,7 @@ var init_vault = __esm(async () => {
|
|
|
1927
1984
|
|
|
1928
1985
|
// ../../packages/core/src/agents/execution-host.ts
|
|
1929
1986
|
import { AsyncLocalStorage } from "async_hooks";
|
|
1930
|
-
import { dirname as
|
|
1987
|
+
import { dirname as dirname4 } from "path";
|
|
1931
1988
|
function activeHost() {
|
|
1932
1989
|
const scoped = scopedHost.getStore();
|
|
1933
1990
|
if (scoped)
|
|
@@ -1962,7 +2019,7 @@ function hostedCodexAuthFilePath() {
|
|
|
1962
2019
|
return activeHost().codexAuthFilePath();
|
|
1963
2020
|
}
|
|
1964
2021
|
function hostedCodexHomePath() {
|
|
1965
|
-
return
|
|
2022
|
+
return dirname4(hostedCodexAuthFilePath());
|
|
1966
2023
|
}
|
|
1967
2024
|
var defaultHost, hostRegistrations, scopedHost;
|
|
1968
2025
|
var init_execution_host = __esm(async () => {
|
|
@@ -2247,7 +2304,7 @@ import {
|
|
|
2247
2304
|
unlinkSync as unlinkSync2,
|
|
2248
2305
|
writeFileSync as writeFileSync2
|
|
2249
2306
|
} from "fs";
|
|
2250
|
-
import { dirname as
|
|
2307
|
+
import { dirname as dirname5 } from "path";
|
|
2251
2308
|
function readJsonlLines(filePath) {
|
|
2252
2309
|
return readFileSync2(filePath, "utf-8").trim().split(`
|
|
2253
2310
|
`).filter(Boolean);
|
|
@@ -2288,7 +2345,7 @@ function appendJsonlEntry(filePath, entry) {
|
|
|
2288
2345
|
`);
|
|
2289
2346
|
}
|
|
2290
2347
|
function appendJsonlLine(filePath, line) {
|
|
2291
|
-
mkdirSync5(
|
|
2348
|
+
mkdirSync5(dirname5(filePath), { recursive: true });
|
|
2292
2349
|
const lockPath = `${filePath}${LOCK_SUFFIX}`;
|
|
2293
2350
|
const payload = line.endsWith(`
|
|
2294
2351
|
`) ? line : `${line}
|
|
@@ -2319,7 +2376,7 @@ function appendJsonlLine(filePath, line) {
|
|
|
2319
2376
|
}
|
|
2320
2377
|
}
|
|
2321
2378
|
function writeJsonlFile(filePath, entries) {
|
|
2322
|
-
const dir =
|
|
2379
|
+
const dir = dirname5(filePath);
|
|
2323
2380
|
mkdirSync5(dir, { recursive: true });
|
|
2324
2381
|
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2325
2382
|
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
@@ -2587,7 +2644,7 @@ var init_claude_registry = __esm(() => {
|
|
|
2587
2644
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2588
2645
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
2589
2646
|
import { existsSync as existsSync5, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync2, unlinkSync as unlinkSync4 } from "fs";
|
|
2590
|
-
import { basename, dirname as
|
|
2647
|
+
import { basename, dirname as dirname6, join as join6, resolve as resolve6 } from "path";
|
|
2591
2648
|
function codexSessionsDir() {
|
|
2592
2649
|
return join6(hostedCodexHomePath(), "sessions");
|
|
2593
2650
|
}
|
|
@@ -2670,7 +2727,7 @@ function canonicalFilePath(path) {
|
|
|
2670
2727
|
return realpathSync3(absolute);
|
|
2671
2728
|
} catch {
|
|
2672
2729
|
try {
|
|
2673
|
-
return join6(realpathSync3(
|
|
2730
|
+
return join6(realpathSync3(dirname6(absolute)), basename(absolute));
|
|
2674
2731
|
} catch {
|
|
2675
2732
|
return absolute;
|
|
2676
2733
|
}
|
|
@@ -3119,7 +3176,7 @@ var init_codex = __esm(async () => {
|
|
|
3119
3176
|
});
|
|
3120
3177
|
|
|
3121
3178
|
// ../../packages/core/src/version.ts
|
|
3122
|
-
var NEGOTIUM_VERSION = "0.
|
|
3179
|
+
var NEGOTIUM_VERSION = "0.18.0";
|
|
3123
3180
|
|
|
3124
3181
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
3125
3182
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -3137,7 +3194,7 @@ import {
|
|
|
3137
3194
|
} from "fs";
|
|
3138
3195
|
import { createRequire as createRequire2 } from "module";
|
|
3139
3196
|
import { tmpdir } from "os";
|
|
3140
|
-
import { dirname as
|
|
3197
|
+
import { dirname as dirname7, join as join7 } from "path";
|
|
3141
3198
|
function readPackageVersion(packageJsonPath) {
|
|
3142
3199
|
const parsed = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
|
|
3143
3200
|
if (typeof parsed.version !== "string" || !parsed.version.trim()) {
|
|
@@ -3146,7 +3203,7 @@ function readPackageVersion(packageJsonPath) {
|
|
|
3146
3203
|
return parsed.version;
|
|
3147
3204
|
}
|
|
3148
3205
|
function codexCliScriptPath() {
|
|
3149
|
-
return join7(
|
|
3206
|
+
return join7(dirname7(bundledCodexPackagePath), "bin", "codex.js");
|
|
3150
3207
|
}
|
|
3151
3208
|
function parseCodexModelCache(contents, sourcePath) {
|
|
3152
3209
|
let parsed;
|
|
@@ -3187,7 +3244,7 @@ function writePrivateFileAtomic(path, contents) {
|
|
|
3187
3244
|
}
|
|
3188
3245
|
}
|
|
3189
3246
|
function bundledCodexModelCachePath(authFilePath) {
|
|
3190
|
-
return join7(
|
|
3247
|
+
return join7(dirname7(authFilePath), NEGOTIUM_MODEL_CACHE);
|
|
3191
3248
|
}
|
|
3192
3249
|
async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
3193
3250
|
const child = spawn2(process.execPath, [codexCliScriptPath(), "app-server", "--stdio"], {
|
|
@@ -3273,7 +3330,7 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
3273
3330
|
});
|
|
3274
3331
|
}
|
|
3275
3332
|
async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
3276
|
-
const sourceHome =
|
|
3333
|
+
const sourceHome = dirname7(authFilePath);
|
|
3277
3334
|
const isolatedHome = mkdtempSync(join7(tmpdir(), "negotium-codex-models-"));
|
|
3278
3335
|
const isolatedCachePath = join7(isolatedHome, "models_cache.json");
|
|
3279
3336
|
try {
|
|
@@ -3293,7 +3350,7 @@ async function bootstrapIsolatedCodexModelCache(authFilePath, bootstrap) {
|
|
|
3293
3350
|
}
|
|
3294
3351
|
}
|
|
3295
3352
|
async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexModelCache) {
|
|
3296
|
-
const codexHome =
|
|
3353
|
+
const codexHome = dirname7(authFilePath);
|
|
3297
3354
|
const configuredCachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE;
|
|
3298
3355
|
if (configuredCachePath) {
|
|
3299
3356
|
if (!existsSync6(configuredCachePath)) {
|
|
@@ -3322,7 +3379,7 @@ async function ensureCodexModelCache(authFilePath, bootstrap = bootstrapCodexMod
|
|
|
3322
3379
|
return bundledCachePath;
|
|
3323
3380
|
}
|
|
3324
3381
|
function writeCodexCatalogWithNativeMultiAgentDisabled(authFilePath, sourcePath) {
|
|
3325
|
-
const codexHome =
|
|
3382
|
+
const codexHome = dirname7(authFilePath);
|
|
3326
3383
|
const outputPath = join7(codexHome, NEGOTIUM_MODEL_CATALOG);
|
|
3327
3384
|
const parsed = readCodexModelCache(sourcePath).parsed;
|
|
3328
3385
|
const models = parsed.models.map((model, index) => {
|
|
@@ -3739,7 +3796,7 @@ function sanitizeId(id) {
|
|
|
3739
3796
|
|
|
3740
3797
|
// ../../packages/core/src/storage/tasks.ts
|
|
3741
3798
|
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
|
|
3799
|
+
import { dirname as dirname8, join as join10 } from "path";
|
|
3743
3800
|
function safeTaskScopeKey(scopeKey) {
|
|
3744
3801
|
const safe = sanitizeFileName(scopeKey);
|
|
3745
3802
|
if (!safe || safe === "." || safe === "..") {
|
|
@@ -3851,7 +3908,7 @@ import {
|
|
|
3851
3908
|
unlinkSync as unlinkSync7,
|
|
3852
3909
|
writeFileSync as writeFileSync7
|
|
3853
3910
|
} from "fs";
|
|
3854
|
-
import { dirname as
|
|
3911
|
+
import { dirname as dirname9, join as join11 } from "path";
|
|
3855
3912
|
function conversationDir(_userId) {
|
|
3856
3913
|
return join11(resolveStorageDataDir(), "conversations");
|
|
3857
3914
|
}
|
|
@@ -3889,7 +3946,7 @@ function appendConversationEventStrict(userId, topicName, agent, event) {
|
|
|
3889
3946
|
event
|
|
3890
3947
|
};
|
|
3891
3948
|
const line = JSON.stringify(entry);
|
|
3892
|
-
mkdirSync9(
|
|
3949
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
3893
3950
|
appendJsonlLine(path, line);
|
|
3894
3951
|
const activePath = getActiveConversationPath(userId, topicName);
|
|
3895
3952
|
if (existsSync10(activePath)) {
|
|
@@ -3907,7 +3964,7 @@ function appendRawConversationEventStrict(userId, topicName, agent, event) {
|
|
|
3907
3964
|
agent,
|
|
3908
3965
|
event
|
|
3909
3966
|
};
|
|
3910
|
-
mkdirSync9(
|
|
3967
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
3911
3968
|
appendJsonlLine(path, JSON.stringify(entry));
|
|
3912
3969
|
}
|
|
3913
3970
|
function readConversationPath(path) {
|
|
@@ -3948,7 +4005,7 @@ function replaceRawConversationStrict(userId, topicName, entries) {
|
|
|
3948
4005
|
}
|
|
3949
4006
|
function replaceConversationPathStrict(path, entries) {
|
|
3950
4007
|
const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
3951
|
-
mkdirSync9(
|
|
4008
|
+
mkdirSync9(dirname9(path), { recursive: true });
|
|
3952
4009
|
try {
|
|
3953
4010
|
writeFileSync7(tempPath, entries.length > 0 ? `${entries.map((entry) => JSON.stringify(entry)).join(`
|
|
3954
4011
|
`)}
|
|
@@ -4630,9 +4687,19 @@ var init_claude_provider = __esm(async () => {
|
|
|
4630
4687
|
"ScheduleWakeup",
|
|
4631
4688
|
"CronCreate",
|
|
4632
4689
|
"CronList",
|
|
4633
|
-
"CronDelete"
|
|
4690
|
+
"CronDelete",
|
|
4691
|
+
"RemoteTrigger"
|
|
4692
|
+
];
|
|
4693
|
+
CLAUDE_NATIVE_AGENT_TOOLS = [
|
|
4694
|
+
"Task",
|
|
4695
|
+
"Agent",
|
|
4696
|
+
"TaskOutput",
|
|
4697
|
+
"TaskStop",
|
|
4698
|
+
"ListAgents",
|
|
4699
|
+
"SendMessage",
|
|
4700
|
+
"TeamCreate",
|
|
4701
|
+
"TeamDelete"
|
|
4634
4702
|
];
|
|
4635
|
-
CLAUDE_NATIVE_AGENT_TOOLS = ["Task", "Agent", "TaskOutput", "TaskStop"];
|
|
4636
4703
|
CLAUDE_IMAGE_MAX_BYTES = 10 * 1024 * 1024;
|
|
4637
4704
|
CLAUDE_IMAGE_MIME_TYPES = new Set([
|
|
4638
4705
|
"image/jpeg",
|
|
@@ -4892,7 +4959,7 @@ import { existsSync as existsSync12 } from "fs";
|
|
|
4892
4959
|
import { chmod, mkdtemp, rm, writeFile } from "fs/promises";
|
|
4893
4960
|
import { createServer } from "net";
|
|
4894
4961
|
import { tmpdir as tmpdir2 } from "os";
|
|
4895
|
-
import { dirname as
|
|
4962
|
+
import { dirname as dirname10, join as join12, resolve as resolve8 } from "path";
|
|
4896
4963
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4897
4964
|
function evaluateCodexVaultPreToolUse(input, userId, operations) {
|
|
4898
4965
|
if (operations.referencesSensitiveStorage(input.tool_input)) {
|
|
@@ -4921,7 +4988,7 @@ function shellQuote(value) {
|
|
|
4921
4988
|
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
4922
4989
|
}
|
|
4923
4990
|
function hookClientPath() {
|
|
4924
|
-
const moduleDir =
|
|
4991
|
+
const moduleDir = dirname10(fileURLToPath2(import.meta.url));
|
|
4925
4992
|
const adjacent = resolve8(moduleDir, "codex-vault-hook.mjs");
|
|
4926
4993
|
if (existsSync12(adjacent))
|
|
4927
4994
|
return adjacent;
|
|
@@ -5570,7 +5637,7 @@ __export(exports_codex_provider, {
|
|
|
5570
5637
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
5571
5638
|
import { existsSync as existsSync13, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
|
|
5572
5639
|
import { homedir as homedir6 } from "os";
|
|
5573
|
-
import { dirname as
|
|
5640
|
+
import { dirname as dirname11, isAbsolute as isAbsolute3, join as join13, relative as relative2, resolve as resolve10 } from "path";
|
|
5574
5641
|
import { Codex } from "@openai/codex-sdk";
|
|
5575
5642
|
function sameCodexUsage(usage, total) {
|
|
5576
5643
|
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 +5665,7 @@ function codexMcpServerName(name) {
|
|
|
5598
5665
|
return CODEX_MCP_SERVER_NAME_OVERRIDES[name] ?? name;
|
|
5599
5666
|
}
|
|
5600
5667
|
function globalCodexMcpServerNames(authFilePath) {
|
|
5601
|
-
const configPath = join13(
|
|
5668
|
+
const configPath = join13(dirname11(authFilePath), "config.toml");
|
|
5602
5669
|
if (!existsSync13(configPath))
|
|
5603
5670
|
return [];
|
|
5604
5671
|
try {
|
|
@@ -5978,7 +6045,14 @@ async function* codexProvider(opts) {
|
|
|
5978
6045
|
codexPathOverride: vaultHook.codexPathOverride,
|
|
5979
6046
|
...codexEnvironment ? { env: codexEnvironment } : {},
|
|
5980
6047
|
config: {
|
|
5981
|
-
|
|
6048
|
+
agents: { enabled: false },
|
|
6049
|
+
features: {
|
|
6050
|
+
hooks: true,
|
|
6051
|
+
goals: false,
|
|
6052
|
+
multi_agent: false,
|
|
6053
|
+
multi_agent_v2: false,
|
|
6054
|
+
enable_fanout: false
|
|
6055
|
+
},
|
|
5982
6056
|
hooks: vaultHook.hooks,
|
|
5983
6057
|
model_catalog_json: codexModelCatalogPath,
|
|
5984
6058
|
mcp_servers: codexMcpServers,
|
|
@@ -6504,6 +6578,7 @@ async function* runAgent(opts) {
|
|
|
6504
6578
|
return;
|
|
6505
6579
|
}
|
|
6506
6580
|
}
|
|
6581
|
+
await prepareNodeMcpServersForQuery(dispatchOpts);
|
|
6507
6582
|
const taskScope = resolveTaskEventScope(dispatchOpts);
|
|
6508
6583
|
const stream = taskScope ? withTaskSnapshots(dispatchAgent(dispatchOpts), taskScope) : dispatchAgent(dispatchOpts);
|
|
6509
6584
|
for await (const event of stream) {
|
|
@@ -6517,6 +6592,7 @@ var loadClaudeProvider, loadCodexProvider, loadMaestroProvider;
|
|
|
6517
6592
|
var init_agents = __esm(async () => {
|
|
6518
6593
|
init_claude();
|
|
6519
6594
|
init_logger();
|
|
6595
|
+
init_mcp_config();
|
|
6520
6596
|
init_types();
|
|
6521
6597
|
await __promiseAll([
|
|
6522
6598
|
init_execution_host(),
|
|
@@ -7205,7 +7281,7 @@ function buildRuntimeToolSection(opts, extensions) {
|
|
|
7205
7281
|
"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
7282
|
"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
7283
|
] : [];
|
|
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.';
|
|
7284
|
+
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
7285
|
const visualSection = visualTools ? [
|
|
7210
7286
|
visualToolLine,
|
|
7211
7287
|
mermaidToolLine,
|
|
@@ -8483,7 +8559,7 @@ var init_api_topics = __esm(async () => {
|
|
|
8483
8559
|
});
|
|
8484
8560
|
|
|
8485
8561
|
// ../../packages/core/src/storage/wiki.ts
|
|
8486
|
-
import { basename as basename3, dirname as
|
|
8562
|
+
import { basename as basename3, dirname as dirname12, join as join15 } from "path";
|
|
8487
8563
|
function getSharedWikiDir(workspaceDir = resolveStorageWorkspaceDir()) {
|
|
8488
8564
|
return workspaceDir === resolveStorageWorkspaceDir() ? resolveStorageSharedWikiDir() : join15(workspaceDir, "wiki");
|
|
8489
8565
|
}
|
|
@@ -8813,7 +8889,6 @@ function createArchiverRuntime(host) {
|
|
|
8813
8889
|
session: `__archiver_${safeTopic}`,
|
|
8814
8890
|
sessionType: "forum",
|
|
8815
8891
|
topicId,
|
|
8816
|
-
wikiMemoryKey: topicTitle,
|
|
8817
8892
|
abortController: new AbortController,
|
|
8818
8893
|
model,
|
|
8819
8894
|
mcpEnabled: ["wiki"],
|
|
@@ -11726,11 +11801,11 @@ import {
|
|
|
11726
11801
|
unlinkSync as unlinkSync11,
|
|
11727
11802
|
writeFileSync as writeFileSync9
|
|
11728
11803
|
} from "fs";
|
|
11729
|
-
import { dirname as
|
|
11804
|
+
import { dirname as dirname13, join as join20, resolve as resolve16 } from "path";
|
|
11730
11805
|
function removeDefaultProfileDataDir(userDataDir) {
|
|
11731
11806
|
const root = resolve16(BROWSER_PROFILES_DIR);
|
|
11732
11807
|
const target = resolve16(userDataDir);
|
|
11733
|
-
if (
|
|
11808
|
+
if (dirname13(target) !== root) {
|
|
11734
11809
|
throw new Error(`Refusing to delete browser profile outside managed root: ${target}`);
|
|
11735
11810
|
}
|
|
11736
11811
|
const existed = existsSync19(target);
|
|
@@ -12310,7 +12385,7 @@ async function cloneProfileForChild(opts) {
|
|
|
12310
12385
|
if (existsSync19(dstDir)) {
|
|
12311
12386
|
rmSync3(dstDir, { recursive: true, force: true });
|
|
12312
12387
|
}
|
|
12313
|
-
mkdirSync11(
|
|
12388
|
+
mkdirSync11(dirname13(dstDir), { recursive: true });
|
|
12314
12389
|
if (process.platform === "darwin") {
|
|
12315
12390
|
try {
|
|
12316
12391
|
execFileSync7("cp", ["-cR", srcDir, dstDir], { stdio: "pipe" });
|
|
@@ -12911,7 +12986,7 @@ var init_idle_compact = __esm(async () => {
|
|
|
12911
12986
|
|
|
12912
12987
|
// ../../packages/core/src/agents/topic-cleanup.ts
|
|
12913
12988
|
import { mkdirSync as mkdirSync13, renameSync as renameSync6, unlinkSync as unlinkSync12, writeFileSync as writeFileSync11 } from "fs";
|
|
12914
|
-
import { dirname as
|
|
12989
|
+
import { dirname as dirname14 } from "path";
|
|
12915
12990
|
function collectSessionIdsByAgent(entries, extraSessions = []) {
|
|
12916
12991
|
const out = new Map;
|
|
12917
12992
|
for (const e of entries) {
|
|
@@ -12977,7 +13052,7 @@ function createTopicLogMaintenance(host) {
|
|
|
12977
13052
|
const path = runtimeHost.activeConversationPath(opts.userId, opts.topicName);
|
|
12978
13053
|
const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
|
|
12979
13054
|
try {
|
|
12980
|
-
mkdirSync13(
|
|
13055
|
+
mkdirSync13(dirname14(path), { recursive: true });
|
|
12981
13056
|
writeFileSync11(tempPath, retained.length > 0 ? `${retained.map((entry) => JSON.stringify(entry)).join(`
|
|
12982
13057
|
`)}
|
|
12983
13058
|
` : "", { flag: "wx" });
|
|
@@ -14844,7 +14919,7 @@ import {
|
|
|
14844
14919
|
unlinkSync as unlinkSync16,
|
|
14845
14920
|
writeFileSync as writeFileSync14
|
|
14846
14921
|
} from "fs";
|
|
14847
|
-
import { dirname as
|
|
14922
|
+
import { dirname as dirname15, join as join27 } from "path";
|
|
14848
14923
|
function pendingAskDir(userId) {
|
|
14849
14924
|
const rawUserId = String(userId);
|
|
14850
14925
|
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 +14942,7 @@ function legacyPendingAskPath(key) {
|
|
|
14867
14942
|
}
|
|
14868
14943
|
const dir = pendingAskDir(key.userId);
|
|
14869
14944
|
const candidate = join27(dir, `${key.from}___${key.to}.pending`);
|
|
14870
|
-
return
|
|
14945
|
+
return dirname15(candidate) === dir ? candidate : null;
|
|
14871
14946
|
}
|
|
14872
14947
|
function parsePendingAskFilename(fileName) {
|
|
14873
14948
|
if (!fileName.endsWith(".pending"))
|
|
@@ -17330,7 +17405,7 @@ var init_turn_session = __esm(async () => {
|
|
|
17330
17405
|
|
|
17331
17406
|
// ../../packages/core/src/storage/app-settings.ts
|
|
17332
17407
|
import { existsSync as existsSync20, mkdirSync as mkdirSync18, readFileSync as readFileSync17, writeFileSync as writeFileSync16 } from "fs";
|
|
17333
|
-
import { dirname as
|
|
17408
|
+
import { dirname as dirname16, join as join29 } from "path";
|
|
17334
17409
|
function settingsFile() {
|
|
17335
17410
|
return join29(resolveStorageDataDir(), "otium-settings.json");
|
|
17336
17411
|
}
|
|
@@ -20703,139 +20778,10 @@ await __promiseAll([
|
|
|
20703
20778
|
init_task_events(),
|
|
20704
20779
|
init_topic_cleanup()
|
|
20705
20780
|
]);
|
|
20706
|
-
|
|
20707
|
-
// ../../packages/core/src/agents/topic-defaults.ts
|
|
20708
|
-
init_model_catalog();
|
|
20709
|
-
init_config();
|
|
20710
|
-
init_logger();
|
|
20711
|
-
await init_registry();
|
|
20712
|
-
|
|
20713
|
-
// ../../packages/core/src/storage/topic-default-assignments.ts
|
|
20714
|
-
init_wiki_summary_names();
|
|
20715
|
-
await __promiseAll([
|
|
20716
|
-
init_forum_db(),
|
|
20717
|
-
init_storage_host()
|
|
20718
|
-
]);
|
|
20719
|
-
registerStorageSchemaInitializer((database) => {
|
|
20720
|
-
database.exec(`
|
|
20721
|
-
CREATE TABLE IF NOT EXISTS topic_default_assignments (
|
|
20722
|
-
memory_key TEXT PRIMARY KEY,
|
|
20723
|
-
model TEXT NOT NULL,
|
|
20724
|
-
effort TEXT,
|
|
20725
|
-
reason TEXT,
|
|
20726
|
-
assign_count INTEGER NOT NULL DEFAULT 1,
|
|
20727
|
-
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
20728
|
-
)
|
|
20729
|
-
`);
|
|
20730
|
-
}, 31);
|
|
20731
|
-
function normalizeMemoryKey(memoryKey) {
|
|
20732
|
-
const raw = memoryKey.trim().replace(/^topic\//, "").replace(/\.md$/i, "").trim();
|
|
20733
|
-
if (!raw)
|
|
20734
|
-
return "";
|
|
20735
|
-
return wikiSummarySlug(raw).toLowerCase();
|
|
20736
|
-
}
|
|
20737
|
-
function rowToAssignment(row) {
|
|
20738
|
-
return {
|
|
20739
|
-
memoryKey: row.memory_key,
|
|
20740
|
-
model: row.model,
|
|
20741
|
-
effort: row.effort ?? undefined,
|
|
20742
|
-
reason: row.reason ?? undefined,
|
|
20743
|
-
assignCount: row.assign_count,
|
|
20744
|
-
updatedAt: row.updated_at
|
|
20745
|
-
};
|
|
20746
|
-
}
|
|
20747
|
-
var SELECT_COLUMNS = "memory_key, model, effort, reason, assign_count, updated_at";
|
|
20748
|
-
function getTopicDefaultAssignment(memoryKey) {
|
|
20749
|
-
const key = normalizeMemoryKey(memoryKey);
|
|
20750
|
-
if (!key)
|
|
20751
|
-
return null;
|
|
20752
|
-
const row = db.query(`SELECT ${SELECT_COLUMNS} FROM topic_default_assignments WHERE memory_key = ?`).get(key);
|
|
20753
|
-
return row ? rowToAssignment(row) : null;
|
|
20754
|
-
}
|
|
20755
|
-
function upsertTopicDefaultAssignment(input) {
|
|
20756
|
-
const key = normalizeMemoryKey(input.memoryKey);
|
|
20757
|
-
const model = input.model.trim();
|
|
20758
|
-
if (!key || !model)
|
|
20759
|
-
return null;
|
|
20760
|
-
db.query(`INSERT INTO topic_default_assignments (memory_key, model, effort, reason, assign_count, updated_at)
|
|
20761
|
-
VALUES (?, ?, ?, ?, 1, ?)
|
|
20762
|
-
ON CONFLICT(memory_key) DO UPDATE SET
|
|
20763
|
-
model = excluded.model,
|
|
20764
|
-
effort = excluded.effort,
|
|
20765
|
-
reason = excluded.reason,
|
|
20766
|
-
assign_count = topic_default_assignments.assign_count + 1,
|
|
20767
|
-
updated_at = excluded.updated_at`).run(key, model, input.effort?.trim() || null, input.reason?.trim() || null, new Date().toISOString());
|
|
20768
|
-
return getTopicDefaultAssignment(key);
|
|
20769
|
-
}
|
|
20770
|
-
|
|
20771
|
-
// ../../packages/core/src/agents/topic-defaults.ts
|
|
20772
|
-
function validateAssignedDefaults(model, effort) {
|
|
20773
|
-
const candidate = canonicalModelId(model.trim());
|
|
20774
|
-
if (!candidate)
|
|
20775
|
-
return null;
|
|
20776
|
-
const agent = modelOwner(candidate);
|
|
20777
|
-
if (!agent)
|
|
20778
|
-
return null;
|
|
20779
|
-
let registry;
|
|
20780
|
-
try {
|
|
20781
|
-
registry = getRegistry(agent);
|
|
20782
|
-
} catch {
|
|
20783
|
-
return null;
|
|
20784
|
-
}
|
|
20785
|
-
if (!registry?.validateModel(candidate))
|
|
20786
|
-
return null;
|
|
20787
|
-
const requestedEffort = effort?.trim().toLowerCase();
|
|
20788
|
-
const resolvedEffort = requestedEffort && registry.validateEffort(requestedEffort) ? requestedEffort : registry.validateEffort(DEFAULT_TOPIC_EFFORT) ? DEFAULT_TOPIC_EFFORT : undefined;
|
|
20789
|
-
if (!resolvedEffort)
|
|
20790
|
-
return null;
|
|
20791
|
-
return { agent, model: candidate, effort: resolvedEffort };
|
|
20792
|
-
}
|
|
20793
|
-
function resolveAssignedTopicDefaults(memoryKey) {
|
|
20794
|
-
const key = memoryKey ? normalizeMemoryKey(memoryKey) : "";
|
|
20795
|
-
if (!key)
|
|
20796
|
-
return null;
|
|
20797
|
-
let stored;
|
|
20798
|
-
try {
|
|
20799
|
-
stored = getTopicDefaultAssignment(key);
|
|
20800
|
-
} catch (err2) {
|
|
20801
|
-
logger.warn({ err: err2, memoryKey: key }, "topic-defaults: assignment lookup failed");
|
|
20802
|
-
return null;
|
|
20803
|
-
}
|
|
20804
|
-
if (!stored)
|
|
20805
|
-
return null;
|
|
20806
|
-
const validated = validateAssignedDefaults(stored.model, stored.effort);
|
|
20807
|
-
if (!validated) {
|
|
20808
|
-
logger.info({ memoryKey: key, model: stored.model, effort: stored.effort }, "topic-defaults: stored assignment is stale - falling back to node defaults");
|
|
20809
|
-
return null;
|
|
20810
|
-
}
|
|
20811
|
-
return {
|
|
20812
|
-
memoryKey: key,
|
|
20813
|
-
...validated,
|
|
20814
|
-
...stored.reason ? { reason: stored.reason } : {}
|
|
20815
|
-
};
|
|
20816
|
-
}
|
|
20817
|
-
function assignTopicDefaults(input) {
|
|
20818
|
-
const validated = validateAssignedDefaults(input.model, input.effort);
|
|
20819
|
-
if (!validated)
|
|
20820
|
-
return null;
|
|
20821
|
-
try {
|
|
20822
|
-
const stored = upsertTopicDefaultAssignment({
|
|
20823
|
-
memoryKey: input.memoryKey,
|
|
20824
|
-
model: validated.model,
|
|
20825
|
-
effort: validated.effort,
|
|
20826
|
-
...input.reason ? { reason: input.reason } : {}
|
|
20827
|
-
});
|
|
20828
|
-
return stored ? { ...validated, assignCount: stored.assignCount } : null;
|
|
20829
|
-
} catch (err2) {
|
|
20830
|
-
logger.warn({ err: err2, memoryKey: input.memoryKey }, "topic-defaults: assignment write failed");
|
|
20831
|
-
return null;
|
|
20832
|
-
}
|
|
20833
|
-
}
|
|
20834
20781
|
export {
|
|
20835
20782
|
withTaskSnapshots,
|
|
20836
20783
|
withCodexSpawnSerial,
|
|
20837
20784
|
visualToolDefinitions,
|
|
20838
|
-
validateAssignedDefaults,
|
|
20839
20785
|
unregisterOwnedCodexPids,
|
|
20840
20786
|
summarizeToolInput,
|
|
20841
20787
|
summarizeShellCommand,
|
|
@@ -20847,7 +20793,6 @@ export {
|
|
|
20847
20793
|
showHtmlTool,
|
|
20848
20794
|
rotateTopicLogs,
|
|
20849
20795
|
resolveTaskEventScope,
|
|
20850
|
-
resolveAssignedTopicDefaults,
|
|
20851
20796
|
registerOwnedCodexPids,
|
|
20852
20797
|
purgeTopicLogs,
|
|
20853
20798
|
otiumVisualToolDefinitions,
|
|
@@ -20876,7 +20821,6 @@ export {
|
|
|
20876
20821
|
checkAgentModelAuth,
|
|
20877
20822
|
checkAgentAuth,
|
|
20878
20823
|
buildNumberedDiffSummary,
|
|
20879
|
-
assignTopicDefaults,
|
|
20880
20824
|
archiveActiveTopicForMemory,
|
|
20881
20825
|
applySelfConfigCapabilityFilter,
|
|
20882
20826
|
acquireCodexSpawnLock,
|
|
@@ -20886,4 +20830,4 @@ export {
|
|
|
20886
20830
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
20887
20831
|
};
|
|
20888
20832
|
|
|
20889
|
-
//# debugId=
|
|
20833
|
+
//# debugId=229E0F9700D2EF9E64756E2164756E21
|