@pellux/goodvibes-sdk 0.21.30 → 0.21.34

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 (307) hide show
  1. package/dist/_internal/contracts/zod-schemas/accounts.d.ts +9 -9
  2. package/dist/_internal/contracts/zod-schemas/auth.d.ts +1 -1
  3. package/dist/_internal/daemon/context.d.ts +1 -0
  4. package/dist/_internal/daemon/context.d.ts.map +1 -1
  5. package/dist/_internal/daemon/error-response.js +22 -22
  6. package/dist/_internal/daemon/integration-route-types.d.ts +2 -1
  7. package/dist/_internal/daemon/integration-route-types.d.ts.map +1 -1
  8. package/dist/_internal/daemon/knowledge-routes.js +5 -5
  9. package/dist/_internal/daemon/media-routes.d.ts.map +1 -1
  10. package/dist/_internal/daemon/media-routes.js +4 -3
  11. package/dist/_internal/daemon/operator.d.ts +1 -1
  12. package/dist/_internal/daemon/operator.d.ts.map +1 -1
  13. package/dist/_internal/daemon/operator.js +2 -0
  14. package/dist/_internal/daemon/runtime-route-types.d.ts +2 -1
  15. package/dist/_internal/daemon/runtime-route-types.d.ts.map +1 -1
  16. package/dist/_internal/daemon/runtime-routes.d.ts +1 -1
  17. package/dist/_internal/daemon/runtime-routes.d.ts.map +1 -1
  18. package/dist/_internal/daemon/runtime-routes.js +1 -0
  19. package/dist/_internal/daemon/telemetry-routes.d.ts.map +1 -1
  20. package/dist/_internal/daemon/telemetry-routes.js +13 -12
  21. package/dist/_internal/errors/daemon-error-contract.d.ts +17 -0
  22. package/dist/_internal/errors/daemon-error-contract.d.ts.map +1 -1
  23. package/dist/_internal/errors/daemon-error-contract.js +17 -1
  24. package/dist/_internal/errors/index.d.ts +2 -1
  25. package/dist/_internal/errors/index.d.ts.map +1 -1
  26. package/dist/_internal/errors/index.js +1 -0
  27. package/dist/_internal/platform/artifacts/store.d.ts.map +1 -1
  28. package/dist/_internal/platform/artifacts/store.js +2 -1
  29. package/dist/_internal/platform/automation/scheduler-capacity.d.ts +29 -0
  30. package/dist/_internal/platform/automation/scheduler-capacity.d.ts.map +1 -0
  31. package/dist/_internal/platform/automation/scheduler-capacity.js +31 -0
  32. package/dist/_internal/platform/channels/delivery/shared.d.ts.map +1 -1
  33. package/dist/_internal/platform/channels/delivery/shared.js +3 -2
  34. package/dist/_internal/platform/channels/delivery/strategies-bridge.d.ts.map +1 -1
  35. package/dist/_internal/platform/channels/delivery/strategies-bridge.js +3 -2
  36. package/dist/_internal/platform/channels/delivery/strategies-core.d.ts.map +1 -1
  37. package/dist/_internal/platform/channels/delivery/strategies-core.js +5 -4
  38. package/dist/_internal/platform/channels/delivery/strategies-enterprise.d.ts.map +1 -1
  39. package/dist/_internal/platform/channels/delivery/strategies-enterprise.js +4 -3
  40. package/dist/_internal/platform/config/manager.d.ts.map +1 -1
  41. package/dist/_internal/platform/config/manager.js +2 -1
  42. package/dist/_internal/platform/config/schema-domain-runtime.d.ts +6 -0
  43. package/dist/_internal/platform/config/schema-domain-runtime.d.ts.map +1 -1
  44. package/dist/_internal/platform/config/schema-domain-runtime.js +22 -0
  45. package/dist/_internal/platform/config/schema-types.d.ts +16 -2
  46. package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
  47. package/dist/_internal/platform/config/schema.d.ts.map +1 -1
  48. package/dist/_internal/platform/config/schema.js +1 -0
  49. package/dist/_internal/platform/config/service-registry.d.ts.map +1 -1
  50. package/dist/_internal/platform/config/service-registry.js +2 -1
  51. package/dist/_internal/platform/control-plane/gateway-web-ui.d.ts +0 -1
  52. package/dist/_internal/platform/control-plane/gateway-web-ui.d.ts.map +1 -1
  53. package/dist/_internal/platform/control-plane/gateway-web-ui.js +7 -6
  54. package/dist/_internal/platform/control-plane/session-broker.d.ts.map +1 -1
  55. package/dist/_internal/platform/control-plane/session-broker.js +12 -4
  56. package/dist/_internal/platform/core/orchestrator-tool-runtime.d.ts.map +1 -1
  57. package/dist/_internal/platform/core/orchestrator-tool-runtime.js +6 -6
  58. package/dist/_internal/platform/core/orchestrator-turn-loop.d.ts.map +1 -1
  59. package/dist/_internal/platform/core/orchestrator-turn-loop.js +10 -2
  60. package/dist/_internal/platform/daemon/facade-composition.d.ts +4 -131
  61. package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
  62. package/dist/_internal/platform/daemon/facade-composition.js +9 -10
  63. package/dist/_internal/platform/daemon/facade-types.d.ts +141 -0
  64. package/dist/_internal/platform/daemon/facade-types.d.ts.map +1 -0
  65. package/dist/_internal/platform/daemon/facade-types.js +1 -0
  66. package/dist/_internal/platform/daemon/http/rate-limiter.d.ts +23 -0
  67. package/dist/_internal/platform/daemon/http/rate-limiter.d.ts.map +1 -0
  68. package/dist/_internal/platform/daemon/http/rate-limiter.js +71 -0
  69. package/dist/_internal/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
  70. package/dist/_internal/platform/daemon/http/router-route-contexts.js +2 -1
  71. package/dist/_internal/platform/daemon/http/router.d.ts.map +1 -1
  72. package/dist/_internal/platform/daemon/http/router.js +70 -65
  73. package/dist/_internal/platform/daemon/http/runtime-route-types.d.ts.map +1 -1
  74. package/dist/_internal/platform/daemon/http-listener.d.ts +1 -0
  75. package/dist/_internal/platform/daemon/http-listener.d.ts.map +1 -1
  76. package/dist/_internal/platform/daemon/http-listener.js +53 -73
  77. package/dist/_internal/platform/daemon/surface-delivery.d.ts.map +1 -1
  78. package/dist/_internal/platform/daemon/surface-delivery.js +6 -5
  79. package/dist/_internal/platform/discovery/mcp-scanner.d.ts.map +1 -1
  80. package/dist/_internal/platform/discovery/mcp-scanner.js +28 -22
  81. package/dist/_internal/platform/discovery/scanner.d.ts.map +1 -1
  82. package/dist/_internal/platform/discovery/scanner.js +38 -22
  83. package/dist/_internal/platform/export/session-export.d.ts +0 -1
  84. package/dist/_internal/platform/export/session-export.d.ts.map +1 -1
  85. package/dist/_internal/platform/export/session-export.js +1 -33
  86. package/dist/_internal/platform/hooks/runners/http.d.ts.map +1 -1
  87. package/dist/_internal/platform/hooks/runners/http.js +2 -1
  88. package/dist/_internal/platform/integrations/delivery.d.ts +3 -1
  89. package/dist/_internal/platform/integrations/delivery.d.ts.map +1 -1
  90. package/dist/_internal/platform/integrations/delivery.js +3 -2
  91. package/dist/_internal/platform/integrations/discord.d.ts.map +1 -1
  92. package/dist/_internal/platform/integrations/discord.js +6 -5
  93. package/dist/_internal/platform/integrations/ntfy.d.ts.map +1 -1
  94. package/dist/_internal/platform/integrations/ntfy.js +3 -2
  95. package/dist/_internal/platform/integrations/webhooks.d.ts.map +1 -1
  96. package/dist/_internal/platform/integrations/webhooks.js +2 -1
  97. package/dist/_internal/platform/intelligence/lsp/binary-downloader.d.ts.map +1 -1
  98. package/dist/_internal/platform/intelligence/lsp/binary-downloader.js +4 -3
  99. package/dist/_internal/platform/knowledge/store.d.ts.map +1 -1
  100. package/dist/_internal/platform/knowledge/store.js +50 -25
  101. package/dist/_internal/platform/mcp/client.d.ts.map +1 -1
  102. package/dist/_internal/platform/mcp/client.js +3 -2
  103. package/dist/_internal/platform/media/builtin-generation-providers.d.ts.map +1 -1
  104. package/dist/_internal/platform/media/builtin-generation-providers.js +4 -3
  105. package/dist/_internal/platform/media/builtin-image-understanding.d.ts.map +1 -1
  106. package/dist/_internal/platform/media/builtin-image-understanding.js +5 -4
  107. package/dist/_internal/platform/providers/anthropic-compat.d.ts.map +1 -1
  108. package/dist/_internal/platform/providers/anthropic-compat.js +5 -3
  109. package/dist/_internal/platform/providers/anthropic.d.ts.map +1 -1
  110. package/dist/_internal/platform/providers/anthropic.js +10 -7
  111. package/dist/_internal/platform/providers/builtin-catalog.d.ts.map +1 -1
  112. package/dist/_internal/platform/providers/builtin-catalog.js +3 -2
  113. package/dist/_internal/platform/providers/catalogue.d.ts +56 -0
  114. package/dist/_internal/platform/providers/catalogue.d.ts.map +1 -0
  115. package/dist/_internal/platform/providers/catalogue.js +111 -0
  116. package/dist/_internal/platform/providers/context-discovery.d.ts.map +1 -1
  117. package/dist/_internal/platform/providers/context-discovery.js +2 -1
  118. package/dist/_internal/platform/providers/credentials.d.ts +12 -0
  119. package/dist/_internal/platform/providers/credentials.d.ts.map +1 -0
  120. package/dist/_internal/platform/providers/credentials.js +54 -0
  121. package/dist/_internal/platform/providers/gemini.d.ts.map +1 -1
  122. package/dist/_internal/platform/providers/gemini.js +6 -5
  123. package/dist/_internal/platform/providers/github-copilot.d.ts.map +1 -1
  124. package/dist/_internal/platform/providers/github-copilot.js +2 -1
  125. package/dist/_internal/platform/providers/health.d.ts +15 -0
  126. package/dist/_internal/platform/providers/health.d.ts.map +1 -0
  127. package/dist/_internal/platform/providers/health.js +32 -0
  128. package/dist/_internal/platform/providers/llama-cpp.d.ts.map +1 -1
  129. package/dist/_internal/platform/providers/llama-cpp.js +5 -3
  130. package/dist/_internal/platform/providers/lm-studio.d.ts.map +1 -1
  131. package/dist/_internal/platform/providers/lm-studio.js +5 -3
  132. package/dist/_internal/platform/providers/model-benchmarks.d.ts.map +1 -1
  133. package/dist/_internal/platform/providers/model-benchmarks.js +2 -1
  134. package/dist/_internal/platform/providers/model-catalog-cache.d.ts.map +1 -1
  135. package/dist/_internal/platform/providers/model-catalog-cache.js +2 -1
  136. package/dist/_internal/platform/providers/model-limits.d.ts.map +1 -1
  137. package/dist/_internal/platform/providers/model-limits.js +2 -1
  138. package/dist/_internal/platform/providers/ollama.d.ts.map +1 -1
  139. package/dist/_internal/platform/providers/ollama.js +5 -3
  140. package/dist/_internal/platform/providers/openai-codex.d.ts.map +1 -1
  141. package/dist/_internal/platform/providers/openai-codex.js +4 -2
  142. package/dist/_internal/platform/providers/openai-compat.d.ts.map +1 -1
  143. package/dist/_internal/platform/providers/openai-compat.js +3 -2
  144. package/dist/_internal/platform/providers/provider-not-found-error.d.ts +3 -1
  145. package/dist/_internal/platform/providers/provider-not-found-error.d.ts.map +1 -1
  146. package/dist/_internal/platform/providers/provider-not-found-error.js +3 -4
  147. package/dist/_internal/platform/providers/well-known-endpoints.d.ts +53 -0
  148. package/dist/_internal/platform/providers/well-known-endpoints.d.ts.map +1 -0
  149. package/dist/_internal/platform/providers/well-known-endpoints.js +52 -0
  150. package/dist/_internal/platform/runtime/auth/oauth-core.d.ts.map +1 -1
  151. package/dist/_internal/platform/runtime/auth/oauth-core.js +2 -1
  152. package/dist/_internal/platform/runtime/contracts/index.d.ts.map +1 -1
  153. package/dist/_internal/platform/runtime/contracts/index.js +1 -5
  154. package/dist/_internal/platform/runtime/contracts/migrations/schemas.d.ts +57 -0
  155. package/dist/_internal/platform/runtime/contracts/migrations/schemas.d.ts.map +1 -0
  156. package/dist/_internal/platform/runtime/contracts/migrations/schemas.js +157 -0
  157. package/dist/_internal/platform/runtime/correlation.d.ts +44 -0
  158. package/dist/_internal/platform/runtime/correlation.d.ts.map +1 -0
  159. package/dist/_internal/platform/runtime/correlation.js +40 -0
  160. package/dist/_internal/platform/runtime/emitters/security.d.ts +32 -0
  161. package/dist/_internal/platform/runtime/emitters/security.d.ts.map +1 -1
  162. package/dist/_internal/platform/runtime/emitters/security.js +26 -0
  163. package/dist/_internal/platform/runtime/emitters/tools.d.ts +11 -2
  164. package/dist/_internal/platform/runtime/emitters/tools.d.ts.map +1 -1
  165. package/dist/_internal/platform/runtime/emitters/tools.js +27 -0
  166. package/dist/_internal/platform/runtime/emitters/transport.d.ts +27 -0
  167. package/dist/_internal/platform/runtime/emitters/transport.d.ts.map +1 -1
  168. package/dist/_internal/platform/runtime/emitters/transport.js +19 -0
  169. package/dist/_internal/platform/runtime/emitters/turn.d.ts +22 -1
  170. package/dist/_internal/platform/runtime/emitters/turn.d.ts.map +1 -1
  171. package/dist/_internal/platform/runtime/emitters/turn.js +9 -0
  172. package/dist/_internal/platform/runtime/events/index.d.ts +45 -0
  173. package/dist/_internal/platform/runtime/events/index.d.ts.map +1 -1
  174. package/dist/_internal/platform/runtime/events/index.js +108 -14
  175. package/dist/_internal/platform/runtime/events/ops.d.ts +8 -0
  176. package/dist/_internal/platform/runtime/events/ops.d.ts.map +1 -1
  177. package/dist/_internal/platform/runtime/events/security.d.ts +47 -0
  178. package/dist/_internal/platform/runtime/events/security.d.ts.map +1 -1
  179. package/dist/_internal/platform/runtime/events/tools.d.ts +14 -2
  180. package/dist/_internal/platform/runtime/events/tools.d.ts.map +1 -1
  181. package/dist/_internal/platform/runtime/events/transport.d.ts +31 -0
  182. package/dist/_internal/platform/runtime/events/transport.d.ts.map +1 -1
  183. package/dist/_internal/platform/runtime/events/turn.d.ts +25 -1
  184. package/dist/_internal/platform/runtime/events/turn.d.ts.map +1 -1
  185. package/dist/_internal/platform/runtime/events/workspace.d.ts +16 -0
  186. package/dist/_internal/platform/runtime/events/workspace.d.ts.map +1 -1
  187. package/dist/_internal/platform/runtime/llm-observability.d.ts +43 -0
  188. package/dist/_internal/platform/runtime/llm-observability.d.ts.map +1 -0
  189. package/dist/_internal/platform/runtime/llm-observability.js +107 -0
  190. package/dist/_internal/platform/runtime/metrics.d.ts +49 -0
  191. package/dist/_internal/platform/runtime/metrics.d.ts.map +1 -0
  192. package/dist/_internal/platform/runtime/metrics.js +114 -0
  193. package/dist/_internal/platform/runtime/ops/control-plane.d.ts +5 -2
  194. package/dist/_internal/platform/runtime/ops/control-plane.d.ts.map +1 -1
  195. package/dist/_internal/platform/runtime/ops/control-plane.js +5 -4
  196. package/dist/_internal/platform/runtime/permissions/divergence-dashboard.d.ts +3 -1
  197. package/dist/_internal/platform/runtime/permissions/divergence-dashboard.d.ts.map +1 -1
  198. package/dist/_internal/platform/runtime/permissions/divergence-dashboard.js +3 -2
  199. package/dist/_internal/platform/runtime/permissions/policy-loader.d.ts +3 -1
  200. package/dist/_internal/platform/runtime/permissions/policy-loader.d.ts.map +1 -1
  201. package/dist/_internal/platform/runtime/permissions/policy-loader.js +3 -2
  202. package/dist/_internal/platform/runtime/permissions/policy-signer.d.ts.map +1 -1
  203. package/dist/_internal/platform/runtime/permissions/policy-signer.js +7 -2
  204. package/dist/_internal/platform/runtime/permissions/simulation.d.ts +3 -1
  205. package/dist/_internal/platform/runtime/permissions/simulation.d.ts.map +1 -1
  206. package/dist/_internal/platform/runtime/permissions/simulation.js +3 -2
  207. package/dist/_internal/platform/runtime/remote/transport-contract.d.ts +14 -2
  208. package/dist/_internal/platform/runtime/remote/transport-contract.d.ts.map +1 -1
  209. package/dist/_internal/platform/runtime/remote/transport-contract.js +7 -5
  210. package/dist/_internal/platform/runtime/store/helpers/reducers/sync.d.ts.map +1 -1
  211. package/dist/_internal/platform/runtime/store/helpers/reducers/sync.js +12 -1
  212. package/dist/_internal/platform/runtime/tasks/manager.d.ts +7 -3
  213. package/dist/_internal/platform/runtime/tasks/manager.d.ts.map +1 -1
  214. package/dist/_internal/platform/runtime/tasks/manager.js +7 -6
  215. package/dist/_internal/platform/runtime/telemetry/api-helpers.d.ts +14 -0
  216. package/dist/_internal/platform/runtime/telemetry/api-helpers.d.ts.map +1 -1
  217. package/dist/_internal/platform/runtime/telemetry/api-helpers.js +59 -0
  218. package/dist/_internal/platform/runtime/telemetry/api.d.ts.map +1 -1
  219. package/dist/_internal/platform/runtime/telemetry/api.js +9 -2
  220. package/dist/_internal/platform/runtime/telemetry/exporters/otlp.d.ts.map +1 -1
  221. package/dist/_internal/platform/runtime/telemetry/exporters/otlp.js +19 -6
  222. package/dist/_internal/platform/runtime/telemetry/exporters/queue.d.ts.map +1 -1
  223. package/dist/_internal/platform/runtime/telemetry/exporters/queue.js +11 -4
  224. package/dist/_internal/platform/runtime/telemetry/meter.d.ts.map +1 -1
  225. package/dist/_internal/platform/runtime/telemetry/meter.js +7 -3
  226. package/dist/_internal/platform/runtime/telemetry/redaction-config.d.ts +9 -0
  227. package/dist/_internal/platform/runtime/telemetry/redaction-config.d.ts.map +1 -0
  228. package/dist/_internal/platform/runtime/telemetry/redaction-config.js +52 -0
  229. package/dist/_internal/platform/runtime/tools/phases/budget.d.ts.map +1 -1
  230. package/dist/_internal/platform/runtime/tools/phases/budget.js +3 -2
  231. package/dist/_internal/platform/runtime/transports/daemon-http-client.d.ts.map +1 -1
  232. package/dist/_internal/platform/runtime/transports/daemon-http-client.js +138 -17
  233. package/dist/_internal/platform/scheduler/scheduler.d.ts.map +1 -1
  234. package/dist/_internal/platform/scheduler/scheduler.js +6 -2
  235. package/dist/_internal/platform/sessions/manager.d.ts.map +1 -1
  236. package/dist/_internal/platform/sessions/manager.js +6 -2
  237. package/dist/_internal/platform/state/memory-embedding-http.d.ts.map +1 -1
  238. package/dist/_internal/platform/state/memory-embedding-http.js +3 -2
  239. package/dist/_internal/platform/state/project-index.d.ts.map +1 -1
  240. package/dist/_internal/platform/state/project-index.js +6 -4
  241. package/dist/_internal/platform/tools/agent/index.d.ts.map +1 -1
  242. package/dist/_internal/platform/tools/agent/index.js +2 -1
  243. package/dist/_internal/platform/tools/analyze/git-modes.d.ts.map +1 -1
  244. package/dist/_internal/platform/tools/analyze/git-modes.js +2 -1
  245. package/dist/_internal/platform/tools/edit/core.d.ts.map +1 -1
  246. package/dist/_internal/platform/tools/edit/core.js +2 -1
  247. package/dist/_internal/platform/tools/exec/runtime.d.ts.map +1 -1
  248. package/dist/_internal/platform/tools/exec/runtime.js +3 -2
  249. package/dist/_internal/platform/tools/fetch/runtime.d.ts.map +1 -1
  250. package/dist/_internal/platform/tools/fetch/runtime.js +4 -2
  251. package/dist/_internal/platform/tools/read/index.d.ts.map +1 -1
  252. package/dist/_internal/platform/tools/read/index.js +2 -1
  253. package/dist/_internal/platform/tools/registry-tool/index.d.ts.map +1 -1
  254. package/dist/_internal/platform/tools/registry-tool/index.js +2 -1
  255. package/dist/_internal/platform/tools/state/index.d.ts.map +1 -1
  256. package/dist/_internal/platform/tools/state/index.js +2 -1
  257. package/dist/_internal/platform/tools/task/index.d.ts.map +1 -1
  258. package/dist/_internal/platform/tools/task/index.js +2 -1
  259. package/dist/_internal/platform/tools/team/index.d.ts.map +1 -1
  260. package/dist/_internal/platform/tools/team/index.js +2 -1
  261. package/dist/_internal/platform/tools/web-search/index.d.ts.map +1 -1
  262. package/dist/_internal/platform/tools/web-search/index.js +2 -1
  263. package/dist/_internal/platform/tools/worklist/index.d.ts.map +1 -1
  264. package/dist/_internal/platform/tools/worklist/index.js +2 -1
  265. package/dist/_internal/platform/types/errors.d.ts +12 -10
  266. package/dist/_internal/platform/types/errors.d.ts.map +1 -1
  267. package/dist/_internal/platform/types/errors.js +21 -20
  268. package/dist/_internal/platform/utils/error-display.d.ts.map +1 -1
  269. package/dist/_internal/platform/utils/error-display.js +6 -4
  270. package/dist/_internal/platform/utils/fetch-with-timeout.d.ts +17 -0
  271. package/dist/_internal/platform/utils/fetch-with-timeout.d.ts.map +1 -1
  272. package/dist/_internal/platform/utils/fetch-with-timeout.js +59 -0
  273. package/dist/_internal/platform/utils/record-coerce.d.ts +11 -0
  274. package/dist/_internal/platform/utils/record-coerce.d.ts.map +1 -0
  275. package/dist/_internal/platform/utils/record-coerce.js +12 -0
  276. package/dist/_internal/platform/utils/redaction.js +1 -1
  277. package/dist/_internal/platform/utils/ring-buffer.d.ts +54 -0
  278. package/dist/_internal/platform/utils/ring-buffer.d.ts.map +1 -0
  279. package/dist/_internal/platform/utils/ring-buffer.js +96 -0
  280. package/dist/_internal/platform/utils/shell-split.d.ts +11 -0
  281. package/dist/_internal/platform/utils/shell-split.d.ts.map +1 -0
  282. package/dist/_internal/platform/utils/shell-split.js +83 -0
  283. package/dist/_internal/platform/version.js +1 -1
  284. package/dist/_internal/platform/voice/providers/deepgram.d.ts.map +1 -1
  285. package/dist/_internal/platform/voice/providers/deepgram.js +2 -1
  286. package/dist/_internal/platform/voice/providers/elevenlabs.d.ts.map +1 -1
  287. package/dist/_internal/platform/voice/providers/elevenlabs.js +5 -4
  288. package/dist/_internal/platform/voice/providers/google.d.ts.map +1 -1
  289. package/dist/_internal/platform/voice/providers/google.js +5 -4
  290. package/dist/_internal/platform/voice/providers/microsoft.d.ts.map +1 -1
  291. package/dist/_internal/platform/voice/providers/microsoft.js +2 -1
  292. package/dist/_internal/platform/voice/providers/openai.d.ts.map +1 -1
  293. package/dist/_internal/platform/voice/providers/openai.js +4 -3
  294. package/dist/_internal/platform/voice/providers/shared.d.ts.map +1 -1
  295. package/dist/_internal/platform/voice/providers/shared.js +2 -1
  296. package/dist/_internal/platform/voice/providers/vydra.d.ts.map +1 -1
  297. package/dist/_internal/platform/voice/providers/vydra.js +3 -2
  298. package/dist/_internal/platform/watchers/registry.d.ts.map +1 -1
  299. package/dist/_internal/platform/watchers/registry.js +3 -2
  300. package/dist/_internal/platform/workflow/trigger-executor.d.ts.map +1 -1
  301. package/dist/_internal/platform/workflow/trigger-executor.js +5 -3
  302. package/dist/_internal/platform/workspace/daemon-home.d.ts.map +1 -1
  303. package/dist/_internal/platform/workspace/daemon-home.js +6 -2
  304. package/dist/_internal/platform/workspace/workspace-swap-manager.d.ts +1 -0
  305. package/dist/_internal/platform/workspace/workspace-swap-manager.d.ts.map +1 -1
  306. package/dist/_internal/platform/workspace/workspace-swap-manager.js +14 -2
  307. package/package.json +1 -1
@@ -7,7 +7,9 @@
7
7
  * ```
8
8
  */
9
9
  import { logger } from '../../utils/logger.js';
10
+ import { createEventEnvelope } from './envelope.js';
10
11
  import { summarizeError } from '../../utils/error-display.js';
12
+ import { listenerErrorsTotal } from '../metrics.js';
11
13
  export { createEventEnvelope } from './envelope.js';
12
14
  export { RUNTIME_EVENT_DOMAINS, isRuntimeEventDomain } from './domain-map.js';
13
15
  export { AUTOMATION_SCHEDULE_KINDS, AUTOMATION_RUN_OUTCOMES } from './automation.js';
@@ -23,7 +25,15 @@ export { SURFACE_KINDS } from './surfaces.js';
23
25
  * rarely exceeds single-digit listeners. Exceeding this strongly suggests a
24
26
  * subscriber is being registered without a corresponding unsubscribe.
25
27
  */
26
- const MAX_LISTENERS = 100;
28
+ export const MAX_LISTENERS = 100;
29
+ /** Extract a plain string error message from an unknown thrown value. */
30
+ function extractErrorMessage(err) {
31
+ if (err instanceof Error)
32
+ return err.message;
33
+ if (typeof err === 'string')
34
+ return err;
35
+ return summarizeError(err);
36
+ }
27
37
  /**
28
38
  * RuntimeEventBus — typed event bus for domain-structured runtime events.
29
39
  *
@@ -41,6 +51,15 @@ export class RuntimeEventBus {
41
51
  _listeners = new Map();
42
52
  /** Per-domain listener sets. Keyed by RuntimeEventDomain. */
43
53
  _domainListeners = new Map();
54
+ /** Effective listener cap for this instance. */
55
+ _maxListeners;
56
+ /** Track per-listener error counts for misbehaving-listener dedup. */
57
+ _listenerErrorCounts = new WeakMap();
58
+ /** Number of errors a listener must throw before OPS_LISTENER_MISBEHAVING is emitted. */
59
+ static _MISBEHAVE_DEDUP_THRESHOLD = 1;
60
+ constructor(opts) {
61
+ this._maxListeners = opts?.maxListeners ?? MAX_LISTENERS;
62
+ }
44
63
  /**
45
64
  * Subscribe to a specific event type.
46
65
  *
@@ -54,11 +73,18 @@ export class RuntimeEventBus {
54
73
  }
55
74
  const set = this._listeners.get(eventType);
56
75
  set.add(callback);
57
- if (set.size > MAX_LISTENERS) {
76
+ if (set.size > this._maxListeners) {
77
+ if (process.env['NODE_ENV'] === 'development') {
78
+ // Remove the just-added listener before throwing to maintain state consistency.
79
+ set.delete(callback);
80
+ if (set.size === 0)
81
+ this._listeners.delete(eventType);
82
+ throw new RangeError(`[RuntimeEventBus] listener cap exceeded — maxListeners=${this._maxListeners} eventType=${String(eventType)}`);
83
+ }
58
84
  logger.warn('[RuntimeEventBus] possible listener leak detected', {
59
85
  eventType,
60
86
  count: set.size,
61
- max: MAX_LISTENERS,
87
+ max: this._maxListeners,
62
88
  });
63
89
  }
64
90
  return () => this._off(eventType, callback);
@@ -76,11 +102,18 @@ export class RuntimeEventBus {
76
102
  }
77
103
  const set = this._domainListeners.get(domain);
78
104
  set.add(callback);
79
- if (set.size > MAX_LISTENERS) {
105
+ if (set.size > this._maxListeners) {
106
+ if (process.env['NODE_ENV'] === 'development') {
107
+ // Remove the just-added listener before throwing to maintain state consistency.
108
+ set.delete(callback);
109
+ if (set.size === 0)
110
+ this._domainListeners.delete(domain);
111
+ throw new RangeError(`[RuntimeEventBus] domain listener cap exceeded — maxListeners=${this._maxListeners} domain=${String(domain)}`);
112
+ }
80
113
  logger.warn('[RuntimeEventBus] possible domain listener leak detected', {
81
114
  domain,
82
115
  count: set.size,
83
- max: MAX_LISTENERS,
116
+ max: this._maxListeners,
84
117
  });
85
118
  }
86
119
  return () => this._offDomain(domain, callback);
@@ -105,10 +138,7 @@ export class RuntimeEventBus {
105
138
  h(ev);
106
139
  }
107
140
  catch (err) {
108
- logger.error('[RuntimeEventBus] listener error', {
109
- eventType: evType,
110
- error: summarizeError(err),
111
- });
141
+ this._recordListenerError(h, evType, err);
112
142
  }
113
143
  });
114
144
  }
@@ -123,15 +153,79 @@ export class RuntimeEventBus {
123
153
  h(ev);
124
154
  }
125
155
  catch (err) {
126
- logger.error('[RuntimeEventBus] domain listener error', {
127
- domain: d,
128
- eventType: evType,
129
- error: summarizeError(err),
130
- });
156
+ this._recordListenerError(h, evType, err, String(d));
131
157
  }
132
158
  });
133
159
  }
134
160
  }
161
+ /**
162
+ * Record a listener error: increment metrics, update error count, emit
163
+ * OPS_LISTENER_MISBEHAVING once the dedup threshold is reached, and log.
164
+ *
165
+ * @param listener - The misbehaving listener function.
166
+ * @param eventType - The event type that triggered the listener.
167
+ * @param err - The thrown value caught from the listener.
168
+ * @param domain - Optional domain name, present when the listener was a domain subscriber.
169
+ */
170
+ _recordListenerError(listener, eventType, err, domain) {
171
+ const errMsg = extractErrorMessage(err);
172
+ listenerErrorsTotal.add(1, { event_type: eventType });
173
+ const prev = this._listenerErrorCounts.get(listener) ?? 0;
174
+ const next = prev + 1;
175
+ this._listenerErrorCounts.set(listener, next);
176
+ if (next === RuntimeEventBus._MISBEHAVE_DEDUP_THRESHOLD) {
177
+ this._emitListenerMisbehaving(listener, String(eventType), errMsg, next);
178
+ }
179
+ if (domain !== undefined) {
180
+ logger.error('[RuntimeEventBus] domain listener error', {
181
+ domain,
182
+ eventType,
183
+ error: summarizeError(err),
184
+ });
185
+ }
186
+ else {
187
+ logger.error('[RuntimeEventBus] listener error', {
188
+ eventType,
189
+ error: summarizeError(err),
190
+ });
191
+ }
192
+ }
193
+ /**
194
+ * Directly dispatch an OPS_LISTENER_MISBEHAVING envelope to any registered
195
+ * OPS_LISTENER_MISBEHAVING and 'ops' domain listeners.
196
+ *
197
+ * Bypasses emit() to avoid potential recursion: a listener watching for
198
+ * misbehaving events itself misbehaving would otherwise cause infinite loops.
199
+ */
200
+ _emitListenerMisbehaving(listener, eventType, errorMessage, errorCount) {
201
+ const payload = {
202
+ type: 'OPS_LISTENER_MISBEHAVING',
203
+ listenerId: listener.name || '(anonymous)',
204
+ eventType,
205
+ errorMessage,
206
+ errorCount,
207
+ };
208
+ const envelope = createEventEnvelope('OPS_LISTENER_MISBEHAVING', payload, { sessionId: 'runtime-bus', source: 'runtime-bus' });
209
+ // Dispatch directly — no queueMicrotask, no recursion path through emit().
210
+ const typeListeners = this._listeners.get('OPS_LISTENER_MISBEHAVING');
211
+ if (typeListeners) {
212
+ for (const h of Array.from(typeListeners)) {
213
+ try {
214
+ h(envelope);
215
+ }
216
+ catch { /* suppress secondary errors */ }
217
+ }
218
+ }
219
+ const domainListeners = this._domainListeners.get('ops');
220
+ if (domainListeners) {
221
+ for (const h of Array.from(domainListeners)) {
222
+ try {
223
+ h(envelope);
224
+ }
225
+ catch { /* suppress secondary errors */ }
226
+ }
227
+ }
228
+ }
135
229
  _off(eventType, callback) {
136
230
  const set = this._listeners.get(eventType);
137
231
  set?.delete(callback);
@@ -76,6 +76,14 @@ export type OpsEvent =
76
76
  note?: string;
77
77
  outcome: 'success' | 'rejected' | 'error';
78
78
  errorMessage?: string;
79
+ }
80
+ /** A subscriber threw an error during event dispatch; emitted after dedup threshold. */
81
+ | {
82
+ type: 'OPS_LISTENER_MISBEHAVING';
83
+ listenerId: string;
84
+ eventType: string;
85
+ errorMessage: string;
86
+ errorCount: number;
79
87
  };
80
88
  /** All ops event type literals as a union. */
81
89
  export type OpsEventType = OpsEvent['type'];
@@ -1 +1 @@
1
- {"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/ops.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;GAMG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,kBAAkB,CAAC;AAEvB,MAAM,MAAM,QAAQ;AAClB,iDAAiD;AAC/C;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AACH,iDAAiD;GAC/C;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AACH,8CAA8C;GAC5C;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AACH,mDAAmD;GACjD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AACH,+DAA+D;GAC7D;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AACH,uCAAuC;GACrC;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AACH,mDAAmD;GACjD;IACE,IAAI,EAAE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,OAAO,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AACH,wFAAwF;GACtF;IACE,IAAI,EAAE,0BAA0B,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC"}
@@ -38,6 +38,53 @@ export type SecurityEvent =
38
38
  tokenId: string;
39
39
  label: string;
40
40
  reason: 'scope_violation' | 'rotation_overdue' | 'scope_violation_and_rotation_overdue';
41
+ }
42
+ /** Emitted when a user authenticates successfully. Never includes credentials. */
43
+ | {
44
+ type: 'AUTH_SUCCEEDED';
45
+ /** Authenticated username (display-safe). */
46
+ username: string;
47
+ /** Session token ID (not the token value). */
48
+ sessionId: string;
49
+ /** Client IP address. */
50
+ clientIp: string;
51
+ /** Authentication method used. */
52
+ method: 'password' | 'cookie' | 'token';
53
+ }
54
+ /** Emitted when an authentication attempt fails. Never includes credential values. */
55
+ | {
56
+ type: 'AUTH_FAILED';
57
+ /** The username that was attempted (may be blank or spoofed). */
58
+ usernameAttempted: string;
59
+ /** Client IP address. */
60
+ clientIp: string;
61
+ /** Machine-readable failure reason. */
62
+ reason: 'invalid_credentials' | 'rate_limited' | 'session_expired' | 'origin_denied' | 'unknown';
63
+ }
64
+ /** Emitted when a companion pairing request is initiated. */
65
+ | {
66
+ type: 'COMPANION_PAIR_REQUESTED';
67
+ clientIp: string;
68
+ }
69
+ /** Emitted when a companion pairing is successfully verified. */
70
+ | {
71
+ type: 'COMPANION_PAIR_VERIFIED';
72
+ /** Opaque token ID (not the token value). */
73
+ tokenId: string;
74
+ clientIp: string;
75
+ }
76
+ /** Emitted when a companion token is rotated. */
77
+ | {
78
+ type: 'COMPANION_TOKEN_ROTATED';
79
+ /** New opaque token ID (not the token value). */
80
+ newTokenId: string;
81
+ clientIp: string;
82
+ }
83
+ /** Emitted when a companion token is revoked. */
84
+ | {
85
+ type: 'COMPANION_TOKEN_REVOKED';
86
+ clientIp: string;
87
+ reason?: string;
41
88
  };
42
89
  /** All security event type literals as a union. */
43
90
  export type SecurityEventType = SecurityEvent['type'];
@@ -1 +1 @@
1
- {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/security.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,aAAa;AACvB,0EAA0E;AACxE;IACE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AACH,+EAA+E;GAC7E;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AACH,sEAAsE;GACpE;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AACH,+DAA+D;GAC7D;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,sCAAsC,CAAC;CACzF,CAAC;AAEN,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources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AyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,MAAM,EAAE,qBAAqB,GAAG,cAAc,GAAG,iBAAiB,GAAG,eAAe,GAAG,SAAS,CAAC;CAClG;AAEH,6DAA6D;GAC3D;IACE,IAAI,EAAE,0BAA0B,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AACH,iEAAiE;GAC/D;IACE,IAAI,EAAE,yBAAyB,CAAC;IAChC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AACH,iDAAiD;GAC/C;IACE,IAAI,EAAE,yBAAyB,CAAC;IAChC,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AACH,iDAAiD;GAC/C;IACE,IAAI,EAAE,yBAAyB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC"}
@@ -4,6 +4,18 @@
4
4
  *
5
5
  * Covers tool execution lifecycle events for the runtime event bus.
6
6
  */
7
+ /**
8
+ * OBS-05: Structured summary of a tool result — avoids leaking raw `unknown` payloads
9
+ * into the event stream while still providing enough context for observability.
10
+ */
11
+ export interface ToolResultSummary {
12
+ /** Discriminant for the result shape (e.g. 'text', 'json', 'error', 'binary'). */
13
+ kind: string;
14
+ /** Approximate byte size of the raw result. */
15
+ byteSize: number;
16
+ /** Optional short preview (first N chars, no credentials). */
17
+ preview?: string;
18
+ }
7
19
  export type ToolEvent =
8
20
  /** A tool call request was received from the LLM. */
9
21
  {
@@ -64,7 +76,7 @@ export type ToolEvent =
64
76
  turnId: string;
65
77
  tool: string;
66
78
  durationMs: number;
67
- result?: unknown;
79
+ result?: ToolResultSummary;
68
80
  }
69
81
  /** Tool call failed with an error. */
70
82
  | {
@@ -74,7 +86,7 @@ export type ToolEvent =
74
86
  tool: string;
75
87
  error: string;
76
88
  durationMs: number;
77
- result?: unknown;
89
+ result?: ToolResultSummary;
78
90
  }
79
91
  /** Tool results were synthesized to reconcile unresolved calls. */
80
92
  | {
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/tools.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;GAIG;AAEH,MAAM,MAAM,SAAS;AACnB,qDAAqD;AACnD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE;AACxG,oDAAoD;GAClD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC1E,uDAAuD;GACrD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC1E,oDAAoD;GAClD;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAChG,kCAAkC;GAChC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC7F,gEAAgE;GAC9D;IAAE,IAAI,EAA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AAoB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,GACD;IACE,IAAI,EAAE,sBAAsB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/tools.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,SAAS;AACnB,qDAAqD;AACnD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAA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C;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC"}
@@ -52,6 +52,37 @@ export type TransportEvent =
52
52
  type: 'TRANSPORT_TERMINAL_FAILURE';
53
53
  transportId: string;
54
54
  error: string;
55
+ }
56
+ /** OBS-18: A retry has been scheduled after a transient failure. */
57
+ | {
58
+ type: 'TRANSPORT_RETRY_SCHEDULED';
59
+ transportId: string;
60
+ attempt: number;
61
+ maxAttempts: number;
62
+ backoffMs: number;
63
+ reason: string;
64
+ }
65
+ /** OBS-18: A scheduled retry is now being executed. */
66
+ | {
67
+ type: 'TRANSPORT_RETRY_EXECUTED';
68
+ transportId: string;
69
+ attempt: number;
70
+ maxAttempts: number;
71
+ }
72
+ /** OBS-19: An SSE subscriber connected to the event stream. */
73
+ | {
74
+ type: 'STREAM_SUBSCRIBER_CONNECTED';
75
+ streamId: string;
76
+ subscriberId: string;
77
+ streamType: string;
78
+ }
79
+ /** OBS-19: An SSE subscriber disconnected from the event stream. */
80
+ | {
81
+ type: 'STREAM_SUBSCRIBER_DISCONNECTED';
82
+ streamId: string;
83
+ subscriberId: string;
84
+ streamType: string;
85
+ reason?: string;
55
86
  };
56
87
  /** All transport event type literals as a union. */
57
88
  export type TransportEventType = TransportEvent['type'];
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/transport.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;GAIG;AAEH,MAAM,MAAM,cAAc;AACxB,4CAA4C;AAC1C;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AAC3E,4DAA4D;GAC1D;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AM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AACrG,oEAAoE;GAClE;IAAE,IAAI,EAAE,gCAAgC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5H,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC"}
@@ -43,18 +43,42 @@ export type TurnEvent =
43
43
  type: 'STREAM_END';
44
44
  turnId: string;
45
45
  }
46
+ /** OBS-04: An LLM request is about to be dispatched to the provider. */
47
+ | {
48
+ type: 'LLM_REQUEST_STARTED';
49
+ turnId: string;
50
+ provider: string;
51
+ model: string;
52
+ /** Redacted prompt summary: {length, sha256, first100chars} unless telemetry.includeRawPrompts is true. */
53
+ promptSummary: {
54
+ length: number;
55
+ sha256: string;
56
+ first100chars: string;
57
+ } | string;
58
+ }
46
59
  /** A provider chat call completed within the current turn iteration. */
47
60
  | {
48
61
  type: 'LLM_RESPONSE_RECEIVED';
49
62
  turnId: string;
50
63
  provider: string;
51
64
  model: string;
52
- content: string;
65
+ /** Redacted response summary: {length, sha256, first100chars} unless telemetry.includeRawPrompts is true. */
66
+ contentSummary: {
67
+ length: number;
68
+ sha256: string;
69
+ first100chars: string;
70
+ } | string;
53
71
  toolCallCount: number;
54
72
  inputTokens: number;
55
73
  outputTokens: number;
56
74
  cacheReadTokens?: number;
57
75
  cacheWriteTokens?: number;
76
+ /** OBS-04 enrichments */
77
+ durationMs?: number;
78
+ retries?: number;
79
+ costUsdCents?: number;
80
+ finishReason?: string;
81
+ providerRequestId?: string;
58
82
  }
59
83
  /** A batch of tool calls is ready for execution. */
60
84
  | {
@@ -1 +1 @@
1
- {"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/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CAAC;IAAC,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,WAAW,GAAG,gBAAgB,CAAC,CAAA;CAAE;AACnI,iCAAiC;GAC/B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,WAAW,GAAG,gBAAgB,GAAG,WAAW,CAAC,CAAA;CAAE;AAC1I,gDAAgD;GAC9C;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;CAAE,CAAC;AAE/G,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC"}
@@ -51,6 +51,22 @@ export type WorkspaceEvent =
51
51
  sourcePath: string;
52
52
  /** Human-readable reason (e.g. JSON parse error message). */
53
53
  reason: string;
54
+ }
55
+ /**
56
+ * Emitted when a workspace swap fails (mkdir or rerootStores threw).
57
+ * Any subscriber that saw WORKSPACE_SWAP_STARTED without a subsequent
58
+ * WORKSPACE_SWAP_COMPLETED should watch for this event. (OBS-08)
59
+ */
60
+ | {
61
+ type: 'WORKSPACE_SWAP_FAILED';
62
+ /** Original working directory (swap source). */
63
+ from: string;
64
+ /** Target path that was attempted. */
65
+ to: string;
66
+ /** Machine-readable failure code. */
67
+ code: 'INVALID_PATH' | 'REROOT_FAILED' | 'UNKNOWN';
68
+ /** Human-readable reason. */
69
+ reason: string;
54
70
  };
55
71
  export type WorkspaceEventType = WorkspaceEvent['type'];
56
72
  //# sourceMappingURL=workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/workspace.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;GAKG;AAEH,MAAM,MAAM,cAAc;AACxB,4DAA4D;AAC1D;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AACH,iFAAiF;GAC/E;IACE,IAAI,EAAE,0BAA0B,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,kEAAkE;IAClE,yBAAyB,EAAE,OAAO,CAAC;CACpC;AACH,sFAAsF;GACpF;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;CACpB;AACH;;;GAGG;GACD;IACE,IAAI,EAAE,6BAA6B,CAAC;IACpC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;CACZ;AACH;;;GAGG;GACD;IACE,IAAI,EAAE,qCAAqC,CAAC;IAC5C,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/runtime/events/workspace.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;GAKG;AAEH,MAAM,MAAM,cAAc;AACxB,4DAA4D;AAC1D;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AACH,iFAAiF;GAC/E;IACE,IAAI,EAAE,0BAA0B,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,kEAAkE;IAClE,yBAAyB,EAAE,OAAO,CAAC;CACpC;AACH,sFAAsF;GACpF;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;CACpB;AACH;;;GAGG;GACD;IACE,IAAI,EAAE,6BAA6B,CAAC;IACpC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;CACZ;AACH;;;GAGG;GACD;IACE,IAAI,EAAE,qCAAqC,CAAC;IAC5C,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB;AACH;;;;GAIG;GACD;IACE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,IAAI,EAAE,cAAc,GAAG,eAAe,GAAG,SAAS,CAAC;IACnD,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ /** Structured prompt summary emitted in telemetry events (default: redacted). */
2
+ export interface PromptSummary {
3
+ /** Byte length of the raw content. */
4
+ length: number;
5
+ /** SHA-256 hex digest of the raw content (for deduplication without exposure). */
6
+ sha256: string;
7
+ /** First 100 chars of the raw content (safe preview). */
8
+ first100chars: string;
9
+ }
10
+ /**
11
+ * OBS-06: Summarize prompt/response content for telemetry emission.
12
+ * When includeRawPrompts is true, returns the raw string.
13
+ * Default (false): returns a PromptSummary with length, sha256, first100chars.
14
+ */
15
+ export declare function summarizePromptContent(content: string, includeRaw: boolean): PromptSummary | string;
16
+ /**
17
+ * OBS-04: Result from an instrumented LLM call.
18
+ * Adds durationMs and retries tracking to the provider response.
19
+ */
20
+ export interface InstrumentedLlmResult<T> {
21
+ result: T;
22
+ durationMs: number;
23
+ retries: number;
24
+ }
25
+ export declare function instrumentedLlmCall<T>(fn: () => Promise<T>, opts?: {
26
+ maxRetries?: number;
27
+ retryDelayMs?: number;
28
+ /** Provider name for metric labels (e.g. 'anthropic'). */
29
+ provider?: string;
30
+ /** Model name for metric labels (e.g. 'claude-opus-4-5'). */
31
+ model?: string;
32
+ /** Extract token usage from a successful result to record histogram instruments. */
33
+ extractTokens?: (result: T) => {
34
+ inputTokens?: number;
35
+ outputTokens?: number;
36
+ } | undefined;
37
+ /**
38
+ * M-2: Optional callback invoked on entry before the first attempt.
39
+ * Callers that have bus/ctx access can wire emitLlmRequestStarted here.
40
+ */
41
+ onStarted?: () => void;
42
+ }): Promise<InstrumentedLlmResult<T>>;
43
+ //# sourceMappingURL=llm-observability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-observability.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/runtime/llm-observability.ts"],"names":[],"mappings":"AAiBA,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,OAAO,GAClB,aAAa,GAAG,MAAM,CAOxB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AA+BD,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,CAAC,EAAE;IACL,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3F;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,GACA,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAkDnC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * OBS-04/OBS-06: LLM observability utilities.
3
+ *
4
+ * Provides:
5
+ * - Prompt/response content summarization for redaction-by-default telemetry
6
+ * - instrumentedLlmCall() wrapper that emits LLM_REQUEST_STARTED + enriched LLM_RESPONSE_RECEIVED
7
+ * - includeRawPrompts config awareness
8
+ */
9
+ import { createHash } from 'node:crypto';
10
+ import { llmRequestsTotal, llmRequestDurationMs, llmTokensInput, llmTokensOutput, llmRequestsStarted, } from './metrics.js';
11
+ /**
12
+ * OBS-06: Summarize prompt/response content for telemetry emission.
13
+ * When includeRawPrompts is true, returns the raw string.
14
+ * Default (false): returns a PromptSummary with length, sha256, first100chars.
15
+ */
16
+ export function summarizePromptContent(content, includeRaw) {
17
+ if (includeRaw)
18
+ return content;
19
+ return {
20
+ length: content.length,
21
+ sha256: createHash('sha256').update(content).digest('hex'),
22
+ first100chars: content.slice(0, 100),
23
+ };
24
+ }
25
+ /**
26
+ * OBS-04: Wrap any LLM provider call to track duration, retry count, and
27
+ * record platformMeter instruments (llmRequestsTotal, llmRequestDurationMs,
28
+ * llmTokensInput, llmTokensOutput).
29
+ *
30
+ * Providers wrap their .chat() / .generate() calls with this helper.
31
+ *
32
+ * Usage:
33
+ * ```ts
34
+ * const { result, durationMs, retries } = await instrumentedLlmCall(
35
+ * async () => await this.chat(params),
36
+ * { provider: this.name, model: params.model ?? this.defaultModel },
37
+ * );
38
+ * ```
39
+ */
40
+ /**
41
+ * OBS-04: Emit LLM_REQUEST_STARTED metric at the llm-observability layer.
42
+ *
43
+ * Records the llmRequestsStarted counter so callers without bus access still
44
+ * get per-provider/model observability. Callers that also hold a RuntimeEventBus
45
+ * should additionally call emitLlmRequestStarted(bus, ctx, data) from emitters/turn.
46
+ */
47
+ function recordLlmRequestStartedMetric(opts) {
48
+ const labels = {};
49
+ if (opts.provider)
50
+ labels.provider = opts.provider;
51
+ if (opts.model)
52
+ labels.model = opts.model;
53
+ llmRequestsStarted.add(1, labels);
54
+ }
55
+ export async function instrumentedLlmCall(fn, opts) {
56
+ const maxRetries = opts?.maxRetries ?? 0;
57
+ const retryDelayMs = opts?.retryDelayMs ?? 0;
58
+ const startedAt = Date.now();
59
+ // Auto-emit LLM_REQUEST_STARTED metric on entry (no bus required)
60
+ recordLlmRequestStartedMetric({ provider: opts?.provider, model: opts?.model });
61
+ // M-2: fire onStarted callback if provided (e.g. to emit LLM_REQUEST_STARTED on the event bus)
62
+ opts?.onStarted?.();
63
+ let lastError;
64
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
65
+ try {
66
+ const result = await fn();
67
+ const durationMs = Date.now() - startedAt;
68
+ // C-1: record LLM metric instruments
69
+ if (opts?.provider !== undefined || opts?.model !== undefined) {
70
+ const labels = {};
71
+ if (opts.provider)
72
+ labels.provider = opts.provider;
73
+ if (opts.model)
74
+ labels.model = opts.model;
75
+ llmRequestsTotal.add(1, { ...labels, status: 'success' });
76
+ llmRequestDurationMs.record(durationMs, labels);
77
+ if (opts.extractTokens) {
78
+ const tokens = opts.extractTokens(result);
79
+ if (tokens?.inputTokens !== undefined && tokens.inputTokens > 0) {
80
+ llmTokensInput.record(tokens.inputTokens, labels);
81
+ }
82
+ if (tokens?.outputTokens !== undefined && tokens.outputTokens > 0) {
83
+ llmTokensOutput.record(tokens.outputTokens, labels);
84
+ }
85
+ }
86
+ }
87
+ return { result, durationMs, retries: attempt };
88
+ }
89
+ catch (err) {
90
+ lastError = err;
91
+ if (attempt < maxRetries && retryDelayMs > 0) {
92
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
93
+ }
94
+ }
95
+ }
96
+ // Record error metric on final failure
97
+ if (opts?.provider !== undefined || opts?.model !== undefined) {
98
+ const labels = {};
99
+ if (opts?.provider)
100
+ labels.provider = opts.provider;
101
+ if (opts?.model)
102
+ labels.model = opts.model;
103
+ llmRequestsTotal.add(1, { ...labels, status: 'error' });
104
+ llmRequestDurationMs.record(Date.now() - startedAt, labels);
105
+ }
106
+ throw lastError;
107
+ }