Repository navigation
Conversation
berthd task new and session new take --env KEY=VALUE (repeatable), the task and session API take env, and the berth_task_new MCP tool takes an env object. The variables reach that session alone, in its terminal or through the agent host, over the same names from the box's env.json and the project's env, and they last through a switch between the terminal and the chat. Names berthd sets itself (BERTH_SESSION, BERTH_PORT, the worktree's BERTH_*, BERTH_HOME, BERTH_OP, …) and malformed ones are refused before anything is made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Stener1 is attempting to deploy a commit to the seanbrydonio's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
berthd sets env per box (
~/.berth/env.json) and per repo (envin.berth/config.json), but not per session. This adds the third level: one task or session gets variables of its own, e.g. a ticket id for its hooks, a second Claude Code account (CLAUDE_CONFIG_DIR), or a different config for each agent you start.POST /v1/tasks, POST /v1/sessions (+ env: {KEY: VALUE}) + CheckSessionEnv(env) # before any worktree or session is made createAgentSessionWith(…, own) sessionEnv(dir, names(own)) # worktree env without those names (and no secret ref for them) + + own's KEY=VALUE # session > repo > box + @berth_env = "KEY1,KEY2" # names only; values live in the tmux session env respawnAgent (terminal <-> chat switch, resume in place) - re-passes the worktree's value for every key + leaves own's names out (worktree value and the browser-timeout default), so tmux supplies themBERTH_SESSION,BERTH_AGENT,BERTH_DRIVER,BERTH_PORT,BERTH_PORT_<n>, the worktree'sBERTH_*, the browser-proxy vars,BERTH_SECRET_VARS), plusBERTH_HOME,BERTH_USER_DIR,BERTH_OP(the secret wrapper in the session trusts them to pickopand the 1Password session file). Malformed input is refused too:--env KEYwith no=, an empty key, the same key twice, a non-identifier, or a NUL in a value. Other names,BERTH_ones included, are the session's to use. A test fails if berthd starts setting aBERTH_variable that a session may still set.$VARexpansion, no secret-reference resolution. The docs point secrets toenvreferences.reference/berthd.mdx,reference/cli.mdx,reference/files.mdx(new "A session's own variables" section),guides/runs.mdx(MCP tool),guides/project-config.mdx, changelog under Unreleased. Theberthskill mentions--env. verify-berthd getsfeatures/session-env.md,scripts/session-env-live.shandscenarios/session-env-live.mjs.Evidence
Before (v0.3.31):
berthd task new acme/x --env A=b→usage: task new LOC/NAME [--agent ID] … [-- COMMAND...](no such flag).After: on a dev box of this branch (
dev-box.sh up),scripts/session-env-live.shsetsACME_*in the box env (ACCOUNT,TICKET,REGION=box), the repo env (TICKET,REGION=repo) and each session's own (REGION,RUN). It then starts real Claude Code four ways, and each agent's own Bash tool ranenv | grep ^ACME_:task new --envACME_ACCOUNT=box ACME_REGION=eu-north ACME_RUN=task run 41 ACME_TICKET=reposession new --envACME_ACCOUNT=box ACME_REGION=us-east ACME_RUN=session-42 ACME_TICKET=repoberth_task_newenv:{…}(viaberthd mcp)ACME_ACCOUNT=box ACME_REGION=ap-south ACME_RUN=mcp-43 ACME_TICKET=reposession new --env -- claude …ACME_ACCOUNT=box ACME_REGION=eu-west ACME_RUN=term-44 ACME_TICKET=repoRefusals on the same box, with no session or worktree made:
A live switch of the MCP-started session to its terminal and back (
POST sessions/{name}/switch) keptACME_REGION=ap-south ACME_RUN=mcp-43in the new pane each time (switch.txt).The chats in the app (
drive.mjs session-env-live --agent …, no console errors):Tests:
TestASessionsOwnEnvironmentComesOverTheProjectsAndTheBoxs: session > repo > box, for task and session, over a real tmux.TestASessionCantSetBerthdsOwnVariablesOrMalformedOnesTestEveryVariableBerthdSetsIsRefusedForASession: the drift guard.TestAStructuredAgentKeepsItsOwnVariablesAcrossASwitch: the pane env from/procafterrespawnAgent, including a session-setAGENT_BROWSER_IDLE_TIMEOUT_MS=0. It fails without the respawn fix.TestEnvFlagsSetTheNewSessionsOwnVariables,TestAMalformedEnvFlagIsRefusedNeverDropped,TestATasksAgentGetsTheVariablesItWasGiven(MCP).Checks:
go vet ./...is clean.go test -race ./internal/box ./internal/boxcmd ./internal/mcpserverpasses on the final commit.go test -race ./...passed exceptinternal/agent's two SSH-route timeouts (they pass 3/3 on rerun) andleadline/api'sTestDetach, which fails on main on this machine too.pnpm buildand the docs-site build pass.cargo check, because this Linux box has no GTK dev libs. No Rust changed.Merge Danger
Door: two-way
Additive: with no
env, every path builds the same environment as before (TestSessionsWithoutSecretsStartAsTheyAlwaysDidstill asserts the exactnew-sessionargs). Revert is a plain revert. Sessions started with--envjust keep an unused@berth_envoption.Blast Radius: sessions
Every agent and terminal start goes through the changed
createAgentSessionWith/sessionEnv, and every terminal↔chat switch and resume-in-place throughrespawnAgent. A mistake there would show up as a wrong or missing variable in new sessions, not as data loss.🤖 Generated with Claude Code