@daniel156161/prism 0.2.59 → 0.2.76

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 (1292) hide show
  1. package/README.md +26 -0
  2. package/dist/cli.js +0 -0
  3. package/dist/pi/pi-env.d.ts +1 -1
  4. package/dist/pi/pi-env.js +1 -1
  5. package/dist/pi/pi-extensions.js +2 -0
  6. package/dist/pi/pi-extensions.js.map +1 -1
  7. package/dist/pi/pi-patch-extension-loader.js +1 -0
  8. package/dist/pi/pi-patch-extension-loader.js.map +1 -1
  9. package/dist/pi/pi-patch-interactive.d.ts +1 -0
  10. package/dist/pi/pi-patch-interactive.js +11 -2
  11. package/dist/pi/pi-patch-interactive.js.map +1 -1
  12. package/dist/prism-extensions/integrations/ai-memory-system.d.ts +7 -0
  13. package/dist/prism-extensions/integrations/ai-memory-system.js +316 -0
  14. package/dist/prism-extensions/integrations/ai-memory-system.js.map +1 -0
  15. package/dist/prism-extensions/integrations/obsidian-formatting.d.ts +3 -0
  16. package/dist/prism-extensions/integrations/obsidian-formatting.js +53 -0
  17. package/dist/prism-extensions/integrations/obsidian-formatting.js.map +1 -0
  18. package/dist/prism-extensions/integrations/obsidian-memory.d.ts +3 -1
  19. package/dist/prism-extensions/integrations/obsidian-memory.js +102 -49
  20. package/dist/prism-extensions/integrations/obsidian-memory.js.map +1 -1
  21. package/dist/prism-extensions/providers/manifest-provider.d.ts +1 -0
  22. package/dist/prism-extensions/providers/manifest-provider.js +29 -2
  23. package/dist/prism-extensions/providers/manifest-provider.js.map +1 -1
  24. package/dist/prism-extensions/tools/builtin-tools.js +2 -157
  25. package/dist/prism-extensions/tools/builtin-tools.js.map +1 -1
  26. package/dist/prism-extensions/tools/prism-diagnostic-tools.d.ts +2 -0
  27. package/dist/prism-extensions/tools/prism-diagnostic-tools.js +155 -0
  28. package/dist/prism-extensions/tools/prism-diagnostic-tools.js.map +1 -0
  29. package/dist/prism-extensions/tools/toolbox.d.ts +1 -0
  30. package/dist/prism-extensions/tools/toolbox.js +81 -3
  31. package/dist/prism-extensions/tools/toolbox.js.map +1 -1
  32. package/dist/prism-extensions/ui/toolbar.js +33 -16
  33. package/dist/prism-extensions/ui/toolbar.js.map +1 -1
  34. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  35. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +1 -1
  36. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  37. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/compile/validator.d.mts +3 -11
  38. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/compile/validator.mjs +6 -36
  39. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/error/errors.d.mts +1 -7
  40. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/format/_idna.mjs +36 -6
  41. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/format/_puny.mjs +4 -1
  42. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/format/uuid.d.mts +2 -2
  43. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/format/uuid.mjs +3 -3
  44. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/guard/emit.d.mts +0 -4
  45. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/guard/emit.mjs +0 -8
  46. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/guard/guard.d.mts +5 -9
  47. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/guard/guard.mjs +10 -15
  48. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/guard/string.mjs +16 -4
  49. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  50. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  51. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  52. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  53. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  54. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
  55. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  56. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  57. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  58. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/index.mjs +0 -1
  59. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  60. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  61. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  62. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  63. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  64. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  65. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  66. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  67. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  68. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  69. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  70. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  71. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  72. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  73. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  74. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  75. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  76. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  77. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  78. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  79. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  80. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  81. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  82. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  83. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  84. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  85. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  86. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  87. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  88. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  89. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  90. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  91. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  92. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  93. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  94. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  95. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  96. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  97. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  98. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  99. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  100. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  101. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  102. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  103. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  104. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  105. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  106. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  107. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  108. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  109. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  110. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  111. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  112. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  113. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  114. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  115. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  116. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  117. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/index.d.mts +7 -4
  118. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/index.mjs +7 -4
  119. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  120. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  121. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/module.d.mts +8 -7
  122. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/module.mjs +7 -6
  123. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
  124. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/with.d.mts +11 -0
  125. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/with.mjs +11 -0
  126. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  127. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  128. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  129. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  130. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  131. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  132. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  133. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  134. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  135. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  136. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  137. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  138. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  139. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  140. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  141. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  142. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  143. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  144. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  145. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  146. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  147. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  148. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  149. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  150. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  151. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  152. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  153. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  154. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  155. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  156. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  157. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  158. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  159. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  160. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  161. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/index.mjs +2 -2
  162. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  163. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  164. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  165. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  166. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  167. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  168. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  169. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  170. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  171. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  172. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  173. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  174. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  175. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  176. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  177. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  178. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  179. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  180. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  181. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  182. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  183. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  184. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  185. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  186. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  187. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  188. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  189. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  190. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  191. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  192. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  193. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  194. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  195. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  196. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  197. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  198. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  199. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  200. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  201. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  202. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  203. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  204. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  205. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  206. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  207. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  208. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  209. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  210. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  211. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  212. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  213. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  214. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  215. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  216. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  217. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  218. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  219. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  220. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  221. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  222. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  223. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  224. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  225. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  226. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  227. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  228. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  229. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  230. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  231. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  232. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  233. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  234. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  235. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  236. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  237. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  238. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  239. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  240. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  241. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  242. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  243. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  244. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  245. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  246. package/node_modules/@earendil-works/{pi-coding-agent/node_modules/typebox/build/type/engine/options → pi-agent-core/node_modules/typebox/build/type/engine/with}/instantiate.mjs +5 -5
  247. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  248. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  249. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  250. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  251. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  252. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  253. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  254. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  255. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  256. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  257. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/object.mjs +25 -3
  258. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  259. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  260. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/record.mjs +23 -0
  261. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  262. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  263. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  264. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  265. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/union.mjs +2 -2
  266. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
  267. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/mapping.mjs +95 -92
  268. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/parser.d.mts +42 -40
  269. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/parser.mjs +23 -22
  270. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/script.d.mts +3 -4
  271. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/script.mjs +3 -2
  272. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  273. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  274. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  275. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  276. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  277. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  278. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  279. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  280. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  281. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  282. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  283. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  284. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  285. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  286. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/call.d.mts +3 -3
  287. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/call.mjs +3 -2
  288. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  289. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  290. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  291. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  292. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  293. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/enum.mjs +5 -0
  294. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/index.d.mts +1 -4
  295. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/index.mjs +1 -4
  296. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/number.d.mts +1 -1
  297. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/number.mjs +1 -1
  298. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/record.d.mts +13 -7
  299. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/record.mjs +15 -9
  300. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/static.d.mts +2 -5
  301. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/typebox.d.mts +3 -7
  302. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/typebox.mjs +3 -7
  303. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  304. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  305. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  306. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  307. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  308. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  309. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  310. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  311. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  312. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  313. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  314. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  315. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  316. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  317. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  318. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  319. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  320. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  321. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  322. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  323. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  324. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  325. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  326. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/index.d.mts +0 -1
  327. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/index.mjs +0 -1
  328. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  329. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  330. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  331. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  332. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/value.d.mts +0 -1
  333. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/value.mjs +0 -1
  334. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/package.json +33 -33
  335. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/readme.md +117 -103
  336. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  337. package/node_modules/@earendil-works/pi-ai/README.md +2 -1
  338. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  339. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +11 -4
  340. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  341. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts.map +1 -1
  342. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +5 -1
  343. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js.map +1 -1
  344. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  345. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +16 -4
  346. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  347. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts.map +1 -1
  348. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +12 -2
  349. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js.map +1 -1
  350. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts.map +1 -1
  351. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +12 -2
  352. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js.map +1 -1
  353. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts.map +1 -1
  354. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +19 -10
  355. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  357. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +12 -2
  358. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  359. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  360. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +21 -9
  361. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  362. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  363. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +11 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  365. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +7 -3
  367. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  368. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.d.ts.map +1 -1
  369. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +3 -2
  370. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js.map +1 -1
  371. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
  372. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -2
  373. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  374. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.d.ts.map +1 -1
  375. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -0
  376. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js.map +1 -1
  377. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts +3 -1
  378. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.d.ts.map +1 -1
  379. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +81 -26
  380. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js.map +1 -1
  381. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -0
  382. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  383. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +16 -8
  384. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  385. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  386. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  387. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  388. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  389. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  390. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  391. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  392. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  393. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  394. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  395. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  396. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  397. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  398. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  399. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  400. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +4 -1
  401. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  402. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +11 -1
  403. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  404. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  405. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/compile/validator.d.mts +3 -11
  406. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/compile/validator.mjs +6 -36
  407. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/error/errors.d.mts +1 -7
  408. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/format/_idna.mjs +36 -6
  409. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/format/_puny.mjs +4 -1
  410. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/format/uuid.d.mts +2 -2
  411. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/format/uuid.mjs +3 -3
  412. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/guard/emit.d.mts +0 -4
  413. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/guard/emit.mjs +0 -8
  414. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/guard/guard.d.mts +5 -9
  415. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/guard/guard.mjs +10 -15
  416. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/guard/string.mjs +16 -4
  417. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  418. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  419. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  420. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  421. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  422. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
  423. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  424. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  425. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  426. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/index.mjs +0 -1
  427. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  428. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  429. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  430. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  431. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  432. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  433. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  434. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  435. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  436. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  437. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  438. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  439. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  440. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  441. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  442. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  443. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  444. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  445. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  446. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  447. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  448. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  449. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  450. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  451. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  452. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  453. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  454. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  455. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  456. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  457. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  458. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  459. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  460. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  461. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  462. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  463. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  464. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  465. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  466. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  467. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  468. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  469. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  470. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  471. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  472. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  473. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  474. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  475. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  476. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  477. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  478. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  479. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  480. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  481. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  482. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  483. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  484. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  485. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/index.d.mts +7 -4
  486. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/index.mjs +7 -4
  487. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  488. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  489. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/module.d.mts +8 -7
  490. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/module.mjs +7 -6
  491. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
  492. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/with.d.mts +11 -0
  493. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/with.mjs +11 -0
  494. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  495. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  496. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  497. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  498. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  499. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  500. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  501. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  502. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  503. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  504. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  505. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  506. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  507. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  508. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  509. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  510. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  511. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  512. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  513. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  514. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  515. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  516. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  517. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  518. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  519. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  520. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  521. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  522. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  523. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  524. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  525. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  526. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  527. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  528. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  529. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/index.mjs +2 -2
  530. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  531. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  532. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  533. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  534. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  535. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  536. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  537. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  538. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  539. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  540. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  541. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  542. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  543. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  544. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  545. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  546. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  547. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  548. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  549. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  550. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  551. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  552. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  553. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  554. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  555. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  556. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  557. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  558. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  559. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  560. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  561. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  562. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  563. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  564. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  565. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  566. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  567. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  568. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  569. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  570. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  571. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  572. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  573. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  574. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  575. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  576. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  577. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  578. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  579. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  580. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  581. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  582. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  583. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  584. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  585. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  586. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  587. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  588. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  589. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  590. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  591. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  592. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  593. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  594. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  595. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  596. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  597. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  598. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  599. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  600. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  601. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  602. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  603. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  604. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  605. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  606. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  607. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  608. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  609. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  610. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  611. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  612. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  613. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  614. package/node_modules/@earendil-works/{pi-agent-core/node_modules/typebox/build/type/engine/options → pi-ai/node_modules/typebox/build/type/engine/with}/instantiate.mjs +5 -5
  615. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  616. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  617. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  618. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  619. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  620. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  621. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  622. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  623. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  624. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  625. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/object.mjs +25 -3
  626. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  627. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  628. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/record.mjs +23 -0
  629. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  630. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  631. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  632. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  633. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/union.mjs +2 -2
  634. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
  635. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/mapping.mjs +95 -92
  636. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/parser.d.mts +42 -40
  637. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/parser.mjs +23 -22
  638. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/script.d.mts +3 -4
  639. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/script.mjs +3 -2
  640. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  641. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  642. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  643. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  644. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  645. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  646. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  647. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  648. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  649. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  650. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  651. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  652. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  653. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  654. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/call.d.mts +3 -3
  655. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/call.mjs +3 -2
  656. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  657. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  658. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  659. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  660. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  661. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/enum.mjs +5 -0
  662. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/index.d.mts +1 -4
  663. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/index.mjs +1 -4
  664. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/number.d.mts +1 -1
  665. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/number.mjs +1 -1
  666. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/record.d.mts +13 -7
  667. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/record.mjs +15 -9
  668. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/static.d.mts +2 -5
  669. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/typebox.d.mts +3 -7
  670. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/typebox.mjs +3 -7
  671. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  672. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  673. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  674. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  675. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  676. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  677. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  678. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  679. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  680. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  681. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  682. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  683. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  684. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  685. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  686. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  687. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  688. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  689. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  690. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  691. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  692. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  693. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  694. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/index.d.mts +0 -1
  695. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/index.mjs +0 -1
  696. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  697. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  698. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  699. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  700. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/value.d.mts +0 -1
  701. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/value.mjs +0 -1
  702. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/package.json +33 -33
  703. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/readme.md +117 -103
  704. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  705. package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +45 -0
  706. package/node_modules/@earendil-works/pi-coding-agent/README.md +1 -1
  707. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
  708. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +8 -1
  709. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js.map +1 -1
  710. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/credential-print.d.ts +23 -0
  711. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/credential-print.d.ts.map +1 -0
  712. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/credential-print.js +116 -0
  713. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/credential-print.js.map +1 -0
  714. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.d.ts.map +1 -1
  715. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js +3 -0
  716. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js.map +1 -1
  717. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +1 -1
  718. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  719. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +13 -6
  720. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  721. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +1 -1
  722. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts +1 -0
  723. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  724. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js +7 -0
  725. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  726. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts +7 -0
  727. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  728. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  729. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.d.ts +10 -0
  730. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -1
  731. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.js +1 -1
  732. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -1
  733. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.d.ts +2 -0
  734. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.d.ts.map +1 -1
  735. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-runtime.js.map +1 -1
  736. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  737. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +13 -6
  738. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  739. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts +15 -0
  740. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  741. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +63 -9
  742. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  743. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +0 -267
  744. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.d.ts.map +1 -1
  745. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js +1 -1
  746. package/node_modules/@earendil-works/pi-coding-agent/dist/extensions/llama/provider.js.map +1 -1
  747. package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts.map +1 -1
  748. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +43 -0
  749. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js.map +1 -1
  750. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  751. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js +4 -1
  752. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
  753. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  754. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +32 -17
  755. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  756. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  757. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js +13 -0
  758. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
  759. package/node_modules/@earendil-works/pi-coding-agent/docs/custom-provider.md +9 -3
  760. package/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md +3 -1
  761. package/node_modules/@earendil-works/pi-coding-agent/docs/providers.md +1 -0
  762. package/node_modules/@earendil-works/pi-coding-agent/docs/session-format.md +2 -0
  763. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/index.ts +8 -2
  764. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  765. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
  766. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  767. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package-lock.json +2 -2
  768. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/gondolin/package.json +1 -1
  769. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +2 -2
  770. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
  771. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +2 -2
  772. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
  773. package/node_modules/@earendil-works/pi-coding-agent/examples/sdk/12-full-control.ts +2 -0
  774. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/compile/validator.d.mts +3 -11
  775. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/compile/validator.mjs +6 -36
  776. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/error/errors.d.mts +1 -7
  777. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/format/_idna.mjs +36 -6
  778. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/format/_puny.mjs +4 -1
  779. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/format/uuid.d.mts +2 -2
  780. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/format/uuid.mjs +3 -3
  781. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/guard/emit.d.mts +0 -4
  782. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/guard/emit.mjs +0 -8
  783. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/guard/guard.d.mts +5 -9
  784. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/guard/guard.mjs +10 -15
  785. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/guard/string.mjs +16 -4
  786. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
  787. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  788. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  789. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  790. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  791. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/schema.mjs +6 -11
  792. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  793. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  794. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  795. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/index.mjs +0 -1
  796. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  797. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  798. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  799. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  800. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  801. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  802. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  803. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  804. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  805. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  806. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  807. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  808. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  809. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  810. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  811. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  812. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  813. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  814. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  815. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  816. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  817. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  818. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  819. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  820. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  821. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  822. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  823. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  824. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  825. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  826. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  827. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  828. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  829. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  830. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  831. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  832. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  833. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  834. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  835. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  836. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  837. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  838. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  839. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  840. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  841. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  842. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  843. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  844. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  845. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  846. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  847. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  848. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  849. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  850. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  851. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  852. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  853. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  854. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/index.d.mts +7 -4
  855. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/index.mjs +7 -4
  856. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  857. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  858. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/module.d.mts +8 -7
  859. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/module.mjs +7 -6
  860. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/readonly_object.mjs +3 -0
  861. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/with.d.mts +11 -0
  862. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/with.mjs +11 -0
  863. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  864. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  865. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  866. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  867. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  868. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  869. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  870. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  871. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  872. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  873. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  874. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  875. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  876. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  877. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  878. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  879. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  880. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  881. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  882. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  883. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  884. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  885. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  886. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  887. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  888. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  889. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  890. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  891. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  892. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  893. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  894. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  895. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  896. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  897. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  898. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/index.mjs +2 -2
  899. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  900. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  901. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  902. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  903. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  904. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  905. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  906. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  907. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  908. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  909. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  910. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  911. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  912. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  913. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  914. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  915. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  916. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  917. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  918. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  919. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  920. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  921. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  922. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  923. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  924. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  925. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  926. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  927. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  928. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  929. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  930. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  931. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  932. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  933. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  934. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  935. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  936. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  937. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  938. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  939. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  940. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  941. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  942. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  943. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  944. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  945. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  946. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  947. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  948. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  949. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  950. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  951. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  952. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  953. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  954. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  955. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  956. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  957. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  958. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  959. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  960. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  961. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  962. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  963. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  964. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  965. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  966. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  967. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  968. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  969. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  970. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  971. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  972. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  973. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  974. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  975. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  976. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  977. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  978. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  979. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  980. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  981. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  982. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  983. package/node_modules/@earendil-works/{pi-ai/node_modules/typebox/build/type/engine/options → pi-coding-agent/node_modules/typebox/build/type/engine/with}/instantiate.mjs +5 -5
  984. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  985. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  986. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  987. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  988. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  989. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  990. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  991. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  992. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  993. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  994. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/object.mjs +25 -3
  995. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  996. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  997. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/record.mjs +23 -0
  998. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  999. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  1000. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  1001. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  1002. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/union.mjs +2 -2
  1003. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/mapping.d.mts +86 -98
  1004. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/mapping.mjs +95 -92
  1005. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/parser.d.mts +42 -40
  1006. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/parser.mjs +23 -22
  1007. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/script.d.mts +3 -4
  1008. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/script.mjs +3 -2
  1009. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  1010. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  1011. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  1012. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  1013. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  1014. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  1015. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  1016. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  1017. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  1018. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  1019. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  1020. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  1021. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  1022. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  1023. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/call.d.mts +3 -3
  1024. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/call.mjs +3 -2
  1025. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  1026. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  1027. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  1028. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  1029. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  1030. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/enum.mjs +5 -0
  1031. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/index.d.mts +1 -4
  1032. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/index.mjs +1 -4
  1033. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/number.d.mts +1 -1
  1034. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/number.mjs +1 -1
  1035. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/record.d.mts +13 -7
  1036. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/record.mjs +15 -9
  1037. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/static.d.mts +2 -5
  1038. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/typebox.d.mts +3 -7
  1039. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/typebox.mjs +3 -7
  1040. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  1041. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  1042. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  1043. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  1044. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  1045. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  1046. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  1047. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  1048. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  1049. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  1050. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  1051. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  1052. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  1053. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  1054. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  1055. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  1056. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  1057. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  1058. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  1059. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  1060. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  1061. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  1062. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  1063. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/index.d.mts +0 -1
  1064. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/index.mjs +0 -1
  1065. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  1066. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  1067. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  1068. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  1069. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/value.d.mts +0 -1
  1070. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/value.mjs +0 -1
  1071. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/package.json +33 -33
  1072. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/readme.md +117 -103
  1073. package/node_modules/@earendil-works/pi-coding-agent/package.json +5 -5
  1074. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  1075. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +3 -2
  1076. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  1077. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +5 -0
  1078. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  1079. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +25 -2
  1080. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  1081. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  1082. package/node_modules/@types/node/README.md +1 -1
  1083. package/node_modules/@types/node/crypto.d.ts +1 -1
  1084. package/node_modules/@types/node/package.json +2 -2
  1085. package/package.json +5 -5
  1086. package/src/prism-extensions/README.md +1 -1
  1087. package/src/prism-extensions/integrations/ai-memory-system.ts +332 -0
  1088. package/src/prism-extensions/integrations/obsidian-formatting.ts +55 -0
  1089. package/src/prism-extensions/integrations/obsidian-memory.ts +90 -47
  1090. package/src/prism-extensions/providers/manifest-provider.ts +29 -2
  1091. package/src/prism-extensions/tools/builtin-tools.ts +2 -150
  1092. package/src/prism-extensions/tools/prism-diagnostic-tools.ts +160 -0
  1093. package/src/prism-extensions/tools/toolbox.ts +87 -3
  1094. package/src/prism-extensions/ui/toolbar.ts +31 -12
  1095. package/dist/prism-extensions/integrations/mcp-adapter.d.ts +0 -3
  1096. package/dist/prism-extensions/integrations/mcp-adapter.js +0 -21
  1097. package/dist/prism-extensions/integrations/mcp-adapter.js.map +0 -1
  1098. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  1099. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  1100. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  1101. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  1102. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  1103. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  1104. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  1105. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  1106. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  1107. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  1108. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/options.d.mts +0 -11
  1109. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/action/options.mjs +0 -11
  1110. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  1111. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  1112. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  1113. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  1114. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  1115. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  1116. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  1117. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  1118. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  1119. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  1120. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  1121. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  1122. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  1123. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/base.d.mts +0 -50
  1124. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/base.mjs +0 -84
  1125. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  1126. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  1127. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  1128. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/types/promise.mjs +0 -29
  1129. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  1130. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  1131. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  1132. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  1133. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  1134. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  1135. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  1136. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  1137. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  1138. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  1139. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  1140. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  1141. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  1142. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  1143. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  1144. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  1145. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  1146. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  1147. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  1148. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  1149. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  1150. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  1151. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  1152. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  1153. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  1154. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  1155. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  1156. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  1157. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  1158. package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  1159. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  1160. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  1161. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  1162. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  1163. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  1164. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  1165. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  1166. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  1167. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  1168. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  1169. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/options.d.mts +0 -11
  1170. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/action/options.mjs +0 -11
  1171. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  1172. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  1173. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  1174. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  1175. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  1176. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  1177. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  1178. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  1179. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  1180. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  1181. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  1182. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  1183. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  1184. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  1185. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  1186. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/base.d.mts +0 -50
  1187. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/base.mjs +0 -84
  1188. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  1189. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  1190. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  1191. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/type/types/promise.mjs +0 -29
  1192. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  1193. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  1194. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  1195. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  1196. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  1197. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  1198. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  1199. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  1200. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  1201. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  1202. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  1203. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  1204. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  1205. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  1206. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  1207. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  1208. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  1209. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  1210. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  1211. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  1212. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  1213. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  1214. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  1215. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  1216. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  1217. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  1218. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  1219. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  1220. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  1221. package/node_modules/@earendil-works/pi-ai/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  1222. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  1223. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  1224. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  1225. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  1226. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  1227. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  1228. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  1229. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  1230. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  1231. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  1232. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/options.d.mts +0 -11
  1233. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/action/options.mjs +0 -11
  1234. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/awaited/index.d.mts +0 -1
  1235. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/awaited/index.mjs +0 -1
  1236. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  1237. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  1238. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  1239. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  1240. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  1241. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  1242. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  1243. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  1244. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  1245. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  1246. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  1247. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  1248. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  1249. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  1250. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  1251. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/base.d.mts +0 -50
  1252. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/base.mjs +0 -84
  1253. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  1254. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  1255. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  1256. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/type/types/promise.mjs +0 -29
  1257. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  1258. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  1259. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  1260. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  1261. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  1262. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  1263. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  1264. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  1265. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  1266. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  1267. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  1268. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  1269. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  1270. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  1271. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  1272. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  1273. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  1274. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  1275. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  1276. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  1277. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  1278. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  1279. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  1280. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  1281. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  1282. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  1283. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  1284. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  1285. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  1286. package/node_modules/@earendil-works/pi-coding-agent/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  1287. /package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  1288. /package/node_modules/@earendil-works/pi-agent-core/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
  1289. /package/node_modules/@earendil-works/{pi-agent-core/node_modules/typebox/build/type/engine/options → pi-ai/node_modules/typebox/build/type/engine/with}/index.d.mts +0 -0
  1290. /package/node_modules/@earendil-works/{pi-agent-core/node_modules/typebox/build/type/engine/options → pi-ai/node_modules/typebox/build/type/engine/with}/index.mjs +0 -0
  1291. /package/node_modules/@earendil-works/{pi-ai/node_modules/typebox/build/type/engine/awaited → pi-coding-agent/node_modules/typebox/build/type/engine/with}/index.d.mts +0 -0
  1292. /package/node_modules/@earendil-works/{pi-ai/node_modules/typebox/build/type/engine/awaited → pi-coding-agent/node_modules/typebox/build/type/engine/with}/index.mjs +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/openrouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAmB,SAAS,EAAmB,MAAM,aAAa,CAAC;AA8N/E,eAAO,MAAM,eAAe,EAAE,SAU7B,CAAC","sourcesContent":["/**\n * OpenRouter OAuth PKCE flow.\n *\n * OpenRouter exchanges an authorization code for a permanent, user-controlled\n * API key rather than an expiring access/refresh token pair. The callback is\n * handled by a one-shot loopback server on an ephemeral port.\n *\n * NOTE: This module uses Node.js http.createServer for the OAuth callback server.\n * It is only intended for CLI use, not browser environments.\n */\n\nimport { createServer, type Server, type ServerResponse } from \"node:http\";\nimport { getProviderEnvValue } from \"../../utils/provider-env.ts\";\nimport type { AuthInteraction, OAuthAuth, OAuthCredential } from \"../types.ts\";\nimport { oauthErrorHtml, oauthSuccessHtml } from \"./oauth-page.ts\";\nimport { generatePKCE } from \"./pkce.ts\";\n\nconst AUTHORIZE_URL = \"https://openrouter.ai/auth\";\nconst TOKEN_URL = \"https://openrouter.ai/api/v1/auth/keys\";\nconst LOGIN_TIMEOUT_MS = 5 * 60 * 1000;\nconst TOKEN_EXCHANGE_TIMEOUT_MS = 30_000;\n\nfunction getCallbackHost(): string {\n\treturn getProviderEnvValue(\"PI_OAUTH_CALLBACK_HOST\") || \"127.0.0.1\";\n}\n\ntype JsonObject = Record<string, unknown>;\n\ntype OpenRouterCallbackServer = {\n\tcallbackUrl: string;\n\tcredential: Promise<OAuthCredential>;\n\tclose(): void;\n};\n\nfunction sendHtml(response: ServerResponse, status: number, html: string): void {\n\tresponse.statusCode = status;\n\tresponse.setHeader(\"content-type\", \"text/html; charset=utf-8\");\n\tresponse.setHeader(\"cache-control\", \"no-store\");\n\tresponse.end(html);\n}\n\nfunction errorDetail(body: JsonObject): string | undefined {\n\tif (typeof body.error_description === \"string\") return body.error_description;\n\tif (typeof body.message === \"string\") return body.message;\n\tif (typeof body.error === \"string\") return body.error;\n\tif (body.error && typeof body.error === \"object\" && !Array.isArray(body.error)) {\n\t\tconst message = (body.error as JsonObject).message;\n\t\tif (typeof message === \"string\") return message;\n\t}\n\treturn undefined;\n}\n\nasync function exchangeAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OAuthCredential> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst controller = new AbortController();\n\tconst onAbort = () => controller.abort(signal?.reason);\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tconst timeout = setTimeout(\n\t\t() => controller.abort(new Error(\"OpenRouter OAuth token exchange timed out\")),\n\t\tTOKEN_EXCHANGE_TIMEOUT_MS,\n\t);\n\n\tlet response: Response;\n\tlet body: JsonObject = {};\n\ttry {\n\t\tresponse = await fetch(TOKEN_URL, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { accept: \"application/json\", \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: \"S256\" }),\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\ttry {\n\t\t\tconst parsed = (await response.json()) as unknown;\n\t\t\tif (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) body = parsed as JsonObject;\n\t\t} catch {\n\t\t\tif (response.ok) throw new Error(\"OpenRouter OAuth returned invalid JSON\");\n\t\t}\n\t} catch (error) {\n\t\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\t\tif (controller.signal.aborted) throw new Error(\"OpenRouter OAuth token exchange timed out\");\n\t\tthrow error;\n\t} finally {\n\t\tclearTimeout(timeout);\n\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t}\n\n\tif (!response.ok) {\n\t\tconst detail = errorDetail(body);\n\t\tthrow new Error(`OpenRouter OAuth key exchange failed (HTTP ${response.status})${detail ? `: ${detail}` : \"\"}`);\n\t}\n\n\tif (typeof body.key !== \"string\" || body.key.length === 0) {\n\t\tthrow new Error('OpenRouter OAuth response carries no \"key\"');\n\t}\n\n\treturn {\n\t\ttype: \"oauth\",\n\t\taccess: body.key,\n\t\trefresh: \"\",\n\t\texpires: Number.MAX_SAFE_INTEGER,\n\t};\n}\n\nasync function startCallbackServer(\n\tcallbackPath: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OpenRouterCallbackServer> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst callbackHost = getCallbackHost();\n\tlet resolveCredential: (credential: OAuthCredential) => void = () => {};\n\tlet rejectCredential: (error: Error) => void = () => {};\n\tconst credential = new Promise<OAuthCredential>((resolve, reject) => {\n\t\tresolveCredential = resolve;\n\t\trejectCredential = reject;\n\t});\n\n\tlet server: Server;\n\tlet claimed = false;\n\tlet settled = false;\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet onAbort: (() => void) | undefined;\n\n\tconst finish = (result: { credential: OAuthCredential } | { error: Error }): void => {\n\t\tif (settled) return;\n\t\tsettled = true;\n\t\tif (timeout) clearTimeout(timeout);\n\t\tif (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n\t\tserver.close();\n\t\tif (\"credential\" in result) resolveCredential(result.credential);\n\t\telse rejectCredential(result.error);\n\t};\n\n\tserver = createServer((request, response) => {\n\t\tvoid (async () => {\n\t\t\tconst requestUrl = new URL(request.url ?? \"/\", `http://${callbackHost}`);\n\t\t\tif (request.method !== \"GET\" || requestUrl.pathname !== callbackPath) {\n\t\t\t\tsendHtml(response, 404, oauthErrorHtml(\"OAuth callback route not found.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (claimed || settled) {\n\t\t\t\tsendHtml(response, 409, oauthErrorHtml(\"This OAuth callback has already been used.\"));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oauthError = requestUrl.searchParams.get(\"error\");\n\t\t\tif (oauthError) {\n\t\t\t\tconst description = requestUrl.searchParams.get(\"error_description\") ?? oauthError;\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter authorization was denied.\", description));\n\t\t\t\tfinish({ error: new Error(`OpenRouter authorization failed: ${description}`) });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst code = requestUrl.searchParams.get(\"code\");\n\t\t\tif (!code) {\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter returned no authorization code.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tclaimed = true;\n\n\t\t\ttry {\n\t\t\t\tconst result = await exchangeAuthorizationCode(code, verifier, signal);\n\t\t\t\tsendHtml(response, 200, oauthSuccessHtml(\"Signed in to OpenRouter. You may now close this page.\"));\n\t\t\t\tfinish({ credential: result });\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown token exchange error\";\n\t\t\t\tsendHtml(response, 502, oauthErrorHtml(\"OpenRouter key exchange failed.\", message));\n\t\t\t\tfinish({ error: error instanceof Error ? error : new Error(message) });\n\t\t\t}\n\t\t})();\n\t});\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.once(\"error\", reject);\n\t\tserver.listen(0, callbackHost, () => {\n\t\t\tserver.removeListener(\"error\", reject);\n\t\t\tresolve();\n\t\t});\n\t});\n\n\tserver.on(\"error\", (error) => finish({ error }));\n\tonAbort = () => finish({ error: new Error(\"Login cancelled\") });\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tif (signal?.aborted) {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\tserver.close();\n\t\tthrow new Error(\"Login cancelled\");\n\t}\n\ttimeout = setTimeout(() => finish({ error: new Error(\"OpenRouter OAuth login timed out\") }), LOGIN_TIMEOUT_MS);\n\n\tconst address = server.address();\n\tif (!address || typeof address === \"string\") {\n\t\tfinish({ error: new Error(\"Could not determine the OpenRouter OAuth callback port\") });\n\t\tthrow new Error(\"Could not determine the OpenRouter OAuth callback port\");\n\t}\n\n\treturn {\n\t\tcallbackUrl: `http://${callbackHost}:${address.port}${callbackPath}`,\n\t\tcredential,\n\t\tclose: () => finish({ error: new Error(\"Login cancelled\") }),\n\t};\n}\n\nasync function loginOpenRouter(interaction: AuthInteraction): Promise<OAuthCredential> {\n\tconst { verifier, challenge } = await generatePKCE();\n\tconst callbackPath = `/oauth/callback/${crypto.randomUUID()}`;\n\tconst callback = await startCallbackServer(callbackPath, verifier, interaction.signal);\n\tconst authorizeUrl = new URL(AUTHORIZE_URL);\n\tauthorizeUrl.search = new URLSearchParams({\n\t\tcallback_url: callback.callbackUrl,\n\t\tcode_challenge: challenge,\n\t\tcode_challenge_method: \"S256\",\n\t}).toString();\n\n\tinteraction.notify({\n\t\ttype: \"progress\",\n\t\tmessage: `Listening for OpenRouter OAuth callback on ${callback.callbackUrl}`,\n\t});\n\tinteraction.notify({\n\t\ttype: \"auth_url\",\n\t\turl: authorizeUrl.toString(),\n\t\tinstructions: \"Complete sign-in in your browser.\",\n\t});\n\n\ttry {\n\t\treturn await callback.credential;\n\t} finally {\n\t\tcallback.close();\n\t}\n}\n\nexport const openRouterOAuth: OAuthAuth = {\n\tname: \"OpenRouter OAuth\",\n\tloginLabel: \"Sign in with OpenRouter\",\n\tlogin: loginOpenRouter,\n\tasync refresh(credential) {\n\t\treturn credential;\n\t},\n\tasync toAuth(credential) {\n\t\treturn { apiKey: credential.access };\n\t},\n};\n"]}
1
+ {"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/openrouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAmB,SAAS,EAAmB,MAAM,aAAa,CAAC;AA6R/E,eAAO,MAAM,eAAe,EAAE,SAU7B,CAAC","sourcesContent":["/**\n * OpenRouter OAuth PKCE flow.\n *\n * OpenRouter exchanges an authorization code for a permanent, user-controlled\n * API key rather than an expiring access/refresh token pair. The callback is\n * handled by a one-shot loopback server on an ephemeral port, raced against a\n * manual prompt so remote/headless sessions can paste the redirect URL when\n * the browser cannot reach the loopback server.\n *\n * NOTE: This module uses Node.js http.createServer for the OAuth callback server.\n * It is only intended for CLI use, not browser environments.\n */\n\nimport { createServer, type Server, type ServerResponse } from \"node:http\";\nimport { getProviderEnvValue } from \"../../utils/provider-env.ts\";\nimport type { AuthInteraction, OAuthAuth, OAuthCredential } from \"../types.ts\";\nimport { oauthErrorHtml, oauthSuccessHtml } from \"./oauth-page.ts\";\nimport { generatePKCE } from \"./pkce.ts\";\n\nconst AUTHORIZE_URL = \"https://openrouter.ai/auth\";\nconst TOKEN_URL = \"https://openrouter.ai/api/v1/auth/keys\";\nconst LOGIN_TIMEOUT_MS = 5 * 60 * 1000;\nconst TOKEN_EXCHANGE_TIMEOUT_MS = 30_000;\n\nfunction getCallbackHost(): string {\n\treturn getProviderEnvValue(\"PI_OAUTH_CALLBACK_HOST\") || \"127.0.0.1\";\n}\n\ntype JsonObject = Record<string, unknown>;\n\ntype OpenRouterCallbackServer = {\n\tcallbackUrl: string;\n\t/** Stop listening and release timers without settling `waitForCredential`. */\n\tclose: () => void;\n\t/** Hand the login over to manual code entry unless a callback already claimed the exchange. */\n\tcancelWait: () => void;\n\t/**\n\t * Resolves with the credential once a browser callback completes the key\n\t * exchange, or with null once `cancelWait` hands the login over to manual\n\t * code entry. Rejects on timeout, cancellation, or a failed exchange.\n\t */\n\twaitForCredential: () => Promise<OAuthCredential | null>;\n};\n\nfunction sendHtml(response: ServerResponse, status: number, html: string): void {\n\tresponse.statusCode = status;\n\tresponse.setHeader(\"content-type\", \"text/html; charset=utf-8\");\n\tresponse.setHeader(\"cache-control\", \"no-store\");\n\tresponse.end(html);\n}\n\nfunction parseAuthorizationInput(input: string): string | undefined {\n\tconst value = input.trim();\n\tif (!value) return undefined;\n\n\ttry {\n\t\treturn new URL(value).searchParams.get(\"code\") ?? undefined;\n\t} catch {\n\t\t// not a URL\n\t}\n\n\tif (value.includes(\"code=\")) {\n\t\treturn new URLSearchParams(value).get(\"code\") ?? undefined;\n\t}\n\n\treturn value;\n}\n\nfunction errorDetail(body: JsonObject): string | undefined {\n\tif (typeof body.error_description === \"string\") return body.error_description;\n\tif (typeof body.message === \"string\") return body.message;\n\tif (typeof body.error === \"string\") return body.error;\n\tif (body.error && typeof body.error === \"object\" && !Array.isArray(body.error)) {\n\t\tconst message = (body.error as JsonObject).message;\n\t\tif (typeof message === \"string\") return message;\n\t}\n\treturn undefined;\n}\n\nasync function exchangeAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OAuthCredential> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst controller = new AbortController();\n\tconst onAbort = () => controller.abort(signal?.reason);\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tconst timeout = setTimeout(\n\t\t() => controller.abort(new Error(\"OpenRouter OAuth token exchange timed out\")),\n\t\tTOKEN_EXCHANGE_TIMEOUT_MS,\n\t);\n\n\tlet response: Response;\n\tlet body: JsonObject = {};\n\ttry {\n\t\tresponse = await fetch(TOKEN_URL, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { accept: \"application/json\", \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: \"S256\" }),\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\ttry {\n\t\t\tconst parsed = (await response.json()) as unknown;\n\t\t\tif (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) body = parsed as JsonObject;\n\t\t} catch {\n\t\t\tif (response.ok) throw new Error(\"OpenRouter OAuth returned invalid JSON\");\n\t\t}\n\t} catch (error) {\n\t\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\t\tif (controller.signal.aborted) throw new Error(\"OpenRouter OAuth token exchange timed out\");\n\t\tthrow error;\n\t} finally {\n\t\tclearTimeout(timeout);\n\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t}\n\n\tif (!response.ok) {\n\t\tconst detail = errorDetail(body);\n\t\tthrow new Error(`OpenRouter OAuth key exchange failed (HTTP ${response.status})${detail ? `: ${detail}` : \"\"}`);\n\t}\n\n\tif (typeof body.key !== \"string\" || body.key.length === 0) {\n\t\tthrow new Error('OpenRouter OAuth response carries no \"key\"');\n\t}\n\n\treturn {\n\t\ttype: \"oauth\",\n\t\taccess: body.key,\n\t\trefresh: \"\",\n\t\texpires: Number.MAX_SAFE_INTEGER,\n\t};\n}\n\nasync function startCallbackServer(\n\tcallbackPath: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OpenRouterCallbackServer> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst callbackHost = getCallbackHost();\n\tlet resolveCredential: (credential: OAuthCredential | null) => void = () => {};\n\tlet rejectCredential: (error: Error) => void = () => {};\n\tconst credential = new Promise<OAuthCredential | null>((resolve, reject) => {\n\t\tresolveCredential = resolve;\n\t\trejectCredential = reject;\n\t});\n\n\tlet server: Server;\n\tlet claimed = false;\n\tlet settled = false;\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet onAbort: (() => void) | undefined;\n\n\tconst close = (): void => {\n\t\tif (timeout) clearTimeout(timeout);\n\t\tif (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n\t\tserver.close();\n\t};\n\n\tconst finish = (result: { credential: OAuthCredential | null } | { error: Error }): void => {\n\t\tif (settled) return;\n\t\tsettled = true;\n\t\tclose();\n\t\tif (\"credential\" in result) resolveCredential(result.credential);\n\t\telse rejectCredential(result.error);\n\t};\n\n\tserver = createServer((request, response) => {\n\t\tvoid (async () => {\n\t\t\tconst requestUrl = new URL(request.url ?? \"/\", `http://${callbackHost}`);\n\t\t\tif (request.method !== \"GET\" || requestUrl.pathname !== callbackPath) {\n\t\t\t\tsendHtml(response, 404, oauthErrorHtml(\"OAuth callback route not found.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (claimed || settled) {\n\t\t\t\tsendHtml(response, 409, oauthErrorHtml(\"This OAuth callback has already been used.\"));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oauthError = requestUrl.searchParams.get(\"error\");\n\t\t\tif (oauthError) {\n\t\t\t\tconst description = requestUrl.searchParams.get(\"error_description\") ?? oauthError;\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter authorization was denied.\", description));\n\t\t\t\tfinish({ error: new Error(`OpenRouter authorization failed: ${description}`) });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst code = requestUrl.searchParams.get(\"code\");\n\t\t\tif (!code) {\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter returned no authorization code.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tclaimed = true;\n\n\t\t\ttry {\n\t\t\t\tconst result = await exchangeAuthorizationCode(code, verifier, signal);\n\t\t\t\tsendHtml(response, 200, oauthSuccessHtml(\"Signed in to OpenRouter. You may now close this page.\"));\n\t\t\t\tfinish({ credential: result });\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown token exchange error\";\n\t\t\t\tsendHtml(response, 502, oauthErrorHtml(\"OpenRouter key exchange failed.\", message));\n\t\t\t\tfinish({ error: error instanceof Error ? error : new Error(message) });\n\t\t\t}\n\t\t})();\n\t});\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.once(\"error\", reject);\n\t\tserver.listen(0, callbackHost, () => {\n\t\t\tserver.removeListener(\"error\", reject);\n\t\t\tresolve();\n\t\t});\n\t});\n\n\tserver.on(\"error\", (error) => finish({ error }));\n\tonAbort = () => finish({ error: new Error(\"Login cancelled\") });\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tif (signal?.aborted) {\n\t\tclose();\n\t\tthrow new Error(\"Login cancelled\");\n\t}\n\ttimeout = setTimeout(() => finish({ error: new Error(\"OpenRouter OAuth login timed out\") }), LOGIN_TIMEOUT_MS);\n\n\tconst address = server.address();\n\tif (!address || typeof address === \"string\") {\n\t\tclose();\n\t\tthrow new Error(\"Could not determine the OpenRouter OAuth callback port\");\n\t}\n\n\treturn {\n\t\tcallbackUrl: `http://${callbackHost}:${address.port}${callbackPath}`,\n\t\tclose,\n\t\t// A claimed callback is already exchanging its code; let that exchange settle the login.\n\t\tcancelWait: () => {\n\t\t\tif (!claimed) finish({ credential: null });\n\t\t},\n\t\twaitForCredential: () => credential,\n\t};\n}\n\nasync function loginOpenRouter(interaction: AuthInteraction): Promise<OAuthCredential> {\n\tconst { verifier, challenge } = await generatePKCE();\n\tconst callbackPath = `/oauth/callback/${crypto.randomUUID()}`;\n\tconst callback = await startCallbackServer(callbackPath, verifier, interaction.signal);\n\tconst manualAbort = new AbortController();\n\tlet manualInput: string | undefined;\n\tlet manualError: Error | undefined;\n\n\ttry {\n\t\tconst authorizeUrl = new URL(AUTHORIZE_URL);\n\t\tauthorizeUrl.search = new URLSearchParams({\n\t\t\tcallback_url: callback.callbackUrl,\n\t\t\tcode_challenge: challenge,\n\t\t\tcode_challenge_method: \"S256\",\n\t\t}).toString();\n\n\t\tinteraction.notify({\n\t\t\ttype: \"progress\",\n\t\t\tmessage: `Listening for OpenRouter OAuth callback on ${callback.callbackUrl}`,\n\t\t});\n\t\tinteraction.notify({\n\t\t\ttype: \"auth_url\",\n\t\t\turl: authorizeUrl.toString(),\n\t\t\tinstructions:\n\t\t\t\t\"Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here.\",\n\t\t});\n\n\t\tconst manualPromise = interaction\n\t\t\t.prompt({\n\t\t\t\ttype: \"manual_code\",\n\t\t\t\tmessage: \"Complete sign-in in your browser, or paste the authorization code / redirect URL here:\",\n\t\t\t\tplaceholder: callback.callbackUrl,\n\t\t\t\tsignal: manualAbort.signal,\n\t\t\t})\n\t\t\t.then((input) => {\n\t\t\t\tmanualInput = input;\n\t\t\t\tcallback.cancelWait();\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tmanualError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tcallback.cancelWait();\n\t\t\t});\n\n\t\tconst credential = await callback.waitForCredential();\n\t\tif (manualError) throw manualError;\n\t\tif (credential) return credential;\n\n\t\tawait manualPromise;\n\t\tif (manualError) throw manualError;\n\t\tconst code = manualInput ? parseAuthorizationInput(manualInput) : undefined;\n\t\tif (!code) throw new Error(\"Missing authorization code\");\n\t\tinteraction.notify({ type: \"progress\", message: \"Exchanging authorization code for an API key...\" });\n\t\treturn await exchangeAuthorizationCode(code, verifier, interaction.signal);\n\t} finally {\n\t\tmanualAbort.abort();\n\t\tcallback.close();\n\t}\n}\n\nexport const openRouterOAuth: OAuthAuth = {\n\tname: \"OpenRouter OAuth\",\n\tloginLabel: \"Sign in with OpenRouter\",\n\tlogin: loginOpenRouter,\n\tasync refresh(credential) {\n\t\treturn credential;\n\t},\n\tasync toAuth(credential) {\n\t\treturn { apiKey: credential.access };\n\t},\n};\n"]}
@@ -3,7 +3,9 @@
3
3
  *
4
4
  * OpenRouter exchanges an authorization code for a permanent, user-controlled
5
5
  * API key rather than an expiring access/refresh token pair. The callback is
6
- * handled by a one-shot loopback server on an ephemeral port.
6
+ * handled by a one-shot loopback server on an ephemeral port, raced against a
7
+ * manual prompt so remote/headless sessions can paste the redirect URL when
8
+ * the browser cannot reach the loopback server.
7
9
  *
8
10
  * NOTE: This module uses Node.js http.createServer for the OAuth callback server.
9
11
  * It is only intended for CLI use, not browser environments.
@@ -25,6 +27,21 @@ function sendHtml(response, status, html) {
25
27
  response.setHeader("cache-control", "no-store");
26
28
  response.end(html);
27
29
  }
30
+ function parseAuthorizationInput(input) {
31
+ const value = input.trim();
32
+ if (!value)
33
+ return undefined;
34
+ try {
35
+ return new URL(value).searchParams.get("code") ?? undefined;
36
+ }
37
+ catch {
38
+ // not a URL
39
+ }
40
+ if (value.includes("code=")) {
41
+ return new URLSearchParams(value).get("code") ?? undefined;
42
+ }
43
+ return value;
44
+ }
28
45
  function errorDetail(body) {
29
46
  if (typeof body.error_description === "string")
30
47
  return body.error_description;
@@ -105,15 +122,18 @@ async function startCallbackServer(callbackPath, verifier, signal) {
105
122
  let settled = false;
106
123
  let timeout;
107
124
  let onAbort;
108
- const finish = (result) => {
109
- if (settled)
110
- return;
111
- settled = true;
125
+ const close = () => {
112
126
  if (timeout)
113
127
  clearTimeout(timeout);
114
128
  if (onAbort)
115
129
  signal?.removeEventListener("abort", onAbort);
116
130
  server.close();
131
+ };
132
+ const finish = (result) => {
133
+ if (settled)
134
+ return;
135
+ settled = true;
136
+ close();
117
137
  if ("credential" in result)
118
138
  resolveCredential(result.credential);
119
139
  else
@@ -166,45 +186,80 @@ async function startCallbackServer(callbackPath, verifier, signal) {
166
186
  onAbort = () => finish({ error: new Error("Login cancelled") });
167
187
  signal?.addEventListener("abort", onAbort, { once: true });
168
188
  if (signal?.aborted) {
169
- signal.removeEventListener("abort", onAbort);
170
- server.close();
189
+ close();
171
190
  throw new Error("Login cancelled");
172
191
  }
173
192
  timeout = setTimeout(() => finish({ error: new Error("OpenRouter OAuth login timed out") }), LOGIN_TIMEOUT_MS);
174
193
  const address = server.address();
175
194
  if (!address || typeof address === "string") {
176
- finish({ error: new Error("Could not determine the OpenRouter OAuth callback port") });
195
+ close();
177
196
  throw new Error("Could not determine the OpenRouter OAuth callback port");
178
197
  }
179
198
  return {
180
199
  callbackUrl: `http://${callbackHost}:${address.port}${callbackPath}`,
181
- credential,
182
- close: () => finish({ error: new Error("Login cancelled") }),
200
+ close,
201
+ // A claimed callback is already exchanging its code; let that exchange settle the login.
202
+ cancelWait: () => {
203
+ if (!claimed)
204
+ finish({ credential: null });
205
+ },
206
+ waitForCredential: () => credential,
183
207
  };
184
208
  }
185
209
  async function loginOpenRouter(interaction) {
186
210
  const { verifier, challenge } = await generatePKCE();
187
211
  const callbackPath = `/oauth/callback/${crypto.randomUUID()}`;
188
212
  const callback = await startCallbackServer(callbackPath, verifier, interaction.signal);
189
- const authorizeUrl = new URL(AUTHORIZE_URL);
190
- authorizeUrl.search = new URLSearchParams({
191
- callback_url: callback.callbackUrl,
192
- code_challenge: challenge,
193
- code_challenge_method: "S256",
194
- }).toString();
195
- interaction.notify({
196
- type: "progress",
197
- message: `Listening for OpenRouter OAuth callback on ${callback.callbackUrl}`,
198
- });
199
- interaction.notify({
200
- type: "auth_url",
201
- url: authorizeUrl.toString(),
202
- instructions: "Complete sign-in in your browser.",
203
- });
213
+ const manualAbort = new AbortController();
214
+ let manualInput;
215
+ let manualError;
204
216
  try {
205
- return await callback.credential;
217
+ const authorizeUrl = new URL(AUTHORIZE_URL);
218
+ authorizeUrl.search = new URLSearchParams({
219
+ callback_url: callback.callbackUrl,
220
+ code_challenge: challenge,
221
+ code_challenge_method: "S256",
222
+ }).toString();
223
+ interaction.notify({
224
+ type: "progress",
225
+ message: `Listening for OpenRouter OAuth callback on ${callback.callbackUrl}`,
226
+ });
227
+ interaction.notify({
228
+ type: "auth_url",
229
+ url: authorizeUrl.toString(),
230
+ instructions: "Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here.",
231
+ });
232
+ const manualPromise = interaction
233
+ .prompt({
234
+ type: "manual_code",
235
+ message: "Complete sign-in in your browser, or paste the authorization code / redirect URL here:",
236
+ placeholder: callback.callbackUrl,
237
+ signal: manualAbort.signal,
238
+ })
239
+ .then((input) => {
240
+ manualInput = input;
241
+ callback.cancelWait();
242
+ })
243
+ .catch((error) => {
244
+ manualError = error instanceof Error ? error : new Error(String(error));
245
+ callback.cancelWait();
246
+ });
247
+ const credential = await callback.waitForCredential();
248
+ if (manualError)
249
+ throw manualError;
250
+ if (credential)
251
+ return credential;
252
+ await manualPromise;
253
+ if (manualError)
254
+ throw manualError;
255
+ const code = manualInput ? parseAuthorizationInput(manualInput) : undefined;
256
+ if (!code)
257
+ throw new Error("Missing authorization code");
258
+ interaction.notify({ type: "progress", message: "Exchanging authorization code for an API key..." });
259
+ return await exchangeAuthorizationCode(code, verifier, interaction.signal);
206
260
  }
207
261
  finally {
262
+ manualAbort.abort();
208
263
  callback.close();
209
264
  }
210
265
  }
@@ -1 +1 @@
1
- {"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../../src/auth/oauth/openrouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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CAAC;QACzC,YAAY,EAAE,QAAQ,CAAC,WAAW;QAClC,cAAc,EAAE,SAAS;QACzB,qBAAqB,EAAE,MAAM;KAC7B,CAAC,CAAC,QAAQ,EAAE,CAAC;IAEd,WAAW,CAAC,MAAM,CAAC;QAClB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,8CAA8C,QAAQ,CAAC,WAAW,EAAE;KAC7E,CAAC,CAAC;IACH,WAAW,CAAC,MAAM,CAAC;QAClB,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,YAAY,CAAC,QAAQ,EAAE;QAC5B,YAAY,EAAE,mCAAmC;KACjD,CAAC,CAAC;IAEH,IAAI,CAAC;QACJ,OAAO,MAAM,QAAQ,CAAC,UAAU,CAAC;IAClC,CAAC;YAAS,CAAC;QACV,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AAAA,CACD;AAED,MAAM,CAAC,MAAM,eAAe,GAAc;IACzC,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,eAAe;IACtB,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE;QACzB,OAAO,UAAU,CAAC;IAAA,CAClB;IACD,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;IAAA,CACrC;CACD,CAAC","sourcesContent":["/**\n * OpenRouter OAuth PKCE flow.\n *\n * OpenRouter exchanges an authorization code for a permanent, user-controlled\n * API key rather than an expiring access/refresh token pair. The callback is\n * handled by a one-shot loopback server on an ephemeral port.\n *\n * NOTE: This module uses Node.js http.createServer for the OAuth callback server.\n * It is only intended for CLI use, not browser environments.\n */\n\nimport { createServer, type Server, type ServerResponse } from \"node:http\";\nimport { getProviderEnvValue } from \"../../utils/provider-env.ts\";\nimport type { AuthInteraction, OAuthAuth, OAuthCredential } from \"../types.ts\";\nimport { oauthErrorHtml, oauthSuccessHtml } from \"./oauth-page.ts\";\nimport { generatePKCE } from \"./pkce.ts\";\n\nconst AUTHORIZE_URL = \"https://openrouter.ai/auth\";\nconst TOKEN_URL = \"https://openrouter.ai/api/v1/auth/keys\";\nconst LOGIN_TIMEOUT_MS = 5 * 60 * 1000;\nconst TOKEN_EXCHANGE_TIMEOUT_MS = 30_000;\n\nfunction getCallbackHost(): string {\n\treturn getProviderEnvValue(\"PI_OAUTH_CALLBACK_HOST\") || \"127.0.0.1\";\n}\n\ntype JsonObject = Record<string, unknown>;\n\ntype OpenRouterCallbackServer = {\n\tcallbackUrl: string;\n\tcredential: Promise<OAuthCredential>;\n\tclose(): void;\n};\n\nfunction sendHtml(response: ServerResponse, status: number, html: string): void {\n\tresponse.statusCode = status;\n\tresponse.setHeader(\"content-type\", \"text/html; charset=utf-8\");\n\tresponse.setHeader(\"cache-control\", \"no-store\");\n\tresponse.end(html);\n}\n\nfunction errorDetail(body: JsonObject): string | undefined {\n\tif (typeof body.error_description === \"string\") return body.error_description;\n\tif (typeof body.message === \"string\") return body.message;\n\tif (typeof body.error === \"string\") return body.error;\n\tif (body.error && typeof body.error === \"object\" && !Array.isArray(body.error)) {\n\t\tconst message = (body.error as JsonObject).message;\n\t\tif (typeof message === \"string\") return message;\n\t}\n\treturn undefined;\n}\n\nasync function exchangeAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OAuthCredential> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst controller = new AbortController();\n\tconst onAbort = () => controller.abort(signal?.reason);\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tconst timeout = setTimeout(\n\t\t() => controller.abort(new Error(\"OpenRouter OAuth token exchange timed out\")),\n\t\tTOKEN_EXCHANGE_TIMEOUT_MS,\n\t);\n\n\tlet response: Response;\n\tlet body: JsonObject = {};\n\ttry {\n\t\tresponse = await fetch(TOKEN_URL, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { accept: \"application/json\", \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: \"S256\" }),\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\ttry {\n\t\t\tconst parsed = (await response.json()) as unknown;\n\t\t\tif (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) body = parsed as JsonObject;\n\t\t} catch {\n\t\t\tif (response.ok) throw new Error(\"OpenRouter OAuth returned invalid JSON\");\n\t\t}\n\t} catch (error) {\n\t\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\t\tif (controller.signal.aborted) throw new Error(\"OpenRouter OAuth token exchange timed out\");\n\t\tthrow error;\n\t} finally {\n\t\tclearTimeout(timeout);\n\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t}\n\n\tif (!response.ok) {\n\t\tconst detail = errorDetail(body);\n\t\tthrow new Error(`OpenRouter OAuth key exchange failed (HTTP ${response.status})${detail ? `: ${detail}` : \"\"}`);\n\t}\n\n\tif (typeof body.key !== \"string\" || body.key.length === 0) {\n\t\tthrow new Error('OpenRouter OAuth response carries no \"key\"');\n\t}\n\n\treturn {\n\t\ttype: \"oauth\",\n\t\taccess: body.key,\n\t\trefresh: \"\",\n\t\texpires: Number.MAX_SAFE_INTEGER,\n\t};\n}\n\nasync function startCallbackServer(\n\tcallbackPath: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OpenRouterCallbackServer> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst callbackHost = getCallbackHost();\n\tlet resolveCredential: (credential: OAuthCredential) => void = () => {};\n\tlet rejectCredential: (error: Error) => void = () => {};\n\tconst credential = new Promise<OAuthCredential>((resolve, reject) => {\n\t\tresolveCredential = resolve;\n\t\trejectCredential = reject;\n\t});\n\n\tlet server: Server;\n\tlet claimed = false;\n\tlet settled = false;\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet onAbort: (() => void) | undefined;\n\n\tconst finish = (result: { credential: OAuthCredential } | { error: Error }): void => {\n\t\tif (settled) return;\n\t\tsettled = true;\n\t\tif (timeout) clearTimeout(timeout);\n\t\tif (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n\t\tserver.close();\n\t\tif (\"credential\" in result) resolveCredential(result.credential);\n\t\telse rejectCredential(result.error);\n\t};\n\n\tserver = createServer((request, response) => {\n\t\tvoid (async () => {\n\t\t\tconst requestUrl = new URL(request.url ?? \"/\", `http://${callbackHost}`);\n\t\t\tif (request.method !== \"GET\" || requestUrl.pathname !== callbackPath) {\n\t\t\t\tsendHtml(response, 404, oauthErrorHtml(\"OAuth callback route not found.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (claimed || settled) {\n\t\t\t\tsendHtml(response, 409, oauthErrorHtml(\"This OAuth callback has already been used.\"));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oauthError = requestUrl.searchParams.get(\"error\");\n\t\t\tif (oauthError) {\n\t\t\t\tconst description = requestUrl.searchParams.get(\"error_description\") ?? oauthError;\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter authorization was denied.\", description));\n\t\t\t\tfinish({ error: new Error(`OpenRouter authorization failed: ${description}`) });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst code = requestUrl.searchParams.get(\"code\");\n\t\t\tif (!code) {\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter returned no authorization code.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tclaimed = true;\n\n\t\t\ttry {\n\t\t\t\tconst result = await exchangeAuthorizationCode(code, verifier, signal);\n\t\t\t\tsendHtml(response, 200, oauthSuccessHtml(\"Signed in to OpenRouter. You may now close this page.\"));\n\t\t\t\tfinish({ credential: result });\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown token exchange error\";\n\t\t\t\tsendHtml(response, 502, oauthErrorHtml(\"OpenRouter key exchange failed.\", message));\n\t\t\t\tfinish({ error: error instanceof Error ? error : new Error(message) });\n\t\t\t}\n\t\t})();\n\t});\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.once(\"error\", reject);\n\t\tserver.listen(0, callbackHost, () => {\n\t\t\tserver.removeListener(\"error\", reject);\n\t\t\tresolve();\n\t\t});\n\t});\n\n\tserver.on(\"error\", (error) => finish({ error }));\n\tonAbort = () => finish({ error: new Error(\"Login cancelled\") });\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tif (signal?.aborted) {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\tserver.close();\n\t\tthrow new Error(\"Login cancelled\");\n\t}\n\ttimeout = setTimeout(() => finish({ error: new Error(\"OpenRouter OAuth login timed out\") }), LOGIN_TIMEOUT_MS);\n\n\tconst address = server.address();\n\tif (!address || typeof address === \"string\") {\n\t\tfinish({ error: new Error(\"Could not determine the OpenRouter OAuth callback port\") });\n\t\tthrow new Error(\"Could not determine the OpenRouter OAuth callback port\");\n\t}\n\n\treturn {\n\t\tcallbackUrl: `http://${callbackHost}:${address.port}${callbackPath}`,\n\t\tcredential,\n\t\tclose: () => finish({ error: new Error(\"Login cancelled\") }),\n\t};\n}\n\nasync function loginOpenRouter(interaction: AuthInteraction): Promise<OAuthCredential> {\n\tconst { verifier, challenge } = await generatePKCE();\n\tconst callbackPath = `/oauth/callback/${crypto.randomUUID()}`;\n\tconst callback = await startCallbackServer(callbackPath, verifier, interaction.signal);\n\tconst authorizeUrl = new URL(AUTHORIZE_URL);\n\tauthorizeUrl.search = new URLSearchParams({\n\t\tcallback_url: callback.callbackUrl,\n\t\tcode_challenge: challenge,\n\t\tcode_challenge_method: \"S256\",\n\t}).toString();\n\n\tinteraction.notify({\n\t\ttype: \"progress\",\n\t\tmessage: `Listening for OpenRouter OAuth callback on ${callback.callbackUrl}`,\n\t});\n\tinteraction.notify({\n\t\ttype: \"auth_url\",\n\t\turl: authorizeUrl.toString(),\n\t\tinstructions: \"Complete sign-in in your browser.\",\n\t});\n\n\ttry {\n\t\treturn await callback.credential;\n\t} finally {\n\t\tcallback.close();\n\t}\n}\n\nexport const openRouterOAuth: OAuthAuth = {\n\tname: \"OpenRouter OAuth\",\n\tloginLabel: \"Sign in with OpenRouter\",\n\tlogin: loginOpenRouter,\n\tasync refresh(credential) {\n\t\treturn credential;\n\t},\n\tasync toAuth(credential) {\n\t\treturn { apiKey: credential.access };\n\t},\n};\n"]}
1
+ {"version":3,"file":"openrouter.js","sourceRoot":"","sources":["../../../src/auth/oauth/openrouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAoC,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,aAAa,GAAG,4BAA4B,CAAC;AACnD,MAAM,SAAS,GAAG,wCAAwC,CAAC;AAC3D,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACvC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEzC,SAAS,eAAe,GAAW;IAClC,OAAO,mBAAmB,CAAC,wBAAwB,CAAC,IAAI,WAAW,CAAC;AAAA,CACpE;AAkBD,SAAS,QAAQ,CAAC,QAAwB,EAAE,MAAc,EAAE,IAAY,EAAQ;IAC/E,QAAQ,CAAC,UAAU,GAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAC/D,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAChD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAAA,CACnB;AAED,SAAS,uBAAuB,CAAC,KAAa,EAAsB;IACnE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC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B,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;YAAS,CAAC;QACV,WAAW,CAAC,KAAK,EAAE,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AAAA,CACD;AAED,MAAM,CAAC,MAAM,eAAe,GAAc;IACzC,IAAI,EAAE,kBAAkB;IACxB,UAAU,EAAE,yBAAyB;IACrC,KAAK,EAAE,eAAe;IACtB,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE;QACzB,OAAO,UAAU,CAAC;IAAA,CAClB;IACD,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;IAAA,CACrC;CACD,CAAC","sourcesContent":["/**\n * OpenRouter OAuth PKCE flow.\n *\n * OpenRouter exchanges an authorization code for a permanent, user-controlled\n * API key rather than an expiring access/refresh token pair. The callback is\n * handled by a one-shot loopback server on an ephemeral port, raced against a\n * manual prompt so remote/headless sessions can paste the redirect URL when\n * the browser cannot reach the loopback server.\n *\n * NOTE: This module uses Node.js http.createServer for the OAuth callback server.\n * It is only intended for CLI use, not browser environments.\n */\n\nimport { createServer, type Server, type ServerResponse } from \"node:http\";\nimport { getProviderEnvValue } from \"../../utils/provider-env.ts\";\nimport type { AuthInteraction, OAuthAuth, OAuthCredential } from \"../types.ts\";\nimport { oauthErrorHtml, oauthSuccessHtml } from \"./oauth-page.ts\";\nimport { generatePKCE } from \"./pkce.ts\";\n\nconst AUTHORIZE_URL = \"https://openrouter.ai/auth\";\nconst TOKEN_URL = \"https://openrouter.ai/api/v1/auth/keys\";\nconst LOGIN_TIMEOUT_MS = 5 * 60 * 1000;\nconst TOKEN_EXCHANGE_TIMEOUT_MS = 30_000;\n\nfunction getCallbackHost(): string {\n\treturn getProviderEnvValue(\"PI_OAUTH_CALLBACK_HOST\") || \"127.0.0.1\";\n}\n\ntype JsonObject = Record<string, unknown>;\n\ntype OpenRouterCallbackServer = {\n\tcallbackUrl: string;\n\t/** Stop listening and release timers without settling `waitForCredential`. */\n\tclose: () => void;\n\t/** Hand the login over to manual code entry unless a callback already claimed the exchange. */\n\tcancelWait: () => void;\n\t/**\n\t * Resolves with the credential once a browser callback completes the key\n\t * exchange, or with null once `cancelWait` hands the login over to manual\n\t * code entry. Rejects on timeout, cancellation, or a failed exchange.\n\t */\n\twaitForCredential: () => Promise<OAuthCredential | null>;\n};\n\nfunction sendHtml(response: ServerResponse, status: number, html: string): void {\n\tresponse.statusCode = status;\n\tresponse.setHeader(\"content-type\", \"text/html; charset=utf-8\");\n\tresponse.setHeader(\"cache-control\", \"no-store\");\n\tresponse.end(html);\n}\n\nfunction parseAuthorizationInput(input: string): string | undefined {\n\tconst value = input.trim();\n\tif (!value) return undefined;\n\n\ttry {\n\t\treturn new URL(value).searchParams.get(\"code\") ?? undefined;\n\t} catch {\n\t\t// not a URL\n\t}\n\n\tif (value.includes(\"code=\")) {\n\t\treturn new URLSearchParams(value).get(\"code\") ?? undefined;\n\t}\n\n\treturn value;\n}\n\nfunction errorDetail(body: JsonObject): string | undefined {\n\tif (typeof body.error_description === \"string\") return body.error_description;\n\tif (typeof body.message === \"string\") return body.message;\n\tif (typeof body.error === \"string\") return body.error;\n\tif (body.error && typeof body.error === \"object\" && !Array.isArray(body.error)) {\n\t\tconst message = (body.error as JsonObject).message;\n\t\tif (typeof message === \"string\") return message;\n\t}\n\treturn undefined;\n}\n\nasync function exchangeAuthorizationCode(\n\tcode: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OAuthCredential> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst controller = new AbortController();\n\tconst onAbort = () => controller.abort(signal?.reason);\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tconst timeout = setTimeout(\n\t\t() => controller.abort(new Error(\"OpenRouter OAuth token exchange timed out\")),\n\t\tTOKEN_EXCHANGE_TIMEOUT_MS,\n\t);\n\n\tlet response: Response;\n\tlet body: JsonObject = {};\n\ttry {\n\t\tresponse = await fetch(TOKEN_URL, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { accept: \"application/json\", \"content-type\": \"application/json\" },\n\t\t\tbody: JSON.stringify({ code, code_verifier: verifier, code_challenge_method: \"S256\" }),\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\ttry {\n\t\t\tconst parsed = (await response.json()) as unknown;\n\t\t\tif (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) body = parsed as JsonObject;\n\t\t} catch {\n\t\t\tif (response.ok) throw new Error(\"OpenRouter OAuth returned invalid JSON\");\n\t\t}\n\t} catch (error) {\n\t\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\t\tif (controller.signal.aborted) throw new Error(\"OpenRouter OAuth token exchange timed out\");\n\t\tthrow error;\n\t} finally {\n\t\tclearTimeout(timeout);\n\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t}\n\n\tif (!response.ok) {\n\t\tconst detail = errorDetail(body);\n\t\tthrow new Error(`OpenRouter OAuth key exchange failed (HTTP ${response.status})${detail ? `: ${detail}` : \"\"}`);\n\t}\n\n\tif (typeof body.key !== \"string\" || body.key.length === 0) {\n\t\tthrow new Error('OpenRouter OAuth response carries no \"key\"');\n\t}\n\n\treturn {\n\t\ttype: \"oauth\",\n\t\taccess: body.key,\n\t\trefresh: \"\",\n\t\texpires: Number.MAX_SAFE_INTEGER,\n\t};\n}\n\nasync function startCallbackServer(\n\tcallbackPath: string,\n\tverifier: string,\n\tsignal?: AbortSignal,\n): Promise<OpenRouterCallbackServer> {\n\tif (signal?.aborted) throw new Error(\"Login cancelled\");\n\tconst callbackHost = getCallbackHost();\n\tlet resolveCredential: (credential: OAuthCredential | null) => void = () => {};\n\tlet rejectCredential: (error: Error) => void = () => {};\n\tconst credential = new Promise<OAuthCredential | null>((resolve, reject) => {\n\t\tresolveCredential = resolve;\n\t\trejectCredential = reject;\n\t});\n\n\tlet server: Server;\n\tlet claimed = false;\n\tlet settled = false;\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet onAbort: (() => void) | undefined;\n\n\tconst close = (): void => {\n\t\tif (timeout) clearTimeout(timeout);\n\t\tif (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n\t\tserver.close();\n\t};\n\n\tconst finish = (result: { credential: OAuthCredential | null } | { error: Error }): void => {\n\t\tif (settled) return;\n\t\tsettled = true;\n\t\tclose();\n\t\tif (\"credential\" in result) resolveCredential(result.credential);\n\t\telse rejectCredential(result.error);\n\t};\n\n\tserver = createServer((request, response) => {\n\t\tvoid (async () => {\n\t\t\tconst requestUrl = new URL(request.url ?? \"/\", `http://${callbackHost}`);\n\t\t\tif (request.method !== \"GET\" || requestUrl.pathname !== callbackPath) {\n\t\t\t\tsendHtml(response, 404, oauthErrorHtml(\"OAuth callback route not found.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (claimed || settled) {\n\t\t\t\tsendHtml(response, 409, oauthErrorHtml(\"This OAuth callback has already been used.\"));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst oauthError = requestUrl.searchParams.get(\"error\");\n\t\t\tif (oauthError) {\n\t\t\t\tconst description = requestUrl.searchParams.get(\"error_description\") ?? oauthError;\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter authorization was denied.\", description));\n\t\t\t\tfinish({ error: new Error(`OpenRouter authorization failed: ${description}`) });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst code = requestUrl.searchParams.get(\"code\");\n\t\t\tif (!code) {\n\t\t\t\tsendHtml(response, 400, oauthErrorHtml(\"OpenRouter returned no authorization code.\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tclaimed = true;\n\n\t\t\ttry {\n\t\t\t\tconst result = await exchangeAuthorizationCode(code, verifier, signal);\n\t\t\t\tsendHtml(response, 200, oauthSuccessHtml(\"Signed in to OpenRouter. You may now close this page.\"));\n\t\t\t\tfinish({ credential: result });\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown token exchange error\";\n\t\t\t\tsendHtml(response, 502, oauthErrorHtml(\"OpenRouter key exchange failed.\", message));\n\t\t\t\tfinish({ error: error instanceof Error ? error : new Error(message) });\n\t\t\t}\n\t\t})();\n\t});\n\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.once(\"error\", reject);\n\t\tserver.listen(0, callbackHost, () => {\n\t\t\tserver.removeListener(\"error\", reject);\n\t\t\tresolve();\n\t\t});\n\t});\n\n\tserver.on(\"error\", (error) => finish({ error }));\n\tonAbort = () => finish({ error: new Error(\"Login cancelled\") });\n\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\tif (signal?.aborted) {\n\t\tclose();\n\t\tthrow new Error(\"Login cancelled\");\n\t}\n\ttimeout = setTimeout(() => finish({ error: new Error(\"OpenRouter OAuth login timed out\") }), LOGIN_TIMEOUT_MS);\n\n\tconst address = server.address();\n\tif (!address || typeof address === \"string\") {\n\t\tclose();\n\t\tthrow new Error(\"Could not determine the OpenRouter OAuth callback port\");\n\t}\n\n\treturn {\n\t\tcallbackUrl: `http://${callbackHost}:${address.port}${callbackPath}`,\n\t\tclose,\n\t\t// A claimed callback is already exchanging its code; let that exchange settle the login.\n\t\tcancelWait: () => {\n\t\t\tif (!claimed) finish({ credential: null });\n\t\t},\n\t\twaitForCredential: () => credential,\n\t};\n}\n\nasync function loginOpenRouter(interaction: AuthInteraction): Promise<OAuthCredential> {\n\tconst { verifier, challenge } = await generatePKCE();\n\tconst callbackPath = `/oauth/callback/${crypto.randomUUID()}`;\n\tconst callback = await startCallbackServer(callbackPath, verifier, interaction.signal);\n\tconst manualAbort = new AbortController();\n\tlet manualInput: string | undefined;\n\tlet manualError: Error | undefined;\n\n\ttry {\n\t\tconst authorizeUrl = new URL(AUTHORIZE_URL);\n\t\tauthorizeUrl.search = new URLSearchParams({\n\t\t\tcallback_url: callback.callbackUrl,\n\t\t\tcode_challenge: challenge,\n\t\t\tcode_challenge_method: \"S256\",\n\t\t}).toString();\n\n\t\tinteraction.notify({\n\t\t\ttype: \"progress\",\n\t\t\tmessage: `Listening for OpenRouter OAuth callback on ${callback.callbackUrl}`,\n\t\t});\n\t\tinteraction.notify({\n\t\t\ttype: \"auth_url\",\n\t\t\turl: authorizeUrl.toString(),\n\t\t\tinstructions:\n\t\t\t\t\"Complete sign-in in your browser. If the browser is on another machine, paste the final redirect URL here.\",\n\t\t});\n\n\t\tconst manualPromise = interaction\n\t\t\t.prompt({\n\t\t\t\ttype: \"manual_code\",\n\t\t\t\tmessage: \"Complete sign-in in your browser, or paste the authorization code / redirect URL here:\",\n\t\t\t\tplaceholder: callback.callbackUrl,\n\t\t\t\tsignal: manualAbort.signal,\n\t\t\t})\n\t\t\t.then((input) => {\n\t\t\t\tmanualInput = input;\n\t\t\t\tcallback.cancelWait();\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tmanualError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tcallback.cancelWait();\n\t\t\t});\n\n\t\tconst credential = await callback.waitForCredential();\n\t\tif (manualError) throw manualError;\n\t\tif (credential) return credential;\n\n\t\tawait manualPromise;\n\t\tif (manualError) throw manualError;\n\t\tconst code = manualInput ? parseAuthorizationInput(manualInput) : undefined;\n\t\tif (!code) throw new Error(\"Missing authorization code\");\n\t\tinteraction.notify({ type: \"progress\", message: \"Exchanging authorization code for an API key...\" });\n\t\treturn await exchangeAuthorizationCode(code, verifier, interaction.signal);\n\t} finally {\n\t\tmanualAbort.abort();\n\t\tcallback.close();\n\t}\n}\n\nexport const openRouterOAuth: OAuthAuth = {\n\tname: \"OpenRouter OAuth\",\n\tloginLabel: \"Sign in with OpenRouter\",\n\tlogin: loginOpenRouter,\n\tasync refresh(credential) {\n\t\treturn credential;\n\t},\n\tasync toAuth(credential) {\n\t\treturn { apiKey: credential.access };\n\t},\n};\n"]}
@@ -4,6 +4,8 @@ export type ModelsErrorCode = "model_source" | "model_validation" | "provider" |
4
4
  export interface AuthResolutionOverrides {
5
5
  apiKey?: string;
6
6
  env?: ProviderEnv;
7
+ /** Require this much remaining OAuth-token validity; defaults to five minutes. */
8
+ minOAuthValidityMs?: number;
7
9
  }
8
10
  export declare class ModelsError extends Error {
9
11
  readonly code: ModelsErrorCode;
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAGX,WAAW,EACX,UAAU,EAEV,eAAe,EAGf,YAAY,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,kBAAkB,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7G,MAAM,WAAW,uBAAuB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,YAAY,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIhF;CACD;AAUD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,EAC5C,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,uBAAuB,GACjC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA2BjC","sourcesContent":["import type { ProviderEnv } from \"../types.ts\";\nimport { formatThrownValue } from \"../utils/diagnostics.ts\";\nimport type {\n\tApiKeyAuth,\n\tApiKeyCredential,\n\tAuthContext,\n\tAuthResult,\n\tCredential,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tProviderAuth,\n} from \"./types.ts\";\n\nexport type ModelsErrorCode = \"model_source\" | \"model_validation\" | \"provider\" | \"stream\" | \"auth\" | \"oauth\";\n\nexport interface AuthResolutionOverrides {\n\tapiKey?: string;\n\tenv?: ProviderEnv;\n}\n\nexport class ModelsError extends Error {\n\treadonly code: ModelsErrorCode;\n\n\tconstructor(code: ModelsErrorCode, message: string, options?: { cause?: unknown }) {\n\t\tsuper(withCauseDetail(message, options?.cause), options);\n\t\tthis.name = \"ModelsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Callers surface `error.message` only, so keep the underlying reason in it. */\nfunction withCauseDetail(message: string, cause: unknown): string {\n\tif (cause === undefined || cause === null) return message;\n\tconst detail = formatThrownValue(cause).trim();\n\tif (!detail || message.includes(detail)) return message;\n\treturn `${message}: ${detail}`;\n}\n\n/**\n * Auth resolution shared by the `Models` and `ImagesModels` collections.\n * A stored credential owns the provider: ambient/env is consulted only when\n * nothing is stored. No silent env fallback after a failed refresh or for a\n * credential type without a matching handler.\n */\nexport async function resolveProviderAuth(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides?: AuthResolutionOverrides,\n): Promise<AuthResult | undefined> {\n\tconst requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;\n\n\tif (overrides?.apiKey !== undefined && provider.auth.apiKey) {\n\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, {\n\t\t\ttype: \"api_key\",\n\t\t\tkey: overrides.apiKey,\n\t\t\tenv: overrides.env,\n\t\t});\n\t}\n\n\tconst stored = await readCredential(credentials, provider.id);\n\tif (stored) {\n\t\tif (stored.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, stored);\n\t\t}\n\t\tif (stored.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Ambient (env vars, AWS profiles, ADC files).\n\treturn provider.auth.apiKey\n\t\t? resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, undefined)\n\t\t: undefined;\n}\n\nfunction overlayEnvAuthContext(base: AuthContext, env: ProviderEnv): AuthContext {\n\treturn {\n\t\tenv: async (name) => env[name] || (await base.env(name)),\n\t\tfileExists: (path) => base.fileExists(path),\n\t};\n}\n\n/**\n * OAuth resolution with double-checked locking (same pattern as today's\n * AuthStorage): valid tokens cost zero locks; expired tokens lock, re-check\n * expiry under the lock, refresh once globally, and persist the rotated\n * credential before release.\n */\nasync function resolveStoredOAuth(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\toauth: OAuthAuth,\n\tstored: OAuthCredential,\n): Promise<AuthResult | undefined> {\n\tlet credential = stored;\n\n\tif (Date.now() >= credential.expires) {\n\t\t// Optimistic check said expired; the authoritative check runs under the lock.\n\t\tlet post: Credential | undefined;\n\t\ttry {\n\t\t\tpost = await credentials.modify(providerId, async (current) => {\n\t\t\t\tif (current?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\t\t\tif (Date.now() < current.expires) return undefined; // another process/request refreshed\n\t\t\t\ttry {\n\t\t\t\t\treturn await oauth.refresh(current);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh failed for ${providerId}`, { cause: error });\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof ModelsError) throw error;\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\tif (post?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\tcredential = post;\n\t}\n\n\ttry {\n\t\treturn { auth: await oauth.toAuth(credential), source: \"OAuth\" };\n\t} catch (error) {\n\t\tthrow new ModelsError(\"oauth\", `OAuth auth derivation failed for ${providerId}`, { cause: error });\n\t}\n}\n\nasync function resolveApiKey(\n\tauthContext: AuthContext,\n\tapiKey: ApiKeyAuth,\n\tproviderId: string,\n\tcredential: ApiKeyCredential | undefined,\n): Promise<AuthResult | undefined> {\n\ttry {\n\t\treturn await apiKey.resolve({ ctx: authContext, credential });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `API key auth failed for provider ${providerId}`, { cause: error });\n\t}\n}\n\nasync function readCredential(credentials: CredentialStore, providerId: string): Promise<Credential | undefined> {\n\ttry {\n\t\treturn await credentials.read(providerId);\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t}\n}\n"]}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAGX,WAAW,EACX,UAAU,EAEV,eAAe,EAGf,YAAY,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,kBAAkB,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7G,MAAM,WAAW,uBAAuB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,WAAY,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,YAAY,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIhF;CACD;AAUD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,EAC5C,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,uBAAuB,GACjC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAiCjC","sourcesContent":["import type { ProviderEnv } from \"../types.ts\";\nimport { formatThrownValue } from \"../utils/diagnostics.ts\";\nimport type {\n\tApiKeyAuth,\n\tApiKeyCredential,\n\tAuthContext,\n\tAuthResult,\n\tCredential,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tProviderAuth,\n} from \"./types.ts\";\n\nexport type ModelsErrorCode = \"model_source\" | \"model_validation\" | \"provider\" | \"stream\" | \"auth\" | \"oauth\";\n\nexport interface AuthResolutionOverrides {\n\tapiKey?: string;\n\tenv?: ProviderEnv;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n\nexport class ModelsError extends Error {\n\treadonly code: ModelsErrorCode;\n\n\tconstructor(code: ModelsErrorCode, message: string, options?: { cause?: unknown }) {\n\t\tsuper(withCauseDetail(message, options?.cause), options);\n\t\tthis.name = \"ModelsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Callers surface `error.message` only, so keep the underlying reason in it. */\nfunction withCauseDetail(message: string, cause: unknown): string {\n\tif (cause === undefined || cause === null) return message;\n\tconst detail = formatThrownValue(cause).trim();\n\tif (!detail || message.includes(detail)) return message;\n\treturn `${message}: ${detail}`;\n}\n\n/**\n * Auth resolution shared by the `Models` and `ImagesModels` collections.\n * A stored credential owns the provider: ambient/env is consulted only when\n * nothing is stored. No silent env fallback after a failed refresh or for a\n * credential type without a matching handler.\n */\nexport async function resolveProviderAuth(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides?: AuthResolutionOverrides,\n): Promise<AuthResult | undefined> {\n\tconst requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;\n\n\tif (overrides?.apiKey !== undefined && provider.auth.apiKey) {\n\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, {\n\t\t\ttype: \"api_key\",\n\t\t\tkey: overrides.apiKey,\n\t\t\tenv: overrides.env,\n\t\t});\n\t}\n\n\tconst stored = await readCredential(credentials, provider.id);\n\tif (stored) {\n\t\tif (stored.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(\n\t\t\t\tcredentials,\n\t\t\t\tprovider.id,\n\t\t\t\tprovider.auth.oauth,\n\t\t\t\tstored,\n\t\t\t\toverrides?.minOAuthValidityMs,\n\t\t\t);\n\t\t}\n\t\tif (stored.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Ambient (env vars, AWS profiles, ADC files).\n\treturn provider.auth.apiKey\n\t\t? resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, undefined)\n\t\t: undefined;\n}\n\nfunction overlayEnvAuthContext(base: AuthContext, env: ProviderEnv): AuthContext {\n\treturn {\n\t\tenv: async (name) => env[name] || (await base.env(name)),\n\t\tfileExists: (path) => base.fileExists(path),\n\t};\n}\n\nconst DEFAULT_OAUTH_MINIMUM_VALIDITY_MS = 5 * 60 * 1000;\n\n/**\n * OAuth resolution with double-checked locking: tokens with less than five\n * minutes remaining lock, re-check expiry under the lock, refresh once\n * globally, and persist the rotated credential before release.\n */\nasync function resolveStoredOAuth(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\toauth: OAuthAuth,\n\tstored: OAuthCredential,\n\tminOAuthValidityMs?: number,\n): Promise<AuthResult | undefined> {\n\tconst minimumValidityMs = Math.max(DEFAULT_OAUTH_MINIMUM_VALIDITY_MS, minOAuthValidityMs ?? 0);\n\tconst expiresSoon = (credential: OAuthCredential) => Date.now() + minimumValidityMs >= credential.expires;\n\tlet credential = stored;\n\n\tif (expiresSoon(credential)) {\n\t\t// Optimistic check said expired; the authoritative check runs under the lock.\n\t\tlet post: Credential | undefined;\n\t\ttry {\n\t\t\tpost = await credentials.modify(providerId, async (current) => {\n\t\t\t\tif (current?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\t\t\tif (!expiresSoon(current)) return undefined; // another process/request refreshed\n\t\t\t\ttry {\n\t\t\t\t\treturn await oauth.refresh(current);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh failed for ${providerId}`, { cause: error });\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof ModelsError) throw error;\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\tif (post?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\tcredential = post;\n\t\t// The normal five-minute window triggers a refresh but does not impose a\n\t\t// provider contract. Explicit callers (such as bearer-token export) do\n\t\t// require the requested minimum after the refresh.\n\t\tif (minOAuthValidityMs !== undefined && expiresSoon(credential)) {\n\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh returned a token that expires too soon for ${providerId}`);\n\t\t}\n\t}\n\n\ttry {\n\t\treturn { auth: await oauth.toAuth(credential), source: \"OAuth\" };\n\t} catch (error) {\n\t\tthrow new ModelsError(\"oauth\", `OAuth auth derivation failed for ${providerId}`, { cause: error });\n\t}\n}\n\nasync function resolveApiKey(\n\tauthContext: AuthContext,\n\tapiKey: ApiKeyAuth,\n\tproviderId: string,\n\tcredential: ApiKeyCredential | undefined,\n): Promise<AuthResult | undefined> {\n\ttry {\n\t\treturn await apiKey.resolve({ ctx: authContext, credential });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `API key auth failed for provider ${providerId}`, { cause: error });\n\t}\n}\n\nasync function readCredential(credentials: CredentialStore, providerId: string): Promise<Credential | undefined> {\n\ttry {\n\t\treturn await credentials.read(providerId);\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t}\n}\n"]}
@@ -34,7 +34,7 @@ export async function resolveProviderAuth(provider, credentials, authContext, ov
34
34
  const stored = await readCredential(credentials, provider.id);
35
35
  if (stored) {
36
36
  if (stored.type === "oauth" && provider.auth.oauth) {
37
- return resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, stored);
37
+ return resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, stored, overrides?.minOAuthValidityMs);
38
38
  }
39
39
  if (stored.type === "api_key" && provider.auth.apiKey) {
40
40
  const credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;
@@ -53,22 +53,24 @@ function overlayEnvAuthContext(base, env) {
53
53
  fileExists: (path) => base.fileExists(path),
54
54
  };
55
55
  }
56
+ const DEFAULT_OAUTH_MINIMUM_VALIDITY_MS = 5 * 60 * 1000;
56
57
  /**
57
- * OAuth resolution with double-checked locking (same pattern as today's
58
- * AuthStorage): valid tokens cost zero locks; expired tokens lock, re-check
59
- * expiry under the lock, refresh once globally, and persist the rotated
60
- * credential before release.
58
+ * OAuth resolution with double-checked locking: tokens with less than five
59
+ * minutes remaining lock, re-check expiry under the lock, refresh once
60
+ * globally, and persist the rotated credential before release.
61
61
  */
62
- async function resolveStoredOAuth(credentials, providerId, oauth, stored) {
62
+ async function resolveStoredOAuth(credentials, providerId, oauth, stored, minOAuthValidityMs) {
63
+ const minimumValidityMs = Math.max(DEFAULT_OAUTH_MINIMUM_VALIDITY_MS, minOAuthValidityMs ?? 0);
64
+ const expiresSoon = (credential) => Date.now() + minimumValidityMs >= credential.expires;
63
65
  let credential = stored;
64
- if (Date.now() >= credential.expires) {
66
+ if (expiresSoon(credential)) {
65
67
  // Optimistic check said expired; the authoritative check runs under the lock.
66
68
  let post;
67
69
  try {
68
70
  post = await credentials.modify(providerId, async (current) => {
69
71
  if (current?.type !== "oauth")
70
72
  return undefined; // logged out meanwhile
71
- if (Date.now() < current.expires)
73
+ if (!expiresSoon(current))
72
74
  return undefined; // another process/request refreshed
73
75
  try {
74
76
  return await oauth.refresh(current);
@@ -86,6 +88,12 @@ async function resolveStoredOAuth(credentials, providerId, oauth, stored) {
86
88
  if (post?.type !== "oauth")
87
89
  return undefined; // logged out meanwhile
88
90
  credential = post;
91
+ // The normal five-minute window triggers a refresh but does not impose a
92
+ // provider contract. Explicit callers (such as bearer-token export) do
93
+ // require the requested minimum after the refresh.
94
+ if (minOAuthValidityMs !== undefined && expiresSoon(credential)) {
95
+ throw new ModelsError("oauth", `OAuth refresh returned a token that expires too soon for ${providerId}`);
96
+ }
89
97
  }
90
98
  try {
91
99
  return { auth: await oauth.toAuth(credential), source: "OAuth" };
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAoB5D,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC5B,IAAI,CAAkB;IAE/B,YAAY,IAAqB,EAAE,OAAe,EAAE,OAA6B,EAAE;QAClF,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAED,iFAAiF;AACjF,SAAS,eAAe,CAAC,OAAe,EAAE,KAAc,EAAU;IACjE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IAC1D,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C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,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AAAA,CACD;AAED,KAAK,UAAU,cAAc,CAAC,WAA4B,EAAE,UAAkB,EAAmC;IAChH,IAAI,CAAC;QACJ,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AAAA,CACD","sourcesContent":["import type { ProviderEnv } from \"../types.ts\";\nimport { formatThrownValue } from \"../utils/diagnostics.ts\";\nimport type {\n\tApiKeyAuth,\n\tApiKeyCredential,\n\tAuthContext,\n\tAuthResult,\n\tCredential,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tProviderAuth,\n} from \"./types.ts\";\n\nexport type ModelsErrorCode = \"model_source\" | \"model_validation\" | \"provider\" | \"stream\" | \"auth\" | \"oauth\";\n\nexport interface AuthResolutionOverrides {\n\tapiKey?: string;\n\tenv?: ProviderEnv;\n}\n\nexport class ModelsError extends Error {\n\treadonly code: ModelsErrorCode;\n\n\tconstructor(code: ModelsErrorCode, message: string, options?: { cause?: unknown }) {\n\t\tsuper(withCauseDetail(message, options?.cause), options);\n\t\tthis.name = \"ModelsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Callers surface `error.message` only, so keep the underlying reason in it. */\nfunction withCauseDetail(message: string, cause: unknown): string {\n\tif (cause === undefined || cause === null) return message;\n\tconst detail = formatThrownValue(cause).trim();\n\tif (!detail || message.includes(detail)) return message;\n\treturn `${message}: ${detail}`;\n}\n\n/**\n * Auth resolution shared by the `Models` and `ImagesModels` collections.\n * A stored credential owns the provider: ambient/env is consulted only when\n * nothing is stored. No silent env fallback after a failed refresh or for a\n * credential type without a matching handler.\n */\nexport async function resolveProviderAuth(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides?: AuthResolutionOverrides,\n): Promise<AuthResult | undefined> {\n\tconst requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;\n\n\tif (overrides?.apiKey !== undefined && provider.auth.apiKey) {\n\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, {\n\t\t\ttype: \"api_key\",\n\t\t\tkey: overrides.apiKey,\n\t\t\tenv: overrides.env,\n\t\t});\n\t}\n\n\tconst stored = await readCredential(credentials, provider.id);\n\tif (stored) {\n\t\tif (stored.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(credentials, provider.id, provider.auth.oauth, stored);\n\t\t}\n\t\tif (stored.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Ambient (env vars, AWS profiles, ADC files).\n\treturn provider.auth.apiKey\n\t\t? resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, undefined)\n\t\t: undefined;\n}\n\nfunction overlayEnvAuthContext(base: AuthContext, env: ProviderEnv): AuthContext {\n\treturn {\n\t\tenv: async (name) => env[name] || (await base.env(name)),\n\t\tfileExists: (path) => base.fileExists(path),\n\t};\n}\n\n/**\n * OAuth resolution with double-checked locking (same pattern as today's\n * AuthStorage): valid tokens cost zero locks; expired tokens lock, re-check\n * expiry under the lock, refresh once globally, and persist the rotated\n * credential before release.\n */\nasync function resolveStoredOAuth(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\toauth: OAuthAuth,\n\tstored: OAuthCredential,\n): Promise<AuthResult | undefined> {\n\tlet credential = stored;\n\n\tif (Date.now() >= credential.expires) {\n\t\t// Optimistic check said expired; the authoritative check runs under the lock.\n\t\tlet post: Credential | undefined;\n\t\ttry {\n\t\t\tpost = await credentials.modify(providerId, async (current) => {\n\t\t\t\tif (current?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\t\t\tif (Date.now() < current.expires) return undefined; // another process/request refreshed\n\t\t\t\ttry {\n\t\t\t\t\treturn await oauth.refresh(current);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh failed for ${providerId}`, { cause: error });\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof ModelsError) throw error;\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\tif (post?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\tcredential = post;\n\t}\n\n\ttry {\n\t\treturn { auth: await oauth.toAuth(credential), source: \"OAuth\" };\n\t} catch (error) {\n\t\tthrow new ModelsError(\"oauth\", `OAuth auth derivation failed for ${providerId}`, { cause: error });\n\t}\n}\n\nasync function resolveApiKey(\n\tauthContext: AuthContext,\n\tapiKey: ApiKeyAuth,\n\tproviderId: string,\n\tcredential: ApiKeyCredential | undefined,\n): Promise<AuthResult | undefined> {\n\ttry {\n\t\treturn await apiKey.resolve({ ctx: authContext, credential });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `API key auth failed for provider ${providerId}`, { cause: error });\n\t}\n}\n\nasync function readCredential(credentials: CredentialStore, providerId: string): Promise<Credential | undefined> {\n\ttry {\n\t\treturn await credentials.read(providerId);\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t}\n}\n"]}
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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CACD;AAED,KAAK,UAAU,cAAc,CAAC,WAA4B,EAAE,UAAkB,EAAmC;IAChH,IAAI,CAAC;QACJ,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,EAAE,oCAAoC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACnG,CAAC;AAAA,CACD","sourcesContent":["import type { ProviderEnv } from \"../types.ts\";\nimport { formatThrownValue } from \"../utils/diagnostics.ts\";\nimport type {\n\tApiKeyAuth,\n\tApiKeyCredential,\n\tAuthContext,\n\tAuthResult,\n\tCredential,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tProviderAuth,\n} from \"./types.ts\";\n\nexport type ModelsErrorCode = \"model_source\" | \"model_validation\" | \"provider\" | \"stream\" | \"auth\" | \"oauth\";\n\nexport interface AuthResolutionOverrides {\n\tapiKey?: string;\n\tenv?: ProviderEnv;\n\t/** Require this much remaining OAuth-token validity; defaults to five minutes. */\n\tminOAuthValidityMs?: number;\n}\n\nexport class ModelsError extends Error {\n\treadonly code: ModelsErrorCode;\n\n\tconstructor(code: ModelsErrorCode, message: string, options?: { cause?: unknown }) {\n\t\tsuper(withCauseDetail(message, options?.cause), options);\n\t\tthis.name = \"ModelsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Callers surface `error.message` only, so keep the underlying reason in it. */\nfunction withCauseDetail(message: string, cause: unknown): string {\n\tif (cause === undefined || cause === null) return message;\n\tconst detail = formatThrownValue(cause).trim();\n\tif (!detail || message.includes(detail)) return message;\n\treturn `${message}: ${detail}`;\n}\n\n/**\n * Auth resolution shared by the `Models` and `ImagesModels` collections.\n * A stored credential owns the provider: ambient/env is consulted only when\n * nothing is stored. No silent env fallback after a failed refresh or for a\n * credential type without a matching handler.\n */\nexport async function resolveProviderAuth(\n\tprovider: { id: string; auth: ProviderAuth },\n\tcredentials: CredentialStore,\n\tauthContext: AuthContext,\n\toverrides?: AuthResolutionOverrides,\n): Promise<AuthResult | undefined> {\n\tconst requestAuthContext = overrides?.env ? overlayEnvAuthContext(authContext, overrides.env) : authContext;\n\n\tif (overrides?.apiKey !== undefined && provider.auth.apiKey) {\n\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, {\n\t\t\ttype: \"api_key\",\n\t\t\tkey: overrides.apiKey,\n\t\t\tenv: overrides.env,\n\t\t});\n\t}\n\n\tconst stored = await readCredential(credentials, provider.id);\n\tif (stored) {\n\t\tif (stored.type === \"oauth\" && provider.auth.oauth) {\n\t\t\treturn resolveStoredOAuth(\n\t\t\t\tcredentials,\n\t\t\t\tprovider.id,\n\t\t\t\tprovider.auth.oauth,\n\t\t\t\tstored,\n\t\t\t\toverrides?.minOAuthValidityMs,\n\t\t\t);\n\t\t}\n\t\tif (stored.type === \"api_key\" && provider.auth.apiKey) {\n\t\t\tconst credential = overrides?.env ? { ...stored, env: { ...stored.env, ...overrides.env } } : stored;\n\t\t\treturn resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, credential);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// Ambient (env vars, AWS profiles, ADC files).\n\treturn provider.auth.apiKey\n\t\t? resolveApiKey(requestAuthContext, provider.auth.apiKey, provider.id, undefined)\n\t\t: undefined;\n}\n\nfunction overlayEnvAuthContext(base: AuthContext, env: ProviderEnv): AuthContext {\n\treturn {\n\t\tenv: async (name) => env[name] || (await base.env(name)),\n\t\tfileExists: (path) => base.fileExists(path),\n\t};\n}\n\nconst DEFAULT_OAUTH_MINIMUM_VALIDITY_MS = 5 * 60 * 1000;\n\n/**\n * OAuth resolution with double-checked locking: tokens with less than five\n * minutes remaining lock, re-check expiry under the lock, refresh once\n * globally, and persist the rotated credential before release.\n */\nasync function resolveStoredOAuth(\n\tcredentials: CredentialStore,\n\tproviderId: string,\n\toauth: OAuthAuth,\n\tstored: OAuthCredential,\n\tminOAuthValidityMs?: number,\n): Promise<AuthResult | undefined> {\n\tconst minimumValidityMs = Math.max(DEFAULT_OAUTH_MINIMUM_VALIDITY_MS, minOAuthValidityMs ?? 0);\n\tconst expiresSoon = (credential: OAuthCredential) => Date.now() + minimumValidityMs >= credential.expires;\n\tlet credential = stored;\n\n\tif (expiresSoon(credential)) {\n\t\t// Optimistic check said expired; the authoritative check runs under the lock.\n\t\tlet post: Credential | undefined;\n\t\ttry {\n\t\t\tpost = await credentials.modify(providerId, async (current) => {\n\t\t\t\tif (current?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\t\t\tif (!expiresSoon(current)) return undefined; // another process/request refreshed\n\t\t\t\ttry {\n\t\t\t\t\treturn await oauth.refresh(current);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh failed for ${providerId}`, { cause: error });\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof ModelsError) throw error;\n\t\t\tthrow new ModelsError(\"auth\", `Credential store modify failed for ${providerId}`, { cause: error });\n\t\t}\n\t\tif (post?.type !== \"oauth\") return undefined; // logged out meanwhile\n\t\tcredential = post;\n\t\t// The normal five-minute window triggers a refresh but does not impose a\n\t\t// provider contract. Explicit callers (such as bearer-token export) do\n\t\t// require the requested minimum after the refresh.\n\t\tif (minOAuthValidityMs !== undefined && expiresSoon(credential)) {\n\t\t\tthrow new ModelsError(\"oauth\", `OAuth refresh returned a token that expires too soon for ${providerId}`);\n\t\t}\n\t}\n\n\ttry {\n\t\treturn { auth: await oauth.toAuth(credential), source: \"OAuth\" };\n\t} catch (error) {\n\t\tthrow new ModelsError(\"oauth\", `OAuth auth derivation failed for ${providerId}`, { cause: error });\n\t}\n}\n\nasync function resolveApiKey(\n\tauthContext: AuthContext,\n\tapiKey: ApiKeyAuth,\n\tproviderId: string,\n\tcredential: ApiKeyCredential | undefined,\n): Promise<AuthResult | undefined> {\n\ttry {\n\t\treturn await apiKey.resolve({ ctx: authContext, credential });\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `API key auth failed for provider ${providerId}`, { cause: error });\n\t}\n}\n\nasync function readCredential(credentials: CredentialStore, providerId: string): Promise<Credential | undefined> {\n\ttry {\n\t\treturn await credentials.read(providerId);\n\t} catch (error) {\n\t\tthrow new ModelsError(\"auth\", `Credential store read failed for ${providerId}`, { cause: error });\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"schemaVersion":3,"generatedAt":"2026-07-25T12:44:19.521Z","structureHash":"1a3c7cf59ada71c94abe4540976960524ee933034491c75d6418e2abc1b42535","files":{"amazon-bedrock.json":"1aabd3227d32b332727eec7638cebdbd1323d2e7eedbf9b174226c5d38196df9","ant-ling.json":"4979fe79d99ed97382d7ce40170c6132e932e77906de1eb54464c042e7d63633","anthropic.json":"fea1226a62396c8d4a3d9c3b7f65d4dc527ac025d05719880418d3a2b0665a69","azure-openai-responses.json":"2d13ecc23826b5be73f3628fca5f70cc2c5c15ff609b41e4acba8167cd40934b","cerebras.json":"3fd3e19b83ab4be07d27817e25e5be0ffe4158b1394f0311d6a22d9f03847728","cloudflare-ai-gateway.json":"9974b65a0c6dda063ea3a30f4a819cab7bf70f9a25e5e3ee2feaf85cfc167b9b","cloudflare-workers-ai.json":"03b19d69433c843512e953390d51d4578e9b91f19098a9b14ff820c001623598","deepseek.json":"0dcc807a4e5827b488c6ceac87884ff6e735e01cf4f2ddfec9dd812e6fde041b","fireworks.json":"0ea306d50e72343439f71995dcda0776473e0e43a8500c4ff42769f085fee09d","github-copilot.json":"1215a0792908480ff709a26954b1c4b76bcfec5d31f31d0843d505770c764c1e","google-vertex.json":"99d0b89ac9d8dc460ed922236abffbe88c9381af4d35046d2ad3a8f08fa2560c","google.json":"bcf8a8d59ccbb75bc6fb4a261a37ac4b7c806f40ee7313b4411178964be5fa37","groq.json":"868c90a897f75f866e09a585f6aee5cb991e40a9c3281497b5842a23de7d9add","huggingface.json":"e001db7b5925939c5850f31cd08b323cd40eb586222e2f74d7890eb52a30f161","kimi-coding.json":"ba42a26a69e5cb2122c0b384ba572efae93f42239ad86f26c2b7320a14aa75a1","minimax-cn.json":"8ccd71ff838f4b78bb88809babb0dc32a4fcfaec2bc4f4083841000428df4f77","minimax.json":"253edd4c910a41c8bb252400ba099f3a4de0a8900ce154319288ab091b372987","mistral.json":"44531201e872713923b7544a1f75a048d31fa25292e3e1f9f896f608a52e412d","moonshotai-cn.json":"1e6146ff3477883636448c0f44222f0a52b3c4562ef8f4eecf7e941cdd59d12e","moonshotai.json":"d8d5209873058ddccd37c1f026833e2ea3f9476c3dc9628b4a940d407acc0b2e","nvidia.json":"f476e23d9c3743c8ed3bb24a7d43b33cf90d1539ebe61c070ea2323555853e25","openai-codex.json":"c3313710bc6910e6bbcb06d5867247e97ec3fa6c2af9bc780f8a3eefb03e32e1","openai.json":"8e3852ef3567b23d2ab03b0f52f1caeb77e6e776f248e6111f851ccbe0fca8b6","opencode-go.json":"57a677764bc885c83fbbba46ad5d418baabe012a062424a0f6d8d488352102ce","opencode.json":"905b27bf3d7e48f35ca862991411b97a93782ad92b24129a2c3ee377fd1e3675","openrouter.json":"bc3e1ea3de6cb962c92ec3bd45f4e73c85ba2ad62ba824253498b41f8acc2b1e","qwen-token-plan-cn.json":"a1495ccc21835c51d438207652f948aa9ecf4a3d784e81deaf313e484bdab1ec","qwen-token-plan.json":"597fae649f549a8ffb0b6a28426ea6761b7ece41a78b6fdef49ca970ac029970","together.json":"1d46a57e99da9be6f7e78d8f98f5610adbb266df3de7b0a13652d6fa175086e7","vercel-ai-gateway.json":"61242947db49d08e4a70ccf4cd16eea9d58758effc35c2f6abdd953f8da64013","xai.json":"4cbdbfbbf915246369b9bacbc6f1feeb56accdac9f3444456343f750547f2f38","xiaomi-token-plan-ams.json":"7ce8ed244672c45737d286ff3ca9c3a2686a5d4b2f0c5f71ab9348c14b14daf3","xiaomi-token-plan-cn.json":"684892b5fe6fa371d6040d2011c0fa33facd650d2eaf19f5dbee8efb33016200","xiaomi-token-plan-sgp.json":"b19e79b82ac4fdcb080e6d220106797504c885ed70b27fc2b3c1aa4810f32963","xiaomi.json":"810368d3828c8bb9498012a0d48639030c0c216b8c13e79da02daa515aa23448","zai-coding-cn.json":"28fcb04ce65b4c6612a6b866902e0c832e18b685e5374578c4e2872569131d39","zai.json":"474670a0cf1109f4c296ea93d2c5c6eb8f53541dc9c0bddbb0e6cb054b971ebe"}}
1
+ {"schemaVersion":3,"generatedAt":"2026-07-29T22:27:21.904Z","structureHash":"5d82f5b1946bdf6d01733aa2a4e4410849c6d44a2ad3038171078c17aed367ce","files":{"amazon-bedrock.json":"1aabd3227d32b332727eec7638cebdbd1323d2e7eedbf9b174226c5d38196df9","ant-ling.json":"4979fe79d99ed97382d7ce40170c6132e932e77906de1eb54464c042e7d63633","anthropic.json":"fea1226a62396c8d4a3d9c3b7f65d4dc527ac025d05719880418d3a2b0665a69","azure-openai-responses.json":"2d13ecc23826b5be73f3628fca5f70cc2c5c15ff609b41e4acba8167cd40934b","cerebras.json":"3fd3e19b83ab4be07d27817e25e5be0ffe4158b1394f0311d6a22d9f03847728","cloudflare-ai-gateway.json":"692b375a3bcb11743a9c1899442caecc3861163d9424356d3d073d9fa5c04091","cloudflare-workers-ai.json":"03b19d69433c843512e953390d51d4578e9b91f19098a9b14ff820c001623598","deepseek.json":"0dcc807a4e5827b488c6ceac87884ff6e735e01cf4f2ddfec9dd812e6fde041b","fireworks.json":"befd3127f292d32e62306da05469e93e10d8b0e6572dbc2df991e3f9671e12f2","github-copilot.json":"3b30436a39d6be22dc8f809e8a7e25e85d2c91a5c9f180692ebf71be70163c60","google-vertex.json":"99d0b89ac9d8dc460ed922236abffbe88c9381af4d35046d2ad3a8f08fa2560c","google.json":"bcf8a8d59ccbb75bc6fb4a261a37ac4b7c806f40ee7313b4411178964be5fa37","groq.json":"868c90a897f75f866e09a585f6aee5cb991e40a9c3281497b5842a23de7d9add","huggingface.json":"d1952ba962c983a9f52a50323cf2475081a69b26b79467b3a9a9a06f8ab68899","kimi-coding.json":"ba42a26a69e5cb2122c0b384ba572efae93f42239ad86f26c2b7320a14aa75a1","minimax-cn.json":"8ccd71ff838f4b78bb88809babb0dc32a4fcfaec2bc4f4083841000428df4f77","minimax.json":"253edd4c910a41c8bb252400ba099f3a4de0a8900ce154319288ab091b372987","mistral.json":"44531201e872713923b7544a1f75a048d31fa25292e3e1f9f896f608a52e412d","moonshotai-cn.json":"1e6146ff3477883636448c0f44222f0a52b3c4562ef8f4eecf7e941cdd59d12e","moonshotai.json":"d8d5209873058ddccd37c1f026833e2ea3f9476c3dc9628b4a940d407acc0b2e","nvidia.json":"33c498ab62940fe9ca659826c35cc922a77938a5f7edbe4443c10d9133323e87","openai-codex.json":"c3313710bc6910e6bbcb06d5867247e97ec3fa6c2af9bc780f8a3eefb03e32e1","openai.json":"8e3852ef3567b23d2ab03b0f52f1caeb77e6e776f248e6111f851ccbe0fca8b6","opencode-go.json":"57a677764bc885c83fbbba46ad5d418baabe012a062424a0f6d8d488352102ce","opencode.json":"d4df3d4d4f8ef5970fbdfd02cdd5a643bddd5a1664307bb45da3503615a3e08e","openrouter.json":"f57911b114dbf272d311234696738288fdafc676383771179392b289834901c8","qwen-token-plan-cn.json":"9c5d76e655f9e74818c4bd137b4385252b92a0615f42da7ffabb4d61a4dc2f1a","qwen-token-plan.json":"4f89469fe53236f97c789b019d426e180f3a944b65c833c8b9a5415c2557ff24","together.json":"7192caa28dc8b59bca1d62d291708903413aac63e44d7b76362294171f2df018","vercel-ai-gateway.json":"de7354638dadbb40b8d83b6022de91e82d4dcc5c84088f1fe7033b3b3731502c","xai.json":"4cbdbfbbf915246369b9bacbc6f1feeb56accdac9f3444456343f750547f2f38","xiaomi-token-plan-ams.json":"7ce8ed244672c45737d286ff3ca9c3a2686a5d4b2f0c5f71ab9348c14b14daf3","xiaomi-token-plan-cn.json":"684892b5fe6fa371d6040d2011c0fa33facd650d2eaf19f5dbee8efb33016200","xiaomi-token-plan-sgp.json":"b19e79b82ac4fdcb080e6d220106797504c885ed70b27fc2b3c1aa4810f32963","xiaomi.json":"810368d3828c8bb9498012a0d48639030c0c216b8c13e79da02daa515aa23448","zai-coding-cn.json":"7408bc46d80b2199987f54f0df41126ef16e0621d7c0f90aaa1d70df3abb590b","zai.json":"602457a21f65879fc5273deaf89243e9b00c0c29c5503ae97ed4d2fb4548ed2b"}}