Skip to content

feat(cli): add deployed persona trigger command#247

Merged
khaliqgant merged 1 commit into
mainfrom
feat/cli-trigger-deployed-persona
Jun 21, 2026
Merged

feat(cli): add deployed persona trigger command#247
khaliqgant merged 1 commit into
mainfrom
feat/cli-trigger-deployed-persona

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jun 21, 2026

Copy link
Copy Markdown
Member

Summary

  • add agentworkforce trigger <agent-name-or-id> for manually firing active deployed personas through the cloud trigger-now endpoint
  • add agentworkforce deployments trigger <agent-name-or-id> as an alias near the existing deployment commands
  • document the command and add parser/response formatting tests

Validation

  • pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json --noEmit
  • pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json && node --test packages/cli/dist/trigger-command.test.js
  • pnpm --filter @agentworkforce/cli test currently fails in pre-existing unrelated local-personas.test.js local skill/sidecar resolution cases; the new trigger tests pass in that run.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b95b6995-29c0-42e2-a507-02400b495fee

📥 Commits

Reviewing files that changed from the base of the PR and between 981e715 and c4a4fa4.

📒 Files selected for processing (4)
  • packages/cli/README.md
  • packages/cli/src/cli.ts
  • packages/cli/src/trigger-command.test.ts
  • packages/cli/src/trigger-command.ts
📝 Walkthrough

Walkthrough

A new trigger subcommand is added to the CLI, implemented in a standalone trigger-command.ts module. The module defines types, argument parsing, response validation, an HTTP POST to the cloud trigger-now endpoint, formatted output helpers, and a runTrigger entrypoint. The subcommand is wired into cli.ts both as a top-level command and as a deployments trigger alias. Documentation is added to README.md and the CLI usage string.

Changes

CLI trigger subcommand

Layer / File(s) Summary
Data contracts, types, and usage string
packages/cli/src/trigger-command.ts
Defines TRIGGER_USAGE help text, TriggerOptions, ParsedTriggerArgs, TriggerResponse, TriggerIO interface, and the default IO implementation wired to process.stdout/stderr.
Argument parsing, response validation, and formatting
packages/cli/src/trigger-command.ts, packages/cli/src/trigger-command.test.ts
Implements parseTriggerArgs (positional/flag scanning, --flag=value and --flag value forms, unknown-flag rejection), parseTriggerResponse (runtime object/field validation with readString), expectValue/expectInlineValue guards, formatTriggerResult, and tests for all three public helpers.
triggerDeployment and runTrigger entrypoint
packages/cli/src/trigger-command.ts
runTrigger parses args, handles --help, calls triggerDeployment, and writes JSON or formatted text while setting process.exitCode. triggerDeployment resolves deployment context, selects the target agent, POSTs to the cloud trigger-now URL with a Bearer token, handles 401 with a login-retry message, and validates the JSON response into TriggerResponse.
CLI wiring and documentation
packages/cli/src/cli.ts, packages/cli/README.md
Imports runTrigger, adds trigger to USAGE help text, adds the subcommand === 'trigger' dispatch branch in main(), extends the deployments action dispatcher with a trigger case, and documents the subcommand in README.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop, hop — the trigger's set!
A POST flies off through cloud and net,
The agent wakes from slumber deep,
No dashboard click — just CLI beep.
Bearer tokens, selectors too,
This rabbit coded it for you! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(cli): add deployed persona trigger command' directly and concisely summarizes the main change—adding a new CLI command for triggering deployed personas.
Description check ✅ Passed The description provides a clear summary of the changes, explaining what the command does, its variants, and the validation performed, all directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-trigger-deployed-persona

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread packages/cli/src/trigger-command.ts Outdated
Comment on lines +76 to +80
} else if (!selector) {
selector = arg;
} else {
throw new Error(`trigger: unexpected positional argument "${arg}"`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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}\"\`);
    }

Comment thread packages/cli/src/trigger-command.ts Outdated
}

function expectValue(flag: string, value: string | undefined): string {
if (typeof value !== 'string' || !value.trim() || value.startsWith('--')) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
if (typeof value !== 'string' || !value.trim() || value.startsWith('--')) {
if (typeof value !== 'string' || !value.trim() || value.startsWith('-')) {

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

Copy link
Copy Markdown

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: 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".

Comment thread packages/cli/src/trigger-command.ts Outdated
Comment on lines +140 to +143
const url = new URL(
`/api/v1/workspaces/${encodeURIComponent(ctx.workspace)}` +
`/deployments/${encodeURIComponent(agent.agentId)}/trigger`,
ctx.cloudUrl

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 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 👍 / 👎.

@khaliqgant khaliqgant force-pushed the feat/cli-trigger-deployed-persona branch from 981e715 to 4409197 Compare June 21, 2026 11:38
@khaliqgant

Copy link
Copy Markdown
Member Author

Addressed review feedback in 4409197:

  • single-dash unknown flags like -x are now rejected instead of being treated as selectors
  • option values now reject any dash-prefixed token, so --workspace -x / --cloud-url -x cannot swallow flags
  • trigger POST URL construction now preserves base paths like https://agentrelay.com/cloud
  • added focused regression tests for all three cases

Validation:

  • pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json --noEmit
  • pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json && node --test packages/cli/dist/trigger-command.test.js

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

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.

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +140 to +144
});
const agent = resolveAgentSelector(agents, opts.selector);
const url = buildTriggerUrl({
cloudUrl: ctx.cloudUrl,
workspace: ctx.workspace,

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.

🔴 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.

Suggested change
});
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`
);
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between eea7446 and 981e715.

📒 Files selected for processing (4)
  • packages/cli/README.md
  • packages/cli/src/cli.ts
  • packages/cli/src/trigger-command.test.ts
  • packages/cli/src/trigger-command.ts

Comment thread packages/cli/src/cli.ts Outdated
Comment thread packages/cli/src/trigger-command.ts Outdated
Comment on lines +140 to +143
const url = new URL(
`/api/v1/workspaces/${encodeURIComponent(ctx.workspace)}` +
`/deployments/${encodeURIComponent(agent.agentId)}/trigger`,
ctx.cloudUrl

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

@khaliqgant khaliqgant force-pushed the feat/cli-trigger-deployed-persona branch from 4409197 to c4a4fa4 Compare June 21, 2026 11:46
@khaliqgant

Copy link
Copy Markdown
Member Author

Addressed the latest feedback in c4a4fa4:

  • top-level CLI help now mentions compact agent id selector support
  • docs/help/test wording now says cloud trigger endpoint instead of implying a literal trigger-now route
  • kept the implementation on /deployments/:agentId/trigger because that is the actual cloud route; verified the adjacent trigger-now route does not exist in the cloud checkout

Validation:

  • pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json --noEmit
  • pnpm --filter @agentworkforce/cli exec tsc -p tsconfig.json && node --test packages/cli/dist/trigger-command.test.js

@khaliqgant khaliqgant merged commit a67df72 into main Jun 21, 2026
1 check passed
@khaliqgant khaliqgant deleted the feat/cli-trigger-deployed-persona branch June 21, 2026 11:47
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