@siftd/connect-agent 0.2.30 → 0.2.31
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/agent.js +17 -0
- package/dist/core/asset-api.d.ts +94 -0
- package/dist/core/asset-api.js +182 -0
- package/dist/core/assets.d.ts +176 -0
- package/dist/core/assets.js +192 -0
- package/dist/core/preview-worker.d.ts +98 -0
- package/dist/core/preview-worker.js +395 -0
- package/dist/genesis/tool-patterns.json +9 -4
- package/dist/orchestrator.js +24 -5
- package/dist/prompts/worker-system.d.ts +1 -1
- package/dist/prompts/worker-system.js +34 -7
- package/dist/websocket.d.ts +19 -2
- package/dist/websocket.js +40 -2
- package/package.json +1 -1
package/dist/websocket.d.ts
CHANGED
|
@@ -7,14 +7,19 @@
|
|
|
7
7
|
* - Supports interruption and progress updates
|
|
8
8
|
*/
|
|
9
9
|
import type { WorkerStatus } from './orchestrator.js';
|
|
10
|
+
import { AssetResponse } from './core/asset-api.js';
|
|
10
11
|
export type MessageHandler = (message: WebSocketMessage) => Promise<void>;
|
|
11
12
|
export type StreamHandler = (chunk: string) => void;
|
|
12
13
|
export interface WebSocketMessage {
|
|
13
|
-
type: 'message' | 'interrupt' | 'ping' | 'pong' | 'connected';
|
|
14
|
+
type: 'message' | 'interrupt' | 'ping' | 'pong' | 'connected' | 'asset_request';
|
|
14
15
|
id?: string;
|
|
15
16
|
content?: string;
|
|
16
17
|
timestamp?: number;
|
|
17
18
|
apiKey?: string;
|
|
19
|
+
requestId?: string;
|
|
20
|
+
assetId?: string;
|
|
21
|
+
groupId?: string;
|
|
22
|
+
viewId?: string;
|
|
18
23
|
}
|
|
19
24
|
export interface StreamingResponse {
|
|
20
25
|
send: (chunk: string) => void;
|
|
@@ -67,7 +72,7 @@ export declare class AgentWebSocket {
|
|
|
67
72
|
*/
|
|
68
73
|
sendGalleryCommand(command: 'open' | 'close' | 'focus_worker' | 'open_asset' | 'back', workerId?: string, assetIndex?: number): void;
|
|
69
74
|
/**
|
|
70
|
-
* Send gallery workers with their assets
|
|
75
|
+
* Send gallery workers with their assets (legacy)
|
|
71
76
|
*/
|
|
72
77
|
sendGalleryWorkers(workers: Array<{
|
|
73
78
|
id: string;
|
|
@@ -85,6 +90,14 @@ export declare class AgentWebSocket {
|
|
|
85
90
|
}>;
|
|
86
91
|
}>;
|
|
87
92
|
}>): void;
|
|
93
|
+
/**
|
|
94
|
+
* Send full gallery state (new fast-path system)
|
|
95
|
+
*/
|
|
96
|
+
sendGalleryState(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Send asset response
|
|
99
|
+
*/
|
|
100
|
+
sendAssetResponse(response: AssetResponse): void;
|
|
88
101
|
/**
|
|
89
102
|
* Check if connected
|
|
90
103
|
*/
|
|
@@ -95,6 +108,10 @@ export declare class AgentWebSocket {
|
|
|
95
108
|
close(): void;
|
|
96
109
|
private handleMessage;
|
|
97
110
|
private sendToServer;
|
|
111
|
+
/**
|
|
112
|
+
* Handle asset requests (fast-path, no LLM)
|
|
113
|
+
*/
|
|
114
|
+
private handleAssetRequest;
|
|
98
115
|
private startPingInterval;
|
|
99
116
|
private stopPingInterval;
|
|
100
117
|
private attemptReconnect;
|
package/dist/websocket.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import WebSocket from 'ws';
|
|
10
10
|
import { getServerUrl, getAgentToken } from './config.js';
|
|
11
|
+
import { handleAssetRequest, buildGalleryState, galleryStateToMessage } from './core/asset-api.js';
|
|
11
12
|
export class AgentWebSocket {
|
|
12
13
|
ws = null;
|
|
13
14
|
serverUrl;
|
|
@@ -180,7 +181,7 @@ export class AgentWebSocket {
|
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
183
|
/**
|
|
183
|
-
* Send gallery workers with their assets
|
|
184
|
+
* Send gallery workers with their assets (legacy)
|
|
184
185
|
*/
|
|
185
186
|
sendGalleryWorkers(workers) {
|
|
186
187
|
this.sendToServer({
|
|
@@ -188,6 +189,19 @@ export class AgentWebSocket {
|
|
|
188
189
|
workers
|
|
189
190
|
});
|
|
190
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Send full gallery state (new fast-path system)
|
|
194
|
+
*/
|
|
195
|
+
sendGalleryState() {
|
|
196
|
+
const state = buildGalleryState();
|
|
197
|
+
this.sendToServer(galleryStateToMessage(state));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Send asset response
|
|
201
|
+
*/
|
|
202
|
+
sendAssetResponse(response) {
|
|
203
|
+
this.sendToServer(response);
|
|
204
|
+
}
|
|
191
205
|
/**
|
|
192
206
|
* Check if connected
|
|
193
207
|
*/
|
|
@@ -228,8 +242,18 @@ export class AgentWebSocket {
|
|
|
228
242
|
this.messageHandler(message);
|
|
229
243
|
}
|
|
230
244
|
break;
|
|
245
|
+
case 'asset_request':
|
|
246
|
+
// Handle asset requests (fast-path, no LLM)
|
|
247
|
+
this.handleAssetRequest(message);
|
|
248
|
+
break;
|
|
231
249
|
default:
|
|
232
|
-
|
|
250
|
+
// Check if it's an asset request type
|
|
251
|
+
if (message.type.startsWith('asset.') || message.type.startsWith('view.')) {
|
|
252
|
+
this.handleAssetRequest(message);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
console.log('[WS] Unknown message type:', message.type);
|
|
256
|
+
}
|
|
233
257
|
}
|
|
234
258
|
}
|
|
235
259
|
catch (error) {
|
|
@@ -241,6 +265,20 @@ export class AgentWebSocket {
|
|
|
241
265
|
this.ws.send(JSON.stringify(data));
|
|
242
266
|
}
|
|
243
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Handle asset requests (fast-path, no LLM)
|
|
270
|
+
*/
|
|
271
|
+
async handleAssetRequest(message) {
|
|
272
|
+
const request = {
|
|
273
|
+
type: message.type,
|
|
274
|
+
requestId: message.requestId || message.id || 'unknown',
|
|
275
|
+
assetId: message.assetId,
|
|
276
|
+
groupId: message.groupId,
|
|
277
|
+
viewId: message.viewId,
|
|
278
|
+
};
|
|
279
|
+
const response = await handleAssetRequest(request);
|
|
280
|
+
this.sendAssetResponse(response);
|
|
281
|
+
}
|
|
244
282
|
startPingInterval() {
|
|
245
283
|
this.pingInterval = setInterval(() => {
|
|
246
284
|
if (this.connected()) {
|