JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat: support passing --user-id from jiuwenswarm-tui to http header
haowenzhong1d37620b02a46
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/ws-client.ts b/jiuwenswarm/channels/tui/frontend/src/core/ws-client.tsindex bf387a2d9e..c3656fd859 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/ws-client.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/ws-client.ts@@ -21,6 +21,7 @@ export class WsClient {private ws: WebSocket | null = null;private readonly url: string;private readonly token: string;+ private readonly userId: string;private handlers: FrameHandler[] = [];private pending = new Map<string, PendingRequest>();private retryCount = 0;@@ -32,9 +33,10 @@ export class WsClient {private closeCode = 0;private closeReason = "";- constructor(url: string, token = "") {+ constructor(url: string, token = "", userId = "") {this.url = url;this.token = token;+ this.userId = userId;}get status(): ConnectionStatus {@@ -129,6 +131,9 @@ export class WsClient {if (this.token) {headers.Authorization = `Bearer ${this.token}`;}+ if (this.userId) {+ headers["X-User-Id"] = this.userId;+ }this.ws = new WebSocket(this.url, { headers });diff --git a/jiuwenswarm/channels/tui/frontend/src/index.ts b/jiuwenswarm/channels/tui/frontend/src/index.tsindex feda7d47ae..665981816c 100644--- a/jiuwenswarm/channels/tui/frontend/src/index.ts+++ b/jiuwenswarm/channels/tui/frontend/src/index.ts@@ -13,6 +13,7 @@ const { values } = parseArgs({url: { type: "string", default: "ws://127.0.0.1:19001/tui" },session: { type: "string" },token: { type: "string", default: "" },+ "user-id": { type: "string", default: "" },help: { type: "boolean", short: "h" },},strict: true,@@ -25,6 +26,7 @@ Options:--url <url> Gateway CLI WebSocket URL (default: ws://127.0.0.1:19001/tui)--session <id> Resume a specific session--token <token> Authentication token+ --user-id <id> User identifier for the session-h, --help Show this help`);process.exit(0);@@ -36,7 +38,7 @@ if (!process.env.JIUWENSWARM_TUI_HEADLESS && (!process.stdin.isTTY || !process.sprocess.exit(1);}-const wsClient = new WsClient(values.url ?? "ws://127.0.0.1:19001/tui", values.token ?? "");+const wsClient = new WsClient(values.url ?? "ws://127.0.0.1:19001/tui", values.token ?? "", values["user-id"] ?? "");const appState = new CliPiAppState(wsClient, values.session);const commandService = new CommandService();commandService.register(createBuiltinCommands());