blink 0.1.54 → 0.1.56
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/api/index.cjs +16 -9
- package/dist/api/index.d.cts +2 -265
- package/dist/api/index.d.ts +2 -265
- package/dist/api/index.js +15 -8
- package/dist/build/index.cjs +7 -0
- package/dist/build/index.d.cts +107 -0
- package/dist/build/index.d.ts +107 -0
- package/dist/build/index.js +7 -0
- package/dist/chunk-___ucjiX.js +1 -0
- package/dist/chunk-hhQzssFb.cjs +1 -0
- package/dist/cli/auth-BUNIOupD.js +30 -0
- package/dist/cli/{chat-VT2y0Ejx.js → chat-L0VBV1Zr.js} +1 -1
- package/dist/cli/connect-BHyGYU8L.js +1 -0
- package/dist/cli/connect-Cxa-uIEb.js +26 -0
- package/dist/cli/{dev-DWe1-Qrm.js → dev-DEnRzFLe.js} +421 -352
- package/dist/cli/devtools-BS9tk1Y9.js +14 -14
- package/dist/cli/{dist-CN69Y-yA.js → dist-NqrnQGst.js} +1 -1
- package/dist/cli/esm-CeJfCMPI.js +1 -1
- package/dist/cli/index.js +10 -10
- package/dist/cli/{init-CyILyaVn.js → init-B61NlodJ.js} +2 -2
- package/dist/cli/login-DKW_KVCA.js +1 -0
- package/dist/cli/undici-BG07ys6c.js +6 -6
- package/dist/cli/util-cVEGIV3r.js +9 -0
- package/dist/cli/wrapper-B4vDwpOq.js +2 -2
- package/dist/cookie-C9-j7DLy.cjs +1 -0
- package/dist/cookie-vgkq7-5W.js +1 -0
- package/dist/http/api.cjs +1 -0
- package/dist/http/api.d.cts +186 -0
- package/dist/http/api.d.ts +186 -0
- package/dist/http/api.js +1 -0
- package/dist/http/index.cjs +1 -0
- package/dist/http/index.d.cts +3 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.js +1 -0
- package/dist/http-DGkzwMDO.js +53 -0
- package/dist/http-DVkCunru.cjs +53 -0
- package/dist/index-BUiNoSbu.d.ts +286 -0
- package/dist/index-BgJpZoBy.d.cts +102 -0
- package/dist/index-DxJfaHIB.d.ts +102 -0
- package/dist/index-IWju3eNc.d.cts +286 -0
- package/dist/test.cjs +1 -4
- package/dist/test.d.cts +4 -1
- package/dist/test.d.ts +4 -1
- package/dist/test.js +1 -4
- package/package.json +17 -8
- package/dist/cli/auth-BP6XsB4o.js +0 -30
- package/dist/cli/connect-CUOPse6P.js +0 -1
- package/dist/cli/connect-CswVxp7Y.js +0 -26
- package/dist/cli/login-JR8bA13P.js +0 -1
- package/dist/cli/main-DqOlaYW2.js +0 -6
- package/dist/cli/serve-CEeYlO7w.js +0 -60
- package/dist/cli/serve-DY71nMqp.js +0 -1
- package/dist/cookie-CB9k3Awr.js +0 -11
- package/dist/cookie-Dx2Kx4Zh.cjs +0 -11
- /package/dist/cli/{open-Cr8lEmcs.js → open-CSMQaj0E.js} +0 -0
package/dist/api/index.d.cts
CHANGED
|
@@ -1,265 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { AsyncIterableStream, InferUIMessageChunk, Tool, ToolSet, UIDataTypes, UIMessage, UIMessagePart, UITools } from "ai";
|
|
4
|
-
|
|
5
|
-
//#region src/api/chat.d.ts
|
|
6
|
-
interface Chat {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
}
|
|
9
|
-
interface MessageOptions {
|
|
10
|
-
/**
|
|
11
|
-
* behavior of the chat when sending this message.
|
|
12
|
-
*
|
|
13
|
-
* - "enqueue" will add messages to the chat and start the chat eventually.
|
|
14
|
-
* - "interrupt" will interrupt the chat if running and send messages.
|
|
15
|
-
* - "append" will add messages to the chat.
|
|
16
|
-
*/
|
|
17
|
-
readonly behavior?: "enqueue" | "interrupt" | "append";
|
|
18
|
-
}
|
|
19
|
-
interface Message<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools> {
|
|
20
|
-
readonly role: UIMessage["role"];
|
|
21
|
-
readonly parts: UIMessagePart<DATA_TYPES, TOOLS>[];
|
|
22
|
-
readonly metadata?: METADATA;
|
|
23
|
-
}
|
|
24
|
-
declare const chat: Readonly<{
|
|
25
|
-
upsert: (id: string) => Promise<Chat>;
|
|
26
|
-
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
27
|
-
}>;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/api/tools.d.ts
|
|
30
|
-
/**
|
|
31
|
-
* ToolWithContext is a tool that supports the "withContext" method.
|
|
32
|
-
*
|
|
33
|
-
* @param CONTEXT The context type.
|
|
34
|
-
* @param TOOL The tool type.
|
|
35
|
-
* @returns The tool with the given context.
|
|
36
|
-
*/
|
|
37
|
-
type ToolWithContext<CONTEXT, TOOL extends Tool> = TOOL & {
|
|
38
|
-
withContext(context: CONTEXT): TOOL;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Tools are helpers for managing tools.
|
|
42
|
-
*/
|
|
43
|
-
declare const tools: {
|
|
44
|
-
/**
|
|
45
|
-
* withContext adds context to a set of tools that supports the "withContext" method.
|
|
46
|
-
*
|
|
47
|
-
* @param context
|
|
48
|
-
* @param tools
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
withContext<const TOOLS extends ToolsWithContext>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: Tool };
|
|
52
|
-
/**
|
|
53
|
-
* @internal
|
|
54
|
-
* @deprecated Use withContext instead - it's the same thing.
|
|
55
|
-
*/
|
|
56
|
-
with<const TOOLS extends ToolsWithContext>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: Tool };
|
|
57
|
-
/**
|
|
58
|
-
* withApproval ensures a set of tools need explicit user approval
|
|
59
|
-
* before they are executed.
|
|
60
|
-
*
|
|
61
|
-
* This works by replacing the execution of all provided tools with
|
|
62
|
-
* special output that interfaces must handle.
|
|
63
|
-
*
|
|
64
|
-
* On approval, the tool will be executed with the verbatim input.
|
|
65
|
-
*
|
|
66
|
-
* @returns Tools that should be sent in `streamText`.
|
|
67
|
-
*/
|
|
68
|
-
withApproval<TOOLS extends ToolSet, MESSAGE extends UIMessage>(options: {
|
|
69
|
-
messages: MESSAGE[];
|
|
70
|
-
tools: TOOLS;
|
|
71
|
-
abortSignal?: AbortSignal;
|
|
72
|
-
}): Promise<TOOLS>;
|
|
73
|
-
/**
|
|
74
|
-
* prefix adds a prefix to all the tools in a tool set.
|
|
75
|
-
*
|
|
76
|
-
* @param tools The tool set to prefix.
|
|
77
|
-
* @param prefix The prefix to add to the tools.
|
|
78
|
-
* @returns The prefixed tool set.
|
|
79
|
-
*/
|
|
80
|
-
prefix(tools: ToolSet, prefix: string): ToolSet;
|
|
81
|
-
};
|
|
82
|
-
type ToolsWithContext = Record<string, Tool & {
|
|
83
|
-
withContext(context: unknown): Tool;
|
|
84
|
-
}>;
|
|
85
|
-
type ContextFromTools<TOOLS extends ToolsWithContext> = TOOLS[keyof TOOLS] extends {
|
|
86
|
-
withContext(context: infer C): any;
|
|
87
|
-
} ? C : never;
|
|
88
|
-
/**
|
|
89
|
-
* ToolApprovalOutput is the output of a tool that requires approval.
|
|
90
|
-
*
|
|
91
|
-
* This should be consumed by the UI to display an approval prompt.
|
|
92
|
-
*/
|
|
93
|
-
interface ToolApprovalOutput {
|
|
94
|
-
type: "tool-approval";
|
|
95
|
-
outcome: "pending" | "approved" | "rejected";
|
|
96
|
-
reason?: string;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* isToolApprovalOutput checks if an output is a tool approval output.
|
|
100
|
-
*/
|
|
101
|
-
declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/api/storage.d.ts
|
|
104
|
-
/**
|
|
105
|
-
* Storage allows agents to persist data.
|
|
106
|
-
* Every agent has it's own persistent storage namespace.
|
|
107
|
-
*/
|
|
108
|
-
declare const storage: Readonly<{
|
|
109
|
-
kv: Readonly<{
|
|
110
|
-
get: (key: string) => Promise<string | undefined>;
|
|
111
|
-
set: (key: string, value: string) => Promise<void>;
|
|
112
|
-
del: (key: string) => Promise<void>;
|
|
113
|
-
}>;
|
|
114
|
-
}>;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/api/index.d.ts
|
|
117
|
-
/**
|
|
118
|
-
* SendMessagesResponse is the response of the sendMessages function.
|
|
119
|
-
* It can be a stream of messages or an arbitrary response.
|
|
120
|
-
*/
|
|
121
|
-
type SendMessagesResponse = {
|
|
122
|
-
toUIMessageStream(): AsyncIterableStream<InferUIMessageChunk<UIMessage>>;
|
|
123
|
-
} | Response | ReadableStream<InferUIMessageChunk<UIMessage>>;
|
|
124
|
-
/**
|
|
125
|
-
* SendMessagesOptions is the options for the sendMessages function.
|
|
126
|
-
*/
|
|
127
|
-
interface SendMessagesOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
128
|
-
/**
|
|
129
|
-
* Messages are all messages for the history of the chat.
|
|
130
|
-
* It is the user's responsibility to manage context for the chat.
|
|
131
|
-
*/
|
|
132
|
-
readonly messages: MESSAGE[];
|
|
133
|
-
/**
|
|
134
|
-
* Chat is the associated chat for the messages.
|
|
135
|
-
*/
|
|
136
|
-
readonly chat: Chat;
|
|
137
|
-
/**
|
|
138
|
-
* abortSignal can be used to terminate streaming operations
|
|
139
|
-
* immediately when the streaming request ends.
|
|
140
|
-
*/
|
|
141
|
-
readonly abortSignal?: AbortSignal;
|
|
142
|
-
}
|
|
143
|
-
interface ExperimentalProvideCompletionsOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
144
|
-
/**
|
|
145
|
-
* The chat for the completions.
|
|
146
|
-
* Omitted if there is no chat.
|
|
147
|
-
*/
|
|
148
|
-
readonly chat?: Chat;
|
|
149
|
-
/**
|
|
150
|
-
* Messages that are part of the current chat.
|
|
151
|
-
* Omitted if there is no chat.
|
|
152
|
-
*/
|
|
153
|
-
readonly messages?: MESSAGE[];
|
|
154
|
-
readonly input: string;
|
|
155
|
-
readonly caret: number;
|
|
156
|
-
readonly selection?: [number, number];
|
|
157
|
-
readonly abortSignal?: AbortSignal;
|
|
158
|
-
}
|
|
159
|
-
type ExperimentalCompletion = {
|
|
160
|
-
text: string;
|
|
161
|
-
replace?: [number, number];
|
|
162
|
-
} | {
|
|
163
|
-
id: string;
|
|
164
|
-
label: string;
|
|
165
|
-
detail?: string;
|
|
166
|
-
insertText?: string;
|
|
167
|
-
replace?: [number, number];
|
|
168
|
-
};
|
|
169
|
-
type ExperimentalProvideCompletionsResponse = ReadableStream<ExperimentalCompletion> | Promise<ReadableStream<ExperimentalCompletion>> | Promise<ExperimentalCompletion> | ExperimentalCompletion;
|
|
170
|
-
interface Agent<MESSAGE extends UIMessage = UIMessage> {
|
|
171
|
-
/**
|
|
172
|
-
* sendMessages is called when the agent is streaming chat messages.
|
|
173
|
-
* This is invoked on chat creation, and can be programatically
|
|
174
|
-
* invoked at any time with `blink.chat.message`.
|
|
175
|
-
*/
|
|
176
|
-
sendMessages(options: SendMessagesOptions<MESSAGE>): Promise<SendMessagesResponse> | SendMessagesResponse;
|
|
177
|
-
/**
|
|
178
|
-
* onRequest is called when the agent receives a request.
|
|
179
|
-
* This is for handling webhooks, or incoming client payloads
|
|
180
|
-
* that warrant a response.
|
|
181
|
-
*
|
|
182
|
-
* @param request The request received by the agent.
|
|
183
|
-
* @returns A response to the request. If void, the agent will
|
|
184
|
-
* respond with a 404.
|
|
185
|
-
*/
|
|
186
|
-
onRequest?(request: Request): Promise<Response | void>;
|
|
187
|
-
/**
|
|
188
|
-
* experimental_provideCompletions is called when the user is typing in the chat input.
|
|
189
|
-
* This is used to provide completions to the user.
|
|
190
|
-
*
|
|
191
|
-
* *NOTE*: This *only* works in the browser at the moment.
|
|
192
|
-
*
|
|
193
|
-
* @param options The options for the completions.
|
|
194
|
-
* @returns A stream of completions, or a single completion.
|
|
195
|
-
*/
|
|
196
|
-
experimental_provideCompletions?(options: ExperimentalProvideCompletionsOptions<MESSAGE>): ExperimentalProvideCompletionsResponse;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* AgentDefaultExport is the expected default export of a compiled agent.
|
|
200
|
-
* All routing logic is handled by the agent function.
|
|
201
|
-
*
|
|
202
|
-
* This maximizes flexibility over the agent's behavior -
|
|
203
|
-
* allowing users to add arbitrary routing logic to the agent.
|
|
204
|
-
*/
|
|
205
|
-
type AgentDefaultExport = {
|
|
206
|
-
readonly version: "v0";
|
|
207
|
-
fetch: (request: Request) => Promise<Response> | Response;
|
|
208
|
-
readonly supportsRequests?: boolean;
|
|
209
|
-
readonly supportsCompletions?: boolean;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* agent is the main function to create a Blink agent.
|
|
213
|
-
*
|
|
214
|
-
* @param agent
|
|
215
|
-
* @returns
|
|
216
|
-
*/
|
|
217
|
-
declare function agent<MESSAGE extends UIMessage = UIMessage>(agent: Agent<MESSAGE>): AgentDefaultExport;
|
|
218
|
-
type StreamResponseFormat = "ui-message" | "openai-chat" | "openai-response" | "anthropic" | "google" | "xai";
|
|
219
|
-
declare function withResponseFormat(response: Response, format: StreamResponseFormat): Response;
|
|
220
|
-
/**
|
|
221
|
-
* model returns an AI SDK model that is authenticated through Blink.
|
|
222
|
-
*
|
|
223
|
-
* Blink's AI Gateway uses Vercel's AI Gateway under-the-hood, and passes
|
|
224
|
-
* through billing cost without any upcharge.
|
|
225
|
-
*
|
|
226
|
-
* Feel free to use any provide you'd like.
|
|
227
|
-
*
|
|
228
|
-
* @param modelName - See: https://vercel.com/ai-gateway/models
|
|
229
|
-
* @returns An AI SDK model that is authenticated through Blink.
|
|
230
|
-
*/
|
|
231
|
-
declare const model: (modelName: string) => _ai_sdk_provider0.LanguageModelV2;
|
|
232
|
-
declare const _default: {
|
|
233
|
-
agent: typeof agent;
|
|
234
|
-
chat: Readonly<{
|
|
235
|
-
upsert: (id: string) => Promise<Chat>;
|
|
236
|
-
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
237
|
-
}>;
|
|
238
|
-
storage: Readonly<{
|
|
239
|
-
kv: Readonly<{
|
|
240
|
-
get: (key: string) => Promise<string | undefined>;
|
|
241
|
-
set: (key: string, value: string) => Promise<void>;
|
|
242
|
-
del: (key: string) => Promise<void>;
|
|
243
|
-
}>;
|
|
244
|
-
}>;
|
|
245
|
-
tools: {
|
|
246
|
-
withContext<const TOOLS extends {
|
|
247
|
-
[x: string]: ai0.Tool & {
|
|
248
|
-
withContext(context: unknown): ai0.Tool;
|
|
249
|
-
};
|
|
250
|
-
}>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: ai0.Tool };
|
|
251
|
-
with<const TOOLS extends {
|
|
252
|
-
[x: string]: ai0.Tool & {
|
|
253
|
-
withContext(context: unknown): ai0.Tool;
|
|
254
|
-
};
|
|
255
|
-
}>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: ai0.Tool };
|
|
256
|
-
withApproval<TOOLS extends ai0.ToolSet, MESSAGE extends UIMessage>(options: {
|
|
257
|
-
messages: MESSAGE[];
|
|
258
|
-
tools: TOOLS;
|
|
259
|
-
abortSignal?: AbortSignal;
|
|
260
|
-
}): Promise<TOOLS>;
|
|
261
|
-
prefix(tools: ai0.ToolSet, prefix: string): ai0.ToolSet;
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
//#endregion
|
|
265
|
-
export { Agent, AgentDefaultExport, Chat, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, agent, chat, _default as default, isToolApprovalOutput, model, storage, tools, withResponseFormat };
|
|
1
|
+
import { Agent, AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, ServeOptions, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, _default, agent, chat, isToolApprovalOutput, model, storage, tools, withResponseFormat } from "../index-IWju3eNc.cjs";
|
|
2
|
+
export { Agent, AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, ServeOptions, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, agent, chat, _default as default, isToolApprovalOutput, model, storage, tools, withResponseFormat };
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,265 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { AsyncIterableStream, InferUIMessageChunk, Tool, ToolSet, UIDataTypes, UIMessage, UIMessagePart, UITools } from "ai";
|
|
4
|
-
|
|
5
|
-
//#region src/api/chat.d.ts
|
|
6
|
-
interface Chat {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
}
|
|
9
|
-
interface MessageOptions {
|
|
10
|
-
/**
|
|
11
|
-
* behavior of the chat when sending this message.
|
|
12
|
-
*
|
|
13
|
-
* - "enqueue" will add messages to the chat and start the chat eventually.
|
|
14
|
-
* - "interrupt" will interrupt the chat if running and send messages.
|
|
15
|
-
* - "append" will add messages to the chat.
|
|
16
|
-
*/
|
|
17
|
-
readonly behavior?: "enqueue" | "interrupt" | "append";
|
|
18
|
-
}
|
|
19
|
-
interface Message<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools> {
|
|
20
|
-
readonly role: UIMessage["role"];
|
|
21
|
-
readonly parts: UIMessagePart<DATA_TYPES, TOOLS>[];
|
|
22
|
-
readonly metadata?: METADATA;
|
|
23
|
-
}
|
|
24
|
-
declare const chat: Readonly<{
|
|
25
|
-
upsert: (id: string) => Promise<Chat>;
|
|
26
|
-
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
27
|
-
}>;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/api/tools.d.ts
|
|
30
|
-
/**
|
|
31
|
-
* ToolWithContext is a tool that supports the "withContext" method.
|
|
32
|
-
*
|
|
33
|
-
* @param CONTEXT The context type.
|
|
34
|
-
* @param TOOL The tool type.
|
|
35
|
-
* @returns The tool with the given context.
|
|
36
|
-
*/
|
|
37
|
-
type ToolWithContext<CONTEXT, TOOL extends Tool> = TOOL & {
|
|
38
|
-
withContext(context: CONTEXT): TOOL;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Tools are helpers for managing tools.
|
|
42
|
-
*/
|
|
43
|
-
declare const tools: {
|
|
44
|
-
/**
|
|
45
|
-
* withContext adds context to a set of tools that supports the "withContext" method.
|
|
46
|
-
*
|
|
47
|
-
* @param context
|
|
48
|
-
* @param tools
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
withContext<const TOOLS extends ToolsWithContext>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: Tool };
|
|
52
|
-
/**
|
|
53
|
-
* @internal
|
|
54
|
-
* @deprecated Use withContext instead - it's the same thing.
|
|
55
|
-
*/
|
|
56
|
-
with<const TOOLS extends ToolsWithContext>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: Tool };
|
|
57
|
-
/**
|
|
58
|
-
* withApproval ensures a set of tools need explicit user approval
|
|
59
|
-
* before they are executed.
|
|
60
|
-
*
|
|
61
|
-
* This works by replacing the execution of all provided tools with
|
|
62
|
-
* special output that interfaces must handle.
|
|
63
|
-
*
|
|
64
|
-
* On approval, the tool will be executed with the verbatim input.
|
|
65
|
-
*
|
|
66
|
-
* @returns Tools that should be sent in `streamText`.
|
|
67
|
-
*/
|
|
68
|
-
withApproval<TOOLS extends ToolSet, MESSAGE extends UIMessage>(options: {
|
|
69
|
-
messages: MESSAGE[];
|
|
70
|
-
tools: TOOLS;
|
|
71
|
-
abortSignal?: AbortSignal;
|
|
72
|
-
}): Promise<TOOLS>;
|
|
73
|
-
/**
|
|
74
|
-
* prefix adds a prefix to all the tools in a tool set.
|
|
75
|
-
*
|
|
76
|
-
* @param tools The tool set to prefix.
|
|
77
|
-
* @param prefix The prefix to add to the tools.
|
|
78
|
-
* @returns The prefixed tool set.
|
|
79
|
-
*/
|
|
80
|
-
prefix(tools: ToolSet, prefix: string): ToolSet;
|
|
81
|
-
};
|
|
82
|
-
type ToolsWithContext = Record<string, Tool & {
|
|
83
|
-
withContext(context: unknown): Tool;
|
|
84
|
-
}>;
|
|
85
|
-
type ContextFromTools<TOOLS extends ToolsWithContext> = TOOLS[keyof TOOLS] extends {
|
|
86
|
-
withContext(context: infer C): any;
|
|
87
|
-
} ? C : never;
|
|
88
|
-
/**
|
|
89
|
-
* ToolApprovalOutput is the output of a tool that requires approval.
|
|
90
|
-
*
|
|
91
|
-
* This should be consumed by the UI to display an approval prompt.
|
|
92
|
-
*/
|
|
93
|
-
interface ToolApprovalOutput {
|
|
94
|
-
type: "tool-approval";
|
|
95
|
-
outcome: "pending" | "approved" | "rejected";
|
|
96
|
-
reason?: string;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* isToolApprovalOutput checks if an output is a tool approval output.
|
|
100
|
-
*/
|
|
101
|
-
declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/api/storage.d.ts
|
|
104
|
-
/**
|
|
105
|
-
* Storage allows agents to persist data.
|
|
106
|
-
* Every agent has it's own persistent storage namespace.
|
|
107
|
-
*/
|
|
108
|
-
declare const storage: Readonly<{
|
|
109
|
-
kv: Readonly<{
|
|
110
|
-
get: (key: string) => Promise<string | undefined>;
|
|
111
|
-
set: (key: string, value: string) => Promise<void>;
|
|
112
|
-
del: (key: string) => Promise<void>;
|
|
113
|
-
}>;
|
|
114
|
-
}>;
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/api/index.d.ts
|
|
117
|
-
/**
|
|
118
|
-
* SendMessagesResponse is the response of the sendMessages function.
|
|
119
|
-
* It can be a stream of messages or an arbitrary response.
|
|
120
|
-
*/
|
|
121
|
-
type SendMessagesResponse = {
|
|
122
|
-
toUIMessageStream(): AsyncIterableStream<InferUIMessageChunk<UIMessage>>;
|
|
123
|
-
} | Response | ReadableStream<InferUIMessageChunk<UIMessage>>;
|
|
124
|
-
/**
|
|
125
|
-
* SendMessagesOptions is the options for the sendMessages function.
|
|
126
|
-
*/
|
|
127
|
-
interface SendMessagesOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
128
|
-
/**
|
|
129
|
-
* Messages are all messages for the history of the chat.
|
|
130
|
-
* It is the user's responsibility to manage context for the chat.
|
|
131
|
-
*/
|
|
132
|
-
readonly messages: MESSAGE[];
|
|
133
|
-
/**
|
|
134
|
-
* Chat is the associated chat for the messages.
|
|
135
|
-
*/
|
|
136
|
-
readonly chat: Chat;
|
|
137
|
-
/**
|
|
138
|
-
* abortSignal can be used to terminate streaming operations
|
|
139
|
-
* immediately when the streaming request ends.
|
|
140
|
-
*/
|
|
141
|
-
readonly abortSignal?: AbortSignal;
|
|
142
|
-
}
|
|
143
|
-
interface ExperimentalProvideCompletionsOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
144
|
-
/**
|
|
145
|
-
* The chat for the completions.
|
|
146
|
-
* Omitted if there is no chat.
|
|
147
|
-
*/
|
|
148
|
-
readonly chat?: Chat;
|
|
149
|
-
/**
|
|
150
|
-
* Messages that are part of the current chat.
|
|
151
|
-
* Omitted if there is no chat.
|
|
152
|
-
*/
|
|
153
|
-
readonly messages?: MESSAGE[];
|
|
154
|
-
readonly input: string;
|
|
155
|
-
readonly caret: number;
|
|
156
|
-
readonly selection?: [number, number];
|
|
157
|
-
readonly abortSignal?: AbortSignal;
|
|
158
|
-
}
|
|
159
|
-
type ExperimentalCompletion = {
|
|
160
|
-
text: string;
|
|
161
|
-
replace?: [number, number];
|
|
162
|
-
} | {
|
|
163
|
-
id: string;
|
|
164
|
-
label: string;
|
|
165
|
-
detail?: string;
|
|
166
|
-
insertText?: string;
|
|
167
|
-
replace?: [number, number];
|
|
168
|
-
};
|
|
169
|
-
type ExperimentalProvideCompletionsResponse = ReadableStream<ExperimentalCompletion> | Promise<ReadableStream<ExperimentalCompletion>> | Promise<ExperimentalCompletion> | ExperimentalCompletion;
|
|
170
|
-
interface Agent<MESSAGE extends UIMessage = UIMessage> {
|
|
171
|
-
/**
|
|
172
|
-
* sendMessages is called when the agent is streaming chat messages.
|
|
173
|
-
* This is invoked on chat creation, and can be programatically
|
|
174
|
-
* invoked at any time with `blink.chat.message`.
|
|
175
|
-
*/
|
|
176
|
-
sendMessages(options: SendMessagesOptions<MESSAGE>): Promise<SendMessagesResponse> | SendMessagesResponse;
|
|
177
|
-
/**
|
|
178
|
-
* onRequest is called when the agent receives a request.
|
|
179
|
-
* This is for handling webhooks, or incoming client payloads
|
|
180
|
-
* that warrant a response.
|
|
181
|
-
*
|
|
182
|
-
* @param request The request received by the agent.
|
|
183
|
-
* @returns A response to the request. If void, the agent will
|
|
184
|
-
* respond with a 404.
|
|
185
|
-
*/
|
|
186
|
-
onRequest?(request: Request): Promise<Response | void>;
|
|
187
|
-
/**
|
|
188
|
-
* experimental_provideCompletions is called when the user is typing in the chat input.
|
|
189
|
-
* This is used to provide completions to the user.
|
|
190
|
-
*
|
|
191
|
-
* *NOTE*: This *only* works in the browser at the moment.
|
|
192
|
-
*
|
|
193
|
-
* @param options The options for the completions.
|
|
194
|
-
* @returns A stream of completions, or a single completion.
|
|
195
|
-
*/
|
|
196
|
-
experimental_provideCompletions?(options: ExperimentalProvideCompletionsOptions<MESSAGE>): ExperimentalProvideCompletionsResponse;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* AgentDefaultExport is the expected default export of a compiled agent.
|
|
200
|
-
* All routing logic is handled by the agent function.
|
|
201
|
-
*
|
|
202
|
-
* This maximizes flexibility over the agent's behavior -
|
|
203
|
-
* allowing users to add arbitrary routing logic to the agent.
|
|
204
|
-
*/
|
|
205
|
-
type AgentDefaultExport = {
|
|
206
|
-
readonly version: "v0";
|
|
207
|
-
fetch: (request: Request) => Promise<Response> | Response;
|
|
208
|
-
readonly supportsRequests?: boolean;
|
|
209
|
-
readonly supportsCompletions?: boolean;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* agent is the main function to create a Blink agent.
|
|
213
|
-
*
|
|
214
|
-
* @param agent
|
|
215
|
-
* @returns
|
|
216
|
-
*/
|
|
217
|
-
declare function agent<MESSAGE extends UIMessage = UIMessage>(agent: Agent<MESSAGE>): AgentDefaultExport;
|
|
218
|
-
type StreamResponseFormat = "ui-message" | "openai-chat" | "openai-response" | "anthropic" | "google" | "xai";
|
|
219
|
-
declare function withResponseFormat(response: Response, format: StreamResponseFormat): Response;
|
|
220
|
-
/**
|
|
221
|
-
* model returns an AI SDK model that is authenticated through Blink.
|
|
222
|
-
*
|
|
223
|
-
* Blink's AI Gateway uses Vercel's AI Gateway under-the-hood, and passes
|
|
224
|
-
* through billing cost without any upcharge.
|
|
225
|
-
*
|
|
226
|
-
* Feel free to use any provide you'd like.
|
|
227
|
-
*
|
|
228
|
-
* @param modelName - See: https://vercel.com/ai-gateway/models
|
|
229
|
-
* @returns An AI SDK model that is authenticated through Blink.
|
|
230
|
-
*/
|
|
231
|
-
declare const model: (modelName: string) => _ai_sdk_provider0.LanguageModelV2;
|
|
232
|
-
declare const _default: {
|
|
233
|
-
agent: typeof agent;
|
|
234
|
-
chat: Readonly<{
|
|
235
|
-
upsert: (id: string) => Promise<Chat>;
|
|
236
|
-
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
237
|
-
}>;
|
|
238
|
-
storage: Readonly<{
|
|
239
|
-
kv: Readonly<{
|
|
240
|
-
get: (key: string) => Promise<string | undefined>;
|
|
241
|
-
set: (key: string, value: string) => Promise<void>;
|
|
242
|
-
del: (key: string) => Promise<void>;
|
|
243
|
-
}>;
|
|
244
|
-
}>;
|
|
245
|
-
tools: {
|
|
246
|
-
withContext<const TOOLS extends {
|
|
247
|
-
[x: string]: ai0.Tool & {
|
|
248
|
-
withContext(context: unknown): ai0.Tool;
|
|
249
|
-
};
|
|
250
|
-
}>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: ai0.Tool };
|
|
251
|
-
with<const TOOLS extends {
|
|
252
|
-
[x: string]: ai0.Tool & {
|
|
253
|
-
withContext(context: unknown): ai0.Tool;
|
|
254
|
-
};
|
|
255
|
-
}>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: ai0.Tool };
|
|
256
|
-
withApproval<TOOLS extends ai0.ToolSet, MESSAGE extends UIMessage>(options: {
|
|
257
|
-
messages: MESSAGE[];
|
|
258
|
-
tools: TOOLS;
|
|
259
|
-
abortSignal?: AbortSignal;
|
|
260
|
-
}): Promise<TOOLS>;
|
|
261
|
-
prefix(tools: ai0.ToolSet, prefix: string): ai0.ToolSet;
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
//#endregion
|
|
265
|
-
export { Agent, AgentDefaultExport, Chat, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, agent, chat, _default as default, isToolApprovalOutput, model, storage, tools, withResponseFormat };
|
|
1
|
+
import { Agent, AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, ServeOptions, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, _default, agent, chat, isToolApprovalOutput, model, storage, tools, withResponseFormat } from "../index-BUiNoSbu.js";
|
|
2
|
+
export { Agent, AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, ServeOptions, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, agent, chat, _default as default, isToolApprovalOutput, model, storage, tools, withResponseFormat };
|