Skip to content

Calls that return the server's answer (GRYT-2005, 1/2) - #18

Merged
grytchat merged 1 commit into
mainfrom
claude/GRYT-2005-sdk
Nov 3, 2026
Merged

grytchat merged 1 commit into
mainfrom
claude/GRYT-2005-sdk

Conversation

@grytchat

@grytchat grytchat commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

First layer of the Gryt MCP stack (GRYT-2005). The second layer, #19, adds the gryt-mcp command on top of these calls.

Before this, a bot could send and listen, but it couldn't ask for something and get the answer back. fetch emitted chat:fetch and said the answer comes on the message event, but nothing listens for chat:history, so it never answered.

New calls, each emitting and then waiting for the matching reply, with a 10 second timeout:

  • history(conversationId, { limit, before }): a page of a channel, plus the threads on it
  • thread(conversationId, threadId, …): a thread's root and replies
  • search({ query, conversationId, senderServerUserId, before, after })
  • startThread(conversationId, rootMessageId, title?)
  • diagnostics(): needs view_diagnostics, from server#358

send now resolves with the message it posted, matched by nonce, and takes replyTo and threadId. bot.members and bot.channels keep the last lists the server sent, and Message carries threadId.

Look at

  • request() in client.ts. An error event rejects whatever is waiting on it, because the server doesn't say which call a chat:error answers. Two calls at once on the same bot can steal each other's refusal. The MCP makes one call at a time.
  • send used to return as soon as it emitted. It now waits for the echo, so a bot that awaited send in a loop is slower by one round trip per message.
  • I left fetch as it was, since removing it would break the public API.

Tested with yarn test, and end to end against a local server from the server branch: every call, through the MCP in #19.

🤖 Generated with Claude Code

history, thread, search, startThread and diagnostics each emit and wait
for the matching reply, with a 10 second timeout. send resolves with the
posted message by matching its nonce, and can reply or post into a
thread. members and channels keep the last lists the server sent.

fetch is left as it was. It never had a chat:history listener, so it has
never answered anything; history is the working version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@grytchat
grytchat added this pull request to stack #20 November 3, 2026 10:38
@grytchat grytchat changed the title Calls that return the server's answer, for the MCP (GRYT-2005) Calls that return the server's answer (GRYT-2005, 1/2) Nov 3, 2026
@grytchat
grytchat marked this pull request as ready for review November 3, 2026 10:39
@grytchat
grytchat merged commit ba391fc into main Nov 3, 2026
8 of 9 checks passed
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