negotium 0.2.19 → 0.2.20
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 +367 -313
- package/dist/agent-helpers.js.map +17 -17
- package/dist/background-bash.js +3 -2
- package/dist/background-bash.js.map +3 -3
- package/dist/browser-runtime.js +60 -36
- package/dist/browser-runtime.js.map +6 -6
- package/dist/{chunk-fc58cqry.js → chunk-g2kqfdwm.js} +154 -24
- package/dist/{chunk-fc58cqry.js.map → chunk-g2kqfdwm.js.map} +6 -5
- package/dist/hosted-agent.js +183 -53
- package/dist/hosted-agent.js.map +7 -6
- package/dist/main.js +671 -425
- package/dist/main.js.map +23 -23
- package/dist/mcp-factories.js +334 -280
- package/dist/mcp-factories.js.map +17 -17
- package/dist/prompts.js +3 -2
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js +47 -26
- package/dist/query-runtime.js.map +4 -4
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/agents/archiver.ts +3 -2
- package/dist/runtime/src/application/switch-topic-access-mode.ts +81 -8
- package/dist/runtime/src/bus.ts +19 -2
- package/dist/runtime/src/mcp/session-comm/runtime.ts +16 -0
- package/dist/runtime/src/platform/config.ts +13 -1
- package/dist/runtime/src/runtime/ask-callbacks.ts +19 -11
- package/dist/runtime/src/runtime/background-sessions.ts +9 -7
- package/dist/runtime/src/runtime/visual-store.ts +31 -23
- package/dist/runtime/src/storage/api-topics.ts +26 -0
- package/dist/runtime/src/storage/browser-profiles.ts +16 -8
- package/dist/runtime/src/storage/runtime-events.ts +30 -20
- package/dist/runtime/src/storage/runtime-gateway-submissions.ts +24 -16
- package/dist/runtime/src/storage/runtime-turn-requests.ts +9 -1
- package/dist/runtime/src/storage/self-schedules.ts +32 -24
- package/dist/runtime/src/storage/storage-host.ts +105 -43
- package/dist/runtime/src/storage/vault.ts +12 -3
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +47 -26
- package/dist/runtime-helpers.js.map +4 -4
- package/dist/storage.js +76 -41
- package/dist/storage.js.map +4 -4
- package/dist/types/packages/core/src/storage/api-topics.d.ts +15 -0
- package/dist/types/packages/core/src/storage/storage-host.d.ts +10 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +140 -10
- package/dist/vault.js.map +6 -5
- package/package.json +1 -1
package/dist/mcp-factories.js
CHANGED
|
@@ -192,7 +192,7 @@ function browserRsMeetsMinimumVersion(candidate) {
|
|
|
192
192
|
try {
|
|
193
193
|
const output = execFileSync(candidate, ["--version"], {
|
|
194
194
|
encoding: "utf8",
|
|
195
|
-
timeout:
|
|
195
|
+
timeout: BROWSER_RS_VERSION_PROBE_TIMEOUT_MS,
|
|
196
196
|
stdio: ["ignore", "pipe", "ignore"]
|
|
197
197
|
}).trim();
|
|
198
198
|
const match = output.match(/^browser-rs (\d+)\.(\d+)\.(\d+)$/);
|
|
@@ -303,7 +303,7 @@ function resolveDefaultModel(agent, registryDefaultModel) {
|
|
|
303
303
|
function codexAuthFilePath() {
|
|
304
304
|
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
|
|
305
305
|
}
|
|
306
|
-
var HOME, PROJECT_ROOT, STATE_DIR_ENV, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.1.19", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.5", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, BROWSER_MCP_SSE_PROXY_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, _envMaxTellDepth, MAX_TELL_DEPTH;
|
|
306
|
+
var HOME, PROJECT_ROOT, STATE_DIR_ENV, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.1.19", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.5", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, BROWSER_MCP_SSE_PROXY_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, _envMaxTellDepth, MAX_TELL_DEPTH;
|
|
307
307
|
var init_config = __esm(() => {
|
|
308
308
|
init_config_helpers();
|
|
309
309
|
init_logger();
|
|
@@ -1005,7 +1005,7 @@ var init_claude_registry = __esm(() => {
|
|
|
1005
1005
|
});
|
|
1006
1006
|
|
|
1007
1007
|
// ../../packages/core/src/version.ts
|
|
1008
|
-
var NEGOTIUM_VERSION = "0.2.
|
|
1008
|
+
var NEGOTIUM_VERSION = "0.2.20";
|
|
1009
1009
|
|
|
1010
1010
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
1011
1011
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -2241,6 +2241,163 @@ var init_mcp_config = __esm(() => {
|
|
|
2241
2241
|
nodeMcpEntries = [];
|
|
2242
2242
|
});
|
|
2243
2243
|
|
|
2244
|
+
// ../../packages/core/src/storage/storage-host.ts
|
|
2245
|
+
import { mkdirSync as mkdirSync6 } from "fs";
|
|
2246
|
+
import { homedir as homedir4 } from "os";
|
|
2247
|
+
import { dirname as dirname5, join as join6, resolve as resolve5 } from "path";
|
|
2248
|
+
function storageState() {
|
|
2249
|
+
const holder = globalThis;
|
|
2250
|
+
const existing = holder[STORAGE_HOST_STATE];
|
|
2251
|
+
if (existing)
|
|
2252
|
+
return existing;
|
|
2253
|
+
const created = {
|
|
2254
|
+
configuredHost: {},
|
|
2255
|
+
fallbackDatabase: null,
|
|
2256
|
+
fallbackDatabasePath: null,
|
|
2257
|
+
frames: [],
|
|
2258
|
+
schemaInitializers: [],
|
|
2259
|
+
initializedSchemas: new WeakMap,
|
|
2260
|
+
initializingDatabases: new WeakSet
|
|
2261
|
+
};
|
|
2262
|
+
Object.defineProperty(holder, STORAGE_HOST_STATE, {
|
|
2263
|
+
value: created,
|
|
2264
|
+
enumerable: false,
|
|
2265
|
+
writable: false,
|
|
2266
|
+
configurable: false
|
|
2267
|
+
});
|
|
2268
|
+
return created;
|
|
2269
|
+
}
|
|
2270
|
+
function envPath(name, fallback) {
|
|
2271
|
+
const value2 = process.env[name]?.trim();
|
|
2272
|
+
return resolve5(value2 || fallback);
|
|
2273
|
+
}
|
|
2274
|
+
function defaultStateDir() {
|
|
2275
|
+
return envPath("NEGOTIUM_STATE_DIR", join6(homedir4(), ".negotium"));
|
|
2276
|
+
}
|
|
2277
|
+
function defaultDataDir() {
|
|
2278
|
+
return envPath("NEGOTIUM_DATA_DIR", join6(defaultStateDir(), "data"));
|
|
2279
|
+
}
|
|
2280
|
+
function defaultLogDir() {
|
|
2281
|
+
return envPath("NEGOTIUM_LOG_DIR", join6(defaultStateDir(), "logs"));
|
|
2282
|
+
}
|
|
2283
|
+
function defaultWorkspaceDir() {
|
|
2284
|
+
return envPath("NEGOTIUM_WORKSPACE_DIR", join6(defaultStateDir(), "workspace"));
|
|
2285
|
+
}
|
|
2286
|
+
function defaultSessionAsksDir() {
|
|
2287
|
+
const runDir = envPath("NEGOTIUM_RUN_DIR", join6(defaultStateDir(), "runtime"));
|
|
2288
|
+
return join6(runDir, "session-asks");
|
|
2289
|
+
}
|
|
2290
|
+
function defaultSessionsDatabasePath() {
|
|
2291
|
+
return envPath("SESSIONS_DB_PATH", join6(resolveStorageDataDir(), "sessions.db"));
|
|
2292
|
+
}
|
|
2293
|
+
function isSqliteBusy(error) {
|
|
2294
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2295
|
+
return /database is (?:locked|busy)|SQLITE_(?:BUSY|LOCKED)/i.test(message);
|
|
2296
|
+
}
|
|
2297
|
+
function execWithBusyRetry(database, sql, timeoutMs = SQLITE_INIT_TIMEOUT_MS) {
|
|
2298
|
+
const deadline = Date.now() + timeoutMs;
|
|
2299
|
+
while (true) {
|
|
2300
|
+
try {
|
|
2301
|
+
database.exec(sql);
|
|
2302
|
+
return;
|
|
2303
|
+
} catch (error) {
|
|
2304
|
+
if (!isSqliteBusy(error) || Date.now() >= deadline)
|
|
2305
|
+
throw error;
|
|
2306
|
+
Atomics.wait(SQLITE_INIT_SLEEP, 0, 0, Math.min(SQLITE_INIT_RETRY_MS, deadline - Date.now()));
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
function initializeDatabase(database) {
|
|
2311
|
+
database.exec("PRAGMA busy_timeout = 5000");
|
|
2312
|
+
execWithBusyRetry(database, "PRAGMA journal_mode = WAL");
|
|
2313
|
+
database.exec("PRAGMA foreign_keys = ON");
|
|
2314
|
+
database.exec("PRAGMA wal_autocheckpoint = 1000");
|
|
2315
|
+
try {
|
|
2316
|
+
database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
2317
|
+
} catch {}
|
|
2318
|
+
}
|
|
2319
|
+
function defaultDatabase() {
|
|
2320
|
+
const path = defaultSessionsDatabasePath();
|
|
2321
|
+
const state = storageState();
|
|
2322
|
+
if (state.fallbackDatabase && state.fallbackDatabasePath === path)
|
|
2323
|
+
return state.fallbackDatabase;
|
|
2324
|
+
if (state.fallbackDatabase)
|
|
2325
|
+
state.fallbackDatabase.close();
|
|
2326
|
+
mkdirSync6(dirname5(path), { recursive: true });
|
|
2327
|
+
state.fallbackDatabase = new Database(path, { create: true });
|
|
2328
|
+
state.fallbackDatabasePath = path;
|
|
2329
|
+
initializeDatabase(state.fallbackDatabase);
|
|
2330
|
+
return state.fallbackDatabase;
|
|
2331
|
+
}
|
|
2332
|
+
function resolveStorageDatabase() {
|
|
2333
|
+
return storageState().configuredHost.database ?? defaultDatabase();
|
|
2334
|
+
}
|
|
2335
|
+
function resolveStorageDataDir() {
|
|
2336
|
+
return storageState().configuredHost.dataDir ?? defaultDataDir();
|
|
2337
|
+
}
|
|
2338
|
+
function resolveStorageLogDir() {
|
|
2339
|
+
return storageState().configuredHost.logDir ?? defaultLogDir();
|
|
2340
|
+
}
|
|
2341
|
+
function resolveStorageSessionAsksDir() {
|
|
2342
|
+
return storageState().configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
|
|
2343
|
+
}
|
|
2344
|
+
function resolveStorageWorkspaceDir() {
|
|
2345
|
+
return storageState().configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
2346
|
+
}
|
|
2347
|
+
function resolveStorageSharedWikiDir() {
|
|
2348
|
+
return storageState().configuredHost.sharedWikiDir ?? join6(resolveStorageWorkspaceDir(), "wiki");
|
|
2349
|
+
}
|
|
2350
|
+
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
2351
|
+
const initializers = storageState().schemaInitializers;
|
|
2352
|
+
initializers.push({ initialize, priority });
|
|
2353
|
+
initializers.sort((a, b) => a.priority - b.priority);
|
|
2354
|
+
}
|
|
2355
|
+
function ensureStorageSchemas(database = resolveStorageDatabase()) {
|
|
2356
|
+
const state = storageState();
|
|
2357
|
+
if (state.initializingDatabases.has(database))
|
|
2358
|
+
return;
|
|
2359
|
+
let initialized = state.initializedSchemas.get(database);
|
|
2360
|
+
if (!initialized) {
|
|
2361
|
+
initialized = new Set;
|
|
2362
|
+
state.initializedSchemas.set(database, initialized);
|
|
2363
|
+
}
|
|
2364
|
+
state.initializingDatabases.add(database);
|
|
2365
|
+
try {
|
|
2366
|
+
for (const entry of state.schemaInitializers) {
|
|
2367
|
+
if (initialized.has(entry.initialize))
|
|
2368
|
+
continue;
|
|
2369
|
+
initialized.add(entry.initialize);
|
|
2370
|
+
try {
|
|
2371
|
+
entry.initialize(database);
|
|
2372
|
+
} catch (error) {
|
|
2373
|
+
initialized.delete(entry.initialize);
|
|
2374
|
+
throw error;
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
} finally {
|
|
2378
|
+
state.initializingDatabases.delete(database);
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
var STORAGE_HOST_STATE, SQLITE_INIT_RETRY_MS = 25, SQLITE_INIT_TIMEOUT_MS = 5000, SQLITE_INIT_SLEEP, internalStorageDatabase;
|
|
2382
|
+
var init_storage_host = __esm(async () => {
|
|
2383
|
+
await init_sqlite();
|
|
2384
|
+
STORAGE_HOST_STATE = Symbol.for("negotium.storage-host.state.v1");
|
|
2385
|
+
SQLITE_INIT_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
2386
|
+
internalStorageDatabase = new Proxy({}, {
|
|
2387
|
+
get(_target, property) {
|
|
2388
|
+
const database = resolveStorageDatabase();
|
|
2389
|
+
ensureStorageSchemas(database);
|
|
2390
|
+
const value2 = Reflect.get(database, property, database);
|
|
2391
|
+
return typeof value2 === "function" ? value2.bind(database) : value2;
|
|
2392
|
+
},
|
|
2393
|
+
set(_target, property, value2) {
|
|
2394
|
+
const database = resolveStorageDatabase();
|
|
2395
|
+
ensureStorageSchemas(database);
|
|
2396
|
+
return Reflect.set(database, property, value2, database);
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2399
|
+
});
|
|
2400
|
+
|
|
2244
2401
|
// ../../packages/core/src/storage/vault-crypto-core.ts
|
|
2245
2402
|
import { createCipheriv, createDecipheriv, createHash as createHash2, randomBytes as randomBytes3 } from "crypto";
|
|
2246
2403
|
function encryptionKey(masterKey) {
|
|
@@ -2297,8 +2454,8 @@ var init_vault_crypto = __esm(() => {
|
|
|
2297
2454
|
});
|
|
2298
2455
|
|
|
2299
2456
|
// ../../packages/core/src/storage/vault.ts
|
|
2300
|
-
import { chmodSync as chmodSync4, mkdirSync as
|
|
2301
|
-
import { join as
|
|
2457
|
+
import { chmodSync as chmodSync4, mkdirSync as mkdirSync7 } from "fs";
|
|
2458
|
+
import { join as join7 } from "path";
|
|
2302
2459
|
function initializeVaultDatabase(database) {
|
|
2303
2460
|
database.exec("PRAGMA journal_mode = WAL");
|
|
2304
2461
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -2333,17 +2490,18 @@ function initializeVaultDatabase(database) {
|
|
|
2333
2490
|
}
|
|
2334
2491
|
}
|
|
2335
2492
|
function openVaultDatabase(dataDir) {
|
|
2336
|
-
const vaultDir =
|
|
2337
|
-
const path =
|
|
2338
|
-
|
|
2493
|
+
const vaultDir = join7(dataDir, "vault");
|
|
2494
|
+
const path = join7(vaultDir, "vault.db");
|
|
2495
|
+
mkdirSync7(vaultDir, { recursive: true, mode: 448 });
|
|
2339
2496
|
const database = new Database(path, { create: true });
|
|
2340
2497
|
chmodSync4(path, 384);
|
|
2341
2498
|
initializeVaultDatabase(database);
|
|
2342
2499
|
return database;
|
|
2343
2500
|
}
|
|
2344
2501
|
function activeVaultDatabase() {
|
|
2345
|
-
if (!vaultDb)
|
|
2346
|
-
vaultDb = openVaultDatabase(
|
|
2502
|
+
if (!vaultDb) {
|
|
2503
|
+
vaultDb = openVaultDatabase(resolveStorageDataDir());
|
|
2504
|
+
}
|
|
2347
2505
|
return vaultDb;
|
|
2348
2506
|
}
|
|
2349
2507
|
function normalizeVaultKey(key) {
|
|
@@ -2433,14 +2591,17 @@ var vaultDb, vaultMasterKey, VAULT_VALUE_MAX_BYTES;
|
|
|
2433
2591
|
var init_vault = __esm(async () => {
|
|
2434
2592
|
init_config();
|
|
2435
2593
|
init_vault_crypto();
|
|
2436
|
-
await
|
|
2594
|
+
await __promiseAll([
|
|
2595
|
+
init_sqlite(),
|
|
2596
|
+
init_storage_host()
|
|
2597
|
+
]);
|
|
2437
2598
|
vaultMasterKey = VAULT_MASTER_KEY;
|
|
2438
2599
|
VAULT_VALUE_MAX_BYTES = 64 * 1024;
|
|
2439
2600
|
});
|
|
2440
2601
|
|
|
2441
2602
|
// ../../packages/core/src/agents/execution-host.ts
|
|
2442
2603
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
2443
|
-
import { dirname as
|
|
2604
|
+
import { dirname as dirname6 } from "path";
|
|
2444
2605
|
function activeHost() {
|
|
2445
2606
|
const scoped = scopedHost.getStore();
|
|
2446
2607
|
if (scoped)
|
|
@@ -2475,7 +2636,7 @@ function hostedCodexAuthFilePath() {
|
|
|
2475
2636
|
return activeHost().codexAuthFilePath();
|
|
2476
2637
|
}
|
|
2477
2638
|
function hostedCodexHomePath() {
|
|
2478
|
-
return
|
|
2639
|
+
return dirname6(hostedCodexAuthFilePath());
|
|
2479
2640
|
}
|
|
2480
2641
|
var defaultHost, hostRegistrations, scopedHost;
|
|
2481
2642
|
var init_execution_host = __esm(async () => {
|
|
@@ -2499,14 +2660,14 @@ var init_execution_host = __esm(async () => {
|
|
|
2499
2660
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
2500
2661
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
2501
2662
|
import { existsSync as existsSync7, readFileSync as readFileSync7, realpathSync as realpathSync2, statSync as statSync3, unlinkSync as unlinkSync7 } from "fs";
|
|
2502
|
-
import { basename as basename2, dirname as
|
|
2663
|
+
import { basename as basename2, dirname as dirname7, join as join8, resolve as resolve6 } from "path";
|
|
2503
2664
|
function codexSessionsDir() {
|
|
2504
|
-
return
|
|
2665
|
+
return join8(hostedCodexHomePath(), "sessions");
|
|
2505
2666
|
}
|
|
2506
2667
|
function loadCodexShell() {
|
|
2507
2668
|
if (_shellCache)
|
|
2508
2669
|
return _shellCache;
|
|
2509
|
-
const raw = readFileSync7(
|
|
2670
|
+
const raw = readFileSync7(join8(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
2510
2671
|
const lines = parseJsonlText(raw);
|
|
2511
2672
|
if (lines.length < 5) {
|
|
2512
2673
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -2573,16 +2734,16 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
2573
2734
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
2574
2735
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
2575
2736
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
2576
|
-
const dir =
|
|
2577
|
-
return
|
|
2737
|
+
const dir = join8(codexSessionsDir(), yyyy, mm, dd);
|
|
2738
|
+
return join8(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
2578
2739
|
}
|
|
2579
2740
|
function canonicalFilePath(path) {
|
|
2580
|
-
const absolute =
|
|
2741
|
+
const absolute = resolve6(path);
|
|
2581
2742
|
try {
|
|
2582
2743
|
return realpathSync2(absolute);
|
|
2583
2744
|
} catch {
|
|
2584
2745
|
try {
|
|
2585
|
-
return
|
|
2746
|
+
return join8(realpathSync2(dirname7(absolute)), basename2(absolute));
|
|
2586
2747
|
} catch {
|
|
2587
2748
|
return absolute;
|
|
2588
2749
|
}
|
|
@@ -2812,19 +2973,19 @@ function latestCodexRolloutPath(threadId) {
|
|
|
2812
2973
|
try {
|
|
2813
2974
|
if (buckets) {
|
|
2814
2975
|
for (const bucket of buckets) {
|
|
2815
|
-
const dir =
|
|
2976
|
+
const dir = join8(sessionsDir, bucket);
|
|
2816
2977
|
if (!existsSync7(dir))
|
|
2817
2978
|
continue;
|
|
2818
2979
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
2819
2980
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
2820
|
-
candidates.push(
|
|
2981
|
+
candidates.push(join8(dir, rel));
|
|
2821
2982
|
}
|
|
2822
2983
|
}
|
|
2823
2984
|
}
|
|
2824
2985
|
if (candidates.length === 0) {
|
|
2825
2986
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
2826
2987
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
2827
|
-
candidates.push(
|
|
2988
|
+
candidates.push(join8(sessionsDir, rel));
|
|
2828
2989
|
}
|
|
2829
2990
|
}
|
|
2830
2991
|
return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
|
|
@@ -2945,13 +3106,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
2945
3106
|
return;
|
|
2946
3107
|
}
|
|
2947
3108
|
for (const bucket of buckets) {
|
|
2948
|
-
const dir =
|
|
3109
|
+
const dir = join8(sessionsDir, bucket);
|
|
2949
3110
|
if (!existsSync7(dir))
|
|
2950
3111
|
continue;
|
|
2951
3112
|
try {
|
|
2952
3113
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
2953
3114
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
2954
|
-
const fullPath =
|
|
3115
|
+
const fullPath = join8(dir, rel);
|
|
2955
3116
|
try {
|
|
2956
3117
|
unlinkSync7(fullPath);
|
|
2957
3118
|
} catch (e) {
|
|
@@ -2969,7 +3130,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
2969
3130
|
try {
|
|
2970
3131
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
2971
3132
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
2972
|
-
const fullPath =
|
|
3133
|
+
const fullPath = join8(sessionsDir, rel);
|
|
2973
3134
|
try {
|
|
2974
3135
|
unlinkSync7(fullPath);
|
|
2975
3136
|
} catch (e) {
|
|
@@ -3035,7 +3196,7 @@ import { spawn as spawn4 } from "child_process";
|
|
|
3035
3196
|
function createCodexAppServerForker(host) {
|
|
3036
3197
|
return async (parentThreadId) => {
|
|
3037
3198
|
const child = host.spawnServer();
|
|
3038
|
-
return await new Promise((
|
|
3199
|
+
return await new Promise((resolve7, reject) => {
|
|
3039
3200
|
let settled = false;
|
|
3040
3201
|
let stdoutBuffer = "";
|
|
3041
3202
|
let stderr = "";
|
|
@@ -3052,7 +3213,7 @@ function createCodexAppServerForker(host) {
|
|
|
3052
3213
|
if (error)
|
|
3053
3214
|
reject(error);
|
|
3054
3215
|
else if (result)
|
|
3055
|
-
|
|
3216
|
+
resolve7(result);
|
|
3056
3217
|
else
|
|
3057
3218
|
reject(new Error("Codex thread fork returned no result"));
|
|
3058
3219
|
};
|
|
@@ -3149,7 +3310,7 @@ var init_codex_app_server = __esm(async () => {
|
|
|
3149
3310
|
|
|
3150
3311
|
// ../../packages/core/src/agents/codex-registry.ts
|
|
3151
3312
|
import { existsSync as existsSync8, unlinkSync as unlinkSync8 } from "fs";
|
|
3152
|
-
import { join as
|
|
3313
|
+
import { join as join9 } from "path";
|
|
3153
3314
|
var VALID_EFFORTS2, codexRegistry, codexRegistryOperations;
|
|
3154
3315
|
var init_codex_registry = __esm(async () => {
|
|
3155
3316
|
init_logger();
|
|
@@ -3194,7 +3355,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3194
3355
|
async cleanupRollouts({ sessionIds }) {
|
|
3195
3356
|
if (sessionIds.length === 0)
|
|
3196
3357
|
return;
|
|
3197
|
-
const sessionsDir =
|
|
3358
|
+
const sessionsDir = join9(hostedCodexHomePath(), "sessions");
|
|
3198
3359
|
if (!existsSync8(sessionsDir))
|
|
3199
3360
|
return;
|
|
3200
3361
|
const failures = [];
|
|
@@ -3202,7 +3363,7 @@ var init_codex_registry = __esm(async () => {
|
|
|
3202
3363
|
try {
|
|
3203
3364
|
const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);
|
|
3204
3365
|
for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3205
|
-
const path =
|
|
3366
|
+
const path = join9(sessionsDir, rel);
|
|
3206
3367
|
try {
|
|
3207
3368
|
unlinkSync8(path);
|
|
3208
3369
|
} catch (e) {
|
|
@@ -3226,17 +3387,17 @@ var init_codex_registry = __esm(async () => {
|
|
|
3226
3387
|
|
|
3227
3388
|
// ../../packages/core/src/agents/maestro-registry.ts
|
|
3228
3389
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
3229
|
-
import { existsSync as existsSync9, mkdirSync as
|
|
3230
|
-
import { homedir as
|
|
3231
|
-
import { join as
|
|
3390
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
3391
|
+
import { homedir as homedir5 } from "os";
|
|
3392
|
+
import { join as join10, resolve as resolve7 } from "path";
|
|
3232
3393
|
function maestroSessionsDir() {
|
|
3233
|
-
return
|
|
3394
|
+
return join10(process.env.MAESTRO_DATA_DIR ? resolve7(process.env.MAESTRO_DATA_DIR) : join10(homedir5(), ".maestro"), "sessions");
|
|
3234
3395
|
}
|
|
3235
3396
|
function maestroSessionPath(sessionId) {
|
|
3236
|
-
return
|
|
3397
|
+
return join10(maestroSessionsDir(), `${sessionId}.jsonl`);
|
|
3237
3398
|
}
|
|
3238
3399
|
function maestroActiveSessionPath(sessionId) {
|
|
3239
|
-
return
|
|
3400
|
+
return join10(maestroSessionsDir(), `${sessionId}.active.jsonl`);
|
|
3240
3401
|
}
|
|
3241
3402
|
function existingCreatedAt(path) {
|
|
3242
3403
|
if (!existsSync9(path))
|
|
@@ -3258,7 +3419,7 @@ function writeRollout(options) {
|
|
|
3258
3419
|
assertUuidLike("sessionId", sessionId);
|
|
3259
3420
|
ensureCwdExists(options.cwd);
|
|
3260
3421
|
const path = maestroSessionPath(sessionId);
|
|
3261
|
-
|
|
3422
|
+
mkdirSync8(maestroSessionsDir(), { recursive: true });
|
|
3262
3423
|
const messages = extractChatPairs(options.entries).flatMap((pair) => [
|
|
3263
3424
|
{ role: "user", content: nonEmptyTurnText(pair.userText) },
|
|
3264
3425
|
{ role: "assistant", content: nonEmptyTurnText(pair.assistantText) }
|
|
@@ -3394,141 +3555,6 @@ var init_common = __esm(() => {
|
|
|
3394
3555
|
init_mcp_helpers();
|
|
3395
3556
|
});
|
|
3396
3557
|
|
|
3397
|
-
// ../../packages/core/src/storage/storage-host.ts
|
|
3398
|
-
import { mkdirSync as mkdirSync8 } from "fs";
|
|
3399
|
-
import { homedir as homedir5 } from "os";
|
|
3400
|
-
import { dirname as dirname7, join as join11, resolve as resolve7 } from "path";
|
|
3401
|
-
function envPath(name, fallback) {
|
|
3402
|
-
const value2 = process.env[name]?.trim();
|
|
3403
|
-
return resolve7(value2 || fallback);
|
|
3404
|
-
}
|
|
3405
|
-
function defaultStateDir() {
|
|
3406
|
-
return envPath("NEGOTIUM_STATE_DIR", join11(homedir5(), ".negotium"));
|
|
3407
|
-
}
|
|
3408
|
-
function defaultDataDir() {
|
|
3409
|
-
return envPath("NEGOTIUM_DATA_DIR", join11(defaultStateDir(), "data"));
|
|
3410
|
-
}
|
|
3411
|
-
function defaultLogDir() {
|
|
3412
|
-
return envPath("NEGOTIUM_LOG_DIR", join11(defaultStateDir(), "logs"));
|
|
3413
|
-
}
|
|
3414
|
-
function defaultWorkspaceDir() {
|
|
3415
|
-
return envPath("NEGOTIUM_WORKSPACE_DIR", join11(defaultStateDir(), "workspace"));
|
|
3416
|
-
}
|
|
3417
|
-
function defaultSessionAsksDir() {
|
|
3418
|
-
const runDir = envPath("NEGOTIUM_RUN_DIR", join11(defaultStateDir(), "runtime"));
|
|
3419
|
-
return join11(runDir, "session-asks");
|
|
3420
|
-
}
|
|
3421
|
-
function defaultSessionsDatabasePath() {
|
|
3422
|
-
return envPath("SESSIONS_DB_PATH", join11(resolveStorageDataDir(), "sessions.db"));
|
|
3423
|
-
}
|
|
3424
|
-
function isSqliteBusy(error) {
|
|
3425
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3426
|
-
return /database is (?:locked|busy)|SQLITE_(?:BUSY|LOCKED)/i.test(message);
|
|
3427
|
-
}
|
|
3428
|
-
function execWithBusyRetry(database, sql, timeoutMs = SQLITE_INIT_TIMEOUT_MS) {
|
|
3429
|
-
const deadline = Date.now() + timeoutMs;
|
|
3430
|
-
while (true) {
|
|
3431
|
-
try {
|
|
3432
|
-
database.exec(sql);
|
|
3433
|
-
return;
|
|
3434
|
-
} catch (error) {
|
|
3435
|
-
if (!isSqliteBusy(error) || Date.now() >= deadline)
|
|
3436
|
-
throw error;
|
|
3437
|
-
Atomics.wait(SQLITE_INIT_SLEEP, 0, 0, Math.min(SQLITE_INIT_RETRY_MS, deadline - Date.now()));
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
function initializeDatabase(database) {
|
|
3442
|
-
database.exec("PRAGMA busy_timeout = 5000");
|
|
3443
|
-
execWithBusyRetry(database, "PRAGMA journal_mode = WAL");
|
|
3444
|
-
database.exec("PRAGMA foreign_keys = ON");
|
|
3445
|
-
database.exec("PRAGMA wal_autocheckpoint = 1000");
|
|
3446
|
-
try {
|
|
3447
|
-
database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
3448
|
-
} catch {}
|
|
3449
|
-
}
|
|
3450
|
-
function defaultDatabase() {
|
|
3451
|
-
const path = defaultSessionsDatabasePath();
|
|
3452
|
-
if (fallbackDatabase && fallbackDatabasePath === path)
|
|
3453
|
-
return fallbackDatabase;
|
|
3454
|
-
if (fallbackDatabase)
|
|
3455
|
-
fallbackDatabase.close();
|
|
3456
|
-
mkdirSync8(dirname7(path), { recursive: true });
|
|
3457
|
-
fallbackDatabase = new Database(path, { create: true });
|
|
3458
|
-
fallbackDatabasePath = path;
|
|
3459
|
-
initializeDatabase(fallbackDatabase);
|
|
3460
|
-
return fallbackDatabase;
|
|
3461
|
-
}
|
|
3462
|
-
function resolveStorageDatabase() {
|
|
3463
|
-
return configuredHost.database ?? defaultDatabase();
|
|
3464
|
-
}
|
|
3465
|
-
function resolveStorageDataDir() {
|
|
3466
|
-
return configuredHost.dataDir ?? defaultDataDir();
|
|
3467
|
-
}
|
|
3468
|
-
function resolveStorageLogDir() {
|
|
3469
|
-
return configuredHost.logDir ?? defaultLogDir();
|
|
3470
|
-
}
|
|
3471
|
-
function resolveStorageSessionAsksDir() {
|
|
3472
|
-
return configuredHost.sessionAsksDir ?? defaultSessionAsksDir();
|
|
3473
|
-
}
|
|
3474
|
-
function resolveStorageWorkspaceDir() {
|
|
3475
|
-
return configuredHost.workspaceDir ?? defaultWorkspaceDir();
|
|
3476
|
-
}
|
|
3477
|
-
function resolveStorageSharedWikiDir() {
|
|
3478
|
-
return configuredHost.sharedWikiDir ?? join11(resolveStorageWorkspaceDir(), "wiki");
|
|
3479
|
-
}
|
|
3480
|
-
function registerStorageSchemaInitializer(initialize, priority = 100) {
|
|
3481
|
-
schemaInitializers.push({ initialize, priority });
|
|
3482
|
-
schemaInitializers.sort((a, b) => a.priority - b.priority);
|
|
3483
|
-
}
|
|
3484
|
-
function ensureStorageSchemas(database = resolveStorageDatabase()) {
|
|
3485
|
-
if (initializingDatabases.has(database))
|
|
3486
|
-
return;
|
|
3487
|
-
let initialized = initializedSchemas.get(database);
|
|
3488
|
-
if (!initialized) {
|
|
3489
|
-
initialized = new Set;
|
|
3490
|
-
initializedSchemas.set(database, initialized);
|
|
3491
|
-
}
|
|
3492
|
-
initializingDatabases.add(database);
|
|
3493
|
-
try {
|
|
3494
|
-
for (const entry of schemaInitializers) {
|
|
3495
|
-
if (initialized.has(entry.initialize))
|
|
3496
|
-
continue;
|
|
3497
|
-
initialized.add(entry.initialize);
|
|
3498
|
-
try {
|
|
3499
|
-
entry.initialize(database);
|
|
3500
|
-
} catch (error) {
|
|
3501
|
-
initialized.delete(entry.initialize);
|
|
3502
|
-
throw error;
|
|
3503
|
-
}
|
|
3504
|
-
}
|
|
3505
|
-
} finally {
|
|
3506
|
-
initializingDatabases.delete(database);
|
|
3507
|
-
}
|
|
3508
|
-
}
|
|
3509
|
-
var configuredHost, fallbackDatabase = null, fallbackDatabasePath = null, schemaInitializers, initializedSchemas, initializingDatabases, SQLITE_INIT_RETRY_MS = 25, SQLITE_INIT_TIMEOUT_MS = 5000, SQLITE_INIT_SLEEP, internalStorageDatabase;
|
|
3510
|
-
var init_storage_host = __esm(async () => {
|
|
3511
|
-
await init_sqlite();
|
|
3512
|
-
configuredHost = {};
|
|
3513
|
-
schemaInitializers = [];
|
|
3514
|
-
initializedSchemas = new WeakMap;
|
|
3515
|
-
initializingDatabases = new WeakSet;
|
|
3516
|
-
SQLITE_INIT_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
3517
|
-
internalStorageDatabase = new Proxy({}, {
|
|
3518
|
-
get(_target, property) {
|
|
3519
|
-
const database = resolveStorageDatabase();
|
|
3520
|
-
ensureStorageSchemas(database);
|
|
3521
|
-
const value2 = Reflect.get(database, property, database);
|
|
3522
|
-
return typeof value2 === "function" ? value2.bind(database) : value2;
|
|
3523
|
-
},
|
|
3524
|
-
set(_target, property, value2) {
|
|
3525
|
-
const database = resolveStorageDatabase();
|
|
3526
|
-
ensureStorageSchemas(database);
|
|
3527
|
-
return Reflect.set(database, property, value2, database);
|
|
3528
|
-
}
|
|
3529
|
-
});
|
|
3530
|
-
});
|
|
3531
|
-
|
|
3532
3558
|
// ../../packages/core/src/storage/forum-db.ts
|
|
3533
3559
|
var db;
|
|
3534
3560
|
var init_forum_db = __esm(async () => {
|
|
@@ -3575,7 +3601,10 @@ function listRuntimeEventsAfter(seq, limit = 500) {
|
|
|
3575
3601
|
}
|
|
3576
3602
|
var RUNTIME_EVENT_TYPES, types;
|
|
3577
3603
|
var init_runtime_events = __esm(async () => {
|
|
3578
|
-
await
|
|
3604
|
+
await __promiseAll([
|
|
3605
|
+
init_forum_db(),
|
|
3606
|
+
init_storage_host()
|
|
3607
|
+
]);
|
|
3579
3608
|
RUNTIME_EVENT_TYPES = [
|
|
3580
3609
|
"message",
|
|
3581
3610
|
"message-updated",
|
|
@@ -3584,26 +3613,28 @@ var init_runtime_events = __esm(async () => {
|
|
|
3584
3613
|
"topic-updated",
|
|
3585
3614
|
"topic-deleted"
|
|
3586
3615
|
];
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
event_type
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3616
|
+
registerStorageSchemaInitializer((database) => {
|
|
3617
|
+
database.exec(`
|
|
3618
|
+
CREATE TABLE IF NOT EXISTS runtime_events (
|
|
3619
|
+
seq INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
3620
|
+
source_id TEXT NOT NULL,
|
|
3621
|
+
event_type TEXT NOT NULL CHECK (
|
|
3622
|
+
event_type IN (
|
|
3623
|
+
'message',
|
|
3624
|
+
'message-updated',
|
|
3625
|
+
'ai-status',
|
|
3626
|
+
'topic-created',
|
|
3627
|
+
'topic-updated',
|
|
3628
|
+
'topic-deleted'
|
|
3629
|
+
)
|
|
3630
|
+
),
|
|
3631
|
+
topic_id TEXT NOT NULL,
|
|
3632
|
+
payload_json TEXT NOT NULL,
|
|
3633
|
+
created_at TEXT NOT NULL
|
|
3634
|
+
)
|
|
3635
|
+
`);
|
|
3636
|
+
database.exec("CREATE INDEX IF NOT EXISTS idx_runtime_events_topic_seq ON runtime_events(topic_id, seq)");
|
|
3637
|
+
});
|
|
3607
3638
|
types = new Set(RUNTIME_EVENT_TYPES);
|
|
3608
3639
|
});
|
|
3609
3640
|
|
|
@@ -3763,13 +3794,17 @@ class SqliteRuntimeBus {
|
|
|
3763
3794
|
};
|
|
3764
3795
|
}
|
|
3765
3796
|
}
|
|
3766
|
-
|
|
3797
|
+
function runtimeBus() {
|
|
3798
|
+
if (!current)
|
|
3799
|
+
current = new SqliteRuntimeBus;
|
|
3800
|
+
return current;
|
|
3801
|
+
}
|
|
3802
|
+
var current = null, WsHub;
|
|
3767
3803
|
var init_bus = __esm(async () => {
|
|
3768
3804
|
await init_runtime_events();
|
|
3769
|
-
current = new SqliteRuntimeBus;
|
|
3770
3805
|
WsHub = {
|
|
3771
3806
|
get() {
|
|
3772
|
-
return
|
|
3807
|
+
return runtimeBus();
|
|
3773
3808
|
}
|
|
3774
3809
|
};
|
|
3775
3810
|
});
|
|
@@ -5068,10 +5103,11 @@ var init_runtime_turn_requests = __esm(async () => {
|
|
|
5068
5103
|
await __promiseAll([
|
|
5069
5104
|
init_forum_db(),
|
|
5070
5105
|
init_runtime_leases(),
|
|
5071
|
-
init_runtime_topic_state()
|
|
5106
|
+
init_runtime_topic_state(),
|
|
5107
|
+
init_storage_host()
|
|
5072
5108
|
]);
|
|
5073
5109
|
REQUEST_CLAIM_STALE_MS = TURN_LEASE_STALE_MS;
|
|
5074
|
-
ensureRuntimeUserTurnRequestsSchema(
|
|
5110
|
+
registerStorageSchemaInitializer((database) => ensureRuntimeUserTurnRequestsSchema(database));
|
|
5075
5111
|
});
|
|
5076
5112
|
|
|
5077
5113
|
// ../../packages/core/src/agents/registry.ts
|
|
@@ -6099,15 +6135,20 @@ function assignTopicBrowserProfile(opts) {
|
|
|
6099
6135
|
}
|
|
6100
6136
|
var DEFAULT_BROWSER_PROFILE = "default";
|
|
6101
6137
|
var init_browser_profiles = __esm(async () => {
|
|
6102
|
-
await
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6138
|
+
await __promiseAll([
|
|
6139
|
+
init_forum_db(),
|
|
6140
|
+
init_storage_host()
|
|
6141
|
+
]);
|
|
6142
|
+
registerStorageSchemaInitializer((database) => {
|
|
6143
|
+
database.exec(`
|
|
6144
|
+
CREATE TABLE IF NOT EXISTS browser_profiles (
|
|
6145
|
+
owner_id TEXT NOT NULL,
|
|
6146
|
+
name TEXT NOT NULL,
|
|
6147
|
+
created_at TEXT NOT NULL,
|
|
6148
|
+
PRIMARY KEY (owner_id, name)
|
|
6149
|
+
)
|
|
6150
|
+
`);
|
|
6151
|
+
});
|
|
6111
6152
|
});
|
|
6112
6153
|
|
|
6113
6154
|
// ../../packages/core/src/platform/playwright/manager.ts
|
|
@@ -10440,9 +10481,9 @@ function formatArchiverBytes(bytes) {
|
|
|
10440
10481
|
function formatArchiverTool(name, input) {
|
|
10441
10482
|
const params = Object.entries(input).map(([key, value2]) => {
|
|
10442
10483
|
const rendered = typeof value2 === "string" ? value2 : JSON.stringify(value2);
|
|
10443
|
-
return `${key}: ${sessionText(rendered ?? "")}`;
|
|
10484
|
+
return `${key}: ${summarizeDisplayText(sessionText(rendered ?? ""))}`;
|
|
10444
10485
|
}).join(", ");
|
|
10445
|
-
return `${name}${params ? `(${params})` : ""}
|
|
10486
|
+
return summarizeDisplayText(`${name}${params ? `(${params})` : ""}`);
|
|
10446
10487
|
}
|
|
10447
10488
|
function createArchiverRuntime(host) {
|
|
10448
10489
|
const activeSessions = new Map;
|
|
@@ -10749,6 +10790,7 @@ function runArchiverTurn(params) {
|
|
|
10749
10790
|
}
|
|
10750
10791
|
var MAX_BRIEF_ENTRIES = 8, defaultArchiverRuntime;
|
|
10751
10792
|
var init_archiver = __esm(async () => {
|
|
10793
|
+
init_tool_format();
|
|
10752
10794
|
init_config();
|
|
10753
10795
|
init_logger();
|
|
10754
10796
|
init_builders();
|
|
@@ -11510,6 +11552,7 @@ function text(value2, maxLen) {
|
|
|
11510
11552
|
}
|
|
11511
11553
|
var providers, transientSessions;
|
|
11512
11554
|
var init_background_sessions = __esm(async () => {
|
|
11555
|
+
init_tool_format();
|
|
11513
11556
|
init_background_session_policy();
|
|
11514
11557
|
await __promiseAll([
|
|
11515
11558
|
init_archiver(),
|
|
@@ -12947,19 +12990,22 @@ var pendingAsks, MAX_ASK_AGE_MS;
|
|
|
12947
12990
|
var init_ask_callbacks = __esm(async () => {
|
|
12948
12991
|
await __promiseAll([
|
|
12949
12992
|
init_forum_db(),
|
|
12950
|
-
init_session_asks()
|
|
12993
|
+
init_session_asks(),
|
|
12994
|
+
init_storage_host()
|
|
12951
12995
|
]);
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12996
|
+
registerStorageSchemaInitializer((database) => {
|
|
12997
|
+
database.exec(`
|
|
12998
|
+
CREATE TABLE IF NOT EXISTS remote_ask_callbacks (
|
|
12999
|
+
target_query_id TEXT PRIMARY KEY,
|
|
13000
|
+
request_id TEXT NOT NULL,
|
|
13001
|
+
node_name TEXT NOT NULL,
|
|
13002
|
+
node_cell_id TEXT NOT NULL,
|
|
13003
|
+
topic_id TEXT NOT NULL,
|
|
13004
|
+
user_id TEXT NOT NULL,
|
|
13005
|
+
created_at INTEGER NOT NULL
|
|
13006
|
+
)
|
|
13007
|
+
`);
|
|
13008
|
+
});
|
|
12963
13009
|
pendingAsks = new Map;
|
|
12964
13010
|
MAX_ASK_AGE_MS = PENDING_ASK_TTL_MS;
|
|
12965
13011
|
});
|
|
@@ -13172,30 +13218,35 @@ paint();document.body.appendChild(b)}
|
|
|
13172
13218
|
if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",init);else init()})();
|
|
13173
13219
|
</script>`;
|
|
13174
13220
|
var init_visual_store = __esm(async () => {
|
|
13175
|
-
await
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13221
|
+
await __promiseAll([
|
|
13222
|
+
init_forum_db(),
|
|
13223
|
+
init_storage_host()
|
|
13224
|
+
]);
|
|
13225
|
+
registerStorageSchemaInitializer((database) => {
|
|
13226
|
+
database.exec(`
|
|
13227
|
+
CREATE TABLE IF NOT EXISTS api_topic_visuals (
|
|
13228
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
13229
|
+
topic_id TEXT NOT NULL,
|
|
13230
|
+
html TEXT NOT NULL,
|
|
13231
|
+
title TEXT,
|
|
13232
|
+
created_at INTEGER NOT NULL,
|
|
13233
|
+
kind TEXT NOT NULL DEFAULT 'html',
|
|
13234
|
+
source TEXT,
|
|
13235
|
+
file_id TEXT,
|
|
13236
|
+
mime_type TEXT,
|
|
13237
|
+
media_token TEXT
|
|
13238
|
+
);
|
|
13239
|
+
CREATE INDEX IF NOT EXISTS idx_api_topic_visuals_topic
|
|
13240
|
+
ON api_topic_visuals(topic_id, created_at DESC);
|
|
13241
|
+
|
|
13242
|
+
CREATE TABLE IF NOT EXISTS api_topic_visual_views (
|
|
13243
|
+
topic_id TEXT NOT NULL,
|
|
13244
|
+
user_id TEXT NOT NULL,
|
|
13245
|
+
visual_id INTEGER NOT NULL,
|
|
13246
|
+
PRIMARY KEY (topic_id, user_id)
|
|
13247
|
+
);
|
|
13248
|
+
`);
|
|
13249
|
+
});
|
|
13199
13250
|
for (const statement of [
|
|
13200
13251
|
"ALTER TABLE api_topic_visuals ADD COLUMN kind TEXT NOT NULL DEFAULT 'html'",
|
|
13201
13252
|
"ALTER TABLE api_topic_visuals ADD COLUMN source TEXT",
|
|
@@ -13236,32 +13287,35 @@ var init_self_schedules = __esm(async () => {
|
|
|
13236
13287
|
await __promiseAll([
|
|
13237
13288
|
init_forum_db(),
|
|
13238
13289
|
init_runtime_leases(),
|
|
13239
|
-
init_runtime_topic_state()
|
|
13290
|
+
init_runtime_topic_state(),
|
|
13291
|
+
init_storage_host()
|
|
13240
13292
|
]);
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13293
|
+
registerStorageSchemaInitializer((database) => {
|
|
13294
|
+
database.exec(`
|
|
13295
|
+
CREATE TABLE IF NOT EXISTS runtime_self_schedules (
|
|
13296
|
+
id TEXT PRIMARY KEY,
|
|
13297
|
+
topic_id TEXT NOT NULL,
|
|
13298
|
+
user_id TEXT NOT NULL,
|
|
13299
|
+
message TEXT NOT NULL,
|
|
13300
|
+
deliver_at INTEGER NOT NULL,
|
|
13301
|
+
created_at INTEGER NOT NULL,
|
|
13302
|
+
updated_at INTEGER NOT NULL,
|
|
13303
|
+
status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'running')),
|
|
13304
|
+
claimed_by TEXT,
|
|
13305
|
+
claimed_at INTEGER,
|
|
13306
|
+
running_query_id TEXT
|
|
13307
|
+
)
|
|
13308
|
+
`);
|
|
13309
|
+
database.exec(`
|
|
13310
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_runtime_self_schedules_one_pending
|
|
13311
|
+
ON runtime_self_schedules(topic_id)
|
|
13312
|
+
WHERE status = 'pending'
|
|
13313
|
+
`);
|
|
13314
|
+
database.exec(`
|
|
13315
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_self_schedules_due
|
|
13316
|
+
ON runtime_self_schedules(status, deliver_at)
|
|
13317
|
+
`);
|
|
13318
|
+
});
|
|
13265
13319
|
});
|
|
13266
13320
|
|
|
13267
13321
|
// ../../packages/core/src/topics/lifecycle.ts
|
|
@@ -20120,7 +20174,7 @@ init_mcp_helpers();
|
|
|
20120
20174
|
await init_codex_registry();
|
|
20121
20175
|
import { spawn as spawn5 } from "child_process";
|
|
20122
20176
|
import { existsSync as existsSync10, readdirSync as readdirSync3 } from "fs";
|
|
20123
|
-
import { join as
|
|
20177
|
+
import { join as join11 } from "path";
|
|
20124
20178
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
20125
20179
|
import { z } from "zod";
|
|
20126
20180
|
function signalProcessTree(child, signal) {
|
|
@@ -20136,7 +20190,7 @@ function signalProcessTree(child, signal) {
|
|
|
20136
20190
|
}
|
|
20137
20191
|
}
|
|
20138
20192
|
function spawnCapture(cmd, args, timeoutMs, signal, env) {
|
|
20139
|
-
return new Promise((
|
|
20193
|
+
return new Promise((resolve8, reject) => {
|
|
20140
20194
|
const child = spawn5(cmd, args, {
|
|
20141
20195
|
env: env ?? process.env,
|
|
20142
20196
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -20194,7 +20248,7 @@ function spawnCapture(cmd, args, timeoutMs, signal, env) {
|
|
|
20194
20248
|
if (killTimer)
|
|
20195
20249
|
clearTimeout(killTimer);
|
|
20196
20250
|
if (code === 0)
|
|
20197
|
-
|
|
20251
|
+
resolve8({ stdout, stderr });
|
|
20198
20252
|
else
|
|
20199
20253
|
reject(new Error(stderr.trim() || `${cmd} exited with ${code ?? exitSignal}`));
|
|
20200
20254
|
});
|
|
@@ -20272,11 +20326,11 @@ async function checkMaestro(model, timeoutMs, signal) {
|
|
|
20272
20326
|
const remaining = deadline - Date.now();
|
|
20273
20327
|
if (remaining <= 0)
|
|
20274
20328
|
throw new Error("timeout");
|
|
20275
|
-
const eventResult = await new Promise((
|
|
20329
|
+
const eventResult = await new Promise((resolve8, reject) => {
|
|
20276
20330
|
const timeout = setTimeout(() => reject(new Error("timeout")), remaining);
|
|
20277
20331
|
const onAbort = () => reject(new Error("aborted"));
|
|
20278
20332
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
20279
|
-
activeIterator.next().then(
|
|
20333
|
+
activeIterator.next().then(resolve8, reject).finally(() => {
|
|
20280
20334
|
clearTimeout(timeout);
|
|
20281
20335
|
signal.removeEventListener("abort", onAbort);
|
|
20282
20336
|
});
|
|
@@ -20315,7 +20369,7 @@ var checkWaiters = [];
|
|
|
20315
20369
|
var activeCheckAllUsers = new Set;
|
|
20316
20370
|
async function withCheckSlot(operation) {
|
|
20317
20371
|
if (activeChecks >= MAX_CONCURRENT_CHECKS) {
|
|
20318
|
-
await new Promise((
|
|
20372
|
+
await new Promise((resolve8) => checkWaiters.push(resolve8));
|
|
20319
20373
|
}
|
|
20320
20374
|
activeChecks += 1;
|
|
20321
20375
|
try {
|
|
@@ -20373,7 +20427,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
|
|
|
20373
20427
|
server.tool("list_active_queries", "\uD604\uC7AC \uC0AC\uC6A9\uC790 \uBC94\uC704\uC5D0\uC11C \uC2E4\uD589 \uC911\uC778 \uD1A0\uD53D \uCFFC\uB9AC \uBAA9\uB85D\uC744 \uC870\uD68C\uD569\uB2C8\uB2E4.", {}, async () => {
|
|
20374
20428
|
if (!context.userId)
|
|
20375
20429
|
return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC870\uD68C \uBD88\uAC00 (user context \uC5C6\uC74C)");
|
|
20376
|
-
const stateDir =
|
|
20430
|
+
const stateDir = join11(USERS_LOG_DIR, context.userId, "active-queries");
|
|
20377
20431
|
if (!existsSync10(stateDir))
|
|
20378
20432
|
return mcpOk("\uC2E4\uD589 \uC911\uC778 \uCFFC\uB9AC \uC5C6\uC74C");
|
|
20379
20433
|
let files;
|
|
@@ -20386,7 +20440,7 @@ ${results.every((result) => result.ok) ? "All agents healthy" : "Some agents fai
|
|
|
20386
20440
|
const entries = files.flatMap((file) => {
|
|
20387
20441
|
if (!file.endsWith(".json"))
|
|
20388
20442
|
return [];
|
|
20389
|
-
const state = readJsonFile(
|
|
20443
|
+
const state = readJsonFile(join11(stateDir, file));
|
|
20390
20444
|
if (!state)
|
|
20391
20445
|
return [];
|
|
20392
20446
|
const sinceMs = new Date(state.since).getTime();
|
|
@@ -21037,4 +21091,4 @@ export {
|
|
|
21037
21091
|
createAgentHealthMcpServer
|
|
21038
21092
|
};
|
|
21039
21093
|
|
|
21040
|
-
//# debugId=
|
|
21094
|
+
//# debugId=B2D00F1A1BBBDD6C64756E2164756E21
|