Commit 3adbac9
authored
Closes #35.
The canonical `@tangle-network/sandbox` `box.streamTask` emits
`message.part.updated` with the text nested under
`data.part.text`:
{ type: 'message.part.updated', data: { part: { type: 'text', text: '…' } } }
Before this fix, the default `mapCommonBackendEvent` only walked
`data.text` / `data.delta` / `record.text` — sandbox-SDK text deltas
silently dropped out of the canonical stream, forcing every sandbox-SDK
consumer (blueprint-agent#1758, future gtm-agent sandbox path, every
sandbox-hosted product downstream) to ship a duplicated `mapEvent` shim
that walked `data.part.text` themselves.
Fix: the `message.part.updated` branch now ALSO walks `data.part.text`
when `data.part.type === 'text'` (or undefined for forward-compat).
Resolution order is `data.text` → `data.delta` → `record.text` →
`data.part.text` so any consumer already passing the flat shape keeps
working unchanged (covered by the new precedence test).
Two new tests pin the behaviour:
- "unwraps the @tangle-network/sandbox `data.part.text` shape natively"
— fires the real sandbox-SDK shape through `runAgentTaskStream` and
asserts the canonical `text_delta` stream contains `['hello', ' world']`,
plus that a non-text part-kind drops cleanly (does NOT mis-fire as a
text_delta).
- "prefers explicit `data.text` when both shapes present" —
back-compat: any existing call site sending `{ data: { text } }` keeps
winning over the nested shape.
Result: products consuming the sandbox SDK can wire it straight into
`createSandboxPromptBackend` without writing a `mapEvent` shim — the
default does the right thing. Blueprint's pinned contract test
(blueprint-agent#1758, `Claude-Code → RuntimeStreamEvent migration seam`)
that documented this gap as a finding now becomes the regression guard
on this fix.
Verification
────────────
- `pnpm test` — 181/181 pass (+2 new).
- `pnpm typecheck` — clean.
1 parent 236ae50 commit 3adbac9
2 files changed
Lines changed: 72 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
303 | 315 | | |
304 | 316 | | |
305 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
498 | 557 | | |
499 | 558 | | |
500 | 559 | | |
| |||
0 commit comments