@skylandnpm/octopus-proxy 0.1.34 → 0.1.35

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.
package/README.md CHANGED
@@ -18,7 +18,7 @@ octopus-proxy identity
18
18
 
19
19
  Proxy 主动连接 Hub 的 `/ws/proxy-chat`,无需开放入站端口或安装 sshd。Claw 经 `/ws/claw-chat` 建立到 Proxy 的内层 TLS 1.3 会话;Hub 只转发加密字节。首次打开工作区显示主机公钥指纹,点击 Trust 后按 Hub 地址和机器人 ID 固定;之后指纹变化会拒绝连接。每次连接都要输入运行 Proxy 服务账号的主机密码,由主机上的 PAM(Linux)或 Open Directory(macOS)验证。断线或连续 60 分钟没有用户操作后需要重新认证。服务安装时生成主机身份,`octopus-proxy identity` 可在主机上查看指纹。安装主机需提供 OpenSSL 和 C 编译器;Linux 还需 PAM 开发头文件。机器人 Secret 仅用于 Hub 路由,不能单独授权工作区。
20
20
 
21
- macOS 12.3 及以上运行 `octopus-proxy onboard` 时,配置保存后、服务启动前会准备截屏辅助程序并申请系统屏幕录制权限;已授权时不会重复弹窗。交互模式和 `--non-interactive` 均执行此步骤,`--no-install-service` 也会申请。请在系统弹窗中允许访问;拒绝、超时或辅助程序编译失败时,向导提示原因与授权路径,并继续初始化。之后可在“系统设置 → 隐私与安全性 → 屏幕录制(或屏幕与系统音频录制)”中授权 `octopus-desktop-capture` 或系统列出的启动程序,再重启 Proxy。Linux 没有通用的截屏授权弹窗,需使用桌面用户的图形会话环境;平台依赖与设置见[桌面快照说明](../../docs/claw-desktop-snapshots.md)。
21
+ macOS 12.3 及以上运行 `octopus-proxy onboard` 时,配置保存后、服务启动前会准备截屏辅助程序并申请系统屏幕录制权限;已授权时不会重复弹窗。交互模式和 `--non-interactive` 均执行此步骤,`--no-install-service` 也会申请。请在系统弹窗中允许访问;拒绝、超时或辅助程序编译失败时,向导提示原因与授权路径,并继续初始化。在“系统设置 → 隐私与安全性 → 屏幕录制(或屏幕与系统音频录制)”中应授权弹窗显示的实际程序,可能是 Terminal、iTerm、编辑器或 node,不保证出现 `octopus-desktop-capture`。onboard 和 doctor 会显示辅助程序路径,文件名不等于系统授权名称。终端授权不代表后台服务已授权,需在 Claw 点击截屏,让实际服务申请权限,按实际名称授权后重启 Proxy。Linux 没有通用的截屏授权弹窗,需使用桌面用户的图形会话环境;平台依赖与设置见[桌面快照说明](../../docs/claw-desktop-snapshots.md)。
22
22
 
23
23
  添加授权项目时,填写项目 ID 后会询问是否继续添加;直接回车即可结束添加并继续保存配置。
24
24
 
@@ -14799,13 +14799,16 @@ var OpenCodeAdapter = class {
14799
14799
  }
14800
14800
  async models(project) {
14801
14801
  const models = await this.data(project, "GET", "/api/model");
14802
+ const config = await this.data(project, "GET", "/api/config").catch(() => void 0);
14803
+ const layers = Array.isArray(config) ? config : [config];
14804
+ const configured = layers.map((layer) => layer?.config?.model ?? layer?.model).filter((value) => typeof value === "string").at(-1);
14802
14805
  const providers = /* @__PURE__ */ new Map();
14803
14806
  for (const model of Array.isArray(models) ? models : []) {
14804
14807
  if (model.enabled === false || model.status === "deprecated") continue;
14805
14808
  const modelId = model.id ?? model.modelID;
14806
14809
  if (typeof model.providerID !== "string" || typeof modelId !== "string") continue;
14807
14810
  const provider = providers.get(model.providerID) ?? { id: model.providerID, models: {} };
14808
- provider.models[modelId] = { ...model, id: modelId };
14811
+ provider.models[modelId] = { ...model, id: modelId, isDefault: configured ? configured === `${model.providerID}/${modelId}` : model.isDefault === true };
14809
14812
  providers.set(model.providerID, provider);
14810
14813
  }
14811
14814
  return redact({ providers: [...providers.values()] });
@@ -16094,7 +16097,10 @@ var CodexAdapter = class {
16094
16097
  if (cursor && seenCursors.has(cursor)) break;
16095
16098
  if (cursor) seenCursors.add(cursor);
16096
16099
  } while (cursor && models.length < 500);
16097
- return { providers: [{ id: "codex", models: Object.fromEntries(models.map((entry) => [entry.model ?? entry.id, { id: entry.model ?? entry.id, name: entry.displayName ?? entry.id, isDefault: entry.isDefault === true }])) }] };
16100
+ const config = await rpc.request("config/read", { cwd: await this.workspace.root(project), includeLayers: false }).catch(() => void 0);
16101
+ const configured = typeof config?.config?.model === "string" ? config.config.model.trim() : void 0;
16102
+ if (configured && !models.some((entry) => (entry.model ?? entry.id) === configured)) models.push({ id: configured, model: configured, displayName: configured });
16103
+ return { providers: [{ id: "codex", models: Object.fromEntries(models.map((entry) => [entry.model ?? entry.id, { id: entry.model ?? entry.id, name: entry.displayName ?? entry.id, isDefault: configured ? (entry.model ?? entry.id) === configured : entry.isDefault === true }])) }] };
16098
16104
  }
16099
16105
  if (op === "sessions.list") {
16100
16106
  const index = await this.index(project);
@@ -16736,10 +16742,11 @@ var PiAdapter = class {
16736
16742
  if (op === "configuration.models") {
16737
16743
  const rpc2 = await this.runtime.connect(project);
16738
16744
  const { models } = await rpc2.request("get_available_models");
16745
+ const state = await rpc2.request("get_state").catch(() => void 0);
16739
16746
  const providers = /* @__PURE__ */ new Map();
16740
16747
  for (const model of models) {
16741
16748
  const provider = providers.get(model.provider) ?? { id: model.provider, models: /* @__PURE__ */ Object.create(null) };
16742
- provider.models[model.id] = { id: model.id, name: model.name ?? model.id };
16749
+ provider.models[model.id] = { id: model.id, name: model.name ?? model.id, isDefault: state?.model?.provider === model.provider && state.model.id === model.id };
16743
16750
  providers.set(model.provider, provider);
16744
16751
  }
16745
16752
  return { providers: [...providers.values()] };
@@ -17266,7 +17273,7 @@ var executeDesktop = async (file, args) => {
17266
17273
  throw new Error(`\u684C\u9762\u622A\u5C4F\u5931\u8D25\uFF1A${detail.stderr?.trim().slice(0, 2048) || detail.message}`);
17267
17274
  }
17268
17275
  };
17269
- var DESKTOP_PERMISSION_GUIDANCE = "\u8BF7\u5728\u201C\u7CFB\u7EDF\u8BBE\u7F6E \u2192 \u9690\u79C1\u4E0E\u5B89\u5168\u6027 \u2192 \u5C4F\u5E55\u5F55\u5236\uFF08\u6216\u5C4F\u5E55\u4E0E\u7CFB\u7EDF\u97F3\u9891\u5F55\u5236\uFF09\u201D\u4E2D\u6388\u6743 octopus-desktop-capture \u6216\u7CFB\u7EDF\u5217\u51FA\u7684\u542F\u52A8\u7A0B\u5E8F\uFF0C\u7136\u540E\u91CD\u542F Proxy\u3002";
17276
+ var DESKTOP_PERMISSION_GUIDANCE = "\u8BF7\u5728\u201C\u7CFB\u7EDF\u8BBE\u7F6E \u2192 \u9690\u79C1\u4E0E\u5B89\u5168\u6027 \u2192 \u5C4F\u5E55\u5F55\u5236\uFF08\u6216\u5C4F\u5E55\u4E0E\u7CFB\u7EDF\u97F3\u9891\u5F55\u5236\uFF09\u201D\u4E2D\u542F\u7528\u7CFB\u7EDF\u6388\u6743\u5F39\u7A97\u663E\u793A\u7684\u5B9E\u9645\u7A0B\u5E8F\u3002\u7EC8\u7AEF\u8FD0\u884C\u65F6\u53EF\u80FD\u663E\u793A Terminal\u3001iTerm \u6216\u7F16\u8F91\u5668\uFF0C\u540E\u53F0\u670D\u52A1\u53EF\u80FD\u663E\u793A node\uFF1B\u4E0D\u4E00\u5B9A\u4F1A\u51FA\u73B0 octopus-desktop-capture\u3002\u7EC8\u7AEF\u6388\u6743\u4E0D\u4EE3\u8868\u540E\u53F0\u670D\u52A1\u5DF2\u6388\u6743\uFF1B\u8BF7\u5728 Claw \u70B9\u51FB\u201C\u622A\u5C4F\u201D\u89E6\u53D1\u670D\u52A1\u7684\u6743\u9650\u7533\u8BF7\uFF0C\u6309\u5B9E\u9645\u540D\u79F0\u6388\u6743\u540E\u91CD\u542F Proxy\u3002";
17270
17277
  async function requestDesktopPermission(stateDirectory) {
17271
17278
  return new PlatformDesktop(stateDirectory).requestScreenCapturePermission();
17272
17279
  }
@@ -17364,14 +17371,14 @@ var PlatformDesktop = class {
17364
17371
  const helper = await this.macHelper();
17365
17372
  try {
17366
17373
  const displays = await this.list();
17367
- record2("\u684C\u9762\u622A\u5C4F\u652F\u6301", "ok", `macOS ${version} \u652F\u6301 ScreenCaptureKit\uFF1B${displays.length} \u4E2A\u6D3B\u52A8\u663E\u793A\u5668\uFF1B\u8F85\u52A9\u7A0B\u5E8F\u53EF\u7528`);
17374
+ record2("\u684C\u9762\u622A\u5C4F\u652F\u6301", "ok", `macOS ${version} \u652F\u6301 ScreenCaptureKit\uFF1B${displays.length} \u4E2A\u6D3B\u52A8\u663E\u793A\u5668\uFF1B\u8F85\u52A9\u7A0B\u5E8F\uFF1A${helper}\uFF08\u6587\u4EF6\u540D\u4E0D\u4E00\u5B9A\u662F\u7CFB\u7EDF\u6388\u6743\u540D\u79F0\uFF09`);
17368
17375
  } catch (error) {
17369
- record2("\u684C\u9762\u622A\u5C4F\u652F\u6301", "warn", error instanceof Error ? error.message : String(error));
17376
+ record2("\u684C\u9762\u622A\u5C4F\u652F\u6301", "warn", `${error instanceof Error ? error.message : error} \u8F85\u52A9\u7A0B\u5E8F\uFF1A${helper}\uFF08\u6587\u4EF6\u540D\u4E0D\u4E00\u5B9A\u662F\u7CFB\u7EDF\u6388\u6743\u540D\u79F0\uFF09`);
17370
17377
  }
17371
17378
  try {
17372
17379
  const permission = (await this.execute(helper, ["permission-status"])).trim();
17373
17380
  if (permission !== "granted" && permission !== "denied") throw new Error("\u5C4F\u5E55\u5F55\u5236\u6388\u6743\u68C0\u67E5\u8FD4\u56DE\u4E86\u65E0\u6548\u7ED3\u679C\u3002");
17374
- record2("\u5C4F\u5E55\u5F55\u5236\u6743\u9650", permission === "granted" ? "ok" : "warn", permission === "granted" ? "\u5DF2\u6388\u6743\uFF08\u5F53\u524D\u7528\u6237\u53CA\u542F\u52A8\u7A0B\u5E8F\uFF09\uFF1B\u68C0\u67E5\u672A\u8BFB\u53D6\u684C\u9762\u56FE\u7247\u3002" : `\u672A\u6388\u6743\u6216\u6388\u6743\u5C1A\u672A\u751F\u6548\uFF1B\u8FD0\u884C octopus-proxy onboard \u7533\u8BF7\u3002${DESKTOP_PERMISSION_GUIDANCE}`);
17381
+ record2("\u5C4F\u5E55\u5F55\u5236\u6743\u9650", permission === "granted" ? "ok" : "warn", permission === "granted" ? "\u5F53\u524D\u542F\u52A8\u7A0B\u5E8F\u5DF2\u6388\u6743\uFF1B\u540E\u53F0\u670D\u52A1\u7684\u6388\u6743\u9700\u5728 Claw \u5B9E\u9645\u622A\u5C4F\u9A8C\u8BC1\u3002" : `\u672A\u6388\u6743\u6216\u6388\u6743\u5C1A\u672A\u751F\u6548\uFF1B\u8FD0\u884C octopus-proxy onboard \u7533\u8BF7\u3002${DESKTOP_PERMISSION_GUIDANCE}`);
17375
17382
  } catch (error) {
17376
17383
  record2("\u5C4F\u5E55\u5F55\u5236\u6743\u9650", "warn", `\u65E0\u6CD5\u68C0\u67E5\uFF1A${error instanceof Error ? error.message : error} ${DESKTOP_PERMISSION_GUIDANCE}`);
17377
17384
  }
package/dist/cli.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  runDaemon,
28
28
  supportedPlatform,
29
29
  systemdUnitPath
30
- } from "./chunk-BIL5ROSQ.js";
30
+ } from "./chunk-5OJQ46AF.js";
31
31
 
32
32
  // src/cli.ts
33
33
  import { spawn } from "node:child_process";
@@ -456,7 +456,7 @@ import { stdin, stdout } from "node:process";
456
456
  import { access as access3, constants as constants2, mkdir as mkdir4, stat as stat3 } from "node:fs/promises";
457
457
  import { execFile as execFile5 } from "node:child_process";
458
458
  import { platform as platform2 } from "node:os";
459
- import { isAbsolute as isAbsolute3 } from "node:path";
459
+ import { isAbsolute as isAbsolute3, join as join3 } from "node:path";
460
460
  import { promisify as promisify5 } from "node:util";
461
461
  var DEFAULT_HUB_URL = "https://octopus.wuyehao.com";
462
462
  async function ask(rl, question, options = {}) {
@@ -645,9 +645,12 @@ async function runOnboard(opts) {
645
645
  stateDirectory = expandHome(stateDirectory);
646
646
  await mkdir4(stateDirectory, { recursive: true, mode: 448 });
647
647
  try {
648
- if (platform2() === "darwin") console.log("\u6B63\u5728\u68C0\u67E5\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF1B\u5982\u51FA\u73B0\u7CFB\u7EDF\u6388\u6743\u63D0\u793A\uFF0C\u8BF7\u5141\u8BB8 Proxy \u8BFB\u53D6\u684C\u9762\u3002");
648
+ if (platform2() === "darwin") {
649
+ console.log(`\u622A\u5C4F\u8F85\u52A9\u7A0B\u5E8F\u8DEF\u5F84\uFF1A${join3(stateDirectory, "octopus-desktop-capture")}\uFF08\u6587\u4EF6\u540D\u4E0D\u4E00\u5B9A\u662F\u7CFB\u7EDF\u6388\u6743\u540D\u79F0\uFF09`);
650
+ console.log("\u6B63\u5728\u68C0\u67E5\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF1B\u5982\u51FA\u73B0\u7CFB\u7EDF\u6388\u6743\u63D0\u793A\uFF0C\u8BF7\u6309\u5F39\u7A97\u4E2D\u7684\u5B9E\u9645\u7A0B\u5E8F\u540D\u79F0\u6388\u6743\uFF0C\u53EF\u80FD\u663E\u793A Terminal\u3001iTerm\u3001\u7F16\u8F91\u5668\u6216 node\u3002");
651
+ }
649
652
  const permission = await requestDesktopPermission(stateDirectory);
650
- if (permission === "granted") console.log("\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF1A\u5DF2\u6388\u6743\uFF0C\u53EF\u5728 Claw \u7684\u201C\u5FEB\u7167\u201D\u4E2D\u622A\u5C4F\u3002");
653
+ if (permission === "granted") console.log("\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF1A\u5F53\u524D\u542F\u52A8\u7A0B\u5E8F\u5DF2\u6388\u6743\uFF1B\u540E\u53F0\u670D\u52A1\u7684\u6388\u6743\u9700\u5728 Claw \u7684\u201C\u5FEB\u7167\u201D\u4E2D\u5B9E\u9645\u622A\u5C4F\u9A8C\u8BC1\u3002");
651
654
  else if (permission === "denied") console.log(`\u8B66\u544A\uFF1A\u5C1A\u672A\u83B7\u5F97\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF0C\u521D\u59CB\u5316\u5C06\u7EE7\u7EED\u3002${DESKTOP_PERMISSION_GUIDANCE}`);
652
655
  } catch (error) {
653
656
  console.log(`\u8B66\u544A\uFF1A\u65E0\u6CD5\u7533\u8BF7\u5C4F\u5E55\u5F55\u5236\u6743\u9650\uFF0C\u521D\u59CB\u5316\u5C06\u7EE7\u7EED\uFF1A${error instanceof Error ? error.message : error} ${DESKTOP_PERMISSION_GUIDANCE}`);
package/dist/main.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConfigError,
4
4
  runDaemon
5
- } from "./chunk-BIL5ROSQ.js";
5
+ } from "./chunk-5OJQ46AF.js";
6
6
 
7
7
  // src/main.ts
8
8
  runDaemon(process.env.OCTOPUS_PROXY_CONFIG ?? "proxy.json").catch((error) => {
@@ -13,7 +13,7 @@ static void fail(NSString *message) {
13
13
  }
14
14
 
15
15
  static NSString *permissionMessage(void) {
16
- return @"无法读取桌面。请在 Proxy 主机的“系统设置 → 隐私与安全性 → 屏幕录制(或屏幕与系统音频录制)”中授权 octopus-desktop-capture 或其启动程序,并重启 Proxy 后重试。";
16
+ return @"无法读取桌面。请在 Proxy 主机的“系统设置 → 隐私与安全性 → 屏幕录制(或屏幕与系统音频录制)”中启用系统弹窗显示的实际程序。终端运行时可能显示 Terminal、iTerm 或编辑器,后台服务可能显示 node;不一定会出现 octopus-desktop-capture。请按此次截屏请求的实际程序名称授权,重启 Proxy 后重试。";
17
17
  }
18
18
 
19
19
  static NSDictionary *displayInfo(CGDirectDisplayID displayId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skylandnpm/octopus-proxy",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "type": "module",
5
5
  "description": "Octopus host proxy: OpenCode, Codex, ZCode and Pi adapters with service installer CLI",
6
6
  "bin": {