feat(cloud): expose connectProvider() in @agent-relay/cloud SDK#798
feat(cloud): expose connectProvider() in @agent-relay/cloud SDK#798khaliqgant merged 3 commits intomainfrom
Conversation
Lifts the Daytona-brokered provider auth flow out of the relay CLI and into
@agent-relay/cloud so other CLIs (ricky, future tools) can drive it directly
via `import { connectProvider } from '@agent-relay/cloud'` instead of shelling
out to `agent-relay cloud connect`.
- New exports: connectProvider, getProviderHelpText, normalizeProvider,
runInteractiveSession, formatShellInvocation, wrapWithLaunchCheckpoint,
loadSSH2, createAskpassScript, buildSystemSshArgs, plus SSH-related types.
- ssh2 is now an optionalDependency of @agent-relay/cloud — the package falls
back to system ssh when ssh2 isn't installed (existing behavior, just newly
exposed to consumers).
- Cloud SDK bumped 6.0.2 → 6.1.0.
- The `agent-relay cloud connect` command body shrinks from ~150 LOC to a
thin wrapper around connectProvider() that keeps telemetry attribution.
- src/cli/lib/{ssh-interactive,auth-ssh}.ts now re-export the SDK helpers
(rather than redefining them) so the existing `auth` command path is
unchanged. ssh-interactive.test.ts moved to packages/cloud alongside
the implementation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
barryollama
left a comment
There was a problem hiding this comment.
👋 Review from Barry (barryollama)
Thanks for the review request! I took a look at this refactoring PR and overall it looks like a solid architectural improvement. Here are my thoughts:
What I like:
-
Clean SDK extraction — Moving
connectProvider(),runInteractiveSession(), and the SSH runtime helpers into@agent-relay/cloud(6.1.0) creates a proper import boundary for other CLIs like ricky. The cloud package now owns the SSH implementation details. -
Backward compatibility — The existing CLI commands still work by re-exporting from the SDK, which is important for existing users.
-
Optional dependency — Making
ssh2anoptionalDependencyis the right call. It allows consumers without the native module to fall back to systemsshseamlessly. -
Type safety — The exported types give consumers a clear API contract.
A couple of observations:
- The CLI command shrinks from ~150 LOC to a thin wrapper — excellent deduplication.
- The moved
ssh-interactive.test.tsplus newconnect.test.tsshows the test coverage is being preserved. - The
CHANGELOG.mdentry is comprehensive and follows the project's format.
Overall assessment:
- This is a well-structured refactoring.
- The extraction reduces duplication while maintaining backward compatibility.
- The test plan in the PR description covers the right surface area.
LGTM! 🚀
Resolves CHANGELOG.md by keeping both 6.1.0 entries (cloud connect SDK and sdk/workflows script runner). Other files auto-merged.
# Conflicts: # CHANGELOG.md
Summary
Lifts the Daytona-brokered provider auth flow out of the relay CLI and into the published
@agent-relay/cloudpackage so other CLIs (ricky, future tools) can drive it directly viaimport { connectProvider } from '@agent-relay/cloud'instead of shelling out toagent-relay cloud connect.connectProvider,getProviderHelpText,normalizeProvider,runInteractiveSession,formatShellInvocation,wrapWithLaunchCheckpoint,loadSSH2,createAskpassScript,buildSystemSshArgs,DEFAULT_SSH_RUNTIME, plus SSH-related typesssh2is now anoptionalDependencyof@agent-relay/cloud— when missing, the existing system-sshfallback path is used (behavior unchanged, just newly visible to consumers)@agent-relay/cloudbumped 6.0.2 → 6.1.0 (additive)agent-relay cloud connectcommand body shrinks from ~150 LOC to a thin wrapper aroundconnectProvider()that keeps telemetry attributionsrc/cli/lib/{ssh-interactive,auth-ssh}.tsnow re-export the SDK helpers (rather than redefining them) so the existingauthcommand path is unchangedssh-interactive.test.tsmoved topackages/cloud/src/lib/alongside the implementationNet diff: ~1000 lines deleted (deduped to the SDK), ~600 added in the new package files.
Why
Other tools in the AgentWorkforce family (ricky in particular) want a
<tool> connect <provider>UX that uses the same Daytona-brokered auth flow. Today they'd have to either shell out toagent-relay cloud connector copy the SSH/PTY code. Extracting it into the published cloud package gives them a clean import boundary.Test plan
vitest runinpackages/cloud(32 passed — includes the movedssh-interactivetests + newconnectunit tests fornormalizeProvider/getProviderHelpText)vitest run src/cli/commands/{cloud,auth}.test.ts src/cli/bootstrap.test.ts(14 passed — confirms CLI wiring still resolves through the SDK)tsc --noEmitat repo root — cleanagent-relay cloud connect claudeend-to-end against staging cloud (not run from this branch — needs a cloud account)connectProviderand shipsricky connect <claude|codex|opencode>(follow-up PR in the ricky repo)Compatibility
@agent-relay/cloud6.0.x consumers see only additive surface — no removed exportsauthcommand (agent-relay auth <provider>) is unchanged — same SSH path, just imported from the cloud packagessh2moves from a regular dep (at the relay repo root, where it stays) to anoptionalDependencyof@agent-relay/cloudso SDK consumers get it on a clean install but cannpm install --no-optionalif they want to skip the native build🤖 Generated with Claude Code