The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): Copilot's questions and permission prompts were unanswerable
0xken155ffef598709b
diff --git a/cli/src/engines/README.md b/cli/src/engines/README.mdindex b4ca71a04..238d7d71a 100644--- a/cli/src/engines/README.md+++ b/cli/src/engines/README.md@@ -300,6 +300,18 @@ conversation reports the last turn as still open and nothing is ever coming to c`turn_heartbeat` every second, indefinitely). Its pane knows — `? for shortcuts` when idle,`esc to cancel` while busy — so attach reads the pane once and closes the folded turn.+**A dialog you can read is not a dialog you can judge.** Copilot names the SUBJECT of a permission+prompt above the question, not in it: "Copilot is attempting to access the following URL:" over a+boxed value, then "Do you want to allow this access?" with a bare "Yes" as option 1. The shared parser+returns the question correctly and the device still gets a choice nobody can make — approving network+access without seeing the domain. Fold the subject into the question; leave the rows alone.++**And one silent run does not prove a prompt is absent.** Copilot gates on FOLDER trust first, so a+shell command in a trusted directory runs with no prompt at all — which reads exactly like "this+engine never asks". Its permission model is patterns (`shell(cmd)`, `write(path)`, `url(domain)`),+and it took a URL fetch to raise one. Find the condition that triggers the prompt before writing that+an engine has none.+**One process can change session underneath you.** Every engine here but Copilot starts a new processto switch conversations, so `bindObservedAgent` stops at the first `agent.sessionId` and never looksagain. Copilot's `/resume` switches IN PROCESS: same pid, same pane, different conversation — and thediff --git a/cli/src/engines/copilot/askQuestion.ts b/cli/src/engines/copilot/askQuestion.tsnew file mode 100644index 000000000..da033675c--- /dev/null+++ b/cli/src/engines/copilot/askQuestion.ts@@ -0,0 +1,66 @@+/**+ * Copilot's permission prompts name their SUBJECT above the question, not inside it.+ *+ * Measured on 1.0.80, unframed:+ *+ * Fetch web content+ * ─────────────────+ * Copilot is attempting to access the following URL:+ * ╭─────────────────────╮+ * │ https://example.com │+ * ╰─────────────────────╯+ * Do you want to allow this access?+ * ❯ 1. Yes+ * 2. Yes, and approve all URLs from "https://example.com" for the rest of the running session+ * …+ *+ * The shared parser reads that correctly and returns "Do you want to allow this access?" — which is+ * the question, exactly as it should. But on a device that is the whole prompt: four options, and no+ * way to see WHAT is being allowed. Row 1 is a bare "Yes". Approving network access without seeing+ * the domain is not a choice anyone can make well.+ *+ * So the subject is folded into the question. Nothing else is touched: the rows, the decline row and+ * the row numbering all stay as the shared parser produced them.+ */++import type { PaneView } from '../../lib/askQuestion.js'++const ESCAPES = /\u001b\[[0-9;:]*[A-Za-z]/g+/** `Copilot is attempting to access the following URL:` / `… to run the following command:` etc. */+const ATTEMPT = /Copilot is attempting to [^:]{0,60}:/i+const MAX_SUBJECT = 120++/**+ * The boxed value Copilot puts between "attempting to …:" and the question.+ *+ * Read from the RAW capture rather than the unframed text: unframing flattens the outer dialog border,+ * and the subject's own inner box is what makes it findable.+ */+export function copilotPromptSubject(capture: string): string | null {+ const lines = capture.replace(ESCAPES, '').split('\n').map((line) => line.trim())+ const start = lines.findIndex((line) => ATTEMPT.test(line))+ if (start === -1) return null+ const parts: string[] = []+ for (let i = start + 1; i < lines.length && i < start + 12; i++) {+ const line = lines[i]+ // Peel the outer dialog border first, then the subject's own box.+ const inner = line.replace(/^│\s*/, '').replace(/\s*│$/, '').trim()+ if (/^[╭╰├└┌]/.test(inner) || !inner) continue+ const value = inner.replace(/^│\s*/, '').replace(/\s*│$/, '').trim()+ if (!value) continue+ // The question itself ends the subject.+ if (/\?\s*$/.test(value)) break+ parts.push(value)+ if (parts.join(' ').length > MAX_SUBJECT) break+ }+ const subject = parts.join(' ').trim()+ return subject ? subject.slice(0, MAX_SUBJECT) : null+}++/** Fold the subject into the question so the device shows what is being approved. */+export function withCopilotSubject(view: PaneView, capture: string): PaneView {+ if (!view || view.kind !== 'question') return view+ const subject = copilotPromptSubject(capture)+ if (!subject || view.question.includes(subject)) return view+ return { ...view, question: `${view.question} — ${subject}` }+}diff --git a/cli/src/engines/copilot/normalizer.spec.ts b/cli/src/engines/copilot/normalizer.spec.tsindex 9a4c2e98b..16a46a771 100644--- a/cli/src/engines/copilot/normalizer.spec.ts+++ b/cli/src/engines/copilot/normalizer.spec.ts@@ -157,3 +157,46 @@ describe('the session a Copilot process is in', () => {expect(await copilotSessionForPid(home, 9999)).toBeNull() // another process holds nothing here})})++describe('the ask-user dialog', () => {+ it('maps the tool to the exact shared name', () => {+ // Anything else and it renders in the tool feed instead of as a question the device can answer.+ expect(copilotToolName('ask_user')).toBe('AskUserQuestion')+ })++ it('is read off a real pane once the box is peeled', async () => {+ const { parseEngineQuestionPane, parseQuestionPane } = await import('../../lib/askQuestion.js')+ const capture = readFileSync(fileURLToPath(new URL('../../lib/__fixtures__/question-copilot.txt', import.meta.url)), 'utf8')+ expect(parseQuestionPane(capture)).toBeNull() // the frame defeats the shared parser+ const view = parseEngineQuestionPane('copilot', capture)+ expect(view).not.toBeNull()+ const question = view as Extract<typeof view, { kind: 'question' }>+ expect(question.question).toBe('Which colour do you prefer?')+ expect(question.rows.map((r) => r.label)).toEqual(['Red', 'Green', 'Blue'])+ // "Other (type your answer)" is a free-text row: the device has no text input, so it must not be+ // offered as a choice.+ expect(question.typeRow?.label).toContain('Other')+ })+})++describe('the permission prompt', () => {+ const capture = () => readFileSync(fileURLToPath(new URL('../../lib/__fixtures__/permission-copilot.txt', import.meta.url)), 'utf8')++ it('names what is being approved, not just "allow this access?"', async () => {+ const { parseEngineQuestionPane } = await import('../../lib/askQuestion.js')+ const view = parseEngineQuestionPane('copilot', capture())+ const question = view as Extract<typeof view, { kind: 'question' }>+ expect(question.question).toContain('Do you want to allow this access?')+ // Row 1 is a bare "Yes": without the subject the device offers a choice nobody can judge.+ expect(question.question).toContain('https://example.com')+ })++ it('keeps a way to say NO', async () => {+ const { parseEngineQuestionPane } = await import('../../lib/askQuestion.js')+ const view = parseEngineQuestionPane('copilot', capture())+ const question = view as Extract<typeof view, { kind: 'question' }>+ // Three ways to approve and none to refuse means the prompt cannot be answered at all.+ expect(question.rows.some((r) => /^No\b/i.test(r.label))).toBe(true)+ expect(question.rows).toHaveLength(4)+ })+})diff --git a/cli/src/engines/copilot/normalizer.ts b/cli/src/engines/copilot/normalizer.tsindex 40001f8c5..84a0c396e 100644--- a/cli/src/engines/copilot/normalizer.ts+++ b/cli/src/engines/copilot/normalizer.ts@@ -42,6 +42,9 @@ const TOOL_NAMES: Record<string, string> = {bash: 'Bash',create: 'Write',view: 'Read',+ // Must be exactly `AskUserQuestion`, or the dialog renders as an ordinary card in the tool feed —+ // where nobody can answer it. Measured: it drew as "Asked user" from the Title-Case fallback.+ ask_user: 'AskUserQuestion',}export function copilotToolName(name: string): string {diff --git a/cli/src/lib/__fixtures__/permission-copilot.txt b/cli/src/lib/__fixtures__/permission-copilot.txtnew file mode 100644index 000000000..dca710354--- /dev/null+++ b/cli/src/lib/__fixtures__/permission-copilot.txt@@ -0,0 +1,50 @@+ [1m[38;2;255;255;255m[48;2;9;105;218m Current [0m [38;2;177;186;196m[48;2;20;27;34m Sessions [39m[49m [2m[38;2;145;152;161m Issues [0m [2m[38;2;145;152;161m Pull requests [0m [38;2;177;186;196m[48;2;20;27;34m Gists [39m[49m++[38;2;48;148;255m ╭─╮╭─╮[39m+[38;2;48;148;255m ╰─╯╰─╯[39m [38;2;145;152;161mCopilot v1.0.80 uses AI.[39m+[38;2;133;52;243m █ [38;2;95;237;131m▘▝[38;2;133;52;243m █[39m [38;2;145;152;161mCheck for mistakes.[39m+[38;2;133;52;243m ▔▔▔▔ [39m++ [38;2;59;120;255m●[39m [38;2;180;180;180mTip: /skills[39m+ [38;2;145;152;161m└ Manage skills for enhanced capabilities[39m+ [38;2;20;27;34m▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄[39m+ [48;2;20;27;34m [38;2;240;246;252m❯ Fetch ]8;id=md-v03177;https://example.com\https://example.com]8;;\ and tell me the page title.[39m [38;2;145;152;161m14:55[39m [49m+ [38;2;20;27;34m▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀[39m+ [38;2;145;152;161m⌄[39m [3m[38;2;145;152;161mThought for 1s[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161mThe user is asking me to fetch ]8;id=md-v03177;https://example.com\https://example.com]8;;\ and tell them the page title. I should use the web_fetch tool to retrieve the page content.[0m+ [2m[38;2;145;152;161m│[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161mLet me call web_fetch with the URL ]8;id=md-v03177;https://example.com\https://example.com]8;;\.[0m++ [38;2;145;152;161m○[39m [1mFetching web content [0m[38;2;145;152;161m]8;id=md-v03177;https://example.com\https://example.com]8;;\ · url: "]8;id=md-v03177;https://example.com\https://example.com]8;;\"[39m [38;2;145;152;161m38s[39m+++++++++++++++[38;2;61;68;77m╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮+│[39m [1m[38;2;240;246;252mFetch web content[0m [38;2;61;68;77m│+│[39m [38;2;61;68;77m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────[39m [38;2;61;68;77m│+│[39m Copilot is attempting to access the following URL: [38;2;61;68;77m│+│[39m [38;2;61;68;77m│+│[39m [38;2;61;68;77m╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮[39m [38;2;61;68;77m│+│[39m [38;2;61;68;77m│[39m https://example.com [38;2;61;68;77m│[39m [38;2;61;68;77m│+│[39m [38;2;61;68;77m╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯[39m [38;2;61;68;77m│+│[39m [38;2;61;68;77m│+│[39m Do you want to allow this access? [38;2;61;68;77m│+│[39m [38;2;61;68;77m│+│[39m [38;2;240;246;252m[48;2;20;27;34m❯[39m [38;2;240;246;252m1. Yes[39m [49m [38;2;61;68;77m│+│[39m 2. Yes, and approve all URLs from "https://example.com" for the rest of the running session [38;2;61;68;77m│+│[39m 3. Yes, and approve all URLs from "https://example.com" permanently [38;2;61;68;77m│+│[39m 4. No, and tell Copilot what to do differently (Esc to stop) [38;2;61;68;77m│+│[39m [38;2;61;68;77m│+│[39m [1m[38;2;145;152;161m↑/↓[0m[38;2;145;152;161m to navigate · [1menter[0m[38;2;145;152;161m to select · [1mesc[0m[38;2;145;152;161m to cancel[39m [38;2;61;68;77m│+╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯diff --git a/cli/src/lib/__fixtures__/question-copilot.txt b/cli/src/lib/__fixtures__/question-copilot.txtnew file mode 100644index 000000000..93dfd13fb--- /dev/null+++ b/cli/src/lib/__fixtures__/question-copilot.txt@@ -0,0 +1,50 @@+ [1m[38;2;255;255;255m[48;2;9;105;218m Current [0m [38;2;177;186;196m[48;2;20;27;34m Sessions [39m[49m [2m[38;2;145;152;161m Issues [0m [2m[38;2;145;152;161m Pull requests [0m [38;2;177;186;196m[48;2;20;27;34m Gists [39m[49m++[38;2;48;148;255m ╭─╮╭─╮[39m+[38;2;48;148;255m ╰─╯╰─╯[39m [38;2;145;152;161mCopilot v1.0.80 uses AI.[39m+[38;2;133;52;243m █ [38;2;95;237;131m▘▝[38;2;133;52;243m █[39m [38;2;145;152;161mCheck for mistakes.[39m+[38;2;133;52;243m ▔▔▔▔ [39m++ [38;2;59;120;255m●[39m [38;2;180;180;180mTip: /clear[39m+ [38;2;145;152;161m└ Abandon this session and start fresh[39m+ [38;2;20;27;34m▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄[39m+ [48;2;20;27;34m [38;2;240;246;252m❯ Ask me a multiple-choice question about which colour I prefer: red, green or blue. Use your ask-user tool and wait for my answer.[39m [38;2;145;152;161m14:49[39m [49m+ [38;2;20;27;34m▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀[39m+ [38;2;145;152;161m⌄[39m [3m[38;2;145;152;161mThought for 1s[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161mThe user wants me to ask them a multiple-choice question about their color preference using the ask_user tool. They want to choose between red, green, or blue. I should use the ask_user tool with[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161mthe choices parameter.[0m+ [2m[38;2;145;152;161m│[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161mLet me use the ask_user tool with:[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161m- question: A simple question asking about their color preference[0m+ [2m[38;2;145;152;161m│[0m [2;3m[38;2;145;152;161m- choices: ["Red", "Green", "Blue"][0m++ [38;2;145;152;161m○[39m [1mAsking user [0m[38;2;145;152;161mWhich colour do you prefer?[39m [38;2;145;152;161m37s[39m++++++++++++++++++[38;2;61;68;77m╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮+│[39m [1m[38;2;240;246;252mQuestion[0m [38;2;61;68;77m│+│[39m [38;2;61;68;77m────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────[39m [38;2;61;68;77m│+│[39m [38;2;180;180;180mWhich colour do you prefer?[39m [38;2;61;68;77m│+│[39m [38;2;61;68;77m│+│[39m [38;2;68;147;248m❯ 1. Red[39m [38;2;61;68;77m│+│[39m 2. Green [38;2;61;68;77m│+│[39m 3. Blue [38;2;61;68;77m│+│[39m 4. Other (type your answer) [38;2;61;68;77m│+│[39m [38;2;61;68;77m│+│[39m [1m[38;2;145;152;161m↑/↓[0m[38;2;145;152;161m to select · [1menter[0m[38;2;145;152;161m to confirm · [1mesc[0m[38;2;145;152;161m to cancel[39m [38;2;61;68;77m│+╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯diff --git a/cli/src/lib/askQuestion.ts b/cli/src/lib/askQuestion.tsindex 4c3542548..5da2d91c7 100644--- a/cli/src/lib/askQuestion.ts+++ b/cli/src/lib/askQuestion.ts@@ -30,6 +30,7 @@ import { parseCursorPermissionPane } from '../engines/cursor/askQuestion.js'import { parseDevinPermissionPane, parseDevinQuestionPane } from '../engines/devin/askQuestion.js'import { parseGrokQuestionPane } from '../engines/grok/askQuestion.js'import { parseAgyQuestionPane } from '../engines/agy/askQuestion.js'+import { withCopilotSubject } from '../engines/copilot/askQuestion.js'/** Device-facing question shape — byte-for-byte the hosted runtime’s `commanderQuestions()` output. */export interface ShapedQuestion {@@ -150,8 +151,14 @@ export function parseEngineQuestionPane(engine: AgentEngine, capture: string): P// shared parser cannot see. Its PERMISSION prompt is numbered rows under `Do you want to proceed?`// and the shared parser reads that one exactly, so it falls through.if (engine === 'agy') return parseAgyQuestionPane(capture) ?? parseQuestionPane(capture)- // Hermes and OpenCode paint Claude's dialog inside a box; peel the border and the shared parser fits.+ // Hermes, OpenCode and Copilot paint the dialog inside a box; peel the border and the shared parser+ // fits. Measured on Copilot: framed it returns null, unframed it reads the question, the three+ // options AND spots `4. Other (type your answer)` as the free-text row rather than an option.if (engine === 'hermes') return parseQuestionPane(unframe(capture))+ // Copilot boxes its dialog the same way, but names the SUBJECT of a permission prompt above the+ // question — "attempting to access the following URL:" over a boxed value. Without it the device+ // shows "Do you want to allow this access?" and a bare "Yes", with nothing to judge.+ if (engine === 'copilot') return withCopilotSubject(parseQuestionPane(unframe(capture)), capture)if (engine === 'opencode') {// OpenCode's PERMISSION prompt is the horizontal one kilo inherited from it — same `△ Permission// required` title, same `⇆ select · enter confirm` footer, same unnumbered rows. Measured: the live