blink 0.1.92 → 0.1.94
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/cli/{dev-LbQr0Fws.js → dev-zx8HDBZT.js} +43 -4
- package/dist/cli/disk-store-Cbn2SJoD.js +21 -0
- package/dist/cli/index.js +2 -2
- package/dist/cli/run-DPPy_-IS.js +1 -0
- package/dist/node/react/index.node.cjs +143 -110
- package/dist/node/react/index.node.d.cts +38 -2
- package/dist/node/react/index.node.d.ts +38 -2
- package/dist/node/react/index.node.js +54 -21
- package/package.json +1 -1
- package/dist/cli/chat-manager-Crb5wc0l.js +0 -21
- package/dist/cli/run-KAT6MOpw.js +0 -1
|
@@ -70,6 +70,39 @@ 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
|
+
|
|
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
|
+
*/
|
|
73
106
|
//#endregion
|
|
74
107
|
//#region src/local/types.d.ts
|
|
75
108
|
interface StoredChat {
|
|
@@ -111,7 +144,8 @@ interface ChatState {
|
|
|
111
144
|
}
|
|
112
145
|
interface ChatManagerOptions {
|
|
113
146
|
readonly chatId: string;
|
|
114
|
-
readonly
|
|
147
|
+
readonly store: Store<StoredChat>;
|
|
148
|
+
readonly watcher: DiskStoreWatcher<StoredChat>;
|
|
115
149
|
/**
|
|
116
150
|
* Optional function to filter messages before persisting them.
|
|
117
151
|
* Return undefined to skip persisting the message.
|
|
@@ -142,7 +176,7 @@ declare class ChatManager {
|
|
|
142
176
|
private abortController;
|
|
143
177
|
private isProcessingQueue;
|
|
144
178
|
private listeners;
|
|
145
|
-
private
|
|
179
|
+
private unwatchStore;
|
|
146
180
|
private disposed;
|
|
147
181
|
constructor(options: ChatManagerOptions);
|
|
148
182
|
/**
|
|
@@ -161,6 +195,7 @@ declare class ChatManager {
|
|
|
161
195
|
* Upsert a message to the chat
|
|
162
196
|
*/
|
|
163
197
|
upsertMessage(message: UIMessage, lock?: LockedStoreEntry<StoredChat>): Promise<void>;
|
|
198
|
+
deleteMessage(id: string): Promise<void>;
|
|
164
199
|
/**
|
|
165
200
|
* Send a message to the agent
|
|
166
201
|
*/
|
|
@@ -205,6 +240,7 @@ interface UseChatOptions {
|
|
|
205
240
|
interface UseChat extends ChatState {
|
|
206
241
|
readonly sendMessage: (message: StoredMessage) => Promise<void>;
|
|
207
242
|
readonly upsertMessage: (message: StoredMessage) => Promise<void>;
|
|
243
|
+
readonly deleteMessage: (id: string) => Promise<void>;
|
|
208
244
|
readonly stopStreaming: () => void;
|
|
209
245
|
readonly resetChat: () => Promise<void>;
|
|
210
246
|
readonly clearQueue: () => void;
|
|
@@ -70,6 +70,39 @@ 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
|
+
|
|
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
|
+
*/
|
|
73
106
|
//#endregion
|
|
74
107
|
//#region src/local/types.d.ts
|
|
75
108
|
interface StoredChat {
|
|
@@ -111,7 +144,8 @@ interface ChatState {
|
|
|
111
144
|
}
|
|
112
145
|
interface ChatManagerOptions {
|
|
113
146
|
readonly chatId: string;
|
|
114
|
-
readonly
|
|
147
|
+
readonly store: Store<StoredChat>;
|
|
148
|
+
readonly watcher: DiskStoreWatcher<StoredChat>;
|
|
115
149
|
/**
|
|
116
150
|
* Optional function to filter messages before persisting them.
|
|
117
151
|
* Return undefined to skip persisting the message.
|
|
@@ -142,7 +176,7 @@ declare class ChatManager {
|
|
|
142
176
|
private abortController;
|
|
143
177
|
private isProcessingQueue;
|
|
144
178
|
private listeners;
|
|
145
|
-
private
|
|
179
|
+
private unwatchStore;
|
|
146
180
|
private disposed;
|
|
147
181
|
constructor(options: ChatManagerOptions);
|
|
148
182
|
/**
|
|
@@ -161,6 +195,7 @@ declare class ChatManager {
|
|
|
161
195
|
* Upsert a message to the chat
|
|
162
196
|
*/
|
|
163
197
|
upsertMessage(message: UIMessage, lock?: LockedStoreEntry<StoredChat>): Promise<void>;
|
|
198
|
+
deleteMessage(id: string): Promise<void>;
|
|
164
199
|
/**
|
|
165
200
|
* Send a message to the agent
|
|
166
201
|
*/
|
|
@@ -205,6 +240,7 @@ interface UseChatOptions {
|
|
|
205
240
|
interface UseChat extends ChatState {
|
|
206
241
|
readonly sendMessage: (message: StoredMessage) => Promise<void>;
|
|
207
242
|
readonly upsertMessage: (message: StoredMessage) => Promise<void>;
|
|
243
|
+
readonly deleteMessage: (id: string) => Promise<void>;
|
|
208
244
|
readonly stopStreaming: () => void;
|
|
209
245
|
readonly resetChat: () => Promise<void>;
|
|
210
246
|
readonly clearQueue: () => void;
|