experimental-ash 0.25.2 → 0.27.0

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 (765) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/bin/ash.d.ts +4 -4
  3. package/bin/ash.js +12 -8
  4. package/dist/docs/public/channels/README.md +26 -2
  5. package/dist/docs/public/channels/discord.md +159 -0
  6. package/dist/docs/public/channels/slack.md +14 -2
  7. package/dist/docs/public/subagents.md +38 -0
  8. package/dist/src/_virtual/_rolldown/runtime.js +1 -0
  9. package/dist/src/channel/adapter-context.js +1 -24
  10. package/dist/src/channel/adapter.js +1 -62
  11. package/dist/src/channel/compiled-channel.js +1 -6
  12. package/dist/src/channel/cross-channel-receive.js +2 -108
  13. package/dist/src/channel/http.js +1 -30
  14. package/dist/src/channel/receive-args.js +1 -1
  15. package/dist/src/channel/resolve-text.js +1 -59
  16. package/dist/src/channel/routes.js +1 -15
  17. package/dist/src/channel/schedule.js +1 -81
  18. package/dist/src/channel/send.js +1 -81
  19. package/dist/src/channel/session-callback.js +1 -65
  20. package/dist/src/channel/session.js +1 -58
  21. package/dist/src/channel/types.js +1 -1
  22. package/dist/src/cli/commands/channels.d.ts +15 -0
  23. package/dist/src/cli/commands/channels.js +3 -0
  24. package/dist/src/cli/commands/info.js +2 -2
  25. package/dist/src/cli/dev/environment.js +1 -1
  26. package/dist/src/cli/dev/input-requests.js +1 -1
  27. package/dist/src/cli/dev/input.js +1 -1
  28. package/dist/src/cli/dev/repl.js +2 -3
  29. package/dist/src/cli/dev/terminal.js +5 -5
  30. package/dist/src/cli/dev/url.js +1 -1
  31. package/dist/src/cli/run.js +2 -2
  32. package/dist/src/cli/ui/output.js +8 -8
  33. package/dist/src/client/client-error.js +1 -19
  34. package/dist/src/client/client.js +1 -128
  35. package/dist/src/client/index.js +1 -11
  36. package/dist/src/client/message-reducer-types.js +1 -1
  37. package/dist/src/client/message-reducer.js +1 -456
  38. package/dist/src/client/message-response.js +1 -55
  39. package/dist/src/client/ndjson.js +3 -62
  40. package/dist/src/client/open-stream.js +1 -45
  41. package/dist/src/client/reducer.js +1 -1
  42. package/dist/src/client/session-utils.js +1 -62
  43. package/dist/src/client/session.js +1 -206
  44. package/dist/src/client/types.js +1 -1
  45. package/dist/src/client/url.js +1 -34
  46. package/dist/src/compiled/.vendor-stamp.json +6 -1
  47. package/dist/src/compiled/@vercel/oidc/LICENSE +202 -0
  48. package/dist/src/compiled/@vercel/oidc/index.d.ts +21 -0
  49. package/dist/src/compiled/@vercel/oidc/index.js +2 -0
  50. package/dist/src/compiled/@vercel/oidc/package.json +7 -0
  51. package/dist/src/compiled/chokidar/LICENSE +21 -0
  52. package/dist/src/compiled/chokidar/index.d.ts +33 -0
  53. package/dist/src/compiled/chokidar/index.js +1 -0
  54. package/dist/src/compiled/chokidar/package.json +7 -0
  55. package/dist/src/compiled/commander/LICENSE +22 -0
  56. package/dist/src/compiled/commander/index.d.ts +1113 -0
  57. package/dist/src/{chunks/url-JdCGA634.js → compiled/commander/index.js} +10 -10
  58. package/dist/src/compiled/commander/package.json +7 -0
  59. package/dist/src/compiled/gray-matter/LICENSE +21 -0
  60. package/dist/src/compiled/gray-matter/index.d.ts +62 -0
  61. package/dist/src/{chunks/gray-matter-D-9jHwOT.js → compiled/gray-matter/index.js} +2 -2
  62. package/dist/src/compiled/gray-matter/package.json +7 -0
  63. package/dist/src/compiled/picocolors/LICENSE +15 -0
  64. package/dist/src/compiled/picocolors/index.d.ts +55 -0
  65. package/dist/src/compiled/picocolors/index.js +1 -0
  66. package/dist/src/compiled/picocolors/package.json +7 -0
  67. package/dist/src/compiler/artifacts.js +1 -147
  68. package/dist/src/compiler/compile-agent.js +3 -76
  69. package/dist/src/compiler/compile-from-memory.js +1 -59
  70. package/dist/src/compiler/manifest.js +1 -424
  71. package/dist/src/compiler/model-catalog.js +1 -224
  72. package/dist/src/compiler/module-map.js +5 -295
  73. package/dist/src/compiler/normalize-agent-config.js +1 -157
  74. package/dist/src/compiler/normalize-channel.js +1 -51
  75. package/dist/src/compiler/normalize-connection.js +1 -58
  76. package/dist/src/compiler/normalize-helpers.js +1 -23
  77. package/dist/src/compiler/normalize-hook.js +1 -19
  78. package/dist/src/compiler/normalize-instructions.js +1 -28
  79. package/dist/src/compiler/normalize-manifest.js +1 -79
  80. package/dist/src/compiler/normalize-sandbox.js +1 -20
  81. package/dist/src/compiler/normalize-schedule.js +1 -38
  82. package/dist/src/compiler/normalize-skill.js +1 -60
  83. package/dist/src/compiler/normalize-subagent.js +1 -174
  84. package/dist/src/compiler/normalize-tool.js +1 -40
  85. package/dist/src/compiler/remote-agent-node.js +1 -19
  86. package/dist/src/compiler/workspace-resources.js +1 -85
  87. package/dist/src/context/accessors.js +1 -93
  88. package/dist/src/context/container.js +1 -89
  89. package/dist/src/context/hook-lifecycle.js +1 -242
  90. package/dist/src/context/key.js +1 -39
  91. package/dist/src/context/keys.js +1 -43
  92. package/dist/src/context/node.js +1 -9
  93. package/dist/src/context/provider.js +1 -1
  94. package/dist/src/context/providers/connection.js +1 -17
  95. package/dist/src/context/providers/sandbox.js +1 -46
  96. package/dist/src/context/providers/session.js +1 -18
  97. package/dist/src/context/run-step.js +1 -51
  98. package/dist/src/context/seed-keys.js +1 -37
  99. package/dist/src/context/serialize.js +1 -44
  100. package/dist/src/discover/connections.js +1 -153
  101. package/dist/src/discover/diagnostics.js +1 -82
  102. package/dist/src/discover/discover-agent.js +1 -159
  103. package/dist/src/discover/discover-subagent.js +1 -223
  104. package/dist/src/discover/filesystem.js +1 -215
  105. package/dist/src/discover/grammar.js +1 -371
  106. package/dist/src/discover/lib.js +1 -34
  107. package/dist/src/discover/manifest.js +1 -136
  108. package/dist/src/discover/markdown.js +1 -17
  109. package/dist/src/discover/named-source-directory.js +1 -188
  110. package/dist/src/discover/project-source.js +1 -152
  111. package/dist/src/discover/project.js +1 -117
  112. package/dist/src/discover/sandbox.js +1 -220
  113. package/dist/src/discover/schedules.js +1 -41
  114. package/dist/src/discover/skills.js +1 -274
  115. package/dist/src/discover/slots.js +1 -68
  116. package/dist/src/evals/cli/eval.js +1 -1
  117. package/dist/src/evals/define-eval-suite.js +1 -1
  118. package/dist/src/evals/index.js +1 -1
  119. package/dist/src/evals/loaders/index.js +1 -1
  120. package/dist/src/evals/loaders/json.js +1 -1
  121. package/dist/src/evals/loaders/yaml.js +1 -1
  122. package/dist/src/evals/reporters/index.js +1 -1
  123. package/dist/src/evals/runner/artifacts.js +3 -3
  124. package/dist/src/evals/runner/derive-run-facts.js +1 -1
  125. package/dist/src/evals/runner/discover.js +1 -1
  126. package/dist/src/evals/runner/execute-case.js +1 -1
  127. package/dist/src/evals/runner/execute-suite.js +1 -1
  128. package/dist/src/evals/runner/reporters/braintrust.js +2 -2
  129. package/dist/src/evals/runner/reporters/console.js +1 -1
  130. package/dist/src/evals/runner/resolve-git-metadata.js +1 -1
  131. package/dist/src/evals/scorers/autoevals-client.js +2 -2
  132. package/dist/src/evals/scorers/autoevals.js +1 -1
  133. package/dist/src/evals/scorers/json.js +1 -1
  134. package/dist/src/evals/scorers/run.js +1 -1
  135. package/dist/src/evals/scorers/sql.js +1 -1
  136. package/dist/src/evals/scorers/text.js +1 -1
  137. package/dist/src/evals/scores/index.js +1 -1
  138. package/dist/src/execution/authorization-challenge-defaults.js +1 -60
  139. package/dist/src/execution/await-authorization-orchestrator.js +1 -192
  140. package/dist/src/execution/await-authorization-splice.js +1 -66
  141. package/dist/src/execution/connection-auth-steps.js +1 -338
  142. package/dist/src/execution/node-step.js +1 -146
  143. package/dist/src/execution/remote-agent-dispatch.js +1 -79
  144. package/dist/src/execution/runtime-context.js +1 -26
  145. package/dist/src/execution/runtime-errors.js +1 -19
  146. package/dist/src/execution/sandbox/bash-tool.js +1 -42
  147. package/dist/src/execution/sandbox/bindings/local.js +1 -296
  148. package/dist/src/execution/sandbox/bindings/vercel.js +1 -363
  149. package/dist/src/execution/sandbox/ensure.js +1 -91
  150. package/dist/src/execution/sandbox/glob-tool.js +3 -146
  151. package/dist/src/execution/sandbox/grep-tool.js +3 -183
  152. package/dist/src/execution/sandbox/lazy-backend.js +1 -33
  153. package/dist/src/execution/sandbox/prewarm.js +1 -132
  154. package/dist/src/execution/sandbox/read-file-tool.js +3 -118
  155. package/dist/src/execution/sandbox/require-sandbox.js +1 -32
  156. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -36
  157. package/dist/src/execution/sandbox/session.js +3 -158
  158. package/dist/src/execution/sandbox/shell-quote.js +1 -14
  159. package/dist/src/execution/sandbox/stream-utils.js +1 -22
  160. package/dist/src/execution/sandbox/truncate-output.js +3 -110
  161. package/dist/src/execution/sandbox/write-file-tool.js +1 -62
  162. package/dist/src/execution/session-callback-step.js +1 -72
  163. package/dist/src/execution/session.js +3 -94
  164. package/dist/src/execution/skills/instructions.js +2 -30
  165. package/dist/src/execution/skills/types.js +1 -1
  166. package/dist/src/execution/subagent-adapter.js +1 -94
  167. package/dist/src/execution/subagent-hitl-proxy.js +1 -81
  168. package/dist/src/execution/subagent-invocation.js +2 -16
  169. package/dist/src/execution/subagent-tool.js +1 -48
  170. package/dist/src/execution/tool-compaction.js +1 -54
  171. package/dist/src/execution/turn-workflow.js +1 -95
  172. package/dist/src/execution/web-fetch/html.js +7 -60
  173. package/dist/src/execution/web-fetch/tool.js +1 -90
  174. package/dist/src/execution/workflow-entry.js +1 -494
  175. package/dist/src/execution/workflow-errors.js +1 -54
  176. package/dist/src/execution/workflow-runtime.js +3 -161
  177. package/dist/src/execution/workflow-steps.js +1 -467
  178. package/dist/src/harness/action-result-helpers.js +1 -82
  179. package/dist/src/harness/attachment-staging.js +1 -303
  180. package/dist/src/harness/compaction.js +4 -221
  181. package/dist/src/harness/emission.js +1 -323
  182. package/dist/src/harness/execute-tool.js +1 -1
  183. package/dist/src/harness/input-extraction.js +1 -62
  184. package/dist/src/harness/input-requests.js +1 -306
  185. package/dist/src/harness/instrumentation-config.js +1 -42
  186. package/dist/src/harness/messages.js +1 -144
  187. package/dist/src/harness/model-call-error.js +1 -368
  188. package/dist/src/harness/otel-integration.js +1 -18
  189. package/dist/src/harness/prompt-cache.js +1 -137
  190. package/dist/src/harness/provider-tools.js +1 -137
  191. package/dist/src/harness/proxy-input-requests.js +1 -91
  192. package/dist/src/harness/runtime-actions.js +1 -321
  193. package/dist/src/harness/step-hooks.js +1 -192
  194. package/dist/src/harness/tool-loop.js +1 -877
  195. package/dist/src/harness/tool-result-pruning.js +1 -124
  196. package/dist/src/harness/tools.js +1 -98
  197. package/dist/src/harness/types.js +1 -1
  198. package/dist/src/index.js +1 -1
  199. package/dist/src/internal/application/cache-metadata.js +1 -42
  200. package/dist/src/internal/application/compiled-artifacts.js +4 -114
  201. package/dist/src/internal/application/import-specifier.js +1 -58
  202. package/dist/src/internal/application/package.js +1 -196
  203. package/dist/src/internal/application/paths.js +1 -117
  204. package/dist/src/internal/application/runtime-compiled-artifacts-source.js +1 -11
  205. package/dist/src/internal/attachments/data.js +1 -127
  206. package/dist/src/internal/attachments/errors.js +1 -26
  207. package/dist/src/internal/attachments/refs.js +1 -94
  208. package/dist/src/internal/attachments/sandbox-refs.js +1 -78
  209. package/dist/src/internal/attachments/url-refs.js +1 -20
  210. package/dist/src/internal/authored-asset-import-plugin.js +1 -141
  211. package/dist/src/internal/authored-definition/channel.js +1 -21
  212. package/dist/src/internal/authored-definition/connection.js +1 -148
  213. package/dist/src/internal/authored-definition/core.js +1 -180
  214. package/dist/src/internal/authored-definition/sandbox.js +1 -47
  215. package/dist/src/internal/authored-definition/schema-backed.js +1 -56
  216. package/dist/src/internal/authored-module-bundle.js +2 -19
  217. package/dist/src/internal/authored-module-loader.js +2 -263
  218. package/dist/src/internal/authored-module-map-loader.js +1 -53
  219. package/dist/src/internal/authored-module.js +1 -81
  220. package/dist/src/internal/authored-package-tsconfig-paths.js +1 -209
  221. package/dist/src/internal/bundler/nitro-rolldown.js +1 -42
  222. package/dist/src/internal/helpers/markdown.js +3 -174
  223. package/dist/src/internal/json-schema.js +1 -13
  224. package/dist/src/internal/logging.js +1 -226
  225. package/dist/src/internal/nitro/host/artifacts-config.js +1 -17
  226. package/dist/src/internal/nitro/host/build-application.js +1 -177
  227. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -140
  228. package/dist/src/internal/nitro/host/channel-routes.js +2 -126
  229. package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.js +2 -28
  230. package/dist/src/internal/nitro/host/configure-nitro-routes.js +4 -272
  231. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -491
  232. package/dist/src/internal/nitro/host/cron-handler-route.js +1 -49
  233. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -390
  234. package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -10
  235. package/dist/src/internal/nitro/host/nitro-routing-import-specifier-plugin.js +1 -28
  236. package/dist/src/internal/nitro/host/prepare-application-host.js +1 -32
  237. package/dist/src/internal/nitro/host/schedule-task-routes.js +2 -148
  238. package/dist/src/internal/nitro/host/server-external-packages.js +1 -107
  239. package/dist/src/internal/nitro/host/start-development-server.js +1 -223
  240. package/dist/src/internal/nitro/host/types.js +1 -1
  241. package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -14
  242. package/dist/src/internal/nitro/host/vercel-build-prewarm.js +1 -30
  243. package/dist/src/internal/nitro/host.js +1 -2
  244. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +2 -180
  245. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -46
  246. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -74
  247. package/dist/src/internal/nitro/routes/health.js +1 -17
  248. package/dist/src/internal/nitro/routes/index.js +2 -89
  249. package/dist/src/internal/nitro/routes/info.js +1 -50
  250. package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -24
  251. package/dist/src/internal/nitro/routes/runtime-stack.js +1 -23
  252. package/dist/src/internal/nitro/routes/schedule-task.js +1 -57
  253. package/dist/src/internal/nitro/routes/workflow-data.js +1 -141
  254. package/dist/src/internal/nitro/routes/workflow-route-helpers.js +1 -137
  255. package/dist/src/internal/nitro/routes/workflow-run-events.js +1 -41
  256. package/dist/src/internal/nitro/routes/workflow-run-steps.js +1 -41
  257. package/dist/src/internal/nitro/routes/workflow-run.js +1 -34
  258. package/dist/src/internal/nitro/routes/workflow-runs.js +1 -28
  259. package/dist/src/internal/node-esm-compat-banner.js +2 -65
  260. package/dist/src/internal/package-name.js +1 -8
  261. package/dist/src/internal/process/pnpm.d.ts +28 -0
  262. package/dist/src/internal/process/pnpm.js +1 -0
  263. package/dist/src/internal/runtime-model.js +1 -24
  264. package/dist/src/internal/runtime-registry.js +1 -93
  265. package/dist/src/internal/vercel-agent-summary.js +1 -72
  266. package/dist/src/internal/workflow/builtins.js +1 -18
  267. package/dist/src/internal/workflow/index.js +1 -9
  268. package/dist/src/internal/workflow-bundle/ash-service-route-output.js +3 -93
  269. package/dist/src/internal/workflow-bundle/builder-support.js +5 -372
  270. package/dist/src/internal/workflow-bundle/builder.js +5 -472
  271. package/dist/src/internal/workflow-bundle/nitro-step-entry.js +2 -132
  272. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +3 -494
  273. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -292
  274. package/dist/src/internal/workflow-bundle/workflow-core-shim.js +1 -84
  275. package/dist/src/internal/workflow-bundle/workflow-transformer.js +5 -318
  276. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/ajv.js +1 -0
  277. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +1 -0
  278. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +2 -0
  279. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +1 -0
  280. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +1 -0
  281. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -0
  282. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +1 -0
  283. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +1 -0
  284. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +1 -0
  285. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -0
  286. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +1 -0
  287. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +1 -0
  288. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +1 -0
  289. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +4 -0
  290. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +1 -0
  291. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +1 -0
  292. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +1 -0
  293. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +1 -0
  294. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -0
  295. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +1 -0
  296. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-draft-07.js +1 -0
  297. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +1 -0
  298. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +1 -0
  299. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +1 -0
  300. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +1 -0
  301. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +1 -0
  302. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +1 -0
  303. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -0
  304. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +1 -0
  305. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +1 -0
  306. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +4 -0
  307. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +1 -0
  308. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -0
  309. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +1 -0
  310. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +1 -0
  311. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +1 -0
  312. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +1 -0
  313. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +1 -0
  314. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +1 -0
  315. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +1 -0
  316. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +1 -0
  317. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +1 -0
  318. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +1 -0
  319. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +1 -0
  320. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +1 -0
  321. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +1 -0
  322. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +1 -0
  323. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +1 -0
  324. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft7.js +1 -0
  325. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +1 -0
  326. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +1 -0
  327. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +1 -0
  328. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +1 -0
  329. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +1 -0
  330. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +1 -0
  331. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +1 -0
  332. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +1 -0
  333. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +1 -0
  334. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +1 -0
  335. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +1 -0
  336. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +1 -0
  337. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +1 -0
  338. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +1 -0
  339. package/dist/src/node_modules/.pnpm/autoevals@0.0.132_ws@8.21.0/node_modules/autoevals/jsdist/index.js +384 -0
  340. package/dist/src/node_modules/.pnpm/compute-cosine-similarity@1.1.0/node_modules/compute-cosine-similarity/lib/index.js +1 -0
  341. package/dist/src/node_modules/.pnpm/compute-dot@1.1.0/node_modules/compute-dot/lib/index.js +1 -0
  342. package/dist/src/node_modules/.pnpm/compute-l2norm@1.1.0/node_modules/compute-l2norm/lib/index.js +1 -0
  343. package/dist/src/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +1 -0
  344. package/dist/src/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js +1 -0
  345. package/dist/src/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js +1 -0
  346. package/dist/src/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js +1 -0
  347. package/dist/src/node_modules/.pnpm/js-levenshtein@1.1.6/node_modules/js-levenshtein/index.js +1 -0
  348. package/dist/src/node_modules/.pnpm/js-yaml@4.1.1/node_modules/js-yaml/dist/js-yaml.js +32 -0
  349. package/dist/src/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +1 -0
  350. package/dist/src/node_modules/.pnpm/mustache@4.2.0/node_modules/mustache/mustache.js +4 -0
  351. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/_vendor/partial-json-parser/parser.js +2 -0
  352. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/auth/workload-identity-auth.js +1 -0
  353. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/azure.js +1 -0
  354. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/client.js +11 -0
  355. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/core/api-promise.js +1 -0
  356. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/core/error.js +1 -0
  357. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/core/pagination.js +1 -0
  358. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/core/resource.js +1 -0
  359. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/core/streaming.js +3 -0
  360. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/core/uploads.js +1 -0
  361. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/error.js +1 -0
  362. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/index.js +1 -0
  363. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/decoders/line.js +3 -0
  364. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/detect-platform.js +1 -0
  365. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/errors.js +1 -0
  366. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/headers.js +1 -0
  367. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/parse.js +1 -0
  368. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/qs/formats.js +1 -0
  369. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/qs/stringify.js +1 -0
  370. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/qs/utils.js +1 -0
  371. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/request-options.js +1 -0
  372. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/shims.js +1 -0
  373. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/to-file.js +1 -0
  374. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/tslib.js +1 -0
  375. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/uploads.js +1 -0
  376. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/base64.js +1 -0
  377. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/bytes.js +1 -0
  378. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/env.js +1 -0
  379. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/log.js +1 -0
  380. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/path.js +2 -0
  381. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/query.js +1 -0
  382. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/sleep.js +1 -0
  383. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/uuid.js +1 -0
  384. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils/values.js +1 -0
  385. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/internal/utils.js +1 -0
  386. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/AbstractChatCompletionRunner.js +1 -0
  387. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/AssistantStream.js +1 -0
  388. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/ChatCompletionRunner.js +1 -0
  389. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/ChatCompletionStream.js +1 -0
  390. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/ChatCompletionStreamingRunner.js +1 -0
  391. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/EventStream.js +1 -0
  392. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/ResponsesParser.js +1 -0
  393. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/RunnableFunction.js +1 -0
  394. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/Util.js +1 -0
  395. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/chatCompletionUtils.js +1 -0
  396. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/parser.js +1 -0
  397. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/lib/responses/ResponseStream.js +1 -0
  398. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/admin.js +1 -0
  399. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/admin-api-keys.js +1 -0
  400. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/audit-logs.js +1 -0
  401. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/certificates.js +1 -0
  402. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/data-retention.js +1 -0
  403. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/groups/groups.js +1 -0
  404. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/groups/roles.js +1 -0
  405. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/groups/users.js +1 -0
  406. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/invites.js +1 -0
  407. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/organization.js +1 -0
  408. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/api-keys.js +1 -0
  409. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/certificates.js +1 -0
  410. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/data-retention.js +1 -0
  411. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/groups/groups.js +1 -0
  412. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/groups/roles.js +1 -0
  413. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.js +1 -0
  414. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/model-permissions.js +1 -0
  415. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/projects.js +1 -0
  416. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/rate-limits.js +1 -0
  417. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/roles.js +1 -0
  418. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/service-accounts.js +1 -0
  419. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/spend-alerts.js +1 -0
  420. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/users/roles.js +1 -0
  421. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/projects/users/users.js +1 -0
  422. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/roles.js +1 -0
  423. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/spend-alerts.js +1 -0
  424. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/usage.js +1 -0
  425. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/users/roles.js +1 -0
  426. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/admin/organization/users/users.js +1 -0
  427. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/audio/audio.js +1 -0
  428. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/audio/speech.js +1 -0
  429. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/audio/transcriptions.js +1 -0
  430. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/audio/translations.js +1 -0
  431. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/batches.js +1 -0
  432. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/assistants.js +1 -0
  433. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/beta.js +1 -0
  434. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/chatkit/chatkit.js +1 -0
  435. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/chatkit/sessions.js +1 -0
  436. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/chatkit/threads.js +1 -0
  437. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/realtime/realtime.js +1 -0
  438. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/realtime/sessions.js +1 -0
  439. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/realtime/transcription-sessions.js +1 -0
  440. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/threads/messages.js +1 -0
  441. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/threads/runs/runs.js +1 -0
  442. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/threads/runs/steps.js +1 -0
  443. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/beta/threads/threads.js +1 -0
  444. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/chat/chat.js +1 -0
  445. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/chat/completions/completions.js +1 -0
  446. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/chat/completions/index.js +1 -0
  447. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/chat/completions/messages.js +1 -0
  448. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/chat/index.js +1 -0
  449. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/completions.js +1 -0
  450. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/containers/containers.js +1 -0
  451. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/containers/files/content.js +1 -0
  452. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/containers/files/files.js +1 -0
  453. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/conversations/conversations.js +1 -0
  454. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/conversations/items.js +1 -0
  455. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/embeddings.js +1 -0
  456. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/evals/evals.js +1 -0
  457. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/evals/runs/output-items.js +1 -0
  458. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/evals/runs/runs.js +1 -0
  459. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/files.js +1 -0
  460. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/alpha/alpha.js +1 -0
  461. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/alpha/graders.js +1 -0
  462. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.js +1 -0
  463. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/checkpoints/permissions.js +1 -0
  464. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/fine-tuning.js +1 -0
  465. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/jobs/checkpoints.js +1 -0
  466. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/jobs/jobs.js +1 -0
  467. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/fine-tuning/methods.js +1 -0
  468. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/graders/grader-models.js +1 -0
  469. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/graders/graders.js +1 -0
  470. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/images.js +1 -0
  471. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/index.js +1 -0
  472. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/models.js +1 -0
  473. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/moderations.js +1 -0
  474. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/realtime/calls.js +1 -0
  475. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/realtime/client-secrets.js +1 -0
  476. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/realtime/realtime.js +1 -0
  477. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/responses/input-items.js +1 -0
  478. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/responses/input-tokens.js +1 -0
  479. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/responses/responses.js +1 -0
  480. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/shared.js +1 -0
  481. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/skills/content.js +1 -0
  482. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/skills/skills.js +1 -0
  483. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/skills/versions/content.js +1 -0
  484. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/skills/versions/versions.js +1 -0
  485. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/uploads/parts.js +1 -0
  486. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/uploads/uploads.js +1 -0
  487. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/vector-stores/file-batches.js +1 -0
  488. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/vector-stores/files.js +1 -0
  489. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/vector-stores/vector-stores.js +1 -0
  490. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/videos.js +1 -0
  491. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/webhooks/index.js +1 -0
  492. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/webhooks/webhooks.js +1 -0
  493. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/resources/webhooks.js +1 -0
  494. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/streaming.js +1 -0
  495. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/version.js +1 -0
  496. package/dist/src/node_modules/.pnpm/validate.io-array@1.0.6/node_modules/validate.io-array/lib/index.js +1 -0
  497. package/dist/src/node_modules/.pnpm/validate.io-function@1.0.2/node_modules/validate.io-function/lib/index.js +1 -0
  498. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Options.js +1 -0
  499. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/Refs.js +1 -0
  500. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +1 -0
  501. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +1 -0
  502. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/index.js +1 -0
  503. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseDef.js +1 -0
  504. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parseTypes.js +1 -0
  505. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +1 -0
  506. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +1 -0
  507. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +1 -0
  508. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +1 -0
  509. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +1 -0
  510. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +1 -0
  511. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +1 -0
  512. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +1 -0
  513. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +1 -0
  514. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +1 -0
  515. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +1 -0
  516. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +1 -0
  517. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +1 -0
  518. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +1 -0
  519. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +1 -0
  520. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +1 -0
  521. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +1 -0
  522. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +1 -0
  523. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +1 -0
  524. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +1 -0
  525. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +1 -0
  526. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +1 -0
  527. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +1 -0
  528. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +1 -0
  529. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +1 -0
  530. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +3 -0
  531. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +1 -0
  532. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +1 -0
  533. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +1 -0
  534. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +1 -0
  535. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/selectParser.js +1 -0
  536. package/dist/src/node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +1 -0
  537. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/index.js +1 -0
  538. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js +1 -0
  539. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +1 -0
  540. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js +1 -0
  541. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js +1 -0
  542. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js +1 -0
  543. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  544. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js +1 -0
  545. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/index.js +1 -0
  546. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js +1 -0
  547. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js +1 -0
  548. package/dist/src/packages/ash-scaffold/src/channels.js +7 -0
  549. package/dist/src/packages/ash-scaffold/src/files.js +1 -0
  550. package/dist/src/packages/ash-scaffold/src/index.js +1 -0
  551. package/dist/src/packages/ash-scaffold/src/module-files.js +1 -0
  552. package/dist/src/packages/ash-scaffold/src/package-json.js +1 -0
  553. package/dist/src/packages/ash-scaffold/src/project.js +1 -0
  554. package/dist/src/protocol/message.js +2 -501
  555. package/dist/src/protocol/routes.js +1 -85
  556. package/dist/src/public/agents/auth.js +1 -37
  557. package/dist/src/public/channels/ash.js +2 -346
  558. package/dist/src/public/channels/auth.js +1 -414
  559. package/dist/src/public/channels/discord/api.d.ts +99 -0
  560. package/dist/src/public/channels/discord/api.js +2 -0
  561. package/dist/src/public/channels/discord/defaults.d.ts +9 -0
  562. package/dist/src/public/channels/discord/defaults.js +3 -0
  563. package/dist/src/public/channels/discord/discordChannel.d.ts +132 -0
  564. package/dist/src/public/channels/discord/discordChannel.js +1 -0
  565. package/dist/src/public/channels/discord/hitl.d.ts +34 -0
  566. package/dist/src/public/channels/discord/hitl.js +1 -0
  567. package/dist/src/public/channels/discord/inbound.d.ts +97 -0
  568. package/dist/src/public/channels/discord/inbound.js +2 -0
  569. package/dist/src/public/channels/discord/index.d.ts +7 -0
  570. package/dist/src/public/channels/discord/index.js +1 -0
  571. package/dist/src/public/channels/discord/responses.d.ts +11 -0
  572. package/dist/src/public/channels/discord/responses.js +1 -0
  573. package/dist/src/public/channels/discord/verify.d.ts +38 -0
  574. package/dist/src/public/channels/discord/verify.js +1 -0
  575. package/dist/src/public/channels/discord/verifyInbound.d.ts +6 -0
  576. package/dist/src/public/channels/discord/verifyInbound.js +1 -0
  577. package/dist/src/public/channels/index.js +1 -1
  578. package/dist/src/public/channels/slack/api-encoding.js +1 -40
  579. package/dist/src/public/channels/slack/api.js +1 -333
  580. package/dist/src/public/channels/slack/attachments.js +1 -156
  581. package/dist/src/public/channels/slack/blocks.js +3 -266
  582. package/dist/src/public/channels/slack/connections.js +1 -70
  583. package/dist/src/public/channels/slack/constants.d.ts +7 -0
  584. package/dist/src/public/channels/slack/constants.js +1 -0
  585. package/dist/src/public/channels/slack/defaults.js +4 -211
  586. package/dist/src/public/channels/slack/hitl.js +1 -242
  587. package/dist/src/public/channels/slack/inbound.js +2 -149
  588. package/dist/src/public/channels/slack/index.js +1 -13
  589. package/dist/src/public/channels/slack/interactions.js +1 -315
  590. package/dist/src/public/channels/slack/limits.js +1 -75
  591. package/dist/src/public/channels/slack/mrkdwn.js +1 -89
  592. package/dist/src/public/channels/slack/slackChannel.js +1 -250
  593. package/dist/src/public/channels/slack/thread.js +1 -45
  594. package/dist/src/public/channels/slack/verify.js +1 -70
  595. package/dist/src/public/channels/twilio/api.js +1 -103
  596. package/dist/src/public/channels/twilio/defaults.js +3 -69
  597. package/dist/src/public/channels/twilio/inbound.js +2 -123
  598. package/dist/src/public/channels/twilio/index.js +1 -4
  599. package/dist/src/public/channels/twilio/twilioChannel.js +1 -316
  600. package/dist/src/public/channels/twilio/twiml.js +1 -58
  601. package/dist/src/public/channels/twilio/verify.js +1 -73
  602. package/dist/src/public/channels/upload-policy.js +1 -170
  603. package/dist/src/public/connections/errors.js +1 -53
  604. package/dist/src/public/connections/index.js +1 -6
  605. package/dist/src/public/context/index.js +1 -13
  606. package/dist/src/public/definitions/agent.js +1 -6
  607. package/dist/src/public/definitions/channel.js +1 -24
  608. package/dist/src/public/definitions/connections/mcp.js +1 -20
  609. package/dist/src/public/definitions/defineChannel.js +1 -74
  610. package/dist/src/public/definitions/hook.js +1 -11
  611. package/dist/src/public/definitions/instructions.js +1 -7
  612. package/dist/src/public/definitions/instrumentation.js +1 -13
  613. package/dist/src/public/definitions/remote-agent.js +1 -11
  614. package/dist/src/public/definitions/sandbox-backend.js +1 -13
  615. package/dist/src/public/definitions/sandbox.js +1 -6
  616. package/dist/src/public/definitions/schedule.js +1 -32
  617. package/dist/src/public/definitions/skill.js +1 -7
  618. package/dist/src/public/definitions/source.js +1 -1
  619. package/dist/src/public/definitions/state.js +1 -34
  620. package/dist/src/public/definitions/tool.js +1 -27
  621. package/dist/src/public/hooks/index.js +1 -9
  622. package/dist/src/public/index.js +1 -5
  623. package/dist/src/public/instructions/index.js +1 -4
  624. package/dist/src/public/instrumentation/index.js +1 -4
  625. package/dist/src/public/next/index.js +1 -148
  626. package/dist/src/public/next/server.js +1 -348
  627. package/dist/src/public/next/vercel-json.js +1 -77
  628. package/dist/src/public/sandbox/backends/default.js +1 -15
  629. package/dist/src/public/sandbox/backends/local.js +1 -18
  630. package/dist/src/public/sandbox/backends/vercel.js +1 -25
  631. package/dist/src/public/sandbox/index.js +1 -10
  632. package/dist/src/public/sandbox/local-sandbox.js +1 -1
  633. package/dist/src/public/sandbox/vercel-sandbox.js +1 -1
  634. package/dist/src/public/schedules/index.js +1 -4
  635. package/dist/src/public/skills/index.js +1 -5
  636. package/dist/src/public/tool-result-narrowing.js +1 -87
  637. package/dist/src/public/tools/approval/approval-helpers.js +1 -22
  638. package/dist/src/public/tools/approval/index.js +1 -4
  639. package/dist/src/public/tools/defaults.js +1 -70
  640. package/dist/src/public/tools/define-bash-tool.js +1 -14
  641. package/dist/src/public/tools/define-glob-tool.js +1 -21
  642. package/dist/src/public/tools/define-grep-tool.js +1 -21
  643. package/dist/src/public/tools/define-read-file-tool.js +1 -27
  644. package/dist/src/public/tools/define-write-file-tool.js +1 -21
  645. package/dist/src/public/tools/index.js +1 -10
  646. package/dist/src/public/tools/internal.js +1 -24
  647. package/dist/src/public/types/json.js +1 -13
  648. package/dist/src/react/index.js +1 -3
  649. package/dist/src/react/use-ash-agent.js +2 -348
  650. package/dist/src/runtime/actions/keys.js +1 -30
  651. package/dist/src/runtime/actions/types.js +1 -99
  652. package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -148
  653. package/dist/src/runtime/agent/bootstrap-model.js +1 -36
  654. package/dist/src/runtime/agent/bootstrap.js +1 -49
  655. package/dist/src/runtime/agent/mock-model-adapter.js +7 -358
  656. package/dist/src/runtime/agent/resolve-model.js +1 -48
  657. package/dist/src/runtime/cache-key.js +1 -52
  658. package/dist/src/runtime/channels/registry.js +1 -133
  659. package/dist/src/runtime/compiled-artifacts-source.js +1 -42
  660. package/dist/src/runtime/connections/authorization-complete-page.js +2 -21
  661. package/dist/src/runtime/connections/authorization-tokens.js +1 -66
  662. package/dist/src/runtime/connections/callback-route.js +1 -139
  663. package/dist/src/runtime/connections/mcp-client.js +1 -307
  664. package/dist/src/runtime/connections/principal-context.js +1 -111
  665. package/dist/src/runtime/connections/principal.js +1 -106
  666. package/dist/src/runtime/connections/registry.js +1 -61
  667. package/dist/src/runtime/connections/types.js +1 -41
  668. package/dist/src/runtime/connections/validate-authorization.js +1 -92
  669. package/dist/src/runtime/framework-channels/index.js +1 -38
  670. package/dist/src/runtime/framework-tools/ask-question.js +1 -30
  671. package/dist/src/runtime/framework-tools/bash.js +1 -40
  672. package/dist/src/runtime/framework-tools/connection-search.js +1 -224
  673. package/dist/src/runtime/framework-tools/connection-tools.js +1 -103
  674. package/dist/src/runtime/framework-tools/file-state.js +1 -71
  675. package/dist/src/runtime/framework-tools/glob.js +2 -56
  676. package/dist/src/runtime/framework-tools/grep.js +2 -75
  677. package/dist/src/runtime/framework-tools/index.js +1 -52
  678. package/dist/src/runtime/framework-tools/pending-connection-tool-calls.js +1 -63
  679. package/dist/src/runtime/framework-tools/read-file.js +2 -64
  680. package/dist/src/runtime/framework-tools/skill.js +1 -47
  681. package/dist/src/runtime/framework-tools/todo.js +3 -122
  682. package/dist/src/runtime/framework-tools/web-fetch.js +2 -42
  683. package/dist/src/runtime/framework-tools/web-search.js +1 -15
  684. package/dist/src/runtime/framework-tools/write-file.js +2 -48
  685. package/dist/src/runtime/governance/auth/http-basic.js +1 -63
  686. package/dist/src/runtime/governance/auth/jwt-ecdsa.js +1 -69
  687. package/dist/src/runtime/governance/auth/jwt-hmac.js +1 -39
  688. package/dist/src/runtime/governance/auth/oidc.js +1 -126
  689. package/dist/src/runtime/governance/auth/token-claims.js +1 -84
  690. package/dist/src/runtime/governance/auth/types.js +1 -14
  691. package/dist/src/runtime/governance/network/ip-allow-list.js +1 -66
  692. package/dist/src/runtime/graph.js +1 -17
  693. package/dist/src/runtime/hooks/registry.js +1 -55
  694. package/dist/src/runtime/input/types.js +1 -63
  695. package/dist/src/runtime/loaders/artifact-paths.js +1 -26
  696. package/dist/src/runtime/loaders/bundled-artifacts.js +1 -21
  697. package/dist/src/runtime/loaders/compile-metadata.js +1 -92
  698. package/dist/src/runtime/loaders/manifest.js +1 -56
  699. package/dist/src/runtime/loaders/module-map.js +1 -64
  700. package/dist/src/runtime/prompt/compose.js +2 -47
  701. package/dist/src/runtime/prompt/connections.js +2 -23
  702. package/dist/src/runtime/resolve-agent-graph.js +1 -287
  703. package/dist/src/runtime/resolve-agent.js +1 -134
  704. package/dist/src/runtime/resolve-channel.js +1 -62
  705. package/dist/src/runtime/resolve-connection.js +1 -72
  706. package/dist/src/runtime/resolve-helpers.js +1 -58
  707. package/dist/src/runtime/resolve-hook.js +1 -67
  708. package/dist/src/runtime/resolve-sandbox.js +1 -65
  709. package/dist/src/runtime/resolve-tool.js +1 -110
  710. package/dist/src/runtime/sandbox/keys.js +1 -72
  711. package/dist/src/runtime/sandbox/registry.js +1 -42
  712. package/dist/src/runtime/schedules/register.js +1 -62
  713. package/dist/src/runtime/schedules/resolve-schedule.js +1 -66
  714. package/dist/src/runtime/session-callback-route.js +1 -87
  715. package/dist/src/runtime/sessions/auth.js +1 -18
  716. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -125
  717. package/dist/src/runtime/sessions/runtime-session.js +1 -50
  718. package/dist/src/runtime/sessions/turn.js +1 -1
  719. package/dist/src/runtime/skills/fragment-context.js +1 -4
  720. package/dist/src/runtime/skills/sandbox-access.js +1 -85
  721. package/dist/src/runtime/subagents/registry.js +1 -62
  722. package/dist/src/runtime/tools/registry.js +1 -40
  723. package/dist/src/runtime/types.js +1 -1
  724. package/dist/src/runtime/validation.js +1 -7
  725. package/dist/src/runtime/workspace/seed-files.js +1 -42
  726. package/dist/src/runtime/workspace/spec.js +2 -22
  727. package/dist/src/runtime/workspace/types.js +1 -9
  728. package/dist/src/sandbox/state.js +1 -1
  729. package/dist/src/services/dev-client/request-headers.js +1 -197
  730. package/dist/src/services/dev-client/stream.js +1 -7
  731. package/dist/src/services/dev-client/url.js +1 -25
  732. package/dist/src/services/dev-client/vercel-auth-error.js +2 -98
  733. package/dist/src/services/dev-client.js +1 -48
  734. package/dist/src/services/inspect-application.js +1 -45
  735. package/dist/src/shared/agent-definition.js +1 -1
  736. package/dist/src/shared/errors.js +1 -66
  737. package/dist/src/shared/guards.js +1 -35
  738. package/dist/src/shared/json-schemas.js +1 -41
  739. package/dist/src/shared/json.js +1 -80
  740. package/dist/src/shared/node.js +1 -1
  741. package/dist/src/shared/optional.js +1 -1
  742. package/dist/src/shared/run-mode.js +1 -1
  743. package/dist/src/shared/sandbox-backend.js +1 -1
  744. package/dist/src/shared/sandbox-definition.js +1 -1
  745. package/dist/src/shared/sandbox-session.js +1 -1
  746. package/dist/src/shared/skill-definition.js +1 -1
  747. package/dist/src/shared/skill-package.js +1 -100
  748. package/dist/src/shared/source-ref.js +1 -1
  749. package/dist/src/shared/tool-definition.js +1 -1
  750. package/package.json +12 -6
  751. package/dist/src/chunks/authored-module-loader-DcCfCiBm.js +0 -4
  752. package/dist/src/chunks/chunk-DSjMdhoD.js +0 -1
  753. package/dist/src/chunks/client-ZqNLLMZB.js +0 -4
  754. package/dist/src/chunks/compile-agent-C4OrJW6C.js +0 -5
  755. package/dist/src/chunks/dev-authored-source-watcher-PwAxalwl.js +0 -1
  756. package/dist/src/chunks/errors-HYWjHxV6.js +0 -1
  757. package/dist/src/chunks/guards-26p6sOw3.js +0 -1
  758. package/dist/src/chunks/host-F-DkwYJK.js +0 -70
  759. package/dist/src/chunks/input-requests-DJiy6dG9.js +0 -1
  760. package/dist/src/chunks/jsdist-BkeWZ7EZ.js +0 -443
  761. package/dist/src/chunks/paths-DnlVBqHu.js +0 -85
  762. package/dist/src/chunks/picocolors-aAkqW4On.js +0 -1
  763. package/dist/src/chunks/runtime-model-Dh0Nz64z.js +0 -1
  764. package/dist/src/chunks/token-YW4VSeBB.js +0 -1
  765. package/dist/src/chunks/types-BJSR0JNV.js +0 -1
@@ -1,877 +1 @@
1
- import { context as otelContext, trace, } from "#compiled/@opentelemetry/api/index.js";
2
- import { isStepCount, ToolLoopAgent, } from "ai";
3
- import { resolveInstalledPackageInfo } from "#internal/application/package.js";
4
- import { createErrorId, createLogger, formatError, recordErrorOnSpan } from "#internal/logging.js";
5
- import { formatLanguageModelGatewayId } from "#internal/runtime-model.js";
6
- import { contextStorage } from "#context/container.js";
7
- import { toErrorMessage } from "#shared/errors.js";
8
- import { createCompactionCompletedEvent, createCompactionRequestedEvent, createInputRequestedEvent, } from "#protocol/message.js";
9
- import { ASK_QUESTION_TOOL_NAME } from "#runtime/framework-tools/ask-question.js";
10
- import { ConnectionRegistryKey, DiscoveredConnectionToolsKey, } from "#runtime/framework-tools/connection-search.js";
11
- import { resolveConnectionToolsFromState } from "#runtime/framework-tools/connection-tools.js";
12
- import { WEB_SEARCH_TOOL_DEFINITION } from "#runtime/framework-tools/web-search.js";
13
- import { hydrateSandboxAttachments, stageAttachmentsToSandbox, } from "#harness/attachment-staging.js";
14
- import { compactMessages, getInputTokenCount, resolveCompactionModel, shouldCompact, } from "#harness/compaction.js";
15
- import { advanceStep, emitFailedStep, emitRecoverableFailedTurn, emitStreamContent, emitTurnEpilogue, emitTurnPreamble, getHarnessEmissionState, setHarnessEmissionState, } from "#harness/emission.js";
16
- import { extractQuestionInputRequests, extractToolApprovalInputRequests, } from "#harness/input-extraction.js";
17
- import { consumeDeferredStepInput, getApprovedTools, hasDeferredStepInput, hasStepInput, resolvePendingInput, setPendingInputBatch, } from "#harness/input-requests.js";
18
- import { getInstrumentationConfig } from "#harness/instrumentation-config.js";
19
- import { resolveAssistantStepText } from "#harness/messages.js";
20
- import { classifyModelCallError, extractModelCallErrorDetails, extractUnsupportedProviderToolTypes, summarizeKnownModelCallConfigError, summarizeKnownModelCallRequestError, } from "#harness/model-call-error.js";
21
- import { ensureOtelIntegration } from "#harness/otel-integration.js";
22
- import { applyLastToolCacheBreakpoint, detectPromptCachePath, getAnthropicCacheMarker, } from "#harness/prompt-cache.js";
23
- import { resolveFrameworkToolFromUpstreamType, resolveGatewayPinForWebSearchBackend, resolveWebSearchBackend, } from "#harness/provider-tools.js";
24
- import { createRuntimeActionRequestFromToolCall, resolvePendingRuntimeActions, setPendingRuntimeActionBatch, } from "#harness/runtime-actions.js";
25
- import { buildStepHooks, emitStepActions, isInvalidToolCall, } from "#harness/step-hooks.js";
26
- import { pruneToolResults } from "#harness/tool-result-pruning.js";
27
- import { buildToolSetWithProviderTools } from "#harness/tools.js";
28
- /**
29
- * Creates a tool-loop harness step function backed by AI SDK `ToolLoopAgent`.
30
- */
31
- /**
32
- * Builds the `telemetry` value for the AI SDK from authored settings.
33
- *
34
- * Custom metadata (authored `InstrumentationDefinition.metadata` plus
35
- * ash-specific identifiers such as `ash.session.id`) is flowed through
36
- * {@link buildTelemetryRuntimeContext} because AI SDK v7 surfaces
37
- * per-call attributes via `runtimeContext`, not a dedicated metadata
38
- * field on `TelemetryOptions`.
39
- */
40
- const environment = process.env.NODE_ENV ?? "unknown";
41
- const ashVersion = resolveInstalledPackageInfo().version;
42
- const log = createLogger("harness.tool-loop");
43
- /**
44
- * Max attempts (1 original + N retries) for transient model-call
45
- * failures before the harness gives up and falls back to the
46
- * recoverable/terminal emission path. Kept small on purpose — every
47
- * attempt costs a round-trip plus prompt tokens, and the dominant
48
- * use case (429 / 502) clears quickly or not at all.
49
- */
50
- const MODEL_CALL_MAX_ATTEMPTS = 3;
51
- /**
52
- * Base delay (ms) between model-call retries. Doubled each attempt,
53
- * plus a small random jitter to avoid thundering-herd behavior when
54
- * a provider incident clears.
55
- */
56
- const MODEL_CALL_RETRY_BASE_DELAY_MS = 500;
57
- function enrichTelemetry(authored, agentName) {
58
- if (authored === undefined) {
59
- return undefined;
60
- }
61
- return {
62
- functionId: authored.functionId ?? agentName,
63
- isEnabled: true,
64
- recordInputs: authored.recordInputs ?? true,
65
- recordOutputs: authored.recordOutputs ?? true,
66
- };
67
- }
68
- /**
69
- * Builds the `runtimeContext` passed into AI SDK calls so that
70
- * ash-specific identifiers (version, environment, session id,
71
- * continuation token) and any authored instrumentation metadata
72
- * are attached to AI SDK spans as `ai.settings.context.*` attributes.
73
- */
74
- function buildTelemetryRuntimeContext(authored, session) {
75
- if (authored === undefined) {
76
- return undefined;
77
- }
78
- return {
79
- ...authored.metadata,
80
- "ash.continuation_token": session.continuationToken,
81
- "ash.environment": environment,
82
- "ash.session.id": session.sessionId,
83
- "ash.version": ashVersion,
84
- };
85
- }
86
- /**
87
- * Resolves the gateway provider slug to pin via
88
- * `providerOptions.gateway.only` for one harness step, or `undefined`
89
- * when no pin is needed.
90
- *
91
- * A pin is added when all of:
92
- * 1. The model is gateway-routed (the `gateway-auto` cache path —
93
- * matches the existing `gateway.caching` hint condition).
94
- * 2. The effective toolset includes a framework provider tool whose
95
- * backend pins to one provider (e.g. `web_search` on Anthropic).
96
- *
97
- * The author keeps the final say via `providerOptions.gateway.only` or
98
- * `.order` on their model reference — those overrides flow through
99
- * {@link mergeGatewayProviderPin} which is a no-op when either field is
100
- * already set.
101
- */
102
- function resolveGatewayPinForStep(input) {
103
- if (input.cachePath.kind !== "gateway-auto") {
104
- return undefined;
105
- }
106
- if (input.tools[WEB_SEARCH_TOOL_DEFINITION.name] === undefined) {
107
- return undefined;
108
- }
109
- const backend = resolveWebSearchBackend(input.modelReference);
110
- if (backend === null) {
111
- return undefined;
112
- }
113
- const pin = resolveGatewayPinForWebSearchBackend(backend);
114
- return pin ?? undefined;
115
- }
116
- /**
117
- * Builds AI Gateway app attribution headers when the model is gateway-routed.
118
- *
119
- * Gateway routing is detected by `typeof model === "string"` — the same
120
- * condition used for the `gateway-auto` cache path. Returns `undefined`
121
- * for non-gateway models or when no meaningful attribution is available.
122
- */
123
- function buildGatewayAttributionHeaders(model, runtimeIdentity) {
124
- if (typeof model !== "string") {
125
- return undefined;
126
- }
127
- const title = runtimeIdentity?.agentName ?? runtimeIdentity?.agentId;
128
- const deploymentHost = process.env.VERCEL_PROJECT_PRODUCTION_URL || process.env.VERCEL_URL;
129
- const referer = deploymentHost ? `https://${deploymentHost}` : undefined;
130
- if (!title && !referer) {
131
- return undefined;
132
- }
133
- const headers = {};
134
- if (title)
135
- headers["x-title"] = title;
136
- if (referer)
137
- headers["http-referer"] = referer;
138
- return headers;
139
- }
140
- // ---------------------------------------------------------------------------
141
- // Turn trace state — survives step boundaries via session.state
142
- // ---------------------------------------------------------------------------
143
- const TURN_TRACE_STATE_KEY = "ash.harness.turnTrace";
144
- function getTurnTraceState(session) {
145
- return session.state?.[TURN_TRACE_STATE_KEY];
146
- }
147
- function setTurnTraceState(session, spanContext) {
148
- const stored = {
149
- traceId: spanContext.traceId,
150
- spanId: spanContext.spanId,
151
- traceFlags: spanContext.traceFlags,
152
- };
153
- return {
154
- ...session,
155
- state: {
156
- ...session.state,
157
- [TURN_TRACE_STATE_KEY]: stored,
158
- },
159
- };
160
- }
161
- /**
162
- * Resolves the OTel context for the current step.
163
- *
164
- * First step of a turn: uses the newly created turn span.
165
- * Continuation steps: restores the parent span context from session state
166
- * so AI SDK spans nest under the same trace as the first step.
167
- */
168
- function resolveStepOtelContext(tracer, turnSpan, session) {
169
- if (turnSpan) {
170
- return trace.setSpan(otelContext.active(), turnSpan);
171
- }
172
- if (tracer) {
173
- const stored = getTurnTraceState(session);
174
- if (stored) {
175
- const parent = trace.wrapSpanContext({
176
- traceId: stored.traceId,
177
- spanId: stored.spanId,
178
- traceFlags: stored.traceFlags,
179
- });
180
- return trace.setSpan(otelContext.active(), parent);
181
- }
182
- }
183
- return undefined;
184
- }
185
- export function createToolLoopHarness(config) {
186
- const emit = config.emit;
187
- const telemetryConfig = getInstrumentationConfig();
188
- if (telemetryConfig !== undefined) {
189
- ensureOtelIntegration();
190
- }
191
- const tracer = telemetryConfig !== undefined ? trace.getTracer("ash") : undefined;
192
- const agentName = config.runtimeIdentity?.agentName;
193
- async function runStep(initialSession, input) {
194
- // --- Turn span lifecycle ------------------------------------------------
195
- // First step of a turn: open a new parent span. Continuation steps
196
- // restore the parent from session state via resolveStepOtelContext.
197
- let turnSpan;
198
- if (tracer && hasStepInput(input)) {
199
- const functionId = telemetryConfig?.functionId ?? agentName;
200
- const attributes = {
201
- "ash.version": ashVersion,
202
- "ash.environment": environment,
203
- "ash.session.id": initialSession.sessionId,
204
- "ash.continuation_token": initialSession.continuationToken,
205
- };
206
- if (functionId) {
207
- attributes["ai.telemetry.functionId"] = functionId;
208
- }
209
- turnSpan = tracer.startSpan("ai.ash.turn", { attributes });
210
- }
211
- // Run the step body inside the turn span's (or restored parent's)
212
- // OTel context so AI SDK spans nest as children.
213
- const parentContext = resolveStepOtelContext(tracer, turnSpan, initialSession);
214
- const executeStep = () => executeStepBody(initialSession, input, turnSpan);
215
- try {
216
- if (parentContext) {
217
- return await otelContext.with(parentContext, executeStep);
218
- }
219
- return await executeStep();
220
- }
221
- finally {
222
- turnSpan?.end();
223
- }
224
- }
225
- async function executeStepBody(initialSession, input, turnSpan) {
226
- let session = initialSession;
227
- // Store the turn span context on the session so continuation steps
228
- // can restore the parent trace across step boundaries.
229
- if (turnSpan) {
230
- session = setTurnTraceState(session, turnSpan.spanContext());
231
- }
232
- let emissionState = getHarnessEmissionState(session);
233
- // Resolve deferred input, runtime actions, then HITL input; each stage
234
- // may park when its resume payload has not arrived.
235
- const stepInput = consumeDeferredStepInput({ input, session });
236
- session = stepInput.session;
237
- const resolvedRuntimeActions = await resolvePendingRuntimeActions({
238
- emit,
239
- session,
240
- stepInput: stepInput.input,
241
- });
242
- if (resolvedRuntimeActions.outcome === "unresolved") {
243
- return { next: null, session: resolvedRuntimeActions.session };
244
- }
245
- session = resolvedRuntimeActions.session;
246
- const pending = resolvePendingInput({
247
- history: resolvedRuntimeActions.messages,
248
- resolveApprovalKey: resolveApprovalKeyFromTools(config.tools),
249
- session,
250
- stepInput: stepInput.input,
251
- });
252
- if (pending.outcome === "unresolved") {
253
- return { next: null, session: pending.session };
254
- }
255
- // --- Turn preamble ------------------------------------------------------
256
- if (emit && hasStepInput(input)) {
257
- emissionState = await emitTurnPreamble(emit, input ?? {}, emissionState, config.runtimeIdentity);
258
- session = setHarnessEmissionState(session, emissionState);
259
- if (turnSpan) {
260
- turnSpan.setAttribute("ash.turn.id", emissionState.turnId);
261
- }
262
- }
263
- session = pending.session;
264
- let messages = pending.messages;
265
- if (stepInput.input?.message !== undefined && !pending.deferredMessage) {
266
- // Staging writes FilePart bytes into the sandbox and replaces
267
- // each part's `data` with a compact `ash-sandbox:` URL. The
268
- // `messages` array — and everything that flows into
269
- // `session.history` from it — therefore never carries raw
270
- // attachment bytes across step boundaries.
271
- const content = await stageAttachmentsToSandbox(stepInput.input.message);
272
- messages.push({ content, role: "user" });
273
- }
274
- // --- Model + tools ------------------------------------------------------
275
- const model = await config.resolveModel(session.agent.modelReference);
276
- const cachePath = detectPromptCachePath(model);
277
- const marker = cachePath.kind === "anthropic-direct" ? getAnthropicCacheMarker() : undefined;
278
- // --- Compaction ---------------------------------------------------------
279
- //
280
- // Runs before `agent.stream()` so the compacted messages flow through
281
- // `messages` (which the harness uses to rebuild session history).
282
- const attributionHeaders = buildGatewayAttributionHeaders(model, config.runtimeIdentity);
283
- ({ messages, session } = await maybeCompact({
284
- emit,
285
- emissionState,
286
- headers: attributionHeaders,
287
- messages,
288
- model,
289
- onCompaction: config.onCompaction,
290
- resolveModel: config.resolveModel,
291
- session,
292
- telemetry: enrichTelemetry(telemetryConfig, agentName) ?? undefined,
293
- }));
294
- const approvedTools = getApprovedTools(session);
295
- // Inject connection tools discovered by a prior `connection_search`.
296
- // Direct harness unit tests may run without an ambient context.
297
- const ctx = contextStorage.getStore();
298
- const registry = ctx?.get(ConnectionRegistryKey);
299
- const discovered = ctx?.get(DiscoveredConnectionToolsKey);
300
- // --- Execute via ToolLoopAgent ------------------------------------------
301
- /*
302
- * The `onError` override suppresses the AI SDK's default
303
- * `console.error(error)` handler inside `streamText`. Errors are
304
- * handled by the harness catch block and emitted as stream events.
305
- */
306
- // Hydrate `ash-sandbox:` ref FileParts into inline bytes for the
307
- // model call only. The result is transient — `messages` itself
308
- // remains ref-only so it can flow into `session.history` without
309
- // bloating every future step boundary.
310
- const hydratedMessages = await hydrateSandboxAttachments(messages);
311
- const ephemeralContext = stepInput.input?.modelContext;
312
- // AI SDK rejects role:"system" in `messages` — route durable history
313
- // and ephemeral context system entries to `instructions` instead.
314
- const systemMessages = [];
315
- const nonSystemMessages = [];
316
- for (const entry of hydratedMessages) {
317
- if (entry.role === "system") {
318
- systemMessages.push(entry);
319
- }
320
- else {
321
- nonSystemMessages.push(entry);
322
- }
323
- }
324
- if (ephemeralContext !== undefined) {
325
- for (const entry of ephemeralContext) {
326
- if (entry.role === "system") {
327
- systemMessages.push(entry);
328
- }
329
- else {
330
- nonSystemMessages.push(entry);
331
- }
332
- }
333
- }
334
- const modelMessages = nonSystemMessages;
335
- /**
336
- * Assembles the effective toolset, instructions, and ToolLoopAgent
337
- * for one attempt of this step, then runs the model call.
338
- *
339
- * Called twice in the recovery path: once for the original attempt
340
- * with full tools, and once after the gateway rejects a
341
- * provider-specific tool — the retry passes `disabledProviderTools`
342
- * to drop the offending tool and `extraSystemNote` to tell the
343
- * model why a capability was removed.
344
- */
345
- const runOneModelCall = async (opts) => {
346
- const tools = await buildToolSetWithProviderTools({
347
- approvedTools,
348
- capabilities: config.capabilities,
349
- disabledProviderTools: opts.disabledProviderTools,
350
- modelReference: session.agent.modelReference,
351
- tools: config.tools,
352
- });
353
- if (registry !== undefined && discovered !== undefined) {
354
- const connectionTools = await resolveConnectionToolsFromState(registry, discovered, {
355
- approvedTools,
356
- existingToolNames: new Set(Object.keys(tools)),
357
- });
358
- Object.assign(tools, connectionTools);
359
- }
360
- const effectiveTools = marker ? applyLastToolCacheBreakpoint(tools, marker) : tools;
361
- // Pin gateway routing to the provider that owns any
362
- // provider-specific tool in this step's toolset. Converts a
363
- // transient primary outage into a retryable 503 instead of
364
- // routing to an incompatible fallback provider. Skipped on the
365
- // recovery retry because the offending tool was dropped — any
366
- // provider can serve the request now.
367
- const gatewayPinProvider = resolveGatewayPinForStep({
368
- cachePath,
369
- modelReference: session.agent.modelReference,
370
- tools: effectiveTools,
371
- });
372
- // Build instructions, optionally prepending the recovery
373
- // system note so the model sees one explicit signal that a
374
- // capability was removed for this attempt.
375
- const extraSystemEntry = opts.extraSystemNote
376
- ? [{ role: "system", content: opts.extraSystemNote }]
377
- : [];
378
- const baseSystemEntry = session.agent.system
379
- ? [{ role: "system", content: session.agent.system }]
380
- : [];
381
- const instructions = systemMessages.length > 0 || extraSystemEntry.length > 0
382
- ? [...extraSystemEntry, ...baseSystemEntry, ...systemMessages]
383
- : session.agent.system || undefined;
384
- const hooks = buildStepHooks({
385
- cachePath,
386
- emit,
387
- emissionState,
388
- emitStepStarted: opts.suppressStepStartedEmission !== true,
389
- gatewayPinProvider,
390
- marker,
391
- session,
392
- });
393
- const agentSettings = {
394
- headers: attributionHeaders,
395
- instructions,
396
- model,
397
- onError() { },
398
- onStepFinish: hooks.onStepFinish,
399
- prepareStep: hooks.prepareStep,
400
- runtimeContext: buildTelemetryRuntimeContext(telemetryConfig, session),
401
- stopWhen: isStepCount(1),
402
- telemetry: enrichTelemetry(telemetryConfig, agentName),
403
- tools: effectiveTools,
404
- };
405
- const agent = new ToolLoopAgent(agentSettings);
406
- const executeModelCall = async () => {
407
- if (emit) {
408
- const streamResult = await agent.stream({ messages: modelMessages });
409
- const { inlineActionResultCallIds, inlineToolResultParts } = await emitStreamContent(emit, emissionState, streamResult.fullStream);
410
- const stepResult = await hooks.stepResult;
411
- await emitStepActions(emit, emissionState, stepResult, {
412
- excludedActionToolNames: new Set([ASK_QUESTION_TOOL_NAME]),
413
- inlineActionResultCallIds,
414
- tools: config.tools,
415
- });
416
- if (inlineToolResultParts.length > 0) {
417
- /*
418
- * AI SDK `StepResult` is a class whose `content`,
419
- * `toolCalls`, `toolResults`, `text` are prototype getters.
420
- * Each field is read explicitly here rather than via spread
421
- * so the returned plain object carries the values — spread
422
- * would copy only own enumerable properties and the
423
- * downstream `extractQuestionInputRequests` would crash on
424
- * `toolCalls === undefined`.
425
- */
426
- return {
427
- content: stepResult.content,
428
- finishReason: stepResult.finishReason,
429
- response: {
430
- ...stepResult.response,
431
- messages: [
432
- { role: "tool", content: [...inlineToolResultParts] },
433
- ...stepResult.response.messages,
434
- ],
435
- },
436
- text: stepResult.text,
437
- toolCalls: stepResult.toolCalls,
438
- toolResults: stepResult.toolResults,
439
- usage: stepResult.usage,
440
- };
441
- }
442
- return stepResult;
443
- }
444
- await agent.generate({ messages: modelMessages });
445
- return await hooks.stepResult;
446
- };
447
- return runModelCallWithRetries(executeModelCall, {
448
- sessionId: session.sessionId,
449
- turnId: emissionState.turnId,
450
- });
451
- };
452
- let result;
453
- try {
454
- result = await runOneModelCall({});
455
- }
456
- catch (error) {
457
- // First, try to recover by dropping any provider-specific tool
458
- // that the AI Gateway's fallback provider rejected. This converts
459
- // the otherwise-terminal failure into one extra model call with a
460
- // degraded toolset — the agent's turn proceeds without the
461
- // capability the chosen provider could not serve.
462
- const recoveryResult = await attemptUnsupportedProviderToolRecovery({
463
- error,
464
- runOneModelCall,
465
- sessionId: session.sessionId,
466
- turnId: emissionState.turnId,
467
- });
468
- if (recoveryResult.outcome === "recovered") {
469
- result = recoveryResult.result;
470
- }
471
- else {
472
- // Surface the full cause chain + upstream responseBody to OTel
473
- // via the turn span. The AI SDK's automatic
474
- // `span.recordException(err)` on its own `ai.streamText` span
475
- // only captures `error.stack` and does not traverse `cause`,
476
- // so the gateway-wrapped upstream 4xx body would otherwise be
477
- // invisible to OTel providers.
478
- const finalError = recoveryResult.error;
479
- if (turnSpan) {
480
- recordErrorOnSpan(turnSpan, finalError);
481
- }
482
- if (!emit) {
483
- // Internal harness callers without an emit fn (tests, task-only
484
- // code paths) get the raw throw. Only runtime-connected harness
485
- // calls go through the structured failure path below.
486
- throw finalError;
487
- }
488
- const classification = classifyModelCallError(finalError);
489
- const errorId = createErrorId();
490
- const configSummary = classification === "terminal" ? summarizeKnownModelCallConfigError(finalError) : null;
491
- const requestSummary = configSummary === null ? summarizeKnownModelCallRequestError(finalError) : null;
492
- const errorMessage = configSummary?.message ?? requestSummary?.message ?? toErrorMessage(finalError);
493
- const modelCallDetails = extractModelCallErrorDetails(finalError);
494
- const details = buildModelCallFailureDetails({
495
- configSummary,
496
- error: finalError,
497
- errorId,
498
- modelCallDetails,
499
- requestSummary,
500
- });
501
- const modelCallLogFields = buildModelCallFailureLogFields({
502
- error: finalError,
503
- errorId,
504
- modelCallDetails,
505
- requestSummary,
506
- sessionId: session.sessionId,
507
- turnId: emissionState.turnId,
508
- });
509
- if (classification === "terminal") {
510
- if (configSummary !== null) {
511
- // Recognized configuration failure: log a concise single line
512
- // and skip the structured SDK dump so the user sees an
513
- // actionable hint instead of a wall of inspector output.
514
- log.error(`${configSummary.name}: ${configSummary.message}`, {
515
- errorId,
516
- sessionId: session.sessionId,
517
- turnId: emissionState.turnId,
518
- });
519
- }
520
- else {
521
- log.error(requestSummary?.message ?? "model call failed terminally", modelCallLogFields);
522
- }
523
- await emitFailedStep(emit, emissionState, {
524
- code: "MODEL_CALL_FAILED",
525
- details,
526
- message: errorMessage,
527
- sessionId: session.sessionId,
528
- });
529
- return {
530
- next: { done: true, output: "" },
531
- session,
532
- };
533
- }
534
- log.error(requestSummary?.message ?? "model call failed — parking session for retry by the user", modelCallLogFields);
535
- emissionState = await emitRecoverableFailedTurn(emit, emissionState, {
536
- code: "MODEL_CALL_FAILED",
537
- details,
538
- message: errorMessage,
539
- });
540
- const parkedSession = setHarnessEmissionState(session, emissionState);
541
- return { next: null, session: parkedSession };
542
- }
543
- }
544
- // --- Handle result ------------------------------------------------------
545
- return handleStepResult({
546
- config,
547
- emit,
548
- emissionState,
549
- promptMessages: messages,
550
- result,
551
- runStep,
552
- session,
553
- });
554
- }
555
- return runStep;
556
- }
557
- // ---------------------------------------------------------------------------
558
- // Model-call failure projection
559
- // ---------------------------------------------------------------------------
560
- /**
561
- * Projects a model-call failure into the `step.failed` / `turn.failed`
562
- * `details` payload. Three mutually exclusive branches:
563
- *
564
- * 1. Config summary (known terminal: missing key, gateway auth) → friendly
565
- * `name` + `message`, no SDK inspector dump.
566
- * 2. Request summary (ambiguous gateway 4xx that we recover from) → raw
567
- * error `message`, friendly `name`, no inspector dump.
568
- * 3. Fallback → full {@link formatError} projection (cause chain via
569
- * `util.inspect`) so unrecognized failures still carry the upstream
570
- * stack to log aggregators.
571
- *
572
- * All branches merge {@link extractModelCallErrorDetails} on top so the
573
- * compact gateway diagnostics (`statusCode`, `upstreamMessage`,
574
- * `responseBodySnippet`, ...) always show up next to the message.
575
- */
576
- function buildModelCallFailureDetails(input) {
577
- const { configSummary, error, errorId, modelCallDetails, requestSummary } = input;
578
- if (configSummary !== null) {
579
- return {
580
- errorId,
581
- message: configSummary.message,
582
- name: configSummary.name,
583
- ...modelCallDetails,
584
- };
585
- }
586
- if (requestSummary !== null) {
587
- return {
588
- errorId,
589
- message: toErrorMessage(error),
590
- name: requestSummary.name,
591
- ...modelCallDetails,
592
- };
593
- }
594
- return { ...formatError(error, errorId), ...modelCallDetails };
595
- }
596
- /**
597
- * Builds the structured log fields for a model-call failure. When we
598
- * recognized the failure as an ambiguous gateway request rejection, attach
599
- * the compact `details` payload and *omit* the raw `error` so the logger's
600
- * `util.inspect` of the cause chain (which would render `[object Object]`
601
- * for upstream `APICallError` shapes) is bypassed. Otherwise fall back to
602
- * the raw error so unrecognized failures keep their full stack in logs.
603
- */
604
- function buildModelCallFailureLogFields(input) {
605
- const base = {
606
- errorId: input.errorId,
607
- sessionId: input.sessionId,
608
- turnId: input.turnId,
609
- };
610
- if (input.requestSummary !== null) {
611
- return { ...base, details: input.modelCallDetails };
612
- }
613
- return { ...base, error: input.error };
614
- }
615
- /**
616
- * Inspects a model-call failure for the "tool type 'X' is not supported"
617
- * provider-attempt rejection that AI Gateway returns when a fallback
618
- * provider cannot serve a provider-specific tool. On a match, retries the
619
- * step once with the offending tool dropped and a one-shot system note
620
- * telling the model which capability has been removed.
621
- *
622
- * Returns `recovered` when the retry succeeded so the caller can hand
623
- * the result off to the usual post-step handler. Returns `failed`
624
- * (with the original error, or the retry's error if the retry also
625
- * threw) otherwise so the caller's existing terminal/recoverable
626
- * cascade still runs.
627
- *
628
- * Recovery is intentionally scoped to known provider tools — entries in
629
- * {@link UPSTREAM_TOOL_TYPE_TO_FRAMEWORK_NAME} — so an unrelated
630
- * upstream rejection cannot accidentally drop a user-authored tool.
631
- */
632
- async function attemptUnsupportedProviderToolRecovery(input) {
633
- const unsupportedTypes = extractUnsupportedProviderToolTypes(input.error);
634
- if (unsupportedTypes.length === 0) {
635
- return { outcome: "failed", error: input.error };
636
- }
637
- const toolsToDisable = [];
638
- for (const type of unsupportedTypes) {
639
- const frameworkName = resolveFrameworkToolFromUpstreamType(type);
640
- if (frameworkName !== null && !toolsToDisable.includes(frameworkName)) {
641
- toolsToDisable.push(frameworkName);
642
- }
643
- }
644
- if (toolsToDisable.length === 0) {
645
- return { outcome: "failed", error: input.error };
646
- }
647
- log.warn("disabling unsupported provider tool(s); retrying step once", {
648
- disabled: toolsToDisable,
649
- sessionId: input.sessionId,
650
- turnId: input.turnId,
651
- upstreamTypes: unsupportedTypes,
652
- });
653
- try {
654
- const result = await input.runOneModelCall({
655
- disabledProviderTools: new Set(toolsToDisable),
656
- extraSystemNote: buildDisabledToolNote(toolsToDisable),
657
- suppressStepStartedEmission: true,
658
- });
659
- return { outcome: "recovered", result };
660
- }
661
- catch (retryError) {
662
- return { outcome: "failed", error: retryError };
663
- }
664
- }
665
- /**
666
- * Builds the one-shot system note prepended to the recovery retry's
667
- * instructions so the model has explicit context for why a capability
668
- * disappeared mid-turn.
669
- */
670
- function buildDisabledToolNote(toolNames) {
671
- const list = toolNames.join(", ");
672
- const noun = toolNames.length === 1 ? "tool is" : "tools are";
673
- return (`The following ${noun} not available with the current model and ` +
674
- `has been removed: ${list}. Proceed using the remaining tools or your ` +
675
- `training knowledge.`);
676
- }
677
- // ---------------------------------------------------------------------------
678
- // Post-step result handling
679
- // ---------------------------------------------------------------------------
680
- /**
681
- * Processes the step result: extracts input requests, decides whether to
682
- * park, continue the tool loop, or terminate.
683
- */
684
- async function handleStepResult(input) {
685
- const { config, emit, promptMessages, result, runStep } = input;
686
- let { emissionState, session } = input;
687
- const responseMessages = result.response.messages;
688
- const stepOutput = resolveAssistantStepText(responseMessages, result.text);
689
- const approvalRequests = extractToolApprovalInputRequests({ content: result.content ?? [] });
690
- const approvalRequestCallIds = new Set(approvalRequests.map((request) => request.action.callId));
691
- const questionRequests = extractQuestionInputRequests({
692
- toolCalls: result.toolCalls,
693
- excludedCallIds: approvalRequestCallIds,
694
- });
695
- const inputRequests = [...approvalRequests, ...questionRequests];
696
- const baseSession = {
697
- ...session,
698
- compaction: createNextCompactionConfig(session.compaction, promptMessages, result),
699
- };
700
- const pendingRuntimeActions = (result.toolCalls ?? [])
701
- .filter((toolCall) => !isInvalidToolCall(toolCall))
702
- .filter((toolCall) => config.tools.get(toolCall.toolName)?.runtimeAction !== undefined)
703
- .map((toolCall) => createRuntimeActionRequestFromToolCall({
704
- toolCall,
705
- tools: config.tools,
706
- }));
707
- if (pendingRuntimeActions.length > 0) {
708
- return {
709
- next: null,
710
- session: setPendingRuntimeActionBatch({
711
- actions: pendingRuntimeActions,
712
- event: {
713
- sequence: emissionState.sequence,
714
- stepIndex: emissionState.stepIndex,
715
- turnId: emissionState.turnId,
716
- },
717
- responseMessages,
718
- session: { ...baseSession, history: [...promptMessages] },
719
- }),
720
- };
721
- }
722
- // --- Park on input requests -----------------------------------------------
723
- if (inputRequests.length > 0) {
724
- let parkedSession = setPendingInputBatch({
725
- requests: inputRequests,
726
- responseMessages,
727
- session: { ...baseSession, history: [...promptMessages] },
728
- });
729
- if (emit) {
730
- await emit(createInputRequestedEvent({
731
- requests: inputRequests,
732
- sequence: emissionState.sequence,
733
- stepIndex: emissionState.stepIndex,
734
- turnId: emissionState.turnId,
735
- }));
736
- if (config.mode === "conversation") {
737
- emissionState = await emitTurnEpilogue(emit, emissionState, config.mode);
738
- parkedSession = setHarnessEmissionState(parkedSession, emissionState);
739
- }
740
- }
741
- return { next: null, session: parkedSession };
742
- }
743
- // --- Continue or terminate ------------------------------------------------
744
- const prunedHistory = pruneToolResults(promptMessages, config.retentionPolicies);
745
- const historyWasPruned = prunedHistory !== promptMessages;
746
- // When pruning rewrites messages that the model already counted, the
747
- // exact input-token snapshot recorded by createNextCompactionConfig
748
- // becomes stale. Clear it so the next step falls back to the
749
- // estimation heuristic instead of overestimating and compacting early.
750
- let compaction = baseSession.compaction;
751
- if (historyWasPruned && compaction.lastKnownInputTokens !== undefined) {
752
- compaction = {
753
- recentWindowSize: compaction.recentWindowSize,
754
- threshold: compaction.threshold,
755
- };
756
- }
757
- const updatedHistory = [...prunedHistory, ...responseMessages];
758
- let nextSession = { ...baseSession, compaction, history: updatedHistory };
759
- const continueLoop = responseMessages.at(-1)?.role === "tool" || hasDeferredStepInput(nextSession);
760
- if (emit) {
761
- if (!continueLoop) {
762
- emissionState = await emitTurnEpilogue(emit, emissionState, config.mode);
763
- }
764
- else {
765
- emissionState = advanceStep(emissionState);
766
- }
767
- nextSession = setHarnessEmissionState(nextSession, emissionState);
768
- }
769
- if (continueLoop) {
770
- return { next: runStep, session: nextSession };
771
- }
772
- return {
773
- next: config.mode === "task" ? { done: true, output: stepOutput ?? "" } : null,
774
- session: nextSession,
775
- };
776
- }
777
- function createNextCompactionConfig(current, promptMessages, result) {
778
- const next = {
779
- recentWindowSize: current.recentWindowSize,
780
- threshold: current.threshold,
781
- };
782
- if (result.usage?.inputTokens !== undefined) {
783
- next.lastKnownInputTokens = result.usage.inputTokens;
784
- next.lastKnownPromptMessageCount = promptMessages.length;
785
- }
786
- return next;
787
- }
788
- /**
789
- * Runs the compaction pipeline once if the session's input-token estimate
790
- * is over the configured threshold. Mutates neither input; returns the new
791
- * messages array and (possibly updated) session.
792
- *
793
- * Kept in the tool-loop (rather than the AI SDK's `prepareStep` hook) so
794
- * the compacted messages flow through the same `messages` variable the
795
- * harness uses to rebuild `session.history` after the step.
796
- */
797
- async function maybeCompact(input) {
798
- const { emit, emissionState } = input;
799
- let messages = input.messages;
800
- let session = input.session;
801
- if (!shouldCompact(messages, session.compaction)) {
802
- return { messages, session };
803
- }
804
- const compaction = await resolveCompactionModel({
805
- compactionModelReference: session.agent.compactionModelReference,
806
- model: input.model,
807
- modelReference: session.agent.modelReference,
808
- resolveModel: input.resolveModel,
809
- });
810
- if (emit) {
811
- await emit(createCompactionRequestedEvent({
812
- modelId: formatLanguageModelGatewayId(compaction.model),
813
- sequence: emissionState.sequence,
814
- sessionId: session.sessionId,
815
- turnId: emissionState.turnId,
816
- usageInputTokens: getInputTokenCount(messages, session.compaction),
817
- }));
818
- }
819
- messages = await compactMessages(messages, compaction.model, session.compaction, compaction.providerOptions, input.telemetry, input.headers);
820
- if (input.onCompaction) {
821
- const compacted = await input.onCompaction(session);
822
- session = compacted.session;
823
- for (const msg of compacted.messages) {
824
- messages.push(msg);
825
- }
826
- }
827
- if (emit) {
828
- await emit(createCompactionCompletedEvent({
829
- modelId: formatLanguageModelGatewayId(compaction.model),
830
- sequence: emissionState.sequence,
831
- sessionId: session.sessionId,
832
- turnId: emissionState.turnId,
833
- }));
834
- }
835
- return { messages, session };
836
- }
837
- /**
838
- * Creates an approval-key resolver from the tool map. The resolver computes
839
- * compound keys at recording time instead of pre-computing and persisting
840
- * them on the pending batch.
841
- */
842
- function resolveApprovalKeyFromTools(tools) {
843
- return (request) => {
844
- const toolDef = tools.get(request.action.toolName);
845
- if (toolDef?.approvalKey === undefined) {
846
- return undefined;
847
- }
848
- return toolDef.approvalKey(request.action.input);
849
- };
850
- }
851
- /**
852
- * Retries `fn` with exponential backoff while the thrown error is
853
- * classified as `"retry"`. Rethrows the last error once attempts are
854
- * exhausted or the error is classified as something other than
855
- * transient.
856
- */
857
- async function runModelCallWithRetries(fn, diag) {
858
- for (let attempt = 1;; attempt++) {
859
- try {
860
- return await fn();
861
- }
862
- catch (error) {
863
- if (attempt === MODEL_CALL_MAX_ATTEMPTS || classifyModelCallError(error) !== "retry") {
864
- throw error;
865
- }
866
- const delayMs = MODEL_CALL_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) + Math.floor(Math.random() * 250);
867
- log.warn("model call failed transiently — retrying", {
868
- attempt,
869
- delayMs,
870
- sessionId: diag.sessionId,
871
- turnId: diag.turnId,
872
- error,
873
- });
874
- await new Promise((resolve) => setTimeout(resolve, delayMs));
875
- }
876
- }
877
- }
1
+ import{createErrorId,createLogger,formatError,recordErrorOnSpan}from"#internal/logging.js";import{toErrorMessage}from"#shared/errors.js";import{createCompactionCompletedEvent,createCompactionRequestedEvent,createInputRequestedEvent}from"#protocol/message.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{contextStorage}from"#context/container.js";import{context,trace}from"#compiled/@opentelemetry/api/index.js";import{ConnectionRegistryKey,DiscoveredConnectionToolsKey}from"#runtime/framework-tools/connection-search.js";import{ToolLoopAgent,isStepCount}from"ai";import{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{consumeDeferredStepInput,getApprovedTools,hasDeferredStepInput,hasStepInput,resolvePendingInput,setPendingInputBatch}from"#harness/input-requests.js";import{createRuntimeActionRequestFromToolCall,resolvePendingRuntimeActions,setPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{resolveAssistantStepText}from"#harness/messages.js";import{ASK_QUESTION_TOOL_NAME}from"#runtime/framework-tools/ask-question.js";import{WEB_SEARCH_TOOL_DEFINITION}from"#runtime/framework-tools/web-search.js";import{extractQuestionInputRequests,extractToolApprovalInputRequests}from"#harness/input-extraction.js";import{applyLastToolCacheBreakpoint,detectPromptCachePath,getAnthropicCacheMarker}from"#harness/prompt-cache.js";import{resolveFrameworkToolFromUpstreamType,resolveGatewayPinForWebSearchBackend,resolveWebSearchBackend}from"#harness/provider-tools.js";import{resolveConnectionToolsFromState}from"#runtime/framework-tools/connection-tools.js";import{hydrateSandboxAttachments,stageAttachmentsToSandbox}from"#harness/attachment-staging.js";import{compactMessages,getInputTokenCount,resolveCompactionModel,shouldCompact}from"#harness/compaction.js";import{getInstrumentationConfig}from"#harness/instrumentation-config.js";import{classifyModelCallError,extractModelCallErrorDetails,extractUnsupportedProviderToolTypes,summarizeKnownModelCallConfigError,summarizeKnownModelCallRequestError}from"#harness/model-call-error.js";import{ensureOtelIntegration}from"#harness/otel-integration.js";import{buildStepHooks,emitStepActions,isInvalidToolCall}from"#harness/step-hooks.js";import{pruneToolResults}from"#harness/tool-result-pruning.js";import{buildToolSetWithProviderTools}from"#harness/tools.js";var environment=process.env.NODE_ENV??`unknown`,ashVersion=resolveInstalledPackageInfo().version,log=createLogger(`harness.tool-loop`),MODEL_CALL_MAX_ATTEMPTS=3,MODEL_CALL_RETRY_BASE_DELAY_MS=500;function enrichTelemetry(e,t){if(e!==void 0)return{functionId:e.functionId??t,isEnabled:!0,recordInputs:e.recordInputs??!0,recordOutputs:e.recordOutputs??!0}}function buildTelemetryRuntimeContext(e,t){if(e!==void 0)return{...e.metadata,"ash.continuation_token":t.continuationToken,"ash.environment":environment,"ash.session.id":t.sessionId,"ash.version":ashVersion}}function resolveGatewayPinForStep(e){if(e.cachePath.kind!==`gateway-auto`||e.tools[WEB_SEARCH_TOOL_DEFINITION.name]===void 0)return;let t=resolveWebSearchBackend(e.modelReference);return t===null?void 0:resolveGatewayPinForWebSearchBackend(t)??void 0}function buildGatewayAttributionHeaders(e,t){if(typeof e!=`string`)return;let n=t?.agentName??t?.agentId,r=process.env.VERCEL_PROJECT_PRODUCTION_URL||process.env.VERCEL_URL,i=r?`https://${r}`:void 0;if(!n&&!i)return;let a={};return n&&(a[`x-title`]=n),i&&(a[`http-referer`]=i),a}var TURN_TRACE_STATE_KEY=`ash.harness.turnTrace`;function getTurnTraceState(e){return e.state?.[TURN_TRACE_STATE_KEY]}function setTurnTraceState(e,t){let n={traceId:t.traceId,spanId:t.spanId,traceFlags:t.traceFlags};return{...e,state:{...e.state,[TURN_TRACE_STATE_KEY]:n}}}function resolveStepOtelContext(e,t,n){if(t)return trace.setSpan(context.active(),t);if(e){let e=getTurnTraceState(n);if(e){let t=trace.wrapSpanContext({traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags});return trace.setSpan(context.active(),t)}}}function createToolLoopHarness(t){let n=t.emit,a=getInstrumentationConfig();a!==void 0&&ensureOtelIntegration();let o=a===void 0?void 0:trace.getTracer(`ash`),s=t.runtimeIdentity?.agentName;async function runStep(e,t){let n;if(o&&hasStepInput(t)){let t=a?.functionId??s,r={"ash.version":ashVersion,"ash.environment":environment,"ash.session.id":e.sessionId,"ash.continuation_token":e.continuationToken};t&&(r[`ai.telemetry.functionId`]=t),n=o.startSpan(`ai.ash.turn`,{attributes:r})}let r=resolveStepOtelContext(o,n,e),executeStep=()=>executeStepBody(e,t,n);try{return r?await context.with(r,executeStep):await executeStep()}finally{n?.end()}}async function executeStepBody(o,c,l){let d=o;l&&(d=setTurnTraceState(d,l.spanContext()));let f=getHarnessEmissionState(d),_=consumeDeferredStepInput({input:c,session:d});d=_.session;let x=await resolvePendingRuntimeActions({emit:n,session:d,stepInput:_.input});if(x.outcome===`unresolved`)return{next:null,session:x.session};d=x.session;let T=resolvePendingInput({history:x.messages,resolveApprovalKey:resolveApprovalKeyFromTools(t.tools),session:d,stepInput:_.input});if(T.outcome===`unresolved`)return{next:null,session:T.session};n&&hasStepInput(c)&&(f=await emitTurnPreamble(n,c??{},f,t.runtimeIdentity),d=setHarnessEmissionState(d,f),l&&l.setAttribute(`ash.turn.id`,f.turnId)),d=T.session;let E=T.messages;if(_.input?.message!==void 0&&!T.deferredMessage){let e=await stageAttachmentsToSandbox(_.input.message);E.push({content:e,role:`user`})}let D=await t.resolveModel(d.agent.modelReference),O=detectPromptCachePath(D),k=O.kind===`anthropic-direct`?getAnthropicCacheMarker():void 0,A=buildGatewayAttributionHeaders(D,t.runtimeIdentity);({messages:E,session:d}=await maybeCompact({emit:n,emissionState:f,headers:A,messages:E,model:D,onCompaction:t.onCompaction,resolveModel:t.resolveModel,session:d,telemetry:enrichTelemetry(a,s)??void 0}));let j=getApprovedTools(d),M=contextStorage.getStore(),N=M?.get(ConnectionRegistryKey),P=M?.get(DiscoveredConnectionToolsKey),F=await hydrateSandboxAttachments(E),I=_.input?.modelContext,L=[],R=[];for(let e of F)e.role===`system`?L.push(e):R.push(e);if(I!==void 0)for(let e of I)e.role===`system`?L.push(e):R.push(e);let z=R,runOneModelCall=async e=>{let r=await buildToolSetWithProviderTools({approvedTools:j,capabilities:t.capabilities,disabledProviderTools:e.disabledProviderTools,modelReference:d.agent.modelReference,tools:t.tools});if(N!==void 0&&P!==void 0){let e=await resolveConnectionToolsFromState(N,P,{approvedTools:j,existingToolNames:new Set(Object.keys(r))});Object.assign(r,e)}let i=k?applyLastToolCacheBreakpoint(r,k):r,o=resolveGatewayPinForStep({cachePath:O,modelReference:d.agent.modelReference,tools:i}),c=e.extraSystemNote?[{role:`system`,content:e.extraSystemNote}]:[],l=d.agent.system?[{role:`system`,content:d.agent.system}]:[],u=L.length>0||c.length>0?[...c,...l,...L]:d.agent.system||void 0,p=buildStepHooks({cachePath:O,emit:n,emissionState:f,emitStepStarted:e.suppressStepStartedEmission!==!0,gatewayPinProvider:o,marker:k,session:d}),m=new ToolLoopAgent({headers:A,instructions:u,model:D,onError(){},onStepFinish:p.onStepFinish,prepareStep:p.prepareStep,runtimeContext:buildTelemetryRuntimeContext(a,d),stopWhen:isStepCount(1),telemetry:enrichTelemetry(a,s),tools:i});return runModelCallWithRetries(async()=>{if(n){let e=await m.stream({messages:z}),{inlineActionResultCallIds:r,inlineToolResultParts:i}=await emitStreamContent(n,f,e.fullStream),a=await p.stepResult;return await emitStepActions(n,f,a,{excludedActionToolNames:new Set([ASK_QUESTION_TOOL_NAME]),inlineActionResultCallIds:r,tools:t.tools}),i.length>0?{content:a.content,finishReason:a.finishReason,response:{...a.response,messages:[{role:`tool`,content:[...i]},...a.response.messages]},text:a.text,toolCalls:a.toolCalls,toolResults:a.toolResults,usage:a.usage}:a}return await m.generate({messages:z}),await p.stepResult},{sessionId:d.sessionId,turnId:f.turnId})},B;try{B=await runOneModelCall({})}catch(t){let a=await attemptUnsupportedProviderToolRecovery({error:t,runOneModelCall,sessionId:d.sessionId,turnId:f.turnId});if(a.outcome===`recovered`)B=a.result;else{let t=a.error;if(l&&recordErrorOnSpan(l,t),!n)throw t;let o=classifyModelCallError(t),s=createErrorId(),c=o===`terminal`?summarizeKnownModelCallConfigError(t):null,u=c===null?summarizeKnownModelCallRequestError(t):null,p=c?.message??u?.message??toErrorMessage(t),m=extractModelCallErrorDetails(t),h=buildModelCallFailureDetails({configSummary:c,error:t,errorId:s,modelCallDetails:m,requestSummary:u}),g=buildModelCallFailureLogFields({error:t,errorId:s,modelCallDetails:m,requestSummary:u,sessionId:d.sessionId,turnId:f.turnId});return o===`terminal`?(c===null?log.error(u?.message??`model call failed terminally`,g):log.error(`${c.name}: ${c.message}`,{errorId:s,sessionId:d.sessionId,turnId:f.turnId}),await emitFailedStep(n,f,{code:`MODEL_CALL_FAILED`,details:h,message:p,sessionId:d.sessionId}),{next:{done:!0,output:``},session:d}):(log.error(u?.message??`model call failed — parking session for retry by the user`,g),f=await emitRecoverableFailedTurn(n,f,{code:`MODEL_CALL_FAILED`,details:h,message:p}),{next:null,session:setHarnessEmissionState(d,f)})}}return handleStepResult({config:t,emit:n,emissionState:f,promptMessages:E,result:B,runStep,session:d})}return runStep}function buildModelCallFailureDetails(e){let{configSummary:t,error:r,errorId:a,modelCallDetails:o,requestSummary:s}=e;return t===null?s===null?{...formatError(r,a),...o}:{errorId:a,message:toErrorMessage(r),name:s.name,...o}:{errorId:a,message:t.message,name:t.name,...o}}function buildModelCallFailureLogFields(e){let t={errorId:e.errorId,sessionId:e.sessionId,turnId:e.turnId};return e.requestSummary===null?{...t,error:e.error}:{...t,details:e.modelCallDetails}}async function attemptUnsupportedProviderToolRecovery(e){let t=extractUnsupportedProviderToolTypes(e.error);if(t.length===0)return{outcome:`failed`,error:e.error};let n=[];for(let e of t){let t=resolveFrameworkToolFromUpstreamType(e);t!==null&&!n.includes(t)&&n.push(t)}if(n.length===0)return{outcome:`failed`,error:e.error};log.warn(`disabling unsupported provider tool(s); retrying step once`,{disabled:n,sessionId:e.sessionId,turnId:e.turnId,upstreamTypes:t});try{return{outcome:`recovered`,result:await e.runOneModelCall({disabledProviderTools:new Set(n),extraSystemNote:buildDisabledToolNote(n),suppressStepStartedEmission:!0})}}catch(e){return{outcome:`failed`,error:e}}}function buildDisabledToolNote(e){let t=e.join(`, `);return`The following ${e.length===1?`tool is`:`tools are`} not available with the current model and has been removed: ${t}. Proceed using the remaining tools or your training knowledge.`}async function handleStepResult(e){let{config:t,emit:n,promptMessages:r,result:i,runStep:a}=e,{emissionState:o,session:c}=e,l=i.response.messages,u=resolveAssistantStepText(l,i.text),d=extractToolApprovalInputRequests({content:i.content??[]}),f=new Set(d.map(e=>e.action.callId)),p=extractQuestionInputRequests({toolCalls:i.toolCalls,excludedCallIds:f}),m=[...d,...p],h={...c,compaction:createNextCompactionConfig(c.compaction,r,i)},g=(i.toolCalls??[]).filter(e=>!isInvalidToolCall(e)).filter(e=>t.tools.get(e.toolName)?.runtimeAction!==void 0).map(e=>createRuntimeActionRequestFromToolCall({toolCall:e,tools:t.tools}));if(g.length>0)return{next:null,session:setPendingRuntimeActionBatch({actions:g,event:{sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId},responseMessages:l,session:{...h,history:[...r]}})};if(m.length>0){let e=setPendingInputBatch({requests:m,responseMessages:l,session:{...h,history:[...r]}});return n&&(await n(createInputRequestedEvent({requests:m,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),t.mode===`conversation`&&(o=await emitTurnEpilogue(n,o,t.mode),e=setHarnessEmissionState(e,o))),{next:null,session:e}}let v=pruneToolResults(r,t.retentionPolicies),y=v!==r,b=h.compaction;y&&b.lastKnownInputTokens!==void 0&&(b={recentWindowSize:b.recentWindowSize,threshold:b.threshold});let S=[...v,...l],C={...h,compaction:b,history:S},w=l.at(-1)?.role===`tool`||hasDeferredStepInput(C);return n&&(o=w?advanceStep(o):await emitTurnEpilogue(n,o,t.mode),C=setHarnessEmissionState(C,o)),w?{next:a,session:C}:{next:t.mode===`task`?{done:!0,output:u??``}:null,session:C}}function createNextCompactionConfig(e,t,n){let r={recentWindowSize:e.recentWindowSize,threshold:e.threshold};return n.usage?.inputTokens!==void 0&&(r.lastKnownInputTokens=n.usage.inputTokens,r.lastKnownPromptMessageCount=t.length),r}async function maybeCompact(e){let{emit:t,emissionState:n}=e,r=e.messages,i=e.session;if(!shouldCompact(r,i.compaction))return{messages:r,session:i};let s=await resolveCompactionModel({compactionModelReference:i.agent.compactionModelReference,model:e.model,modelReference:i.agent.modelReference,resolveModel:e.resolveModel});if(t&&await t(createCompactionRequestedEvent({modelId:formatLanguageModelGatewayId(s.model),sequence:n.sequence,sessionId:i.sessionId,turnId:n.turnId,usageInputTokens:getInputTokenCount(r,i.compaction)})),r=await compactMessages(r,s.model,i.compaction,s.providerOptions,e.telemetry,e.headers),e.onCompaction){let t=await e.onCompaction(i);i=t.session;for(let e of t.messages)r.push(e)}return t&&await t(createCompactionCompletedEvent({modelId:formatLanguageModelGatewayId(s.model),sequence:n.sequence,sessionId:i.sessionId,turnId:n.turnId})),{messages:r,session:i}}function resolveApprovalKeyFromTools(e){return t=>{let n=e.get(t.action.toolName);if(n?.approvalKey!==void 0)return n.approvalKey(t.action.input)}}async function runModelCallWithRetries(e,t){for(let n=1;;n++)try{return await e()}catch(e){if(n===MODEL_CALL_MAX_ATTEMPTS||classifyModelCallError(e)!==`retry`)throw e;let r=MODEL_CALL_RETRY_BASE_DELAY_MS*2**(n-1)+Math.floor(Math.random()*250);log.warn(`model call failed transiently — retrying`,{attempt:n,delayMs:r,sessionId:t.sessionId,turnId:t.turnId,error:e}),await new Promise(e=>setTimeout(e,r))}}export{createToolLoopHarness};