Skip to content

Grok Bot computer-gateway backend + authenticated /internal/reply callback - #1

Merged
FlyOverCoderKY merged 2 commits into
mainfrom
cursor/grok-bot-callback-bridge-c697
Aug 14, 2026
Merged

FlyOverCoderKY merged 2 commits into
mainfrom
cursor/grok-bot-callback-bridge-c697

Conversation

@FlyOverCoderKY

@FlyOverCoderKY FlyOverCoderKY commented Aug 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Phase 1 production path stays OpenAICompatibleBackend (AGENT_BACKEND=openai).

This adds the interim unofficial Grok Bot path:

  • In-process HTTP server (BRIDGE_HTTP_HOST/BRIDGE_HTTP_PORT, default 0.0.0.0:8788) with authenticated POST /internal/reply (Authorization: Bearer <BRIDGE_REPLY_TOKEN>, fail-closed).
  • GrokBotBackend POSTs { agentId, prompt } to GROK_BOT_GATEWAY_URL/api/sendPrompt, embeds correlationId + replyUrl + bearer instructions plus Discord context, then waits for the matching callback (or GROK_BOT_TIMEOUT_MS).
  • On callback, the bridge posts text to the Discord channel/thread (same ~1900 split) and resolves generate().
  • If Discord delivery fails, the pending entry is kept and the callback returns 503 so the agent can retry. The waiter is removed only after a successful send (or timeout / explicit fail).
  • Docker Compose publishes ${BRIDGE_HTTP_PORT:-8788}:${BRIDGE_HTTP_PORT:-8788} and keeps .env, ./SOUL.md, and ./examples mounts.

BRIDGE_PUBLIC_URL must be reachable from the Grok Bot computer (Tailscale / SSH tunnel / similar). Do not expose Grok Bot :1340 to the internet. Treat GROK_BOT_TOKEN and BRIDGE_REPLY_TOKEN like passwords; they are not logged.

This is unofficial and may break. See docs/PHASE2-GROK-BOT-BACKEND.md.

Test plan

  • Reply endpoint: missing / wrong / unset token → 401
  • Unknown or expired correlationId → 404
  • Missing body fields → 400
  • Happy path: register pending → POST /internal/reply → generate() resolves with text
  • Timeout path fails generate() with a short Discord-friendly error
  • Mocked sendPrompt payload includes correlationId + replyUrl + Discord context
  • grok-bot config fails closed when required env is missing; openai defaults unchanged
  • Delivery failure keeps the pending entry, returns HTTP 503 (not 200), and a later retry can complete
  • npm test and npm run build pass
  • Existing access-control tests still pass (not weakened)
Open in Web Open in Cursor 

… callback.

Add an in-process POST /internal/reply server so a Grok Bot agent can return
text after sendPrompt wakes it asynchronously. grok-bot mode fails closed on
missing env; openai remains the default path.

Co-authored-by: Fly Over Coder <FlyOverCoder@gmail.com>
@FlyOverCoderKY
FlyOverCoderKY marked this pull request as ready for review August 14, 2026 17:57

@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: 0609b7b97c

ℹ️ 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 src/http/pendingReplies.ts Resolved
Comment thread docker-compose.yml Resolved
complete() no longer drops the waiter before sendSplitReply finishes. A
delivery failure returns HTTP 503 and leaves the correlationId retryable.
Compose now maps host and container ports from BRIDGE_HTTP_PORT.

Co-authored-by: Fly Over Coder <FlyOverCoder@gmail.com>
@FlyOverCoderKY
FlyOverCoderKY merged commit ed6b5f9 into main Aug 14, 2026
1 check passed
@FlyOverCoderKY
FlyOverCoderKY deleted the cursor/grok-bot-callback-bridge-c697 branch August 30, 2026 00:26
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.

2 participants