@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
package/dist/hosted-agent.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
canonicalMcpBridgeEnv,
|
|
4
|
-
revokeCanonicalMcpBridgeTurn
|
|
5
|
-
} from "./chunk-f7p0h1gs.js";
|
|
6
|
-
import {
|
|
7
|
-
AGENT_HEALTH_SERVER,
|
|
8
|
-
BASHRS_SPILL_ROOT,
|
|
9
|
-
BASH_RS_BIN,
|
|
10
|
-
BASH_RS_VERSION,
|
|
11
|
-
BG_BASH_BASE_PORT,
|
|
12
|
-
BG_BASH_MAX_PORT,
|
|
13
|
-
CANONICAL_MCP_PROXY_SERVER,
|
|
14
|
-
CLAUDE_EFFORT_VALUES,
|
|
15
|
-
CLAUDE_EXECUTABLE,
|
|
16
|
-
DECISION_SERVER,
|
|
17
|
-
DM_WORKSPACE_DIR,
|
|
18
|
-
FALLBACK_AGENT,
|
|
19
|
-
FILE_TAG_REGEX,
|
|
20
|
-
MODEL_FABLE,
|
|
21
|
-
MODEL_OPUS,
|
|
22
|
-
MODEL_SONNET,
|
|
23
|
-
NEGOTIUM_PORT,
|
|
24
|
-
PROJECT_ROOT,
|
|
25
|
-
RUNTIME_MCP_SECRET,
|
|
26
|
-
RUN_DIR,
|
|
27
|
-
SESSION_COMM_SERVER,
|
|
28
|
-
SESSION_HISTORY_SERVER,
|
|
29
|
-
SESSION_WORKSPACE_DIR,
|
|
30
|
-
SUPPORTED_AGENTS,
|
|
31
|
-
SYSTEM_HEALTH_SERVER,
|
|
32
|
-
TASK_SERVER,
|
|
33
|
-
TOKEN_STATS_SERVER,
|
|
34
|
-
TOPIC_WORKSPACE_DIR,
|
|
35
|
-
TSCONFIG_PATH,
|
|
36
|
-
TSX_LOADER,
|
|
37
|
-
VAULT_MASTER_KEY,
|
|
38
|
-
VAULT_SERVER,
|
|
39
|
-
WIKI_SERVER,
|
|
40
|
-
WORKSPACE_DIR,
|
|
41
|
-
codexAuthFilePath,
|
|
42
|
-
envText,
|
|
43
3
|
logger,
|
|
4
|
+
SUPPORTED_AGENTS,
|
|
5
|
+
CLAUDE_EFFORT_VALUES,
|
|
44
6
|
resolveFallbackAgent,
|
|
45
|
-
|
|
46
|
-
|
|
7
|
+
envText2,
|
|
8
|
+
PROJECT_ROOT2,
|
|
9
|
+
WORKSPACE_DIR2,
|
|
10
|
+
TOPIC_WORKSPACE_DIR2,
|
|
11
|
+
BROWSER_BACKEND2,
|
|
12
|
+
DM_WORKSPACE_DIR2,
|
|
13
|
+
SESSION_WORKSPACE_DIR2,
|
|
14
|
+
CLAUDE_EXECUTABLE2,
|
|
15
|
+
BASH_RS_VERSION2,
|
|
16
|
+
BASH_RS_BIN2,
|
|
17
|
+
TSX_LOADER2,
|
|
18
|
+
TSCONFIG_PATH2,
|
|
19
|
+
SESSION_COMM_SERVER2,
|
|
20
|
+
TASK_SERVER2,
|
|
21
|
+
DECISION_SERVER2,
|
|
22
|
+
CANONICAL_MCP_PROXY_SERVER2,
|
|
23
|
+
WIKI_SERVER2,
|
|
24
|
+
TOKEN_STATS_SERVER2,
|
|
25
|
+
SESSION_HISTORY_SERVER2,
|
|
26
|
+
SYSTEM_HEALTH_SERVER2,
|
|
27
|
+
AGENT_HEALTH_SERVER2,
|
|
28
|
+
VAULT_SERVER2,
|
|
29
|
+
BG_BASH_BASE_PORT2,
|
|
30
|
+
BG_BASH_MAX_PORT2,
|
|
31
|
+
resolveTopicWorkspaceDir2,
|
|
32
|
+
RUNTIME_MCP_SECRET2,
|
|
33
|
+
VAULT_MASTER_KEY2,
|
|
34
|
+
NEGOTIUM_PORT2,
|
|
35
|
+
RUN_DIR2,
|
|
36
|
+
BASHRS_SPILL_ROOT2,
|
|
37
|
+
FILE_TAG_REGEX2,
|
|
38
|
+
MODEL_SONNET2,
|
|
39
|
+
MODEL_OPUS2,
|
|
40
|
+
MODEL_FABLE2,
|
|
41
|
+
MODEL_FABLE_5_22,
|
|
42
|
+
FALLBACK_AGENT2,
|
|
43
|
+
codexAuthFilePath2
|
|
44
|
+
} from "./chunk-pesnv5zv.js";
|
|
47
45
|
import {
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
canonicalMcpBridgeEnv2,
|
|
47
|
+
revokeCanonicalMcpBridgeTurn2
|
|
48
|
+
} from "./chunk-ww8a4ej4.js";
|
|
50
49
|
|
|
51
50
|
// ../../packages/core/src/agents/claude-provider.ts
|
|
52
51
|
import { spawn as spawn2 } from "child_process";
|
|
52
|
+
import { randomUUID } from "crypto";
|
|
53
53
|
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
54
54
|
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
55
55
|
|
|
@@ -151,12 +151,12 @@ function toDisplayPath(filePath) {
|
|
|
151
151
|
|
|
152
152
|
// ../../packages/core/src/agents/rollout/shared.ts
|
|
153
153
|
var trustedWorkspaceRoots = [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
WORKSPACE_DIR2,
|
|
155
|
+
DM_WORKSPACE_DIR2,
|
|
156
|
+
SESSION_WORKSPACE_DIR2,
|
|
157
|
+
TOPIC_WORKSPACE_DIR2
|
|
158
158
|
].map((root) => resolve2(root));
|
|
159
|
-
var FIXTURES_DIR = resolve2(
|
|
159
|
+
var FIXTURES_DIR = resolve2(PROJECT_ROOT2, "src", "agents", "fixtures");
|
|
160
160
|
|
|
161
161
|
// ../../packages/core/src/platform/jsonl.ts
|
|
162
162
|
import {
|
|
@@ -242,9 +242,10 @@ function fsyncDirectoryBestEffort(dir) {
|
|
|
242
242
|
|
|
243
243
|
// ../../packages/core/src/agents/claude-registry.ts
|
|
244
244
|
var ALIAS_MAP = {
|
|
245
|
-
sonnet:
|
|
246
|
-
opus:
|
|
247
|
-
fable:
|
|
245
|
+
sonnet: MODEL_SONNET2,
|
|
246
|
+
opus: MODEL_OPUS2,
|
|
247
|
+
fable: MODEL_FABLE2,
|
|
248
|
+
"fable-5.2": MODEL_FABLE_5_22
|
|
248
249
|
};
|
|
249
250
|
var VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));
|
|
250
251
|
var VALID_EFFORTS = new Set(CLAUDE_EFFORT_VALUES);
|
|
@@ -372,7 +373,7 @@ function agentAliases(agent) {
|
|
|
372
373
|
"gpt-6-astra"
|
|
373
374
|
];
|
|
374
375
|
case "claude":
|
|
375
|
-
return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable"];
|
|
376
|
+
return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable", "fable-5.2"];
|
|
376
377
|
case "maestro":
|
|
377
378
|
return [
|
|
378
379
|
"maestro",
|
|
@@ -616,12 +617,12 @@ class McpUrlBudgetExceededError extends Error {
|
|
|
616
617
|
this.name = "McpUrlBudgetExceededError";
|
|
617
618
|
}
|
|
618
619
|
}
|
|
619
|
-
var runtimePort =
|
|
620
|
+
var runtimePort = NEGOTIUM_PORT2;
|
|
620
621
|
function encodeTokenPart(value) {
|
|
621
622
|
return Buffer.from(JSON.stringify(value), "utf-8").toString("base64url");
|
|
622
623
|
}
|
|
623
624
|
function signTokenPayload(payloadPart) {
|
|
624
|
-
return createHmac("sha256",
|
|
625
|
+
return createHmac("sha256", RUNTIME_MCP_SECRET2).update(payloadPart).digest("base64url");
|
|
625
626
|
}
|
|
626
627
|
function issueRuntimeMcpToken(ctx) {
|
|
627
628
|
const payloadPart = encodeTokenPart({
|
|
@@ -773,9 +774,9 @@ function createBackgroundBashManager(options = {}) {
|
|
|
773
774
|
const knownContexts = new Map;
|
|
774
775
|
const runtimeCapability = options.capability ?? randomBytes(32).toString("hex");
|
|
775
776
|
const runtimeServerId = options.serverId ?? randomBytes(16).toString("hex");
|
|
776
|
-
const bashRsBin = options.bashRsBin ??
|
|
777
|
-
const basePort = options.basePort ??
|
|
778
|
-
const maxPort = options.maxPort ??
|
|
777
|
+
const bashRsBin = options.bashRsBin ?? BASH_RS_BIN2;
|
|
778
|
+
const basePort = options.basePort ?? BG_BASH_BASE_PORT2;
|
|
779
|
+
const maxPort = options.maxPort ?? BG_BASH_MAX_PORT2;
|
|
779
780
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
780
781
|
const now = options.now ?? Date.now;
|
|
781
782
|
const wait = options.delay ?? delay;
|
|
@@ -832,7 +833,7 @@ function createBackgroundBashManager(options = {}) {
|
|
|
832
833
|
}
|
|
833
834
|
async function spawnServer(key, reservedPort, excludedPorts = new Set) {
|
|
834
835
|
if (!bashRsBin) {
|
|
835
|
-
throw new Error(`background-bash requires the bash-rs ${
|
|
836
|
+
throw new Error(`background-bash requires the bash-rs ${BASH_RS_VERSION2} binary; run install-bash-rs.mjs (or set NEGOTIUM_BASH_RS_BIN)`);
|
|
836
837
|
}
|
|
837
838
|
const port = reservedPort ?? await allocatePort(excludedPorts);
|
|
838
839
|
const process2 = spawnImpl(bashRsBin, [String(port)], {
|
|
@@ -845,7 +846,7 @@ function createBackgroundBashManager(options = {}) {
|
|
|
845
846
|
NEGOTIUM_BG_BASH_SERVER_ID: runtimeServerId,
|
|
846
847
|
BASHRS_HTTP_CAPABILITY: runtimeCapability,
|
|
847
848
|
BASHRS_INSTANCE_ID: runtimeServerId,
|
|
848
|
-
BASHRS_SPILL_ROOT
|
|
849
|
+
BASHRS_SPILL_ROOT: BASHRS_SPILL_ROOT2
|
|
849
850
|
}
|
|
850
851
|
});
|
|
851
852
|
process2.once("error", (error) => {
|
|
@@ -932,12 +933,12 @@ function createBackgroundBashManager(options = {}) {
|
|
|
932
933
|
usedPorts.clear();
|
|
933
934
|
knownContexts.clear();
|
|
934
935
|
const deadline = now() + 3000;
|
|
935
|
-
await Promise.all(entries.map((instance) => new Promise((
|
|
936
|
+
await Promise.all(entries.map((instance) => new Promise((resolve) => {
|
|
936
937
|
if (instance.process.exitCode !== null || instance.process.killed)
|
|
937
|
-
return
|
|
938
|
-
instance.process.once("exit",
|
|
939
|
-
instance.process.once("error",
|
|
940
|
-
const timer = setTimeout(
|
|
938
|
+
return resolve();
|
|
939
|
+
instance.process.once("exit", resolve);
|
|
940
|
+
instance.process.once("error", resolve);
|
|
941
|
+
const timer = setTimeout(resolve, Math.max(0, deadline - now()));
|
|
941
942
|
timer.unref?.();
|
|
942
943
|
})));
|
|
943
944
|
}
|
|
@@ -1370,7 +1371,7 @@ var SCHEMA_TRIGGERS = {
|
|
|
1370
1371
|
};
|
|
1371
1372
|
var OTIUM_TOPIC_SCOPE_IMMUTABLE_ERROR = "otium_topic_scope_immutable";
|
|
1372
1373
|
function topicLinkSchemaIsCurrent(database, nodeId) {
|
|
1373
|
-
const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((
|
|
1374
|
+
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 ?? ""]));
|
|
1374
1375
|
for (const name of [...SCHEMA_TABLES, ...SCHEMA_INDEXES, ...SCHEMA_INDEXES_TOMBSTONES]) {
|
|
1375
1376
|
if (!objects.has(name))
|
|
1376
1377
|
return false;
|
|
@@ -1387,7 +1388,7 @@ function topicLinkSchemaIsCurrent(database, nodeId) {
|
|
|
1387
1388
|
return false;
|
|
1388
1389
|
}
|
|
1389
1390
|
const identity = database.query("SELECT node_id, epoch_id FROM api_node_identity WHERE singleton = 1").all();
|
|
1390
|
-
if (identity.some((
|
|
1391
|
+
if (identity.some((row) => row.epoch_id === null))
|
|
1391
1392
|
return false;
|
|
1392
1393
|
if (nodeId && identity[0]?.node_id !== nodeId)
|
|
1393
1394
|
return false;
|
|
@@ -2211,8 +2212,8 @@ function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
|
|
|
2211
2212
|
if (agent === "codex") {
|
|
2212
2213
|
return {
|
|
2213
2214
|
command: "node",
|
|
2214
|
-
args: ["--import",
|
|
2215
|
-
env: { TSX_TSCONFIG_PATH:
|
|
2215
|
+
args: ["--import", TSX_LOADER2, serverFile, ...serverArgs],
|
|
2216
|
+
env: { TSX_TSCONFIG_PATH: TSCONFIG_PATH2, ...env }
|
|
2216
2217
|
};
|
|
2217
2218
|
}
|
|
2218
2219
|
return {
|
|
@@ -2222,12 +2223,12 @@ function buildStdioMcpServer(agent, serverFile, serverArgs, env) {
|
|
|
2222
2223
|
};
|
|
2223
2224
|
}
|
|
2224
2225
|
function useHostedBuiltinMcp() {
|
|
2225
|
-
return
|
|
2226
|
+
return envText2("NEGOTIUM_BUILTIN_MCP_TRANSPORT") !== "stdio";
|
|
2226
2227
|
}
|
|
2227
2228
|
function buildBuiltinMcpServer(surface, ctx, stdio) {
|
|
2228
2229
|
if (!useHostedBuiltinMcp())
|
|
2229
2230
|
return stdio();
|
|
2230
|
-
const agent = ctx.agent ??
|
|
2231
|
+
const agent = ctx.agent ?? FALLBACK_AGENT2;
|
|
2231
2232
|
return buildHostedMcpSpec(agent, surface, {
|
|
2232
2233
|
userId: ctx.userId,
|
|
2233
2234
|
...ctx.actorUserId ? { actorUserId: ctx.actorUserId } : {},
|
|
@@ -2239,7 +2240,7 @@ function buildBuiltinMcpServer(surface, ctx, stdio) {
|
|
|
2239
2240
|
...ctx.wikiTopicId ? { wikiTopicId: ctx.wikiTopicId } : {},
|
|
2240
2241
|
...ctx.subagentParentTopicId ? { subagentParentTopicId: ctx.subagentParentTopicId } : {},
|
|
2241
2242
|
...ctx.threadRootId ? { threadRootId: ctx.threadRootId } : {},
|
|
2242
|
-
cwd: ctx.cwd ?? (ctx.topicId ?
|
|
2243
|
+
cwd: ctx.cwd ?? (ctx.topicId ? resolveTopicWorkspaceDir2(ctx.topicId) : process.cwd()),
|
|
2243
2244
|
agent,
|
|
2244
2245
|
...ctx.model ? { model: ctx.model } : {},
|
|
2245
2246
|
...ctx.depth !== undefined ? { depth: ctx.depth } : {},
|
|
@@ -2309,6 +2310,8 @@ var MCP_CATALOG = {
|
|
|
2309
2310
|
playwright: {
|
|
2310
2311
|
...commonRuntimeMcpPolicy("playwright"),
|
|
2311
2312
|
build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
|
|
2313
|
+
if (BROWSER_BACKEND2 === "egolite")
|
|
2314
|
+
return null;
|
|
2312
2315
|
if (playwrightPort && playwrightCapability) {
|
|
2313
2316
|
const owner = browserOwnerForContext({ userId, session, topicId });
|
|
2314
2317
|
if (!owner)
|
|
@@ -2352,7 +2355,7 @@ var MCP_CATALOG = {
|
|
|
2352
2355
|
topicId,
|
|
2353
2356
|
topicTitle: session,
|
|
2354
2357
|
queryId,
|
|
2355
|
-
cwd: cwd ??
|
|
2358
|
+
cwd: cwd ?? resolveTopicWorkspaceDir2(topicId),
|
|
2356
2359
|
agent,
|
|
2357
2360
|
model,
|
|
2358
2361
|
...switchTargets.length ? { explicitAgentSwitchTargets: switchTargets } : {},
|
|
@@ -2367,7 +2370,7 @@ var MCP_CATALOG = {
|
|
|
2367
2370
|
"token-stats": {
|
|
2368
2371
|
...commonRuntimeMcpPolicy("token-stats"),
|
|
2369
2372
|
build(ctx) {
|
|
2370
|
-
return buildBuiltinMcpServer("token-stats", ctx, () => buildStdioMcpServer(ctx.agent,
|
|
2373
|
+
return buildBuiltinMcpServer("token-stats", ctx, () => buildStdioMcpServer(ctx.agent, TOKEN_STATS_SERVER2, [`--user-id=${ctx.userId}`]));
|
|
2371
2374
|
}
|
|
2372
2375
|
},
|
|
2373
2376
|
task: {
|
|
@@ -2377,19 +2380,19 @@ var MCP_CATALOG = {
|
|
|
2377
2380
|
if (peerBridge) {
|
|
2378
2381
|
if (!topicId || !queryId)
|
|
2379
2382
|
return null;
|
|
2380
|
-
const env =
|
|
2383
|
+
const env = canonicalMcpBridgeEnv2({
|
|
2381
2384
|
surface: "task",
|
|
2382
2385
|
userId,
|
|
2383
2386
|
topicId,
|
|
2384
2387
|
queryId,
|
|
2385
2388
|
peerBridge
|
|
2386
2389
|
});
|
|
2387
|
-
return env ? buildStdioMcpServer(agent,
|
|
2390
|
+
return env ? buildStdioMcpServer(agent, CANONICAL_MCP_PROXY_SERVER2, ["--surface=task"], env) : null;
|
|
2388
2391
|
}
|
|
2389
2392
|
const args = [`--user-id=${userId}`, `--topic=${session}`];
|
|
2390
2393
|
if (topicId)
|
|
2391
2394
|
args.push(`--topic-id=${topicId}`);
|
|
2392
|
-
return buildBuiltinMcpServer("task", ctx, () => buildStdioMcpServer(agent,
|
|
2395
|
+
return buildBuiltinMcpServer("task", ctx, () => buildStdioMcpServer(agent, TASK_SERVER2, args));
|
|
2393
2396
|
}
|
|
2394
2397
|
},
|
|
2395
2398
|
decision: {
|
|
@@ -2399,25 +2402,25 @@ var MCP_CATALOG = {
|
|
|
2399
2402
|
if (peerBridge) {
|
|
2400
2403
|
if (!topicId || !queryId)
|
|
2401
2404
|
return null;
|
|
2402
|
-
const env =
|
|
2405
|
+
const env = canonicalMcpBridgeEnv2({
|
|
2403
2406
|
surface: "decision",
|
|
2404
2407
|
userId,
|
|
2405
2408
|
topicId,
|
|
2406
2409
|
queryId,
|
|
2407
2410
|
peerBridge
|
|
2408
2411
|
});
|
|
2409
|
-
return env ? buildStdioMcpServer(agent,
|
|
2412
|
+
return env ? buildStdioMcpServer(agent, CANONICAL_MCP_PROXY_SERVER2, ["--surface=decision"], env) : null;
|
|
2410
2413
|
}
|
|
2411
2414
|
const args = [
|
|
2412
2415
|
`--user-id=${userId}`,
|
|
2413
2416
|
`--topic=${session}`,
|
|
2414
|
-
`--agent=${agent ??
|
|
2417
|
+
`--agent=${agent ?? FALLBACK_AGENT2}`
|
|
2415
2418
|
];
|
|
2416
2419
|
if (topicId)
|
|
2417
2420
|
args.push(`--topic-id=${topicId}`);
|
|
2418
2421
|
if (model)
|
|
2419
2422
|
args.push(`--model=${model}`);
|
|
2420
|
-
return buildBuiltinMcpServer("decision", ctx, () => buildStdioMcpServer(agent,
|
|
2423
|
+
return buildBuiltinMcpServer("decision", ctx, () => buildStdioMcpServer(agent, DECISION_SERVER2, args));
|
|
2421
2424
|
}
|
|
2422
2425
|
},
|
|
2423
2426
|
"session-history": {
|
|
@@ -2427,19 +2430,19 @@ var MCP_CATALOG = {
|
|
|
2427
2430
|
if (peerBridge) {
|
|
2428
2431
|
if (!topicId || !queryId)
|
|
2429
2432
|
return null;
|
|
2430
|
-
const env =
|
|
2433
|
+
const env = canonicalMcpBridgeEnv2({
|
|
2431
2434
|
surface: "session-history",
|
|
2432
2435
|
userId,
|
|
2433
2436
|
topicId,
|
|
2434
2437
|
queryId,
|
|
2435
2438
|
peerBridge
|
|
2436
2439
|
});
|
|
2437
|
-
return env ? buildStdioMcpServer(agent,
|
|
2440
|
+
return env ? buildStdioMcpServer(agent, CANONICAL_MCP_PROXY_SERVER2, ["--surface=session-history"], env) : null;
|
|
2438
2441
|
}
|
|
2439
2442
|
const args = [`--user-id=${userId}`, `--topic=${session}`];
|
|
2440
2443
|
if (topicId)
|
|
2441
2444
|
args.push(`--topic-id=${topicId}`);
|
|
2442
|
-
return buildBuiltinMcpServer("session-history", ctx, () => buildStdioMcpServer(agent,
|
|
2445
|
+
return buildBuiltinMcpServer("session-history", ctx, () => buildStdioMcpServer(agent, SESSION_HISTORY_SERVER2, args));
|
|
2443
2446
|
}
|
|
2444
2447
|
},
|
|
2445
2448
|
"session-comm": {
|
|
@@ -2459,7 +2462,7 @@ var MCP_CATALOG = {
|
|
|
2459
2462
|
threadRootId,
|
|
2460
2463
|
peerBridge
|
|
2461
2464
|
} = ctx;
|
|
2462
|
-
const effectiveAgent = agent ??
|
|
2465
|
+
const effectiveAgent = agent ?? FALLBACK_AGENT2;
|
|
2463
2466
|
const cronSessionId = topicId ? getRegisteredCronSession(topicId, effectiveAgent)?.sessionId : undefined;
|
|
2464
2467
|
const args = [
|
|
2465
2468
|
`--user-id=${userId}`,
|
|
@@ -2479,7 +2482,7 @@ var MCP_CATALOG = {
|
|
|
2479
2482
|
...threadRootId ? [`--thread-root-id=${threadRootId}`] : [],
|
|
2480
2483
|
...peerBridge ? [`--peer-host-query-id=${peerBridge.hostQueryId}`] : []
|
|
2481
2484
|
];
|
|
2482
|
-
return buildBuiltinMcpServer("session-comm", ctx, () => buildStdioMcpServer(effectiveAgent,
|
|
2485
|
+
return buildBuiltinMcpServer("session-comm", ctx, () => buildStdioMcpServer(effectiveAgent, SESSION_COMM_SERVER2, args, peerBridge ? peerSessionBridgeIpcEnv() : undefined));
|
|
2483
2486
|
}
|
|
2484
2487
|
},
|
|
2485
2488
|
wiki: {
|
|
@@ -2489,14 +2492,14 @@ var MCP_CATALOG = {
|
|
|
2489
2492
|
if (peerBridge) {
|
|
2490
2493
|
if (!topicId || !queryId)
|
|
2491
2494
|
return null;
|
|
2492
|
-
const env =
|
|
2495
|
+
const env = canonicalMcpBridgeEnv2({
|
|
2493
2496
|
surface: "wiki",
|
|
2494
2497
|
userId,
|
|
2495
2498
|
topicId,
|
|
2496
2499
|
queryId,
|
|
2497
2500
|
peerBridge
|
|
2498
2501
|
});
|
|
2499
|
-
return env ? buildStdioMcpServer(agent,
|
|
2502
|
+
return env ? buildStdioMcpServer(agent, CANONICAL_MCP_PROXY_SERVER2, ["--surface=wiki"], env) : null;
|
|
2500
2503
|
}
|
|
2501
2504
|
const args = [`--user-id=${userId}`];
|
|
2502
2505
|
if (topicId)
|
|
@@ -2505,7 +2508,7 @@ var MCP_CATALOG = {
|
|
|
2505
2508
|
if (resolvedWikiTopicId)
|
|
2506
2509
|
args.push(`--topic-id=${resolvedWikiTopicId}`);
|
|
2507
2510
|
args.push("--surface=wiki");
|
|
2508
|
-
return buildBuiltinMcpServer("wiki", { ...ctx, wikiTopicId: resolvedWikiTopicId }, () => buildStdioMcpServer(agent,
|
|
2511
|
+
return buildBuiltinMcpServer("wiki", { ...ctx, wikiTopicId: resolvedWikiTopicId }, () => buildStdioMcpServer(agent, WIKI_SERVER2, args));
|
|
2509
2512
|
}
|
|
2510
2513
|
},
|
|
2511
2514
|
skills: {
|
|
@@ -2515,13 +2518,13 @@ var MCP_CATALOG = {
|
|
|
2515
2518
|
const args = [`--user-id=${userId}`, "--surface=skills"];
|
|
2516
2519
|
if (topicId)
|
|
2517
2520
|
args.push(`--topic-id=${topicId}`);
|
|
2518
|
-
return buildBuiltinMcpServer("skills", ctx, () => buildStdioMcpServer(agent,
|
|
2521
|
+
return buildBuiltinMcpServer("skills", ctx, () => buildStdioMcpServer(agent, WIKI_SERVER2, args));
|
|
2519
2522
|
}
|
|
2520
2523
|
},
|
|
2521
2524
|
"system-health": {
|
|
2522
2525
|
...commonRuntimeMcpPolicy("system-health"),
|
|
2523
2526
|
build(ctx) {
|
|
2524
|
-
return buildBuiltinMcpServer("system-health", ctx, () => buildStdioMcpServer(ctx.agent,
|
|
2527
|
+
return buildBuiltinMcpServer("system-health", ctx, () => buildStdioMcpServer(ctx.agent, SYSTEM_HEALTH_SERVER2, []));
|
|
2525
2528
|
}
|
|
2526
2529
|
},
|
|
2527
2530
|
"background-bash": {
|
|
@@ -2537,7 +2540,7 @@ var MCP_CATALOG = {
|
|
|
2537
2540
|
build(ctx) {
|
|
2538
2541
|
const { userId, agent } = ctx;
|
|
2539
2542
|
const args = [`--user-id=${userId}`];
|
|
2540
|
-
return buildBuiltinMcpServer("agent-health", ctx, () => buildStdioMcpServer(agent,
|
|
2543
|
+
return buildBuiltinMcpServer("agent-health", ctx, () => buildStdioMcpServer(agent, AGENT_HEALTH_SERVER2, args));
|
|
2541
2544
|
}
|
|
2542
2545
|
},
|
|
2543
2546
|
vault: {
|
|
@@ -2547,7 +2550,7 @@ var MCP_CATALOG = {
|
|
|
2547
2550
|
const args = [`--user-id=${vaultUserId ?? userId}`];
|
|
2548
2551
|
if (agent !== "codex")
|
|
2549
2552
|
args.push("--list-only=true");
|
|
2550
|
-
return buildBuiltinMcpServer("vault", { ...ctx, userId: vaultUserId ?? userId }, () => buildStdioMcpServer(agent,
|
|
2553
|
+
return buildBuiltinMcpServer("vault", { ...ctx, userId: vaultUserId ?? userId }, () => buildStdioMcpServer(agent, VAULT_SERVER2, args));
|
|
2551
2554
|
}
|
|
2552
2555
|
},
|
|
2553
2556
|
"cua-rs": {
|
|
@@ -2896,16 +2899,16 @@ function decryptVaultValueWithKey(userId, key, storedValue, masterKey) {
|
|
|
2896
2899
|
}
|
|
2897
2900
|
|
|
2898
2901
|
// ../../packages/core/src/storage/vault-crypto.ts
|
|
2899
|
-
function encryptVaultValue(userId, key, value, masterKey =
|
|
2902
|
+
function encryptVaultValue(userId, key, value, masterKey = VAULT_MASTER_KEY2) {
|
|
2900
2903
|
return encryptVaultValueWithKey(userId, key, value, masterKey);
|
|
2901
2904
|
}
|
|
2902
|
-
function decryptVaultValue(userId, key, storedValue, masterKey =
|
|
2905
|
+
function decryptVaultValue(userId, key, storedValue, masterKey = VAULT_MASTER_KEY2) {
|
|
2903
2906
|
return decryptVaultValueWithKey(userId, key, storedValue, masterKey);
|
|
2904
2907
|
}
|
|
2905
2908
|
|
|
2906
2909
|
// ../../packages/core/src/storage/vault.ts
|
|
2907
2910
|
var vaultDb;
|
|
2908
|
-
var vaultMasterKey =
|
|
2911
|
+
var vaultMasterKey = VAULT_MASTER_KEY2;
|
|
2909
2912
|
function initializeVaultDatabase(database) {
|
|
2910
2913
|
database.exec("PRAGMA journal_mode = WAL");
|
|
2911
2914
|
database.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -3045,8 +3048,8 @@ var defaultHost = {
|
|
|
3045
3048
|
redactVaultSecrets,
|
|
3046
3049
|
substituteVaultSecrets: (userId, value) => vaultSubstituteDetailed(userId, value).text,
|
|
3047
3050
|
referencesRuntimeSecretStorage,
|
|
3048
|
-
claudeCodeExecutablePath: () =>
|
|
3049
|
-
codexAuthFilePath
|
|
3051
|
+
claudeCodeExecutablePath: () => CLAUDE_EXECUTABLE2,
|
|
3052
|
+
codexAuthFilePath: codexAuthFilePath2
|
|
3050
3053
|
};
|
|
3051
3054
|
var hostRegistrations = [];
|
|
3052
3055
|
var scopedHost = new AsyncLocalStorage;
|
|
@@ -3111,7 +3114,7 @@ function hostedCodexHomePath() {
|
|
|
3111
3114
|
|
|
3112
3115
|
// ../../packages/core/src/media/file-events.ts
|
|
3113
3116
|
function* extractFileEvents(text, source) {
|
|
3114
|
-
const tagRegex = new RegExp(
|
|
3117
|
+
const tagRegex = new RegExp(FILE_TAG_REGEX2.source, "gi");
|
|
3115
3118
|
let match = tagRegex.exec(text);
|
|
3116
3119
|
while (match !== null) {
|
|
3117
3120
|
yield { type: "file", path: match[1], source, origin: "tag" };
|
|
@@ -3203,10 +3206,54 @@ function isClaudeImageAttachment(attachment) {
|
|
|
3203
3206
|
async function* singleUserMessage(message) {
|
|
3204
3207
|
yield message;
|
|
3205
3208
|
}
|
|
3209
|
+
var textUserMessage = (text) => ({
|
|
3210
|
+
type: "user",
|
|
3211
|
+
message: { role: "user", content: text },
|
|
3212
|
+
parent_tool_use_id: null
|
|
3213
|
+
});
|
|
3214
|
+
function liveTurnInput(first) {
|
|
3215
|
+
const waiting = [];
|
|
3216
|
+
let wake;
|
|
3217
|
+
let ended = false;
|
|
3218
|
+
async function* stream() {
|
|
3219
|
+
yield first;
|
|
3220
|
+
for (;; ) {
|
|
3221
|
+
while (waiting.length > 0)
|
|
3222
|
+
yield waiting.shift();
|
|
3223
|
+
if (ended)
|
|
3224
|
+
return;
|
|
3225
|
+
await new Promise((resolve) => {
|
|
3226
|
+
wake = resolve;
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
const nudge = () => {
|
|
3231
|
+
wake?.();
|
|
3232
|
+
wake = undefined;
|
|
3233
|
+
};
|
|
3234
|
+
return {
|
|
3235
|
+
stream: stream(),
|
|
3236
|
+
push(message) {
|
|
3237
|
+
if (ended)
|
|
3238
|
+
return false;
|
|
3239
|
+
waiting.push(message);
|
|
3240
|
+
nudge();
|
|
3241
|
+
return true;
|
|
3242
|
+
},
|
|
3243
|
+
end() {
|
|
3244
|
+
ended = true;
|
|
3245
|
+
nudge();
|
|
3246
|
+
}
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3206
3249
|
function buildClaudePrompt(opts) {
|
|
3250
|
+
const message = buildClaudeUserMessage(opts);
|
|
3251
|
+
return message ? singleUserMessage(message) : opts.prompt;
|
|
3252
|
+
}
|
|
3253
|
+
function buildClaudeUserMessage(opts) {
|
|
3207
3254
|
const attachments = opts.attachments ?? [];
|
|
3208
3255
|
if (attachments.length === 0)
|
|
3209
|
-
return
|
|
3256
|
+
return;
|
|
3210
3257
|
const imageBlocks = [];
|
|
3211
3258
|
for (const attachment of attachments) {
|
|
3212
3259
|
if (!isClaudeImageAttachment(attachment))
|
|
@@ -3238,23 +3285,23 @@ function buildClaudePrompt(opts) {
|
|
|
3238
3285
|
}
|
|
3239
3286
|
}
|
|
3240
3287
|
if (imageBlocks.length === 0)
|
|
3241
|
-
return
|
|
3288
|
+
return;
|
|
3242
3289
|
const content = [{ type: "text", text: opts.prompt }, ...imageBlocks];
|
|
3243
|
-
return
|
|
3290
|
+
return {
|
|
3244
3291
|
type: "user",
|
|
3245
3292
|
message: {
|
|
3246
3293
|
role: "user",
|
|
3247
3294
|
content
|
|
3248
3295
|
},
|
|
3249
3296
|
parent_tool_use_id: null
|
|
3250
|
-
}
|
|
3297
|
+
};
|
|
3251
3298
|
}
|
|
3252
3299
|
var CLAUDE_ABORT_SIGKILL_DELAY_MS = 2500;
|
|
3253
3300
|
var claudeProcessExitListeners = new WeakMap;
|
|
3254
3301
|
function watchClaudeProcessExit(signal) {
|
|
3255
3302
|
let listener;
|
|
3256
|
-
const exited = new Promise((
|
|
3257
|
-
listener =
|
|
3303
|
+
const exited = new Promise((resolve) => {
|
|
3304
|
+
listener = resolve;
|
|
3258
3305
|
const listeners = claudeProcessExitListeners.get(signal) ?? new Set;
|
|
3259
3306
|
listeners.add(listener);
|
|
3260
3307
|
claudeProcessExitListeners.set(signal, listeners);
|
|
@@ -3524,8 +3571,27 @@ async function* claudeProvider(opts) {
|
|
|
3524
3571
|
lastThinkingBeat = now;
|
|
3525
3572
|
return { type: "tool_progress", toolName: "thinking", elapsed: (now - thinkingStart) / 1000 };
|
|
3526
3573
|
};
|
|
3574
|
+
const live = opts.midTurn ? liveTurnInput(buildClaudeUserMessage(opts) ?? textUserMessage(opts.prompt)) : undefined;
|
|
3575
|
+
const midTurnIds = new Map;
|
|
3576
|
+
let midTurnClosed = false;
|
|
3577
|
+
const closeMidTurn = (readUuids) => {
|
|
3578
|
+
if (!opts.midTurn || midTurnClosed)
|
|
3579
|
+
return;
|
|
3580
|
+
midTurnClosed = true;
|
|
3581
|
+
live?.end();
|
|
3582
|
+
opts.midTurn.close(readUuids.flatMap((uuid) => midTurnIds.get(uuid) ?? []));
|
|
3583
|
+
};
|
|
3584
|
+
opts.midTurn?.open((message) => {
|
|
3585
|
+
if (!live || midTurnClosed)
|
|
3586
|
+
return false;
|
|
3587
|
+
const uuid = randomUUID();
|
|
3588
|
+
if (!live.push({ ...textUserMessage(message.text), priority: "next", uuid }))
|
|
3589
|
+
return false;
|
|
3590
|
+
midTurnIds.set(uuid, message.id);
|
|
3591
|
+
return true;
|
|
3592
|
+
});
|
|
3527
3593
|
try {
|
|
3528
|
-
const prompt = buildClaudePrompt(opts);
|
|
3594
|
+
const prompt = live ? live.stream : buildClaudePrompt(opts);
|
|
3529
3595
|
for await (const message of query({
|
|
3530
3596
|
prompt,
|
|
3531
3597
|
options: queryOptions
|
|
@@ -3583,6 +3649,7 @@ async function* claudeProvider(opts) {
|
|
|
3583
3649
|
}
|
|
3584
3650
|
if (message.type === "result") {
|
|
3585
3651
|
const m = message;
|
|
3652
|
+
closeMidTurn(m.user_message_uuids ?? []);
|
|
3586
3653
|
if (m.subtype === "success") {
|
|
3587
3654
|
const contextWindow = (lastContextModel ? m.modelUsage?.[lastContextModel]?.contextWindow : undefined) ?? Object.values(m.modelUsage ?? {})[0]?.contextWindow;
|
|
3588
3655
|
yield {
|
|
@@ -3682,6 +3749,7 @@ async function* claudeProvider(opts) {
|
|
|
3682
3749
|
logger.error({ err: e }, "claudeProvider: SDK iteration failed");
|
|
3683
3750
|
yield { type: "error", content: errMsg(e) };
|
|
3684
3751
|
} finally {
|
|
3752
|
+
closeMidTurn([]);
|
|
3685
3753
|
processExitWatch.dispose();
|
|
3686
3754
|
opts.abortController?.signal.removeEventListener("abort", onCallerAbort);
|
|
3687
3755
|
}
|
|
@@ -3696,7 +3764,7 @@ import { Codex } from "@openai/codex-sdk";
|
|
|
3696
3764
|
|
|
3697
3765
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
3698
3766
|
import { spawn as spawn3 } from "child_process";
|
|
3699
|
-
import { randomUUID } from "crypto";
|
|
3767
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
3700
3768
|
import {
|
|
3701
3769
|
chmodSync as chmodSync2,
|
|
3702
3770
|
copyFileSync,
|
|
@@ -3713,7 +3781,7 @@ import { dirname as dirname5, join as join3 } from "path";
|
|
|
3713
3781
|
import { fileURLToPath } from "url";
|
|
3714
3782
|
|
|
3715
3783
|
// ../../packages/core/src/version.ts
|
|
3716
|
-
var NEGOTIUM_VERSION = "0.23.
|
|
3784
|
+
var NEGOTIUM_VERSION = "0.23.14";
|
|
3717
3785
|
|
|
3718
3786
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
3719
3787
|
function findPackageJson(specifier, searchFromDir) {
|
|
@@ -3773,7 +3841,7 @@ function readCompatibleCodexModelCache(cachePath) {
|
|
|
3773
3841
|
function writePrivateFileAtomic(path, contents) {
|
|
3774
3842
|
if (existsSync2(path) && readFileSync3(path, "utf8") === contents)
|
|
3775
3843
|
return;
|
|
3776
|
-
const tempPath = `${path}.${process.pid}.${
|
|
3844
|
+
const tempPath = `${path}.${process.pid}.${randomUUID2()}.tmp`;
|
|
3777
3845
|
try {
|
|
3778
3846
|
writeFileSync2(tempPath, contents, { encoding: "utf8", mode: 384 });
|
|
3779
3847
|
renameSync2(tempPath, path);
|
|
@@ -3793,7 +3861,7 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
3793
3861
|
stdio: ["pipe", "pipe", "pipe"],
|
|
3794
3862
|
windowsHide: true
|
|
3795
3863
|
});
|
|
3796
|
-
const refreshed = new Promise((
|
|
3864
|
+
const refreshed = new Promise((resolve, reject) => {
|
|
3797
3865
|
let settled = false;
|
|
3798
3866
|
let stdoutBuffer = "";
|
|
3799
3867
|
let stderr = "";
|
|
@@ -3812,7 +3880,7 @@ async function bootstrapCodexModelCache(codexHome, cachePath) {
|
|
|
3812
3880
|
else if (!existsSync2(cachePath))
|
|
3813
3881
|
reject(new Error("Codex did not create its model cache"));
|
|
3814
3882
|
else
|
|
3815
|
-
|
|
3883
|
+
resolve();
|
|
3816
3884
|
};
|
|
3817
3885
|
const send = (message) => {
|
|
3818
3886
|
child.stdin.write(`${JSON.stringify(message)}
|
|
@@ -3879,12 +3947,12 @@ var CODEX_BOOTSTRAP_EXIT_WAIT_MS = 3000;
|
|
|
3879
3947
|
function waitForChildExit(child, timeoutMs) {
|
|
3880
3948
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
3881
3949
|
return Promise.resolve();
|
|
3882
|
-
return new Promise((
|
|
3883
|
-
const timer = setTimeout(
|
|
3950
|
+
return new Promise((resolve) => {
|
|
3951
|
+
const timer = setTimeout(resolve, timeoutMs);
|
|
3884
3952
|
timer.unref?.();
|
|
3885
3953
|
child.once("exit", () => {
|
|
3886
3954
|
clearTimeout(timer);
|
|
3887
|
-
|
|
3955
|
+
resolve();
|
|
3888
3956
|
});
|
|
3889
3957
|
});
|
|
3890
3958
|
}
|
|
@@ -4082,12 +4150,12 @@ function createCodexTreeManager(host, options = {}) {
|
|
|
4082
4150
|
const previous = spawnChain;
|
|
4083
4151
|
let release;
|
|
4084
4152
|
let released = false;
|
|
4085
|
-
spawnChain = new Promise((
|
|
4153
|
+
spawnChain = new Promise((resolve) => {
|
|
4086
4154
|
release = () => {
|
|
4087
4155
|
if (released)
|
|
4088
4156
|
return;
|
|
4089
4157
|
released = true;
|
|
4090
|
-
|
|
4158
|
+
resolve();
|
|
4091
4159
|
};
|
|
4092
4160
|
});
|
|
4093
4161
|
await previous;
|
|
@@ -4194,7 +4262,7 @@ function createCodexTreeManager(host, options = {}) {
|
|
|
4194
4262
|
return;
|
|
4195
4263
|
const deadline = Date.now() + Math.max(0, graceMs);
|
|
4196
4264
|
while (Date.now() < deadline && hasSurvivors(plan.targets)) {
|
|
4197
|
-
await new Promise((
|
|
4265
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(100, Math.max(1, deadline - Date.now()))));
|
|
4198
4266
|
}
|
|
4199
4267
|
killStragglers(plan);
|
|
4200
4268
|
}
|
|
@@ -4257,7 +4325,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
4257
4325
|
|
|
4258
4326
|
// ../../packages/core/src/agents/codex-windows-wrapper.ts
|
|
4259
4327
|
import { execFile } from "child_process";
|
|
4260
|
-
import { createHash as createHash3, randomUUID as
|
|
4328
|
+
import { createHash as createHash3, randomUUID as randomUUID3 } from "crypto";
|
|
4261
4329
|
import { existsSync as existsSync3 } from "fs";
|
|
4262
4330
|
import { mkdir, rename, rm, writeFile } from "fs/promises";
|
|
4263
4331
|
import { join as join4 } from "path";
|
|
@@ -4364,7 +4432,7 @@ async function ensureCodexWindowsWrapperExe(cacheDir) {
|
|
|
4364
4432
|
if (existsSync3(exePath))
|
|
4365
4433
|
return exePath;
|
|
4366
4434
|
await mkdir(cacheDir, { recursive: true });
|
|
4367
|
-
const stamp =
|
|
4435
|
+
const stamp = randomUUID3();
|
|
4368
4436
|
const sourcePath = join4(cacheDir, `wrapper-${stamp}.cs`);
|
|
4369
4437
|
const tempExe = join4(cacheDir, `wrapper-${stamp}.exe`);
|
|
4370
4438
|
try {
|
|
@@ -4518,7 +4586,7 @@ async function createCodexVaultHookBridge(userId) {
|
|
|
4518
4586
|
});
|
|
4519
4587
|
restrictIpcEndpoint(socketPath);
|
|
4520
4588
|
if (IS_WINDOWS2) {
|
|
4521
|
-
const { BINARIES_DIR } = await import("./chunk-
|
|
4589
|
+
const { BINARIES_DIR } = await import("./chunk-d1c2wt8q.js");
|
|
4522
4590
|
const cached = await ensureCodexWindowsWrapperExe(join5(BINARIES_DIR, "codex-hook-wrapper"));
|
|
4523
4591
|
await copyFile(cached, wrapperPath);
|
|
4524
4592
|
await writeFile2(join5(root, "codex-with-hooks.cfg"), [process.execPath, codexCliScriptPath(), socketPath, token].join(`
|
|
@@ -5308,9 +5376,9 @@ async function startStreamedWithTracking(thread, prompt, abortSignal, trackedPid
|
|
|
5308
5376
|
nextP.catch(() => {});
|
|
5309
5377
|
first = await Promise.race([nextP, startupTimeout]);
|
|
5310
5378
|
} catch (err) {
|
|
5311
|
-
const
|
|
5312
|
-
if (
|
|
5313
|
-
killCodexTrees(
|
|
5379
|
+
const novel = findNewCodexChildren(baseline);
|
|
5380
|
+
if (novel.length > 0) {
|
|
5381
|
+
killCodexTrees(novel);
|
|
5314
5382
|
}
|
|
5315
5383
|
await closeIterator(iter);
|
|
5316
5384
|
throw err;
|
|
@@ -5799,7 +5867,7 @@ function buildProviderOwnedToolBlockHook() {
|
|
|
5799
5867
|
}
|
|
5800
5868
|
};
|
|
5801
5869
|
}
|
|
5802
|
-
var MAESTRO_TOOL_OUTPUT_DIR = resolve8(
|
|
5870
|
+
var MAESTRO_TOOL_OUTPUT_DIR = resolve8(RUN_DIR2, "maestro-tool-outputs");
|
|
5803
5871
|
function buildMaestroToolResultTruncation(opts) {
|
|
5804
5872
|
if (opts.toolResultTruncation)
|
|
5805
5873
|
return opts.toolResultTruncation;
|
|
@@ -5893,7 +5961,7 @@ async function* runHostedAgent(input, host) {
|
|
|
5893
5961
|
}
|
|
5894
5962
|
} finally {
|
|
5895
5963
|
if (opts.userId && opts.topicId && opts.queryId && opts.peerBridge) {
|
|
5896
|
-
|
|
5964
|
+
revokeCanonicalMcpBridgeTurn2({
|
|
5897
5965
|
userId: opts.userId,
|
|
5898
5966
|
topicId: opts.topicId,
|
|
5899
5967
|
queryId: opts.queryId,
|
|
@@ -5903,17 +5971,17 @@ async function* runHostedAgent(input, host) {
|
|
|
5903
5971
|
}
|
|
5904
5972
|
}
|
|
5905
5973
|
export {
|
|
5906
|
-
|
|
5907
|
-
spawnClaudeCodeProcessWithTreeKill,
|
|
5908
|
-
runHostedAgent,
|
|
5909
|
-
maestroProvider,
|
|
5910
|
-
inspectBundledClaudeRuntime,
|
|
5911
|
-
configureAgentExecutionHost,
|
|
5912
|
-
codexProvider,
|
|
5913
|
-
claudeProvider,
|
|
5914
|
-
buildMaestroToolHooks,
|
|
5974
|
+
buildClaudeDisallowedTools,
|
|
5915
5975
|
buildMaestroDisallowedTools,
|
|
5916
|
-
|
|
5976
|
+
buildMaestroToolHooks,
|
|
5977
|
+
claudeProvider,
|
|
5978
|
+
codexProvider,
|
|
5979
|
+
configureAgentExecutionHost,
|
|
5980
|
+
inspectBundledClaudeRuntime,
|
|
5981
|
+
maestroProvider,
|
|
5982
|
+
runHostedAgent,
|
|
5983
|
+
spawnClaudeCodeProcessWithTreeKill,
|
|
5984
|
+
toCodexMcpServers
|
|
5917
5985
|
};
|
|
5918
5986
|
|
|
5919
|
-
//# debugId=
|
|
5987
|
+
//# debugId=46992D8061A9877264756E2164756E21
|