mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Switch the @opencode-manager/workspace-plugin adaptor from type local to type remote so opencode TUIs running on machines without filesystem access can use the manager's managed opencode server as their workspace backend. Phase 1 - Plugin adaptor: - Update target() to return type remote with manager URL and bearer auth - Export makeAdaptor for testing - Add tests for remote URL construction, slug encoding, and trailing slash Phase 2 - HTTP proxy route: - Add ALL /opencode/:slug/* catch-all proxy in workspace-plugin routes - Reuses existing proxyRequest helper with slug-to-directory translation - Rewrites inbound URL to /api/opencode/* shape for shared proxy logic - Includes bearer token scope validation and project service Phase 3 - WebSocket proxy: - Extract verifyPluginBearerAuth as named function for reuse - Attach second WebSocket proxy mount for /api/workspace-plugin/opencode prefix - Both /api/opencode and /api/workspace-plugin/opencode prefixes supported Phase 4 - Tests: - Add 8 backend route tests covering auth, proxy forwarding, and POST body - Add 3 plugin adaptor tests for remote target construction
@opencode-manager/workspace-plugin
Connect your local OpenCode TUI to a running opencode-manager instance and use its projects as remote workspaces.
Installation
Add the plugin to your opencode.json configuration:
{
"plugin": [
["@opencode-manager/workspace-plugin", {
"url": "https://manager.example.com",
"token": "<bearer token from manager settings>"
}]
]
}
Configuration
Options
url(required): The base URL of your opencode-manager instancetoken(required): Bearer token created from the manager's Settings page
Environment Variables
As an alternative to configuring in opencode.json, you can use:
OPENCODE_MANAGER_URL: The base URL of your opencode-manager instanceOPENCODE_MANAGER_TOKEN: Bearer token for authentication
Usage
Once configured, the plugin will automatically discover all projects in your opencode-manager instance and register them as remote workspaces. Each project will appear in the OpenCode TUI workspace picker as manager:<slug>.
Creating a Bearer Token
- Open your opencode-manager web UI
- Navigate to Settings → API Tokens
- Click "Create Token"
- Give it a name (e.g., "OpenCode TUI")
- Copy the token immediately (it won't be shown again)
- Paste it into your
opencode.jsonor setOPENCODE_MANAGER_TOKEN
Token Scope
Tokens created for the workspace plugin have the workspace-plugin scope by default. This restricts their access to only the workspace plugin endpoints.
How It Works
- On startup, the plugin calls
GET /api/workspace-plugin/projectson the manager - For each project returned, it registers a
WorkspaceAdaptorwith typemanager:<slug> - When you select a workspace in the TUI, the adaptor provides:
- Remote target URL:
<manager>/api/opencode - Authorization header:
Bearer <token> - Project slug header:
x-opencode-manager-project: <slug>
- Remote target URL:
The manager then proxies requests to the embedded OpenCode server with the appropriate ?directory= parameter.
Security Notes
- Bearer tokens are stored hashed (SHA-256) in the manager database
- Tokens are shown only once on creation
- Tokens can be revoked at any time from the Settings page
- Tokens bypass CORS origin requirements (explicit opt-in authentication)