MCPcopy Create free account
hub / github.com/Epic0522/Codex-Remote-Contact / buildRemoteExecutionReply

Function buildRemoteExecutionReply

src/server.js:4353–4425  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

4351}
4352
4353async function buildRemoteExecutionReply(event) {
4354 const id = crypto.randomUUID();
4355 const outputPath = join(codexTmpDir, `${id}.remote-execution.txt`);
4356 const memoryContext = formatRemoteExecutionMemoryContext();
4357 const unifiedMemoryContext = await unifiedMemory.formatForPrompt({ query: event.text, limit: 8 });
4358 const skillContext = await loadRemoteExecutionSkillContext();
4359 const effectiveModel = event.temporaryCodex?.model || state.remoteExecution.model;
4360 const effectiveReasoningEffort = event.temporaryCodex?.reasoningEffort || state.remoteExecution.reasoningEffort;
4361 const prompt = [
4362 // Deployment customization: this high-permission prompt is neutral. Add
4363 // relationship/profile wording through assistantProfilePath or skill paths.
4364 `你正在通过 iMessage 远程执行模式与${ownerLabel}对话。`,
4365 "这是一个完整 Codex CLI 通道:你可以检查本机文件、运行命令、修改项目,并在需要时控制桌面相关任务。",
4366 "用中文回复。先给结论和关键动作,不要把长日志整段塞进 iMessage;长输出应整理成摘要,并写明本地文件路径。",
4367 "不要在结尾追加 AI 助手味很重的服务式结束语,例如“要是你想,我下次也可以……”“想的话我还能……”“如果需要我可以……”“要不要我再……”。",
4368 `对删除文件、改系统设置、杀服务、发送外部消息、移动大量文件、代理/VPN 之类高风险动作,要先说明风险并要求${ownerLabel}再次确认,不要直接执行。`,
4369 `如果${ownerLabel}说“给我看看”“截图给我看”“现在什么样”等跟进话,并且前文刚操作过 Finder、文件夹、App 或桌面状态,你应该主动打开相关窗口或切到相关 App,再用 screencapture 生成 PNG 截图。`,
4370 `如果需要把截图或图片给${ownerLabel}看,请把图片保存为本机绝对路径,并在最终回复单独包含一行:[[imessage_attachment:/absolute/path/to/image.png]]。Hub 会根据当前配置把图片导入 Photos/iCloud 照片或作为 iMessage 附件发送。不要把标记解释给${ownerLabel}看。`,
4371 `你可以自然称呼对方为${ownerLabel},自称用“我”。部署者可在 profile 中覆盖具体语气和自定义风格。`,
4372 `当前远程执行模式模型:${effectiveModel}`,
4373 `当前智能等级:${effectiveReasoningEffort}`,
4374 "",
4375 skillContext,
4376 skillContext ? "" : null,
4377 unifiedMemoryContext,
4378 unifiedMemoryContext ? "" : null,
4379 memoryContext,
4380 memoryContext ? "" : null,
4381 event.imagePaths?.length ? `收到的图片数量:${event.imagePaths.length}` : null,
4382 event.imagePaths?.length ? "请结合图片内容处理。如果图片看不清,就如实说明。" : null,
4383 event.imagePaths?.length ? "" : null,
4384 `${ownerLabel}刚刚在远程执行模式里说:`,
4385 event.text,
4386 "",
4387 "请执行需要的工作,并输出适合 iMessage 阅读的最终回复。"
4388 ].filter((part) => part != null).join("\n");
4389
4390 await ensureCodexReplyWorkspace();
4391 state.remoteExecution.busy = true;
4392 try {
4393 const args = [
4394 "exec",
4395 "--ephemeral",
4396 "--skip-git-repo-check",
4397 "-s",
4398 "danger-full-access",
4399 "-m",
4400 effectiveModel,
4401 "-c",
4402 `model_reasoning_effort="${effectiveReasoningEffort}"`,
4403 "-C",
4404 projectDir,
4405 "-o",
4406 outputPath,
4407 ...((event.imagePaths || []).flatMap((imagePath) => ["--image", imagePath])),
4408 "-"
4409 ];
4410 await runCodexCli(args, prompt, {

Callers 1

handleIMessageCommandFunction · 0.85

Tested by

no test coverage detected