eve 0.79.1 → 0.79.2

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 (64) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/channel/pending-authorization.d.ts +10 -0
  3. package/dist/src/channel/pending-authorization.js +1 -0
  4. package/dist/src/compiled/.vendor-stamp.json +2 -2
  5. package/dist/src/compiled/@eve/tracing/index.js +1 -1
  6. package/dist/src/compiled/@eve/tracing/otel.js +1 -1
  7. package/dist/src/compiled/_chunks/workflow/{mcp-C01bDEX-.js → mcp-Bwx_LQ4q.js} +4 -4
  8. package/dist/src/compiler/extension-compatibility.d.ts +18 -18
  9. package/dist/src/compiler/extension-compatibility.js +1 -1
  10. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  11. package/dist/src/execution/proxied-deliver-step.js +1 -1
  12. package/dist/src/execution/publish-session-events.d.ts +13 -3
  13. package/dist/src/execution/publish-session-events.js +1 -1
  14. package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
  15. package/dist/src/execution/session/active-turn.d.ts +2 -1
  16. package/dist/src/execution/session/active-turn.js +1 -1
  17. package/dist/src/execution/session/turn-step.js +1 -1
  18. package/dist/src/execution/session/turn.d.ts +1 -0
  19. package/dist/src/execution/session/turn.js +1 -1
  20. package/dist/src/execution/tasks/task-id-input.js +1 -1
  21. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  22. package/dist/src/execution/tools/workflow/apply-run-messages-step.d.ts +6 -2
  23. package/dist/src/execution/tools/workflow/apply-run-messages-step.js +1 -1
  24. package/dist/src/execution/tools/workflow/body.d.ts +10 -1
  25. package/dist/src/execution/tools/workflow/body.js +1 -1
  26. package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
  27. package/dist/src/execution/tools/workflow/serve.js +1 -1
  28. package/dist/src/harness/action-result-helpers.js +1 -1
  29. package/dist/src/harness/attachment-staging.js +1 -1
  30. package/dist/src/harness/compaction/engine.js +3 -1
  31. package/dist/src/harness/compaction/prompt.d.ts +7 -0
  32. package/dist/src/harness/compaction/prompt.js +1 -1
  33. package/dist/src/harness/hitl/approvals.js +1 -1
  34. package/dist/src/harness/hitl/approved-calls.js +1 -1
  35. package/dist/src/harness/input-request-resolution.d.ts +2 -1
  36. package/dist/src/harness/input-request-resolution.js +1 -1
  37. package/dist/src/instrumentation/native-events.js +1 -1
  38. package/dist/src/internal/application/optional-package-import.d.ts +5 -0
  39. package/dist/src/internal/application/optional-package-import.js +1 -1
  40. package/dist/src/internal/application/stamped-package-version.js +1 -1
  41. package/dist/src/internal/nitro/host/start-production-server.js +2 -2
  42. package/dist/src/protocol/message.d.ts +2 -0
  43. package/dist/src/protocol/message.js +1 -1
  44. package/dist/src/public/channels/teams/authorization.d.ts +53 -0
  45. package/dist/src/public/channels/teams/authorization.js +1 -0
  46. package/dist/src/public/channels/teams/defaults.js +2 -2
  47. package/dist/src/public/channels/teams/hitl.d.ts +2 -1
  48. package/dist/src/public/channels/teams/teamsChannel.js +1 -1
  49. package/dist/src/public/channels/telegram/authorization-callback.js +1 -1
  50. package/dist/src/public/next/index.js +1 -1
  51. package/dist/src/public/next/server.d.ts +11 -2
  52. package/dist/src/public/next/server.js +1 -1
  53. package/dist/src/setup/scaffold/create/project.js +1 -1
  54. package/dist/src/shared/action-types.d.ts +1 -0
  55. package/dist/src/shared/action-types.js +1 -1
  56. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  57. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  58. package/dist/src/tools/signature.d.ts +4 -2
  59. package/dist/src/tools/signature.js +1 -1
  60. package/docs/channels/teams.mdx +6 -0
  61. package/docs/concepts/built-in-tools.md +1 -1
  62. package/docs/guides/hooks.md +4 -0
  63. package/docs/guides/instrumentation/instrumentation.mdx +2 -0
  64. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # eve
2
2
 
3
+ ## 0.79.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 910705c: An agent or `serve` tool call with an empty `taskId` now starts a new task instead of failing with `UNKNOWN_TASK`. Some models send `""` for the optional `taskId` rather than omitting it.
8
+ - 3ac1bd0: `eve start` no longer keeps the server's stdout and stderr in memory after startup. Output is still forwarded, and an unexpected exit no longer repeats the full log history in its error.
9
+ - 4c8ffa6: Keep successful tool calls completed when their output includes `code` and `message` fields.
10
+ - ee0c6c0: `ctx.cancel()` in a `message.received` hook now cancels the turn when the message is a plain-text answer to a pending `ask_question` or `ctx.ask()` question. The question resolves as `cancelled` and the tool call never receives the text. Before, eve logged a warning and delivered the answer. `ctx.cancel()` in an `action.partial` hook for a workflow tool's report now cancels the turn waiting on that tool too.
11
+ - bc4edd9: Attachments no longer fail a step when the session's sandbox cannot be resumed, for example when a follow-up lands on another replica. Earlier attachments and tool-result files in history reach the model as a "FileNotFound" note, and new inbound attachments and tool-returned files become a "could not be stored" note. Tools that use the sandbox still report the resume error.
12
+ - 2de4011: Fail fast with an actionable error when the project has an unsupported `microsandbox` version (such as 0.7), instead of every sandbox operation throwing `isInstalled is not a function`.
13
+ - 394ed22: Start built, managed eve agents when a local production Next.js server loads its configuration, so `next start` can serve eve routes.
14
+ - f6bf73e: Keep every property name in `eve__search` tool signatures that run past the length cap. A long signature now drops its property descriptions before any property name, so the model no longer misses fields a large MCP tool such as Linear's `save_issue` supports.
15
+ - b382594: Compaction no longer re-caps a tool result it already capped. A capped result now fits the size limit it was measured against, so later compactions leave it as it is instead of nesting another truncation notice and keeping less of the original content. A summary written after a cap also sees the whole content the capped result kept.
16
+ - a1c18f5: Teams group chats and channels no longer show connection sign-in links or confirmation codes in the shared thread. The card now has a **Sign in** button, and Teams shows the link only to the person who has to sign in, so another member can't connect their own account under the requester's identity.
17
+ - 9f3a634: Snapshot retained tracing arguments and errors so later mutations cannot introduce private content into telemetry or checkpoints. Apply accepted delegation capture ceilings when re-entering durable turns, including through `resume()`.
18
+ - ec2862e: When a tool throws, the error on its `tool.call.failed` instrumentation event now keeps the thrown error's `name`, such as `QuotaError`, instead of always reading `Error`. The `action.result` stream event reports the same name as `error.name`.
19
+ - c1880f4: Parse a workflow tool's result as JSON when its run completes, the way a local tool's result already is. A tool that returns `ctx.ask()`'s answer directly, after the person picked an option, no longer fails the turn with `Cannot convert undefined or null to object`: undefined properties are omitted, a tool that returns nothing reports `null`, and the same applies to `ctx.reply()` in `serve` tools. A result JSON can't carry, such as a `Date` or `Map`, now fails the call with a serialization error instead of reaching the model as `{}`.
20
+
3
21
  ## 0.79.1
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,10 @@
1
+ import type { Session } from "#channel/session.js";
2
+ import type { AuthorizationRequiredStreamEvent } from "#protocol/message.js";
3
+ type AuthorizationRequired = AuthorizationRequiredStreamEvent["data"];
4
+ /**
5
+ * The newest sign-in that `matches` and hasn't completed yet, from the
6
+ * session's recent events. Attempts are keyed by connection name and
7
+ * `attemptId`, so one attempt completing never hides another still pending.
8
+ */
9
+ export declare function findPendingAuthorization(session: Pick<Session, "getEventStream">, matches: (event: AuthorizationRequired) => boolean): Promise<AuthorizationRequired | undefined>;
10
+ export {};
@@ -0,0 +1 @@
1
+ async function findPendingAuthorization(e,t){let n=new Map,r=(await e.getEventStream({follow:!1,startIndex:-500})).getReader();try{for(;;){let e=await r.read();if(e.done)break;let i=e.value;if(i.type===`authorization.required`&&t(i.data)){let e=attemptKey(i.data);n.delete(e),n.set(e,i.data)}else i.type===`authorization.completed`&&n.delete(attemptKey(i.data))}}finally{await r.cancel().catch(()=>{})}return[...n.values()].at(-1)}function attemptKey(e){return JSON.stringify([e.name,e.attemptId??null])}export{findPendingAuthorization};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "moduleFingerprints": {
3
3
  "@eve/catalog": "d5babf703f0f589f123ee2043b72bcb4823ccccbe5034315c3b70fbae7cd76a0",
4
- "@eve/tracing": "db045e46c45dfa0c1d045789bb04cfbe21999a0c35a848844b25e011ed332004",
4
+ "@eve/tracing": "f9d137e4e8838f1a359a8897b7229ecb243f441386b8e5e78fd71445be04b4ad",
5
5
  "just-secrets": "1ce67d437d0bb06df02e4e99180a3c5f5edf0010314010226e97b96d462bba5d",
6
6
  "@workflow/world-local": "a10e78551f65fc607cf75261a569d852c40bc9cfac13a7fb6e15c88bf1ccf429"
7
7
  },
@@ -61,7 +61,7 @@
61
61
  "zod": "4.5.4",
62
62
  "zod-validation-error": "5.0.0"
63
63
  },
64
- "scriptHash": "ad76180bc219ba33360a00db361000cab844f139baecb30faf54c133084f24b4",
64
+ "scriptHash": "e2b444777326d6ef8f68b8571793402c26df6ba49dcc7943a71038e9216be63a",
65
65
  "toolVersions": {
66
66
  "rolldown": "1.2.9",
67
67
  "typescript": "7.0.2"
@@ -1 +1 @@
1
- import{f as e,g as t,i as n,l as r,m as i,n as a,o,r as s,s as c,t as l,u,v as d}from"../../_chunks/workflow/mcp-C01bDEX-.js";import{n as f,t as p}from"../../_chunks/workflow/delegation-BqhZ398D.js";import{createHash as m,randomBytes as h,randomUUID as g}from"node:crypto";var _=class{#e;#t;allocateSpanId(){return y(16)}deriveSpanId(e){return v(e)}deriveTraceId(e){let t=m(`sha256`).update(e).digest(`hex`).slice(0,32);return/^0+$/u.test(t)?`00000000000000000000000000000001`:t}generateSpanId(){let e=this.#e;return e===void 0?y(16):(this.#e=void 0,e)}generateTraceId(){let e=this.#t;return e===void 0?y(32):(this.#t=void 0,e)}withSpanId(e,t){this.#e=e;try{return t()}finally{this.#e=void 0}}withTraceId(e,t){this.#t=e;try{return t()}finally{this.#t=void 0}}};function v(e){let t=m(`sha256`).update(e).digest(`hex`).slice(0,16);return/^0+$/u.test(t)?`0000000000000001`:t}function y(e){let t;do{t=``;for(let n=0;n<e;n+=1)t+=`0123456789abcdef`[Math.trunc(Math.random()*16)]}while(!/[1-9a-f]/u.test(t));return t}function b(e,t,n,r){let i=!1;try{return e.run(t,()=>(i=!0,n()),r)}catch(t){if(i)throw t;if(e.suppressed!==void 0)try{return e.suppressed(()=>(i=!0,n()))}catch(e){if(i)throw e}return n()}}function x(e){function n(t,n=`complete`,r){try{return t()}catch(t){try{e.onError?.(t,{phase:n,reference:r})}catch{}return}}function r(r,i,a,o){let s=u(r.attributes,i)??r.attributes,c=i.emit?n(()=>e.telemetry.startSpan({...r,attributes:s},{reference:o,context:a}),`start`,o):void 0,l=c?.reference??{traceId:`0`.repeat(32),spanId:`0`.repeat(16),traceFlags:0},d=!1;return{reference:l,get capture(){return i},narrow(e){i=t(i,e)},get finished(){return d},setAttribute(e,t){let r=u({[e]:t},i);!d&&(r===void 0||e in r)&&n(()=>c?.setAttribute(e,r===void 0?t:r[e]))},addEvent(e,t,r){d||n(()=>c?.addEvent(e,t===void 0?void 0:u(t,i)??t,r))},fail(e,t){d||n(()=>c?.fail(i.recordOutputs?e:void 0,t??(e instanceof Error?e.name:void 0)))},setStatus(e){d||n(()=>c?.setStatus(e))},end(e){d||(d=!0,n(()=>c?.end(e)))},run(t){return d?t():b(e.telemetry,{type:r.type,reference:l,capture:i},t,a)}}}return{start:r,startReserved:(e,t,n,i)=>r(e,n,i,t)}}const S=32768,C=65536;function w(e,t){function n(t,n){return r(()=>Reflect.apply(e[t],e,n))}function r(e){try{let t=e();return t===void 0||new TextEncoder().encode(t).length>S?void 0:t}catch(e){try{t?.(e,{phase:`serialize`})}catch{}return}}return{json:e=>n(`json`,[e]),text:e=>n(`text`,[e]),inputMessages:t=>{let n=0,i=r(()=>{let r=e.inputMessages(t);return n=r?.omitted??0,r?.json});return i===void 0?void 0:{json:i,omitted:n}},instructions:e=>n(`instructions`,[e]),toolDefinitions:e=>n(`toolDefinitions`,[e]),outputMessages:(e,t)=>n(`outputMessages`,[e,t]),toolResults:e=>n(`toolResults`,[e])}}function T(e){return new TextEncoder().encode(JSON.stringify({...e,children:void 0})).length}function ee(e){return JSON.parse(JSON.stringify(e))}function E(e,t=C,n=0){try{if(n>16||typeof e!=`object`||!e)return!1;let r=e;if(r.children!==void 0&&(!Array.isArray(r.children)||r.children.length>1e4||!r.children.every(e=>E(e,t,n+1)))||r.version!==1||r.finished!==void 0&&typeof r.finished!=`boolean`||r.childSequence!==void 0&&(!Number.isSafeInteger(r.childSequence)||r.childSequence<0)||typeof r.key!=`string`||typeof r.startTimeMs!=`number`||!Number.isFinite(r.startTimeMs)||r.reference.traceFlags!==0&&r.reference.traceFlags!==1||r.reference.tracestate!==void 0&&(typeof r.reference.tracestate!=`string`||r.reference.tracestate.length>512)||r.parent!==void 0&&(!/^[a-f0-9]{32}$/u.test(r.parent.traceId)||!/^[a-f0-9]{16}$/u.test(r.parent.spanId))||![r.identity.conversationId,r.identity.runId,r.identity.turnId].every(e=>typeof e==`string`))return!1;let i=r.data.options;return!(!{activation:[],step:[],model:[`provider`,`modelId`],tool:[`callId`,`name`],approval:[`requestId`,`callId`,`toolName`],memory:[`operation`,`phase`,`slot`,`storeId`]}[r.data.type].every(e=>typeof i[e]==`string`)||r.data.type===`activation`&&!Number.isSafeInteger(i.sequence)||r.data.type===`step`&&!Number.isSafeInteger(i.index)||r.data.type===`memory`&&i.operation!==`search_memory`&&i.operation!==`upsert_memory`||!/^[a-f0-9]{32}$/u.test(r.reference.traceId)||!/^[a-f0-9]{16}$/u.test(r.reference.spanId)||typeof r.reference.traceFlags!=`number`||![r.capture.emit,r.capture.recordInputs,r.capture.recordOutputs].every(e=>typeof e==`boolean`)||![`activation`,`step`,`model`,`tool`,`approval`,`memory`].includes(r.data.type)||typeof r.data.options!=`object`||r.data.options===null||T(r)>t)}catch{return!1}}function D(e,t){let n=e.terminal;e={...e,children:e.children?.map(n=>D({...n,capture:{emit:n.capture.emit&&e.capture.emit,recordInputs:n.capture.recordInputs&&e.capture.recordInputs,recordOutputs:n.capture.recordOutputs&&e.capture.recordOutputs}},t))},e={...e,terminal:n===void 0||e.finished?void 0:{...n,errorCode:n.errorCode??(n.error instanceof Error?n.error.name:void 0),error:e.capture.recordOutputs?n.error instanceof Error?{name:n.error.name,message:t.text(n.error.message)}:n.error:void 0,output:e.capture.recordOutputs?n.output:void 0,response:e.capture.recordOutputs?n.response:void 0,records:e.capture.recordInputs?n.records:void 0,model:n.model===void 0?void 0:{...n.model,content:e.capture.recordOutputs?n.model.content:void 0}}},e={...e,attributes:u(e.attributes??{},e.capture)??e.attributes};let r=s(e.data,e.capture),i;try{i=t.json(r)}catch{}let a=()=>{let t=s(r,{emit:e.capture.emit,recordInputs:!1,recordOutputs:!1});return t.type===`step`&&(t={...t,options:{...t.options,runtimeContext:void 0}}),t.type===`model`&&(t={...t,options:{...t.options,runtimeContext:void 0}}),JSON.parse(JSON.stringify({...e,version:1,data:t,terminal:e.terminal===void 0?void 0:{outcome:e.terminal.outcome,failed:e.terminal.failed,errorCode:e.terminal.errorCode,usage:e.terminal.usage},attributes:u(e.attributes??{},{recordInputs:!1,recordOutputs:!1})??e.attributes}))};if(i===void 0||new TextEncoder().encode(i).length>S)return a();try{let t=JSON.parse(JSON.stringify({...e,version:1,data:JSON.parse(i)}));return T(t)<=C?t:a()}catch{return a()}}const O=1e4,k={emit:!1,recordInputs:!1,recordOutputs:!1},te=new Set([`activation`,`tool`,`approval`]),ne=new Set([`tool`,`approval`]);function A(e){return encodeURIComponent(String(e))}function j(e){switch(e.type){case`step`:return`step:${A(e.options.index)}:${A(e.options.attempt??0)}`;case`tool`:return`tool:${A(e.options.callId)}`;case`approval`:return`approval:${A(e.options.requestId)}`;default:return}}function M(e){let t=e.failed||e.outcome===`failed`;return{...e,model:`result`in e?e.result:e.model,failed:t,errorCode:`errorType`in e?e.errorType:e.errorCode}}function N(e){let i=e.telemetry,d=w(e.serializer,e.onError),p=x({telemetry:i,onError:e.onError}),m=(t,n)=>{try{e.onError?.(t,n)}catch{}};function g(t,n,r,a,o){let s=i.ids;if(e.durable&&s!==void 0&&t.type!==`model`&&t.type!==`memory`){if(t.type===`activation`&&r!==void 0)return{traceId:r.traceId,spanId:s.spanId(n),traceFlags:o.emit?r.traceFlags&1:0};if(t.type===`activation`){let e=s.traceId(n);return{traceId:e,spanId:s.spanId(n),traceFlags:o.emit&&(i.samples?.(e,a)??!0)?1:0}}return r===void 0?void 0:{...r,spanId:s.spanId(n),isRemote:!1}}}async function _(e,t,n,r,i,a,o){try{return await v(e,t,n,r,i,a,o)}catch(t){return m(t,{phase:`start`,operation:n.type,reference:a.reference}),v(e,k,s(n,k),r,i,{...a,sample:!1,reference:{traceId:a.reference?.traceId??r?.reference.traceId??a.parent?.traceId??h(16).toString(`hex`),spanId:a.reference?.spanId??h(8).toString(`hex`),traceFlags:0}},o)}}async function v(h,v,y,x,S,C,w){if(C.terminal?.error!==null&&typeof C.terminal?.error==`object`&&!(C.terminal.error instanceof Error)&&`message`in C.terminal.error&&typeof C.terminal.error.message==`string`){let e=Error(C.terminal.error.message);e.name=C.terminal.errorCode??`Error`,C={...C,terminal:{...C.terminal,error:e}}}let T=C.key,E=C.startTimeMs??Date.now(),N=C.parent??x?.reference;v.emit&&(v=t(v,i.active()?.capture));let P=v,F=s(y,P),I=c({identity:h,data:F,attempt:S,capture:P,key:T,parent:N,startTimeMs:E,links:C.links},d);I={...I,attributes:{...I.attributes,...C.attributes}},F=D({key:T,identity:h,data:F,capture:P,reference:C.reference??{traceId:`0`.repeat(32),spanId:`0`.repeat(16),traceFlags:0},startTimeMs:E},d).data;let L=C.deferred??(e.durable&&te.has(F.type)),R=C.executionContext,z=C.reference??g(y,T,N,I,P);C.sample===!0&&z!==void 0&&(z={...z,traceFlags:z.traceFlags&1&&P.emit&&(N!==void 0||(i.samples?.(z.traceId,I)??!0))?1:0});let B=L?void 0:p.start(I,P,R,z),V=z??B?.reference;if(V===void 0)throw Error(`A deferred trace scope requires a reserved reference.`);let H=!!(V.traceFlags&1);P={emit:P.emit&&H,recordInputs:P.emit&&H&&P.recordInputs,recordOutputs:P.emit&&H&&P.recordOutputs},F=s(F,P);let U=C.finished??!1,W=C.terminal,G=new Map,K=new Set,q=C.childSequence??0,J=C.usage,Y=new Set(C.usageKeys??[]),X={},re=F.type===`tool`?F.options.callId:void 0;function Z(){w()}function Q(){return t(P,i.active()?.capture)}async function ie(t,n,r={}){let i=G.get(n);if(e.durable&&i!==void 0&&!i.settled)return i.refine(t,r.startTimeMs),i;if(U)throw Error(`The operation is not permitted in this trace scope.`);for(let[e,t]of G)t.settled&&G.delete(e);let o=P;G.size>=O&&(m(Error(`Trace unfinished-child limit reached.`),{phase:`start`,operation:t.type,reference:V}),o=k),t.type===`model`&&B!==void 0&&a(B,{"agent.model.id":t.options.modelId});let s=await _(h,o,t,$,t.type===`step`?{index:t.options.index,attempt:t.options.attempt??0}:S,{key:n,executionContext:R,links:r.links,startTimeMs:r.startTimeMs},w);return(o.emit||G.size<O)&&G.set(n,s),await w(),s}async function ae(e,t){let n=F.type===`step`||F.type===`activation`;for(let r of G.values())(t||!n||!ne.has(r.type))&&await r.release({failed:e.failed,error:e.error,outcome:`abandoned`})}async function oe(t){if(K.size>0&&await Promise.allSettled(K),U)return;let r=Q();r.recordOutputs||(t={...t,error:void 0}),W?.failed&&(t={...t,outcome:t.outcome===`completed`?`failed`:t.outcome,failed:!0,error:W.error,errorCode:t.errorCode??W.errorCode}),U=!0,W=t,await ae(t,t.failed===!0||!e.durable),B??=p.start(I,P,R,V);let i=F.type===`activation`&&t.usage===void 0?{...t,usage:J}:t;try{n(B,F,i,{...r,emit:P.emit},E,d)}catch(e){m(e,{phase:`complete`,operation:F.type,reference:V})}if(a(B,X),F.type===`model`&&t.model!==void 0){await x?.usage(t.model.usage,T);let e=t.model.content;if(r.recordOutputs&&P.recordOutputs&&e!==void 0){let n=d.outputMessages(e,t.model.finishReason);n!==void 0&&x?.turnContent({output:n})}}B.end(t.endTimeMs),await w()}let $={waitUntil(e){K.add(e),x?.waitUntil(e),e.then(()=>K.delete(e),()=>K.delete(e))},snapshot:()=>ee($.record()),attributes:e=>$.update({attributes:e}),modelCall:(e,t)=>$.child({type:`model`,options:e},t),fail(e){return $.error(e),$.complete({outcome:`failed`,failed:!0})},update(e){if(U)return;let t=u(e.attributes??{},Q())??e.attributes;F.type===`activation`&&(F={...F,options:{...F.options,attributes:{...F.options.attributes,...t}}}),I={...I,attributes:{...I.attributes,...t},links:e.links??I.links},B!==void 0&&a(B,t),Z()},useContext(e){R=e;for(let t of G.values())t.useContext(e)},refine(e,t){if(U||B!==void 0)return;if(t!==void 0&&t<E&&(E=t),e.type===`tool`&&F.type===`tool`){let t=F.options;F=s({type:`tool`,options:{...t,kind:t.kind??e.options.kind,arguments:t.arguments??(Q().recordInputs?e.options.arguments:void 0)}},P)}let n=c({identity:h,data:F,attempt:S,capture:P,key:T,parent:N,startTimeMs:E,links:I.links},d),r=Object.fromEntries(Object.entries(n.attributes).filter(([,e])=>e!==void 0));I={...I,name:n.name,kind:n.kind,startTimeMs:E,attributes:{...I.attributes,...r}},Z()},narrow(e){P={...t(P,e),emit:P.emit},F=s(F,P);let n=u(I.attributes,P)??I.attributes;I={...I,attributes:F.type===`activation`?{...n,"agent.trace.content.input":P.recordInputs,"agent.trace.content.output":P.recordOutputs}:n};let r=u(X,P)??X;for(let e of Object.keys(X))e in r||delete X[e];!P.recordOutputs&&W?.error!==void 0&&(W={...W,error:void 0}),B?.narrow(P);for(let e of G.values())e.narrow(P);Z()},async release(t){U?await ae(t,t.failed===!0||!e.durable):await oe(M(t))},record(){return D({version:1,finished:U,terminal:W,usage:J,usageKeys:[...Y],attributes:{...I.attributes,...X},childSequence:q,children:[...G.values()].filter(e=>!e.settled).map(e=>e.record()),key:T,identity:h,data:F,capture:P,reference:V,parent:N,startTimeMs:E,attempt:S,links:I.links},d)},get parent(){return N},get startTimeMs(){return E},child(t,n,r){if(!o(t).includes(F.type))throw Error(`The operation is not permitted in this trace scope.`);let i=n===void 0?(e.durable?j(t):void 0)??`${t.type}:${q++}`:`${t.type}:${A(n)}`;return ie(t,`${T}/${i}`,r)},find(e){let t=j(e),n=t===void 0?void 0:G.get(`${T}/${t}`);return n===void 0||n.settled?void 0:n},get children(){return[...G.values()].filter(e=>!e.settled)},type:F.type,reference:V,callId:re,get capture(){return P},mcp:l({serializer:d,...P,write(e){let t=u(e,Q())??e;Object.assign(X,t),B!==void 0&&a(B,t)},error(e,t){$.error(e,t)}}),get finished(){return U},get settled(){return U&&[...G.values()].every(e=>e.settled)},run(e,n){if(U)throw Error(`The trace scope has already finished.`);let r=t(t(P,n),i.active()?.capture),a=F.type===`tool`&&(F.options.kind===`subagent-call`||F.options.kind===`remote-agent-call`)?F.options:void 0,o=a===void 0?e:()=>f({caller:V,conversationId:h.conversationId,parentRunId:h.runId,parentCallId:a.callId,agentName:a.name,capture:r},e);return b(i,{type:$.type,reference:V,capture:r,mcp:$.mcp},o,R)},async complete(e=W??{}){U||await oe(M(e))},async usage(e,t){t!==void 0&&Y.has(t)||(t!==void 0&&Y.add(t),B!==void 0&&a(B,r(e)),J={inputTokens:e.inputTokens===void 0?J?.inputTokens:(J?.inputTokens??0)+e.inputTokens,outputTokens:e.outputTokens===void 0?J?.outputTokens:(J?.outputTokens??0)+e.outputTokens,costUsd:e.costUsd===void 0?J?.costUsd:(J?.costUsd??0)+e.costUsd},await x?.usage(e,t))},turnContent(e){if(F.type!==`activation`)return x?.turnContent(e);if(U)return;let t={};e.input!==void 0&&I.attributes[`gen_ai.input.messages`]===void 0&&(t[`gen_ai.input.messages`]=e.input),e.output!==void 0&&(t[`gen_ai.output.messages`]=e.output),Object.keys(t).length>0&&$.update({attributes:t})},error(e,t){W={...W,failed:!0,error:Q().recordOutputs?e:void 0,errorCode:t??(e instanceof Error?e.name:void 0)},B!==void 0&&B.fail(W.error,W.errorCode),Z()}};for(let e of C.children??[])G.set(e.key,await _(e.identity,t(e.capture,P),e.data,$,e.attempt,{...e,deferred:!0,executionContext:R},w));!U&&B!==void 0&&F.type===`step`&&B.addEvent(`step.started`,void 0,E);let se=I.attributes[`gen_ai.input.messages`];return!U&&F.type===`model`&&typeof se==`string`&&x?.turnContent({input:se}),$}return{start(e){return _(e.identity,e.capture,e.data,void 0,void 0,{key:e.key,parent:e.parent,reference:e.reference,sample:e.reference!==void 0&&e.data.type===`activation`,startTimeMs:e.startTimeMs,links:e.links,executionContext:e.context},e.onChange??(()=>Promise.resolve()))},async restore(e,n={}){if(!E(e)){m(Error(`Invalid tracing checkpoint.`),{phase:`restore`});return}return _(e.identity,t(e.capture,n.capture),e.data,void 0,e.attempt,{...e,deferred:!0,executionContext:n.context},n.onChange??(()=>Promise.resolve()))}}}function P(e,t,n){try{e?.(t,{phase:n})}catch{}}function F(e,t={outcome:`completed`},n){async function r(r,i){if(i===void 0)return e(r);let a=await e(r),o=t;try{let e=await a.run(()=>i(a));try{o=r.describe?.(e)??t}catch(e){P(n,e,`complete`)}return e}catch(e){throw o={outcome:`failed`,errorType:e instanceof Error?e.name:`_OTHER`,error:e},e}finally{try{await a.complete(o)}catch(e){P(n,e,`complete`)}}}return r}function I(e,t,n){let r=t=>Object.defineProperties(t,{finished:{get:()=>e.finished},capture:{get:()=>e.capture},parent:{get:()=>e.parent}}),i={type:e.type,reference:e.reference,get startTimeMs(){return e.startTimeMs},get parent(){return e.parent},get finished(){return e.finished},get capture(){return e.capture},run:(t,n)=>e.run(t,n),attributes:t=>e.attributes(t),complete:t=>e.complete(t),fail:t=>e.fail(t),recordError:(t,n)=>e.error(t,n)},a=async(t,r,i)=>I(await e.child(t,r,i),t,n),o=F(async({startTimeMs:e,...t})=>a({type:`tool`,options:t},void 0,{startTimeMs:e}),void 0,n),s=e=>e===void 0?void 0:I(e,e.record().data,n),c=F(async e=>a({type:`memory`,options:e}),void 0,n);if(t.type===`activation`)return r({...i,memory:c,links:t=>e.update({links:t}),findAttempt:t=>s(e.find({type:`step`,options:{index:t.stepIndex,attempt:t.attempt}})),findTool:t=>s(L(e,t)),attempt:F(async e=>a({type:`step`,options:{index:e.stepIndex,attempt:e.attempt,runtimeContext:e.runtimeContext,channel:e.channel}},void 0,{links:e.links}),void 0,n)});if(t.type===`step`){let t=e=>F(async t=>a({type:`tool`,options:{callId:t.callId,name:t.agentName,kind:e}}),void 0,n),s=(e,t)=>a({type:`model`,options:e},t);async function l(e,t){if(typeof t!=`function`)return s(e,t);let r=await s(e),i;try{i=await r.run(t)}catch(e){try{await r.fail(e)}catch(e){P(n,e,`complete`)}throw e}try{await r.complete({outcome:`completed`,result:i})}catch(e){P(n,e,`complete`)}return i.result}return r({...i,memory:c,tool:o,callSubAgent:t(`subagent-call`),callRemoteAgent:t(`remote-agent-call`),modelCall:l,async modelStream(t,r){let i=await s(t);try{let t=await i.run(r),a=Promise.resolve(t.completion).then(e=>i.complete({outcome:`completed`,result:e}),e=>i.fail(e)).catch(e=>P(n,e,`complete`));return e.waitUntil(a),t.result}catch(e){try{await i.fail(e)}catch(e){P(n,e,`complete`)}throw e}}})}return t.type===`tool`?r({...i,memory:c,tool:o,findApproval:n=>s(e.find({type:`approval`,options:{requestId:n,callId:t.options.callId,toolName:t.options.name}})),approval:F(async e=>a({type:`approval`,options:{...e,callId:t.options.callId,toolName:t.options.name}}),{outcome:`ignored`},n)}):i}function L(e,t){for(let n of e.children){if(n.type===`tool`&&n.callId===t)return n;if(n.type===`step`||n.type===`tool`){let e=L(n,t);if(e!==void 0)return e}}}const R={emit:!0,recordInputs:!1,recordOutputs:!1};function z(n){let r=n.telemetry??e(),i=n.checkpointer;if(i!==void 0&&r.ids===void 0)throw Error(`Durable agent tracing needs stable span IDs. Pass the AgentSpanIdGenerator installed on your tracer provider to otelTelemetry({ idGenerator }).`);let a=(e,t)=>{try{n.onError?.(e,t)}catch{}},o=N({telemetry:r,serializer:n.serializer??d,durable:i!==void 0,onError:n.onError}),s=new Map;function c(e){return i===void 0?`turn:${g()}`:[`turn`,e.runId,e.turnId].map(encodeURIComponent).join(`:`)}function l(e,t){let n=Promise.resolve();return()=>{let r=t();return i===void 0||r===void 0?n:(r.writes++,n=n.then(async()=>{try{if(r.root.settled)s.delete(e),await i.delete(e);else{let t=g();await i.set(e,ee({...r.root.record(),revision:t})),r.revision=t}}catch(e){a(e,{phase:`checkpoint`,operation:`activation`})}finally{r.writes--}}),n)}}async function u(e){try{return await i.get(e)}catch(e){a(e,{phase:`restore`,operation:`activation`});return}}async function f(e,t,n,r,a){let s=i===void 0?void 0:await u(e);if(t!==void 0&&(t.writes>0||s?.revision===t.revision))return r!==void 0&&t.root.useContext(r),a!==void 0&&t.root.narrow(a),t;let c,d=l(e,()=>c),f=s===void 0?void 0:await o.restore(s,{capture:a,context:r,onChange:d}),p=f??await n?.(d);if(p!==void 0)return c={root:p,revision:s?.revision,writes:0},f===void 0&&await d(),c}function m(e,t){let n=s.get(e),r=(async()=>t(n===void 0?void 0:await n.catch(()=>void 0)))();return s.set(e,r),r.then(t=>{(t===void 0||t.root.settled)&&s.delete(e)},()=>s.delete(e)),s.size>1e3&&s.delete(s.keys().next().value),r}function h(e,n){return i=>{let a=p(),s=t(e.capture??R,a?.capture),c=a!==void 0&&e.sequence===0,l=e.parent??(c&&a?.remote!==!0?a?.caller:void 0),u=[...c&&a?.remote===!0?[{relationship:`agent.dispatch`,context:a.caller}]:[],...e.links??[]];return o.start({identity:{...e.identity,conversationId:a?.conversationId??e.identity.conversationId,agentName:e.agentName,framework:e.framework},key:n,capture:s,parent:l,reference:r.ids===void 0?void 0:e.reference,startTimeMs:e.startTimeMs,data:{type:`activation`,options:{sequence:e.sequence,attributes:e.attributes,channel:e.channel,subagent:a!==void 0||e.lineage!==void 0,subagentName:a?.agentName??e.lineage?.agentName,parentRunId:a?.parentRunId??e.lineage?.parentRunId,parentCallId:a?.parentCallId??e.lineage?.parentCallId}},links:u.length===0?void 0:u,context:e.context,onChange:i})}}function _(e){return I(e,{type:`activation`,options:{sequence:0}},n.onError)}async function v(e){let t=c(e.identity);return _((i===void 0?await f(t,void 0,h(e,t),e.context):await m(t,n=>f(t,n,h(e,t),e.context,e.capture))).root)}async function y(e){if(i===void 0)return;let t=c(e.identity),n=await m(t,n=>f(t,n,void 0,e.context));return n===void 0?void 0:_(n.root)}async function b(e){try{await e()}catch(e){a(e,{phase:`complete`})}}async function x(e,t,n){let i=r.active(),s=await o.start({identity:t.identity,key:`memory:${g()}`,capture:t.capture??i?.capture??R,parent:t.parent??i?.reference,context:t.context,data:{type:`memory`,options:{operation:e,phase:t.phase,slot:t.slot,storeId:t.storeId}}}),c;try{c=await s.run(n)}catch(e){throw await s.fail(e).catch(e=>a(e,{phase:`complete`})),e}return await s.complete({outcome:`completed`,...t.describe?.(c)}).catch(e=>a(e,{phase:`complete`})),c}return{turn:F(v,void 0,n.onError),resume:y,memory:{search:(e,t)=>x(`search_memory`,e,t),write:(e,t)=>x(`upsert_memory`,e,t)},forceFlush:()=>b(()=>r.forceFlush()),shutdown:()=>b(()=>r.shutdown())}}export{_ as AgentSpanIdGenerator,z as createAgentTracing,i as currentCapture,e as otelTelemetry};
1
+ import{b as e,f as t,g as n,i as r,l as i,m as a,n as o,o as s,r as c,s as l,t as u,u as d,v as f}from"../../_chunks/workflow/mcp-Bwx_LQ4q.js";import{n as p,t as m}from"../../_chunks/workflow/delegation-BqhZ398D.js";import{createHash as h,randomBytes as g,randomUUID as _}from"node:crypto";var v=class{#e;#t;allocateSpanId(){return b(16)}deriveSpanId(e){return y(e)}deriveTraceId(e){let t=h(`sha256`).update(e).digest(`hex`).slice(0,32);return/^0+$/u.test(t)?`00000000000000000000000000000001`:t}generateSpanId(){let e=this.#e;return e===void 0?b(16):(this.#e=void 0,e)}generateTraceId(){let e=this.#t;return e===void 0?b(32):(this.#t=void 0,e)}withSpanId(e,t){this.#e=e;try{return t()}finally{this.#e=void 0}}withTraceId(e,t){this.#t=e;try{return t()}finally{this.#t=void 0}}};function y(e){let t=h(`sha256`).update(e).digest(`hex`).slice(0,16);return/^0+$/u.test(t)?`0000000000000001`:t}function b(e){let t;do{t=``;for(let n=0;n<e;n+=1)t+=`0123456789abcdef`[Math.trunc(Math.random()*16)]}while(!/[1-9a-f]/u.test(t));return t}function x(e,t,n,r){let i=!1;try{return e.run(t,()=>(i=!0,n()),r)}catch(t){if(i)throw t;if(e.suppressed!==void 0)try{return e.suppressed(()=>(i=!0,n()))}catch(e){if(i)throw e}return n()}}function S(e){function t(t,n=`complete`,r){try{return t()}catch(t){try{e.onError?.(t,{phase:n,reference:r})}catch{}return}}function r(r,i,a,o){let s=d(r.attributes,i)??r.attributes,c=i.emit?t(()=>e.telemetry.startSpan({...r,attributes:s},{reference:o,context:a}),`start`,o):void 0,l=c?.reference??{traceId:`0`.repeat(32),spanId:`0`.repeat(16),traceFlags:0},u=!1;return{reference:l,get capture(){return i},narrow(e){i=n(i,e)},get finished(){return u},setAttribute(e,n){let r=d({[e]:n},i);!u&&(r===void 0||e in r)&&t(()=>c?.setAttribute(e,r===void 0?n:r[e]))},addEvent(e,n,r){u||t(()=>c?.addEvent(e,n===void 0?void 0:d(n,i)??n,r))},fail(e,n){u||t(()=>c?.fail(i.recordOutputs?e:void 0,n??(e instanceof Error?e.name:void 0)))},setStatus(e){u||t(()=>c?.setStatus(e))},end(e){u||(u=!0,t(()=>c?.end(e)))},run(t){return u?t():x(e.telemetry,{type:r.type,reference:l,capture:i},t,a)}}}return{start:r,startReserved:(e,t,n,i)=>r(e,n,i,t)}}const C=32768,w=65536;function T(e,t){function n(t,n){return r(()=>Reflect.apply(e[t],e,n))}function r(e){try{let t=e();return t===void 0||new TextEncoder().encode(t).length>C?void 0:t}catch(e){try{t?.(e,{phase:`serialize`})}catch{}return}}return{json:e=>n(`json`,[e]),text:e=>n(`text`,[e]),inputMessages:t=>{let n=0,i=r(()=>{let r=e.inputMessages(t);return n=r?.omitted??0,r?.json});return i===void 0?void 0:{json:i,omitted:n}},instructions:e=>n(`instructions`,[e]),toolDefinitions:e=>n(`toolDefinitions`,[e]),outputMessages:(e,t)=>n(`outputMessages`,[e,t]),toolResults:e=>n(`toolResults`,[e])}}function E(e){return new TextEncoder().encode(JSON.stringify({...e,children:void 0})).length}function ee(e){return JSON.parse(JSON.stringify(e))}function D(e,t=w,n=0){try{if(n>16||typeof e!=`object`||!e)return!1;let r=e;if(r.children!==void 0&&(!Array.isArray(r.children)||r.children.length>1e4||!r.children.every(e=>D(e,t,n+1)))||r.version!==1||r.finished!==void 0&&typeof r.finished!=`boolean`||r.childSequence!==void 0&&(!Number.isSafeInteger(r.childSequence)||r.childSequence<0)||typeof r.key!=`string`||typeof r.startTimeMs!=`number`||!Number.isFinite(r.startTimeMs)||r.reference.traceFlags!==0&&r.reference.traceFlags!==1||r.reference.tracestate!==void 0&&(typeof r.reference.tracestate!=`string`||r.reference.tracestate.length>512)||r.parent!==void 0&&(!/^[a-f0-9]{32}$/u.test(r.parent.traceId)||!/^[a-f0-9]{16}$/u.test(r.parent.spanId))||![r.identity.conversationId,r.identity.runId,r.identity.turnId].every(e=>typeof e==`string`))return!1;let i=r.data.options;return!(!{activation:[],step:[],model:[`provider`,`modelId`],tool:[`callId`,`name`],approval:[`requestId`,`callId`,`toolName`],memory:[`operation`,`phase`,`slot`,`storeId`]}[r.data.type].every(e=>typeof i[e]==`string`)||r.data.type===`activation`&&!Number.isSafeInteger(i.sequence)||r.data.type===`step`&&!Number.isSafeInteger(i.index)||r.data.type===`memory`&&i.operation!==`search_memory`&&i.operation!==`upsert_memory`||!/^[a-f0-9]{32}$/u.test(r.reference.traceId)||!/^[a-f0-9]{16}$/u.test(r.reference.spanId)||typeof r.reference.traceFlags!=`number`||![r.capture.emit,r.capture.recordInputs,r.capture.recordOutputs].every(e=>typeof e==`boolean`)||![`activation`,`step`,`model`,`tool`,`approval`,`memory`].includes(r.data.type)||typeof r.data.options!=`object`||r.data.options===null||E(r)>t)}catch{return!1}}function O(e,t){let n=e.terminal;e={...e,children:e.children?.map(n=>O({...n,capture:{emit:n.capture.emit&&e.capture.emit,recordInputs:n.capture.recordInputs&&e.capture.recordInputs,recordOutputs:n.capture.recordOutputs&&e.capture.recordOutputs}},t))},e={...e,terminal:n===void 0||e.finished?void 0:{...n,errorCode:n.errorCode??(n.error instanceof Error?n.error.name:void 0),error:e.capture.recordOutputs?n.error instanceof Error?{name:n.error.name,message:t.text(n.error.message)}:n.error:void 0,output:e.capture.recordOutputs?n.output:void 0,response:e.capture.recordOutputs?n.response:void 0,records:e.capture.recordInputs?n.records:void 0,model:n.model===void 0?void 0:{...n.model,content:e.capture.recordOutputs?n.model.content:void 0}}},e={...e,attributes:d(e.attributes??{},e.capture)??e.attributes};let r=c(e.data,e.capture),i;try{i=t.json(r)}catch{}let a=()=>{let t=c(r,{emit:e.capture.emit,recordInputs:!1,recordOutputs:!1});return t.type===`step`&&(t={...t,options:{...t.options,runtimeContext:void 0}}),t.type===`model`&&(t={...t,options:{...t.options,runtimeContext:void 0}}),JSON.parse(JSON.stringify({...e,version:1,data:t,terminal:e.terminal===void 0?void 0:{outcome:e.terminal.outcome,failed:e.terminal.failed,errorCode:e.terminal.errorCode,usage:e.terminal.usage},attributes:d(e.attributes??{},{recordInputs:!1,recordOutputs:!1})??e.attributes}))};if(i===void 0||new TextEncoder().encode(i).length>C)return a();try{let t=JSON.parse(JSON.stringify({...e,version:1,data:JSON.parse(i)}));return E(t)<=w?t:a()}catch{return a()}}const k=1e4,A={emit:!1,recordInputs:!1,recordOutputs:!1},te=new Set([`activation`,`tool`,`approval`]),ne=new Set([`tool`,`approval`]);function j(e){return encodeURIComponent(String(e))}function re(e){switch(e.type){case`step`:return`step:${j(e.options.index)}:${j(e.options.attempt??0)}`;case`tool`:return`tool:${j(e.options.callId)}`;case`approval`:return`approval:${j(e.options.requestId)}`;default:return}}function ie(e){let t=e.failed||e.outcome===`failed`;return{...e,model:`result`in e?e.result:e.model,failed:t,errorCode:`errorType`in e?e.errorType:e.errorCode}}function M(t){let a=t.telemetry,f=T(t.serializer,t.onError),m=S({telemetry:a,onError:t.onError}),h=(e,n)=>{try{t.onError?.(e,n)}catch{}};function _(e){let t=f.json(e);try{return t===void 0?void 0:JSON.parse(t)}catch{return}}function v(e,n,r,i,o){let s=a.ids;if(t.durable&&s!==void 0&&e.type!==`model`&&e.type!==`memory`){if(e.type===`activation`&&r!==void 0)return{traceId:r.traceId,spanId:s.spanId(n),traceFlags:o.emit?r.traceFlags&1:0};if(e.type===`activation`){let e=s.traceId(n);return{traceId:e,spanId:s.spanId(n),traceFlags:o.emit&&(a.samples?.(e,i)??!0)?1:0}}return r===void 0?void 0:{...r,spanId:s.spanId(n),isRemote:!1}}}async function y(e,t,n,r,i,a,o){try{return await b(e,t,n,r,i,a,o)}catch(t){return h(t,{phase:`start`,operation:n.type,reference:a.reference}),b(e,A,c(n,A),r,i,{...a,sample:!1,reference:{traceId:a.reference?.traceId??r?.reference.traceId??a.parent?.traceId??g(16).toString(`hex`),spanId:a.reference?.spanId??g(8).toString(`hex`),traceFlags:0}},o)}}async function b(g,b,S,C,w,T,E){if(T.terminal?.error!==null&&typeof T.terminal?.error==`object`&&!(T.terminal.error instanceof Error)&&`message`in T.terminal.error&&typeof T.terminal.error.message==`string`){let e=Error(T.terminal.error.message);e.name=T.terminal.errorCode??`Error`,T={...T,terminal:{...T.terminal,error:e}}}let D=T.key,M=T.startTimeMs??Date.now(),N=T.parent??C?.reference;b.emit&&(b=n(b,a.active()?.capture));let P=b,F=c(S,P),I=l({identity:g,data:F,attempt:w,capture:P,key:D,parent:N,startTimeMs:M,links:T.links},f);I={...I,attributes:{...I.attributes,...T.attributes}},F=O({key:D,identity:g,data:F,capture:P,reference:T.reference??{traceId:`0`.repeat(32),spanId:`0`.repeat(16),traceFlags:0},startTimeMs:M},f).data;let L=T.deferred??(t.durable&&te.has(F.type)),R=T.executionContext,z=T.reference??v(S,D,N,I,P);T.sample===!0&&z!==void 0&&(z={...z,traceFlags:z.traceFlags&1&&P.emit&&(N!==void 0||(a.samples?.(z.traceId,I)??!0))?1:0});let B=L?void 0:m.start(I,P,R,z),V=z??B?.reference;if(V===void 0)throw Error(`A deferred trace scope requires a reserved reference.`);let H=!!(V.traceFlags&1);P={emit:P.emit&&H,recordInputs:P.emit&&H&&P.recordInputs,recordOutputs:P.emit&&H&&P.recordOutputs},F=c(F,P);let U=T.finished??!1,W=T.terminal,G=new Map,K=new Set,ae=T.childSequence??0,q=T.usage,J=new Set(T.usageKeys??[]),Y={},oe=F.type===`tool`?F.options.callId:void 0;function X(){E()}function Z(){return n(P,a.active()?.capture)}async function se(e,n,r={}){let i=G.get(n);if(t.durable&&i!==void 0&&!i.settled)return i.refine(e,r.startTimeMs),i;if(U)throw Error(`The operation is not permitted in this trace scope.`);for(let[e,t]of G)t.settled&&G.delete(e);let a=P;G.size>=k&&(h(Error(`Trace unfinished-child limit reached.`),{phase:`start`,operation:e.type,reference:V}),a=A),e.type===`model`&&B!==void 0&&o(B,{"agent.model.id":e.options.modelId});let s=await y(g,a,e,$,e.type===`step`?{index:e.options.index,attempt:e.options.attempt??0}:w,{key:n,executionContext:R,links:r.links,startTimeMs:r.startTimeMs},E);return(a.emit||G.size<k)&&G.set(n,s),await E(),s}async function Q(e,t){let n=F.type===`step`||F.type===`activation`;for(let r of G.values())(t||!n||!ne.has(r.type))&&await r.release({failed:e.failed,error:e.error,outcome:`abandoned`})}async function ce(e){if(K.size>0&&await Promise.allSettled(K),U)return;let n=Z();n.recordOutputs||(e={...e,error:void 0}),W?.failed&&(e={...e,outcome:e.outcome===`completed`?`failed`:e.outcome,failed:!0,error:W.error,errorCode:e.errorCode??W.errorCode}),U=!0,W=e,await Q(e,e.failed===!0||!t.durable),B??=m.start(I,P,R,V);let i=F.type===`activation`&&e.usage===void 0?{...e,usage:q}:e;try{r(B,F,i,{...n,emit:P.emit},M,f)}catch(e){h(e,{phase:`complete`,operation:F.type,reference:V})}if(o(B,Y),F.type===`model`&&e.model!==void 0){await C?.usage(e.model.usage,D);let t=e.model.content;if(n.recordOutputs&&P.recordOutputs&&t!==void 0){let n=f.outputMessages(t,e.model.finishReason);n!==void 0&&C?.turnContent({output:n})}}B.end(e.endTimeMs),await E()}let $={waitUntil(e){K.add(e),C?.waitUntil(e),e.then(()=>K.delete(e),()=>K.delete(e))},snapshot:()=>ee($.record()),attributes:e=>$.update({attributes:e}),modelCall:(e,t)=>$.child({type:`model`,options:e},t),fail(e){return $.error(e),$.complete({outcome:`failed`,failed:!0})},update(e){if(U)return;let t=d(e.attributes??{},Z())??e.attributes;F.type===`activation`&&(F={...F,options:{...F.options,attributes:{...F.options.attributes,...t}}}),I={...I,attributes:{...I.attributes,...t},links:e.links??I.links},B!==void 0&&o(B,t),X()},useContext(e){R=e;for(let t of G.values())t.useContext(e)},refine(e,t){if(U||B!==void 0)return;if(t!==void 0&&t<M&&(M=t),e.type===`tool`&&F.type===`tool`){let t=F.options;F=c({type:`tool`,options:{...t,kind:t.kind??e.options.kind,arguments:t.arguments??(Z().recordInputs?_(e.options.arguments):void 0)}},P)}let n=l({identity:g,data:F,attempt:w,capture:P,key:D,parent:N,startTimeMs:M,links:I.links},f),r=Object.fromEntries(Object.entries(n.attributes).filter(([,e])=>e!==void 0));I={...I,name:n.name,kind:n.kind,startTimeMs:M,attributes:{...I.attributes,...r}},X()},narrow(e){P={...n(P,e),emit:P.emit},F=c(F,P);let t=d(I.attributes,P)??I.attributes;I={...I,attributes:F.type===`activation`?{...t,"agent.trace.content.input":P.recordInputs,"agent.trace.content.output":P.recordOutputs}:t};let r=d(Y,P)??Y;for(let e of Object.keys(Y))e in r||delete Y[e];!P.recordOutputs&&W?.error!==void 0&&(W={...W,error:void 0}),B?.narrow(P);for(let e of G.values())e.narrow(P);X()},async release(e){U?await Q(e,e.failed===!0||!t.durable):await ce(ie(e))},record(){return O({version:1,finished:U,terminal:W,usage:q,usageKeys:[...J],attributes:{...I.attributes,...Y},childSequence:ae,children:[...G.values()].filter(e=>!e.settled).map(e=>e.record()),key:D,identity:g,data:F,capture:P,reference:V,parent:N,startTimeMs:M,attempt:w,links:I.links},f)},get parent(){return N},get startTimeMs(){return M},child(e,n,r){if(!s(e).includes(F.type))throw Error(`The operation is not permitted in this trace scope.`);let i=n===void 0?(t.durable?re(e):void 0)??`${e.type}:${ae++}`:`${e.type}:${j(n)}`;return se(e,`${D}/${i}`,r)},find(e){let t=re(e),n=t===void 0?void 0:G.get(`${D}/${t}`);return n===void 0||n.settled?void 0:n},get children(){return[...G.values()].filter(e=>!e.settled)},type:F.type,reference:V,callId:oe,get capture(){return P},mcp:u({serializer:f,...P,write(e){let t=d(e,Z())??e;Object.assign(Y,t),B!==void 0&&o(B,t)},error(e,t){$.error(e,t)}}),get finished(){return U},get settled(){return U&&[...G.values()].every(e=>e.settled)},run(e,t){if(U)throw Error(`The trace scope has already finished.`);let r=n(n(P,t),a.active()?.capture),i=F.type===`tool`&&(F.options.kind===`subagent-call`||F.options.kind===`remote-agent-call`)?F.options:void 0,o=i===void 0?e:()=>p({caller:V,conversationId:g.conversationId,parentRunId:g.runId,parentCallId:i.callId,agentName:i.name,capture:r},e);return x(a,{type:$.type,reference:V,capture:r,mcp:$.mcp},o,R)},async complete(e=W??{}){U||await ce(ie(e))},async usage(e,t){t!==void 0&&J.has(t)||(t!==void 0&&J.add(t),B!==void 0&&o(B,i(e)),q={inputTokens:e.inputTokens===void 0?q?.inputTokens:(q?.inputTokens??0)+e.inputTokens,outputTokens:e.outputTokens===void 0?q?.outputTokens:(q?.outputTokens??0)+e.outputTokens,costUsd:e.costUsd===void 0?q?.costUsd:(q?.costUsd??0)+e.costUsd},await C?.usage(e,t))},turnContent(e){if(F.type!==`activation`)return C?.turnContent(e);if(U)return;let t={};e.input!==void 0&&I.attributes[`gen_ai.input.messages`]===void 0&&(t[`gen_ai.input.messages`]=e.input),e.output!==void 0&&(t[`gen_ai.output.messages`]=e.output),Object.keys(t).length>0&&$.update({attributes:t})},error(t,n){W={...W,failed:!0,error:Z().recordOutputs?t instanceof Error?e(t):_(t):void 0,errorCode:n??(t instanceof Error?t.name:void 0)},B!==void 0&&B.fail(W.error,W.errorCode),X()}};for(let e of T.children??[])G.set(e.key,await y(e.identity,n(e.capture,P),e.data,$,e.attempt,{...e,deferred:!0,executionContext:R},E));!U&&B!==void 0&&F.type===`step`&&B.addEvent(`step.started`,void 0,M);let le=I.attributes[`gen_ai.input.messages`];return!U&&F.type===`model`&&typeof le==`string`&&C?.turnContent({input:le}),$}return{start(e){return y(e.identity,e.capture,e.data,void 0,void 0,{key:e.key,parent:e.parent,reference:e.reference,sample:e.reference!==void 0&&e.data.type===`activation`,startTimeMs:e.startTimeMs,links:e.links,executionContext:e.context},e.onChange??(()=>Promise.resolve()))},async restore(e,t={}){if(!D(e)){h(Error(`Invalid tracing checkpoint.`),{phase:`restore`});return}return y(e.identity,n(e.capture,t.capture),e.data,void 0,e.attempt,{...e,deferred:!0,executionContext:t.context},t.onChange??(()=>Promise.resolve()))}}}function N(e,t,n){try{e?.(t,{phase:n})}catch{}}function P(e,t={outcome:`completed`},n){async function r(r,i){if(i===void 0)return e(r);let a=await e(r),o=t;try{let e=await a.run(()=>i(a));try{o=r.describe?.(e)??t}catch(e){N(n,e,`complete`)}return e}catch(e){throw o={outcome:`failed`,errorType:e instanceof Error?e.name:`_OTHER`,error:e},e}finally{try{await a.complete(o)}catch(e){N(n,e,`complete`)}}}return r}function F(e,t,n){let r=t=>Object.defineProperties(t,{finished:{get:()=>e.finished},capture:{get:()=>e.capture},parent:{get:()=>e.parent}}),i={type:e.type,reference:e.reference,get startTimeMs(){return e.startTimeMs},get parent(){return e.parent},get finished(){return e.finished},get capture(){return e.capture},run:(t,n)=>e.run(t,n),attributes:t=>e.attributes(t),complete:t=>e.complete(t),fail:t=>e.fail(t),recordError:(t,n)=>e.error(t,n)},a=async(t,r,i)=>F(await e.child(t,r,i),t,n),o=P(async({startTimeMs:e,...t})=>a({type:`tool`,options:t},void 0,{startTimeMs:e}),void 0,n),s=e=>e===void 0?void 0:F(e,e.record().data,n),c=P(async e=>a({type:`memory`,options:e}),void 0,n);if(t.type===`activation`)return r({...i,memory:c,links:t=>e.update({links:t}),findAttempt:t=>s(e.find({type:`step`,options:{index:t.stepIndex,attempt:t.attempt}})),findTool:t=>s(I(e,t)),attempt:P(async e=>a({type:`step`,options:{index:e.stepIndex,attempt:e.attempt,runtimeContext:e.runtimeContext,channel:e.channel}},void 0,{links:e.links}),void 0,n)});if(t.type===`step`){let t=e=>P(async t=>a({type:`tool`,options:{callId:t.callId,name:t.agentName,kind:e}}),void 0,n),s=(e,t)=>a({type:`model`,options:e},t);async function l(e,t){if(typeof t!=`function`)return s(e,t);let r=await s(e),i;try{i=await r.run(t)}catch(e){try{await r.fail(e)}catch(e){N(n,e,`complete`)}throw e}try{await r.complete({outcome:`completed`,result:i})}catch(e){N(n,e,`complete`)}return i.result}return r({...i,memory:c,tool:o,callSubAgent:t(`subagent-call`),callRemoteAgent:t(`remote-agent-call`),modelCall:l,async modelStream(t,r){let i=await s(t);try{let t=await i.run(r),a=Promise.resolve(t.completion).then(e=>i.complete({outcome:`completed`,result:e}),e=>i.fail(e)).catch(e=>N(n,e,`complete`));return e.waitUntil(a),t.result}catch(e){try{await i.fail(e)}catch(e){N(n,e,`complete`)}throw e}}})}return t.type===`tool`?r({...i,memory:c,tool:o,findApproval:n=>s(e.find({type:`approval`,options:{requestId:n,callId:t.options.callId,toolName:t.options.name}})),approval:P(async e=>a({type:`approval`,options:{...e,callId:t.options.callId,toolName:t.options.name}}),{outcome:`ignored`},n)}):i}function I(e,t){for(let n of e.children){if(n.type===`tool`&&n.callId===t)return n;if(n.type===`step`||n.type===`tool`){let e=I(n,t);if(e!==void 0)return e}}}const L={emit:!0,recordInputs:!1,recordOutputs:!1};function R(e){let r=e.telemetry??t(),i=e.checkpointer;if(i!==void 0&&r.ids===void 0)throw Error(`Durable agent tracing needs stable span IDs. Pass the AgentSpanIdGenerator installed on your tracer provider to otelTelemetry({ idGenerator }).`);let a=(t,n)=>{try{e.onError?.(t,n)}catch{}},o=M({telemetry:r,serializer:e.serializer??f,durable:i!==void 0,onError:e.onError}),s=new Map;function c(e){return i===void 0?`turn:${_()}`:[`turn`,e.runId,e.turnId].map(encodeURIComponent).join(`:`)}function l(e,t){let n=Promise.resolve();return()=>{let r=t();return i===void 0||r===void 0?n:(r.writes++,n=n.then(async()=>{try{if(r.root.settled)s.delete(e),await i.delete(e);else{let t=_();await i.set(e,ee({...r.root.record(),revision:t})),r.revision=t}}catch(e){a(e,{phase:`checkpoint`,operation:`activation`})}finally{r.writes--}}),n)}}async function u(e){try{return await i.get(e)}catch(e){a(e,{phase:`restore`,operation:`activation`});return}}async function d(e,t,r,a,s){let c=m()?.capture;s=s===void 0?c:n(s,c);let d=i===void 0?void 0:await u(e);if(t!==void 0&&(t.writes>0||d?.revision===t.revision))return a!==void 0&&t.root.useContext(a),s!==void 0&&t.root.narrow(s),t;let f,p=l(e,()=>f),h=d===void 0?void 0:await o.restore(d,{capture:s,context:a,onChange:p}),g=h??await r?.(p);if(g!==void 0)return f={root:g,revision:d?.revision,writes:0},h===void 0&&await p(),f}function p(e,t){let n=s.get(e),r=(async()=>t(n===void 0?void 0:await n.catch(()=>void 0)))();return s.set(e,r),r.then(t=>{(t===void 0||t.root.settled)&&s.delete(e)},()=>s.delete(e)),s.size>1e3&&s.delete(s.keys().next().value),r}function h(e,t){return i=>{let a=m(),s=n(e.capture??L,a?.capture),c=a!==void 0&&e.sequence===0,l=e.parent??(c&&a?.remote!==!0?a?.caller:void 0),u=[...c&&a?.remote===!0?[{relationship:`agent.dispatch`,context:a.caller}]:[],...e.links??[]];return o.start({identity:{...e.identity,conversationId:a?.conversationId??e.identity.conversationId,agentName:e.agentName,framework:e.framework},key:t,capture:s,parent:l,reference:r.ids===void 0?void 0:e.reference,startTimeMs:e.startTimeMs,data:{type:`activation`,options:{sequence:e.sequence,attributes:e.attributes,channel:e.channel,subagent:a!==void 0||e.lineage!==void 0,subagentName:a?.agentName??e.lineage?.agentName,parentRunId:a?.parentRunId??e.lineage?.parentRunId,parentCallId:a?.parentCallId??e.lineage?.parentCallId}},links:u.length===0?void 0:u,context:e.context,onChange:i})}}function g(t){return F(t,{type:`activation`,options:{sequence:0}},e.onError)}async function v(e){let t=c(e.identity);return g((i===void 0?await d(t,void 0,h(e,t),e.context):await p(t,n=>d(t,n,h(e,t),e.context,e.capture))).root)}async function y(e){if(i===void 0)return;let t=c(e.identity),n=await p(t,n=>d(t,n,void 0,e.context));return n===void 0?void 0:g(n.root)}async function b(e){try{await e()}catch(e){a(e,{phase:`complete`})}}async function x(e,t,n){let i=r.active(),s=await o.start({identity:t.identity,key:`memory:${_()}`,capture:t.capture??i?.capture??L,parent:t.parent??i?.reference,context:t.context,data:{type:`memory`,options:{operation:e,phase:t.phase,slot:t.slot,storeId:t.storeId}}}),c;try{c=await s.run(n)}catch(e){throw await s.fail(e).catch(e=>a(e,{phase:`complete`})),e}return await s.complete({outcome:`completed`,...t.describe?.(c)}).catch(e=>a(e,{phase:`complete`})),c}return{turn:P(v,void 0,e.onError),resume:y,memory:{search:(e,t)=>x(`search_memory`,e,t),write:(e,t)=>x(`upsert_memory`,e,t)},forceFlush:()=>b(()=>r.forceFlush()),shutdown:()=>b(()=>r.shutdown())}}export{v as AgentSpanIdGenerator,R as createAgentTracing,a as currentCapture,t as otelTelemetry};
@@ -1 +1 @@
1
- import{S as e,_ as t,a as n,b as r,c as i,d as a,h as o,p as s,t as c,u as l,x as u,y as d}from"../../_chunks/workflow/mcp-C01bDEX-.js";export{t as CONTENT_ATTRIBUTE_LIMIT,i as USAGE_FIELDS,a as activeTraceOperation,d as boundedPrincipalId,r as contentAttribute,n as invocationName,c as mcpLifecycle,u as telemetryByteLength,e as truncateTelemetryText,o as withCapture,s as withErrorContent,l as withoutDeclinedContent};
1
+ import{C as e,S as t,_ as n,a as r,c as i,d as a,h as o,p as s,t as c,u as l,x as u,y as d}from"../../_chunks/workflow/mcp-Bwx_LQ4q.js";export{n as CONTENT_ATTRIBUTE_LIMIT,i as USAGE_FIELDS,a as activeTraceOperation,d as boundedPrincipalId,u as contentAttribute,r as invocationName,c as mcpLifecycle,t as telemetryByteLength,e as truncateTelemetryText,o as withCapture,s as withErrorContent,l as withoutDeclinedContent};
@@ -1,5 +1,5 @@
1
- import{D as e,E as t,c as n,l as r,r as i,s as a,u as o}from"./esm-DtrPCf49.js";const s=32768,c={json:p,text:m,inputMessages:e=>ne(e,e=>typeof e==`string`?e:void 0),instructions:re,toolDefinitions:se,outputMessages:ie,toolResults:ae},l=new TextEncoder,u=new TextDecoder;function d(e){return l.encode(e).length}function f(e,t){let n=e.slice(0,t+1),r=l.encode(n);if(n.length===e.length&&r.length<=t)return e;let i=`... [truncated]`.slice(0,t),a=Math.max(0,t-i.length);for(;a>0&&(r[a]&192)==128;)--a;return u.decode(r.subarray(0,a))+i}function ee(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&d(e)<=1024?e:void 0}function te(e){let t=Error(f(e.message,4096));return t.name=f(e.name,128),t.stack=e.stack===void 0?void 0:f(e.stack,8192),t}function p(e){if(e===void 0)return;let t;try{t=JSON.stringify(e)}catch{return}if(t!==void 0)return m(t)}function ne(e,t){if(!Array.isArray(e))return;let n=e.flatMap(e=>{if(!x(e)||e.role===`system`||typeof e.role!=`string`)return[];let n=y(e.content);if(n.length===0)return[];let r=e.role===`user`?t?.(e.kind):void 0;return[r===void 0?{parts:n,role:e.role}:{kind:r,parts:n,role:e.role}]});for(let e=0;e<n.length;e+=1){let t=g(n.slice(e));if(t!==void 0)return{json:t,omitted:e}}let r=le(n);return r===void 0?{json:`[]`,omitted:n.length}:{json:r,omitted:n.length-1}}function re(e){let t=ce(e);if(t!==void 0)return _(t,e=>[{content:e,type:`text`}])}function ie(e,t){let n=y(e),r=t===`tool-calls`?`tool_call`:t,i=e=>[{finish_reason:r,parts:e,role:`assistant`}];return g(i(n))??_(v(n),e=>i([{content:e,type:`text`}]),!0)}function ae(e){if(e.length===0)return;let t=h(e);if(t!==void 0&&t.length<=32768)return t;for(let t=s;t>=0;t=t>=256?Math.floor(t/2):-1){let n=h(e.map(e=>oe(e,t)));if(n!==void 0&&n.length<=32768)return n}}function oe(e,t){let n={toolName:e.toolName};for(let r of[`input`,`output`,`error`]){if(!(r in e))continue;let i=e[r],a=typeof i==`string`?i:h(i)??``;n[r]=a.length<=t?a:`${a.slice(0,t)}… [truncated]`}return n}function se(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>{if(!x(e)||typeof e.name!=`string`)return[];let t={name:e.name};return typeof e.description==`string`&&(t.description=e.description),e.inputSchema!==void 0&&(t.parameters=e.inputSchema),[t]});if(t.length===0)return;let n=[],r=2;for(let e of t){let t=h(e);if(t===void 0)break;let i=r+(n.length===0?0:1)+t.length;if(i>32768)break;n.push(t),r=i}return`[${n.join(`,`)}]`}function ce(e){if(typeof e==`string`)return e.length===0?void 0:e;if(!x(e)&&!Array.isArray(e))return;let t=Array.isArray(e)?e:[e],n=[];for(let e of t)if(x(e)){if(typeof e.content==`string`)n.push(e.content);else if(Array.isArray(e.content))for(let t of e.content)x(t)&&t.type===`text`&&typeof t.text==`string`&&n.push(t.text)}let r=n.join(`
1
+ import{D as e,E as t,c as n,l as r,r as i,s as a,u as o}from"./esm-DtrPCf49.js";const s=32768,c={json:m,text:h,inputMessages:e=>te(e,e=>typeof e==`string`?e:void 0),instructions:ne,toolDefinitions:oe,outputMessages:re,toolResults:ie},l=new TextEncoder,u=new TextDecoder;function d(e){return l.encode(e).length}function f(e,t){let n=e.slice(0,t+1),r=l.encode(n);if(n.length===e.length&&r.length<=t)return e;let i=`... [truncated]`.slice(0,t),a=Math.max(0,t-i.length);for(;a>0&&(r[a]&192)==128;)--a;return u.decode(r.subarray(0,a))+i}function ee(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&d(e)<=1024?e:void 0}function p(e){let t=Error(f(e.message,4096));return t.name=f(e.name,128),t.stack=e.stack===void 0?void 0:f(e.stack,8192),t}function m(e){if(e===void 0)return;let t;try{t=JSON.stringify(e)}catch{return}if(t!==void 0)return h(t)}function te(e,t){if(!Array.isArray(e))return;let n=e.flatMap(e=>{if(!S(e)||e.role===`system`||typeof e.role!=`string`)return[];let n=b(e.content);if(n.length===0)return[];let r=e.role===`user`?t?.(e.kind):void 0;return[r===void 0?{parts:n,role:e.role}:{kind:r,parts:n,role:e.role}]});for(let e=0;e<n.length;e+=1){let t=_(n.slice(e));if(t!==void 0)return{json:t,omitted:e}}let r=ce(n);return r===void 0?{json:`[]`,omitted:n.length}:{json:r,omitted:n.length-1}}function ne(e){let t=se(e);if(t!==void 0)return v(t,e=>[{content:e,type:`text`}])}function re(e,t){let n=b(e),r=t===`tool-calls`?`tool_call`:t,i=e=>[{finish_reason:r,parts:e,role:`assistant`}];return _(i(n))??v(y(n),e=>i([{content:e,type:`text`}]),!0)}function ie(e){if(e.length===0)return;let t=g(e);if(t!==void 0&&t.length<=32768)return t;for(let t=s;t>=0;t=t>=256?Math.floor(t/2):-1){let n=g(e.map(e=>ae(e,t)));if(n!==void 0&&n.length<=32768)return n}}function ae(e,t){let n={toolName:e.toolName};for(let r of[`input`,`output`,`error`]){if(!(r in e))continue;let i=e[r],a=typeof i==`string`?i:g(i)??``;n[r]=a.length<=t?a:`${a.slice(0,t)}… [truncated]`}return n}function oe(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>{if(!S(e)||typeof e.name!=`string`)return[];let t={name:e.name};return typeof e.description==`string`&&(t.description=e.description),e.inputSchema!==void 0&&(t.parameters=e.inputSchema),[t]});if(t.length===0)return;let n=[],r=2;for(let e of t){let t=g(e);if(t===void 0)break;let i=r+(n.length===0?0:1)+t.length;if(i>32768)break;n.push(t),r=i}return`[${n.join(`,`)}]`}function se(e){if(typeof e==`string`)return e.length===0?void 0:e;if(!S(e)&&!Array.isArray(e))return;let t=Array.isArray(e)?e:[e],n=[];for(let e of t)if(S(e)){if(typeof e.content==`string`)n.push(e.content);else if(Array.isArray(e.content))for(let t of e.content)S(t)&&t.type===`text`&&typeof t.text==`string`&&n.push(t.text)}let r=n.join(`
2
2
 
3
- `).trim();return r.length===0?void 0:r}function m(e){if(e.length!==0)return e.length<=32768?e:`${e.slice(0,s)}… [truncated]`}function h(e){try{return JSON.stringify(e)}catch{return}}function g(e){let t=h(e);return t!==void 0&&t.length<=32768?t:void 0}function le(e){let t=e.at(-1);if(t===void 0||typeof t.role!=`string`)return;let n=v(t.parts),r=typeof t.kind==`string`?{kind:t.kind,role:t.role}:{role:t.role};return _(n,e=>[{...r,parts:[{content:e,type:`text`}]}],!0)}function _(e,t,n=!1){if(!n&&e.length<=32768){let n=g(t(e));if(n!==void 0)return n}for(let n=Math.min(e.length,s);n>0;n-=256){let r=g(t(`${e.slice(0,n)}… [truncated]`));if(r!==void 0)return r}return g(t(`… [truncated]`))}function v(e){if(!Array.isArray(e))return``;let t=``;for(let n of e){if(!x(n)||n.type!==`text`||typeof n.content!=`string`)continue;let e=t.length===0?``:`
4
- `,r=32769-t.length-e.length;if(r<=0)break;t+=e+n.content.slice(0,r)}return t}function y(e){if(typeof e==`string`)return[{content:e,type:`text`}];if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=ue(n);e!==void 0&&t.push(e)}return t}function ue(e){if(x(e)&&typeof e.type==`string`)switch(e.type){case`text`:case`reasoning`:{let t=typeof e.text==`string`?e.text:e.content;return typeof t==`string`?{content:t,type:e.type}:void 0}case`tool-call`:return{arguments:e.input,id:b(e.toolCallId)??b(e.callId)??null,name:e.toolName,type:`tool_call`};case`tool-result`:return{id:b(e.toolCallId)??b(e.callId)??null,response:de(e.output),type:`tool_call_response`};case`tool-error`:return{id:b(e.toolCallId)??b(e.callId)??null,response:e.error instanceof Error?e.error.message:e.error,type:`tool_call_response`};default:return{type:e.type}}}function de(e){return x(e)?(e.type===`text`||e.type===`error-text`||e.type===`json`||e.type===`error-json`)&&`value`in e?e.value:e.type===`execution-denied`?{denied:!0,reason:e.reason}:e:e}function b(e){return typeof e==`string`?e:void 0}function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fe(e,t,n){e.setAttribute(`error.type`,f(n??(t instanceof Error?t.name:`_OTHER`),128));let i=t!==void 0&&!(t instanceof Error);if(i){let e=p(t),n=typeof t==`object`&&t?Reflect.get(t,`message`):void 0,r=typeof t==`string`?m(t):typeof n==`string`?m(e===void 0?n:`${n}\n${e}`):e;r!==void 0&&(t=Error(r))}if(t instanceof Error){let a=te(t);i&&n!==void 0&&(a.name=f(n,128)),e.recordException(a),e.setStatus({code:r.ERROR,message:a.message})}else e.setStatus({code:r.ERROR})}function S(e,t){let n=e.emit&&(t?.emit??!0);return{emit:n,recordInputs:n&&e.recordInputs&&(t?.recordInputs??!0),recordOutputs:n&&e.recordOutputs&&(t?.recordOutputs??!0)}}function pe(e,t){let n=e.mcp;return{type:e.type,reference:e.reference,capture:t,mcp:n===void 0?void 0:{update:e=>n.update(e),error:(e,r)=>n.error(t.recordOutputs?e:void 0,r??(e instanceof Error?e.name:void 0)),arguments:e=>{t.recordInputs&&n.arguments(e)},result:e=>{t.recordOutputs&&n.result(e)}}}}const C=e(`agent.tracing.capture`);function me(){return a.active().getValue(C)}function w(e,t){return e.setValue(C,t)}const T=e(`agent.tracing.active-operation`),E=e(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function D(e,t){return w(e,{emit:!0,recordInputs:t,recordOutputs:t})}function O(e){return e.setValue(E,!0)}function k(e=a.active()){return typeof e.getValue==`function`?e.getValue(T):void 0}function he(e,n){let r=n??t;return e===void 0?r:i.setSpan(r,i.wrapSpanContext(A(e)))}function A(e){return{...e,traceState:e.tracestate===void 0?void 0:n(e.tracestate)}}function ge(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags,isRemote:e.isRemote,tracestate:e.traceState?.serialize()}}function j(e,t,n){return e?.attributes(t,n)??n}const _e={attributes(e,t){let n=t[`agent.run.id`];return ve()&&typeof n==`string`&&t[`vercel.session_id`]===void 0?{...t,"vercel.session_id":n}:t},link:(e,t)=>({"agent.link.type":t.relationship})};function ve(){return globalThis.process?.env?.VERCEL_ENV!==void 0}function M(e={}){let n=e.provider??i.getTracerProvider(),s=n.getTracer(e.tracerName??`agent.tracing`,e.tracerVersion),c=e.mapping??_e,l=e.idGenerator;function u(t){return e[t]??(async()=>{let e=n[t];if(e===void 0)throw Error(`The tracer provider does not support ${t}.`);await e.call(n)})}function d(e,t){let n=s.startSpan(e.name,{attributes:j(c,e,e.attributes),kind:e.kind===void 0?void 0:o[e.kind],root:e.root,startTime:e.startTimeMs,links:e.links?.map(t=>({context:A(t.context),attributes:c?.link(e,t)??{"agent.link.type":t.relationship}}))},he(e.root?void 0:e.parent,t));return{reference:ge(n.spanContext()),setAttribute(t,r){for(let[i,a]of Object.entries(j(c,e,{[t]:r})))a!==void 0&&n.setAttribute(i,a)},addEvent:(e,t,r)=>{n.addEvent(e,t,r)},fail:(e,t)=>fe(n,e,t),setStatus:e=>{n.setStatus({code:r[e]})},end:e=>{n.end(e)}}}return{startSpan(e,{reference:t,context:n}={}){if(t===void 0||l===void 0)return d(e,n);let r=l.withTraceId(t.traceId,()=>l.withSpanId(t.spanId,()=>d(e,n)));if(r.reference.spanId!==t.spanId||r.reference.traceId!==t.traceId)throw Error(`The tracer provider must use the telemetry's ID generator.`);return r},active:()=>k(),suppressed(e){return a.with(D(O(t),!1),e)},run(e,t,n){let r=S(e.capture,k()?.capture),o=i.setSpan(n??a.active(),i.wrapSpanContext(A(e.reference)));return r=S(r,o.getValue(T)?.capture),o=o.setValue(T,pe(e,r)),o=w(o,r),(!r.emit||!(e.reference.traceFlags&1))&&(o=O(o)),a.with(o,t)},samples:(t,n)=>e.samplesTrace?.(t,{name:n.name,attributes:j(c,n,n.attributes)})??!0,ids:l===void 0?void 0:{traceId:e=>l.deriveTraceId(e),spanId:e=>l.deriveSpanId(e)},forceFlush:u(`forceFlush`),shutdown:u(`shutdown`)}}const N=new Set([`agent.channel.delivery.input`,`agent.session.title`,`agent.approval.request`,`ai.documents`,`ai.prompt`,`ai.prompt.toolChoice`,`ai.prompt.tools`,`ai.value`,`ai.values`,`gen_ai.input.messages`,`gen_ai.memory.records`,`gen_ai.system_instructions`,`gen_ai.tool.call.arguments`,`gen_ai.tool.definitions`]),P=new Set([`agent.approval.response`,`ai.embedding`,`ai.embeddings`,`ai.ranking`,`ai.response.files`,`ai.response.object`,`ai.response.reasoning`,`ai.response.text`,`ai.response.toolCalls`,`ai.response.tool_calls`,`ai.response.tool_results`,`ai.toolCall.args`,`ai.toolCall.result`,`gen_ai.output.messages`,`gen_ai.tool.call.result`]),F=`agent.trace.content.input`,I=`agent.trace.content.output`;function L(e,t){return!t.recordInputs&&N.has(e)?!0:!t.recordOutputs&&P.has(e)}function R(e,t){return!t.recordInputs&&e[F]===!0||!t.recordOutputs&&e[I]===!0}function ye(e,t,n){return e===F&&t===!0&&!n.recordInputs||e===I&&t===!0&&!n.recordOutputs?!1:t}function z(e,t){let n=Object.keys(e);if(!n.some(e=>L(e,t))&&!R(e,t))return;let r={};for(let i of n)L(i,t)||(r[i]=ye(i,e[i],t));return r}const B={costUsd:`agent.usage.cost_usd`,inputTokens:`agent.usage.input_tokens`,outputTokens:`agent.usage.output_tokens`,cacheReadTokens:`agent.usage.cache_read_tokens`,cacheWriteTokens:`agent.usage.cache_write_tokens`};function be(e){return{"agent.run.id":e.runId,"agent.trace.schema.version":4,"gen_ai.conversation.id":e.conversationId}}function V(e,t=e){return{"operation.name":t,"resource.name":e}}function H(e){return{"agent.framework.name":e?.name||void 0,"agent.framework.version":e?.version||void 0}}function U(e,t=!1){return t?{[B.costUsd]:e.costUsd,"gen_ai.usage.input_tokens":e.inputTokens,"gen_ai.usage.output_tokens":e.outputTokens,"gen_ai.usage.cache_read.input_tokens":e.inputTokenDetails?.cacheReadTokens,"gen_ai.usage.cache_write.input_tokens":e.inputTokenDetails?.cacheWriteTokens}:{[B.costUsd]:e.costUsd,[B.inputTokens]:e.inputTokens,[B.outputTokens]:e.outputTokens,[B.cacheReadTokens]:e.inputTokenDetails?.cacheReadTokens,[B.cacheWriteTokens]:e.inputTokenDetails?.cacheWriteTokens}}function W(e){let t={},n=new WeakSet,r=256;function i(e,a,o){if(!(r<=0||o>8||a==null)){if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`)t[e]=a,--r;else if(Array.isArray(a))a.length<=256&&a.every(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&new Set(a.map(e=>typeof e)).size===1&&(t[e]=a,--r);else if(typeof a==`object`&&!n.has(a)){n.add(a);for(let t of Object.keys(a)){if(r<=0)break;i(`${e}.${t}`,Reflect.get(a,t),o+1)}n.delete(a)}}}return e!==void 0&&i(`ai.settings.context`,e,0),t}const G=e=>e===void 0?`invoke_agent`:`invoke_agent ${e}`,K=e=>`chat ${e}`,q=e=>`execute_tool ${e}`,J={approval:`agent.approval`,step:`agent.step`},Y={toolArguments:`gen_ai.tool.call.arguments`,toolResult:`gen_ai.tool.call.result`,approvalRequest:`agent.approval.request`,approvalResponse:`agent.approval.response`,memoryRecords:`gen_ai.memory.records`};function X(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.setAttribute(n,r)}function Z(e){return{"agent.turn.id":e.attempt.turnId,"agent.step.index":e.attempt.index,"agent.step.attempt":e.attempt.attempt}}function Q(e,t){return z(e??{},t)??e}function xe(e,t){return{[Y.toolArguments]:t.capture.recordInputs?t.serializer.json(e):void 0}}function Se(e,t,n){n.capture.recordOutputs&&X(e,{[Y.toolResult]:n.serializer.json(t.output)})}const Ce={activation:{parents:[],prepare({options:e},t){let{identity:n,capture:r}=t;return{name:G(n.agentName),attributes:{...t.attributes,...H(n.framework),...V(G(n.agentName),`invoke_agent`),"agent.channel.kind":e.channel?.kind,"agent.session.origin":e.channel?.origin,"agent.name":n.agentName,"gen_ai.agent.name":n.agentName,"gen_ai.operation.name":`invoke_agent`,"agent.turn.id":n.turnId,"agent.turn.sequence":e.sequence,"agent.run.type":e.subagent?`subagent`:`session`,"agent.parent_call.id":e.parentCallId,"agent.parent_run.id":e.parentRunId,"agent.subagent.name":e.subagentName,"agent.trace.content.input":r.recordInputs,"agent.trace.content.output":r.recordOutputs,...Q(e.attributes,r)}}},complete(e,t,n,r){e.addEvent(`turn.started`,void 0,r.startTimeMs),(n.outcomeUnknown!==!0||n.failed===!0)&&e.addEvent(`turn.${r.outcome}`,void 0,n.endTimeMs)},redact(e,t){return{...e,options:{...e.options,attributes:Q(e.options.attributes,t)}}}},step:{parents:[`activation`],prepare({options:e},t){return{name:J.step,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(J.step,`workflow`),"gen_ai.operation.name":`workflow`,"agent.name":t.identity.agentName,"agent.channel.kind":e.channel?.kind===`unknown`?void 0:e.channel?.kind,"agent.session.origin":e.channel?.kind===`unknown`?void 0:e.channel?.origin,...W(e.runtimeContext)}}},complete(e,t,n){e.addEvent(n.failed?`step.failed`:`step.completed`,void 0,n.endTimeMs)}},model:{parents:[`step`],prepare({options:e},t){let n=t.capture.recordInputs&&e.messages!==void 0?t.serializer.inputMessages(e.messages):void 0;return{name:K(e.modelId),kind:`CLIENT`,attributes:{...t.attributes,...V(K(e.modelId),`chat`),"gen_ai.agent.name":t.identity.agentName,"gen_ai.operation.name":`chat`,"gen_ai.provider.name":e.provider,"gen_ai.request.model":e.modelId,...W(e.runtimeContext),...t.capture.recordInputs&&e.messages!==void 0?{"gen_ai.input.messages":n?.json,"agent.input.messages.omitted":n?.omitted||void 0,"gen_ai.system_instructions":t.serializer.instructions(e.instructions)}:void 0,"gen_ai.tool.definitions":t.capture.recordInputs?t.serializer.toolDefinitions(e.tools):void 0}}},complete(e,t,n,r){n.model!==void 0&&X(e,Oe(n.model,r.serializer,r.capture.recordOutputs))},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,messages:void 0,instructions:void 0,tools:void 0}}}},tool:{parents:[`step`,`tool`],prepare({options:e},t){let n=e.kind===`subagent-call`||e.kind===`remote-agent-call`;return{name:q(e.name),kind:e.kind===`remote-agent-call`?`CLIENT`:`INTERNAL`,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(q(e.name),`execute_tool`),"gen_ai.agent.name":n?e.name:t.identity.agentName,"gen_ai.operation.name":`execute_tool`,"gen_ai.tool.call.id":e.callId,"gen_ai.tool.name":e.name,"gen_ai.tool.type":`function`,"agent.action.kind":e.kind,"agent.action.name":e.kind===void 0?void 0:e.name,"agent.invocation.role":n?`caller`:void 0,...xe(e.arguments,t)}}},complete(e,t,n,r){n.outcome!==void 0&&X(e,{"agent.action.outcome":n.outcome}),Se(e,n,r)},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,arguments:void 0}}}},approval:{parents:[`tool`],prepare({options:e},t){return{name:J.approval,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(J.approval,`workflow`),"gen_ai.operation.name":`workflow`,"gen_ai.tool.call.id":e.callId,"agent.action.name":e.toolName,"agent.approval.kind":`tool-approval`,"agent.approval.request_id":e.requestId,[Y.approvalRequest]:t.capture.recordInputs?t.serializer.json(e.request):void 0}}},complete(e,t,n,r){r.capture.recordOutputs&&X(e,{[Y.approvalResponse]:r.serializer.json(n.response)})},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,request:void 0}}}},memory:{parents:[`activation`,`step`,`tool`],prepare({options:e},t){return{name:e.operation,kind:`CLIENT`,attributes:{...t.attributes,...V(e.operation),"gen_ai.operation.name":e.operation,"gen_ai.memory.store.id":e.storeId,"agent.memory.phase":e.phase,"agent.memory.slot":e.slot,"agent.turn.id":t.identity.turnId}}},complete(e,t,n,r){n.recordCount!==void 0&&X(e,{"gen_ai.memory.record.count":n.recordCount}),r.capture.recordInputs&&X(e,{[Y.memoryRecords]:r.serializer.json(n.records)})}}};function $(e){return Ce[e.type]}function we(e){return $(e).parents}function Te(e,t){let n={identity:e.identity,attributes:be(e.identity),attempt:{turnId:e.identity.turnId,index:e.attempt?.index??0,attempt:e.attempt?.attempt??0},capture:e.capture,serializer:t};return{type:e.data.type,operationId:e.key,kind:`INTERNAL`,...$(e.data).prepare(e.data,n),parent:e.parent,root:e.data.type===`activation`&&e.parent===void 0,startTimeMs:e.startTimeMs,links:e.links}}function Ee(e,t,n,r,i,a){let o=n.outcome??(n.failed?`failed`:`completed`),s=n.outcomeUnknown!==!0||n.failed===!0;(t.type===`activation`||t.type===`approval`)&&s&&X(e,{[t.type===`activation`?`agent.turn.outcome`:`agent.approval.outcome`]:o}),n.usage!==void 0&&X(e,U(n.usage,t.type===`activation`||t.type===`model`)),$(t).complete?.(e,t,n,{capture:r,startTimeMs:i,serializer:a,outcome:o}),n.failed&&e.fail(n.error,n.errorCode)}function De(e,t){return t.emit||(t={emit:!1,recordInputs:!1,recordOutputs:!1}),$(e).redact?.(e,t)??e}function Oe(e,t,n){let r={...U(e.usage,!0),"gen_ai.response.id":e.responseId,"gen_ai.response.model":e.responseModelId,"gen_ai.response.finish_reasons":[e.finishReason]};if(!n)return r;r[`ai.response.finish_reason`]=e.finishReason;let i=e.content;if(i===void 0)return r;r[`gen_ai.output.messages`]=t.outputMessages(i,e.finishReason),r[`ai.response.reasoning`]=t.text(i.filter(e=>e.type===`reasoning`).map(e=>e.text).filter(e=>e.trim().length>0).join(`
5
- `)),r[`ai.response.text`]=t.text(i.filter(e=>e.type===`text`).map(e=>e.text).join(``));let a=i.filter(e=>e.type===`tool-call`).map(e=>({callId:e.callId,input:e.input,toolName:e.toolName}));a.length>0&&(r[`ai.response.tool_calls`]=t.json(a));let o=i.filter(e=>e.type===`tool-result`||e.type===`tool-error`).map(e=>e.type===`tool-result`?{callId:e.callId,input:e.input,output:e.output,toolName:e.toolName}:{callId:e.callId,input:e.input,error:e.error instanceof Error?e.error.message:e.error,toolName:e.toolName});return o.length>0&&(r[`ai.response.tool_results`]=t.toolResults(o)),r}function ke(e){return{update(t){t.connectionName!==void 0&&t.method!==void 0&&e.write({"agent.connection.name":t.connectionName,"mcp.method.name":t.method,"network.protocol.name":`http`,"network.transport":`tcp`,"mcp.protocol.version":t.protocolVersion,"jsonrpc.request.id":t.requestId,"gen_ai.operation.name":t.method===`tools/call`?`execute_tool`:void 0,"gen_ai.tool.name":t.method===`tools/call`?t.toolName:void 0}),t.sessionId!==void 0&&e.write({"mcp.session.id":t.sessionId}),t.statusCode!==void 0&&e.write({"rpc.response.status_code":t.statusCode})},error(t,n){e.error(e.recordOutputs?t:void 0,n??(t instanceof Error?t.name:void 0))},arguments(t){e.recordInputs&&e.write({"gen_ai.tool.call.arguments":e.serializer.json(t)})},result(t){e.recordOutputs&&e.write({"gen_ai.tool.call.result":e.serializer.json(t)})}}}export{f as S,s as _,G as a,p as b,B as c,k as d,M as f,S as g,w as h,Ee as i,U as l,me as m,X as n,we as o,D as p,De as r,Te as s,ke as t,z as u,c as v,d as x,ee as y};
3
+ `).trim();return r.length===0?void 0:r}function h(e){if(e.length!==0)return e.length<=32768?e:`${e.slice(0,s)}… [truncated]`}function g(e){try{return JSON.stringify(e)}catch{return}}function _(e){let t=g(e);return t!==void 0&&t.length<=32768?t:void 0}function ce(e){let t=e.at(-1);if(t===void 0||typeof t.role!=`string`)return;let n=y(t.parts),r=typeof t.kind==`string`?{kind:t.kind,role:t.role}:{role:t.role};return v(n,e=>[{...r,parts:[{content:e,type:`text`}]}],!0)}function v(e,t,n=!1){if(!n&&e.length<=32768){let n=_(t(e));if(n!==void 0)return n}for(let n=Math.min(e.length,s);n>0;n-=256){let r=_(t(`${e.slice(0,n)}… [truncated]`));if(r!==void 0)return r}return _(t(`… [truncated]`))}function y(e){if(!Array.isArray(e))return``;let t=``;for(let n of e){if(!S(n)||n.type!==`text`||typeof n.content!=`string`)continue;let e=t.length===0?``:`
4
+ `,r=32769-t.length-e.length;if(r<=0)break;t+=e+n.content.slice(0,r)}return t}function b(e){if(typeof e==`string`)return[{content:e,type:`text`}];if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=le(n);e!==void 0&&t.push(e)}return t}function le(e){if(S(e)&&typeof e.type==`string`)switch(e.type){case`text`:case`reasoning`:{let t=typeof e.text==`string`?e.text:e.content;return typeof t==`string`?{content:t,type:e.type}:void 0}case`tool-call`:return{arguments:e.input,id:x(e.toolCallId)??x(e.callId)??null,name:e.toolName,type:`tool_call`};case`tool-result`:return{id:x(e.toolCallId)??x(e.callId)??null,response:ue(e.output),type:`tool_call_response`};case`tool-error`:return{id:x(e.toolCallId)??x(e.callId)??null,response:e.error instanceof Error?e.error.message:e.error,type:`tool_call_response`};default:return{type:e.type}}}function ue(e){return S(e)?(e.type===`text`||e.type===`error-text`||e.type===`json`||e.type===`error-json`)&&`value`in e?e.value:e.type===`execution-denied`?{denied:!0,reason:e.reason}:e:e}function x(e){return typeof e==`string`?e:void 0}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function de(e,t,n){e.setAttribute(`error.type`,f(n??(t instanceof Error?t.name:`_OTHER`),128));let i=t!==void 0&&!(t instanceof Error);if(i){let e=m(t),n=typeof t==`object`&&t?Reflect.get(t,`message`):void 0,r=typeof t==`string`?h(t):typeof n==`string`?h(e===void 0?n:`${n}\n${e}`):e;r!==void 0&&(t=Error(r))}if(t instanceof Error){let a=p(t);i&&n!==void 0&&(a.name=f(n,128)),e.recordException(a),e.setStatus({code:r.ERROR,message:a.message})}else e.setStatus({code:r.ERROR})}function C(e,t){let n=e.emit&&(t?.emit??!0);return{emit:n,recordInputs:n&&e.recordInputs&&(t?.recordInputs??!0),recordOutputs:n&&e.recordOutputs&&(t?.recordOutputs??!0)}}function fe(e,t){let n=e.mcp;return{type:e.type,reference:e.reference,capture:t,mcp:n===void 0?void 0:{update:e=>n.update(e),error:(e,r)=>n.error(t.recordOutputs?e:void 0,r??(e instanceof Error?e.name:void 0)),arguments:e=>{t.recordInputs&&n.arguments(e)},result:e=>{t.recordOutputs&&n.result(e)}}}}const w=e(`agent.tracing.capture`);function pe(){return a.active().getValue(w)}function T(e,t){return e.setValue(w,t)}const E=e(`agent.tracing.active-operation`),D=e(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function O(e,t){return T(e,{emit:!0,recordInputs:t,recordOutputs:t})}function k(e){return e.setValue(D,!0)}function A(e=a.active()){return typeof e.getValue==`function`?e.getValue(E):void 0}function me(e,n){let r=n??t;return e===void 0?r:i.setSpan(r,i.wrapSpanContext(j(e)))}function j(e){return{...e,traceState:e.tracestate===void 0?void 0:n(e.tracestate)}}function he(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags,isRemote:e.isRemote,tracestate:e.traceState?.serialize()}}function M(e,t,n){return e?.attributes(t,n)??n}const ge={attributes(e,t){let n=t[`agent.run.id`];return _e()&&typeof n==`string`&&t[`vercel.session_id`]===void 0?{...t,"vercel.session_id":n}:t},link:(e,t)=>({"agent.link.type":t.relationship})};function _e(){return globalThis.process?.env?.VERCEL_ENV!==void 0}function ve(e={}){let n=e.provider??i.getTracerProvider(),s=n.getTracer(e.tracerName??`agent.tracing`,e.tracerVersion),c=e.mapping??ge,l=e.idGenerator;function u(t){return e[t]??(async()=>{let e=n[t];if(e===void 0)throw Error(`The tracer provider does not support ${t}.`);await e.call(n)})}function d(e,t){let n=s.startSpan(e.name,{attributes:M(c,e,e.attributes),kind:e.kind===void 0?void 0:o[e.kind],root:e.root,startTime:e.startTimeMs,links:e.links?.map(t=>({context:j(t.context),attributes:c?.link(e,t)??{"agent.link.type":t.relationship}}))},me(e.root?void 0:e.parent,t));return{reference:he(n.spanContext()),setAttribute(t,r){for(let[i,a]of Object.entries(M(c,e,{[t]:r})))a!==void 0&&n.setAttribute(i,a)},addEvent:(e,t,r)=>{n.addEvent(e,t,r)},fail:(e,t)=>de(n,e,t),setStatus:e=>{n.setStatus({code:r[e]})},end:e=>{n.end(e)}}}return{startSpan(e,{reference:t,context:n}={}){if(t===void 0||l===void 0)return d(e,n);let r=l.withTraceId(t.traceId,()=>l.withSpanId(t.spanId,()=>d(e,n)));if(r.reference.spanId!==t.spanId||r.reference.traceId!==t.traceId)throw Error(`The tracer provider must use the telemetry's ID generator.`);return r},active:()=>A(),suppressed(e){return a.with(O(k(t),!1),e)},run(e,t,n){let r=C(e.capture,A()?.capture),o=i.setSpan(n??a.active(),i.wrapSpanContext(j(e.reference)));return r=C(r,o.getValue(E)?.capture),o=o.setValue(E,fe(e,r)),o=T(o,r),(!r.emit||!(e.reference.traceFlags&1))&&(o=k(o)),a.with(o,t)},samples:(t,n)=>e.samplesTrace?.(t,{name:n.name,attributes:M(c,n,n.attributes)})??!0,ids:l===void 0?void 0:{traceId:e=>l.deriveTraceId(e),spanId:e=>l.deriveSpanId(e)},forceFlush:u(`forceFlush`),shutdown:u(`shutdown`)}}const N=new Set([`agent.channel.delivery.input`,`agent.session.title`,`agent.approval.request`,`ai.documents`,`ai.prompt`,`ai.prompt.toolChoice`,`ai.prompt.tools`,`ai.value`,`ai.values`,`gen_ai.input.messages`,`gen_ai.memory.records`,`gen_ai.system_instructions`,`gen_ai.tool.call.arguments`,`gen_ai.tool.definitions`]),P=new Set([`agent.approval.response`,`ai.embedding`,`ai.embeddings`,`ai.ranking`,`ai.response.files`,`ai.response.object`,`ai.response.reasoning`,`ai.response.text`,`ai.response.toolCalls`,`ai.response.tool_calls`,`ai.response.tool_results`,`ai.toolCall.args`,`ai.toolCall.result`,`gen_ai.output.messages`,`gen_ai.tool.call.result`]),F=`agent.trace.content.input`,I=`agent.trace.content.output`;function L(e,t){return!t.recordInputs&&N.has(e)?!0:!t.recordOutputs&&P.has(e)}function R(e,t){return!t.recordInputs&&e[F]===!0||!t.recordOutputs&&e[I]===!0}function ye(e,t,n){return e===F&&t===!0&&!n.recordInputs||e===I&&t===!0&&!n.recordOutputs?!1:t}function z(e,t){let n=Object.keys(e);if(!n.some(e=>L(e,t))&&!R(e,t))return;let r={};for(let i of n)L(i,t)||(r[i]=ye(i,e[i],t));return r}const B={costUsd:`agent.usage.cost_usd`,inputTokens:`agent.usage.input_tokens`,outputTokens:`agent.usage.output_tokens`,cacheReadTokens:`agent.usage.cache_read_tokens`,cacheWriteTokens:`agent.usage.cache_write_tokens`};function be(e){return{"agent.run.id":e.runId,"agent.trace.schema.version":4,"gen_ai.conversation.id":e.conversationId}}function V(e,t=e){return{"operation.name":t,"resource.name":e}}function H(e){return{"agent.framework.name":e?.name||void 0,"agent.framework.version":e?.version||void 0}}function U(e,t=!1){return t?{[B.costUsd]:e.costUsd,"gen_ai.usage.input_tokens":e.inputTokens,"gen_ai.usage.output_tokens":e.outputTokens,"gen_ai.usage.cache_read.input_tokens":e.inputTokenDetails?.cacheReadTokens,"gen_ai.usage.cache_write.input_tokens":e.inputTokenDetails?.cacheWriteTokens}:{[B.costUsd]:e.costUsd,[B.inputTokens]:e.inputTokens,[B.outputTokens]:e.outputTokens,[B.cacheReadTokens]:e.inputTokenDetails?.cacheReadTokens,[B.cacheWriteTokens]:e.inputTokenDetails?.cacheWriteTokens}}function W(e){let t={},n=new WeakSet,r=256;function i(e,a,o){if(!(r<=0||o>8||a==null)){if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`)t[e]=a,--r;else if(Array.isArray(a))a.length<=256&&a.every(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&new Set(a.map(e=>typeof e)).size===1&&(t[e]=a,--r);else if(typeof a==`object`&&!n.has(a)){n.add(a);for(let t of Object.keys(a)){if(r<=0)break;i(`${e}.${t}`,Reflect.get(a,t),o+1)}n.delete(a)}}}return e!==void 0&&i(`ai.settings.context`,e,0),t}const G=e=>e===void 0?`invoke_agent`:`invoke_agent ${e}`,K=e=>`chat ${e}`,q=e=>`execute_tool ${e}`,J={approval:`agent.approval`,step:`agent.step`},Y={toolArguments:`gen_ai.tool.call.arguments`,toolResult:`gen_ai.tool.call.result`,approvalRequest:`agent.approval.request`,approvalResponse:`agent.approval.response`,memoryRecords:`gen_ai.memory.records`};function X(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.setAttribute(n,r)}function Z(e){return{"agent.turn.id":e.attempt.turnId,"agent.step.index":e.attempt.index,"agent.step.attempt":e.attempt.attempt}}function Q(e,t){return z(e??{},t)??e}function xe(e,t){return{[Y.toolArguments]:t.capture.recordInputs?t.serializer.json(e):void 0}}function Se(e,t,n){n.capture.recordOutputs&&X(e,{[Y.toolResult]:n.serializer.json(t.output)})}const Ce={activation:{parents:[],prepare({options:e},t){let{identity:n,capture:r}=t;return{name:G(n.agentName),attributes:{...t.attributes,...H(n.framework),...V(G(n.agentName),`invoke_agent`),"agent.channel.kind":e.channel?.kind,"agent.session.origin":e.channel?.origin,"agent.name":n.agentName,"gen_ai.agent.name":n.agentName,"gen_ai.operation.name":`invoke_agent`,"agent.turn.id":n.turnId,"agent.turn.sequence":e.sequence,"agent.run.type":e.subagent?`subagent`:`session`,"agent.parent_call.id":e.parentCallId,"agent.parent_run.id":e.parentRunId,"agent.subagent.name":e.subagentName,"agent.trace.content.input":r.recordInputs,"agent.trace.content.output":r.recordOutputs,...Q(e.attributes,r)}}},complete(e,t,n,r){e.addEvent(`turn.started`,void 0,r.startTimeMs),(n.outcomeUnknown!==!0||n.failed===!0)&&e.addEvent(`turn.${r.outcome}`,void 0,n.endTimeMs)},redact(e,t){return{...e,options:{...e.options,attributes:Q(e.options.attributes,t)}}}},step:{parents:[`activation`],prepare({options:e},t){return{name:J.step,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(J.step,`workflow`),"gen_ai.operation.name":`workflow`,"agent.name":t.identity.agentName,"agent.channel.kind":e.channel?.kind===`unknown`?void 0:e.channel?.kind,"agent.session.origin":e.channel?.kind===`unknown`?void 0:e.channel?.origin,...W(e.runtimeContext)}}},complete(e,t,n){e.addEvent(n.failed?`step.failed`:`step.completed`,void 0,n.endTimeMs)}},model:{parents:[`step`],prepare({options:e},t){let n=t.capture.recordInputs&&e.messages!==void 0?t.serializer.inputMessages(e.messages):void 0;return{name:K(e.modelId),kind:`CLIENT`,attributes:{...t.attributes,...V(K(e.modelId),`chat`),"gen_ai.agent.name":t.identity.agentName,"gen_ai.operation.name":`chat`,"gen_ai.provider.name":e.provider,"gen_ai.request.model":e.modelId,...W(e.runtimeContext),...t.capture.recordInputs&&e.messages!==void 0?{"gen_ai.input.messages":n?.json,"agent.input.messages.omitted":n?.omitted||void 0,"gen_ai.system_instructions":t.serializer.instructions(e.instructions)}:void 0,"gen_ai.tool.definitions":t.capture.recordInputs?t.serializer.toolDefinitions(e.tools):void 0}}},complete(e,t,n,r){n.model!==void 0&&X(e,Oe(n.model,r.serializer,r.capture.recordOutputs))},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,messages:void 0,instructions:void 0,tools:void 0}}}},tool:{parents:[`step`,`tool`],prepare({options:e},t){let n=e.kind===`subagent-call`||e.kind===`remote-agent-call`;return{name:q(e.name),kind:e.kind===`remote-agent-call`?`CLIENT`:`INTERNAL`,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(q(e.name),`execute_tool`),"gen_ai.agent.name":n?e.name:t.identity.agentName,"gen_ai.operation.name":`execute_tool`,"gen_ai.tool.call.id":e.callId,"gen_ai.tool.name":e.name,"gen_ai.tool.type":`function`,"agent.action.kind":e.kind,"agent.action.name":e.kind===void 0?void 0:e.name,"agent.invocation.role":n?`caller`:void 0,...xe(e.arguments,t)}}},complete(e,t,n,r){n.outcome!==void 0&&X(e,{"agent.action.outcome":n.outcome}),Se(e,n,r)},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,arguments:void 0}}}},approval:{parents:[`tool`],prepare({options:e},t){return{name:J.approval,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(J.approval,`workflow`),"gen_ai.operation.name":`workflow`,"gen_ai.tool.call.id":e.callId,"agent.action.name":e.toolName,"agent.approval.kind":`tool-approval`,"agent.approval.request_id":e.requestId,[Y.approvalRequest]:t.capture.recordInputs?t.serializer.json(e.request):void 0}}},complete(e,t,n,r){r.capture.recordOutputs&&X(e,{[Y.approvalResponse]:r.serializer.json(n.response)})},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,request:void 0}}}},memory:{parents:[`activation`,`step`,`tool`],prepare({options:e},t){return{name:e.operation,kind:`CLIENT`,attributes:{...t.attributes,...V(e.operation),"gen_ai.operation.name":e.operation,"gen_ai.memory.store.id":e.storeId,"agent.memory.phase":e.phase,"agent.memory.slot":e.slot,"agent.turn.id":t.identity.turnId}}},complete(e,t,n,r){n.recordCount!==void 0&&X(e,{"gen_ai.memory.record.count":n.recordCount}),r.capture.recordInputs&&X(e,{[Y.memoryRecords]:r.serializer.json(n.records)})}}};function $(e){return Ce[e.type]}function we(e){return $(e).parents}function Te(e,t){let n={identity:e.identity,attributes:be(e.identity),attempt:{turnId:e.identity.turnId,index:e.attempt?.index??0,attempt:e.attempt?.attempt??0},capture:e.capture,serializer:t};return{type:e.data.type,operationId:e.key,kind:`INTERNAL`,...$(e.data).prepare(e.data,n),parent:e.parent,root:e.data.type===`activation`&&e.parent===void 0,startTimeMs:e.startTimeMs,links:e.links}}function Ee(e,t,n,r,i,a){let o=n.outcome??(n.failed?`failed`:`completed`),s=n.outcomeUnknown!==!0||n.failed===!0;(t.type===`activation`||t.type===`approval`)&&s&&X(e,{[t.type===`activation`?`agent.turn.outcome`:`agent.approval.outcome`]:o}),n.usage!==void 0&&X(e,U(n.usage,t.type===`activation`||t.type===`model`)),$(t).complete?.(e,t,n,{capture:r,startTimeMs:i,serializer:a,outcome:o}),n.failed&&e.fail(n.error,n.errorCode)}function De(e,t){return t.emit||(t={emit:!1,recordInputs:!1,recordOutputs:!1}),$(e).redact?.(e,t)??e}function Oe(e,t,n){let r={...U(e.usage,!0),"gen_ai.response.id":e.responseId,"gen_ai.response.model":e.responseModelId,"gen_ai.response.finish_reasons":[e.finishReason]};if(!n)return r;r[`ai.response.finish_reason`]=e.finishReason;let i=e.content;if(i===void 0)return r;r[`gen_ai.output.messages`]=t.outputMessages(i,e.finishReason),r[`ai.response.reasoning`]=t.text(i.filter(e=>e.type===`reasoning`).map(e=>e.text).filter(e=>e.trim().length>0).join(`
5
+ `)),r[`ai.response.text`]=t.text(i.filter(e=>e.type===`text`).map(e=>e.text).join(``));let a=i.filter(e=>e.type===`tool-call`).map(e=>({callId:e.callId,input:e.input,toolName:e.toolName}));a.length>0&&(r[`ai.response.tool_calls`]=t.json(a));let o=i.filter(e=>e.type===`tool-result`||e.type===`tool-error`).map(e=>e.type===`tool-result`?{callId:e.callId,input:e.input,output:e.output,toolName:e.toolName}:{callId:e.callId,input:e.input,error:e.error instanceof Error?e.error.message:e.error,toolName:e.toolName});return o.length>0&&(r[`ai.response.tool_results`]=t.toolResults(o)),r}function ke(e){return{update(t){t.connectionName!==void 0&&t.method!==void 0&&e.write({"agent.connection.name":t.connectionName,"mcp.method.name":t.method,"network.protocol.name":`http`,"network.transport":`tcp`,"mcp.protocol.version":t.protocolVersion,"jsonrpc.request.id":t.requestId,"gen_ai.operation.name":t.method===`tools/call`?`execute_tool`:void 0,"gen_ai.tool.name":t.method===`tools/call`?t.toolName:void 0}),t.sessionId!==void 0&&e.write({"mcp.session.id":t.sessionId}),t.statusCode!==void 0&&e.write({"rpc.response.status_code":t.statusCode})},error(t,n){e.error(e.recordOutputs?t:void 0,n??(t instanceof Error?t.name:void 0))},arguments(t){e.recordInputs&&e.write({"gen_ai.tool.call.arguments":e.serializer.json(t)})},result(t){e.recordOutputs&&e.write({"gen_ai.tool.call.result":e.serializer.json(t)})}}}export{f as C,d as S,s as _,G as a,p as b,B as c,A as d,ve as f,C as g,T as h,Ee as i,U as l,pe as m,X as n,we as o,O as p,De as r,Te as s,ke as t,z as u,c as v,m as x,ee as y};
@@ -11,8 +11,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
11
11
  readonly dropped: {};
12
12
  };
13
13
  readonly tool: {
14
- readonly current: 90;
15
- readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90];
14
+ readonly current: 91;
15
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 29, 30, 31, 32, 34, 35, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 91];
16
16
  readonly dropped: {
17
17
  readonly 14: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
18
18
  readonly 15: "TaskExec replaces stageEffect with send";
@@ -75,8 +75,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
75
75
  };
76
76
  };
77
77
  readonly dynamicTool: {
78
- readonly current: 84;
79
- readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 31, 32, 33, 52, 54, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84];
78
+ readonly current: 85;
79
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 31, 32, 33, 52, 54, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85];
80
80
  readonly dropped: {
81
81
  readonly 21: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
82
82
  readonly 23: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
@@ -116,8 +116,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
116
116
  };
117
117
  };
118
118
  readonly channel: {
119
- readonly current: 60;
120
- readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 29, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60];
119
+ readonly current: 61;
120
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 29, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61];
121
121
  readonly dropped: {
122
122
  readonly 12: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
123
123
  readonly 19: "Continuation rekey was removed; channel extensions must use additive continuation.alias instead.";
@@ -139,8 +139,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
139
139
  };
140
140
  };
141
141
  readonly schedule: {
142
- readonly current: 32;
143
- readonly supported: readonly [1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32];
142
+ readonly current: 33;
143
+ readonly supported: readonly [1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33];
144
144
  readonly dropped: {
145
145
  readonly 5: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
146
146
  readonly 16: 'Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.';
@@ -148,8 +148,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
148
148
  };
149
149
  };
150
150
  readonly subagent: {
151
- readonly current: 37;
152
- readonly supported: readonly [3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37];
151
+ readonly current: 38;
152
+ readonly supported: readonly [3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 19, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38];
153
153
  readonly dropped: {
154
154
  readonly 1: "Persistent subagent sessions are now the default and the experimental opt-in was removed";
155
155
  readonly 2: "Persistent subagent sessions are now the default and the experimental opt-in was removed";
@@ -162,8 +162,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
162
162
  };
163
163
  };
164
164
  readonly connection: {
165
- readonly current: 48;
166
- readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48];
165
+ readonly current: 49;
166
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49];
167
167
  readonly dropped: {
168
168
  readonly 9: "Dynamic connection resolvers no longer receive conversation or channel continuation data";
169
169
  readonly 10: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
@@ -178,8 +178,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
178
178
  };
179
179
  };
180
180
  readonly hook: {
181
- readonly current: 45;
182
- readonly supported: readonly [20, 21, 22, 23, 25, 27, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45];
181
+ readonly current: 46;
182
+ readonly supported: readonly [20, 21, 22, 23, 25, 27, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46];
183
183
  readonly dropped: {
184
184
  readonly 1: "Model identity moved from session.started runtime metadata to step.started call attribution.";
185
185
  readonly 2: "Model identity moved from session.started runtime metadata to step.started call attribution.";
@@ -214,8 +214,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
214
214
  readonly dropped: {};
215
215
  };
216
216
  readonly dynamicSkill: {
217
- readonly current: 37;
218
- readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37];
217
+ readonly current: 38;
218
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38];
219
219
  readonly dropped: {
220
220
  readonly 13: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
221
221
  readonly 22: "Run mode was removed; sessions always park and ConversationContext no longer carries mode.";
@@ -229,8 +229,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
229
229
  readonly dropped: {};
230
230
  };
231
231
  readonly dynamicInstructions: {
232
- readonly current: 38;
233
- readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38];
232
+ readonly current: 39;
233
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39];
234
234
  readonly dropped: {
235
235
  readonly 14: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
236
236
  readonly 23: "Run mode was removed; sessions always park and ConversationContext no longer carries mode.";
@@ -1 +1 @@
1
- import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:90,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,29,30,31,32,34,35,76,77,78,80,81,82,84,85,86,87,88,89,90],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,28:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`,36:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,37:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,38:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,39:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,40:`runWorkflowProgram was made internal; use the workflow factory from eve/tools/workflow`,41:`workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })`,42:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,43:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,44:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,45:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,46:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,47:`eve/experimental/evaluate was removed; import decide from eve/ai`,48:`eve/experimental/evaluate was removed; import decide from eve/ai`,49:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,50:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,51:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,52:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,53:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,54:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,55:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,56:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,57:`agentRouter() no longer accepts a model-facing outputSchema; structured subagent output is requested only through ctx.agent().`,58:`Workflow tools no longer accept execution or return background task receipts; every call blocks until it settles.`,59:`Workflow tools no longer accept execution or return background task receipts, and every call blocks until it settles. ctx.ask() no longer accepts dismissible and reports a withdrawn request as cancelled, workflow tool contexts carry interruptSignal, and ctx.agent(name) returns a session handle whose send() delivers a message and whose result() resolves the turn; ctx.agent(name, { message, agentId }) and AgentInput were removed. A ctx.ask() question parks the open turn with turn.waiting instead of ending it.`,60:`Workflow tools define exactly one of execute(input, ctx), task(input, ctx), or serve(receive, ctx): a task() call returns a receipt and runs as a task, a serve() call reaches a resumable task through receive() and its model input gains taskId, and stream events gained task.started and task.settled. Agent tools are serve() tools with taskId in place of agentId, and the subagent.* stream events were removed. ctx.interruptSignal and WorkflowTaskContext were removed: a steering message aborts the abortSignal of an execute call the turn waits on.`,61:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,62:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,63:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,64:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,65:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,66:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,67:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,68:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,69:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,70:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,71:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,72:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,73:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,74:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,75:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,79:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`,83:`webSearch provider "openai" was replaced by "native" before it shipped in a release`}},dynamicTool:{current:84,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,31,32,33,52,54,60,61,62,63,64,65,66,67,68,69,70,72,73,75,76,77,78,79,80,81,82,83,84],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,28:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,29:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,30:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,34:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,35:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,36:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,37:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,38:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,39:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,40:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,41:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,42:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,43:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,44:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,45:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,46:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,47:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,48:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,49:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,50:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,51:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,53:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,55:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,56:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,57:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`,58:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,59:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,71:`AI SDK evaluation models became decision models; auto() accepts decision models only`,74:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},channel:{current:60,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,29,31,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,54,55,56,57,58,59,60],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,19:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,20:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,21:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,22:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,23:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,24:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,25:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,26:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,27:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,28:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,30:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,32:`Run mode and caller-supplied output schemas were removed from channel operations; sessions always park, and send options, audience inputs, and ConversationContext no longer carry mode, while from().send() and from().respond() no longer accept outputSchema.`,33:`Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text.`,34:`Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,35:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`,53:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},schedule:{current:32,supported:[1,2,3,4,6,7,8,9,10,11,12,13,14,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,16:`Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,17:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},subagent:{current:37,supported:[3,4,6,7,8,9,10,11,12,13,14,15,16,19,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,17:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`,18:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`,20:`Run mode was removed and agent definitions no longer declare outputSchema; sessions always park, ConversationContext no longer carries mode, and structured output is requested per turn.`,21:`Background task execution was removed: subagent results no longer carry backgroundTask, message.completed always carries text, and experimental.tasks is gone. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,22:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},connection:{current:48,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,19,20,21,22,24,26,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,25:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,27:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,28:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,29:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`,30:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,31:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,42:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},hook:{current:45,supported:[20,21,22,23,25,27,31,32,33,34,35,36,37,38,39,41,42,43,44,45],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,10:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,11:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,12:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,13:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,14:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,15:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,17:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,18:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,19:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,24:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,26:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,28:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text.`,29:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,30:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,40:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},skill:{current:3,supported:[1,2,3],dropped:{}},dynamicSkill:{current:37,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,25,26,27,28,29,30,31,32,33,34,35,36,37],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,22:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,23:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,24:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:38,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,26,27,28,29,30,31,32,33,34,35,36,37,38],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,24:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,25:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},config:{current:1,supported:[1],dropped:{}},state:{current:13,supported:[1,2,3,4,5,7,9,10,12,13],dropped:{6:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,8:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,11:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
1
+ import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:91,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,29,30,31,32,34,35,76,77,78,80,81,82,84,85,86,87,88,89,90,91],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,28:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`,36:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,37:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,38:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,39:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,40:`runWorkflowProgram was made internal; use the workflow factory from eve/tools/workflow`,41:`workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })`,42:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,43:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,44:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,45:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,46:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,47:`eve/experimental/evaluate was removed; import decide from eve/ai`,48:`eve/experimental/evaluate was removed; import decide from eve/ai`,49:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,50:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,51:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,52:`Background defineTool and TaskExec were removed; use defineWorkflowTool for durable background work.`,53:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,54:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,55:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,56:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,57:`agentRouter() no longer accepts a model-facing outputSchema; structured subagent output is requested only through ctx.agent().`,58:`Workflow tools no longer accept execution or return background task receipts; every call blocks until it settles.`,59:`Workflow tools no longer accept execution or return background task receipts, and every call blocks until it settles. ctx.ask() no longer accepts dismissible and reports a withdrawn request as cancelled, workflow tool contexts carry interruptSignal, and ctx.agent(name) returns a session handle whose send() delivers a message and whose result() resolves the turn; ctx.agent(name, { message, agentId }) and AgentInput were removed. A ctx.ask() question parks the open turn with turn.waiting instead of ending it.`,60:`Workflow tools define exactly one of execute(input, ctx), task(input, ctx), or serve(receive, ctx): a task() call returns a receipt and runs as a task, a serve() call reaches a resumable task through receive() and its model input gains taskId, and stream events gained task.started and task.settled. Agent tools are serve() tools with taskId in place of agentId, and the subagent.* stream events were removed. ctx.interruptSignal and WorkflowTaskContext were removed: a steering message aborts the abortSignal of an execute call the turn waits on.`,61:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,62:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,63:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,64:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,65:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,66:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,67:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,68:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,69:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,70:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,71:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,72:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,73:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,74:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,75:`eve/ai evaluate was renamed to decide and AI SDK evaluation models became decision models; import decide from eve/ai`,79:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`,83:`webSearch provider "openai" was replaced by "native" before it shipped in a release`}},dynamicTool:{current:85,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,31,32,33,52,54,60,61,62,63,64,65,66,67,68,69,70,72,73,75,76,77,78,79,80,81,82,83,84,85],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,28:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,29:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,30:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,34:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,35:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,36:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,37:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,38:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,39:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,40:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,41:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,42:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,43:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,44:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,45:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,46:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,47:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,48:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,49:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,50:`Background dynamic tools were removed; use a static defineWorkflowTool for durable background work.`,51:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,53:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,55:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,56:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,57:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`,58:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,59:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,71:`AI SDK evaluation models became decision models; auto() accepts decision models only`,74:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},channel:{current:61,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,29,31,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,54,55,56,57,58,59,60,61],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,19:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,20:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,21:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,22:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,23:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,24:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,25:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,26:`Task views no longer expose executor bindings; background work is owned by workflow runs.`,27:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,28:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,30:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,32:`Run mode and caller-supplied output schemas were removed from channel operations; sessions always park, and send options, audience inputs, and ConversationContext no longer carry mode, while from().send() and from().respond() no longer accept outputSchema.`,33:`Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text.`,34:`Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,35:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`,53:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},schedule:{current:33,supported:[1,2,3,4,6,7,8,9,10,11,12,13,14,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,16:`Background task delivery was removed: sends no longer accept taskDeliveryPolicy and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,17:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},subagent:{current:38,supported:[3,4,6,7,8,9,10,11,12,13,14,15,16,19,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,17:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`,18:`Removed experimental.instrumentationProviders; instrumentation is now always enabled for root agents.`,20:`Run mode was removed and agent definitions no longer declare outputSchema; sessions always park, ConversationContext no longer carries mode, and structured output is requested per turn.`,21:`Background task execution was removed: subagent results no longer carry backgroundTask, message.completed always carries text, and experimental.tasks is gone. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,22:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},connection:{current:49,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,19,20,21,22,24,26,32,33,34,35,36,37,38,39,40,41,43,44,45,46,47,48,49],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,25:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,27:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,28:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,29:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`,30:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,31:`Approval response policies now run for Cancel as well as Approve; a policy written for Approve only could reject every Cancel.`,42:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},hook:{current:46,supported:[20,21,22,23,25,27,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,10:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,11:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,12:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,13:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,14:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,15:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,17:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,18:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,19:`The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,24:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,26:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,28:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text.`,29:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,30:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event hook events were removed; subscribe to task.started, task.settled, and agent.started.`,40:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}},skill:{current:3,supported:[1,2,3],dropped:{}},dynamicSkill:{current:38,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,25,26,27,28,29,30,31,32,33,34,35,36,37,38],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,22:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,23:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,24:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:39,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21,22,26,27,28,29,30,31,32,33,34,35,36,37,38,39],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`Run mode was removed; sessions always park and ConversationContext no longer carries mode.`,24:`Background task execution was removed: subagent results no longer carry backgroundTask and message.completed always carries text. input.resolved reports outcome "cancelled" when a workflow tool withdraws a ctx.ask() request, and stream events gained agent.started, published when a workflow run opens a ctx.agent session, and turn.waiting, which parks the open turn instead of emitting turn.completed and session.waiting.`,25:`Stream events gained task.started and task.settled, and input.requested, authorization events, and agent.started carry the taskId of the task they come from. The subagent.called, subagent.completed, subagent.started, and subagent.event stream events were removed; agent calls report task.started, task.settled, and agent.started.`}},config:{current:1,supported:[1],dropped:{}},state:{current:13,supported:[1,2,3,4,5,7,9,10,12,13],dropped:{6:`Sandbox sessions no longer expose core identity and mutable networking is provider-specific.`,8:`SandboxSession no longer exposes setNetworkPolicy; pass the configured environment to ctx.getSandbox(environment) to access network policy capabilities`,11:`Sandbox provider handle hooks were renamed to onSandboxStop and onSandboxDelete.`}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
@@ -1 +1 @@
1
- import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function runWorkflowProgramTask(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}runWorkflowProgramTask.workflowId=`workflow//eve@0.79.1//runWorkflowProgramTask`;export{runWorkflowProgramTask};
1
+ import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function runWorkflowProgramTask(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}runWorkflowProgramTask.workflowId=`workflow//eve@0.79.2//runWorkflowProgramTask`;export{runWorkflowProgramTask};
@@ -1 +1 @@
1
- import{AuthKey,TurnDeliveryIdsKey}from"#context/keys.js";import"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveRemoteAgentStreamHeaders,respondToRemoteAgentSession}from"#execution/agent-sessions/remote.js";import{readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readHitlState}from"#harness/hitl/index.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{commitSessionStep,publishSessionEvents}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{receiveRelayedAnswer,routeAnswer}from"#harness/session-machine/transitions.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{setChannelContext}from"#execution/channel-context.js";import{routeDeliverPayload}from"#subagents/hitl-proxy.js";import{sendWorkflowAskAnswers,toToolInputResponseResponder}from"#execution/tools/workflow/answer.js";async function routeProxiedDeliverStep(e){"use step";return await withSessionStateDelta(e,routeProxiedDeliver)}async function routeProxiedDeliver(e){let t=readHitlState(readDurableSession(e.sessionState).state).relays,{delivery:n,serializedContext:r}=await deliverChannelInputResponses({...e,routable:e=>t.has(e.requestId)}),i=readDurableSession(e.sessionState),a=new Map,o=new Map,s,c=!hasDelegatedSessionContext(r)&&n.caller===void 0,l=new Set,u=[],d=[];for(let[e,t]of n.payloads.entries()){let r=routeDeliverPayload({allowRoute:e=>!l.has(e),payload:t,resolveMessage:c,state:i.state});s??=r.parentAction,r.forSelf!==void 0&&a.set(e,r.forSelf);for(let[t,i]of r.forChildren.entries()){if(i.workflowAsk!==void 0||i.message!==void 0)for(let{requestId:e}of i.payload.inputResponses)l.add(e);if(i.message!==void 0){let{sequence:t,turnId:r}=i.resolved.event;u.push(receiveRelayedAnswer({message:i.message,sequence:t,turnId:r}));for(let t of n.deliveryMetadata??[])t.payloadIndex===e&&d.push(t.deliveryId)}let a=JSON.stringify([i.childContinuationToken,i.childSessionInbox?.sessionId??``,i.remote?.sessionId??``,i.resolved.event.sequence,i.resolved.event.stepIndex,i.resolved.event.turnId,i.inputSource??null]),s=o.get(a)??{workflowAsk:i.workflowAsk,remote:i.remote,childContinuationToken:i.childContinuationToken,childSessionInbox:i.childSessionInbox,event:i.resolved.event,metadata:[],payloads:[],resolutions:new Map},c=s.payloads.length;s.payloads.push(i.payload);for(let e of i.resolved.resolutions)s.resolutions.has(e.requestId)||s.resolutions.set(e.requestId,e);if(r.forSelf===void 0&&t===0)for(let t of n.deliveryMetadata??[])t.payloadIndex===e&&s.metadata.push({...t,payloadIndex:c});o.set(a,s)}}let f=[];for(let e of o.values()){if(e.workflowAsk!==void 0){let t=coalesceDeliverPayloads(e.payloads).inputResponses??[];await sendWorkflowAskAnswers(e.workflowAsk,t,toToolInputResponseResponder(n.auth))}else{let t={...n,deliveryMetadata:e.metadata.length===0?void 0:e.metadata,payloads:e.payloads},i=e.remote;if(i!==void 0){let t=await deserializeContext(r),a=await resolveRemoteAgentStreamHeaders({bundle:t.require(BundleKey),name:i.name,resolverId:i.resolverId,url:i.url});await respondToRemoteAgentSession({remote:i,headers:a,auth:n.auth,responses:coalesceDeliverPayloads(e.payloads).inputResponses??[]})}else await resumeSessionInbox(e.childSessionInbox??e.childContinuationToken,t)}f.push({event:e.event,resolutions:[...e.resolutions.values()]})}let p=new Set([...o.values()].flatMap(e=>e.payloads.flatMap(e=>(e.inputResponses??[]).map(e=>e.requestId)))),m=new Set(f.flatMap(e=>e.resolutions.map(e=>e.requestId))),h=o.size>0&&a.size===0&&s===void 0&&[...t.keys()].some(e=>!m.has(e)&&!p.has(e)),g={serializedContext:r,sessionState:e.sessionState};u.length>0&&(g=await publishSessionEvents({serializedContext:joinTurnDeliveryIds(g.serializedContext,d),sessionState:g.sessionState,sessionWritable:e.sessionWritable},u));let _=await commitSessionStep({...g,sessionWritable:e.sessionWritable},e=>[routeAnswer(e,{children:f,holds:h})],{origin:`relayed`});if(s!==void 0)return{..._,...s};let v=[...a].sort(([e],[t])=>e-t),y=v.flatMap(([e],t)=>(n.deliveryMetadata??[]).filter(t=>t.payloadIndex===e).map(e=>({...e,payloadIndex:t}))),b=v.length===0?void 0:{...n,deliveryMetadata:y.length===0?void 0:y,payloads:v.map(([,e])=>e)};return{..._,kind:`continue`,remainder:b}}function joinTurnDeliveryIds(e,t){if(t.length===0)return e;let n=e[TurnDeliveryIdsKey.name]??[];return{...e,[TurnDeliveryIdsKey.name]:[...new Set([...n,...t])]}}async function mapHeldInputResponsesStep(e){"use step";return await withSessionStateDelta(e,async()=>{let t=new Set(e.requestIds),n=await deliverChannelInputResponses({...e,routable:e=>t.has(e.requestId)});return n.delivery===e.delivery?{delivery:void 0}:{delivery:n.delivery,serializedContext:n.serializedContext}})}async function deliverChannelInputResponses(e){let{routable:t}=e;if(!e.delivery.payloads.some(e=>e.inputResponses?.some(e=>!t(e))===!0))return e;let n=await deserializeContext(e.serializedContext),r=n.require(ChannelKey);if(r.deliver===void 0)return e;e.delivery.auth!==void 0&&n.set(AuthKey,e.delivery.auth??null);let i=r.state??{},a=!1,o=[];for(let s of e.delivery.payloads){if(s.inputResponses===void 0){o.push(s);continue}let e=[];for(let o of s.inputResponses){if(t(o)){e.push(o);continue}let c=buildAdapterContext({...r,state:structuredClone(i)},n),l=(await r.deliver({...s,inputResponses:[o],message:void 0},c))?.inputResponses?.filter(t)??[];if(l.length===0){e.push(o);continue}a=!0,i=c.state,e.push(...l)}o.push({...s,inputResponses:e})}if(!a)return e;let s=await deserializeContext(e.serializedContext);return setChannelContext(s,{...r,state:i}),{delivery:{...e.delivery,payloads:o},serializedContext:serializeContext(s)}}export{mapHeldInputResponsesStep,routeProxiedDeliverStep};
1
+ import{AuthKey,TurnDeliveryIdsKey}from"#context/keys.js";import"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{resolveRemoteAgentStreamHeaders,respondToRemoteAgentSession}from"#execution/agent-sessions/remote.js";import{readDurableSession}from"#execution/durable-session-store.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{readHitlState}from"#harness/hitl/index.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{commitSessionStep,publishSessionEvents}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{receiveRelayedAnswer,routeAnswer}from"#harness/session-machine/transitions.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{hasDelegatedSessionContext}from"#execution/delegated-session-context.js";import{setChannelContext}from"#execution/channel-context.js";import{routeDeliverPayload}from"#subagents/hitl-proxy.js";import{sendWorkflowAskAnswers,toToolInputResponseResponder}from"#execution/tools/workflow/answer.js";async function routeProxiedDeliverStep(e){"use step";return await withSessionStateDelta(e,routeProxiedDeliver)}async function routeProxiedDeliver(e){let t=readHitlState(readDurableSession(e.sessionState).state).relays,{delivery:n,serializedContext:r}=await deliverChannelInputResponses({...e,routable:e=>t.has(e.requestId)}),i=readDurableSession(e.sessionState),a=new Map,o=new Map,s,c=!hasDelegatedSessionContext(r)&&n.caller===void 0,l=new Set,u=[],d=[];for(let[e,t]of n.payloads.entries()){let r=routeDeliverPayload({allowRoute:e=>!l.has(e),payload:t,resolveMessage:c,state:i.state});s??=r.parentAction,r.forSelf!==void 0&&a.set(e,r.forSelf);for(let[t,i]of r.forChildren.entries()){if(i.workflowAsk!==void 0||i.message!==void 0)for(let{requestId:e}of i.payload.inputResponses)l.add(e);if(i.message!==void 0){let{sequence:t,turnId:r}=i.resolved.event;u.push(receiveRelayedAnswer({message:i.message,sequence:t,turnId:r}));for(let t of n.deliveryMetadata??[])t.payloadIndex===e&&d.push(t.deliveryId)}let a=JSON.stringify([i.childContinuationToken,i.childSessionInbox?.sessionId??``,i.remote?.sessionId??``,i.resolved.event.sequence,i.resolved.event.stepIndex,i.resolved.event.turnId,i.inputSource??null]),s=o.get(a)??{workflowAsk:i.workflowAsk,remote:i.remote,childContinuationToken:i.childContinuationToken,childSessionInbox:i.childSessionInbox,event:i.resolved.event,metadata:[],payloads:[],resolutions:new Map},c=s.payloads.length;s.payloads.push(i.payload);for(let e of i.resolved.resolutions)s.resolutions.has(e.requestId)||s.resolutions.set(e.requestId,e);if(r.forSelf===void 0&&t===0)for(let t of n.deliveryMetadata??[])t.payloadIndex===e&&s.metadata.push({...t,payloadIndex:c});o.set(a,s)}}let f={serializedContext:r,sessionState:e.sessionState,cancelled:!1};u.length>0&&(f=await publishSessionEvents({serializedContext:joinTurnDeliveryIds(f.serializedContext,d),sessionState:f.sessionState,sessionWritable:e.sessionWritable},u,{canCancelTurn:!0})),f.cancelled&&(s={kind:`cancel-turn`});let p=[];for(let e of f.cancelled?[]:o.values()){if(e.workflowAsk!==void 0){let t=coalesceDeliverPayloads(e.payloads).inputResponses??[];await sendWorkflowAskAnswers(e.workflowAsk,t,toToolInputResponseResponder(n.auth))}else{let t={...n,deliveryMetadata:e.metadata.length===0?void 0:e.metadata,payloads:e.payloads},i=e.remote;if(i!==void 0){let t=await deserializeContext(r),a=await resolveRemoteAgentStreamHeaders({bundle:t.require(BundleKey),name:i.name,resolverId:i.resolverId,url:i.url});await respondToRemoteAgentSession({remote:i,headers:a,auth:n.auth,responses:coalesceDeliverPayloads(e.payloads).inputResponses??[]})}else await resumeSessionInbox(e.childSessionInbox??e.childContinuationToken,t)}p.push({event:e.event,resolutions:[...e.resolutions.values()]})}let m=new Set([...o.values()].flatMap(e=>e.payloads.flatMap(e=>(e.inputResponses??[]).map(e=>e.requestId)))),h=new Set(p.flatMap(e=>e.resolutions.map(e=>e.requestId))),g=o.size>0&&a.size===0&&s===void 0&&[...t.keys()].some(e=>!h.has(e)&&!m.has(e)),_=await commitSessionStep({...f,sessionWritable:e.sessionWritable},e=>[routeAnswer(e,{children:p,holds:g})],{origin:`relayed`});if(s!==void 0)return{..._,...s};let v=[...a].sort(([e],[t])=>e-t),y=v.flatMap(([e],t)=>(n.deliveryMetadata??[]).filter(t=>t.payloadIndex===e).map(e=>({...e,payloadIndex:t}))),b=v.length===0?void 0:{...n,deliveryMetadata:y.length===0?void 0:y,payloads:v.map(([,e])=>e)};return{..._,kind:`continue`,remainder:b}}function joinTurnDeliveryIds(e,t){if(t.length===0)return e;let n=e[TurnDeliveryIdsKey.name]??[];return{...e,[TurnDeliveryIdsKey.name]:[...new Set([...n,...t])]}}async function mapHeldInputResponsesStep(e){"use step";return await withSessionStateDelta(e,async()=>{let t=new Set(e.requestIds),n=await deliverChannelInputResponses({...e,routable:e=>t.has(e.requestId)});return n.delivery===e.delivery?{delivery:void 0}:{delivery:n.delivery,serializedContext:n.serializedContext}})}async function deliverChannelInputResponses(e){let{routable:t}=e;if(!e.delivery.payloads.some(e=>e.inputResponses?.some(e=>!t(e))===!0))return e;let n=await deserializeContext(e.serializedContext),r=n.require(ChannelKey);if(r.deliver===void 0)return e;e.delivery.auth!==void 0&&n.set(AuthKey,e.delivery.auth??null);let i=r.state??{},a=!1,o=[];for(let s of e.delivery.payloads){if(s.inputResponses===void 0){o.push(s);continue}let e=[];for(let o of s.inputResponses){if(t(o)){e.push(o);continue}let c=buildAdapterContext({...r,state:structuredClone(i)},n),l=(await r.deliver({...s,inputResponses:[o],message:void 0},c))?.inputResponses?.filter(t)??[];if(l.length===0){e.push(o);continue}a=!0,i=c.state,e.push(...l)}o.push({...s,inputResponses:e})}if(!a)return e;let s=await deserializeContext(e.serializedContext);return setChannelContext(s,{...r,state:i}),{delivery:{...e.delivery,payloads:o},serializedContext:serializeContext(s)}}export{mapHeldInputResponsesStep,routeProxiedDeliverStep};
@@ -39,8 +39,15 @@ export interface PublishedSessionEvents {
39
39
  * Publishes a session step's own events, such as a workflow tool's
40
40
  * `action.partial`, exactly as a turn publishes its events. Call from a step
41
41
  * and adopt the result: hooks run in the session's context and may change it.
42
+ * Set `canCancelTurn` only for events of a running turn. Cancellation is
43
+ * returned with the updated state after the hooks finish, not thrown across
44
+ * the durable step boundary.
42
45
  */
43
- export declare function publishSessionEvents(target: SessionStepState, events: readonly UnstampedMessageStreamEvent[]): Promise<PublishedSessionEvents>;
46
+ export declare function publishSessionEvents(target: SessionStepState, events: readonly UnstampedMessageStreamEvent[], options?: {
47
+ readonly canCancelTurn?: boolean;
48
+ }): Promise<PublishedSessionEvents & {
49
+ readonly cancelled: boolean;
50
+ }>;
44
51
  /** A session step's context and session, restored so the step can publish. */
45
52
  export interface RestoredSessionStep {
46
53
  readonly ctx: ContextContainer;
@@ -59,6 +66,8 @@ export declare function restoreSessionStep(step: SessionStepState): Promise<Rest
59
66
  */
60
67
  export interface SessionStepPublication<T, R, S extends HarnessSessionBase = HarnessSessionBase> {
61
68
  readonly origin: SessionEventOrigin;
69
+ /** Stops the running turn the events belong to, for a hook's `ctx.cancel()`. */
70
+ readonly cancelTurn?: () => void;
62
71
  /** Where a relayed input batch came from; the channel adapter and its forwarding see it. */
63
72
  readonly inputSource?: string;
64
73
  /** Emits the step's events in the session's context scope. */
@@ -104,8 +113,8 @@ export interface SessionEventDispatcher {
104
113
  /** The context delivery hands the channel adapter; a turn step also hands it to `adapter.deliver`. */
105
114
  readonly adapterCtx: ChannelAdapterContext;
106
115
  /**
107
- * Runs the stream-event hooks for a written event. Only a turn step passes
108
- * `cancelTurn`; see `turn-event-handler.ts`.
116
+ * Runs the stream-event hooks for a written event. `cancelTurn` is passed
117
+ * only for an event of a running turn; see `turn-event-handler.ts`.
109
118
  */
110
119
  runHooks(event: MessageStreamEvent, cancelTurn?: () => void): Promise<void>;
111
120
  }
@@ -123,6 +132,7 @@ export interface SessionEventPublisher {
123
132
  publish(event: UnstampedMessageStreamEvent): Promise<void>;
124
133
  }
125
134
  export declare function openSessionEventPublisher(input: {
135
+ readonly cancelTurn?: () => void;
126
136
  readonly ctx: ContextContainer;
127
137
  readonly origin: SessionEventOrigin;
128
138
  readonly sessionWritable: WritableStream<Uint8Array>;