eve 0.30.8 → 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 +29 -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-DDoDDmJ2.js → use-eve-agent-CF5D6jSV.js} +339 -367
- package/dist/src/chunks/{use-eve-agent-Bx-ONuyb.js → use-eve-agent-DbYZLG0h.js} +342 -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/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/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 +2 -1
- package/dist/src/client/index.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/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/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.d.ts +1 -1
- 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/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/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 +4 -14
- 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 +4 -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 +3 -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 +3 -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 +55 -74
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.d.ts +3 -3
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.d.ts +4 -4
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/twilioChannel.d.ts +3 -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 +21 -86
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/definitions/remote-agent.js +1 -1
- package/dist/src/public/definitions/schedule.d.ts +16 -16
- 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/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/channel-definition.d.ts +7 -7
- package/dist/src/shared/schedule-definition.d.ts +2 -2
- 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 +6 -8
- 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 +42 -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 +17 -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/instrumentation.md +1 -1
- package/docs/patterns/dynamic-scheduling.md +16 -15
- package/docs/schedules.mdx +10 -11
- package/docs/subagents.mdx +1 -1
- package/docs/tools/human-in-the-loop.md +1 -1
- 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,44 +1,33 @@
|
|
|
1
1
|
import type { UserContent } from "ai";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { CrossChannelToFn } from "#channel/cross-channel-receive.js";
|
|
3
|
+
import type { ChannelFrom, ChannelResolveSession } from "#channel/channel-operations.js";
|
|
4
4
|
import type { InputResponse } from "#runtime/input/types.js";
|
|
5
5
|
import type { Session } from "#channel/session.js";
|
|
6
|
-
import type { RunMode } from "#shared/run-mode.js";
|
|
7
6
|
import type { JsonObject } from "#shared/json.js";
|
|
8
7
|
import type { ChannelMethod } from "#public/definitions/channel.js";
|
|
9
8
|
type WebSocketHeaders = Headers | readonly (readonly [string, string])[] | Record<string, string>;
|
|
10
9
|
/**
|
|
11
|
-
* Second argument passed to every route handler. `
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `compact` summarizes its context without sending model input; `reset` retires
|
|
15
|
-
* a session so its token can start a fresh session; `getSession` looks one up by
|
|
16
|
-
* id; `receive` hands inbound work to a different channel; `params` contains
|
|
17
|
-
* the matched path parameters; `waitUntil` keeps background work alive past
|
|
18
|
-
* the response; `requestIp` is the client IP, or `null` when the host cannot
|
|
19
|
-
* provide it.
|
|
10
|
+
* Second argument passed to every route handler. `from` binds local operations,
|
|
11
|
+
* `resolveSession` snapshots the current owner, `to` selects a proactive target
|
|
12
|
+
* on another channel, and `attachSession` binds an immutable-ID handle.
|
|
20
13
|
*/
|
|
21
14
|
export interface RouteHandlerArgs<TState = undefined> {
|
|
22
|
-
|
|
15
|
+
/** Binds a raw channel-local address to its current-owner operations. */
|
|
16
|
+
readonly from: ChannelFrom<TState>;
|
|
17
|
+
/** Snapshots the session currently owning a raw channel-local address. */
|
|
18
|
+
readonly resolveSession: ChannelResolveSession;
|
|
19
|
+
/** Attaches a fixed operation handle to one exact durable session ID without performing I/O. */
|
|
20
|
+
attachSession: AttachSessionFn;
|
|
23
21
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* Selects a proactive target on another channel. Call `.send(message, options)`
|
|
23
|
+
* on the returned handle; the target channel owns its address and initial state.
|
|
26
24
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
clear: ClearFn;
|
|
30
|
-
compact: CompactFn;
|
|
31
|
-
reset: ResetFn;
|
|
32
|
-
getSession: GetSessionFn;
|
|
33
|
-
/**
|
|
34
|
-
* Starts a session on a different channel to hand off inbound work (e.g. an
|
|
35
|
-
* HTTP webhook routing the conversation onto Slack). The target's authored
|
|
36
|
-
* `receive` hook owns continuation-token format and initial state; the caller
|
|
37
|
-
* supplies the payload, channel-specific args, and auth.
|
|
38
|
-
*/
|
|
39
|
-
receive: CrossChannelReceiveFn;
|
|
25
|
+
readonly to: CrossChannelToFn;
|
|
26
|
+
/** Path parameters matched for the current route. */
|
|
40
27
|
params: Readonly<Record<string, string>>;
|
|
28
|
+
/** Keeps background work alive after the route returns its response. */
|
|
41
29
|
waitUntil: (task: Promise<unknown>) => void;
|
|
30
|
+
/** Best-effort client IP reported by the host, or `null` when unavailable. */
|
|
42
31
|
requestIp: string | null;
|
|
43
32
|
}
|
|
44
33
|
export interface SendPayload {
|
|
@@ -51,130 +40,13 @@ export interface SendPayload {
|
|
|
51
40
|
*/
|
|
52
41
|
readonly context?: readonly string[];
|
|
53
42
|
/**
|
|
54
|
-
* Run-scoped JSON schema the turn's result must match.
|
|
55
|
-
*
|
|
56
|
-
* only decides the failure behavior. A conversation run parks recoverably and
|
|
57
|
-
* waits for more input; a task run (which cannot wait) finishes as an error.
|
|
43
|
+
* Run-scoped JSON schema the turn's result must match. eve enforces the
|
|
44
|
+
* schema in conversation and task mode; mode only decides failure behavior.
|
|
58
45
|
*/
|
|
59
46
|
readonly outputSchema?: JsonObject;
|
|
60
47
|
}
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
* `UserContent`, or a {@link SendPayload}, plus {@link SendOptions}. Resolves
|
|
64
|
-
* to the resulting {@link Session}.
|
|
65
|
-
*/
|
|
66
|
-
export type SendFn<TState = undefined> = (input: string | UserContent | SendPayload, options: SendOptions<TState>) => Promise<Session>;
|
|
67
|
-
/** Resolves the active owner of a channel-local continuation token. */
|
|
68
|
-
export type ResolveActiveSessionFn = (options: {
|
|
69
|
-
readonly continuationToken: string;
|
|
70
|
-
}) => Promise<{
|
|
71
|
-
readonly sessionId: string;
|
|
72
|
-
} | undefined>;
|
|
73
|
-
type BaseSendOptions = {
|
|
74
|
-
auth: SessionAuthContext | null;
|
|
75
|
-
callback?: SessionCallback;
|
|
76
|
-
/** Framework-internal delegated caller waiting on this turn's settled result. */
|
|
77
|
-
caller?: TurnCaller;
|
|
78
|
-
capabilities?: SessionCapabilities;
|
|
79
|
-
continuationToken: string;
|
|
80
|
-
/**
|
|
81
|
-
* `"resume"` requires an active session and propagates a typed no-active-session
|
|
82
|
-
* error. `"resume-or-start"` preserves the default channel behavior.
|
|
83
|
-
*/
|
|
84
|
-
intent?: "resume" | "resume-or-start";
|
|
85
|
-
/**
|
|
86
|
-
* The original (top-level) caller's auth for a newly started session,
|
|
87
|
-
* becoming `session.auth.initiator`. Defaults to {@link auth} when omitted
|
|
88
|
-
* (root session behavior). Ignored when the send resolves to an existing
|
|
89
|
-
* session, whose initiator never changes after start.
|
|
90
|
-
*/
|
|
91
|
-
initiatorAuth?: SessionAuthContext | null;
|
|
92
|
-
mode?: RunMode;
|
|
93
|
-
/**
|
|
94
|
-
* Human-readable title for a newly started workflow session. Defaults to
|
|
95
|
-
* the first user message and is ignored when resuming an existing session.
|
|
96
|
-
*/
|
|
97
|
-
title?: string;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Options for {@link SendFn}. The channel owns its continuation-token
|
|
101
|
-
* format: pass the channel-local raw token (the framework prepends
|
|
102
|
-
* the channel name). Stateful channels also seed initial adapter
|
|
103
|
-
* state via {@link state}, which becomes the new session's `state`
|
|
104
|
-
* on first `runtime.run()` and is ignored on subsequent `deliver`s.
|
|
105
|
-
*/
|
|
106
|
-
export type SendOptions<TState = undefined> = [TState] extends [undefined] ? BaseSendOptions : BaseSendOptions & {
|
|
107
|
-
state: TState;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Resolves an existing {@link Session} by id, for example to read its event
|
|
111
|
-
* stream from within a route handler.
|
|
112
|
-
*/
|
|
113
|
-
export type GetSessionFn = (sessionId: string) => Session;
|
|
114
|
-
/**
|
|
115
|
-
* Options for {@link CancelFn}. `continuationToken` is the channel-local raw
|
|
116
|
-
* token, exactly as passed to {@link SendFn}. `turnId` limits the request to
|
|
117
|
-
* the turn the caller observed; a stale guard is consumed as a benign no-op.
|
|
118
|
-
*/
|
|
119
|
-
export interface CancelOptions {
|
|
120
|
-
readonly continuationToken: string;
|
|
121
|
-
readonly turnId?: string;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Requests cancellation of the active turn on the session that owns the
|
|
125
|
-
* continuation token. Never starts a session, sends input, or clears history.
|
|
126
|
-
*
|
|
127
|
-
* Both statuses are successful: `"accepted"` means the request was consumed,
|
|
128
|
-
* and `"no_active_turn"` covers an unknown token and a session with nothing
|
|
129
|
-
* to cancel. Confirmation is `turn.cancelled` followed by `session.waiting`
|
|
130
|
-
* on the event stream.
|
|
131
|
-
*/
|
|
132
|
-
export type CancelFn = (options: CancelOptions) => Promise<CancelTurnResult>;
|
|
133
|
-
/** Options for {@link CompactFn}. */
|
|
134
|
-
export interface CompactOptions {
|
|
135
|
-
/** Channel-local raw token, in the same format accepted by {@link SendFn}. */
|
|
136
|
-
readonly continuationToken: string;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Queues context compaction for the session owning a continuation token.
|
|
140
|
-
* Never sends model input or starts a new session. An accepted request returns
|
|
141
|
-
* to `session.waiting`; successful compaction emits `compaction.requested`
|
|
142
|
-
* followed by `compaction.completed` on the session stream.
|
|
143
|
-
*/
|
|
144
|
-
export type CompactFn = (options: CompactOptions) => Promise<CompactSessionResult>;
|
|
145
|
-
/** Options for {@link ClearFn}. */
|
|
146
|
-
export interface ClearOptions {
|
|
147
|
-
/** Channel-local raw token, in the same format accepted by {@link SendFn}. */
|
|
148
|
-
readonly continuationToken: string;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Queues removal of the model-message history for the session owning a
|
|
152
|
-
* continuation token. Preserves the session, agent configuration, durable
|
|
153
|
-
* state, limits, and sandbox. Completion is `context.cleared` followed by
|
|
154
|
-
* `session.waiting` on the session stream.
|
|
155
|
-
*/
|
|
156
|
-
export type ClearFn = (options: ClearOptions) => Promise<ClearSessionResult>;
|
|
157
|
-
/** Options for {@link ResetFn}. */
|
|
158
|
-
export interface ResetOptions {
|
|
159
|
-
/** Channel-local raw token, in the same format accepted by {@link SendFn}. */
|
|
160
|
-
readonly continuationToken: string;
|
|
161
|
-
/** Human-readable terminal reason. Do not include credentials or message contents. */
|
|
162
|
-
readonly reason?: string;
|
|
163
|
-
}
|
|
164
|
-
/** Result of resetting the session that owned a continuation token. */
|
|
165
|
-
export type ResetResult = {
|
|
166
|
-
readonly status: "reset";
|
|
167
|
-
readonly previousSessionId: string;
|
|
168
|
-
} | {
|
|
169
|
-
readonly status: "no_active_session";
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Terminally retires the session currently owning a continuation token.
|
|
173
|
-
* The token is available for the next {@link SendFn} after this resolves;
|
|
174
|
-
* that send starts with fresh history and state, and initializes a new
|
|
175
|
-
* session-scoped sandbox on first sandbox use.
|
|
176
|
-
*/
|
|
177
|
-
export type ResetFn = (options: ResetOptions) => Promise<ResetResult>;
|
|
48
|
+
/** Attaches an I/O-free handle to one exact durable session ID. */
|
|
49
|
+
export type AttachSessionFn = (sessionId: string) => Session;
|
|
178
50
|
export type RouteHandler<TState = undefined> = (req: Request, args: RouteHandlerArgs<TState>) => Promise<Response>;
|
|
179
51
|
/**
|
|
180
52
|
* A connected WebSocket peer passed to every {@link WebSocketRouteHooks}
|
|
@@ -28,7 +28,7 @@ export interface ScheduleDispatchInput {
|
|
|
28
28
|
*
|
|
29
29
|
* For handler schedules: builds {@link ScheduleHandlerArgs} against the
|
|
30
30
|
* request-scoped channel bundle and invokes the author's `run`. The
|
|
31
|
-
* author owns control flow — `args.
|
|
31
|
+
* author owns control flow — `args.to(channel, target).send(…)` hands work off
|
|
32
32
|
* to a channel; `args.waitUntil(promise)` extends the task lifetime
|
|
33
33
|
* so the dispatcher awaits in-flight work before settling.
|
|
34
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSession}from"#channel/session.js";import{SCHEDULE_APP_AUTH,SCHEDULE_APP_AUTH as SCHEDULE_APP_AUTH$1}from"#channel/schedule-auth.js";import{
|
|
1
|
+
import{createSession}from"#channel/session.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{expectFunction}from"#internal/authored-module.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=[],a=[],o=createCrossChannelToFn(this.runtime,toCrossChannelTargets(this.channels)),s={appAuth:SCHEDULE_APP_AUTH$1,to(e,n){let r=o(e,n);return{async send(e,n){let i=await r.send(e,n);return t.push(i),i}}},waitUntil(e){a.push(e)}};if(e.run)await e.run(s);else if(e.markdown!==void 0){let n=await this.runMarkdown(e.markdown);t.push(n)}else throw Error(`Schedule "${e.scheduleId}" has neither "run" nor "markdown" — at least one must be set.`);return{sessions:t,waitUntilTasks:a}}async runMarkdown(t){return createSession((await this.runtime.createSession({adapter:SCHEDULE_ADAPTER,auth:SCHEDULE_APP_AUTH$1,input:{message:t},mode:`task`})).sessionId,this.runtime)}};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};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UserContent } from "ai";
|
|
2
|
+
import type { SendPayload } from "#channel/routes.js";
|
|
3
|
+
/** Normalizes the shorthand input forms accepted by channel and session sends. */
|
|
4
|
+
export declare function normalizeSendInput(input: string | UserContent | SendPayload): SendPayload;
|
|
5
|
+
/** Serializes non-data URL file parts before input crosses the durable boundary. */
|
|
6
|
+
export declare function serializeUrlFilePartsInMessage(message: string | UserContent | undefined): string | UserContent | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{serializeUrlFilePart}from"#internal/attachments/url-refs.js";function normalizeSendInput(e){return typeof e==`string`||Array.isArray(e)?{message:e}:e}function serializeUrlFilePartsInMessage(t){if(t===void 0||typeof t==`string`)return t;let n=!1,r=t.map(t=>t.type===`file`&&t.data instanceof URL&&t.data.protocol!==`data:`?(n=!0,{...t,data:serializeUrlFilePart(t.data)}):t);return n?r:t}export{normalizeSendInput,serializeUrlFilePartsInMessage};
|
|
@@ -1,56 +1,67 @@
|
|
|
1
1
|
import type { ContextAccessor } from "#context/key.js";
|
|
2
2
|
import type { MessageStreamEvent } from "#protocol/message.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { UserContent } from "ai";
|
|
4
|
+
import type { CancelTurnResult, ClearSessionResult, CompactSessionResult, ResetSessionResult, Runtime, SessionAuthContext, SessionCallback, SessionSendCommandResult, TurnCaller } from "#channel/types.js";
|
|
4
5
|
import type { SessionAuth } from "#context/keys.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* resolves to a `ReadableStream` of the session's harness events
|
|
9
|
-
* (optionally from `startIndex`). Returned by {@link SendFn},
|
|
10
|
-
* {@link GetSessionFn}, and a channel's `receive` hook. Unlike the live
|
|
11
|
-
* {@link SessionHandle} on `ctx.session`, this is an inert result value:
|
|
12
|
-
* its fields are snapshots and it cannot mutate the continuation token.
|
|
13
|
-
*/
|
|
6
|
+
import type { InputResponse } from "#runtime/input/types.js";
|
|
7
|
+
import type { JsonObject } from "#shared/json.js";
|
|
8
|
+
/** Immutable-ID handle for one exact durable session. */
|
|
14
9
|
export interface Session {
|
|
15
10
|
readonly id: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* `session.waiting` on the event stream.
|
|
22
|
-
*/
|
|
11
|
+
/** Sends a message to this exact session ID without creating or following a replacement. */
|
|
12
|
+
send(message: string | UserContent, options: SessionSendOptions): Promise<SessionSendCommandResult>;
|
|
13
|
+
/** Answers pending input requests on this exact session ID. */
|
|
14
|
+
respond(inputResponses: readonly InputResponse[], options: SessionRespondOptions): Promise<SessionSendCommandResult>;
|
|
15
|
+
/** Requests cancellation of this exact session's active turn. */
|
|
23
16
|
cancel(options?: {
|
|
24
17
|
turnId?: string;
|
|
25
18
|
}): Promise<CancelTurnResult>;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
/** Queues compaction on this exact session ID. */
|
|
20
|
+
compact(): Promise<CompactSessionResult>;
|
|
21
|
+
/** Queues a context clear on this exact session ID. */
|
|
22
|
+
clear(): Promise<ClearSessionResult>;
|
|
23
|
+
/** Terminally retires this exact session ID. */
|
|
24
|
+
reset(options?: {
|
|
25
|
+
reason?: string;
|
|
26
|
+
}): Promise<ResetSessionResult>;
|
|
30
27
|
getEventStream(options?: {
|
|
31
28
|
startIndex?: number;
|
|
32
29
|
}): Promise<ReadableStream<MessageStreamEvent>>;
|
|
33
|
-
/**
|
|
34
|
-
* Resolves the durable tail of the event stream: the zero-based index of
|
|
35
|
-
* the last recorded event, or `-1` before the first.
|
|
36
|
-
*/
|
|
37
30
|
getStreamTailIndex(): Promise<number>;
|
|
38
31
|
}
|
|
32
|
+
interface SessionDeliveryOptions {
|
|
33
|
+
readonly auth: SessionAuthContext | null;
|
|
34
|
+
/** Public callback destination for a delegated continuation turn. */
|
|
35
|
+
readonly callback?: SessionCallback;
|
|
36
|
+
readonly context?: readonly string[];
|
|
37
|
+
readonly outputSchema?: JsonObject;
|
|
38
|
+
}
|
|
39
|
+
/** Options for sending a message through a fixed session handle. */
|
|
40
|
+
export type SessionSendOptions = SessionDeliveryOptions;
|
|
41
|
+
/** Options for answering pending input requests through a fixed session handle. */
|
|
42
|
+
export type SessionRespondOptions = SessionDeliveryOptions;
|
|
39
43
|
/**
|
|
40
44
|
* Live handle to the current session, exposed on `ctx.session` to
|
|
41
45
|
* `deliver` and event handlers. The framework hydrates the read-only
|
|
42
46
|
* fields from the active context at step start. A write through
|
|
43
|
-
*
|
|
47
|
+
* `continuation.rekey()` updates the context so the
|
|
44
48
|
* runtime can re-key the parked workflow hook at the next step boundary.
|
|
45
49
|
*/
|
|
46
50
|
export interface SessionHandle {
|
|
47
51
|
readonly id: string;
|
|
48
|
-
readonly continuationToken: string;
|
|
49
52
|
readonly auth: SessionAuth;
|
|
50
|
-
|
|
53
|
+
readonly continuation?: {
|
|
54
|
+
readonly token: string;
|
|
55
|
+
rekey(rawToken: string): void;
|
|
56
|
+
};
|
|
51
57
|
}
|
|
52
|
-
export declare function createSession(id: string,
|
|
53
|
-
|
|
58
|
+
export declare function createSession(id: string, runtime: Runtime, metadata?: {
|
|
59
|
+
readonly requestId?: string;
|
|
60
|
+
}): Session;
|
|
61
|
+
/** Builds an I/O-free factory for fixed session-ID handles. */
|
|
62
|
+
export declare function createAttachSessionFn(runtime: Runtime, metadata?: {
|
|
63
|
+
readonly requestId?: string;
|
|
64
|
+
}): (sessionId: string) => Session;
|
|
54
65
|
/**
|
|
55
66
|
* Builds a live {@link SessionHandle} backed by the active context
|
|
56
67
|
* accessor. Read-only fields resolve through getters so they reflect
|
|
@@ -62,3 +73,6 @@ export declare function createGetSessionFn(runtime: Runtime): (sessionId: string
|
|
|
62
73
|
* every adapter handler invocation.
|
|
63
74
|
*/
|
|
64
75
|
export declare function buildSessionHandle(accessor: ContextAccessor): SessionHandle;
|
|
76
|
+
/** @internal Converts validated public callback metadata into runtime turn routing. */
|
|
77
|
+
export declare function sessionCallbackToTurnCaller(callback: SessionCallback | undefined): TurnCaller | undefined;
|
|
78
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AuthKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";function createSession(
|
|
1
|
+
import{serializeUrlFilePartsInMessage}from"#channel/send-input.js";import{AuthKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function createSession(t,n,r={}){return{id:t,async send(i,a){let o=sessionCallbackToTurnCaller(a.callback),s={message:serializeUrlFilePartsInMessage(i)};a.context!==void 0&&(s.context=a.context),a.outputSchema!==void 0&&(s.outputSchema=a.outputSchema);let c={auth:a.auth,kind:`send`,payload:s,requestId:r.requestId};return await n.dispatchSession({command:o===void 0?c:{...c,caller:o},sessionId:t})},async respond(e,i){if(e.length===0)throw Error(`respond() requires at least one input response.`);let a=sessionCallbackToTurnCaller(i.callback),o={inputResponses:e};i.context!==void 0&&(o.context=i.context),i.outputSchema!==void 0&&(o.outputSchema=i.outputSchema);let s={auth:i.auth,kind:`send`,payload:o,requestId:r.requestId};return await n.dispatchSession({command:a===void 0?s:{...s,caller:a},sessionId:t})},async cancel(e){return await n.dispatchSession({command:{kind:`cancel`,turnId:e?.turnId},sessionId:t})},async compact(){return await n.dispatchSession({command:{kind:`compact`},sessionId:t})},async clear(){return await n.dispatchSession({command:{kind:`clear`},sessionId:t})},async reset(e){return await n.dispatchSession({command:{kind:`reset`,reason:e?.reason},sessionId:t})},async getEventStream(e){return n.getEventStream(t,e)},async getStreamTailIndex(){return n.getStreamTailIndex(t)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function buildSessionHandle(e){return{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),rekey(r){let i=namespaceContinuationToken(t,r);t!==i&&e.set(ContinuationTokenKey,i)}}}}}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`,url:e.url},subagentName:e.subagentName}}export{buildSessionHandle,createAttachSessionFn,createSession,sessionCallbackToTurnCaller};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UserContent } from "ai";
|
|
2
2
|
import type { UnstampedMessageStreamEvent, MessageStreamEvent } from "#protocol/message.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CancelTurnResult as ProtocolCancelTurnResult } from "#protocol/cancel-turn.js";
|
|
4
4
|
import type { RunMode } from "#shared/run-mode.js";
|
|
5
5
|
import type { RuntimeSubagentChildResult } from "#runtime/actions/types.js";
|
|
6
6
|
import type { InputRequest, InputResponse } from "#runtime/input/types.js";
|
|
@@ -18,19 +18,7 @@ export interface CancelTurnInput {
|
|
|
18
18
|
readonly turnId?: string;
|
|
19
19
|
}
|
|
20
20
|
/** Result of requesting turn cancellation. Both statuses are successful. */
|
|
21
|
-
export
|
|
22
|
-
readonly status: CancelTurnStatus;
|
|
23
|
-
/**
|
|
24
|
-
* For `no_active_turn`: the error class that classified the target as
|
|
25
|
-
* inactive, distinguishing "already finished" (`HookNotFoundError`) from a
|
|
26
|
-
* transiently unreachable cancel hook (`EntityConflictError`).
|
|
27
|
-
*/
|
|
28
|
-
readonly reason?: string;
|
|
29
|
-
}
|
|
30
|
-
/** Identifies the continuation hook whose durable session should compact. */
|
|
31
|
-
export interface CompactSessionInput {
|
|
32
|
-
readonly continuationToken: string;
|
|
33
|
-
}
|
|
21
|
+
export type CancelTurnResult = ProtocolCancelTurnResult;
|
|
34
22
|
/** Result of queueing manual context compaction for a session. */
|
|
35
23
|
export type CompactSessionResult = {
|
|
36
24
|
readonly status: "accepted";
|
|
@@ -38,10 +26,6 @@ export type CompactSessionResult = {
|
|
|
38
26
|
} | {
|
|
39
27
|
readonly status: "no_active_session";
|
|
40
28
|
};
|
|
41
|
-
/** Identifies the continuation hook whose durable session should clear context. */
|
|
42
|
-
export interface ClearSessionInput {
|
|
43
|
-
readonly continuationToken: string;
|
|
44
|
-
}
|
|
45
29
|
/** Result of queueing a manual context clear for a session. */
|
|
46
30
|
export type ClearSessionResult = {
|
|
47
31
|
readonly status: "accepted";
|
|
@@ -49,18 +33,6 @@ export type ClearSessionResult = {
|
|
|
49
33
|
} | {
|
|
50
34
|
readonly status: "no_active_session";
|
|
51
35
|
};
|
|
52
|
-
/** Identifies a session to transition permanently to a terminal state. */
|
|
53
|
-
export interface TerminateSessionInput {
|
|
54
|
-
/** Human-readable reason recorded on the terminal workflow transition. */
|
|
55
|
-
readonly reason?: string;
|
|
56
|
-
readonly sessionId: string;
|
|
57
|
-
}
|
|
58
|
-
/** Result of attempting to terminally retire a session. */
|
|
59
|
-
export type TerminateSessionResult = {
|
|
60
|
-
readonly status: "terminated";
|
|
61
|
-
} | {
|
|
62
|
-
readonly status: "already_terminal";
|
|
63
|
-
};
|
|
64
36
|
/**
|
|
65
37
|
* Identifies one turn within a session.
|
|
66
38
|
*
|
|
@@ -177,7 +149,8 @@ export type SessionSendCommandResult = {
|
|
|
177
149
|
} | {
|
|
178
150
|
readonly status: "session_not_active";
|
|
179
151
|
};
|
|
180
|
-
|
|
152
|
+
/** Result of terminally resetting a session. */
|
|
153
|
+
export type ResetSessionResult = {
|
|
181
154
|
readonly status: "reset";
|
|
182
155
|
readonly previousSessionId: string;
|
|
183
156
|
} | {
|
|
@@ -191,7 +164,7 @@ export type SessionCommandResult<TCommand extends SessionCommand = SessionComman
|
|
|
191
164
|
readonly kind: "compact";
|
|
192
165
|
} ? CompactSessionResult : TCommand extends {
|
|
193
166
|
readonly kind: "clear";
|
|
194
|
-
} ? ClearSessionResult :
|
|
167
|
+
} ? ClearSessionResult : ResetSessionResult;
|
|
195
168
|
export interface DispatchContinuationInput<TCommand extends SessionCommand = SessionCommand> {
|
|
196
169
|
readonly command: TCommand;
|
|
197
170
|
readonly continuationToken: string;
|
|
@@ -368,9 +341,10 @@ export interface RunInput {
|
|
|
368
341
|
/**
|
|
369
342
|
* Session continuation token for delivery and hook creation. Channels can
|
|
370
343
|
* re-key the session during the first turn via
|
|
371
|
-
* `ctx.session.
|
|
344
|
+
* `ctx.session.continuation.rekey(...)` (e.g. Slack adopts its first
|
|
372
345
|
* post's `ts` as the thread root), so an initial placeholder token is
|
|
373
|
-
* acceptable when full identity isn't known until the first message.
|
|
346
|
+
* acceptable when full identity isn't known until the first message. ID-only
|
|
347
|
+
* transports omit this field.
|
|
374
348
|
*/
|
|
375
349
|
readonly continuationToken?: string;
|
|
376
350
|
/**
|
|
@@ -440,7 +414,6 @@ export type RunResult = {
|
|
|
440
414
|
* Carries the identifiers needed for stream endpoints.
|
|
441
415
|
*/
|
|
442
416
|
export interface RunHandle {
|
|
443
|
-
readonly continuationToken: string;
|
|
444
417
|
readonly events: ReadableStream<MessageStreamEvent>;
|
|
445
418
|
/**
|
|
446
419
|
* Runtime-owned identifier for this session. Stream and inspection APIs
|