eve 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/src/channel/types.d.ts +11 -0
- package/dist/src/chunks/{use-eve-agent-BEOUv37s.js → use-eve-agent-Bh1NmXO9.js} +8 -5
- package/dist/src/chunks/{use-eve-agent-C25KOe9i.js → use-eve-agent-Dvy_Wjvq.js} +8 -5
- package/dist/src/cli/dev/tui/status-line.d.ts +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +2 -0
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/dev/url-target.d.ts +14 -0
- package/dist/src/cli/dev/url-target.js +1 -0
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/client.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +4 -4
- package/dist/src/compiled/@chat-adapter/slack/api.d.ts +132 -0
- package/dist/src/compiled/@chat-adapter/slack/api.js +1 -0
- package/dist/src/compiled/@chat-adapter/slack/blocks.js +1 -1
- package/dist/src/compiled/@chat-adapter/slack/format.d.ts +33 -0
- package/dist/src/compiled/@chat-adapter/slack/format.js +1 -0
- package/dist/src/compiled/@chat-adapter/slack/index.js +28 -28
- package/dist/src/compiled/@chat-adapter/slack/types-AntsVifS.d.ts +187 -0
- package/dist/src/compiled/@chat-adapter/slack/webhook.d.ts +10 -0
- package/dist/src/compiled/@chat-adapter/slack/webhook.js +1 -0
- package/dist/src/compiled/@workflow/core/classify-error.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime.js +27 -27
- package/dist/src/compiled/@workflow/core/serialization.d.ts +12 -3
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +10 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/_chunks/node/chunk-AYN7QRWH-B__hKQV7.js +1 -0
- package/dist/src/compiled/_chunks/node/chunk-HFKBBKCJ-CWaVIQuL.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-DUxG-Gic.js → attribute-changes-zAifvEhb.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{resume-hook-CUCPW67D.js → resume-hook-C15uJ2ik.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/run-BJUPZ0Ni.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{sleep-Dxuzj5to.js → sleep-C8B-TYir.js} +1 -1
- package/dist/src/compiler/manifest.d.ts +2 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/context/keys.d.ts +2 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/evals/assertions/run.js +2 -2
- package/dist/src/execution/create-session-step.d.ts +2 -0
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +3 -0
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session.d.ts +6 -1
- package/dist/src/execution/session.js +3 -3
- package/dist/src/execution/subagent-invocation.d.ts +20 -5
- package/dist/src/execution/subagent-invocation.js +2 -2
- package/dist/src/execution/subagent-tool.d.ts +7 -0
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +33 -0
- package/dist/src/harness/advertised-tools.js +1 -0
- package/dist/src/harness/subagent-depth.d.ts +17 -0
- package/dist/src/harness/subagent-depth.js +1 -0
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/turn-tag-state.d.ts +30 -22
- package/dist/src/harness/turn-tag-state.js +1 -1
- package/dist/src/harness/types.d.ts +28 -0
- package/dist/src/harness/workflow-continuation-security.d.ts +1 -0
- package/dist/src/harness/workflow-continuation-security.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/http/basic-auth.d.ts +1 -0
- package/dist/src/internal/http/basic-auth.js +1 -0
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +5 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -0
- package/dist/src/internal/nitro/routes/info.d.ts +2 -6
- package/dist/src/internal/nitro/routes/info.js +1 -1
- package/dist/src/protocol/routes.d.ts +2 -4
- package/dist/src/public/channels/eve.d.ts +5 -4
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +3 -6
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +11 -9
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/interactions.d.ts +2 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/mrkdwn.d.ts +3 -35
- package/dist/src/public/channels/slack/mrkdwn.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/verify.d.ts +4 -42
- package/dist/src/public/channels/slack/verify.js +1 -1
- package/dist/src/public/definitions/agent.d.ts +1 -1
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/services/dev-client/client-options.d.ts +5 -1
- package/dist/src/services/dev-client/client-options.js +1 -1
- package/dist/src/setup/boxes/preflight.js +1 -1
- package/dist/src/setup/boxes/select-model.js +1 -1
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/scaffold/create/project.d.ts +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +3 -0
- package/dist/src/setup/scaffold/create/web-template.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +37 -0
- package/dist/src/shared/default-agent-model.d.ts +1 -1
- package/dist/src/shared/default-agent-model.js +1 -1
- 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 +35 -8
- package/docs/channels/eve.mdx +3 -2
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/getting-started.mdx +5 -5
- package/docs/guides/dev-tui.md +7 -1
- package/docs/reference/cli.md +10 -1
- package/docs/reference/typescript-api.md +1 -1
- package/docs/subagents.mdx +19 -0
- package/package.json +5 -5
- package/dist/src/compiled/_chunks/node/chunk-AYN7QRWH-Csu8sG38.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-CVlF84yI.js +0 -1
|
@@ -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.0`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.2.2`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.17.
|
|
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.0`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.2.2`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.17.2`,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__",
|
|
@@ -39,8 +39,11 @@ export declare const WEB_APP_TEMPLATE_FILES: {
|
|
|
39
39
|
export declare const WEB_APP_TEMPLATE_PACKAGE_JSON: {
|
|
40
40
|
readonly scripts: {
|
|
41
41
|
readonly build: "next build";
|
|
42
|
+
readonly "build:eve": "eve build";
|
|
42
43
|
readonly dev: "next dev";
|
|
44
|
+
readonly "dev:eve": "eve dev";
|
|
43
45
|
readonly start: "next start";
|
|
46
|
+
readonly "start:eve": "eve start";
|
|
44
47
|
readonly typecheck: "tsc --noEmit -p tsconfig.json";
|
|
45
48
|
};
|
|
46
49
|
readonly dependencies: {
|
|
@@ -4798,4 +4798,4 @@ export default config;
|
|
|
4798
4798
|
],
|
|
4799
4799
|
"exclude": ["node_modules"]
|
|
4800
4800
|
}
|
|
4801
|
-
`},WEB_APP_TEMPLATE_PACKAGE_JSON={scripts:{build:`next build`,dev:`next dev`,start:`next start`,typecheck:`tsc --noEmit -p tsconfig.json`},dependencies:{"@radix-ui/react-use-controllable-state":`1.2.2`,"@shikijs/core":`4.1.0`,"@shikijs/engine-javascript":`4.1.0`,"@shikijs/engine-oniguruma":`4.1.0`,"@streamdown/cjk":`1.0.3`,"@streamdown/code":`1.1.1`,"@streamdown/math":`1.0.2`,"@streamdown/mermaid":`1.0.2`,"@tailwindcss/postcss":`4.3.0`,ai:`catalog:`,"class-variance-authority":`0.7.1`,clsx:`2.1.1`,cmdk:`1.1.1`,eve:`workspace:*`,"lucide-react":`1.16.0`,motion:`12.40.0`,nanoid:`5.1.11`,next:`catalog:`,"radix-ui":`1.4.3`,react:`catalog:`,"react-dom":`catalog:`,shiki:`4.1.0`,streamdown:`catalog:`,"tailwind-merge":`3.6.0`,tailwindcss:`4.3.0`,"use-stick-to-bottom":`1.1.4`,zod:`catalog:`},devDependencies:{"@types/node":`catalog:`,"@types/react":`catalog:`,"@types/react-dom":`catalog:`,typescript:`6.0.3`}};export{WEB_APP_TEMPLATE_FILES,WEB_APP_TEMPLATE_PACKAGE_JSON};
|
|
4801
|
+
`},WEB_APP_TEMPLATE_PACKAGE_JSON={scripts:{build:`next build`,"build:eve":`eve build`,dev:`next dev`,"dev:eve":`eve dev`,start:`next start`,"start:eve":`eve start`,typecheck:`tsc --noEmit -p tsconfig.json`},dependencies:{"@radix-ui/react-use-controllable-state":`1.2.2`,"@shikijs/core":`4.1.0`,"@shikijs/engine-javascript":`4.1.0`,"@shikijs/engine-oniguruma":`4.1.0`,"@streamdown/cjk":`1.0.3`,"@streamdown/code":`1.1.1`,"@streamdown/math":`1.0.2`,"@streamdown/mermaid":`1.0.2`,"@tailwindcss/postcss":`4.3.0`,ai:`catalog:`,"class-variance-authority":`0.7.1`,clsx:`2.1.1`,cmdk:`1.1.1`,eve:`workspace:*`,"lucide-react":`1.16.0`,motion:`12.40.0`,nanoid:`5.1.11`,next:`catalog:`,"radix-ui":`1.4.3`,react:`catalog:`,"react-dom":`catalog:`,shiki:`4.1.0`,streamdown:`catalog:`,"tailwind-merge":`3.6.0`,tailwindcss:`4.3.0`,"use-stick-to-bottom":`1.1.4`,zod:`catalog:`},devDependencies:{"@types/node":`catalog:`,"@types/react":`catalog:`,"@types/react-dom":`catalog:`,typescript:`6.0.3`}};export{WEB_APP_TEMPLATE_FILES,WEB_APP_TEMPLATE_PACKAGE_JSON};
|
|
@@ -93,6 +93,38 @@ export interface PublicAgentCompactionDefinition {
|
|
|
93
93
|
*/
|
|
94
94
|
readonly thresholdPercent?: number;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Configures framework-owned runtime limits for this agent's runs.
|
|
98
|
+
*/
|
|
99
|
+
export interface AgentLimitsDefinition {
|
|
100
|
+
/**
|
|
101
|
+
* Maximum number of delegated child-session levels from the root session.
|
|
102
|
+
*
|
|
103
|
+
* Root sessions are depth 0. A `maxSubagentDepth` of 3 allows child sessions at
|
|
104
|
+
* depths 1, 2, and 3; sessions already at depth 3 cannot delegate again.
|
|
105
|
+
*
|
|
106
|
+
* @default 3
|
|
107
|
+
*/
|
|
108
|
+
readonly maxSubagentDepth?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Maximum provider-reported input tokens accumulated by one durable session.
|
|
111
|
+
*
|
|
112
|
+
* eve checks this before starting each model call. The model call that crosses
|
|
113
|
+
* the limit is allowed to finish because providers only report exact usage
|
|
114
|
+
* after the call completes; later model calls in the same session are blocked.
|
|
115
|
+
*
|
|
116
|
+
* @default 40_000_000 for root sessions; 5_000_000 for delegated subagent sessions
|
|
117
|
+
*/
|
|
118
|
+
readonly maxInputTokensPerSession?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Maximum provider-reported output tokens accumulated by one durable session.
|
|
121
|
+
*
|
|
122
|
+
* eve checks this before starting each model call. The model call that crosses
|
|
123
|
+
* the limit is allowed to finish because providers only report exact usage
|
|
124
|
+
* after the call completes; later model calls in the same session are blocked.
|
|
125
|
+
*/
|
|
126
|
+
readonly maxOutputTokensPerSession?: number;
|
|
127
|
+
}
|
|
96
128
|
/**
|
|
97
129
|
* Experimental, opt-in agent capabilities authored in `agent.ts`.
|
|
98
130
|
*
|
|
@@ -155,6 +187,7 @@ export type InternalAgentDefinition = {
|
|
|
155
187
|
outputSchema?: JsonObject;
|
|
156
188
|
reasoning?: AgentReasoningDefinition;
|
|
157
189
|
source?: ModuleSourceRef;
|
|
190
|
+
limits?: AgentLimitsDefinition;
|
|
158
191
|
};
|
|
159
192
|
/**
|
|
160
193
|
* Shared public definition for an agent.
|
|
@@ -197,6 +230,10 @@ export type PublicAgentDefinition = {
|
|
|
197
230
|
* Support for individual levels depends on the selected model and provider.
|
|
198
231
|
*/
|
|
199
232
|
readonly reasoning?: AgentReasoningDefinition;
|
|
233
|
+
/**
|
|
234
|
+
* Framework-owned runtime limits for this agent's runs.
|
|
235
|
+
*/
|
|
236
|
+
readonly limits?: AgentLimitsDefinition;
|
|
200
237
|
/**
|
|
201
238
|
* Optional structured return type used when this agent runs in task mode
|
|
202
239
|
* (for example as a subagent, schedule, or remote job). Interactive
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Model used when an agent does not declare one, baked in by `eve init`, and
|
|
3
3
|
* pre-selected in the setup model picker.
|
|
4
4
|
*/
|
|
5
|
-
export declare const DEFAULT_AGENT_MODEL_ID = "anthropic/claude-sonnet-
|
|
5
|
+
export declare const DEFAULT_AGENT_MODEL_ID = "anthropic/claude-sonnet-5";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const DEFAULT_AGENT_MODEL_ID=`anthropic/claude-sonnet-
|
|
1
|
+
const DEFAULT_AGENT_MODEL_ID=`anthropic/claude-sonnet-5`;export{DEFAULT_AGENT_MODEL_ID};
|
package/dist/src/svelte/index.js
CHANGED
package/dist/src/vue/index.js
CHANGED
package/docs/agent-config.md
CHANGED
|
@@ -18,7 +18,7 @@ export default defineAgent({
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The root `agent.ts` can be omitted when no runtime config is needed. In that case, eve defaults
|
|
21
|
-
to `anthropic/claude-sonnet-
|
|
21
|
+
to `anthropic/claude-sonnet-5`. When `agent.ts` is present, `model` is required.
|
|
22
22
|
|
|
23
23
|
`model` accepts a gateway model id string, which routes through the [Vercel AI Gateway](https://vercel.com/docs/ai-gateway). To call a provider directly and configure the model in code, pass a provider-authored `LanguageModel`.
|
|
24
24
|
|
|
@@ -75,6 +75,32 @@ export default defineAgent({
|
|
|
75
75
|
|
|
76
76
|
See [Default harness](./concepts/default-harness#compaction) for how the loop applies it.
|
|
77
77
|
|
|
78
|
+
## Runtime limits
|
|
79
|
+
|
|
80
|
+
Use `limits` for framework-owned runtime caps. Session token limits stop the
|
|
81
|
+
current durable session from starting another model call after accumulated
|
|
82
|
+
provider-reported input or output token usage reaches the configured limit:
|
|
83
|
+
|
|
84
|
+
```ts title="agent/agent.ts"
|
|
85
|
+
export default defineAgent({
|
|
86
|
+
model: "anthropic/claude-opus-4.8",
|
|
87
|
+
limits: {
|
|
88
|
+
maxInputTokensPerSession: 200_000,
|
|
89
|
+
maxOutputTokensPerSession: 20_000,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Input and output budgets are checked independently. The model call that crosses
|
|
95
|
+
either limit is allowed to finish because providers only report exact token
|
|
96
|
+
usage after a call completes. Follow-up model calls in the same session fail
|
|
97
|
+
with `SESSION_TOKEN_LIMIT_REACHED`.
|
|
98
|
+
|
|
99
|
+
When `maxInputTokensPerSession` is omitted, eve applies a default input budget:
|
|
100
|
+
`40_000_000` provider-reported input tokens for root sessions and `5_000_000`
|
|
101
|
+
for delegated subagent sessions. `maxOutputTokensPerSession` is unset unless
|
|
102
|
+
configured.
|
|
103
|
+
|
|
78
104
|
## Workflow world
|
|
79
105
|
|
|
80
106
|
By default, eve selects the Workflow SDK world for the host: Vercel Workflow on
|
|
@@ -116,13 +142,14 @@ installed package must stay external in hosted output, list it in
|
|
|
116
142
|
|
|
117
143
|
`defineAgent` takes a few more fields, all optional. For the exported types, see the [TypeScript API](./reference/typescript-api).
|
|
118
144
|
|
|
119
|
-
| Field | Type | Default | Description
|
|
120
|
-
| -------------- | --------------------------------------- | ---------------- |
|
|
121
|
-
| `reasoning` | `AgentReasoningDefinition` | provider default | Provider-agnostic reasoning effort forwarded to the agent's turn model calls.
|
|
122
|
-
| `modelOptions` | `AgentModelOptionsDefinition` | none | Provider option overrides forwarded to the model call.
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
145
|
+
| Field | Type | Default | Description |
|
|
146
|
+
| -------------- | --------------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| `reasoning` | `AgentReasoningDefinition` | provider default | Provider-agnostic reasoning effort forwarded to the agent's turn model calls. |
|
|
148
|
+
| `modelOptions` | `AgentModelOptionsDefinition` | none | Provider option overrides forwarded to the model call. |
|
|
149
|
+
| `limits` | `AgentLimitsDefinition` | field-specific | Framework-owned runtime limits. `maxSubagentDepth` defaults to `3`; `maxInputTokensPerSession` defaults to `40_000_000` for root sessions and `5_000_000` for delegated subagent sessions; `maxOutputTokensPerSession` is unset unless configured. |
|
|
150
|
+
| `experimental` | `{ workflow?: { world?: string } }` | unset | Opt-in settings that can change or disappear in any release. Treat them as unstable. `workflow.world` selects the Workflow world package backing session state, queues, hooks, and streams on the root agent. |
|
|
151
|
+
| `outputSchema` | Standard Schema or a JSON Schema object | none | Structured return type for task-mode runs (a subagent, schedule, or remote job). Interactive conversation turns ignore it unless the client supplies a per-message schema. |
|
|
152
|
+
| `build` | `{ externalDependencies?: string[] }` | none | Hosted-build packaging controls. `externalDependencies` keeps listed packages external while eve compiles authored modules such as tools and channels, and traces those packages into the hosted output. |
|
|
126
153
|
|
|
127
154
|
`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.
|
|
128
155
|
|
package/docs/channels/eve.mdx
CHANGED
|
@@ -18,9 +18,10 @@ export default eveChannel({
|
|
|
18
18
|
|
|
19
19
|
## Routes
|
|
20
20
|
|
|
21
|
-
The
|
|
21
|
+
The application exposes a health route plus eve channel routes that inspect the agent, create sessions, send follow-ups, and stream events:
|
|
22
22
|
|
|
23
23
|
- `GET /eve/v1/health`
|
|
24
|
+
- `GET /eve/v1/info`
|
|
24
25
|
- `POST /eve/v1/session` (start a session)
|
|
25
26
|
- `POST /eve/v1/session/:sessionId` (send a follow-up)
|
|
26
27
|
- `GET /eve/v1/session/:sessionId/stream` (stream events, NDJSON)
|
|
@@ -70,7 +71,7 @@ export default eveChannel({
|
|
|
70
71
|
|
|
71
72
|
## Authentication
|
|
72
73
|
|
|
73
|
-
The `auth` option decides who can call
|
|
74
|
+
The `auth` option decides who can call `/eve/v1/info` and the session routes. The built-in helpers cover development and trusted infrastructure:
|
|
74
75
|
|
|
75
76
|
- `localDev()` accepts requests during local development.
|
|
76
77
|
- `vercelOidc()` lets the local CLI reach a deployed agent, and lets other internal deployments from your team call it.
|
|
@@ -104,13 +104,13 @@ Start with the [TypeScript SDK](../guides/client/overview) guide. It covers basi
|
|
|
104
104
|
|
|
105
105
|
## Inspect the agent over HTTP
|
|
106
106
|
|
|
107
|
-
`GET /eve/v1/info` returns a JSON inspection snapshot for the running agent: model, instructions, authored and framework tools, skills, channels, schedules, subagents, sandbox, connections, hooks, workflow, and workspace metadata.
|
|
107
|
+
`GET /eve/v1/info` returns a JSON inspection snapshot for the running agent: model, instructions, authored and framework tools, skills, channels, schedules, subagents, sandbox, connections, hooks, workflow, and workspace metadata. It uses the resolved `eveChannel()` route auth when `agent/channels/eve.ts` authors one; otherwise it falls back to the framework default of Vercel OIDC plus local development access.
|
|
108
108
|
|
|
109
109
|
```bash
|
|
110
110
|
curl http://127.0.0.1:3000/eve/v1/info
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
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).
|
|
114
114
|
|
|
115
115
|
## Dispatch order
|
|
116
116
|
|
package/docs/getting-started.mdx
CHANGED
|
@@ -11,7 +11,7 @@ eve is a filesystem-first framework for durable agents. You write capabilities u
|
|
|
11
11
|
- npm (bundled with Node)
|
|
12
12
|
- A model credential (see below)
|
|
13
13
|
|
|
14
|
-
The scaffold's default model is `anthropic/claude-sonnet-
|
|
14
|
+
The scaffold's default model is `anthropic/claude-sonnet-5`, which routes through the Vercel AI Gateway. Set one of these before you run the agent:
|
|
15
15
|
|
|
16
16
|
- A gateway model id needs `AI_GATEWAY_API_KEY`, or a `VERCEL_OIDC_TOKEN` pulled with `vercel link`.
|
|
17
17
|
- A direct provider model uses that provider's AI SDK package and API key. For example, `anthropic("claude-...")` from `@ai-sdk/anthropic` needs `ANTHROPIC_API_KEY`.
|
|
@@ -79,7 +79,7 @@ You are a concise assistant. Use tools when they are available.
|
|
|
79
79
|
import { defineAgent } from "eve";
|
|
80
80
|
|
|
81
81
|
export default defineAgent({
|
|
82
|
-
model: "anthropic/claude-sonnet-
|
|
82
|
+
model: "anthropic/claude-sonnet-5",
|
|
83
83
|
});
|
|
84
84
|
```
|
|
85
85
|
|
|
@@ -137,7 +137,7 @@ The same CLI can point at a deployment. `npx eve dev https://your-app.vercel.app
|
|
|
137
137
|
Every eve app exposes the same stable HTTP API. Start a durable session:
|
|
138
138
|
|
|
139
139
|
```bash
|
|
140
|
-
curl -X POST http://127.0.0.1:
|
|
140
|
+
curl -X POST http://127.0.0.1:2000/eve/v1/session \
|
|
141
141
|
-H 'content-type: application/json' \
|
|
142
142
|
-d '{"message":"What is the weather in Brooklyn?"}'
|
|
143
143
|
```
|
|
@@ -152,7 +152,7 @@ The response comes back with two things you'll reuse:
|
|
|
152
152
|
Attach to the session stream:
|
|
153
153
|
|
|
154
154
|
```bash
|
|
155
|
-
curl http://127.0.0.1:
|
|
155
|
+
curl http://127.0.0.1:2000/eve/v1/session/<sessionId>/stream
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
The stream is NDJSON, served as `application/x-ndjson; charset=utf-8`. For this run you'll see a handful of lifecycle events:
|
|
@@ -174,7 +174,7 @@ The full set covers more lifecycle, human-in-the-loop, and authorization events,
|
|
|
174
174
|
When the session is waiting for the next user message, post a follow-up with the token:
|
|
175
175
|
|
|
176
176
|
```bash
|
|
177
|
-
curl -X POST http://127.0.0.1:
|
|
177
|
+
curl -X POST http://127.0.0.1:2000/eve/v1/session/<sessionId> \
|
|
178
178
|
-H 'content-type: application/json' \
|
|
179
179
|
-d '{"continuationToken":"<token>","message":"Now do Queens."}'
|
|
180
180
|
```
|
package/docs/guides/dev-tui.md
CHANGED
|
@@ -128,7 +128,13 @@ Pass a URL and the TUI talks to a running deployment instead of starting a local
|
|
|
128
128
|
eve dev https://<your-app>
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
The bare URL is shorthand for `--url`; it cannot be combined with `--host`, `--port`, or `--no-ui`.
|
|
131
|
+
The bare URL is shorthand for `--url`; it cannot be combined with `--host`, `--port`, or `--no-ui`. For HTTP Basic auth, put credentials in the URL; eve sends them as a Basic `Authorization` header and strips them from the server URL before connecting:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
eve dev https://user:pass@<your-app>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
For bearer tokens or custom schemes, repeat `-H, --header` to attach request headers.
|
|
132
138
|
|
|
133
139
|
At startup the TUI asks Vercel to resolve the remote origin under the active scope. A resolved response is the authority for a project-scoped OIDC token—refreshing an expired development token when refresh credentials exist—or an automation-bypass secret. An unresolved host is probed anonymously. The TUI then requests `/eve/v1/info`, with a ten-second timeout. A successful response marks the remote ready. An eve OIDC challenge, Vercel Deployment Protection challenge, or `TRUSTED_SOURCES_ENVIRONMENT_MISMATCH` opens `/vc:login` automatically; ordinary network failures and server errors remain remote-availability errors and do not start an authentication flow. Esc or Ctrl-C cancels the authentication flow.
|
|
134
140
|
|
package/docs/reference/cli.md
CHANGED
|
@@ -91,13 +91,14 @@ eve dev [options]
|
|
|
91
91
|
eve dev https://your-app.vercel.app
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
Pass a bare URL
|
|
94
|
+
Pass a bare URL and the UI connects to that server instead of booting a local one (same as `--url`), which lets you smoke-test a preview or production deployment. The interactive UI turns off in a non-TTY terminal.
|
|
95
95
|
|
|
96
96
|
| Flag | Type | Default | Description |
|
|
97
97
|
| ----------------------------------- | ------ | ------------------ | ----------------------------------------------------------------------------------------- |
|
|
98
98
|
| `--host <host>` | string | all interfaces | Host interface to bind |
|
|
99
99
|
| `--port <port>` | number | `$PORT`, then 3000 | Port to listen on |
|
|
100
100
|
| `-u, --url <url>` | string | none | Connect to an existing server URL instead of starting one |
|
|
101
|
+
| `-H, --header <header>` | string | none | Request header for a URL target, in `Name: value` form; repeat for multiple headers |
|
|
101
102
|
| `--no-ui` | flag | UI on | Start the server without an interactive UI |
|
|
102
103
|
| `--name <name>` | string | app folder name | Title shown in the terminal UI |
|
|
103
104
|
| `--input <text>` | string | none | Pre-fill the prompt input; bare local `/model` starts onboarding |
|
|
@@ -111,6 +112,14 @@ Pass a bare URL as the only argument and the UI connects to that server instead
|
|
|
111
112
|
|
|
112
113
|
A fresh `eve init` passes `--input /model`. That bare local input starts onboarding: the TUI installs the Vercel CLI if needed, asks you to log in if needed, then opens `/model`. Other input stays editable in the prompt.
|
|
113
114
|
|
|
115
|
+
For a URL target protected by HTTP Basic auth, put the credentials in the URL. Eve sends them as a Basic `Authorization` header and strips them from the server URL before connecting:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
eve dev https://user:pass@your-app.example.com
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For bearer tokens or custom schemes, pass explicit headers with `-H`.
|
|
122
|
+
|
|
114
123
|
Local dev records the last ready URL per resolved app root in `.eve/dev-server-state.v1.json`. A second interactive `eve dev` reconnects only when that URL is loopback and healthy; each terminal UI creates a fresh client session while sharing the server process. A stale or malformed record is replaced when eve starts a new server. Passing `--host`, `--port`, or a `PORT` environment value skips reconnection and reports a healthy recorded server instead.
|
|
115
124
|
|
|
116
125
|
Local dev keeps immutable runtime source snapshots under `.eve/dev-runtime/snapshots/` so in-flight sessions hold a consistent code revision while new prompts pick up rebuilds. On startup, `eve dev` prunes stale runtime snapshots and old local sandbox templates in the background. For manual cleanup, stop `eve dev` and delete `.eve/dev-runtime/snapshots/` or `.eve/sandbox-cache/local/templates/`.
|
|
@@ -52,7 +52,7 @@ export default defineTool({
|
|
|
52
52
|
| `mockModel` | `eve/evals` | Deterministic fixture agent models | [Evals](../evals/overview) |
|
|
53
53
|
| `useEveAgent` | `eve/react`, `eve/vue`, `eve/svelte` | frontend | [Frontend](../guides/frontend/overview) |
|
|
54
54
|
|
|
55
|
-
A few non-`define*` helpers round out the set: `disableTool` from `eve/tools` (see [Default harness](../concepts/default-harness)), the route verbs `GET`/`POST`/`PUT`/`PATCH`/`DELETE`/`WS` from `eve/channels`, the approval policies `always`/`once`/`never` from `eve/tools/approval`, and the channel auth helpers `localDev`/`vercelOidc`/`placeholderAuth` from `eve/channels/auth`. To wrap a built-in tool, import its default value from `eve/tools/defaults` (`bash`, `readFile`, `writeFile`, `glob`, `grep`, `webFetch`, `webSearch`, `todo`, `loadSkill`). `AgentReasoningDefinition` is exported from `eve` for the top-level `defineAgent({ reasoning })` setting. `AgentWorkflowDefinition` and `AgentWorkflowWorldDefinition` are exported from `eve` for the `defineAgent({ experimental: { workflow } })` config shape.
|
|
55
|
+
A few non-`define*` helpers round out the set: `disableTool` from `eve/tools` (see [Default harness](../concepts/default-harness)), the route verbs `GET`/`POST`/`PUT`/`PATCH`/`DELETE`/`WS` from `eve/channels`, the approval policies `always`/`once`/`never` from `eve/tools/approval`, and the channel auth helpers `localDev`/`vercelOidc`/`placeholderAuth` from `eve/channels/auth`. To wrap a built-in tool, import its default value from `eve/tools/defaults` (`bash`, `readFile`, `writeFile`, `glob`, `grep`, `webFetch`, `webSearch`, `todo`, `loadSkill`). `AgentReasoningDefinition` is exported from `eve` for the top-level `defineAgent({ reasoning })` setting. `AgentLimitsDefinition` is exported for `defineAgent({ limits })`. `AgentWorkflowDefinition` and `AgentWorkflowWorldDefinition` are exported from `eve` for the `defineAgent({ experimental: { workflow } })` config shape.
|
|
56
56
|
|
|
57
57
|
## Runtime context (`ctx`)
|
|
58
58
|
|
package/docs/subagents.mdx
CHANGED
|
@@ -77,6 +77,25 @@ The built-in `agent` tool is the exception. Its children share the parent's sand
|
|
|
77
77
|
|
|
78
78
|
eve lowers every subagent (built-in copy, declared, or [remote](./guides/remote-agents)) into a model-visible tool with the same `{ message, outputSchema? }` shape. The parent packs `message` with everything the child needs, since the child never sees the parent's history. Set `outputSchema` to run the child in task mode, returning structured output as the tool result.
|
|
79
79
|
|
|
80
|
+
Subagent delegation is capped by default at three child-session levels. Increase
|
|
81
|
+
or lower that limit with `limits.maxSubagentDepth`:
|
|
82
|
+
|
|
83
|
+
```ts title="agent/agent.ts"
|
|
84
|
+
export default defineAgent({
|
|
85
|
+
model: "anthropic/claude-sonnet-5",
|
|
86
|
+
limits: {
|
|
87
|
+
maxSubagentDepth: 4,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The root session is depth 0. With `maxSubagentDepth: 4`, eve may create child sessions
|
|
93
|
+
at depths 1 through 4; a session already at depth 4 cannot delegate again.
|
|
94
|
+
|
|
95
|
+
At the configured depth, eve stops advertising subagent tools, including declared local subagents, remote-agent tools, the built-in `agent` tool, and the `Workflow` orchestration tool when it would only expose subagents. If a stale or forced subagent call still reaches execution, eve blocks it and returns an error tool result instead of starting another child session.
|
|
96
|
+
|
|
97
|
+
`Workflow` is root-only. Delegated subagent sessions can still call their own visible subagent tools until the depth cap, but they do not receive the `Workflow` orchestration wrapper.
|
|
98
|
+
|
|
80
99
|
A declared subagent's tool name is the bare path-derived name, with no prefix. `agent/subagents/researcher/` registers as the tool `researcher`. Unlike connection tools (`<connection>__<tool>`), it carries no namespace, so the model, approvals, logs, and evals all reference it by that name. Its input schema is:
|
|
81
100
|
|
|
82
101
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
|
|
6
6
|
"keywords": [
|
|
@@ -287,11 +287,11 @@
|
|
|
287
287
|
"@vercel/oidc": "3.5.0",
|
|
288
288
|
"@vercel/sandbox": "2.2.1",
|
|
289
289
|
"@vercel/sdk": "1.28.1",
|
|
290
|
-
"@workflow/core": "5.0.0-beta.
|
|
290
|
+
"@workflow/core": "5.0.0-beta.26",
|
|
291
291
|
"@workflow/errors": "5.0.0-beta.8",
|
|
292
|
-
"@workflow/serde": "
|
|
293
|
-
"@workflow/world": "5.0.0-beta.
|
|
294
|
-
"@workflow/world-local": "5.0.0-beta.
|
|
292
|
+
"@workflow/serde": "5.0.0-beta.2",
|
|
293
|
+
"@workflow/world": "5.0.0-beta.14",
|
|
294
|
+
"@workflow/world-local": "5.0.0-beta.22",
|
|
295
295
|
"ai": "^7.0.0",
|
|
296
296
|
"autoevals": "0.0.132",
|
|
297
297
|
"chat": "4.31.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=/(?<![<\w])@([A-Z][A-Z0-9_]+)/g;function t(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function n(e){let n=e;return n=n.replace(/<@([A-Z0-9_]+)\|([^<>]+)>/g,`@$2`),n=n.replace(/<@([A-Z0-9_]+)>/g,`@$1`),n=n.replace(/<#[A-Z0-9_]+\|([^<>]+)>/g,`#$1`),n=n.replace(/<#([A-Z0-9_]+)>/g,`#$1`),n=n.replace(/<(https?:\/\/[^|<>]+)\|([^<>]+)>/g,`[$2]($1)`),n=n.replace(/<(https?:\/\/[^<>]+)>/g,`$1`),n=n.replace(/(?<![_*\\])\*([^*\n]+)\*(?![_*])/g,`**$1**`),n=n.replace(/(?<!~)~([^~\n]+)~(?!~)/g,`~~$1~~`),t(n)}function r(e){return e.replace(/\*\*(.+?)\*\*/g,`*$1*`)}function i(t){return t.replace(e,`<@$1>`)}export{r as n,n as r,i as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e}from"./dist-FLIfyJ4Y.js";import{C as t,S as n,T as r,b as i,m as a,r as o,w as s,x as c}from"./dist-Dxrjttr2.js";import{A as l,At as u,C as d,Dn as f,Gt as p,It as m,J as h,L as g,Lt as _,Q as v,T as y,Wt as b,Y as x,_n as S,a as C,b as w,en as T,gn as E,hn as D,k as O,kn as k,m as A,n as j,p as M,r as N,s as P,t as F,xn as I,z as L}from"./attribute-changes-DUxG-Gic.js";const R=f();let z=!1;async function B(t,n,r){"use step";return await N(()=>{let i=t?.workflowId;if(!i)throw new s(`'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 x(`workflow.start ${e(i)}`,async e=>{e?.setAttributes({...m(i),..._(`start`)});let t=[],a=r??{};Array.isArray(n)?t=n:typeof n==`object`&&(a=n),e?.setAttributes({...u(t.length)});let c=a?.world??await S(),l=await c.getDeploymentId(),d=a.deploymentId??l;d===`latest`&&(c.resolveLatestDeploymentId?d=await c.resolveLatestDeploymentId():(z||(z=!0,L.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:l})),d=l));let f,g;if(d===l)f=!0,g=!0;else if(typeof c.streams?.get!=`function`)f=!1,g=!1;else{let e=A((await P(c,`workflow`,{deploymentId:d,timeout:2e3}).catch(()=>void 0))?.workflowCoreVersion);f=e.framedByteStreams,g=e.supportedFormats.has(T.GZIP)}let y=[],x=`wrun_${R()}`,E=await h(),D=a.specVersion??c.specVersion??2,O=k(D),N=a.allowReservedAttributes===!0,B;if(a.attributes&&Object.keys(a.attributes).length>0){if(D<4)throw new s(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(a.attributes))if(typeof t!=`string`)throw new s(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=F(a.attributes,{allowReservedAttributes:N});B=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let H=B?{attributes:B,...N?{allowReservedAttributes:!0}:{}}:{},U=await c.getEncryptionKeyForRun?.(x,{...a,deploymentId:d}),W=U?await I(U):void 0,G=await w(t,x,W,y,globalThis,O,f,g&&D>=5),K={traceCarrier:E,workflowCoreVersion:M,features:{encryption:!!W}},[q,J]=await Promise.allSettled([c.events.create(x,{eventType:`run_created`,specVersion:D,eventData:{deploymentId:d,workflowName:i,input:G,executionContext:K,...H}},{v1Compat:O}),c.queue(C(i),{runId:x,traceCarrier:E,...D>=3?{runInput:{input:G,deploymentId:d,workflowName:i,specVersion:D,executionContext:K,...H}}:{}},{deploymentId:d,specVersion:D})]);if(J.status===`rejected`)throw J.reason;let X=!1;if(q.status===`rejected`){let e=q.reason;if(!o.is(e))if(V(e))X=!0,L.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:x,error:e.message});else throw e}else{let e=q.value;if(!e.run)throw new s(`Missing 'run' in server response for 'run_created' event`);if(!O&&e.run.runId!==x)throw new s(`Server returned different runId than requested: expected ${x}, got ${e.run.runId}`)}return j(Promise.all(y),e=>{L.warn(`Background flush of workflow argument streams failed`,{workflowRunId:x,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...b(x),...v(d),...q.status===`fulfilled`&&q.value.run?p(q.value.run.status):{}}),new Y(x,{resilientStart:X})})})}function V(e){return!!(a.is(e)||r.is(e)&&e.status&&e.status>=500)}const H=e=>Array.isArray(e)?e:[e];async function U(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await I(i):void 0,o=H(await O(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await B({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function W(e,t){try{let n=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,r=k(n),i={eventType:`run_cancelled`,specVersion:n};await e.events.create(t,i,{v1Compat:r})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function G(e,t){try{let n=await e.runs.get(t,{resolveData:`none`});await e.queue(C(n.workflowName),{runId:t},{deploymentId:n.deploymentId,specVersion:n.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function K(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=k(r.specVersion),a=[],s=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...s?{cursor:s}:{}},resolveData:`none`});a.push(...n.data),s=n.hasMore?n.cursor:null}while(s);let c=a.filter(e=>e.eventType===`wait_created`),l=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),u=c.filter(e=>!l.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);u=u.filter(t=>t.correlationId&&e.has(t.correlationId))}let d=[],f=0;for(let n of u){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),f++}catch(e){o.is(e)?f++:d.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await e.queue(C(r.workflowName),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),d.length>0)throw AggregateError(d,`Failed to complete ${d.length}/${u.length} pending wait(s) for run ${t}`);return{stoppedCount:f}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function q(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 J(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 Y=class e{static[E](e){return{runId:e.runId,resilientStart:e.#r}}static[D](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=S(),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 I(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return K(await this.#t,this.runId,e)}async cancel(){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(t.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:i}=e,a=g(this.runId,i),o=this.#a(),s=d(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}async#o(){let e=await this.#t,r=0,a=this.#r?3:0,o=[1e3,3e3,6e3];for(;;)try{let t=await e.runs.get(this.runId);if(t.status===`completed`){let e=await this.#i();return await l(t.output,this.runId,e)}if(t.status===`cancelled`)throw new i(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 c(this.runId,n,{errorCode:t.errorCode})}throw new n(this.runId,t.status)}catch(e){if(n.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(t.is(e)&&r<a){let e=o[r];r++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function X(e){return new Y(e)}export{q as a,K as c,J as i,B as l,X as n,U as o,W as r,G as s,Y as t};
|