@clawos-dev/clawd 0.2.537 → 0.2.539

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22835,6 +22835,13 @@ var EngineStatusResponseSchema = external_exports.object({
22835
22835
  /** daemon 手里这份模型表是什么时候查的(ms);还没查过时缺席 */
22836
22836
  modelsLoadedAt: external_exports.number().optional()
22837
22837
  }).strict();
22838
+ var EngineConnectPoolArgs = external_exports.object({
22839
+ /** 自助台发的个人 key(sk-…)。只进 daemon 子进程 env,不落日志、不回显 */
22840
+ apiKey: external_exports.string().min(1)
22841
+ }).strict();
22842
+ var EngineConnectPoolResponseSchema = external_exports.object({
22843
+ ok: external_exports.literal(true)
22844
+ }).strict();
22838
22845
 
22839
22846
  // ../protocol/src/persona-schemas.ts
22840
22847
  var PersonaFileSchema = external_exports.object({
@@ -24379,6 +24386,10 @@ var METHOD_DOCS = {
24379
24386
  summary: "\u67D0\u4E2A\u5F15\u64CE\uFF08claude / codex / pi\uFF09\u7684\u5B89\u88C5\u72B6\u6001 + \u8BA2\u9605 / \u767B\u5F55\u60C5\u51B5\uFF08claude auth status\u3001codex account/read + rateLimits\u3001pi auth.json \u51ED\u636E\u7C7B\u578B\uFF09+ \u6A21\u578B\u8868\u52A0\u8F7D\u65F6\u95F4\u3002\u4E00\u5F8B\u4E0D\u5E26 key / token \u503C\u3002owner-only",
24380
24387
  args: EngineStatusArgs
24381
24388
  },
24389
+ "engine:connectPool": {
24390
+ summary: "\u63A5\u5165\u53F7\u6C60\uFF1A\u62FF\u81EA\u52A9\u53F0\u53D1\u7684\u4E2A\u4EBA key\uFF0C\u62C9\u53F7\u6C60 setup.sh \u8DD1\u4E00\u904D\uFF08\u5199 ~/.codex/config.toml \u6307\u5411 CLIProxyAPI \u4EE3\u7406\uFF09\uFF0C\u518D\u5237 codex \u6A21\u578B\u8868\u9A8C\u8BC1\u3002\u6210\u529F\u56DE { ok:true }\uFF1B\u62FF\u4E0D\u5230\u811A\u672C / \u811A\u672C\u62A5\u9519 / \u8D85\u65F6 / 401 \u4E00\u5F8B reject \u5E26\u4EBA\u8BDD\u3002\u53EA\u7BA1 codex\uFF1B\u672C\u673A\u6CA1\u88C5 codex \u62A5 INVALID_PARAM\u3002owner-only",
24391
+ args: EngineConnectPoolArgs
24392
+ },
24382
24393
  "persona:create": {
24383
24394
  summary: "\u65B0\u5EFA persona\uFF08\u5199 PersonaFile + CLAUDE.md \u9AA8\u67B6\uFF09\u3002owner-only\u3002slug \u53EA\u6536\u5C0F\u5199\u5B57\u6BCD\u6570\u5B57\u4E0E\u5355\u8FDE\u5B57\u7B26\uFF08^[a-z0-9]+(-[a-z0-9]+)*$\uFF0C\u226432\uFF09\uFF0Cdaemon \u62FC\u6210 personaId=persona-<slug>\uFF1B\u8BE5 id \u5DF2\u5B58\u5728\u5219\u62A5\u9519\uFF0C\u4E0D\u81EA\u52A8\u6539\u540D\u3002label \u662F\u663E\u793A\u540D\uFF0C\u4E0D\u53C2\u4E0E id \u63A8\u5BFC\uFF0C\u53EF\u7528\u4E2D\u6587",
24384
24395
  args: PersonaCreateArgsSchema
package/dist/cli.cjs CHANGED
@@ -7486,7 +7486,7 @@ var init_onboarding_schemas = __esm({
7486
7486
  });
7487
7487
 
7488
7488
  // ../protocol/src/engine-schemas.ts
7489
- var EngineStatusArgs, RateLimitWindowSchema, EngineAccountSchema, EngineStatusResponseSchema;
7489
+ var EngineStatusArgs, RateLimitWindowSchema, EngineAccountSchema, EngineStatusResponseSchema, POOL_PORTAL_URL, EngineConnectPoolArgs, EngineConnectPoolResponseSchema;
7490
7490
  var init_engine_schemas = __esm({
7491
7491
  "../protocol/src/engine-schemas.ts"() {
7492
7492
  "use strict";
@@ -7558,6 +7558,14 @@ var init_engine_schemas = __esm({
7558
7558
  /** daemon 手里这份模型表是什么时候查的(ms);还没查过时缺席 */
7559
7559
  modelsLoadedAt: external_exports.number().optional()
7560
7560
  }).strict();
7561
+ POOL_PORTAL_URL = "https://cpa-portal-d417.app.clawos.chat";
7562
+ EngineConnectPoolArgs = external_exports.object({
7563
+ /** 自助台发的个人 key(sk-…)。只进 daemon 子进程 env,不落日志、不回显 */
7564
+ apiKey: external_exports.string().min(1)
7565
+ }).strict();
7566
+ EngineConnectPoolResponseSchema = external_exports.object({
7567
+ ok: external_exports.literal(true)
7568
+ }).strict();
7561
7569
  }
7562
7570
  });
7563
7571
 
@@ -9205,6 +9213,10 @@ var init_methods = __esm({
9205
9213
  summary: "\u67D0\u4E2A\u5F15\u64CE\uFF08claude / codex / pi\uFF09\u7684\u5B89\u88C5\u72B6\u6001 + \u8BA2\u9605 / \u767B\u5F55\u60C5\u51B5\uFF08claude auth status\u3001codex account/read + rateLimits\u3001pi auth.json \u51ED\u636E\u7C7B\u578B\uFF09+ \u6A21\u578B\u8868\u52A0\u8F7D\u65F6\u95F4\u3002\u4E00\u5F8B\u4E0D\u5E26 key / token \u503C\u3002owner-only",
9206
9214
  args: EngineStatusArgs
9207
9215
  },
9216
+ "engine:connectPool": {
9217
+ summary: "\u63A5\u5165\u53F7\u6C60\uFF1A\u62FF\u81EA\u52A9\u53F0\u53D1\u7684\u4E2A\u4EBA key\uFF0C\u62C9\u53F7\u6C60 setup.sh \u8DD1\u4E00\u904D\uFF08\u5199 ~/.codex/config.toml \u6307\u5411 CLIProxyAPI \u4EE3\u7406\uFF09\uFF0C\u518D\u5237 codex \u6A21\u578B\u8868\u9A8C\u8BC1\u3002\u6210\u529F\u56DE { ok:true }\uFF1B\u62FF\u4E0D\u5230\u811A\u672C / \u811A\u672C\u62A5\u9519 / \u8D85\u65F6 / 401 \u4E00\u5F8B reject \u5E26\u4EBA\u8BDD\u3002\u53EA\u7BA1 codex\uFF1B\u672C\u673A\u6CA1\u88C5 codex \u62A5 INVALID_PARAM\u3002owner-only",
9218
+ args: EngineConnectPoolArgs
9219
+ },
9208
9220
  "persona:create": {
9209
9221
  summary: "\u65B0\u5EFA persona\uFF08\u5199 PersonaFile + CLAUDE.md \u9AA8\u67B6\uFF09\u3002owner-only\u3002slug \u53EA\u6536\u5C0F\u5199\u5B57\u6BCD\u6570\u5B57\u4E0E\u5355\u8FDE\u5B57\u7B26\uFF08^[a-z0-9]+(-[a-z0-9]+)*$\uFF0C\u226432\uFF09\uFF0Cdaemon \u62FC\u6210 personaId=persona-<slug>\uFF1B\u8BE5 id \u5DF2\u5B58\u5728\u5219\u62A5\u9519\uFF0C\u4E0D\u81EA\u52A8\u6539\u540D\u3002label \u662F\u663E\u793A\u540D\uFF0C\u4E0D\u53C2\u4E0E id \u63A8\u5BFC\uFF0C\u53EF\u7528\u4E2D\u6587",
9210
9222
  args: PersonaCreateArgsSchema
@@ -51285,7 +51297,7 @@ function createVisitorStore(opts) {
51285
51297
  init_claude();
51286
51298
 
51287
51299
  // src/tools/codex.ts
51288
- var import_node_child_process6 = require("child_process");
51300
+ var import_node_child_process7 = require("child_process");
51289
51301
  var import_node_fs20 = __toESM(require("fs"), 1);
51290
51302
 
51291
51303
  // src/tools/codex-session.ts
@@ -52457,9 +52469,11 @@ function mergeProviderModels(native, provider) {
52457
52469
  }
52458
52470
 
52459
52471
  // src/tools/codex-provider-models.ts
52472
+ var import_node_child_process6 = require("child_process");
52460
52473
  var import_node_fs19 = __toESM(require("fs"), 1);
52461
52474
  var import_node_os8 = __toESM(require("os"), 1);
52462
52475
  var import_node_path19 = __toESM(require("path"), 1);
52476
+ var import_node_util = require("util");
52463
52477
  var PROVIDER_FETCH_TIMEOUT_MS = 3e3;
52464
52478
  function asRecord(v3) {
52465
52479
  return v3 && typeof v3 === "object" && !Array.isArray(v3) ? v3 : null;
@@ -52473,7 +52487,27 @@ function readAuthKey(codexHome) {
52473
52487
  return void 0;
52474
52488
  }
52475
52489
  }
52476
- function resolveProviderEndpoint(rawConfig, deps = {}) {
52490
+ var defaultExecFile = (0, import_node_util.promisify)(import_node_child_process6.execFile);
52491
+ var AUTH_COMMAND_TIMEOUT_MS = 5e3;
52492
+ async function runAuthCommand(name, auth, deps) {
52493
+ const command = typeof auth.command === "string" && auth.command ? auth.command : void 0;
52494
+ if (!command) return void 0;
52495
+ const args = Array.isArray(auth.args) ? auth.args.filter((a2) => typeof a2 === "string") : [];
52496
+ const timeout = typeof auth.timeout_ms === "number" && auth.timeout_ms > 0 ? Math.min(auth.timeout_ms, AUTH_COMMAND_TIMEOUT_MS) : AUTH_COMMAND_TIMEOUT_MS;
52497
+ const cwd = typeof auth.cwd === "string" && auth.cwd ? auth.cwd : void 0;
52498
+ try {
52499
+ const { stdout } = await deps.execFileImpl(command, args, { ...cwd ? { cwd } : {}, timeout });
52500
+ const token = String(stdout).trim();
52501
+ if (token) return token;
52502
+ deps.logger?.warn?.(`provider "${name}": auth command \`${command}\` produced an empty token, sending unauthenticated`);
52503
+ } catch (err) {
52504
+ const e = err;
52505
+ const why = e.killed ? `killed by ${e.signal ?? "signal"} (timeout ${timeout}ms)` : e.code !== void 0 ? `exit/code ${e.code}` : "failed";
52506
+ deps.logger?.warn?.(`provider "${name}": auth command \`${command}\` ${why}, sending unauthenticated`);
52507
+ }
52508
+ return void 0;
52509
+ }
52510
+ async function resolveProviderEndpoint(rawConfig, deps = {}) {
52477
52511
  const config = asRecord(asRecord(rawConfig)?.config);
52478
52512
  if (!config) return null;
52479
52513
  const name = config.model_provider;
@@ -52485,8 +52519,15 @@ function resolveProviderEndpoint(rawConfig, deps = {}) {
52485
52519
  const env = deps.env ?? process.env;
52486
52520
  const codexHome = deps.codexHome ?? env.CODEX_HOME ?? import_node_path19.default.join(import_node_os8.default.homedir(), ".codex");
52487
52521
  const envKey = typeof entry.env_key === "string" && entry.env_key ? entry.env_key : null;
52488
- const token = envKey ? env[envKey] : readAuthKey(codexHome);
52489
- if (!token) {
52522
+ const inlineToken = typeof entry.experimental_bearer_token === "string" && entry.experimental_bearer_token ? entry.experimental_bearer_token : void 0;
52523
+ const auth = asRecord(entry.auth);
52524
+ let token;
52525
+ if (envKey) token = env[envKey];
52526
+ else if (inlineToken) token = inlineToken;
52527
+ else if (auth && typeof auth.command === "string" && auth.command) {
52528
+ token = await runAuthCommand(name, auth, { execFileImpl: deps.execFileImpl ?? defaultExecFile, ...deps.logger ? { logger: deps.logger } : {} });
52529
+ } else token = readAuthKey(codexHome);
52530
+ if (!token && !(auth && typeof auth.command === "string" && auth.command)) {
52490
52531
  deps.logger?.warn?.(
52491
52532
  envKey ? `provider "${name}": env_key ${envKey} is not set in the daemon process, sending unauthenticated` : `provider "${name}": no OPENAI_API_KEY in ${codexHome}/auth.json, sending unauthenticated`
52492
52533
  );
@@ -52593,7 +52634,7 @@ function sanitizeCodexModel(model) {
52593
52634
  async function probeCodex(env = process.env) {
52594
52635
  if (env.CODEX_BIN && import_node_fs20.default.existsSync(env.CODEX_BIN)) return { available: true, path: env.CODEX_BIN };
52595
52636
  try {
52596
- const out = (0, import_node_child_process6.execFileSync)("which", ["codex"], { encoding: "utf8" }).trim();
52637
+ const out = (0, import_node_child_process7.execFileSync)("which", ["codex"], { encoding: "utf8" }).trim();
52597
52638
  if (out && import_node_fs20.default.existsSync(out)) return { available: true, path: out };
52598
52639
  } catch {
52599
52640
  }
@@ -52671,7 +52712,7 @@ var CodexAdapter = class {
52671
52712
  const raw = this.configQueryOverride ? await this.configQueryOverride() : await queryCodexAppServer(process.cwd(), "config/read", {}, {
52672
52713
  timeoutMs: PROVIDER_FETCH_TIMEOUT_MS
52673
52714
  });
52674
- const endpoint = resolveProviderEndpoint(raw, {
52715
+ const endpoint = await resolveProviderEndpoint(raw, {
52675
52716
  ...this.logger ? { logger: this.logger } : {}
52676
52717
  });
52677
52718
  if (!endpoint) return [];
@@ -54927,7 +54968,7 @@ function createShiftStore(deps) {
54927
54968
  }
54928
54969
 
54929
54970
  // src/github/gh.ts
54930
- var import_node_child_process7 = require("child_process");
54971
+ var import_node_child_process8 = require("child_process");
54931
54972
  var GhError = class extends Error {
54932
54973
  constructor(kind, message, stderr) {
54933
54974
  super(message);
@@ -54942,12 +54983,12 @@ var DEFAULT_TIMEOUT_MS2 = 15e3;
54942
54983
  var MAX_BUFFER = 4 * 1024 * 1024;
54943
54984
  function createGhRunner(defaults) {
54944
54985
  const baseTimeoutMs = defaults?.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
54945
- const spawn14 = defaults?.execFile ?? import_node_child_process7.execFile;
54986
+ const spawn15 = defaults?.execFile ?? import_node_child_process8.execFile;
54946
54987
  return {
54947
54988
  run(args, opts) {
54948
54989
  const token = defaults?.token?.();
54949
54990
  return new Promise((resolve9, reject) => {
54950
- spawn14(
54991
+ spawn15(
54951
54992
  "gh",
54952
54993
  args,
54953
54994
  {
@@ -59377,10 +59418,10 @@ var L2 = [
59377
59418
  var WORKFLOW_TEMPLATE = L2.join("\n");
59378
59419
 
59379
59420
  // src/deploy/exec.ts
59380
- var import_node_child_process8 = require("child_process");
59421
+ var import_node_child_process9 = require("child_process");
59381
59422
  var DEFAULT_TIMEOUT_MS3 = 6e4;
59382
59423
  var runCommand = (cmd, args, opts = {}) => new Promise((resolve9) => {
59383
- const child = (0, import_node_child_process8.spawn)(cmd, args, {
59424
+ const child = (0, import_node_child_process9.spawn)(cmd, args, {
59384
59425
  cwd: opts.cwd,
59385
59426
  ...opts.env ? { env: { ...process.env, ...opts.env } } : {},
59386
59427
  stdio: [opts.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
@@ -62420,7 +62461,7 @@ var GATEWAY_ROUTES = {
62420
62461
  healthz: () => "/healthz",
62421
62462
  session: (personaId2) => `/p/${encodeURIComponent(personaId2)}/session`,
62422
62463
  sessionSend: (personaId2, sessionId) => `/p/${encodeURIComponent(personaId2)}/session/${encodeURIComponent(sessionId)}`,
62423
- // 历史文件不挂在 persona 下:使用者的 codex-home 卷跨 persona 共用(design 2026-09-14-codex-native-memories §3.2f)
62464
+ // 历史文件不挂在 persona 下:使用者卷跨 persona 共用(design 2026-09-14-codex-native-memories §3.2f)
62424
62465
  thread: (threadId) => `/threads/${encodeURIComponent(threadId)}`
62425
62466
  };
62426
62467
  var trimSlash = (u2) => u2.replace(/\/+$/, "");
@@ -62951,7 +62992,7 @@ var CloudCodexAdapter = class {
62951
62992
  };
62952
62993
 
62953
62994
  // src/tools/pi.ts
62954
- var import_node_child_process10 = require("child_process");
62995
+ var import_node_child_process11 = require("child_process");
62955
62996
  var import_node_fs37 = __toESM(require("fs"), 1);
62956
62997
  init_protocol();
62957
62998
 
@@ -63029,7 +63070,7 @@ var PiRpcClient = class {
63029
63070
  };
63030
63071
 
63031
63072
  // src/tools/pi-session.ts
63032
- var import_node_child_process9 = require("child_process");
63073
+ var import_node_child_process10 = require("child_process");
63033
63074
  var import_node_crypto9 = require("crypto");
63034
63075
  var import_node_fs35 = __toESM(require("fs"), 1);
63035
63076
  var import_node_path40 = __toESM(require("path"), 1);
@@ -63221,7 +63262,7 @@ function createPiSession(ctx, sink, deps = {}) {
63221
63262
  ...ctx.env,
63222
63263
  ...deps.mcpBridgePath ? { [PI_MCP_CONFIGS_ENV]: JSON.stringify((ctx.mcpConfigs ?? []).map((m3) => m3.path)) } : {}
63223
63264
  };
63224
- const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, ctx.cwd, env) : (0, import_node_child_process9.spawn)(cmd, args, { cwd: ctx.cwd, env, stdio: ["pipe", "pipe", "pipe"] });
63265
+ const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args, ctx.cwd, env) : (0, import_node_child_process10.spawn)(cmd, args, { cwd: ctx.cwd, env, stdio: ["pipe", "pipe", "pipe"] });
63225
63266
  const alive = () => proc.exitCode === null && proc.signalCode === null;
63226
63267
  const st2 = createPiTranslatorState();
63227
63268
  let busy = false;
@@ -63541,7 +63582,7 @@ var PI_FULL_ACCESS = { id: "never", label: "Full Access", description: "pi \u65E
63541
63582
  async function probePi(env = process.env) {
63542
63583
  if (env.PI_BIN && import_node_fs37.default.existsSync(env.PI_BIN)) return { available: true, path: env.PI_BIN };
63543
63584
  try {
63544
- const out = (0, import_node_child_process10.execFileSync)("which", ["pi"], { encoding: "utf8" }).trim();
63585
+ const out = (0, import_node_child_process11.execFileSync)("which", ["pi"], { encoding: "utf8" }).trim();
63545
63586
  if (out && import_node_fs37.default.existsSync(out)) return { available: true, path: out };
63546
63587
  } catch {
63547
63588
  }
@@ -63609,7 +63650,7 @@ function buildPiCapabilities(models) {
63609
63650
  async function queryPiModels(deps = {}) {
63610
63651
  const cmd = process.env.PI_BIN ?? "pi";
63611
63652
  const args = ["--mode", "rpc", "--no-session", "--no-skills", "--no-context-files"];
63612
- const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args) : (0, import_node_child_process10.spawn)(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
63653
+ const proc = deps.spawnOverride ? deps.spawnOverride(cmd, args) : (0, import_node_child_process11.spawn)(cmd, args, { stdio: ["pipe", "pipe", "pipe"] });
63613
63654
  proc.stdin?.on("error", () => {
63614
63655
  });
63615
63656
  const client = new PiRpcClient(proc);
@@ -64494,7 +64535,7 @@ function listRegistered() {
64494
64535
  }
64495
64536
 
64496
64537
  // src/tools/title-generator.ts
64497
- var import_node_child_process11 = require("child_process");
64538
+ var import_node_child_process12 = require("child_process");
64498
64539
  init_protocol();
64499
64540
  var import_node_fs42 = __toESM(require("fs"), 1);
64500
64541
  var import_node_os15 = __toESM(require("os"), 1);
@@ -64591,7 +64632,7 @@ async function generateSessionTitle(tool, firstMessage, deps = {}) {
64591
64632
  }
64592
64633
  const cmd = tool === "claude" ? process.env.CLAUDE_BIN ?? "claude" : process.env.CODEX_BIN ?? "codex";
64593
64634
  const args = tool === "claude" ? buildClaudeTitleArgs(buildClaudeTitlePrompt(text)) : buildCodexTitleArgs(buildTitlePrompt(text), outFile, schemaFile);
64594
- const doSpawn = deps.spawnOverride ?? ((c2, a2, o2) => (0, import_node_child_process11.spawn)(c2, a2, { ...o2, stdio: ["ignore", "pipe", "pipe"] }));
64635
+ const doSpawn = deps.spawnOverride ?? ((c2, a2, o2) => (0, import_node_child_process12.spawn)(c2, a2, { ...o2, stdio: ["ignore", "pipe", "pipe"] }));
64595
64636
  const timeoutMs = deps.timeoutMs ?? DEFAULT_TITLE_GEN_TIMEOUT_MS;
64596
64637
  return await new Promise((resolve9) => {
64597
64638
  let proc;
@@ -66945,7 +66986,7 @@ function readSpawnedByDesktopFromEnv(env = process.env) {
66945
66986
  var import_node_fs51 = __toESM(require("fs"), 1);
66946
66987
  var import_node_path57 = __toESM(require("path"), 1);
66947
66988
  var import_node_crypto13 = __toESM(require("crypto"), 1);
66948
- var import_node_child_process14 = require("child_process");
66989
+ var import_node_child_process15 = require("child_process");
66949
66990
 
66950
66991
  // src/tunnel/tunnel-store.ts
66951
66992
  var import_node_fs48 = __toESM(require("fs"), 1);
@@ -67081,7 +67122,7 @@ function escape2(v3) {
67081
67122
  var import_node_fs49 = __toESM(require("fs"), 1);
67082
67123
  var import_node_os17 = __toESM(require("os"), 1);
67083
67124
  var import_node_path55 = __toESM(require("path"), 1);
67084
- var import_node_child_process12 = require("child_process");
67125
+ var import_node_child_process13 = require("child_process");
67085
67126
  var import_node_stream3 = require("stream");
67086
67127
  var import_promises9 = require("stream/promises");
67087
67128
  var FRPC_VERSION = "0.68.0";
@@ -67181,7 +67222,7 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
67181
67222
  import_node_fs49.default.mkdirSync(work, { recursive: true });
67182
67223
  try {
67183
67224
  await new Promise((resolve9, reject) => {
67184
- const proc = (0, import_node_child_process12.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
67225
+ const proc = (0, import_node_child_process13.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
67185
67226
  proc.on("error", reject);
67186
67227
  proc.on("exit", (code) => code === 0 ? resolve9() : reject(new Error(`tar exited ${code}`)));
67187
67228
  });
@@ -67199,7 +67240,7 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
67199
67240
  // src/tunnel/frpc-process.ts
67200
67241
  var import_node_fs50 = __toESM(require("fs"), 1);
67201
67242
  var import_node_path56 = __toESM(require("path"), 1);
67202
- var import_node_child_process13 = require("child_process");
67243
+ var import_node_child_process14 = require("child_process");
67203
67244
  function frpcPidFilePath(dataDir) {
67204
67245
  return import_node_path56.default.join(dataDir, "frpc.pid");
67205
67246
  }
@@ -67285,7 +67326,7 @@ async function killStaleFrpc(deps) {
67285
67326
  async function defaultScanFrpcPidsByCmdline(tomlPath, logger) {
67286
67327
  if (process.platform === "win32") return [];
67287
67328
  return new Promise((resolve9) => {
67288
- const ps = (0, import_node_child_process13.spawn)("ps", ["-axo", "pid=,command="], { stdio: ["ignore", "pipe", "ignore"] });
67329
+ const ps = (0, import_node_child_process14.spawn)("ps", ["-axo", "pid=,command="], { stdio: ["ignore", "pipe", "ignore"] });
67289
67330
  let buf = "";
67290
67331
  ps.stdout.on("data", (c2) => {
67291
67332
  buf += c2.toString();
@@ -67454,7 +67495,7 @@ var TunnelManager = class {
67454
67495
  logLevel: "info"
67455
67496
  });
67456
67497
  await import_node_fs51.default.promises.writeFile(tomlPath, toml, { mode: 384 });
67457
- const proc = (this.deps.spawnImpl ?? import_node_child_process14.spawn)(frpcBin, ["-c", tomlPath], {
67498
+ const proc = (this.deps.spawnImpl ?? import_node_child_process15.spawn)(frpcBin, ["-c", tomlPath], {
67458
67499
  stdio: ["ignore", "pipe", "pipe"]
67459
67500
  });
67460
67501
  const logDir = import_node_path57.default.join(this.deps.dataDir, "log");
@@ -68342,7 +68383,7 @@ var import_promises10 = __toESM(require("fs/promises"), 1);
68342
68383
  var import_node_os21 = __toESM(require("os"), 1);
68343
68384
  var import_node_path63 = __toESM(require("path"), 1);
68344
68385
  var import_node_module = require("module");
68345
- var import_node_child_process15 = require("child_process");
68386
+ var import_node_child_process16 = require("child_process");
68346
68387
  var import_meta6 = {};
68347
68388
  function defaultRoots() {
68348
68389
  const home = import_node_os21.default.homedir();
@@ -68510,14 +68551,14 @@ function readCodexThreads(db) {
68510
68551
  } catch {
68511
68552
  }
68512
68553
  try {
68513
- const info = (0, import_node_child_process15.spawnSync)("sqlite3", [db, "PRAGMA table_info(threads);"], { encoding: "utf8" });
68554
+ const info = (0, import_node_child_process16.spawnSync)("sqlite3", [db, "PRAGMA table_info(threads);"], { encoding: "utf8" });
68514
68555
  if (info.status !== 0) return null;
68515
68556
  const have = new Set(
68516
68557
  info.stdout.split("\n").map((l2) => l2.split("|")[1]).filter(Boolean)
68517
68558
  );
68518
68559
  if (!["id", "cwd", "updated_at", "thread_source"].every((c2) => have.has(c2))) return null;
68519
68560
  const sel = COLS.map((c2) => have.has(c2) ? c2 : `NULL AS ${c2}`).join(", ");
68520
- const res = (0, import_node_child_process15.spawnSync)("sqlite3", ["-json", db, `SELECT ${sel} FROM threads;`], {
68561
+ const res = (0, import_node_child_process16.spawnSync)("sqlite3", ["-json", db, `SELECT ${sel} FROM threads;`], {
68521
68562
  encoding: "utf8",
68522
68563
  maxBuffer: 64 * 1024 * 1024
68523
68564
  });
@@ -69352,7 +69393,7 @@ function buildHistoryHandlers(deps) {
69352
69393
  var fs75 = __toESM(require("fs"), 1);
69353
69394
  var os23 = __toESM(require("os"), 1);
69354
69395
  var path80 = __toESM(require("path"), 1);
69355
- var import_node_child_process16 = require("child_process");
69396
+ var import_node_child_process17 = require("child_process");
69356
69397
  init_protocol();
69357
69398
  var DEFAULT_PROJECTS_ROOT = path80.join(os23.homedir(), "Documents", "ChatGPT");
69358
69399
  function allocateDir(root, name) {
@@ -69391,7 +69432,7 @@ function buildProjectHandlers(deps) {
69391
69432
  } catch {
69392
69433
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `not a directory: ${args.path}`);
69393
69434
  }
69394
- const r2 = (0, import_node_child_process16.spawnSync)("open", ["-R", args.path], { stdio: "ignore" });
69435
+ const r2 = (0, import_node_child_process17.spawnSync)("open", ["-R", args.path], { stdio: "ignore" });
69395
69436
  if (r2.status !== 0) {
69396
69437
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `open -R \u5931\u8D25: exit ${r2.status}`);
69397
69438
  }
@@ -69417,7 +69458,7 @@ function buildProjectHandlers(deps) {
69417
69458
  } catch (err) {
69418
69459
  throw new ClawdError(ERROR_CODES.INVALID_CWD, `\u521B\u5EFA\u9879\u76EE\u76EE\u5F55\u5931\u8D25: ${String(err)}`);
69419
69460
  }
69420
- const git2 = (0, import_node_child_process16.spawnSync)("git", ["init"], { cwd: target, stdio: "ignore" });
69461
+ const git2 = (0, import_node_child_process17.spawnSync)("git", ["init"], { cwd: target, stdio: "ignore" });
69421
69462
  if (git2.status !== 0) {
69422
69463
  fs75.rmSync(target, { recursive: true, force: true });
69423
69464
  throw new ClawdError(
@@ -69541,11 +69582,11 @@ init_protocol();
69541
69582
  init_protocol();
69542
69583
 
69543
69584
  // src/workspace/git.ts
69544
- var import_node_child_process17 = require("child_process");
69585
+ var import_node_child_process18 = require("child_process");
69545
69586
  var import_node_fs58 = __toESM(require("fs"), 1);
69546
69587
  var import_node_path65 = __toESM(require("path"), 1);
69547
- var import_node_util = require("util");
69548
- var pexec = (0, import_node_util.promisify)(import_node_child_process17.execFile);
69588
+ var import_node_util2 = require("util");
69589
+ var pexec = (0, import_node_util2.promisify)(import_node_child_process18.execFile);
69549
69590
  function normalizePath(p3) {
69550
69591
  const resolved = import_node_path65.default.resolve(p3);
69551
69592
  try {
@@ -69675,18 +69716,18 @@ function buildCapabilitiesHandlers(deps) {
69675
69716
  init_protocol();
69676
69717
 
69677
69718
  // src/tools/version-probe.ts
69678
- var import_node_child_process19 = require("child_process");
69719
+ var import_node_child_process20 = require("child_process");
69679
69720
  init_claude();
69680
69721
  init_protocol();
69681
69722
 
69682
69723
  // src/tools/shell-path.ts
69683
- var import_node_child_process18 = require("child_process");
69724
+ var import_node_child_process19 = require("child_process");
69684
69725
  var import_node_os22 = __toESM(require("os"), 1);
69685
69726
  function refreshPathFromLoginShell() {
69686
69727
  if (process.platform === "win32") return;
69687
69728
  const shell = process.env.SHELL ?? import_node_os22.default.userInfo().shell ?? "/bin/zsh";
69688
69729
  try {
69689
- const out = (0, import_node_child_process18.execFileSync)(shell, ["-ilc", 'command echo -n "$PATH"'], {
69730
+ const out = (0, import_node_child_process19.execFileSync)(shell, ["-ilc", 'command echo -n "$PATH"'], {
69690
69731
  encoding: "utf8",
69691
69732
  timeout: 3e3,
69692
69733
  stdio: ["ignore", "pipe", "ignore"]
@@ -69703,7 +69744,7 @@ function parseVersionOutput(out) {
69703
69744
  }
69704
69745
  function execVersion(bin) {
69705
69746
  return new Promise((resolve9, reject) => {
69706
- (0, import_node_child_process19.execFile)(bin, ["--version"], { timeout: 5e3 }, (err, stdout) => {
69747
+ (0, import_node_child_process20.execFile)(bin, ["--version"], { timeout: 5e3 }, (err, stdout) => {
69707
69748
  if (err) reject(err);
69708
69749
  else resolve9(String(stdout));
69709
69750
  });
@@ -69735,8 +69776,79 @@ async function probeToolVersions(opts = {}) {
69735
69776
  return out;
69736
69777
  }
69737
69778
 
69779
+ // src/tools/pool-connect.ts
69780
+ var import_node_child_process21 = require("child_process");
69781
+ init_protocol();
69782
+ var POOL_SETUP_SCRIPT_PATH = "/api/setup.sh";
69783
+ var POOL_SCRIPT_FETCH_TIMEOUT_MS = 5e3;
69784
+ var POOL_SCRIPT_RUN_TIMEOUT_MS = 1e4;
69785
+ async function runPoolSetupScript(opts, deps = {}) {
69786
+ const script = await fetchScript(deps);
69787
+ return runScript(script, opts.apiKey, deps);
69788
+ }
69789
+ async function fetchScript(deps) {
69790
+ const fetchImpl = deps.fetchImpl ?? fetch;
69791
+ const url = `${POOL_PORTAL_URL}${POOL_SETUP_SCRIPT_PATH}`;
69792
+ const controller = new AbortController();
69793
+ const timer = setTimeout(() => controller.abort(), deps.fetchTimeoutMs ?? POOL_SCRIPT_FETCH_TIMEOUT_MS);
69794
+ try {
69795
+ const res = await fetchImpl(url, { signal: controller.signal });
69796
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
69797
+ return await res.text();
69798
+ } catch (err) {
69799
+ throw new Error(`\u62FF\u4E0D\u5230\u53F7\u6C60\u811A\u672C\uFF1A${err.message} (${url})`);
69800
+ } finally {
69801
+ clearTimeout(timer);
69802
+ }
69803
+ }
69804
+ function runScript(script, apiKey, deps) {
69805
+ return new Promise((resolve9, reject) => {
69806
+ const proc = (0, import_node_child_process21.spawn)("bash", ["-s"], {
69807
+ env: { ...deps.env ?? process.env, CPA_KEY: apiKey, CPA_MODE: "api" },
69808
+ stdio: ["pipe", "pipe", "pipe"]
69809
+ });
69810
+ let stdout = "";
69811
+ let stderr = "";
69812
+ let settled = false;
69813
+ const timeoutMs = deps.scriptTimeoutMs ?? POOL_SCRIPT_RUN_TIMEOUT_MS;
69814
+ const timer = setTimeout(() => {
69815
+ if (settled) return;
69816
+ settled = true;
69817
+ proc.kill("SIGTERM");
69818
+ reject(new Error(`\u53F7\u6C60\u811A\u672C\u8D85\u65F6\uFF08${Math.round(timeoutMs / 1e3)}s \u6CA1\u8DD1\u5B8C\uFF09`));
69819
+ }, timeoutMs);
69820
+ const redact = (s2) => s2.split(apiKey).join("***");
69821
+ proc.stdout.on("data", (d2) => {
69822
+ stdout += d2.toString();
69823
+ });
69824
+ proc.stderr.on("data", (d2) => {
69825
+ stderr += d2.toString();
69826
+ });
69827
+ proc.on("error", (err) => {
69828
+ if (settled) return;
69829
+ settled = true;
69830
+ clearTimeout(timer);
69831
+ reject(new Error(`\u8D77\u4E0D\u6765 bash\uFF1A${err.message}`));
69832
+ });
69833
+ proc.on("close", (code) => {
69834
+ if (settled) return;
69835
+ settled = true;
69836
+ clearTimeout(timer);
69837
+ if (code === 0) {
69838
+ resolve9({ stdout: redact(stdout) });
69839
+ return;
69840
+ }
69841
+ const lastLine = stderr.trim().split("\n").filter(Boolean).pop();
69842
+ reject(new Error(lastLine ? redact(lastLine) : `\u53F7\u6C60\u811A\u672C\u5931\u8D25\uFF08\u9000\u51FA\u7801 ${code}\uFF09`));
69843
+ });
69844
+ proc.stdin.on("error", () => {
69845
+ });
69846
+ proc.stdin.end(script);
69847
+ });
69848
+ }
69849
+
69738
69850
  // src/tools/claude-auth-status.ts
69739
- var import_node_child_process20 = require("child_process");
69851
+ var import_node_child_process22 = require("child_process");
69740
69852
  var str5 = (v3) => typeof v3 === "string" && v3 ? v3 : void 0;
69741
69853
  function mapClaudeAuthStatus(raw) {
69742
69854
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
@@ -69759,7 +69871,7 @@ function mapClaudeAuthStatus(raw) {
69759
69871
  };
69760
69872
  }
69761
69873
  async function queryClaudeAuthStatus(deps = {}) {
69762
- const run = deps.execFileImpl ?? import_node_child_process20.execFile;
69874
+ const run = deps.execFileImpl ?? import_node_child_process22.execFile;
69763
69875
  const env = deps.env ?? process.env;
69764
69876
  const bin = env.CLAUDE_BIN ?? "claude";
69765
69877
  const stdout = await new Promise((resolve9, reject) => {
@@ -69881,6 +69993,7 @@ function buildEngineHandlers(deps, overrides = {}) {
69881
69993
  ...overrides.probes
69882
69994
  };
69883
69995
  const probeTools = overrides.probeTools ?? probeToolVersions;
69996
+ const runScript2 = overrides.runScript ?? runPoolSetupScript;
69884
69997
  const status = async (frame) => {
69885
69998
  const { tool } = parseArgs2(EngineStatusArgs, frame, "engine:status");
69886
69999
  const probed = (await probeTools()).find((t2) => t2.id === tool);
@@ -69903,7 +70016,17 @@ function buildEngineHandlers(deps, overrides = {}) {
69903
70016
  return { response: { ...withLoadedAt(), error: err.message } };
69904
70017
  }
69905
70018
  };
69906
- return { "engine:status": status };
70019
+ const connectPool = async (frame) => {
70020
+ const { apiKey } = parseArgs2(EngineConnectPoolArgs, frame, "engine:connectPool");
70021
+ const codex = (await probeTools()).find((t2) => t2.id === "codex");
70022
+ if (!codex?.available) {
70023
+ throw new ClawdError(ERROR_CODES.INVALID_PARAM, "\u672C\u673A\u6CA1\u88C5 Codex\uFF0C\u53F7\u6C60\u53EA\u670D\u52A1 Codex");
70024
+ }
70025
+ await runScript2({ apiKey });
70026
+ await deps.manager.getCapabilities("codex", { refresh: true });
70027
+ return { response: { ok: true } };
70028
+ };
70029
+ return { "engine:status": status, "engine:connectPool": connectPool };
69907
70030
  }
69908
70031
 
69909
70032
  // src/handlers/inbox.ts
@@ -70671,6 +70794,8 @@ var METHOD_GRANT_MAP = {
70671
70794
  "capabilities:get": ADMIN_ANY,
70672
70795
  // engine:status(设置 → 账号「引擎」,spec 2026-09-17-engine-status):回账号邮箱 / 订阅档,与 githubAuth:get 同档,guest 够不着
70673
70796
  "engine:status": ADMIN_ANY,
70797
+ // engine:connectPool(接入号池,spec 2026-09-17-onboarding-pool-key):改本机 ~/.codex/config.toml,owner-only
70798
+ "engine:connectPool": ADMIN_ANY,
70674
70799
  "persona:create": ADMIN_ANY,
70675
70800
  // persona:list / persona:get 下沉到 CAPABILITY_SCOPED:guest 调用合法
70676
70801
  // (list 用于 People 面板展开对方分享的 personas;get 用于 guest 视角下
@@ -70785,7 +70910,7 @@ function computeMethodAccess(args) {
70785
70910
  }
70786
70911
 
70787
70912
  // src/version.ts
70788
- var version = "0.2.537".length > 0 ? "0.2.537" : "dev";
70913
+ var version = "0.2.539".length > 0 ? "0.2.539" : "dev";
70789
70914
 
70790
70915
  // src/cli-probe/probe.ts
70791
70916
  var fs78 = __toESM(require("fs"), 1);
@@ -72559,7 +72684,7 @@ var import_node_crypto21 = require("crypto");
72559
72684
  init_protocol();
72560
72685
 
72561
72686
  // src/peer-ops/run-command.ts
72562
- var import_node_child_process21 = require("child_process");
72687
+ var import_node_child_process23 = require("child_process");
72563
72688
  var import_node_os27 = __toESM(require("os"), 1);
72564
72689
  var DEFAULT_TIMEOUT_MS6 = 3e4;
72565
72690
  var MAX_TIMEOUT_MS = 3e5;
@@ -72567,7 +72692,7 @@ var MAX_OUTPUT_BYTES = 1048576;
72567
72692
  function runCommand2(command, opts = {}) {
72568
72693
  const timeoutMs = Math.min(opts.timeoutMs ?? DEFAULT_TIMEOUT_MS6, MAX_TIMEOUT_MS);
72569
72694
  return new Promise((resolve9) => {
72570
- const child = (0, import_node_child_process21.spawn)("bash", ["-c", command], { cwd: import_node_os27.default.homedir() });
72695
+ const child = (0, import_node_child_process23.spawn)("bash", ["-c", command], { cwd: import_node_os27.default.homedir() });
72571
72696
  const out = [];
72572
72697
  const err = [];
72573
72698
  let outBytes = 0;
@@ -72937,7 +73062,7 @@ async function dispatchRpc(method, frame, client, ctx, deps) {
72937
73062
  }
72938
73063
 
72939
73064
  // src/extension/runtime.ts
72940
- var import_node_child_process22 = require("child_process");
73065
+ var import_node_child_process24 = require("child_process");
72941
73066
  var import_node_path77 = __toESM(require("path"), 1);
72942
73067
  var import_promises18 = require("timers/promises");
72943
73068
 
@@ -73045,7 +73170,7 @@ var Runtime = class {
73045
73170
  CLAWOS_EXT_PORT: String(port),
73046
73171
  CLAWOS_EXT_ID: extId
73047
73172
  };
73048
- const child = (0, import_node_child_process22.spawn)("sh", ["-c", cmd], {
73173
+ const child = (0, import_node_child_process24.spawn)("sh", ["-c", cmd], {
73049
73174
  cwd: dir,
73050
73175
  env,
73051
73176
  stdio: ["ignore", "pipe", "pipe"],
@@ -22650,6 +22650,13 @@ var EngineStatusResponseSchema = external_exports.object({
22650
22650
  /** daemon 手里这份模型表是什么时候查的(ms);还没查过时缺席 */
22651
22651
  modelsLoadedAt: external_exports.number().optional()
22652
22652
  }).strict();
22653
+ var EngineConnectPoolArgs = external_exports.object({
22654
+ /** 自助台发的个人 key(sk-…)。只进 daemon 子进程 env,不落日志、不回显 */
22655
+ apiKey: external_exports.string().min(1)
22656
+ }).strict();
22657
+ var EngineConnectPoolResponseSchema = external_exports.object({
22658
+ ok: external_exports.literal(true)
22659
+ }).strict();
22653
22660
 
22654
22661
  // ../protocol/src/persona-schemas.ts
22655
22662
  var PersonaFileSchema = external_exports.object({
@@ -24194,6 +24201,10 @@ var METHOD_DOCS = {
24194
24201
  summary: "\u67D0\u4E2A\u5F15\u64CE\uFF08claude / codex / pi\uFF09\u7684\u5B89\u88C5\u72B6\u6001 + \u8BA2\u9605 / \u767B\u5F55\u60C5\u51B5\uFF08claude auth status\u3001codex account/read + rateLimits\u3001pi auth.json \u51ED\u636E\u7C7B\u578B\uFF09+ \u6A21\u578B\u8868\u52A0\u8F7D\u65F6\u95F4\u3002\u4E00\u5F8B\u4E0D\u5E26 key / token \u503C\u3002owner-only",
24195
24202
  args: EngineStatusArgs
24196
24203
  },
24204
+ "engine:connectPool": {
24205
+ summary: "\u63A5\u5165\u53F7\u6C60\uFF1A\u62FF\u81EA\u52A9\u53F0\u53D1\u7684\u4E2A\u4EBA key\uFF0C\u62C9\u53F7\u6C60 setup.sh \u8DD1\u4E00\u904D\uFF08\u5199 ~/.codex/config.toml \u6307\u5411 CLIProxyAPI \u4EE3\u7406\uFF09\uFF0C\u518D\u5237 codex \u6A21\u578B\u8868\u9A8C\u8BC1\u3002\u6210\u529F\u56DE { ok:true }\uFF1B\u62FF\u4E0D\u5230\u811A\u672C / \u811A\u672C\u62A5\u9519 / \u8D85\u65F6 / 401 \u4E00\u5F8B reject \u5E26\u4EBA\u8BDD\u3002\u53EA\u7BA1 codex\uFF1B\u672C\u673A\u6CA1\u88C5 codex \u62A5 INVALID_PARAM\u3002owner-only",
24206
+ args: EngineConnectPoolArgs
24207
+ },
24197
24208
  "persona:create": {
24198
24209
  summary: "\u65B0\u5EFA persona\uFF08\u5199 PersonaFile + CLAUDE.md \u9AA8\u67B6\uFF09\u3002owner-only\u3002slug \u53EA\u6536\u5C0F\u5199\u5B57\u6BCD\u6570\u5B57\u4E0E\u5355\u8FDE\u5B57\u7B26\uFF08^[a-z0-9]+(-[a-z0-9]+)*$\uFF0C\u226432\uFF09\uFF0Cdaemon \u62FC\u6210 personaId=persona-<slug>\uFF1B\u8BE5 id \u5DF2\u5B58\u5728\u5219\u62A5\u9519\uFF0C\u4E0D\u81EA\u52A8\u6539\u540D\u3002label \u662F\u663E\u793A\u540D\uFF0C\u4E0D\u53C2\u4E0E id \u63A8\u5BFC\uFF0C\u53EF\u7528\u4E2D\u6587",
24199
24210
  args: PersonaCreateArgsSchema