@herbertgao/pi-extensions 2026.10.12 → 2026.10.14

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 (269) hide show
  1. package/README.md +11 -11
  2. package/THIRD_PARTY_NOTICES.md +3 -3
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +7 -9
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.md +7 -9
  5. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +1 -0
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +14 -8
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +22 -5
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +28 -6
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +33 -12
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +60 -17
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +1 -5
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +20 -5
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +4 -1
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +42 -18
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/layout.ts +12 -3
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +131 -0
  17. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +217 -113
  18. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +12 -5
  19. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/subagent-notification.ts +556 -0
  20. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +50 -0
  21. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/format.ts +11 -0
  22. package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/patch-keys.ts +4 -0
  23. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  24. package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +1 -0
  25. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +27 -3
  26. package/node_modules/@juicesharp/rpiv-ask-user-question/config.ts +23 -0
  27. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/configuration.md +15 -0
  28. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +9 -2
  29. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/de.json +7 -4
  30. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +8 -5
  31. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/es.json +7 -4
  32. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/fr.json +7 -4
  33. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt-BR.json +7 -4
  34. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/pt.json +7 -4
  35. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/ru.json +7 -4
  36. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/uk.json +7 -4
  37. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/zh.json +7 -4
  38. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +4 -3
  39. package/node_modules/@juicesharp/rpiv-ask-user-question/presentation.ts +11 -1
  40. package/node_modules/@juicesharp/rpiv-ask-user-question/state/build-questionnaire.ts +6 -0
  41. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +49 -8
  42. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +6 -0
  43. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +13 -1
  44. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state.ts +2 -0
  45. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +19 -7
  46. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +36 -7
  47. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-copy.ts +13 -2
  48. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +24 -8
  49. package/node_modules/@juicesharp/rpiv-ask-user-question/view/transcript.ts +144 -0
  50. package/node_modules/@narumitw/pi-btw/README.md +7 -2
  51. package/node_modules/@narumitw/pi-btw/dist/index.ts +371 -118
  52. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
  53. package/node_modules/@narumitw/pi-btw/docs/main-context-runtime.md +45 -0
  54. package/node_modules/@narumitw/pi-btw/docs/workflows.md +48 -5
  55. package/node_modules/@narumitw/pi-btw/package.json +1 -1
  56. package/node_modules/@narumitw/pi-btw/src/btw.ts +39 -14
  57. package/node_modules/@narumitw/pi-btw/src/import-main-updates.ts +84 -0
  58. package/node_modules/@narumitw/pi-btw/src/keybindings.ts +29 -4
  59. package/node_modules/@narumitw/pi-btw/src/main-context-snapshot.ts +125 -0
  60. package/node_modules/@narumitw/pi-btw/src/menu.ts +1 -0
  61. package/node_modules/@narumitw/pi-btw/src/side-thread.ts +66 -17
  62. package/node_modules/@narumitw/pi-btw/src/transcript-markdown.ts +5 -5
  63. package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +47 -6
  64. package/node_modules/pi-lens/CHANGELOG.md +440 -0
  65. package/node_modules/pi-lens/README.md +13 -3
  66. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -0
  67. package/node_modules/pi-lens/dist/chunk-22Y2BM7H.js +23 -0
  68. package/node_modules/pi-lens/dist/{chunk-ATKJFDQN.js → chunk-27VWVB23.js} +12 -14
  69. package/node_modules/pi-lens/dist/{chunk-S2HEXIWI.js → chunk-2FYKETQJ.js} +10 -6
  70. package/node_modules/pi-lens/dist/{chunk-SRYEJNES.js → chunk-2LDMXL2M.js} +2 -2
  71. package/node_modules/pi-lens/dist/{chunk-ZHH37KZL.js → chunk-2SDHYHHO.js} +17 -17
  72. package/node_modules/pi-lens/dist/chunk-2Y6OJRSI.js +38 -0
  73. package/node_modules/pi-lens/dist/chunk-3SNDVPOR.js +507 -0
  74. package/node_modules/pi-lens/dist/{chunk-5OFV52AM.js → chunk-3WCEHYOI.js} +1 -1
  75. package/node_modules/pi-lens/dist/chunk-44X7VIKR.js +73 -0
  76. package/node_modules/pi-lens/dist/{chunk-DEL2U6CM.js → chunk-4FHUGDKU.js} +16 -14
  77. package/node_modules/pi-lens/dist/{chunk-CT4MN5IU.js → chunk-4ODSZ35Z.js} +353 -359
  78. package/node_modules/pi-lens/dist/{chunk-ZIVJBOO3.js → chunk-4U7GDSZQ.js} +2 -2
  79. package/node_modules/pi-lens/dist/chunk-54NIOJJZ.js +25 -0
  80. package/node_modules/pi-lens/dist/{chunk-N5FLEO7W.js → chunk-5DKE4HGX.js} +37 -37
  81. package/node_modules/pi-lens/dist/{chunk-P63GXC37.js → chunk-5LRUKYFA.js} +31 -4
  82. package/node_modules/pi-lens/dist/{chunk-HRNHZA3N.js → chunk-63NMUNYP.js} +12 -16
  83. package/node_modules/pi-lens/dist/{chunk-HWCCCQNX.js → chunk-6XSESGWD.js} +13 -6
  84. package/node_modules/pi-lens/dist/{chunk-UMS2MFPZ.js → chunk-72J27ICO.js} +2 -3
  85. package/node_modules/pi-lens/dist/{chunk-ED36RF6Y.js → chunk-7FLRUH6B.js} +1 -1
  86. package/node_modules/pi-lens/dist/chunk-7IYC4ENJ.js +297 -0
  87. package/node_modules/pi-lens/dist/chunk-7WWQAW5P.js +30 -0
  88. package/node_modules/pi-lens/dist/{chunk-3DA2JDOL.js → chunk-7ZS7MC24.js} +551 -203
  89. package/node_modules/pi-lens/dist/{chunk-WMYE35PX.js → chunk-AHWA4AKM.js} +7 -5
  90. package/node_modules/pi-lens/dist/{chunk-JW3YWBVB.js → chunk-AI3GP74G.js} +17 -19
  91. package/node_modules/pi-lens/dist/{chunk-AGSS7277.js → chunk-APFJKOP6.js} +6 -23
  92. package/node_modules/pi-lens/dist/{chunk-ZVUL7QYY.js → chunk-ASRAO7KG.js} +29 -32
  93. package/node_modules/pi-lens/dist/{chunk-BW5KFIQC.js → chunk-AWQWXSW4.js} +1 -0
  94. package/node_modules/pi-lens/dist/{chunk-TLX72JTG.js → chunk-CG5V25HX.js} +1 -1
  95. package/node_modules/pi-lens/dist/chunk-CKEQFGLT.js +32 -0
  96. package/node_modules/pi-lens/dist/{chunk-Y6GZHWSJ.js → chunk-COOUUC5W.js} +6 -6
  97. package/node_modules/pi-lens/dist/{chunk-XTBDCR27.js → chunk-CPZ5JJW6.js} +4 -4
  98. package/node_modules/pi-lens/dist/{chunk-RKKOYPRA.js → chunk-DS2USX5G.js} +13 -15
  99. package/node_modules/pi-lens/dist/chunk-EA2ZRG44.js +27 -0
  100. package/node_modules/pi-lens/dist/{chunk-GSLNCYGG.js → chunk-EDMLIW6W.js} +13 -14
  101. package/node_modules/pi-lens/dist/{chunk-2EECBNC5.js → chunk-EIKRZ32J.js} +75 -0
  102. package/node_modules/pi-lens/dist/chunk-EKNWOL2I.js +27 -0
  103. package/node_modules/pi-lens/dist/{chunk-R3T7CLQ2.js → chunk-ELZRSR5N.js} +41 -41
  104. package/node_modules/pi-lens/dist/{chunk-GMX5OS7B.js → chunk-EN5AM7PX.js} +11 -12
  105. package/node_modules/pi-lens/dist/{chunk-3RKP3FMS.js → chunk-EWXXLS26.js} +226 -24
  106. package/node_modules/pi-lens/dist/chunk-EX4EXBW7.js +37 -0
  107. package/node_modules/pi-lens/dist/{chunk-XHJBS436.js → chunk-EXVXBSGN.js} +25 -25
  108. package/node_modules/pi-lens/dist/{chunk-MZGQNL3Y.js → chunk-F7BO6FWH.js} +12 -13
  109. package/node_modules/pi-lens/dist/{chunk-V35JG4JB.js → chunk-FEDWAYDS.js} +152 -334
  110. package/node_modules/pi-lens/dist/{chunk-J64T55EI.js → chunk-FWZRGGGY.js} +73 -9
  111. package/node_modules/pi-lens/dist/{chunk-T57LYLZT.js → chunk-G224FADB.js} +1 -1
  112. package/node_modules/pi-lens/dist/chunk-G5UCJFT7.js +26 -0
  113. package/node_modules/pi-lens/dist/{chunk-LLJNQKQW.js → chunk-GLW3YDZZ.js} +20 -13
  114. package/node_modules/pi-lens/dist/{chunk-GXFV6MYU.js → chunk-GTDSYEA2.js} +72 -39
  115. package/node_modules/pi-lens/dist/{chunk-DUO2TU77.js → chunk-GYRZ72R4.js} +10 -4
  116. package/node_modules/pi-lens/dist/chunk-HYVXA3BB.js +49 -0
  117. package/node_modules/pi-lens/dist/{chunk-W66O5E25.js → chunk-IEBJF3PN.js} +13 -15
  118. package/node_modules/pi-lens/dist/{chunk-GAQ7OQG6.js → chunk-IL7K66ZQ.js} +83 -94
  119. package/node_modules/pi-lens/dist/{chunk-T7FEBKXN.js → chunk-JWOVP5BL.js} +7 -9
  120. package/node_modules/pi-lens/dist/{chunk-UBOQLVT2.js → chunk-K2GUZ4DN.js} +4 -4
  121. package/node_modules/pi-lens/dist/{chunk-5VSF4UUQ.js → chunk-K4SZB56V.js} +34 -39
  122. package/node_modules/pi-lens/dist/{chunk-7D6L4MTX.js → chunk-KCBRHV5E.js} +3 -3
  123. package/node_modules/pi-lens/dist/{chunk-GSM5UU7A.js → chunk-KFXCL4OV.js} +38 -28
  124. package/node_modules/pi-lens/dist/{chunk-J6MPGQTS.js → chunk-KJJAVH3X.js} +81 -15
  125. package/node_modules/pi-lens/dist/{chunk-BWD5EPKO.js → chunk-KPVLQHCZ.js} +4 -6
  126. package/node_modules/pi-lens/dist/{chunk-MPNJLASA.js → chunk-KX56K73G.js} +10 -13
  127. package/node_modules/pi-lens/dist/{chunk-AWSCPCN2.js → chunk-LMCTHJ2H.js} +19 -19
  128. package/node_modules/pi-lens/dist/{chunk-IWDLU6K3.js → chunk-MEFLGBCS.js} +4 -6
  129. package/node_modules/pi-lens/dist/{chunk-TOY6QKOH.js → chunk-MKPCELNI.js} +17 -17
  130. package/node_modules/pi-lens/dist/{chunk-POMLXPMY.js → chunk-N3PLNNCW.js} +1 -1
  131. package/node_modules/pi-lens/dist/chunk-N5FBM25N.js +22 -0
  132. package/node_modules/pi-lens/dist/{chunk-CYRKQRPM.js → chunk-NFNVDDGB.js} +2 -4
  133. package/node_modules/pi-lens/dist/{chunk-RMLC67LF.js → chunk-NLIVE7L6.js} +2 -30
  134. package/node_modules/pi-lens/dist/{chunk-24AKHFGP.js → chunk-OMJ3OFBJ.js} +6 -6
  135. package/node_modules/pi-lens/dist/{chunk-IQWN5JCP.js → chunk-OZNCKLOX.js} +13 -14
  136. package/node_modules/pi-lens/dist/chunk-P5XUGPIX.js +31 -0
  137. package/node_modules/pi-lens/dist/{chunk-2KXTHF3M.js → chunk-PJXNTPB2.js} +253 -33
  138. package/node_modules/pi-lens/dist/chunk-PKOXJIVT.js +88 -0
  139. package/node_modules/pi-lens/dist/{chunk-DGUKIYSI.js → chunk-PP2A5V2T.js} +8 -10
  140. package/node_modules/pi-lens/dist/{chunk-KAPJINKN.js → chunk-Q42LJANT.js} +2 -2
  141. package/node_modules/pi-lens/dist/{chunk-UZ2XCLYS.js → chunk-Q4BKKOVC.js} +8 -8
  142. package/node_modules/pi-lens/dist/{chunk-TIQ2PKDW.js → chunk-QT66NEYN.js} +4 -4
  143. package/node_modules/pi-lens/dist/{chunk-U44DJXQP.js → chunk-RCHO5W7M.js} +15 -18
  144. package/node_modules/pi-lens/dist/{chunk-YH5MVY2U.js → chunk-RG3MXTRI.js} +7 -7
  145. package/node_modules/pi-lens/dist/chunk-RG7OODGM.js +57 -0
  146. package/node_modules/pi-lens/dist/{chunk-OHKJ7PQF.js → chunk-RU34BA4D.js} +43 -39
  147. package/node_modules/pi-lens/dist/{chunk-JMYYOTQG.js → chunk-S26LC76R.js} +13 -1
  148. package/node_modules/pi-lens/dist/{chunk-XBJVAEEO.js → chunk-S55TEC7I.js} +3 -2
  149. package/node_modules/pi-lens/dist/{chunk-RVK72CZX.js → chunk-SJHC3BCZ.js} +1397 -481
  150. package/node_modules/pi-lens/dist/{chunk-IYNJ6YPZ.js → chunk-SNEUMLM7.js} +4 -4
  151. package/node_modules/pi-lens/dist/{chunk-S67KYG37.js → chunk-T4NGVFYI.js} +2 -2
  152. package/node_modules/pi-lens/dist/{chunk-YCWYO6TQ.js → chunk-THEXI2QO.js} +48 -45
  153. package/node_modules/pi-lens/dist/{chunk-AMERCH6V.js → chunk-TL2TCJYL.js} +15 -16
  154. package/node_modules/pi-lens/dist/{chunk-KUA4OJ5Y.js → chunk-TPYYEDP5.js} +823 -350
  155. package/node_modules/pi-lens/dist/{chunk-YNE3RP52.js → chunk-TVZRLTG6.js} +8 -1
  156. package/node_modules/pi-lens/dist/{chunk-ROYSX2S5.js → chunk-UCVMSOXF.js} +2 -2
  157. package/node_modules/pi-lens/dist/chunk-UL5SXQVX.js +32 -0
  158. package/node_modules/pi-lens/dist/{chunk-7HXE67BN.js → chunk-UO66IMVP.js} +2 -2
  159. package/node_modules/pi-lens/dist/{chunk-VOOAPROD.js → chunk-UVY4TOJH.js} +3 -3
  160. package/node_modules/pi-lens/dist/{chunk-RKBXZN3A.js → chunk-VIDEKABZ.js} +2 -2
  161. package/node_modules/pi-lens/dist/{chunk-2FN63LPV.js → chunk-VITFDI3O.js} +13 -14
  162. package/node_modules/pi-lens/dist/{chunk-6DLWKFEX.js → chunk-VUAVE3QC.js} +41 -42
  163. package/node_modules/pi-lens/dist/{chunk-FM4RDMKT.js → chunk-WUY4BZEP.js} +10 -12
  164. package/node_modules/pi-lens/dist/{chunk-SD4I7ZO4.js → chunk-X3UTCXAA.js} +43 -53
  165. package/node_modules/pi-lens/dist/chunk-XHDBJODR.js +45 -0
  166. package/node_modules/pi-lens/dist/{chunk-5IUSNGOC.js → chunk-XHLK33VM.js} +28 -21
  167. package/node_modules/pi-lens/dist/{chunk-3KAZU3VR.js → chunk-XI34NWDI.js} +2 -2
  168. package/node_modules/pi-lens/dist/{chunk-QBFBRV2B.js → chunk-XWFIHYCH.js} +4 -2
  169. package/node_modules/pi-lens/dist/{chunk-JUKMK5Y4.js → chunk-Y2TPADJR.js} +10 -11
  170. package/node_modules/pi-lens/dist/{chunk-EBC36LNN.js → chunk-Y5KTA2OB.js} +17 -17
  171. package/node_modules/pi-lens/dist/{chunk-HYGZEMX6.js → chunk-YKVDBNPO.js} +11 -5
  172. package/node_modules/pi-lens/dist/{chunk-KN35K52N.js → chunk-YSDPVDFC.js} +3 -3
  173. package/node_modules/pi-lens/dist/chunk-YWNO5Q4R.js +44 -0
  174. package/node_modules/pi-lens/dist/{chunk-US7ECLD7.js → chunk-YWWG4AQA.js} +119 -28
  175. package/node_modules/pi-lens/dist/{chunk-O4NWQT6I.js → chunk-YXDCRUKQ.js} +4 -4
  176. package/node_modules/pi-lens/dist/{chunk-XYURS6EN.js → chunk-YXGRRORB.js} +15 -17
  177. package/node_modules/pi-lens/dist/{chunk-IUE7SSKV.js → chunk-ZAPSUBLU.js} +13 -7
  178. package/node_modules/pi-lens/dist/{chunk-EUXZEFTV.js → chunk-ZPJM7DID.js} +3 -3
  179. package/node_modules/pi-lens/dist/{chunk-5HSRT26B.js → chunk-ZSUX7KEM.js} +16 -15
  180. package/node_modules/pi-lens/dist/index.js +37155 -32210
  181. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +11 -12
  182. package/node_modules/pi-lens/dist/mcp/cli.js +46 -45
  183. package/node_modules/pi-lens/dist/mcp/server.js +1210 -574
  184. package/node_modules/pi-lens/dist/mcp/worker.js +65 -65
  185. package/node_modules/pi-lens/dist/probes/installer.js +21 -23
  186. package/node_modules/pi-lens/docs/adr/0010-trace-validation-session-lifecycle.md +390 -0
  187. package/node_modules/pi-lens/docs/adr/README.md +1 -0
  188. package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +5 -3
  189. package/node_modules/pi-lens/docs/configuration.md +9 -0
  190. package/node_modules/pi-lens/docs/engineering-principles.md +12 -0
  191. package/node_modules/pi-lens/docs/environment-variables.md +20 -0
  192. package/node_modules/pi-lens/docs/features.md +16 -1
  193. package/node_modules/pi-lens/docs/globalconfig.md +37 -8
  194. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +105 -12
  195. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +37 -18
  196. package/node_modules/pi-lens/docs/pi-lens-fixer.md +22 -1
  197. package/node_modules/pi-lens/docs/pi-lens-investigator.md +14 -0
  198. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +23 -10
  199. package/node_modules/pi-lens/docs/pi-lens-monitor.md +64 -8
  200. package/node_modules/pi-lens/docs/pi-lens-retro.md +2 -2
  201. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +48 -1
  202. package/node_modules/pi-lens/docs/pi-lens-subagent.md +8 -1
  203. package/node_modules/pi-lens/docs/release-qa-baseline.md +19 -7
  204. package/node_modules/pi-lens/docs/servercapabilities.md +47 -47
  205. package/node_modules/pi-lens/docs/settings.md +9 -5
  206. package/node_modules/pi-lens/docs/subagent-compat.md +1 -1
  207. package/node_modules/pi-lens/docs/usage.md +1 -0
  208. package/node_modules/pi-lens/package.json +6 -4
  209. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-return-value-in-generator-test.yml +17 -0
  210. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-js-test.yml +86 -0
  211. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-sql-in-code-execute-test.yml +86 -0
  212. package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/unchecked-numeric-parse-python-test.yml +15 -0
  213. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-return-value-in-generator.yml +9 -4
  214. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +119 -0
  215. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +119 -0
  216. package/node_modules/pi-lens/rules/ast-grep-rules/rules/unchecked-numeric-parse-python.yml +13 -2
  217. package/node_modules/pi-lens/rules/rule-catalog.json +25 -1
  218. package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +15 -5
  219. package/node_modules/pi-lens/scripts/lib/is-main-module.mjs +27 -0
  220. package/node_modules/pi-lens/scripts/lib/scratch-home-env.mjs +21 -0
  221. package/node_modules/pi-lens/scripts/rpc-load-check.mjs +4 -6
  222. package/node_modules/pi-lens/scripts/warm-loader-cache.mjs +2 -5
  223. package/node_modules/pi-next-cue/package.json +4 -1
  224. package/node_modules/pi-provider-qoder/dist/index.js +438 -283
  225. package/node_modules/pi-provider-qoder/package.json +1 -1
  226. package/node_modules/pi-typesafe/README.md +6 -6
  227. package/node_modules/pi-typesafe/dist/ask.js +9 -2
  228. package/node_modules/pi-typesafe/dist/auth.d.ts +3 -2
  229. package/node_modules/pi-typesafe/dist/auth.js +2 -2
  230. package/node_modules/pi-typesafe/dist/backends.d.ts +20 -5
  231. package/node_modules/pi-typesafe/dist/backends.js +32 -8
  232. package/node_modules/pi-typesafe/dist/batch.d.ts +1 -1
  233. package/node_modules/pi-typesafe/dist/batch.js +2 -2
  234. package/node_modules/pi-typesafe/dist/client.d.ts +1 -1
  235. package/node_modules/pi-typesafe/dist/client.js +24 -12
  236. package/node_modules/pi-typesafe/dist/credentials.d.ts +8 -6
  237. package/node_modules/pi-typesafe/dist/credentials.js +70 -16
  238. package/node_modules/pi-typesafe/dist/extension.js +118 -26
  239. package/node_modules/pi-typesafe/dist/index.d.ts +1 -1
  240. package/node_modules/pi-typesafe/dist/index.js +1 -1
  241. package/node_modules/pi-typesafe/dist/key-prompt.d.ts +1 -1
  242. package/node_modules/pi-typesafe/dist/key-prompt.js +6 -6
  243. package/node_modules/pi-typesafe/dist/login.d.ts +11 -10
  244. package/node_modules/pi-typesafe/dist/login.js +24 -21
  245. package/node_modules/pi-typesafe/dist/schema.d.ts +8 -8
  246. package/node_modules/pi-typesafe/dist/schema.js +29 -7
  247. package/node_modules/pi-typesafe/package.json +2 -2
  248. package/package.json +12 -12
  249. package/node_modules/pi-lens/dist/chunk-3PTHXJXR.js +0 -28
  250. package/node_modules/pi-lens/dist/chunk-3QED2P4V.js +0 -31
  251. package/node_modules/pi-lens/dist/chunk-5WRPDP2A.js +0 -47
  252. package/node_modules/pi-lens/dist/chunk-ABBOA7UD.js +0 -157
  253. package/node_modules/pi-lens/dist/chunk-CUHSHSB6.js +0 -273
  254. package/node_modules/pi-lens/dist/chunk-GL5LUMZE.js +0 -51
  255. package/node_modules/pi-lens/dist/chunk-HAD7QRQI.js +0 -30
  256. package/node_modules/pi-lens/dist/chunk-JORED7EX.js +0 -44
  257. package/node_modules/pi-lens/dist/chunk-KYUB6QDC.js +0 -72
  258. package/node_modules/pi-lens/dist/chunk-LZSEQW6A.js +0 -57
  259. package/node_modules/pi-lens/dist/chunk-M2IFVFWU.js +0 -79
  260. package/node_modules/pi-lens/dist/chunk-M2UD3LPU.js +0 -88
  261. package/node_modules/pi-lens/dist/chunk-MBKQHGA7.js +0 -39
  262. package/node_modules/pi-lens/dist/chunk-R7YOCSNV.js +0 -23
  263. package/node_modules/pi-lens/dist/chunk-SKAMFC7A.js +0 -28
  264. package/node_modules/pi-lens/dist/chunk-SYE6T2EB.js +0 -28
  265. package/node_modules/pi-lens/dist/chunk-TRETHTQO.js +0 -26
  266. package/node_modules/pi-lens/dist/chunk-UA7ZXYDR.js +0 -184
  267. package/node_modules/pi-lens/dist/chunk-XTFDJI3T.js +0 -24
  268. package/node_modules/pi-lens/dist/chunk-Z3CCVDUB.js +0 -76
  269. package/node_modules/pi-next-cue/.github/workflows/publish.yml +0 -20
@@ -1,12 +1,33 @@
1
1
  import { Text } from "@earendil-works/pi-tui";
2
- import { DEFAULT_BACKEND, defaultModelId } from "./backends.js";
2
+ import { BACKEND_ENV, DEFAULT_BACKEND, DECISIONS_BACKENDS, MODEL_ENV, backendFromEnvironment, backendHost, modelFromEnvironment, resolveBackend, sentModelId } from "./backends.js";
3
3
  import { createTypeSafe, DEFAULT_MAX_REQUESTS } from "./client.js";
4
4
  import { authState, clearAuthState, describeAuth } from "./auth.js";
5
5
  import { clearStoredApiKey, credentialsPath, keySituation, keySourceLabel } from "./credentials.js";
6
6
  import { TypeSafeIntegrationError, safeError } from "./errors.js";
7
7
  import { loginWithPrompt } from "./login.js";
8
8
  import { DEFAULT_MAX_INPUT_BYTES, evaluationSchema, normalizeEvaluationRequest, prepareEvaluationRequest } from "./schema.js";
9
- const disclosure = "Submitted state and questions will be sent to api.typesafe.ai and may incur charges. Do not include secrets. The extension does not collect files or conversation history. Results are model judgments, not proof or authorization.";
9
+ const fixedDisclosure = "Submitted state and questions will be sent to api.typesafe.ai and may incur charges. Do not include secrets. The extension does not collect files or conversation history. Results are model judgments, not proof or authorization.";
10
+ /**
11
+ * The consent sentence for the backend this session actually uses, and whether it names the model sent. The default
12
+ * backend with no model override returns the fixed sentence unchanged, so an install that selects nothing reads
13
+ * exactly what it read before. Every other session is told the host, the backend, and the model id the request
14
+ * carries — the same `sentModelId` value the client sends, so consent cannot describe a model that is not sent.
15
+ */
16
+ function consentFor(backend, model) {
17
+ const namesModel = backend !== DEFAULT_BACKEND || model !== undefined;
18
+ if (!namesModel)
19
+ return { text: fixedDisclosure, namesModel };
20
+ const config = resolveBackend(backend);
21
+ return {
22
+ text: `Submitted state and questions will be sent to ${backendHost(backend)} (${config.label}) as model ${JSON.stringify(sentModelId(backend, model))} and may incur charges. Do not include secrets. The extension does not collect files or conversation history. Results are model judgments, not proof or authorization.`,
23
+ namesModel,
24
+ };
25
+ }
26
+ /** The status line naming the backend, its host, and its key variable; the model is stated once, by `Model:` or the consent sentence. */
27
+ function backendLine(backend) {
28
+ const config = resolveBackend(backend);
29
+ return `${config.label} backend: ${backendHost(backend)}, key from ${config.keyEnv}.`;
30
+ }
10
31
  const sample = {
11
32
  state: { message: "I was charged twice for my subscription. Please help today." },
12
33
  questions: {
@@ -15,6 +36,8 @@ const sample = {
15
36
  frustration: { type: "score", instructions: "How frustrated does the sender sound?", criteria: ["Neutral request", "Frustrated but civil", "Angry or threatening"] },
16
37
  },
17
38
  };
39
+ /** 0.7.0 reports a count it did not measure as null; name it instead of printing "null". */
40
+ const formatNumber = (count) => (count === null ? "not reported" : String(count));
18
41
  function format(result, expanded = false) {
19
42
  const lines = [`TypeSafe · ${JSON.stringify(result.model)} · ${result.elapsedMs} ms`];
20
43
  for (const [id, answer] of Object.entries(result.answers)) {
@@ -23,22 +46,37 @@ function format(result, expanded = false) {
23
46
  lines.push(`${label}: P(yes) = ${answer.noul.toFixed(3)}`);
24
47
  else if (answer.type === "choice")
25
48
  lines.push(`${label}: ${JSON.stringify(answer.choice)} · confidence ${answer.confidence.toFixed(3)}`);
26
- else
49
+ else if (answer.type === "score")
27
50
  lines.push(`${label}: ${answer.score.toFixed(3)} · confidence ${answer.confidence.toFixed(3)}`);
28
- if (expanded && answer.type !== "noul")
51
+ else
52
+ lines.push(`${label}: box ${JSON.stringify(answer.box)} · confidence ${formatNumber(answer.confidence)}`);
53
+ if (expanded && (answer.type === "choice" || answer.type === "score"))
29
54
  lines.push(` ${JSON.stringify(answer.probabilities)}`);
30
55
  }
31
- lines.push(`${result.usage.input_tokens} input / ${result.usage.output_tokens} output tokens`);
56
+ lines.push(`${formatNumber(result.usage.input_tokens)} input / ${formatNumber(result.usage.output_tokens)} output tokens`);
32
57
  lines.push("Confidence is distribution concentration, not proof of correctness.");
33
58
  return lines.join("\n");
34
59
  }
35
60
  /** Native Pi registration; importing the root library does not load this module. */
36
61
  export default function typesafeExtension(pi) {
37
62
  let enabled = process.env.PI_TYPESAFE_ENABLED === "1";
63
+ // Resolved once per process: the backend names the host every request goes to, so it cannot change mid-session.
64
+ let backend;
65
+ let model;
66
+ let backendError;
67
+ try {
68
+ backend = backendFromEnvironment();
69
+ model = modelFromEnvironment();
70
+ }
71
+ catch (error) {
72
+ backend = DEFAULT_BACKEND;
73
+ backendError = safeError(error).message;
74
+ }
75
+ const consent = consentFor(backend, model);
38
76
  let client;
39
77
  // One callout per distinct degradation per session: a long run must not bury the reason in repeated notices.
40
78
  let calledOut;
41
- const getClient = () => client ??= createTypeSafe();
79
+ const getClient = () => client ??= createTypeSafe({ backend, ...(model === undefined ? {} : { model }) });
42
80
  const callOut = (ctx, key, text) => {
43
81
  if (calledOut === key)
44
82
  return;
@@ -59,16 +97,19 @@ export default function typesafeExtension(pi) {
59
97
  calledOut = undefined;
60
98
  // An enabled extension with no usable key used to look exactly like a working one. Say it at startup; an
61
99
  // unverified-but-present key stays quiet, because the first request is what proves it.
62
- const auth = describeAuth(authState());
63
- if (enabled && auth.level === "error")
100
+ const auth = describeAuth(authState({ backend }));
101
+ // A backend name the registry does not know means no judgment can be sent at all, whether or not it is enabled.
102
+ if (backendError !== undefined)
103
+ callOut(ctx, `start:backend`, `${backendError} Judgments are skipped until ${BACKEND_ENV} names a valid backend or is unset.`);
104
+ else if (enabled && auth.level === "error")
64
105
  callOut(ctx, `start:${auth.level}`, `TypeSafe is enabled but judgments are skipped. ${auth.text}`);
65
106
  });
66
107
  pi.registerEntryRenderer("typesafe-result", (entry, { expanded }) => new Text(entry.data ? format(entry.data, expanded) : "TypeSafe · no result", 0, 0));
67
108
  pi.registerTool({
68
109
  name: "typesafe_evaluate",
69
110
  label: "TypeSafe",
70
- description: `Evaluate supplied state with independent Choice, Score, and Noul questions in one TypeSafe request. Each question judges the whole state, so when several items are involved, put each item in a named state field (e.g. \`reports.r1\`) and ask one question per item per dimension (e.g. \`r1_owner\`, \`r2_owner\`), naming the field in the instructions; never aggregate several items into one question. ${disclosure} Requires operator opt-in via /typesafe enable or PI_TYPESAFE_ENABLED=1. Limit: 32 questions, ${DEFAULT_MAX_INPUT_BYTES / 1024} KiB JSON, ${DEFAULT_MAX_REQUESTS} attempts per session; no retries.`,
71
- promptSnippet: "Ask batched structured questions with TypeSafe (external service; operator opt-in required)",
111
+ description: `Evaluate supplied state with independent Choice, Score, and Noul questions in one ${resolveBackend(backend).label} request. Each question judges the whole state, so when several items are involved, put each item in a named state field (e.g. \`reports.r1\`) and ask one question per item per dimension (e.g. \`r1_owner\`, \`r2_owner\`), naming the field in the instructions; never aggregate several items into one question. ${consent.text} Requires operator opt-in via /typesafe enable or PI_TYPESAFE_ENABLED=1. Limit: 32 questions, ${DEFAULT_MAX_INPUT_BYTES / 1024} KiB JSON, ${DEFAULT_MAX_REQUESTS} attempts per session; no retries.`,
112
+ promptSnippet: `Ask batched structured questions with ${resolveBackend(backend).label} (external service; operator opt-in required)`,
72
113
  promptGuidelines: [
73
114
  // The payload shape is what models get wrong on the first call; the same sample the playground edits is the cheapest way to show it.
74
115
  // Every session pays for this line on every tool listing, so the sample stays short.
@@ -84,6 +125,8 @@ export default function typesafeExtension(pi) {
84
125
  async execute(_id, params, signal, _onUpdate, ctx) {
85
126
  if (!enabled)
86
127
  throw new TypeSafeIntegrationError("configuration", "TypeSafe is disabled. Ask the operator to run /typesafe enable; do not enable it by editing configuration or environment files.");
128
+ if (backendError !== undefined)
129
+ throw new TypeSafeIntegrationError("configuration", backendError);
87
130
  // The tool admits through the same rule as the library; evaluate() re-runs it idempotently.
88
131
  const request = prepareEvaluationRequest(params);
89
132
  try {
@@ -115,37 +158,82 @@ export default function typesafeExtension(pi) {
115
158
  pi.registerCommand("typesafe", {
116
159
  description: "TypeSafe login, consent, usage, sample test, and JSON playground",
117
160
  getArgumentCompletions(prefix) {
161
+ const [verb, ...rest] = prefix.split(/\s+/);
162
+ if (rest.length && (verb === "login" || verb === "logout")) {
163
+ const typed = rest.join(" ");
164
+ const names = Object.keys(DECISIONS_BACKENDS).filter(name => name.startsWith(typed));
165
+ return names.length ? names.map(name => ({ value: `${verb} ${name}`, label: name })) : null;
166
+ }
118
167
  const matches = actions.filter(action => action.startsWith(prefix)).map(action => ({ value: action, label: action }));
119
168
  return matches.length ? matches : null;
120
169
  },
121
170
  async handler(args, ctx) {
122
- const action = args.trim() || "status";
171
+ const [action = "status", ...rest] = args.trim().split(/\s+/).filter(Boolean);
172
+ const backendArg = rest[0];
173
+ const backendChoices = Object.keys(DECISIONS_BACKENDS).join(", ");
123
174
  const report = (text, level = "info") => {
124
175
  if (ctx.hasUI)
125
176
  ctx.ui.notify(text, level);
126
177
  else
127
178
  pi.sendMessage({ customType: "typesafe-status", content: text, display: true });
128
179
  };
180
+ // No key change makes an unusable backend name work: decline instead of prompting for a key or deleting the
181
+ // stored one a later valid run would want.
182
+ if (backendError !== undefined && (action === "login" || action === "logout")) {
183
+ report(`${backendError} No key change fixes that, so /typesafe ${action} does nothing: fix or unset ${BACKEND_ENV} first.`, "warning");
184
+ return;
185
+ }
129
186
  try {
187
+ // A backend the command names, or this session's own backend when it names none, so the commands act on
188
+ // what judgments actually use. resolveBackend refuses a name the registry does not know.
189
+ const spec = backendArg === undefined ? backend : backendArg;
190
+ const config = resolveBackend(spec);
191
+ const isActive = config.keyEnv === resolveBackend(backend).keyEnv;
192
+ const situation = keySituation(backend);
130
193
  if (action === "status") {
131
194
  const spend = client?.getSpend();
132
- const auth = describeAuth(authState());
195
+ const auth = describeAuth(authState({ backend }));
133
196
  const session = spend
134
197
  ? `Session ${spend.session.requestsStarted}/${DEFAULT_MAX_REQUESTS} attempts, ${spend.session.requestsSucceeded} successful, ${spend.session.requestsFailed} failed, ${spend.session.inputTokens} input tokens (~$${spend.session.estimatedUsd.toFixed(4)}).`
135
198
  : `Session 0/${DEFAULT_MAX_REQUESTS} attempts; no client yet in this session.`;
136
199
  const today = spend
137
200
  ? `Today ${spend.today.requestsStarted} requests (${spend.today.requestsSucceeded} ok, ${spend.today.requestsFailed} failed), ${spend.today.inputTokens} input tokens, ~$${spend.today.estimatedUsd.toFixed(4)}.`
138
201
  : "";
139
- const blocked = spend?.blocked ? ` Cap reached: ${spend.blocked.cap} ${spend.blocked.used}/${spend.blocked.limit} on ${spend.blocked.day}; no request will be submitted until the local day rolls over.` : "";
140
- report(`TypeSafe: ${enabled ? "enabled" : "disabled"}. ${auth.text} ${session} ${today}${blocked} Model: ${defaultModelId(DEFAULT_BACKEND)}. Session limits reset on session start/reload; daily counters persist and caps come from client options or PI_TYPESAFE_MAX_* environment variables. ${disclosure}`, auth.level === "error" && enabled ? "warning" : "info");
202
+ const blocked = spend?.blocked ? `Cap reached: ${spend.blocked.cap} ${spend.blocked.used}/${spend.blocked.limit} on ${spend.blocked.day}; no request will be submitted until the local day rolls over.` : "";
203
+ // The backend, host, and key source lead, so a status line cannot describe the TypeSafe key while another
204
+ // backend serves the requests. The model is named once: by `Model:` when the consent sentence is the fixed
205
+ // one that names none, otherwise by the consent sentence itself. An unusable name sends nothing, so that
206
+ // status names no model and quotes no consent.
207
+ const route = backendError !== undefined
208
+ ? `Backend: ${BACKEND_ENV} is invalid — ${backendError} Judgments are skipped.`
209
+ : backendLine(backend);
210
+ const version = backendError === undefined && !consent.namesModel ? `Model: ${sentModelId(backend, model)}.` : "";
211
+ report([
212
+ `TypeSafe: ${enabled ? "enabled" : "disabled"}.`,
213
+ route,
214
+ auth.text,
215
+ session,
216
+ today,
217
+ blocked,
218
+ version,
219
+ backend === DEFAULT_BACKEND ? "" : `Set ${MODEL_ENV} to send another model.`,
220
+ "Session limits reset on session start/reload; daily counters persist and caps come from client options or PI_TYPESAFE_MAX_* environment variables.",
221
+ backendError === undefined ? consent.text : "",
222
+ ].filter((part) => part !== "").join(" "), (auth.level === "error" && enabled) || backendError !== undefined ? "warning" : "info");
141
223
  return;
142
224
  }
143
225
  if (action === "logout") {
144
- const removed = clearStoredApiKey();
226
+ const removed = clearStoredApiKey(spec);
145
227
  clearAuthState();
146
228
  client = undefined;
147
- enabled = false;
148
- report(removed ? `Removed the stored key at ${credentialsPath()}. TypeSafe is disabled.` : "No stored key to remove." + (process.env.TYPESAFE_API_KEY?.trim() ? " TYPESAFE_API_KEY is still set in the environment." : ""));
229
+ const env = process.env[config.keyEnv]?.trim();
230
+ // A session with consent but no key can only fail the next call; logging out another backend's key changes nothing.
231
+ if (isActive && !env)
232
+ enabled = false;
233
+ const tail = env
234
+ ? ` ${config.keyEnv} is still set in the environment and takes precedence over a stored key.`
235
+ : (isActive ? " Judgments are off for this session." : "");
236
+ report(`${removed ? `Removed the stored ${config.label} key at ${credentialsPath()}.` : `No stored ${config.label} key to remove.`}${tail}`);
149
237
  return;
150
238
  }
151
239
  if (action === "disable") {
@@ -154,26 +242,30 @@ export default function typesafeExtension(pi) {
154
242
  return;
155
243
  }
156
244
  if (!actions.includes(action)) {
157
- report(`Usage: /typesafe ${actions.join(" | ")}`, "warning");
245
+ report(`Usage: /typesafe ${actions.join(" | ")}. login and logout take a backend name: ${backendChoices}.`, "warning");
158
246
  return;
159
247
  }
160
248
  if (!ctx.hasUI) {
161
- report("This command needs interactive Pi. For headless tool use, explicitly set PI_TYPESAFE_ENABLED=1 and TYPESAFE_API_KEY before launching Pi.", "warning");
249
+ report(`This command needs interactive Pi. For headless tool use, explicitly set PI_TYPESAFE_ENABLED=1 and ${config.keyEnv} before launching Pi.`, "warning");
162
250
  return;
163
251
  }
164
- const situation = keySituation();
165
252
  if (action === "login" || (action === "setup" && situation.kind === "missing")) {
166
- if (process.env.TYPESAFE_API_KEY?.trim()) {
167
- report("TYPESAFE_API_KEY is set in the environment and takes precedence over a stored key. Unset it before using /typesafe login.", "warning");
253
+ // The one rule for every backend: the stored key is used unless the backend's variable is set, and then it wins.
254
+ if (process.env[config.keyEnv]?.trim()) {
255
+ report(`${config.keyEnv} is set in the environment and takes precedence over a stored key. Unset it before using /typesafe login.`, "warning");
168
256
  return;
169
257
  }
170
- const login = await loginWithPrompt(ctx);
258
+ const login = await loginWithPrompt(ctx, { backend: spec });
171
259
  if (login === undefined) {
172
260
  report("Login cancelled; nothing was saved.");
173
261
  return;
174
262
  }
175
263
  client = undefined;
176
- report(`Key verified (${login.models} model${login.models === 1 ? "" : "s"} available) and saved to ${login.path} with owner-only permissions. Run /typesafe enable to allow agent tool calls.`);
264
+ const proof = login.models === undefined ? "verified with one request" : `verified (${login.models} model${login.models === 1 ? "" : "s"} available)`;
265
+ const hint = isActive
266
+ ? (enabled ? "" : " Run /typesafe enable to allow agent tool calls.")
267
+ : ` ${BACKEND_ENV} is ${backend}; set it to ${config.name} to send judgments there.`;
268
+ report(`${config.label} key ${proof} and saved to ${login.path} with owner-only permissions.${hint}`);
177
269
  return;
178
270
  }
179
271
  if (action === "setup") {
@@ -192,7 +284,7 @@ export default function typesafeExtension(pi) {
192
284
  report(`The stored key cannot be used. ${situation.reason}`, "warning");
193
285
  return;
194
286
  }
195
- if (await ctx.ui.confirm("Enable TypeSafe for this session?", disclosure)) {
287
+ if (await ctx.ui.confirm("Enable TypeSafe for this session?", consent.text)) {
196
288
  enabled = true;
197
289
  report(`TypeSafe enabled. Up to ${DEFAULT_MAX_REQUESTS} attempts in this session; /typesafe disable stops future agent calls.`);
198
290
  }
@@ -212,7 +304,7 @@ export default function typesafeExtension(pi) {
212
304
  }
213
305
  }
214
306
  const validated = prepareEvaluationRequest(request);
215
- if (!await ctx.ui.confirm("Send this TypeSafe request?", disclosure))
307
+ if (!await ctx.ui.confirm("Send this TypeSafe request?", consent.text))
216
308
  return;
217
309
  const result = await getClient().evaluate(validated);
218
310
  // Playground results stay out of LLM context; the agent tool returns its own results normally.
@@ -1,4 +1,4 @@
1
- export { createTypeSafe, backendHost, backendPrice, resolveBackend, DEFAULT_MAX_REQUESTS, DECISIONS_BACKENDS, DEFAULT_BACKEND } from "./client.js";
1
+ export { createTypeSafe, backendHost, backendPrice, backendFromEnvironment, modelFromEnvironment, resolveBackend, sentModelId, BACKEND_ENV, MODEL_ENV, DEFAULT_MAX_REQUESTS, DECISIONS_BACKENDS, DEFAULT_BACKEND } from "./client.js";
2
2
  export type { TypeSafe, TypeSafeOptions, EvaluationOptions, Evaluation, UsageSnapshot, SpendReport, TypeSafeBackend, BackendConfig, BackendEndpoint, BackendSpec, RegistryBackendConfig, ResolvedBackend, } from "./client.js";
3
3
  export { ask, DEFAULT_ASK_TIMEOUT_MS } from "./ask.js";
4
4
  export type { AskAnswer, AskOptions, Judge } from "./ask.js";
@@ -1,4 +1,4 @@
1
- export { createTypeSafe, backendHost, backendPrice, resolveBackend, DEFAULT_MAX_REQUESTS, DECISIONS_BACKENDS, DEFAULT_BACKEND } from "./client.js";
1
+ export { createTypeSafe, backendHost, backendPrice, backendFromEnvironment, modelFromEnvironment, resolveBackend, sentModelId, BACKEND_ENV, MODEL_ENV, DEFAULT_MAX_REQUESTS, DECISIONS_BACKENDS, DEFAULT_BACKEND } from "./client.js";
2
2
  export { ask, DEFAULT_ASK_TIMEOUT_MS } from "./ask.js";
3
3
  export { fanOut, DEFAULT_CONCURRENCY, evaluateMany, evaluateAll, chunkEvaluationRequest } from "./batch.js";
4
4
  export { authState, authStatePath, clearAuthState, describeAuth, recordAuthFailure, recordAuthVerified } from "./auth.js";
@@ -1,3 +1,3 @@
1
1
  import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
2
  /** Hidden input in the TUI; falls back to Pi's plain input dialog where custom components are unavailable. */
3
- export declare function promptForApiKey(ctx: ExtensionCommandContext): Promise<string | undefined>;
3
+ export declare function promptForApiKey(ctx: ExtensionCommandContext, label?: string): Promise<string | undefined>;
@@ -11,10 +11,10 @@ class SecretInput extends Input {
11
11
  class KeyPrompt extends Container {
12
12
  input = new SecretInput();
13
13
  isFocused = false;
14
- constructor(theme, done) {
14
+ constructor(theme, label, done) {
15
15
  super();
16
- this.addChild(new Text(theme.fg("accent", theme.bold("TypeSafe API key")), 1, 0));
17
- this.addChild(new Text(theme.fg("muted", "Paste the key from console.typesafe.ai › API Keys. Input is hidden. Enter saves, Esc cancels."), 1, 0));
16
+ this.addChild(new Text(theme.fg("accent", theme.bold(`${label} API key`)), 1, 0));
17
+ this.addChild(new Text(theme.fg("muted", "Paste the key. Input is hidden. Enter saves, Esc cancels."), 1, 0));
18
18
  this.addChild(this.input);
19
19
  this.input.onSubmit = value => done(value);
20
20
  this.input.onEscape = () => done(undefined);
@@ -35,9 +35,9 @@ class KeyPrompt extends Container {
35
35
  }
36
36
  }
37
37
  /** Hidden input in the TUI; falls back to Pi's plain input dialog where custom components are unavailable. */
38
- export async function promptForApiKey(ctx) {
38
+ export async function promptForApiKey(ctx, label = "TypeSafe") {
39
39
  if (typeof ctx.ui.custom === "function") {
40
- return ctx.ui.custom((_tui, theme, _keybindings, done) => new KeyPrompt(theme, done));
40
+ return ctx.ui.custom((_tui, theme, _keybindings, done) => new KeyPrompt(theme, label, done));
41
41
  }
42
- return ctx.ui.input("TypeSafe API key (visible while typing)", "Paste the key, then press Enter");
42
+ return ctx.ui.input(`${label} API key (visible while typing)`, "Paste the key, then press Enter");
43
43
  }
@@ -4,16 +4,18 @@ import type { KeySource } from "./credentials.js";
4
4
  export interface LoginResult {
5
5
  /** Where the verified key was saved. */
6
6
  path: string;
7
- /** Number of models the key can access; proves the key was accepted by the API. */
8
- models: number;
7
+ /** Models the key can access, when the backend's model list proves the key. Absent when one judge request proved it. */
8
+ models?: number;
9
9
  }
10
10
  /**
11
- * Prompt for a TypeSafe key (hidden input), verify it against api.typesafe.ai with a model listing, and store it for
12
- * every pi-typesafe consumer. Resolves to undefined when the user cancels. Rejects with TypeSafeIntegrationError for an
13
- * invalid or unverifiable key. Refuses when TYPESAFE_API_KEY is set, because the environment would shadow the stored
14
- * key. Other backends have no login: their key is an environment variable only.
11
+ * Prompt for one backend's key (hidden input), prove it before saving, and store it for every pi-typesafe consumer.
12
+ * A backend whose model list is public is proved with one judge question instead, because that list accepts any key.
13
+ * Resolves to undefined when the user cancels. Rejects with TypeSafeIntegrationError for an invalid or unverifiable
14
+ * key. Refuses when the backend's environment variable is set, because the environment would shadow the stored key.
15
15
  */
16
- export declare function loginWithPrompt(ctx: ExtensionCommandContext): Promise<LoginResult | undefined>;
16
+ export declare function loginWithPrompt(ctx: ExtensionCommandContext, options?: {
17
+ backend?: BackendSpec;
18
+ }): Promise<LoginResult | undefined>;
17
19
  export type EnsureApiKeyResult = {
18
20
  source: KeySource;
19
21
  login?: undefined;
@@ -24,9 +26,8 @@ export type EnsureApiKeyResult = {
24
26
  /**
25
27
  * Use the configured key for the backend if there is one; otherwise run the login prompt. `undefined` means the user
26
28
  * cancelled. A store that must not be read throws `configuration` with the reason instead of prompting, so a
27
- * permissions problem stays visible; the result shape is frozen for existing callers. A backend without a login store
28
- * (every backend except TypeSafe) throws `configuration` naming its environment variable instead of prompting, because
29
- * the prompt would verify the key against the wrong service and store it where the TypeSafe key lives.
29
+ * permissions problem stays visible; the result shape is frozen for existing callers. Every backend has a login store,
30
+ * so the prompt proves the key against the backend it was asked for and saves it under that backend.
30
31
  */
31
32
  export declare function ensureApiKey(ctx: ExtensionCommandContext, options?: {
32
33
  backend?: BackendSpec;
@@ -1,35 +1,42 @@
1
- import { DEFAULT_BACKEND, resolveBackend, usesTypesafeKey } from "./backends.js";
1
+ import { noul } from "@typesafe-ai/sdk";
2
+ import { DEFAULT_BACKEND, resolveBackend } from "./backends.js";
2
3
  import { createTypeSafe } from "./client.js";
3
4
  import { keySituation, normalizeApiKey, storeApiKey } from "./credentials.js";
4
5
  import { TypeSafeIntegrationError } from "./errors.js";
5
6
  import { promptForApiKey } from "./key-prompt.js";
6
7
  /**
7
- * Prompt for a TypeSafe key (hidden input), verify it against api.typesafe.ai with a model listing, and store it for
8
- * every pi-typesafe consumer. Resolves to undefined when the user cancels. Rejects with TypeSafeIntegrationError for an
9
- * invalid or unverifiable key. Refuses when TYPESAFE_API_KEY is set, because the environment would shadow the stored
10
- * key. Other backends have no login: their key is an environment variable only.
8
+ * Prompt for one backend's key (hidden input), prove it before saving, and store it for every pi-typesafe consumer.
9
+ * A backend whose model list is public is proved with one judge question instead, because that list accepts any key.
10
+ * Resolves to undefined when the user cancels. Rejects with TypeSafeIntegrationError for an invalid or unverifiable
11
+ * key. Refuses when the backend's environment variable is set, because the environment would shadow the stored key.
11
12
  */
12
- export async function loginWithPrompt(ctx) {
13
- if (process.env.TYPESAFE_API_KEY?.trim()) {
14
- throw new TypeSafeIntegrationError("configuration", "TYPESAFE_API_KEY is set in the environment and takes precedence over a stored key. Unset it before logging in interactively.");
13
+ export async function loginWithPrompt(ctx, options = {}) {
14
+ const spec = options.backend ?? DEFAULT_BACKEND;
15
+ const config = resolveBackend(spec);
16
+ if (process.env[config.keyEnv]?.trim()) {
17
+ throw new TypeSafeIntegrationError("configuration", `${config.keyEnv} is set in the environment and takes precedence over a stored key. Unset it before logging in interactively.`);
15
18
  }
16
19
  if (!ctx.hasUI) {
17
- throw new TypeSafeIntegrationError("configuration", "Logging in needs an interactive session. Set TYPESAFE_API_KEY in the environment instead.");
20
+ throw new TypeSafeIntegrationError("configuration", `Logging in needs an interactive session. Set ${config.keyEnv} in the environment instead.`);
18
21
  }
19
- const entered = await promptForApiKey(ctx);
22
+ const entered = await promptForApiKey(ctx, config.label);
20
23
  if (entered === undefined)
21
24
  return undefined;
22
25
  const key = normalizeApiKey(entered);
23
- // Verify before saving so a bad paste fails here, not on first use.
24
- const models = await createTypeSafe({ apiKey: key }).listModels();
25
- return { path: storeApiKey(key), models: models.length };
26
+ const client = createTypeSafe({ apiKey: key, backend: spec });
27
+ if (config.modelsVerifyKey) {
28
+ const models = await client.listModels();
29
+ return { path: storeApiKey(key, spec), models: models.length };
30
+ }
31
+ // A public model list accepts any key; one judge question proves this one.
32
+ await client.evaluate({ state: "login", questions: { key: noul("Is this key accepted?") } });
33
+ return { path: storeApiKey(key, spec) };
26
34
  }
27
35
  /**
28
36
  * Use the configured key for the backend if there is one; otherwise run the login prompt. `undefined` means the user
29
37
  * cancelled. A store that must not be read throws `configuration` with the reason instead of prompting, so a
30
- * permissions problem stays visible; the result shape is frozen for existing callers. A backend without a login store
31
- * (every backend except TypeSafe) throws `configuration` naming its environment variable instead of prompting, because
32
- * the prompt would verify the key against the wrong service and store it where the TypeSafe key lives.
38
+ * permissions problem stays visible; the result shape is frozen for existing callers. Every backend has a login store,
39
+ * so the prompt proves the key against the backend it was asked for and saves it under that backend.
33
40
  */
34
41
  export async function ensureApiKey(ctx, options = {}) {
35
42
  const backend = options.backend ?? DEFAULT_BACKEND;
@@ -38,10 +45,6 @@ export async function ensureApiKey(ctx, options = {}) {
38
45
  return { source: situation.kind };
39
46
  if (situation.kind === "unusable")
40
47
  throw new TypeSafeIntegrationError("configuration", situation.reason);
41
- const config = resolveBackend(backend);
42
- if (!usesTypesafeKey(config)) {
43
- throw new TypeSafeIntegrationError("configuration", `No ${config.label} key. Set ${config.keyEnv} in the environment; /typesafe login stores a TypeSafe key only.`);
44
- }
45
- const login = await loginWithPrompt(ctx);
48
+ const login = await loginWithPrompt(ctx, { backend });
46
49
  return login ? { source: "stored", login } : undefined;
47
50
  }
@@ -19,22 +19,22 @@ export interface BackendLimits {
19
19
  export declare const DEFAULT_BACKEND_LIMITS: BackendLimits;
20
20
  /** The JSON schema used by both the Pi tool and the programmatic interface. */
21
21
  export declare const evaluationSchema: Type.TObject<{
22
- state: Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>;
22
+ state: Type.TUnion<(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[]>;
23
23
  questions: Type.TRecord<"^.*$", Type.TUnion<[Type.TObject<{
24
24
  type: Type.TLiteral<"noul">;
25
- instructions: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
25
+ instructions: Type.TOptional<Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
26
26
  criteria: Type.TOptional<Type.TUnion<[Type.TNull, Type.TObject<{
27
- true: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
28
- false: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
27
+ true: Type.TOptional<Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
28
+ false: Type.TOptional<Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
29
29
  }>]>>;
30
30
  }>, Type.TObject<{
31
31
  type: Type.TLiteral<"choice">;
32
- instructions: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
33
- criteria: Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
32
+ instructions: Type.TOptional<Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
33
+ criteria: Type.TRecord<"^.*$", Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
34
34
  }>, Type.TObject<{
35
35
  type: Type.TLiteral<"score">;
36
- instructions: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
37
- criteria: Type.TArray<Type.TUnion<[Type.TString, Type.TNull, Type.TArray<Type.TUnknown>, Type.TRecord<"^.*$", Type.TUnknown>]>>;
36
+ instructions: Type.TOptional<Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
37
+ criteria: Type.TArray<Type.TUnion<[...(Type.TArray<Type.TUnknown> | Type.TRecord<"^.*$", Type.TUnknown> | Type.TString)[], Type.TNull]>>;
38
38
  }>]>>;
39
39
  model: Type.TOptional<Type.TString>;
40
40
  }>;
@@ -9,12 +9,10 @@ export const DEFAULT_MAX_QUESTIONS = 32;
9
9
  export const DEFAULT_BACKEND_LIMITS = Object.freeze({ maxQuestions: DEFAULT_MAX_QUESTIONS, minChoiceOptions: 1, maxChoiceOptions: 64, maxScoreLevels: 32 });
10
10
  // The API accepts structured descriptions, not only strings. The schema is the only shape guidance the model gets
11
11
  // before its first call, so every field the agent authors says what it means.
12
- const entry = (description) => Type.Union([
13
- Type.String(),
14
- Type.Null(),
15
- Type.Array(Type.Unknown()),
16
- Type.Record(Type.String(), Type.Unknown()),
17
- ], description === undefined ? {} : { description });
12
+ const content = () => [Type.String(), Type.Array(Type.Unknown()), Type.Record(Type.String(), Type.Unknown())];
13
+ const entry = (description) => Type.Union([...content(), Type.Null()], description === undefined ? {} : { description });
14
+ /** `state` alone is non-null: @typesafe-ai/sdk 0.7.0 types it as `NonNullable<EntryType>`. */
15
+ const state = Type.Union(content(), { description: "What to judge: text, or an object whose fields the questions name. Not null." });
18
16
  const instructions = Type.Optional(entry("One judgment about the whole state, phrased as a question or a statement."));
19
17
  const question = Type.Union([
20
18
  Type.Object({
@@ -42,7 +40,7 @@ const question = Type.Union([
42
40
  ]);
43
41
  /** The JSON schema used by both the Pi tool and the programmatic interface. */
44
42
  export const evaluationSchema = Type.Object({
45
- state: entry("What to judge: text, or an object whose fields the questions name."),
43
+ state,
46
44
  questions: Type.Record(Type.String({ minLength: 1, maxLength: 100 }), question, {
47
45
  minProperties: 1,
48
46
  maxProperties: DEFAULT_MAX_QUESTIONS,
@@ -51,6 +49,29 @@ export const evaluationSchema = Type.Object({
51
49
  model: Type.Optional(Type.String({ minLength: 1, maxLength: 100, description: "Jev model id, e.g. jev-latest. Omit for the default." })),
52
50
  }, { additionalProperties: false });
53
51
  const usage = `Expected { state, questions: { <id>: { type: "choice", instructions, criteria: { label: description|null } } | { type: "score", instructions, criteria: [level0, level1, ...] } | { type: "noul", instructions } } }; 1–${DEFAULT_MAX_QUESTIONS} questions, Choice 1–64 options, Score 2–32 levels.`;
52
+ /** Question types this package sends. The SDK also offers `box`, which locates a subject in the request's image. */
53
+ const SUPPORTED_QUESTION_TYPES = new Set(["noul", "choice", "score"]);
54
+ /**
55
+ * Name the two refusals the schema can otherwise only report as a union mismatch: a `box` question, and a `null`
56
+ * state. Both are shapes @typesafe-ai/sdk 0.7.0 added or tightened; neither is something this package can send.
57
+ */
58
+ function refuseUnsupported(value) {
59
+ if (!value || typeof value !== "object" || Array.isArray(value))
60
+ return;
61
+ const request = value;
62
+ if (request.state === null) {
63
+ throw new TypeSafeIntegrationError("validation", `state must not be null: send what to judge as text, an object, or an array. ${usage}`);
64
+ }
65
+ const questions = request.questions;
66
+ if (!questions || typeof questions !== "object" || Array.isArray(questions))
67
+ return;
68
+ for (const [id, question] of Object.entries(questions)) {
69
+ const type = question && typeof question === "object" && !Array.isArray(question) ? question.type : undefined;
70
+ if (typeof type === "string" && !SUPPORTED_QUESTION_TYPES.has(type)) {
71
+ throw new TypeSafeIntegrationError("validation", `Invalid evaluation request at questions.${id.slice(0, 100)}.type: ${JSON.stringify(type.slice(0, 40))} is not a question type this package sends. ${usage}`);
72
+ }
73
+ }
74
+ }
54
75
  /** Paths and messages only; never the submitted values. */
55
76
  function describeSchemaErrors(value) {
56
77
  const details = [];
@@ -67,6 +88,7 @@ export function parseEvaluationRequest(value) {
67
88
  if (value !== null && typeof value === "object" && !Array.isArray(value) && !isJsonSafe(value)) {
68
89
  throw new TypeSafeIntegrationError("validation", `Invalid evaluation request: state and questions must be plain JSON. ${usage}`);
69
90
  }
91
+ refuseUnsupported(value);
70
92
  if (!Check(evaluationSchema, value)) {
71
93
  throw new TypeSafeIntegrationError("validation", `Invalid evaluation request at ${describeSchemaErrors(value)}. ${usage}`);
72
94
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-typesafe",
3
- "version": "0.10.0",
3
+ "version": "0.13.0",
4
4
  "description": "TypeSafe AI (Jev) decisions for Pi: batched Choice/Score/Noul evaluation tool, terminal playground, and a typed API other extensions build on.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -64,7 +64,7 @@
64
64
  "prepack": "npm run build"
65
65
  },
66
66
  "dependencies": {
67
- "@typesafe-ai/sdk": "^0.6.0"
67
+ "@typesafe-ai/sdk": "^0.7.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@earendil-works/pi-coding-agent": "*",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-extensions",
3
- "version": "2026.10.12",
3
+ "version": "2026.10.14",
4
4
  "description": "Aggregate installer for HerbertGao-maintained Pi extensions.",
5
5
  "keywords": [
6
6
  "extensions",
@@ -35,20 +35,20 @@
35
35
  "postpack": "node ../../scripts/aggregate-bundle.mjs restore"
36
36
  },
37
37
  "dependencies": {
38
- "@ast-grep/cli": "0.50.0",
39
- "@ast-grep/napi": "^0.50.0",
38
+ "@ast-grep/cli": "0.51.0",
39
+ "@ast-grep/napi": "^0.51.0",
40
40
  "@dietrichgebert/ponytail": "5.3.2",
41
41
  "@herbertgao/pi-agency": "0.1.2",
42
42
  "@herbertgao/pi-bark": "0.2.1",
43
- "@herbertgao/pi-cc-extensions": "1.0.8-local.1",
43
+ "@herbertgao/pi-cc-extensions": "1.0.11-local.1",
44
44
  "@herbertgao/pi-subagents": "0.22.0-local.2",
45
45
  "@herbertgao/sol-pi": "0.4.2",
46
- "@juicesharp/rpiv-ask-user-question": "2.13.9",
47
- "@juicesharp/rpiv-config": "^2.13.9",
46
+ "@juicesharp/rpiv-ask-user-question": "2.15.0",
47
+ "@juicesharp/rpiv-config": "^2.15.0",
48
48
  "@modelcontextprotocol/sdk": "^1.32.1",
49
49
  "@mozilla/readability": "^0.6.0",
50
50
  "@napi-rs/keyring": "^2.1.0",
51
- "@narumitw/pi-btw": "0.62.0",
51
+ "@narumitw/pi-btw": "0.63.0",
52
52
  "@narumitw/pi-caffeinate": "0.49.12",
53
53
  "@narumitw/pi-tui-kit": "^0.64.0",
54
54
  "@pi-plugins/fast-mode": "0.1.14",
@@ -60,7 +60,7 @@
60
60
  "@tifan/pi-preferred-thinking": "1.0.2",
61
61
  "@tifan/pi-recap": "0.4.8",
62
62
  "@tifan/pi-rename": "0.6.0",
63
- "@typesafe-ai/sdk": "0.6.0",
63
+ "@typesafe-ai/sdk": "0.7.0",
64
64
  "croner": "^10.0.1",
65
65
  "dbus-native": "^0.16.1",
66
66
  "defuddle": "0.19.3",
@@ -72,10 +72,10 @@
72
72
  "nanoid": "^5.0.0",
73
73
  "p-limit": "^6.1.0",
74
74
  "pi-antigravity": "0.11.0",
75
- "pi-lens": "4.4.4",
76
- "pi-next-cue": "1.0.7",
77
- "pi-provider-qoder": "0.6.2",
78
- "pi-typesafe": "0.10.0",
75
+ "pi-lens": "4.4.5",
76
+ "pi-next-cue": "1.0.8",
77
+ "pi-provider-qoder": "0.6.5",
78
+ "pi-typesafe": "0.13.0",
79
79
  "pi-web-access": "0.44.0",
80
80
  "pidusage": "^4.0.1",
81
81
  "promise.try": "^2.0.1",