feat(cloud-agent-next): discover and send remote slash commands#4519
Draft
eshurakov wants to merge 1 commit into
Draft
feat(cloud-agent-next): discover and send remote slash commands#4519eshurakov wants to merge 1 commit into
eshurakov wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
/commandmessages instead of only freetext. This mirrors the existing
list_modelsdiscovery flow but forthe
list_commandsrelay command.cli-live-transport.ts): discovers commandsvia
list_commands, parses with the newremoteCommandCatalogV1Schema, and publishescommands.availableevents. 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_commandsget an empty catalog.sendnow forwardscommandpayloads tosend_commandwithprotocolVersion,command,arguments, optionalmessageID, and model/variant.schemas.ts): newremoteCommandCatalogV1Schemawithbounds (max 256 commands, 2 KB strings, 32 hints, 512 KB serialized)
and a transform that drops
source: 'skill'commands from the relaycatalog.
session-manager.ts): ignorescommands.availableemitted by a previous session after a switch, via the existing switch
generation guard.
useSlashCommandSets.ts+ newslash-command-selection.ts): replaces the unconditional pinned-defaultfallback 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.
chat-composer.tsx+ newchat-composer-slash-commands.ts,slash-command-suggestions.tsx):surfaces autocomplete suggestions while typing
/, inserts the selectedcommand into the input, and routes structured command submissions
through a new
onSendCommandprop.session-detail-content.tsxwiresthis to
manager.send({ payload: { type: 'command', ... } }).UserConnectionDO.ts): treatslist_commandsthe sameas
list_modelsfor pending-request dedupe (CATALOG_REQUEST_PENDING)and the 512 KiB response size cap (
CATALOG_TOO_LARGE), via a sharedisCatalogCommandhelper.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
/commandsuggestions above the input and inserts the selected commandReviewer Notes
implements
list_commands/send_commandhandling in the CLI wrapper.This PR is the cloud-side counterpart and should be reviewed together
with it.
discoverCommandsflow closely mirrorsdiscoverModels; the riskarea 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).
remoteCommandCatalogV1Schemasilently filterssource: 'skill'commands; confirm that's the intended policy for the relay catalog.
onSendCommandis a new required prop onChatComposer;verify all call sites pass it.