@dan-ai-studio/dshopencodego 0.1.6 → 0.1.8
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 +2 -2
- package/lib/index.js +13 -5
- package/lib/types/adapter.js +4 -8
- package/lib/types/catalog/metadata.d.ts +7 -0
- package/lib/types/catalog/metadata.js +36 -5
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -440,7 +440,7 @@ if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id) + "]")
|
|
|
440
440
|
style.textContent = ".d7lz0W_root{color:var(--dsw-alias-label-primary);flex-direction:column;gap:1.25rem;display:flex}.d7lz0W_title{margin:0;font-size:1.05rem}.d7lz0W_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:.8rem}.d7lz0W_warn{color:var(--dsw-alias-state-warn-primary);margin:0;font-size:.8rem}.d7lz0W_ok{color:var(--dsw-alias-state-success-primary);font-size:.8rem}.d7lz0W_block{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:.6rem;flex-direction:column;gap:.5rem;padding:.85rem;display:flex}.d7lz0W_row{flex-wrap:wrap;align-items:center;gap:.5rem;display:flex}.d7lz0W_row>strong{margin-right:auto}.d7lz0W_input{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);min-width:10rem;color:var(--dsw-alias-label-primary);font:inherit;border-radius:.35rem;flex:14rem;padding:.35rem .5rem;font-size:.85rem}.d7lz0W_button{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border-radius:.35rem;padding:.35rem .7rem;font-size:.8rem}.d7lz0W_button:disabled{color:var(--dsw-alias-state-idle-primary);cursor:default}.d7lz0W_number{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);width:5rem;color:var(--dsw-alias-label-primary);font:inherit;border-radius:.35rem;padding:.25rem .4rem;font-size:.8rem}.d7lz0W_select{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-base);width:auto;max-width:100%;color:var(--dsw-alias-label-primary);font:inherit;border-radius:.35rem;padding:.25rem .4rem;font-size:.8rem}.d7lz0W_segmented{border:1px solid var(--dsw-alias-border-l1);border-radius:.35rem;display:inline-flex;overflow:hidden}.d7lz0W_segment,.d7lz0W_segmentActive{background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;border:0;padding:.25rem .6rem;font-size:.8rem}.d7lz0W_segmentActive{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}.d7lz0W_tableWrap{overflow-x:auto}.d7lz0W_table{border-collapse:collapse;width:100%;min-width:62rem;font-size:.78rem}.d7lz0W_table th{color:var(--dsw-alias-label-secondary);text-align:left;white-space:nowrap;padding:.25rem .45rem;font-weight:500}.d7lz0W_table td{border-top:1px solid var(--dsw-alias-border-l1);vertical-align:middle;white-space:nowrap;padding:.28rem .45rem}.d7lz0W_toggle{width:2rem}.d7lz0W_toggle input{accent-color:var(--dsw-alias-brand-primary)}.d7lz0W_list{flex-direction:column;display:flex}.d7lz0W_item{border-top:1px solid var(--dsw-alias-border-l1);align-items:flex-start;gap:.5rem;padding:.45rem .15rem;display:flex}.d7lz0W_item input[type=checkbox]{accent-color:var(--dsw-alias-brand-primary);margin-top:.15rem}.d7lz0W_itemBody{flex-direction:column;gap:.15rem;min-width:0;display:flex}.d7lz0W_itemMain{flex-wrap:wrap;align-items:baseline;gap:.6rem;display:flex}.d7lz0W_itemMeta{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:.75rem;font-size:.75rem;display:flex}.d7lz0W_name{color:var(--dsw-alias-label-primary)}.d7lz0W_mono{color:var(--dsw-alias-label-secondary);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.d7lz0W_badge{color:var(--dsw-alias-brand-primary)}";
|
|
441
441
|
document.head.appendChild(style);
|
|
442
442
|
}
|
|
443
|
-
var section_default = { "
|
|
443
|
+
var section_default = { "ok": "d7lz0W_ok", "hint": "d7lz0W_hint", "number": "d7lz0W_number", "root": "d7lz0W_root", "item": "d7lz0W_item", "segmentActive": "d7lz0W_segmentActive", "segmented": "d7lz0W_segmented", "itemMeta": "d7lz0W_itemMeta", "segment": "d7lz0W_segment", "tableWrap": "d7lz0W_tableWrap", "input": "d7lz0W_input", "select": "d7lz0W_select", "name": "d7lz0W_name", "toggle": "d7lz0W_toggle", "button": "d7lz0W_button", "mono": "d7lz0W_mono", "warn": "d7lz0W_warn", "row": "d7lz0W_row", "itemBody": "d7lz0W_itemBody", "block": "d7lz0W_block", "table": "d7lz0W_table", "badge": "d7lz0W_badge", "list": "d7lz0W_list", "itemMain": "d7lz0W_itemMain", "title": "d7lz0W_title" };
|
|
444
444
|
|
|
445
445
|
// src/client/Section.tsx
|
|
446
446
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -996,7 +996,7 @@ if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id2) + "]"
|
|
|
996
996
|
style.textContent = ".mMNkkW_root{align-items:center;display:inline-flex;position:relative}.mMNkkW_trigger{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;white-space:nowrap;border-radius:999px;padding:.35rem .6rem;font-size:.8rem;line-height:1}.mMNkkW_trigger:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.mMNkkW_panel{z-index:20;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-overlay);width:18rem;color:var(--dsw-alias-label-primary);border-radius:.6rem;flex-direction:column;gap:.6rem;padding:.75rem .85rem;display:flex;position:absolute;bottom:calc(100% + .5rem);right:0;box-shadow:0 8px 24px #0000002e}.mMNkkW_window{flex-direction:column;gap:.25rem;display:flex}.mMNkkW_row{justify-content:space-between;gap:.5rem;font-size:.85rem;display:flex}.mMNkkW_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:.75rem}.mMNkkW_progress{width:100%;height:.35rem;accent-color:var(--dsw-alias-brand-primary)}.mMNkkW_limited{color:var(--dsw-alias-state-warn-primary);font-size:.75rem}.mMNkkW_warning{border:1px solid var(--dsw-alias-state-warn-primary);color:var(--dsw-alias-label-primary);border-radius:.4rem;padding:.4rem .5rem;font-size:.75rem}.mMNkkW_retry{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border-radius:.35rem;align-self:flex-start;padding:.25rem .5rem;font-size:.75rem}.mMNkkW_local{border-top:1px solid var(--dsw-alias-border-l1);flex-direction:column;gap:.2rem;padding-top:.5rem;display:flex}";
|
|
997
997
|
document.head.appendChild(style);
|
|
998
998
|
}
|
|
999
|
-
var pill_default = { "
|
|
999
|
+
var pill_default = { "trigger": "mMNkkW_trigger", "window": "mMNkkW_window", "row": "mMNkkW_row", "root": "mMNkkW_root", "limited": "mMNkkW_limited", "local": "mMNkkW_local", "panel": "mMNkkW_panel", "retry": "mMNkkW_retry", "hint": "mMNkkW_hint", "progress": "mMNkkW_progress", "warning": "mMNkkW_warning" };
|
|
1000
1000
|
|
|
1001
1001
|
// src/client/UsagePill.tsx
|
|
1002
1002
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
package/lib/index.js
CHANGED
|
@@ -223,6 +223,8 @@ function rates(value) {
|
|
|
223
223
|
};
|
|
224
224
|
return { input: rate("input"), output: rate("output"), cacheRead: rate("cache_read"), cacheWrite: rate("cache_write") };
|
|
225
225
|
}
|
|
226
|
+
var DISABLES_THINKING_WHEN_UNSET = /* @__PURE__ */ new Set(["deepseek", "zai", "qwen", "qwen-chat-template"]);
|
|
227
|
+
var UNDOCUMENTED_EFFORTS = ["low", "medium", "high"];
|
|
226
228
|
function thinkingLevels(metadata, known) {
|
|
227
229
|
const options = metadata["reasoning_options"];
|
|
228
230
|
if (!Array.isArray(options)) return known?.thinkingLevelMap;
|
|
@@ -230,8 +232,7 @@ function thinkingLevels(metadata, known) {
|
|
|
230
232
|
for (const item of options) {
|
|
231
233
|
const option = record(item);
|
|
232
234
|
if (option["type"] === "toggle" || option["type"] === "budget_tokens") {
|
|
233
|
-
map.
|
|
234
|
-
map.high = "high";
|
|
235
|
+
map.high ??= "high";
|
|
235
236
|
}
|
|
236
237
|
if (option["type"] !== "effort" || !Array.isArray(option["values"])) continue;
|
|
237
238
|
for (const value of option["values"]) {
|
|
@@ -241,9 +242,17 @@ function thinkingLevels(metadata, known) {
|
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
|
-
|
|
245
|
+
const format = known?.compat?.thinkingFormat;
|
|
246
|
+
if (known?.reasoning === true && format !== void 0 && DISABLES_THINKING_WHEN_UNSET.has(format) && known.thinkingLevelMap?.off !== null) {
|
|
245
247
|
map.off ??= known.thinkingLevelMap?.off ?? "off";
|
|
246
248
|
}
|
|
249
|
+
if (options.length === 0) {
|
|
250
|
+
const installed = known?.thinkingLevelMap;
|
|
251
|
+
if (installed !== void 0 && LEVELS.some((level) => typeof installed[level] === "string")) return installed;
|
|
252
|
+
if (format === void 0) {
|
|
253
|
+
for (const level of UNDOCUMENTED_EFFORTS) map[level] = level;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
247
256
|
return map;
|
|
248
257
|
}
|
|
249
258
|
function familySibling(id, api, documentFamily, entries, builtin) {
|
|
@@ -1255,7 +1264,6 @@ function providerHeaders(sessionId) {
|
|
|
1255
1264
|
}
|
|
1256
1265
|
|
|
1257
1266
|
// src/adapter.ts
|
|
1258
|
-
var DISABLES_THINKING_WHEN_UNSET = /* @__PURE__ */ new Set(["deepseek", "zai", "qwen", "qwen-chat-template"]);
|
|
1259
1267
|
function withModelLimit(model, limits) {
|
|
1260
1268
|
const limit = limits[model.id];
|
|
1261
1269
|
if (limit === null || limit === void 0) return model;
|
|
@@ -1344,7 +1352,7 @@ var OpencodeGoAdapter = class extends LlmAdapter {
|
|
|
1344
1352
|
}
|
|
1345
1353
|
/** Validate an explicit effort against the model's own levels, without clamping. */
|
|
1346
1354
|
resolveReasoningLevel(model, effort) {
|
|
1347
|
-
if (effort === void 0) return void 0;
|
|
1355
|
+
if (effort === void 0 || effort === "off") return void 0;
|
|
1348
1356
|
const supported = getSupportedThinkingLevels(model);
|
|
1349
1357
|
if (supported.some((level) => level === effort)) return effort;
|
|
1350
1358
|
throw new LlmError7(
|
package/lib/types/adapter.js
CHANGED
|
@@ -68,17 +68,11 @@ import { getSupportedThinkingLevels, normalizeContext } from '@earendil-works/pi
|
|
|
68
68
|
import { attributionHeaders, contentHasImage, LlmAdapter, LlmError, ReasoningEffortId, } from '@deepseek-ai/dsh-llm';
|
|
69
69
|
import { idleWatchdog, timeoutOf } from '@deepseek-ai/dsh-timeout';
|
|
70
70
|
import { DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog } from "./catalog/index.js";
|
|
71
|
-
import { toPiModel } from "./catalog/metadata.js";
|
|
71
|
+
import { DISABLES_THINKING_WHEN_UNSET, toPiModel } from "./catalog/metadata.js";
|
|
72
72
|
import { assertBaseURL } from "./config.js";
|
|
73
73
|
import { toPiContext, toStreamChunks } from "./conversion/index.js";
|
|
74
74
|
import { isModelEnabled, recommendedIds } from "./models.js";
|
|
75
75
|
import { providerHeaders } from "./session-header.js";
|
|
76
|
-
/**
|
|
77
|
-
* pi-ai thinking formats that answer an unset effort with an explicit disable.
|
|
78
|
-
* Every other format omits the parameter and lets the provider decide, so only
|
|
79
|
-
* these need a default effort to avoid silently turning thinking off.
|
|
80
|
-
*/
|
|
81
|
-
const DISABLES_THINKING_WHEN_UNSET = new Set(['deepseek', 'zai', 'qwen', 'qwen-chat-template']);
|
|
82
76
|
/** Apply one request's configured capacities without touching the catalog. */
|
|
83
77
|
function withModelLimit(model, limits) {
|
|
84
78
|
const limit = limits[model.id];
|
|
@@ -188,7 +182,9 @@ export class OpencodeGoAdapter extends LlmAdapter {
|
|
|
188
182
|
}
|
|
189
183
|
/** Validate an explicit effort against the model's own levels, without clamping. */
|
|
190
184
|
resolveReasoningLevel(model, effort) {
|
|
191
|
-
|
|
185
|
+
// "off" is not a level to validate: it is the absence of a request, exactly
|
|
186
|
+
// like an unset effort, and the caller drops both before the wire.
|
|
187
|
+
if (effort === undefined || effort === 'off')
|
|
192
188
|
return undefined;
|
|
193
189
|
const supported = getSupportedThinkingLevels(model);
|
|
194
190
|
if (supported.some(level => level === effort))
|
|
@@ -49,6 +49,13 @@ export interface ModelDefaults {
|
|
|
49
49
|
readonly maxTokens: number;
|
|
50
50
|
readonly input: readonly ('text' | 'image')[];
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Transports whose request branch spells "thinking off" itself — DeepSeek's
|
|
54
|
+
* separate thinking flag, for example — so an installed `off` marker is a
|
|
55
|
+
* promise they can keep. Everywhere else the marker would ride the wire as
|
|
56
|
+
* `reasoning_effort: "off"`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const DISABLES_THINKING_WHEN_UNSET: ReadonlySet<string>;
|
|
52
59
|
/** The base URL one protocol's SDK expects for this gateway. */
|
|
53
60
|
export declare function modelBaseURL(api: WireProtocol, baseURL: string): string;
|
|
54
61
|
/** Inputs the ladder needs beyond the document itself. */
|
|
@@ -41,6 +41,19 @@ function rates(value) {
|
|
|
41
41
|
};
|
|
42
42
|
return { input: rate('input'), output: rate('output'), cacheRead: rate('cache_read'), cacheWrite: rate('cache_write') };
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Transports whose request branch spells "thinking off" itself — DeepSeek's
|
|
46
|
+
* separate thinking flag, for example — so an installed `off` marker is a
|
|
47
|
+
* promise they can keep. Everywhere else the marker would ride the wire as
|
|
48
|
+
* `reasoning_effort: "off"`.
|
|
49
|
+
*/
|
|
50
|
+
export const DISABLES_THINKING_WHEN_UNSET = new Set(['deepseek', 'zai', 'qwen', 'qwen-chat-template']);
|
|
51
|
+
/**
|
|
52
|
+
* The efforts the gateway accepts for a reasoning model whose document names
|
|
53
|
+
* none. Measured 2026-09-25 on every such model that was available:
|
|
54
|
+
* low/medium/high all stream, while "minimal" and "off" answer 400.
|
|
55
|
+
*/
|
|
56
|
+
const UNDOCUMENTED_EFFORTS = ['low', 'medium', 'high'];
|
|
44
57
|
/**
|
|
45
58
|
* Reasoning levels a model actually offers.
|
|
46
59
|
*
|
|
@@ -57,8 +70,11 @@ function thinkingLevels(metadata, known) {
|
|
|
57
70
|
for (const item of options) {
|
|
58
71
|
const option = record(item);
|
|
59
72
|
if (option['type'] === 'toggle' || option['type'] === 'budget_tokens') {
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
// A switch exists but the document names no wire value; "high" is the
|
|
74
|
+
// one "on" spelling measured to work wherever this gateway offers such
|
|
75
|
+
// a switch. "off" is deliberately not invented here: some of these
|
|
76
|
+
// models answer `reasoning_effort: "off"` with a 400.
|
|
77
|
+
map.high ??= 'high';
|
|
62
78
|
}
|
|
63
79
|
if (option['type'] !== 'effort' || !Array.isArray(option['values']))
|
|
64
80
|
continue;
|
|
@@ -69,11 +85,26 @@ function thinkingLevels(metadata, known) {
|
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
}
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
|
|
88
|
+
const format = known?.compat?.thinkingFormat;
|
|
89
|
+
// Only a transport that expresses "off" in its own convention may keep the
|
|
90
|
+
// marker; one that would send it as `reasoning_effort` must not promise a
|
|
91
|
+
// switch it cannot keep (measured: qwen3.7-max, qwen3.8-max and qwen3.8-flash
|
|
92
|
+
// all answer 400 to that value).
|
|
93
|
+
if (known?.reasoning === true && format !== undefined && DISABLES_THINKING_WHEN_UNSET.has(format) && known.thinkingLevelMap?.off !== null) {
|
|
75
94
|
map.off ??= known.thinkingLevelMap?.off ?? 'off';
|
|
76
95
|
}
|
|
96
|
+
if (options.length === 0) {
|
|
97
|
+
// "Reasoning, options undocumented" — the MiMo family and friends.
|
|
98
|
+
const installed = known?.thinkingLevelMap;
|
|
99
|
+
if (installed !== undefined && LEVELS.some(level => typeof installed[level] === 'string'))
|
|
100
|
+
return installed;
|
|
101
|
+
// Without a format of its own the transport speaks plain reasoning_effort,
|
|
102
|
+
// so it offers exactly the measured trio.
|
|
103
|
+
if (format === undefined) {
|
|
104
|
+
for (const level of UNDOCUMENTED_EFFORTS)
|
|
105
|
+
map[level] = level;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
77
108
|
return map;
|
|
78
109
|
}
|
|
79
110
|
/**
|
package/package.json
CHANGED