eve 0.34.0 → 0.36.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 (280) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +3 -3
  3. package/dist/src/chunks/{use-eve-agent-BNdcle_M.js → use-eve-agent-COmP-H8R.js} +6 -3
  4. package/dist/src/chunks/{use-eve-agent-FJkEMXYk.js → use-eve-agent-CnppTEFk.js} +6 -3
  5. package/dist/src/cli/commands/info.js +1 -1
  6. package/dist/src/cli/commands/trace-detail.d.ts +3 -2
  7. package/dist/src/cli/commands/trace-detail.js +1 -1
  8. package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +4 -6
  9. package/dist/src/cli/dev/tui/traces/trace-conversation.js +1 -2
  10. package/dist/src/client/agent-info-schema.d.ts +12 -4
  11. package/dist/src/client/agent-info-schema.js +1 -1
  12. package/dist/src/client/index.d.ts +1 -1
  13. package/dist/src/compiled/.vendor-stamp.json +3 -3
  14. package/dist/src/compiled/@chat-adapter/slack/index.js +1 -1
  15. package/dist/src/compiled/@workflow/core/index.js +1 -1
  16. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  17. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  18. package/dist/src/compiled/@workflow/world/env-config.d.ts +1 -0
  19. package/dist/src/compiled/@workflow/world/events.d.ts +92 -35
  20. package/dist/src/compiled/@workflow/world/index.d.ts +3 -2
  21. package/dist/src/compiled/@workflow/world/interfaces.d.ts +25 -23
  22. package/dist/src/compiled/@workflow/world/queue.d.ts +4 -0
  23. package/dist/src/compiled/@workflow/world/runs.d.ts +4 -0
  24. package/dist/src/compiled/@workflow/world/slot-identity.d.ts +53 -0
  25. package/dist/src/compiled/@workflow/world/spec-version.d.ts +36 -1
  26. package/dist/src/compiled/@workflow/world/steps.d.ts +4 -0
  27. package/dist/src/compiled/@workflow/world/ulid.d.ts +6 -0
  28. package/dist/src/compiled/@workflow/world-local/index.js +4 -4
  29. package/dist/src/compiled/@workflow/world-vercel/index.js +13 -17
  30. package/dist/src/compiled/_chunks/workflow/{attribute-changes-6OqdYdi4.js → attribute-changes-BoH7JsWp.js} +3 -3
  31. package/dist/src/compiled/_chunks/workflow/dist-DlFv0aHY.js +40 -0
  32. package/dist/src/compiled/_chunks/workflow/env-config-DxamfI7T.js +1 -0
  33. package/dist/src/compiled/_chunks/workflow/frames-CTpeJYEQ.js +3 -0
  34. package/dist/src/compiled/_chunks/workflow/{functions-CXb61C6h.js → functions-CeeNvKsq.js} +1 -1
  35. package/dist/src/compiled/_chunks/workflow/resume-hook-BPQHjeY5.js +1 -0
  36. package/dist/src/compiled/_chunks/workflow/run-DQ5dOyjm.js +1 -0
  37. package/dist/src/compiled/_chunks/workflow/run-id-BdE0MZz9.js +1 -0
  38. package/dist/src/compiled/_chunks/workflow/sleep-CzdoBiqy.js +1 -0
  39. package/dist/src/compiled/_chunks/workflow/spec-version-DBUVfF_R.js +1 -0
  40. package/dist/src/compiled/_chunks/workflow/undici-CUIybhQ2.js +95 -0
  41. package/dist/src/compiled/_chunks/workflow/wait-until-DK2lnH6U.js +15 -0
  42. package/dist/src/compiled/_chunks/workflow/{wrapper-CDq65xJV.js → wrapper-CMGju7QA.js} +1 -1
  43. package/dist/src/compiled/_chunks/workflow/ws-transport-Csi6Cydc.js +1 -0
  44. package/dist/src/compiler/extension-compatibility.d.ts +10 -10
  45. package/dist/src/compiler/extension-compatibility.js +1 -1
  46. package/dist/src/compiler/manifest.d.ts +8 -8
  47. package/dist/src/compiler/manifest.js +1 -1
  48. package/dist/src/compiler/normalize-extension.d.ts +3 -3
  49. package/dist/src/compiler/normalize-extension.js +1 -1
  50. package/dist/src/compiler/normalize-instructions.d.ts +1 -1
  51. package/dist/src/compiler/normalize-instructions.js +1 -1
  52. package/dist/src/compiler/normalize-manifest.js +1 -3
  53. package/dist/src/context/dynamic-instruction-lifecycle.d.ts +5 -1
  54. package/dist/src/context/dynamic-instruction-lifecycle.js +1 -1
  55. package/dist/src/context/keys.d.ts +6 -2
  56. package/dist/src/context/keys.js +1 -1
  57. package/dist/src/discover/manifest.d.ts +1 -1
  58. package/dist/src/discover/manifest.js +1 -1
  59. package/dist/src/evals/context.js +1 -1
  60. package/dist/src/evals/index.d.ts +2 -2
  61. package/dist/src/evals/reporters/index.d.ts +1 -1
  62. package/dist/src/evals/runner/artifacts.js +1 -1
  63. package/dist/src/evals/runner/execute-eval.d.ts +5 -0
  64. package/dist/src/evals/runner/execute-eval.js +1 -1
  65. package/dist/src/evals/runner/execute-task.d.ts +3 -0
  66. package/dist/src/evals/runner/execute-task.js +1 -1
  67. package/dist/src/evals/runner/reporters/braintrust.js +1 -1
  68. package/dist/src/evals/runner/reporters/types.d.ts +28 -2
  69. package/dist/src/evals/runner/run-evals.js +1 -1
  70. package/dist/src/evals/session.d.ts +12 -2
  71. package/dist/src/evals/session.js +1 -1
  72. package/dist/src/evals/target.js +1 -1
  73. package/dist/src/evals/types.d.ts +12 -1
  74. package/dist/src/execution/node-step.js +1 -1
  75. package/dist/src/execution/session.js +1 -1
  76. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  77. package/dist/src/execution/workflow-steps.js +1 -1
  78. package/dist/src/execution/workflow-trace-context.d.ts +11 -0
  79. package/dist/src/execution/workflow-trace-context.js +1 -0
  80. package/dist/src/harness/ai-sdk-hook-bridge.d.ts +1 -1
  81. package/dist/src/harness/ai-sdk-hook-bridge.js +1 -1
  82. package/dist/src/harness/approval-delivery-coordinator.js +1 -1
  83. package/dist/src/harness/channel-delivery-instrumentation.d.ts +1 -1
  84. package/dist/src/harness/channel-delivery-instrumentation.js +1 -1
  85. package/dist/src/harness/emission.d.ts +2 -2
  86. package/dist/src/harness/emission.js +1 -1
  87. package/dist/src/harness/instrumentation/config.js +1 -0
  88. package/dist/src/harness/{instrumentation-content.d.ts → instrumentation/content.d.ts} +1 -1
  89. package/dist/src/harness/{instrumentation-dispatch.d.ts → instrumentation/dispatch.d.ts} +1 -1
  90. package/dist/src/harness/{instrumentation-dispatch.js → instrumentation/dispatch.js} +1 -1
  91. package/dist/src/harness/{instrumentation-lifecycle.d.ts → instrumentation/lifecycle.d.ts} +3 -6
  92. package/dist/src/harness/{instrumentation-lifecycle.js → instrumentation/lifecycle.js} +1 -1
  93. package/dist/src/harness/{instrumentation-native-events.d.ts → instrumentation/native-events.d.ts} +1 -1
  94. package/dist/src/harness/{instrumentation-native-events.js → instrumentation/native-events.js} +1 -1
  95. package/dist/src/harness/{instrumentation-providers.d.ts → instrumentation/providers.d.ts} +1 -1
  96. package/dist/src/harness/{instrumentation-providers.js → instrumentation/providers.js} +1 -1
  97. package/dist/src/harness/{instrumentation-runtime.d.ts → instrumentation/runtime.d.ts} +4 -2
  98. package/dist/src/harness/{instrumentation-state.d.ts → instrumentation/state.d.ts} +1 -1
  99. package/dist/src/harness/parent-lineage.d.ts +1 -1
  100. package/dist/src/harness/prepare-trace-context.d.ts +16 -0
  101. package/dist/src/harness/prepare-trace-context.js +1 -0
  102. package/dist/src/harness/tool-loop.js +2 -2
  103. package/dist/src/harness/types.d.ts +1 -1
  104. package/dist/src/internal/application/compiled-artifacts.js +2 -2
  105. package/dist/src/internal/application/package.js +1 -1
  106. package/dist/src/internal/authored-definition/core.d.ts +3 -3
  107. package/dist/src/internal/authored-definition/core.js +1 -1
  108. package/dist/src/internal/authored-package-boundary.js +1 -1
  109. package/dist/src/internal/helpers/markdown.js +1 -1
  110. package/dist/src/internal/instrumentation.d.ts +1 -1
  111. package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
  112. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
  113. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +4 -3
  114. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  115. package/dist/src/internal/nitro/routes/channel-request-instrumentation.js +1 -1
  116. package/dist/src/internal/vercel/project-link.d.ts +1 -1
  117. package/dist/src/internal/vercel/project-link.js +1 -1
  118. package/dist/src/internal/vercel-agent-summary.d.ts +10 -9
  119. package/dist/src/internal/vercel-agent-summary.js +1 -1
  120. package/dist/src/internal/workflow/development-world-client.js +1 -1
  121. package/dist/src/protocol/message.d.ts +15 -1
  122. package/dist/src/protocol/message.js +1 -1
  123. package/dist/src/public/channels/github/auth.d.ts +30 -0
  124. package/dist/src/public/channels/github/auth.js +2 -2
  125. package/dist/src/public/channels/github/defaults.d.ts +4 -4
  126. package/dist/src/public/channels/github/defaults.js +1 -1
  127. package/dist/src/public/channels/github/dispatch.d.ts +3 -2
  128. package/dist/src/public/channels/github/dispatch.js +1 -1
  129. package/dist/src/public/channels/github/githubChannel.d.ts +7 -2
  130. package/dist/src/public/channels/github/githubChannel.js +1 -1
  131. package/dist/src/public/channels/github/index.d.ts +1 -1
  132. package/dist/src/public/definitions/instructions.d.ts +14 -4
  133. package/dist/src/public/definitions/instructions.js +1 -1
  134. package/dist/src/public/definitions/tool.d.ts +5 -8
  135. package/dist/src/public/instructions/index.d.ts +1 -2
  136. package/dist/src/public/instructions/index.js +1 -1
  137. package/dist/src/public/instrumentation/index.d.ts +4 -3
  138. package/dist/src/public/instrumentation/otel.d.ts +5 -4
  139. package/dist/src/public/instrumentation/provider.d.ts +2 -2
  140. package/dist/src/public/nuxt/module.js +1 -1
  141. package/dist/src/public/sveltekit/index.d.ts +6 -20
  142. package/dist/src/public/sveltekit/index.js +1 -1
  143. package/dist/src/public/sveltekit/routing.d.ts +0 -24
  144. package/dist/src/public/sveltekit/routing.js +1 -1
  145. package/dist/src/runtime/agent/bootstrap.d.ts +2 -0
  146. package/dist/src/runtime/agent/bootstrap.js +1 -1
  147. package/dist/src/runtime/prompt/compose.d.ts +1 -1
  148. package/dist/src/runtime/prompt/compose.js +3 -1
  149. package/dist/src/runtime/resolve-agent.js +1 -1
  150. package/dist/src/runtime/types.d.ts +4 -3
  151. package/dist/src/setup/boxes/select-model.d.ts +6 -6
  152. package/dist/src/setup/boxes/select-model.js +1 -1
  153. package/dist/src/setup/project-resolution.d.ts +3 -3
  154. package/dist/src/setup/scaffold/create/project.js +1 -1
  155. package/dist/src/setup/slack-connect-lifecycle.d.ts +0 -9
  156. package/dist/src/setup/slack-connect-lifecycle.js +1 -1
  157. package/dist/src/setup/slackbot.d.ts +2 -1
  158. package/dist/src/setup/slackbot.js +1 -1
  159. package/dist/src/shared/default-agent-model.d.ts +1 -1
  160. package/dist/src/shared/default-agent-model.js +1 -1
  161. package/dist/src/shared/dynamic-tool-definition.d.ts +3 -4
  162. package/dist/src/shared/instructions-definition.d.ts +15 -11
  163. package/dist/src/{public/nuxt → shared}/vercel-services.d.ts +18 -19
  164. package/dist/src/shared/vercel-services.js +1 -0
  165. package/dist/src/svelte/index.js +1 -1
  166. package/dist/src/svelte/use-eve-agent.js +1 -1
  167. package/dist/src/tracing/agent-action-instrumentation.d.ts +1 -1
  168. package/dist/src/tracing/agent-action-instrumentation.js +1 -1
  169. package/dist/src/tracing/agent-approval-instrumentation.d.ts +1 -1
  170. package/dist/src/tracing/agent-channel-delivery-instrumentation.d.ts +1 -1
  171. package/dist/src/tracing/agent-channel-delivery-instrumentation.js +1 -1
  172. package/dist/src/tracing/agent-otel-provider.d.ts +4 -2
  173. package/dist/src/tracing/agent-otel-provider.js +2 -2
  174. package/dist/src/tracing/agent-otel-session-context.d.ts +17 -0
  175. package/dist/src/tracing/agent-otel-session-context.js +1 -0
  176. package/dist/src/tracing/agent-otel-usage.d.ts +1 -1
  177. package/dist/src/tracing/agent-tool-instrumentation.d.ts +1 -1
  178. package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
  179. package/dist/src/tracing/agent-trace-state.d.ts +1 -1
  180. package/dist/src/tracing/install-instrumentation-runtime.d.ts +2 -2
  181. package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
  182. package/dist/src/tracing/local-instrumentation-runtime.d.ts +1 -1
  183. package/dist/src/tracing/local-instrumentation-runtime.js +1 -1
  184. package/dist/src/tracing/local-traces.d.ts +3 -3
  185. package/dist/src/tracing/local-traces.js +1 -1
  186. package/dist/src/tracing/otel-declaration.d.ts +2 -2
  187. package/dist/src/tracing/otel-declaration.js +1 -1
  188. package/dist/src/vue/index.js +1 -1
  189. package/dist/src/vue/use-eve-agent.js +1 -1
  190. package/docs/README.md +18 -20
  191. package/docs/agent-config.md +9 -6
  192. package/docs/channels/custom.mdx +1 -1
  193. package/docs/channels/eve.mdx +10 -56
  194. package/docs/channels/github.mdx +1 -1
  195. package/docs/channels/meta.json +1 -0
  196. package/docs/concepts/context-control.md +32 -56
  197. package/docs/concepts/default-harness.md +2 -2
  198. package/docs/concepts/execution-model-and-durability.mdx +4 -4
  199. package/docs/concepts/meta.json +3 -1
  200. package/docs/concepts/sessions-runs-and-streaming.md +23 -11
  201. package/docs/{guides → concepts}/state.md +3 -3
  202. package/docs/connections/mcp.mdx +6 -89
  203. package/docs/connections/meta.json +1 -0
  204. package/docs/connections/openapi.mdx +5 -69
  205. package/docs/connections/overview.mdx +29 -3
  206. package/docs/evals/meta.json +1 -0
  207. package/docs/evals/reporters.mdx +14 -4
  208. package/docs/extensions.md +1 -1
  209. package/docs/getting-started.mdx +175 -13
  210. package/docs/guides/auth-and-route-protection.md +3 -18
  211. package/docs/guides/client/messages.mdx +3 -1
  212. package/docs/guides/client/meta.json +2 -1
  213. package/docs/guides/client/output-schema.mdx +2 -2
  214. package/docs/guides/client/overview.mdx +1 -1
  215. package/docs/guides/deployment/meta.json +1 -0
  216. package/docs/guides/deployment/overview.md +1 -1
  217. package/docs/guides/deployment/self-hosting.md +3 -3
  218. package/docs/guides/deployment/vercel.mdx +1 -1
  219. package/docs/guides/dev-tui.md +3 -13
  220. package/docs/guides/dynamic-capabilities.md +64 -4
  221. package/docs/guides/frontend/meta.json +2 -1
  222. package/docs/guides/frontend/nextjs.mdx +1 -10
  223. package/docs/guides/frontend/nuxt.mdx +1 -10
  224. package/docs/guides/frontend/overview.mdx +12 -3
  225. package/docs/guides/frontend/sveltekit.mdx +23 -11
  226. package/docs/guides/frontend/use-eve-agent-svelte.mdx +39 -126
  227. package/docs/guides/frontend/use-eve-agent-vue.mdx +40 -139
  228. package/docs/guides/instrumentation.md +15 -15
  229. package/docs/guides/meta.json +1 -5
  230. package/docs/guides/remote-agents.md +9 -9
  231. package/docs/guides/session-context.md +34 -103
  232. package/docs/install-integrations.mdx +1 -1
  233. package/docs/instructions.mdx +45 -12
  234. package/docs/meta.json +24 -13
  235. package/docs/patterns/dynamic-scheduling.md +1 -1
  236. package/docs/patterns/meta.json +1 -0
  237. package/docs/patterns/multi-tenant-approvals.md +1 -1
  238. package/docs/patterns/multi-tenant-auth.md +1 -1
  239. package/docs/patterns/multi-tenant-memory.md +4 -3
  240. package/docs/{guides → protocols}/acp.md +1 -1
  241. package/docs/protocols/meta.json +5 -0
  242. package/docs/reference/cli.md +39 -39
  243. package/docs/reference/meta.json +1 -1
  244. package/docs/reference/typescript-api.md +4 -2
  245. package/docs/sandbox.mdx +8 -0
  246. package/docs/{subagents.mdx → subagents/index.mdx} +2 -2
  247. package/docs/subagents/meta.json +5 -0
  248. package/docs/{guides/dynamic-workflows.md → subagents/workflow-tool.md} +6 -6
  249. package/docs/tools/human-in-the-loop.md +1 -1
  250. package/docs/tools/meta.json +1 -0
  251. package/docs/tools/overview.mdx +1 -1
  252. package/docs/tutorial/connect-a-warehouse.mdx +1 -1
  253. package/docs/tutorial/meta.json +1 -0
  254. package/docs/tutorial/remember-definitions.mdx +2 -2
  255. package/docs/tutorial/ship-it.mdx +2 -2
  256. package/package.json +4 -4
  257. package/dist/src/compiled/_chunks/workflow/dist-C8PhDW9B.js +0 -1
  258. package/dist/src/compiled/_chunks/workflow/functions-xMPAeWFr.js +0 -1
  259. package/dist/src/compiled/_chunks/workflow/node-Smb57EnG.js +0 -40
  260. package/dist/src/compiled/_chunks/workflow/resume-hook-BrduAuFX.js +0 -1
  261. package/dist/src/compiled/_chunks/workflow/run-CX7_sJnW.js +0 -1
  262. package/dist/src/compiled/_chunks/workflow/sleep-tsb2HjWK.js +0 -1
  263. package/dist/src/compiled/_chunks/workflow/undici-BNc_0O4m.js +0 -95
  264. package/dist/src/compiled/_chunks/workflow/wait-until-BYKVqrwc.js +0 -15
  265. package/dist/src/harness/instrumentation-config.js +0 -1
  266. package/dist/src/public/nuxt/vercel-services.js +0 -1
  267. package/dist/src/public/sveltekit/vercel-json.d.ts +0 -17
  268. package/dist/src/public/sveltekit/vercel-json.js +0 -1
  269. package/docs/installation.mdx +0 -66
  270. package/docs/project-structure.mdx +0 -53
  271. package/docs/reference/project-layout.md +0 -123
  272. /package/dist/src/harness/{instrumentation-config.d.ts → instrumentation/config.d.ts} +0 -0
  273. /package/dist/src/harness/{instrumentation-content.js → instrumentation/content.js} +0 -0
  274. /package/dist/src/harness/{instrumentation-runtime-context.d.ts → instrumentation/runtime-context.d.ts} +0 -0
  275. /package/dist/src/harness/{instrumentation-runtime-context.js → instrumentation/runtime-context.js} +0 -0
  276. /package/dist/src/harness/{instrumentation-runtime.js → instrumentation/runtime.js} +0 -0
  277. /package/dist/src/harness/{instrumentation-setup-context.d.ts → instrumentation/setup-context.d.ts} +0 -0
  278. /package/dist/src/harness/{instrumentation-setup-context.js → instrumentation/setup-context.js} +0 -0
  279. /package/dist/src/harness/{instrumentation-state.js → instrumentation/state.js} +0 -0
  280. /package/docs/{guides → protocols}/ucp.mdx +0 -0
@@ -1 +1 @@
1
- import{readFile}from"node:fs/promises";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{basename,join}from"node:path";import{LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}from"#internal/workflow/local-world-data-directory.js";import{turnWorkflowReference}from"#execution/workflow-runtime.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV,DEVELOPMENT_WORKFLOW_DELIVERY_HEADER,DEVELOPMENT_WORKFLOW_SECRET_ENV,DEVELOPMENT_WORKFLOW_STREAM_ROUTE,DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,DEVELOPMENT_WORKFLOW_WORLD_ROUTE,DEVELOPMENT_WORLD_OPERATIONS}from"#internal/workflow/development-world-protocol.js";import{timingSafeEqualStrings}from"#internal/nitro/dev-client-address.js";import{decodeDevelopmentWorldJson,decodeDevelopmentWorldValue,deserializeDevelopmentWorldError,encodeDevelopmentWorldValue}from"#internal/workflow/development-world-codec.js";import{getDevelopmentWorkflowGeneration,withDevelopmentWorkflowGeneration}from"#internal/workflow/development-generation-context.js";var MissingDevelopmentGenerationError=class extends Error{constructor(e,t){super(`Workflow run references missing development generation "${e}". Remove "${LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}" to discard the app's active local Workflow runs.`,t===void 0?void 0:{cause:t}),this.name=`MissingDevelopmentGenerationError`}};async function call(e,t=[]){return decodeDevelopmentWorldValue(await(await fetchDevelopmentWorld(DEVELOPMENT_WORKFLOW_WORLD_ROUTE,{body:encodeDevelopmentWorldValue({arguments:t,operation:e}),method:`POST`})).text())}function createDevelopmentWorkflowWorld(){let e=buildForwardedOperations();return{specVersion:5,processExitTriggersQueueRedelivery:!1,async getDeploymentId(){return getDevelopmentWorkflowGeneration()?.generationId??await call(`getDeploymentId`)},resolveLatestDeploymentId:e.topLevel.resolveLatestDeploymentId,queue:e.topLevel.queue,createQueueHandler,runs:e.groups.runs,steps:e.groups.steps,events:e.groups.events,hooks:e.groups.hooks,streams:{...e.groups.streams,get:async(e,t,n)=>{let r=new URL(resolveDevelopmentWorldBaseUrl());r.pathname=DEVELOPMENT_WORKFLOW_STREAM_ROUTE,r.searchParams.set(`runId`,e),r.searchParams.set(`name`,t),n!==void 0&&r.searchParams.set(`startIndex`,String(n));let i=await fetchDevelopmentWorld(r,{method:`GET`});if(i.body===null)throw Error(`Development Workflow stream response had no body.`);return i.body}},async start(){},async close(){}}}function buildForwardedOperations(){let e={},t={};for(let n of DEVELOPMENT_WORLD_OPERATIONS){let forward=async(...e)=>await call(n,e),r=n.indexOf(`.`);r===-1?t[n]=forward:(e[n.slice(0,r)]??={})[n.slice(r+1)]=forward}return{groups:e,topLevel:t}}function createQueueHandler(e,n){return async r=>{let i=readRequiredEnvironment(DEVELOPMENT_WORKFLOW_SECRET_ENV),a=r.headers.get(DEVELOPMENT_WORKFLOW_DELIVERY_HEADER);if(a===null||!timingSafeEqualStrings(a,i))return Response.json({error:`Workflow delivery is not trusted.`},{status:401});let c=r.headers.get(`x-vqs-queue-name`),l=r.headers.get(`x-vqs-message-id`),u=Number(r.headers.get(`x-vqs-message-attempt`));if(c===null||!c.startsWith(e)||l===null||!Number.isInteger(u)||u<1||r.body===null)return Response.json({error:`Workflow delivery is malformed.`},{status:400});let d=decodeDevelopmentWorldJson(await r.text());try{let e=readRequiredEnvironment(DEVELOPMENT_WORKER_APP_ROOT_ENV),r=await resolveDeliveryGenerationId(d),i=await withDevelopmentWorkflowGeneration({generationId:r,source:createDiskRuntimeCompiledArtifactsSource(await readGenerationRuntimeAppRoot(e,r),{durableReference:`development-generation`,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:e})},async()=>await n(d,{attempt:u,messageId:l,queueName:c}));return Response.json(i===void 0?{ok:!0}:{timeoutSeconds:i.timeoutSeconds})}catch(e){return e instanceof MissingDevelopmentGenerationError?(console.error(`[eve:dev] ${e.message}`),Response.json({ok:!0})):Response.json(String(e),{status:500})}}}async function resolveDeliveryGenerationId(e){if(!isRecord(e))return await call(`resolveLatestDeploymentId`);let t=isRecord(e.runInput)?e.runInput:void 0;if(t!==void 0)return t.workflowName===turnWorkflowReference.workflowId&&typeof t.deploymentId==`string`?t.deploymentId:await call(`resolveLatestDeploymentId`);let n=typeof e.runId==`string`?e.runId:typeof e.workflowRunId==`string`?e.workflowRunId:void 0;if(n===void 0)return await call(`resolveLatestDeploymentId`);let r=await call(`runs.get`,[n,{resolveData:`none`}]);return r.workflowName===turnWorkflowReference.workflowId?r.deploymentId:await call(`resolveLatestDeploymentId`)}async function readGenerationRuntimeAppRoot(t,i){if(i.length===0||i===`.`||i===`..`||basename(i)!==i)throw Error(`Workflow run references invalid development generation "${i}".`);let a=join(t,`.eve`,`dev-runtime`,`snapshots`,i,`generation.json`),o;try{o=await readFile(a,`utf8`)}catch(e){throw isFileNotFoundError(e)?new MissingDevelopmentGenerationError(i,e):e}let s;try{s=JSON.parse(o)}catch(e){throw Error(`Development generation "${i}" has invalid metadata.`,{cause:e})}if(!isRecord(s)||typeof s.runtimeAppRoot!=`string`)throw Error(`Development generation "${i}" has invalid metadata.`);return s.runtimeAppRoot}function isFileNotFoundError(e){return e instanceof Error&&`code`in e&&e.code===`ENOENT`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function fetchDevelopmentWorld(e,t){let n=e instanceof URL?e:new URL(e,resolveDevelopmentWorldBaseUrl()),r=new Headers(t.headers);r.set(DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,readRequiredEnvironment(DEVELOPMENT_WORKFLOW_SECRET_ENV));let i=await fetch(n,{...t,headers:r});if(!i.ok){let e=await i.text(),t=readDevelopmentWorldError(e);throw t===void 0?Error(`Development Workflow World request failed (${String(i.status)}): ${e}`):t}return i}function readDevelopmentWorldError(e){try{return deserializeDevelopmentWorldError(decodeDevelopmentWorldValue(e))}catch{return}}function resolveDevelopmentWorldBaseUrl(){return readRequiredEnvironment(`WORKFLOW_LOCAL_BASE_URL`)}function readRequiredEnvironment(e){let t=process.env[e];if(t===void 0||t.length===0)throw Error(`Development Workflow transport is missing ${e}.`);return t}export{MissingDevelopmentGenerationError,createDevelopmentWorkflowWorld};
1
+ import{readFile}from"node:fs/promises";import{resolvePackageSourceFilePath}from"#internal/application/package.js";import{basename,join}from"node:path";import{LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}from"#internal/workflow/local-world-data-directory.js";import{turnWorkflowReference}from"#execution/workflow-runtime.js";import{createDiskRuntimeCompiledArtifactsSource}from"#runtime/compiled-artifacts-source.js";import{DEVELOPMENT_WORKER_APP_ROOT_ENV,DEVELOPMENT_WORKFLOW_DELIVERY_HEADER,DEVELOPMENT_WORKFLOW_SECRET_ENV,DEVELOPMENT_WORKFLOW_STREAM_ROUTE,DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,DEVELOPMENT_WORKFLOW_WORLD_ROUTE,DEVELOPMENT_WORLD_OPERATIONS}from"#internal/workflow/development-world-protocol.js";import{timingSafeEqualStrings}from"#internal/nitro/dev-client-address.js";import{decodeDevelopmentWorldJson,decodeDevelopmentWorldValue,deserializeDevelopmentWorldError,encodeDevelopmentWorldValue}from"#internal/workflow/development-world-codec.js";import{getDevelopmentWorkflowGeneration,withDevelopmentWorkflowGeneration}from"#internal/workflow/development-generation-context.js";var MissingDevelopmentGenerationError=class extends Error{constructor(e,t){super(`Workflow run references missing development generation "${e}". Remove "${LOCAL_WORKFLOW_WORLD_DATA_DIRECTORY_RELATIVE_PATH}" to discard the app's active local Workflow runs.`,t===void 0?void 0:{cause:t}),this.name=`MissingDevelopmentGenerationError`}};async function call(e,t=[]){return decodeDevelopmentWorldValue(await(await fetchDevelopmentWorld(DEVELOPMENT_WORKFLOW_WORLD_ROUTE,{body:encodeDevelopmentWorldValue({arguments:t,operation:e}),method:`POST`})).text())}function createDevelopmentWorkflowWorld(){let e=buildForwardedOperations();return{specVersion:5,async getDeploymentId(){return getDevelopmentWorkflowGeneration()?.generationId??await call(`getDeploymentId`)},resolveLatestDeploymentId:e.topLevel.resolveLatestDeploymentId,queue:e.topLevel.queue,createQueueHandler,runs:e.groups.runs,steps:e.groups.steps,events:e.groups.events,hooks:e.groups.hooks,streams:{...e.groups.streams,get:async(e,t,n)=>{let r=new URL(resolveDevelopmentWorldBaseUrl());r.pathname=DEVELOPMENT_WORKFLOW_STREAM_ROUTE,r.searchParams.set(`runId`,e),r.searchParams.set(`name`,t),n!==void 0&&r.searchParams.set(`startIndex`,String(n));let i=await fetchDevelopmentWorld(r,{method:`GET`});if(i.body===null)throw Error(`Development Workflow stream response had no body.`);return i.body}},async start(){},async close(){}}}function buildForwardedOperations(){let e={},t={};for(let n of DEVELOPMENT_WORLD_OPERATIONS){let forward=async(...e)=>await call(n,e),r=n.indexOf(`.`);r===-1?t[n]=forward:(e[n.slice(0,r)]??={})[n.slice(r+1)]=forward}return{groups:e,topLevel:t}}function createQueueHandler(e,n){return async r=>{let i=readRequiredEnvironment(DEVELOPMENT_WORKFLOW_SECRET_ENV),a=r.headers.get(DEVELOPMENT_WORKFLOW_DELIVERY_HEADER);if(a===null||!timingSafeEqualStrings(a,i))return Response.json({error:`Workflow delivery is not trusted.`},{status:401});let c=r.headers.get(`x-vqs-queue-name`),l=r.headers.get(`x-vqs-message-id`),u=Number(r.headers.get(`x-vqs-message-attempt`));if(c===null||!c.startsWith(e)||l===null||!Number.isInteger(u)||u<1||r.body===null)return Response.json({error:`Workflow delivery is malformed.`},{status:400});let d=decodeDevelopmentWorldJson(await r.text());try{let e=readRequiredEnvironment(DEVELOPMENT_WORKER_APP_ROOT_ENV),r=await resolveDeliveryGenerationId(d),i=await withDevelopmentWorkflowGeneration({generationId:r,source:createDiskRuntimeCompiledArtifactsSource(await readGenerationRuntimeAppRoot(e,r),{durableReference:`development-generation`,moduleMapLoaderPath:resolvePackageSourceFilePath(`src/internal/authored-module-map-loader.ts`),sandboxAppRoot:e})},async()=>await n(d,{attempt:u,messageId:l,queueName:c}));return Response.json(i===void 0?{ok:!0}:{timeoutSeconds:i.timeoutSeconds})}catch(e){return e instanceof MissingDevelopmentGenerationError?(console.error(`[eve:dev] ${e.message}`),Response.json({ok:!0})):Response.json(String(e),{status:500})}}}async function resolveDeliveryGenerationId(e){if(!isRecord(e))return await call(`resolveLatestDeploymentId`);let t=isRecord(e.runInput)?e.runInput:void 0;if(t!==void 0)return t.workflowName===turnWorkflowReference.workflowId&&typeof t.deploymentId==`string`?t.deploymentId:await call(`resolveLatestDeploymentId`);let n=typeof e.runId==`string`?e.runId:typeof e.workflowRunId==`string`?e.workflowRunId:void 0;if(n===void 0)return await call(`resolveLatestDeploymentId`);let r=await call(`runs.get`,[n,{resolveData:`none`}]);return r.workflowName===turnWorkflowReference.workflowId?r.deploymentId:await call(`resolveLatestDeploymentId`)}async function readGenerationRuntimeAppRoot(t,i){if(i.length===0||i===`.`||i===`..`||basename(i)!==i)throw Error(`Workflow run references invalid development generation "${i}".`);let a=join(t,`.eve`,`dev-runtime`,`snapshots`,i,`generation.json`),o;try{o=await readFile(a,`utf8`)}catch(e){throw isFileNotFoundError(e)?new MissingDevelopmentGenerationError(i,e):e}let s;try{s=JSON.parse(o)}catch(e){throw Error(`Development generation "${i}" has invalid metadata.`,{cause:e})}if(!isRecord(s)||typeof s.runtimeAppRoot!=`string`)throw Error(`Development generation "${i}" has invalid metadata.`);return s.runtimeAppRoot}function isFileNotFoundError(e){return e instanceof Error&&`code`in e&&e.code===`ENOENT`}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function fetchDevelopmentWorld(e,t){let n=e instanceof URL?e:new URL(e,resolveDevelopmentWorldBaseUrl()),r=new Headers(t.headers);r.set(DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,readRequiredEnvironment(DEVELOPMENT_WORKFLOW_SECRET_ENV));let i=await fetch(n,{...t,headers:r});if(!i.ok){let e=await i.text(),t=readDevelopmentWorldError(e);throw t===void 0?Error(`Development Workflow World request failed (${String(i.status)}): ${e}`):t}return i}function readDevelopmentWorldError(e){try{return deserializeDevelopmentWorldError(decodeDevelopmentWorldValue(e))}catch{return}}function resolveDevelopmentWorldBaseUrl(){return readRequiredEnvironment(`WORKFLOW_LOCAL_BASE_URL`)}function readRequiredEnvironment(e){let t=process.env[e];if(t===void 0||t.length===0)throw Error(`Development Workflow transport is missing ${e}.`);return t}export{MissingDevelopmentGenerationError,createDevelopmentWorkflowWorld};
@@ -9,7 +9,7 @@ export declare const EVE_STREAM_TAIL_INDEX_HEADER = "x-eve-stream-tail-index";
9
9
  export declare const EVE_STREAM_VERSION_HEADER = "x-eve-stream-version";
10
10
  export declare const EVE_MESSAGE_STREAM_CONTENT_TYPE = "application/x-ndjson; charset=utf-8";
11
11
  export declare const EVE_MESSAGE_STREAM_FORMAT = "ndjson";
12
- export declare const EVE_MESSAGE_STREAM_VERSION = "21";
12
+ export declare const EVE_MESSAGE_STREAM_VERSION = "22";
13
13
  /**
14
14
  * eve-owned finish reason for one completed assistant step.
15
15
  *
@@ -90,6 +90,16 @@ export interface RuntimeIdentity {
90
90
  readonly gitSha?: string;
91
91
  };
92
92
  }
93
+ /**
94
+ * Portable trace coordinates for correlating an eve run with an external
95
+ * observability backend. The fields follow the W3C trace-context model while
96
+ * remaining owned by eve rather than exposing an OpenTelemetry type.
97
+ */
98
+ export interface RuntimeTraceContext {
99
+ readonly traceId: string;
100
+ readonly spanId: string;
101
+ readonly traceFlags: number;
102
+ }
93
103
  /**
94
104
  * JSON request accepted by the canonical message route.
95
105
  *
@@ -117,6 +127,7 @@ export interface SessionStartedStreamEvent {
117
127
  data: {
118
128
  invocation?: SubagentSessionInvocationMetadata;
119
129
  runtime?: RuntimeIdentity;
130
+ trace?: RuntimeTraceContext;
120
131
  };
121
132
  type: "session.started";
122
133
  }
@@ -126,6 +137,7 @@ export interface SessionStartedStreamEvent {
126
137
  export interface TurnStartedStreamEvent {
127
138
  data: {
128
139
  sequence: number;
140
+ trace?: RuntimeTraceContext;
129
141
  turnId: string;
130
142
  };
131
143
  type: "turn.started";
@@ -612,12 +624,14 @@ export declare function isTurnFailureEvent<TEvent extends UnstampedMessageStream
612
624
  export declare function createSessionStartedEvent(input?: {
613
625
  readonly invocation?: SubagentSessionInvocationMetadata;
614
626
  readonly runtime?: RuntimeIdentity;
627
+ readonly trace?: RuntimeTraceContext;
615
628
  }): SessionStartedStreamEvent;
616
629
  /**
617
630
  * Creates the `turn.started` event for one prepared runtime turn.
618
631
  */
619
632
  export declare function createTurnStartedEvent(input: {
620
633
  readonly sequence: number;
634
+ readonly trace?: RuntimeTraceContext;
621
635
  readonly turnId: string;
622
636
  }): TurnStartedStreamEvent;
623
637
  /**
@@ -1,2 +1,2 @@
1
- import{deserializeUrlFilePart,hasInternalRefScheme,isSerializedUrlFilePart}from"#internal/attachments/url-refs.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";import{decodeSandboxRef,isSandboxRefUrl}from"#internal/attachments/sandbox-refs.js";import{createEventId}from"#protocol/event-id.js";const EVE_SESSION_ID_HEADER=`x-eve-session-id`,EVE_STREAM_FORMAT_HEADER=`x-eve-stream-format`,EVE_STREAM_TAIL_INDEX_HEADER=`x-eve-stream-tail-index`,EVE_STREAM_VERSION_HEADER=`x-eve-stream-version`,EVE_MESSAGE_STREAM_CONTENT_TYPE=`application/x-ndjson; charset=utf-8`,EVE_MESSAGE_STREAM_FORMAT=`ndjson`,EVE_MESSAGE_STREAM_VERSION=`21`,textEncoder=new TextEncoder;function isCurrentTurnBoundaryEvent(e){return e.type===`session.completed`||e.type===`session.failed`||e.type===`session.waiting`}function isTurnFailureEvent(e){return e.type===`session.failed`||e.type===`step.failed`||e.type===`turn.failed`}function createSessionStartedEvent(e){let t={};return e?.invocation!==void 0&&(t.invocation=e.invocation),e?.runtime!==void 0&&(t.runtime=e.runtime),{data:t,type:`session.started`}}function createTurnStartedEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.started`}}function createMessageReceivedEvent(e){return{data:{message:summarizeUserContent(e.message),parts:projectUserContentParts(e.message),sequence:e.sequence,turnId:e.turnId},type:`message.received`}}function summarizeUserContent(e){if(typeof e==`string`)return e;let t=[];for(let n of e)if(n.type===`text`)t.push(n.text);else if(n.type===`file`){let e=n.filename??n.mediaType;t.push(`[file: ${e} (${n.mediaType})]`)}else n.type===`image`&&t.push(`[image: ${n.mediaType??`image`}]`);return t.join(`
1
+ import{deserializeUrlFilePart,hasInternalRefScheme,isSerializedUrlFilePart}from"#internal/attachments/url-refs.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";import{decodeSandboxRef,isSandboxRefUrl}from"#internal/attachments/sandbox-refs.js";import{createEventId}from"#protocol/event-id.js";const EVE_SESSION_ID_HEADER=`x-eve-session-id`,EVE_STREAM_FORMAT_HEADER=`x-eve-stream-format`,EVE_STREAM_TAIL_INDEX_HEADER=`x-eve-stream-tail-index`,EVE_STREAM_VERSION_HEADER=`x-eve-stream-version`,EVE_MESSAGE_STREAM_CONTENT_TYPE=`application/x-ndjson; charset=utf-8`,EVE_MESSAGE_STREAM_FORMAT=`ndjson`,EVE_MESSAGE_STREAM_VERSION=`22`,textEncoder=new TextEncoder;function isCurrentTurnBoundaryEvent(e){return e.type===`session.completed`||e.type===`session.failed`||e.type===`session.waiting`}function isTurnFailureEvent(e){return e.type===`session.failed`||e.type===`step.failed`||e.type===`turn.failed`}function createSessionStartedEvent(e){let t={};return e?.invocation!==void 0&&(t.invocation=e.invocation),e?.runtime!==void 0&&(t.runtime=e.runtime),e?.trace!==void 0&&(t.trace=e.trace),{data:t,type:`session.started`}}function createTurnStartedEvent(e){let t={sequence:e.sequence,turnId:e.turnId};return e.trace!==void 0&&(t.trace=e.trace),{data:t,type:`turn.started`}}function createMessageReceivedEvent(e){return{data:{message:summarizeUserContent(e.message),parts:projectUserContentParts(e.message),sequence:e.sequence,turnId:e.turnId},type:`message.received`}}function summarizeUserContent(e){if(typeof e==`string`)return e;let t=[];for(let n of e)if(n.type===`text`)t.push(n.text);else if(n.type===`file`){let e=n.filename??n.mediaType;t.push(`[file: ${e} (${n.mediaType})]`)}else n.type===`image`&&t.push(`[image: ${n.mediaType??`image`}]`);return t.join(`
2
2
  `)}function projectUserContentParts(e){if(typeof e==`string`)return[{text:e,type:`text`}];let t=[];for(let n of e)n.type===`text`?t.push({text:n.text,type:`text`}):n.type===`file`?t.push(projectFileLikePart(n.data,n.mediaType,n.filename)):n.type===`image`&&t.push(projectFileLikePart(n.image,n.mediaType??`application/octet-stream`,void 0));return t}function projectFileLikePart(e,t,n){if(isSandboxRefUrl(e)){let t=decodeSandboxRef(e);return createProjectedFilePart({filename:basenameOf(n??t.path),mediaType:t.mediaType,size:t.size})}let r=projectTaggedFileData(e,t,n);if(r!==void 0)return r;let i=byteLengthOf(e);return createProjectedFilePart(i===void 0?{filename:n,mediaType:t,...clientUrlFragment(e)}:{filename:n,mediaType:t,size:i})}function projectTaggedFileData(e,t,n){if(isTaggedFileData(e))switch(e.type){case`data`:{let r=byteLengthOf(e.data);return createProjectedFilePart(r===void 0?{filename:n,mediaType:t}:{filename:n,mediaType:t,size:r})}case`reference`:case`text`:return createProjectedFilePart({filename:n,mediaType:t});case`url`:return createProjectedFilePart({filename:n,mediaType:t,...clientUrlFragment(e.url)})}}function createProjectedFilePart(e){let t={mediaType:e.mediaType,type:`file`};return e.filename!==void 0&&(t.filename=e.filename),e.size!==void 0&&(t.size=e.size),e.url!==void 0&&(t.url=e.url),t}function isTaggedFileData(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`data`||t===`reference`||t===`text`||t===`url`}function byteLengthOf(e){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return e.byteLength}function clientUrlFragment(r){if(isSerializedUrlFilePart(r))try{let t=deserializeUrlFilePart(r);return isClientResolvableUrl(t)?{url:t.href}:{}}catch{return{}}if(r instanceof URL)return isClientResolvableUrl(r)?{url:r.href}:{};if(typeof r!=`string`||hasInternalRefScheme(r))return{};if(r.startsWith(`data:`))return{url:r};try{let e=new URL(r);return isClientResolvableUrl(e)?{url:e.href}:{}}catch{return{}}}function isClientResolvableUrl(e){return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`data:`}function basenameOf(e){let t=e.replaceAll(`\\`,`/`),n=t.slice(t.lastIndexOf(`/`)+1);return n.length>0?n:e}function createActionsRequestedEvent(e){return{data:{actions:e.actions,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`actions.requested`}}function createAuthorizationRequiredEvent(e){let t={description:e.description,name:e.name,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.authorization!==void 0&&(t.authorization=e.authorization),e.candidateId!==void 0&&(t.candidateId=e.candidateId),e.webhookUrl!==void 0&&(t.webhookUrl=e.webhookUrl),{data:t,type:`authorization.required`}}function createAuthorizationCompletedEvent(e){let t={name:e.name,outcome:e.outcome,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.authorization!==void 0&&(t.authorization=e.authorization),e.candidateId!==void 0&&(t.candidateId=e.candidateId),e.reason!==void 0&&(t.reason=e.reason),{data:t,type:`authorization.completed`}}function createApprovalCandidateEvent(e){return{data:e,type:`approval.candidate`}}function createApprovalSettledEvent(e){return{data:e,type:`approval.settled`}}function createInputRequestedEvent(e){return{data:{requests:e.requests,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`input.requested`}}function createActionResultEvent(e){let t=e.rejected===!0?{error:buildActionResultError(e.result),status:`rejected`}:normalizeActionResultOutcome(e.result);return{data:{error:t.error,result:e.result,sequence:e.sequence,status:t.status,stepIndex:e.stepIndex,turnId:e.turnId},type:`action.result`}}function createActionPartialEvent(e){return{data:{result:e.result,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`action.partial`}}function createSubagentCalledEvent(e){return{data:{callId:e.callId,childSessionId:e.childSessionId,sessionId:e.sessionId,sequence:e.sequence,name:e.name,remote:e.remote,toolName:e.toolName,turnId:e.turnId,workflowId:e.workflowId},type:`subagent.called`}}function createMessageAppendedEvent(e){return{data:{messageDelta:e.messageDelta,messageSoFar:e.messageSoFar,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`message.appended`}}function createReasoningAppendedEvent(e){return{data:{reasoningDelta:e.reasoningDelta,reasoningSoFar:e.reasoningSoFar,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`reasoning.appended`}}function createMessageCompletedEvent(e){return{data:{finishReason:e.finishReason??`stop`,message:e.message,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`message.completed`}}function createReasoningCompletedEvent(e){return{data:{reasoning:e.reasoning,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`reasoning.completed`}}function createResultCompletedEvent(e){return{data:{result:e.result,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`result.completed`}}function createStepStartedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`step.started`}}function createStepCompletedEvent(e){let t={finishReason:e.finishReason,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.usage!==void 0&&(t.usage=e.usage),e.providerMetadata!==void 0&&(t.providerMetadata=e.providerMetadata),{data:t,type:`step.completed`}}function createStepFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`step.failed`}}function createTurnCompletedEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.completed`}}function createTurnFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sequence:e.sequence,turnId:e.turnId},type:`turn.failed`}}function createTurnCancelledEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.cancelled`}}function createContextClearedEvent(e){return{data:{sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId},type:`context.cleared`}}function createCompactionRequestedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId,usageInputTokens:e.usageInputTokens??null},type:`compaction.requested`}}function createCompactionCompletedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId},type:`compaction.completed`}}function createSessionWaitingEvent(e=``){return{data:{continuationToken:toChannelLocalContinuationToken(e),wait:`next-user-message`},type:`session.waiting`}}function createSessionFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sessionId:e.sessionId},type:`session.failed`}}function createSessionCompletedEvent(){return{type:`session.completed`}}function stampMessageStreamEvent(e){return{...e,meta:{at:new Date().toISOString(),id:createEventId()}}}function encodeMessageStreamEvent(e){return textEncoder.encode(`${JSON.stringify(e)}\n`)}function normalizeActionResultOutcome(e){if(e.isError===!0)return{error:buildActionResultError(e),status:`failed`};let t=readActionResultOutputError(e.output);return t===void 0?{status:`completed`}:{error:t,status:`failed`}}function buildActionResultError(e){let t=readActionResultOutputError(e.output);return t===void 0?{code:`ACTION_RESULT_FAILED`,message:formatActionResultOutput(e.output)}:t}function readActionResultOutputError(e){let t=parseActionResultOutputRecord(e);if(t===void 0)return;let n=typeof t.code==`string`&&t.code.length>0?t.code:void 0,r=typeof t.message==`string`&&t.message.length>0?t.message:void 0;if(!(n===void 0||r===void 0))return{code:n,message:r}}function parseActionResultOutputRecord(e){if(typeof e==`object`&&e)return e;if(typeof e!=`string`)return;let t=e.trim();if(t.length!==0)try{let e=JSON.parse(t);if(typeof e==`object`&&e)return e}catch{return}}function formatActionResultOutput(e){if(typeof e==`string`)return e;let t=JSON.stringify(e);return typeof t==`string`&&t.length>0?t:`Action failed.`}export{EVE_MESSAGE_STREAM_CONTENT_TYPE,EVE_MESSAGE_STREAM_FORMAT,EVE_MESSAGE_STREAM_VERSION,EVE_SESSION_ID_HEADER,EVE_STREAM_FORMAT_HEADER,EVE_STREAM_TAIL_INDEX_HEADER,EVE_STREAM_VERSION_HEADER,createActionPartialEvent,createActionResultEvent,createActionsRequestedEvent,createApprovalCandidateEvent,createApprovalSettledEvent,createAuthorizationCompletedEvent,createAuthorizationRequiredEvent,createCompactionCompletedEvent,createCompactionRequestedEvent,createContextClearedEvent,createInputRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createResultCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepCompletedEvent,createStepFailedEvent,createStepStartedEvent,createSubagentCalledEvent,createTurnCancelledEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent,encodeMessageStreamEvent,isCurrentTurnBoundaryEvent,isTurnFailureEvent,stampMessageStreamEvent};
@@ -12,11 +12,29 @@ export type GitHubWebhookSecret = string | (() => string | Promise<string>);
12
12
  * as Connect derive the installation token out-of-band and set this field.
13
13
  */
14
14
  export type GitHubInstallationToken = string | (() => string | Promise<string>);
15
+ /**
16
+ * The name the channel answers to in `@mentions` (the GitHub App slug,
17
+ * without the `[bot]` suffix), supplied directly or resolved lazily.
18
+ *
19
+ * A lazy resolver runs on first use inside request handling, where
20
+ * credentials that only exist per request (such as the Vercel OIDC token
21
+ * behind Connect metadata lookups) are available; a fulfilled value is
22
+ * cached, and a rejection is retried on the next event instead of pinned.
23
+ */
24
+ export type GitHubBotName = string | (() => string | Promise<string>);
15
25
  /** Credentials used by the native GitHub channel. */
16
26
  export interface GitHubChannelCredentials {
17
27
  readonly appId?: GitHubAppId;
18
28
  readonly privateKey?: GitHubPrivateKey;
19
29
  readonly webhookSecret?: GitHubWebhookSecret;
30
+ /**
31
+ * The GitHub App's slug (its `@mention` handle, without the `[bot]`
32
+ * suffix), supplied directly or resolved lazily. Used as the channel's
33
+ * `botName` when the config does not set one, so integrations that broker
34
+ * credentials can make mention dispatch work with no explicit
35
+ * configuration.
36
+ */
37
+ readonly appSlug?: GitHubBotName;
20
38
  /**
21
39
  * Pre-resolved GitHub installation access token. When supplied, eve uses
22
40
  * it directly for authenticated GitHub API calls and skips the native
@@ -44,6 +62,18 @@ export declare function resolveGitHubAppId(appId?: GitHubAppId): Promise<string>
44
62
  export declare function resolveGitHubPrivateKey(privateKey?: GitHubPrivateKey): Promise<string>;
45
63
  /** Resolves a GitHub webhook secret, falling back to `GITHUB_WEBHOOK_SECRET`. */
46
64
  export declare function resolveGitHubWebhookSecret(webhookSecret?: GitHubWebhookSecret): Promise<string>;
65
+ /** The channel's lazily resolved bot name, shared by dispatch and defaults. */
66
+ export type GitHubBotNameResolver = () => Promise<string | undefined>;
67
+ /**
68
+ * Creates the channel's `botName` resolver: explicit config first, then the
69
+ * credentials' `appSlug`, then `GITHUB_APP_SLUG`. A fulfilled name is cached
70
+ * for the channel's lifetime; a rejection is logged and retried on the next
71
+ * event, so one failed delivery cannot pin the channel to a missing name.
72
+ */
73
+ export declare function createGitHubBotNameResolver(input: {
74
+ readonly botName?: GitHubBotName;
75
+ readonly credentials?: GitHubChannelCredentials;
76
+ }): GitHubBotNameResolver;
47
77
  /** Converts hosted-platform escaped newlines back into PEM newlines. */
48
78
  export declare function normalizeGitHubPrivateKey(privateKey: string): string;
49
79
  /** Creates a short-lived RS256 GitHub App JWT. */
@@ -1,2 +1,2 @@
1
- import{createSign}from"node:crypto";import{isObject}from"#shared/guards.js";const installationTokenCache=new Map;async function resolveGitHubAppId(e){let t=e??process.env.GITHUB_APP_ID;if(t===void 0||t===``)throw Error(`githubChannel: GITHUB_APP_ID is required.`);let n=typeof t==`function`?await t():t;return String(n)}async function resolveGitHubPrivateKey(e){let t=e??process.env.GITHUB_APP_PRIVATE_KEY;if(!t)throw Error(`githubChannel: GITHUB_APP_PRIVATE_KEY is required.`);return normalizeGitHubPrivateKey(typeof t==`function`?await t():t)}async function resolveGitHubWebhookSecret(e){let t=e??process.env.GITHUB_WEBHOOK_SECRET;if(!t)throw Error(`githubChannel: GITHUB_WEBHOOK_SECRET is required.`);return typeof t==`function`?await t():t}function normalizeGitHubPrivateKey(e){return e.replace(/\\n/gu,`
2
- `)}async function createGitHubAppJwt(t){let n=await resolveGitHubAppId(t.appId),r=await resolveGitHubPrivateKey(t.privateKey),i=Math.floor((t.now?.getTime()??Date.now())/1e3),a={alg:`RS256`,typ:`JWT`},o={exp:i+600,iat:i-60,iss:n},s=`${base64UrlJson(a)}.${base64UrlJson(o)}`;return`${s}.${createSign(`RSA-SHA256`).update(s).sign(r,`base64url`)}`}async function resolveGitHubInstallationToken(e){let t=e.credentials?.installationToken;if(t!==void 0)return typeof t==`function`?await t():t;if(e.installationId===void 0)throw Error(`githubChannel: installationId is required for authenticated GitHub API calls.`);return createGitHubInstallationToken({api:e.api,appId:e.credentials?.appId,installationId:e.installationId,privateKey:e.credentials?.privateKey})}async function createGitHubInstallationToken(e){let r=await resolveGitHubAppId(e.appId),i=e.api?.apiBaseUrl??`https://api.github.com`,a=`${i}:${r}:${e.installationId}`,o=installationTokenCache.get(a);if(o!==void 0&&Date.now()<o.expiresAtMs-6e4)return o.token;let s=await createGitHubAppJwt({appId:r,privateKey:e.privateKey}),c=await(e.api?.fetch??fetch)(`${i}/app/installations/${e.installationId}/access_tokens`,{headers:{accept:`application/vnd.github+json`,authorization:`Bearer ${s}`,"x-github-api-version":`2022-11-28`},method:`POST`}),l=await parseJsonBody(c);if(!c.ok)throw Error(`githubChannel: create installation token failed with HTTP ${c.status}.`);if(!isObject(l)||typeof l.token!=`string`)throw Error(`githubChannel: installation token response did not include a token.`);let u=parseExpiryMs(l.expires_at);return installationTokenCache.set(a,{expiresAtMs:u,token:l.token}),l.token}function clearGitHubInstallationTokenCache(){installationTokenCache.clear()}function seedGitHubInstallationTokenForTests(e){let t=e.apiBaseUrl??`https://api.github.com`,r=e.appId??`test-app`;installationTokenCache.set(`${t}:${r}:${e.installationId}`,{expiresAtMs:Date.now()+3600*1e3,token:e.token})}function base64UrlJson(e){return Buffer.from(JSON.stringify(e)).toString(`base64url`)}async function parseJsonBody(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function parseExpiryMs(e){if(typeof e==`string`){let t=Date.parse(e);if(Number.isFinite(t))return t}return Date.now()+3600*1e3}export{clearGitHubInstallationTokenCache,createGitHubAppJwt,createGitHubInstallationToken,normalizeGitHubPrivateKey,resolveGitHubAppId,resolveGitHubInstallationToken,resolveGitHubPrivateKey,resolveGitHubWebhookSecret,seedGitHubInstallationTokenForTests};
1
+ import{createSign}from"node:crypto";import{createLogger}from"#internal/logging.js";import{isObject}from"#shared/guards.js";const log=createLogger(`github.auth`),installationTokenCache=new Map;async function resolveGitHubAppId(e){let t=e??process.env.GITHUB_APP_ID;if(t===void 0||t===``)throw Error(`githubChannel: GITHUB_APP_ID is required.`);let n=typeof t==`function`?await t():t;return String(n)}async function resolveGitHubPrivateKey(e){let t=e??process.env.GITHUB_APP_PRIVATE_KEY;if(!t)throw Error(`githubChannel: GITHUB_APP_PRIVATE_KEY is required.`);return normalizeGitHubPrivateKey(typeof t==`function`?await t():t)}async function resolveGitHubWebhookSecret(e){let t=e??process.env.GITHUB_WEBHOOK_SECRET;if(!t)throw Error(`githubChannel: GITHUB_WEBHOOK_SECRET is required.`);return typeof t==`function`?await t():t}function createGitHubBotNameResolver(e){let t;return async()=>{if(t!==void 0)return t;let n=e.botName??e.credentials?.appSlug??process.env.GITHUB_APP_SLUG;if(n!==void 0){if(typeof n==`string`)return t=normalizeBotName(n),t;try{return t=normalizeBotName(await n()),t}catch(e){log.warn(`githubChannel: botName resolver failed; retrying on the next event`,{error:e});return}}}}function normalizeBotName(e){let t=e.trim();return t.length>0?t:void 0}function normalizeGitHubPrivateKey(e){return e.replace(/\\n/gu,`
2
+ `)}async function createGitHubAppJwt(t){let n=await resolveGitHubAppId(t.appId),r=await resolveGitHubPrivateKey(t.privateKey),i=Math.floor((t.now?.getTime()??Date.now())/1e3),a={alg:`RS256`,typ:`JWT`},o={exp:i+600,iat:i-60,iss:n},s=`${base64UrlJson(a)}.${base64UrlJson(o)}`;return`${s}.${createSign(`RSA-SHA256`).update(s).sign(r,`base64url`)}`}async function resolveGitHubInstallationToken(e){let t=e.credentials?.installationToken;if(t!==void 0)return typeof t==`function`?await t():t;if(e.installationId===void 0)throw Error(`githubChannel: installationId is required for authenticated GitHub API calls.`);return createGitHubInstallationToken({api:e.api,appId:e.credentials?.appId,installationId:e.installationId,privateKey:e.credentials?.privateKey})}async function createGitHubInstallationToken(e){let t=await resolveGitHubAppId(e.appId),r=e.api?.apiBaseUrl??`https://api.github.com`,a=`${r}:${t}:${e.installationId}`,o=installationTokenCache.get(a);if(o!==void 0&&Date.now()<o.expiresAtMs-6e4)return o.token;let s=await createGitHubAppJwt({appId:t,privateKey:e.privateKey}),c=await(e.api?.fetch??fetch)(`${r}/app/installations/${e.installationId}/access_tokens`,{headers:{accept:`application/vnd.github+json`,authorization:`Bearer ${s}`,"x-github-api-version":`2022-11-28`},method:`POST`}),l=await parseJsonBody(c);if(!c.ok)throw Error(`githubChannel: create installation token failed with HTTP ${c.status}.`);if(!isObject(l)||typeof l.token!=`string`)throw Error(`githubChannel: installation token response did not include a token.`);let u=parseExpiryMs(l.expires_at);return installationTokenCache.set(a,{expiresAtMs:u,token:l.token}),l.token}function clearGitHubInstallationTokenCache(){installationTokenCache.clear()}function seedGitHubInstallationTokenForTests(e){let t=e.apiBaseUrl??`https://api.github.com`,n=e.appId??`test-app`;installationTokenCache.set(`${t}:${n}:${e.installationId}`,{expiresAtMs:Date.now()+3600*1e3,token:e.token})}function base64UrlJson(e){return Buffer.from(JSON.stringify(e)).toString(`base64url`)}async function parseJsonBody(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function parseExpiryMs(e){if(typeof e==`string`){let t=Date.parse(e);if(Number.isFinite(t))return t}return Date.now()+3600*1e3}export{clearGitHubInstallationTokenCache,createGitHubAppJwt,createGitHubBotNameResolver,createGitHubInstallationToken,normalizeGitHubPrivateKey,resolveGitHubAppId,resolveGitHubInstallationToken,resolveGitHubPrivateKey,resolveGitHubWebhookSecret,seedGitHubInstallationTokenForTests};
@@ -1,6 +1,6 @@
1
1
  import type { SessionAuthContext } from "#channel/types.js";
2
2
  import type { GitHubApiOptions } from "#public/channels/github/api.js";
3
- import type { GitHubChannelCredentials } from "#public/channels/github/auth.js";
3
+ import type { GitHubBotNameResolver, GitHubChannelCredentials } from "#public/channels/github/auth.js";
4
4
  import { type GitHubComment } from "#public/channels/github/inbound.js";
5
5
  import type { GitHubChannelEvents, GitHubInboundContext, GitHubInboundResult, GitHubProgressConfig } from "#public/channels/github/githubChannel.js";
6
6
  /**
@@ -12,14 +12,14 @@ import type { GitHubChannelEvents, GitHubInboundContext, GitHubInboundResult, Gi
12
12
  export declare function defaultGitHubAuth(ctx: GitHubInboundContext): SessionAuthContext;
13
13
  /** Options used by the built-in GitHub comment dispatch hook. */
14
14
  export interface GitHubDefaultDispatchOptions {
15
- readonly botName?: string;
15
+ readonly botName?: GitHubBotNameResolver;
16
16
  }
17
17
  /** Default comment hook: dispatch only when the comment `@mention`s the bot. */
18
- export declare function defaultOnComment(ctx: GitHubInboundContext, comment: GitHubComment, options: GitHubDefaultDispatchOptions): GitHubInboundResult;
18
+ export declare function defaultOnComment(ctx: GitHubInboundContext, comment: GitHubComment, options: GitHubDefaultDispatchOptions): Promise<GitHubInboundResult>;
19
19
  /** Options used by built-in GitHub event handlers. */
20
20
  export interface GitHubDefaultEventOptions {
21
21
  readonly api?: GitHubApiOptions;
22
- readonly botName?: string;
22
+ readonly botName?: GitHubBotNameResolver;
23
23
  readonly credentials?: GitHubChannelCredentials;
24
24
  readonly progress?: GitHubProgressConfig;
25
25
  }
@@ -1,4 +1,4 @@
1
- import{createLogger,extractErrorId,formatErrorHint,logError}from"#internal/logging.js";import{checkoutGitHubRepository}from"#public/channels/github/checkout.js";import{shouldDispatchGitHubComment}from"#public/channels/github/inbound.js";import{splitGitHubCommentBody}from"#public/channels/github/limits.js";const log=createLogger(`github.defaults`);function defaultGitHubAuth(e){let{sender:t}=e;return{attributes:{conversation_kind:e.conversation.kind,delivery_id:e.delivery.id,installation_id:String(e.github.installationId??``),issue_number:String(e.conversation.issueNumber??``),pull_request_number:String(e.conversation.pullRequestNumber??``),repository:e.repository.fullName,repository_id:String(e.repository.id),user_login:t.login,user_type:t.type},authenticator:`github-webhook`,issuer:`github:${e.repository.owner}`,principalId:`github:${t.id}`,principalType:t.type===`Bot`?`service`:`user`,subject:t.login}}function defaultOnComment(e,t,n){return shouldDispatchGitHubComment({author:t.author,body:t.body,botName:n.botName})?{auth:defaultGitHubAuth(e)}:null}function createDefaultEvents(e={}){return{async"turn.started"(t,n,i){if(e.progress?.reactions!==!1)try{await n.thread.react(`eyes`)}catch(e){logError(log,`GitHub reaction failed — swallowed`,e)}await checkoutRepositoryForTurn(n,i,e)},async"message.completed"(e,t,n){e.finishReason===`tool-calls`||!e.message||await postCommentChunks(t,e.message)},async"input.requested"(t,n,r){if(t.requests.length===0)return;let i=t.requests.map(renderInputRequest),a=renderReplyInstruction(t.requests,e.botName);a!==void 0&&i.push(a),await postCommentChunks(n,i.join(`
1
+ import{createLogger,extractErrorId,formatErrorHint,logError}from"#internal/logging.js";import{checkoutGitHubRepository}from"#public/channels/github/checkout.js";import{shouldDispatchGitHubComment}from"#public/channels/github/inbound.js";import{splitGitHubCommentBody}from"#public/channels/github/limits.js";const log=createLogger(`github.defaults`);function defaultGitHubAuth(e){let{sender:t}=e;return{attributes:{conversation_kind:e.conversation.kind,delivery_id:e.delivery.id,installation_id:String(e.github.installationId??``),issue_number:String(e.conversation.issueNumber??``),pull_request_number:String(e.conversation.pullRequestNumber??``),repository:e.repository.fullName,repository_id:String(e.repository.id),user_login:t.login,user_type:t.type},authenticator:`github-webhook`,issuer:`github:${e.repository.owner}`,principalId:`github:${t.id}`,principalType:t.type===`Bot`?`service`:`user`,subject:t.login}}async function defaultOnComment(e,t,n){return shouldDispatchGitHubComment({author:t.author,body:t.body,botName:await n.botName?.()})?{auth:defaultGitHubAuth(e)}:null}function createDefaultEvents(e={}){return{async"turn.started"(t,n,i){if(e.progress?.reactions!==!1)try{await n.thread.react(`eyes`)}catch(e){logError(log,`GitHub reaction failed — swallowed`,e)}await checkoutRepositoryForTurn(n,i,e)},async"message.completed"(e,t,n){e.finishReason===`tool-calls`||!e.message||await postCommentChunks(t,e.message)},async"input.requested"(t,n,r){if(t.requests.length===0)return;let i=t.requests.map(renderInputRequest),a=renderReplyInstruction(t.requests,await e.botName?.());a!==void 0&&i.push(a),await postCommentChunks(n,i.join(`
2
2
 
3
3
  `))},async"session.failed"(e,r){let i=formatErrorHint(e),a=extractErrorId(e.details);await postFailure(r,[`This session could not recover from an error${i}.`,``,`Start a new comment to continue.`,...a?[``,`Error id: ${a}`]:[]].join(`
4
4
  `))},async"turn.failed"(e,r,i){let a=formatErrorHint(e),o=extractErrorId(e.details);await postFailure(r,[`I hit an error while handling your request${a}.`,``,`Please try again, rephrase, or reach out if it keeps failing.`,...o?[``,`Error id: ${o}`]:[]].join(`
@@ -1,10 +1,11 @@
1
1
  import type { ChannelFrom } from "#channel/channel-operations.js";
2
+ import type { GitHubBotNameResolver } from "#public/channels/github/auth.js";
2
3
  import { type GitHubCheckRunWebhookEvent, type GitHubCheckSuiteWebhookEvent, type GitHubIssueCommentEvent, type GitHubIssueWebhookEvent, type GitHubPullRequestReviewCommentEvent, type GitHubPullRequestWebhookEvent, type GitHubWorkflowRunWebhookEvent } from "#public/channels/github/inbound.js";
3
4
  import { type GitHubChannelState } from "#public/channels/github/state.js";
4
5
  import type { GitHubChannelConfig } from "#public/channels/github/githubChannel.js";
5
6
  /** Dispatches a bot-directed issue or PR timeline comment into the runtime. */
6
7
  export declare function dispatchIssueComment(input: {
7
- readonly botName: string | undefined;
8
+ readonly botName: GitHubBotNameResolver;
8
9
  readonly config: GitHubChannelConfig;
9
10
  readonly event: GitHubIssueCommentEvent;
10
11
  readonly handler: NonNullable<GitHubChannelConfig["onComment"]>;
@@ -12,7 +13,7 @@ export declare function dispatchIssueComment(input: {
12
13
  }): Promise<void>;
13
14
  /** Dispatches a bot-directed inline pull-request review comment. */
14
15
  export declare function dispatchPullRequestReviewComment(input: {
15
- readonly botName: string | undefined;
16
+ readonly botName: GitHubBotNameResolver;
16
17
  readonly config: GitHubChannelConfig;
17
18
  readonly event: GitHubPullRequestReviewCommentEvent;
18
19
  readonly handler: NonNullable<GitHubChannelConfig["onComment"]>;
@@ -1 +1 @@
1
- import{createLogger,logError}from"#internal/logging.js";import{extractGitHubCommentTrigger,formatGitHubContextBlock}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{buildGitHubPullRequestContext,mergeGitHubContext}from"#public/channels/github/pr-context.js";import{continuationTokenFromState,stateFromCiEvent,stateFromIssueCommentEvent,stateFromIssueEvent,stateFromPullRequestEvent,stateFromPullRequestReviewCommentEvent}from"#public/channels/github/state.js";const log=createLogger(`github.dispatch`);async function dispatchIssueComment(e){if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,e.botName))return;let t=buildInboundContext(e.config,e.event);await dispatchCommentTurn({body:e.event.comment.body,botName:e.botName,commentUrl:e.event.comment.htmlUrl,event:e.event,handlerResult:()=>e.handler(t,toGitHubComment(e.event.comment)),config:e.config,from:e.from,state:stateFromIssueCommentEvent(e.event)})}async function dispatchPullRequestReviewComment(e){if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,e.botName))return;let t=buildInboundContext(e.config,e.event);await dispatchCommentTurn({body:e.event.comment.body,botName:e.botName,commentUrl:e.event.comment.htmlUrl,event:e.event,handlerResult:()=>e.handler(t,toGitHubComment(e.event.comment)),config:e.config,from:e.from,state:stateFromPullRequestReviewCommentEvent(e.event)})}async function dispatchIssue(e){let t=buildInboundContext(e.config,e.event);await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handler(t,e.event.issue),message:formatIssueEventMessage(e.event),from:e.from,state:stateFromIssueEvent(e.event)})}async function dispatchPullRequest(e){let t=buildInboundContext(e.config,e.event);await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handler(t,e.event.pullRequest),message:formatPullRequestEventMessage(e.event),from:e.from,state:stateFromPullRequestEvent(e.event)})}async function dispatchCheckSuite(e){await dispatchCiEvent({...e,ci:e.event.checkSuite,handlerResult:t=>e.handler(t,e.event.checkSuite),label:`Check suite`})}async function dispatchCheckRun(e){await dispatchCiEvent({...e,ci:e.event.checkRun,handlerResult:t=>e.handler(t,e.event.checkRun),label:`Check run`})}async function dispatchWorkflowRun(e){await dispatchCiEvent({...e,ci:e.event.workflowRun,handlerResult:t=>e.handler(t,e.event.workflowRun),label:`Workflow run`})}async function dispatchCiEvent(e){let t=stateFromCiEvent(e.event),n=buildInboundContext(e.config,e.event);if(t.pullRequestNumber===null){await runInboundHandler({event:e.event,handlerResult:()=>e.handlerResult(n)})!=null&&log.warn(`GitHub CI event cannot dispatch without an associated pull request`,{deliveryId:e.event.delivery.id,event:e.event.kind});return}await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handlerResult(n),message:formatCiEventMessage(e.label,e.ci),from:e.from,state:t})}async function dispatchWebhookEventTurn(e){let t=await runInboundHandler({event:e.event,handlerResult:e.handlerResult});t!=null&&await sendGitHubTurn({auth:t.auth,event:e.event,message:e.message,context:mergeGitHubContext({github:await buildPullRequestContext(e.config,e.state,e.event.delivery.id),hook:t.context}),from:e.from,state:e.state})}async function dispatchCommentTurn(e){let t=await runInboundHandler({event:e.event,handlerResult:e.handlerResult});if(t==null)return;let r=extractGitHubCommentTrigger({body:e.body,botName:e.botName})?.message??e.body.trim();await sendGitHubTurn({auth:t.auth,commentUrl:e.commentUrl,event:e.event,message:r,context:mergeGitHubContext({github:await buildPullRequestContext(e.config,e.state,e.event.delivery.id),hook:t.context}),from:e.from,state:e.state})}async function runInboundHandler(e){try{return await e.handlerResult()}catch(n){logError(log,`GitHub inbound handler failed`,n,{deliveryId:e.event.delivery.id});return}}async function sendGitHubTurn(e){let n=formatGitHubContextBlock({deliveryId:e.event.delivery.id,commentUrl:e.commentUrl,headSha:e.state.headSha,issueNumber:e.state.issueNumber,pullRequestNumber:e.state.pullRequestNumber,repository:e.event.repository,sender:e.event.sender});try{await e.from(continuationTokenFromState(e.state)).send(e.message,{auth:e.auth,context:[n,...e.context??[]],state:e.state})}catch(n){logError(log,e.logMessage??`GitHub delivery failed`,n,{deliveryId:e.event.delivery.id})}}async function buildPullRequestContext(e,n,r){try{return await buildGitHubPullRequestContext({api:e.api,baseSha:n.baseSha,config:e.pullRequestContext,credentials:e.credentials,headSha:n.headSha,installationId:n.installationId??void 0,owner:n.owner,pullRequestNumber:n.pullRequestNumber,repo:n.repo})}catch(e){logError(log,`GitHub pull-request context failed — swallowed`,e,{deliveryId:r});return}}function buildInboundContext(e,t){let n=buildGitHubBinding({config:e,state:t.kind===`check_suite`||t.kind===`check_run`||t.kind===`workflow_run`?stateFromCiEvent(t):t.kind===`issue_comment`?stateFromIssueCommentEvent(t):t.kind===`issues`?stateFromIssueEvent(t):t.kind===`pull_request`?stateFromPullRequestEvent(t):stateFromPullRequestReviewCommentEvent(t)});return{conversation:t.conversation,delivery:t.delivery,github:n.github,repository:t.repository,sender:t.sender,thread:n.thread}}function toGitHubComment(e){return{author:e.author,body:e.body,htmlUrl:e.htmlUrl,id:e.id,raw:e.raw,url:e.url}}function formatIssueEventMessage(e){let t=readString(e.issue.raw.title);return`Issue ${e.issue.action}: #${e.issue.issueNumber}${t?` ${t}`:``}`}function formatPullRequestEventMessage(e){let t=readString(e.pullRequest.raw.title);return`Pull request ${e.pullRequest.action}: #${e.pullRequest.pullRequestNumber}${t?` ${t}`:``}`}function formatCiEventMessage(e,t){let n=t.conclusion??t.status;return`${e} ${t.action}: ${ciEventId(t)}${n?` (${n})`:``}`}function ciEventId(e){return`checkSuiteId`in e?e.checkSuiteId:`checkRunId`in e?e.checkRunId:e.workflowRunId}function isIgnoredInboundComment(e,t,n){if(e.includes(`<!-- eve:github:`)||t?.type===`Bot`)return!0;let r=n?`${n}[bot]`.toLowerCase():``;return r.length>0&&t?.login.toLowerCase()===r}function readString(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}export{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun};
1
+ import{createLogger,logError}from"#internal/logging.js";import{extractGitHubCommentTrigger,formatGitHubContextBlock}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{buildGitHubPullRequestContext,mergeGitHubContext}from"#public/channels/github/pr-context.js";import{continuationTokenFromState,stateFromCiEvent,stateFromIssueCommentEvent,stateFromIssueEvent,stateFromPullRequestEvent,stateFromPullRequestReviewCommentEvent}from"#public/channels/github/state.js";const log=createLogger(`github.dispatch`);async function dispatchIssueComment(e){let t=await e.botName();if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,t))return;let n=buildInboundContext(e.config,e.event);await dispatchCommentTurn({body:e.event.comment.body,botName:t,commentUrl:e.event.comment.htmlUrl,event:e.event,handlerResult:()=>e.handler(n,toGitHubComment(e.event.comment)),config:e.config,from:e.from,state:stateFromIssueCommentEvent(e.event)})}async function dispatchPullRequestReviewComment(e){let t=await e.botName();if(isIgnoredInboundComment(e.event.comment.body,e.event.comment.author,t))return;let n=buildInboundContext(e.config,e.event);await dispatchCommentTurn({body:e.event.comment.body,botName:t,commentUrl:e.event.comment.htmlUrl,event:e.event,handlerResult:()=>e.handler(n,toGitHubComment(e.event.comment)),config:e.config,from:e.from,state:stateFromPullRequestReviewCommentEvent(e.event)})}async function dispatchIssue(e){let t=buildInboundContext(e.config,e.event);await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handler(t,e.event.issue),message:formatIssueEventMessage(e.event),from:e.from,state:stateFromIssueEvent(e.event)})}async function dispatchPullRequest(e){let t=buildInboundContext(e.config,e.event);await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handler(t,e.event.pullRequest),message:formatPullRequestEventMessage(e.event),from:e.from,state:stateFromPullRequestEvent(e.event)})}async function dispatchCheckSuite(e){await dispatchCiEvent({...e,ci:e.event.checkSuite,handlerResult:t=>e.handler(t,e.event.checkSuite),label:`Check suite`})}async function dispatchCheckRun(e){await dispatchCiEvent({...e,ci:e.event.checkRun,handlerResult:t=>e.handler(t,e.event.checkRun),label:`Check run`})}async function dispatchWorkflowRun(e){await dispatchCiEvent({...e,ci:e.event.workflowRun,handlerResult:t=>e.handler(t,e.event.workflowRun),label:`Workflow run`})}async function dispatchCiEvent(e){let t=stateFromCiEvent(e.event),n=buildInboundContext(e.config,e.event);if(t.pullRequestNumber===null){await runInboundHandler({event:e.event,handlerResult:()=>e.handlerResult(n)})!=null&&log.warn(`GitHub CI event cannot dispatch without an associated pull request`,{deliveryId:e.event.delivery.id,event:e.event.kind});return}await dispatchWebhookEventTurn({config:e.config,event:e.event,handlerResult:()=>e.handlerResult(n),message:formatCiEventMessage(e.label,e.ci),from:e.from,state:t})}async function dispatchWebhookEventTurn(e){let t=await runInboundHandler({event:e.event,handlerResult:e.handlerResult});t!=null&&await sendGitHubTurn({auth:t.auth,event:e.event,message:e.message,context:mergeGitHubContext({github:await buildPullRequestContext(e.config,e.state,e.event.delivery.id),hook:t.context}),from:e.from,state:e.state})}async function dispatchCommentTurn(e){let t=await runInboundHandler({event:e.event,handlerResult:e.handlerResult});if(t==null)return;let r=extractGitHubCommentTrigger({body:e.body,botName:e.botName})?.message??e.body.trim();await sendGitHubTurn({auth:t.auth,commentUrl:e.commentUrl,event:e.event,message:r,context:mergeGitHubContext({github:await buildPullRequestContext(e.config,e.state,e.event.delivery.id),hook:t.context}),from:e.from,state:e.state})}async function runInboundHandler(e){try{return await e.handlerResult()}catch(n){logError(log,`GitHub inbound handler failed`,n,{deliveryId:e.event.delivery.id});return}}async function sendGitHubTurn(e){let n=formatGitHubContextBlock({deliveryId:e.event.delivery.id,commentUrl:e.commentUrl,headSha:e.state.headSha,issueNumber:e.state.issueNumber,pullRequestNumber:e.state.pullRequestNumber,repository:e.event.repository,sender:e.event.sender});try{await e.from(continuationTokenFromState(e.state)).send(e.message,{auth:e.auth,context:[n,...e.context??[]],state:e.state})}catch(n){logError(log,e.logMessage??`GitHub delivery failed`,n,{deliveryId:e.event.delivery.id})}}async function buildPullRequestContext(e,n,r){try{return await buildGitHubPullRequestContext({api:e.api,baseSha:n.baseSha,config:e.pullRequestContext,credentials:e.credentials,headSha:n.headSha,installationId:n.installationId??void 0,owner:n.owner,pullRequestNumber:n.pullRequestNumber,repo:n.repo})}catch(e){logError(log,`GitHub pull-request context failed — swallowed`,e,{deliveryId:r});return}}function buildInboundContext(e,t){let n=buildGitHubBinding({config:e,state:t.kind===`check_suite`||t.kind===`check_run`||t.kind===`workflow_run`?stateFromCiEvent(t):t.kind===`issue_comment`?stateFromIssueCommentEvent(t):t.kind===`issues`?stateFromIssueEvent(t):t.kind===`pull_request`?stateFromPullRequestEvent(t):stateFromPullRequestReviewCommentEvent(t)});return{conversation:t.conversation,delivery:t.delivery,github:n.github,repository:t.repository,sender:t.sender,thread:n.thread}}function toGitHubComment(e){return{author:e.author,body:e.body,htmlUrl:e.htmlUrl,id:e.id,raw:e.raw,url:e.url}}function formatIssueEventMessage(e){let t=readString(e.issue.raw.title);return`Issue ${e.issue.action}: #${e.issue.issueNumber}${t?` ${t}`:``}`}function formatPullRequestEventMessage(e){let t=readString(e.pullRequest.raw.title);return`Pull request ${e.pullRequest.action}: #${e.pullRequest.pullRequestNumber}${t?` ${t}`:``}`}function formatCiEventMessage(e,t){let n=t.conclusion??t.status;return`${e} ${t.action}: ${ciEventId(t)}${n?` (${n})`:``}`}function ciEventId(e){return`checkSuiteId`in e?e.checkSuiteId:`checkRunId`in e?e.checkRunId:e.workflowRunId}function isIgnoredInboundComment(e,t,n){if(e.includes(`<!-- eve:github:`)||t?.type===`Bot`)return!0;let r=n?`${n}[bot]`.toLowerCase():``;return r.length>0&&t?.login.toLowerCase()===r}function readString(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}export{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun};
@@ -4,7 +4,7 @@ import type { ChannelContinuationOps } from "#public/definitions/channel.js";
4
4
  import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
5
5
  import { type GitHubHandle, type GitHubThread } from "#public/channels/github/binding.js";
6
6
  import { type GitHubApiOptions } from "#public/channels/github/api.js";
7
- import type { GitHubChannelCredentials } from "#public/channels/github/auth.js";
7
+ import { type GitHubBotName, type GitHubChannelCredentials } from "#public/channels/github/auth.js";
8
8
  import { type GitHubCheckRunEvent, type GitHubCheckSuiteEvent, type GitHubComment, type GitHubConversationRef, type GitHubDelivery, type GitHubIssueEvent, type GitHubPullRequestEvent, type GitHubRepositoryRef, type GitHubUser, type GitHubWorkflowRunEvent } from "#public/channels/github/inbound.js";
9
9
  import { type GitHubChannelState } from "#public/channels/github/state.js";
10
10
  import type { GitHubPullRequestContextConfig } from "#public/channels/github/pr-context.js";
@@ -96,7 +96,12 @@ export interface GitHubChannelEvents {
96
96
  /** Configuration for {@link githubChannel}. */
97
97
  export interface GitHubChannelConfig {
98
98
  readonly api?: GitHubApiOptions;
99
- readonly botName?: string;
99
+ /**
100
+ * The name the channel answers to in `@mentions`, supplied directly or
101
+ * resolved lazily on first use inside request handling. Falls back to the
102
+ * credentials' `appSlug`, then `GITHUB_APP_SLUG`.
103
+ */
104
+ readonly botName?: GitHubBotName;
100
105
  readonly credentials?: GitHubChannelCredentials;
101
106
  readonly events?: GitHubChannelEvents;
102
107
  readonly progress?: GitHubProgressConfig;
@@ -1 +1 @@
1
- import{createLogger}from"#internal/logging.js";import{readNonEmptyString}from"#shared/guards.js";import{POST,defineChannel}from"#public/definitions/channel.js";import{getGitHubRepository}from"#public/channels/github/api.js";import{parseGitHubWebhookEvent}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{continuationTokenFromState,conversationFromState,initialGitHubState,stateFromReceiveTarget}from"#public/channels/github/state.js";import{GITHUB_CHANNEL_DEFAULT_ROUTE}from"#public/channels/github/constants.js";import{createDefaultEvents,defaultOnComment}from"#public/channels/github/defaults.js";import{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun}from"#public/channels/github/dispatch.js";import{verifyGitHubRequest}from"#public/channels/github/verify.js";const log=createLogger(`github.channel`);function githubChannel(e={}){let c=e.botName??process.env.GITHUB_APP_SLUG,d={botName:c},f={...createDefaultEvents({api:e.api,botName:c,credentials:e.credentials,progress:e.progress}),...e.events};return defineChannel({kindHint:`github`,turnPolicy:e.turnPolicy,state:initialGitHubState(),context(t,n){return rebuildGitHubContext(t,n,e)},routes:[POST(e.route??GITHUB_CHANNEL_DEFAULT_ROUTE,async(t,{from:n,waitUntil:r})=>{let i=await verifyInbound(t,e.credentials);if(i===null)return new Response(`unauthorized`,{status:401});let o=missingGitHubWebhookHeaders(t.headers),s;try{s=parseGitHubWebhookEvent({body:i,contentType:t.headers.get(`content-type`)??void 0,headers:t.headers})}catch(e){return log.warn(`inbound GitHub body is not valid JSON`,{error:e}),jsonOk({ignored:!0,ok:!0})}return s===null?(o.length>0&&log.warn(`GitHub webhook ignored because standard headers were missing`,{missingHeaders:o}),jsonOk({ignored:!0,ok:!0})):(o.length>0&&log.warn(`GitHub webhook missing standard headers; inferred metadata from payload`,{deliveryId:s.delivery.id,event:s.delivery.event,missingHeaders:o,repository:s.repository.fullName}),s.kind===`ping`?jsonOk({ok:!0}):s.kind===`issue_comment`&&s.action===`created`?(r(dispatchIssueComment({botName:c,config:e,event:s,handler:e.onComment??((e,t)=>defaultOnComment(e,t,d)),from:n})),jsonOk({ok:!0})):s.kind===`pull_request_review_comment`&&s.action===`created`?(r(dispatchPullRequestReviewComment({botName:c,config:e,event:s,handler:e.onComment??((e,t)=>defaultOnComment(e,t,d)),from:n})),jsonOk({ok:!0})):s.kind===`issues`&&e.onIssue!==void 0?(r(dispatchIssue({config:e,event:s,handler:e.onIssue,from:n})),jsonOk({ok:!0})):s.kind===`pull_request`&&e.onPullRequest!==void 0?(r(dispatchPullRequest({config:e,event:s,handler:e.onPullRequest,from:n})),jsonOk({ok:!0})):s.kind===`check_suite`&&e.onCheckSuite!==void 0?(r(dispatchCheckSuite({config:e,event:s,handler:e.onCheckSuite,from:n})),jsonOk({ok:!0})):s.kind===`check_run`&&e.onCheckRun!==void 0?(r(dispatchCheckRun({config:e,event:s,handler:e.onCheckRun,from:n})),jsonOk({ok:!0})):s.kind===`workflow_run`&&e.onWorkflowRun!==void 0?(r(dispatchWorkflowRun({config:e,event:s,handler:e.onWorkflowRun,from:n})),jsonOk({ok:!0})):jsonOk({ignored:!0,ok:!0}))})],async receive(n,{from:r}){let a=n.target,c=readNonEmptyString(a.owner),l=readNonEmptyString(a.repo);if(c===void 0||l===void 0)throw Error(`githubChannel().receive requires target.owner and target.repo.`);if([a.issueNumber!==void 0,a.pullRequestNumber!==void 0].filter(Boolean).length!==1)throw Error(`githubChannel().receive requires exactly one of issueNumber or pullRequestNumber.`);let u=stateFromReceiveTarget({target:a,owner:c,repo:l,repositoryId:a.repositoryId??(await getGitHubRepository({api:e.api,credentials:e.credentials,installationId:a.installationId,owner:c,repo:l})).id});if(a.initialMessage!==void 0){let{thread:t}=buildGitHubBinding({config:e,state:u});await t.post(a.initialMessage)}return r(continuationTokenFromState(u)).send(n.message,{auth:n.auth,state:u})},events:f})}function rebuildGitHubContext(e,t,n){let r=buildGitHubBinding({config:n,state:e});return{conversation:conversationFromState(e),github:r.github,repository:r.github.repository,state:e,thread:r.thread}}async function verifyInbound(e,t){try{return await verifyGitHubRequest(e,{webhookSecret:t?.webhookSecret,webhookVerifier:t?.webhookVerifier})}catch(e){return log.warn(`github inbound verification failed`,{error:e}),null}}function missingGitHubWebhookHeaders(e){return[`x-github-event`,`x-github-delivery`].filter(t=>{let n=e.get(t);return n===null||n.trim().length===0})}function jsonOk(e){return new Response(JSON.stringify(e),{headers:{"content-type":`application/json; charset=utf-8`},status:200})}export{githubChannel};
1
+ import{createLogger}from"#internal/logging.js";import{readNonEmptyString}from"#shared/guards.js";import{POST,defineChannel}from"#public/definitions/channel.js";import{createGitHubBotNameResolver}from"#public/channels/github/auth.js";import{getGitHubRepository}from"#public/channels/github/api.js";import{parseGitHubWebhookEvent}from"#public/channels/github/inbound.js";import{buildGitHubBinding}from"#public/channels/github/binding.js";import{continuationTokenFromState,conversationFromState,initialGitHubState,stateFromReceiveTarget}from"#public/channels/github/state.js";import{GITHUB_CHANNEL_DEFAULT_ROUTE}from"#public/channels/github/constants.js";import{createDefaultEvents,defaultOnComment}from"#public/channels/github/defaults.js";import{dispatchCheckRun,dispatchCheckSuite,dispatchIssue,dispatchIssueComment,dispatchPullRequest,dispatchPullRequestReviewComment,dispatchWorkflowRun}from"#public/channels/github/dispatch.js";import{verifyGitHubRequest}from"#public/channels/github/verify.js";const log=createLogger(`github.channel`);function githubChannel(e={}){let c=createGitHubBotNameResolver({botName:e.botName,credentials:e.credentials}),u={botName:c},d={...createDefaultEvents({api:e.api,botName:c,credentials:e.credentials,progress:e.progress}),...e.events};return defineChannel({kindHint:`github`,turnPolicy:e.turnPolicy,state:initialGitHubState(),context(t,n){return rebuildGitHubContext(t,n,e)},routes:[POST(e.route??GITHUB_CHANNEL_DEFAULT_ROUTE,async(t,{from:n,waitUntil:r})=>{let i=await verifyInbound(t,e.credentials);if(i===null)return new Response(`unauthorized`,{status:401});let a=missingGitHubWebhookHeaders(t.headers),s;try{s=parseGitHubWebhookEvent({body:i,contentType:t.headers.get(`content-type`)??void 0,headers:t.headers})}catch(e){return log.warn(`inbound GitHub body is not valid JSON`,{error:e}),jsonOk({ignored:!0,ok:!0})}return s===null?(a.length>0&&log.warn(`GitHub webhook ignored because standard headers were missing`,{missingHeaders:a}),jsonOk({ignored:!0,ok:!0})):(a.length>0&&log.warn(`GitHub webhook missing standard headers; inferred metadata from payload`,{deliveryId:s.delivery.id,event:s.delivery.event,missingHeaders:a,repository:s.repository.fullName}),s.kind===`ping`?jsonOk({ok:!0}):s.kind===`issue_comment`&&s.action===`created`?(r(dispatchIssueComment({botName:c,config:e,event:s,handler:e.onComment??((e,t)=>defaultOnComment(e,t,u)),from:n})),jsonOk({ok:!0})):s.kind===`pull_request_review_comment`&&s.action===`created`?(r(dispatchPullRequestReviewComment({botName:c,config:e,event:s,handler:e.onComment??((e,t)=>defaultOnComment(e,t,u)),from:n})),jsonOk({ok:!0})):s.kind===`issues`&&e.onIssue!==void 0?(r(dispatchIssue({config:e,event:s,handler:e.onIssue,from:n})),jsonOk({ok:!0})):s.kind===`pull_request`&&e.onPullRequest!==void 0?(r(dispatchPullRequest({config:e,event:s,handler:e.onPullRequest,from:n})),jsonOk({ok:!0})):s.kind===`check_suite`&&e.onCheckSuite!==void 0?(r(dispatchCheckSuite({config:e,event:s,handler:e.onCheckSuite,from:n})),jsonOk({ok:!0})):s.kind===`check_run`&&e.onCheckRun!==void 0?(r(dispatchCheckRun({config:e,event:s,handler:e.onCheckRun,from:n})),jsonOk({ok:!0})):s.kind===`workflow_run`&&e.onWorkflowRun!==void 0?(r(dispatchWorkflowRun({config:e,event:s,handler:e.onWorkflowRun,from:n})),jsonOk({ok:!0})):jsonOk({ignored:!0,ok:!0}))})],async receive(n,{from:r}){let i=n.target,o=readNonEmptyString(i.owner),c=readNonEmptyString(i.repo);if(o===void 0||c===void 0)throw Error(`githubChannel().receive requires target.owner and target.repo.`);if([i.issueNumber!==void 0,i.pullRequestNumber!==void 0].filter(Boolean).length!==1)throw Error(`githubChannel().receive requires exactly one of issueNumber or pullRequestNumber.`);let l=stateFromReceiveTarget({target:i,owner:o,repo:c,repositoryId:i.repositoryId??(await getGitHubRepository({api:e.api,credentials:e.credentials,installationId:i.installationId,owner:o,repo:c})).id});if(i.initialMessage!==void 0){let{thread:t}=buildGitHubBinding({config:e,state:l});await t.post(i.initialMessage)}return r(continuationTokenFromState(l)).send(n.message,{auth:n.auth,state:l})},events:d})}function rebuildGitHubContext(e,t,n){let r=buildGitHubBinding({config:n,state:e});return{conversation:conversationFromState(e),github:r.github,repository:r.github.repository,state:e,thread:r.thread}}async function verifyInbound(e,t){try{return await verifyGitHubRequest(e,{webhookSecret:t?.webhookSecret,webhookVerifier:t?.webhookVerifier})}catch(e){return log.warn(`github inbound verification failed`,{error:e}),null}}function missingGitHubWebhookHeaders(e){return[`x-github-event`,`x-github-delivery`].filter(t=>{let n=e.get(t);return n===null||n.trim().length===0})}function jsonOk(e){return new Response(JSON.stringify(e),{headers:{"content-type":`application/json; charset=utf-8`},status:200})}export{githubChannel};
@@ -1,6 +1,6 @@
1
1
  export { GitHubApiError, type GitHubApiMethod, type GitHubApiOptions, type GitHubApiResponse, type GitHubJsonObject, type GitHubPostedComment, type GitHubReactionContent, } from "#public/channels/github/api.js";
2
2
  export { type GitHubHandle, type GitHubThread } from "#public/channels/github/binding.js";
3
- export { type GitHubAppId, type GitHubChannelCredentials, type GitHubInstallationToken, type GitHubPrivateKey, type GitHubWebhookSecret, } from "#public/channels/github/auth.js";
3
+ export { type GitHubAppId, type GitHubBotName, type GitHubChannelCredentials, type GitHubInstallationToken, type GitHubPrivateKey, type GitHubWebhookSecret, } from "#public/channels/github/auth.js";
4
4
  export { defaultGitHubAuth } from "#public/channels/github/defaults.js";
5
5
  export { type GitHubAppRef, type GitHubCheckRunEvent, type GitHubCheckSuiteEvent, type GitHubCiEvent, type GitHubCiPayload, type GitHubComment, type GitHubConversationKind, type GitHubConversationRef, type GitHubDelivery, type GitHubIssueAction, type GitHubIssueEvent, type GitHubPullRequestAction, type GitHubPullRequestEvent, type GitHubRepositoryRef, type GitHubUser, type GitHubWorkflowRunEvent, } from "#public/channels/github/inbound.js";
6
6
  export { githubChannel, type GitHubChannel, type GitHubChannelConfig, type GitHubChannelEvents, type GitHubEventContext, type GitHubInboundContext, type GitHubInboundResult, type GitHubInboundResultOrPromise, type GitHubProgressConfig, type GitHubReceiveTarget, } from "#public/channels/github/githubChannel.js";
@@ -1,15 +1,25 @@
1
+ import { type DynamicResolveContext, type DynamicSentinel } from "#shared/dynamic-tool-definition.js";
1
2
  import type { ExactDefinition } from "#public/definitions/exact.js";
2
3
  import type { PublicInstructionsDefinition } from "#shared/instructions-definition.js";
3
4
  export type InstructionsDefinition = Readonly<PublicInstructionsDefinition>;
4
5
  /**
5
- * Defines an instructions prompt in TypeScript from a `{ markdown }`
6
- * definition.
6
+ * Defines instructions in TypeScript from a `{ content, role? }`
7
+ * definition. Omitted `role` defaults to `"system"`.
7
8
  *
8
9
  * Use it to return instructions from a `defineDynamic` resolver in
9
- * `agent/instructions/`; the returned markdown lowers to a single
10
- * `{ role: "system" }` message. For a fixed prompt with no resolver,
10
+ * `agent/instructions/`. For a fixed prompt with no resolver,
11
11
  * author `instructions.md` instead. The result is branded so the dynamic
12
12
  * instruction lifecycle can validate that a resolver return came through
13
13
  * this helper.
14
14
  */
15
15
  export declare function defineInstructions<TInstructions extends InstructionsDefinition>(definition: ExactDefinition<TInstructions, InstructionsDefinition>): TInstructions;
16
+ export type DynamicInstructionsResult = InstructionsDefinition | null;
17
+ export type DynamicInstructionsEvents = {
18
+ readonly [K in "session.started" | "turn.started"]?: (event: unknown, ctx: DynamicResolveContext) => DynamicInstructionsResult | Promise<DynamicInstructionsResult>;
19
+ };
20
+ /**
21
+ * Defines a runtime instructions resolver for session and turn boundaries.
22
+ */
23
+ export declare function defineDynamic<const TEvents extends DynamicInstructionsEvents>(definition: {
24
+ readonly events: ExactDefinition<TEvents, DynamicInstructionsEvents>;
25
+ }): DynamicSentinel<DynamicInstructionsResult>;
@@ -1 +1 @@
1
- import{INSTRUCTIONS_BRAND}from"#shared/dynamic-tool-definition.js";function defineInstructions(e){return Object.assign(e,{[INSTRUCTIONS_BRAND]:!0}),e}export{defineInstructions};
1
+ import{DYNAMIC_SENTINEL_KIND,INSTRUCTIONS_BRAND}from"#shared/dynamic-tool-definition.js";import{stampDefinitionKey}from"#public/tool-result-narrowing.js";function defineInstructions(e){return Object.assign(e,{[INSTRUCTIONS_BRAND]:!0}),e}function defineDynamic(t){let n={kind:DYNAMIC_SENTINEL_KIND,events:t.events};return stampDefinitionKey(n,`dynamic-instructions:${Object.keys(t.events).join(`,`)}`),n}export{defineDynamic,defineInstructions};
@@ -157,7 +157,8 @@ export declare function defineTool<TReturn>(definition: {
157
157
  export declare function defineTool<TInput = unknown, TOutput = unknown>(definition: ToolDefinition<TInput, TOutput>): ToolDefinition<TInput, TOutput>;
158
158
  /**
159
159
  * Defines a dynamic resolver evaluated at runtime from stream-event
160
- * handlers. It is shared across four slots, and the directory it is
160
+ * handlers. It is shared across tools, skills, and agent definitions;
161
+ * the directory it is
161
162
  * authored in (not this function) decides what each handler must return
162
163
  * and which events are honored. The file's path-derived slug names the
163
164
  * single-entry case; a `Record<string, ...>` return names entries
@@ -168,17 +169,13 @@ export declare function defineTool<TInput = unknown, TOutput = unknown>(definiti
168
169
  * `Record<string, defineTool(...)>`, or `null`.
169
170
  * - `agent/skills/`: return a single `defineSkill(...)`, a
170
171
  * `Record<string, defineSkill(...)>`, or `null`.
171
- * - `agent/instructions/`: return a single `defineInstructions({ markdown })`,
172
- * which lowers to one `{ role: "system", content: markdown }` message,
173
- * or `null`. (Maps are not meaningful here.)
174
172
  * - `agent/subagents/<name>/agent.ts`: return `defineAgent(...)` to configure
175
173
  * and expose the subagent, or `null` to omit it.
176
174
  *
177
175
  * Per-slot events: tools resolvers run at `session.started`,
178
- * `turn.started`, and `step.started`. Instructions and skills resolvers
179
- * contribute to the system prompt, so for cache stability they run only
180
- * at `session.started` and `turn.started`; the runtime never invokes a
181
- * handler keyed on `step.started` in those slots.
176
+ * `turn.started`, and `step.started`. Skills resolvers run only at
177
+ * `session.started` and `turn.started`; the runtime never invokes a
178
+ * handler keyed on `step.started` in that slot.
182
179
  * Dynamic subagents run at `session.started` and `turn.started` only.
183
180
  *
184
181
  * ```ts
@@ -2,6 +2,5 @@
2
2
  * Instructions prompt authoring helpers for `agent/instructions.ts`
3
3
  * and `agent/instructions/*.ts` files.
4
4
  */
5
- export { defineInstructions, type InstructionsDefinition, } from "#public/definitions/instructions.js";
6
- export { defineDynamic } from "#public/definitions/tool.js";
5
+ export { defineDynamic, defineInstructions, type DynamicInstructionsEvents, type DynamicInstructionsResult, type InstructionsDefinition, } from "#public/definitions/instructions.js";
7
6
  export type { DynamicResolveContext, DynamicSentinel } from "#shared/dynamic-tool-definition.js";
@@ -1 +1 @@
1
- import{defineDynamic}from"#public/definitions/tool.js";import{defineInstructions}from"#public/definitions/instructions.js";export{defineDynamic,defineInstructions};
1
+ import{defineDynamic,defineInstructions}from"#public/definitions/instructions.js";export{defineDynamic,defineInstructions};
@@ -121,13 +121,14 @@ export interface InstrumentationDefinition {
121
121
  readonly events?: InstrumentationEvents;
122
122
  /**
123
123
  * Whether to record full model inputs in telemetry spans. Defaults to
124
- * `true` when `instrumentation.ts` is present. Set `false` for sensitive
125
- * inputs or to reduce span payload size.
124
+ * `false`. Set `true` only when the destination is approved to receive
125
+ * input content.
126
126
  */
127
127
  readonly recordInputs?: boolean;
128
128
  /**
129
129
  * Whether to record full model outputs in telemetry spans. Defaults to
130
- * `true` when `instrumentation.ts` is present.
130
+ * `false`. Set `true` only when the destination is approved to receive
131
+ * output content.
131
132
  */
132
133
  readonly recordOutputs?: boolean;
133
134
  /**
@@ -14,8 +14,8 @@ export type { SpanExporter, SpanProcessor } from "#compiled/@vercel/otel/index.j
14
14
  /**
15
15
  * Vercel Agent Runs, enabled by default in production.
16
16
  *
17
- * Export it from `agent/instrumentation/agent-runs.ts` to narrow content, or
18
- * export `disableInstrumentation()` from that file to turn it off.
17
+ * Export it from `agent/instrumentation/agent-runs.ts` to configure content
18
+ * capture, or export `disableInstrumentation()` from that file to turn it off.
19
19
  */
20
20
  export declare function agentRuns(options?: ContentOptions): OtelIntegration;
21
21
  /**
@@ -25,7 +25,8 @@ export declare function agentRuns(options?: ContentOptions): OtelIntegration;
25
25
  * backend, or export `disableInstrumentation()` from that file to turn it off.
26
26
  * Omitting the file leaves eve's default in place.
27
27
  *
28
- * `EVE_TRACES_CONTENT=off` narrows this destination and no other, so declining
29
- * content locally leaves what a hosted backend receives alone.
28
+ * `EVE_TRACES_CONTENT=on` opts the default local spool into content capture.
29
+ * `off` overrides this destination and no other, so declining content locally
30
+ * leaves what a hosted backend receives alone.
30
31
  */
31
32
  export declare function localTraces(options?: ContentOptions): OtelIntegration;
@@ -4,10 +4,10 @@
4
4
  * Reachable only with `experimental.instrumentationProviders` on. With the flag
5
5
  * off nothing discovers that directory, so these types compile but never run.
6
6
  */
7
- import type { InstrumentationCapture, InstrumentationEvent } from "#harness/instrumentation-lifecycle.js";
7
+ import type { InstrumentationCapture, InstrumentationEvent } from "#harness/instrumentation/lifecycle.js";
8
8
  import type { JsonValue } from "#public/types/json.js";
9
9
  export type { JsonValue } from "#public/types/json.js";
10
- export type { InstrumentationActionCompletedEvent, InstrumentationActionFailedEvent, InstrumentationActionKind, InstrumentationActionOutcome, InstrumentationActionOutput, InstrumentationActionStartedEvent, InstrumentationAttemptScope, InstrumentationCapture, InstrumentationChannelDeliveryInput, InstrumentationChannelDeliveryOutcome, InstrumentationChannelDeliveryRef, InstrumentationChannelDeliveryStartedEvent, InstrumentationChannelDeliveryTerminalEvent, InstrumentationContentPart, InstrumentationEvent, InstrumentationInputKind, InstrumentationInputOption, InstrumentationInputOutcome, InstrumentationInputRequest, InstrumentationInputRequestedEvent, InstrumentationInputResolvedEvent, InstrumentationInputResponse, InstrumentationModelCallCompletedEvent, InstrumentationModelCallFailedEvent, InstrumentationModelCallStartedEvent, InstrumentationModelRef, InstrumentationOperationRef, InstrumentationParentLineage, InstrumentationSessionFailedEvent, InstrumentationSessionSettledEvent, InstrumentationSessionStartedEvent, InstrumentationSessionTransitionEvent, InstrumentationStepAttemptMetadataEvent, InstrumentationStepAttemptCompletedEvent, InstrumentationStepAttemptFailedEvent, InstrumentationStepAttemptStartedEvent, InstrumentationStepAttemptTerminalEvent, InstrumentationToolCallCompletedEvent, InstrumentationToolCallFailedEvent, InstrumentationToolCallStartedEvent, InstrumentationToolOutput, InstrumentationTraceContext, InstrumentationTurnFailedEvent, InstrumentationTurnSettledEvent, InstrumentationTurnStartedEvent, InstrumentationTurnTerminalEvent, InstrumentationUsage, } from "#harness/instrumentation-lifecycle.js";
10
+ export type { InstrumentationActionCompletedEvent, InstrumentationActionFailedEvent, InstrumentationActionKind, InstrumentationActionOutcome, InstrumentationActionOutput, InstrumentationActionStartedEvent, InstrumentationAttemptScope, InstrumentationCapture, InstrumentationChannelDeliveryInput, InstrumentationChannelDeliveryOutcome, InstrumentationChannelDeliveryRef, InstrumentationChannelDeliveryStartedEvent, InstrumentationChannelDeliveryTerminalEvent, InstrumentationContentPart, InstrumentationEvent, InstrumentationInputKind, InstrumentationInputOption, InstrumentationInputOutcome, InstrumentationInputRequest, InstrumentationInputRequestedEvent, InstrumentationInputResolvedEvent, InstrumentationInputResponse, InstrumentationModelCallCompletedEvent, InstrumentationModelCallFailedEvent, InstrumentationModelCallStartedEvent, InstrumentationModelRef, InstrumentationOperationRef, InstrumentationParentLineage, InstrumentationSessionFailedEvent, InstrumentationSessionSettledEvent, InstrumentationSessionStartedEvent, InstrumentationSessionTransitionEvent, InstrumentationStepAttemptMetadataEvent, InstrumentationStepAttemptCompletedEvent, InstrumentationStepAttemptFailedEvent, InstrumentationStepAttemptStartedEvent, InstrumentationStepAttemptTerminalEvent, InstrumentationToolCallCompletedEvent, InstrumentationToolCallFailedEvent, InstrumentationToolCallStartedEvent, InstrumentationToolOutput, InstrumentationTraceContext, InstrumentationTurnFailedEvent, InstrumentationTurnSettledEvent, InstrumentationTurnStartedEvent, InstrumentationTurnTerminalEvent, InstrumentationUsage, } from "#harness/instrumentation/lifecycle.js";
11
11
  /**
12
12
  * Marks a value as having come from `defineInstrumentation` or a built-in
13
13
  * factory.
@@ -1 +1 @@
1
- import{joinRoutePrefix,normalizeOrigin,resolveProductionTarget}from"./routing.js";import{EVE_BASE_URL_ENV,resolveSharedEveDevServer}from"./dev-server.js";import{ensureEveVercelServicesConfig,mergeEveVercelConfig}from"./vercel-services.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isAbsolute,resolve}from"node:path";import{addImports,defineNuxtModule,extendRouteRules}from"@nuxt/kit";function resolveApplicationRoot(e,t){return t===void 0||t.length===0?e:isAbsolute(t)?t:resolve(e,t)}async function resolveEveProxyTarget(a){if(!a.dev)return resolveProductionTarget();let o=process.env[EVE_BASE_URL_ENV]?.trim();if(o&&o.length>0)return joinRoutePrefix(normalizeOrigin(o),EVE_ROUTE_PREFIX);let s=await resolveSharedEveDevServer(a.appRoot);return s.process!==void 0&&a.onDevServerSpawned?.(s.process),joinRoutePrefix(s.origin,EVE_ROUTE_PREFIX)}var module_default=defineNuxtModule({meta:{name:`eve`,configKey:`eve`,compatibility:{nuxt:`>=4.0.0`}},defaults:{},async setup(e,t){let n=t.options.rootDir,r=resolveApplicationRoot(n,e.eveRoot);if(addImports({name:`useEveAgent`,from:`eve/vue`}),!t.options.dev&&process.env.VERCEL){let i=await ensureEveVercelServicesConfig({appRoot:r,eveBuildCommand:e.eveBuildCommand,nuxtRoot:n});if(i.mode===`generated`){let e=t.options.nitro;e.vercel={...e.vercel,config:mergeEveVercelConfig(e.vercel?.config,i)}}}else t.hook(`modules:done`,async()=>{let e=await resolveEveProxyTarget({appRoot:r,dev:t.options.dev,onDevServerSpawned:e=>{t.hook(`close`,()=>{e.killed||e.kill()})}});extendRouteRules(`${EVE_ROUTE_PREFIX}/**`,{proxy:`${e}/**`})})}});export{module_default as default};
1
+ import{joinRoutePrefix,normalizeOrigin,resolveProductionTarget}from"./routing.js";import{EVE_BASE_URL_ENV,resolveSharedEveDevServer}from"./dev-server.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isAbsolute,resolve}from"node:path";import{addImports,defineNuxtModule,extendRouteRules}from"@nuxt/kit";import{ensureEveVercelServicesConfig,mergeEveVercelConfig}from"#shared/vercel-services.js";function resolveApplicationRoot(e,t){return t===void 0||t.length===0?e:isAbsolute(t)?t:resolve(e,t)}async function resolveEveProxyTarget(a){if(!a.dev)return resolveProductionTarget();let o=process.env[EVE_BASE_URL_ENV]?.trim();if(o&&o.length>0)return joinRoutePrefix(normalizeOrigin(o),EVE_ROUTE_PREFIX);let s=await resolveSharedEveDevServer(a.appRoot);return s.process!==void 0&&a.onDevServerSpawned?.(s.process),joinRoutePrefix(s.origin,EVE_ROUTE_PREFIX)}var module_default=defineNuxtModule({meta:{name:`eve`,configKey:`eve`,compatibility:{nuxt:`>=4.0.0`}},defaults:{},async setup(e,t){let n=t.options.rootDir,r=resolveApplicationRoot(n,e.eveRoot);if(addImports({name:`useEveAgent`,from:`eve/vue`}),!t.options.dev&&process.env.VERCEL){let i=await ensureEveVercelServicesConfig({appRoot:r,eveBuildCommand:e.eveBuildCommand,frameworkName:`Nuxt`,hostRoot:n});if(i.mode===`generated`){let e=t.options.nitro;e.vercel={...e.vercel,config:mergeEveVercelConfig(e.vercel?.config,i)}}}else t.hook(`modules:done`,async()=>{let e=await resolveEveProxyTarget({appRoot:r,dev:t.options.dev,onDevServerSpawned:e=>{t.hook(`close`,()=>{e.killed||e.kill()})}});extendRouteRules(`${EVE_ROUTE_PREFIX}/**`,{proxy:`${e}/**`})})}});export{module_default as default};
@@ -1,6 +1,4 @@
1
1
  import type { Plugin } from "vite";
2
- import { EVE_SVELTEKIT_SERVICE_PREFIX } from "./routing.js";
3
- export { EVE_SVELTEKIT_SERVICE_PREFIX };
4
2
  /**
5
3
  * Options for the eve SvelteKit Vite plugin.
6
4
  */
@@ -11,23 +9,11 @@ export interface EveSvelteKitPluginOptions {
11
9
  */
12
10
  readonly eveRoot?: string;
13
11
  /**
14
- * Build command for the generated eve Vercel service.
15
- * Defaults to `"eve build"`.
12
+ * Command that builds the eve app inside the generated Vercel eve service.
13
+ * Defaults to running the installed eve binary from the SvelteKit app's
14
+ * dependencies (`node <path-to>/eve/bin/eve.js build`).
16
15
  */
17
16
  readonly eveBuildCommand?: string;
18
- /**
19
- * Set to `false` to skip creating or updating `vercel.json`.
20
- *
21
- * By default the plugin ensures `vercel.json` contains `experimentalServices`
22
- * for the SvelteKit app and eve app.
23
- */
24
- readonly configureVercelJson?: boolean;
25
- /**
26
- * Private Vercel service prefix for the eve deployment. Must match the
27
- * eve service's `routePrefix` in `vercel.json`. Defaults to
28
- * {@link EVE_SVELTEKIT_SERVICE_PREFIX} (`"/_eve_internal/eve"`).
29
- */
30
- readonly servicePrefix?: string;
31
17
  }
32
18
  /**
33
19
  * Vite plugin for running an eve agent alongside a SvelteKit app.
@@ -37,8 +23,8 @@ export interface EveSvelteKitPluginOptions {
37
23
  * `EVE_BASE_URL` env var if set, then a healthy shared eve dev server already
38
24
  * running for the app, then a freshly spawned `eve dev --no-ui --port 0`.
39
25
  *
40
- * During builds, unless `configureVercelJson` is `false`, it ensures
41
- * `vercel.json` deploys the SvelteKit app and eve agent as sibling Vercel
42
- * services.
26
+ * On Vercel builds, `eveSvelteKit` adds the eve runtime as a sibling Vercel
27
+ * service and routes its transport requests before SvelteKit filesystem
28
+ * routing.
43
29
  */
44
30
  export declare function eveSvelteKit(options?: EveSvelteKitPluginOptions): Plugin;
@@ -1 +1 @@
1
- import{EVE_SVELTEKIT_SERVICE_PREFIX,normalizeOrigin,normalizeRoutePrefix}from"./routing.js";import{EVE_BASE_URL_ENV,resolveSharedEveDevServer}from"./dev-server.js";import{ensureEveVercelJson}from"./vercel-json.js";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isAbsolute,resolve}from"node:path";function resolveApplicationRoot(e,t){return t===void 0||t.length===0?e:isAbsolute(t)?t:resolve(e,t)}function mergeProxyConfig(e,t){return{...e,[EVE_ROUTE_PREFIX]:{changeOrigin:!0,target:t}}}async function resolveEveDevProxyTarget(e){let n=process.env[EVE_BASE_URL_ENV]?.trim();return n&&n.length>0?normalizeOrigin(n):(await resolveSharedEveDevServer(e)).origin}function eveSvelteKit(e={}){let t=process.cwd(),r=resolveApplicationRoot(t,e.eveRoot),i=normalizeRoutePrefix(e.servicePrefix??`/_eve_internal/eve`),a=e.configureVercelJson!==!1;return{name:`eve:sveltekit`,async config(n,o){if(t=n.root===void 0?process.cwd():resolve(process.cwd(),n.root),r=resolveApplicationRoot(t,e.eveRoot),a&&o.command===`build`&&await ensureEveVercelJson({appRoot:r,eveBuildCommand:e.eveBuildCommand??`eve build`,servicePrefix:i,svelteKitRoot:t}),o.command!==`serve`)return{};let s=await resolveEveDevProxyTarget(r);return o.isPreview?{preview:{proxy:mergeProxyConfig(n.preview?.proxy,s)}}:{server:{proxy:mergeProxyConfig(n.server?.proxy,s)}}}}}export{EVE_SVELTEKIT_SERVICE_PREFIX,eveSvelteKit};
1
+ import{normalizeOrigin}from"./routing.js";import{EVE_BASE_URL_ENV,resolveSharedEveDevServer}from"./dev-server.js";import{readFile,writeFile}from"node:fs/promises";import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";import{isAbsolute,join,resolve}from"node:path";import{ensureEveVercelServicesConfig,mergeEveVercelConfig}from"#shared/vercel-services.js";function resolveApplicationRoot(e,t){return t===void 0||t.length===0?e:isAbsolute(t)?t:resolve(e,t)}function mergeProxyConfig(e,t){return{...e,[EVE_ROUTE_PREFIX]:{changeOrigin:!0,target:t}}}async function resolveEveDevProxyTarget(r){let i=process.env[EVE_BASE_URL_ENV]?.trim();return i&&i.length>0?normalizeOrigin(i):(await resolveSharedEveDevServer(r)).origin}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function mergeGeneratedVercelServicesConfig(e){let t;try{t=await readFile(e.outputConfigPath,`utf8`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let n=JSON.parse(t);if(!isRecord(n))throw Error(`Vercel Build Output config.json must contain a JSON object.`);let a=mergeEveVercelConfig(n,e.generated);await writeFile(e.outputConfigPath,`${JSON.stringify(a,null,2)}\n`)}function eveSvelteKit(e={}){let t=process.cwd(),n=resolveApplicationRoot(t,e.eveRoot),r=!1,i;return{enforce:`post`,name:`eve:sveltekit`,async config(r,a){if(t=r.root===void 0?process.cwd():resolve(process.cwd(),r.root),n=resolveApplicationRoot(t,e.eveRoot),a.command===`build`&&process.env.VERCEL){let r=await ensureEveVercelServicesConfig({appRoot:n,eveBuildCommand:e.eveBuildCommand,frameworkName:`SvelteKit`,hostRoot:t});i=r.mode===`generated`?r:void 0}if(a.command!==`serve`)return{};let o=await resolveEveDevProxyTarget(n);return a.isPreview?{preview:{proxy:mergeProxyConfig(r.preview?.proxy,o)}}:{server:{proxy:mergeProxyConfig(r.server?.proxy,o)}}},configResolved(e){r=!!e.build.ssr,t=e.root},closeBundle:{sequential:!0,async handler(){!r||i===void 0||await mergeGeneratedVercelServicesConfig({generated:i,outputConfigPath:join(t,`.vercel`,`output`,`config.json`)})}}}}export{eveSvelteKit};
@@ -1,14 +1,3 @@
1
- /**
2
- * Private route namespace for hosting eve as a separate experimental Vercel
3
- * service behind the SvelteKit app.
4
- */
5
- export declare const EVE_SVELTEKIT_SERVICE_PREFIX = "/_eve_internal/eve";
6
- /**
7
- * Normalize a user-supplied service prefix into a leading-slash, no-trailing-
8
- * slash route. Throws when the prefix resolves to the root route, which would
9
- * collide with the SvelteKit web service.
10
- */
11
- export declare function normalizeRoutePrefix(prefix: string): string;
12
1
  /**
13
2
  * Join a route prefix and a path with exactly one separating slash.
14
3
  */
@@ -17,16 +6,3 @@ export declare function joinRoutePrefix(prefix: string, path: string): string;
17
6
  * Reduce an origin string to its canonical `protocol://host[:port]` form.
18
7
  */
19
8
  export declare function normalizeOrigin(origin: string): string;
20
- /**
21
- * A Vercel rewrite that forwards eve transport requests (`/eve/v1/**`) to the
22
- * private eve service prefix (`/_eve_internal/eve/eve/v1/**`).
23
- */
24
- export interface EveVercelRewrite {
25
- readonly destination: string;
26
- readonly source: string;
27
- }
28
- /**
29
- * Build the Vercel rewrite that forwards browser eve transport requests to the
30
- * sibling eve service.
31
- */
32
- export declare function createEveVercelRewrite(servicePrefix: string): EveVercelRewrite;
@@ -1 +1 @@
1
- import{EVE_ROUTE_PREFIX}from"#protocol/routes.js";const EVE_SVELTEKIT_SERVICE_PREFIX=`/_eve_internal/eve`;function normalizeRoutePrefix(e){let t=(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``);if(t.length===0)throw Error(`eve SvelteKit service prefix cannot resolve to the root route.`);return t}function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e.trim()).origin}function createEveVercelRewrite(t){return{destination:`${joinRoutePrefix(t,EVE_ROUTE_PREFIX)}/:path*`,source:`${EVE_ROUTE_PREFIX}/:path*`}}export{EVE_SVELTEKIT_SERVICE_PREFIX,createEveVercelRewrite,joinRoutePrefix,normalizeOrigin,normalizeRoutePrefix};
1
+ function joinRoutePrefix(e,t){return`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function normalizeOrigin(e){return new URL(e.trim()).origin}export{joinRoutePrefix,normalizeOrigin};