Skip to content

feat(cloud-agent-next): discover and send remote slash commands#4519

Draft
eshurakov wants to merge 1 commit into
mainfrom
impossible-peanut
Draft

feat(cloud-agent-next): discover and send remote slash commands#4519
eshurakov wants to merge 1 commit into
mainfrom
impossible-peanut

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

Adds end-to-end remote slash command support so Cloud Agent sessions
running against a live CLI wrapper can discover the wrapper's command
catalog and submit structured /command messages instead of only free
text. This mirrors the existing list_models discovery flow but for
the list_commands relay command.

  • CLI live transport (cli-live-transport.ts): discovers commands
    via list_commands, parses with the new
    remoteCommandCatalogV1Schema, and publishes commands.available
    events. Adds per-owner in-flight dedupe and generation guards so a
    catalog from a replaced/stale owner is ignored, the catalog is
    retained across transient refresh failures, and is cleared on owner
    disconnect, malformed payloads, or oversized responses. Legacy CLIs
    that reject list_commands get an empty catalog. send now forwards
    command payloads to send_command with protocolVersion,
    command, arguments, optional messageID, and model/variant.
  • Schema (schemas.ts): new remoteCommandCatalogV1Schema with
    bounds (max 256 commands, 2 KB strings, 32 hints, 512 KB serialized)
    and a transform that drops source: 'skill' commands from the relay
    catalog.
  • Session manager (session-manager.ts): ignores commands.available
    emitted by a previous session after a switch, via the existing switch
    generation guard.
  • Web hook (useSlashCommandSets.ts + new
    slash-command-selection.ts): replaces the unconditional pinned-default
    fallback with session-type-aware selection — Cloud Agent sessions still
    fall back to the pinned default catalog when the wrapper list is empty,
    remote sessions use only the exact CLI catalog, and read-only/unresolved
    sessions expose nothing.
  • Mobile composer (chat-composer.tsx + new
    chat-composer-slash-commands.ts, slash-command-suggestions.tsx):
    surfaces autocomplete suggestions while typing /, inserts the selected
    command into the input, and routes structured command submissions
    through a new onSendCommand prop. session-detail-content.tsx wires
    this to manager.send({ payload: { type: 'command', ... } }).
  • Relay DO (UserConnectionDO.ts): treats list_commands the same
    as list_models for pending-request dedupe (CATALOG_REQUEST_PENDING)
    and the 512 KiB response size cap (CATALOG_TOO_LARGE), via a shared
    isCatalogCommand helper.

Architecturally, the command discovery path reuses the model discovery
pattern (owner-scoped in-flight tracking + generation invalidation) rather
than introducing a new coordination mechanism. The mobile composer splits
slash-command parsing into a pure helper (chat-composer-slash-commands.ts)
so the composer component stays focused on rendering.

Verification

No manual verification was performed in this session — the work consisted
of committing and pushing the implementation; no local runtime or in-app
testing was done.

  • [ ]

Visual Changes

Before After
Mobile composer had no slash command autocomplete Mobile composer shows /command suggestions above the input and inserts the selected command
(add before screenshot) (add after screenshot)

Reviewer Notes

  • Companion PR (CLI side): Cli - Support remote slash command discovery and execution kilocode#12169
    implements list_commands/send_command handling in the CLI wrapper.
    This PR is the cloud-side counterpart and should be reviewed together
    with it.
  • The discoverCommands flow closely mirrors discoverModels; the risk
    area is the generation/owner guards ensuring a stale or in-flight
    catalog doesn't leak across owner changes or reconnects — covered by
    the new transport tests (replaced owner, in-flight dedupe, transient
    failure retention, malformed/oversized clearing).
  • remoteCommandCatalogV1Schema silently filters source: 'skill'
    commands; confirm that's the intended policy for the relay catalog.
  • Mobile onSendCommand is a new required prop on ChatComposer;
    verify all call sites pass it.

Add end-to-end remote slash command support across the CLI live
transport, web composer, and mobile chat composer.

- CLI live transport discovers commands via `list_commands` and
  publishes `commands.available` events, with per-owner in-flight
  dedupe, owner-change staleness guards, and catalog size validation.
- Web session manager ignores stale command catalogs from replaced
  sessions; `useSlashCommandSets` selects commands by session type
  instead of always falling back to the pinned default catalog.
- Mobile chat composer surfaces slash command suggestions and routes
  structured command submissions through the session manager.
- UserConnectionDO treats `list_commands` like `list_models` for
  pending-request dedupe and 512 KiB response size enforcement.
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