blink 0.1.91 → 0.1.92

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.
Files changed (28) hide show
  1. package/dist/browser/agent/client/index.cjs +1 -1
  2. package/dist/browser/agent/client/index.js +1 -1
  3. package/dist/cli/{auth-DpiyIVyb.js → auth-DjAEZyZZ.js} +18 -17
  4. package/dist/cli/{chat-COey7v82.js → chat-DOA1hSTm.js} +1 -1
  5. package/dist/cli/{run-agent-BVF1YDCN.js → chat-manager-Crb5wc0l.js} +8 -8
  6. package/dist/cli/{dev-DPi0w-yZ.js → dev-LbQr0Fws.js} +96 -88
  7. package/dist/cli/index.js +6 -6
  8. package/dist/cli/{init-m-BdPD26.js → init-iySs9KUe.js} +1 -1
  9. package/dist/cli/login-DTwQcbaT.js +1 -0
  10. package/dist/cli/{main-DSwQ2okO.js → main-BdSSlDIs.js} +5 -5
  11. package/dist/cli/{open-ydKPp-AQ.js → open-DCYivxgo.js} +1 -1
  12. package/dist/cli/run-KAT6MOpw.js +1 -0
  13. package/dist/node/agent/index.node.cjs +1 -1
  14. package/dist/node/agent/index.node.d.cts +1 -1
  15. package/dist/node/agent/index.node.d.ts +1 -1
  16. package/dist/node/agent/index.node.js +1 -1
  17. package/dist/node/{index.node-9Ne6ij69.cjs → index.node-DlfrLUZ3.cjs} +4 -4
  18. package/dist/node/{index.node-B8u-uZx1.d.ts → index.node-GlFXJEaB.d.ts} +7 -17
  19. package/dist/node/{index.node-WvPABjgt.js → index.node-hG-farUz.js} +4 -4
  20. package/dist/node/{index.node-CFD7trD8.d.cts → index.node-ztcay7c1.d.cts} +7 -17
  21. package/dist/node/react/index.node.cjs +134 -129
  22. package/dist/node/react/index.node.d.cts +93 -23
  23. package/dist/node/react/index.node.d.ts +93 -23
  24. package/dist/node/react/index.node.js +60 -55
  25. package/package.json +1 -1
  26. package/dist/cli/login-CoiO1E6k.js +0 -1
  27. package/dist/cli/run-zYfUW2Ad.js +0 -1
  28. /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-CFD7trD8.cjs";
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";
@@ -70,25 +70,14 @@ interface StoreEntry {
70
70
  * It works with filesystem locks - so multiple processes can
71
71
  * read and write to the store concurrently.
72
72
  */
73
- interface Store<T extends object> {
74
- get: (key: string) => Promise<T | undefined>;
75
- list: () => Promise<StoreEntry[]>;
76
- lock: (key: string, opts?: {
77
- force?: boolean;
78
- }) => Promise<LockedStoreEntry<T>>;
79
- dispose: () => void;
80
- }
81
- /**
82
- * createFileStore creates a simple file-based store with atomic read/write.
83
- * All operations are protected by filesystem locks for multi-process safety.
84
- */
85
73
  //#endregion
86
74
  //#region src/local/types.d.ts
87
75
  interface StoredChat {
88
- readonly id: string;
89
- readonly created_at: string;
90
- readonly updated_at: string;
91
- readonly messages: StoredMessage[];
76
+ id: string;
77
+ created_at: string;
78
+ updated_at: string;
79
+ messages: StoredMessage[];
80
+ error?: string;
92
81
  }
93
82
  type StoredMessageMetadata = {
94
83
  __blink_internal: true;
@@ -107,22 +96,100 @@ interface StoredMessage<T extends UIMessage = UIMessage<StoredMessageMetadata>>
107
96
  * Helper to convert UIMessage to StoredMessage
108
97
  */
109
98
  //#endregion
110
- //#region src/react/use-chat.d.ts
99
+ //#region src/local/chat-manager.d.ts
111
100
  type ChatStatus = "idle" | "streaming" | "error";
112
- interface Chat {
101
+ interface ChatState {
113
102
  readonly id: string;
114
103
  readonly created_at?: string;
115
104
  readonly updated_at?: string;
116
105
  readonly messages: StoredMessage[];
117
106
  readonly status: ChatStatus;
118
107
  readonly streamingMessage?: UIMessage;
119
- readonly error?: Error;
108
+ readonly error?: string;
109
+ readonly loading: boolean;
120
110
  readonly queuedMessages: StoredMessage[];
121
111
  }
112
+ interface ChatManagerOptions {
113
+ readonly chatId: string;
114
+ readonly chatsDirectory: string;
115
+ /**
116
+ * Optional function to filter messages before persisting them.
117
+ * Return undefined to skip persisting the message.
118
+ */
119
+ readonly serializeMessage?: (message: UIMessage) => StoredMessage | undefined;
120
+ /**
121
+ * Optional function to filter messages before sending to the agent.
122
+ * Return true to include the message, false to exclude it.
123
+ */
124
+ readonly filterMessages?: (message: UIMessage) => boolean;
125
+ }
126
+ type StateListener = (state: ChatState) => void;
127
+ /**
128
+ * ChatManager handles all chat state and operations outside of React.
129
+ * This makes it easier to test and reason about race conditions.
130
+ */
131
+ declare class ChatManager {
132
+ private chatId;
133
+ private agent;
134
+ private chatStore;
135
+ private serializeMessage?;
136
+ private filterMessages?;
137
+ private chat;
138
+ private loading;
139
+ private streamingMessage;
140
+ private status;
141
+ private queue;
142
+ private abortController;
143
+ private isProcessingQueue;
144
+ private listeners;
145
+ private watcher;
146
+ private disposed;
147
+ constructor(options: ChatManagerOptions);
148
+ /**
149
+ * Update the agent instance to be used for chats
150
+ */
151
+ setAgent(agent: Client | undefined): void;
152
+ /**
153
+ * Get the current state
154
+ */
155
+ getState(): ChatState;
156
+ /**
157
+ * Subscribe to state changes
158
+ */
159
+ subscribe(listener: StateListener): () => void;
160
+ /**
161
+ * Upsert a message to the chat
162
+ */
163
+ upsertMessage(message: UIMessage, lock?: LockedStoreEntry<StoredChat>): Promise<void>;
164
+ /**
165
+ * Send a message to the agent
166
+ */
167
+ sendMessage(message: StoredMessage): Promise<void>;
168
+ private processQueue;
169
+ /**
170
+ * Stop the current streaming operation
171
+ */
172
+ stopStreaming(): void;
173
+ /**
174
+ * Clear all queued messages
175
+ */
176
+ clearQueue(): void;
177
+ /**
178
+ * Reset the chat (delete from disk)
179
+ */
180
+ resetChat(): Promise<void>;
181
+ /**
182
+ * Dispose of the manager (cleanup)
183
+ */
184
+ dispose(): void;
185
+ private resetChatState;
186
+ private notifyListeners;
187
+ }
188
+ //#endregion
189
+ //#region src/react/use-chat.d.ts
122
190
  interface UseChatOptions {
123
191
  readonly chatId: string;
124
192
  readonly agent: Client | undefined;
125
- readonly chatStore: Store<StoredChat>;
126
193
  readonly chatsDirectory: string;
127
194
  /**
128
195
  * Optional function to filter messages before persisting them.
@@ -135,7 +202,7 @@ interface UseChatOptions {
135
202
  */
136
203
  readonly filterMessages?: (message: UIMessage) => boolean;
137
204
  }
138
- interface UseChat extends Chat {
205
+ interface UseChat extends ChatState {
139
206
  readonly sendMessage: (message: StoredMessage) => Promise<void>;
140
207
  readonly upsertMessage: (message: StoredMessage) => Promise<void>;
141
208
  readonly stopStreaming: () => void;
@@ -163,8 +230,10 @@ type LocalServer = ReturnType<typeof createLocalServer>;
163
230
  declare function createLocalServer(options: CreateLocalServerOptions): {
164
231
  url: string;
165
232
  runtime: Context;
166
- chatStore: Store<StoredChat>;
167
233
  chatsDirectory: string;
234
+ getChatManager: (chatId: string) => ChatManager;
235
+ listChats: () => Promise<StoreEntry[]>;
236
+ lockChat: (chatId: string) => Promise<LockedStoreEntry<StoredChat>>;
168
237
  startChat: (chatId: string) => void;
169
238
  stopChat: (chatId: string) => void;
170
239
  dispose: () => void;
@@ -226,6 +295,7 @@ interface UseDevMode {
226
295
  readonly approval: ApprovalRequest | undefined;
227
296
  readonly tokenUsage: TokenUsage | undefined;
228
297
  readonly server: LocalServer;
298
+ readonly showWaitingPlaceholder: boolean;
229
299
  }
230
300
  /**
231
301
  * 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-B8u-uZx1.js";
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";
@@ -70,25 +70,14 @@ interface StoreEntry {
70
70
  * It works with filesystem locks - so multiple processes can
71
71
  * read and write to the store concurrently.
72
72
  */
73
- interface Store<T extends object> {
74
- get: (key: string) => Promise<T | undefined>;
75
- list: () => Promise<StoreEntry[]>;
76
- lock: (key: string, opts?: {
77
- force?: boolean;
78
- }) => Promise<LockedStoreEntry<T>>;
79
- dispose: () => void;
80
- }
81
- /**
82
- * createFileStore creates a simple file-based store with atomic read/write.
83
- * All operations are protected by filesystem locks for multi-process safety.
84
- */
85
73
  //#endregion
86
74
  //#region src/local/types.d.ts
87
75
  interface StoredChat {
88
- readonly id: string;
89
- readonly created_at: string;
90
- readonly updated_at: string;
91
- readonly messages: StoredMessage[];
76
+ id: string;
77
+ created_at: string;
78
+ updated_at: string;
79
+ messages: StoredMessage[];
80
+ error?: string;
92
81
  }
93
82
  type StoredMessageMetadata = {
94
83
  __blink_internal: true;
@@ -107,22 +96,100 @@ interface StoredMessage<T extends UIMessage = UIMessage<StoredMessageMetadata>>
107
96
  * Helper to convert UIMessage to StoredMessage
108
97
  */
109
98
  //#endregion
110
- //#region src/react/use-chat.d.ts
99
+ //#region src/local/chat-manager.d.ts
111
100
  type ChatStatus = "idle" | "streaming" | "error";
112
- interface Chat {
101
+ interface ChatState {
113
102
  readonly id: string;
114
103
  readonly created_at?: string;
115
104
  readonly updated_at?: string;
116
105
  readonly messages: StoredMessage[];
117
106
  readonly status: ChatStatus;
118
107
  readonly streamingMessage?: UIMessage;
119
- readonly error?: Error;
108
+ readonly error?: string;
109
+ readonly loading: boolean;
120
110
  readonly queuedMessages: StoredMessage[];
121
111
  }
112
+ interface ChatManagerOptions {
113
+ readonly chatId: string;
114
+ readonly chatsDirectory: string;
115
+ /**
116
+ * Optional function to filter messages before persisting them.
117
+ * Return undefined to skip persisting the message.
118
+ */
119
+ readonly serializeMessage?: (message: UIMessage) => StoredMessage | undefined;
120
+ /**
121
+ * Optional function to filter messages before sending to the agent.
122
+ * Return true to include the message, false to exclude it.
123
+ */
124
+ readonly filterMessages?: (message: UIMessage) => boolean;
125
+ }
126
+ type StateListener = (state: ChatState) => void;
127
+ /**
128
+ * ChatManager handles all chat state and operations outside of React.
129
+ * This makes it easier to test and reason about race conditions.
130
+ */
131
+ declare class ChatManager {
132
+ private chatId;
133
+ private agent;
134
+ private chatStore;
135
+ private serializeMessage?;
136
+ private filterMessages?;
137
+ private chat;
138
+ private loading;
139
+ private streamingMessage;
140
+ private status;
141
+ private queue;
142
+ private abortController;
143
+ private isProcessingQueue;
144
+ private listeners;
145
+ private watcher;
146
+ private disposed;
147
+ constructor(options: ChatManagerOptions);
148
+ /**
149
+ * Update the agent instance to be used for chats
150
+ */
151
+ setAgent(agent: Client | undefined): void;
152
+ /**
153
+ * Get the current state
154
+ */
155
+ getState(): ChatState;
156
+ /**
157
+ * Subscribe to state changes
158
+ */
159
+ subscribe(listener: StateListener): () => void;
160
+ /**
161
+ * Upsert a message to the chat
162
+ */
163
+ upsertMessage(message: UIMessage, lock?: LockedStoreEntry<StoredChat>): Promise<void>;
164
+ /**
165
+ * Send a message to the agent
166
+ */
167
+ sendMessage(message: StoredMessage): Promise<void>;
168
+ private processQueue;
169
+ /**
170
+ * Stop the current streaming operation
171
+ */
172
+ stopStreaming(): void;
173
+ /**
174
+ * Clear all queued messages
175
+ */
176
+ clearQueue(): void;
177
+ /**
178
+ * Reset the chat (delete from disk)
179
+ */
180
+ resetChat(): Promise<void>;
181
+ /**
182
+ * Dispose of the manager (cleanup)
183
+ */
184
+ dispose(): void;
185
+ private resetChatState;
186
+ private notifyListeners;
187
+ }
188
+ //#endregion
189
+ //#region src/react/use-chat.d.ts
122
190
  interface UseChatOptions {
123
191
  readonly chatId: string;
124
192
  readonly agent: Client | undefined;
125
- readonly chatStore: Store<StoredChat>;
126
193
  readonly chatsDirectory: string;
127
194
  /**
128
195
  * Optional function to filter messages before persisting them.
@@ -135,7 +202,7 @@ interface UseChatOptions {
135
202
  */
136
203
  readonly filterMessages?: (message: UIMessage) => boolean;
137
204
  }
138
- interface UseChat extends Chat {
205
+ interface UseChat extends ChatState {
139
206
  readonly sendMessage: (message: StoredMessage) => Promise<void>;
140
207
  readonly upsertMessage: (message: StoredMessage) => Promise<void>;
141
208
  readonly stopStreaming: () => void;
@@ -163,8 +230,10 @@ type LocalServer = ReturnType<typeof createLocalServer>;
163
230
  declare function createLocalServer(options: CreateLocalServerOptions): {
164
231
  url: string;
165
232
  runtime: Context;
166
- chatStore: Store<StoredChat>;
167
233
  chatsDirectory: string;
234
+ getChatManager: (chatId: string) => ChatManager;
235
+ listChats: () => Promise<StoreEntry[]>;
236
+ lockChat: (chatId: string) => Promise<LockedStoreEntry<StoredChat>>;
168
237
  startChat: (chatId: string) => void;
169
238
  stopChat: (chatId: string) => void;
170
239
  dispose: () => void;
@@ -226,6 +295,7 @@ interface UseDevMode {
226
295
  readonly approval: ApprovalRequest | undefined;
227
296
  readonly tokenUsage: TokenUsage | undefined;
228
297
  readonly server: LocalServer;
298
+ readonly showWaitingPlaceholder: boolean;
229
299
  }
230
300
  /**
231
301
  * useDevMode abstracts all the business logic for running/editing an agent.