agentbox-sdk 0.1.501 → 0.1.502

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.
@@ -2,7 +2,7 @@ import {
2
2
  Agent,
3
3
  agentboxRoot,
4
4
  getAgentLayout
5
- } from "../chunk-2FCUUUXG.js";
5
+ } from "../chunk-IEQM5L4K.js";
6
6
  import "../chunk-775FIGGL.js";
7
7
  import {
8
8
  AGENT_RESERVED_PORTS,
@@ -3360,28 +3360,32 @@ async function materializeCodexImage(options, part, index) {
3360
3360
  if (part.source.type === "url") {
3361
3361
  return part.source.url;
3362
3362
  }
3363
+ const data = Buffer.from(part.source.data, "base64");
3364
+ if (data.length === 0) {
3365
+ throw new Error("Cannot attach an empty image to Codex.");
3366
+ }
3363
3367
  const root = agentboxRoot(AgentProvider.Codex, Boolean(options.sandbox));
3364
3368
  const imagePath = path9.join(
3365
3369
  root,
3366
3370
  "inputs",
3367
- `codex-image-${index}${codexImageExtension(part.mediaType)}`
3371
+ `codex-image-${index}-${crypto2.randomUUID()}${codexImageExtension(part.mediaType)}`
3368
3372
  );
3369
3373
  if (options.sandbox) {
3370
- const encodedPath = `${imagePath}.b64`;
3371
- await options.sandbox.uploadAndRun(
3372
- [{ path: encodedPath, content: part.source.data }],
3373
- [
3374
- `mkdir -p ${shellQuote(path9.posix.dirname(imagePath))}`,
3375
- `(base64 --decode < ${shellQuote(encodedPath)} > ${shellQuote(imagePath)} || base64 -D < ${shellQuote(encodedPath)} > ${shellQuote(imagePath)})`,
3376
- `rm -f ${shellQuote(encodedPath)}`
3377
- ].join(" && "),
3374
+ const result = await options.sandbox.uploadAndRun(
3375
+ [{ path: imagePath, content: data }],
3376
+ `test "$(wc -c < ${shellQuote(imagePath)})" -eq ${data.length}`,
3378
3377
  { cwd: options.cwd, env: options.env }
3379
3378
  );
3379
+ if (result.exitCode !== 0) {
3380
+ throw new Error(
3381
+ `Failed to upload image attachment to Codex (exit ${result.exitCode}): the file could not be written or its size did not match.`
3382
+ );
3383
+ }
3380
3384
  return imagePath;
3381
3385
  }
3382
3386
  const fs = await import("fs/promises");
3383
3387
  await fs.mkdir(path9.dirname(imagePath), { recursive: true });
3384
- await fs.writeFile(imagePath, Buffer.from(part.source.data, "base64"));
3388
+ await fs.writeFile(imagePath, data);
3385
3389
  return imagePath;
3386
3390
  }
3387
3391
  function resolveCodexOpenAiBaseUrlFromOptions(options) {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  Agent,
3
3
  agentboxRoot,
4
4
  getAgentLayout
5
- } from "./chunk-2FCUUUXG.js";
5
+ } from "./chunk-IEQM5L4K.js";
6
6
  import {
7
7
  ProviderLogAssembler,
8
8
  createNormalizedEvent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbox-sdk",
3
- "version": "0.1.501",
3
+ "version": "0.1.502",
4
4
  "description": "Swappable coding agents and sandbox providers for Bun and TypeScript.",
5
5
  "license": "MIT",
6
6
  "repository": {