@agent-native/core 0.28.5 → 0.30.1
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/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +53 -15
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +20 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/guided-questions.d.ts +9 -1
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.flow.spec.d.ts +2 -0
- package/dist/client/guided-questions.flow.spec.d.ts.map +1 -0
- package/dist/client/guided-questions.flow.spec.js +147 -0
- package/dist/client/guided-questions.flow.spec.js.map +1 -0
- package/dist/client/guided-questions.js +45 -20
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/coding-tools/index.d.ts.map +1 -1
- package/dist/coding-tools/index.js +18 -18
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +201 -188
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/templates/default/.agents/skills/create-skill/SKILL.md +47 -28
- package/dist/templates/workspace-core/.agents/skills/create-skill/SKILL.md +47 -29
- package/docs/content/creating-templates.md +1 -1
- package/docs/content/skills-guide.md +2 -0
- package/docs/content/writing-agent-instructions.md +130 -0
- package/package.json +1 -1
- package/src/templates/default/.agents/skills/create-skill/SKILL.md +47 -28
- package/src/templates/workspace-core/.agents/skills/create-skill/SKILL.md +47 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-agent-executor.d.ts","sourceRoot":"","sources":["../../src/cli/code-agent-executor.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,WAAW,EAKZ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AACvC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
|
562
562
|
function codeAgentSystemPrompt(cwd, permissionMode) {
|
|
563
|
-
|
|
563
|
+
const mode = permissionMode === "read-only" ? "Plan" : "Auto";
|
|
564
|
+
return `You are Agent-Native Code, a coding agent running in ${cwd}. You and the user share one workspace, and your job is to collaborate with them until their goal is genuinely handled.
|
|
564
565
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
-
|
|
570
|
-
-
|
|
571
|
-
- Do not
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
566
|
+
# General
|
|
567
|
+
|
|
568
|
+
You bring a senior engineer's judgment to the work, but you let it arrive through attention rather than premature certainty. Read the codebase first, resist easy assumptions, and let the shape of the existing system teach you how to move.
|
|
569
|
+
|
|
570
|
+
- When you search for text or files, reach first for \`rg\` or \`rg --files\`; they are much faster than \`grep\` or \`find\`. If \`rg\` is unavailable, use the next best tool without fuss.
|
|
571
|
+
- Parallelize independent read-only work (file reads, searches) so you gather context quickly. Keep mutating steps ordered.
|
|
572
|
+
- Read relevant files before editing them. Do not edit a file you have not actually read.
|
|
573
|
+
|
|
574
|
+
# Engineering judgment
|
|
575
|
+
|
|
576
|
+
When the user leaves implementation details open, choose conservatively and in sympathy with the codebase already in front of you:
|
|
577
|
+
|
|
578
|
+
- Prefer the repo's existing patterns, frameworks, and local helper APIs over inventing a new abstraction.
|
|
579
|
+
- For structured data, use structured APIs or parsers instead of ad hoc string manipulation when the toolchain gives you a reasonable option.
|
|
580
|
+
- Keep edits closely scoped to what the request and surrounding code imply. Leave unrelated refactors and metadata churn alone unless they are truly needed to finish safely.
|
|
581
|
+
- Add an abstraction only when it removes real complexity, reduces meaningful duplication, or clearly matches an established local pattern.
|
|
582
|
+
- Let test coverage scale with risk and blast radius: focused for narrow changes, broader when you touch shared behavior or cross-module contracts.
|
|
583
|
+
|
|
584
|
+
# Run mode
|
|
585
|
+
|
|
586
|
+
Current run mode: ${mode} mode (${permissionMode}).
|
|
587
|
+
- In Plan mode, inspect and explain only — do not edit files or run mutating commands.
|
|
588
|
+
- In Auto mode, edit files and run ordinary project commands without pausing. Pause only for genuinely destructive operations: recursive deletes, package publishing, privileged commands, destructive database operations, or forbidden git branch/reset/stash/rebase operations.
|
|
589
|
+
|
|
590
|
+
# Editing constraints
|
|
591
|
+
|
|
592
|
+
- Use the shared coding tools: \`bash\` for search/list/test/build/git-status commands, \`read\` for file reads, \`edit\` for exact-match replacements, and \`write\` only for new files or an intentional full rewrite. Prefer \`edit\` over \`write\` for existing files.
|
|
593
|
+
- Default to ASCII when editing or creating files; introduce non-ASCII only when the file already uses it or there is a clear reason.
|
|
594
|
+
- Add succinct comments only where the code is not self-explanatory. Avoid empty narration like "assign the value"; a short orienting comment before a complex block is fine, used sparingly.
|
|
595
|
+
- You may be in a dirty git worktree. NEVER revert or overwrite changes you did not make — assume they came from the user or another concurrent agent. If unrelated changes exist, ignore them; if they touch your task, work *with* them rather than undoing them. Only stop and ask if they make the task impossible.
|
|
596
|
+
- If you notice unexpected changes appearing mid-task that you did not make, STOP and ask the user how to proceed rather than guessing.
|
|
597
|
+
- Do not create, switch, delete, reset, rebase, or stash git branches. Never run destructive git commands (\`git reset --hard\`, \`git checkout --\`, \`git clean\`) unless the user explicitly asked for that exact operation.
|
|
598
|
+
|
|
599
|
+
# Autonomy and verification
|
|
600
|
+
|
|
601
|
+
- Stay with the work until the task is handled end to end within this turn whenever feasible. Don't stop at analysis or a proposal — implement the fix, and work through blockers yourself before handing them back. The exception is Plan mode, where you propose only.
|
|
602
|
+
- Done means verified, not generated. After code changes (not docs-only), run the repo's checks before reporting success: \`pnpm run prep\` (format + typecheck + test + guards), or a focused subset like \`pnpm typecheck\` or a single package's tests for a small change. Fix all errors before you call it done.
|
|
603
|
+
- Do not claim a change works, tests pass, or a build succeeds unless you actually ran it and saw the result. If you could not verify something, say exactly what is unverified and why.
|
|
604
|
+
|
|
605
|
+
# Tools beyond the basics
|
|
606
|
+
|
|
607
|
+
- Use \`tool-search\` when you need a capability that may come from MCP, including browser automation or computer control.
|
|
576
608
|
- Prefer Playwright MCP for deterministic browser testing; prefer Chrome DevTools MCP when the user needs their live logged-in Chrome session.
|
|
577
|
-
- Only use computer-control MCP tools when they are explicitly available and the
|
|
578
|
-
|
|
579
|
-
|
|
609
|
+
- Only use computer-control MCP tools when they are explicitly available and the request warrants controlling the local computer.
|
|
610
|
+
|
|
611
|
+
# Final answer
|
|
612
|
+
|
|
613
|
+
- Keep it concise and high-signal — plain, idiomatic engineering prose, not a mechanical report. Lead with the outcome. For a small change, one or two short paragraphs plus a verification line is usually right; reserve bullet lists for genuinely multi-part results.
|
|
614
|
+
- Reference files as clickable paths (e.g. \`packages/core/src/foo.ts\`), with a line number when it helps. Do not paste large file contents back — the user shares this machine and can open them.
|
|
615
|
+
- State what you changed, and show evidence you verified it: name the check you ran (e.g. \`pnpm typecheck\`) and its key result, not just a claim that it passed. If you could not run something, say so plainly.
|
|
616
|
+
- No emojis or em dashes unless the user used them first.
|
|
617
|
+
- Respect any AGENTS.md instructions in the repository; they override these defaults on conflict.`;
|
|
580
618
|
}
|
|
581
619
|
function createLocalCodeAgentActions(cwd, permissionMode, runId) {
|
|
582
620
|
const actions = createCodingToolRegistry({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-agent-executor.js","sourceRoot":"","sources":["../../src/cli/code-agent-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,YAAY,GAEb,MAAM,8BAA8B,CAA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AAE,eAAe,CAAC;IACnD,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,SAAS,GAAG,QAAmC,CAAC;IACtD,MAAM,IAAI,GACR,SAAS,CAAC,IAAI,KAAK,MAAM,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa;QAC3D,CAAC,CAAC,SAAS,CAAC,IAAI;QAChB,CAAC,CAAC,IAAI,CAAC;IACX,IACE,CAAC,IAAI;QACL,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ;QACrC,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ;QACpC,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ;QAChC,OAAO,SAAS,CAAC,WAAW,KAAK,QAAQ,EACzC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,IAAI;QACJ,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,cAAc,EACZ,SAAS,CAAC,cAAc,KAAK,WAAW;YACxC,SAAS,CAAC,cAAc,KAAK,iBAAiB;YAC9C,SAAS,CAAC,cAAc,KAAK,WAAW;YACxC,SAAS,CAAC,cAAc,KAAK,WAAW;YACtC,CAAC,CAAC,SAAS,CAAC,cAAc;YAC1B,CAAC,CAAC,WAAW;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import {\n createToolSearchEntry,\n TOOL_SEARCH_ACTION_NAME,\n} from \"../agent/tool-search.js\";\nimport {\n createCodingToolRegistry,\n isReadOnlyShellCommand,\n runCodingCommand,\n truncateCodingOutput,\n} from \"../coding-tools/index.js\";\nimport {\n buildMergedConfig,\n McpClientManager,\n mcpToolsToActionEntries,\n} from \"../mcp-client/index.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport {\n actionsToEngineTools,\n runAgentLoop,\n type ActionEntry,\n} from \"../agent/production-agent.js\";\nimport {\n resolveEngine,\n getStoredModelForEngine,\n registerBuiltinEngines,\n} from \"../agent/engine/index.js\";\nimport type {\n AgentEngine,\n EngineContentPart,\n EngineEvent,\n EngineMessage,\n EngineStreamOptions,\n} from \"../agent/engine/types.js\";\nimport type { AgentChatEvent } from \"../agent/types.js\";\nimport { PROVIDER_ENV_VARS } from \"../agent/engine/provider-env-vars.js\";\nimport {\n isReasoningEffort,\n type ReasoningEffort,\n} from \"../shared/reasoning-effort.js\";\nimport {\n formatPromptWithAttachments,\n type AgentPromptAttachment,\n} from \"../code-agents/prompt-attachments.js\";\nimport {\n appendCodeAgentTranscriptEvent,\n dequeueCodeAgentFollowUp,\n getCodeAgentRunRecord,\n listCodeAgentTranscriptEvents,\n updateCodeAgentRunRecord,\n type CodeAgentPermissionMode,\n type CodeAgentRunRecord,\n} from \"./code-agent-runs.js\";\n\nexport interface ExecuteCodeAgentRunOptions {\n runId: string;\n prompt?: string;\n appendUserEvent?: boolean;\n engine?: AgentEngine;\n model?: string;\n reasoningEffort?: ReasoningEffort;\n attachments?: AgentPromptAttachment[];\n stdout?: NodeJS.WritableStream;\n signal?: AbortSignal;\n}\n\ninterface PendingCodeAgentApproval {\n id: string;\n tool: \"bash\" | \"run_command\";\n command: string;\n reason: string;\n requestedAt: string;\n permissionMode: CodeAgentPermissionMode;\n}\n\nconst DEFAULT_COMMAND_TIMEOUT_MS = 120_000;\nconst MAX_TOOL_OUTPUT_CHARS = 50_000;\nconst MAX_FILE_READ_CHARS = 120_000;\n\nexport async function executeCodeAgentRun(\n options: ExecuteCodeAgentRunOptions,\n): Promise<CodeAgentRunRecord | null> {\n const existing = getCodeAgentRunRecord(options.runId);\n if (!existing) return null;\n\n const prompt = options.prompt ?? latestUserPrompt(existing.id);\n const executionPrompt = formatPromptWithAttachments(\n prompt,\n options.attachments ?? latestUserPromptAttachments(existing.id, prompt),\n );\n if (!prompt) {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: \"No prompt was found for this Agent-Native Code run.\",\n metadata: { status: \"errored\", phase: \"missing-prompt\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"errored\",\n phase: \"missing-prompt\",\n progress: {\n label: \"Missing prompt\",\n completed: 0,\n total: 1,\n failed: 1,\n percent: 0,\n },\n });\n }\n\n if (options.appendUserEvent !== false) {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"user\",\n message: prompt,\n metadata: { source: \"execution-prompt\" },\n });\n }\n\n const running = updateCodeAgentRunRecord(existing.id, {\n status: \"running\",\n phase: \"executing\",\n progress: {\n label: \"Running\",\n completed: 0,\n total: 1,\n percent: 10,\n },\n metadata: {\n executionStartedAt: new Date().toISOString(),\n },\n });\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: \"Agent-Native Code run started.\",\n metadata: { status: \"running\", phase: \"executing\" },\n });\n\n const requestedEngine = metadataString(existing, \"engine\");\n const engine =\n options.engine ?? (await resolveExecutorEngine(requestedEngine));\n if (!engine) {\n const message =\n \"No LLM provider key was found. Set ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, or another supported provider key and resume this run.\";\n options.stdout?.write(`${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message,\n metadata: { status: \"paused\", phase: \"missing-credentials\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"paused\",\n phase: \"missing-credentials\",\n needsApproval: false,\n progress: {\n label: \"Missing credentials\",\n completed: 0,\n total: 1,\n percent: 0,\n },\n });\n }\n\n const model =\n options.model ??\n metadataString(existing, \"model\") ??\n process.env.AGENT_MODEL ??\n (await getStoredModelForEngine(engine).catch(() => undefined)) ??\n engine.defaultModel;\n const reasoningEffort =\n options.reasoningEffort ?? metadataReasoningEffort(existing);\n const cwd = existing.cwd || process.cwd();\n const permissionMode = existing.permissionMode ?? \"full-auto\";\n const actions = createLocalCodeAgentActions(cwd, permissionMode, existing.id);\n const mcpManager = await startCodeAgentMcpManager(existing.id);\n if (mcpManager) {\n Object.assign(actions, mcpToolsToActionEntries(mcpManager));\n }\n actions[TOOL_SEARCH_ACTION_NAME] = createToolSearchEntry(() => actions);\n const tools = actionsToEngineTools(actions);\n const messages = buildCodeAgentMessages(existing, executionPrompt);\n const controller = new AbortController();\n const abortFromParent = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else\n options.signal.addEventListener(\"abort\", abortFromParent, { once: true });\n }\n\n let assistantText = \"\";\n const send = (event: AgentChatEvent) => {\n if (event.type === \"text\") {\n assistantText += event.text;\n options.stdout?.write(event.text);\n return;\n }\n if (event.type === \"activity\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: event.label,\n metadata: { type: \"activity\", tool: event.tool },\n });\n return;\n }\n if (event.type === \"tool_start\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: `Running ${event.tool}.`,\n metadata: { type: \"tool_start\", tool: event.tool, input: event.input },\n });\n return;\n }\n if (event.type === \"tool_done\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: `Finished ${event.tool}.`,\n metadata: {\n type: \"tool_done\",\n tool: event.tool,\n result: truncateCodingOutput(event.result, 4000),\n ...(event.mcpApp ? { mcpApp: event.mcpApp } : {}),\n },\n });\n return;\n }\n if (event.type === \"error\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: event.error,\n metadata: { type: \"error\", errorCode: event.errorCode },\n });\n }\n };\n\n try {\n await runWithOptionalCodeAgentRequestContext(existing, () =>\n runAgentLoop({\n engine,\n model,\n systemPrompt: codeAgentSystemPrompt(cwd, permissionMode),\n tools,\n actions,\n messages,\n send,\n signal: controller.signal,\n maxIterations: 12,\n reasoningEffort,\n }),\n );\n if (assistantText.trim()) {\n options.stdout?.write(\"\\n\");\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"system\",\n message: assistantText.trim(),\n metadata: {\n role: \"assistant\",\n model,\n engine: engine.name,\n reasoningEffort,\n },\n });\n }\n const approvalPending = getPendingApproval(existing.id);\n if (approvalPending) {\n const message = `Agent-Native Code run paused for approval: ${approvalPending.reason}`;\n options.stdout?.write(`\\n${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message,\n metadata: {\n status: \"needs-approval\",\n phase: \"approval-required\",\n pendingApprovalId: approvalPending.id,\n },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"needs-approval\",\n phase: \"approval-required\",\n needsApproval: true,\n progress: {\n label: \"Approval required\",\n completed: 0,\n total: 1,\n percent: 50,\n },\n });\n }\n\n const pendingFollowUp = dequeueCodeAgentFollowUp(existing.id);\n if (pendingFollowUp) {\n const message =\n pendingFollowUp.mode === \"queued\"\n ? \"Agent-Native Code run completed; running queued follow-up.\"\n : \"Agent-Native Code run completed; applying steering follow-up.\";\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message,\n metadata: {\n status: \"running\",\n phase: \"follow-up\",\n followUpId: pendingFollowUp.id,\n followUpMode: pendingFollowUp.mode,\n },\n });\n if (pendingFollowUp.permissionMode) {\n updateCodeAgentRunRecord(existing.id, {\n permissionMode: pendingFollowUp.permissionMode,\n });\n }\n return executeCodeAgentRun({\n ...options,\n runId: existing.id,\n prompt: pendingFollowUp.prompt,\n attachments:\n pendingFollowUp.attachments ??\n userPromptAttachmentsForEvent(existing.id, pendingFollowUp.eventId),\n appendUserEvent: false,\n });\n }\n\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: \"Agent-Native Code run completed.\",\n metadata: { status: \"completed\", phase: \"complete\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"completed\",\n phase: \"complete\",\n needsApproval: false,\n progress: {\n label: \"Complete\",\n completed: 1,\n total: 1,\n percent: 100,\n },\n metadata: {\n executionCompletedAt: new Date().toISOString(),\n engine: engine.name,\n model,\n reasoningEffort,\n permissionMode,\n },\n });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n options.stdout?.write(`\\nAgent-Native Code run failed: ${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: `Agent-Native Code run failed: ${message}`,\n metadata: { status: \"errored\", phase: \"error\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: controller.signal.aborted ? \"paused\" : \"errored\",\n phase: controller.signal.aborted ? \"paused\" : \"error\",\n progress: {\n label: controller.signal.aborted ? \"Paused\" : \"Error\",\n completed: 0,\n total: 1,\n failed: controller.signal.aborted ? 0 : 1,\n percent: 0,\n },\n metadata: {\n executionError: message,\n executionErroredAt: new Date().toISOString(),\n },\n });\n } finally {\n options.signal?.removeEventListener(\"abort\", abortFromParent);\n await mcpManager?.stop().catch(() => undefined);\n void running;\n }\n}\n\nexport async function executeExistingCodeAgentRun(\n runId: string,\n options: Omit<ExecuteCodeAgentRunOptions, \"runId\"> = {},\n): Promise<CodeAgentRunRecord | null> {\n return executeCodeAgentRun({ ...options, runId, appendUserEvent: false });\n}\n\nexport async function executePendingCodeAgentApproval(\n runId: string,\n options: { stdout?: NodeJS.WritableStream } = {},\n): Promise<CodeAgentRunRecord | null> {\n const record = getCodeAgentRunRecord(runId);\n if (!record) return null;\n const approval = getPendingApproval(runId);\n if (!approval) {\n options.stdout?.write(\"No pending approval was found for this run.\\n\");\n return record;\n }\n\n const permission = classifyCodeAgentCommandPermission(approval.command);\n if (permission.kind === \"forbidden\") {\n const message = `Approval cannot run forbidden command: ${permission.reason}`;\n options.stdout?.write(`${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message,\n metadata: {\n status: \"needs-approval\",\n phase: \"approval-forbidden\",\n approvalId: approval.id,\n },\n });\n return updateCodeAgentRunRecord(runId, {\n status: \"needs-approval\",\n phase: \"approval-forbidden\",\n needsApproval: true,\n });\n }\n\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `Approved command ${approval.id}; running now.`,\n metadata: {\n status: \"running\",\n phase: \"approval-running\",\n approvalId: approval.id,\n command: approval.command,\n },\n });\n const result = await runCodingCommand(\n approval.command,\n record.cwd || process.cwd(),\n DEFAULT_COMMAND_TIMEOUT_MS,\n );\n const summary = truncateCodingOutput(\n [\n `Approved command finished with exit code ${result.code}.`,\n result.timedOut ? \"Timed out: true\" : \"\",\n result.stdout ? `stdout:\\n${result.stdout}` : \"\",\n result.stderr ? `stderr:\\n${result.stderr}` : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n MAX_TOOL_OUTPUT_CHARS,\n );\n options.stdout?.write(`${summary}\\n`);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: summary,\n metadata: {\n status: result.code === 0 ? \"paused\" : \"errored\",\n phase: \"approval-complete\",\n approvalId: approval.id,\n exitCode: result.code,\n timedOut: result.timedOut,\n },\n });\n return updateCodeAgentRunRecord(runId, {\n status: result.code === 0 ? \"paused\" : \"errored\",\n phase: result.code === 0 ? \"approval-complete\" : \"approval-command-error\",\n needsApproval: false,\n progress: {\n label: result.code === 0 ? \"Approval complete\" : \"Approval failed\",\n completed: result.code === 0 ? 1 : 0,\n total: 1,\n failed: result.code === 0 ? 0 : 1,\n percent: result.code === 0 ? 100 : 0,\n },\n metadata: {\n pendingApproval: undefined,\n lastApproval: {\n ...approval,\n completedAt: new Date().toISOString(),\n exitCode: result.code,\n },\n },\n });\n}\n\nfunction latestUserPrompt(runId: string): string {\n const events = listCodeAgentTranscriptEvents(runId);\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n if (event.kind === \"user\" && event.message.trim()) return event.message;\n }\n return \"\";\n}\n\nfunction latestUserPromptAttachments(\n runId: string,\n prompt: string,\n): AgentPromptAttachment[] {\n const events = listCodeAgentTranscriptEvents(runId);\n const normalizedPrompt = prompt.trim();\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n if (event.kind !== \"user\" || !event.message.trim()) continue;\n if (\n !normalizedPrompt ||\n event.message.trim() === normalizedPrompt ||\n i === events.length - 1\n ) {\n return promptAttachmentsFromMetadata(event.metadata?.attachments);\n }\n }\n return [];\n}\n\nfunction userPromptAttachmentsForEvent(\n runId: string,\n eventId: string | undefined,\n): AgentPromptAttachment[] {\n if (!eventId) return [];\n const event = listCodeAgentTranscriptEvents(runId).find(\n (item) => item.id === eventId && item.kind === \"user\",\n );\n return promptAttachmentsFromMetadata(event?.metadata?.attachments);\n}\n\nfunction promptAttachmentsFromMetadata(\n value: unknown,\n): AgentPromptAttachment[] {\n if (!Array.isArray(value)) return [];\n return value\n .filter((item): item is Record<string, unknown> =>\n Boolean(item && typeof item === \"object\" && !Array.isArray(item)),\n )\n .map((item) => ({\n name: typeof item.name === \"string\" && item.name ? item.name : \"file\",\n ...(typeof item.type === \"string\" ? { type: item.type } : {}),\n ...(typeof item.size === \"number\" ? { size: item.size } : {}),\n ...(typeof item.text === \"string\" ? { text: item.text } : {}),\n ...(typeof item.dataUrl === \"string\" ? { dataUrl: item.dataUrl } : {}),\n }));\n}\n\nfunction metadataString(\n run: CodeAgentRunRecord,\n key: string,\n): string | undefined {\n const value = run.metadata?.[key];\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nasync function startCodeAgentMcpManager(\n runId: string,\n): Promise<McpClientManager | null> {\n const config = await buildMergedConfig().catch((err) => {\n const message = err instanceof Error ? err.message : String(err);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `MCP tools unavailable: ${message}`,\n metadata: { type: \"mcp-config-error\" },\n });\n return null;\n });\n if (!config || Object.keys(config.servers ?? {}).length === 0) return null;\n\n const manager = new McpClientManager(config);\n await manager.start().catch((err) => {\n const message = err instanceof Error ? err.message : String(err);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `MCP tools failed to start: ${message}`,\n metadata: { type: \"mcp-start-error\" },\n });\n });\n const status = manager.getStatus();\n if (status.totalTools === 0) {\n await manager.stop().catch(() => undefined);\n return null;\n }\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `Connected ${status.totalTools} MCP tool${status.totalTools === 1 ? \"\" : \"s\"} for this run.`,\n metadata: {\n type: \"mcp-tools-connected\",\n servers: status.connectedServers,\n toolCount: status.totalTools,\n },\n });\n return manager;\n}\n\nfunction runWithOptionalCodeAgentRequestContext<T>(\n run: CodeAgentRunRecord,\n fn: () => T | Promise<T>,\n): T | Promise<T> {\n const userEmail =\n metadataString(run, \"ownerEmail\") ??\n metadataString(run, \"userEmail\") ??\n process.env.AGENT_USER_EMAIL;\n const orgId = metadataString(run, \"orgId\") ?? process.env.AGENT_ORG_ID;\n if (!userEmail && !orgId) return fn();\n return runWithRequestContext({ userEmail, orgId }, fn);\n}\n\nfunction metadataReasoningEffort(\n run: CodeAgentRunRecord,\n): ReasoningEffort | undefined {\n const value = run.metadata?.reasoningEffort ?? run.metadata?.effort;\n return isReasoningEffort(value) && value !== \"auto\" ? value : undefined;\n}\n\nasync function resolveExecutorEngine(\n requestedEngine?: string,\n): Promise<AgentEngine | null> {\n const fakeText = process.env.AGENT_NATIVE_CODE_AGENT_FAKE_RESPONSE;\n if (fakeText !== undefined) {\n return createFakeCodeAgentEngine(fakeText || \"Done.\");\n }\n registerBuiltinEngines();\n if (!hasAnyProviderCredential()) return null;\n return resolveEngine({\n engineOption: requestedEngine ?? process.env.AGENT_ENGINE,\n });\n}\n\nfunction hasAnyProviderCredential(): boolean {\n if (process.env.AGENT_ENGINE) return true;\n if (PROVIDER_ENV_VARS.some((key) => Boolean(process.env[key]))) return true;\n return Boolean(\n process.env.BUILDER_PRIVATE_KEY && process.env.BUILDER_PUBLIC_KEY,\n );\n}\n\nfunction createFakeCodeAgentEngine(text: string): AgentEngine {\n return {\n name: \"fake-code-agent\",\n label: \"Fake Agent-Native Code\",\n defaultModel: \"fake-code-agent\",\n supportedModels: [\"fake-code-agent\"],\n capabilities: {\n thinking: false,\n promptCaching: false,\n vision: false,\n computerUse: false,\n parallelToolCalls: false,\n },\n async *stream(_opts: EngineStreamOptions): AsyncIterable<EngineEvent> {\n yield { type: \"text-delta\", text };\n yield {\n type: \"assistant-content\",\n parts: [{ type: \"text\", text }],\n };\n yield {\n type: \"usage\",\n inputTokens: 1,\n outputTokens: 1,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n };\n yield { type: \"stop\", reason: \"end_turn\" };\n },\n };\n}\n\nfunction buildCodeAgentMessages(\n run: CodeAgentRunRecord,\n prompt: string,\n): EngineMessage[] {\n const transcript = listCodeAgentTranscriptEvents(run.id)\n .slice(-40)\n .map((event) => {\n const label =\n event.kind === \"user\"\n ? \"User\"\n : event.metadata?.role === \"assistant\"\n ? \"Assistant\"\n : event.kind;\n return `${label}: ${event.message}`;\n })\n .join(\"\\n\");\n const context = transcript\n ? `\\n\\nPrevious session transcript:\\n${transcript}`\n : \"\";\n return [\n {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: `${prompt}${context}`,\n },\n ],\n },\n ];\n}\n\nfunction codeAgentSystemPrompt(\n cwd: string,\n permissionMode: CodeAgentPermissionMode,\n): string {\n return `You are Agent-Native Code, a local coding agent running in ${cwd}.\n\nWork like a careful senior engineer:\n- Read relevant files before editing.\n- Prefer small, focused changes.\n- Current run mode: ${permissionMode === \"read-only\" ? \"Plan mode\" : \"Auto mode\"} (${permissionMode}).\n- In Plan mode, inspect and explain only.\n- In Auto mode, edit files and run ordinary project commands without pausing. Pause only for genuinely destructive operations such as recursive deletes, package publishing, privileged commands, destructive database operations, or forbidden git branch/reset/stash/rebase operations.\n- Do not create, switch, delete, reset, rebase, or stash git branches.\n- Do not run destructive git commands.\n- Use the shared coding tools: bash for search/list/test/build commands, read for file reads, edit for exact replacement edits, and write only for new files or intentional full rewrites.\n- Prefer edit over write when changing existing files, then run focused verification with bash.\n- Use tool-search when you need a capability that may come from MCP, including browser automation or computer control.\n- Prefer Playwright MCP for deterministic browser testing; prefer Chrome DevTools MCP when the user needs their live logged-in Chrome session.\n- Only use computer-control MCP tools when they are explicitly available and the user request warrants controlling the local computer.\n- Keep the final answer concise and include files changed plus tests run.\n- Respect any AGENTS.md instructions in the repository.`;\n}\n\nfunction createLocalCodeAgentActions(\n cwd: string,\n permissionMode: CodeAgentPermissionMode,\n runId: string,\n): Record<string, ActionEntry> {\n const actions = createCodingToolRegistry({\n cwd,\n restrictToCwd: true,\n commandTimeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,\n maxOutputChars: MAX_TOOL_OUTPUT_CHARS,\n maxFileReadChars: MAX_FILE_READ_CHARS,\n canWrite: (toolName) => permissionErrorForWrite(permissionMode, toolName),\n beforeBash: ({ command }) => {\n const permission = classifyCodeAgentCommandPermission(command);\n if (permission.kind === \"forbidden\") {\n return `Error: command is blocked by Agent-Native Code policy: ${permission.reason}`;\n }\n if (permission.kind !== \"read\") {\n const permissionError = permissionErrorForWrite(permissionMode, \"bash\");\n if (permissionError) return permissionError;\n }\n if (permission.kind === \"approval-required\") {\n const approval = requestCodeAgentApproval(runId, {\n tool: \"bash\",\n command,\n reason: permission.reason,\n permissionMode,\n });\n return [\n `Approval required before running this command: ${permission.reason}.`,\n `Approval id: ${approval.id}`,\n `Command: ${command}`,\n \"The run is paused; approve from the Agent-Native Code UI/CLI if this command is intentional.\",\n ].join(\"\\n\");\n }\n return null;\n },\n });\n if (permissionMode === \"read-only\") {\n return {\n bash: actions.bash,\n read: actions.read,\n };\n }\n return actions;\n}\n\nexport type CodeAgentCommandPermission =\n | { kind: \"read\" }\n | { kind: \"write\" }\n | { kind: \"approval-required\"; reason: string }\n | { kind: \"forbidden\"; reason: string };\n\nexport function classifyCodeAgentCommandPermission(\n command: string,\n): CodeAgentCommandPermission {\n const normalized = command.trim().toLowerCase();\n if (!normalized) return { kind: \"read\" };\n\n const blockedPatterns: Array<[RegExp, string]> = [\n [\n /\\bgit\\s+(checkout|switch|reset|rebase|stash|clean|worktree)\\b/,\n \"forbidden git branch/reset/stash/rebase operation\",\n ],\n [\n /\\bgit\\s+branch\\b(?!\\s+--show-current\\b)/,\n \"forbidden git branch operation\",\n ],\n [/\\bdrizzle-kit\\s+push\\b/, \"drizzle-kit push is not allowed\"],\n ];\n for (const [pattern, reason] of blockedPatterns) {\n if (pattern.test(normalized)) return { kind: \"forbidden\", reason };\n }\n\n const approvalPatterns: Array<[RegExp, string]> = [\n [/\\brm\\s+-rf\\b/, \"destructive recursive delete\"],\n [/\\bsudo\\b/, \"privileged command\"],\n [/\\bkill\\s+-9\\b/, \"force-kill command\"],\n [/\\bcurl\\b.*\\|\\s*(sh|bash|zsh)\\b/, \"remote script execution\"],\n [/\\b(wget|fetch)\\b.*\\|\\s*(sh|bash|zsh)\\b/, \"remote script execution\"],\n [/\\bnpm\\s+publish\\b/, \"package publish\"],\n [/\\bpnpm\\s+publish\\b/, \"package publish\"],\n [/\\btruncate\\b/, \"destructive data command\"],\n [/\\bdrop\\s+(table|column|database)\\b/, \"destructive database command\"],\n [/\\bdelete\\s+from\\b(?![\\s\\S]*\\bwhere\\b)/, \"unscoped delete command\"],\n ];\n for (const [pattern, reason] of approvalPatterns) {\n if (pattern.test(normalized)) {\n return { kind: \"approval-required\", reason };\n }\n }\n\n if (isReadOnlyShellCommand(command)) {\n return { kind: \"read\" };\n }\n\n const writePatterns = [\n /(^|[^>])>(?!>)/,\n />>/,\n /\\btee\\b/,\n /\\bapply_patch\\b/,\n /\\b(write|touch|mkdir|cp|mv|rm|chmod|chown)\\b/,\n /\\bpnpm\\s+(add|install|remove|dlx)\\b/,\n /\\bnpm\\s+(install|i|add|remove|uninstall)\\b/,\n ];\n if (writePatterns.some((pattern) => pattern.test(normalized))) {\n return { kind: \"write\" };\n }\n\n return { kind: \"write\" };\n}\n\nfunction permissionErrorForWrite(\n permissionMode: CodeAgentPermissionMode,\n toolName: string,\n): string | null {\n if (\n permissionMode === \"ask-before-edit\" ||\n permissionMode === \"auto-edit\" ||\n permissionMode === \"full-auto\"\n ) {\n return null;\n }\n if (permissionMode === \"read-only\") {\n return `Error: ${toolName} is unavailable in read-only mode.`;\n }\n return `Error: ${toolName} is blocked by the current run mode.`;\n}\n\nfunction requestCodeAgentApproval(\n runId: string,\n input: Omit<PendingCodeAgentApproval, \"id\" | \"requestedAt\">,\n): PendingCodeAgentApproval {\n const requestedAt = new Date().toISOString();\n const approval: PendingCodeAgentApproval = {\n id: `approval-${requestedAt.replace(/\\D/g, \"\").slice(0, 14)}`,\n requestedAt,\n ...input,\n };\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `Approval required: ${approval.reason}`,\n metadata: {\n status: \"needs-approval\",\n phase: \"approval-required\",\n pendingApproval: approval,\n },\n });\n updateCodeAgentRunRecord(runId, {\n status: \"needs-approval\",\n phase: \"approval-required\",\n needsApproval: true,\n progress: {\n label: \"Approval required\",\n completed: 0,\n total: 1,\n percent: 50,\n },\n metadata: {\n pendingApproval: approval,\n },\n });\n return approval;\n}\n\nfunction getPendingApproval(runId: string): PendingCodeAgentApproval | null {\n const record = getCodeAgentRunRecord(runId);\n const approval = record?.metadata?.pendingApproval;\n if (!approval || typeof approval !== \"object\") return null;\n const candidate = approval as Record<string, unknown>;\n const tool =\n candidate.tool === \"bash\" || candidate.tool === \"run_command\"\n ? candidate.tool\n : null;\n if (\n !tool ||\n typeof candidate.command !== \"string\" ||\n typeof candidate.reason !== \"string\" ||\n typeof candidate.id !== \"string\" ||\n typeof candidate.requestedAt !== \"string\"\n ) {\n return null;\n }\n return {\n id: candidate.id,\n tool,\n command: candidate.command,\n reason: candidate.reason,\n requestedAt: candidate.requestedAt,\n permissionMode:\n candidate.permissionMode === \"read-only\" ||\n candidate.permissionMode === \"ask-before-edit\" ||\n candidate.permissionMode === \"auto-edit\" ||\n candidate.permissionMode === \"full-auto\"\n ? candidate.permissionMode\n : \"full-auto\",\n };\n}\n"]}
|
|
1
|
+
{"version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AAS,CAAC,cAAc,KAAK,WAAW;YACxC,SAAS,CAAC,cAAc,KAAK,iBAAiB;YAC9C,SAAS,CAAC,cAAc,KAAK,WAAW;YACxC,SAAS,CAAC,cAAc,KAAK,WAAW;YACtC,CAAC,CAAC,SAAS,CAAC,cAAc;YAC1B,CAAC,CAAC,WAAW;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import {\n createToolSearchEntry,\n TOOL_SEARCH_ACTION_NAME,\n} from \"../agent/tool-search.js\";\nimport {\n createCodingToolRegistry,\n isReadOnlyShellCommand,\n runCodingCommand,\n truncateCodingOutput,\n} from \"../coding-tools/index.js\";\nimport {\n buildMergedConfig,\n McpClientManager,\n mcpToolsToActionEntries,\n} from \"../mcp-client/index.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport {\n actionsToEngineTools,\n runAgentLoop,\n type ActionEntry,\n} from \"../agent/production-agent.js\";\nimport {\n resolveEngine,\n getStoredModelForEngine,\n registerBuiltinEngines,\n} from \"../agent/engine/index.js\";\nimport type {\n AgentEngine,\n EngineContentPart,\n EngineEvent,\n EngineMessage,\n EngineStreamOptions,\n} from \"../agent/engine/types.js\";\nimport type { AgentChatEvent } from \"../agent/types.js\";\nimport { PROVIDER_ENV_VARS } from \"../agent/engine/provider-env-vars.js\";\nimport {\n isReasoningEffort,\n type ReasoningEffort,\n} from \"../shared/reasoning-effort.js\";\nimport {\n formatPromptWithAttachments,\n type AgentPromptAttachment,\n} from \"../code-agents/prompt-attachments.js\";\nimport {\n appendCodeAgentTranscriptEvent,\n dequeueCodeAgentFollowUp,\n getCodeAgentRunRecord,\n listCodeAgentTranscriptEvents,\n updateCodeAgentRunRecord,\n type CodeAgentPermissionMode,\n type CodeAgentRunRecord,\n} from \"./code-agent-runs.js\";\n\nexport interface ExecuteCodeAgentRunOptions {\n runId: string;\n prompt?: string;\n appendUserEvent?: boolean;\n engine?: AgentEngine;\n model?: string;\n reasoningEffort?: ReasoningEffort;\n attachments?: AgentPromptAttachment[];\n stdout?: NodeJS.WritableStream;\n signal?: AbortSignal;\n}\n\ninterface PendingCodeAgentApproval {\n id: string;\n tool: \"bash\" | \"run_command\";\n command: string;\n reason: string;\n requestedAt: string;\n permissionMode: CodeAgentPermissionMode;\n}\n\nconst DEFAULT_COMMAND_TIMEOUT_MS = 120_000;\nconst MAX_TOOL_OUTPUT_CHARS = 50_000;\nconst MAX_FILE_READ_CHARS = 120_000;\n\nexport async function executeCodeAgentRun(\n options: ExecuteCodeAgentRunOptions,\n): Promise<CodeAgentRunRecord | null> {\n const existing = getCodeAgentRunRecord(options.runId);\n if (!existing) return null;\n\n const prompt = options.prompt ?? latestUserPrompt(existing.id);\n const executionPrompt = formatPromptWithAttachments(\n prompt,\n options.attachments ?? latestUserPromptAttachments(existing.id, prompt),\n );\n if (!prompt) {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: \"No prompt was found for this Agent-Native Code run.\",\n metadata: { status: \"errored\", phase: \"missing-prompt\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"errored\",\n phase: \"missing-prompt\",\n progress: {\n label: \"Missing prompt\",\n completed: 0,\n total: 1,\n failed: 1,\n percent: 0,\n },\n });\n }\n\n if (options.appendUserEvent !== false) {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"user\",\n message: prompt,\n metadata: { source: \"execution-prompt\" },\n });\n }\n\n const running = updateCodeAgentRunRecord(existing.id, {\n status: \"running\",\n phase: \"executing\",\n progress: {\n label: \"Running\",\n completed: 0,\n total: 1,\n percent: 10,\n },\n metadata: {\n executionStartedAt: new Date().toISOString(),\n },\n });\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: \"Agent-Native Code run started.\",\n metadata: { status: \"running\", phase: \"executing\" },\n });\n\n const requestedEngine = metadataString(existing, \"engine\");\n const engine =\n options.engine ?? (await resolveExecutorEngine(requestedEngine));\n if (!engine) {\n const message =\n \"No LLM provider key was found. Set ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, or another supported provider key and resume this run.\";\n options.stdout?.write(`${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message,\n metadata: { status: \"paused\", phase: \"missing-credentials\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"paused\",\n phase: \"missing-credentials\",\n needsApproval: false,\n progress: {\n label: \"Missing credentials\",\n completed: 0,\n total: 1,\n percent: 0,\n },\n });\n }\n\n const model =\n options.model ??\n metadataString(existing, \"model\") ??\n process.env.AGENT_MODEL ??\n (await getStoredModelForEngine(engine).catch(() => undefined)) ??\n engine.defaultModel;\n const reasoningEffort =\n options.reasoningEffort ?? metadataReasoningEffort(existing);\n const cwd = existing.cwd || process.cwd();\n const permissionMode = existing.permissionMode ?? \"full-auto\";\n const actions = createLocalCodeAgentActions(cwd, permissionMode, existing.id);\n const mcpManager = await startCodeAgentMcpManager(existing.id);\n if (mcpManager) {\n Object.assign(actions, mcpToolsToActionEntries(mcpManager));\n }\n actions[TOOL_SEARCH_ACTION_NAME] = createToolSearchEntry(() => actions);\n const tools = actionsToEngineTools(actions);\n const messages = buildCodeAgentMessages(existing, executionPrompt);\n const controller = new AbortController();\n const abortFromParent = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else\n options.signal.addEventListener(\"abort\", abortFromParent, { once: true });\n }\n\n let assistantText = \"\";\n const send = (event: AgentChatEvent) => {\n if (event.type === \"text\") {\n assistantText += event.text;\n options.stdout?.write(event.text);\n return;\n }\n if (event.type === \"activity\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: event.label,\n metadata: { type: \"activity\", tool: event.tool },\n });\n return;\n }\n if (event.type === \"tool_start\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: `Running ${event.tool}.`,\n metadata: { type: \"tool_start\", tool: event.tool, input: event.input },\n });\n return;\n }\n if (event.type === \"tool_done\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: `Finished ${event.tool}.`,\n metadata: {\n type: \"tool_done\",\n tool: event.tool,\n result: truncateCodingOutput(event.result, 4000),\n ...(event.mcpApp ? { mcpApp: event.mcpApp } : {}),\n },\n });\n return;\n }\n if (event.type === \"error\") {\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: event.error,\n metadata: { type: \"error\", errorCode: event.errorCode },\n });\n }\n };\n\n try {\n await runWithOptionalCodeAgentRequestContext(existing, () =>\n runAgentLoop({\n engine,\n model,\n systemPrompt: codeAgentSystemPrompt(cwd, permissionMode),\n tools,\n actions,\n messages,\n send,\n signal: controller.signal,\n maxIterations: 12,\n reasoningEffort,\n }),\n );\n if (assistantText.trim()) {\n options.stdout?.write(\"\\n\");\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"system\",\n message: assistantText.trim(),\n metadata: {\n role: \"assistant\",\n model,\n engine: engine.name,\n reasoningEffort,\n },\n });\n }\n const approvalPending = getPendingApproval(existing.id);\n if (approvalPending) {\n const message = `Agent-Native Code run paused for approval: ${approvalPending.reason}`;\n options.stdout?.write(`\\n${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message,\n metadata: {\n status: \"needs-approval\",\n phase: \"approval-required\",\n pendingApprovalId: approvalPending.id,\n },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"needs-approval\",\n phase: \"approval-required\",\n needsApproval: true,\n progress: {\n label: \"Approval required\",\n completed: 0,\n total: 1,\n percent: 50,\n },\n });\n }\n\n const pendingFollowUp = dequeueCodeAgentFollowUp(existing.id);\n if (pendingFollowUp) {\n const message =\n pendingFollowUp.mode === \"queued\"\n ? \"Agent-Native Code run completed; running queued follow-up.\"\n : \"Agent-Native Code run completed; applying steering follow-up.\";\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message,\n metadata: {\n status: \"running\",\n phase: \"follow-up\",\n followUpId: pendingFollowUp.id,\n followUpMode: pendingFollowUp.mode,\n },\n });\n if (pendingFollowUp.permissionMode) {\n updateCodeAgentRunRecord(existing.id, {\n permissionMode: pendingFollowUp.permissionMode,\n });\n }\n return executeCodeAgentRun({\n ...options,\n runId: existing.id,\n prompt: pendingFollowUp.prompt,\n attachments:\n pendingFollowUp.attachments ??\n userPromptAttachmentsForEvent(existing.id, pendingFollowUp.eventId),\n appendUserEvent: false,\n });\n }\n\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: \"Agent-Native Code run completed.\",\n metadata: { status: \"completed\", phase: \"complete\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: \"completed\",\n phase: \"complete\",\n needsApproval: false,\n progress: {\n label: \"Complete\",\n completed: 1,\n total: 1,\n percent: 100,\n },\n metadata: {\n executionCompletedAt: new Date().toISOString(),\n engine: engine.name,\n model,\n reasoningEffort,\n permissionMode,\n },\n });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n options.stdout?.write(`\\nAgent-Native Code run failed: ${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId: existing.id,\n kind: \"status\",\n message: `Agent-Native Code run failed: ${message}`,\n metadata: { status: \"errored\", phase: \"error\" },\n });\n return updateCodeAgentRunRecord(existing.id, {\n status: controller.signal.aborted ? \"paused\" : \"errored\",\n phase: controller.signal.aborted ? \"paused\" : \"error\",\n progress: {\n label: controller.signal.aborted ? \"Paused\" : \"Error\",\n completed: 0,\n total: 1,\n failed: controller.signal.aborted ? 0 : 1,\n percent: 0,\n },\n metadata: {\n executionError: message,\n executionErroredAt: new Date().toISOString(),\n },\n });\n } finally {\n options.signal?.removeEventListener(\"abort\", abortFromParent);\n await mcpManager?.stop().catch(() => undefined);\n void running;\n }\n}\n\nexport async function executeExistingCodeAgentRun(\n runId: string,\n options: Omit<ExecuteCodeAgentRunOptions, \"runId\"> = {},\n): Promise<CodeAgentRunRecord | null> {\n return executeCodeAgentRun({ ...options, runId, appendUserEvent: false });\n}\n\nexport async function executePendingCodeAgentApproval(\n runId: string,\n options: { stdout?: NodeJS.WritableStream } = {},\n): Promise<CodeAgentRunRecord | null> {\n const record = getCodeAgentRunRecord(runId);\n if (!record) return null;\n const approval = getPendingApproval(runId);\n if (!approval) {\n options.stdout?.write(\"No pending approval was found for this run.\\n\");\n return record;\n }\n\n const permission = classifyCodeAgentCommandPermission(approval.command);\n if (permission.kind === \"forbidden\") {\n const message = `Approval cannot run forbidden command: ${permission.reason}`;\n options.stdout?.write(`${message}\\n`);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message,\n metadata: {\n status: \"needs-approval\",\n phase: \"approval-forbidden\",\n approvalId: approval.id,\n },\n });\n return updateCodeAgentRunRecord(runId, {\n status: \"needs-approval\",\n phase: \"approval-forbidden\",\n needsApproval: true,\n });\n }\n\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `Approved command ${approval.id}; running now.`,\n metadata: {\n status: \"running\",\n phase: \"approval-running\",\n approvalId: approval.id,\n command: approval.command,\n },\n });\n const result = await runCodingCommand(\n approval.command,\n record.cwd || process.cwd(),\n DEFAULT_COMMAND_TIMEOUT_MS,\n );\n const summary = truncateCodingOutput(\n [\n `Approved command finished with exit code ${result.code}.`,\n result.timedOut ? \"Timed out: true\" : \"\",\n result.stdout ? `stdout:\\n${result.stdout}` : \"\",\n result.stderr ? `stderr:\\n${result.stderr}` : \"\",\n ]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n MAX_TOOL_OUTPUT_CHARS,\n );\n options.stdout?.write(`${summary}\\n`);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: summary,\n metadata: {\n status: result.code === 0 ? \"paused\" : \"errored\",\n phase: \"approval-complete\",\n approvalId: approval.id,\n exitCode: result.code,\n timedOut: result.timedOut,\n },\n });\n return updateCodeAgentRunRecord(runId, {\n status: result.code === 0 ? \"paused\" : \"errored\",\n phase: result.code === 0 ? \"approval-complete\" : \"approval-command-error\",\n needsApproval: false,\n progress: {\n label: result.code === 0 ? \"Approval complete\" : \"Approval failed\",\n completed: result.code === 0 ? 1 : 0,\n total: 1,\n failed: result.code === 0 ? 0 : 1,\n percent: result.code === 0 ? 100 : 0,\n },\n metadata: {\n pendingApproval: undefined,\n lastApproval: {\n ...approval,\n completedAt: new Date().toISOString(),\n exitCode: result.code,\n },\n },\n });\n}\n\nfunction latestUserPrompt(runId: string): string {\n const events = listCodeAgentTranscriptEvents(runId);\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n if (event.kind === \"user\" && event.message.trim()) return event.message;\n }\n return \"\";\n}\n\nfunction latestUserPromptAttachments(\n runId: string,\n prompt: string,\n): AgentPromptAttachment[] {\n const events = listCodeAgentTranscriptEvents(runId);\n const normalizedPrompt = prompt.trim();\n for (let i = events.length - 1; i >= 0; i--) {\n const event = events[i];\n if (event.kind !== \"user\" || !event.message.trim()) continue;\n if (\n !normalizedPrompt ||\n event.message.trim() === normalizedPrompt ||\n i === events.length - 1\n ) {\n return promptAttachmentsFromMetadata(event.metadata?.attachments);\n }\n }\n return [];\n}\n\nfunction userPromptAttachmentsForEvent(\n runId: string,\n eventId: string | undefined,\n): AgentPromptAttachment[] {\n if (!eventId) return [];\n const event = listCodeAgentTranscriptEvents(runId).find(\n (item) => item.id === eventId && item.kind === \"user\",\n );\n return promptAttachmentsFromMetadata(event?.metadata?.attachments);\n}\n\nfunction promptAttachmentsFromMetadata(\n value: unknown,\n): AgentPromptAttachment[] {\n if (!Array.isArray(value)) return [];\n return value\n .filter((item): item is Record<string, unknown> =>\n Boolean(item && typeof item === \"object\" && !Array.isArray(item)),\n )\n .map((item) => ({\n name: typeof item.name === \"string\" && item.name ? item.name : \"file\",\n ...(typeof item.type === \"string\" ? { type: item.type } : {}),\n ...(typeof item.size === \"number\" ? { size: item.size } : {}),\n ...(typeof item.text === \"string\" ? { text: item.text } : {}),\n ...(typeof item.dataUrl === \"string\" ? { dataUrl: item.dataUrl } : {}),\n }));\n}\n\nfunction metadataString(\n run: CodeAgentRunRecord,\n key: string,\n): string | undefined {\n const value = run.metadata?.[key];\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nasync function startCodeAgentMcpManager(\n runId: string,\n): Promise<McpClientManager | null> {\n const config = await buildMergedConfig().catch((err) => {\n const message = err instanceof Error ? err.message : String(err);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `MCP tools unavailable: ${message}`,\n metadata: { type: \"mcp-config-error\" },\n });\n return null;\n });\n if (!config || Object.keys(config.servers ?? {}).length === 0) return null;\n\n const manager = new McpClientManager(config);\n await manager.start().catch((err) => {\n const message = err instanceof Error ? err.message : String(err);\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `MCP tools failed to start: ${message}`,\n metadata: { type: \"mcp-start-error\" },\n });\n });\n const status = manager.getStatus();\n if (status.totalTools === 0) {\n await manager.stop().catch(() => undefined);\n return null;\n }\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `Connected ${status.totalTools} MCP tool${status.totalTools === 1 ? \"\" : \"s\"} for this run.`,\n metadata: {\n type: \"mcp-tools-connected\",\n servers: status.connectedServers,\n toolCount: status.totalTools,\n },\n });\n return manager;\n}\n\nfunction runWithOptionalCodeAgentRequestContext<T>(\n run: CodeAgentRunRecord,\n fn: () => T | Promise<T>,\n): T | Promise<T> {\n const userEmail =\n metadataString(run, \"ownerEmail\") ??\n metadataString(run, \"userEmail\") ??\n process.env.AGENT_USER_EMAIL;\n const orgId = metadataString(run, \"orgId\") ?? process.env.AGENT_ORG_ID;\n if (!userEmail && !orgId) return fn();\n return runWithRequestContext({ userEmail, orgId }, fn);\n}\n\nfunction metadataReasoningEffort(\n run: CodeAgentRunRecord,\n): ReasoningEffort | undefined {\n const value = run.metadata?.reasoningEffort ?? run.metadata?.effort;\n return isReasoningEffort(value) && value !== \"auto\" ? value : undefined;\n}\n\nasync function resolveExecutorEngine(\n requestedEngine?: string,\n): Promise<AgentEngine | null> {\n const fakeText = process.env.AGENT_NATIVE_CODE_AGENT_FAKE_RESPONSE;\n if (fakeText !== undefined) {\n return createFakeCodeAgentEngine(fakeText || \"Done.\");\n }\n registerBuiltinEngines();\n if (!hasAnyProviderCredential()) return null;\n return resolveEngine({\n engineOption: requestedEngine ?? process.env.AGENT_ENGINE,\n });\n}\n\nfunction hasAnyProviderCredential(): boolean {\n if (process.env.AGENT_ENGINE) return true;\n if (PROVIDER_ENV_VARS.some((key) => Boolean(process.env[key]))) return true;\n return Boolean(\n process.env.BUILDER_PRIVATE_KEY && process.env.BUILDER_PUBLIC_KEY,\n );\n}\n\nfunction createFakeCodeAgentEngine(text: string): AgentEngine {\n return {\n name: \"fake-code-agent\",\n label: \"Fake Agent-Native Code\",\n defaultModel: \"fake-code-agent\",\n supportedModels: [\"fake-code-agent\"],\n capabilities: {\n thinking: false,\n promptCaching: false,\n vision: false,\n computerUse: false,\n parallelToolCalls: false,\n },\n async *stream(_opts: EngineStreamOptions): AsyncIterable<EngineEvent> {\n yield { type: \"text-delta\", text };\n yield {\n type: \"assistant-content\",\n parts: [{ type: \"text\", text }],\n };\n yield {\n type: \"usage\",\n inputTokens: 1,\n outputTokens: 1,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n };\n yield { type: \"stop\", reason: \"end_turn\" };\n },\n };\n}\n\nfunction buildCodeAgentMessages(\n run: CodeAgentRunRecord,\n prompt: string,\n): EngineMessage[] {\n const transcript = listCodeAgentTranscriptEvents(run.id)\n .slice(-40)\n .map((event) => {\n const label =\n event.kind === \"user\"\n ? \"User\"\n : event.metadata?.role === \"assistant\"\n ? \"Assistant\"\n : event.kind;\n return `${label}: ${event.message}`;\n })\n .join(\"\\n\");\n const context = transcript\n ? `\\n\\nPrevious session transcript:\\n${transcript}`\n : \"\";\n return [\n {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: `${prompt}${context}`,\n },\n ],\n },\n ];\n}\n\nfunction codeAgentSystemPrompt(\n cwd: string,\n permissionMode: CodeAgentPermissionMode,\n): string {\n const mode = permissionMode === \"read-only\" ? \"Plan\" : \"Auto\";\n return `You are Agent-Native Code, a coding agent running in ${cwd}. You and the user share one workspace, and your job is to collaborate with them until their goal is genuinely handled.\n\n# General\n\nYou bring a senior engineer's judgment to the work, but you let it arrive through attention rather than premature certainty. Read the codebase first, resist easy assumptions, and let the shape of the existing system teach you how to move.\n\n- When you search for text or files, reach first for \\`rg\\` or \\`rg --files\\`; they are much faster than \\`grep\\` or \\`find\\`. If \\`rg\\` is unavailable, use the next best tool without fuss.\n- Parallelize independent read-only work (file reads, searches) so you gather context quickly. Keep mutating steps ordered.\n- Read relevant files before editing them. Do not edit a file you have not actually read.\n\n# Engineering judgment\n\nWhen the user leaves implementation details open, choose conservatively and in sympathy with the codebase already in front of you:\n\n- Prefer the repo's existing patterns, frameworks, and local helper APIs over inventing a new abstraction.\n- For structured data, use structured APIs or parsers instead of ad hoc string manipulation when the toolchain gives you a reasonable option.\n- Keep edits closely scoped to what the request and surrounding code imply. Leave unrelated refactors and metadata churn alone unless they are truly needed to finish safely.\n- Add an abstraction only when it removes real complexity, reduces meaningful duplication, or clearly matches an established local pattern.\n- Let test coverage scale with risk and blast radius: focused for narrow changes, broader when you touch shared behavior or cross-module contracts.\n\n# Run mode\n\nCurrent run mode: ${mode} mode (${permissionMode}).\n- In Plan mode, inspect and explain only — do not edit files or run mutating commands.\n- In Auto mode, edit files and run ordinary project commands without pausing. Pause only for genuinely destructive operations: recursive deletes, package publishing, privileged commands, destructive database operations, or forbidden git branch/reset/stash/rebase operations.\n\n# Editing constraints\n\n- Use the shared coding tools: \\`bash\\` for search/list/test/build/git-status commands, \\`read\\` for file reads, \\`edit\\` for exact-match replacements, and \\`write\\` only for new files or an intentional full rewrite. Prefer \\`edit\\` over \\`write\\` for existing files.\n- Default to ASCII when editing or creating files; introduce non-ASCII only when the file already uses it or there is a clear reason.\n- Add succinct comments only where the code is not self-explanatory. Avoid empty narration like \"assign the value\"; a short orienting comment before a complex block is fine, used sparingly.\n- You may be in a dirty git worktree. NEVER revert or overwrite changes you did not make — assume they came from the user or another concurrent agent. If unrelated changes exist, ignore them; if they touch your task, work *with* them rather than undoing them. Only stop and ask if they make the task impossible.\n- If you notice unexpected changes appearing mid-task that you did not make, STOP and ask the user how to proceed rather than guessing.\n- Do not create, switch, delete, reset, rebase, or stash git branches. Never run destructive git commands (\\`git reset --hard\\`, \\`git checkout --\\`, \\`git clean\\`) unless the user explicitly asked for that exact operation.\n\n# Autonomy and verification\n\n- Stay with the work until the task is handled end to end within this turn whenever feasible. Don't stop at analysis or a proposal — implement the fix, and work through blockers yourself before handing them back. The exception is Plan mode, where you propose only.\n- Done means verified, not generated. After code changes (not docs-only), run the repo's checks before reporting success: \\`pnpm run prep\\` (format + typecheck + test + guards), or a focused subset like \\`pnpm typecheck\\` or a single package's tests for a small change. Fix all errors before you call it done.\n- Do not claim a change works, tests pass, or a build succeeds unless you actually ran it and saw the result. If you could not verify something, say exactly what is unverified and why.\n\n# Tools beyond the basics\n\n- Use \\`tool-search\\` when you need a capability that may come from MCP, including browser automation or computer control.\n- Prefer Playwright MCP for deterministic browser testing; prefer Chrome DevTools MCP when the user needs their live logged-in Chrome session.\n- Only use computer-control MCP tools when they are explicitly available and the request warrants controlling the local computer.\n\n# Final answer\n\n- Keep it concise and high-signal — plain, idiomatic engineering prose, not a mechanical report. Lead with the outcome. For a small change, one or two short paragraphs plus a verification line is usually right; reserve bullet lists for genuinely multi-part results.\n- Reference files as clickable paths (e.g. \\`packages/core/src/foo.ts\\`), with a line number when it helps. Do not paste large file contents back — the user shares this machine and can open them.\n- State what you changed, and show evidence you verified it: name the check you ran (e.g. \\`pnpm typecheck\\`) and its key result, not just a claim that it passed. If you could not run something, say so plainly.\n- No emojis or em dashes unless the user used them first.\n- Respect any AGENTS.md instructions in the repository; they override these defaults on conflict.`;\n}\n\nfunction createLocalCodeAgentActions(\n cwd: string,\n permissionMode: CodeAgentPermissionMode,\n runId: string,\n): Record<string, ActionEntry> {\n const actions = createCodingToolRegistry({\n cwd,\n restrictToCwd: true,\n commandTimeoutMs: DEFAULT_COMMAND_TIMEOUT_MS,\n maxOutputChars: MAX_TOOL_OUTPUT_CHARS,\n maxFileReadChars: MAX_FILE_READ_CHARS,\n canWrite: (toolName) => permissionErrorForWrite(permissionMode, toolName),\n beforeBash: ({ command }) => {\n const permission = classifyCodeAgentCommandPermission(command);\n if (permission.kind === \"forbidden\") {\n return `Error: command is blocked by Agent-Native Code policy: ${permission.reason}`;\n }\n if (permission.kind !== \"read\") {\n const permissionError = permissionErrorForWrite(permissionMode, \"bash\");\n if (permissionError) return permissionError;\n }\n if (permission.kind === \"approval-required\") {\n const approval = requestCodeAgentApproval(runId, {\n tool: \"bash\",\n command,\n reason: permission.reason,\n permissionMode,\n });\n return [\n `Approval required before running this command: ${permission.reason}.`,\n `Approval id: ${approval.id}`,\n `Command: ${command}`,\n \"The run is paused; approve from the Agent-Native Code UI/CLI if this command is intentional.\",\n ].join(\"\\n\");\n }\n return null;\n },\n });\n if (permissionMode === \"read-only\") {\n return {\n bash: actions.bash,\n read: actions.read,\n };\n }\n return actions;\n}\n\nexport type CodeAgentCommandPermission =\n | { kind: \"read\" }\n | { kind: \"write\" }\n | { kind: \"approval-required\"; reason: string }\n | { kind: \"forbidden\"; reason: string };\n\nexport function classifyCodeAgentCommandPermission(\n command: string,\n): CodeAgentCommandPermission {\n const normalized = command.trim().toLowerCase();\n if (!normalized) return { kind: \"read\" };\n\n const blockedPatterns: Array<[RegExp, string]> = [\n [\n /\\bgit\\s+(checkout|switch|reset|rebase|stash|clean|worktree)\\b/,\n \"forbidden git branch/reset/stash/rebase operation\",\n ],\n [\n /\\bgit\\s+branch\\b(?!\\s+--show-current\\b)/,\n \"forbidden git branch operation\",\n ],\n [/\\bdrizzle-kit\\s+push\\b/, \"drizzle-kit push is not allowed\"],\n ];\n for (const [pattern, reason] of blockedPatterns) {\n if (pattern.test(normalized)) return { kind: \"forbidden\", reason };\n }\n\n const approvalPatterns: Array<[RegExp, string]> = [\n [/\\brm\\s+-rf\\b/, \"destructive recursive delete\"],\n [/\\bsudo\\b/, \"privileged command\"],\n [/\\bkill\\s+-9\\b/, \"force-kill command\"],\n [/\\bcurl\\b.*\\|\\s*(sh|bash|zsh)\\b/, \"remote script execution\"],\n [/\\b(wget|fetch)\\b.*\\|\\s*(sh|bash|zsh)\\b/, \"remote script execution\"],\n [/\\bnpm\\s+publish\\b/, \"package publish\"],\n [/\\bpnpm\\s+publish\\b/, \"package publish\"],\n [/\\btruncate\\b/, \"destructive data command\"],\n [/\\bdrop\\s+(table|column|database)\\b/, \"destructive database command\"],\n [/\\bdelete\\s+from\\b(?![\\s\\S]*\\bwhere\\b)/, \"unscoped delete command\"],\n ];\n for (const [pattern, reason] of approvalPatterns) {\n if (pattern.test(normalized)) {\n return { kind: \"approval-required\", reason };\n }\n }\n\n if (isReadOnlyShellCommand(command)) {\n return { kind: \"read\" };\n }\n\n const writePatterns = [\n /(^|[^>])>(?!>)/,\n />>/,\n /\\btee\\b/,\n /\\bapply_patch\\b/,\n /\\b(write|touch|mkdir|cp|mv|rm|chmod|chown)\\b/,\n /\\bpnpm\\s+(add|install|remove|dlx)\\b/,\n /\\bnpm\\s+(install|i|add|remove|uninstall)\\b/,\n ];\n if (writePatterns.some((pattern) => pattern.test(normalized))) {\n return { kind: \"write\" };\n }\n\n return { kind: \"write\" };\n}\n\nfunction permissionErrorForWrite(\n permissionMode: CodeAgentPermissionMode,\n toolName: string,\n): string | null {\n if (\n permissionMode === \"ask-before-edit\" ||\n permissionMode === \"auto-edit\" ||\n permissionMode === \"full-auto\"\n ) {\n return null;\n }\n if (permissionMode === \"read-only\") {\n return `Error: ${toolName} is unavailable in read-only mode.`;\n }\n return `Error: ${toolName} is blocked by the current run mode.`;\n}\n\nfunction requestCodeAgentApproval(\n runId: string,\n input: Omit<PendingCodeAgentApproval, \"id\" | \"requestedAt\">,\n): PendingCodeAgentApproval {\n const requestedAt = new Date().toISOString();\n const approval: PendingCodeAgentApproval = {\n id: `approval-${requestedAt.replace(/\\D/g, \"\").slice(0, 14)}`,\n requestedAt,\n ...input,\n };\n appendCodeAgentTranscriptEvent({\n runId,\n kind: \"status\",\n message: `Approval required: ${approval.reason}`,\n metadata: {\n status: \"needs-approval\",\n phase: \"approval-required\",\n pendingApproval: approval,\n },\n });\n updateCodeAgentRunRecord(runId, {\n status: \"needs-approval\",\n phase: \"approval-required\",\n needsApproval: true,\n progress: {\n label: \"Approval required\",\n completed: 0,\n total: 1,\n percent: 50,\n },\n metadata: {\n pendingApproval: approval,\n },\n });\n return approval;\n}\n\nfunction getPendingApproval(runId: string): PendingCodeAgentApproval | null {\n const record = getCodeAgentRunRecord(runId);\n const approval = record?.metadata?.pendingApproval;\n if (!approval || typeof approval !== \"object\") return null;\n const candidate = approval as Record<string, unknown>;\n const tool =\n candidate.tool === \"bash\" || candidate.tool === \"run_command\"\n ? candidate.tool\n : null;\n if (\n !tool ||\n typeof candidate.command !== \"string\" ||\n typeof candidate.reason !== \"string\" ||\n typeof candidate.id !== \"string\" ||\n typeof candidate.requestedAt !== \"string\"\n ) {\n return null;\n }\n return {\n id: candidate.id,\n tool,\n command: candidate.command,\n reason: candidate.reason,\n requestedAt: candidate.requestedAt,\n permissionMode:\n candidate.permissionMode === \"read-only\" ||\n candidate.permissionMode === \"ask-before-edit\" ||\n candidate.permissionMode === \"auto-edit\" ||\n candidate.permissionMode === \"full-auto\"\n ? candidate.permissionMode\n : \"full-auto\",\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantChat.d.ts","sourceRoot":"","sources":["../../src/client/AssistantChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAaf,OAAO,KAAK,EAEV,gBAAgB,EAEhB,yBAAyB,EAI1B,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAEL,KAAK,oBAA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AC,CAAC;IACxE,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAEjD,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,QAI9C;AAqCD,OAAO,EACL,iBAAiB,EAElB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,CAAC;AA01D7B,eAAO,MAAM,aAAa,gGAuFxB,CAAC"}
|
|
@@ -21,6 +21,7 @@ import { useBuilderConnectFlow } from "./settings/useBuilderStatus.js";
|
|
|
21
21
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "./components/ui/tooltip.js";
|
|
22
22
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "./components/ui/dropdown-menu.js";
|
|
23
23
|
import { IframeEmbed, parseEmbedBody } from "./IframeEmbed.js";
|
|
24
|
+
import { GuidedQuestionFlow, useGuidedQuestionFlow, } from "./guided-questions.js";
|
|
24
25
|
import { useDevMode } from "./use-dev-mode.js";
|
|
25
26
|
import { agentNativePath } from "./api-path.js";
|
|
26
27
|
import { BUILDER_SPACE_SETTINGS_URL, NEW_CHAT_ACTION_HREF, } from "./error-format.js";
|
|
@@ -2969,6 +2970,16 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2969
2970
|
!authError &&
|
|
2970
2971
|
!missingApiKey;
|
|
2971
2972
|
const centeredEmptyState = centerComposerWhenEmpty && isFreshEmptyChat;
|
|
2973
|
+
// Clarifying-question surface: the `ask-question` action writes a
|
|
2974
|
+
// GuidedQuestionPayload to application_state under "guided-questions". The
|
|
2975
|
+
// hook polls that key, and on submit/skip composes the answer as a normal
|
|
2976
|
+
// user turn (via the shared sendToAgentChat) and clears the persisted key so
|
|
2977
|
+
// the question does not reappear.
|
|
2978
|
+
const { questions: guidedQuestions, title: guidedQuestionsTitle, description: guidedQuestionsDescription, skipLabel: guidedQuestionsSkipLabel, submitLabel: guidedQuestionsSubmitLabel, handleSubmit: handleGuidedQuestionsSubmit, handleSkip: handleGuidedQuestionsSkip, } = useGuidedQuestionFlow({
|
|
2979
|
+
stateKey: "guided-questions",
|
|
2980
|
+
queryKey: ["guided-questions"],
|
|
2981
|
+
...(browserTabId ? { browserTabId } : {}),
|
|
2982
|
+
});
|
|
2972
2983
|
return (_jsx(CheckpointContext.Provider, { value: checkpointCtx, children: _jsx(MessageActionsContext.Provider, { value: messageActionsCtx, children: _jsx(ChatRunningContext.Provider, { value: isRunning, children: _jsxs("div", { "data-agent-empty-state": centeredEmptyState ? "centered" : undefined, className: cn("relative flex flex-1 flex-col h-full min-h-0 text-foreground", className), onDragEnter: handleChatDragEnter, onDragOver: handleChatDragOver, onDragLeave: handleChatDragLeave, onDropCapture: handleChatDropCapture, onDrop: handleChatDrop, children: [dropActive && (_jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-md border-2 border-dashed border-primary/70 bg-primary/5 backdrop-blur-[1px]", children: _jsx("span", { className: "rounded-md bg-background/90 px-3 py-1.5 text-xs font-medium text-foreground shadow-sm", children: "Drop to attach" }) })), showHeader && (_jsxs("div", { className: "flex h-11 shrink-0 items-center justify-between border-b border-border px-4", children: [_jsx("span", { className: "text-[13px] font-medium text-muted-foreground", children: "Agent" }), _jsx("div", { className: "flex items-center gap-1", children: onSwitchToCli && (_jsx(TooltipProvider, { delayDuration: 200, children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { onClick: onSwitchToCli, "aria-label": "Switch to CLI", className: "flex items-center gap-1 text-[12px] text-muted-foreground hover:text-foreground px-2 py-1 rounded-md hover:bg-accent", children: [_jsx(IconTerminal, { className: "h-3.5 w-3.5" }), "CLI"] }) }), _jsx(TooltipContent, { children: "Switch to CLI" })] }) })) })] })), _jsx("div", { ref: scrollRef, className: "agent-chat-scroll flex-1 overflow-y-auto overflow-x-hidden min-h-0", children: authError ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full px-4 gap-3", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10", children: _jsx(IconLock, { className: "h-5 w-5 text-destructive" }) }), _jsxs("div", { className: "text-center max-w-[280px]", children: [_jsx("p", { className: "text-sm font-medium text-foreground mb-1", children: authSessionAvailable
|
|
2973
2984
|
? "Chat session needs refresh"
|
|
2974
2985
|
: authError.sessionExpired
|
|
@@ -3028,7 +3039,15 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3028
3039
|
.replace(/<context>[\s\S]*?<\/context>\n?/g, "")
|
|
3029
3040
|
.trim();
|
|
3030
3041
|
return (_jsx("div", { className: "flex justify-end group", children: _jsxs("div", { className: "relative max-w-[85%] rounded-lg bg-accent/50 text-foreground/60 px-3 py-2 text-sm leading-relaxed whitespace-pre-wrap break-words", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground mb-1 font-medium uppercase tracking-wide", children: [_jsx(IconClock, { className: "h-3 w-3" }), "Queued"] }), displayText, msg.images && msg.images.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: msg.images.map((img, j) => (_jsx("img", { src: img, alt: "", className: "h-12 w-12 rounded object-cover border border-border/50" }, j))) })), _jsx("button", { type: "button", onClick: () => setQueuedMessages((prev) => prev.filter((m) => m.id !== msg.id)), "aria-label": "Remove from queue", className: "absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-foreground hover:bg-accent shadow-sm", children: _jsx(IconX, { className: "h-3 w-3" }) })] }) }, msg.id));
|
|
3031
|
-
})] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), composerSlot,
|
|
3042
|
+
})] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), composerSlot, guidedQuestions && guidedQuestions.length > 0 && (_jsx("div", { className: "shrink-0 px-3 pb-2 pt-1", children: _jsx("div", { className: "rounded-lg border border-border bg-card/60 shadow-sm", children: _jsx(GuidedQuestionFlow, { questions: guidedQuestions, onSubmit: handleGuidedQuestionsSubmit, onSkip: handleGuidedQuestionsSkip, ...(guidedQuestionsTitle
|
|
3043
|
+
? { title: guidedQuestionsTitle }
|
|
3044
|
+
: {}), ...(guidedQuestionsDescription
|
|
3045
|
+
? { description: guidedQuestionsDescription }
|
|
3046
|
+
: {}), ...(guidedQuestionsSkipLabel
|
|
3047
|
+
? { skipLabel: guidedQuestionsSkipLabel }
|
|
3048
|
+
: {}), ...(guidedQuestionsSubmitLabel
|
|
3049
|
+
? { submitLabel: guidedQuestionsSubmitLabel }
|
|
3050
|
+
: {}), className: "h-auto items-stretch justify-stretch bg-transparent" }) }) })), showPlanModeCallout && (_jsx(PlanModeCallout, { canImplementPlan: canImplementPlan, onImplementPlan: handleImplementPlan, onSwitchToAct: handleSwitchToAct })), _jsx(SelectionAttachedPill, {}), showRunningInUI && (_jsx(RunningActivityStatus, { steps: activitySteps, label: isReconnecting
|
|
3032
3051
|
? "Reconnecting"
|
|
3033
3052
|
: (activityLabel ?? "Thinking") })), _jsxs(AgentComposerFrame, { layoutVariant: composerLayoutVariant, className: cn(composerAreaClassName, missingApiKey && "cursor-pointer", isComposerDisabled && "opacity-70"), onClick: missingApiKey
|
|
3034
3053
|
? () => setMissingKeyBouncePulse((p) => p + 1)
|