dsh-context 0.56.1 → 0.57.0
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 +854 -675
- package/lib/index.js +41 -4
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -2101,7 +2101,9 @@ function createToolAttribution(ctx) {
|
|
|
2101
2101
|
//#region src/host/balance.ts
|
|
2102
2102
|
/** The plugin's balance route, under the authenticated `/api` fence. */
|
|
2103
2103
|
const BALANCE_ROUTE = "/api/dsh-context/balance";
|
|
2104
|
-
/** The settings
|
|
2104
|
+
/** The settings id the DeepSeek API-key provider has served its connection
|
|
2105
|
+
* section under: the V3 registered namespace, kept as the entry id on V4+
|
|
2106
|
+
* product profiles. */
|
|
2105
2107
|
const DEEPSEEK_SETTINGS_NS = "llm-deepseek";
|
|
2106
2108
|
/** llm-deepseek's default credential ref (the env-var name its section resolves). */
|
|
2107
2109
|
const DEFAULT_API_KEY_ENV = "DEEPSEEK_API_KEY";
|
|
@@ -2119,14 +2121,49 @@ function amountOf(value) {
|
|
|
2119
2121
|
return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : null;
|
|
2120
2122
|
}
|
|
2121
2123
|
/**
|
|
2124
|
+
* The DeepSeek API-key provider's settings section, read through whichever
|
|
2125
|
+
* face the running line serves. V3's `get` reads the registered
|
|
2126
|
+
* `llm-deepseek` section directly; V4+ retired that face, so its `describe()`
|
|
2127
|
+
* projection is folded instead — the provider's row is the one whose served
|
|
2128
|
+
* value declares the top-level `apiKeyEnv` credential ref (the volatile shape
|
|
2129
|
+
* only that provider declares at the section root), preferred under the entry
|
|
2130
|
+
* ids the generations have served it as (`llm-deepseek` on product profiles,
|
|
2131
|
+
* `llm-deepseek-api-key` elsewhere). Rows fold in isolation — a hostile row
|
|
2132
|
+
* drops whole, valid siblings keep serving — and a describe that throws is no
|
|
2133
|
+
* section at all.
|
|
2134
|
+
*/
|
|
2135
|
+
function deepseekSectionOf(ctx) {
|
|
2136
|
+
const settings = ctx.get("settings");
|
|
2137
|
+
const section = typeof settings?.get === "function" ? asRecord$1(settings.get(DEEPSEEK_SETTINGS_NS)) : null;
|
|
2138
|
+
if (section !== null) return section;
|
|
2139
|
+
if (typeof settings?.describe !== "function") return null;
|
|
2140
|
+
try {
|
|
2141
|
+
const rows = settings.describe();
|
|
2142
|
+
if (!Array.isArray(rows)) return null;
|
|
2143
|
+
let shaped = null;
|
|
2144
|
+
for (const row of rows) try {
|
|
2145
|
+
const record = asRecord$1(row);
|
|
2146
|
+
if (record === null) continue;
|
|
2147
|
+
const value = asRecord$1(record.value);
|
|
2148
|
+
if (value === null || typeof value.apiKeyEnv !== "string" || value.apiKeyEnv === "") continue;
|
|
2149
|
+
if (record.ns === DEEPSEEK_SETTINGS_NS || record.ns === "llm-deepseek-api-key") return value;
|
|
2150
|
+
shaped ??= value;
|
|
2151
|
+
} catch {
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
return shaped;
|
|
2155
|
+
} catch {
|
|
2156
|
+
return null;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
/**
|
|
2122
2160
|
* Resolve the DeepSeek connection facts exactly as llm-deepseek serves its
|
|
2123
|
-
* requests: its settings
|
|
2161
|
+
* requests: its settings row for the credential ref and endpoint, the
|
|
2124
2162
|
* credentials service for the key. `null` whenever any fact is missing —
|
|
2125
2163
|
* the platform is simply not configured for this deployment.
|
|
2126
2164
|
*/
|
|
2127
2165
|
async function resolveFacts(ctx) {
|
|
2128
|
-
const
|
|
2129
|
-
const section = typeof settings?.get === "function" ? asRecord$1(settings.get(DEEPSEEK_SETTINGS_NS)) : null;
|
|
2166
|
+
const section = deepseekSectionOf(ctx);
|
|
2130
2167
|
if (section === null) return null;
|
|
2131
2168
|
const apiKeyEnv = typeof section.apiKeyEnv === "string" && section.apiKeyEnv !== "" ? section.apiKeyEnv : DEFAULT_API_KEY_ENV;
|
|
2132
2169
|
const baseUrl = typeof section.baseURL === "string" && section.baseURL !== "" ? section.baseURL : PUBLIC_BASE_URL;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-context",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "A DeepSeek Harness plugin for context insight and management, with context dashboard and context command, for understanding how the context is made of, and how it evolves.",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"author": "bowenliang123",
|