feat(sdk): expose runScriptWorkflow() in @agent-relay/sdk/workflows#799
feat(sdk): expose runScriptWorkflow() in @agent-relay/sdk/workflows#799khaliqgant merged 3 commits intomainfrom
Conversation
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>
There was a problem hiding this comment.
💡 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".
| "@agent-relay/config": "6.0.2", | ||
| "@agent-relay/hooks": "6.0.2", | ||
| "@agent-relay/sdk": "6.0.2", | ||
| "@agent-relay/sdk": "6.1.0", |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
Fixed in 96801aa — bumped @agent-relay/sdk from 6.0.2 → 6.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.
Co-Authored-By: Khaliq Gant <khaliqgant@gmail.com>
… sync lockfile Co-Authored-By: Khaliq Gant <khaliqgant@gmail.com>
Summary
Lifts the body of
agent-relay run <script>out of the relay CLI and into the published@agent-relay/sdk/workflowsso other tools — ricky in particular — can drive the same.ts/.tsx/.pyexecution flow in-process instead of spawning theagent-relaybinary.@agent-relay/sdk/workflows:runScriptWorkflow(filePath, options)— main APIparseTsxStderr/formatWorkflowParseError— workflow parse-error normalizerfindLocalSdkWorkspace/ensureLocalSdkWorkflowRuntime— dev-mode SDK auto-build helpersRunScriptWorkflowOptions,ParsedWorkflowError,LocalSdkWorkspace,ExecFileSyncLike@agent-relay/sdk6.0.2 → 6.1.0 (additive). Root@agent-relay/sdkdep 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'sruncommand body is unchanged in shape — it just delegates to the SDK function, andsetup.tsstill re-exports the helpers so any internal consumer importing from it keeps working.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 matchagent-relay run <script>exactly. Today they shell out to theagent-relaybinary, which means: (1) ~1-2s npx cold-start; (2) PATH /--no-installresolution 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 runinpackages/sdk(run-script tests) — 9 passedvitest run src/cli/(full relay CLI suite) — 178 passed, 5 skippedtsc --noEmitat repo root — cleanrunScriptWorkflowand runs a.tsworkflow end-to-end (will follow up in the ricky-side PR that lands once 6.1.0 publishes)Compatibility
@agent-relay/sdk@6.0.xconsumers 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.tsstill re-exports the helpers for any internal callers.🤖 Generated with Claude Code