mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 20:03:11 +00:00
* chore: recover hamburg workspace state * chore: drop workspace context files * refactor: generalize permissions example * refactor: parse permissions example flags * docs: clarify why fs and terminal stay native * feat: add interactive permission prompt UI to Inspector Add permission request handling to the Inspector UI so users can Allow, Always Allow, or Reject tool calls that require permissions instead of having them auto-cancelled. Wires up SDK onPermissionRequest/respondPermission through App → ChatPanel → ChatMessages with proper toolCallId-to-pendingId mapping. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: prevent permission reply from silently escalating "once" to "always" Remove allow_always from the fallback chain when the user replies "once", aligning with the ACP spec which says "map by option kind first" with no fallback for allow_once. Also fix Inspector to use rawSend, revert hydration guard to accept empty configOptions, and handle respondPermission errors by rejecting the pending promise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
61 lines
1.5 KiB
Text
61 lines
1.5 KiB
Text
---
|
|
title: "Attachments"
|
|
description: "Upload files into the sandbox and reference them in prompts."
|
|
sidebarTitle: "Attachments"
|
|
icon: "paperclip"
|
|
---
|
|
|
|
Use the filesystem API to upload files, then include file references in prompt content.
|
|
|
|
<Steps>
|
|
<Step title="Upload a file">
|
|
<CodeGroup>
|
|
```ts TypeScript
|
|
import { SandboxAgent } from "sandbox-agent";
|
|
import fs from "node:fs";
|
|
|
|
const sdk = await SandboxAgent.connect({
|
|
baseUrl: "http://127.0.0.1:2468",
|
|
});
|
|
|
|
const buffer = await fs.promises.readFile("./data.csv");
|
|
|
|
const upload = await sdk.writeFsFile(
|
|
{ path: "./uploads/data.csv" },
|
|
buffer,
|
|
);
|
|
|
|
console.log(upload.path);
|
|
```
|
|
|
|
```bash cURL
|
|
curl -X PUT "http://127.0.0.1:2468/v1/fs/file?path=./uploads/data.csv" \
|
|
--data-binary @./data.csv
|
|
```
|
|
</CodeGroup>
|
|
|
|
The upload response returns the absolute path.
|
|
</Step>
|
|
|
|
<Step title="Reference the file in a prompt">
|
|
```ts TypeScript
|
|
const session = await sdk.createSession({ agent: "mock" });
|
|
|
|
await session.prompt([
|
|
{ type: "text", text: "Please analyze the attached CSV." },
|
|
{
|
|
type: "resource_link",
|
|
name: "data.csv",
|
|
uri: "file:///home/sandbox/uploads/data.csv",
|
|
mimeType: "text/csv",
|
|
},
|
|
]);
|
|
```
|
|
</Step>
|
|
</Steps>
|
|
|
|
## Notes
|
|
|
|
- Use absolute file URIs in `resource_link` blocks.
|
|
- If `mimeType` is omitted, the agent/runtime may infer a default.
|
|
- Support for non-text resources depends on each agent's prompt capabilities.
|