@meistrari/sandbox-sdk 1.0.2 → 1.0.4
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/index.cjs +21 -11
- package/dist/index.mjs +21 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -290,8 +290,8 @@ class SandboxClient {
|
|
|
290
290
|
}
|
|
291
291
|
let capturedRunId;
|
|
292
292
|
let receivedDone = false;
|
|
293
|
-
let
|
|
294
|
-
let
|
|
293
|
+
let stdoutCharsEmitted = 0;
|
|
294
|
+
let stderrCharsEmitted = 0;
|
|
295
295
|
try {
|
|
296
296
|
for await (const event of parseSSEStream(res)) {
|
|
297
297
|
if (event.type === "run_created" && event.runId) {
|
|
@@ -301,10 +301,10 @@ class SandboxClient {
|
|
|
301
301
|
receivedDone = true;
|
|
302
302
|
}
|
|
303
303
|
if (event.type === "stdout" && event.content) {
|
|
304
|
-
|
|
304
|
+
stdoutCharsEmitted += event.content.length;
|
|
305
305
|
}
|
|
306
306
|
if (event.type === "stderr" && event.content) {
|
|
307
|
-
|
|
307
|
+
stderrCharsEmitted += event.content.length;
|
|
308
308
|
}
|
|
309
309
|
yield event;
|
|
310
310
|
}
|
|
@@ -315,9 +315,19 @@ class SandboxClient {
|
|
|
315
315
|
if (!capturedRunId) {
|
|
316
316
|
throw error;
|
|
317
317
|
}
|
|
318
|
-
let run
|
|
319
|
-
|
|
320
|
-
run = await
|
|
318
|
+
let run;
|
|
319
|
+
try {
|
|
320
|
+
run = await this.getRun(capturedRunId);
|
|
321
|
+
if (!run.isComplete) {
|
|
322
|
+
run = await run.waitForCompletion();
|
|
323
|
+
}
|
|
324
|
+
} catch (pollError) {
|
|
325
|
+
yield {
|
|
326
|
+
type: "error",
|
|
327
|
+
runId: capturedRunId,
|
|
328
|
+
content: pollError instanceof Error ? pollError.message : "Polling fallback failed"
|
|
329
|
+
};
|
|
330
|
+
return;
|
|
321
331
|
}
|
|
322
332
|
if (run.status !== "completed") {
|
|
323
333
|
yield {
|
|
@@ -327,11 +337,11 @@ class SandboxClient {
|
|
|
327
337
|
};
|
|
328
338
|
return;
|
|
329
339
|
}
|
|
330
|
-
if (run.stdout && run.stdout.length >
|
|
331
|
-
yield { type: "stdout", content: run.stdout.slice(
|
|
340
|
+
if (run.stdout && run.stdout.length > stdoutCharsEmitted) {
|
|
341
|
+
yield { type: "stdout", content: run.stdout.slice(stdoutCharsEmitted) };
|
|
332
342
|
}
|
|
333
|
-
if (run.stderr && run.stderr.length >
|
|
334
|
-
yield { type: "stderr", content: run.stderr.slice(
|
|
343
|
+
if (run.stderr && run.stderr.length > stderrCharsEmitted) {
|
|
344
|
+
yield { type: "stderr", content: run.stderr.slice(stderrCharsEmitted) };
|
|
335
345
|
}
|
|
336
346
|
yield {
|
|
337
347
|
type: "done",
|
package/dist/index.mjs
CHANGED
|
@@ -288,8 +288,8 @@ class SandboxClient {
|
|
|
288
288
|
}
|
|
289
289
|
let capturedRunId;
|
|
290
290
|
let receivedDone = false;
|
|
291
|
-
let
|
|
292
|
-
let
|
|
291
|
+
let stdoutCharsEmitted = 0;
|
|
292
|
+
let stderrCharsEmitted = 0;
|
|
293
293
|
try {
|
|
294
294
|
for await (const event of parseSSEStream(res)) {
|
|
295
295
|
if (event.type === "run_created" && event.runId) {
|
|
@@ -299,10 +299,10 @@ class SandboxClient {
|
|
|
299
299
|
receivedDone = true;
|
|
300
300
|
}
|
|
301
301
|
if (event.type === "stdout" && event.content) {
|
|
302
|
-
|
|
302
|
+
stdoutCharsEmitted += event.content.length;
|
|
303
303
|
}
|
|
304
304
|
if (event.type === "stderr" && event.content) {
|
|
305
|
-
|
|
305
|
+
stderrCharsEmitted += event.content.length;
|
|
306
306
|
}
|
|
307
307
|
yield event;
|
|
308
308
|
}
|
|
@@ -313,9 +313,19 @@ class SandboxClient {
|
|
|
313
313
|
if (!capturedRunId) {
|
|
314
314
|
throw error;
|
|
315
315
|
}
|
|
316
|
-
let run
|
|
317
|
-
|
|
318
|
-
run = await
|
|
316
|
+
let run;
|
|
317
|
+
try {
|
|
318
|
+
run = await this.getRun(capturedRunId);
|
|
319
|
+
if (!run.isComplete) {
|
|
320
|
+
run = await run.waitForCompletion();
|
|
321
|
+
}
|
|
322
|
+
} catch (pollError) {
|
|
323
|
+
yield {
|
|
324
|
+
type: "error",
|
|
325
|
+
runId: capturedRunId,
|
|
326
|
+
content: pollError instanceof Error ? pollError.message : "Polling fallback failed"
|
|
327
|
+
};
|
|
328
|
+
return;
|
|
319
329
|
}
|
|
320
330
|
if (run.status !== "completed") {
|
|
321
331
|
yield {
|
|
@@ -325,11 +335,11 @@ class SandboxClient {
|
|
|
325
335
|
};
|
|
326
336
|
return;
|
|
327
337
|
}
|
|
328
|
-
if (run.stdout && run.stdout.length >
|
|
329
|
-
yield { type: "stdout", content: run.stdout.slice(
|
|
338
|
+
if (run.stdout && run.stdout.length > stdoutCharsEmitted) {
|
|
339
|
+
yield { type: "stdout", content: run.stdout.slice(stdoutCharsEmitted) };
|
|
330
340
|
}
|
|
331
|
-
if (run.stderr && run.stderr.length >
|
|
332
|
-
yield { type: "stderr", content: run.stderr.slice(
|
|
341
|
+
if (run.stderr && run.stderr.length > stderrCharsEmitted) {
|
|
342
|
+
yield { type: "stderr", content: run.stderr.slice(stderrCharsEmitted) };
|
|
333
343
|
}
|
|
334
344
|
yield {
|
|
335
345
|
type: "done",
|