Skip to content

feat(sdk): expose runScriptWorkflow() in @agent-relay/sdk/workflows#799

Merged
khaliqgant merged 3 commits intomainfrom
feat/sdk-run-script-workflow
Apr 29, 2026
Merged

feat(sdk): expose runScriptWorkflow() in @agent-relay/sdk/workflows#799
khaliqgant merged 3 commits intomainfrom
feat/sdk-run-script-workflow

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Apr 28, 2026

Summary

Lifts the body of agent-relay run <script> out of the relay CLI and into the published @agent-relay/sdk/workflows so other tools — ricky in particular — can drive the same .ts / .tsx / .py execution flow in-process instead of spawning the agent-relay binary.

  • New SDK exports from @agent-relay/sdk/workflows:
    • runScriptWorkflow(filePath, options) — main API
    • parseTsxStderr / formatWorkflowParseError — workflow parse-error normalizer
    • findLocalSdkWorkspace / ensureLocalSdkWorkflowRuntime — dev-mode SDK auto-build helpers
    • Types: RunScriptWorkflowOptions, ParsedWorkflowError, LocalSdkWorkspace, ExecFileSyncLike
  • @agent-relay/sdk 6.0.2 → 6.1.0 (additive). Root @agent-relay/sdk dep updated to match.
  • relay/src/cli/commands/setup.ts: ~390 lines of helper functions deleted and replaced with imports from @agent-relay/sdk/workflows. The CLI's run command body is unchanged in shape — it just delegates to the SDK function, and setup.ts still re-exports the helpers so any internal consumer importing from it keeps working.
  • 9 unit tests added in packages/sdk/src/workflows/__tests__/run-script.test.ts (parse-error normalizer, formatter hints, missing-file error, unsupported-extension error, workspace detector).

Net diff: −408 / +625 (the SDK gains the run-script body + tests; the CLI shrinks).

Why

Other AgentWorkforce tools want <tool> run <script> semantics that match agent-relay run <script> exactly. Today they shell out to the agent-relay binary, which means: (1) ~1-2s npx cold-start; (2) PATH / --no-install resolution issues for users with global vs local installs; (3) drift risk if relay changes its execution semantics. With this PR the runner is callable as a single import.

Test plan

  • vitest run in packages/sdk (run-script tests) — 9 passed
  • vitest run src/cli/ (full relay CLI suite) — 178 passed, 5 skipped
  • tsc --noEmit at repo root — clean
  • Smoke test once published: a non-relay CLI imports runScriptWorkflow and runs a .ts workflow end-to-end (will follow up in the ricky-side PR that lands once 6.1.0 publishes)

Compatibility

  • @agent-relay/sdk@6.0.x consumers see only additive surface — no removed exports.
  • agent-relay run <file> CLI behavior is byte-for-byte unchanged. Same telemetry, same exit codes, same log lines (the [agent-relay] diag breadcrumbs come from the same code, just imported from a new location).
  • setup.ts still re-exports the helpers for any internal callers.

🤖 Generated with Claude Code


Open in Devin Review

Lifts the body of `agent-relay run <script>` out of the relay CLI and into
the published @agent-relay/sdk so other tools (ricky in particular) can
import the same .ts/.tsx/.py runner directly instead of spawning the
agent-relay binary.

- New SDK exports from @agent-relay/sdk/workflows:
    runScriptWorkflow, parseTsxStderr, formatWorkflowParseError,
    findLocalSdkWorkspace, ensureLocalSdkWorkflowRuntime, plus
    RunScriptWorkflowOptions / ParsedWorkflowError / LocalSdkWorkspace types.
- @agent-relay/sdk bumped 6.0.2 → 6.1.0 (additive; root dep updated to match).
- relay/src/cli/commands/setup.ts: ~390 lines of helper functions deleted
  and replaced with imports from @agent-relay/sdk/workflows. The CLI's
  `run` command body is unchanged in shape — it just delegates to the SDK
  function. setup.ts also re-exports the helpers so any internal consumer
  importing from setup.ts keeps working.
- 9 unit tests added in packages/sdk/src/workflows/__tests__/run-script.test.ts
  covering the parse-error normalizer, formatter hints, missing-file error,
  unsupported-extension error, and the workspace detector.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2bcd9eaa6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
"@agent-relay/config": "6.0.2",
"@agent-relay/hooks": "6.0.2",
"@agent-relay/sdk": "6.0.2",
"@agent-relay/sdk": "6.1.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Synchronize lockfile after bumping @agent-relay/sdk

The root dependency was bumped to @agent-relay/sdk 6.1.0, but package-lock.json in this commit still records 6.0.2 for the root package and packages/sdk, so the manifest and lockfile diverge. This is likely to break CI installs that use npm ci (for example .github/workflows/test.yml), because npm's ci behavior requires package.json and lockfile dependency entries to match rather than rewriting the lock.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 96801aa — bumped @agent-relay/sdk from 6.0.26.1.0 in all 5 workspace consumers (acp-bridge, browser-primitive, gateway, hooks, openclaw) and regenerated package-lock.json. All 58 CI checks now pass.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

devin-ai-integration Bot and others added 2 commits April 29, 2026 00:58
Co-Authored-By: Khaliq Gant <khaliqgant@gmail.com>
… sync lockfile

Co-Authored-By: Khaliq Gant <khaliqgant@gmail.com>
@khaliqgant khaliqgant merged commit ee0373f into main Apr 29, 2026
58 checks passed
@khaliqgant khaliqgant deleted the feat/sdk-run-script-workflow branch April 29, 2026 01:19
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