@ken-jo/agent-connector 0.4.44 → 0.4.67

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.
Files changed (188) hide show
  1. package/README.md +17 -4
  2. package/dist/{action-72J2TCKQ.js → action-RUM6GP23.js} +12 -12
  3. package/dist/{amazon-q-UFLBUSHG.js → amazon-q-KXVJFT7Q.js} +7 -11
  4. package/dist/amazon-q-KXVJFT7Q.js.map +1 -0
  5. package/dist/{amp-5DJK7VAL.js → amp-WAPHJYTK.js} +38 -63
  6. package/dist/amp-WAPHJYTK.js.map +1 -0
  7. package/dist/{antigravity-NWP2TUG6.js → antigravity-GF3RU42A.js} +5 -5
  8. package/dist/{antigravity-cli-KPNLE7X4.js → antigravity-cli-OH27IFH5.js} +5 -5
  9. package/dist/{chunk-QY42WGBX.js → chunk-2HCJV6UO.js} +33 -3
  10. package/dist/chunk-2HCJV6UO.js.map +1 -0
  11. package/dist/{chunk-ERV4TKRV.js → chunk-3Y23ZYYF.js} +10 -10
  12. package/dist/chunk-3Y23ZYYF.js.map +1 -0
  13. package/dist/{chunk-L7ESV37V.js → chunk-7CZKXXBD.js} +4 -2
  14. package/dist/chunk-7CZKXXBD.js.map +1 -0
  15. package/dist/{chunk-ZY25RG4Y.js → chunk-ALVXORZM.js} +4 -2
  16. package/dist/chunk-ALVXORZM.js.map +1 -0
  17. package/dist/{chunk-M3H7PQWT.js → chunk-AXAHW2KU.js} +4 -2
  18. package/dist/chunk-AXAHW2KU.js.map +1 -0
  19. package/dist/{chunk-CFM3JKIR.js → chunk-CSRBMJLU.js} +7 -7
  20. package/dist/{chunk-F4DSMVZ7.js → chunk-D6ZJS4ND.js} +2 -2
  21. package/dist/{chunk-B47MDOV3.js → chunk-E45SUUD7.js} +5 -5
  22. package/dist/{chunk-3Q6YEDCG.js → chunk-F5COBB5F.js} +17 -45
  23. package/dist/chunk-F5COBB5F.js.map +1 -0
  24. package/dist/{chunk-5M2SMDA4.js → chunk-GCRRX4MO.js} +2 -2
  25. package/dist/{chunk-2RPHDVHW.js → chunk-IU42THN7.js} +2 -2
  26. package/dist/{chunk-VPSHGDDQ.js → chunk-IZ4XQ23W.js} +26 -10
  27. package/dist/chunk-IZ4XQ23W.js.map +1 -0
  28. package/dist/{chunk-SBV2QJ5C.js → chunk-LS65GL2P.js} +36 -36
  29. package/dist/{chunk-IKEXNI2W.js → chunk-NXR4HM5N.js} +18 -18
  30. package/dist/{chunk-ASHAMORS.js → chunk-P5KA5NVR.js} +2 -2
  31. package/dist/{chunk-A767JFHW.js → chunk-RHML2NOB.js} +65 -35
  32. package/dist/chunk-RHML2NOB.js.map +1 -0
  33. package/dist/{chunk-UXG64P6R.js → chunk-RQCBBLTA.js} +7 -4
  34. package/dist/chunk-RQCBBLTA.js.map +1 -0
  35. package/dist/{chunk-LETB5HCK.js → chunk-TZ5KGCE2.js} +2 -2
  36. package/dist/{chunk-WZWK4ICE.js → chunk-UVBAH263.js} +10 -7
  37. package/dist/chunk-UVBAH263.js.map +1 -0
  38. package/dist/{chunk-E3GWKJU5.js → chunk-ZEFUDBTY.js} +5 -5
  39. package/dist/{chunk-XW46WVR2.js → chunk-ZSMGHEB5.js} +10 -5
  40. package/dist/chunk-ZSMGHEB5.js.map +1 -0
  41. package/dist/{claude-code-HXIVRZCY.js → claude-code-WLN43K7I.js} +15 -8
  42. package/dist/claude-code-WLN43K7I.js.map +1 -0
  43. package/dist/cli/sdk.js +7 -7
  44. package/dist/cli.js +1 -1
  45. package/dist/{cline-AGFJF4AC.js → cline-PEGTGVQD.js} +4 -4
  46. package/dist/{codebuff-YUQ4PN7G.js → codebuff-UG6LVSOM.js} +4 -4
  47. package/dist/{codex-FLU37DV3.js → codex-4LVDQXCD.js} +32 -6
  48. package/dist/codex-4LVDQXCD.js.map +1 -0
  49. package/dist/{continue-ZMI4YN75.js → continue-DYV5V55Y.js} +9 -5
  50. package/dist/continue-DYV5V55Y.js.map +1 -0
  51. package/dist/{copilot-cli-XPRJ5MQB.js → copilot-cli-NVFXFLUF.js} +66 -51
  52. package/dist/copilot-cli-NVFXFLUF.js.map +1 -0
  53. package/dist/{crush-3OB5ZTCC.js → crush-PP4HYZLT.js} +4 -4
  54. package/dist/{cursor-F4HYO2FP.js → cursor-XMXOZKAP.js} +5 -5
  55. package/dist/{detect-L3NJTBO5.js → detect-IZOWP5AA.js} +4 -4
  56. package/dist/{doctor-PUE4HO3N.js → doctor-5IVUQ2YH.js} +14 -14
  57. package/dist/{droid-NZCKYKOV.js → droid-ETNOUIPJ.js} +6 -12
  58. package/dist/droid-ETNOUIPJ.js.map +1 -0
  59. package/dist/{gemini-cli-3ZGCXUDD.js → gemini-cli-P7XJXWVH.js} +19 -6
  60. package/dist/gemini-cli-P7XJXWVH.js.map +1 -0
  61. package/dist/{goose-MGGNVXJP.js → goose-UZVA6MQC.js} +16 -22
  62. package/dist/goose-UZVA6MQC.js.map +1 -0
  63. package/dist/{hermes-L3CBJ37L.js → hermes-IC6R4CII.js} +44 -22
  64. package/dist/hermes-IC6R4CII.js.map +1 -0
  65. package/dist/{hook-S3DNNGZX.js → hook-7IUPIHCZ.js} +12 -12
  66. package/dist/index.d.ts +2 -2
  67. package/dist/index.js +5 -5
  68. package/dist/{install-7SUJFRYO.js → install-EP6GPQ65.js} +14 -14
  69. package/dist/{introspect-B164-hj3.d.ts → introspect-BFcXpfUp.d.ts} +1 -1
  70. package/dist/{jetbrains-copilot-M2LHJBAW.js → jetbrains-copilot-MZO2RQGJ.js} +19 -15
  71. package/dist/jetbrains-copilot-MZO2RQGJ.js.map +1 -0
  72. package/dist/{kilo-RMRP2EL7.js → kilo-CCB34CQQ.js} +18 -55
  73. package/dist/kilo-CCB34CQQ.js.map +1 -0
  74. package/dist/{kilo-cli-6ITBNHTH.js → kilo-cli-EOMN3WC7.js} +18 -55
  75. package/dist/kilo-cli-EOMN3WC7.js.map +1 -0
  76. package/dist/{kimi-QYHWAY54.js → kimi-GUSJME55.js} +8 -4
  77. package/dist/kimi-GUSJME55.js.map +1 -0
  78. package/dist/{kiro-2K5UJVGC.js → kiro-6OHZ5RGV.js} +5 -5
  79. package/dist/kiro-6OHZ5RGV.js.map +1 -0
  80. package/dist/{leaderboard-2VAAOK3D.js → leaderboard-6I2E5XZK.js} +5 -5
  81. package/dist/{mimo-code-K7AMX2QW.js → mimo-code-ZPJJ6IIW.js} +21 -56
  82. package/dist/mimo-code-ZPJJ6IIW.js.map +1 -0
  83. package/dist/{mux-GT7FWVLH.js → mux-AFTVMGGM.js} +4 -4
  84. package/dist/{nemoclaw-GQMS6CUM.js → nemoclaw-D5EN4G2Q.js} +5 -5
  85. package/dist/{omp-2RPYIZUF.js → omp-GKI2PZ7G.js} +17 -46
  86. package/dist/omp-GKI2PZ7G.js.map +1 -0
  87. package/dist/{openclaw-P5GMEEGC.js → openclaw-A76PCNBV.js} +5 -5
  88. package/dist/{opencode-5D2SK3EX.js → opencode-M34E6PI7.js} +21 -56
  89. package/dist/opencode-M34E6PI7.js.map +1 -0
  90. package/dist/{package-VUX663ET.js → package-BWLV24OO.js} +11 -11
  91. package/dist/{pi-ZMM4KJTO.js → pi-HVG6ZWFE.js} +4 -4
  92. package/dist/{qwen-code-4ZLVGN2C.js → qwen-code-OWLM3I5P.js} +12 -5
  93. package/dist/qwen-code-OWLM3I5P.js.map +1 -0
  94. package/dist/{roo-code-67QGLQRM.js → roo-code-RFKKTNNI.js} +4 -4
  95. package/dist/runtime/index.d.ts +1 -1
  96. package/dist/runtime/index.js +10 -10
  97. package/dist/sdk/index.d.ts +3 -3
  98. package/dist/sdk/index.js +6 -6
  99. package/dist/sdk/test.d.ts +2 -2
  100. package/dist/sdk/test.js +9 -9
  101. package/dist/{serve-MOIIYFER.js → serve-CM4HZPMP.js} +12 -12
  102. package/dist/{status-SCBCWS7H.js → status-BPB4VLQX.js} +10 -10
  103. package/dist/{statusline-NRPDOPGA.js → statusline-HIKR2I4Q.js} +11 -11
  104. package/dist/{telemetry-Q55B5NSZ.js → telemetry-SBVUJYNE.js} +10 -10
  105. package/dist/{trae-TMJPHWZ5.js → trae-FVHQALK3.js} +4 -4
  106. package/dist/{types-COSBYpKs.d.ts → types-ChUrvw0j.d.ts} +8 -8
  107. package/dist/{uninstall-SNI7GPQD.js → uninstall-MO3RGGVE.js} +21 -14
  108. package/dist/uninstall-MO3RGGVE.js.map +1 -0
  109. package/dist/{upgrade-ZUNBJWJ7.js → upgrade-6XIGSPGY.js} +14 -14
  110. package/dist/{usage-UQDBIU42.js → usage-IBN36ZVW.js} +2 -2
  111. package/dist/{usage-event-HPG2BIAY.js → usage-event-4RJP37K6.js} +11 -11
  112. package/dist/{vscode-copilot-H7JKUKLZ.js → vscode-copilot-6FLDRTKV.js} +26 -19
  113. package/dist/vscode-copilot-6FLDRTKV.js.map +1 -0
  114. package/dist/{warp-SVDVKQQI.js → warp-7CC52UJV.js} +4 -4
  115. package/dist/{windsurf-H36YKOMR.js → windsurf-6ZLQMBQW.js} +4 -4
  116. package/dist/{zed-LHWJALLZ.js → zed-FULJMNBV.js} +4 -4
  117. package/package.json +2 -1
  118. package/dist/amazon-q-UFLBUSHG.js.map +0 -1
  119. package/dist/amp-5DJK7VAL.js.map +0 -1
  120. package/dist/chunk-3Q6YEDCG.js.map +0 -1
  121. package/dist/chunk-A767JFHW.js.map +0 -1
  122. package/dist/chunk-ERV4TKRV.js.map +0 -1
  123. package/dist/chunk-L7ESV37V.js.map +0 -1
  124. package/dist/chunk-M3H7PQWT.js.map +0 -1
  125. package/dist/chunk-QY42WGBX.js.map +0 -1
  126. package/dist/chunk-UXG64P6R.js.map +0 -1
  127. package/dist/chunk-VPSHGDDQ.js.map +0 -1
  128. package/dist/chunk-WZWK4ICE.js.map +0 -1
  129. package/dist/chunk-XW46WVR2.js.map +0 -1
  130. package/dist/chunk-ZY25RG4Y.js.map +0 -1
  131. package/dist/claude-code-HXIVRZCY.js.map +0 -1
  132. package/dist/codex-FLU37DV3.js.map +0 -1
  133. package/dist/continue-ZMI4YN75.js.map +0 -1
  134. package/dist/copilot-cli-XPRJ5MQB.js.map +0 -1
  135. package/dist/droid-NZCKYKOV.js.map +0 -1
  136. package/dist/gemini-cli-3ZGCXUDD.js.map +0 -1
  137. package/dist/goose-MGGNVXJP.js.map +0 -1
  138. package/dist/hermes-L3CBJ37L.js.map +0 -1
  139. package/dist/jetbrains-copilot-M2LHJBAW.js.map +0 -1
  140. package/dist/kilo-RMRP2EL7.js.map +0 -1
  141. package/dist/kilo-cli-6ITBNHTH.js.map +0 -1
  142. package/dist/kimi-QYHWAY54.js.map +0 -1
  143. package/dist/kiro-2K5UJVGC.js.map +0 -1
  144. package/dist/mimo-code-K7AMX2QW.js.map +0 -1
  145. package/dist/omp-2RPYIZUF.js.map +0 -1
  146. package/dist/opencode-5D2SK3EX.js.map +0 -1
  147. package/dist/qwen-code-4ZLVGN2C.js.map +0 -1
  148. package/dist/uninstall-SNI7GPQD.js.map +0 -1
  149. package/dist/vscode-copilot-H7JKUKLZ.js.map +0 -1
  150. /package/dist/{action-72J2TCKQ.js.map → action-RUM6GP23.js.map} +0 -0
  151. /package/dist/{antigravity-NWP2TUG6.js.map → antigravity-GF3RU42A.js.map} +0 -0
  152. /package/dist/{antigravity-cli-KPNLE7X4.js.map → antigravity-cli-OH27IFH5.js.map} +0 -0
  153. /package/dist/{chunk-CFM3JKIR.js.map → chunk-CSRBMJLU.js.map} +0 -0
  154. /package/dist/{chunk-F4DSMVZ7.js.map → chunk-D6ZJS4ND.js.map} +0 -0
  155. /package/dist/{chunk-B47MDOV3.js.map → chunk-E45SUUD7.js.map} +0 -0
  156. /package/dist/{chunk-5M2SMDA4.js.map → chunk-GCRRX4MO.js.map} +0 -0
  157. /package/dist/{chunk-2RPHDVHW.js.map → chunk-IU42THN7.js.map} +0 -0
  158. /package/dist/{chunk-SBV2QJ5C.js.map → chunk-LS65GL2P.js.map} +0 -0
  159. /package/dist/{chunk-IKEXNI2W.js.map → chunk-NXR4HM5N.js.map} +0 -0
  160. /package/dist/{chunk-ASHAMORS.js.map → chunk-P5KA5NVR.js.map} +0 -0
  161. /package/dist/{chunk-LETB5HCK.js.map → chunk-TZ5KGCE2.js.map} +0 -0
  162. /package/dist/{chunk-E3GWKJU5.js.map → chunk-ZEFUDBTY.js.map} +0 -0
  163. /package/dist/{cline-AGFJF4AC.js.map → cline-PEGTGVQD.js.map} +0 -0
  164. /package/dist/{codebuff-YUQ4PN7G.js.map → codebuff-UG6LVSOM.js.map} +0 -0
  165. /package/dist/{crush-3OB5ZTCC.js.map → crush-PP4HYZLT.js.map} +0 -0
  166. /package/dist/{cursor-F4HYO2FP.js.map → cursor-XMXOZKAP.js.map} +0 -0
  167. /package/dist/{detect-L3NJTBO5.js.map → detect-IZOWP5AA.js.map} +0 -0
  168. /package/dist/{doctor-PUE4HO3N.js.map → doctor-5IVUQ2YH.js.map} +0 -0
  169. /package/dist/{hook-S3DNNGZX.js.map → hook-7IUPIHCZ.js.map} +0 -0
  170. /package/dist/{install-7SUJFRYO.js.map → install-EP6GPQ65.js.map} +0 -0
  171. /package/dist/{leaderboard-2VAAOK3D.js.map → leaderboard-6I2E5XZK.js.map} +0 -0
  172. /package/dist/{mux-GT7FWVLH.js.map → mux-AFTVMGGM.js.map} +0 -0
  173. /package/dist/{nemoclaw-GQMS6CUM.js.map → nemoclaw-D5EN4G2Q.js.map} +0 -0
  174. /package/dist/{openclaw-P5GMEEGC.js.map → openclaw-A76PCNBV.js.map} +0 -0
  175. /package/dist/{package-VUX663ET.js.map → package-BWLV24OO.js.map} +0 -0
  176. /package/dist/{pi-ZMM4KJTO.js.map → pi-HVG6ZWFE.js.map} +0 -0
  177. /package/dist/{roo-code-67QGLQRM.js.map → roo-code-RFKKTNNI.js.map} +0 -0
  178. /package/dist/{serve-MOIIYFER.js.map → serve-CM4HZPMP.js.map} +0 -0
  179. /package/dist/{status-SCBCWS7H.js.map → status-BPB4VLQX.js.map} +0 -0
  180. /package/dist/{statusline-NRPDOPGA.js.map → statusline-HIKR2I4Q.js.map} +0 -0
  181. /package/dist/{telemetry-Q55B5NSZ.js.map → telemetry-SBVUJYNE.js.map} +0 -0
  182. /package/dist/{trae-TMJPHWZ5.js.map → trae-FVHQALK3.js.map} +0 -0
  183. /package/dist/{upgrade-ZUNBJWJ7.js.map → upgrade-6XIGSPGY.js.map} +0 -0
  184. /package/dist/{usage-UQDBIU42.js.map → usage-IBN36ZVW.js.map} +0 -0
  185. /package/dist/{usage-event-HPG2BIAY.js.map → usage-event-4RJP37K6.js.map} +0 -0
  186. /package/dist/{warp-SVDVKQQI.js.map → warp-7CC52UJV.js.map} +0 -0
  187. /package/dist/{windsurf-H36YKOMR.js.map → windsurf-6ZLQMBQW.js.map} +0 -0
  188. /package/dist/{zed-LHWJALLZ.js.map → zed-FULJMNBV.js.map} +0 -0
package/README.md CHANGED
@@ -11,10 +11,10 @@
11
11
  ![platforms](https://img.shields.io/badge/platforms-35-2563eb)
12
12
  ![surfaces](https://img.shields.io/badge/surfaces-MCP%20%7C%20hooks%20%7C%20commands%20%7C%20tools%20%7C%20memory%20%7C%20status%20line-2563eb)
13
13
  ![hook paradigms](https://img.shields.io/badge/hook%20paradigms-3-2563eb)
14
- ![install verified](https://img.shields.io/badge/install%20verified-29%2F29-22c55e)
15
- ![headless runtime](https://img.shields.io/badge/headless%20runtime-10%20CLIs%20activated-22c55e)
14
+ ![install verified](https://img.shields.io/badge/install%20verified-35%2F35-22c55e)
15
+ ![headless runtime](https://img.shields.io/badge/headless%20runtime-20%20CLIs%20activated-22c55e)
16
16
  ![marketplace](https://img.shields.io/badge/package-9%20marketplace%20formats-2563eb)
17
- ![tests](https://img.shields.io/badge/tests-1916%20passing-22c55e)
17
+ ![tests](https://img.shields.io/badge/tests-passing-22c55e)
18
18
 
19
19
  ## Who this is for
20
20
 
@@ -677,11 +677,24 @@ defineConnector({
677
677
  ```bash
678
678
  npm install
679
679
  npm run typecheck
680
- npm test
681
680
  npm run build
682
681
  npm run dev -- detect # run the CLI from source via tsx
682
+
683
+ # Tests: scope + single-fork (NOT bare `npm test` — it OOMs low-RAM machines).
684
+ npx vitest run --pool=forks --poolOptions.forks.singleFork=true --poolOptions.forks.maxForks=1 \
685
+ tests/adapters/<host>.test.ts
683
686
  ```
684
687
 
688
+ ## Contributing
689
+
690
+ PRs welcome — especially new host adapters and fixes verified against a host's
691
+ primary source. See **[CONTRIBUTING.md](CONTRIBUTING.md)** for the dev workflow,
692
+ the single-fork test discipline, the **verify-first** rule for adapters, and the
693
+ new-host checklist. Want a new agent CLI supported? Open a
694
+ [host adapter request](https://github.com/ken-jo/agent-connector/issues/new?template=host_adapter_request.yml).
695
+
696
+ Security reports: see [SECURITY.md](SECURITY.md).
697
+
685
698
  ## License
686
699
 
687
700
  Apache-2.0 © 2026 KenJo
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  fail
4
- } from "./chunk-IKEXNI2W.js";
4
+ } from "./chunk-NXR4HM5N.js";
5
5
  import {
6
6
  runAction
7
- } from "./chunk-CFM3JKIR.js";
7
+ } from "./chunk-CSRBMJLU.js";
8
8
  import "./chunk-OP4KBXUO.js";
9
9
  import "./chunk-7QRUZAUG.js";
10
- import "./chunk-5M2SMDA4.js";
11
- import "./chunk-B47MDOV3.js";
12
- import "./chunk-F4DSMVZ7.js";
10
+ import "./chunk-GCRRX4MO.js";
11
+ import "./chunk-E45SUUD7.js";
12
+ import "./chunk-D6ZJS4ND.js";
13
13
  import "./chunk-KHO5WNTP.js";
14
- import "./chunk-UXG64P6R.js";
15
- import "./chunk-WZWK4ICE.js";
16
- import "./chunk-SBV2QJ5C.js";
17
- import "./chunk-L7ESV37V.js";
14
+ import "./chunk-RQCBBLTA.js";
15
+ import "./chunk-UVBAH263.js";
16
+ import "./chunk-LS65GL2P.js";
17
+ import "./chunk-7CZKXXBD.js";
18
18
  import "./chunk-TO57WYBB.js";
19
- import "./chunk-ZY25RG4Y.js";
20
- import "./chunk-QY42WGBX.js";
19
+ import "./chunk-ALVXORZM.js";
20
+ import "./chunk-2HCJV6UO.js";
21
21
 
22
22
  // src/cli/commands/action.ts
23
23
  import { parseArgs } from "util";
@@ -52,4 +52,4 @@ async function run(argv) {
52
52
  export {
53
53
  run
54
54
  };
55
- //# sourceMappingURL=action-72J2TCKQ.js.map
55
+ //# sourceMappingURL=action-RUM6GP23.js.map
@@ -1,19 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- normalizeSessionSource
4
- } from "./chunk-H53QZQJI.js";
5
2
  import {
6
3
  resolveEnvRefsDeep
7
4
  } from "./chunk-DBQMX75U.js";
8
5
  import {
9
6
  BaseAdapter
10
- } from "./chunk-A767JFHW.js";
7
+ } from "./chunk-RHML2NOB.js";
11
8
  import {
12
9
  buildWrappedStdio,
13
10
  isHomeBinHookCommand
14
11
  } from "./chunk-TO57WYBB.js";
15
- import "./chunk-ZY25RG4Y.js";
16
- import "./chunk-QY42WGBX.js";
12
+ import "./chunk-ALVXORZM.js";
13
+ import "./chunk-2HCJV6UO.js";
17
14
 
18
15
  // src/adapters/amazon-q/index.ts
19
16
  import { existsSync, statSync } from "fs";
@@ -476,7 +473,7 @@ var AmazonQAdapter = class extends BaseAdapter {
476
473
  parseEvent(event, raw) {
477
474
  const input = raw ?? {};
478
475
  const connectorId = typeof input.connector === "string" ? input.connector : "";
479
- const sessionId = typeof input.session_id === "string" ? input.session_id : "";
476
+ const sessionId = "";
480
477
  const projectDir = typeof input.cwd === "string" ? input.cwd : void 0;
481
478
  const base = {
482
479
  hostPlatform: HOST,
@@ -506,7 +503,7 @@ var AmazonQAdapter = class extends BaseAdapter {
506
503
  case "SessionStart": {
507
504
  const ev = {
508
505
  ...base,
509
- source: normalizeSessionSource(input.source)
506
+ source: "startup"
510
507
  };
511
508
  return ev;
512
509
  }
@@ -519,8 +516,7 @@ var AmazonQAdapter = class extends BaseAdapter {
519
516
  }
520
517
  case "Stop": {
521
518
  const ev = {
522
- ...base,
523
- ...typeof input.stop_hook_active === "boolean" ? { stopHookActive: input.stop_hook_active } : {}
519
+ ...base
524
520
  };
525
521
  return ev;
526
522
  }
@@ -567,4 +563,4 @@ export {
567
563
  adapter,
568
564
  amazon_q_default as default
569
565
  };
570
- //# sourceMappingURL=amazon-q-UFLBUSHG.js.map
566
+ //# sourceMappingURL=amazon-q-KXVJFT7Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/amazon-q/index.ts"],"sourcesContent":["/**\n * adapters/amazon-q — Amazon Q Developer CLI platform adapter.\n *\n * Amazon Q Developer CLI (`q` / `qchat`) is a **json-stdio** host. It exposes a\n * real hooks layer (agentSpawn / userPromptSubmit / preToolUse / postToolUse /\n * stop, JSON-over-STDIN, exit-code 0/2 contract — primary-verified via\n * aws.github.io/amazon-q-developer-cli agent-format → Hooks Field). The hook\n * STDIN+exit contract is IDENTICAL to the sibling AWS host kiro; only the WRITE\n * shape differs (see below).\n *\n * Hooks live ONLY in per-agent config JSON files — there is NO global hooks.json:\n * user → ~/.aws/amazonq/cli-agents/<name>.json\n * project → <projectDir>/.amazonq/cli-agents/<name>.json\n * Because hooks have no global file, AC must target a SPECIFIC agent file. We\n * mirror kiro's per-agent selection rule and write the built-in default agent\n * file — `cli-agents/q_cli_default.json`. Amazon Q auto-loads the built-in\n * `q_cli_default` agent for a new chat session (the built-in default is otherwise\n * in-memory); a file literally named `default.json` would be an INACTIVE custom\n * agent named `default` the user must explicitly select (`q chat --agent default`),\n * so hooks there would never fire — exactly the trap kiro avoids with\n * `kiro_default.json`. Primary-verified via the agent-format default\n * knowledge-base dir `~/.aws/amazonq/knowledge_bases/q_cli_default/`.\n * A PROJECT install writes a project-scoped `q_cli_default` agent file\n * (<projectDir>/.amazonq/cli-agents/q_cli_default.json) that SHADOWS the\n * user-global one — a local `q_cli_default` takes precedence and auto-loads.\n *\n * The `hooks` field is an OBJECT keyed by trigger name (NOT kiro's matcher-grouped\n * array). Each entry is `{ command, matcher? }` — NO `type` field; `matcher` is\n * only meaningful for preToolUse/postToolUse:\n * \"hooks\": {\n * \"agentSpawn\": [{ \"command\": \"<cmd>\" }],\n * \"userPromptSubmit\": [{ \"command\": \"<cmd>\" }],\n * \"preToolUse\": [{ \"command\": \"<cmd>\", \"matcher\": \"<toolNamePattern?>\" }],\n * \"postToolUse\": [{ \"command\": \"<cmd>\", \"matcher\": \"<optional>\" }],\n * \"stop\": [{ \"command\": \"<cmd>\" }]\n * }\n * AC MERGES into this object: it preserves ALL other agent fields (name /\n * description / mcpServers / tools / resources / user hooks) and only upserts its\n * own home-bin command into each mapped trigger array, identified by the command\n * string for idempotent re-install and clean uninstall (an emptied trigger key is\n * dropped). The shared object-map hook-array merge engine (base.ts\n * upsertHookEntries / removeHookEntries) handles this FLAT object-of-arrays shape\n * directly — the descriptor renders a flat `{ command, matcher? }` entry.\n *\n * Canonical AC event → Amazon Q trigger:\n * SessionStart → agentSpawn\n * UserPromptSubmit → userPromptSubmit\n * PreToolUse → preToolUse\n * PostToolUse → postToolUse\n * Stop → stop\n * Events with no Amazon Q trigger (PreCompact / SessionEnd / Notification and the\n * E1 extension events) warn-skip at install time.\n *\n * Hook protocol is EXIT-CODE based (identical to kiro): exit 0 = allow, exit 2 =\n * block (preToolUse only; STDERR is returned to the LLM). Amazon Q cannot rewrite\n * tool args or output, so canModifyArgs / canModifyOutput are false.\n * Context injection → exit 0 with the guidance written as PLAIN STDOUT (NOT a\n * JSON envelope). Amazon Q adds a hook's STDOUT to the agent's context ONLY for\n * agentSpawn and userPromptSubmit (\"STDOUT is added to agent's context\"); for\n * preToolUse / postToolUse / stop the docs say STDOUT is \"captured but not shown\n * to user\" — no context channel — so a `context` decision on those degrades to a\n * plain exit-0 pass-through. Primary-verified via aws/amazon-q-developer-cli\n * docs/hooks.md (Hook Output + per-event Exit Code Behavior); there is NO\n * hookSpecificOutput / hookEventName / additionalContext envelope anywhere in\n * Amazon Q's schema.\n *\n * MCP config (legacy files, primary-verified via AWS docs) — UNCHANGED by the\n * hooks wiring; the MCP server surface still targets the global/workspace mcp.json:\n * - user scope → ~/.aws/amazonq/mcp.json (global; applies to all workspaces)\n * - project scope → <projectDir>/.amazonq/mcp.json (local workspace)\n * Both are JSON, root key \"mcpServers\". Amazon Q reads BOTH when both exist\n * and merges them (union); workspace wins on same-name conflict with a warning.\n *\n * Server entry shape (primary-verified):\n * - stdio: { command: string; args?: string[]; env?: { [k: string]: string };\n * timeout?: number } (timeout in MILLISECONDS, e.g. 60000;\n * transport inferred from presence of `command` — no `type` key)\n * - http: { type: \"http\"; url: string }\n * (the remote/HTTP shape is written with an explicit `type: \"http\"`\n * discriminator + `url`, per command-line-mcp-config-CLI.html. No\n * `headers` field — Amazon Q remote auth is OAuth, not static\n * headers — and no `disabled` flag.)\n *\n * Path resolution — NOTE the nested user scope:\n * - user: join(homedir(), \".aws\", \"amazonq\") (two path segments)\n * - project: join(projectDir, \".amazonq\") (single dotDir, no .aws)\n * homedir() handles USERPROFILE on Windows automatically; no manual branch.\n *\n * Env interpolation: Amazon Q has no documented native ${env:VAR} token;\n * resolve all references to literals at install time (the safe path, same as\n * droid/crush).\n *\n * Memory / rules (primary-verified — docs.aws.amazon.com context-project-rules):\n * Project rules are plain Markdown files in <projectDir>/.amazonq/rules; Amazon\n * Q \"will automatically use them as context whenever a developer chats with\n * Amazon Q within your project\". NO frontmatter required. We write a DEDICATED\n * agent-connector-owned file there (`.amazonq/rules/agent-connector.md`),\n * mirroring the cline `.clinerules/agent-connector.md` approach: memoryTargets()\n * points at the dedicated file and the base managed-block engine performs the\n * surgical, hash-stamped, uninstall-reversible write. PROJECT SCOPE ONLY — the\n * AWS docs do not cleanly document a user/global rules directory for the CLI\n * (a `~/.aws/amazonq/.../rules` path is unverified), so user scope returns [] →\n * the base installMemory skip-warns rather than writing into an unread path.\n *\n * Hook config path targets the built-in default agent file\n * (cli-agents/q_cli_default.json), which is a DIFFERENT file from the MCP mcp.json\n * (getHookConfigPath ≠ getServerConfigPath), mirroring kiro's split surfaces.\n */\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter, type HookMergeDescriptor } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, MemoryTarget, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n StopEvent,\n SubagentDef,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildWrappedStdio,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"amazon-q\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * The built-in default agent file AC registers hooks on. Amazon Q auto-loads the\n * built-in `q_cli_default` agent for a new chat session (the built-in default is\n * otherwise in-memory). A file literally named `default.json` would be an INACTIVE\n * custom agent named `default` that the user must explicitly select\n * (`q chat --agent default`), so hooks merged there would never fire — we register\n * on `q_cli_default.json` instead (mirrors kiro's `kiro_default.json` selection;\n * primary-verified via the agent-format default knowledge-base dir\n * `knowledge_bases/q_cli_default/`).\n */\nconst DEFAULT_AGENT_FILE = \"q_cli_default.json\";\n\n/**\n * The agent NAME (filename stem) AC reserves for the hooks / built-in default\n * agent (`cli-agents/q_cli_default.json`). A connector subagent declared with\n * this exact name would resolve to the SAME file and clobber the hooks agent, so\n * installSubagents REFUSES it (skip-warn) and uninstallSubagents never touches it.\n */\nconst RESERVED_AGENT_NAME = \"q_cli_default\";\n\n/**\n * Amazon Q native hook trigger names (the keys under an agent file's `hooks`\n * object). Only the triggers Amazon Q fires for the json-stdio command paradigm.\n */\nconst Q_TRIGGER = {\n preToolUse: \"preToolUse\",\n postToolUse: \"postToolUse\",\n agentSpawn: \"agentSpawn\",\n userPromptSubmit: \"userPromptSubmit\",\n stop: \"stop\",\n} as const;\n\n/**\n * Map canonical event names → Amazon Q's native trigger names. Only mapped\n * events are present; PreCompact / SessionEnd / Notification and the E1\n * extension events have no Amazon Q equivalent → warn-skip at install time.\n */\nconst EVENT_MAP: Partial<Record<HookEventName, string>> = {\n SessionStart: Q_TRIGGER.agentSpawn,\n UserPromptSubmit: Q_TRIGGER.userPromptSubmit,\n PreToolUse: Q_TRIGGER.preToolUse,\n PostToolUse: Q_TRIGGER.postToolUse,\n Stop: Q_TRIGGER.stop,\n};\n\n/** Triggers whose `matcher` is meaningful (tool-name pattern). Others omit it. */\nconst MATCHER_TRIGGERS: ReadonlySet<string> = new Set([\n Q_TRIGGER.preToolUse,\n Q_TRIGGER.postToolUse,\n]);\n\n/**\n * Amazon Q triggers whose hook STDOUT is added to the agent's context: agentSpawn\n * (≈ SessionStart) and userPromptSubmit (docs/hooks.md — both say \"STDOUT is added\n * to agent's context\"). For preToolUse / postToolUse / stop the docs say STDOUT is\n * \"captured but not shown to user\" — no context channel — so a `context` decision\n * on those degrades to a plain exit-0 pass-through.\n * Ref: aws/amazon-q-developer-cli docs/hooks.md (per-event Exit Code Behavior).\n */\nconst CONTEXT_TRIGGERS: ReadonlySet<string> = new Set([\n Q_TRIGGER.agentSpawn,\n Q_TRIGGER.userPromptSubmit,\n]);\n\n/**\n * A single Amazon Q native hook entry: FLAT `{ command, matcher? }` (NO `type`\n * field — unlike kiro's matcher-grouped nested shape).\n */\ninterface AmazonQHookEntry {\n command: string;\n matcher?: string;\n}\n\n/** The shape of an Amazon Q agent file (only the parts we touch). */\ninterface AmazonQAgentFile {\n hooks?: Record<string, AmazonQHookEntry[]>;\n [key: string]: unknown;\n}\n\n/**\n * Raw Amazon Q CLI hook stdin payload (snake_case wire fields).\n *\n * PRIMARY-VERIFIED against aws/amazon-q-developer-cli\n * crates/chat-cli/src/cli/chat/cli/hooks.rs:300-321 (run_hook builds `hook_input`)\n * and docs/hooks.md:14-107 (per-event input examples). The host serializes ONLY:\n * - hook_event_name + cwd (always)\n * - prompt (userPromptSubmit only)\n * - tool_name + tool_input + tool_response (pre/postToolUse only; response optional)\n * `connector` is injected by AC's own hook-command argv, not the host.\n *\n * Host GAPS (fields the host NEVER serializes — do NOT add reads for these):\n * - session_id : no session id on stdin → sessionId stays \"\".\n * - source : agentSpawn carries no start-reason discriminator; the Rust\n * hook::Source enum is config-grouping, never serialized.\n * - stop_hook_active: stop payload is exactly {hook_event_name, cwd}.\n */\ninterface AmazonQWireInput {\n connector?: unknown;\n hook_event_name?: string;\n cwd?: string;\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: unknown;\n prompt?: string;\n}\n\n/**\n * Native MCP server entry shapes Amazon Q accepts under `mcpServers`.\n * - stdio: BARE shape — NO `type` discriminator and NO `disabled` flag; the\n * transport is inferred from the presence of `command`. timeout is in\n * MILLISECONDS (pass timeoutMs through unchanged, do NOT divide).\n * - http: REMOTE shape — explicit `type: \"http\"` + `url`\n * (command-line-mcp-config-CLI.html). NO `headers` (remote auth is OAuth,\n * not static headers) and NO `disabled` flag.\n */\ninterface AmazonQStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n timeout?: number;\n}\ninterface AmazonQHttpServer {\n type: \"http\";\n url: string;\n}\n\nexport class AmazonQAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Amazon Q Developer CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: WIRED. Amazon Q reads `.amazonq/rules` (NOT AGENTS.md), so\n // the AGENTS.md-first BaseAdapter default does not apply — memoryTargets()\n // below overrides it to write a DEDICATED agent-connector-owned file\n // (<projectDir>/.amazonq/rules/agent-connector.md, plain Markdown, no\n // frontmatter — auto-applied as context per the AWS docs). Project scope\n // only; user scope skip-warns (no verified user/global rules dir).\n supportsMemory: true,\n //\n // Hooks: Amazon Q fires agentSpawn / userPromptSubmit / preToolUse /\n // postToolUse / stop (mapped from SessionStart / UserPromptSubmit /\n // PreToolUse / PostToolUse / Stop). It has no PreCompact / SessionEnd /\n // Notification equivalent, nor the E1 extension events (PermissionRequest /\n // PostToolUseFailure / SubagentStart / SubagentStop) — those warn-skip.\n preToolUse: true,\n postToolUse: true,\n preCompact: false,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // Exit-code protocol only — a hook can allow (0) or block (2), but it CANNOT\n // rewrite tool args or output.\n canModifyArgs: false,\n canModifyOutput: false,\n // agentSpawn / userPromptSubmit add a hook's plain STDOUT to the agent's\n // context (no JSON envelope) — primary-verified via docs/hooks.md.\n canInjectSessionContext: true,\n // Amazon Q registers stdio + Streamable HTTP MCP servers (primary-verified).\n transports: [\"stdio\", \"http\"],\n // Content surfaces:\n // subagents: WIRED. Amazon Q's \"agents\" are per-agent JSON files where the\n // FILENAME (minus .json) IS the agent name (primary-verified via the CLI\n // repo docs/agent-file-locations.md + docs/agent-format.md). AC maps each\n // connector SubagentDef → cli-agents/<name>.json = { name, description,\n // prompt } (+ model when non-\"inherit\"; + tools/allowedTools when the\n // SubagentDef carries a tool policy — see renderSubagent). Both scopes:\n // user → ~/.aws/amazonq/cli-agents/<name>.json\n // project → <projectDir>/.amazonq/cli-agents/<name>.json\n // A subagent named `q_cli_default` would resolve to the hooks/default-agent\n // file — the SDK already rejects it (non-kebab name), and installSubagents\n // refuses it as defense-in-depth so a subagent write can never clobber it.\n supportsSubagents: true,\n // commands (prompt library): DEFERRED — format unverified. The only primary\n // doc for the ~/.aws/amazonq/prompts/*.md prompt library is the IDE prompt-\n // library page (q-in-IDE-chat → ide-chat-context: prompts saved in\n // ~/.aws/amazonq/prompts, invoked via @<name> inside the IDE chat). The Q\n // CLI repo (aws/amazon-q-developer-cli/docs) ships NO prompts/saved-prompts\n // doc, so whether the `q`/`qchat` CLI reads that folder — and whether a\n // project-scoped prompts dir exists — is NOT primary-verified for the CLI\n // host this adapter targets. supportsCommands stays UNSET (base skip-warns)\n // rather than render an unverified surface (the continue per-server-YAML /\n // other deferred-unverified precedent).\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".aws\", \"amazonq\");\n const userMcp = join(userDir, \"mcp.json\");\n const projDir = join(projectDir, \".amazonq\");\n const projMcp = join(projDir, \"mcp.json\");\n\n const userInstalled = existsSync(userDir) || existsSync(userMcp);\n const projInstalled = existsSync(projDir) || existsSync(projMcp);\n const installed = userInstalled || projInstalled;\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projMcp : userMcp;\n\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 ? `found Amazon Q config (${scope}) at ${configPath}`\n : `no Amazon Q mcp.json at ${userDir} or ${projDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n /**\n * Config directory per scope. Amazon Q uses DIFFERENT basenames:\n * user: ~/.aws/amazonq (two segments — NOT a single dotDir)\n * project: <projectDir>/.amazonq\n * This is the ONE deviation from droid/cursor's single-basename getConfigDir.\n */\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".amazonq\")\n : join(homedir(), \".aws\", \"amazonq\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * Hooks live in a per-agent file, NOT the mcp.json. Amazon Q hooks have no\n * global file, so AC targets the built-in `q_cli_default` agent file at the\n * install scope (mirroring kiro's default-agent selection):\n * user → ~/.aws/amazonq/cli-agents/q_cli_default.json\n * project → <projectDir>/.amazonq/cli-agents/q_cli_default.json\n * A project install writes a project-scoped `q_cli_default` that SHADOWS the\n * user-global one (a local `q_cli_default` takes precedence and auto-loads).\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"cli-agents\", DEFAULT_AGENT_FILE);\n }\n\n // ── Memory surface: the `.amazonq/rules` content tree ─────────────────────\n // Amazon Q uses `.amazonq/rules` (NOT AGENTS.md) for its OWN project rules, so\n // this override replaces the AGENTS.md base default entirely:\n // project → <projectDir>/.amazonq/rules/agent-connector.md (DEDICATED file\n // AC owns; plain Markdown, auto-applied — no frontmatter needed)\n // user → [] (no verified user/global rules dir → base installMemory\n // skip-warns rather than guessing a path the CLI may not read)\n // When `.amazonq/rules` exists as a single FILE (not a directory) we must NOT\n // create `.amazonq/rules/agent-connector.md` underneath it (that would throw\n // ENOTDIR), so memoryTargets() returns [] and installMemory() emits a precise\n // skip-warn rather than crashing (the cline `.clinerules`-is-a-file precedent).\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n // An explicit platforms[amazon-q].memory.path override wins (escape hatch).\n if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);\n if (ctx.scope === \"project\") {\n if (this.rulesDirIsFile(ctx.projectDir)) return [];\n return [\n {\n path: join(ctx.projectDir, \".amazonq\", \"rules\", \"agent-connector.md\"),\n reason: \"amazon-q project rules dir (.amazonq/rules; agent-connector-owned file)\",\n },\n ];\n }\n // user scope: no primary-verified user/global rules dir → [] → skip-warn.\n return [];\n }\n\n /**\n * Override installMemory ONLY to surface a precise warn when `.amazonq/rules`\n * exists as a single FILE at project scope (so memoryTargets() returned []):\n * we never write under it. All other behavior delegates to the base\n * implementation (the cline `.clinerules`-is-a-file precedent).\n */\n override installMemory(ctx: InstallContext): ChangeRecord[] {\n if (\n ctx.scope === \"project\" &&\n !this.memoryOverride(ctx)?.path &&\n (ctx.connector.memory ?? []).length > 0 &&\n ctx.connector.platforms[this.id]?.memory !== false &&\n this.rulesDirIsFile(ctx.projectDir)\n ) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: join(ctx.projectDir, \".amazonq\", \"rules\"),\n detail:\n \"existing .amazonq/rules is a file, not a directory; left untouched — \" +\n \"convert it to a .amazonq/rules/ directory to receive agent-connector memory\",\n },\n ];\n }\n return super.installMemory(ctx);\n }\n\n /** True when `<dir>/.amazonq/rules` exists and is a regular FILE (not a dir). */\n private rulesDirIsFile(dir: string): boolean {\n const p = join(dir, \".amazonq\", \"rules\");\n if (!existsSync(p)) return false;\n try {\n return statSync(p).isFile();\n } catch {\n return false;\n }\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 amazon-q\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Amazon Q's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): AmazonQStdioServer | AmazonQHttpServer {\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 ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Amazon Q has no documented native interpolation token — resolve every\n // ${env:VAR} to a literal at install time (safe path, matches droid/crush).\n const entry: AmazonQStdioServer = {\n command: resolveEnvRefsDeep(command),\n };\n if (args.length > 0) entry.args = resolveEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n // timeout: Amazon Q uses MILLISECONDS — pass timeoutMs through unchanged.\n // Only emit when the connector explicitly sets one (do NOT invent a default).\n if (server.timeoutMs !== undefined) entry.timeout = server.timeoutMs;\n return entry;\n }\n\n // http (and any other remote transport) — Amazon Q registers a remote URL.\n // REMOTE shape: { type: \"http\", url } — explicit `type` discriminator, NO\n // `headers` (OAuth auth, not static headers), NO `disabled`.\n return {\n type: \"http\",\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n };\n }\n\n /**\n * Render stdio env values. Amazon Q has no documented native interpolation\n * token, so resolve `${env:VAR}` references to literals at install time.\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 (merge into the default agent file) ──────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.hooks === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"hooks disabled for amazon-q\" }];\n }\n if (connector.hookEvents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no hooks\" }];\n }\n\n const pending = connector.hookEvents.map((event) => ({\n event,\n matcher: connector.hooks[event]?.matcher ?? \"\",\n }));\n return this.upsertHookEntries(\n ctx,\n this.getHookConfigPath(ctx),\n pending,\n this.hookDescriptor(),\n );\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n return this.removeHookEntries(ctx, this.getHookConfigPath(ctx), this.hookDescriptor());\n }\n\n /**\n * Amazon Q's hook-merge descriptor (FLAT object-of-arrays shape — each entry is\n * `{ command, matcher? }`, NO `type` field, unlike kiro's nested\n * `{ matcher, hooks:[...] }`).\n * - mapEvent = EVENT_MAP (canonical → Amazon Q trigger); unmapped events\n * (PreCompact / SessionEnd / Notification + the E1 set) warn-skip.\n * - renderEntry emits `{ command }`, adding `matcher` ONLY for the\n * matcher-meaningful triggers (preToolUse/postToolUse) when one is declared;\n * an empty matcher = all tools, so it is OMITTED (no `matcher: \"\"` noise).\n * - entryOwnsCommand / ownsEntryForRemove match the home-bin command string\n * (idempotency on re-install; whole-entry removal on uninstall). FLAT host →\n * no stripInner; an emptied trigger key is dropped by the engine.\n */\n private hookDescriptor(): HookMergeDescriptor<AmazonQHookEntry> {\n return {\n mapEvent: (e) => EVENT_MAP[e as HookEventName],\n unmappedWarnDetail: (e) => `${e} has no Amazon Q hook equivalent — skipped`,\n renderEntry: (trigger, matcher, command) => {\n const entry: AmazonQHookEntry = { command };\n if (matcher && MATCHER_TRIGGERS.has(trigger)) entry.matcher = matcher;\n return entry;\n },\n entryOwnsCommand: (entry, command) => entry.command === command,\n ownsEntryForRemove: (c) => (entry) => this.isOurCommand(entry.command, c),\n skipDetail: (trigger) => `hooks.${trigger} already registered`,\n removeDetail: (trigger, removed) => `hooks.${trigger} (${removed})`,\n absentDetail: \"no hooks section present\",\n noMatchDetail: \"no matching hook entries\",\n };\n }\n\n /** True when a hook command references our home binary AND this connector id\n * (anchored so a shared-prefix id can't collide — see isHomeBinHookCommand). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Content surface: subagents → cli-agents/<name>.json ───────────────────\n // CONTENT-ONLY: a pure native-file writer — no runtime dispatch, no home-bin\n // pointer, no telemetry wrap. Amazon Q \"agents\" are per-agent JSON files where\n // the FILENAME (minus .json) IS the agent name (agent-file-locations.md). Each\n // file is a STANDALONE agent definition: we write only { name, description,\n // prompt } (+ model / tools / allowedTools when the SubagentDef carries them)\n // and NEVER inject hooks (those live in q_cli_default.json) or mcpServers (those\n // live in mcp.json). The whole file is AC-owned, so idempotency + reversibility\n // come from writeContentFile/removeContentFile (byte-identical → skip; uninstall\n // removes the file → NO_RESIDUE).\n // user → ~/.aws/amazonq/cli-agents/<name>.json\n // project → <projectDir>/.amazonq/cli-agents/<name>.json\n\n /** Native subagent file path: <configDir>/cli-agents/<name>.json. */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"cli-agents\", `${name}.json`);\n }\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 amazon-q\" }];\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 // COLLISION GUARD: a subagent named `q_cli_default` resolves to the SAME\n // file as the hooks/built-in default agent — refuse it so a subagent write\n // can never clobber the hooks agent.\n if (agent.name === RESERVED_AGENT_NAME) {\n return {\n platform: this.id,\n action: \"warn\",\n detail:\n `subagent \"${agent.name}\" collides with the built-in default agent file ` +\n `(cli-agents/${DEFAULT_AGENT_FILE}); skipped — rename the subagent`,\n };\n }\n return 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 // Never remove the hooks/default-agent file under the collision name.\n if (agent.name === RESERVED_AGENT_NAME) {\n return {\n platform: this.id,\n action: \"warn\",\n detail:\n `subagent \"${agent.name}\" was never installed (collides with ` +\n `cli-agents/${DEFAULT_AGENT_FILE}); left untouched`,\n };\n }\n return this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun);\n });\n }\n\n /**\n * Render a connector subagent into an Amazon Q agent JSON file\n * (agent-format.md):\n * { name, description, prompt } — prompt is the INLINE system-prompt string\n * (Amazon Q's `prompt` field is \"high-level context … similar to a system\n * prompt\"; we use the inline-text form, NOT a file:// ref).\n * Plus, when the SubagentDef carries them:\n * - model: only when set and not the platform-agnostic \"inherit\"\n * sentinel (Amazon Q has no \"inherit\" — omitting it applies the default).\n * - tools: SurfaceToolPolicy.allow → the `tools` array (the tools the\n * agent can use). Amazon Q's `tools` accepts plain tool-name strings and\n * `*`, the same vocabulary the portable allow-list carries.\n * - allowedTools: SurfaceToolPolicy.allow → the `allowedTools` array (tools\n * usable WITHOUT a permission prompt) — BUT only when the allow-list holds\n * no `*` (Amazon Q's allowedTools does NOT accept the `\"*\"` wildcard;\n * agent-format.md \"AllowedTools Field\"). When allow is exactly [\"*\"] we set\n * `tools` but omit `allowedTools` (every tool available, none auto-allowed).\n * `deny` has no clean Amazon Q analog (there is no disallowedTools field —\n * access is an allow-list), so a deny-only policy maps to no tool keys.\n * `readonly` is likewise dropped — Amazon Q has no read-only-agent field; the\n * permission model IS the allowedTools allow-list (no separate analog).\n * `extra` is shallow-merged last (per-platform escape hatch).\n */\n private renderSubagent(agent: SubagentDef): string {\n const obj: Record<string, unknown> = {\n name: agent.name,\n description: agent.description,\n prompt: agent.prompt,\n };\n if (agent.model !== undefined && agent.model !== \"inherit\") obj.model = agent.model;\n\n const allow = agent.tools?.allow;\n if (allow && allow.length > 0) {\n obj.tools = [...allow];\n // allowedTools rejects the \"*\" wildcard — only emit it for concrete patterns.\n const allowed = allow.filter((t) => t !== \"*\");\n if (allowed.length > 0) obj.allowedTools = allowed;\n }\n if (agent.extra) Object.assign(obj, agent.extra);\n\n // Match writeJson's serialization (2-space indent + trailing newline) so the\n // bytes are stable for writeContentFile's idempotent skip.\n return `${JSON.stringify(obj, null, 2)}\\n`;\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const agentPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp.json present`,\n check: () =>\n existsSync(mcpPath)\n ? { status: \"OK\", detail: mcpPath }\n : { status: \"FAIL\", detail: `not found: ${mcpPath}` },\n },\n {\n name: `${this.name}: server entry registered`,\n check: () => {\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<{ [k: string]: Record<string, unknown> }>(mcpPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return { status: \"FAIL\", detail: `no ${MCP_ROOT_KEY} in ${mcpPath}` };\n }\n return connectorId in bucket\n ? { status: \"OK\", detail: `${MCP_ROOT_KEY}.${connectorId} present` }\n : {\n status: \"FAIL\",\n detail: `no ${MCP_ROOT_KEY}.${connectorId} in ${mcpPath}`,\n };\n },\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 agent = this.readJson<AmazonQAgentFile>(agentPath);\n if (!agent) return { status: \"FAIL\", detail: `cannot read ${agentPath}` };\n const hooks = agent.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) => isHomeBinHookCommand(e.command, homeBin, connectorId)),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${agentPath}` };\n },\n },\n ];\n\n // Content-surface checks: assert each declared subagent's JSON file exists.\n // Skip the reserved collision name (never written by installSubagents).\n for (const agent of ctx.connector.subagents) {\n if (agent.name === RESERVED_AGENT_NAME) continue;\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse Amazon Q stdin JSON → normalized event ─────────────────\n // Amazon Q's stdin payload shape and exit-code contract are IDENTICAL to kiro's\n // (both AWS hosts in the same hook family); this parse + the formatReply context\n // channel below follow Amazon Q's own primary-verified schema (docs/hooks.md):\n // exit-code reply + PLAIN STDOUT context, gated to agentSpawn / userPromptSubmit.\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as AmazonQWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n // Host gap: Amazon Q never serializes a session id onto hook stdin — the only\n // always-present fields are hook_event_name + cwd (hooks.rs:300-304). sessionId\n // stays \"\" rather than reading a non-existent input.session_id.\n // Ref: aws/amazon-q-developer-cli crates/chat-cli/src/cli/chat/cli/hooks.rs:300-321\n const sessionId = \"\";\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 // Host gap: agentSpawn stdin is exactly {hook_event_name, cwd} — Amazon Q\n // serializes no start-reason discriminator (the Rust hook::Source enum is\n // config-grouping, never written to the payload), so resume/compact/clear\n // are indistinguishable. Default to \"startup\" rather than reading a\n // non-existent input.source.\n // Ref: aws/amazon-q-developer-cli crates/chat-cli/src/cli/chat/cli/hooks.rs:300-304\n // + docs/hooks.md:14-17 (agentSpawn input example)\n const ev: SessionStartEvent = {\n ...base,\n source: \"startup\",\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"Stop\": {\n // Host gap: stop stdin is exactly {hook_event_name, cwd} — Amazon Q never\n // serializes a stop_hook_active boolean, so the field is omitted (never set\n // from a non-existent input.stop_hook_active).\n // Ref: aws/amazon-q-developer-cli crates/chat-cli/src/cli/chat/cli/hooks.rs:300-321\n // + docs/hooks.md:106-107 (stop input example)\n const ev: StopEvent = {\n ...base,\n };\n return ev;\n }\n default: {\n // Amazon Q never delivers PreCompact / SessionEnd / Notification nor the\n // E1 extension events (no native triggers). If the runtime dispatches one\n // anyway, surface it loudly rather than silently mis-parse.\n throw new Error(`unsupported amazon-q hook event: ${String(event)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Amazon Q native (exit-code) hook reply ──\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n // deny → block the action: exit 2 with the reason on stderr.\n if (decision === \"deny\") {\n return { exitCode: 2, stderr: response.reason ?? \"Blocked by hook\" };\n }\n\n // ask → Amazon Q has no native \"ask\"; degrade to deny (exit 2) to stay fail-safe.\n if (decision === \"ask\") {\n return {\n exitCode: 2,\n stderr: response.reason ?? \"Action requires user confirmation (security policy)\",\n };\n }\n\n // Stop → exit-code only (deny already handled above). No context channel on a\n // Stop hook, so anything non-deny passes through with exit 0.\n if (event === \"Stop\") {\n return { exitCode: 0 };\n }\n\n // context → inject soft guidance. Amazon Q adds a hook's PLAIN STDOUT to the\n // agent's context (NO JSON envelope), but ONLY for agentSpawn and\n // userPromptSubmit; preToolUse / postToolUse / stop have no context channel\n // (their STDOUT is \"captured but not shown\"). So emit the raw text on stdout\n // only when the FIRING event maps to a context-supporting Amazon Q trigger;\n // otherwise the context decision degrades to a plain exit-0 pass-through rather\n // than a mislabeled/ineffective payload. exit 0 = allow.\n // Ref: aws/amazon-q-developer-cli docs/hooks.md\n const trigger = EVENT_MAP[event as HookEventName];\n if (\n decision === \"context\" &&\n response.additionalContext &&\n trigger !== undefined &&\n CONTEXT_TRIGGERS.has(trigger)\n ) {\n return { exitCode: 0, stdout: response.additionalContext };\n }\n\n // modify is unsupported (exit-code protocol — cannot rewrite args/output);\n // allow / void → pass through with exit 0.\n return { exitCode: 0 };\n }\n}\n\n/** Coerce an Amazon Q 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\nexport const adapter = new AmazonQAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;AA6GA,SAAS,YAAY,gBAAgB;AACrC,SAAS,eAAe;AACxB,SAAS,YAAY;AA4BrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAYrB,IAAM,qBAAqB;AAQ3B,IAAM,sBAAsB;AAM5B,IAAM,YAAY;AAAA,EAChB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,MAAM;AACR;AAOA,IAAM,YAAoD;AAAA,EACxD,cAAc,UAAU;AAAA,EACxB,kBAAkB,UAAU;AAAA,EAC5B,YAAY,UAAU;AAAA,EACtB,aAAa,UAAU;AAAA,EACvB,MAAM,UAAU;AAClB;AAGA,IAAM,mBAAwC,oBAAI,IAAI;AAAA,EACpD,UAAU;AAAA,EACV,UAAU;AACZ,CAAC;AAUD,IAAM,mBAAwC,oBAAI,IAAI;AAAA,EACpD,UAAU;AAAA,EACV,UAAU;AACZ,CAAC;AAgEM,IAAM,iBAAN,cAA6B,YAA+B;AAAA,EACxD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO5C,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,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SAAS,qBACT,YAAY,UACZ,iBAAiB,IAAI,OAAO,GAC5B;AACA,aAAO,EAAE,UAAU,GAAG,QAAQ,SAAS,kBAAkB;AAAA,IAC3D;AAIA,WAAO,EAAE,UAAU,EAAE;AAAA,EACvB;AACF;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;AAEO,IAAM,UAAU,IAAI,eAAe;AAC1C,IAAO,mBAAQ;","names":[]}
@@ -8,24 +8,17 @@ import {
8
8
  import {
9
9
  BaseAdapter,
10
10
  renderSkillMd
11
- } from "./chunk-A767JFHW.js";
11
+ } from "./chunk-RHML2NOB.js";
12
12
  import {
13
13
  buildWrappedStdio
14
14
  } from "./chunk-TO57WYBB.js";
15
- import "./chunk-ZY25RG4Y.js";
16
- import "./chunk-QY42WGBX.js";
15
+ import "./chunk-ALVXORZM.js";
16
+ import "./chunk-2HCJV6UO.js";
17
17
 
18
18
  // src/adapters/amp/index.ts
19
- import {
20
- chmodSync,
21
- existsSync,
22
- mkdirSync,
23
- readFileSync,
24
- rmSync,
25
- writeFileSync
26
- } from "fs";
19
+ import { existsSync } from "fs";
27
20
  import { homedir } from "os";
28
- import { dirname, join } from "path";
21
+ import { join } from "path";
29
22
  var HOST = "amp";
30
23
  var MCP_ROOT_KEY = "amp.mcpServers";
31
24
  var EVENT_TO_AMP = {
@@ -292,45 +285,22 @@ var AmpAdapter = class extends BaseAdapter {
292
285
  const files = this.synthesizePlugin(ctx);
293
286
  const changes = [];
294
287
  for (const file of files) {
295
- const before = existsSync(file.path) ? this.safeRead(file.path) : void 0;
296
- let action;
297
- if (before === void 0) action = "create";
298
- else if (before === file.contents) action = "skip";
299
- else action = "update";
300
- if (action !== "skip" && !ctx.dryRun) {
301
- ensureDir(dirname(file.path));
302
- writeFileSync(file.path, file.contents, "utf8");
303
- chmodSync(file.path, file.executable ? 493 : 420);
304
- }
305
- changes.push({
306
- platform: this.id,
307
- action,
308
- path: file.path,
309
- detail: `amp plugin module (${this.hookDetail(ctx)})`
310
- });
288
+ changes.push(
289
+ this.writeManagedFile(
290
+ file.path,
291
+ file.contents,
292
+ ctx.dryRun,
293
+ `amp plugin module (${this.hookDetail(ctx)})`,
294
+ file.executable
295
+ )
296
+ );
311
297
  }
312
298
  return changes;
313
299
  }
314
300
  uninstallHooks(ctx) {
315
301
  const pluginPath = this.getHookConfigPath(ctx);
316
- if (!existsSync(pluginPath)) {
317
- return [
318
- {
319
- platform: this.id,
320
- action: "skip",
321
- path: pluginPath,
322
- detail: "no amp plugin module present"
323
- }
324
- ];
325
- }
326
- if (!ctx.dryRun) rmSync(pluginPath, { force: true });
327
302
  return [
328
- {
329
- platform: this.id,
330
- action: "remove",
331
- path: pluginPath,
332
- detail: "amp plugin module"
333
- }
303
+ this.removeManagedFile(pluginPath, ctx.dryRun, "amp plugin module", "no amp plugin module present")
334
304
  ];
335
305
  }
336
306
  /**
@@ -419,11 +389,13 @@ let SESSION_ID = "";
419
389
  }
420
390
  if (has("UserPromptSubmit")) {
421
391
  handlers.push(` // UserPromptSubmit \u2192 agent.start "fires when the user submits a prompt"
422
- // (ampcode.com/manual). The manual's example takes (_event) and documents no
423
- // prompt field or return surface, so this is observe-only \u2014 the raw event is
424
- // forwarded for the connector to inspect; any deny/context decision is a no-op.
392
+ // (ampcode.com/manual). The host DOES carry the prompt: AgentStartEvent.message
393
+ // is "The user's prompt message" (@ampcode/plugin index.d.ts:1011-1012), so we
394
+ // PROJECT event.message into the bridge payload's prompt key (the prior version
395
+ // dropped it). Observe-only return surface \u2014 any deny/context decision is a no-op.
425
396
  amp.on("agent.start", async (event) => {
426
397
  bridge("UserPromptSubmit", {
398
+ prompt: (event && typeof event.message === "string" && event.message) || "",
427
399
  sessionId: SESSION_ID,
428
400
  projectDir: PROJECT_DIR,
429
401
  raw: event,
@@ -458,13 +430,16 @@ let SESSION_ID = "";
458
430
  if (has("PostToolUse")) {
459
431
  handlers.push(` // PostToolUse \u2192 tool.result "fires after a tool finishes and before the result
460
432
  // is sent back to the model" (ampcode.com/manual). The tool name is event.tool
461
- // and the error signal is event.status === "error" (both verified). The manual
462
- // says a replacement status/output CAN be returned but never documents the
463
- // replacement object shape, so this is observe-only (canModifyOutput:false) \u2014
464
- // the raw event is forwarded; we never return a guessed replacement.
433
+ // and the error signal is event.status === "error" (both verified). The host DOES
434
+ // carry the output: ToolResultEvent extends ToolResult.output (typed unknown \u2014
435
+ // "Tool output/result if available", @ampcode/plugin index.d.ts:946-947,976), so
436
+ // we PROJECT event.output into the bridge payload's toolOutput (prior version
437
+ // dropped it). Replacement still observe-only (canModifyOutput:false) \u2014 the
438
+ // replacement OBJECT shape is undocumented, so we never return a guessed mutation.
465
439
  amp.on("tool.result", async (event) => {
466
440
  bridge("PostToolUse", {
467
441
  toolName: (event && event.tool) || "",
442
+ toolOutput: event && event.output,
468
443
  isError: !!(event && event.status === "error"),
469
444
  sessionId: SESSION_ID,
470
445
  projectDir: PROJECT_DIR,
@@ -518,11 +493,12 @@ ${handlers.join("\n\n")}
518
493
  return ev;
519
494
  }
520
495
  case "PostToolUse": {
496
+ const out = coerceToolOutput(input.toolOutput);
521
497
  const ev = {
522
498
  ...base,
523
499
  toolName: input.toolName ?? "",
524
500
  toolInput: input.toolInput ?? {},
525
- ...typeof input.toolOutput === "string" ? { toolOutput: input.toolOutput } : {},
501
+ ...out !== void 0 ? { toolOutput: out } : {},
526
502
  ...typeof input.isError === "boolean" ? { isError: input.isError } : {}
527
503
  };
528
504
  return ev;
@@ -604,16 +580,15 @@ ${handlers.join("\n\n")}
604
580
  ];
605
581
  }
606
582
  /** Read a file, returning undefined on any error (idempotency compare). */
607
- safeRead(path) {
608
- try {
609
- return readFileSync(path, "utf8");
610
- } catch {
611
- return void 0;
612
- }
613
- }
614
583
  };
615
- function ensureDir(dir) {
616
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
584
+ function coerceToolOutput(value) {
585
+ if (typeof value === "string") return value;
586
+ if (value === void 0 || value === null) return void 0;
587
+ try {
588
+ return JSON.stringify(value);
589
+ } catch {
590
+ return String(value);
591
+ }
617
592
  }
618
593
  function ampEnvToken(name, def) {
619
594
  if (def !== void 0) {
@@ -629,4 +604,4 @@ export {
629
604
  adapter,
630
605
  amp_default as default
631
606
  };
632
- //# sourceMappingURL=amp-5DJK7VAL.js.map
607
+ //# sourceMappingURL=amp-WAPHJYTK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/amp/index.ts"],"sourcesContent":["/**\n * adapters/amp — Amp (Sourcegraph / AmpCode) platform adapter for agent-connector.\n *\n * Amp is a **ts-plugin** host: alongside MCP it loads TypeScript plugin modules\n * from `.amp/plugins/<name>.ts`, each default-exporting a function `(amp) => void`\n * that registers lifecycle handlers via `amp.on(\"<event>\", async (event, ctx) =>\n * …)` (ampcode.com/manual → Plugins). This adapter wires the five amp.on events\n * that have a canonical analog and bridges them to the universal home-bin\n * entrypoint, exactly like the OMP / OpenCode ts-plugin adapters.\n *\n * Event mapping (only events the connector declares are subscribed):\n * SessionStart → amp.on(\"session.start\", …) (thread begins; id = event.thread.id)\n * UserPromptSubmit → amp.on(\"agent.start\", …) (user submits a prompt; observe-only)\n * PreToolUse → amp.on(\"tool.call\", …) (before a tool runs; deny → return\n * { action: \"reject-and-continue\" }, else { action: \"allow\" })\n * PostToolUse → amp.on(\"tool.result\", …) (after a tool finishes; observe-only)\n * Stop → amp.on(\"agent.end\", …) (turn ends; observe-only)\n * Amp documents NO session.end event, so SessionEnd is an honest gap (warn-skip\n * via the unsupported-here detail). tool.call's decision surface is the\n * { action } union (canModifyArgs:false — the \"modify\" input shape is not\n * documented); tool.result CAN return a replacement but the manual never\n * documents its object shape, so PostToolUse is observe-only (canModifyOutput:\n * false) rather than ship a guessed mutation; session.start has no documented\n * context-injection surface (canInjectSessionContext:false).\n *\n * Why we SYNTHESIZE a self-contained module instead of importing handlers:\n * the connector's hook handlers are arbitrary developer code we must not import\n * into Amp's (Bun) runtime — wrong cwd, wrong deps, version skew. So, like the\n * OMP / OpenCode adapters, we generate a tiny ESM/TS plugin that imports NOTHING\n * from agent-connector: each `amp.on(...)` handler shells out to the ONE stable\n * home binary's universal entrypoint (`<homeBin> hook amp <event> --connector\n * <id>`) over child_process, feeds it the amp-shaped payload as JSON on stdin,\n * and JSON.parses the normalized HookResponse back from stdout. Fail-open: any\n * bridge error → no-op. One entrypoint, every paradigm.\n *\n * Plugin scope: the `.amp/plugins/` dir is documented at PROJECT scope only; Amp\n * documents no user-scope plugins dir, so installHooks writes the plugin for\n * project scope and warn-skips user scope (the MCP + skills surfaces keep their\n * own user-scope paths). MCP config (report §2 / §5.3):\n * - user scope → ~/.config/amp/settings.json\n * - project scope → <projectDir>/.amp/settings.json\n * Both are JSONC (we write plain JSON, which is valid JSONC). The settings file\n * is SHARED with the rest of Amp's configuration, so we MERGE our entry into\n * the existing object and never clobber unrelated keys.\n *\n * QUIRK 1 — dotted top-level key: Amp does NOT use a nested `mcpServers` object.\n * The MCP registry is a single FLAT settings key literally named\n * `\"amp.mcpServers\"`, whose value is an object of `{ id: { command, args, env } }`.\n * We therefore set `settings[\"amp.mcpServers\"][connectorId] = entry`. Because the\n * base JSON helpers index `config[rootKey][serverId]`, passing the dotted string\n * as the root key writes exactly that flat key while preserving every sibling\n * setting (true merge).\n *\n * QUIRK 2 — native interpolation: Amp expands `${VAR_NAME}` in stdio entries at\n * runtime, so we KEEP env/header/url refs native by rewriting the portable\n * `${env:VAR}` syntax to Amp's `${VAR}` token rather than resolving to literals\n * (secrets stay out of the settings file).\n *\n * Skills surface: Amp reads SKILL.md files (dir-per-skill, same shape as\n * claude-code) from a skill root that is NOT under the config dir\n * (`~/.config/amp`):\n * - user scope → ~/.config/agents/skills/<name>/SKILL.md (the sibling\n * cross-agent `agents` dir — `~/.config/amp/skills/` is also documented-native,\n * but the `agents` root is the cross-agent standard we standardize on)\n * - project scope → <projectDir>/.agents/skills/<name>/SKILL.md\n * Because that root differs from getConfigDir, skills use a dedicated skillDir()\n * helper rather than reusing getConfigDir.\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 {\n Adapter,\n GeneratedPluginFile,\n HookReply,\n InstallContext,\n NormalizedEvent,\n} from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n SkillDef,\n StopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { rewriteEnvRefs } from \"../../core/interpolate.js\";\nimport { renderBridgePrelude } from \"../../core/ts-plugin-bridge.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"amp\";\n/**\n * QUIRK: a single FLAT, dotted settings key — NOT a nested object. The base\n * JSON helpers treat this as `config[\"amp.mcpServers\"][serverId]`.\n */\nconst MCP_ROOT_KEY = \"amp.mcpServers\";\n\n/**\n * Canonical → Amp plugin event name map. A connector hook event is only\n * subscribed by the generated plugin when it appears here AND is declared by the\n * connector. Names verified against ampcode.com/manual (Plugins → amp.on events).\n * Amp documents NO `session.end`, so SessionEnd has no entry (honest gap).\n */\nconst EVENT_TO_AMP: Partial<Record<HookEventName, string>> = {\n SessionStart: \"session.start\",\n UserPromptSubmit: \"agent.start\",\n PreToolUse: \"tool.call\",\n PostToolUse: \"tool.result\",\n Stop: \"agent.end\",\n};\n\n/** Raw payload the generated plugin posts to the universal hook entrypoint. */\ninterface AmpBridgePayload {\n toolName?: string;\n toolInput?: Record<string, unknown>;\n // ToolResultEvent.output is typed `unknown` by the host (@ampcode/plugin\n // index.d.ts:947 — \"Tool output/result if available\"), so the bridge may\n // forward a string OR a structured value; parseEvent stringifies non-strings.\n toolOutput?: unknown;\n isError?: boolean;\n prompt?: string;\n sessionId?: string;\n projectDir?: string;\n}\n\n/** Native MCP server entry shapes Amp accepts under `amp.mcpServers`. */\ninterface AmpStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\ninterface AmpHttpServer {\n url: string;\n headers?: Record<string, string>;\n}\n\nexport class AmpAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Amp\";\n readonly paradigm: HookParadigm = \"ts-plugin\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block via the BaseAdapter default\n // (memoryTargets: project <projectDir>/AGENTS.md; user scope where documented).\n supportsMemory: true,\n // amp.on lifecycle events with a canonical analog (EVENT_TO_AMP):\n // tool.call / tool.result / session.start / agent.start / agent.end.\n preToolUse: true,\n postToolUse: true,\n // Amp has no documented compaction hook.\n preCompact: false,\n sessionStart: true,\n // Amp documents NO session.end event — SessionEnd is an honest gap.\n sessionEnd: false,\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // Newer events: Amp documents no permission/approval, post-tool-failure, or\n // subagent lifecycle hook with a canonical analog, so permissionRequest /\n // postToolUseFailure / subagentStart / subagentStop stay unset — the\n // generated bridge never references them and install reports them as\n // \"unsupported here\".\n // tool.call's documented decision surface is { action: \"allow\" |\n // \"reject-and-continue\" | \"modify\" | \"synthesize\" } (ampcode.com/manual →\n // Plugins → tool.call). We wire allow + reject-and-continue (block); the\n // \"modify\" input-rewrite shape is not byte-documented, so canModifyArgs:false.\n canModifyArgs: false,\n // tool.result says \"return a replacement status/output\" but the manual never\n // documents the replacement OBJECT SHAPE (which keys). Rather than guess it,\n // PostToolUse is observe-only and canModifyOutput stays false until the shape\n // is primary-source-verified (honesty bar: under-claim, never emit a guessed\n // mutation contract).\n canModifyOutput: false,\n // session.start has no documented context-injection surface.\n canInjectSessionContext: false,\n // Amp registers stdio and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"http\"],\n // Skills: Amp reads SKILL.md from ~/.config/agents/skills/<name>/SKILL.md\n // (user) and <projectDir>/.agents/skills/<name>/SKILL.md (project) — a root\n // OUTSIDE the config dir, so the skillDir() helper resolves it explicitly.\n supportsSkills: true,\n // Native passthrough hooks: amp.on events with no canonical HookEventName\n // analog are reachable via platforms[\"amp\"].nativeHooks; the generated plugin\n // registers + bridges each declared native event verbatim and the home-bin\n // runtime dispatches it host-generically via runNativeHook.\n supportsNativeHooks: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".config\", \"amp\");\n const userSettings = join(userDir, \"settings.json\");\n const projectDirAmp = join(projectDir, \".amp\");\n const projectSettings = join(projectDirAmp, \"settings.json\");\n\n const userInstalled = existsSync(userDir) || existsSync(userSettings);\n const projectInstalled = existsSync(projectDirAmp) || existsSync(projectSettings);\n const installed = userInstalled || projectInstalled;\n const scope = projectInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectSettings : userSettings;\n\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 ? `found Amp config (${scope}) at ${configPath}`\n : `no Amp config at ${userSettings} or ${projectSettings}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".amp\")\n : join(homedir(), \".config\", \"amp\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"settings.json\");\n }\n\n /**\n * For this ts-plugin host the \"hook config path\" is the generated plugin\n * MODULE. Amp loads every `.ts` file in `.amp/plugins/`, so writing this file\n * IS the registration. The `.amp/plugins/` dir is documented at PROJECT scope\n * (Amp documents no user-scope plugins dir — see pluginsDir); the user-scope\n * path is returned for doctor/uninstall symmetry but installHooks warn-skips it.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.pluginsDir(ctx), `${ctx.connector.id}.ts`);\n }\n\n /**\n * Plugin directory Amp auto-loads `.ts` modules from. PROJECT scope is the\n * documented `<projectDir>/.amp/plugins`; user scope mirrors the MCP config dir\n * (`~/.config/amp/plugins`) for path symmetry only — installHooks never writes\n * there because Amp documents no user-scope plugins dir.\n */\n private pluginsDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".amp\", \"plugins\")\n : join(this.getConfigDir(ctx), \"plugins\");\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 amp\"\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 // Upsert into the flat \"amp.mcpServers\" key, merging into existing settings.\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Amp's native `amp.mcpServers` entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): AmpStdioServer | AmpHttpServer {\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 ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Amp expands ${VAR_NAME} natively, so keep refs native (no literals).\n const entry: AmpStdioServer = { command: this.rewrite(command) };\n if (args.length > 0) entry.args = args.map((a) => this.rewrite(a));\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // http (and any other remote transport we surface) — Amp registers a URL.\n const entry: AmpHttpServer = { url: this.rewrite(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. Amp supports native `${VAR_NAME}` interpolation,\n * so translate `${env:VAR}` refs to that native token rather than baking\n * secrets into the file. Literals pass through unchanged.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(env)) out[k] = this.rewrite(v);\n return out;\n }\n\n /** Translate `${env:VAR(:-default)}` to Amp's native `${VAR}` token. */\n private rewrite(value: string): string {\n return rewriteEnvRefs(value, ampEnvToken);\n }\n\n // ── Skills surface ───────────────────────────────────────────────────────\n // CONTENT-ONLY: pure native-file writers under the skill root. No runtime\n // dispatch, no home-bin pointer, no telemetry wrap. Idempotent (byte-identical\n // → skip) via writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"amp\"].skills === false to skip.\n //\n // QUIRK: the skill root is NOT under getConfigDir (~/.config/amp). Amp reads\n // SKILL.md from the sibling cross-agent `agents` tree:\n // user scope → ~/.config/agents/skills/<name>/SKILL.md\n // project scope → <projectDir>/.agents/skills/<name>/SKILL.md\n // so skillDir() resolves it explicitly rather than reusing getConfigDir.\n\n /** Skill root: user `~/.config/agents/skills`, project `<projectDir>/.agents/skills`. */\n private skillsDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".agents\", \"skills\")\n : join(homedir(), \".config\", \"agents\", \"skills\");\n }\n\n /** Native skill dir: <skillRoot>/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\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 amp\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /** Render a skill's SKILL.md (delegates to the shared renderer). */\n private renderSkill(skill: SkillDef): string {\n return renderSkillMd(skill);\n }\n\n // ── Hook install / uninstall (ts-plugin module) ──────────────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const pluginPath = this.getHookConfigPath(ctx);\n\n // Amp documents no user-scope plugins dir — only `.amp/plugins/` at project\n // scope. Degradation is never silent: warn-skip rather than write to an\n // unverified user path.\n if (ctx.scope !== \"project\") {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: pluginPath,\n detail:\n \"amp plugins are project-scoped (.amp/plugins/) — no user-scope plugins dir is documented; skipped\",\n },\n ];\n }\n\n // Native passthrough events are a sibling, amp-scoped declaration: `hooks:\n // false` disables only the CANONICAL events, and the generated native loop\n // reads platforms.amp.nativeHooks directly (independent of hookEvents). So\n // whenever native events exist the plugin must still be synthesized.\n const canonicalDisabled = ctx.connector.platforms[HOST]?.hooks === false;\n const hasCanonical = !canonicalDisabled && ctx.connector.hookEvents.length > 0;\n const hasNative = this.nativeHookEvents(ctx).length > 0;\n\n if (!hasCanonical && !hasNative) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: pluginPath,\n detail: canonicalDisabled\n ? \"hooks disabled for amp\"\n : \"connector declares no hooks\",\n },\n ];\n }\n\n const files = this.synthesizePlugin(ctx);\n const changes: ChangeRecord[] = [];\n\n for (const file of files) {\n changes.push(\n this.writeManagedFile(\n file.path,\n file.contents,\n ctx.dryRun,\n `amp plugin module (${this.hookDetail(ctx)})`,\n file.executable,\n ),\n );\n }\n\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const pluginPath = this.getHookConfigPath(ctx);\n return [\n this.removeManagedFile(pluginPath, ctx.dryRun, \"amp plugin module\", \"no amp plugin module present\"),\n ];\n }\n\n /**\n * Human-facing summary of which declared events the synthesized module ACTUALLY\n * wires. Only events present in EVENT_TO_AMP are mapped/wired; any declared\n * event with no Amp mapping (e.g. SessionEnd) is reported separately as\n * \"unsupported here\" so the detail never overstates coverage.\n */\n private hookDetail(ctx: InstallContext): string {\n // `hooks: false` suppresses the canonical handlers, so the detail must not\n // claim them; native events are still reported below.\n const canonicalOff = ctx.connector.platforms[HOST]?.hooks === false;\n const declared = canonicalOff ? [] : ctx.connector.hookEvents;\n const mapped = declared.filter((e) => EVENT_TO_AMP[e] !== undefined);\n const unsupported = declared.filter((e) => EVENT_TO_AMP[e] === undefined);\n const native = this.nativeHookEvents(ctx);\n const parts: string[] = [];\n if (mapped.length > 0) parts.push(mapped.join(\",\"));\n if (native.length > 0) parts.push(`native: ${native.join(\",\")}`);\n const base = parts.join(\"; \") || \"no canonical hooks\";\n return unsupported.length > 0\n ? `${base}; unsupported here: ${unsupported.join(\",\")}`\n : base;\n }\n\n /**\n * Amp-native passthrough events declared on platforms[\"amp\"].nativeHooks\n * (amp.on event names with no canonical HookEventName analog). Emitted as\n * generic bridge registrations and dispatched host-generically by the home-bin's\n * runNativeHook.\n */\n private nativeHookEvents(ctx: InstallContext): string[] {\n return Object.keys(ctx.connector.platforms[HOST]?.nativeHooks ?? {});\n }\n\n // ── ts-plugin synthesis ──────────────────────────────────────────────────\n\n /**\n * Build ONE self-contained Amp plugin module (`.amp/plugins/<id>.ts`). It\n * imports nothing from agent-connector; each `amp.on(...)` handler shells out to\n * the universal hook entrypoint via child_process and applies the normalized\n * HookResponse. Its default export is the Amp plugin function `(amp) => void`.\n */\n synthesizePlugin(ctx: InstallContext): GeneratedPluginFile[] {\n const path = this.getHookConfigPath(ctx);\n const contents = this.buildPluginSource(ctx);\n return [{ path, contents, executable: false }];\n }\n\n /** Compose the generated plugin source with plain string concatenation. */\n private buildPluginSource(ctx: InstallContext): string {\n // `platforms.amp.hooks === false` disables only the CANONICAL events (the\n // native loop below reads platforms.amp.nativeHooks directly and is a sibling,\n // unaffected). When canonical hooks are off the module may still be\n // synthesized for native events, so the canonical handler set collapses to\n // empty here rather than short-circuiting the whole plugin.\n const canonicalOff = ctx.connector.platforms[HOST]?.hooks === false;\n const events = canonicalOff\n ? []\n : ctx.connector.hookEvents.filter(\n (e): e is HookEventName => EVENT_TO_AMP[e] !== undefined,\n );\n const has = (e: HookEventName) => events.includes(e);\n\n const header = `/**\n * AUTO-GENERATED by agent-connector — DO NOT EDIT.\n *\n * Self-contained Amp plugin for connector ${ctx.connector.id}.\n * It imports nothing from agent-connector: every hook invocation shells out to\n * the stable home binary's universal entrypoint and JSON-parses the normalized\n * response. Fail-open: any bridge error degrades to a no-op (never wedges Amp).\n *\n * Amp loads this module from .amp/plugins/${ctx.connector.id}.ts; the default\n * export is the plugin function (amp) => void called once with the PluginAPI.\n */\nimport type { PluginAPI } from \"@ampcode/plugin\";\nimport { execFileSync, execSync } from \"node:child_process\";\n\n${renderBridgePrelude({\n homeBin: ctx.homeBinPath,\n connectorId: ctx.connector.id,\n hookSlug: \"amp\",\n payloadNoun: \"amp\",\n failOpenComment: \"Fail-open — never wedge an Amp tool call / lifecycle event.\",\n})}\n\n// Amp documents no project-dir env var; the plugin process runs in the workspace\n// root, so resolve once at load. Session id is rebound on each session.start.\nconst PROJECT_DIR = process.cwd();\nlet SESSION_ID = \"\";\n`;\n\n const handlers: string[] = [];\n\n if (has(\"SessionStart\")) {\n handlers.push(` // SessionStart → rebind the session id and notify the connector.\n // Amp's session.start event carries event.thread.id (ampcode.com/manual →\n // Plugins → session.start: \"Example session.start for \\${event.thread.id}\").\n amp.on(\"session.start\", async (event) => {\n SESSION_ID =\n (event && event.thread && event.thread.id) || \"amp-session\";\n bridge(\"SessionStart\", { sessionId: SESSION_ID, projectDir: PROJECT_DIR });\n });`);\n }\n\n if (has(\"UserPromptSubmit\")) {\n handlers.push(` // UserPromptSubmit → agent.start \"fires when the user submits a prompt\"\n // (ampcode.com/manual). The host DOES carry the prompt: AgentStartEvent.message\n // is \"The user's prompt message\" (@ampcode/plugin index.d.ts:1011-1012), so we\n // PROJECT event.message into the bridge payload's prompt key (the prior version\n // dropped it). Observe-only return surface — any deny/context decision is a no-op.\n amp.on(\"agent.start\", async (event) => {\n bridge(\"UserPromptSubmit\", {\n prompt: (event && typeof event.message === \"string\" && event.message) || \"\",\n sessionId: SESSION_ID,\n projectDir: PROJECT_DIR,\n raw: event,\n });\n });`);\n }\n\n if (has(\"PreToolUse\")) {\n handlers.push(` // PreToolUse → Amp's tool.call returns a decision union (ampcode.com/manual →\n // Plugins → tool.call): { action: \"allow\" } to run, or { action:\n // \"reject-and-continue\", message } to block and let the agent continue. The\n // tool name is event.tool (verified); the input field is not byte-documented,\n // so event.input is a best-effort hint for the connector's matcher (the matcher\n // keys on the verified tool name). A deny/ask decision maps to reject-and-\n // continue; everything else allows.\n amp.on(\"tool.call\", async (event) => {\n const payload = {\n toolName: (event && event.tool) || \"\",\n toolInput: (event && event.input) || {},\n sessionId: SESSION_ID,\n projectDir: PROJECT_DIR,\n };\n const res = bridge(\"PreToolUse\", payload);\n if (res && (res.decision === \"deny\" || res.decision === \"ask\")) {\n return {\n action: \"reject-and-continue\",\n message: res.reason || \"Blocked by ${ctx.connector.id}\",\n };\n }\n return { action: \"allow\" };\n });`);\n }\n\n if (has(\"PostToolUse\")) {\n handlers.push(` // PostToolUse → tool.result \"fires after a tool finishes and before the result\n // is sent back to the model\" (ampcode.com/manual). The tool name is event.tool\n // and the error signal is event.status === \"error\" (both verified). The host DOES\n // carry the output: ToolResultEvent extends ToolResult.output (typed unknown —\n // \"Tool output/result if available\", @ampcode/plugin index.d.ts:946-947,976), so\n // we PROJECT event.output into the bridge payload's toolOutput (prior version\n // dropped it). Replacement still observe-only (canModifyOutput:false) — the\n // replacement OBJECT shape is undocumented, so we never return a guessed mutation.\n amp.on(\"tool.result\", async (event) => {\n bridge(\"PostToolUse\", {\n toolName: (event && event.tool) || \"\",\n toolOutput: event && event.output,\n isError: !!(event && event.status === \"error\"),\n sessionId: SESSION_ID,\n projectDir: PROJECT_DIR,\n raw: event,\n });\n });`);\n }\n\n if (has(\"Stop\")) {\n handlers.push(` // Stop → observe turn end. Amp's agent.end exposes no decision surface, so\n // this is observe-only (a deny decision degrades to a no-op).\n amp.on(\"agent.end\", async (event) => {\n bridge(\"Stop\", { sessionId: SESSION_ID, projectDir: PROJECT_DIR, raw: event });\n });`);\n }\n\n // NATIVE passthrough events: amp.on event names with no canonical analog,\n // declared on platforms.amp.nativeHooks (independent of hookEvents, so they\n // install even with hooks:false). Each bridges the NATIVE event name verbatim\n // to the home-bin → runNativeHook dispatches it host-generically.\n for (const ev of this.nativeHookEvents(ctx)) {\n const key = JSON.stringify(ev);\n handlers.push(` // nativeHooks passthrough → ${ev}\n amp.on(${key}, async (event) => {\n bridge(${key}, { sessionId: SESSION_ID, projectDir: PROJECT_DIR, raw: event });\n });`);\n }\n\n const factory = `\nexport default function plugin(amp: PluginAPI) {\n${handlers.join(\"\\n\\n\")}\n}\n`;\n\n return header + factory;\n }\n\n // ── Runtime: parse OUR bridge payload → normalized event ─────────────────\n\n /**\n * `raw` is the payload OUR generated plugin posts (NOT a host-native shape):\n * { toolName?, toolInput?, toolOutput?, isError?, prompt?, sessionId?, projectDir? }\n * so this maps straight through.\n */\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as AmpBridgePayload;\n const base = {\n hostPlatform: HOST,\n connectorId: \"\",\n sessionId: typeof input.sessionId === \"string\" ? input.sessionId : \"\",\n raw,\n ...(typeof input.projectDir === \"string\"\n ? { projectDir: input.projectDir }\n : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n // ToolResultEvent.output is typed `unknown` by the host (@ampcode/plugin\n // index.d.ts:947), so the bridge can forward a string OR a structured value.\n // Accept both: pass strings through, JSON-stringify other non-nullish\n // values (the old `typeof === \"string\"` guard silently dropped the latter).\n const out = coerceToolOutput(input.toolOutput);\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n ...(out !== undefined ? { toolOutput: out } : {}),\n ...(typeof input.isError === \"boolean\"\n ? { isError: input.isError }\n : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = { ...base };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = { ...base, source: \"startup\" };\n return ev;\n }\n default:\n // Other canonical events are not surfaced by Amp; treat as a\n // session-start-shaped no-op so the dispatcher fails open gracefully.\n return { ...base, source: \"startup\" } satisfies SessionStartEvent;\n }\n }\n\n // ── Runtime: normalized response → reply the generated bridge parses ─────\n\n /**\n * Unlike json-stdio hosts (whose reply is the host's NATIVE control payload),\n * OUR generated bridge consumes this stdout directly. So the reply body is the\n * NORMALIZED HookResponse itself — the bridge JSON.parses it and, for tool.call,\n * maps a deny/ask decision → { action: \"reject-and-continue\" } (else allow).\n * Other events are observe-only, so their reply is ignored by the handler.\n */\n formatReply(_event: HookEventName, response: HookResponse): HookReply {\n return {\n exitCode: 0,\n stdout: JSON.stringify(response ?? { decision: \"allow\" }),\n };\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const settingsPath = this.getServerConfigPath(ctx);\n const connectorId = ctx.connector.id;\n return [\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}: server entry registered`,\n check: () => {\n // Only assert what the connector declares: a server-less connector\n // never writes a server entry, so its absence is healthy.\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<{ [k: string]: Record<string, unknown> }>(settingsPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return { status: \"FAIL\", detail: `no \"${MCP_ROOT_KEY}\" in ${settingsPath}` };\n }\n return connectorId in bucket\n ? { status: \"OK\", detail: `\"${MCP_ROOT_KEY}\".${connectorId} present` }\n : {\n status: \"FAIL\",\n detail: `no \"${MCP_ROOT_KEY}\".${connectorId} in ${settingsPath}`,\n };\n },\n },\n {\n name: `${this.name}: plugin module present`,\n check: () => {\n const hasHooks =\n ctx.connector.hookEvents.length > 0 ||\n this.nativeHookEvents(ctx).length > 0;\n if (!hasHooks) return { status: \"OK\", detail: \"no hooks declared\" };\n // Amp plugins are project-scoped; a user-scope install warn-skips the\n // plugin, so its absence there is healthy.\n if (ctx.scope !== \"project\") {\n return {\n status: \"OK\",\n detail: \"amp plugins are project-scoped (user scope skipped)\",\n };\n }\n const pluginPath = this.getHookConfigPath(ctx);\n return existsSync(pluginPath)\n ? { status: \"OK\", detail: pluginPath }\n : { status: \"FAIL\", detail: `not found: ${pluginPath}` };\n },\n },\n ];\n }\n\n /** Read a file, returning undefined on any error (idempotency compare). */\n}\n\n/**\n * Coerce Amp's `ToolResultEvent.output` (typed `unknown` upstream) into the\n * normalized event's `toolOutput: string`. Strings pass through; other\n * non-nullish values (objects / arrays / numbers) are JSON-stringified so a\n * structured tool result is no longer silently dropped. `undefined`/`null`\n * yields `undefined` (the key is omitted by the caller).\n */\nfunction coerceToolOutput(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (value === undefined || value === null) return undefined;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Amp native interpolation token: `${env:VAR}` → `${VAR}`.\n *\n * When the portable ref carried a default (`${env:VAR:-fallback}`), Amp's native\n * `${VAR}` token has no way to express it — so a bare native token would silently\n * DROP the default. Instead, resolve the default at install time: emit the live\n * value when VAR is set and non-empty, else the literal fallback. The native\n * token is only emitted when there is no default to preserve.\n */\nfunction ampEnvToken(name: string, def?: string): string {\n if (def !== undefined) {\n const v = process.env[name];\n return v != null && v !== \"\" ? v : def;\n }\n return `\\${${name}}`;\n}\n\nexport const adapter = new AmpAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqEA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAmCrB,IAAM,OAAmB;AAKzB,IAAM,eAAe;AAQrB,IAAM,eAAuD;AAAA,EAC3D,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,MAAM;AACR;AA2BO,IAAM,aAAN,cAAyB,YAA+B;AAAA,EACpD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA;AAAA,IAGhB,YAAY;AAAA,IACZ,aAAa;AAAA;AAAA,IAEb,YAAY;AAAA,IACZ,cAAc;AAAA;AAAA,IAEd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUd,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMf,iBAAiB;AAAA;AAAA,IAEjB,yBAAyB;AAAA;AAAA,IAEzB,YAAY,CAAC,SAAS,MAAM;AAAA;AAAA;AAAA;AAAA,IAI5B,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKhB,qBAAqB;AAAA,EACvB;AAAA;AAAA,EAIA,gBAAgB,YAAsC;AACpD,UAAM,UAAU,KAAK,QAAQ,GAAG,WAAW,KAAK;AAChD,UAAM,eAAe,KAAK,SAAS,eAAe;AAClD,UAAM,gBAAgB,KAAK,YAAY,MAAM;AAC7C,UAAM,kBAAkB,KAAK,eAAe,eAAe;AAE3D,UAAM,gBAAgB,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AU,IACxB,EAAE,QAAQ,MAAM,QAAQ,WAAW,IACnC,EAAE,QAAQ,QAAQ,QAAQ,cAAc,UAAU,GAAG;AAAA,QAC3D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAGF;AASA,SAAS,iBAAiB,OAAoC;AAC5D,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,MAAI;AACF,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;AAWA,SAAS,YAAY,MAAc,KAAsB;AACvD,MAAI,QAAQ,QAAW;AACrB,UAAM,IAAI,QAAQ,IAAI,IAAI;AAC1B,WAAO,KAAK,QAAQ,MAAM,KAAK,IAAI;AAAA,EACrC;AACA,SAAO,MAAM,IAAI;AACnB;AAEO,IAAM,UAAU,IAAI,WAAW;AACtC,IAAO,cAAQ;","names":["entry"]}
@@ -3,16 +3,16 @@ import {
3
3
  AntigravityAdapter,
4
4
  adapter,
5
5
  antigravity_default
6
- } from "./chunk-ERV4TKRV.js";
6
+ } from "./chunk-3Y23ZYYF.js";
7
7
  import "./chunk-H53QZQJI.js";
8
8
  import "./chunk-DBQMX75U.js";
9
- import "./chunk-A767JFHW.js";
9
+ import "./chunk-RHML2NOB.js";
10
10
  import "./chunk-TO57WYBB.js";
11
- import "./chunk-ZY25RG4Y.js";
12
- import "./chunk-QY42WGBX.js";
11
+ import "./chunk-ALVXORZM.js";
12
+ import "./chunk-2HCJV6UO.js";
13
13
  export {
14
14
  AntigravityAdapter,
15
15
  adapter,
16
16
  antigravity_default as default
17
17
  };
18
- //# sourceMappingURL=antigravity-NWP2TUG6.js.map
18
+ //# sourceMappingURL=antigravity-GF3RU42A.js.map
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  AntigravityAdapter
4
- } from "./chunk-ERV4TKRV.js";
4
+ } from "./chunk-3Y23ZYYF.js";
5
5
  import "./chunk-H53QZQJI.js";
6
6
  import "./chunk-DBQMX75U.js";
7
- import "./chunk-A767JFHW.js";
7
+ import "./chunk-RHML2NOB.js";
8
8
  import "./chunk-TO57WYBB.js";
9
- import "./chunk-ZY25RG4Y.js";
10
- import "./chunk-QY42WGBX.js";
9
+ import "./chunk-ALVXORZM.js";
10
+ import "./chunk-2HCJV6UO.js";
11
11
 
12
12
  // src/adapters/antigravity-cli/index.ts
13
13
  import { existsSync } from "fs";
@@ -84,4 +84,4 @@ export {
84
84
  adapter,
85
85
  antigravity_cli_default as default
86
86
  };
87
- //# sourceMappingURL=antigravity-cli-KPNLE7X4.js.map
87
+ //# sourceMappingURL=antigravity-cli-OH27IFH5.js.map