@intella/sdk 0.0.4 → 0.0.6
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/agents/base-agent.d.ts.map +1 -1
- package/dist/agents/base-agent.js +9 -3
- package/dist/agents/base-agent.js.map +1 -1
- package/dist/agents/claude-agent.js +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/sandbox/agent-installers.d.ts +33 -0
- package/dist/sandbox/agent-installers.d.ts.map +1 -0
- package/dist/sandbox/agent-installers.js +277 -0
- package/dist/sandbox/agent-installers.js.map +1 -0
- package/dist/sandbox/agent-setup.d.ts +29 -0
- package/dist/sandbox/agent-setup.d.ts.map +1 -0
- package/dist/sandbox/agent-setup.js +63 -0
- package/dist/sandbox/agent-setup.js.map +1 -0
- package/dist/sandbox/config.d.ts +33 -0
- package/dist/sandbox/config.d.ts.map +1 -0
- package/dist/sandbox/config.js +113 -0
- package/dist/sandbox/config.js.map +1 -0
- package/dist/sandbox/daytona-provider.d.ts.map +1 -1
- package/dist/sandbox/daytona-provider.js +2 -1
- package/dist/sandbox/daytona-provider.js.map +1 -1
- package/dist/sandbox/e2b-provider.js +2 -1
- package/dist/sandbox/e2b-provider.js.map +1 -1
- package/dist/sandbox/local-provider.d.ts +52 -0
- package/dist/sandbox/local-provider.d.ts.map +1 -0
- package/dist/sandbox/local-provider.js +305 -0
- package/dist/sandbox/local-provider.js.map +1 -0
- package/dist/sandbox/modal-provider.js +2 -1
- package/dist/sandbox/modal-provider.js.map +1 -1
- package/dist/sandbox/vercel-provider.d.ts +92 -0
- package/dist/sandbox/vercel-provider.d.ts.map +1 -0
- package/dist/sandbox/vercel-provider.js +491 -0
- package/dist/sandbox/vercel-provider.js.map +1 -0
- package/dist/sandbox-manager.d.ts +2 -1
- package/dist/sandbox-manager.d.ts.map +1 -1
- package/dist/sandbox-manager.js +8 -3
- package/dist/sandbox-manager.js.map +1 -1
- package/dist/sdk.d.ts +18 -6
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +40 -0
- package/dist/sdk.js.map +1 -1
- package/dist/types.d.ts +52 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/cli-daemon.d.ts +25 -0
- package/dist/utils/cli-daemon.d.ts.map +1 -0
- package/dist/utils/cli-daemon.js +82 -0
- package/dist/utils/cli-daemon.js.map +1 -0
- package/dist/utils/id.util.d.ts +53 -0
- package/dist/utils/id.util.d.ts.map +1 -0
- package/dist/utils/id.util.js +71 -0
- package/dist/utils/id.util.js.map +1 -0
- package/dist/utils/redis-stream.d.ts +161 -0
- package/dist/utils/redis-stream.d.ts.map +1 -0
- package/dist/utils/redis-stream.js +462 -0
- package/dist/utils/redis-stream.js.map +1 -0
- package/package.json +8 -2
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis Stream utilities for sandbox command execution
|
|
3
|
+
* Provides reusable methods for publishing commands, chunks, and waiting for results
|
|
4
|
+
*/
|
|
5
|
+
import { createClient } from 'redis';
|
|
6
|
+
export let client = null;
|
|
7
|
+
/**
|
|
8
|
+
* Generate a unique command ID
|
|
9
|
+
*/
|
|
10
|
+
function generateCommandId() {
|
|
11
|
+
const timestamp = Date.now().toString(36);
|
|
12
|
+
const random = Math.random().toString(36).substring(2, 9);
|
|
13
|
+
return `cmd_${timestamp}_${random}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get Redis client from URL
|
|
17
|
+
*/
|
|
18
|
+
export async function getRedisClient(redisUrl) {
|
|
19
|
+
const url = redisUrl || process.env.REDIS_URL;
|
|
20
|
+
if (!url) {
|
|
21
|
+
throw new Error('Redis URL not provided and REDIS_URL environment variable is not set');
|
|
22
|
+
}
|
|
23
|
+
if (!client) {
|
|
24
|
+
client = createClient({ url });
|
|
25
|
+
}
|
|
26
|
+
if (!client.isOpen) {
|
|
27
|
+
await client.connect();
|
|
28
|
+
}
|
|
29
|
+
return client;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ensure consumer group exists for a stream
|
|
33
|
+
*/
|
|
34
|
+
async function ensureConsumerGroup(client, streamKey, groupName) {
|
|
35
|
+
try {
|
|
36
|
+
await client.xGroupCreate(streamKey, groupName, '0', {
|
|
37
|
+
MKSTREAM: true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// If group already exists (BUSYGROUP), that's fine - ignore the error
|
|
42
|
+
if (error?.message && !error.message.includes('BUSYGROUP')) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Publish a command to sandbox-specific Redis stream
|
|
49
|
+
* @param sandboxId - Sandbox ID
|
|
50
|
+
* @param command - Command to publish
|
|
51
|
+
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
52
|
+
*/
|
|
53
|
+
export async function publishCommand(sandboxId, command, redisUrl) {
|
|
54
|
+
const client = await getRedisClient(redisUrl);
|
|
55
|
+
const commandId = command.id || generateCommandId();
|
|
56
|
+
try {
|
|
57
|
+
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
58
|
+
// Prepare command data for Redis stream
|
|
59
|
+
const commandData = {
|
|
60
|
+
id: commandId,
|
|
61
|
+
type: command.type,
|
|
62
|
+
timestamp: String(Date.now()),
|
|
63
|
+
};
|
|
64
|
+
if (command.sessionId) {
|
|
65
|
+
commandData.sessionId = command.sessionId;
|
|
66
|
+
}
|
|
67
|
+
if (command.agentType) {
|
|
68
|
+
commandData.agentType = String(command.agentType);
|
|
69
|
+
}
|
|
70
|
+
if (command.prompt) {
|
|
71
|
+
commandData.prompt = command.prompt;
|
|
72
|
+
}
|
|
73
|
+
if (command.model) {
|
|
74
|
+
commandData.model = command.model;
|
|
75
|
+
}
|
|
76
|
+
if (command.apiKeys) {
|
|
77
|
+
commandData.apiKeys = JSON.stringify(command.apiKeys);
|
|
78
|
+
}
|
|
79
|
+
if (command.taskRequest) {
|
|
80
|
+
commandData.taskRequest = JSON.stringify(command.taskRequest);
|
|
81
|
+
}
|
|
82
|
+
if (command.history) {
|
|
83
|
+
commandData.history = JSON.stringify(command.history);
|
|
84
|
+
}
|
|
85
|
+
if (command.metadata) {
|
|
86
|
+
commandData.metadata = JSON.stringify(command.metadata);
|
|
87
|
+
}
|
|
88
|
+
if (command.streamAgentResult) {
|
|
89
|
+
commandData.streamAgentResult = command.streamAgentResult ? 'true' : 'false';
|
|
90
|
+
}
|
|
91
|
+
for (const [key, value] of Object.entries(command)) {
|
|
92
|
+
if (key !== 'id' && key !== 'type' && key !== 'timestamp' && key !== 'sessionId' && key !== 'agentType' && key !== 'prompt' && key !== 'model' && key !== 'apiKeys' && key !== 'taskRequest' && key !== 'history' && key !== 'metadata' && key !== 'streamAgentResult') {
|
|
93
|
+
commandData[key] = JSON.stringify(value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Use XADD to add command to stream
|
|
97
|
+
await client.xAdd(streamKey, '*', commandData);
|
|
98
|
+
return commandId;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
await client.quit();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Publish a chunk to sandbox-specific Redis stream
|
|
106
|
+
* @param sandboxId - Sandbox ID
|
|
107
|
+
* @param chunk - Chunk data to publish
|
|
108
|
+
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
109
|
+
*/
|
|
110
|
+
export async function publishChunk(sandboxId, chunk, redisUrl) {
|
|
111
|
+
const client = await getRedisClient(redisUrl);
|
|
112
|
+
try {
|
|
113
|
+
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
114
|
+
const chunkId = chunk.chunkId || generateCommandId();
|
|
115
|
+
// Use XADD to add message to stream
|
|
116
|
+
await client.xAdd(streamKey, '*', {
|
|
117
|
+
chunkId: chunkId,
|
|
118
|
+
chunk: chunk.chunk || '',
|
|
119
|
+
segmentId: chunk.segmentId || '',
|
|
120
|
+
isDone: chunk.isDone ? 'true' : 'false',
|
|
121
|
+
type: chunk.type || 'text-delta',
|
|
122
|
+
senderType: chunk.senderType || '',
|
|
123
|
+
timestamp: String(chunk.timestamp || Date.now()),
|
|
124
|
+
data: chunk.data ? JSON.stringify(chunk.data) : '',
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
await client.quit();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Publish a chunk to session-specific Redis stream
|
|
133
|
+
* @param sessionId - Session ID
|
|
134
|
+
* @param chunk - Chunk data to publish
|
|
135
|
+
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
136
|
+
*/
|
|
137
|
+
export async function publishChunkToSession(sessionId, chunk, redisUrl) {
|
|
138
|
+
const client = await getRedisClient(redisUrl);
|
|
139
|
+
try {
|
|
140
|
+
const streamKey = `session:${sessionId}:stream`;
|
|
141
|
+
const chunkId = chunk.chunkId || generateCommandId();
|
|
142
|
+
// Use XADD to add message to stream
|
|
143
|
+
await client.xAdd(streamKey, '*', {
|
|
144
|
+
chunkId: chunkId,
|
|
145
|
+
chunk: chunk.chunk || '',
|
|
146
|
+
segmentId: chunk.segmentId || '',
|
|
147
|
+
isDone: chunk.isDone ? 'true' : 'false',
|
|
148
|
+
type: chunk.type || 'text-delta',
|
|
149
|
+
senderType: chunk.senderType || '',
|
|
150
|
+
timestamp: String(chunk.timestamp || Date.now()),
|
|
151
|
+
data: chunk.data ? JSON.stringify(chunk.data) : '',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
await client.quit();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Generic function to read from any Redis stream (async generator)
|
|
160
|
+
* @param streamKey - Redis stream key
|
|
161
|
+
* @param options - Configuration options
|
|
162
|
+
*/
|
|
163
|
+
export async function* readFromStream(streamKey, options = {}) {
|
|
164
|
+
const { redisUrl, timeout = 10 * 60 * 1000, groupName, consumerName, commandId, filter, transform, stopOnDone = true, blockTime = 1000, count = 100, } = options;
|
|
165
|
+
const client = await getRedisClient(redisUrl);
|
|
166
|
+
const finalGroupName = groupName || `stream-${streamKey.replace(/:/g, '-')}-consumers`;
|
|
167
|
+
const finalConsumerName = consumerName || `consumer-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
168
|
+
try {
|
|
169
|
+
// Ensure consumer group exists
|
|
170
|
+
await ensureConsumerGroup(client, streamKey, finalGroupName);
|
|
171
|
+
const maxWaitTime = timeout;
|
|
172
|
+
const startTime = Date.now();
|
|
173
|
+
while (Date.now() - startTime < maxWaitTime) {
|
|
174
|
+
try {
|
|
175
|
+
// Always use '>' with consumer groups to read new messages that haven't been delivered to this consumer
|
|
176
|
+
const messages = await client.xReadGroup(finalGroupName, finalConsumerName, [
|
|
177
|
+
{
|
|
178
|
+
key: streamKey,
|
|
179
|
+
id: '>', // Always read new messages for this consumer
|
|
180
|
+
},
|
|
181
|
+
], {
|
|
182
|
+
COUNT: count,
|
|
183
|
+
BLOCK: blockTime,
|
|
184
|
+
});
|
|
185
|
+
if (messages && Array.isArray(messages) && messages.length > 0) {
|
|
186
|
+
const streamData = messages[0];
|
|
187
|
+
if (streamData.messages && streamData.messages.length > 0) {
|
|
188
|
+
for (const message of streamData.messages) {
|
|
189
|
+
// Parse message
|
|
190
|
+
const msg = message.message;
|
|
191
|
+
// Apply filter if provided
|
|
192
|
+
if (filter && !filter(msg)) {
|
|
193
|
+
// ACK and skip
|
|
194
|
+
await client.xAck(streamKey, finalGroupName, message.id);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
// Default filter: For sandbox streams, filter by commandId if provided
|
|
198
|
+
if (commandId) {
|
|
199
|
+
// Only process result messages (those with 'commandId' field)
|
|
200
|
+
if (!msg.commandId) {
|
|
201
|
+
// This is a command message, not a result - ACK and skip
|
|
202
|
+
await client.xAck(streamKey, finalGroupName, message.id);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
// Filter by commandId - only process results for our specific command
|
|
206
|
+
if (msg.commandId !== commandId) {
|
|
207
|
+
// ACK and skip messages not for this command
|
|
208
|
+
await client.xAck(streamKey, finalGroupName, message.id);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Transform message to result type
|
|
213
|
+
let result;
|
|
214
|
+
if (transform) {
|
|
215
|
+
result = transform(msg);
|
|
216
|
+
}
|
|
217
|
+
else if (commandId) {
|
|
218
|
+
// Default transform for sandbox results
|
|
219
|
+
result = {
|
|
220
|
+
commandId: msg.commandId,
|
|
221
|
+
type: (msg.type || 'success'),
|
|
222
|
+
sessionId: msg.sessionId,
|
|
223
|
+
data: msg.data ? JSON.parse(msg.data) : undefined,
|
|
224
|
+
error: msg.error,
|
|
225
|
+
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
// Default: return message as-is
|
|
230
|
+
result = msg;
|
|
231
|
+
}
|
|
232
|
+
yield result;
|
|
233
|
+
// ACK the message
|
|
234
|
+
await client.xAck(streamKey, finalGroupName, message.id);
|
|
235
|
+
// If stopOnDone is true and result has type 'done' or 'error', stop listening
|
|
236
|
+
if (stopOnDone && result && typeof result === 'object' && 'type' in result) {
|
|
237
|
+
const resultType = result.type;
|
|
238
|
+
if (resultType === 'done' || resultType === 'error') {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error(`Error reading from stream ${streamKey}:`, error);
|
|
248
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
finally {
|
|
253
|
+
await client.quit();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Read results from sandbox stream (convenience function)
|
|
258
|
+
* @param sandboxId - Sandbox ID
|
|
259
|
+
* @param commandId - Command ID to filter by
|
|
260
|
+
* @param options - Additional options
|
|
261
|
+
*/
|
|
262
|
+
export async function* readFromSandbox(sandboxId, commandId, options = {}) {
|
|
263
|
+
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
264
|
+
const groupName = options.groupName || `sandbox-${sandboxId}-results`;
|
|
265
|
+
yield* readFromStream(streamKey, {
|
|
266
|
+
...options,
|
|
267
|
+
commandId,
|
|
268
|
+
groupName,
|
|
269
|
+
transform: (msg) => ({
|
|
270
|
+
commandId: msg.commandId,
|
|
271
|
+
type: (msg.type || 'success'),
|
|
272
|
+
sessionId: msg.sessionId,
|
|
273
|
+
data: msg.data ? JSON.parse(msg.data) : undefined,
|
|
274
|
+
error: msg.error,
|
|
275
|
+
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
276
|
+
}),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Read chunks from session stream (convenience function)
|
|
281
|
+
* @param sessionId - Session ID
|
|
282
|
+
* @param options - Additional options
|
|
283
|
+
*/
|
|
284
|
+
export async function* readFromSession(sessionId, options = {}) {
|
|
285
|
+
const streamKey = `session:${sessionId}:stream`;
|
|
286
|
+
const groupName = options.groupName || 'sse-consumers';
|
|
287
|
+
yield* readFromStream(streamKey, {
|
|
288
|
+
...options,
|
|
289
|
+
groupName,
|
|
290
|
+
stopOnDone: false, // Session streams don't stop on done - they continue for new messages
|
|
291
|
+
transform: (msg) => ({
|
|
292
|
+
chunkId: msg.chunkId || undefined,
|
|
293
|
+
chunk: msg.chunk || '',
|
|
294
|
+
segmentId: msg.segmentId || null,
|
|
295
|
+
isDone: msg.isDone === 'true',
|
|
296
|
+
type: msg.type || 'text-delta',
|
|
297
|
+
senderType: msg.senderType || undefined,
|
|
298
|
+
timestamp: msg.timestamp ? parseInt(msg.timestamp, 10) : Date.now(),
|
|
299
|
+
data: msg.data ? (() => {
|
|
300
|
+
try {
|
|
301
|
+
return JSON.parse(msg.data);
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
return msg.data;
|
|
305
|
+
}
|
|
306
|
+
})() : undefined,
|
|
307
|
+
}),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Wait for a success result for a specific command
|
|
312
|
+
* @param sandboxId - Sandbox ID
|
|
313
|
+
* @param commandId - Command ID to wait for
|
|
314
|
+
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
315
|
+
* @param timeout - Timeout in milliseconds (default: 10 minutes)
|
|
316
|
+
* @returns Promise that resolves when success is received
|
|
317
|
+
* @throws Error if timeout or error result is received
|
|
318
|
+
*/
|
|
319
|
+
export async function waitForSuccess(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000) {
|
|
320
|
+
const client = await getRedisClient(redisUrl);
|
|
321
|
+
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
322
|
+
const groupName = `sandbox-${sandboxId}-wait`;
|
|
323
|
+
const consumerName = `consumer-${Date.now()}`;
|
|
324
|
+
try {
|
|
325
|
+
await ensureConsumerGroup(client, streamKey, groupName);
|
|
326
|
+
const deadline = Date.now() + timeout;
|
|
327
|
+
while (Date.now() < deadline) {
|
|
328
|
+
const raw = await client.xReadGroup(groupName, consumerName, [{ key: streamKey, id: '>' }], { COUNT: 10, BLOCK: 1000 });
|
|
329
|
+
const replies = Array.isArray(raw) ? raw : [];
|
|
330
|
+
if (replies.length === 0)
|
|
331
|
+
continue;
|
|
332
|
+
for (const reply of replies) {
|
|
333
|
+
const messages = reply
|
|
334
|
+
.messages;
|
|
335
|
+
if (!messages)
|
|
336
|
+
continue;
|
|
337
|
+
for (const { id: msgId, message: msg } of messages) {
|
|
338
|
+
await client.xAck(streamKey, groupName, msgId);
|
|
339
|
+
// Only process results for our command
|
|
340
|
+
if (msg.commandId === commandId) {
|
|
341
|
+
if (msg.type === 'success') {
|
|
342
|
+
return {
|
|
343
|
+
commandId: msg.commandId,
|
|
344
|
+
type: 'success',
|
|
345
|
+
sessionId: msg.sessionId,
|
|
346
|
+
data: msg.data ? JSON.parse(msg.data) : undefined,
|
|
347
|
+
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
if (msg.type === 'error') {
|
|
351
|
+
throw new Error(`Command failed: ${msg.error || 'unknown error'}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
throw new Error(`Timeout waiting for success for command ${commandId}`);
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
await client.quit();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Wait for an error result for a specific command
|
|
365
|
+
* @param sandboxId - Sandbox ID
|
|
366
|
+
* @param commandId - Command ID to wait for
|
|
367
|
+
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
368
|
+
* @param timeout - Timeout in milliseconds (default: 10 minutes)
|
|
369
|
+
* @returns Promise that resolves with error result
|
|
370
|
+
* @throws Error if timeout
|
|
371
|
+
*/
|
|
372
|
+
export async function waitForError(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000) {
|
|
373
|
+
const client = await getRedisClient(redisUrl);
|
|
374
|
+
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
375
|
+
const groupName = `sandbox-${sandboxId}-wait`;
|
|
376
|
+
const consumerName = `consumer-${Date.now()}`;
|
|
377
|
+
try {
|
|
378
|
+
await ensureConsumerGroup(client, streamKey, groupName);
|
|
379
|
+
const deadline = Date.now() + timeout;
|
|
380
|
+
while (Date.now() < deadline) {
|
|
381
|
+
const raw = await client.xReadGroup(groupName, consumerName, [{ key: streamKey, id: '>' }], { COUNT: 10, BLOCK: 1000 });
|
|
382
|
+
const replies = Array.isArray(raw) ? raw : [];
|
|
383
|
+
if (replies.length === 0)
|
|
384
|
+
continue;
|
|
385
|
+
for (const reply of replies) {
|
|
386
|
+
const messages = reply
|
|
387
|
+
.messages;
|
|
388
|
+
if (!messages)
|
|
389
|
+
continue;
|
|
390
|
+
for (const { id: msgId, message: msg } of messages) {
|
|
391
|
+
await client.xAck(streamKey, groupName, msgId);
|
|
392
|
+
// Only process results for our command
|
|
393
|
+
if (msg.commandId === commandId && msg.type === 'error') {
|
|
394
|
+
return {
|
|
395
|
+
commandId: msg.commandId,
|
|
396
|
+
type: 'error',
|
|
397
|
+
sessionId: msg.sessionId,
|
|
398
|
+
error: msg.error,
|
|
399
|
+
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
throw new Error(`Timeout waiting for error for command ${commandId}`);
|
|
406
|
+
}
|
|
407
|
+
finally {
|
|
408
|
+
await client.quit();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Wait for a done or error result for a specific command (returns full result data)
|
|
413
|
+
* @param sandboxId - Sandbox ID
|
|
414
|
+
* @param commandId - Command ID to wait for
|
|
415
|
+
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
416
|
+
* @param timeout - Timeout in milliseconds (default: 10 minutes)
|
|
417
|
+
* @returns Promise that resolves with done or error result
|
|
418
|
+
* @throws Error if timeout
|
|
419
|
+
*/
|
|
420
|
+
export async function waitForResult(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000) {
|
|
421
|
+
const client = await getRedisClient(redisUrl);
|
|
422
|
+
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
423
|
+
const groupName = `sandbox-${sandboxId}-wait`;
|
|
424
|
+
const consumerName = `consumer-${Date.now()}`;
|
|
425
|
+
try {
|
|
426
|
+
await ensureConsumerGroup(client, streamKey, groupName);
|
|
427
|
+
const deadline = Date.now() + timeout;
|
|
428
|
+
while (Date.now() < deadline) {
|
|
429
|
+
const raw = await client.xReadGroup(groupName, consumerName, [{ key: streamKey, id: '>' }], { COUNT: 10, BLOCK: 1000 });
|
|
430
|
+
const replies = Array.isArray(raw) ? raw : [];
|
|
431
|
+
if (replies.length === 0)
|
|
432
|
+
continue;
|
|
433
|
+
for (const reply of replies) {
|
|
434
|
+
const messages = reply
|
|
435
|
+
.messages;
|
|
436
|
+
if (!messages)
|
|
437
|
+
continue;
|
|
438
|
+
for (const { id: msgId, message: msg } of messages) {
|
|
439
|
+
await client.xAck(streamKey, groupName, msgId);
|
|
440
|
+
// Only process results for our command
|
|
441
|
+
if (msg.commandId === commandId) {
|
|
442
|
+
if (msg.type === 'done' || msg.type === 'error') {
|
|
443
|
+
return {
|
|
444
|
+
commandId: msg.commandId,
|
|
445
|
+
type: msg.type,
|
|
446
|
+
sessionId: msg.sessionId,
|
|
447
|
+
data: msg.data ? JSON.parse(msg.data) : undefined,
|
|
448
|
+
error: msg.error,
|
|
449
|
+
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
throw new Error(`Timeout waiting for result for command ${commandId}`);
|
|
457
|
+
}
|
|
458
|
+
finally {
|
|
459
|
+
await client.quit();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=redis-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-stream.js","sourceRoot":"","sources":["../../src/utils/redis-stream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAK3D,MAAM,C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;QAED,MAAM,IAAI,KAAK,CAAC,0CAA0C,SAAS,EAAE,CAAC,CAAC;IACzE,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intella/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Agent orchestrator SDK for managing tasks across multiple AI agents using AI SDK v6",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"example:integrated-task": "tsx examples/integrated-task/integrated-usage.ts",
|
|
30
30
|
"example:simple-example": "tsx examples/integrated-task/simple-example.ts",
|
|
31
31
|
"example:sandbox": "tsx examples/sandbox/basic-usage.ts",
|
|
32
|
+
"example:local-sandbox": "tsx examples/local-sandbox/local-sandbox-usage.ts",
|
|
33
|
+
"example:local-sandbox-commands": "tsx examples/local-sandbox/command-and-code-execution.ts",
|
|
34
|
+
"example:local-sandbox-agent": "tsx examples/local-sandbox/agent-execution.ts",
|
|
32
35
|
"example:e2b-template": "tsx examples/e2b-template/use-template.ts",
|
|
33
36
|
"example:e2b-cli-agent": "tsx examples/e2b-cli-agent/agent-execution.ts",
|
|
34
37
|
"template:build:dev": "tsx templates/e2b-intella/build.dev.ts",
|
|
@@ -46,6 +49,7 @@
|
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"@daytonaio/sdk": "^0.129.0",
|
|
48
51
|
"@e2b/code-interpreter": "^2.3.3",
|
|
52
|
+
"@vercel/sandbox": "^1.2.0",
|
|
49
53
|
"ai": "6.0.23",
|
|
50
54
|
"ai-sdk-provider-claude-code": "^3.1.0",
|
|
51
55
|
"ai-sdk-provider-codex-cli": "^1.0.4",
|
|
@@ -53,8 +57,10 @@
|
|
|
53
57
|
"dotenv": "^17.2.3",
|
|
54
58
|
"e2b": "^2.9.0",
|
|
55
59
|
"modal": "^0.6.0",
|
|
60
|
+
"ts-node": "^10.9.2",
|
|
56
61
|
"tsx": "^4.21.0",
|
|
57
|
-
"
|
|
62
|
+
"ulid": "^3.0.2",
|
|
63
|
+
"ulid-uuid-converter": "^1.0.4"
|
|
58
64
|
},
|
|
59
65
|
"peerDependencies": {
|
|
60
66
|
"@ai-sdk/openai": "*"
|