dsh-packycode-api 1.3.4 → 1.3.6

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/lib/client.js CHANGED
@@ -126,18 +126,8 @@ window.__ModuleLoader__.load({
126
126
  keyClaudeHttp: "Claude 经 HTTP",
127
127
  keyClaudeCliHint: "分组 {groups} 只接受官方 Claude Code 客户端,这个 Key 的 Claude 请求由本机 Claude Code CLI 发出。",
128
128
  keyClaudeHttpHint: "这个 Key 的 Claude 请求走插件内置的 HTTP 通道。",
129
- keyClaudePinned: "(已在 Claude Code CLI 卡片中固定)",
130
129
  cliTitle: "Claude Code CLI",
131
- cliIntro: "cc 分组只接受官方 Claude Code 客户端,这些 Key 的 Claude 请求由本机的 Claude Code CLI 发出;cc-sale、cc-expensive、claude-officially 等分组继续走插件内置的 HTTP 通道。两种通道都由 DSH 执行工具、审批权限、计划模式、附件和历史,体验一致,CLI 只负责把请求发给 PackyCode。",
132
- cliTransportTitle: "Claude 通道",
133
- cliTransportAuto: "按分组自动",
134
- cliTransportCli: "始终用 CLI",
135
- cliTransportHttp: "始终用 HTTP",
136
- cliTransportAutoHint: "推荐。Key 在 cc 分组时走 CLI,其它分组走 HTTP。",
137
- cliTransportCliHint: "所有 Claude 请求都由 Claude Code CLI 发出,需要本机已安装 CLI。",
138
- cliTransportHttpHint: "所有 Claude 请求都走 HTTP;cc 分组可能被网关识别为第三方客户端而拒绝。",
139
- cliTransportNotWritable: "当前 profile 不允许写入设置,通道选择无法保存。",
140
- cliTransportFailed: "保存 Claude 通道失败",
130
+ cliIntro: "cc 分组只接受官方 Claude Code 客户端,这些 Key 的 Claude 请求由本机的 Claude Code CLI 发出;cc-sale、cc-expensive、claude-officially 等分组继续走插件内置的 HTTP 通道。通道由 Key 所在的分组决定。两种通道都由 DSH 执行工具、审批权限、计划模式、附件和历史,体验一致,CLI 只负责把请求发给 PackyCode。",
141
131
  cliProcesses: "运行中的 CLI 会话 {live} 个 · 已启动 {opened} 次 · 续接 {continued} 次",
142
132
  cliChecking: "正在检测本机的 Claude Code CLI…",
143
133
  cliInstalled: "已安装",
@@ -161,6 +151,16 @@ window.__ModuleLoader__.load({
161
151
  cliTimeout: "安装超时,请检查网络后重试。",
162
152
  cliNotFoundAfterInstall: "npm 显示安装完成,但仍找不到 claude 命令。请在终端执行 claude --version 确认,然后点「重新检测」。",
163
153
  cliWindowsNote: "Windows 上 Claude Code 还需要 Git for Windows(https://git-scm.com/downloads/win)。",
154
+ cliOutdated: "Claude Code CLI 版本过低",
155
+ cliOutdatedHint: "插件需要 {minVersion} 或更新版本。更新前,cc 分组 Key 的 Claude 请求无法发出;其它分组和其它模型不受影响。",
156
+ cliUpdate: "更新 Claude Code CLI",
157
+ cliUpdating: "正在更新…(通常需要一两分钟,请勿关闭 DSH)",
158
+ cliUpdateCommand: "将在本机执行:{command}",
159
+ cliUpdateSucceeded: "已更新到 {version}。",
160
+ cliUpdateFailed: "更新失败",
161
+ cliUpdateNotInstalled: "没有找到要更新的 CLI,请点「重新检测」。",
162
+ cliUpdateStillOutdated: "更新命令已执行,但版本仍低于 {minVersion}。请在终端执行 {command},看它给出的提示(例如用 Homebrew 安装的要执行 brew upgrade claude-code),然后点「重新检测」。",
163
+ cliUpdateBroken: "更新后 CLI 无法运行。请点「重新安装」,或在终端执行 {command}。",
164
164
  modelsTitle: "显示的模型",
165
165
  modelsIntro: "切换模型时只显示已勾选的 PackyCode 模型,默认全选。修改后立即生效;已有会话仍可继续使用原模型。",
166
166
  modelsChecking: "正在读取模型设置…",
@@ -338,18 +338,8 @@ window.__ModuleLoader__.load({
338
338
  keyClaudeHttp: "Claude via HTTP",
339
339
  keyClaudeCliHint: "Group {groups} only serves the official Claude Code client, so this key's Claude requests are sent by this device's Claude Code CLI.",
340
340
  keyClaudeHttpHint: "This key's Claude requests use the plugin's built-in HTTP route.",
341
- keyClaudePinned: " (pinned in the Claude Code CLI card)",
342
341
  cliTitle: "Claude Code CLI",
343
- cliIntro: "The cc group only serves the official Claude Code client, so Claude requests on cc keys go through this device's Claude Code CLI; cc-sale, cc-expensive, claude-officially and other groups keep the built-in HTTP route. Either way DSH runs the tools, permissions, plan mode, attachments and history the same; the CLI only carries the request to PackyCode.",
344
- cliTransportTitle: "Claude route",
345
- cliTransportAuto: "By group",
346
- cliTransportCli: "Always CLI",
347
- cliTransportHttp: "Always HTTP",
348
- cliTransportAutoHint: "Recommended. Keys in cc use the CLI; other groups use HTTP.",
349
- cliTransportCliHint: "Every Claude request is sent by the Claude Code CLI, which must be installed.",
350
- cliTransportHttpHint: "Every Claude request uses HTTP; the cc group may refuse it as a third-party client.",
351
- cliTransportNotWritable: "This profile does not allow writing settings, so the route cannot be saved.",
352
- cliTransportFailed: "Could not save the Claude route",
342
+ cliIntro: "The cc group only serves the official Claude Code client, so Claude requests on cc keys go through this device's Claude Code CLI; cc-sale, cc-expensive, claude-officially and other groups keep the built-in HTTP route. The key's groups decide the route. Either way DSH runs the tools, permissions, plan mode, attachments and history the same; the CLI only carries the request to PackyCode.",
353
343
  cliProcesses: "{live} CLI session(s) running · started {opened} · continued {continued}",
354
344
  cliChecking: "Checking this device for the Claude Code CLI…",
355
345
  cliInstalled: "Installed",
@@ -373,6 +363,16 @@ window.__ModuleLoader__.load({
373
363
  cliTimeout: "The install timed out. Check your network and retry.",
374
364
  cliNotFoundAfterInstall: "npm reported success, but the claude command still cannot be found. Run claude --version in a terminal, then click Check again.",
375
365
  cliWindowsNote: "On Windows, Claude Code also needs Git for Windows (https://git-scm.com/downloads/win).",
366
+ cliOutdated: "Claude Code CLI is too old",
367
+ cliOutdatedHint: "The plugin needs {minVersion} or later. Until it is updated, Claude requests on cc keys cannot be sent; other groups and models are unaffected.",
368
+ cliUpdate: "Update Claude Code CLI",
369
+ cliUpdating: "Updating… (usually a minute or two; keep DSH open)",
370
+ cliUpdateCommand: "Runs on this device: {command}",
371
+ cliUpdateSucceeded: "Updated to {version}.",
372
+ cliUpdateFailed: "Update failed",
373
+ cliUpdateNotInstalled: "No CLI was found to update. Click Check again.",
374
+ cliUpdateStillOutdated: "The update ran, but the version is still below {minVersion}. Run {command} in a terminal and follow what it says (for a Homebrew install, brew upgrade claude-code), then click Check again.",
375
+ cliUpdateBroken: "The CLI no longer runs after the update. Click Reinstall, or run {command} in a terminal.",
376
376
  advanced: "Advanced: endpoints",
377
377
  apiHost: "Model endpoint",
378
378
  statusHost: "Balance endpoint",
@@ -2031,8 +2031,7 @@ window.__ModuleLoader__.load({
2031
2031
  function ClaudeRoute({ group, t }) {
2032
2032
  const route = group.claudeTransport;
2033
2033
  if (route === void 0 || !CLAUDE_MODELS.some((id) => group.coverage?.[id] === true)) return null;
2034
- const pinned = route.reason === "preference" ? t("keyClaudePinned") : "";
2035
- const hint = route.transport === "cli" ? `${fill(t("keyClaudeCliHint"), { groups: (route.groups ?? []).join(" / ") || "cc" })}${pinned}` : `${t("keyClaudeHttpHint")}${pinned}`;
2034
+ const hint = route.transport === "cli" ? fill(t("keyClaudeCliHint"), { groups: (route.groups ?? []).join(" / ") || "cc" }) : t("keyClaudeHttpHint");
2036
2035
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2037
2036
  className: "pkc-groups",
2038
2037
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -2589,21 +2588,27 @@ window.__ModuleLoader__.load({
2589
2588
  permission: (cli) => cli.platform === "win32" ? "cliPermissionWindows" : "cliPermission",
2590
2589
  network: () => "cliNetwork",
2591
2590
  timeout: () => "cliTimeout",
2592
- "not-found-after-install": () => "cliNotFoundAfterInstall"
2591
+ "not-found-after-install": () => "cliNotFoundAfterInstall",
2592
+ "not-installed": () => "cliUpdateNotInstalled",
2593
+ "still-outdated": () => "cliUpdateStillOutdated",
2594
+ "broken-after-update": () => "cliUpdateBroken"
2593
2595
  };
2594
- /** The sentence explaining a failed install, by the code the host classified. */
2596
+ /** The sentence explaining a failed install or update, by the code the host classified. */
2595
2597
  function installFailure(cli, t) {
2596
2598
  const key = INSTALL_FAILURES[cli.install?.code]?.(cli);
2597
- return key === void 0 ? void 0 : fill(t(key), { command: cli.command ?? "" });
2599
+ const command = cli.install?.action === "update" ? cli.updateCommand : cli.command;
2600
+ return key === void 0 ? void 0 : fill(t(key), {
2601
+ command: command ?? "",
2602
+ minVersion: cli.minVersion ?? ""
2603
+ });
2598
2604
  }
2599
2605
  /**
2600
- * Which route Claude requests take, whether this device has the Claude Code
2601
- * CLI those on cc keys need, and — without one — an installer.
2606
+ * Whether this device has the Claude Code CLI that Claude requests on cc
2607
+ * keys go through: an installer without one, an updater for one too old.
2602
2608
  */
2603
2609
  function ClaudeCliCard({ call, t }) {
2604
2610
  const [cli, setCli] = react.useState();
2605
2611
  const [checking, setChecking] = react.useState(false);
2606
- const [saving, setSaving] = react.useState(false);
2607
2612
  const [error, setError] = react.useState();
2608
2613
  const check = react.useCallback((force = false) => {
2609
2614
  setChecking(true);
@@ -2631,15 +2636,15 @@ window.__ModuleLoader__.load({
2631
2636
  setError(void 0);
2632
2637
  call("claude-cli/install").then(setCli).catch((failure) => setError(clearMessage(failure)));
2633
2638
  };
2634
- const choose = (transport) => {
2635
- setSaving(true);
2639
+ const update = () => {
2636
2640
  setError(void 0);
2637
- call("claude-cli/update", { transport }).then(setCli).catch((failure) => setError(`${t("cliTransportFailed")}: ${clearMessage(failure)}`)).finally(() => setSaving(false));
2641
+ call("claude-cli/update").then(setCli).catch((failure) => setError(clearMessage(failure)));
2638
2642
  };
2639
2643
  const usable = cli?.installed === true && cli.version !== void 0;
2644
+ const outdated = usable && cli.outdated === true;
2645
+ const action = cli?.install?.action ?? "install";
2640
2646
  const failed = cli?.install?.state === "failed";
2641
2647
  const failure = cli === void 0 ? void 0 : installFailure(cli, t);
2642
- const transport = cli?.transport ?? "auto";
2643
2648
  const processes = cli?.processes;
2644
2649
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Card, {
2645
2650
  title: t("cliTitle"),
@@ -2653,51 +2658,11 @@ window.__ModuleLoader__.load({
2653
2658
  className: "pkc-note",
2654
2659
  children: t("cliIntro")
2655
2660
  }),
2656
- cli !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2657
- className: "pkc-setting",
2658
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2659
- className: "pkc-label",
2660
- children: t("cliTransportTitle")
2661
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
2662
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Segmented, {
2663
- label: t("cliTransportTitle"),
2664
- value: transport,
2665
- disabled: saving || cli.writable !== true,
2666
- onChange: choose,
2667
- options: [
2668
- {
2669
- value: "auto",
2670
- label: t("cliTransportAuto")
2671
- },
2672
- {
2673
- value: "cli",
2674
- label: t("cliTransportCli")
2675
- },
2676
- {
2677
- value: "http",
2678
- label: t("cliTransportHttp")
2679
- }
2680
- ]
2681
- }),
2682
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2683
- className: "pkc-note",
2684
- children: t({
2685
- auto: "cliTransportAutoHint",
2686
- cli: "cliTransportCliHint",
2687
- http: "cliTransportHttpHint"
2688
- }[transport] ?? "cliTransportAutoHint")
2689
- }),
2690
- cli.writable !== true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2691
- className: "pkc-note",
2692
- children: t("cliTransportNotWritable")
2693
- })
2694
- ] })]
2695
- }),
2696
2661
  cli === void 0 && error === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2697
2662
  className: "pkc-note",
2698
2663
  children: t("cliChecking")
2699
2664
  }),
2700
- usable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2665
+ usable && !outdated && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2701
2666
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2702
2667
  className: "pkc-status",
2703
2668
  children: [
@@ -2726,9 +2691,61 @@ window.__ModuleLoader__.load({
2726
2691
  }),
2727
2692
  cli.install?.state === "succeeded" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2728
2693
  className: "pkc-note",
2729
- children: t("cliInstallSucceeded")
2694
+ children: action === "update" ? fill(t("cliUpdateSucceeded"), { version: cli.install.to ?? cli.version }) : t("cliInstallSucceeded")
2730
2695
  })
2731
2696
  ] }),
2697
+ outdated && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2698
+ className: "pkc-callout",
2699
+ children: [
2700
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2701
+ className: "pkc-status",
2702
+ children: [
2703
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2704
+ className: "pkc-dot",
2705
+ "data-tone": "warn"
2706
+ }),
2707
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: t("cliOutdated") }),
2708
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${t("cliVersion")} ${cli.version}` })
2709
+ ]
2710
+ }),
2711
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2712
+ className: "pkc-meta",
2713
+ children: [
2714
+ t("cliPath"),
2715
+ " ",
2716
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2717
+ className: "pkc-mono",
2718
+ children: cli.path
2719
+ })
2720
+ ]
2721
+ }),
2722
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2723
+ className: "pkc-note",
2724
+ children: fill(t("cliOutdatedHint"), { minVersion: cli.minVersion ?? "" })
2725
+ }),
2726
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2727
+ className: "pkc-split",
2728
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2729
+ variant: "primary",
2730
+ size: "md",
2731
+ disabled: running || checking,
2732
+ onClick: update,
2733
+ children: running && action === "update" ? t("cliUpdating") : t("cliUpdate")
2734
+ })
2735
+ }),
2736
+ cli.updateCommand !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2737
+ className: "pkc-note",
2738
+ children: fill(t("cliUpdateCommand"), { command: cli.updateCommand })
2739
+ })
2740
+ ]
2741
+ }),
2742
+ failed && action === "update" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2743
+ className: "pkc-error",
2744
+ children: failure === void 0 ? t("cliUpdateFailed") : `${t("cliUpdateFailed")} · ${failure}`
2745
+ }), cli.install.detail !== void 0 && cli.install.detail !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
2746
+ className: "pkc-detail",
2747
+ children: cli.install.detail
2748
+ })] }),
2732
2749
  cli !== void 0 && !usable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2733
2750
  className: "pkc-callout",
2734
2751
  children: [
@@ -2768,7 +2785,7 @@ window.__ModuleLoader__.load({
2768
2785
  size: "md",
2769
2786
  disabled: running || checking,
2770
2787
  onClick: install,
2771
- children: running ? t("cliInstalling") : cli.installed ? t("cliReinstall") : t("cliInstall")
2788
+ children: running && action === "install" ? t("cliInstalling") : cli.installed ? t("cliReinstall") : t("cliInstall")
2772
2789
  })
2773
2790
  }),
2774
2791
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
@@ -2777,7 +2794,7 @@ window.__ModuleLoader__.load({
2777
2794
  })
2778
2795
  ]
2779
2796
  }),
2780
- failed && !usable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2797
+ failed && action === "install" && !usable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2781
2798
  className: "pkc-error",
2782
2799
  children: failure === void 0 ? t("cliInstallFailed") : `${t("cliInstallFailed")} · ${failure}`
2783
2800
  }), cli.install.detail !== void 0 && cli.install.detail !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {