dsh-context 0.56.2 → 0.58.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.
Files changed (3) hide show
  1. package/lib/client.js +1024 -708
  2. package/lib/index.js +47 -7
  3. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -11,11 +11,14 @@ import { randomUUID } from "node:crypto";
11
11
  * The provider-id seam between dsh request envelopes and the models.dev
12
12
  * registry: client/cost.ts resolves price-book branches through it, and
13
13
  * host/fold.ts uses the DeepSeek resolution to split the session-cost totals
14
- * into peak/off-peak periods. Only the renames live here — an id absent
15
- * from the table passes through verbatim.
14
+ * into peak/off-peak periods. Only the renames live here — a dsh route key
15
+ * that is not a registry id (user-declared gateways, `claude`/`codex`
16
+ * subscriptions, org-prefixed catalogs) passes through and prices through
17
+ * the model-side resolution index instead (client/cost.ts).
16
18
  */
17
19
  const MODELS_DEV_PROVIDER_IDS = {
18
20
  "deepseek-official": "deepseek",
21
+ "deepseek-account": "deepseek",
19
22
  "kimi-coding": "moonshotai",
20
23
  "minimax-cn": "minimax",
21
24
  "zai-coding-cn": "zhipuai"
@@ -2101,7 +2104,9 @@ function createToolAttribution(ctx) {
2101
2104
  //#region src/host/balance.ts
2102
2105
  /** The plugin's balance route, under the authenticated `/api` fence. */
2103
2106
  const BALANCE_ROUTE = "/api/dsh-context/balance";
2104
- /** The settings namespace llm-deepseek installs its connection section under. */
2107
+ /** The settings id the DeepSeek API-key provider has served its connection
2108
+ * section under: the V3 registered namespace, kept as the entry id on V4+
2109
+ * product profiles. */
2105
2110
  const DEEPSEEK_SETTINGS_NS = "llm-deepseek";
2106
2111
  /** llm-deepseek's default credential ref (the env-var name its section resolves). */
2107
2112
  const DEFAULT_API_KEY_ENV = "DEEPSEEK_API_KEY";
@@ -2119,14 +2124,49 @@ function amountOf(value) {
2119
2124
  return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : null;
2120
2125
  }
2121
2126
  /**
2127
+ * The DeepSeek API-key provider's settings section, read through whichever
2128
+ * face the running line serves. V3's `get` reads the registered
2129
+ * `llm-deepseek` section directly; V4+ retired that face, so its `describe()`
2130
+ * projection is folded instead — the provider's row is the one whose served
2131
+ * value declares the top-level `apiKeyEnv` credential ref (the volatile shape
2132
+ * only that provider declares at the section root), preferred under the entry
2133
+ * ids the generations have served it as (`llm-deepseek` on product profiles,
2134
+ * `llm-deepseek-api-key` elsewhere). Rows fold in isolation — a hostile row
2135
+ * drops whole, valid siblings keep serving — and a describe that throws is no
2136
+ * section at all.
2137
+ */
2138
+ function deepseekSectionOf(ctx) {
2139
+ const settings = ctx.get("settings");
2140
+ const section = typeof settings?.get === "function" ? asRecord$1(settings.get(DEEPSEEK_SETTINGS_NS)) : null;
2141
+ if (section !== null) return section;
2142
+ if (typeof settings?.describe !== "function") return null;
2143
+ try {
2144
+ const rows = settings.describe();
2145
+ if (!Array.isArray(rows)) return null;
2146
+ let shaped = null;
2147
+ for (const row of rows) try {
2148
+ const record = asRecord$1(row);
2149
+ if (record === null) continue;
2150
+ const value = asRecord$1(record.value);
2151
+ if (value === null || typeof value.apiKeyEnv !== "string" || value.apiKeyEnv === "") continue;
2152
+ if (record.ns === DEEPSEEK_SETTINGS_NS || record.ns === "llm-deepseek-api-key") return value;
2153
+ shaped ??= value;
2154
+ } catch {
2155
+ continue;
2156
+ }
2157
+ return shaped;
2158
+ } catch {
2159
+ return null;
2160
+ }
2161
+ }
2162
+ /**
2122
2163
  * Resolve the DeepSeek connection facts exactly as llm-deepseek serves its
2123
- * requests: its settings section for the credential ref and endpoint, the
2164
+ * requests: its settings row for the credential ref and endpoint, the
2124
2165
  * credentials service for the key. `null` whenever any fact is missing —
2125
2166
  * the platform is simply not configured for this deployment.
2126
2167
  */
2127
2168
  async function resolveFacts(ctx) {
2128
- const settings = ctx.get("settings");
2129
- const section = typeof settings?.get === "function" ? asRecord$1(settings.get(DEEPSEEK_SETTINGS_NS)) : null;
2169
+ const section = deepseekSectionOf(ctx);
2130
2170
  if (section === null) return null;
2131
2171
  const apiKeyEnv = typeof section.apiKeyEnv === "string" && section.apiKeyEnv !== "" ? section.apiKeyEnv : DEFAULT_API_KEY_ENV;
2132
2172
  const baseUrl = typeof section.baseURL === "string" && section.baseURL !== "" ? section.baseURL : PUBLIC_BASE_URL;
@@ -3139,7 +3179,7 @@ function createContextTimelineDefinition(config, slim) {
3139
3179
  },
3140
3180
  init: () => createTimelineState(),
3141
3181
  apply: (state, event) => applyTimeline(state, event, bounds),
3142
- stateVersion: 20
3182
+ stateVersion: 21
3143
3183
  };
3144
3184
  }
3145
3185
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context",
3
- "version": "0.56.2",
3
+ "version": "0.58.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",
@@ -112,7 +112,7 @@
112
112
  "@deepseek-ai/dsh-settings": "0.1.5-rc.1",
113
113
  "@deepseek-ai/dsh-util-workspace-path": "0.1.5-rc.1",
114
114
  "@deepseek-ai/schemastery": "^3.18.4",
115
- "@opencode-ai/models": "^0.0.72",
115
+ "@opencode-ai/models": "^0.0.87",
116
116
  "@shikijs/langs": "^4.3.1",
117
117
  "@stylistic/eslint-plugin": "^5.10.0",
118
118
  "@tailwindcss/node": "4.3.3",