@ken-jo/agent-connector 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/{action-PLZW5BGX.js → action-WT7GVRCC.js} +11 -10
- package/dist/{action-PLZW5BGX.js.map → action-WT7GVRCC.js.map} +1 -1
- package/dist/amazon-q-COAL3764.js +276 -0
- package/dist/amazon-q-COAL3764.js.map +1 -0
- package/dist/{amp-B524U6LO.js → amp-4U33CU7E.js} +3 -3
- package/dist/{antigravity-ANDKF3K7.js → antigravity-AMKKKHS4.js} +4 -4
- package/dist/{antigravity-cli-LLRPDDOT.js → antigravity-cli-XERXEH5W.js} +4 -4
- package/dist/{chunk-KGJWE6A2.js → chunk-24IDL5RW.js} +2 -2
- package/dist/{chunk-CIRDOY2V.js → chunk-2AVLX7GH.js} +3 -3
- package/dist/{chunk-ADTHT2FN.js → chunk-4ENJK5S2.js} +10 -173
- package/dist/chunk-4ENJK5S2.js.map +1 -0
- package/dist/{chunk-BHUCB6LY.js → chunk-5OWS5CMA.js} +8 -7
- package/dist/{chunk-BHUCB6LY.js.map → chunk-5OWS5CMA.js.map} +1 -1
- package/dist/{chunk-IW77FFNX.js → chunk-CPLK7GTE.js} +41 -5
- package/dist/chunk-CPLK7GTE.js.map +1 -0
- package/dist/chunk-DCKFYWGM.js +237 -0
- package/dist/chunk-DCKFYWGM.js.map +1 -0
- package/dist/{chunk-J3D5W5T2.js → chunk-EGCBZ2DC.js} +2 -2
- package/dist/{chunk-22Y24V7O.js → chunk-F5RX62T7.js} +2 -2
- package/dist/chunk-FAHIMJRU.js +177 -0
- package/dist/chunk-FAHIMJRU.js.map +1 -0
- package/dist/{chunk-BXGFUENQ.js → chunk-I5MLE6S7.js} +14 -1
- package/dist/{chunk-BXGFUENQ.js.map → chunk-I5MLE6S7.js.map} +1 -1
- package/dist/{chunk-LL4OBGRU.js → chunk-LQRAPXS4.js} +3 -3
- package/dist/{chunk-KGXDYGNJ.js → chunk-O5TWCIJN.js} +19 -19
- package/dist/{chunk-KGXDYGNJ.js.map → chunk-O5TWCIJN.js.map} +1 -1
- package/dist/{chunk-MAH6QQTO.js → chunk-QREL7LZJ.js} +5 -4
- package/dist/chunk-QREL7LZJ.js.map +1 -0
- package/dist/{chunk-G3ER4SY5.js → chunk-RIMVWCZY.js} +9 -9
- package/dist/{chunk-6XHB6BE3.js → chunk-SCVBYSF7.js} +1 -1
- package/dist/{chunk-KGGBNKI4.js → chunk-URHQMFB3.js} +90 -13
- package/dist/chunk-URHQMFB3.js.map +1 -0
- package/dist/chunk-WZA4CSGJ.js +28 -0
- package/dist/chunk-WZA4CSGJ.js.map +1 -0
- package/dist/{chunk-76FUSVIA.js → chunk-XJ4S47CT.js} +6 -5
- package/dist/chunk-XJ4S47CT.js.map +1 -0
- package/dist/{claude-code-MLWS7CW6.js → claude-code-W4PUFZL5.js} +20 -30
- package/dist/claude-code-W4PUFZL5.js.map +1 -0
- package/dist/cli/sdk.js +5 -4
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cline-WRYMNS7Z.js +442 -0
- package/dist/cline-WRYMNS7Z.js.map +1 -0
- package/dist/{codebuff-SH2S3QAN.js → codebuff-DH5Y7GAT.js} +8 -4
- package/dist/codebuff-DH5Y7GAT.js.map +1 -0
- package/dist/{codex-BXA4FIF4.js → codex-DDHIV767.js} +43 -11
- package/dist/codex-DDHIV767.js.map +1 -0
- package/dist/continue-K43SUHLQ.js +790 -0
- package/dist/continue-K43SUHLQ.js.map +1 -0
- package/dist/{copilot-cli-ROIBTTDT.js → copilot-cli-Q3SSPT4V.js} +70 -12
- package/dist/copilot-cli-Q3SSPT4V.js.map +1 -0
- package/dist/{crush-QLEFLHUC.js → crush-MBEH2R3I.js} +130 -6
- package/dist/crush-MBEH2R3I.js.map +1 -0
- package/dist/{cursor-ASJPWZ4R.js → cursor-TMBXDYR4.js} +119 -19
- package/dist/cursor-TMBXDYR4.js.map +1 -0
- package/dist/{detect-ZIIS55LD.js → detect-KG5FG3EV.js} +5 -4
- package/dist/{detect-ZIIS55LD.js.map → detect-KG5FG3EV.js.map} +1 -1
- package/dist/{doctor-TJUGSQ5C.js → doctor-FLZF34Y3.js} +221 -95
- package/dist/doctor-FLZF34Y3.js.map +1 -0
- package/dist/{droid-NCSS3B5Y.js → droid-JC2NT6S4.js} +135 -13
- package/dist/droid-JC2NT6S4.js.map +1 -0
- package/dist/{gemini-cli-SLVWLXJW.js → gemini-cli-ILR7M5X3.js} +62 -10
- package/dist/gemini-cli-ILR7M5X3.js.map +1 -0
- package/dist/{goose-PBA7KTE5.js → goose-SFO5BBGW.js} +15 -8
- package/dist/goose-SFO5BBGW.js.map +1 -0
- package/dist/{hermes-ONDCECP2.js → hermes-3N7WN4WS.js} +329 -15
- package/dist/hermes-3N7WN4WS.js.map +1 -0
- package/dist/{hook-OU522ABV.js → hook-XR3Z45FB.js} +14 -11
- package/dist/hook-XR3Z45FB.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/{install-UDCBL7HP.js → install-BSR62UHJ.js} +11 -10
- package/dist/{install-UDCBL7HP.js.map → install-BSR62UHJ.js.map} +1 -1
- package/dist/{introspect-DuZSPSHB.d.ts → introspect-Nw8hTReX.d.ts} +1 -1
- package/dist/{jetbrains-copilot-YABZ3HFA.js → jetbrains-copilot-NRZHI5PC.js} +85 -18
- package/dist/jetbrains-copilot-NRZHI5PC.js.map +1 -0
- package/dist/{kilo-F3ZDZKCT.js → kilo-5NWOXVSD.js} +16 -16
- package/dist/kilo-5NWOXVSD.js.map +1 -0
- package/dist/{kilo-cli-3HWPWBY4.js → kilo-cli-UZ7R5UOP.js} +3 -3
- package/dist/{kimi-NV72FVAO.js → kimi-2YFK2GBA.js} +87 -25
- package/dist/kimi-2YFK2GBA.js.map +1 -0
- package/dist/{kiro-C5W6AGDR.js → kiro-YL6AWUYG.js} +3 -3
- package/dist/{leaderboard-TIBVONVT.js → leaderboard-MJG24O35.js} +3 -3
- package/dist/{mimo-code-IMM5YM3M.js → mimo-code-FTMGSKMQ.js} +41 -5
- package/dist/mimo-code-FTMGSKMQ.js.map +1 -0
- package/dist/{mux-DSSH4AFS.js → mux-5XZFB44C.js} +156 -6
- package/dist/mux-5XZFB44C.js.map +1 -0
- package/dist/{nemoclaw-3EVNKD3I.js → nemoclaw-W5KEJ3WX.js} +4 -4
- package/dist/{omp-Z6FRNDPN.js → omp-2QMEY6HD.js} +138 -18
- package/dist/omp-2QMEY6HD.js.map +1 -0
- package/dist/{openclaw-7G437NT7.js → openclaw-EXJEFNZI.js} +4 -4
- package/dist/{opencode-Q6KBSAKW.js → opencode-WNXYJR4X.js} +84 -27
- package/dist/opencode-WNXYJR4X.js.map +1 -0
- package/dist/{package-RMPN57YZ.js → package-ACZXJHWB.js} +8 -7
- package/dist/{package-RMPN57YZ.js.map → package-ACZXJHWB.js.map} +1 -1
- package/dist/{pi-LZT6WWAZ.js → pi-PVVPVWKG.js} +3 -2
- package/dist/{pi-LZT6WWAZ.js.map → pi-PVVPVWKG.js.map} +1 -1
- package/dist/{qwen-code-WQBKRPWJ.js → qwen-code-G4CXKUHR.js} +426 -10
- package/dist/qwen-code-G4CXKUHR.js.map +1 -0
- package/dist/{roo-code-GWSNU3OW.js → roo-code-67TYJIQR.js} +3 -3
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +9 -8
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk/index.js +4 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/test.d.ts +2 -2
- package/dist/sdk/test.js +6 -5
- package/dist/sdk/test.js.map +1 -1
- package/dist/{serve-D3GO36UT.js → serve-GER7URPR.js} +11 -10
- package/dist/{serve-D3GO36UT.js.map → serve-GER7URPR.js.map} +1 -1
- package/dist/{status-KOSKCETC.js → status-LAJE3BM5.js} +7 -6
- package/dist/{status-KOSKCETC.js.map → status-LAJE3BM5.js.map} +1 -1
- package/dist/{statusline-ZNTCL5YC.js → statusline-L376ZPZU.js} +10 -9
- package/dist/{statusline-ZNTCL5YC.js.map → statusline-L376ZPZU.js.map} +1 -1
- package/dist/{telemetry-XIKUUGTQ.js → telemetry-B3DX3PWU.js} +6 -5
- package/dist/{telemetry-XIKUUGTQ.js.map → telemetry-B3DX3PWU.js.map} +1 -1
- package/dist/{trae-NWT3TMSZ.js → trae-7CZZGOGI.js} +3 -3
- package/dist/{types-BEKsAium.d.ts → types-CRVrFWeU.d.ts} +64 -22
- package/dist/{uninstall-2LBLQVFA.js → uninstall-ZYTW7YMZ.js} +11 -10
- package/dist/{uninstall-2LBLQVFA.js.map → uninstall-ZYTW7YMZ.js.map} +1 -1
- package/dist/{upgrade-ZC2S7VRN.js → upgrade-4LUEEOZW.js} +11 -10
- package/dist/{upgrade-ZC2S7VRN.js.map → upgrade-4LUEEOZW.js.map} +1 -1
- package/dist/{usage-E2A4O2CY.js → usage-ZFBVQF3H.js} +3 -3
- package/dist/{usage-event-JKMC4QC4.js → usage-event-GZ32AGEB.js} +10 -9
- package/dist/{usage-event-JKMC4QC4.js.map → usage-event-GZ32AGEB.js.map} +1 -1
- package/dist/{vscode-copilot-ALV45XF6.js → vscode-copilot-MF2CDNMT.js} +23 -10
- package/dist/vscode-copilot-MF2CDNMT.js.map +1 -0
- package/dist/{warp-H6IX4U3J.js → warp-VKG55TAT.js} +55 -4
- package/dist/warp-VKG55TAT.js.map +1 -0
- package/dist/windsurf-FU5G4SHF.js +443 -0
- package/dist/windsurf-FU5G4SHF.js.map +1 -0
- package/dist/{zed-RH34TNSW.js → zed-SFUHL3GS.js} +3 -3
- package/package.json +2 -2
- package/dist/chunk-3PFFTFCU.js +0 -190
- package/dist/chunk-3PFFTFCU.js.map +0 -1
- package/dist/chunk-76FUSVIA.js.map +0 -1
- package/dist/chunk-ADTHT2FN.js.map +0 -1
- package/dist/chunk-IW77FFNX.js.map +0 -1
- package/dist/chunk-KGGBNKI4.js.map +0 -1
- package/dist/chunk-MAH6QQTO.js.map +0 -1
- package/dist/claude-code-MLWS7CW6.js.map +0 -1
- package/dist/codebuff-SH2S3QAN.js.map +0 -1
- package/dist/codex-BXA4FIF4.js.map +0 -1
- package/dist/copilot-cli-ROIBTTDT.js.map +0 -1
- package/dist/crush-QLEFLHUC.js.map +0 -1
- package/dist/cursor-ASJPWZ4R.js.map +0 -1
- package/dist/doctor-TJUGSQ5C.js.map +0 -1
- package/dist/droid-NCSS3B5Y.js.map +0 -1
- package/dist/gemini-cli-SLVWLXJW.js.map +0 -1
- package/dist/goose-PBA7KTE5.js.map +0 -1
- package/dist/hermes-ONDCECP2.js.map +0 -1
- package/dist/hook-OU522ABV.js.map +0 -1
- package/dist/jetbrains-copilot-YABZ3HFA.js.map +0 -1
- package/dist/kilo-F3ZDZKCT.js.map +0 -1
- package/dist/kimi-NV72FVAO.js.map +0 -1
- package/dist/mimo-code-IMM5YM3M.js.map +0 -1
- package/dist/mux-DSSH4AFS.js.map +0 -1
- package/dist/omp-Z6FRNDPN.js.map +0 -1
- package/dist/opencode-Q6KBSAKW.js.map +0 -1
- package/dist/qwen-code-WQBKRPWJ.js.map +0 -1
- package/dist/vscode-copilot-ALV45XF6.js.map +0 -1
- package/dist/warp-H6IX4U3J.js.map +0 -1
- /package/dist/{amp-B524U6LO.js.map → amp-4U33CU7E.js.map} +0 -0
- /package/dist/{antigravity-ANDKF3K7.js.map → antigravity-AMKKKHS4.js.map} +0 -0
- /package/dist/{antigravity-cli-LLRPDDOT.js.map → antigravity-cli-XERXEH5W.js.map} +0 -0
- /package/dist/{chunk-KGJWE6A2.js.map → chunk-24IDL5RW.js.map} +0 -0
- /package/dist/{chunk-CIRDOY2V.js.map → chunk-2AVLX7GH.js.map} +0 -0
- /package/dist/{chunk-J3D5W5T2.js.map → chunk-EGCBZ2DC.js.map} +0 -0
- /package/dist/{chunk-22Y24V7O.js.map → chunk-F5RX62T7.js.map} +0 -0
- /package/dist/{chunk-LL4OBGRU.js.map → chunk-LQRAPXS4.js.map} +0 -0
- /package/dist/{chunk-G3ER4SY5.js.map → chunk-RIMVWCZY.js.map} +0 -0
- /package/dist/{chunk-6XHB6BE3.js.map → chunk-SCVBYSF7.js.map} +0 -0
- /package/dist/{kilo-cli-3HWPWBY4.js.map → kilo-cli-UZ7R5UOP.js.map} +0 -0
- /package/dist/{kiro-C5W6AGDR.js.map → kiro-YL6AWUYG.js.map} +0 -0
- /package/dist/{leaderboard-TIBVONVT.js.map → leaderboard-MJG24O35.js.map} +0 -0
- /package/dist/{nemoclaw-3EVNKD3I.js.map → nemoclaw-W5KEJ3WX.js.map} +0 -0
- /package/dist/{openclaw-7G437NT7.js.map → openclaw-EXJEFNZI.js.map} +0 -0
- /package/dist/{roo-code-GWSNU3OW.js.map → roo-code-67TYJIQR.js.map} +0 -0
- /package/dist/{trae-NWT3TMSZ.js.map → trae-7CZZGOGI.js.map} +0 -0
- /package/dist/{usage-E2A4O2CY.js.map → usage-ZFBVQF3H.js.map} +0 -0
- /package/dist/{zed-RH34TNSW.js.map → zed-SFUHL3GS.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
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,IAK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AAI,SAAS,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,EAAG;AACtE,WAAO;AAAA,EACT;AACA,SAAO,KAAK,SAAS,SAAS,SAAS,CAAC,CAAE;AAC5C;AASA,SAAS,iBAAiB,OAA8B;AACtD,MAAI,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,IAAI;AACnE,WAAO,MAAM;AAAA,EACf;AACA,MAAI,OAAO,MAAM,oBAAoB,UAAU;AAC7C,UAAM,IAAI,MAAM,gBAAgB,MAAM,yBAAyB;AAC/D,QAAI,KAAK,EAAE,CAAC,EAAG,QAAO,EAAE,CAAC;AAAA,EAC3B;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,gBAAgB;AAC3C,IAAO,oBAAQ;","names":["entry","headers"]}
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-DBQMX75U.js";
|
|
5
5
|
import {
|
|
6
6
|
BaseAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-CPLK7GTE.js";
|
|
8
8
|
import "./chunk-7L6ITC4T.js";
|
|
9
9
|
import {
|
|
10
10
|
buildServeWrapperCommand,
|
|
11
11
|
shouldWrapForTelemetry
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-I5MLE6S7.js";
|
|
13
13
|
import "./chunk-N6HH7K6P.js";
|
|
14
14
|
import "./chunk-TRQKHP7D.js";
|
|
15
15
|
|
|
@@ -396,4 +396,4 @@ export {
|
|
|
396
396
|
adapter,
|
|
397
397
|
roo_code_default as default
|
|
398
398
|
};
|
|
399
|
-
//# sourceMappingURL=roo-code-
|
|
399
|
+
//# sourceMappingURL=roo-code-67TYJIQR.js.map
|
package/dist/runtime/index.d.ts
CHANGED
package/dist/runtime/index.js
CHANGED
|
@@ -4,21 +4,22 @@ import {
|
|
|
4
4
|
runServe,
|
|
5
5
|
runStatusline,
|
|
6
6
|
runUsageEvent
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-5OWS5CMA.js";
|
|
8
8
|
import "../chunk-OP4KBXUO.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-F5RX62T7.js";
|
|
10
|
+
import "../chunk-EGCBZ2DC.js";
|
|
11
11
|
import {
|
|
12
12
|
isNativeHookDeclared,
|
|
13
13
|
runHook,
|
|
14
14
|
runNativeHook
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-2AVLX7GH.js";
|
|
16
16
|
import "../chunk-BCHWFTV4.js";
|
|
17
17
|
import "../chunk-KHO5WNTP.js";
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-24IDL5RW.js";
|
|
19
|
+
import "../chunk-4ENJK5S2.js";
|
|
20
|
+
import "../chunk-DCKFYWGM.js";
|
|
21
|
+
import "../chunk-FAHIMJRU.js";
|
|
22
|
+
import "../chunk-I5MLE6S7.js";
|
|
22
23
|
import "../chunk-N6HH7K6P.js";
|
|
23
24
|
import "../chunk-TRQKHP7D.js";
|
|
24
25
|
export {
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ConnectorConfigError, defineAction, defineCommand, defineConfigPatch, defineConnector, defineHook, defineMemory, defineNativeHook, defineSkill, defineStatusline, defineSubagent } from '../index.js';
|
|
2
|
-
export { S as SURFACE_PREDICATES, a as SurfaceName, c as capabilitiesOf, h as hostsSupporting, s as surfaceSupport } from '../introspect-
|
|
3
|
-
import { P as PlatformId } from '../types-
|
|
4
|
-
export { A as ActionDef, a as ActionResult, b as AuthSpec, C as CommandDef, c as ConfigPatchDef, d as ConnectorConfig, E as EventPayloadMap, H as HookDefinition, e as HookEventName, f as HookParadigm, g as HookResponse, h as HooksConfig, i as HostCtx, I as InstallScope, J as JsonValue, M as MemoryDef, N as NativeHookDef, j as NativeHookEvent, k as NotificationEvent, l as PermissionRequestEvent, m as PlatformCapabilities, n as PlatformMemoryOverride, o as PlatformOverride, p as PostToolUseEvent, q as PostToolUseFailureEvent, r as PreCompactEvent, s as PreToolUseEvent, t as PublishConfig, R as ResolvedConnector, S as ServerDef, u as SessionEndEvent, v as SessionStartEvent, w as SkillDef, x as StatuslineContext, y as StatuslineDef, z as StopEvent, B as SubagentDef, D as SubagentStartEvent, F as SubagentStopEvent, G as SurfaceToolPolicy, T as TelemetryAccessor, K as TelemetryConfig, L as TelemetryUsageSummary, O as ToolFilter, Q as Transport, U as UserPromptSubmitEvent } from '../types-
|
|
2
|
+
export { S as SURFACE_PREDICATES, a as SurfaceName, c as capabilitiesOf, h as hostsSupporting, s as surfaceSupport } from '../introspect-Nw8hTReX.js';
|
|
3
|
+
import { P as PlatformId } from '../types-CRVrFWeU.js';
|
|
4
|
+
export { A as ActionDef, a as ActionResult, b as AuthSpec, C as CommandDef, c as ConfigPatchDef, d as ConnectorConfig, E as EventPayloadMap, H as HookDefinition, e as HookEventName, f as HookParadigm, g as HookResponse, h as HooksConfig, i as HostCtx, I as InstallScope, J as JsonValue, M as MemoryDef, N as NativeHookDef, j as NativeHookEvent, k as NotificationEvent, l as PermissionRequestEvent, m as PlatformCapabilities, n as PlatformMemoryOverride, o as PlatformOverride, p as PostToolUseEvent, q as PostToolUseFailureEvent, r as PreCompactEvent, s as PreToolUseEvent, t as PublishConfig, R as ResolvedConnector, S as ServerDef, u as SessionEndEvent, v as SessionStartEvent, w as SkillDef, x as StatuslineContext, y as StatuslineDef, z as StopEvent, B as SubagentDef, D as SubagentStartEvent, F as SubagentStopEvent, G as SurfaceToolPolicy, T as TelemetryAccessor, K as TelemetryConfig, L as TelemetryUsageSummary, O as ToolFilter, Q as Transport, U as UserPromptSubmitEvent } from '../types-CRVrFWeU.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* sdk/helpers — host-aware authoring helpers for connector handlers.
|
package/dist/sdk/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
capabilitiesOf,
|
|
5
5
|
hostsSupporting,
|
|
6
6
|
surfaceSupport
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-XJ4S47CT.js";
|
|
8
8
|
import {
|
|
9
9
|
ConnectorConfigError,
|
|
10
10
|
defineAction,
|
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
defineSkill,
|
|
18
18
|
defineStatusline,
|
|
19
19
|
defineSubagent
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-4ENJK5S2.js";
|
|
21
|
+
import "../chunk-DCKFYWGM.js";
|
|
22
|
+
import "../chunk-FAHIMJRU.js";
|
|
22
23
|
import "../chunk-N6HH7K6P.js";
|
|
23
24
|
import "../chunk-TRQKHP7D.js";
|
|
24
25
|
|
package/dist/sdk/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sdk/helpers.ts"],"sourcesContent":["/**\n * sdk/helpers — host-aware authoring helpers for connector handlers.\n *\n * A handler (a hook, a statusline render, an action run) sees the host it is\n * dispatched for via the {@link HostCtx} (`ctx.host`). These two helpers let a\n * handler render a host-correct value without hardcoding a per-host branch:\n *\n * • {@link toolName} — resolve a bare MCP tool name to the host's native\n * reference form (some hosts namespace MCP tools as `mcp__<id>__<tool>`).\n * • {@link style} — wrap text in an ANSI escape ONLY on hosts that render\n * ANSI in a status line / output; plain everywhere else.\n *\n * Both are deliberately MODEST, documented best-effort lists — NOT a capability\n * query. The per-host convention each encodes is not centrally modeled in\n * {@link PlatformCapabilities} yet; if either set grows it should migrate to a\n * capability flag (a `mcpToolPrefix` / `rendersAnsi` flag) the adapter declares.\n */\n\nimport type { PlatformId } from \"../core/types.js\";\n\n/**\n * Hosts that namespace MCP tools as `mcp__<connectorId>__<tool>` — the\n * `mcp__`-prefix convention Claude Code popularized and most MCP-client agents\n * adopted. CONFIRMED in-repo via the adapters' own `mcp__` PreToolUse matchers\n * for claude-code, codex, and kimi; the remaining members are MCP-client hosts\n * the convention applies to but are not separately verified here (a wrong\n * inclusion only ever yields a name the host doesn't resolve, the same outcome\n * as wrongly EXCLUDING a prefixing host — and an author can always construct the\n * reference themselves). This is a SMALL explicit set, not a capability query;\n * if it grows, migrate it to a per-adapter `mcpToolPrefix` capability flag.\n * (Follow-up: spot-verify gemini-cli / a copilot variant on a live box.)\n */\nconst PREFIXED_HOSTS: ReadonlySet<PlatformId> = new Set<PlatformId>([\n \"claude-code\",\n \"codex\",\n \"kimi\",\n \"cursor\",\n \"copilot-cli\",\n \"vscode-copilot\",\n \"jetbrains-copilot\",\n \"gemini-cli\",\n \"qwen-code\",\n]);\n\n/**\n * Resolve a bare MCP tool name to the host's native reference form.\n *\n * On a {@link PREFIXED_HOSTS} host the result is `mcp__<connectorId>__<baseName>`\n * (how those hosts surface a connector's MCP tools); on every other host it is\n * the bare `baseName`. When the host prefixes but no `connectorId` is supplied\n * the helper falls back to the bare name rather than emitting a malformed\n * `mcp__undefined__…` reference — it NEVER throws.\n */\nexport function toolName(\n ctx: { host: PlatformId; connectorId?: string },\n baseName: string,\n): string {\n if (PREFIXED_HOSTS.has(ctx.host) && ctx.connectorId) {\n return `mcp__${ctx.connectorId}__${baseName}`;\n }\n return baseName;\n}\n\n/**\n * Hosts that render ANSI escape sequences in a status line / terminal output —\n * the CLI/TUI hosts. IDE-embedded hosts (where output lands in a webview /\n * editor panel that shows the raw escape) are deliberately EXCLUDED. Like\n * {@link PREFIXED_HOSTS} this is a documented best-effort list, not a capability\n * query; migrate it to a `rendersAnsi` capability flag if it grows.\n */\nconst ANSI_HOSTS: ReadonlySet<PlatformId> = new Set<PlatformId>([\n \"claude-code\",\n \"codex\",\n \"gemini-cli\",\n \"qwen-code\",\n \"cursor\",\n \"copilot-cli\",\n \"opencode\",\n \"droid\",\n \"crush\",\n \"goose\",\n \"amp\",\n]);\n\n/**\n * Style `text` with an ANSI SGR escape on hosts that render it (a status line /\n * terminal output), plain everywhere else.\n *\n * When `ctx.host` is in {@link ANSI_HOSTS} and `codes.ansi` is provided, returns\n * `\\x1b[<ansi>m<text>\\x1b[0m`; otherwise returns `text` unchanged (an\n * IDE-embedded host, or no `ansi` code given). `codes.ansi` is the SGR\n * parameter(s), e.g. `\"1\"` (bold) or `\"1;32\"` (bold green).\n */\nexport function style(\n ctx: { host: PlatformId },\n text: string,\n codes: { ansi?: string },\n): string {\n if (codes.ansi && ANSI_HOSTS.has(ctx.host)) {\n return `\\x1b[${codes.ansi}m${text}\\x1b[0m`;\n }\n return text;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/helpers.ts"],"sourcesContent":["/**\n * sdk/helpers — host-aware authoring helpers for connector handlers.\n *\n * A handler (a hook, a statusline render, an action run) sees the host it is\n * dispatched for via the {@link HostCtx} (`ctx.host`). These two helpers let a\n * handler render a host-correct value without hardcoding a per-host branch:\n *\n * • {@link toolName} — resolve a bare MCP tool name to the host's native\n * reference form (some hosts namespace MCP tools as `mcp__<id>__<tool>`).\n * • {@link style} — wrap text in an ANSI escape ONLY on hosts that render\n * ANSI in a status line / output; plain everywhere else.\n *\n * Both are deliberately MODEST, documented best-effort lists — NOT a capability\n * query. The per-host convention each encodes is not centrally modeled in\n * {@link PlatformCapabilities} yet; if either set grows it should migrate to a\n * capability flag (a `mcpToolPrefix` / `rendersAnsi` flag) the adapter declares.\n */\n\nimport type { PlatformId } from \"../core/types.js\";\n\n/**\n * Hosts that namespace MCP tools as `mcp__<connectorId>__<tool>` — the\n * `mcp__`-prefix convention Claude Code popularized and most MCP-client agents\n * adopted. CONFIRMED in-repo via the adapters' own `mcp__` PreToolUse matchers\n * for claude-code, codex, and kimi; the remaining members are MCP-client hosts\n * the convention applies to but are not separately verified here (a wrong\n * inclusion only ever yields a name the host doesn't resolve, the same outcome\n * as wrongly EXCLUDING a prefixing host — and an author can always construct the\n * reference themselves). This is a SMALL explicit set, not a capability query;\n * if it grows, migrate it to a per-adapter `mcpToolPrefix` capability flag.\n * (Follow-up: spot-verify gemini-cli / a copilot variant on a live box.)\n */\nconst PREFIXED_HOSTS: ReadonlySet<PlatformId> = new Set<PlatformId>([\n \"claude-code\",\n \"codex\",\n \"kimi\",\n \"cursor\",\n \"copilot-cli\",\n \"vscode-copilot\",\n \"jetbrains-copilot\",\n \"gemini-cli\",\n \"qwen-code\",\n]);\n\n/**\n * Resolve a bare MCP tool name to the host's native reference form.\n *\n * On a {@link PREFIXED_HOSTS} host the result is `mcp__<connectorId>__<baseName>`\n * (how those hosts surface a connector's MCP tools); on every other host it is\n * the bare `baseName`. When the host prefixes but no `connectorId` is supplied\n * the helper falls back to the bare name rather than emitting a malformed\n * `mcp__undefined__…` reference — it NEVER throws.\n */\nexport function toolName(\n ctx: { host: PlatformId; connectorId?: string },\n baseName: string,\n): string {\n if (PREFIXED_HOSTS.has(ctx.host) && ctx.connectorId) {\n return `mcp__${ctx.connectorId}__${baseName}`;\n }\n return baseName;\n}\n\n/**\n * Hosts that render ANSI escape sequences in a status line / terminal output —\n * the CLI/TUI hosts. IDE-embedded hosts (where output lands in a webview /\n * editor panel that shows the raw escape) are deliberately EXCLUDED. Like\n * {@link PREFIXED_HOSTS} this is a documented best-effort list, not a capability\n * query; migrate it to a `rendersAnsi` capability flag if it grows.\n */\nconst ANSI_HOSTS: ReadonlySet<PlatformId> = new Set<PlatformId>([\n \"claude-code\",\n \"codex\",\n \"gemini-cli\",\n \"qwen-code\",\n \"cursor\",\n \"copilot-cli\",\n \"opencode\",\n \"droid\",\n \"crush\",\n \"goose\",\n \"amp\",\n]);\n\n/**\n * Style `text` with an ANSI SGR escape on hosts that render it (a status line /\n * terminal output), plain everywhere else.\n *\n * When `ctx.host` is in {@link ANSI_HOSTS} and `codes.ansi` is provided, returns\n * `\\x1b[<ansi>m<text>\\x1b[0m`; otherwise returns `text` unchanged (an\n * IDE-embedded host, or no `ansi` code given). `codes.ansi` is the SGR\n * parameter(s), e.g. `\"1\"` (bold) or `\"1;32\"` (bold green).\n */\nexport function style(\n ctx: { host: PlatformId },\n text: string,\n codes: { ansi?: string },\n): string {\n if (codes.ansi && ANSI_HOSTS.has(ctx.host)) {\n return `\\x1b[${codes.ansi}m${text}\\x1b[0m`;\n }\n return text;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAM,iBAA0C,oBAAI,IAAgB;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAWM,SAAS,SACd,KACA,UACQ;AACR,MAAI,eAAe,IAAI,IAAI,IAAI,KAAK,IAAI,aAAa;AACnD,WAAO,QAAQ,IAAI,WAAW,KAAK,QAAQ;AAAA,EAC7C;AACA,SAAO;AACT;AASA,IAAM,aAAsC,oBAAI,IAAgB;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAWM,SAAS,MACd,KACA,MACA,OACQ;AACR,MAAI,MAAM,QAAQ,WAAW,IAAI,IAAI,IAAI,GAAG;AAC1C,WAAO,QAAQ,MAAM,IAAI,IAAI,IAAI;AAAA,EACnC;AACA,SAAO;AACT;","names":[]}
|
package/dist/sdk/test.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlatformId, e as HookEventName, R as ResolvedConnector } from '../types-
|
|
2
|
-
import { a as SurfaceName } from '../introspect-
|
|
1
|
+
import { P as PlatformId, e as HookEventName, R as ResolvedConnector } from '../types-CRVrFWeU.js';
|
|
2
|
+
import { a as SurfaceName } from '../introspect-Nw8hTReX.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* sdk/test-harness — the SHIPPED, OFFLINE behavioral harness.
|
package/dist/sdk/test.js
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
compileMatcher,
|
|
4
4
|
eventMatcherSubject
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-2AVLX7GH.js";
|
|
6
6
|
import "../chunk-BCHWFTV4.js";
|
|
7
7
|
import "../chunk-KHO5WNTP.js";
|
|
8
8
|
import {
|
|
9
9
|
SURFACE_PREDICATES
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-XJ4S47CT.js";
|
|
11
|
+
import "../chunk-24IDL5RW.js";
|
|
12
|
+
import "../chunk-4ENJK5S2.js";
|
|
13
13
|
import {
|
|
14
14
|
allAdapters,
|
|
15
15
|
loadAdapter
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-DCKFYWGM.js";
|
|
17
|
+
import "../chunk-FAHIMJRU.js";
|
|
17
18
|
import "../chunk-N6HH7K6P.js";
|
|
18
19
|
import "../chunk-TRQKHP7D.js";
|
|
19
20
|
|
package/dist/sdk/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sdk/test-harness.ts"],"sourcesContent":["/**\n * sdk/test-harness — the SHIPPED, OFFLINE behavioral harness.\n *\n * Two read-only tools a connector author runs WITHOUT installing anything or\n * touching the host's filesystem:\n *\n * • `explain(connector)` — the static per-host × per-DECLARED-surface matrix:\n * for every registered host and every surface the connector actually ships,\n * is it `native` (the host can honor it), `disabled` (the connector opted\n * out for that host via `platforms[host].<surface> === false`), or\n * `skip-warn` (the host cannot honor it → install would skip-warn)?\n *\n * • `simulate(connector, opts)` — runs the REAL adapter parse → handler →\n * format chain INLINE against a host-shaped raw payload and reports whether\n * the host actually HONORS the connector's response (the trustworthy part:\n * it surfaces the documented degradations, e.g. Codex silently dropping a\n * UserPromptSubmit \"context\" injection that has no stdout path).\n *\n * It deliberately does NOT import the runtime entrypoints (runHook /\n * runStatusline) — those load the REGISTERED connector from disk and record\n * telemetry. The harness instead re-implements the tiny parse→handler→format\n * chain against the in-memory connector + the adapter, mirroring the runtime's\n * input tolerance (empty/malformed payload → `{}`) and its fail-safe envelope.\n */\n\nimport type {\n HookEventName,\n HookResponse,\n PlatformId,\n PlatformOverride,\n ResolvedConnector,\n} from \"../core/types.js\";\nimport { allAdapters, loadAdapter } from \"../adapters/registry.js\";\nimport type { NormalizedEvent } from \"../adapters/spi.js\";\nimport {\n compileMatcher,\n eventMatcherSubject,\n} from \"../runtime/hook-entrypoint.js\";\nimport type { SurfaceName } from \"./introspect.js\";\nimport { SURFACE_PREDICATES } from \"./introspect.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// explain — the static per-host × per-declared-surface matrix\n// ─────────────────────────────────────────────────────────────────────────\n\n/** One cell of the {@link explain} matrix: a host × a declared surface. */\nexport interface ExplainRow {\n host: PlatformId;\n surface: SurfaceName;\n /**\n * - \"native\" — the host's capabilities pass the surface predicate.\n * - \"disabled\" — the connector opted out for this host\n * (`platforms[host].<surface> === false`).\n * - \"skip-warn\" — the host cannot honor it; install would skip-warn.\n */\n support: \"native\" | \"skip-warn\" | \"disabled\";\n reason: string;\n}\n\n/**\n * The GLOBAL surfaces a connector declares (these apply to every host — only\n * declared surfaces get a matrix row). The two platform-scoped surfaces\n * (`configPatch` / `nativeHooks`) are deliberately EXCLUDED here: they are\n * declared under one specific `platforms[host]`, so each is added PER HOST in\n * {@link explain} (see {@link platformScopedSurfacesFor}) — adding them globally\n * would falsely promise a configPatch row on hosts that never declared it.\n */\nfunction declaredGlobalSurfaces(connector: ResolvedConnector): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (connector.server) out.push(\"server\");\n if (Object.keys(connector.hooks).length > 0) out.push(\"hooks\");\n if (connector.commands.length > 0) out.push(\"commands\");\n if (connector.skills.length > 0) out.push(\"skills\");\n if (connector.subagents.length > 0) out.push(\"subagents\");\n if (connector.memory.length > 0) out.push(\"memory\");\n if (connector.statusline) out.push(\"statusline\");\n if (connector.actions.length > 0) out.push(\"actions\");\n return out;\n}\n\n/**\n * The platform-scoped surfaces (`configPatch` / `nativeHooks`) THIS host\n * actually declares — keyed off the host's own `platforms[host]` override, so a\n * configPatch declared under claude-code never shows up as a row for codex.\n */\nfunction platformScopedSurfacesFor(\n override: PlatformOverride | undefined,\n): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (!override) return out;\n if ((override.configPatch?.length ?? 0) > 0) out.push(\"configPatch\");\n if (override.nativeHooks != null && Object.keys(override.nativeHooks).length > 0) {\n out.push(\"nativeHooks\");\n }\n return out;\n}\n\n/**\n * Is the surface explicitly DISABLED for this host? Mirrors the per-host opt-out\n * the installer honors: a boolean-or-object surface override is \"disabled\" only\n * when set to the literal `false` (the object form is a tuning, not an opt-out).\n * `configPatch` / `nativeHooks` have no boolean opt-out form — declaring them is\n * the opt-in, so they are never \"disabled\".\n */\nfunction isDisabledForHost(\n connector: ResolvedConnector,\n host: PlatformId,\n surface: SurfaceName,\n): boolean {\n const override = connector.platforms[host];\n if (!override) return false;\n switch (surface) {\n case \"server\":\n return override.server === false;\n case \"hooks\":\n return override.hooks === false;\n case \"commands\":\n return override.commands === false;\n case \"skills\":\n return override.skills === false;\n case \"subagents\":\n return override.subagents === false;\n case \"memory\":\n return override.memory === false;\n case \"statusline\":\n return override.statusline === false;\n case \"actions\":\n case \"configPatch\":\n case \"nativeHooks\":\n // No per-host boolean opt-out form (declaring them is the opt-in).\n return false;\n }\n}\n\n/**\n * The static support matrix: every registered host × every surface the\n * connector declares. Rows are sorted by host then surface for stable output.\n * Pure read of the adapter capabilities — installs nothing, writes nothing.\n */\nexport async function explain(connector: ResolvedConnector): Promise<ExplainRow[]> {\n const globalSurfaces = declaredGlobalSurfaces(connector);\n const adapters = await allAdapters();\n const rows: ExplainRow[] = [];\n\n for (const adapter of adapters) {\n // Per-host surface set = the global surfaces every host gets a row for, plus\n // the platform-scoped surfaces THIS host actually declares (configPatch /\n // nativeHooks live under platforms[host], so they are host-local).\n const override = connector.platforms[adapter.id];\n const surfaces = [\n ...globalSurfaces,\n ...platformScopedSurfacesFor(override),\n ];\n for (const surface of surfaces) {\n if (isDisabledForHost(connector, adapter.id, surface)) {\n rows.push({\n host: adapter.id,\n surface,\n support: \"disabled\",\n reason: `connector opted out for ${adapter.id} (platforms.${adapter.id}.${surface} = false)`,\n });\n continue;\n }\n const native = SURFACE_PREDICATES[surface](adapter.capabilities);\n rows.push({\n host: adapter.id,\n surface,\n support: native ? \"native\" : \"skip-warn\",\n reason: explainReason(adapter.id, surface, native),\n });\n }\n }\n\n rows.sort((a, b) =>\n a.host === b.host ? a.surface.localeCompare(b.surface) : a.host.localeCompare(b.host),\n );\n return rows;\n}\n\n/**\n * The human-readable reason for a native/skip-warn cell. `server` is a special\n * case: the predicate is CAPABILITY-based (the host advertises ≥1 MCP\n * transport), but advertising a transport does NOT guarantee a writable\n * registration — e.g. jetbrains-copilot advertises stdio yet its installServer\n * skip-warns because MCP is managed in IDE settings. So the server reason states\n * the verdict is capability-based and registration may be host-managed, rather\n * than promising a write. (A precise per-adapter installServer dry-run is a\n * Phase-2 enhancement — until then this avoids over-promising.)\n */\nfunction explainReason(host: PlatformId, surface: SurfaceName, native: boolean): string {\n if (surface === \"server\") {\n return native\n ? `${host} advertises an MCP transport (capability-based; registration may be host-managed)`\n : `${host} advertises no MCP transport; install skip-warns`;\n }\n return native\n ? `${host} natively supports ${surface}`\n : `${host} cannot honor ${surface}; install skip-warns`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// simulate — the real adapter parse → handler → format chain, inline\n// ─────────────────────────────────────────────────────────────────────────\n\n/** What to drive through the harness: one host, one surface, one raw payload. */\nexport interface SimulateOptions {\n surface: \"hooks\" | \"statusline\";\n host: PlatformId | string;\n /** REQUIRED when `surface === \"hooks\"`: which normalized lifecycle event. */\n event?: HookEventName;\n /** The host-shaped RAW payload (what the host would pipe in on stdin). */\n input: unknown;\n}\n\n/** The harness verdict: did the host actually honor the connector's response? */\nexport interface SimulateResult {\n /** True when the host's native reply carries the connector's intent. */\n honored: boolean;\n /** The host-native stdout the adapter would emit (when there is one). */\n hostReply?: string;\n /** Human-readable why — names the documented degradation when honored:false. */\n reason: string;\n}\n\n/**\n * Tolerantly coerce the raw payload, mirroring the runtime's parseStdin: a\n * string is JSON-parsed (empty/malformed → `{}`); a nullish value → `{}`; any\n * other value (already-parsed object) is passed through untouched.\n */\nfunction coerceInput(input: unknown): unknown {\n if (input == null) return {};\n if (typeof input === \"string\") {\n const trimmed = input.trim();\n if (trimmed === \"\") return {};\n try {\n return JSON.parse(trimmed);\n } catch {\n return {};\n }\n }\n return input;\n}\n\n/** Normalize a handler's return into a concrete response (void/non-object → `{}`). */\nfunction normalizeResponse(value: HookResponse | void): HookResponse {\n if (value == null || typeof value !== \"object\") return {};\n return value;\n}\n\n/**\n * The decoded shape of a host's native hook reply on stdout. Every json-stdio\n * adapter writes a SUBSET of these fields (claude-code / codex share the\n * `hookSpecificOutput` envelope; Stop-class continuation uses the TOP-LEVEL\n * `decision:\"block\"`). We read the DECODED fields — never substring-match the\n * serialized JSON, which a path/newline/quote in the payload would break.\n */\ninterface ParsedReply {\n /** Top-level Stop-class continuation: {\"decision\":\"block\",\"reason\"}. */\n decision?: unknown;\n reason?: unknown;\n /** Top-level Claude context channel (no adapter emits it yet; future-proofing). */\n systemMessage?: unknown;\n hookSpecificOutput?: {\n hookEventName?: unknown;\n additionalContext?: unknown;\n permissionDecision?: unknown;\n permissionDecisionReason?: unknown;\n updatedInput?: unknown;\n /** PermissionRequest nested envelope: decision:{behavior:\"allow\"|\"deny\", updatedInput?}. */\n decision?: { behavior?: unknown; updatedInput?: unknown };\n };\n}\n\n/**\n * Tolerantly decode a reply's stdout into {@link ParsedReply}. Empty / absent /\n * unparseable stdout is a legitimate \"no payload\" signal (the adapter wrote a\n * bare exit-0) → `undefined`, the honest \"this decision had no stdout path\"\n * verdict input.\n */\nfunction parseReplyStdout(stdout: string | undefined): ParsedReply | undefined {\n if (stdout == null || stdout.trim() === \"\") return undefined;\n try {\n const value = JSON.parse(stdout);\n return value != null && typeof value === \"object\"\n ? (value as ParsedReply)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Structural deep-equal for plain JSON values (objects/arrays/primitives). */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a !== typeof b || a == null || b == null) return false;\n if (typeof a !== \"object\") return false;\n const aArr = Array.isArray(a);\n if (aArr !== Array.isArray(b)) return false;\n if (aArr) {\n const x = a as unknown[];\n const y = b as unknown[];\n return x.length === y.length && x.every((v, i) => deepEqual(v, y[i]));\n }\n const x = a as Record<string, unknown>;\n const y = b as Record<string, unknown>;\n const xk = Object.keys(x);\n const yk = Object.keys(y);\n return xk.length === yk.length && xk.every((k) => deepEqual(x[k], y[k]));\n}\n\n/**\n * Decide whether the host HONORED a decision-bearing response, judging the\n * PARSED reply against each adapter's ACTUAL (event, decision) contract — never\n * by substring-matching the serialized JSON. `allow`/no-decision is always\n * pass-through honored; every other decision is honored only when the decoded\n * reply carries that exact intent, and the verdict names the documented\n * degradation when it does not.\n */\nfunction judgeHookHonor(\n host: string,\n event: HookEventName,\n response: HookResponse,\n stdout: string | undefined,\n): { honored: boolean; reason: string } {\n const decision = response.decision;\n if (decision === undefined || decision === \"allow\") {\n return { honored: true, reason: \"pass-through allow\" };\n }\n\n const reply = parseReplyStdout(stdout);\n const hso = reply?.hookSpecificOutput;\n\n if (decision === \"context\") {\n // Honored only when the DECODED additionalContext equals what the handler\n // asked to inject (claude-code's hookSpecificOutput.additionalContext, or a\n // future top-level systemMessage). codex only emits this on\n // SessionStart/PostToolUse — every other event silently drops it.\n const want = response.additionalContext;\n const got = hso?.additionalContext ?? reply?.systemMessage;\n if (reply && got === want) {\n return { honored: true, reason: `${host} injects context on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops context on ${event} (no stdout path)`,\n };\n }\n\n if (decision === \"deny\") {\n if (!reply) {\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n // A real block: PreToolUse's permissionDecision:\"deny\", or the\n // PermissionRequest nested decision.behavior:\"deny\".\n if (hso?.permissionDecision === \"deny\" || hso?.decision?.behavior === \"deny\") {\n return { honored: true, reason: `${host} blocks ${event}` };\n }\n // Stop-class continuation: top-level decision:\"block\" KEEPS the session /\n // subagent running (persistence) — the SEMANTIC OPPOSITE of a block. Honored\n // (the reply carried the intent), but the reason must not say \"blocks\".\n if (reply.decision === \"block\") {\n return {\n honored: true,\n reason: `${host} continues the session/subagent on ${event} (persistence) — NOT a block`,\n };\n }\n // SubagentStart / PostToolUseFailure DEGRADE a deny to a context note — the\n // spawn/failure is not actually blocked.\n if (hso?.additionalContext != null) {\n return {\n honored: false,\n reason: `${host} degrades deny to a context note on ${event}; spawn/failure not blocked`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n\n if (decision === \"ask\") {\n if (hso?.permissionDecision === \"ask\") {\n return { honored: true, reason: `${host} asks on ${event}` };\n }\n // On PermissionRequest, ask/void falls through to the host's NATIVE dialog\n // (the dialog IS the ask), which the adapter expresses as a bare exit-0.\n if (event === \"PermissionRequest\" && !reply) {\n return {\n honored: true,\n reason: `${host} shows the native confirmation dialog on ${event} (the ask)`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops ask on ${event} (no ask path)`,\n };\n }\n\n // decision === \"modify\": honored only when the decoded updatedInput deep-equals\n // what the handler asked to write (hookSpecificOutput.updatedInput, or the\n // PermissionRequest nested decision.updatedInput).\n const wrote = hso?.updatedInput ?? hso?.decision?.updatedInput;\n if (reply && wrote !== undefined && deepEqual(wrote, response.updatedInput)) {\n return { honored: true, reason: `${host} rewrites tool input on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops modify on ${event} (modify not honored)`,\n };\n}\n\n/**\n * Run the connector against ONE host-shaped payload through the REAL adapter\n * path and report whether the host honors the response. Self-contained (does not\n * touch the registered-connector loader or telemetry) and fail-safe: any throw\n * in the chain degrades to `honored:false` with the error message, never rejects.\n */\nexport async function simulate(\n connector: ResolvedConnector,\n opts: SimulateOptions,\n): Promise<SimulateResult> {\n try {\n const adapter = await loadAdapter(opts.host);\n if (!adapter) {\n return { honored: false, reason: `unknown host \"${opts.host}\"` };\n }\n\n if (opts.surface === \"statusline\") {\n if (\n !(adapter.capabilities.supportsStatusline ?? false) ||\n !adapter.parseStatusInput ||\n !adapter.formatStatusOutput\n ) {\n return { honored: false, reason: `${opts.host} has no statusline surface` };\n }\n // Guarding on the TOP-LEVEL render is sufficient: a `hosts`-only statusline\n // (a hosts: map with no top-level render) is rejected at defineConnector, so\n // a connector that targets `opts.host` only via hosts[] still has a top-level\n // render here. (If that author-time invariant ever relaxes, revisit this.)\n if (!connector.statusline || typeof connector.statusline.render !== \"function\") {\n return { honored: false, reason: \"connector declares no statusline\" };\n }\n const ctx = adapter.parseStatusInput(coerceInput(opts.input));\n ctx.connectorId = connector.id;\n // Defensive: parseStatusInput now sets ctx.capabilities (it is required on\n // StatuslineContext), but a future adapter could omit it — backfill from\n // the adapter so render() can always read ctx.capabilities.\n if (ctx.capabilities == null) ctx.capabilities = adapter.capabilities;\n // Per-host render override, mirroring the runtime: hosts[host].render wins\n // over the top-level render; an unlisted host falls back to top-level.\n const perHost = connector.statusline.hosts?.[opts.host as PlatformId]?.render;\n const render =\n typeof perHost === \"function\" ? perHost : connector.statusline.render;\n const rendered = await render(ctx);\n const line = rendered == null ? \"\" : String(rendered);\n const reply = adapter.formatStatusOutput(line);\n return {\n honored: true,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: \"rendered\",\n };\n }\n\n // surface === \"hooks\"\n const event = opts.event;\n if (!event) {\n return { honored: false, reason: \"event is required when surface === \\\"hooks\\\"\" };\n }\n if (!adapter.parseEvent || !adapter.formatReply) {\n return { honored: false, reason: `${opts.host} has no hook runtime (mcp-only)` };\n }\n\n const evt = adapter.parseEvent(event, coerceInput(opts.input));\n evt.connectorId = connector.id;\n // Mirror the runtime: runHook backfills evt.capabilities from the adapter so\n // a handler reading evt.capabilities behaves the same here. (scope/telemetry\n // are runtime-only — recovered from the registered meta / store, which the\n // offline harness deliberately never touches — so they stay undefined.)\n evt.capabilities = adapter.capabilities;\n\n // Guarding on the TOP-LEVEL handler is sufficient: a `hosts`-only hook (a\n // hosts: map with no top-level handler) is rejected at defineConnector, so a\n // host targeted only via hosts[] still has a top-level handler here. (If that\n // author-time invariant ever relaxes, revisit this.)\n const definition = connector.hooks[event];\n if (!definition || typeof definition.handler !== \"function\") {\n return { honored: false, reason: `connector declares no ${event} handler` };\n }\n\n // Matcher filtering, in lockstep with runHook: when the connector's matcher\n // is set and the event's subject (tool name, or agent type for Subagent*\n // events) does not match, the host never runs the handler — so the harness\n // must NOT run it either, and reports the (honored) exclusion. Reuses the\n // runtime helpers directly so the two stay byte-for-byte aligned.\n const subject = eventMatcherSubject(evt as NormalizedEvent);\n if (subject !== undefined) {\n const re = compileMatcher(definition.matcher);\n if (re && !re.test(subject)) {\n return {\n honored: true,\n reason: `matcher excludes ${subject} (handler not run)`,\n };\n }\n }\n\n // Per-host handler override, mirroring runHook: hosts[host].handler wins\n // over the top-level handler; an unlisted host falls back to top-level.\n const perHost = definition.hosts?.[opts.host as PlatformId]?.handler;\n const handler = typeof perHost === \"function\" ? perHost : definition.handler;\n const response = normalizeResponse(\n await handler(evt as never),\n );\n const reply = adapter.formatReply(event, response);\n const verdict = judgeHookHonor(String(opts.host), event, response, reply.stdout);\n return {\n honored: verdict.honored,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: verdict.reason,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n const verb = opts.surface === \"statusline\" ? \"render\" : \"handler\";\n return { honored: false, reason: `${verb} threw: ${message}` };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmEA,SAAS,uBAAuB,WAA6C;AAC3E,QAAM,MAAqB,CAAC;AAC5B,MAAI,UAAU,OAAQ,KAAI,KAAK,QAAQ;AACvC,MAAI,OAAO,KAAK,UAAU,KAAK,EAAE,SAAS,EAAG,KAAI,KAAK,OAAO;AAC7D,MAAI,UAAU,SAAS,SAAS,EAAG,KAAI,KAAK,UAAU;AACtD,MAAI,UAAU,OAAO,SAAS,EAAG,KAAI,KAAK,QAAQ;AAClD,MAAI,UAAU,UAAU,SAAS,EAAG,KAAI,KAAK,WAAW;AACxD,MAAI,UAAU,OAAO,SAAS,EAAG,KAAI,KAAK,QAAQ;AAClD,MAAI,UAAU,WAAY,KAAI,KAAK,YAAY;AAC/C,MAAI,UAAU,QAAQ,SAAS,EAAG,KAAI,KAAK,SAAS;AACpD,SAAO;AACT;AAOA,SAAS,0BACP,UACe;AACf,QAAM,MAAqB,CAAC;AAC5B,MAAI,CAAC,SAAU,QAAO;AACtB,OAAK,SAAS,aAAa,UAAU,KAAK,EAAG,KAAI,KAAK,aAAa;AACnE,MAAI,SAAS,eAAe,QAAQ,OAAO,KAAK,SAAS,WAAW,EAAE,SAAS,GAAG;AAChF,QAAI,KAAK,aAAa;AAAA,EACxB;AACA,SAAO;AACT;AASA,SAAS,kBACP,WACA,MACA,SACS;AACT,QAAM,WAAW,UAAU,UAAU,IAAI;AACzC,MAAI,CAAC,SAAU,QAAO;AACtB,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aA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O,GAAG;AAC3B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,oBAAoB,OAAO;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAIA,UAAM,UAAU,WAAW,QAAQ,KAAK,IAAkB,GAAG;AAC7D,UAAM,UAAU,OAAO,YAAY,aAAa,UAAU,WAAW;AACrE,UAAM,WAAW;AAAA,MACf,MAAM,QAAQ,GAAY;AAAA,IAC5B;AACA,UAAM,QAAQ,QAAQ,YAAY,OAAO,QAAQ;AACjD,UAAM,UAAU,eAAe,OAAO,KAAK,IAAI,GAAG,OAAO,UAAU,MAAM,MAAM;AAC/E,WAAO;AAAA,MACL,SAAS,QAAQ;AAAA,MACjB,GAAI,MAAM,WAAW,SAAY,EAAE,WAAW,MAAM,OAAO,IAAI,CAAC;AAAA,MAChE,QAAQ,QAAQ;AAAA,IAClB;AAAA,EACF,SAAS,KAAK;AACZ,UAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,UAAM,OAAO,KAAK,YAAY,eAAe,WAAW;AACxD,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,IAAI,WAAW,OAAO,GAAG;AAAA,EAC/D;AACF;","names":["x","y","perHost","reply"]}
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/test-harness.ts"],"sourcesContent":["/**\n * sdk/test-harness — the SHIPPED, OFFLINE behavioral harness.\n *\n * Two read-only tools a connector author runs WITHOUT installing anything or\n * touching the host's filesystem:\n *\n * • `explain(connector)` — the static per-host × per-DECLARED-surface matrix:\n * for every registered host and every surface the connector actually ships,\n * is it `native` (the host can honor it), `disabled` (the connector opted\n * out for that host via `platforms[host].<surface> === false`), or\n * `skip-warn` (the host cannot honor it → install would skip-warn)?\n *\n * • `simulate(connector, opts)` — runs the REAL adapter parse → handler →\n * format chain INLINE against a host-shaped raw payload and reports whether\n * the host actually HONORS the connector's response (the trustworthy part:\n * it surfaces the documented degradations, e.g. Codex silently dropping a\n * UserPromptSubmit \"context\" injection that has no stdout path).\n *\n * It deliberately does NOT import the runtime entrypoints (runHook /\n * runStatusline) — those load the REGISTERED connector from disk and record\n * telemetry. The harness instead re-implements the tiny parse→handler→format\n * chain against the in-memory connector + the adapter, mirroring the runtime's\n * input tolerance (empty/malformed payload → `{}`) and its fail-safe envelope.\n */\n\nimport type {\n HookEventName,\n HookResponse,\n PlatformId,\n PlatformOverride,\n ResolvedConnector,\n} from \"../core/types.js\";\nimport { allAdapters, loadAdapter } from \"../adapters/registry.js\";\nimport type { NormalizedEvent } from \"../adapters/spi.js\";\nimport {\n compileMatcher,\n eventMatcherSubject,\n} from \"../runtime/hook-entrypoint.js\";\nimport type { SurfaceName } from \"./introspect.js\";\nimport { SURFACE_PREDICATES } from \"./introspect.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// explain — the static per-host × per-declared-surface matrix\n// ─────────────────────────────────────────────────────────────────────────\n\n/** One cell of the {@link explain} matrix: a host × a declared surface. */\nexport interface ExplainRow {\n host: PlatformId;\n surface: SurfaceName;\n /**\n * - \"native\" — the host's capabilities pass the surface predicate.\n * - \"disabled\" — the connector opted out for this host\n * (`platforms[host].<surface> === false`).\n * - \"skip-warn\" — the host cannot honor it; install would skip-warn.\n */\n support: \"native\" | \"skip-warn\" | \"disabled\";\n reason: string;\n}\n\n/**\n * The GLOBAL surfaces a connector declares (these apply to every host — only\n * declared surfaces get a matrix row). The two platform-scoped surfaces\n * (`configPatch` / `nativeHooks`) are deliberately EXCLUDED here: they are\n * declared under one specific `platforms[host]`, so each is added PER HOST in\n * {@link explain} (see {@link platformScopedSurfacesFor}) — adding them globally\n * would falsely promise a configPatch row on hosts that never declared it.\n */\nfunction declaredGlobalSurfaces(connector: ResolvedConnector): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (connector.server) out.push(\"server\");\n if (Object.keys(connector.hooks).length > 0) out.push(\"hooks\");\n if (connector.commands.length > 0) out.push(\"commands\");\n if (connector.skills.length > 0) out.push(\"skills\");\n if (connector.subagents.length > 0) out.push(\"subagents\");\n if (connector.memory.length > 0) out.push(\"memory\");\n if (connector.statusline) out.push(\"statusline\");\n if (connector.actions.length > 0) out.push(\"actions\");\n return out;\n}\n\n/**\n * The platform-scoped surfaces (`configPatch` / `nativeHooks`) THIS host\n * actually declares — keyed off the host's own `platforms[host]` override, so a\n * configPatch declared under claude-code never shows up as a row for codex.\n */\nfunction platformScopedSurfacesFor(\n override: PlatformOverride | undefined,\n): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (!override) return out;\n if ((override.configPatch?.length ?? 0) > 0) out.push(\"configPatch\");\n if (override.nativeHooks != null && Object.keys(override.nativeHooks).length > 0) {\n out.push(\"nativeHooks\");\n }\n return out;\n}\n\n/**\n * Is the surface explicitly DISABLED for this host? Mirrors the per-host opt-out\n * the installer honors: a boolean-or-object surface override is \"disabled\" only\n * when set to the literal `false` (the object form is a tuning, not an opt-out).\n * `configPatch` / `nativeHooks` have no boolean opt-out form — declaring them is\n * the opt-in, so they are never \"disabled\".\n */\nfunction isDisabledForHost(\n connector: ResolvedConnector,\n host: PlatformId,\n surface: SurfaceName,\n): boolean {\n const override = connector.platforms[host];\n if (!override) return false;\n switch (surface) {\n case \"server\":\n return override.server === false;\n case \"hooks\":\n return override.hooks === false;\n case \"commands\":\n return override.commands === false;\n case \"skills\":\n return override.skills === false;\n case \"subagents\":\n return override.subagents === false;\n case \"memory\":\n return override.memory === false;\n case \"statusline\":\n return override.statusline === false;\n case \"actions\":\n case \"configPatch\":\n case \"nativeHooks\":\n // No per-host boolean opt-out form (declaring them is the opt-in).\n return false;\n }\n}\n\n/**\n * The static support matrix: every registered host × every surface the\n * connector declares. Rows are sorted by host then surface for stable output.\n * Pure read of the adapter capabilities — installs nothing, writes nothing.\n */\nexport async function explain(connector: ResolvedConnector): Promise<ExplainRow[]> {\n const globalSurfaces = declaredGlobalSurfaces(connector);\n const adapters = await allAdapters();\n const rows: ExplainRow[] = [];\n\n for (const adapter of adapters) {\n // Per-host surface set = the global surfaces every host gets a row for, plus\n // the platform-scoped surfaces THIS host actually declares (configPatch /\n // nativeHooks live under platforms[host], so they are host-local).\n const override = connector.platforms[adapter.id];\n const surfaces = [\n ...globalSurfaces,\n ...platformScopedSurfacesFor(override),\n ];\n for (const surface of surfaces) {\n if (isDisabledForHost(connector, adapter.id, surface)) {\n rows.push({\n host: adapter.id,\n surface,\n support: \"disabled\",\n reason: `connector opted out for ${adapter.id} (platforms.${adapter.id}.${surface} = false)`,\n });\n continue;\n }\n const native = SURFACE_PREDICATES[surface](adapter.capabilities);\n rows.push({\n host: adapter.id,\n surface,\n support: native ? \"native\" : \"skip-warn\",\n reason: explainReason(adapter.id, surface, native),\n });\n }\n }\n\n rows.sort((a, b) =>\n a.host === b.host ? a.surface.localeCompare(b.surface) : a.host.localeCompare(b.host),\n );\n return rows;\n}\n\n/**\n * The human-readable reason for a native/skip-warn cell. `server` is a special\n * case: the predicate is CAPABILITY-based (the host advertises ≥1 MCP\n * transport), but advertising a transport does NOT guarantee a writable\n * registration — e.g. jetbrains-copilot advertises stdio yet its installServer\n * skip-warns because MCP is managed in IDE settings. So the server reason states\n * the verdict is capability-based and registration may be host-managed, rather\n * than promising a write. (A precise per-adapter installServer dry-run is a\n * Phase-2 enhancement — until then this avoids over-promising.)\n */\nfunction explainReason(host: PlatformId, surface: SurfaceName, native: boolean): string {\n if (surface === \"server\") {\n return native\n ? `${host} advertises an MCP transport (capability-based; registration may be host-managed)`\n : `${host} advertises no MCP transport; install skip-warns`;\n }\n return native\n ? `${host} natively supports ${surface}`\n : `${host} cannot honor ${surface}; install skip-warns`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// simulate — the real adapter parse → handler → format chain, inline\n// ─────────────────────────────────────────────────────────────────────────\n\n/** What to drive through the harness: one host, one surface, one raw payload. */\nexport interface SimulateOptions {\n surface: \"hooks\" | \"statusline\";\n host: PlatformId | string;\n /** REQUIRED when `surface === \"hooks\"`: which normalized lifecycle event. */\n event?: HookEventName;\n /** The host-shaped RAW payload (what the host would pipe in on stdin). */\n input: unknown;\n}\n\n/** The harness verdict: did the host actually honor the connector's response? */\nexport interface SimulateResult {\n /** True when the host's native reply carries the connector's intent. */\n honored: boolean;\n /** The host-native stdout the adapter would emit (when there is one). */\n hostReply?: string;\n /** Human-readable why — names the documented degradation when honored:false. */\n reason: string;\n}\n\n/**\n * Tolerantly coerce the raw payload, mirroring the runtime's parseStdin: a\n * string is JSON-parsed (empty/malformed → `{}`); a nullish value → `{}`; any\n * other value (already-parsed object) is passed through untouched.\n */\nfunction coerceInput(input: unknown): unknown {\n if (input == null) return {};\n if (typeof input === \"string\") {\n const trimmed = input.trim();\n if (trimmed === \"\") return {};\n try {\n return JSON.parse(trimmed);\n } catch {\n return {};\n }\n }\n return input;\n}\n\n/** Normalize a handler's return into a concrete response (void/non-object → `{}`). */\nfunction normalizeResponse(value: HookResponse | void): HookResponse {\n if (value == null || typeof value !== \"object\") return {};\n return value;\n}\n\n/**\n * The decoded shape of a host's native hook reply on stdout. Every json-stdio\n * adapter writes a SUBSET of these fields (claude-code / codex share the\n * `hookSpecificOutput` envelope; Stop-class continuation uses the TOP-LEVEL\n * `decision:\"block\"`). We read the DECODED fields — never substring-match the\n * serialized JSON, which a path/newline/quote in the payload would break.\n */\ninterface ParsedReply {\n /** Top-level Stop-class continuation: {\"decision\":\"block\",\"reason\"}. */\n decision?: unknown;\n reason?: unknown;\n /** Top-level Claude context channel (no adapter emits it yet; future-proofing). */\n systemMessage?: unknown;\n hookSpecificOutput?: {\n hookEventName?: unknown;\n additionalContext?: unknown;\n permissionDecision?: unknown;\n permissionDecisionReason?: unknown;\n updatedInput?: unknown;\n /** PermissionRequest nested envelope: decision:{behavior:\"allow\"|\"deny\", updatedInput?}. */\n decision?: { behavior?: unknown; updatedInput?: unknown };\n };\n}\n\n/**\n * Tolerantly decode a reply's stdout into {@link ParsedReply}. Empty / absent /\n * unparseable stdout is a legitimate \"no payload\" signal (the adapter wrote a\n * bare exit-0) → `undefined`, the honest \"this decision had no stdout path\"\n * verdict input.\n */\nfunction parseReplyStdout(stdout: string | undefined): ParsedReply | undefined {\n if (stdout == null || stdout.trim() === \"\") return undefined;\n try {\n const value = JSON.parse(stdout);\n return value != null && typeof value === \"object\"\n ? (value as ParsedReply)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Structural deep-equal for plain JSON values (objects/arrays/primitives). */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a !== typeof b || a == null || b == null) return false;\n if (typeof a !== \"object\") return false;\n const aArr = Array.isArray(a);\n if (aArr !== Array.isArray(b)) return false;\n if (aArr) {\n const x = a as unknown[];\n const y = b as unknown[];\n return x.length === y.length && x.every((v, i) => deepEqual(v, y[i]));\n }\n const x = a as Record<string, unknown>;\n const y = b as Record<string, unknown>;\n const xk = Object.keys(x);\n const yk = Object.keys(y);\n return xk.length === yk.length && xk.every((k) => deepEqual(x[k], y[k]));\n}\n\n/**\n * Decide whether the host HONORED a decision-bearing response, judging the\n * PARSED reply against each adapter's ACTUAL (event, decision) contract — never\n * by substring-matching the serialized JSON. `allow`/no-decision is always\n * pass-through honored; every other decision is honored only when the decoded\n * reply carries that exact intent, and the verdict names the documented\n * degradation when it does not.\n */\nfunction judgeHookHonor(\n host: string,\n event: HookEventName,\n response: HookResponse,\n stdout: string | undefined,\n): { honored: boolean; reason: string } {\n const decision = response.decision;\n if (decision === undefined || decision === \"allow\") {\n return { honored: true, reason: \"pass-through allow\" };\n }\n\n const reply = parseReplyStdout(stdout);\n const hso = reply?.hookSpecificOutput;\n\n if (decision === \"context\") {\n // Honored only when the DECODED additionalContext equals what the handler\n // asked to inject (claude-code's hookSpecificOutput.additionalContext, or a\n // future top-level systemMessage). codex only emits this on\n // SessionStart/PostToolUse — every other event silently drops it.\n const want = response.additionalContext;\n const got = hso?.additionalContext ?? reply?.systemMessage;\n if (reply && got === want) {\n return { honored: true, reason: `${host} injects context on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops context on ${event} (no stdout path)`,\n };\n }\n\n if (decision === \"deny\") {\n if (!reply) {\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n // A real block: PreToolUse's permissionDecision:\"deny\", or the\n // PermissionRequest nested decision.behavior:\"deny\".\n if (hso?.permissionDecision === \"deny\" || hso?.decision?.behavior === \"deny\") {\n return { honored: true, reason: `${host} blocks ${event}` };\n }\n // Stop-class continuation: top-level decision:\"block\" KEEPS the session /\n // subagent running (persistence) — the SEMANTIC OPPOSITE of a block. Honored\n // (the reply carried the intent), but the reason must not say \"blocks\".\n if (reply.decision === \"block\") {\n return {\n honored: true,\n reason: `${host} continues the session/subagent on ${event} (persistence) — NOT a block`,\n };\n }\n // SubagentStart / PostToolUseFailure DEGRADE a deny to a context note — the\n // spawn/failure is not actually blocked.\n if (hso?.additionalContext != null) {\n return {\n honored: false,\n reason: `${host} degrades deny to a context note on ${event}; spawn/failure not blocked`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n\n if (decision === \"ask\") {\n if (hso?.permissionDecision === \"ask\") {\n return { honored: true, reason: `${host} asks on ${event}` };\n }\n // On PermissionRequest, ask/void falls through to the host's NATIVE dialog\n // (the dialog IS the ask), which the adapter expresses as a bare exit-0.\n if (event === \"PermissionRequest\" && !reply) {\n return {\n honored: true,\n reason: `${host} shows the native confirmation dialog on ${event} (the ask)`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops ask on ${event} (no ask path)`,\n };\n }\n\n // decision === \"modify\": honored only when the decoded updatedInput deep-equals\n // what the handler asked to write (hookSpecificOutput.updatedInput, or the\n // PermissionRequest nested decision.updatedInput).\n const wrote = hso?.updatedInput ?? hso?.decision?.updatedInput;\n if (reply && wrote !== undefined && deepEqual(wrote, response.updatedInput)) {\n return { honored: true, reason: `${host} rewrites tool input on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops modify on ${event} (modify not honored)`,\n };\n}\n\n/**\n * Run the connector against ONE host-shaped payload through the REAL adapter\n * path and report whether the host honors the response. Self-contained (does not\n * touch the registered-connector loader or telemetry) and fail-safe: any throw\n * in the chain degrades to `honored:false` with the error message, never rejects.\n */\nexport async function simulate(\n connector: ResolvedConnector,\n opts: SimulateOptions,\n): Promise<SimulateResult> {\n try {\n const adapter = await loadAdapter(opts.host);\n if (!adapter) {\n return { honored: false, reason: `unknown host \"${opts.host}\"` };\n }\n\n if (opts.surface === \"statusline\") {\n if (\n !(adapter.capabilities.supportsStatusline ?? false) ||\n !adapter.parseStatusInput ||\n !adapter.formatStatusOutput\n ) {\n return { honored: false, reason: `${opts.host} has no statusline surface` };\n }\n // Guarding on the TOP-LEVEL render is sufficient: a `hosts`-only statusline\n // (a hosts: map with no top-level render) is rejected at defineConnector, so\n // a connector that targets `opts.host` only via hosts[] still has a top-level\n // render here. (If that author-time invariant ever relaxes, revisit this.)\n if (!connector.statusline || typeof connector.statusline.render !== \"function\") {\n return { honored: false, reason: \"connector declares no statusline\" };\n }\n const ctx = adapter.parseStatusInput(coerceInput(opts.input));\n ctx.connectorId = connector.id;\n // Defensive: parseStatusInput now sets ctx.capabilities (it is required on\n // StatuslineContext), but a future adapter could omit it — backfill from\n // the adapter so render() can always read ctx.capabilities.\n if (ctx.capabilities == null) ctx.capabilities = adapter.capabilities;\n // Per-host render override, mirroring the runtime: hosts[host].render wins\n // over the top-level render; an unlisted host falls back to top-level.\n const perHost = connector.statusline.hosts?.[opts.host as PlatformId]?.render;\n const render =\n typeof perHost === \"function\" ? perHost : connector.statusline.render;\n const rendered = await render(ctx);\n const line = rendered == null ? \"\" : String(rendered);\n const reply = adapter.formatStatusOutput(line);\n return {\n honored: true,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: \"rendered\",\n };\n }\n\n // surface === \"hooks\"\n const event = opts.event;\n if (!event) {\n return { honored: false, reason: \"event is required when surface === \\\"hooks\\\"\" };\n }\n if (!adapter.parseEvent || !adapter.formatReply) {\n return { honored: false, reason: `${opts.host} has no hook runtime (mcp-only)` };\n }\n\n const evt = adapter.parseEvent(event, coerceInput(opts.input));\n evt.connectorId = connector.id;\n // Mirror the runtime: runHook backfills evt.capabilities from the adapter so\n // a handler reading evt.capabilities behaves the same here. (scope/telemetry\n // are runtime-only — recovered from the registered meta / store, which the\n // offline harness deliberately never touches — so they stay undefined.)\n evt.capabilities = adapter.capabilities;\n\n // Guarding on the TOP-LEVEL handler is sufficient: a `hosts`-only hook (a\n // hosts: map with no top-level handler) is rejected at defineConnector, so a\n // host targeted only via hosts[] still has a top-level handler here. (If that\n // author-time invariant ever relaxes, revisit this.)\n const definition = connector.hooks[event];\n if (!definition || typeof definition.handler !== \"function\") {\n return { honored: false, reason: `connector declares no ${event} handler` };\n }\n\n // Matcher filtering, in lockstep with runHook: when the connector's matcher\n // is set and the event's subject (tool name, or agent type for Subagent*\n // events) does not match, the host never runs the handler — so the harness\n // must NOT run it either, and reports the (honored) exclusion. Reuses the\n // runtime helpers directly so the two stay byte-for-byte aligned.\n const subject = eventMatcherSubject(evt as NormalizedEvent);\n if (subject !== undefined) {\n const re = compileMatcher(definition.matcher);\n if (re && !re.test(subject)) {\n return {\n honored: true,\n reason: `matcher excludes ${subject} (handler not run)`,\n };\n }\n }\n\n // Per-host handler override, mirroring runHook: hosts[host].handler wins\n // over the top-level handler; an unlisted host falls back to top-level.\n const perHost = definition.hosts?.[opts.host as PlatformId]?.handler;\n const handler = typeof perHost === \"function\" ? perHost : definition.handler;\n const response = normalizeResponse(\n await handler(evt as never),\n );\n const reply = adapter.formatReply(event, response);\n const verdict = judgeHookHonor(String(opts.host), event, response, reply.stdout);\n return {\n honored: verdict.honored,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: verdict.reason,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n const verb = opts.surface === \"statusline\" ? \"render\" : \"handler\";\n return { honored: false, reason: `${verb} threw: ${message}` };\n }\n}\n"],"mappings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AY,OAAO,QAAQ;AACjD,UAAM,UAAU,eAAe,OAAO,KAAK,IAAI,GAAG,OAAO,UAAU,MAAM,MAAM;AAC/E,WAAO;AAAA,MACL,SAAS,QAAQ;AAAA,MACjB,GAAI,MAAM,WAAW,SAAY,EAAE,WAAW,MAAM,OAAO,IAAI,CAAC;AAAA,MAChE,QAAQ,QAAQ;AAAA,IAClB;AAAA,EACF,SAAS,KAAK;AACZ,UAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,UAAM,OAAO,KAAK,YAAY,eAAe,WAAW;AACxD,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,IAAI,WAAW,OAAO,GAAG;AAAA,EAC/D;AACF;","names":["x","y","perHost","reply"]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-O5TWCIJN.js";
|
|
5
5
|
import {
|
|
6
6
|
runServe
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5OWS5CMA.js";
|
|
8
8
|
import "./chunk-OP4KBXUO.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-F5RX62T7.js";
|
|
10
|
+
import "./chunk-EGCBZ2DC.js";
|
|
11
|
+
import "./chunk-2AVLX7GH.js";
|
|
12
12
|
import "./chunk-BCHWFTV4.js";
|
|
13
13
|
import "./chunk-KHO5WNTP.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-24IDL5RW.js";
|
|
15
|
+
import "./chunk-4ENJK5S2.js";
|
|
16
|
+
import "./chunk-DCKFYWGM.js";
|
|
17
|
+
import "./chunk-FAHIMJRU.js";
|
|
18
|
+
import "./chunk-I5MLE6S7.js";
|
|
18
19
|
import "./chunk-N6HH7K6P.js";
|
|
19
20
|
import "./chunk-TRQKHP7D.js";
|
|
20
21
|
|
|
@@ -66,4 +67,4 @@ async function run(argv) {
|
|
|
66
67
|
export {
|
|
67
68
|
run
|
|
68
69
|
};
|
|
69
|
-
//# sourceMappingURL=serve-
|
|
70
|
+
//# sourceMappingURL=serve-GER7URPR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/commands/serve.ts"],"sourcesContent":["/**\n * cli/commands/serve — the telemetry-wrapping MCP stdio proxy entrypoint.\n *\n * agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <realCommand> <realArgs...>\n *\n * A stdio MCP server that opts into transparent telemetry has its host config\n * rewritten to launch THIS instead of the server directly. We split argv at the\n * literal `--` separator: flags on the left, the real server command + args on\n * the right (taken verbatim). The optional `--scope` flag records the install\n * dimension (global user vs project-local) onto telemetry; it is absent for\n * configs written before scope plumbing existed → the runtime reads \"unknown\".\n * The optional `--host` flag carries the install TARGET platform id so the proxy\n * stamps hostPlatform correctly under a headless spawn; absent configs fall back\n * to runtime env detection.\n * runServe stands up the per-session telemetry context and proxies bytes both\n * ways, resolving with the child's exit code.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport type { PlatformId } from \"../../core/types.js\";\nimport type { TelemetryInstallScope } from \"../../telemetry/types.js\";\nimport { runServe } from \"../../runtime/index.js\";\nimport { fail } from \"../app.js\";\n\nexport async function run(argv: string[]): Promise<number> {\n // Split at the FIRST literal \"--\": everything after it is the real server\n // invocation and must be passed through verbatim (never re-parsed as flags).\n const sepIndex = argv.indexOf(\"--\");\n if (sepIndex === -1) {\n return fail(\n \"usage: agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <command> [args...]\",\n );\n }\n const flagArgs = argv.slice(0, sepIndex);\n const serverInvocation = argv.slice(sepIndex + 1);\n\n // strict:false so an unknown FUTURE flag before `--` (written by a newer host\n // config) is ignored instead of throwing — a parse throw here would prevent the\n // real MCP server from ever spawning and wedge the host's tool call. We only\n // read the two flags we understand; everything else is tolerated.\n const { values } = parseArgs({\n args: flagArgs,\n options: {\n connector: { type: \"string\" },\n scope: { type: \"string\" },\n // `--host <platformId>` bakes the install TARGET platform into the wrapper\n // so the proxy stamps hostPlatform correctly under a headless spawn (where\n // runtime env markers are absent). Optional + tolerated (strict:false).\n host: { type: \"string\" },\n },\n allowPositionals: true,\n strict: false,\n });\n\n // With strict:false, parseArgs types each value as string | boolean; we only\n // accept the string form (a bare `--connector` flag with no value is invalid).\n const connectorId = typeof values.connector === \"string\" ? values.connector : undefined;\n if (!connectorId || connectorId.trim() === \"\") {\n return fail(\"serve requires --connector <id>\");\n }\n\n // `--scope` is optional and only ever \"user\" | \"project\" (the wrapper emits\n // exactly those). An unrecognized value is ignored rather than fatal so a\n // future/older wrapper can never break a real tool call over a flag mismatch.\n const rawScope = values.scope;\n const installScope: TelemetryInstallScope | undefined =\n rawScope === \"user\" || rawScope === \"project\" ? rawScope : undefined;\n\n // `--host` carries the install TARGET platform id (string only). runServe\n // validates it against the registry and falls back to runtime detection when\n // it is absent or unrecognized — so a future/older wrapper never breaks here.\n const hostPlatformOverride =\n typeof values.host === \"string\" ? (values.host as PlatformId) : undefined;\n\n const serverCommand = serverInvocation[0];\n if (!serverCommand) {\n return fail(\"serve requires a command after `--`\");\n }\n const serverArgs = serverInvocation.slice(1);\n\n const code = await runServe({\n connectorId,\n serverCommand,\n serverArgs,\n installScope,\n hostPlatformOverride,\n });\n process.exit(code);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/serve.ts"],"sourcesContent":["/**\n * cli/commands/serve — the telemetry-wrapping MCP stdio proxy entrypoint.\n *\n * agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <realCommand> <realArgs...>\n *\n * A stdio MCP server that opts into transparent telemetry has its host config\n * rewritten to launch THIS instead of the server directly. We split argv at the\n * literal `--` separator: flags on the left, the real server command + args on\n * the right (taken verbatim). The optional `--scope` flag records the install\n * dimension (global user vs project-local) onto telemetry; it is absent for\n * configs written before scope plumbing existed → the runtime reads \"unknown\".\n * The optional `--host` flag carries the install TARGET platform id so the proxy\n * stamps hostPlatform correctly under a headless spawn; absent configs fall back\n * to runtime env detection.\n * runServe stands up the per-session telemetry context and proxies bytes both\n * ways, resolving with the child's exit code.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport type { PlatformId } from \"../../core/types.js\";\nimport type { TelemetryInstallScope } from \"../../telemetry/types.js\";\nimport { runServe } from \"../../runtime/index.js\";\nimport { fail } from \"../app.js\";\n\nexport async function run(argv: string[]): Promise<number> {\n // Split at the FIRST literal \"--\": everything after it is the real server\n // invocation and must be passed through verbatim (never re-parsed as flags).\n const sepIndex = argv.indexOf(\"--\");\n if (sepIndex === -1) {\n return fail(\n \"usage: agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <command> [args...]\",\n );\n }\n const flagArgs = argv.slice(0, sepIndex);\n const serverInvocation = argv.slice(sepIndex + 1);\n\n // strict:false so an unknown FUTURE flag before `--` (written by a newer host\n // config) is ignored instead of throwing — a parse throw here would prevent the\n // real MCP server from ever spawning and wedge the host's tool call. We only\n // read the two flags we understand; everything else is tolerated.\n const { values } = parseArgs({\n args: flagArgs,\n options: {\n connector: { type: \"string\" },\n scope: { type: \"string\" },\n // `--host <platformId>` bakes the install TARGET platform into the wrapper\n // so the proxy stamps hostPlatform correctly under a headless spawn (where\n // runtime env markers are absent). Optional + tolerated (strict:false).\n host: { type: \"string\" },\n },\n allowPositionals: true,\n strict: false,\n });\n\n // With strict:false, parseArgs types each value as string | boolean; we only\n // accept the string form (a bare `--connector` flag with no value is invalid).\n const connectorId = typeof values.connector === \"string\" ? values.connector : undefined;\n if (!connectorId || connectorId.trim() === \"\") {\n return fail(\"serve requires --connector <id>\");\n }\n\n // `--scope` is optional and only ever \"user\" | \"project\" (the wrapper emits\n // exactly those). An unrecognized value is ignored rather than fatal so a\n // future/older wrapper can never break a real tool call over a flag mismatch.\n const rawScope = values.scope;\n const installScope: TelemetryInstallScope | undefined =\n rawScope === \"user\" || rawScope === \"project\" ? rawScope : undefined;\n\n // `--host` carries the install TARGET platform id (string only). runServe\n // validates it against the registry and falls back to runtime detection when\n // it is absent or unrecognized — so a future/older wrapper never breaks here.\n const hostPlatformOverride =\n typeof values.host === \"string\" ? (values.host as PlatformId) : undefined;\n\n const serverCommand = serverInvocation[0];\n if (!serverCommand) {\n return fail(\"serve requires a command after `--`\");\n }\n const serverArgs = serverInvocation.slice(1);\n\n const code = await runServe({\n connectorId,\n serverCommand,\n serverArgs,\n installScope,\n hostPlatformOverride,\n });\n process.exit(code);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,iBAAiB;AAO1B,eAAsB,IAAI,MAAiC;AAGzD,QAAM,WAAW,KAAK,QAAQ,IAAI;AAClC,MAAI,aAAa,IAAI;AACnB,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,KAAK,MAAM,GAAG,QAAQ;AACvC,QAAM,mBAAmB,KAAK,MAAM,WAAW,CAAC;AAMhD,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,WAAW,EAAE,MAAM,SAAS;AAAA,MAC5B,OAAO,EAAE,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA,MAIxB,MAAM,EAAE,MAAM,SAAS;AAAA,IACzB;AAAA,IACA,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EACV,CAAC;AAID,QAAM,cAAc,OAAO,OAAO,cAAc,WAAW,OAAO,YAAY;AAC9E,MAAI,CAAC,eAAe,YAAY,KAAK,MAAM,IAAI;AAC7C,WAAO,KAAK,iCAAiC;AAAA,EAC/C;AAKA,QAAM,WAAW,OAAO;AACxB,QAAM,eACJ,aAAa,UAAU,aAAa,YAAY,WAAW;AAK7D,QAAM,uBACJ,OAAO,OAAO,SAAS,WAAY,OAAO,OAAsB;AAElE,QAAM,gBAAgB,iBAAiB,CAAC;AACxC,MAAI,CAAC,eAAe;AAClB,WAAO,KAAK,qCAAqC;AAAA,EACnD;AACA,QAAM,aAAa,iBAAiB,MAAM,CAAC;AAE3C,QAAM,OAAO,MAAM,SAAS;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,UAAQ,KAAK,IAAI;AACnB;","names":[]}
|