mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 08:15:53 +00:00
feat: 支持自托管的 remote-control-server (#214)
* feat: 支持自托管的 remote-control-server (#214) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { Hono } from "hono";
|
||||
import { createCodeSession, getSession, incrementEpoch } from "../../services/session";
|
||||
import { apiKeyAuth, acceptCliHeaders } from "../../auth/middleware";
|
||||
import { generateWorkerJwt } from "../../auth/jwt";
|
||||
import { getBaseUrl, config } from "../../config";
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
/** POST /v1/code/sessions — Create code session (wrapped response for TUI compat) */
|
||||
app.post("/", acceptCliHeaders, apiKeyAuth, async (c) => {
|
||||
const body = await c.req.json();
|
||||
const session = createCodeSession(body);
|
||||
return c.json({ session }, 200);
|
||||
});
|
||||
|
||||
/** POST /v1/code/sessions/:id/bridge — Get connection info + worker JWT */
|
||||
app.post("/:id/bridge", acceptCliHeaders, apiKeyAuth, async (c) => {
|
||||
const sessionId = c.req.param("id");
|
||||
const session = getSession(sessionId);
|
||||
if (!session) {
|
||||
return c.json({ error: { type: "not_found", message: "Session not found" } }, 404);
|
||||
}
|
||||
|
||||
const epoch = incrementEpoch(sessionId);
|
||||
const expiresInSeconds = config.jwtExpiresIn;
|
||||
const workerJwt = generateWorkerJwt(sessionId, expiresInSeconds);
|
||||
|
||||
return c.json({
|
||||
api_base_url: getBaseUrl(),
|
||||
worker_epoch: epoch,
|
||||
worker_jwt: workerJwt,
|
||||
expires_in: expiresInSeconds,
|
||||
}, 200);
|
||||
});
|
||||
|
||||
export default app;
|
||||
Reference in New Issue
Block a user