外观主题
阅读语言

BITSDK —— 多语言客户端 SDK(Java/JS/Go/Rust/C/C#/Lua)

软件 本站软件 3天前 更新于 20小时前
https://yxp.hk/p/gaSZ64

📦 开源仓库:yxpil/BITSDK

gh-card · yxpil/BITSDK

📦 仓库名片 · Powered by gh-card


BITSDK — Call BIT from any language

Official client SDKs for BIT (本地优先的 AI Agent 工具集).
Drive your local BIT from Java, JavaScript/Node, Go, Rust, C, C# and Lua:
chat with the agent, register/remote-call tools, read audit and debug state,
or use BIT as an OpenAI-compatible endpoint and MCP server.

Language Directory Transport Streaming Package
JavaScript / Node 18+ javascript/ fetch (zero-dep) SSE, async-friendly bit-sdk-js
Go 1.22+ go/ net/http (std-only) SSE callback github.com/yxpil/BITSDK/go
Rust rust/ ureq (sync) SSE iterator/callback bit-sdk
Java 17+ java/ java.net.http (zero-dep) SSE callback copy the 3 source files
C c/ libcurl + bundled cJSON SSE callback make in c/
C# csharp/ HttpClient (zero-dep) SSE (IAsyncEnumerable) single file BitSdk.cs
Lua lua/ curl subprocess (zero-dep) line streaming single file bitsdk.lua

Full HTTP contract (endpoints, auth rules, error bodies, SSE format):
docs/API.md. Every SDK implements it and ships a smoke test
against the same fake BIT server (test/fake_bit_server.js).

What BIT exposes

  • POST /api/chat — one full agent turn (tools/MCP executed internally), returns the reply.
  • /api/tools — list / register / remove / invoke tools. Remote tools: BIT POSTs tool calls to your webhook.
  • /api/audit, /api/debug/* — audit log and read-only runtime snapshots (sessions, providers, MCP).
  • /v1/chat/completions, /v1/models — OpenAI-compatible endpoint (streaming supported).
  • POST /mcp — BIT as an MCP server (JSON-RPC 2.0).

🛠 技术栈与开发

  • 7 种语言实现:JavaScript / Node 18+(fetch 零依赖)· Go 1.22+(net/http 纯标准库)· Rust(ureq 同步 + SSE 迭代器)· Java 17+(java.net.http 零依赖)· C(libcurl + 内置 cJSON,make 编译)· C#(HttpClient 零依赖单文件 BitSdk.cs)· Lua(curl 子进程单文件)
  • 统一契约:全部 SDK 实现同一份 docs/API.md HTTP 契约(端点 / 鉴权 / 错误体 / SSE 格式),并对同一个 fake BIT 服务器跑冒烟测试
  • 能力面:Agent 对话(/api/chat)、OpenAI 兼容端点(/v1/chat/completions 支持流式)、工具注册与远程调用(webhook 回调)、审计与调试快照、BIT 作为 MCP 服务器(POST /mcp)

🚀 30 秒上手(JS 为例)

import { BitClient } from "bit-sdk-js";
const client = new BitClient({
  baseUrl: "http://127.0.0.1:7777",
  clientKey: "bit_...",          // BIT → 设置 → 远程访问 → 复制
  accessPassword: "...",         // 可选
});
const { reply } = await client.chat({ message: "总结今天的待办" });

鉴权规则:/api/* 需要 Client Key(Bearer 或 ?key=)+ X-Access-Password 头;/v1/* 与 /mcp 只需 Client Key(OpenAI 客户端无法发自定义头)。503 = 未配置 Client Key,401 = 凭据错误。

📚 文档与链接