feat: add cross conversation messaging
This commit is contained in:
@@ -9,6 +9,10 @@ function createAgentRuntime(deps) {
|
||||
getDefaultCodexModel,
|
||||
loadCodexConfig,
|
||||
prepareCodexCustomRuntime,
|
||||
ccwebMcpServerPath,
|
||||
internalMcpUrl,
|
||||
internalMcpToken,
|
||||
nodePath,
|
||||
wsSend,
|
||||
truncateObj,
|
||||
sanitizeToolInput,
|
||||
@@ -18,6 +22,39 @@ function createAgentRuntime(deps) {
|
||||
getRuntimeSessionId,
|
||||
} = deps;
|
||||
|
||||
function tomlString(value) {
|
||||
return JSON.stringify(String(value || ''));
|
||||
}
|
||||
|
||||
function tomlStringArray(values) {
|
||||
return `[${values.map((value) => tomlString(value)).join(',')}]`;
|
||||
}
|
||||
|
||||
function createCcwebMcpEnv(session, options = {}) {
|
||||
if (!ccwebMcpServerPath || !internalMcpUrl || !internalMcpToken || !session?.id) return null;
|
||||
const rawHopCount = Number.parseInt(String(options.mcpContext?.hopCount || 0), 10);
|
||||
const hopCount = Number.isFinite(rawHopCount) ? Math.max(0, rawHopCount) : 0;
|
||||
return {
|
||||
CC_WEB_MCP_URL: internalMcpUrl,
|
||||
CC_WEB_MCP_TOKEN: internalMcpToken,
|
||||
CC_WEB_SOURCE_SESSION_ID: session.id,
|
||||
CC_WEB_CROSS_HOP_COUNT: String(hopCount),
|
||||
};
|
||||
}
|
||||
|
||||
function appendCcwebMcpConfig(args, mcpEnv) {
|
||||
if (!mcpEnv) return;
|
||||
const envVars = Object.keys(mcpEnv);
|
||||
args.push(
|
||||
'-c', 'mcp_servers.ccweb.type="stdio"',
|
||||
'-c', `mcp_servers.ccweb.command=${tomlString(nodePath || 'node')}`,
|
||||
'-c', `mcp_servers.ccweb.args=${tomlStringArray([ccwebMcpServerPath])}`,
|
||||
'-c', `mcp_servers.ccweb.env_vars=${tomlStringArray(envVars)}`,
|
||||
'-c', 'mcp_servers.ccweb.startup_timeout_sec=10',
|
||||
'-c', 'mcp_servers.ccweb.tool_timeout_sec=60'
|
||||
);
|
||||
}
|
||||
|
||||
function buildClaudeSpawnSpec(session, options = {}) {
|
||||
const hasAttachments = Array.isArray(options.attachments) && options.attachments.length > 0;
|
||||
const args = ['-p', '--output-format', 'stream-json', '--verbose'];
|
||||
@@ -75,6 +112,8 @@ function createAgentRuntime(deps) {
|
||||
const runtimeId = getRuntimeSessionId(session);
|
||||
const args = ['exec'];
|
||||
args.push('--json', '--skip-git-repo-check');
|
||||
const ccwebMcpEnv = createCcwebMcpEnv(session, options);
|
||||
appendCcwebMcpConfig(args, ccwebMcpEnv);
|
||||
|
||||
const permMode = session.permissionMode || 'yolo';
|
||||
// `-s/--sandbox` is an option for `codex exec`, but not for `codex exec resume`.
|
||||
@@ -126,7 +165,7 @@ function createAgentRuntime(deps) {
|
||||
args.push('-');
|
||||
}
|
||||
|
||||
const env = { ...processEnv };
|
||||
const env = { ...processEnv, ...(ccwebMcpEnv || {}) };
|
||||
delete env.CC_WEB_PASSWORD;
|
||||
delete env.CLAUDECODE;
|
||||
delete env.CLAUDE_CODE;
|
||||
|
||||
Reference in New Issue
Block a user