Pipeline runs use the workspace's directory environment
Resolve the run workspace's environment with workenv (direnv, parent .envrc, mise; same account rule as Claude chats) at run start and resume, and apply it to Pi stage processes, a per-environment Pipelines-owned OpenCode stage service (keyed by a hash of the change, reused across runs, idle ones stopped after PIPELINES_OPENCODE_STAGE_IDLE_TIMEOUT, revived per registration), delivery-gate checks and merges, plain-stage opencode CLI calls and file-change capture git reads. Record the directory, .envrc files, sources and variable names (never values) on the run detail; a blocked .envrc becomes a run warning.
This commit is contained in:
@@ -287,6 +287,41 @@ Codex and OpenCode chats share one App Server or `opencode serve` process
|
||||
across directories, so only the working directory applies to them; their
|
||||
account is the one that process uses.
|
||||
|
||||
**Pipeline runs.** A run resolves its workspace's environment the same way
|
||||
(direnv in the workspace, so a parent `.envrc` applies to a worktree below it;
|
||||
mise; the same account rule) when it starts, and again when it resumes after a
|
||||
decision or a restart. Everything the server starts for the run gets it:
|
||||
|
||||
- Pi stage processes (`PWD` is the workspace).
|
||||
- OpenCode stages: the server runs one Pipelines-owned stage service per
|
||||
distinct environment (keyed by a hash of the change, registration
|
||||
`opencode-stage-service-env-<key>.json` beside the original
|
||||
`opencode-stage-service.json`), started with that environment, so the
|
||||
agent's shell commands, `gcloud`, and any `claude` it launches use the
|
||||
directory's accounts. Runs with the same environment share the service; a
|
||||
workspace without its own environment keeps the original service. An idle
|
||||
per-environment service is stopped after
|
||||
`PIPELINES_OPENCODE_STAGE_IDLE_TIMEOUT` (default `30m`, `off` keeps it until
|
||||
shutdown); its registration stays, so a retained session revives on the same
|
||||
endpoint with the directory's current environment. With
|
||||
`PIPELINES_OPENCODE_STAGE_SERVICE=shared` stages run on the CLI-managed
|
||||
service and the directory environment does not reach their tools.
|
||||
- Delivery-gate checks (`sh -c`) and the gate's merge commands, the
|
||||
`opencode` CLI calls of plain model stages, and the git reads behind
|
||||
file-change captures.
|
||||
|
||||
When the directory chooses the Claude account (for example its `.envrc` sets
|
||||
`CLAUDE_CONFIG_DIR`), inherited `CLAUDE_CODE_OAUTH_TOKEN`, `ANTHROPIC_API_KEY`,
|
||||
`ANTHROPIC_AUTH_TOKEN` and `CLAUDE_SECURESTORAGE_CONFIG_DIR` are removed for all
|
||||
of these, as for chats.
|
||||
|
||||
The run detail (`pipelines inspect <run> --json`, field `environment`) records
|
||||
what applied: the directory, the `.envrc` files, the sources, the names of the
|
||||
variables set and unset, the dropped credential names, and the service key,
|
||||
never a value. A blocked `.envrc` or untrusted mise config is listed in the
|
||||
run's `warnings` (and printed by `pipelines inspect`); the run continues with
|
||||
the server's environment.
|
||||
|
||||
## Adopting existing sessions
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user