dsh-decision-engine 0.5.0 → 0.5.1
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 +17 -6
- package/lib/index.js +49 -9
- package/lib/providers.js +4 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -833,8 +833,13 @@ window.__ModuleLoader__.load({
|
|
|
833
833
|
// 4) API Key:每个 provider 一格,各自保存各自的 key
|
|
834
834
|
row(
|
|
835
835
|
`API Key${keyOk ? `(已配置 ${activeKeyStatus?.hint ?? view.keyHint ?? ""})` : "(未配置)"}`,
|
|
836
|
-
activeKeyStatus !== null
|
|
837
|
-
?
|
|
836
|
+
activeKeyStatus !== null
|
|
837
|
+
? storageValue === "config"
|
|
838
|
+
// 存到配置文件时,目标是该 provider 的显式字段名(如
|
|
839
|
+
// bamboonodeApiKey),而不是凭据变量名——两者是不同的位置,
|
|
840
|
+
// 混着说会让人去 .credentials.yaml 里找 key。
|
|
841
|
+
? `存到插件配置 config.yml 的 ${activeKeyStatus.keyField || "显式 key 字段"}(明文)`
|
|
842
|
+
: `存到 .credentials.yaml 的 ${activeKeyStatus.refName}`
|
|
838
843
|
: "留空则不修改;粘贴新 key 后点保存",
|
|
839
844
|
h("input", {
|
|
840
845
|
type: "password",
|
|
@@ -854,7 +859,7 @@ window.__ModuleLoader__.load({
|
|
|
854
859
|
row(
|
|
855
860
|
"密钥保存位置",
|
|
856
861
|
storageValue === "config"
|
|
857
|
-
?
|
|
862
|
+
? `存进插件配置 config.yml 的 ${activeKeyStatus?.keyField || "显式 key 字段"}(自包含,便于随目录备份;注意是明文)`
|
|
858
863
|
: "存进 ~/.dsh/.credentials.yaml(默认,与其他服务统一托管)",
|
|
859
864
|
h(
|
|
860
865
|
"select",
|
|
@@ -1132,9 +1137,15 @@ window.__ModuleLoader__.load({
|
|
|
1132
1137
|
`模型 ${view.model || "(服务端默认)"} · 超时 ${view.timeoutMs}ms · 请求 ${view.stats?.requests ?? 0} 次(缓存 ${view.stats?.cached ?? 0})`,
|
|
1133
1138
|
// 密钥来源一律取「当前 provider 自己那一条」:用顶层 keyEnvName 会
|
|
1134
1139
|
// 在切换后短暂显示上一家的名字(服务端字段与本地选择不同步时)。
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1140
|
+
//
|
|
1141
|
+
// 显示的是**真实命中的来源**(sourceLabel,服务端算好),而不是
|
|
1142
|
+
// `apiKeyEnv`。后者只是「若走凭据文件时该查哪个变量名」,
|
|
1143
|
+
// 在 keyStorage=config 时根本没被读取——照它显示会让人以为
|
|
1144
|
+
// key 存在 .credentials.yaml 里,甚至误判它过期了。
|
|
1145
|
+
activeKeyStatus !== null ? h("br", null) : null,
|
|
1146
|
+
activeKeyStatus !== null
|
|
1147
|
+
? `密钥来源 ${activeKeyStatus.sourceLabel ?? activeKeyStatus.refName ?? "未知"}` +
|
|
1148
|
+
`${activeKeyStatus.configured === true ? "" : "(未读到)"}`
|
|
1138
1149
|
: null,
|
|
1139
1150
|
),
|
|
1140
1151
|
msg !== null
|
package/lib/index.js
CHANGED
|
@@ -1641,13 +1641,40 @@ export function apply(ctx, config) {
|
|
|
1641
1641
|
}),
|
|
1642
1642
|
);
|
|
1643
1643
|
|
|
1644
|
+
/**
|
|
1645
|
+
* 把「密钥来源」翻成用户能核对的一句话。
|
|
1646
|
+
*
|
|
1647
|
+
* 为什么不让前端自己拼:界面只知道变量名(`BAMBOO_API_KEY`),
|
|
1648
|
+
* 不知道真正命中的是配置文件里的哪一格。只显示变量名会造成误判——
|
|
1649
|
+
* 用户看到 `BAMBOO_API_KEY` 会以为 key 在 `.credentials.yaml` 里,
|
|
1650
|
+
* 而实际生效的可能是 `config.yml` 的 `bamboonodeApiKey`,甚至以为
|
|
1651
|
+
* 那个变量「过期了」。来源判定与文案因此都放在服务端,只有一份真相。
|
|
1652
|
+
*
|
|
1653
|
+
* @param source - config / credentials / env / none。
|
|
1654
|
+
* @param provider - 已解析的 provider(提供 keyField 与 apiKeyEnv)。
|
|
1655
|
+
* @returns 可直接展示的中文说明。
|
|
1656
|
+
*/
|
|
1657
|
+
const keySourceLabel = (source, provider) => {
|
|
1658
|
+
if (source === "config") {
|
|
1659
|
+
const field = provider.preset?.keyField ?? "显式 key 字段";
|
|
1660
|
+
return `配置文件 ${CONFIG_FILE_NAME} 的 ${field}`;
|
|
1661
|
+
}
|
|
1662
|
+
if (source === "credentials") {
|
|
1663
|
+
return `~/.dsh/.credentials.yaml 的 ${provider.apiKeyEnv}`;
|
|
1664
|
+
}
|
|
1665
|
+
if (source === "env") {
|
|
1666
|
+
return `环境变量 ${provider.apiKeyEnv}`;
|
|
1667
|
+
}
|
|
1668
|
+
return "未配置";
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1644
1671
|
/**
|
|
1645
1672
|
* 汇总三个 provider 各自的 key 状态。
|
|
1646
1673
|
*
|
|
1647
1674
|
* 只回报「有没有」「从哪来的」「末四位」,绝不回传明文——
|
|
1648
1675
|
* 这份 JSON 会经过浏览器,明文 key 不应出现在网络响应里。
|
|
1649
1676
|
*
|
|
1650
|
-
* @returns id → `{ configured, hint, source, refName }`。
|
|
1677
|
+
* @returns id → `{ configured, hint, source, refName, sourceLabel }`。
|
|
1651
1678
|
*/
|
|
1652
1679
|
const buildKeyStatus = () => {
|
|
1653
1680
|
const out = {};
|
|
@@ -1656,19 +1683,32 @@ export function apply(ctx, config) {
|
|
|
1656
1683
|
const key = resolveKey({ ...cfg, provider: id }, probe);
|
|
1657
1684
|
const inCredentials =
|
|
1658
1685
|
probe.apiKeyEnv.length > 0 && readCredentialFromDsh(probe.apiKeyEnv) !== undefined;
|
|
1686
|
+
const source =
|
|
1687
|
+
probe.explicitKey.length > 0
|
|
1688
|
+
? "config"
|
|
1689
|
+
: inCredentials
|
|
1690
|
+
? "credentials"
|
|
1691
|
+
: key === undefined
|
|
1692
|
+
? "none"
|
|
1693
|
+
: "env";
|
|
1659
1694
|
out[id] = {
|
|
1660
1695
|
configured: key !== undefined,
|
|
1661
1696
|
hint: key === undefined ? "" : `…${key.slice(-4)}`,
|
|
1662
1697
|
refName: probe.apiKeyEnv,
|
|
1698
|
+
// 该 provider 的显式 key 字段名:`keyStorage=config` 时保存的目标。
|
|
1699
|
+
// 与 refName(凭据文件/环境变量的变量名)是两个不同的位置,
|
|
1700
|
+
// 界面上必须分开说,否则「存到插件配置的 BAMBOO_API_KEY」这种
|
|
1701
|
+
// 自相矛盾的文案就会出现。
|
|
1702
|
+
keyField: probe.preset?.keyField ?? "",
|
|
1663
1703
|
// explicit = 配置里写了明文;credentials = 凭据文件;env = 环境变量
|
|
1664
|
-
source
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1704
|
+
source,
|
|
1705
|
+
// 给界面直接用的可读来源。**必须由服务端算**:只有这里同时知道
|
|
1706
|
+
// provider 的显式字段名(bamboonodeApiKey)与真正命中的来源。
|
|
1707
|
+
//
|
|
1708
|
+
// 早先界面只显示 `apiKeyEnv`(如 BAMBOO_API_KEY),在
|
|
1709
|
+
// keyStorage=config 时会造成严重误解——那个变量根本没被读取,
|
|
1710
|
+
// 用户会以为 key 存在 .credentials.yaml 里,甚至以为它过期了。
|
|
1711
|
+
sourceLabel: keySourceLabel(source, probe),
|
|
1672
1712
|
};
|
|
1673
1713
|
}
|
|
1674
1714
|
return out;
|
package/lib/providers.js
CHANGED
|
@@ -485,6 +485,10 @@ export function providerCatalog() {
|
|
|
485
485
|
endpointStyle: preset.endpointStyle,
|
|
486
486
|
defaultModel: preset.defaultModel,
|
|
487
487
|
apiKeyEnv: preset.apiKeyEnv,
|
|
488
|
+
// 该 provider 的显式 key 字段名(`bamboonodeApiKey` 等)。
|
|
489
|
+
// 界面用它说明「key 存在配置文件的哪一格」——只报变量名会让人
|
|
490
|
+
// 以为 key 在 .credentials.yaml 里,而实际生效的可能是配置文件。
|
|
491
|
+
keyField: preset.keyField,
|
|
488
492
|
hint: preset.hint,
|
|
489
493
|
hintEn: preset.hintEn,
|
|
490
494
|
customizable: id === "custom",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-decision-engine",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "dsh-decision-engine: a cheap judgement layer for DeepSeek Harness — all nine decision points (tool authorization, model routing, delegation, compaction, turn continuation, retrieval, skill pick, session title, COT translation) are implemented and individually switchable, and it works against any system-one style API (system one, bamboonode, or a custom base URL).",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|