Skip to content

feat(auth): share session environment and capture login shell environment - #490

Merged
stamp-build[bot] merged 2 commits into
mainfrom
agent/otter/auth-environment
Oct 26, 2026
Merged

stamp-build[bot] merged 2 commits into
mainfrom
agent/otter/auth-environment

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Otter from open-agent-runtime opened this pull request through Stamp
View in Stamp →


Login, logout and authentication status can now use the same environment overlay as a session. Executable lookup, credential locations and confirmation reads receive it; runtime-owned browser suppression still wins. Cursor rejects nonempty overlays before loading its in-process SDK instead of ignoring them.

Adds the explicit userShellEnvironment() helper for one bounded login-shell capture. It returns an environment map and changed critical variable names without mutating the host or forwarding shell output. Missing shells, failed captures, deadlines, cancellation and Windows return typed failures. Node SEA and compiled or unidentified Bun hosts refuse before starting a shell, so the helper never executes the host binary as a Node interpreter. Service-user session/keychain availability remains outside its guarantee.

Validation: complete check (2,133 unit tests), all eight behavior backends and build passed. Isolated real Bash, fish 3.7.0 and Nushell 0.116.1 probes passed. PowerShell command construction is unit-tested; native PowerShell capture has not been verified.

The reader environment surfaces (installation, usage, models, inventories and orient) follow in a separate PR. Per maintainer sequencing, merge this change only after 0.72.0 is published.

@stamp-build
stamp-build Bot force-pushed the agent/otter/auth-environment branch from daac0fe to 9acef18 Compare October 26, 2026 15:28
@stamp-build
stamp-build Bot merged commit 30ff1d1 into main Oct 26, 2026
27 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/auth-environment branch October 26, 2026 15:39
stamp-build Bot added a commit that referenced this pull request Oct 26, 2026
…491)

<!-- stamp:review:v1 -->
<sup><img
src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp"
width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_9b66568094e31e865a39369419ae6ed4"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp
→</a></sup>

---
<!-- /stamp:review:v1 -->

Runtime observations can use the same environment as login and sessions.
`installation`, `accountUsage`, `listModels`, inventories, providers and
`orient` accept the session overlay. Executable discovery, credential
directories, readiness/version probes and native CLI queries resolve it
per call without mutating the host.

Readers follow their runtime's execution semantics. Pi accepts env: its
inventory's Bash tool receives the overlay, while SDK configuration,
credential resolution and SDK-owned key commands keep the host
environment. This also applies to readers on the Pi subprocess runtime;
no new reader RPC protocol is introduced. Cursor and Pi Durable direct
readers reject nonempty overlays, matching their sessions. `orient`
checks `refusedSessionOptions.env` and omits the overlay for those
runtimes, preserving facts from the host environment without branching
on runtime names.

Kimi account usage accepts credential and CLI environment changes but
refuses actual changes to the fixed host HTTP/TLS variable list;
unchanged values remain accepted. `orient` records that precise refusal
as unsupported without exposing environment values.

Validation: all eight behavior backends and build passed on the initial
implementation. After review corrections, the full check (2,177 unit
tests and 19 mock cases), both affected Pi behavior backends and build
passed. Seven targeted regressions failed before the review fixes and
passed afterward, covering Pi acceptance and Cursor/Pi Durable
orientation. Three Windows fixture path expectations found by initial CI
were corrected; final three-platform CI runs on this head.

Based on main after merged #490. This completes its reader-environment
follow-up; no package version change.

---------

Co-authored-by: Otter <[email protected]>
@stamp-build stamp-build Bot mentioned this pull request Oct 26, 2026
stamp-build Bot added a commit that referenced this pull request Oct 26, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg"
width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_55fe77367d11a6f73936cd8d1ffa9e7d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp
→</a></sup>

---
<!-- /stamp:review:v1 -->

## New

### Login and sessions share one environment (#490)
`LoginOptions`, `LogoutOptions` and `AuthStatusOptions` take `env`, with
the same overlay semantics as `SessionOptions.env`: strings set a
variable, `null` removes it, and the host's own environment is never
changed. Claude login, logout and status, Qoder login and status, and
Codex's app-server login, `codex logout` and `codex login status` all
run with it, including the read that confirms a login. Runtimes whose
sessions refuse `env` (Cursor, whose SDK runs in the host process)
refuse a non-empty `env` on login, logout and status too, with
`UnsupportedOptionError("env")`.

`userShellEnvironment({ timeoutMs, signal })` runs `$SHELL` once as an
interactive login shell (POSIX shells, fish, Nushell and PowerShell;
natively verified with Bash, fish and Nushell) and returns `{ env,
changedVariables }`. `env` is the complete snapshot, with `null` for
host variables the shell removed, ready to pass as an overlay.
`changedVariables` lists only the names of `HOME`, `PATH`,
`CLAUDE_CONFIG_DIR`, `CODEX_HOME` and proxy variables that differ from
the host, never their values. Failures throw `UserShellEnvironmentError`
with a typed `reason`: `no_node_runtime` (the host is a Node single
executable application or a compiled Bun binary, which cannot evaluate
the capture script), `unsupported_platform` (Windows), `shell_not_set`,
`shell_unavailable`, `shell_failed`, `timed_out`, `cancelled`,
`invalid_output` and `output_too_large`; an invalid `timeoutMs` throws
`RangeError`. It never returns a partial environment and never forwards
shell output. It does not check for a login session; without one,
session variables such as `XDG_RUNTIME_DIR` may be missing. New exported
types: `UserShellEnvironmentOptions`, `UserShellEnvironmentFailure`.

**Host note:** capture once and pass the same `env` to sessions, login,
logout, status and `orient`, so credentials are written and read in the
same place. Skip it for runtimes that declare
`refusedSessionOptions.env` (Cursor, Pi Durable). Fall back to the host
environment when the helper fails.

### Readers take the same environment (#491)
Installation probes, account usage, model listing, inventories and
provider listing accept `env` (new `InstallationProbeOptions` and
optional `env` fields on the other reader options), with the meaning
that runtime's sessions give it. Executable lookup uses the passed
`PATH`, home-relative fallbacks use the passed `HOME`, and child
processes receive the overlay. Built-in runtimes whose sessions refuse
`env` (Cursor, Pi Durable) refuse it in their readers too. Kimi account
usage refuses only overlays that change proxy or TLS variables
(`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY` in either case,
`NODE_EXTRA_CA_CERTS`, `SSL_CERT_FILE`, `SSL_CERT_DIR`,
`NODE_TLS_REJECT_UNAUTHORIZED`), because its HTTP request runs in the
host process.

`orient({ env })` passes `env` only to runtimes whose sessions accept it
(`refusedSessionOptions.env` absent); the others are observed in the
host environment, where their sessions run. A reader that refuses `env`
is reported as `unsupported`.

**Known limitation (Pi):** Pi readers accept `env` with in-process Pi
session semantics, where it reaches only child processes and the SDK
reads credentials and configuration from the host environment. This
holds even when sessions use `execution: "subprocess"`, whose child
process uses `env` throughout, including `HOME` for the agent directory.
With a subprocess runtime and an `env` that changes `HOME`, the agent
directory or provider keys, Pi readers and sessions can see different
configuration. A follow-up will align them.

## Behavior changes
- Executable lookup no longer searches the working directory when `PATH`
is empty, and on POSIX an unset `PATH` now searches `/usr/bin:/bin`
(previously only the working directory); on Windows an empty or unset
`PATH` finds nothing. This applies to the host's own `PATH` as well as a
passed `env`. `OAR_*_BIN` pins and absolute install-location fallbacks
still resolve (#490, #491).
- Qoder's home-directory fallback is resolved on each call instead of
when the module loads, so a later `HOME` change is seen (#491).
- `InstallationProbe` now takes an optional `InstallationProbeOptions`
argument; zero-argument probes still type-check, but a custom probe
whose first parameter has another type does not (#491).

## Fixes
- `@botiverse/oar` ships its `LICENSE` again. 0.72.0 omitted it because
pnpm copies the workspace root license only into packages without
another license-like file, and the Qwen brand assets added one. Both
packages now carry their own copy, and the packaging test compares it
with the root license (#493).

## Internal
- Toolchain: typecheck and builds use tsrs `0.20.0-ts7.1.0-beta`
(TypeScript 7.1 beta semantics, pinned exactly) instead of TypeScript
6.0.3 (#452). Its output, source maps included, is byte-identical to
official TypeScript 7.1 beta. Compared with 0.72.0's TypeScript 6 build,
emitted JavaScript is semantically unchanged; one declaration file
orders a property differently, and source maps differ. The official
`typescript` dependency remains only to check that a TypeScript 6 host
can consume the published declarations.
- Windows Pi RPC CI records process and memory samples (#492).

Co-authored-by: Cindy <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants