eve 0.30.7 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +5 -6
- package/dist/src/acp/adapter.d.ts +10 -4
- package/dist/src/acp/adapter.js +1 -1
- package/dist/src/channel/adapter-context.d.ts +1 -1
- package/dist/src/channel/adapter.d.ts +2 -4
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/channel-address.d.ts +58 -0
- package/dist/src/channel/channel-address.js +1 -0
- package/dist/src/channel/channel-operations.d.ts +72 -0
- package/dist/src/channel/channel-operations.js +1 -0
- package/dist/src/channel/compiled-channel.d.ts +10 -6
- package/dist/src/channel/cross-channel-receive.d.ts +13 -25
- package/dist/src/channel/cross-channel-receive.js +2 -2
- package/dist/src/channel/receive-target.d.ts +1 -2
- package/dist/src/channel/routes.d.ts +21 -149
- package/dist/src/channel/schedule.d.ts +1 -1
- package/dist/src/channel/schedule.js +1 -1
- package/dist/src/channel/send-input.d.ts +6 -0
- package/dist/src/channel/send-input.js +1 -0
- package/dist/src/channel/session.d.ts +44 -30
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +8 -35
- package/dist/src/chunks/{use-eve-agent-k-XHfrJT.js → use-eve-agent-CF5D6jSV.js} +361 -367
- package/dist/src/chunks/{use-eve-agent-BXMIf5fR.js → use-eve-agent-DbYZLG0h.js} +364 -368
- package/dist/src/cli/commands/agent-prompt/build-and-verify.md +1 -2
- package/dist/src/cli/commands/channel-add-conflicts.js +1 -1
- package/dist/src/cli/commands/info.d.ts +1 -1
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/commands/registry-metadata.d.ts +15 -0
- package/dist/src/cli/commands/registry-metadata.js +1 -0
- package/dist/src/cli/commands/registry-package.d.ts +46 -0
- package/dist/src/cli/commands/registry-package.js +1 -0
- package/dist/src/cli/commands/registry.d.ts +1 -1
- package/dist/src/cli/commands/registry.js +4 -4
- 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/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +2 -2
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/invoke/invoke.d.ts +1 -1
- package/dist/src/cli/invoke/invoke.js +1 -1
- package/dist/src/cli/invoke/result.d.ts +0 -11
- package/dist/src/cli/invoke/result.js +1 -1
- package/dist/src/client/client-error.d.ts +2 -0
- package/dist/src/client/client-error.js +1 -1
- package/dist/src/client/client.d.ts +7 -14
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/eve-agent-store.d.ts +4 -4
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/index.d.ts +3 -2
- package/dist/src/client/index.js +1 -1
- package/dist/src/client/message-reducer-types.d.ts +3 -0
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/message-response.d.ts +2 -7
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session-controls.d.ts +29 -0
- package/dist/src/client/session-controls.js +1 -0
- package/dist/src/client/session-utils.d.ts +0 -20
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.d.ts +26 -90
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/sessions.d.ts +20 -0
- package/dist/src/client/sessions.js +1 -0
- package/dist/src/client/types.d.ts +26 -47
- package/dist/src/compiler/extension-compatibility.d.ts +10 -10
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/evals/cli/eval-client.js +1 -1
- package/dist/src/evals/context.js +1 -1
- package/dist/src/evals/session.d.ts +7 -6
- package/dist/src/evals/session.js +1 -1
- package/dist/src/evals/types.d.ts +9 -9
- package/dist/src/execution/agent-handle-dispatch.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/remote-agent-dispatch.d.ts +1 -3
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/runtime-errors.d.ts +1 -1
- package/dist/src/execution/session-command-token.d.ts +2 -0
- package/dist/src/execution/session-command-token.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-hitl-proxy.js +1 -1
- package/dist/src/execution/tool-auth.d.ts +1 -1
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/turn-control-receiver.d.ts +2 -2
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/cancelled-turn-emission.d.ts +1 -1
- package/dist/src/harness/cancelled-turn-emission.js +1 -1
- package/dist/src/harness/emission-state.d.ts +25 -0
- package/dist/src/harness/emission-state.js +1 -0
- package/dist/src/harness/emission.d.ts +5 -37
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/handles/prompt.d.ts +22 -3
- package/dist/src/harness/handles/prompt.js +1 -1
- package/dist/src/harness/handles/store.d.ts +0 -5
- package/dist/src/harness/handles/store.js +1 -1
- package/dist/src/harness/ordered-stream-emitter.d.ts +3 -2
- package/dist/src/harness/ordered-stream-emitter.js +1 -1
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tools.d.ts +1 -1
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.d.ts +15 -0
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-local-roots.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.d.ts +14 -2
- package/dist/src/internal/nitro/dev-runtime-source-snapshot.js +1 -1
- package/dist/src/internal/nitro/host/dev-server-http.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.d.ts +2 -5
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +4 -3
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/protocol/cancel-turn.d.ts +9 -4
- package/dist/src/protocol/cancel-turn.js +1 -1
- package/dist/src/protocol/message.d.ts +27 -17
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/reset-session.d.ts +1 -1
- package/dist/src/protocol/routes.d.ts +27 -47
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +19 -21
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
- package/dist/src/public/channels/discord/discordChannel.d.ts +5 -4
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/eve.d.ts +11 -10
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/github/dispatch.d.ts +8 -8
- package/dist/src/public/channels/github/dispatch.js +1 -1
- package/dist/src/public/channels/github/githubChannel.d.ts +4 -3
- package/dist/src/public/channels/github/githubChannel.js +1 -1
- package/dist/src/public/channels/github/pr-context.d.ts +1 -1
- package/dist/src/public/channels/index.d.ts +1 -1
- package/dist/src/public/channels/linear/linearChannel.d.ts +4 -3
- package/dist/src/public/channels/linear/linearChannel.js +1 -1
- package/dist/src/public/channels/slack/index.d.ts +1 -1
- package/dist/src/public/channels/slack/interactions.d.ts +3 -4
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/session-operations.d.ts +37 -0
- package/dist/src/public/channels/slack/session-operations.js +1 -0
- package/dist/src/public/channels/slack/slackChannel.d.ts +56 -74
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +4 -3
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +5 -4
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +4 -3
- package/dist/src/public/channels/twilio/twilioChannel.js +1 -1
- package/dist/src/public/definitions/callback-context.d.ts +1 -2
- package/dist/src/public/definitions/channel.d.ts +22 -86
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/hook.d.ts +1 -0
- package/dist/src/public/definitions/remote-agent.js +1 -1
- package/dist/src/public/definitions/schedule.d.ts +16 -16
- package/dist/src/public/definitions/tool.d.ts +5 -5
- package/dist/src/public/schedules/index.d.ts +1 -1
- package/dist/src/react/use-eve-agent.d.ts +7 -4
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/agent/bootstrap-model-utils.d.ts +11 -0
- package/dist/src/runtime/agent/bootstrap-model-utils.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
- package/dist/src/runtime/types.d.ts +2 -2
- package/dist/src/services/inspect-application.d.ts +1 -1
- package/dist/src/services/inspect-application.js +1 -1
- package/dist/src/setup/channel-add-conflicts.js +1 -1
- package/dist/src/setup/integrations/linear/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +29 -17
- package/dist/src/shared/async-iterable.d.ts +2 -0
- package/dist/src/shared/async-iterable.js +1 -0
- package/dist/src/shared/channel-definition.d.ts +7 -7
- package/dist/src/shared/schedule-definition.d.ts +2 -2
- package/dist/src/shared/tool-definition.d.ts +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +8 -5
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +8 -5
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/README.md +6 -6
- package/docs/channels/chat-sdk.mdx +5 -6
- package/docs/channels/custom.mdx +116 -144
- package/docs/channels/discord.mdx +1 -1
- package/docs/channels/eve.mdx +76 -30
- package/docs/channels/github.mdx +1 -1
- package/docs/channels/linear.mdx +10 -10
- package/docs/channels/overview.mdx +2 -2
- package/docs/channels/slack.mdx +46 -15
- package/docs/channels/telegram.mdx +1 -1
- package/docs/channels/twilio.mdx +1 -1
- package/docs/concepts/default-harness.md +11 -3
- package/docs/concepts/execution-model-and-durability.mdx +17 -5
- package/docs/concepts/sessions-runs-and-streaming.md +45 -16
- package/docs/evals/cases.mdx +3 -3
- package/docs/evals/targets.mdx +1 -1
- package/docs/guides/auth-and-route-protection.md +2 -1
- package/docs/guides/client/continuations.mdx +50 -77
- package/docs/guides/client/messages.mdx +29 -33
- package/docs/guides/client/output-schema.mdx +7 -14
- package/docs/guides/client/overview.mdx +40 -11
- package/docs/guides/client/streaming.mdx +18 -23
- package/docs/guides/frontend/nuxt.mdx +1 -1
- package/docs/guides/frontend/overview.mdx +40 -36
- package/docs/guides/frontend/sveltekit.mdx +1 -1
- package/docs/guides/frontend/use-eve-agent-svelte.mdx +19 -23
- package/docs/guides/frontend/use-eve-agent-vue.mdx +21 -25
- package/docs/guides/hooks.md +1 -1
- package/docs/guides/instrumentation.md +1 -1
- package/docs/install-integrations.mdx +4 -2
- package/docs/patterns/dynamic-scheduling.md +16 -15
- package/docs/reference/cli.md +4 -1
- package/docs/schedules.mdx +10 -11
- package/docs/subagents.mdx +1 -1
- package/docs/tools/human-in-the-loop.md +1 -1
- package/docs/tools/overview.mdx +26 -2
- package/docs/tutorial/ship-it.mdx +1 -1
- package/package.json +1 -1
- package/dist/src/channel/cancel.d.ts +0 -6
- package/dist/src/channel/cancel.js +0 -1
- package/dist/src/channel/clear-session.d.ts +0 -4
- package/dist/src/channel/clear-session.js +0 -1
- package/dist/src/channel/compact-session.d.ts +0 -4
- package/dist/src/channel/compact-session.js +0 -1
- package/dist/src/channel/reset-session.d.ts +0 -6
- package/dist/src/channel/reset-session.js +0 -1
- package/dist/src/channel/resolve-active-session.d.ts +0 -4
- package/dist/src/channel/resolve-active-session.js +0 -1
- package/dist/src/channel/send.d.ts +0 -6
- package/dist/src/channel/send.js +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ChannelReference } from "#channel/compiled-channel.js";
|
|
2
2
|
import { type ChannelCorsOptions } from "#channel/cors.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type { RouteDefinition
|
|
3
|
+
import type { ChannelFrom, ChannelReceiveContext, ChannelResolveSession, ChannelRespondOptions, ChannelSendOptions, ChannelSource } from "#channel/channel-operations.js";
|
|
4
|
+
import type { RouteDefinition } from "#channel/routes.js";
|
|
5
5
|
import type { Session } from "#channel/session.js";
|
|
6
|
-
import type {
|
|
7
|
-
import type { UnstampedMessageStreamEvent, MessageStreamEvent } from "#protocol/message.js";
|
|
6
|
+
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
8
7
|
import type { SessionContext } from "#public/definitions/callback-context.js";
|
|
9
8
|
import type { GenericChannelDefinition, GenericReceiveInput } from "#shared/channel-definition.js";
|
|
10
9
|
declare const CHANNEL_METADATA_TYPE: unique symbol;
|
|
11
|
-
export type {
|
|
10
|
+
export type { CancelTurnResult, ClearSessionResult, CompactSessionResult, GetEventStreamOptions, ResetSessionResult, SessionCallback, } from "#channel/types.js";
|
|
12
11
|
export type { Session, SessionHandle } from "#channel/session.js";
|
|
12
|
+
export type { SessionRespondOptions, SessionSendOptions } from "#channel/session.js";
|
|
13
|
+
export type { ChannelFrom, ChannelReceiveContext, ChannelResolveSession, ChannelRespondOptions, ChannelSendOptions, ChannelSource, };
|
|
13
14
|
export type { ChannelCors, ChannelCorsOptions } from "#channel/cors.js";
|
|
14
15
|
export { GET, POST, PUT, PATCH, DELETE, WS } from "#channel/routes.js";
|
|
15
|
-
export type {
|
|
16
|
+
export type { AttachSessionFn, HttpRouteDefinition, RouteDefinition, RouteHandlerArgs, WebSocketMessage, WebSocketPeer, WebSocketRouteDefinition, WebSocketRouteHandler, WebSocketRouteHooks, WebSocketUpgradeRequest, WebSocketUpgradeResult, } from "#channel/routes.js";
|
|
16
17
|
/**
|
|
17
18
|
* HTTP method a route handles. Defaults to `"POST"` — almost every route
|
|
18
19
|
* is a webhook. Override only when authoring a non-webhook route such as a
|
|
@@ -31,27 +32,14 @@ export type ChannelRouteMethod = ChannelMethod | "WEBSOCKET";
|
|
|
31
32
|
* framework constructs this per request and passes it as the second
|
|
32
33
|
* argument.
|
|
33
34
|
*
|
|
34
|
-
*
|
|
35
|
-
* cancel turns, and read events.
|
|
35
|
+
* Framework callback routes use this for request metadata and background work.
|
|
36
36
|
*/
|
|
37
37
|
export interface RouteContext {
|
|
38
|
-
/**
|
|
39
|
-
* Handle to the agent that this route sends inbound requests to.
|
|
40
|
-
* Conceptually the runtime + harness combined: routes call `run`,
|
|
41
|
-
* `deliver`, `cancelTurn`, and `getEventStream` to drive sessions of
|
|
42
|
-
* this agent without knowing about the workflow runtime, the harness,
|
|
43
|
-
* or any other execution-layer detail.
|
|
44
|
-
*
|
|
45
|
-
* Every route speaks the same `RunInput` shape regardless of which
|
|
46
|
-
* webhook it serves — `agent` is platform-agnostic.
|
|
47
|
-
*/
|
|
48
|
-
readonly agent: Agent;
|
|
49
38
|
/**
|
|
50
39
|
* Hands a background promise to the request host so the serverless
|
|
51
40
|
* invocation stays alive until the promise resolves. Use this when the
|
|
52
41
|
* route responds to the platform immediately (e.g. a Slack `200 OK`
|
|
53
|
-
* acknowledgement) but still needs to
|
|
54
|
-
* completion.
|
|
42
|
+
* acknowledgement) but still needs to finish background work.
|
|
55
43
|
*/
|
|
56
44
|
readonly waitUntil: (task: Promise<unknown>) => void;
|
|
57
45
|
/**
|
|
@@ -72,56 +60,6 @@ export interface RouteContext {
|
|
|
72
60
|
*/
|
|
73
61
|
readonly requestIp: string | null;
|
|
74
62
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Route-facing handle to the agent that owns this request.
|
|
77
|
-
*
|
|
78
|
-
* `Agent` is conceptually the workflow runtime plus the tool-loop harness:
|
|
79
|
-
* routes call `run` to start a new session of the agent, `deliver` to
|
|
80
|
-
* send a follow-up to a parked session, `cancelTurn` to stop in-flight work,
|
|
81
|
-
* and `getEventStream` to read events from a previously-started session.
|
|
82
|
-
* The framework's internal `Runtime`
|
|
83
|
-
* interface (in `channel/types.ts`) is the underlying primitive — `Agent`
|
|
84
|
-
* is the *public* shape exposed on `RouteContext` so route authors
|
|
85
|
-
* speak in terms of the agent rather than the runtime.
|
|
86
|
-
*/
|
|
87
|
-
export interface Agent {
|
|
88
|
-
/**
|
|
89
|
-
* Starts a new agent session and returns a handle. The session's identity
|
|
90
|
-
* is the supplied `continuationToken` — subsequent calls to `deliver()`
|
|
91
|
-
* with the same token resume the same session.
|
|
92
|
-
*/
|
|
93
|
-
run(input: RunInput): Promise<RunHandle>;
|
|
94
|
-
/**
|
|
95
|
-
* Requests cancellation of a session's in-flight turn. A `turnId` limits
|
|
96
|
-
* the request to the turn the caller observed.
|
|
97
|
-
*
|
|
98
|
-
* `"accepted"` means a cancellation hook accepted the request; observe
|
|
99
|
-
* the event stream for `turn.cancelled` to confirm that it affected the
|
|
100
|
-
* current turn. `"no_active_turn"` means no cancellable hook was active.
|
|
101
|
-
* Both outcomes are successful.
|
|
102
|
-
*/
|
|
103
|
-
cancelTurn(input: CancelTurnInput): Promise<CancelTurnResult>;
|
|
104
|
-
/**
|
|
105
|
-
* Sends a follow-up message to a session that is currently parked waiting
|
|
106
|
-
* for input. Throws if no parked session exists for the supplied
|
|
107
|
-
* `continuationToken` — routes typically catch the failure and fall back
|
|
108
|
-
* to `run()` to start a new session.
|
|
109
|
-
*/
|
|
110
|
-
deliver(input: DeliverInput): Promise<{
|
|
111
|
-
sessionId: string;
|
|
112
|
-
}>;
|
|
113
|
-
/**
|
|
114
|
-
* Returns a readable NDJSON-style stream of lifecycle events for an
|
|
115
|
-
* existing session. Used by the framework's HTTP session-stream route and by
|
|
116
|
-
* any user-authored route that exposes an event-streaming endpoint.
|
|
117
|
-
*
|
|
118
|
-
* Nonnegative `options.startIndex` values skip events the caller has already
|
|
119
|
-
* consumed. Negative values read relative to the current tail (`-1` starts
|
|
120
|
-
* at the latest event). The framework HTTP session-stream route forwards
|
|
121
|
-
* the `startIndex` query parameter unchanged.
|
|
122
|
-
*/
|
|
123
|
-
getEventStream(sessionId: string, options?: GetEventStreamOptions): Promise<ReadableStream<MessageStreamEvent>>;
|
|
124
|
-
}
|
|
125
63
|
/**
|
|
126
64
|
* Marker discriminator written into every {@link DisabledRouteSentinel}.
|
|
127
65
|
*/
|
|
@@ -151,25 +89,25 @@ type EventData<T extends UnstampedMessageStreamEvent["type"]> = Extract<Unstampe
|
|
|
151
89
|
}> extends {
|
|
152
90
|
data: infer D;
|
|
153
91
|
} ? D : undefined;
|
|
154
|
-
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
92
|
+
/** Continuation routing on the `channel` argument of every channel event handler. */
|
|
93
|
+
export interface ChannelContinuationOps {
|
|
94
|
+
readonly continuation?: {
|
|
95
|
+
readonly token: string;
|
|
96
|
+
rekey(token: string): void;
|
|
97
|
+
};
|
|
160
98
|
}
|
|
161
99
|
/**
|
|
162
100
|
* Channel context passed to event handlers: `TCtx` intersected with
|
|
163
|
-
* {@link
|
|
101
|
+
* {@link ChannelContinuationOps}.
|
|
164
102
|
*/
|
|
165
|
-
export type ChannelContext<TCtx> = TCtx &
|
|
103
|
+
export type ChannelContext<TCtx> = TCtx & ChannelContinuationOps;
|
|
166
104
|
type ChannelEventHandler<T extends UnstampedMessageStreamEvent["type"], TCtx> = (data: EventData<T>, channel: ChannelContext<TCtx>, ctx: SessionContext) => void | Promise<void>;
|
|
167
105
|
type ChannelSessionFailedHandler<TCtx> = (data: EventData<"session.failed">, channel: ChannelContext<TCtx>) => void | Promise<void>;
|
|
168
106
|
/**
|
|
169
107
|
* Optional handlers keyed by session lifecycle event name. Each handler receives
|
|
170
108
|
* the event `data`, the {@link ChannelContext}, and a {@link SessionContext}
|
|
171
109
|
* `ctx`. The `session.failed` handler is the exception: it receives only `data`
|
|
172
|
-
* and the channel context, with no `ctx`.
|
|
110
|
+
* and the channel context, with no `ctx`; its data includes `sessionId`.
|
|
173
111
|
*/
|
|
174
112
|
export interface ChannelEvents<TCtx = void> {
|
|
175
113
|
readonly "context.cleared"?: ChannelEventHandler<"context.cleared", TCtx>;
|
|
@@ -177,6 +115,7 @@ export interface ChannelEvents<TCtx = void> {
|
|
|
177
115
|
readonly "compaction.completed"?: ChannelEventHandler<"compaction.completed", TCtx>;
|
|
178
116
|
readonly "turn.started"?: ChannelEventHandler<"turn.started", TCtx>;
|
|
179
117
|
readonly "actions.requested"?: ChannelEventHandler<"actions.requested", TCtx>;
|
|
118
|
+
readonly "action.partial"?: ChannelEventHandler<"action.partial", TCtx>;
|
|
180
119
|
readonly "action.result"?: ChannelEventHandler<"action.result", TCtx>;
|
|
181
120
|
readonly "message.completed"?: ChannelEventHandler<"message.completed", TCtx>;
|
|
182
121
|
readonly "message.appended"?: ChannelEventHandler<"message.appended", TCtx>;
|
|
@@ -216,14 +155,11 @@ export type ChannelDefinition<TState = undefined, TCtx = void, TReceiveTarget =
|
|
|
216
155
|
* {@link ChannelDefinition} it has no `TCtx` parameter: the context type is
|
|
217
156
|
* internal to the definition.
|
|
218
157
|
*/
|
|
219
|
-
export interface Channel<TState = undefined, TReceiveTarget = Record<string, unknown>, TMetadata extends Record<string, unknown> = Record<string, unknown>> extends
|
|
220
|
-
readonly __kind: typeof CHANNEL_SENTINEL;
|
|
158
|
+
export interface Channel<TState = undefined, TReceiveTarget = Record<string, unknown>, TMetadata extends Record<string, unknown> = Record<string, unknown>> extends ChannelReference<TReceiveTarget> {
|
|
221
159
|
readonly [CHANNEL_METADATA_TYPE]?: TMetadata;
|
|
222
160
|
readonly routes: readonly RouteDefinition<TState>[];
|
|
223
161
|
readonly cors?: ChannelCorsOptions;
|
|
224
|
-
readonly receive?: (input: ReceiveInput<TReceiveTarget>,
|
|
225
|
-
send: SendFn<TState>;
|
|
226
|
-
}) => Promise<Session>;
|
|
162
|
+
readonly receive?: (input: ReceiveInput<TReceiveTarget>, ctx: ChannelReceiveContext<TState>) => Promise<Session>;
|
|
227
163
|
}
|
|
228
164
|
/**
|
|
229
165
|
* Extracts the metadata projection type (`TMetadata`) from a {@link Channel}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CHANNEL_SENTINEL}from"#channel/compiled-channel.js";import{defaultDeliverResult}from"#channel/adapter.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{normalizeChannelCors}from"#channel/cors.js";import{HTTP_ADAPTER_KIND}from"#channel/http.js";import{DELETE,GET,PATCH,POST,PUT,WS}from"#channel/routes.js";const DISABLED_ROUTE_SENTINEL_KIND=`eve:disabled-channel`;function disableRoute(){return{kind:DISABLED_ROUTE_SENTINEL_KIND}}function isDisabledRouteSentinel(e){return typeof e==`object`&&!!e&&e.kind===DISABLED_ROUTE_SENTINEL_KIND}function defineChannel(t){let n=buildAdapter(t),i=normalizeChannelCors(t.cors);return{__kind:CHANNEL_SENTINEL,routes:t.routes,adapter:n,cors:i,receive:t.receive}}const eventTypes=Object.keys({"context.cleared":null,"compaction.requested":null,"compaction.completed":null,"turn.started":null,"actions.requested":null,"action.result":null,"message.completed":null,"message.appended":null,"reasoning.appended":null,"reasoning.completed":null,"input.requested":null,"turn.failed":null,"turn.completed":null,"turn.cancelled":null,"session.failed":null,"session.completed":null,"session.waiting":null,"authorization.required":null,"authorization.completed":null});function buildAdapter(e){let r=e.state!=null,a=e.context!=null,o=e.fetchFile!==void 0,s=e.metadata,c=r||a||s!==void 0,l={},u=!1,d=e.events;for(let e of eventTypes){let t=d?.[e];t&&(u=!0,l[e]=(r,i)=>{let
|
|
1
|
+
import{CHANNEL_SENTINEL}from"#channel/compiled-channel.js";import{defaultDeliverResult}from"#channel/adapter.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{normalizeChannelCors}from"#channel/cors.js";import{HTTP_ADAPTER_KIND}from"#channel/http.js";import{DELETE,GET,PATCH,POST,PUT,WS}from"#channel/routes.js";const DISABLED_ROUTE_SENTINEL_KIND=`eve:disabled-channel`;function disableRoute(){return{kind:DISABLED_ROUTE_SENTINEL_KIND}}function isDisabledRouteSentinel(e){return typeof e==`object`&&!!e&&e.kind===DISABLED_ROUTE_SENTINEL_KIND}function defineChannel(t){let n=buildAdapter(t),i=normalizeChannelCors(t.cors);return{__kind:CHANNEL_SENTINEL,routes:t.routes,adapter:n,cors:i,receive:t.receive}}const eventTypes=Object.keys({"context.cleared":null,"compaction.requested":null,"compaction.completed":null,"turn.started":null,"actions.requested":null,"action.partial":null,"action.result":null,"message.completed":null,"message.appended":null,"reasoning.appended":null,"reasoning.completed":null,"input.requested":null,"turn.failed":null,"turn.completed":null,"turn.cancelled":null,"session.failed":null,"session.completed":null,"session.waiting":null,"authorization.required":null,"authorization.completed":null});function buildAdapter(e){let r=e.state!=null,a=e.context!=null,o=e.fetchFile!==void 0,s=e.metadata,c=r||a||s!==void 0,l={},u=!1,d=e.events;for(let e of eventTypes){let t=d?.[e];t&&(u=!0,l[e]=(r,i)=>{let{session:a,...o}=i,s={...o,continuation:a?.continuation===void 0?void 0:{token:a.continuation.token,rekey:e=>a.continuation?.rekey(e)}};if(e===`session.failed`)return t(r,s);let c=buildCallbackContext();return t(r,s,c)})}return!c&&!u&&!o?{kind:e.kindHint??HTTP_ADAPTER_KIND}:{kind:e.kindHint??`defineChannel`,state:r?{...e.state}:{},fetchFile:e.fetchFile,instrumentation:s===void 0?void 0:{metadata(e){return s(e)}},createAdapterContext(t){let n=t.state,r=t.session;return{...a?e.context(n,r):{},state:n,ctx:t.ctx,session:r}},deliver(e){return defaultDeliverResult(e)},...l}}export{DELETE,GET,PATCH,POST,PUT,WS,defineChannel,disableRoute,isDisabledRouteSentinel};
|
|
@@ -12,6 +12,7 @@ type ProtocolEvent<TType extends MessageStreamEvent["type"]> = Extract<MessageSt
|
|
|
12
12
|
* until eve exposes them here.
|
|
13
13
|
*/
|
|
14
14
|
export interface HookEventMap {
|
|
15
|
+
readonly "action.partial": ProtocolEvent<"action.partial">;
|
|
15
16
|
readonly "action.result": ProtocolEvent<"action.result">;
|
|
16
17
|
readonly "actions.requested": ProtocolEvent<"actions.requested">;
|
|
17
18
|
readonly "authorization.completed": ProtocolEvent<"authorization.completed">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EVE_SESSION_ROUTE_PATH}from"#protocol/routes.js";function defineRemoteAgent(e){return{...e,kind:`remote`,path:e.path??EVE_SESSION_ROUTE_PATH}}export{defineRemoteAgent};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CrossChannelToFn } from "#channel/cross-channel-receive.js";
|
|
2
2
|
import type { SessionAuthContext } from "#channel/types.js";
|
|
3
3
|
import type { ExactDefinition } from "#public/definitions/exact.js";
|
|
4
4
|
import type { GenericScheduleDefinition, GenericScheduleRunHandler, GenericScheduleDefinitionFields } from "#shared/schedule-definition.js";
|
|
5
5
|
export type { InferReceiveTarget, TypedReceiveTarget } from "#channel/receive-target.js";
|
|
6
|
+
/** Selects a proactive target channel from a schedule handler. */
|
|
7
|
+
export type ScheduleToFn = CrossChannelToFn;
|
|
6
8
|
/**
|
|
7
9
|
* Arguments passed to a schedule's `run` handler. A tight subset of a route
|
|
8
|
-
* handler's args: `
|
|
9
|
-
* extends the task lifetime.
|
|
10
|
-
* current channel.
|
|
10
|
+
* handler's args: `to` selects another channel and `waitUntil`
|
|
11
|
+
* extends the task lifetime.
|
|
11
12
|
*/
|
|
12
13
|
export interface ScheduleHandlerArgs {
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* Selects a proactive target on another channel. Call `.send(message, options)`
|
|
16
|
+
* on the returned handle.
|
|
16
17
|
*/
|
|
17
|
-
readonly
|
|
18
|
+
readonly to: ScheduleToFn;
|
|
18
19
|
/**
|
|
19
20
|
* Extends the cron task's lifetime past handler return so the runtime awaits
|
|
20
21
|
* background work (the parked workflow session, in-flight fetches, etc.)
|
|
@@ -22,14 +23,14 @@ export interface ScheduleHandlerArgs {
|
|
|
22
23
|
*/
|
|
23
24
|
readonly waitUntil: (task: Promise<unknown>) => void;
|
|
24
25
|
/**
|
|
25
|
-
* Pre-built APP auth context. Pass this to `
|
|
26
|
+
* Pre-built APP auth context. Pass this to `to(channel, target).send(message, { auth })`
|
|
26
27
|
* for schedules that run on behalf of the agent itself.
|
|
27
28
|
*/
|
|
28
29
|
readonly appAuth: SessionAuthContext;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
32
|
* The `run` form of {@link ScheduleDefinition} invokes this handler when a
|
|
32
|
-
* schedule's cron fires. It receives {@link ScheduleHandlerArgs} (`
|
|
33
|
+
* schedule's cron fires. It receives {@link ScheduleHandlerArgs} (`to`,
|
|
33
34
|
* `waitUntil`, `appAuth`) and may return synchronously or as a promise.
|
|
34
35
|
*/
|
|
35
36
|
export type ScheduleRunHandler = GenericScheduleRunHandler<ScheduleHandlerArgs>;
|
|
@@ -41,7 +42,7 @@ export type ScheduleRunHandler = GenericScheduleRunHandler<ScheduleHandlerArgs>;
|
|
|
41
42
|
* on the prompt and discards the output (equivalent to the `<name>.md`
|
|
42
43
|
* markdown form).
|
|
43
44
|
* - `run`: full handler ({@link ScheduleRunHandler}). Receives
|
|
44
|
-
* `{
|
|
45
|
+
* `{ to, waitUntil, appAuth }` and decides what to do.
|
|
45
46
|
*
|
|
46
47
|
* Identity is derived from the file path under `agent/schedules/`; authored
|
|
47
48
|
* definitions do not carry a `name` field.
|
|
@@ -60,12 +61,11 @@ export type ScheduleDefinition = GenericScheduleDefinition<ScheduleHandlerArgs>;
|
|
|
60
61
|
*
|
|
61
62
|
* export default defineSchedule({
|
|
62
63
|
* cron: "0 9 * * 1-5",
|
|
63
|
-
* async run({
|
|
64
|
-
* waitUntil(
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* }));
|
|
64
|
+
* async run({ to, waitUntil, appAuth }) {
|
|
65
|
+
* waitUntil(to(slack, { channelId: "C0123ABC" }).send(
|
|
66
|
+
* "Post the daily standup summary.",
|
|
67
|
+
* { auth: appAuth },
|
|
68
|
+
* ));
|
|
69
69
|
* },
|
|
70
70
|
* });
|
|
71
71
|
* ```
|
|
@@ -88,7 +88,7 @@ export type ToolContext = SessionContext & {
|
|
|
88
88
|
* Authored definitions have no `name` field; identity is path-derived.
|
|
89
89
|
*/
|
|
90
90
|
export interface ToolDefinition<TInput = unknown, TOutput = unknown> extends PublicToolDefinition<TInput, TOutput> {
|
|
91
|
-
execute(input: TInput, ctx: ToolContext): Promise<TOutput> | TOutput
|
|
91
|
+
execute(input: TInput, ctx: ToolContext): Promise<TOutput> | TOutput | AsyncIterable<TOutput>;
|
|
92
92
|
/**
|
|
93
93
|
* Optional per-tool approval gate. The return value determines whether
|
|
94
94
|
* user approval is required before executing this tool.
|
|
@@ -122,7 +122,7 @@ export declare function defineTool<TInputSchema extends StandardJSONSchemaV1<unk
|
|
|
122
122
|
description: ToolDefinition<unknown, unknown>["description"];
|
|
123
123
|
inputSchema: TInputSchema;
|
|
124
124
|
outputSchema: TOutputSchema;
|
|
125
|
-
execute(input: StandardJSONSchemaV1.InferOutput<TInputSchema>, ctx: ToolContext): Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | StandardJSONSchemaV1.InferOutput<TOutputSchema
|
|
125
|
+
execute(input: StandardJSONSchemaV1.InferOutput<TInputSchema>, ctx: ToolContext): Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | StandardJSONSchemaV1.InferOutput<TOutputSchema> | AsyncIterable<StandardJSONSchemaV1.InferOutput<TOutputSchema>>;
|
|
126
126
|
approval?: ToolDefinition<StandardJSONSchemaV1.InferOutput<TInputSchema>, unknown>["approval"];
|
|
127
127
|
toModelOutput?: ToolDefinition<unknown, StandardJSONSchemaV1.InferOutput<TOutputSchema>>["toModelOutput"];
|
|
128
128
|
}): ToolDefinition<StandardJSONSchemaV1.InferOutput<TInputSchema>, StandardJSONSchemaV1.InferOutput<TOutputSchema>>;
|
|
@@ -130,7 +130,7 @@ export declare function defineTool<TSchema extends StandardJSONSchemaV1<unknown,
|
|
|
130
130
|
description: ToolDefinition<unknown, unknown>["description"];
|
|
131
131
|
inputSchema: TSchema;
|
|
132
132
|
outputSchema?: JsonObject;
|
|
133
|
-
execute(input: StandardJSONSchemaV1.InferOutput<TSchema>, ctx: ToolContext): Promise<TOutput> | TOutput
|
|
133
|
+
execute(input: StandardJSONSchemaV1.InferOutput<TSchema>, ctx: ToolContext): Promise<TOutput> | TOutput | AsyncIterable<TOutput>;
|
|
134
134
|
approval?: ToolDefinition<StandardJSONSchemaV1.InferOutput<TSchema>, unknown>["approval"];
|
|
135
135
|
toModelOutput?: ToolDefinition<unknown, TOutput>["toModelOutput"];
|
|
136
136
|
}): ToolDefinition<StandardJSONSchemaV1.InferOutput<TSchema>, TOutput>;
|
|
@@ -138,7 +138,7 @@ export declare function defineTool<TOutputSchema extends StandardJSONSchemaV1<un
|
|
|
138
138
|
description: ToolDefinition<unknown, unknown>["description"];
|
|
139
139
|
inputSchema: JsonObject;
|
|
140
140
|
outputSchema: TOutputSchema;
|
|
141
|
-
execute(input: Record<string, unknown>, ctx: ToolContext): Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | StandardJSONSchemaV1.InferOutput<TOutputSchema
|
|
141
|
+
execute(input: Record<string, unknown>, ctx: ToolContext): Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | StandardJSONSchemaV1.InferOutput<TOutputSchema> | AsyncIterable<StandardJSONSchemaV1.InferOutput<TOutputSchema>>;
|
|
142
142
|
approval?: ToolDefinition<Record<string, unknown>, unknown>["approval"];
|
|
143
143
|
toModelOutput?: ToolDefinition<unknown, StandardJSONSchemaV1.InferOutput<TOutputSchema>>["toModelOutput"];
|
|
144
144
|
}): ToolDefinition<Record<string, unknown>, StandardJSONSchemaV1.InferOutput<TOutputSchema>>;
|
|
@@ -146,7 +146,7 @@ export declare function defineTool<TOutput>(definition: {
|
|
|
146
146
|
description: ToolDefinition<unknown, unknown>["description"];
|
|
147
147
|
inputSchema: JsonObject;
|
|
148
148
|
outputSchema?: JsonObject;
|
|
149
|
-
execute(input: Record<string, unknown>, ctx: ToolContext): Promise<TOutput> | TOutput
|
|
149
|
+
execute(input: Record<string, unknown>, ctx: ToolContext): Promise<TOutput> | TOutput | AsyncIterable<TOutput>;
|
|
150
150
|
approval?: ToolDefinition<Record<string, unknown>, unknown>["approval"];
|
|
151
151
|
toModelOutput?: ToolDefinition<unknown, TOutput>["toModelOutput"];
|
|
152
152
|
}): ToolDefinition<Record<string, unknown>, TOutput>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Schedule authoring helpers for `agent/schedules/*` files.
|
|
3
3
|
*/
|
|
4
|
-
export { defineSchedule, type ScheduleDefinition, type ScheduleHandlerArgs, type ScheduleRunHandler, type TypedReceiveTarget, } from "#public/definitions/schedule.js";
|
|
4
|
+
export { defineSchedule, type ScheduleDefinition, type ScheduleHandlerArgs, type ScheduleRunHandler, type ScheduleToFn, type TypedReceiveTarget, } from "#public/definitions/schedule.js";
|
|
@@ -3,7 +3,8 @@ import type { EveAgentReducer } from "#client/reducer.js";
|
|
|
3
3
|
import type { ClientSession } from "#client/session.js";
|
|
4
4
|
import { type EveMessageData } from "#client/message-reducer.js";
|
|
5
5
|
import type { MessageStreamEvent } from "#protocol/message.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { UserContent } from "ai";
|
|
7
|
+
import type { ClientAuth, HeadersValue, RespondTurnOptions, SendTurnOptions, ClientSessionState } from "#client/types.js";
|
|
7
8
|
export type { PrepareSend };
|
|
8
9
|
/**
|
|
9
10
|
* Lifecycle status of an eve agent session.
|
|
@@ -26,8 +27,10 @@ export type UseEveAgentSnapshot<TData> = EveAgentStoreSnapshot<TData>;
|
|
|
26
27
|
export interface UseEveAgentHelpers<TData> extends UseEveAgentSnapshot<TData> {
|
|
27
28
|
/** Resets the session: aborts any in-flight turn, recreates the owned session, and clears events and projected data. */
|
|
28
29
|
readonly reset: () => void;
|
|
29
|
-
/** Sends a
|
|
30
|
-
readonly send: <TOutput = unknown>(
|
|
30
|
+
/** Sends a message. Rejects if a turn is already in flight. */
|
|
31
|
+
readonly send: <TOutput = unknown>(message: string | UserContent, options?: SendTurnOptions<TOutput>) => Promise<void>;
|
|
32
|
+
/** Answers pending HITL input requests. Rejects if a turn is already in flight. */
|
|
33
|
+
readonly respond: <TOutput = unknown>(inputResponses: Parameters<ClientSession["respond"]>[0], options?: RespondTurnOptions<TOutput>) => Promise<void>;
|
|
31
34
|
/** Aborts the in-flight turn's stream, if any. */
|
|
32
35
|
readonly stop: () => void;
|
|
33
36
|
}
|
|
@@ -63,7 +66,7 @@ export interface UseEveAgentOptions<TData> extends EveAgentStoreCallbacks<TData>
|
|
|
63
66
|
readonly host?: string;
|
|
64
67
|
/** Ordered prefix of the session stream used to rehydrate projected state. */
|
|
65
68
|
readonly initialEvents?: readonly MessageStreamEvent[];
|
|
66
|
-
readonly initialSession?:
|
|
69
|
+
readonly initialSession?: ClientSessionState;
|
|
67
70
|
/**
|
|
68
71
|
* Project submitted user messages before eve confirms them with a
|
|
69
72
|
* `message.received` stream event.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EveAgentStore}from"#client/eve-agent-store.js";import{defaultMessageReducer}from"#client/message-reducer.js";import{useCallback,useMemo,useRef,useSyncExternalStore}from"react";import{resolveEveAgentHost}from"#client/agent-host.js";function useEveAgent(
|
|
1
|
+
import{EveAgentStore}from"#client/eve-agent-store.js";import{defaultMessageReducer}from"#client/message-reducer.js";import{useCallback,useMemo,useRef,useSyncExternalStore}from"react";import{resolveEveAgentHost}from"#client/agent-host.js";function useEveAgent(r={}){let i=useRef(void 0);if(!i.current){let n=r.reducer??defaultMessageReducer();i.current=new EveAgentStore({auth:r.auth,headers:r.headers,host:resolveEveAgentHost({agent:r.agent,host:r.host}),initialEvents:r.initialEvents,initialSession:r.initialSession,optimistic:r.optimistic,reducer:n,session:r.session})}let a=i.current;a.setCallbacks({onError:r.onError,onEvent:r.onEvent,onFinish:r.onFinish,onSessionChange:r.onSessionChange,prepareSend:r.prepareSend});let o=useSyncExternalStore(useCallback(e=>a.subscribe(e),[a]),()=>a.snapshot,()=>a.snapshot),s=useCallback(()=>a.reset(),[a]),c=useCallback((e,t)=>a.send({...t,message:e}),[a]),l=useCallback((e,t)=>a.send({...t,inputResponses:e}),[a]),u=useCallback(()=>a.stop(),[a]);return useMemo(()=>({...o,reset:s,respond:l,send:c,stop:u}),[s,l,c,o,u])}export{useEveAgent};
|
|
@@ -28,8 +28,19 @@ export declare function estimateTokenCount(value: string): number;
|
|
|
28
28
|
export declare function getPromptContentText(content: BootstrapPrompt[number]["content"]): string;
|
|
29
29
|
/**
|
|
30
30
|
* Returns the text from the last user message in the prompt, or `null`.
|
|
31
|
+
*
|
|
32
|
+
* Skips framework-injected `[Agents]` announcements: they ride the user
|
|
33
|
+
* role in conversation history, but they are not authored input and must
|
|
34
|
+
* not drive mock directive parsing.
|
|
31
35
|
*/
|
|
32
36
|
export declare function getLastUserPromptText(prompt: BootstrapPrompt): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* True when the text is a framework-injected `[Agents]` announcement.
|
|
39
|
+
* Announcements are user-role scaffolding, not authored input: mock model
|
|
40
|
+
* heuristics must scan past them instead of treating them as the turn's
|
|
41
|
+
* message or as a turn boundary.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isAgentsAnnouncementText(text: string): boolean;
|
|
33
44
|
/**
|
|
34
45
|
* Joins all message content in the prompt into a single string.
|
|
35
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const BOOTSTRAP_RESPONSE_TIMESTAMP=new Date(`2026-03-16T00:00:00.000Z`);function createBootstrapGenerateResult(
|
|
1
|
+
import{AGENTS_SNIPPET_LABEL}from"#harness/handles/prompt.js";const BOOTSTRAP_RESPONSE_TIMESTAMP=new Date(`2026-03-16T00:00:00.000Z`);function createBootstrapGenerateResult(e){return{content:[{text:e.text,type:`text`}],finishReason:{raw:void 0,unified:`stop`},response:{id:`bootstrap-response`,modelId:e.modelId,timestamp:BOOTSTRAP_RESPONSE_TIMESTAMP},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:e.inputTokens,total:e.inputTokens},outputTokens:{reasoning:0,text:e.outputTokens,total:e.outputTokens}},warnings:[]}}function createBootstrapStreamResult(e){let t=[{type:`stream-start`,warnings:e.warnings}];e.response!==void 0&&t.push({...e.response,type:`response-metadata`});let n=0;for(let r of e.content)switch(r.type){case`text`:{let e=`text_${n}`;n+=1,t.push({id:e,type:`text-start`}),r.text.length>0&&t.push({delta:r.text,id:e,type:`text-delta`}),t.push({id:e,type:`text-end`});break}case`tool-call`:t.push(r);break;default:break}return t.push({finishReason:e.finishReason,type:`finish`,usage:e.usage}),{stream:new ReadableStream({start(e){for(let n of t)e.enqueue(n);e.close()}})}}function estimateTokenCount(e){return Math.max(1,Math.ceil(e.trim().length/4))}function getPromptContentText(e){return typeof e==`string`?e:e.flatMap(e=>{if(typeof e==`string`)return[e];switch(e.type){case`text`:return[e.text];default:return[]}}).join(``)}function getLastUserPromptText(e){for(let t of[...e].reverse()){if(t.role!==`user`)continue;let e=getPromptContentText(t.content).trim();if(!isAgentsAnnouncementText(e)&&e.length>0)return e}return null}function isAgentsAnnouncementText(t){return t.startsWith(AGENTS_SNIPPET_LABEL)}function getPromptText(e){return e.map(e=>getPromptContentText(e.content)).join(` `)}export{createBootstrapGenerateResult,createBootstrapStreamResult,estimateTokenCount,getLastUserPromptText,getPromptContentText,getPromptText,isAgentsAnnouncementText};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{MockLanguageModelV3}from"ai/test";import{FINAL_OUTPUT_TOOL_NAME}from"#runtime/framework-tools/final-output.js";import{BOOTSTRAP_RUNTIME_MODEL_ID,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT}from"#runtime/agent/bootstrap.js";import{createBootstrapGenerateResult,createBootstrapStreamResult,estimateTokenCount,getLastUserPromptText,getPromptContentText,getPromptText}from"#runtime/agent/bootstrap-model-utils.js";import{createMockAuthoredToolInput,formatToolOutput,resolveMockFixtureToken,resolveWeatherCity}from"#runtime/agent/mock-model-fixtures.js";import{findRelevantSkill,getActivatedSkillIds,getAvailableSkills}from"#runtime/agent/mock-model-skill-selection.js";import{createJsonSchemaSample}from"#runtime/agent/mock-structured-output.js";const authoredRuntimeModelMocks=new Map,bootstrapWeatherPayloadSchema=z.object({city:z.string(),condition:z.string(),summary:z.string(),temperatureF:z.number().finite()}).strict();function shouldMockAuthoredRuntimeModels(){return process.env.NODE_ENV===`test`||process.env.EVE_MOCK_AUTHORED_MODELS===`1`}function createMockAuthoredRuntimeModel(e){let t=authoredRuntimeModelMocks.get(e.id);if(t!==void 0)return t;let r=new MockLanguageModelV3({modelId:e.id,provider:`eve-runtime-mock`,doGenerate:async t=>createMockModelResult(t,e.id),doStream:async t=>createBootstrapStreamResult(createMockModelResult(t,e.id))});return authoredRuntimeModelMocks.set(e.id,r),r}function createMockModelResult(e,t){let n=getLastAuthoredToolResult(e.prompt);if(n!==null){let r=createFollowUpToolCallResult({modelId:t,options:e,result:n});if(r!==null)return r}else{let n=createParallelAuthoredToolCallsResult(e,t)??createSubagentDelegationResult(e,t)??createSkillLoadResult(e.prompt,t)??createAuthoredToolCallResult(e,t);if(n!==null)return n}let r=createFinalOutputResult(e,t);if(r!==null)return r;let i=n===null?createAssistantMessage(e.prompt):formatToolResultReply(n,e.prompt);return createBootstrapGenerateResult({inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i),text:i})}function createFinalOutputResult(e,t){let n=getAvailableTools(e).find(e=>e.name===FINAL_OUTPUT_TOOL_NAME);if(n===void 0)return null;let i=createJsonSchemaSample(n.inputSchema);return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(JSON.stringify(i)),toolCallId:createToolCallId(FINAL_OUTPUT_TOOL_NAME),toolName:FINAL_OUTPUT_TOOL_NAME})}function resolveMockAuthoredRuntimeModel(e){return!shouldMockAuthoredRuntimeModels()||e.id===BOOTSTRAP_RUNTIME_MODEL_ID?null:createMockAuthoredRuntimeModel(e)}function createSkillLoadResult(e,n){let r=getLastUserPromptText(e);if(r===null||getActivatedSkillIds(e).length>0)return null;let i=findRelevantSkill(getAvailableSkills(e),r);return i===null?null:createToolCallGenerateResult({input:{skill:i.name},inputTokens:estimateTokenCount(getPromptText(e)),modelId:n,outputTokens:estimateTokenCount(i.name),toolCallId:`call_load_skill`,toolName:LOAD_SKILL_TOOL_NAME})}const SUBAGENT_TOOL_NAME=`agent`,SUBAGENT_DELEGATION_DIRECTIVE=/\bdelegate\s+to\s+a\s+subagent\s*:\s*(.+)$/iu,PARALLEL_AUTHORED_TOOLS_DIRECTIVE=/^call tools in parallel:\s*(.+)$/imu;function createParallelAuthoredToolCallsResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=PARALLEL_AUTHORED_TOOLS_DIRECTIVE.exec(n)?.[1]?.split(`,`).map(e=>e.trim()).filter(Boolean);if(r===void 0||r.length<2||new Set(r).size!==r.length)return null;let i=new Map(getAvailableTools(e).map(e=>[e.name,e])),a=[];for(let e of r){let t=i.get(e);if(t===void 0)return null;a.push(t)}let o=resolveWeatherCity(n);return createToolCallsGenerateResult({calls:a.map(e=>({input:createMockAuthoredToolInput(e,n,o),toolCallId:createToolCallId(e.name),toolName:e.name})),inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(n)})}function createSubagentDelegationResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=SUBAGENT_DELEGATION_DIRECTIVE.exec(n);if(r?.[1]===void 0||getAvailableTools(e).find(e=>e.name===SUBAGENT_TOOL_NAME)===void 0)return null;let i={message:r[1].trim()};return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i.message),toolCallId:createToolCallId(SUBAGENT_TOOL_NAME),toolName:SUBAGENT_TOOL_NAME})}function createAuthoredToolCallResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=findRelevantTool(getAvailableTools(e),n);if(r===null)return null;let i=createMockAuthoredToolInput(r,n,resolveWeatherCity(n));return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(Object.values(i).join(` `)),toolCallId:createToolCallId(r.name),toolName:r.name})}function createFollowUpToolCallResult(e){let t=findNextExplicitToolAfterResult({previousToolName:e.result.toolName,prompt:e.options.prompt,tools:getAvailableTools(e.options)});if(t===null)return null;let n=createFollowUpToolInput(e.result.output);return n===null?null:createToolCallGenerateResult({input:n,inputTokens:estimateTokenCount(getPromptText(e.options.prompt)),modelId:e.modelId,outputTokens:estimateTokenCount(Object.values(n).join(` `)),toolCallId:createToolCallId(t.name),toolName:t.name})}function createAssistantMessage(e){let t=getLastUserPromptText(e)??`Hello from eve`,n=getSystemPromptLabels(e),r=resolveSystemProbe(e),i=resolveMockFixtureToken(e);return i===null?n.length>0?r===null?`Bootstrap reply [${n.join(`, `)}]: ${t}`:`Bootstrap reply [${n.join(`, `)}; probe=${r}]: ${t}`:r===null?`Bootstrap reply: ${t}`:`Bootstrap reply [probe=${r}]: ${t}`:i}function formatToolResultReply(e,t){if(e.isError)return`Local weather tool failed: ${formatToolOutput(e.output)}`;if(isWeatherPayload(e.output))return`Used local weather tool for ${e.output.city}: ${e.output.condition}, ${e.output.temperatureF}F. ${e.output.summary}`;let n=getLastUserPromptText(t)??`Hello from eve`;return`Used ${e.toolName} for "${n}": ${formatToolOutput(e.output)}`}function createToolCallGenerateResult(e){return createToolCallsGenerateResult({calls:[{input:e.input,toolCallId:e.toolCallId,toolName:e.toolName}],inputTokens:e.inputTokens,modelId:e.modelId,outputTokens:e.outputTokens})}function createToolCallsGenerateResult(e){return{content:e.calls.map(e=>({input:JSON.stringify(e.input),toolCallId:e.toolCallId,toolName:e.toolName,type:`tool-call`})),finishReason:{raw:void 0,unified:`tool-calls`},response:{id:`bootstrap-response`,modelId:e.modelId,timestamp:new Date(`2026-03-16T00:00:00.000Z`)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:e.inputTokens,total:e.inputTokens},outputTokens:{reasoning:0,text:e.outputTokens,total:e.outputTokens}},warnings:[]}}function getAvailableTools(e){return(e.tools??[]).flatMap(e=>e.type===`function`?[{description:e.description,inputSchema:`inputSchema`in e?e.inputSchema:void 0,name:e.name,outputSchema:`outputSchema`in e?e.outputSchema:void 0}]:[])}function getLastAuthoredToolResult(e){for(let n of[...e].reverse()){if(n.role===`user`)return null
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{MockLanguageModelV3}from"ai/test";import{FINAL_OUTPUT_TOOL_NAME}from"#runtime/framework-tools/final-output.js";import{BOOTSTRAP_RUNTIME_MODEL_ID,BOOTSTRAP_RUNTIME_SYSTEM_PROMPT}from"#runtime/agent/bootstrap.js";import{createBootstrapGenerateResult,createBootstrapStreamResult,estimateTokenCount,getLastUserPromptText,getPromptContentText,getPromptText,isAgentsAnnouncementText}from"#runtime/agent/bootstrap-model-utils.js";import{createMockAuthoredToolInput,formatToolOutput,resolveMockFixtureToken,resolveWeatherCity}from"#runtime/agent/mock-model-fixtures.js";import{findRelevantSkill,getActivatedSkillIds,getAvailableSkills}from"#runtime/agent/mock-model-skill-selection.js";import{createJsonSchemaSample}from"#runtime/agent/mock-structured-output.js";const authoredRuntimeModelMocks=new Map,bootstrapWeatherPayloadSchema=z.object({city:z.string(),condition:z.string(),summary:z.string(),temperatureF:z.number().finite()}).strict();function shouldMockAuthoredRuntimeModels(){return process.env.NODE_ENV===`test`||process.env.EVE_MOCK_AUTHORED_MODELS===`1`}function createMockAuthoredRuntimeModel(e){let t=authoredRuntimeModelMocks.get(e.id);if(t!==void 0)return t;let r=new MockLanguageModelV3({modelId:e.id,provider:`eve-runtime-mock`,doGenerate:async t=>createMockModelResult(t,e.id),doStream:async t=>createBootstrapStreamResult(createMockModelResult(t,e.id))});return authoredRuntimeModelMocks.set(e.id,r),r}function createMockModelResult(e,t){let n=getLastAuthoredToolResult(e.prompt);if(n!==null){let r=createFollowUpToolCallResult({modelId:t,options:e,result:n});if(r!==null)return r}else{let n=createParallelAuthoredToolCallsResult(e,t)??createSubagentDelegationResult(e,t)??createSkillLoadResult(e.prompt,t)??createAuthoredToolCallResult(e,t);if(n!==null)return n}let r=createFinalOutputResult(e,t);if(r!==null)return r;let i=n===null?createAssistantMessage(e.prompt):formatToolResultReply(n,e.prompt);return createBootstrapGenerateResult({inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i),text:i})}function createFinalOutputResult(e,t){let n=getAvailableTools(e).find(e=>e.name===FINAL_OUTPUT_TOOL_NAME);if(n===void 0)return null;let i=createJsonSchemaSample(n.inputSchema);return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(JSON.stringify(i)),toolCallId:createToolCallId(FINAL_OUTPUT_TOOL_NAME),toolName:FINAL_OUTPUT_TOOL_NAME})}function resolveMockAuthoredRuntimeModel(e){return!shouldMockAuthoredRuntimeModels()||e.id===BOOTSTRAP_RUNTIME_MODEL_ID?null:createMockAuthoredRuntimeModel(e)}function createSkillLoadResult(e,n){let r=getLastUserPromptText(e);if(r===null||getActivatedSkillIds(e).length>0)return null;let i=findRelevantSkill(getAvailableSkills(e),r);return i===null?null:createToolCallGenerateResult({input:{skill:i.name},inputTokens:estimateTokenCount(getPromptText(e)),modelId:n,outputTokens:estimateTokenCount(i.name),toolCallId:`call_load_skill`,toolName:LOAD_SKILL_TOOL_NAME})}const SUBAGENT_TOOL_NAME=`agent`,SUBAGENT_DELEGATION_DIRECTIVE=/\bdelegate\s+to\s+a\s+subagent\s*:\s*(.+)$/iu,PARALLEL_AUTHORED_TOOLS_DIRECTIVE=/^call tools in parallel:\s*(.+)$/imu;function createParallelAuthoredToolCallsResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=PARALLEL_AUTHORED_TOOLS_DIRECTIVE.exec(n)?.[1]?.split(`,`).map(e=>e.trim()).filter(Boolean);if(r===void 0||r.length<2||new Set(r).size!==r.length)return null;let i=new Map(getAvailableTools(e).map(e=>[e.name,e])),a=[];for(let e of r){let t=i.get(e);if(t===void 0)return null;a.push(t)}let o=resolveWeatherCity(n);return createToolCallsGenerateResult({calls:a.map(e=>({input:createMockAuthoredToolInput(e,n,o),toolCallId:createToolCallId(e.name),toolName:e.name})),inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(n)})}function createSubagentDelegationResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=SUBAGENT_DELEGATION_DIRECTIVE.exec(n);if(r?.[1]===void 0||getAvailableTools(e).find(e=>e.name===SUBAGENT_TOOL_NAME)===void 0)return null;let i={message:r[1].trim()};return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(i.message),toolCallId:createToolCallId(SUBAGENT_TOOL_NAME),toolName:SUBAGENT_TOOL_NAME})}function createAuthoredToolCallResult(e,t){let n=getLastUserPromptText(e.prompt);if(n===null)return null;let r=findRelevantTool(getAvailableTools(e),n);if(r===null)return null;let i=createMockAuthoredToolInput(r,n,resolveWeatherCity(n));return createToolCallGenerateResult({input:i,inputTokens:estimateTokenCount(getPromptText(e.prompt)),modelId:t,outputTokens:estimateTokenCount(Object.values(i).join(` `)),toolCallId:createToolCallId(r.name),toolName:r.name})}function createFollowUpToolCallResult(e){let t=findNextExplicitToolAfterResult({previousToolName:e.result.toolName,prompt:e.options.prompt,tools:getAvailableTools(e.options)});if(t===null)return null;let n=createFollowUpToolInput(e.result.output);return n===null?null:createToolCallGenerateResult({input:n,inputTokens:estimateTokenCount(getPromptText(e.options.prompt)),modelId:e.modelId,outputTokens:estimateTokenCount(Object.values(n).join(` `)),toolCallId:createToolCallId(t.name),toolName:t.name})}function createAssistantMessage(e){let t=getLastUserPromptText(e)??`Hello from eve`,n=getSystemPromptLabels(e),r=resolveSystemProbe(e),i=resolveMockFixtureToken(e);return i===null?n.length>0?r===null?`Bootstrap reply [${n.join(`, `)}]: ${t}`:`Bootstrap reply [${n.join(`, `)}; probe=${r}]: ${t}`:r===null?`Bootstrap reply: ${t}`:`Bootstrap reply [probe=${r}]: ${t}`:i}function formatToolResultReply(e,t){if(e.isError)return`Local weather tool failed: ${formatToolOutput(e.output)}`;if(isWeatherPayload(e.output))return`Used local weather tool for ${e.output.city}: ${e.output.condition}, ${e.output.temperatureF}F. ${e.output.summary}`;let n=getLastUserPromptText(t)??`Hello from eve`;return`Used ${e.toolName} for "${n}": ${formatToolOutput(e.output)}`}function createToolCallGenerateResult(e){return createToolCallsGenerateResult({calls:[{input:e.input,toolCallId:e.toolCallId,toolName:e.toolName}],inputTokens:e.inputTokens,modelId:e.modelId,outputTokens:e.outputTokens})}function createToolCallsGenerateResult(e){return{content:e.calls.map(e=>({input:JSON.stringify(e.input),toolCallId:e.toolCallId,toolName:e.toolName,type:`tool-call`})),finishReason:{raw:void 0,unified:`tool-calls`},response:{id:`bootstrap-response`,modelId:e.modelId,timestamp:new Date(`2026-03-16T00:00:00.000Z`)},usage:{inputTokens:{cacheRead:0,cacheWrite:0,noCache:e.inputTokens,total:e.inputTokens},outputTokens:{reasoning:0,text:e.outputTokens,total:e.outputTokens}},warnings:[]}}function getAvailableTools(e){return(e.tools??[]).flatMap(e=>e.type===`function`?[{description:e.description,inputSchema:`inputSchema`in e?e.inputSchema:void 0,name:e.name,outputSchema:`outputSchema`in e?e.outputSchema:void 0}]:[])}function getLastAuthoredToolResult(e){for(let n of[...e].reverse()){if(n.role===`user`){if(isAgentsAnnouncementText(getPromptContentText(n.content).trim()))continue;return null}if(!(n.role!==`tool`&&n.role!==`assistant`)){for(let e of[...n.content].reverse())if(!(typeof e==`string`||e.type!==`tool-result`)&&e.toolName!==LOAD_SKILL_TOOL_NAME)return{isError:e.output.type===`error-json`||e.output.type===`error-text`||e.output.type===`execution-denied`,output:e.output.type===`execution-denied`?{reason:e.output.reason??null,type:e.output.type}:e.output.value,toolCallId:e.toolCallId,toolName:e.toolName}}}return null}function findNextExplicitToolAfterResult(e){let t=getLastUserPromptText(e.prompt);if(t===null)return null;let n=normalizeText(t),r=n.indexOf(normalizeText(e.previousToolName));return r<0?null:e.tools.filter(t=>t.name!==e.previousToolName).flatMap(e=>{let t=n.indexOf(normalizeText(e.name),r+1);return t<0?[]:[{index:t,tool:e}]}).sort((e,t)=>e.index-t.index)[0]?.tool??null}function createFollowUpToolInput(e){return isRecord(e)&&typeof e.stepKey==`string`?{stepKey:e.stepKey}:null}function getSystemPromptLabels(e){let t=e.filter(e=>e.role===`system`);if(t.length===0)return[];let n=t.flatMap(e=>{let t=getPromptContentText(e.content);if(t.startsWith(`Available skills
|
|
2
2
|
`))return[];let n=t.split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(e=>e.length>0),r=[];for(let e of n){if(e===BOOTSTRAP_RUNTIME_SYSTEM_PROMPT||e===`Available skills`)continue;let t=/^System \((.+)\)$/.exec(e);if(t?.[1]){r.push(t[1]);continue}let n=/^Skill \((.+)\)$/.exec(e);n?.[1]&&r.push(n[1])}if(r.length>0)return r;let i=n.find(e=>e!==BOOTSTRAP_RUNTIME_SYSTEM_PROMPT&&e!==`Available skills`);return i===void 0?[]:[i]});return[...new Set(n)]}function findRelevantTool(e,n){let r=normalizeText(n),i=e.find(e=>e.name!==`agent`&&e.name!==LOAD_SKILL_TOOL_NAME&&r.includes(normalizeText(e.name)));return i===void 0?/\b(forecast|temperature|weather|wind|rain|snow)\b/u.test(r)?e.find(e=>/\b(forecast|temperature|weather|wind|rain|snow)\b/u.test(normalizeText(`${e.name} ${e.description??``}`)))??null:null:i}function normalizeText(e){return e.toLowerCase().replace(/[^a-z0-9]+/gu,` `).trim()}function createToolCallId(e){return`call_${e.toLowerCase().replace(/[^a-z0-9]+/gu,`_`).replace(/^_+|_+$/gu,``)||`tool`}`}function resolveSystemProbe(e){let t=e.filter(e=>e.role===`system`).map(e=>getPromptContentText(e.content)).join(`
|
|
4
4
|
`);return/hmr-probe:\s*([^\n]+)/iu.exec(t)?.[1]?.trim()||null}function isWeatherPayload(e){return bootstrapWeatherPayloadSchema.safeParse(e).success}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{createMockAuthoredRuntimeModel,resolveMockAuthoredRuntimeModel,shouldMockAuthoredRuntimeModels};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{getPromptContentText}from"#runtime/agent/bootstrap-model-utils.js";import{createJsonSchemaSample}from"#runtime/agent/mock-structured-output.js";function createMockAuthoredToolInput(e,t,
|
|
2
|
-
`),r=[...getLoadedSkillResultTexts(e),n,getTrailingUserText(e)];for(let e of r){let t=resolveExactFixtureReply(e);if(t!==null)return t}return null}function resolveWeatherCity(e){let t=/"city"\s*:\s*"([^"]+)"/u.exec(e);return t?.[1]?t[1].trim():(/\b(?:in|for)\s+([A-Za-z][A-Za-z\s.-]*?)(?:[?.!,]|$)/u.exec(e)??/\b([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)\b/u.exec(e))?.[1]?.trim()||`Brooklyn`}function formatToolOutput(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function getTrailingUserText(e){let
|
|
1
|
+
import{LOAD_SKILL_TOOL_NAME}from"#runtime/skills/fragment-context.js";import{getPromptContentText,isAgentsAnnouncementText}from"#runtime/agent/bootstrap-model-utils.js";import{createJsonSchemaSample}from"#runtime/agent/mock-structured-output.js";function createMockAuthoredToolInput(e,t,n){let i=getToolInputPropertyNames(e.inputSchema);if(e.name===`ask_question`||hasProperties(i,[`prompt`,`options`]))return createAskQuestionInput(t);if(i.includes(`command`))return{command:resolveShellCommand(t)};if(i.includes(`topic`)||!hasDeclaredInputProperties(e.inputSchema)&&/\btopic\b/u.test(normalizeText(t)))return{topic:resolveLookupTopic(t)};let a=extractAnchoredInputs(i,t);if(Object.keys(a).length>0)return a;if(i.length===1&&i[0]===`message`)return{message:t};if(i.includes(`city`)||!hasDeclaredInputProperties(e.inputSchema))return{city:n};let o=createJsonSchemaSample(e.inputSchema);return isRecord(o)?o:{}}function extractAnchoredInputs(e,t){let n={};for(let r of e){let e=RegExp(`\\b${escapeRegExp(r)}\\b\\s*(?:to|=|:)?\\s*(?:\`([^\`]+)\`|"([^"]+)"|'([^']+)')`,`iu`).exec(t),i=e?.[1]??e?.[2]??e?.[3];i!==void 0&&(n[r]=i.trim())}return n}function escapeRegExp(e){return e.replace(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`)}function resolveMockFixtureToken(e){let n=e.filter(e=>e.role===`system`).map(e=>getPromptContentText(e.content)).join(`
|
|
2
|
+
`),r=[...getLoadedSkillResultTexts(e),n,getTrailingUserText(e)];for(let e of r){let t=resolveExactFixtureReply(e);if(t!==null)return t}return null}function resolveWeatherCity(e){let t=/"city"\s*:\s*"([^"]+)"/u.exec(e);return t?.[1]?t[1].trim():(/\b(?:in|for)\s+([A-Za-z][A-Za-z\s.-]*?)(?:[?.!,]|$)/u.exec(e)??/\b([A-Z][a-z]+(?:\s+[A-Z][a-z]+)*)\b/u.exec(e))?.[1]?.trim()||`Brooklyn`}function formatToolOutput(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function getTrailingUserText(e){let r=[];for(let i of[...e].reverse()){if(i.role===`system`)continue;if(i.role!==`user`)break;let e=getPromptContentText(i.content);isAgentsAnnouncementText(e.trim())||r.unshift(e)}return r.join(`
|
|
3
3
|
`)}function getLoadedSkillResultTexts(t){return t.flatMap(t=>t.role!==`tool`&&t.role!==`assistant`?[]:(typeof t.content==`string`?[t.content]:t.content).flatMap(t=>typeof t==`string`||t.type!==`tool-result`||t.toolName!==LOAD_SKILL_TOOL_NAME||t.output.type===`execution-denied`?[]:[formatToolOutput(t.output.value)]))}function resolveExactFixtureReply(e){let t=matchExactValue(/\breply\s+with\s+the\s+exact\s+string\s+(`([^`]+)`|"([^"]+)"|'([^']+)'|([^\s.]+))\s+and\s+nothing\s+else\b/iu,e);if(t!==null)return t;let n=e.split(/\r?\n/u);for(let e=0;e<n.length;e+=1){let t=n[e]?.trim()??``,r=/\breply\s+with\s+exactly(?:\s+the\s+following\s+text\s+and\s+nothing\s+else)?:\s*(.+)$/iu.exec(t);if(r?.[1])return cleanExactValue(r[1]);if(/\breply\s+with\s+exactly\s+the\s+following\s+text\s+and\s+nothing\s+else:\s*$/iu.test(t)||/\breply\s+with\s+exactly:\s*$/iu.test(t)){let t=n.slice(e+1).map(e=>e.trim()).find(e=>e.length>0);if(t!==void 0)return cleanExactValue(t)}}return matchExactValue(/\binclude\s+the\s+exact\s+token\s+(`([^`]+)`|"([^"]+)"|'([^']+)'|([^\s.]+))\s+verbatim\b/iu,e)}function matchExactValue(e,t){let n=e.exec(t);return n===null?null:cleanExactValue(n[2]??n[3]??n[4]??n[5]??n[1]??``)}function cleanExactValue(e){return e.trim()}function getToolInputPropertyNames(e){return!isRecord(e)||!isRecord(e.properties)?[]:Object.keys(e.properties)}function hasDeclaredInputProperties(e){return isRecord(e)&&isRecord(e.properties)}function hasProperties(e,t){return t.every(t=>e.includes(t))}function createAskQuestionInput(e){let t=parseInputOptions(e),n={prompt:resolveQuestionPrompt(e)};return t.length>0&&(n.options=t),/\ballow\s*freeform\s+(?:to\s+)?true\b|\ballowfreeform\s+(?:to\s+)?true\b/iu.test(e)&&(n.allowFreeform=!0),n}function parseInputOptions(e){return[...e.matchAll(/\bid\b\s*:?\s*"([^"]+)"\s*,\s*label\b\s*:?\s*"([^"]+)"/giu)].map(e=>({id:e[1]??``,label:e[2]??``}))}function resolveQuestionPrompt(e){let t=/\b(?:set\s+)?prompt\s+to:\s*'([^']+)'/iu.exec(e)??/\b(?:set\s+)?prompt\s+to:\s*"([^"]+)"/iu.exec(e);return t?.[1]?t[1].trim():/\bask(?:\s+me)?\s+(?:to\s+)?(.+?)(?:\.|$)/iu.exec(e)?.[1]?.trim()||`Please choose an option.`}function resolveShellCommand(e){let t=/`([^`]+)`/u.exec(e);return t?.[1]?t[1].trim():(/\b(?:run|command)\s+["']([^"']+)["']/iu.exec(e)??/\bcommand\s+(.+?)(?:\.|$)/iu.exec(e))?.[1]?.trim()||`pwd`}function resolveLookupTopic(e){return/\btopic\s+['"]?([A-Za-z0-9_.-]+)['"]?/u.exec(e)?.[1]??`demo`}function normalizeText(e){return e.toLowerCase().replace(/[^a-z0-9]+/gu,` `).trim()}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{createMockAuthoredToolInput,formatToolOutput,resolveMockFixtureToken,resolveWeatherCity};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{formatAvailableSkillsSection}from"#execution/skills/instructions.js";import{createWorkspacePromptSection}from"#runtime/workspace/spec.js";import{formatConnectionsSection}from"#runtime/prompt/connections.js";function composeRuntimeBasePrompt(e){return[...createInstructionsPromptBlocks(e.instructions),...createWorkspacePromptBlocks(e.workspaceSpec),...e.toolsAvailable?[`Tool execution
|
|
2
|
-
A single tool or subagent call runs as one serial action. If you call multiple independent tools or subagents in one response, eve treats that batch as parallel work. Only batch work that is independent and does not rely on another call in the same response.`]:[],...e.subagentsAvailable&&e.persistentSubagentSessions?["Agent messaging\nAgents you have already delegated to stay available after they answer.
|
|
2
|
+
A single tool or subagent call runs as one serial action. If you call multiple independent tools or subagents in one response, eve treats that batch as parallel work. Only batch work that is independent and does not rely on another call in the same response.`]:[],...e.subagentsAvailable&&e.persistentSubagentSessions?["Agent messaging\nAgents you have already delegated to stay available after they answer. eve injects the current `<agents>` list into the conversation as a note labeled `[Agents]`; it is added automatically by the framework, not written by the user, and never requires a reply. The list is only a record of those existing agents — their `agentId`, name, and latest status. It does not limit which subagent tools you can call: your tool list is the source of truth, and any subagent tool can always be called without `agentId` to start a new agent, including when the `<agents>` list is empty or absent. Pass `agentId` to the same subagent tool only to continue one of those existing agents' sessions."]:[],...createConnectionsPromptBlocks(e.connections),...createSkillsPromptBlocks(e.skills)]}function createInstructionsPromptBlocks(e){if(e===void 0)return[];let t=e.markdown.trim();return t.length===0?[]:[`Instructions (${e.name})\n${t}`]}function createWorkspacePromptBlocks(e){if(e===void 0)return[];let n=createWorkspacePromptSection(e);return n===void 0?[]:[n]}function createConnectionsPromptBlocks(e){return!e||e.length===0?[]:[formatConnectionsSection(e)]}function createSkillsPromptBlocks(t){if(!t||t.length===0)return[];let n=formatAvailableSkillsSection(t);return n===null?[]:[n]}export{composeRuntimeBasePrompt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectString,getOptionalStringRecordProperty}from"#internal/authored-module.js";import{
|
|
1
|
+
import{expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectString,getOptionalStringRecordProperty}from"#internal/authored-module.js";import{EVE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{serializeOutputSchema}from"#shared/tool-schema.js";async function normalizeDynamicRemoteAgentConfig(t){let i=`Dynamic subagent "${t.name}" must return defineAgent(...), defineRemoteAgent(...), or null.`,a=expectObjectRecord(t.value,i);if(expectOnlyKnownKeys(a,[`auth`,`description`,`forwardPrincipal`,`headers`,`kind`,`outputSchema`,`path`,`url`],i),a.kind!==`remote`)throw Error(i);let o=await resolveUrl(a.url,i),s=readCredentialsStepId(a);if(validateCredentials(a,i),(a.auth!==void 0||a.headers!==void 0)&&s===void 0)throw Error(`${i} Dynamic remote auth and headers must be compiled by eve so credentials stay out of durable workflow state.`);let c={description:expectString(a.description,i),path:a.path===void 0?EVE_SESSION_ROUTE_PATH:expectString(a.path,i),url:o};return s!==void 0&&(c.credentialsStepId=s),a.forwardPrincipal!==void 0&&(c.forwardPrincipal=expectBoolean(a.forwardPrincipal,i)),a.outputSchema!==void 0&&(c.outputSchema=serializeOutputSchema(a.outputSchema)),c}async function resolveUrl(e,n){let r=typeof e==`function`?await expectFunction(e,n)():expectString(e,n);if(r.length===0)throw Error(`${n} The "url" field must resolve to a non-empty string.`);return r}function validateCredentials(e,n){e.auth!==void 0&&expectFunction(e.auth,n),e.headers!==void 0&&typeof e.headers!=`function`&&getOptionalStringRecordProperty(e,`headers`,n)}function readCredentialsStepId(e){let t=e.__eveResolveRemoteAgentCredentials;if(typeof t!=`function`)return;let n=t.stepId;return typeof n==`string`?n:void 0}export{normalizeDynamicRemoteAgentConfig};
|
|
@@ -199,7 +199,7 @@ export interface ResolvedChannelDefinition extends ResolvedModuleSourceRef {
|
|
|
199
199
|
/**
|
|
200
200
|
* Universal entry point for new sessions, called by cross-channel
|
|
201
201
|
* initiators (the schedule dispatcher today). Typed precisely as
|
|
202
|
-
* {@link CompiledChannel.receive} — `(input,
|
|
202
|
+
* {@link CompiledChannel.receive} — `(input, ctx) => Session` —
|
|
203
203
|
* so any caller passing the wrong context shape is a typecheck error,
|
|
204
204
|
* not a runtime crash.
|
|
205
205
|
*
|
|
@@ -211,7 +211,7 @@ export interface ResolvedChannelDefinition extends ResolvedModuleSourceRef {
|
|
|
211
211
|
readonly receive?: CompiledChannel["receive"];
|
|
212
212
|
/**
|
|
213
213
|
* Reference to the authored {@link CompiledChannel} value the channel
|
|
214
|
-
* module exported. Preserved so callers of `
|
|
214
|
+
* module exported. Preserved so callers of `ctx.to(channel, target)`
|
|
215
215
|
* can identify a target by the same imported reference. `undefined`
|
|
216
216
|
* for framework-internal channels constructed without going through
|
|
217
217
|
* `defineChannel`.
|
|
@@ -5,7 +5,7 @@ import { type ApplicationInfo } from "#internal/application/paths.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export interface ApplicationInspectionMessaging {
|
|
7
7
|
readonly createSessionRoutePath: string;
|
|
8
|
-
readonly
|
|
8
|
+
readonly sessionMessagesRoutePattern: string;
|
|
9
9
|
readonly streamRoutePattern: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EVE_SESSION_ROUTE_PATH,EVE_SESSION_ROUTE_PATTERN,EVE_SESSION_STREAM_ROUTE_PATTERN}from"#protocol/routes.js";import{getApplicationInfo}from"#internal/application/paths.js";import{DiscoveryProjectResolutionError}from"#discover/project.js";import{CompileAgentError,compileAgent}from"#compiler/compile-agent.js";async function inspectApplication(t){let n=await loadCompiledApplicationState(t);return{application:getApplicationInfo(n?.project.appRoot??t),compiledState:n,messaging:{createSessionRoutePath:EVE_SESSION_ROUTE_PATH,sessionMessagesRoutePattern:EVE_SESSION_ROUTE_PATTERN,streamRoutePattern:EVE_SESSION_STREAM_ROUTE_PATTERN}}}async function loadCompiledApplicationState(e){try{return await compileAgent({startPath:e})}catch(e){if(e instanceof CompileAgentError)return e.result;if(e instanceof DiscoveryProjectResolutionError)return null;throw e}}export{inspectApplication};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EVE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{join}from"node:path";import{compileChannelDefinition}from"#compiler/normalize-channel.js";import{discoverAgent}from"#discover/discover-agent.js";import{isNextJsProject}from"#setup/scaffold/index.js";const SCAFFOLDED_WEB_CHANNEL_LOGICAL_PATH=`channels/eve.ts`;async function inspectExistingChannelRegistrations(a){let o=join(a,`agent`),[{manifest:s},c]=await Promise.all([discoverAgent({agentRoot:o,appRoot:a}),isNextJsProject(a)]),l=new Set,u=new Set;for(let t of s.channels){let r=await compileChannelDefinition(o,t),i=Array.isArray(r)?r:[r];for(let n of i)n.kind===`channel`&&(n.method===`POST`&&n.urlPath===EVE_SESSION_ROUTE_PATH&&l.add(t.logicalPath),n.adapterKind===`slack`&&u.add(t.logicalPath))}let d={};return[...l].some(e=>e!==SCAFFOLDED_WEB_CHANNEL_LOGICAL_PATH)&&(d.web=`POST ${EVE_SESSION_ROUTE_PATH} already registered`),u.size>0&&(d.slack=`Slack channel already registered`),{disabledChannelReasons:d,webRouteOwners:[...l],slackOwners:[...u],webAppPresent:c}}function assertCanAddSelectedChannels(t,n){if(t.includes(`web`)){let t=n.webRouteOwners.find(e=>e!==SCAFFOLDED_WEB_CHANNEL_LOGICAL_PATH);if(t!==void 0)throw Error(`Cannot scaffold Web Chat because agent/${t} already defines POST ${EVE_SESSION_ROUTE_PATH}. Web Chat scaffolds the same eve session routes.`)}if(t.includes(`slack`)){let e=n.slackOwners.find(e=>e!==`channels/slack.ts`);if(e!==void 0)throw Error(`Cannot scaffold Slack because agent/${e} already defines a Slack channel. Slack scaffolding would register the channel again.`)}}export{assertCanAddSelectedChannels,inspectExistingChannelRegistrations};
|
|
@@ -4,4 +4,4 @@ import { linearChannel } from "eve/channels/linear";
|
|
|
4
4
|
export default linearChannel({
|
|
5
5
|
credentials: connectLinearCredentials(${JSON.stringify(e)}),
|
|
6
6
|
});
|
|
7
|
-
`}async function chooseConnector(e,t,n){let r=linearSafeConnectorSlug(await t.deriveConnectorSlug(e.appRoot)),i=linearSafeConnectorSlug(await e.ui.asker.ask(text({key:`linear.connector-name`,message:`Name your Linear agent`,recommended:r,validate:e=>e.trim().length===0?`A Linear agent name is required.`:null}))),a=await t.findConnector({project:n,projectRoot:e.appRoot,slug:i,signal:e.signal});if(a!==void 0){let r=await e.ui.asker.ask(select({key:`linear.existing-connector`,message:`A Linear connector named "${i}" already exists. What would you like to do?`,options:[{id:`reuse`,label:`Reuse existing connector`,value:`reuse`},{id:`new`,label:`Create a new connector`,value:`new`},{id:`exit`,label:`Exit setup`,value:`exit`}],recommended:`reuse`}));if(r===`exit`)return;if(r===`reuse`)return await t.attachConnector({connector:a,log:e.ui.prompter.log,project:n,projectRoot:e.appRoot,signal:e.signal}),a}let o=a===void 0?i:linearSafeConnectorSlug(await e.ui.asker.ask(text({key:`linear.new-connector-name`,message:`Name the new Linear agent`,recommended:`${i}-2`,validate:e=>e.trim().length===0?`A Linear agent name is required.`:null})));return t.provisionConnector({log:e.ui.prompter.log,project:n,projectRoot:e.appRoot,slug:o,signal:e.signal})}async function setupLinear(e,t=defaultDeps){if(e.environment.vercel.kind===`unavailable`)throw Error("Linear setup requires an authenticated Vercel CLI. Run `vercel login`, then retry.");try{let n=await chooseConnector(e,t,await t.ensureVercelProject({appRoot:e.appRoot,prompter:e.ui.prompter,signal:e.signal}));return n===void 0?{kind:`cancelled`}:(await t.writeTextFile(join(e.appRoot,`agent/channels/linear.ts`),connectTemplate(n.uid),{force:e.force}),
|
|
7
|
+
`}async function chooseConnector(e,t,n){let r=linearSafeConnectorSlug(await t.deriveConnectorSlug(e.appRoot)),i=linearSafeConnectorSlug(await e.ui.asker.ask(text({key:`linear.connector-name`,message:`Name your Linear agent`,recommended:r,validate:e=>e.trim().length===0?`A Linear agent name is required.`:null}))),a=await t.findConnector({project:n,projectRoot:e.appRoot,slug:i,signal:e.signal});if(a!==void 0){let r=await e.ui.asker.ask(select({key:`linear.existing-connector`,message:`A Linear connector named "${i}" already exists. What would you like to do?`,options:[{id:`reuse`,label:`Reuse existing connector`,value:`reuse`},{id:`new`,label:`Create a new connector`,value:`new`},{id:`exit`,label:`Exit setup`,value:`exit`}],recommended:`reuse`}));if(r===`exit`)return;if(r===`reuse`)return await t.attachConnector({connector:a,log:e.ui.prompter.log,project:n,projectRoot:e.appRoot,signal:e.signal}),a}let o=a===void 0?i:linearSafeConnectorSlug(await e.ui.asker.ask(text({key:`linear.new-connector-name`,message:`Name the new Linear agent`,recommended:`${i}-2`,validate:e=>e.trim().length===0?`A Linear agent name is required.`:null})));return t.provisionConnector({log:e.ui.prompter.log,project:n,projectRoot:e.appRoot,slug:o,signal:e.signal})}async function setupLinear(e,t=defaultDeps){if(e.environment.vercel.kind===`unavailable`)throw Error("Linear setup requires an authenticated Vercel CLI. Run `vercel login`, then retry.");try{let n=await chooseConnector(e,t,await t.ensureVercelProject({appRoot:e.appRoot,prompter:e.ui.prompter,signal:e.signal}));return n===void 0?{kind:`cancelled`}:(await t.writeTextFile(join(e.appRoot,`agent/channels/linear.ts`),connectTemplate(n.uid),{force:e.force}),{kind:`done`,facts:[{label:`Vercel Connect`,value:`https://vercel.com/d?to=/%5Bteam%5D/~/connect&title=Open+Vercel+Connect`,kind:`url`},{label:`Next step`,value:`Deploy the agent, then open the Linear app in Vercel Connect and install it in the workspace where you want to delegate issues and comments.`},{label:`In Linear`,value:`Delegate an issue or mention the agent in an Agent Session to start a conversation.`}]})}catch(e){if(e instanceof WizardCancelledError)return{kind:`cancelled`};throw e}}const LINEAR_SETUP={kind:`linear`,label:`Linear Agent`,hint:`Delegate Linear issues and comments`,setup:setupLinear};export{LINEAR_SETUP,linearSafeConnectorSlug,setupLinear};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.38`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.4.3`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.
|
|
1
|
+
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.38`,DEFAULT_CONNECT_PACKAGE_VERSION=`0.4.3`,DEFAULT_ZOD_PACKAGE_VERSION=`4.4.3`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.31.0`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e){return{"agent/agent.ts":BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e),"agent/channels/eve.ts":WEB_APP_TEMPLATE_FILES[`agent/channels/eve.ts`],"agent/instructions.md":AGENT_INSTRUCTIONS_TEMPLATE}}function renderTemplate(e,t){return e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
|
|
2
2
|
|
|
3
3
|
export default defineAgent({
|
|
4
4
|
model: "__EVE_INIT_MODEL__",
|