@ken-jo/agent-connector 0.4.6 → 0.4.7
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/{action-EV63GAPY.js → action-YCU53FNE.js} +8 -8
- package/dist/{amazon-q-COAL3764.js → amazon-q-W574ZX35.js} +2 -2
- package/dist/{amp-XJQ4TDAU.js → amp-JPBQJJVM.js} +2 -2
- package/dist/{antigravity-AMKKKHS4.js → antigravity-VK2Y3FGV.js} +3 -3
- package/dist/{antigravity-cli-XERXEH5W.js → antigravity-cli-D4PCCUG2.js} +3 -3
- package/dist/{chunk-BMD7ANKF.js → chunk-2F5QH3D4.js} +36 -36
- package/dist/{chunk-5G4EPJ4Y.js → chunk-6RYPUR6O.js} +5 -5
- package/dist/{chunk-2X4EH2D7.js → chunk-7ECYDK5T.js} +2 -2
- package/dist/{chunk-QC5A3TFQ.js → chunk-CYOAH23F.js} +18 -18
- package/dist/{chunk-RQPKL62M.js → chunk-DT6Y7XBI.js} +2 -2
- package/dist/{chunk-QOGMDOUX.js → chunk-HAIMYUEY.js} +3 -3
- package/dist/{chunk-DCK5FADX.js → chunk-MDNX7HTN.js} +2 -2
- package/dist/{chunk-EXLS7BSI.js → chunk-NLFPH4S2.js} +10 -2
- package/dist/chunk-NLFPH4S2.js.map +1 -0
- package/dist/{chunk-CPLK7GTE.js → chunk-PFDUGDOA.js} +351 -34
- package/dist/chunk-PFDUGDOA.js.map +1 -0
- package/dist/{chunk-EROJDXMW.js → chunk-SDPIT4HW.js} +2 -2
- package/dist/{chunk-H67V7DEL.js → chunk-SPWFUHHK.js} +5 -5
- package/dist/{chunk-LQRAPXS4.js → chunk-TZQBASI7.js} +4 -2
- package/dist/chunk-TZQBASI7.js.map +1 -0
- package/dist/{chunk-SRVAA2VN.js → chunk-WFXWJITA.js} +2 -2
- package/dist/{chunk-MZF2YCXX.js → chunk-YQLQJZ7S.js} +2 -2
- package/dist/{claude-code-T2LPFNC3.js → claude-code-ROSIILTM.js} +36 -100
- package/dist/claude-code-ROSIILTM.js.map +1 -0
- package/dist/cli/sdk.js +4 -4
- package/dist/cli.js +1 -1
- package/dist/{cline-WRYMNS7Z.js → cline-JUTO4V27.js} +2 -2
- package/dist/{codebuff-PODYPOOP.js → codebuff-2QUHL6HO.js} +2 -2
- package/dist/{codex-O4G7D7KK.js → codex-YBBTIDD4.js} +91 -112
- package/dist/codex-YBBTIDD4.js.map +1 -0
- package/dist/{continue-K43SUHLQ.js → continue-W4TU4JSB.js} +5 -3
- package/dist/continue-W4TU4JSB.js.map +1 -0
- package/dist/{copilot-cli-Q3SSPT4V.js → copilot-cli-Y74SOP5G.js} +4 -2
- package/dist/copilot-cli-Y74SOP5G.js.map +1 -0
- package/dist/{crush-MBEH2R3I.js → crush-GMEWLXK5.js} +4 -2
- package/dist/{crush-MBEH2R3I.js.map → crush-GMEWLXK5.js.map} +1 -1
- package/dist/{cursor-TMBXDYR4.js → cursor-JBS4B3Q4.js} +50 -134
- package/dist/cursor-JBS4B3Q4.js.map +1 -0
- package/dist/{detect-AHJIUMBO.js → detect-2NIXILMZ.js} +4 -4
- package/dist/{doctor-G5MLCPAB.js → doctor-QWJBWALA.js} +8 -8
- package/dist/{droid-JC2NT6S4.js → droid-TJMTNCQE.js} +48 -106
- package/dist/droid-TJMTNCQE.js.map +1 -0
- package/dist/{gemini-cli-ILR7M5X3.js → gemini-cli-RAONGZRG.js} +7 -2
- package/dist/gemini-cli-RAONGZRG.js.map +1 -0
- package/dist/{goose-SFO5BBGW.js → goose-G4KKM6YU.js} +91 -131
- package/dist/goose-G4KKM6YU.js.map +1 -0
- package/dist/{hermes-3N7WN4WS.js → hermes-PJDTJE6F.js} +29 -33
- package/dist/hermes-PJDTJE6F.js.map +1 -0
- package/dist/{hook-76JBKTUX.js → hook-FDGIQPRC.js} +8 -8
- package/dist/index.js +2 -2
- package/dist/{install-R7252QFH.js → install-TLG3QVP3.js} +8 -8
- package/dist/{jetbrains-copilot-NRZHI5PC.js → jetbrains-copilot-DNXSLQE5.js} +4 -2
- package/dist/jetbrains-copilot-DNXSLQE5.js.map +1 -0
- package/dist/{kilo-IX4T3OHJ.js → kilo-FERJ3X46.js} +2 -2
- package/dist/{kilo-cli-2AYCXBQD.js → kilo-cli-TDCONH5G.js} +2 -2
- package/dist/{kimi-2YFK2GBA.js → kimi-RIRD4J5J.js} +12 -2
- package/dist/kimi-RIRD4J5J.js.map +1 -0
- package/dist/{kiro-YL6AWUYG.js → kiro-X7JVLAN7.js} +4 -2
- package/dist/kiro-X7JVLAN7.js.map +1 -0
- package/dist/{leaderboard-V6VWA5ZV.js → leaderboard-MXGENYXN.js} +2 -2
- package/dist/{mimo-code-FTMGSKMQ.js → mimo-code-RFLQ727H.js} +2 -2
- package/dist/{mux-5XZFB44C.js → mux-D77HBSBU.js} +3 -17
- package/dist/mux-D77HBSBU.js.map +1 -0
- package/dist/{nemoclaw-CQYXZVQN.js → nemoclaw-LXUTMR56.js} +3 -3
- package/dist/{omp-2QMEY6HD.js → omp-CO7IXURG.js} +2 -2
- package/dist/{openclaw-UZC437RW.js → openclaw-XWJLEW35.js} +3 -3
- package/dist/{opencode-L4BGFP25.js → opencode-QKZ5EIYU.js} +2 -2
- package/dist/{package-DNLQTPNN.js → package-IA56LSC3.js} +6 -6
- package/dist/{pi-PVVPVWKG.js → pi-YGBXYWY5.js} +2 -2
- package/dist/{qwen-code-G4CXKUHR.js → qwen-code-E2MSEZK6.js} +55 -123
- package/dist/qwen-code-E2MSEZK6.js.map +1 -0
- package/dist/{roo-code-67TYJIQR.js → roo-code-AGGJ473T.js} +2 -2
- package/dist/runtime/index.js +6 -6
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/test.js +5 -5
- package/dist/{serve-EOVWYBGZ.js → serve-RNUCK5F7.js} +8 -8
- package/dist/{status-VTD6XXLW.js → status-JOX6RLJU.js} +6 -6
- package/dist/{statusline-3ET5YPQ5.js → statusline-ZVFI5DRT.js} +7 -7
- package/dist/{telemetry-QCTMKDBQ.js → telemetry-3FN6HDVU.js} +5 -5
- package/dist/{trae-7CZZGOGI.js → trae-6L226ZDU.js} +2 -2
- package/dist/{uninstall-FL3SH2DT.js → uninstall-SCKZYB4J.js} +8 -8
- package/dist/{upgrade-SLFG2FCT.js → upgrade-WU3KZWR4.js} +8 -8
- package/dist/{usage-IRBLVUZM.js → usage-G72SF7JG.js} +2 -2
- package/dist/{usage-event-VFF77WYY.js → usage-event-DHSEBO5T.js} +7 -7
- package/dist/{vscode-copilot-MF2CDNMT.js → vscode-copilot-6EOZDLXC.js} +4 -2
- package/dist/vscode-copilot-6EOZDLXC.js.map +1 -0
- package/dist/{warp-VKG55TAT.js → warp-N5YYN5BF.js} +2 -2
- package/dist/{windsurf-FU5G4SHF.js → windsurf-4TGSJIVV.js} +2 -2
- package/dist/{zed-SFUHL3GS.js → zed-6P2UFWXU.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-CPLK7GTE.js.map +0 -1
- package/dist/chunk-EXLS7BSI.js.map +0 -1
- package/dist/chunk-LQRAPXS4.js.map +0 -1
- package/dist/claude-code-T2LPFNC3.js.map +0 -1
- package/dist/codex-O4G7D7KK.js.map +0 -1
- package/dist/continue-K43SUHLQ.js.map +0 -1
- package/dist/copilot-cli-Q3SSPT4V.js.map +0 -1
- package/dist/cursor-TMBXDYR4.js.map +0 -1
- package/dist/droid-JC2NT6S4.js.map +0 -1
- package/dist/gemini-cli-ILR7M5X3.js.map +0 -1
- package/dist/goose-SFO5BBGW.js.map +0 -1
- package/dist/hermes-3N7WN4WS.js.map +0 -1
- package/dist/jetbrains-copilot-NRZHI5PC.js.map +0 -1
- package/dist/kimi-2YFK2GBA.js.map +0 -1
- package/dist/kiro-YL6AWUYG.js.map +0 -1
- package/dist/mux-5XZFB44C.js.map +0 -1
- package/dist/qwen-code-G4CXKUHR.js.map +0 -1
- package/dist/vscode-copilot-MF2CDNMT.js.map +0 -1
- /package/dist/{action-EV63GAPY.js.map → action-YCU53FNE.js.map} +0 -0
- /package/dist/{amazon-q-COAL3764.js.map → amazon-q-W574ZX35.js.map} +0 -0
- /package/dist/{amp-XJQ4TDAU.js.map → amp-JPBQJJVM.js.map} +0 -0
- /package/dist/{antigravity-AMKKKHS4.js.map → antigravity-VK2Y3FGV.js.map} +0 -0
- /package/dist/{antigravity-cli-XERXEH5W.js.map → antigravity-cli-D4PCCUG2.js.map} +0 -0
- /package/dist/{chunk-BMD7ANKF.js.map → chunk-2F5QH3D4.js.map} +0 -0
- /package/dist/{chunk-5G4EPJ4Y.js.map → chunk-6RYPUR6O.js.map} +0 -0
- /package/dist/{chunk-2X4EH2D7.js.map → chunk-7ECYDK5T.js.map} +0 -0
- /package/dist/{chunk-QC5A3TFQ.js.map → chunk-CYOAH23F.js.map} +0 -0
- /package/dist/{chunk-RQPKL62M.js.map → chunk-DT6Y7XBI.js.map} +0 -0
- /package/dist/{chunk-QOGMDOUX.js.map → chunk-HAIMYUEY.js.map} +0 -0
- /package/dist/{chunk-DCK5FADX.js.map → chunk-MDNX7HTN.js.map} +0 -0
- /package/dist/{chunk-EROJDXMW.js.map → chunk-SDPIT4HW.js.map} +0 -0
- /package/dist/{chunk-H67V7DEL.js.map → chunk-SPWFUHHK.js.map} +0 -0
- /package/dist/{chunk-SRVAA2VN.js.map → chunk-WFXWJITA.js.map} +0 -0
- /package/dist/{chunk-MZF2YCXX.js.map → chunk-YQLQJZ7S.js.map} +0 -0
- /package/dist/{cline-WRYMNS7Z.js.map → cline-JUTO4V27.js.map} +0 -0
- /package/dist/{codebuff-PODYPOOP.js.map → codebuff-2QUHL6HO.js.map} +0 -0
- /package/dist/{detect-AHJIUMBO.js.map → detect-2NIXILMZ.js.map} +0 -0
- /package/dist/{doctor-G5MLCPAB.js.map → doctor-QWJBWALA.js.map} +0 -0
- /package/dist/{hook-76JBKTUX.js.map → hook-FDGIQPRC.js.map} +0 -0
- /package/dist/{install-R7252QFH.js.map → install-TLG3QVP3.js.map} +0 -0
- /package/dist/{kilo-IX4T3OHJ.js.map → kilo-FERJ3X46.js.map} +0 -0
- /package/dist/{kilo-cli-2AYCXBQD.js.map → kilo-cli-TDCONH5G.js.map} +0 -0
- /package/dist/{leaderboard-V6VWA5ZV.js.map → leaderboard-MXGENYXN.js.map} +0 -0
- /package/dist/{mimo-code-FTMGSKMQ.js.map → mimo-code-RFLQ727H.js.map} +0 -0
- /package/dist/{nemoclaw-CQYXZVQN.js.map → nemoclaw-LXUTMR56.js.map} +0 -0
- /package/dist/{omp-2QMEY6HD.js.map → omp-CO7IXURG.js.map} +0 -0
- /package/dist/{openclaw-UZC437RW.js.map → openclaw-XWJLEW35.js.map} +0 -0
- /package/dist/{opencode-L4BGFP25.js.map → opencode-QKZ5EIYU.js.map} +0 -0
- /package/dist/{package-DNLQTPNN.js.map → package-IA56LSC3.js.map} +0 -0
- /package/dist/{pi-PVVPVWKG.js.map → pi-YGBXYWY5.js.map} +0 -0
- /package/dist/{roo-code-67TYJIQR.js.map → roo-code-AGGJ473T.js.map} +0 -0
- /package/dist/{serve-EOVWYBGZ.js.map → serve-RNUCK5F7.js.map} +0 -0
- /package/dist/{status-VTD6XXLW.js.map → status-JOX6RLJU.js.map} +0 -0
- /package/dist/{statusline-3ET5YPQ5.js.map → statusline-ZVFI5DRT.js.map} +0 -0
- /package/dist/{telemetry-QCTMKDBQ.js.map → telemetry-3FN6HDVU.js.map} +0 -0
- /package/dist/{trae-7CZZGOGI.js.map → trae-6L226ZDU.js.map} +0 -0
- /package/dist/{uninstall-FL3SH2DT.js.map → uninstall-SCKZYB4J.js.map} +0 -0
- /package/dist/{upgrade-SLFG2FCT.js.map → upgrade-WU3KZWR4.js.map} +0 -0
- /package/dist/{usage-IRBLVUZM.js.map → usage-G72SF7JG.js.map} +0 -0
- /package/dist/{usage-event-VFF77WYY.js.map → usage-event-DHSEBO5T.js.map} +0 -0
- /package/dist/{warp-VKG55TAT.js.map → warp-N5YYN5BF.js.map} +0 -0
- /package/dist/{windsurf-FU5G4SHF.js.map → windsurf-4TGSJIVV.js.map} +0 -0
- /package/dist/{zed-SFUHL3GS.js.map → zed-6P2UFWXU.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/qwen-code/index.ts"],"sourcesContent":["/**\n * adapters/qwen-code — Qwen Code (Qwen CLI) platform adapter for agent-connector.\n *\n * Qwen Code is a Gemini-CLI-derived host, but — unlike Gemini CLI — its hook\n * WIRE PROTOCOL is Claude-compatible (verified against context-mode's proven\n * qwen-code adapter, which extends the shared ClaudeCodeBaseAdapter):\n *\n * - Hook event names are PascalCase, identical to Claude Code:\n * PreToolUse, PostToolUse, PreCompact, SessionStart, SessionEnd,\n * UserPromptSubmit, Stop, Notification — plus the E1 extension events\n * PermissionRequest, PostToolUseFailure, SubagentStart and SubagentStop,\n * all Qwen-native (verified against the upstream\n * docs/users/features/hooks.md: PermissionRequest takes the nested\n * hookSpecificOutput.decision{behavior} envelope, PostToolUseFailure /\n * SubagentStart are additionalContext feedback, SubagentStop blocks via\n * the TOP-LEVEL {\"decision\":\"block\",\"reason\"} Stop shape).\n * (NOT Gemini's BeforeTool/AfterTool/PreCompress vocabulary.)\n * - Hook stdin JSON carries snake_case fields: session_id, transcript_path,\n * cwd, tool_name, tool_input, tool_response, source, reason, prompt,\n * trigger, stop_hook_active, message.\n * - Reply is exit-code 0 + a `hookSpecificOutput` JSON object on stdout\n * (permissionDecision allow|deny|ask, updatedInput, additionalContext) —\n * the Claude reply shape. Qwen's PreToolUse CAN rewrite tool input\n * (updatedInput; capabilities.canModifyArgs = true), but — verified against\n * qwen 0.17.1 — there is NO `updatedMCPToolOutput` honor on PostToolUse, so\n * this host CANNOT rewrite already-emitted tool output\n * (capabilities.canModifyOutput = false, like the Claude-family hosts).\n * - Native tool names are Qwen/Gemini-flavored (run_shell_command, read_file,\n * write_file, grep_search, …) — used only inside matcher strings; the wire\n * field names are unchanged from Claude.\n *\n * Native config (JSONC — Qwen shares Gemini's tolerant settings loader; we write\n * strict JSON and MERGE into any existing settings so user keys survive):\n * - MCP servers: user → ~/.qwen/settings.json; project → <projectDir>/.qwen/\n * settings.json. Root key \"mcpServers\". Qwen is a Gemini-CLI fork, so — like\n * Gemini — the MCP TRANSPORT IS SELECTED BY WHICH KEY IS PRESENT, not a\n * `type` field: stdio → {command,args,env(,cwd)}; SSE → {url, headers?};\n * streamable-HTTP → {httpUrl, headers?}.\n * - Hooks: the SAME settings.json, top-level sibling \"hooks\" key, keyed by the\n * PascalCase event name, each value an array of\n * `{ matcher, hooks:[{ type:\"command\", command }] }`.\n *\n * Env handling: Qwen's settings loader has no `${env:VAR}` interpolation of our\n * framework's dialect, so env / header / url refs resolve to literals at install\n * time via resolveEnvRefsDeep — the safe default shared with the Gemini / Codex\n * adapters.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, MemoryTarget, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n CommandDef,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n JsonValue,\n NotificationEvent,\n PermissionRequestEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PostToolUseFailureEvent,\n PostCompactEvent,\n PreCompactEvent,\n PreToolUseEvent,\n ServerDef,\n SessionEndEvent,\n SessionStartEvent,\n SkillDef,\n StatuslineContext,\n StopEvent,\n SubagentDef,\n SubagentStartEvent,\n SubagentStopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport { writeTomlString } from \"../../core/toml.js\";\nimport {\n buildHomeBinHookCommand,\n buildHomeBinStatuslineCommand,\n buildServeWrapperCommand,\n isHomeBinHookCommand,\n isHomeBinStatuslineCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\nimport {\n type ConfigPatchLedgerEntry,\n addLedgerOwner,\n createLedgerEntry,\n describeJsonValue,\n dropLedgerEntry,\n findLedgerEntry,\n hashJsonValue,\n jsonDeepEquals,\n ledgerEntriesOwnedBy,\n loadConfigPatchLedger,\n removeLedgerOwner,\n saveConfigPatchLedger,\n} from \"../../core/config-patch-ledger.js\";\n\nconst HOST: PlatformId = \"qwen-code\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * settings.json leaf key the statusline surface owns on Qwen. UNLIKE claude-code\n * (a top-level `statusLine` leaf), Qwen nests its status-line config under `ui`\n * (`{ ui: { statusLine: { type:\"command\", command, refreshInterval? } } }` in\n * ~/.qwen/settings.json; verified against the qwen-code status-line docs and\n * QwenLM/qwen-code settings.md, shipped v0.14.3 / PR #2923). We own the\n * `ui.statusLine` leaf via the SAME refcounted ownership ledger as configPatch\n * (the ledger is surface-agnostic) — never clobbering a `ui.statusLine` a user\n * already set.\n */\nconst STATUSLINE_KEY = \"ui.statusLine\";\n\n/** A single hook registration entry as Qwen stores it (Claude-shaped, nested). */\ninterface QwenHookEntry {\n matcher: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** Shape of Qwen's settings.json (only the parts we touch). */\ninterface QwenSettingsFile {\n mcpServers?: Record<string, unknown>;\n hooks?: Record<string, QwenHookEntry[]>;\n [key: string]: unknown;\n}\n\n/**\n * Qwen's statusLine command stdin payload (the documented status-line input Qwen\n * pipes to the command, read once). Every field optional — a refresh only carries\n * what the host knows. Unmodeled fields (version, git, metrics, vim) stay in\n * StatuslineContext.raw. Sources: qwenlm.github.io/qwen-code-docs status-line page,\n * QwenLM/qwen-code settings.md.\n */\ninterface QwenStatuslineInput {\n session_id?: string;\n version?: string;\n model?: { display_name?: string };\n context_window?: {\n context_window_size?: number;\n used_percentage?: number;\n remaining_percentage?: number;\n current_usage?: number;\n total_input_tokens?: number;\n total_output_tokens?: number;\n };\n workspace?: { current_dir?: string };\n git?: { branch?: string };\n vim?: { mode?: string };\n}\n\n/**\n * Native MCP server entry shapes Qwen accepts under `mcpServers`. Qwen is a\n * Gemini-CLI fork, so the REMOTE transport is selected by WHICH KEY is present\n * (NOT a `type` field): SSE → `url`, streamable-HTTP → `httpUrl`. The stdio\n * entry keeps its (harmless, Claude-style) `type:\"stdio\"` tag — Qwen accepts it\n * and stdio is unambiguous by its command/args anyway.\n */\ninterface QwenStdioServer {\n type: \"stdio\";\n command: string;\n args: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\ninterface QwenSseServer {\n url: string;\n headers?: Record<string, string>;\n}\ninterface QwenHttpServer {\n httpUrl: string;\n headers?: Record<string, string>;\n}\n\n/** Raw Qwen hook stdin payload (Claude-compatible snake_case wire fields). */\ninterface QwenWireInput {\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n hook_event_name?: string;\n\n // tool events\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n /** PostToolUse result payload (string or structured). */\n tool_response?: unknown;\n\n // PermissionRequest — suggested permission entries the dialog would offer.\n permission_suggestions?: unknown[];\n\n // PostToolUseFailure (Qwen documents tool_use_id/error/is_interrupt; there is\n // no duration_ms on this host's payload).\n tool_use_id?: string;\n error?: string;\n is_interrupt?: boolean;\n\n // SubagentStart / SubagentStop — treat both as optional everywhere (the\n // Claude-family quirk: agent_type is not reliably populated on stop).\n agent_id?: string;\n agent_type?: string;\n // SubagentStop — the subagent's OWN transcript + its final message.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n\n // SessionStart\n source?: string;\n // SessionEnd\n reason?: string;\n // UserPromptSubmit\n prompt?: string;\n // PreCompact\n trigger?: string;\n // Stop\n stop_hook_active?: boolean;\n // Notification\n message?: string;\n\n /** Injected by the entrypoint so the runtime knows which connector to dispatch. */\n connector?: unknown;\n}\n\nexport class QwenCodeAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Qwen CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block (project <projectDir>/AGENTS.md\n // via the base default — Qwen reads repo AGENTS.md natively alongside QWEN.md,\n // so no QWEN.md duplicate; user scope → ~/.qwen/QWEN.md below, the only\n // documented user-scope memory file).\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n // Qwen fires PostCompact natively (observe-only — \"not in the decision mode\n // supported events list\"; QwenLM/qwen-code docs/users/features/hooks.md\n // \"#### PostCompact\", trigger + compact_summary payload).\n postCompact: true,\n sessionStart: true,\n sessionEnd: true,\n userPromptSubmit: true,\n stop: true,\n notification: true,\n // E1 events — all four are Qwen-native (its 16-event surface is strictly\n // wider than the canonical union).\n permissionRequest: true,\n postToolUseFailure: true,\n subagentStart: true,\n subagentStop: true,\n // Qwen's PreToolUse can rewrite input (updatedInput). It CANNOT rewrite\n // already-emitted tool output — `updatedMCPToolOutput` does not exist in\n // qwen 0.17.1, so canModifyOutput is false (like the Claude-family hosts).\n canModifyArgs: true,\n canModifyOutput: false,\n canInjectSessionContext: true,\n transports: [\"stdio\", \"sse\", \"http\"],\n // Content surfaces: Qwen ships native slash commands (TOML), subagents\n // (md+frontmatter), and skills (SKILL.md under .qwen/skills/<name>/).\n // Confirmed dir: .qwen/skills/ (project), ~/.qwen/skills/ (user scope).\n // Ground truth: kilo-pi-ground-truth.md § \"Already-known skills gaps\".\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n // Statusline surface: qwen-code is the 2nd v1 host (after claude-code).\n // installStatusline wires settings.json `ui.statusLine` = {type:\"command\",\n // command:<home-bin statusline cmd>} through the SAME refcounted ownership\n // ledger as configPatch (never clobbers a ui.statusLine agent-connector does\n // not own). The key is NESTED here (`ui.statusLine`), unlike claude-code's\n // top-level `statusLine`. Confirmed config key + stdin payload against the\n // qwen-code status-line docs (shipped v0.14.3, PR #2923).\n supportsStatusline: true,\n // Native passthrough: Qwen's 16-event surface includes 3 host-specific events\n // with NO canonical HookEventName analog — TodoCreated / TodoCompleted /\n // StopFailure (QwenLM/qwen-code docs/users/features/hooks.md). A connector\n // reaches them via platforms[\"qwen-code\"].nativeHooks; installHooks files the\n // PascalCase event key VERBATIM into settings.json hooks, and the generic\n // uninstall reverses it.\n supportsNativeHooks: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".qwen\");\n const userSettings = join(userDir, \"settings.json\");\n const projectDirQwen = join(projectDir, \".qwen\");\n const projectSettings = join(projectDirQwen, \"settings.json\");\n const userInstalled = existsSync(userDir) || existsSync(userSettings);\n const projInstalled = existsSync(projectDirQwen) || existsSync(projectSettings);\n const installed = userInstalled || projInstalled;\n // Report the scope/path that actually matched, so a project-only install\n // isn't misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectSettings : userSettings;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Qwen CLI config at ${projectSettings}`\n : `found Qwen CLI config under ${userDir}`\n : `no Qwen CLI config at ${userDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Memory surface: ~/.qwen/QWEN.md at user scope ────────────────────────\n // Project scope stays on the AGENTS.md base default (Qwen reads the repo\n // AGENTS.md natively in ADDITION to QWEN.md — one canonical copy, never a\n // QWEN.md duplicate). User scope targets ~/.qwen/QWEN.md: Qwen has no\n // user-scope AGENTS.md, so the host's own global memory file is the only\n // file it actually reads there.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n if (this.memoryOverride(ctx)?.path || ctx.scope !== \"user\") {\n return super.memoryTargets(ctx);\n }\n return [\n {\n path: join(homedir(), \".qwen\", \"QWEN.md\"),\n reason: \"qwen-code global memory (~/.qwen/QWEN.md; no user-scope AGENTS.md exists)\",\n },\n ];\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".qwen\")\n : join(homedir(), \".qwen\");\n }\n\n /** MCP servers live in settings.json under `mcpServers`. */\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"settings.json\");\n }\n\n /** Hooks live in the SAME settings.json under the sibling `hooks` key. */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"settings.json\");\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for qwen-code\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /**\n * Render a normalized ServerDef into Qwen's native mcpServers entry. As a\n * Gemini-CLI fork, the transport is encoded by WHICH KEY is present (NOT a\n * `type` field): command/args/env (stdio), url (sse), httpUrl (http).\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): QwenStdioServer | QwenSseServer | QwenHttpServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(\n ctx.homeBinPath,\n ctx.connector.id,\n command,\n args,\n ctx.scope,\n this.id,\n );\n command = wrapped.command;\n args = wrapped.args;\n }\n\n const entry: QwenStdioServer = {\n type: \"stdio\",\n command: resolveEnvRefsDeep(command),\n args: args.map((a) => resolveEnvRefsDeep(a)),\n };\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n if (server.cwd) entry.cwd = resolveEnvRefsDeep(server.cwd);\n return entry;\n }\n\n // SSE transport → `url` key.\n if (transport === \"sse\") {\n const entry: QwenSseServer = { url: resolveEnvRefsDeep(server.url ?? \"\") };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n // http (streamable-HTTP) and any other remote transport → `httpUrl` key.\n const entry: QwenHttpServer = { httpUrl: resolveEnvRefsDeep(server.url ?? \"\") };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. Qwen's settings loader does not interpret our\n * `${env:VAR}` dialect, so refs resolve to literals at install time — the safe\n * default shared with the Gemini / Codex adapters.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n return resolveEnvRefsDeep({ ...env });\n }\n\n // ── Hook install / uninstall ─────────────────────────────────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST];\n const hooksDisabled = override?.hooks === false;\n // `hooks: false` disables only the NORMALIZED events; nativeHooks is a\n // sibling, qwen-scoped declaration that installs regardless.\n const normalizedEvents = hooksDisabled ? [] : connector.hookEvents;\n const nativeHooks = override?.nativeHooks ?? {};\n const nativeEvents = Object.keys(nativeHooks);\n\n if (normalizedEvents.length === 0 && nativeEvents.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: hooksDisabled ? \"hooks disabled for qwen-code\" : \"connector declares no hooks\",\n },\n ];\n }\n\n const settingsPath = this.getHookConfigPath(ctx);\n // MERGE into any existing settings (JSONC written as strict JSON) so the\n // user's own mcpServers / theme / other keys are preserved.\n const settings = this.readJson<QwenSettingsFile>(settingsPath) ?? {};\n const hooks = (settings.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of normalizedEvents) {\n // Qwen's hook event names are Claude-identical (PascalCase) — register the\n // canonical event name directly. Write-all is AUDITED here: every canonical\n // event (incl. PermissionRequest / PostToolUseFailure / SubagentStart /\n // SubagentStop) exists natively on Qwen, whose 16-event surface is strictly\n // wider than the canonical union.\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const entry: QwenHookEntry = {\n matcher,\n hooks: [{ type: \"command\", command }],\n };\n\n const bucket = (hooks[event] ??= []);\n const existingIdx = bucket.findIndex((e) => this.entryHasOurCommand(e, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: settingsPath,\n detail: `hooks.${event} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: settingsPath,\n detail: `hooks.${event}`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: settingsPath,\n detail: `hooks.${event}`,\n });\n }\n mutated = true;\n }\n\n // NATIVE passthrough events: qwen-native event-name keys (e.g. TodoCreated,\n // TodoCompleted, StopFailure) filed VERBATIM into settings.json hooks — no\n // EVENT_MAP, since they ARE Qwen events. Same nested entry shape; matched by\n // EXACT command so a native key coinciding with a normalized one never clobbers.\n for (const nativeEvent of nativeEvents) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, nativeEvent, connector.id);\n const entry: QwenHookEntry = {\n matcher: nativeHooks[nativeEvent]?.matcher ?? \"\",\n hooks: [{ type: \"command\", command }],\n };\n const bucket = (hooks[nativeEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => e.hooks?.[0]?.command === command);\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: settingsPath,\n detail: `hooks.${nativeEvent} (native) already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({ platform: this.id, action: \"update\", path: settingsPath, detail: `hooks.${nativeEvent} (native)` });\n } else {\n bucket.push(entry);\n changes.push({ platform: this.id, action: \"create\", path: settingsPath, detail: `hooks.${nativeEvent} (native)` });\n }\n mutated = true;\n }\n\n if (mutated) this.writeJson(settingsPath, settings, ctx.dryRun);\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const settingsPath = this.getHookConfigPath(ctx);\n const settings = this.readJson<QwenSettingsFile>(settingsPath);\n const hooks = settings?.hooks;\n if (!settings || !hooks) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: settingsPath,\n detail: \"no hooks section present\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of Object.keys(hooks)) {\n const bucket = hooks[event];\n if (!Array.isArray(bucket)) continue;\n\n // Strip our hook command from each entry; drop entries left empty so we\n // never remove another connector's (or the user's own) hook commands. The\n // id token is anchored (isHomeBinHookCommand) so a shared-prefix connector\n // id is never affected.\n const next: QwenHookEntry[] = [];\n let removed = 0;\n for (const e of bucket) {\n const innerBefore = e.hooks?.length ?? 0;\n const inner = (e.hooks ?? []).filter((h) => !this.isOurCommand(h.command, ctx));\n removed += innerBefore - inner.length;\n if (inner.length > 0) next.push({ matcher: e.matcher ?? \"\", hooks: inner });\n }\n\n if (removed > 0) {\n if (next.length > 0) hooks[event] = next;\n else delete hooks[event];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: settingsPath,\n detail: `hooks.${event} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(settingsPath, settings, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: settingsPath,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n private entryHasOurCommand(entry: QwenHookEntry, ctx: InstallContext): boolean {\n return (entry.hooks ?? []).some((h) => this.isOurCommand(h.command, ctx));\n }\n\n /** True when a hook command references our home binary AND this connector id\n * (anchored so a shared-prefix id can't collide — see isHomeBinHookCommand). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Statusline surface (a HUD/status line) ────────────────────────────────\n // Wires settings.json `ui.statusLine` = { type:\"command\", command:<home-bin\n // statusline cmd> } through the SAME refcounted ownership ledger as configPatch\n // (the ledger primitives are surface-agnostic). qwen-code does NOT advertise\n // supportsConfigPatch, so — unlike claude-code, which routes the statusline\n // through its private applyConfigPatches loop — this adapter performs the nested\n // set-if-absent write directly with the exported ledger primitives. Semantics\n // are identical: never clobber a ui.statusLine agent-connector does not own\n // (skip-warn), record prior state + owner (refcounted across connectors),\n // reversible by uninstallStatusline (last-owner-verified delete). The key is\n // NESTED (`ui.statusLine`), so we own the `ui.statusLine` leaf — if the user\n // already has it, we skip-warn and never touch their value.\n //\n // The home-bin command makes Qwen exec\n // `<homeBin> statusline qwen-code --connector <id>` for every status refresh,\n // which re-imports the connector module and renders the line (runtime/\n // statusline-entrypoint). No telemetry in v1.\n\n /** The statusLine config object value agent-connector writes at `ui.statusLine`. */\n private statuslineValue(ctx: InstallContext): JsonValue {\n const command = buildHomeBinStatuslineCommand(ctx.homeBinPath, HOST, ctx.connector.id);\n return { type: \"command\", command };\n }\n\n override installStatusline(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.statusline == null) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no statusline\" }];\n }\n if (connector.platforms[HOST]?.statusline === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"statusline disabled for qwen-code\" }];\n }\n\n const filePath = this.getServerConfigPath(ctx);\n // OVERWRITE GUARD (upsertServerInJson precedent): never round-trip a\n // present-but-unparseable settings file into `{}`.\n if (this.isPresentButUnparseable(filePath)) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail: `existing ${filePath} is not parseable; statusline left unapplied (back it up / fix it, then re-run)`,\n },\n ];\n }\n const settings = this.readJson<Record<string, unknown>>(filePath) ?? {};\n if (typeof settings !== \"object\" || Array.isArray(settings)) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail: `existing ${filePath} is not a JSON object; statusline left unapplied`,\n },\n ];\n }\n\n const ledger = loadConfigPatchLedger(ctx.dataRoot);\n const desired = this.statuslineValue(ctx);\n const segments = STATUSLINE_KEY.split(\".\");\n const leaf = readJsonLeaf(settings, segments);\n const entry = findLedgerEntry(ledger, HOST, filePath, STATUSLINE_KEY);\n const changes: ChangeRecord[] = [];\n\n if (leaf.kind === \"blocked\") {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `statusline ${STATUSLINE_KEY} skipped: \"${leaf.atPath}\" exists but is not an ` +\n `object — set ${STATUSLINE_KEY} manually if wanted`,\n },\n ];\n }\n\n if (leaf.kind === \"absent\") {\n // SET-IF-ABSENT: the one write path. Intermediates (`ui`) created as needed.\n writeJsonLeaf(settings, segments, desired);\n this.writeJson(filePath, settings, ctx.dryRun);\n if (entry) {\n // Stale ledger row (key deleted out from under us): re-assert the value,\n // keep existing owners (they still rely on the key), record what we wrote.\n entry.writtenValue = desired;\n entry.writtenValueHash = hashJsonValue(desired);\n addLedgerOwner(entry, connector.id, connector.version);\n } else {\n createLedgerEntry(ledger, {\n platform: HOST,\n file: filePath,\n key: STATUSLINE_KEY,\n value: desired,\n connectorId: connector.id,\n connectorVersion: connector.version,\n });\n }\n if (!ctx.dryRun) saveConfigPatchLedger(ctx.dataRoot, ledger);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: filePath,\n detail: `statusline ${STATUSLINE_KEY}: <absent> → ${describeJsonValue(desired)}`,\n });\n return changes;\n }\n\n // Key PRESENT — never overwrite; the only question is ownership/refcount.\n if (!entry) {\n // User- (or other-tool-) owned. No ownership is taken even when the values\n // happen to match — uninstall must never delete a key we did not create.\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `statusline ${STATUSLINE_KEY} skipped: already set to ${describeJsonValue(leaf.value)} ` +\n `(not created by agent-connector) — left untouched`,\n },\n ];\n }\n\n if (!jsonDeepEquals(leaf.value, entry.writtenValue)) {\n // DRIFT: the user edited the value after we wrote it. Never revert.\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `statusline ${STATUSLINE_KEY}: value changed since install ` +\n `(current ${describeJsonValue(leaf.value)}, wrote ${describeJsonValue(entry.writtenValue)}); ` +\n `leaving in place`,\n },\n ];\n }\n\n if (jsonDeepEquals(desired, leaf.value)) {\n // Same value we own: register as co-owner (refcount++) or idempotent skip.\n const owners = entry.owners.map((o) => o.connectorId);\n if (addLedgerOwner(entry, connector.id, connector.version)) {\n if (!ctx.dryRun) saveConfigPatchLedger(ctx.dataRoot, ledger);\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `statusline ${STATUSLINE_KEY} already installed; registered as co-owner (co-owned with ${owners.join(\", \")})`,\n },\n ];\n }\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `statusline ${STATUSLINE_KEY} already installed`,\n },\n ];\n }\n\n // FIRST-WRITER-WINS: another connector owns the key with a different value.\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `statusline ${STATUSLINE_KEY} skipped: already owned by ${entry.owners\n .map((o) => o.connectorId)\n .join(\", \")} with a different value — left untouched`,\n },\n ];\n }\n\n override uninstallStatusline(ctx: InstallContext): ChangeRecord[] {\n const ledger = loadConfigPatchLedger(ctx.dataRoot);\n // Release ONLY the ui.statusLine ledger row this connector owns (keyed off the\n // ledger, not the declaration, so an id-only synthetic uninstall still reclaims\n // it). Last-owner-verified delete: remove the key ONLY when last-owner ∧\n // value-unchanged ∧ prior-absent (else skip-warn + leave the key).\n const owned = ledgerEntriesOwnedBy(ledger, HOST, ctx.connector.id).filter(\n (e) => e.key === STATUSLINE_KEY,\n );\n if (owned.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"statusline: no ownership recorded; left untouched\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let ledgerMutated = false;\n\n // All rows share one file (the scope-resolved settings.json), but group by\n // file anyway so a scope drift between install and uninstall stays correct.\n const byFile = new Map<string, ConfigPatchLedgerEntry[]>();\n for (const entry of owned) {\n const bucket = byFile.get(entry.file) ?? [];\n bucket.push(entry);\n byFile.set(entry.file, bucket);\n }\n\n for (const [filePath, entries] of byFile) {\n const unparseable = this.isPresentButUnparseable(filePath);\n const settings = unparseable ? null : this.readJson<Record<string, unknown>>(filePath);\n let fileMutated = false;\n\n for (const entry of entries) {\n const { lastOwner } = removeLedgerOwner(entry, ctx.connector.id);\n ledgerMutated = true;\n\n if (!lastOwner) {\n // Shared-flag case: A uninstalls, B still relies on the key.\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `statusline ${entry.key} retained: still owned by ${entry.owners\n .map((o) => o.connectorId)\n .join(\", \")}`,\n });\n continue;\n }\n\n // Last owner out → the ledger row is dropped on every branch below; the\n // KEY is removed only on the fully-verified branch.\n dropLedgerEntry(ledger, entry);\n\n if (unparseable) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail: `statusline ${entry.key}: ${filePath} is not parseable; key left in place (ownership released)`,\n });\n continue;\n }\n if (!settings || typeof settings !== \"object\" || Array.isArray(settings)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `statusline ${entry.key} already absent (no settings file); ownership record dropped`,\n });\n continue;\n }\n const leaf = readJsonLeaf(settings, entry.key.split(\".\"));\n if (leaf.kind !== \"present\") {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `statusline ${entry.key} already absent; ownership record dropped`,\n });\n continue;\n }\n if (entry.prior?.present !== false || !jsonDeepEquals(leaf.value, entry.writtenValue)) {\n // User edited the value after install (or the row predates the\n // set-if-absent guarantee): deleting would clobber them. Leave it.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `statusline ${entry.key}: value changed since install ` +\n `(current ${describeJsonValue(leaf.value)}, wrote ${describeJsonValue(entry.writtenValue)}); ` +\n `left in place`,\n });\n continue;\n }\n\n // VERIFIED: last owner + current === writtenValue + prior absent. Delete\n // the leaf key (the `ui` intermediate we may have created is left in place).\n deleteJsonLeaf(settings, entry.key.split(\".\"));\n fileMutated = true;\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: filePath,\n detail: `statusline ${entry.key} removed (was ${describeJsonValue(entry.writtenValue)})`,\n });\n }\n\n if (fileMutated && settings) this.writeJson(filePath, settings, ctx.dryRun);\n }\n\n if (ledgerMutated && !ctx.dryRun) saveConfigPatchLedger(ctx.dataRoot, ledger);\n return changes;\n }\n\n /**\n * Parse Qwen's statusLine stdin JSON into the normalized\n * {@link StatuslineContext}. Qwen pipes a JSON object to the statusLine command\n * on stdin (model, context_window, workspace, git, …); fields the payload omits\n * stay undefined. `raw` keeps the verbatim payload (incl. version/git/metrics/\n * vim). NOTE: Qwen has NO cost analog (no cost field in the payload), so\n * `ctx.cost` is intentionally left undefined. Sources: qwen-code status-line\n * docs, QwenLM/qwen-code settings.md.\n */\n parseStatusInput(raw: unknown): StatuslineContext {\n const input = (raw ?? {}) as QwenStatuslineInput;\n\n const ctx: StatuslineContext = {\n host: HOST,\n capabilities: this.capabilities,\n raw,\n };\n if (typeof input.session_id === \"string\" && input.session_id !== \"\") {\n ctx.sessionId = input.session_id;\n }\n if (typeof input.workspace?.current_dir === \"string\") {\n ctx.cwd = input.workspace.current_dir;\n }\n if (typeof input.model?.display_name === \"string\") {\n ctx.model = { displayName: input.model.display_name };\n }\n const cw = input.context_window;\n if (cw) {\n const context: { usedTokens?: number; maxTokens?: number; percent?: number } = {};\n if (typeof cw.context_window_size === \"number\") context.maxTokens = cw.context_window_size;\n if (typeof cw.current_usage === \"number\") context.usedTokens = cw.current_usage;\n if (typeof cw.used_percentage === \"number\") context.percent = cw.used_percentage;\n if (\n context.usedTokens !== undefined ||\n context.maxTokens !== undefined ||\n context.percent !== undefined\n ) {\n ctx.context = context;\n }\n }\n // ctx.cost stays undefined: Qwen's status payload has no cost analog.\n return ctx;\n }\n\n /** Format the rendered status line into Qwen's native reply: stdout = line, exit 0. */\n formatStatusOutput(rendered: string): HookReply {\n return { exitCode: 0, stdout: rendered };\n }\n\n // ── Content surfaces: commands / subagents ───────────────────────────────\n // CONTENT-ONLY: pure native-file writers under <qwenDir>/{commands,agents}. No\n // runtime dispatch, no home-bin pointer, no telemetry wrap. Each method is\n // idempotent (byte-identical → skip) via BaseAdapter.writeContentFile and\n // reversible via removeContentFile. Honors platforms[\"qwen-code\"] per-surface\n // false to skip. Qwen has NO Agent-Skills surface, so skills are left to the\n // BaseAdapter skip/warn default (supportsSkills stays false).\n\n private commandsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"commands\");\n }\n private skillsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"skills\");\n }\n private agentsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"agents\");\n }\n\n /** Native command file path: <qwenDir>/commands/<name>.toml. */\n private commandPath(ctx: InstallContext, name: string): string {\n return join(this.commandsDir(ctx), `${name}.toml`);\n }\n /** Native skill dir: <qwenDir>/skills/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n /** Native subagent file path: <qwenDir>/agents/<name>.md. */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.agentsDir(ctx), `${name}.md`);\n }\n\n // ── Commands ──────────────────────────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for qwen-code\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(\n this.commandPath(ctx, cmd.name),\n this.renderCommand(cmd),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n /** Render a command to Qwen's native TOML (description, prompt). */\n private renderCommand(cmd: CommandDef): string {\n const obj: Record<string, unknown> = {};\n if (cmd.description !== undefined) obj.description = cmd.description;\n obj.prompt = cmd.prompt;\n return writeTomlString(obj);\n }\n\n // ── Skills ────────────────────────────────────────────────────────────────\n // Qwen reads SKILL.md from <qwenDir>/skills/<name>/SKILL.md.\n // Project dir: <projectDir>/.qwen/skills/<name>/SKILL.md\n // User dir: ~/.qwen/skills/<name>/SKILL.md\n // Confirmed: kilo-pi-ground-truth.md § \"Already-known skills gaps\" (.qwen/skills).\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for qwen-code\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue;\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n private renderSkill(skill: SkillDef): string {\n return renderSkillMd(skill);\n }\n\n // ── Subagents ──────────────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for qwen-code\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(\n this.subagentPath(ctx, agent.name),\n this.renderSubagent(agent),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /** Render a subagent to md+frontmatter (name, description, tools, model) + prompt body. */\n private renderSubagent(agent: SubagentDef): string {\n const frontmatter: Record<string, unknown> = {\n name: agent.name,\n description: agent.description,\n };\n const allow = agent.tools?.allow;\n if (allow && allow.length > 0) frontmatter.tools = allow.join(\", \");\n if (agent.model !== undefined) frontmatter.model = agent.model;\n if (agent.extra) Object.assign(frontmatter, agent.extra);\n return this.renderFrontmatterMd(frontmatter, agent.prompt);\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const settingsPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: settings.json present`,\n check: () =>\n existsSync(settingsPath)\n ? { status: \"OK\", detail: settingsPath }\n : { status: \"FAIL\", detail: `not found: ${settingsPath}` },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const settings = this.readJson<QwenSettingsFile>(settingsPath);\n if (!settings) return { status: \"FAIL\", detail: `cannot read ${settingsPath}` };\n const hooks = settings.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) =>\n (e.hooks ?? []).some((h) =>\n isHomeBinHookCommand(h.command, homeBin, connectorId),\n ),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${settingsPath}` };\n },\n },\n ];\n\n // Content-surface checks: assert presence of all three content surfaces\n // (commands, skills, subagents) this connector declares.\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(ctx, cmd.name);\n checks.push({\n name: `${this.name}: command ${cmd.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n\n // Statusline check: assert it when the connector declares a statusline AND it\n // is not disabled for this host, OR when the ownership ledger holds a\n // ui.statusLine row this connector owns (the REGISTERED-connector path:\n // connectorFromMeta can't re-expose the render fn, so statusline comes back\n // undefined — but the ledger row proves the surface was wired). Mirrors\n // claude-code's \"statusline wired\" check; ui.statusLine.command must be OUR\n // home-bin statusline command (OK); present-but-not-ours / absent → FAIL.\n const statuslineLedgerOwned = ledgerEntriesOwnedBy(\n loadConfigPatchLedger(ctx.dataRoot),\n HOST,\n connectorId,\n ).some((e) => e.key === STATUSLINE_KEY);\n if (\n (ctx.connector.statusline != null || statuslineLedgerOwned) &&\n ctx.connector.platforms[HOST]?.statusline !== false\n ) {\n checks.push({\n name: `${this.name}: statusline wired`,\n check: () => {\n const settings = this.readJson<{ ui?: { statusLine?: { command?: unknown } } }>(\n settingsPath,\n );\n const command = settings?.ui?.statusLine?.command;\n if (command === undefined) {\n return { status: \"FAIL\", detail: `ui.statusLine not set in ${settingsPath}` };\n }\n if (\n typeof command === \"string\" &&\n isHomeBinStatuslineCommand(command, homeBin, connectorId)\n ) {\n return { status: \"OK\", detail: \"ui.statusLine command present\" };\n }\n // Present but not ours — a non-AC ui.statusLine we must never clobber.\n return {\n status: \"FAIL\",\n detail: `ui.statusLine in ${settingsPath} is not agent-connector's (left untouched)`,\n };\n },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse Qwen stdin JSON → normalized event ────────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as QwenWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = extractSessionId(input);\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(toolResponseToString(input.tool_response) !== undefined\n ? { toolOutput: toolResponseToString(input.tool_response) }\n : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source),\n };\n return ev;\n }\n case \"SessionEnd\": {\n const ev: SessionEndEvent = {\n ...base,\n ...(typeof input.reason === \"string\" ? { reason: input.reason } : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"PreCompact\": {\n const ev: PreCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"PostCompact\": {\n // Qwen fires PostCompact natively (observe-only). Parsed like PreCompact:\n // normalize the trigger (auto|manual); compact_summary rides on `raw`.\n const ev: PostCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = {\n ...base,\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"Notification\": {\n const ev: NotificationEvent = {\n ...base,\n message: typeof input.message === \"string\" ? input.message : \"\",\n };\n return ev;\n }\n case \"PermissionRequest\": {\n const ev: PermissionRequestEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(Array.isArray(input.permission_suggestions)\n ? { permissionSuggestions: input.permission_suggestions }\n : {}),\n };\n return ev;\n }\n case \"PostToolUseFailure\": {\n // durationMs stays unset — Qwen's failure payload has no duration_ms.\n const ev: PostToolUseFailureEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: typeof input.error === \"string\" ? input.error : \"\",\n ...(typeof input.tool_use_id === \"string\"\n ? { toolUseId: input.tool_use_id }\n : {}),\n ...(typeof input.is_interrupt === \"boolean\"\n ? { isInterrupt: input.is_interrupt }\n : {}),\n };\n return ev;\n }\n case \"SubagentStart\": {\n const ev: SubagentStartEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n };\n return ev;\n }\n case \"SubagentStop\": {\n // agent_id/agent_type stay optional — the Claude-family SDK does not\n // reliably populate agent_type on stop.\n const ev: SubagentStopEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n ...(typeof input.agent_transcript_path === \"string\"\n ? { agentTranscriptPath: input.agent_transcript_path }\n : {}),\n ...(typeof input.last_assistant_message === \"string\"\n ? { lastAssistantMessage: input.last_assistant_message }\n : {}),\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n default: {\n // Exhaustive guard — every HookEventName is handled above.\n const _never: never = event;\n throw new Error(`unsupported qwen-code hook event: ${String(_never)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Qwen native hook reply ────────────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const hookEventName = event;\n const decision = response.decision ?? \"allow\";\n\n // PermissionRequest uses Qwen's nested decision{behavior} envelope (Claude-\n // identical) and is the ONE event where an EXPLICIT \"allow\" is an ACTIVE\n // grant that suppresses the permission dialog:\n // allow → decision{behavior:\"allow\"} (+updatedInput when set —\n // Qwen honors input rewrite, canModifyArgs above);\n // modify → an allow grant carrying updatedInput;\n // deny → decision{behavior:\"deny\", message};\n // ask/context/void → NO decision output: fall through to the native\n // dialog (the dialog IS the ask).\n if (event === \"PermissionRequest\") {\n if (response.decision === \"deny\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n decision: {\n behavior: \"deny\",\n message: response.reason ?? \"Blocked by hook\",\n },\n },\n });\n }\n if (\n response.decision === \"allow\" ||\n (response.decision === \"modify\" && response.updatedInput)\n ) {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n decision: {\n behavior: \"allow\",\n ...(response.updatedInput\n ? { updatedInput: response.updatedInput }\n : {}),\n },\n },\n });\n }\n return { exitCode: 0 };\n }\n\n // PostToolUseFailure (feedback beside the error) and SubagentStart (context\n // injected into the SUBAGENT's conversation) are observe/context-only on\n // Qwen: \"context\" emits additionalContext, and a \"deny\" DEGRADES to the\n // same shape carrying the reason (the tool already failed / the spawn is\n // not blockable).\n if (event === \"PostToolUseFailure\" || event === \"SubagentStart\") {\n const context =\n decision === \"context\"\n ? response.additionalContext\n : decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: context },\n });\n }\n return { exitCode: 0 };\n }\n\n // SubagentStop deny = Stop semantics: Qwen documents the TOP-LEVEL\n // {\"decision\":\"block\",\"reason\"} shape (keeps the subagent running with\n // `reason` as its next instruction).\n if (decision === \"deny\" && event === \"SubagentStop\") {\n return this.stdout({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n\n // deny → block the action with a reason (exit 0; JSON carries the decision).\n if (decision === \"deny\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n });\n }\n\n // ask → prompt the user to confirm.\n if (decision === \"ask\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"ask\",\n permissionDecisionReason: response.reason ?? \"Confirmation required by hook\",\n },\n });\n }\n\n // modify → rewrite PreToolUse input only. Qwen 0.17.1 has no PostToolUse\n // output-rewrite (`updatedMCPToolOutput` does not exist), so a modify on any\n // other event falls through to allow.\n if (decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, updatedInput: response.updatedInput },\n });\n }\n // Nothing applicable on this event; fall through to allow.\n }\n\n // context → inject soft guidance (also the SessionStart context path).\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: response.additionalContext },\n });\n }\n\n // allow / void / unsupported-degradation → pass through with exit 0.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// JSON leaf-path helpers (statusline nested set-if-absent). Mirror claude-code's\n// file-local helpers (those are private to the claude-code module). The leaf\n// path here is the validated dotted `ui.statusLine`.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Result of looking up a dotted leaf path in a parsed JSON object. */\ntype JsonLeafLookup =\n | { kind: \"absent\" }\n | { kind: \"present\"; value: JsonValue }\n | { kind: \"blocked\"; atPath: string };\n\n/**\n * Walk `segments` (a dotted leaf path) through `root`. \"blocked\" reports the\n * first intermediate that exists but is not a plain object — the skip-warn case\n * (we never replace a non-object intermediate, e.g. a user's `ui: \"dark\"`).\n */\nfunction readJsonLeaf(root: Record<string, unknown>, segments: string[]): JsonLeafLookup {\n let node: Record<string, unknown> = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const next = node[segments[i]!];\n if (next === undefined) return { kind: \"absent\" };\n if (next === null || typeof next !== \"object\" || Array.isArray(next)) {\n return { kind: \"blocked\", atPath: segments.slice(0, i + 1).join(\".\") };\n }\n node = next as Record<string, unknown>;\n }\n const leaf = node[segments[segments.length - 1]!];\n if (leaf === undefined) return { kind: \"absent\" };\n return { kind: \"present\", value: leaf as JsonValue };\n}\n\n/**\n * Write `value` at the leaf, creating ONLY absent intermediate objects along the\n * way (callers must have verified the path is not blocked).\n */\nfunction writeJsonLeaf(\n root: Record<string, unknown>,\n segments: string[],\n value: JsonValue,\n): void {\n let node: Record<string, unknown> = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i]!;\n const next = node[seg];\n if (next === undefined) {\n const created: Record<string, unknown> = {};\n node[seg] = created;\n node = created;\n } else {\n node = next as Record<string, unknown>;\n }\n }\n node[segments[segments.length - 1]!] = value;\n}\n\n/**\n * Delete the leaf key only. Intermediate objects — even ones we created (the\n * `ui` wrapper) — are deliberately left in place (harmless; pruning risks\n * clobbering sibling keys the user set under `ui`).\n */\nfunction deleteJsonLeaf(root: Record<string, unknown>, segments: string[]): void {\n let node: Record<string, unknown> = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const next = node[segments[i]!];\n if (next === null || typeof next !== \"object\" || Array.isArray(next)) return;\n node = next as Record<string, unknown>;\n }\n delete node[segments[segments.length - 1]!];\n}\n\n/**\n * Extract a stable session id from a Qwen wire payload. Unlike Claude (which\n * prefers the transcript UUID), Qwen Code surfaces `session_id` directly and\n * prioritizes it — matching context-mode's QwenCodeAdapter.extractSessionId.\n * Falls back to the transcript UUID, then \"\" (no ppid fabrication — the\n * normalized event uses \"\" when the host provides no id).\n */\nfunction extractSessionId(input: QwenWireInput): string {\n if (typeof input.session_id === \"string\" && input.session_id !== \"\") {\n return input.session_id;\n }\n if (typeof input.transcript_path === \"string\") {\n const m = input.transcript_path.match(/([a-f0-9-]{36})\\.jsonl$/);\n if (m && m[1]) return m[1];\n }\n return \"\";\n}\n\n/** Coerce a Qwen PostToolUse `tool_response` into a string for the normalized event. */\nfunction toolResponseToString(value: unknown): string | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction normalizeSessionSource(source: string | undefined): SessionStartEvent[\"source\"] {\n switch (source) {\n case \"compact\":\n return \"compact\";\n case \"resume\":\n return \"resume\";\n case \"clear\":\n return \"clear\";\n default:\n return \"startup\";\n }\n}\n\nexport const adapter = new QwenCodeAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AA4DrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAYrB,IAAM,iBAAiB;AA6GhB,IAAM,kBAAN,cAA8B,YAA+B;AAAA,EACzD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,IAK5C,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA;AAAA;AAAA;AAAA,IAIZ,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA,IAGd,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,cAAc;AAAA;AAAA;AAAA;AAAA,IAId,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,YAAY,CAAC,SAAS,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnC,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQnB,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOpB,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;AAAA,EACrB;AACF;AAEA,SAAS,uBAAuB,QAAyD;AACvF,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,IAAM,UAAU,IAAI,gBAAgB;AAC3C,IAAO,oBAAQ;","names":["entry","headers"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/vscode-copilot/index.ts"],"sourcesContent":["/**\n * adapters/vscode-copilot — VS Code Copilot platform adapter for agent-connector.\n *\n * Generalized from context-mode's proven VS Code Copilot adapter: the served\n * identity is now `ctx.connector` (not a hardcoded \"context-mode\"), and every\n * hook command points at the single stable home binary\n * (`buildHomeBinHookCommand`) so one framework update propagates everywhere.\n *\n * VS Code Copilot is a json-stdio host (report §2 \"Platform Integration Matrix\"):\n * - MCP servers: workspace (project) scope → <projectDir>/.vscode/mcp.json;\n * user-profile scope → ~/.vscode/mcp.json. The ROOT KEY is \"servers\" (NOT\n * \"mcpServers\" — a Cursor footgun VS Code deliberately diverges on), with an\n * optional sibling \"inputs\" array. The file is officially JSONC, but a plain\n * JSON write is valid JSONC, so we write strict JSON.\n * - Hooks (Preview, ~v1.110): discovered from .github/hooks/*.json (and from\n * Claude-compatible .claude/settings.json). We write a per-connector file at\n * <projectDir>/.github/hooks/<connector-id>.json shaped like the Copilot\n * hooks schema: `{ version: 1, hooks: { <PascalCaseEvent>: [ { type:\n * \"command\", command } ] } }`. The top-level `version: 1` is REQUIRED — the\n * Copilot runtime rejects a version-less file and no hooks fire. Unlike\n * Claude, each entry is a FLAT `{ type, command }` object (no `{ matcher,\n * hooks:[...] }` wrapper). Matchers are parsed but IGNORED (all hooks fire\n * on all tools) — we still persist a connector-declared matcher for parity.\n * - Reply: Claude-compatible JSON on stdout (exit 0). A `hookSpecificOutput`\n * object keyed by PascalCase `hookEventName` carries permissionDecision\n * (deny|ask) + permissionDecisionReason, additionalContext, and (PreToolUse)\n * updatedInput. This mirrors the claude-code adapter exactly.\n *\n * Env interpolation: VS Code supports its own `${env:VAR}` (and `${input:VAR}`)\n * native interpolation, so env/header/url values are rewritten to the native\n * `${env:VAR}` token rather than baked into the file. The token is documented at\n * vscodeEnvToken below.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n CommandDef,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n NotificationEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PostCompactEvent,\n PreCompactEvent,\n PreToolUseEvent,\n ServerDef,\n SessionEndEvent,\n SessionStartEvent,\n SkillDef,\n StopEvent,\n SubagentDef,\n SubagentStartEvent,\n SubagentStopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { rewriteEnvRefs } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinHookCommand,\n buildServeWrapperCommand,\n isHomeBinHookCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"vscode-copilot\";\n\n/**\n * VS Code's MCP root key is \"servers\" — NOT \"mcpServers\". This is the single\n * most common VS Code Copilot integration bug (report §1): a config written\n * under \"mcpServers\" is silently ignored.\n */\nconst MCP_ROOT_KEY = \"servers\";\n\n/** Top-level version the Copilot hooks runtime requires; a version-less file is rejected. */\nconst VSCODE_HOOKS_VERSION = 1;\n\n/**\n * VS Code Copilot reads PascalCase hook event names from its hooks file —\n * identical to Claude Code. Only the events VS Code actually delivers are\n * registered; everything else has no Copilot equivalent and is reported as a\n * warn/skip at install time.\n *\n * VS Code's official Hook Events table (microsoft/vscode-copilot-chat:\n * assets/prompts/skills/agent-customization/references/hooks.md) is, verbatim\n * (PascalCase): SessionStart, UserPromptSubmit, PreToolUse, PostToolUse,\n * PreCompact, SubagentStart, SubagentStop, Stop — all eight now wired 1:1.\n * SessionEnd, Notification, PermissionRequest and PostToolUseFailure are NOT in\n * the list — they have no VS Code analog and skip-warn.\n */\nconst EVENT_MAP: Partial<Record<HookEventName, string>> = {\n PreToolUse: \"PreToolUse\",\n PostToolUse: \"PostToolUse\",\n PreCompact: \"PreCompact\",\n SessionStart: \"SessionStart\",\n UserPromptSubmit: \"UserPromptSubmit\",\n Stop: \"Stop\",\n SubagentStart: \"SubagentStart\",\n SubagentStop: \"SubagentStop\",\n};\n\n/** A single VS Code Copilot native hook entry — a flat command object. */\ninterface VSCodeHookEntry {\n type: \"command\";\n command: string;\n}\n\n/** The shape of a VS Code Copilot .github/hooks/<connector>.json file. */\ninterface VSCodeHooksFile {\n version?: number;\n hooks?: Record<string, VSCodeHookEntry[]>;\n}\n\n/** Native MCP server entry shapes VS Code accepts under `servers`. */\ninterface VSCodeStdioServer {\n type: \"stdio\";\n command: string;\n args?: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\ninterface VSCodeHttpServer {\n type: \"http\" | \"sse\";\n url: string;\n headers?: Record<string, string>;\n}\n\n/** Raw VS Code Copilot hook stdin payload (Claude-compatible snake_case fields). */\ninterface VSCodeWireInput {\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n workspace_roots?: string[];\n hook_event_name?: string;\n\n // tool events\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: unknown;\n tool_output?: string;\n error_message?: string;\n\n // SessionStart\n source?: string;\n // SessionEnd\n reason?: string;\n // UserPromptSubmit\n prompt?: string;\n // PreCompact\n trigger?: string;\n // Stop / SubagentStop\n stop_hook_active?: boolean;\n // Notification\n message?: string;\n\n // SubagentStart / SubagentStop — Claude-compatible snake_case fields.\n // agent_type is unreliable on SubagentStop; treat both as optional.\n agent_id?: string;\n agent_type?: string;\n // SubagentStop — the subagent's OWN transcript + its final response text.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n\n /** Injected by the entrypoint so the runtime knows which connector to dispatch. */\n connector?: string;\n}\n\nexport class VSCodeCopilotAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"VS Code Copilot\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block via the BaseAdapter default\n // (memoryTargets: project <projectDir>/AGENTS.md; user scope where documented).\n supportsMemory: true,\n // VS Code Copilot's Preview hooks runtime delivers all eight events in its\n // official Hook Events table: Pre/PostToolUse, PreCompact, SessionStart,\n // UserPromptSubmit, Stop, and Subagent Start/Stop. PostToolUse, UserPromptSubmit,\n // Stop and SubagentStop are BLOCKABLE via the top-level {decision:\"block\"} shape;\n // PreToolUse permission flows through hookSpecificOutput.permissionDecision (per\n // the Output Contract — see formatReply).\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // Newer events: VS Code's Preview hooks runtime delivers SubagentStart /\n // SubagentStop (Claude-compatible). permissionRequest / postToolUseFailure\n // stay unset — no VS Code analog exists; install reports the skip-warn.\n subagentStart: true,\n subagentStop: true,\n // PreToolUse can rewrite tool input (updatedInput) but a PostToolUse hook\n // cannot rewrite already-emitted tool output — same as Claude/Cursor.\n canModifyArgs: true,\n canModifyOutput: false,\n canInjectSessionContext: true,\n transports: [\"stdio\", \"http\", \"sse\"],\n // Content surfaces: VS Code Copilot authors prompt files, Agent Skills, and\n // chat-mode agent files under the workspace .github/ tree (see content-file\n // path helpers below). All three are supported.\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".vscode\");\n const userMcp = join(userDir, \"mcp.json\");\n const userInsidersDir = join(homedir(), \".vscode-insiders\");\n const projectVscode = join(projectDir, \".vscode\");\n const projectMcp = join(projectVscode, \"mcp.json\");\n\n const projInstalled = existsSync(projectMcp) || existsSync(projectVscode);\n const userInstalled =\n existsSync(userMcp) || existsSync(userDir) || existsSync(userInsidersDir);\n const installed = projInstalled || userInstalled;\n\n // Report the scope/path/reason for the marker that actually matched, so a\n // project-only install isn't misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectMcp : userMcp;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project VS Code config at ${projectVscode}`\n : `found VS Code config under ${userDir}`\n : `no VS Code config at ${userDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n /**\n * Config dir choice (documented per task brief): project (workspace) scope →\n * <projectDir>/.vscode; user-profile scope → ~/.vscode. The real VS Code user\n * profile dir is OS-specific and not reliably discoverable without launching\n * VS Code, so ~/.vscode is the reasonable, cross-OS, no-launch choice — it is\n * also where \"MCP: Open User Configuration\" writes on a default profile.\n */\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".vscode\")\n : join(homedir(), \".vscode\");\n }\n\n /** MCP server registration lives in <configDir>/mcp.json under root \"servers\". */\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * Hook registration lives in the workspace-discovered .github/hooks tree,\n * which VS Code Copilot scans for *.json hook files. We write one file per\n * connector so installs/uninstalls never clobber another connector's hooks.\n * Anchored on projectDir for both scopes — .github/hooks is a workspace\n * concept (there is no user-profile equivalent in the Copilot hooks schema).\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(ctx.projectDir, \".github\", \"hooks\", `${ctx.connector.id}.json`);\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for vscode-copilot\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into VS Code's native `servers` entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): VSCodeStdioServer | VSCodeHttpServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(\n ctx.homeBinPath,\n ctx.connector.id,\n command,\n args,\n ctx.scope,\n this.id,\n );\n command = wrapped.command;\n args = wrapped.args;\n }\n\n const entry: VSCodeStdioServer = { type: \"stdio\", command: this.rewrite(command) };\n if (args.length > 0) entry.args = args.map((a) => this.rewrite(a));\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n if (server.cwd) entry.cwd = this.rewrite(server.cwd);\n return entry;\n }\n\n // Remote transports — VS Code registers a URL. An explicit `sse` forces an\n // SSE-only connection; `http` (Streamable HTTP) auto-falls-back to SSE when a\n // server doesn't support it (code.visualstudio.com/docs/agents/reference/mcp-configuration).\n const entry: VSCodeHttpServer = {\n type: transport === \"sse\" ? \"sse\" : \"http\",\n url: this.rewrite(server.url ?? \"\"),\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. VS Code supports its own `${env:VAR}` native\n * interpolation, so translate `${env:VAR}` refs to that native token rather\n * than baking secrets into the file. Literals pass through unchanged.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(env)) out[k] = this.rewrite(v);\n return out;\n }\n\n /** Translate `${env:VAR(:-default)}` to VS Code's native `${env:VAR}` token. */\n private rewrite(value: string): string {\n return rewriteEnvRefs(value, vscodeEnvToken);\n }\n\n // ── Hook install / uninstall ─────────────────────────────────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.hooks === false) {\n return [\n { platform: this.id, action: \"skip\", detail: \"hooks disabled for vscode-copilot\" },\n ];\n }\n if (connector.hookEvents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no hooks\" }];\n }\n\n const hooksPath = this.getHookConfigPath(ctx);\n const file = this.readJson<VSCodeHooksFile>(hooksPath) ?? {};\n const hooks = (file.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of connector.hookEvents) {\n const vscodeEvent = EVENT_MAP[event];\n if (!vscodeEvent) {\n // No VS Code Copilot equivalent for this normalized event — report+skip.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: hooksPath,\n detail: `${event} has no VS Code Copilot hook equivalent — skipped`,\n });\n continue;\n }\n\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const entry: VSCodeHookEntry = { type: \"command\", command };\n\n const bucket = (hooks[vscodeEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => this.isOurCommand(e.command, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: `hooks.${vscodeEvent} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: hooksPath,\n detail: `hooks.${vscodeEvent}`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: hooksPath,\n detail: `hooks.${vscodeEvent}`,\n });\n }\n mutated = true;\n }\n\n if (mutated) {\n // The top-level version is REQUIRED — a version-less file is rejected and\n // no hooks fire. Always (re)assert it when we write.\n file.version = VSCODE_HOOKS_VERSION;\n this.writeJson(hooksPath, file, ctx.dryRun);\n }\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const hooksPath = this.getHookConfigPath(ctx);\n const file = this.readJson<VSCodeHooksFile>(hooksPath);\n const hooks = file?.hooks;\n if (!file || !hooks) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no hooks section present\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const vscodeEvent of Object.keys(hooks)) {\n const bucket = hooks[vscodeEvent];\n if (!Array.isArray(bucket)) continue;\n\n const before = bucket.length;\n // Only strip OUR connector's home-bin commands — never another\n // connector's (isHomeBinHookCommand is id-anchored).\n const next = bucket.filter((e) => !this.isOurCommand(e.command, ctx));\n const removed = before - next.length;\n if (removed > 0) {\n if (next.length > 0) hooks[vscodeEvent] = next;\n else delete hooks[vscodeEvent];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: hooksPath,\n detail: `hooks.${vscodeEvent} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(hooksPath, file, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n /** True when a hook command references our home binary AND this connector id\n * (anchored so a shared-prefix id can't collide — see isHomeBinHookCommand). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Content surfaces: commands / skills / subagents ──────────────────────\n // CONTENT-ONLY: pure native-file writers under the workspace .github/ tree\n // ({prompts,skills,agents}). No runtime dispatch, no home-bin pointer, no\n // telemetry wrap. Each method is idempotent (byte-identical → skip) via\n // BaseAdapter.writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"vscode-copilot\"] per-surface false to skip.\n //\n // SHARED .github TREE: vscode-copilot, copilot-cli, and jetbrains-copilot all\n // write under the SAME project <projectDir>/.github tree. The rendered content\n // is identical and idempotent across those connectors, and uninstall here only\n // removes the files THIS connector declared — never another writer's files.\n //\n // SCOPE NOTE: .github is a workspace concept; the Copilot prompt/skill/agent\n // discovery is workspace-rooted and there is no documented per-user .github\n // authoring location. VS Code's reliable per-user authoring root is the user\n // profile prompts dir under the OS app-data path, which is not discoverable\n // without launching VS Code. So for user scope we anchor on\n // <homedir>/.config/github-copilot (the documented cross-OS Copilot user dir;\n // see contentRootDir) rather than fabricating a profile path. Project scope is\n // the primary, fully-supported path.\n\n /**\n * Root of the content tree. Project (workspace) scope → <projectDir>/.github,\n * which VS Code Copilot scans for prompt/skill/agent files (and which\n * copilot-cli + jetbrains-copilot share). User scope has no documented\n * workspace-independent .github equivalent, so we anchor on the documented\n * cross-OS Copilot user dir ~/.config/github-copilot to keep user-scope writes\n * deterministic and removable.\n */\n private contentRootDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".github\")\n : join(homedir(), \".config\", \"github-copilot\");\n }\n\n private promptsDir(ctx: InstallContext): string {\n return join(this.contentRootDir(ctx), \"prompts\");\n }\n private skillsDir(ctx: InstallContext): string {\n // Project scope: .github/skills (a VS Code-documented project location).\n // User scope: ~/.agents/skills — the vendor-neutral Agent Skills location\n // VS Code reads for personal skills. Deliberately NOT ~/.copilot/skills\n // (also read): copilot-cli's adapter owns that dir, and two adapters\n // writing the same SKILL.md would fight over ownership at uninstall.\n // (~/.config/github-copilot/skills, the 0.1.0 target, is read by nothing.)\n return ctx.scope === \"project\"\n ? join(this.contentRootDir(ctx), \"skills\")\n : join(homedir(), \".agents\", \"skills\");\n }\n private agentsDir(ctx: InstallContext): string {\n return join(this.contentRootDir(ctx), \"agents\");\n }\n\n /** Native command file path: <ghDir>/prompts/<name>.prompt.md. */\n private commandPath(ctx: InstallContext, name: string): string {\n return join(this.promptsDir(ctx), `${name}.prompt.md`);\n }\n /** Native skill dir: <ghDir>/skills/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n /** Native subagent file path: <ghDir>/agents/<name>.agent.md. */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.agentsDir(ctx), `${name}.agent.md`);\n }\n\n // ── Commands ──────────────────────────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for vscode-copilot\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(\n this.commandPath(ctx, cmd.name),\n this.renderCommand(cmd),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n /** Render a VS Code Copilot prompt file: md+frontmatter(description, tools, model, argument-hint). */\n private renderCommand(cmd: CommandDef): string {\n const frontmatter: Record<string, unknown> = {};\n if (cmd.description !== undefined) frontmatter.description = cmd.description;\n // VS Code prompt files express tool access as a `tools` array, sourced from\n // the portable tools.allow policy.\n const allow = cmd.tools?.allow;\n if (allow && allow.length > 0) frontmatter.tools = [...allow];\n if (cmd.model !== undefined) frontmatter.model = cmd.model;\n if (cmd.argumentHint !== undefined) frontmatter[\"argument-hint\"] = cmd.argumentHint;\n if (cmd.extra) Object.assign(frontmatter, cmd.extra);\n return this.renderFrontmatterMd(frontmatter, cmd.prompt);\n }\n\n // ── Skills ────────────────────────────────────────────────────────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for vscode-copilot\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /**\n * Render a skill's SKILL.md — the uniform Agent Skills format: frontmatter\n * (name, description + optional model, allowed-tools, disable-model-invocation)\n * + body. Byte-identical to the other .github-sharing connectors so a shared\n * skill folder never thrashes.\n */\n private renderSkill(skill: SkillDef): string {\n const frontmatter: Record<string, unknown> = {\n name: skill.name,\n description: skill.description,\n };\n if (skill.model !== undefined) frontmatter.model = skill.model;\n const allow = skill.tools?.allow;\n if (allow && allow.length > 0) frontmatter[\"allowed-tools\"] = allow.join(\", \");\n if (skill.disableModelInvocation !== undefined) {\n frontmatter[\"disable-model-invocation\"] = skill.disableModelInvocation;\n }\n if (skill.extra) Object.assign(frontmatter, skill.extra);\n return this.renderFrontmatterMd(frontmatter, skill.body);\n }\n\n // ── Subagents ───────────────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for vscode-copilot\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(\n this.subagentPath(ctx, agent.name),\n this.renderSubagent(agent),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /** Render a subagent agent file: md+frontmatter(name, description, tools, model) + prompt body. */\n private renderSubagent(agent: SubagentDef): string {\n const frontmatter: Record<string, unknown> = {\n name: agent.name,\n description: agent.description,\n };\n const allow = agent.tools?.allow;\n if (allow && allow.length > 0) frontmatter.tools = allow.join(\", \");\n if (agent.model !== undefined) frontmatter.model = agent.model;\n if (agent.extra) Object.assign(frontmatter, agent.extra);\n return this.renderFrontmatterMd(frontmatter, agent.prompt);\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const hooksPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp.json present`,\n check: () =>\n existsSync(mcpPath)\n ? { status: \"OK\", detail: mcpPath }\n : { status: \"FAIL\", detail: `not found: ${mcpPath}` },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const file = this.readJson<VSCodeHooksFile>(hooksPath);\n if (!file) return { status: \"FAIL\", detail: `not found: ${hooksPath}` };\n if (file.version !== VSCODE_HOOKS_VERSION) {\n return {\n status: \"FAIL\",\n detail: `${hooksPath} missing required \"version\": ${VSCODE_HOOKS_VERSION} — Copilot rejects it`,\n };\n }\n const registered = Object.values(file.hooks ?? {}).some((entries) =>\n (entries ?? []).some((e) =>\n isHomeBinHookCommand(e.command, homeBin, connectorId),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${hooksPath}` };\n },\n },\n ];\n\n // Content-surface checks: only assert presence of the files this connector\n // declares (skip silently for surfaces it never asked for).\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(ctx, cmd.name);\n checks.push({\n name: `${this.name}: command ${cmd.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse VS Code Copilot stdin JSON → normalized event ──────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as VSCodeWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = extractSessionId(input);\n const projectDir = this.getProjectDir(input);\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const toolOutput =\n toolResponseToString(input.tool_response) ??\n input.tool_output ??\n input.error_message;\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(toolOutput !== undefined ? { toolOutput } : {}),\n ...(input.error_message ? { isError: true } : {}),\n };\n return ev;\n }\n case \"PreCompact\": {\n const ev: PreCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"PostCompact\": {\n // VS Code Copilot does not fire PostCompact natively (postCompact unset\n // → warn-skip at install). Parsed defensively, mirroring PreCompact, so\n // a manual/mis-routed dispatch normalizes instead of hitting the guard.\n const ev: PostCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source ?? input.trigger),\n };\n return ev;\n }\n case \"SessionEnd\": {\n const ev: SessionEndEvent = {\n ...base,\n ...(typeof input.reason === \"string\" ? { reason: input.reason } : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = {\n ...base,\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"Notification\": {\n const ev: NotificationEvent = {\n ...base,\n message: typeof input.message === \"string\" ? input.message : \"\",\n };\n return ev;\n }\n case \"SubagentStart\": {\n const ev: SubagentStartEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n };\n return ev;\n }\n case \"SubagentStop\": {\n // agent_id/agent_type stay optional — hosts do not reliably populate\n // agent_type on SubagentStop (Claude-compatible quirk).\n const ev: SubagentStopEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n ...(typeof input.agent_transcript_path === \"string\"\n ? { agentTranscriptPath: input.agent_transcript_path }\n : {}),\n ...(typeof input.last_assistant_message === \"string\"\n ? { lastAssistantMessage: input.last_assistant_message }\n : {}),\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"PermissionRequest\":\n case \"PostToolUseFailure\": {\n // No VS Code Copilot analog (its Preview event list has neither a\n // permission-dialog event nor a tool-failure event). Install already\n // skip-warns these; a runtime dispatch is a mis-route — fail loudly.\n throw new Error(`unsupported vscode-copilot hook event: ${String(event)}`);\n }\n default: {\n // Exhaustive guard — every HookEventName is handled above. (VS Code only\n // delivers the events in EVENT_MAP; the rest are handled defensively so\n // a mis-dispatch stays inert rather than crashing.)\n const _never: never = event;\n throw new Error(`unsupported vscode-copilot hook event: ${String(_never)}`);\n }\n }\n }\n\n /** Resolve the project dir from the wire payload, preferring the explicit cwd. */\n private getProjectDir(input: VSCodeWireInput): string | undefined {\n return input.cwd ?? input.workspace_roots?.[0] ?? undefined;\n }\n\n // ── Runtime: normalized response → VS Code Copilot native hook reply ──────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const hookEventName = event;\n const decision = response.decision ?? \"allow\";\n\n // SubagentStart is observe/context-only (the spawn is not blockable):\n // \"context\" injects additionalContext at the start of the SUBAGENT's\n // conversation, and a \"deny\" DEGRADES to the same shape carrying the\n // reason. Everything else passes through.\n if (event === \"SubagentStart\") {\n const context =\n decision === \"context\"\n ? response.additionalContext\n : decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: context },\n });\n }\n return { exitCode: 0 };\n }\n\n // deny → block the action with a reason (exit 0; JSON carries the decision).\n // Per VS Code's Output Contract, `hookSpecificOutput.permissionDecision` is\n // read ONLY for the pre-execution TOOL-permission event (PreToolUse). The\n // post-execution / turn-control events — PostToolUse, Stop, UserPromptSubmit\n // and SubagentStop — block via the TOP-LEVEL {\"decision\":\"block\",\"reason\"}\n // instead: PostToolUse blocks further processing (hooks.md: \"PostToolUse\n // output can block further processing with decision: block\") with `reason` as\n // feedback; Stop/SubagentStop keep the (sub)agent running with `reason` as the\n // next instruction; UserPromptSubmit blocks the prompt with `reason`. The tool\n // already ran by PostToolUse, so there is no permission left to grant — a\n // permissionDecision there is silently ignored (the old behaviour dropped the\n // deny).\n if (decision === \"deny\") {\n if (\n event === \"PostToolUse\" ||\n event === \"SubagentStop\" ||\n event === \"Stop\" ||\n event === \"UserPromptSubmit\"\n ) {\n return this.stdout({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n });\n }\n\n // ask → prompt the user to confirm.\n if (decision === \"ask\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"ask\",\n permissionDecisionReason:\n response.reason ?? \"Confirmation required by hook\",\n },\n });\n }\n\n // modify → rewrite PreToolUse input (only where VS Code supports it).\n if (decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, updatedInput: response.updatedInput },\n });\n }\n // Output rewrite is unsupported on VS Code; fall through to allow.\n }\n\n // context → inject soft guidance (also the SessionStart context path).\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: response.additionalContext },\n });\n }\n\n // allow / void / unsupported-degradation → pass through with exit 0.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\n/**\n * VS Code native interpolation token: `${env:VAR}` → `${env:VAR}` (passthrough).\n * VS Code also supports `${input:VAR}` (prompted/secret inputs declared in the\n * sibling `inputs` array); we keep portable `${env:VAR}` refs as the native env\n * token so secrets are never baked into the committed config.\n */\nfunction vscodeEnvToken(name: string): string {\n return `\\${env:${name}}`;\n}\n\n/**\n * Extract a stable session id from a VS Code Copilot wire payload. Priority\n * mirrors the Claude-compatible wire: transcript UUID > session_id > \"\" (the\n * framework uses \"\" when no id is available — no ppid fabrication here).\n */\nfunction extractSessionId(input: VSCodeWireInput): string {\n if (typeof input.transcript_path === \"string\") {\n const m = input.transcript_path.match(/([a-f0-9-]{36})\\.jsonl$/);\n if (m && m[1]) return m[1];\n }\n if (typeof input.session_id === \"string\" && input.session_id !== \"\") {\n return input.session_id;\n }\n return \"\";\n}\n\n/** Coerce a Claude-compatible PostToolUse `tool_response` into a string. */\nfunction toolResponseToString(value: unknown): string | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction normalizeSessionSource(source: string | undefined): SessionStartEvent[\"source\"] {\n switch (source) {\n case \"compact\":\n return \"compact\";\n case \"resume\":\n return \"resume\";\n case \"clear\":\n return \"clear\";\n default:\n return \"startup\";\n }\n}\n\nexport const adapter = new VSCodeCopilotAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAsCrB,IAAM,OAAmB;AAOzB,IAAM,eAAe;AAGrB,IAAM,uBAAuB;AAe7B,IAAM,YAAoD;AAAA,EACxD,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,cAAc;AAChB;AAoEO,IAAM,uBAAN,cAAmC,YAA+B;AAAA,EAC9D,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA,IAId,eAAe;AAAA,IACf,cAAc;AAAA;AAAA;AAAA,IAG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BAAyB;AAC/D,QAAI,KAAK,EAAE,CAAC,EAAG,QAAO,EAAE,CAAC;AAAA,EAC3B;AACA,MAAI,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,IAAI;AACnE,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AAGA,SAAS,qBAAqB,OAAoC;AAChE,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI;AACF,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;AAEA,SAAS,uBAAuB,QAAyD;AACvF,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,IAAM,UAAU,IAAI,qBAAqB;AAChD,IAAO,yBAAQ;","names":["entry"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|