@intella/sdk 0.0.8 → 0.0.9
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/README.md +70 -6
- package/dist/agent-manager.d.ts +4 -4
- package/dist/agent-manager.d.ts.map +1 -1
- package/dist/agent-manager.js +12 -7
- package/dist/agent-manager.js.map +1 -1
- package/dist/agents/base-agent.d.ts +35 -2
- package/dist/agents/base-agent.d.ts.map +1 -1
- package/dist/agents/base-agent.js +280 -24
- package/dist/agents/base-agent.js.map +1 -1
- package/dist/agents/claude-agent.d.ts +1 -1
- package/dist/agents/claude-agent.d.ts.map +1 -1
- package/dist/agents/claude-agent.js +2 -1
- package/dist/agents/claude-agent.js.map +1 -1
- package/dist/agents/codex-agent.d.ts +1 -1
- package/dist/agents/codex-agent.d.ts.map +1 -1
- package/dist/agents/codex-agent.js +2 -1
- package/dist/agents/codex-agent.js.map +1 -1
- package/dist/agents/intella-lite-agent.d.ts +1 -1
- package/dist/agents/intella-lite-agent.d.ts.map +1 -1
- package/dist/agents/intella-lite-agent.js +2 -1
- package/dist/agents/intella-lite-agent.js.map +1 -1
- package/dist/agents/opencode-agent.d.ts +1 -1
- package/dist/agents/opencode-agent.d.ts.map +1 -1
- package/dist/agents/opencode-agent.js +2 -3
- package/dist/agents/opencode-agent.js.map +1 -1
- package/dist/index.d.ts +22 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/sandbox/{agent-installers.d.ts → agents/agent-installers.d.ts} +1 -1
- package/dist/sandbox/agents/agent-installers.d.ts.map +1 -0
- package/dist/sandbox/{agent-installers.js → agents/agent-installers.js} +5 -4
- package/dist/sandbox/agents/agent-installers.js.map +1 -0
- package/dist/sandbox/{agent-setup.d.ts → agents/agent-setup.d.ts} +1 -1
- package/dist/sandbox/agents/agent-setup.d.ts.map +1 -0
- package/dist/sandbox/{agent-setup.js → agents/agent-setup.js} +3 -2
- package/dist/sandbox/agents/agent-setup.js.map +1 -0
- package/dist/sandbox/agents/agents.d.ts +49 -0
- package/dist/sandbox/agents/agents.d.ts.map +1 -0
- package/dist/sandbox/agents/agents.js +71 -0
- package/dist/sandbox/agents/agents.js.map +1 -0
- package/dist/sandbox/config.d.ts +1 -1
- package/dist/sandbox/config.d.ts.map +1 -1
- package/dist/sandbox/config.js +26 -18
- package/dist/sandbox/config.js.map +1 -1
- package/dist/sandbox/file-utils.d.ts +20 -0
- package/dist/sandbox/file-utils.d.ts.map +1 -0
- package/dist/sandbox/file-utils.js +101 -0
- package/dist/sandbox/file-utils.js.map +1 -0
- package/dist/sandbox/operations/code-operations.d.ts +68 -0
- package/dist/sandbox/operations/code-operations.d.ts.map +1 -0
- package/dist/sandbox/operations/code-operations.js +208 -0
- package/dist/sandbox/operations/code-operations.js.map +1 -0
- package/dist/sandbox/operations/git-operations.d.ts +27 -0
- package/dist/sandbox/operations/git-operations.d.ts.map +1 -0
- package/dist/sandbox/operations/git-operations.js +235 -0
- package/dist/sandbox/operations/git-operations.js.map +1 -0
- package/dist/sandbox/providers/base-provider.d.ts +283 -0
- package/dist/sandbox/providers/base-provider.d.ts.map +1 -0
- package/dist/sandbox/providers/base-provider.js +816 -0
- package/dist/sandbox/providers/base-provider.js.map +1 -0
- package/dist/sandbox/{daytona-provider.d.ts → providers/daytona-provider.d.ts} +19 -16
- package/dist/sandbox/providers/daytona-provider.d.ts.map +1 -0
- package/dist/sandbox/{daytona-provider.js → providers/daytona-provider.js} +96 -27
- package/dist/sandbox/providers/daytona-provider.js.map +1 -0
- package/dist/sandbox/{e2b-provider.d.ts → providers/e2b-provider.d.ts} +16 -10
- package/dist/sandbox/providers/e2b-provider.d.ts.map +1 -0
- package/dist/sandbox/{e2b-provider.js → providers/e2b-provider.js} +51 -29
- package/dist/sandbox/providers/e2b-provider.js.map +1 -0
- package/dist/sandbox/{local-provider.d.ts → providers/local-provider.d.ts} +12 -6
- package/dist/sandbox/providers/local-provider.d.ts.map +1 -0
- package/dist/sandbox/{local-provider.js → providers/local-provider.js} +24 -21
- package/dist/sandbox/providers/local-provider.js.map +1 -0
- package/dist/sandbox/{modal-provider.d.ts → providers/modal-provider.d.ts} +18 -12
- package/dist/sandbox/providers/modal-provider.d.ts.map +1 -0
- package/dist/sandbox/{modal-provider.js → providers/modal-provider.js} +49 -29
- package/dist/sandbox/providers/modal-provider.js.map +1 -0
- package/dist/sandbox/{vercel-provider.d.ts → providers/vercel-provider.d.ts} +19 -14
- package/dist/sandbox/providers/vercel-provider.d.ts.map +1 -0
- package/dist/sandbox/{vercel-provider.js → providers/vercel-provider.js} +41 -42
- package/dist/sandbox/providers/vercel-provider.js.map +1 -0
- package/dist/sandbox/utils/detector.d.ts +28 -0
- package/dist/sandbox/utils/detector.d.ts.map +1 -0
- package/dist/sandbox/utils/detector.js +243 -0
- package/dist/sandbox/utils/detector.js.map +1 -0
- package/dist/sandbox-manager.js +5 -5
- package/dist/sandbox-manager.js.map +1 -1
- package/dist/sdk.d.ts +4 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +7 -3
- package/dist/sdk.js.map +1 -1
- package/dist/session/execution-store.d.ts +71 -0
- package/dist/session/execution-store.d.ts.map +1 -0
- package/dist/session/execution-store.js +156 -0
- package/dist/session/execution-store.js.map +1 -0
- package/dist/session/index.d.ts +14 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +20 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +164 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +493 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/store.d.ts +20 -0
- package/dist/session/store.d.ts.map +1 -0
- package/dist/session/store.js +69 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/types.d.ts +57 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/dist/types.d.ts +622 -19
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +35 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/cli-daemon.d.ts.map +1 -1
- package/dist/utils/cli-daemon.js +1 -3
- package/dist/utils/cli-daemon.js.map +1 -1
- package/dist/utils/machine-id.d.ts +8 -0
- package/dist/utils/machine-id.d.ts.map +1 -0
- package/dist/utils/machine-id.js +19 -0
- package/dist/utils/machine-id.js.map +1 -0
- package/dist/utils/redis/client.d.ts +18 -0
- package/dist/utils/redis/client.d.ts.map +1 -0
- package/dist/utils/redis/client.js +52 -0
- package/dist/utils/redis/client.js.map +1 -0
- package/dist/utils/redis/index.d.ts +2 -0
- package/dist/utils/redis/index.d.ts.map +1 -0
- package/dist/utils/redis/index.js +2 -0
- package/dist/utils/redis/index.js.map +1 -0
- package/dist/utils/{redis-stream.d.ts → redis/stream.d.ts} +41 -74
- package/dist/utils/redis/stream.d.ts.map +1 -0
- package/dist/utils/{redis-stream.js → redis/stream.js} +133 -69
- package/dist/utils/redis/stream.js.map +1 -0
- package/dist/utils/repo-context.d.ts +16 -0
- package/dist/utils/repo-context.d.ts.map +1 -0
- package/dist/utils/repo-context.js +65 -0
- package/dist/utils/repo-context.js.map +1 -0
- package/dist/utils/tool-response.d.ts +20 -0
- package/dist/utils/tool-response.d.ts.map +1 -0
- package/dist/utils/tool-response.js +68 -0
- package/dist/utils/tool-response.js.map +1 -0
- package/package.json +22 -7
- package/dist/sandbox/agent-installers.d.ts.map +0 -1
- package/dist/sandbox/agent-installers.js.map +0 -1
- package/dist/sandbox/agent-setup.d.ts.map +0 -1
- package/dist/sandbox/agent-setup.js.map +0 -1
- package/dist/sandbox/base-provider.d.ts +0 -106
- package/dist/sandbox/base-provider.d.ts.map +0 -1
- package/dist/sandbox/base-provider.js +0 -74
- package/dist/sandbox/base-provider.js.map +0 -1
- package/dist/sandbox/daytona-provider.d.ts.map +0 -1
- package/dist/sandbox/daytona-provider.js.map +0 -1
- package/dist/sandbox/e2b-provider.d.ts.map +0 -1
- package/dist/sandbox/e2b-provider.js.map +0 -1
- package/dist/sandbox/local-provider.d.ts.map +0 -1
- package/dist/sandbox/local-provider.js.map +0 -1
- package/dist/sandbox/modal-provider.d.ts.map +0 -1
- package/dist/sandbox/modal-provider.js.map +0 -1
- package/dist/sandbox/vercel-provider.d.ts.map +0 -1
- package/dist/sandbox/vercel-provider.js.map +0 -1
- package/dist/utils/redis-stream.d.ts.map +0 -1
- package/dist/utils/redis-stream.js.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides reusable methods for publishing commands, chunks, and waiting for results
|
|
4
4
|
*/
|
|
5
5
|
import { createClient } from 'redis';
|
|
6
|
+
import { StreamEventType } from '../../types.js';
|
|
6
7
|
export let client = null;
|
|
7
8
|
/**
|
|
8
9
|
* Generate a unique command ID
|
|
@@ -44,6 +45,18 @@ async function ensureConsumerGroup(client, streamKey, groupName) {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Get Redis stream key for sandbox commands (incoming work for daemon)
|
|
50
|
+
*/
|
|
51
|
+
export function getSandboxCommandsStreamKey(sandboxId) {
|
|
52
|
+
return `sandbox:${sandboxId}:commands`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get Redis stream key for sandbox results (outgoing responses from daemon)
|
|
56
|
+
*/
|
|
57
|
+
export function getSandboxResultsStreamKey(sandboxId) {
|
|
58
|
+
return `sandbox:${sandboxId}:results`;
|
|
59
|
+
}
|
|
47
60
|
/**
|
|
48
61
|
* Publish a command to sandbox-specific Redis stream
|
|
49
62
|
* @param sandboxId - Sandbox ID
|
|
@@ -52,68 +65,38 @@ async function ensureConsumerGroup(client, streamKey, groupName) {
|
|
|
52
65
|
*/
|
|
53
66
|
export async function publishCommand(sandboxId, command, redisUrl) {
|
|
54
67
|
const client = await getRedisClient(redisUrl);
|
|
55
|
-
const
|
|
68
|
+
const cmdId = command.cmdId ?? generateCommandId();
|
|
56
69
|
try {
|
|
57
|
-
const streamKey =
|
|
58
|
-
// Prepare command data for Redis stream
|
|
70
|
+
const streamKey = getSandboxCommandsStreamKey(sandboxId);
|
|
59
71
|
const commandData = {
|
|
60
|
-
|
|
72
|
+
cmdId,
|
|
61
73
|
type: command.type,
|
|
62
|
-
|
|
74
|
+
sessionId: command.sessionId ?? '',
|
|
75
|
+
data: JSON.stringify(command.data),
|
|
76
|
+
metadata: JSON.stringify(command.metadata),
|
|
77
|
+
apiKeys: JSON.stringify(command.apiKeys),
|
|
78
|
+
env: JSON.stringify(command.env ?? {}),
|
|
79
|
+
timestamp: String(command.timestamp ?? Date.now()),
|
|
63
80
|
};
|
|
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
81
|
await client.xAdd(streamKey, '*', commandData);
|
|
98
|
-
return
|
|
82
|
+
return cmdId;
|
|
99
83
|
}
|
|
100
84
|
finally {
|
|
101
85
|
await client.quit();
|
|
102
86
|
}
|
|
103
87
|
}
|
|
104
88
|
/**
|
|
105
|
-
* Publish a chunk to sandbox-specific Redis stream
|
|
89
|
+
* Publish a chunk to sandbox-specific Redis results stream
|
|
106
90
|
* @param sandboxId - Sandbox ID
|
|
107
|
-
* @param chunk - Chunk data to publish
|
|
91
|
+
* @param chunk - Chunk data to publish (include commandId for correlation)
|
|
108
92
|
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
109
93
|
*/
|
|
110
94
|
export async function publishChunk(sandboxId, chunk, redisUrl) {
|
|
111
95
|
const client = await getRedisClient(redisUrl);
|
|
112
96
|
try {
|
|
113
|
-
const streamKey =
|
|
97
|
+
const streamKey = getSandboxResultsStreamKey(sandboxId);
|
|
114
98
|
const chunkId = chunk.chunkId || generateCommandId();
|
|
115
|
-
|
|
116
|
-
await client.xAdd(streamKey, '*', {
|
|
99
|
+
const streamFields = {
|
|
117
100
|
chunkId: chunkId,
|
|
118
101
|
chunk: chunk.chunk || '',
|
|
119
102
|
segmentId: chunk.segmentId || '',
|
|
@@ -122,7 +105,12 @@ export async function publishChunk(sandboxId, chunk, redisUrl) {
|
|
|
122
105
|
senderType: chunk.senderType || '',
|
|
123
106
|
timestamp: String(chunk.timestamp || Date.now()),
|
|
124
107
|
data: chunk.data ? JSON.stringify(chunk.data) : '',
|
|
125
|
-
}
|
|
108
|
+
};
|
|
109
|
+
if (chunk.commandId) {
|
|
110
|
+
streamFields.commandId = chunk.commandId;
|
|
111
|
+
streamFields.resultType = 'chunk';
|
|
112
|
+
}
|
|
113
|
+
await client.xAdd(streamKey, '*', streamFields);
|
|
126
114
|
}
|
|
127
115
|
finally {
|
|
128
116
|
await client.quit();
|
|
@@ -195,20 +183,10 @@ export async function* readFromStream(streamKey, options = {}) {
|
|
|
195
183
|
await client.xAck(streamKey, finalGroupName, message.id);
|
|
196
184
|
continue;
|
|
197
185
|
}
|
|
198
|
-
//
|
|
199
|
-
if (commandId) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// This is a command message, not a result - ACK and skip
|
|
203
|
-
await client.xAck(streamKey, finalGroupName, message.id);
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
// Filter by commandId - only process results for our specific command
|
|
207
|
-
if (msg.commandId !== commandId) {
|
|
208
|
-
// ACK and skip messages not for this command
|
|
209
|
-
await client.xAck(streamKey, finalGroupName, message.id);
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
186
|
+
// Filter by commandId when provided (results stream may have heartbeats without commandId)
|
|
187
|
+
if (commandId && msg.commandId !== commandId) {
|
|
188
|
+
await client.xAck(streamKey, finalGroupName, message.id);
|
|
189
|
+
continue;
|
|
212
190
|
}
|
|
213
191
|
// Transform message to result type
|
|
214
192
|
let result;
|
|
@@ -261,7 +239,7 @@ export async function* readFromStream(streamKey, options = {}) {
|
|
|
261
239
|
* @param options - Additional options
|
|
262
240
|
*/
|
|
263
241
|
export async function* readFromSandbox(sandboxId, commandId, options = {}) {
|
|
264
|
-
const streamKey =
|
|
242
|
+
const streamKey = getSandboxResultsStreamKey(sandboxId);
|
|
265
243
|
const groupName = options.groupName || `sandbox-${sandboxId}-results`;
|
|
266
244
|
yield* readFromStream(streamKey, {
|
|
267
245
|
...options,
|
|
@@ -277,6 +255,36 @@ export async function* readFromSandbox(sandboxId, commandId, options = {}) {
|
|
|
277
255
|
}),
|
|
278
256
|
});
|
|
279
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Stream events from Session or Sandbox Redis stream.
|
|
260
|
+
* @param eventType - 'Session' streams session chunks, 'Sandbox' streams command results
|
|
261
|
+
* @param sandboxOrSessionId - Session ID when eventType is Session, Sandbox ID when Sandbox
|
|
262
|
+
* @param options - groupName, consumerName, commandId (Sandbox only), redisUrl, etc.
|
|
263
|
+
*/
|
|
264
|
+
export async function* streamEvents(eventType, sandboxOrSessionId, options = {}) {
|
|
265
|
+
if (eventType === StreamEventType.SESSION) {
|
|
266
|
+
yield* readFromSession(sandboxOrSessionId, {
|
|
267
|
+
redisUrl: options.redisUrl,
|
|
268
|
+
timeout: options.timeout,
|
|
269
|
+
groupName: options.groupName,
|
|
270
|
+
consumerName: options.consumerName,
|
|
271
|
+
blockTime: options.blockTime,
|
|
272
|
+
count: options.count,
|
|
273
|
+
stopOnDone: options.stopOnDone ?? false,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
yield* readFromSandbox(sandboxOrSessionId, options.commandId, {
|
|
278
|
+
redisUrl: options.redisUrl,
|
|
279
|
+
timeout: options.timeout,
|
|
280
|
+
groupName: options.groupName,
|
|
281
|
+
consumerName: options.consumerName,
|
|
282
|
+
blockTime: options.blockTime,
|
|
283
|
+
count: options.count,
|
|
284
|
+
stopOnDone: options.stopOnDone ?? true,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
280
288
|
/**
|
|
281
289
|
* Read chunks from session stream (convenience function)
|
|
282
290
|
* @param sessionId - Session ID
|
|
@@ -309,16 +317,41 @@ export async function* readFromSession(sessionId, options = {}) {
|
|
|
309
317
|
}),
|
|
310
318
|
});
|
|
311
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Publish agent:execute command then yield chunks from session stream (convenience helper)
|
|
322
|
+
* @param sandboxId - Sandbox ID
|
|
323
|
+
* @param taskRequest - Full task request (must include sessionId)
|
|
324
|
+
* @param agentType - Optional agent type (can also be on taskRequest.agentType)
|
|
325
|
+
* @param options - Optional redisUrl and apiKeys
|
|
326
|
+
*/
|
|
327
|
+
export async function* streamAgentExecution(sandboxId, taskRequest, _agentType, options) {
|
|
328
|
+
const sessionId = taskRequest.sessionId;
|
|
329
|
+
if (!sessionId) {
|
|
330
|
+
throw new Error('TaskRequest.sessionId is required for streamAgentExecution');
|
|
331
|
+
}
|
|
332
|
+
await publishCommand(sandboxId, {
|
|
333
|
+
type: 'agent:execute',
|
|
334
|
+
sessionId,
|
|
335
|
+
data: taskRequest,
|
|
336
|
+
metadata: {},
|
|
337
|
+
apiKeys: options?.apiKeys ?? {},
|
|
338
|
+
env: {},
|
|
339
|
+
timestamp: Date.now(),
|
|
340
|
+
}, options?.redisUrl);
|
|
341
|
+
yield* readFromSession(sessionId, { redisUrl: options?.redisUrl });
|
|
342
|
+
}
|
|
312
343
|
/**
|
|
313
344
|
* Wait for a success result for a specific command
|
|
314
345
|
* @param sandboxId - Sandbox ID
|
|
315
346
|
* @param commandId - Command ID to wait for
|
|
316
347
|
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
317
348
|
* @param timeout - Timeout in milliseconds (default: 10 minutes)
|
|
349
|
+
* @param execute - Function to execute when success is received
|
|
350
|
+
* @param onRead - Function to execute when a new message is read
|
|
318
351
|
* @returns Promise that resolves when success is received
|
|
319
352
|
* @throws Error if timeout or error result is received
|
|
320
353
|
*/
|
|
321
|
-
export async function waitForSuccess(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000) {
|
|
354
|
+
export async function waitForSuccess(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000, execute, onRead) {
|
|
322
355
|
const client = await getRedisClient(redisUrl);
|
|
323
356
|
const streamKey = `sandbox:${sandboxId}:stream`;
|
|
324
357
|
const groupName = `sandbox-${sandboxId}-wait`;
|
|
@@ -326,8 +359,13 @@ export async function waitForSuccess(sandboxId, commandId, redisUrl, timeout = 1
|
|
|
326
359
|
try {
|
|
327
360
|
await ensureConsumerGroup(client, streamKey, groupName);
|
|
328
361
|
const deadline = Date.now() + timeout;
|
|
362
|
+
let isRead = false;
|
|
329
363
|
while (Date.now() < deadline) {
|
|
330
364
|
const raw = await client.xReadGroup(groupName, consumerName, [{ key: streamKey, id: '>' }], { COUNT: 10, BLOCK: 1000 });
|
|
365
|
+
if (!isRead && onRead) {
|
|
366
|
+
await onRead();
|
|
367
|
+
isRead = true;
|
|
368
|
+
}
|
|
331
369
|
const replies = Array.isArray(raw) ? raw : [];
|
|
332
370
|
if (replies.length === 0)
|
|
333
371
|
continue;
|
|
@@ -341,13 +379,17 @@ export async function waitForSuccess(sandboxId, commandId, redisUrl, timeout = 1
|
|
|
341
379
|
// Only process results for our command
|
|
342
380
|
if (msg.commandId === commandId) {
|
|
343
381
|
if (msg.type === 'success') {
|
|
344
|
-
|
|
382
|
+
const result = {
|
|
345
383
|
commandId: msg.commandId,
|
|
346
384
|
type: 'success',
|
|
347
385
|
sessionId: msg.sessionId,
|
|
348
386
|
data: msg.data ? JSON.parse(msg.data) : undefined,
|
|
349
387
|
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
350
388
|
};
|
|
389
|
+
if (execute) {
|
|
390
|
+
await execute(result);
|
|
391
|
+
}
|
|
392
|
+
return result;
|
|
351
393
|
}
|
|
352
394
|
if (msg.type === 'error') {
|
|
353
395
|
throw new Error(`Command failed: ${msg.error || 'unknown error'}`);
|
|
@@ -368,19 +410,26 @@ export async function waitForSuccess(sandboxId, commandId, redisUrl, timeout = 1
|
|
|
368
410
|
* @param commandId - Command ID to wait for
|
|
369
411
|
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
370
412
|
* @param timeout - Timeout in milliseconds (default: 10 minutes)
|
|
413
|
+
* @param execute - Function to execute when error is received
|
|
414
|
+
* @param onRead - Function to execute when a new message is read
|
|
371
415
|
* @returns Promise that resolves with error result
|
|
372
416
|
* @throws Error if timeout
|
|
373
417
|
*/
|
|
374
|
-
export async function waitForError(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000) {
|
|
418
|
+
export async function waitForError(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000, execute, onRead) {
|
|
375
419
|
const client = await getRedisClient(redisUrl);
|
|
376
|
-
const streamKey =
|
|
420
|
+
const streamKey = getSandboxResultsStreamKey(sandboxId);
|
|
377
421
|
const groupName = `sandbox-${sandboxId}-wait`;
|
|
378
422
|
const consumerName = `consumer-${Date.now()}`;
|
|
379
423
|
try {
|
|
380
424
|
await ensureConsumerGroup(client, streamKey, groupName);
|
|
381
425
|
const deadline = Date.now() + timeout;
|
|
426
|
+
let isRead = false;
|
|
382
427
|
while (Date.now() < deadline) {
|
|
383
428
|
const raw = await client.xReadGroup(groupName, consumerName, [{ key: streamKey, id: '>' }], { COUNT: 10, BLOCK: 1000 });
|
|
429
|
+
if (!isRead && onRead) {
|
|
430
|
+
await onRead();
|
|
431
|
+
isRead = true;
|
|
432
|
+
}
|
|
384
433
|
const replies = Array.isArray(raw) ? raw : [];
|
|
385
434
|
if (replies.length === 0)
|
|
386
435
|
continue;
|
|
@@ -393,13 +442,17 @@ export async function waitForError(sandboxId, commandId, redisUrl, timeout = 10
|
|
|
393
442
|
await client.xAck(streamKey, groupName, msgId);
|
|
394
443
|
// Only process results for our command
|
|
395
444
|
if (msg.commandId === commandId && msg.type === 'error') {
|
|
396
|
-
|
|
445
|
+
const result = {
|
|
397
446
|
commandId: msg.commandId,
|
|
398
447
|
type: 'error',
|
|
399
448
|
sessionId: msg.sessionId,
|
|
400
449
|
error: msg.error,
|
|
401
450
|
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
402
451
|
};
|
|
452
|
+
if (execute) {
|
|
453
|
+
await execute(result);
|
|
454
|
+
}
|
|
455
|
+
return result;
|
|
403
456
|
}
|
|
404
457
|
}
|
|
405
458
|
}
|
|
@@ -416,19 +469,26 @@ export async function waitForError(sandboxId, commandId, redisUrl, timeout = 10
|
|
|
416
469
|
* @param commandId - Command ID to wait for
|
|
417
470
|
* @param redisUrl - Optional Redis URL (defaults to REDIS_URL env var)
|
|
418
471
|
* @param timeout - Timeout in milliseconds (default: 10 minutes)
|
|
472
|
+
* @param execute - Function to execute when done or error is received
|
|
473
|
+
* @param onRead - Function to execute when a new message is read
|
|
419
474
|
* @returns Promise that resolves with done or error result
|
|
420
475
|
* @throws Error if timeout
|
|
421
476
|
*/
|
|
422
|
-
export async function waitForResult(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000) {
|
|
477
|
+
export async function waitForResult(sandboxId, commandId, redisUrl, timeout = 10 * 60 * 1000, execute, onRead) {
|
|
423
478
|
const client = await getRedisClient(redisUrl);
|
|
424
|
-
const streamKey =
|
|
479
|
+
const streamKey = getSandboxResultsStreamKey(sandboxId);
|
|
425
480
|
const groupName = `sandbox-${sandboxId}-wait`;
|
|
426
481
|
const consumerName = `consumer-${Date.now()}`;
|
|
427
482
|
try {
|
|
428
483
|
await ensureConsumerGroup(client, streamKey, groupName);
|
|
429
484
|
const deadline = Date.now() + timeout;
|
|
485
|
+
let isRead = false;
|
|
430
486
|
while (Date.now() < deadline) {
|
|
431
487
|
const raw = await client.xReadGroup(groupName, consumerName, [{ key: streamKey, id: '>' }], { COUNT: 10, BLOCK: 1000 });
|
|
488
|
+
if (!isRead && onRead) {
|
|
489
|
+
await onRead();
|
|
490
|
+
isRead = true;
|
|
491
|
+
}
|
|
432
492
|
const replies = Array.isArray(raw) ? raw : [];
|
|
433
493
|
if (replies.length === 0)
|
|
434
494
|
continue;
|
|
@@ -442,7 +502,7 @@ export async function waitForResult(sandboxId, commandId, redisUrl, timeout = 10
|
|
|
442
502
|
// Only process results for our command
|
|
443
503
|
if (msg.commandId === commandId) {
|
|
444
504
|
if (msg.type === 'done' || msg.type === 'error') {
|
|
445
|
-
|
|
505
|
+
const result = {
|
|
446
506
|
commandId: msg.commandId,
|
|
447
507
|
type: msg.type,
|
|
448
508
|
sessionId: msg.sessionId,
|
|
@@ -450,6 +510,10 @@ export async function waitForResult(sandboxId, commandId, redisUrl, timeout = 10
|
|
|
450
510
|
error: msg.error,
|
|
451
511
|
timestamp: parseInt(msg.timestamp || String(Date.now()), 10),
|
|
452
512
|
};
|
|
513
|
+
if (execute) {
|
|
514
|
+
await execute(result);
|
|
515
|
+
}
|
|
516
|
+
return result;
|
|
453
517
|
}
|
|
454
518
|
}
|
|
455
519
|
}
|
|
@@ -461,4 +525,4 @@ export async function waitForResult(sandboxId, commandId, redisUrl, timeout = 10
|
|
|
461
525
|
await client.quit();
|
|
462
526
|
}
|
|
463
527
|
}
|
|
464
|
-
//# sourceMappingURL=
|
|
528
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/utils/redis/stream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAS3D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,CAAC,IAAI,MAAM,GAA2B,IAAI,CAAC;AACjD;;GAEG;AACH,SAAS,iBAAiB;IACxB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,OAAO,OAAO,SAAS,IAAI,MAAM,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAiB;IACpD,MAAM,GAAG,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC1F,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjC,CA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E,CAAC;wBAChC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;4BAChD,MAAM,MAAM,GAAyB;gCACnC,SAAS,EAAE,GAAG,CAAC,SAAS;gCACxB,IAAI,EAAE,GAAG,CAAC,IAAwB;gCAClC,SAAS,EAAE,GAAG,CAAC,SAAS;gCACxB,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;gCACjD,KAAK,EAAE,GAAG,CAAC,KAAK;gCAChB,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;6BAC7D,CAAC;4BACF,IAAI,OAAO,EAAE,CAAC;gCACZ,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;4BACxB,CAAC;4BACD,OAAO,MAAM,CAAC;wBAChB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo Context Utilities
|
|
3
|
+
*
|
|
4
|
+
* Types and prompt builder for repo annotations.
|
|
5
|
+
* Used by the SDK to build repo context prompts from RepoPath data.
|
|
6
|
+
*/
|
|
7
|
+
import type { RepoPath } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Build a prompt snippet describing the workspace repos
|
|
10
|
+
* Used to augment the agent's task request
|
|
11
|
+
*
|
|
12
|
+
* @param repoPaths - Array of repo paths with status
|
|
13
|
+
* @returns Prompt snippet describing available repos
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildRepoContextPrompt(repoPaths: RepoPath[] | RepoPath): string;
|
|
16
|
+
//# sourceMappingURL=repo-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-context.d.ts","sourceRoot":"","sources":["../../src/utils/repo-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAM5C;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,QAAQ,GAAG,MAAM,CAgE/E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo Context Utilities
|
|
3
|
+
*
|
|
4
|
+
* Types and prompt builder for repo annotations.
|
|
5
|
+
* Used by the SDK to build repo context prompts from RepoPath data.
|
|
6
|
+
*/
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Prompt Builder
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Build a prompt snippet describing the workspace repos
|
|
12
|
+
* Used to augment the agent's task request
|
|
13
|
+
*
|
|
14
|
+
* @param repoPaths - Array of repo paths with status
|
|
15
|
+
* @returns Prompt snippet describing available repos
|
|
16
|
+
*/
|
|
17
|
+
export function buildRepoContextPrompt(repoPaths) {
|
|
18
|
+
const repos = Array.isArray(repoPaths) ? repoPaths : [repoPaths];
|
|
19
|
+
const successfulRepos = repos.filter((r) => r.success);
|
|
20
|
+
const failedRepos = repos.filter((r) => !r.success);
|
|
21
|
+
if (repos.length === 0) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
const lines = [
|
|
25
|
+
'\n## Workspace Repositories\n',
|
|
26
|
+
'The following repositories are available in your workspace:\n',
|
|
27
|
+
];
|
|
28
|
+
const sourceRepos = successfulRepos.filter((r) => r.role === 'source');
|
|
29
|
+
const targetRepos = successfulRepos.filter((r) => r.role === 'target');
|
|
30
|
+
const allRepos = successfulRepos.filter((r) => r.role === 'all' || !r.role);
|
|
31
|
+
if (sourceRepos.length > 0) {
|
|
32
|
+
lines.push('\n### Source Repositories (read-only context):\n');
|
|
33
|
+
for (const repo of sourceRepos) {
|
|
34
|
+
lines.push(`- **${repo.repoName}**: \`${repo.path}\` (branch: ${repo.branch})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (targetRepos.length > 0) {
|
|
38
|
+
lines.push('\n### Target Repositories (for writing and reading ):\n');
|
|
39
|
+
for (const repo of targetRepos) {
|
|
40
|
+
let line = `- **${repo.repoName}**: \`${repo.path}\` (branch: ${repo.branch})`;
|
|
41
|
+
if (repo.branchStrategy === 'follow-on') {
|
|
42
|
+
line += ' — use this branch for follow-on work; add new commits after you have finished your work.';
|
|
43
|
+
}
|
|
44
|
+
lines.push(line);
|
|
45
|
+
}
|
|
46
|
+
lines.push('Ensure you push your changes to the target repository after you have finished your work.');
|
|
47
|
+
}
|
|
48
|
+
if (allRepos.length > 0) {
|
|
49
|
+
lines.push('\n### Repositories:\n');
|
|
50
|
+
for (const repo of allRepos) {
|
|
51
|
+
lines.push(`- **${repo.repoName}**: \`${repo.path}\` (branch: ${repo.branch})`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
lines.push('\n');
|
|
55
|
+
if (failedRepos.length > 0) {
|
|
56
|
+
lines.push('\n### Failed Clone Repositories:\n The following repositories failed to clone:');
|
|
57
|
+
for (const repo of failedRepos) {
|
|
58
|
+
lines.push(`- **${repo.repoName}**: \`${repo.path}\` (branch: ${repo.branch}). Error: ${repo.error}`);
|
|
59
|
+
}
|
|
60
|
+
lines.push('Notify the user about this');
|
|
61
|
+
}
|
|
62
|
+
lines.push('\n');
|
|
63
|
+
return lines.join('\n');
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=repo-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-context.js","sourceRoot":"","sources":["../../src/utils/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AC1F,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC3C,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAGjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Response Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for formatting and storing large tool responses.
|
|
5
|
+
* Used by both the app and CLI when building TaskRequests.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolResponseData } from '../types.js';
|
|
8
|
+
/** Maximum length for inline tool response output (characters) */
|
|
9
|
+
export declare const TOOL_RESPONSE_MAX_INLINE_LENGTH = 10000;
|
|
10
|
+
/** File path template for large tool responses */
|
|
11
|
+
/**
|
|
12
|
+
* Format tool response as Markdown for file storage
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatToolResponseMarkdown(toolData: ToolResponseData): string;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a tool response output needs to be written to file
|
|
17
|
+
* (i.e., exceeds the inline length threshold)
|
|
18
|
+
*/
|
|
19
|
+
export declare function shouldWriteToolResponseToFile(output: string | undefined): boolean;
|
|
20
|
+
//# sourceMappingURL=tool-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-response.d.ts","sourceRoot":"","sources":["../../src/utils/tool-response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,kEAAkE;AAClE,eAAO,MAAM,+BAA+B,QAAQ,CAAC;AAErD,kDAAkD;AAMlD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CA4C7E;AAQD;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEjF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Response Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for formatting and storing large tool responses.
|
|
5
|
+
* Used by both the app and CLI when building TaskRequests.
|
|
6
|
+
*/
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Constants
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/** Maximum length for inline tool response output (characters) */
|
|
11
|
+
export const TOOL_RESPONSE_MAX_INLINE_LENGTH = 10000;
|
|
12
|
+
/** File path template for large tool responses */
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// Formatting
|
|
15
|
+
// =============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Format tool response as Markdown for file storage
|
|
18
|
+
*/
|
|
19
|
+
export function formatToolResponseMarkdown(toolData) {
|
|
20
|
+
const lines = [];
|
|
21
|
+
lines.push(`# Tool Response: ${toolData.toolName || 'Unknown Tool'}`);
|
|
22
|
+
lines.push('');
|
|
23
|
+
lines.push(`**ID:** ${toolData.id || 'N/A'}`);
|
|
24
|
+
lines.push(`**Status:** ${toolData.status || 'completed'}`);
|
|
25
|
+
if (toolData.toolCallId) {
|
|
26
|
+
lines.push(`**Tool Call ID:** ${toolData.toolCallId}`);
|
|
27
|
+
}
|
|
28
|
+
lines.push('');
|
|
29
|
+
// Input section
|
|
30
|
+
lines.push('## Input');
|
|
31
|
+
lines.push('');
|
|
32
|
+
lines.push('```json');
|
|
33
|
+
if (toolData.input) {
|
|
34
|
+
lines.push(typeof toolData.input === 'string'
|
|
35
|
+
? toolData.input
|
|
36
|
+
: JSON.stringify(toolData.input, null, 2));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
lines.push('{}');
|
|
40
|
+
}
|
|
41
|
+
lines.push('```');
|
|
42
|
+
lines.push('');
|
|
43
|
+
// Output section
|
|
44
|
+
lines.push('## Output');
|
|
45
|
+
lines.push('');
|
|
46
|
+
lines.push('```');
|
|
47
|
+
lines.push(toolData.output || '');
|
|
48
|
+
lines.push('```');
|
|
49
|
+
// Error section (if failed)
|
|
50
|
+
if (toolData.status === 'failed' && toolData.error) {
|
|
51
|
+
lines.push('');
|
|
52
|
+
lines.push('## Error');
|
|
53
|
+
lines.push('');
|
|
54
|
+
lines.push(toolData.error);
|
|
55
|
+
}
|
|
56
|
+
return lines.join('\n');
|
|
57
|
+
}
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// File Writing
|
|
60
|
+
// =============================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Check if a tool response output needs to be written to file
|
|
63
|
+
* (i.e., exceeds the inline length threshold)
|
|
64
|
+
*/
|
|
65
|
+
export function shouldWriteToolResponseToFile(output) {
|
|
66
|
+
return !!output && output.length > TOOL_RESPONSE_MAX_INLINE_LENGTH;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=tool-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-response.js","sourceRoot":"","sources":["../../src/utils/tool-response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,kEAAkE;AAClE,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAErD,kDAAkD;AAElD,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAA0B;IACnE,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,oBAAoB,QAAQ,CAAC,QAAQ,IAAI,cAAc,EAAE,CAAC,CAAC;IACtE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,WAAW,QAAQ,CAAC,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;IAC9C,KAAK,CAAC,IAAI,CAAC,eAAe,QAAQ,CAAC,MAAM,IAAI,WAAW,E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