blink 0.1.91 → 0.1.93
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/browser/agent/client/index.cjs +1 -1
- package/dist/browser/agent/client/index.js +1 -1
- package/dist/cli/{auth-DpiyIVyb.js → auth-DjAEZyZZ.js} +18 -17
- package/dist/cli/{chat-COey7v82.js → chat-DOA1hSTm.js} +1 -1
- package/dist/cli/{dev-DPi0w-yZ.js → dev-Dc7M3oIW.js} +136 -89
- package/dist/cli/disk-store-Cbn2SJoD.js +21 -0
- package/dist/cli/index.js +6 -6
- package/dist/cli/{init-m-BdPD26.js → init-iySs9KUe.js} +1 -1
- package/dist/cli/login-DTwQcbaT.js +1 -0
- package/dist/cli/{main-DSwQ2okO.js → main-BdSSlDIs.js} +5 -5
- package/dist/cli/{open-ydKPp-AQ.js → open-DCYivxgo.js} +1 -1
- package/dist/cli/run-DPPy_-IS.js +1 -0
- package/dist/node/agent/index.node.cjs +1 -1
- package/dist/node/agent/index.node.d.cts +1 -1
- package/dist/node/agent/index.node.d.ts +1 -1
- package/dist/node/agent/index.node.js +1 -1
- package/dist/node/{index.node-9Ne6ij69.cjs → index.node-DlfrLUZ3.cjs} +4 -4
- package/dist/node/{index.node-B8u-uZx1.d.ts → index.node-GlFXJEaB.d.ts} +7 -17
- package/dist/node/{index.node-WvPABjgt.js → index.node-hG-farUz.js} +4 -4
- package/dist/node/{index.node-CFD7trD8.d.cts → index.node-ztcay7c1.d.cts} +7 -17
- package/dist/node/react/index.node.cjs +136 -98
- package/dist/node/react/index.node.d.cts +127 -11
- package/dist/node/react/index.node.d.ts +127 -11
- package/dist/node/react/index.node.js +93 -55
- package/package.json +1 -1
- package/dist/cli/login-CoiO1E6k.js +0 -1
- package/dist/cli/run-agent-BVF1YDCN.js +0 -21
- package/dist/cli/run-zYfUW2Ad.js +0 -1
- /package/dist/cli/{dist-wyfWuz5A.js → dist-BNbSDxaw.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, UIOptions, UIOptionsSchema } from "../index.browser-CS2PXHA_.cjs";
|
|
2
|
-
import "../index.node-
|
|
2
|
+
import "../index.node-ztcay7c1.cjs";
|
|
3
3
|
import { BuildLog, BuildResult } from "../index-DZ_cKJPr.cjs";
|
|
4
4
|
import { CapabilitiesResponse, Client } from "../index-BDhvk5TM.cjs";
|
|
5
5
|
import { UIMessage } from "ai";
|
|
@@ -82,13 +82,35 @@ interface Store<T extends object> {
|
|
|
82
82
|
* createFileStore creates a simple file-based store with atomic read/write.
|
|
83
83
|
* All operations are protected by filesystem locks for multi-process safety.
|
|
84
84
|
*/
|
|
85
|
+
|
|
86
|
+
interface DiskStoreWatcher<T = any> {
|
|
87
|
+
onChange: (callback: (event: {
|
|
88
|
+
key: string;
|
|
89
|
+
value: T | undefined;
|
|
90
|
+
locked: boolean;
|
|
91
|
+
pid?: number;
|
|
92
|
+
}) => void) => () => void;
|
|
93
|
+
dispose: () => void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* createDiskStoreWatcher creates a watcher for the disk store.
|
|
97
|
+
* It watches the disk store for changes and emits events when the
|
|
98
|
+
* store changes.
|
|
99
|
+
*
|
|
100
|
+
* It also polls the store for changes in case the watcher misses
|
|
101
|
+
* any changes.
|
|
102
|
+
*
|
|
103
|
+
* It also debounces the changes to prevent too many events from
|
|
104
|
+
* being emitted.
|
|
105
|
+
*/
|
|
85
106
|
//#endregion
|
|
86
107
|
//#region src/local/types.d.ts
|
|
87
108
|
interface StoredChat {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
id: string;
|
|
110
|
+
created_at: string;
|
|
111
|
+
updated_at: string;
|
|
112
|
+
messages: StoredMessage[];
|
|
113
|
+
error?: string;
|
|
92
114
|
}
|
|
93
115
|
type StoredMessageMetadata = {
|
|
94
116
|
__blink_internal: true;
|
|
@@ -107,23 +129,111 @@ interface StoredMessage<T extends UIMessage = UIMessage<StoredMessageMetadata>>
|
|
|
107
129
|
* Helper to convert UIMessage to StoredMessage
|
|
108
130
|
*/
|
|
109
131
|
//#endregion
|
|
110
|
-
//#region src/
|
|
132
|
+
//#region src/local/chat-manager.d.ts
|
|
111
133
|
type ChatStatus = "idle" | "streaming" | "error";
|
|
112
|
-
interface
|
|
134
|
+
interface ChatState {
|
|
113
135
|
readonly id: string;
|
|
114
136
|
readonly created_at?: string;
|
|
115
137
|
readonly updated_at?: string;
|
|
116
138
|
readonly messages: StoredMessage[];
|
|
117
139
|
readonly status: ChatStatus;
|
|
118
140
|
readonly streamingMessage?: UIMessage;
|
|
119
|
-
readonly error?:
|
|
141
|
+
readonly error?: string;
|
|
142
|
+
readonly loading: boolean;
|
|
120
143
|
readonly queuedMessages: StoredMessage[];
|
|
121
144
|
}
|
|
145
|
+
interface ChatManagerOptions {
|
|
146
|
+
readonly chatId: string;
|
|
147
|
+
readonly store: Store<StoredChat>;
|
|
148
|
+
readonly watcher: DiskStoreWatcher<StoredChat>;
|
|
149
|
+
/**
|
|
150
|
+
* Optional function to filter messages before persisting them.
|
|
151
|
+
* Return undefined to skip persisting the message.
|
|
152
|
+
*/
|
|
153
|
+
readonly serializeMessage?: (message: UIMessage) => StoredMessage | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Optional function to filter messages before sending to the agent.
|
|
156
|
+
* Return true to include the message, false to exclude it.
|
|
157
|
+
*/
|
|
158
|
+
readonly filterMessages?: (message: UIMessage) => boolean;
|
|
159
|
+
}
|
|
160
|
+
type StateListener = (state: ChatState) => void;
|
|
161
|
+
/**
|
|
162
|
+
* ChatManager handles all chat state and operations outside of React.
|
|
163
|
+
* This makes it easier to test and reason about race conditions.
|
|
164
|
+
*/
|
|
165
|
+
declare class ChatManager {
|
|
166
|
+
private chatId;
|
|
167
|
+
private agent;
|
|
168
|
+
private chatStore;
|
|
169
|
+
private serializeMessage?;
|
|
170
|
+
private filterMessages?;
|
|
171
|
+
private chat;
|
|
172
|
+
private loading;
|
|
173
|
+
private streamingMessage;
|
|
174
|
+
private status;
|
|
175
|
+
private queue;
|
|
176
|
+
private abortController;
|
|
177
|
+
private isProcessingQueue;
|
|
178
|
+
private listeners;
|
|
179
|
+
private unwatchStore;
|
|
180
|
+
private disposed;
|
|
181
|
+
constructor(options: ChatManagerOptions);
|
|
182
|
+
/**
|
|
183
|
+
* Update the agent instance to be used for chats
|
|
184
|
+
*/
|
|
185
|
+
setAgent(agent: Client | undefined): void;
|
|
186
|
+
/**
|
|
187
|
+
* Get the current state
|
|
188
|
+
*/
|
|
189
|
+
getState(): ChatState;
|
|
190
|
+
/**
|
|
191
|
+
* Subscribe to state changes
|
|
192
|
+
*/
|
|
193
|
+
subscribe(listener: StateListener): () => void;
|
|
194
|
+
/**
|
|
195
|
+
* Upsert a message to the chat
|
|
196
|
+
*/
|
|
197
|
+
upsertMessage(message: UIMessage, lock?: LockedStoreEntry<StoredChat>): Promise<void>;
|
|
198
|
+
deleteMessage(id: string): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Send a message to the agent
|
|
201
|
+
*/
|
|
202
|
+
sendMessage(message: StoredMessage): Promise<void>;
|
|
203
|
+
private processQueue;
|
|
204
|
+
/**
|
|
205
|
+
* Stop the current streaming operation
|
|
206
|
+
*/
|
|
207
|
+
stopStreaming(): void;
|
|
208
|
+
/**
|
|
209
|
+
* Clear all queued messages
|
|
210
|
+
*/
|
|
211
|
+
clearQueue(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Reset the chat (delete from disk)
|
|
214
|
+
*/
|
|
215
|
+
resetChat(): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Dispose of the manager (cleanup)
|
|
218
|
+
*/
|
|
219
|
+
dispose(): void;
|
|
220
|
+
private resetChatState;
|
|
221
|
+
private notifyListeners;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/react/use-chat.d.ts
|
|
122
225
|
interface UseChatOptions {
|
|
123
226
|
readonly chatId: string;
|
|
124
227
|
readonly agent: Client | undefined;
|
|
125
|
-
readonly chatStore: Store<StoredChat>;
|
|
126
228
|
readonly chatsDirectory: string;
|
|
229
|
+
/**
|
|
230
|
+
* Optional shared store to use. If not provided, a new one will be created.
|
|
231
|
+
*/
|
|
232
|
+
readonly store?: Store<StoredChat>;
|
|
233
|
+
/**
|
|
234
|
+
* Optional shared watcher to use. If not provided, a new one will be created.
|
|
235
|
+
*/
|
|
236
|
+
readonly watcher?: DiskStoreWatcher<StoredChat>;
|
|
127
237
|
/**
|
|
128
238
|
* Optional function to filter messages before persisting them.
|
|
129
239
|
* Return undefined to skip persisting the message.
|
|
@@ -135,9 +245,10 @@ interface UseChatOptions {
|
|
|
135
245
|
*/
|
|
136
246
|
readonly filterMessages?: (message: UIMessage) => boolean;
|
|
137
247
|
}
|
|
138
|
-
interface UseChat extends
|
|
248
|
+
interface UseChat extends ChatState {
|
|
139
249
|
readonly sendMessage: (message: StoredMessage) => Promise<void>;
|
|
140
250
|
readonly upsertMessage: (message: StoredMessage) => Promise<void>;
|
|
251
|
+
readonly deleteMessage: (id: string) => Promise<void>;
|
|
141
252
|
readonly stopStreaming: () => void;
|
|
142
253
|
readonly resetChat: () => Promise<void>;
|
|
143
254
|
readonly clearQueue: () => void;
|
|
@@ -163,8 +274,12 @@ type LocalServer = ReturnType<typeof createLocalServer>;
|
|
|
163
274
|
declare function createLocalServer(options: CreateLocalServerOptions): {
|
|
164
275
|
url: string;
|
|
165
276
|
runtime: Context;
|
|
166
|
-
chatStore: Store<StoredChat>;
|
|
167
277
|
chatsDirectory: string;
|
|
278
|
+
chatStore: Store<StoredChat>;
|
|
279
|
+
chatWatcher: DiskStoreWatcher<StoredChat>;
|
|
280
|
+
getChatManager: (chatId: string) => ChatManager;
|
|
281
|
+
listChats: () => Promise<StoreEntry[]>;
|
|
282
|
+
lockChat: (chatId: string) => Promise<LockedStoreEntry<StoredChat>>;
|
|
168
283
|
startChat: (chatId: string) => void;
|
|
169
284
|
stopChat: (chatId: string) => void;
|
|
170
285
|
dispose: () => void;
|
|
@@ -226,6 +341,7 @@ interface UseDevMode {
|
|
|
226
341
|
readonly approval: ApprovalRequest | undefined;
|
|
227
342
|
readonly tokenUsage: TokenUsage | undefined;
|
|
228
343
|
readonly server: LocalServer;
|
|
344
|
+
readonly showWaitingPlaceholder: boolean;
|
|
229
345
|
}
|
|
230
346
|
/**
|
|
231
347
|
* useDevMode abstracts all the business logic for running/editing an agent.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, UIOptions, UIOptionsSchema } from "../index.browser-BsqAq16G.js";
|
|
2
|
-
import "../index.node-
|
|
2
|
+
import "../index.node-GlFXJEaB.js";
|
|
3
3
|
import { BuildLog, BuildResult } from "../index-BNMqN1Am.js";
|
|
4
4
|
import { CapabilitiesResponse, Client } from "../index-DHCYXwb2.js";
|
|
5
5
|
import { UIMessage } from "ai";
|
|
@@ -82,13 +82,35 @@ interface Store<T extends object> {
|
|
|
82
82
|
* createFileStore creates a simple file-based store with atomic read/write.
|
|
83
83
|
* All operations are protected by filesystem locks for multi-process safety.
|
|
84
84
|
*/
|
|
85
|
+
|
|
86
|
+
interface DiskStoreWatcher<T = any> {
|
|
87
|
+
onChange: (callback: (event: {
|
|
88
|
+
key: string;
|
|
89
|
+
value: T | undefined;
|
|
90
|
+
locked: boolean;
|
|
91
|
+
pid?: number;
|
|
92
|
+
}) => void) => () => void;
|
|
93
|
+
dispose: () => void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* createDiskStoreWatcher creates a watcher for the disk store.
|
|
97
|
+
* It watches the disk store for changes and emits events when the
|
|
98
|
+
* store changes.
|
|
99
|
+
*
|
|
100
|
+
* It also polls the store for changes in case the watcher misses
|
|
101
|
+
* any changes.
|
|
102
|
+
*
|
|
103
|
+
* It also debounces the changes to prevent too many events from
|
|
104
|
+
* being emitted.
|
|
105
|
+
*/
|
|
85
106
|
//#endregion
|
|
86
107
|
//#region src/local/types.d.ts
|
|
87
108
|
interface StoredChat {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
id: string;
|
|
110
|
+
created_at: string;
|
|
111
|
+
updated_at: string;
|
|
112
|
+
messages: StoredMessage[];
|
|
113
|
+
error?: string;
|
|
92
114
|
}
|
|
93
115
|
type StoredMessageMetadata = {
|
|
94
116
|
__blink_internal: true;
|
|
@@ -107,23 +129,111 @@ interface StoredMessage<T extends UIMessage = UIMessage<StoredMessageMetadata>>
|
|
|
107
129
|
* Helper to convert UIMessage to StoredMessage
|
|
108
130
|
*/
|
|
109
131
|
//#endregion
|
|
110
|
-
//#region src/
|
|
132
|
+
//#region src/local/chat-manager.d.ts
|
|
111
133
|
type ChatStatus = "idle" | "streaming" | "error";
|
|
112
|
-
interface
|
|
134
|
+
interface ChatState {
|
|
113
135
|
readonly id: string;
|
|
114
136
|
readonly created_at?: string;
|
|
115
137
|
readonly updated_at?: string;
|
|
116
138
|
readonly messages: StoredMessage[];
|
|
117
139
|
readonly status: ChatStatus;
|
|
118
140
|
readonly streamingMessage?: UIMessage;
|
|
119
|
-
readonly error?:
|
|
141
|
+
readonly error?: string;
|
|
142
|
+
readonly loading: boolean;
|
|
120
143
|
readonly queuedMessages: StoredMessage[];
|
|
121
144
|
}
|
|
145
|
+
interface ChatManagerOptions {
|
|
146
|
+
readonly chatId: string;
|
|
147
|
+
readonly store: Store<StoredChat>;
|
|
148
|
+
readonly watcher: DiskStoreWatcher<StoredChat>;
|
|
149
|
+
/**
|
|
150
|
+
* Optional function to filter messages before persisting them.
|
|
151
|
+
* Return undefined to skip persisting the message.
|
|
152
|
+
*/
|
|
153
|
+
readonly serializeMessage?: (message: UIMessage) => StoredMessage | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Optional function to filter messages before sending to the agent.
|
|
156
|
+
* Return true to include the message, false to exclude it.
|
|
157
|
+
*/
|
|
158
|
+
readonly filterMessages?: (message: UIMessage) => boolean;
|
|
159
|
+
}
|
|
160
|
+
type StateListener = (state: ChatState) => void;
|
|
161
|
+
/**
|
|
162
|
+
* ChatManager handles all chat state and operations outside of React.
|
|
163
|
+
* This makes it easier to test and reason about race conditions.
|
|
164
|
+
*/
|
|
165
|
+
declare class ChatManager {
|
|
166
|
+
private chatId;
|
|
167
|
+
private agent;
|
|
168
|
+
private chatStore;
|
|
169
|
+
private serializeMessage?;
|
|
170
|
+
private filterMessages?;
|
|
171
|
+
private chat;
|
|
172
|
+
private loading;
|
|
173
|
+
private streamingMessage;
|
|
174
|
+
private status;
|
|
175
|
+
private queue;
|
|
176
|
+
private abortController;
|
|
177
|
+
private isProcessingQueue;
|
|
178
|
+
private listeners;
|
|
179
|
+
private unwatchStore;
|
|
180
|
+
private disposed;
|
|
181
|
+
constructor(options: ChatManagerOptions);
|
|
182
|
+
/**
|
|
183
|
+
* Update the agent instance to be used for chats
|
|
184
|
+
*/
|
|
185
|
+
setAgent(agent: Client | undefined): void;
|
|
186
|
+
/**
|
|
187
|
+
* Get the current state
|
|
188
|
+
*/
|
|
189
|
+
getState(): ChatState;
|
|
190
|
+
/**
|
|
191
|
+
* Subscribe to state changes
|
|
192
|
+
*/
|
|
193
|
+
subscribe(listener: StateListener): () => void;
|
|
194
|
+
/**
|
|
195
|
+
* Upsert a message to the chat
|
|
196
|
+
*/
|
|
197
|
+
upsertMessage(message: UIMessage, lock?: LockedStoreEntry<StoredChat>): Promise<void>;
|
|
198
|
+
deleteMessage(id: string): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Send a message to the agent
|
|
201
|
+
*/
|
|
202
|
+
sendMessage(message: StoredMessage): Promise<void>;
|
|
203
|
+
private processQueue;
|
|
204
|
+
/**
|
|
205
|
+
* Stop the current streaming operation
|
|
206
|
+
*/
|
|
207
|
+
stopStreaming(): void;
|
|
208
|
+
/**
|
|
209
|
+
* Clear all queued messages
|
|
210
|
+
*/
|
|
211
|
+
clearQueue(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Reset the chat (delete from disk)
|
|
214
|
+
*/
|
|
215
|
+
resetChat(): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Dispose of the manager (cleanup)
|
|
218
|
+
*/
|
|
219
|
+
dispose(): void;
|
|
220
|
+
private resetChatState;
|
|
221
|
+
private notifyListeners;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/react/use-chat.d.ts
|
|
122
225
|
interface UseChatOptions {
|
|
123
226
|
readonly chatId: string;
|
|
124
227
|
readonly agent: Client | undefined;
|
|
125
|
-
readonly chatStore: Store<StoredChat>;
|
|
126
228
|
readonly chatsDirectory: string;
|
|
229
|
+
/**
|
|
230
|
+
* Optional shared store to use. If not provided, a new one will be created.
|
|
231
|
+
*/
|
|
232
|
+
readonly store?: Store<StoredChat>;
|
|
233
|
+
/**
|
|
234
|
+
* Optional shared watcher to use. If not provided, a new one will be created.
|
|
235
|
+
*/
|
|
236
|
+
readonly watcher?: DiskStoreWatcher<StoredChat>;
|
|
127
237
|
/**
|
|
128
238
|
* Optional function to filter messages before persisting them.
|
|
129
239
|
* Return undefined to skip persisting the message.
|
|
@@ -135,9 +245,10 @@ interface UseChatOptions {
|
|
|
135
245
|
*/
|
|
136
246
|
readonly filterMessages?: (message: UIMessage) => boolean;
|
|
137
247
|
}
|
|
138
|
-
interface UseChat extends
|
|
248
|
+
interface UseChat extends ChatState {
|
|
139
249
|
readonly sendMessage: (message: StoredMessage) => Promise<void>;
|
|
140
250
|
readonly upsertMessage: (message: StoredMessage) => Promise<void>;
|
|
251
|
+
readonly deleteMessage: (id: string) => Promise<void>;
|
|
141
252
|
readonly stopStreaming: () => void;
|
|
142
253
|
readonly resetChat: () => Promise<void>;
|
|
143
254
|
readonly clearQueue: () => void;
|
|
@@ -163,8 +274,12 @@ type LocalServer = ReturnType<typeof createLocalServer>;
|
|
|
163
274
|
declare function createLocalServer(options: CreateLocalServerOptions): {
|
|
164
275
|
url: string;
|
|
165
276
|
runtime: Context;
|
|
166
|
-
chatStore: Store<StoredChat>;
|
|
167
277
|
chatsDirectory: string;
|
|
278
|
+
chatStore: Store<StoredChat>;
|
|
279
|
+
chatWatcher: DiskStoreWatcher<StoredChat>;
|
|
280
|
+
getChatManager: (chatId: string) => ChatManager;
|
|
281
|
+
listChats: () => Promise<StoreEntry[]>;
|
|
282
|
+
lockChat: (chatId: string) => Promise<LockedStoreEntry<StoredChat>>;
|
|
168
283
|
startChat: (chatId: string) => void;
|
|
169
284
|
stopChat: (chatId: string) => void;
|
|
170
285
|
dispose: () => void;
|
|
@@ -226,6 +341,7 @@ interface UseDevMode {
|
|
|
226
341
|
readonly approval: ApprovalRequest | undefined;
|
|
227
342
|
readonly tokenUsage: TokenUsage | undefined;
|
|
228
343
|
readonly server: LocalServer;
|
|
344
|
+
readonly showWaitingPlaceholder: boolean;
|
|
229
345
|
}
|
|
230
346
|
/**
|
|
231
347
|
* useDevMode abstracts all the business logic for running/editing an agent.
|