@darrenloasby/clawdbridge
v0.1.1
Published
🦀ClawdBridge bridge helpers for OpenAI-compatible Claude routing with brokered session state.
Maintainers
Readme
ClawdBridge
Private OpenCode bridge helpers for an OpenAI-compatible Claude endpoint.
This package is intentionally tiny:
- wraps an OpenAI-compatible transport
- carries
project_id/session_idbetween calls - persists bridge context in a local JSON state file
- keys state per
baseURLand optionalworkspaceId - preserves OpenAI-style
tool_callshandoff - exposes an OpenCode-style
modifyUrl/modifyHeaders/modifyBodyhelper
Install
npm install @darrenloasby/clawdbridgeUse
import createChatBridgeProvider from "@darrenloasby/clawdbridge";
const provider = createChatBridgeProvider({
baseURL: "http://127.0.0.1:8888/v1",
apiKey: process.env.OPENAI_API_KEY,
workspaceId: "my-project",
});
const body = provider.request({
model: "claude-chat-haiku",
messages: [{ role: "user", content: "hello" }],
});OpenCode-style helper
import { createOaCompatBridgeHelper } from "@darrenloasby/clawdbridge";
const helper = createOaCompatBridgeHelper({
baseURL: "http://127.0.0.1:8888/v1",
});
helper.modifyUrl("http://127.0.0.1:8888/v1");
helper.modifyBody({
model: "claude-chat-haiku",
messages: [{ role: "user", content: "hello" }],
});UI status
If the host app wants to show the current binding, use:
import { describeBridgeState } from "@darrenloasby/clawdbridge";
const status = describeBridgeState(
"http://127.0.0.1:8888/v1",
{ projectId: "proj-123", sessionId: "sess-456" },
"my-project",
);That returns a small label like:
workspace my-project · project proj-123 · session sess-456What it stores
The default state file is:
~/.local/share/opencode-chatbridge/state.jsonIt stores one entry per baseURL.
Notes
tool_callsare preserved as OpenAI-compatible function calls.project_idandsession_idare added when available.- This package is a bridge helper, not a full model provider by itself.
