negotium 0.23.3 → 0.23.5
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 +198 -14
- package/dist/agent-helpers.js.map +14 -13
- package/dist/background-bash.js +2 -1
- package/dist/background-bash.js.map +3 -3
- package/dist/browser-runtime.js +2 -1
- package/dist/browser-runtime.js.map +3 -3
- package/dist/{chunk-6gt62j1j.js → chunk-0hmrwxks.js} +3 -3
- package/dist/{chunk-6gt62j1j.js.map → chunk-0hmrwxks.js.map} +2 -2
- package/dist/{chunk-q5djsg78.js → chunk-ad7kxsaq.js} +4 -2
- package/dist/{chunk-q5djsg78.js.map → chunk-ad7kxsaq.js.map} +1 -1
- package/dist/chunk-f7p0h1gs.js.map +1 -1
- package/dist/{chunk-9zn0bkc9.js → chunk-mxxwx5mg.js} +3 -2
- package/dist/{chunk-9zn0bkc9.js.map → chunk-mxxwx5mg.js.map} +3 -3
- package/dist/{chunk-6cnpkzkb.js → chunk-n6crwk1s.js} +26 -2
- package/dist/{chunk-6cnpkzkb.js.map → chunk-n6crwk1s.js.map} +8 -8
- package/dist/{chunk-cez5m5hm.js → chunk-ztcj9grz.js} +1 -1
- package/dist/hosted-agent.js +191 -14
- package/dist/hosted-agent.js.map +11 -10
- package/dist/main.js +556 -46
- package/dist/main.js.map +18 -16
- package/dist/mcp-catalog.js +3 -2
- package/dist/mcp-catalog.js.map +3 -3
- package/dist/mcp-factories.js +513 -42
- package/dist/mcp-factories.js.map +15 -13
- package/dist/media.js +2 -1
- package/dist/media.js.map +3 -3
- package/dist/prompts.js +2 -1
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js +2 -1
- package/dist/query-runtime.js.map +3 -3
- package/dist/registry.js +3 -3
- package/dist/rollout.js +2 -2
- package/dist/runtime/src/agents/claude-notices.ts +130 -0
- package/dist/runtime/src/agents/claude-provider.ts +9 -11
- package/dist/runtime/src/agents/codex-provider.ts +51 -6
- package/dist/runtime/src/agents/rollout/codex.ts +58 -0
- package/dist/runtime/src/mcp/canonical-bridge-config.ts +1 -1
- package/dist/runtime/src/mcp/canonical-proxy-server.ts +39 -1
- package/dist/runtime/src/mcp/factories/index.ts +4 -0
- package/dist/runtime/src/mcp/factories/session-history.ts +388 -0
- package/dist/runtime/src/mcp/runtime-spec.ts +1 -0
- package/dist/runtime/src/mcp/session-history-server.ts +27 -0
- package/dist/runtime/src/platform/config.ts +2 -0
- package/dist/runtime/src/platform/mcp-catalog-policy.ts +5 -0
- package/dist/runtime/src/platform/mcp-config.ts +30 -0
- package/dist/runtime/src/storage/topic-archive.ts +4 -2
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +2 -1
- package/dist/runtime-helpers.js.map +3 -3
- package/dist/storage.js +5 -1
- package/dist/storage.js.map +3 -3
- package/dist/types/packages/core/src/agents/claude-notices.d.ts +15 -0
- package/dist/types/packages/core/src/agents/codex-provider.d.ts +6 -0
- package/dist/types/packages/core/src/agents/rollout/codex.d.ts +12 -0
- package/dist/types/packages/core/src/mcp/canonical-bridge-config.d.ts +1 -1
- package/dist/types/packages/core/src/mcp/factories/index.d.ts +1 -0
- package/dist/types/packages/core/src/mcp/factories/session-history.d.ts +11 -0
- package/dist/types/packages/core/src/mcp/runtime-spec.d.ts +1 -1
- package/dist/types/packages/core/src/platform/config.d.ts +1 -0
- package/dist/types/packages/core/src/platform/mcp-catalog-policy.d.ts +4 -0
- package/dist/types/packages/core/src/storage/topic-archive.d.ts +5 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +2 -1
- package/dist/vault.js.map +3 -3
- package/package.json +1 -1
- /package/dist/{chunk-cez5m5hm.js.map → chunk-ztcj9grz.js.map} +0 -0
package/dist/agent-helpers.js
CHANGED
|
@@ -220,6 +220,7 @@ __export(exports_config, {
|
|
|
220
220
|
SHARED_WIKI_DIR: () => SHARED_WIKI_DIR,
|
|
221
221
|
SESSION_WORKSPACE_DIR: () => SESSION_WORKSPACE_DIR,
|
|
222
222
|
SESSION_INBOX_DIR: () => SESSION_INBOX_DIR,
|
|
223
|
+
SESSION_HISTORY_SERVER: () => SESSION_HISTORY_SERVER,
|
|
223
224
|
SESSION_COMM_SERVER: () => SESSION_COMM_SERVER,
|
|
224
225
|
SESSION_ASKS_DIR: () => SESSION_ASKS_DIR,
|
|
225
226
|
SESSIONS_DB: () => SESSIONS_DB,
|
|
@@ -480,7 +481,7 @@ function resolveWhisperBackend() {
|
|
|
480
481
|
function codexAuthFilePath() {
|
|
481
482
|
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
|
|
482
483
|
}
|
|
483
|
-
var HOME, PROJECT_ROOT, 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", BINARY_EXTENSION, BROWSER_RS_VERSION = "v0.7.7", BROWSER_RS_MIN_SECURE_VERSION = "0.2.1", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.10", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER_PATH, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_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, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, RUNTIME_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, ABSOLUTE_PATH_PREFIX, FILE_EXTENSIONS_REGEX, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5-5", MODEL_HAIKU = "claude-haiku-4-5-20251001", MODEL_FABLE = "claude-fable-5-1", MODEL_DEEPSEEK_V4_PRO = "deepseek-v4-pro", MODEL_DEEPSEEK_V4_FLASH = "deepseek-v4-flash", FALLBACK_AGENT, FALLBACK_MODEL, DEFAULT_TOPIC_EFFORT, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, WHISPER_BACKEND, MLX_WHISPER_BIN, WHISPER_MODEL_MLX, _envMaxTellDepth, MAX_TELL_DEPTH;
|
|
484
|
+
var HOME, PROJECT_ROOT, 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", BINARY_EXTENSION, BROWSER_RS_VERSION = "v0.7.7", BROWSER_RS_MIN_SECURE_VERSION = "0.2.1", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.10", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER_PATH, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SESSION_HISTORY_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, RUNTIME_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, ABSOLUTE_PATH_PREFIX, FILE_EXTENSIONS_REGEX, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5-5", MODEL_HAIKU = "claude-haiku-4-5-20251001", MODEL_FABLE = "claude-fable-5-1", MODEL_DEEPSEEK_V4_PRO = "deepseek-v4-pro", MODEL_DEEPSEEK_V4_FLASH = "deepseek-v4-flash", FALLBACK_AGENT, FALLBACK_MODEL, DEFAULT_TOPIC_EFFORT, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, WHISPER_BACKEND, MLX_WHISPER_BIN, WHISPER_MODEL_MLX, _envMaxTellDepth, MAX_TELL_DEPTH;
|
|
484
485
|
var init_config = __esm(() => {
|
|
485
486
|
init_config_helpers();
|
|
486
487
|
init_logger();
|
|
@@ -516,6 +517,7 @@ var init_config = __esm(() => {
|
|
|
516
517
|
WIKI_SERVER = resolve3(PROJECT_ROOT, "src/mcp/wiki-server.ts");
|
|
517
518
|
TOKEN_STATS_SERVER = resolve3(PROJECT_ROOT, "src/mcp/token-stats-server.ts");
|
|
518
519
|
COMPACTION_LOG_SERVER = resolve3(PROJECT_ROOT, "src/mcp/compaction-log-server.ts");
|
|
520
|
+
SESSION_HISTORY_SERVER = resolve3(PROJECT_ROOT, "src/mcp/session-history-server.ts");
|
|
519
521
|
SYSTEM_HEALTH_SERVER = resolve3(PROJECT_ROOT, "src/mcp/system-health-server.ts");
|
|
520
522
|
AGENT_HEALTH_SERVER = resolve3(PROJECT_ROOT, "src/mcp/agent-health-server.ts");
|
|
521
523
|
VAULT_SERVER = resolve3(PROJECT_ROOT, "src/mcp/vault-server.ts");
|
|
@@ -1339,7 +1341,8 @@ var init_mcp_catalog_policy = __esm(() => {
|
|
|
1339
1341
|
"background-bash": { scopes: ["forum"], forumRequired: true },
|
|
1340
1342
|
"agent-health": { scopes: ["forum", "manager", "cron"], forumRequired: true },
|
|
1341
1343
|
vault: { scopes: ["dm", "forum", "manager", "cron"], forumRequired: true },
|
|
1342
|
-
"cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false }
|
|
1344
|
+
"cua-rs": { scopes: ["dm", "forum", "fork"], forumRequired: false },
|
|
1345
|
+
"session-history": { scopes: ["dm", "forum", "manager"], forumRequired: false }
|
|
1343
1346
|
};
|
|
1344
1347
|
});
|
|
1345
1348
|
|
|
@@ -3690,6 +3693,28 @@ var init_mcp_config = __esm(async () => {
|
|
|
3690
3693
|
return buildBuiltinMcpServer("decision", ctx, () => buildStdioMcpServer(agent, DECISION_SERVER, args));
|
|
3691
3694
|
}
|
|
3692
3695
|
},
|
|
3696
|
+
"session-history": {
|
|
3697
|
+
...commonRuntimeMcpPolicy("session-history"),
|
|
3698
|
+
build(ctx) {
|
|
3699
|
+
const { userId, session, topicId, queryId, agent, peerBridge } = ctx;
|
|
3700
|
+
if (peerBridge) {
|
|
3701
|
+
if (!topicId || !queryId)
|
|
3702
|
+
return null;
|
|
3703
|
+
const env = canonicalMcpBridgeEnv({
|
|
3704
|
+
surface: "session-history",
|
|
3705
|
+
userId,
|
|
3706
|
+
topicId,
|
|
3707
|
+
queryId,
|
|
3708
|
+
peerBridge
|
|
3709
|
+
});
|
|
3710
|
+
return env ? buildStdioMcpServer(agent, CANONICAL_MCP_PROXY_SERVER, ["--surface=session-history"], env) : null;
|
|
3711
|
+
}
|
|
3712
|
+
const args = [`--user-id=${userId}`, `--topic=${session}`];
|
|
3713
|
+
if (topicId)
|
|
3714
|
+
args.push(`--topic-id=${topicId}`);
|
|
3715
|
+
return buildBuiltinMcpServer("session-history", ctx, () => buildStdioMcpServer(agent, SESSION_HISTORY_SERVER, args));
|
|
3716
|
+
}
|
|
3717
|
+
},
|
|
3693
3718
|
"session-comm": {
|
|
3694
3719
|
...commonRuntimeMcpPolicy("session-comm"),
|
|
3695
3720
|
build(ctx) {
|
|
@@ -4977,6 +5002,49 @@ function extractCodexForkedFromId(jsonl) {
|
|
|
4977
5002
|
return;
|
|
4978
5003
|
}
|
|
4979
5004
|
}
|
|
5005
|
+
function extractLatestCodexSystemInstructionsTurn(jsonl) {
|
|
5006
|
+
const lines = jsonl.trimEnd().split(`
|
|
5007
|
+
`);
|
|
5008
|
+
for (let index = lines.length - 1;index >= 0; index -= 1) {
|
|
5009
|
+
const line = lines[index] ?? "";
|
|
5010
|
+
if (!line.includes("[System Instructions]"))
|
|
5011
|
+
continue;
|
|
5012
|
+
try {
|
|
5013
|
+
const entry = JSON.parse(line);
|
|
5014
|
+
if (entry.type !== "response_item")
|
|
5015
|
+
continue;
|
|
5016
|
+
if (entry.payload?.type !== "message" || entry.payload.role !== "user")
|
|
5017
|
+
continue;
|
|
5018
|
+
const text = (entry.payload.content ?? []).map((part) => typeof part.text === "string" ? part.text : "").join("");
|
|
5019
|
+
if (text.startsWith(`[System Instructions]
|
|
5020
|
+
`))
|
|
5021
|
+
return text;
|
|
5022
|
+
} catch {}
|
|
5023
|
+
}
|
|
5024
|
+
return;
|
|
5025
|
+
}
|
|
5026
|
+
function codexThreadHasSystemPrompt(threadId, systemPrompt, depth = 0) {
|
|
5027
|
+
const path = latestCodexRolloutPath(threadId);
|
|
5028
|
+
if (!path)
|
|
5029
|
+
return false;
|
|
5030
|
+
try {
|
|
5031
|
+
const jsonl = readFileSync4(path, "utf8");
|
|
5032
|
+
const latest = extractLatestCodexSystemInstructionsTurn(jsonl);
|
|
5033
|
+
if (latest !== undefined) {
|
|
5034
|
+
return latest.startsWith(`[System Instructions]
|
|
5035
|
+
${systemPrompt}
|
|
5036
|
+
|
|
5037
|
+
`);
|
|
5038
|
+
}
|
|
5039
|
+
if (depth >= 8)
|
|
5040
|
+
return false;
|
|
5041
|
+
const parentId = extractCodexForkedFromId(jsonl);
|
|
5042
|
+
return parentId && parentId !== threadId ? codexThreadHasSystemPrompt(parentId, systemPrompt, depth + 1) : false;
|
|
5043
|
+
} catch (error) {
|
|
5044
|
+
logger.debug({ error, threadId }, "codex system prompt: rollout read failed");
|
|
5045
|
+
return false;
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
4980
5048
|
function readLatestCodexTokenTotals(threadId, depth = 0) {
|
|
4981
5049
|
const path = latestCodexRolloutPath(threadId);
|
|
4982
5050
|
if (!path)
|
|
@@ -5246,7 +5314,7 @@ var init_codex = __esm(async () => {
|
|
|
5246
5314
|
});
|
|
5247
5315
|
|
|
5248
5316
|
// ../../packages/core/src/version.ts
|
|
5249
|
-
var NEGOTIUM_VERSION = "0.23.
|
|
5317
|
+
var NEGOTIUM_VERSION = "0.23.5";
|
|
5250
5318
|
|
|
5251
5319
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
5252
5320
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -6147,6 +6215,97 @@ var init_conversations = __esm(async () => {
|
|
|
6147
6215
|
};
|
|
6148
6216
|
});
|
|
6149
6217
|
|
|
6218
|
+
// ../../packages/core/src/agents/claude-notices.ts
|
|
6219
|
+
function modelLabel(id) {
|
|
6220
|
+
const match = /^claude-([a-z]+)-(\d+)-(\d+)/.exec(id);
|
|
6221
|
+
if (!match)
|
|
6222
|
+
return id;
|
|
6223
|
+
const [, family = "", major, minor] = match;
|
|
6224
|
+
return `${family.charAt(0).toUpperCase()}${family.slice(1)} ${major}.${minor}`;
|
|
6225
|
+
}
|
|
6226
|
+
function rateLimitNotice(m) {
|
|
6227
|
+
const { status, rateLimitType } = m.rate_limit_info;
|
|
6228
|
+
const limit = rateLimitType ? `${RATE_LIMIT_TEXT[rateLimitType] ?? ""} `.trimStart() : "";
|
|
6229
|
+
if (status === "allowed_warning")
|
|
6230
|
+
return `Nearing your ${limit}Claude usage limit`;
|
|
6231
|
+
if (status === "rejected")
|
|
6232
|
+
return `Reached your ${limit}Claude usage limit`;
|
|
6233
|
+
return;
|
|
6234
|
+
}
|
|
6235
|
+
function claudeNoticeStatus(message) {
|
|
6236
|
+
try {
|
|
6237
|
+
if (message.type === "rate_limit_event")
|
|
6238
|
+
return rateLimitNotice(message);
|
|
6239
|
+
if (message.type !== "system")
|
|
6240
|
+
return;
|
|
6241
|
+
const handler = SYSTEM_NOTICES[message.subtype];
|
|
6242
|
+
if (!handler) {
|
|
6243
|
+
logger.debug({ subtype: message.subtype, msg: message }, "claudeProvider: system message (unhandled subtype)");
|
|
6244
|
+
return;
|
|
6245
|
+
}
|
|
6246
|
+
const status = handler(message);
|
|
6247
|
+
if (status)
|
|
6248
|
+
logger.warn({ subtype: message.subtype, status }, "claudeProvider: notice");
|
|
6249
|
+
return status;
|
|
6250
|
+
} catch (err) {
|
|
6251
|
+
logger.debug({ err, msg: message }, "claudeProvider: notice mapping failed");
|
|
6252
|
+
return;
|
|
6253
|
+
}
|
|
6254
|
+
}
|
|
6255
|
+
var API_ERROR_TEXT, RATE_LIMIT_TEXT, DENIAL_TEXT, SYSTEM_NOTICES;
|
|
6256
|
+
var init_claude_notices = __esm(() => {
|
|
6257
|
+
init_logger();
|
|
6258
|
+
API_ERROR_TEXT = {
|
|
6259
|
+
overloaded: "Claude is overloaded",
|
|
6260
|
+
rate_limit: "Claude rate limit hit",
|
|
6261
|
+
server_error: "Claude API error",
|
|
6262
|
+
unknown: "Claude request failed",
|
|
6263
|
+
authentication_failed: "Claude sign-in failed",
|
|
6264
|
+
oauth_org_not_allowed: "Organization not allowed for Claude",
|
|
6265
|
+
account_on_hold: "Claude account is on hold",
|
|
6266
|
+
verification_required: "Claude account needs verification",
|
|
6267
|
+
billing_error: "Claude billing issue",
|
|
6268
|
+
invalid_request: "Claude rejected the request",
|
|
6269
|
+
model_not_found: "Claude model not found",
|
|
6270
|
+
max_output_tokens: "Claude reply hit the length limit",
|
|
6271
|
+
cloud_credential_error: "Cloud credentials failed"
|
|
6272
|
+
};
|
|
6273
|
+
RATE_LIMIT_TEXT = {
|
|
6274
|
+
five_hour: "5-hour",
|
|
6275
|
+
seven_day: "weekly",
|
|
6276
|
+
seven_day_opus: "weekly Opus",
|
|
6277
|
+
seven_day_sonnet: "weekly Sonnet",
|
|
6278
|
+
seven_day_overage_included: "weekly",
|
|
6279
|
+
overage: "extra usage"
|
|
6280
|
+
};
|
|
6281
|
+
DENIAL_TEXT = {
|
|
6282
|
+
rule: "by a permission rule",
|
|
6283
|
+
mode: "by the permission mode",
|
|
6284
|
+
classifier: "by the safety check",
|
|
6285
|
+
asyncAgent: "for a background agent"
|
|
6286
|
+
};
|
|
6287
|
+
SYSTEM_NOTICES = {
|
|
6288
|
+
api_retry: (m) => {
|
|
6289
|
+
const reason = m.error_status === null ? "Lost connection to Claude" : API_ERROR_TEXT[m.error] ?? "Claude request failed";
|
|
6290
|
+
const delay2 = Math.round(m.retry_delay_ms / 1000);
|
|
6291
|
+
const when = delay2 > 0 ? `in ${delay2}s` : "now";
|
|
6292
|
+
return `${reason} \xB7 retrying ${when} (${m.attempt}/${m.max_retries})`;
|
|
6293
|
+
},
|
|
6294
|
+
model_refusal_fallback: (m) => m.direction === "retry" ? `${modelLabel(m.original_model)} declined \xB7 ${modelLabel(m.fallback_model)} is answering instead` : m.content || undefined,
|
|
6295
|
+
model_refusal_no_fallback: (m) => `${modelLabel(m.original_model)} declined this request`,
|
|
6296
|
+
permission_denied: (m) => {
|
|
6297
|
+
const tool = m.tool_name.split("__").at(-1) || m.tool_name;
|
|
6298
|
+
const why = m.decision_reason ? `: ${m.decision_reason}` : ` ${DENIAL_TEXT[m.decision_reason_type ?? ""] ?? ""}`.trimEnd();
|
|
6299
|
+
return `${tool} was blocked${why}`;
|
|
6300
|
+
},
|
|
6301
|
+
informational: (m) => m.prevent_continuation || m.level === "warning" || m.level === "suggestion" ? m.content : undefined,
|
|
6302
|
+
mirror_error: (m) => {
|
|
6303
|
+
logger.warn({ error: m.error }, "claudeProvider: transcript mirror batch dropped");
|
|
6304
|
+
return;
|
|
6305
|
+
}
|
|
6306
|
+
};
|
|
6307
|
+
});
|
|
6308
|
+
|
|
6150
6309
|
// ../../packages/core/src/agents/deep-map.ts
|
|
6151
6310
|
function deepMapStrings(value, fn) {
|
|
6152
6311
|
if (typeof value === "string")
|
|
@@ -6652,12 +6811,13 @@ async function* claudeProvider(opts) {
|
|
|
6652
6811
|
yield { type: "tool_use_summary", summary: m.summary };
|
|
6653
6812
|
continue;
|
|
6654
6813
|
}
|
|
6655
|
-
if (message.type === "system") {
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
yield { type: "session", sessionId: m.session_id };
|
|
6814
|
+
if (message.type === "system" || message.type === "rate_limit_event") {
|
|
6815
|
+
if (message.type === "system" && message.subtype === "init") {
|
|
6816
|
+
yield { type: "session", sessionId: message.session_id };
|
|
6659
6817
|
} else {
|
|
6660
|
-
|
|
6818
|
+
const status = claudeNoticeStatus(message);
|
|
6819
|
+
if (status)
|
|
6820
|
+
yield { type: "status", content: status };
|
|
6661
6821
|
}
|
|
6662
6822
|
continue;
|
|
6663
6823
|
}
|
|
@@ -6768,6 +6928,7 @@ async function* claudeProvider(opts) {
|
|
|
6768
6928
|
}
|
|
6769
6929
|
var CLAUDE_DEFAULT_DISALLOWED_TOOLS, CLAUDE_NATIVE_AGENT_TOOLS, CLAUDE_IMAGE_MAX_BYTES, CLAUDE_IMAGE_MIME_TYPES, CLAUDE_ABORT_SIGKILL_DELAY_MS = 2500, claudeProcessExitListeners;
|
|
6770
6930
|
var init_claude_provider = __esm(async () => {
|
|
6931
|
+
init_claude_notices();
|
|
6771
6932
|
init_claude_registry();
|
|
6772
6933
|
init_vault_tool_policy();
|
|
6773
6934
|
init_file_events();
|
|
@@ -7946,13 +8107,22 @@ var exports_codex_provider = {};
|
|
|
7946
8107
|
__export(exports_codex_provider, {
|
|
7947
8108
|
toCodexMcpServers: () => toCodexMcpServers,
|
|
7948
8109
|
normalizeCodexTurnUsage: () => normalizeCodexTurnUsage,
|
|
7949
|
-
codexProvider: () => codexProvider
|
|
8110
|
+
codexProvider: () => codexProvider,
|
|
8111
|
+
codexNoticeStatus: () => codexNoticeStatus
|
|
7950
8112
|
});
|
|
7951
8113
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
7952
8114
|
import { existsSync as existsSync14, readFileSync as readFileSync11, realpathSync as realpathSync4, statSync as statSync5 } from "fs";
|
|
7953
8115
|
import { homedir as homedir6 } from "os";
|
|
7954
8116
|
import { dirname as dirname11, isAbsolute as isAbsolute3, join as join14, relative as relative2, resolve as resolve10 } from "path";
|
|
7955
8117
|
import { Codex } from "@openai/codex-sdk";
|
|
8118
|
+
function codexNoticeStatus(message) {
|
|
8119
|
+
const firstLine = message.trim().split(`
|
|
8120
|
+
`)[0]?.trim() ?? "";
|
|
8121
|
+
const sentence = /^.*?[.!?](?=\s|$)/.exec(firstLine)?.[0] ?? firstLine;
|
|
8122
|
+
if (!sentence)
|
|
8123
|
+
return "Codex notice";
|
|
8124
|
+
return /^codex\b/i.test(sentence) ? sentence : `Codex: ${sentence}`;
|
|
8125
|
+
}
|
|
7956
8126
|
function sameCodexUsage(usage, total) {
|
|
7957
8127
|
return usage.input_tokens === total.inputTokens && usage.output_tokens === total.outputTokens && (usage.cached_input_tokens ?? 0) === total.cachedInputTokens && (usage.cache_write_input_tokens ?? 0) === total.cacheWriteInputTokens;
|
|
7958
8128
|
}
|
|
@@ -8370,8 +8540,7 @@ async function* codexProvider(opts) {
|
|
|
8370
8540
|
},
|
|
8371
8541
|
hooks: vaultHook.hooks,
|
|
8372
8542
|
model_catalog_json: codexModelCatalogPath,
|
|
8373
|
-
mcp_servers: codexMcpServers
|
|
8374
|
-
...opts.toolPolicy ? { sandbox_permissions: [] } : {}
|
|
8543
|
+
mcp_servers: codexMcpServers
|
|
8375
8544
|
}
|
|
8376
8545
|
});
|
|
8377
8546
|
const threadOptions = {
|
|
@@ -8392,7 +8561,7 @@ async function* codexProvider(opts) {
|
|
|
8392
8561
|
let currentSessionId = opts.sessionId;
|
|
8393
8562
|
let usageBaseline = currentSessionId ? readLatestCodexTokenTotals(currentSessionId) : undefined;
|
|
8394
8563
|
let thread = currentSessionId ? codex.resumeThread(currentSessionId, threadOptions) : codex.startThread(threadOptions);
|
|
8395
|
-
let prompt = promptForThread(opts,
|
|
8564
|
+
let prompt = promptForThread(opts, !currentSessionId || !opts.systemPrompt || !codexThreadHasSystemPrompt(currentSessionId, opts.systemPrompt));
|
|
8396
8565
|
let agentTextSoFar = "";
|
|
8397
8566
|
let currentAgentMessageId;
|
|
8398
8567
|
let finalText = "";
|
|
@@ -8420,6 +8589,8 @@ async function* codexProvider(opts) {
|
|
|
8420
8589
|
trackedPids.pids = [];
|
|
8421
8590
|
let heartbeatTriggered = false;
|
|
8422
8591
|
let attemptCompleted = false;
|
|
8592
|
+
let turnFailed = false;
|
|
8593
|
+
let streamError;
|
|
8423
8594
|
let heartbeatTimer = null;
|
|
8424
8595
|
const scheduleHeartbeat = () => {
|
|
8425
8596
|
if (heartbeatTimer !== null)
|
|
@@ -8548,7 +8719,8 @@ async function* codexProvider(opts) {
|
|
|
8548
8719
|
} else if (item.type === "error") {
|
|
8549
8720
|
const message = String(item.message ?? "");
|
|
8550
8721
|
if (message !== CODEX_HOOK_TRUST_BYPASS_NOTICE) {
|
|
8551
|
-
|
|
8722
|
+
logger.warn({ message }, "codexProvider: codex non-fatal error item");
|
|
8723
|
+
yield { type: "status", content: codexNoticeStatus(message) };
|
|
8552
8724
|
}
|
|
8553
8725
|
}
|
|
8554
8726
|
break;
|
|
@@ -8576,7 +8748,15 @@ async function* codexProvider(opts) {
|
|
|
8576
8748
|
yield* extractFileEvents(finalText, "result");
|
|
8577
8749
|
break;
|
|
8578
8750
|
}
|
|
8751
|
+
case "error": {
|
|
8752
|
+
const message = event.message || "Codex stream error";
|
|
8753
|
+
logger.warn({ message }, "codexProvider: codex stream error event");
|
|
8754
|
+
streamError = message;
|
|
8755
|
+
yield { type: "status", content: codexNoticeStatus(message) };
|
|
8756
|
+
break;
|
|
8757
|
+
}
|
|
8579
8758
|
case "turn.failed": {
|
|
8759
|
+
turnFailed = true;
|
|
8580
8760
|
stopReason = "error";
|
|
8581
8761
|
yield {
|
|
8582
8762
|
type: "error",
|
|
@@ -8588,6 +8768,10 @@ async function* codexProvider(opts) {
|
|
|
8588
8768
|
break;
|
|
8589
8769
|
}
|
|
8590
8770
|
}
|
|
8771
|
+
if (!attemptCompleted && !turnFailed && streamError) {
|
|
8772
|
+
stopReason = "error";
|
|
8773
|
+
yield { type: "error", content: streamError };
|
|
8774
|
+
}
|
|
8591
8775
|
} catch (err) {
|
|
8592
8776
|
if (abortSignal?.aborted)
|
|
8593
8777
|
return;
|
|
@@ -23583,4 +23767,4 @@ export {
|
|
|
23583
23767
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
23584
23768
|
};
|
|
23585
23769
|
|
|
23586
|
-
//# debugId=
|
|
23770
|
+
//# debugId=ED5A62E03BAFB97964756E2164756E21
|