blink 0.1.54 → 0.1.55
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-Dw-wJ1IM.js +30 -0
- package/dist/cli/{chat-VT2y0Ejx.js → chat-CvTLq5E0.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-Kje8z9kN.js} +415 -340
- package/dist/cli/devtools-BS9tk1Y9.js +14 -14
- package/dist/cli/dist-CN69Y-yA.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-x07jlFqm.js} +2 -2
- package/dist/cli/login-KHDcJ0iZ.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/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-BAfeJhFm.js +53 -0
- package/dist/http-DS8vmbQx.cjs +53 -0
- package/dist/index-BgJpZoBy.d.cts +102 -0
- package/dist/index-IWju3eNc.d.cts +286 -0
- package/dist/index-auvvMWNH.d.ts +102 -0
- package/dist/index-tvf1rglX.d.ts +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 +12 -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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Chat, ExperimentalCompletion } from "./index-IWju3eNc.cjs";
|
|
2
|
+
import { UIMessage, UIMessageChunk } from "ai";
|
|
3
|
+
|
|
4
|
+
//#region src/http/async-iterable-stream.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A type that combines AsyncIterable and ReadableStream.
|
|
7
|
+
* This allows a ReadableStream to be consumed using for-await-of syntax.
|
|
8
|
+
*/
|
|
9
|
+
type AsyncIterableStream$1<T> = AsyncIterable<T> & ReadableStream<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a ReadableStream and returns an object that is both a ReadableStream and an AsyncIterable.
|
|
12
|
+
* This enables consumption of the stream using for-await-of, with proper resource cleanup on early exit or error.
|
|
13
|
+
*
|
|
14
|
+
* @template T The type of the stream's chunks.
|
|
15
|
+
* @param source The source ReadableStream to wrap.
|
|
16
|
+
* @returns An AsyncIterableStream that can be used as both a ReadableStream and an AsyncIterable.
|
|
17
|
+
*/
|
|
18
|
+
declare function createAsyncIterableStream<T>(source: ReadableStream<T>): AsyncIterableStream$1<T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/api/internal/client.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* APIServerURLEnvironmentVariable is the environment variable that
|
|
23
|
+
* the Blink agent uses for executions to the `blink.*` API.
|
|
24
|
+
* (e.g. blink.chat.upsert).
|
|
25
|
+
*/
|
|
26
|
+
declare const APIServerURLEnvironmentVariable = "BLINK_API_SERVER_URL";
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/http/client.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* StreamResponseFormatHeader indicates to a client the stream response
|
|
31
|
+
* format that the agent is using.
|
|
32
|
+
*/
|
|
33
|
+
declare const StreamResponseFormatHeader = "x-blink-stream-response-format";
|
|
34
|
+
/**
|
|
35
|
+
* SendMessagesRequest is the request format of the `/_agent/send-messages` endpoint.
|
|
36
|
+
*
|
|
37
|
+
* It executes the `sendMessages` function.
|
|
38
|
+
*/
|
|
39
|
+
interface SendMessagesRequest {
|
|
40
|
+
readonly messages: UIMessage[];
|
|
41
|
+
readonly chat: Chat;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* ExperimentalProvideCompletionsRequest is the request format of the `/_agent/completions` endpoint.
|
|
45
|
+
*
|
|
46
|
+
* It executes the `experimental_provideCompletions` function.
|
|
47
|
+
*/
|
|
48
|
+
interface ExperimentalProvideCompletionsRequest {
|
|
49
|
+
readonly messages: UIMessage[];
|
|
50
|
+
readonly chat?: Chat;
|
|
51
|
+
readonly input: string;
|
|
52
|
+
readonly caret: number;
|
|
53
|
+
readonly selection?: [number, number];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* CapabilitiesResponse is the response format of the `/_agent/capabilities` endpoint.
|
|
57
|
+
*
|
|
58
|
+
* It indicates whether the agent supports requests and completions.
|
|
59
|
+
*/
|
|
60
|
+
interface CapabilitiesResponse {
|
|
61
|
+
readonly requests: boolean;
|
|
62
|
+
readonly completions: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface ClientOptions {
|
|
65
|
+
readonly baseUrl: string;
|
|
66
|
+
readonly headers?: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Client is a client for the Blink agent HTTP API.
|
|
70
|
+
*/
|
|
71
|
+
declare class Client {
|
|
72
|
+
private readonly options;
|
|
73
|
+
constructor(options: ClientOptions);
|
|
74
|
+
get baseUrl(): string;
|
|
75
|
+
/**
|
|
76
|
+
* sendMessages sends messages to the agent.
|
|
77
|
+
*
|
|
78
|
+
* The response format is automatically converted to a UI message stream.
|
|
79
|
+
*/
|
|
80
|
+
sendMessages(request: SendMessagesRequest, options?: {
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
}): Promise<AsyncIterableStream$1<UIMessageChunk>>;
|
|
83
|
+
/**
|
|
84
|
+
* experimental_provideCompletions provides completions to the user.
|
|
85
|
+
* This is used to provide completions to the user.
|
|
86
|
+
*/
|
|
87
|
+
experimental_provideCompletions(request: ExperimentalProvideCompletionsRequest): Promise<AsyncIterableStream$1<ExperimentalCompletion>>;
|
|
88
|
+
/**
|
|
89
|
+
* capabilities returns the capabilities of the agent.
|
|
90
|
+
* This is used to check if the agent supports requests and completions.
|
|
91
|
+
*/
|
|
92
|
+
capabilities(): Promise<CapabilitiesResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* health simply returns a 200 response.
|
|
95
|
+
* This is used to check if the agent is running.
|
|
96
|
+
*/
|
|
97
|
+
health(): Promise<void>;
|
|
98
|
+
private handleError;
|
|
99
|
+
}
|
|
100
|
+
declare const streamSSE: <T>(resp: Response) => AsyncIterableStream$1<T>;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { APIServerURLEnvironmentVariable, AsyncIterableStream$1 as AsyncIterableStream, CapabilitiesResponse, Client, ClientOptions, ExperimentalProvideCompletionsRequest, SendMessagesRequest, StreamResponseFormatHeader, createAsyncIterableStream, streamSSE };
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import * as _ai_sdk_provider0 from "@ai-sdk/provider";
|
|
2
|
+
import * as ai0 from "ai";
|
|
3
|
+
import { AsyncIterableStream, InferUIMessageChunk, Tool, ToolSet, UIDataTypes, UIMessage, UIMessagePart, UITools } from "ai";
|
|
4
|
+
import http from "http";
|
|
5
|
+
|
|
6
|
+
//#region src/api/chat.d.ts
|
|
7
|
+
interface Chat {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
}
|
|
10
|
+
type ChatBehavior = "enqueue" | "interrupt" | "append";
|
|
11
|
+
interface MessageOptions {
|
|
12
|
+
/**
|
|
13
|
+
* behavior of the chat when sending this message.
|
|
14
|
+
*
|
|
15
|
+
* - "enqueue" will add messages to the chat and start the chat eventually.
|
|
16
|
+
* - "interrupt" will interrupt the chat if running and send messages.
|
|
17
|
+
* - "append" will add messages to the chat.
|
|
18
|
+
*/
|
|
19
|
+
readonly behavior?: ChatBehavior;
|
|
20
|
+
}
|
|
21
|
+
interface Message<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools> {
|
|
22
|
+
readonly role: UIMessage["role"];
|
|
23
|
+
readonly parts: UIMessagePart<DATA_TYPES, TOOLS>[];
|
|
24
|
+
readonly metadata?: METADATA;
|
|
25
|
+
}
|
|
26
|
+
declare const chat: Readonly<{
|
|
27
|
+
upsert: (id: string) => Promise<Chat>;
|
|
28
|
+
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
29
|
+
}>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/api/tools.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* ToolWithContext is a tool that supports the "withContext" method.
|
|
34
|
+
*
|
|
35
|
+
* @param CONTEXT The context type.
|
|
36
|
+
* @param TOOL The tool type.
|
|
37
|
+
* @returns The tool with the given context.
|
|
38
|
+
*/
|
|
39
|
+
type ToolWithContext<CONTEXT, TOOL extends Tool> = TOOL & {
|
|
40
|
+
withContext(context: CONTEXT): TOOL;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Tools are helpers for managing tools.
|
|
44
|
+
*/
|
|
45
|
+
declare const tools: {
|
|
46
|
+
/**
|
|
47
|
+
* withContext adds context to a set of tools that supports the "withContext" method.
|
|
48
|
+
*
|
|
49
|
+
* @param context
|
|
50
|
+
* @param tools
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
withContext<const TOOLS extends ToolsWithContext>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: Tool };
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
* @deprecated Use withContext instead - it's the same thing.
|
|
57
|
+
*/
|
|
58
|
+
with<const TOOLS extends ToolsWithContext>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: Tool };
|
|
59
|
+
/**
|
|
60
|
+
* withApproval ensures a set of tools need explicit user approval
|
|
61
|
+
* before they are executed.
|
|
62
|
+
*
|
|
63
|
+
* This works by replacing the execution of all provided tools with
|
|
64
|
+
* special output that interfaces must handle.
|
|
65
|
+
*
|
|
66
|
+
* On approval, the tool will be executed with the verbatim input.
|
|
67
|
+
*
|
|
68
|
+
* @returns Tools that should be sent in `streamText`.
|
|
69
|
+
*/
|
|
70
|
+
withApproval<TOOLS extends ToolSet, MESSAGE extends UIMessage>(options: {
|
|
71
|
+
messages: MESSAGE[];
|
|
72
|
+
tools: TOOLS;
|
|
73
|
+
abortSignal?: AbortSignal;
|
|
74
|
+
}): Promise<TOOLS>;
|
|
75
|
+
/**
|
|
76
|
+
* prefix adds a prefix to all the tools in a tool set.
|
|
77
|
+
*
|
|
78
|
+
* @param tools The tool set to prefix.
|
|
79
|
+
* @param prefix The prefix to add to the tools.
|
|
80
|
+
* @returns The prefixed tool set.
|
|
81
|
+
*/
|
|
82
|
+
prefix(tools: ToolSet, prefix: string): ToolSet;
|
|
83
|
+
};
|
|
84
|
+
type ToolsWithContext = Record<string, Tool & {
|
|
85
|
+
withContext(context: unknown): Tool;
|
|
86
|
+
}>;
|
|
87
|
+
type ContextFromTools<TOOLS extends ToolsWithContext> = TOOLS[keyof TOOLS] extends {
|
|
88
|
+
withContext(context: infer C): any;
|
|
89
|
+
} ? C : never;
|
|
90
|
+
/**
|
|
91
|
+
* ToolApprovalOutput is the output of a tool that requires approval.
|
|
92
|
+
*
|
|
93
|
+
* This should be consumed by the UI to display an approval prompt.
|
|
94
|
+
*/
|
|
95
|
+
interface ToolApprovalOutput {
|
|
96
|
+
type: "tool-approval";
|
|
97
|
+
outcome: "pending" | "approved" | "rejected";
|
|
98
|
+
reason?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* isToolApprovalOutput checks if an output is a tool approval output.
|
|
102
|
+
*/
|
|
103
|
+
declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/api/storage.d.ts
|
|
106
|
+
/**
|
|
107
|
+
* Storage allows agents to persist data.
|
|
108
|
+
* Every agent has it's own persistent storage namespace.
|
|
109
|
+
*/
|
|
110
|
+
declare const storage: Readonly<{
|
|
111
|
+
kv: Readonly<{
|
|
112
|
+
get: (key: string) => Promise<string | undefined>;
|
|
113
|
+
set: (key: string, value: string) => Promise<void>;
|
|
114
|
+
del: (key: string) => Promise<void>;
|
|
115
|
+
}>;
|
|
116
|
+
}>;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/api/index.d.ts
|
|
119
|
+
/**
|
|
120
|
+
* SendMessagesResponse is the response of the sendMessages function.
|
|
121
|
+
* It can be a stream of messages or an arbitrary response.
|
|
122
|
+
*/
|
|
123
|
+
type SendMessagesResponse = {
|
|
124
|
+
toUIMessageStream(): AsyncIterableStream<InferUIMessageChunk<UIMessage>>;
|
|
125
|
+
} | Response | ReadableStream<InferUIMessageChunk<UIMessage>>;
|
|
126
|
+
/**
|
|
127
|
+
* SendMessagesOptions is the options for the sendMessages function.
|
|
128
|
+
*/
|
|
129
|
+
interface SendMessagesOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
130
|
+
/**
|
|
131
|
+
* Messages are all messages for the history of the chat.
|
|
132
|
+
* It is the user's responsibility to manage context for the chat.
|
|
133
|
+
*/
|
|
134
|
+
readonly messages: MESSAGE[];
|
|
135
|
+
/**
|
|
136
|
+
* Chat is the associated chat for the messages.
|
|
137
|
+
*/
|
|
138
|
+
readonly chat: Chat;
|
|
139
|
+
/**
|
|
140
|
+
* abortSignal can be used to terminate streaming operations
|
|
141
|
+
* immediately when the streaming request ends.
|
|
142
|
+
*/
|
|
143
|
+
readonly abortSignal?: AbortSignal;
|
|
144
|
+
}
|
|
145
|
+
interface ExperimentalProvideCompletionsOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
146
|
+
/**
|
|
147
|
+
* The chat for the completions.
|
|
148
|
+
* Omitted if there is no chat.
|
|
149
|
+
*/
|
|
150
|
+
readonly chat?: Chat;
|
|
151
|
+
/**
|
|
152
|
+
* Messages that are part of the current chat.
|
|
153
|
+
* Omitted if there is no chat.
|
|
154
|
+
*/
|
|
155
|
+
readonly messages?: MESSAGE[];
|
|
156
|
+
readonly input: string;
|
|
157
|
+
readonly caret: number;
|
|
158
|
+
readonly selection?: [number, number];
|
|
159
|
+
readonly abortSignal?: AbortSignal;
|
|
160
|
+
}
|
|
161
|
+
type ExperimentalCompletion = {
|
|
162
|
+
text: string;
|
|
163
|
+
replace?: [number, number];
|
|
164
|
+
} | {
|
|
165
|
+
id: string;
|
|
166
|
+
label: string;
|
|
167
|
+
detail?: string;
|
|
168
|
+
insertText?: string;
|
|
169
|
+
replace?: [number, number];
|
|
170
|
+
};
|
|
171
|
+
type ExperimentalProvideCompletionsResponse = ReadableStream<ExperimentalCompletion> | Promise<ReadableStream<ExperimentalCompletion>> | Promise<ExperimentalCompletion> | ExperimentalCompletion;
|
|
172
|
+
interface AgentOptions<MESSAGE extends UIMessage = UIMessage> {
|
|
173
|
+
/**
|
|
174
|
+
* sendMessages is called when the agent is streaming chat messages.
|
|
175
|
+
* This is invoked on chat creation, and can be programatically
|
|
176
|
+
* invoked at any time with `blink.chat.message`.
|
|
177
|
+
*/
|
|
178
|
+
sendMessages(options: SendMessagesOptions<MESSAGE>): Promise<SendMessagesResponse> | SendMessagesResponse;
|
|
179
|
+
/**
|
|
180
|
+
* onRequest is called when the agent receives a request.
|
|
181
|
+
* This is for handling webhooks, or incoming client payloads
|
|
182
|
+
* that warrant a response.
|
|
183
|
+
*
|
|
184
|
+
* @param request The request received by the agent.
|
|
185
|
+
* @returns A response to the request. If void, the agent will
|
|
186
|
+
* respond with a 404.
|
|
187
|
+
*/
|
|
188
|
+
onRequest?(request: Request): Promise<Response | void>;
|
|
189
|
+
/**
|
|
190
|
+
* experimental_provideCompletions is called when the user is typing in the chat input.
|
|
191
|
+
* This is used to provide completions to the user.
|
|
192
|
+
*
|
|
193
|
+
* *NOTE*: This *only* works in the browser at the moment.
|
|
194
|
+
*
|
|
195
|
+
* @param options The options for the completions.
|
|
196
|
+
* @returns A stream of completions, or a single completion.
|
|
197
|
+
*/
|
|
198
|
+
experimental_provideCompletions?(options: ExperimentalProvideCompletionsOptions<MESSAGE>): ExperimentalProvideCompletionsResponse;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A Blink agent is simply an HTTP handler with a reserved
|
|
202
|
+
* "/_agent/" path used for agent-specific requests.
|
|
203
|
+
*
|
|
204
|
+
* The environment variable "BLINK_API_SERVER_URL" is used
|
|
205
|
+
* to serve responses to the `blink.*` API. (e.g. blink.chat.upsert).
|
|
206
|
+
*/
|
|
207
|
+
interface Agent {
|
|
208
|
+
/**
|
|
209
|
+
* fetch is the HTTP handler for the agent.
|
|
210
|
+
*
|
|
211
|
+
* @param request The request to handle.
|
|
212
|
+
* @returns A response to the request.
|
|
213
|
+
*/
|
|
214
|
+
fetch(request: Request): Promise<Response> | Response;
|
|
215
|
+
/**
|
|
216
|
+
* serve starts the agent as an unauthenticated HTTP server.
|
|
217
|
+
* This is required for use in the Blink Cloud or with the Blink CLI.
|
|
218
|
+
*
|
|
219
|
+
* @param options Optional options for the server.
|
|
220
|
+
* @returns A Node.JS HTTP server.
|
|
221
|
+
*/
|
|
222
|
+
serve(options?: ServeOptions): http.Server;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* ServeOptions is the options for the `.serve()` method.
|
|
226
|
+
*/
|
|
227
|
+
type ServeOptions = {
|
|
228
|
+
readonly host?: string;
|
|
229
|
+
readonly port?: number;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* agent creates an HTTP handler that when served
|
|
233
|
+
* speaks the Blink agent protocol.
|
|
234
|
+
*
|
|
235
|
+
* Call `.serve()` to serve the agent for use in
|
|
236
|
+
* the Blink Cloud or with the Blink CLI.
|
|
237
|
+
*/
|
|
238
|
+
declare function agent<MESSAGE extends UIMessage = UIMessage>(agent: AgentOptions<MESSAGE>): Agent;
|
|
239
|
+
type StreamResponseFormat = "ui-message" | "openai-chat" | "openai-response" | "anthropic" | "google" | "xai";
|
|
240
|
+
declare function withResponseFormat(response: Response, format: StreamResponseFormat): Response;
|
|
241
|
+
/**
|
|
242
|
+
* model returns an AI SDK model that is authenticated through Blink.
|
|
243
|
+
*
|
|
244
|
+
* Blink's AI Gateway uses Vercel's AI Gateway under-the-hood, and passes
|
|
245
|
+
* through billing cost without any upcharge.
|
|
246
|
+
*
|
|
247
|
+
* Feel free to use any provide you'd like.
|
|
248
|
+
*
|
|
249
|
+
* @param modelName - See: https://vercel.com/ai-gateway/models
|
|
250
|
+
* @returns An AI SDK model that is authenticated through Blink.
|
|
251
|
+
*/
|
|
252
|
+
declare const model: (modelName: string) => _ai_sdk_provider0.LanguageModelV2;
|
|
253
|
+
declare const _default: {
|
|
254
|
+
agent: typeof agent;
|
|
255
|
+
chat: Readonly<{
|
|
256
|
+
upsert: (id: string) => Promise<Chat>;
|
|
257
|
+
message: (id: string, message: Message, options?: MessageOptions) => Promise<void>;
|
|
258
|
+
}>;
|
|
259
|
+
storage: Readonly<{
|
|
260
|
+
kv: Readonly<{
|
|
261
|
+
get: (key: string) => Promise<string | undefined>;
|
|
262
|
+
set: (key: string, value: string) => Promise<void>;
|
|
263
|
+
del: (key: string) => Promise<void>;
|
|
264
|
+
}>;
|
|
265
|
+
}>;
|
|
266
|
+
tools: {
|
|
267
|
+
withContext<const TOOLS extends {
|
|
268
|
+
[x: string]: ai0.Tool & {
|
|
269
|
+
withContext(context: unknown): ai0.Tool;
|
|
270
|
+
};
|
|
271
|
+
}>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: ai0.Tool };
|
|
272
|
+
with<const TOOLS extends {
|
|
273
|
+
[x: string]: ai0.Tool & {
|
|
274
|
+
withContext(context: unknown): ai0.Tool;
|
|
275
|
+
};
|
|
276
|
+
}>(tools: TOOLS, context: ContextFromTools<TOOLS>): { [K in keyof TOOLS]: ai0.Tool };
|
|
277
|
+
withApproval<TOOLS extends ai0.ToolSet, MESSAGE extends UIMessage>(options: {
|
|
278
|
+
messages: MESSAGE[];
|
|
279
|
+
tools: TOOLS;
|
|
280
|
+
abortSignal?: AbortSignal;
|
|
281
|
+
}): Promise<TOOLS>;
|
|
282
|
+
prefix(tools: ai0.ToolSet, prefix: string): ai0.ToolSet;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
//#endregion
|
|
286
|
+
export { Agent, AgentOptions, Chat, ChatBehavior, ContextFromTools, ExperimentalCompletion, ExperimentalProvideCompletionsOptions, ExperimentalProvideCompletionsResponse, Message, MessageOptions, SendMessagesOptions, SendMessagesResponse, ServeOptions, StreamResponseFormat, ToolApprovalOutput, ToolWithContext, _default, agent, chat, isToolApprovalOutput, model, storage, tools, withResponseFormat };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Chat, ExperimentalCompletion } from "./index-tvf1rglX.js";
|
|
2
|
+
import { UIMessage, UIMessageChunk } from "ai";
|
|
3
|
+
|
|
4
|
+
//#region src/http/async-iterable-stream.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A type that combines AsyncIterable and ReadableStream.
|
|
7
|
+
* This allows a ReadableStream to be consumed using for-await-of syntax.
|
|
8
|
+
*/
|
|
9
|
+
type AsyncIterableStream$1<T> = AsyncIterable<T> & ReadableStream<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a ReadableStream and returns an object that is both a ReadableStream and an AsyncIterable.
|
|
12
|
+
* This enables consumption of the stream using for-await-of, with proper resource cleanup on early exit or error.
|
|
13
|
+
*
|
|
14
|
+
* @template T The type of the stream's chunks.
|
|
15
|
+
* @param source The source ReadableStream to wrap.
|
|
16
|
+
* @returns An AsyncIterableStream that can be used as both a ReadableStream and an AsyncIterable.
|
|
17
|
+
*/
|
|
18
|
+
declare function createAsyncIterableStream<T>(source: ReadableStream<T>): AsyncIterableStream$1<T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/api/internal/client.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* APIServerURLEnvironmentVariable is the environment variable that
|
|
23
|
+
* the Blink agent uses for executions to the `blink.*` API.
|
|
24
|
+
* (e.g. blink.chat.upsert).
|
|
25
|
+
*/
|
|
26
|
+
declare const APIServerURLEnvironmentVariable = "BLINK_API_SERVER_URL";
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/http/client.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* StreamResponseFormatHeader indicates to a client the stream response
|
|
31
|
+
* format that the agent is using.
|
|
32
|
+
*/
|
|
33
|
+
declare const StreamResponseFormatHeader = "x-blink-stream-response-format";
|
|
34
|
+
/**
|
|
35
|
+
* SendMessagesRequest is the request format of the `/_agent/send-messages` endpoint.
|
|
36
|
+
*
|
|
37
|
+
* It executes the `sendMessages` function.
|
|
38
|
+
*/
|
|
39
|
+
interface SendMessagesRequest {
|
|
40
|
+
readonly messages: UIMessage[];
|
|
41
|
+
readonly chat: Chat;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* ExperimentalProvideCompletionsRequest is the request format of the `/_agent/completions` endpoint.
|
|
45
|
+
*
|
|
46
|
+
* It executes the `experimental_provideCompletions` function.
|
|
47
|
+
*/
|
|
48
|
+
interface ExperimentalProvideCompletionsRequest {
|
|
49
|
+
readonly messages: UIMessage[];
|
|
50
|
+
readonly chat?: Chat;
|
|
51
|
+
readonly input: string;
|
|
52
|
+
readonly caret: number;
|
|
53
|
+
readonly selection?: [number, number];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* CapabilitiesResponse is the response format of the `/_agent/capabilities` endpoint.
|
|
57
|
+
*
|
|
58
|
+
* It indicates whether the agent supports requests and completions.
|
|
59
|
+
*/
|
|
60
|
+
interface CapabilitiesResponse {
|
|
61
|
+
readonly requests: boolean;
|
|
62
|
+
readonly completions: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface ClientOptions {
|
|
65
|
+
readonly baseUrl: string;
|
|
66
|
+
readonly headers?: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Client is a client for the Blink agent HTTP API.
|
|
70
|
+
*/
|
|
71
|
+
declare class Client {
|
|
72
|
+
private readonly options;
|
|
73
|
+
constructor(options: ClientOptions);
|
|
74
|
+
get baseUrl(): string;
|
|
75
|
+
/**
|
|
76
|
+
* sendMessages sends messages to the agent.
|
|
77
|
+
*
|
|
78
|
+
* The response format is automatically converted to a UI message stream.
|
|
79
|
+
*/
|
|
80
|
+
sendMessages(request: SendMessagesRequest, options?: {
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
}): Promise<AsyncIterableStream$1<UIMessageChunk>>;
|
|
83
|
+
/**
|
|
84
|
+
* experimental_provideCompletions provides completions to the user.
|
|
85
|
+
* This is used to provide completions to the user.
|
|
86
|
+
*/
|
|
87
|
+
experimental_provideCompletions(request: ExperimentalProvideCompletionsRequest): Promise<AsyncIterableStream$1<ExperimentalCompletion>>;
|
|
88
|
+
/**
|
|
89
|
+
* capabilities returns the capabilities of the agent.
|
|
90
|
+
* This is used to check if the agent supports requests and completions.
|
|
91
|
+
*/
|
|
92
|
+
capabilities(): Promise<CapabilitiesResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* health simply returns a 200 response.
|
|
95
|
+
* This is used to check if the agent is running.
|
|
96
|
+
*/
|
|
97
|
+
health(): Promise<void>;
|
|
98
|
+
private handleError;
|
|
99
|
+
}
|
|
100
|
+
declare const streamSSE: <T>(resp: Response) => AsyncIterableStream$1<T>;
|
|
101
|
+
//#endregion
|
|
102
|
+
export { APIServerURLEnvironmentVariable, AsyncIterableStream$1 as AsyncIterableStream, CapabilitiesResponse, Client, ClientOptions, ExperimentalProvideCompletionsRequest, SendMessagesRequest, StreamResponseFormatHeader, createAsyncIterableStream, streamSSE };
|