feat(pty): propagate active sessionId and AGENT_TTY_ACTIVE to spawned processes#166
Open
prmartinow wants to merge 1 commit into
Open
feat(pty): propagate active sessionId and AGENT_TTY_ACTIVE to spawned processes#166prmartinow wants to merge 1 commit into
prmartinow wants to merge 1 commit into
Conversation
… processes This exposes AGENT_TTY_ACTIVE=true and AGENT_TTY_SESSION_ID=<sessionId> in the child PTY environment, allowing scripts and utilities inside the session to detect and inspect the active agent-tty context.
5f6d685 to
dc7679d
Compare
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.
This PR exposes the active session state in the environment of all PTY processes spawned by
agent-tty.Specifically, it injects:
AGENT_TTY_ACTIVE=true: A simple boolean flag indicating the command is running inside a managed session.AGENT_TTY_SESSION_ID=<sessionId>: The UUID of the current terminal session.Why this is useful:
It enables scripts, shell profiles, and automation utilities running inside the virtual terminal to:
Code Changes
src/host/hostMain.tsPasses
sessionIdfromrunHostintocreatePtyoptions.src/pty/createPty.tsPtyOptionswith an optionalsessionIdfield.resolvePtyEnvto accept an optionalsessionId.resolved.AGENT_TTY_ACTIVE = 'true'unconditionally.resolved.AGENT_TTY_SESSION_ID = sessionIdwhen asessionIdis provided.test/unit/pty/createPty.test.tsAdds Vitest unit tests verifying:
AGENT_TTY_ACTIVEis unconditionally set to'true'.AGENT_TTY_SESSION_IDis set to the provided value if present.AGENT_TTY_SESSION_IDis undefined when nosessionIdis passed.Verification & Testing
Verify that all repository formats, lints, types, and tests pass:
npm run format:check npm run lint npm run typecheck npm run test npm run build