eve 0.84.1 → 0.86.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/README.md +7 -4
- package/dist/CHANGELOG.md +38 -0
- package/dist/src/channel/channel-operations.d.ts +2 -18
- package/dist/src/channel/compiled-channel.d.ts +3 -7
- package/dist/src/channel/cross-channel-receive.d.ts +9 -10
- package/dist/src/channel/cross-channel-receive.js +1 -1
- package/dist/src/channel/schedule.js +1 -1
- package/dist/src/channel/session.d.ts +26 -4
- package/dist/src/channel/session.js +1 -1
- package/dist/src/chunks/{use-eve-agent-DMeP0JOF.js → use-eve-agent-B2jCfcnG.js} +3 -2
- package/dist/src/chunks/{use-eve-agent-DP5Rso9C.js → use-eve-agent-DCLFi26P.js} +3 -2
- package/dist/src/cli/commands/agent-prompt/collect-intent.md +2 -1
- package/dist/src/cli/commands/agent-prompt/scaffold.md +1 -2
- package/dist/src/cli/dev/tui/runner.d.ts +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/types.d.ts +5 -4
- package/dist/src/compiled/.vendor-stamp.json +4 -4
- package/dist/src/compiled/@vercel/schedules/index.d.ts +45 -6
- package/dist/src/compiled/@vercel/schedules/index.js +2 -2
- package/dist/src/context/keys.d.ts +7 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/execution/agent-sessions/context.d.ts +5 -1
- package/dist/src/execution/agent-sessions/context.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/legacy-session/snapshot.d.ts +1 -2
- package/dist/src/execution/legacy-session/snapshot.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/public-destination.d.ts +3 -0
- package/dist/src/execution/public-destination.js +1 -1
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/answer-caller.d.ts +9 -5
- package/dist/src/execution/session/answer-caller.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.d.ts +16 -5
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/checkpoint-refusal.d.ts +4 -0
- package/dist/src/execution/session/checkpoint-refusal.js +1 -0
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/handoff-steps.d.ts +7 -1
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/imported-conversation.d.ts +2 -0
- package/dist/src/execution/session/imported-conversation.js +1 -0
- package/dist/src/execution/session/interrupted-step.js +1 -1
- package/dist/src/execution/session/pre-v27-checkpoint.d.ts +36 -0
- package/dist/src/execution/session/pre-v27-checkpoint.js +1 -0
- package/dist/src/execution/session/principal.d.ts +8 -0
- package/dist/src/execution/session/principal.js +1 -1
- package/dist/src/execution/session/program.d.ts +2 -0
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-callback-request.js +1 -1
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/channel-to.d.ts +12 -0
- package/dist/src/execution/tools/channel-to.js +1 -0
- package/dist/src/execution/tools/workflow/body.d.ts +3 -0
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/step-context.d.ts +5 -0
- package/dist/src/execution/tools/workflow/step-execution.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/workflow-callback-url.d.ts +2 -3
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/attachment-staging.d.ts +2 -2
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/compaction/step.js +1 -1
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/run.js +1 -1
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/attachments/limited-read.d.ts +2 -0
- package/dist/src/internal/attachments/limited-read.js +1 -1
- package/dist/src/internal/attachments/url-refs.js +1 -1
- package/dist/src/internal/capability-error.d.ts +3 -0
- package/dist/src/internal/capability-error.js +1 -0
- package/dist/src/internal/nitro/routes/schedule-collection-consumer.js +1 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -1
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/github/githubChannel.js +1 -1
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/linq/inboundContent.js +1 -1
- package/dist/src/public/channels/slack/answers.d.ts +2 -3
- package/dist/src/public/channels/slack/answers.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +23 -3
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/app-manifest.d.ts +2 -0
- package/dist/src/public/channels/slack/app-manifest.js +1 -1
- package/dist/src/public/channels/slack/auth.d.ts +2 -1
- package/dist/src/public/channels/slack/auth.js +1 -1
- package/dist/src/public/channels/slack/code-channel.d.ts +42 -0
- package/dist/src/public/channels/slack/code-channel.js +1 -0
- package/dist/src/public/channels/slack/defaults.d.ts +7 -3
- package/dist/src/public/channels/slack/defaults.js +3 -3
- package/dist/src/public/channels/slack/hitl.d.ts +7 -17
- package/dist/src/public/channels/slack/hitl.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +4 -3
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/interaction-cards.d.ts +0 -2
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/open-code-channel.d.ts +30 -0
- package/dist/src/public/channels/slack/open-code-channel.js +1 -0
- package/dist/src/public/channels/slack/private-approval-delivery.d.ts +16 -4
- package/dist/src/public/channels/slack/private-approval-delivery.js +1 -1
- package/dist/src/public/channels/slack/renderers.d.ts +58 -6
- package/dist/src/public/channels/slack/renderers.js +1 -1
- package/dist/src/public/channels/slack/reply-delivery.d.ts +4 -0
- package/dist/src/public/channels/slack/reply-delivery.js +1 -1
- package/dist/src/public/channels/slack/request-card-render.d.ts +45 -0
- package/dist/src/public/channels/slack/request-card-render.js +1 -0
- package/dist/src/public/channels/slack/request-cards.d.ts +35 -0
- package/dist/src/public/channels/slack/request-cards.js +3 -0
- package/dist/src/public/channels/slack/sign-in-cancel.d.ts +3 -5
- package/dist/src/public/channels/slack/sign-in-cancel.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +109 -22
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/task-card.d.ts +3 -3
- package/dist/src/public/channels/slack/task-card.js +1 -1
- package/dist/src/public/channels/slack/thread-status.js +1 -1
- package/dist/src/public/channels/teams/api.js +1 -1
- package/dist/src/public/channels/teams/defaults.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/teams/verify.d.ts +9 -5
- package/dist/src/public/channels/teams/verify.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
- package/dist/src/public/schedules/providers/vercel.d.ts +2 -0
- package/dist/src/public/schedules/providers/vercel.js +1 -1
- package/dist/src/public/schedules/subscription.d.ts +10 -1
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/setup/index.d.ts +1 -1
- package/dist/src/setup/primitives/index.d.ts +1 -1
- package/dist/src/setup/primitives/pm/run.d.ts +0 -2
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/channel-definition.d.ts +4 -4
- package/dist/src/subagents/adapter.js +1 -1
- package/dist/src/subagents/parent-notification.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/definition.d.ts +21 -0
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +4 -4
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +16 -3
- package/docs/channels/eve.mdx +3 -5
- package/docs/channels/linq.mdx +1 -1
- package/docs/channels/slack.mdx +185 -18
- package/docs/channels/teams.mdx +6 -2
- package/docs/concepts/project-structure.mdx +1 -1
- package/docs/concepts/security-model.md +4 -0
- package/docs/concepts/upgrade-to-v27-events.md +70 -2
- package/docs/experimental/dynamic-schedules.mdx +2 -2
- package/docs/getting-started.mdx +2 -0
- package/docs/guides/auth-and-route-protection.md +1 -0
- package/docs/guides/client/overview.mdx +1 -1
- package/docs/guides/client/streaming.mdx +1 -1
- package/docs/guides/deployment/self-hosting.md +1 -1
- package/docs/guides/frontend/meta.json +1 -0
- package/docs/guides/frontend/nextjs.mdx +329 -121
- package/docs/guides/frontend/overview.mdx +115 -335
- package/docs/guides/frontend/tanstack.mdx +1 -1
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +5 -5
- package/docs/guides/frontend/use-eve-agent-vue.mdx +5 -5
- package/docs/guides/frontend/use-eve-agent.mdx +385 -0
- package/docs/guides/hooks.md +1 -1
- package/docs/guides/remote-agents.md +10 -0
- package/docs/guides/self-modification.md +6 -0
- package/docs/patterns/fork-conversations-into-new-threads.md +159 -0
- package/docs/patterns/meta.json +1 -0
- package/docs/reference/cli.md +1 -2
- package/docs/sandbox/index.mdx +1 -1
- package/docs/schedules.mdx +1 -1
- package/docs/tools/overview.mdx +34 -0
- package/docs/tools/workflows.mdx +47 -5
- package/package.json +13 -21
- package/CHANGELOG.md +0 -3076
- package/dist/src/public/channels/slack/approval-cards.d.ts +0 -25
- package/dist/src/public/channels/slack/approval-cards.js +0 -2
- package/dist/src/self-modification/agent.d.ts +0 -12
- package/dist/src/self-modification/agent.js +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ You author an agent as a directory on disk. The directory is the contract — ma
|
|
|
6
6
|
|
|
7
7
|
The framework is called eve. The published npm package is `eve`. The CLI binary is `eve`.
|
|
8
8
|
|
|
9
|
+
## Release notes
|
|
10
|
+
|
|
11
|
+
The installed package contains its release notes in `dist/CHANGELOG.md`, with a link to the full changelog through that version. For an upgrade across releases, review the target version's history at `https://raw.githubusercontent.com/vercel/eve/refs/tags/eve%40<version>/packages/eve/CHANGELOG.md`.
|
|
12
|
+
|
|
9
13
|
## Preview Terms and Safeguards
|
|
10
14
|
|
|
11
15
|
eve is currently a preview and subject to the Vercel beta terms; the framework, APIs, documentation, and behavior may change before general availability.
|
|
@@ -119,9 +123,8 @@ npx eve@latest init my-agent
|
|
|
119
123
|
```
|
|
120
124
|
|
|
121
125
|
`eve init` writes a new agent with eve's default model. Pass `--model
|
|
122
|
-
openai/gpt-5.5` to choose another AI Gateway model, `--reasoning high` to set a
|
|
123
|
-
reasoning effort,
|
|
124
|
-
installs dependencies, initializes Git, and opens the terminal UI in an interactive
|
|
126
|
+
openai/gpt-5.5` to choose another AI Gateway model, or `--reasoning high` to set a
|
|
127
|
+
reasoning effort. It installs dependencies, initializes Git, and opens the terminal UI in an interactive
|
|
125
128
|
human terminal. Coding-agent invocations return setup instructions instead.
|
|
126
129
|
Targeting an existing project directory (`eve init .`) adds the agent files and
|
|
127
130
|
missing dependencies instead. Initialization does not create a Vercel project,
|
|
@@ -191,4 +194,4 @@ and inspection. Channel-local addresses remain behind authored channel APIs.
|
|
|
191
194
|
|
|
192
195
|
## Changelog
|
|
193
196
|
|
|
194
|
-
|
|
197
|
+
The repository's `CHANGELOG.md` contains the full release history. For the installed package, see [Release notes](#release-notes).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Release eve@0.86.0 | 2026-10-28 | minor
|
|
2
|
+
|
|
3
|
+
## 🚀 Features
|
|
4
|
+
|
|
5
|
+
- `EVE_CALLBACK_TRUSTED_ORIGINS` now accepts a leading `*.` label, such as `https://*.preview.example.com`, so a remote agent can trust preview parents whose deployment URLs change on every deploy. [#5539](https://github.com/vercel/eve/pull/5539)
|
|
6
|
+
|
|
7
|
+
The wildcard matches exactly one subdomain label, and `*.vercel.app` and trailing dots are rejected.
|
|
8
|
+
|
|
9
|
+
- Hide `eve init --channel-web-nextjs` from `eve init --help` in favor of `eve add channel/web`. [#5474](https://github.com/vercel/eve/pull/5474)
|
|
10
|
+
|
|
11
|
+
The flag still works. The README and coding-agent setup instructions now point to `eve add channel/web`, which also sets up sign-in.
|
|
12
|
+
|
|
13
|
+
- Ship current release notes at `dist/CHANGELOG.md` with a version-pinned link to the full changelog. [#5446](https://github.com/vercel/eve/pull/5446)
|
|
14
|
+
|
|
15
|
+
## 🐛 Bug Fixes
|
|
16
|
+
|
|
17
|
+
- The experimental Vercel schedule provider bundles Schedules SDK alpha.19 and identifies eve to the Schedules API with an `x-vss-framework: eve` header. [#5528](https://github.com/vercel/eve/pull/5528)
|
|
18
|
+
|
|
19
|
+
- A file returned by a tool now becomes a "could not be stored" note when the session's sandbox rejects the write, instead of failing the step and replaying its model call and tools. [#4843](https://github.com/vercel/eve/pull/4843)
|
|
20
|
+
|
|
21
|
+
- A turn's principal no longer changes while it runs. [#4925](https://github.com/vercel/eve/pull/4925)
|
|
22
|
+
|
|
23
|
+
Only the turn's own principal can answer a pending `ctx.ask()` or `ask_question` by typing, whether a workflow tool, a subagent or a remote agent asked; another person's text waits and runs as their own turn instead of answering the question under the asker's auth. A typed answer updates the claims on `ctx.session.auth.current`, so its `delivery.consumed` hook and the rest of the turn see the request that sent it. Someone else's button answer still settles the request as its responder.
|
|
24
|
+
|
|
25
|
+
## Other Changes
|
|
26
|
+
|
|
27
|
+
See the [full list of changes](https://github.com/vercel/eve/compare/eve%400.85.0...eve%400.86.0).
|
|
28
|
+
|
|
29
|
+
## Contributors
|
|
30
|
+
|
|
31
|
+
- [@benpankow](https://github.com/benpankow)
|
|
32
|
+
- [@chadhietala](https://github.com/chadhietala)
|
|
33
|
+
- [@cmpadden](https://github.com/cmpadden)
|
|
34
|
+
- [@elliotdauber](https://github.com/elliotdauber)
|
|
35
|
+
- [@OwenKephart](https://github.com/OwenKephart)
|
|
36
|
+
- [@ruiconti](https://github.com/ruiconti)
|
|
37
|
+
|
|
38
|
+
For an upgrade across multiple releases, review each version between the installed and target versions in the [target version's changelog](https://raw.githubusercontent.com/vercel/eve/refs/tags/eve%400.86.0/packages/eve/CHANGELOG.md).
|
|
@@ -4,29 +4,13 @@ import type { ChannelAdapter } from "#channel/adapter.js";
|
|
|
4
4
|
import type { ChannelDeliverySource } from "#channel/delivery-metadata.js";
|
|
5
5
|
import { type ChannelCreateResult } from "#channel/channel-address.js";
|
|
6
6
|
export type { ChannelCreateResult } from "#channel/channel-address.js";
|
|
7
|
-
import type { Session } from "#channel/session.js";
|
|
7
|
+
import type { SessionSendOptions, Session } from "#channel/session.js";
|
|
8
8
|
import type { Runtime, SessionAuthContext, TurnPolicy, SessionControlOptions } from "#channel/types.js";
|
|
9
9
|
import { type Answer, type StrictAnswers } from "#shared/input.js";
|
|
10
10
|
import type { JsonObject } from "#shared/json.js";
|
|
11
11
|
import type { SessionHistoryMessage } from "#shared/session-history.js";
|
|
12
|
-
interface BaseChannelSendOptions {
|
|
13
|
-
/** Stable delivery identity, deduplicated within this session's recent-key window. */
|
|
14
|
-
readonly idempotencyKey?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Prior conversation added as user and assistant turns before this
|
|
17
|
-
* message and its `context`. Seeds a session this send creates, or
|
|
18
|
-
* extends the history of the session that owns the address.
|
|
19
|
-
*/
|
|
20
|
-
readonly history?: readonly SessionHistoryMessage[];
|
|
21
|
-
readonly auth: SessionAuthContext | null;
|
|
22
|
-
readonly context?: readonly string[];
|
|
23
|
-
/** JSON Schema for a structured final answer, as on `Session.send()`. */
|
|
24
|
-
readonly outputSchema?: JsonObject;
|
|
25
|
-
readonly title?: string;
|
|
26
|
-
readonly turnPolicy?: TurnPolicy;
|
|
27
|
-
}
|
|
28
12
|
/** Options for sending a message from a channel-local continuation address. */
|
|
29
|
-
export type ChannelSendOptions<TState = undefined> =
|
|
13
|
+
export type ChannelSendOptions<TState = undefined> = SessionSendOptions & {
|
|
30
14
|
readonly state?: Partial<TState>;
|
|
31
15
|
};
|
|
32
16
|
interface BaseChannelRespondOptions<TState = undefined> {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ChannelAdapter } from "#channel/adapter.js";
|
|
2
|
-
import type { MessageContent } from "#shared/message-content.js";
|
|
3
2
|
import type { ChannelReceiveContext } from "#channel/channel-operations.js";
|
|
4
3
|
import type { NormalizedChannelCorsOptions } from "#channel/cors.js";
|
|
5
4
|
import type { TypedReceiveTarget } from "#channel/receive-target.js";
|
|
6
5
|
import type { RouteDefinition } from "#channel/routes.js";
|
|
7
6
|
import type { Delivery } from "#shared/delivery.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { TurnPolicy } from "#channel/types.js";
|
|
8
|
+
import type { GenericReceiveInput } from "#shared/channel-definition.js";
|
|
9
9
|
import type { JsonObject } from "#shared/json.js";
|
|
10
10
|
export declare const CHANNEL_SENTINEL: "eve:channel";
|
|
11
11
|
interface ChannelBuildMetadata {
|
|
@@ -22,11 +22,7 @@ export interface CompiledChannel<TState = undefined, TReceiveTarget = Record<str
|
|
|
22
22
|
readonly adapter: ChannelAdapter<any>;
|
|
23
23
|
readonly cors?: NormalizedChannelCorsOptions;
|
|
24
24
|
readonly __metadata?: TMetadata;
|
|
25
|
-
readonly receive?: (input:
|
|
26
|
-
readonly message: MessageContent;
|
|
27
|
-
readonly target: Readonly<TReceiveTarget>;
|
|
28
|
-
readonly auth: SessionAuthContext | null;
|
|
29
|
-
}, ctx: ChannelReceiveContext<TState>) => Promise<Delivery>;
|
|
25
|
+
readonly receive?: (input: GenericReceiveInput<TReceiveTarget>, ctx: ChannelReceiveContext<TState>) => Promise<Delivery>;
|
|
30
26
|
readonly turnPolicy?: TurnPolicy;
|
|
31
27
|
}
|
|
32
28
|
export declare function isCompiledChannel(value: unknown): value is CompiledChannel;
|
|
@@ -3,19 +3,17 @@ import type { ChannelAdapter } from "#channel/adapter.js";
|
|
|
3
3
|
import { type ChannelReference, type CompiledChannel } from "#channel/compiled-channel.js";
|
|
4
4
|
import type { ChannelDeliverySource } from "#channel/delivery-metadata.js";
|
|
5
5
|
import type { InferReceiveTarget } from "#channel/receive-target.js";
|
|
6
|
+
import { type SessionSendOptions } from "#channel/session.js";
|
|
6
7
|
import type { Delivery } from "#shared/delivery.js";
|
|
7
|
-
import type { Runtime
|
|
8
|
+
import type { Runtime } from "#channel/types.js";
|
|
8
9
|
import type { ResolvedChannelDefinition } from "#runtime/types.js";
|
|
9
|
-
/**
|
|
10
|
-
* Options for sending a message to a channel selected with `ctx.to(...)`.
|
|
11
|
-
*/
|
|
12
|
-
interface CrossChannelSendOptions {
|
|
13
|
-
readonly auth: SessionAuthContext | null;
|
|
14
|
-
readonly turnPolicy?: TurnPolicy;
|
|
15
|
-
}
|
|
16
10
|
/** Message delivery bound to one channel-specific proactive target. */
|
|
17
11
|
export interface CrossChannelTargetHandle {
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Starts a session at the target, or continues the one that owns it. The
|
|
14
|
+
* channel's `receive()` hook gets `options` with the message and target.
|
|
15
|
+
*/
|
|
16
|
+
send(message: MessageContent, options: SessionSendOptions): Promise<Delivery>;
|
|
19
17
|
}
|
|
20
18
|
/** Selects another authored channel and one of its proactive targets. */
|
|
21
19
|
export type CrossChannelToFn = <TChannel extends ChannelReference<unknown>>(channel: TChannel, target: InferReceiveTarget<TChannel>) => CrossChannelTargetHandle;
|
|
@@ -42,7 +40,8 @@ type CrossChannelDeliverySource = Omit<ChannelDeliverySource, "channelKind" | "c
|
|
|
42
40
|
*/
|
|
43
41
|
export declare function toCrossChannelTargets(channels: readonly ResolvedChannelDefinition[]): readonly CrossChannelTarget[];
|
|
44
42
|
/**
|
|
45
|
-
* Builds the `ctx.to(channel, target)` closure used by route and schedule
|
|
43
|
+
* Builds the `ctx.to(channel, target)` closure used by route and schedule
|
|
44
|
+
* handlers and tools.
|
|
46
45
|
*/
|
|
47
46
|
export declare function createCrossChannelToFn(runtime: Runtime, channels: readonly CrossChannelTarget[], source?: CrossChannelDeliverySource): CrossChannelToFn;
|
|
48
47
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createChannelOperations}from"#channel/channel-operations.js";import{isCompiledChannel}from"#channel/compiled-channel.js";function toCrossChannelTargets(e){return e.flatMap(e=>e.definition===void 0?[]:[{name:e.name,definition:e.definition,receive:e.receive,adapter:e.adapter,turnPolicy:e.turnPolicy}])}function createCrossChannelToFn(e,t,n={}){return(r,i)=>{let a=resolveTargetByReference(r,t);return{async send(t,r){return await invokeChannelReceive({runtime:e,source:n,target:a,input:{message:t,target:i
|
|
1
|
+
import{toSessionSendOptions}from"#channel/session.js";import{createChannelOperations}from"#channel/channel-operations.js";import{isCompiledChannel}from"#channel/compiled-channel.js";function toCrossChannelTargets(e){return e.flatMap(e=>e.definition===void 0?[]:[{name:e.name,definition:e.definition,receive:e.receive,adapter:e.adapter,turnPolicy:e.turnPolicy}])}function createCrossChannelToFn(e,t,n={}){return(r,i)=>{let a=resolveTargetByReference(r,t);return{async send(t,r){return await invokeChannelReceive({runtime:e,source:n,target:a,input:{...toSessionSendOptions(r),message:t,target:i},turnPolicy:r.turnPolicy})}}}}async function invokeChannelReceive(e){let{name:t}=e.target;if(!e.target.receive)throw Error(`ctx.to(): channel "${t}" does not implement receive(). Declare a receive hook on the channel to accept cross-channel sessions.`);if(!e.target.adapter)throw Error(`ctx.to(): channel "${t}" has no adapter — cannot build ctx.from().`);let n=createChannelOperations({adapter:e.target.adapter,channelName:t,metadata:{...e.source,channelKind:`channel:${t}`,channelName:t},runtime:e.runtime,turnPolicy:e.turnPolicy??e.target.turnPolicy});return await e.target.receive(e.input,n)}function resolveTargetByReference(e,t){for(let n of t)if(n.definition===e)return n;let n=resolveTargetByRouteFingerprint(e,t);if(n!==null)return n;throw Error(`ctx.to(): the channel passed as the first argument is not registered in this agent's channels/. Import the channel module's default export from agent/channels/<name>.ts and pass that value.`)}function resolveTargetByRouteFingerprint(e,t){if(!isCompiledChannel(e))return null;let n=createRouteFingerprint(e);if(n===null)return null;let r=new Map;for(let e of t)createRouteFingerprint(e.definition)===n&&r.set(e.name,e);if(r.size===1)return[...r.values()][0];if(r.size>1)throw Error(`ctx.to(): the channel passed as the first argument matches multiple registered channels by route shape. Import a channel with a unique route set from agent/channels/<name>.ts before passing it to ctx.to().`);return null}function createRouteFingerprint(e){return e.routes.length===0?null:e.routes.map(e=>`${e.method.toUpperCase()} ${e.path}`).sort().join(`
|
|
2
2
|
`)}export{createCrossChannelToFn,toCrossChannelTargets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{commandDelivery}from"#channel/delivery.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{scheduleDisplayName}from"#runtime/schedules/record.js";import{SCHEDULE_APP_AUTH,SCHEDULE_APP_AUTH as SCHEDULE_APP_AUTH$1}from"#channel/schedule-auth.js";import{createCrossChannelToFn,toCrossChannelTargets}from"#channel/cross-channel-receive.js";import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,OccurrenceIdKey,ScheduleIdKey,ScheduleInstanceKey}from"#context/keys.js";import{expectFunction}from"#internal/authored-module.js";import{parseSchedulePayload,validateSchedulePayload}from"#runtime/schedules/payload.js";const SCHEDULE_ADAPTER_KIND=`schedule`,SCHEDULE_ADAPTER={kind:SCHEDULE_ADAPTER_KIND};var ScheduleDispatcher=class{runtime;channels;constructor(e){this.runtime=e.runtime,this.channels=e.channels}async trigger(e){let t=new ContextContainer;return t.set(ScheduleIdKey,e.scheduleId),await contextStorage.run(t,()=>this.triggerInScope(e))}async triggerCollection(e){let{envelope:t}=parseSchedulePayload(e.payload,{application:e.payload.eve.application,collection:e.collectionId}),{definition:n}=e,r={...e.occurrence,displayName:scheduleDisplayName(e.occurrence.name)},i=n.preparePayload===void 0?await validateSchedulePayload(n.inputSchema,t.payload):t.payload;await e.verifyDelivery?.();let a=await n.auth({principal:t.principal,payload:i,occurrence:r});if(a===null)throw Error(`Scheduled execution is no longer authorized.`);if(a.principalId!==t.principal.principalId||a.principalType!==t.principal.type||a.authenticator!==t.principal.authenticator||a.issuer!==t.principal.issuer||a.subject!==t.principal.subject)throw Error(`Scheduled execution auth must resolve the schedule creator.`);let o=a,s=new ContextContainer;
|
|
1
|
+
import{createHash,randomUUID}from"node:crypto";import{commandDelivery}from"#channel/delivery.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{scheduleDisplayName}from"#runtime/schedules/record.js";import{SCHEDULE_APP_AUTH,SCHEDULE_APP_AUTH as SCHEDULE_APP_AUTH$1}from"#channel/schedule-auth.js";import{createCrossChannelToFn,toCrossChannelTargets}from"#channel/cross-channel-receive.js";import{ContextContainer,contextStorage}from"#context/container.js";import{AuthKey,OccurrenceIdKey,ScheduleIdKey,ScheduleInstanceKey}from"#context/keys.js";import{expectFunction}from"#internal/authored-module.js";import{parseSchedulePayload,validateSchedulePayload}from"#runtime/schedules/payload.js";const SCHEDULE_ADAPTER_KIND=`schedule`,SCHEDULE_ADAPTER={kind:SCHEDULE_ADAPTER_KIND};var ScheduleDispatcher=class{runtime;channels;constructor(e){this.runtime=e.runtime,this.channels=e.channels}async trigger(e){let t=new ContextContainer;return t.set(ScheduleIdKey,e.scheduleId),await contextStorage.run(t,()=>this.triggerInScope(e))}async triggerCollection(e){let{envelope:t}=parseSchedulePayload(e.payload,{application:e.payload.eve.application,collection:e.collectionId}),{definition:n}=e,r={...e.occurrence,displayName:scheduleDisplayName(e.occurrence.name)},i=n.preparePayload===void 0?await validateSchedulePayload(n.inputSchema,t.payload):t.payload;await e.verifyDelivery?.();let a=await n.auth({principal:t.principal,payload:i,occurrence:r});if(a===null)throw Error(`Scheduled execution is no longer authorized.`);if(a.principalId!==t.principal.principalId||a.principalType!==t.principal.type||a.authenticator!==t.principal.authenticator||a.issuer!==t.principal.issuer||a.subject!==t.principal.subject)throw Error(`Scheduled execution auth must resolve the schedule creator.`);let o=a,s=new ContextContainer;s.set(ScheduleIdKey,e.collectionId),s.set(AuthKey,o),s.set(OccurrenceIdKey,r.executionId),s.set(ScheduleInstanceKey,r.name);let scheduledToken=(e,t)=>t===void 0?`eve-scheduled-send:${randomUUID()}`:`eve-scheduled-send:${createHash(`sha256`).update(JSON.stringify([r.scheduleId,e,t])).digest(`hex`)}`,freshRun=e=>({...e,auth:o,initiatorAuth:o,capabilities:{requestInput:!1},continuationToken:scheduledToken(e.continuationToken,e.idempotencyKey),continuationConflictCommand:e.idempotencyKey===void 0?void 0:e.continuationConflictCommand});return await contextStorage.run(s,async()=>{let e={...this.runtime,resolveContinuation:async()=>void 0,dispatchContinuation:async e=>{let{command:t}=e;if(t.kind!==`send`)throw Error(`Scheduled channel receive can only start a fresh session.`);return t.idempotencyKey===void 0?{status:`session_not_active`}:await this.runtime.dispatchContinuation({command:t,continuationToken:scheduledToken(e.continuationToken,t.idempotencyKey),successor:e.successor&&freshRun(e.successor)})},createSession:async e=>await this.runtime.createSession(freshRun(e))},{args:t,sessions:a,waitUntilTasks:s}=this.createHandlerContext(e);return await n.run({payload:i,occurrence:r,auth:o,to:(e,n)=>({send:(r,i)=>t.to(e,n).send(r,{...i,auth:o})}),waitUntil:t.waitUntil}),await Promise.all(s),{sessions:a,waitUntilTasks:s}})}async triggerInScope(e){let{args:t,sessions:n,waitUntilTasks:r}=this.createHandlerContext();if(e.run)await e.run(t);else if(e.markdown!==void 0)n.push(await this.runMarkdown(e.markdown));else throw Error(`Schedule "${e.scheduleId}" has neither "run" nor "markdown" — at least one must be set.`);return{sessions:n,waitUntilTasks:r}}createHandlerContext(e=this.runtime){let t=[],n=[],r=createCrossChannelToFn(e,toCrossChannelTargets(this.channels));return{args:{appAuth:SCHEDULE_APP_AUTH$1,to(e,n){let i=r(e,n);return{async send(e,n){let r=await i.send(e,n);return t.push(r),r}}},waitUntil(e){n.push(e)}},sessions:t,waitUntilTasks:n}}async runMarkdown(e){let t=createChannelDeliveryMetadata({channelKind:`schedule`,channelName:`schedule`}),n=await this.runtime.createSession({delivery:t,adapter:SCHEDULE_ADAPTER,auth:SCHEDULE_APP_AUTH$1,input:{message:e}});return commandDelivery(this.runtime,{status:`accepted`,sessionId:n.sessionId},t.deliveryId)}};function expectScheduleRun(e,t,n){let r=e;if(typeof r!=`object`||!r)throw Error(`Schedule export "${n??`default`}" from "${t}" must be an object.`);return expectFunction(r.run,`Expected the schedule export "${n??`default`}" from "${t}" to export a \`run\` handler function.`)}export{SCHEDULE_ADAPTER,SCHEDULE_ADAPTER_KIND,SCHEDULE_APP_AUTH,ScheduleDispatcher,expectScheduleRun};
|
|
@@ -48,14 +48,36 @@ interface SessionDeliveryOptions {
|
|
|
48
48
|
readonly context?: readonly string[];
|
|
49
49
|
readonly outputSchema?: JsonObject;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Options every server-side message send accepts: `Session.send()`,
|
|
53
|
+
* `from(address).send()`, `to(channel, target).send()`, and the input a
|
|
54
|
+
* channel's `receive()` hook gets.
|
|
55
|
+
*/
|
|
56
|
+
export interface SessionSendOptions {
|
|
57
|
+
/** Who the session runs as. */
|
|
58
|
+
readonly auth: SessionAuthContext | null;
|
|
59
|
+
/** Strings added as user messages before the message, kept in session history. */
|
|
60
|
+
readonly context?: readonly string[];
|
|
53
61
|
/** Prior conversation added as user and assistant turns before this message and its `context`. */
|
|
54
62
|
readonly history?: readonly SessionHistoryMessage[];
|
|
55
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Stable delivery identity. Deduplicated within the receiving session's recent-key window, which
|
|
65
|
+
* every sender to that session shares, so make it unique across senders, for example by
|
|
66
|
+
* prefixing the source. A threadless Slack target also derives its session from it.
|
|
67
|
+
*/
|
|
68
|
+
readonly idempotencyKey?: string;
|
|
69
|
+
/** JSON Schema for a structured final answer. */
|
|
70
|
+
readonly outputSchema?: JsonObject;
|
|
71
|
+
/** Workflow run title for a session this send starts. Defaults to one derived from the message. */
|
|
56
72
|
readonly title?: string;
|
|
73
|
+
/** How the message treats a running turn. */
|
|
57
74
|
readonly turnPolicy?: TurnPolicy;
|
|
58
|
-
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Copies only the {@link SessionSendOptions} fields and validates the key. Callers can pass wider
|
|
78
|
+
* objects, which must not carry internal send fields such as `callback` across a channel boundary.
|
|
79
|
+
*/
|
|
80
|
+
export declare function toSessionSendOptions(options: SessionSendOptions): SessionSendOptions;
|
|
59
81
|
/** Options for answering pending input requests through a fixed session handle. */
|
|
60
82
|
export type SessionRespondOptions = SessionDeliveryOptions;
|
|
61
83
|
export declare function createSession(id: string, runtime: Runtime, metadata?: Partial<ChannelDeliverySource> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{validateSessionHistory}from"#shared/session-history.js";import{parseAnswers}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function internalSession(e){return e}function createSession(e,t,n={}){return{id:e,async send(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createDelivery(n,i.deliveryId),o=sessionCallbackToTurnCaller(i.callback),s=validateSessionHistory(i.history),c=attachClientContext({message:serializeFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(c.context=i.context),s!==void 0&&(c.history=s),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:c,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY,title:i.title},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,a.deliveryId)},async respond(r,i){if(validateDeliveryIdempotencyKey(i.idempotencyKey),r.length===0)throw Error(`respond() requires at least one answer.`);let a=parseAnswers(r),o=sessionCallbackToTurnCaller(i.callback),s=createDelivery(n,i.deliveryId),c=attachClientContext({answers:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,s.deliveryId)},async cancel(n){let r=controlCommand({kind:`cancel`,turnId:n?.turnId},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async prewarm(){return await t.dispatchSession({command:{kind:`prewarm`,targetDeploymentId:n.acceptedDeploymentId},sessionId:e})},async compact(n){let r=controlCommand({kind:`compact`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async clear(n){let r=controlCommand({kind:`clear`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async reset(n){let r=controlCommand({kind:`reset`,reason:n?.reason},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId,{follow:!1})},async*stream(n){yield*await t.getEventStream(e,n)},async getLineStream(n){return t.getLineStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)},async hasRunnableOwner(){return await t.hasRunnableOwner?.(e)??!0},async getChildBinding(n){return await t.readChildBinding?.(e,n)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e,t){let n=createChannelDeliveryMetadata({channelKind:`http`,channelName:`http`,...e});return t===void 0?n:{...n,deliveryId:t}}function buildChannelContext(e){return{session:{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e){return e===void 0?void 0:{callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName}}export{buildChannelContext,createAttachSessionFn,createSession,internalSession,sessionCallbackToTurnCaller};
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{validateSessionHistory}from"#shared/session-history.js";import{parseAnswers}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function internalSession(e){return e}const SESSION_SEND_OPTION_KEYS=Object.keys({auth:!0,context:!0,history:!0,idempotencyKey:!0,outputSchema:!0,title:!0,turnPolicy:!0});function toSessionSendOptions(e){validateDeliveryIdempotencyKey(e.idempotencyKey);let t={};for(let n of SESSION_SEND_OPTION_KEYS)e[n]!==void 0&&(t[n]=e[n]);return t}function createSession(e,t,n={}){return{id:e,async send(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createDelivery(n,i.deliveryId),o=sessionCallbackToTurnCaller(i.callback),s=validateSessionHistory(i.history),c=attachClientContext({message:serializeFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(c.context=i.context),s!==void 0&&(c.history=s),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:c,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY,title:i.title},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,a.deliveryId)},async respond(r,i){if(validateDeliveryIdempotencyKey(i.idempotencyKey),r.length===0)throw Error(`respond() requires at least one answer.`);let a=parseAnswers(r),o=sessionCallbackToTurnCaller(i.callback),s=createDelivery(n,i.deliveryId),c=attachClientContext({answers:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,s.deliveryId)},async cancel(n){let r=controlCommand({kind:`cancel`,turnId:n?.turnId},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async prewarm(){return await t.dispatchSession({command:{kind:`prewarm`,targetDeploymentId:n.acceptedDeploymentId},sessionId:e})},async compact(n){let r=controlCommand({kind:`compact`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async clear(n){let r=controlCommand({kind:`clear`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async reset(n){let r=controlCommand({kind:`reset`,reason:n?.reason},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId,{follow:!1})},async*stream(n){yield*await t.getEventStream(e,n)},async getLineStream(n){return t.getLineStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)},async hasRunnableOwner(){return await t.hasRunnableOwner?.(e)??!0},async getChildBinding(n){return await t.readChildBinding?.(e,n)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e,t){let n=createChannelDeliveryMetadata({channelKind:`http`,channelName:`http`,...e});return t===void 0?n:{...n,deliveryId:t}}function buildChannelContext(e){return{session:{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e){return e===void 0?void 0:{callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName}}export{buildChannelContext,createAttachSessionFn,createSession,internalSession,sessionCallbackToTurnCaller,toSessionSendOptions};
|
|
@@ -2299,6 +2299,7 @@ async function openStreamBody(input) {
|
|
|
2299
2299
|
signal
|
|
2300
2300
|
});
|
|
2301
2301
|
} catch (error) {
|
|
2302
|
+
if (input.redirect === "error" && error instanceof Error && error.cause instanceof Error && error.cause.message === "unexpected redirect") throw new Error("The session stream refused a redirect. Use the final agent URL instead.", { cause: error });
|
|
2302
2303
|
if (input.signal?.aborted || !isStreamDisconnectError(error) || attempt === openRetryPolicy.maxAttempts - 1) throw error;
|
|
2303
2304
|
await sleep(retryDelayMs, input.signal);
|
|
2304
2305
|
retryDelayMs = Math.min(retryDelayMs * 2, openRetryPolicy.maxDelayMs);
|
|
@@ -3253,7 +3254,7 @@ var Client = class {
|
|
|
3253
3254
|
this.#baseUrl = options.baseUrl;
|
|
3254
3255
|
this.#auth = options.auth;
|
|
3255
3256
|
this.#headers = options.headers;
|
|
3256
|
-
this.#redirect = options.redirect;
|
|
3257
|
+
this.#redirect = options.redirect ?? "error";
|
|
3257
3258
|
this.sessions = new ClientSessions({
|
|
3258
3259
|
baseUrl: this.#baseUrl,
|
|
3259
3260
|
redirect: this.#redirect,
|
|
@@ -3350,7 +3351,7 @@ function headersInitToRecord(headers) {
|
|
|
3350
3351
|
return Object.fromEntries(new Headers(headers).entries());
|
|
3351
3352
|
}
|
|
3352
3353
|
function withRedirectPolicy(init, redirect) {
|
|
3353
|
-
return
|
|
3354
|
+
return {
|
|
3354
3355
|
...init,
|
|
3355
3356
|
redirect
|
|
3356
3357
|
};
|
|
@@ -2300,6 +2300,7 @@ async function openStreamBody(input) {
|
|
|
2300
2300
|
signal
|
|
2301
2301
|
});
|
|
2302
2302
|
} catch (error) {
|
|
2303
|
+
if (input.redirect === "error" && error instanceof Error && error.cause instanceof Error && error.cause.message === "unexpected redirect") throw new Error("The session stream refused a redirect. Use the final agent URL instead.", { cause: error });
|
|
2303
2304
|
if (input.signal?.aborted || !isStreamDisconnectError(error) || attempt === openRetryPolicy.maxAttempts - 1) throw error;
|
|
2304
2305
|
await sleep(retryDelayMs, input.signal);
|
|
2305
2306
|
retryDelayMs = Math.min(retryDelayMs * 2, openRetryPolicy.maxDelayMs);
|
|
@@ -3254,7 +3255,7 @@ var Client = class {
|
|
|
3254
3255
|
this.#baseUrl = options.baseUrl;
|
|
3255
3256
|
this.#auth = options.auth;
|
|
3256
3257
|
this.#headers = options.headers;
|
|
3257
|
-
this.#redirect = options.redirect;
|
|
3258
|
+
this.#redirect = options.redirect ?? "error";
|
|
3258
3259
|
this.sessions = new ClientSessions({
|
|
3259
3260
|
baseUrl: this.#baseUrl,
|
|
3260
3261
|
redirect: this.#redirect,
|
|
@@ -3351,7 +3352,7 @@ function headersInitToRecord(headers) {
|
|
|
3351
3352
|
return Object.fromEntries(new Headers(headers).entries());
|
|
3352
3353
|
}
|
|
3353
3354
|
function withRedirectPolicy(init, redirect) {
|
|
3354
|
-
return
|
|
3355
|
+
return {
|
|
3355
3356
|
...init,
|
|
3356
3357
|
redirect
|
|
3357
3358
|
};
|
|
@@ -6,7 +6,8 @@ the coding harness's prompt tools when available, and do not guess.
|
|
|
6
6
|
1. What should the agent do? This becomes its always-on purpose.
|
|
7
7
|
2. Where should it be reachable? Every agent ships the built-in HTTP channel. On
|
|
8
8
|
top of that:
|
|
9
|
-
- **Web Chat** (a Next.js app): add it
|
|
9
|
+
- **Web Chat** (a Next.js or TanStack Start app): add it after init with
|
|
10
|
+
`eve add channel/web`.
|
|
10
11
|
- **Slack** and other platforms: add after deploy with `eve add channel/slack`.
|
|
11
12
|
Credentials run through **Vercel Connect**, which provisions the bot token
|
|
12
13
|
and verifies inbound webhooks, so there is no `SLACK_BOT_TOKEN` or signing
|
|
@@ -4,8 +4,7 @@ First settle the target: a new project, or the agent added to an existing
|
|
|
4
4
|
directory? For a new project, propose a name and ask the user to confirm it; for
|
|
5
5
|
an existing one, ask for the directory.
|
|
6
6
|
|
|
7
|
-
For a new project, run
|
|
8
|
-
Chat):
|
|
7
|
+
For a new project, run:
|
|
9
8
|
|
|
10
9
|
npx eve@latest init <name>
|
|
11
10
|
|
|
@@ -316,5 +316,5 @@ export declare class EveTUIRunner {
|
|
|
316
316
|
run(): Promise<void>;
|
|
317
317
|
}
|
|
318
318
|
/** Returns the registry address carried by a packaged self-modification terminal handoff. */
|
|
319
|
-
export declare function registryHandoffAddress(subagentName: string
|
|
319
|
+
export declare function registryHandoffAddress(subagentName: string, toolName: string | undefined, output: unknown): string | undefined;
|
|
320
320
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{formatFailureDetail,formatFailureMessage,interruptedError,isInterruptedError,localFailureHint}from"./errors.js";import{conversationView,isWorking,tuiSessionData}from"./conversation-view.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{describeRemoteAuthCompletedMutations}from"./remote-auth-result.js";import{createRemoteConnectionController}from"./remote-connection.js";import{prepareRemoteTuiAccess}from"./remote-startup.js";import{formatStrandedSessionNotice}from"./stranded-session.js";import{isTerminalToolCallPart}from"./terminal-tool-part.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import{optionStyle}from"#channel/interaction-prompts.js";import{activeTurn,delivery,failure,openInteractions,task,turn}from"#protocol/session-projection/public-view.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{isTaskAdmissionRefused}from"#protocol/task-tools.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{APPROVE_OPTION_ID,DENY_OPTION_ID}from"#protocol/interaction-options.js";import"#client/conversation-state.js";import{SessionStore,attachSessionStore,detachSessionStore}from"#client/session-store.js";import{isAbortError}from"#client/session-store-helpers.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}function hasOpenTurn(e){return activeTurn(e.view)!==void 0}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=!1;#m;#h;#g=!0;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E=!1;#D;#O=!1;#k=new AbortController;#A=!1;#j=0;#M=0;#N=[];#P;#F;#I;#L;#R;#z=new Set;#B=new Set;#V=[];#H;#U=new Set;#W;#G=0;#K=new Set;#q=new Map;#J;constructor(e){if(this.#e=e.client,e.lifecycle!==void 0&&(this.#J=e.lifecycle),e.diagnostics!==void 0&&(this.#r=e.diagnostics),this.#n=createRenderer(e),this.#t=new SessionStore({client:e.client,followAgents:!0}),this.#t.setCallbacks({onEvent:e=>this.#Ue(e),onSessionChange:e=>{e!==void 0&&this.#n.setSessionId?.(e.sessionId)},prepareSend:e=>this.#ne(e)}),this.#i=e.name??`eve`,this.#y=e.withExclusiveTerminal,this.#a=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#l=e.initialInput),e.startup!==void 0&&(this.#u=e.startup),this.#f=e.onboard===!0,this.#m=e.onOnboardingStep,this.#h=e.onOnboardingTerminal,e.appRoot!==void 0){this.#c=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#F=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#I=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}e.promptCommandHandler!==void 0&&(this.#_=e.promptCommandHandler),this.#v=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0&&(this.#x=e.remote.runAuthFlow,this.#b=createRemoteConnectionController({client:this.#e,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})),this.#S=e.bootDetections??BOOT_DETECTIONS,this.#C=e.getVercelAuthStatus??getVercelAuthStatus,this.#w=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#T=e.onBootProgress),e.serverUrl!==void 0&&(this.#s=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#o=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#Y(){if(this.#s===void 0){this.#Q(),this.#f||await this.#we(void 0);return}let e;if(this.#b!==void 0){let t=await this.#b.check();t.state===`ready`&&(e=t.info)}else{let t=this.#e;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t,timeoutMs:2e3}),this.#T);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#Q();let t=this.#Z(e);this.#f||await this.#we(t)}#X(){let e=this.#u?.finish();return this.#d=e?.queuedPrompt,e?.draft??this.#l}#Z(e){let t=this.#c===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#L=t;let n=this.#s;if(n===void 0||this.#g)return t;let r={name:this.#i,serverUrl:n,localDevelopment:this.#c!==void 0};return t!==void 0&&(r.info=t),this.#n.renderAgentHeader?.(r),t}#Q(){let e=this.#T;this.#T=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#J?.signal.aborted===!0?onStop():this.#J?.signal.addEventListener(`abort`,onStop,{once:!0});let e=this.#t.subscribe(()=>this.#re());attachSessionStore(this.#t);try{await this.#$()}catch(e){if(!isInterruptedError(e))throw e}finally{this.#J?.signal.removeEventListener(`abort`,onStop),this.#E=!0,this.#k.abort(),this.#R?.abort(),e(),detachSessionStore(this.#t),this.#n.shutdown?.(),this.#F?.dispose(),this.#I?.dispose(),this.#b?.dispose()}}async#$(){let e=this.#i,t;this.#n.setStartupPhase?.(`starting`),await this.#Y(),this.#F?.refreshIdentity(),this.#I?.refresh();let n=(this.#f||this.#L?.agent.model.endpoint?.kind===`gateway`&&!this.#L.agent.model.endpoint.connected)&&this.#c!==void 0&&this.#_!==void 0&&this.#n.setupFlow!==void 0,r;if(this.#b!==void 0&&this.#n.setupFlow!==void 0){let e=await prepareRemoteTuiAccess({connection:this.#b,renderer:this.#n.setupFlow,signal:this.#J?.signal,runAuthFlow:this.#x});if(e?.kind===`authenticated`){let e=this.#b.current().connection;e.state===`ready`&&this.#Z(e.info)}else e?.kind===`failed`||e?.kind===`unavailable`?r={failed:!0,message:e.kind===`failed`?e.message:e.failure.message}:e?.kind===`cancelled`&&(r={cancelled:!0},e.completedMutations.length>0&&(r.message=`Completed before cancellation: ${describeRemoteAuthCompletedMutations(e.completedMutations).join(`, `)}.`))}n&&(this.#n.setStartupPhase?.(`connecting`),r=await this.#Ne(e));let i=this.#X();for(r?.cancelled||r?.failed?i=[this.#d,i].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)||void 0:t=this.#d,this.#g=!1,this.#Z(this.#L),this.#Te(),this.#n.setStartupPhase?.(void 0),(!n||r?.cancelled||r?.failed)&&r?.message!==void 0&&this.#Oe({kind:`result`,message:r.message});this.#J?.signal.aborted!==!0&&this.#n.exitRequested?.()!==!0;){if(this.#ie()){this.#me();continue}if(this.#de().length>0){await this.#fe(e);continue}let n=isWorking(this.#t.snapshot.status)?void 0:this.#V.shift();if(n!==void 0){this.#H=n;try{await this.#Ce(n)}finally{this.#H=void 0}continue}if(t===void 0){let n=await this.#be({title:e,initialDraft:i});if(i=void 0,n===void 0)continue;if(n.type===`cancel`){this.#_e();continue}if(n.type===`interrupt`){this.#me(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`);continue}t=n.text}let r=t;t=void 0;let a=parsePromptCommand(r);if(a===null){this.#te(r);continue}let o=await this.#ee(a,e);if(o===`exit`)return;o!==void 0&&(i=o.draft)}}async#ee(e,t){switch(e.type){case`exit`:return this.#Oe({kind:`dismiss`}),this.#J?.requestStop(),`exit`;case`cancel`:{let e=hasOpenTurn(this.#t.snapshot);e&&this.#_e(),this.#Oe({kind:`result`,summary:e?`Cancellation requested`:`No active turn to cancel`});return}case`new`:await this.#ye();return;case`compact`:await this.#ve({absent:`No active session to compact`,accepted:`Compaction requested`,failed:`Couldn't compact the session`,invoke:()=>this.#t.compact()});return;case`clear`:await this.#ve({absent:`No active session to clear`,accepted:`Session context cleared`,failed:`Couldn't clear the session`,invoke:()=>this.#t.clear()});return;case`help`:{if(this.#n.choosePromptCommand===void 0){this.#Oe({kind:`result`,message:formatPromptCommandHelp(this.#v)});return}let e=await this.#n.choosePromptCommand(this.#v);return e===void 0?void 0:{draft:e}}case`info`:await this.#Ie();return;case`loglevel`:{let t=this.#Le(e.argument),n=t.startsWith(`/loglevel is not available`)||t.startsWith(`Unknown log level`);this.#Oe(n?{kind:`result`,message:t}:{kind:`result`,summary:t});return}case`traces`:await this.#Fe(e.argument);return;case`extension`:await this.#Me(e,t,{trigger:`command`});return}}#te(e){let t=this.#t.snapshot,n=hasOpenTurn(t),r={text:e};this.#D=r,n||(this.#O=!1);let i=n?{message:e,turnPolicy:`steer`}:t.session===void 0?{message:e}:{message:e,turnPolicy:`queue`};this.#t.send(i).then(({deliveryId:e})=>{r.deliveryId=e,this.#E||this.#ae(this.#t.snapshot)}).catch(e=>{this.#E||isAbortError(e)||this.#se(n?`Steering failed`:`Error`,e)})}async#ne(e){return e.turnPolicy===`steer`?e:(this.#o!==void 0&&await this.#o.refresh({answers:e.answers,message:typeof e.message==`string`?e.message:void 0,onRuntimeArtifactsChanged:()=>this.#Ve()}),e.message!==void 0&&this.#n.flushDelayedDevBuildErrors?.(),e)}#re(){let e=this.#t.snapshot,t=tuiSessionData(e);this.#n.renderConversation?.(conversationView(e,t,this.#c===void 0?void 0:localFailureHint)),this.#oe(e.error,t.sessionFailed),this.#We(t.failures),this.#He(e),this.#ue(e),this.#Se(e),this.#ae(e),(t.sessionFailed||this.#de().length>0||!isWorking(e.status)&&this.#V.length>0)&&this.#R?.abort()}#ie(){return tuiSessionData(this.#t.snapshot).sessionFailed}#ae(e){let t=this.#D;if(t?.deliveryId===void 0)return;let n=delivery(e.view,t.deliveryId)?.turnId;if(n===void 0)return;let r=turn(e.view,n);if(r===void 0||r.status===`running`)return;let i=r.outcome;this.#D=void 0,i===`cancelled`&&!this.#O&&failure(e.view,n)===void 0&&this.#n.restoreDraft?.(t.text)}#oe(e,t){e!==void 0&&e!==this.#W&&(this.#W=e,!t&&(this.#le(e)||(this.#b?.reportFailure(e),this.#n.renderError?.(`Error`,this.#a(e)))))}#se(e,t){this.#le(t)||this.#n.renderError?.(e,this.#a(t))}#ce(e){return formatStrandedSessionNotice(e,{localServer:this.#c!==void 0,sessionId:this.#t.snapshot.session?.sessionId})}#le(e){let t=this.#ce(e);return t!==void 0&&(this.#n.renderError?.(`Session stranded`,t),!0)}#ue(e){!this.#f||this.#p||!e.messages.some(e=>e.role===`assistant`&&e.parts.some(e=>e.type===`text`&&e.text.length>0))||(this.#p=!0,this.#m?.({flow:`onboarding`,step:`first_response`}))}#de(){return openInteractions(this.#t.snapshot.view).filter(e=>e.request.kind!==`sign-in`&&!this.#z.has(e.interactionId)&&!this.#B.has(e.interactionId))}async#fe(e){for(let t=0;;t+=1){let n=this.#de(),r=n[0];if(r===void 0)return;let i=inputContext(r,t+1,t+n.length),a=await this.#pe(r,i,e);if(a===void 0){this.#z.add(r.interactionId);continue}this.#B.add(r.interactionId),this.#t.send({answers:[a]}).catch(e=>{this.#B.delete(r.interactionId),!(this.#E||isAbortError(e))&&this.#se(`Error`,e)})}}async#pe(e,t,n){if(e.request.kind===`approval`){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);let r=await this.#n.readToolApproval(toAgentTUIToolApprovalRequest(e,t),{title:n});return{interactionId:e.interactionId,optionId:r.approved?APPROVE_OPTION_ID:DENY_OPTION_ID}}if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);let r=await this.#n.readInputQuestion(toAgentTUIInputQuestion(e,t),{title:n});if(r!==void 0)return{interactionId:e.interactionId,...r.optionId!==void 0&&{optionId:r.optionId},...r.text!==void 0&&{text:r.text}}}#me(e){this.#n.renderSessionBoundary===void 0?e===void 0&&this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary(),e!==void 0&&this.#n.renderNotice?.(e),this.#he()}#he(){this.#t.newSession(),this.#ge()}#ge(){this.#z.clear(),this.#B.clear(),this.#U.clear(),this.#q.clear(),this.#G=0,this.#o?.clear()}#_e(){this.#O=!0,this.#t.cancel().catch(e=>{this.#n.renderNotice?.(`Couldn't cancel the turn: ${toErrorMessage(e)}`)})}async#ve(e){if(this.#t.snapshot.session===void 0){this.#Oe({kind:`result`,summary:e.absent});return}try{let t=await(await e.invoke()).result();if(t.status!==`completed`)throw Error(`The command settled ${t.status}.`);this.#Oe({kind:`result`,summary:e.accepted})}catch(t){this.#Oe({kind:`result`,message:this.#ce(t)??toErrorMessage(t),summary:e.failed})}}async#ye(){try{this.#t.snapshot.session!==void 0&&await(await this.#t.reset()).result(),this.#t.newSession()}catch(e){this.#Oe({kind:`result`,message:`Couldn't reset the session: ${toErrorMessage(e)}`});return}this.#ge(),this.#n.reset?.(),this.#Oe({kind:`dismiss`})}async#be(e){if(!this.#n.readInput)throw Error(`The renderer does not support prompt input.`);let t=new AbortController;this.#R=t;try{let n=await this.#xe(this.#n.readInput({...e,signal:t.signal}));if(n===void 0&&!t.signal.aborted)throw interruptedError();return n}finally{this.#R===t&&(this.#R=void 0)}}async#xe(e){let t=this.#o;if(t===void 0)return await e;let n=!1,r=!1,i,a=!1,o=0,refresh=async()=>{if(!(n||r)){r=!0;try{await t.refreshIdle({onRuntimeArtifactsChanged:()=>this.#Ve()}),this.#c!==void 0&&this.#L===void 0&&!a&&(a=!0,this.#ze().finally(()=>{a=!1}));let e=this.#L?.agent.model.endpoint,n=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();n&&r-o>=5e3&&(o=r,this.#ze())}finally{r=!1}}},startRefresh=()=>{if(n||r)return;let e=refresh().finally(()=>{i===e&&(i=void 0)});i=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await e}finally{n=!0,clearInterval(s),await i}}#Se(e){if(this.#c!==void 0)for(let{callId:t,address:n}of registryHandoffs(e))this.#U.has(t)||(this.#U.add(t),!(this.#H===n||this.#V.includes(n))&&this.#V.push(n))}async#Ce(e){this.#n.renderCommandInvocation?.(`/add ${e}`),await this.#Me({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#we(e){if(this.#c===void 0)return;let t={appRoot:this.#c,env:process.env};e!==void 0&&(t.info=e),this.#N=await detectSetupIssues(t,this.#S),this.#n.renderSetupWarning!==void 0&&(this.#Te(),this.#Ee())}#Te(){if(this.#g)return;let e=orderedSetupIssues(this.#N,this.#P);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#Ee(){let e=this.#c;if(e===void 0||process.env.EVE_MODEL_CONNECTION!==`ai-gateway-project`)return;let t;try{t=await this.#C(e,{signal:this.#k.signal})}catch{return}this.#E||this.#A||(this.#P=authIssueForStatus(t),this.#Te())}async#De(e){let t=this.#c;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n=++this.#j,r={appRoot:t,env:process.env};e!==void 0&&(r.info=e);try{let[e,i]=await Promise.all([detectSetupIssues(r,this.#S),process.env.EVE_MODEL_CONNECTION===`ai-gateway-project`?this.#C(t,{signal:this.#k.signal}):void 0]);if(this.#E||n!==this.#j)return;this.#N=e,this.#P=i===void 0?void 0:authIssueForStatus(i),this.#Te()}catch{return}}#Oe(e){if(this.#n.finishCommand!==void 0){this.#n.finishCommand(e);return}if(e.kind===`result`){let t=[e.summary,e.message].filter(Boolean).join(`
|
|
4
|
-
`);t!==``&&this.#n.renderNotice?.(t)}}async#ke(e,t){let n=this.#_;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#L?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#je(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#y},a=this.#I?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}async#Ae(e){if(e?.kind===`model-access-changed`){this.#F?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Re(e);return}e!==void 0&&(this.#F?.applyEffect(e),this.#A=!0,this.#De(this.#L))}async#je(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#g&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#Ae(e.effect);let{effect:t,...n}=e;return n}catch{return{failed:!0,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Me(e,t,n){let r=await this.#ke(e,{...n,title:t}),i=r===void 0?void 0:await this.#je(r);return!(n.suppressSuccessfulTranscript===!0&&i?.failed!==!0||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&(i===void 0?this.#Oe({kind:`result`}):this.#Oe({kind:`result`,message:i.message,summary:i.summary})),this.#Pe(),i}async#Ne(e){this.#m?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Me({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.failed!==!0&&this.#m?.({flow:`onboarding`,step:`connection_ready`}),this.#h?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.failed===!0?`error`:`completed`}),t}#Pe(){if(this.#g)return;let e=this.#b?.current().connection;e?.state===`ready`&&e.info!==this.#L&&(this.#L=e.info,this.#s!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#i,serverUrl:this.#s}))}async#Fe(e){if(this.#c===void 0||this.#n.traceViewer===void 0){this.#Oe({kind:`result`,message:`/traces is only available in local dev sessions.`});return}try{await this.#n.traceViewer.open({appRoot:this.#c,sessionId:this.#t.snapshot.session?.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}finally{this.#Oe({kind:`dismiss`})}}async#Ie(){let e=this.#c;if(e===void 0){this.#Oe({kind:`result`,message:`/info is only available in local dev sessions.`});return}try{let t=renderApplicationInfo(await this.#w(e));this.#n.showInfoPanel===void 0?this.#Oe({kind:`result`,message:t}):await this.#n.showInfoPanel(t)}catch(e){this.#Oe({kind:`result`,message:`Couldn't inspect the application: ${toErrorMessage(e)}`})}}#Le(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel none|error|warn|debug|all — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use none, error, warn, debug, or all.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`error`:return`Showing errors.`;case`warn`:return`Showing warnings and errors.`;case`debug`:return`Showing all severity-tagged logs.`;case`all`:return`Showing all logs.`}}async#Re(e){let t=this.#c;t!==void 0&&(++this.#M,++this.#j,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#o?.refreshAfterSourceChange({}),e.model&&this.#L?this.#Z({...this.#L,agent:{...this.#L.agent,model:{...this.#L.agent.model,...e.model}}}):this.#Z(this.#L),this.#N=[],this.#P=void 0,this.#Te(),this.#ze())}async#ze(e=!1){let t=this.#L,n=++this.#M,r=await this.#Be();this.#E||n!==this.#M||r===void 0||(this.#Z(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#De(this.#L))}async#Be(){let e=this.#e;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#Ve(){this.#ze(!0)}#He(e){let t=this.#r;if(t!==void 0){for(let n of Object.values(e.agents))if(n.observation.status!==`not-followed`)for(let e of n.observation.conversation?.messages??[])for(let r of e.parts)r.type===`tool`&&r.state===`failed`&&(this.#K.has(r.callId)||(this.#K.add(r.callId),t.append({source:`tool`,summary:`${r.name} failed (subagent ${n.name})`,detail:r.error?.message??`Failed.`})))}}#Ue(e){let t=this.#r;if(t!==void 0)switch(e.type){case`call.requested`:this.#q.set(e.data.callId,e.data.capability.name),e.data.capability.kind===`tool`&&t.recordToolCall(e.data.capability.name);break;case`call.settled`:{let n=this.#q.get(e.data.callId)??e.data.callId;isTaskAdmissionRefused(e.data)?t.append({source:`tool`,summary:`${n} was refused for the model to retry`,detail:e.data.error?.message??`Refused.`}):e.data.outcome===`failed`&&t.append({source:`tool`,summary:`${n} failed`,detail:e.data.error?.message??`Tool failed.`});break}case`task.ended`:e.data.outcome===`failed`&&t.append({source:`tool`,summary:`${task(this.#t.snapshot.view,e.data.taskId)?.name??`A task`} ended with an error`,detail:e.data.error?.message??`Task failed.`});break;case`child.opened`:`callId`in e.data.owner&&t.recordSubagentDispatch(e.data.owner.callId);break;case`usage.recorded`:t.recordStepUsage(e.data.usage)}}#We(e){e.length<this.#G&&(this.#G=0);for(let{error:t}of e.slice(this.#G)){let e=formatFailureMessage(t),n={detail:formatFailureDetail(t)??e,source:`workflow`,summary:`Error: ${e}`};this.#r?.append(t.hint===void 0?n:{...n,hint:t.hint})}this.#G=e.length}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,argumentSuggestions:e.argumentSuggestions,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffs(e){let t=[],collect=(e,n)=>{for(let r of e.messages)for(let e of r.parts){if(!isTerminalToolCallPart(e)||e.state!==`completed`)continue;let r=registryHandoffAddress(n,e.name,e.output);r!==void 0&&t.push({callId:e.callId,address:r})}};
|
|
4
|
+
`);t!==``&&this.#n.renderNotice?.(t)}}async#ke(e,t){let n=this.#_;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#L?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#je(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#y},a=this.#I?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}async#Ae(e){if(e?.kind===`model-access-changed`){this.#F?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Re(e);return}e!==void 0&&(this.#F?.applyEffect(e),this.#A=!0,this.#De(this.#L))}async#je(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#g&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#Ae(e.effect);let{effect:t,...n}=e;return n}catch{return{failed:!0,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Me(e,t,n){let r=await this.#ke(e,{...n,title:t}),i=r===void 0?void 0:await this.#je(r);return!(n.suppressSuccessfulTranscript===!0&&i?.failed!==!0||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&(i===void 0?this.#Oe({kind:`result`}):this.#Oe({kind:`result`,message:i.message,summary:i.summary})),this.#Pe(),i}async#Ne(e){this.#m?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Me({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.failed!==!0&&this.#m?.({flow:`onboarding`,step:`connection_ready`}),this.#h?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.failed===!0?`error`:`completed`}),t}#Pe(){if(this.#g)return;let e=this.#b?.current().connection;e?.state===`ready`&&e.info!==this.#L&&(this.#L=e.info,this.#s!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#i,serverUrl:this.#s}))}async#Fe(e){if(this.#c===void 0||this.#n.traceViewer===void 0){this.#Oe({kind:`result`,message:`/traces is only available in local dev sessions.`});return}try{await this.#n.traceViewer.open({appRoot:this.#c,sessionId:this.#t.snapshot.session?.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}finally{this.#Oe({kind:`dismiss`})}}async#Ie(){let e=this.#c;if(e===void 0){this.#Oe({kind:`result`,message:`/info is only available in local dev sessions.`});return}try{let t=renderApplicationInfo(await this.#w(e));this.#n.showInfoPanel===void 0?this.#Oe({kind:`result`,message:t}):await this.#n.showInfoPanel(t)}catch(e){this.#Oe({kind:`result`,message:`Couldn't inspect the application: ${toErrorMessage(e)}`})}}#Le(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel none|error|warn|debug|all — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use none, error, warn, debug, or all.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`error`:return`Showing errors.`;case`warn`:return`Showing warnings and errors.`;case`debug`:return`Showing all severity-tagged logs.`;case`all`:return`Showing all logs.`}}async#Re(e){let t=this.#c;t!==void 0&&(++this.#M,++this.#j,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#o?.refreshAfterSourceChange({}),e.model&&this.#L?this.#Z({...this.#L,agent:{...this.#L.agent,model:{...this.#L.agent.model,...e.model}}}):this.#Z(this.#L),this.#N=[],this.#P=void 0,this.#Te(),this.#ze())}async#ze(e=!1){let t=this.#L,n=++this.#M,r=await this.#Be();this.#E||n!==this.#M||r===void 0||(this.#Z(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#De(this.#L))}async#Be(){let e=this.#e;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#Ve(){this.#ze(!0)}#He(e){let t=this.#r;if(t!==void 0){for(let n of Object.values(e.agents))if(n.observation.status!==`not-followed`)for(let e of n.observation.conversation?.messages??[])for(let r of e.parts)r.type===`tool`&&r.state===`failed`&&(this.#K.has(r.callId)||(this.#K.add(r.callId),t.append({source:`tool`,summary:`${r.name} failed (subagent ${n.name})`,detail:r.error?.message??`Failed.`})))}}#Ue(e){let t=this.#r;if(t!==void 0)switch(e.type){case`call.requested`:this.#q.set(e.data.callId,e.data.capability.name),e.data.capability.kind===`tool`&&t.recordToolCall(e.data.capability.name);break;case`call.settled`:{let n=this.#q.get(e.data.callId)??e.data.callId;isTaskAdmissionRefused(e.data)?t.append({source:`tool`,summary:`${n} was refused for the model to retry`,detail:e.data.error?.message??`Refused.`}):e.data.outcome===`failed`&&t.append({source:`tool`,summary:`${n} failed`,detail:e.data.error?.message??`Tool failed.`});break}case`task.ended`:e.data.outcome===`failed`&&t.append({source:`tool`,summary:`${task(this.#t.snapshot.view,e.data.taskId)?.name??`A task`} ended with an error`,detail:e.data.error?.message??`Task failed.`});break;case`child.opened`:`callId`in e.data.owner&&t.recordSubagentDispatch(e.data.owner.callId);break;case`usage.recorded`:t.recordStepUsage(e.data.usage)}}#We(e){e.length<this.#G&&(this.#G=0);for(let{error:t}of e.slice(this.#G)){let e=formatFailureMessage(t),n={detail:formatFailureDetail(t)??e,source:`workflow`,summary:`Error: ${e}`};this.#r?.append(t.hint===void 0?n:{...n,hint:t.hint})}this.#G=e.length}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,argumentSuggestions:e.argumentSuggestions,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffs(e){let t=[],collect=(e,n)=>{for(let r of e.messages)for(let e of r.parts){if(!isTerminalToolCallPart(e)||e.state!==`completed`)continue;let r=registryHandoffAddress(n,e.name,e.output);r!==void 0&&t.push({callId:e.callId,address:r})}};for(let t of Object.values(e.agents)){if(t.observation.status===`not-followed`)continue;let e=t.observation.conversation;e!==void 0&&collect(e,t.name)}return t}function registryHandoffAddress(e,t,n){if(e!==`self-modification__agent`||t!==`registry_add`||typeof n!=`object`||!n)return;let r=n;return r.status===`needs-terminal`&&typeof r.address==`string`?r.address:void 0}function inputContext(e,t,n){let r={};return n>1&&(r.position={index:t,total:n}),e.taskId!==void 0&&(r.taskId=e.taskId),r.position===void 0&&r.taskId===void 0?void 0:r}function toAgentTUIToolApprovalRequest(e,t){let n={approvalId:e.interactionId,toolCallId:e.call?.callId??e.interactionId,toolName:e.call?.name??e.request.kind,prompt:e.request.prompt,input:e.call?.input??{}};return t!==void 0&&(n.context=t),n}function toAgentTUIInputQuestion(e,t){let n=e.request.display===`text`?`text`:e.request.display===`select`||e.request.options!==void 0&&e.request.options.length>0?`select`:`text`,r={requestId:e.interactionId,prompt:e.request.prompt,display:n};return e.request.options!==void 0&&(r.options=e.request.options.map(e=>{let t={id:e.id,label:e.label};e.description!==void 0&&(t.description=e.description);let n=optionStyle(e);return n!==void 0&&(t.style=n),t})),e.request.allowFreeform!==void 0&&(r.allowFreeform=e.request.allowFreeform),t!==void 0&&(r.context=t),r}export{EveTUIRunner,registryHandoffAddress};
|
package/dist/src/cli/run.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Command,CommanderError}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{findEveProjectContext,resolveEveProjectContext}from"#internal/project-context.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{areSchedulesDisabled}from"#internal/schedules/disabled.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{registerDevelopmentCommand,registerRemoteCommands}from"#cli/dev/command.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{parseAgentNamesOption,parsePortOption,parseReasoningOption}from"#cli/option-parsers.js";import{registerEveTelemetryCommands}from"#cli/telemetry/command.js";import{canonicalCommand,createEveCliTelemetry}from"#cli/telemetry/index.js";async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function createCliProgram(e,t,n,r){let i=resolveInstalledPackageInfo().version,a=new Command,o=createCliTheme();a.name(`eve`).description(`Build and run an eve application.`).version(i).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{let{json:r}=n.opts();!r&&(n.name()===`info`||n.name()===`init`&&n.parent!==a)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),registerEveTelemetryCommands(a,e),registerIntegrationCommands({program:a,logger:e,applicationContext:n});let s=a.command(`extension`).description(`Create and build reusable eve extension packages.`);s.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:a}=await import(`#cli/commands/extension-init.js`);await a(e,n.root,t,void 0,e=>{r.trackSetupStep({flow:`extension_init`,step:e})})}),s.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);await t(n.root);let{runExtensionBuildCommand:r}=await import(`#cli/commands/extension-build.js`);await r(e,n.root)}),registerRegistryCommands({program:a,logger:e,applicationContext:n}),a.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).
|
|
1
|
+
import{Command,CommanderError,Option}from"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{waitForShutdownSignal}from"#cli/shutdown.js";import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createCliTheme,renderCliTaggedLine}from"#cli/ui/output.js";import{findEveProjectContext,resolveEveProjectContext}from"#internal/project-context.js";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{eveCliBanner}from"#cli/banner.js";import{registerBuildCommand}from"#cli/commands/build.js";import{resolveApplicationRoot}from"#internal/application/paths.js";import{areSchedulesDisabled}from"#internal/schedules/disabled.js";import{findCliApplicationRoot,resolveCliApplicationProject}from"#cli/application-root.js";import{registerIntegrationCommands}from"#cli/commands/register-integration-commands.js";import{registerProjectCommands}from"#cli/commands/register-project-commands.js";import{registerRegistryCommands}from"#cli/commands/register-registry-commands.js";import{registerDevelopmentCommand,registerRemoteCommands}from"#cli/dev/command.js";import{resolveDevUiMode,resolveTuiDisplayOptions}from"#cli/dev/ui-options.js";import{registerAcpCommand}from"#cli/acp/command.js";import{parseAgentNamesOption,parsePortOption,parseReasoningOption}from"#cli/option-parsers.js";import{registerEveTelemetryCommands}from"#cli/telemetry/command.js";import{canonicalCommand,createEveCliTelemetry}from"#cli/telemetry/index.js";async function loadPrintApplicationInfo(){return(await import(`#cli/commands/info.js`)).printApplicationInfo}async function loadRunEvalCommand(){return(await import(`#evals/cli/eval.js`)).runEvalCommand}async function loadStartProductionHost(){return(await import(`#internal/nitro/host.js`)).startProductionServer}function createCliProgram(e,t,n,r){let i=resolveInstalledPackageInfo().version,a=new Command,o=createCliTheme();a.name(`eve`).description(`Build and run an eve application.`).version(i).showHelpAfterError().exitOverride().hook(`preAction`,(t,n)=>{let{json:r}=n.opts();!r&&(n.name()===`info`||n.name()===`init`&&n.parent!==a)&&e.log(eveCliBanner())}).configureOutput({writeErr:t=>{e.error(t.trimEnd())},writeOut:t=>{e.log(t.trimEnd())}}),registerEveTelemetryCommands(a,e),registerIntegrationCommands({program:a,logger:e,applicationContext:n});let s=a.command(`extension`).description(`Create and build reusable eve extension packages.`);s.command(`init [target]`).description(`Create a new eve extension package.`).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve extension init.`);let{runExtensionInitCommand:a}=await import(`#cli/commands/extension-init.js`);await a(e,n.root,t,void 0,e=>{r.trackSetupStep({flow:`extension_init`,step:e})})}),s.command(`build`).description(`Build the current package as an eve extension.`).action(async()=>{let{loadDevelopmentEnvironmentFiles:t}=await import(`#cli/dev/environment.js`);await t(n.root);let{runExtensionBuildCommand:r}=await import(`#cli/commands/extension-build.js`);await r(e,n.root)}),registerRegistryCommands({program:a,logger:e,applicationContext:n}),a.command(`init [target]`).description(`Create a new eve agent, or add one to an existing project directory.`).addOption(new Option(`--channel-web-nextjs`,`Add the Web Chat application (Next.js)`).hideHelp()).option(`--agents <names>`,`Create an agents/ workspace with comma-separated agent names`,parseAgentNamesOption).option(`--model <model>`,`Set the agent model (provider/model-id)`).option(`-n, --non-interactive`,`Scaffold the agent without starting development`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).option(`-y, --yes`,`Accepted for compatibility; has no effect`).action(async(t,i)=>{i.yes&&e.error(`warning: --yes has no effect for eve init.`);let{runInitCommand:a}=await import(`#cli/commands/init.js`);await a(e,n.root,t,{agents:i.agents,channelWebNextjs:i.channelWebNextjs,model:i.model,reasoning:i.reasoning,nonInteractive:i.nonInteractive},void 0,e=>{r.trackSetupStep({flow:`init`,step:e})},(e,t,n)=>{r.trackSetupTerminal({flow:`init`,step:e,result:t,failureCode:n})})});let c=a.command(`set`).description(`Change root agent model settings.`);agentCommand(c.command(`model [model]`),n).description(`Set the agent model and reasoning effort.`).option(`--reasoning <effort>`,`Set reasoning (provider-default|none|minimal|low|medium|high|xhigh)`,parseReasoningOption).action(async(t,r)=>{let{runSetCommand:i}=await import(`#cli/commands/set.js`);await i(e,n.root,{model:t,reasoning:r.reasoning})}),registerProjectCommands({program:a,logger:e,applicationContext:n}),registerBuildCommand({applicationContext:n,buildHost:t.buildHost,logger:e,program:a}),agentCommand(a.command(`start`),n).description(`Start a built eve application.`).option(`--no-schedules`,`Start without running authored cron schedules`).option(`--host <host>`,`Host interface to bind`).option(`--port <port>`,`Port to listen on (defaults to $PORT, then 3000)`,parsePortOption).action(async r=>{let{loadDevelopmentEnvironmentFiles:i}=await import(`#cli/dev/environment.js`);await i(n.root);let a=await(t.startProductionHost??await loadStartProductionHost())(n.root,{host:r.host,port:r.port,schedules:r.schedules});e.log(renderCliTaggedLine(o,{message:`server listening at ${a.url}`,tag:`start`,tone:`success`})),(r.schedules===!1||areSchedulesDisabled())&&e.log(renderCliTaggedLine(o,{message:`schedules disabled`,tag:`start`,tone:`info`})),await waitForShutdownSignal({close:()=>a.close(),wait:()=>a.wait()})});let l=a.command(`remote`).description(`Connect to an existing eve agent.`);registerRemoteCommands({applicationContext:n,logger:e,program:l,runtime:t,telemetry:r}),registerAcpCommand({applicationContext:n,eveVersion:i,program:a,resolveVerifiedRemoteDevelopmentClient:t.resolveVerifiedRemoteDevelopmentClient,runAcpServer:t.runAcpServer,startHost:t.startHost}),registerDevelopmentCommand({applicationContext:n,logger:e,program:a,runtime:t,telemetry:r});let u=a.command(`logs`).description("Inspect local `eve dev` diagnostic logs (.eve/logs).");agentCommand(u.command(`show [logid]`,{isDefault:!0}),n).description(`Print a diagnostic log (the most recent when logid is omitted).`).option(`--dump`,`Prepend the log's environment dump (.dump sibling)`).option(`--events`,`Interleave session events from the local workflow store`).action(async(t,r)=>{let{runLogsShowCommand:i}=await import(`#cli/commands/logs.js`);await i(e,n.root,t,r)}),agentCommand(u.command(`list`).alias(`ls`),n).description(`List diagnostic logs, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runLogsListCommand:r}=await import(`#cli/commands/logs.js`);await r(e,n.root,t)});let d=a.command(`traces`).usage(`[options] [trace]
|
|
2
2
|
eve traces list [options]`).description("Inspect local `eve dev` traces.");return agentCommand(d.command(`show [trace]`,{isDefault:!0}),n).description(`Show a local trace (the most recent when trace is omitted).`).option(`--verbose`,`Expand every span with all attributes and events`).option(`--json`,`Output as JSON`).action(async(t,r)=>{let{runTraceShowCommand:i}=await import(`#cli/commands/trace.js`);await i(e,n.root,t,r)}),agentCommand(d.command(`list`).alias(`ls`),n).description(`List local traces, most recent first.`).option(`--json`,`Output as JSON`).action(async t=>{let{runTraceListCommand:r}=await import(`#cli/commands/trace.js`);await r(e,n.root,t)}),agentCommand(a.command(`info`),n).description(`Print resolved application information.`).option(`--json`,`Output as JSON`).action(async r=>{await(t.printApplicationInfo??await loadPrintApplicationInfo())(e,n.root,r)}),agentCommand(a.command(`eval`),n,e=>e.opts().url===void 0).description(`Run evals against an eve agent.`).argument(`[evalIds...]`,`Eval ids (or directory prefixes) to run (all discovered evals when omitted)`).option(`--url <url>`,`Remote agent URL (skip local host startup)`,parseDevelopmentServerUrl).option(`--tag <tag...>`,`Run only evals carrying a tag`).option(`--exclude-tag <tag...>`,`Skip evals carrying a tag`).option(`--strict`,`Fail the exit code when any score falls below its threshold`).option(`--list`,`Print discovered evals without running them`).option(`--timeout <ms>`,`Per-eval timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent eval executions`).option(`--repeat <n>`,`Run every eval n times to measure repeatability`).option(`--json`,`Output results as JSON`).option(`--junit <path>`,`Write JUnit XML results to a file`).option(`--skip-report`,`Skip eval-defined reporters (e.g. Braintrust)`).option(`--keep-state`,`Keep the local eval server's state, including its Workflow data, after the run`).option(`--verbose`,`Stream per-eval logs and workflow run IDs to stdout`).action(async(r,i)=>{await(t.runEvalCommand??await loadRunEvalCommand())(r,i,e,n.root)}),a}async function runCli(e=process.argv.slice(2),t=console,n={}){let r={root:resolveApplicationRoot(),async resolve(){let e=await(n.resolveApplicationProject??resolveCliApplicationProject)(r.root);r.project=e,r.root=e.appRoot},async resolveAgent(){return resolveEveProjectContext(r.root)}},i=createEveCliTelemetry(resolveInstalledPackageInfo().version),a=createCliProgram(t,n,r,i),o=e;if(o.length===0){let e=await(n.findApplicationRoot??findCliApplicationRoot)(r.root);e===void 0?o=(await findEveProjectContext(r.root))?.kind===`workspace`?[`dev`]:[`init`]:(r.root=e,o=[`dev`])}let s=canonicalCommand(o);i.trackCommand(s),s!==`telemetry`&&await i.notify(t);try{await a.parseAsync(o,{from:`user`}),i.trackOutcome(`success`)}catch(e){if(e instanceof CommanderError&&e.exitCode===0){i.trackOutcome(`success`);return}if(i.trackOutcome(e instanceof CommanderError?`usage_error`:`error`),e instanceof CommanderError){let r=await(n.isCodingAgentLaunch??isCodingAgentLaunch)();if(o[0]===`init`&&r){let{initAgentInstructions:e}=await import(`#cli/commands/agent-instructions.js`);t.log(e())}throw Error(e.message)}throw e}finally{await i.flush()}}export{createCliProgram,resolveDevUiMode,resolveTuiDisplayOptions,runCli};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{ClientError}from"#client/client-error.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{HealthResponseError}from"#client/health-response-error.js";import{HealthResultSchema}from"#client/health-schema.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientSessions}from"#client/sessions.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;sessions;constructor(e){this.#n=e.baseUrl,this.#e=e.auth,this.#t=e.headers,this.#r=e.redirect
|
|
1
|
+
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{ClientError}from"#client/client-error.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{HealthResponseError}from"#client/health-response-error.js";import{HealthResultSchema}from"#client/health-schema.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientSessions}from"#client/sessions.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;sessions;constructor(e){this.#n=e.baseUrl,this.#e=e.auth,this.#t=e.headers,this.#r=e.redirect??`error`,this.sessions=new ClientSessions({baseUrl:this.#n,redirect:this.#r,resolveHeaders:e=>this.#i(e)})}async health(){let e=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),t=await this.#i(),n=await fetch(e,withRedirectPolicy({headers:t},this.#r));if(!n.ok){let e=await n.text();throw new ClientError(n.status,e,n.headers)}let r;try{r=await n.json()}catch{throw new HealthResponseError}let i=HealthResultSchema.safeParse(r);if(!i.success)throw new HealthResponseError(i.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return i.data}async info(e={}){let t=await this.fetch(EVE_INFO_ROUTE_PATH,e);if(!t.ok){let e=await t.text();throw new ClientError(t.status,e,t.headers)}let n;try{n=await t.json()}catch{throw new AgentInfoResponseError}let r=AgentInfoResultSchema.safeParse(n);if(!r.success)throw new AgentInfoResponseError(r.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return r.data}async fetch(e,t={}){let n=createClientUrl(this.#n,e),r=await this.#i(headersInitToRecord(t.headers));return await fetch(n,withRedirectPolicy({...t,headers:r},this.#r))}async#i(e){let t=new Headers,[n,r]=await Promise.all([resolveHeadersValue(this.#t),this.#a()]);for(let[e,r]of Object.entries(n))t.set(e,r);for(let[e,n]of Object.entries(r))t.set(e,n);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);return t}async#a(){let e=this.#e;if(!e)return{};if(`vercelOidc`in e){let t=(await resolveTokenValue(e.vercelOidc.token)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`,[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]:t}}if(`bearer`in e){let t=(await resolveTokenValue(e.bearer)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`}}if(`basic`in e){let t=await resolveTokenValue(e.basic.password);return{authorization:`Basic ${encodeBasicCredentials(e.basic.username,t)}`}}return{}}};async function resolveTokenValue(e){return typeof e==`function`?e():e}async function resolveHeadersValue(e){return e===void 0?{}:typeof e==`function`?await e():e}function headersInitToRecord(e){return e===void 0?{}:Object.fromEntries(new Headers(e).entries())}function withRedirectPolicy(e,t){return{...e,redirect:t}}export{Client};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{ClientError,ClientSessionStrandedError,createClientError}from"#client/client-error.js";import{createEventReader}from"#protocol/session-lines.js";import{EVE_STREAM_TAIL_INDEX_HEADER}from"#protocol/session-http.js";import{createClientUrl}from"#client/url.js";import{throwIfAborted}from"#client/abort-signal.js";import{isV26Line}from"#protocol/v26-lines.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";import{readMessageStreamVersion}from"#client/stream-version.js";const RECONNECT_BACKOFF={baseDelayMs:250,maxDelayMs:5e3},DEFAULT_STREAM_RECONNECT_POLICY={reconnect:!0,retryableErrorStatuses:new Set([404,409,425,500,502,503,504]),streamOpenReconnectPolicy:{baseDelayMs:250,maxAttempts:12,maxDelayMs:5e3}},NO_STREAM_RECONNECT_POLICY={...DEFAULT_STREAM_RECONNECT_POLICY,reconnect:!1,streamOpenReconnectPolicy:{...DEFAULT_STREAM_RECONNECT_POLICY.streamOpenReconnectPolicy,maxAttempts:1}};function isRetryableStreamError(e,t=DEFAULT_STREAM_RECONNECT_POLICY.retryableErrorStatuses){return e instanceof ClientSessionStrandedError?!1:SessionNotActiveError.is(e)?t.has(409):e instanceof ClientError?e.code!==`session_version_unsupported`&&t.has(e.status):isStreamDisconnectError(e)}function resolveRetryPolicy(e,t){return{...t,...e}}function resolveStreamReconnectPolicy(e){if(e&&`reconnect`in e&&e.reconnect===!1)return NO_STREAM_RECONNECT_POLICY;let t=e;return{reconnect:!0,retryableErrorStatuses:t?.retryableErrorStatuses?new Set(t.retryableErrorStatuses):DEFAULT_STREAM_RECONNECT_POLICY.retryableErrorStatuses,streamOpenReconnectPolicy:resolveRetryPolicy(t?.streamOpenReconnectPolicy,DEFAULT_STREAM_RECONNECT_POLICY.streamOpenReconnectPolicy)}}async function*followStreamLines(e){let resolvePolicy=()=>resolveStreamReconnectPolicy(e.resolveReconnectPolicy===void 0?e.streamReconnectPolicy:e.resolveReconnectPolicy()),t=e.follow===!1||e.onCaughtUp!==void 0,n=e.startIndex,r=RECONNECT_BACKOFF.baseDelayMs,i=0,a,o=!1,passedTail=()=>a!==void 0&&n>a,noteProgress=()=>(!o&&passedTail()&&(o=!0,e.onCaughtUp?.()),e.follow===!1&&passedTail());for(;;){let o=resolvePolicy(),s;try{s=await openStreamBody({...e,retryPolicy:o,startIndex:n,requestTailIndex:(t||n<0)&&a===void 0})}catch(t){if(e.signal?.aborted)return;throw t}if((t||n<0)&&a===void 0){if(a=s.tailIndex,a===void 0)throw s.close(),Error(`This read requires the server to report the ${EVE_STREAM_TAIL_INDEX_HEADER} header. The agent may be running an older eve version.`);n<0&&(n=Math.max(0,a+1+n))}try{e.onOpen?.(s.headers)}catch(e){throw s.close(),e}if(noteProgress()){s.close();return}let c=!1,l=!1;try{for await(let t of readNdjsonStream(s.body,{signal:e.signal,idleTimeoutMs:e.streamReadIdleTimeoutMs??3e4}))switch(t.kind){case`transport`:switch(t.record.$eve){case`position`:if(t.record.next>n&&(n=t.record.next),e.onPosition?.(n),noteProgress())return;break;case`stream.lease-ended`:l=!0;break;case`stream.ended`:c=!0}continue;case`unknown-transport`:continue;case`commit`:case`progress`:case`invalid`:{if(t.kind===`invalid`&&isV26Line(t.value))throw new ClientError(409,JSON.stringify({code:`session_version_unsupported`,error:`This session was started by an earlier eve version. Start a new session.`}));let a=n;if(n+=1,i=0,r=RECONNECT_BACKOFF.baseDelayMs,yield{line:t.kind===`invalid`?void 0:t.line,position:a},e.onPosition?.(n),noteProgress())return}}}catch(e){if(!isStreamDisconnectError(e))throw e}finally{s.close()}if(c||e.signal?.aborted||!resolvePolicy().reconnect)return;if(!l){if(i+=1,e.follow===!1&&i>=o.streamOpenReconnectPolicy.maxAttempts)throw Error(`The session stream kept disconnecting before the read reached its tail.`);if(await sleep(r,e.signal),e.signal?.aborted)return;r=Math.min(r*2,RECONNECT_BACKOFF.maxDelayMs)}}}async function*followStreamIterable(e){let t=createEventReader();for await(let{line:n,position:r}of followStreamLines(e)){if(n===void 0)continue;let e=t.read(n,r);for(let[t,n]of e.entries())yield{cursor:t===e.length-1?r+1:r,event:n}}}async function openStreamBody(e){let t=e.retryPolicy??resolveStreamReconnectPolicy(e.streamReconnectPolicy),n=t.streamOpenReconnectPolicy,r,i,a,o=n.baseDelayMs,s={...e.searchParams};e.startIndex!==0&&(s.startIndex=String(e.startIndex)),e.requestTailIndex===!0&&(s.includeTailIndex=`1`),e.follow===!1&&(s.follow=`false`);for(let c=0;c<n.maxAttempts;c+=1){throwIfAborted(e.signal);let l=createClientUrl(e.baseUrl,e.path,Object.keys(s).length>0?s:void 0),u=await e.resolveHeaders();throwIfAborted(e.signal);let d=new AbortController,f=e.signal?AbortSignal.any([e.signal,d.signal]):d.signal,p;try{p=await fetch(l,{cache:`no-store`,headers:u,redirect:e.redirect,signal:f})}catch(t){if(e.signal?.aborted||!isStreamDisconnectError(t)||c===n.maxAttempts-1)throw t;await sleep(o,e.signal),o=Math.min(o*2,n.maxDelayMs);continue}if(p.ok){if(!p.body)throw new ClientError(p.status,`Response body is null.`,p.headers);try{readMessageStreamVersion(p.headers)}catch(e){throw p.body.cancel().catch(()=>{}),d.abort(),e}let e=!1;return{headers:p.headers,body:p.body,close:()=>{e||(e=!0,p.body?.cancel().catch(()=>{}),d.abort())},tailIndex:parseTailIndexHeader(p.headers)}}r=p.status,i=await p.text(),a=p.headers;let m=createClientError(p.status,i,p.headers);if(!isRetryableStreamError(m,t.retryableErrorStatuses))throw m;c<n.maxAttempts-1&&(await sleep(o,e.signal),o=Math.min(o*2,n.maxDelayMs))}throw new ClientError(r??0,i??`Failed to open message stream.`,a)}function parseTailIndexHeader(e){let t=e.get(EVE_STREAM_TAIL_INDEX_HEADER);if(t===null||!/^-?\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)?n:void 0}async function sleep(e,t){t?.aborted||await new Promise(n=>{let onAbort=()=>{clearTimeout(r),n()},r=setTimeout(()=>{t?.removeEventListener(`abort`,onAbort),n()},e);t?.addEventListener(`abort`,onAbort,{once:!0})})}export{DEFAULT_STREAM_RECONNECT_POLICY,RECONNECT_BACKOFF,followStreamIterable,followStreamLines,isRetryableStreamError,openStreamBody,sleep};
|
|
1
|
+
import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{ClientError,ClientSessionStrandedError,createClientError}from"#client/client-error.js";import{createEventReader}from"#protocol/session-lines.js";import{EVE_STREAM_TAIL_INDEX_HEADER}from"#protocol/session-http.js";import{createClientUrl}from"#client/url.js";import{throwIfAborted}from"#client/abort-signal.js";import{isV26Line}from"#protocol/v26-lines.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";import{readMessageStreamVersion}from"#client/stream-version.js";const RECONNECT_BACKOFF={baseDelayMs:250,maxDelayMs:5e3},DEFAULT_STREAM_RECONNECT_POLICY={reconnect:!0,retryableErrorStatuses:new Set([404,409,425,500,502,503,504]),streamOpenReconnectPolicy:{baseDelayMs:250,maxAttempts:12,maxDelayMs:5e3}},NO_STREAM_RECONNECT_POLICY={...DEFAULT_STREAM_RECONNECT_POLICY,reconnect:!1,streamOpenReconnectPolicy:{...DEFAULT_STREAM_RECONNECT_POLICY.streamOpenReconnectPolicy,maxAttempts:1}};function isRetryableStreamError(e,t=DEFAULT_STREAM_RECONNECT_POLICY.retryableErrorStatuses){return e instanceof ClientSessionStrandedError?!1:SessionNotActiveError.is(e)?t.has(409):e instanceof ClientError?e.code!==`session_version_unsupported`&&t.has(e.status):isStreamDisconnectError(e)}function resolveRetryPolicy(e,t){return{...t,...e}}function resolveStreamReconnectPolicy(e){if(e&&`reconnect`in e&&e.reconnect===!1)return NO_STREAM_RECONNECT_POLICY;let t=e;return{reconnect:!0,retryableErrorStatuses:t?.retryableErrorStatuses?new Set(t.retryableErrorStatuses):DEFAULT_STREAM_RECONNECT_POLICY.retryableErrorStatuses,streamOpenReconnectPolicy:resolveRetryPolicy(t?.streamOpenReconnectPolicy,DEFAULT_STREAM_RECONNECT_POLICY.streamOpenReconnectPolicy)}}async function*followStreamLines(e){let resolvePolicy=()=>resolveStreamReconnectPolicy(e.resolveReconnectPolicy===void 0?e.streamReconnectPolicy:e.resolveReconnectPolicy()),t=e.follow===!1||e.onCaughtUp!==void 0,n=e.startIndex,r=RECONNECT_BACKOFF.baseDelayMs,i=0,a,o=!1,passedTail=()=>a!==void 0&&n>a,noteProgress=()=>(!o&&passedTail()&&(o=!0,e.onCaughtUp?.()),e.follow===!1&&passedTail());for(;;){let o=resolvePolicy(),s;try{s=await openStreamBody({...e,retryPolicy:o,startIndex:n,requestTailIndex:(t||n<0)&&a===void 0})}catch(t){if(e.signal?.aborted)return;throw t}if((t||n<0)&&a===void 0){if(a=s.tailIndex,a===void 0)throw s.close(),Error(`This read requires the server to report the ${EVE_STREAM_TAIL_INDEX_HEADER} header. The agent may be running an older eve version.`);n<0&&(n=Math.max(0,a+1+n))}try{e.onOpen?.(s.headers)}catch(e){throw s.close(),e}if(noteProgress()){s.close();return}let c=!1,l=!1;try{for await(let t of readNdjsonStream(s.body,{signal:e.signal,idleTimeoutMs:e.streamReadIdleTimeoutMs??3e4}))switch(t.kind){case`transport`:switch(t.record.$eve){case`position`:if(t.record.next>n&&(n=t.record.next),e.onPosition?.(n),noteProgress())return;break;case`stream.lease-ended`:l=!0;break;case`stream.ended`:c=!0}continue;case`unknown-transport`:continue;case`commit`:case`progress`:case`invalid`:{if(t.kind===`invalid`&&isV26Line(t.value))throw new ClientError(409,JSON.stringify({code:`session_version_unsupported`,error:`This session was started by an earlier eve version. Start a new session.`}));let a=n;if(n+=1,i=0,r=RECONNECT_BACKOFF.baseDelayMs,yield{line:t.kind===`invalid`?void 0:t.line,position:a},e.onPosition?.(n),noteProgress())return}}}catch(e){if(!isStreamDisconnectError(e))throw e}finally{s.close()}if(c||e.signal?.aborted||!resolvePolicy().reconnect)return;if(!l){if(i+=1,e.follow===!1&&i>=o.streamOpenReconnectPolicy.maxAttempts)throw Error(`The session stream kept disconnecting before the read reached its tail.`);if(await sleep(r,e.signal),e.signal?.aborted)return;r=Math.min(r*2,RECONNECT_BACKOFF.maxDelayMs)}}}async function*followStreamIterable(e){let t=createEventReader();for await(let{line:n,position:r}of followStreamLines(e)){if(n===void 0)continue;let e=t.read(n,r);for(let[t,n]of e.entries())yield{cursor:t===e.length-1?r+1:r,event:n}}}async function openStreamBody(e){let t=e.retryPolicy??resolveStreamReconnectPolicy(e.streamReconnectPolicy),n=t.streamOpenReconnectPolicy,r,i,a,o=n.baseDelayMs,s={...e.searchParams};e.startIndex!==0&&(s.startIndex=String(e.startIndex)),e.requestTailIndex===!0&&(s.includeTailIndex=`1`),e.follow===!1&&(s.follow=`false`);for(let c=0;c<n.maxAttempts;c+=1){throwIfAborted(e.signal);let l=createClientUrl(e.baseUrl,e.path,Object.keys(s).length>0?s:void 0),u=await e.resolveHeaders();throwIfAborted(e.signal);let d=new AbortController,f=e.signal?AbortSignal.any([e.signal,d.signal]):d.signal,p;try{p=await fetch(l,{cache:`no-store`,headers:u,redirect:e.redirect,signal:f})}catch(t){if(e.redirect===`error`&&t instanceof Error&&t.cause instanceof Error&&t.cause.message===`unexpected redirect`)throw Error(`The session stream refused a redirect. Use the final agent URL instead.`,{cause:t});if(e.signal?.aborted||!isStreamDisconnectError(t)||c===n.maxAttempts-1)throw t;await sleep(o,e.signal),o=Math.min(o*2,n.maxDelayMs);continue}if(p.ok){if(!p.body)throw new ClientError(p.status,`Response body is null.`,p.headers);try{readMessageStreamVersion(p.headers)}catch(e){throw p.body.cancel().catch(()=>{}),d.abort(),e}let e=!1;return{headers:p.headers,body:p.body,close:()=>{e||(e=!0,p.body?.cancel().catch(()=>{}),d.abort())},tailIndex:parseTailIndexHeader(p.headers)}}r=p.status,i=await p.text(),a=p.headers;let m=createClientError(p.status,i,p.headers);if(!isRetryableStreamError(m,t.retryableErrorStatuses))throw m;c<n.maxAttempts-1&&(await sleep(o,e.signal),o=Math.min(o*2,n.maxDelayMs))}throw new ClientError(r??0,i??`Failed to open message stream.`,a)}function parseTailIndexHeader(e){let t=e.get(EVE_STREAM_TAIL_INDEX_HEADER);if(t===null||!/^-?\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)?n:void 0}async function sleep(e,t){t?.aborted||await new Promise(n=>{let onAbort=()=>{clearTimeout(r),n()},r=setTimeout(()=>{t?.removeEventListener(`abort`,onAbort),n()},e);t?.addEventListener(`abort`,onAbort,{once:!0})})}export{DEFAULT_STREAM_RECONNECT_POLICY,RECONNECT_BACKOFF,followStreamIterable,followStreamLines,isRetryableStreamError,openStreamBody,sleep};
|
|
@@ -67,10 +67,11 @@ export interface ClientOptions {
|
|
|
67
67
|
*/
|
|
68
68
|
readonly headers?: HeadersValue;
|
|
69
69
|
/**
|
|
70
|
-
* Redirect policy for every request, including streams.
|
|
71
|
-
* per-request `RequestInit.redirect`.
|
|
72
|
-
* `"manual"`
|
|
73
|
-
* redirect.
|
|
70
|
+
* Redirect policy for every request, including streams. Defaults to
|
|
71
|
+
* `"error"` and overrides a per-request `RequestInit.redirect`. Use
|
|
72
|
+
* `"manual"` to stop at redirects. Browsers expose an opaque response;
|
|
73
|
+
* Node.js exposes the redirect status and headers.
|
|
74
|
+
* `"follow"` explicitly permits forwarding custom headers on redirects.
|
|
74
75
|
*/
|
|
75
76
|
readonly redirect?: ClientRedirectPolicy;
|
|
76
77
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"moduleFingerprints": {
|
|
3
3
|
"@eve/catalog": "29b7529f6044427c750e4c27fe91da792014c60c660db31b7ca1fff0afe7f603",
|
|
4
4
|
"just-secrets": "1ce67d437d0bb06df02e4e99180a3c5f5edf0010314010226e97b96d462bba5d",
|
|
5
|
-
"@vercel/agent-runs": "
|
|
5
|
+
"@vercel/agent-runs": "bd9dbd157bb034dc10d3949b621b6d9d80e028dd4735df3b4819256067577d0a",
|
|
6
6
|
"@workflow/world-local": "a10e78551f65fc607cf75261a569d852c40bc9cfac13a7fb6e15c88bf1ccf429"
|
|
7
7
|
},
|
|
8
8
|
"moduleVersions": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@shadcn/registry": "0.1.3",
|
|
43
43
|
"@standard-schema/spec": "1.1.0",
|
|
44
44
|
"turndown": "7.2.4",
|
|
45
|
-
"@vercel/agent-runs": "0.0.
|
|
45
|
+
"@vercel/agent-runs": "0.0.2",
|
|
46
46
|
"@vercel/blob": "2.8.0",
|
|
47
47
|
"@vercel/connect": "2.5.2",
|
|
48
48
|
"@vercel/detect-agent": "1.2.3",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@vercel/queue": "0.5.1",
|
|
52
52
|
"@vercel/sandbox": "3.9.0",
|
|
53
53
|
"@vercel/sdk": "1.28.8",
|
|
54
|
-
"@vercel/schedules": "0.0.0-alpha.
|
|
54
|
+
"@vercel/schedules": "0.0.0-alpha.19",
|
|
55
55
|
"@workflow/core": "5.2.3",
|
|
56
56
|
"@workflow/errors": "5.0.5",
|
|
57
57
|
"@workflow/serde": "5.0.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"zod": "4.5.4",
|
|
62
62
|
"zod-validation-error": "5.0.0"
|
|
63
63
|
},
|
|
64
|
-
"scriptHash": "
|
|
64
|
+
"scriptHash": "90a2d0a60853ca975229f547260bd2d13c40547d53274021ce81688db2ebae9c",
|
|
65
65
|
"toolVersions": {
|
|
66
66
|
"rolldown": "1.2.9",
|
|
67
67
|
"typescript": "7.0.2"
|