eve 0.22.3 → 0.22.5

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 (138) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -0
  3. package/dist/src/chunks/{use-eve-agent-Cojyfr4X.js → use-eve-agent-CFBTHlPx.js} +18 -1
  4. package/dist/src/chunks/{use-eve-agent-D-S1TPCW.js → use-eve-agent-dEGV09g_.js} +18 -1
  5. package/dist/src/cli/commands/agent-instructions.d.ts +15 -0
  6. package/dist/src/cli/commands/agent-instructions.js +3 -1
  7. package/dist/src/cli/commands/agent-prompt/scaffold.md +3 -0
  8. package/dist/src/cli/commands/extension-build.d.ts +9 -0
  9. package/dist/src/cli/commands/extension-build.js +1 -0
  10. package/dist/src/cli/commands/extension-init.d.ts +25 -0
  11. package/dist/src/cli/commands/extension-init.js +1 -0
  12. package/dist/src/cli/commands/info.js +1 -1
  13. package/dist/src/cli/commands/init-git.js +1 -1
  14. package/dist/src/cli/commands/init-repl.js +1 -1
  15. package/dist/src/cli/commands/init.d.ts +2 -0
  16. package/dist/src/cli/commands/init.js +1 -1
  17. package/dist/src/cli/run.js +1 -1
  18. package/dist/src/client/agent-host.d.ts +4 -0
  19. package/dist/src/client/agent-host.js +1 -0
  20. package/dist/src/compiled/.vendor-stamp.json +4 -4
  21. package/dist/src/compiled/@workflow/core/global.d.ts +20 -0
  22. package/dist/src/compiled/@workflow/core/index.js +2 -2
  23. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +54 -0
  24. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +11 -3
  25. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +6 -2
  26. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +36 -2
  27. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +28 -0
  28. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +23 -0
  29. package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +131 -0
  30. package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +72 -0
  31. package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +12 -0
  32. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +7 -0
  33. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  34. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  35. package/dist/src/compiled/@workflow/core/serialization-format.d.ts +1 -0
  36. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +40 -0
  37. package/dist/src/compiled/@workflow/core/telemetry.d.ts +8 -0
  38. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  39. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  40. package/dist/src/compiled/@workflow/world/analytics.d.ts +4 -4
  41. package/dist/src/compiled/@workflow/world/events.d.ts +142 -21
  42. package/dist/src/compiled/@workflow/world/hooks.d.ts +1 -24
  43. package/dist/src/compiled/@workflow/world/index.d.ts +3 -2
  44. package/dist/src/compiled/@workflow/world/queue.d.ts +10 -0
  45. package/dist/src/compiled/@workflow/world/ulid.d.ts +9 -0
  46. package/dist/src/compiled/@workflow/world-local/index.js +4 -4
  47. package/dist/src/compiled/@workflow/world-vercel/index.js +16 -16
  48. package/dist/src/compiled/_chunks/workflow/attribute-changes-ubiPfqvY.js +20 -0
  49. package/dist/src/compiled/_chunks/workflow/{dist-DJU_7R9s.js → dist-DnBjuNAZ.js} +1 -1
  50. package/dist/src/compiled/_chunks/workflow/{functions-CnVBREsg.js → functions-BCMO8vbf.js} +1 -1
  51. package/dist/src/compiled/_chunks/workflow/resume-hook-BkVkWg2r.js +1 -0
  52. package/dist/src/compiled/_chunks/workflow/run-B3N1kN9q.js +1 -0
  53. package/dist/src/compiled/_chunks/workflow/{sleep-phozDCW8.js → sleep-C2Bn-UUg.js} +1 -1
  54. package/dist/src/compiler/manifest.d.ts +4 -4
  55. package/dist/src/compiler/normalize-subagent.js +1 -1
  56. package/dist/src/compiler/remote-agent-node.d.ts +1 -1
  57. package/dist/src/compiler/remote-agent-node.js +1 -1
  58. package/dist/src/discover/filesystem.d.ts +2 -2
  59. package/dist/src/discover/filesystem.js +1 -1
  60. package/dist/src/discover/project.js +1 -1
  61. package/dist/src/harness/emission.d.ts +2 -4
  62. package/dist/src/harness/emission.js +1 -1
  63. package/dist/src/harness/inline-tool-authorization.d.ts +3 -0
  64. package/dist/src/harness/inline-tool-authorization.js +1 -0
  65. package/dist/src/harness/interruptible-stream.d.ts +5 -0
  66. package/dist/src/harness/interruptible-stream.js +1 -0
  67. package/dist/src/harness/model-call-error.js +1 -1
  68. package/dist/src/harness/ordered-stream-emitter.d.ts +17 -0
  69. package/dist/src/harness/ordered-stream-emitter.js +1 -0
  70. package/dist/src/harness/stream-actions.d.ts +1 -0
  71. package/dist/src/harness/stream-actions.js +1 -1
  72. package/dist/src/harness/subagent-depth.d.ts +1 -1
  73. package/dist/src/harness/subagent-depth.js +1 -1
  74. package/dist/src/harness/tool-loop.js +1 -1
  75. package/dist/src/internal/application/optional-package-install.js +2 -2
  76. package/dist/src/internal/application/package.js +1 -1
  77. package/dist/src/internal/authored-module-loader.d.ts +1 -1
  78. package/dist/src/internal/nitro/host/build-application.js +1 -1
  79. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  80. package/dist/src/internal/workflow-bundle/eve-service-route-output.d.ts +1 -2
  81. package/dist/src/internal/workflow-bundle/eve-service-route-output.js +1 -54
  82. package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
  83. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  84. package/dist/src/public/definitions/extension.d.ts +4 -4
  85. package/dist/src/public/definitions/remote-agent.d.ts +11 -2
  86. package/dist/src/public/index.d.ts +1 -1
  87. package/dist/src/public/models/openai/chatgpt/auth.d.ts +69 -0
  88. package/dist/src/public/models/openai/chatgpt/auth.js +1 -0
  89. package/dist/src/public/models/openai/chatgpt/model.d.ts +8 -0
  90. package/dist/src/public/models/openai/chatgpt/model.js +1 -0
  91. package/dist/src/public/models/openai/chatgpt/transport.d.ts +24 -0
  92. package/dist/src/public/models/openai/chatgpt/transport.js +1 -0
  93. package/dist/src/public/models/openai/chatgpt/unsigned-jwt.d.ts +5 -0
  94. package/dist/src/public/models/openai/chatgpt/unsigned-jwt.js +1 -0
  95. package/dist/src/public/models/openai/index.d.ts +30 -0
  96. package/dist/src/public/models/openai/index.js +1 -0
  97. package/dist/src/public/next/index.d.ts +38 -3
  98. package/dist/src/public/next/index.js +1 -1
  99. package/dist/src/public/next/server.d.ts +1 -0
  100. package/dist/src/public/next/server.js +2 -1
  101. package/dist/src/public/next/vercel-output-config.d.ts +12 -3
  102. package/dist/src/public/next/vercel-output-config.js +1 -1
  103. package/dist/src/public/nuxt/dev-server.js +1 -1
  104. package/dist/src/public/sveltekit/dev-server.js +1 -1
  105. package/dist/src/react/use-eve-agent.d.ts +8 -1
  106. package/dist/src/react/use-eve-agent.js +1 -1
  107. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  108. package/dist/src/setup/scaffold/connections/catalog.js +1 -1
  109. package/dist/src/setup/scaffold/create/extension.d.ts +30 -0
  110. package/dist/src/setup/scaffold/create/extension.js +34 -0
  111. package/dist/src/setup/scaffold/create/project.d.ts +2 -0
  112. package/dist/src/setup/scaffold/create/project.js +2 -2
  113. package/dist/src/setup/scaffold/index.d.ts +1 -0
  114. package/dist/src/setup/scaffold/index.js +1 -1
  115. package/dist/src/shared/agent-definition.d.ts +1 -1
  116. package/dist/src/svelte/index.js +1 -1
  117. package/dist/src/svelte/use-eve-agent.d.ts +8 -1
  118. package/dist/src/svelte/use-eve-agent.js +1 -1
  119. package/dist/src/vue/index.js +1 -1
  120. package/dist/src/vue/use-eve-agent.d.ts +8 -1
  121. package/dist/src/vue/use-eve-agent.js +1 -1
  122. package/docs/agent-config.md +1 -1
  123. package/docs/channels/slack.mdx +6 -0
  124. package/docs/concepts/sessions-runs-and-streaming.md +1 -1
  125. package/docs/extensions.md +42 -13
  126. package/docs/guides/client/streaming.mdx +1 -1
  127. package/docs/guides/frontend/nextjs.mdx +32 -7
  128. package/docs/guides/frontend/overview.mdx +7 -1
  129. package/docs/guides/hooks.md +9 -0
  130. package/docs/guides/remote-agents.md +23 -8
  131. package/docs/meta.json +0 -1
  132. package/docs/reference/cli.md +56 -22
  133. package/docs/reference/typescript-api.md +17 -0
  134. package/docs/subagents.mdx +1 -1
  135. package/package.json +10 -5
  136. package/dist/src/compiled/_chunks/workflow/attribute-changes-BnKD8Y3m.js +0 -20
  137. package/dist/src/compiled/_chunks/workflow/resume-hook-DjPY9VGg.js +0 -1
  138. package/dist/src/compiled/_chunks/workflow/run-BSANnUPR.js +0 -1
@@ -1 +1 @@
1
- import{t as e}from"./chunk-BHKSVoKr.js";var t=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>w,ipAddress:()=>S}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function S(e){return y(`headers`in e?e.headers:e,f)}function C(e){return e?e.split(`:`)[0]:`dev1`}function w(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:C(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}0&&(t.exports={CITY_HEADER_NAME:u,COUNTRY_HEADER_NAME:d,EMOJI_FLAG_UNICODE_STARTING_POSITION:v,IP_HEADER_NAME:f,LATITUDE_HEADER_NAME:p,LONGITUDE_HEADER_NAME:m,POSTAL_CODE_HEADER_NAME:g,REGION_HEADER_NAME:h,REQUEST_ID_HEADER_NAME:_,geolocation:w,ipAddress:S})})),n=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n};0&&(t.exports={getEnv:u})})),r=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),i=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{waitUntil:()=>f}),t.exports=l(u);var d=r();let f=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,d.getContext)().waitUntil?.(e)};0&&(t.exports={waitUntil:f})})),a=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}0&&(t.exports={next:f,rewrite:d})})),o=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}};0&&(t.exports={InMemoryCache:u})})),s=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},l=e=>s(n({},`__esModule`,{value:!0}),e),u={};o(u,{BuildCache:()=>f}),t.exports=l(u);var d=c(),f=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(d.HEADERS_VERCEL_CACHE_STATE)!==d.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[d.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[d.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[d.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}};0&&(t.exports={BuildCache:f})})),c=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of a(t))!c.call(e,s)&&s!==r&&n(e,s,{get:()=>t[s],enumerable:!(o=i(t,s))||o.enumerable});return e},d=e=>u(n({},`__esModule`,{value:!0}),e),f={};l(f,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>O,HEADERS_VERCEL_CACHE_STATE:()=>T,HEADERS_VERCEL_CACHE_TAGS:()=>D,HEADERS_VERCEL_REVALIDATE:()=>E,PkgCacheState:()=>w,getCache:()=>y}),t.exports=d(f);var p=r(),m=o(),h=s();let g=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},_=null,v=null,y=e=>x(()=>{let e;return e=(0,p.getContext)().cache?(0,p.getContext)().cache:C(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},b(e));function b(e){let t=e?.keyHashFunction||g;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function x(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,{...i,name:i?.name??n}),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let S=!1;function C(e){if(_||=new m.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),_;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return S||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),_;if(!v){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),_}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}v=new h.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return v}var w=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(w||{});let T=`x-vercel-cache-state`,E=`x-vercel-revalidate`,D=`x-vercel-cache-tags`,O=`x-vercel-cache-item-name`;0&&(t.exports={HEADERS_VERCEL_CACHE_ITEM_NAME:O,HEADERS_VERCEL_CACHE_STATE:T,HEADERS_VERCEL_CACHE_TAGS:D,HEADERS_VERCEL_REVALIDATE:E,PkgCacheState:w,getCache:y})})),l=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{attachDatabasePool:()=>v,experimental_attachDatabasePool:()=>y}),t.exports=l(u);var d=r();let f=!!process.env.DEBUG;function p(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let m=null,h=()=>{},g=Date.now();function _(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;m&&(clearTimeout(m),h());let t=new Promise(e=>{h=e}),n=Math.min(p(e)+100,Math.max(100,899e3-(Date.now()-g)));m=setTimeout(()=>{h?.(),f&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,d.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function v(e){if(m&&(h?.(),clearTimeout(m)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{f&&console.log(`Client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL2/MariaDB client released from pool`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{f&&console.log(`MongoDB connection checked out`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{f&&console.log(`Redis connection ended`),_(e)});return}throw Error(`Unsupported database pool type`)}let y=v;0&&(t.exports={attachDatabasePool:v,experimental_attachDatabasePool:y})})),u=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{dangerouslyDeleteBySrcImage:()=>h,dangerouslyDeleteByTag:()=>p,invalidateBySrcImage:()=>m,invalidateByTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},p=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},m=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},h=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()};0&&(t.exports={dangerouslyDeleteBySrcImage:h,dangerouslyDeleteByTag:p,invalidateBySrcImage:m,invalidateByTag:f})})),d=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{addCacheTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().addCacheTag;return t?t(e):Promise.resolve()};0&&(t.exports={addCacheTag:f})})),f=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{experimental_upgradeWebSocket:()=>p}),t.exports=l(u);var d=r();async function f(){try{return(await import(`./wrapper-CQmdlFyy.js`)).WebSocketServer}catch{throw Error(`The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws`)}}async function p(e){let t=(0,d.getContext)();if(typeof t.upgradeWebSocket!=`function`)throw Error(`experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades.`);let n=await f(),{req:r,socket:i,head:a}=t.upgradeWebSocket(),o=new n({noServer:!0}),s=await new Promise((e,t)=>{let n=()=>{i.removeListener(`error`,l),i.removeListener(`close`,u)},s=e=>{if(n(),e instanceof Error){t(e);return}let r=Error(`WebSocket upgrade failed`);r.cause=e,t(r)},c=t=>{n(),e(t)},l=e=>s(e),u=()=>s(Error(`socket closed before the WebSocket upgrade completed`));i.once(`error`,l),i.once(`close`,u);try{o.handleUpgrade(r,i,a,c)}catch(e){s(e)}});try{await e(s)}catch(e){throw s.close(1011,`WebSocket handler failed`),e}return new Response(null,{status:204})}0&&(t.exports={experimental_upgradeWebSocket:p})})),p=e(((e,r)=>{var o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty,h=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of p(t))!m.call(e,i)&&i!==n&&o(e,i,{get:()=>t[i],enumerable:!(r=s(t,i))||r.enumerable});return e},_=e=>g(o({},`__esModule`,{value:!0}),e),v={};h(v,{addCacheTag:()=>E.addCacheTag,attachDatabasePool:()=>w.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>T.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>T.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>w.experimental_attachDatabasePool,experimental_upgradeWebSocket:()=>D.experimental_upgradeWebSocket,geolocation:()=>y.geolocation,getCache:()=>C.getCache,getEnv:()=>b.getEnv,invalidateBySrcImage:()=>T.invalidateBySrcImage,invalidateByTag:()=>T.invalidateByTag,ipAddress:()=>y.ipAddress,next:()=>S.next,rewrite:()=>S.rewrite,waitUntil:()=>x.waitUntil}),r.exports=_(v);var y=t(),b=n(),x=i(),S=a(),C=c(),w=l(),T=u(),E=d(),D=f();0&&(r.exports={addCacheTag,attachDatabasePool,dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag,experimental_attachDatabasePool,experimental_upgradeWebSocket,geolocation,getCache,getEnv,invalidateBySrcImage,invalidateByTag,ipAddress,next,rewrite,waitUntil})}));export default p();export{};
1
+ import{t as e}from"./chunk-BHKSVoKr.js";var t=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>w,ipAddress:()=>S}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function S(e){return y(`headers`in e?e.headers:e,f)}function C(e){return e?e.split(`:`)[0]:`dev1`}function w(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:C(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}0&&(t.exports={CITY_HEADER_NAME:u,COUNTRY_HEADER_NAME:d,EMOJI_FLAG_UNICODE_STARTING_POSITION:v,IP_HEADER_NAME:f,LATITUDE_HEADER_NAME:p,LONGITUDE_HEADER_NAME:m,POSTAL_CODE_HEADER_NAME:g,REGION_HEADER_NAME:h,REQUEST_ID_HEADER_NAME:_,geolocation:w,ipAddress:S})})),n=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n};0&&(t.exports={getEnv:u})})),r=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),i=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{waitUntil:()=>f}),t.exports=l(u);var d=r();let f=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,d.getContext)().waitUntil?.(e)};0&&(t.exports={waitUntil:f})})),a=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}0&&(t.exports={next:f,rewrite:d})})),o=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}};0&&(t.exports={InMemoryCache:u})})),s=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},l=e=>s(n({},`__esModule`,{value:!0}),e),u={};o(u,{BuildCache:()=>f}),t.exports=l(u);var d=c(),f=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(d.HEADERS_VERCEL_CACHE_STATE)!==d.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[d.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[d.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[d.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}};0&&(t.exports={BuildCache:f})})),c=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,l=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let s of a(t))!c.call(e,s)&&s!==r&&n(e,s,{get:()=>t[s],enumerable:!(o=i(t,s))||o.enumerable});return e},d=e=>u(n({},`__esModule`,{value:!0}),e),f={};l(f,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>O,HEADERS_VERCEL_CACHE_STATE:()=>T,HEADERS_VERCEL_CACHE_TAGS:()=>D,HEADERS_VERCEL_REVALIDATE:()=>E,PkgCacheState:()=>w,getCache:()=>y}),t.exports=d(f);var p=r(),m=o(),h=s();let g=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},_=null,v=null,y=e=>x(()=>{let e;return e=(0,p.getContext)().cache?(0,p.getContext)().cache:C(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},b(e));function b(e){let t=e?.keyHashFunction||g;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function x(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,{...i,name:i?.name??n}),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let S=!1;function C(e){if(_||=new m.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),_;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return S||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),_;if(!v){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),_}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}v=new h.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return v}var w=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(w||{});let T=`x-vercel-cache-state`,E=`x-vercel-revalidate`,D=`x-vercel-cache-tags`,O=`x-vercel-cache-item-name`;0&&(t.exports={HEADERS_VERCEL_CACHE_ITEM_NAME:O,HEADERS_VERCEL_CACHE_STATE:T,HEADERS_VERCEL_CACHE_TAGS:D,HEADERS_VERCEL_REVALIDATE:E,PkgCacheState:w,getCache:y})})),l=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{attachDatabasePool:()=>v,experimental_attachDatabasePool:()=>y}),t.exports=l(u);var d=r();let f=!!process.env.DEBUG;function p(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let m=null,h=()=>{},g=Date.now();function _(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;m&&(clearTimeout(m),h());let t=new Promise(e=>{h=e}),n=Math.min(p(e)+100,Math.max(100,899e3-(Date.now()-g)));m=setTimeout(()=>{h?.(),f&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,d.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function v(e){if(m&&(h?.(),clearTimeout(m)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{f&&console.log(`Client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL client released from pool`),_(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{f&&console.log(`MySQL2/MariaDB client released from pool`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{f&&console.log(`MongoDB connection checked out`),_(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{f&&console.log(`Redis connection ended`),_(e)});return}throw Error(`Unsupported database pool type`)}let y=v;0&&(t.exports={attachDatabasePool:v,experimental_attachDatabasePool:y})})),u=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{dangerouslyDeleteBySrcImage:()=>h,dangerouslyDeleteByTag:()=>p,invalidateBySrcImage:()=>m,invalidateByTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},p=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},m=e=>{let t=(0,d.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},h=(e,t)=>{let n=(0,d.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()};0&&(t.exports={dangerouslyDeleteBySrcImage:h,dangerouslyDeleteByTag:p,invalidateBySrcImage:m,invalidateByTag:f})})),d=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{addCacheTag:()=>f}),t.exports=l(u);var d=r();let f=e=>{let t=(0,d.getContext)().addCacheTag;return t?t(e):Promise.resolve()};0&&(t.exports={addCacheTag:f})})),f=e(((e,t)=>{var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!o.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=i(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{experimental_upgradeWebSocket:()=>p}),t.exports=l(u);var d=r();async function f(){try{return(await import(`./wrapper-CQmdlFyy.js`)).WebSocketServer}catch{throw Error(`The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws`)}}async function p(e,t={}){let n=(0,d.getContext)();if(typeof n.upgradeWebSocket!=`function`)throw Error(`experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades.`);let r=await f(),{req:i,socket:a,head:o}=n.upgradeWebSocket(),s=new r({noServer:!0,maxPayload:t.maxPayload??262144}),c=await new Promise((e,t)=>{let n=()=>{a.removeListener(`error`,l),a.removeListener(`close`,u)},r=e=>{if(n(),e instanceof Error){t(e);return}let r=Error(`WebSocket upgrade failed`);r.cause=e,t(r)},c=t=>{n(),e(t)},l=e=>r(e),u=()=>r(Error(`socket closed before the WebSocket upgrade completed`));a.once(`error`,l),a.once(`close`,u);try{s.handleUpgrade(i,a,o,c)}catch(e){r(e)}});try{await e(c)}catch(e){throw c.close(1011,`WebSocket handler failed`),e}return new Response(null,{status:204})}0&&(t.exports={experimental_upgradeWebSocket:p})})),p=e(((e,r)=>{var o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty,h=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of p(t))!m.call(e,i)&&i!==n&&o(e,i,{get:()=>t[i],enumerable:!(r=s(t,i))||r.enumerable});return e},_=e=>g(o({},`__esModule`,{value:!0}),e),v={};h(v,{addCacheTag:()=>E.addCacheTag,attachDatabasePool:()=>w.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>T.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>T.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>w.experimental_attachDatabasePool,experimental_upgradeWebSocket:()=>D.experimental_upgradeWebSocket,geolocation:()=>y.geolocation,getCache:()=>C.getCache,getEnv:()=>b.getEnv,invalidateBySrcImage:()=>T.invalidateBySrcImage,invalidateByTag:()=>T.invalidateByTag,ipAddress:()=>y.ipAddress,next:()=>S.next,rewrite:()=>S.rewrite,waitUntil:()=>x.waitUntil}),r.exports=_(v);var y=t(),b=n(),x=i(),S=a(),C=c(),w=l(),T=u(),E=d(),D=f();0&&(r.exports={addCacheTag,attachDatabasePool,dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag,experimental_attachDatabasePool,experimental_upgradeWebSocket,geolocation,getCache,getEnv,invalidateBySrcImage,invalidateByTag,ipAddress,next,rewrite,waitUntil})}));export default p();export{};
@@ -0,0 +1 @@
1
+ import{r as e}from"./chunk-BHKSVoKr.js";import{n as t,o as n,w as r}from"./dist-DpDDcpTl.js";import{B as i,Cn as a,D as o,J as s,On as c,Vt as l,X as u,Xt as d,a as f,at as p,b as m,hn as h,it as g,m as _,n as v,on as y,r as b,rt as x}from"./attribute-changes-ubiPfqvY.js";import{s as S}from"./dist-DnBjuNAZ.js";var C=e({getHookByToken:()=>T,resumeHook:()=>E,resumeWebhook:()=>D});async function w(e){let t=await a(),n=await t.hooks.getByToken(e),r=await t.runs.get(n.runId),i=await t.getEncryptionKeyForRun?.(r),s=i?await c(i):void 0;return n.metadata!==void 0&&(n.metadata=await o(n.metadata,n.runId,s)),{hook:n,run:r,encryptionKey:s}}async function T(e){let{hook:t}=await w(e);return t}async function E(e,t,n){return await b(()=>u(`hook.resume`,async r=>{let o=await a();try{let a,u,h;if(typeof e==`string`){let t=await w(e);a=t.hook,u=t.run,h=n??t.encryptionKey}else if(a=e,u=await o.runs.get(a.runId),n)h=n;else{let e=await o.getEncryptionKeyForRun?.(u);h=e?await c(e):void 0}r?.setAttributes({...p(a.token),...g(a.hookId),...d(a.runId)});let b=u.executionContext?.workflowCoreVersion,x=_(typeof b==`string`?b:void 0);x.supportedFormats.has(y.ENCRYPTED)||(h=void 0);let C=(u.specVersion??0)>=5&&x.supportedFormats.has(y.GZIP),T=[],E=S(a.specVersion),D=await m(t,a.runId,h,T,globalThis,E,x.framedByteStreams,C);v(Promise.all(T),e=>{e!==void 0&&i.warn(`Background flush of hook payload ops failed`,{workflowRunId:a.runId,hookId:a.hookId,error:e instanceof Error?e.message:String(e)})}),await o.events.create(a.runId,{eventType:`hook_received`,specVersion:5,correlationId:a.hookId,eventData:{...E?{}:{token:a.token},payload:D}},{v1Compat:E}),r?.setAttributes({...l(u.workflowName)});let O=await s(u.executionContext?.traceCarrier);return O&&r?.addLink?.(O),await o.queue(f(u.workflowName),{runId:a.runId,traceCarrier:u.executionContext?.traceCarrier??void 0},{deploymentId:u.deploymentId,specVersion:u.specVersion??1}),a}catch(t){throw r?.setAttributes({...p(typeof e==`string`?e:e.token),...x(!1)}),t}}))}async function D(e,i){let{hook:a,encryptionKey:o}=await w(e);if(a.isWebhook===!1)throw new n(e);let s,c;if(a.metadata&&typeof a.metadata==`object`&&`respondWith`in a.metadata)if(a.metadata.respondWith===`manual`){let{readable:e,writable:t}=new TransformStream;c=e,i[h]=t}else if(a.metadata.respondWith instanceof Response)s=a.metadata.respondWith;else throw new r(`Invalid \`respondWith\` value: ${a.metadata.respondWith}`,{slug:t.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else s=new Response(null,{status:202});if(await E(a,i,o),c){let e=c.getReader(),t=await e.read();t.value&&(s=t.value),e.cancel()}if(!s)throw new r(`Workflow run did not send a response`,{slug:t.WEBHOOK_RESPONSE_NOT_SENT});return s}export{C as i,E as n,D as r,T as t};
@@ -0,0 +1 @@
1
+ import{h as e}from"./dist-CttsoN4D.js";import{C as t,E as n,S as r,T as i,b as a,d as o,m as s,p as c,r as l,s as u,t as d,w as f,x as p,y as m}from"./dist-DpDDcpTl.js";import{$ as h,A as g,B as _,Cn as v,E as y,Ht as b,On as x,Pt as S,R as C,Sn as w,Vt as T,X as E,Xt as D,Y as O,Zt as k,a as A,j,m as M,n as N,on as ee,p as P,r as F,s as I,t as L,w as R,wn as z,x as B,xn as V}from"./attribute-changes-ubiPfqvY.js";import{i as H,o as U,s as W}from"./dist-DnBjuNAZ.js";const G=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,n.WORLD_CONTRACT_ERROR]),K=new Set([`TRANSPORT`,`TIMEOUT`]),q=[f.is,c.is,m.is,o.is];function J(e){if(!i.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&G.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function Y(e){return s.is(e)?!0:i.is(e)?e.status!==void 0&&e.status>=500?!0:e.code!==void 0&&K.has(e.code):!1}function te(e){if(u.is(e))return n.REPLAY_DIVERGENCE;if(d.is(e))return n.CORRUPTED_EVENT_LOG;if(J(e)||Y(e))return n.WORLD_CONTRACT_ERROR;for(let t of q)if(t(e))return n.RUNTIME_ERROR;return n.USER_ERROR}const ne=U();let X=!1;async function Z(t,n,r){"use step";return await F(()=>{let i=t?.workflowId;if(!i)throw new f(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return E(`workflow.start ${e(i)}`,async e=>{e?.setAttributes({...T(i),...b(`start`)});let t=[],a=r??{};Array.isArray(n)?t=n:typeof n==`object`&&(a=n),e?.setAttributes({...S(t.length)});let o=a.world??await v();z(o);let s=await o.getDeploymentId(),c=a.deploymentId??s;c===`latest`&&(o.resolveLatestDeploymentId?c=await o.resolveLatestDeploymentId():(X||(X=!0,_.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:s})),c=s));let u,d;if(c===s)u=!0,d=!0;else if(typeof o.streams?.get!=`function`)u=!1,d=!1;else{let e=M((await I(o,`workflow`,{deploymentId:c,timeout:2e3,namespace:a.namespace}).catch(()=>void 0))?.workflowCoreVersion);u=e.framedByteStreams,d=e.supportedFormats.has(ee.GZIP)}let p=[],m=`wrun_${ne()}`,g=await O(),y=a.specVersion??o.specVersion,C=W(y),w=a.allowReservedAttributes===!0,E;if(a.attributes&&Object.keys(a.attributes).length>0){if(y<4)throw new f(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(a.attributes))if(typeof t!=`string`)throw new f(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=L(a.attributes,{allowReservedAttributes:w});E=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let j=E?{attributes:E,...w?{allowReservedAttributes:!0}:{}}:{};if(a.replayedFromRunId!==void 0&&!H.safeParse(a.replayedFromRunId).success)throw new f(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(a.replayedFromRunId).slice(0,64))}.`);let F=await o.getEncryptionKeyForRun?.(m,{...a,deploymentId:c}),R=F?await x(F):void 0,V=await B(t,m,R,p,globalThis,C,u,d&&y>=5),U={traceCarrier:g,workflowCoreVersion:P,features:{encryption:!!R},...a.replayedFromRunId?{replayedFromRunId:a.replayedFromRunId}:{}},[G,K]=await Promise.allSettled([o.events.create(m,{eventType:`run_created`,specVersion:y,eventData:{deploymentId:c,workflowName:i,input:V,executionContext:U,...j}},{v1Compat:C}),o.queue(A(i,a.namespace),{runId:m,traceCarrier:g,...y>=3?{runInput:{input:V,deploymentId:c,workflowName:i,specVersion:y,executionContext:U,...j}}:{}},{deploymentId:c,specVersion:y})]);if(K.status===`rejected`)throw K.reason;let q=!1;if(G.status===`rejected`){let e=G.reason;if(!l.is(e))if(Y(e))q=!0,_.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:m,error:e.message});else throw e}else{let e=G.value;if(!e.run)throw new f(`Missing 'run' in server response for 'run_created' event`);if(!C&&e.run.runId!==m)throw new f(`Server returned different runId than requested: expected ${m}, got ${e.run.runId}`)}return N(Promise.all(p),e=>{_.warn(`Background flush of workflow argument streams failed`,{workflowRunId:m,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...D(m),...h(c),...G.status===`fulfilled`&&G.value.run?k(G.value.run.status):{}}),new $(m,{resilientStart:q})})})}const re=e=>Array.isArray(e)?e:[e];async function ie(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await x(i):void 0,o=re(await g(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await Z({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ae(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=W(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function oe(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(A(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=W(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),u=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);u=u.filter(t=>t.correlationId&&e.has(t.correlationId))}let d=[],f=0;for(let n of u){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),f++}catch(e){l.is(e)?f++:d.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await e.queue(A(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),d.length>0)throw AggregateError(d,`Failed to complete ${d.length}/${u.length} pending wait(s) for run ${t}`);return{stoppedCount:f}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function se(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ce(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}var $=class e{static[w](e){return{runId:e.runId,resilientStart:e.#r}}static[V](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=v(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await x(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(t.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:i}=e,a=C(this.runId,i),o=this.#a(),s=R(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}async#o(){let e=await this.#t,n=0,i=this.#r?3:0,o=[1e3,3e3,6e3];for(;;)try{let t=await e.runs.get(this.runId);if(t.status===`completed`){let e=await this.#i();return await j(t.output,this.runId,e)}if(t.status===`cancelled`)throw new a(this.runId);if(t.status===`failed`){let e=await this.#i(),n;try{n=await y(t.error,this.runId,e)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new p(this.runId,n,{errorCode:t.errorCode})}throw new r(this.runId,t.status)}catch(e){if(r.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(t.is(e)&&n<i){let e=o[n];n++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function le(e){return new $(e)}export{se as a,Q as c,Y as d,J as f,ce as i,Z as l,le as n,ie as o,ae as r,oe as s,$ as t,te as u};
@@ -1 +1 @@
1
- import{En as e,mn as t}from"./attribute-changes-BnKD8Y3m.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
1
+ import{jn as e,yn as t}from"./attribute-changes-ubiPfqvY.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
@@ -326,7 +326,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
326
326
  outputSchema?: import("../shared/json.ts").JsonObject;
327
327
  path: string;
328
328
  rootPath: string;
329
- url: string;
329
+ url?: string;
330
330
  }>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & {
331
331
  description: string;
332
332
  entryPath: string;
@@ -334,7 +334,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
334
334
  outputSchema?: import("../shared/json.ts").JsonObject;
335
335
  path: string;
336
336
  rootPath: string;
337
- url: string;
337
+ url?: string;
338
338
  }>, unknown>>>;
339
339
  skills: z.ZodReadonly<z.ZodArray<z.ZodType<CompiledSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledSkillDefinition, unknown>>>>;
340
340
  instructions: z.ZodOptional<z.ZodType<CompiledInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledInstructionsDefinition, unknown>>>;
@@ -421,7 +421,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
421
421
  outputSchema?: import("../shared/json.ts").JsonObject;
422
422
  path: string;
423
423
  rootPath: string;
424
- url: string;
424
+ url?: string;
425
425
  }>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & {
426
426
  description: string;
427
427
  entryPath: string;
@@ -429,7 +429,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
429
429
  outputSchema?: import("../shared/json.ts").JsonObject;
430
430
  path: string;
431
431
  rootPath: string;
432
- url: string;
432
+ url?: string;
433
433
  }>, unknown>>>;
434
434
  sandbox: z.ZodNullable<z.ZodObject<{
435
435
  backendName: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- import{expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{createPathDerivedSourceId}from"#discover/manifest.js";async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t});return readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent(e)}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`);return{...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath,url:r.url}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(a,o){let s=expectObjectRecord(a,o);if(expectOnlyKnownKeys(s,[`auth`,`description`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),s.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return{description:expectString(s.description,o),outputSchema:s.outputSchema===void 0?void 0:normalizeJsonSchemaDefinition(s.outputSchema,`output`),path:s.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(s.path,o),url:expectString(s.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
1
+ import{expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{createPathDerivedSourceId}from"#discover/manifest.js";async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t});return readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent(e)}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description;if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},description:i,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(a,o){let s=expectObjectRecord(a,o);if(expectOnlyKnownKeys(s,[`auth`,`description`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),s.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return{description:expectString(s.description,o),outputSchema:s.outputSchema===void 0?void 0:normalizeJsonSchemaDefinition(s.outputSchema,`output`),path:s.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(s.path,o),url:typeof s.url==`function`?void 0:expectString(s.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
@@ -14,7 +14,7 @@ export type CompiledRemoteAgentNode = Readonly<ModuleSourceRef & Node & {
14
14
  outputSchema?: JsonObject;
15
15
  path: string;
16
16
  rootPath: string;
17
- url: string;
17
+ url?: string;
18
18
  }>;
19
19
  /**
20
20
  * Zod schema for one compiled remote subagent entry.
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const compiledRemoteAgentNodeSchema=z.object({description:z.string(),entryPath:z.string(),exportName:z.string().optional(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),outputSchema:jsonObjectSchema.optional(),path:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string()}).strict();export{compiledRemoteAgentNodeSchema};
1
+ import{z}from"#compiled/zod/index.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const compiledRemoteAgentNodeSchema=z.object({description:z.string(),entryPath:z.string(),exportName:z.string().optional(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),outputSchema:jsonObjectSchema.optional(),path:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string().optional()}).strict();export{compiledRemoteAgentNodeSchema};
@@ -15,11 +15,11 @@ export type DirectoryEntryType = "directory" | "file" | "other";
15
15
  /**
16
16
  * Classified root-level agent entry.
17
17
  */
18
- export type AgentRootEntryKind = "agent-config-module" | "channels-directory" | "connections-directory" | "extensions-directory" | "hooks-directory" | "instructions-directory" | "instructions-markdown" | "instructions-module" | "lib-directory" | "sandbox-directory" | "schedules-directory" | "skills-directory" | "system-markdown" | "system-module" | "tools-directory" | "unknown" | "subagents-directory";
18
+ export type AgentRootEntryKind = "agent-config-module" | "channels-directory" | "connections-directory" | "extensions-directory" | "hooks-directory" | "ignored-directory" | "instructions-directory" | "instructions-markdown" | "instructions-module" | "lib-directory" | "sandbox-directory" | "schedules-directory" | "skills-directory" | "system-markdown" | "system-module" | "tools-directory" | "unknown" | "subagents-directory";
19
19
  /**
20
20
  * Classified local-subagent root entry.
21
21
  */
22
- export type LocalSubagentEntryKind = "agent-config-module" | "connections-directory" | "hooks-directory" | "instructions-directory" | "instructions-markdown" | "instructions-module" | "invalid-schedules-directory" | "lib-directory" | "sandbox-directory" | "skills-directory" | "system-markdown" | "system-module" | "tools-directory" | "unknown" | "subagents-directory";
22
+ export type LocalSubagentEntryKind = "agent-config-module" | "connections-directory" | "hooks-directory" | "ignored-directory" | "instructions-directory" | "instructions-markdown" | "instructions-module" | "invalid-schedules-directory" | "lib-directory" | "sandbox-directory" | "skills-directory" | "system-markdown" | "system-module" | "tools-directory" | "unknown" | "subagents-directory";
23
23
  /**
24
24
  * Classified Agent Skills package entry.
25
25
  */
@@ -1 +1 @@
1
- import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e.toLowerCase()===`skill.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.toLowerCase().endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
1
+ import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES),GENERATED_AGENT_DIRECTORY_NAMES=new Set([`.eve`,`.next`,`.output`,`.vercel`,`.workflow-data`,`node_modules`]);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e.toLowerCase()===`skill.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(e.toLowerCase().endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
@@ -1 +1 @@
1
- import{basename,dirname,join,resolve}from"node:path";import{DISCOVER_PROJECT_NOT_FOUND,createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifyAgentRootEntry,getDirectoryEntryType,isProjectMarkerEntry}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";var DiscoveryProjectResolutionError=class extends Error{diagnostic;constructor(e){super(e.message),this.name=`DiscoveryProjectResolutionError`,this.diagnostic=e}};async function resolveDiscoveryProject(e=process.cwd(),n={}){let r=n.source??createDiskProjectSource(),a=await resolveSearchDirectory(r,e),o=a;for(;;){let e=await tryResolveNestedProjectFromAgentDirectory(r,o);if(e!==null)return e;let n=await tryResolveNestedProjectFromAppRoot(r,o);if(n!==null)return n;if(await isFlatAgentRoot(r,o))return{agentRoot:o,appRoot:o,layout:`flat`};let i=dirname(o);if(i===o)break;o=i}throw new DiscoveryProjectResolutionError(createDiscoverErrorDiagnostic({code:DISCOVER_PROJECT_NOT_FOUND,message:`Could not resolve an eve agent root from "${a}".`,sourcePath:a}))}async function resolveSearchDirectory(e,n){let i=resolve(n);return await e.stat(i)===`directory`?i:dirname(i)}async function tryResolveNestedProjectFromAgentDirectory(n,r){if(basename(r)!==`agent`)return null;let i=dirname(r);return await hasProjectMarkers(n,i)?{agentRoot:r,appRoot:i,layout:`nested`}:null}async function tryResolveNestedProjectFromAppRoot(e,t){if(!await hasProjectMarkers(e,t))return null;let r=join(t,`agent`);return await directoryExists(e,r)?{agentRoot:r,appRoot:t,layout:`nested`}:null}async function isFlatAgentRoot(e,t){let n=await readDirectoryEntryTypes(e,t);return Array.from(n.entries()).some(([e,t])=>{let n=classifyAgentRootEntry(e,t);return n!==`unknown`&&n!==`lib-directory`})}async function hasProjectMarkers(e,t){let n=await readDirectoryEntryTypes(e,t);return Array.from(n.entries()).some(([e,t])=>isProjectMarkerEntry(e,t))}async function readDirectoryEntryTypes(e,t){if(await e.stat(t)!==`directory`)return new Map;let n=await e.readDirectory(t);return new Map(n.map(e=>[e.name,getDirectoryEntryType(e)]))}async function directoryExists(e,t){return await e.stat(t)===`directory`}export{DiscoveryProjectResolutionError,resolveDiscoveryProject};
1
+ import{basename,dirname,join,resolve}from"node:path";import{DISCOVER_PROJECT_NOT_FOUND,createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifyAgentRootEntry,getDirectoryEntryType,isProjectMarkerEntry}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";var DiscoveryProjectResolutionError=class extends Error{diagnostic;constructor(e){super(e.message),this.name=`DiscoveryProjectResolutionError`,this.diagnostic=e}};async function resolveDiscoveryProject(e=process.cwd(),n={}){let r=n.source??createDiskProjectSource(),a=await resolveSearchDirectory(r,e),o=a;for(;;){let e=await tryResolveNestedProjectFromAgentDirectory(r,o);if(e!==null)return e;let n=await tryResolveNestedProjectFromAppRoot(r,o);if(n!==null)return n;if(await isFlatAgentRoot(r,o))return{agentRoot:o,appRoot:o,layout:`flat`};let i=dirname(o);if(i===o)break;o=i}throw new DiscoveryProjectResolutionError(createDiscoverErrorDiagnostic({code:DISCOVER_PROJECT_NOT_FOUND,message:`Could not resolve an eve agent root from "${a}".`,sourcePath:a}))}async function resolveSearchDirectory(e,n){let i=resolve(n);return await e.stat(i)===`directory`?i:dirname(i)}async function tryResolveNestedProjectFromAgentDirectory(n,r){if(basename(r)!==`agent`)return null;let i=dirname(r);return await hasProjectMarkers(n,i)?{agentRoot:r,appRoot:i,layout:`nested`}:null}async function tryResolveNestedProjectFromAppRoot(e,t){if(!await hasProjectMarkers(e,t))return null;let r=join(t,`agent`);return await directoryExists(e,r)?{agentRoot:r,appRoot:t,layout:`nested`}:null}async function isFlatAgentRoot(e,t){let n=await readDirectoryEntryTypes(e,t);return Array.from(n.entries()).some(([e,t])=>{let n=classifyAgentRootEntry(e,t);return n!==`unknown`&&n!==`ignored-directory`&&n!==`lib-directory`})}async function hasProjectMarkers(e,t){let n=await readDirectoryEntryTypes(e,t);return Array.from(n.entries()).some(([e,t])=>isProjectMarkerEntry(e,t))}async function readDirectoryEntryTypes(e,t){if(await e.stat(t)!==`directory`)return new Map;let n=await e.readDirectory(t);return new Map(n.map(e=>[e.name,getDirectoryEntryType(e)]))}async function directoryExists(e,t){return await e.stat(t)===`directory`}export{DiscoveryProjectResolutionError,resolveDiscoveryProject};
@@ -91,16 +91,14 @@ export declare function normalizeAssistantStepFinishReason(value: string | undef
91
91
  /**
92
92
  * Result of consuming one step's `fullStream`.
93
93
  *
94
- * Inline results avoid duplicate post-step events. Approval-resume results
95
- * also repair persisted history or route authorization back to the park
96
- * detector.
94
+ * Inline results avoid duplicate post-step events. Approval-resume
95
+ * authorization results also route back to the park detector.
97
96
  */
98
97
  interface EmittedStreamContent {
99
98
  readonly emittedActionCallIds: ReadonlySet<string>;
100
99
  readonly handledInlineToolResultCallIds: ReadonlySet<string>;
101
100
  readonly invalidInputToolCallIds: ReadonlySet<string>;
102
101
  readonly inlineAuthorizationResults: readonly TypedToolResult<ToolSet>[];
103
- readonly inlineToolResultParts: readonly InlineToolResultPart[];
104
102
  readonly trailingInlineToolResultParts: readonly InlineToolResultPart[];
105
103
  }
106
104
  interface StreamActionEmissionOptions {
@@ -1 +1 @@
1
- import{normalizeModelStreamError}from"#harness/model-call-error.js";import{createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{createRuntimeActionRequestFromToolCall,resolveToolCallInputObject}from"#harness/runtime-actions.js";import{isAuthorizationSignal,isPendingAuthorizationToolOutput}from"#harness/authorization.js";import{hasEmptyDeliverySentinel}from"#shared/empty-delivery.js";import{createRuntimeToolResultFromStepResult,createRuntimeToolResultFromToolError,createToolResultMessagePartFromToolError}from"#harness/action-result-helpers.js";import{createInvalidToolCallInputError}from"#harness/tool-call-input-errors.js";import{readToolInterrupt}from"#harness/tool-interrupts.js";import{createProviderStreamActionBatch}from"#harness/stream-actions.js";const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(e){return e?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(e,t){return{...e,state:{...e.state,[HARNESS_EMISSION_STATE_KEY]:t}}}async function emitTurnPreamble(e,t,n,r){let i=`turn_${n.sequence}`;return n.sessionStarted||await e(createSessionStartedEvent({runtime:r})),await e(createTurnStartedEvent({sequence:n.sequence,turnId:i})),t.message!==void 0&&await e(createMessageReceivedEvent({message:t.message,sequence:n.sequence,turnId:i})),{sessionStarted:!0,sequence:n.sequence,stepIndex:0,turnId:i}}async function emitStepStarted(e,t,n){await e(createStepStartedEvent({sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId}),n)}async function emitStepAndTurnFailed(e,t,n){await e(createStepFailedEvent({...n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),await e(createTurnFailedEvent({...n,sequence:t.sequence,turnId:t.turnId}))}async function emitFailedStep(e,t,n){await emitStepAndTurnFailed(e,t,n),await e(createSessionFailedEvent(n))}async function emitRecoverableFailedTurn(e,t,n){return await emitStepAndTurnFailed(e,t,n),await e(createSessionWaitingEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function advanceStep(e){return{...e,stepIndex:e.stepIndex+1}}async function emitTurnEpilogue(e,t,n){return await e(createTurnCompletedEvent({sequence:t.sequence,turnId:t.turnId})),n===`conversation`?await e(createSessionWaitingEvent()):await e(createSessionCompletedEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function normalizeAssistantStepFinishReason(e){switch(e){case`content-filter`:case`error`:case`length`:case`stop`:case`tool-calls`:return e;default:return`other`}}async function emitStreamContent(a,o,s,c){let l=``,u=``,d=`stop`,f,p=new Set,m=new Set,h=new Set,g=new Set,_=createProviderStreamActionBatch({emitFn:a,state:o}),v=new Set,y=new Set,b=[],x=[],S=[],flushCurrentMessage=async()=>{u.length!==0&&(await a(createMessageCompletedEvent({finishReason:`tool-calls`,message:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),u=``)},emitActionRequest=async e=>{m.has(e.callId)||(u.trim().length>0&&await flushCurrentMessage(),m.add(e.callId),await a(createActionsRequestedEvent({actions:[e],sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))},collectProviderToolCall=async e=>{g.has(e.toolCallId)||(g.add(e.toolCallId),!m.has(e.toolCallId)&&(m.add(e.toolCallId),u.trim().length>0&&await flushCurrentMessage(),_.observe({callId:e.toolCallId,input:resolveToolCallInputObject(e.input,{callId:e.toolCallId,toolName:e.toolName}),kind:`tool-call`,toolName:e.toolName})))},emitActionResult=async e=>{h.has(e.callId)||(h.add(e.callId),await a(createActionResultEvent({result:e,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))},emitToolCall=async e=>{if(!(c===void 0||e.invalid===!0||c.excludedActionToolNames.has(e.toolName)))try{await emitActionRequest(createRuntimeActionRequestFromToolCall({toolCall:e,tools:c.tools}))}catch(t){if(t instanceof TypeError){let n=createInvalidToolCallInputError({error:t,toolCall:e});y.add(e.toolCallId),u.trim().length>0&&await flushCurrentMessage(),await emitActionResult(createRuntimeToolResultFromToolError(n)),v.add(e.toolCallId),S.push(createToolResultMessagePartFromToolError(n));return}throw t}};for await(let t of s)if(f===void 0)switch(t.type){case`reasoning-delta`:await _.flush(),l+=t.text,await a(createReasoningAppendedEvent({reasoningDelta:t.text,reasoningSoFar:l,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`text-delta`:await _.flush(),l.trim().length>0&&(await a(createReasoningCompletedEvent({reasoning:l,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),l=``),u+=t.text,await a(createMessageAppendedEvent({messageDelta:t.text,messageSoFar:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`tool-call`:{let e=t;p.add(e.toolCallId),e.providerExecuted===!0?await collectProviderToolCall(e):(await _.flush(),await emitToolCall(e));break}case`tool-result`:{let e=t;if(e.preliminary===!0)break;if(e.providerExecuted===!0){await collectProviderToolCall({input:`input`in e?e.input:void 0,toolCallId:e.toolCallId,toolName:e.toolName}),await _.flush(),await emitActionResult(createRuntimeToolResultFromStepResult(e));break}if(p.has(t.toolCallId)){if(isInlineAuthorizationToolResult(e))break;m.has(t.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromStepResult(e)),v.add(t.toolCallId));break}if(await _.flush(),await flushCurrentMessage(),isInlineAuthorizationToolResult(e)){v.add(t.toolCallId),b.push(e);break}await emitActionResult(createRuntimeToolResultFromStepResult(e)),v.add(t.toolCallId);let n=e.output;x.push({type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:typeof n==`string`?{type:`text`,value:n}:{type:`json`,value:n??null}});break}case`tool-error`:{let e=t;e.providerExecuted===!0?(await collectProviderToolCall(e),await _.flush(),await emitActionResult(createRuntimeToolResultFromToolError(e))):m.has(e.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromToolError(e)),v.add(e.toolCallId),S.push(createToolResultMessagePartFromToolError(e)));break}case`finish-step`:d=normalizeAssistantStepFinishReason(t.finishReason),await _.flush();break;case`error`:f=normalizeModelStreamError(t.error);break;case`abort`:throw new DOMException(t.reason??`The model stream was aborted.`,`AbortError`);default:break}if(await _.flush(),f!==void 0)throw f;return l.trim().length>0&&await a(createReasoningCompletedEvent({reasoning:l,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),d!==`tool-calls`&&hasEmptyDeliverySentinel(u)?await a(createMessageCompletedEvent({finishReason:d,message:null,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})):u.trim().length>0&&await a(createMessageCompletedEvent({finishReason:d,message:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),{emittedActionCallIds:m,handledInlineToolResultCallIds:v,invalidInputToolCallIds:y,inlineAuthorizationResults:b,inlineToolResultParts:x,trailingInlineToolResultParts:S}}function isInlineAuthorizationToolResult(e){if(isPendingAuthorizationToolOutput(e.output))return!0;let t=contextStorage.getStore();if(t===void 0)return!1;let n=readToolInterrupt(t,e.toolCallId);return n!==void 0&&isAuthorizationSignal(n)}export{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStepStarted,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,normalizeAssistantStepFinishReason,setHarnessEmissionState};
1
+ import{normalizeModelStreamError}from"#harness/model-call-error.js";import{createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{createRuntimeActionRequestFromToolCall,resolveToolCallInputObject}from"#harness/runtime-actions.js";import{hasEmptyDeliverySentinel}from"#shared/empty-delivery.js";import{createRuntimeToolResultFromStepResult,createRuntimeToolResultFromToolError,createToolResultMessagePartFromToolError}from"#harness/action-result-helpers.js";import{createInvalidToolCallInputError}from"#harness/tool-call-input-errors.js";import{createProviderStreamActionBatch}from"#harness/stream-actions.js";import{createOrderedStreamEmitter}from"#harness/ordered-stream-emitter.js";import{interruptStreamOnFailure}from"#harness/interruptible-stream.js";import{isInlineAuthorizationToolResult}from"#harness/inline-tool-authorization.js";const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(e){return e?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(e,t){return{...e,state:{...e.state,[HARNESS_EMISSION_STATE_KEY]:t}}}async function emitTurnPreamble(e,t,n,r){let i=`turn_${n.sequence}`;return n.sessionStarted||await e(createSessionStartedEvent({runtime:r})),await e(createTurnStartedEvent({sequence:n.sequence,turnId:i})),t.message!==void 0&&await e(createMessageReceivedEvent({message:t.message,sequence:n.sequence,turnId:i})),{sessionStarted:!0,sequence:n.sequence,stepIndex:0,turnId:i}}async function emitStepStarted(e,t,n){await e(createStepStartedEvent({sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId}),n)}async function emitStepAndTurnFailed(e,t,n){await e(createStepFailedEvent({...n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),await e(createTurnFailedEvent({...n,sequence:t.sequence,turnId:t.turnId}))}async function emitFailedStep(e,t,n){await emitStepAndTurnFailed(e,t,n),await e(createSessionFailedEvent(n))}async function emitRecoverableFailedTurn(e,t,n){return await emitStepAndTurnFailed(e,t,n),await e(createSessionWaitingEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function advanceStep(e){return{...e,stepIndex:e.stepIndex+1}}async function emitTurnEpilogue(e,t,n){return await e(createTurnCompletedEvent({sequence:t.sequence,turnId:t.turnId})),n===`conversation`?await e(createSessionWaitingEvent()):await e(createSessionCompletedEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function normalizeAssistantStepFinishReason(e){switch(e){case`content-filter`:case`error`:case`length`:case`stop`:case`tool-calls`:return e;default:return`other`}}async function emitStreamContent(e,t,n,r){let i=createOrderedStreamEmitter(e),a=createProviderStreamActionBatch({emitFn:i.emit,state:t});try{return await consumeStreamContent(i.emit,t,interruptStreamOnFailure(n,i.failureSignal),a,r)}finally{try{await a.cancel()}finally{await i.closeAndDrain()}}}async function consumeStreamContent(a,o,s,c,l){let u=``,d=``,f=`stop`,p,m=new Set,h=new Set,g=new Set,_=new Set,v=new Set,y=new Set,b=[],x=[],flushCurrentMessage=async()=>{d.length!==0&&(await a(createMessageCompletedEvent({finishReason:`tool-calls`,message:d,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),d=``)},emitActionRequest=async e=>{h.has(e.callId)||(d.trim().length>0&&await flushCurrentMessage(),h.add(e.callId),await a(createActionsRequestedEvent({actions:[e],sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))},collectProviderToolCall=async e=>{_.has(e.toolCallId)||(_.add(e.toolCallId),!h.has(e.toolCallId)&&(h.add(e.toolCallId),d.trim().length>0&&await flushCurrentMessage(),c.observe({callId:e.toolCallId,input:resolveToolCallInputObject(e.input,{callId:e.toolCallId,toolName:e.toolName}),kind:`tool-call`,toolName:e.toolName})))},emitActionResult=async e=>{g.has(e.callId)||(g.add(e.callId),await a(createActionResultEvent({result:e,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))},emitToolCall=async e=>{if(!(l===void 0||e.invalid===!0||l.excludedActionToolNames.has(e.toolName)))try{await emitActionRequest(createRuntimeActionRequestFromToolCall({toolCall:e,tools:l.tools}))}catch(t){if(t instanceof TypeError){let n=createInvalidToolCallInputError({error:t,toolCall:e});y.add(e.toolCallId),d.trim().length>0&&await flushCurrentMessage(),await emitActionResult(createRuntimeToolResultFromToolError(n)),v.add(e.toolCallId),x.push(createToolResultMessagePartFromToolError(n));return}throw t}};for await(let t of s)if(p===void 0)switch(t.type){case`reasoning-delta`:await c.flush(),u+=t.text,await a(createReasoningAppendedEvent({reasoningDelta:t.text,reasoningSoFar:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`text-delta`:await c.flush(),u.trim().length>0&&(await a(createReasoningCompletedEvent({reasoning:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),u=``),d+=t.text,await a(createMessageAppendedEvent({messageDelta:t.text,messageSoFar:d,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`tool-call`:{let e=t;m.add(e.toolCallId),e.providerExecuted===!0?await collectProviderToolCall(e):(await c.flush(),await emitToolCall(e));break}case`tool-result`:{let e=t;if(e.preliminary===!0)break;if(e.providerExecuted===!0){await collectProviderToolCall({input:`input`in e?e.input:void 0,toolCallId:e.toolCallId,toolName:e.toolName}),await c.flush(),await emitActionResult(createRuntimeToolResultFromStepResult(e));break}if(m.has(t.toolCallId)){if(isInlineAuthorizationToolResult(e))break;h.has(t.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromStepResult(e)),v.add(t.toolCallId));break}if(await c.flush(),await flushCurrentMessage(),isInlineAuthorizationToolResult(e)){v.add(t.toolCallId),b.push(e);break}await emitActionResult(createRuntimeToolResultFromStepResult(e)),v.add(t.toolCallId);break}case`tool-error`:{let e=t;e.providerExecuted===!0?(await collectProviderToolCall(e),await c.flush(),await emitActionResult(createRuntimeToolResultFromToolError(e))):h.has(e.toolCallId)&&(await emitActionResult(createRuntimeToolResultFromToolError(e)),v.add(e.toolCallId),x.push(createToolResultMessagePartFromToolError(e)));break}case`finish-step`:f=normalizeAssistantStepFinishReason(t.finishReason),await c.flush();break;case`error`:p=normalizeModelStreamError(t.error);break;case`abort`:throw new DOMException(t.reason??`The model stream was aborted.`,`AbortError`);default:break}if(await c.flush(),p!==void 0)throw p;return u.trim().length>0&&await a(createReasoningCompletedEvent({reasoning:u,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),f!==`tool-calls`&&hasEmptyDeliverySentinel(d)?await a(createMessageCompletedEvent({finishReason:f,message:null,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})):d.trim().length>0&&await a(createMessageCompletedEvent({finishReason:f,message:d,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),{emittedActionCallIds:h,handledInlineToolResultCallIds:v,invalidInputToolCallIds:y,inlineAuthorizationResults:b,trailingInlineToolResultParts:x}}export{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStepStarted,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,normalizeAssistantStepFinishReason,setHarnessEmissionState};
@@ -0,0 +1,3 @@
1
+ import type { ToolSet, TypedToolResult } from "ai";
2
+ /** Returns whether an inline tool result represents a pending authorization interrupt. */
3
+ export declare function isInlineAuthorizationToolResult(toolResult: TypedToolResult<ToolSet>): boolean;
@@ -0,0 +1 @@
1
+ import{contextStorage}from"#context/container.js";import{isAuthorizationSignal,isPendingAuthorizationToolOutput}from"#harness/authorization.js";import{readToolInterrupt}from"#harness/tool-interrupts.js";function isInlineAuthorizationToolResult(e){if(isPendingAuthorizationToolOutput(e.output))return!0;let t=contextStorage.getStore();if(t===void 0)return!1;let n=readToolInterrupt(t,e.toolCallId);return n!==void 0&&isAuthorizationSignal(n)}export{isInlineAuthorizationToolResult};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Stops consuming `stream` as soon as `failureSignal` aborts, including while
3
+ * the underlying iterator is stalled in `next()`.
4
+ */
5
+ export declare function interruptStreamOnFailure<T>(stream: AsyncIterable<T>, failureSignal: AbortSignal): AsyncIterable<T>;
@@ -0,0 +1 @@
1
+ async function*interruptStreamOnFailure(e,t){let n=e[Symbol.asyncIterator](),r=!1;try{for(;;){let e=await nextOrFailure(n,t);if(e.done){r=!0;return}yield e.value}}finally{if(!r&&n.return!==void 0)try{let e=n.return();Promise.resolve(e).catch(()=>{})}catch{}}}function nextOrFailure(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let onFailure=()=>{r(t.reason)};t.addEventListener(`abort`,onFailure,{once:!0});let i;try{i=e.next()}catch(e){t.removeEventListener(`abort`,onFailure),r(e);return}i.then(e=>{t.removeEventListener(`abort`,onFailure),n(e)},e=>{t.removeEventListener(`abort`,onFailure),r(e)})})}export{interruptStreamOnFailure};
@@ -1 +1 @@
1
- import{isObject}from"#shared/guards.js";import{toError}from"#shared/errors.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";const GATEWAY_AUTHENTICATION_ERROR_NAME=`GatewayAuthenticationError`,GATEWAY_AUTH_FAILURE_SUMMARY_NAME=`AI Gateway authentication failed`,UNSUPPORTED_TOOL_TYPE_REGEX=/tool type ['"]([\w.-]+)['"] is not supported/i;function summarizeKnownModelCallConfigError(e){let t=readErrorName(e),n=readErrorMessage(e);return t===`GatewayAuthenticationError`||/AI Gateway authentication/i.test(n)?/Invalid API key/i.test(n)?{name:GATEWAY_AUTH_FAILURE_SUMMARY_NAME,message:"AI Gateway rejected the provided API key. Update or unset `AI_GATEWAY_API_KEY` (check your shell profile if you did not set it for this project) — manage keys at https://vercel.com/dashboard/ai/api-keys. Unsetting it falls back to OIDC via `eve link`."}:/Invalid OIDC token/i.test(n)?{name:GATEWAY_AUTH_FAILURE_SUMMARY_NAME,message:"AI Gateway rejected the OIDC token. Run `eve link` to refresh `VERCEL_OIDC_TOKEN` in `.env.local`, or set `AI_GATEWAY_API_KEY` — create a key at https://vercel.com/dashboard/ai/api-keys."}:{name:GATEWAY_AUTH_FAILURE_SUMMARY_NAME,message:"AI Gateway received no credentials. Run `eve link` to populate `VERCEL_OIDC_TOKEN`, or set `AI_GATEWAY_API_KEY` — create a key at https://vercel.com/dashboard/ai/api-keys."}:t===`LoadAPIKeyError`||/API key is missing/i.test(n)?{name:`Model provider API key missing`,message:"The model provider could not load an API key. Export the provider's API key environment variable (for example `AI_GATEWAY_API_KEY` or `OPENAI_API_KEY`) and try again."}:null}function summarizeKnownModelCallRequestError(e){if(e instanceof EmptyModelResponseError)return{name:`Empty model response`,message:e.message};let t=readModelCallErrorSignals(e);return t.statusCode===400&&isGatewayErrorSignal(t)?{name:`AI Gateway model request rejected`,message:`AI Gateway rejected the model request before the agent produced a response.`}:null}function extractUnsupportedProviderToolTypes(e){let t=new Set;for(let n of walkCauseChain(e)){collectUnsupportedToolTypesFromValue(readObjectField(n,`data`),t);let e=readStringField(n,`responseBody`);if(e!==void 0)try{collectUnsupportedToolTypesFromValue(JSON.parse(e),t)}catch{let n=UNSUPPORTED_TOOL_TYPE_REGEX.exec(e);n?.[1]!==void 0&&t.add(n[1])}}return[...t]}function collectUnsupportedToolTypesFromValue(t,n){if(t!=null){if(typeof t==`string`){let e=UNSUPPORTED_TOOL_TYPE_REGEX.exec(t);e?.[1]!==void 0&&n.add(e[1]);return}if(Array.isArray(t)){for(let e of t)collectUnsupportedToolTypesFromValue(e,n);return}if(isObject(t))for(let e of Object.values(t))collectUnsupportedToolTypesFromValue(e,n)}}function extractModelCallErrorDetails(e){let t=readModelCallErrorSignals(e),n={};return appendJsonField(n,`gatewayName`,t.gatewayName),appendJsonField(n,`gatewayType`,t.gatewayType),appendJsonField(n,`statusCode`,t.statusCode),appendJsonField(n,`generationId`,t.generationId),appendJsonField(n,`upstreamStatusCode`,t.upstreamStatusCode),appendJsonField(n,`upstreamType`,t.upstreamType),appendJsonField(n,`upstreamMessage`,t.upstreamMessage),appendJsonField(n,`responseBodySnippet`,t.responseBodySnippet),n}function readErrorName(t){if(t instanceof Error||isObject(t)&&typeof t.name==`string`)return t.name}function readErrorMessage(t){return t instanceof Error||isObject(t)&&typeof t.message==`string`?t.message:``}var EmptyModelResponseError=class extends Error{constructor(e){super(`The model did not return a response. Please try again.`,e),this.name=`EmptyModelResponseError`}};function normalizeModelStreamError(e){let n=toError(e);return n===e||Object.defineProperty(n,"cause",{configurable:!0,value:e}),n}function isNoOutputGeneratedError(e){for(let t of walkCauseChain(e))if(readErrorName(t)===`AI_NoOutputGeneratedError`)return!0;return!1}function classifyModelCallError(e){if(isTurnCancellation(e))return`terminal`;if(e instanceof EmptyModelResponseError)return`recoverable`;if(hasRetryableFlag(e))return`retry`;if(summarizeKnownModelCallConfigError(e)!==null)return`terminal`;let t=readModelCallErrorSignals(e);if(isRetryableGatewayType(t.gatewayType)||isRetryableGatewayType(t.upstreamType))return`retry`;if(isTerminalGatewayType(t.gatewayType)||isTerminalGatewayType(t.upstreamType)||t.gatewayName===`GatewayInvalidRequestError`)return`terminal`;let r=t.statusCode;if(r!==void 0){if(r===408||r===409||r===429||r>=500)return`retry`;if(isAmbiguousGatewayInternalBadRequest(t))return`recoverable`;if(r>=400&&r<500)return`terminal`}return isLikelyNetworkError(e)?`retry`:`recoverable`}function hasRetryableFlag(t){for(let n of walkCauseChain(t))if(isObject(n)&&n.isRetryable===!0)return!0;return!1}function isLikelyNetworkError(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`econnreset`)||t.includes(`etimedout`)||t.includes(`eai_again`)||t.includes(`socket hang up`)||t.includes(`network`)||t.includes(`fetch failed`)?!0:e.cause!==void 0&&e.cause!==e?isLikelyNetworkError(e.cause):!1}function readModelCallErrorSignals(e){let t=findGatewayError(e),n=findUpstreamApiCallError(e),r=readStringField(n,`responseBody`),i=readGatewayErrorBody(n);return{gatewayName:readErrorName(t),gatewayType:readStringField(t,`type`),generationId:readStringField(t,`generationId`)??i?.generationId,responseBodySnippet:r===void 0?void 0:truncateSnippet(r,1e3),statusCode:readStatusCode(t)??readStatusCode(n)??findStatusCode(e),upstreamMessage:i?.message,upstreamStatusCode:readStatusCode(n),upstreamType:i?.type}}function findGatewayError(e){for(let t of walkCauseChain(e)){let e=readErrorName(t),n=readStringField(t,`type`);if(e?.startsWith(`Gateway`)||n?.endsWith(`_error`)||n===`rate_limit_exceeded`)return t}}function findUpstreamApiCallError(e){for(let t of walkCauseChain(e))if(readErrorName(t)===`AI_APICallError`||readStringField(t,`responseBody`)!==void 0||readObjectField(t,`data`)!==void 0||readObjectField(t,`requestBodyValues`)!==void 0)return t}function readGatewayErrorBody(e){let t=readGatewayErrorBodyFromValue(readObjectField(e,`data`));if(t!==void 0)return t;let n=readStringField(e,`responseBody`);if(n!==void 0)try{return readGatewayErrorBodyFromValue(JSON.parse(n))}catch{return}}function readGatewayErrorBodyFromValue(t){if(!isObject(t))return;let n=readObjectField(t,`error`);if(n===void 0)return;let r=readStringField(t,`generationId`),i=readStringField(n,`message`),a=readStringField(n,`type`);return i===void 0&&a===void 0&&r===void 0?void 0:{generationId:r,message:i,type:a}}function readStatusCode(t){if(isObject(t))return typeof t.statusCode==`number`?t.statusCode:void 0}function findStatusCode(e){for(let t of walkCauseChain(e)){let e=readStatusCode(t);if(e!==void 0)return e}}function readStringField(t,n){if(!isObject(t))return;let r=t[n];return typeof r==`string`&&r.length>0?r:void 0}function readObjectField(t,n){if(!isObject(t))return;let r=t[n];return isObject(r)?r:void 0}function isRetryableGatewayType(e){return e===`overloaded_error`||e===`rate_limit_exceeded`||e===`timeout_error`}function isTerminalGatewayType(e){return e===`authentication_error`||e===`invalid_request_error`||e===`model_not_found`}function isGatewayErrorSignal(e){return e.gatewayName!==void 0||e.gatewayType!==void 0}function isAmbiguousGatewayInternalBadRequest(e){return e.statusCode===400&&(e.gatewayName===`GatewayInternalServerError`||e.gatewayType===`internal_server_error`)&&(e.upstreamType===void 0||e.upstreamType===`internal_server_error`)}function*walkCauseChain(t){let n=new Set,r=t;for(;isObject(r)&&!n.has(r);)n.add(r),yield r,r=r.cause}function appendJsonField(e,t,n){if(typeof n==`string`&&n.length>0){e[t]=n;return}typeof n==`number`&&Number.isFinite(n)&&(e[t]=n)}function truncateSnippet(e,t){return e.length<=t?e:`${e.slice(0,t)}...<truncated>`}export{EmptyModelResponseError,GATEWAY_AUTHENTICATION_ERROR_NAME,GATEWAY_AUTH_FAILURE_SUMMARY_NAME,classifyModelCallError,extractModelCallErrorDetails,extractUnsupportedProviderToolTypes,isNoOutputGeneratedError,normalizeModelStreamError,summarizeKnownModelCallConfigError,summarizeKnownModelCallRequestError};
1
+ import{isObject}from"#shared/guards.js";import{toError}from"#shared/errors.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";const GATEWAY_AUTHENTICATION_ERROR_NAME=`GatewayAuthenticationError`,GATEWAY_AUTH_FAILURE_SUMMARY_NAME=`AI Gateway authentication failed`,UNSUPPORTED_TOOL_TYPE_REGEX=/tool type ['"]([\w.-]+)['"] is not supported/i;function summarizeKnownModelCallConfigError(e){let t=readErrorName(e),n=readErrorMessage(e);return t===`GatewayAuthenticationError`||/AI Gateway authentication/i.test(n)?/Invalid API key/i.test(n)?{name:GATEWAY_AUTH_FAILURE_SUMMARY_NAME,message:"AI Gateway rejected the provided API key. Update or unset `AI_GATEWAY_API_KEY` (check your shell profile if you did not set it for this project) — manage keys at https://vercel.com/dashboard/ai/api-keys. Unsetting it falls back to OIDC via `eve link`."}:/Invalid OIDC token/i.test(n)?{name:GATEWAY_AUTH_FAILURE_SUMMARY_NAME,message:"AI Gateway rejected the OIDC token. Run `eve link` to refresh `VERCEL_OIDC_TOKEN` in `.env.local`, or set `AI_GATEWAY_API_KEY` — create a key at https://vercel.com/dashboard/ai/api-keys."}:{name:GATEWAY_AUTH_FAILURE_SUMMARY_NAME,message:"AI Gateway received no credentials. Run `eve link` to populate `VERCEL_OIDC_TOKEN`, or set `AI_GATEWAY_API_KEY` — create a key at https://vercel.com/dashboard/ai/api-keys."}:t===`LoadAPIKeyError`||/API key is missing/i.test(n)?{name:`Model provider API key missing`,message:"The model provider could not load an API key. Export the provider's API key environment variable (for example `AI_GATEWAY_API_KEY` or `OPENAI_API_KEY`) and try again."}:null}function summarizeKnownModelCallRequestError(e){if(e instanceof EmptyModelResponseError)return{name:`Empty model response`,message:e.message};let t=readModelCallErrorSignals(e);if(isTransientHttpStatus(t.statusCode??t.upstreamStatusCode))return null;let n=t.apiErrorMessage;if(n!==void 0)return{name:isGatewayErrorSignal(t)?`AI Gateway model request rejected`:`Model provider API error`,message:n};if(t.statusCode===400&&isGatewayErrorSignal(t))return{name:`AI Gateway model request rejected`,message:`AI Gateway rejected the model request before the agent produced a response.`};let r=formatApiCallErrorFallback(t);return r===void 0?null:{name:isGatewayErrorSignal(t)?`AI Gateway model request rejected`:`Model provider API error`,message:r}}function isTransientHttpStatus(e){return e===408||e===429||e!==void 0&&e>=500}function extractUnsupportedProviderToolTypes(e){let t=new Set;for(let n of walkCauseChain(e)){collectUnsupportedToolTypesFromValue(readObjectField(n,`data`),t);let e=readStringField(n,`responseBody`);if(e!==void 0)try{collectUnsupportedToolTypesFromValue(JSON.parse(e),t)}catch{let n=UNSUPPORTED_TOOL_TYPE_REGEX.exec(e);n?.[1]!==void 0&&t.add(n[1])}}return[...t]}function collectUnsupportedToolTypesFromValue(t,n){if(t!=null){if(typeof t==`string`){let e=UNSUPPORTED_TOOL_TYPE_REGEX.exec(t);e?.[1]!==void 0&&n.add(e[1]);return}if(Array.isArray(t)){for(let e of t)collectUnsupportedToolTypesFromValue(e,n);return}if(isObject(t))for(let e of Object.values(t))collectUnsupportedToolTypesFromValue(e,n)}}function extractModelCallErrorDetails(e){let t=readModelCallErrorSignals(e),n={};return appendJsonField(n,`apiErrorMessage`,t.apiErrorMessage),appendJsonField(n,`gatewayName`,t.gatewayName),appendJsonField(n,`gatewayType`,t.gatewayType),appendJsonField(n,`statusCode`,t.statusCode),appendJsonField(n,`generationId`,t.generationId),appendJsonField(n,`upstreamStatusCode`,t.upstreamStatusCode),appendJsonField(n,`upstreamType`,t.upstreamType),appendJsonField(n,`upstreamMessage`,t.upstreamMessage),appendJsonField(n,`responseBodySnippet`,t.responseBodySnippet),n}function readErrorName(t){if(t instanceof Error||isObject(t)&&typeof t.name==`string`)return t.name}function readErrorMessage(t){return t instanceof Error||isObject(t)&&typeof t.message==`string`?t.message:``}var EmptyModelResponseError=class extends Error{constructor(e){super(`The model did not return a response. Please try again.`,e),this.name=`EmptyModelResponseError`}};function normalizeModelStreamError(e){let n=toError(e);return n===e||Object.defineProperty(n,"cause",{configurable:!0,value:e}),n}function isNoOutputGeneratedError(e){for(let t of walkCauseChain(e))if(readErrorName(t)===`AI_NoOutputGeneratedError`)return!0;return!1}function classifyModelCallError(e){if(isTurnCancellation(e))return`terminal`;if(e instanceof EmptyModelResponseError)return`recoverable`;if(hasRetryableFlag(e))return`retry`;if(summarizeKnownModelCallConfigError(e)!==null)return`terminal`;let t=readModelCallErrorSignals(e);if(isRetryableGatewayType(t.gatewayType)||isRetryableGatewayType(t.upstreamType))return`retry`;if(isTerminalGatewayType(t.gatewayType)||isTerminalGatewayType(t.upstreamType)||t.gatewayName===`GatewayInvalidRequestError`)return`terminal`;let r=t.statusCode;if(r!==void 0){if(r===408||r===409||r===429||r>=500)return`retry`;if(isAmbiguousGatewayInternalBadRequest(t))return`recoverable`;if(r>=400&&r<500)return`terminal`}return isLikelyNetworkError(e)?`retry`:`recoverable`}function hasRetryableFlag(t){for(let n of walkCauseChain(t))if(isObject(n)&&n.isRetryable===!0)return!0;return!1}function isLikelyNetworkError(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes(`econnreset`)||t.includes(`etimedout`)||t.includes(`eai_again`)||t.includes(`socket hang up`)||t.includes(`network`)||t.includes(`fetch failed`)?!0:e.cause!==void 0&&e.cause!==e?isLikelyNetworkError(e.cause):!1}function readModelCallErrorSignals(e){let t=findGatewayError(e),n=findUpstreamApiCallError(e),r=readStringField(n,`responseBody`),i=readGatewayErrorBody(n);return{apiCallError:n!==void 0,apiErrorMessage:i?.apiErrorMessage??firstInformativeApiMessage([readErrorMessage(n)]),gatewayName:readErrorName(t),gatewayType:readStringField(t,`type`),generationId:readStringField(t,`generationId`)??i?.generationId,responseBodySnippet:r===void 0?void 0:truncateSnippet(r,1e3),statusCode:readStatusCode(t)??readStatusCode(n)??findStatusCode(e),upstreamMessage:i?.message,upstreamStatusCode:readStatusCode(n),upstreamType:i?.type}}function findGatewayError(e){for(let t of walkCauseChain(e)){let e=readErrorName(t),n=readStringField(t,`type`);if(e?.startsWith(`Gateway`)||n?.endsWith(`_error`)||n===`rate_limit_exceeded`)return t}}function findUpstreamApiCallError(e){for(let t of walkCauseChain(e))if(readErrorName(t)===`AI_APICallError`||readStringField(t,`responseBody`)!==void 0||readObjectField(t,`data`)!==void 0||readObjectField(t,`requestBodyValues`)!==void 0)return t}function readGatewayErrorBody(e){let t=readGatewayErrorBodyFromValue(readObjectField(e,`data`));if(t!==void 0)return t;let n=readStringField(e,`responseBody`);if(n!==void 0)try{return readGatewayErrorBodyFromValue(JSON.parse(n))}catch{return}}function readGatewayErrorBodyFromValue(t){if(!isObject(t))return;let n=readObjectField(t,`error`),r=readStringField(t,`generationId`),i=readStringField(n,`message`)??readStringField(t,`message`),a=readStringField(n,`type`)??readStringField(t,`type`),o=firstInformativeApiMessage([i,...readNestedApiErrorMessages(n),...readNestedApiErrorMessages(t)]);return i===void 0&&a===void 0&&r===void 0&&o===void 0?void 0:{apiErrorMessage:o,generationId:r,message:i,type:a}}function readStatusCode(t){if(isObject(t))return typeof t.statusCode==`number`?t.statusCode:void 0}function findStatusCode(e){for(let t of walkCauseChain(e)){let e=readStatusCode(t);if(e!==void 0)return e}}function readStringField(t,n){if(!isObject(t))return;let r=t[n];return typeof r==`string`&&r.length>0?r:void 0}function readObjectField(t,n){if(!isObject(t))return;let r=t[n];return isObject(r)?r:void 0}function readNestedApiErrorMessages(t){if(!isObject(t))return[];let n=[];return appendString(n,readStringField(t,`message`)),appendString(n,readStringField(t,`error_description`)),appendNestedApiFieldMessages(n,t.error),appendNestedApiFieldMessages(n,t.code),n}function appendNestedApiFieldMessages(t,n){if(typeof n==`string`){appendString(t,n);return}isObject(n)&&(appendString(t,readStringField(n,`message`)),appendString(t,readStringField(n,`error`)),appendString(t,readStringField(n,`description`)),appendString(t,readStringField(n,`error_description`)),appendNestedApiFieldMessages(t,n.error))}function appendString(e,t){t!==void 0&&e.push(t)}function firstInformativeApiMessage(e){for(let t of e)if(t!==void 0&&isInformativeApiMessage(t))return truncateSnippet(t,800)}function isInformativeApiMessage(e){let t=e.trim();return t.length>0&&t!==`[object Object]`&&t!==`AI_APICallError`&&t!==`Bad Request`&&t!==`Internal Server Error`}function formatApiCallErrorFallback(e){if(!e.apiCallError)return;let t=e.statusCode??e.upstreamStatusCode,n=e.responseBodySnippet,r=e.upstreamType!==void 0&&isInformativeApiMessage(e.upstreamType)?e.upstreamType:void 0;if(t===void 0&&n===void 0&&r===void 0)return;let i=[t===void 0?void 0:`HTTP ${t}`,r].filter(e=>e!==void 0).join(`, `),a=i.length===0?`Model provider API request failed`:`Model provider API request failed (${i})`;return n===void 0?`${a}.`:`${a}: ${n}`}function isRetryableGatewayType(e){return e===`overloaded_error`||e===`rate_limit_exceeded`||e===`timeout_error`}function isTerminalGatewayType(e){return e===`authentication_error`||e===`invalid_request_error`||e===`model_not_found`}function isGatewayErrorSignal(e){return e.gatewayName!==void 0||e.gatewayType!==void 0}function isAmbiguousGatewayInternalBadRequest(e){return e.statusCode===400&&(e.gatewayName===`GatewayInternalServerError`||e.gatewayType===`internal_server_error`)&&(e.upstreamType===void 0||e.upstreamType===`internal_server_error`)}function*walkCauseChain(t){let n=new Set,r=t;for(;isObject(r)&&!n.has(r);)n.add(r),yield r,r=r.cause}function appendJsonField(e,t,n){if(typeof n==`string`&&n.length>0){e[t]=n;return}typeof n==`number`&&Number.isFinite(n)&&(e[t]=n)}function truncateSnippet(e,t){return e.length<=t?e:`${e.slice(0,t)}...<truncated>`}export{EmptyModelResponseError,GATEWAY_AUTHENTICATION_ERROR_NAME,GATEWAY_AUTH_FAILURE_SUMMARY_NAME,classifyModelCallError,extractModelCallErrorDetails,extractUnsupportedProviderToolTypes,isNoOutputGeneratedError,normalizeModelStreamError,summarizeKnownModelCallConfigError,summarizeKnownModelCallRequestError};
@@ -0,0 +1,17 @@
1
+ import type { HarnessEmitFn } from "#harness/types.js";
2
+ interface OrderedStreamEmitter {
3
+ closeAndDrain(): Promise<void>;
4
+ emit: HarnessEmitFn;
5
+ readonly failureSignal: AbortSignal;
6
+ }
7
+ /**
8
+ * Decouples model-stream consumption from the durable event sink while
9
+ * preserving FIFO dispatch. Adjacent append events waiting behind the active
10
+ * write are folded together; every other event remains an ordering barrier.
11
+ * Coalescing before the durable writer keeps one Workflow chunk per emitted
12
+ * event, so event-count reconnect cursors remain aligned with chunk indexes.
13
+ */
14
+ export declare function createOrderedStreamEmitter(emitFn: HarnessEmitFn, options?: {
15
+ readonly maxPendingEvents?: number;
16
+ }): OrderedStreamEmitter;
17
+ export {};
@@ -0,0 +1 @@
1
+ const MAX_PENDING_DELTA_CHARACTERS=64*1024;function createOrderedStreamEmitter(t,n={}){let r=n.maxPendingEvents??64;if(!Number.isInteger(r)||r<1)throw RangeError(`maxPendingEvents must be a positive integer.`);let i=[],a=new Set,o=new Set,s=!1,c=0,l=0,u,d=!1,f=!1,p=new AbortController,throwIfFailed=()=>{if(d)throw u},settleIdleWaiters=()=>{for(let e of o)e();o.clear()},hasCapacity=()=>l<r&&c<MAX_PENDING_DELTA_CHARACTERS,settleCapacityWaiters=()=>{if(hasCapacity()){for(let e of a)e();a.clear()}},pump=async()=>{if(!(f||d)){for(f=!0;i.length>0;){let e=i.shift();if(e===void 0)break;c-=e.deltaCharacters,l-=e.sourceEvents,settleCapacityWaiters();try{await t(materializeEvent(e),e.messages)}catch(e){d||(u=e,d=!0,p.abort(e)),i.length=0,c=0,l=0,settleCapacityWaiters();break}}f=!1,settleIdleWaiters()}},waitForIdle=async()=>{if(!f&&i.length===0){throwIfFailed();return}await new Promise(e=>{o.add(e)}),throwIfFailed()},waitForCapacity=async()=>{hasCapacity()||(await new Promise(e=>{a.add(e)}),throwIfFailed())};return{async closeAndDrain(){s=!0,pump(),await waitForIdle()},async emit(t,n){if(throwIfFailed(),s)throw TypeError(`Cannot emit after the ordered stream emitter has closed.`);let a=i[i.length-1],o=appendDelta(t);a===void 0||!mergeAdjacentAppends(a,t,n)?i.push({deltaCharacters:o?.length??0,event:t,messages:n,sourceEvents:1}):(a.deltaCharacters+=o?.length??0,a.sourceEvents+=1),c+=o?.length??0,l+=1,pump(),(l>=r||c>=MAX_PENDING_DELTA_CHARACTERS)&&await waitForCapacity(),throwIfFailed()},failureSignal:p.signal}}function mergeAdjacentAppends(e,t,n){return e.event.type===`message.appended`&&t.type===`message.appended`?sameCoordinates(e.event,t)?(e.deltaParts??=[e.event.data.messageDelta],e.deltaParts.push(t.data.messageDelta),e.event=t,e.messages=n,!0):!1:e.event.type===`reasoning.appended`&&t.type===`reasoning.appended`&&sameCoordinates(e.event,t)?(e.deltaParts??=[e.event.data.reasoningDelta],e.deltaParts.push(t.data.reasoningDelta),e.event=t,e.messages=n,!0):!1}function appendDelta(e){if(e.type===`message.appended`)return e.data.messageDelta;if(e.type===`reasoning.appended`)return e.data.reasoningDelta}function materializeEvent(e){return e.deltaParts===void 0?e.event:e.event.type===`message.appended`?{...e.event,data:{...e.event.data,messageDelta:e.deltaParts.join(``)}}:e.event.type===`reasoning.appended`?{...e.event,data:{...e.event.data,reasoningDelta:e.deltaParts.join(``)}}:e.event}function sameCoordinates(e,t){return e.data.sequence===t.data.sequence&&e.data.stepIndex===t.data.stepIndex&&e.data.turnId===t.data.turnId}export{createOrderedStreamEmitter};
@@ -6,6 +6,7 @@ interface ActionEventCoordinates {
6
6
  readonly turnId: string;
7
7
  }
8
8
  interface ProviderStreamActionBatch {
9
+ cancel(): Promise<void>;
9
10
  flush(): Promise<void>;
10
11
  observe(action: RuntimeToolCallActionRequest): void;
11
12
  }
@@ -1 +1 @@
1
- import{createActionsRequestedEvent}from"#protocol/message.js";function createProviderStreamActionBatch(t){let n=new Map,r=Promise.resolve(),i,a,o,emitPendingActions=async()=>{if(n.size===0)return;let r=[...n.values()];n.clear(),await t.emitFn(createActionsRequestedEvent({actions:r,sequence:t.state.sequence,stepIndex:t.state.stepIndex,turnId:t.state.turnId}))},scheduleFlush=()=>{if(a!==void 0)return;let e,t=new Promise(t=>{e=t});o=e,a=setTimeout(()=>{a=void 0,o=void 0,e?.()},0),r=r.then(()=>t).then(emitPendingActions).catch(e=>{i??=e})};return{observe(e){n.set(e.callId,e),scheduleFlush()},async flush(){if(a!==void 0){clearTimeout(a),a=void 0;let e=o;o=void 0,e?.()}if(await r,i!==void 0)throw i;await emitPendingActions()}}}export{createProviderStreamActionBatch};
1
+ import{createActionsRequestedEvent}from"#protocol/message.js";function createProviderStreamActionBatch(t){let n=new Map,r=Promise.resolve(),i,a,o=!1,s,emitPendingActions=async()=>{if(o){n.clear();return}if(n.size===0)return;let r=[...n.values()];n.clear(),await t.emitFn(createActionsRequestedEvent({actions:r,sequence:t.state.sequence,stepIndex:t.state.stepIndex,turnId:t.state.turnId}))},scheduleFlush=()=>{if(o||a!==void 0)return;let e,t=new Promise(t=>{e=t});s=e,a=setTimeout(()=>{a=void 0,s=void 0,e?.()},0),r=r.then(()=>t).then(emitPendingActions).catch(e=>{i??=e})},releaseFlushTimer=()=>{if(a===void 0)return;clearTimeout(a),a=void 0;let e=s;s=void 0,e?.()};return{async cancel(){o=!0,n.clear(),releaseFlushTimer(),await r},observe(e){o||(n.set(e.callId,e),scheduleFlush())},async flush(){if(!o){if(releaseFlushTimer(),await r,i!==void 0)throw i;await emitPendingActions()}}}}export{createProviderStreamActionBatch};
@@ -1,6 +1,6 @@
1
1
  import type { HarnessSession } from "#harness/types.js";
2
2
  import type { RuntimeActionRequest, RuntimeRemoteAgentCallActionRequest, RuntimeSubagentCallActionRequest } from "#runtime/actions/types.js";
3
- export declare const DEFAULT_SUBAGENT_MAX_DEPTH = 3;
3
+ export declare const DEFAULT_SUBAGENT_MAX_DEPTH = 1;
4
4
  export type DelegatedRuntimeActionRequest = RuntimeRemoteAgentCallActionRequest | RuntimeSubagentCallActionRequest;
5
5
  export type SubagentDelegationLimit = {
6
6
  readonly currentDepth: number;
@@ -1 +1 @@
1
- import{SubagentDepthKey}from"#context/keys.js";const DEFAULT_SUBAGENT_MAX_DEPTH=3;function resolveSubagentDelegationLimit(e){let t=parseSubagentDepth(e.subagentDepth),n=parseSubagentMaxDepth(e.subagentMaxDepth)??3;return{currentDepth:t,maxDepth:n,nextChildDepth:t+1,reached:t>=n}}function readSerializedSubagentDepth(t){let n=parseSubagentDepth(t[SubagentDepthKey.name]);return n===0?void 0:n}function isSubagentDelegationAction(e){return e.kind===`subagent-call`||e.kind===`remote-agent-call`}function getSubagentDelegationName(e){switch(e.kind){case`remote-agent-call`:return e.remoteAgentName;case`subagent-call`:return e.subagentName;default:return e}}function parseSubagentDepth(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:0}function parseSubagentMaxDepth(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:void 0}export{DEFAULT_SUBAGENT_MAX_DEPTH,getSubagentDelegationName,isSubagentDelegationAction,readSerializedSubagentDepth,resolveSubagentDelegationLimit};
1
+ import{SubagentDepthKey}from"#context/keys.js";const DEFAULT_SUBAGENT_MAX_DEPTH=1;function resolveSubagentDelegationLimit(e){let t=parseSubagentDepth(e.subagentDepth),n=parseSubagentMaxDepth(e.subagentMaxDepth)??1;return{currentDepth:t,maxDepth:n,nextChildDepth:t+1,reached:t>=n}}function readSerializedSubagentDepth(t){let n=parseSubagentDepth(t[SubagentDepthKey.name]);return n===0?void 0:n}function isSubagentDelegationAction(e){return e.kind===`subagent-call`||e.kind===`remote-agent-call`}function getSubagentDelegationName(e){switch(e.kind){case`remote-agent-call`:return e.remoteAgentName;case`subagent-call`:return e.subagentName;default:return e}}function parseSubagentDepth(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:0}function parseSubagentMaxDepth(e){return typeof e==`number`&&Number.isInteger(e)&&e>0?e:void 0}export{DEFAULT_SUBAGENT_MAX_DEPTH,getSubagentDelegationName,isSubagentDelegationAction,readSerializedSubagentDepth,resolveSubagentDelegationLimit};