@herbertgao/pi-extensions 2026.11.19 → 2026.11.21

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 (185) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +10 -10
  3. package/THIRD_PARTY_NOTICES.md +3 -3
  4. package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +8 -0
  5. package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +9 -5
  6. package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +11 -1
  7. package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +1 -1
  8. package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +71 -13
  9. package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +148 -47
  10. package/node_modules/@narumitw/pi-btw/CHANGELOG.md +7 -0
  11. package/node_modules/@narumitw/pi-btw/dist/chunks/{main-tree-picker-3PXJARQW.ts → main-tree-picker-WMTVRTR2.ts} +1 -1
  12. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-WMTVRTR2.ts.map +7 -0
  13. package/node_modules/@narumitw/pi-btw/dist/index.ts +1 -1
  14. package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +6 -0
  15. package/node_modules/@narumitw/pi-btw/package.json +5 -5
  16. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +1 -1
  17. package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +7 -0
  18. package/node_modules/@narumitw/pi-caffeinate/package.json +3 -3
  19. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  20. package/node_modules/pi-lens/CHANGELOG.md +121 -0
  21. package/node_modules/pi-lens/README.md +9 -2
  22. package/node_modules/pi-lens/dist/{chunk-ZVQUYCBU.js → chunk-2ERVW2UF.js} +161 -100
  23. package/node_modules/pi-lens/dist/{chunk-AFSG6YUB.js → chunk-2K7BUOKS.js} +13 -13
  24. package/node_modules/pi-lens/dist/{chunk-BJGWP4UX.js → chunk-3JJ4OAJI.js} +10 -10
  25. package/node_modules/pi-lens/dist/{chunk-GIK6VUCY.js → chunk-3UHGSUVL.js} +1 -1
  26. package/node_modules/pi-lens/dist/{chunk-EKQDQPX6.js → chunk-463WN3VP.js} +1 -1
  27. package/node_modules/pi-lens/dist/{chunk-F7BFIENK.js → chunk-4X3ML2UQ.js} +29 -32
  28. package/node_modules/pi-lens/dist/{chunk-7JMEPY6P.js → chunk-5BI5YP57.js} +10 -10
  29. package/node_modules/pi-lens/dist/{chunk-MKW7ZUTT.js → chunk-5Z4XLUFF.js} +3 -3
  30. package/node_modules/pi-lens/dist/{chunk-NIZKGBOU.js → chunk-62AJH3IN.js} +12 -14
  31. package/node_modules/pi-lens/dist/{chunk-4GLSO2EM.js → chunk-6F34GMP7.js} +12 -12
  32. package/node_modules/pi-lens/dist/{chunk-35UJUF27.js → chunk-6LIUVGOR.js} +13 -3
  33. package/node_modules/pi-lens/dist/{chunk-WJ7GY5WJ.js → chunk-6REF4GCO.js} +1 -1
  34. package/node_modules/pi-lens/dist/{chunk-HFIFEH46.js → chunk-7KRR24GO.js} +3 -3
  35. package/node_modules/pi-lens/dist/{chunk-WAK2AXQQ.js → chunk-7OMOMBEQ.js} +9 -9
  36. package/node_modules/pi-lens/dist/{chunk-S7KUDW73.js → chunk-7ZFXICNN.js} +15 -15
  37. package/node_modules/pi-lens/dist/{chunk-VEF3GFOL.js → chunk-ABKRQVOY.js} +28 -52
  38. package/node_modules/pi-lens/dist/{chunk-Y2LIOCA7.js → chunk-ANSLRJBG.js} +1 -1
  39. package/node_modules/pi-lens/dist/{chunk-ARTCVE6I.js → chunk-AWMFBPGJ.js} +9 -9
  40. package/node_modules/pi-lens/dist/{chunk-H6DNTQ4V.js → chunk-BG7KHGNX.js} +2 -2
  41. package/node_modules/pi-lens/dist/{chunk-FD4LJQ6Y.js → chunk-BK2R2223.js} +10 -8
  42. package/node_modules/pi-lens/dist/{chunk-TWAQFMLW.js → chunk-BXXC6KRR.js} +31 -34
  43. package/node_modules/pi-lens/dist/{chunk-S247BOH2.js → chunk-CKJS2AUI.js} +4 -4
  44. package/node_modules/pi-lens/dist/{chunk-GNK2IHVG.js → chunk-COGU5KQJ.js} +15 -15
  45. package/node_modules/pi-lens/dist/{chunk-P7EV5ISR.js → chunk-CQNXALZJ.js} +12 -6
  46. package/node_modules/pi-lens/dist/{chunk-IO6P3NBP.js → chunk-CSZESDPP.js} +1 -1
  47. package/node_modules/pi-lens/dist/chunk-CZ5TCJPB.js +98 -0
  48. package/node_modules/pi-lens/dist/{chunk-DLGJYQML.js → chunk-D2LFEA5U.js} +9 -2
  49. package/node_modules/pi-lens/dist/chunk-D3KLF5CD.js +50 -0
  50. package/node_modules/pi-lens/dist/{chunk-W2JPGW7Q.js → chunk-ENJ2M76Y.js} +20 -20
  51. package/node_modules/pi-lens/dist/{chunk-2DWNYVUN.js → chunk-EQKF6BAK.js} +3 -3
  52. package/node_modules/pi-lens/dist/{chunk-KIQSNH3F.js → chunk-F2SAP2FM.js} +38 -45
  53. package/node_modules/pi-lens/dist/{chunk-BYIEU4E4.js → chunk-F6QAJXQV.js} +2 -2
  54. package/node_modules/pi-lens/dist/chunk-GR2QDWH5.js +25 -0
  55. package/node_modules/pi-lens/dist/{chunk-T2D2WWP6.js → chunk-GVE5VZYQ.js} +5 -5
  56. package/node_modules/pi-lens/dist/{chunk-HMXWZUQW.js → chunk-GWZZOJD2.js} +1 -1
  57. package/node_modules/pi-lens/dist/chunk-GZS6VPIE.js +27 -0
  58. package/node_modules/pi-lens/dist/chunk-H4B4SC7I.js +71 -0
  59. package/node_modules/pi-lens/dist/{chunk-2RQREVGO.js → chunk-HA6TUJOE.js} +1 -1
  60. package/node_modules/pi-lens/dist/{chunk-NAACKIKT.js → chunk-HKPJTI47.js} +2 -2
  61. package/node_modules/pi-lens/dist/{chunk-NHHS5T52.js → chunk-HPKC55MA.js} +1 -1
  62. package/node_modules/pi-lens/dist/{chunk-B2QO7GHY.js → chunk-I65CQLCG.js} +1 -1
  63. package/node_modules/pi-lens/dist/{chunk-BQ72NQQM.js → chunk-IDKLWVKY.js} +11 -11
  64. package/node_modules/pi-lens/dist/chunk-IUM2Q7NF.js +25 -0
  65. package/node_modules/pi-lens/dist/{chunk-PVV27TOX.js → chunk-J24IS3KZ.js} +5 -5
  66. package/node_modules/pi-lens/dist/{chunk-DKXIUGNA.js → chunk-J2DAHH4T.js} +2 -2
  67. package/node_modules/pi-lens/dist/{chunk-CDAJQBKJ.js → chunk-JBDZVOFL.js} +11 -11
  68. package/node_modules/pi-lens/dist/{chunk-T7KHGEJ5.js → chunk-JC6NFC57.js} +3 -3
  69. package/node_modules/pi-lens/dist/{chunk-BWGNVM33.js → chunk-JTHEUTW7.js} +11 -11
  70. package/node_modules/pi-lens/dist/{chunk-WWZLT6AM.js → chunk-JWW3ODBN.js} +2 -2
  71. package/node_modules/pi-lens/dist/{chunk-Q32RJDYC.js → chunk-K3ZIYLHT.js} +4 -4
  72. package/node_modules/pi-lens/dist/{chunk-LDPY22FS.js → chunk-KDPZA2UE.js} +2 -3
  73. package/node_modules/pi-lens/dist/{chunk-YIEHUKX2.js → chunk-KMY2OU4T.js} +489 -285
  74. package/node_modules/pi-lens/dist/{chunk-WH6O4IFD.js → chunk-KQF7VT26.js} +10 -10
  75. package/node_modules/pi-lens/dist/{chunk-OG3UCAHV.js → chunk-KVGA7X76.js} +3 -3
  76. package/node_modules/pi-lens/dist/{chunk-TABDCX35.js → chunk-KW7O72AK.js} +2 -2
  77. package/node_modules/pi-lens/dist/{chunk-AOEVZXR6.js → chunk-LEQTVRSV.js} +9 -9
  78. package/node_modules/pi-lens/dist/{chunk-7BWPQZHE.js → chunk-LKPSBM6S.js} +3 -3
  79. package/node_modules/pi-lens/dist/{chunk-WA6U2URH.js → chunk-LKW2HFSZ.js} +6 -6
  80. package/node_modules/pi-lens/dist/{chunk-M3QGXGY4.js → chunk-LURFD4HD.js} +624 -97
  81. package/node_modules/pi-lens/dist/{chunk-2YQ5LI7R.js → chunk-M6ELTECW.js} +4 -4
  82. package/node_modules/pi-lens/dist/{chunk-OHTHVILU.js → chunk-MGVVYYKW.js} +12 -12
  83. package/node_modules/pi-lens/dist/{chunk-W2YHHNY3.js → chunk-MQBKGRSB.js} +7 -7
  84. package/node_modules/pi-lens/dist/{chunk-MET776XM.js → chunk-MVG2ZEAO.js} +6 -6
  85. package/node_modules/pi-lens/dist/{chunk-2XALJI2K.js → chunk-MY4XNNTX.js} +39 -41
  86. package/node_modules/pi-lens/dist/{chunk-GFCPPCNR.js → chunk-N4AJVFRF.js} +11 -11
  87. package/node_modules/pi-lens/dist/{chunk-UARVPNAU.js → chunk-OFKKMXWM.js} +31 -36
  88. package/node_modules/pi-lens/dist/{chunk-DHFJS2I4.js → chunk-OFZE4ANN.js} +8 -8
  89. package/node_modules/pi-lens/dist/chunk-OLXBUTJR.js +61 -0
  90. package/node_modules/pi-lens/dist/{chunk-SJ2SR432.js → chunk-OZGEHOSG.js} +38 -17
  91. package/node_modules/pi-lens/dist/{chunk-6MDWNZ7E.js → chunk-PKGOROPQ.js} +40 -2
  92. package/node_modules/pi-lens/dist/{chunk-3IWMNN2S.js → chunk-Q6D5QKRG.js} +17 -17
  93. package/node_modules/pi-lens/dist/{chunk-JGCBMCCS.js → chunk-QECLJFHI.js} +12 -17
  94. package/node_modules/pi-lens/dist/{chunk-KXKM2DFP.js → chunk-QJA33VD5.js} +4 -4
  95. package/node_modules/pi-lens/dist/{chunk-YV7XVYSJ.js → chunk-R5XVJ6AN.js} +11 -11
  96. package/node_modules/pi-lens/dist/{chunk-62PIU4TO.js → chunk-REZL4OM4.js} +1 -1
  97. package/node_modules/pi-lens/dist/{chunk-NNDZ7DOP.js → chunk-RK5RBREN.js} +74 -107
  98. package/node_modules/pi-lens/dist/chunk-RP5ZQTHO.js +86 -0
  99. package/node_modules/pi-lens/dist/{chunk-HKRESBMC.js → chunk-RURPX2YV.js} +23 -23
  100. package/node_modules/pi-lens/dist/chunk-TB5MGZLS.js +53 -0
  101. package/node_modules/pi-lens/dist/chunk-TC63XRYP.js +27 -0
  102. package/node_modules/pi-lens/dist/chunk-TJOYHAXJ.js +69 -0
  103. package/node_modules/pi-lens/dist/{chunk-NZ7NSKIW.js → chunk-TRXKDCBP.js} +13 -13
  104. package/node_modules/pi-lens/dist/{chunk-7WAQ3K26.js → chunk-TTK37D7R.js} +22 -23
  105. package/node_modules/pi-lens/dist/{chunk-ALTHJUZO.js → chunk-UH3QHLR5.js} +2 -2
  106. package/node_modules/pi-lens/dist/{chunk-6MZLS6CK.js → chunk-UNTJJ7GN.js} +7 -7
  107. package/node_modules/pi-lens/dist/{chunk-XRLZ75YY.js → chunk-UPAFSETJ.js} +54 -59
  108. package/node_modules/pi-lens/dist/{chunk-N2U644ZW.js → chunk-UX75PTQW.js} +50 -17
  109. package/node_modules/pi-lens/dist/{chunk-EXHSWN3P.js → chunk-V353PYMK.js} +423 -233
  110. package/node_modules/pi-lens/dist/{chunk-SL4G67AP.js → chunk-V4TFQY5G.js} +2 -2
  111. package/node_modules/pi-lens/dist/{chunk-YOMLAKU6.js → chunk-VC3W54G3.js} +289 -138
  112. package/node_modules/pi-lens/dist/{chunk-KSQJBGRO.js → chunk-VSBCJVPC.js} +5 -5
  113. package/node_modules/pi-lens/dist/{chunk-EBXCYEII.js → chunk-WAQQGXVV.js} +3 -3
  114. package/node_modules/pi-lens/dist/{chunk-7ORBRDFY.js → chunk-WLEVWR7Y.js} +2 -2
  115. package/node_modules/pi-lens/dist/{chunk-Q4UQNTLB.js → chunk-WPMPVP5I.js} +4 -4
  116. package/node_modules/pi-lens/dist/{chunk-TQKWR5AZ.js → chunk-WXNLFOC2.js} +7 -7
  117. package/node_modules/pi-lens/dist/{chunk-HOWHAKXO.js → chunk-Y3ZNOZZS.js} +6 -6
  118. package/node_modules/pi-lens/dist/{chunk-DNJJVKJZ.js → chunk-YL6JQTWC.js} +29 -32
  119. package/node_modules/pi-lens/dist/{chunk-HUWW77QY.js → chunk-YVE5Q2UU.js} +86 -217
  120. package/node_modules/pi-lens/dist/{chunk-25CAONWT.js → chunk-YZNARDMM.js} +12 -9
  121. package/node_modules/pi-lens/dist/{chunk-HERQPNY6.js → chunk-ZDWNFZJ2.js} +8 -8
  122. package/node_modules/pi-lens/dist/{chunk-MKQFSW2Q.js → chunk-ZEUF7BIN.js} +2 -2
  123. package/node_modules/pi-lens/dist/{chunk-AB26NAHA.js → chunk-ZIF4WLWR.js} +45 -25
  124. package/node_modules/pi-lens/dist/{chunk-6MWX2J5H.js → chunk-ZSPVF7KI.js} +227 -24
  125. package/node_modules/pi-lens/dist/{chunk-QQGZY2BR.js → chunk-ZX6OKBVO.js} +2 -2
  126. package/node_modules/pi-lens/dist/index.js +6455 -5243
  127. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +8 -8
  128. package/node_modules/pi-lens/dist/mcp/cli.js +39 -41
  129. package/node_modules/pi-lens/dist/mcp/server.js +870 -559
  130. package/node_modules/pi-lens/dist/mcp/worker.js +68 -59
  131. package/node_modules/pi-lens/dist/probes/installer.js +19 -20
  132. package/node_modules/pi-lens/docs/configuration.md +24 -10
  133. package/node_modules/pi-lens/docs/defect-shapes.md +18 -2
  134. package/node_modules/pi-lens/docs/environment-variables.md +18 -9
  135. package/node_modules/pi-lens/docs/globalconfig.md +16 -0
  136. package/node_modules/pi-lens/docs/invariants/dispatch-runners.md +7 -0
  137. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +33 -3
  138. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +23 -10
  139. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +8 -3
  140. package/node_modules/pi-lens/docs/release-qa-baseline.md +22 -17
  141. package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
  142. package/node_modules/pi-lens/docs/settings.md +9 -2
  143. package/node_modules/pi-lens/docs/tools.md +1 -1
  144. package/node_modules/pi-lens/package.json +3 -3
  145. package/node_modules/pi-typesafe/README.md +1 -1
  146. package/node_modules/pi-typesafe/dist/ask.js +6 -3
  147. package/node_modules/pi-typesafe/dist/auth.d.ts +31 -7
  148. package/node_modules/pi-typesafe/dist/auth.js +159 -55
  149. package/node_modules/pi-typesafe/dist/batch.d.ts +16 -2
  150. package/node_modules/pi-typesafe/dist/batch.js +62 -22
  151. package/node_modules/pi-typesafe/dist/calibrate.d.ts +38 -11
  152. package/node_modules/pi-typesafe/dist/calibrate.js +56 -24
  153. package/node_modules/pi-typesafe/dist/client.d.ts +13 -0
  154. package/node_modules/pi-typesafe/dist/client.js +67 -27
  155. package/node_modules/pi-typesafe/dist/errors.d.ts +20 -0
  156. package/node_modules/pi-typesafe/dist/errors.js +105 -2
  157. package/node_modules/pi-typesafe/dist/extension.d.ts +106 -0
  158. package/node_modules/pi-typesafe/dist/extension.js +206 -106
  159. package/node_modules/pi-typesafe/dist/index.d.ts +8 -8
  160. package/node_modules/pi-typesafe/dist/index.js +3 -3
  161. package/node_modules/pi-typesafe/dist/key-prompt.d.ts +20 -0
  162. package/node_modules/pi-typesafe/dist/key-prompt.js +23 -3
  163. package/node_modules/pi-typesafe/dist/login.d.ts +58 -1
  164. package/node_modules/pi-typesafe/dist/login.js +167 -13
  165. package/node_modules/pi-typesafe/dist/schema.d.ts +3 -0
  166. package/node_modules/pi-typesafe/dist/schema.js +47 -13
  167. package/node_modules/pi-typesafe/dist/ui.d.ts +2 -1
  168. package/node_modules/pi-typesafe/dist/usage.d.ts +53 -0
  169. package/node_modules/pi-typesafe/dist/usage.js +79 -40
  170. package/node_modules/pi-typesafe/package.json +3 -3
  171. package/package.json +8 -8
  172. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-3PXJARQW.ts.map +0 -7
  173. package/node_modules/pi-lens/dist/chunk-3UTDLQWO.js +0 -88
  174. package/node_modules/pi-lens/dist/chunk-3Z7Z3B7V.js +0 -27
  175. package/node_modules/pi-lens/dist/chunk-4E4OCW3L.js +0 -38
  176. package/node_modules/pi-lens/dist/chunk-5HVDD7IA.js +0 -17
  177. package/node_modules/pi-lens/dist/chunk-BKJ6WZKP.js +0 -255
  178. package/node_modules/pi-lens/dist/chunk-D3UQWOCB.js +0 -46
  179. package/node_modules/pi-lens/dist/chunk-EH6EHFW2.js +0 -73
  180. package/node_modules/pi-lens/dist/chunk-J7VNGHLN.js +0 -69
  181. package/node_modules/pi-lens/dist/chunk-L3Q72QGQ.js +0 -25
  182. package/node_modules/pi-lens/dist/chunk-TFSBHRL2.js +0 -25
  183. package/node_modules/pi-lens/dist/chunk-UWBD3JMH.js +0 -56
  184. package/node_modules/pi-lens/dist/chunk-XWWFESYZ.js +0 -27
  185. package/node_modules/pi-lens/dist/chunk-XZSXSM4K.js +0 -27
@@ -148,17 +148,21 @@ extension lists one any other way, and a narrower pi-tui range turned a raw
148
148
  `npm i` with a current pi-tui at the top level into a hard ERESOLVE while
149
149
  `pi install` (which runs `--legacy-peer-deps`) showed users nothing.
150
150
 
151
- The window pi-lens actually supports is therefore not in `package.json`. It is
152
- `PI_HOST_SUPPORTED_RANGE` in `.github/workflows/install-smoke.yml` (the
153
- newest-in-range lane reads it, bounded above so `"*"` can never mean
154
- `@latest`), and `tests/packaging.test.ts` pins it against the hosts this
155
- matrix has passed on. A newer host enters the window in ONE change: run this
156
- matrix on it, add it to that test's verified list, and move the workflow's
157
- ceiling together. P1 is one verified host per minor line from 0.86 onward;
158
- 0.86–1.5 are in-window, and every minor line below 0.86 falls outside the
159
- window entirely, so none needs a dedicated host. A ceiling past an unrun
160
- minor still claims that minor, so the verified-minor ratchet names the admitted
161
- lines explicitly.
151
+ The window pi-lens actually supports is therefore not in `package.json`, and it
152
+ has no hand-kept ceiling (#5749, maintainer decision 2026-11-22). Its lower end
153
+ is `PI_HOST_FLOOR_VERSION` in `.github/workflows/install-smoke.yml`; its upper
154
+ end is always the newest stable pi, the npm dist-tag `latest`. The gating
155
+ newest-in-range lane resolves that tag on every run and installs it (no
156
+ prerelease; if the registry cannot answer, the lane fails closed and never
157
+ falls back to an older host), so a new pi release is exercised by a gating lane
158
+ without anyone bumping a range. `tests/packaging.test.ts` derives the window
159
+ from the floor and pins it against the hosts this matrix has passed on. A
160
+ release-QA run on a newer host extends the `Verified hosts` table below: the
161
+ table is evidence about a host, no longer a gate on the lane.
162
+ P1 is one verified host per minor line from 0.86 onward; 0.86 onward are in-window,
163
+ and every minor line below 0.86 falls outside the window entirely, so none needs
164
+ a dedicated host. A minor line above the newest verified one is inside the window
165
+ and tested by the gating lane, but not release-QA verified until its row lands.
162
166
 
163
167
  The floor is 0.86.1 (#4688, maintainer decision 2026-10-20). 0.80–0.85 are
164
168
  out of the window: since #4644 pi-lens injects context only from a `context`
@@ -171,12 +175,13 @@ the old hosts; a real 0.80.10 session delivered the staged guidance at
171
175
 
172
176
  ### Verified hosts
173
177
 
174
- The certified policy is `>=0.86.1 <1.6.0`, and this table is the whole verified
175
- set: `tests/packaging.test.ts` fails when it and `PI_HOST_SUPPORTED_RANGE`
176
- disagree. Each listed minor line through 1.4 has a release-QA witness; 1.5 was
177
- certified by maintainer decision on 2026-11-02, with its witness blocked by
178
- the lane npm guard. The workflow ceiling
179
- and `tests/packaging.test.ts` list are updated together.
178
+ The certified policy is `>=0.86.1`, with no upper end (the newest stable pi is
179
+ inside the window the day it ships, #5749), and this table is the whole verified set:
180
+ `tests/packaging.test.ts` fails when it and the workflow's floor disagree. Each
181
+ listed minor line through 1.4 has a release-QA witness; 1.5 was certified by
182
+ maintainer decision on 2026-11-02, with its witness blocked by the lane npm
183
+ guard. Add a host here, together with that test's list, after release-QA has
184
+ run on it.
180
185
 
181
186
  | host | date | pi-lens commit | result |
182
187
  | --- | --- | --- | --- |
@@ -6,7 +6,7 @@ server's `initialize` handshake. Generated by `node scripts/server-capabilities.
6
6
  absent on the generating host are listed under *Unavailable* — run in a
7
7
  provisioned environment (the nightly) to capture those rows.
8
8
 
9
- _Last generated: 2026-11-15 on linux; 41 servers captured, 9 unavailable._
9
+ _Last generated: 2026-11-21 on linux; 42 servers captured, 9 unavailable._
10
10
 
11
11
  ## Diagnostic mode + navigation/edit operations
12
12
 
@@ -48,7 +48,12 @@ For a single toggle, highest priority first:
48
48
  project-scoped keys only: the three mutation controls (`format.enabled`,
49
49
  `autofix.enabled`, `actionableWarnings.autoFix.enabled`) and the per-tool
50
50
  switches `tools.<name>.enabled` (`tools.lazy` itself stays global-only). In a
51
- monorepo the closest config to the edited file wins.
51
+ monorepo the closest config to the edited file wins for the three mutation
52
+ controls. The per-tool switches are read once per session from the
53
+ repository's `.pi-lens.json` files at your working directory, up to the git
54
+ root, so a package's own file does not switch a tool off or on. A repository
55
+ with no `.pi-lens.json` of its own still inherits the nearest one above it,
56
+ whole: the git-root limit applies to layered reads, not to that fallback.
52
57
  4. **Global `~/.pi-lens/config.json`**.
53
58
  5. **Built-in default**.
54
59
 
@@ -160,6 +165,8 @@ add a denial but never re-enable one. See
160
165
  | --- | --- | --- | --- |
161
166
  | `ignore` | global + project | `[]` | Gitignore-style globs excluded from every scan |
162
167
  | `widget.visible` | global | `true` | Whether the diagnostics widget shows at session start |
168
+ | `widget.position` | global | `"belowEditor"` | `"aboveEditor"` or `"belowEditor"`: where the widget draws relative to the input box |
169
+ | `widget.hideWhenClean` | global | `false` | Hide the widget 5 s after it first shows `✓ clean`. See [globalconfig](globalconfig.md#widget-position-and-hiding) |
163
170
  | `dispatch.runnerTimeoutFloorMs` | global | none (no floor) | Minimum wall-clock budget per dispatch runner |
164
171
  | `lsp.queryMaxFileLines` | global | `5000` | Line limit of the explicit single-file `lens_diagnostics source=lsp` query only; a whole number from `5000` to `40000` (suggested `20000`). See [globalconfig](globalconfig.md#explicit-diagnostics-query-line-limit) |
165
172
  | `dispatch.disabledRunners` | global + project | `[]` | Dispatch runner ids that never run (for example `["dotnet-build"]`). A denial: the union of every tier, so a project can add but never re-enable. Unknown ids are dropped with a warning. See [configuration](configuration.md#dispatchdisabledrunners--turning-a-dispatch-runner-off) |
@@ -182,7 +189,7 @@ add a denial but never re-enable one. See
182
189
  User-level. The file is selected by the [global-location table](configuration.md#global-config-location)
183
190
  and applies to **every** project. It honors **all** flag keys from the
184
191
  table above plus the non-flag global knobs (`ignore`, `widget.visible`,
185
- `dispatch.runnerTimeoutFloorMs`, `dispatch.disabledRunners`, `format.mode`,
192
+ `widget.position`, `widget.hideWhenClean`, `dispatch.runnerTimeoutFloorMs`, `dispatch.disabledRunners`, `format.mode`,
186
193
  `actionableWarnings.autoFix.maxFixes`, `lsp.queryMaxFileLines`). On Windows the path is
187
194
  `%USERPROFILE%\.pi-lens\config.json`.
188
195
 
@@ -4,7 +4,7 @@ pi-lens registers the following slash commands with the pi host:
4
4
 
5
5
  - `/lens-toggle` — toggle pi-lens on/off for the current session without restarting
6
6
  - `/lens-context-toggle` — toggle automatic context injection on/off for the session (tools/LSP/read-guard/formatting stay active)
7
- - `/lens-widget-toggle` — show/hide the pi-lens diagnostics widget below the editor
7
+ - `/lens-widget-toggle` — show/hide the pi-lens diagnostics widget
8
8
  - `/lens-health` — runtime health, latency, and diagnostic telemetry, including
9
9
  bounded per-session degradation counts (trust refusals, LSP breakers,
10
10
  formatter skips/failures, idle evictions, WASM aborts, timeout tallies, and
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lens",
3
- "version": "4.5.1",
3
+ "version": "4.5.2",
4
4
  "type": "module",
5
5
  "description": "Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo",
6
6
  "repository": {
@@ -131,7 +131,7 @@
131
131
  "banner.png"
132
132
  ],
133
133
  "dependencies": {
134
- "@ast-grep/cli": "0.51.1",
134
+ "@ast-grep/cli": "0.51.2",
135
135
  "@ast-grep/napi": "^0.51.0",
136
136
  "js-yaml": "^5.2.2",
137
137
  "minimatch": "^11.0.4",
@@ -168,7 +168,7 @@
168
168
  ]
169
169
  },
170
170
  "allowScripts": {
171
- "@ast-grep/cli@0.51.1": true,
171
+ "@ast-grep/cli@0.51.2": true,
172
172
  "@google/genai@2.21.0": true,
173
173
  "esbuild@0.28.2": true,
174
174
  "fsevents@2.3.3": false,
@@ -142,7 +142,7 @@ if (!answer.ok) return { skipped: answer.errorCode === "budget" }; // never thr
142
142
 
143
143
  Your extension owns its own user consent and budget; `/typesafe enable` applies only to this package's tool. Check `authState()` rather than your own consent flag before you report that judgments are on.
144
144
 
145
- Judgments can also go through OpenRouter: `createTypeSafe({ backend: "openrouter" })` sends them to `openrouter.ai` with the key from `OPENROUTER_API_KEY`. Command Code serves the same protocol: `createTypeSafe({ backend: "commandcode" })` sends them to `api.commandcode.ai` with the key from `COMMANDCODE_API_KEY` and the model `typesafe/jev`. So does Liquid AI: `createTypeSafe({ backend: "liquid" })` sends them to `api.liquid.ai` with the key from `LIQUID_API_KEY` and the model `d1:free`, which is free; pass `model: "d1"` for the paid model, priced at $0.040 per million input tokens. Liquid counts the state once per question, where TypeSafe counts it once per request, so a request with N questions costs about N times the state on Liquid. Speed, measured on 2026-10-03 with one request at a time: `d1:free` took a median of about 14 seconds and sometimes failed with HTTP 504 after about 46 seconds, while `d1` took about 0.5 seconds. With `d1:free`, raise `timeoutMs` above its 15-second default, or pass `model: "d1"`. SubQ too: `createTypeSafe({ backend: "subq" })` sends them to `api.subq.ai` with the key from `SUBQ_API_KEY` and the model `subq-snap-preview`, priced at $0.05 per million input tokens. SubQ takes at most 16 questions in one request, a Choice of at least 2 options, and a Score of at most 10 levels: `evaluate` refuses a larger request before it sends it, `evaluateAll` splits to 16, and `client.limits` tells you the limit without a request. Nace.AI serves Drex the same way: `createTypeSafe({ backend: "nace" })` sends judgments to `console.nace.ai` with the key from `NACE_API_KEY` and the model `drex-v2.0`, priced at $0.060 per million input tokens; `drex-v1.5` is $0.050, and `drex-max` and `drex-max-v1.1` are $0.030. Nace accepted every request shape the schema allows, so it declares no narrower limits. Drex holds a request for up to 55 seconds upstream, so raise `timeoutMs` above its 15-second default for a heavy request. Or pass a `BackendEndpoint` object as `backend` to name any host that serves the protocol: it brings its own key variable, never reads `TYPESAFE_API_KEY`, and `backendHost()` reports its destination host for your consent text. Each backend's key can also be stored with `/typesafe login <backend>`: it prompts once, proves the key with the backend's model list where that list checks the key and otherwise with one judge request, and saves it under that backend's name, so a key stored for one backend is never sent to another. A backend's own environment variable still wins over its stored key. Pass the same `backend` to `authState`, `keySituation`, and `ensureApiKey`, or the status you report describes the TypeSafe key while the requests use another one. The `/typesafe` commands and the `typesafe_evaluate` tool follow `PI_TYPESAFE_BACKEND` (`typesafe` by default) and name that backend's host, key variable, and model in their consent and status text — so the extension sends judgments where it says it sends them. A name the registry does not know is a `configuration` error at session start, not a silent fallback. `PI_TYPESAFE_MODEL` overrides the backend's default model, written as that backend's own id is written (`jev-1.14`; it is mapped to the backend's id form, so OpenRouter sends `typesafe/jev-1.14`). `/typesafe login [backend]` and `/typesafe logout [backend]` act on the backend they name, or on the session's own backend when they name none, and on a backend whose environment variable is set they say that the variable wins. Every export — the client, `ask`, batching, the usage ledger, auth state, the `PI_TYPESAFE_BACKEND` and `PI_TYPESAFE_MODEL` readers, and the `pi-typesafe/calibrate` and `pi-typesafe/ui` entry points — is in [docs/api.md](docs/api.md).
145
+ Judgments can also go through OpenRouter: `createTypeSafe({ backend: "openrouter" })` sends them to `openrouter.ai` with the key from `OPENROUTER_API_KEY`. Command Code serves the same protocol: `createTypeSafe({ backend: "commandcode" })` sends them to `api.commandcode.ai` with the key from `COMMANDCODE_API_KEY` and the model `typesafe/jev`. So does Liquid AI: `createTypeSafe({ backend: "liquid" })` sends them to `api.liquid.ai` with the key from `LIQUID_API_KEY` and the model `d1:free`, which is free; pass `model: "d1"` for the paid model, priced at $0.040 per million input tokens. Liquid counts the state once per question, where TypeSafe counts it once per request, so a request with N questions costs about N times the state on Liquid. Speed, measured on 2026-10-03 with one request at a time: `d1:free` took a median of about 14 seconds and sometimes failed with HTTP 504 after about 46 seconds, while `d1` took about 0.5 seconds. With `d1:free`, raise `timeoutMs` above its 15-second default, or pass `model: "d1"`. SubQ too: `createTypeSafe({ backend: "subq" })` sends them to `api.subq.ai` with the key from `SUBQ_API_KEY` and the model `subq-snap-preview`, priced at $0.05 per million input tokens. SubQ takes at most 16 questions in one request, a Choice of at least 2 options, and a Score of at most 10 levels: `evaluate` refuses a larger request before it sends it, `evaluateAll` splits to 16, and `client.limits` tells you the limit without a request. Nace.AI serves Drex the same way: `createTypeSafe({ backend: "nace" })` sends judgments to `console.nace.ai` with the key from `NACE_API_KEY` and the model `drex-v2.0`, priced at $0.060 per million input tokens; `drex-v1.5` is $0.050, and `drex-max` and `drex-max-v1.1` are $0.030. Nace accepted every request shape the schema allows, so it declares no narrower limits. Drex holds a request for up to 55 seconds upstream, so raise `timeoutMs` above its 15-second default for a heavy request. Or pass a `BackendEndpoint` object as `backend` to name any host that serves the protocol: it brings its own key variable, never reads `TYPESAFE_API_KEY`, and `backendHost()` reports its destination host for your consent text. Each backend's key can also be stored with `/typesafe login <backend>`: it prompts once, proves the key with the backend's model list where that list checks the key and otherwise with one isolated judge request (without writing `usage.json`, hitting daily caps, or overwriting `auth-state.json` on a rejected candidate key), and saves it under that backend's name, so a key stored for one backend is never sent to another. A backend's own environment variable still wins over its stored key. Pass the same `backend` to `authState`, `keySituation`, and `ensureApiKey`, or the status you report describes the TypeSafe key while the requests use another one. The `/typesafe` commands and the `typesafe_evaluate` tool follow `PI_TYPESAFE_BACKEND` (`typesafe` by default) and name that backend's host, key variable, and model in their consent and status text — so the extension sends judgments where it says it sends them. A name the registry does not know is a `configuration` error at session start, not a silent fallback: `/typesafe login`, `logout`, `setup`, `enable`, `test`, and `playground` all decline until `PI_TYPESAFE_BACKEND` is fixed or unset. `PI_TYPESAFE_MODEL` overrides the backend's default model, written as that backend's own id is written (`jev-1.14`; it is mapped to the backend's id form, so OpenRouter sends `typesafe/jev-1.14`). `/typesafe login [backend]` and `/typesafe logout [backend]` act on the backend they name, or on the session's own backend when they name none, and on a backend whose environment variable is set they say that the variable wins. Every export — the client, `ask`, batching, the usage ledger, auth state, the `PI_TYPESAFE_BACKEND` and `PI_TYPESAFE_MODEL` readers, and the `pi-typesafe/calibrate` and `pi-typesafe/ui` entry points — is in [docs/api.md](docs/api.md).
146
146
 
147
147
  ## Development
148
148
 
@@ -1,4 +1,4 @@
1
- import { TypeSafeIntegrationError } from "./errors.js";
1
+ import { TypeSafeIntegrationError, attachErrorDisposition } from "./errors.js";
2
2
  /** Default per-ask deadline; matches the client's own request timeout. */
3
3
  export const DEFAULT_ASK_TIMEOUT_MS = 15_000;
4
4
  const FALLBACK_MESSAGE = "TypeSafe request failed.";
@@ -22,8 +22,11 @@ export async function ask(judge, request, options = {}) {
22
22
  return { ok: true, answers: result.answers, model: result.model, usage: result.usage, elapsedMs: result.elapsedMs };
23
23
  }
24
24
  catch (error) {
25
- if (error instanceof TypeSafeIntegrationError)
26
- return { ok: false, error: error.message, errorCode: error.code };
25
+ if (error instanceof TypeSafeIntegrationError) {
26
+ const failed = { ok: false, error: error.message, errorCode: error.code };
27
+ attachErrorDisposition(failed, error.disposition);
28
+ return failed;
29
+ }
27
30
  return { ok: false, error: FALLBACK_MESSAGE };
28
31
  }
29
32
  finally {
@@ -20,6 +20,28 @@ export interface AuthFailure {
20
20
  readonly message: string;
21
21
  readonly at: string;
22
22
  }
23
+ /** Explicit auth breaker state for one backend. */
24
+ export type AuthStatus = "missing" | "unusable" | "rejected" | "rejection_expired" | "unverified" | "verified";
25
+ /** Persisted per-backend auth record written through `transitionAuthRecord`. */
26
+ export interface AuthRecord {
27
+ readonly verifiedAt?: string;
28
+ readonly lastFailure?: AuthFailure;
29
+ }
30
+ export type AuthEvent = {
31
+ readonly type: "verified";
32
+ readonly at: string;
33
+ } | {
34
+ readonly type: "failed";
35
+ readonly failure: AuthFailure;
36
+ } | {
37
+ readonly type: "cleared";
38
+ };
39
+ export interface AuthWriteOptions {
40
+ readonly backend?: BackendSpec;
41
+ readonly path?: string;
42
+ }
43
+ /** Single-writer pure transition reducer for one backend's persisted auth record. */
44
+ export declare function transitionAuthRecord(record: AuthRecord, event: AuthEvent): AuthRecord;
23
45
  /**
24
46
  * The whole answer to "is Jev actually available right now": which key is in effect, whether it has been accepted, and
25
47
  * the last failure that degraded it. Consumers must consult this instead of treating their own consent flag as proof
@@ -28,6 +50,8 @@ export interface AuthFailure {
28
50
  export interface AuthState {
29
51
  /** The judgment backend this state describes; each backend has its own key. Holds the value the caller passed. */
30
52
  readonly backend: BackendSpec;
53
+ /** Explicit auth breaker state derived from key presence, persisted record, and the rejection window. */
54
+ readonly status: AuthStatus;
31
55
  /** Same kinds as KeySituation: where the key in effect comes from. */
32
56
  readonly kind: "environment" | "stored" | "missing" | "unusable";
33
57
  readonly source?: KeySource;
@@ -39,8 +63,8 @@ export interface AuthState {
39
63
  readonly keyName: string;
40
64
  /**
41
65
  * True when the key in effect was accepted by the backend (a login proves the backend it was asked for; a successful
42
- * request proves any key). A 401 rejection younger than `AUTH_REJECTION_TTL_MS` clears it; a 403 never does. The
43
- * record is shared across backends: switching backends keeps the last outcome until the next request.
66
+ * request proves any key). A 401 rejection younger than `AUTH_REJECTION_TTL_MS` clears it; a 403 never does. Each
67
+ * backend keeps its own record in `auth-state.json`.
44
68
  */
45
69
  readonly verified: boolean;
46
70
  readonly verifiedAt?: string;
@@ -64,11 +88,11 @@ export declare function authState(options?: {
64
88
  backend?: BackendSpec;
65
89
  }): AuthState;
66
90
  /** Record that the key was accepted: login verification, or any successful request. Clears the last failure. */
67
- export declare function recordAuthVerified(at?: Date): void;
68
- /** Record the failure that degraded TypeSafe. The verification timestamp is kept so a recovered key stays known. */
69
- export declare function recordAuthFailure(error: TypeSafeIntegrationError, at?: Date): void;
70
- /** Forget verification and degradation: used when the key itself changes (login or logout). */
71
- export declare function clearAuthState(): void;
91
+ export declare function recordAuthVerified(at?: Date, options?: AuthWriteOptions): void;
92
+ /** Record the failure that degraded a backend. The verification timestamp is kept so a recovered key stays known. */
93
+ export declare function recordAuthFailure(error: TypeSafeIntegrationError, at?: Date, options?: AuthWriteOptions): void;
94
+ /** Forget verification and degradation: removes the whole file with no backend, or clears only that backend's entry. */
95
+ export declare function clearAuthState(options?: BackendSpec | AuthWriteOptions): void;
72
96
  export interface AuthReport {
73
97
  /**
74
98
  * `error` when judgments will fail or the key was rejected, `warning` when the key is unverified or its rejection has
@@ -1,12 +1,15 @@
1
1
  import { chmodSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { DEFAULT_BACKEND, TYPESAFE_KEY_ENV, resolveBackend } from "./backends.js";
4
- import { credentialsPath, keySituation, keySourceLabel, piTypesafeDir } from "./credentials.js";
2
+ import { dirname, join } from "node:path";
3
+ import { DEFAULT_BACKEND, resolveBackend } from "./backends.js";
4
+ import { credentialId, credentialsPath, keySituation, keySourceLabel, piTypesafeDir } from "./credentials.js";
5
5
  import { TypeSafeIntegrationError } from "./errors.js";
6
6
  const AUTH_VERSION = 1;
7
7
  const CODES = new Set([
8
8
  "configuration", "validation", "budget", "aborted", "timeout", "http", "connection", "response",
9
9
  ]);
10
+ function assertNever(value) {
11
+ throw new Error(`Unexpected auth state: ${String(value)}`);
12
+ }
10
13
  /**
11
14
  * How long a stored 401 vetoes the key. The next request proves the key again once the window passes, so one refusal
12
15
  * cannot disable judgments for good. Fifteen minutes is a policy choice, not a measured provider constant.
@@ -20,47 +23,101 @@ export const AUTH_REJECTION_TTL_MS = 15 * 60 * 1000;
20
23
  export function isKeyRejection(status) {
21
24
  return status === 401;
22
25
  }
26
+ /** Single-writer pure transition reducer for one backend's persisted auth record. */
27
+ export function transitionAuthRecord(record, event) {
28
+ switch (event.type) {
29
+ case "verified":
30
+ return { verifiedAt: event.at };
31
+ case "failed":
32
+ return {
33
+ ...(record.verifiedAt === undefined ? {} : { verifiedAt: record.verifiedAt }),
34
+ lastFailure: event.failure,
35
+ };
36
+ case "cleared":
37
+ return {};
38
+ default:
39
+ return assertNever(event);
40
+ }
41
+ }
23
42
  /** `fresh` still vetoes the key, `expired` is only a record of what was refused when: no schema change, no manual reset. */
24
- function rejectionOf(failure) {
43
+ function rejectionOf(failure, nowMs) {
25
44
  if (failure === undefined || failure.code !== "http" || !isKeyRejection(failure.status))
26
45
  return "none";
27
46
  const at = Date.parse(failure.at);
28
47
  // A timestamp this code cannot read cannot prove the rejection is current, so it counts as spent.
29
48
  if (!Number.isFinite(at))
30
49
  return "expired";
31
- return Date.now() - at < AUTH_REJECTION_TTL_MS ? "fresh" : "expired";
50
+ return nowMs - at < AUTH_REJECTION_TTL_MS ? "fresh" : "expired";
51
+ }
52
+ function evaluateAuth(situation, record, nowMs) {
53
+ const rejection = rejectionOf(record.lastFailure, nowMs);
54
+ const status = situation.kind === "missing" ? "missing"
55
+ : situation.kind === "unusable" ? "unusable"
56
+ : rejection === "fresh" ? "rejected"
57
+ : rejection === "expired" ? "rejection_expired"
58
+ : record.verifiedAt === undefined ? "unverified"
59
+ : "verified";
60
+ const usable = status !== "missing" && status !== "unusable" && status !== "rejected";
61
+ // Keeps `verified` aligned with `verifiedAt` whenever no fresh 401 stands against it (including expired 401s).
62
+ const verified = record.verifiedAt !== undefined && rejection !== "fresh";
63
+ return { status, usable, verified };
32
64
  }
33
65
  /** The auth-state file: one small, owner-only record that outlives the process that wrote it. */
34
66
  export function authStatePath() {
35
67
  return join(piTypesafeDir(), "auth-state.json");
36
68
  }
37
- function readState(path) {
69
+ function parseRecord(raw) {
70
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
71
+ return {};
72
+ const obj = raw;
73
+ const verifiedAt = typeof obj.verifiedAt === "string" && obj.verifiedAt.length <= 40 ? obj.verifiedAt : undefined;
74
+ const failure = obj.lastFailure && typeof obj.lastFailure === "object" && !Array.isArray(obj.lastFailure)
75
+ ? obj.lastFailure
76
+ : undefined;
77
+ const code = typeof failure?.code === "string" && CODES.has(failure.code) ? failure.code : undefined;
78
+ const message = typeof failure?.message === "string" ? failure.message.slice(0, 300) : undefined;
79
+ const at = typeof failure?.at === "string" && failure.at.length <= 40 ? failure.at : undefined;
80
+ const status = typeof failure?.status === "number" && Number.isSafeInteger(failure.status) ? failure.status : undefined;
81
+ const lastFailure = code && message && at
82
+ ? { code, message, at, ...(status === undefined ? {} : { status }) }
83
+ : undefined;
84
+ return { ...(verifiedAt === undefined ? {} : { verifiedAt }), ...(lastFailure === undefined ? {} : { lastFailure }) };
85
+ }
86
+ function isNonEmptyRecord(record) {
87
+ return record.verifiedAt !== undefined || record.lastFailure !== undefined;
88
+ }
89
+ function readStateMap(path) {
90
+ const map = Object.create(null);
38
91
  try {
39
92
  const parsed = JSON.parse(readFileSync(path, "utf8"));
40
- if (!parsed || typeof parsed !== "object")
41
- return {};
93
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
94
+ return map;
42
95
  const raw = parsed;
43
- const verifiedAt = typeof raw.verifiedAt === "string" && raw.verifiedAt.length <= 40 ? raw.verifiedAt : undefined;
44
- const failure = raw.lastFailure && typeof raw.lastFailure === "object" ? raw.lastFailure : undefined;
45
- const code = typeof failure?.code === "string" && CODES.has(failure.code) ? failure.code : undefined;
46
- const message = typeof failure?.message === "string" ? failure.message.slice(0, 300) : undefined;
47
- const at = typeof failure?.at === "string" && failure.at.length <= 40 ? failure.at : undefined;
48
- const status = typeof failure?.status === "number" && Number.isSafeInteger(failure.status) ? failure.status : undefined;
49
- const lastFailure = code && message && at
50
- ? { code, message, at, ...(status === undefined ? {} : { status }) }
51
- : undefined;
52
- return { ...(verifiedAt === undefined ? {} : { verifiedAt }), ...(lastFailure === undefined ? {} : { lastFailure }) };
96
+ if (raw.backends && typeof raw.backends === "object" && !Array.isArray(raw.backends)) {
97
+ for (const [id, entry] of Object.entries(raw.backends)) {
98
+ const record = parseRecord(entry);
99
+ if (isNonEmptyRecord(record))
100
+ map[id] = record;
101
+ }
102
+ }
103
+ // Pre-per-backend files hold top-level verifiedAt/lastFailure; heal them into DEFAULT_BACKEND on read.
104
+ if (!(DEFAULT_BACKEND in map)) {
105
+ const legacy = parseRecord(raw);
106
+ if (isNonEmptyRecord(legacy))
107
+ map[DEFAULT_BACKEND] = legacy;
108
+ }
109
+ return map;
53
110
  }
54
111
  catch {
55
- return {};
112
+ return map;
56
113
  }
57
114
  }
58
115
  /** Owner-only, atomic, and best-effort: an unwritable auth record never changes how a request behaves. */
59
- function writeState(path, state) {
116
+ function writeStateMap(path, backends) {
60
117
  const temporary = `${path}.${process.pid}.tmp`;
61
118
  try {
62
- mkdirSync(piTypesafeDir(), { recursive: true, mode: 0o700 });
63
- writeFileSync(temporary, `${JSON.stringify({ version: AUTH_VERSION, ...state }, null, 2)}\n`, { mode: 0o600, flag: "w" });
119
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
120
+ writeFileSync(temporary, `${JSON.stringify({ version: AUTH_VERSION, backends: { ...backends } }, null, 2)}\n`, { mode: 0o600, flag: "w" });
64
121
  chmodSync(temporary, 0o600);
65
122
  renameSync(temporary, path);
66
123
  }
@@ -71,6 +128,9 @@ function writeState(path, state) {
71
128
  catch { /* best-effort cleanup only */ }
72
129
  }
73
130
  }
131
+ function isBackendEndpoint(value) {
132
+ return "host" in value || "label" in value || "keyEnv" in value;
133
+ }
74
134
  /**
75
135
  * What the key situation, the last outcome, and the clock add up to for a valid backend; it never throws for one. An
76
136
  * invalid backend throws the same `configuration` error as resolveBackend(), so validate a user-supplied endpoint
@@ -80,44 +140,87 @@ export function authState(options = {}) {
80
140
  const path = options.path ?? authStatePath();
81
141
  const backend = options.backend ?? DEFAULT_BACKEND;
82
142
  const situation = keySituation(backend);
83
- const stored = readState(path);
143
+ const stored = readStateMap(path)[credentialId(backend)] ?? {};
84
144
  const source = situation.kind === "environment" ? "environment" : situation.kind === "stored" ? "stored" : undefined;
85
- const rejected = rejectionOf(stored.lastFailure) === "fresh";
86
- const usable = source !== undefined && !rejected;
145
+ const { status, usable, verified } = evaluateAuth(situation, stored, Date.now());
87
146
  return {
88
147
  backend,
148
+ status,
89
149
  kind: situation.kind,
90
150
  ...(source === undefined ? {} : { source }),
91
151
  path: situation.kind === "unusable" ? situation.path : credentialsPath(),
92
152
  ...(situation.kind === "unusable" ? { reason: situation.reason } : {}),
93
153
  keyName: keySourceLabel(situation),
94
- verified: stored.verifiedAt !== undefined && !rejected,
154
+ verified,
95
155
  ...(stored.verifiedAt === undefined ? {} : { verifiedAt: stored.verifiedAt }),
96
156
  ...(stored.lastFailure === undefined ? {} : { lastFailure: stored.lastFailure }),
97
157
  usable,
98
158
  };
99
159
  }
100
160
  /** Record that the key was accepted: login verification, or any successful request. Clears the last failure. */
101
- export function recordAuthVerified(at = new Date()) {
102
- writeState(authStatePath(), { verifiedAt: at.toISOString() });
161
+ export function recordAuthVerified(at = new Date(), options = {}) {
162
+ const path = options.path ?? authStatePath();
163
+ const id = credentialId(options.backend);
164
+ const map = readStateMap(path);
165
+ map[id] = transitionAuthRecord(map[id] ?? {}, { type: "verified", at: at.toISOString() });
166
+ writeStateMap(path, map);
103
167
  }
104
- /** Record the failure that degraded TypeSafe. The verification timestamp is kept so a recovered key stays known. */
105
- export function recordAuthFailure(error, at = new Date()) {
106
- const current = readState(authStatePath());
168
+ /** Record the failure that degraded a backend. The verification timestamp is kept so a recovered key stays known. */
169
+ export function recordAuthFailure(error, at = new Date(), options = {}) {
170
+ const path = options.path ?? authStatePath();
171
+ const id = credentialId(options.backend);
172
+ const map = readStateMap(path);
107
173
  const failure = {
108
174
  code: error.code,
109
175
  message: error.message,
110
176
  at: at.toISOString(),
111
177
  ...(error.status === undefined ? {} : { status: error.status }),
112
178
  };
113
- writeState(authStatePath(), { ...(current.verifiedAt === undefined ? {} : { verifiedAt: current.verifiedAt }), lastFailure: failure });
179
+ map[id] = transitionAuthRecord(map[id] ?? {}, { type: "failed", failure });
180
+ writeStateMap(path, map);
114
181
  }
115
- /** Forget verification and degradation: used when the key itself changes (login or logout). */
116
- export function clearAuthState() {
117
- try {
118
- rmSync(authStatePath(), { force: true });
182
+ /** Forget verification and degradation: removes the whole file with no backend, or clears only that backend's entry. */
183
+ export function clearAuthState(options) {
184
+ let backend;
185
+ let path = authStatePath();
186
+ if (typeof options === "string") {
187
+ backend = options;
188
+ }
189
+ else if (options !== undefined) {
190
+ if (isBackendEndpoint(options)) {
191
+ backend = options;
192
+ }
193
+ else {
194
+ backend = options.backend;
195
+ if (options.path !== undefined)
196
+ path = options.path;
197
+ }
198
+ }
199
+ if (backend === undefined) {
200
+ try {
201
+ rmSync(path, { force: true });
202
+ }
203
+ catch { /* nothing to clear */ }
204
+ return;
205
+ }
206
+ const id = credentialId(backend);
207
+ const map = readStateMap(path);
208
+ if (!(id in map))
209
+ return;
210
+ const next = transitionAuthRecord(map[id] ?? {}, { type: "cleared" });
211
+ if (!isNonEmptyRecord(next))
212
+ delete map[id];
213
+ else
214
+ map[id] = next;
215
+ if (Object.keys(map).length === 0) {
216
+ try {
217
+ rmSync(path, { force: true });
218
+ }
219
+ catch { /* nothing to clear */ }
220
+ }
221
+ else {
222
+ writeStateMap(path, map);
119
223
  }
120
- catch { /* nothing to clear */ }
121
224
  }
122
225
  /**
123
226
  * One line plus a level, so a status command, a headless log, or a consumer's own status line can call out a degraded
@@ -127,23 +230,24 @@ export function describeAuth(state = authState()) {
127
230
  const config = resolveBackend(state.backend);
128
231
  const label = `${config.label} key`;
129
232
  const since = state.lastFailure ? ` Last failure: ${state.lastFailure.message}${state.lastFailure.at ? ` (${state.lastFailure.at})` : ""}` : "";
130
- if (state.kind === "missing") {
131
- const how = `a key is configured (/typesafe login${config.name && config.name !== DEFAULT_BACKEND ? ` ${config.name}` : ""} or ${config.keyEnv})`;
132
- return { level: "error", text: `${label}: missing — every Jev judgment will fail until ${how}.${since}` };
133
- }
134
- if (state.kind === "unusable") {
135
- return { level: "error", text: `${label}: unusable (${state.reason ?? "unknown reason"}) — judgments will fail until the key is fixed.${since}` };
136
- }
137
- const rejection = rejectionOf(state.lastFailure);
138
- if (rejection === "fresh") {
139
- return { level: "error", text: `${label}: ${state.keyName} was rejected.${since}` };
140
- }
141
- if (rejection === "expired") {
142
- const at = state.lastFailure?.at;
143
- return { level: "warning", text: `${label}: ${state.keyName} was rejected${at === undefined ? "" : ` at ${at}`}; that rejection expired, so the next request proves the key.` };
144
- }
145
- if (!state.verified) {
146
- return { level: "warning", text: `${label}: ${state.keyName} (not verified yet — the first request proves it).${since}` };
233
+ switch (state.status) {
234
+ case "missing": {
235
+ const how = `a key is configured (/typesafe login${config.name && config.name !== DEFAULT_BACKEND ? ` ${config.name}` : ""} or ${config.keyEnv})`;
236
+ return { level: "error", text: `${label}: missing — every Jev judgment will fail until ${how}.${since}` };
237
+ }
238
+ case "unusable":
239
+ return { level: "error", text: `${label}: unusable (${state.reason ?? "unknown reason"}) — judgments will fail until the key is fixed.${since}` };
240
+ case "rejected":
241
+ return { level: "error", text: `${label}: ${state.keyName} was rejected.${since}` };
242
+ case "rejection_expired": {
243
+ const at = state.lastFailure?.at;
244
+ return { level: "warning", text: `${label}: ${state.keyName} was rejected${at === undefined ? "" : ` at ${at}`}; that rejection expired, so the next request proves the key.` };
245
+ }
246
+ case "unverified":
247
+ return { level: "warning", text: `${label}: ${state.keyName} (not verified yet — the first request proves it).${since}` };
248
+ case "verified":
249
+ return { level: "ok", text: `${label}: ${state.keyName} (verified${state.verifiedAt ? ` ${state.verifiedAt}` : ""}).${since}` };
250
+ default:
251
+ return assertNever(state.status);
147
252
  }
148
- return { level: "ok", text: `${label}: ${state.keyName} (verified${state.verifiedAt ? ` ${state.verifiedAt}` : ""}).${since}` };
149
253
  }
@@ -1,18 +1,32 @@
1
1
  import type { Questions, SystemOneRequest, Usage } from "@typesafe-ai/sdk";
2
2
  import type { Evaluation, TypeSafe } from "./client.js";
3
+ import { TypeSafeIntegrationError } from "./errors.js";
3
4
  import type { BackendSpec } from "./backends.js";
4
5
  /** Default number of requests in flight. TypeSafe answers in isolation, so a small pool is enough. */
5
6
  export declare const DEFAULT_CONCURRENCY = 4;
6
- /** One item's outcome. `skipped` marks work that was never started because of an abort or a stop rule. */
7
+ /** Terminal state of one item in a batch. */
8
+ export type SettledStatus = "succeeded" | "failed" | "skipped";
9
+ /** Why an unstarted batch item was skipped. */
10
+ export type SkipReason = "aborted" | "stopped";
11
+ /** One item's outcome. `status` discriminates every terminal state while keeping `ok` and `skipped` narrowable. */
7
12
  export type Settled<T> = {
13
+ readonly status: "succeeded";
8
14
  readonly ok: true;
9
15
  readonly index: number;
10
16
  readonly value: T;
11
17
  } | {
18
+ readonly status: "failed";
12
19
  readonly ok: false;
20
+ readonly skipped: false;
13
21
  readonly index: number;
14
22
  readonly error: unknown;
15
- readonly skipped: boolean;
23
+ } | {
24
+ readonly status: "skipped";
25
+ readonly ok: false;
26
+ readonly skipped: true;
27
+ readonly skipReason: SkipReason;
28
+ readonly index: number;
29
+ readonly error: TypeSafeIntegrationError;
16
30
  };
17
31
  export interface FanOutOptions {
18
32
  /** Requests in flight at once. Default: DEFAULT_CONCURRENCY. */