Files
PaperClipAI/packages
DottaandClaude Opus 5.5 29afc633f6 feat(runner): forward ACP _meta from ACPX as a bounded copy (#19259)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The native runner runs Claude through ACPX and maps ACP updates into
canonical run events.
> - Claude sends useful data in the ACP `_meta` field: the real tool
name, the parent tool of a subagent call, the terminal exit code, and
the rate-limit state.
> - ACPX 0.13.1 drops all `_meta` before the runner sees it.
> - Three planned features need this data: richer tool rows, a
rate-limit gauge, and a subagent tree.
> - This pull request forwards `_meta` from ACPX and bounds it once in
the runner.
> - The benefit is that each feature can read the data from one safe,
shared place.

## Linked Issues or Issue Description

**Problem or motivation**
ACPX keeps only the title, status, kind, locations, raw input, raw
output and content of an ACP tool update. It drops `_meta`. Claude's
tool name, `parentToolUseId`, `terminal_exit` and `_claude/rateLimit`
never reach the runner.

**Proposed solution**
Forward `_meta` from ACPX on tool and status events. Copy it into a
bounded, JSON-safe object in the runner before any mapper reads it.

**Alternatives considered**
Read the full ACP notification through `onSessionNotification` and join
it to runtime events by tool call ID. That needs a side table and
depends on callback order. Forwarding on the event is simpler and keeps
the data with the event.

## What Changed

- `patches/acpx@0.13.1.patch`: ACPX now sets `_meta` on `tool_call`
events and on status events (`usage_update`, `current_mode_update`,
`config_option_update`, `session_info_update`). The type declarations
document the field as unvalidated producer data.
- `packages/paperclip-runner/src/provider-events.ts`: new
`boundedAcpMeta()`. `createAcpxToolEventNormalizer` applies it to every
runtime event. Limits: depth 6, 64 entries per object or array, 4 KB per
string, about 16 KB in total. It drops `__proto__`, `constructor` and
`prototype` keys, functions and non-finite numbers.
- The hardened ACPX sidecar path keeps its explicit field allowlist. It
does not forward `_meta` yet. A feature that needs a field there must
add it to that allowlist.
- Tests for the passthrough and for each bound.

## Verification

- `cd packages/paperclip-runner && npx vitest run
src/provider-events.test.ts`
- The canonical mappers do not read `_meta` yet, so run events do not
change. Follow-up pull requests use it.

## Risks

- Low risk. The new field is additive and the mappers ignore it today.
- The lockfile patch hash for `acpx@0.13.1` changes. A fresh `pnpm
install` applies the new patch.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 11:31:06 -06:00
..