negotium 0.4.0 → 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 +179 -142
- package/dist/agent-helpers.js.map +7 -7
- 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 +89 -47
- package/dist/hosted-agent.js.map +8 -8
- package/dist/main.js +315 -278
- package/dist/main.js.map +7 -7
- package/dist/mcp-catalog.js +3 -2
- package/dist/mcp-catalog.js.map +3 -3
- package/dist/mcp-factories.js +161 -124
- package/dist/mcp-factories.js.map +7 -7
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/codex-provider.ts +7 -1
- package/dist/runtime/src/agents/codex-vault-hook-bridge.ts +14 -8
- package/dist/runtime/src/agents/codex-vault-hook.mjs +3 -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/agents/codex-vault-hook-bridge.d.ts +1 -0
- 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 +2 -2
|
@@ -779,7 +779,7 @@ function isPoisonedAssistantEntry(entry) {
|
|
|
779
779
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
780
780
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
781
781
|
import { existsSync as existsSync3, readFileSync as readFileSync4, realpathSync as realpathSync2, statSync as statSync2, unlinkSync as unlinkSync3 } from "fs";
|
|
782
|
-
import { basename, dirname as dirname5, join as
|
|
782
|
+
import { basename, dirname as dirname5, join as join6, resolve as resolve5 } from "path";
|
|
783
783
|
|
|
784
784
|
// ../../packages/core/src/agents/execution-host.ts
|
|
785
785
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -838,6 +838,11 @@ function referencesRuntimeSecretStorage(value) {
|
|
|
838
838
|
return false;
|
|
839
839
|
}
|
|
840
840
|
|
|
841
|
+
// ../../packages/core/src/platform/mcp-config.ts
|
|
842
|
+
import { accessSync as accessSync2, constants as fsConstants } from "fs";
|
|
843
|
+
import { homedir as homedir3 } from "os";
|
|
844
|
+
import { join as join3 } from "path";
|
|
845
|
+
|
|
841
846
|
// ../../packages/core/src/mcp/canonical-bridge-config.ts
|
|
842
847
|
var registrations = [];
|
|
843
848
|
var turnLeases = new Map;
|
|
@@ -1200,7 +1205,8 @@ var COMMON_RUNTIME_MCP_POLICY = {
|
|
|
1200
1205
|
"system-health": { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
1201
1206
|
"background-bash": { scopes: ["forum"], forumRequired: true },
|
|
1202
1207
|
"agent-health": { scopes: ["forum", "manager", "cron"], forumRequired: true },
|
|
1203
|
-
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true }
|
|
1208
|
+
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
1209
|
+
"cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false }
|
|
1204
1210
|
};
|
|
1205
1211
|
function classifyForumMcpServers(catalog) {
|
|
1206
1212
|
const all = Object.entries(catalog).filter(([, entry]) => entry.scopes.includes("forum")).map(([name]) => name);
|
|
@@ -1528,8 +1534,38 @@ var MCP_CATALOG = {
|
|
|
1528
1534
|
args.push("--list-only=true");
|
|
1529
1535
|
return buildBuiltinMcpServer("vault", { ...ctx, userId: vaultUserId ?? userId }, () => buildStdioMcpServer(agent, VAULT_SERVER, args));
|
|
1530
1536
|
}
|
|
1537
|
+
},
|
|
1538
|
+
"cua-rs": {
|
|
1539
|
+
...commonRuntimeMcpPolicy("cua-rs"),
|
|
1540
|
+
build() {
|
|
1541
|
+
const bin = resolveCuaRsBinary();
|
|
1542
|
+
if (!bin)
|
|
1543
|
+
return null;
|
|
1544
|
+
return { command: bin, args: cuaRsArgs() };
|
|
1545
|
+
}
|
|
1531
1546
|
}
|
|
1532
1547
|
};
|
|
1548
|
+
function cuaRsArgs() {
|
|
1549
|
+
const raw = envText("NEGOTIUM_CUA_RS_ALLOW_HID")?.trim().toLowerCase();
|
|
1550
|
+
const on = raw === "1" || raw === "true" || raw === "yes";
|
|
1551
|
+
return on ? ["--allow-hid"] : [];
|
|
1552
|
+
}
|
|
1553
|
+
function resolveCuaRsBinary(platform = process.platform) {
|
|
1554
|
+
if (platform !== "darwin")
|
|
1555
|
+
return null;
|
|
1556
|
+
const candidates = [
|
|
1557
|
+
envText("NEGOTIUM_CUA_RS_BIN"),
|
|
1558
|
+
join3(homedir3(), ".local", "bin", "cua-rs"),
|
|
1559
|
+
"/usr/local/bin/cua-rs"
|
|
1560
|
+
].filter((p) => Boolean(p));
|
|
1561
|
+
for (const candidate of candidates) {
|
|
1562
|
+
try {
|
|
1563
|
+
accessSync2(candidate, fsConstants.X_OK);
|
|
1564
|
+
return candidate;
|
|
1565
|
+
} catch {}
|
|
1566
|
+
}
|
|
1567
|
+
return null;
|
|
1568
|
+
}
|
|
1533
1569
|
var allForumMcpServerNames = [];
|
|
1534
1570
|
var requiredForumMcpServers = [];
|
|
1535
1571
|
var REQUIRED_FORUM_MCP_SERVERS = requiredForumMcpServers;
|
|
@@ -1757,7 +1793,7 @@ function getMcpServersForQuery(opts) {
|
|
|
1757
1793
|
|
|
1758
1794
|
// ../../packages/core/src/storage/vault.ts
|
|
1759
1795
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync5 } from "fs";
|
|
1760
|
-
import { join as
|
|
1796
|
+
import { join as join5 } from "path";
|
|
1761
1797
|
|
|
1762
1798
|
// ../../packages/core/src/storage/sqlite.ts
|
|
1763
1799
|
var isBun = typeof process.versions.bun === "string";
|
|
@@ -1812,8 +1848,8 @@ if (isBun) {
|
|
|
1812
1848
|
|
|
1813
1849
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1814
1850
|
import { mkdirSync as mkdirSync4 } from "fs";
|
|
1815
|
-
import { homedir as
|
|
1816
|
-
import { dirname as dirname3, join as
|
|
1851
|
+
import { homedir as homedir4 } from "os";
|
|
1852
|
+
import { dirname as dirname3, join as join4, resolve as resolve4 } from "path";
|
|
1817
1853
|
var STORAGE_HOST_STATE = Symbol.for("negotium.storage-host.state.v1");
|
|
1818
1854
|
function storageState() {
|
|
1819
1855
|
const holder = globalThis;
|
|
@@ -1842,13 +1878,13 @@ function envPath(name, fallback) {
|
|
|
1842
1878
|
return resolve4(value || fallback);
|
|
1843
1879
|
}
|
|
1844
1880
|
function defaultStateDir() {
|
|
1845
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
1881
|
+
return envPath("NEGOTIUM_STATE_DIR", join4(homedir4(), ".negotium"));
|
|
1846
1882
|
}
|
|
1847
1883
|
function defaultDataDir() {
|
|
1848
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
1884
|
+
return envPath("NEGOTIUM_DATA_DIR", join4(defaultStateDir(), "data"));
|
|
1849
1885
|
}
|
|
1850
1886
|
function defaultSessionsDatabasePath() {
|
|
1851
|
-
return envPath("SESSIONS_DB_PATH",
|
|
1887
|
+
return envPath("SESSIONS_DB_PATH", join4(resolveStorageDataDir(), "sessions.db"));
|
|
1852
1888
|
}
|
|
1853
1889
|
var SQLITE_INIT_RETRY_MS = 25;
|
|
1854
1890
|
var SQLITE_INIT_TIMEOUT_MS = 5000;
|
|
@@ -2027,8 +2063,8 @@ function initializeVaultDatabase(database) {
|
|
|
2027
2063
|
}
|
|
2028
2064
|
}
|
|
2029
2065
|
function openVaultDatabase(dataDir) {
|
|
2030
|
-
const vaultDir =
|
|
2031
|
-
const path =
|
|
2066
|
+
const vaultDir = join5(dataDir, "vault");
|
|
2067
|
+
const path = join5(vaultDir, "vault.db");
|
|
2032
2068
|
mkdirSync5(vaultDir, { recursive: true, mode: 448 });
|
|
2033
2069
|
const database = new Database(path, { create: true });
|
|
2034
2070
|
chmodSync2(path, 384);
|
|
@@ -2155,13 +2191,13 @@ function hostedCodexHomePath() {
|
|
|
2155
2191
|
|
|
2156
2192
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2157
2193
|
function codexSessionsDir() {
|
|
2158
|
-
return
|
|
2194
|
+
return join6(hostedCodexHomePath(), "sessions");
|
|
2159
2195
|
}
|
|
2160
2196
|
var _shellCache = null;
|
|
2161
2197
|
function loadCodexShell() {
|
|
2162
2198
|
if (_shellCache)
|
|
2163
2199
|
return _shellCache;
|
|
2164
|
-
const raw = readFileSync4(
|
|
2200
|
+
const raw = readFileSync4(join6(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
2165
2201
|
const lines = parseJsonlText(raw);
|
|
2166
2202
|
if (lines.length < 5) {
|
|
2167
2203
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -2228,8 +2264,8 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
2228
2264
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
2229
2265
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
2230
2266
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
2231
|
-
const dir =
|
|
2232
|
-
return
|
|
2267
|
+
const dir = join6(codexSessionsDir(), yyyy, mm, dd);
|
|
2268
|
+
return join6(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
2233
2269
|
}
|
|
2234
2270
|
function canonicalFilePath(path) {
|
|
2235
2271
|
const absolute = resolve5(path);
|
|
@@ -2237,7 +2273,7 @@ function canonicalFilePath(path) {
|
|
|
2237
2273
|
return realpathSync2(absolute);
|
|
2238
2274
|
} catch {
|
|
2239
2275
|
try {
|
|
2240
|
-
return
|
|
2276
|
+
return join6(realpathSync2(dirname5(absolute)), basename(absolute));
|
|
2241
2277
|
} catch {
|
|
2242
2278
|
return absolute;
|
|
2243
2279
|
}
|
|
@@ -2426,19 +2462,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
2426
2462
|
try {
|
|
2427
2463
|
if (buckets) {
|
|
2428
2464
|
for (const bucket of buckets) {
|
|
2429
|
-
const dir =
|
|
2465
|
+
const dir = join6(sessionsDir, bucket);
|
|
2430
2466
|
if (!existsSync3(dir))
|
|
2431
2467
|
continue;
|
|
2432
2468
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
2433
2469
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
2434
|
-
candidates.push(
|
|
2470
|
+
candidates.push(join6(dir, rel));
|
|
2435
2471
|
}
|
|
2436
2472
|
}
|
|
2437
2473
|
}
|
|
2438
2474
|
if (candidates.length === 0) {
|
|
2439
2475
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
2440
2476
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
2441
|
-
candidates.push(
|
|
2477
|
+
candidates.push(join6(sessionsDir, rel));
|
|
2442
2478
|
}
|
|
2443
2479
|
}
|
|
2444
2480
|
return candidates.sort((a, b) => statSync2(b).mtimeMs - statSync2(a).mtimeMs)[0];
|
|
@@ -2559,13 +2595,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
2559
2595
|
return;
|
|
2560
2596
|
}
|
|
2561
2597
|
for (const bucket of buckets) {
|
|
2562
|
-
const dir =
|
|
2598
|
+
const dir = join6(sessionsDir, bucket);
|
|
2563
2599
|
if (!existsSync3(dir))
|
|
2564
2600
|
continue;
|
|
2565
2601
|
try {
|
|
2566
2602
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
2567
2603
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
2568
|
-
const fullPath =
|
|
2604
|
+
const fullPath = join6(dir, rel);
|
|
2569
2605
|
try {
|
|
2570
2606
|
unlinkSync3(fullPath);
|
|
2571
2607
|
} catch (e) {
|
|
@@ -2583,7 +2619,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
2583
2619
|
try {
|
|
2584
2620
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
2585
2621
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
2586
|
-
const fullPath =
|
|
2622
|
+
const fullPath = join6(sessionsDir, rel);
|
|
2587
2623
|
try {
|
|
2588
2624
|
unlinkSync3(fullPath);
|
|
2589
2625
|
} catch (e) {
|
|
@@ -2642,4 +2678,4 @@ function formatDateBucket(d) {
|
|
|
2642
2678
|
|
|
2643
2679
|
export { __toESM, __require, logger, CLAUDE_EFFORT_VALUES, CODEX_EFFORT_VALUES, MAESTRO_EFFORT_VALUES, MODEL_SONNET, MODEL_OPUS, MODEL_FABLE, configureRolloutHost, assertUuidLike, ensureCwdExists, extractChatPairs, encodeClaudeCwd, writeClaudeRollout, repairPoisonedRollout, hostedCodexHomePath, extractLatestCodexPatchPreview, extractCodexPatchCallIds, readCodexPatchCallIds, readLatestCodexPatchPreview, extractLatestCodexContextUsage, readLatestCodexContextUsage, migrateCodexRolloutNativeMultiAgentMetadata, latestCodexRolloutPath, writeCodexRollout, decodeUuidV7Timestamp };
|
|
2644
2680
|
|
|
2645
|
-
//# debugId=
|
|
2681
|
+
//# debugId=280A0B27D507790464756E2164756E21
|