paperclip/packages/shared/src
Dotta bc9ba7cd26
feat(runner): project native runs into task threads (#12321)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The experimental Paperclip Runner can execute a guarded Codex run
and persist provider-neutral events.
> - The task page still reads direct-adapter transcripts and cannot
present those native events.
> - Structured runner questions must also use the existing task
interaction experience.
> - Runtime selection must use the persisted run mode, not an adapter
name or a current feature flag.
> - This pull request projects native events and questions into the
existing task thread.
> - Direct adapters keep their existing transcript, composer,
interaction, and finalization paths.
> - The benefit is a complete native Codex task thread without a
behavior change for existing adapters.

## Linked Issues or Issue Description

Refs #12202. This pull request replaces that stale implementation on
current `master`.

**What happened?**

The server persists native runner events and structured input requests.
The task page only consumes direct-adapter transcripts. A native run
therefore cannot present a complete transcript, usage, or question flow
through the normal task experience.

**Expected behavior**

Native runs project persisted provider-neutral events into the existing
task thread. Native structured questions use the existing interaction
card. Direct adapters retain their current behavior.

**Steps to reproduce**

1. Enable the experimental runner.
2. Start a native Codex run that emits progress, usage, a structured
question, and a final reply.
3. Open the task page.
4. Observe that the direct-adapter transcript path cannot project the
native event records.

**Paperclip version or commit**

`master` at `67f9867bc`.

## What Changed

- Add the canonical structured-question validator and shared contract
exports.
- Materialize native input requests as existing task interactions.
- Validate native answers and deliver them through the durable
question-response receipt.
- Resume the original PRP request with an idempotent `request.resolve`
command.
- Project native messages, tool activity, cumulative usage, and final
replies into the existing transcript model.
- Propagate persisted `runtimeMode` to the task page and select native
handling only for `runtimeMode: "native"`.
- Expire pending interactions through the shared issue service on every
terminal transition, including decisions, stalled reviews, tree control,
and pipeline retry cleanup.
- Queue native run cancellation while a transaction is open and execute
it only after the owning transaction commits.
- Keep nonterminal and non-runner issue paths on their existing service
call shapes and behavior.

## Verification

- `pnpm --filter @paperclipai/server typecheck` — passed, including the
Rust runner release build and protocol/catalog drift gates.
- Focused native-thread and lifecycle suites — 18 files and 481 tests
passed during review.
- `issue-execution-policy-routes.test.ts` — 19/19 passed after the final
transactional-queue expectation update.
- `issue-agent-mutation-ownership-routes.test.ts` — 87/87 passed in the
final isolated compatibility rerun.
- GitHub Actions — policy, build, canary, typecheck/release registry, 5
serialized server shards, 8 general-test shards, 3 browser shards, and
both aggregate gates passed on `7793f3193`.
- Security — Snyk, Socket Project Report, Socket PR Alerts, and
Superagent passed.
- Greptile — 5/5 on `7793f3193`; all actionable review threads resolved.
- `git diff --check` — passed.
- Diff against `master`: 44 files.

## Compatibility Boundary

- Native transcript polling only runs when the persisted run reports
`runtimeMode: "native"`.
- Missing or legacy runtime modes continue through
`useLiveRunTranscripts`.
- Legacy questions keep the existing optional free-text choice.
- Native closed select sets can suppress that legacy fallback.
- Terminal cleanup uses the same issue service for native and legacy
interactions; only a bound native question schedules a native run
cancellation.
- Native cancellation happens after transaction commit, so failed or
rolled-back writes do not cancel a still-valid run.
- The durable delivery service checks the original native request before
it considers a continuation run.
- This pull request adds no migration, dependency, workflow, manifest,
or lockfile change.

## Risks

The main risk is routing a direct-adapter task through native handling
or changing terminal issue behavior. The implementation selects the
native path only from persisted runtime facts, retains the existing
nonterminal call shape, and schedules native cancellation only for a
validated bound native question after commit. Focused and
repository-wide tests cover both paths. Native requests remain bound to
the company, issue, run, and agent; answers are validated, durable, and
idempotent across reconnects.

## Model Used

OpenAI Codex, GPT-5 family. The client does not expose the exact
deployment ID or context window. Agentic reasoning, tool use, and code
execution were enabled.

## 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 and contains no internal
Paperclip ticket id or instance-derived details
- [x] I have run the affected local tests and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated the compatibility notes for this change
- [x] I have considered and documented risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I addressed all Greptile and reviewer comments before requesting
merge
2026-08-29 19:26:20 -05:00
..
app-definitions feat(apps): refine Postman and Shopify setup (#12357) 2026-08-29 12:08:35 -05:00
runtime-exposure fix(workspaces): make managed runtimes reliable across restarts (#11740) 2026-08-19 14:55:16 -05:00
telemetry refactor: disambiguate the Telemetry and Observability data paths (#12128) 2026-08-24 16:42:33 -07:00
types feat(runner): project native runs into task threads (#12321) 2026-08-29 19:26:20 -05:00
validators feat(runner): project native runs into task threads (#12321) 2026-08-29 19:26:20 -05:00
adapter-agnostic-keys.test.ts fix: deduplicate adapter-agnostic config keys (#9058) 2026-07-05 21:47:38 -07:00
adapter-auth-check-code.test.ts feat(auth): normalize agent login in the sandbox onto one session table and a capability contract (#11730) 2026-08-19 11:51:31 -07:00
adapter-auth-check-code.ts feat(auth): normalize agent login in the sandbox onto one session table and a capability contract (#11730) 2026-08-19 11:51:31 -07:00
adapter-auth-session.ts Add sandbox device-login for the Codex adapter (#11237) 2026-08-12 08:58:25 -07:00
adapter-type.ts
…
adapter-types.test.ts
…
agent-eligibility.test.ts feat(agents): warn when an agent's escalation path routes to a paused manager (#10657) 2026-08-01 17:42:42 -07:00
agent-eligibility.ts feat(agents): warn when an agent's escalation path routes to a paused manager (#10657) 2026-08-01 17:42:42 -07:00
agent-url-key.ts
…
api.ts feat: maintained in_review review-path contract + stalled-review actions (#10675) 2026-08-04 13:54:40 -05:00
app-definitions-url.test.ts feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
app-definitions.generated.ts feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
app-definitions.ingestion-report.json feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
app-definitions.test.ts feat(apps): refine Postman and Shopify setup (#12357) 2026-08-29 12:08:35 -05:00
app-definitions.ts feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
company-import-transfer.test.ts feat: already-imported transfer error names the landed company (#12144) 2026-08-25 13:51:50 -07:00
company-import-transfer.ts feat: already-imported transfer error names the landed company (#12144) 2026-08-25 13:51:50 -07:00
config-schema.test.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
config-schema.ts build(deps): bump zod from 3.25.76 to 4.4.3 (#11719) 2026-08-21 00:04:14 -07:00
connection-intent-guidance.test.ts feat(connections): add self-serve intent runtime (#12345) 2026-08-29 12:08:34 -05:00
connection-intent-guidance.ts feat(connections): add self-serve intent runtime (#12345) 2026-08-29 12:08:34 -05:00
constants.ts feat(connections): add self-serve intent runtime (#12345) 2026-08-29 12:08:34 -05:00
decision.test.ts feat(decisions): add first-class propose mode (#10010) 2026-07-31 19:17:02 -07:00
document-anchors.test.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
document-anchors.ts [codex] Add document annotations and comments (#6733) 2026-05-26 06:41:23 -07:00
env-file.test.ts fix(config): preserve env files during managed updates (#10980) 2026-08-07 00:54:43 -05:00
env-file.ts fix(config): preserve env files during managed updates (#10980) 2026-08-07 00:54:43 -05:00
environment-custom-images.test.ts Add browser SSH terminal for custom image setup (#8911) 2026-07-03 16:44:21 -07:00
environment-custom-images.ts Add browser SSH terminal for custom image setup (#8911) 2026-07-03 16:44:21 -07:00
environment-support.test.ts feat: add kimi-local adapter for Kimi Code CLI (CLI + ACP engines) (#9967) 2026-08-20 12:06:33 -07:00
environment-support.ts feat: add kimi-local adapter for Kimi Code CLI (CLI + ACP engines) (#9967) 2026-08-20 12:06:33 -07:00
execution-workspace-guards.ts
…
external-objects-server.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external-objects.test.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
external-objects.ts External object references across issue surfaces (#8512) 2026-06-23 08:27:19 -05:00
feature-catalog.test.ts Add a feature catalog build artifact derived from the experimental settings schema (#10055) 2026-07-22 18:12:56 -07:00
feature-catalog.ts feat(runner): add flagged Codex execution adapter (#12188) 2026-08-25 16:03:41 -05:00
frontmatter.test.ts Skill Studio: three-pane skill IDE with sandboxed test runs (#9241) 2026-07-09 13:08:56 -05:00
frontmatter.ts build(deps): bump zod from 3.25.76 to 4.4.3 (#11719) 2026-08-21 00:04:14 -07:00
gitignore-runtime.test.ts chore: ignore materialized Paperclip runtime directory 2026-07-08 17:59:43 -07:00
google-workspace-connectors.ts feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
home-paths.test.ts
…
home-paths.ts
…
humanize-connection.test.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
humanize-connection.ts feat(mcp) [split 2/8]: add governed access contracts (#9557) 2026-07-14 12:57:20 -05:00
index.ts feat(runner): project native runs into task threads (#12321) 2026-08-29 19:26:20 -05:00
issue-attribution.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
issue-attribution.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
issue-references.test.ts
…
issue-references.ts
…
issue-thread-interactions.test.ts feat(runner): project native runs into task threads (#12321) 2026-08-29 19:26:20 -05:00
issue-write-denial.test.ts feat(issues): explain cross-task agent writes with attribution, audit receipts, and actionable denials (#10843) 2026-08-04 23:02:51 -05:00
issue-write-denial.ts feat(issues): explain cross-task agent writes with attribution, audit receipts, and actionable denials (#10843) 2026-08-04 23:02:51 -05:00
markdown-work-products.test.ts feat(artifacts): bridge Markdown work products into the document review surface (#11822) 2026-08-20 17:28:01 -07:00
markdown-work-products.ts feat(artifacts): bridge Markdown work products into the document review surface (#11822) 2026-08-20 17:28:01 -07:00
mcp-config-help-prompt.ts feat(apps): add secure remote MCP and PostHog setup (#12339) 2026-08-29 12:08:32 -05:00
mcp-remote-headers.test.ts feat(apps): add secure remote MCP and PostHog setup (#12339) 2026-08-29 12:08:32 -05:00
mcp-remote-headers.ts feat(apps): add secure remote MCP and PostHog setup (#12339) 2026-08-29 12:08:32 -05:00
network-bind.ts
…
node-version.ts fix(build): enforce Node 24 across Paperclip (#11792) 2026-08-21 10:17:52 -07:00
oauth-endpoint-url.test.ts feat(apps): add secure remote MCP and PostHog setup (#12339) 2026-08-29 12:08:32 -05:00
oauth-endpoint-url.ts feat(apps): add secure remote MCP and PostHog setup (#12339) 2026-08-29 12:08:32 -05:00
pipeline-case-type.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
pipeline-health.test.ts [codex] Deduplicate pipeline automation health warnings (#9090) 2026-07-06 12:12:18 -05:00
pipeline-health.ts [codex] Deduplicate pipeline automation health warnings (#9090) 2026-07-06 12:12:18 -05:00
portability-fidelity.test.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
portability-fidelity.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
portability-hash.ts Replace host-to-host Cloud Sync with full-fidelity company Import/Export (#10507) 2026-07-30 11:37:00 -07:00
portability-zip.test.ts fix(server): raise company import zip upload limit to 1 GB and make it operator-configurable (#11184) 2026-08-10 12:47:03 -07:00
portability-zip.ts fix(server): raise company import zip upload limit to 1 GB and make it operator-configurable (#11184) 2026-08-10 12:47:03 -07:00
project-mentions.test.ts
…
project-mentions.ts Add pipeline workflow primitives and operator UI (#7903) 2026-06-26 12:02:44 -05:00
project-url-key.ts
…
resource-memberships.test.ts feat(server): add per-user document stars (#9952) 2026-07-27 19:13:35 -05:00
responsible-user-denial.test.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
responsible-user-denial.ts feat(secrets): add user-specific runtime secrets (#8825) 2026-07-05 05:58:20 -05:00
routine-variables.test.ts feat(routines): add date variable controls (#8655) 2026-06-26 12:00:16 -05:00
routine-variables.ts feat(routines): add date variable controls (#8655) 2026-06-26 12:00:16 -05:00
self-serve-mcp-research.json feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
self-serve-mcp-research.ts feat(apps): expand the self-serve connection catalog (#12344) 2026-08-29 12:08:34 -05:00
setting-defaults.test.ts Let operators supply defaults for selected instance settings (#12285) 2026-08-27 11:29:05 -07:00
setting-defaults.ts Let operators supply defaults for selected instance settings (#12285) 2026-08-27 11:29:05 -07:00
settings-visibility.test.ts Let operators hide the Provider vaults and Proposals tabs (#12284) 2026-08-27 11:28:15 -07:00
settings-visibility.ts Remove the instance Heartbeats settings page (#12282) 2026-08-27 11:31:43 -07:00
summary-slot.test.ts fix: isolate execution workspace summaries (#10790) 2026-08-11 08:56:32 -04:00
trust-policy.ts fix(auth): clarify protected-agent assignment blocks (#10893) 2026-08-05 10:09:17 -05:00
work-product.test.ts Add workspace file viewer and artifact links (#7681) 2026-06-09 17:17:43 -05:00
workspace-commands.test.ts feat(apps): improve gateway and workspace connection UX (#12340) 2026-08-29 12:08:32 -05:00
workspace-commands.ts feat(apps): improve gateway and workspace connection UX (#12340) 2026-08-29 12:08:32 -05:00
workspace-file-resource.test.ts fix(files): only highlight accessible workspace file links (#11090) 2026-08-11 12:11:45 -04:00
worktree-port-registry.test.ts fix(workspaces): make managed runtimes reliable across restarts (#11740) 2026-08-19 14:55:16 -05:00
worktree-port-registry.ts fix(workspaces): make managed runtimes reliable across restarts (#11740) 2026-08-19 14:55:16 -05:00
worktree-seed-source.test.ts fix(workspaces): seed managed worktrees when the base checkout has no config (#11752) 2026-08-20 08:42:16 -07:00
worktree-seed-source.ts fix(workspaces): seed managed worktrees when the base checkout has no config (#11752) 2026-08-20 08:42:16 -07:00