eve 0.29.5 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/cli/dev/tui/message-queue.d.ts +7 -7
  3. package/dist/src/cli/dev/tui/message-queue.js +1 -1
  4. package/dist/src/cli/dev/tui/prompt-commands.d.ts +4 -4
  5. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  6. package/dist/src/cli/dev/tui/runner.d.ts +1 -1
  7. package/dist/src/cli/dev/tui/setup-panel.js +4 -1
  8. package/dist/src/cli/dev/tui/subagent-pump.d.ts +2 -2
  9. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  10. package/dist/src/compiled/.vendor-stamp.json +6 -6
  11. package/dist/src/compiled/@workflow/core/_devalue.d.ts +8 -0
  12. package/dist/src/compiled/@workflow/core/capabilities.d.ts +5 -0
  13. package/dist/src/compiled/@workflow/core/index.js +2 -2
  14. package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +11 -0
  15. package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +12 -0
  16. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +18 -0
  17. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +103 -31
  18. package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +36 -0
  19. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +22 -2
  20. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +17 -13
  21. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +13 -8
  22. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  23. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  24. package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +17 -0
  25. package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +155 -0
  26. package/dist/src/compiled/@workflow/core/serialization/index.d.ts +2 -1
  27. package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +1 -1
  28. package/dist/src/compiled/@workflow/core/serialization.d.ts +13 -9
  29. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +1 -1
  30. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +41 -0
  31. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  32. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  33. package/dist/src/compiled/@workflow/errors/index.d.ts +16 -8
  34. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  35. package/dist/src/compiled/@workflow/world/analytics.d.ts +2 -0
  36. package/dist/src/compiled/@workflow/world/events.d.ts +87 -0
  37. package/dist/src/compiled/@workflow/world/hooks.d.ts +39 -0
  38. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  39. package/dist/src/compiled/@workflow/world/interfaces.d.ts +61 -0
  40. package/dist/src/compiled/@workflow/world/queue.d.ts +40 -0
  41. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  42. package/dist/src/compiled/@workflow/world-vercel/index.js +14 -14
  43. package/dist/src/compiled/_chunks/workflow/{attribute-changes-1LmTKuTT.js → attribute-changes-DROfGk6l.js} +3 -3
  44. package/dist/src/compiled/_chunks/workflow/{dist-WjtNsOyf.js → dist-D5bR13zs.js} +1 -1
  45. package/dist/src/compiled/_chunks/workflow/{dist-BeQ_csYA.js → dist-dNxTT6nO.js} +2 -2
  46. package/dist/src/compiled/_chunks/workflow/resume-hook-bc-OQVI0.js +1 -0
  47. package/dist/src/compiled/_chunks/workflow/run-DM3ouA3U.js +1 -0
  48. package/dist/src/compiled/_chunks/workflow/sleep-D5iWly6-.js +1 -0
  49. package/dist/src/compiled/_chunks/workflow/wait-until-DoW76jdb.js +15 -0
  50. package/dist/src/compiler/normalize-subagent.js +1 -1
  51. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -1
  52. package/dist/src/context/keys.d.ts +8 -0
  53. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  54. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  55. package/dist/src/execution/remote-agent-dispatch.d.ts +3 -1
  56. package/dist/src/execution/remote-agent-dispatch.js +1 -1
  57. package/dist/src/execution/workflow-steps.js +1 -1
  58. package/dist/src/harness/tool-loop.js +1 -1
  59. package/dist/src/internal/application/package.js +1 -1
  60. package/dist/src/internal/authored-module-loader.js +1 -1
  61. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  62. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.d.ts +10 -0
  63. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -0
  64. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.d.ts +7 -0
  65. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +3 -0
  66. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +2 -0
  67. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
  68. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
  69. package/dist/src/public/channels/auth.d.ts +11 -25
  70. package/dist/src/public/channels/auth.js +1 -1
  71. package/dist/src/public/definitions/agent.d.ts +5 -2
  72. package/dist/src/public/index.d.ts +1 -1
  73. package/dist/src/runtime/framework-channels/index.js +1 -1
  74. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
  75. package/dist/src/runtime/subagents/dynamic-remote-agent-config.d.ts +13 -0
  76. package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -0
  77. package/dist/src/setup/scaffold/channels-catalog.d.ts +2 -2
  78. package/dist/src/setup/scaffold/channels-catalog.js +1 -1
  79. package/dist/src/setup/scaffold/connections/catalog.d.ts +2 -2
  80. package/dist/src/setup/scaffold/create/project.js +1 -1
  81. package/docs/channels/eve.mdx +1 -1
  82. package/docs/concepts/sessions-runs-and-streaming.md +1 -1
  83. package/docs/guides/auth-and-route-protection.md +13 -13
  84. package/docs/guides/dev-tui.md +4 -4
  85. package/docs/guides/dynamic-capabilities.md +26 -1
  86. package/docs/guides/frontend/nextjs.mdx +1 -1
  87. package/docs/guides/frontend/nuxt.mdx +1 -1
  88. package/docs/guides/frontend/sveltekit.mdx +1 -1
  89. package/docs/guides/remote-agents.md +33 -0
  90. package/package.json +7 -7
  91. package/dist/src/compiled/_chunks/workflow/resume-hook-D1_5NCZ6.js +0 -1
  92. package/dist/src/compiled/_chunks/workflow/run-C240Ctf4.js +0 -1
  93. package/dist/src/compiled/_chunks/workflow/sleep-De802yfX.js +0 -1
  94. package/dist/src/compiled/_chunks/workflow/wait-until-z48sPUjU.js +0 -15
@@ -1,4 +1,4 @@
1
- import{pinnedNodeEngineMajor}from"../../node-engine.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.38`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.4.3`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.29.5`,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";
1
+ import{pinnedNodeEngineMajor}from"../../node-engine.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.38`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.4.3`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.30.0`,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__",
@@ -113,7 +113,7 @@ The `auth` option decides who can call `/eve/v1/info` and the session routes. Th
113
113
 
114
114
  Neither admits browser users or external clients in production. For a public app, wire the channel to your own auth (Clerk, Auth.js, your own OIDC/JWT verification, an API-key verifier, or any custom `AuthFn`). Vercel OIDC is optional; use it only when Vercel-issued deployment tokens are part of your trust model.
115
115
 
116
- `eve init` scaffolds an `agent/channels/eve.ts` with a production placeholder so you replace it before going live. The generated channel checks Vercel OIDC before falling back to localhost access, and includes `placeholderAuth()`, which returns a setup-focused 401 in production until you swap it for real auth. Delete the file and eve falls back to `[vercelOidc(), localDev()]`, which still does not admit browser users in production.
116
+ `eve init` scaffolds an `agent/channels/eve.ts` with a production placeholder so you replace it before going live. The generated channel checks Vercel OIDC before falling back to localhost access, and includes `placeholderAuth()`, which returns a setup-focused 401 in production until you swap it for real auth. Delete the file and eve falls back to `[vercelOidc(), localDev(), placeholderAuth()]`, which rejects all production traffic.
117
117
 
118
118
  For the full auth model and helper list, see [Auth & route protection](../guides/auth-and-route-protection).
119
119
 
@@ -208,7 +208,7 @@ Start with the [TypeScript SDK](../guides/client/overview) guide. It covers basi
208
208
  curl http://127.0.0.1:2000/eve/v1/info
209
209
  ```
210
210
 
211
- With the default auth chain (`[vercelOidc(), localDev()]`), a local Vercel OIDC bearer takes precedence and other local requests fall back to development access. A deployed Vercel target requires a valid OIDC bearer, with a same-project bypass for in-deployment callers. See [auth & route protection](../guides/auth-and-route-protection).
211
+ With the default auth chain (`[vercelOidc(), localDev(), placeholderAuth()]`), a Vercel OIDC bearer takes precedence, an `eve dev` or `vercel dev` server authenticates local requests, and everything else is rejected. A deployed Vercel target requires a valid OIDC bearer, with a same-project bypass for in-deployment callers. See [auth & route protection](../guides/auth-and-route-protection).
212
212
 
213
213
  ## Dispatch order
214
214
 
@@ -18,7 +18,7 @@ The route-auth policy lives on the HTTP channel factory (`agent/channels/eve.ts`
18
18
  - `POST /eve/v1/session/:sessionId`
19
19
  - `GET /eve/v1/session/:sessionId/stream`
20
20
 
21
- These routes are protected by the channel's auth policy. eve fails closed by default: production browser traffic is rejected unless you configure an authenticator that accepts it, and anonymous access requires an explicit `none()`.
21
+ These routes are protected by the channel's auth policy. eve fails closed by default: production traffic is rejected unless you configure an authenticator that accepts it, and anonymous access requires an explicit `none()`.
22
22
 
23
23
  `GET /eve/v1/health` is always public and skips the walk entirely, so load balancers and uptime monitors can probe it without credentials.
24
24
 
@@ -86,15 +86,15 @@ Any other thrown error follows the normal channel failure path. When building a
86
86
 
87
87
  `eve/channels/auth` ships these channel-auth helpers:
88
88
 
89
- | Helper | Use when |
90
- | ---------------- | ------------------------------------------------------------------------- |
91
- | `localDev()` | Local development. Accepts requests addressed to a loopback hostname. |
92
- | `vercelOidc()` | The common Vercel deployment path. Verifies a Vercel OIDC bearer JWT. |
93
- | `none()` | You want to accept anonymous traffic explicitly (use as the final entry). |
94
- | `httpBasic(...)` | Operator or service access via a shared username/password. |
95
- | `jwtHmac(...)` | You control a shared-secret JWT signer. |
96
- | `jwtEcdsa(...)` | You verify asymmetric JWTs minted by another system. |
97
- | `oidc(...)` | You want eve to verify OIDC-issued tokens from an arbitrary issuer. |
89
+ | Helper | Use when |
90
+ | ---------------- | -------------------------------------------------------------------------------------------------- |
91
+ | `localDev()` | Local development. Accepts requests only while the process is an `eve dev` or `vercel dev` server. |
92
+ | `vercelOidc()` | The common Vercel deployment path. Verifies a Vercel OIDC bearer JWT. |
93
+ | `none()` | You want to accept anonymous traffic explicitly (use as the final entry). |
94
+ | `httpBasic(...)` | Operator or service access via a shared username/password. |
95
+ | `jwtHmac(...)` | You control a shared-secret JWT signer. |
96
+ | `jwtEcdsa(...)` | You verify asymmetric JWTs minted by another system. |
97
+ | `oidc(...)` | You want eve to verify OIDC-issued tokens from an arbitrary issuer. |
98
98
 
99
99
  `httpBasic(credentials, { realm })` accepts an optional `realm`, rendered on the `WWW-Authenticate: Basic` challenge (e.g. `Basic realm="agent", charset="UTF-8"`) so browsers label their native login prompt. It defaults to `"eve"`, ensuring every Basic challenge includes the required realm. Usernames and passwords are normalized to Unicode NFC before comparison, matching the advertised UTF-8 credential encoding.
100
100
 
@@ -102,9 +102,9 @@ Exercise caution for agents that process non-public, sensitive, regulated, or pr
102
102
 
103
103
  ### `localDev()`
104
104
 
105
- Authenticates a synthetic `local-dev` principal, but only when the inbound request is addressed to a loopback hostname (`localhost`, `*.localhost`, `127.0.0.0/8`, or `::1`). The check keys off the request URL's hostname rather than the bare `process.env.VERCEL` flag, and that's deliberate: a deployment outside Vercel leaves `VERCEL` unset, so sniffing that flag alone would wave through all public traffic. There's one process-level exception. `vercel dev`, detected by `VERCEL=1` and `VERCEL_ENV=development` together, opens the local dev server even when it serves over a non-loopback host. Every other non-loopback request returns `null` and falls through.
105
+ Authenticates a synthetic `local-dev` principal, but only while the process is a local development server: `eve dev` (which sets `EVE_DEV=1`) or `vercel dev` (detected by `VERCEL=1` and `VERCEL_ENV=development` together). This is a property of the deployment, not the request, so no request header can flip it. A production deployment (`eve start`, a Vercel deployment, or any container host) sets neither flag, so `localDev()` authenticates nothing there and every request falls through to the next entry.
106
106
 
107
- `localDev()` trusts the advertised hostname, so an attacker who can inject a `Host` header (no normalizing proxy in front of your origin) can spoof it. Always layer a real authenticator on top; never run on `localDev()` alone.
107
+ Because it never opens a production deployment, `localDev()` is safe to leave in the walk. Still put a real authenticator ahead of it so production traffic has something to match.
108
108
 
109
109
  ### `vercelOidc()`
110
110
 
@@ -214,7 +214,7 @@ export default eveChannel({
214
214
  });
215
215
  ```
216
216
 
217
- In production, `placeholderAuth()` returns a structured `401` so a generated web chat app can say "auth isn't configured yet" instead of throwing an internal error. Replace it before a browser caller submits a production request: swap in your app's `AuthFn` or one of the shipped helpers. Delete the authored channel file entirely and eve falls back to the framework default `[vercelOidc(), localDev()]`, which also rejects production browser traffic.
217
+ In production, `placeholderAuth()` returns a structured `401` so a generated web chat app can say "auth isn't configured yet" instead of throwing an internal error. Replace it before a browser caller submits a production request: swap in your app's `AuthFn` or one of the shipped helpers. Delete the authored channel file entirely and eve falls back to the framework default `[vercelOidc(), localDev(), placeholderAuth()]`, which also rejects production traffic.
218
218
 
219
219
  You do not have to keep `vercelOidc()` in the final policy. For a self-hosted app, an app-embedded frontend, or any deployment that uses a non-Vercel identity system, use `httpBasic()`, `jwtHmac()`, `jwtEcdsa()`, generic `oidc()`, or a custom `AuthFn` that maps your verified user/session/API key into a `SessionAuthContext`.
220
220
 
@@ -43,7 +43,7 @@ Each command echoes as an invocation line, asks through a bordered panel that ta
43
43
  | `/traces` | Opens the full-screen local trace viewer. See [Inspect traces](#inspect-traces). |
44
44
  | `/reset` | Starts a fresh session. |
45
45
  | `/cancel` | Cooperatively cancels the running turn while preserving the session and settled context. |
46
- | `/clear` | Clears model-message history while preserving the current session and its durable resources. |
46
+ | `/clear` | Clears model-message history while preserving the current session and its durable resources. `/new` is an alias. |
47
47
  | `/compact` | Queues context compaction for the current session without sending a message. |
48
48
  | `/exit` | Quits the TUI. |
49
49
  | `/help` | Lists the commands available for the current local or remote session. |
@@ -71,9 +71,9 @@ Chat and freeform `ask_question` inputs behave like a shell line editor.
71
71
  | Key | Action |
72
72
  | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
73
73
  | `Enter` | Submit the message or question response. While a turn is running, queue the message for the next turn. |
74
- | `Esc` | While a turn runs: pop the oldest queued message and steer with it; with nothing queued, press twice to cancel. |
74
+ | `Esc` | While a turn runs: pop the oldest queued message and steer with it; with nothing queued, cancel the turn. |
75
75
  | `Shift+Enter` | Insert a newline without sending (needs a terminal that reports modified keys). |
76
- | `Ctrl+C` | Interrupt a running turn. At the chat or freeform-question prompt, clear non-empty input; when empty, quit. |
76
+ | `Ctrl+C` | While a turn runs, behave like Esc. At the idle chat prompt, clear input and arm exit; press again to quit. |
77
77
  | `↑` / `↓` | Move between input lines; at a chat-buffer edge, navigate messages you have sent this session. |
78
78
  | `←` / `→`, `Home` / `End`, `Ctrl+A` / `Ctrl+E` | Move the caret; Home/End stay within the current line. |
79
79
  | `Ctrl+U` / `Ctrl+K` / `Ctrl+W` | Delete to the start of the line, to its end, or through the previous word. |
@@ -86,7 +86,7 @@ In terminals that support bracketed paste, pasting multi-line text into chat or
86
86
 
87
87
  Sending a message while a turn is still running does not interrupt it — the message joins a queue of up to five, pinned in a panel directly above the input with one line per message. When the turn ends, the queued messages coalesce into the next turn's message. Submit `/cancel` during a turn to cancel it immediately without queueing the command as model input; `/cancel` also works from the idle prompt when a prior stream disconnected while its server turn may still be running.
88
88
 
89
- `Esc` steers instead of waiting: it pops the oldest queued message, cancels the running turn cooperatively, and submits the popped message as the replacement turn. In the transcript, a steered message carries an accent `↑` on its own line above its gutter bar; a queued message that waited for the boundary carries it below. Any remaining messages stay queued behind it. With nothing queued, one `Esc` cancels the turn immediately. Unlike `Ctrl+C` — which drops the stream client-side — a cancelled turn ends cleanly on the server and the session keeps its context; the conversation picks up at the next prompt.
89
+ `Esc` and `Ctrl+C` steer instead of waiting: either key pops the oldest queued message, cancels the running turn cooperatively, and submits the popped message as the replacement turn. In the transcript, a steered message carries an accent `↑` on its own line above its gutter bar; a queued message that waited for the boundary carries it below. Any remaining messages stay queued behind it. With nothing queued, either key cancels the turn immediately. A cancelled turn ends cleanly on the server and the session keeps its context; the conversation picks up at the next prompt.
90
90
 
91
91
  If a turn fails terminally (the server session dies or the connection drops), the TUI starts a fresh session and notes it inline so you can keep going. Server-side context resets with the old session. Messages still queued when a turn is interrupted or fails are restored into the next prompt's input instead of being sent blind.
92
92
 
@@ -51,12 +51,37 @@ compiled manifest. Each resolution can return a different model or other
51
51
  runtime agent settings. Runtime-selected models must use string model IDs;
52
52
  build and Workflow-world configuration cannot be selected at runtime.
53
53
 
54
+ A single-file remote subagent uses the same lifecycle. Return
55
+ `defineRemoteAgent(...)` to expose the selected deployment, or nil to omit it:
56
+
57
+ ```ts title="agent/subagents/finance.ts"
58
+ import { defineDynamic, defineRemoteAgent } from "eve";
59
+
60
+ export default defineDynamic({
61
+ events: {
62
+ "session.started": (_event, ctx) =>
63
+ ctx.session.auth.current?.attributes.plan === "enterprise"
64
+ ? defineRemoteAgent({
65
+ description: "Analyze financial and accounting data.",
66
+ url: "https://finance-agent.example.com",
67
+ })
68
+ : null,
69
+ },
70
+ });
71
+ ```
72
+
73
+ The returned remote definition can change its URL, path, headers, auth,
74
+ principal forwarding, and output schema. Function-valued URLs resolve when the
75
+ dynamic event runs. Auth and headers remain lazy and resolve before each
76
+ outbound request without entering durable workflow state.
77
+
54
78
  Dynamic subagents support `session.started` and `turn.started`. A turn selection
55
79
  shadows the session selection for that turn, including when the turn handler
56
80
  returns nil. If a resolver throws or returns an invalid definition, eve logs the
57
81
  failure and omits the subagent.
58
82
 
59
- The resolved set applies to direct delegation and the `Workflow` tool. eve
83
+ The resolved set applies to local and remote direct delegation and the
84
+ `Workflow` tool. eve
60
85
  also checks availability again before starting the child, so a stale or
61
86
  manually constructed call fails with `SUBAGENT_UNAVAILABLE`. Treat conditional
62
87
  availability as capability composition, not as the only authorization
@@ -88,7 +88,7 @@ const agent = useEveAgent({
88
88
  });
89
89
  ```
90
90
 
91
- The default eve channel is fail-closed. With no `agent/channels/eve.ts` authored, eve registers `eveChannel({ auth: [vercelOidc(), localDev()] })`: `vercelOidc()` gets the first chance to resolve a Vercel caller, `localDev()` opens the remaining localhost requests, and everything else gets a `401`. To run your app's own auth policy, add `agent/channels/eve.ts`:
91
+ The default eve channel is fail-closed. With no `agent/channels/eve.ts` authored, eve registers `eveChannel({ auth: [vercelOidc(), localDev(), placeholderAuth()] })`: `vercelOidc()` gets the first chance to resolve a Vercel caller, `localDev()` authenticates while the process is an `eve dev` or `vercel dev` server, and everything else gets a `401`. To run your app's own auth policy, add `agent/channels/eve.ts`:
92
92
 
93
93
  ```ts title="agent/channels/eve.ts"
94
94
  import { eveChannel } from "eve/channels/eve";
@@ -60,7 +60,7 @@ async function handleSubmit() {
60
60
  </template>
61
61
  ```
62
62
 
63
- The default eve channel is fail-closed. With no `agent/channels/eve.ts` authored, eve registers `eveChannel({ auth: [vercelOidc(), localDev()] })`: `vercelOidc()` gets the first chance to resolve a Vercel caller, `localDev()` opens the remaining localhost requests, and everything else gets a `401`. To run your own auth policy, add `agent/channels/eve.ts`:
63
+ The default eve channel is fail-closed. With no `agent/channels/eve.ts` authored, eve registers `eveChannel({ auth: [vercelOidc(), localDev(), placeholderAuth()] })`: `vercelOidc()` gets the first chance to resolve a Vercel caller, `localDev()` authenticates while the process is an `eve dev` or `vercel dev` server, and everything else gets a `401`. To run your own auth policy, add `agent/channels/eve.ts`:
64
64
 
65
65
  ```ts title="agent/channels/eve.ts"
66
66
  import { eveChannel } from "eve/channels/eve";
@@ -69,7 +69,7 @@ With the plugin in `vite.config.ts`, components call [`useEveAgent`](./use-eve-a
69
69
  </form>
70
70
  ```
71
71
 
72
- The default eve channel is fail-closed. With no `agent/channels/eve.ts` authored, eve registers `eveChannel({ auth: [vercelOidc(), localDev()] })`: `vercelOidc()` gets the first chance to resolve a Vercel caller, `localDev()` opens the remaining localhost requests, and everything else gets a `401`. To set your own auth policy, add `agent/channels/eve.ts`:
72
+ The default eve channel is fail-closed. With no `agent/channels/eve.ts` authored, eve registers `eveChannel({ auth: [vercelOidc(), localDev(), placeholderAuth()] })`: `vercelOidc()` gets the first chance to resolve a Vercel caller, `localDev()` authenticates while the process is an `eve dev` or `vercel dev` server, and everything else gets a `401`. To set your own auth policy, add `agent/channels/eve.ts`:
73
73
 
74
74
  ```ts title="agent/channels/eve.ts"
75
75
  import { eveChannel } from "eve/channels/eve";
@@ -30,6 +30,39 @@ export default defineRemoteAgent({
30
30
  | `path` | `string` | No | `/eve/v1/session` | Route appended to `url` for the create-session request. |
31
31
  | `outputSchema` | `StandardSchema \| JSON Schema` | No | none | Structured return type the caller requires. Lowered to JSON Schema at compile time and enforced by the remote like any task-mode output schema. |
32
32
 
33
+ ## Dynamic remote agents
34
+
35
+ Wrap the file in `defineDynamic` when the target or its availability depends on
36
+ the current session. Return `defineRemoteAgent(...)` to expose it and nil to
37
+ omit it:
38
+
39
+ ```ts title="agent/subagents/weather.ts"
40
+ import { defineDynamic, defineRemoteAgent } from "eve";
41
+
42
+ export default defineDynamic({
43
+ events: {
44
+ "session.started": (_event, ctx) =>
45
+ ctx.session.auth.current?.attributes.region === "us"
46
+ ? defineRemoteAgent({
47
+ description: "Answers weather questions for US customers.",
48
+ url: "https://us-weather-agent.example.com",
49
+ })
50
+ : null,
51
+ },
52
+ });
53
+ ```
54
+
55
+ Dynamic remote subagents support `session.started` and `turn.started`. The
56
+ returned definition may select different remote settings at either scope. eve
57
+ resolves function-valued URLs when the event handler runs. Auth and headers
58
+ remain lazy and resolve before each outbound request without entering durable
59
+ workflow state.
60
+
61
+ Author `auth` and `headers` directly in the `defineRemoteAgent({ ... })` object
62
+ and keep their functions self-contained with module imports or environment
63
+ variables. They are rehydrated outside the event handler, so they cannot close
64
+ over `_event`, `ctx`, or handler-local values.
65
+
33
66
  ## Runtime URLs
34
67
 
35
68
  A string `url` is read at compile time and frozen into the build. When the target comes from a runtime env var — known only once the deployment runs — pass a function instead. eve calls it when it resolves the agent graph at runtime, so it can read `process.env`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve",
3
- "version": "0.29.5",
3
+ "version": "0.30.0",
4
4
  "private": false,
5
5
  "description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
6
6
  "keywords": [
@@ -320,13 +320,13 @@
320
320
  "@vercel/otel": "2.1.3",
321
321
  "@vercel/sandbox": "2.8.0",
322
322
  "@vercel/sdk": "1.28.8",
323
- "@workflow/core": "5.0.0-beta.38",
324
- "@workflow/errors": "5.0.0-beta.14",
323
+ "@workflow/core": "5.0.0-beta.39",
324
+ "@workflow/errors": "5.0.0-beta.15",
325
325
  "@workflow/serde": "5.0.0-beta.2",
326
326
  "@workflow/utils": "5.0.0-beta.8",
327
- "@workflow/world": "5.0.0-beta.23",
328
- "@workflow/world-local": "5.0.0-beta.32",
329
- "@workflow/world-vercel": "5.0.0-beta.34",
327
+ "@workflow/world": "5.0.0-beta.24",
328
+ "@workflow/world-local": "5.0.0-beta.33",
329
+ "@workflow/world-vercel": "5.0.0-beta.35",
330
330
  "ai": "^7.0.38",
331
331
  "autoevals": "0.0.132",
332
332
  "chat": "4.34.0",
@@ -355,7 +355,7 @@
355
355
  "vue": "^3.5.0",
356
356
  "zod": "4.4.3",
357
357
  "zod-validation-error": "5.0.0",
358
- "@vercel/eve-catalog": "0.0.1"
358
+ "@eve/catalog": "0.0.1"
359
359
  },
360
360
  "peerDependencies": {
361
361
  "@opentelemetry/api": "^1.0.0",
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-DaDcL9Zw.js";import{A as t,C as n,Mn as r,Q as i,Vn as a,W as o,_ as s,a as c,ct as l,et as u,fn as d,hn as f,lt as p,mn as m,n as h,nn as g,qt as _,st as v,t as y,xn as b,zn as x}from"./wait-until-z48sPUjU.js";import{E as S,d as C,n as w,o as T,r as E}from"./dist-BeQ_csYA.js";import{A as D}from"./dist-WjtNsOyf.js";import{t as O}from"./spec-version-C0hBsfu-.js";var k=e({getHookByToken:()=>P,resumeHook:()=>F,resumeWebhook:()=>I});function A(e){let t=e.executionContext?.workflowCoreVersion,n=e.executionContext?.traceCarrier;return{deploymentId:e.deploymentId,workflowName:e.workflowName,runSpecVersion:e.specVersion,workflowCoreVersion:typeof t==`string`?t:void 0,traceCarrier:n&&typeof n==`object`?n:void 0,encryptionPublicKey:e.encryptionPublicKey}}async function j(e){if(e.resumeContext)return{resumeContext:e.resumeContext,source:`hook`};let t=await(await b()).runs.get(e.runId);return{resumeContext:A(t),source:`run_fallback`,run:t}}async function M(e,t){let n=await b(),r=t.run?await n.getEncryptionKeyForRun?.(t.run):await n.getEncryptionKeyForRun?.(e.runId,{deploymentId:t.resumeContext.deploymentId});return r?await a(r):void 0}async function N(e){let n=await b(),r=await n.hooks.getByToken(e),i;if(r.metadata!==void 0){let e=await j(r),a=e.run?await n.getEncryptionKeyForRun?.(e.run):await n.getEncryptionKeyForRun?.(r.runId,{deploymentId:e.resumeContext.deploymentId});i=a?await d(a):void 0,r.metadata=await t(r.metadata,r.runId,i)}return{hook:r,encryptionKey:i}}async function P(e){let{hook:t}=await N(e);return t}async function F(e,t,r){return await h(()=>u(`hook.resume`,async a=>{let u=await b();try{let d=typeof e==`string`?await u.hooks.getByToken(e):e,h=await j(d),{resumeContext:v}=h;if(a?.setAttributes({...p(d.token),...l(d.hookId),...g(d.runId),"workflow.hook.resume_context_source":h.source}),h.run&&D(h.run.status))throw new T(d.token);let b=s(v.workflowCoreVersion),S,w=r?void 0:x(v.encryptionPublicKey);if(w)S=m(w);else{let e=r??await M(d,h);b.supportedFormats.has(f.ENCRYPTED)||(e=void 0),S=e}let k=(v.runSpecVersion??0)>=5&&b.supportedFormats.has(f.GZIP),A=[],N=O(d.specVersion),P=await n(t,d.runId,S,A,globalThis,N,b.framedByteStreams,k);y(Promise.all(A),e=>{e!==void 0&&o.warn(`Background flush of hook payload ops failed`,{workflowRunId:d.runId,hookId:d.hookId,error:e instanceof Error?e.message:String(e)})});try{await u.events.create(d.runId,{eventType:`hook_received`,specVersion:5,correlationId:d.hookId,eventData:{...N?{}:{token:d.token},payload:P}},{v1Compat:N})}catch(e){throw T.is(e)||E.is(e)||C.is(e)?new T(d.token):e}a?.setAttributes({..._(v.workflowName)});let F=await i(v.traceCarrier);return F&&a?.addLink?.(F),await u.queue(c(v.workflowName),{runId:d.runId,traceCarrier:v.traceCarrier??void 0},{deploymentId:v.deploymentId,specVersion:v.runSpecVersion??1}),d}catch(t){throw a?.setAttributes({...p(typeof e==`string`?e:e.token),...v(!1)}),t}}))}async function I(e,t){let{hook:n,encryptionKey:i}=await N(e);if(n.isWebhook===!1)throw new T(e);let a,o;if(n.metadata&&typeof n.metadata==`object`&&`respondWith`in n.metadata)if(n.metadata.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;o=e,t[r]=n}else if(n.metadata.respondWith instanceof Response)a=n.metadata.respondWith;else throw new S(`Invalid \`respondWith\` value: ${n.metadata.respondWith}`,{slug:w.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else a=new Response(null,{status:202});if(await F(n,t,i),o){let e=o.getReader(),t=await e.read();t.value&&(a=t.value),e.cancel()}if(!a)throw new S(`Workflow run did not send a response`,{slug:w.WEBHOOK_RESPONSE_NOT_SENT});return a}export{k as i,F as n,I as r,P as t};
@@ -1 +0,0 @@
1
- import{$ as e,Bn as t,Bt as n,D as r,H as i,Jt as a,N as o,P as s,Rn as c,Sn as l,U as u,Vn as d,W as f,Yn as p,_ as ee,a as m,bn as h,et as g,fn as _,g as te,hn as v,k as y,mn as ne,n as b,nn as re,qt as ie,rn as ae,rt as oe,s as x,t as S,w as se,xn as C,yn as w,zn as T}from"./wait-until-z48sPUjU.js";import{C as E,D,E as O,O as k,S as A,T as j,g as M,h as N,l as P,p as F,r as I,s as L,t as R,w as z,x as B}from"./dist-BeQ_csYA.js";import{t as V}from"./attribute-changes-1LmTKuTT.js";import{G as H,W as U,i as ce,o as W}from"./dist-WjtNsOyf.js";import{t as G}from"./spec-version-C0hBsfu-.js";const K=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,k.WORLD_CONTRACT_ERROR]),q=new Set([`TRANSPORT`,`TIMEOUT`]),le=[O.is,N.is,B.is,F.is];function J(e){if(!D.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&K.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function Y(e){return M.is(e)?!0:D.is(e)?e.status!==void 0&&e.status>=500||e.code!==void 0&&q.has(e.code):!1}function ue(e){if(P.is(e))return k.REPLAY_DIVERGENCE;if(R.is(e))return k.CORRUPTED_EVENT_LOG;if(L.is(e))return k.MAX_EVENTS_EXCEEDED;if(J(e)||Y(e))return k.WORLD_CONTRACT_ERROR;for(let t of le)if(t(e))return k.RUNTIME_ERROR;return k.USER_ERROR}const de=W();function fe(){let e=u.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[H]:e.rootRunId??t,[U]:t}}let X=!1;async function Z(r,i,o){"use step";return await b(()=>{let s=r?.workflowId;if(!s)throw new O(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return g(`workflow.start ${p(s)}`,async r=>{r?.setAttributes({...ie(s),...a(`start`)});let u=[],p=o??{};Array.isArray(i)?u=i:typeof i==`object`&&(p=i),r?.setAttributes({...n(u.length)});let h=p.world??await C();l(h);let g=await h.getDeploymentId(),_=p.deploymentId??g;_===`latest`&&(h.resolveLatestDeploymentId?_=await h.resolveLatestDeploymentId():(X||(X=!0,f.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:g})),_=g));let y=`wrun_${h.createRunId?h.createRunId(p):de()}`,b,w,E;if(_===g)b=!0,w=!0;else if(typeof h.streams?.get!=`function`)b=!1,w=!1;else{let e=await x(h,{deploymentId:_,runId:y,timeout:2e3,namespace:p.namespace}).catch(()=>void 0);E=e?.encryptionPublicKey;let t=ee(e?.workflowCoreVersion);b=t.framedByteStreams,w=t.supportedFormats.has(v.GZIP)}let D=[],k=await e(),A=p.specVersion??h.specVersion,j=G(A),M=p.allowReservedAttributes===!0,N;if(p.attributes&&Object.keys(p.attributes).length>0){if(A<4)throw new O(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(p.attributes))if(typeof t!=`string`)throw new O(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=V(p.attributes,{allowReservedAttributes:M});N=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let P=A>=4?fe():void 0,F=P?{...P,...N}:N,L=F?{attributes:F,...M||P!=null?{allowReservedAttributes:!0}:{}}:{};if(p.replayedFromRunId!==void 0&&!ce.safeParse(p.replayedFromRunId).success)throw new O(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(p.replayedFromRunId).slice(0,64))}.`);let R=T(E),z,B;if(R)z=ne(R),B=E;else{let e=await h.getEncryptionKeyForRun?.(y,{...p,deploymentId:_});z=e?await d(e):void 0,B=e?c((await t(e)).publicKey):void 0}let H=await se(u,y,z,D,globalThis,j,b,w&&A>=5),U={traceCarrier:k,workflowCoreVersion:te,features:{encryption:!!z},...p.replayedFromRunId?{replayedFromRunId:p.replayedFromRunId}:{}},[W,K]=await Promise.allSettled([h.events.create(y,{eventType:`run_created`,specVersion:A,eventData:{deploymentId:_,workflowName:s,input:H,executionContext:U,...B?{encryptionPublicKey:B}:{},...L}},{v1Compat:j}),h.queue(m(s,p.namespace),{runId:y,traceCarrier:k,...A>=3?{runInput:{input:H,deploymentId:_,workflowName:s,specVersion:A,executionContext:U,...B?{encryptionPublicKey:B}:{},...L}}:{}},{deploymentId:_,specVersion:A,...p.region===void 0?{}:{region:p.region}})]);if(K.status===`rejected`)throw K.reason;let q=!1;if(W.status===`rejected`){let e=W.reason;if(!I.is(e))if(Y(e))q=!0,f.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:y,error:e.message});else throw e}else{let e=W.value;if(!e.run)throw new O(`Missing 'run' in server response for 'run_created' event`);if(!j&&e.run.runId!==y)throw new O(`Server returned different runId than requested: expected ${y}, got ${e.run.runId}`)}return S(Promise.all(D),e=>{f.warn(`Background flush of workflow argument streams failed`,{workflowRunId:y,error:e instanceof Error?e.message:String(e)})}),r?.setAttributes({...re(y),...oe(_),...W.status===`fulfilled`&&W.value.run?ae(W.value.run.status):{}}),new $(y,{resilientStart:q})})})}const pe=e=>Array.isArray(e)?e:[e];async function me(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await _(i):void 0,s=pe(await o(r.input,t,a,globalThis)),c=n.specVersion??r.specVersion??1,l=n.deploymentId??r.deploymentId;return(await Z({workflowId:r.workflowName},s,{deploymentId:l,world:e,specVersion:c,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function he(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=G(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ge(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(m(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=G(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],d=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),d++}catch(e){I.is(e)?d++:u.push(e instanceof Error?e:Error(String(e)))}}if(d>0&&await e.queue(m(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:d}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function _e(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ve(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}var $=class e{static[h](e){return{runId:e.runId,resilientStart:e.#r}}static[w](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=C(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await _(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(j.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:a,namespace:o}=e,s=i(this.runId,o),c=this.#a(),l=r(n,t,this.runId,c).ReadableStream({name:s,startIndex:a}),u=this.#t,d=this.runId;return Object.assign(l,{getTailIndex:async()=>(await(await u).streams.getInfo(d,s)).tailIndex})}async#o(){let e=await this.#t,t=0,n=this.#r?3:0,r=[1e3,3e3,6e3];for(;;)try{let t=await e.runs.get(this.runId);if(t.status===`completed`){let e=await this.#i();return await s(t.output,this.runId,e)}if(t.status===`cancelled`)throw new A(this.runId);if(t.status===`failed`){let e=await this.#i(),n;try{n=await y(t.error,this.runId,e)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new E(this.runId,n,{errorCode:t.errorCode})}throw new z(this.runId,t.status)}catch(e){if(z.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(j.is(e)&&t<n){let e=r[t];t++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function ye(e){return new $(e)}export{_e as a,Q as c,Y as d,J as f,ve as i,Z as l,ye as n,me as o,he as r,ge as s,$ as t,ue as u};
@@ -1 +0,0 @@
1
- import{In as e}from"./wait-until-z48sPUjU.js";import{i as t}from"./attribute-changes-1LmTKuTT.js";async function n(r){let i=globalThis[e];return i||t(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};