Commit 5d3b2d0
feat(protocol+sdk+server): attachments — workdir uploads at session create
Lets clients ship per-request files into the agent's workdir before the
engine starts. Files overlay on top of the loader-materialized GAP repo
(caller wins on path collisions). Path-jailed by the existing harness
fs helpers — '..', absolute paths, and symlink-outs return 400.
Wire shape (CreateSessionBody.attachments + RunBody.attachments):
attachments: [
{ path: "data.csv", content: "name,age\nA,30\n" },
{ path: "report.pdf", content: "JVBERi0...", encoding: "base64" }
]
Architecture: zero changes at the engine or substrate layer. The workdir
is the universal interface — every engine (claude-agent-sdk, gitagent,
deepagents) already operates on cwd via its native tools, and every
substrate (local, bwrap, e2b, vzvm) already exposes the workdir to its
harness child. We just write the files once at session-create time,
inside the harness-server's createSession service, between
loader.load() and engine startup.
Files touched:
- packages/protocol/src/harness-rest.ts: new Attachment zod schema +
CreateSessionBody.attachments field
- packages/harness-server/src/services/create-session.ts:
materializeAttachments helper after loader.load; PATH_ESCAPE maps to
400 with the attempted path; one info log per attachment
- packages/sdk/src/types.ts: ComputerAgentOptions.attachments
- packages/sdk/src/computer-agent.ts: forwards attachments into the
session create body
- examples/computeragent-server.ts: RunBody.attachments → passed to
ComputerAgent constructor
Verified locally end-to-end on LocalSubstrate:
- POST /run with attachments [secret.txt utf8, binary.bin base64]
- Both written to workdir (harness logs: session.attachment.written)
- Agent read secret.txt back via Bash, replied with exact content
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent ad916ee commit 5d3b2d0
8 files changed
Lines changed: 671 additions & 494 deletions
File tree
- examples
- packages
- harness-server/src/services
- protocol/src
- runtime-e2b/assets
- runtime-local/assets
- runtime-vzvm/assets
- sdk/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
118 | 133 | | |
119 | 134 | | |
120 | 135 | | |
| |||
213 | 228 | | |
214 | 229 | | |
215 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
216 | 234 | | |
217 | 235 | | |
218 | 236 | | |
| |||
451 | 469 | | |
452 | 470 | | |
453 | 471 | | |
454 | | - | |
| 472 | + | |
455 | 473 | | |
456 | 474 | | |
457 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
122 | 132 | | |
123 | 133 | | |
124 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
25 | 41 | | |
26 | 42 | | |
27 | 43 | | |
| |||
51 | 67 | | |
52 | 68 | | |
53 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
54 | 78 | | |
55 | 79 | | |
56 | 80 | | |
| |||
0 commit comments