Repository navigation
Conversation
Deploying phase-cli-install-script with
|
| Latest commit: |
cbe06d7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://26d5f7da.phase-cli-install-script.pages.dev |
| Branch Preview URL: | https://feat--agents.phase-cli-install-script.pages.dev |
Brings in the 11 commits on feat--agents since aaae4de. Where both lines of work fixed the same thing, the merge keeps the feat--agents version: - The guard's wrapper command keeps feat--agents' per-harness quoting (harnessWrapperCommandLine: PowerShell's call operator for Codex, and Cursor's terminal profile choosing Cursor's form). The hook commands keep ai.WindowsShellCommand from this branch. - The OpenCode plugin path, its doc comment and its test come from feat--agents; this branch keeps only the removal of the copy earlier builds left in %AppData%. - ai_shell_scope_test.go keeps the new tests from both sides. Two pieces each side's edits removed are restored because the merged code uses them: quoteWindowsCommand, which this branch had deleted, and the runtime import in opencode_plugin.go, which feat--agents had dropped.
harnessWrapperCommandLine gives Codex, and Cursor on a PowerShell profile, PowerShell's call-operator form. Every other harness on Windows (Devin, OpenCode, and Cursor on a Git Bash or Command Prompt profile) got the double-quoted form `"C:\...\phase-hook-v1.exe" "ai" ...`. cmd and Git Bash run it, but PowerShell reads a leading quoted string as an expression and rejects it, which is what kept Codex's hooks from running. Nothing guarantees that Devin and OpenCode use cmd or Git Bash on Windows. Those harnesses now get the unquoted forward-slash form that PowerShell, cmd and Git Bash all run (ai.WindowsPlainCommand, split out of WindowsShellCommand), and the double-quoted form only when the path cannot be written unquoted even with its 8.3 name.
The guard's check for PowerShell web cmdlets accepted a cmdlet only after whitespace or a shell operator, so `pwsh -Command "iwr http://phase.invalid/..."` slipped past it: the Agent got a failed host lookup instead of the message pointing it at curl. A quote now also counts as a word edge.
…r harness phase ai enable refreshes every configured harness, so enabling Cursor or OpenCode on a machine where Codex was enabled earlier still went through Codex. With the Codex CLI on PATH it reactivated an unchanged plugin and asked to re-trust its hooks; without it, it warned that Codex was not refreshed. When another harness is selected, enable now compares the Codex plugin files with what this build would write (ai.CodexBootstrapPluginCurrent, which needs no Codex CLI) and leaves an up-to-date adapter alone, with no CLI call and no Codex notes in the summary. An outdated adapter is still refreshed when the CLI is available, and is otherwise reported as out of date.
- One PowerShell quoting helper (ai.PowerShellCallCommand) serves both the guard's wrapper and the hook fallback, so the fallback now doubles typographic single quotes too; Devin recognizes that spelling on reinstall. - Drop the %AppData% OpenCode plugin cleanup: no released build installed the plugin there. - CodexBootstrapPluginCurrent compares the plugin version and hooks without reshaping InstallCodexBootstrapPlugin. - Shorter comments.
fix(agents): Windows fixes for Phase AI harness integrations
The Console now mints Agent tokens as
pss_agent:v2:{token}:{kx_pub}:{share_a}:{wrap_key}, the same layout as
Service Account tokens. Parse that form and reject the bearer-only v1
form, which was never released. Only the bearer part is sent.
No released CLI or Console has ever handled pss_agent tokens, so the
first released form is pss_agent:v1:{token}:{kx_pub}:{share_a}:{wrap_key}.
The prefix alone selects Agent authentication, so the version does not
need to match Service Account tokens. v2 and the bearer-only form are
rejected.
…it codes OpenCode runs commands in pwsh or Windows PowerShell unless $SHELL names another shell, so a helper path that cannot be written unquoted now gets PowerShell's call-operator form there, and the cmd form only under Git Bash or cmd. Devin gets the same form as its hooks. PowerShell -Command reports every failure as exit 1; the wrapped command now exits with a failed native command's own status.
Refreshing or removing the Devin hooks dropped every hook group that held a Phase handler, along with any user handler added to the same group. Cleanup now removes only Phase's handlers, keeps the rest of the group as written, and drops a group only once it has no handler left.
On macOS and Linux a helper path with an apostrophe is rendered with the '"'"' escape, which cleanup did not look for. Reinstalling duplicated the hooks and disabling left them in place. Cleanup now also matches the spelling from the same renderer that writes the hooks.
…t own Installing the Claude adapter overwrote whatever manifest and hooks were in ~/.claude/skills/phase-ai-bootstrap, and the rewritten manifest then let uninstall remove the whole directory. Install now refuses an existing directory without Phase's manifest, and uninstall removes only the two files Phase writes and the directories they leave empty.
The tokenizer split >& and <& at the ampersand, so the descriptor after it looked like a separate ordinary command and a Phase control call ending in 2>&1 was denied as mixed. An ampersand straight after > or < now stays part of the redirection.
OpenCode 2.x names its command tool shell, but the 2.x execute.before hook only handled bash, so explicit phase.invalid calls were never checked or rewritten there. The 2.x hook now handles shell, and the plugin test dispatches the 2.x event with that name.
OpenCode loads plugins and skills from one global config root: OPENCODE_CONFIG_DIR, else $XDG_CONFIG_HOME/opencode, else ~/.config/opencode. Phase always used ~/.config/opencode, so with either variable set enable reported success but OpenCode never loaded the plugin or skill. The plugin path and the OpenCode skill targets now resolve that root, so install and disable agree with OpenCode. The relay keeps the default layout for sandbox homes, which do not share this machine's environment.
…credential calls The minting guard missed several AWS calls that hand back a fresh credential: EC2 CreateKeyPair and Lightsail CreateKeyPair, DownloadDefaultKeyPair and GetInstanceAccessDetails (SSH private keys), Lightsail CreateBucketAccessKey (an access key pair), Redshift Serverless GetCredentials (database credentials) and S3 Express CreateSession (session credentials for a directory bucket). They are now in the rule table. CreateSession is a GET on the bucket with a ?session query, so path rules can also require a query parameter.
A host rule with a path matched against the cleaned request path, but the request went upstream as sent. S3 keeps "..", "." and repeated slashes in object keys, so with a rule for /allowed/* a request for /outside/../allowed/key was bound to the Connection and signed for an object outside the prefix. A path that cleaning would change (other than a trailing slash) now never matches a path-scoped rule, so it is not bound to that Connection.
Re-signing required every signed header to carry exactly one value, so an S3 PutObject signed with two X-Amz-Meta-* values was refused as a malformed Authorization header. SigV4 signs repeated values joined by commas, and the SDK signer does the same when the proxy re-signs. Ordinary signed headers now only need to be present. X-Amz-Date, X-Amz-Content-Sha256, X-Amz-Security-Token and Authorization stay single-valued where they are read.
Response redaction deleted ETag from every AWS response with a body, so an S3 GetObject through the proxy came back without the version identifier clients pass to If-Match on a later conditional write. ETag is now kept. Content-Length, Content-MD5 and Digest are still dropped because redaction can change the body.
S3 sends an object's stored Content-Encoding even when the request asks for identity, and response redaction refused every encoded AWS body, so any object uploaded with Content-Encoding: gzip failed through the proxy with unsafe_aws_response. A gzip body of up to 8 MiB is now read and decoded in full and, when no live value appears in the compressed bytes or the decoded content, passed on unchanged with its original length, ETag and checksums. Larger gzip bodies, bodies that do not decode, bodies carrying live material and other encodings are still refused. Content-Encoding is read across all header values, so a stacked encoding is refused rather than read by its first value.
CAStore.Ensure read, renewed and published the CA with no lock. Two runtimes starting while the CA was inside its renewal window could each generate a CA and interleave their writes, leaving one CA's private key in the keyring beside the other's certificate: leaves from one live proxy then failed against the published bundle, and the next Ensure replaced the CA again. Ensure now holds an exclusive lock on ca.lock in the CA directory (flock on Unix, LockFileEx on Windows) from the first read to the last write, so a second caller loads the CA the first one published.
…password After authentication the PostgreSQL adapter copied client traffic to the upstream unread, so an Agent could run ALTER ROLE CURRENT_USER PASSWORD '...' and hold a password of its own that outlives the Phase session, or create a new login role. The adapter now reads client messages one at a time and checks the SQL of each simple Query and Parse. A statement that creates a role or sets a role password is swapped for one that raises Phase's credential-minting message (SQLSTATE 42501), so the server returns an ordinary error and the session, any open transaction and pipelined messages stay in step. The block is recorded as a credential_minting_blocked event. The check is best-effort: SQL assembled at run time is not seen. A Query or Parse larger than 16 MiB now closes the connection instead of being forwarded uninspected.
A plain http:// request to a bound AWS host (port 80, or http://...:443) was re-signed with the live credential and sent in cleartext, exposing the live access key ID, session token and a replayable signature to anyone on the path before AWS refused or served it. SigV4 Connections now refuse plaintext requests with aws_https_required before anything is re-signed. Loopback endpoints keep working over HTTP, as the PostgreSQL adapter already allows.
The PostgreSQL connection watcher armed a timer only for the credential's expiry and relied on the monitor to fail the session at its hard expiry. The monitor stops its expiry timer while it refreshes, so a slow Console refresh kept an open PostgreSQL connection usable past session expiry. The watcher now closes the connection at the earlier of the session and credential expiry. HTTP requests and WebSockets already check the session expiry themselves.
eventSecrets counted every field of a Connection's secret material, including the public username it shares with the Agent-visible identifiers. With the common PostgreSQL user "postgres", the protocol and provider fields of any PostgreSQL denial or error event matched that "secret", so audit validation failed and stopped every Connection in the runtime. Audit redaction now uses the same proxy-only credential values as the manifest checks (agentapi.ProxyOnlyCredentialValues), alongside the decoys and the session and runtime capabilities.
phase ai exec --connection removed every variable the runtime plan owns and then applied the selected Connection's plan. A relay compiles that plan with its own CA file paths, which the relay bootstrap rewrites to the sandbox's $HOME/.phase/ai files or leaves unset. In a bootstrapped sandbox the selected command therefore got relay-local PGSSLROOTCERT, SSL_CERT_FILE and similar paths, and PostgreSQL and AWS TLS failed. A value the selected plan leaves unchanged from the runtime plan now keeps its inherited form; only values the selection changes or drops are replaced. Locally the inherited values already match the runtime plan, so nothing changes there.
…alue on the request
…to the Console's manifests
…d begins the same
…tenv read it Single quotes broke every export with a ' in a value: Compose refused the file and python-dotenv dropped the line. Values without a single quote stay in single quotes as they are; the rest go in double quotes with \, ", $ and backtick escaped, so a shell still never runs a value.
… arrives whole Runs on the Windows CI job: the payload first runs through cmd.exe to show it is real, then the opener's exact arguments start a stand-in for rundll32, which must receive the URL unchanged with nothing run.
…inventory # Conflicts: # src/cmd/ai_status.go # src/cmd/leak_protection.go # src/cmd/leak_protection_test.go # src/cmd/users_logout.go # src/internal/aiproxy/CONTROL_API.md # src/internal/aiproxy/control_inventory.go # src/internal/aiproxy/leak.go # src/internal/aiproxy/leak_policy_test.go # src/internal/leakguard/leakguard_test.go # src/pkg/censor/entries.go
…it was saved with
Five probes changed in the base itself: URL tokens and passwords now keep their first characters as structure, so pieces holding fewer than 12 secret characters are left alone.
…Windows reports as 0666
…Windows reports as 0666
…1305, and finish its writes before a proxy exits - The store is now secret-inventory.bin (with .lock and .queue), its keystore entry phase-cli-ai-secret-inventory, and its derivation labels and file magic follow the name. - Records are sealed with XChaCha20-Poly1305 from golang.org/x/crypto, which the CLI already depends on, with 24-byte random nonces. - The key route takes POST only. Nothing sends GET to it. - Status waits at most 250 ms for the keystore's answer on whether the key is still this process's, so a locked keystore never makes a health check late. A slower answer still lands, and the next Status reports it. - A stopping proxy waits, at most 5 seconds, for the inventory writes that registrations it already acknowledged left running.
feat(ai): keep leak protection's inventory across proxy restarts
… the AWS action classes, rules by AWS action and the Admin class Every HTTP Connection, AWS included, now classes a call by its method (GET, HEAD, OPTIONS read; POST create; PUT, PATCH update; DELETE delete; any other update), with the method-override headers and parameters it already honoured. The CLI no longer reads actionClasses or operationClasses, refuses a policy that names the admin class or a rule by AWS action as one it cannot enforce, and asks for an AWS call's method and exact path like any other call. The secret guard keeps reading AWS action names off the wire for minting calls, with the few AWS protocol facts it needs held beside it, so an AWS Connection needs only its secretGuard to be served. The equivalence corpus keeps its guard answers and loses the classifier's.
…a member can change the Connection's access rules A Block answer now names the Connection, the call's method and path, and the HTTP rule, the class's row, or the Default that row follows, in the words the Phase Console uses, and says a member can change this Connection's access rules there. A blocked call still cannot be requested; an Ask keeps its ready-made request.
…the access policy versioning contract CONTROL_API.md and the access-rules guide now say every HTTP call is classed by its method alone, AWS included, that an approval asks for the call's method and exact path, and what a blocked call's answer names. The policy section writes down the versioning contract: a higher version, or a class, effect or rule kind this CLI does not know, makes the Connection unavailable with a message to update the Phase CLI, and unknown keys elsewhere are ignored.
… manifest, with its GitHub Enterprise paths and SSH key calls
…he Workflow's, and write "an update call" The Ask answer, the skill, the access-rules guide and CONTROL_API.md now place the access rules on the Connection; only temporary allows and the time limit belong to the Workflow's grant. An Ask for a PUT or PATCH now reads "(an update call)".
… binding is newer than this CLI, instead of failing the session A binding with a member, an action or a source this CLI does not know is still never applied, but it no longer fails the whole session open: its Connection is unavailable (environment_bindings_unsupported, 403 agent_connection_unsupported, "Update the Phase CLI."), exports nothing, keeps its credential names reserved and its hosts on the proxy, and every other Connection works as usual.
…path still reads as a percent escape the Console would refuse
…pply in the guard's own words, not the access policy's
…rride names a method outside the usual nine
…gment, as the proxy does
…ames a whenAbsent newer than this CLI, instead of rejecting the session's Connections An unknown whenAbsent now does what a newer environment binding does: the Connection is unavailable (when_absent_unsupported, 403 agent_connection_unsupported, "Update the Phase CLI."), exports nothing, keeps its credential names reserved and its hosts on the proxy, and the session and its other Connections keep working. A refresh that brings one recycles the session like any change to the Agent's environment, instead of being rejected.
…n unavailable, not to fail the bindings
…t POST body, and forward the whole upload unchanged Rack reads _method from multipart forms as well, so a multipart POST that asks to be run as DELETE is now also judged as a delete. Only the first 256 KiB are read, the bound a urlencoded form has: a part beyond or across it is not read, a larger upload is never refused for it, and the body is replayed from the bytes already read followed by the rest.
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
Phase AI lets coding agents use third-party services (HTTP APIs, AWS, PostgreSQL) and Phase app secrets through Connections a member approved in the Console, without receiving a live credential. The agent's process gets decoys; a local proxy swaps them for the real credential on the way out, enforces the Connection's access rules, and blocks calls that would mint new credentials.
The Console side is phasehq/console#1025.
What's in here
phase ai enable | disable | status,phase ai run -- <agent>,phase ai exec -- <command>,phase ai guide [topic],phase ai skill, and a hook-managed proxy daemon shared by the harness sessions (internal/aiproxy,internal/airuntime).phase-cli, installed per harness, with the detail in guides printed byphase ai guide(Connections, custom HTTP, access rules, app secrets, Workflow context, troubleshooting).pkg/proxy): credential injection for packaged and custom HTTP Connections (header, basic auth, query; attach or block when a request carries no credential), SigV4 re-signing, PostgreSQL, and a per-installation CA.pss_agent:v1token.http://phase.invalidfor the agent: status, Connections, presets, hints for hosts with no Connection, requests, refresh (internal/aiproxy/CONTROL_API.md).phase secrets *,phase run,phase apps listandphase initwork for the apps and environments the Workflow was granted. Inside a Phase AI sessionphase rundoes not inject secrets named like proxy or provider credential variables.phase auth --mode tokenaccepts an Agent token and stores it in the system keystore;--insecure-storageopts in to plain-text storage on a machine without one.internal/agentsdk; the CLI stays on golang-sdk v2.4.1.Safety properties
secretorsealedvalues, and a one-line warning goes to stderr.~/.phase/aiholds only what is in use: no per-session lock files, spool folders only while they hold undelivered events, and a sweep that removes leftovers of earlier builds.phase users logout --purgestops the proxy and removes the CA key as well.Removed
phase relayand the remote mode behind it, the secret visibility setting (--mask/--no-mask),--mode, Devin support, and the two earlier skills.Testing
go build,go vetandgo test ./...pass on macOS, plus the race detector on the proxy packages. CI runs the tests on Linux, macOS and Windows, andphase ai enableon those three plus five Linux distribution images.Not in this PR
Dynamic secrets and
phase shellfor Agent tokens, end-to-end encrypted apps for Agents, SQL-level rules, replay of undelivered audit events from ended sessions. Docs are in phasehq/docs#273 and need updating to match.