@otium-team/negotium 0.23.11 → 0.23.14
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/README.md +8 -0
- package/dist/agent-helpers.js +821 -1516
- package/dist/agent-helpers.js.map +22 -21
- package/dist/background-bash.js +48 -19
- package/dist/background-bash.js.map +6 -5
- package/dist/browser-runtime.js +96 -69
- package/dist/browser-runtime.js.map +6 -5
- package/dist/canonical-mcp-bridge.js +8 -9
- package/dist/canonical-mcp-bridge.js.map +1 -1
- package/dist/{chunk-0fenxbe6.js → chunk-3v58ejrk.js} +4 -5
- package/dist/{chunk-0fenxbe6.js.map → chunk-3v58ejrk.js.map} +2 -2
- package/dist/chunk-d1c2wt8q.js +83 -0
- package/dist/{chunk-ad7kxsaq.js.map → chunk-d1c2wt8q.js.map} +1 -1
- package/dist/{chunk-jtv8yzy1.js → chunk-m1ngkjdd.js} +12 -12
- package/dist/{chunk-jtv8yzy1.js.map → chunk-m1ngkjdd.js.map} +2 -2
- package/dist/{chunk-da9ad838.js → chunk-ng13grfj.js} +180 -152
- package/dist/{chunk-da9ad838.js.map → chunk-ng13grfj.js.map} +11 -10
- package/dist/{chunk-mxxwx5mg.js → chunk-pesnv5zv.js} +134 -143
- package/dist/chunk-pesnv5zv.js.map +14 -0
- package/dist/{chunk-f7p0h1gs.js → chunk-ww8a4ej4.js} +5 -5
- package/dist/{chunk-f7p0h1gs.js.map → chunk-ww8a4ej4.js.map} +2 -2
- package/dist/hosted-agent.js +204 -136
- package/dist/hosted-agent.js.map +7 -7
- package/dist/main.js +4340 -4529
- package/dist/main.js.map +31 -28
- package/dist/mcp-catalog.js +4 -4
- package/dist/mcp-catalog.js.map +1 -1
- package/dist/mcp-factories.js +1080 -1767
- package/dist/mcp-factories.js.map +21 -20
- package/dist/mcp-servers.js +5 -5
- package/dist/mcp-servers.js.map +1 -1
- package/dist/media.js +42 -13
- package/dist/media.js.map +6 -5
- package/dist/outbox.js +15 -15
- package/dist/outbox.js.map +2 -2
- package/dist/platform-runtime.js +7 -7
- package/dist/platform-runtime.js.map +1 -1
- package/dist/prompts.js +74 -15
- package/dist/prompts.js.map +8 -7
- package/dist/query-runtime.js +57 -30
- package/dist/query-runtime.js.map +7 -6
- package/dist/registry.js +22 -21
- package/dist/registry.js.map +3 -3
- package/dist/rollout.js +41 -41
- package/dist/rollout.js.map +2 -2
- package/dist/runtime/src/agents/claude-provider.ts +80 -5
- package/dist/runtime/src/agents/claude-registry.ts +2 -1
- package/dist/runtime/src/agents/explicit-agent-switch.ts +1 -1
- package/dist/runtime/src/agents/mcp-tools/self-config.ts +1 -1
- package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +9 -1
- package/dist/runtime/src/agents/model-catalog.ts +13 -0
- package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +84 -20
- package/dist/runtime/src/application/topic-service.ts +6 -2
- package/dist/runtime/src/application/turn-follow-ups.ts +291 -0
- package/dist/runtime/src/bus.ts +6 -0
- package/dist/runtime/src/node-host.ts +11 -0
- package/dist/runtime/src/platform/browser-backend.ts +73 -0
- package/dist/runtime/src/platform/config.ts +3 -0
- package/dist/runtime/src/platform/mcp-config.ts +3 -0
- package/dist/runtime/src/prompts/builders.ts +11 -2
- package/dist/runtime/src/prompts/sessions/_shared-tools.md +2 -0
- package/dist/runtime/src/query/active-rooms.ts +7 -1
- package/dist/runtime/src/runtime/turn-event-stream.ts +34 -6
- package/dist/runtime/src/runtime/turn-runner.ts +54 -9
- package/dist/runtime/src/runtime-gateway.ts +198 -1
- package/dist/runtime/src/storage/runtime-follow-ups.ts +212 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +43 -2
- package/dist/runtime/src/storage/token-stats.ts +4 -0
- package/dist/runtime/src/types/api.ts +9 -0
- package/dist/runtime/src/types.ts +23 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-gateway.js +73 -12
- package/dist/runtime-gateway.js.map +3 -3
- package/dist/runtime-helpers.js +107 -80
- package/dist/runtime-helpers.js.map +6 -5
- package/dist/sqlite.js +3 -5
- package/dist/sqlite.js.map +2 -2
- package/dist/storage.js +4843 -4812
- package/dist/storage.js.map +4 -4
- package/dist/types/packages/core/src/bus.d.ts +3 -0
- package/dist/types/packages/core/src/platform/browser-backend.d.ts +8 -0
- package/dist/types/packages/core/src/platform/config.d.ts +2 -0
- package/dist/types/packages/core/src/query/active-rooms.d.ts +7 -1
- package/dist/types/packages/core/src/runtime-gateway.d.ts +59 -1
- package/dist/types/packages/core/src/storage/runtime-turn-requests.d.ts +25 -0
- package/dist/types/packages/core/src/types/api.d.ts +5 -0
- package/dist/types/packages/core/src/types.d.ts +21 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +64 -37
- package/dist/vault.js.map +6 -5
- package/package.json +1 -1
- package/dist/chunk-2mx7fq49.js +0 -6
- package/dist/chunk-2mx7fq49.js.map +0 -9
- package/dist/chunk-ad7kxsaq.js +0 -202
- package/dist/chunk-mxxwx5mg.js.map +0 -13
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __require = import.meta.require;
|
|
3
|
-
|
|
4
2
|
// ../../packages/core/src/agents/rollout/shared.ts
|
|
5
3
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
6
4
|
import { resolve as resolve3 } from "path";
|
|
@@ -9,19 +7,47 @@ import { resolve as resolve3 } from "path";
|
|
|
9
7
|
import { execFileSync } from "child_process";
|
|
10
8
|
import { randomBytes } from "crypto";
|
|
11
9
|
import {
|
|
12
|
-
accessSync,
|
|
10
|
+
accessSync as accessSync2,
|
|
13
11
|
chmodSync,
|
|
14
|
-
constants,
|
|
12
|
+
constants as constants2,
|
|
15
13
|
existsSync,
|
|
16
14
|
mkdirSync,
|
|
17
15
|
readFileSync,
|
|
18
16
|
writeFileSync
|
|
19
17
|
} from "fs";
|
|
20
18
|
import { createRequire } from "module";
|
|
21
|
-
import { homedir } from "os";
|
|
22
|
-
import { dirname, join, resolve } from "path";
|
|
19
|
+
import { homedir as homedir2 } from "os";
|
|
20
|
+
import { dirname, join as join2, resolve } from "path";
|
|
23
21
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
24
22
|
|
|
23
|
+
// ../../packages/core/src/platform/browser-backend.ts
|
|
24
|
+
import { accessSync, constants, statSync } from "fs";
|
|
25
|
+
import { homedir } from "os";
|
|
26
|
+
import { delimiter, isAbsolute, join } from "path";
|
|
27
|
+
function resolveBrowserBackend(value, findEgoBrowser = resolveEgoBrowserBin) {
|
|
28
|
+
const backend = value?.trim();
|
|
29
|
+
if (!backend)
|
|
30
|
+
return findEgoBrowser() ? "egolite" : "chrome";
|
|
31
|
+
if (backend === "chrome" || backend === "egolite")
|
|
32
|
+
return backend;
|
|
33
|
+
throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
|
|
34
|
+
}
|
|
35
|
+
function resolveEgoBrowserBin(path = process.env.PATH ?? "", home = homedir()) {
|
|
36
|
+
const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
|
|
37
|
+
const directories = [...path.split(delimiter).filter(isAbsolute), join(home, ".local", "bin")];
|
|
38
|
+
for (const directory of directories) {
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
const candidate = join(directory, name);
|
|
41
|
+
try {
|
|
42
|
+
accessSync(candidate, constants.X_OK);
|
|
43
|
+
if (statSync(candidate).isFile())
|
|
44
|
+
return candidate;
|
|
45
|
+
} catch {}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
25
51
|
// ../../packages/core/src/types.ts
|
|
26
52
|
var SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
|
|
27
53
|
function isAgentKind(value) {
|
|
@@ -80,7 +106,7 @@ var logger = createStdioLogger();
|
|
|
80
106
|
function envText(envKey) {
|
|
81
107
|
return readEnvText(process.env, envKey);
|
|
82
108
|
}
|
|
83
|
-
var HOME =
|
|
109
|
+
var HOME = homedir2();
|
|
84
110
|
function resolveStateDir() {
|
|
85
111
|
const configured = envText("NEGOTIUM_STATE_DIR");
|
|
86
112
|
if (false) {}
|
|
@@ -129,6 +155,7 @@ var TOPIC_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "topics");
|
|
|
129
155
|
var SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
|
|
130
156
|
var CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
|
|
131
157
|
var BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
|
|
158
|
+
var BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
|
|
132
159
|
var BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
|
|
133
160
|
var BINARIES_DIR = resolve(STATE_DIR, "binaries");
|
|
134
161
|
var SECRETS_DIR = resolve(STATE_DIR, "secrets");
|
|
@@ -176,7 +203,7 @@ function resolveBrowserRsBin(envValue) {
|
|
|
176
203
|
}
|
|
177
204
|
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
|
|
178
205
|
try {
|
|
179
|
-
|
|
206
|
+
accessSync2(candidate, constants2.X_OK);
|
|
180
207
|
return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
|
|
181
208
|
} catch {
|
|
182
209
|
return;
|
|
@@ -189,7 +216,7 @@ function resolveBashRsBin(envValue) {
|
|
|
189
216
|
const override = envValue?.trim();
|
|
190
217
|
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
|
|
191
218
|
try {
|
|
192
|
-
|
|
219
|
+
accessSync2(candidate, constants2.X_OK);
|
|
193
220
|
return candidate;
|
|
194
221
|
} catch {
|
|
195
222
|
return;
|
|
@@ -224,7 +251,7 @@ function safeWorkspaceSegment(value, fallback) {
|
|
|
224
251
|
return safeRuntimePathSegment(value, fallback);
|
|
225
252
|
}
|
|
226
253
|
function resolveTopicWorkspaceDir(topicId) {
|
|
227
|
-
return
|
|
254
|
+
return join2(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
|
|
228
255
|
}
|
|
229
256
|
function loadOrCreateLocalSecret(envKey, filename, options = {}) {
|
|
230
257
|
const envValue = envText(envKey);
|
|
@@ -314,6 +341,7 @@ var FILE_TAG_REGEX = new RegExp(`\\[FILE:(${ABSOLUTE_PATH_PREFIX}[^\\]]+)\\]`, "
|
|
|
314
341
|
var MODEL_SONNET = "claude-sonnet-5";
|
|
315
342
|
var MODEL_OPUS = "claude-opus-5-5";
|
|
316
343
|
var MODEL_FABLE = "claude-fable-5-1";
|
|
344
|
+
var MODEL_FABLE_5_2 = "claude-fable-5-2";
|
|
317
345
|
var FALLBACK_AGENT = resolveFallbackAgent(process.env);
|
|
318
346
|
var FALLBACK_MODEL = envText("FALLBACK_MODEL") ?? envText("DEFAULT_MODEL");
|
|
319
347
|
var DEFAULT_TOPIC_EFFORT = (() => {
|
|
@@ -336,12 +364,12 @@ var WHISPER_MODEL_MLX = envText("WHISPER_MODEL_MLX") ?? "mlx-community/whisper-l
|
|
|
336
364
|
var _envMaxTellDepth = Number.parseInt(process.env.MAX_TELL_DEPTH ?? "", 10);
|
|
337
365
|
var MAX_TELL_DEPTH = Number.isInteger(_envMaxTellDepth) && _envMaxTellDepth > 0 ? _envMaxTellDepth : 20;
|
|
338
366
|
function codexAuthFilePath() {
|
|
339
|
-
return process.env.NEGOTIUM_CODEX_AUTH_FILE ||
|
|
367
|
+
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join2(process.env.CODEX_HOME || join2(homedir2(), ".codex"), "auth.json");
|
|
340
368
|
}
|
|
341
369
|
|
|
342
370
|
// ../../packages/core/src/platform/paths.ts
|
|
343
371
|
import { existsSync as existsSync2, realpathSync } from "fs";
|
|
344
|
-
import { dirname as dirname2, isAbsolute, relative, resolve as resolve2, sep } from "path";
|
|
372
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
|
|
345
373
|
function normalizeExistingOrResolved(filePath) {
|
|
346
374
|
const resolved = resolve2(filePath);
|
|
347
375
|
try {
|
|
@@ -365,7 +393,7 @@ function isInsideDir(childPath, parentDir) {
|
|
|
365
393
|
const parent = normalizeExistingOrResolved(parentDir);
|
|
366
394
|
const child = normalizeExistingOrResolved(childPath);
|
|
367
395
|
const rel = relative(parent, child);
|
|
368
|
-
return rel === "" || !!rel && !rel.startsWith("..") && !
|
|
396
|
+
return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute2(rel);
|
|
369
397
|
}
|
|
370
398
|
function toDisplayPath(filePath) {
|
|
371
399
|
return filePath.split(sep).join("/");
|
|
@@ -390,7 +418,7 @@ var trustedWorkspaceRoots = [
|
|
|
390
418
|
SESSION_WORKSPACE_DIR,
|
|
391
419
|
TOPIC_WORKSPACE_DIR
|
|
392
420
|
].map((root) => resolve3(root));
|
|
393
|
-
function
|
|
421
|
+
function configureRolloutHost2(options) {
|
|
394
422
|
if (!options.workspaceRoots && !options.fixturesDir) {
|
|
395
423
|
throw new Error("configureRolloutHost requires workspaceRoots or fixturesDir");
|
|
396
424
|
}
|
|
@@ -442,7 +470,7 @@ function truncate(text, n) {
|
|
|
442
470
|
const cps = Array.from(text);
|
|
443
471
|
return cps.length > n ? `${cps.slice(0, n).join("")}\u2026` : text;
|
|
444
472
|
}
|
|
445
|
-
function
|
|
473
|
+
function extractChatPairs2(entries, opts = { includeToolAnnotations: true }) {
|
|
446
474
|
const pairs = [];
|
|
447
475
|
let pendingUsers = [];
|
|
448
476
|
let pendingBatchSize = null;
|
|
@@ -546,9 +574,91 @@ ${toolBuffer.join(`
|
|
|
546
574
|
return pairs;
|
|
547
575
|
}
|
|
548
576
|
|
|
577
|
+
// ../../packages/core/src/platform/jsonl.ts
|
|
578
|
+
import {
|
|
579
|
+
appendFileSync,
|
|
580
|
+
closeSync,
|
|
581
|
+
fsyncSync,
|
|
582
|
+
mkdirSync as mkdirSync3,
|
|
583
|
+
openSync,
|
|
584
|
+
readFileSync as readFileSync2,
|
|
585
|
+
renameSync,
|
|
586
|
+
statSync as statSync2,
|
|
587
|
+
unlinkSync as unlinkSync2,
|
|
588
|
+
writeFileSync as writeFileSync2
|
|
589
|
+
} from "fs";
|
|
590
|
+
import { dirname as dirname3 } from "path";
|
|
591
|
+
|
|
592
|
+
// ../../packages/core/src/platform/file-utils.ts
|
|
593
|
+
import { unlinkSync } from "fs";
|
|
594
|
+
function createSafeUnlink(host) {
|
|
595
|
+
return (path, warnLabel) => {
|
|
596
|
+
try {
|
|
597
|
+
host.unlink(path);
|
|
598
|
+
} catch (e) {
|
|
599
|
+
if (e?.code === "ENOENT")
|
|
600
|
+
return;
|
|
601
|
+
if (warnLabel)
|
|
602
|
+
host.warn({ err: e, path }, warnLabel);
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
var defaultSafeUnlink = createSafeUnlink({
|
|
607
|
+
unlink: unlinkSync,
|
|
608
|
+
warn: (context, message) => logger.warn(context, message)
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// ../../packages/core/src/platform/jsonl.ts
|
|
612
|
+
function parseJsonlText(raw) {
|
|
613
|
+
return raw.trim().split(`
|
|
614
|
+
`).filter(Boolean).map((line) => JSON.parse(line));
|
|
615
|
+
}
|
|
616
|
+
var LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
617
|
+
function writeJsonlFile(filePath, entries) {
|
|
618
|
+
const dir = dirname3(filePath);
|
|
619
|
+
mkdirSync3(dir, { recursive: true });
|
|
620
|
+
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
621
|
+
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
622
|
+
`)}
|
|
623
|
+
`;
|
|
624
|
+
let fd = null;
|
|
625
|
+
try {
|
|
626
|
+
fd = openSync(tmpPath, "w");
|
|
627
|
+
writeFileSync2(fd, payload);
|
|
628
|
+
fsyncSync(fd);
|
|
629
|
+
closeSync(fd);
|
|
630
|
+
fd = null;
|
|
631
|
+
renameSync(tmpPath, filePath);
|
|
632
|
+
fsyncDirectoryBestEffort(dir);
|
|
633
|
+
} catch (err) {
|
|
634
|
+
if (fd !== null) {
|
|
635
|
+
try {
|
|
636
|
+
closeSync(fd);
|
|
637
|
+
} catch {}
|
|
638
|
+
}
|
|
639
|
+
try {
|
|
640
|
+
unlinkSync2(tmpPath);
|
|
641
|
+
} catch {}
|
|
642
|
+
throw err;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function fsyncDirectoryBestEffort(dir) {
|
|
646
|
+
let fd = null;
|
|
647
|
+
try {
|
|
648
|
+
fd = openSync(dir, "r");
|
|
649
|
+
fsyncSync(fd);
|
|
650
|
+
} catch {} finally {
|
|
651
|
+
if (fd !== null) {
|
|
652
|
+
try {
|
|
653
|
+
closeSync(fd);
|
|
654
|
+
} catch {}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
549
659
|
// ../../packages/core/src/agents/execution-host.ts
|
|
550
660
|
import { AsyncLocalStorage } from "async_hooks";
|
|
551
|
-
import { dirname as
|
|
661
|
+
import { dirname as dirname5 } from "path";
|
|
552
662
|
|
|
553
663
|
// ../../packages/core/src/security/sensitive-path.ts
|
|
554
664
|
import { realpathSync as realpathSync2 } from "fs";
|
|
@@ -627,7 +737,7 @@ function agentAliases(agent) {
|
|
|
627
737
|
"gpt-6-astra"
|
|
628
738
|
];
|
|
629
739
|
case "claude":
|
|
630
|
-
return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable"];
|
|
740
|
+
return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable", "fable-5.2"];
|
|
631
741
|
case "maestro":
|
|
632
742
|
return [
|
|
633
743
|
"maestro",
|
|
@@ -1211,12 +1321,12 @@ function createBackgroundBashManager(options = {}) {
|
|
|
1211
1321
|
usedPorts.clear();
|
|
1212
1322
|
knownContexts.clear();
|
|
1213
1323
|
const deadline = now() + 3000;
|
|
1214
|
-
await Promise.all(entries.map((instance) => new Promise((
|
|
1324
|
+
await Promise.all(entries.map((instance) => new Promise((resolve) => {
|
|
1215
1325
|
if (instance.process.exitCode !== null || instance.process.killed)
|
|
1216
|
-
return
|
|
1217
|
-
instance.process.once("exit",
|
|
1218
|
-
instance.process.once("error",
|
|
1219
|
-
const timer = setTimeout(
|
|
1326
|
+
return resolve();
|
|
1327
|
+
instance.process.once("exit", resolve);
|
|
1328
|
+
instance.process.once("error", resolve);
|
|
1329
|
+
const timer = setTimeout(resolve, Math.max(0, deadline - now()));
|
|
1220
1330
|
timer.unref?.();
|
|
1221
1331
|
})));
|
|
1222
1332
|
}
|
|
@@ -1312,9 +1422,9 @@ var RESERVED_TOPIC_NAMES = new Set([
|
|
|
1312
1422
|
var GENERAL_TOPIC_ID = "general";
|
|
1313
1423
|
|
|
1314
1424
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1315
|
-
import { mkdirSync as
|
|
1316
|
-
import { homedir as
|
|
1317
|
-
import { dirname as
|
|
1425
|
+
import { mkdirSync as mkdirSync4 } from "fs";
|
|
1426
|
+
import { homedir as homedir3 } from "os";
|
|
1427
|
+
import { dirname as dirname4, join as join3, resolve as resolve5 } from "path";
|
|
1318
1428
|
|
|
1319
1429
|
// ../../packages/core/src/storage/sqlite.ts
|
|
1320
1430
|
var isBun = typeof process.versions.bun === "string";
|
|
@@ -1405,13 +1515,13 @@ function envPath(name, fallback) {
|
|
|
1405
1515
|
return resolve5(value || fallback);
|
|
1406
1516
|
}
|
|
1407
1517
|
function defaultStateDir() {
|
|
1408
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
1518
|
+
return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
|
|
1409
1519
|
}
|
|
1410
1520
|
function defaultDataDir() {
|
|
1411
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
1521
|
+
return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
|
|
1412
1522
|
}
|
|
1413
1523
|
function defaultSessionsDatabasePath() {
|
|
1414
|
-
return envPath("SESSIONS_DB_PATH",
|
|
1524
|
+
return envPath("SESSIONS_DB_PATH", join3(resolveStorageDataDir(), "sessions.db"));
|
|
1415
1525
|
}
|
|
1416
1526
|
var SQLITE_INIT_RETRY_MS = 25;
|
|
1417
1527
|
var SQLITE_INIT_TIMEOUT_MS = 5000;
|
|
@@ -1449,7 +1559,7 @@ function defaultDatabase() {
|
|
|
1449
1559
|
return state.fallbackDatabase;
|
|
1450
1560
|
if (state.fallbackDatabase)
|
|
1451
1561
|
closeDatabase(state.fallbackDatabase);
|
|
1452
|
-
|
|
1562
|
+
mkdirSync4(dirname4(path), { recursive: true });
|
|
1453
1563
|
state.fallbackDatabase = new Database(path, { create: true });
|
|
1454
1564
|
state.fallbackDatabasePath = path;
|
|
1455
1565
|
initializeDatabase(state.fallbackDatabase);
|
|
@@ -1649,7 +1759,7 @@ var SCHEMA_TRIGGERS = {
|
|
|
1649
1759
|
};
|
|
1650
1760
|
var OTIUM_TOPIC_SCOPE_IMMUTABLE_ERROR = "otium_topic_scope_immutable";
|
|
1651
1761
|
function topicLinkSchemaIsCurrent(database, nodeId) {
|
|
1652
|
-
const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((
|
|
1762
|
+
const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((row) => [row.name, row.sql ?? ""]));
|
|
1653
1763
|
for (const name of [...SCHEMA_TABLES, ...SCHEMA_INDEXES, ...SCHEMA_INDEXES_TOMBSTONES]) {
|
|
1654
1764
|
if (!objects.has(name))
|
|
1655
1765
|
return false;
|
|
@@ -1666,7 +1776,7 @@ function topicLinkSchemaIsCurrent(database, nodeId) {
|
|
|
1666
1776
|
return false;
|
|
1667
1777
|
}
|
|
1668
1778
|
const identity = database.query("SELECT node_id, epoch_id FROM api_node_identity WHERE singleton = 1").all();
|
|
1669
|
-
if (identity.some((
|
|
1779
|
+
if (identity.some((row) => row.epoch_id === null))
|
|
1670
1780
|
return false;
|
|
1671
1781
|
if (nodeId && identity[0]?.node_id !== nodeId)
|
|
1672
1782
|
return false;
|
|
@@ -2588,6 +2698,8 @@ var MCP_CATALOG = {
|
|
|
2588
2698
|
playwright: {
|
|
2589
2699
|
...commonRuntimeMcpPolicy("playwright"),
|
|
2590
2700
|
build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
|
|
2701
|
+
if (BROWSER_BACKEND === "egolite")
|
|
2702
|
+
return null;
|
|
2591
2703
|
if (playwrightPort && playwrightCapability) {
|
|
2592
2704
|
const owner = browserOwnerForContext({ userId, session, topicId });
|
|
2593
2705
|
if (!owner)
|
|
@@ -3127,8 +3239,8 @@ function hideProviderIntrospectionForOtium(servers, topicId) {
|
|
|
3127
3239
|
}
|
|
3128
3240
|
|
|
3129
3241
|
// ../../packages/core/src/storage/vault.ts
|
|
3130
|
-
import { chmodSync as chmodSync2, mkdirSync as
|
|
3131
|
-
import { join as
|
|
3242
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync5 } from "fs";
|
|
3243
|
+
import { join as join4 } from "path";
|
|
3132
3244
|
|
|
3133
3245
|
// ../../packages/core/src/storage/vault-crypto-core.ts
|
|
3134
3246
|
import { createCipheriv, createDecipheriv, createHash as createHash2, randomBytes as randomBytes3 } from "crypto";
|
|
@@ -3219,9 +3331,9 @@ function initializeVaultDatabase(database) {
|
|
|
3219
3331
|
}
|
|
3220
3332
|
}
|
|
3221
3333
|
function openVaultDatabase(dataDir) {
|
|
3222
|
-
const vaultDir =
|
|
3223
|
-
const path =
|
|
3224
|
-
|
|
3334
|
+
const vaultDir = join4(dataDir, "vault");
|
|
3335
|
+
const path = join4(vaultDir, "vault.db");
|
|
3336
|
+
mkdirSync5(vaultDir, { recursive: true, mode: 448 });
|
|
3225
3337
|
const database = new Database(path, { create: true });
|
|
3226
3338
|
chmodSync2(path, 384);
|
|
3227
3339
|
initializeVaultDatabase(database);
|
|
@@ -3342,105 +3454,21 @@ function hostedCodexAuthFilePath() {
|
|
|
3342
3454
|
return activeHost().codexAuthFilePath();
|
|
3343
3455
|
}
|
|
3344
3456
|
function hostedCodexHomePath() {
|
|
3345
|
-
return
|
|
3457
|
+
return dirname5(hostedCodexAuthFilePath());
|
|
3346
3458
|
}
|
|
3347
3459
|
|
|
3348
3460
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
3349
3461
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
3350
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as
|
|
3351
|
-
import { basename, dirname as dirname6, join as
|
|
3352
|
-
|
|
3353
|
-
// ../../packages/core/src/platform/jsonl.ts
|
|
3354
|
-
import {
|
|
3355
|
-
appendFileSync,
|
|
3356
|
-
closeSync,
|
|
3357
|
-
fsyncSync,
|
|
3358
|
-
mkdirSync as mkdirSync5,
|
|
3359
|
-
openSync,
|
|
3360
|
-
readFileSync as readFileSync2,
|
|
3361
|
-
renameSync,
|
|
3362
|
-
statSync,
|
|
3363
|
-
unlinkSync as unlinkSync2,
|
|
3364
|
-
writeFileSync as writeFileSync2
|
|
3365
|
-
} from "fs";
|
|
3366
|
-
import { dirname as dirname5 } from "path";
|
|
3367
|
-
|
|
3368
|
-
// ../../packages/core/src/platform/file-utils.ts
|
|
3369
|
-
import { unlinkSync } from "fs";
|
|
3370
|
-
function createSafeUnlink(host) {
|
|
3371
|
-
return (path, warnLabel) => {
|
|
3372
|
-
try {
|
|
3373
|
-
host.unlink(path);
|
|
3374
|
-
} catch (e) {
|
|
3375
|
-
if (e?.code === "ENOENT")
|
|
3376
|
-
return;
|
|
3377
|
-
if (warnLabel)
|
|
3378
|
-
host.warn({ err: e, path }, warnLabel);
|
|
3379
|
-
}
|
|
3380
|
-
};
|
|
3381
|
-
}
|
|
3382
|
-
var defaultSafeUnlink = createSafeUnlink({
|
|
3383
|
-
unlink: unlinkSync,
|
|
3384
|
-
warn: (context, message) => logger.warn(context, message)
|
|
3385
|
-
});
|
|
3386
|
-
|
|
3387
|
-
// ../../packages/core/src/platform/jsonl.ts
|
|
3388
|
-
function parseJsonlText(raw) {
|
|
3389
|
-
return raw.trim().split(`
|
|
3390
|
-
`).filter(Boolean).map((line) => JSON.parse(line));
|
|
3391
|
-
}
|
|
3392
|
-
var LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
3393
|
-
function writeJsonlFile(filePath, entries) {
|
|
3394
|
-
const dir = dirname5(filePath);
|
|
3395
|
-
mkdirSync5(dir, { recursive: true });
|
|
3396
|
-
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3397
|
-
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
3398
|
-
`)}
|
|
3399
|
-
`;
|
|
3400
|
-
let fd = null;
|
|
3401
|
-
try {
|
|
3402
|
-
fd = openSync(tmpPath, "w");
|
|
3403
|
-
writeFileSync2(fd, payload);
|
|
3404
|
-
fsyncSync(fd);
|
|
3405
|
-
closeSync(fd);
|
|
3406
|
-
fd = null;
|
|
3407
|
-
renameSync(tmpPath, filePath);
|
|
3408
|
-
fsyncDirectoryBestEffort(dir);
|
|
3409
|
-
} catch (err) {
|
|
3410
|
-
if (fd !== null) {
|
|
3411
|
-
try {
|
|
3412
|
-
closeSync(fd);
|
|
3413
|
-
} catch {}
|
|
3414
|
-
}
|
|
3415
|
-
try {
|
|
3416
|
-
unlinkSync2(tmpPath);
|
|
3417
|
-
} catch {}
|
|
3418
|
-
throw err;
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
function fsyncDirectoryBestEffort(dir) {
|
|
3422
|
-
let fd = null;
|
|
3423
|
-
try {
|
|
3424
|
-
fd = openSync(dir, "r");
|
|
3425
|
-
fsyncSync(fd);
|
|
3426
|
-
} catch {} finally {
|
|
3427
|
-
if (fd !== null) {
|
|
3428
|
-
try {
|
|
3429
|
-
closeSync(fd);
|
|
3430
|
-
} catch {}
|
|
3431
|
-
}
|
|
3432
|
-
}
|
|
3433
|
-
}
|
|
3434
|
-
|
|
3435
|
-
// ../../packages/core/src/agents/rollout/codex.ts
|
|
3462
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync3 } from "fs";
|
|
3463
|
+
import { basename, dirname as dirname6, join as join5, resolve as resolve6 } from "path";
|
|
3436
3464
|
function codexSessionsDir() {
|
|
3437
|
-
return
|
|
3465
|
+
return join5(hostedCodexHomePath(), "sessions");
|
|
3438
3466
|
}
|
|
3439
3467
|
var _shellCache = null;
|
|
3440
3468
|
function loadCodexShell() {
|
|
3441
3469
|
if (_shellCache)
|
|
3442
3470
|
return _shellCache;
|
|
3443
|
-
const raw = readFileSync3(
|
|
3471
|
+
const raw = readFileSync3(join5(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
3444
3472
|
const lines = parseJsonlText(raw);
|
|
3445
3473
|
if (lines.length < 5) {
|
|
3446
3474
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -3499,7 +3527,7 @@ function patchEnvContext(envContext, cwd, currentDate, timezone) {
|
|
|
3499
3527
|
}
|
|
3500
3528
|
}
|
|
3501
3529
|
function codexRolloutPath(threadId, fallback) {
|
|
3502
|
-
const threadCreatedAt =
|
|
3530
|
+
const threadCreatedAt = decodeUuidV7Timestamp2(threadId);
|
|
3503
3531
|
const createdAt = threadCreatedAt === null ? fallback : new Date(threadCreatedAt);
|
|
3504
3532
|
const yyyy = String(createdAt.getFullYear());
|
|
3505
3533
|
const mm = String(createdAt.getMonth() + 1).padStart(2, "0");
|
|
@@ -3507,8 +3535,8 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
3507
3535
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
3508
3536
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
3509
3537
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
3510
|
-
const dir =
|
|
3511
|
-
return
|
|
3538
|
+
const dir = join5(codexSessionsDir(), yyyy, mm, dd);
|
|
3539
|
+
return join5(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
3512
3540
|
}
|
|
3513
3541
|
function canonicalFilePath(path) {
|
|
3514
3542
|
const absolute = resolve6(path);
|
|
@@ -3516,7 +3544,7 @@ function canonicalFilePath(path) {
|
|
|
3516
3544
|
return realpathSync3(absolute);
|
|
3517
3545
|
} catch {
|
|
3518
3546
|
try {
|
|
3519
|
-
return
|
|
3547
|
+
return join5(realpathSync3(dirname6(absolute)), basename(absolute));
|
|
3520
3548
|
} catch {
|
|
3521
3549
|
return absolute;
|
|
3522
3550
|
}
|
|
@@ -3571,7 +3599,7 @@ function changedPatchLines(value) {
|
|
|
3571
3599
|
`) } : {}
|
|
3572
3600
|
};
|
|
3573
3601
|
}
|
|
3574
|
-
function
|
|
3602
|
+
function extractLatestCodexPatchPreview2(jsonl, expectedPaths, consumedCallIds = new Set, expectedCallId) {
|
|
3575
3603
|
const expected = expectedPaths.map(canonicalFilePath);
|
|
3576
3604
|
const lines = jsonl.trimEnd().split(`
|
|
3577
3605
|
`);
|
|
@@ -3608,7 +3636,7 @@ function extractLatestCodexPatchPreview(jsonl, expectedPaths, consumedCallIds =
|
|
|
3608
3636
|
}
|
|
3609
3637
|
return;
|
|
3610
3638
|
}
|
|
3611
|
-
function
|
|
3639
|
+
function extractCodexPatchCallIds2(jsonl) {
|
|
3612
3640
|
const callIds = [];
|
|
3613
3641
|
for (const line of jsonl.trimEnd().split(`
|
|
3614
3642
|
`)) {
|
|
@@ -3621,29 +3649,29 @@ function extractCodexPatchCallIds(jsonl) {
|
|
|
3621
3649
|
}
|
|
3622
3650
|
return callIds;
|
|
3623
3651
|
}
|
|
3624
|
-
function
|
|
3652
|
+
function readCodexPatchCallIds2(threadId) {
|
|
3625
3653
|
const path = latestCodexRolloutPath(threadId);
|
|
3626
3654
|
if (!path)
|
|
3627
3655
|
return [];
|
|
3628
3656
|
try {
|
|
3629
|
-
return
|
|
3657
|
+
return extractCodexPatchCallIds2(readFileSync3(path, "utf8"));
|
|
3630
3658
|
} catch (error) {
|
|
3631
3659
|
logger.debug({ error, threadId }, "codex patch ids: rollout read failed");
|
|
3632
3660
|
return [];
|
|
3633
3661
|
}
|
|
3634
3662
|
}
|
|
3635
|
-
function
|
|
3663
|
+
function readLatestCodexPatchPreview2(threadId, expectedPaths, consumedCallIds = new Set, expectedCallId) {
|
|
3636
3664
|
const path = latestCodexRolloutPath(threadId);
|
|
3637
3665
|
if (!path)
|
|
3638
3666
|
return;
|
|
3639
3667
|
try {
|
|
3640
|
-
return
|
|
3668
|
+
return extractLatestCodexPatchPreview2(readFileSync3(path, "utf8"), expectedPaths, consumedCallIds, expectedCallId);
|
|
3641
3669
|
} catch (error) {
|
|
3642
3670
|
logger.debug({ error, threadId }, "codex patch preview: rollout read failed");
|
|
3643
3671
|
return;
|
|
3644
3672
|
}
|
|
3645
3673
|
}
|
|
3646
|
-
function
|
|
3674
|
+
function extractLatestCodexContextUsage2(jsonl) {
|
|
3647
3675
|
const lines = jsonl.trimEnd().split(`
|
|
3648
3676
|
`);
|
|
3649
3677
|
for (let index = lines.length - 1;index >= 0; index -= 1) {
|
|
@@ -3660,18 +3688,18 @@ function extractLatestCodexContextUsage(jsonl) {
|
|
|
3660
3688
|
}
|
|
3661
3689
|
return;
|
|
3662
3690
|
}
|
|
3663
|
-
function
|
|
3691
|
+
function readLatestCodexContextUsage2(threadId) {
|
|
3664
3692
|
const path = latestCodexRolloutPath(threadId);
|
|
3665
3693
|
if (!path)
|
|
3666
3694
|
return;
|
|
3667
3695
|
try {
|
|
3668
|
-
return
|
|
3696
|
+
return extractLatestCodexContextUsage2(readFileSync3(path, "utf8"));
|
|
3669
3697
|
} catch (error) {
|
|
3670
3698
|
logger.debug({ error, threadId }, "codex context usage: rollout read failed");
|
|
3671
3699
|
return;
|
|
3672
3700
|
}
|
|
3673
3701
|
}
|
|
3674
|
-
function
|
|
3702
|
+
function migrateCodexRolloutNativeMultiAgentMetadata2(threadId) {
|
|
3675
3703
|
const path = latestCodexRolloutPath(threadId);
|
|
3676
3704
|
if (!path)
|
|
3677
3705
|
return false;
|
|
@@ -3705,32 +3733,32 @@ function latestCodexRolloutPath(threadId) {
|
|
|
3705
3733
|
try {
|
|
3706
3734
|
if (buckets) {
|
|
3707
3735
|
for (const bucket of buckets) {
|
|
3708
|
-
const dir =
|
|
3736
|
+
const dir = join5(sessionsDir, bucket);
|
|
3709
3737
|
if (!existsSync3(dir))
|
|
3710
3738
|
continue;
|
|
3711
3739
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3712
3740
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3713
|
-
candidates.push(
|
|
3741
|
+
candidates.push(join5(dir, rel));
|
|
3714
3742
|
}
|
|
3715
3743
|
}
|
|
3716
3744
|
}
|
|
3717
3745
|
if (candidates.length === 0) {
|
|
3718
3746
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3719
3747
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3720
|
-
candidates.push(
|
|
3748
|
+
candidates.push(join5(sessionsDir, rel));
|
|
3721
3749
|
}
|
|
3722
3750
|
}
|
|
3723
|
-
return candidates.sort((a, b) =>
|
|
3751
|
+
return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
|
|
3724
3752
|
} catch (error) {
|
|
3725
3753
|
logger.debug({ error, threadId }, "codex rollout lookup failed");
|
|
3726
3754
|
return;
|
|
3727
3755
|
}
|
|
3728
3756
|
}
|
|
3729
|
-
function
|
|
3757
|
+
function writeCodexRollout2(opts) {
|
|
3730
3758
|
const threadId = opts.threadId ?? uuidv7();
|
|
3731
3759
|
assertUuidLike("threadId", threadId);
|
|
3732
3760
|
ensureCwdExists(opts.cwd);
|
|
3733
|
-
const pairs = opts.pairs ??
|
|
3761
|
+
const pairs = opts.pairs ?? extractChatPairs2(opts.entries ?? []);
|
|
3734
3762
|
const now = new Date;
|
|
3735
3763
|
const tsIso = now.toISOString();
|
|
3736
3764
|
const currentDate = [
|
|
@@ -3841,13 +3869,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
3841
3869
|
return;
|
|
3842
3870
|
}
|
|
3843
3871
|
for (const bucket of buckets) {
|
|
3844
|
-
const dir =
|
|
3872
|
+
const dir = join5(sessionsDir, bucket);
|
|
3845
3873
|
if (!existsSync3(dir))
|
|
3846
3874
|
continue;
|
|
3847
3875
|
try {
|
|
3848
3876
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3849
3877
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3850
|
-
const fullPath =
|
|
3878
|
+
const fullPath = join5(dir, rel);
|
|
3851
3879
|
try {
|
|
3852
3880
|
unlinkSync3(fullPath);
|
|
3853
3881
|
} catch (e) {
|
|
@@ -3865,7 +3893,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
3865
3893
|
try {
|
|
3866
3894
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3867
3895
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3868
|
-
const fullPath =
|
|
3896
|
+
const fullPath = join5(sessionsDir, rel);
|
|
3869
3897
|
try {
|
|
3870
3898
|
unlinkSync3(fullPath);
|
|
3871
3899
|
} catch (e) {
|
|
@@ -3882,7 +3910,7 @@ var MAX_DAY_SPAN = 30;
|
|
|
3882
3910
|
var DAY_MS = 86400000;
|
|
3883
3911
|
var LOCAL_DATE_SKEW_DAYS = 1;
|
|
3884
3912
|
function candidateDateBuckets(threadId) {
|
|
3885
|
-
const tidMs =
|
|
3913
|
+
const tidMs = decodeUuidV7Timestamp2(threadId);
|
|
3886
3914
|
if (tidMs === null)
|
|
3887
3915
|
return null;
|
|
3888
3916
|
const nowMs = Date.now();
|
|
@@ -3899,7 +3927,7 @@ function candidateDateBuckets(threadId) {
|
|
|
3899
3927
|
}
|
|
3900
3928
|
return buckets;
|
|
3901
3929
|
}
|
|
3902
|
-
function
|
|
3930
|
+
function decodeUuidV7Timestamp2(threadId) {
|
|
3903
3931
|
if (typeof threadId !== "string")
|
|
3904
3932
|
return null;
|
|
3905
3933
|
const m = /^([0-9a-fA-F]{8})-([0-9a-fA-F]{4})-7[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.exec(threadId);
|
|
@@ -3922,6 +3950,6 @@ function formatDateBucket(d) {
|
|
|
3922
3950
|
return `${yyyy}/${mm}/${dd}`;
|
|
3923
3951
|
}
|
|
3924
3952
|
|
|
3925
|
-
export {
|
|
3953
|
+
export { CLAUDE_EFFORT_VALUES, CODEX_EFFORT_VALUES, MAESTRO_EFFORT_VALUES, logger, MODEL_SONNET, MODEL_OPUS, MODEL_FABLE, MODEL_FABLE_5_2, configureRolloutHost2, FIXTURES_DIR, clone, assertUuidLike, ensureCwdExists, extractChatPairs2, parseJsonlText, writeJsonlFile, hostedCodexHomePath, extractLatestCodexPatchPreview2, extractCodexPatchCallIds2, readCodexPatchCallIds2, readLatestCodexPatchPreview2, extractLatestCodexContextUsage2, readLatestCodexContextUsage2, migrateCodexRolloutNativeMultiAgentMetadata2, latestCodexRolloutPath, writeCodexRollout2, decodeUuidV7Timestamp2 };
|
|
3926
3954
|
|
|
3927
|
-
//# debugId=
|
|
3955
|
+
//# debugId=D1C688B1C671E0A464756E2164756E21
|