dsh-workspace-api-key 0.2.10 → 0.2.11

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
@@ -78,7 +78,7 @@ The command forwards its arguments to pnpm inside the profile directory, so the
78
78
  pnpm add dsh-workspace-api-key # or: npm install dsh-workspace-api-key
79
79
  ```
80
80
 
81
- Pin a version with `dsh-workspace-api-key@0.2.10`, or install straight from the repository with `dsh-workspace-api-key@github:COH2357/dsh-workspace-api-key` (a git-hosted plugin is built from source on install).
81
+ Pin a version with `dsh-workspace-api-key@0.2.11`, or install straight from the repository with `dsh-workspace-api-key@github:COH2357/dsh-workspace-api-key` (a git-hosted plugin is built from source on install).
82
82
 
83
83
  Then add `"dsh-workspace-api-key"` to `dsh.profile.bundles` in that profile's `package.json` and restart DSH. For local development, use a link instead:
84
84
 
package/README.zh.md CHANGED
@@ -78,7 +78,7 @@ dsh plugin --profile web add dsh-workspace-api-key
78
78
  pnpm add dsh-workspace-api-key # 或者:npm install dsh-workspace-api-key
79
79
  ```
80
80
 
81
- 锁版本用 `dsh-workspace-api-key@0.2.10`;直接从仓库装则用 `dsh-workspace-api-key@github:COH2357/dsh-workspace-api-key`(git 来源的插件会在安装时现场构建)。
81
+ 锁版本用 `dsh-workspace-api-key@0.2.11`;直接从仓库装则用 `dsh-workspace-api-key@github:COH2357/dsh-workspace-api-key`(git 来源的插件会在安装时现场构建)。
82
82
 
83
83
  然后把 `"dsh-workspace-api-key"` 加进该 profile `package.json` 的 `dsh.profile.bundles`,重启 DSH。本地开发用 link 代替:
84
84
 
package/lib/index.js CHANGED
@@ -700,6 +700,10 @@ function readWebSettings(ctx) {
700
700
  // settings 服务的真实形状是 describe() 返回「按 profile 条目 id 键控」的行(每行带 ns 与活值),
701
701
  // 没有 get(ns):早期版本曾按 get 读取,结果永远拿到 undefined,搜索面板会整个消失。
702
702
  let rows = []
703
+ // 重入保护:describe() 会 interpolate 各条目的配置表达式,若某个表达式又要凭据,
704
+ // 就会再次走到这里。读不成就算了,绝不能递归。
705
+ if (readingWebSettings === true) return webDefaults()
706
+ readingWebSettings = true
703
707
  try {
704
708
  if (typeof settings?.describe === 'function') {
705
709
  rows = settings.describe() ?? []
@@ -710,7 +714,34 @@ function readWebSettings(ctx) {
710
714
  }
711
715
  } catch {
712
716
  rows = []
717
+ } finally {
718
+ readingWebSettings = false
713
719
  }
720
+ return webConfigOf(rows)
721
+ }
722
+
723
+ /** readWebSettings 期间的重入标记。 */
724
+ let readingWebSettings = false
725
+
726
+ /** 读不到官方设置时的默认形状:旧 Messages 通道、默认 ref。 */
727
+ function webDefaults() {
728
+ return {
729
+ apiKeyEnv: DEFAULT_API_KEY_REF,
730
+ legacyKeyEnv: DEFAULT_API_KEY_REF,
731
+ apiLiteralKey: undefined,
732
+ legacyLiteralKey: undefined,
733
+ baseURL: FALLBACK_SEARCH_BASE_URL,
734
+ searchProvider: FALLBACK_SEARCH_PROVIDER,
735
+ fetchProvider: FALLBACK_FETCH_PROVIDER,
736
+ count: 10,
737
+ apiChannel: false,
738
+ searchKeyEnv: DEFAULT_API_KEY_REF,
739
+ searchLiteralKey: undefined,
740
+ }
741
+ }
742
+
743
+ /** 把 describe() 的行投影成本插件关心的字段。 */
744
+ function webConfigOf(rows) {
714
745
  const read = (ns) => {
715
746
  const value = rows.find((row) => row?.ns === ns)?.value
716
747
  return typeof value === 'object' && value !== null ? value : {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workspace-api-key",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "A DeepSeek Harness plugin that binds a separate DeepSeek API key to each workspace, or to a single session, so the spend of one key stays with the sessions you choose.",
5
5
  "type": "module",
6
6
  "license": "MIT",