Skip to content

refactor(discord): move Computer's brain onto the Zo host - #94

Merged
EthanThatOneKid merged 1 commit into
mainfrom
refactor/zo-brain
Sep 26, 2026
Merged

EthanThatOneKid merged 1 commit into
mainfrom
refactor/zo-brain

Conversation

@EthanThatOneKid

@EthanThatOneKid EthanThatOneKid commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Computer's Discord turn ran in the Vercel deployment: a bridge on the host forwarded each admitted mention to POST /eve/v1/discord-mentions and the deployment ran the model call. That kept the model credential in the deployment, so one revoked provider key took the surface down, and it made every reply depend on a Vercel function.

This moves the brain to the Zo host. channels/discord/index.ts is now the whole runtime: it holds the Gateway socket, admits a mention with the same tested policy modules, runs the turn on the Computer Zo persona over /zo/ask, and posts the answer back into the originating channel or thread. The persona owns the prompt and the model, so no model credential lives in this repository or on Vercel.

What is retired

  • bridge/discord-gateway/index.ts and agent/channels/discord-mentions.ts, the two halves of the forward path.
  • The bridge HMAC and its header constants in lib/discord-bridge.ts, plus DISCORD_BRIDGE_SECRET: nothing signs or verifies a forward any more.
  • bridge/** drops out of the deploy path filter; channels/** replaces it. The service label becomes computer-discord, matching goop-discord and data-discord.

lib/host-secrets.ts now takes the names to fill and includes ZO_CLIENT_IDENTITY_TOKEN, which is the credential /zo/ask is called with.

The reconnect defect

Issue #92 filed a bridge that held two Gateway sessions and reconnected every minute: scheduleReconnect called socket.close(), whose own close listener called scheduleReconnect again. The replacement is single by construction: one socket per attempt, a pending-reconnect timer guard, and a stale socket's close ignored. A forced close in the end-to-end harness shows exactly one replacement socket.

Verification

  • pnpm run typecheck clean; pnpm test 165/165 (three fixtures updated for the retired secret and the new ready line).
  • build:eve succeeds on Node 24, so the authored app still compiles without the deleted channel.
  • End-to-end against stub Zo, stub Discord REST, and a stub Gateway: one admitted mention produces one /zo/ask call carrying the persona id, the reply is posted into the originating channel, a second mention continues the same conversation, and a non-allowlisted author and a bot-authored message are dropped.

Not in this PR: the web surface. Vercel still runs the eve agent for web chat and the GitHub path, so AI_GATEWAY_API_KEY and the Blob-backed factory remain. That cut is the next one.

Closes #92.

Computer's model call, session continuity, and answers ran in the Vercel
deployment, reached by a signed forward from a host bridge. That put the model
credential in the deployment (one revoked provider key took the Discord surface
down) and kept replies depending on a Vercel function.

The channel is now the runtime: channels/discord/index.ts holds the Gateway
socket, admits a mention with the same tested policy modules, runs the turn on
the Computer Zo persona over /zo/ask, and posts the reply. The persona owns the
prompt and the model, so no model credential lives in the repository.

Retires the forward path it replaces: bridge/discord-gateway/,
agent/channels/discord-mentions.ts, the bridge HMAC and its header constants in
lib/discord-bridge.ts, and DISCORD_BRIDGE_SECRET. lib/host-secrets.ts now takes
the names to fill and includes ZO_CLIENT_IDENTITY_TOKEN.

The reconnect path is single by construction, which is the defect #92 filed
against the bridge it replaces: one socket per attempt, a pending-reconnect
guard, and a stale socket's close ignored.

Verified: typecheck clean, 165/165 tests pass, eve build succeeds on Node 24,
and an end-to-end harness against stub Zo, stub Discord REST, and a stub Gateway
shows one admitted mention producing one /zo/ask call carrying the persona id,
the reply posted into the originating channel, a second mention continuing the
same conversation, a non-allowlisted author and a bot message dropped, and
exactly one socket after a forced reconnect.
@vercel

vercel Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
computer Ready Ready Preview Sep 26, 2026 7:31am UTC

@wazoocomputer

wazoocomputer Bot commented Sep 26, 2026

Copy link
Copy Markdown

This pull request refactors the Discord integration by moving Computer's brain, which is a Zo persona, from the Vercel deployment to the Zo host. This change aims to improve reliability and security by centralizing the model and prompt on the Zo host and removing model credentials from this repository and Vercel.

File Path Change Type Summary of Change
.github/ARCHITECTURE.md modified Updated architecture documentation to reflect the new Discord channel
.github/workflows/deploy.yml modified Modified deployment workflow for the Discord channel
.gitignore modified Added channels/discord/data to gitignore
AGENTS.md modified Updated agent documentation regarding Computer's brain location and Discord channel operation
README.md modified Updated README with new Discord channel setup and explanation of where the brain lives
agent/channels/discord-mentions.ts removed Removed the old Discord mentions agent
bridge/discord-gateway/index.ts removed Removed the old Discord gateway bridge
channels/discord/README.md added Added README for the new Discord channel
channels/discord/index.ts added Added the new Discord channel implementation
lib/discord-bridge.test.ts modified Removed DISCORD_BRIDGE_SECRET from test context
lib/discord-bridge.ts modified Removed DISCORD_BRIDGE_SECRET related code
lib/discord-policy.ts modified No functional changes, minor whitespace change
lib/host-secrets.test.ts modified Updated host secrets test to reflect ZO_CLIENT_IDENTITY_TOKEN
lib/host-secrets.ts modified Added ZO_CLIENT_IDENTITY_TOKEN to host secrets
lib/zo-deploy-cli.test.ts modified Updated Zo deploy CLI test
lib/zo-deploy.test.ts modified Updated Zo deploy test
package.json modified Updated discord:channel script and removed discord:bridge script
scripts/zo-deploy.ts modified Updated zo-deploy script to reference new service label

Reviewers should begin by examining channels/discord/index.ts to understand the new Discord channel implementation.

1 similar comment
@wazoocomputer

wazoocomputer Bot commented Sep 26, 2026

Copy link
Copy Markdown

This pull request refactors the Discord integration by moving Computer's brain, which is a Zo persona, from the Vercel deployment to the Zo host. This change aims to improve reliability and security by centralizing the model and prompt on the Zo host and removing model credentials from this repository and Vercel.

File Path Change Type Summary of Change
.github/ARCHITECTURE.md modified Updated architecture documentation to reflect the new Discord channel
.github/workflows/deploy.yml modified Modified deployment workflow for the Discord channel
.gitignore modified Added channels/discord/data to gitignore
AGENTS.md modified Updated agent documentation regarding Computer's brain location and Discord channel operation
README.md modified Updated README with new Discord channel setup and explanation of where the brain lives
agent/channels/discord-mentions.ts removed Removed the old Discord mentions agent
bridge/discord-gateway/index.ts removed Removed the old Discord gateway bridge
channels/discord/README.md added Added README for the new Discord channel
channels/discord/index.ts added Added the new Discord channel implementation
lib/discord-bridge.test.ts modified Removed DISCORD_BRIDGE_SECRET from test context
lib/discord-bridge.ts modified Removed DISCORD_BRIDGE_SECRET related code
lib/discord-policy.ts modified No functional changes, minor whitespace change
lib/host-secrets.test.ts modified Updated host secrets test to reflect ZO_CLIENT_IDENTITY_TOKEN
lib/host-secrets.ts modified Added ZO_CLIENT_IDENTITY_TOKEN to host secrets
lib/zo-deploy-cli.test.ts modified Updated Zo deploy CLI test
lib/zo-deploy.test.ts modified Updated Zo deploy test
package.json modified Updated discord:channel script and removed discord:bridge script
scripts/zo-deploy.ts modified Updated zo-deploy script to reference new service label

Reviewers should begin by examining channels/discord/index.ts to understand the new Discord channel implementation.

This branch was successfully deployed

1 active deployment
Preview — fc651a30 Deployed Sep 26, 2026 by vercel[bot]
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.

fix: the Discord bridge holds two gateway sessions and reconnects every 60 seconds

1 participant