experimental-ash 0.28.0 → 0.29.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 (345) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -0
  3. package/dist/docs/internals/hooks.md +1 -1
  4. package/dist/docs/public/cli-build-and-debugging.md +2 -0
  5. package/dist/docs/public/getting-started.md +1 -0
  6. package/dist/src/channel/adapter.js +1 -1
  7. package/dist/src/channel/compiled-channel.js +1 -1
  8. package/dist/src/channel/http.js +1 -1
  9. package/dist/src/channel/schedule.js +1 -1
  10. package/dist/src/channel/send.js +1 -1
  11. package/dist/src/channel/session-callback.js +1 -1
  12. package/dist/src/channel/session.js +1 -1
  13. package/dist/src/cli/commands/channels.js +1 -1
  14. package/dist/src/cli/dev/environment.js +1 -1
  15. package/dist/src/cli/dev/input-requests.js +1 -1
  16. package/dist/src/cli/dev/repl.js +1 -1
  17. package/dist/src/cli/dev/terminal.js +1 -1
  18. package/dist/src/cli/dev/url.js +1 -1
  19. package/dist/src/cli/run.d.ts +9 -0
  20. package/dist/src/cli/run.js +1 -1
  21. package/dist/src/compiler/artifacts.js +1 -1
  22. package/dist/src/compiler/manifest.js +1 -1
  23. package/dist/src/compiler/model-catalog.js +1 -1
  24. package/dist/src/compiler/module-map.js +1 -1
  25. package/dist/src/compiler/normalize-subagent.js +1 -1
  26. package/dist/src/compiler/remote-agent-node.js +1 -1
  27. package/dist/src/compiler/workspace-resources.js +1 -1
  28. package/dist/src/context/accessors.js +1 -1
  29. package/dist/src/context/container.js +1 -1
  30. package/dist/src/context/hook-lifecycle.d.ts +3 -3
  31. package/dist/src/context/hook-lifecycle.js +1 -1
  32. package/dist/src/context/key.js +1 -1
  33. package/dist/src/context/keys.d.ts +31 -10
  34. package/dist/src/context/keys.js +1 -1
  35. package/dist/src/context/node.js +1 -1
  36. package/dist/src/context/providers/connection.js +1 -1
  37. package/dist/src/context/providers/sandbox.js +1 -1
  38. package/dist/src/context/providers/session.js +1 -1
  39. package/dist/src/context/run-step.js +1 -1
  40. package/dist/src/context/serialize.js +1 -1
  41. package/dist/src/discover/connections.js +1 -1
  42. package/dist/src/discover/diagnostics.js +1 -1
  43. package/dist/src/discover/discover-subagent.js +1 -1
  44. package/dist/src/discover/filesystem.js +1 -1
  45. package/dist/src/discover/grammar.js +1 -1
  46. package/dist/src/discover/lib.js +1 -1
  47. package/dist/src/discover/manifest.js +1 -1
  48. package/dist/src/discover/sandbox.js +1 -1
  49. package/dist/src/discover/schedules.js +1 -1
  50. package/dist/src/discover/skills.js +1 -1
  51. package/dist/src/evals/runner/discover.js +1 -1
  52. package/dist/src/evals/runner/execute-suite.js +1 -1
  53. package/dist/src/evals/runner/reporters/braintrust.js +1 -1
  54. package/dist/src/evals/scores/index.js +1 -1
  55. package/dist/src/execution/await-authorization-orchestrator.js +1 -1
  56. package/dist/src/execution/connection-auth-steps.js +1 -1
  57. package/dist/src/execution/runtime-context.d.ts +1 -1
  58. package/dist/src/execution/runtime-context.js +1 -1
  59. package/dist/src/execution/sandbox/bindings/local.js +1 -1
  60. package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
  61. package/dist/src/execution/sandbox/glob-tool.js +1 -1
  62. package/dist/src/execution/sandbox/grep-tool.js +1 -1
  63. package/dist/src/execution/sandbox/prewarm.d.ts +12 -2
  64. package/dist/src/execution/sandbox/prewarm.js +1 -1
  65. package/dist/src/execution/sandbox/read-file-tool.js +1 -1
  66. package/dist/src/execution/sandbox/require-sandbox.js +1 -1
  67. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
  68. package/dist/src/execution/sandbox/truncate-output.js +1 -1
  69. package/dist/src/execution/session-callback-step.js +1 -1
  70. package/dist/src/execution/session.js +1 -1
  71. package/dist/src/execution/subagent-adapter.js +1 -1
  72. package/dist/src/execution/tool-compaction.js +1 -1
  73. package/dist/src/execution/turn-workflow.js +1 -1
  74. package/dist/src/execution/web-fetch/html.js +1 -1
  75. package/dist/src/execution/web-fetch/tool.js +1 -1
  76. package/dist/src/execution/workflow-entry.js +1 -1
  77. package/dist/src/execution/workflow-runtime.js +1 -1
  78. package/dist/src/execution/workflow-steps.js +1 -1
  79. package/dist/src/harness/attachment-staging.js +1 -1
  80. package/dist/src/harness/compaction.js +2 -2
  81. package/dist/src/harness/emission.js +1 -1
  82. package/dist/src/harness/input-requests.js +1 -1
  83. package/dist/src/harness/instrumentation-config.js +1 -1
  84. package/dist/src/harness/model-call-error.js +1 -1
  85. package/dist/src/harness/otel-integration.js +1 -1
  86. package/dist/src/harness/prompt-cache.js +1 -1
  87. package/dist/src/harness/provider-tools.js +1 -1
  88. package/dist/src/harness/proxy-input-requests.js +1 -1
  89. package/dist/src/harness/runtime-actions.js +1 -1
  90. package/dist/src/harness/step-hooks.js +1 -1
  91. package/dist/src/harness/tool-loop.js +1 -1
  92. package/dist/src/harness/tool-result-pruning.js +1 -1
  93. package/dist/src/internal/application/cache-metadata.js +1 -1
  94. package/dist/src/internal/application/compiled-artifacts.js +1 -1
  95. package/dist/src/internal/application/import-specifier.js +1 -1
  96. package/dist/src/internal/application/package.js +1 -1
  97. package/dist/src/internal/attachments/refs.js +1 -1
  98. package/dist/src/internal/attachments/sandbox-refs.js +1 -1
  99. package/dist/src/internal/attachments/url-refs.js +1 -1
  100. package/dist/src/internal/authored-asset-import-plugin.js +1 -1
  101. package/dist/src/internal/authored-definition/connection.js +1 -1
  102. package/dist/src/internal/authored-module-loader.js +1 -1
  103. package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
  104. package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
  105. package/dist/src/internal/helpers/markdown.js +2 -2
  106. package/dist/src/internal/json-schema.js +1 -1
  107. package/dist/src/internal/logging.js +1 -1
  108. package/dist/src/internal/nitro/host/channel-routes.js +1 -1
  109. package/dist/src/internal/nitro/host/compiled-sandbox-backend-prune-plugin.js +1 -1
  110. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  111. package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
  112. package/dist/src/internal/nitro/host/schedule-task-routes.js +1 -1
  113. package/dist/src/internal/nitro/host/server-external-packages.js +1 -1
  114. package/dist/src/internal/nitro/host/start-development-server.js +1 -1
  115. package/dist/src/internal/nitro/host/start-production-server.d.ts +8 -0
  116. package/dist/src/internal/nitro/host/start-production-server.js +3 -0
  117. package/dist/src/internal/nitro/host/types.d.ts +8 -0
  118. package/dist/src/internal/nitro/host.d.ts +2 -1
  119. package/dist/src/internal/nitro/host.js +1 -1
  120. package/dist/src/internal/nitro/routes/agent-info/load-agent-info-data.js +1 -1
  121. package/dist/src/internal/nitro/routes/index.js +3 -3
  122. package/dist/src/internal/nitro/routes/workflow-route-helpers.js +1 -1
  123. package/dist/src/internal/node-esm-compat-banner.js +1 -1
  124. package/dist/src/internal/package-name.js +1 -1
  125. package/dist/src/internal/vercel-agent-summary.js +1 -1
  126. package/dist/src/internal/workflow-bundle/ash-service-route-output.js +1 -1
  127. package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
  128. package/dist/src/internal/workflow-bundle/builder.js +2 -2
  129. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  130. package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
  131. package/dist/src/internal/workflow-bundle/workflow-core-shim.js +1 -1
  132. package/dist/src/internal/workflow-bundle/workflow-transformer.js +1 -1
  133. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/ajv.js +1 -1
  134. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +1 -1
  135. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +2 -2
  136. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +1 -1
  137. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +1 -1
  138. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -1
  139. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +1 -1
  140. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +1 -1
  141. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +1 -1
  142. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -1
  143. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +1 -1
  144. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +1 -1
  145. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +2 -2
  146. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +1 -1
  147. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +1 -1
  148. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +1 -1
  149. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +1 -1
  150. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -1
  151. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +1 -1
  152. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +1 -1
  153. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +1 -1
  154. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +1 -1
  155. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -1
  156. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +1 -1
  157. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +2 -2
  158. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +1 -1
  159. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
  160. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +1 -1
  161. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +1 -1
  162. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +1 -1
  163. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +1 -1
  164. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +1 -1
  165. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +1 -1
  166. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +1 -1
  167. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +1 -1
  168. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +1 -1
  169. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +1 -1
  170. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
  171. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +1 -1
  172. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +1 -1
  173. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft7.js +1 -1
  174. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +1 -1
  175. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +1 -1
  176. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +1 -1
  177. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +1 -1
  178. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +1 -1
  179. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +1 -1
  180. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +1 -1
  181. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +1 -1
  182. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +1 -1
  183. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +1 -1
  184. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +1 -1
  185. package/dist/src/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +1 -1
  186. package/dist/src/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js +1 -1
  187. package/dist/src/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js +1 -1
  188. package/dist/src/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js +1 -1
  189. 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 -2
  190. 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 -1
  191. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/azure.js +1 -1
  192. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/client.js +2 -2
  193. 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 -1
  194. 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 -1
  195. 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 -1
  196. 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 -1
  197. 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 -1
  198. 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 -1
  199. 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 -1
  200. 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 -1
  201. 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 -1
  202. 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 -1
  203. 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 -1
  204. 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 -1
  205. 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 -1
  206. 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 +1 -1
  207. 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 -1
  208. 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 -1
  209. 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 -1
  210. 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 -1
  211. 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 -1
  212. 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 -1
  213. package/dist/src/node_modules/.pnpm/openai@6.39.0_ws@8.21.0_zod@3.25.76/node_modules/openai/version.js +1 -1
  214. 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 -1
  215. 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 -1
  216. 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 -1
  217. 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 -1
  218. 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 -1
  219. 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 -1
  220. 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 -1
  221. 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 -1
  222. 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 -1
  223. 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 -1
  224. 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 +1 -1
  225. 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 -1
  226. 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 -1
  227. 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 -1
  228. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js +1 -1
  229. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js +1 -1
  230. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js +1 -1
  231. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js +1 -1
  232. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js +1 -1
  233. package/dist/src/node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js +1 -1
  234. package/dist/src/packages/ash-scaffold/src/channels.js +2 -2
  235. package/dist/src/packages/ash-scaffold/src/module-files.js +1 -1
  236. package/dist/src/protocol/message.js +1 -1
  237. package/dist/src/protocol/routes.js +1 -1
  238. package/dist/src/public/channels/ash.js +2 -2
  239. package/dist/src/public/channels/auth.js +1 -1
  240. package/dist/src/public/channels/discord/api.js +1 -1
  241. package/dist/src/public/channels/discord/defaults.js +1 -1
  242. package/dist/src/public/channels/discord/discordChannel.js +1 -1
  243. package/dist/src/public/channels/discord/hitl.js +1 -1
  244. package/dist/src/public/channels/discord/inbound.js +1 -1
  245. package/dist/src/public/channels/discord/verify.js +1 -1
  246. package/dist/src/public/channels/discord/verifyInbound.js +1 -1
  247. package/dist/src/public/channels/slack/api.js +1 -1
  248. package/dist/src/public/channels/slack/attachments.js +1 -1
  249. package/dist/src/public/channels/slack/constants.js +1 -1
  250. package/dist/src/public/channels/slack/defaults.js +2 -2
  251. package/dist/src/public/channels/slack/hitl.js +1 -1
  252. package/dist/src/public/channels/slack/interactions.js +1 -1
  253. package/dist/src/public/channels/slack/limits.js +1 -1
  254. package/dist/src/public/channels/slack/mrkdwn.js +1 -1
  255. package/dist/src/public/channels/slack/slackChannel.js +1 -1
  256. package/dist/src/public/channels/slack/verify.js +1 -1
  257. package/dist/src/public/channels/teams/api.js +1 -1
  258. package/dist/src/public/channels/teams/attachments.js +1 -1
  259. package/dist/src/public/channels/teams/defaults.js +1 -1
  260. package/dist/src/public/channels/teams/hitl.js +1 -1
  261. package/dist/src/public/channels/teams/inbound.js +1 -1
  262. package/dist/src/public/channels/teams/limits.js +1 -1
  263. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  264. package/dist/src/public/channels/teams/verify.js +1 -1
  265. package/dist/src/public/channels/telegram/api.js +1 -1
  266. package/dist/src/public/channels/telegram/attachments.js +1 -1
  267. package/dist/src/public/channels/telegram/defaults.js +1 -1
  268. package/dist/src/public/channels/telegram/hitl.js +1 -1
  269. package/dist/src/public/channels/telegram/inbound.js +1 -1
  270. package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
  271. package/dist/src/public/channels/telegram/verify.js +1 -1
  272. package/dist/src/public/channels/twilio/defaults.js +1 -1
  273. package/dist/src/public/channels/twilio/inbound.js +1 -1
  274. package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
  275. package/dist/src/public/channels/twilio/verify.js +1 -1
  276. package/dist/src/public/channels/upload-policy.js +1 -1
  277. package/dist/src/public/definitions/channel.js +1 -1
  278. package/dist/src/public/definitions/tool.js +1 -1
  279. package/dist/src/public/next/index.js +1 -1
  280. package/dist/src/public/next/server.js +1 -1
  281. package/dist/src/public/next/vercel-json.js +1 -1
  282. package/dist/src/public/tool-result-narrowing.js +1 -1
  283. package/dist/src/public/tools/defaults.js +1 -1
  284. package/dist/src/react/use-ash-agent.js +1 -1
  285. package/dist/src/runtime/actions/types.js +1 -1
  286. package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
  287. package/dist/src/runtime/agent/bootstrap-model.js +1 -1
  288. package/dist/src/runtime/agent/bootstrap.js +1 -1
  289. package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
  290. package/dist/src/runtime/cache-key.js +1 -1
  291. package/dist/src/runtime/channels/registry.js +1 -1
  292. package/dist/src/runtime/connections/authorization-tokens.js +1 -1
  293. package/dist/src/runtime/connections/callback-route.js +1 -1
  294. package/dist/src/runtime/connections/principal-context.js +1 -1
  295. package/dist/src/runtime/connections/principal.js +1 -1
  296. package/dist/src/runtime/framework-channels/index.js +1 -1
  297. package/dist/src/runtime/framework-tools/ask-question.js +1 -1
  298. package/dist/src/runtime/framework-tools/bash.js +1 -1
  299. package/dist/src/runtime/framework-tools/connection-search.js +1 -1
  300. package/dist/src/runtime/framework-tools/file-state.js +1 -1
  301. package/dist/src/runtime/framework-tools/glob.js +1 -1
  302. package/dist/src/runtime/framework-tools/grep.js +1 -1
  303. package/dist/src/runtime/framework-tools/index.js +1 -1
  304. package/dist/src/runtime/framework-tools/pending-connection-tool-calls.js +1 -1
  305. package/dist/src/runtime/framework-tools/read-file.js +1 -1
  306. package/dist/src/runtime/framework-tools/skill.js +1 -1
  307. package/dist/src/runtime/framework-tools/todo.js +2 -2
  308. package/dist/src/runtime/framework-tools/web-fetch.js +1 -1
  309. package/dist/src/runtime/framework-tools/web-search.js +1 -1
  310. package/dist/src/runtime/framework-tools/write-file.js +1 -1
  311. package/dist/src/runtime/governance/auth/jwt-ecdsa.js +1 -1
  312. package/dist/src/runtime/governance/auth/oidc.js +1 -1
  313. package/dist/src/runtime/governance/auth/token-claims.js +1 -1
  314. package/dist/src/runtime/graph.js +1 -1
  315. package/dist/src/runtime/input/types.js +1 -1
  316. package/dist/src/runtime/loaders/bundled-artifacts.d.ts +12 -0
  317. package/dist/src/runtime/loaders/bundled-artifacts.js +1 -1
  318. package/dist/src/runtime/loaders/compile-metadata.js +1 -1
  319. package/dist/src/runtime/loaders/manifest.js +1 -1
  320. package/dist/src/runtime/loaders/module-map.js +1 -1
  321. package/dist/src/runtime/prompt/compose.js +2 -2
  322. package/dist/src/runtime/prompt/connections.js +1 -1
  323. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  324. package/dist/src/runtime/resolve-hook.js +1 -1
  325. package/dist/src/runtime/sandbox/keys.js +1 -1
  326. package/dist/src/runtime/sandbox/registry.js +1 -1
  327. package/dist/src/runtime/schedules/register.js +1 -1
  328. package/dist/src/runtime/session-callback-route.js +1 -1
  329. package/dist/src/runtime/sessions/auth.js +1 -1
  330. package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
  331. package/dist/src/runtime/sessions/runtime-context-keys.d.ts +11 -0
  332. package/dist/src/runtime/sessions/runtime-context-keys.js +1 -0
  333. package/dist/src/runtime/sessions/runtime-session.js +1 -1
  334. package/dist/src/runtime/skills/fragment-context.js +1 -1
  335. package/dist/src/runtime/skills/sandbox-access.js +1 -1
  336. package/dist/src/runtime/subagents/registry.js +1 -1
  337. package/dist/src/runtime/workspace/types.js +1 -1
  338. package/dist/src/services/dev-client/request-headers.js +1 -1
  339. package/dist/src/services/dev-client/vercel-auth-error.js +1 -1
  340. package/dist/src/shared/json-schemas.js +1 -1
  341. package/dist/src/shared/json.js +1 -1
  342. package/dist/src/shared/skill-package.js +1 -1
  343. package/package.json +1 -1
  344. package/dist/src/context/seed-keys.d.ts +0 -39
  345. package/dist/src/context/seed-keys.js +0 -1
@@ -1,10 +1,13 @@
1
- import type { ChannelAdapter } from "#channel/adapter.js";
2
- import type { SessionAuthContext, SessionParent, SessionTurn } from "#channel/types.js";
3
- import { getCompiledRuntimeAgentBundle } from "#runtime/sessions/compiled-agent-cache.js";
4
- import type { SandboxAccess } from "#sandbox/state.js";
1
+ /**
2
+ * Leaf context keys — no codec, no runtime imports. Safe to import from any
3
+ * tier. Codec-carrying keys (`ChannelKey`, `BundleKey`) live in
4
+ * `#runtime/sessions/runtime-context-keys.ts`.
5
+ */
6
+ import type { SessionAuthContext, SessionCallback, SessionCapabilities, SessionParent, SessionTurn } from "#channel/types.js";
5
7
  import { ContextKey } from "#context/key.js";
8
+ import type { SandboxAccess } from "#sandbox/state.js";
9
+ import type { RunMode } from "#shared/run-mode.js";
6
10
  export type { SessionAuthContext, SessionParent, SessionTurn } from "#channel/types.js";
7
- export { AuthKey, CapabilitiesKey, ContinuationTokenKey, InitiatorAuthKey, ModeKey, ParentSessionKey, SessionCallbackKey, SessionIdKey, SessionPreparedKey, } from "#context/seed-keys.js";
8
11
  /**
9
12
  * Auth metadata on the active session.
10
13
  *
@@ -25,12 +28,30 @@ export interface Session {
25
28
  readonly sessionId: string;
26
29
  readonly turn: SessionTurn;
27
30
  }
28
- export declare const ChannelKey: ContextKey<ChannelAdapter>;
31
+ export declare const AuthKey: ContextKey<SessionAuthContext | null>;
32
+ export declare const InitiatorAuthKey: ContextKey<SessionAuthContext | null>;
33
+ export declare const SessionIdKey: ContextKey<string>;
34
+ export declare const ContinuationTokenKey: ContextKey<string>;
35
+ export declare const ModeKey: ContextKey<RunMode>;
36
+ export declare const ParentSessionKey: ContextKey<SessionParent>;
37
+ /**
38
+ * Session-level capability flags (see {@link SessionCapabilities}). Set
39
+ * on root runs by channel routes and inherited pointwise by subagent
40
+ * dispatch so HITL readiness flows through a conversation chain.
41
+ */
42
+ export declare const CapabilitiesKey: ContextKey<SessionCapabilities>;
43
+ /**
44
+ * Optional framework-owned terminal callback metadata for this session.
45
+ */
46
+ export declare const SessionCallbackKey: ContextKey<SessionCallback>;
29
47
  /**
30
- * Bundle returned by the compiled-agent cache. Carries the resolved agent
31
- * graph, registries, and the active node's turn agent.
48
+ * Marker durable boolean set by the runtime **before** the
49
+ * `lifecycle.session` hook chain runs. The runtime checks this flag at
50
+ * the top of every turn so the chain never runs twice for the same
51
+ * session — including when one of the hooks throws. A thrown hook is
52
+ * a terminal session failure (`session.failed`); the next turn does
53
+ * not retry. See `research/active/hooks.md`.
32
54
  */
33
- export type CompiledBundle = Awaited<ReturnType<typeof getCompiledRuntimeAgentBundle>>;
34
- export declare const BundleKey: ContextKey<import("#runtime/sessions/compiled-agent-cache.js").CompiledRuntimeAgentBundle>;
55
+ export declare const SessionPreparedKey: ContextKey<boolean>;
35
56
  export declare const SessionKey: ContextKey<Session>;
36
57
  export declare const SandboxKey: ContextKey<SandboxAccess>;
@@ -1 +1 @@
1
- import{AuthKey,CapabilitiesKey,ContinuationTokenKey,InitiatorAuthKey,ModeKey,ParentSessionKey,SessionCallbackKey,SessionIdKey,SessionPreparedKey}from"#context/seed-keys.js";import{ContextKey}from"#context/key.js";import{getAdapterKind}from"#channel/adapter.js";import{deserializeRuntimeAdapter}from"#runtime/channels/registry.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";var ChannelKey=new ContextKey(`ash.channel`,{codec:{serialize(e){return{kind:getAdapterKind(e),state:e.state?{...e.state}:{}}},deserialize(e,t){let n=t.get(BundleKey);if(n===void 0)throw Error(`Cannot deserialize "ash.channel" before "ash.bundle". The runtime bundle must be present in context.`);return deserializeRuntimeAdapter(n.adapterRegistry,e)}}}),BundleKey=new ContextKey(`ash.bundle`,{codec:{serialize:e=>({nodeId:e.nodeId,source:e.compiledArtifactsSource}),deserialize:e=>{let{source:t,nodeId:n}=e;return getCompiledRuntimeAgentBundle({compiledArtifactsSource:t,nodeId:n})}}}),SessionKey=new ContextKey(`ash.session`),SandboxKey=new ContextKey(`ash.sandbox`);export{AuthKey,BundleKey,CapabilitiesKey,ChannelKey,ContinuationTokenKey,InitiatorAuthKey,ModeKey,ParentSessionKey,SandboxKey,SessionCallbackKey,SessionIdKey,SessionKey,SessionPreparedKey};
1
+ import{ContextKey}from"#context/key.js";const AuthKey=new ContextKey(`ash.auth`),InitiatorAuthKey=new ContextKey(`ash.initiatorAuth`),SessionIdKey=new ContextKey(`ash.sessionId`),ContinuationTokenKey=new ContextKey(`ash.continuationToken`),ModeKey=new ContextKey(`ash.mode`),ParentSessionKey=new ContextKey(`ash.parentSession`),CapabilitiesKey=new ContextKey(`ash.capabilities`),SessionCallbackKey=new ContextKey(`ash.sessionCallback`),SessionPreparedKey=new ContextKey(`ash.sessionPrepared`),SessionKey=new ContextKey(`ash.session`),SandboxKey=new ContextKey(`ash.sandbox`);export{AuthKey,CapabilitiesKey,ContinuationTokenKey,InitiatorAuthKey,ModeKey,ParentSessionKey,SandboxKey,SessionCallbackKey,SessionIdKey,SessionKey,SessionPreparedKey};
@@ -1 +1 @@
1
- import{BundleKey}from"#context/keys.js";function getActiveRuntimeNode(e){return e.require(BundleKey).graph.root}export{getActiveRuntimeNode};
1
+ import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";function getActiveRuntimeNode(e){return e.require(BundleKey).graph.root}export{getActiveRuntimeNode};
@@ -1 +1 @@
1
- import{BundleKey}from"#context/keys.js";import{ConnectionRegistryImpl}from"#runtime/connections/registry.js";import{ConnectionRegistryKey}from"#runtime/framework-tools/connection-search.js";import{getActiveRuntimeNode}from"#context/node.js";var connectionProvider={key:ConnectionRegistryKey,create(e,t){if(e.get(BundleKey)===void 0)return;let n=getActiveRuntimeNode(e).agent?.connections;if(!(!n||n.length===0))return{value:new ConnectionRegistryImpl(n)}}};export{connectionProvider};
1
+ import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";import{ConnectionRegistryImpl}from"#runtime/connections/registry.js";import{ConnectionRegistryKey}from"#runtime/framework-tools/connection-search.js";import{getActiveRuntimeNode}from"#context/node.js";const connectionProvider={key:ConnectionRegistryKey,create(e,t){if(e.get(BundleKey)===void 0)return;let n=getActiveRuntimeNode(e).agent?.connections;if(!(!n||n.length===0))return{value:new ConnectionRegistryImpl(n)}}};export{connectionProvider};
@@ -1 +1 @@
1
- import{contextStorage}from"#context/container.js";import{BundleKey,ChannelKey,SandboxKey,SessionIdKey}from"#context/keys.js";import{getAdapterKind}from"#channel/adapter.js";import{getActiveRuntimeNode}from"#context/node.js";import{ensureSandboxAccess}from"#execution/sandbox/ensure.js";var sandboxProvider={key:SandboxKey,async create(r,i){let a=r.get(BundleKey);if(a===void 0)return;let o=getActiveRuntimeNode(r),s=o.sandboxRegistry,c=r.require(SessionIdKey);return{value:await ensureSandboxAccess({compiledArtifactsSource:a.compiledArtifactsSource,nodeId:o.nodeId,registry:s,runOnSession:async t=>await contextStorage.run(r,t),sessionId:c,state:i.sandboxState??null,tags:{agent:resolveTagAgentName({bundle:a,node:o}),channel:resolveTagChannelKind(r.get(ChannelKey)),sessionId:c}})}},async commit(e,t){let n=await e.captureState();return{...t,sandboxState:n}}};function resolveTagAgentName(e){let t=e.node,n=e.bundle;return t.agent?.config?.name??n.resolvedAgent?.config?.name??t.nodeId??`unknown`}function resolveTagChannelKind(e){return e===void 0?`unknown`:getAdapterKind(e)}export{sandboxProvider};
1
+ import{SandboxKey,SessionIdKey}from"#context/keys.js";import{contextStorage}from"#context/container.js";import{getAdapterKind}from"#channel/adapter.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getActiveRuntimeNode}from"#context/node.js";import{ensureSandboxAccess}from"#execution/sandbox/ensure.js";const sandboxProvider={key:SandboxKey,async create(e,r){let i=e.get(BundleKey);if(i===void 0)return;let a=getActiveRuntimeNode(e),o=a.sandboxRegistry,s=e.require(SessionIdKey);return{value:await ensureSandboxAccess({compiledArtifactsSource:i.compiledArtifactsSource,nodeId:a.nodeId,registry:o,runOnSession:async t=>await contextStorage.run(e,t),sessionId:s,state:r.sandboxState??null,tags:{agent:resolveTagAgentName({bundle:i,node:a}),channel:resolveTagChannelKind(e.get(ChannelKey)),sessionId:s}})}},async commit(e,t){let n=await e.captureState();return{...t,sandboxState:n}}};function resolveTagAgentName(e){let t=e.node,n=e.bundle;return t.agent?.config?.name??n.resolvedAgent?.config?.name??t.nodeId??`unknown`}function resolveTagChannelKind(e){return e===void 0?`unknown`:getAdapterKind(e)}export{sandboxProvider};
@@ -1 +1 @@
1
- import{AuthKey,InitiatorAuthKey,ParentSessionKey,SessionIdKey,SessionKey}from"#context/keys.js";var sessionProvider={key:SessionKey,create(e){let t=e.require(AuthKey);return{value:Object.freeze({auth:{current:t,initiator:e.get(InitiatorAuthKey)??t},parent:e.get(ParentSessionKey),sessionId:e.require(SessionIdKey),turn:{id:`turn-${crypto.randomUUID()}`,sequence:0}})}}};export{sessionProvider};
1
+ import{AuthKey,InitiatorAuthKey,ParentSessionKey,SessionIdKey,SessionKey}from"#context/keys.js";const sessionProvider={key:SessionKey,create(e){let t=e.require(AuthKey);return{value:Object.freeze({auth:{current:t,initiator:e.get(InitiatorAuthKey)??t},parent:e.get(ParentSessionKey),sessionId:e.require(SessionIdKey),turn:{id:`turn-${crypto.randomUUID()}`,sequence:0}})}}};export{sessionProvider};
@@ -1 +1 @@
1
- import{contextStorage}from"#context/container.js";import{connectionProvider}from"#context/providers/connection.js";import{sandboxProvider}from"#context/providers/sandbox.js";import{sessionProvider}from"#context/providers/session.js";var frameworkProviders=[sessionProvider,connectionProvider,sandboxProvider];async function runStep(t,n,r){let i=n;t.clearVirtualContext();for(let e of frameworkProviders){let n=await e.create(t,i);n!==void 0&&(t.setVirtualContext(e.key,n.value),n.session!==void 0&&(i=n.session))}let a=await contextStorage.run(t,()=>r(i)),o=a.session;for(let e of frameworkProviders)e.commit&&t.has(e.key)&&(o=await e.commit(t.require(e.key),o));return o===a.session?a:{next:a.next,session:o}}export{runStep};
1
+ import{contextStorage}from"#context/container.js";import{connectionProvider}from"#context/providers/connection.js";import{sandboxProvider}from"#context/providers/sandbox.js";import{sessionProvider}from"#context/providers/session.js";const frameworkProviders=[sessionProvider,connectionProvider,sandboxProvider];async function runStep(t,n,r){let i=n;t.clearVirtualContext();for(let e of frameworkProviders){let n=await e.create(t,i);n!==void 0&&(t.setVirtualContext(e.key,n.value),n.session!==void 0&&(i=n.session))}let a=await contextStorage.run(t,()=>r(i)),o=a.session;for(let e of frameworkProviders)e.commit&&t.has(e.key)&&(o=await e.commit(t.require(e.key),o));return o===a.session?a:{next:a.next,session:o}}export{runStep};
@@ -1 +1 @@
1
- import{ContextContainer}from"#context/container.js";import{BundleKey}from"#context/keys.js";import{resolveKey}from"#context/key.js";function serializeContext(e){let t={};for(let[n,r]of e.entries())t[n.name]=n.codec?n.codec.serialize(r):r;return t}async function deserializeContext(r){let i=new ContextContainer,a=r[BundleKey.name];if(a!==void 0){let e=BundleKey.codec;if(e===void 0)throw Error(`Context key "ash.bundle" is missing a codec.`);i.set(BundleKey,await e.deserialize(a,i))}for(let[e,a]of Object.entries(r)){if(a===void 0||e===BundleKey.name)continue;let r=resolveKey(e);r!==void 0&&i.set(r,r.codec?await r.codec.deserialize(a,i):a)}return i}export{deserializeContext,serializeContext};
1
+ import{ContextContainer}from"#context/container.js";import{resolveKey}from"#context/key.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";function serializeContext(e){let t={};for(let[n,r]of e.entries())t[n.name]=n.codec?n.codec.serialize(r):r;return t}async function deserializeContext(r){let i=new ContextContainer,a=r[BundleKey.name];if(a!==void 0){let e=BundleKey.codec;if(e===void 0)throw Error(`Context key "ash.bundle" is missing a codec.`);i.set(BundleKey,await e.deserialize(a,i))}for(let[e,a]of Object.entries(r)){if(a===void 0||e===BundleKey.name)continue;let r=resolveKey(e);r!==void 0&&i.set(r,r.codec?await r.codec.deserialize(a,i):a)}return i}export{deserializeContext,serializeContext};
@@ -1 +1 @@
1
- import{join}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{createConnectionSourceRef}from"#discover/manifest.js";import{DISCOVER_MODULE_SLOT_COLLISION,createConnectionNameDiagnostic,createModuleSlotCollisionDiagnostic,readSortedDirectoryEntries}from"#discover/grammar.js";import{collectNamedSlotCandidates}from"#discover/slots.js";var DISCOVER_CONNECTIONS_DIRECTORY_INVALID=`discover/connections-directory-invalid`,DISCOVER_CONNECTION_FILE_FOLDER_COLLISION=`discover/connection-file-folder-collision`,DISCOVER_CONNECTION_FOLDER_EMPTY=`discover/connection-folder-empty`,CONNECTION_DEFINITION_BASE_NAME=`connection`;async function discoverConnectionSources(c){let l=`connections`,u=join(c.rootPath,l),d=c.rootEntries.find(e=>e.name===l);if(d===void 0)return{connections:[],diagnostics:[]};if(!d.isDirectory())return{connections:[],diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTIONS_DIRECTORY_INVALID,message:`Expected "${u}" to be a directory of authored connections.`,sourcePath:u})]};let f=await readSortedDirectoryEntries(c.source,u),p=[],m=[],h=new Set;for(let t of collectNamedSlotCandidates(f,{allowMarkdown:!1,allowModules:!0})){let r=normalizeLogicalPath(join(l,t.slotName));if(t.moduleFileNames.length>1){h.add(t.slotName),m.push(createModuleSlotCollisionDiagnostic(u,r,t.moduleFileNames));continue}let[a]=t.moduleFileNames;if(a===void 0)continue;h.add(t.slotName);let o=createConnectionNameDiagnostic(t.slotName,join(u,a));if(o!==null){m.push(o);continue}p.push(createConnectionSourceRef({connectionName:t.slotName,logicalPath:join(l,a)}))}for(let i of f){if(!i.isDirectory())continue;let o=i.name,s=join(u,o);if(h.has(o)){m.push(createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTION_FILE_FOLDER_COLLISION,message:`Connection "${o}" is defined twice. Found both file-form "connections/${o}.ts" and folder-form "connections/${o}/". Use one form, not both.`,sourcePath:s}));let e=p.findIndex(e=>e.connectionName===o);e!==-1&&p.splice(e,1);continue}let d=createConnectionNameDiagnostic(o,s);if(d!==null){m.push(d);continue}let f=collectFolderConnectionModuleCandidates(await readSortedDirectoryEntries(c.source,s));if(f.length>1){m.push(createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple connection definition modules inside "${normalizeLogicalPath(join(l,o))}": `+f.map(e=>`"${e}"`).join(`, `),sourcePath:s}));continue}let[g]=f;if(g===void 0){m.push(createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTION_FOLDER_EMPTY,message:`Connection folder "connections/${o}/" contains no "connection.ts" definition. Add "connections/${o}/connection.ts" or use the file form "connections/${o}.ts".`,sourcePath:s}));continue}p.push(createConnectionSourceRef({connectionName:o,logicalPath:join(l,o,g)}))}return{connections:p,diagnostics:m}}function collectFolderConnectionModuleCandidates(e){let t=e.filter(e=>e.isFile()),n=[];for(let e of collectNamedSlotCandidates(t,{allowMarkdown:!1,allowModules:!0}))e.slotName===CONNECTION_DEFINITION_BASE_NAME&&n.push(...e.moduleFileNames);return n}export{DISCOVER_CONNECTIONS_DIRECTORY_INVALID,DISCOVER_CONNECTION_FILE_FOLDER_COLLISION,DISCOVER_CONNECTION_FOLDER_EMPTY,discoverConnectionSources};
1
+ import{join}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{createConnectionSourceRef}from"#discover/manifest.js";import{DISCOVER_MODULE_SLOT_COLLISION,createConnectionNameDiagnostic,createModuleSlotCollisionDiagnostic,readSortedDirectoryEntries}from"#discover/grammar.js";import{collectNamedSlotCandidates}from"#discover/slots.js";const DISCOVER_CONNECTIONS_DIRECTORY_INVALID=`discover/connections-directory-invalid`,DISCOVER_CONNECTION_FILE_FOLDER_COLLISION=`discover/connection-file-folder-collision`,DISCOVER_CONNECTION_FOLDER_EMPTY=`discover/connection-folder-empty`;async function discoverConnectionSources(c){let l=`connections`,u=join(c.rootPath,l),d=c.rootEntries.find(e=>e.name===l);if(d===void 0)return{connections:[],diagnostics:[]};if(!d.isDirectory())return{connections:[],diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTIONS_DIRECTORY_INVALID,message:`Expected "${u}" to be a directory of authored connections.`,sourcePath:u})]};let f=await readSortedDirectoryEntries(c.source,u),p=[],m=[],h=new Set;for(let t of collectNamedSlotCandidates(f,{allowMarkdown:!1,allowModules:!0})){let r=normalizeLogicalPath(join(l,t.slotName));if(t.moduleFileNames.length>1){h.add(t.slotName),m.push(createModuleSlotCollisionDiagnostic(u,r,t.moduleFileNames));continue}let[a]=t.moduleFileNames;if(a===void 0)continue;h.add(t.slotName);let o=createConnectionNameDiagnostic(t.slotName,join(u,a));if(o!==null){m.push(o);continue}p.push(createConnectionSourceRef({connectionName:t.slotName,logicalPath:join(l,a)}))}for(let i of f){if(!i.isDirectory())continue;let o=i.name,s=join(u,o);if(h.has(o)){m.push(createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTION_FILE_FOLDER_COLLISION,message:`Connection "${o}" is defined twice. Found both file-form "connections/${o}.ts" and folder-form "connections/${o}/". Use one form, not both.`,sourcePath:s}));let e=p.findIndex(e=>e.connectionName===o);e!==-1&&p.splice(e,1);continue}let d=createConnectionNameDiagnostic(o,s);if(d!==null){m.push(d);continue}let f=collectFolderConnectionModuleCandidates(await readSortedDirectoryEntries(c.source,s));if(f.length>1){m.push(createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple connection definition modules inside "${normalizeLogicalPath(join(l,o))}": `+f.map(e=>`"${e}"`).join(`, `),sourcePath:s}));continue}let[g]=f;if(g===void 0){m.push(createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTION_FOLDER_EMPTY,message:`Connection folder "connections/${o}/" contains no "connection.ts" definition. Add "connections/${o}/connection.ts" or use the file form "connections/${o}.ts".`,sourcePath:s}));continue}p.push(createConnectionSourceRef({connectionName:o,logicalPath:join(l,o,g)}))}return{connections:p,diagnostics:m}}function collectFolderConnectionModuleCandidates(e){let t=e.filter(e=>e.isFile()),n=[];for(let e of collectNamedSlotCandidates(t,{allowMarkdown:!1,allowModules:!0}))e.slotName===`connection`&&n.push(...e.moduleFileNames);return n}export{DISCOVER_CONNECTIONS_DIRECTORY_INVALID,DISCOVER_CONNECTION_FILE_FOLDER_COLLISION,DISCOVER_CONNECTION_FOLDER_EMPTY,discoverConnectionSources};
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";var discoverDiagnosticSeveritySchema=z.union([z.literal(`error`),z.literal(`warning`)]),discoverDiagnosticSchema=z.object({code:z.string(),message:z.string(),severity:discoverDiagnosticSeveritySchema,sourcePath:z.string()}).strict(),discoverDiagnosticsSummarySchema=z.object({errors:z.number().finite(),warnings:z.number().finite()}).strict(),DISCOVER_PROJECT_NOT_FOUND=`discover/project-not-found`;function createDiscoverErrorDiagnostic(e){return{...e,severity:`error`}}function createDiscoverWarningDiagnostic(e){return{...e,severity:`warning`}}function summarizeDiscoverDiagnostics(e){return e.reduce((e,t)=>(t.severity===`error`?e.errors+=1:e.warnings+=1,e),{errors:0,warnings:0})}function hasDiscoverErrors(e){return e.some(e=>e.severity===`error`)}export{DISCOVER_PROJECT_NOT_FOUND,createDiscoverErrorDiagnostic,createDiscoverWarningDiagnostic,discoverDiagnosticSchema,discoverDiagnosticSeveritySchema,discoverDiagnosticsSummarySchema,hasDiscoverErrors,summarizeDiscoverDiagnostics};
1
+ import{z}from"#compiled/zod/index.js";const discoverDiagnosticSeveritySchema=z.union([z.literal(`error`),z.literal(`warning`)]),discoverDiagnosticSchema=z.object({code:z.string(),message:z.string(),severity:discoverDiagnosticSeveritySchema,sourcePath:z.string()}).strict(),discoverDiagnosticsSummarySchema=z.object({errors:z.number().finite(),warnings:z.number().finite()}).strict(),DISCOVER_PROJECT_NOT_FOUND=`discover/project-not-found`;function createDiscoverErrorDiagnostic(e){return{...e,severity:`error`}}function createDiscoverWarningDiagnostic(e){return{...e,severity:`warning`}}function summarizeDiscoverDiagnostics(e){return e.reduce((e,t)=>(t.severity===`error`?e.errors+=1:e.warnings+=1,e),{errors:0,warnings:0})}function hasDiscoverErrors(e){return e.some(e=>e.severity===`error`)}export{DISCOVER_PROJECT_NOT_FOUND,createDiscoverErrorDiagnostic,createDiscoverWarningDiagnostic,discoverDiagnosticSchema,discoverDiagnosticSeveritySchema,discoverDiagnosticsSummarySchema,hasDiscoverErrors,summarizeDiscoverDiagnostics};
@@ -1 +1 @@
1
- import{join,relative,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifyLocalSubagentEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createAgentSourceManifest,createLocalSubagentSourceRef,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverSkills}from"#discover/skills.js";var DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID=`discover/local-subagent-schedules-invalid`,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING=`discover/required-subagent-config-module-missing`,DISCOVER_SUBAGENTS_DIRECTORY_INVALID=`discover/subagents-directory-invalid`;async function discoverSubagents(i){let a=i.source??createDiskProjectSource(),l=resolve(i.agentRoot),u=resolve(i.subagentsDirectoryPath??join(l,`subagents`)),d=normalizeLogicalPath(i.subagentsLogicalPath??relative(l,u)),f=await a.stat(u);if(f===`missing`)return{diagnostics:[],subagents:[]};if(f!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SUBAGENTS_DIRECTORY_INVALID,message:`Expected "${u}" to be a directory of authored subagents.`,sourcePath:u})],subagents:[]};let p=await readSortedDirectoryEntries(a,u),m=[],h=[];for(let t of p){if(t.isFile()){let n=getSupportedModuleBaseName(t.name);if(n===null)continue;h.push(discoverSingleFileSubagent({agentRoot:l,appRoot:i.appRoot,subagentId:n,subagentLogicalPath:join(d,t.name),subagentPath:join(u,t.name)}));continue}if(!t.isDirectory())continue;let n=await discoverLocalSubagentPackage({appRoot:i.appRoot,source:a,subagentId:t.name,subagentLogicalPath:join(d,t.name),subagentRoot:join(u,t.name)});m.push(...n.diagnostics),h.push(n.subagent)}return{diagnostics:m,subagents:h}}function discoverSingleFileSubagent(e){let t=createModuleSourceRef({logicalPath:e.subagentLogicalPath}),n=createAgentSourceManifest({agentId:e.subagentId,agentRoot:e.agentRoot,appRoot:e.appRoot,configModule:t});return createLocalSubagentSourceRef({entryPath:e.subagentPath,logicalPath:e.subagentLogicalPath,manifest:n,rootPath:e.agentRoot,subagentId:e.subagentId})}async function discoverLocalSubagentPackage(t){let n=[],r=await readSortedDirectoryEntries(t.source,t.subagentRoot);n.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyLocalSubagentEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the local subagent root.`},rootEntries:r,rootPath:t.subagentRoot}));let a=await discoverInstructionsSource({required:!1,rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...a.diagnostics);let o=discoverFlatModuleSource({missingDiagnostic:{code:DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,message:`Expected one authored subagent config module at "agent.ts", "agent.cts", "agent.mts", "agent.js", "agent.cjs", or "agent.mjs".`},rootEntries:r,rootPath:t.subagentRoot,slotName:`agent`});n.push(...o.diagnostics);let s=await discoverConnectionSources({rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...s.diagnostics);let c=await discoverSandboxSource({rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...c.diagnostics);let d=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:r,rootPath:t.subagentRoot,source:t.source,validateSegment:createToolNameDiagnostic});n.push(...d.diagnostics);let g=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:r,rootPath:t.subagentRoot,source:t.source,validateSegment:createHookNameDiagnostic});n.push(...g.diagnostics);let _=await discoverLibSources({agentRoot:t.subagentRoot,rootEntries:r,source:t.source});n.push(..._.diagnostics),n.push(...createLocalSubagentScheduleDiagnostics(t.subagentRoot,r));let v=await discoverSkills({agentRoot:t.subagentRoot,source:t.source});n.push(...v.diagnostics);let y=await discoverSubagents({agentRoot:t.subagentRoot,appRoot:t.appRoot,source:t.source});n.push(...y.diagnostics);let b={agentRoot:t.subagentRoot,appRoot:t.appRoot,connections:s.connections,diagnostics:n,hooks:g.sources,lib:_.lib,instructions:a.instructions,sandbox:c.sandbox,sandboxWorkspaces:c.sandboxWorkspace===null?[]:[c.sandboxWorkspace],skills:v.skills,tools:d.sources,subagents:y.subagents};o.module!==void 0&&(b.configModule=o.module);let x=createAgentSourceManifest(b);return{diagnostics:n,subagent:createLocalSubagentSourceRef({entryPath:t.subagentRoot,logicalPath:t.subagentLogicalPath,manifest:x,rootPath:t.subagentRoot,subagentId:t.subagentId})}}function createLocalSubagentScheduleDiagnostics(t,n){return n.flatMap(n=>classifyLocalSubagentEntry(n.name,getDirectoryEntryType(n))===`invalid-schedules-directory`?[createDiscoverErrorDiagnostic({code:DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,message:`Local subagent packages cannot define schedules at "${join(t,n.name)}".`,sourcePath:join(t,n.name)})]:[])}export{DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,DISCOVER_SUBAGENTS_DIRECTORY_INVALID,discoverSubagents};
1
+ import{join,relative,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifyLocalSubagentEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createAgentSourceManifest,createLocalSubagentSourceRef,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverSkills}from"#discover/skills.js";const DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID=`discover/local-subagent-schedules-invalid`,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING=`discover/required-subagent-config-module-missing`,DISCOVER_SUBAGENTS_DIRECTORY_INVALID=`discover/subagents-directory-invalid`;async function discoverSubagents(i){let a=i.source??createDiskProjectSource(),l=resolve(i.agentRoot),u=resolve(i.subagentsDirectoryPath??join(l,`subagents`)),d=normalizeLogicalPath(i.subagentsLogicalPath??relative(l,u)),f=await a.stat(u);if(f===`missing`)return{diagnostics:[],subagents:[]};if(f!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SUBAGENTS_DIRECTORY_INVALID,message:`Expected "${u}" to be a directory of authored subagents.`,sourcePath:u})],subagents:[]};let p=await readSortedDirectoryEntries(a,u),m=[],h=[];for(let t of p){if(t.isFile()){let n=getSupportedModuleBaseName(t.name);if(n===null)continue;h.push(discoverSingleFileSubagent({agentRoot:l,appRoot:i.appRoot,subagentId:n,subagentLogicalPath:join(d,t.name),subagentPath:join(u,t.name)}));continue}if(!t.isDirectory())continue;let n=await discoverLocalSubagentPackage({appRoot:i.appRoot,source:a,subagentId:t.name,subagentLogicalPath:join(d,t.name),subagentRoot:join(u,t.name)});m.push(...n.diagnostics),h.push(n.subagent)}return{diagnostics:m,subagents:h}}function discoverSingleFileSubagent(e){let t=createModuleSourceRef({logicalPath:e.subagentLogicalPath}),n=createAgentSourceManifest({agentId:e.subagentId,agentRoot:e.agentRoot,appRoot:e.appRoot,configModule:t});return createLocalSubagentSourceRef({entryPath:e.subagentPath,logicalPath:e.subagentLogicalPath,manifest:n,rootPath:e.agentRoot,subagentId:e.subagentId})}async function discoverLocalSubagentPackage(t){let n=[],r=await readSortedDirectoryEntries(t.source,t.subagentRoot);n.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyLocalSubagentEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the local subagent root.`},rootEntries:r,rootPath:t.subagentRoot}));let a=await discoverInstructionsSource({required:!1,rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...a.diagnostics);let o=discoverFlatModuleSource({missingDiagnostic:{code:DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,message:`Expected one authored subagent config module at "agent.ts", "agent.cts", "agent.mts", "agent.js", "agent.cjs", or "agent.mjs".`},rootEntries:r,rootPath:t.subagentRoot,slotName:`agent`});n.push(...o.diagnostics);let s=await discoverConnectionSources({rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...s.diagnostics);let c=await discoverSandboxSource({rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...c.diagnostics);let d=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:r,rootPath:t.subagentRoot,source:t.source,validateSegment:createToolNameDiagnostic});n.push(...d.diagnostics);let g=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:r,rootPath:t.subagentRoot,source:t.source,validateSegment:createHookNameDiagnostic});n.push(...g.diagnostics);let _=await discoverLibSources({agentRoot:t.subagentRoot,rootEntries:r,source:t.source});n.push(..._.diagnostics),n.push(...createLocalSubagentScheduleDiagnostics(t.subagentRoot,r));let v=await discoverSkills({agentRoot:t.subagentRoot,source:t.source});n.push(...v.diagnostics);let y=await discoverSubagents({agentRoot:t.subagentRoot,appRoot:t.appRoot,source:t.source});n.push(...y.diagnostics);let b={agentRoot:t.subagentRoot,appRoot:t.appRoot,connections:s.connections,diagnostics:n,hooks:g.sources,lib:_.lib,instructions:a.instructions,sandbox:c.sandbox,sandboxWorkspaces:c.sandboxWorkspace===null?[]:[c.sandboxWorkspace],skills:v.skills,tools:d.sources,subagents:y.subagents};o.module!==void 0&&(b.configModule=o.module);let x=createAgentSourceManifest(b);return{diagnostics:n,subagent:createLocalSubagentSourceRef({entryPath:t.subagentRoot,logicalPath:t.subagentLogicalPath,manifest:x,rootPath:t.subagentRoot,subagentId:t.subagentId})}}function createLocalSubagentScheduleDiagnostics(t,n){return n.flatMap(n=>classifyLocalSubagentEntry(n.name,getDirectoryEntryType(n))===`invalid-schedules-directory`?[createDiscoverErrorDiagnostic({code:DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,message:`Local subagent packages cannot define schedules at "${join(t,n.name)}".`,sourcePath:join(t,n.name)})]:[])}export{DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,DISCOVER_SUBAGENTS_DIRECTORY_INVALID,discoverSubagents};
@@ -1 +1 @@
1
- import{sep}from"node:path";var SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e===`SKILL.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
1
+ import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e===`SKILL.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
@@ -1 +1 @@
1
- import{join}from"node:path";import{createDiscoverErrorDiagnostic,createDiscoverWarningDiagnostic}from"#discover/diagnostics.js";import{getDirectoryEntryType}from"#discover/filesystem.js";import{createModuleSourceRef}from"#discover/manifest.js";import{collectFlatSlotCandidates}from"#discover/slots.js";import{lowerInstructionsMarkdown}from"#internal/helpers/markdown.js";import{discoverMarkdownSource}from"#discover/markdown.js";import{discoverNamedSourceDirectory}from"#discover/named-source-directory.js";var DISCOVER_MODULE_SLOT_COLLISION=`discover/module-slot-collision`,DISCOVER_REQUIRED_INSTRUCTIONS_MISSING=`discover/required-instructions-missing`,DISCOVER_DEPRECATED_SYSTEM_SLOT=`discover/deprecated-system-slot`,DISCOVER_SLOT_COLLISION=`discover/slot-collision`,DISCOVER_TOOLS_DIRECTORY_INVALID=`discover/tools-directory-invalid`,DISCOVER_HOOKS_DIRECTORY_INVALID=`discover/hooks-directory-invalid`,DISCOVER_CHANNELS_DIRECTORY_INVALID=`discover/channels-directory-invalid`,DISCOVER_TOOL_NAME_INVALID=`discover/tool-name-invalid`,DISCOVER_CONNECTION_NAME_INVALID=`discover/connection-name-invalid`,DISCOVER_SANDBOX_DIRECTORY_INVALID=`discover/sandbox-directory-invalid`,DISCOVER_CHANNEL_NAME_INVALID=`discover/channel-name-invalid`,DISCOVER_HOOK_NAME_INVALID=`discover/hook-name-invalid`,TOOL_SLUG_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,CONNECTION_SLUG_PATTERN=/^[a-z][a-z0-9-]{0,63}$/,CHANNEL_SLUG_PATTERN=/^(\.?[a-z][a-z0-9-]{0,63}|\[[a-zA-Z][a-zA-Z0-9_]{0,63}\])$/,HOOK_SLUG_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,DISCOVER_UNSUPPORTED_DIRECTORY=`discover/unsupported-directory`;async function readSortedDirectoryEntries(e,t){let n=[...await e.readDirectory(t)];return n.sort((e,t)=>e.name.localeCompare(t.name)),n}async function discoverInstructionsSource(r){let i=await discoverSlotSource({markdownFileName:`instructions.md`,moduleBaseName:`instructions`,rootEntries:r.rootEntries,rootPath:r.rootPath,slotLabel:`instructions`,source:r.source});if(i.diagnostics.length>0||i.source!==void 0)return{diagnostics:i.diagnostics,instructions:i.source};let a=await discoverSlotSource({markdownFileName:`system.md`,moduleBaseName:`system`,rootEntries:r.rootEntries,rootPath:r.rootPath,slotLabel:`system`,source:r.source});if(a.source!==void 0){let t=a.source.sourceKind===`markdown`?`system.md`:a.source.logicalPath;return{diagnostics:[createDiscoverWarningDiagnostic({code:DISCOVER_DEPRECATED_SYSTEM_SLOT,message:`The "${t}" slot is deprecated. Rename it to "${t.replace(/^system/,`instructions`)}" — the runtime still loads the legacy slot for now, but support will be removed in a future release.`,sourcePath:join(r.rootPath,t)}),...a.diagnostics],instructions:a.source}}return a.diagnostics.length>0?{diagnostics:a.diagnostics}:r.required===!1?{diagnostics:[]}:{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_REQUIRED_INSTRUCTIONS_MISSING,message:`Expected one authored instructions prompt source at "instructions.md", "instructions.ts", "instructions.cts", "instructions.mts", "instructions.js", "instructions.cjs", or "instructions.mjs".`,sourcePath:r.rootPath})]}}async function discoverSlotSource(t){let n=collectFlatSlotCandidates(t.rootEntries,{markdownFileName:t.markdownFileName,moduleBaseName:t.moduleBaseName});if(n.markdownFileName!==void 0&&n.moduleFileNames.length>0)return{diagnostics:[createSlotCollisionDiagnostic(t.rootPath,t.slotLabel,[n.markdownFileName,...n.moduleFileNames])]};if(n.moduleFileNames.length>1)return{diagnostics:[createModuleSlotCollisionDiagnostic(t.rootPath,t.slotLabel,n.moduleFileNames)]};if(n.markdownFileName!==void 0)return{diagnostics:[],source:await discoverMarkdownSource({logicalPath:t.markdownFileName,lower:lowerInstructionsMarkdown,source:t.source,sourcePath:join(t.rootPath,n.markdownFileName)})};let[r]=n.moduleFileNames;return r===void 0?{diagnostics:[]}:{diagnostics:[],source:createModuleSourceRef({logicalPath:r})}}function discoverFlatModuleSource(e){let n=collectFlatSlotCandidates(e.rootEntries,{moduleBaseName:e.slotName});if(n.moduleFileNames.length>1)return{diagnostics:[createModuleSlotCollisionDiagnostic(e.rootPath,e.slotName,n.moduleFileNames)]};let[r]=n.moduleFileNames;return r===void 0?e.missingDiagnostic===void 0?{diagnostics:[]}:{diagnostics:[createDiscoverErrorDiagnostic({code:e.missingDiagnostic.code,message:e.missingDiagnostic.message,sourcePath:e.rootPath})]}:{diagnostics:[],module:createModuleSourceRef({logicalPath:r})}}function createToolNameDiagnostic(e,n){return TOOL_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_TOOL_NAME_INVALID,message:`Tool filename "${e}" is not a legal tool name. Expected ASCII letters, digits, underscores, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:n})}function createConnectionNameDiagnostic(e,n){return CONNECTION_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTION_NAME_INVALID,message:`Connection filename "${e}" is not a legal connection name. Expected lowercase ASCII letters, digits, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:n})}function createChannelNameDiagnostic(e,n){return CHANNEL_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_CHANNEL_NAME_INVALID,message:`Channel path segment "${e}" is not a legal channel name. Expected lowercase kebab-case (\`my-channel\`), optionally with a leading dot (\`.well-known\`), or a path parameter form (\`[sessionId]\`).`,sourcePath:n})}function createHookNameDiagnostic(e,n){return HOOK_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_HOOK_NAME_INVALID,message:`Hook path segment "${e}" is not a legal hook name. Expected ASCII letters, digits, underscores, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:n})}function createUnsupportedRootDirectoryDiagnostics(t){return t.rootEntries.flatMap(i=>!i.isDirectory()||t.classifyEntry(i.name,getDirectoryEntryType(i))!==`unknown`?[]:[createDiscoverWarningDiagnostic({code:DISCOVER_UNSUPPORTED_DIRECTORY,message:t.createUnsupportedDirectoryMessage(i.name),sourcePath:join(t.rootPath,i.name)})])}function createSlotCollisionDiagnostic(e,n,r){return createDiscoverErrorDiagnostic({code:DISCOVER_SLOT_COLLISION,message:`Found conflicting authored sources for "${n}": ${formatQuotedFileList(r)}.`,sourcePath:e})}function createModuleSlotCollisionDiagnostic(e,n,r){return createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple authored module sources for "${n}": ${formatQuotedFileList(r)}.`,sourcePath:e})}function formatQuotedFileList(e){return e.map(e=>`"${e}"`).join(`, `)}export{CHANNEL_SLUG_PATTERN,CONNECTION_SLUG_PATTERN,DISCOVER_CHANNELS_DIRECTORY_INVALID,DISCOVER_CHANNEL_NAME_INVALID,DISCOVER_CONNECTION_NAME_INVALID,DISCOVER_DEPRECATED_SYSTEM_SLOT,DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_HOOK_NAME_INVALID,DISCOVER_MODULE_SLOT_COLLISION,DISCOVER_REQUIRED_INSTRUCTIONS_MISSING,DISCOVER_SANDBOX_DIRECTORY_INVALID,DISCOVER_SLOT_COLLISION,DISCOVER_TOOLS_DIRECTORY_INVALID,DISCOVER_TOOL_NAME_INVALID,DISCOVER_UNSUPPORTED_DIRECTORY,HOOK_SLUG_PATTERN,TOOL_SLUG_PATTERN,createChannelNameDiagnostic,createConnectionNameDiagnostic,createHookNameDiagnostic,createModuleSlotCollisionDiagnostic,createSlotCollisionDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries};
1
+ import{join}from"node:path";import{createDiscoverErrorDiagnostic,createDiscoverWarningDiagnostic}from"#discover/diagnostics.js";import{getDirectoryEntryType}from"#discover/filesystem.js";import{createModuleSourceRef}from"#discover/manifest.js";import{collectFlatSlotCandidates}from"#discover/slots.js";import{lowerInstructionsMarkdown}from"#internal/helpers/markdown.js";import{discoverMarkdownSource}from"#discover/markdown.js";import{discoverNamedSourceDirectory}from"#discover/named-source-directory.js";const DISCOVER_MODULE_SLOT_COLLISION=`discover/module-slot-collision`,DISCOVER_REQUIRED_INSTRUCTIONS_MISSING=`discover/required-instructions-missing`,DISCOVER_DEPRECATED_SYSTEM_SLOT=`discover/deprecated-system-slot`,DISCOVER_SLOT_COLLISION=`discover/slot-collision`,DISCOVER_TOOLS_DIRECTORY_INVALID=`discover/tools-directory-invalid`,DISCOVER_HOOKS_DIRECTORY_INVALID=`discover/hooks-directory-invalid`,DISCOVER_CHANNELS_DIRECTORY_INVALID=`discover/channels-directory-invalid`,DISCOVER_TOOL_NAME_INVALID=`discover/tool-name-invalid`,DISCOVER_CONNECTION_NAME_INVALID=`discover/connection-name-invalid`,DISCOVER_SANDBOX_DIRECTORY_INVALID=`discover/sandbox-directory-invalid`,DISCOVER_CHANNEL_NAME_INVALID=`discover/channel-name-invalid`,DISCOVER_HOOK_NAME_INVALID=`discover/hook-name-invalid`,TOOL_SLUG_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,CONNECTION_SLUG_PATTERN=/^[a-z][a-z0-9-]{0,63}$/,CHANNEL_SLUG_PATTERN=/^(\.?[a-z][a-z0-9-]{0,63}|\[[a-zA-Z][a-zA-Z0-9_]{0,63}\])$/,HOOK_SLUG_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,DISCOVER_UNSUPPORTED_DIRECTORY=`discover/unsupported-directory`;async function readSortedDirectoryEntries(e,t){let n=[...await e.readDirectory(t)];return n.sort((e,t)=>e.name.localeCompare(t.name)),n}async function discoverInstructionsSource(r){let i=await discoverSlotSource({markdownFileName:`instructions.md`,moduleBaseName:`instructions`,rootEntries:r.rootEntries,rootPath:r.rootPath,slotLabel:`instructions`,source:r.source});if(i.diagnostics.length>0||i.source!==void 0)return{diagnostics:i.diagnostics,instructions:i.source};let a=await discoverSlotSource({markdownFileName:`system.md`,moduleBaseName:`system`,rootEntries:r.rootEntries,rootPath:r.rootPath,slotLabel:`system`,source:r.source});if(a.source!==void 0){let t=a.source.sourceKind===`markdown`?`system.md`:a.source.logicalPath;return{diagnostics:[createDiscoverWarningDiagnostic({code:DISCOVER_DEPRECATED_SYSTEM_SLOT,message:`The "${t}" slot is deprecated. Rename it to "${t.replace(/^system/,`instructions`)}" — the runtime still loads the legacy slot for now, but support will be removed in a future release.`,sourcePath:join(r.rootPath,t)}),...a.diagnostics],instructions:a.source}}return a.diagnostics.length>0?{diagnostics:a.diagnostics}:r.required===!1?{diagnostics:[]}:{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_REQUIRED_INSTRUCTIONS_MISSING,message:`Expected one authored instructions prompt source at "instructions.md", "instructions.ts", "instructions.cts", "instructions.mts", "instructions.js", "instructions.cjs", or "instructions.mjs".`,sourcePath:r.rootPath})]}}async function discoverSlotSource(t){let n=collectFlatSlotCandidates(t.rootEntries,{markdownFileName:t.markdownFileName,moduleBaseName:t.moduleBaseName});if(n.markdownFileName!==void 0&&n.moduleFileNames.length>0)return{diagnostics:[createSlotCollisionDiagnostic(t.rootPath,t.slotLabel,[n.markdownFileName,...n.moduleFileNames])]};if(n.moduleFileNames.length>1)return{diagnostics:[createModuleSlotCollisionDiagnostic(t.rootPath,t.slotLabel,n.moduleFileNames)]};if(n.markdownFileName!==void 0)return{diagnostics:[],source:await discoverMarkdownSource({logicalPath:t.markdownFileName,lower:lowerInstructionsMarkdown,source:t.source,sourcePath:join(t.rootPath,n.markdownFileName)})};let[r]=n.moduleFileNames;return r===void 0?{diagnostics:[]}:{diagnostics:[],source:createModuleSourceRef({logicalPath:r})}}function discoverFlatModuleSource(e){let n=collectFlatSlotCandidates(e.rootEntries,{moduleBaseName:e.slotName});if(n.moduleFileNames.length>1)return{diagnostics:[createModuleSlotCollisionDiagnostic(e.rootPath,e.slotName,n.moduleFileNames)]};let[r]=n.moduleFileNames;return r===void 0?e.missingDiagnostic===void 0?{diagnostics:[]}:{diagnostics:[createDiscoverErrorDiagnostic({code:e.missingDiagnostic.code,message:e.missingDiagnostic.message,sourcePath:e.rootPath})]}:{diagnostics:[],module:createModuleSourceRef({logicalPath:r})}}function createToolNameDiagnostic(e,n){return TOOL_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_TOOL_NAME_INVALID,message:`Tool filename "${e}" is not a legal tool name. Expected ASCII letters, digits, underscores, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:n})}function createConnectionNameDiagnostic(e,n){return CONNECTION_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_CONNECTION_NAME_INVALID,message:`Connection filename "${e}" is not a legal connection name. Expected lowercase ASCII letters, digits, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:n})}function createChannelNameDiagnostic(e,n){return CHANNEL_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_CHANNEL_NAME_INVALID,message:`Channel path segment "${e}" is not a legal channel name. Expected lowercase kebab-case (\`my-channel\`), optionally with a leading dot (\`.well-known\`), or a path parameter form (\`[sessionId]\`).`,sourcePath:n})}function createHookNameDiagnostic(e,n){return HOOK_SLUG_PATTERN.test(e)?null:createDiscoverErrorDiagnostic({code:DISCOVER_HOOK_NAME_INVALID,message:`Hook path segment "${e}" is not a legal hook name. Expected ASCII letters, digits, underscores, and dashes only, starting with a letter, up to 64 characters.`,sourcePath:n})}function createUnsupportedRootDirectoryDiagnostics(t){return t.rootEntries.flatMap(i=>!i.isDirectory()||t.classifyEntry(i.name,getDirectoryEntryType(i))!==`unknown`?[]:[createDiscoverWarningDiagnostic({code:DISCOVER_UNSUPPORTED_DIRECTORY,message:t.createUnsupportedDirectoryMessage(i.name),sourcePath:join(t.rootPath,i.name)})])}function createSlotCollisionDiagnostic(e,n,r){return createDiscoverErrorDiagnostic({code:DISCOVER_SLOT_COLLISION,message:`Found conflicting authored sources for "${n}": ${formatQuotedFileList(r)}.`,sourcePath:e})}function createModuleSlotCollisionDiagnostic(e,n,r){return createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple authored module sources for "${n}": ${formatQuotedFileList(r)}.`,sourcePath:e})}function formatQuotedFileList(e){return e.map(e=>`"${e}"`).join(`, `)}export{CHANNEL_SLUG_PATTERN,CONNECTION_SLUG_PATTERN,DISCOVER_CHANNELS_DIRECTORY_INVALID,DISCOVER_CHANNEL_NAME_INVALID,DISCOVER_CONNECTION_NAME_INVALID,DISCOVER_DEPRECATED_SYSTEM_SLOT,DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_HOOK_NAME_INVALID,DISCOVER_MODULE_SLOT_COLLISION,DISCOVER_REQUIRED_INSTRUCTIONS_MISSING,DISCOVER_SANDBOX_DIRECTORY_INVALID,DISCOVER_SLOT_COLLISION,DISCOVER_TOOLS_DIRECTORY_INVALID,DISCOVER_TOOL_NAME_INVALID,DISCOVER_UNSUPPORTED_DIRECTORY,HOOK_SLUG_PATTERN,TOOL_SLUG_PATTERN,createChannelNameDiagnostic,createConnectionNameDiagnostic,createHookNameDiagnostic,createModuleSlotCollisionDiagnostic,createSlotCollisionDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries};
@@ -1 +1 @@
1
- import{discoverNamedSourceDirectory}from"#discover/grammar.js";var DISCOVER_LIB_DIRECTORY_INVALID=`discover/lib-directory-invalid`,DISCOVER_LIB_ENTRY_UNSUPPORTED=`discover/lib-entry-unsupported`;async function discoverLibSources(t){let n=await discoverNamedSourceDirectory({directoryName:`lib`,invalidDirectoryCode:DISCOVER_LIB_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${t.agentRoot}/lib" to be a directory of authored helper modules.`,recursive:!0,rootEntries:t.rootEntries,rootPath:t.agentRoot,source:t.source,unsupportedEntryCode:DISCOVER_LIB_ENTRY_UNSUPPORTED,unsupportedEntryMessage:e=>`Expected "${e}" to be a supported authored module within "lib/".`,unsupportedFileCode:DISCOVER_LIB_ENTRY_UNSUPPORTED,unsupportedFileMessage:e=>`Expected "${e}" to be a supported authored module within "lib/".`});return{diagnostics:n.diagnostics,lib:n.sources}}export{DISCOVER_LIB_DIRECTORY_INVALID,DISCOVER_LIB_ENTRY_UNSUPPORTED,discoverLibSources};
1
+ import{discoverNamedSourceDirectory}from"#discover/grammar.js";const DISCOVER_LIB_DIRECTORY_INVALID=`discover/lib-directory-invalid`,DISCOVER_LIB_ENTRY_UNSUPPORTED=`discover/lib-entry-unsupported`;async function discoverLibSources(t){let n=await discoverNamedSourceDirectory({directoryName:`lib`,invalidDirectoryCode:DISCOVER_LIB_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${t.agentRoot}/lib" to be a directory of authored helper modules.`,recursive:!0,rootEntries:t.rootEntries,rootPath:t.agentRoot,source:t.source,unsupportedEntryCode:DISCOVER_LIB_ENTRY_UNSUPPORTED,unsupportedEntryMessage:e=>`Expected "${e}" to be a supported authored module within "lib/".`,unsupportedFileCode:DISCOVER_LIB_ENTRY_UNSUPPORTED,unsupportedFileMessage:e=>`Expected "${e}" to be a supported authored module within "lib/".`});return{diagnostics:n.diagnostics,lib:n.sources}}export{DISCOVER_LIB_DIRECTORY_INVALID,DISCOVER_LIB_ENTRY_UNSUPPORTED,discoverLibSources};
@@ -1 +1 @@
1
- import{basename,relative,resolve}from"node:path";import{summarizeDiscoverDiagnostics}from"#discover/diagnostics.js";import{normalizeLogicalPath}from"#discover/filesystem.js";var AGENT_SOURCE_MANIFEST_KIND=`ash-agent-discovery-manifest`,AGENT_SOURCE_MANIFEST_VERSION=12;function createAgentSourceManifest(e){let t=resolve(e.appRoot),i=resolve(e.agentRoot),o={agentId:e.agentId??deriveAgentIdFromRoots(t,i,e.packageName),agentRoot:i,appRoot:t,channels:[...e.channels??[]],connections:[...e.connections??[]],diagnosticsSummary:summarizeDiscoverDiagnostics(e.diagnostics??[]),hooks:[...e.hooks??[]],lib:[...e.lib??[]],kind:AGENT_SOURCE_MANIFEST_KIND,sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],version:12,subagents:[...e.subagents??[]]};return e.configModule!==void 0&&(o.configModule=e.configModule),e.instructions!==void 0&&(o.instructions=e.instructions),o}function deriveAgentIdFromRoots(n,r,a){let o=normalizeLogicalPath(relative(n,r));return o===``||o===`.`||o===`agent`?a??basename(n):basename(r)}function createPathDerivedSourceId(e){return normalizeLogicalPath(e)}function createModuleSourceRef(e){let t=normalizeLogicalPath(e.logicalPath),n={sourceKind:`module`,logicalPath:t,sourceId:e.sourceId??createPathDerivedSourceId(t)};return e.exportName!==void 0&&(n.exportName=e.exportName),n}function createConnectionSourceRef(e){return{...createModuleSourceRef(e),connectionName:e.connectionName}}function createLocalSubagentSourceRef(e){let t=normalizeLogicalPath(e.logicalPath);return{entryPath:e.entryPath,logicalPath:t,manifest:e.manifest,rootPath:e.rootPath,sourceId:e.sourceId??createPathDerivedSourceId(t),subagentId:e.subagentId}}function createSkillPackageSourceRef(e){let t={description:e.description,sourceKind:`skill-package`,logicalPath:normalizeLogicalPath(e.logicalPath),markdown:e.markdown,name:e.name,rootPath:e.rootPath,skillFilePath:e.skillFilePath,skillId:e.skillId,sourceId:e.sourceId};return e.assetsPath!==void 0&&(t.assetsPath=e.assetsPath),e.license!==void 0&&(t.license=e.license),e.metadata!==void 0&&(t.metadata={...e.metadata}),e.referencesPath!==void 0&&(t.referencesPath=e.referencesPath),e.scriptsPath!==void 0&&(t.scriptsPath=e.scriptsPath),t}export{AGENT_SOURCE_MANIFEST_KIND,AGENT_SOURCE_MANIFEST_VERSION,createAgentSourceManifest,createConnectionSourceRef,createLocalSubagentSourceRef,createModuleSourceRef,createPathDerivedSourceId,createSkillPackageSourceRef,deriveAgentIdFromRoots};
1
+ import{basename,relative,resolve}from"node:path";import{summarizeDiscoverDiagnostics}from"#discover/diagnostics.js";import{normalizeLogicalPath}from"#discover/filesystem.js";const AGENT_SOURCE_MANIFEST_KIND=`ash-agent-discovery-manifest`,AGENT_SOURCE_MANIFEST_VERSION=12;function createAgentSourceManifest(e){let t=resolve(e.appRoot),i=resolve(e.agentRoot),o={agentId:e.agentId??deriveAgentIdFromRoots(t,i,e.packageName),agentRoot:i,appRoot:t,channels:[...e.channels??[]],connections:[...e.connections??[]],diagnosticsSummary:summarizeDiscoverDiagnostics(e.diagnostics??[]),hooks:[...e.hooks??[]],lib:[...e.lib??[]],kind:AGENT_SOURCE_MANIFEST_KIND,sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],version:12,subagents:[...e.subagents??[]]};return e.configModule!==void 0&&(o.configModule=e.configModule),e.instructions!==void 0&&(o.instructions=e.instructions),o}function deriveAgentIdFromRoots(n,r,a){let o=normalizeLogicalPath(relative(n,r));return o===``||o===`.`||o===`agent`?a??basename(n):basename(r)}function createPathDerivedSourceId(e){return normalizeLogicalPath(e)}function createModuleSourceRef(e){let t=normalizeLogicalPath(e.logicalPath),n={sourceKind:`module`,logicalPath:t,sourceId:e.sourceId??createPathDerivedSourceId(t)};return e.exportName!==void 0&&(n.exportName=e.exportName),n}function createConnectionSourceRef(e){return{...createModuleSourceRef(e),connectionName:e.connectionName}}function createLocalSubagentSourceRef(e){let t=normalizeLogicalPath(e.logicalPath);return{entryPath:e.entryPath,logicalPath:t,manifest:e.manifest,rootPath:e.rootPath,sourceId:e.sourceId??createPathDerivedSourceId(t),subagentId:e.subagentId}}function createSkillPackageSourceRef(e){let t={description:e.description,sourceKind:`skill-package`,logicalPath:normalizeLogicalPath(e.logicalPath),markdown:e.markdown,name:e.name,rootPath:e.rootPath,skillFilePath:e.skillFilePath,skillId:e.skillId,sourceId:e.sourceId};return e.assetsPath!==void 0&&(t.assetsPath=e.assetsPath),e.license!==void 0&&(t.license=e.license),e.metadata!==void 0&&(t.metadata={...e.metadata}),e.referencesPath!==void 0&&(t.referencesPath=e.referencesPath),e.scriptsPath!==void 0&&(t.scriptsPath=e.scriptsPath),t}export{AGENT_SOURCE_MANIFEST_KIND,AGENT_SOURCE_MANIFEST_VERSION,createAgentSourceManifest,createConnectionSourceRef,createLocalSubagentSourceRef,createModuleSourceRef,createPathDerivedSourceId,createSkillPackageSourceRef,deriveAgentIdFromRoots};
@@ -1 +1 @@
1
- import{join}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{createModuleSourceRef,createPathDerivedSourceId}from"#discover/manifest.js";import{DISCOVER_MODULE_SLOT_COLLISION,DISCOVER_SANDBOX_DIRECTORY_INVALID,readSortedDirectoryEntries}from"#discover/grammar.js";import{collectFlatSlotCandidates,collectNamedSlotCandidates}from"#discover/slots.js";var SANDBOX_DIRECTORY_NAME=`sandbox`,SANDBOX_WORKSPACE_DIRECTORY_NAME=`workspace`,SANDBOX_DEFINITION_BASE_NAME=`sandbox`,DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED=`discover/sandbox-workspace-skills-reserved`,DISCOVER_SANDBOX_FOLDER_EMPTY=`discover/sandbox-folder-empty`;async function discoverSandboxSource(o){let s=[],c=o.rootEntries.find(e=>e.name===SANDBOX_DIRECTORY_NAME);if(c===void 0)return discoverRootSandboxModule({diagnostics:s,rootEntries:o.rootEntries,rootPath:o.rootPath});let l=join(o.rootPath,SANDBOX_DIRECTORY_NAME);if(!c.isDirectory())return s.push(createDiscoverErrorDiagnostic({code:DISCOVER_SANDBOX_DIRECTORY_INVALID,message:`Expected "${l}" to be the sandbox folder.`,sourcePath:l})),{diagnostics:s,sandbox:null,sandboxWorkspace:null};let u=await readSortedDirectoryEntries(o.source,l),d=collectFolderSandboxModuleCandidates(u),f=u.find(e=>e.name===SANDBOX_WORKSPACE_DIRECTORY_NAME&&e.isDirectory());if(d.length>1)return s.push(createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple sandbox definition modules inside "${normalizeLogicalPath(SANDBOX_DIRECTORY_NAME)}": `+d.map(e=>`"${e}"`).join(`, `),sourcePath:l})),{diagnostics:s,sandbox:null,sandboxWorkspace:null};let[p]=d,m=p!==void 0,h=f!==void 0;if(!m&&!h)return s.push(createDiscoverErrorDiagnostic({code:DISCOVER_SANDBOX_FOLDER_EMPTY,message:`Sandbox folder "sandbox/" contains neither a "sandbox.<ext>" definition nor a "workspace/" subdirectory. Add one or the other, or remove the folder.`,sourcePath:l})),{diagnostics:s,sandbox:null,sandboxWorkspace:null};let g=null;m&&(g=createModuleSourceRef({logicalPath:join(SANDBOX_DIRECTORY_NAME,p)}));let _=null;if(h){let t=join(l,SANDBOX_WORKSPACE_DIRECTORY_NAME),r=normalizeLogicalPath(join(SANDBOX_DIRECTORY_NAME,SANDBOX_WORKSPACE_DIRECTORY_NAME)),a=await checkWorkspaceSkillsReservation(o.source,t);a===null?_={logicalPath:r,rootEntries:await collectWorkspaceRootEntries(o.source,t),sourceId:createPathDerivedSourceId(r),sourcePath:t}:s.push(a)}return{diagnostics:s,sandbox:g,sandboxWorkspace:_}}function discoverRootSandboxModule(e){let n=collectFlatSlotCandidates(e.rootEntries,{moduleBaseName:SANDBOX_DEFINITION_BASE_NAME});if(n.moduleFileNames.length>1)return e.diagnostics.push(createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple top-level sandbox definition modules: `+n.moduleFileNames.map(e=>`"${e}"`).join(`, `),sourcePath:e.rootPath})),{diagnostics:e.diagnostics,sandbox:null,sandboxWorkspace:null};let[i]=n.moduleFileNames;return i===void 0?{diagnostics:e.diagnostics,sandbox:null,sandboxWorkspace:null}:{diagnostics:e.diagnostics,sandbox:createModuleSourceRef({logicalPath:i}),sandboxWorkspace:null}}function collectFolderSandboxModuleCandidates(e){let t=e.filter(e=>e.isFile()),n=[];for(let e of collectNamedSlotCandidates(t,{allowMarkdown:!1,allowModules:!0}))e.slotName===SANDBOX_DEFINITION_BASE_NAME&&n.push(...e.moduleFileNames);return n}async function collectWorkspaceRootEntries(e,t){let n=await readSortedDirectoryEntries(e,t),r=[];for(let e of n){if(e.isDirectory()){r.push(`${e.name}/`);continue}e.isFile()&&r.push(e.name)}return r}async function checkWorkspaceSkillsReservation(n,r){return(await readSortedDirectoryEntries(n,r)).find(e=>e.name===`skills`)===void 0?null:createDiscoverErrorDiagnostic({code:DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,message:`"sandbox/workspace/skills/" is reserved for the framework skill discovery. Move skill files under "agent/skills/" instead, or rename the subtree.`,sourcePath:join(r,`skills`)})}export{DISCOVER_SANDBOX_FOLDER_EMPTY,DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,discoverSandboxSource};
1
+ import{join}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{createModuleSourceRef,createPathDerivedSourceId}from"#discover/manifest.js";import{DISCOVER_MODULE_SLOT_COLLISION,DISCOVER_SANDBOX_DIRECTORY_INVALID,readSortedDirectoryEntries}from"#discover/grammar.js";import{collectFlatSlotCandidates,collectNamedSlotCandidates}from"#discover/slots.js";const SANDBOX_DIRECTORY_NAME=`sandbox`,SANDBOX_WORKSPACE_DIRECTORY_NAME=`workspace`,SANDBOX_DEFINITION_BASE_NAME=`sandbox`,DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED=`discover/sandbox-workspace-skills-reserved`,DISCOVER_SANDBOX_FOLDER_EMPTY=`discover/sandbox-folder-empty`;async function discoverSandboxSource(o){let s=[],c=o.rootEntries.find(e=>e.name===SANDBOX_DIRECTORY_NAME);if(c===void 0)return discoverRootSandboxModule({diagnostics:s,rootEntries:o.rootEntries,rootPath:o.rootPath});let l=join(o.rootPath,SANDBOX_DIRECTORY_NAME);if(!c.isDirectory())return s.push(createDiscoverErrorDiagnostic({code:DISCOVER_SANDBOX_DIRECTORY_INVALID,message:`Expected "${l}" to be the sandbox folder.`,sourcePath:l})),{diagnostics:s,sandbox:null,sandboxWorkspace:null};let u=await readSortedDirectoryEntries(o.source,l),d=collectFolderSandboxModuleCandidates(u),f=u.find(e=>e.name===SANDBOX_WORKSPACE_DIRECTORY_NAME&&e.isDirectory());if(d.length>1)return s.push(createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple sandbox definition modules inside "${normalizeLogicalPath(SANDBOX_DIRECTORY_NAME)}": `+d.map(e=>`"${e}"`).join(`, `),sourcePath:l})),{diagnostics:s,sandbox:null,sandboxWorkspace:null};let[p]=d,m=p!==void 0,h=f!==void 0;if(!m&&!h)return s.push(createDiscoverErrorDiagnostic({code:DISCOVER_SANDBOX_FOLDER_EMPTY,message:`Sandbox folder "sandbox/" contains neither a "sandbox.<ext>" definition nor a "workspace/" subdirectory. Add one or the other, or remove the folder.`,sourcePath:l})),{diagnostics:s,sandbox:null,sandboxWorkspace:null};let g=null;m&&(g=createModuleSourceRef({logicalPath:join(SANDBOX_DIRECTORY_NAME,p)}));let _=null;if(h){let t=join(l,SANDBOX_WORKSPACE_DIRECTORY_NAME),r=normalizeLogicalPath(join(SANDBOX_DIRECTORY_NAME,SANDBOX_WORKSPACE_DIRECTORY_NAME)),a=await checkWorkspaceSkillsReservation(o.source,t);a===null?_={logicalPath:r,rootEntries:await collectWorkspaceRootEntries(o.source,t),sourceId:createPathDerivedSourceId(r),sourcePath:t}:s.push(a)}return{diagnostics:s,sandbox:g,sandboxWorkspace:_}}function discoverRootSandboxModule(e){let n=collectFlatSlotCandidates(e.rootEntries,{moduleBaseName:SANDBOX_DEFINITION_BASE_NAME});if(n.moduleFileNames.length>1)return e.diagnostics.push(createDiscoverErrorDiagnostic({code:DISCOVER_MODULE_SLOT_COLLISION,message:`Found multiple top-level sandbox definition modules: `+n.moduleFileNames.map(e=>`"${e}"`).join(`, `),sourcePath:e.rootPath})),{diagnostics:e.diagnostics,sandbox:null,sandboxWorkspace:null};let[i]=n.moduleFileNames;return i===void 0?{diagnostics:e.diagnostics,sandbox:null,sandboxWorkspace:null}:{diagnostics:e.diagnostics,sandbox:createModuleSourceRef({logicalPath:i}),sandboxWorkspace:null}}function collectFolderSandboxModuleCandidates(e){let t=e.filter(e=>e.isFile()),n=[];for(let e of collectNamedSlotCandidates(t,{allowMarkdown:!1,allowModules:!0}))e.slotName===SANDBOX_DEFINITION_BASE_NAME&&n.push(...e.moduleFileNames);return n}async function collectWorkspaceRootEntries(e,t){let n=await readSortedDirectoryEntries(e,t),r=[];for(let e of n){if(e.isDirectory()){r.push(`${e.name}/`);continue}e.isFile()&&r.push(e.name)}return r}async function checkWorkspaceSkillsReservation(n,r){return(await readSortedDirectoryEntries(n,r)).find(e=>e.name===`skills`)===void 0?null:createDiscoverErrorDiagnostic({code:DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,message:`"sandbox/workspace/skills/" is reserved for the framework skill discovery. Move skill files under "agent/skills/" instead, or rename the subtree.`,sourcePath:join(r,`skills`)})}export{DISCOVER_SANDBOX_FOLDER_EMPTY,DISCOVER_SANDBOX_WORKSPACE_SKILLS_RESERVED,discoverSandboxSource};
@@ -1 +1 @@
1
- import{join}from"node:path";import{discoverNamedSourceDirectory}from"#discover/grammar.js";import{lowerScheduleMarkdown}from"#internal/helpers/markdown.js";var DISCOVER_SCHEDULES_DIRECTORY_INVALID=`discover/schedules-directory-invalid`,DISCOVER_SCHEDULE_FILE_UNSUPPORTED=`discover/schedule-file-unsupported`;async function discoverScheduleSources(t){let n=await discoverNamedSourceDirectory({allowMarkdown:!0,directoryName:`schedules`,invalidDirectoryCode:DISCOVER_SCHEDULES_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.agentRoot,`schedules`)}" to be a directory of authored schedules.`,markdownLowerer:e=>lowerScheduleMarkdown(e),recursive:!0,rootEntries:t.rootEntries,rootPath:t.agentRoot,source:t.source,unsupportedFileCode:DISCOVER_SCHEDULE_FILE_UNSUPPORTED,unsupportedFileMessage:e=>`Expected "${e}" to be a TypeScript or markdown schedule file within "schedules/".`});return{diagnostics:n.diagnostics,schedules:n.sources}}export{DISCOVER_SCHEDULES_DIRECTORY_INVALID,DISCOVER_SCHEDULE_FILE_UNSUPPORTED,discoverScheduleSources};
1
+ import{join}from"node:path";import{discoverNamedSourceDirectory}from"#discover/grammar.js";import{lowerScheduleMarkdown}from"#internal/helpers/markdown.js";const DISCOVER_SCHEDULES_DIRECTORY_INVALID=`discover/schedules-directory-invalid`,DISCOVER_SCHEDULE_FILE_UNSUPPORTED=`discover/schedule-file-unsupported`;async function discoverScheduleSources(t){let n=await discoverNamedSourceDirectory({allowMarkdown:!0,directoryName:`schedules`,invalidDirectoryCode:DISCOVER_SCHEDULES_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.agentRoot,`schedules`)}" to be a directory of authored schedules.`,markdownLowerer:e=>lowerScheduleMarkdown(e),recursive:!0,rootEntries:t.rootEntries,rootPath:t.agentRoot,source:t.source,unsupportedFileCode:DISCOVER_SCHEDULE_FILE_UNSUPPORTED,unsupportedFileMessage:e=>`Expected "${e}" to be a TypeScript or markdown schedule file within "schedules/".`});return{diagnostics:n.diagnostics,schedules:n.sources}}export{DISCOVER_SCHEDULES_DIRECTORY_INVALID,DISCOVER_SCHEDULE_FILE_UNSUPPORTED,discoverScheduleSources};
@@ -1 +1 @@
1
- import{toErrorMessage}from"#shared/errors.js";import{join,relative,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createModuleSourceRef,createPathDerivedSourceId,createSkillPackageSourceRef}from"#discover/manifest.js";import{readSortedDirectoryEntries}from"#discover/grammar.js";import{lowerSkillMarkdown}from"#internal/helpers/markdown.js";var DISCOVER_SKILLS_DIRECTORY_INVALID=`discover/skills-directory-invalid`,DISCOVER_SKILL_COLLISION=`discover/skill-collision`,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY=`discover/skill-entry-not-directory`,DISCOVER_SKILL_FRONTMATTER_INVALID=`discover/skill-frontmatter-invalid`,DISCOVER_SKILL_MARKDOWN_MISSING=`discover/skill-markdown-missing`;async function discoverSkills(e){let a=e.source??createDiskProjectSource(),o=resolve(e.agentRoot),c=resolve(e.skillsDirectoryPath??join(o,`skills`)),l=normalizeLogicalPath(e.skillsLogicalPath??relative(o,c)),u=await a.stat(c);if(u===`missing`)return{diagnostics:[],skills:[]};if(u!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILLS_DIRECTORY_INVALID,message:`Expected "${c}" to be a directory of authored skills.`,sourcePath:c})],skills:[]};let d=[],f=new Set,p=new Map,m=await readSortedDirectoryEntries(a,c);for(let e of m){let n=await discoverOneSkill({entryName:e.name,entryType:getDirectoryEntryType(e),skillsDirectoryPath:c,skillsLogicalPath:l,source:a});if(d.push(...n.diagnostics),n.skill===null||n.skillId===null||f.has(n.skillId))continue;let r=p.get(n.skillId);if(r!==void 0){d.push(createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_COLLISION,message:`Found conflicting authored skill sources for "${n.skillId}": "${r.logicalPath}" and "${n.logicalPath}".`,sourcePath:join(c,n.skillId)})),f.add(n.skillId),p.delete(n.skillId);continue}p.set(n.skillId,{logicalPath:n.logicalPath,skill:n.skill})}return{diagnostics:d,skills:[...p.values()].map(e=>e.skill)}}async function discoverOneSkill(e){let n=join(e.skillsDirectoryPath,e.entryName);switch(classifySkillsDirectoryEntry(e.entryName,e.entryType)){case`skill-package-directory`:return discoverPackagedSkill({logicalSkillsPath:e.skillsLogicalPath,skillId:e.entryName,skillRootPath:n,source:e.source});case`flat-skill-markdown`:return discoverFlatMarkdownSkill({logicalSkillsPath:e.skillsLogicalPath,skillFileName:e.entryName,skillFilePath:n,source:e.source});case`flat-skill-module`:return discoverFlatModuleSkill({logicalSkillsPath:e.skillsLogicalPath,skillFileName:e.entryName});default:return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,message:`Expected "${n}" to be a skill directory containing SKILL.md or a flat ".md", ".ts", ".cts", ".mts", ".js", ".cjs", or ".mjs" skill file.`,sourcePath:n})],logicalPath:normalizeLogicalPath(join(e.skillsLogicalPath,e.entryName)),skill:null,skillId:null}}}async function discoverPackagedSkill(e){let n=join(e.skillRootPath,`SKILL.md`),r=normalizeLogicalPath(join(e.logicalSkillsPath,e.skillId,`SKILL.md`));if(await e.source.stat(n)!==`file`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_MARKDOWN_MISSING,message:`Expected "${n}" to exist for the "${e.skillId}" skill.`,sourcePath:e.skillRootPath})],logicalPath:r,skill:null,skillId:null};let a;try{a=lowerSkillMarkdown(await e.source.readTextFile(n))}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(n,e),sourcePath:n})],logicalPath:r,skill:null,skillId:null}}let o=await discoverSkillPackagePaths(e.source,e.skillRootPath),s={description:a.description,logicalPath:r,markdown:a.markdown,name:e.skillId,rootPath:e.skillRootPath,skillFilePath:n,skillId:e.skillId,sourceId:createPathDerivedSourceId(r)};return o.assetsPath!==void 0&&(s.assetsPath=o.assetsPath),a.license!==void 0&&(s.license=a.license),a.metadata!==void 0&&(s.metadata=a.metadata),o.referencesPath!==void 0&&(s.referencesPath=o.referencesPath),o.scriptsPath!==void 0&&(s.scriptsPath=o.scriptsPath),{diagnostics:[],logicalPath:r,skill:createSkillPackageSourceRef(s),skillId:e.skillId}}async function discoverFlatMarkdownSkill(e){let n=stripMarkdownExtension(e.skillFileName),r=normalizeLogicalPath(join(e.logicalSkillsPath,e.skillFileName)),a;try{a=lowerSkillMarkdown(await e.source.readTextFile(e.skillFilePath),{slug:n})}catch(t){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(e.skillFilePath,t),sourcePath:e.skillFilePath})],logicalPath:r,skill:null,skillId:null}}return{diagnostics:[],logicalPath:r,skill:{definition:a,sourceKind:`markdown`,logicalPath:r,sourceId:createPathDerivedSourceId(r)},skillId:n}}async function discoverFlatModuleSkill(e){let n=getSupportedModuleBaseName(e.skillFileName),r=normalizeLogicalPath(join(e.logicalSkillsPath,e.skillFileName));return n===null?{diagnostics:[],logicalPath:r,skill:null,skillId:null}:{diagnostics:[],logicalPath:r,skill:createModuleSourceRef({logicalPath:r}),skillId:n}}async function discoverSkillPackagePaths(e,n){let r=await e.readDirectory(n),i={};for(let e of r)if(e.isDirectory())switch(classifySkillPackageEntry(e.name,getDirectoryEntryType(e))){case`skill-assets-directory`:i.assetsPath=join(n,e.name);break;case`skill-references-directory`:i.referencesPath=join(n,e.name);break;case`skill-scripts-directory`:i.scriptsPath=join(n,e.name);break;default:break}return i}function formatSkillDiscoveryError(t,n){return`Invalid authored skill frontmatter in "${t}": ${toErrorMessage(n)}`}function stripMarkdownExtension(e){return e.endsWith(`.md`)?e.slice(0,-3):e}export{DISCOVER_SKILLS_DIRECTORY_INVALID,DISCOVER_SKILL_COLLISION,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,DISCOVER_SKILL_FRONTMATTER_INVALID,DISCOVER_SKILL_MARKDOWN_MISSING,discoverSkills};
1
+ import{toErrorMessage}from"#shared/errors.js";import{join,relative,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createModuleSourceRef,createPathDerivedSourceId,createSkillPackageSourceRef}from"#discover/manifest.js";import{readSortedDirectoryEntries}from"#discover/grammar.js";import{lowerSkillMarkdown}from"#internal/helpers/markdown.js";const DISCOVER_SKILLS_DIRECTORY_INVALID=`discover/skills-directory-invalid`,DISCOVER_SKILL_COLLISION=`discover/skill-collision`,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY=`discover/skill-entry-not-directory`,DISCOVER_SKILL_FRONTMATTER_INVALID=`discover/skill-frontmatter-invalid`,DISCOVER_SKILL_MARKDOWN_MISSING=`discover/skill-markdown-missing`;async function discoverSkills(e){let a=e.source??createDiskProjectSource(),o=resolve(e.agentRoot),c=resolve(e.skillsDirectoryPath??join(o,`skills`)),l=normalizeLogicalPath(e.skillsLogicalPath??relative(o,c)),u=await a.stat(c);if(u===`missing`)return{diagnostics:[],skills:[]};if(u!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILLS_DIRECTORY_INVALID,message:`Expected "${c}" to be a directory of authored skills.`,sourcePath:c})],skills:[]};let d=[],f=new Set,p=new Map,m=await readSortedDirectoryEntries(a,c);for(let e of m){let n=await discoverOneSkill({entryName:e.name,entryType:getDirectoryEntryType(e),skillsDirectoryPath:c,skillsLogicalPath:l,source:a});if(d.push(...n.diagnostics),n.skill===null||n.skillId===null||f.has(n.skillId))continue;let r=p.get(n.skillId);if(r!==void 0){d.push(createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_COLLISION,message:`Found conflicting authored skill sources for "${n.skillId}": "${r.logicalPath}" and "${n.logicalPath}".`,sourcePath:join(c,n.skillId)})),f.add(n.skillId),p.delete(n.skillId);continue}p.set(n.skillId,{logicalPath:n.logicalPath,skill:n.skill})}return{diagnostics:d,skills:[...p.values()].map(e=>e.skill)}}async function discoverOneSkill(e){let n=join(e.skillsDirectoryPath,e.entryName);switch(classifySkillsDirectoryEntry(e.entryName,e.entryType)){case`skill-package-directory`:return discoverPackagedSkill({logicalSkillsPath:e.skillsLogicalPath,skillId:e.entryName,skillRootPath:n,source:e.source});case`flat-skill-markdown`:return discoverFlatMarkdownSkill({logicalSkillsPath:e.skillsLogicalPath,skillFileName:e.entryName,skillFilePath:n,source:e.source});case`flat-skill-module`:return discoverFlatModuleSkill({logicalSkillsPath:e.skillsLogicalPath,skillFileName:e.entryName});default:return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,message:`Expected "${n}" to be a skill directory containing SKILL.md or a flat ".md", ".ts", ".cts", ".mts", ".js", ".cjs", or ".mjs" skill file.`,sourcePath:n})],logicalPath:normalizeLogicalPath(join(e.skillsLogicalPath,e.entryName)),skill:null,skillId:null}}}async function discoverPackagedSkill(e){let n=join(e.skillRootPath,`SKILL.md`),r=normalizeLogicalPath(join(e.logicalSkillsPath,e.skillId,`SKILL.md`));if(await e.source.stat(n)!==`file`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_MARKDOWN_MISSING,message:`Expected "${n}" to exist for the "${e.skillId}" skill.`,sourcePath:e.skillRootPath})],logicalPath:r,skill:null,skillId:null};let a;try{a=lowerSkillMarkdown(await e.source.readTextFile(n))}catch(e){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(n,e),sourcePath:n})],logicalPath:r,skill:null,skillId:null}}let o=await discoverSkillPackagePaths(e.source,e.skillRootPath),s={description:a.description,logicalPath:r,markdown:a.markdown,name:e.skillId,rootPath:e.skillRootPath,skillFilePath:n,skillId:e.skillId,sourceId:createPathDerivedSourceId(r)};return o.assetsPath!==void 0&&(s.assetsPath=o.assetsPath),a.license!==void 0&&(s.license=a.license),a.metadata!==void 0&&(s.metadata=a.metadata),o.referencesPath!==void 0&&(s.referencesPath=o.referencesPath),o.scriptsPath!==void 0&&(s.scriptsPath=o.scriptsPath),{diagnostics:[],logicalPath:r,skill:createSkillPackageSourceRef(s),skillId:e.skillId}}async function discoverFlatMarkdownSkill(e){let n=stripMarkdownExtension(e.skillFileName),r=normalizeLogicalPath(join(e.logicalSkillsPath,e.skillFileName)),a;try{a=lowerSkillMarkdown(await e.source.readTextFile(e.skillFilePath),{slug:n})}catch(t){return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SKILL_FRONTMATTER_INVALID,message:formatSkillDiscoveryError(e.skillFilePath,t),sourcePath:e.skillFilePath})],logicalPath:r,skill:null,skillId:null}}return{diagnostics:[],logicalPath:r,skill:{definition:a,sourceKind:`markdown`,logicalPath:r,sourceId:createPathDerivedSourceId(r)},skillId:n}}async function discoverFlatModuleSkill(e){let n=getSupportedModuleBaseName(e.skillFileName),r=normalizeLogicalPath(join(e.logicalSkillsPath,e.skillFileName));return n===null?{diagnostics:[],logicalPath:r,skill:null,skillId:null}:{diagnostics:[],logicalPath:r,skill:createModuleSourceRef({logicalPath:r}),skillId:n}}async function discoverSkillPackagePaths(e,n){let r=await e.readDirectory(n),i={};for(let e of r)if(e.isDirectory())switch(classifySkillPackageEntry(e.name,getDirectoryEntryType(e))){case`skill-assets-directory`:i.assetsPath=join(n,e.name);break;case`skill-references-directory`:i.referencesPath=join(n,e.name);break;case`skill-scripts-directory`:i.scriptsPath=join(n,e.name);break;default:break}return i}function formatSkillDiscoveryError(t,n){return`Invalid authored skill frontmatter in "${t}": ${toErrorMessage(n)}`}function stripMarkdownExtension(e){return e.endsWith(`.md`)?e.slice(0,-3):e}export{DISCOVER_SKILLS_DIRECTORY_INVALID,DISCOVER_SKILL_COLLISION,DISCOVER_SKILL_ENTRY_NOT_DIRECTORY,DISCOVER_SKILL_FRONTMATTER_INVALID,DISCOVER_SKILL_MARKDOWN_MISSING,discoverSkills};
@@ -1 +1 @@
1
- import{join,relative}from"node:path";import{readdir}from"node:fs/promises";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";var EVAL_SUITE_GLOB_SUFFIX=`.eval.ts`;async function discoverSuiteFiles(n){let r=join(n,`evals`),i=[];try{await collectSuiteFiles(r,i)}catch(e){if(isNoEntryError(e))return[];throw e}return i.sort((e,n)=>relative(r,e).localeCompare(relative(r,n))),i}function deriveSuiteId(n,r){let a=relative(join(n,`evals`),r).split(/[\\/]/u).join(`/`);return a.endsWith(EVAL_SUITE_GLOB_SUFFIX)?a.slice(0,-EVAL_SUITE_GLOB_SUFFIX.length):a}async function importSuiteFile(e,t){let n=(await loadAuthoredModuleNamespace(t)).default;if(!isAshEvalSuiteDefinition(n))throw Error(`Suite file "${t}" does not export a valid AshEvalSuite as its default export. Use defineEvalSuite() to create the suite.`);return{...n,id:deriveSuiteId(e,t)}}async function discoverAndImportSuites(e,t){let n=await discoverSuiteFiles(e);if(n.length===0)return[];let r=[];for(let i of n){let n=await importSuiteFile(e,i);(t===void 0||t.length===0||t.includes(n.id))&&r.push(n)}return r}function isAshEvalSuiteDefinition(e){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AshEvalSuite`}async function collectSuiteFiles(t,r){let a=await readdir(t,{withFileTypes:!0});for(let n of a){let a=join(t,n.name);n.isDirectory()?await collectSuiteFiles(a,r):n.isFile()&&n.name.endsWith(EVAL_SUITE_GLOB_SUFFIX)&&r.push(a)}}function isNoEntryError(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}export{discoverAndImportSuites,discoverSuiteFiles,importSuiteFile};
1
+ import{join,relative}from"node:path";import{readdir}from"node:fs/promises";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";const EVAL_SUITE_GLOB_SUFFIX=`.eval.ts`;async function discoverSuiteFiles(n){let r=join(n,`evals`),i=[];try{await collectSuiteFiles(r,i)}catch(e){if(isNoEntryError(e))return[];throw e}return i.sort((e,n)=>relative(r,e).localeCompare(relative(r,n))),i}function deriveSuiteId(n,r){let a=relative(join(n,`evals`),r).split(/[\\/]/u).join(`/`);return a.endsWith(EVAL_SUITE_GLOB_SUFFIX)?a.slice(0,-8):a}async function importSuiteFile(e,t){let n=(await loadAuthoredModuleNamespace(t)).default;if(!isAshEvalSuiteDefinition(n))throw Error(`Suite file "${t}" does not export a valid AshEvalSuite as its default export. Use defineEvalSuite() to create the suite.`);return{...n,id:deriveSuiteId(e,t)}}async function discoverAndImportSuites(e,t){let n=await discoverSuiteFiles(e);if(n.length===0)return[];let r=[];for(let i of n){let n=await importSuiteFile(e,i);(t===void 0||t.length===0||t.includes(n.id))&&r.push(n)}return r}function isAshEvalSuiteDefinition(e){return typeof e==`object`&&!!e&&`_tag`in e&&e._tag===`AshEvalSuite`}async function collectSuiteFiles(t,r){let a=await readdir(t,{withFileTypes:!0});for(let n of a){let a=join(t,n.name);n.isDirectory()?await collectSuiteFiles(a,r):n.isFile()&&n.name.endsWith(EVAL_SUITE_GLOB_SUFFIX)&&r.push(a)}}function isNoEntryError(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}export{discoverAndImportSuites,discoverSuiteFiles,importSuiteFile};
@@ -1 +1 @@
1
- import{toErrorMessage}from"#shared/errors.js";import{resolveArtifactDirectory,writeArtifacts}from"#evals/runner/artifacts.js";import{executeCase}from"#evals/runner/execute-case.js";var DEFAULT_MAX_CONCURRENCY=8;async function executeSuite(e){let{suite:r,target:a,reporters:o,appRoot:s,client:c}=e,l=new Date().toISOString();for(let e of o)await e.onSuiteStart(r,a);let u=await r.load(),d=r.maxConcurrency??DEFAULT_MAX_CONCURRENCY,f=[],p=[...u],m=new Set;for(;p.length>0||m.size>0;){for(;p.length>0&&m.size<d;){let e=p.shift();if(e===void 0)break;let t=(async()=>{let t=await executeSingleCase(r,e,c);f.push(t);for(let e of o)await e.onCaseComplete(t)})().finally(()=>{m.delete(t)});m.add(t)}m.size>0&&await Promise.race(m)}let h=new Date().toISOString(),g={suite:r.id,target:a,cases:f,startedAt:l,completedAt:h,passed:f.filter(e=>!e.error&&e.scores.every(e=>meetsThreshold(e,r.thresholds))).length,errored:f.filter(e=>e.error!==void 0).length};await writeArtifacts(resolveArtifactDirectory(s,r.id),g);for(let e of o)await e.onSuiteComplete(g);return g}async function executeSingleCase(t,n,i){let a,o;try{a=await executeCase({client:i,testCase:n,task:t.task,timeoutMs:t.timeoutMs})}catch(t){o=toErrorMessage(t),a={output:null,finalMessage:null,status:`failed`,events:[],derived:{toolCalls:[],toolCallCount:0,subagentCalls:[],subagentCallCount:0,messageCount:0,reasoningBlockCount:0}}}let s=await runScorers(t,n,a);return{case:n,result:a,scores:s,error:o}}async function runScorers(e,t,n){let r={input:typeof t.input==`string`?t.input:JSON.stringify(t.input),output:String(n.output??``),expected:t.expected===void 0?void 0:String(t.expected),model:e.model,modelOptions:e.modelOptions,case:t,result:n},i=[];for(let t of e.scores){let e=await t(r);e!==null&&i.push(e)}return i}function meetsThreshold(e,t){if(e.score===null)return!0;let n=t?.[e.name]??1;return e.score>=n}export{executeSuite};
1
+ import{toErrorMessage}from"#shared/errors.js";import{resolveArtifactDirectory,writeArtifacts}from"#evals/runner/artifacts.js";import{executeCase}from"#evals/runner/execute-case.js";async function executeSuite(e){let{suite:r,target:i,reporters:a,appRoot:o,client:s}=e,c=new Date().toISOString();for(let e of a)await e.onSuiteStart(r,i);let l=await r.load(),u=r.maxConcurrency??8,d=[],f=[...l],p=new Set;for(;f.length>0||p.size>0;){for(;f.length>0&&p.size<u;){let e=f.shift();if(e===void 0)break;let t=(async()=>{let t=await executeSingleCase(r,e,s);d.push(t);for(let e of a)await e.onCaseComplete(t)})().finally(()=>{p.delete(t)});p.add(t)}p.size>0&&await Promise.race(p)}let m=new Date().toISOString(),h={suite:r.id,target:i,cases:d,startedAt:c,completedAt:m,passed:d.filter(e=>!e.error&&e.scores.every(e=>meetsThreshold(e,r.thresholds))).length,errored:d.filter(e=>e.error!==void 0).length};await writeArtifacts(resolveArtifactDirectory(o,r.id),h);for(let e of a)await e.onSuiteComplete(h);return h}async function executeSingleCase(t,n,i){let a,o;try{a=await executeCase({client:i,testCase:n,task:t.task,timeoutMs:t.timeoutMs})}catch(t){o=toErrorMessage(t),a={output:null,finalMessage:null,status:`failed`,events:[],derived:{toolCalls:[],toolCallCount:0,subagentCalls:[],subagentCallCount:0,messageCount:0,reasoningBlockCount:0}}}let s=await runScorers(t,n,a);return{case:n,result:a,scores:s,error:o}}async function runScorers(e,t,n){let r={input:typeof t.input==`string`?t.input:JSON.stringify(t.input),output:String(n.output??``),expected:t.expected===void 0?void 0:String(t.expected),model:e.model,modelOptions:e.modelOptions,case:t,result:n},i=[];for(let t of e.scores){let e=await t(r);e!==null&&i.push(e)}return i}function meetsThreshold(e,t){if(e.score===null)return!0;let n=t?.[e.name]??1;return e.score>=n}export{executeSuite};
@@ -1,2 +1,2 @@
1
- import{resolveLocalGitMetadata}from"#evals/runner/resolve-git-metadata.js";function Braintrust(e={}){return new BraintrustReporter(e)}var BraintrustReporter=class{#e;#t;#n;#r;constructor(e){this.#e=e}async onSuiteStart(t,n){let r=await loadBraintrustSdk();this.#t=r;let i=resolveLocalGitMetadata(process.cwd());this.#r=t.metadata;let a=resolveTags(t,n),o=resolveExperimentMetadata(t,n);this.#n=await r.init({project:this.#e.projectName??t.id,projectId:this.#e.projectId,experiment:this.#e.experimentName,baseExperiment:this.#e.baseExperimentName,baseExperimentId:this.#e.baseExperimentId,update:this.#e.update,tags:a,metadata:o,noExitFlush:!0,setCurrent:!1,repoInfo:i.sha?{commit:i.sha,branch:i.branch}:null})}onCaseComplete(e){if(!this.#n)return;let t={};for(let n of e.scores)n.score!==null&&(t[n.name]=n.score);let n={...this.#r,...e.case.metadata,ashSessionId:e.result.sessionId,ashStatus:e.result.status,ashToolCalls:e.result.derived.toolCalls,ashSubagentCalls:e.result.derived.subagentCalls};e.result.derived.failureCode&&(n.ashFailureCode=e.result.derived.failureCode);let r={toolCallCount:e.result.derived.toolCallCount,subagentCallCount:e.result.derived.subagentCallCount,messageCount:e.result.derived.messageCount,reasoningBlockCount:e.result.derived.reasoningBlockCount};this.#n.log({id:e.case.id,input:e.case.input,output:e.result.output,expected:e.case.expected,error:e.error??void 0,scores:t,metadata:n,metrics:r,tags:e.case.tags?[...e.case.tags]:void 0})}async onSuiteComplete(e){if(this.#n)try{this.#t&&await this.#t.flush();let e=await this.#n.summarize();e.experimentUrl&&console.log(`Braintrust experiment: ${e.experimentUrl}\n\n`)}finally{await this.#n.close(),this.#n=void 0,this.#t=void 0}}},BRAINTRUST_PACKAGE=`braintrust`;async function loadBraintrustSdk(){try{return await import(BRAINTRUST_PACKAGE)}catch{throw Error([`The 'braintrust' package is required for Braintrust reporting but was not found.`,``,`Install it with:`,` npm install braintrust`].join(`
1
+ import{resolveLocalGitMetadata}from"#evals/runner/resolve-git-metadata.js";function Braintrust(e={}){return new BraintrustReporter(e)}var BraintrustReporter=class{#e;#t;#n;#r;constructor(e){this.#e=e}async onSuiteStart(t,n){let r=await loadBraintrustSdk();this.#t=r;let i=resolveLocalGitMetadata(process.cwd());this.#r=t.metadata;let a=resolveTags(t,n),o=resolveExperimentMetadata(t,n);this.#n=await r.init({project:this.#e.projectName??t.id,projectId:this.#e.projectId,experiment:this.#e.experimentName,baseExperiment:this.#e.baseExperimentName,baseExperimentId:this.#e.baseExperimentId,update:this.#e.update,tags:a,metadata:o,noExitFlush:!0,setCurrent:!1,repoInfo:i.sha?{commit:i.sha,branch:i.branch}:null})}onCaseComplete(e){if(!this.#n)return;let t={};for(let n of e.scores)n.score!==null&&(t[n.name]=n.score);let n={...this.#r,...e.case.metadata,ashSessionId:e.result.sessionId,ashStatus:e.result.status,ashToolCalls:e.result.derived.toolCalls,ashSubagentCalls:e.result.derived.subagentCalls};e.result.derived.failureCode&&(n.ashFailureCode=e.result.derived.failureCode);let r={toolCallCount:e.result.derived.toolCallCount,subagentCallCount:e.result.derived.subagentCallCount,messageCount:e.result.derived.messageCount,reasoningBlockCount:e.result.derived.reasoningBlockCount};this.#n.log({id:e.case.id,input:e.case.input,output:e.result.output,expected:e.case.expected,error:e.error??void 0,scores:t,metadata:n,metrics:r,tags:e.case.tags?[...e.case.tags]:void 0})}async onSuiteComplete(e){if(this.#n)try{this.#t&&await this.#t.flush();let e=await this.#n.summarize();e.experimentUrl&&console.log(`Braintrust experiment: ${e.experimentUrl}\n\n`)}finally{await this.#n.close(),this.#n=void 0,this.#t=void 0}}};async function loadBraintrustSdk(){try{return await import(`braintrust`)}catch{throw Error([`The 'braintrust' package is required for Braintrust reporting but was not found.`,``,`Install it with:`,` npm install braintrust`].join(`
2
2
  `))}}function resolveTags(e,t){let n=[`ash`,`suite:${e.id}`,`target:${t.kind}`];return Array.isArray(e.tags)&&n.push(...e.tags),n}function resolveExperimentMetadata(e,t){return{ashSuiteId:e.id,ashTargetKind:t.kind,ashTargetUrl:t.url,ashTimestamp:new Date().toISOString()}}export{Braintrust};
@@ -1 +1 @@
1
- import*as JsonScorers from"#evals/scorers/json.js";import*as RunScorers from"#evals/scorers/run.js";import*as SqlScorers from"#evals/scorers/sql.js";import*as TextScorers from"#evals/scorers/text.js";import*as AutoevalsScorers from"#evals/scorers/autoevals.js";var Text=TextScorers,Json=JsonScorers,Sql=SqlScorers,Run=RunScorers,Autoevals=AutoevalsScorers;export{Autoevals,Json,Run,Sql,Text};
1
+ import*as JsonScorers from"#evals/scorers/json.js";import*as RunScorers from"#evals/scorers/run.js";import*as SqlScorers from"#evals/scorers/sql.js";import*as TextScorers from"#evals/scorers/text.js";import*as AutoevalsScorers from"#evals/scorers/autoevals.js";const Text=TextScorers,Json=JsonScorers,Sql=SqlScorers,Run=RunScorers,Autoevals=AutoevalsScorers;export{Autoevals,Json,Run,Sql,Text};
@@ -1 +1 @@
1
- import{createAshConnectionCallbackRoutePath}from"#protocol/routes.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{getHarnessEmissionState}from"#harness/emission.js";import{completeAuthorizationForConnectionStep,emitConnectionAuthorizationPendingStep,resolvePendingToolCallsStep,startAuthorizationForConnectionStep}from"#execution/connection-auth-steps.js";async function awaitAuthorizationAndResolve(s){let c=getHarnessEmissionState(s.session),l=uniqueConnectionNames(s.pendingToolCalls);if(l.length===0)return{serializedContext:s.serializedContext,session:s.session};let u=trimTrailingSlash(getWorkflowMetadata().url),d=l.map(n=>{let r=createHook();return{connectionName:n,hook:r,webhookUrl:`${u}${createAshConnectionCallbackRoutePath(n,r.token)}`}}),f=await Promise.all(d.map(async({connectionName:e,hook:t,webhookUrl:n})=>({connectionName:e,hook:t,webhookUrl:n,start:await startAuthorizationForConnectionStep({connectionName:e,emissionState:c,parentWritable:s.parentWritable,serializedContext:s.serializedContext,webhookUrl:n})}))),p=f.flatMap(e=>e.start.ok?[{connectionName:e.connectionName,hook:e.hook,principal:e.start.principal,serializedContext:e.start.serializedContext,state:e.start.state,webhookUrl:e.webhookUrl}]:[]);p.length>0&&await emitConnectionAuthorizationPendingStep({connectionNames:p.map(e=>e.connectionName),emissionState:c,parentWritable:s.parentWritable,serializedContext:s.serializedContext});let m=await Promise.all(p.map(async({connectionName:e,hook:t,principal:n,serializedContext:r,state:i,webhookUrl:a})=>{try{let o=await awaitHookRequest(t);return{complete:await completeAuthorizationForConnectionStep({connectionName:e,emissionState:c,parentWritable:s.parentWritable,principal:n,request:o,serializedContext:r,state:i,webhookUrl:a}),connectionName:e,principal:n}}finally{t.dispose()}})),h={},g={},_={},v=[];for(let e of f)e.start.ok||(_[e.connectionName]={reason:e.start.reason,retryable:!1});for(let e of m)e.complete.ok?(h[e.connectionName]=e.complete.token,g[e.connectionName]=e.principal,v.push(e.connectionName)):_[e.connectionName]={reason:e.complete.reason,retryable:e.complete.retryable};return resolvePendingToolCallsStep({failedConnections:_,parentWritable:s.parentWritable,pendingCalls:s.pendingToolCalls,principals:g,resolvedConnectionNames:v,serializedContext:s.serializedContext,session:s.session,tokens:h})}function uniqueConnectionNames(e){let t=new Set;for(let n of e){let e=n.kind===`connection-execute`?[n.connectionName]:n.connectionNames;for(let n of e)t.add(n)}return[...t]}async function awaitHookRequest(e){let t=await e[Symbol.asyncIterator]().next();if(t.done===!0||t.value===void 0)throw Error(`Connection callback hook closed before delivering a request.`);return t.value}function trimTrailingSlash(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{awaitAuthorizationAndResolve};
1
+ import{createAshConnectionCallbackRoutePath}from"#protocol/routes.js";import{getHarnessEmissionState}from"#harness/emission.js";import{createHook,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{completeAuthorizationForConnectionStep,emitConnectionAuthorizationPendingStep,resolvePendingToolCallsStep,startAuthorizationForConnectionStep}from"#execution/connection-auth-steps.js";async function awaitAuthorizationAndResolve(s){let c=getHarnessEmissionState(s.session),l=uniqueConnectionNames(s.pendingToolCalls);if(l.length===0)return{serializedContext:s.serializedContext,session:s.session};let u=trimTrailingSlash(getWorkflowMetadata().url),d=l.map(t=>{let r=createHook();return{connectionName:t,hook:r,webhookUrl:`${u}${createAshConnectionCallbackRoutePath(t,r.token)}`}}),f=await Promise.all(d.map(async({connectionName:e,hook:t,webhookUrl:n})=>({connectionName:e,hook:t,webhookUrl:n,start:await startAuthorizationForConnectionStep({connectionName:e,emissionState:c,parentWritable:s.parentWritable,serializedContext:s.serializedContext,webhookUrl:n})}))),p=f.flatMap(e=>e.start.ok?[{connectionName:e.connectionName,hook:e.hook,principal:e.start.principal,serializedContext:e.start.serializedContext,state:e.start.state,webhookUrl:e.webhookUrl}]:[]);p.length>0&&await emitConnectionAuthorizationPendingStep({connectionNames:p.map(e=>e.connectionName),emissionState:c,parentWritable:s.parentWritable,serializedContext:s.serializedContext});let m=await Promise.all(p.map(async({connectionName:e,hook:t,principal:n,serializedContext:r,state:i,webhookUrl:a})=>{try{let o=await awaitHookRequest(t);return{complete:await completeAuthorizationForConnectionStep({connectionName:e,emissionState:c,parentWritable:s.parentWritable,principal:n,request:o,serializedContext:r,state:i,webhookUrl:a}),connectionName:e,principal:n}}finally{t.dispose()}})),h={},g={},_={},v=[];for(let e of f)e.start.ok||(_[e.connectionName]={reason:e.start.reason,retryable:!1});for(let e of m)e.complete.ok?(h[e.connectionName]=e.complete.token,g[e.connectionName]=e.principal,v.push(e.connectionName)):_[e.connectionName]={reason:e.complete.reason,retryable:e.complete.retryable};return resolvePendingToolCallsStep({failedConnections:_,parentWritable:s.parentWritable,pendingCalls:s.pendingToolCalls,principals:g,resolvedConnectionNames:v,serializedContext:s.serializedContext,session:s.session,tokens:h})}function uniqueConnectionNames(e){let t=new Set;for(let n of e){let e=n.kind===`connection-execute`?[n.connectionName]:n.connectionNames;for(let n of e)t.add(n)}return[...t]}async function awaitHookRequest(e){let t=await e[Symbol.asyncIterator]().next();if(t.done===!0||t.value===void 0)throw Error(`Connection callback hook closed before delivering a request.`);return t.value}function trimTrailingSlash(e){return e.endsWith(`/`)?e.slice(0,-1):e}export{awaitAuthorizationAndResolve};
@@ -1 +1 @@
1
- import{createConnectionAuthorizationCompletedEvent,createConnectionAuthorizationPendingEvent,createConnectionAuthorizationRequiredEvent,encodeMessageStreamEvent,timestampHandleMessageStreamEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{BundleKey,ChannelKey}from"#context/keys.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{ConnectionRegistryImpl}from"#runtime/connections/registry.js";import{ConnectionRegistryKey,executeConnectionSearch}from"#runtime/framework-tools/connection-search.js";import{getActiveRuntimeNode}from"#context/node.js";import{PendingConnectionToolCallsKey,isConnectionAuthorizationPlaceholder}from"#runtime/framework-tools/pending-connection-tool-calls.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{isConnectionAuthorizationFailedError,isConnectionAuthorizationRequiredError}from"#public/connections/errors.js";import{writeCachedToken}from"#runtime/connections/authorization-tokens.js";import{withConnectionPrincipalOverride}from"#runtime/connections/principal-context.js";import{principalKey,resolveConnectionPrincipal}from"#runtime/connections/principal.js";import{withDefaultAuthorizationInstructions}from"#execution/authorization-challenge-defaults.js";import{splicePendingToolResults}from"#execution/await-authorization-splice.js";async function startAuthorizationForConnectionStep(t){"use step";let r=await deserializeContext(t.serializedContext),i=findConnection(r,t.connectionName);if(i?.authorization?.startAuthorization===void 0){let n=`Connection "${t.connectionName}" does not define startAuthorization.`;return await emitAuthorizationEvent(r,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:n,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:n}}let a=i.description??t.connectionName,o,s,c;try{o=resolveConnectionPrincipal(t.connectionName,i.authorization,r);let e=await i.authorization.startAuthorization({principal:o,connection:{url:i.url},callbackUrl:t.webhookUrl});s=withDefaultAuthorizationInstructions(e.challenge,t.connectionName),c=e.state}catch(n){let i=n instanceof Error?n.message:String(n);return await emitAuthorizationEvent(r,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:i,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:i}}return await emitAuthorizationEvent(r,createConnectionAuthorizationRequiredEvent({authorization:s,connectionName:t.connectionName,description:a,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId,webhookUrl:t.webhookUrl}),t.parentWritable),{ok:!0,principal:o,serializedContext:serializeContext(r),state:c}}async function emitConnectionAuthorizationPendingStep(e){"use step";e.connectionNames.length!==0&&await emitAuthorizationEvent(await deserializeContext(e.serializedContext),createConnectionAuthorizationPendingEvent({connectionNames:e.connectionNames,sequence:e.emissionState.sequence,stepIndex:e.emissionState.stepIndex,turnId:e.emissionState.turnId}),e.parentWritable)}async function completeAuthorizationForConnectionStep(t){"use step";let n=await deserializeContext(t.serializedContext),r=findConnection(n,t.connectionName);if(r?.authorization?.completeAuthorization===void 0){let r=`Connection "${t.connectionName}" does not define completeAuthorization.`;return await emitAuthorizationEvent(n,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:r,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:r,retryable:!1}}try{let i=await r.authorization.completeAuthorization({principal:t.principal,connection:{url:r.url},request:t.request,state:t.state,callbackUrl:t.webhookUrl});return await emitAuthorizationEvent(n,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`authorized`,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!0,token:i}}catch(r){let i=isConnectionAuthorizationFailedError(r)?r:null,a=i?.retryable??!0,o=i?.reason??(r instanceof Error?r.message:String(r));return await emitAuthorizationEvent(n,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:o,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:o,retryable:a}}}async function resolvePendingToolCallsStep(e){"use step";let t=await deserializeContext(e.serializedContext),n=new ConnectionRegistryImpl(getActiveRuntimeNode(t).agent?.connections??[]);t.setVirtualContext(ConnectionRegistryKey,n);for(let[n,r]of Object.entries(e.tokens)){let i=e.principals[n];if(i===void 0)throw Error(`Internal error: missing resolved principal for connection "${n}".`);writeCachedToken(t,n,principalKey(i),r)}let r={},i=new Set(e.resolvedConnectionNames);await contextStorage.run(t,()=>withConnectionPrincipalOverride(t,e.principals,async()=>{for(let t of e.pendingCalls){let a=t.kind===`connection-execute`?[t.connectionName]:t.connectionNames,o;for(let t of a){let n=e.failedConnections[t];if(n!==void 0){o={connectionName:t,...n};break}}if(o!==void 0&&t.kind===`connection-execute`){r[t.toolCallId]=o.retryable?{error:`authorization_required`,retryable:!0}:{connectionName:o.connectionName,error:`authorization_failed`,message:o.reason,retryable:!1};continue}if(!a.every(e=>i.has(e))&&t.kind===`connection-execute`){r[t.toolCallId]={error:`authorization_required`,retryable:!0};continue}try{if(t.kind===`connection-execute`){let e=await n.getClient(t.connectionName).executeTool(t.toolName,t.args);r[t.toolCallId]=normalizeToolResult(e)}else{let e=await executeConnectionSearch(t.args,{toolCallId:t.toolCallId});isConnectionAuthorizationPlaceholder(e)?r[t.toolCallId]={error:`authorization_required`,retryable:!0}:r[t.toolCallId]=normalizeToolResult(e)}}catch(e){if(isConnectionAuthorizationRequiredError(e)){r[t.toolCallId]={error:`authorization_required`,retryable:!0};continue}let n=e instanceof Error?e.message:String(e);r[t.toolCallId]={error:`tool_execution_failed`,message:n,retryable:!1}}}}));let o=splicePendingToolResults(e.session,r),s=e.pendingCalls.filter(t=>(t.kind===`connection-execute`?[t.connectionName]:t.connectionNames).some(t=>!i.has(t)&&e.failedConnections[t]===void 0));return t.set(PendingConnectionToolCallsKey,s),{serializedContext:serializeContext(t),session:o}}function findConnection(e,t){return e.get(BundleKey)===void 0?void 0:(getActiveRuntimeNode(e).agent?.connections??[]).find(e=>e.connectionName===t)}async function emitAuthorizationEvent(e,t,n){let a=e.require(ChannelKey),o=buildAdapterContext(a,e),l=await callAdapterEventHandler(a,t,o);e.set(ChannelKey,{...a,state:{...o.state}});let u=n.getWriter();try{await u.write(encodeMessageStreamEvent(timestampHandleMessageStreamEvent(l)))}finally{u.releaseLock()}}function normalizeToolResult(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return{error:`tool_result_not_serializable`,retryable:!1}}}export{completeAuthorizationForConnectionStep,emitConnectionAuthorizationPendingStep,resolvePendingToolCallsStep,startAuthorizationForConnectionStep};
1
+ import{createConnectionAuthorizationCompletedEvent,createConnectionAuthorizationPendingEvent,createConnectionAuthorizationRequiredEvent,encodeMessageStreamEvent,timestampHandleMessageStreamEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{callAdapterEventHandler}from"#channel/adapter.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{ConnectionRegistryImpl}from"#runtime/connections/registry.js";import{ConnectionRegistryKey,executeConnectionSearch}from"#runtime/framework-tools/connection-search.js";import{getActiveRuntimeNode}from"#context/node.js";import{PendingConnectionToolCallsKey,isConnectionAuthorizationPlaceholder}from"#runtime/framework-tools/pending-connection-tool-calls.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{isConnectionAuthorizationFailedError,isConnectionAuthorizationRequiredError}from"#public/connections/errors.js";import{writeCachedToken}from"#runtime/connections/authorization-tokens.js";import{withConnectionPrincipalOverride}from"#runtime/connections/principal-context.js";import{principalKey,resolveConnectionPrincipal}from"#runtime/connections/principal.js";import{withDefaultAuthorizationInstructions}from"#execution/authorization-challenge-defaults.js";import{splicePendingToolResults}from"#execution/await-authorization-splice.js";async function startAuthorizationForConnectionStep(t){"use step";let r=await deserializeContext(t.serializedContext),i=findConnection(r,t.connectionName);if(i?.authorization?.startAuthorization===void 0){let n=`Connection "${t.connectionName}" does not define startAuthorization.`;return await emitAuthorizationEvent(r,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:n,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:n}}let a=i.description??t.connectionName,o,s,c;try{o=resolveConnectionPrincipal(t.connectionName,i.authorization,r);let e=await i.authorization.startAuthorization({principal:o,connection:{url:i.url},callbackUrl:t.webhookUrl});s=withDefaultAuthorizationInstructions(e.challenge,t.connectionName),c=e.state}catch(n){let i=n instanceof Error?n.message:String(n);return await emitAuthorizationEvent(r,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:i,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:i}}return await emitAuthorizationEvent(r,createConnectionAuthorizationRequiredEvent({authorization:s,connectionName:t.connectionName,description:a,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId,webhookUrl:t.webhookUrl}),t.parentWritable),{ok:!0,principal:o,serializedContext:serializeContext(r),state:c}}async function emitConnectionAuthorizationPendingStep(e){"use step";e.connectionNames.length!==0&&await emitAuthorizationEvent(await deserializeContext(e.serializedContext),createConnectionAuthorizationPendingEvent({connectionNames:e.connectionNames,sequence:e.emissionState.sequence,stepIndex:e.emissionState.stepIndex,turnId:e.emissionState.turnId}),e.parentWritable)}async function completeAuthorizationForConnectionStep(t){"use step";let n=await deserializeContext(t.serializedContext),r=findConnection(n,t.connectionName);if(r?.authorization?.completeAuthorization===void 0){let r=`Connection "${t.connectionName}" does not define completeAuthorization.`;return await emitAuthorizationEvent(n,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:r,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:r,retryable:!1}}try{let i=await r.authorization.completeAuthorization({principal:t.principal,connection:{url:r.url},request:t.request,state:t.state,callbackUrl:t.webhookUrl});return await emitAuthorizationEvent(n,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`authorized`,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!0,token:i}}catch(r){let i=isConnectionAuthorizationFailedError(r)?r:null,a=i?.retryable??!0,o=i?.reason??(r instanceof Error?r.message:String(r));return await emitAuthorizationEvent(n,createConnectionAuthorizationCompletedEvent({connectionName:t.connectionName,outcome:`failed`,reason:o,sequence:t.emissionState.sequence,stepIndex:t.emissionState.stepIndex,turnId:t.emissionState.turnId}),t.parentWritable),{ok:!1,reason:o,retryable:a}}}async function resolvePendingToolCallsStep(e){"use step";let t=await deserializeContext(e.serializedContext),n=new ConnectionRegistryImpl(getActiveRuntimeNode(t).agent?.connections??[]);t.setVirtualContext(ConnectionRegistryKey,n);for(let[n,r]of Object.entries(e.tokens)){let i=e.principals[n];if(i===void 0)throw Error(`Internal error: missing resolved principal for connection "${n}".`);writeCachedToken(t,n,principalKey(i),r)}let r={},i=new Set(e.resolvedConnectionNames);await contextStorage.run(t,()=>withConnectionPrincipalOverride(t,e.principals,async()=>{for(let t of e.pendingCalls){let a=t.kind===`connection-execute`?[t.connectionName]:t.connectionNames,o;for(let t of a){let n=e.failedConnections[t];if(n!==void 0){o={connectionName:t,...n};break}}if(o!==void 0&&t.kind===`connection-execute`){r[t.toolCallId]=o.retryable?{error:`authorization_required`,retryable:!0}:{connectionName:o.connectionName,error:`authorization_failed`,message:o.reason,retryable:!1};continue}if(!a.every(e=>i.has(e))&&t.kind===`connection-execute`){r[t.toolCallId]={error:`authorization_required`,retryable:!0};continue}try{if(t.kind===`connection-execute`){let e=await n.getClient(t.connectionName).executeTool(t.toolName,t.args);r[t.toolCallId]=normalizeToolResult(e)}else{let e=await executeConnectionSearch(t.args,{toolCallId:t.toolCallId});isConnectionAuthorizationPlaceholder(e)?r[t.toolCallId]={error:`authorization_required`,retryable:!0}:r[t.toolCallId]=normalizeToolResult(e)}}catch(e){if(isConnectionAuthorizationRequiredError(e)){r[t.toolCallId]={error:`authorization_required`,retryable:!0};continue}let n=e instanceof Error?e.message:String(e);r[t.toolCallId]={error:`tool_execution_failed`,message:n,retryable:!1}}}}));let o=splicePendingToolResults(e.session,r),s=e.pendingCalls.filter(t=>(t.kind===`connection-execute`?[t.connectionName]:t.connectionNames).some(t=>!i.has(t)&&e.failedConnections[t]===void 0));return t.set(PendingConnectionToolCallsKey,s),{serializedContext:serializeContext(t),session:o}}function findConnection(e,t){return e.get(BundleKey)===void 0?void 0:(getActiveRuntimeNode(e).agent?.connections??[]).find(e=>e.connectionName===t)}async function emitAuthorizationEvent(e,t,n){let a=e.require(ChannelKey),s=buildAdapterContext(a,e),l=await callAdapterEventHandler(a,t,s);e.set(ChannelKey,{...a,state:{...s.state}});let u=n.getWriter();try{await u.write(encodeMessageStreamEvent(timestampHandleMessageStreamEvent(l)))}finally{u.releaseLock()}}function normalizeToolResult(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return{error:`tool_result_not_serializable`,retryable:!1}}}export{completeAuthorizationForConnectionStep,emitConnectionAuthorizationPendingStep,resolvePendingToolCallsStep,startAuthorizationForConnectionStep};
@@ -1,6 +1,6 @@
1
1
  import type { RunInput } from "#channel/types.js";
2
2
  import { ContextContainer } from "#context/container.js";
3
- import { type CompiledBundle } from "#context/keys.js";
3
+ import { type CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
4
4
  /**
5
5
  * Builds the bootstrap {@link ContextContainer} for one run.
6
6
  */
@@ -1 +1 @@
1
- import{ContextContainer}from"#context/container.js";import{AuthKey,BundleKey,CapabilitiesKey,ChannelKey,ContinuationTokenKey,InitiatorAuthKey,ModeKey,ParentSessionKey,SessionCallbackKey}from"#context/keys.js";function buildRunContext(e){let{bundle:t,run:n}=e,r=new ContextContainer,i=n.auth;return r.set(BundleKey,t),r.set(ChannelKey,n.adapter),r.set(ContinuationTokenKey,n.continuationToken??``),r.set(ModeKey,n.mode),r.set(AuthKey,i),r.set(InitiatorAuthKey,n.initiatorAuth??i),n.capabilities!==void 0&&r.set(CapabilitiesKey,n.capabilities),n.callback!==void 0&&r.set(SessionCallbackKey,n.callback),n.parent!==void 0&&r.set(ParentSessionKey,n.parent),r}export{buildRunContext};
1
+ import{AuthKey,CapabilitiesKey,ContinuationTokenKey,InitiatorAuthKey,ModeKey,ParentSessionKey,SessionCallbackKey}from"#context/keys.js";import{ContextContainer}from"#context/container.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";function buildRunContext(e){let{bundle:t,run:n}=e,r=new ContextContainer,i=n.auth;return r.set(BundleKey,t),r.set(ChannelKey,n.adapter),r.set(ContinuationTokenKey,n.continuationToken??``),r.set(ModeKey,n.mode),r.set(AuthKey,i),r.set(InitiatorAuthKey,n.initiatorAuth??i),n.capabilities!==void 0&&r.set(CapabilitiesKey,n.capabilities),n.callback!==void 0&&r.set(SessionCallbackKey,n.callback),n.parent!==void 0&&r.set(ParentSessionKey,n.parent),r}export{buildRunContext};
@@ -1 +1 @@
1
- import{dirname,join}from"node:path";import{access,mkdir,readFile,writeFile}from"node:fs/promises";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{bufferToStream,streamToBuffer}from"#execution/sandbox/stream-utils.js";var LOCAL_SANDBOX_SNAPSHOT_VERSION=1;function createLocalSandboxBackend(e={}){return{name:`local`,async prewarm(e){let t=resolveTemplateSnapshotPath(resolveSandboxCacheDirectory(e.runtimeContext.appRoot),e.templateKey);if(await doesPathExist(t))return;let n=await createBashSandbox({sessionKey:e.templateKey,snapshotPath:t}),r=buildSandboxSession(createLocalInternalSandboxSession(n));try{e.bootstrap!==void 0&&await e.bootstrap({use:async()=>r});for(let t of e.seedFiles)typeof t.content==`string`?await r.writeTextFile({content:t.content,path:t.path}):await r.writeBinaryFile({content:t.content,path:t.path});if(await n.captureSnapshot()===null)throw Error(`Failed to capture local sandbox template state for "${e.templateKey}".`)}finally{await n.dispose()}},async create(e){let t=resolveSandboxCacheDirectory(e.runtimeContext.appRoot),n=await readLocalSnapshot(resolveTemplateSnapshotPath(t,e.templateKey));if(n===null)throw new SandboxTemplateNotProvisionedError({backendName:`local`,templateKey:e.templateKey});let r=getLocalSnapshotPath(e.existingMetadata)??resolveSessionSnapshotPath(t,e.sessionKey);return await doesPathExist(r)||await writeLocalSnapshot(r,n),createHandle(await createBashSandbox({sessionKey:e.sessionKey,snapshotPath:r}))}}}async function createBashSandbox(t){let{Bash:n,InMemoryFs:r}=await import(`#compiled/just-bash/index.js`),i=await readLocalSnapshot(t.snapshotPath),a=new r(createInitialFiles(i));await ensureLocalSandboxDirectories(a),await restoreLocalSandboxDirectories(a,i?.entries??[]);let o=new n({cwd:WORKSPACE_ROOT,env:i?.env,fs:a,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureSnapshot(){let e=await captureLocalSnapshot({filesystem:a,sandbox:o});return await writeLocalSnapshot(t.snapshotPath,e),{snapshotPath:t.snapshotPath}},async dispose(){await o.dispose?.()},async executeCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=e.workingDirectory===void 0?e.command:`( cd ${shellQuote(e.workingDirectory)} && ${e.command} )`,n=o.exec(t),r=e.abortSignal?await raceAbort(n,e.abortSignal):await n;return{exitCode:r.exitCode,stderr:r.stderr,stdout:r.stdout}},async readFileBytes(e){let t;try{t=await a.readFileBuffer(e)}catch{return null}return Buffer.from(t)},async readFileText(e){let t;try{t=await a.readFileBuffer(e)}catch{return null}return new TextDecoder(`utf-8`,{fatal:!0}).decode(t)},sessionKey:t.sessionKey,snapshotPath:t.snapshotPath,async writeFiles(t){for(let n of t){let t=dirname(n.path);await a.mkdir(t,{recursive:!0}),await a.writeFile(n.path,n.content)}}}}function createHandle(e){let t=buildSandboxSession(createLocalInternalSandboxSession(e));return{session:t,useSessionFn:async()=>t,async captureState(){return{backendName:`local`,metadata:await e.captureSnapshot()??{},sessionKey:e.sessionKey}},async dispose(){await e.dispose()}}}function createLocalInternalSandboxSession(e){return{id:e.sessionKey,resolvePath:resolveLocalPath,async runCommand(t){return await e.executeCommand(t)},async readFile(t){let n=await e.readFileBytes(t.path);return n===null?null:bufferToStream(n)},async writeFile(t){let n=await streamToBuffer(t.content);await e.writeFiles([{content:n,path:t.path}])}}}async function raceAbort(e,t){return await new Promise((n,r)=>{let onAbort=()=>{r(new DOMException(`The operation was aborted.`,`AbortError`))};if(t.aborted){onAbort();return}t.addEventListener(`abort`,onAbort,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,onAbort),n(e)},e=>{t.removeEventListener(`abort`,onAbort),r(e)})})}function resolveLocalPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}function resolveTemplateSnapshotPath(e,n){return join(e,`local`,`templates`,`${n}.json`)}function resolveSessionSnapshotPath(e,n){return join(e,`local`,`sessions`,`${n}.json`)}function createInitialFiles(e){let t={};for(let n of e?.entries??[])n.kind===`file`&&(t[n.path]=Buffer.from(n.contentBase64,`base64`));return t}async function ensureLocalSandboxDirectories(e){await e.mkdir(WORKSPACE_ROOT,{recursive:!0})}async function restoreLocalSandboxDirectories(e,t){let n=t.filter(e=>e.kind===`directory`).map(e=>e.path).sort((e,t)=>e.localeCompare(t));for(let t of n)t!==WORKSPACE_ROOT&&await e.mkdir(t,{recursive:!0})}async function captureLocalSnapshot(e){let t=[],n=e.filesystem.getAllPaths().sort((e,t)=>e.localeCompare(t));for(let r of n){let n=await e.filesystem.stat(r);if(n.isSymbolicLink)continue;if(n.isDirectory){t.push({kind:`directory`,path:r});continue}if(!n.isFile)continue;let i=await e.filesystem.readFileBuffer(r);t.push({contentBase64:Buffer.from(i).toString(`base64`),kind:`file`,path:r})}return{entries:t,env:{...e.sandbox.getEnv()},version:LOCAL_SANDBOX_SNAPSHOT_VERSION}}async function readLocalSnapshot(e){if(!await doesPathExist(e))return null;let t=JSON.parse(await readFile(e,`utf8`));return t.version===LOCAL_SANDBOX_SNAPSHOT_VERSION?t:null}async function writeLocalSnapshot(t,n){await mkdir(dirname(t),{recursive:!0}),await writeFile(t,`${JSON.stringify(n,null,2)}\n`)}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}function getLocalSnapshotPath(e){let t=e?.snapshotPath;return typeof t==`string`?t:void 0}export{createLocalSandboxBackend};
1
+ import{dirname,join}from"node:path";import{access,mkdir,readFile,writeFile}from"node:fs/promises";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{bufferToStream,streamToBuffer}from"#execution/sandbox/stream-utils.js";function createLocalSandboxBackend(e={}){return{name:`local`,async prewarm(e){let t=resolveTemplateSnapshotPath(resolveSandboxCacheDirectory(e.runtimeContext.appRoot),e.templateKey);if(await doesPathExist(t))return;let n=await createBashSandbox({sessionKey:e.templateKey,snapshotPath:t}),r=buildSandboxSession(createLocalInternalSandboxSession(n));try{e.bootstrap!==void 0&&await e.bootstrap({use:async()=>r});for(let t of e.seedFiles)typeof t.content==`string`?await r.writeTextFile({content:t.content,path:t.path}):await r.writeBinaryFile({content:t.content,path:t.path});if(await n.captureSnapshot()===null)throw Error(`Failed to capture local sandbox template state for "${e.templateKey}".`)}finally{await n.dispose()}},async create(e){let t=resolveSandboxCacheDirectory(e.runtimeContext.appRoot),n=await readLocalSnapshot(resolveTemplateSnapshotPath(t,e.templateKey));if(n===null)throw new SandboxTemplateNotProvisionedError({backendName:`local`,templateKey:e.templateKey});let r=getLocalSnapshotPath(e.existingMetadata)??resolveSessionSnapshotPath(t,e.sessionKey);return await doesPathExist(r)||await writeLocalSnapshot(r,n),createHandle(await createBashSandbox({sessionKey:e.sessionKey,snapshotPath:r}))}}}async function createBashSandbox(t){let{Bash:n,InMemoryFs:r}=await import(`#compiled/just-bash/index.js`),i=await readLocalSnapshot(t.snapshotPath),a=new r(createInitialFiles(i));await ensureLocalSandboxDirectories(a),await restoreLocalSandboxDirectories(a,i?.entries??[]);let o=new n({cwd:WORKSPACE_ROOT,env:i?.env,fs:a,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureSnapshot(){let e=await captureLocalSnapshot({filesystem:a,sandbox:o});return await writeLocalSnapshot(t.snapshotPath,e),{snapshotPath:t.snapshotPath}},async dispose(){await o.dispose?.()},async executeCommand(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=e.workingDirectory===void 0?e.command:`( cd ${shellQuote(e.workingDirectory)} && ${e.command} )`,n=o.exec(t),r=e.abortSignal?await raceAbort(n,e.abortSignal):await n;return{exitCode:r.exitCode,stderr:r.stderr,stdout:r.stdout}},async readFileBytes(e){let t;try{t=await a.readFileBuffer(e)}catch{return null}return Buffer.from(t)},async readFileText(e){let t;try{t=await a.readFileBuffer(e)}catch{return null}return new TextDecoder(`utf-8`,{fatal:!0}).decode(t)},sessionKey:t.sessionKey,snapshotPath:t.snapshotPath,async writeFiles(t){for(let n of t){let t=dirname(n.path);await a.mkdir(t,{recursive:!0}),await a.writeFile(n.path,n.content)}}}}function createHandle(e){let t=buildSandboxSession(createLocalInternalSandboxSession(e));return{session:t,useSessionFn:async()=>t,async captureState(){return{backendName:`local`,metadata:await e.captureSnapshot()??{},sessionKey:e.sessionKey}},async dispose(){await e.dispose()}}}function createLocalInternalSandboxSession(e){return{id:e.sessionKey,resolvePath:resolveLocalPath,async runCommand(t){return await e.executeCommand(t)},async readFile(t){let n=await e.readFileBytes(t.path);return n===null?null:bufferToStream(n)},async writeFile(t){let n=await streamToBuffer(t.content);await e.writeFiles([{content:n,path:t.path}])}}}async function raceAbort(e,t){return await new Promise((n,r)=>{let onAbort=()=>{r(new DOMException(`The operation was aborted.`,`AbortError`))};if(t.aborted){onAbort();return}t.addEventListener(`abort`,onAbort,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,onAbort),n(e)},e=>{t.removeEventListener(`abort`,onAbort),r(e)})})}function resolveLocalPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}function resolveTemplateSnapshotPath(e,n){return join(e,`local`,`templates`,`${n}.json`)}function resolveSessionSnapshotPath(e,n){return join(e,`local`,`sessions`,`${n}.json`)}function createInitialFiles(e){let t={};for(let n of e?.entries??[])n.kind===`file`&&(t[n.path]=Buffer.from(n.contentBase64,`base64`));return t}async function ensureLocalSandboxDirectories(e){await e.mkdir(WORKSPACE_ROOT,{recursive:!0})}async function restoreLocalSandboxDirectories(e,t){let n=t.filter(e=>e.kind===`directory`).map(e=>e.path).sort((e,t)=>e.localeCompare(t));for(let t of n)t!==WORKSPACE_ROOT&&await e.mkdir(t,{recursive:!0})}async function captureLocalSnapshot(e){let t=[],n=e.filesystem.getAllPaths().sort((e,t)=>e.localeCompare(t));for(let r of n){let n=await e.filesystem.stat(r);if(n.isSymbolicLink)continue;if(n.isDirectory){t.push({kind:`directory`,path:r});continue}if(!n.isFile)continue;let i=await e.filesystem.readFileBuffer(r);t.push({contentBase64:Buffer.from(i).toString(`base64`),kind:`file`,path:r})}return{entries:t,env:{...e.sandbox.getEnv()},version:1}}async function readLocalSnapshot(e){if(!await doesPathExist(e))return null;let t=JSON.parse(await readFile(e,`utf8`));return t.version===1?t:null}async function writeLocalSnapshot(t,n){await mkdir(dirname(t),{recursive:!0}),await writeFile(t,`${JSON.stringify(n,null,2)}\n`)}async function doesPathExist(e){try{return await access(e),!0}catch{return!1}}function getLocalSnapshotPath(e){let t=e?.snapshotPath;return typeof t==`string`?t:void 0}export{createLocalSandboxBackend};
@@ -1 +1 @@
1
- import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";function createVercelSandboxBackend(t={}){let n=t.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),r={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...t.createOptions},i=new Map;return{name:`vercel`,async create(t){let a=resolveVercelSandboxTags(r.tags,t.tags),o;try{o=await readTemplate({loadSandboxModule:n,prewarmedTemplates:i,templateKey:t.templateKey})}catch(n){throw SandboxTemplateNotProvisionedError.is(n)?n:Error(`Failed to read sandbox template "${t.templateKey}": ${errorMessage(n)}`,{cause:n})}let s;try{s=await ensureSession({createOptions:r,existingMetadata:t.existingMetadata,sandboxModule:await n(),sessionKey:t.sessionKey,snapshotId:o.snapshotId,tags:a})}catch(e){throw Error(`Failed to create sandbox session "${t.sessionKey}": ${errorMessage(e)}`,{cause:e})}return createHandle(s,t.sessionKey)},async prewarm(e){let t;try{t=await ensureTemplate({bootstrap:e.bootstrap,createOptions:r,loadSandboxModule:n,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${errorMessage(t)}. Run \`vercel login\` and \`vercel link\` so the SDK can authenticate, or set VERCEL_TOKEN.`,{cause:t})}i.set(e.templateKey,t)}}}async function readTemplate(t){let n=t.prewarmedTemplates.get(t.templateKey);if(n!==void 0)return n;let r=await getNamedSandbox(await t.loadSandboxModule(),t.templateKey);if(r===null||typeof r.currentSnapshotId!=`string`)throw new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:t.templateKey});return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:t.templateKey}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),r=await getNamedSandbox(t,e.templateKey),i=resolveVercelSandboxTags(e.createOptions.tags,e.tags);if(r===null){let n={...e.createOptions,name:e.templateKey,persistent:!1};i!==void 0&&(n.tags=i),r=await t.Sandbox.create(n)}else await ensureVercelSandboxTags(r,i);let a=extractAuthorSnapshotId(e.createOptions);if(typeof r.currentSnapshotId==`string`&&r.currentSnapshotId.length>0&&r.currentSnapshotId!==a)return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:e.templateKey};await ensureSandboxWorkingDirectory(r,e.createOptions);let o=buildSandboxSession(createVercelInternalSandboxSession(r,e.templateKey));e.bootstrap!==void 0&&await e.bootstrap({use:async e=>(e!==void 0&&await r.update(e),o)});for(let t of e.seedFiles)typeof t.content==`string`?await o.writeTextFile({content:t.content,path:t.path}):await o.writeBinaryFile({content:t.content,path:t.path});let s=await r.snapshot();return{sandboxName:r.name,snapshotId:s.snapshotId,templateKey:e.templateKey}}async function ensureSession(e){let t=getVercelSandboxName(e.existingMetadata)??e.sessionKey,n=await getNamedSandbox(e.sandboxModule,t);if(n!==null)return await ensureVercelSandboxTags(n,e.tags),n;let{runtime:r,source:i,...a}=e.createOptions,o={...a,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}};return e.tags!==void 0&&(o.tags=e.tags),await e.sandboxModule.Sandbox.create(o)}function createHandle(e,t){return{session:buildSandboxSession(createVercelInternalSandboxSession(e,t)),useSessionFn:async r=>(r!==void 0&&await e.update(r),buildSandboxSession(createVercelInternalSandboxSession(e,t))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function createVercelInternalSandboxSession(e,n){return{id:n,resolvePath:resolveVercelSandboxPath,async runCommand(n){let r=await e.runCommand({args:[`-lc`,n.command],cmd:`bash`,cwd:n.workingDirectory??WORKSPACE_ROOT,signal:n.abortSignal}),[i,a]=await Promise.all([r.stdout(),r.stderr()]);return{exitCode:r.exitCode,stderr:a,stdout:i}},async readFile(t){return await e.readFile({path:t.path})??null},async writeFile(t){let n=await streamToBuffer(t.content);await e.writeFiles([{content:n,path:t.path}])}}}function resolveVercelSandboxPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}async function ensureSandboxWorkingDirectory(e,n){await runSandboxBootstrapStep(e,{failureMessage:`Failed to initialize Vercel sandbox workspace.`,script:`mkdir -p ${WORKSPACE_ROOT} && chown ${SANDBOX_USER}:${SANDBOX_USER} ${WORKSPACE_ROOT}`}),n.networkPolicy!==`deny-all`&&await runSandboxBootstrapStep(e,{failureMessage:`Failed to install ripgrep in Vercel sandbox.`,script:`command -v rg >/dev/null 2>&1 || { dnf install -y spal-release && dnf install -y ripgrep; }`})}async function runSandboxBootstrapStep(e,t){let n=await e.runCommand({args:[`-lc`,t.script],cmd:`bash`,sudo:!0});if(n.exitCode!==0){let e=await n.stderr();throw Error(`${t.failureMessage} ${e}`.trim())}}var SANDBOX_USER=`vercel-sandbox`;async function getNamedSandbox(e,t){try{return await e.Sandbox.get({name:t})}catch(e){if(isSandboxMissingError(e))return null;throw Error(`Failed to look up Vercel sandbox "${t}": ${errorMessage(e)}`,{cause:e})}}function isSandboxMissingError(e){return e instanceof Error?(e.response?.status??e.cause?.response?.status)===404:!1}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function getVercelSandboxName(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function resolveVercelSandboxTags(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>VERCEL_SANDBOX_TAG_LIMIT)throw Error(`Vercel Sandbox supports at most ${VERCEL_SANDBOX_TAG_LIMIT} tags. Ash reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercelBackend().`);return n}}async function ensureVercelSandboxTags(e,t){t===void 0||areVercelSandboxTagsEqual(e.tags,t)||await e.update({tags:t})}function areVercelSandboxTagsEqual(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length?i.every(([e,t])=>n[e]===t):!1}function errorMessage(e){return e instanceof Error?e.message:String(e)}var DEFAULT_SANDBOX_TIMEOUT_MS=1800*1e3,VERCEL_SANDBOX_TAG_LIMIT=5;export{createVercelSandboxBackend};
1
+ import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";function createVercelSandboxBackend(t={}){let n=t.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),r={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...t.createOptions},i=new Map;return{name:`vercel`,async create(t){let a=resolveVercelSandboxTags(r.tags,t.tags),o;try{o=await readTemplate({loadSandboxModule:n,prewarmedTemplates:i,templateKey:t.templateKey})}catch(n){throw SandboxTemplateNotProvisionedError.is(n)?n:Error(`Failed to read sandbox template "${t.templateKey}": ${errorMessage(n)}`,{cause:n})}let s;try{s=await ensureSession({createOptions:r,existingMetadata:t.existingMetadata,sandboxModule:await n(),sessionKey:t.sessionKey,snapshotId:o.snapshotId,tags:a})}catch(e){throw Error(`Failed to create sandbox session "${t.sessionKey}": ${errorMessage(e)}`,{cause:e})}return createHandle(s,t.sessionKey)},async prewarm(e){let t;try{t=await ensureTemplate({bootstrap:e.bootstrap,createOptions:r,loadSandboxModule:n,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${errorMessage(t)}. Run \`vercel login\` and \`vercel link\` so the SDK can authenticate, or set VERCEL_TOKEN.`,{cause:t})}i.set(e.templateKey,t)}}}async function readTemplate(t){let n=t.prewarmedTemplates.get(t.templateKey);if(n!==void 0)return n;let r=await getNamedSandbox(await t.loadSandboxModule(),t.templateKey);if(r===null||typeof r.currentSnapshotId!=`string`)throw new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:t.templateKey});return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:t.templateKey}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),r=await getNamedSandbox(t,e.templateKey),i=resolveVercelSandboxTags(e.createOptions.tags,e.tags);if(r===null){let n={...e.createOptions,name:e.templateKey,persistent:!1};i!==void 0&&(n.tags=i),r=await t.Sandbox.create(n)}else await ensureVercelSandboxTags(r,i);let a=extractAuthorSnapshotId(e.createOptions);if(typeof r.currentSnapshotId==`string`&&r.currentSnapshotId.length>0&&r.currentSnapshotId!==a)return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:e.templateKey};await ensureSandboxWorkingDirectory(r,e.createOptions);let o=buildSandboxSession(createVercelInternalSandboxSession(r,e.templateKey));e.bootstrap!==void 0&&await e.bootstrap({use:async e=>(e!==void 0&&await r.update(e),o)});for(let t of e.seedFiles)typeof t.content==`string`?await o.writeTextFile({content:t.content,path:t.path}):await o.writeBinaryFile({content:t.content,path:t.path});let s=await r.snapshot();return{sandboxName:r.name,snapshotId:s.snapshotId,templateKey:e.templateKey}}async function ensureSession(e){let t=getVercelSandboxName(e.existingMetadata)??e.sessionKey,n=await getNamedSandbox(e.sandboxModule,t);if(n!==null)return await ensureVercelSandboxTags(n,e.tags),n;let{runtime:r,source:i,...a}=e.createOptions,o={...a,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}};return e.tags!==void 0&&(o.tags=e.tags),await e.sandboxModule.Sandbox.create(o)}function createHandle(e,t){return{session:buildSandboxSession(createVercelInternalSandboxSession(e,t)),useSessionFn:async r=>(r!==void 0&&await e.update(r),buildSandboxSession(createVercelInternalSandboxSession(e,t))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async dispose(){}}}function createVercelInternalSandboxSession(e,n){return{id:n,resolvePath:resolveVercelSandboxPath,async runCommand(n){let r=await e.runCommand({args:[`-lc`,n.command],cmd:`bash`,cwd:n.workingDirectory??WORKSPACE_ROOT,signal:n.abortSignal}),[i,a]=await Promise.all([r.stdout(),r.stderr()]);return{exitCode:r.exitCode,stderr:a,stdout:i}},async readFile(t){return await e.readFile({path:t.path})??null},async writeFile(t){let n=await streamToBuffer(t.content);await e.writeFiles([{content:n,path:t.path}])}}}function resolveVercelSandboxPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}async function ensureSandboxWorkingDirectory(e,n){await runSandboxBootstrapStep(e,{failureMessage:`Failed to initialize Vercel sandbox workspace.`,script:`mkdir -p ${WORKSPACE_ROOT} && chown ${SANDBOX_USER}:${SANDBOX_USER} ${WORKSPACE_ROOT}`}),n.networkPolicy!==`deny-all`&&await runSandboxBootstrapStep(e,{failureMessage:`Failed to install ripgrep in Vercel sandbox.`,script:`command -v rg >/dev/null 2>&1 || { dnf install -y spal-release && dnf install -y ripgrep; }`})}async function runSandboxBootstrapStep(e,t){let n=await e.runCommand({args:[`-lc`,t.script],cmd:`bash`,sudo:!0});if(n.exitCode!==0){let e=await n.stderr();throw Error(`${t.failureMessage} ${e}`.trim())}}const SANDBOX_USER=`vercel-sandbox`;async function getNamedSandbox(e,t){try{return await e.Sandbox.get({name:t})}catch(e){if(isSandboxMissingError(e))return null;throw Error(`Failed to look up Vercel sandbox "${t}": ${errorMessage(e)}`,{cause:e})}}function isSandboxMissingError(e){return e instanceof Error?(e.response?.status??e.cause?.response?.status)===404:!1}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function getVercelSandboxName(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function resolveVercelSandboxTags(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>VERCEL_SANDBOX_TAG_LIMIT)throw Error(`Vercel Sandbox supports at most ${VERCEL_SANDBOX_TAG_LIMIT} tags. Ash reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercelBackend().`);return n}}async function ensureVercelSandboxTags(e,t){t===void 0||areVercelSandboxTagsEqual(e.tags,t)||await e.update({tags:t})}function areVercelSandboxTagsEqual(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length?i.every(([e,t])=>n[e]===t):!1}function errorMessage(e){return e instanceof Error?e.message:String(e)}const DEFAULT_SANDBOX_TIMEOUT_MS=1800*1e3,VERCEL_SANDBOX_TAG_LIMIT=5;export{createVercelSandboxBackend};
@@ -1,3 +1,3 @@
1
- import{requireSandboxSession,validateAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{MAX_OUTPUT_BYTES}from"#execution/sandbox/truncate-output.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{normalizeModelPath}from"#runtime/framework-tools/file-state.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";var DEFAULT_GLOB_LIMIT=100,MAX_GLOB_LIMIT=1e3,DEFAULT_PATH=`/workspace`;async function executeGlobOnSandbox(r){let a=r.path??DEFAULT_PATH;validateAbsoluteFilePath(a);let o=normalizeModelPath(a),s=Math.min(Math.max(1,r.limit??DEFAULT_GLOB_LIMIT),MAX_GLOB_LIMIT),c=await requireSandboxSession(),l=await ripgrepIsAvailable(c)?buildRipgrepCommand({normalizedPath:o,pattern:r.pattern}):buildPosixFindCommand({normalizedPath:o,pattern:r.pattern}),u=await c.runCommand({command:l});if(u.exitCode!==0&&u.exitCode!==1)throw buildGlobExecutionError(l,u.exitCode,u.stderr);let d=u.stdout.split(`
1
+ import{requireSandboxSession,validateAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{MAX_OUTPUT_BYTES}from"#execution/sandbox/truncate-output.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{normalizeModelPath}from"#runtime/framework-tools/file-state.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGlobOnSandbox(r){let a=r.path??`/workspace`;validateAbsoluteFilePath(a);let o=normalizeModelPath(a),s=Math.min(Math.max(1,r.limit??100),1e3),c=await requireSandboxSession(),l=await ripgrepIsAvailable(c)?buildRipgrepCommand({normalizedPath:o,pattern:r.pattern}):buildPosixFindCommand({normalizedPath:o,pattern:r.pattern}),u=await c.runCommand({command:l});if(u.exitCode!==0&&u.exitCode!==1)throw buildGlobExecutionError(l,u.exitCode,u.stderr);let d=u.stdout.split(`
2
2
  `).filter(e=>e.length>0),f=d.length>s,p=f?d.slice(0,s):d,m=[],h=0,g=!1;for(let e of p){let t=normalizeModelPath(e),r=Buffer.byteLength(t,`utf8`)+1;if(h+r>MAX_OUTPUT_BYTES&&m.length>0){g=!0;break}m.push(t),h+=r}if(m.length===0)return{content:`No files found`,count:0,path:o,truncated:!1};let _=f||g,v=[...m];return _&&(v.push(``),v.push(`(Results truncated: showing first ${m.length} results out of more. Use a more specific path or pattern to narrow results.)`)),{content:v.join(`
3
3
  `),count:m.length,path:o,truncated:_}}function buildRipgrepCommand(e){return[`rg --files --hidden`,`--glob '!.git/*'`,`--glob ${shellQuote(e.pattern)}`,`-- ${shellQuote(e.normalizedPath)}`].join(` `)}function buildPosixFindCommand(e){let t=translateGlobToFindPattern(e.pattern),n=t.includes(`/`)?`-path ${shellQuote(`*/${t}`)}`:`-name ${shellQuote(t)}`;return[`find ${shellQuote(e.normalizedPath)}`,`-type f`,`-not -path '*/.git/*'`,n].join(` `)}function translateGlobToFindPattern(e){let t=e.replaceAll(`**`,`*`);for(;t.startsWith(`*/`);)t=t.slice(2);return t}function buildGlobExecutionError(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`glob failed (exit ${t}): ${i}\nCommand: ${e}`)}export{executeGlobOnSandbox};
@@ -1,3 +1,3 @@
1
- import{requireSandboxSession,validateAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{MAX_OUTPUT_BYTES,capLineLength}from"#execution/sandbox/truncate-output.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{normalizeModelPath}from"#runtime/framework-tools/file-state.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";var DEFAULT_GREP_LIMIT=100,MAX_GREP_LIMIT=1e3,DEFAULT_PATH=`/workspace`;async function executeGrepOnSandbox(n){let r=n.path??DEFAULT_PATH;validateAbsoluteFilePath(r);let i=normalizeModelPath(r),u=Math.min(Math.max(1,n.limit??DEFAULT_GREP_LIMIT),MAX_GREP_LIMIT),d=n.context!==void 0&&n.context>0?n.context:0,f=await requireSandboxSession(),p=await ripgrepIsAvailable(f)?buildRipgrepCommand({contextLines:d,effectiveLimit:u,glob:n.glob,ignoreCase:n.ignoreCase??!1,literal:n.literal??!1,normalizedPath:i,pattern:n.pattern}):buildPosixGrepCommand({contextLines:d,effectiveLimit:u,glob:n.glob,ignoreCase:n.ignoreCase??!1,literal:n.literal??!1,normalizedPath:i,pattern:n.pattern}),m=await f.runCommand({command:p});if(m.exitCode!==0&&m.exitCode!==1)throw buildGrepExecutionError(p,m.exitCode,m.stderr);let h=m.stdout;return h.trim().length===0?{content:`No matches found`,matchCount:0,path:i,truncated:!1}:processOutput({effectiveLimit:u,normalizedPath:i,stdout:h})}function buildRipgrepCommand(e){let t=[`rg`,`--line-number`,`--color=never`,`--hidden`,`--glob '!.git/*'`];return e.ignoreCase&&t.push(`--ignore-case`),e.literal&&t.push(`--fixed-strings`),e.glob!==void 0&&t.push(`--glob ${shellQuote(e.glob)}`),e.contextLines>0&&t.push(`--context ${e.contextLines}`),t.push(`--max-count ${e.effectiveLimit}`),t.push(`--`),t.push(shellQuote(e.pattern)),t.push(shellQuote(e.normalizedPath)),t.join(` `)}function buildPosixGrepCommand(e){let t=[`grep`,`-r`,`-n`,`--color=never`,`--exclude-dir=.git`];return e.ignoreCase&&t.push(`-i`),e.literal?t.push(`-F`):t.push(`-E`),e.glob!==void 0&&t.push(`--include=${shellQuote(e.glob)}`),e.contextLines>0&&t.push(`-C ${e.contextLines}`),t.push(`-m ${e.effectiveLimit}`),t.push(`--`),t.push(shellQuote(e.pattern)),t.push(shellQuote(e.normalizedPath)),t.join(` `)}function processOutput(e){let t=e.stdout.split(`
1
+ import{requireSandboxSession,validateAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{MAX_OUTPUT_BYTES,capLineLength}from"#execution/sandbox/truncate-output.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{normalizeModelPath}from"#runtime/framework-tools/file-state.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGrepOnSandbox(n){let r=n.path??`/workspace`;validateAbsoluteFilePath(r);let i=normalizeModelPath(r),s=Math.min(Math.max(1,n.limit??100),1e3),c=n.context!==void 0&&n.context>0?n.context:0,l=await requireSandboxSession(),u=await ripgrepIsAvailable(l)?buildRipgrepCommand({contextLines:c,effectiveLimit:s,glob:n.glob,ignoreCase:n.ignoreCase??!1,literal:n.literal??!1,normalizedPath:i,pattern:n.pattern}):buildPosixGrepCommand({contextLines:c,effectiveLimit:s,glob:n.glob,ignoreCase:n.ignoreCase??!1,literal:n.literal??!1,normalizedPath:i,pattern:n.pattern}),d=await l.runCommand({command:u});if(d.exitCode!==0&&d.exitCode!==1)throw buildGrepExecutionError(u,d.exitCode,d.stderr);let f=d.stdout;return f.trim().length===0?{content:`No matches found`,matchCount:0,path:i,truncated:!1}:processOutput({effectiveLimit:s,normalizedPath:i,stdout:f})}function buildRipgrepCommand(e){let t=[`rg`,`--line-number`,`--color=never`,`--hidden`,`--glob '!.git/*'`];return e.ignoreCase&&t.push(`--ignore-case`),e.literal&&t.push(`--fixed-strings`),e.glob!==void 0&&t.push(`--glob ${shellQuote(e.glob)}`),e.contextLines>0&&t.push(`--context ${e.contextLines}`),t.push(`--max-count ${e.effectiveLimit}`),t.push(`--`),t.push(shellQuote(e.pattern)),t.push(shellQuote(e.normalizedPath)),t.join(` `)}function buildPosixGrepCommand(e){let t=[`grep`,`-r`,`-n`,`--color=never`,`--exclude-dir=.git`];return e.ignoreCase&&t.push(`-i`),e.literal?t.push(`-F`):t.push(`-E`),e.glob!==void 0&&t.push(`--include=${shellQuote(e.glob)}`),e.contextLines>0&&t.push(`-C ${e.contextLines}`),t.push(`-m ${e.effectiveLimit}`),t.push(`--`),t.push(shellQuote(e.pattern)),t.push(shellQuote(e.normalizedPath)),t.join(` `)}function processOutput(e){let t=e.stdout.split(`
2
2
  `),i=[],a=0,o=0,s=!1;for(let e of t){if(e.length===0&&t.indexOf(e)===t.length-1)continue;e!==`--`&&e.length>0&&/^.+:\d+:/.test(e)&&o++;let c=capLineLength(e),l=Buffer.byteLength(c,`utf8`)+1;if(a+l>MAX_OUTPUT_BYTES&&i.length>0){s=!0;break}i.push(c),a+=l}let c=s||o>=e.effectiveLimit,l=i.join(`
3
3
  `);if(c){let t=[];o>=e.effectiveLimit&&t.push(`Match limit reached (${e.effectiveLimit}). Use a larger limit or more specific pattern.`),s&&t.push(`Output truncated due to size. Use a more specific path or pattern.`),l+=`\n\n[${t.join(` `)}]`}return{content:l,matchCount:o,path:e.normalizedPath,truncated:c}}function buildGrepExecutionError(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`grep failed (exit ${t}): ${i}\nCommand: ${e}`)}export{executeGrepOnSandbox};
@@ -1,5 +1,5 @@
1
1
  import type { SandboxBackend, SandboxBackendPrewarmInput } from "#public/definitions/sandbox-backend.js";
2
- import type { RuntimeDiskCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
2
+ import { type RuntimeCompiledArtifactsSource, type RuntimeDiskCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
3
3
  import { type ResolvedAgentGraphBundle } from "#runtime/graph.js";
4
4
  /**
5
5
  * Optional dispatch override that intercepts every `backend.prewarm`
@@ -13,7 +13,8 @@ export type SandboxBackendPrewarmDispatch = (input: {
13
13
  readonly input: SandboxBackendPrewarmInput;
14
14
  }) => Promise<void>;
15
15
  interface PrewarmSandboxesInput {
16
- readonly compiledArtifactsSource: RuntimeDiskCompiledArtifactsSource;
16
+ readonly appRoot: string;
17
+ readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
17
18
  readonly graph: ResolvedAgentGraphBundle;
18
19
  readonly log?: (message: string) => void;
19
20
  readonly dispatch?: SandboxBackendPrewarmDispatch;
@@ -43,4 +44,13 @@ export declare function prewarmAppSandboxes(input: {
43
44
  readonly log?: (message: string) => void;
44
45
  readonly dispatch?: SandboxBackendPrewarmDispatch;
45
46
  }): Promise<void>;
47
+ /**
48
+ * Loads one built app's bundled compiled artifacts and prewarms the sandbox
49
+ * templates that its production Nitro runtime will request.
50
+ */
51
+ export declare function prewarmBuiltAppSandboxes(input: {
52
+ readonly appRoot: string;
53
+ readonly log?: (message: string) => void;
54
+ readonly dispatch?: SandboxBackendPrewarmDispatch;
55
+ }): Promise<void>;
46
56
  export {};