@oscharko-dev/keiko 0.3.13 → 0.3.15

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 (232) hide show
  1. package/dist/ui/csp-hashes.json +6 -6
  2. package/dist/ui/static/404.html +1 -1
  3. package/dist/ui/static/__next.__PAGE__.txt +1 -1
  4. package/dist/ui/static/__next._full.txt +1 -1
  5. package/dist/ui/static/__next._head.txt +1 -1
  6. package/dist/ui/static/__next._index.txt +1 -1
  7. package/dist/ui/static/__next._tree.txt +1 -1
  8. package/dist/ui/static/_not-found/__next._full.txt +1 -1
  9. package/dist/ui/static/_not-found/__next._head.txt +1 -1
  10. package/dist/ui/static/_not-found/__next._index.txt +1 -1
  11. package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +1 -1
  12. package/dist/ui/static/_not-found/__next._not-found.txt +1 -1
  13. package/dist/ui/static/_not-found/__next._tree.txt +1 -1
  14. package/dist/ui/static/_not-found.html +1 -1
  15. package/dist/ui/static/_not-found.txt +1 -1
  16. package/dist/ui/static/atlassian-connectors/__next._full.txt +1 -1
  17. package/dist/ui/static/atlassian-connectors/__next._head.txt +1 -1
  18. package/dist/ui/static/atlassian-connectors/__next._index.txt +1 -1
  19. package/dist/ui/static/atlassian-connectors/__next._tree.txt +1 -1
  20. package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.__PAGE__.txt +1 -1
  21. package/dist/ui/static/atlassian-connectors/__next.atlassian-connectors.txt +1 -1
  22. package/dist/ui/static/atlassian-connectors.html +1 -1
  23. package/dist/ui/static/atlassian-connectors.txt +1 -1
  24. package/dist/ui/static/index.html +1 -1
  25. package/dist/ui/static/index.txt +1 -1
  26. package/dist/ui/static/launch/__next._full.txt +1 -1
  27. package/dist/ui/static/launch/__next._head.txt +1 -1
  28. package/dist/ui/static/launch/__next._index.txt +1 -1
  29. package/dist/ui/static/launch/__next._tree.txt +1 -1
  30. package/dist/ui/static/launch/__next.launch.__PAGE__.txt +1 -1
  31. package/dist/ui/static/launch/__next.launch.txt +1 -1
  32. package/dist/ui/static/launch.html +1 -1
  33. package/dist/ui/static/launch.txt +1 -1
  34. package/dist/ui/static/local-knowledge/__next._full.txt +1 -1
  35. package/dist/ui/static/local-knowledge/__next._head.txt +1 -1
  36. package/dist/ui/static/local-knowledge/__next._index.txt +1 -1
  37. package/dist/ui/static/local-knowledge/__next._tree.txt +1 -1
  38. package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +1 -1
  39. package/dist/ui/static/local-knowledge/__next.local-knowledge.txt +1 -1
  40. package/dist/ui/static/local-knowledge/capsule/__next._full.txt +1 -1
  41. package/dist/ui/static/local-knowledge/capsule/__next._head.txt +1 -1
  42. package/dist/ui/static/local-knowledge/capsule/__next._index.txt +1 -1
  43. package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +1 -1
  44. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +1 -1
  45. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.txt +1 -1
  46. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.txt +1 -1
  47. package/dist/ui/static/local-knowledge/capsule.html +1 -1
  48. package/dist/ui/static/local-knowledge/capsule.txt +1 -1
  49. package/dist/ui/static/local-knowledge.html +1 -1
  50. package/dist/ui/static/local-knowledge.txt +1 -1
  51. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.d.ts.map +1 -1
  52. package/node_modules/@oscharko-dev/keiko-cli/dist/ui.js +25 -6
  53. package/node_modules/@oscharko-dev/keiko-cli/package.json +13 -13
  54. package/node_modules/@oscharko-dev/keiko-connectors/package.json +3 -3
  55. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +2 -2
  56. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.js +2 -2
  57. package/node_modules/@oscharko-dev/keiko-contracts/package.json +1 -1
  58. package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
  59. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.d.ts +1 -1
  60. package/node_modules/@oscharko-dev/keiko-evidence/dist/version.js +1 -1
  61. package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
  62. package/node_modules/@oscharko-dev/keiko-git/package.json +1 -1
  63. package/node_modules/@oscharko-dev/keiko-harness/dist/version.d.ts +1 -1
  64. package/node_modules/@oscharko-dev/keiko-harness/dist/version.js +1 -1
  65. package/node_modules/@oscharko-dev/keiko-harness/package.json +6 -6
  66. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/connector-pod.d.ts +2 -0
  67. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/connector-pod.d.ts.map +1 -1
  68. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/connector-pod.js +1 -0
  69. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/index.d.ts +1 -0
  70. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/index.d.ts.map +1 -1
  71. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/index.js +3 -0
  72. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-batcher.d.ts +1 -0
  73. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-batcher.d.ts.map +1 -1
  74. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/embedding-batcher.js +341 -62
  75. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator.d.ts.map +1 -1
  76. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/orchestrator.js +586 -132
  77. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/types.d.ts +9 -0
  78. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/indexing/types.d.ts.map +1 -1
  79. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/knowledge-log.d.ts +20 -0
  80. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/knowledge-log.d.ts.map +1 -0
  81. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/knowledge-log.js +154 -0
  82. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/manual-pod-refresh.d.ts +2 -0
  83. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/manual-pod-refresh.d.ts.map +1 -1
  84. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/manual-pod-refresh.js +1 -0
  85. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/manual-pod.d.ts +2 -0
  86. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/manual-pod.d.ts.map +1 -1
  87. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/manual-pod.js +1 -0
  88. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/repository-pod.d.ts +2 -0
  89. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/repository-pod.d.ts.map +1 -1
  90. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/repository-pod.js +1 -0
  91. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.d.ts +2 -0
  92. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.d.ts.map +1 -1
  93. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/store.js +43 -1
  94. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.d.ts +1 -1
  95. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/version.js +1 -1
  96. package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
  97. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.d.ts +1 -1
  98. package/node_modules/@oscharko-dev/keiko-memory-capture/dist/version.js +1 -1
  99. package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
  100. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.d.ts +1 -1
  101. package/node_modules/@oscharko-dev/keiko-memory-consolidation/dist/version.js +1 -1
  102. package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
  103. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.d.ts +1 -1
  104. package/node_modules/@oscharko-dev/keiko-memory-governance/dist/version.js +1 -1
  105. package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
  106. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.d.ts +1 -1
  107. package/node_modules/@oscharko-dev/keiko-memory-retrieval/dist/version.js +1 -1
  108. package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
  109. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.d.ts +1 -1
  110. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/version.js +1 -1
  111. package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
  112. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts +15 -2
  113. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.d.ts.map +1 -1
  114. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/gateway.js +147 -15
  115. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.d.ts +3 -0
  116. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.d.ts.map +1 -1
  117. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/http.js +188 -23
  118. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.d.ts +27 -0
  119. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.d.ts.map +1 -0
  120. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/observability.js +180 -0
  121. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.d.ts +5 -0
  122. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.d.ts.map +1 -1
  123. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/openai-embedding-adapter.js +339 -55
  124. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts +18 -5
  125. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.d.ts.map +1 -1
  126. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/resilience.js +141 -26
  127. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.d.ts +1 -1
  128. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/version.js +1 -1
  129. package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +3 -3
  130. package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
  131. package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
  132. package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
  133. package/node_modules/@oscharko-dev/keiko-security/dist/version.d.ts +1 -1
  134. package/node_modules/@oscharko-dev/keiko-security/dist/version.js +1 -1
  135. package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
  136. package/node_modules/@oscharko-dev/keiko-server/dist/atlassian/syncService.d.ts.map +1 -1
  137. package/node_modules/@oscharko-dev/keiko-server/dist/atlassian/syncService.js +4 -0
  138. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.d.ts +1 -1
  139. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.d.ts.map +1 -1
  140. package/node_modules/@oscharko-dev/keiko-server/dist/bounded-request-body.js +51 -3
  141. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.d.ts.map +1 -1
  142. package/node_modules/@oscharko-dev/keiko-server/dist/diagnostics-log.js +77 -3
  143. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.d.ts.map +1 -1
  144. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-instance-cache.js +71 -11
  145. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.d.ts.map +1 -1
  146. package/node_modules/@oscharko-dev/keiko-server/dist/gateway-setup.js +9 -1
  147. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-qa.js +1 -1
  148. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.d.ts.map +1 -1
  149. package/node_modules/@oscharko-dev/keiko-server/dist/grounded-rerank-facade.js +37 -0
  150. package/node_modules/@oscharko-dev/keiko-server/dist/index.d.ts +1 -0
  151. package/node_modules/@oscharko-dev/keiko-server/dist/index.d.ts.map +1 -1
  152. package/node_modules/@oscharko-dev/keiko-server/dist/index.js +7 -0
  153. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-handlers.d.ts.map +1 -1
  154. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-handlers.js +158 -36
  155. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-remediation-store.d.ts.map +1 -1
  156. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-remediation-store.js +9 -1
  157. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-remediation.d.ts.map +1 -1
  158. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-remediation.js +10 -5
  159. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-store-open.d.ts.map +1 -1
  160. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-store-open.js +8 -2
  161. package/node_modules/@oscharko-dev/keiko-server/dist/manual/manual-pod-service.d.ts.map +1 -1
  162. package/node_modules/@oscharko-dev/keiko-server/dist/manual/manual-pod-service.js +3 -0
  163. package/node_modules/@oscharko-dev/keiko-server/dist/memory-embedding.d.ts.map +1 -1
  164. package/node_modules/@oscharko-dev/keiko-server/dist/memory-embedding.js +135 -36
  165. package/node_modules/@oscharko-dev/keiko-server/dist/observability/index.d.ts +3 -0
  166. package/node_modules/@oscharko-dev/keiko-server/dist/observability/index.d.ts.map +1 -0
  167. package/node_modules/@oscharko-dev/keiko-server/dist/observability/index.js +9 -0
  168. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-level.d.ts +13 -0
  169. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-level.d.ts.map +1 -0
  170. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-level.js +57 -0
  171. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.d.ts +20 -0
  172. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.d.ts.map +1 -0
  173. package/node_modules/@oscharko-dev/keiko-server/dist/observability/log-redaction.js +499 -0
  174. package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.d.ts +4 -0
  175. package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.d.ts.map +1 -0
  176. package/node_modules/@oscharko-dev/keiko-server/dist/observability/route-template.js +340 -0
  177. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-log.d.ts +49 -0
  178. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-log.d.ts.map +1 -0
  179. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-log.js +449 -0
  180. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-logger.d.ts +36 -0
  181. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-logger.d.ts.map +1 -0
  182. package/node_modules/@oscharko-dev/keiko-server/dist/observability/server-logger.js +190 -0
  183. package/node_modules/@oscharko-dev/keiko-server/dist/process-log-sink.d.ts +11 -0
  184. package/node_modules/@oscharko-dev/keiko-server/dist/process-log-sink.d.ts.map +1 -0
  185. package/node_modules/@oscharko-dev/keiko-server/dist/process-log-sink.js +48 -0
  186. package/node_modules/@oscharko-dev/keiko-server/dist/server.d.ts +2 -0
  187. package/node_modules/@oscharko-dev/keiko-server/dist/server.d.ts.map +1 -1
  188. package/node_modules/@oscharko-dev/keiko-server/dist/server.js +22 -4
  189. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.d.ts.map +1 -1
  190. package/node_modules/@oscharko-dev/keiko-server/dist/store-handlers.js +7 -2
  191. package/node_modules/@oscharko-dev/keiko-server/package.json +21 -21
  192. package/node_modules/@oscharko-dev/keiko-tools/dist/version.d.ts +1 -1
  193. package/node_modules/@oscharko-dev/keiko-tools/dist/version.js +1 -1
  194. package/node_modules/@oscharko-dev/keiko-tools/package.json +5 -5
  195. package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
  196. package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
  197. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.d.ts +1 -1
  198. package/node_modules/@oscharko-dev/keiko-workspace/dist/version.js +1 -1
  199. package/node_modules/@oscharko-dev/keiko-workspace/package.json +3 -3
  200. package/package.json +25 -25
  201. package/release-impact.catalog.json +117 -7
  202. package/vendor/{oscharko-dev-keiko-cli-0.3.13.tgz → oscharko-dev-keiko-cli-0.3.15.tgz} +0 -0
  203. package/vendor/{oscharko-dev-keiko-connectors-0.3.13.tgz → oscharko-dev-keiko-connectors-0.3.15.tgz} +0 -0
  204. package/vendor/{oscharko-dev-keiko-contracts-0.3.13.tgz → oscharko-dev-keiko-contracts-0.3.15.tgz} +0 -0
  205. package/vendor/{oscharko-dev-keiko-evaluations-0.3.13.tgz → oscharko-dev-keiko-evaluations-0.3.15.tgz} +0 -0
  206. package/vendor/{oscharko-dev-keiko-evidence-0.3.13.tgz → oscharko-dev-keiko-evidence-0.3.15.tgz} +0 -0
  207. package/vendor/{oscharko-dev-keiko-git-0.3.13.tgz → oscharko-dev-keiko-git-0.3.15.tgz} +0 -0
  208. package/vendor/{oscharko-dev-keiko-harness-0.3.13.tgz → oscharko-dev-keiko-harness-0.3.15.tgz} +0 -0
  209. package/vendor/oscharko-dev-keiko-local-knowledge-0.3.15.tgz +0 -0
  210. package/vendor/{oscharko-dev-keiko-memory-capture-0.3.13.tgz → oscharko-dev-keiko-memory-capture-0.3.15.tgz} +0 -0
  211. package/vendor/{oscharko-dev-keiko-memory-consolidation-0.3.13.tgz → oscharko-dev-keiko-memory-consolidation-0.3.15.tgz} +0 -0
  212. package/vendor/oscharko-dev-keiko-memory-governance-0.3.15.tgz +0 -0
  213. package/vendor/{oscharko-dev-keiko-memory-retrieval-0.3.13.tgz → oscharko-dev-keiko-memory-retrieval-0.3.15.tgz} +0 -0
  214. package/vendor/{oscharko-dev-keiko-memory-vault-0.3.13.tgz → oscharko-dev-keiko-memory-vault-0.3.15.tgz} +0 -0
  215. package/vendor/oscharko-dev-keiko-model-gateway-0.3.15.tgz +0 -0
  216. package/vendor/{oscharko-dev-keiko-quality-intelligence-0.3.13.tgz → oscharko-dev-keiko-quality-intelligence-0.3.15.tgz} +0 -0
  217. package/vendor/{oscharko-dev-keiko-sandbox-0.3.13.tgz → oscharko-dev-keiko-sandbox-0.3.15.tgz} +0 -0
  218. package/vendor/oscharko-dev-keiko-sdk-0.3.15.tgz +0 -0
  219. package/vendor/{oscharko-dev-keiko-security-0.3.13.tgz → oscharko-dev-keiko-security-0.3.15.tgz} +0 -0
  220. package/vendor/oscharko-dev-keiko-server-0.3.15.tgz +0 -0
  221. package/vendor/{oscharko-dev-keiko-tools-0.3.13.tgz → oscharko-dev-keiko-tools-0.3.15.tgz} +0 -0
  222. package/vendor/{oscharko-dev-keiko-verification-0.3.13.tgz → oscharko-dev-keiko-verification-0.3.15.tgz} +0 -0
  223. package/vendor/{oscharko-dev-keiko-workflows-0.3.13.tgz → oscharko-dev-keiko-workflows-0.3.15.tgz} +0 -0
  224. package/vendor/{oscharko-dev-keiko-workspace-0.3.13.tgz → oscharko-dev-keiko-workspace-0.3.15.tgz} +0 -0
  225. package/vendor/oscharko-dev-keiko-local-knowledge-0.3.13.tgz +0 -0
  226. package/vendor/oscharko-dev-keiko-memory-governance-0.3.13.tgz +0 -0
  227. package/vendor/oscharko-dev-keiko-model-gateway-0.3.13.tgz +0 -0
  228. package/vendor/oscharko-dev-keiko-sdk-0.3.13.tgz +0 -0
  229. package/vendor/oscharko-dev-keiko-server-0.3.13.tgz +0 -0
  230. /package/dist/ui/static/_next/static/{iwhpaHGb663ka5R3lhZBj → 4j3JDaPBERRu_ZIgeR1VQ}/_buildManifest.js +0 -0
  231. /package/dist/ui/static/_next/static/{iwhpaHGb663ka5R3lhZBj → 4j3JDaPBERRu_ZIgeR1VQ}/_clientMiddlewareManifest.js +0 -0
  232. /package/dist/ui/static/_next/static/{iwhpaHGb663ka5R3lhZBj → 4j3JDaPBERRu_ZIgeR1VQ}/_ssgManifest.js +0 -0
@@ -3,6 +3,36 @@
3
3
  // information; the raw provider body never escapes this module.
4
4
  import { apiKeyHeaderValue, trimTrailingSlash } from "./config.js";
5
5
  import { gatewayFetch, OutboundHttpEgressError, readJsonCapped, } from "./http.js";
6
+ import { logEndpointHost, logLevelEnabled, logTimer, resolveLogSink, withCorrelationId, } from "./observability.js";
7
+ // The wire default for one embedding request, shared by the scalar path, the array path, the
8
+ // per-item fallback and the ladder budget. Named rather than repeated so the attempt line's
9
+ // `timeoutMs` cannot report a deadline the request is not actually running under.
10
+ const DEFAULT_EMBEDDING_TIMEOUT_MS = 30_000;
11
+ // The compatibility ladder in this module is a chain of SILENT degradations: extras dropped,
12
+ // array shape abandoned, per-item fallback, endpoint strictness memoized for the process
13
+ // lifetime. Each rung changes throughput by an order of magnitude and none of them surfaces to
14
+ // the caller, which is exactly how the 0.3.11/0.3.13 field incidents presented — indexing that
15
+ // spun for hours with no error to point at. Every rung below therefore emits one line naming the
16
+ // branch, the input count, and the outcome. Never the inputs themselves.
17
+ function embeddingEvent(level, op, extra, status, errorKind) {
18
+ return { level, category: "embedding", op, status, errorKind, extra };
19
+ }
20
+ // The sink every line in this module is written through, with the caller's correlation id bound
21
+ // to it (see `withCorrelationId`). Resolved from the request at each entry point rather than
22
+ // threaded as a parameter because the compatibility ladder re-enters itself — a batch degrades to
23
+ // the scalar path, which retries in the minimal shape — and each rung starts from the request it
24
+ // was handed. Binding the id here is what makes the whole ladder for ONE batch greppable as a
25
+ // single sequence while N other batches interleave with it in the same file.
26
+ function embeddingLog(request) {
27
+ return withCorrelationId(resolveLogSink(request.log), request.logContext?.correlationId);
28
+ }
29
+ // `info`, not `debug`: a line that only appears once the operator has already reproduced the hang
30
+ // under a raised threshold is not evidence of the hang.
31
+ function logDispatch(log, op, fields) {
32
+ if (!logLevelEnabled(log, "info"))
33
+ return;
34
+ log.write(embeddingEvent("info", op, { ...fields }));
35
+ }
6
36
  const OUTBOUND_EMBEDDING_KINDS = {
7
37
  PROXY_UNREACHABLE: "proxy-unreachable",
8
38
  PROXY_AUTH_REQUIRED: "proxy-auth-required",
@@ -127,7 +157,7 @@ function buildRequest(request, minimalShape = false) {
127
157
  ...(minimalShape ? {} : { encoding_format: "float" }),
128
158
  ...(request.dimensions !== undefined ? { dimensions: request.dimensions } : {}),
129
159
  });
130
- const timeoutSignal = AbortSignal.timeout(request.timeoutMs ?? 30_000);
160
+ const timeoutSignal = AbortSignal.timeout(request.timeoutMs ?? DEFAULT_EMBEDDING_TIMEOUT_MS);
131
161
  const signal = request.signal !== undefined ? AbortSignal.any([timeoutSignal, request.signal]) : timeoutSignal;
132
162
  return {
133
163
  url: joinUrl(request),
@@ -138,6 +168,18 @@ function buildRequest(request, minimalShape = false) {
138
168
  callerSignal: request.signal,
139
169
  };
140
170
  }
171
+ // One attempt line for a SCALAR request, emitted before the socket work starts. Shared by the
172
+ // first-try path and the minimal-shape retry so neither can hang without leaving a record.
173
+ function logScalarDispatch(log, request, built, minimalShape) {
174
+ logDispatch(log, "embedding.request.dispatch", {
175
+ endpoint: logEndpointHost(request.endpoint),
176
+ modelId: request.modelId,
177
+ inputCount: 1,
178
+ bodyBytes: Buffer.byteLength(built.body, "utf8"),
179
+ timeoutMs: request.timeoutMs ?? DEFAULT_EMBEDDING_TIMEOUT_MS,
180
+ minimalShape,
181
+ });
182
+ }
141
183
  async function discardBody(response) {
142
184
  try {
143
185
  await readJsonCapped(response);
@@ -146,13 +188,14 @@ async function discardBody(response) {
146
188
  // ignore — body discarded intentionally
147
189
  }
148
190
  }
149
- async function dispatch(built, fetchImpl, egress) {
191
+ async function dispatch(built, fetchImpl, egress, log) {
150
192
  try {
151
193
  return await gatewayFetch(built.url, {
152
194
  method: "POST",
153
195
  headers: built.headers,
154
196
  body: built.body,
155
197
  signal: built.signal,
198
+ log,
156
199
  ...(fetchImpl !== undefined ? { fetchImpl } : {}),
157
200
  ...(egress !== undefined ? { egress } : {}),
158
201
  });
@@ -181,22 +224,39 @@ async function decodeSuccess(response, request) {
181
224
  return { ok: true, value };
182
225
  }
183
226
  export async function requestOpenAIEmbedding(request) {
184
- const built = buildRequest(request, strictShapeEndpoints.has(request.endpoint));
185
- const dispatched = await dispatch(built, request.fetchImpl, request.egress);
227
+ const log = embeddingLog(request);
228
+ const endpoint = logEndpointHost(request.endpoint);
229
+ // Captured for the log field only; the post-await check below deliberately stays a LIVE read of
230
+ // the memo, exactly as before, so a concurrent call that learned the endpoint is strict is seen.
231
+ const minimalShape = strictShapeEndpoints.has(request.endpoint);
232
+ const built = buildRequest(request, minimalShape);
233
+ logScalarDispatch(log, request, built, minimalShape);
234
+ const dispatched = await dispatch(built, request.fetchImpl, request.egress, log);
186
235
  if (typeof dispatched === "string") {
236
+ log.write(embeddingEvent("warn", "embedding.request.failed", { endpoint, minimalShape }, undefined, dispatched));
187
237
  return { ok: false, kind: dispatched };
188
238
  }
189
239
  if (!dispatched.ok) {
190
- await discardBody(dispatched);
191
- if (isStrictGatewayRejection(dispatched.status) &&
192
- !strictShapeEndpoints.has(request.endpoint)) {
193
- return await requestMinimalShapeEmbedding(request);
194
- }
195
- const kind = classifyStatus(dispatched.status) ?? "transport";
196
- return { ok: false, kind, status: dispatched.status };
240
+ return await handleScalarErrorResponse(request, dispatched, log, minimalShape);
197
241
  }
198
242
  return decodeSuccess(dispatched, request);
199
243
  }
244
+ // The error-status rungs of the scalar ladder, split out of `requestOpenAIEmbedding` so both
245
+ // halves stay inside the function-length budget with their decision lines attached — the same
246
+ // shape `handleBatchErrorResponse` already gives the array path.
247
+ async function handleScalarErrorResponse(request, dispatched, log, minimalShape) {
248
+ const endpoint = logEndpointHost(request.endpoint);
249
+ await discardBody(dispatched);
250
+ // A LIVE read of the memo, exactly as before: a concurrent call that learned this endpoint is
251
+ // strict while we were awaiting must be seen here.
252
+ if (isStrictGatewayRejection(dispatched.status) && !strictShapeEndpoints.has(request.endpoint)) {
253
+ log.write(embeddingEvent("warn", "embedding.request.minimal-shape-retry", { endpoint, reason: "strict-gateway-rejection" }, dispatched.status));
254
+ return await requestMinimalShapeEmbedding(request);
255
+ }
256
+ const kind = classifyStatus(dispatched.status) ?? "transport";
257
+ log.write(embeddingEvent("warn", "embedding.request.failed", { endpoint, minimalShape }, dispatched.status, kind));
258
+ return { ok: false, kind, status: dispatched.status };
259
+ }
200
260
  // A validation-shaped rejection (400/422) of a request that carried our optional extras: the
201
261
  // endpoint ANSWERED, so this is not transport flakiness — retry exactly once in the minimal
202
262
  // wire shape a plain curl would send. 401/403/404/429/5xx keep their existing semantics.
@@ -215,9 +275,13 @@ export function resetStrictGatewayMemoForTests() {
215
275
  arrayRejectingEndpoints.clear();
216
276
  }
217
277
  async function requestMinimalShapeEmbedding(request) {
278
+ const log = embeddingLog(request);
279
+ const endpoint = logEndpointHost(request.endpoint);
218
280
  const built = buildRequest(request, true);
219
- const dispatched = await dispatch(built, request.fetchImpl, request.egress);
281
+ logScalarDispatch(log, request, built, true);
282
+ const dispatched = await dispatch(built, request.fetchImpl, request.egress, log);
220
283
  if (typeof dispatched === "string") {
284
+ log.write(embeddingEvent("warn", "embedding.request.minimal-shape-failed", { endpoint }, undefined, dispatched));
221
285
  return { ok: false, kind: dispatched };
222
286
  }
223
287
  if (!dispatched.ok) {
@@ -225,9 +289,12 @@ async function requestMinimalShapeEmbedding(request) {
225
289
  // status) would surface a contradiction in operator-visible readiness diagnostics.
226
290
  const kind = classifyStatus(dispatched.status) ?? "transport";
227
291
  await discardBody(dispatched);
292
+ log.write(embeddingEvent("warn", "embedding.request.minimal-shape-failed", { endpoint }, dispatched.status, kind));
228
293
  return { ok: false, kind, status: dispatched.status };
229
294
  }
295
+ // Process-lifetime memo: from here on every request to this endpoint SKIPS the extras rung.
230
296
  strictShapeEndpoints.add(request.endpoint);
297
+ log.write(embeddingEvent("info", "embedding.endpoint.strict-shape-memoized", { endpoint }));
231
298
  return decodeSuccess(dispatched, request);
232
299
  }
233
300
  // ─── Array-batch transport (#189 GRD-004) ────────────────────────────────────
@@ -245,7 +312,7 @@ function buildBatchRequest(request, minimalShape = false) {
245
312
  ...(minimalShape ? {} : { encoding_format: "float" }),
246
313
  ...(request.dimensions !== undefined ? { dimensions: request.dimensions } : {}),
247
314
  });
248
- const timeoutSignal = AbortSignal.timeout(request.timeoutMs ?? 30_000);
315
+ const timeoutSignal = AbortSignal.timeout(request.timeoutMs ?? DEFAULT_EMBEDDING_TIMEOUT_MS);
249
316
  const signal = request.signal !== undefined ? AbortSignal.any([timeoutSignal, request.signal]) : timeoutSignal;
250
317
  return {
251
318
  url: joinUrl(request),
@@ -256,6 +323,18 @@ function buildBatchRequest(request, minimalShape = false) {
256
323
  callerSignal: request.signal,
257
324
  };
258
325
  }
326
+ // Attempt line for an ARRAY request. This is the call the 0.3.13 incident hung inside: 36 inputs,
327
+ // one request, nineteen seconds, no vectors and nothing written until it returned.
328
+ function logBatchDispatch(log, request, built, minimalShape) {
329
+ logDispatch(log, "embedding.batch.dispatch", {
330
+ endpoint: logEndpointHost(request.endpoint),
331
+ modelId: request.modelId,
332
+ inputCount: request.inputs.length,
333
+ bodyBytes: Buffer.byteLength(built.body, "utf8"),
334
+ timeoutMs: request.timeoutMs ?? DEFAULT_EMBEDDING_TIMEOUT_MS,
335
+ minimalShape,
336
+ });
337
+ }
259
338
  // Resolve the slot index for one `data[]` entry, or -1 if its index is missing, non-integer,
260
339
  // out of range, or already filled (duplicate).
261
340
  function batchSlotIndex(item, count, slots) {
@@ -294,37 +373,125 @@ function buildBatchContext(payload, request) {
294
373
  requestModelId: request.modelId,
295
374
  };
296
375
  }
376
+ // "invalid-response" is returned from five structurally different rejections and the caller
377
+ // cannot tell them apart — a truncated body, a provider that ignored the array, and a duplicate
378
+ // `index` are three different bugs with three different owners. The reason label is the only
379
+ // place that distinction survives; the body itself is never read into the line.
380
+ function invalidBatchResponse(log, request, reason) {
381
+ log.write(embeddingEvent("warn", "embedding.batch.invalid-response", {
382
+ endpoint: logEndpointHost(request.endpoint),
383
+ reason,
384
+ inputCount: request.inputs.length,
385
+ }));
386
+ return { ok: false, kind: "invalid-response" };
387
+ }
297
388
  async function decodeBatchSuccess(response, request) {
389
+ const log = embeddingLog(request);
298
390
  let payload;
299
391
  try {
300
392
  payload = await readJsonCapped(response);
301
393
  }
302
394
  catch {
303
- return { ok: false, kind: "invalid-response" };
395
+ return invalidBatchResponse(log, request, "body-unreadable");
304
396
  }
305
397
  if (!isRecord(payload) || !Array.isArray(payload.data)) {
306
- return { ok: false, kind: "invalid-response" };
398
+ return invalidBatchResponse(log, request, "no-data-array");
307
399
  }
308
400
  const ctx = buildBatchContext(payload, request);
309
401
  if (payload.data.length !== ctx.count) {
310
- return { ok: false, kind: "invalid-response" };
402
+ return invalidBatchResponse(log, request, "item-count-mismatch");
311
403
  }
312
404
  // Place each item at its declared `index` so the result is strictly aligned to `inputs`
313
405
  // regardless of provider ordering. Any missing/duplicate/out-of-range index → invalid.
314
406
  const slots = new Array(ctx.count);
315
407
  for (const item of payload.data) {
316
408
  if (!placeBatchItem(item, ctx, slots)) {
317
- return { ok: false, kind: "invalid-response" };
409
+ return invalidBatchResponse(log, request, "malformed-item");
318
410
  }
319
411
  }
320
412
  const value = [];
321
413
  for (const slot of slots) {
322
414
  if (slot === undefined)
323
- return { ok: false, kind: "invalid-response" };
415
+ return invalidBatchResponse(log, request, "unfilled-slot");
324
416
  value.push(slot);
325
417
  }
326
418
  return { ok: true, value };
327
419
  }
420
+ // A batch failure that is NOT a clean shape rejection is not proof the gateway is down.
421
+ // Field incident (0.3.13, self-hosted LiteLLM): the route answered ONE input in 0.2s and the
422
+ // SAME 36 inputs as an array with HTTP 500 after 19s. Degrading only on 400/422 left the
423
+ // batcher retrying the identical doomed array — every attempt paid the full 19s, wrote zero
424
+ // vectors, and surfaced no error, which is indistinguishable from a hang. One scalar attempt
425
+ // decides it: if the items embed one at a time, the ARRAY SHAPE is what this gateway cannot
426
+ // serve, and the endpoint is remembered exactly like an explicitly rejecting one. If the
427
+ // scalar attempt fails too, the gateway really is unavailable and the ORIGINAL failure is
428
+ // returned unchanged — a genuine outage is never dressed up as a shape problem.
429
+ // Why the scalar probe was NOT attempted. A caller-cancelled batch must not fire N more
430
+ // requests, a single-item batch has no array shape to blame, and an exhausted budget has no room
431
+ // left to probe. The signal is checked in ADDITION to the kind: a cancellation that lands after
432
+ // the gateway already answered — while the failed body is being drained — never reaches the
433
+ // error classifier, so the failure still reads "http-error" while the caller is long gone.
434
+ function degradeSkipReason(request, failure, deadlineAt) {
435
+ if (failure.kind === "cancelled")
436
+ return "failure-was-cancellation";
437
+ if (request.signal?.aborted === true)
438
+ return "caller-aborted";
439
+ if (request.inputs.length <= 1)
440
+ return "single-item-batch";
441
+ if (Date.now() >= deadlineAt)
442
+ return "ladder-deadline-expired";
443
+ return undefined;
444
+ }
445
+ function embeddedCount(outcome) {
446
+ return outcome.ok ? outcome.value.length : (outcome.partial ?? []).length;
447
+ }
448
+ // Binds the ORIGINAL batch failure's status and kind to every line the degradation ladder emits,
449
+ // so each step stays attributable to the failure that triggered it rather than to the probe.
450
+ function degradeLogger(log, failure) {
451
+ return (op, extra) => {
452
+ log.write(embeddingEvent("warn", op, extra, failure.status, failure.kind));
453
+ };
454
+ }
455
+ async function degradeToScalarAfterBatchFailure(request, deadlineAt, failure) {
456
+ const log = embeddingLog(request);
457
+ const note = degradeLogger(log, failure);
458
+ const endpoint = logEndpointHost(request.endpoint);
459
+ const inputCount = request.inputs.length;
460
+ const skipReason = degradeSkipReason(request, failure, deadlineAt);
461
+ if (skipReason !== undefined) {
462
+ note("embedding.batch.degrade-skipped", { endpoint, inputCount, reason: skipReason });
463
+ return failure;
464
+ }
465
+ note("embedding.batch.degrading-to-scalar", { endpoint, inputCount });
466
+ const scalar = await requestScalarFallbackBatch(request, deadlineAt);
467
+ // Partial progress is the same evidence as full success: items DID embed one at a time, so
468
+ // the array shape is the problem. Returning the scalar outcome also keeps the completed
469
+ // prefix the batcher resumes behind.
470
+ if (!scalar.ok && embeddedCount(scalar) === 0) {
471
+ note("embedding.batch.degrade-inconclusive", {
472
+ endpoint,
473
+ inputCount,
474
+ reason: "scalar-probe-also-failed",
475
+ });
476
+ return failure;
477
+ }
478
+ // A THROTTLED batch is the one failure that says nothing about the shape: "try again later"
479
+ // is not "arrays are unsupported", and a large request can trip a limit the same request
480
+ // clears a minute later. Memoizing it would turn a passing rate limit into a
481
+ // process-lifetime degradation, so this batch is served item by item and the next one is
482
+ // free to try the array again.
483
+ const memoized = failure.kind !== "rate-limited";
484
+ if (memoized) {
485
+ arrayRejectingEndpoints.add(request.endpoint);
486
+ }
487
+ note("embedding.batch.degraded-to-scalar", {
488
+ endpoint,
489
+ inputCount,
490
+ memoized,
491
+ embedded: embeddedCount(scalar),
492
+ });
493
+ return scalar;
494
+ }
328
495
  export async function requestOpenAIEmbeddingBatch(request) {
329
496
  if (request.inputs.length === 0) {
330
497
  return { ok: true, value: [] };
@@ -335,56 +502,116 @@ export async function requestOpenAIEmbeddingBatch(request) {
335
502
  // mid-batch, the batcher classifies the timeout as transient, retries DISCARD the partial
336
503
  // progress, and indexing spins for hours without an error. Per item the budget stays the
337
504
  // request timeout; the sum is capped at 15 minutes as the runaway backstop.
338
- const deadlineAt = Date.now() + ladderDeadlineMs(request.inputs.length, request.timeoutMs);
505
+ const log = embeddingLog(request);
506
+ const endpoint = logEndpointHost(request.endpoint);
507
+ const inputCount = request.inputs.length;
508
+ const deadlineAt = Date.now() + ladderDeadlineMs(inputCount, request.timeoutMs);
339
509
  if (arrayRejectingEndpoints.has(request.endpoint)) {
510
+ // The memo means this process already proved the array shape unusable here: every batch from
511
+ // now on costs N round-trips instead of one, which is the throughput cliff an operator
512
+ // chasing "indexing got slow after a restart" needs to see named.
513
+ log.write(embeddingEvent("info", "embedding.batch.scalar-memo-hit", { endpoint, inputCount }));
340
514
  return await requestScalarFallbackBatch(request, deadlineAt);
341
515
  }
342
- const built = buildBatchRequest(request, strictShapeEndpoints.has(request.endpoint));
343
- const dispatched = await dispatch(built, request.fetchImpl, request.egress);
516
+ const minimalShape = strictShapeEndpoints.has(request.endpoint);
517
+ const built = buildBatchRequest(request, minimalShape);
518
+ logBatchDispatch(log, request, built, minimalShape);
519
+ const dispatched = await dispatch(built, request.fetchImpl, request.egress, log);
344
520
  if (typeof dispatched === "string") {
345
- return { ok: false, kind: dispatched };
521
+ return await degradeToScalarAfterBatchFailure(request, deadlineAt, {
522
+ ok: false,
523
+ kind: dispatched,
524
+ });
346
525
  }
347
526
  if (!dispatched.ok) {
348
- await discardBody(dispatched);
349
- if (isStrictGatewayRejection(dispatched.status) &&
350
- !strictShapeEndpoints.has(request.endpoint)) {
351
- return await requestMinimalShapeEmbeddingBatch(request, deadlineAt);
352
- }
353
- if (isStrictGatewayRejection(dispatched.status)) {
354
- // Known strict-shape endpoint that STILL rejects the minimal array: the array shape
355
- // itself is unsupported — degrade to scalars and remember.
356
- arrayRejectingEndpoints.add(request.endpoint);
357
- return await requestScalarFallbackBatch(request, deadlineAt);
358
- }
359
- const kind = classifyStatus(dispatched.status) ?? "transport";
360
- return { ok: false, kind, status: dispatched.status };
527
+ return await handleBatchErrorResponse(request, deadlineAt, dispatched, log);
361
528
  }
362
529
  return decodeBatchSuccess(dispatched, request);
363
530
  }
531
+ // The error-status rungs of the batch ladder, split out of `requestOpenAIEmbeddingBatch` so both
532
+ // halves stay inside the complexity budget with their decision lines attached.
533
+ async function handleBatchErrorResponse(request, deadlineAt, dispatched, log) {
534
+ await discardBody(dispatched);
535
+ const endpoint = logEndpointHost(request.endpoint);
536
+ const inputCount = request.inputs.length;
537
+ const strictRejection = isStrictGatewayRejection(dispatched.status);
538
+ if (strictRejection && !strictShapeEndpoints.has(request.endpoint)) {
539
+ log.write(embeddingEvent("warn", "embedding.batch.minimal-shape-retry", { endpoint, inputCount, reason: "strict-gateway-rejection" }, dispatched.status));
540
+ return await requestMinimalShapeEmbeddingBatch(request, deadlineAt);
541
+ }
542
+ if (strictRejection) {
543
+ // Known strict-shape endpoint that STILL rejects the minimal array: the array shape
544
+ // itself is unsupported — degrade to scalars and remember.
545
+ return await degradeToScalarsForArrayRejectingEndpoint(request, deadlineAt, dispatched.status, log);
546
+ }
547
+ const kind = classifyStatus(dispatched.status) ?? "transport";
548
+ return await degradeToScalarAfterBatchFailure(request, deadlineAt, {
549
+ ok: false,
550
+ kind,
551
+ status: dispatched.status,
552
+ });
553
+ }
364
554
  // Batch compat ladder for strict gateways: first the same array request without the optional
365
555
  // extras; if the endpoint rejects the ARRAY shape itself, degrade to per-item scalar requests
366
556
  // (each of which carries its own minimal-shape retry). The first failing item fails the batch.
367
557
  async function requestMinimalShapeEmbeddingBatch(request, deadlineAt) {
558
+ const log = embeddingLog(request);
559
+ const endpoint = logEndpointHost(request.endpoint);
368
560
  const built = buildBatchRequest(request, true);
369
- const dispatched = await dispatch(built, request.fetchImpl, request.egress);
561
+ logBatchDispatch(log, request, built, true);
562
+ const dispatched = await dispatch(built, request.fetchImpl, request.egress, log);
370
563
  if (typeof dispatched === "string") {
371
- return { ok: false, kind: dispatched };
564
+ return await degradeToScalarAfterBatchFailure(request, deadlineAt, {
565
+ ok: false,
566
+ kind: dispatched,
567
+ });
372
568
  }
373
569
  if (dispatched.ok) {
374
570
  strictShapeEndpoints.add(request.endpoint);
571
+ log.write(embeddingEvent("info", "embedding.endpoint.strict-shape-memoized", { endpoint }));
375
572
  return decodeBatchSuccess(dispatched, request);
376
573
  }
377
574
  await discardBody(dispatched);
378
575
  if (!isStrictGatewayRejection(dispatched.status)) {
379
- // kind and status come from the SAME response (see the scalar helper).
576
+ // kind and status come from the SAME response (see the scalar helper). This is the rung
577
+ // the field incident actually lands on: the gateway rejects the extras with 400, then
578
+ // answers the minimal ARRAY with 500 — so the scalar probe has to happen here too.
380
579
  const kind = classifyStatus(dispatched.status) ?? "transport";
381
- return { ok: false, kind, status: dispatched.status };
580
+ return await degradeToScalarAfterBatchFailure(request, deadlineAt, {
581
+ ok: false,
582
+ kind,
583
+ status: dispatched.status,
584
+ });
382
585
  }
586
+ return await degradeToScalarsForArrayRejectingEndpoint(request, deadlineAt, dispatched.status, log);
587
+ }
588
+ // The single place that records "this endpoint rejects the ARRAY shape itself". Both strict
589
+ // rejection paths — the already-memoized strict endpoint and the minimal-shape retry that is
590
+ // rejected in turn — reach the identical decision, and a fail-safe rule kept in two copies drifts:
591
+ // a change to the memo key, the reason label, or the event fields would otherwise have to be
592
+ // applied twice for the two paths to keep reporting the same decision the same way.
593
+ async function degradeToScalarsForArrayRejectingEndpoint(request, deadlineAt, status, log) {
383
594
  arrayRejectingEndpoints.add(request.endpoint);
595
+ log.write(embeddingEvent("warn", "embedding.batch.array-unsupported", {
596
+ endpoint: logEndpointHost(request.endpoint),
597
+ inputCount: request.inputs.length,
598
+ memoized: true,
599
+ reason: "minimal-array-rejected",
600
+ }, status));
384
601
  return await requestScalarFallbackBatch(request, deadlineAt);
385
602
  }
386
603
  function perItemTimeoutMs(request) {
387
- return request.timeoutMs ?? 30_000;
604
+ return request.timeoutMs ?? DEFAULT_EMBEDDING_TIMEOUT_MS;
605
+ }
606
+ // The routing fields decide the URL itself: an azure-openai-deployment request resolves to
607
+ // /openai/deployments/<id>/embeddings?api-version=…. Dropping them on the scalar fallback sent
608
+ // every probe to the plain /embeddings path — a DIFFERENT endpoint than the array attempt just
609
+ // used, so the probe could only ever fail and report a false outage.
610
+ function deploymentRouting(request) {
611
+ return {
612
+ ...(request.endpointStyle !== undefined ? { endpointStyle: request.endpointStyle } : {}),
613
+ ...(request.apiVersion !== undefined ? { apiVersion: request.apiVersion } : {}),
614
+ };
388
615
  }
389
616
  // The complete-ladder budget scales with the WORK: the scalar fallback serves one item per
390
617
  // request, so a flat per-batch budget expires mid-batch on slow strict gateways, the batcher
@@ -392,38 +619,95 @@ function perItemTimeoutMs(request) {
392
619
  // spins for hours without an error (customer field incident, 0.3.11). Capped at 15 minutes
393
620
  // as the runaway backstop. Exported for the budget-math pin.
394
621
  export function ladderDeadlineMs(inputCount, timeoutMs) {
395
- return Math.min((timeoutMs ?? 30_000) * Math.max(1, inputCount), 900_000);
622
+ return Math.min((timeoutMs ?? DEFAULT_EMBEDDING_TIMEOUT_MS) * Math.max(1, inputCount), 900_000);
396
623
  }
397
624
  // A mid-ladder failure keeps the completed prefix (see OpenAIEmbeddingBatchOutcome.partial):
398
625
  // the batcher resumes behind it on retry instead of re-paying every finished embedding.
399
626
  function scalarLadderFailure(failure, completed) {
400
627
  return completed.length === 0 ? failure : { ...failure, partial: completed };
401
628
  }
629
+ // One line per ladder STOP. `completed` is the prefix the batcher may resume behind — without it
630
+ // a retry re-embeds from item zero, which is the shape of the 0.3.11 non-convergent field
631
+ // incident. `total` gives the operator the ratio; neither the inputs nor the vectors are read.
632
+ function logLadderStop(log, request, op, completed, outcome) {
633
+ log.write(embeddingEvent("warn", op, { endpoint: logEndpointHost(request.endpoint), total: request.inputs.length, completed }, outcome.status, outcome.kind));
634
+ }
635
+ // The per-item request the ladder issues, extracted so the loop below stays readable and within
636
+ // the function-length budget. Present-only spreads throughout: `exactOptionalPropertyTypes` makes
637
+ // an explicit `undefined` a different thing from an absent property, and several of these fields
638
+ // (endpointStyle, dimensions) change the URL or the vector space when present.
639
+ function scalarLadderRequest(request, input, timeoutMs) {
640
+ return {
641
+ endpoint: request.endpoint,
642
+ apiKey: request.apiKey,
643
+ ...(request.apiKeyHeaderName !== undefined
644
+ ? { apiKeyHeaderName: request.apiKeyHeaderName }
645
+ : {}),
646
+ modelId: request.modelId,
647
+ input,
648
+ ...(request.log !== undefined ? { log: request.log } : {}),
649
+ // The batch's correlation id rides down to every per-item request: without it the ladder's N
650
+ // scalar calls read as unrelated traffic next to the batch line that spawned them.
651
+ ...(request.logContext !== undefined ? { logContext: request.logContext } : {}),
652
+ ...deploymentRouting(request),
653
+ ...(request.dimensions !== undefined ? { dimensions: request.dimensions } : {}),
654
+ ...(request.signal !== undefined ? { signal: request.signal } : {}),
655
+ timeoutMs,
656
+ ...(request.fetchImpl !== undefined ? { fetchImpl: request.fetchImpl } : {}),
657
+ ...(request.egress !== undefined ? { egress: request.egress } : {}),
658
+ };
659
+ }
660
+ // PROGRESS, not just outcomes. Before this line the ladder wrote only when it STOPPED, so the
661
+ // slowest and most incident-prone path in the package — N sequential round-trips against a gateway
662
+ // that has already proven degraded — produced N items' worth of silence, and an operator watching
663
+ // "0 of 36 vectors" could not tell a ladder crawling at 9s per item from one wedged on item 3.
664
+ //
665
+ // Per item is the right granularity precisely BECAUSE this path only runs when a gateway is
666
+ // already degraded: the volume is bounded by the batch size, it is emitted at most once per
667
+ // network round-trip (so it can never outpace the work it describes), and the alternative —
668
+ // summarising at the end — reports the stall only once it is over. `inputChars` is a COUNT of the
669
+ // item's characters; the item itself is never read into the line.
670
+ function logLadderItem(log, request, item, durationMs) {
671
+ if (!logLevelEnabled(log, "info"))
672
+ return;
673
+ log.write({
674
+ level: "info",
675
+ category: "embedding",
676
+ op: "embedding.scalar-ladder.item-completed",
677
+ durationMs,
678
+ extra: {
679
+ endpoint: logEndpointHost(request.endpoint),
680
+ index: item.index,
681
+ total: request.inputs.length,
682
+ inputChars: item.inputChars,
683
+ },
684
+ });
685
+ }
402
686
  async function requestScalarFallbackBatch(request, deadlineAt) {
687
+ const log = embeddingLog(request);
403
688
  const value = [];
404
689
  for (const input of request.inputs) {
405
690
  const remainingMs = deadlineAt - Date.now();
406
691
  if (remainingMs <= 0) {
692
+ logLadderStop(log, request, "embedding.scalar-ladder.deadline-expired", value.length, {
693
+ kind: "timeout",
694
+ });
407
695
  return scalarLadderFailure({ ok: false, kind: "timeout" }, value);
408
696
  }
409
- const outcome = await requestOpenAIEmbedding({
410
- endpoint: request.endpoint,
411
- apiKey: request.apiKey,
412
- ...(request.apiKeyHeaderName !== undefined
413
- ? { apiKeyHeaderName: request.apiKeyHeaderName }
414
- : {}),
415
- modelId: request.modelId,
416
- input,
417
- ...(request.dimensions !== undefined ? { dimensions: request.dimensions } : {}),
418
- ...(request.signal !== undefined ? { signal: request.signal } : {}),
419
- timeoutMs: Math.min(remainingMs, perItemTimeoutMs(request)),
420
- ...(request.fetchImpl !== undefined ? { fetchImpl: request.fetchImpl } : {}),
421
- ...(request.egress !== undefined ? { egress: request.egress } : {}),
422
- });
697
+ const index = value.length;
698
+ const itemElapsed = logTimer();
699
+ const outcome = await requestOpenAIEmbedding(scalarLadderRequest(request, input, Math.min(remainingMs, perItemTimeoutMs(request))));
423
700
  if (!outcome.ok) {
701
+ logLadderStop(log, request, "embedding.scalar-ladder.item-failed", value.length, outcome);
424
702
  return scalarLadderFailure(outcome, value);
425
703
  }
426
704
  value.push(outcome.value);
705
+ logLadderItem(log, request, { index, inputChars: input.length }, itemElapsed());
427
706
  }
707
+ log.write(embeddingEvent("info", "embedding.scalar-ladder.completed", {
708
+ endpoint: logEndpointHost(request.endpoint),
709
+ total: request.inputs.length,
710
+ completed: value.length,
711
+ }));
428
712
  return { ok: true, value };
429
713
  }
@@ -1,3 +1,4 @@
1
+ import { type ModelGatewayLogSink } from "./observability.js";
1
2
  import type { CircuitBreakerConfig, CircuitBreakerStatus, Clock } from "./types.js";
2
3
  export declare const systemClock: Clock;
3
4
  export interface RetryConfig {
@@ -5,20 +6,32 @@ export interface RetryConfig {
5
6
  readonly retryBaseDelayMs: number;
6
7
  readonly timeoutMs?: number | undefined;
7
8
  }
8
- export declare function executeWithRetry<T>(operation: (attemptTimeoutMs?: number) => Promise<T>, config: RetryConfig, clock: Clock, signal?: AbortSignal, random?: () => number): Promise<T>;
9
+ export interface RetryLogContext {
10
+ readonly sink?: ModelGatewayLogSink | undefined;
11
+ readonly modelId?: string | undefined;
12
+ readonly correlationId?: string | undefined;
13
+ }
14
+ export declare function executeWithRetry<T>(operation: (attemptTimeoutMs?: number) => Promise<T>, config: RetryConfig, clock: Clock, signal?: AbortSignal, random?: () => number, logContext?: RetryLogContext): Promise<T>;
9
15
  export declare class CircuitBreaker {
10
16
  private readonly modelId;
11
17
  private readonly config;
12
18
  private readonly clock;
19
+ private readonly log;
13
20
  private state;
14
21
  private consecutiveFailures;
15
22
  private openedAt;
16
23
  private probesRemaining;
17
24
  private probesInFlight;
18
- constructor(modelId: string, config: CircuitBreakerConfig, clock: Clock);
19
- assertAllowed(): void;
20
- recordSuccess(): void;
21
- recordFailure(): void;
25
+ private rejectedSinceTransition;
26
+ constructor(modelId: string, config: CircuitBreakerConfig, clock: Clock, log?: ModelGatewayLogSink);
27
+ private emit;
28
+ private noteRejection;
29
+ private takeRejectedCount;
30
+ assertAllowed(correlationId?: string): void;
31
+ private enterHalfOpenOrReject;
32
+ private admitProbeOrReject;
33
+ recordSuccess(correlationId?: string): void;
34
+ recordFailure(correlationId?: string): void;
22
35
  status(modelId: string): CircuitBreakerStatus;
23
36
  private open;
24
37
  private close;
@@ -1 +1 @@
1
- {"version":3,"file":"resilience.d.ts","sourceRoot":"","sources":["../src/resilience.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAgB,KAAK,EAAE,MAAM,YAAY,CAAC;AAIlG,eAAO,MAAM,WAAW,EAAE,KAkBzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AA2FD,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,SAAS,EAAE,CAAC,gBAAgB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACpD,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,GAAE,MAAM,MAAoB,GACjC,OAAO,CAAC,CAAC,CAAC,CA0BZ;AAED,qBAAa,cAAc;IASvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAVxB,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,eAAe,CAAK;IAE5B,OAAO,CAAC,cAAc,CAAK;IAE3B,YACmB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,KAAK,EAC3B;IAOJ,aAAa,IAAI,IAAI,CAgBpB;IAED,aAAa,IAAI,IAAI,CAUpB;IAED,aAAa,IAAI,IAAI,CAUpB;IAED,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAO5C;IAED,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,KAAK;CAOd"}
1
+ {"version":3,"file":"resilience.d.ts","sourceRoot":"","sources":["../src/resilience.ts"],"names":[],"mappings":"AAUA,OAAO,EAQL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAgB,KAAK,EAAE,MAAM,YAAY,CAAC;AAIlG,eAAO,MAAM,WAAW,EAAE,KAkBzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AA6FD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C;AA2CD,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,SAAS,EAAE,CAAC,gBAAgB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACpD,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,GAAE,MAAM,MAAoB,EAClC,UAAU,GAAE,eAAoB,GAC/B,OAAO,CAAC,CAAC,CAAC,CAsCZ;AAED,qBAAa,cAAc;IAYvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAdtB,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,eAAe,CAAK;IAE5B,OAAO,CAAC,cAAc,CAAK;IAG3B,OAAO,CAAC,uBAAuB,CAAK;IAEpC,YACmB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,oBAAoB,EAC5B,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,mBAA6C,EACjE;IAYJ,OAAO,CAAC,IAAI;IA4BZ,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,iBAAiB;IAWzB,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAO1C;IAED,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,kBAAkB;IAQ1B,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAU1C;IAED,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAU1C;IAED,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAO5C;IAMD,OAAO,CAAC,IAAI;IAmBZ,OAAO,CAAC,KAAK;CAiBd"}