paperclip/packages/adapter-utils/src
Devin Foley d47ffa87f0
Fix CEO AGENT_HOME paths and centralize workspace env propagation (#4551)
## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies.
> - The local adapter layer is responsible for turning Paperclip runtime
context into the environment seen by the child agent process.
> - The CEO onboarding bundle tells the agent where to read and write
its persistent memory and fact files.
> - That bundle was using `./memory/...` and `./life/...`, which only
works when the process cwd happens to equal the agent home directory.
> - At the same time, six local adapters each duplicated the same
workspace-env propagation logic, including `AGENT_HOME`, which makes
this contract easy to drift.
> - This pull request fixes the CEO instructions to use
`$AGENT_HOME/...` and centralizes workspace-env propagation in one
shared helper with shared tests.
> - The benefit is a real bug fix for agent memory paths plus a single
tested contract that makes future built-in adapter work less likely to
forget `AGENT_HOME`.

## What Changed

- Updated `server/src/onboarding-assets/ceo/HEARTBEAT.md` to use
`$AGENT_HOME/memory/...` and `$AGENT_HOME/life/...` instead of
cwd-relative `./memory/...` and `./life/...`.
- Added `applyPaperclipWorkspaceEnv(...)` in
`packages/adapter-utils/src/server-utils.ts` to centralize
`PAPERCLIP_WORKSPACE_*` and `AGENT_HOME` propagation.
- Added shared helper coverage in
`packages/adapter-utils/src/server-utils.test.ts` for both populated and
skip-empty cases.
- Switched the built-in local adapters (`claude_local`, `codex_local`,
`cursor_local`, `gemini_local`, `opencode_local`, `pi_local`) over to
the shared helper instead of inline env assignment blocks.

## Verification

- `pnpm install`
- `pnpm exec vitest run packages/adapter-utils/src/server-utils.test.ts
packages/adapters/claude-local/src/server/execute.remote.test.ts
packages/adapters/codex-local/src/server/execute.remote.test.ts
packages/adapters/cursor-local/src/server/execute.remote.test.ts
packages/adapters/gemini-local/src/server/execute.remote.test.ts
packages/adapters/opencode-local/src/server/execute.remote.test.ts
packages/adapters/pi-local/src/server/execute.remote.test.ts`
- Result: 7 test files passed, 31 tests passed, 0 failures.

## Risks

- Low risk.
- The only behavioral surface is the shared env propagation refactor
across six adapters; if the helper diverged from prior semantics, an
adapter could miss a workspace env var.
- The shared helper test plus the affected adapter execute tests reduce
that risk, and the helper preserves the prior "set only non-empty
strings" behavior.

## Model Used

- OpenAI Codex via Paperclip `codex_local` agent runtime; tool-assisted
coding workflow with shell execution, file patching, git operations, and
API interaction. The exact backend model identifier and context window
are not surfaced by this local runtime.

## 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 run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-04-26 13:57:35 -07:00
..
billing.test.ts feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
billing.ts feat(costs): add billing, quota, and budget control plane 2026-03-16 15:11:01 -05:00
command-managed-runtime.ts Add sandbox environment support (#4415) 2026-04-24 12:15:53 -07:00
execution-target-sandbox.test.ts Add sandbox environment support (#4415) 2026-04-24 12:15:53 -07:00
execution-target.test.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
execution-target.ts Add sandbox environment support (#4415) 2026-04-24 12:15:53 -07:00
index.ts feat(adapters): declarative config-schema API and UI for plugin adapters 2026-04-03 21:11:22 +01:00
log-redaction.ts fix(ui): external adapter selection, config field placement, and transcript parser freshness 2026-04-03 21:11:22 +01:00
remote-managed-runtime.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
sandbox-managed-runtime.test.ts Add sandbox environment support (#4415) 2026-04-24 12:15:53 -07:00
sandbox-managed-runtime.ts Add sandbox environment support (#4415) 2026-04-24 12:15:53 -07:00
server-utils.test.ts Fix CEO AGENT_HOME paths and centralize workspace env propagation (#4551) 2026-04-26 13:57:35 -07:00
server-utils.ts Fix CEO AGENT_HOME paths and centralize workspace env propagation (#4551) 2026-04-26 13:57:35 -07:00
session-compaction.ts feat: add hermes_local session management and show provider/model in run details 2026-04-03 21:11:23 +01:00
ssh-fixture.test.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
ssh.ts Add SSH environment support (#4358) 2026-04-23 19:15:22 -07:00
types.ts [codex] Improve transient recovery and Codex model refresh (#4383) 2026-04-24 09:40:40 -05:00