@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
@@ -1,2 +1,2 @@
1
- export declare const KEIKO_MEMORY_VAULT_VERSION: "0.3.13";
1
+ export declare const KEIKO_MEMORY_VAULT_VERSION: "0.3.15";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const KEIKO_MEMORY_VAULT_VERSION = "0.3.13";
1
+ export const KEIKO_MEMORY_VAULT_VERSION = "0.3.15";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscharko-dev/keiko-memory-vault",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "MemoriaViva — Internal memory-vault package: governed enterprise memory storage (node:sqlite). Scope-isolated CRUD, edges, embeddings, tombstones, validator-gated boundary, redaction-aware writes (ADR-0019 + Epic #204). Not published independently.",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "private": true,
23
23
  "peerDependencies": {
24
- "@oscharko-dev/keiko-contracts": "0.3.13",
25
- "@oscharko-dev/keiko-security": "0.3.13"
24
+ "@oscharko-dev/keiko-contracts": "0.3.15",
25
+ "@oscharko-dev/keiko-security": "0.3.15"
26
26
  }
27
27
  }
@@ -1,8 +1,13 @@
1
+ import { type ModelGatewayLogContext, type ModelGatewayLogSink } from "./observability.js";
1
2
  import type { Clock, CircuitBreakerStatus, GatewayConfig, GatewayRequest, GatewayStreamChunk, NormalizedResponse, ProviderAdapter } from "./types.js";
2
3
  export interface GatewayDeps {
3
4
  readonly adapter?: ProviderAdapter | undefined;
4
5
  readonly clock?: Clock | undefined;
5
6
  readonly random?: (() => number) | undefined;
7
+ readonly log?: ModelGatewayLogSink | undefined;
8
+ }
9
+ export interface GatewayCallRequest extends GatewayRequest {
10
+ readonly logContext?: ModelGatewayLogContext | undefined;
6
11
  }
7
12
  export declare class Gateway {
8
13
  private readonly config;
@@ -11,13 +16,21 @@ export declare class Gateway {
11
16
  private readonly adapter;
12
17
  private readonly providers;
13
18
  private readonly breakers;
19
+ private readonly log;
14
20
  constructor(config: GatewayConfig, deps?: GatewayDeps);
15
- chat(request: GatewayRequest): Promise<NormalizedResponse>;
16
- chatStream(request: GatewayRequest): AsyncGenerator<GatewayStreamChunk>;
21
+ chat(request: GatewayCallRequest): Promise<NormalizedResponse>;
22
+ chatStream(request: GatewayCallRequest): AsyncGenerator<GatewayStreamChunk>;
23
+ private logCallStarted;
24
+ private logCallFailed;
25
+ private logStreamCompleted;
26
+ private logStreamAbandoned;
27
+ private logStreamFailed;
28
+ private logCallCompleted;
17
29
  private streamFrom;
18
30
  private enrich;
19
31
  circuitStatus(modelId: string): CircuitBreakerStatus;
20
32
  private invoke;
33
+ private logRouteRejected;
21
34
  private route;
22
35
  private breakerFor;
23
36
  private adapterFor;
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,kBAAkB,EAGlB,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAInC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;CAC9C;AAiBD,qBAAa,OAAO;IAQhB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2C;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAE9D,YACmB,MAAM,EAAE,aAAa,EACtC,IAAI,GAAE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AAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2C;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAsB;IAE1C,YACmB,MAAM,EAAE,aAAa,EACtC,IAAI,GAAE,WAAgB,EAOvB;IAEK,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAyCnE;IAMM,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CA8CjF;IAQD,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,eAAe;IA+BvB,OAAO,CAAC,gBAAgB;YAwBT,UAAU;IAyBzB,OAAO,CAAC,MAAM;IAiBd,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAUnD;YAEa,MAAM;IA8BpB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,KAAK;IAoBb,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,UAAU;CAUnB"}
@@ -5,9 +5,19 @@
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { CancelledError, GatewayError, UnknownModelError, } from "@oscharko-dev/keiko-security/errors/gateway";
7
7
  import { findConfiguredCapability } from "./model-selection.js";
8
+ import { logEndpointHost, logErrorKind, logLevelEnabled, logTimer, resolveLogSink, } from "./observability.js";
8
9
  import { OpenAiAdapter } from "./openai-adapter.js";
9
10
  import { CircuitBreaker, executeWithRetry, systemClock } from "./resilience.js";
10
11
  import { assertValidGatewaySamplingParameters } from "./types.js";
12
+ function callIds(requestId, request) {
13
+ return { requestId, correlationId: request.logContext?.correlationId ?? requestId };
14
+ }
15
+ function callIdFields(ids) {
16
+ return ids.correlationId === ids.requestId ? {} : { requestId: ids.requestId };
17
+ }
18
+ function gatewayEvent(level, op, correlationId, extra, durationMs, errorKind) {
19
+ return { level, category: "gateway", op, correlationId, durationMs, errorKind, extra };
20
+ }
11
21
  // RB-6 (GEN-OBS-CORRELATION-503): tag a thrown GatewayError with the gateway's per-call request id
12
22
  // so a failed model call is traceable to the gateway record (mirrors the id already carried by a
13
23
  // successful call's `usage.requestId`). Only the first (innermost) tag wins so a retry does not
@@ -24,33 +34,40 @@ export class Gateway {
24
34
  adapter;
25
35
  providers;
26
36
  breakers = new Map();
37
+ log;
27
38
  constructor(config, deps = {}) {
28
39
  this.config = config;
29
40
  this.clock = deps.clock ?? systemClock;
30
41
  this.random = deps.random ?? Math.random;
31
42
  this.adapter = deps.adapter;
43
+ this.log = resolveLogSink(deps.log);
32
44
  this.providers = new Map(config.providers.map((p) => [p.modelId, p]));
33
45
  }
34
46
  async chat(request) {
35
- const route = this.route(request.modelId);
47
+ const route = this.route(request.modelId, request.logContext?.correlationId);
36
48
  assertValidGatewaySamplingParameters(request);
37
49
  const breaker = this.breakerFor(route.provider);
38
50
  const requestId = randomUUID();
51
+ const ids = callIds(requestId, request);
39
52
  const start = this.clock.now();
53
+ const elapsed = logTimer();
40
54
  const adapter = this.adapterFor(requestId, route.capability);
55
+ this.logCallStarted(ids, route, false);
41
56
  let result;
42
57
  try {
43
- result = await executeWithRetry((attemptTimeoutMs) => this.invoke(breaker, adapter, request, {
58
+ result = await executeWithRetry((attemptTimeoutMs) => this.invoke(breaker, adapter, request, ids.correlationId, {
44
59
  ...route.provider,
45
60
  ...(attemptTimeoutMs === undefined ? {} : { timeoutMs: attemptTimeoutMs }),
46
- }), route.provider, this.clock, request.cancellationSignal, this.random);
61
+ }), route.provider, this.clock, request.cancellationSignal, this.random, { sink: this.log, modelId: route.provider.modelId, correlationId: ids.correlationId });
47
62
  }
48
63
  catch (error) {
49
64
  // RB-6: stamp the gateway request id onto the thrown error so a FAILED buffered call is
50
65
  // traceable to the gateway record (previously requestId was attached only on success/usage).
51
66
  attachGatewayRequestId(error, requestId);
67
+ this.logCallFailed(ids, route, elapsed(), error);
52
68
  throw error;
53
69
  }
70
+ this.logCallCompleted(ids, route, result, elapsed());
54
71
  return {
55
72
  ...result,
56
73
  usage: {
@@ -66,36 +83,136 @@ export class Gateway {
66
83
  // already-emitted tokens. An adapter without a streaming variant falls back to a
67
84
  // single delta+done synthesised from its buffered call().
68
85
  async *chatStream(request) {
69
- const route = this.route(request.modelId);
86
+ const route = this.route(request.modelId, request.logContext?.correlationId);
70
87
  assertValidGatewaySamplingParameters(request);
71
88
  const breaker = this.breakerFor(route.provider);
72
- breaker.assertAllowed();
73
89
  const requestId = randomUUID();
90
+ const ids = callIds(requestId, request);
91
+ breaker.assertAllowed(ids.correlationId);
74
92
  const start = this.clock.now();
93
+ const elapsed = logTimer();
75
94
  const adapter = this.adapterFor(requestId, route.capability);
95
+ this.logCallStarted(ids, route, true);
96
+ let chunkCount = 0;
97
+ // EVERY started stream needs exactly one outcome line. Set the moment an outcome is written,
98
+ // so the `finally` can tell "the consumer walked away" from the two paths that already spoke.
99
+ let settled = false;
76
100
  try {
77
- for await (const chunk of this.streamFrom(adapter, request, route.provider)) {
101
+ for await (const chunk of this.streamFrom(adapter, request, route.provider, ids)) {
102
+ chunkCount += 1;
78
103
  yield chunk.type === "done"
79
104
  ? { type: "done", response: this.enrich(chunk.response, requestId, start, route) }
80
105
  : chunk;
81
106
  }
82
- breaker.recordSuccess();
107
+ breaker.recordSuccess(ids.correlationId);
108
+ settled = true;
83
109
  }
84
110
  catch (error) {
85
111
  // A client-initiated cancel is not a provider fault — skip the breaker.
86
112
  if (!(error instanceof CancelledError)) {
87
- breaker.recordFailure();
113
+ breaker.recordFailure(ids.correlationId);
88
114
  }
89
115
  // RB-6: stamp the gateway request id onto the thrown error (mid-stream failure traceability).
90
116
  attachGatewayRequestId(error, requestId);
117
+ settled = true;
118
+ this.logStreamFailed(ids, route, chunkCount, elapsed(), error);
91
119
  throw error;
92
120
  }
121
+ finally {
122
+ // A consumer that stops iterating (client disconnect, request abort, `break`) closes this
123
+ // generator through `return()`: the loop is left without running either outcome branch, so
124
+ // without this line the log keeps `gateway.stream.started` with nothing after it — the exact
125
+ // shape of a wedged provider. Not a failure and not a fault, so it is an outcome of its own.
126
+ if (!settled) {
127
+ this.logStreamAbandoned(ids, route, chunkCount, elapsed());
128
+ }
129
+ }
130
+ // Outside the try on purpose: a sink that throws here must not be caught above and reported as
131
+ // a mid-stream provider failure — which would also trip the circuit breaker on a logging fault.
132
+ this.logStreamCompleted(ids, route, chunkCount, elapsed());
133
+ }
134
+ // THE ATTEMPT LINE for a model call — written BEFORE the adapter is invoked, not after it
135
+ // returns. A provider that accepts the connection and then goes quiet produces no completion
136
+ // and no failure, so without this the gateway is silent for exactly the window an operator is
137
+ // trying to diagnose. `timeoutMs` and `maxRetries` are on it because the pair bounds how long
138
+ // this silence can legitimately last: an attempt line whose deadline has already passed with no
139
+ // outcome is a wedge, not a slow provider.
140
+ logCallStarted(ids, route, streaming) {
141
+ if (!logLevelEnabled(this.log, "info"))
142
+ return;
143
+ this.log.write(gatewayEvent("info", streaming ? "gateway.stream.started" : "gateway.chat.started", ids.correlationId, {
144
+ ...callIdFields(ids),
145
+ modelId: route.provider.modelId,
146
+ endpoint: logEndpointHost(route.provider.baseUrl),
147
+ costClass: route.capability.costClass,
148
+ timeoutMs: route.provider.timeoutMs,
149
+ maxRetries: route.provider.maxRetries,
150
+ streaming,
151
+ }));
93
152
  }
94
- async *streamFrom(adapter, request, provider) {
153
+ logCallFailed(ids, route, durationMs, error) {
154
+ this.log.write(gatewayEvent("warn", "gateway.chat.failed", ids.correlationId, { ...callIdFields(ids), modelId: route.provider.modelId, streaming: false }, durationMs, logErrorKind(error)));
155
+ }
156
+ logStreamCompleted(ids, route, chunkCount, durationMs) {
157
+ this.log.write(gatewayEvent("info", "gateway.stream.completed", ids.correlationId, {
158
+ ...callIdFields(ids),
159
+ modelId: route.provider.modelId,
160
+ costClass: route.capability.costClass,
161
+ chunkCount,
162
+ }, durationMs));
163
+ }
164
+ // The third stream outcome: the provider never finished because nobody was listening any more.
165
+ // `info`, not `warn` — a user pressing stop is routine, and the line exists to close the
166
+ // started/outcome pair an operator scans for, not to report a fault. `chunkCount` says how much
167
+ // of the answer had already been paid for and thrown away.
168
+ logStreamAbandoned(ids, route, chunkCount, durationMs) {
169
+ this.log.write(gatewayEvent("info", "gateway.stream.abandoned", ids.correlationId, {
170
+ ...callIdFields(ids),
171
+ modelId: route.provider.modelId,
172
+ costClass: route.capability.costClass,
173
+ streaming: true,
174
+ chunkCount,
175
+ reason: "consumer-stopped-iterating",
176
+ }, durationMs));
177
+ }
178
+ logStreamFailed(ids, route, chunkCount, durationMs, error) {
179
+ this.log.write(gatewayEvent("warn", "gateway.stream.failed", ids.correlationId, {
180
+ ...callIdFields(ids),
181
+ modelId: route.provider.modelId,
182
+ streaming: true,
183
+ chunkCount,
184
+ // A mid-stream failure has already handed tokens to the caller and cannot be retried
185
+ // (chatStream is deliberately outside executeWithRetry); the count is how far it got.
186
+ afterFirstChunk: chunkCount > 0,
187
+ }, durationMs, logErrorKind(error)));
188
+ }
189
+ // Buffered completions only: the streaming path has its own outcome lines with their own fields
190
+ // (`gateway.stream.completed` / `.abandoned` / `.failed`). The `streaming: false` here is a
191
+ // constant of THIS op rather than a parameter — a caller able to pass `true` would emit
192
+ // `gateway.chat.completed` for a stream and break the op naming every reader filters on.
193
+ logCallCompleted(ids, route, result, durationMs) {
194
+ this.log.write(gatewayEvent("info", "gateway.chat.completed", ids.correlationId, {
195
+ ...callIdFields(ids),
196
+ modelId: route.provider.modelId,
197
+ costClass: route.capability.costClass,
198
+ finishReason: result.finishReason,
199
+ toolCallCount: result.toolCalls.length,
200
+ streaming: false,
201
+ }, durationMs));
202
+ }
203
+ async *streamFrom(adapter, request, provider, ids) {
95
204
  if (adapter.callStream !== undefined) {
96
205
  yield* adapter.callStream(request, provider);
97
206
  return;
98
207
  }
208
+ // Degradation: this adapter has no streaming variant, so the caller gets ONE synthetic delta
209
+ // after the full buffered latency instead of incremental tokens. Silently, that reads to an
210
+ // operator as a provider that took seconds to emit its first token.
211
+ this.log.write(gatewayEvent("warn", "gateway.stream.buffered-fallback", ids.correlationId, {
212
+ ...callIdFields(ids),
213
+ modelId: provider.modelId,
214
+ reason: "adapter-has-no-stream",
215
+ }));
99
216
  const response = await adapter.call(request, provider);
100
217
  yield { type: "delta", token: response.content };
101
218
  yield { type: "done", response };
@@ -120,31 +237,46 @@ export class Gateway {
120
237
  openedAt: null,
121
238
  });
122
239
  }
123
- async invoke(breaker, adapter, request, provider) {
124
- breaker.assertAllowed();
240
+ async invoke(breaker, adapter, request, correlationId, provider) {
241
+ breaker.assertAllowed(correlationId);
125
242
  try {
126
243
  const response = await adapter.call(request, provider);
127
- breaker.recordSuccess();
244
+ breaker.recordSuccess(correlationId);
128
245
  return response;
129
246
  }
130
247
  catch (error) {
131
248
  // A client-initiated cancel is not a provider fault — skip the breaker.
132
249
  if (!(error instanceof CancelledError)) {
133
- breaker.recordFailure();
250
+ breaker.recordFailure(correlationId);
134
251
  }
135
252
  throw error;
136
253
  }
137
254
  }
138
- route(modelId) {
255
+ // Fail-closed routing. Each of the three refusals is a DIFFERENT operator problem — an unknown
256
+ // model id, a configured provider with no capability metadata, and a correctly configured model
257
+ // of the wrong kind — and all three surface to the caller as the same UnknownModelError, so the
258
+ // reason label is the only thing that separates them after the fact.
259
+ //
260
+ // Routing happens BEFORE this call has a request id of its own, so the caller's correlation id
261
+ // is the only thing that can attribute a refusal to the operation that provoked it — and a
262
+ // refusal is exactly the "never started" case an operator has to separate from "started and
263
+ // hung". Absent when the caller supplied none, as before.
264
+ logRouteRejected(modelId, correlationId, reason, kind) {
265
+ this.log.write(gatewayEvent("warn", "gateway.route.rejected", correlationId, { modelId, reason, kind }));
266
+ }
267
+ route(modelId, correlationId) {
139
268
  const provider = this.providers.get(modelId);
140
269
  if (provider === undefined) {
270
+ this.logRouteRejected(modelId, correlationId, "no-provider-configured");
141
271
  throw new UnknownModelError(`no provider configured for model '${modelId}'`);
142
272
  }
143
273
  const capability = findConfiguredCapability(this.config, modelId);
144
274
  if (capability === undefined) {
275
+ this.logRouteRejected(modelId, correlationId, "no-capability-metadata");
145
276
  throw new UnknownModelError(`model '${modelId}' has no capability metadata`);
146
277
  }
147
278
  if (capability.kind !== "chat") {
279
+ this.logRouteRejected(modelId, correlationId, "wrong-model-kind", capability.kind);
148
280
  throw new UnknownModelError(`model '${modelId}' has kind '${capability.kind}'; the chat path requires a chat model`);
149
281
  }
150
282
  return { provider, capability };
@@ -158,7 +290,7 @@ export class Gateway {
158
290
  // GatewayConfig.circuitBreaker when the provider did not declare its own — every existing
159
291
  // config keeps its exact behaviour.
160
292
  const breakerConfig = provider.circuitBreaker ?? this.config.circuitBreaker;
161
- const breaker = new CircuitBreaker(provider.modelId, breakerConfig, this.clock);
293
+ const breaker = new CircuitBreaker(provider.modelId, breakerConfig, this.clock, this.log);
162
294
  this.breakers.set(provider.modelId, breaker);
163
295
  return breaker;
164
296
  }
@@ -1,4 +1,5 @@
1
1
  import type { LookupAddress } from "node:dns";
2
+ import { type ModelGatewayLogContext, type ModelGatewayLogSink } from "./observability.js";
2
3
  import type { OutboundHttpEgressConfig } from "./types.js";
3
4
  export type { OutboundHttpEgressConfig } from "./types.js";
4
5
  export { classifyOutboundHost } from "./egress-policy.js";
@@ -9,6 +10,8 @@ export interface GatewayFetchOptions extends RequestInit {
9
10
  readonly egress?: OutboundHttpEgressConfig | undefined;
10
11
  readonly timeoutMs?: number | undefined;
11
12
  readonly maxResponseBytes?: number | undefined;
13
+ readonly log?: ModelGatewayLogSink | undefined;
14
+ readonly logContext?: ModelGatewayLogContext | undefined;
12
15
  }
13
16
  export type OutboundHttpEgressErrorCode = "PROXY_UNREACHABLE" | "PROXY_AUTH_REQUIRED" | "PROXY_EGRESS_FAILED" | "PROXY_BLOCKED_BY_POLICY" | "TLS_CA_FAILURE";
14
17
  export declare class OutboundHttpEgressError extends Error {
@@ -1 +1 @@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,GAAE,MAA2B,EACrC,MAAM,CAAC,EAAE,MAAM,IAAI,GAClB,QAAQ,CA2CV;AAkYD,wBAAgB,iCAAiC,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE/E;AA8MD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,GAAG,EACX,KAAK,EAAE,GAAG,EACV,EAAE,EAAE,SAAS,MAAM,EAAE,EACrB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,MAAM,CAOR;AA+jBD,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAwBnB;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,MAA2B,GACpC,OAAO,CAAC,OAAO,CAAC,CAyBlB;AASD,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,MAA2B,GACpC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAgClC;AAuCD,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,aAAa,EAAE,MAAM,EAGhC;CACF;AAmCD,wBAAuB,aAAa,CAClC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,MAA2B,EACrC,aAAa,CAAC,EAAE,MAAM,GACrB,cAAc,CA+BhB"}
@@ -6,6 +6,7 @@ import { request as httpsRequest } from "node:https";
6
6
  import { connect as netConnect, isIP } from "node:net";
7
7
  import * as tls from "node:tls";
8
8
  import { normalizeHost, outboundAddressBlockedReason, outboundTargetBlockedReason, } from "./egress-policy.js";
9
+ import { logEndpointHost, logErrorKind, logLevelEnabled, logTimer, resolveLogSink, withCorrelationId, } from "./observability.js";
9
10
  // Re-exported so a caller can classify a target's address class (e.g. "loopback") by hostname
10
11
  // string alone, with no DNS resolution and no dependency on any `OutboundHttpEgressConfig` flag —
11
12
  // safe to use unconditionally, proxied or not (see keiko-server's Atlassian httpPort.ts for why
@@ -895,27 +896,51 @@ function attemptPrimaryFetch(url, init, doFetch, maxResponseBytes, pinnedAddress
895
896
  : doFetch(url, init);
896
897
  }
897
898
  // Extracted from fetchDirectWithCaFallback to keep its cyclomatic complexity within the limit.
898
- async function attemptCaBundleFallback(url, init, egress, maxResponseBytes, pinnedAddresses) {
899
+ async function attemptCaBundleFallback(url, init, plan) {
899
900
  try {
900
- return await fetchWithCaBundle(url, init, egress, maxResponseBytes, pinnedAddresses !== undefined ? pinnedLookup(pinnedAddresses) : undefined);
901
+ return await fetchWithCaBundle(url, init, plan.egress, plan.maxResponseBytes, plan.pinnedAddresses !== undefined ? pinnedLookup(plan.pinnedAddresses) : undefined);
901
902
  }
902
903
  catch (fallbackError) {
903
904
  if (isRecoverableTlsTrustError(fallbackError)) {
905
+ plan.log.write({
906
+ level: "warn",
907
+ category: "http",
908
+ op: "http.gateway.tls.trust-failed",
909
+ errorKind: logErrorKind(fallbackError),
910
+ extra: { endpoint: logEndpointHost(url), afterCaBundleFallback: true },
911
+ });
904
912
  throw tlsCaFailureError();
905
913
  }
906
914
  throw fallbackError;
907
915
  }
908
916
  }
909
917
  // Extracted from gatewayFetch to keep its cyclomatic complexity within the limit.
910
- async function fetchDirectWithCaFallback(url, init, doFetch, useCaFallback, egress, maxResponseBytes, pinnedAddresses) {
918
+ async function fetchDirectWithCaFallback(url, init, plan) {
911
919
  try {
912
- return await attemptPrimaryFetch(url, init, doFetch, maxResponseBytes, pinnedAddresses);
920
+ return await attemptPrimaryFetch(url, init, plan.doFetch, plan.maxResponseBytes, plan.pinnedAddresses);
913
921
  }
914
922
  catch (error) {
915
- if (useCaFallback && usesHttps(url) && isRecoverableTlsTrustError(error)) {
916
- return attemptCaBundleFallback(url, init, egress, maxResponseBytes, pinnedAddresses);
923
+ const recoverable = usesHttps(url) && isRecoverableTlsTrustError(error);
924
+ if (plan.useCaFallback && recoverable) {
925
+ // Degradation: the default trust store rejected the peer, so the call is retried against
926
+ // Keiko's assembled CA set. Silently, this shows up only as a doubled connect latency.
927
+ plan.log.write({
928
+ level: "warn",
929
+ category: "http",
930
+ op: "http.gateway.tls.ca-bundle-fallback",
931
+ errorKind: logErrorKind(error),
932
+ extra: { endpoint: logEndpointHost(url) },
933
+ });
934
+ return attemptCaBundleFallback(url, init, plan);
917
935
  }
918
- if (usesHttps(url) && isRecoverableTlsTrustError(error)) {
936
+ if (recoverable) {
937
+ plan.log.write({
938
+ level: "warn",
939
+ category: "http",
940
+ op: "http.gateway.tls.trust-failed",
941
+ errorKind: logErrorKind(error),
942
+ extra: { endpoint: logEndpointHost(url), afterCaBundleFallback: false },
943
+ });
919
944
  throw tlsCaFailureError();
920
945
  }
921
946
  throw error;
@@ -963,10 +988,10 @@ function requirePinnedAddress(addresses) {
963
988
  // picked, and derives every address binding a caller of gatewayFetch needs from that single
964
989
  // lookup: the direct-path pinned set (AUDIT-SEC-001), the proxy-path pinned address (ADR-0038 D6),
965
990
  // and the resolveDns flag the redirect re-check must reuse.
966
- async function resolveGatewayDns(target, egress, usesRealTransport, proxy, doFetch) {
967
- const dns = planGatewayDns(usesRealTransport, proxy, doFetch, egress);
991
+ async function resolveGatewayDns(plan, egress) {
992
+ const dns = planGatewayDns(plan.usesRealTransport, plan.proxy, plan.doFetch, egress);
968
993
  const resolveDns = dns.pinForConnect || dns.pinForProxyConnect;
969
- const vettedAddresses = await enforceOutboundTargetPolicy(target, egress, { resolveDns });
994
+ const vettedAddresses = await enforceOutboundTargetPolicy(plan.target, egress, { resolveDns });
970
995
  return {
971
996
  pinnedAddresses: dns.pinForConnect ? vettedAddresses : undefined,
972
997
  proxyPinnedAddress: dns.pinForProxyConnect ? requirePinnedAddress(vettedAddresses) : undefined,
@@ -974,7 +999,7 @@ async function resolveGatewayDns(target, egress, usesRealTransport, proxy, doFet
974
999
  };
975
1000
  }
976
1001
  // Extracted from gatewayFetch to keep its line count and cyclomatic complexity within budget.
977
- function planGatewayProxy(url, fetchImpl, egress) {
1002
+ function planGatewayProxy(url, fetchImpl, egress, log) {
978
1003
  const doFetch = fetchImpl ?? globalThis.fetch;
979
1004
  const target = new URL(url);
980
1005
  const usesRealTransport = fetchImpl === undefined;
@@ -982,27 +1007,167 @@ function planGatewayProxy(url, fetchImpl, egress) {
982
1007
  // Validate the configured proxy before target DNS work so malformed/credentialed proxy settings
983
1008
  // fail with their deterministic policy error rather than an unrelated target lookup failure.
984
1009
  const proxy = proxyRaw === undefined ? undefined : parseProxyUrl(proxyRaw);
1010
+ // WHICH ROUTE this call took is the first question asked of a stuck outbound request, and it is
1011
+ // decided entirely by configuration the operator cannot see from the failure. Both endpoints are
1012
+ // reduced to scheme://host:port — a proxy URL may carry credentials in its userinfo.
1013
+ //
1014
+ // Gated: this is a `debug` line on the hot path of every outbound call, and the two
1015
+ // `logEndpointHost` calls below each parse a URL. Asking the sink first means an operator
1016
+ // running at the default `info` threshold pays a predicate call instead of two URL parses and
1017
+ // two allocations per request.
1018
+ if (logLevelEnabled(log, "debug")) {
1019
+ log.write({
1020
+ level: "debug",
1021
+ category: "http",
1022
+ op: "http.gateway.egress.planned",
1023
+ extra: {
1024
+ endpoint: logEndpointHost(target),
1025
+ proxied: proxy !== undefined,
1026
+ proxyEndpoint: logEndpointHost(proxy),
1027
+ transport: usesRealTransport ? "native" : "injected",
1028
+ },
1029
+ });
1030
+ }
985
1031
  return { doFetch, target, usesRealTransport, proxy };
986
1032
  }
987
- export async function gatewayFetch(url, options = {}) {
988
- const { fetchImpl, useCaFallback = fetchImpl === undefined, egress, timeoutMs, maxResponseBytes, ...rest } = options;
989
- // Compose caller signal + optional timeout into a single signal for all paths.
1033
+ // Compose caller signal + optional timeout into a single signal for all paths.
1034
+ function gatewayRequestInit(rest, timeoutMs) {
990
1035
  const composedSignal = composeSignal(rest.signal, timeoutMs);
991
- const init = composedSignal !== undefined
1036
+ return composedSignal !== undefined
992
1037
  ? { ...rest, redirect: "manual", signal: composedSignal }
993
1038
  : { ...rest, redirect: "manual" };
994
- const { doFetch, target, usesRealTransport, proxy } = planGatewayProxy(url, fetchImpl, egress);
995
- refuseUnpinnableResearchEgress(proxy, egress);
996
- const { pinnedAddresses, proxyPinnedAddress, redirectPolicy } = await resolveGatewayDns(target, egress, usesRealTransport, proxy, doFetch);
997
- if (proxy !== undefined) {
998
- const response = await fetchViaProxy(target, init, proxy, egress, maxResponseBytes, proxyPinnedAddress);
999
- await enforceRedirectTargetPolicy(target, response, egress, redirectPolicy);
1039
+ }
1040
+ // The fetch itself. Split out of `gatewayFetch` so the outcome line can wrap it without pushing
1041
+ // either half past the function-length budget.
1042
+ async function performGatewayFetch(url, options) {
1043
+ const { fetchImpl, useCaFallback = fetchImpl === undefined, egress, timeoutMs, maxResponseBytes, log: logOption, ...rest } = options;
1044
+ const log = resolveLogSink(logOption);
1045
+ const init = gatewayRequestInit(rest, timeoutMs);
1046
+ const plan = planGatewayProxy(url, fetchImpl, egress, log);
1047
+ refuseUnpinnableResearchEgress(plan.proxy, egress);
1048
+ const dns = await resolveGatewayDns(plan, egress);
1049
+ if (plan.proxy !== undefined) {
1050
+ const response = await fetchViaProxy(plan.target, init, plan.proxy, egress, maxResponseBytes, dns.proxyPinnedAddress);
1051
+ await enforceRedirectTargetPolicy(plan.target, response, egress, dns.redirectPolicy);
1000
1052
  return response;
1001
1053
  }
1002
- const response = await fetchDirectWithCaFallback(url, init, doFetch, useCaFallback, egress, maxResponseBytes, pinnedAddresses);
1003
- await enforceRedirectTargetPolicy(target, response, egress, redirectPolicy);
1054
+ const response = await fetchDirectWithCaFallback(url, init, {
1055
+ doFetch: plan.doFetch,
1056
+ useCaFallback,
1057
+ egress,
1058
+ maxResponseBytes,
1059
+ pinnedAddresses: dns.pinnedAddresses,
1060
+ log,
1061
+ });
1062
+ await enforceRedirectTargetPolicy(plan.target, response, egress, dns.redirectPolicy);
1004
1063
  return response;
1005
1064
  }
1065
+ // Size of the request body for the attempt line, for the shapes this transport sends verbatim —
1066
+ // a JSON string, or bytes for a multipart audio payload. Anything else reports nothing rather
1067
+ // than being coerced to find out: serialising a body to measure it costs an allocation on the hot
1068
+ // path, and reading a stream to count it would consume the body the call is about to send. No
1069
+ // size field is worth changing what goes on the wire, and an absent field is honest.
1070
+ //
1071
+ // BYTES, not characters. `String.length` counts UTF-16 code units, so it under-reports every
1072
+ // multi-byte character an embedding payload is full of — CJK text, accented European text and
1073
+ // emoji all send roughly two to four times the bytes it claims — and the field exists to be
1074
+ // compared against a gateway's request-size limit. `Buffer.byteLength` measures the UTF-8 encoding
1075
+ // without allocating a copy of the body.
1076
+ function requestBodyBytes(body) {
1077
+ if (typeof body === "string")
1078
+ return Buffer.byteLength(body, "utf8");
1079
+ if (body instanceof Uint8Array)
1080
+ return body.byteLength;
1081
+ if (body instanceof Blob)
1082
+ return body.size;
1083
+ return undefined;
1084
+ }
1085
+ // THE ATTEMPT LINE — the one this whole file exists for.
1086
+ //
1087
+ // Every other line in this module is written when a call RETURNS. A request that never returns is
1088
+ // exactly the incident being diagnosed (a wedged proxy CONNECT, a gateway that accepts the
1089
+ // connection and then goes quiet), and it produces no completion, no failure, and therefore no
1090
+ // evidence at all: the log stays empty for precisely the window an operator is staring at. This
1091
+ // line is written BEFORE the socket work starts, so a stuck call leaves a `started` with no
1092
+ // matching `completed` — which names both the endpoint and the deadline it is hanging against.
1093
+ //
1094
+ // `info`, not `debug`: a line only readable after an operator has already reproduced the hang
1095
+ // under a raised threshold is not evidence of the hang.
1096
+ function logFetchStarted(log, url, options) {
1097
+ if (!logLevelEnabled(log, "info"))
1098
+ return;
1099
+ log.write({
1100
+ level: "info",
1101
+ category: "http",
1102
+ op: "http.gateway.fetch.started",
1103
+ extra: {
1104
+ endpoint: logEndpointHost(url),
1105
+ method: options.method ?? "GET",
1106
+ requestBytes: requestBodyBytes(options.body),
1107
+ timeoutMs: options.timeoutMs,
1108
+ },
1109
+ });
1110
+ }
1111
+ // THE OUTCOME LINE — `info` for a successful response, `warn` for an answered error.
1112
+ //
1113
+ // A 2xx completion used to be `debug`, which meant that at the default `info` threshold a healthy
1114
+ // outbound request produced NOTHING: the attempt line went out and the log fell silent whether the
1115
+ // request came back in 40ms or never came back at all. That is precisely the distinction an
1116
+ // operator staring at a frozen run needs — "requests are flowing, the gateway is just slow" versus
1117
+ // "nothing is being sent" versus "one request went out and never returned" — and it is unanswerable
1118
+ // from a log that only records failures. The pairing is the evidence: a `started` with a matching
1119
+ // `completed` is a call that returned, and a `started` without one is the wedge.
1120
+ //
1121
+ // The volume is bounded by network round-trips, not by data: one line per outbound HTTP call, on a
1122
+ // path that has just paid TLS and a socket. Genuinely per-item chatter stays at `debug` and behind
1123
+ // `logLevelEnabled` — the route-planning line below (one per call, pure configuration echo, no
1124
+ // news once the deployment is understood) and the circuit breaker's repeat refusals in
1125
+ // `resilience.ts`, which multiply by caller rather than by round-trip.
1126
+ function logFetchCompleted(log, url, response, durationMs) {
1127
+ const level = response.ok ? "info" : "warn";
1128
+ if (!logLevelEnabled(log, level))
1129
+ return;
1130
+ log.write({
1131
+ level,
1132
+ category: "http",
1133
+ op: "http.gateway.fetch.completed",
1134
+ status: response.status,
1135
+ durationMs,
1136
+ extra: { endpoint: logEndpointHost(url) },
1137
+ });
1138
+ }
1139
+ // Outcome line for one outbound gateway call, paired with the attempt line above. `errorKind`
1140
+ // carries the egress taxonomy code verbatim (`PROXY_BLOCKED_BY_POLICY`, `PROXY_UNREACHABLE`,
1141
+ // `TLS_CA_FAILURE`, …), which is how every fail-closed rejection in this module — literal-address
1142
+ // policy, DNS-resolved-to-blocked, redirect target, unpinnable research egress, missing pinned
1143
+ // address, oversized CONNECT header — becomes visible without threading a sink through each
1144
+ // individual guard.
1145
+ export async function gatewayFetch(url, options = {}) {
1146
+ // `logContext` is separated from the transport options here, once, for two reasons: the sink
1147
+ // every line below writes through is bound to its correlation id (see `withCorrelationId`), and
1148
+ // the remaining options are the ones that may reach `RequestInit` — a correlation id must never
1149
+ // travel on the wire.
1150
+ const { logContext, ...fetchOptions } = options;
1151
+ const log = withCorrelationId(resolveLogSink(options.log), logContext?.correlationId);
1152
+ const elapsed = logTimer();
1153
+ logFetchStarted(log, url, options);
1154
+ try {
1155
+ const response = await performGatewayFetch(url, { ...fetchOptions, log });
1156
+ logFetchCompleted(log, url, response, elapsed());
1157
+ return response;
1158
+ }
1159
+ catch (error) {
1160
+ log.write({
1161
+ level: "warn",
1162
+ category: "http",
1163
+ op: "http.gateway.fetch.failed",
1164
+ durationMs: elapsed(),
1165
+ errorKind: logErrorKind(error),
1166
+ extra: { endpoint: logEndpointHost(url) },
1167
+ });
1168
+ throw error;
1169
+ }
1170
+ }
1006
1171
  export async function readJsonCapped(response, maxBytes = MAX_RESPONSE_BYTES) {
1007
1172
  if (response.body === null) {
1008
1173
  return response.json();