@fased/fased 0.1.58 → 0.1.60

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 (778) hide show
  1. package/LICENSE +0 -0
  2. package/assets/avatar-placeholder.svg +0 -0
  3. package/assets/chrome-extension/README.md +0 -0
  4. package/assets/chrome-extension/background-utils.js +0 -0
  5. package/assets/chrome-extension/background.js +0 -0
  6. package/assets/chrome-extension/icons/icon128.png +0 -0
  7. package/assets/chrome-extension/icons/icon16.png +0 -0
  8. package/assets/chrome-extension/icons/icon32.png +0 -0
  9. package/assets/chrome-extension/icons/icon48.png +0 -0
  10. package/assets/chrome-extension/manifest.json +0 -0
  11. package/assets/chrome-extension/options-validation.js +0 -0
  12. package/assets/chrome-extension/options.html +0 -0
  13. package/assets/chrome-extension/options.js +0 -0
  14. package/config/official-external-plugin-catalog.json +0 -0
  15. package/config/sat-runtime.env +0 -0
  16. package/dist/agents/anthropic-payload-policy.js +188 -0
  17. package/dist/agents/anthropic-transport-stream.js +736 -0
  18. package/dist/agents/copilot-dynamic-headers.js +1 -1
  19. package/dist/agents/custom-api-registry.js +21 -0
  20. package/dist/agents/google-transport-stream.js +543 -0
  21. package/dist/agents/models-config.js +2 -1
  22. package/dist/agents/openai-completions-compat.js +49 -0
  23. package/dist/agents/openai-responses-payload-policy.js +100 -0
  24. package/dist/agents/openai-tool-schema.js +130 -0
  25. package/dist/agents/openai-transport-stream.js +1040 -0
  26. package/dist/agents/pi-embedded-runner/compact.js +9 -0
  27. package/dist/agents/pi-embedded-runner/run/attempt.js +9 -0
  28. package/dist/agents/provider-request-config.js +1 -1
  29. package/dist/agents/provider-stream.js +29 -0
  30. package/dist/agents/provider-transport-fetch.js +89 -0
  31. package/dist/agents/provider-transport-stream.js +72 -0
  32. package/dist/agents/system-prompt-cache-boundary.js +1 -1
  33. package/dist/agents/system-prompt.js +1 -1
  34. package/dist/agents/transport-message-transform.js +143 -0
  35. package/dist/agents/transport-stream-shared.js +81 -0
  36. package/dist/brand.js +1 -1
  37. package/dist/build-info.json +3 -3
  38. package/dist/bundled/boot-md/HOOK.md +0 -0
  39. package/dist/bundled/bootstrap-extra-files/HOOK.md +0 -0
  40. package/dist/bundled/command-logger/HOOK.md +0 -0
  41. package/dist/bundled/session-memory/HOOK.md +0 -0
  42. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  43. package/dist/canvas-host/a2ui/index.html +0 -0
  44. package/dist/channels/delivery.js +78 -0
  45. package/dist/channels/plugins/catalog.js +10 -5
  46. package/dist/cli/components-cli.js +16 -13
  47. package/dist/cli/daemon-cli/install.js +10 -0
  48. package/dist/cli/program/register.subclis.js +9 -0
  49. package/dist/cli/providers-cli.js +79 -6
  50. package/dist/cli/services-cli.js +28 -0
  51. package/dist/cli/update-cli/update-command.js +73 -7
  52. package/dist/commands/auth-choice.js +1 -1
  53. package/dist/commands/daemon-install-helpers.js +2 -1
  54. package/dist/commands/models/list.auth-overview.js +12 -0
  55. package/dist/commands/onboard-channels.js +5 -0
  56. package/dist/commands/onboard-helpers.js +1 -1
  57. package/dist/commands/vllm-setup.js +12 -3
  58. package/dist/control-ui/apple-touch-icon.png +0 -0
  59. package/dist/control-ui/assets/{app-CpgQGqe6.js → app-CqF4Tc9n.js} +1706 -1675
  60. package/dist/control-ui/assets/{index-DiBBflpv.js → index-DYggPSfy.js} +3 -3
  61. package/dist/control-ui/assets/{providers-Cc89iMdx.js → providers-QMn4w2_f.js} +3 -3
  62. package/dist/control-ui/boot-watchdog.js +0 -0
  63. package/dist/control-ui/fased-logo.svg +0 -0
  64. package/dist/control-ui/favicon-32.png +0 -0
  65. package/dist/control-ui/favicon.ico +0 -0
  66. package/dist/control-ui/favicon.svg +0 -0
  67. package/dist/control-ui/index.html +1 -1
  68. package/dist/control-ui/manifest.webmanifest +0 -0
  69. package/dist/control-ui/version.json +1 -1
  70. package/dist/daemon/program-args.js +34 -0
  71. package/dist/export-html/template.css +0 -0
  72. package/dist/export-html/template.html +0 -0
  73. package/dist/export-html/template.js +0 -0
  74. package/dist/export-html/vendor/highlight.min.js +0 -0
  75. package/dist/export-html/vendor/marked.min.js +0 -0
  76. package/dist/gateway/control-reply-text.js +10 -1
  77. package/dist/gateway/method-scopes.js +2 -0
  78. package/dist/gateway/protocol/schema/agents-models-skills.js +1 -0
  79. package/dist/gateway/server-chat.js +3 -3
  80. package/dist/gateway/server-methods/channels.js +10 -2
  81. package/dist/gateway/server-methods/chat.js +19 -12
  82. package/dist/gateway/server-methods/models.js +4 -0
  83. package/dist/gateway/server-methods/services.js +47 -2
  84. package/dist/gateway/server-methods-list.js +2 -0
  85. package/dist/gateway/session-event-payloads.js +20 -9
  86. package/dist/infra/google-api-base-url.js +29 -0
  87. package/dist/infra/managed-runtime-bootstrap.js +106 -0
  88. package/dist/plugin-sdk/{accounts-BJuN64m-.js → accounts-DxblobYM.js} +1 -1
  89. package/dist/plugin-sdk/{actions-DaEvM9Bl.js → actions-D4UNimWa.js} +2 -2
  90. package/dist/plugin-sdk/{active-listener-B8Kuanet.js → active-listener-CFuy106s.js} +1 -1
  91. package/dist/plugin-sdk/{audio-preflight-D7tCO0EH.js → audio-preflight-C2QXh5Ml.js} +25 -25
  92. package/dist/plugin-sdk/{audit-CVWH4BVP.js → audit-Cs0K7LBp.js} +1 -1
  93. package/dist/plugin-sdk/{channel-access-CH9FAS-I.js → channel-access-D5aHoTY8.js} +1 -1
  94. package/dist/plugin-sdk/{channel-access-configure-CI0je66H.js → channel-access-configure-Dvch9mMQ.js} +1 -1
  95. package/dist/plugin-sdk/channel-plugin-common.js +4 -4
  96. package/dist/plugin-sdk/{chunk-01oBnQjh.js → chunk-B0FUGc5A.js} +1 -1
  97. package/dist/plugin-sdk/{chunk-items-D2zDJ8q8.js → chunk-items-3ZyiGiff.js} +1 -1
  98. package/dist/plugin-sdk/command-status.js +25 -25
  99. package/dist/plugin-sdk/{commands-registry-ckg4fhYa.js → commands-registry-DmDRhRAU.js} +2 -2
  100. package/dist/plugin-sdk/{common-zHvdO8ly.js → common-CfUOowOp.js} +1 -1
  101. package/dist/plugin-sdk/{config-DrhYEiCM.js → config-mxULv0fQ.js} +1 -1
  102. package/dist/plugin-sdk/{config-schema-BtjeV5Hm.js → config-schema-C9tx1Lyz.js} +4410 -465
  103. package/dist/plugin-sdk/discord.d.ts +1 -1
  104. package/dist/plugin-sdk/discord.js +19 -19
  105. package/dist/plugin-sdk/{handle-action-5dhYpMbP.js → handle-action-DbVCF9HZ.js} +13 -13
  106. package/dist/plugin-sdk/{helpers-E9aafRzA.js → helpers-BXbdgs5H.js} +1 -1
  107. package/dist/plugin-sdk/{image-ops-D2U9ctmu.js → image-ops-D7jPxaph.js} +1 -1
  108. package/dist/plugin-sdk/index.d.ts +11 -11
  109. package/dist/plugin-sdk/index.js +27 -27
  110. package/dist/plugin-sdk/{login-hql0fNuL.js → login-BRxww6nv.js} +3 -3
  111. package/dist/plugin-sdk/{login-qr-DJJ0svux.js → login-qr-DJXsk9XH.js} +3 -3
  112. package/dist/plugin-sdk/{manager-ciNnAMBn.js → manager-Y2S_5IlI.js} +2 -2
  113. package/dist/plugin-sdk/{markdown-tables-BKxbua_h.js → markdown-tables-DHLFQqaF.js} +1 -1
  114. package/dist/plugin-sdk/{media-DUIZ6x9H.js → media-Czo4carg.js} +2 -2
  115. package/dist/plugin-sdk/{monitor-D-giXewh.js → monitor-XbunF2-r.js} +32 -32
  116. package/dist/plugin-sdk/{monitor-CNSGw4uQ.js → monitor-Xgx6vGcg.js} +29 -29
  117. package/dist/plugin-sdk/ollama-runtime.js +970 -0
  118. package/dist/plugin-sdk/{openresponses-http-dbTd8UMk.js → openresponses-http-BRUr0JLE.js} +25 -25
  119. package/dist/plugin-sdk/{optional-runtime-dependency-CKsJL1PD.js → optional-runtime-dependency-DdMbxS24.js} +1 -1
  120. package/dist/plugin-sdk/{outbound-DhGrjRft.js → outbound-Db8mRN6P.js} +6 -6
  121. package/dist/plugin-sdk/{outbound-attachment-DAF8huFz.js → outbound-attachment-BqFjcypb.js} +2 -2
  122. package/dist/plugin-sdk/{pairing-message-BsJVvXkb.js → pairing-message-B3GC_7CD.js} +1 -1
  123. package/dist/plugin-sdk/{pairing-store-DwM-BNbj.js → pairing-store-CQikgIbw.js} +2 -2
  124. package/dist/plugin-sdk/{pi-model-discovery-DkIdlJvJ.js → pi-model-discovery-CY3m5zJP.js} +1 -1
  125. package/dist/plugin-sdk/{pi-model-discovery-runtime-Cv7okUMt.js → pi-model-discovery-runtime-DSh1T2pn.js} +2 -2
  126. package/dist/plugin-sdk/{pw-ai-Dxd87W3J.js → pw-ai-BzV0f18N.js} +3 -3
  127. package/dist/plugin-sdk/{replies-Bx61SvAC.js → replies-Fzh9PhXl.js} +2 -2
  128. package/dist/plugin-sdk/{resolve-outbound-target-bc-FpPZg.js → resolve-outbound-target-KpF3co6T.js} +1 -1
  129. package/dist/plugin-sdk/{resolve-route-D0eBYPtb.js → resolve-route-CDl74O19.js} +1 -1
  130. package/dist/plugin-sdk/{retry-policy-HTrC4zfC.js → retry-policy-D4uiqUOG.js} +1 -1
  131. package/dist/plugin-sdk/{runtime-BVkIrYLQ.js → runtime-Bb6KRnCC.js} +6 -4
  132. package/dist/plugin-sdk/{runtime-dependency-B2PqMdBu.js → runtime-dependency-Ch7J9a0d.js} +11 -11
  133. package/dist/plugin-sdk/sat-runtime.js +25 -25
  134. package/dist/plugin-sdk/{send-DgzZUx2i.js → send-5nFktR1n.js} +5 -5
  135. package/dist/plugin-sdk/{send-DT2egZNK.js → send-Bfzf11VY.js} +7 -7
  136. package/dist/plugin-sdk/{send-BGDGzxUu.js → send-C4k4JuJN.js} +6 -6
  137. package/dist/plugin-sdk/{send-KJy3ajA3.js → send-D-uDKGIq.js} +6 -6
  138. package/dist/plugin-sdk/{send-C3QWSYLR.js → send-Du8ykP1k.js} +8 -8
  139. package/dist/plugin-sdk/{session-BCIEFOu1.js → session-CS-Td9EM.js} +2 -2
  140. package/dist/plugin-sdk/{skill-commands-CyIkcR8P.js → skill-commands-CFAlXWHk.js} +2 -2
  141. package/dist/plugin-sdk/{slack-DjKNh2uh.js → slack-BzJfCWjq.js} +37 -37
  142. package/dist/plugin-sdk/{slack-actions-CeM9LWDp.js → slack-actions-BcMkNv1Z.js} +11 -11
  143. package/dist/plugin-sdk/slack.d.ts +1 -1
  144. package/dist/plugin-sdk/slack.js +9 -9
  145. package/dist/plugin-sdk/{sticker-cache-DcWzQ2wx.js → sticker-cache-Dex-XpRj.js} +3 -3
  146. package/dist/plugin-sdk/{tables-B2iehyjG.js → tables-bFXyRpkx.js} +1 -1
  147. package/dist/plugin-sdk/{targets-BPket0SF.js → targets-DH7a9lKB.js} +1 -1
  148. package/dist/plugin-sdk/{telegram-actions-Cx_HWVht.js → telegram-actions-DoFTGX4z.js} +28 -28
  149. package/dist/plugin-sdk/telegram.d.ts +1 -1
  150. package/dist/plugin-sdk/telegram.js +8 -8
  151. package/dist/plugin-sdk/{thread-bindings.lifecycle-CYH69SIw.js → thread-bindings.lifecycle-CgOvvdw8.js} +3 -3
  152. package/dist/plugin-sdk/{thread-bindings.state-BN6461WG.js → thread-bindings.state-CQpk44Hq.js} +2 -2
  153. package/dist/plugin-sdk/{web-vR-oNiBv.js → web--wC3ZfVl.js} +30 -30
  154. package/dist/plugin-sdk/{whatsapp-actions-BYNf8ceY.js → whatsapp-actions-BtSc2CBv.js} +13 -13
  155. package/dist/plugin-sdk/{whatsapp-heartbeat-DZwa8MF0.js → whatsapp-heartbeat-Bg9TuYzl.js} +2 -2
  156. package/dist/plugin-sdk/whatsapp.d.ts +6 -6
  157. package/dist/plugin-sdk/whatsapp.js +12 -12
  158. package/dist/plugin-sdk/{wsl-WGtdw_6h.js → wsl-C4DGFkOd.js} +3 -3
  159. package/dist/plugin-sdk/{zod-schema.providers-core-CIzCjXH9.d.ts → zod-schema.providers-core-FaYR6KdD.d.ts} +61 -61
  160. package/dist/plugins/provider-runtime.js +79 -0
  161. package/dist/providers/refresh.js +14 -0
  162. package/docs/reference/templates/AGENTS.dev.md +0 -0
  163. package/docs/reference/templates/AGENTS.md +0 -0
  164. package/docs/reference/templates/BOOT.md +0 -0
  165. package/docs/reference/templates/BOOTSTRAP.md +0 -0
  166. package/docs/reference/templates/HEARTBEAT.md +0 -0
  167. package/docs/reference/templates/IDENTITY.dev.md +0 -0
  168. package/docs/reference/templates/IDENTITY.md +0 -0
  169. package/docs/reference/templates/SOUL.dev.md +0 -0
  170. package/docs/reference/templates/SOUL.md +0 -0
  171. package/docs/reference/templates/TOOLS.dev.md +0 -0
  172. package/docs/reference/templates/TOOLS.md +0 -0
  173. package/docs/reference/templates/USER.dev.md +0 -0
  174. package/docs/reference/templates/USER.md +0 -0
  175. package/extensions/acpx/fased.plugin.json +0 -0
  176. package/extensions/acpx/package.json +1 -1
  177. package/extensions/acpx/skills/acp-router/SKILL.md +0 -0
  178. package/extensions/acpx/src/config.ts +0 -0
  179. package/extensions/acpx/src/ensure.ts +0 -0
  180. package/extensions/acpx/src/mcp-readonly-tool-registry.ts +0 -0
  181. package/extensions/acpx/src/mcp-status-adapter.ts +0 -0
  182. package/extensions/acpx/src/runtime-internals/events.ts +0 -0
  183. package/extensions/acpx/src/runtime-internals/process.ts +0 -0
  184. package/extensions/acpx/src/runtime-internals/shared.ts +0 -0
  185. package/extensions/acpx/src/runtime.ts +0 -0
  186. package/extensions/acpx/src/service.ts +0 -0
  187. package/extensions/bluebubbles/README.md +0 -0
  188. package/extensions/bluebubbles/fased.plugin.json +0 -0
  189. package/extensions/bluebubbles/package.json +1 -1
  190. package/extensions/bluebubbles/src/account-resolve.ts +0 -0
  191. package/extensions/bluebubbles/src/accounts.ts +0 -0
  192. package/extensions/bluebubbles/src/actions.ts +0 -0
  193. package/extensions/bluebubbles/src/attachments.ts +0 -0
  194. package/extensions/bluebubbles/src/channel.ts +0 -0
  195. package/extensions/bluebubbles/src/chat.ts +0 -0
  196. package/extensions/bluebubbles/src/config-schema.ts +0 -0
  197. package/extensions/bluebubbles/src/history.ts +0 -0
  198. package/extensions/bluebubbles/src/media-send.ts +0 -0
  199. package/extensions/bluebubbles/src/monitor-normalize.ts +0 -0
  200. package/extensions/bluebubbles/src/monitor-processing.ts +0 -0
  201. package/extensions/bluebubbles/src/monitor-reply-cache.ts +0 -0
  202. package/extensions/bluebubbles/src/monitor-shared.ts +0 -0
  203. package/extensions/bluebubbles/src/monitor.ts +0 -0
  204. package/extensions/bluebubbles/src/multipart.ts +0 -0
  205. package/extensions/bluebubbles/src/onboarding.ts +0 -0
  206. package/extensions/bluebubbles/src/probe.ts +0 -0
  207. package/extensions/bluebubbles/src/reactions.ts +0 -0
  208. package/extensions/bluebubbles/src/request-url.ts +0 -0
  209. package/extensions/bluebubbles/src/runtime.ts +0 -0
  210. package/extensions/bluebubbles/src/send-helpers.ts +0 -0
  211. package/extensions/bluebubbles/src/send.ts +0 -0
  212. package/extensions/bluebubbles/src/targets.ts +0 -0
  213. package/extensions/bluebubbles/src/test-mocks.ts +0 -0
  214. package/extensions/bluebubbles/src/types.ts +0 -0
  215. package/extensions/copilot-proxy/README.md +0 -0
  216. package/extensions/copilot-proxy/fased.plugin.json +0 -0
  217. package/extensions/copilot-proxy/package.json +1 -1
  218. package/extensions/device-pair/fased.plugin.json +0 -0
  219. package/extensions/diagnostics-otel/fased.plugin.json +0 -0
  220. package/extensions/diagnostics-otel/package.json +1 -1
  221. package/extensions/diagnostics-otel/src/service.ts +0 -0
  222. package/extensions/fased-federation/README.md +0 -0
  223. package/extensions/fased-federation/fased.plugin.json +0 -0
  224. package/extensions/fased-federation/package.json +1 -1
  225. package/extensions/google-gemini-cli-auth/README.md +0 -0
  226. package/extensions/google-gemini-cli-auth/fased.plugin.json +0 -0
  227. package/extensions/google-gemini-cli-auth/oauth.ts +0 -0
  228. package/extensions/google-gemini-cli-auth/package.json +1 -1
  229. package/extensions/imessage/fased.plugin.json +0 -0
  230. package/extensions/imessage/package.json +1 -1
  231. package/extensions/imessage/src/channel.ts +0 -0
  232. package/extensions/imessage/src/runtime.ts +0 -0
  233. package/extensions/irc/fased.plugin.json +0 -0
  234. package/extensions/irc/package.json +1 -1
  235. package/extensions/irc/src/accounts.ts +0 -0
  236. package/extensions/irc/src/channel.ts +0 -0
  237. package/extensions/irc/src/client.ts +0 -0
  238. package/extensions/irc/src/config-schema.ts +0 -0
  239. package/extensions/irc/src/connect-options.ts +0 -0
  240. package/extensions/irc/src/control-chars.ts +0 -0
  241. package/extensions/irc/src/inbound.ts +0 -0
  242. package/extensions/irc/src/monitor.ts +0 -0
  243. package/extensions/irc/src/normalize.ts +0 -0
  244. package/extensions/irc/src/onboarding.ts +0 -0
  245. package/extensions/irc/src/policy.ts +0 -0
  246. package/extensions/irc/src/probe.ts +0 -0
  247. package/extensions/irc/src/protocol.ts +0 -0
  248. package/extensions/irc/src/runtime.ts +0 -0
  249. package/extensions/irc/src/send.ts +0 -0
  250. package/extensions/irc/src/types.ts +0 -0
  251. package/extensions/line/fased.plugin.json +0 -0
  252. package/extensions/line/package.json +1 -1
  253. package/extensions/line/src/card-command.ts +0 -0
  254. package/extensions/line/src/channel.ts +0 -0
  255. package/extensions/line/src/runtime.ts +0 -0
  256. package/extensions/llm-task/README.md +0 -0
  257. package/extensions/llm-task/fased.plugin.json +0 -0
  258. package/extensions/llm-task/package.json +1 -1
  259. package/extensions/lobster/README.md +0 -0
  260. package/extensions/lobster/SKILL.md +0 -0
  261. package/extensions/lobster/fased.plugin.json +0 -0
  262. package/extensions/lobster/package.json +1 -1
  263. package/extensions/lobster/src/test-helpers.ts +0 -0
  264. package/extensions/lobster/src/windows-spawn.ts +0 -0
  265. package/extensions/matrix/CHANGELOG.md +12 -0
  266. package/extensions/matrix/fased.plugin.json +0 -0
  267. package/extensions/matrix/package.json +1 -1
  268. package/extensions/matrix/src/actions.ts +0 -0
  269. package/extensions/matrix/src/channel.ts +0 -0
  270. package/extensions/matrix/src/config-schema.ts +0 -0
  271. package/extensions/matrix/src/directory-live.ts +0 -0
  272. package/extensions/matrix/src/group-mentions.ts +0 -0
  273. package/extensions/matrix/src/matrix/accounts.ts +0 -0
  274. package/extensions/matrix/src/matrix/actions/client.ts +0 -0
  275. package/extensions/matrix/src/matrix/actions/limits.ts +0 -0
  276. package/extensions/matrix/src/matrix/actions/messages.ts +0 -0
  277. package/extensions/matrix/src/matrix/actions/pins.ts +0 -0
  278. package/extensions/matrix/src/matrix/actions/reactions.ts +0 -0
  279. package/extensions/matrix/src/matrix/actions/room.ts +0 -0
  280. package/extensions/matrix/src/matrix/actions/summary.ts +0 -0
  281. package/extensions/matrix/src/matrix/actions/types.ts +0 -0
  282. package/extensions/matrix/src/matrix/actions.ts +0 -0
  283. package/extensions/matrix/src/matrix/active-client.ts +0 -0
  284. package/extensions/matrix/src/matrix/client/config.ts +0 -0
  285. package/extensions/matrix/src/matrix/client/create-client.ts +0 -0
  286. package/extensions/matrix/src/matrix/client/logging.ts +0 -0
  287. package/extensions/matrix/src/matrix/client/runtime.ts +0 -0
  288. package/extensions/matrix/src/matrix/client/shared.ts +0 -0
  289. package/extensions/matrix/src/matrix/client/storage.ts +0 -0
  290. package/extensions/matrix/src/matrix/client/types.ts +0 -0
  291. package/extensions/matrix/src/matrix/client-bootstrap.ts +0 -0
  292. package/extensions/matrix/src/matrix/client.ts +0 -0
  293. package/extensions/matrix/src/matrix/credentials.ts +0 -0
  294. package/extensions/matrix/src/matrix/deps.ts +0 -0
  295. package/extensions/matrix/src/matrix/format.ts +0 -0
  296. package/extensions/matrix/src/matrix/monitor/access-policy.ts +0 -0
  297. package/extensions/matrix/src/matrix/monitor/allowlist.ts +0 -0
  298. package/extensions/matrix/src/matrix/monitor/auto-join.ts +0 -0
  299. package/extensions/matrix/src/matrix/monitor/direct.ts +0 -0
  300. package/extensions/matrix/src/matrix/monitor/events.ts +0 -0
  301. package/extensions/matrix/src/matrix/monitor/handler.ts +0 -0
  302. package/extensions/matrix/src/matrix/monitor/inbound-body.ts +0 -0
  303. package/extensions/matrix/src/matrix/monitor/location.ts +0 -0
  304. package/extensions/matrix/src/matrix/monitor/media.ts +0 -0
  305. package/extensions/matrix/src/matrix/monitor/mentions.ts +0 -0
  306. package/extensions/matrix/src/matrix/monitor/replies.ts +0 -0
  307. package/extensions/matrix/src/matrix/monitor/room-info.ts +0 -0
  308. package/extensions/matrix/src/matrix/monitor/rooms.ts +0 -0
  309. package/extensions/matrix/src/matrix/monitor/threads.ts +0 -0
  310. package/extensions/matrix/src/matrix/monitor/types.ts +0 -0
  311. package/extensions/matrix/src/matrix/poll-types.ts +0 -0
  312. package/extensions/matrix/src/matrix/probe.ts +0 -0
  313. package/extensions/matrix/src/matrix/send/client.ts +0 -0
  314. package/extensions/matrix/src/matrix/send/formatting.ts +0 -0
  315. package/extensions/matrix/src/matrix/send/media.ts +0 -0
  316. package/extensions/matrix/src/matrix/send/targets.ts +0 -0
  317. package/extensions/matrix/src/matrix/send/types.ts +0 -0
  318. package/extensions/matrix/src/matrix/send-queue.ts +0 -0
  319. package/extensions/matrix/src/matrix/send.ts +0 -0
  320. package/extensions/matrix/src/onboarding.ts +0 -0
  321. package/extensions/matrix/src/outbound.ts +0 -0
  322. package/extensions/matrix/src/resolve-targets.ts +0 -0
  323. package/extensions/matrix/src/runtime.ts +0 -0
  324. package/extensions/matrix/src/tool-actions.ts +0 -0
  325. package/extensions/matrix/src/types.ts +0 -0
  326. package/extensions/mattermost/fased.plugin.json +0 -0
  327. package/extensions/mattermost/package.json +1 -1
  328. package/extensions/mattermost/src/channel.ts +0 -0
  329. package/extensions/mattermost/src/config-schema.ts +0 -0
  330. package/extensions/mattermost/src/group-mentions.ts +0 -0
  331. package/extensions/mattermost/src/mattermost/accounts.ts +0 -0
  332. package/extensions/mattermost/src/mattermost/client.ts +0 -0
  333. package/extensions/mattermost/src/mattermost/monitor-auth.ts +0 -0
  334. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -0
  335. package/extensions/mattermost/src/mattermost/monitor-onchar.ts +0 -0
  336. package/extensions/mattermost/src/mattermost/monitor-websocket.ts +0 -0
  337. package/extensions/mattermost/src/mattermost/monitor.ts +0 -0
  338. package/extensions/mattermost/src/mattermost/probe.ts +0 -0
  339. package/extensions/mattermost/src/mattermost/reactions.test-helpers.ts +0 -0
  340. package/extensions/mattermost/src/mattermost/reactions.ts +0 -0
  341. package/extensions/mattermost/src/mattermost/reconnect.ts +0 -0
  342. package/extensions/mattermost/src/mattermost/send.ts +0 -0
  343. package/extensions/mattermost/src/normalize.ts +0 -0
  344. package/extensions/mattermost/src/onboarding-helpers.ts +0 -0
  345. package/extensions/mattermost/src/onboarding.ts +0 -0
  346. package/extensions/mattermost/src/runtime.ts +0 -0
  347. package/extensions/mattermost/src/types.ts +0 -0
  348. package/extensions/memory-core/fased.plugin.json +0 -0
  349. package/extensions/memory-core/package.json +2 -2
  350. package/extensions/memory-lancedb/config.ts +0 -0
  351. package/extensions/memory-lancedb/fased.plugin.json +0 -0
  352. package/extensions/memory-lancedb/package.json +1 -1
  353. package/extensions/minimax-portal-auth/README.md +0 -0
  354. package/extensions/minimax-portal-auth/fased.plugin.json +0 -0
  355. package/extensions/minimax-portal-auth/oauth.ts +0 -0
  356. package/extensions/minimax-portal-auth/package.json +1 -1
  357. package/extensions/msteams/CHANGELOG.md +12 -0
  358. package/extensions/msteams/fased.plugin.json +0 -0
  359. package/extensions/msteams/package.json +1 -1
  360. package/extensions/msteams/src/attachments/download.ts +0 -0
  361. package/extensions/msteams/src/attachments/graph.ts +0 -0
  362. package/extensions/msteams/src/attachments/html.ts +0 -0
  363. package/extensions/msteams/src/attachments/payload.ts +0 -0
  364. package/extensions/msteams/src/attachments/remote-media.ts +0 -0
  365. package/extensions/msteams/src/attachments/shared.ts +0 -0
  366. package/extensions/msteams/src/attachments/types.ts +0 -0
  367. package/extensions/msteams/src/attachments.ts +0 -0
  368. package/extensions/msteams/src/channel.ts +0 -0
  369. package/extensions/msteams/src/conversation-store-fs.ts +0 -0
  370. package/extensions/msteams/src/conversation-store-memory.ts +0 -0
  371. package/extensions/msteams/src/conversation-store.ts +0 -0
  372. package/extensions/msteams/src/directory-live.ts +0 -0
  373. package/extensions/msteams/src/errors.ts +0 -0
  374. package/extensions/msteams/src/file-consent-helpers.ts +0 -0
  375. package/extensions/msteams/src/file-consent.ts +0 -0
  376. package/extensions/msteams/src/file-lock.ts +0 -0
  377. package/extensions/msteams/src/graph-chat.ts +0 -0
  378. package/extensions/msteams/src/graph-upload.ts +0 -0
  379. package/extensions/msteams/src/graph-users.ts +0 -0
  380. package/extensions/msteams/src/graph.ts +0 -0
  381. package/extensions/msteams/src/inbound.ts +0 -0
  382. package/extensions/msteams/src/media-helpers.ts +0 -0
  383. package/extensions/msteams/src/mentions.ts +0 -0
  384. package/extensions/msteams/src/messenger.ts +0 -0
  385. package/extensions/msteams/src/monitor-handler/inbound-media.ts +0 -0
  386. package/extensions/msteams/src/monitor-handler/message-handler.ts +0 -0
  387. package/extensions/msteams/src/monitor-handler.ts +0 -0
  388. package/extensions/msteams/src/monitor-types.ts +0 -0
  389. package/extensions/msteams/src/monitor.ts +0 -0
  390. package/extensions/msteams/src/onboarding.ts +0 -0
  391. package/extensions/msteams/src/outbound.ts +0 -0
  392. package/extensions/msteams/src/pending-uploads.ts +0 -0
  393. package/extensions/msteams/src/policy.ts +0 -0
  394. package/extensions/msteams/src/polls-store-memory.ts +0 -0
  395. package/extensions/msteams/src/polls.ts +0 -0
  396. package/extensions/msteams/src/probe.ts +0 -0
  397. package/extensions/msteams/src/reply-dispatcher.ts +0 -0
  398. package/extensions/msteams/src/resolve-allowlist.ts +0 -0
  399. package/extensions/msteams/src/runtime.ts +0 -0
  400. package/extensions/msteams/src/sdk-types.ts +0 -0
  401. package/extensions/msteams/src/sdk.ts +0 -0
  402. package/extensions/msteams/src/send-context.ts +0 -0
  403. package/extensions/msteams/src/send.ts +0 -0
  404. package/extensions/msteams/src/sent-message-cache.ts +0 -0
  405. package/extensions/msteams/src/storage.ts +0 -0
  406. package/extensions/msteams/src/store-fs.ts +0 -0
  407. package/extensions/msteams/src/test-runtime.ts +0 -0
  408. package/extensions/msteams/src/token-response.ts +0 -0
  409. package/extensions/msteams/src/token.ts +0 -0
  410. package/extensions/nextcloud-talk/fased.plugin.json +0 -0
  411. package/extensions/nextcloud-talk/package.json +1 -1
  412. package/extensions/nextcloud-talk/src/accounts.ts +0 -0
  413. package/extensions/nextcloud-talk/src/config-schema.ts +0 -0
  414. package/extensions/nextcloud-talk/src/format.ts +0 -0
  415. package/extensions/nextcloud-talk/src/inbound.ts +0 -0
  416. package/extensions/nextcloud-talk/src/monitor.ts +0 -0
  417. package/extensions/nextcloud-talk/src/normalize.ts +0 -0
  418. package/extensions/nextcloud-talk/src/onboarding.ts +0 -0
  419. package/extensions/nextcloud-talk/src/policy.ts +0 -0
  420. package/extensions/nextcloud-talk/src/replay-guard.ts +0 -0
  421. package/extensions/nextcloud-talk/src/room-info.ts +0 -0
  422. package/extensions/nextcloud-talk/src/runtime.ts +0 -0
  423. package/extensions/nextcloud-talk/src/send.ts +0 -0
  424. package/extensions/nextcloud-talk/src/signature.ts +0 -0
  425. package/extensions/nextcloud-talk/src/types.ts +0 -0
  426. package/extensions/nostr/CHANGELOG.md +12 -0
  427. package/extensions/nostr/README.md +0 -0
  428. package/extensions/nostr/fased.plugin.json +0 -0
  429. package/extensions/nostr/package.json +1 -1
  430. package/extensions/nostr/src/channel.ts +0 -0
  431. package/extensions/nostr/src/config-schema.ts +0 -0
  432. package/extensions/nostr/src/metrics.ts +0 -0
  433. package/extensions/nostr/src/nostr-bus.ts +0 -0
  434. package/extensions/nostr/src/nostr-profile-http.ts +0 -0
  435. package/extensions/nostr/src/nostr-profile-import.ts +0 -0
  436. package/extensions/nostr/src/nostr-profile.ts +0 -0
  437. package/extensions/nostr/src/nostr-state-store.ts +0 -0
  438. package/extensions/nostr/src/onboarding.ts +0 -0
  439. package/extensions/nostr/src/runtime.ts +0 -0
  440. package/extensions/nostr/src/seen-tracker.ts +0 -0
  441. package/extensions/nostr/src/types.ts +0 -0
  442. package/extensions/nostr/test/setup.ts +0 -0
  443. package/extensions/open-prose/README.md +0 -0
  444. package/extensions/open-prose/fased.plugin.json +0 -0
  445. package/extensions/open-prose/package.json +1 -1
  446. package/extensions/open-prose/skills/prose/LICENSE +0 -0
  447. package/extensions/open-prose/skills/prose/SKILL.md +0 -0
  448. package/extensions/open-prose/skills/prose/alt-borges.md +0 -0
  449. package/extensions/open-prose/skills/prose/alts/arabian-nights.md +0 -0
  450. package/extensions/open-prose/skills/prose/alts/borges.md +0 -0
  451. package/extensions/open-prose/skills/prose/alts/folk.md +0 -0
  452. package/extensions/open-prose/skills/prose/alts/homer.md +0 -0
  453. package/extensions/open-prose/skills/prose/alts/kafka.md +0 -0
  454. package/extensions/open-prose/skills/prose/compiler.md +0 -0
  455. package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +0 -0
  456. package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +0 -0
  457. package/extensions/open-prose/skills/prose/examples/03-code-review.prose +0 -0
  458. package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +0 -0
  459. package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +0 -0
  460. package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +0 -0
  461. package/extensions/open-prose/skills/prose/examples/07-refactor.prose +0 -0
  462. package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +0 -0
  463. package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +0 -0
  464. package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +0 -0
  465. package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +0 -0
  466. package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +0 -0
  467. package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +0 -0
  468. package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +0 -0
  469. package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +0 -0
  470. package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +0 -0
  471. package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +0 -0
  472. package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +0 -0
  473. package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +0 -0
  474. package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +0 -0
  475. package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +0 -0
  476. package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +0 -0
  477. package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +0 -0
  478. package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +0 -0
  479. package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +0 -0
  480. package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +0 -0
  481. package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +0 -0
  482. package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +0 -0
  483. package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +0 -0
  484. package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +0 -0
  485. package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +0 -0
  486. package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +0 -0
  487. package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +0 -0
  488. package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +0 -0
  489. package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +0 -0
  490. package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +0 -0
  491. package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +0 -0
  492. package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +0 -0
  493. package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +0 -0
  494. package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +0 -0
  495. package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +0 -0
  496. package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +0 -0
  497. package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +0 -0
  498. package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +0 -0
  499. package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +0 -0
  500. package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +0 -0
  501. package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +0 -0
  502. package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +0 -0
  503. package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +0 -0
  504. package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +0 -0
  505. package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +0 -0
  506. package/extensions/open-prose/skills/prose/examples/README.md +0 -0
  507. package/extensions/open-prose/skills/prose/examples/roadmap/README.md +0 -0
  508. package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +0 -0
  509. package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +0 -0
  510. package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +0 -0
  511. package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +0 -0
  512. package/extensions/open-prose/skills/prose/guidance/antipatterns.md +0 -0
  513. package/extensions/open-prose/skills/prose/guidance/patterns.md +0 -0
  514. package/extensions/open-prose/skills/prose/guidance/system-prompt.md +0 -0
  515. package/extensions/open-prose/skills/prose/help.md +0 -0
  516. package/extensions/open-prose/skills/prose/lib/README.md +0 -0
  517. package/extensions/open-prose/skills/prose/lib/calibrator.prose +0 -0
  518. package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +0 -0
  519. package/extensions/open-prose/skills/prose/lib/error-forensics.prose +0 -0
  520. package/extensions/open-prose/skills/prose/lib/inspector.prose +0 -0
  521. package/extensions/open-prose/skills/prose/lib/profiler.prose +0 -0
  522. package/extensions/open-prose/skills/prose/lib/program-improver.prose +0 -0
  523. package/extensions/open-prose/skills/prose/lib/project-memory.prose +0 -0
  524. package/extensions/open-prose/skills/prose/lib/user-memory.prose +0 -0
  525. package/extensions/open-prose/skills/prose/lib/vm-improver.prose +0 -0
  526. package/extensions/open-prose/skills/prose/primitives/session.md +0 -0
  527. package/extensions/open-prose/skills/prose/prose.md +0 -0
  528. package/extensions/open-prose/skills/prose/state/filesystem.md +0 -0
  529. package/extensions/open-prose/skills/prose/state/in-context.md +0 -0
  530. package/extensions/open-prose/skills/prose/state/postgres.md +0 -0
  531. package/extensions/open-prose/skills/prose/state/sqlite.md +0 -0
  532. package/extensions/phone-control/fased.plugin.json +0 -0
  533. package/extensions/qwen-portal-auth/README.md +0 -0
  534. package/extensions/qwen-portal-auth/fased.plugin.json +0 -0
  535. package/extensions/qwen-portal-auth/oauth.ts +0 -0
  536. package/extensions/sat-mining/fased.plugin.json +0 -0
  537. package/extensions/sat-mining/package.json +1 -1
  538. package/extensions/sat-mining/skills/sat-mining/SKILL.md +0 -0
  539. package/extensions/sat-mining/src/audit-store.ts +0 -0
  540. package/extensions/sat-mining/src/auto-planner.ts +0 -0
  541. package/extensions/sat-mining/src/chain-time.ts +0 -0
  542. package/extensions/sat-mining/src/client.ts +0 -0
  543. package/extensions/sat-mining/src/cycle-progress.ts +0 -0
  544. package/extensions/sat-mining/src/dispute-review.ts +0 -0
  545. package/extensions/sat-mining/src/hash-spec.ts +0 -0
  546. package/extensions/sat-mining/src/planner-analytics.ts +0 -0
  547. package/extensions/sat-mining/src/planner-outcomes.ts +0 -0
  548. package/extensions/sat-mining/src/planner-policy-eval.ts +0 -0
  549. package/extensions/sat-mining/src/planner-policy.ts +0 -0
  550. package/extensions/sat-mining/src/recovery-service.ts +0 -0
  551. package/extensions/sat-mining/src/replay.ts +0 -0
  552. package/extensions/sat-mining/src/service-read-timeout.ts +0 -0
  553. package/extensions/sat-mining/src/strategy-base.ts +0 -0
  554. package/extensions/sat-mining/src/strategy-engine.ts +0 -0
  555. package/extensions/sat-mining/src/strategy-validate.ts +0 -0
  556. package/extensions/shared/resolve-target-test-helpers.ts +0 -0
  557. package/extensions/signal/fased.plugin.json +0 -0
  558. package/extensions/signal/package.json +1 -1
  559. package/extensions/signal/src/channel.ts +0 -0
  560. package/extensions/signal/src/runtime.ts +0 -0
  561. package/extensions/synology-chat/fased.plugin.json +0 -0
  562. package/extensions/synology-chat/package.json +1 -1
  563. package/extensions/synology-chat/src/accounts.ts +0 -0
  564. package/extensions/synology-chat/src/channel.ts +0 -0
  565. package/extensions/synology-chat/src/client.ts +0 -0
  566. package/extensions/synology-chat/src/runtime.ts +0 -0
  567. package/extensions/synology-chat/src/security.ts +0 -0
  568. package/extensions/synology-chat/src/types.ts +0 -0
  569. package/extensions/synology-chat/src/webhook-handler.ts +0 -0
  570. package/extensions/talk-voice/fased.plugin.json +0 -0
  571. package/extensions/thread-ownership/fased.plugin.json +0 -0
  572. package/extensions/tlon/README.md +0 -0
  573. package/extensions/tlon/fased.plugin.json +0 -0
  574. package/extensions/tlon/package.json +1 -1
  575. package/extensions/tlon/src/account-fields.ts +0 -0
  576. package/extensions/tlon/src/channel.ts +0 -0
  577. package/extensions/tlon/src/config-schema.ts +0 -0
  578. package/extensions/tlon/src/monitor/discovery.ts +0 -0
  579. package/extensions/tlon/src/monitor/history.ts +0 -0
  580. package/extensions/tlon/src/monitor/processed-messages.ts +0 -0
  581. package/extensions/tlon/src/monitor/utils.ts +0 -0
  582. package/extensions/tlon/src/onboarding.ts +0 -0
  583. package/extensions/tlon/src/runtime.ts +0 -0
  584. package/extensions/tlon/src/targets.ts +0 -0
  585. package/extensions/tlon/src/types.ts +0 -0
  586. package/extensions/tlon/src/urbit/auth.ts +0 -0
  587. package/extensions/tlon/src/urbit/base-url.ts +0 -0
  588. package/extensions/tlon/src/urbit/channel-client.ts +0 -0
  589. package/extensions/tlon/src/urbit/channel-ops.ts +0 -0
  590. package/extensions/tlon/src/urbit/context.ts +0 -0
  591. package/extensions/tlon/src/urbit/errors.ts +0 -0
  592. package/extensions/tlon/src/urbit/fetch.ts +0 -0
  593. package/extensions/tlon/src/urbit/send.ts +0 -0
  594. package/extensions/tlon/src/urbit/sse-client.ts +0 -0
  595. package/extensions/twitch/CHANGELOG.md +12 -0
  596. package/extensions/twitch/README.md +0 -0
  597. package/extensions/twitch/fased.plugin.json +0 -0
  598. package/extensions/twitch/package.json +1 -1
  599. package/extensions/twitch/src/access-control.ts +0 -0
  600. package/extensions/twitch/src/actions.ts +0 -0
  601. package/extensions/twitch/src/client-manager-registry.ts +0 -0
  602. package/extensions/twitch/src/config-schema.ts +0 -0
  603. package/extensions/twitch/src/config.ts +0 -0
  604. package/extensions/twitch/src/monitor.ts +0 -0
  605. package/extensions/twitch/src/onboarding.ts +0 -0
  606. package/extensions/twitch/src/outbound.ts +0 -0
  607. package/extensions/twitch/src/probe.ts +0 -0
  608. package/extensions/twitch/src/resolver.ts +0 -0
  609. package/extensions/twitch/src/runtime.ts +0 -0
  610. package/extensions/twitch/src/send.ts +0 -0
  611. package/extensions/twitch/src/status.ts +0 -0
  612. package/extensions/twitch/src/test-fixtures.ts +0 -0
  613. package/extensions/twitch/src/twitch-client.ts +0 -0
  614. package/extensions/twitch/src/utils/markdown.ts +0 -0
  615. package/extensions/twitch/src/utils/twitch.ts +0 -0
  616. package/extensions/twitch/test/setup.ts +0 -0
  617. package/extensions/voice-call/CHANGELOG.md +12 -0
  618. package/extensions/voice-call/README.md +0 -0
  619. package/extensions/voice-call/fased.plugin.json +0 -0
  620. package/extensions/voice-call/package.json +1 -1
  621. package/extensions/voice-call/src/allowlist.ts +0 -0
  622. package/extensions/voice-call/src/cli.ts +0 -0
  623. package/extensions/voice-call/src/core-bridge.ts +0 -0
  624. package/extensions/voice-call/src/http-headers.ts +0 -0
  625. package/extensions/voice-call/src/manager/context.ts +0 -0
  626. package/extensions/voice-call/src/manager/events.ts +0 -0
  627. package/extensions/voice-call/src/manager/lookup.ts +0 -0
  628. package/extensions/voice-call/src/manager/outbound.ts +0 -0
  629. package/extensions/voice-call/src/manager/state.ts +0 -0
  630. package/extensions/voice-call/src/manager/store.ts +0 -0
  631. package/extensions/voice-call/src/manager/timers.ts +0 -0
  632. package/extensions/voice-call/src/manager/twiml.ts +0 -0
  633. package/extensions/voice-call/src/manager.ts +0 -0
  634. package/extensions/voice-call/src/media-stream.ts +0 -0
  635. package/extensions/voice-call/src/providers/base.ts +0 -0
  636. package/extensions/voice-call/src/providers/mock.ts +0 -0
  637. package/extensions/voice-call/src/providers/plivo.ts +0 -0
  638. package/extensions/voice-call/src/providers/shared/guarded-json-api.ts +0 -0
  639. package/extensions/voice-call/src/providers/stt-openai-realtime.ts +0 -0
  640. package/extensions/voice-call/src/providers/telnyx.ts +0 -0
  641. package/extensions/voice-call/src/providers/tts-openai.ts +0 -0
  642. package/extensions/voice-call/src/providers/twilio/api.ts +0 -0
  643. package/extensions/voice-call/src/providers/twilio/webhook.ts +0 -0
  644. package/extensions/voice-call/src/providers/twilio.ts +0 -0
  645. package/extensions/voice-call/src/response-generator.ts +0 -0
  646. package/extensions/voice-call/src/runtime.ts +0 -0
  647. package/extensions/voice-call/src/telephony-audio.ts +0 -0
  648. package/extensions/voice-call/src/telephony-tts.ts +0 -0
  649. package/extensions/voice-call/src/tunnel.ts +0 -0
  650. package/extensions/voice-call/src/types.ts +0 -0
  651. package/extensions/voice-call/src/utils.ts +0 -0
  652. package/extensions/voice-call/src/voice-mapping.ts +0 -0
  653. package/extensions/voice-call/src/webhook/stale-call-reaper.ts +0 -0
  654. package/extensions/voice-call/src/webhook-security.ts +0 -0
  655. package/extensions/zalo/CHANGELOG.md +12 -0
  656. package/extensions/zalo/README.md +0 -0
  657. package/extensions/zalo/fased.plugin.json +0 -0
  658. package/extensions/zalo/package.json +1 -1
  659. package/extensions/zalo/src/accounts.ts +0 -0
  660. package/extensions/zalo/src/actions.ts +0 -0
  661. package/extensions/zalo/src/api.ts +0 -0
  662. package/extensions/zalo/src/channel.ts +0 -0
  663. package/extensions/zalo/src/config-schema.ts +0 -0
  664. package/extensions/zalo/src/group-access.ts +0 -0
  665. package/extensions/zalo/src/monitor.ts +0 -0
  666. package/extensions/zalo/src/monitor.webhook.ts +0 -0
  667. package/extensions/zalo/src/onboarding.ts +0 -0
  668. package/extensions/zalo/src/probe.ts +0 -0
  669. package/extensions/zalo/src/proxy.ts +0 -0
  670. package/extensions/zalo/src/runtime.ts +0 -0
  671. package/extensions/zalo/src/send.ts +0 -0
  672. package/extensions/zalo/src/status-issues.ts +0 -0
  673. package/extensions/zalo/src/token.ts +0 -0
  674. package/extensions/zalo/src/types.ts +0 -0
  675. package/extensions/zalouser/CHANGELOG.md +12 -0
  676. package/extensions/zalouser/README.md +0 -0
  677. package/extensions/zalouser/fased.plugin.json +0 -0
  678. package/extensions/zalouser/package.json +1 -1
  679. package/extensions/zalouser/src/accounts.ts +0 -0
  680. package/extensions/zalouser/src/channel.ts +0 -0
  681. package/extensions/zalouser/src/config-schema.ts +0 -0
  682. package/extensions/zalouser/src/monitor.ts +0 -0
  683. package/extensions/zalouser/src/onboarding.ts +0 -0
  684. package/extensions/zalouser/src/probe.ts +0 -0
  685. package/extensions/zalouser/src/runtime.ts +0 -0
  686. package/extensions/zalouser/src/send.ts +0 -0
  687. package/extensions/zalouser/src/status-issues.ts +0 -0
  688. package/extensions/zalouser/src/tool.ts +0 -0
  689. package/extensions/zalouser/src/types.ts +0 -0
  690. package/extensions/zalouser/src/zca.ts +0 -0
  691. package/package.json +8 -2
  692. package/scripts/fased-launcher-runtime.mjs +0 -0
  693. package/scripts/fased-managed-launcher.sh +60 -0
  694. package/scripts/fased-managed-service.sh +57 -0
  695. package/scripts/fased-managed-updater.mjs +879 -0
  696. package/scripts/install-managed-runtime.mjs +239 -0
  697. package/scripts/managed-runtime-layout.mjs +188 -0
  698. package/scripts/run-node.mjs +0 -0
  699. package/shared/sat-hash-v1.json +0 -0
  700. package/skills/1password/SKILL.md +0 -0
  701. package/skills/1password/references/cli-examples.md +0 -0
  702. package/skills/1password/references/get-started.md +0 -0
  703. package/skills/apple-notes/SKILL.md +0 -0
  704. package/skills/apple-reminders/SKILL.md +0 -0
  705. package/skills/bear-notes/SKILL.md +0 -0
  706. package/skills/blogwatcher/SKILL.md +0 -0
  707. package/skills/blucli/SKILL.md +0 -0
  708. package/skills/bluebubbles/SKILL.md +0 -0
  709. package/skills/camsnap/SKILL.md +0 -0
  710. package/skills/canvas/SKILL.md +0 -0
  711. package/skills/clawhub/SKILL.md +0 -0
  712. package/skills/coding-agent/SKILL.md +0 -0
  713. package/skills/diagram-maker/SKILL.md +0 -0
  714. package/skills/diagram-maker/references/excalidraw-patterns.md +0 -0
  715. package/skills/diagram-maker/references/svg-template.md +0 -0
  716. package/skills/discord/SKILL.md +0 -0
  717. package/skills/eightctl/SKILL.md +0 -0
  718. package/skills/food-order/SKILL.md +0 -0
  719. package/skills/gemini/SKILL.md +0 -0
  720. package/skills/gh-issues/SKILL.md +0 -0
  721. package/skills/gifgrep/SKILL.md +0 -0
  722. package/skills/github/SKILL.md +0 -0
  723. package/skills/gog/SKILL.md +0 -0
  724. package/skills/goplaces/SKILL.md +0 -0
  725. package/skills/healthcheck/SKILL.md +0 -0
  726. package/skills/himalaya/SKILL.md +0 -0
  727. package/skills/himalaya/references/configuration.md +0 -0
  728. package/skills/himalaya/references/message-composition.md +0 -0
  729. package/skills/imsg/SKILL.md +0 -0
  730. package/skills/mcporter/SKILL.md +0 -0
  731. package/skills/model-usage/SKILL.md +0 -0
  732. package/skills/model-usage/references/codexbar-cli.md +0 -0
  733. package/skills/model-usage/scripts/model_usage.py +0 -0
  734. package/skills/model-usage/scripts/test_model_usage.py +0 -0
  735. package/skills/nano-banana-pro/SKILL.md +0 -0
  736. package/skills/nano-pdf/SKILL.md +0 -0
  737. package/skills/node-connect/SKILL.md +0 -0
  738. package/skills/node-inspect-debugger/SKILL.md +0 -0
  739. package/skills/notion/SKILL.md +0 -0
  740. package/skills/obsidian/SKILL.md +0 -0
  741. package/skills/openai-image-gen/SKILL.md +0 -0
  742. package/skills/openai-image-gen/scripts/gen.py +0 -0
  743. package/skills/openai-image-gen/scripts/test_gen.py +0 -0
  744. package/skills/openai-whisper/SKILL.md +0 -0
  745. package/skills/openai-whisper-api/SKILL.md +0 -0
  746. package/skills/openai-whisper-api/scripts/transcribe.sh +0 -0
  747. package/skills/opencode/SKILL.md +0 -0
  748. package/skills/openhue/SKILL.md +0 -0
  749. package/skills/oracle/SKILL.md +0 -0
  750. package/skills/ordercli/SKILL.md +0 -0
  751. package/skills/peekaboo/SKILL.md +0 -0
  752. package/skills/python-debugpy/SKILL.md +0 -0
  753. package/skills/sag/SKILL.md +0 -0
  754. package/skills/session-logs/SKILL.md +0 -0
  755. package/skills/sherpa-onnx-tts/SKILL.md +0 -0
  756. package/skills/skill-creator/SKILL.md +0 -0
  757. package/skills/skill-creator/license.txt +0 -0
  758. package/skills/skill-creator/scripts/init_skill.py +0 -0
  759. package/skills/skill-creator/scripts/package_skill.py +0 -0
  760. package/skills/skill-creator/scripts/quick_validate.py +0 -0
  761. package/skills/skill-creator/scripts/test_package_skill.py +0 -0
  762. package/skills/skill-creator/scripts/test_quick_validate.py +0 -0
  763. package/skills/skill-workshop/SKILL.md +0 -0
  764. package/skills/slack/SKILL.md +0 -0
  765. package/skills/songsee/SKILL.md +0 -0
  766. package/skills/sonoscli/SKILL.md +0 -0
  767. package/skills/spotify-player/SKILL.md +0 -0
  768. package/skills/summarize/SKILL.md +0 -0
  769. package/skills/things-mac/SKILL.md +0 -0
  770. package/skills/tmux/SKILL.md +0 -0
  771. package/skills/trello/SKILL.md +0 -0
  772. package/skills/video-frames/SKILL.md +0 -0
  773. package/skills/video-frames/scripts/frame.sh +0 -0
  774. package/skills/voice-call/SKILL.md +0 -0
  775. package/skills/wacli/SKILL.md +0 -0
  776. package/skills/wallet-actions/SKILL.md +0 -0
  777. package/skills/weather/SKILL.md +0 -0
  778. package/skills/xurl/SKILL.md +0 -0
@@ -0,0 +1,1040 @@
1
+ import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./copilot-dynamic-headers.js";
2
+ import { resolveProviderTransportTurnStateWithPlugin } from "../plugins/provider-runtime.js";
3
+ import { stripSystemPromptCacheBoundary } from "./system-prompt-cache-boundary.js";
4
+ import { buildGuardedModelFetch } from "./provider-transport-fetch.js";
5
+ import { transformTransportMessages } from "./transport-message-transform.js";
6
+ import { mergeTransportMetadata, sanitizeTransportPayloadText } from "./transport-stream-shared.js";
7
+ import { detectOpenAICompletionsCompat } from "./openai-completions-compat.js";
8
+ import { applyOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesPayloadPolicy } from "./openai-responses-payload-policy.js";
9
+ import { normalizeOpenAIStrictToolParameters, resolveOpenAIStrictToolFlagForInventory, resolveOpenAIStrictToolSetting } from "./openai-tool-schema.js";
10
+ import { randomUUID } from "node:crypto";
11
+ import { calculateCost, createAssistantMessageEventStream, getEnvApiKey, parseStreamingJson } from "@mariozechner/pi-ai/compat";
12
+ import { convertMessages } from "@mariozechner/pi-ai/api/openai-completions";
13
+
14
+ //#region src/agents/openai-transport-stream.ts
15
+ function resolveAzureOpenAIApiVersion(env = process.env) {
16
+ return env.AZURE_OPENAI_API_VERSION?.trim() || "2024-12-01-preview";
17
+ }
18
+ function stringifyUnknown(value, fallback = "") {
19
+ if (typeof value === "string") {
20
+ return value;
21
+ }
22
+ if (typeof value === "number" || typeof value === "boolean") {
23
+ return String(value);
24
+ }
25
+ return fallback;
26
+ }
27
+ function stringifyJsonLike(value, fallback = "") {
28
+ if (typeof value === "string") {
29
+ return value;
30
+ }
31
+ if (value && typeof value === "object") {
32
+ return JSON.stringify(value);
33
+ }
34
+ if (typeof value === "number" || typeof value === "boolean") {
35
+ return String(value);
36
+ }
37
+ return fallback;
38
+ }
39
+ function getServiceTierCostMultiplier(serviceTier) {
40
+ switch (serviceTier) {
41
+ case "flex": return .5;
42
+ case "priority": return 2;
43
+ default: return 1;
44
+ }
45
+ }
46
+ function applyServiceTierPricing(usage, serviceTier) {
47
+ const multiplier = getServiceTierCostMultiplier(serviceTier);
48
+ if (multiplier === 1) {
49
+ return;
50
+ }
51
+ usage.cost.input *= multiplier;
52
+ usage.cost.output *= multiplier;
53
+ usage.cost.cacheRead *= multiplier;
54
+ usage.cost.cacheWrite *= multiplier;
55
+ usage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;
56
+ }
57
+ function resolveOpenAIEndpoint(baseURL, path) {
58
+ const base = (baseURL?.trim() || "https://api.openai.com/v1").replace(/\/+$/, "");
59
+ return `${base}${path}`;
60
+ }
61
+ async function* parseServerSentJson(response) {
62
+ if (!response.body) {
63
+ const text = await response.text();
64
+ for (const line of text.split(/\r?\n/)) {
65
+ const trimmed = line.trim();
66
+ if (!trimmed || trimmed === "[DONE]") {
67
+ continue;
68
+ }
69
+ yield JSON.parse(trimmed);
70
+ }
71
+ return;
72
+ }
73
+ const reader = response.body.getReader();
74
+ const decoder = new TextDecoder();
75
+ let buffer = "";
76
+ const emitBlock = function* (block) {
77
+ const data = block.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).trim()).join("\n").trim();
78
+ if (!data || data === "[DONE]") {
79
+ return;
80
+ }
81
+ yield JSON.parse(data);
82
+ };
83
+ while (true) {
84
+ const chunk = await reader.read();
85
+ if (chunk.done) {
86
+ break;
87
+ }
88
+ buffer += decoder.decode(chunk.value, { stream: true });
89
+ let boundary = buffer.indexOf("\n\n");
90
+ while (boundary >= 0) {
91
+ const block = buffer.slice(0, boundary);
92
+ buffer = buffer.slice(boundary + 2);
93
+ for (const event of emitBlock(block)) {
94
+ yield event;
95
+ }
96
+ boundary = buffer.indexOf("\n\n");
97
+ }
98
+ }
99
+ buffer += decoder.decode();
100
+ if (buffer.trim()) {
101
+ for (const event of emitBlock(buffer)) {
102
+ yield event;
103
+ }
104
+ }
105
+ }
106
+ function createOpenAIStreamClient(options) {
107
+ const request = async (path, payload, init) => {
108
+ const response = await options.fetch(resolveOpenAIEndpoint(options.baseURL, path), {
109
+ method: "POST",
110
+ headers: {
111
+ authorization: `Bearer ${options.apiKey}`,
112
+ "content-type": "application/json",
113
+ accept: "text/event-stream",
114
+ ...options.defaultHeaders
115
+ },
116
+ body: JSON.stringify(payload),
117
+ signal: init?.signal
118
+ });
119
+ if (!response.ok) {
120
+ const text = await response.text().catch(() => "");
121
+ throw new Error(`OpenAI transport request failed (${response.status} ${response.statusText})${text ? `: ${text.slice(0, 500)}` : ""}`);
122
+ }
123
+ return parseServerSentJson(response);
124
+ };
125
+ return {
126
+ responses: { create: (payload, init) => request("/responses", payload, init) },
127
+ chat: { completions: { create: (payload, init) => request("/chat/completions", payload, init) } }
128
+ };
129
+ }
130
+ async function resolvePayloadOverride(onPayload, payload, model) {
131
+ const nextPayload = onPayload?.(payload, model);
132
+ return nextPayload instanceof Promise ? await nextPayload : nextPayload;
133
+ }
134
+ function shortHash(value) {
135
+ let hash = 0;
136
+ for (let i = 0; i < value.length; i += 1) {
137
+ hash = hash * 31 + value.charCodeAt(i) | 0;
138
+ }
139
+ return Math.abs(hash).toString(36);
140
+ }
141
+ function encodeTextSignatureV1(id, phase) {
142
+ return JSON.stringify({
143
+ v: 1,
144
+ id,
145
+ ...phase ? { phase } : {}
146
+ });
147
+ }
148
+ function parseTextSignature(signature) {
149
+ if (!signature) {
150
+ return undefined;
151
+ }
152
+ if (signature.startsWith("{")) {
153
+ try {
154
+ const parsed = JSON.parse(signature);
155
+ if (parsed.v === 1 && typeof parsed.id === "string") {
156
+ return parsed.phase === "commentary" || parsed.phase === "final_answer" ? {
157
+ id: parsed.id,
158
+ phase: parsed.phase
159
+ } : { id: parsed.id };
160
+ }
161
+ } catch {}
162
+ }
163
+ return { id: signature };
164
+ }
165
+ function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
166
+ const messages = [];
167
+ const normalizeIdPart = (part) => {
168
+ const sanitized = part.replace(/[^a-zA-Z0-9_-]/g, "_");
169
+ const normalized = sanitized.length > 64 ? sanitized.slice(0, 64) : sanitized;
170
+ return normalized.replace(/_+$/, "");
171
+ };
172
+ const buildForeignResponsesItemId = (itemId) => {
173
+ const normalized = `fc_${shortHash(itemId)}`;
174
+ return normalized.length > 64 ? normalized.slice(0, 64) : normalized;
175
+ };
176
+ const normalizeToolCallId = (id, _targetModel, source) => {
177
+ if (!allowedToolCallProviders.has(model.provider)) {
178
+ return normalizeIdPart(id);
179
+ }
180
+ if (!id.includes("|")) {
181
+ return normalizeIdPart(id);
182
+ }
183
+ const [callId, itemId] = id.split("|");
184
+ const normalizedCallId = normalizeIdPart(callId);
185
+ const isForeignToolCall = source.provider !== model.provider || source.api !== model.api;
186
+ let normalizedItemId = isForeignToolCall ? buildForeignResponsesItemId(itemId) : normalizeIdPart(itemId);
187
+ if (!normalizedItemId.startsWith("fc_")) {
188
+ normalizedItemId = normalizeIdPart(`fc_${normalizedItemId}`);
189
+ }
190
+ return `${normalizedCallId}|${normalizedItemId}`;
191
+ };
192
+ const transformedMessages = transformTransportMessages(context.messages, model, normalizeToolCallId);
193
+ const includeSystemPrompt = options?.includeSystemPrompt ?? true;
194
+ if (includeSystemPrompt && context.systemPrompt) {
195
+ messages.push({
196
+ role: model.reasoning && options?.supportsDeveloperRole !== false ? "developer" : "system",
197
+ content: sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(context.systemPrompt))
198
+ });
199
+ }
200
+ let msgIndex = 0;
201
+ for (const msg of transformedMessages) {
202
+ if (msg.role === "user") {
203
+ if (typeof msg.content === "string") {
204
+ messages.push({
205
+ role: "user",
206
+ content: [{
207
+ type: "input_text",
208
+ text: sanitizeTransportPayloadText(msg.content)
209
+ }]
210
+ });
211
+ } else {
212
+ const content = msg.content.map((item) => item.type === "text" ? {
213
+ type: "input_text",
214
+ text: sanitizeTransportPayloadText(item.text ?? "")
215
+ } : {
216
+ type: "input_image",
217
+ detail: "auto",
218
+ image_url: `data:${item.mimeType};base64,${item.data}`
219
+ }).filter((item) => model.input.includes("image") || item.type !== "input_image");
220
+ if (content.length > 0) {
221
+ messages.push({
222
+ role: "user",
223
+ content
224
+ });
225
+ }
226
+ }
227
+ } else if (msg.role === "assistant") {
228
+ const output = [];
229
+ const isDifferentModel = msg.model !== model.id && msg.provider === model.provider && msg.api === model.api;
230
+ for (const block of msg.content) {
231
+ if (block.type === "thinking") {
232
+ if (block.thinkingSignature) {
233
+ output.push(JSON.parse(block.thinkingSignature));
234
+ }
235
+ } else if (block.type === "text") {
236
+ let msgId = parseTextSignature(block.textSignature)?.id ?? `msg_${msgIndex}`;
237
+ if (msgId.length > 64) {
238
+ msgId = `msg_${shortHash(msgId)}`;
239
+ }
240
+ output.push({
241
+ type: "message",
242
+ role: "assistant",
243
+ content: [{
244
+ type: "output_text",
245
+ text: sanitizeTransportPayloadText(block.text),
246
+ annotations: []
247
+ }],
248
+ status: "completed",
249
+ id: msgId,
250
+ phase: parseTextSignature(block.textSignature)?.phase
251
+ });
252
+ } else if (block.type === "toolCall") {
253
+ const [callId, itemIdRaw] = block.id.split("|");
254
+ const itemId = isDifferentModel && itemIdRaw?.startsWith("fc_") ? undefined : itemIdRaw;
255
+ output.push({
256
+ type: "function_call",
257
+ id: itemId,
258
+ call_id: callId,
259
+ name: block.name,
260
+ arguments: JSON.stringify(block.arguments)
261
+ });
262
+ }
263
+ }
264
+ if (output.length > 0) {
265
+ messages.push(...output);
266
+ }
267
+ } else if (msg.role === "toolResult") {
268
+ const textResult = msg.content.filter((item) => item.type === "text").map((item) => item.text).join("\n");
269
+ const hasImages = msg.content.some((item) => item.type === "image");
270
+ const [callId] = msg.toolCallId.split("|");
271
+ messages.push({
272
+ type: "function_call_output",
273
+ call_id: callId,
274
+ output: hasImages && model.input.includes("image") ? [...textResult ? [{
275
+ type: "input_text",
276
+ text: sanitizeTransportPayloadText(textResult)
277
+ }] : [], ...msg.content.filter((item) => item.type === "image").map((item) => ({
278
+ type: "input_image",
279
+ detail: "auto",
280
+ image_url: `data:${item.mimeType};base64,${item.data}`
281
+ }))] : sanitizeTransportPayloadText(textResult || "(see attached image)")
282
+ });
283
+ }
284
+ msgIndex += 1;
285
+ }
286
+ return messages;
287
+ }
288
+ function convertResponsesTools(tools, options) {
289
+ const strict = resolveOpenAIStrictToolFlagForInventory(tools, options?.strict);
290
+ if (strict === undefined) {
291
+ return tools.map((tool) => ({
292
+ type: "function",
293
+ name: tool.name,
294
+ description: tool.description,
295
+ parameters: tool.parameters
296
+ }));
297
+ }
298
+ return tools.map((tool) => ({
299
+ type: "function",
300
+ name: tool.name,
301
+ description: tool.description,
302
+ parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict),
303
+ strict
304
+ }));
305
+ }
306
+ async function processResponsesStream(openaiStream, output, stream, model, options) {
307
+ let currentItem = null;
308
+ let currentBlock = null;
309
+ const blockIndex = () => output.content.length - 1;
310
+ for await (const rawEvent of openaiStream) {
311
+ const event = rawEvent;
312
+ const type = stringifyUnknown(event.type);
313
+ if (type === "response.created") {
314
+ output.responseId = stringifyUnknown(event.response?.id);
315
+ } else if (type === "response.output_item.added") {
316
+ const item = event.item;
317
+ if (item.type === "reasoning") {
318
+ currentItem = item;
319
+ currentBlock = {
320
+ type: "thinking",
321
+ thinking: ""
322
+ };
323
+ output.content.push(currentBlock);
324
+ stream.push({
325
+ type: "thinking_start",
326
+ contentIndex: blockIndex(),
327
+ partial: output
328
+ });
329
+ } else if (item.type === "message") {
330
+ currentItem = item;
331
+ currentBlock = {
332
+ type: "text",
333
+ text: ""
334
+ };
335
+ output.content.push(currentBlock);
336
+ stream.push({
337
+ type: "text_start",
338
+ contentIndex: blockIndex(),
339
+ partial: output
340
+ });
341
+ } else if (item.type === "function_call") {
342
+ currentItem = item;
343
+ currentBlock = {
344
+ type: "toolCall",
345
+ id: `${stringifyUnknown(item.call_id)}|${stringifyUnknown(item.id)}`,
346
+ name: stringifyUnknown(item.name),
347
+ arguments: {},
348
+ partialJson: stringifyJsonLike(item.arguments)
349
+ };
350
+ output.content.push(currentBlock);
351
+ stream.push({
352
+ type: "toolcall_start",
353
+ contentIndex: blockIndex(),
354
+ partial: output
355
+ });
356
+ }
357
+ } else if (type === "response.reasoning_summary_text.delta") {
358
+ if (currentItem?.type === "reasoning" && currentBlock?.type === "thinking") {
359
+ currentBlock.thinking = `${stringifyUnknown(currentBlock.thinking)}${stringifyUnknown(event.delta)}`;
360
+ stream.push({
361
+ type: "thinking_delta",
362
+ contentIndex: blockIndex(),
363
+ delta: stringifyUnknown(event.delta),
364
+ partial: output
365
+ });
366
+ }
367
+ } else if (type === "response.output_text.delta" || type === "response.refusal.delta") {
368
+ if (currentItem?.type === "message" && currentBlock?.type === "text") {
369
+ currentBlock.text = `${stringifyUnknown(currentBlock.text)}${stringifyUnknown(event.delta)}`;
370
+ stream.push({
371
+ type: "text_delta",
372
+ contentIndex: blockIndex(),
373
+ delta: stringifyUnknown(event.delta),
374
+ partial: output
375
+ });
376
+ }
377
+ } else if (type === "response.function_call_arguments.delta") {
378
+ if (currentItem?.type === "function_call" && currentBlock?.type === "toolCall") {
379
+ currentBlock.partialJson = `${stringifyJsonLike(currentBlock.partialJson)}${stringifyJsonLike(event.delta)}`;
380
+ currentBlock.arguments = parseStreamingJson(stringifyJsonLike(currentBlock.partialJson));
381
+ stream.push({
382
+ type: "toolcall_delta",
383
+ contentIndex: blockIndex(),
384
+ delta: stringifyJsonLike(event.delta),
385
+ partial: output
386
+ });
387
+ }
388
+ } else if (type === "response.output_item.done") {
389
+ const item = event.item;
390
+ if (item.type === "reasoning" && currentBlock?.type === "thinking") {
391
+ const summary = Array.isArray(item.summary) ? item.summary.map((part) => String(part.text ?? "")).join("\n\n") : "";
392
+ currentBlock.thinking = summary;
393
+ currentBlock.thinkingSignature = JSON.stringify(item);
394
+ stream.push({
395
+ type: "thinking_end",
396
+ contentIndex: blockIndex(),
397
+ content: stringifyUnknown(currentBlock.thinking),
398
+ partial: output
399
+ });
400
+ currentBlock = null;
401
+ } else if (item.type === "message" && currentBlock?.type === "text") {
402
+ const content = Array.isArray(item.content) ? item.content : [];
403
+ currentBlock.text = content.map((part) => part.type === "output_text" ? String(part.text ?? "") : String(part.refusal ?? "")).join("");
404
+ currentBlock.textSignature = encodeTextSignatureV1(stringifyUnknown(item.id), item.phase ?? undefined);
405
+ stream.push({
406
+ type: "text_end",
407
+ contentIndex: blockIndex(),
408
+ content: stringifyUnknown(currentBlock.text),
409
+ partial: output
410
+ });
411
+ currentBlock = null;
412
+ } else if (item.type === "function_call") {
413
+ const args = currentBlock?.type === "toolCall" && currentBlock.partialJson ? parseStreamingJson(stringifyJsonLike(currentBlock.partialJson, "{}")) : parseStreamingJson(stringifyJsonLike(item.arguments, "{}"));
414
+ stream.push({
415
+ type: "toolcall_end",
416
+ contentIndex: blockIndex(),
417
+ toolCall: {
418
+ type: "toolCall",
419
+ id: `${stringifyUnknown(item.call_id)}|${stringifyUnknown(item.id)}`,
420
+ name: stringifyUnknown(item.name),
421
+ arguments: args
422
+ },
423
+ partial: output
424
+ });
425
+ currentBlock = null;
426
+ }
427
+ } else if (type === "response.completed") {
428
+ const response = event.response;
429
+ if (typeof response?.id === "string") {
430
+ output.responseId = response.id;
431
+ }
432
+ const usage = response?.usage;
433
+ if (usage) {
434
+ const cachedTokens = usage.input_tokens_details?.cached_tokens || 0;
435
+ output.usage = {
436
+ input: (usage.input_tokens || 0) - cachedTokens,
437
+ output: usage.output_tokens || 0,
438
+ cacheRead: cachedTokens,
439
+ cacheWrite: 0,
440
+ totalTokens: usage.total_tokens || 0,
441
+ cost: {
442
+ input: 0,
443
+ output: 0,
444
+ cacheRead: 0,
445
+ cacheWrite: 0,
446
+ total: 0
447
+ }
448
+ };
449
+ }
450
+ calculateCost(model, output.usage);
451
+ if (options?.applyServiceTierPricing) {
452
+ options.applyServiceTierPricing(output.usage, response?.service_tier ?? options.serviceTier);
453
+ }
454
+ output.stopReason = mapResponsesStopReason(response?.status);
455
+ if (output.content.some((block) => block.type === "toolCall") && output.stopReason === "stop") {
456
+ output.stopReason = "toolUse";
457
+ }
458
+ } else if (type === "error") {
459
+ throw new Error(`Error Code ${stringifyUnknown(event.code, "unknown")}: ${stringifyUnknown(event.message, "Unknown error")}`);
460
+ } else if (type === "response.failed") {
461
+ const response = event.response;
462
+ const msg = response?.error ? `${response.error.code || "unknown"}: ${response.error.message || "no message"}` : response?.incomplete_details?.reason ? `incomplete: ${response.incomplete_details.reason}` : "Unknown error (no error details in response)";
463
+ throw new Error(msg);
464
+ }
465
+ }
466
+ }
467
+ function mapResponsesStopReason(status) {
468
+ if (!status) {
469
+ return "stop";
470
+ }
471
+ switch (status) {
472
+ case "completed": return "stop";
473
+ case "incomplete": return "length";
474
+ case "failed":
475
+ case "cancelled": return "error";
476
+ case "in_progress":
477
+ case "queued": return "stop";
478
+ default: throw new Error(`Unhandled stop reason: ${status}`);
479
+ }
480
+ }
481
+ function buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders) {
482
+ const headers = { ...model.headers };
483
+ if (model.provider === "github-copilot") {
484
+ Object.assign(headers, buildCopilotDynamicHeaders({
485
+ messages: context.messages,
486
+ hasImages: hasCopilotVisionInput(context.messages)
487
+ }));
488
+ }
489
+ if (optionHeaders) {
490
+ Object.assign(headers, optionHeaders);
491
+ }
492
+ if (turnHeaders) {
493
+ Object.assign(headers, turnHeaders);
494
+ }
495
+ return headers;
496
+ }
497
+ function resolveProviderTransportTurnState(model, params) {
498
+ return resolveProviderTransportTurnStateWithPlugin({
499
+ provider: model.provider,
500
+ context: {
501
+ provider: model.provider,
502
+ modelId: model.id,
503
+ model,
504
+ sessionId: params.sessionId,
505
+ turnId: params.turnId,
506
+ attempt: params.attempt,
507
+ transport: params.transport
508
+ }
509
+ });
510
+ }
511
+ function createOpenAIResponsesClient(model, context, apiKey, optionHeaders, turnHeaders) {
512
+ return createOpenAIStreamClient({
513
+ apiKey,
514
+ baseURL: model.baseUrl,
515
+ defaultHeaders: buildOpenAIClientHeaders(model, context, optionHeaders, turnHeaders),
516
+ fetch: buildGuardedModelFetch(model)
517
+ });
518
+ }
519
+ function createOpenAIResponsesTransportStreamFn() {
520
+ return (model, context, options) => {
521
+ const eventStream = createAssistantMessageEventStream();
522
+ const stream = eventStream;
523
+ void (async () => {
524
+ const output = {
525
+ role: "assistant",
526
+ content: [],
527
+ api: model.api,
528
+ provider: model.provider,
529
+ model: model.id,
530
+ usage: {
531
+ input: 0,
532
+ output: 0,
533
+ cacheRead: 0,
534
+ cacheWrite: 0,
535
+ totalTokens: 0,
536
+ cost: {
537
+ input: 0,
538
+ output: 0,
539
+ cacheRead: 0,
540
+ cacheWrite: 0,
541
+ total: 0
542
+ }
543
+ },
544
+ stopReason: "stop",
545
+ timestamp: Date.now()
546
+ };
547
+ try {
548
+ const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
549
+ const turnState = resolveProviderTransportTurnState(model, {
550
+ sessionId: options?.sessionId,
551
+ turnId: randomUUID(),
552
+ attempt: 1,
553
+ transport: "stream"
554
+ });
555
+ const client = createOpenAIResponsesClient(model, context, apiKey, options?.headers, turnState?.headers);
556
+ let params = buildOpenAIResponsesParams(model, context, options, turnState?.metadata);
557
+ const nextParams = await resolvePayloadOverride(options?.onPayload, params, model);
558
+ if (nextParams !== undefined) {
559
+ params = nextParams;
560
+ }
561
+ params = mergeTransportMetadata(params, turnState?.metadata);
562
+ const responseStream = await client.responses.create(params, options?.signal ? { signal: options.signal } : undefined);
563
+ stream.push({
564
+ type: "start",
565
+ partial: output
566
+ });
567
+ await processResponsesStream(responseStream, output, stream, model, {
568
+ serviceTier: options?.serviceTier,
569
+ applyServiceTierPricing
570
+ });
571
+ if (options?.signal?.aborted) {
572
+ throw new Error("Request was aborted");
573
+ }
574
+ if (output.stopReason === "aborted" || output.stopReason === "error") {
575
+ throw new Error("An unknown error occurred");
576
+ }
577
+ stream.push({
578
+ type: "done",
579
+ reason: output.stopReason,
580
+ message: output
581
+ });
582
+ stream.end();
583
+ } catch (error) {
584
+ output.stopReason = options?.signal?.aborted ? "aborted" : "error";
585
+ output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
586
+ stream.push({
587
+ type: "error",
588
+ reason: output.stopReason,
589
+ error: output
590
+ });
591
+ stream.end();
592
+ }
593
+ })();
594
+ return eventStream;
595
+ };
596
+ }
597
+ function resolveCacheRetention(cacheRetention) {
598
+ if (cacheRetention === "short" || cacheRetention === "long" || cacheRetention === "none") {
599
+ return cacheRetention;
600
+ }
601
+ if (typeof process !== "undefined" && process.env.PI_CACHE_RETENTION === "long") {
602
+ return "long";
603
+ }
604
+ return "short";
605
+ }
606
+ function getPromptCacheRetention(baseUrl, cacheRetention) {
607
+ if (cacheRetention !== "long") {
608
+ return undefined;
609
+ }
610
+ return baseUrl?.includes("api.openai.com") ? "24h" : undefined;
611
+ }
612
+ function buildOpenAIResponsesParams(model, context, options, metadata) {
613
+ const compat = getCompat(model);
614
+ const supportsDeveloperRole = typeof compat.supportsDeveloperRole === "boolean" ? compat.supportsDeveloperRole : undefined;
615
+ const messages = convertResponsesMessages(model, context, new Set([
616
+ "openai",
617
+ "openai-codex",
618
+ "opencode"
619
+ ]), { supportsDeveloperRole });
620
+ const cacheRetention = resolveCacheRetention(options?.cacheRetention);
621
+ const payloadPolicy = resolveOpenAIResponsesPayloadPolicy(model, { storeMode: "disable" });
622
+ const params = {
623
+ model: model.id,
624
+ input: messages,
625
+ stream: true,
626
+ prompt_cache_key: cacheRetention === "none" ? undefined : options?.sessionId,
627
+ prompt_cache_retention: getPromptCacheRetention(model.baseUrl, cacheRetention),
628
+ ...metadata ? { metadata } : {}
629
+ };
630
+ if (options?.maxTokens) {
631
+ params.max_output_tokens = options.maxTokens;
632
+ }
633
+ if (options?.temperature !== undefined) {
634
+ params.temperature = options.temperature;
635
+ }
636
+ if (options?.serviceTier !== undefined && payloadPolicy.allowsServiceTier) {
637
+ params.service_tier = options.serviceTier;
638
+ }
639
+ if (context.tools) {
640
+ params.tools = convertResponsesTools(context.tools, { strict: resolveOpenAIStrictToolSetting(model, { transport: "stream" }) });
641
+ }
642
+ const reasoningEffort = options?.reasoningEffort ?? options?.reasoning ?? (model.reasoning ? "high" : undefined);
643
+ if (model.reasoning) {
644
+ if (reasoningEffort || options?.reasoningSummary) {
645
+ params.reasoning = {
646
+ effort: reasoningEffort || "medium",
647
+ summary: options?.reasoningSummary || "auto"
648
+ };
649
+ params.include = ["reasoning.encrypted_content"];
650
+ } else if (model.provider !== "github-copilot") {
651
+ params.reasoning = { effort: "none" };
652
+ }
653
+ }
654
+ applyOpenAIResponsesPayloadPolicy(params, payloadPolicy);
655
+ return params;
656
+ }
657
+ function hasToolHistory(messages) {
658
+ return messages.some((message) => message.role === "toolResult" || message.role === "assistant" && message.content.some((block) => block.type === "toolCall"));
659
+ }
660
+ function createOpenAICompletionsClient(model, context, apiKey, optionHeaders) {
661
+ return createOpenAIStreamClient({
662
+ apiKey,
663
+ baseURL: model.baseUrl,
664
+ defaultHeaders: buildOpenAIClientHeaders(model, context, optionHeaders),
665
+ fetch: buildGuardedModelFetch(model)
666
+ });
667
+ }
668
+ function createOpenAICompletionsTransportStreamFn() {
669
+ return (model, context, options) => {
670
+ const eventStream = createAssistantMessageEventStream();
671
+ const stream = eventStream;
672
+ void (async () => {
673
+ const output = {
674
+ role: "assistant",
675
+ content: [],
676
+ api: model.api,
677
+ provider: model.provider,
678
+ model: model.id,
679
+ usage: {
680
+ input: 0,
681
+ output: 0,
682
+ cacheRead: 0,
683
+ cacheWrite: 0,
684
+ totalTokens: 0,
685
+ cost: {
686
+ input: 0,
687
+ output: 0,
688
+ cacheRead: 0,
689
+ cacheWrite: 0,
690
+ total: 0
691
+ }
692
+ },
693
+ stopReason: "stop",
694
+ timestamp: Date.now()
695
+ };
696
+ try {
697
+ const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
698
+ const client = createOpenAICompletionsClient(model, context, apiKey, options?.headers);
699
+ let params = buildOpenAICompletionsParams(model, context, options);
700
+ const nextParams = await resolvePayloadOverride(options?.onPayload, params, model);
701
+ if (nextParams !== undefined) {
702
+ params = nextParams;
703
+ }
704
+ const responseStream = await client.chat.completions.create(params, { signal: options?.signal });
705
+ stream.push({
706
+ type: "start",
707
+ partial: output
708
+ });
709
+ await processOpenAICompletionsStream(responseStream, output, model, stream);
710
+ if (options?.signal?.aborted) {
711
+ throw new Error("Request was aborted");
712
+ }
713
+ stream.push({
714
+ type: "done",
715
+ reason: output.stopReason,
716
+ message: output
717
+ });
718
+ stream.end();
719
+ } catch (error) {
720
+ output.stopReason = options?.signal?.aborted ? "aborted" : "error";
721
+ output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
722
+ stream.push({
723
+ type: "error",
724
+ reason: output.stopReason,
725
+ error: output
726
+ });
727
+ stream.end();
728
+ }
729
+ })();
730
+ return eventStream;
731
+ };
732
+ }
733
+ async function processOpenAICompletionsStream(responseStream, output, model, stream) {
734
+ let currentBlock = null;
735
+ const blockIndex = () => output.content.length - 1;
736
+ const finishCurrentBlock = () => {
737
+ if (!currentBlock) {
738
+ return;
739
+ }
740
+ if (currentBlock.type === "toolCall") {
741
+ currentBlock.arguments = parseStreamingJson(currentBlock.partialArgs);
742
+ const completed = {
743
+ ...currentBlock,
744
+ arguments: parseStreamingJson(currentBlock.partialArgs)
745
+ };
746
+ output.content[blockIndex()] = completed;
747
+ }
748
+ };
749
+ for await (const chunk of responseStream) {
750
+ output.responseId ||= chunk.id;
751
+ if (chunk.usage) {
752
+ output.usage = parseTransportChunkUsage(chunk.usage, model);
753
+ }
754
+ const choice = Array.isArray(chunk.choices) ? chunk.choices[0] : undefined;
755
+ if (!choice) {
756
+ continue;
757
+ }
758
+ const choiceUsage = choice.usage;
759
+ if (!chunk.usage && choiceUsage) {
760
+ output.usage = parseTransportChunkUsage(choiceUsage, model);
761
+ }
762
+ if (choice.finish_reason) {
763
+ const finishReasonResult = mapStopReason(choice.finish_reason);
764
+ output.stopReason = finishReasonResult.stopReason;
765
+ if (finishReasonResult.errorMessage) {
766
+ output.errorMessage = finishReasonResult.errorMessage;
767
+ }
768
+ }
769
+ if (!choice.delta) {
770
+ continue;
771
+ }
772
+ if (choice.delta.content) {
773
+ if (!currentBlock || currentBlock.type !== "text") {
774
+ finishCurrentBlock();
775
+ currentBlock = {
776
+ type: "text",
777
+ text: ""
778
+ };
779
+ output.content.push(currentBlock);
780
+ stream.push({
781
+ type: "text_start",
782
+ contentIndex: blockIndex(),
783
+ partial: output
784
+ });
785
+ }
786
+ currentBlock.text += choice.delta.content;
787
+ stream.push({
788
+ type: "text_delta",
789
+ contentIndex: blockIndex(),
790
+ delta: choice.delta.content,
791
+ partial: output
792
+ });
793
+ continue;
794
+ }
795
+ const reasoningFields = [
796
+ "reasoning_content",
797
+ "reasoning",
798
+ "reasoning_text"
799
+ ];
800
+ const reasoningField = reasoningFields.find((field) => {
801
+ const value = choice.delta[field];
802
+ return typeof value === "string" && value.length > 0;
803
+ });
804
+ if (reasoningField) {
805
+ if (!currentBlock || currentBlock.type !== "thinking") {
806
+ finishCurrentBlock();
807
+ currentBlock = {
808
+ type: "thinking",
809
+ thinking: "",
810
+ thinkingSignature: reasoningField
811
+ };
812
+ output.content.push(currentBlock);
813
+ stream.push({
814
+ type: "thinking_start",
815
+ contentIndex: blockIndex(),
816
+ partial: output
817
+ });
818
+ }
819
+ currentBlock.thinking += String(choice.delta[reasoningField]);
820
+ stream.push({
821
+ type: "thinking_delta",
822
+ contentIndex: blockIndex(),
823
+ delta: String(choice.delta[reasoningField]),
824
+ partial: output
825
+ });
826
+ continue;
827
+ }
828
+ if (choice.delta.tool_calls) {
829
+ for (const toolCall of choice.delta.tool_calls) {
830
+ if (!currentBlock || currentBlock.type !== "toolCall" || toolCall.id && currentBlock.id !== toolCall.id) {
831
+ finishCurrentBlock();
832
+ currentBlock = {
833
+ type: "toolCall",
834
+ id: toolCall.id || "",
835
+ name: toolCall.function?.name || "",
836
+ arguments: {},
837
+ partialArgs: ""
838
+ };
839
+ output.content.push(currentBlock);
840
+ stream.push({
841
+ type: "toolcall_start",
842
+ contentIndex: blockIndex(),
843
+ partial: output
844
+ });
845
+ }
846
+ if (currentBlock.type !== "toolCall") {
847
+ continue;
848
+ }
849
+ if (toolCall.id) {
850
+ currentBlock.id = toolCall.id;
851
+ }
852
+ if (toolCall.function?.name) {
853
+ currentBlock.name = toolCall.function.name;
854
+ }
855
+ if (toolCall.function?.arguments) {
856
+ currentBlock.partialArgs += toolCall.function.arguments;
857
+ currentBlock.arguments = parseStreamingJson(currentBlock.partialArgs);
858
+ stream.push({
859
+ type: "toolcall_delta",
860
+ contentIndex: blockIndex(),
861
+ delta: toolCall.function.arguments,
862
+ partial: output
863
+ });
864
+ }
865
+ }
866
+ }
867
+ }
868
+ finishCurrentBlock();
869
+ }
870
+ function detectCompat(model) {
871
+ const provider = model.provider;
872
+ const { capabilities, defaults: compatDefaults } = detectOpenAICompletionsCompat(model);
873
+ const endpointClass = capabilities.endpointClass;
874
+ const isDefaultRoute = endpointClass === "default";
875
+ const isMistral = capabilities.knownProviderFamily === "mistral" || endpointClass === "mistral-public" || isDefaultRoute && provider === "mistral";
876
+ const isVolcengine = provider === "volcengine" || provider === "volcengine-coding" || provider === "volcengine-plan";
877
+ const isBytePlus = provider === "byteplus" || provider === "byteplus-coding" || provider === "byteplus-plan";
878
+ const reasoningEffortMap = isMistral ? {
879
+ minimal: "none",
880
+ low: "none",
881
+ medium: "high",
882
+ high: "high",
883
+ xhigh: "high"
884
+ } : isVolcengine ? {
885
+ off: "minimal",
886
+ minimal: "minimal",
887
+ low: "low",
888
+ medium: "medium",
889
+ high: "high",
890
+ xhigh: "high"
891
+ } : {};
892
+ return {
893
+ supportsStore: compatDefaults.supportsStore,
894
+ supportsDeveloperRole: compatDefaults.supportsDeveloperRole,
895
+ supportsReasoningEffort: compatDefaults.supportsReasoningEffort,
896
+ reasoningEffortMap,
897
+ supportsUsageInStreaming: compatDefaults.supportsUsageInStreaming,
898
+ maxTokensField: compatDefaults.maxTokensField,
899
+ requiresToolResultName: false,
900
+ requiresAssistantAfterToolResult: false,
901
+ requiresThinkingAsText: false,
902
+ thinkingFormat: isBytePlus ? "modelark-thinking-type" : compatDefaults.thinkingFormat,
903
+ openRouterRouting: {},
904
+ vercelGatewayRouting: {},
905
+ supportsStrictMode: compatDefaults.supportsStrictMode
906
+ };
907
+ }
908
+ function getCompat(model) {
909
+ const detected = detectCompat(model);
910
+ const compat = model.compat ?? {};
911
+ const supportsStore = typeof compat.supportsStore === "boolean" ? compat.supportsStore : detected.supportsStore;
912
+ const supportsReasoningEffort = typeof compat.supportsReasoningEffort === "boolean" ? compat.supportsReasoningEffort : detected.supportsReasoningEffort;
913
+ return {
914
+ supportsStore,
915
+ supportsDeveloperRole: compat.supportsDeveloperRole ?? detected.supportsDeveloperRole,
916
+ supportsReasoningEffort,
917
+ reasoningEffortMap: compat.reasoningEffortMap ?? detected.reasoningEffortMap,
918
+ supportsUsageInStreaming: compat.supportsUsageInStreaming ?? detected.supportsUsageInStreaming,
919
+ maxTokensField: compat.maxTokensField ?? detected.maxTokensField,
920
+ requiresToolResultName: compat.requiresToolResultName ?? detected.requiresToolResultName,
921
+ requiresAssistantAfterToolResult: compat.requiresAssistantAfterToolResult ?? detected.requiresAssistantAfterToolResult,
922
+ requiresThinkingAsText: compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
923
+ thinkingFormat: compat.thinkingFormat ?? detected.thinkingFormat,
924
+ openRouterRouting: compat.openRouterRouting ?? {},
925
+ vercelGatewayRouting: compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,
926
+ supportsStrictMode: compat.supportsStrictMode ?? detected.supportsStrictMode
927
+ };
928
+ }
929
+ function mapReasoningEffort(effort, reasoningEffortMap) {
930
+ return reasoningEffortMap[effort] ?? effort;
931
+ }
932
+ function convertTools(tools, compat, model) {
933
+ const strict = resolveOpenAIStrictToolFlagForInventory(tools, resolveOpenAIStrictToolSetting(model, {
934
+ transport: "stream",
935
+ supportsStrictMode: compat?.supportsStrictMode
936
+ }));
937
+ return tools.map((tool) => ({
938
+ type: "function",
939
+ function: {
940
+ name: tool.name,
941
+ description: tool.description,
942
+ parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true),
943
+ ...strict === undefined ? {} : { strict }
944
+ }
945
+ }));
946
+ }
947
+ function buildOpenAICompletionsParams(model, context, options) {
948
+ const compat = getCompat(model);
949
+ const completionsContext = context.systemPrompt ? {
950
+ ...context,
951
+ systemPrompt: stripSystemPromptCacheBoundary(context.systemPrompt)
952
+ } : context;
953
+ const params = {
954
+ model: model.id,
955
+ messages: convertMessages(model, completionsContext, compat),
956
+ stream: true
957
+ };
958
+ if (compat.supportsUsageInStreaming) {
959
+ params.stream_options = { include_usage: true };
960
+ }
961
+ if (compat.supportsStore) {
962
+ params.store = false;
963
+ }
964
+ if (options?.maxTokens) {
965
+ if (compat.maxTokensField === "max_tokens") {
966
+ params.max_tokens = options.maxTokens;
967
+ } else {
968
+ params.max_completion_tokens = options.maxTokens;
969
+ }
970
+ }
971
+ if (options?.temperature !== undefined) {
972
+ params.temperature = options.temperature;
973
+ }
974
+ if (context.tools) {
975
+ params.tools = convertTools(context.tools, compat, model);
976
+ } else if (hasToolHistory(context.messages)) {
977
+ params.tools = [];
978
+ }
979
+ if (options?.toolChoice) {
980
+ params.tool_choice = options.toolChoice;
981
+ }
982
+ const reasoningEffort = options?.reasoningEffort ?? options?.reasoning ?? (model.reasoning ? "high" : undefined);
983
+ if (compat.thinkingFormat === "modelark-thinking-type" && model.reasoning && reasoningEffort) {
984
+ params.thinking = { type: reasoningEffort === "off" ? "disabled" : "enabled" };
985
+ } else if (compat.thinkingFormat === "openrouter" && model.reasoning && reasoningEffort) {
986
+ params.reasoning = { effort: mapReasoningEffort(reasoningEffort, compat.reasoningEffortMap) };
987
+ } else if (reasoningEffort && model.reasoning && compat.supportsReasoningEffort) {
988
+ params.reasoning_effort = mapReasoningEffort(reasoningEffort, compat.reasoningEffortMap);
989
+ }
990
+ return params;
991
+ }
992
+ function parseTransportChunkUsage(rawUsage, model) {
993
+ const cachedTokens = rawUsage.prompt_tokens_details?.cached_tokens || 0;
994
+ const promptTokens = rawUsage.prompt_tokens || 0;
995
+ const input = Math.max(0, promptTokens - cachedTokens);
996
+ const outputTokens = rawUsage.completion_tokens || 0;
997
+ const usage = {
998
+ input,
999
+ output: outputTokens,
1000
+ cacheRead: cachedTokens,
1001
+ cacheWrite: 0,
1002
+ totalTokens: input + outputTokens + cachedTokens,
1003
+ cost: {
1004
+ input: 0,
1005
+ output: 0,
1006
+ cacheRead: 0,
1007
+ cacheWrite: 0,
1008
+ total: 0
1009
+ }
1010
+ };
1011
+ calculateCost(model, usage);
1012
+ return usage;
1013
+ }
1014
+ function mapStopReason(reason) {
1015
+ if (reason === null) {
1016
+ return { stopReason: "stop" };
1017
+ }
1018
+ switch (reason) {
1019
+ case "stop":
1020
+ case "end": return { stopReason: "stop" };
1021
+ case "length": return { stopReason: "length" };
1022
+ case "function_call":
1023
+ case "tool_calls": return { stopReason: "toolUse" };
1024
+ case "content_filter": return {
1025
+ stopReason: "error",
1026
+ errorMessage: "Provider finish_reason: content_filter"
1027
+ };
1028
+ case "network_error": return {
1029
+ stopReason: "error",
1030
+ errorMessage: "Provider finish_reason: network_error"
1031
+ };
1032
+ default: return {
1033
+ stopReason: "error",
1034
+ errorMessage: `Provider finish_reason: ${reason}`
1035
+ };
1036
+ }
1037
+ }
1038
+
1039
+ //#endregion
1040
+ export { createOpenAICompletionsTransportStreamFn, createOpenAIResponsesTransportStreamFn };