feat(cli): add deployed persona trigger command#247
Conversation
|
Warning Review limit reached
More reviews will be available in 48 minutes and 1 second. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughA new ChangesCLI trigger subcommand
Sequence Diagram(s)sequenceDiagram
participant User as User (CLI)
participant runTrigger
participant triggerDeployment
participant Resolver as resolveDeploymentContext
participant Cloud as Cloud trigger-now endpoint
User->>runTrigger: agentworkforce trigger <selector> [flags]
runTrigger->>runTrigger: parseTriggerArgs(args)
runTrigger->>triggerDeployment: TriggerOptions
triggerDeployment->>Resolver: resolve workspace / cloudUrl / auth
Resolver-->>triggerDeployment: context + deployments
triggerDeployment->>Cloud: POST /trigger-now (Bearer token)
alt 401 Unauthorized
Cloud-->>triggerDeployment: 401
triggerDeployment-->>runTrigger: throw login-retry error
else HTTP error
Cloud-->>triggerDeployment: non-OK + body
triggerDeployment-->>runTrigger: throw formatted HTTP error
else Success
Cloud-->>triggerDeployment: JSON payload
triggerDeployment->>triggerDeployment: parseTriggerResponse(payload)
triggerDeployment-->>runTrigger: TriggerResponse
runTrigger-->>User: JSON or formatTriggerResult output
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new trigger command (and a corresponding deployments trigger subcommand) to manually fire an active deployed persona. It includes the implementation of the command, argument parsing, API integration, and unit tests. The review feedback highlights two issues in the argument parsing logic: first, unknown single-dash flags could be incorrectly treated as the agent selector; second, single-dash flags could be swallowed as values for other flags. Suggestions are provided to resolve both issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| } else if (!selector) { | ||
| selector = arg; | ||
| } else { | ||
| throw new Error(`trigger: unexpected positional argument "${arg}"`); | ||
| } |
There was a problem hiding this comment.
The parser currently allows any argument (including unknown single-dash flags like -x) to be treated as the agent selector if it hasn't been set yet. To prevent this and maintain consistency with parseDeploymentLogsArgs in list-command.ts, we should ensure the selector does not start with - and throw an unknown flag error for single-dash flags.
} else if (!arg.startsWith('-') && !selector) {
selector = arg;
} else if (arg.startsWith('-')) {
throw new Error(\`trigger: unknown flag \"\ h{arg}\"\`);
} else {
throw new Error(\`trigger: unexpected positional argument \"\ h{arg}\"\`);
}| } | ||
|
|
||
| function expectValue(flag: string, value: string | undefined): string { | ||
| if (typeof value !== 'string' || !value.trim() || value.startsWith('--')) { |
There was a problem hiding this comment.
The check value.startsWith('--') only prevents double-dash flags from being swallowed as values. Single-dash flags (like -h) will still be incorrectly accepted as values. It should be changed to value.startsWith('-') to match the behavior in list-command.ts and prevent swallowing any flags.
| if (typeof value !== 'string' || !value.trim() || value.startsWith('--')) { | |
| if (typeof value !== 'string' || !value.trim() || value.startsWith('-')) { |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 981e71539f
ℹ️ 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".
| const url = new URL( | ||
| `/api/v1/workspaces/${encodeURIComponent(ctx.workspace)}` + | ||
| `/deployments/${encodeURIComponent(agent.agentId)}/trigger`, | ||
| ctx.cloudUrl |
There was a problem hiding this comment.
Preserve cloud base path when posting triggers
When ctx.cloudUrl is the canonical default https://agentrelay.com/cloud, using new URL() with a leading /api/... path discards the /cloud base path and posts to https://agentrelay.com/api/... instead of https://agentrelay.com/cloud/api/.... The preceding deployment lookup can succeed because it uses ctx.cloudUrl directly, but the actual trigger POST will hit the wrong host path for the default public cloud; construct the URL the same way as the other deployment endpoints or avoid the leading slash.
Useful? React with 👍 / 👎.
981e715 to
4409197
Compare
|
Addressed review feedback in 4409197:
Validation:
|
| }); | ||
| const agent = resolveAgentSelector(agents, opts.selector); | ||
| const url = buildTriggerUrl({ | ||
| cloudUrl: ctx.cloudUrl, | ||
| workspace: ctx.workspace, |
There was a problem hiding this comment.
🔴 Two-arg new URL() with absolute path drops the cloud base path, causing requests to wrong endpoint
The trigger command constructs its URL using new URL('/api/v1/...', ctx.cloudUrl). Because the path starts with /, the URL constructor treats it as an absolute path and replaces the entire pathname of the base URL. The default cloud URL resolved by resolveCloudUrl is https://agentrelay.com/cloud (see packages/deploy/src/cloud-url.ts:44,54), so the resulting URL becomes https://agentrelay.com/api/v1/workspaces/.../trigger instead of the correct https://agentrelay.com/cloud/api/v1/workspaces/.../trigger. Every other command in the codebase uses single-arg string concatenation to preserve the base path, e.g. new URL(\${cloudUrl}/api/v1/...`)atpackages/cli/src/list-command.ts:84andpackages/cli/src/list-command.ts:371`. This will cause trigger requests to 404 or hit the wrong endpoint in production.
| }); | |
| const agent = resolveAgentSelector(agents, opts.selector); | |
| const url = buildTriggerUrl({ | |
| cloudUrl: ctx.cloudUrl, | |
| workspace: ctx.workspace, | |
| const url = new URL( | |
| `${ctx.cloudUrl}/api/v1/workspaces/${encodeURIComponent(ctx.workspace)}` + | |
| `/deployments/${encodeURIComponent(agent.agentId)}/trigger` | |
| ); |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/cli.ts`:
- Around line 236-237: The CLI help text in the selector description (around
lines 236-237) lists the accepted selector types but omits compact agent ids,
even though the runtime selector resolution supports them. Update the help text
string that begins with "The selector accepts" to include "compact agent id"
along with the currently mentioned agent id, deployed name, persona slug, and
persona id options, ensuring the help output matches the actual supported
selector types at runtime.
In `@packages/cli/src/trigger-command.ts`:
- Around line 140-143: The URL path constructed in trigger-command.ts uses the
`/deployments/{id}/trigger` endpoint, but the usage text on Line 11 and the
README document the `trigger-now` contract. Update the path string being built
(where encodeURIComponent(agent.agentId) and the endpoint name are specified) to
use the `trigger-now` endpoint instead of `trigger` to align the code
implementation with the documented API contract and prevent 404 errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 98fd8f24-d58c-4d02-8d95-d7dbec034dfe
📒 Files selected for processing (4)
packages/cli/README.mdpackages/cli/src/cli.tspackages/cli/src/trigger-command.test.tspackages/cli/src/trigger-command.ts
| const url = new URL( | ||
| `/api/v1/workspaces/${encodeURIComponent(ctx.workspace)}` + | ||
| `/deployments/${encodeURIComponent(agent.agentId)}/trigger`, | ||
| ctx.cloudUrl |
There was a problem hiding this comment.
Align the trigger route with the documented trigger-now contract.
Line 141 builds /deployments/{id}/trigger, but this file’s usage text (Line 11) and README describe the cloud trigger-now path. Please make the code path and docs consistent; otherwise this can become a real API contract break (e.g., 404 on trigger).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/cli/src/trigger-command.ts` around lines 140 - 143, The URL path
constructed in trigger-command.ts uses the `/deployments/{id}/trigger` endpoint,
but the usage text on Line 11 and the README document the `trigger-now`
contract. Update the path string being built (where
encodeURIComponent(agent.agentId) and the endpoint name are specified) to use
the `trigger-now` endpoint instead of `trigger` to align the code implementation
with the documented API contract and prevent 404 errors.
4409197 to
c4a4fa4
Compare
|
Addressed the latest feedback in c4a4fa4:
Validation:
|
Summary
agentworkforce trigger <agent-name-or-id>for manually firing active deployed personas through the cloud trigger-now endpointagentworkforce deployments trigger <agent-name-or-id>as an alias near the existing deployment commandsValidation
pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json --noEmitpnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json && node --test packages/cli/dist/trigger-command.test.jspnpm --filter @agentworkforce/cli testcurrently fails in pre-existing unrelatedlocal-personas.test.jslocal skill/sidecar resolution cases; the new trigger tests pass in that run.