agents 0.24.0 → 0.26.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/dist/{agent-routing-B2XLNMxq.d.ts → agent-routing-0DR0Tk2v.d.ts} +205 -132
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-routing.js.map +1 -1
- package/dist/agent-tool-types.d.ts +28 -22
- package/dist/agent-tool-types.js +23 -1
- package/dist/agent-tool-types.js.map +1 -1
- package/dist/{agent-tools-y7zLfw4Q.js → agent-tools-CdJC-8Dc.js} +72 -9
- package/dist/agent-tools-CdJC-8Dc.js.map +1 -0
- package/dist/{agent-tools-Dj5Mzlw7.d.ts → agent-tools-YrATZJu2.d.ts} +34 -20
- package/dist/agent-tools.d.ts +20 -18
- package/dist/agent-tools.js.map +1 -1
- package/dist/ai-fm7xx1BK.js +312 -0
- package/dist/ai-fm7xx1BK.js.map +1 -0
- package/dist/base64-redaction-C1Uu29t5.js +59 -0
- package/dist/base64-redaction-C1Uu29t5.js.map +1 -0
- package/dist/browser/ai-sdk.d.ts +90 -0
- package/dist/browser/ai-sdk.js +51 -0
- package/dist/browser/ai-sdk.js.map +1 -0
- package/dist/browser/ai.d.ts +4 -4
- package/dist/browser/ai.js +1 -347
- package/dist/browser/index.d.ts +81 -79
- package/dist/browser/index.js +361 -2
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/tanstack-ai.d.ts +96 -1
- package/dist/browser/tanstack-ai.js +62 -2
- package/dist/browser/tanstack-ai.js.map +1 -1
- package/dist/browser-DE3d-RLk.d.ts +275 -0
- package/dist/browser-tool-CQ10e6Kj.js +480 -0
- package/dist/browser-tool-CQ10e6Kj.js.map +1 -0
- package/dist/browser-tool-DuNdlwZ9.d.ts +73 -0
- package/dist/capability-B4WbF81e.js.map +1 -1
- package/dist/{capability-runner-BUBa6Ake.d.ts → capability-runner-DBAnGr6L.d.ts} +7 -2
- package/dist/chat/index.d.ts +340 -234
- package/dist/chat/index.js +592 -66
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.d.ts +42 -2
- package/dist/chat/react.js +191 -35
- package/dist/chat/react.js.map +1 -1
- package/dist/chat/transport.d.ts +1 -1
- package/dist/chat/transport.js +1 -1
- package/dist/chat-sdk/index.d.ts +17 -3
- package/dist/chat-sdk/index.js +28 -2
- package/dist/chat-sdk/index.js.map +1 -1
- package/dist/{client-C9DAjZIY.js → client-4OlMIJx-.js} +102 -29
- package/dist/client-4OlMIJx-.js.map +1 -0
- package/dist/{client-BxdkCuVy.d.ts → client-je3koD9Z.d.ts} +45 -10
- package/dist/client.d.ts +7 -5
- package/dist/client.js +2 -2
- package/dist/{connector-CptFKzRh.js → connector-58XDGvc3.js} +251 -120
- package/dist/connector-58XDGvc3.js.map +1 -0
- package/dist/{connector-CkQD4MK3.d.ts → connector-Cl-VqPmA.d.ts} +244 -146
- package/dist/context/index.d.ts +29 -0
- package/dist/context/index.js +64 -17
- package/dist/context/index.js.map +1 -1
- package/dist/current-agent-DhoDkSnH.js.map +1 -1
- package/dist/{current-agent-C4w86kcN.d.ts → current-agent-vAk_5JMt.d.ts} +4 -4
- package/dist/{durable-object-lifecycle-ei7M7lqB.d.ts → durable-object-lifecycle-HhgOMWq9.d.ts} +15 -7
- package/dist/harness/pi/index.d.ts +344 -0
- package/dist/harness/pi/index.js +873 -0
- package/dist/harness/pi/index.js.map +1 -0
- package/dist/images-iiTDSyRu.js +1631 -0
- package/dist/images-iiTDSyRu.js.map +1 -0
- package/dist/{index-Dlgtd3Mj.d.ts → index-BreL0YrQ.d.ts} +2 -2
- package/dist/index-kbSUIer3.d.ts +343 -0
- package/dist/index.d.ts +46 -44
- package/dist/index.js +1 -1
- package/dist/internal_context.d.ts +1 -1
- package/dist/lifecycle/index.d.ts +3 -3
- package/dist/lifecycle/index.js +1 -1
- package/dist/{lifecycle-Mm_jQh7r.js → lifecycle-CFu6OV03.js} +39 -10
- package/dist/{lifecycle-Mm_jQh7r.js.map → lifecycle-CFu6OV03.js.map} +1 -1
- package/dist/mcp/client/index.d.ts +20 -20
- package/dist/mcp/client/x402.js +21 -19
- package/dist/mcp/client/x402.js.map +1 -1
- package/dist/mcp/index.d.ts +35 -35
- package/dist/mcp/index.js +1 -1
- package/dist/{message-builder-BymO4N_D.js → message-builder-DAl9AhHH.js} +89 -4
- package/dist/message-builder-DAl9AhHH.js.map +1 -0
- package/dist/models/ai-sdk/index.d.ts +353 -0
- package/dist/models/ai-sdk/index.js +2443 -0
- package/dist/models/ai-sdk/index.js.map +1 -0
- package/dist/models/pi-ai/index.d.ts +313 -0
- package/dist/models/pi-ai/index.js +1795 -0
- package/dist/models/pi-ai/index.js.map +1 -0
- package/dist/observability/ai/index.js +20 -4
- package/dist/observability/ai/index.js.map +1 -1
- package/dist/{protocol-B0nh6KNf.js → protocol-kHsr-f0X.js} +26 -12
- package/dist/{protocol-B0nh6KNf.js.map → protocol-kHsr-f0X.js.map} +1 -1
- package/dist/queue/index.d.ts +3 -3
- package/dist/queue/index.js +1 -1
- package/dist/{queue-BC9F5cUo.js → queue-BB-zfIYF.js} +2 -2
- package/dist/{queue-BC9F5cUo.js.map → queue-BB-zfIYF.js.map} +1 -1
- package/dist/react.d.ts +6 -6
- package/dist/react.js +160 -64
- package/dist/react.js.map +1 -1
- package/dist/{retries-D9B2UCq3.d.ts → retries-CV6AkXmQ.d.ts} +18 -9
- package/dist/retries.d.ts +11 -9
- package/dist/retries.js +11 -1
- package/dist/retries.js.map +1 -1
- package/dist/routing/index.d.ts +2 -2
- package/dist/routing/index.js +1 -1
- package/dist/{scheduler-D_KHqxBa.js → scheduler-DZ3xQfeK.js} +2 -2
- package/dist/{scheduler-D_KHqxBa.js.map → scheduler-DZ3xQfeK.js.map} +1 -1
- package/dist/{scheduler-BGq6M5Kd.d.ts → scheduler-RdACNXDP.d.ts} +3 -3
- package/dist/schedules/index.d.ts +1 -1
- package/dist/schedules/index.js +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/sessions/index.d.ts +70 -3
- package/dist/sessions/index.js +276 -67
- package/dist/sessions/index.js.map +1 -1
- package/dist/skills/index.d.ts +29 -314
- package/dist/socket-address.d.ts +16 -0
- package/dist/socket-address.js +19 -0
- package/dist/socket-address.js.map +1 -0
- package/dist/{src-BNU3ZiJM.js → src-BZeu-SCD.js} +423 -115
- package/dist/src-BZeu-SCD.js.map +1 -0
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.js +1 -1
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/{streams-BcE8JP2X.d.ts → streams-Cmkj9QfW.d.ts} +4 -2
- package/dist/{streams-CCPRV6dt.js → streams-DW-UCOUc.js} +9 -2
- package/dist/streams-DW-UCOUc.js.map +1 -0
- package/dist/sub-routing.d.ts +12 -12
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/{tasks-D4nLqVSI.js → tasks-68DESxf0.js} +2 -2
- package/dist/{tasks-D4nLqVSI.js.map → tasks-68DESxf0.js.map} +1 -1
- package/dist/{tasks-V2lCT8ZV.d.ts → tasks-9YxYtByh.d.ts} +2 -2
- package/dist/transport-PfFnt-Ld.d.ts +525 -0
- package/dist/{types-DCD6BNZH.d.ts → types-BA4anrjI.d.ts} +2 -2
- package/dist/voice/index.d.ts +2 -2
- package/dist/websockets/index.d.ts +23 -6
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-D7IzWbZb.js → websockets-Ci-LZFHH.js} +45 -20
- package/dist/{websockets-D7IzWbZb.js.map → websockets-Ci-LZFHH.js.map} +1 -1
- package/dist/wire-types-CnMt6_HR.js.map +1 -1
- package/dist/wire-types-CrjKvDyi.d.ts +300 -0
- package/dist/workflow-types.d.ts +25 -25
- package/dist/workflows.d.ts +21 -21
- package/dist/workflows.js +1 -1
- package/dist/{ws-chat-transport-UNRIS2xl.d.ts → ws-chat-transport-BbT1A5Lc.d.ts} +51 -2
- package/dist/{ws-chat-transport-rWwta645.js → ws-chat-transport-cqMKq3IY.js} +143 -16
- package/dist/ws-chat-transport-cqMKq3IY.js.map +1 -0
- package/docs/agent-tools.md +29 -4
- package/docs/browse-the-web.md +87 -5
- package/docs/chat-agents.md +124 -16
- package/docs/context.md +27 -0
- package/docs/durable-execution.md +2 -0
- package/docs/harnesses/pi.md +173 -0
- package/docs/human-in-the-loop.md +4 -0
- package/docs/index.md +3 -0
- package/docs/lifecycle.md +20 -4
- package/docs/models-pi-ai.md +325 -0
- package/docs/models.md +504 -0
- package/docs/resumable-streaming.md +2 -0
- package/docs/routing.md +13 -13
- package/docs/sessions.md +36 -1
- package/docs/state.md +1 -0
- package/docs/sub-agents.md +9 -0
- package/package.json +40 -2
- package/dist/agent-tools-y7zLfw4Q.js.map +0 -1
- package/dist/browser/ai.js.map +0 -1
- package/dist/client-C9DAjZIY.js.map +0 -1
- package/dist/client-tools-aIBO0Fk7.d.ts +0 -53
- package/dist/connector-CptFKzRh.js.map +0 -1
- package/dist/message-builder-BymO4N_D.js.map +0 -1
- package/dist/src-BNU3ZiJM.js.map +0 -1
- package/dist/streams-CCPRV6dt.js.map +0 -1
- package/dist/ws-chat-transport-rWwta645.js.map +0 -1
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { JSONSchema7, Tool, ToolSet, UIMessage } from "ai";
|
|
2
|
+
|
|
3
|
+
//#region src/chat/client-tools.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Wire-format tool schema sent from the client.
|
|
6
|
+
* Uses `parameters` (JSONSchema7) rather than AI SDK's `inputSchema`
|
|
7
|
+
* because Zod schemas cannot be serialized over the wire.
|
|
8
|
+
*/
|
|
9
|
+
type ClientToolSchema = {
|
|
10
|
+
/** Unique name for the tool */ name: string /** Human-readable description of what the tool does */;
|
|
11
|
+
description?: Tool["description"] /** JSON Schema defining the tool's input parameters */;
|
|
12
|
+
parameters?: JSONSchema7;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Executes a client-defined tool and returns its output.
|
|
16
|
+
*
|
|
17
|
+
* Used for the RPC path (e.g. a parent agent delegating to a Think sub-agent)
|
|
18
|
+
* where the caller can run the client tools itself, rather than the
|
|
19
|
+
* browser/WebSocket path where results are sent back asynchronously.
|
|
20
|
+
*/
|
|
21
|
+
type ClientToolExecutor = (call: {
|
|
22
|
+
/** The name of the client tool the model called. */ toolName: string /** The model-generated input for the tool call. */;
|
|
23
|
+
input: unknown /** The AI SDK tool-call id for the invocation. */;
|
|
24
|
+
toolCallId: string;
|
|
25
|
+
}) => unknown | Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Converts client tool schemas to AI SDK tool format.
|
|
28
|
+
*
|
|
29
|
+
* By default these tools have no `execute` function — when the AI model calls
|
|
30
|
+
* them, the tool call is sent back to the client for execution.
|
|
31
|
+
*
|
|
32
|
+
* When `options.execute` is provided, each tool is built WITH an `execute` that
|
|
33
|
+
* delegates to it. This is used by the RPC path (e.g. a parent agent driving a
|
|
34
|
+
* Think sub-agent) so the model's client-tool call is resolved inline within
|
|
35
|
+
* the same turn.
|
|
36
|
+
*
|
|
37
|
+
* @param clientTools - Array of tool schemas from the client
|
|
38
|
+
* @param options - Optional `execute` delegate to run the tools inline
|
|
39
|
+
* @returns Record of AI SDK tools that can be spread into your tools object
|
|
40
|
+
*/
|
|
41
|
+
declare function createToolsFromClientSchemas(
|
|
42
|
+
clientTools?: ClientToolSchema[],
|
|
43
|
+
options?: {
|
|
44
|
+
execute?: ClientToolExecutor;
|
|
45
|
+
}
|
|
46
|
+
): ToolSet;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/chat/protocol.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Wire protocol message type constants for the cf_agent_chat_* protocol.
|
|
51
|
+
*
|
|
52
|
+
* These are the string values used on the wire between agent servers and
|
|
53
|
+
* clients. Both @cloudflare/ai-chat (via its MessageType enum) and
|
|
54
|
+
* @cloudflare/think use these values.
|
|
55
|
+
*/
|
|
56
|
+
declare const STREAM_RESUME_NONE_REASONS: {
|
|
57
|
+
/** No active, pending, or terminal stream exists for this agent. */ readonly IDLE: "idle" /** An active tool continuation is owned by another live connection. */;
|
|
58
|
+
readonly CONTINUATION_OWNED: "continuation-owned";
|
|
59
|
+
};
|
|
60
|
+
type StreamResumeNoneReason =
|
|
61
|
+
(typeof STREAM_RESUME_NONE_REASONS)[keyof typeof STREAM_RESUME_NONE_REASONS];
|
|
62
|
+
declare const CHAT_MESSAGE_TYPES: {
|
|
63
|
+
readonly CHAT_MESSAGES: "cf_agent_chat_messages";
|
|
64
|
+
readonly USE_CHAT_REQUEST: "cf_agent_use_chat_request";
|
|
65
|
+
readonly USE_CHAT_RESPONSE: "cf_agent_use_chat_response";
|
|
66
|
+
readonly CHAT_CLEAR: "cf_agent_chat_clear";
|
|
67
|
+
readonly CHAT_REQUEST_CANCEL: "cf_agent_chat_request_cancel";
|
|
68
|
+
readonly STREAM_RESUMING: "cf_agent_stream_resuming";
|
|
69
|
+
readonly STREAM_RESUME_ACK: "cf_agent_stream_resume_ack";
|
|
70
|
+
readonly STREAM_RESUME_REQUEST: "cf_agent_stream_resume_request";
|
|
71
|
+
readonly STREAM_RESUME_NONE: "cf_agent_stream_resume_none";
|
|
72
|
+
readonly STREAM_PENDING: "cf_agent_stream_pending";
|
|
73
|
+
readonly TOOL_RESULT: "cf_agent_tool_result";
|
|
74
|
+
readonly TOOL_APPROVAL: "cf_agent_tool_approval";
|
|
75
|
+
readonly MESSAGE_UPDATED: "cf_agent_message_updated";
|
|
76
|
+
readonly CHAT_RECOVERING: "cf_agent_chat_recovering";
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/chat/wire-types.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* How a chat request ended.
|
|
82
|
+
*
|
|
83
|
+
* - `completed`: the turn finished normally.
|
|
84
|
+
* - `error`: the turn failed.
|
|
85
|
+
* - `aborted`: the turn was cancelled while it ran.
|
|
86
|
+
* - `skipped`: the turn never ran, because a newer send superseded it or the
|
|
87
|
+
* concurrency policy dropped it.
|
|
88
|
+
* - `recovering`: this request stopped, but recovery continues the same turn
|
|
89
|
+
* under a new request that carries the same `messageIds`.
|
|
90
|
+
*/
|
|
91
|
+
type ChatTurnOutcome =
|
|
92
|
+
| "completed"
|
|
93
|
+
| "error"
|
|
94
|
+
| "aborted"
|
|
95
|
+
| "skipped"
|
|
96
|
+
| "recovering";
|
|
97
|
+
/**
|
|
98
|
+
* Enum for message types to improve type safety and maintainability
|
|
99
|
+
*/
|
|
100
|
+
declare enum MessageType {
|
|
101
|
+
CF_AGENT_CHAT_MESSAGES = "cf_agent_chat_messages",
|
|
102
|
+
CF_AGENT_USE_CHAT_REQUEST = "cf_agent_use_chat_request",
|
|
103
|
+
CF_AGENT_USE_CHAT_RESPONSE = "cf_agent_use_chat_response",
|
|
104
|
+
CF_AGENT_CHAT_CLEAR = "cf_agent_chat_clear",
|
|
105
|
+
CF_AGENT_CHAT_REQUEST_CANCEL = "cf_agent_chat_request_cancel",
|
|
106
|
+
/** Sent by server when client connects and there's an active stream to resume */
|
|
107
|
+
CF_AGENT_STREAM_RESUMING = "cf_agent_stream_resuming",
|
|
108
|
+
/** Sent by client to acknowledge stream resuming notification and request chunks */
|
|
109
|
+
CF_AGENT_STREAM_RESUME_ACK = "cf_agent_stream_resume_ack",
|
|
110
|
+
/** Sent by client after message handler is ready, requesting stream resume check */
|
|
111
|
+
CF_AGENT_STREAM_RESUME_REQUEST = "cf_agent_stream_resume_request",
|
|
112
|
+
/** Sent by server when client requests resume but no active stream exists */
|
|
113
|
+
CF_AGENT_STREAM_RESUME_NONE = "cf_agent_stream_resume_none",
|
|
114
|
+
/**
|
|
115
|
+
* Sent by server when a turn is accepted but its resumable stream has not
|
|
116
|
+
* started yet (queued / debouncing / waiting on MCP / async setup). Tells a
|
|
117
|
+
* reconnecting client to keep waiting rather than resolve its resume probe to
|
|
118
|
+
* "no stream". Resolved by a later `CF_AGENT_STREAM_RESUMING` (stream started)
|
|
119
|
+
* or `CF_AGENT_STREAM_RESUME_NONE` (settled without streaming). See #1784.
|
|
120
|
+
*/
|
|
121
|
+
CF_AGENT_STREAM_PENDING = "cf_agent_stream_pending",
|
|
122
|
+
/** Client sends tool result to server (for client-side tools) */
|
|
123
|
+
CF_AGENT_TOOL_RESULT = "cf_agent_tool_result",
|
|
124
|
+
/** Server notifies client that a message was updated (e.g., tool result applied) */
|
|
125
|
+
CF_AGENT_MESSAGE_UPDATED = "cf_agent_message_updated",
|
|
126
|
+
/** Client sends tool approval response to server (for tools with needsApproval) */
|
|
127
|
+
CF_AGENT_TOOL_APPROVAL = "cf_agent_tool_approval",
|
|
128
|
+
/**
|
|
129
|
+
* Server→client progress hint: a durable chat turn is being recovered
|
|
130
|
+
* (interrupted by a deploy/eviction or a stream-stall watchdog abort and now
|
|
131
|
+
* resuming). Sent when a recovery continuation is scheduled and cleared on
|
|
132
|
+
* every terminal outcome. (`@cloudflare/think` also replays it on connect;
|
|
133
|
+
* `@cloudflare/ai-chat` broadcasts the live signal only — see #1645.)
|
|
134
|
+
* Backward-compatible — clients that don't understand it ignore it. See #1620.
|
|
135
|
+
*/
|
|
136
|
+
CF_AGENT_CHAT_RECOVERING = "cf_agent_chat_recovering"
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Types of messages sent from the Agent to clients
|
|
140
|
+
*/
|
|
141
|
+
type OutgoingMessage<ChatMessage extends UIMessage = UIMessage> =
|
|
142
|
+
| {
|
|
143
|
+
/** Indicates this message is a command to clear chat history */ type: MessageType.CF_AGENT_CHAT_CLEAR;
|
|
144
|
+
}
|
|
145
|
+
| {
|
|
146
|
+
/** Indicates this message contains updated chat messages */ type: MessageType.CF_AGENT_CHAT_MESSAGES /** Array of chat messages */;
|
|
147
|
+
messages: readonly ChatMessage[];
|
|
148
|
+
/**
|
|
149
|
+
* Set on the transcript a server sends to a newly connected client. It
|
|
150
|
+
* predates any request the client buffered while disconnected, so the
|
|
151
|
+
* client keeps those optimistic sends; any other snapshot is
|
|
152
|
+
* authoritative (#1983).
|
|
153
|
+
*/
|
|
154
|
+
connect?: boolean;
|
|
155
|
+
}
|
|
156
|
+
| {
|
|
157
|
+
/** Indicates this message is a response to a chat request */ type: MessageType.CF_AGENT_USE_CHAT_RESPONSE /** Unique ID of the request this response corresponds to */;
|
|
158
|
+
id: string /** Content body of the response */;
|
|
159
|
+
body: string /** Whether this is the final chunk of the response */;
|
|
160
|
+
done: boolean /** Whether this response contains an error */;
|
|
161
|
+
error?: boolean /** Whether this is a continuation (append to last assistant message) */;
|
|
162
|
+
continuation?: boolean /** Whether this chunk is being replayed from storage (stream resumption) */;
|
|
163
|
+
replay?: boolean /** Signals that replay of stored chunks is complete (stream is still active) */;
|
|
164
|
+
replayComplete?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Index of this chunk within its stream. A live chunk carries the index
|
|
167
|
+
* its replay will carry, so a client can skip replayed chunks it has
|
|
168
|
+
* already applied.
|
|
169
|
+
*/
|
|
170
|
+
seq?: number;
|
|
171
|
+
/**
|
|
172
|
+
* IDs of the user messages the originating request carried (the
|
|
173
|
+
* trailing user messages of its `messages`). Set on terminal frames
|
|
174
|
+
* (`done` or `error`), live and replayed, when the server knows them,
|
|
175
|
+
* so a client can settle exactly the sends a completion, error, or
|
|
176
|
+
* cancellation belongs to.
|
|
177
|
+
*/
|
|
178
|
+
messageIds?: string[];
|
|
179
|
+
/**
|
|
180
|
+
* How the request ended, on its terminal `done` frame. Absent means
|
|
181
|
+
* `"error"` when the frame (or an earlier frame for the request) carried
|
|
182
|
+
* `error`, and `"completed"` otherwise.
|
|
183
|
+
*/
|
|
184
|
+
outcome?: ChatTurnOutcome;
|
|
185
|
+
}
|
|
186
|
+
| {
|
|
187
|
+
/** Indicates the server is resuming an active stream */ type: MessageType.CF_AGENT_STREAM_RESUMING /** The request ID of the stream being resumed */;
|
|
188
|
+
id: string /** Present when this offer directly answers a client resume probe. */;
|
|
189
|
+
probeId?: string;
|
|
190
|
+
}
|
|
191
|
+
| {
|
|
192
|
+
/** Server notifies client that a message was updated (e.g., tool result applied) */ type: MessageType.CF_AGENT_MESSAGE_UPDATED /** The updated message */;
|
|
193
|
+
message: ChatMessage;
|
|
194
|
+
}
|
|
195
|
+
| {
|
|
196
|
+
/** Server responds to a resume request with no stream for this client. */ type: MessageType.CF_AGENT_STREAM_RESUME_NONE;
|
|
197
|
+
/**
|
|
198
|
+
* Why no stream was offered. Only `idle` proves global inactivity;
|
|
199
|
+
* omitted by older servers and by non-authoritative delayed releases.
|
|
200
|
+
*/
|
|
201
|
+
reason?: StreamResumeNoneReason /** Correlates an authoritative response to its client resume probe. */;
|
|
202
|
+
probeId?: string;
|
|
203
|
+
}
|
|
204
|
+
| {
|
|
205
|
+
/**
|
|
206
|
+
* Server signals an accepted turn whose resumable stream has not started
|
|
207
|
+
* yet — the client should keep waiting for `STREAM_RESUMING` (or a later
|
|
208
|
+
* `STREAM_RESUME_NONE`) rather than give up. See #1784.
|
|
209
|
+
*/
|
|
210
|
+
type: MessageType.CF_AGENT_STREAM_PENDING /** The accepted request id, when known. */;
|
|
211
|
+
id?: string /** Correlates a direct keep-waiting response to its client probe. */;
|
|
212
|
+
probeId?: string;
|
|
213
|
+
}
|
|
214
|
+
| {
|
|
215
|
+
/**
|
|
216
|
+
* Progress hint: a durable chat turn is being recovered (`recovering:
|
|
217
|
+
* true`) or recovery has resolved (`recovering: false`). Purely advisory;
|
|
218
|
+
* a client renders a "recovering…" indicator while true.
|
|
219
|
+
*/
|
|
220
|
+
type: MessageType.CF_AGENT_CHAT_RECOVERING /** Whether recovery is in progress (true) or has resolved (false). */;
|
|
221
|
+
recovering: boolean /** The recovery-root request id of the turn being recovered, if known. */;
|
|
222
|
+
id?: string;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Types of messages sent from clients to the Agent
|
|
226
|
+
*/
|
|
227
|
+
type IncomingMessage<ChatMessage extends UIMessage = UIMessage> =
|
|
228
|
+
| {
|
|
229
|
+
/** Indicates this message is a command to clear chat history */ type: MessageType.CF_AGENT_CHAT_CLEAR;
|
|
230
|
+
}
|
|
231
|
+
| {
|
|
232
|
+
/** Indicates this message is a request to the chat API */ type: MessageType.CF_AGENT_USE_CHAT_REQUEST /** Unique ID for this request */;
|
|
233
|
+
id: string /** Request initialization options */;
|
|
234
|
+
init: Pick<
|
|
235
|
+
RequestInit,
|
|
236
|
+
| "method"
|
|
237
|
+
| "keepalive"
|
|
238
|
+
| "headers"
|
|
239
|
+
| "body"
|
|
240
|
+
| "redirect"
|
|
241
|
+
| "integrity"
|
|
242
|
+
| "credentials"
|
|
243
|
+
| "mode"
|
|
244
|
+
| "referrer"
|
|
245
|
+
| "referrerPolicy"
|
|
246
|
+
| "window"
|
|
247
|
+
>;
|
|
248
|
+
}
|
|
249
|
+
| {
|
|
250
|
+
/** Indicates this message contains updated chat messages */ type: MessageType.CF_AGENT_CHAT_MESSAGES /** Array of chat messages */;
|
|
251
|
+
messages: ChatMessage[];
|
|
252
|
+
}
|
|
253
|
+
| {
|
|
254
|
+
/** Indicates the user wants to stop generation of this message */ type: MessageType.CF_AGENT_CHAT_REQUEST_CANCEL;
|
|
255
|
+
id: string;
|
|
256
|
+
}
|
|
257
|
+
| {
|
|
258
|
+
/** Client acknowledges stream resuming notification and is ready to receive chunks */ type: MessageType.CF_AGENT_STREAM_RESUME_ACK /** The request ID of the stream being resumed */;
|
|
259
|
+
id: string;
|
|
260
|
+
}
|
|
261
|
+
| {
|
|
262
|
+
/** Client requests stream resume check after message handler is registered */ type: MessageType.CF_AGENT_STREAM_RESUME_REQUEST /** Opaque correlation id echoed by direct server responses. */;
|
|
263
|
+
probeId?: string;
|
|
264
|
+
}
|
|
265
|
+
| {
|
|
266
|
+
/** Client sends tool result to server (for client-side tools) */ type: MessageType.CF_AGENT_TOOL_RESULT /** The tool call ID this result is for */;
|
|
267
|
+
toolCallId: string /** The name of the tool */;
|
|
268
|
+
toolName: string /** The output from the tool execution */;
|
|
269
|
+
output: unknown /** Override the tool part state (e.g. "output-error" for custom denial) */;
|
|
270
|
+
state?:
|
|
271
|
+
| "output-available"
|
|
272
|
+
| "output-error" /** Error message when state is "output-error" */;
|
|
273
|
+
errorText?: string /** Whether server should auto-continue the conversation after applying result */;
|
|
274
|
+
autoContinue?: boolean /** Client tool schemas for continuation (client is source of truth) */;
|
|
275
|
+
clientTools?: Array<{
|
|
276
|
+
name: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
parameters?: JSONSchema7;
|
|
279
|
+
}>;
|
|
280
|
+
}
|
|
281
|
+
| {
|
|
282
|
+
/** Client sends tool approval response to server (for tools with needsApproval) */ type: MessageType.CF_AGENT_TOOL_APPROVAL /** The tool call ID this approval is for */;
|
|
283
|
+
toolCallId: string /** Whether the tool execution was approved */;
|
|
284
|
+
approved: boolean /** Whether server should auto-continue the conversation after applying approval */;
|
|
285
|
+
autoContinue?: boolean;
|
|
286
|
+
};
|
|
287
|
+
//#endregion
|
|
288
|
+
export {
|
|
289
|
+
CHAT_MESSAGE_TYPES as a,
|
|
290
|
+
ClientToolExecutor as c,
|
|
291
|
+
OutgoingMessage as i,
|
|
292
|
+
ClientToolSchema as l,
|
|
293
|
+
IncomingMessage as n,
|
|
294
|
+
STREAM_RESUME_NONE_REASONS as o,
|
|
295
|
+
MessageType as r,
|
|
296
|
+
StreamResumeNoneReason as s,
|
|
297
|
+
ChatTurnOutcome as t,
|
|
298
|
+
createToolsFromClientSchemas as u
|
|
299
|
+
};
|
|
300
|
+
//# sourceMappingURL=wire-types-CrjKvDyi.d.ts.map
|
package/dist/workflow-types.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Ct as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
st as
|
|
21
|
-
ut as
|
|
22
|
-
vt as
|
|
23
|
-
wt as
|
|
24
|
-
xt as
|
|
25
|
-
yt as
|
|
26
|
-
} from "./agent-routing-
|
|
2
|
+
Ct as WorkflowInfo,
|
|
3
|
+
Dt as WorkflowRejectedError,
|
|
4
|
+
Et as WorkflowQueryCriteria,
|
|
5
|
+
Ot as WorkflowStatus,
|
|
6
|
+
St as WorkflowEventPayload,
|
|
7
|
+
Tt as WorkflowProgressCallback,
|
|
8
|
+
_t as WorkflowCallbackBase,
|
|
9
|
+
bt as WorkflowErrorCallback,
|
|
10
|
+
ct as AgentWorkflowOrigin,
|
|
11
|
+
dt as AgentWorkflowStep,
|
|
12
|
+
ft as ApprovalEventPayload,
|
|
13
|
+
gt as WorkflowCallback,
|
|
14
|
+
ht as WaitForApprovalOptions,
|
|
15
|
+
kt as WorkflowTrackingRow,
|
|
16
|
+
lt as AgentWorkflowParams,
|
|
17
|
+
mt as RunWorkflowOptions,
|
|
18
|
+
ot as AgentWorkflowEvent,
|
|
19
|
+
pt as DefaultProgress,
|
|
20
|
+
st as AgentWorkflowInternalParams,
|
|
21
|
+
ut as AgentWorkflowPathStep,
|
|
22
|
+
vt as WorkflowCallbackType,
|
|
23
|
+
wt as WorkflowPage,
|
|
24
|
+
xt as WorkflowEventCallback,
|
|
25
|
+
yt as WorkflowCompleteCallback
|
|
26
|
+
} from "./agent-routing-0DR0Tk2v.js";
|
|
27
27
|
export {
|
|
28
28
|
AgentWorkflowEvent,
|
|
29
29
|
AgentWorkflowInternalParams,
|
package/dist/workflows.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Ct as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Ct as WorkflowInfo,
|
|
3
|
+
Dt as WorkflowRejectedError,
|
|
4
|
+
Et as WorkflowQueryCriteria,
|
|
5
|
+
Ot as WorkflowStatus,
|
|
6
|
+
St as WorkflowEventPayload,
|
|
7
|
+
Tt as WorkflowProgressCallback,
|
|
8
|
+
bt as WorkflowErrorCallback,
|
|
8
9
|
c as Agent,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
lt as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from "./agent-routing-B2XLNMxq.js";
|
|
10
|
+
dt as AgentWorkflowStep,
|
|
11
|
+
ft as ApprovalEventPayload,
|
|
12
|
+
gt as WorkflowCallback,
|
|
13
|
+
ht as WaitForApprovalOptions,
|
|
14
|
+
kt as WorkflowTrackingRow,
|
|
15
|
+
lt as AgentWorkflowParams,
|
|
16
|
+
mt as RunWorkflowOptions,
|
|
17
|
+
ot as AgentWorkflowEvent,
|
|
18
|
+
pt as DefaultProgress,
|
|
19
|
+
vt as WorkflowCallbackType,
|
|
20
|
+
wt as WorkflowPage,
|
|
21
|
+
xt as WorkflowEventCallback,
|
|
22
|
+
yt as WorkflowCompleteCallback
|
|
23
|
+
} from "./agent-routing-0DR0Tk2v.js";
|
|
24
24
|
import { WorkflowEntrypoint, WorkflowEvent } from "cloudflare:workers";
|
|
25
25
|
|
|
26
26
|
//#region src/workflows.d.ts
|
package/dist/workflows.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isInternalJsStubProp } from "./utils.js";
|
|
2
2
|
import { getAgentByName } from "./agent-routing.js";
|
|
3
|
-
import "./src-
|
|
3
|
+
import "./src-BZeu-SCD.js";
|
|
4
4
|
import { WorkflowRejectedError } from "./workflow-types.js";
|
|
5
5
|
import { WorkflowEntrypoint } from "cloudflare:workers";
|
|
6
6
|
//#region src/workflows.ts
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { ChatTransport, UIMessage, UIMessageChunk } from "ai";
|
|
2
2
|
|
|
3
|
+
//#region src/chat/replay-dedupe.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Replay de-duplication for continuation streams (#1951).
|
|
6
|
+
*
|
|
7
|
+
* A continuation appends to an assistant message this client may already have
|
|
8
|
+
* rendered live. After a reconnect the server replays the continuation's
|
|
9
|
+
* whole buffer, and applying it on top of the live-rendered bytes would
|
|
10
|
+
* duplicate them. Every live and replayed chunk frame carries its index in
|
|
11
|
+
* the stream (`seq`), so a client that records how far it applied each
|
|
12
|
+
* stream can drop the replayed chunks it already has.
|
|
13
|
+
*
|
|
14
|
+
* Non-continuation replays are left alone: the client resets the message and
|
|
15
|
+
* rebuilds it from chunk 0 for those.
|
|
16
|
+
*/
|
|
17
|
+
type ChunkFrame = {
|
|
18
|
+
body?: string;
|
|
19
|
+
continuation?: boolean;
|
|
20
|
+
replay?: boolean;
|
|
21
|
+
seq?: number;
|
|
22
|
+
};
|
|
23
|
+
/** Highest chunk `seq` this client applied, per request id. */
|
|
24
|
+
declare class AppliedChunkLedger {
|
|
25
|
+
private readonly applied;
|
|
26
|
+
record(requestId: string, seq: number | undefined): void;
|
|
27
|
+
/** Whether `frame` replays a continuation chunk this client already applied. */
|
|
28
|
+
isAppliedReplay(requestId: string, frame: ChunkFrame): boolean;
|
|
29
|
+
forget(requestId: string): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
3
33
|
//#region src/chat/ws-chat-transport.d.ts
|
|
4
34
|
/**
|
|
5
35
|
* Agent-like interface for sending/receiving WebSocket messages.
|
|
@@ -7,7 +37,7 @@ import { ChatTransport, UIMessage, UIMessageChunk } from "ai";
|
|
|
7
37
|
* `useAgent` from `agents/react`.
|
|
8
38
|
*/
|
|
9
39
|
interface AgentConnection {
|
|
10
|
-
send: (data: string) => void;
|
|
40
|
+
send: (data: string) => boolean | void;
|
|
11
41
|
addEventListener: (
|
|
12
42
|
type: string,
|
|
13
43
|
listener: (event: MessageEvent) => void,
|
|
@@ -44,6 +74,13 @@ type WebSocketChatTransportOptions<ChatMessage extends UIMessage = UIMessage> =
|
|
|
44
74
|
* @default false
|
|
45
75
|
*/
|
|
46
76
|
cancelOnClientAbort?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Called when a `submit-message` request frame was buffered rather than sent
|
|
79
|
+
* immediately (the socket was not OPEN, so PartySocket queued it for the next
|
|
80
|
+
* reconnect). The hook uses this to preserve the optimistic message across the
|
|
81
|
+
* reconnect transcript replay. `messageId` is the submitted user message's id.
|
|
82
|
+
*/
|
|
83
|
+
onRequestBuffered?: (messageId: string | undefined) => void;
|
|
47
84
|
};
|
|
48
85
|
/**
|
|
49
86
|
* ChatTransport that sends messages over WebSocket and returns a
|
|
@@ -61,7 +98,13 @@ declare class WebSocketChatTransport<
|
|
|
61
98
|
private prepareBody?;
|
|
62
99
|
private activeRequestIds?;
|
|
63
100
|
private cancelOnClientAbort;
|
|
101
|
+
private onRequestBuffered?;
|
|
64
102
|
private _resumeResolver;
|
|
103
|
+
/**
|
|
104
|
+
* Continuation chunks this client applied, shared with the hook's fallback
|
|
105
|
+
* observer so a replay after reconnect skips them on either path (#1951).
|
|
106
|
+
*/
|
|
107
|
+
readonly appliedChunks: AppliedChunkLedger;
|
|
65
108
|
private _resumeNoneResolver;
|
|
66
109
|
private _onStreamPending;
|
|
67
110
|
private _retryResumeProbe;
|
|
@@ -84,6 +127,12 @@ declare class WebSocketChatTransport<
|
|
|
84
127
|
* clients can detach locally without stopping server work.
|
|
85
128
|
*/
|
|
86
129
|
cancelActiveServerTurn(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* The server turn this transport last attached to that has not reported a
|
|
132
|
+
* terminal frame. A socket close ends the local stream but keeps this set,
|
|
133
|
+
* since the server keeps running the turn.
|
|
134
|
+
*/
|
|
135
|
+
get activeServerTurnId(): string | null;
|
|
87
136
|
private sendCancelFrame;
|
|
88
137
|
private setActiveServerTurn;
|
|
89
138
|
private clearActiveServerTurn;
|
|
@@ -181,4 +230,4 @@ export {
|
|
|
181
230
|
WebSocketChatTransportOptions as r,
|
|
182
231
|
AgentConnection as t
|
|
183
232
|
};
|
|
184
|
-
//# sourceMappingURL=ws-chat-transport-
|
|
233
|
+
//# sourceMappingURL=ws-chat-transport-BbT1A5Lc.d.ts.map
|