eve 0.29.4 → 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.
- package/CHANGELOG.md +28 -0
- package/dist/src/channel/clear-session.d.ts +4 -0
- package/dist/src/channel/clear-session.js +1 -0
- package/dist/src/channel/compact-session.d.ts +4 -0
- package/dist/src/channel/compact-session.js +1 -0
- package/dist/src/channel/routes.d.ts +34 -6
- package/dist/src/channel/types.d.ts +61 -9
- package/dist/src/chunks/{use-eve-agent-8mofdZcO.js → use-eve-agent-BXMIf5fR.js} +85 -1
- package/dist/src/chunks/{use-eve-agent-bKJbH0k4.js → use-eve-agent-k-XHfrJT.js} +85 -1
- package/dist/src/cli/dev/tui/message-queue.d.ts +12 -16
- package/dist/src/cli/dev/tui/message-queue.js +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +13 -5
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +7 -7
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.js +4 -1
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +5 -5
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/client/agent-info-schema.d.ts +2 -2
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/session.d.ts +15 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +20 -0
- package/dist/src/compiled/.vendor-stamp.json +6 -6
- package/dist/src/compiled/@workflow/core/_devalue.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +18 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +103 -31
- package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +36 -0
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +22 -2
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +17 -13
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +13 -8
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +17 -0
- package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +155 -0
- package/dist/src/compiled/@workflow/core/serialization/index.d.ts +2 -1
- package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization.d.ts +13 -9
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +41 -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/@workflow/errors/index.d.ts +16 -8
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +2 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +87 -0
- package/dist/src/compiled/@workflow/world/hooks.d.ts +39 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +61 -0
- package/dist/src/compiled/@workflow/world/queue.d.ts +40 -0
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +14 -14
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-1LmTKuTT.js → attribute-changes-DROfGk6l.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/{dist-WjtNsOyf.js → dist-D5bR13zs.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-BeQ_csYA.js → dist-dNxTT6nO.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/resume-hook-bc-OQVI0.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DM3ouA3U.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-D5iWly6-.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-DoW76jdb.js +15 -0
- package/dist/src/compiler/extension-compatibility.d.ts +8 -8
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +11 -22
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.d.ts +3 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-subagent.d.ts +1 -0
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/compiler/remote-agent-node.d.ts +3 -0
- package/dist/src/context/dynamic-subagent-lifecycle.d.ts +22 -0
- package/dist/src/context/dynamic-subagent-lifecycle.js +1 -0
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +21 -2
- package/dist/src/context/keys.js +1 -1
- package/dist/src/context/run-step.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- 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/delegation-tool.d.ts +3 -0
- package/dist/src/execution/delegation-tool.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/effective-agent-config.d.ts +12 -0
- package/dist/src/execution/effective-agent-config.js +1 -0
- package/dist/src/execution/node-step.d.ts +4 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/remote-agent-dispatch.d.ts +3 -1
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/runtime-context.d.ts +2 -0
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session-callback-request.d.ts +5 -0
- package/dist/src/execution/session-callback-request.js +1 -0
- package/dist/src/execution/session-delivery-hook.d.ts +1 -0
- package/dist/src/execution/session-delivery-hook.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +2 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/agent-handles.d.ts +238 -0
- package/dist/src/harness/agent-handles.js +2 -0
- package/dist/src/harness/compaction.d.ts +1 -1
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/types.d.ts +16 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +1 -1
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.d.ts +10 -0
- package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -0
- package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.d.ts +7 -0
- package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +3 -0
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +2 -0
- package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
- package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
- package/dist/src/protocol/clear-session.d.ts +14 -0
- package/dist/src/protocol/clear-session.js +1 -0
- package/dist/src/protocol/compact-session.d.ts +14 -0
- package/dist/src/protocol/compact-session.js +1 -0
- package/dist/src/protocol/message.d.ts +19 -1
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/protocol/routes.d.ts +10 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/auth.d.ts +11 -25
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/definitions/agent.d.ts +35 -1
- package/dist/src/public/definitions/agent.js +1 -1
- package/dist/src/public/definitions/channel.d.ts +5 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +1 -0
- package/dist/src/public/definitions/tool.d.ts +4 -1
- package/dist/src/public/index.d.ts +1 -2
- package/dist/src/public/index.js +1 -1
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/dist/src/runtime/framework-tools/connection-search-dynamic.d.ts +2 -18
- package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -2
- package/dist/src/runtime/framework-tools/index.d.ts +7 -2
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-dynamic-subagent.d.ts +12 -0
- package/dist/src/runtime/resolve-dynamic-subagent.js +1 -0
- package/dist/src/runtime/resolve-dynamic-tool.d.ts +15 -0
- package/dist/src/runtime/resolve-dynamic-tool.js +1 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +22 -0
- package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -0
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.d.ts +13 -0
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -0
- package/dist/src/runtime/subagents/registry.d.ts +10 -2
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +11 -2
- package/dist/src/setup/flows/registry.js +1 -1
- package/dist/src/setup/scaffold/channels-catalog.d.ts +2 -2
- package/dist/src/setup/scaffold/channels-catalog.js +1 -1
- package/dist/src/setup/scaffold/connections/catalog.d.ts +2 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +7 -0
- package/dist/src/shared/agent-turn-outcome.d.ts +47 -0
- package/dist/src/shared/agent-turn-outcome.js +1 -0
- package/dist/src/shared/dynamic-tool-definition.d.ts +1 -5
- package/dist/src/shared/dynamic-tool-definition.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/channels/custom.mdx +41 -1
- package/docs/channels/eve.mdx +27 -2
- package/docs/concepts/default-harness.md +4 -0
- package/docs/concepts/sessions-runs-and-streaming.md +1 -1
- package/docs/guides/auth-and-route-protection.md +13 -13
- package/docs/guides/client/streaming.mdx +14 -0
- package/docs/guides/dev-tui.md +12 -9
- package/docs/guides/dynamic-capabilities.md +74 -6
- package/docs/guides/frontend/nextjs.mdx +1 -1
- package/docs/guides/frontend/nuxt.mdx +1 -1
- package/docs/guides/frontend/sveltekit.mdx +1 -1
- package/docs/guides/remote-agents.md +33 -0
- package/docs/reference/project-layout.md +1 -1
- package/docs/reference/typescript-api.md +48 -48
- package/docs/subagents.mdx +32 -2
- package/package.json +8 -8
- package/dist/src/compiled/_chunks/workflow/resume-hook-D1_5NCZ6.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-C240Ctf4.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-De802yfX.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-z48sPUjU.js +0 -15
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Dynamic Capabilities"
|
|
3
|
-
description: "Resolve models, tools, skills, and instructions at runtime
|
|
3
|
+
description: "Resolve models, subagents, tools, skills, and instructions at runtime with defineDynamic resolver events."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`defineDynamic` resolves the model, tools, skills, and instructions at runtime from a session event instead of declaring them up front. Reach for it when the right capability isn't known until the session starts, because it hinges on who the caller is, what tenant they belong to, feature flags, or external data. The [tools](../tools), [skills](../skills), and [instructions](../instructions) guides each point here for their dynamic form.
|
|
6
|
+
`defineDynamic` resolves the model, subagents, tools, skills, and instructions at runtime from a session event instead of declaring them up front. Reach for it when the right capability isn't known until the session starts, because it hinges on who the caller is, what tenant they belong to, feature flags, or external data. The [subagents](../subagents), [tools](../tools), [skills](../skills), and [instructions](../instructions) guides each point here for their dynamic form.
|
|
7
7
|
|
|
8
8
|
## Dynamic models
|
|
9
9
|
|
|
@@ -16,10 +16,77 @@ uncached prices. See
|
|
|
16
16
|
[agent configuration](../agent-config#choose-the-model-dynamically) for the
|
|
17
17
|
full contract.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
The agent always needs exactly one model, so the compiled fallback anchors
|
|
20
|
+
build-time metadata. Tools, skills, instructions, and subagents default by
|
|
21
|
+
authoring a static entry (or returning `null`), so `fallback` on their
|
|
22
|
+
`defineDynamic` export is a build error.
|
|
23
|
+
|
|
24
|
+
## Dynamic subagents
|
|
25
|
+
|
|
26
|
+
Wrap a declared subagent's own `agent.ts` in `defineDynamic` when its
|
|
27
|
+
availability depends on the caller, tenant, environment, or a feature flag.
|
|
28
|
+
Return the child definition to configure and expose it. Return `null` or
|
|
29
|
+
`undefined` to omit it from the parent's model-visible tools.
|
|
30
|
+
|
|
31
|
+
```ts title="agent/subagents/finance/agent.ts"
|
|
32
|
+
import { defineAgent, defineDynamic } from "eve";
|
|
33
|
+
|
|
34
|
+
export default defineDynamic({
|
|
35
|
+
events: {
|
|
36
|
+
"session.started": (_event, ctx) =>
|
|
37
|
+
ctx.session.auth.current?.attributes.plan === "enterprise"
|
|
38
|
+
? defineAgent({
|
|
39
|
+
description: "Analyze financial and accounting data.",
|
|
40
|
+
model: "openai/gpt-5.5",
|
|
41
|
+
})
|
|
42
|
+
: null,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
eve always compiles the subagent's filesystem manifest, including its
|
|
48
|
+
instructions, tools, skills, connections, sandbox, and nested subagents. When
|
|
49
|
+
the resolver selects it, eve injects the returned agent configuration into that
|
|
50
|
+
compiled manifest. Each resolution can return a different model or other
|
|
51
|
+
runtime agent settings. Runtime-selected models must use string model IDs;
|
|
52
|
+
build and Workflow-world configuration cannot be selected at runtime.
|
|
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
|
+
|
|
78
|
+
Dynamic subagents support `session.started` and `turn.started`. A turn selection
|
|
79
|
+
shadows the session selection for that turn, including when the turn handler
|
|
80
|
+
returns nil. If a resolver throws or returns an invalid definition, eve logs the
|
|
81
|
+
failure and omits the subagent.
|
|
82
|
+
|
|
83
|
+
The resolved set applies to local and remote direct delegation and the
|
|
84
|
+
`Workflow` tool. eve
|
|
85
|
+
also checks availability again before starting the child, so a stale or
|
|
86
|
+
manually constructed call fails with `SUBAGENT_UNAVAILABLE`. Treat conditional
|
|
87
|
+
availability as capability composition, not as the only authorization
|
|
88
|
+
boundary: sensitive child tools still need their own authorization and
|
|
89
|
+
approval checks.
|
|
23
90
|
|
|
24
91
|
## Dynamic tools
|
|
25
92
|
|
|
@@ -162,6 +229,7 @@ Both resolve before the prompt is assembled, so the model sees the right instruc
|
|
|
162
229
|
|
|
163
230
|
## What to read next
|
|
164
231
|
|
|
232
|
+
- Conditionally expose a specialist → [Subagents](../subagents)
|
|
165
233
|
- The static tool basics this builds on → [Tools](../tools)
|
|
166
234
|
- The built-in tools and how to override them → [Default harness](../concepts/default-harness)
|
|
167
235
|
- Authenticate a tool or connection to an external service → [Auth & route protection](./auth-and-route-protection)
|
|
@@ -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()`
|
|
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()`
|
|
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()`
|
|
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`:
|
|
@@ -91,7 +91,7 @@ agent/subagents/researcher/
|
|
|
91
91
|
|
|
92
92
|
Rules:
|
|
93
93
|
|
|
94
|
-
- `agent.ts` is required
|
|
94
|
+
- `agent.ts` is required. A static subagent's definition must declare a `description`; a dynamic subagent's resolver must return a definition with one. The parent reads it on the lowered subagent tool to decide when to delegate.
|
|
95
95
|
- `instructions.md` / `instructions.ts` is optional (unlike the root agent, where it is required).
|
|
96
96
|
- `connections/`, `hooks/`, `skills/`, `lib/`, `sandbox/`, and `tools/` are all supported, discovered from the subagent's own directory.
|
|
97
97
|
- `channels/` and `schedules/` are not supported inside local subagents.
|
|
@@ -30,27 +30,27 @@ export default defineTool({
|
|
|
30
30
|
|
|
31
31
|
## The define\* helpers
|
|
32
32
|
|
|
33
|
-
| Helper | Import from
|
|
34
|
-
| ----------------------------------------------------- |
|
|
35
|
-
| `defineAgent` | `eve`
|
|
36
|
-
| `defineTool` | `eve/tools`
|
|
37
|
-
| `defineDynamic` | `eve/tools`, `eve/skills`, `eve/instructions` | `agent/{tools,skills,instructions}/` | [Dynamic capabilities](../guides/dynamic-capabilities) |
|
|
38
|
-
| `defineMcpClientConnection` | `eve/connections`
|
|
39
|
-
| `defineOpenAPIConnection` | `eve/connections`
|
|
40
|
-
| `defineChannel` | `eve/channels`
|
|
41
|
-
| `eveChannel`, `slackChannel`, and the other platforms | `eve/channels/<platform>`
|
|
42
|
-
| `defineSkill` | `eve/skills`
|
|
43
|
-
| `defineInstructions` | `eve/instructions`
|
|
44
|
-
| `defineHook` | `eve/hooks`
|
|
45
|
-
| `defineSchedule` | `eve/schedules`
|
|
46
|
-
| `defineState` | `eve/context`
|
|
47
|
-
| `defineSandbox` | `eve/sandbox`
|
|
48
|
-
| `defineInstrumentation` | `eve/instrumentation`
|
|
49
|
-
| `defineRemoteAgent` | `eve`
|
|
50
|
-
| `defineEval` | `eve/evals`
|
|
51
|
-
| `defineEvalConfig` | `eve/evals`
|
|
52
|
-
| `mockModel` | `eve/evals`
|
|
53
|
-
| `useEveAgent` | `eve/react`, `eve/vue`, `eve/svelte`
|
|
33
|
+
| Helper | Import from | Authored at | Guide |
|
|
34
|
+
| ----------------------------------------------------- | ---------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
35
|
+
| `defineAgent` | `eve` | `agent/agent.ts` | [agent.ts](../agent-config) |
|
|
36
|
+
| `defineTool` | `eve/tools` | `agent/tools/<name>.ts` | [Tools](../tools) |
|
|
37
|
+
| `defineDynamic` | `eve`, `eve/tools`, `eve/skills`, `eve/instructions` | dynamic model or subagent `agent.ts`; `agent/{tools,skills,instructions}/` | [Dynamic capabilities](../guides/dynamic-capabilities) |
|
|
38
|
+
| `defineMcpClientConnection` | `eve/connections` | `agent/connections/<name>.ts` | [MCP connections](../connections/mcp) |
|
|
39
|
+
| `defineOpenAPIConnection` | `eve/connections` | `agent/connections/<name>.ts` | [OpenAPI connections](../connections/openapi) |
|
|
40
|
+
| `defineChannel` | `eve/channels` | `agent/channels/<name>.ts` | [Custom channels](../channels/custom) |
|
|
41
|
+
| `eveChannel`, `slackChannel`, and the other platforms | `eve/channels/<platform>` | `agent/channels/<platform>.ts` | [Channels](../channels/overview) |
|
|
42
|
+
| `defineSkill` | `eve/skills` | `agent/skills/<name>.ts` | [Skills](../skills) |
|
|
43
|
+
| `defineInstructions` | `eve/instructions` | `agent/instructions.ts` | [Instructions](../instructions) |
|
|
44
|
+
| `defineHook` | `eve/hooks` | `agent/hooks/<slug>.ts` | [Hooks](../guides/hooks) |
|
|
45
|
+
| `defineSchedule` | `eve/schedules` | `agent/schedules/<name>.ts` | [Schedules](../schedules) |
|
|
46
|
+
| `defineState` | `eve/context` | tools, hooks, lifecycle | [Session context](../guides/session-context) |
|
|
47
|
+
| `defineSandbox` | `eve/sandbox` | `agent/sandbox.ts` | [Sandbox](../sandbox) |
|
|
48
|
+
| `defineInstrumentation` | `eve/instrumentation` | `agent/instrumentation.ts` | [instrumentation.ts](../guides/instrumentation) |
|
|
49
|
+
| `defineRemoteAgent` | `eve` | `agent/subagents/<id>/agent.ts` | [Remote agents](../guides/remote-agents) |
|
|
50
|
+
| `defineEval` | `eve/evals` | `evals/*.eval.ts` | [Evals](../evals/overview) |
|
|
51
|
+
| `defineEvalConfig` | `eve/evals` | `evals/evals.config.ts` | [Evals](../evals/overview) |
|
|
52
|
+
| `mockModel` | `eve/evals` | Deterministic fixture agent models | [Evals](../evals/overview) |
|
|
53
|
+
| `useEveAgent` | `eve/react`, `eve/vue`, `eve/svelte` | frontend | [Frontend](../guides/frontend/overview) |
|
|
54
54
|
|
|
55
55
|
A few non-`define*` helpers round out the set: `disableTool` and `experimental_workflow` from `eve/tools` (see [Default harness](../concepts/default-harness)), `sleep` from `eve/tools/sleep`, 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. `ExperimentalWorkflowToolInput` is exported from `eve/tools` for the `experimental_workflow(...)` config shape.
|
|
56
56
|
|
|
@@ -68,33 +68,33 @@ A few non-`define*` helpers round out the set: `disableTool` and `experimental_w
|
|
|
68
68
|
|
|
69
69
|
## Imports at a glance
|
|
70
70
|
|
|
71
|
-
| Import | Holds
|
|
72
|
-
| ----------------------------------------------------------- |
|
|
73
|
-
| `eve` | `defineAgent`, `defineRemoteAgent`, agent config types
|
|
74
|
-
| `eve/tools` | `defineTool`, `defineDynamic`, `disableTool`, `experimental_workflow`
|
|
75
|
-
| `eve/tools/defaults` | the built-in tools as plain values
|
|
76
|
-
| `eve/tools/approval` | `always`, `once`, `never`
|
|
77
|
-
| `eve/tools/sleep` | opt-in durable `sleep` tool
|
|
78
|
-
| `eve/connections` | `defineMcpClientConnection`, `defineOpenAPIConnection`
|
|
79
|
-
| `eve/channels` | `defineChannel`, route verbs
|
|
80
|
-
| `eve/channels/eve` | `eveChannel`
|
|
81
|
-
| `eve/channels/auth` | `localDev`, `vercelOidc`, `placeholderAuth`
|
|
82
|
-
| `eve/channels/{slack,discord,teams,telegram,twilio,github}` | platform channel factories
|
|
83
|
-
| `eve/hooks` | `defineHook`
|
|
84
|
-
| `eve/schedules` | `defineSchedule`
|
|
85
|
-
| `eve/skills` | `defineSkill`, `defineDynamic`
|
|
86
|
-
| `eve/instructions` | `defineInstructions`, `defineDynamic`
|
|
87
|
-
| `eve/context` | `defineState`, session and state types
|
|
88
|
-
| `eve/sandbox` | `defineSandbox`, backends
|
|
89
|
-
| `eve/instrumentation` | `defineInstrumentation`, `isChannel`
|
|
90
|
-
| `eve/models/openai` | `experimental_chatgpt`
|
|
91
|
-
| `eve/evals` | `defineEval`, `defineEvalConfig`, `mockModel`, eval types
|
|
92
|
-
| `eve/evals/expect` | `includes`, `equals`, `matches`, `similarity`
|
|
93
|
-
| `eve/evals/reporters` | `Braintrust`, `JUnit`, `EvalReporter`
|
|
94
|
-
| `eve/evals/loaders` | `loadJson`, `loadYaml`
|
|
95
|
-
| `eve/react`, `eve/vue`, `eve/svelte` | `useEveAgent`
|
|
96
|
-
| `eve/next`, `eve/nuxt`, `eve/sveltekit` | framework bundler plugins
|
|
97
|
-
| [`eve/client`](../guides/client/overview) | `Client`, `ClientSession`
|
|
71
|
+
| Import | Holds |
|
|
72
|
+
| ----------------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
73
|
+
| `eve` | `defineAgent`, `defineRemoteAgent`, `defineDynamic`, agent config types |
|
|
74
|
+
| `eve/tools` | `defineTool`, `defineDynamic`, `disableTool`, `experimental_workflow` |
|
|
75
|
+
| `eve/tools/defaults` | the built-in tools as plain values |
|
|
76
|
+
| `eve/tools/approval` | `always`, `once`, `never` |
|
|
77
|
+
| `eve/tools/sleep` | opt-in durable `sleep` tool |
|
|
78
|
+
| `eve/connections` | `defineMcpClientConnection`, `defineOpenAPIConnection` |
|
|
79
|
+
| `eve/channels` | `defineChannel`, route verbs |
|
|
80
|
+
| `eve/channels/eve` | `eveChannel` |
|
|
81
|
+
| `eve/channels/auth` | `localDev`, `vercelOidc`, `placeholderAuth` |
|
|
82
|
+
| `eve/channels/{slack,discord,teams,telegram,twilio,github}` | platform channel factories |
|
|
83
|
+
| `eve/hooks` | `defineHook` |
|
|
84
|
+
| `eve/schedules` | `defineSchedule` |
|
|
85
|
+
| `eve/skills` | `defineSkill`, `defineDynamic` |
|
|
86
|
+
| `eve/instructions` | `defineInstructions`, `defineDynamic` |
|
|
87
|
+
| `eve/context` | `defineState`, session and state types |
|
|
88
|
+
| `eve/sandbox` | `defineSandbox`, backends |
|
|
89
|
+
| `eve/instrumentation` | `defineInstrumentation`, `isChannel` |
|
|
90
|
+
| `eve/models/openai` | `experimental_chatgpt` |
|
|
91
|
+
| `eve/evals` | `defineEval`, `defineEvalConfig`, `mockModel`, eval types |
|
|
92
|
+
| `eve/evals/expect` | `includes`, `equals`, `matches`, `similarity` |
|
|
93
|
+
| `eve/evals/reporters` | `Braintrust`, `JUnit`, `EvalReporter` |
|
|
94
|
+
| `eve/evals/loaders` | `loadJson`, `loadYaml` |
|
|
95
|
+
| `eve/react`, `eve/vue`, `eve/svelte` | `useEveAgent` |
|
|
96
|
+
| `eve/next`, `eve/nuxt`, `eve/sveltekit` | framework bundler plugins |
|
|
97
|
+
| [`eve/client`](../guides/client/overview) | `Client`, `ClientSession` |
|
|
98
98
|
|
|
99
99
|
Exported types ship from the same entrypoint as the helper they describe (for example `ToolDefinition` and `ToolContext` from `eve/tools`). For the exhaustive list, read `packages/eve/src/public/index.ts`.
|
|
100
100
|
|
package/docs/subagents.mdx
CHANGED
|
@@ -47,11 +47,41 @@ export default defineAgent({
|
|
|
47
47
|
|
|
48
48
|
`description` is required. The parent reads it to decide whether to delegate, so the compiler rejects any subagent whose `agent.ts` leaves it out.
|
|
49
49
|
|
|
50
|
+
### Conditional availability
|
|
51
|
+
|
|
52
|
+
To expose a declared subagent only for certain sessions or turns, export
|
|
53
|
+
`defineDynamic` from that subagent's `agent.ts`. Return a `defineAgent`
|
|
54
|
+
configuration to expose the subagent, or nil to omit it from the parent's tools.
|
|
55
|
+
|
|
56
|
+
```ts title="agent/subagents/researcher/agent.ts"
|
|
57
|
+
import { defineAgent, defineDynamic } from "eve";
|
|
58
|
+
|
|
59
|
+
export default defineDynamic({
|
|
60
|
+
events: {
|
|
61
|
+
"session.started": (_event, ctx) =>
|
|
62
|
+
ctx.session.auth.current?.attributes.research === true
|
|
63
|
+
? defineAgent({
|
|
64
|
+
description: "Investigate ambiguous questions before the parent responds.",
|
|
65
|
+
model: "anthropic/claude-opus-4.8",
|
|
66
|
+
})
|
|
67
|
+
: null,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Resolvers run at `session.started` or `turn.started`; `step.started` is not
|
|
73
|
+
supported for subagents. A nil result (`null` or `undefined`) removes the
|
|
74
|
+
subagent's description and tool definition from the model-visible surface.
|
|
75
|
+
The subagent's filesystem manifest is always compiled; a non-nil result injects
|
|
76
|
+
the returned agent configuration when the child runs.
|
|
77
|
+
See [Dynamic capabilities](./guides/dynamic-capabilities#dynamic-subagents) for
|
|
78
|
+
scope precedence, failure behavior, and the dispatch-time guard.
|
|
79
|
+
|
|
50
80
|
Minimum files:
|
|
51
81
|
|
|
52
82
|
```text
|
|
53
83
|
agent/subagents/researcher/
|
|
54
|
-
├── agent.ts # required
|
|
84
|
+
├── agent.ts # required
|
|
55
85
|
├── instructions.md # or instructions.ts, optional
|
|
56
86
|
├── tools/ # optional, its own tools
|
|
57
87
|
├── skills/ # optional, its own skills
|
|
@@ -100,7 +130,7 @@ A declared subagent's tool name is the bare path-derived name, with no prefix. `
|
|
|
100
130
|
}
|
|
101
131
|
```
|
|
102
132
|
|
|
103
|
-
Because the name lives in the same runtime tool namespace as authored tools, a subagent named `researcher` collides with a tool named `researcher`. eve rejects
|
|
133
|
+
Because the name lives in the same runtime tool namespace as authored tools, a subagent named `researcher` collides with a tool named `researcher`. eve rejects static collisions at build time and active dynamic collisions at runtime rather than picking a winner, so keep subagent directory names distinct from tool names.
|
|
104
134
|
|
|
105
135
|
Do not rely on subagent delegation by itself as an approval boundary. Put sensitive tools behind `approval`, connection approval, route/session authorization, or other controls wherever those tools can be called.
|
|
106
136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
324
|
-
"@workflow/errors": "5.0.0-beta.
|
|
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.
|
|
328
|
-
"@workflow/world-local": "5.0.0-beta.
|
|
329
|
-
"@workflow/world-vercel": "5.0.0-beta.
|
|
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
|
-
"@
|
|
358
|
+
"@eve/catalog": "0.0.1"
|
|
359
359
|
},
|
|
360
360
|
"peerDependencies": {
|
|
361
361
|
"@opentelemetry/api": "^1.0.0",
|
|
@@ -385,7 +385,7 @@
|
|
|
385
385
|
"clean": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\"",
|
|
386
386
|
"build": "pnpm run check:bin-runtime-dependencies && pnpm run build:js && node ./scripts/copy-docs.mjs && node ./scripts/stamp-version-tokens.mjs",
|
|
387
387
|
"build:compiled": "node ./scripts/vendor-compiled.mjs",
|
|
388
|
-
"build:js": "pnpm run build:compiled && pnpm run clean && pnpm run build:types && node ./scripts/copy-compiled-assets.mjs && node ./scripts/build-rolldown.mjs && node ./scripts/copy-runtime-assets.mjs",
|
|
388
|
+
"build:js": "pnpm run build:compiled && pnpm run clean && pnpm run build:types && node ./scripts/copy-compiled-assets.mjs && node --conditions=eve-source ./scripts/build-rolldown.mjs && node ./scripts/copy-runtime-assets.mjs",
|
|
389
389
|
"build:types": "pnpm run build:compiled && tsc -p tsconfig.build.json",
|
|
390
390
|
"check:bin-runtime-dependencies": "node ./scripts/check-bin-runtime-dependencies.mjs",
|
|
391
391
|
"dev": "pnpm run build:compiled && node ./scripts/copy-runtime-assets.mjs && tsc -p tsconfig.dev.json --watch --preserveWatchOutput",
|
|
@@ -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};
|