agentbox-sdk 0.1.301 → 0.1.303
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/{Sandbox-CByFJI8X.d.ts → Sandbox-K6VNqKeo.d.ts} +1 -1
- package/dist/agents/index.d.ts +5 -5
- package/dist/agents/index.js +3 -3
- package/dist/{chunk-INMA52FV.js → chunk-AVXJMCBC.js} +17 -0
- package/dist/{chunk-4MBB6QHD.js → chunk-GBM7LKZF.js} +539 -161
- package/dist/{chunk-ZOWBRUQR.js → chunk-NWAXQ7UD.js} +136 -2
- package/dist/{chunk-LPKKT6YT.js → chunk-QNNAAVJV.js} +80 -9
- package/dist/events/index.d.ts +4 -4
- package/dist/events/index.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/sandboxes/index.d.ts +4 -4
- package/dist/sandboxes/index.js +2 -2
- package/dist/{types-B3N-Qo2q.d.ts → types-Ozo1rHKs.d.ts} +34 -13
- package/package.json +2 -2
|
@@ -155,6 +155,7 @@ function toAISDKEvent(event) {
|
|
|
155
155
|
};
|
|
156
156
|
case "message.completed":
|
|
157
157
|
case "run.completed":
|
|
158
|
+
case "run.cancelled":
|
|
158
159
|
return {
|
|
159
160
|
type: "response-finish",
|
|
160
161
|
id: event.runId,
|
|
@@ -376,9 +377,130 @@ var OpenCodeLogAssembler = class {
|
|
|
376
377
|
return clone(next);
|
|
377
378
|
}
|
|
378
379
|
};
|
|
380
|
+
var ClaudeCodeLogAssembler = class {
|
|
381
|
+
currentMessageId = null;
|
|
382
|
+
textByMessageId = /* @__PURE__ */ new Map();
|
|
383
|
+
thinkingByMessageId = /* @__PURE__ */ new Map();
|
|
384
|
+
byMessageId = /* @__PURE__ */ new Map();
|
|
385
|
+
process(event) {
|
|
386
|
+
if (!isRecord(event)) return [];
|
|
387
|
+
const type = typeof event.type === "string" ? event.type : "";
|
|
388
|
+
if (type === "stream_event") {
|
|
389
|
+
const stream = isRecord(event.event) ? event.event : null;
|
|
390
|
+
if (!stream) return [];
|
|
391
|
+
const streamType = typeof stream.type === "string" ? stream.type : "";
|
|
392
|
+
if (streamType === "message_start") {
|
|
393
|
+
const message = isRecord(stream.message) ? stream.message : null;
|
|
394
|
+
const id = message && typeof message.id === "string" ? message.id : null;
|
|
395
|
+
if (!id) return [];
|
|
396
|
+
this.currentMessageId = id;
|
|
397
|
+
if (!this.textByMessageId.has(id)) this.textByMessageId.set(id, "");
|
|
398
|
+
if (!this.thinkingByMessageId.has(id))
|
|
399
|
+
this.thinkingByMessageId.set(id, "");
|
|
400
|
+
return [this.upsertMessage(id)];
|
|
401
|
+
}
|
|
402
|
+
if (streamType === "content_block_delta") {
|
|
403
|
+
const id = this.currentMessageId;
|
|
404
|
+
if (!id) return [];
|
|
405
|
+
const delta = isRecord(stream.delta) ? stream.delta : null;
|
|
406
|
+
if (!delta) return [];
|
|
407
|
+
if (delta.type === "text_delta" && typeof delta.text === "string" && delta.text) {
|
|
408
|
+
const text = (this.textByMessageId.get(id) ?? "") + delta.text;
|
|
409
|
+
this.textByMessageId.set(id, text);
|
|
410
|
+
return [this.upsertMessage(id)];
|
|
411
|
+
}
|
|
412
|
+
if (delta.type === "thinking_delta" && typeof delta.thinking === "string" && delta.thinking) {
|
|
413
|
+
const thinking = (this.thinkingByMessageId.get(id) ?? "") + delta.thinking;
|
|
414
|
+
this.thinkingByMessageId.set(id, thinking);
|
|
415
|
+
return [this.upsertMessage(id)];
|
|
416
|
+
}
|
|
417
|
+
return [];
|
|
418
|
+
}
|
|
419
|
+
return [];
|
|
420
|
+
}
|
|
421
|
+
if (type === "assistant") {
|
|
422
|
+
const message = isRecord(event.message) ? event.message : null;
|
|
423
|
+
const id = message && typeof message.id === "string" ? message.id : null;
|
|
424
|
+
if (!id || !message) {
|
|
425
|
+
return [clone(event)];
|
|
426
|
+
}
|
|
427
|
+
const final = extractClaudeAssistantContent(message);
|
|
428
|
+
this.textByMessageId.set(id, final.text);
|
|
429
|
+
this.thinkingByMessageId.set(id, final.thinking);
|
|
430
|
+
const snapshot = this.upsertMessage(id, final.extraBlocks);
|
|
431
|
+
this.currentMessageId = null;
|
|
432
|
+
return [snapshot];
|
|
433
|
+
}
|
|
434
|
+
return [clone(event)];
|
|
435
|
+
}
|
|
436
|
+
seed(snapshots) {
|
|
437
|
+
this.currentMessageId = null;
|
|
438
|
+
this.textByMessageId.clear();
|
|
439
|
+
this.thinkingByMessageId.clear();
|
|
440
|
+
this.byMessageId.clear();
|
|
441
|
+
for (const snapshot of snapshots) {
|
|
442
|
+
if (!isRecord(snapshot)) continue;
|
|
443
|
+
if (snapshot.type !== "message.updated") continue;
|
|
444
|
+
const messageId = typeof snapshot.messageId === "string" ? snapshot.messageId : null;
|
|
445
|
+
if (!messageId) continue;
|
|
446
|
+
this.byMessageId.set(messageId, clone(snapshot));
|
|
447
|
+
const message = isRecord(snapshot.message) ? snapshot.message : null;
|
|
448
|
+
const content = message && Array.isArray(message.content) ? message.content : [];
|
|
449
|
+
let text = "";
|
|
450
|
+
let thinking = "";
|
|
451
|
+
for (const block of content) {
|
|
452
|
+
if (!isRecord(block)) continue;
|
|
453
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
454
|
+
text += block.text;
|
|
455
|
+
} else if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
456
|
+
thinking += block.thinking;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
this.textByMessageId.set(messageId, text);
|
|
460
|
+
this.thinkingByMessageId.set(messageId, thinking);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
upsertMessage(messageId, extraBlocks = []) {
|
|
464
|
+
const text = this.textByMessageId.get(messageId) ?? "";
|
|
465
|
+
const thinking = this.thinkingByMessageId.get(messageId) ?? "";
|
|
466
|
+
const content = [];
|
|
467
|
+
if (text) content.push({ type: "text", text });
|
|
468
|
+
if (thinking) content.push({ type: "thinking", thinking });
|
|
469
|
+
for (const block of extraBlocks) content.push(clone(block));
|
|
470
|
+
const next = {
|
|
471
|
+
type: "message.updated",
|
|
472
|
+
messageId,
|
|
473
|
+
message: {
|
|
474
|
+
id: messageId,
|
|
475
|
+
role: "assistant",
|
|
476
|
+
content
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
this.byMessageId.set(messageId, next);
|
|
480
|
+
return clone(next);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
function extractClaudeAssistantContent(message) {
|
|
484
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
485
|
+
let text = "";
|
|
486
|
+
let thinking = "";
|
|
487
|
+
const extraBlocks = [];
|
|
488
|
+
for (const block of content) {
|
|
489
|
+
if (!isRecord(block)) continue;
|
|
490
|
+
if (block.type === "text" && typeof block.text === "string") {
|
|
491
|
+
text += block.text;
|
|
492
|
+
} else if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
493
|
+
thinking += block.thinking;
|
|
494
|
+
} else {
|
|
495
|
+
extraBlocks.push(clone(block));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return { text, thinking, extraBlocks };
|
|
499
|
+
}
|
|
379
500
|
var ProviderLogAssembler = class {
|
|
380
501
|
codex = new CodexLogAssembler();
|
|
381
502
|
openCode = new OpenCodeLogAssembler();
|
|
503
|
+
claudeCode = new ClaudeCodeLogAssembler();
|
|
382
504
|
/**
|
|
383
505
|
* Process a raw provider event and return any newly-produced assembled
|
|
384
506
|
* snapshots. May return an empty array when the event is non-stateful (e.g.
|
|
@@ -391,6 +513,9 @@ var ProviderLogAssembler = class {
|
|
|
391
513
|
if (provider === AgentProvider.OpenCode || provider === "opencode") {
|
|
392
514
|
return this.openCode.process(event);
|
|
393
515
|
}
|
|
516
|
+
if (provider === AgentProvider.ClaudeCode || provider === "claude-code") {
|
|
517
|
+
return this.claudeCode.process(event);
|
|
518
|
+
}
|
|
394
519
|
if (isRecord(event)) {
|
|
395
520
|
return [clone(event)];
|
|
396
521
|
}
|
|
@@ -411,14 +536,17 @@ var ProviderLogAssembler = class {
|
|
|
411
536
|
this.openCode.seed(snapshots);
|
|
412
537
|
return;
|
|
413
538
|
}
|
|
539
|
+
if (provider === AgentProvider.ClaudeCode || provider === "claude-code") {
|
|
540
|
+
this.claudeCode.seed(snapshots);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
414
543
|
}
|
|
415
544
|
/**
|
|
416
545
|
* Given a sequence of assembled snapshots (typically the persisted history
|
|
417
546
|
* for a run), return one entry per item / part with the latest snapshot
|
|
418
547
|
* winning, preserving first-seen order.
|
|
419
548
|
*
|
|
420
|
-
* For
|
|
421
|
-
* for unrecognized snapshot shapes, entries are returned in original order
|
|
549
|
+
* For unrecognized snapshot shapes, entries are returned in original order
|
|
422
550
|
* with no dedup.
|
|
423
551
|
*/
|
|
424
552
|
static dedupeSnapshots(provider, snapshots) {
|
|
@@ -429,6 +557,12 @@ var ProviderLogAssembler = class {
|
|
|
429
557
|
return item && typeof item.id === "string" ? `item:${item.id}` : null;
|
|
430
558
|
});
|
|
431
559
|
}
|
|
560
|
+
if (provider === AgentProvider.ClaudeCode || provider === "claude-code") {
|
|
561
|
+
return dedupeByKey(snapshots, (snapshot) => {
|
|
562
|
+
const messageId = typeof snapshot.messageId === "string" ? snapshot.messageId : null;
|
|
563
|
+
return messageId ? `message:${messageId}` : null;
|
|
564
|
+
});
|
|
565
|
+
}
|
|
432
566
|
if (provider === AgentProvider.OpenCode || provider === "opencode") {
|
|
433
567
|
return dedupeByKey(snapshots, (snapshot) => {
|
|
434
568
|
const properties = isRecord(snapshot.properties) ? snapshot.properties : null;
|
|
@@ -5,11 +5,12 @@ import {
|
|
|
5
5
|
debugSandbox,
|
|
6
6
|
pipeReadableStream,
|
|
7
7
|
readNodeStream,
|
|
8
|
+
readStreamAsBytes,
|
|
8
9
|
readStreamAsText,
|
|
9
10
|
sleep,
|
|
10
11
|
suppressUnhandledRejection,
|
|
11
12
|
time
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-AVXJMCBC.js";
|
|
13
14
|
import {
|
|
14
15
|
shellQuote,
|
|
15
16
|
toShellCommand
|
|
@@ -68,7 +69,7 @@ var SandboxAdapter = class {
|
|
|
68
69
|
* `provision()` implementations. Stays `false` until `findOrProvision()`
|
|
69
70
|
* has resolved.
|
|
70
71
|
*/
|
|
71
|
-
|
|
72
|
+
isWarmFlag = false;
|
|
72
73
|
constructor(options) {
|
|
73
74
|
this.options = options;
|
|
74
75
|
this.baseEnv = { ...options.env ?? {} };
|
|
@@ -167,8 +168,8 @@ var SandboxAdapter = class {
|
|
|
167
168
|
* idempotent setup that the previous run already performed (e.g.
|
|
168
169
|
* `agent.setup()`). Always `false` before `findOrProvision()` resolves.
|
|
169
170
|
*/
|
|
170
|
-
get
|
|
171
|
-
return this.
|
|
171
|
+
get isWarm() {
|
|
172
|
+
return this.isWarmFlag;
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
174
175
|
* Headers that callers should attach to HTTP / WebSocket requests they make
|
|
@@ -241,8 +242,9 @@ var DaytonaSandboxAdapter = class extends SandboxAdapter {
|
|
|
241
242
|
const existing = await this.findMatchingSandbox();
|
|
242
243
|
if (existing) {
|
|
243
244
|
this.sandbox = existing;
|
|
245
|
+
const isWarm = existing.state === "started";
|
|
244
246
|
await existing.start();
|
|
245
|
-
this.
|
|
247
|
+
this.isWarmFlag = isWarm;
|
|
246
248
|
return;
|
|
247
249
|
}
|
|
248
250
|
const labels = this.getLabels();
|
|
@@ -517,7 +519,7 @@ var E2bSandboxAdapter = class extends SandboxAdapter {
|
|
|
517
519
|
const existing = await this.findMatchingSandbox();
|
|
518
520
|
if (existing) {
|
|
519
521
|
this.sandbox = existing;
|
|
520
|
-
this.
|
|
522
|
+
this.isWarmFlag = true;
|
|
521
523
|
return;
|
|
522
524
|
}
|
|
523
525
|
const template = resolveSandboxImage(this.options.image);
|
|
@@ -1284,6 +1286,7 @@ var LocalDockerSandboxAdapter = class extends SandboxAdapter {
|
|
|
1284
1286
|
};
|
|
1285
1287
|
|
|
1286
1288
|
// src/sandboxes/providers/modal.ts
|
|
1289
|
+
import path from "path";
|
|
1287
1290
|
import { ModalClient } from "modal";
|
|
1288
1291
|
|
|
1289
1292
|
// src/sandboxes/tarball.ts
|
|
@@ -1350,7 +1353,7 @@ var ModalSandboxAdapter = class extends SandboxAdapter {
|
|
|
1350
1353
|
const existing = await this.findMatchingSandbox();
|
|
1351
1354
|
if (existing) {
|
|
1352
1355
|
this.sandbox = existing;
|
|
1353
|
-
this.
|
|
1356
|
+
this.isWarmFlag = true;
|
|
1354
1357
|
return;
|
|
1355
1358
|
}
|
|
1356
1359
|
const appName = this.options.provider?.appName ?? "agentbox";
|
|
@@ -1535,6 +1538,74 @@ ${command}`;
|
|
|
1535
1538
|
raw: process2
|
|
1536
1539
|
};
|
|
1537
1540
|
}
|
|
1541
|
+
/**
|
|
1542
|
+
* Upload `content` to `targetPath` inside the Modal sandbox.
|
|
1543
|
+
*
|
|
1544
|
+
* Modal's TS SDK only exposes a `Sandbox.open()` FileIO handle for direct
|
|
1545
|
+
* filesystem access, which is deprecated and capped at 100 MiB per
|
|
1546
|
+
* operation. To match the cross-provider semantics (works for arbitrarily
|
|
1547
|
+
* large artifacts, parent dirs are created on demand), we instead pipe
|
|
1548
|
+
* raw bytes through stdin into a single `mkdir -p … && cat > …` shell —
|
|
1549
|
+
* the same single-exec pattern `uploadAndRun` uses.
|
|
1550
|
+
*/
|
|
1551
|
+
async uploadFile(content, targetPath) {
|
|
1552
|
+
this.requireProvisioned();
|
|
1553
|
+
const sandbox = this.requireSandbox();
|
|
1554
|
+
const data = Buffer.isBuffer(content) ? content : Buffer.from(content, "utf8");
|
|
1555
|
+
const dir = path.posix.dirname(targetPath);
|
|
1556
|
+
const wrapped = dir && dir !== "." && dir !== "/" ? `set -e; mkdir -p ${shellQuote(dir)}; cat > ${shellQuote(targetPath)}` : `set -e; cat > ${shellQuote(targetPath)}`;
|
|
1557
|
+
const proc = await sandbox.exec(["/bin/sh", "-c", wrapped], {
|
|
1558
|
+
mode: "binary"
|
|
1559
|
+
});
|
|
1560
|
+
const writer = proc.stdin.getWriter();
|
|
1561
|
+
try {
|
|
1562
|
+
await writer.write(data);
|
|
1563
|
+
await writer.close();
|
|
1564
|
+
} finally {
|
|
1565
|
+
try {
|
|
1566
|
+
writer.releaseLock();
|
|
1567
|
+
} catch {
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
const [stderrBytes, exitCode] = await Promise.all([
|
|
1571
|
+
readStreamAsBytes(proc.stderr),
|
|
1572
|
+
proc.wait()
|
|
1573
|
+
]);
|
|
1574
|
+
if (exitCode !== 0) {
|
|
1575
|
+
const stderr = stderrBytes.toString("utf8").trim();
|
|
1576
|
+
throw new Error(
|
|
1577
|
+
`Failed to upload file to Modal sandbox at ${targetPath} (exit ${exitCode})${stderr ? `: ${stderr}` : ""}`
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Download a file from the Modal sandbox as raw bytes.
|
|
1583
|
+
*
|
|
1584
|
+
* Implemented by `cat`-ing the file in a binary-mode `exec` and
|
|
1585
|
+
* collecting stdout. This matches the cross-provider contract (returns a
|
|
1586
|
+
* Node `Buffer` of the file's exact bytes) and avoids the deprecated
|
|
1587
|
+
* 100 MiB FileIO cap on `Sandbox.open()`.
|
|
1588
|
+
*/
|
|
1589
|
+
async downloadFile(sourcePath) {
|
|
1590
|
+
this.requireProvisioned();
|
|
1591
|
+
const sandbox = this.requireSandbox();
|
|
1592
|
+
const proc = await sandbox.exec(
|
|
1593
|
+
["/bin/sh", "-c", `cat -- ${shellQuote(sourcePath)}`],
|
|
1594
|
+
{ mode: "binary" }
|
|
1595
|
+
);
|
|
1596
|
+
const [stdoutBytes, stderrBytes, exitCode] = await Promise.all([
|
|
1597
|
+
readStreamAsBytes(proc.stdout),
|
|
1598
|
+
readStreamAsBytes(proc.stderr),
|
|
1599
|
+
proc.wait()
|
|
1600
|
+
]);
|
|
1601
|
+
if (exitCode !== 0) {
|
|
1602
|
+
const stderr = stderrBytes.toString("utf8").trim();
|
|
1603
|
+
throw new Error(
|
|
1604
|
+
`Failed to download file from Modal sandbox at ${sourcePath} (exit ${exitCode})${stderr ? `: ${stderr}` : ""}`
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
return stdoutBytes;
|
|
1608
|
+
}
|
|
1538
1609
|
async list(options) {
|
|
1539
1610
|
const sandboxes = [];
|
|
1540
1611
|
for await (const sandbox of this.client.sandboxes.list({
|
|
@@ -2032,8 +2103,8 @@ var Sandbox = class {
|
|
|
2032
2103
|
* idempotent setup that the previous run already performed (e.g.
|
|
2033
2104
|
* `agent.setup()`). Always `false` before `findOrProvision()` resolves.
|
|
2034
2105
|
*/
|
|
2035
|
-
get
|
|
2036
|
-
return this.adapter.
|
|
2106
|
+
get isWarm() {
|
|
2107
|
+
return this.adapter.isWarm;
|
|
2037
2108
|
}
|
|
2038
2109
|
/**
|
|
2039
2110
|
* Attach to an existing tagged sandbox or create a new one. Must be
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AISDKEvent,
|
|
1
|
+
export { A as AISDKEvent, R as MessageCompletedEvent, S as MessageInjectedEvent, T as MessageStartedEvent, U as NormalizedAgentEvent, V as NormalizedAgentEventBase, W as NormalizedAgentEventType, a0 as PermissionRequestedEvent, a1 as PermissionResolvedEvent, a2 as RawAgentEvent, a3 as ReasoningDeltaEvent, a5 as RunCancelledEvent, a6 as RunCompletedEvent, a7 as RunErrorEvent, a8 as RunStartedEvent, a9 as TextDeltaEvent, ab as ToolCallCompletedEvent, ac as ToolCallDeltaEvent, ad as ToolCallStartedEvent, ag as createNormalizedEvent, ah as normalizeRawAgentEvent, ai as toAISDKEvent, aj as toAISDKStream } from '../types-Ozo1rHKs.js';
|
|
2
2
|
import { AgentProvider } from '../enums.js';
|
|
3
|
-
import '../Sandbox-
|
|
3
|
+
import '../Sandbox-K6VNqKeo.js';
|
|
4
4
|
import 'e2b';
|
|
5
5
|
import '@vercel/sandbox';
|
|
6
6
|
import '@daytonaio/sdk';
|
|
@@ -62,6 +62,7 @@ type JsonRecord = Record<string, unknown>;
|
|
|
62
62
|
declare class ProviderLogAssembler {
|
|
63
63
|
private readonly codex;
|
|
64
64
|
private readonly openCode;
|
|
65
|
+
private readonly claudeCode;
|
|
65
66
|
/**
|
|
66
67
|
* Process a raw provider event and return any newly-produced assembled
|
|
67
68
|
* snapshots. May return an empty array when the event is non-stateful (e.g.
|
|
@@ -80,8 +81,7 @@ declare class ProviderLogAssembler {
|
|
|
80
81
|
* for a run), return one entry per item / part with the latest snapshot
|
|
81
82
|
* winning, preserving first-seen order.
|
|
82
83
|
*
|
|
83
|
-
* For
|
|
84
|
-
* for unrecognized snapshot shapes, entries are returned in original order
|
|
84
|
+
* For unrecognized snapshot shapes, entries are returned in original order
|
|
85
85
|
* with no dedup.
|
|
86
86
|
*/
|
|
87
87
|
static dedupeSnapshots(provider: AgentProvider | string | null | undefined, snapshots: JsonRecord[]): JsonRecord[];
|
package/dist/events/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AISDKEvent, a as AgentApprovalMode, b as AgentAttachRequest, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, h as AgentOptions, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, o as AgentProviderName, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, r as AgentResult, s as AgentRun, t as AgentRunConfig, u as AgentRunSink, v as
|
|
1
|
+
export { A as AISDKEvent, a as AgentApprovalMode, b as AgentAttachRequest, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, h as AgentOptions, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, o as AgentProviderName, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, r as AgentResult, s as AgentRun, t as AgentRunConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AttachedRun, C as ClaudeCodeAgentOptions, z as ClaudeCodeHookConfig, B as ClaudeCodeHookEvent, D as ClaudeCodeHookHandler, E as ClaudeCodeHookMatcherGroup, F as ClaudeCodeHooksConfig, G as ClaudeCodeProviderOptions, H as CodexAgentOptions, I as CodexCommandHook, J as CodexHookEvent, K as CodexHookMatcherGroup, L as CodexHooksConfig, M as CodexProviderOptions, N as DataContent, O as EmbeddedSkillConfig, P as FilePart, Q as ImagePart, R as MessageCompletedEvent, S as MessageInjectedEvent, T as MessageStartedEvent, U as NormalizedAgentEvent, V as NormalizedAgentEventBase, W as NormalizedAgentEventType, X as OpenCodeAgentOptions, Y as OpenCodePluginConfig, Z as OpenCodePluginEvent, _ as OpenCodePluginHookConfig, $ as OpenCodeProviderOptions, a0 as PermissionRequestedEvent, a1 as PermissionResolvedEvent, a2 as RawAgentEvent, a3 as ReasoningDeltaEvent, a4 as RepoSkillConfig, a5 as RunCancelledEvent, a6 as RunCompletedEvent, a7 as RunErrorEvent, a8 as RunStartedEvent, a9 as TextDeltaEvent, aa as TextPart, ab as ToolCallCompletedEvent, ac as ToolCallDeltaEvent, ad as ToolCallStartedEvent, ae as UserContent, af as UserContentPart, ag as createNormalizedEvent, ah as normalizeRawAgentEvent, ai as toAISDKEvent, aj as toAISDKStream } from './types-Ozo1rHKs.js';
|
|
2
2
|
export { AGENT_RESERVED_PORTS, Agent, collectAllAgentReservedPorts } from './agents/index.js';
|
|
3
|
-
export { A as AsyncCommandHandle, C as CommandEvent, a as CommandOptions, b as CommandResult, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, G as GitCloneOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, g as SandboxDescriptor, h as SandboxListOptions, i as SandboxOptions, j as SandboxOptionsBase, k as SandboxOptionsMap, l as SandboxProviderName, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, T as TarballEntry, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from './Sandbox-
|
|
3
|
+
export { A as AsyncCommandHandle, C as CommandEvent, a as CommandOptions, b as CommandResult, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, G as GitCloneOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, g as SandboxDescriptor, h as SandboxListOptions, i as SandboxOptions, j as SandboxOptionsBase, k as SandboxOptionsMap, l as SandboxProviderName, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, T as TarballEntry, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from './Sandbox-K6VNqKeo.js';
|
|
4
4
|
export { SandboxAdapter, buildGitCloneCommand } from './sandboxes/index.js';
|
|
5
5
|
export { ProviderLogAssembler } from './events/index.js';
|
|
6
6
|
export { AgentProvider, SandboxProvider } from './enums.js';
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Agent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GBM7LKZF.js";
|
|
4
4
|
import {
|
|
5
5
|
ProviderLogAssembler,
|
|
6
6
|
createNormalizedEvent,
|
|
7
7
|
normalizeRawAgentEvent,
|
|
8
8
|
toAISDKEvent,
|
|
9
9
|
toAISDKStream
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NWAXQ7UD.js";
|
|
11
11
|
import {
|
|
12
12
|
Sandbox,
|
|
13
13
|
SandboxAdapter,
|
|
14
14
|
buildGitCloneCommand
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QNNAAVJV.js";
|
|
16
16
|
import {
|
|
17
17
|
AGENT_RESERVED_PORTS,
|
|
18
18
|
collectAllAgentReservedPorts
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-AVXJMCBC.js";
|
|
20
20
|
import "./chunk-NSJM57Z4.js";
|
|
21
21
|
import {
|
|
22
22
|
AgentProvider,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as SandboxProviderName, i as SandboxOptions, a as CommandOptions, b as CommandResult, A as AsyncCommandHandle, h as SandboxListOptions, g as SandboxDescriptor, T as TarballEntry, G as GitCloneOptions } from '../Sandbox-
|
|
2
|
-
export { C as CommandEvent, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, j as SandboxOptionsBase, k as SandboxOptionsMap, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from '../Sandbox-
|
|
1
|
+
import { l as SandboxProviderName, i as SandboxOptions, a as CommandOptions, b as CommandResult, A as AsyncCommandHandle, h as SandboxListOptions, g as SandboxDescriptor, T as TarballEntry, G as GitCloneOptions } from '../Sandbox-K6VNqKeo.js';
|
|
2
|
+
export { C as CommandEvent, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, j as SandboxOptionsBase, k as SandboxOptionsMap, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from '../Sandbox-K6VNqKeo.js';
|
|
3
3
|
export { SandboxProvider } from '../enums.js';
|
|
4
4
|
import 'e2b';
|
|
5
5
|
import '@vercel/sandbox';
|
|
@@ -19,7 +19,7 @@ declare abstract class SandboxAdapter<TProvider extends SandboxProviderName = Sa
|
|
|
19
19
|
* `provision()` implementations. Stays `false` until `findOrProvision()`
|
|
20
20
|
* has resolved.
|
|
21
21
|
*/
|
|
22
|
-
protected
|
|
22
|
+
protected isWarmFlag: boolean;
|
|
23
23
|
constructor(options: TOptions);
|
|
24
24
|
abstract get provider(): TProvider;
|
|
25
25
|
abstract get raw(): TRaw | undefined;
|
|
@@ -74,7 +74,7 @@ declare abstract class SandboxAdapter<TProvider extends SandboxProviderName = Sa
|
|
|
74
74
|
* idempotent setup that the previous run already performed (e.g.
|
|
75
75
|
* `agent.setup()`). Always `false` before `findOrProvision()` resolves.
|
|
76
76
|
*/
|
|
77
|
-
get
|
|
77
|
+
get isWarm(): boolean;
|
|
78
78
|
/**
|
|
79
79
|
* Headers that callers should attach to HTTP / WebSocket requests they make
|
|
80
80
|
* against this sandbox's preview URL. Default is empty; providers like
|
package/dist/sandboxes/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentProvider } from './enums.js';
|
|
2
|
-
import { S as Sandbox } from './Sandbox-
|
|
2
|
+
import { S as Sandbox } from './Sandbox-K6VNqKeo.js';
|
|
3
3
|
|
|
4
4
|
interface RawAgentEvent<TPayload = unknown> {
|
|
5
5
|
provider: string;
|
|
@@ -9,7 +9,7 @@ interface RawAgentEvent<TPayload = unknown> {
|
|
|
9
9
|
payload: TPayload;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
type NormalizedAgentEventType = "run.started" | "message.started" | "message.injected" | "text.delta" | "reasoning.delta" | "tool.call.started" | "tool.call.delta" | "tool.call.completed" | "permission.requested" | "permission.resolved" | "message.completed" | "run.completed" | "run.error";
|
|
12
|
+
type NormalizedAgentEventType = "run.started" | "message.started" | "message.injected" | "text.delta" | "reasoning.delta" | "tool.call.started" | "tool.call.delta" | "tool.call.completed" | "permission.requested" | "permission.resolved" | "message.completed" | "run.completed" | "run.cancelled" | "run.error";
|
|
13
13
|
interface NormalizedAgentEventBase {
|
|
14
14
|
provider: string;
|
|
15
15
|
runId: string;
|
|
@@ -97,11 +97,15 @@ interface RunCompletedEvent extends NormalizedAgentEventBase {
|
|
|
97
97
|
type: "run.completed";
|
|
98
98
|
text?: string;
|
|
99
99
|
}
|
|
100
|
+
interface RunCancelledEvent extends NormalizedAgentEventBase {
|
|
101
|
+
type: "run.cancelled";
|
|
102
|
+
text?: string;
|
|
103
|
+
}
|
|
100
104
|
interface RunErrorEvent extends NormalizedAgentEventBase {
|
|
101
105
|
type: "run.error";
|
|
102
106
|
error: string;
|
|
103
107
|
}
|
|
104
|
-
type NormalizedAgentEvent = RunStartedEvent | MessageStartedEvent | MessageInjectedEvent | TextDeltaEvent | ReasoningDeltaEvent | ToolCallStartedEvent | ToolCallDeltaEvent | ToolCallCompletedEvent | PermissionRequestedEvent | PermissionResolvedEvent | MessageCompletedEvent | RunCompletedEvent | RunErrorEvent;
|
|
108
|
+
type NormalizedAgentEvent = RunStartedEvent | MessageStartedEvent | MessageInjectedEvent | TextDeltaEvent | ReasoningDeltaEvent | ToolCallStartedEvent | ToolCallDeltaEvent | ToolCallCompletedEvent | PermissionRequestedEvent | PermissionResolvedEvent | MessageCompletedEvent | RunCompletedEvent | RunCancelledEvent | RunErrorEvent;
|
|
105
109
|
declare function createNormalizedEvent<TType extends NormalizedAgentEventType>(type: TType, base: Omit<NormalizedAgentEventBase, "type" | "timestamp"> & {
|
|
106
110
|
timestamp?: string;
|
|
107
111
|
}, extra?: Record<string, unknown>): NormalizedAgentEvent;
|
|
@@ -307,16 +311,28 @@ interface AgentRunConfig {
|
|
|
307
311
|
model?: string;
|
|
308
312
|
systemPrompt?: string;
|
|
309
313
|
resumeSessionId?: string;
|
|
314
|
+
/**
|
|
315
|
+
* Source session/thread to fork from. The new run begins in a *new*
|
|
316
|
+
* session whose history is the prefix of the source up to and including
|
|
317
|
+
* {@link forkAtMessageId}. Mutually exclusive with {@link resumeSessionId}.
|
|
318
|
+
* Requires {@link forkAtMessageId}.
|
|
319
|
+
*
|
|
320
|
+
* Provider mapping:
|
|
321
|
+
* - claude-code: `query({ resume, resumeSessionAt, forkSession: true })`
|
|
322
|
+
* - opencode: `POST /session/:forkSessionId/fork { messageID }`
|
|
323
|
+
* - codex: emulated via `thread/fork` + `thread/rollback` (no native
|
|
324
|
+
* message-level fork in the codex app-server)
|
|
325
|
+
*/
|
|
326
|
+
forkSessionId?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Provider-native message id (claude-code: assistant message UUID;
|
|
329
|
+
* opencode: message info id; codex: turn id) to fork at — inclusive.
|
|
330
|
+
* The unified `messageId` field on `message.started` events carries the
|
|
331
|
+
* value to feed back here. Required when {@link forkSessionId} is set.
|
|
332
|
+
*/
|
|
333
|
+
forkAtMessageId?: string;
|
|
310
334
|
reasoning?: AgentReasoningEffort;
|
|
311
335
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Subset of {@link AgentRunConfig} that needs to be committed at
|
|
314
|
-
* `agent.setup()` time so the runtime can pre-bake artifacts that
|
|
315
|
-
* reference it (codex `model_instructions_file`, opencode agent config,
|
|
316
|
-
* etc.). Unlike `AgentRunConfig`, this never carries per-turn input or
|
|
317
|
-
* a resumed session id.
|
|
318
|
-
*/
|
|
319
|
-
type AgentSetupConfig = Pick<AgentRunConfig, "systemPrompt" | "model" | "reasoning">;
|
|
320
336
|
type AgentApprovalMode = "auto" | "interactive";
|
|
321
337
|
type AgentPermissionKind = "bash" | "edit" | "tool" | "network" | "file-change" | "unknown";
|
|
322
338
|
type AgentPermissionDecision = "allow" | "deny";
|
|
@@ -396,6 +412,8 @@ interface AgentResult {
|
|
|
396
412
|
provider: AgentProviderName;
|
|
397
413
|
sessionId: string;
|
|
398
414
|
text: string;
|
|
415
|
+
isCancelled: boolean;
|
|
416
|
+
error?: string;
|
|
399
417
|
rawEvents: RawAgentEvent[];
|
|
400
418
|
events: NormalizedAgentEvent[];
|
|
401
419
|
costData?: AgentCostData | null;
|
|
@@ -427,12 +445,15 @@ interface AgentRunSink {
|
|
|
427
445
|
text?: string;
|
|
428
446
|
costData?: AgentCostData | null;
|
|
429
447
|
}): void;
|
|
448
|
+
cancel(result?: {
|
|
449
|
+
text?: string;
|
|
450
|
+
costData?: AgentCostData | null;
|
|
451
|
+
}): void;
|
|
430
452
|
fail(error: unknown): void;
|
|
431
453
|
}
|
|
432
454
|
interface AgentSetupRequest<P extends AgentProviderName = AgentProviderName> {
|
|
433
455
|
provider: P;
|
|
434
456
|
options: AgentOptions<P>;
|
|
435
|
-
config: AgentSetupConfig;
|
|
436
457
|
}
|
|
437
458
|
interface AgentExecutionRequest<P extends AgentProviderName = AgentProviderName> {
|
|
438
459
|
runId: string;
|
|
@@ -524,4 +545,4 @@ interface AgentProviderAdapter<P extends AgentProviderName = AgentProviderName>
|
|
|
524
545
|
attachSendMessage(request: AgentAttachRequest<P>, content: UserContent): Promise<void>;
|
|
525
546
|
}
|
|
526
547
|
|
|
527
|
-
export { type
|
|
548
|
+
export { type OpenCodeProviderOptions as $, type AISDKEvent as A, type ClaudeCodeHookEvent as B, type ClaudeCodeAgentOptions as C, type ClaudeCodeHookHandler as D, type ClaudeCodeHookMatcherGroup as E, type ClaudeCodeHooksConfig as F, type ClaudeCodeProviderOptions as G, type CodexAgentOptions as H, type CodexCommandHook as I, type CodexHookEvent as J, type CodexHookMatcherGroup as K, type CodexHooksConfig as L, type CodexProviderOptions as M, type DataContent as N, type EmbeddedSkillConfig as O, type FilePart as P, type ImagePart as Q, type MessageCompletedEvent as R, type MessageInjectedEvent as S, type MessageStartedEvent as T, type NormalizedAgentEvent as U, type NormalizedAgentEventBase as V, type NormalizedAgentEventType as W, type OpenCodeAgentOptions as X, type OpenCodePluginConfig as Y, type OpenCodePluginEvent as Z, type OpenCodePluginHookConfig as _, type AgentApprovalMode as a, type PermissionRequestedEvent as a0, type PermissionResolvedEvent as a1, type RawAgentEvent as a2, type ReasoningDeltaEvent as a3, type RepoSkillConfig as a4, type RunCancelledEvent as a5, type RunCompletedEvent as a6, type RunErrorEvent as a7, type RunStartedEvent as a8, type TextDeltaEvent as a9, type TextPart as aa, type ToolCallCompletedEvent as ab, type ToolCallDeltaEvent as ac, type ToolCallStartedEvent as ad, type UserContent as ae, type UserContentPart as af, createNormalizedEvent as ag, normalizeRawAgentEvent as ah, toAISDKEvent as ai, toAISDKStream as aj, type AgentAttachRequest as b, type AgentCommandConfig as c, type AgentCostData as d, type AgentExecutionRequest as e, type AgentLocalMcpConfig as f, type AgentMcpConfig as g, type AgentOptions as h, type AgentOptionsBase as i, type AgentOptionsMap as j, type AgentPermissionDecision as k, type AgentPermissionKind as l, type AgentPermissionResponse as m, type AgentProviderAdapter as n, type AgentProviderName as o, type AgentReasoningEffort as p, type AgentRemoteMcpConfig as q, type AgentResult as r, type AgentRun as s, type AgentRunConfig as t, type AgentRunSink as u, type AgentSetupRequest as v, type AgentSkillConfig as w, type AgentSubAgentConfig as x, type AttachedRun as y, type ClaudeCodeHookConfig as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentbox-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.303",
|
|
4
4
|
"description": "Swappable coding agents and sandbox providers for Bun and TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"bun": ">=1.1.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@daytonaio/sdk": "^0.
|
|
61
|
+
"@daytonaio/sdk": "^0.171.0",
|
|
62
62
|
"@types/debug": "^4.1.13",
|
|
63
63
|
"@vercel/sandbox": "2.0.0-beta.13",
|
|
64
64
|
"debug": "^4.4.3",
|