eve 0.81.1 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/src/channel/channel-address.d.ts +21 -2
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/channel-operations.d.ts +32 -1
- package/dist/src/channel/channel-operations.js +1 -1
- package/dist/src/channel/delivery-idempotency.d.ts +4 -0
- package/dist/src/channel/delivery-idempotency.js +1 -0
- package/dist/src/channel/routes.d.ts +6 -0
- package/dist/src/channel/session.d.ts +5 -0
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +14 -11
- package/dist/src/chunks/{use-eve-agent-Bp6nbhfV.js → use-eve-agent-DTu78IAF.js} +36 -0
- package/dist/src/chunks/{use-eve-agent-DLkjJIm3.js → use-eve-agent-DlznYwQk.js} +36 -0
- package/dist/src/cli/dev/command-options.d.ts +1 -0
- package/dist/src/cli/dev/diagnostic-dump.js +1 -1
- package/dist/src/cli/run.d.ts +1 -0
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/message-reducer-types.d.ts +7 -3
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/transcript-reducer.d.ts +6 -3
- package/dist/src/client/transcript-reducer.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +19 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.d.ts +2 -0
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/module-lifecycle.d.ts +1 -1
- package/dist/src/compiler/module-lifecycle.js +1 -1
- package/dist/src/compiler/module-map.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/project-sources.d.ts +6 -0
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/context/keys.d.ts +2 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/evals/cli/eval-state-directory.d.ts +7 -0
- package/dist/src/evals/cli/eval-state-directory.js +1 -0
- package/dist/src/evals/cli/eval.js +2 -2
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/support.d.ts +2 -0
- package/dist/src/eve-channel/support.js +1 -1
- package/dist/src/eve-channel/types.d.ts +7 -0
- package/dist/src/execution/agent-sessions/context.d.ts +2 -13
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/agent-sessions/runtime-overrides.d.ts +5 -0
- package/dist/src/execution/agent-sessions/runtime-overrides.js +1 -0
- package/dist/src/execution/agent-sessions/session.d.ts +2 -2
- package/dist/src/execution/agent-sessions/session.js +1 -1
- package/dist/src/execution/agent-sessions/steps.d.ts +2 -0
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +5 -5
- package/dist/src/execution/coordination-dispatch-step.d.ts +17 -2
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +5 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +0 -1
- package/dist/src/execution/dynamic-connection-recovery.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/effective-agent-config.d.ts +8 -2
- package/dist/src/execution/effective-agent-config.js +1 -1
- package/dist/src/execution/install-workflow-deployment-id.d.ts +3 -0
- package/dist/src/execution/install-workflow-deployment-id.js +1 -0
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/node-step.d.ts +1 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/runtime-context.d.ts +2 -0
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/entry-input.d.ts +1 -3
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +6 -9
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +5 -1
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/pending-history.d.ts +5 -0
- package/dist/src/execution/session/pending-history.js +1 -0
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/program.d.ts +1 -1
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/timeout-control.d.ts +18 -4
- package/dist/src/execution/session/timeout-control.js +1 -1
- package/dist/src/execution/session/timeout.d.ts +1 -2
- package/dist/src/execution/session/timeout.js +1 -1
- package/dist/src/execution/session/turn-event-handler.js +1 -1
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn-waiting-step.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/protocol.js +1 -1
- package/dist/src/execution/session.d.ts +0 -12
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/tasks/model-step.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +4 -4
- package/dist/src/execution/tasks/start.js +1 -1
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +2 -2
- package/dist/src/execution/workflow-runtime.d.ts +5 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/budget-request.d.ts +12 -6
- package/dist/src/harness/hitl/budget-request.js +1 -1
- package/dist/src/harness/hitl/budget.d.ts +7 -1
- package/dist/src/harness/hitl/budget.js +1 -1
- package/dist/src/harness/hitl/coordinator.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +1 -1
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.d.ts +2 -2
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/messages.d.ts +5 -0
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +2 -2
- package/dist/src/harness/model-call/request.d.ts +2 -2
- package/dist/src/harness/session-machine/transitions.d.ts +3 -1
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/step/context.d.ts +3 -0
- package/dist/src/harness/step/context.js +1 -1
- package/dist/src/harness/step/intake.d.ts +5 -2
- package/dist/src/harness/step/intake.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +7 -26
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +10 -25
- package/dist/src/internal/application/build-profile.d.ts +3 -0
- package/dist/src/internal/application/build-profile.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +2 -2
- package/dist/src/internal/application/dev-environment.d.ts +13 -0
- package/dist/src/internal/application/dev-environment.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-module-build-options.d.ts +7 -0
- package/dist/src/internal/authored-module-build-options.js +1 -0
- package/dist/src/internal/authored-module-graph.d.ts +13 -0
- package/dist/src/internal/authored-module-graph.js +1 -0
- package/dist/src/internal/authored-module-loader.d.ts +22 -1
- package/dist/src/internal/authored-module-loader.js +1 -3
- package/dist/src/internal/authored-module.d.ts +7 -0
- package/dist/src/internal/authored-module.js +1 -1
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +5 -1
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/development-programmatic-source-loader.d.ts +1 -0
- package/dist/src/internal/development-programmatic-source-loader.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-generation-metadata.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-deployment-id.d.ts +8 -0
- package/dist/src/internal/nitro/host/build-deployment-id.js +1 -0
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-server-state.js +1 -1
- package/dist/src/internal/nitro/host/skill-server-assets.js +1 -1
- package/dist/src/internal/nitro/host/stage-build-deployment-id.d.ts +2 -0
- package/dist/src/internal/nitro/host/stage-build-deployment-id.js +1 -0
- package/dist/src/internal/nitro/host/start-production-server.d.ts +1 -0
- package/dist/src/internal/nitro/host/start-production-server.js +3 -3
- package/dist/src/internal/nitro/routes/schedule-task.d.ts +3 -0
- package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
- package/dist/src/internal/programmatic-source-loader.d.ts +1 -0
- package/dist/src/internal/programmatic-source-loader.js +1 -1
- package/dist/src/internal/schedules/disabled.d.ts +2 -0
- package/dist/src/internal/schedules/disabled.js +1 -0
- package/dist/src/internal/workflow/development-world-server.js +1 -1
- package/dist/src/internal/workflow/local-world-data-directory.d.ts +2 -1
- package/dist/src/internal/workflow/local-world-data-directory.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/protocol/message.d.ts +27 -1
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +13 -0
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/chat-sdk/fetch-message.d.ts +10 -0
- package/dist/src/public/channels/chat-sdk/fetch-message.js +1 -0
- package/dist/src/public/channels/chat-sdk/index.d.ts +1 -1
- package/dist/src/public/channels/chat-sdk/reply-context.d.ts +15 -0
- package/dist/src/public/channels/chat-sdk/reply-context.js +2 -0
- package/dist/src/public/channels/discord/discordChannel.d.ts +3 -0
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +3 -0
- package/dist/src/public/channels/imessage-tapbacks.d.ts +74 -0
- package/dist/src/public/channels/imessage-tapbacks.js +1 -0
- package/dist/src/public/channels/index.d.ts +2 -1
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.d.ts +3 -0
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/linq/inboundContent.d.ts +7 -0
- package/dist/src/public/channels/linq/inboundContent.js +1 -1
- package/dist/src/public/channels/linq/index.d.ts +1 -0
- package/dist/src/public/channels/linq/index.js +1 -1
- package/dist/src/public/channels/linq/linqChannel.d.ts +17 -1
- package/dist/src/public/channels/linq/linqChannel.js +1 -1
- package/dist/src/public/channels/photon/inboundContent.d.ts +7 -0
- package/dist/src/public/channels/photon/inboundContent.js +2 -1
- package/dist/src/public/channels/photon/index.d.ts +1 -0
- package/dist/src/public/channels/photon/index.js +1 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +17 -1
- package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +6 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/model-context.d.ts +7 -0
- package/dist/src/public/channels/slack/model-context.js +1 -1
- package/dist/src/public/channels/slack/reply-delivery.d.ts +5 -0
- package/dist/src/public/channels/slack/reply-delivery.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +17 -3
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +3 -0
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +3 -0
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/definitions/agent.d.ts +1 -1
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +1 -0
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/runtime/agent/resolve-model.d.ts +4 -0
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +2 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
- package/dist/src/runtime/types.d.ts +3 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +31 -42
- package/dist/src/shared/session-history.d.ts +22 -0
- package/dist/src/shared/session-history.js +1 -0
- package/dist/src/subagents/tool.d.ts +1 -3
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +14 -1
- package/dist/src/tracing/eve/conversation-context.d.ts +4 -1
- package/dist/src/tracing/eve/conversation-context.js +1 -1
- package/dist/src/tracing/eve/invoke-tool-span.js +1 -1
- package/dist/src/tracing/eve/operation-input.d.ts +0 -5
- package/dist/src/tracing/eve/operation-input.js +1 -1
- package/dist/src/tracing/eve/otel-registration.js +1 -1
- package/dist/src/tracing/eve/session.d.ts +3 -2
- package/dist/src/tracing/eve/session.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +86 -65
- package/docs/channels/chat-sdk.mdx +6 -1
- package/docs/channels/custom.mdx +38 -6
- package/docs/channels/eve.mdx +46 -0
- package/docs/channels/linq.mdx +51 -0
- package/docs/channels/photon.mdx +64 -0
- package/docs/channels/slack.mdx +4 -2
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/concepts/execution-model-and-durability.mdx +12 -5
- package/docs/concepts/sessions-runs-and-streaming.md +9 -8
- package/docs/connections/overview.mdx +1 -1
- package/docs/experimental/dynamic-schedules.mdx +186 -0
- package/docs/experimental/meta.json +4 -0
- package/docs/guides/client/streaming.mdx +1 -0
- package/docs/guides/deployment/self-hosting.md +3 -0
- package/docs/guides/hooks.md +21 -1
- package/docs/memory/overview.mdx +2 -1
- package/docs/patterns/dynamic-scheduling.md +3 -1
- package/docs/reference/cli.md +14 -7
- package/docs/schedules.mdx +2 -0
- package/docs/subagents/index.mdx +2 -0
- package/docs/tools/overview.mdx +2 -1
- package/docs/tools/tasks-upgrade.md +12 -7
- package/docs/tools/tasks.md +10 -6
- package/docs/tools/workflows.mdx +36 -5
- package/docs/tutorial/connect-a-warehouse.mdx +1 -1
- package/docs/tutorial/run-analysis.mdx +1 -1
- package/package.json +1 -1
- package/dist/src/execution/run-session-limits.d.ts +0 -12
- package/dist/src/execution/run-session-limits.js +0 -1
- package/dist/src/harness/session-usage-limits.d.ts +0 -49
- package/dist/src/harness/session-usage-limits.js +0 -1
- package/dist/src/subagents/token-budget.d.ts +0 -15
- package/dist/src/subagents/token-budget.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join,posix}from"node:path";import{stripLogicalPathExtension}from"#discover/filesystem.js";import{canonicalSourceSlot,extensionMountId}from"#compiler/source-graph.js";import{mountRefNamespace}from"#discover/extensions.js";const MODULE_KIND_BY_SLOT_ROOT={agent:`config`,channels:`channel`,extensions:`extension`,hooks:`hook`,instructions:`instructions`,memory:`memory`,sandbox:`sandbox`,schedules:`schedule`,skills:`skill`,tools:`tool`};function projectAgentSources(e){let t=e.owner??{kind:`application`},n=[],r=[],i=[];projectManifest({externalDependencies:e.externalDependencies,candidates:n,projection:createApplicationManifestSourceProjection(e.extensionScope),layer:e.layer??`application`,manifest:e.manifest,nodeId:e.nodeId,subagentsPath:posix.join(e.nodePath,`subagents`),owner:t,mountId:e.mountId,declarationMountIds:new Map(e.manifest.extensions.map(t=>[t.sourceId,posix.join(e.nodePath,`extensions`,mountRefNamespace(t.logicalPath))])),resources:r,subagents:i});for(let t of[...e.manifest.resolvedExtensions].sort((e,t)=>e.namespace.localeCompare(t.namespace))){let a=extensionMountId(e.nodePath,t.namespace),o=createExtensionManifestSourceProjection(t),s={kind:`extension`,mountId:a,namespace:t.namespace,packageName:t.packageName};projectManifest({externalDependencies:mergeDependencies(e.externalDependencies,t.externalDependencies),candidates:n,projection:o,layer:`extension-package`,manifest:t.manifest,nodeId:e.nodeId,subagentsPath:posix.join(a,`subagents`),owner:s,mountId:a,resources:r,sourceIdPrefix:`ext:${t.namespace}:`,subagents:i}),t.overrides!==void 0&&projectManifest({externalDependencies:e.externalDependencies,candidates:n,projection:o,layer:`extension-override`,manifest:t.overrides,nodeId:e.nodeId,subagentsPath:posix.join(a,`subagents`),owner:{kind:`application`},mountId:a,resources:r,sourceIdPrefix:`ext-override:${t.namespace}:`,subagents:i})}return{candidates:n,resources:r,subagents:i}}function projectSelectedSources(e){let t=new Map(e.resources.map(e=>[e.candidate.sourceId,e])),n=[];for(let r of e.candidates)if(isModuleCandidate(r))n.push(projectModuleCandidate(r));else{let e=t.get(r.sourceId);e!==void 0&&n.push(e)}return n}function createFilesystemModuleCandidate(e){return{backing:{externalDependencies:[...e.externalDependencies],...e.owner.kind===`extension`&&e.extensionScope!==void 0?{extensionScope:e.extensionScope}:{},kind:`filesystem`,mountId:e.mountId,sourcePath:join(e.sourceRoot,e.source.logicalPath)},exportName:e.source.exportName,form:`direct`,layer:e.layer,logicalPath:e.logicalPath,nodeId:e.nodeId,owner:e.owner,sourceId:e.sourceId??e.source.sourceId}}function createApplicationManifestSourceProjection(e){let t={logicalPath:e=>e,name:e=>e};return e!==void 0&&(t.extensionScope=e),t}function createExtensionManifestSourceProjection(e){let{namespace:t,sourceRoot:n}=e;return{extensionScope:{namespace:t,sourceRoot:n},logicalPath:e=>qualifyExtensionContributionLogicalPath(e,t),name:e=>`${t}__${e}`}}function projectManifest(e){let{projection:t}=e,sourceId=t=>`${e.sourceIdPrefix??``}${t}`,pushModule=(n,r,i=e.mountId)=>{let a=t.logicalPath(r??n.logicalPath),o=createFilesystemModuleCandidate({externalDependencies:e.externalDependencies,...t.extensionScope===void 0?{}:{extensionScope:t.extensionScope},layer:e.layer,logicalPath:a,nodeId:e.nodeId,owner:e.owner,mountId:i,source:n,sourceId:sourceId(n.sourceId),sourceRoot:e.manifest.agentRoot});e.candidates.push(o)},pushResource=(n,r)=>{let i=t.logicalPath(r.logicalPath),a={...r,...r.sourceKind===`skill-package`?{name:t.name(r.name)}:{},logicalPath:i,sourceId:sourceId(r.sourceId)},o={backing:{kind:`resource`,sourcePath:r.sourceKind===`skill-package`?r.skillFilePath:join(e.manifest.agentRoot,r.logicalPath)},form:`direct`,layer:e.layer,logicalPath:i,nodeId:e.nodeId,owner:e.owner,sourceId:a.sourceId};e.candidates.push(o),e.resources.push({candidate:o,kind:n,source:a})};if(e.manifest.configModule!==void 0){let t=e.manifest.configModule.logicalPath;pushModule(e.manifest.configModule,canonicalSourceSlot(t)===`agent`?void 0:`agent.ts`)}let n=new Set(e.manifest.resolvedExtensions.map(e=>e.namespace));for(let t of e.manifest.extensions)n.has(mountRefNamespace(t.logicalPath))&&pushModule(t,void 0,e.declarationMountIds?.get(t.sourceId));for(let t of e.manifest.channels)pushModule(t);for(let t of e.manifest.connections)pushModule(t);for(let t of e.manifest.hooks)pushModule(t);for(let t of e.manifest.memories)pushModule(t);e.manifest.sandbox!==null&&pushModule(e.manifest.sandbox);for(let t of e.manifest.tools)pushModule(t);for(let t of e.manifest.instructions)t.sourceKind===`module`?pushModule(t):pushResource(`instructions`,t);for(let t of e.manifest.schedules)t.sourceKind===`module`?pushModule(t):pushResource(`schedule`,t);for(let t of e.manifest.skills)t.sourceKind===`module`?pushModule(t):pushResource(`skill`,t);for(let n of e.manifest.subagents){let r=t.name(n.subagentId),i=t.logicalPath(n.logicalPath);if(r===`agent`)throw Error(`Subagent "${i}" uses the reserved name "agent". Rename its path; eve reserves "agent" for the built-in root-copy target.`);let a={...n,logicalPath:i,sourceId:sourceId(n.sourceId),subagentId:r},o={backing:{kind:`resource`,sourcePath:n.entryPath},form:`direct`,layer:e.layer,logicalPath:i,nodeId:e.nodeId,owner:e.owner,sourceId:a.sourceId};e.candidates.push(o),e.subagents.push({candidate:o,mountId:e.mountId,nodePath:posix.join(e.subagentsPath,n.subagentId),...t.extensionScope===void 0?{}:{extensionScope:t.extensionScope},owner:e.owner,source:a})}}function projectModuleCandidate(e){let t={exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`},n=canonicalSourceSlot(e.logicalPath);if(n.startsWith(`connections/`))return{candidate:e,kind:`connection`,source:{...t,connectionName:deriveConnectionName(e.logicalPath)}};let r=MODULE_KIND_BY_SLOT_ROOT[n.split(`/`,1)[0]];if(r===void 0)throw Error(`Agent module source slot "${e.logicalPath}" is not compiled yet.`);return{candidate:e,kind:r,source:t}}function isModuleCandidate(e){return e.backing.kind!==`resource`}const EXTENSION_CONTRIBUTION_ROOTS=new Set([`channels`,`connections`,`hooks`,`instructions`,`schedules`,`skills`,`subagents`,`tools`]);function qualifyExtensionContributionLogicalPath(e,t){let n=e.split(`/`);if(n.length===1){let n=stripLogicalPathExtension(e);if(n===`instructions`||n===`system`)return`instructions/${t}${e.slice(e.lastIndexOf(`.`))}`;throw Error(`Extension source slot "${e}" cannot be namespace-scoped.`)}let r=n[0];if(!EXTENSION_CONTRIBUTION_ROOTS.has(r))throw Error(`Extension source slot "${e}" cannot be namespace-scoped.`);return n[1]=`${t}__${n[1]}`,n.join(`/`)}function deriveConnectionName(e){let t=stripLogicalPathExtension(e).replace(/^connections\//,``);return t.endsWith(`/connection`)?t.slice(0,-11):t}function mergeDependencies(...e){return[...new Set(e.flat())]}export{projectAgentSources,projectSelectedSources,qualifyExtensionContributionLogicalPath};
|
|
1
|
+
import{join,posix}from"node:path";import{stripLogicalPathExtension}from"#discover/filesystem.js";import{canonicalSourceSlot,extensionMountId}from"#compiler/source-graph.js";import{mountRefNamespace}from"#discover/extensions.js";const MODULE_KIND_BY_SLOT_ROOT={agent:`config`,channels:`channel`,extensions:`extension`,hooks:`hook`,instructions:`instructions`,memory:`memory`,sandbox:`sandbox`,schedules:`schedule`,skills:`skill`,tools:`tool`};function projectAgentSources(e){let t=e.owner??{kind:`application`},n=[],r=[],i=[];projectManifest({externalDependencies:e.externalDependencies,candidates:n,projection:createApplicationManifestSourceProjection(e.extensionScope),layer:e.layer??`application`,manifest:e.manifest,nodeId:e.nodeId,subagentsPath:posix.join(e.nodePath,`subagents`),owner:t,mountId:e.mountId,declarationMountIds:new Map(e.manifest.extensions.map(t=>[t.sourceId,posix.join(e.nodePath,`extensions`,mountRefNamespace(t.logicalPath))])),resources:r,subagents:i});for(let t of[...e.manifest.resolvedExtensions].sort((e,t)=>e.namespace.localeCompare(t.namespace))){let a=extensionMountId(e.nodePath,t.namespace),o=createExtensionManifestSourceProjection(t),s={kind:`extension`,mountId:a,namespace:t.namespace,packageName:t.packageName};projectManifest({externalDependencies:mergeDependencies(e.externalDependencies,t.externalDependencies),candidates:n,projection:o,layer:`extension-package`,manifest:t.manifest,nodeId:e.nodeId,subagentsPath:posix.join(a,`subagents`),owner:s,mountId:a,resources:r,sourceIdPrefix:`ext:${t.namespace}:`,subagents:i}),t.overrides!==void 0&&projectManifest({externalDependencies:e.externalDependencies,candidates:n,projection:o,layer:`extension-override`,manifest:t.overrides,nodeId:e.nodeId,subagentsPath:posix.join(a,`subagents`),owner:{kind:`application`},mountId:a,resources:r,sourceIdPrefix:`ext-override:${t.namespace}:`,subagents:i})}return{candidates:n,resources:r,subagents:i}}function listApplicationModulePaths(e){return[...[...e.configModule===void 0?[]:[e.configModule],...e.sandbox===null?[]:[e.sandbox],...e.channels,...e.connections,...e.hooks,...e.memories,...e.tools,...e.instructions,...e.schedules,...e.skills].flatMap(t=>t.sourceKind===`module`?[join(e.agentRoot,t.logicalPath)]:[]),...e.subagents.flatMap(e=>listApplicationModulePaths(e.manifest))]}function projectSelectedSources(e){let t=new Map(e.resources.map(e=>[e.candidate.sourceId,e])),n=[];for(let r of e.candidates)if(isModuleCandidate(r))n.push(projectModuleCandidate(r));else{let e=t.get(r.sourceId);e!==void 0&&n.push(e)}return n}function createFilesystemModuleCandidate(e){return{backing:{externalDependencies:[...e.externalDependencies],...e.owner.kind===`extension`&&e.extensionScope!==void 0?{extensionScope:e.extensionScope}:{},kind:`filesystem`,mountId:e.mountId,sourcePath:join(e.sourceRoot,e.source.logicalPath)},exportName:e.source.exportName,form:`direct`,layer:e.layer,logicalPath:e.logicalPath,nodeId:e.nodeId,owner:e.owner,sourceId:e.sourceId??e.source.sourceId}}function createApplicationManifestSourceProjection(e){let t={logicalPath:e=>e,name:e=>e};return e!==void 0&&(t.extensionScope=e),t}function createExtensionManifestSourceProjection(e){let{namespace:t,sourceRoot:n}=e;return{extensionScope:{namespace:t,sourceRoot:n},logicalPath:e=>qualifyExtensionContributionLogicalPath(e,t),name:e=>`${t}__${e}`}}function projectManifest(e){let{projection:t}=e,sourceId=t=>`${e.sourceIdPrefix??``}${t}`,pushModule=(n,r,i=e.mountId)=>{let a=t.logicalPath(r??n.logicalPath),o=createFilesystemModuleCandidate({externalDependencies:e.externalDependencies,...t.extensionScope===void 0?{}:{extensionScope:t.extensionScope},layer:e.layer,logicalPath:a,nodeId:e.nodeId,owner:e.owner,mountId:i,source:n,sourceId:sourceId(n.sourceId),sourceRoot:e.manifest.agentRoot});e.candidates.push(o)},pushResource=(n,r)=>{let i=t.logicalPath(r.logicalPath),a={...r,...r.sourceKind===`skill-package`?{name:t.name(r.name)}:{},logicalPath:i,sourceId:sourceId(r.sourceId)},o={backing:{kind:`resource`,sourcePath:r.sourceKind===`skill-package`?r.skillFilePath:join(e.manifest.agentRoot,r.logicalPath)},form:`direct`,layer:e.layer,logicalPath:i,nodeId:e.nodeId,owner:e.owner,sourceId:a.sourceId};e.candidates.push(o),e.resources.push({candidate:o,kind:n,source:a})};if(e.manifest.configModule!==void 0){let t=e.manifest.configModule.logicalPath;pushModule(e.manifest.configModule,canonicalSourceSlot(t)===`agent`?void 0:`agent.ts`)}let n=new Set(e.manifest.resolvedExtensions.map(e=>e.namespace));for(let t of e.manifest.extensions)n.has(mountRefNamespace(t.logicalPath))&&pushModule(t,void 0,e.declarationMountIds?.get(t.sourceId));for(let t of e.manifest.channels)pushModule(t);for(let t of e.manifest.connections)pushModule(t);for(let t of e.manifest.hooks)pushModule(t);for(let t of e.manifest.memories)pushModule(t);e.manifest.sandbox!==null&&pushModule(e.manifest.sandbox);for(let t of e.manifest.tools)pushModule(t);for(let t of e.manifest.instructions)t.sourceKind===`module`?pushModule(t):pushResource(`instructions`,t);for(let t of e.manifest.schedules)t.sourceKind===`module`?pushModule(t):pushResource(`schedule`,t);for(let t of e.manifest.skills)t.sourceKind===`module`?pushModule(t):pushResource(`skill`,t);for(let n of e.manifest.subagents){let r=t.name(n.subagentId),i=t.logicalPath(n.logicalPath);if(r===`agent`)throw Error(`Subagent "${i}" uses the reserved name "agent". Rename its path; eve reserves "agent" for the built-in root-copy target.`);let a={...n,logicalPath:i,sourceId:sourceId(n.sourceId),subagentId:r},o={backing:{kind:`resource`,sourcePath:n.entryPath},form:`direct`,layer:e.layer,logicalPath:i,nodeId:e.nodeId,owner:e.owner,sourceId:a.sourceId};e.candidates.push(o),e.subagents.push({candidate:o,mountId:e.mountId,nodePath:posix.join(e.subagentsPath,n.subagentId),...t.extensionScope===void 0?{}:{extensionScope:t.extensionScope},owner:e.owner,source:a})}}function projectModuleCandidate(e){let t={exportName:e.exportName,logicalPath:e.logicalPath,sourceId:e.sourceId,sourceKind:`module`},n=canonicalSourceSlot(e.logicalPath);if(n.startsWith(`connections/`))return{candidate:e,kind:`connection`,source:{...t,connectionName:deriveConnectionName(e.logicalPath)}};let r=MODULE_KIND_BY_SLOT_ROOT[n.split(`/`,1)[0]];if(r===void 0)throw Error(`Agent module source slot "${e.logicalPath}" is not compiled yet.`);return{candidate:e,kind:r,source:t}}function isModuleCandidate(e){return e.backing.kind!==`resource`}const EXTENSION_CONTRIBUTION_ROOTS=new Set([`channels`,`connections`,`hooks`,`instructions`,`schedules`,`skills`,`subagents`,`tools`]);function qualifyExtensionContributionLogicalPath(e,t){let n=e.split(`/`);if(n.length===1){let n=stripLogicalPathExtension(e);if(n===`instructions`||n===`system`)return`instructions/${t}${e.slice(e.lastIndexOf(`.`))}`;throw Error(`Extension source slot "${e}" cannot be namespace-scoped.`)}let r=n[0];if(!EXTENSION_CONTRIBUTION_ROOTS.has(r))throw Error(`Extension source slot "${e}" cannot be namespace-scoped.`);return n[1]=`${t}__${n[1]}`,n.join(`/`)}function deriveConnectionName(e){let t=stripLogicalPathExtension(e).replace(/^connections\//,``);return t.endsWith(`/connection`)?t.slice(0,-11):t}function mergeDependencies(...e){return[...new Set(e.flat())]}export{listApplicationModulePaths,projectAgentSources,projectSelectedSources,qualifyExtensionContributionLogicalPath};
|
|
@@ -13,6 +13,7 @@ import type { InstrumentationChannelDeliveryRef } from "#instrumentation/lifecyc
|
|
|
13
13
|
import type { UserModelMessage } from "#harness/messages.js";
|
|
14
14
|
import type { HandleEventFn } from "#harness/types.js";
|
|
15
15
|
import type { PersistedDynamicToolMetadata } from "#context/dynamic-tool-metadata.js";
|
|
16
|
+
import type { AgentSessionRuntimeOverrides } from "#execution/agent-sessions/runtime-overrides.js";
|
|
16
17
|
import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
|
|
17
18
|
import type { DynamicRemoteAgentConfig } from "#runtime/subagents/dynamic-remote-agent-config.js";
|
|
18
19
|
import type { SandboxAccess, SandboxSessionEndReason } from "#sandbox/state.js";
|
|
@@ -222,6 +223,7 @@ export declare const SessionDynamicSubagentSelectionsKey: ContextKey<Readonly<Re
|
|
|
222
223
|
export declare const TurnDynamicSubagentSelectionsKey: ContextKey<Readonly<Record<string, DurableDynamicSubagentSelection>>>;
|
|
223
224
|
export declare const SessionDynamicSubagentRuntimeRevisionKey: ContextKey<string>;
|
|
224
225
|
export declare const DynamicSubagentAgentConfigKey: ContextKey<DynamicSubagentAgentConfig>;
|
|
226
|
+
export declare const AgentSessionRuntimeOverridesKey: ContextKey<AgentSessionRuntimeOverrides>;
|
|
225
227
|
/**
|
|
226
228
|
* Durable state for one session-scoped dynamic skill.
|
|
227
229
|
*/
|
package/dist/src/context/keys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SESSION_INBOX_CONTEXT_KEY}from"#execution/session-inbox/address.js";import{ContextKey}from"#context/key.js";import{STUB_CONTEXT_KEY}from"#tool-stubs/types.js";import{SESSION_CALLBACK_CONTEXT_KEY_NAME}from"#context/key-names.js";const AuthKey=new ContextKey(`eve.auth`),ToolStubsKey=new ContextKey(STUB_CONTEXT_KEY),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ConversationIdKey=new ContextKey(`eve.conversationId`),SessionInboxKey=new ContextKey(SESSION_INBOX_CONTEXT_KEY),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ContinuationHookTokensKey=new ContextKey(`eve.continuationHookTokens`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),LocalDevRequestKey=new ContextKey(`eve.internal.localDevRequest`),OccurrenceIdKey=new ContextKey(`eve.scheduleOccurrenceId`),ScheduleIdKey=new ContextKey(`eve.scheduleId`),ScheduleInstanceKey=new ContextKey(`eve.scheduleInstance`),SessionTitleKey=new ContextKey(`eve.sessionTitle`),ChannelDeliveryKey=new ContextKey(`eve.channelDelivery`),TurnDeliveryIdsKey=new ContextKey(`eve.turnDeliveryIds`),HistoryStateKey=new ContextKey(`eve.historyState`),OfferedCatalogToolsKey=new ContextKey(`eve.offeredCatalogTools`),ActiveChannelDeliveriesKey=new ContextKey(`eve.activeChannelDeliveries`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ParentSessionKey=new ContextKey(`eve.parentSession`),SessionPredecessorKey=new ContextKey(`eve.sessionPredecessor`),TraceRootKey=new ContextKey(`eve.traceRoot`),ParentTraceContextKey=new ContextKey(`eve.parentTraceContext`),SessionTraceSeedKey=new ContextKey(`eve.sessionTraceSeed`),OtelTraceEnabledKey=new ContextKey(`eve.otelTraceEnabled`),CapabilitiesKey=new ContextKey(`eve.capabilities`),SessionCallbackKey=new ContextKey(SESSION_CALLBACK_CONTEXT_KEY_NAME),LegacyRemoteAgentCallerKey=new ContextKey(`eve.legacyRemoteAgentCaller`),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),SandboxTerminalCleanupKey=new ContextKey(`eve.internal.sandboxTerminalCleanup`),HandleEventKey=new ContextKey(`eve.internal.handleEvent`),StaticModelReferenceKey=new ContextKey(`eve.staticModelReference`),SessionDynamicModelReferenceKey=new ContextKey(`eve.sessionDynamicModelReference`),TurnDynamicModelReferenceKey=new ContextKey(`eve.turnDynamicModelReference`),RuntimeModelMetadataCacheKey=new ContextKey(`eve.runtimeModelMetadataCache`),LiveStepDynamicModelSelectionKey=new ContextKey(`eve.liveStepDynamicModelSelection`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),SessionDynamicToolRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicToolRuntimeRevision`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),TurnMemoryLocksKey=new ContextKey(`eve.memory.turnLocks`),PreparedMemoryPreambleKey=new ContextKey(`eve.memory.preparedPreamble`),PendingMemoryCommitKey=new ContextKey(`eve.memory.pendingCommit`),PreparedMemoryCompactionKey=new ContextKey(`eve.memory.preparedCompaction`),StepDynamicToolMetadataKey=new ContextKey(`eve.stepDynamicToolMetadata`),SessionDynamicSubagentSelectionsKey=new ContextKey(`eve.sessionDynamicSubagentSelections`),TurnDynamicSubagentSelectionsKey=new ContextKey(`eve.turnDynamicSubagentSelections`),SessionDynamicSubagentRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicSubagentRuntimeRevision`),DynamicSubagentAgentConfigKey=new ContextKey(`eve.dynamicSubagentAgentConfig`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),DynamicSkillSandboxKey=new ContextKey(`eve.dynamicSkillSandbox`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`),DynamicInstructionResolveMessagesKey=new ContextKey(`eve.dynamicInstructionResolveMessages`),PendingDynamicInstructionUserMessagesKey=new ContextKey(`eve.pendingDynamicInstructionUserMessages`);export{ActiveChannelDeliveriesKey,AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationHookTokensKey,ContinuationTokenKey,ConversationIdKey,DynamicInstructionResolveMessagesKey,DynamicSkillManifestKey,DynamicSkillSandboxKey,DynamicSubagentAgentConfigKey,HandleEventKey,HistoryStateKey,InitiatorAuthKey,LegacyRemoteAgentCallerKey,LiveStepDynamicModelSelectionKey,LocalDevRequestKey,OccurrenceIdKey,OfferedCatalogToolsKey,OtelTraceEnabledKey,ParentSessionKey,ParentTraceContextKey,PendingDynamicInstructionUserMessagesKey,PendingMemoryCommitKey,PreparedMemoryCompactionKey,PreparedMemoryPreambleKey,RuntimeModelMetadataCacheKey,SandboxKey,SandboxTerminalCleanupKey,ScheduleIdKey,ScheduleInstanceKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicModelReferenceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicSubagentSelectionsKey,SessionDynamicToolMetadataKey,SessionDynamicToolRuntimeRevisionKey,SessionIdKey,SessionInboxKey,SessionKey,SessionPredecessorKey,SessionTitleKey,SessionTraceSeedKey,StaticModelReferenceKey,StepDynamicToolMetadataKey,ToolStubsKey,TraceRootKey,TurnDeliveryIdsKey,TurnDynamicInstructionsKey,TurnDynamicModelReferenceKey,TurnDynamicSubagentSelectionsKey,TurnDynamicToolMetadataKey,TurnMemoryLocksKey};
|
|
1
|
+
import{SESSION_INBOX_CONTEXT_KEY}from"#execution/session-inbox/address.js";import{ContextKey}from"#context/key.js";import{STUB_CONTEXT_KEY}from"#tool-stubs/types.js";import{SESSION_CALLBACK_CONTEXT_KEY_NAME}from"#context/key-names.js";const AuthKey=new ContextKey(`eve.auth`),ToolStubsKey=new ContextKey(STUB_CONTEXT_KEY),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ConversationIdKey=new ContextKey(`eve.conversationId`),SessionInboxKey=new ContextKey(SESSION_INBOX_CONTEXT_KEY),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ContinuationHookTokensKey=new ContextKey(`eve.continuationHookTokens`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),LocalDevRequestKey=new ContextKey(`eve.internal.localDevRequest`),OccurrenceIdKey=new ContextKey(`eve.scheduleOccurrenceId`),ScheduleIdKey=new ContextKey(`eve.scheduleId`),ScheduleInstanceKey=new ContextKey(`eve.scheduleInstance`),SessionTitleKey=new ContextKey(`eve.sessionTitle`),ChannelDeliveryKey=new ContextKey(`eve.channelDelivery`),TurnDeliveryIdsKey=new ContextKey(`eve.turnDeliveryIds`),HistoryStateKey=new ContextKey(`eve.historyState`),OfferedCatalogToolsKey=new ContextKey(`eve.offeredCatalogTools`),ActiveChannelDeliveriesKey=new ContextKey(`eve.activeChannelDeliveries`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ParentSessionKey=new ContextKey(`eve.parentSession`),SessionPredecessorKey=new ContextKey(`eve.sessionPredecessor`),TraceRootKey=new ContextKey(`eve.traceRoot`),ParentTraceContextKey=new ContextKey(`eve.parentTraceContext`),SessionTraceSeedKey=new ContextKey(`eve.sessionTraceSeed`),OtelTraceEnabledKey=new ContextKey(`eve.otelTraceEnabled`),CapabilitiesKey=new ContextKey(`eve.capabilities`),SessionCallbackKey=new ContextKey(SESSION_CALLBACK_CONTEXT_KEY_NAME),LegacyRemoteAgentCallerKey=new ContextKey(`eve.legacyRemoteAgentCaller`),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),SandboxTerminalCleanupKey=new ContextKey(`eve.internal.sandboxTerminalCleanup`),HandleEventKey=new ContextKey(`eve.internal.handleEvent`),StaticModelReferenceKey=new ContextKey(`eve.staticModelReference`),SessionDynamicModelReferenceKey=new ContextKey(`eve.sessionDynamicModelReference`),TurnDynamicModelReferenceKey=new ContextKey(`eve.turnDynamicModelReference`),RuntimeModelMetadataCacheKey=new ContextKey(`eve.runtimeModelMetadataCache`),LiveStepDynamicModelSelectionKey=new ContextKey(`eve.liveStepDynamicModelSelection`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),SessionDynamicToolRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicToolRuntimeRevision`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),TurnMemoryLocksKey=new ContextKey(`eve.memory.turnLocks`),PreparedMemoryPreambleKey=new ContextKey(`eve.memory.preparedPreamble`),PendingMemoryCommitKey=new ContextKey(`eve.memory.pendingCommit`),PreparedMemoryCompactionKey=new ContextKey(`eve.memory.preparedCompaction`),StepDynamicToolMetadataKey=new ContextKey(`eve.stepDynamicToolMetadata`),SessionDynamicSubagentSelectionsKey=new ContextKey(`eve.sessionDynamicSubagentSelections`),TurnDynamicSubagentSelectionsKey=new ContextKey(`eve.turnDynamicSubagentSelections`),SessionDynamicSubagentRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicSubagentRuntimeRevision`),DynamicSubagentAgentConfigKey=new ContextKey(`eve.dynamicSubagentAgentConfig`),AgentSessionRuntimeOverridesKey=new ContextKey(`eve.agentSessionRuntimeOverrides`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),DynamicSkillSandboxKey=new ContextKey(`eve.dynamicSkillSandbox`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`),DynamicInstructionResolveMessagesKey=new ContextKey(`eve.dynamicInstructionResolveMessages`),PendingDynamicInstructionUserMessagesKey=new ContextKey(`eve.pendingDynamicInstructionUserMessages`);export{ActiveChannelDeliveriesKey,AgentSessionRuntimeOverridesKey,AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationHookTokensKey,ContinuationTokenKey,ConversationIdKey,DynamicInstructionResolveMessagesKey,DynamicSkillManifestKey,DynamicSkillSandboxKey,DynamicSubagentAgentConfigKey,HandleEventKey,HistoryStateKey,InitiatorAuthKey,LegacyRemoteAgentCallerKey,LiveStepDynamicModelSelectionKey,LocalDevRequestKey,OccurrenceIdKey,OfferedCatalogToolsKey,OtelTraceEnabledKey,ParentSessionKey,ParentTraceContextKey,PendingDynamicInstructionUserMessagesKey,PendingMemoryCommitKey,PreparedMemoryCompactionKey,PreparedMemoryPreambleKey,RuntimeModelMetadataCacheKey,SandboxKey,SandboxTerminalCleanupKey,ScheduleIdKey,ScheduleInstanceKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicModelReferenceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicSubagentSelectionsKey,SessionDynamicToolMetadataKey,SessionDynamicToolRuntimeRevisionKey,SessionIdKey,SessionInboxKey,SessionKey,SessionPredecessorKey,SessionTitleKey,SessionTraceSeedKey,StaticModelReferenceKey,StepDynamicToolMetadataKey,ToolStubsKey,TraceRootKey,TurnDeliveryIdsKey,TurnDynamicInstructionsKey,TurnDynamicModelReferenceKey,TurnDynamicSubagentSelectionsKey,TurnDynamicToolMetadataKey,TurnMemoryLocksKey};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the per-run state directory for the server `eve eval` starts, after
|
|
3
|
+
* removing directories left by eval runs whose process died before cleanup
|
|
4
|
+
* (Ctrl-C, CI timeouts, crashes). Directories of live concurrent runs stay.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createEvalStateDirectory(appRoot: string, runId: string): Promise<string>;
|
|
7
|
+
export declare function removeEvalStateDirectory(directory: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdir,readFile,readdir,rm,writeFile}from"node:fs/promises";import{join}from"node:path";const OWNER_FILE_NAME=`owner.json`;async function createEvalStateDirectory(e,t){let n=join(e,`.eve`,`eval-servers`);await removeAbandonedEvalStateDirectories(n);let r=join(n,t);return await mkdir(r,{recursive:!0}),await writeFile(join(r,OWNER_FILE_NAME),JSON.stringify({pid:process.pid})),r}async function removeEvalStateDirectory(e){await rm(e,{force:!0,recursive:!0,maxRetries:5,retryDelay:100})}async function removeAbandonedEvalStateDirectories(e){let t;try{t=await readdir(e)}catch{return}await Promise.all(t.map(async t=>{let n=join(e,t),r=await readOwnerPid(n);r===void 0||isProcessAlive(r)||await removeEvalStateDirectory(n).catch(()=>{})}))}async function readOwnerPid(e){try{let t=JSON.parse(await readFile(join(e,OWNER_FILE_NAME),`utf8`));return typeof t.pid==`number`&&Number.isInteger(t.pid)&&t.pid>0?t.pid:void 0}catch{return}}function isProcessAlive(e){try{return process.kill(e,0),!0}catch(e){return e instanceof Error&&`code`in e&&e.code===`EPERM`}}export{createEvalStateDirectory,removeEvalStateDirectory};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{readFile}from"node:fs/promises";import{basename,join}from"node:path";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{noDevelopmentExtensions}from"#compiler/development-extensions.js";import{EVE_EVALUATION_ENV_FLAG,EVE_EVALUATION_RUN_ID_ENV}from"#internal/application/dev-environment.js";import{shutdownActiveSandboxHandles}from"#execution/sandbox/active-handles.js";import{createDevelopmentServer}from"#internal/nitro/host.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{filterEvalsByTags}from"#evals/cli/filter.js";import{discoverAndImportEvals,discoverEvalConfig,findMisplacedEvalDirs}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{Console}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n,r=process.cwd()){await loadDevelopmentEnvironmentFiles(r);let i=e.length>0?e:void 0,a=await discoverAndImportEvals(r,i);if(a.length===0){let e=await findMisplacedEvalDirs(r);e.length>0?n.error(`No evals found under evals/, but eval files are present inside agent/:
|
|
1
|
+
import{randomUUID}from"node:crypto";import{readFile}from"node:fs/promises";import{basename,join}from"node:path";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{noDevelopmentExtensions}from"#compiler/development-extensions.js";import{EVE_DEV_STATE_DIR_ENV,EVE_EVALUATION_ENV_FLAG,EVE_EVALUATION_RUN_ID_ENV}from"#internal/application/dev-environment.js";import{shutdownActiveSandboxHandles}from"#execution/sandbox/active-handles.js";import{createDevelopmentServer}from"#internal/nitro/host.js";import{createEvalClient}from"#evals/cli/eval-client.js";import{createEvalStateDirectory,removeEvalStateDirectory}from"#evals/cli/eval-state-directory.js";import{filterEvalsByTags}from"#evals/cli/filter.js";import{discoverAndImportEvals,discoverEvalConfig,findMisplacedEvalDirs}from"#evals/runner/discover.js";import{runEvals}from"#evals/runner/run-evals.js";import{Console}from"#evals/runner/reporters/console.js";import{JUnit}from"#evals/runner/reporters/junit.js";import{resolveEvalTargetHandle}from"#evals/target.js";async function runEvalCommand(e,t,n,r=process.cwd()){await loadDevelopmentEnvironmentFiles(r);let i=e.length>0?e:void 0,a=await discoverAndImportEvals(r,i);if(a.length===0){let e=await findMisplacedEvalDirs(r);e.length>0?n.error(`No evals found under evals/, but eval files are present inside agent/:
|
|
2
2
|
`+e.map(e=>` - ${e}`).join(`
|
|
3
3
|
`)+`
|
|
4
|
-
eve eval only scans the top-level evals/ directory (a sibling of agent/). Move these files there.`):i?n.error(`No evals found matching: ${i.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let o=t.tag??[],s=t.excludeTag??[],c=filterEvalsByTags({evaluations:a,includeTags:o,excludeTags:[]});if(c.length===0){n.error(`No evals matched the provided tags (${o.join(`, `)}).`),process.exitCode=2;return}let l=filterEvalsByTags({evaluations:c,includeTags:[],excludeTags:s});if(t.list===!0){printEvalList(l,t.json===!0,n);return}if(l.length===0){n.log(`All ${c.length} matching evals are excluded by tags (${s.join(`, `)}); nothing to run.`);return}let u,d;try{u=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),d=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let f;try{f=await discoverEvalConfig(r)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let p,m,h,g;try{if(
|
|
4
|
+
eve eval only scans the top-level evals/ directory (a sibling of agent/). Move these files there.`):i?n.error(`No evals found matching: ${i.join(`, `)}`):n.error(`No evals found. Create files under evals/ with the *.eval.ts extension.`),process.exitCode=2;return}let o=t.tag??[],s=t.excludeTag??[],c=filterEvalsByTags({evaluations:a,includeTags:o,excludeTags:[]});if(c.length===0){n.error(`No evals matched the provided tags (${o.join(`, `)}).`),process.exitCode=2;return}let l=filterEvalsByTags({evaluations:c,includeTags:[],excludeTags:s});if(t.list===!0){printEvalList(l,t.json===!0,n);return}if(l.length===0){n.log(`All ${c.length} matching evals are excluded by tags (${s.join(`, `)}); nothing to run.`);return}let u,d;try{u=parsePositiveInteger(t.maxConcurrency,`--max-concurrency`),d=parseNonNegativeInteger(t.timeout,`--timeout`)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let f;try{f=await discoverEvalConfig(r)}catch(e){n.error(e instanceof Error?e.message:String(e)),process.exitCode=2;return}let p,m,h,g,_;try{if(_=await f.setup?.(),t.url)g=await createEvalClient({kind:`remote`,url:t.url},{workspaceRoot:r}),h=await resolveEvalTargetHandle({client:g,expectedAgentName:await readExpectedAgentName(r),kind:`remote`,url:t.url});else{let e=randomUUID();process.env[EVE_EVALUATION_ENV_FLAG]=`1`,process.env[EVE_EVALUATION_RUN_ID_ENV]=e,m=await createEvalStateDirectory(r,e),process.env[EVE_DEV_STATE_DIR_ENV]=m,p=createDevelopmentServer(r,{developmentExtensions:noDevelopmentExtensions(),host:`127.0.0.1`,port:0});let t=await p.start();g=await createEvalClient({kind:`local`,url:t.url}),h=await resolveEvalTargetHandle({client:g,expectedAgentName:await readExpectedAgentName(r),kind:`local`,url:t.url})}let e=t.json===!0?[]:[Console()];t.junit!==void 0&&e.push(JUnit({filePath:t.junit}));let i=await runEvals({evaluations:l,config:f,setupContext:_,target:h,client:g,appRoot:r,reporters:e,includeEvalReporters:t.skipReport!==!0,maxConcurrency:u,timeoutMs:d,onEvalLog:t.verbose===!0?(e,t)=>n.log(`[${e}] ${t}`):void 0});t.json&&n.log(JSON.stringify(i,null,2));let a=i.failed>0,o=t.strict===!0&&i.scored>0;(a||o)&&(process.exitCode=1)}finally{for(let e of[()=>p?.close(),()=>p&&shutdownActiveSandboxHandles({log:e=>n.error(e)}),()=>m&&removeEvalStateDirectory(m),()=>f.teardown?.(_)])try{await e()}catch(e){n.error(`Eval cleanup failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1}}let v=typeof process.exitCode==`number`?process.exitCode:0;await flushStandardStreams(),process.exit(v)}async function flushStandardStreams(){await Promise.all([flushStream(process.stdout),flushStream(process.stderr)])}async function flushStream(e){await new Promise(t=>{let n=!1,settle=()=>{n||(n=!0,setImmediate(()=>{e.off(`error`,settle),t()}))};e.once(`error`,settle);try{e.write(``,settle)}catch{settle()}})}function parsePositiveInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<1)throw Error(`${t} must be a positive integer; got "${e}".`);return n}function parseNonNegativeInteger(e,t){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0)throw Error(`${t} must be a non-negative integer; got "${e}".`);return n}function printEvalList(e,t,n){if(t){let t=e.map(e=>({id:e.id,description:e.description,tags:e.tags}));n.log(JSON.stringify(t,null,2));return}for(let t of e){let e=t.description===void 0?``:` — ${t.description}`,r=t.tags!==void 0&&t.tags.length>0?` [${t.tags.join(`, `)}]`:``;n.log(`${t.id}${r}${e}`)}}async function readExpectedAgentName(e){try{let t=JSON.parse(await readFile(join(e,`package.json`),`utf8`));return typeof t.name==`string`&&t.name.length>0?t.name:basename(e)}catch{return basename(e)}}export{runEvalCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext}from"#internal/client-context.js";import{createLogger,logError}from"#internal/logging.js";import{FAIL_CLOSED_FORWARDED_TRACE_ASSERTION,formatTraceContentCeiling}from"#shared/forwarded-trace-policy.js";import{EVE_CALLBACK_ROUTE_PATTERN,EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH,EVE_ROUTE_PREFIX,EVE_SESSION_CANCEL_ROUTE_PATTERN,EVE_SESSION_CLEAR_ROUTE_PATTERN,EVE_SESSION_COMPACT_ROUTE_PATTERN,EVE_SESSION_RESET_ROUTE_PATTERN,EVE_SESSION_ROUTE_PATH,EVE_SESSION_ROUTE_PATTERN,EVE_SESSION_STREAM_ROUTE_PATTERN,EVE_SESSION_STUBS_ROUTE_PATTERN,EVE_SUBAGENT_STREAM_ROUTE_PATTERN,createEveSessionStreamRoutePath,createEveSubagentStreamRoutePath}from"#protocol/routes.js";import{EVE_SESSION_ID_HEADER,EVE_STREAM_CONTROL_VERSION_QUERY}from"#protocol/message.js";import{DELETE,GET,HEAD,PATCH,POST,PUT,defineChannel}from"#public/definitions/channel.js";import{readMatchedStubRules,readStubFailure}from"#execution/tool-stubs/steps.js";import{InvalidToolStubTargetError}from"#tool-stubs/validate-targets.js";import{getRun}from"#internal/workflow/runtime.js";import{proxyStreamHeaders}from"#eve-channel/stream-headers.js";import{handleExpiredLegacyAuthorization}from"#execution/legacy-session/authorization.js";import{resolveForwardedPrincipal}from"#channel/forwarded-principal.js";import{handleConnectionCallbackRequest}from"#execution/connections/callback-route.js";import{handleSessionCallbackRequest}from"#subagents/callback-route.js";import{WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest}from"#execution/workflow-webhook-route.js";import{readAgentInfoRouteResponse,readRemoteAgentStreamHeadersResolver,readRouteSessionCreator}from"#internal/nitro/routes/channel-route-context.js";import{legacyTaskInputRoute}from"#execution/legacy-remote-agent/protocol.js";import{parseTraceparent,readAgentDispatchTraceContext}from"#protocol/traceparent.js";import{readForwardedAudienceBaggage,readForwardedParentSessionBaggage}from"#protocol/baggage.js";import{agentDelegation}from"#tracing/eve/delegation.js";import{sessionAuthFromResult}from"#channel/auth/result.js";import{routeAuth}from"#public/channels/auth.js";import{defaultEveAudience}from"#eve-channel/audience.js";import{mergeUploadPolicy}from"#public/channels/upload-policy.js";import{checkUploadPolicy,createSessionStreamResponse,deriveOperationContinuationToken,parseCancelTurnBody,parseCreateBody,parseIncludeTailIndex,parseJsonRequest,parseOptionalJsonRequest,parseResetBody,parseSessionControlBody,parseSessionMessageBody,parseStartIndex,rejectSessionContinuationToken,requireSessionId}from"#eve-channel/request.js";import{findRemoteAgentBinding,healthResponse,normalizeEveCors,resolveOnMessage,resolveTurnClientContext,strandedSessionResponse}from"#eve-channel/support.js";export*from"#eve-channel/types.js";const log=createLogger(`eve.channel`);function createdSessionBody(e,t){let n={ok:!0,sessionId:e,status:`accepted`};return t.protocolVersion!==void 0&&(n.protocolVersion=t.protocolVersion),n}function eveChannel(e){let t=mergeUploadPolicy(e.uploadPolicy);return defineChannel({cors:normalizeEveCors(e.cors),turnPolicy:e.turnPolicy,audience:t=>{let n=e.audience??defaultEveAudience;return typeof n==`function`?n(t):n},routes:[GET(EVE_HEALTH_ROUTE_PATH,async()=>healthResponse()),HEAD(EVE_HEALTH_ROUTE_PATH,async()=>healthResponse()),GET(EVE_INFO_ROUTE_PATH,async(t,n)=>{let r=await routeAuth(t,e.auth);if(r instanceof Response)return r;let i=readAgentInfoRouteResponse(n);return i===void 0?Response.json({error:`Agent info route requires internal channel dispatch context.`,ok:!1},{status:500}):await i()}),GET(`${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`,handleExpiredLegacyAuthorization),POST(`${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`,handleExpiredLegacyAuthorization),GET(EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,handleConnectionCallbackRequest),POST(EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,handleConnectionCallbackRequest),POST(EVE_CALLBACK_ROUTE_PATTERN,handleSessionCallbackRequest),POST(legacyTaskInputRoute.path,legacyTaskInputRoute.handler),GET(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),POST(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),PUT(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),PATCH(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),DELETE(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),POST(EVE_SESSION_ROUTE_PATH,async(n,r)=>{let i=await routeAuth(n,e.auth);if(i instanceof Response)return i;let a=sessionAuthFromResult(i),o=await parseOptionalJsonRequest(n);if(o instanceof Response)return o;if(o.stubs!==void 0&&i.allowToolStubs!==!0)return Response.json({ok:!1,error:`Tool stubbing is not permitted for this caller.`},{status:403});let s=rejectSessionContinuationToken(o);if(s!==null)return s;let c=await resolveForwardedPrincipal({trustedForwarders:e.trustedForwarders,forwarder:a,payload:o});if(c instanceof Response)return c;let l=parseCreateBody(o);if(l instanceof Response)return l;l.callback!==void 0&&l.legacyRemoteAgentCaller!==void 0&&log.info(`serving a remote agent protocol 1 caller`,{callerOrigin:new URL(l.callback.url).origin,forwarder:i.principalId});let u=l.callback===void 0?`absent`:readForwardedParentSessionBaggage(n.headers.get(`baggage`)),d;if(typeof u==`object`){if(u.callId!==l.callback?.callId)log.warn(`ignoring remote parent lineage with a mismatched callback`,{forwarder:i.principalId});else{let t=c.accepted;if(!t&&e.trustedForwarders!==void 0)try{t=await e.trustedForwarders(a,{})}catch(e){let t=logError(log,`trustedForwarders handler failed`,e,{forwarder:i.principalId});return Response.json({error:`trustedForwarders handler failed.`,errorId:t,ok:!1},{status:500})}t?d=u:log.warn(`ignoring remote parent lineage from an untrusted forwarder`,{forwarder:i.principalId})}}else u===`malformed`&&log.warn(`ignoring malformed remote parent lineage`,{forwarder:i.principalId});let f=l.callback===void 0?void 0:parseTraceparent(n.headers.get(`traceparent`)),p=l.callback===void 0?void 0:readAgentDispatchTraceContext(n.headers.get(`tracestate`),f)??f,m=checkUploadPolicy(l,t);if(m!==null)return m;if(l.operationId!==void 0&&c.auth.principalType===`anonymous`)return Response.json({error:`operationId requires an authenticated principal.`,ok:!1},{status:400});let h=l.operationId===void 0?void 0:await deriveOperationContinuationToken({auth:c.auth,operationId:l.operationId});if(h!==void 0){let e=await r.resolveSession(h);if(e!==void 0)return Response.json(createdSessionBody(e.id,l),{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:e.id},status:202})}let g=f===void 0?`absent`:readForwardedAudienceBaggage(n.headers.get(`baggage`)),_=c.accepted&&f!==void 0&&(f.traceFlags&1)==1?typeof g==`object`?g:g===`malformed`?FAIL_CLOSED_FORWARDED_TRACE_ASSERTION:void 0:void 0,v=p;_!==void 0&&p!==void 0&&(v={...p,forwardedTracePolicy:_}),g===`malformed`?log.warn(`using metadata-only policy for malformed forwarded audience baggage`,{forwarder:i.principalId}):typeof g==`object`&&(_===void 0?log.warn(`ignoring forwarded trace policy without an accepted sampled principal`,{forwarder:i.principalId}):log.info(`accepted forwarded trace policy`,{audience:g.originAudience,ceiling:formatTraceContentCeiling(g.ceiling),forwarder:i.principalId}));let y=l.message===void 0?{auth:c.auth,clientContext:resolveTurnClientContext(void 0,l.context)}:await resolveOnMessage({auth:c.auth,clientContext:l.context,config:e,invocation:d===void 0||l.operationId===void 0?void 0:{operationId:l.operationId},message:l.message,request:n});if(y instanceof Response)return y;let b=readRouteSessionCreator(r);if(b===void 0)return Response.json({error:`Session creation requires internal channel dispatch context.`,ok:!1},{status:500});let x;try{x=await agentDelegation.receive({headers:n.headers,delegated:l.callback!==void 0,trusted:c.accepted,parent:d,callerTrace:p,parentTraceContext:v},({conversationId:e,parentTraceContext:t})=>b({audienceAuth:a,toolStubs:l.stubs===void 0?void 0:{rules:l.stubs,token:crypto.randomUUID()},auth:y.auth,capabilities:l.capabilities??{requestInput:!0},callback:l.callback,legacyRemoteAgentCaller:l.legacyRemoteAgentCaller,continuationToken:h,initiatorAuth:c.accepted?c.initiatorAuth:void 0,input:attachClientContext({message:l.message,context:y.context,outputSchema:l.outputSchema},y.clientContext),conversationId:e,parent:d,parentTraceContext:t,traceRoot:d===void 0?void 0:{kind:`own`},title:y.title}))}catch(e){if(e instanceof InvalidToolStubTargetError)return Response.json({error:e.message,ok:!1},{status:400});let t=logError(log,`session-create request failed`,e);return Response.json({error:`Failed to create the session.`,errorId:t,ok:!1},{status:500})}return Response.json(createdSessionBody(x.sessionId,l),{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:x.sessionId},status:202})}),POST(EVE_SESSION_ROUTE_PATTERN,async(n,{attachSession:r,params:i})=>{let a=await routeAuth(n,e.auth);if(a instanceof Response)return a;let o=requireSessionId(i);if(o instanceof Response)return o;let s=await parseJsonRequest(n);if(s instanceof Response)return s;let c=await resolveForwardedPrincipal({trustedForwarders:e.trustedForwarders,forwarder:sessionAuthFromResult(a),payload:s});if(c instanceof Response)return c;let l=parseSessionMessageBody(s);if(l instanceof Response)return l;let u=checkUploadPolicy(l,t);if(u!==null)return u;let d=resolveTurnClientContext(void 0,l.context),f,p,m=c.auth;if(l.message!==void 0){let t=await resolveOnMessage({auth:c.auth,clientContext:l.context,config:e,message:l.message,request:n,sessionId:o});if(t instanceof Response)return t;d=t.clientContext,f=t.context,p=t.title,m=t.auth}let h;try{let e=r(o),t=attachClientContext({auth:m,callback:l.callback,context:f,outputSchema:l.outputSchema,turnPolicy:l.turnPolicy,title:p},d);h=l.inputResponses===void 0?await e.send(l.message,t):await e.respond(l.inputResponses,t)}catch(e){let t=strandedSessionResponse(e);if(t!==void 0)return t;let n=logError(log,`session-message request failed`,e,{sessionId:o});return Response.json({error:`Failed to send the session message.`,errorId:n,ok:!1},{status:500})}return h.status===`accepted`?Response.json({ok:!0,sessionId:h.sessionId,status:`accepted`,deliveryId:h.deliveryId},{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:h.sessionId},status:202}):Response.json({code:h.retryable?`session_not_ready`:`session_not_active`,error:h.retryable===!0?`The session is not ready to accept messages yet.`:`The session is no longer active.`,ok:!1},{headers:{"cache-control":`no-store`},status:409})}),POST(EVE_SESSION_CANCEL_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseCancelTurnBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).cancel({turnId:o.turnId})}catch(e){let t=logError(log,`cancel-turn request failed`,e,{sessionId:a});return Response.json({error:`Failed to cancel the turn.`,errorId:t,ok:!1},{status:500})}return Response.json(s.status===`accepted`?{ok:!0,sessionId:s.sessionId,status:`accepted`}:{ok:!0,status:`no_active_turn`},{headers:{"cache-control":`no-store`},status:s.status===`accepted`?202:200})}),POST(EVE_SESSION_COMPACT_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseSessionControlBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).compact()}catch(e){let t=logError(log,`session-compaction request failed`,e,{sessionId:a});return Response.json({error:`Failed to compact the session.`,errorId:t,ok:!1},{status:500})}return Response.json(s.status===`accepted`?{ok:!0,sessionId:s.sessionId,status:`accepted`}:{ok:!0,status:`no_active_session`},{headers:{"cache-control":`no-store`},status:s.status===`accepted`?202:200})}),POST(EVE_SESSION_CLEAR_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseSessionControlBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).clear()}catch(e){let t=strandedSessionResponse(e);if(t!==void 0)return t;let n=logError(log,`session-clear request failed`,e,{sessionId:a});return Response.json({error:`Failed to clear the session context.`,errorId:n,ok:!1},{status:500})}return Response.json({ok:!0,...s},{headers:{"cache-control":`no-store`},status:s.status===`accepted`?202:200})}),POST(EVE_SESSION_RESET_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseResetBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).reset({reason:o.reason})}catch(e){let t=logError(log,`session-reset request failed`,e,{sessionId:a});return Response.json({error:`Failed to reset the session.`,errorId:t,ok:!1},{status:500})}return Response.json(s.status===`reset`?{ok:!0,previousSessionId:s.previousSessionId,status:`reset`}:{ok:!0,status:`no_active_session`},{headers:{"cache-control":`no-store`}})}),GET(EVE_SESSION_STUBS_ROUTE_PATTERN,async(t,{params:n})=>{let r=await routeAuth(t,e.auth);if(r instanceof Response)return r;if(r.allowToolStubs!==!0)return Response.json({error:`Tool stubbing is not permitted for this caller.`,ok:!1},{status:403});let i=requireSessionId(n);if(i instanceof Response)return i;try{return await getRun(i).exists?Response.json({error:await readStubFailure(i)??null,matchedRuleIds:await readMatchedStubRules(i)},{headers:{"cache-control":`no-store`}}):Response.json({error:`Session not found.`,ok:!1},{status:404})}catch(e){let t=logError(log,`tool-stub verification request failed`,e,{sessionId:i});return Response.json({error:`Failed to verify tool stubs.`,errorId:t,ok:!1},{status:500})}}),GET(EVE_SESSION_STREAM_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);return a instanceof Response?a:await createSessionStreamResponse(t,n(a))}),GET(EVE_SUBAGENT_STREAM_ROUTE_PATTERN,async(t,n)=>{let r=await routeAuth(t,e.auth);if(r instanceof Response)return r;let i=n.params.parentSessionId,a=n.params.callId,o=n.params.childSessionId;if(!i||!a||!o)return Response.json({error:`Missing subagent stream coordinates.`,ok:!1},{status:400});let s=parseStartIndex(t);if(s instanceof Response)return s;let c=parseIncludeTailIndex(t),l=createEveSubagentStreamRoutePath({callId:a,childSessionId:o,parentSessionId:i}),u;try{let e=n.attachSession(i),t=await findRemoteAgentBinding({callId:a,childSessionId:o,childStreamPath:l,parent:e});if(t===void 0)throw Error(`Remote subagent binding not found.`);u=t}catch{return Response.json({error:`Subagent stream not found.`,ok:!1},{status:404})}let d=readRemoteAgentStreamHeadersResolver(n);if(d===void 0)return Response.json({error:`Subagent stream proxy requires internal channel dispatch context.`,ok:!1},{status:500});let f;try{f=await d(u)}catch{return Response.json({error:`Subagent stream not found.`,ok:!1},{status:404})}let p=new URL(createEveSessionStreamRoutePath(o).replace(/^\/+/,``),`${u.url.replace(/\/+$/,``)}/`);s!==void 0&&p.searchParams.set(`startIndex`,String(s));let m=new URL(t.url).searchParams.get(EVE_STREAM_CONTROL_VERSION_QUERY);m!==null&&p.searchParams.set(EVE_STREAM_CONTROL_VERSION_QUERY,m),c&&p.searchParams.set(`includeTailIndex`,`1`);let h=await fetch(p,{cache:`no-store`,headers:f,redirect:`manual`,signal:t.signal}),g=proxyStreamHeaders(h.headers);return new Response(h.body,{headers:g,status:h.status,statusText:h.statusText})})],events:e.events,fetchFile:e.fetchFile,uploadPolicy:e.uploadPolicy})}export{eveChannel};
|
|
1
|
+
import{attachClientContext}from"#internal/client-context.js";import{createLogger,logError}from"#internal/logging.js";import{validateSessionHistory}from"#shared/session-history.js";import{FAIL_CLOSED_FORWARDED_TRACE_ASSERTION,formatTraceContentCeiling}from"#shared/forwarded-trace-policy.js";import{EVE_CALLBACK_ROUTE_PATTERN,EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH,EVE_ROUTE_PREFIX,EVE_SESSION_CANCEL_ROUTE_PATTERN,EVE_SESSION_CLEAR_ROUTE_PATTERN,EVE_SESSION_COMPACT_ROUTE_PATTERN,EVE_SESSION_RESET_ROUTE_PATTERN,EVE_SESSION_ROUTE_PATH,EVE_SESSION_ROUTE_PATTERN,EVE_SESSION_STREAM_ROUTE_PATTERN,EVE_SESSION_STUBS_ROUTE_PATTERN,EVE_SUBAGENT_STREAM_ROUTE_PATTERN,createEveSessionStreamRoutePath,createEveSubagentStreamRoutePath}from"#protocol/routes.js";import{EVE_SESSION_ID_HEADER,EVE_STREAM_CONTROL_VERSION_QUERY}from"#protocol/message.js";import{DELETE,GET,HEAD,PATCH,POST,PUT,defineChannel}from"#public/definitions/channel.js";import{readMatchedStubRules,readStubFailure}from"#execution/tool-stubs/steps.js";import{InvalidToolStubTargetError}from"#tool-stubs/validate-targets.js";import{getRun}from"#internal/workflow/runtime.js";import{proxyStreamHeaders}from"#eve-channel/stream-headers.js";import{handleExpiredLegacyAuthorization}from"#execution/legacy-session/authorization.js";import{resolveForwardedPrincipal}from"#channel/forwarded-principal.js";import{handleConnectionCallbackRequest}from"#execution/connections/callback-route.js";import{handleSessionCallbackRequest}from"#subagents/callback-route.js";import{WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest}from"#execution/workflow-webhook-route.js";import{readAgentInfoRouteResponse,readRemoteAgentStreamHeadersResolver,readRouteSessionCreator}from"#internal/nitro/routes/channel-route-context.js";import{legacyTaskInputRoute}from"#execution/legacy-remote-agent/protocol.js";import{parseTraceparent,readAgentDispatchTraceContext}from"#protocol/traceparent.js";import{readForwardedAudienceBaggage,readForwardedParentSessionBaggage}from"#protocol/baggage.js";import{agentDelegation}from"#tracing/eve/delegation.js";import{sessionAuthFromResult}from"#channel/auth/result.js";import{routeAuth}from"#public/channels/auth.js";import{defaultEveAudience}from"#eve-channel/audience.js";import{mergeUploadPolicy}from"#public/channels/upload-policy.js";import{checkUploadPolicy,createSessionStreamResponse,deriveOperationContinuationToken,parseCancelTurnBody,parseCreateBody,parseIncludeTailIndex,parseJsonRequest,parseOptionalJsonRequest,parseResetBody,parseSessionControlBody,parseSessionMessageBody,parseStartIndex,rejectSessionContinuationToken,requireSessionId}from"#eve-channel/request.js";import{findRemoteAgentBinding,healthResponse,normalizeEveCors,resolveOnMessage,resolveTurnClientContext,strandedSessionResponse}from"#eve-channel/support.js";export*from"#eve-channel/types.js";const log=createLogger(`eve.channel`);function createdSessionBody(e,t){let n={ok:!0,sessionId:e,status:`accepted`};return t.protocolVersion!==void 0&&(n.protocolVersion=t.protocolVersion),n}function eveChannel(e){let t=mergeUploadPolicy(e.uploadPolicy);return defineChannel({cors:normalizeEveCors(e.cors),turnPolicy:e.turnPolicy,audience:t=>{let n=e.audience??defaultEveAudience;return typeof n==`function`?n(t):n},routes:[GET(EVE_HEALTH_ROUTE_PATH,async()=>healthResponse()),HEAD(EVE_HEALTH_ROUTE_PATH,async()=>healthResponse()),GET(EVE_INFO_ROUTE_PATH,async(t,n)=>{let r=await routeAuth(t,e.auth);if(r instanceof Response)return r;let i=readAgentInfoRouteResponse(n);return i===void 0?Response.json({error:`Agent info route requires internal channel dispatch context.`,ok:!1},{status:500}):await i()}),GET(`${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`,handleExpiredLegacyAuthorization),POST(`${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`,handleExpiredLegacyAuthorization),GET(EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,handleConnectionCallbackRequest),POST(EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,handleConnectionCallbackRequest),POST(EVE_CALLBACK_ROUTE_PATTERN,handleSessionCallbackRequest),POST(legacyTaskInputRoute.path,legacyTaskInputRoute.handler),GET(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),POST(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),PUT(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),PATCH(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),DELETE(WORKFLOW_WEBHOOK_ROUTE_PATTERN,handleWorkflowWebhookRequest),POST(EVE_SESSION_ROUTE_PATH,async(n,r)=>{let i=await routeAuth(n,e.auth);if(i instanceof Response)return i;let a=sessionAuthFromResult(i),o=await parseOptionalJsonRequest(n);if(o instanceof Response)return o;if(o.stubs!==void 0&&i.allowToolStubs!==!0)return Response.json({ok:!1,error:`Tool stubbing is not permitted for this caller.`},{status:403});let s=rejectSessionContinuationToken(o);if(s!==null)return s;let c=await resolveForwardedPrincipal({trustedForwarders:e.trustedForwarders,forwarder:a,payload:o});if(c instanceof Response)return c;let l=parseCreateBody(o);if(l instanceof Response)return l;l.callback!==void 0&&l.legacyRemoteAgentCaller!==void 0&&log.info(`serving a remote agent protocol 1 caller`,{callerOrigin:new URL(l.callback.url).origin,forwarder:i.principalId});let u=l.callback===void 0?`absent`:readForwardedParentSessionBaggage(n.headers.get(`baggage`)),d;if(typeof u==`object`){if(u.callId!==l.callback?.callId)log.warn(`ignoring remote parent lineage with a mismatched callback`,{forwarder:i.principalId});else{let t=c.accepted;if(!t&&e.trustedForwarders!==void 0)try{t=await e.trustedForwarders(a,{})}catch(e){let t=logError(log,`trustedForwarders handler failed`,e,{forwarder:i.principalId});return Response.json({error:`trustedForwarders handler failed.`,errorId:t,ok:!1},{status:500})}t?d=u:log.warn(`ignoring remote parent lineage from an untrusted forwarder`,{forwarder:i.principalId})}}else u===`malformed`&&log.warn(`ignoring malformed remote parent lineage`,{forwarder:i.principalId});let f=l.callback===void 0?void 0:parseTraceparent(n.headers.get(`traceparent`)),p=l.callback===void 0?void 0:readAgentDispatchTraceContext(n.headers.get(`tracestate`),f)??f,m=checkUploadPolicy(l,t);if(m!==null)return m;if(l.operationId!==void 0&&c.auth.principalType===`anonymous`)return Response.json({error:`operationId requires an authenticated principal.`,ok:!1},{status:400});let h=l.operationId===void 0?void 0:await deriveOperationContinuationToken({auth:c.auth,operationId:l.operationId});if(h!==void 0){let e=await r.resolveSession(h);if(e!==void 0)return Response.json(createdSessionBody(e.id,l),{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:e.id},status:202})}let g=f===void 0?`absent`:readForwardedAudienceBaggage(n.headers.get(`baggage`)),_=c.accepted&&f!==void 0&&(f.traceFlags&1)==1?typeof g==`object`?g:g===`malformed`?FAIL_CLOSED_FORWARDED_TRACE_ASSERTION:void 0:void 0,v=p;_!==void 0&&p!==void 0&&(v={...p,forwardedTracePolicy:_}),g===`malformed`?log.warn(`using metadata-only policy for malformed forwarded audience baggage`,{forwarder:i.principalId}):typeof g==`object`&&(_===void 0?log.warn(`ignoring forwarded trace policy without an accepted sampled principal`,{forwarder:i.principalId}):log.info(`accepted forwarded trace policy`,{audience:g.originAudience,ceiling:formatTraceContentCeiling(g.ceiling),forwarder:i.principalId}));let y=l.message===void 0?{auth:c.auth,clientContext:resolveTurnClientContext(void 0,l.context)}:await resolveOnMessage({auth:c.auth,clientContext:l.context,config:e,invocation:d===void 0||l.operationId===void 0?void 0:{operationId:l.operationId},message:l.message,request:n});if(y instanceof Response)return y;let b=readRouteSessionCreator(r);if(b===void 0)return Response.json({error:`Session creation requires internal channel dispatch context.`,ok:!1},{status:500});let x;try{x=await agentDelegation.receive({headers:n.headers,delegated:l.callback!==void 0,trusted:c.accepted,parent:d,callerTrace:p,parentTraceContext:v},({conversationId:e,parentTraceContext:t})=>b({audienceAuth:a,toolStubs:l.stubs===void 0?void 0:{rules:l.stubs,token:crypto.randomUUID()},auth:y.auth,capabilities:l.capabilities??{requestInput:!0},callback:l.callback,legacyRemoteAgentCaller:l.legacyRemoteAgentCaller,continuationToken:h,initiatorAuth:c.accepted?c.initiatorAuth:void 0,input:attachClientContext({message:l.message,context:y.context,history:validateSessionHistory(`history`in y?y.history:void 0),outputSchema:l.outputSchema},y.clientContext),conversationId:e,parent:d,parentTraceContext:t,traceRoot:d===void 0?void 0:{kind:`own`},title:y.title}))}catch(e){if(e instanceof InvalidToolStubTargetError)return Response.json({error:e.message,ok:!1},{status:400});let t=logError(log,`session-create request failed`,e);return Response.json({error:`Failed to create the session.`,errorId:t,ok:!1},{status:500})}return Response.json(createdSessionBody(x.sessionId,l),{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:x.sessionId},status:202})}),POST(EVE_SESSION_ROUTE_PATTERN,async(n,{attachSession:r,params:i})=>{let a=await routeAuth(n,e.auth);if(a instanceof Response)return a;let o=requireSessionId(i);if(o instanceof Response)return o;let s=await parseJsonRequest(n);if(s instanceof Response)return s;let c=await resolveForwardedPrincipal({trustedForwarders:e.trustedForwarders,forwarder:sessionAuthFromResult(a),payload:s});if(c instanceof Response)return c;let l=parseSessionMessageBody(s);if(l instanceof Response)return l;let u=checkUploadPolicy(l,t);if(u!==null)return u;let d=resolveTurnClientContext(void 0,l.context),f,p,m,h=c.auth;if(l.message!==void 0){let t=await resolveOnMessage({auth:c.auth,clientContext:l.context,config:e,message:l.message,request:n,sessionId:o});if(t instanceof Response)return t;d=t.clientContext,f=t.context,p=t.history,m=t.title,h=t.auth}let g;try{let e=r(o),t=attachClientContext({auth:h,callback:l.callback,context:f,history:p,outputSchema:l.outputSchema,turnPolicy:l.turnPolicy,title:m},d);g=l.inputResponses===void 0?await e.send(l.message,t):await e.respond(l.inputResponses,t)}catch(e){let t=strandedSessionResponse(e);if(t!==void 0)return t;let n=logError(log,`session-message request failed`,e,{sessionId:o});return Response.json({error:`Failed to send the session message.`,errorId:n,ok:!1},{status:500})}return g.status===`accepted`?Response.json({ok:!0,sessionId:g.sessionId,status:`accepted`,deliveryId:g.deliveryId},{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:g.sessionId},status:202}):Response.json({code:g.retryable?`session_not_ready`:`session_not_active`,error:g.retryable===!0?`The session is not ready to accept messages yet.`:`The session is no longer active.`,ok:!1},{headers:{"cache-control":`no-store`},status:409})}),POST(EVE_SESSION_CANCEL_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseCancelTurnBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).cancel({turnId:o.turnId})}catch(e){let t=logError(log,`cancel-turn request failed`,e,{sessionId:a});return Response.json({error:`Failed to cancel the turn.`,errorId:t,ok:!1},{status:500})}return Response.json(s.status===`accepted`?{ok:!0,sessionId:s.sessionId,status:`accepted`}:{ok:!0,status:`no_active_turn`},{headers:{"cache-control":`no-store`},status:s.status===`accepted`?202:200})}),POST(EVE_SESSION_COMPACT_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseSessionControlBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).compact()}catch(e){let t=logError(log,`session-compaction request failed`,e,{sessionId:a});return Response.json({error:`Failed to compact the session.`,errorId:t,ok:!1},{status:500})}return Response.json(s.status===`accepted`?{ok:!0,sessionId:s.sessionId,status:`accepted`}:{ok:!0,status:`no_active_session`},{headers:{"cache-control":`no-store`},status:s.status===`accepted`?202:200})}),POST(EVE_SESSION_CLEAR_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseSessionControlBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).clear()}catch(e){let t=strandedSessionResponse(e);if(t!==void 0)return t;let n=logError(log,`session-clear request failed`,e,{sessionId:a});return Response.json({error:`Failed to clear the session context.`,errorId:n,ok:!1},{status:500})}return Response.json({ok:!0,...s},{headers:{"cache-control":`no-store`},status:s.status===`accepted`?202:200})}),POST(EVE_SESSION_RESET_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);if(a instanceof Response)return a;let o=await parseResetBody(t);if(o instanceof Response)return o;let s;try{s=await n(a).reset({reason:o.reason})}catch(e){let t=logError(log,`session-reset request failed`,e,{sessionId:a});return Response.json({error:`Failed to reset the session.`,errorId:t,ok:!1},{status:500})}return Response.json(s.status===`reset`?{ok:!0,previousSessionId:s.previousSessionId,status:`reset`}:{ok:!0,status:`no_active_session`},{headers:{"cache-control":`no-store`}})}),GET(EVE_SESSION_STUBS_ROUTE_PATTERN,async(t,{params:n})=>{let r=await routeAuth(t,e.auth);if(r instanceof Response)return r;if(r.allowToolStubs!==!0)return Response.json({error:`Tool stubbing is not permitted for this caller.`,ok:!1},{status:403});let i=requireSessionId(n);if(i instanceof Response)return i;try{return await getRun(i).exists?Response.json({error:await readStubFailure(i)??null,matchedRuleIds:await readMatchedStubRules(i)},{headers:{"cache-control":`no-store`}}):Response.json({error:`Session not found.`,ok:!1},{status:404})}catch(e){let t=logError(log,`tool-stub verification request failed`,e,{sessionId:i});return Response.json({error:`Failed to verify tool stubs.`,errorId:t,ok:!1},{status:500})}}),GET(EVE_SESSION_STREAM_ROUTE_PATTERN,async(t,{attachSession:n,params:r})=>{let i=await routeAuth(t,e.auth);if(i instanceof Response)return i;let a=requireSessionId(r);return a instanceof Response?a:await createSessionStreamResponse(t,n(a))}),GET(EVE_SUBAGENT_STREAM_ROUTE_PATTERN,async(t,n)=>{let r=await routeAuth(t,e.auth);if(r instanceof Response)return r;let i=n.params.parentSessionId,a=n.params.callId,o=n.params.childSessionId;if(!i||!a||!o)return Response.json({error:`Missing subagent stream coordinates.`,ok:!1},{status:400});let s=parseStartIndex(t);if(s instanceof Response)return s;let c=parseIncludeTailIndex(t),l=createEveSubagentStreamRoutePath({callId:a,childSessionId:o,parentSessionId:i}),u;try{let e=n.attachSession(i),t=await findRemoteAgentBinding({callId:a,childSessionId:o,childStreamPath:l,parent:e});if(t===void 0)throw Error(`Remote subagent binding not found.`);u=t}catch{return Response.json({error:`Subagent stream not found.`,ok:!1},{status:404})}let d=readRemoteAgentStreamHeadersResolver(n);if(d===void 0)return Response.json({error:`Subagent stream proxy requires internal channel dispatch context.`,ok:!1},{status:500});let f;try{f=await d(u)}catch{return Response.json({error:`Subagent stream not found.`,ok:!1},{status:404})}let p=new URL(createEveSessionStreamRoutePath(o).replace(/^\/+/,``),`${u.url.replace(/\/+$/,``)}/`);s!==void 0&&p.searchParams.set(`startIndex`,String(s));let m=new URL(t.url).searchParams.get(EVE_STREAM_CONTROL_VERSION_QUERY);m!==null&&p.searchParams.set(EVE_STREAM_CONTROL_VERSION_QUERY,m),c&&p.searchParams.set(`includeTailIndex`,`1`);let h=await fetch(p,{cache:`no-store`,headers:f,redirect:`manual`,signal:t.signal}),g=proxyStreamHeaders(h.headers);return new Response(h.body,{headers:g,status:h.status,statusText:h.statusText})})],events:e.events,fetchFile:e.fetchFile,uploadPolicy:e.uploadPolicy})}export{eveChannel};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UserContent } from "ai";
|
|
2
2
|
import type { SessionAuthContext } from "#channel/types.js";
|
|
3
|
+
import type { SessionHistoryMessage } from "#shared/session-history.js";
|
|
3
4
|
import type { MessageStreamEvent } from "#protocol/message.js";
|
|
4
5
|
import type { ChannelCors } from "#public/definitions/channel.js";
|
|
5
6
|
import { type ClientContextValue, type EveChannelCors, type EveChannelInput, type EveHandle } from "#eve-channel/types.js";
|
|
@@ -33,6 +34,7 @@ interface OnMessageOutcome {
|
|
|
33
34
|
/** Model-ready turn context: `onMessage`'s replacement, or the request's labeled entries. */
|
|
34
35
|
readonly clientContext?: readonly string[];
|
|
35
36
|
readonly context?: readonly string[];
|
|
37
|
+
readonly history?: readonly SessionHistoryMessage[];
|
|
36
38
|
readonly title?: string;
|
|
37
39
|
}
|
|
38
40
|
export declare function resolveOnMessage(input: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{SessionStrandedError}from"#channel/session-stranded-error.js";import{defaultEveAuth}from"#eve-channel/types.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";const log=createLogger(`eve.channel`);function healthResponse(){return Response.json({ok:!0,status:`ready`,workflowId:workflowEntryReference.workflowId})}function strandedSessionResponse(e){if(!SessionStrandedError.is(e))return;let t={code:`session_stranded`,error:`This session is no longer available.`,ok:!1};return e.owner.eveVersion!==void 0&&(t.eveVersion=e.owner.eveVersion),Response.json(t,{headers:{"cache-control":`no-store`},status:409})}async function findRemoteAgentBinding(e){let t=await e.parent.getStreamTailIndex();if(t<0)return;let n=(await e.parent.getEventStream({startIndex:0})).getReader();try{for(let r=0;r<=t;r+=1){let t=await n.read();if(t.done)break;let r=readRemoteAgentBinding(t.value,e);if(r!==void 0)return r}}finally{await n.cancel().catch(()=>{})}}function readRemoteAgentBinding(e,t){if(e.type!==`agent.started`)return;let{data:n}=e;if(n.callId===t.callId&&n.sessionId===t.childSessionId&&n.streamPath===t.childStreamPath&&n.remote!==void 0)return{name:n.name,...n.remote}}function normalizeEveCors(e){if(e===void 0||e===!1)return!1;if(e===!0)return!0;let t={};return e.origin!==void 0&&(t.origin=normalizeEveCorsOrigin(e.origin)),e.methods!==void 0&&(t.methods=e.methods),e.allowedHeaders!==void 0&&(t.allowHeaders=e.allowedHeaders),e.exposedHeaders!==void 0&&(t.exposeHeaders=e.exposedHeaders),e.credentials!==void 0&&(t.credentials=e.credentials),e.maxAge!==void 0&&(t.maxAge=e.maxAge),e.preflightStatus!==void 0&&(t.preflight={statusCode:e.preflightStatus}),t}function normalizeEveCorsOrigin(e){return e===`*`||e===`null`?e:typeof e==`string`?[e]:e}async function resolveOnMessage(e){let t=e.config.onMessage??defaultOnMessage,n;try{let r={caller:e.auth,clientContext:e.clientContext,request:e.request};if(n=await t({eve:e.sessionId===void 0?e.invocation===void 0?r:{...r,invocation:e.invocation}:{...r,sessionId:e.sessionId}},e.message),n==null)throw TypeError(`eveChannel onMessage must return an auth result.`)}catch(t){let n=logError(log,`onMessage handler failed`,t,{sessionId:e.sessionId});return Response.json({error:`onMessage handler failed.`,errorId:n,ok:!1},{status:500})}return{auth:n.auth,clientContext:resolveTurnClientContext(n.clientContext,e.clientContext),context:n.context,title:n.title}}function resolveTurnClientContext(e,t){let n=e===void 0?toContextEntries(t).map(e=>`Client context:
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{SessionStrandedError}from"#channel/session-stranded-error.js";import{defaultEveAuth}from"#eve-channel/types.js";import{workflowEntryReference}from"#execution/workflow-runtime.js";const log=createLogger(`eve.channel`);function healthResponse(){return Response.json({ok:!0,status:`ready`,workflowId:workflowEntryReference.workflowId})}function strandedSessionResponse(e){if(!SessionStrandedError.is(e))return;let t={code:`session_stranded`,error:`This session is no longer available.`,ok:!1};return e.owner.eveVersion!==void 0&&(t.eveVersion=e.owner.eveVersion),Response.json(t,{headers:{"cache-control":`no-store`},status:409})}async function findRemoteAgentBinding(e){let t=await e.parent.getStreamTailIndex();if(t<0)return;let n=(await e.parent.getEventStream({startIndex:0})).getReader();try{for(let r=0;r<=t;r+=1){let t=await n.read();if(t.done)break;let r=readRemoteAgentBinding(t.value,e);if(r!==void 0)return r}}finally{await n.cancel().catch(()=>{})}}function readRemoteAgentBinding(e,t){if(e.type!==`agent.started`)return;let{data:n}=e;if(n.callId===t.callId&&n.sessionId===t.childSessionId&&n.streamPath===t.childStreamPath&&n.remote!==void 0)return{name:n.name,...n.remote}}function normalizeEveCors(e){if(e===void 0||e===!1)return!1;if(e===!0)return!0;let t={};return e.origin!==void 0&&(t.origin=normalizeEveCorsOrigin(e.origin)),e.methods!==void 0&&(t.methods=e.methods),e.allowedHeaders!==void 0&&(t.allowHeaders=e.allowedHeaders),e.exposedHeaders!==void 0&&(t.exposeHeaders=e.exposedHeaders),e.credentials!==void 0&&(t.credentials=e.credentials),e.maxAge!==void 0&&(t.maxAge=e.maxAge),e.preflightStatus!==void 0&&(t.preflight={statusCode:e.preflightStatus}),t}function normalizeEveCorsOrigin(e){return e===`*`||e===`null`?e:typeof e==`string`?[e]:e}async function resolveOnMessage(e){let t=e.config.onMessage??defaultOnMessage,n;try{let r={caller:e.auth,clientContext:e.clientContext,request:e.request};if(n=await t({eve:e.sessionId===void 0?e.invocation===void 0?r:{...r,invocation:e.invocation}:{...r,sessionId:e.sessionId}},e.message),n==null)throw TypeError(`eveChannel onMessage must return an auth result.`)}catch(t){let n=logError(log,`onMessage handler failed`,t,{sessionId:e.sessionId});return Response.json({error:`onMessage handler failed.`,errorId:n,ok:!1},{status:500})}return{auth:n.auth,clientContext:resolveTurnClientContext(n.clientContext,e.clientContext),context:n.context,history:n.history,title:n.title}}function resolveTurnClientContext(e,t){let n=e===void 0?toContextEntries(t).map(e=>`Client context:
|
|
2
2
|
${e}`):toContextEntries(e);return n.length===0?void 0:n}function toContextEntries(e){return e===void 0||e===``?[]:typeof e==`string`?[e]:Array.isArray(e)?e:[JSON.stringify(e)]}function defaultOnMessage(e){return{auth:defaultEveAuth(e)}}export{findRemoteAgentBinding,healthResponse,normalizeEveCors,resolveOnMessage,resolveTurnClientContext,strandedSessionResponse};
|
|
@@ -7,6 +7,7 @@ import type { FetchFileFunction } from "#shared/channel-definition.js";
|
|
|
7
7
|
import type { JsonObject } from "#shared/json.js";
|
|
8
8
|
import type { AudienceContext, Channel, ChannelContinuationOps, ChannelEvents, ChannelMethod } from "#public/definitions/channel.js";
|
|
9
9
|
import type { ChannelAudience } from "#shared/channel-audience.js";
|
|
10
|
+
import type { SessionHistoryMessage } from "#shared/session-history.js";
|
|
10
11
|
export type { ForwardedAssertion, TrustedForwarders } from "#channel/forwarded-principal.js";
|
|
11
12
|
/**
|
|
12
13
|
* Event-handler channel context exposed by `eveChannel({ events })`. The default eve HTTP channel
|
|
@@ -80,6 +81,12 @@ export type EveMessageResult = {
|
|
|
80
81
|
* context; omit it to keep the request's context.
|
|
81
82
|
*/
|
|
82
83
|
readonly clientContext?: ClientContextValue;
|
|
84
|
+
/**
|
|
85
|
+
* Prior conversation added as user and assistant turns before this message.
|
|
86
|
+
* Resolve it on the server and authorize the caller against the stored
|
|
87
|
+
* conversation.
|
|
88
|
+
*/
|
|
89
|
+
readonly history?: readonly SessionHistoryMessage[];
|
|
83
90
|
/** Sets the title when creating a workflow or sending its first message after prewarming. */
|
|
84
91
|
readonly title?: string;
|
|
85
92
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChannelInstrumentationProjection,
|
|
1
|
+
import type { ChannelInstrumentationProjection, SessionCapabilities, SessionParent, SessionTraceRoot } from "#channel/types.js";
|
|
2
2
|
import type { LocalDevRequestProvenance } from "#context/keys.js";
|
|
3
3
|
import { type StubScope } from "#tool-stubs/types.js";
|
|
4
4
|
import { type SessionSchedule } from "#context/session-schedule.js";
|
|
@@ -31,8 +31,6 @@ export interface AgentSessionContext {
|
|
|
31
31
|
readonly conversation?: ConversationContext;
|
|
32
32
|
/** Dynamic agents the calling turn selected, by node id. */
|
|
33
33
|
readonly dynamicSelections: DynamicSubagentSelections;
|
|
34
|
-
/** The token budget each session inherits: its share of the caller's remaining quota. */
|
|
35
|
-
readonly limits: RunSessionLimits;
|
|
36
34
|
readonly localDevRequest?: LocalDevRequestProvenance;
|
|
37
35
|
/** The calling session, turn, and tool call, recorded as each session's lineage. */
|
|
38
36
|
readonly parent: SessionParent;
|
|
@@ -52,15 +50,6 @@ export interface AgentSessionSandbox {
|
|
|
52
50
|
readonly state?: SandboxState;
|
|
53
51
|
}
|
|
54
52
|
type CallerDispatch = Pick<PreparedCoordinationDispatch<unknown>, "batch" | "bundle" | "capabilities" | "channelMetadata" | "dynamicSubagentSelections" | "inheritedConversation" | "localDevRequest" | "sandboxSessionId" | "serializedContext" | "session" | "traceRoot" | "workflowAgents">;
|
|
55
|
-
/**
|
|
56
|
-
* The token budget every session a model step's calls open inherits: the
|
|
57
|
-
* caller's remaining quota split evenly across the agent tasks the step
|
|
58
|
-
* starts, local or remote, so those tasks are bounded by the remainder
|
|
59
|
-
* together. Sessions a workflow tool opens with `ctx.agent` get the same
|
|
60
|
-
* share without dividing it further. A call to a running task starts none,
|
|
61
|
-
* so it takes no share.
|
|
62
|
-
*/
|
|
63
|
-
export declare function resolveStepAgentLimits(caller: Pick<PreparedCoordinationDispatch, "plan" | "session">): RunSessionLimits;
|
|
64
53
|
/** Captures the agent session context for one workflow tool call, in the step that admits it. */
|
|
65
|
-
export declare function captureAgentSessionContext(caller: CallerDispatch, callId: string
|
|
54
|
+
export declare function captureAgentSessionContext(caller: CallerDispatch, callId: string): AgentSessionContext;
|
|
66
55
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readSerializedSessionSchedule}from"#context/session-schedule.js";import{STUB_CONTEXT_KEY}from"#tool-stubs/types.js";import{serializeDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{
|
|
1
|
+
import{readSerializedSessionSchedule}from"#context/session-schedule.js";import{STUB_CONTEXT_KEY}from"#tool-stubs/types.js";import{serializeDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{resolveToolCallAgentTrace}from"#tracing/eve/agent-invocation-coordinator.js";function captureAgentSessionContext(e,t){let{batch:n,session:r}=e;return{agents:e.workflowAgents,toolStubs:e.serializedContext[STUB_CONTEXT_KEY],bundle:{nodeId:e.bundle.nodeId,source:serializeDurableCompiledArtifactsSource(e.bundle.compiledArtifactsSource)},capabilities:e.capabilities,schedule:readSerializedSessionSchedule(e.serializedContext),channelMetadata:e.channelMetadata,conversation:e.inheritedConversation,dynamicSelections:e.dynamicSubagentSelections,localDevRequest:e.localDevRequest,parent:{callId:t,rootSessionId:r.rootSessionId??r.sessionId,sessionId:r.sessionId,turn:{id:n.event.turnId,sequence:n.event.sequence}},sandbox:{sessionId:e.sandboxSessionId,state:r.sandboxState},traceRoot:e.traceRoot,trace:resolveToolCallAgentTrace({callId:t,conversation:e.inheritedConversation,serializedContext:e.serializedContext,sessionId:r.sessionId,turnId:n.event.turnId})}}export{captureAgentSessionContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RunUsageTally } from "#execution/agent-sessions/usage.js";
|
|
2
2
|
import type { WorkflowToolRunContext } from "#execution/tools/workflow/ask.js";
|
|
3
|
-
import type { AgentSession } from "#tools/workflow-definition.js";
|
|
3
|
+
import type { AgentSession, AgentSessionOptions } from "#tools/workflow-definition.js";
|
|
4
4
|
/**
|
|
5
5
|
* Opens `ctx.agent` sessions for a workflow run. A handle's position in the
|
|
6
6
|
* run names its session, so replay reaches the same one, and `close` ends
|
|
@@ -8,5 +8,5 @@ import type { AgentSession } from "#tools/workflow-definition.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function createAgentSessions(run: WorkflowToolRunContext, usage: RunUsageTally): {
|
|
10
10
|
readonly close: () => Promise<void>;
|
|
11
|
-
readonly open: (name: string) => AgentSession;
|
|
11
|
+
readonly open: (name: string, options?: AgentSessionOptions) => AgentSession;
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toErrorMessage}from"#shared/errors.js";import{createHook}from"#compiled/@workflow/core/index.js";import{normalizeRequestedOutputSchema}from"#subagents/invocation.js";import{forwardAgentSessionRequest}from"#execution/agent-sessions/requests.js";import{cancelAgentSessionTurnStep,endAgentSessionsStep,openAgentSessionStep,sendAgentSessionMessageStep}from"#execution/agent-sessions/steps.js";import{disposeHook}from"#execution/hook-ownership.js";import{serializeOutputSchema}from"#tools/schema-emission.js";function createAgentSessions(e,t){let n=[],r=0;return{open:i=>{if(typeof i!=`string`||i.trim()===``)throw TypeError(`ctx.agent() requires a non-empty agent name.`);let
|
|
1
|
+
import{toErrorMessage}from"#shared/errors.js";import{createHook}from"#compiled/@workflow/core/index.js";import{normalizeRequestedOutputSchema}from"#subagents/invocation.js";import{forwardAgentSessionRequest}from"#execution/agent-sessions/requests.js";import{cancelAgentSessionTurnStep,endAgentSessionsStep,openAgentSessionStep,sendAgentSessionMessageStep}from"#execution/agent-sessions/steps.js";import{disposeHook}from"#execution/hook-ownership.js";import{serializeOutputSchema}from"#tools/schema-emission.js";function createAgentSessions(e,t){let n=[],r=0;return{open:(i,a={})=>{if(typeof i!=`string`||i.trim()===``)throw TypeError(`ctx.agent() requires a non-empty agent name.`);let o=`${e.from.runId}:${String(r)}`;return r+=1,new RunAgentSession({key:o,name:i,options:a,run:e,sessions:n,usage:t})},close:async()=>{n.length!==0&&await endAgentSessionsStep({sessions:n})}}}var RunAgentSession=class{#e;#t;#n;#r;#i;#a;#o;#s=[];constructor(e){this.#e=e.key,this.#t=e.name,this.#n=e.options,this.#r=e.run,this.#i=e.sessions,this.#a=e.usage}async send(e,t={}){if(typeof e!=`string`||e.trim()===``)throw TypeError(`ctx.agent("${this.#t}").send() requires a non-empty message.`);let n=normalizeRequestedOutputSchema(serializeOutputSchema(t.outputSchema)),r=this.#c(n!==void 0);try{await this.#d({auth:this.#r.auth,message:e,outputSchema:n,replyTo:r.hook.token})}catch(e){throw this.#s.splice(this.#s.indexOf(r),1),await releaseHook(r.hook),e}return t.signal!==void 0&&this.#p(r,t.signal),{result:()=>r.ended.then(unwrapTurnEnd)}}#c(e){let t=createHook(),settle=()=>{},n={ended:new Promise(e=>{settle=e}),hook:t,settle};return this.#s.push(n),this.#l(t,e).then(e=>this.#u(n,e)),n}async#l(e,t){try{for await(let n of e){if(n.kind!==`runtime-action-result`){await forwardAgentSessionRequest({from:this.#r.from,owner:this.#r.owner,replyTo:e.token,request:n,remote:this.#o===void 0?void 0:await this.#o.then(({address:e})=>e.kind===`remote`?{forwardPrincipal:e.forwardPrincipal,name:e.name,resolverId:e.resolverId,url:e.url,sessionId:e.sessionId}:void 0)});continue}let r=n.results.find(e=>e.kind===`subagent-result`);if(r!==void 0)return r.origin===`child`&&this.#a.record(r.outcome.usageDelta),{kind:`ended`,result:toAgentMessageResult(r,t)}}return{error:Error(`Agent "${this.#t}" stopped reporting before its turn ended.`),kind:`failed`}}catch(e){return{error:e,kind:`failed`}}}async#u(e,t){let n=this.#s.indexOf(e);if(!(n<0))for(let e of this.#s.splice(0,n+1))e.settle(t),await releaseHook(e.hook)}async#d(e){if(this.#o===void 0){this.#o=this.#f(e),await this.#o;return}let t=await this.#o;await sendAgentSessionMessageStep({...e,...t})}async#f(e){let{agentContext:t,from:n}=this.#r;try{let r=await openAgentSessionStep({...e,context:t,key:this.#e,model:this.#n.model,name:this.#t}),i={address:r,context:t,key:this.#e};return this.#i.push(i),await this.#r.owner.send({from:n,kind:`agent-started`,session:r}),i}catch(e){throw this.#o=void 0,e}}#p(e,t){let cancel=()=>{this.#s.includes(e)&&this.#o!==void 0&&this.#o.then(e=>cancelAgentSessionTurnStep(e)).catch(()=>{})};if(t.aborted){cancel();return}t.addEventListener(`abort`,cancel,{once:!0})}};async function releaseHook(e){try{await disposeHook(e)}catch{}}function unwrapTurnEnd(e){if(e.kind===`failed`)throw e.error;return e.result}const NO_REPLY={data:void 0,message:void 0};function failedTurn(e){return{...NO_REPLY,error:{message:toErrorMessage(e)},status:`failed`}}function toAgentMessageResult(e,t){if(e.origin!==`child`)return failedTurn(e.output);let{outcome:n}=e;switch(n.result.kind){case`failed`:return failedTurn(n.result.error);case`cancelled`:return{...NO_REPLY,status:`waiting`};case`succeeded`:{let{output:e}=n.result,r=n.kind===`terminal`?`completed`:`waiting`;return t?{data:e,message:void 0,status:r}:{data:void 0,message:typeof e==`string`?e:void 0,status:r}}}}export{createAgentSessions};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SessionAuth } from "#context/session-context.js";
|
|
2
2
|
import type { AgentSessionContext } from "#execution/agent-sessions/context.js";
|
|
3
3
|
import type { JsonObject } from "#shared/json.js";
|
|
4
|
+
import type { AgentSessionModelSelection } from "#tools/workflow-definition.js";
|
|
4
5
|
/** Where a session a run opened lives, for its later sends, cancels, and end. */
|
|
5
6
|
export type AgentSessionAddress = {
|
|
6
7
|
readonly kind: "local";
|
|
@@ -46,6 +47,7 @@ export interface AgentSessionMessage {
|
|
|
46
47
|
export declare function openAgentSessionStep(input: AgentSessionMessage & {
|
|
47
48
|
readonly context: AgentSessionContext;
|
|
48
49
|
readonly key: string;
|
|
50
|
+
readonly model?: AgentSessionModelSelection;
|
|
49
51
|
readonly name: string;
|
|
50
52
|
}): Promise<AgentSessionAddress>;
|
|
51
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{sessionInboxHookToken}from"#execution/session-inbox/address.js";import{ContextContainer,contextStorage}from"#context/container.js";import{createEveCallbackRoutePath}from"#protocol/routes.js";import{
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{SessionStrandedError}from"#channel/session-stranded-error.js";import{sessionInboxHookToken}from"#execution/session-inbox/address.js";import{ContextContainer,contextStorage}from"#context/container.js";import{createEveCallbackRoutePath}from"#protocol/routes.js";import{toErrorMessage}from"#shared/errors.js";import{InvalidRuntimeModelSelectionError,resolveRuntimeModelSelection}from"#runtime/agent/resolve-model.js";import{agentDelegation}from"#tracing/eve/delegation.js";import{createWorkflowRuntime,dispatchWorkflowSessionCommand,resolveContinuation,waitForCommandHookOwner,waitForSessionInbox}from"#execution/workflow-runtime.js";import{resolveDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{FatalError,getStepMetadata,getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{createWorkflowCallbackUrl,resolveWorkflowCallbackBaseUrl}from"#execution/workflow-callback-url.js";import{resolveAgentAction,resolveAgentStartTarget}from"#execution/agent-sessions/target.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{cancelRemoteAgentTurn,continueRemoteAgentSession,resetRemoteAgentSession,resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/agent-sessions/remote.js";import{buildSubagentRunInput}from"#subagents/tool.js";import{resolveConversationId}from"#shared/conversation-identity.js";import{stubToolPath}from"#tool-stubs/target.js";const log=createLogger(`execution.agent-sessions`),RUN_FINISHED_REASON=`The workflow run that opened this session finished.`;async function openAgentSessionStep(e){"use step";let{context:t}=e,n=await loadAgentSessionBundle(t),r=resolveAgentAction({bundle:n,callId:t.parent.callId,dynamicSelections:t.dynamicSelections,input:{message:e.message,outputSchema:e.outputSchema,target:e.name}}),i=resolveAgentStartTarget({action:r,bundle:n,dynamicSelections:t.dynamicSelections,isRootSession:t.parent.rootSessionId===t.parent.sessionId});if(e.model!==void 0&&i.kind===`remote`)throw new FatalError(`ctx.agent("${e.name}", { model }) cannot override a remote agent's model. Configure the model on the receiving agent.`);let a=e.model===void 0?void 0:await normalizeRuntimeOverrides(e.name,e.model),o={auth:e.auth,bundle:n,context:t,key:e.key,replyTo:e.replyTo,runtimeOverrides:a};return await agentDelegation.resume({context:t,agentName:r.name},()=>i.kind===`remote`?startRemoteSession({...o,target:i}):startLocalSession({...o,target:i}))}async function normalizeRuntimeOverrides(e,t){try{return{model:(await resolveRuntimeModelSelection({durability:`durable`,selection:t,state:new ContextContainer})).reference}}catch(t){throw t instanceof InvalidRuntimeModelSelectionError?new FatalError(`ctx.agent("${e}", { model }) could not resolve the model selection: ${toErrorMessage(t)}`):t}}async function sendAgentSessionMessageStep(e){"use step";let{address:t,context:n}=e;if(t.kind===`remote`){let r=await resolveSessionRemote(n,t);await continueRemoteAgentSession({auth:e.auth.current,callback:{callId:n.parent.callId,subagentName:t.name,token:e.replyTo,url:createWorkflowCallbackUrl(t.callbackBaseUrl,createEveCallbackRoutePath(e.replyTo))},message:e.message,outputSchema:e.outputSchema,remote:r,sessionId:t.sessionId});return}if((await commandLocalSession({...e,address:t},{auth:e.auth.current,schedule:n.schedule,caller:{callId:n.parent.callId,replyTo:{kind:`hook`,token:e.replyTo},subagentName:t.name},kind:`send`,payload:{message:e.message,outputSchema:e.outputSchema}}).catch(e=>{throw SessionStrandedError.is(e)?Error(`Agent "${t.name}" can no longer receive messages: ${e.message}`,{cause:e}):e})).status!==`accepted`)throw Error(`Agent "${t.name}" can no longer receive messages; its session ended.`)}async function cancelAgentSessionTurnStep(e){"use step";let{address:t}=e;try{if(t.kind===`remote`){let n=await resolveSessionRemote(e.context,t);await cancelRemoteAgentTurn({remote:n,sessionId:t.sessionId});return}await commandLocalSession({...e,address:t},{kind:`cancel`})}catch(e){logError(log,`failed to cancel an agent session turn`,e,{name:t.name,sessionId:t.sessionId})}}async function endAgentSessionsStep(e){"use step";await Promise.all(e.sessions.map(endAgentSession))}async function endAgentSession(e){let{address:t,context:n}=e;try{if(t.kind===`remote`){let e=await resolveSessionRemote(n,t);await resetRemoteAgentSession({reason:RUN_FINISHED_REASON,remote:e,sessionId:t.sessionId});return}await commandLocalSession({...e,address:t},{kind:`reset`,reason:RUN_FINISHED_REASON})}catch(e){logError(log,`failed to end an agent session`,e,{name:t.name,sessionId:t.sessionId})}}async function commandLocalSession(e,t){let{continuationToken:n,sessionId:r}=e.address,i=await dispatchWorkflowSessionCommand({command:t,sessionId:r});if(i.status===`accepted`||i.status===`reset`)return i;let a=await waitForSessionInbox(r)?r:(await resolveContinuation(n))?.sessionId;return a===void 0?i:await dispatchWorkflowSessionCommand({command:t,sessionId:a})}async function startLocalSession(e){let{auth:t,bundle:n,context:r,target:i}=e,{action:a}=i,{childContinuationToken:o,runInput:s}=buildSubagentRunInput({action:a,auth:t.current,capabilities:r.capabilities,schedule:r.schedule,channelMetadata:r.channelMetadata,continuationKey:e.key,graph:n.graph,inheritedConversation:r.conversation,initiatorAuth:t.initiator,parent:createParentContext(r,e.replyTo),sandboxSessionId:r.sandbox.sessionId,selfAgent:i.source.type===`runtime`,session:{continuationToken:e.replyTo,sandboxState:r.sandbox.state,sessionId:r.parent.sessionId},source:i.source}),c=createWorkflowRuntime({agentSessionRuntimeOverrides:e.runtimeOverrides,compiledArtifactsSource:n.compiledArtifactsSource,dynamicSubagentAgentConfig:i.dynamicSubagentAgentConfig,nodeId:a.nodeId}),l=r.toolStubs;l!==void 0&&(l={...l,agentPath:stubToolPath(l,a.name)});let u=(await contextStorage.run(new ContextContainer({localDevRequest:r.localDevRequest}),()=>c.createSession({...s,toolStubs:l}))).sessionId;return getStepMetadata().attempt>1&&({runId:u}=await waitForCommandHookOwner(sessionInboxHookToken(o))),{continuationToken:o,kind:`local`,name:a.name,nodeId:a.nodeId,sessionId:u}}async function startRemoteSession(e){let{auth:t,bundle:n,context:r,target:i}=e,{action:a}=i,o=resolveRemoteAgentForAction({dynamicRemoteAgent:i.dynamicRemoteAgent,nodeId:a.nodeId,registry:n.subagentRegistry.subagentsByNodeId,remoteAgentName:a.remoteAgentName}),s=resolveWorkflowCallbackBaseUrl(getWorkflowMetadata().url),c=await startRemoteAgentSession({action:a,auth:t.current,callbackBaseUrl:s,capabilities:r.capabilities,initiatorAuth:t.initiator,operationId:`agent-session:${e.key}`,originAudience:r.trace.originAudience,parent:createParentContext(r,e.replyTo),remote:o,session:{continuationToken:e.replyTo}});return{callbackBaseUrl:s,kind:`remote`,forwardPrincipal:o.forwardPrincipal,name:a.remoteAgentName,nodeId:a.nodeId,resolverId:i.dynamicRemoteAgent?.credentialsStepId??a.nodeId,sessionId:c.sessionId,url:o.url}}function createParentContext(e,t){return{continuationToken:t,conversationId:e.trace.conversationId??resolveConversationId(e.parent.rootSessionId),lineage:e.parent,originAudience:e.trace.originAudience,traceContext:e.trace.parentTraceContext,traceRoot:e.traceRoot}}async function resolveSessionRemote(e,t){let n=await loadAgentSessionBundle(e),r=e.dynamicSelections[t.nodeId];return{...resolveRemoteAgentForAction({dynamicRemoteAgent:r?.kind===`remote`?r.remoteAgent:void 0,nodeId:t.nodeId,registry:n.subagentRegistry.subagentsByNodeId,remoteAgentName:t.name}),url:t.url}}async function loadAgentSessionBundle(e){return await getCompiledRuntimeAgentBundle({compiledArtifactsSource:resolveDurableCompiledArtifactsSource(e.bundle.source),nodeId:e.bundle.nodeId})}export{cancelAgentSessionTurnStep,endAgentSessionsStep,openAgentSessionStep,sendAgentSessionMessageStep};
|
|
@@ -4,6 +4,7 @@ import { type LocalDevRequestProvenance } from "#context/keys.js";
|
|
|
4
4
|
import { ContextContainer } from "#context/container.js";
|
|
5
5
|
import { type CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
6
6
|
import type { HarnessSessionBase } from "#harness/types.js";
|
|
7
|
+
import type { TaskStartedStreamEvent } from "#protocol/message.js";
|
|
7
8
|
import type { RuntimeActionResult, RuntimeWorkflowTaskRequest } from "#shared/action-types.js";
|
|
8
9
|
import type { SessionParent, SessionTraceRoot } from "#channel/types.js";
|
|
9
10
|
import { type DurableSessionState, readDurableSession } from "#execution/durable-session-store.js";
|
|
@@ -14,7 +15,6 @@ import type { WorkflowAgentMetadata } from "#tools/workflow-definition.js";
|
|
|
14
15
|
/** Input shared by direct and Workflow-originated owner-side dispatch. */
|
|
15
16
|
export interface CoordinationDispatchInput {
|
|
16
17
|
readonly workflowToolRunOwner: WorkflowToolRunOwner;
|
|
17
|
-
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
18
18
|
readonly serializedContext: Record<string, unknown>;
|
|
19
19
|
readonly sessionState: DurableSessionState;
|
|
20
20
|
}
|
|
@@ -23,6 +23,8 @@ export interface CoordinationDispatchResult {
|
|
|
23
23
|
readonly results: readonly RuntimeActionResult[];
|
|
24
24
|
readonly serializedContext: Record<string, unknown>;
|
|
25
25
|
readonly sessionState: DurableSessionState;
|
|
26
|
+
/** The tasks the dispatch started or sent to, for the step that publishes `task.started`. */
|
|
27
|
+
readonly started: readonly TaskStartedStreamEvent["data"][];
|
|
26
28
|
}
|
|
27
29
|
/** Everything preflight produces before either step's dispatch loop runs. */
|
|
28
30
|
export interface PreparedCoordinationDispatch<PlanEntry = RuntimeWorkflowTaskRequest> {
|
|
@@ -51,10 +53,8 @@ export interface PreparedCoordinationDispatch<PlanEntry = RuntimeWorkflowTaskReq
|
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* Runs every dispatch precondition that may throw — durable reads, context
|
|
54
|
-
* deserialization, handle-store validation, and batch planning — before
|
|
55
|
-
*
|
|
56
|
-
* never leaks the writer lock. Returns undefined when no actions are
|
|
57
|
-
* pending.
|
|
56
|
+
* deserialization, handle-store validation, and batch planning — before any
|
|
57
|
+
* run starts. Returns undefined when no actions are pending.
|
|
58
58
|
*/
|
|
59
59
|
export declare function prepareCoordinationDispatch(input: {
|
|
60
60
|
readonly serializedContext: Record<string, unknown>;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
/** Starts workflow-tool runs for pending coordination. */
|
|
1
|
+
/** Starts workflow-tool runs for pending coordination, then reports the tasks it started. */
|
|
2
2
|
import { type CoordinationDispatchInput, type CoordinationDispatchResult } from "#execution/coordination-dispatch-shared.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type SessionStepState } from "#execution/publish-session-events.js";
|
|
4
|
+
import { type SessionStateTransition, type WithSessionStateDelta } from "#execution/session/state-delta.js";
|
|
5
|
+
import type { TaskStartedStreamEvent } from "#protocol/message.js";
|
|
4
6
|
type CoordinationDispatchStepInput = CoordinationDispatchInput & {
|
|
5
7
|
readonly action: "park";
|
|
6
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Starts the runs of the pending calls and records them on the session. A
|
|
11
|
+
* retry starts its runs again, since a Workflow start has no idempotency key,
|
|
12
|
+
* so this step publishes nothing and commits as soon as the runs are
|
|
13
|
+
* recorded. See {@link publishTaskStartedStep}.
|
|
14
|
+
*/
|
|
7
15
|
export declare function dispatchCoordinationStep(input: CoordinationDispatchStepInput): Promise<WithSessionStateDelta<CoordinationDispatchResult>>;
|
|
16
|
+
/**
|
|
17
|
+
* Publishes `task.started` for the tasks {@link dispatchCoordinationStep}
|
|
18
|
+
* started, before their receipts reach the turn. A retry only publishes again.
|
|
19
|
+
*/
|
|
20
|
+
export declare function publishTaskStartedStep(input: SessionStepState & {
|
|
21
|
+
readonly started: readonly TaskStartedStreamEvent["data"][];
|
|
22
|
+
}): Promise<SessionStateTransition>;
|
|
8
23
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createDurableSessionState}from"#execution/durable-session-store.js";import{prepareCoordinationDispatch}from"#execution/coordination-dispatch-shared.js";import{commitSessionStep}from"#execution/publish-session-events.js";import{withSessionStateDelta}from"#execution/session/state-delta.js";import{startWorkflowTask,startWorkflowToolCallRun}from"#execution/tools/workflow/start.js";import{runEntryToStart,sendToTask,startTaskRun,startsEveryRun}from"#execution/tasks/start.js";import{readTaskTable}from"#execution/tasks/table.js";import{captureAgentSessionContext}from"#execution/agent-sessions/context.js";import{startTask}from"#harness/session-machine/transitions.js";async function dispatchCoordinationStep(e){"use step";return await withSessionStateDelta(e,dispatchCoordination)}async function publishTaskStartedStep(e){"use step";return await withSessionStateDelta(e,({started:e,...t})=>commitSessionStep(t,t=>e.map(e=>startTask(t,e)),{origin:`own`}))}async function dispatchCoordination(e){let t=await prepareCoordinationDispatch({serializedContext:e.serializedContext,sessionState:e.sessionState});if(t===void 0)return{results:[],serializedContext:e.serializedContext,sessionState:e.sessionState,started:[]};let{batch:n,session:r}=t,i=r,a=[],o=[],s=withPrestartedRuns(t.plan.map(i=>({agentContext:captureAgentSessionContext(t,i.callId),auth:{current:t.auth,initiator:t.initiatorAuth},batchEvent:n.event,owner:e.workflowToolRunOwner,parentSession:t.parentSession,session:r,task:i})),readTaskTable(r.state));for(let e of s){let t=await dispatchWorkflowCall({...e,session:i});i=t.session,t.result!==void 0&&a.push(t.result),t.started!==void 0&&o.push(t.started)}return{results:a,serializedContext:e.serializedContext,sessionState:i===r?t.sessionState:createDurableSessionState({session:i}),started:o}}function withPrestartedRuns(e,t){let n=e.map(e=>e.task),r=n.map(e=>runEntryToStart(t,e));return r.filter(e=>e!==void 0).length>1&&startsEveryRun(t,n)?e.map((e,t)=>{let n=r[t];if(n===void 0)return e;let i=startWorkflowToolCallRun(e,n);return i.catch(()=>{}),{...e,prestarted:{entry:n,run:i}}}):e}async function dispatchWorkflowCall(e){let{entry:t}=e.task;switch(t.entryPoint){case`execute`:return await startWorkflowTask(e);case`task`:case`serve`:return await startTaskRun({...e,entry:t});case`receive`:return await sendToTask({...e,taskId:t.taskId})}}export{dispatchCoordinationStep,publishTaskStartedStep};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type DurableCompiledArtifactsSource } from "#runtime/durable-compiled-artifacts-source.js";
|
|
2
2
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
3
3
|
import type { HarnessModelMessage } from "#harness/messages.js";
|
|
4
|
-
import type { RunSessionLimits } from "#channel/types.js";
|
|
5
4
|
import type { JsonObject } from "#shared/json.js";
|
|
5
|
+
import type { AgentSessionRuntimeOverrides } from "#execution/agent-sessions/runtime-overrides.js";
|
|
6
6
|
import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
|
|
7
|
+
import type { SessionHistoryMessage } from "#shared/session-history.js";
|
|
7
8
|
/**
|
|
8
9
|
* Result returned by {@link createSessionStep}.
|
|
9
10
|
*
|
|
@@ -21,10 +22,12 @@ export interface CreateSessionStepResult {
|
|
|
21
22
|
* the root agent.
|
|
22
23
|
*/
|
|
23
24
|
export declare function createSessionStep(input: {
|
|
25
|
+
readonly agentSessionRuntimeOverrides?: AgentSessionRuntimeOverrides;
|
|
24
26
|
readonly compiledArtifactsSource: DurableCompiledArtifactsSource;
|
|
25
27
|
readonly continuationToken: string;
|
|
26
28
|
readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
|
|
27
|
-
|
|
29
|
+
/** History from `create()`, held until the first message's turn adds it. */
|
|
30
|
+
readonly history?: readonly SessionHistoryMessage[];
|
|
28
31
|
readonly outputSchema?: JsonObject;
|
|
29
32
|
readonly nodeId?: string;
|
|
30
33
|
readonly rootSessionId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{createDurableSessionValues}from"#execution/durable-session-store.js";import{createSession}from"#execution/session.js";import{resolveEffectiveAgentRuntimeFromConfig}from"#execution/effective-agent-config.js";import{
|
|
1
|
+
import{resolveDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{createDurableSessionValues}from"#execution/durable-session-store.js";import{createSession}from"#execution/session.js";import{resolveEffectiveAgentRuntimeFromConfig}from"#execution/effective-agent-config.js";import{withPendingHistory}from"#execution/session/pending-history.js";async function createSessionStep(e){"use step";let t=await getCompiledRuntimeAgentBundle({compiledArtifactsSource:resolveDurableCompiledArtifactsSource(e.compiledArtifactsSource),nodeId:e.nodeId}),n=resolveEffectiveAgentRuntimeFromConfig(t,e.dynamicSubagentAgentConfig,e.agentSessionRuntimeOverrides),r=createSession({compactionOverrides:{thresholdPercent:n.thresholdPercent},continuationToken:e.continuationToken,outputSchema:e.outputSchema,rootSessionId:e.rootSessionId,sessionId:e.sessionId,turnAgent:n.turnAgent}),i=withPendingHistory(r.state,e.history),{history:a,sessionState:o}=createDurableSessionValues(i===r.state?r:{...r,state:i});return{history:a,state:o}}export{createSessionStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`inputResponses`,`message`,`outputSchema`];function coalesceDeliverPayloads(e){if(e.length===0)return{};if(e.length===1)return e[0]??{};let t={},n={};for(let r of e){for(let[e,n]of Object.entries(r))n!==void 0&&(t[e]=n);n=coalesceTurnInputs(n,r)}for(let e of COALESCED_DELIVER_FIELDS)delete t[e];return Object.assign(t,n)}export{coalesceDeliverPayloads};
|
|
1
|
+
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`history`,`inputResponses`,`message`,`outputSchema`];function coalesceDeliverPayloads(e){if(e.length===0)return{};if(e.length===1)return e[0]??{};let t={},n={};for(let r of e){for(let[e,n]of Object.entries(r))n!==void 0&&(t[e]=n);n=coalesceTurnInputs(n,r)}for(let e of COALESCED_DELIVER_FIELDS)delete t[e];return Object.assign(t,n)}export{coalesceDeliverPayloads};
|
|
@@ -47,7 +47,6 @@ export interface DurableSession {
|
|
|
47
47
|
*/
|
|
48
48
|
readonly rootSessionId?: string;
|
|
49
49
|
readonly continuationToken: string;
|
|
50
|
-
readonly limits?: HarnessSession["limits"];
|
|
51
50
|
readonly outputSchema?: JsonObject;
|
|
52
51
|
readonly state?: SessionStateMap;
|
|
53
52
|
readonly sandboxState?: SandboxState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createErrorId,createLogger}from"#internal/logging.js";import{toErrorMessage}from"#shared/errors.js";import{activeTurnId,turnPosition}from"#harness/session-machine/view.js";import{
|
|
1
|
+
import{createErrorId,createLogger}from"#internal/logging.js";import{toErrorMessage}from"#shared/errors.js";import{activeTurnId,turnPosition}from"#harness/session-machine/view.js";import{fail}from"#harness/session-machine/transitions.js";import{isDynamicConnectionResolutionError}from"#context/dynamic-connection-lifecycle.js";import{applyTransition,sessionView}from"#harness/session-machine/commit.js";const log=createLogger(`turn-step`);async function recoverDynamicConnectionRehydration(e){if(!isDynamicConnectionResolutionError(e.error))return;let t=createErrorId(),n=toErrorMessage(e.error);return log.error(`dynamic connection rehydration failed — parking session`,{error:e.error,errorId:t,sessionId:e.session.sessionId,turnId:activeTurnId(turnPosition(e.projection))}),{next:null,session:{...await applyTransition(e.session,fail(sessionView(e.projection,e.session.state),{code:`EVENT_HANDLER_FAILED`,details:{errorId:t},message:n}),e.emit),outputSchema:void 0},settledTurn:{isError:!0,output:n}}}export{recoverDynamicConnectionRehydration};
|
|
@@ -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.
|
|
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.82.0//runWorkflowProgramTask`;export{runWorkflowProgramTask};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ContextReader } from "#context/key.js";
|
|
2
2
|
import type { RuntimeTurnAgent } from "#runtime/agent/bootstrap.js";
|
|
3
3
|
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
4
|
-
import type { AgentLimitsDefinition } from "#shared/agent-definition.js";
|
|
4
|
+
import type { AgentLimitsDefinition, SessionUsageLimit } from "#shared/agent-definition.js";
|
|
5
|
+
import type { AgentSessionRuntimeOverrides } from "#execution/agent-sessions/runtime-overrides.js";
|
|
5
6
|
import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
|
|
6
7
|
interface EffectiveAgentRuntime {
|
|
7
8
|
readonly limits?: AgentLimitsDefinition;
|
|
@@ -9,5 +10,10 @@ interface EffectiveAgentRuntime {
|
|
|
9
10
|
readonly turnAgent: RuntimeTurnAgent;
|
|
10
11
|
}
|
|
11
12
|
export declare function resolveEffectiveAgentRuntime(bundle: Pick<CompiledBundle, "resolvedAgent" | "turnAgent">, context: ContextReader): EffectiveAgentRuntime;
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The session's `limits.sessionUsage`: the agent's own, else the root agent's.
|
|
15
|
+
* A dynamic subagent config can't carry one, so its sessions run the root's.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveSessionUsageLimit(bundle: Pick<CompiledBundle, "graph" | "resolvedAgent">): SessionUsageLimit | undefined;
|
|
18
|
+
export declare function resolveEffectiveAgentRuntimeFromConfig(bundle: Pick<CompiledBundle, "resolvedAgent" | "turnAgent">, config: DynamicSubagentAgentConfig | undefined, overrides?: AgentSessionRuntimeOverrides): EffectiveAgentRuntime;
|
|
13
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DynamicSubagentAgentConfigKey}from"#context/keys.js";function resolveEffectiveAgentRuntime(e,t){return resolveEffectiveAgentRuntimeFromConfig(e,t.get(DynamicSubagentAgentConfigKey))}function resolveEffectiveAgentRuntimeFromConfig(e,t){if(t===void 0){if(e.turnAgent.configResolver===!0)throw Error(`Dynamic subagent execution requires a selected concrete agent config.`);
|
|
1
|
+
import{AgentSessionRuntimeOverridesKey,DynamicSubagentAgentConfigKey}from"#context/keys.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";function resolveEffectiveAgentRuntime(e,t){return resolveEffectiveAgentRuntimeFromConfig(e,t.get(DynamicSubagentAgentConfigKey),t.get(AgentSessionRuntimeOverridesKey))}function resolveSessionUsageLimit(e){return e.resolvedAgent.config?.limits?.sessionUsage??e.graph.nodesByNodeId.get(ROOT_RUNTIME_AGENT_NODE_ID)?.agent.config?.limits?.sessionUsage}function resolveEffectiveAgentRuntimeFromConfig(e,t,n){let r;if(t===void 0){if(e.turnAgent.configResolver===!0)throw Error(`Dynamic subagent execution requires a selected concrete agent config.`);r={limits:e.resolvedAgent.config?.limits,thresholdPercent:e.resolvedAgent.config?.compaction?.thresholdPercent,turnAgent:e.turnAgent}}else{let{compactionModel:n,configResolver:i,dynamicModel:a,model:o,...s}=e.turnAgent;r={limits:t.limits,thresholdPercent:t.compaction?.thresholdPercent,turnAgent:{...s,compactionModel:t.compaction?.model,model:t.model,reasoning:t.reasoning}}}if(n===void 0)return r;let{configResolver:i,dynamicModel:a,model:o,...s}=r.turnAgent;return{...r,turnAgent:{...s,model:n.model}}}export{resolveEffectiveAgentRuntime,resolveEffectiveAgentRuntimeFromConfig,resolveSessionUsageLimit};
|