eve 0.24.2 → 0.24.4
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 +22 -0
- package/dist/src/channel/adapter.d.ts +4 -2
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/session.d.ts +5 -1
- package/dist/src/channel/types.d.ts +7 -6
- package/dist/src/chunks/{use-eve-agent-CFBTHlPx.js → use-eve-agent-BP9FpQsJ.js} +15 -4
- package/dist/src/chunks/{use-eve-agent-dEGV09g_.js → use-eve-agent-Dwa2j1wE.js} +15 -4
- package/dist/src/cli/dev/environment.d.ts +6 -0
- package/dist/src/cli/dev/environment.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +2 -2
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.d.ts +4 -2
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +3 -2
- package/dist/src/compiled/.vendor-stamp.json +2 -1
- package/dist/src/compiled/@chat-adapter/slack/index.js +12 -12
- package/dist/src/compiled/@chat-adapter/twilio/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +19 -19
- package/dist/src/compiled/@workflow/world-local/index.d.ts +14 -0
- package/dist/src/compiled/_chunks/node/{auth-CWHn3Yve.js → auth-BuQkq4Gr.js} +2 -2
- package/dist/src/compiled/_chunks/node/{dist-BdTs18CF.js → chunk-BTyA9uPd.js} +1 -1
- package/dist/src/compiled/_chunks/node/{dist-W8yle6rh.js → dist-CdH_Yoxt.js} +5 -5
- package/dist/src/compiled/_chunks/node/{dist-RHRJZ03Q.js → dist-Drt-_JVK.js} +1 -1
- package/dist/src/compiled/_chunks/node/dist-DsNhwdzf.js +1 -0
- package/dist/src/compiled/_chunks/node/retry-DngYleaI.js +1 -0
- package/dist/src/compiled/_chunks/node/token-DabMnh8F.js +1 -0
- package/dist/src/compiled/_chunks/node/token-util-BoSJPKrG.js +1 -0
- package/dist/src/compiled/_chunks/node/token-util-DVigMYWS.js +1 -0
- package/dist/src/compiled/_chunks/node/virtual-loader-B8K8w9cr.js +1 -0
- package/dist/src/compiled/chat/index.js +1 -1
- package/dist/src/compiled/env-runner/LICENSE +21 -0
- package/dist/src/compiled/env-runner/index.d.ts +38 -0
- package/dist/src/compiled/env-runner/index.js +1 -0
- package/dist/src/compiled/env-runner/node-worker.d.ts +1 -0
- package/dist/src/compiled/env-runner/node-worker.js +12 -0
- package/dist/src/compiler/compile-agent.d.ts +4 -6
- package/dist/src/compiler/compile-agent.js +1 -1
- package/dist/src/discover/filesystem.js +1 -1
- package/dist/src/execution/create-session-step.d.ts +2 -2
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/durable-session-migrations/turn-workflow.d.ts +1 -0
- package/dist/src/execution/durable-session-migrations/turn-workflow.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +7 -0
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +16 -0
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -0
- package/dist/src/execution/subagent-hitl-proxy.js +1 -1
- package/dist/src/execution/terminal-session-failure-step.d.ts +6 -0
- package/dist/src/execution/terminal-session-failure-step.js +1 -0
- package/dist/src/execution/turn-cancellation-control.d.ts +40 -0
- package/dist/src/execution/turn-cancellation-control.js +1 -0
- package/dist/src/execution/turn-dispatch.d.ts +14 -1
- package/dist/src/execution/turn-dispatch.js +1 -1
- package/dist/src/execution/turn-execution-cursor.d.ts +2 -1
- package/dist/src/execution/turn-execution-cursor.js +1 -1
- package/dist/src/execution/turn-workflow.d.ts +9 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +8 -6
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/active-turn-id.d.ts +11 -0
- package/dist/src/harness/active-turn-id.js +1 -0
- package/dist/src/harness/cancelled-turn-emission.d.ts +11 -0
- package/dist/src/harness/cancelled-turn-emission.js +1 -0
- package/dist/src/harness/emission.d.ts +4 -2
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +5 -0
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/internal/application/compiled-artifacts.d.ts +13 -0
- package/dist/src/internal/application/compiled-artifacts.js +5 -3
- package/dist/src/internal/application/dev-environment.d.ts +4 -0
- package/dist/src/internal/application/dev-environment.js +1 -0
- package/dist/src/internal/application/optional-package-install.d.ts +2 -10
- package/dist/src/internal/application/optional-package-install.js +1 -1
- package/dist/src/internal/application/output-publication-lock.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/tsconfig-dependencies.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +3 -9
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/authored-package-boundary.d.ts +0 -2
- package/dist/src/internal/authored-package-boundary.js +1 -1
- package/dist/src/internal/authored-package-tsconfig-paths.js +1 -1
- package/dist/src/internal/bundler/nitro-rolldown.d.ts +18 -2
- package/dist/src/internal/bundler/nitro-rolldown.js +1 -1
- package/dist/src/internal/compiled-manifest-fingerprint.d.ts +5 -0
- package/dist/src/internal/compiled-manifest-fingerprint.js +1 -0
- package/dist/src/internal/materialized-authored-modules.d.ts +0 -3
- package/dist/src/internal/materialized-authored-modules.js +1 -1
- package/dist/src/internal/nitro/dev-client-address.d.ts +22 -0
- package/dist/src/internal/nitro/dev-client-address.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts-retention.d.ts +12 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts-retention.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +19 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
- package/dist/src/internal/nitro/development-generation.d.ts +5 -1
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/artifacts-config.d.ts +2 -0
- package/dist/src/internal/nitro/host/artifacts-config.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.d.ts +1 -13
- package/dist/src/internal/nitro/host/channel-routes.js +3 -3
- package/dist/src/internal/nitro/host/configure-nitro-routes.d.ts +1 -2
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/host/create-application-nitro.d.ts +3 -5
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +32 -0
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -0
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +4 -15
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-host-candidate.d.ts +16 -0
- package/dist/src/internal/nitro/host/dev-host-candidate.js +1 -0
- package/dist/src/internal/nitro/host/dev-host-fingerprint.d.ts +2 -0
- package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -0
- package/dist/src/internal/nitro/host/dev-host-workspace.d.ts +10 -0
- package/dist/src/internal/nitro/host/dev-host-workspace.js +1 -0
- package/dist/src/internal/nitro/host/dev-runner.d.ts +21 -0
- package/dist/src/internal/nitro/host/dev-runner.js +1 -0
- package/dist/src/internal/nitro/host/dev-server-http.d.ts +5 -0
- package/dist/src/internal/nitro/host/dev-server-http.js +1 -0
- package/dist/src/internal/nitro/host/dev-server-url.d.ts +6 -0
- package/dist/src/internal/nitro/host/dev-server-url.js +1 -0
- package/dist/src/internal/nitro/host/dev-workflow-world-setup.d.ts +9 -0
- package/dist/src/internal/nitro/host/dev-workflow-world-setup.js +1 -0
- package/dist/src/internal/nitro/host/dispatch-schedule-in-dev.js +1 -1
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.d.ts +53 -0
- package/dist/src/internal/nitro/host/drained-nitro-dev-server.js +1 -0
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +4 -5
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.d.ts +2 -5
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/types.d.ts +6 -0
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-artifacts.d.ts +7 -0
- package/dist/src/internal/nitro/routes/runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/routes/schedule-task.d.ts +9 -0
- package/dist/src/internal/nitro/routes/schedule-task.js +1 -1
- package/dist/src/internal/workflow/development-generation-context.d.ts +8 -0
- package/dist/src/internal/workflow/development-generation-context.js +1 -0
- package/dist/src/internal/workflow/development-world-client.d.ts +29 -0
- package/dist/src/internal/workflow/development-world-client.js +1 -0
- package/dist/src/internal/workflow/development-world-codec.d.ts +11 -0
- package/dist/src/internal/workflow/development-world-codec.js +1 -0
- package/dist/src/internal/workflow/development-world-protocol.d.ts +31 -0
- package/dist/src/internal/workflow/development-world-protocol.js +1 -0
- package/dist/src/internal/workflow/development-world-server.d.ts +27 -0
- package/dist/src/internal/workflow/development-world-server.js +1 -0
- package/dist/src/internal/workflow/local-world-data-directory.d.ts +2 -0
- package/dist/src/internal/workflow/local-world-data-directory.js +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.js +3 -3
- package/dist/src/internal/workflow-bundle/builder.js +2 -2
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/protocol/message.d.ts +23 -3
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/discord/discordChannel.d.ts +1 -0
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +1 -0
- package/dist/src/public/channels/linear/linearChannel.d.ts +1 -0
- package/dist/src/public/channels/slack/slackChannel.d.ts +1 -0
- package/dist/src/public/channels/teams/teamsChannel.d.ts +1 -0
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +1 -0
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +1 -0
- package/dist/src/public/definitions/channel.d.ts +5 -4
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/compiled-artifacts-source.d.ts +9 -0
- package/dist/src/runtime/compiled-artifacts-source.js +1 -1
- package/dist/src/runtime/durable-compiled-artifacts-source.d.ts +8 -0
- package/dist/src/runtime/durable-compiled-artifacts-source.js +1 -0
- package/dist/src/runtime/sessions/runtime-context-keys.js +1 -1
- package/dist/src/services/dev-client/runtime-artifacts.d.ts +2 -2
- package/dist/src/services/dev-client.d.ts +10 -18
- package/dist/src/services/dev-client.js +1 -1
- package/dist/src/setup/scaffold/create/extension.js +0 -1
- package/dist/src/setup/scaffold/create/project.js +1 -3
- package/dist/src/shared/atomic-write-file.d.ts +1 -1
- package/dist/src/shared/atomic-write-file.js +1 -1
- package/dist/src/shared/continuation-token.d.ts +2 -0
- package/dist/src/shared/continuation-token.js +1 -0
- package/dist/src/shared/rename-with-retry.d.ts +5 -0
- package/dist/src/shared/rename-with-retry.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.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 +2 -0
- package/docs/concepts/execution-model-and-durability.md +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +13 -4
- package/docs/guides/client/continuations.mdx +14 -1
- package/docs/guides/client/streaming.mdx +14 -1
- package/docs/guides/deployment.md +1 -1
- package/docs/reference/cli.md +1 -1
- package/package.json +2 -1
- package/dist/src/compiled/_chunks/node/retry-DkR2H1Y0.js +0 -1
- package/dist/src/compiled/_chunks/node/token-ORseRyWn.js +0 -1
- package/dist/src/internal/bundler/nitro-node-file-trace.d.ts +0 -10
- package/dist/src/internal/bundler/nitro-node-file-trace.js +0 -1
- package/dist/src/internal/materialize-authored-external-dependencies.d.ts +0 -10
- package/dist/src/internal/materialize-authored-external-dependencies.js +0 -2
- package/dist/src/internal/nitro/host/dev-live-virtual-modules.d.ts +0 -15
- package/dist/src/internal/nitro/host/dev-live-virtual-modules.js +0 -1
- package/dist/src/internal/nitro/host/server-external-packages.d.ts +0 -5
- package/dist/src/internal/nitro/host/server-external-packages.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deserializeUrlFilePart,hasInternalRefScheme,isSerializedUrlFilePart}from"#internal/attachments/url-refs.js";import{decodeSandboxRef,isSandboxRefUrl}from"#internal/attachments/sandbox-refs.js";const EVE_SESSION_ID_HEADER=`x-eve-session-id`,EVE_STREAM_FORMAT_HEADER=`x-eve-stream-format`,EVE_STREAM_VERSION_HEADER=`x-eve-stream-version`,EVE_MESSAGE_STREAM_CONTENT_TYPE=`application/x-ndjson; charset=utf-8`,EVE_MESSAGE_STREAM_FORMAT=`ndjson`,EVE_MESSAGE_STREAM_VERSION=`
|
|
2
|
-
`)}function projectUserContentParts(e){if(typeof e==`string`)return[{text:e,type:`text`}];let t=[];for(let n of e)n.type===`text`?t.push({text:n.text,type:`text`}):n.type===`file`?t.push(projectFileLikePart(n.data,n.mediaType,n.filename)):n.type===`image`&&t.push(projectFileLikePart(n.image,n.mediaType??`application/octet-stream`,void 0));return t}function projectFileLikePart(e,t,n){if(isSandboxRefUrl(e)){let t=decodeSandboxRef(e);return createProjectedFilePart({filename:basenameOf(n??t.path),mediaType:t.mediaType,size:t.size})}let
|
|
1
|
+
import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";import{deserializeUrlFilePart,hasInternalRefScheme,isSerializedUrlFilePart}from"#internal/attachments/url-refs.js";import{decodeSandboxRef,isSandboxRefUrl}from"#internal/attachments/sandbox-refs.js";const EVE_SESSION_ID_HEADER=`x-eve-session-id`,EVE_STREAM_FORMAT_HEADER=`x-eve-stream-format`,EVE_STREAM_VERSION_HEADER=`x-eve-stream-version`,EVE_MESSAGE_STREAM_CONTENT_TYPE=`application/x-ndjson; charset=utf-8`,EVE_MESSAGE_STREAM_FORMAT=`ndjson`,EVE_MESSAGE_STREAM_VERSION=`19`,textEncoder=new TextEncoder;function isCurrentTurnBoundaryEvent(e){return e.type===`session.completed`||e.type===`session.failed`||e.type===`session.waiting`}function isTurnFailureEvent(e){return e.type===`session.failed`||e.type===`step.failed`||e.type===`turn.failed`}function createSessionStartedEvent(e){let t={};return e?.invocation!==void 0&&(t.invocation=e.invocation),e?.runtime!==void 0&&(t.runtime=e.runtime),{data:t,type:`session.started`}}function createTurnStartedEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.started`}}function createMessageReceivedEvent(e){return{data:{message:summarizeUserContent(e.message),parts:projectUserContentParts(e.message),sequence:e.sequence,turnId:e.turnId},type:`message.received`}}function summarizeUserContent(e){if(typeof e==`string`)return e;let t=[];for(let n of e)if(n.type===`text`)t.push(n.text);else if(n.type===`file`){let e=n.filename??n.mediaType;t.push(`[file: ${e} (${n.mediaType})]`)}else n.type===`image`&&t.push(`[image: ${n.mediaType??`image`}]`);return t.join(`
|
|
2
|
+
`)}function projectUserContentParts(e){if(typeof e==`string`)return[{text:e,type:`text`}];let t=[];for(let n of e)n.type===`text`?t.push({text:n.text,type:`text`}):n.type===`file`?t.push(projectFileLikePart(n.data,n.mediaType,n.filename)):n.type===`image`&&t.push(projectFileLikePart(n.image,n.mediaType??`application/octet-stream`,void 0));return t}function projectFileLikePart(e,t,n){if(isSandboxRefUrl(e)){let t=decodeSandboxRef(e);return createProjectedFilePart({filename:basenameOf(n??t.path),mediaType:t.mediaType,size:t.size})}let r=projectTaggedFileData(e,t,n);if(r!==void 0)return r;let i=byteLengthOf(e);return createProjectedFilePart(i===void 0?{filename:n,mediaType:t,...clientUrlFragment(e)}:{filename:n,mediaType:t,size:i})}function projectTaggedFileData(e,t,n){if(isTaggedFileData(e))switch(e.type){case`data`:{let r=byteLengthOf(e.data);return createProjectedFilePart(r===void 0?{filename:n,mediaType:t}:{filename:n,mediaType:t,size:r})}case`reference`:case`text`:return createProjectedFilePart({filename:n,mediaType:t});case`url`:return createProjectedFilePart({filename:n,mediaType:t,...clientUrlFragment(e.url)})}}function createProjectedFilePart(e){let t={mediaType:e.mediaType,type:`file`};return e.filename!==void 0&&(t.filename=e.filename),e.size!==void 0&&(t.size=e.size),e.url!==void 0&&(t.url=e.url),t}function isTaggedFileData(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`data`||t===`reference`||t===`text`||t===`url`}function byteLengthOf(e){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return e.byteLength}function clientUrlFragment(e){if(isSerializedUrlFilePart(e))try{let n=deserializeUrlFilePart(e);return isClientResolvableUrl(n)?{url:n.href}:{}}catch{return{}}if(e instanceof URL)return isClientResolvableUrl(e)?{url:e.href}:{};if(typeof e!=`string`||hasInternalRefScheme(e))return{};if(e.startsWith(`data:`))return{url:e};try{let t=new URL(e);return isClientResolvableUrl(t)?{url:t.href}:{}}catch{return{}}}function isClientResolvableUrl(e){return e.protocol===`http:`||e.protocol===`https:`||e.protocol===`data:`}function basenameOf(e){let t=e.replaceAll(`\\`,`/`),n=t.slice(t.lastIndexOf(`/`)+1);return n.length>0?n:e}function createActionsRequestedEvent(e){return{data:{actions:e.actions,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`actions.requested`}}function createAuthorizationRequiredEvent(e){let t={description:e.description,name:e.name,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.authorization!==void 0&&(t.authorization=e.authorization),e.webhookUrl!==void 0&&(t.webhookUrl=e.webhookUrl),{data:t,type:`authorization.required`}}function createAuthorizationCompletedEvent(e){let t={name:e.name,outcome:e.outcome,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.authorization!==void 0&&(t.authorization=e.authorization),e.reason!==void 0&&(t.reason=e.reason),{data:t,type:`authorization.completed`}}function createInputRequestedEvent(e){return{data:{requests:e.requests,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`input.requested`}}function createActionResultEvent(e){let t=e.rejected===!0?{error:buildActionResultError(e.result),status:`rejected`}:normalizeActionResultOutcome(e.result);return{data:{error:t.error,result:e.result,sequence:e.sequence,stepIndex:e.stepIndex,status:t.status,turnId:e.turnId},type:`action.result`}}function createSubagentCalledEvent(e){return{data:{callId:e.callId,childSessionId:e.childSessionId,sessionId:e.sessionId,sequence:e.sequence,name:e.name,remote:e.remote,toolName:e.toolName,turnId:e.turnId,workflowId:e.workflowId},type:`subagent.called`}}function createMessageAppendedEvent(e){return{data:{messageDelta:e.messageDelta,messageSoFar:e.messageSoFar,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`message.appended`}}function createReasoningAppendedEvent(e){return{data:{reasoningDelta:e.reasoningDelta,reasoningSoFar:e.reasoningSoFar,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`reasoning.appended`}}function createMessageCompletedEvent(e){return{data:{finishReason:e.finishReason??`stop`,message:e.message,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`message.completed`}}function createReasoningCompletedEvent(e){return{data:{reasoning:e.reasoning,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`reasoning.completed`}}function createResultCompletedEvent(e){return{data:{result:e.result,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`result.completed`}}function createStepStartedEvent(e){return{data:{sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`step.started`}}function createStepCompletedEvent(e){let t={finishReason:e.finishReason,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId};return e.usage!==void 0&&(t.usage=e.usage),e.providerMetadata!==void 0&&(t.providerMetadata=e.providerMetadata),{data:t,type:`step.completed`}}function createStepFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sequence:e.sequence,stepIndex:e.stepIndex,turnId:e.turnId},type:`step.failed`}}function createTurnCompletedEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.completed`}}function createTurnFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sequence:e.sequence,turnId:e.turnId},type:`turn.failed`}}function createTurnCancelledEvent(e){return{data:{sequence:e.sequence,turnId:e.turnId},type:`turn.cancelled`}}function createCompactionRequestedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId,usageInputTokens:e.usageInputTokens??null},type:`compaction.requested`}}function createCompactionCompletedEvent(e){return{data:{modelId:e.modelId,sequence:e.sequence,sessionId:e.sessionId,turnId:e.turnId},type:`compaction.completed`}}function createSessionWaitingEvent(t){return{data:{continuationToken:toChannelLocalContinuationToken(t),wait:`next-user-message`},type:`session.waiting`}}function createSessionFailedEvent(e){return{data:{code:e.code,details:e.details,message:e.message,sessionId:e.sessionId},type:`session.failed`}}function createSessionCompletedEvent(){return{type:`session.completed`}}function timestampHandleMessageStreamEvent(e,t=new Date().toISOString()){return{...e,meta:{at:t}}}function encodeMessageStreamEvent(e){return textEncoder.encode(`${JSON.stringify(e)}\n`)}function normalizeActionResultOutcome(e){if(e.isError===!0)return{error:buildActionResultError(e),status:`failed`};let t=readActionResultOutputError(e.output);return t===void 0?{status:`completed`}:{error:t,status:`failed`}}function buildActionResultError(e){let t=readActionResultOutputError(e.output);return t===void 0?{code:`ACTION_RESULT_FAILED`,message:formatActionResultOutput(e.output)}:t}function readActionResultOutputError(e){let t=parseActionResultOutputRecord(e);if(t===void 0)return;let n=typeof t.code==`string`&&t.code.length>0?t.code:void 0,r=typeof t.message==`string`&&t.message.length>0?t.message:void 0;if(!(n===void 0||r===void 0))return{code:n,message:r}}function parseActionResultOutputRecord(e){if(typeof e==`object`&&e)return e;if(typeof e!=`string`)return;let t=e.trim();if(t.length!==0)try{let e=JSON.parse(t);if(typeof e==`object`&&e)return e}catch{return}}function formatActionResultOutput(e){if(typeof e==`string`)return e;let t=JSON.stringify(e);return typeof t==`string`&&t.length>0?t:`Action failed.`}export{EVE_MESSAGE_STREAM_CONTENT_TYPE,EVE_MESSAGE_STREAM_FORMAT,EVE_MESSAGE_STREAM_VERSION,EVE_SESSION_ID_HEADER,EVE_STREAM_FORMAT_HEADER,EVE_STREAM_VERSION_HEADER,createActionResultEvent,createActionsRequestedEvent,createAuthorizationCompletedEvent,createAuthorizationRequiredEvent,createCompactionCompletedEvent,createCompactionRequestedEvent,createInputRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createResultCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepCompletedEvent,createStepFailedEvent,createStepStartedEvent,createSubagentCalledEvent,createTurnCancelledEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent,encodeMessageStreamEvent,isCurrentTurnBoundaryEvent,isTurnFailureEvent,timestampHandleMessageStreamEvent};
|
|
@@ -78,6 +78,7 @@ export interface DiscordChannelEvents {
|
|
|
78
78
|
readonly "input.requested"?: DiscordEventHandler<"input.requested">;
|
|
79
79
|
readonly "turn.failed"?: DiscordEventHandler<"turn.failed">;
|
|
80
80
|
readonly "turn.completed"?: DiscordEventHandler<"turn.completed">;
|
|
81
|
+
readonly "turn.cancelled"?: DiscordEventHandler<"turn.cancelled">;
|
|
81
82
|
readonly "session.failed"?: DiscordSessionFailedHandler;
|
|
82
83
|
readonly "session.completed"?: DiscordEventHandler<"session.completed">;
|
|
83
84
|
readonly "session.waiting"?: DiscordEventHandler<"session.waiting">;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createLogger,logError}from"#internal/logging.js";import{hasInternalRefScheme}from"#internal/attachments/url-refs.js";import{EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{EVE_MESSAGE_STREAM_CONTENT_TYPE,EVE_MESSAGE_STREAM_FORMAT,EVE_MESSAGE_STREAM_VERSION,EVE_SESSION_ID_HEADER,EVE_STREAM_FORMAT_HEADER,EVE_STREAM_VERSION_HEADER}from"#protocol/message.js";import{isInputResponse}from"#runtime/input/types.js";import{parseJsonObject}from"#shared/json.js";import{GET,POST,defineChannel}from"#public/definitions/channel.js";import"ai";import{parseSessionCallback}from"#channel/session-callback.js";import{readAgentInfoRouteResponse}from"#internal/nitro/routes/channel-route-context.js";import{routeAuth}from"#public/channels/auth.js";import{collectUploadPolicyViolations,formatUploadPolicyViolation,mergeUploadPolicy}from"#public/channels/upload-policy.js";const log=createLogger(`eve.channel`);function defaultEveAuth(e){return e.eve.caller}function eveChannel(e){let t=mergeUploadPolicy(e.uploadPolicy);return defineChannel({cors:normalizeEveCors(e.cors),routes:[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()}),POST(`/eve/v1/session`,async(n,{send:r})=>{let i=await routeAuth(n,e.auth);if(i instanceof Response)return i;let a=i,o;try{o=await n.json()}catch{return Response.json({error:`Invalid JSON body.`,ok:!1},{status:400})}if(typeof o!=`object`||!o)return Response.json({error:`Expected a JSON object.`,ok:!1},{status:400});let s=parseCreateBody(o);if(s instanceof Response)return s;let c=checkUploadPolicy(s,t);if(c!==null)return c;let l=await resolveOnMessage({auth:a,config:e,message:s.message,request:n});if(l instanceof Response)return l;if(!l.dispatch)return droppedMessageResponse();let u=`eve:${crypto.randomUUID()}`,d=await r(createSendPayload(s,mergeContext(s.context,l.context)),{auth:l.auth,callback:s.callback,continuationToken:u,mode:s.mode});return Response.json({continuationToken:d.continuationToken,ok:!0,sessionId:d.id},{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:d.id},status:202})}),POST(`/eve/v1/session/:sessionId`,async(n,{send:r,getSession:i,params:a})=>{let o=await routeAuth(n,e.auth);if(o instanceof Response)return o;let s=o,c=a.sessionId;if(!c)return Response.json({error:`Missing session id.`,ok:!1},{status:400});try{i(c)}catch{return Response.json({error:`Session not found.`,ok:!1},{status:404})}let l;try{l=await n.json()}catch{return Response.json({error:`Invalid JSON body.`,ok:!1},{status:400})}if(typeof l!=`object`||!l)return Response.json({error:`Expected a JSON object.`,ok:!1},{status:400});let u=parseContinueBody(l);if(u instanceof Response)return u;let d=checkUploadPolicy(u,t);if(d!==null)return d;let f=u.context,p=s;if(u.message!==void 0){let t=await resolveOnMessage({auth:s,config:e,message:u.message,request:n,sessionId:c});if(t instanceof Response)return t;if(!t.dispatch)return droppedMessageResponse();f=mergeContext(u.context,t.context),p=t.auth}let m=await r({inputResponses:u.inputResponses,message:u.message,context:f,outputSchema:u.outputSchema},{auth:p,continuationToken:u.continuationToken});return Response.json({ok:!0,sessionId:m.id},{headers:{"cache-control":`no-store`,[EVE_SESSION_ID_HEADER]:m.id},status:200})}),GET(`/eve/v1/session/:sessionId/stream`,async(t,{getSession:n,params:r})=>{let l=await routeAuth(t,e.auth);if(l instanceof Response)return l;let u=r.sessionId;if(!u)return Response.json({error:`Missing session id.`,ok:!1},{status:400});let d=parseStartIndex(t);if(d instanceof Response)return d;try{let e=serializeAsNdjson(await n(u).getEventStream({startIndex:d}));return new Response(e,{headers:{"cache-control":`no-store, no-transform`,"content-type":EVE_MESSAGE_STREAM_CONTENT_TYPE,"x-accel-buffering":`no`,[EVE_SESSION_ID_HEADER]:u,[EVE_STREAM_FORMAT_HEADER]:EVE_MESSAGE_STREAM_FORMAT,[EVE_STREAM_VERSION_HEADER]:EVE_MESSAGE_STREAM_VERSION}})}catch{return Response.json({error:`Session not found.`,ok:!1},{status:404})}})],events:e.events})}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 n=e.config.onMessage??defaultOnMessage,r;try{r=await n({eve:e.sessionId===void 0?{caller:e.auth,request:e.request}:{caller:e.auth,request:e.request,sessionId:e.sessionId}},e.message)}catch(n){let r=logError(log,`onMessage handler failed`,n,{sessionId:e.sessionId});return Response.json({error:`onMessage handler failed.`,errorId:r,ok:!1},{status:500})}return r==null?{dispatch:!1}:r.context===void 0?{auth:r.auth,dispatch:!0}:{auth:r.auth,context:r.context,dispatch:!0}}function defaultOnMessage(e){return{auth:defaultEveAuth(e)}}function droppedMessageResponse(){return new Response(null,{headers:{"cache-control":`no-store`},status:204})}function parseCreateBody(e){let t=parseMessageField(e.message);if(t instanceof Response)return t;let n=parseClientContextField(e.clientContext);if(n instanceof Response)return n;let r=parseCallbackField(e.callback);if(r instanceof Response)return r;let i=parseModeField(e.mode);if(i instanceof Response)return i;let a=parseOutputSchemaField(e.outputSchema);return a instanceof Response?a:t===void 0?Response.json({error:`Missing or empty 'message' field.`,ok:!1},{status:400}):{callback:r,message:t,mode:i,context:n,outputSchema:a}}function parseContinueBody(e){let t=typeof e.continuationToken==`string`&&e.continuationToken.length>0?e.continuationToken:void 0;if(t===void 0)return Response.json({error:`Missing or empty 'continuationToken' field.`,ok:!1},{status:400});let n=parseMessageField(e.message);if(n instanceof Response)return n;let r=parseInputResponses(e.inputResponses);if(r instanceof Response)return r;let i=parseClientContextField(e.clientContext);if(i instanceof Response)return i;let a=parseOutputSchemaField(e.outputSchema);return a instanceof Response?a:n===void 0&&r===void 0?Response.json({error:`Expected a non-empty 'message', a non-empty 'inputResponses' array, or both.`,ok:!1},{status:400}):{message:n,continuationToken:t,inputResponses:r,context:i,outputSchema:a}}function createSendPayload(e,t=e.context){if(t===void 0&&e.outputSchema===void 0)return e.message;let n={message:e.message};return t!==void 0&&(n.context=t),e.outputSchema!==void 0&&(n.outputSchema=e.outputSchema),n}function parseOutputSchemaField(e){if(e!==void 0)try{return parseJsonObject(e)}catch{return Response.json({error:`Expected 'outputSchema' to be a JSON-serializable object.`,ok:!1},{status:400})}}function parseCallbackField(e){if(e===void 0)return;let t=parseSessionCallback(e);return t.ok?t.callback:Response.json({error:t.message,ok:!1},{status:400})}function parseModeField(e){if(e!==void 0)return e===`conversation`||e===`task`?e:Response.json({error:`Expected 'mode' to be either 'conversation' or 'task'.`,ok:!1},{status:400})}function parseMessageField(e){if(e===void 0)return;if(typeof e==`string`)return e.length>0?e:void 0;if(!Array.isArray(e))return Response.json({error:`Expected 'message' to be a string or an array of text/file parts.`,ok:!1},{status:400});if(e.length===0)return;let t=[];for(let n of e){let e=parseMessagePart(n);if(e instanceof Response)return e;t.push(e)}return t}function parseMessagePart(e){if(typeof e!=`object`||!e)return Response.json({error:`Expected each message part to be an object.`,ok:!1},{status:400});let t=e;if(t.type===`text`)return typeof t.text!=`string`||t.text.length===0?Response.json({error:`Text parts require a non-empty 'text' string.`,ok:!1},{status:400}):{type:`text`,text:t.text};if(t.type===`file`){if(typeof t.mediaType!=`string`||t.mediaType.length===0)return Response.json({error:`File parts require a non-empty 'mediaType' string.`,ok:!1},{status:400});if(typeof t.data!=`string`)return Response.json({error:`File parts require a 'data' string (base64, data URL, or URL).`,ok:!1},{status:400});if(hasInternalRefScheme(t.data))return Response.json({error:`File part 'data' must not use a framework-internal ref scheme.`,ok:!1},{status:400});let e={type:`file`,mediaType:t.mediaType,data:t.data};return typeof t.filename==`string`&&t.filename.length>0&&(e.filename=t.filename),e}return Response.json({error:`Unsupported message part type "${String(t.type)}". Use 'text' or 'file'.`,ok:!1},{status:400})}function checkUploadPolicy(e,t){if(!e.message)return null;let n=collectUploadPolicyViolations(e.message,t);if(n.length===0)return null;let[r]=n;if(!r)return null;let i=r.kind===`too-large`?413:415;return Response.json({error:formatUploadPolicyViolation(r),ok:!1,violations:n.map(e=>e.kind===`too-large`?{byteLength:e.byteLength,filename:e.filename,kind:e.kind,limit:e.limit,mediaType:e.mediaType}:{allowedMediaTypes:e.allowedMediaTypes,filename:e.filename,kind:e.kind,mediaType:e.mediaType})},{status:i})}function parseInputResponses(e){if(e===void 0)return;if(!Array.isArray(e)||e.length===0)return Response.json({error:`Expected 'inputResponses' to be a non-empty array.`,ok:!1},{status:400});let t=e.filter(isInputResponse);return t.length===e.length?t:Response.json({error:`Expected every 'inputResponses' entry to match the HITL response schema.`,ok:!1},{status:400})}function mergeContext(e,t){return e===void 0?t:t===void 0?e:[...e,...t]}function parseClientContextField(e){if(e!==void 0){if(typeof e==`string`)return e.length>0?[toClientContextMessage(e)]:void 0;if(Array.isArray(e))return e.length===0?void 0:e.every(e=>typeof e==`string`&&e.length>0)?e.map(e=>toClientContextMessage(e)):Response.json({error:`Expected 'clientContext' array entries to be non-empty strings.`,ok:!1},{status:400});if(typeof e!=`object`||!e)return Response.json({error:`Expected 'clientContext' to be a string, string array, or JSON object.`,ok:!1},{status:400});try{let t=parseJsonObject(e);return[toClientContextMessage(JSON.stringify(t))]}catch{return Response.json({error:`Expected 'clientContext' to be a JSON-serializable object.`,ok:!1},{status:400})}}}function toClientContextMessage(e){return`Client context:
|
|
2
|
-
${e}`}function parseStartIndex(e){let t=new URL(e.url).searchParams.get(`startIndex`);if(t===null)return;let n=Number
|
|
2
|
+
${e}`}function parseStartIndex(e){let t=new URL(e.url).searchParams.get(`startIndex`);if(t===null)return;let n=Number(t);return!/^-?\d+$/.test(t)||!Number.isSafeInteger(n)?Response.json({error:`Expected startIndex to be an integer.`,ok:!1},{status:400}):n}function serializeAsNdjson(e){let t=new TextEncoder;return e.pipeThrough(new TransformStream({transform(e,n){n.enqueue(t.encode(`${JSON.stringify(e)}\n`))}}))}export{defaultEveAuth,eveChannel};
|
|
@@ -88,6 +88,7 @@ export interface GitHubChannelEvents {
|
|
|
88
88
|
readonly "session.failed"?: GitHubSessionFailedHandler;
|
|
89
89
|
readonly "session.waiting"?: GitHubEventHandler<"session.waiting">;
|
|
90
90
|
readonly "turn.completed"?: GitHubEventHandler<"turn.completed">;
|
|
91
|
+
readonly "turn.cancelled"?: GitHubEventHandler<"turn.cancelled">;
|
|
91
92
|
readonly "turn.failed"?: GitHubEventHandler<"turn.failed">;
|
|
92
93
|
readonly "turn.started"?: GitHubEventHandler<"turn.started">;
|
|
93
94
|
}
|
|
@@ -102,6 +102,7 @@ export interface LinearChannelEvents {
|
|
|
102
102
|
readonly "input.requested"?: LinearEventHandler<"input.requested">;
|
|
103
103
|
readonly "turn.failed"?: LinearEventHandler<"turn.failed">;
|
|
104
104
|
readonly "turn.completed"?: LinearEventHandler<"turn.completed">;
|
|
105
|
+
readonly "turn.cancelled"?: LinearEventHandler<"turn.cancelled">;
|
|
105
106
|
readonly "session.failed"?: LinearSessionFailedHandler;
|
|
106
107
|
readonly "session.completed"?: LinearEventHandler<"session.completed">;
|
|
107
108
|
readonly "session.waiting"?: LinearEventHandler<"session.waiting">;
|
|
@@ -256,6 +256,7 @@ export interface SlackChannelEvents {
|
|
|
256
256
|
readonly "input.requested"?: SlackEventHandler<"input.requested">;
|
|
257
257
|
readonly "turn.failed"?: SlackEventHandler<"turn.failed">;
|
|
258
258
|
readonly "turn.completed"?: SlackEventHandler<"turn.completed">;
|
|
259
|
+
readonly "turn.cancelled"?: SlackEventHandler<"turn.cancelled">;
|
|
259
260
|
readonly "session.failed"?: SlackSessionFailedHandler;
|
|
260
261
|
readonly "session.completed"?: SlackEventHandler<"session.completed">;
|
|
261
262
|
readonly "session.waiting"?: SlackEventHandler<"session.waiting">;
|
|
@@ -99,6 +99,7 @@ export interface TeamsChannelEvents {
|
|
|
99
99
|
readonly "input.requested"?: TeamsEventHandler<"input.requested">;
|
|
100
100
|
readonly "turn.failed"?: TeamsEventHandler<"turn.failed">;
|
|
101
101
|
readonly "turn.completed"?: TeamsEventHandler<"turn.completed">;
|
|
102
|
+
readonly "turn.cancelled"?: TeamsEventHandler<"turn.cancelled">;
|
|
102
103
|
readonly "session.failed"?: TeamsSessionFailedHandler;
|
|
103
104
|
readonly "session.completed"?: TeamsEventHandler<"session.completed">;
|
|
104
105
|
readonly "session.waiting"?: TeamsEventHandler<"session.waiting">;
|
|
@@ -73,6 +73,7 @@ export interface TelegramChannelEvents {
|
|
|
73
73
|
readonly "input.requested"?: TelegramEventHandler<"input.requested">;
|
|
74
74
|
readonly "turn.failed"?: TelegramEventHandler<"turn.failed">;
|
|
75
75
|
readonly "turn.completed"?: TelegramEventHandler<"turn.completed">;
|
|
76
|
+
readonly "turn.cancelled"?: TelegramEventHandler<"turn.cancelled">;
|
|
76
77
|
readonly "session.failed"?: TelegramSessionFailedHandler;
|
|
77
78
|
readonly "session.completed"?: TelegramEventHandler<"session.completed">;
|
|
78
79
|
readonly "session.waiting"?: TelegramEventHandler<"session.waiting">;
|
|
@@ -94,6 +94,7 @@ export interface TwilioChannelEvents {
|
|
|
94
94
|
readonly "input.requested"?: TwilioEventHandler<"input.requested">;
|
|
95
95
|
readonly "turn.failed"?: TwilioEventHandler<"turn.failed">;
|
|
96
96
|
readonly "turn.completed"?: TwilioEventHandler<"turn.completed">;
|
|
97
|
+
readonly "turn.cancelled"?: TwilioEventHandler<"turn.cancelled">;
|
|
97
98
|
readonly "session.failed"?: TwilioSessionFailedHandler;
|
|
98
99
|
readonly "session.completed"?: TwilioEventHandler<"session.completed">;
|
|
99
100
|
readonly "session.waiting"?: TwilioEventHandler<"session.waiting">;
|
|
@@ -105,10 +105,10 @@ export interface Agent {
|
|
|
105
105
|
* existing session. Used by the framework's HTTP session-stream route and by
|
|
106
106
|
* any user-authored route that exposes an event-streaming endpoint.
|
|
107
107
|
*
|
|
108
|
-
*
|
|
109
|
-
* consumed
|
|
110
|
-
* the
|
|
111
|
-
* the
|
|
108
|
+
* Nonnegative `options.startIndex` values skip events the caller has already
|
|
109
|
+
* consumed. Negative values read relative to the current tail (`-1` starts
|
|
110
|
+
* at the latest event). The framework HTTP session-stream route forwards
|
|
111
|
+
* the `startIndex` query parameter unchanged.
|
|
112
112
|
*/
|
|
113
113
|
getEventStream(sessionId: string, options?: GetEventStreamOptions): Promise<ReadableStream<HandleMessageStreamEvent>>;
|
|
114
114
|
}
|
|
@@ -172,6 +172,7 @@ export interface ChannelEvents<TCtx = void> {
|
|
|
172
172
|
readonly "input.requested"?: ChannelEventHandler<"input.requested", TCtx>;
|
|
173
173
|
readonly "turn.failed"?: ChannelEventHandler<"turn.failed", TCtx>;
|
|
174
174
|
readonly "turn.completed"?: ChannelEventHandler<"turn.completed", TCtx>;
|
|
175
|
+
readonly "turn.cancelled"?: ChannelEventHandler<"turn.cancelled", TCtx>;
|
|
175
176
|
readonly "session.failed"?: ChannelSessionFailedHandler<TCtx>;
|
|
176
177
|
readonly "session.completed"?: ChannelEventHandler<"session.completed", TCtx>;
|
|
177
178
|
readonly "session.waiting"?: ChannelEventHandler<"session.waiting", TCtx>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CHANNEL_SENTINEL}from"#channel/compiled-channel.js";import{defaultDeliverResult}from"#channel/adapter.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{normalizeChannelCors}from"#channel/cors.js";import{HTTP_ADAPTER_KIND}from"#channel/http.js";import{DELETE,GET,PATCH,POST,PUT,WS}from"#channel/routes.js";const DISABLED_ROUTE_SENTINEL_KIND=`eve:disabled-channel`;function disableRoute(){return{kind:DISABLED_ROUTE_SENTINEL_KIND}}function isDisabledRouteSentinel(e){return typeof e==`object`&&!!e&&e.kind===DISABLED_ROUTE_SENTINEL_KIND}function defineChannel(t){let n=buildAdapter(t),i=normalizeChannelCors(t.cors);return{__kind:CHANNEL_SENTINEL,routes:t.routes,adapter:n,cors:i,receive:t.receive}}function buildAdapter(e){let r=e.state!=null,a=e.context!=null,o=e.fetchFile!==void 0,s=e.metadata,c=r||a||s!==void 0,l={},u=!1,d=
|
|
1
|
+
import{CHANNEL_SENTINEL}from"#channel/compiled-channel.js";import{defaultDeliverResult}from"#channel/adapter.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{normalizeChannelCors}from"#channel/cors.js";import{HTTP_ADAPTER_KIND}from"#channel/http.js";import{DELETE,GET,PATCH,POST,PUT,WS}from"#channel/routes.js";const DISABLED_ROUTE_SENTINEL_KIND=`eve:disabled-channel`;function disableRoute(){return{kind:DISABLED_ROUTE_SENTINEL_KIND}}function isDisabledRouteSentinel(e){return typeof e==`object`&&!!e&&e.kind===DISABLED_ROUTE_SENTINEL_KIND}function defineChannel(t){let n=buildAdapter(t),i=normalizeChannelCors(t.cors);return{__kind:CHANNEL_SENTINEL,routes:t.routes,adapter:n,cors:i,receive:t.receive}}const eventTypes=Object.keys({"turn.started":null,"actions.requested":null,"action.result":null,"message.completed":null,"message.appended":null,"reasoning.appended":null,"reasoning.completed":null,"input.requested":null,"turn.failed":null,"turn.completed":null,"turn.cancelled":null,"session.failed":null,"session.completed":null,"session.waiting":null,"authorization.required":null,"authorization.completed":null});function buildAdapter(e){let r=e.state!=null,a=e.context!=null,o=e.fetchFile!==void 0,s=e.metadata,c=r||a||s!==void 0,l={},u=!1,d=e.events;for(let e of eventTypes){let t=d?.[e];t&&(u=!0,l[e]=(r,i)=>{let a={...i,continuationToken:i.session?.continuationToken??``,setContinuationToken:e=>i.session?.setContinuationToken(e)};return e===`session.failed`?t(r,a):t(r,a,buildCallbackContext())})}return!c&&!u&&!o?{kind:e.kindHint??HTTP_ADAPTER_KIND}:{kind:e.kindHint??`defineChannel`,state:r?{...e.state}:{},fetchFile:e.fetchFile,instrumentation:s===void 0?void 0:{metadata(e){return s(e)}},createAdapterContext(t){let n=t.state,r=t.session;return{...a?e.context(n,r):{},state:n,ctx:t.ctx,session:r}},deliver(e){return defaultDeliverResult(e)},...l}}export{DELETE,GET,PATCH,POST,PUT,WS,defineChannel,disableRoute,isDisabledRouteSentinel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{MockLanguageModelV3}from"ai/test";import{FINAL_OUTPUT_TOOL_NAME}from"#runtime/framework-tools/final-output.js";import{BOOTSTRAP_RUNTIME_MODEL_ID,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT}from"#runtime/agent/bootstrap.js";import{createBootstrapGenerateResult,createBootstrapStreamResult,estimateTokenCount,getLastUserPromptText,getPromptContentText,getPromptText}from"#runtime/agent/bootstrap-model-utils.js";import{createMockAuthoredToolInput,formatToolOutput,resolveMockFixtureToken,resolveWeatherCity}from"#runtime/agent/mock-model-fixtures.js";import{findRelevantSkill,getActivatedSkillIds,getAvailableSkills}from"#runtime/agent/mock-model-skill-selection.js";import{createJsonSchemaSample}from"#runtime/agent/mock-structured-output.js";const authoredRuntimeModelMocks=new Map,bootstrapWeatherPayloadSchema=z.object({city:z.string(),condition:z.string(),summary:z.string(),temperatureF:z.number().finite()}).strict();function shouldMockAuthoredRuntimeModels(){return process.env.NODE_ENV===`test`||process.env.EVE_MOCK_AUTHORED_MODELS===`1`}function createMockAuthoredRuntimeModel(e){let t=authoredRuntimeModelMocks.get(e.id);if(t!==void 0)return t;let r=new MockLanguageModelV3({modelId:e.id,provider:`eve-runtime-mock`,doGenerate:async t=>createMockModelResult(t,e.id),doStream:async t=>createBootstrapStreamResult(createMockModelResult(t,e.id))});return authoredRuntimeModelMocks.set(e.id,r),r}function createMockModelResult(e,t){let n=getLastAuthoredToolResult(e.prompt);if(n!==null){let r=createFollowUpToolCallResult({modelId:t,options:e,result:n});if(r!==null)return r}else{let n=createSkillLoadResult(e.prompt,t)??createAuthoredToolCallResult(e,t);if(n!==null)return n}let r=createFinalOutputResult(e,t);if(r!==null)return r;let i=n===null?createAssistantMessage(e.prompt):formatToolResultReply(n,e.prompt);return createBootstrapGenerateResult({inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i),text:i})}function createFinalOutputResult(e,t){let n=getAvailableTools(e).find(e=>e.name===FINAL_OUTPUT_TOOL_NAME);if(n===void 0)return null;let i=createJsonSchemaSample(n.inputSchema);return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(JSON.stringify(i)),toolCallId:createToolCallId(FINAL_OUTPUT_TOOL_NAME),toolName:FINAL_OUTPUT_TOOL_NAME})}function resolveMockAuthoredRuntimeModel(e){return!shouldMockAuthoredRuntimeModels()||e.id===BOOTSTRAP_RUNTIME_MODEL_ID?null:createMockAuthoredRuntimeModel(e)}function createSkillLoadResult(e,n){let r=getLastUserPromptText(e);if(r===null||getActivatedSkillIds(e).length>0)return null;let i=findRelevantSkill(getAvailableSkills(e),r);return i===null?null:createToolCallGenerateResult({input:{skill:i.name},inputTokens:estimateTokenCount(getPromptText(e)),modelId:n,outputTokens:estimateTokenCount(i.name),toolCallId:`call_load_skill`,toolName:LOAD_SKILL_TOOL_NAME})}function createAuthoredToolCallResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=findRelevantTool(getAvailableTools(e),n);if(r===null)return null;let i=createMockAuthoredToolInput(r,n,resolveWeatherCity(n));return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(Object.values(i).join(` `)),toolCallId:createToolCallId(r.name),toolName:r.name})}function createFollowUpToolCallResult(e){let t=findNextExplicitToolAfterResult({previousToolName:e.result.toolName,prompt:e.options.prompt,tools:getAvailableTools(e.options)});if(t===null)return null;let n=createFollowUpToolInput(e.result.output);return n===null?null:createToolCallGenerateResult({input:n,inputTokens:estimateTokenCount(getPromptText(e.options.prompt)),modelId:e.modelId,outputTokens:estimateTokenCount(Object.values(n).join(` `)),toolCallId:createToolCallId(t.name),toolName:t.name})}function createAssistantMessage(e){let t=getLastUserPromptText(e)??`Hello from eve`,n=getSystemPromptLabels(e),r=resolveSystemProbe(e),i=resolveMockFixtureToken(e);return i===null?n.length>0?r===null?`Bootstrap reply [${n.join(`, `)}]: ${t}`:`Bootstrap reply [${n.join(`, `)}; probe=${r}]: ${t}`:r===null?`Bootstrap reply: ${t}`:`Bootstrap reply [probe=${r}]: ${t}`:i}function formatToolResultReply(e,t){if(e.isError)return`Local weather tool failed: ${formatToolOutput(e.output)}`;if(isWeatherPayload(e.output))return`Used local weather tool for ${e.output.city}: ${e.output.condition}, ${e.output.temperatureF}F. ${e.output.summary}`;let n=getLastUserPromptText(t)??`Hello from eve`;return`Used ${e.toolName} for "${n}": ${formatToolOutput(e.output)}`}function createToolCallGenerateResult(e){return{content:[{input:JSON.stringify(e.input),toolCallId:e.toolCallId,toolName:e.toolName,type:`tool-call`}],finishReason:{raw:void 0,unified:`tool-calls`},response:{id:`bootstrap-response`,modelId:e.modelId,timestamp:new Date(`2026-03-16T00:00:00.000Z`)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:e.inputTokens,total:e.inputTokens},outputTokens:{reasoning:0,text:e.outputTokens,total:e.outputTokens}},warnings:[]}}function getAvailableTools(e){return(e.tools??[]).flatMap(e=>e.type===`function`?[{description:e.description,inputSchema:`inputSchema`in e?e.inputSchema:void 0,name:e.name,outputSchema:`outputSchema`in e?e.outputSchema:void 0}]:[])}function getLastAuthoredToolResult(e){for(let n of[...e].reverse()){if(n.role===`user`)return null;if(!(n.role!==`tool`&&n.role!==`assistant`)){for(let e of[...n.content].reverse())if(!(typeof e==`string`||e.type!==`tool-result`)&&e.toolName!==LOAD_SKILL_TOOL_NAME)return{isError:e.output.type===`error-json`||e.output.type===`error-text`||e.output.type===`execution-denied`,output:e.output.type===`execution-denied`?{reason:e.output.reason??null,type:e.output.type}:e.output.value,toolCallId:e.toolCallId,toolName:e.toolName}}}return null}function findNextExplicitToolAfterResult(e){let t=getLastUserPromptText(e.prompt);if(t===null)return null;let n=normalizeText(t),r=n.indexOf(normalizeText(e.previousToolName));return r<0?null:e.tools.filter(t=>t.name!==e.previousToolName).flatMap(e=>{let t=n.indexOf(normalizeText(e.name),r+1);return t<0?[]:[{index:t,tool:e}]}).sort((e,t)=>e.index-t.index)[0]?.tool??null}function createFollowUpToolInput(e){return isRecord(e)&&typeof e.stepKey==`string`?{stepKey:e.stepKey}:null}function getSystemPromptLabels(e){let t=e.filter(e=>e.role===`system`);if(t.length===0)return[];let n=t.flatMap(e=>{let t=getPromptContentText(e.content);if(t.startsWith(`Available skills
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{MockLanguageModelV3}from"ai/test";import{FINAL_OUTPUT_TOOL_NAME}from"#runtime/framework-tools/final-output.js";import{BOOTSTRAP_RUNTIME_MODEL_ID,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT}from"#runtime/agent/bootstrap.js";import{createBootstrapGenerateResult,createBootstrapStreamResult,estimateTokenCount,getLastUserPromptText,getPromptContentText,getPromptText}from"#runtime/agent/bootstrap-model-utils.js";import{createMockAuthoredToolInput,formatToolOutput,resolveMockFixtureToken,resolveWeatherCity}from"#runtime/agent/mock-model-fixtures.js";import{findRelevantSkill,getActivatedSkillIds,getAvailableSkills}from"#runtime/agent/mock-model-skill-selection.js";import{createJsonSchemaSample}from"#runtime/agent/mock-structured-output.js";const authoredRuntimeModelMocks=new Map,bootstrapWeatherPayloadSchema=z.object({city:z.string(),condition:z.string(),summary:z.string(),temperatureF:z.number().finite()}).strict();function shouldMockAuthoredRuntimeModels(){return process.env.NODE_ENV===`test`||process.env.EVE_MOCK_AUTHORED_MODELS===`1`}function createMockAuthoredRuntimeModel(e){let t=authoredRuntimeModelMocks.get(e.id);if(t!==void 0)return t;let r=new MockLanguageModelV3({modelId:e.id,provider:`eve-runtime-mock`,doGenerate:async t=>createMockModelResult(t,e.id),doStream:async t=>createBootstrapStreamResult(createMockModelResult(t,e.id))});return authoredRuntimeModelMocks.set(e.id,r),r}function createMockModelResult(e,t){let n=getLastAuthoredToolResult(e.prompt);if(n!==null){let r=createFollowUpToolCallResult({modelId:t,options:e,result:n});if(r!==null)return r}else{let n=createSubagentDelegationResult(e,t)??createSkillLoadResult(e.prompt,t)??createAuthoredToolCallResult(e,t);if(n!==null)return n}let r=createFinalOutputResult(e,t);if(r!==null)return r;let i=n===null?createAssistantMessage(e.prompt):formatToolResultReply(n,e.prompt);return createBootstrapGenerateResult({inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i),text:i})}function createFinalOutputResult(e,t){let n=getAvailableTools(e).find(e=>e.name===FINAL_OUTPUT_TOOL_NAME);if(n===void 0)return null;let i=createJsonSchemaSample(n.inputSchema);return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(JSON.stringify(i)),toolCallId:createToolCallId(FINAL_OUTPUT_TOOL_NAME),toolName:FINAL_OUTPUT_TOOL_NAME})}function resolveMockAuthoredRuntimeModel(e){return!shouldMockAuthoredRuntimeModels()||e.id===BOOTSTRAP_RUNTIME_MODEL_ID?null:createMockAuthoredRuntimeModel(e)}function createSkillLoadResult(e,n){let r=getLastUserPromptText(e);if(r===null||getActivatedSkillIds(e).length>0)return null;let i=findRelevantSkill(getAvailableSkills(e),r);return i===null?null:createToolCallGenerateResult({input:{skill:i.name},inputTokens:estimateTokenCount(getPromptText(e)),modelId:n,outputTokens:estimateTokenCount(i.name),toolCallId:`call_load_skill`,toolName:LOAD_SKILL_TOOL_NAME})}const SUBAGENT_TOOL_NAME=`agent`,SUBAGENT_DELEGATION_DIRECTIVE=/\bdelegate\s+to\s+a\s+subagent\s*:\s*(.+)$/iu;function createSubagentDelegationResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=SUBAGENT_DELEGATION_DIRECTIVE.exec(n);if(r?.[1]===void 0||getAvailableTools(e).find(e=>e.name===SUBAGENT_TOOL_NAME)===void 0)return null;let i={message:r[1].trim()};return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i.message),toolCallId:createToolCallId(SUBAGENT_TOOL_NAME),toolName:SUBAGENT_TOOL_NAME})}function createAuthoredToolCallResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=findRelevantTool(getAvailableTools(e),n);if(r===null)return null;let i=createMockAuthoredToolInput(r,n,resolveWeatherCity(n));return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(Object.values(i).join(` `)),toolCallId:createToolCallId(r.name),toolName:r.name})}function createFollowUpToolCallResult(e){let t=findNextExplicitToolAfterResult({previousToolName:e.result.toolName,prompt:e.options.prompt,tools:getAvailableTools(e.options)});if(t===null)return null;let n=createFollowUpToolInput(e.result.output);return n===null?null:createToolCallGenerateResult({input:n,inputTokens:estimateTokenCount(getPromptText(e.options.prompt)),modelId:e.modelId,outputTokens:estimateTokenCount(Object.values(n).join(` `)),toolCallId:createToolCallId(t.name),toolName:t.name})}function createAssistantMessage(e){let t=getLastUserPromptText(e)??`Hello from eve`,n=getSystemPromptLabels(e),r=resolveSystemProbe(e),i=resolveMockFixtureToken(e);return i===null?n.length>0?r===null?`Bootstrap reply [${n.join(`, `)}]: ${t}`:`Bootstrap reply [${n.join(`, `)}; probe=${r}]: ${t}`:r===null?`Bootstrap reply: ${t}`:`Bootstrap reply [probe=${r}]: ${t}`:i}function formatToolResultReply(e,t){if(e.isError)return`Local weather tool failed: ${formatToolOutput(e.output)}`;if(isWeatherPayload(e.output))return`Used local weather tool for ${e.output.city}: ${e.output.condition}, ${e.output.temperatureF}F. ${e.output.summary}`;let n=getLastUserPromptText(t)??`Hello from eve`;return`Used ${e.toolName} for "${n}": ${formatToolOutput(e.output)}`}function createToolCallGenerateResult(e){return{content:[{input:JSON.stringify(e.input),toolCallId:e.toolCallId,toolName:e.toolName,type:`tool-call`}],finishReason:{raw:void 0,unified:`tool-calls`},response:{id:`bootstrap-response`,modelId:e.modelId,timestamp:new Date(`2026-03-16T00:00:00.000Z`)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:e.inputTokens,total:e.inputTokens},outputTokens:{reasoning:0,text:e.outputTokens,total:e.outputTokens}},warnings:[]}}function getAvailableTools(e){return(e.tools??[]).flatMap(e=>e.type===`function`?[{description:e.description,inputSchema:`inputSchema`in e?e.inputSchema:void 0,name:e.name,outputSchema:`outputSchema`in e?e.outputSchema:void 0}]:[])}function getLastAuthoredToolResult(e){for(let n of[...e].reverse()){if(n.role===`user`)return null;if(!(n.role!==`tool`&&n.role!==`assistant`)){for(let e of[...n.content].reverse())if(!(typeof e==`string`||e.type!==`tool-result`)&&e.toolName!==LOAD_SKILL_TOOL_NAME)return{isError:e.output.type===`error-json`||e.output.type===`error-text`||e.output.type===`execution-denied`,output:e.output.type===`execution-denied`?{reason:e.output.reason??null,type:e.output.type}:e.output.value,toolCallId:e.toolCallId,toolName:e.toolName}}}return null}function findNextExplicitToolAfterResult(e){let t=getLastUserPromptText(e.prompt);if(t===null)return null;let n=normalizeText(t),r=n.indexOf(normalizeText(e.previousToolName));return r<0?null:e.tools.filter(t=>t.name!==e.previousToolName).flatMap(e=>{let t=n.indexOf(normalizeText(e.name),r+1);return t<0?[]:[{index:t,tool:e}]}).sort((e,t)=>e.index-t.index)[0]?.tool??null}function createFollowUpToolInput(e){return isRecord(e)&&typeof e.stepKey==`string`?{stepKey:e.stepKey}:null}function getSystemPromptLabels(e){let t=e.filter(e=>e.role===`system`);if(t.length===0)return[];let n=t.flatMap(e=>{let t=getPromptContentText(e.content);if(t.startsWith(`Available skills
|
|
2
2
|
`))return[];let n=t.split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(e=>e.length>0),r=[];for(let e of n){if(e===BOOTSTRAP_RUNTIME_SYSTEM_PROMPT||e===`Available skills`)continue;let t=/^System \((.+)\)$/.exec(e);if(t?.[1]){r.push(t[1]);continue}let n=/^Skill \((.+)\)$/.exec(e);n?.[1]&&r.push(n[1])}if(r.length>0)return r;let i=n.find(e=>e!==BOOTSTRAP_RUNTIME_SYSTEM_PROMPT&&e!==`Available skills`);return i===void 0?[]:[i]});return[...new Set(n)]}function findRelevantTool(e,n){let r=normalizeText(n),i=e.find(e=>e.name!==`agent`&&e.name!==LOAD_SKILL_TOOL_NAME&&r.includes(normalizeText(e.name)));return i===void 0?/\b(forecast|temperature|weather|wind|rain|snow)\b/u.test(r)?e.find(e=>/\b(forecast|temperature|weather|wind|rain|snow)\b/u.test(normalizeText(`${e.name} ${e.description??``}`)))??null:null:i}function normalizeText(e){return e.toLowerCase().replace(/[^a-z0-9]+/gu,` `).trim()}function createToolCallId(e){return`call_${e.toLowerCase().replace(/[^a-z0-9]+/gu,`_`).replace(/^_+|_+$/gu,``)||`tool`}`}function resolveSystemProbe(e){let t=e.filter(e=>e.role===`system`).map(e=>getPromptContentText(e.content)).join(`
|
|
4
4
|
`);return/hmr-probe:\s*([^\n]+)/iu.exec(t)?.[1]?.trim()||null}function isWeatherPayload(e){return bootstrapWeatherPayloadSchema.safeParse(e).success}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{createMockAuthoredRuntimeModel,resolveMockAuthoredRuntimeModel,shouldMockAuthoredRuntimeModels};
|
|
@@ -29,6 +29,14 @@ export interface RuntimeDiskCompiledArtifactsSource {
|
|
|
29
29
|
* while sandbox state should remain scoped to the authored application.
|
|
30
30
|
*/
|
|
31
31
|
readonly sandboxAppRoot?: string;
|
|
32
|
+
/**
|
|
33
|
+
* How this source is recorded in durable Workflow payloads.
|
|
34
|
+
* `"development-generation"` stores a logical selector resolved from the
|
|
35
|
+
* delivery's generation context — valid only where deliveries install
|
|
36
|
+
* that context (the parent-owned dev World). Absent, the source is stored
|
|
37
|
+
* verbatim, pinning durable work to this exact path.
|
|
38
|
+
*/
|
|
39
|
+
readonly durableReference?: "development-generation";
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* Creates the bundled compiled-artifact source.
|
|
@@ -38,6 +46,7 @@ export declare function createBundledRuntimeCompiledArtifactsSource(): RuntimeBu
|
|
|
38
46
|
* Creates the disk-backed compiled-artifact source for one authored app root.
|
|
39
47
|
*/
|
|
40
48
|
export declare function createDiskRuntimeCompiledArtifactsSource(appRoot: string, options?: {
|
|
49
|
+
readonly durableReference?: "development-generation";
|
|
41
50
|
readonly moduleMapLoaderPath?: string;
|
|
42
51
|
readonly sandboxAppRoot?: string;
|
|
43
52
|
}): RuntimeDiskCompiledArtifactsSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function createBundledRuntimeCompiledArtifactsSource(){return{kind:`bundled`}}function createDiskRuntimeCompiledArtifactsSource(e,t={}){return t.moduleMapLoaderPath!==void 0||t.sandboxAppRoot!==void 0?{appRoot:e,kind:`disk`,moduleMapLoaderPath:t.moduleMapLoaderPath,sandboxAppRoot:t.sandboxAppRoot}:{appRoot:e,kind:`disk`}}function getRuntimeCompiledArtifactsAppRoot(e){return e.kind===`disk`?e.appRoot:void 0}function getRuntimeCompiledArtifactsSandboxAppRoot(e){return e.kind===`disk`?e.sandboxAppRoot??e.appRoot:void 0}function getRuntimeCompiledArtifactsCacheKey(e){return e.kind===`disk`?e.moduleMapLoaderPath===void 0?`disk:${e.appRoot}`:`disk:${e.appRoot}:authored-source:${e.moduleMapLoaderPath}`:`bundled`}export{createBundledRuntimeCompiledArtifactsSource,createDiskRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsAppRoot,getRuntimeCompiledArtifactsCacheKey,getRuntimeCompiledArtifactsSandboxAppRoot};
|
|
1
|
+
function createBundledRuntimeCompiledArtifactsSource(){return{kind:`bundled`}}function createDiskRuntimeCompiledArtifactsSource(e,t={}){return t.moduleMapLoaderPath!==void 0||t.sandboxAppRoot!==void 0||t.durableReference!==void 0?{appRoot:e,durableReference:t.durableReference,kind:`disk`,moduleMapLoaderPath:t.moduleMapLoaderPath,sandboxAppRoot:t.sandboxAppRoot}:{appRoot:e,kind:`disk`}}function getRuntimeCompiledArtifactsAppRoot(e){return e.kind===`disk`?e.appRoot:void 0}function getRuntimeCompiledArtifactsSandboxAppRoot(e){return e.kind===`disk`?e.sandboxAppRoot??e.appRoot:void 0}function getRuntimeCompiledArtifactsCacheKey(e){return e.kind===`disk`?e.moduleMapLoaderPath===void 0?`disk:${e.appRoot}`:`disk:${e.appRoot}:authored-source:${e.moduleMapLoaderPath}`:`bundled`}export{createBundledRuntimeCompiledArtifactsSource,createDiskRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsAppRoot,getRuntimeCompiledArtifactsCacheKey,getRuntimeCompiledArtifactsSandboxAppRoot};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts-source.js";
|
|
2
|
+
interface DevelopmentCompiledArtifactsSelector {
|
|
3
|
+
readonly kind: "development";
|
|
4
|
+
}
|
|
5
|
+
export type DurableCompiledArtifactsSource = RuntimeCompiledArtifactsSource | DevelopmentCompiledArtifactsSelector;
|
|
6
|
+
export declare function serializeDurableCompiledArtifactsSource(source: RuntimeCompiledArtifactsSource): DurableCompiledArtifactsSource;
|
|
7
|
+
export declare function resolveDurableCompiledArtifactsSource(source: DurableCompiledArtifactsSource): RuntimeCompiledArtifactsSource;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getDevelopmentWorkflowGeneration}from"#internal/workflow/development-generation-context.js";function serializeDurableCompiledArtifactsSource(e){return e.kind===`disk`&&e.durableReference===`development-generation`?{kind:`development`}:e}function resolveDurableCompiledArtifactsSource(t){if(t.kind!==`development`)return t;let n=getDevelopmentWorkflowGeneration();if(n===void 0)throw Error(`A development Workflow generation selector was resumed outside a generation-bound delivery.`);return n.source}export{resolveDurableCompiledArtifactsSource,serializeDurableCompiledArtifactsSource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getAdapterKind}from"#channel/adapter.js";import{ContextKey}from"#context/key.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{deserializeRuntimeAdapter}from"#runtime/channels/registry.js";const ChannelKey=new ContextKey(`eve.channel`,{codec:{serialize(t){return{kind:getAdapterKind(t),state:t.state?{...t.state}:{}}},deserialize(e,t){let n=t.get(BundleKey);if(n===void 0)throw Error(`Cannot deserialize "eve.channel" before "eve.bundle". The runtime bundle must be present in context.`);return deserializeRuntimeAdapter(n.adapterRegistry,e)}}}),BundleKey=new ContextKey(`eve.bundle`,{codec:{serialize:e=>({nodeId:e.nodeId,source:e.compiledArtifactsSource}),deserialize:e=>{let{source:t,nodeId:r}=e;return getCompiledRuntimeAgentBundle({compiledArtifactsSource:t,nodeId:r})}}});export{BundleKey,ChannelKey};
|
|
1
|
+
import{getAdapterKind}from"#channel/adapter.js";import{ContextKey}from"#context/key.js";import{getCompiledRuntimeAgentBundle}from"#runtime/sessions/compiled-agent-cache.js";import{resolveDurableCompiledArtifactsSource,serializeDurableCompiledArtifactsSource}from"#runtime/durable-compiled-artifacts-source.js";import{deserializeRuntimeAdapter}from"#runtime/channels/registry.js";const ChannelKey=new ContextKey(`eve.channel`,{codec:{serialize(t){return{kind:getAdapterKind(t),state:t.state?{...t.state}:{}}},deserialize(e,t){let n=t.get(BundleKey);if(n===void 0)throw Error(`Cannot deserialize "eve.channel" before "eve.bundle". The runtime bundle must be present in context.`);return deserializeRuntimeAdapter(n.adapterRegistry,e)}}}),BundleKey=new ContextKey(`eve.bundle`,{codec:{serialize:e=>({nodeId:e.nodeId,source:serializeDurableCompiledArtifactsSource(e.compiledArtifactsSource)}),deserialize:e=>{let{source:t,nodeId:r}=e;return getCompiledRuntimeAgentBundle({compiledArtifactsSource:resolveDurableCompiledArtifactsSource(t),nodeId:r})}}});export{BundleKey,ChannelKey};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reads the dev server's runtime-artifacts revision — an opaque token that
|
|
3
3
|
* changes whenever the authored-source watcher recompiles (HMR). Consumers
|
|
4
|
-
* compare successive values to detect "the agent changed under me"
|
|
5
|
-
*
|
|
4
|
+
* compare successive values to detect "the agent changed under me" and
|
|
5
|
+
* refresh the development UI before the next turn.
|
|
6
6
|
*
|
|
7
7
|
* Never throws: any transport failure, non-2xx response, or malformed body
|
|
8
8
|
* resolves to `undefined`, so callers treat "unknown" and "unreachable" the
|
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import type { UserContent } from "ai";
|
|
2
|
-
import type { ClientSession } from "#client/session.js";
|
|
3
2
|
import type { InputResponse } from "#runtime/input/types.js";
|
|
4
3
|
/**
|
|
5
|
-
* Tracks local dev runtime-artifact revisions
|
|
6
|
-
*
|
|
7
|
-
* input-response resumes.
|
|
4
|
+
* Tracks local dev runtime-artifact revisions so callers can refresh their
|
|
5
|
+
* presentation before delivering the next turn.
|
|
8
6
|
*/
|
|
9
|
-
export interface
|
|
7
|
+
export interface DevelopmentRuntimeArtifactRefresher {
|
|
10
8
|
/**
|
|
11
9
|
* Clears the remembered runtime-artifact revision.
|
|
12
10
|
*/
|
|
13
11
|
clear(): void;
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
13
|
+
* Refreshes the artifact revision before a normal turn.
|
|
16
14
|
*/
|
|
17
15
|
refresh(input: {
|
|
18
|
-
readonly createSession: () => ClientSession;
|
|
19
16
|
readonly inputResponses?: readonly InputResponse[];
|
|
20
17
|
readonly message?: string | UserContent;
|
|
21
18
|
readonly onRuntimeArtifactsChanged?: (change: DevelopmentRuntimeArtifactChange) => void | Promise<void>;
|
|
22
|
-
|
|
23
|
-
}): Promise<ClientSession>;
|
|
19
|
+
}): Promise<void>;
|
|
24
20
|
/**
|
|
25
21
|
* Forces one rebuild after a local setup action wrote authored source.
|
|
26
22
|
*/
|
|
27
23
|
refreshAfterSourceChange(input: {
|
|
28
|
-
readonly createSession: () => ClientSession;
|
|
29
24
|
readonly onRuntimeArtifactsChanged?: (change: DevelopmentRuntimeArtifactChange) => void | Promise<void>;
|
|
30
|
-
|
|
31
|
-
}): Promise<ClientSession>;
|
|
25
|
+
}): Promise<void>;
|
|
32
26
|
/**
|
|
33
27
|
* Checks for a runtime-artifact revision change while the UI is idle.
|
|
34
28
|
*/
|
|
35
29
|
refreshIdle(input: {
|
|
36
|
-
readonly createSession: () => ClientSession;
|
|
37
30
|
readonly onRuntimeArtifactsChanged?: (change: DevelopmentRuntimeArtifactChange) => void | Promise<void>;
|
|
38
|
-
|
|
39
|
-
}): Promise<ClientSession>;
|
|
31
|
+
}): Promise<void>;
|
|
40
32
|
}
|
|
41
33
|
export interface DevelopmentRuntimeArtifactChange {
|
|
42
34
|
readonly previousRevision: string;
|
|
43
35
|
readonly revision: string;
|
|
44
36
|
}
|
|
45
37
|
/**
|
|
46
|
-
* Creates a revision-aware local dev
|
|
38
|
+
* Creates a revision-aware local dev runtime-artifact refresher.
|
|
47
39
|
*/
|
|
48
|
-
export declare function
|
|
40
|
+
export declare function createDevelopmentRuntimeArtifactRefresher(input: {
|
|
49
41
|
readonly serverUrl: string;
|
|
50
|
-
}):
|
|
42
|
+
}): DevelopmentRuntimeArtifactRefresher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isLocalDevelopmentServerUrl}from"#services/dev-client/local-host.js";import{readDevelopmentRuntimeArtifactsRevision,rebuildDevelopmentRuntimeArtifacts}from"#services/dev-client/runtime-artifacts.js";var
|
|
1
|
+
import{isLocalDevelopmentServerUrl}from"#services/dev-client/local-host.js";import{readDevelopmentRuntimeArtifactsRevision,rebuildDevelopmentRuntimeArtifacts}from"#services/dev-client/runtime-artifacts.js";var LocalDevelopmentRuntimeArtifactRefresher=class{#e;#t;#n;constructor(t){this.#e=isLocalDevelopmentServerUrl(t.serverUrl),this.#t=t.serverUrl}clear(){this.#n=void 0}async refresh(e){shouldRefreshRuntimeArtifactsForTurn(e)&&await this.#r({...e,rebuild:!0})}async refreshIdle(e){await this.#r({...e,rebuild:!1})}async refreshAfterSourceChange(e){await this.#r({...e,force:!0,rebuild:!0})}async#r(e){if(!this.#e)return;let n=(e.rebuild?await rebuildDevelopmentRuntimeArtifacts({force:e.force,serverUrl:this.#t}):void 0)??await readDevelopmentRuntimeArtifactsRevision({serverUrl:this.#t});if(n===void 0)return;let r=this.#n;r!==void 0&&r!==n&&await e.onRuntimeArtifactsChanged?.({previousRevision:r,revision:n}),this.#n=n}};function shouldRefreshRuntimeArtifactsForTurn(e){return e.message!==void 0&&(e.inputResponses?.length??0)===0}function createDevelopmentRuntimeArtifactRefresher(e){return new LocalDevelopmentRuntimeArtifactRefresher(e)}export{createDevelopmentRuntimeArtifactRefresher};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{pathExists,writeTextFile}from"../files.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{basename,join,resolve}from"node:path";import{mkdir,readdir,stat}from"node:fs/promises";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,ALLOWED_CREATE_IN_PLACE_ENTRIES=new Set([`.DS_Store`,`.git`,`.gitkeep`,`.hg`]),DEFAULT_AI_PACKAGE_VERSION=`^7.0.26`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.2.2`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.24.
|
|
1
|
+
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{pathExists,writeTextFile}from"../files.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{basename,join,resolve}from"node:path";import{mkdir,readdir,stat}from"node:fs/promises";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,ALLOWED_CREATE_IN_PLACE_ENTRIES=new Set([`.DS_Store`,`.git`,`.gitkeep`,`.hg`]),DEFAULT_AI_PACKAGE_VERSION=`^7.0.26`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.2.2`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.24.4`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e){return{"agent/agent.ts":BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e),"agent/channels/eve.ts":WEB_APP_TEMPLATE_FILES[`agent/channels/eve.ts`],"agent/instructions.md":AGENT_INSTRUCTIONS_TEMPLATE}}function renderTemplate(e,t){return e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
|
|
2
2
|
|
|
3
3
|
export default defineAgent({
|
|
4
4
|
model: "__EVE_INIT_MODEL__",
|
|
@@ -58,7 +58,6 @@ You are a helpful assistant.
|
|
|
58
58
|
.env*
|
|
59
59
|
.eve
|
|
60
60
|
.vercel
|
|
61
|
-
.workflow-data
|
|
62
61
|
.next
|
|
63
62
|
.output
|
|
64
63
|
.nitro
|
|
@@ -68,7 +67,6 @@ dist
|
|
|
68
67
|
`,".vercelignore":`node_modules
|
|
69
68
|
.env*
|
|
70
69
|
.eve
|
|
71
|
-
.workflow-data
|
|
72
70
|
.next
|
|
73
71
|
.output
|
|
74
72
|
.nitro
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Windows refuses to replace a file while another handle is open on it
|
|
8
8
|
* (concurrent readers, `utimes` heartbeats, antivirus scans), surfacing as
|
|
9
|
-
* `EPERM`/`EACCES`, so the replace is retried briefly before giving up.
|
|
9
|
+
* `EPERM`/`EACCES`/`EBUSY`, so the replace is retried briefly before giving up.
|
|
10
10
|
*/
|
|
11
11
|
export declare function atomicWriteFile(targetPath: string, contents: string | Buffer | Uint8Array): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{rm,writeFile}from"node:fs/promises";import{renameWithTransientBusyRetry}from"#shared/rename-with-retry.js";async function atomicWriteFile(t,n){let r=`${t}.tmp-${process.pid}-${Date.now().toString(36)}`;await writeFile(r,n);try{await renameWithTransientBusyRetry(r,t)}catch(e){throw await rm(r,{force:!0}).catch(()=>void 0),e}}export{atomicWriteFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function toChannelLocalContinuationToken(e){let t=e.indexOf(`:`);return t<0?e:e.slice(t+1)}export{toChannelLocalContinuationToken};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renames a path atomically, retrying the transient busy-handle errors that
|
|
3
|
+
* Windows can report while another process briefly has either path open.
|
|
4
|
+
*/
|
|
5
|
+
export declare function renameWithTransientBusyRetry(sourcePath: string, destinationPath: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rename}from"node:fs/promises";import{isErrnoCode}from"#shared/guards.js";const TRANSIENT_RENAME_RETRY_DELAYS_MS=[10,20,40,80,160,320,640];async function renameWithTransientBusyRetry(t,n){for(let r of TRANSIENT_RENAME_RETRY_DELAYS_MS)try{await rename(t,n);return}catch(e){if(!isTransientRenameError(e))throw e;await new Promise(e=>setTimeout(e,r))}await rename(t,n)}function isTransientRenameError(e){return isErrnoCode(e,`EPERM`)||isErrnoCode(e,`EACCES`)||isErrnoCode(e,`EBUSY`)}export{renameWithTransientBusyRetry};
|
package/dist/src/svelte/index.js
CHANGED
package/dist/src/vue/index.js
CHANGED
package/docs/agent-config.md
CHANGED
|
@@ -214,6 +214,8 @@ installed package must stay external in hosted output, list it in
|
|
|
214
214
|
|
|
215
215
|
`externalDependencies` is a packaging control only. It keeps selected packages as runtime dependencies in the hosted output; it does not authorize, configure, or review any third-party service those packages may call.
|
|
216
216
|
|
|
217
|
+
During `eve dev`, ordinary dependencies are bundled into each retained runtime generation. Packages listed in `externalDependencies` keep normal Node.js resolution instead, so replacing one of those packages requires restarting the dev server.
|
|
218
|
+
|
|
217
219
|
## Where adjacent settings live
|
|
218
220
|
|
|
219
221
|
| Concern | Lives in |
|
|
@@ -15,7 +15,7 @@ Work nests in three levels:
|
|
|
15
15
|
|
|
16
16
|
Every turn runs as a durable workflow, built on the open-source [Workflow SDK](https://workflow-sdk.dev/) (Vercel Workflow when you deploy on Vercel). eve checkpoints progress and serializes durable state at each step boundary. Your code runs inside a managed step, so tools, the sandbox, and subagents feel synchronous even though the session underneath them is durable.
|
|
17
17
|
|
|
18
|
-
The Workflow SDK is not inherently tied to Vercel. In local development and in a self-deployed `eve start` process, eve uses the SDK's local world by default; that world persists workflow runs on disk
|
|
18
|
+
The Workflow SDK is not inherently tied to Vercel. In local development and in a self-deployed `eve start` process, eve uses the SDK's local world by default; that world persists workflow runs on disk under `.eve/.workflow-data` and dispatches through the same Nitro-hosted workflow routes. On Vercel, the same workflow code runs against Vercel Workflow instead, which adds platform features such as latest production deployment routing and dashboard run metadata.
|
|
19
19
|
|
|
20
20
|
When a Vercel production deployment changes, the next model turn in an existing session uses that deployment's current instructions, model, and tools. The durable session keeps its conversation history and authored state, so identity-based channels such as Telegram private chats and Twilio phone-number conversations adopt agent updates without requiring a new session.
|
|
21
21
|
|
|
@@ -58,7 +58,8 @@ The stream is newline-delimited JSON (NDJSON), one event per line:
|
|
|
58
58
|
| `step.failed` | A model step failed; carries `{ code, message, details? }`. |
|
|
59
59
|
| `turn.completed` | The turn finished. |
|
|
60
60
|
| `turn.failed` | The turn failed; carries `{ code, message, details? }`. |
|
|
61
|
-
| `
|
|
61
|
+
| `turn.cancelled` | The turn was cancelled before finishing; always followed by `session.waiting`. |
|
|
62
|
+
| `session.waiting` | The session parked for the next input; carries the current channel-owned `continuationToken`. |
|
|
62
63
|
| `session.failed` | The session failed. |
|
|
63
64
|
| `session.completed` | The session reached a terminal end. |
|
|
64
65
|
|
|
@@ -70,11 +71,11 @@ Note: consider the privacy, confidentiality, and user-experience implications fo
|
|
|
70
71
|
|
|
71
72
|
A delegated subagent publishes progress on its own child-session stream. The parent only emits `subagent.called` with a `childSessionId`, which a client uses to attach.
|
|
72
73
|
|
|
73
|
-
`step.failed` and `turn.failed` carry `{ code, message, details? }` for the failed fragment or turn, and `session.failed` is the terminal session-level variant. When a turn requested an output schema, the finalized payload lands on `result.completed` as `data.result` before the turn boundary. `authorization.required` carries the sign-in challenge (`data.authorization` may include `url`, `userCode`, `expiresAt`, `instructions`), and `authorization.completed` carries `data.outcome` (`"authorized" | "declined" | "failed" | "timed-out"`).
|
|
74
|
+
`step.failed` and `turn.failed` carry `{ code, message, details? }` for the failed fragment or turn, and `session.failed` is the terminal session-level variant. `turn.cancelled` is not a failure: the cancelled turn ends without any failure event, `session.waiting` follows, and the session accepts the next message normally — whatever the turn streamed before cancellation stays on the stream, while durable history keeps only what had already settled. When a turn requested an output schema, the finalized payload lands on `result.completed` as `data.result` before the turn boundary. `authorization.required` carries the sign-in challenge (`data.authorization` may include `url`, `userCode`, `expiresAt`, `instructions`), and `authorization.completed` carries `data.outcome` (`"authorized" | "declined" | "failed" | "timed-out"`).
|
|
74
75
|
|
|
75
76
|
## Send a follow-up message
|
|
76
77
|
|
|
77
|
-
Once the session is waiting (you'll see `session.waiting`), POST your follow-up to the session endpoint with
|
|
78
|
+
Once the session is waiting (you'll see `session.waiting`), POST your follow-up to the session endpoint with `event.data.continuationToken`:
|
|
78
79
|
|
|
79
80
|
```bash
|
|
80
81
|
curl -X POST http://127.0.0.1:3000/eve/v1/session/<sessionId> \
|
|
@@ -90,12 +91,20 @@ For deterministic ordering, send one follow-up at a time and wait for the next `
|
|
|
90
91
|
|
|
91
92
|
## Reconnect and rewind
|
|
92
93
|
|
|
93
|
-
The stream is durable. Every event is recorded before a step completes, so the whole stream is replayable.
|
|
94
|
+
The stream is durable. Every event is recorded before a step completes, so the whole stream is replayable. A nonnegative `startIndex` is an absolute event count: use it to pick up where you dropped off or pass `0` to rewind to the start.
|
|
94
95
|
|
|
95
96
|
```bash
|
|
96
97
|
curl "http://127.0.0.1:3000/eve/v1/session/<sessionId>/stream?startIndex=<count>"
|
|
97
98
|
```
|
|
98
99
|
|
|
100
|
+
A negative `startIndex` reads relative to the stream's current tail. For example, `-1` reads the latest event, which is normally `session.waiting` for a resumable session:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
curl "http://127.0.0.1:3000/eve/v1/session/<sessionId>/stream?startIndex=-1"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This gives a consumer that only persisted `sessionId` a lightweight way to recover the current `continuationToken`. Because a tail-relative position does not resolve to an absolute consumed-event count, client tail reads do not automatically reconnect or advance the stored cursor.
|
|
107
|
+
|
|
99
108
|
## Use the client from TypeScript
|
|
100
109
|
|
|
101
110
|
For scripts, server-to-server calls, tests, evals, and custom UIs, `eve/client` wraps these routes in a typed client so you don't hand-roll the POST and NDJSON stream loop.
|
|
@@ -64,7 +64,7 @@ The shorthand can send a follow-up, but it doesn't know the previous stream curs
|
|
|
64
64
|
|
|
65
65
|
## Waiting, completed, and failed sessions
|
|
66
66
|
|
|
67
|
-
When a turn ends with `session.waiting`, the client preserves the state so the next send continues the conversation.
|
|
67
|
+
When a turn ends with `session.waiting`, the event carries the current channel-owned `data.continuationToken` and the client preserves the state so the next send continues the conversation.
|
|
68
68
|
|
|
69
69
|
When a turn ends with `session.completed` or `session.failed`, the client resets its local state. The next send starts a fresh durable session:
|
|
70
70
|
|
|
@@ -115,6 +115,19 @@ for await (const event of session.stream()) {
|
|
|
115
115
|
|
|
116
116
|
`stream()` attaches to an existing run; to send new user input, use `send()`. For overriding the cursor with `startIndex` and the full reconnection model, see [Streaming](./streaming#open-a-stream-manually).
|
|
117
117
|
|
|
118
|
+
If you only persisted `sessionId`, read the latest durable event to recover the current token from a waiting session:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const session = client.session({ sessionId, streamIndex: 0 });
|
|
122
|
+
|
|
123
|
+
for await (const event of session.stream({ startIndex: -1 })) {
|
|
124
|
+
if (event.type === "session.waiting") {
|
|
125
|
+
await saveContinuationToken(event.data.continuationToken);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
118
131
|
## What to read next
|
|
119
132
|
|
|
120
133
|
- [Streaming](./streaming): stream events and reconnect by index
|
|
@@ -70,7 +70,7 @@ The most common UI events are:
|
|
|
70
70
|
| `action.result` | Show tool call results. |
|
|
71
71
|
| `input.requested` | Pause the UI for approval or a question answer. |
|
|
72
72
|
| `result.completed` | Read structured output from an [output schema](./output-schema). |
|
|
73
|
-
| `session.waiting` | Enable the composer
|
|
73
|
+
| `session.waiting` | Enable the composer and read the current `data.continuationToken`. |
|
|
74
74
|
| `session.completed` | Mark the conversation terminal. |
|
|
75
75
|
| `session.failed` | Mark the conversation failed. |
|
|
76
76
|
|
|
@@ -124,6 +124,19 @@ for await (const event of session.stream({ startIndex: 0 })) {
|
|
|
124
124
|
}
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
+
Nonnegative values are absolute event indexes. Negative values read relative to the stream's current tail, so `-1` reads the latest event:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
for await (const event of session.stream({ startIndex: -1 })) {
|
|
131
|
+
if (event.type === "session.waiting") {
|
|
132
|
+
console.log(event.data.continuationToken);
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Tail-relative attachments do not automatically reconnect or advance the session's stored absolute `streamIndex`. Break after the event you need when using one as a tail lookup.
|
|
139
|
+
|
|
127
140
|
`stream()` throws if the session has no `sessionId`, because there's no stream to attach to before the first send.
|
|
128
141
|
|
|
129
142
|
## Abort a request
|