@e4779/pi-fabric 0.109.2-fork.23 → 0.116.0-fork.25

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 (346) hide show
  1. package/README.md +3 -1
  2. package/THIRD_PARTY_NOTICES.md +9 -2
  3. package/dist/agents/completion-inbox.d.ts.map +1 -1
  4. package/dist/agents/handoff.d.ts +1 -1
  5. package/dist/agents/handoff.d.ts.map +1 -1
  6. package/dist/agents/manager.d.ts +8 -0
  7. package/dist/agents/manager.d.ts.map +1 -1
  8. package/dist/agents/provider-bridge.d.ts +64 -0
  9. package/dist/agents/provider-bridge.d.ts.map +1 -0
  10. package/dist/agents/provider-bridge.js +117 -0
  11. package/dist/agents/provider-bridge.js.map +7 -0
  12. package/dist/agents/runner-registry.d.ts +3 -0
  13. package/dist/agents/runner-registry.d.ts.map +1 -1
  14. package/dist/agents/trace-context-request.d.ts +4 -0
  15. package/dist/agents/trace-context-request.d.ts.map +1 -0
  16. package/dist/agents/trace-context.d.ts +31 -0
  17. package/dist/agents/trace-context.d.ts.map +1 -0
  18. package/dist/agents/types.d.ts +13 -0
  19. package/dist/agents/types.d.ts.map +1 -1
  20. package/dist/agents.js +7 -7
  21. package/dist/audit/details.d.ts +5 -2
  22. package/dist/audit/details.d.ts.map +1 -1
  23. package/dist/capture/interceptor.d.ts.map +1 -1
  24. package/dist/chunks/{chunk-X2TRSE7D.js → chunk-2YG4ZA2K.js} +2 -2
  25. package/dist/chunks/{chunk-WHBJDTCR.js → chunk-4GGBND7V.js} +37 -10
  26. package/dist/chunks/chunk-4GGBND7V.js.map +7 -0
  27. package/dist/chunks/{chunk-N2VKKA7O.js → chunk-4GNFBZPR.js} +2 -2
  28. package/dist/chunks/{chunk-M5IN6DMF.js → chunk-56RFFBBO.js} +6 -6
  29. package/dist/chunks/{chunk-J2HUD36Z.js → chunk-5X35KXBV.js} +14 -2
  30. package/dist/chunks/{chunk-J2HUD36Z.js.map → chunk-5X35KXBV.js.map} +2 -2
  31. package/dist/chunks/{chunk-DU6ZA44F.js → chunk-6EVAHJAR.js} +5 -5
  32. package/dist/chunks/{chunk-ST36EYHN.js → chunk-6QVQXGMR.js} +1 -1
  33. package/dist/chunks/chunk-6QVQXGMR.js.map +7 -0
  34. package/dist/chunks/chunk-7C5IEIQK.js +157 -0
  35. package/dist/chunks/chunk-7C5IEIQK.js.map +7 -0
  36. package/dist/chunks/{chunk-C7EEG6SM.js → chunk-A5XF3ZPJ.js} +19 -2
  37. package/dist/chunks/chunk-A5XF3ZPJ.js.map +7 -0
  38. package/dist/chunks/{chunk-CZPQTISQ.js → chunk-BQWJ5ZR7.js} +10 -6
  39. package/dist/chunks/chunk-BQWJ5ZR7.js.map +7 -0
  40. package/dist/chunks/{chunk-ABJCSNZO.js → chunk-D3IONBBJ.js} +2 -2
  41. package/dist/chunks/{chunk-7JU7Z4XQ.js → chunk-D3W6CBJZ.js} +2 -2
  42. package/dist/chunks/{chunk-3SHUUBZJ.js → chunk-DONS3EZH.js} +3 -3
  43. package/dist/chunks/{chunk-W5CHVJBR.js → chunk-EQYQICUY.js} +54 -8
  44. package/dist/chunks/chunk-EQYQICUY.js.map +7 -0
  45. package/dist/chunks/{chunk-FB24AOIJ.js → chunk-H3SGA7G7.js} +5 -5
  46. package/dist/chunks/{chunk-ZXKYU6CH.js → chunk-HCNHKJDA.js} +2 -2
  47. package/dist/chunks/{chunk-UXEMIWYI.js → chunk-HITKWKYD.js} +11 -9
  48. package/dist/chunks/chunk-HITKWKYD.js.map +7 -0
  49. package/dist/chunks/{chunk-YYSZBD7S.js → chunk-HQ5YW2OJ.js} +2 -2
  50. package/dist/chunks/{chunk-GC2AUXG6.js → chunk-HZGQ7XYM.js} +2 -2
  51. package/dist/chunks/{chunk-WREA4RNR.js → chunk-I2TK65VR.js} +3 -3
  52. package/dist/chunks/chunk-IQXNJNDI.js +854 -0
  53. package/dist/chunks/chunk-IQXNJNDI.js.map +7 -0
  54. package/dist/chunks/{chunk-DZ4WN5XJ.js → chunk-JV4JR6TT.js} +3 -3
  55. package/dist/chunks/{chunk-3GJJG2FV.js → chunk-KBYSGB7E.js} +2 -2
  56. package/dist/chunks/chunk-KBYSGB7E.js.map +7 -0
  57. package/dist/chunks/{chunk-PF27MQY5.js → chunk-MOJBW5X2.js} +42 -3
  58. package/dist/chunks/chunk-MOJBW5X2.js.map +7 -0
  59. package/dist/chunks/{chunk-YJX27XBO.js → chunk-O7IREHJI.js} +104 -46
  60. package/dist/chunks/chunk-O7IREHJI.js.map +7 -0
  61. package/dist/chunks/{chunk-FRPNQZV2.js → chunk-ODYU3IJU.js} +81 -18
  62. package/dist/chunks/chunk-ODYU3IJU.js.map +7 -0
  63. package/dist/chunks/{chunk-LOLCTWJF.js → chunk-OTHMEDN6.js} +4 -4
  64. package/dist/chunks/{chunk-PXAICAUT.js → chunk-PBDDXBHY.js} +2 -1
  65. package/dist/chunks/chunk-PBDDXBHY.js.map +7 -0
  66. package/dist/chunks/{chunk-M6IRQ3QT.js → chunk-PH4PT6R4.js} +2 -2
  67. package/dist/chunks/{chunk-B54Z662X.js → chunk-PTZ5DKAB.js} +25 -5
  68. package/dist/chunks/chunk-PTZ5DKAB.js.map +7 -0
  69. package/dist/chunks/{chunk-RUO6L7RM.js → chunk-Q2JQ3RYZ.js} +3 -1
  70. package/dist/chunks/chunk-Q2JQ3RYZ.js.map +7 -0
  71. package/dist/chunks/{chunk-WYUV6WL3.js → chunk-QCCPR3U5.js} +4 -4
  72. package/dist/chunks/{chunk-GYPDGW27.js → chunk-QGP7AY2R.js} +4 -2
  73. package/dist/chunks/{chunk-GYPDGW27.js.map → chunk-QGP7AY2R.js.map} +2 -2
  74. package/dist/chunks/{chunk-7XRUMDV7.js → chunk-QQ7D6UAM.js} +2 -2
  75. package/dist/chunks/chunk-QRN433TI.js +19 -0
  76. package/dist/chunks/chunk-QRN433TI.js.map +7 -0
  77. package/dist/chunks/{chunk-PYQM7KPL.js → chunk-R2MMPHR2.js} +2 -2
  78. package/dist/chunks/{chunk-CXTTLBUV.js → chunk-R2XQ6AHT.js} +2 -2
  79. package/dist/chunks/{chunk-DV2JZSCI.js → chunk-SPCJXN4K.js} +14 -4
  80. package/dist/chunks/{chunk-DV2JZSCI.js.map → chunk-SPCJXN4K.js.map} +2 -2
  81. package/dist/chunks/{chunk-T5CU2GPZ.js → chunk-TNPZBMYC.js} +34 -10
  82. package/dist/chunks/chunk-TNPZBMYC.js.map +7 -0
  83. package/dist/chunks/{chunk-5SU3YXBS.js → chunk-UGYCAG6O.js} +1 -1
  84. package/dist/chunks/{chunk-5SU3YXBS.js.map → chunk-UGYCAG6O.js.map} +1 -1
  85. package/dist/chunks/{chunk-X3CHSIL2.js → chunk-V2IV4LYW.js} +3 -3
  86. package/dist/chunks/{chunk-QY7YK7M6.js → chunk-VR2LV4CA.js} +2 -2
  87. package/dist/chunks/chunk-WJJXODAB.js +82 -0
  88. package/dist/chunks/chunk-WJJXODAB.js.map +7 -0
  89. package/dist/chunks/{chunk-S3IRPDSO.js → chunk-WQ6LC2KK.js} +2 -2
  90. package/dist/chunks/{chunk-CYMDX3XP.js → chunk-WTLH5RY4.js} +2 -2
  91. package/dist/chunks/chunk-WTLH5RY4.js.map +7 -0
  92. package/dist/chunks/{chunk-BVJBYFHD.js → chunk-ZPI4QTOX.js} +2 -2
  93. package/dist/chunks/{chunk-3DUKKQHN.js → chunk-ZQMBS5SH.js} +5 -5
  94. package/dist/cli/decisions.js +1 -1
  95. package/dist/cli/mesh.js +2 -2
  96. package/dist/commands/fabric.d.ts +1 -1
  97. package/dist/commands/fabric.d.ts.map +1 -1
  98. package/dist/compaction/hook.d.ts +1 -1
  99. package/dist/compaction/hook.d.ts.map +1 -1
  100. package/dist/compaction/hook.js +6 -6
  101. package/dist/compaction/owner.js +7 -7
  102. package/dist/components/configuration.js +4 -4
  103. package/dist/config.d.ts +2 -0
  104. package/dist/config.d.ts.map +1 -1
  105. package/dist/core/action-registry.d.ts.map +1 -1
  106. package/dist/core/action-registry.js +7 -7
  107. package/dist/core/action-result.d.ts +10 -0
  108. package/dist/core/action-result.d.ts.map +1 -1
  109. package/dist/core/agent-dir.d.ts +1 -0
  110. package/dist/core/agent-dir.d.ts.map +1 -1
  111. package/dist/core/fabric-state-paths.d.ts.map +1 -1
  112. package/dist/core/host-sdk-runtime.d.ts +8 -0
  113. package/dist/core/host-sdk-runtime.d.ts.map +1 -0
  114. package/dist/core/host-sdk.d.ts +28 -0
  115. package/dist/core/host-sdk.d.ts.map +1 -0
  116. package/dist/core/host-sdk.js +11 -0
  117. package/dist/core/host-sdk.js.map +7 -0
  118. package/dist/core/provider-operations.js +1 -1
  119. package/dist/core/provider-operations.js.map +2 -2
  120. package/dist/core/session-context.d.ts +5 -0
  121. package/dist/core/session-context.d.ts.map +1 -1
  122. package/dist/core/shell-inbox.d.ts.map +1 -1
  123. package/dist/core/shell-jobs.d.ts +2 -0
  124. package/dist/core/shell-jobs.d.ts.map +1 -1
  125. package/dist/core/tool-ownership.d.ts.map +1 -1
  126. package/dist/core/tool-result-proxy.d.ts +2 -0
  127. package/dist/core/tool-result-proxy.d.ts.map +1 -1
  128. package/dist/durable/agent.d.ts +6 -0
  129. package/dist/durable/agent.d.ts.map +1 -1
  130. package/dist/durable/worker-host.d.ts.map +1 -1
  131. package/dist/durable/worker-host.js +48 -10
  132. package/dist/durable/worker-host.js.map +2 -2
  133. package/dist/durable.js +2 -2
  134. package/dist/durable.js.map +1 -1
  135. package/dist/entropy/index.js +8 -8
  136. package/dist/extension-bootstrap.js +17 -17
  137. package/dist/fabric-runtime-state.d.ts +2 -0
  138. package/dist/fabric-runtime-state.d.ts.map +1 -1
  139. package/dist/fabric-runtime-state.js +362 -101
  140. package/dist/fabric-runtime-state.js.map +4 -4
  141. package/dist/fabric-state.d.ts +2 -0
  142. package/dist/fabric-state.d.ts.map +1 -1
  143. package/dist/index.js +23 -21
  144. package/dist/index.js.map +1 -1
  145. package/dist/jev/auth.d.ts +2 -0
  146. package/dist/jev/auth.d.ts.map +1 -1
  147. package/dist/jev/client.d.ts.map +1 -1
  148. package/dist/jev/client.js +3 -3
  149. package/dist/jev/config.d.ts +5 -0
  150. package/dist/jev/config.d.ts.map +1 -1
  151. package/dist/jev/decision-profiles.d.ts +8 -0
  152. package/dist/jev/decision-profiles.d.ts.map +1 -0
  153. package/dist/jev/decision-schema.d.ts +35 -0
  154. package/dist/jev/decision-schema.d.ts.map +1 -0
  155. package/dist/jev/decision-types.d.ts +139 -0
  156. package/dist/jev/decision-types.d.ts.map +1 -0
  157. package/dist/jev/decisions.d.ts +27 -0
  158. package/dist/jev/decisions.d.ts.map +1 -0
  159. package/dist/jev/guest-types.d.ts +1 -1
  160. package/dist/jev/guest-types.d.ts.map +1 -1
  161. package/dist/jev/manager.d.ts +7 -0
  162. package/dist/jev/manager.d.ts.map +1 -1
  163. package/dist/jev/model-key.d.ts +3 -2
  164. package/dist/jev/model-key.d.ts.map +1 -1
  165. package/dist/jev/observation.js +7 -7
  166. package/dist/jev/routes.d.ts +11 -1
  167. package/dist/jev/routes.d.ts.map +1 -1
  168. package/dist/jev/types.d.ts +3 -2
  169. package/dist/jev/types.d.ts.map +1 -1
  170. package/dist/jev/validation.d.ts +34 -0
  171. package/dist/jev/validation.d.ts.map +1 -1
  172. package/dist/jev-fabric/resolve.d.ts +4 -0
  173. package/dist/jev-fabric/resolve.d.ts.map +1 -1
  174. package/dist/jev-fabric/resolve.js +1 -0
  175. package/dist/jev-fabric/resolve.js.map +2 -2
  176. package/dist/jev-fabric/serve.d.ts +5 -15
  177. package/dist/jev-fabric/serve.d.ts.map +1 -1
  178. package/dist/jev-fabric/serve.js +87 -56
  179. package/dist/jev-fabric/serve.js.map +2 -2
  180. package/dist/jev.d.ts +6 -2
  181. package/dist/jev.d.ts.map +1 -1
  182. package/dist/jev.js +37 -15
  183. package/dist/memory/digest.js +2 -2
  184. package/dist/memory/discovery.js +6 -6
  185. package/dist/memory/extractive-history.d.ts +3 -0
  186. package/dist/memory/extractive-history.d.ts.map +1 -1
  187. package/dist/memory/extractive-history.js +36 -7
  188. package/dist/memory/extractive-history.js.map +3 -3
  189. package/dist/memory/extractive-index.d.ts.map +1 -1
  190. package/dist/memory/file-worker.js +9 -9
  191. package/dist/memory/normalize.js +5 -5
  192. package/dist/memory/search.js +7 -7
  193. package/dist/memory/worker-provider.js +10 -10
  194. package/dist/memory.js +10 -10
  195. package/dist/native-codemode.d.ts.map +1 -1
  196. package/dist/protocol.d.ts +3 -0
  197. package/dist/protocol.d.ts.map +1 -1
  198. package/dist/protocol.js +3 -1
  199. package/dist/providers/agents-provider.d.ts.map +1 -1
  200. package/dist/providers/captured-tools-provider.d.ts.map +1 -1
  201. package/dist/providers/jev-provider.d.ts +2 -0
  202. package/dist/providers/jev-provider.d.ts.map +1 -1
  203. package/dist/providers/jev-provider.js +12 -12
  204. package/dist/providers/memory-provider.js +9 -9
  205. package/dist/providers/pi-bash-cwd.d.ts +1 -1
  206. package/dist/providers/pi-bash-cwd.d.ts.map +1 -1
  207. package/dist/providers/pi-tools-provider.d.ts.map +1 -1
  208. package/dist/providers/write-preview.d.ts +1 -1
  209. package/dist/providers/write-preview.d.ts.map +1 -1
  210. package/dist/residency/host.js +16 -14
  211. package/dist/residency/pi-entry.js +16 -14
  212. package/dist/residency/pi-entry.js.map +1 -1
  213. package/dist/runners.js +1 -1
  214. package/dist/runtime/core-override-guest-types.js +2 -2
  215. package/dist/runtime/guest-types.d.ts +1 -1
  216. package/dist/runtime/guest-types.d.ts.map +1 -1
  217. package/dist/runtime/guest-types.js +1 -1
  218. package/dist/runtime/monty-runtime.js +3 -3
  219. package/dist/runtime/native-codemode-types.d.ts +1 -1
  220. package/dist/runtime/native-codemode-types.d.ts.map +1 -1
  221. package/dist/runtime/node-process-runtime.js +3 -3
  222. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  223. package/dist/runtime/quickjs-runtime.js +2 -2
  224. package/dist/runtime/typescript-kernel.js +5 -5
  225. package/dist/storage/retention.d.ts.map +1 -1
  226. package/dist/topology/peer-presence.d.ts +56 -0
  227. package/dist/topology/peer-presence.d.ts.map +1 -0
  228. package/dist/type-error-guidance.js +1 -1
  229. package/dist/ui/controller.d.ts.map +1 -1
  230. package/dist/ui/conversation-chrome.js +2 -2
  231. package/dist/ui/conversation-host.js +1 -1
  232. package/dist/ui/conversation-native-reader.js +1 -1
  233. package/dist/ui/conversation.js +6 -6
  234. package/dist/ui/dashboard.js +3 -3
  235. package/dist/ui/settings-decision-profiles.d.ts +24 -0
  236. package/dist/ui/settings-decision-profiles.d.ts.map +1 -0
  237. package/dist/ui/settings-section-context.d.ts +1 -1
  238. package/dist/ui/settings-section-context.d.ts.map +1 -1
  239. package/dist/ui/settings-sections-agents.d.ts.map +1 -1
  240. package/dist/ui/settings-sections-decisions.d.ts +4 -0
  241. package/dist/ui/settings-sections-decisions.d.ts.map +1 -0
  242. package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
  243. package/dist/ui/settings-sections.d.ts +1 -1
  244. package/dist/ui/settings-sections.d.ts.map +1 -1
  245. package/dist/ui/settings-submenus.d.ts +3 -1
  246. package/dist/ui/settings-submenus.d.ts.map +1 -1
  247. package/dist/ui/settings-values.d.ts.map +1 -1
  248. package/dist/ui/settings.d.ts.map +1 -1
  249. package/dist/ui/settings.js +224 -45
  250. package/dist/ui/settings.js.map +4 -4
  251. package/dist/verified/generated/authority-kernel.js +2 -2
  252. package/dist/verified/generated/kernel.js +2 -2
  253. package/dist/verified/generated/lifecycle-kernel.js +2 -2
  254. package/dist/verified/generated/manifest.json +7 -7
  255. package/dist/verified/generated/provider-kernel.js +2 -2
  256. package/dist/verified/generated/storage-kernel.js +2 -2
  257. package/dist/worker/options.d.ts.map +1 -1
  258. package/dist/worker/options.js +15 -0
  259. package/dist/worker/options.js.map +2 -2
  260. package/dist/worker.js +11 -1
  261. package/dist/worker.js.map +2 -2
  262. package/docs/agents.md +49 -0
  263. package/docs/architecture.md +1 -1
  264. package/docs/audit-trace.md +3 -1
  265. package/docs/background-tasks.md +4 -0
  266. package/docs/codemode-parity.md +3 -1
  267. package/docs/compaction.md +1 -1
  268. package/docs/configuration.md +91 -8
  269. package/docs/decision-profiles.schema.json +52 -0
  270. package/docs/decision-test-coverage.md +77 -0
  271. package/docs/durable-pi.md +9 -2
  272. package/docs/extractive-history.md +17 -2
  273. package/docs/jev-decisions.md +150 -0
  274. package/docs/jev.md +18 -5
  275. package/docs/prompt-cache.md +1 -1
  276. package/docs/provider-capabilities.md +1 -1
  277. package/docs/providers.md +4 -1
  278. package/docs/verified-kernels.md +1 -1
  279. package/node_modules/pi-coralbricks-provider/LICENSE +21 -0
  280. package/node_modules/pi-coralbricks-provider/README.md +306 -0
  281. package/node_modules/pi-coralbricks-provider/auth.ts +30 -0
  282. package/node_modules/pi-coralbricks-provider/custom-models.json +1 -0
  283. package/node_modules/pi-coralbricks-provider/deprecated-models.json +1 -0
  284. package/node_modules/pi-coralbricks-provider/guard.ts +155 -0
  285. package/node_modules/pi-coralbricks-provider/index.ts +662 -0
  286. package/node_modules/pi-coralbricks-provider/models.json +88 -0
  287. package/node_modules/pi-coralbricks-provider/package.json +74 -0
  288. package/node_modules/pi-coralbricks-provider/park.ts +122 -0
  289. package/node_modules/pi-coralbricks-provider/patch.json +34 -0
  290. package/node_modules/pi-coralbricks-provider/scripts/update-models.js +658 -0
  291. package/node_modules/pi-coralbricks-provider/settings.ts +143 -0
  292. package/node_modules/pi-coralbricks-provider/sync-policy.ts +309 -0
  293. package/package.json +23 -15
  294. package/scripts/test-verified-kernels.mjs +1 -1
  295. package/scripts/verified-kernels.mjs +1 -1
  296. package/skillsets/python/fabric-exec/SKILL.md +1 -1
  297. package/skillsets/python/fabric-exec/references/agents.md +1 -1
  298. package/skillsets/python/fabric-foreman/SKILL.md +1 -1
  299. package/skillsets/python/fabric-jev/SKILL.md +2 -2
  300. package/skillsets/typescript/fabric-exec/SKILL.md +1 -1
  301. package/skillsets/typescript/fabric-exec/references/agents.md +1 -0
  302. package/skillsets/typescript/fabric-foreman/SKILL.md +1 -1
  303. package/skillsets/typescript/fabric-jev/SKILL.md +2 -2
  304. package/dist/chunks/chunk-3GJJG2FV.js.map +0 -7
  305. package/dist/chunks/chunk-B54Z662X.js.map +0 -7
  306. package/dist/chunks/chunk-C7EEG6SM.js.map +0 -7
  307. package/dist/chunks/chunk-CYMDX3XP.js.map +0 -7
  308. package/dist/chunks/chunk-CZPQTISQ.js.map +0 -7
  309. package/dist/chunks/chunk-FRPNQZV2.js.map +0 -7
  310. package/dist/chunks/chunk-IAFI4A2I.js +0 -92
  311. package/dist/chunks/chunk-IAFI4A2I.js.map +0 -7
  312. package/dist/chunks/chunk-LEDY5G2V.js +0 -515
  313. package/dist/chunks/chunk-LEDY5G2V.js.map +0 -7
  314. package/dist/chunks/chunk-PF27MQY5.js.map +0 -7
  315. package/dist/chunks/chunk-PXAICAUT.js.map +0 -7
  316. package/dist/chunks/chunk-RUO6L7RM.js.map +0 -7
  317. package/dist/chunks/chunk-ST36EYHN.js.map +0 -7
  318. package/dist/chunks/chunk-T5CU2GPZ.js.map +0 -7
  319. package/dist/chunks/chunk-UXEMIWYI.js.map +0 -7
  320. package/dist/chunks/chunk-W5CHVJBR.js.map +0 -7
  321. package/dist/chunks/chunk-WHBJDTCR.js.map +0 -7
  322. package/dist/chunks/chunk-YJX27XBO.js.map +0 -7
  323. /package/dist/chunks/{chunk-X2TRSE7D.js.map → chunk-2YG4ZA2K.js.map} +0 -0
  324. /package/dist/chunks/{chunk-N2VKKA7O.js.map → chunk-4GNFBZPR.js.map} +0 -0
  325. /package/dist/chunks/{chunk-M5IN6DMF.js.map → chunk-56RFFBBO.js.map} +0 -0
  326. /package/dist/chunks/{chunk-DU6ZA44F.js.map → chunk-6EVAHJAR.js.map} +0 -0
  327. /package/dist/chunks/{chunk-ABJCSNZO.js.map → chunk-D3IONBBJ.js.map} +0 -0
  328. /package/dist/chunks/{chunk-7JU7Z4XQ.js.map → chunk-D3W6CBJZ.js.map} +0 -0
  329. /package/dist/chunks/{chunk-3SHUUBZJ.js.map → chunk-DONS3EZH.js.map} +0 -0
  330. /package/dist/chunks/{chunk-FB24AOIJ.js.map → chunk-H3SGA7G7.js.map} +0 -0
  331. /package/dist/chunks/{chunk-ZXKYU6CH.js.map → chunk-HCNHKJDA.js.map} +0 -0
  332. /package/dist/chunks/{chunk-YYSZBD7S.js.map → chunk-HQ5YW2OJ.js.map} +0 -0
  333. /package/dist/chunks/{chunk-GC2AUXG6.js.map → chunk-HZGQ7XYM.js.map} +0 -0
  334. /package/dist/chunks/{chunk-WREA4RNR.js.map → chunk-I2TK65VR.js.map} +0 -0
  335. /package/dist/chunks/{chunk-DZ4WN5XJ.js.map → chunk-JV4JR6TT.js.map} +0 -0
  336. /package/dist/chunks/{chunk-LOLCTWJF.js.map → chunk-OTHMEDN6.js.map} +0 -0
  337. /package/dist/chunks/{chunk-M6IRQ3QT.js.map → chunk-PH4PT6R4.js.map} +0 -0
  338. /package/dist/chunks/{chunk-WYUV6WL3.js.map → chunk-QCCPR3U5.js.map} +0 -0
  339. /package/dist/chunks/{chunk-7XRUMDV7.js.map → chunk-QQ7D6UAM.js.map} +0 -0
  340. /package/dist/chunks/{chunk-PYQM7KPL.js.map → chunk-R2MMPHR2.js.map} +0 -0
  341. /package/dist/chunks/{chunk-CXTTLBUV.js.map → chunk-R2XQ6AHT.js.map} +0 -0
  342. /package/dist/chunks/{chunk-X3CHSIL2.js.map → chunk-V2IV4LYW.js.map} +0 -0
  343. /package/dist/chunks/{chunk-QY7YK7M6.js.map → chunk-VR2LV4CA.js.map} +0 -0
  344. /package/dist/chunks/{chunk-S3IRPDSO.js.map → chunk-WQ6LC2KK.js.map} +0 -0
  345. /package/dist/chunks/{chunk-BVJBYFHD.js.map → chunk-ZPI4QTOX.js.map} +0 -0
  346. /package/dist/chunks/{chunk-3DUKKQHN.js.map → chunk-ZQMBS5SH.js.map} +0 -0
package/docs/jev.md CHANGED
@@ -6,6 +6,11 @@ Programs run in persistent QuickJS contexts with exact granted capabilities. Use
6
6
 
7
7
  For guided authoring, invoke `/skill:fabric-jev <task>`. It is user-opt-in and available in both kernel skill trees. Python callers use `tools.call` dictionaries; the Jev program artifact itself remains TypeScript in QuickJS, without changing the outer Fabric kernel. See [skills](skills.md).
8
8
 
9
+ For multi-provider model switching, inline images and exact provider evidence,
10
+ use the additive [lossless decisions API](jev-decisions.md): `jev.decide`,
11
+ `jev.resolveDecision`, `jev.models` and portable profiles. These require a
12
+ compatible native binary; `jev.evaluate` below keeps its legacy contract.
13
+
9
14
  ## Shell-first workflow
10
15
 
11
16
  1. Launch an authorized command; code owns commands and arguments. Never execute model answers or untrusted output as shell source.
@@ -50,7 +55,7 @@ Shell execution retains Fabric approvals, compatible shell middleware, and capab
50
55
 
51
56
  On Pi 0.99.0 or newer, `/login jev` prompts privately for a TypeSafe API key and stores an ordinary API-key credential under `jev` in Pi's `auth.json`. `/logout` removes it. Jev registers an **auth-only provider with no chat models**; it does not appear as a selectable text-generating model.
52
57
 
53
- Jev has three upstream routes. Bare aliases (`jev-latest`, `jev-1.13`, `jev-1.13.0`, `jev-preview`) post to TypeSafe's `/v1/systemone`. OpenRouter decisions IDs (`typesafe/jev-1.13`, `~typesafe/jev-latest`) post to OpenRouter's `/api/alpha/decisions` and reuse the **existing `openrouter` credential** (the same `auth.json` entry as your chat models), so `/login openrouter` covers both. OpenRouter serves Jev on its Decisions API, not `/chat/completions`, and has no `jev-preview` alias. Vercel AI Gateway model IDs (`typesafe-ai/jev`, or the `jev-latest` alias) post to its TypeSafe-compatible `/typesafe/v1/systemone` endpoint and reuse the **existing `vercel-ai-gateway` credential** (`/login vercel-ai-gateway`, `AI_GATEWAY_API_KEY`); the request and response shapes stay TypeSafe's own, so only the base URL and key change. No second provider is registered.
58
+ Jev has four upstream routes. Bare aliases (`jev-latest`, `jev-1.13`, `jev-1.13.0`, `jev-preview`) post to TypeSafe's `/v1/systemone`. OpenRouter decisions IDs (`typesafe/jev-1.13`, `~typesafe/jev-latest`) post to OpenRouter's `/api/alpha/decisions` and reuse the **existing `openrouter` credential** (the same `auth.json` entry as your chat models), so `/login openrouter` covers both. OpenRouter serves Jev on its Decisions API, not `/chat/completions`, and has no `jev-preview` alias. Vercel AI Gateway model IDs (`typesafe-ai/jev`, or the `jev-latest` alias) post to its TypeSafe-compatible `/typesafe/v1/systemone` endpoint and reuse the **existing `vercel-ai-gateway` credential** (`/login vercel-ai-gateway`, `AI_GATEWAY_API_KEY`); the request and response shapes stay TypeSafe's own, so only the base URL and key change. No second provider is registered.
54
59
 
55
60
  TypeSafe route resolution order:
56
61
 
@@ -60,6 +65,8 @@ TypeSafe route resolution order:
60
65
 
61
66
  The Vercel AI Gateway route resolves Pi's `vercel-ai-gateway` provider authentication first (`auth.json`, then `AI_GATEWAY_API_KEY`), then `AI_GATEWAY_API_KEY`, then the same trusted `jev.credentialCommand`.
62
67
 
68
+ SubQ model IDs (`subq-snap-preview`) post to SubQ's own `/v1/systemone` at `api.subq.ai`: SubQ Snap is a System One model with TypeSafe's request and response shapes, and it reports no output tokens. The SubQ route resolves Pi's `subq` provider authentication first (`/login subq` in `auth.json`, then `SUBQ_API_KEY`), then `SUBQ_API_KEY`, then the same trusted `jev.credentialCommand`. A TypeSafe key is never sent to SubQ, nor a SubQ key to TypeSafe.
69
+
63
70
  The OpenRouter route resolves Pi's `openrouter` provider authentication first (`auth.json`, then `OPENROUTER_API_KEY`), then `OPENROUTER_API_KEY` or `TYPESAFE_OPENROUTER_API_KEY`, then the same trusted `jev.credentialCommand`.
64
71
 
65
72
  For Localterm, set this in your trusted `fabric.json` (never put the resolved secret into model-visible code):
@@ -78,7 +85,7 @@ The command uses argv, not a shell. It runs only when inference needs a key, wit
78
85
 
79
86
  ## Auto-mode tool safety
80
87
 
81
- Jev can also serve as the host's auto-approval classifier, independently of programs and observers. Choose **Approvals → Auto model** in `/fabric settings`, or set `approvals.model` to `"pi-fabric/typesafe/jev-latest"` and the relevant risk policies to `"auto"`. The picker also offers the pinned `pi-fabric/typesafe/jev-1.13`, `pi-fabric/typesafe/jev-1.13.0`, and `pi-fabric/typesafe/jev-preview` aliases (all resolve to the same build today), plus OpenRouter-served `pi-fabric/openrouter/jev-latest` and `pi-fabric/openrouter/jev-1.13`, and Vercel AI Gateway-served `pi-fabric/vercel-ai-gateway/jev-latest`. Authenticate with `/login jev` and `TYPESAFE_API_KEY` on the TypeSafe route, `/login openrouter` and `OPENROUTER_API_KEY` on the OpenRouter route, or `/login vercel-ai-gateway` and `AI_GATEWAY_API_KEY` on the Vercel AI Gateway route.
88
+ Jev can also serve as the host's auto-approval classifier, independently of programs and observers. Choose **Approvals → Auto model** in `/fabric settings`, or set `approvals.model` to `"pi-fabric/typesafe/jev-latest"` and the relevant risk policies to `"auto"`. The picker also offers the pinned `pi-fabric/typesafe/jev-1.13`, `pi-fabric/typesafe/jev-1.13.0`, and `pi-fabric/typesafe/jev-preview` aliases (all resolve to the same build today), plus OpenRouter-served `pi-fabric/openrouter/jev-latest` and `pi-fabric/openrouter/jev-1.13`, Vercel AI Gateway-served `pi-fabric/vercel-ai-gateway/jev-latest`, and SubQ-served `pi-fabric/subq/subq-snap-preview` (`/login subq` or `SUBQ_API_KEY`). Authenticate with `/login jev` and `TYPESAFE_API_KEY` on the TypeSafe route, `/login openrouter` and `OPENROUTER_API_KEY` on the OpenRouter route, or `/login vercel-ai-gateway` and `AI_GATEWAY_API_KEY` on the Vercel AI Gateway route.
82
89
 
83
90
  The host asks four typed Noul questions in one request - safety, secrets exposure, destructive effect, and whether the action targets only artifacts this session created - and never uses generated text or a chat-model adapter. Auto-allow requires the safety probability at or above `jev.autoApprovalThreshold` (default **0.50**) **and** the secrets and destructive probabilities below 0.5; lower scores, a positive secrets or destructive judgment, missing user text, and errors require explicit approval. When a Jev model is selected, **Approvals → Jev minimum probability** lets you enter any finite value from 0 to 1. Higher values are more conservative; 0 allows every judgment whose secrets and destructive verdicts are clean. This is a probabilistic advisor, not a hard security boundary or a correctness guarantee. Read [auto approval configuration](configuration.md#jev-as-the-auto-mode-classifier) for the current-turn evidence, session-action projection, outbound data disclosure, credential behavior, timeout and usage rules. Jev remains absent from ordinary chat-model pickers.
84
91
 
@@ -114,7 +121,7 @@ return { team: result.answers.route.choice, refundProbability: result.answers.re
114
121
  - Keep exact rules, arithmetic, source extraction, action execution, and permissions in code. Confidence is neither truth nor authorization.
115
122
  - State is sent to TypeSafe. Bound and minimize browser/application data; do not send secrets or unrelated private content.
116
123
 
117
- Fabric accepts up to 128 questions and 255 Choice options per question, subject to the configured request byte cap and upstream limits. Structured JSON instructions/rubrics are supported. Service failures are not automatically retried: a controller must decide whether a retry is affordable and its observation is still fresh. For HTTP 429/529, back off; do not spin.
124
+ Fabric accepts up to 128 questions and 255 Choice options per question, subject to the configured request byte cap and upstream limits. Structured JSON instructions/rubrics are supported. Service failures are not automatically retried: a controller must decide whether a retry is affordable and its observation is still fresh. A received transient HTTP status (408, 429, 500, 502, 503, 504 or 529) rejects with numeric `status` and, when the response sends `Retry-After-Ms` or `Retry-After`, `retryAfterMs` (whole milliseconds, at most one day) on the error object. For HTTP 429/529, back off; do not spin.
118
125
 
119
126
  ## Foreground and background
120
127
 
@@ -226,11 +233,17 @@ try {
226
233
  const decision = await jev.evaluate({ state, questions });
227
234
  if (decision.answers.action.confidence < 0.5) degraded = true;
228
235
  else frame = decision.answers.action.choice;
229
- } catch { degraded = true; }
236
+ } catch (error) {
237
+ degraded = true;
238
+ const { status, retryAfterMs } = error as { status?: number; retryAfterMs?: number };
239
+ if (status === 429 || status === 529) backoffUntil = Date.now() + (retryAfterMs ?? 1000);
240
+ }
230
241
  if (degraded) { frame = deterministicFallback(state); await program.emit({ fallback: true, frame }); }
231
242
  ```
232
243
 
233
- Confidence is neither truth nor authorization; a low-confidence answer is a reason to fall back, not a reason to act. Fabric validates the response before it returns it. An invalid choice, probability set, or confidence rejects the evaluation without surfacing a partial answer, so `catch` is part of the loop.
244
+ Skip `jev.evaluate` until `backoffUntil` passes, and keep applying the deterministic fallback meanwhile.
245
+
246
+ Confidence is neither truth nor authorization; a low-confidence answer is a reason to fall back, not a reason to act. Fabric validates the response before it returns it. An invalid choice, probability set, or confidence rejects the evaluation without surfacing a partial answer, so `catch` is part of the loop. The response's well-formed reported usage still counts against the run's evaluation and token budgets, and later evaluations proceed within them. A transient HTTP error counts as one evaluation and bills the usage its body reports, or else a fixed cost of the request body's UTF-8 byte length as input tokens and 0 output tokens; later evaluations proceed within the budgets, so a guest that retries forever stops at `maxEvaluations` or `maxTokens`. This applies to the in-process transport; a failed request dispatched through jev-fabric has unknown usage. A failure whose usage is unknown (a network error, a timeout or cancellation, any other HTTP status, or a response without valid usage) closes inference for the rest of the run, because it may have been billed.
234
247
 
235
248
  ### Budget arithmetic for sustained loops
236
249
 
@@ -69,7 +69,7 @@ Import `FabricCacheHoldResult` as a type from `pi-fabric/protocol`. Inspect its
69
69
 
70
70
  ## Boundaries and future work
71
71
 
72
- Stable prompt construction already lives in [model-guidance components](components.md#prompt-cache-and-cold-prefill-behavior). Built-in provider guidance depends only on configuration and resolves from the first agent start, so it stays out of activation-timing churn. Do not inject clocks, task state, or cache diagnostics into the stable prefix.
72
+ Stable prompt construction already lives in [model-guidance components](components.md#prompt-cache-and-cold-prefill-behavior). Built-in provider guidance depends only on configuration and resolves from the first agent start, so it stays out of activation-timing churn. Do not inject clocks, task state, or cache diagnostics into the stable prefix. [Peer presence notices](agents.md#peer-presence-notices) follow the same rule: they are appended to the transcript at a turn boundary and never enter the system prompt.
73
73
 
74
74
  Persistent actor transcripts differ from persistent Pi worker processes: current actor activations reuse the session file and close the Pi child after settlement. Idle actor warming needs a separately designed live-runtime retention capability; this change does not keep children alive, alter durable residency, or route cache control across participants.
75
75
 
@@ -208,7 +208,7 @@ bun run benchmark:provider-dispatch
208
208
  bun run benchmark:startup . ../pi-fovea ../pi-contour
209
209
  ```
210
210
 
211
- The contributor toolchain pins Bend 2.0.35. `BEND_BIN` can select a trusted
211
+ The contributor toolchain pins Bend 2.0.36. `BEND_BIN` can select a trusted
212
212
  compiler executable. Normal builds verify artifact hashes without Bend.
213
213
 
214
214
  The dispatch benchmark measures first use and warm full-registry read calls
package/docs/providers.md CHANGED
@@ -278,7 +278,8 @@ Results from MCP, agent, memory, state, schema, mesh, components, compact, and e
278
278
  A proxied event carries:
279
279
 
280
280
  - `toolName` holding the fully qualified Fabric ref, such as `mcp.github.search`;
281
- - a `toolCallId` that starts with `FABRIC_NESTED_TOOL_CALL_ID_PREFIX`;
281
+ - a `toolCallId` that starts with `FABRIC_NESTED_TOOL_CALL_ID_PREFIX`, persisted as `nestedToolCallId` on the call's audit in the final `fabric_exec` details;
282
+ - `parentToolCallId`, the id of the call that issued it, normally the outer `fabric_exec` tool call;
282
283
  - text `content` holding the raw string result or a JSON projection;
283
284
  - `details` matching `FabricToolResultProxyDetailsV1`, whose `result` is the exact host-side structured value.
284
285
 
@@ -319,3 +320,5 @@ export default function resultGuard(pi: ExtensionAPI) {
319
320
  If you change only `content`, the nested sandbox value becomes the patched text. To keep a structured replacement, return the proxy envelope in `details` with a changed `result`, as in the example above. When both fields are patched, a valid changed `details.result` takes precedence. Returning `isError: true` fails the nested provider invocation.
320
321
 
321
322
  Pi core tools and captured extension tools skip this generic proxy, because they already replay their native `tool_call`, `tool_result`, and `tool_execution_*` lifecycle. Nested shell calls still emit their native identity: `pi.bash()` uses `toolName: "bash"`/`isBashToolResult()`, while `pi.powershell()` uses `toolName: "powershell"`/`isPowerShellToolResult()`. Proxied events act as middleware only. They create no separate persisted tool-result messages.
323
+
324
+ Those replayed `tool_call`, `tool_result`, and `tool_execution_*` events carry the same `parentToolCallId`, as Pi's own nested calls do. A listener can then attribute a nested call to its `fabric_exec` when several run in parallel. A call Fabric issues outside a `fabric_exec`, such as one from a Jev program or a component, carries Fabric's own id for that caller.
@@ -204,7 +204,7 @@ author-defined observational equivalence are not claimed as Bend theorems.
204
204
 
205
205
  ## Reproducible bridge
206
206
 
207
- The contributor toolchain pins **Bend 2.0.35**. Installed Fabric needs neither
207
+ The contributor toolchain pins **Bend 2.0.36**. Installed Fabric needs neither
208
208
  Bend nor a Bend loader. Linux CI downloads that exact release archive and checks
209
209
  its SHA-256 before running proofs. Windows tests execute the checked-in generated
210
210
  JS and ABI; native Bend currently requires Linux, macOS, or WSL.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,306 @@
1
+ <div align="center">
2
+
3
+ # 🪸 pi-coralbricks-provider
4
+
5
+ **GLM 5.3 & DeepSeek V4.1 Flash through [Coral Bricks](https://www.coralbricks.ai)**
6
+
7
+ _A [pi](https://github.com/earendil-works/pi-coding-agent) provider extension for Coral's OpenAI-compatible inference gateway — up to **1M context** on open models._
8
+
9
+ [![pi extension](https://img.shields.io/badge/pi-extension-blueviolet)](https://github.com/earendil-works/pi-coding-agent)
10
+ [![npm](https://img.shields.io/npm/v/pi-coralbricks-provider)](https://www.npmjs.com/package/pi-coralbricks-provider)
11
+ [![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
12
+ [![synbad](https://img.shields.io/badge/synbad-evals_passing-brightgreen)](https://github.com/synthetic-lab/synbad)
13
+
14
+ </div>
15
+
16
+ ## Pi 1.0 compatibility
17
+
18
+ Tested with Pi **1.0.0**. Host-provided packages remain wildcard peers; development uses exact SDK pins.
19
+ Run `bun run test:pi` for offline manifest, catalog, lifecycle and streaming checks. To test an installed host, set `PI1_HOST_PACKAGE` to its package directory; add `PI1_HOST_ENTRY=bundle` for its bundled CLI runtime. The probe stubs all network requests and never uses a live provider endpoint.
20
+
21
+ ---
22
+
23
+ ## Features
24
+
25
+ - **2 reasoning models** from Coral's live catalog — GLM 5.3 and DeepSeek V4.1 Flash (the `-fp4` twin slugs Coral still serves are hidden as duplicates)
26
+ - **1M token context** on GLM and DeepSeek, with vision (image input) on DeepSeek V4.1 Flash
27
+ - **OpenAI-compatible API** — standard `/v1/chat/completions`, streaming, and tool calling
28
+ - **Per-family thinking levels** — zai-style `thinking` control for GLM (including a *real* off switch), `reasoning_effort` for DeepSeek V4.1 Flash
29
+ - **Accurate cost tracking** — input, cache-write and output rates mirror Coral's [published pricing](https://www.coralbricks.ai/pricing), and cached reads are **$0 on every model**
30
+ - **Self-healing model sync** — stale-while-revalidate from the authenticated `/v1/models`, hot-swapped at session start and after `/login`. Without a key it makes no network request and serves the cached or embedded catalog
31
+ - **Quiet startup sync** — startup never waits on the network, and the catalog is refreshed at most hourly, by one pi process at a time, so `/new`, `pi -p` and fan-out child agents share one cache (see [Model Sync](#model-sync))
32
+ - **Safe to install twice** — when a standalone install and a copy bundled in another Pi package (such as [pi-fabric](https://github.com/fabric-runtime/pi-fabric)) load together, only the newest copy registers the provider (see [Installed more than once](#installed-more-than-once))
33
+ - **synbad-validated** — [synbad](https://github.com/synthetic-lab/synbad) tool-calling and reasoning-parsing evals pass 13/13 in every run on GLM 5.3 in both unary and streaming modes
34
+
35
+ ## Installation
36
+
37
+ ### Option 1: Using `pi install` (Recommended)
38
+
39
+ Install directly from GitHub:
40
+
41
+ ```bash
42
+ pi install https://github.com/monotykamary/pi-coralbricks-provider
43
+ ```
44
+
45
+ or from npm:
46
+
47
+ ```bash
48
+ pi install npm:pi-coralbricks-provider
49
+ ```
50
+
51
+ Then set your API key and run pi:
52
+
53
+ ```bash
54
+ # Recommended: run /login coralbricks inside pi (saves it to auth.json)
55
+ # See Authentication section below
56
+
57
+ # Or set as environment variable
58
+ export CORALBRICKS_API_KEY=cb_your-key-here
59
+
60
+ pi
61
+ ```
62
+
63
+ ### Option 2: Manual Clone
64
+
65
+ 1. Clone this repository:
66
+ ```bash
67
+ git clone https://github.com/monotykamary/pi-coralbricks-provider.git
68
+ cd pi-coralbricks-provider
69
+ bun install
70
+ ```
71
+
72
+ 2. Set your Coral API key:
73
+ ```bash
74
+ # Recommended: run /login coralbricks inside pi (saves it to auth.json)
75
+ # See Authentication section below
76
+
77
+ # Or set as environment variable
78
+ export CORALBRICKS_API_KEY=cb_your-key-here
79
+ ```
80
+
81
+ 3. Run pi with the extension:
82
+ ```bash
83
+ pi -e /path/to/pi-coralbricks-provider
84
+ ```
85
+
86
+ ### Installed more than once
87
+
88
+ Another Pi package can bundle this extension; [pi-fabric](https://github.com/fabric-runtime/pi-fabric) does. You can still install it yourself, for example to get a newer version first. When two or more copies load into one Pi session, the newest version registers `coralbricks`, syncs models and serves `/coralbricks-settings`. The other copies register nothing and make no requests, so `/model` lists each model once and `/v1/models` is fetched once. Copies of the same version keep the one that loaded first.
89
+
90
+ The copies find each other through a process-global registry (`Symbol.for("pi-coralbricks-provider.registry.v1")`), scoped to the Pi extension runtime through the event bus Pi shares among that runtime's extensions. The newest copy wins whichever order Pi loads them in. If it loads second, it takes over before the session starts, and Pi serves its registration because a provider registered later under the same id replaces the earlier one. Ownership never moves back, and it ends with the session, so `/reload`, `/new`, `/resume` and `/fork` start from a clean slate. Versions before 1.0.32 do not take part and always register.
91
+
92
+ ## Available Models
93
+
94
+ | Model | Context | Vision | Reasoning | Input $/M | Cache Read $/M | Cache Write $/M | Output $/M |
95
+ |-------|---------|--------|-----------|-----------|-----------------|------------------|------------|
96
+ | DeepSeek V4.1 Flash | 1.0M | ✅ | ✅ | $0.01 | — | $0.09 | $1.20 |
97
+ | GLM 5.3 | 1.0M | ❌ | ✅ | $1.12 | — | $1.68 | $4.40 |
98
+
99
+ *Costs are per million tokens. Cache Read shows — because Coral bills cached input at **$0** on every model. Prompt tokens Coral has not cached yet are billed once at the Cache Write rate, in place of the Input rate. Prices subject to change — check [Coral's live catalog](https://www.coralbricks.ai/api/public/models).*
100
+
101
+ ## Usage
102
+
103
+ After loading the extension, use the `/model` command in pi to select your preferred model:
104
+
105
+ ```
106
+ /model coralbricks glm-5.3-fp4
107
+ ```
108
+
109
+ Or start pi directly with a Coral model:
110
+
111
+ ```bash
112
+ pi -e /path/to/pi-coralbricks-provider --model coralbricks/deepseek-v4.1-flash-fast-fp4:high
113
+ ```
114
+
115
+ Thinking levels attach to the model id with `:<level>` — e.g. `:low`, `:high`, `:max`, or `:off` (GLM and DeepSeek).
116
+
117
+ ## Provider Settings
118
+
119
+ Run `/coralbricks-settings` to choose the **API surface** and, for Responses,
120
+ whether to **park turns**. The searchable,
121
+ bordered settings list matches pi's settings UI; GUI/RPC clients get a selection
122
+ dialog. Changes are saved immediately and apply to the next request without a
123
+ restart, including when a CoralBricks model is already selected.
124
+
125
+ Settings live at `~/.pi/agent/extensions/coralbricks.json` (or under
126
+ `PI_CODING_AGENT_DIR` when set):
127
+
128
+ ```json
129
+ { "api": "responses", "park": false }
130
+ ```
131
+
132
+ - **`chat-completions`** (default): uses `/v1/chat/completions`; existing behavior
133
+ is unchanged. Select this to opt back out.
134
+ - **`responses`** (opt-in): uses `/v1/responses` with pi's native text, reasoning,
135
+ tool-call, image, usage, and cancellation handling. The same model IDs and API
136
+ key work on both surfaces. Thinking levels map to `reasoning.effort` here.
137
+
138
+ By default, Responses requests replay the full local conversation and send
139
+ `store: false`. This integration does not use background jobs or resumable
140
+ streams. Coral's broader Responses API is documented at
141
+ [coralbricks.ai/docs](https://www.coralbricks.ai/docs).
142
+
143
+ ### Parking (`"park": true`)
144
+
145
+ With parking on, every Responses request is sent with `store: true` and the
146
+ next request continues it with `previous_response_id`. pi still builds the full
147
+ transcript, but only the items after the parked response (tool results, the
148
+ next user message) go over the wire. Tools are re-sent every time because Coral
149
+ does not carry them across a chain.
150
+
151
+ A turn is chained only when the full input starts with exactly what was sent
152
+ for the parked response, followed by that response's own output. Compaction, a
153
+ model switch, an edited or branched history, or a pi restart falls back to a
154
+ full replay, and that request is parked again. If Coral no longer has the parent
155
+ (`previous_response_not_found`), the same request is re-sent once in full.
156
+ Parked ids live in memory only.
157
+
158
+ Things to know before turning it on:
159
+
160
+ - Coral keeps every parked response on its side. Deleting a parent breaks the
161
+ chain, so the extension does not delete them.
162
+ - Coral bills a chained request as the tool definitions plus the new items. The
163
+ first chained request in a session writes the tool block to cache once, and
164
+ later ones read it back. With a warm cache, a 7-request tool loop cost about
165
+ the same as a full replay on DeepSeek V4.1 Flash and about a third more on
166
+ GLM 5.3 Flash. The parked history itself is not billed again, which matters
167
+ when Coral evicts a long session's cache.
168
+
169
+ Live probes verified text, automatic tool calls, tool-result replay, and switching
170
+ back to Chat Completions on all current models. The gateway currently rejects
171
+ Responses requests that force a named tool (`tool_choice: {"type":"function",
172
+ "name":"..."}`); leave tool selection automatic (pi's default). Errors are surfaced
173
+ without silently falling back to a different API.
174
+
175
+ Missing, invalid, or unreadable settings default to Chat Completions. Unknown
176
+ JSON fields are preserved when toggling; malformed files must be fixed before
177
+ saving. If editing the file manually, run `/reload` to apply it.
178
+
179
+ ## Authentication
180
+
181
+ The Coral API key can be configured in multiple ways (resolved in this order):
182
+
183
+ 1. **Runtime override** — Use the `--api-key` CLI flag
184
+ 2. **`auth.json`** (recommended) — Run `/login coralbricks` inside pi and paste your key; pi saves it to `~/.pi/agent/auth.json` and refreshes the model list from the authenticated `/v1/models`. Or add it by hand:
185
+ ```json
186
+ { "coralbricks": { "type": "api_key", "key": "cb_your-key" } }
187
+ ```
188
+ The `key` field supports literal values, env var names, and shell commands (prefix with `!`). `/logout` (pick CoralBricks) removes the stored key; `CORALBRICKS_API_KEY` is left alone.
189
+ 3. **Environment variable** — Set `CORALBRICKS_API_KEY`
190
+
191
+ With [localterm](https://www.npmjs.com/package/localterm), store it once and it's exposed everywhere:
192
+
193
+ ```bash
194
+ localterm secret set coralbricks_api_key
195
+ ```
196
+
197
+ ### Environment Variables
198
+
199
+ | Variable | Required | Description |
200
+ |----------|----------|-------------|
201
+ | `CORALBRICKS_API_KEY` | No | Your Coral API key (fallback if not in `auth.json` or `--api-key`) |
202
+ | `PI_PROVIDER_SYNC_TTL_MS` | No | Model sync freshness window in ms (default `3600000`; `0` = revalidate every session start) |
203
+
204
+ > Coral Inference is currently in a design-partner program — mint keys at [coralbricks.ai/api-keys](https://www.coralbricks.ai/api-keys). Newly-minted keys may take ~30 seconds to be honored, and `403 access_denied` means the account isn't on the allowlist yet.
205
+
206
+ ## Thinking Levels
207
+
208
+ Verified against the live gateway:
209
+
210
+ | Model | Format | off | low | medium | high | max |
211
+ |-------|--------|-----|-----|--------|------|-----|
212
+ | GLM 5.3 FP4 | `thinking: {type}` + `reasoning_effort` | ✅ | ✅ | — | ✅ | ✅ |
213
+ | GLM 5.3 Flash (retired) | `thinking: {type}` + `reasoning_effort` | ✅ | ✅ | — | ✅ | ✅ |
214
+ | DeepSeek V4.1 Flash | `reasoning_effort` | ✅ | ✅ | — | ✅ | ✅ |
215
+
216
+ - **GLM** accepts zai-style `thinking: {type: "disabled"}` on Coral — pi's *off* level turns thinking off, though a short preamble of a few dozen tokens can still appear (the upstream Z.ai API has no off at all, so this differs from the canonical Z.ai map).
217
+ - **DeepSeek V4.1 Flash** reasons only when asked: a request without `reasoning_effort`, or with `"none"`, gets no reasoning, which is what pi's *off* sends. `thinking: {type}` has no effect on this model.
218
+ - Coral streams a duplicate `reasoning` field alongside `reasoning_content`; pi dedupes these automatically.
219
+
220
+ ## Compat Settings
221
+
222
+ Coral's gateway follows the OpenAI Chat Completions API:
223
+
224
+ - **`supportsStore: false`** / **`supportsDeveloperRole: false`** — all models; Coral serves open models on the classic roles.
225
+ - **`maxTokensField: "max_tokens"`** — all models.
226
+ - **`thinkingFormat: "zai"`** — GLM 5.3: `thinking: {type: "enabled"|"disabled"}` toggles reasoning, `reasoning_effort` picks the depth.
227
+ - **`thinkingFormat: "openai"`** — DeepSeek V4.1 Flash: `reasoning_effort` drives thinking depth.
228
+
229
+ ### Patch Overrides & Custom Models
230
+
231
+ - **`patch.json`** — per-model overrides applied on top of `models.json` (reasoning flags, pricing corrections, compat settings, thinking level maps, `"hidden"`). One entry per model Coral serves: GLM 5.3 and DeepSeek V4.1 Flash carry the reasoning and compat settings, and their `-fp4` twins set `"hidden": true` so `/model` and the table above list each model once.
232
+ - **`custom-models.json`** — full model definitions for models Coral doesn't list. Merged after patch.
233
+
234
+ Merge order: `[live|cache|embedded] → patch.json → custom-models.json`
235
+
236
+ ## Inference-Quality Testing
237
+
238
+ Validated with [synbad](https://github.com/synthetic-lab/synbad) — Synthetic's tool-calling and reasoning-parsing eval suite for LLM inference providers (current 13-eval suite, `--reasoning-effort high`, five `--count 1` runs per mode on 2026-09-15, DeepSeek on 2026-09-22; a cell shows the evals that passed in every run):
239
+
240
+ | Model | Unary | Stream | Notes |
241
+ |-------|-------|--------|-------|
242
+ | GLM 5.3 FP4 | 13/13 ✅ | 13/13 ✅ | 5/5 runs |
243
+ | GLM 5.3 Flash (retired) | 12/13 ⚠️ | 12/13 ⚠️ | `reasoning/reasoning-parsing` passes 4 of 5 runs; see below |
244
+ | GPT-OSS 120B (retired) | 12/13 ⚠️ | 12/13 ⚠️ | `tools/parallel-tool` 0 of 5 runs, before Coral retired the model |
245
+ | DeepSeek V4.1 Flash | 12/13 ⚠️ | 12/13 ⚠️ | `tools/octo-list-no-optional-args` passes 1 of 5 runs; see below |
246
+ | Kimi K3 (retired) | 13/13 ✅ | 13/13 ✅ | 5/5 runs, before Coral retired the model |
247
+ | GLM 5.2 FP4 (retired) | 15/15 ✅ | 15/15 ✅ | 15-eval suite, single run, before Coral retired the model |
248
+
249
+ The misses are model-side, not transport: gpt-oss answered "Paris and London" with one call after another instead of two parallel calls even when `parallel_tool_calls: true`, in every run; on the trivial prompt `reasoning-parsing` uses, GLM 5.3 Flash answers without a think block about one run in five, in both modes, with the answer itself unaffected; and asked to "call the list tool with no args", DeepSeek V4.1 Flash usually fills in the optional `dirPath` as `"."`.
250
+
251
+ Reproduce:
252
+
253
+ ```bash
254
+ CORALBRICKS_API_KEY=cb_... node ../synbad/dist/source/index.js eval \
255
+ --env-var CORALBRICKS_API_KEY \
256
+ --base-url https://inference.coralbricks.ai/v1 \
257
+ --model glm-5.3-fp4 --count 1 --reasoning-effort high
258
+ ```
259
+
260
+ ## Model Sync
261
+
262
+ At startup the extension serves the last catalog it cached (`~/.pi/agent/cache/coralbricks-models.json`), or the catalog embedded in the package. Once Pi resolves a key (`/login coralbricks`, `auth.json`, `--api-key` or `CORALBRICKS_API_KEY`), it refreshes from the authenticated `/v1/models` at session start and after `/login`, caches the result and swaps it in. With no key it makes no network request at all.
263
+
264
+ Startup never waits on the network: the session-start refresh runs in the background, and only when:
265
+
266
+ - a Coral API key is configured (no key, no request),
267
+ - the cache is older than 1 hour, missing or unreadable, was fetched with a different API key, or was written by a version before this sync policy, and
268
+ - no other pi process is already refreshing it (a `coralbricks-models.lock` file next to the cache).
269
+
270
+ So `/new`, `/reload`, `pi -p` and fan-out child agents share one cache instead of each calling the API; a session that skips the fetch still picks up a cache another process refreshed, and every cache write is atomic. `/login coralbricks` and a changed key always refresh, whatever the cache's age. A failed refresh is retried after 5 minutes at the earliest. `PI_PROVIDER_SYNC_TTL_MS` changes the window (`0` revalidates on every session start). Only a hash fingerprint of the key is stored (`coralbricks-models.sync.json`), never the key itself. When several copies of the extension load (see [Installed more than once](#installed-more-than-once)), only the owning copy touches the lock or the network.
271
+
272
+ ## Updating Models
273
+
274
+ Run the update script to fetch the latest models from Coral's API:
275
+
276
+ ```bash
277
+ export CORALBRICKS_API_KEY=cb_your-key
278
+ node scripts/update-models.js
279
+ ```
280
+
281
+ This will:
282
+ 1. Fetch models from `https://inference.coralbricks.ai/v1/models` (falls back to the unauthenticated [public catalog](https://www.coralbricks.ai/api/public/models) without a key)
283
+ 2. Preserve existing model data (pricing, compat, thinking maps) for known models
284
+ 3. Apply overrides from `patch.json`
285
+ 4. Update `models.json` and the README model table
286
+
287
+ To regenerate just the README model table from local data — no API key needed:
288
+
289
+ ```bash
290
+ node scripts/update-models.js --readme-only
291
+ ```
292
+
293
+ ## Troubleshooting
294
+
295
+ | Symptom | Meaning |
296
+ |---------|---------|
297
+ | `403 access_denied` | Account not on the Coral Inference allowlist yet |
298
+ | `404 model_not_accepted` | Model id not enabled for your key |
299
+ | `401 invalid_api_key` | Re-mint at [coralbricks.ai/api-keys](https://www.coralbricks.ai/api-keys); fresh keys take ~30s to activate |
300
+ | `429 rate_limit_exceeded` | Per-key rate limit — retry with backoff |
301
+ | `502 upstream_error` / `503 backend_unconfigured` | Transient — retry |
302
+ | `504 timeout` | Sync request waited too long; re-issue smaller or use Coral's background Responses API |
303
+
304
+ ## License
305
+
306
+ MIT
@@ -0,0 +1,30 @@
1
+ import { envApiKeyAuth, type ApiKeyAuth } from "@earendil-works/pi-ai";
2
+
3
+ export const CORALBRICKS_ENV_VAR = "CORALBRICKS_API_KEY";
4
+ export const CORALBRICKS_KEYS_URL = "https://www.coralbricks.ai/api-keys";
5
+
6
+ /**
7
+ * API-key auth for `/login coralbricks`, the pattern Pi's built-in OpenRouter and
8
+ * Vercel AI Gateway providers use (pi-ai `envApiKeyAuth`): a stored auth.json
9
+ * `coralbricks` api_key wins, then CORALBRICKS_API_KEY. Login stores
10
+ * `{ "type": "api_key", "key": ... }` under `coralbricks`, the entry this
11
+ * extension has always read, and `/logout` removes it.
12
+ */
13
+ export function coralApiKeyAuth(): ApiKeyAuth {
14
+ const base = envApiKeyAuth("CoralBricks API key", [CORALBRICKS_ENV_VAR]);
15
+ return {
16
+ ...base,
17
+ login: async (interaction) => {
18
+ interaction.signal.throwIfAborted();
19
+ interaction.notify({
20
+ type: "info",
21
+ message: "Create a Coral Inference API key at https://www.coralbricks.ai (API keys page). New keys can take ~30 seconds to be honored.",
22
+ links: [{ url: CORALBRICKS_KEYS_URL, label: "coralbricks.ai/api-keys" }],
23
+ });
24
+ const key = (await interaction.prompt({ type: "secret", message: "Enter CoralBricks API key", placeholder: "cb_..." })).trim();
25
+ interaction.signal.throwIfAborted();
26
+ if (!key) throw new Error("No CoralBricks API key entered");
27
+ return { type: "api_key", key };
28
+ },
29
+ };
30
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * One provider per Pi runtime, however many copies of this package load.
3
+ *
4
+ * A standalone install (`pi install npm:pi-coralbricks-provider`) and a copy
5
+ * bundled inside another Pi package (pi-fabric) load from separate module
6
+ * roots, so module state is not shared between them. Without coordination both
7
+ * would register `coralbricks`, both would sync models at session start, and
8
+ * both would add `/coralbricks-settings`.
9
+ *
10
+ * Copies coordinate through a process-global registry under
11
+ * `Symbol.for("pi-coralbricks-provider.registry.v1")`. It is scoped per Pi
12
+ * extension runtime: copies discover a shared scope token over the extension
13
+ * event bus Pi gives every extension of one runtime (`pi.events`). Pi drops a
14
+ * runtime's bus subscriptions when it invalidates that runtime (`/reload`,
15
+ * `/new`, `/resume`, `/fork`), so the next generation starts from an empty
16
+ * scope and never inherits a stale owner. Separate runtimes in one process
17
+ * (another SDK session, an isolated loader) get separate scopes.
18
+ *
19
+ * Within a scope the highest version owns the provider; equal versions keep the
20
+ * copy that loaded first. Ownership is decided while extensions load, before
21
+ * Pi binds a session:
22
+ *
23
+ * - The first copy owns the scope and registers the provider.
24
+ * - A later copy that is not newer yields: it registers nothing and never
25
+ * syncs models.
26
+ * - A later, newer copy takes over: the incumbent resigns (its hooks go inert)
27
+ * and the newer copy registers the provider. Pi applies registrations in
28
+ * load order and a native provider with an existing id replaces the previous
29
+ * one, so the newer registration is the one Pi serves.
30
+ *
31
+ * Ownership only ever moves to a strictly newer version, and only at load
32
+ * time, so it cannot flap, and only the owner fetches `/v1/models`. The first
33
+ * copy registers `/coralbricks-settings` once and serves it through whichever
34
+ * copy owns the scope. Ownership ends with the session (`session_shutdown`).
35
+ * Copies older than this protocol do not take part and keep registering.
36
+ */
37
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
38
+
39
+ const REGISTRY_KEY = Symbol.for("pi-coralbricks-provider.registry.v1");
40
+ const SCOPE_CHANNEL = "pi-coralbricks-provider:scope.v1";
41
+
42
+ /** What one loaded copy offers the registry. Stable across versions (protocol v1). */
43
+ export interface CoralCopy {
44
+ readonly version: string;
45
+ /** A newer copy took over this runtime: stop syncing and serving. */
46
+ resign(): void;
47
+ /** `/coralbricks-settings`, as this copy implements it. */
48
+ settings(args: string, ctx: unknown): Promise<void>;
49
+ }
50
+
51
+ interface Scope {
52
+ owner?: CoralCopy;
53
+ }
54
+
55
+ type Registry = WeakMap<object, Scope>;
56
+
57
+ export interface RuntimeClaim {
58
+ /** True while this copy owns the provider in its runtime. */
59
+ owns(): boolean;
60
+ /** True for the first copy in the runtime, which registers the shared command. */
61
+ readonly first: boolean;
62
+ /** The copy that owns the runtime now, if any. */
63
+ owner(): CoralCopy | undefined;
64
+ /** End this copy's ownership (session shutdown). */
65
+ release(): void;
66
+ }
67
+
68
+ function registry(): Registry {
69
+ const global = globalThis as typeof globalThis & { [REGISTRY_KEY]?: Registry };
70
+ global[REGISTRY_KEY] ??= new WeakMap();
71
+ return global[REGISTRY_KEY];
72
+ }
73
+
74
+ function parseVersion(version: string): { core: number[]; pre: string | undefined } | undefined {
75
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(version.trim());
76
+ if (!match) return undefined;
77
+ return { core: [Number(match[1]), Number(match[2]), Number(match[3])], pre: match[4] };
78
+ }
79
+
80
+ function comparePrerelease(a: string, b: string): number {
81
+ const left = a.split(".");
82
+ const right = b.split(".");
83
+ for (let i = 0; i < Math.max(left.length, right.length); i++) {
84
+ if (left[i] === undefined) return -1;
85
+ if (right[i] === undefined) return 1;
86
+ const numericLeft = /^\d+$/.test(left[i]);
87
+ const numericRight = /^\d+$/.test(right[i]);
88
+ if (numericLeft && numericRight) {
89
+ const diff = Number(left[i]) - Number(right[i]);
90
+ if (diff !== 0) return Math.sign(diff);
91
+ } else if (numericLeft !== numericRight) {
92
+ return numericLeft ? -1 : 1;
93
+ } else if (left[i] !== right[i]) {
94
+ return left[i] < right[i] ? -1 : 1;
95
+ }
96
+ }
97
+ return 0;
98
+ }
99
+
100
+ /** Semver precedence; a malformed version sorts below every valid one. */
101
+ export function compareVersions(a: string, b: string): number {
102
+ const left = parseVersion(a);
103
+ const right = parseVersion(b);
104
+ if (!left || !right) return left ? 1 : right ? -1 : 0;
105
+ for (let i = 0; i < 3; i++) {
106
+ const diff = left.core[i] - right.core[i];
107
+ if (diff !== 0) return Math.sign(diff);
108
+ }
109
+ if (left.pre === undefined || right.pre === undefined) {
110
+ return left.pre === right.pre ? 0 : left.pre === undefined ? 1 : -1;
111
+ }
112
+ return comparePrerelease(left.pre, right.pre);
113
+ }
114
+
115
+ /** The scope token every copy in this extension runtime shares. */
116
+ function joinScope(pi: ExtensionAPI): { token: object; first: boolean } {
117
+ // A host without an extension event bus gives every copy its own scope.
118
+ if (typeof pi.events?.emit !== "function" || typeof pi.events.on !== "function") return { token: {}, first: true };
119
+ let token: object | undefined;
120
+ // Copies already loaded in this runtime answer synchronously on the bus.
121
+ pi.events.emit(SCOPE_CHANNEL, (found: unknown) => {
122
+ if (!token && typeof found === "object" && found !== null) token = found;
123
+ });
124
+ const first = token === undefined;
125
+ const scope = token ?? {};
126
+ pi.events.on(SCOPE_CHANNEL, (reply: unknown) => {
127
+ if (typeof reply === "function") reply(scope);
128
+ });
129
+ return { token: scope, first };
130
+ }
131
+
132
+ /** Decide, while this copy loads, whether it owns the `coralbricks` provider in its runtime. */
133
+ export function claimRuntime(pi: ExtensionAPI, copy: CoralCopy): RuntimeClaim {
134
+ const { token, first } = joinScope(pi);
135
+ const scopes = registry();
136
+ let scope = scopes.get(token);
137
+ if (!scope) {
138
+ scope = {};
139
+ scopes.set(token, scope);
140
+ }
141
+ const incumbent = scope.owner;
142
+ if (!incumbent || compareVersions(copy.version, incumbent.version) > 0) {
143
+ scope.owner = copy;
144
+ incumbent?.resign();
145
+ }
146
+ const current = scope;
147
+ return {
148
+ first,
149
+ owns: () => current.owner === copy,
150
+ owner: () => current.owner,
151
+ release: () => {
152
+ if (current.owner === copy) current.owner = undefined;
153
+ },
154
+ };
155
+ }