* feat: acp-link 支持 --group 参数指定 channel group - 添加 --group CLI flag,校验格式 [a-zA-Z0-9_-]+ - 支持 ACP_RCS_GROUP 环境变量 fallback - 传递 channelGroupId 到 RcsUpstreamClient - 更新 README 文档说明 --group 和相关环境变量 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: RCS 后端 session 复用与 group 绑定 - storeFindEnvironmentByMachineName 匹配 offline 状态,防止重连创建重复 session - registerEnvironment 复用已有 session 而非每次新建 - EnvironmentResponse 返回 channel_group_id 字段 - 注册时将 session 绑定到 group ID,支持 web UI 按 group 查询 - apiKeyAuth 不再设置 uuid,由 uuidAuth 统一处理 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: Web UI Token Manager — 多 token 切换与 session 隔离 - 新增 useTokens hook 管理 localStorage token CRUD - 新增 TokenManagerDialog 弹窗组件(添加/编辑/删除/切换 token) - api client 支持Bearer token 认证,UUID 跟随 token 变化 - Navbar 添加 token 切换按钮 - 切换 token 时自动 reload,实现 session 数据隔离 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复 useTokens useState 初始化函数签名错误 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
103 lines
3.2 KiB
TypeScript
103 lines
3.2 KiB
TypeScript
import { buildCommand, numberParser } from "@stricli/core";
|
|
import type { LocalContext } from "./context.js";
|
|
|
|
export const command = buildCommand({
|
|
docs: {
|
|
brief: "Start the ACP proxy server",
|
|
fullDescription:
|
|
"Starts a WebSocket proxy server that bridges clients to ACP agents. " +
|
|
"The agent command is spawned as a subprocess and communicates via stdin/stdout.\n\n" +
|
|
"Use -- to pass arguments to the agent:\n" +
|
|
" acp-link /path/to/agent -- --verbose --model gpt-4\n\n" +
|
|
"For remote access, set ACP_AUTH_TOKEN environment variable or let it auto-generate.",
|
|
},
|
|
parameters: {
|
|
flags: {
|
|
port: {
|
|
kind: "parsed",
|
|
parse: numberParser,
|
|
brief: "Port to listen on",
|
|
default: "9315",
|
|
},
|
|
host: {
|
|
kind: "parsed",
|
|
parse: String,
|
|
brief: "Host to bind to (use 0.0.0.0 for remote access)",
|
|
default: "localhost",
|
|
},
|
|
debug: {
|
|
kind: "boolean",
|
|
brief: "Enable debug logging to file",
|
|
default: false,
|
|
},
|
|
"no-auth": {
|
|
kind: "boolean",
|
|
brief: "DANGEROUS: Disable authentication (not recommended)",
|
|
default: false,
|
|
},
|
|
https: {
|
|
kind: "boolean",
|
|
brief: "Enable HTTPS with auto-generated self-signed certificate",
|
|
default: false,
|
|
},
|
|
group: {
|
|
kind: "parsed",
|
|
parse: (value: string) => {
|
|
if (!/^[a-zA-Z0-9_-]+$/.test(value)) {
|
|
throw new Error(`Invalid group "${value}": only letters, digits, hyphens, and underscores are allowed`);
|
|
}
|
|
return value;
|
|
},
|
|
brief: "Channel group ID for RCS registration (env: ACP_RCS_GROUP)",
|
|
optional: true,
|
|
},
|
|
},
|
|
positional: {
|
|
kind: "array",
|
|
parameter: {
|
|
brief: "Agent command and arguments (use -- before agent flags)",
|
|
parse: String,
|
|
placeholder: "command",
|
|
},
|
|
minimum: 1,
|
|
},
|
|
},
|
|
func: async function (
|
|
this: LocalContext,
|
|
flags: { port: number; host: string; debug: boolean; "no-auth": boolean; https: boolean; group: string | undefined },
|
|
...args: readonly string[]
|
|
) {
|
|
const port = flags.port;
|
|
const host = flags.host;
|
|
const debug = flags.debug;
|
|
const noAuth = flags["no-auth"];
|
|
const https = flags.https;
|
|
const group = flags.group;
|
|
const [command, ...agentArgs] = args;
|
|
const cwd = process.cwd();
|
|
|
|
// Determine auth token
|
|
// Priority: ACP_AUTH_TOKEN env var > auto-generate (unless --no-auth)
|
|
let token: string | undefined;
|
|
if (noAuth) {
|
|
console.warn("⚠️ WARNING: Authentication disabled. This is dangerous for remote access!");
|
|
token = undefined;
|
|
} else {
|
|
token = process.env.ACP_AUTH_TOKEN;
|
|
if (!token) {
|
|
// Auto-generate random token
|
|
const { randomBytes } = await import("node:crypto");
|
|
token = randomBytes(32).toString("hex");
|
|
}
|
|
}
|
|
|
|
// Initialize logger
|
|
const { initLogger } = await import("../logger.js");
|
|
initLogger({ debug });
|
|
|
|
// Import and run the server
|
|
const { startServer } = await import("../server.js");
|
|
await startServer({ port, host, command: command!, args: [...agentArgs], cwd, debug, token, https, group });
|
|
},
|
|
});
|