Skip to content

refactor: update GitHub Actions workflow and enhance TypeScript SDK#86

Merged
sawradip merged 1 commit into
mainfrom
sawra/sdk_fix_ts
Nov 13, 2025
Merged

refactor: update GitHub Actions workflow and enhance TypeScript SDK#86
sawradip merged 1 commit into
mainfrom
sawra/sdk_fix_ts

Conversation

@sawradip
Copy link
Copy Markdown
Contributor

@sawradip sawradip commented Nov 13, 2025

  • Renamed workflow job from detect-and-release to detect-release for clarity.
  • Introduced separate jobs for publishing Python and TypeScript SDKs, utilizing a reusable workflow.
  • Updated the create-release job to depend on the new publishing jobs.
  • Enhanced TypeScript SDK with improved error handling, timeout management, and structured response handling.
  • Added optional timeoutSeconds parameter to REST and WebSocket clients for better control over request durations.
  • Updated peer dependencies in package.json to include better-sqlite3 as optional.
  • Refactored environment detection logic in the client to handle undefined values more gracefully.

Summary by CodeRabbit

  • New Features

    • Added comprehensive SDK documentation and quickstart guides
    • Introduced streaming execution support for async operations
    • Added configuration options for custom timeouts and extra parameters
    • Enhanced support for both local and remote agent execution
  • Documentation

    • Published TypeScript SDK README with usage examples and configuration details
    • Added publishing guide for SDK releases
  • Chores

    • Refactored release workflow automation for improved maintainability

- Renamed workflow job from `detect-and-release` to `detect-release` for clarity.
- Introduced separate jobs for publishing Python and TypeScript SDKs, utilizing a reusable workflow.
- Updated the `create-release` job to depend on the new publishing jobs.
- Enhanced TypeScript SDK with improved error handling, timeout management, and structured response handling.
- Added optional `timeoutSeconds` parameter to REST and WebSocket clients for better control over request durations.
- Updated peer dependencies in `package.json` to include `better-sqlite3` as optional.
- Refactored environment detection logic in the client to handle undefined values more gracefully.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR refactors the GitHub Actions release workflow to use reusable job patterns for SDK publishing, introduces dedicated workflows for Python and TypeScript SDK releases, updates the TypeScript SDK client with config-driven initialization supporting local agent discovery and WebSocket streaming, restructures request/response types, and adds comprehensive documentation for publishing and SDK implementation.

Changes

Cohort / File(s) Summary
GitHub Actions Release Workflow Refactoring
.github/workflows/create-release.yml, .github/workflows/reusable-sdk-release.yml, .github/workflows/python-release.yml, .github/workflows/typescript-release.yml
Renames main job from detect-and-release to detect-release with new outputs (latest_tag, version, should_release). Replaces inline release steps with reusable workflow pattern: new Publish Python SDK and Publish TypeScript SDK jobs invoke reusable workflows; new Create GitHub Release job consolidates release creation. Adds python-release.yml workflow for PyPI publishing with version verification and PyPI existence check. Adds typescript-release.yml workflow for npm publishing with package.json version matching and npm registry checks. Introduces reusable-sdk-release.yml as a dispatcher routing to language-specific workflows based on sdk input.
TypeScript SDK Client Initialization
runagent-ts/src/client/index.ts
Introduces config-driven initialization with explicit local vs. remote setup, lazy registry initialization, two-phase setup (connection resolution then metadata loading), and ensureInitialized prerequisite. Adds explicit run and runStream methods (AsyncGenerator), URL sanitization helpers, and support for local agent discovery via registry with graceful fallbacks. Expands public interface with getExtraParams and preserves existing getters.
TypeScript SDK HTTP and REST Clients
runagent-ts/src/http/index.ts, runagent-ts/src/rest/index.ts
HttpHandler now accepts _isLocal parameter and always includes User-Agent header. RestClient now supports timeoutSeconds and isLocal; implements new /agents/{id}/run endpoint with requestData payload (entrypoint_tag, input_args, input_kwargs, timeout_seconds, async_execution). Adds comprehensive error mapping for AuthenticationError, ValidationError, ConnectionError, ServerError, ClientError. getAgentArchitecture now properly awaits and types response.
TypeScript SDK WebSocket Clients
runagent-ts/src/websocket/base.ts, runagent-ts/src/websocket/browser.ts, runagent-ts/src/websocket/node.ts
BaseWebSocketClient adds isLocal, timeoutSeconds, apiPrefix fields and accepts optional headers in createWebSocket. Endpoint changed from /agents/{id}/execute/{tag} to /agents/{id}/run-stream with Bearer token auth when not local. Request payload restructured to match ExecutionRequest changes. Adds internal helpers parseStreamMessage, cleanErrorMessage, deserializeStreamPayload. Browser and Node implementations update message handling from wrapped format to streamMessage-based parsing. Node implementation removes NodeWebSocket interface in favor of any type casting.
TypeScript SDK Types
runagent-ts/src/types/index.ts
RunAgentConfig adds optional timeoutSeconds, extraParams, enableRegistry fields. ExecutionRequest restructured: replaces action/agent_id/input_data with entrypoint_tag, input_args (flat), input_kwargs (flat), and adds optional timeout_seconds, async_execution.
TypeScript SDK Configuration & Dependencies
runagent-ts/package.json
Moves better-sqlite3 from dependencies to peerDependencies with optional: true metadata. Retains ws as optional peer dependency.
TypeScript SDK Documentation
runagent-ts/README.md, runagent-ts/PUBLISH.md, sdk_checklist.md
README.md provides comprehensive documentation for RunAgent TypeScript SDK installation, configuration, usage patterns for Node.js and browser, API surface, security, troubleshooting, and example code. PUBLISH.md details the publishing workflow for TypeScript SDK including preflight checks, build/test, publishing, and post-publish tasks. sdk_checklist.md introduces SDK implementation guide specifying constructor signatures, configuration precedence, local agent discovery via SQLite, error taxonomy, endpoint defaults, authentication, HTTP and WebSocket semantics, testing expectations, and per-SDK implementation checklist.

Sequence Diagram(s)

sequenceDiagram
    participant User as Developer
    participant Workflow as create-release.yml
    participant Detector as detect-release Job
    participant PythonPub as python-release.yml
    participant TypeScriptPub as typescript-release.yml
    participant ReleaseJob as Create GitHub Release Job
    
    User->>Workflow: Push tag
    Workflow->>Detector: Run detect-release
    Detector->>Detector: Determine latest_tag, version, should_release
    Detector-->>Workflow: Output (latest_tag, version, should_release)
    
    par Python & TypeScript Publishing
        Workflow->>PythonPub: Call reusable-sdk-release.yml<br/>(sdk: python, tag, version)
        PythonPub->>PythonPub: Verify version match<br/>Check PyPI existence<br/>Publish if needed
        
        Workflow->>TypeScriptPub: Call reusable-sdk-release.yml<br/>(sdk: typescript, tag, version)
        TypeScriptPub->>TypeScriptPub: Verify version match<br/>Check npm existence<br/>Publish if needed
    end
    
    PythonPub-->>ReleaseJob: Complete
    TypeScriptPub-->>ReleaseJob: Complete
    
    ReleaseJob->>ReleaseJob: Create GitHub Release<br/>with standardized notes<br/>& CHANGELOG.md
    ReleaseJob-->>Workflow: Release created
Loading
sequenceDiagram
    participant App as Application
    participant Client as RunAgentClient
    participant Config as Config Resolver
    participant Registry as RunAgentRegistry
    participant REST as RestClient
    participant WS as WebSocketClient
    participant Server as RunAgent Server
    
    App->>Client: new RunAgentClient(config)
    Client->>Config: Resolve local vs remote<br/>from config + env
    
    alt Local Mode
        Config->>Registry: Initialize registry<br/>(lazy load)
        Registry->>Registry: Query ~/.runagent/runagent_local.db
    else Remote Mode
        Config->>Config: Use environment endpoints
    end
    
    Config-->>Client: Connection details
    
    App->>Client: run(agentId, entrypointTag, input)
    Client->>Client: ensureInitialized()
    Client->>REST: runAgent(agentId, entrypointTag, options)
    
    rect rgba(100, 200, 100, 0.3)
        note right of REST: POST /agents/{id}/run<br/>requestData: entrypoint_tag,<br/>input_args, input_kwargs,<br/>timeout_seconds
    end
    
    REST->>Server: HTTP POST request
    Server-->>REST: ApiResponse
    REST-->>Client: Result
    Client-->>App: Response
    
    App->>Client: runStream(agentId, entrypointTag, input)
    
    rect rgba(100, 150, 200, 0.3)
        note right of WS: WebSocket upgrade<br/>to /agents/{id}/run-stream<br/>with Bearer token (remote)
    end
    
    Client->>WS: Create WebSocket connection
    WS->>Server: Upgrade to ws://
    
    loop Stream messages
        Server-->>WS: streamMessage<br/>(type: data|stream_completed|error)
        WS->>WS: parseStreamMessage()<br/>deserializeStreamPayload()
        WS-->>App: Yield payload
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • TypeScript SDK Client Initialization (runagent-ts/src/client/index.ts): Significant refactor introducing config-driven flow, lazy registry initialization, two-phase setup, and new public API surface. Verify proper initialization sequencing, registry fallback handling, and environment variable precedence.
  • WebSocket Message Handling (runagent-ts/src/websocket/*.ts): Changes to message parsing, streaming protocol, and error handling across base, browser, and Node implementations. Verify stream lifecycle (stream_completed condition), payload deserialization, and error propagation paths.
  • Request/Response Type Restructuring (runagent-ts/src/types/index.ts and REST client): ExecutionRequest shape changed significantly (entrypoint_tag, flat input_args/input_kwargs). Verify payload construction matches new schema and backward compatibility implications.
  • GitHub Actions Workflow Refactoring: New reusable workflow pattern and job dependencies. Verify conditional job execution (version checks), secret propagation through workflow calls, and proper output handling in create-release.yml.
  • Package Dependencies (runagent-ts/package.json): Moving better-sqlite3 to optional peerDependencies. Verify graceful degradation when optional dependencies are absent and registry fallback behavior.

Possibly related PRs

  • Sawra/util fix #85: Modifies RunAgent TypeScript client runtime and response handling in the same file (runagent-ts/src/client/index.ts).
  • Sawra/runagent cloud support wip #73: Implements matching changes to request/response schemas (entrypoint_tag, input_args/input_kwargs, timeout_seconds) and endpoint migration (/agents/{id}/run, /run-stream).
  • release -> ci/cd -> version release #61: Related release workflow changes adding inline PyPI publishing logic that this PR refactors into a reusable workflow pattern.

Poem

🐰 Workflows now flow through reusable gates,
Local agents peek from SQLite's states,
WebSockets stream with entrypoint grace,
Types flattened out in their rightful place,
From config's truth the client takes its stance! 🚀

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawra/sdk_fix_ts

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22ca175 and 096a236.

⛔ Files ignored due to path filters (1)
  • runagent-ts/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • .github/workflows/create-release.yml (2 hunks)
  • .github/workflows/python-release.yml (1 hunks)
  • .github/workflows/reusable-sdk-release.yml (1 hunks)
  • .github/workflows/typescript-release.yml (1 hunks)
  • runagent-ts/PUBLISH.md (1 hunks)
  • runagent-ts/README.md (1 hunks)
  • runagent-ts/package.json (1 hunks)
  • runagent-ts/src/client/index.ts (7 hunks)
  • runagent-ts/src/http/index.ts (1 hunks)
  • runagent-ts/src/rest/index.ts (1 hunks)
  • runagent-ts/src/types/index.ts (2 hunks)
  • runagent-ts/src/websocket/base.ts (2 hunks)
  • runagent-ts/src/websocket/browser.ts (2 hunks)
  • runagent-ts/src/websocket/node.ts (3 hunks)
  • sdk_checklist.md (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sawradip sawradip merged commit dc3baae into main Nov 13, 2025
1 of 2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Nov 13, 2025
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.

1 participant