Skip to content

[FEATURE]: @opencode-ai/slack — support connecting to an existing remote OpenCode server #20075

Description

@xuezhaojun
  • I have verified this feature I'm about to request hasn't been suggested before.

@opencode-ai/slack currently always spawns a local OpenCode server via createOpencode(). It should support connecting to an existing remote server when an environment variable (e.g. OPENCODE_SERVER_URL) is set.

Problem

The Slack bot in packages/slack/src/index.ts hardcodes server creation:

const opencode = await createOpencode({ port: 0 })

This means the Slack bot and the OpenCode server must run in the same process/container. There's no way to point the bot at a server running elsewhere.

Use case

In Kubernetes environments, OpenCode runs as a persistent server (via opencode serve) inside a cluster. The Slack bot needs to run as a separate Deployment that connects to this existing server over the internal network. The current architecture makes this impossible without forking the package.

This is the same pattern already discussed in:

The SDK already exposes createOpencodeClient({ baseUrl }) for exactly this purpose — the Slack bot just doesn't use it.

Proposed change

let client: OpencodeClient
let server: { url: string; close(): void } | undefined

if (process.env.OPENCODE_SERVER_URL) {
  client = createOpencodeClient({ baseUrl: process.env.OPENCODE_SERVER_URL })
} else {
  const opencode = await createOpencode({ port: 0 })
  client = opencode.client
  server = opencode.server
}

Optionally also support OPENCODE_SERVER_PASSWORD / OPENCODE_SERVER_USERNAME for authenticated servers (consistent with existing opencode attach auth).

No breaking changes — default behavior is preserved when the env var is not set.

Why this matters

The Slack bot is one of the simplest and most compelling integrations in the OpenCode ecosystem. Letting it connect to a remote server unlocks:

  • Kubernetes-native deployment — separate bot pod from server pod, each scaling independently
  • Shared context — multiple Slack threads can share the same server's loaded repos/context
  • Enterprise deployment — server behind VPN, bot exposed to Slack via Socket Mode (no public URL needed)
  • Multi-interface — same server serves the web UI, CLI (opencode attach), and Slack bot simultaneously

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions