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.
package/dist/agents/index.js
CHANGED
|
@@ -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
|
|
3371
|
-
|
|
3372
|
-
|
|
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,
|
|
3388
|
+
await fs.writeFile(imagePath, data);
|
|
3385
3389
|
return imagePath;
|
|
3386
3390
|
}
|
|
3387
3391
|
function resolveCodexOpenAiBaseUrlFromOptions(options) {
|
package/dist/index.js
CHANGED