@dan-ai-studio/dshopencodego 0.1.7 → 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 +11 -4
- package/lib/types/adapter.js +1 -7
- package/lib/types/catalog/metadata.d.ts +7 -0
- package/lib/types/catalog/metadata.js +35 -9
- 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"]) {
|
|
@@ -242,9 +243,16 @@ function thinkingLevels(metadata, known) {
|
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
const format = known?.compat?.thinkingFormat;
|
|
245
|
-
if (known?.reasoning === true && format !== void 0 && known.thinkingLevelMap?.off !== null) {
|
|
246
|
+
if (known?.reasoning === true && format !== void 0 && DISABLES_THINKING_WHEN_UNSET.has(format) && known.thinkingLevelMap?.off !== null) {
|
|
246
247
|
map.off ??= known.thinkingLevelMap?.off ?? "off";
|
|
247
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
|
+
}
|
|
248
256
|
return map;
|
|
249
257
|
}
|
|
250
258
|
function familySibling(id, api, documentFamily, entries, builtin) {
|
|
@@ -1256,7 +1264,6 @@ function providerHeaders(sessionId) {
|
|
|
1256
1264
|
}
|
|
1257
1265
|
|
|
1258
1266
|
// src/adapter.ts
|
|
1259
|
-
var DISABLES_THINKING_WHEN_UNSET = /* @__PURE__ */ new Set(["deepseek", "zai", "qwen", "qwen-chat-template"]);
|
|
1260
1267
|
function withModelLimit(model, limits) {
|
|
1261
1268
|
const limit = limits[model.id];
|
|
1262
1269
|
if (limit === null || limit === void 0) return model;
|
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];
|
|
@@ -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,16 +85,26 @@ function thinkingLevels(metadata, known) {
|
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
87
|
}
|
|
72
|
-
// An established transport may support disabling thinking on top of the
|
|
73
|
-
// advertised effort levels — but only one that has a way to *say* it: a
|
|
74
|
-
// thinkingFormat. Without one, the OpenAI-shaped spelling is
|
|
75
|
-
// `reasoning_effort: "off"`, and gateways that reject the parameter reject
|
|
76
|
-
// the whole request; the honest default there is to send nothing and let the
|
|
77
|
-
// provider decide.
|
|
78
88
|
const format = known?.compat?.thinkingFormat;
|
|
79
|
-
|
|
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) {
|
|
80
94
|
map.off ??= known.thinkingLevelMap?.off ?? 'off';
|
|
81
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
|
+
}
|
|
82
108
|
return map;
|
|
83
109
|
}
|
|
84
110
|
/**
|
package/package.json
CHANGED