@dan-ai-studio/dshopencodego 0.1.69 → 0.1.70
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/README.en.md +3 -0
- package/README.md +3 -0
- package/lib/client.js +39 -0
- package/lib/index.js +35 -9
- package/lib/types/config.d.ts +8 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -101,6 +101,7 @@ Configuration lives in the profile's `cordis.patch.yml`:
|
|
|
101
101
|
# the timer restarts on every answer, so a connection in
|
|
102
102
|
# frequent use is never dropped; a long pause in a
|
|
103
103
|
# conversation costs one handshake (about 200ms)
|
|
104
|
+
requestGzip: true # gzip JSON request bodies of 1 KB or more; turn off if the gateway rejects them
|
|
104
105
|
maxRequestImageBytes: 6291456 # whole-request image payload cap (after base64, bytes)
|
|
105
106
|
requestImagePixelBudget: 1440000 # total-pixel budget for one image
|
|
106
107
|
requestImageMaxBytes: 400000 # encoded-byte target for one image (before base64)
|
|
@@ -141,6 +142,8 @@ The API key comes from the Harness credential store (reference name `OPENCODE_GO
|
|
|
141
142
|
- The settings page shows and accepts the value in **seconds** (a number of milliseconds is not readable at a glance) and stores it in milliseconds. Range: 1 to 1800000 milliseconds.
|
|
142
143
|
- Once a connection has been idle that long, the pool **reclaims it** on its own — no separate mechanism is needed. The actual release comes a couple of seconds later than the setting, which is the client's own small margin beyond the deadline the server states. When the plugin is unloaded, the pool is **closed with it**: the pool belongs to the plugin and should not be left behind on the machine.
|
|
143
144
|
|
|
145
|
+
**Request body gzip**: `requestGzip` is on by default; JSON bodies of 1 KB or more are gzipped (fastest level, off the event loop) with a `Content-Encoding: gzip` header, smaller bodies travel plain. The log's body size is the **actual wire bytes** — compare the same large request with the switch on and off to see what it saved. **If the gateway does not accept gzip it fails requests outright; turn the switch off** (one setting, no other coupling).
|
|
146
|
+
|
|
144
147
|
**Request log**: per-request records, on by default; turning them off returns the request path to exactly as without the log. The settings page's "Request log" group holds the master switch, the debug switch (pool events and the request user agent, default off), and the retention count (default 200).
|
|
145
148
|
|
|
146
149
|
- **Two entries, one page**:
|
package/README.md
CHANGED
|
@@ -100,6 +100,7 @@ DSH 桌面端是 Electron 壳 + 完整的 dsh Web 应用,本插件对它同样
|
|
|
100
100
|
keepAliveTimeoutMs: 600000 # 连接空闲保留:两次请求之间连接留多久(毫秒,1 ~ 1800000)
|
|
101
101
|
# 每次收到回答后重新计时,所以常用时连接不会被断开;
|
|
102
102
|
# 对话中每次停顿较久都要重新握手一次(约 200ms)
|
|
103
|
+
requestGzip: true # 1KB 以上的 JSON 请求体先 gzip 再发;网关如果拒绝就关掉它
|
|
103
104
|
maxRequestImageBytes: 6291456 # 整个请求的图片载荷上限(base64 之后,字节)
|
|
104
105
|
requestImagePixelBudget: 1440000 # 单张图的总像素预算
|
|
105
106
|
requestImageMaxBytes: 400000 # 单张图编码前的字节目标(base64 之前)
|
|
@@ -135,6 +136,8 @@ API Key 通过 Harness 凭证库提供(引用名 `OPENCODE_GO_API_KEY`),
|
|
|
135
136
|
|
|
136
137
|
**连接保留**:`keepAliveTimeoutMs` 决定**与网关的连接在两次请求之间保留多久**。计时器**每次收到回答后重新开始**,所以常用时连接不会被断开,它约束的只是两次请求之间的静默。默认 10 分钟。
|
|
137
138
|
|
|
139
|
+
**请求体压缩**:`requestGzip` 默认开启,1KB 以上的 JSON 请求先 gzip(最快档,异步压,不堵事件循环)再发,`Content-Encoding: gzip` 随行;1KB 以下原样走(压了也省不出什么)。日志里"请求体"记的是** wire 上的实际字节**——同一条大请求,开关两边对比一下就知道压了多少。**网关如果不吃 gzip 会直接 4xx,那时关掉这个开关就行**(一处配置,没有别的连带)。
|
|
140
|
+
|
|
138
141
|
- 背后的原因很实际:连接一旦被断开,下一次请求要重新做一次 TCP 与 TLS 握手,**到网关这一侧约 200 毫秒**,而这笔开销正好落在**下一轮的第一个 token 上**。对话里的停顿(读答案、思考、再打字)通常在 5 ~ 30 秒,正好跨过 HTTP 客户端默认的 4 秒,于是**几乎每一轮都在白付一次握手**。
|
|
139
142
|
- 这条只影响**固定了地址**(`pinnedAddresses`)的部署:没有固定地址时走的是系统自己的 fetch,本插件不加任何东西。
|
|
140
143
|
- 设置页里以**秒**显示与填写(毫秒的数字人读不出量级),存储时换算成毫秒。取值 1 ~ 1800000 毫秒。
|
package/lib/client.js
CHANGED
|
@@ -506,6 +506,8 @@ var en = {
|
|
|
506
506
|
refreshHint: "How long requests and the model picker reuse one listing.",
|
|
507
507
|
keepAliveLabel: "Connection kept idle (seconds)",
|
|
508
508
|
keepAliveHint: "How long a connection to the gateway is held between requests. Longer pauses in a conversation cost one handshake each; the timer restarts on every answer.",
|
|
509
|
+
requestGzipLabel: "Gzip request bodies",
|
|
510
|
+
requestGzipHint: "Compress JSON bodies of 1 KB or more before sending. Turn off if the gateway rejects requests.",
|
|
509
511
|
requestLogTitle: "Request log",
|
|
510
512
|
requestLogHint: "Per-request records for troubleshooting. On by default; turning it off returns the request path to exactly as without the log.",
|
|
511
513
|
requestLogPageHint: "One row per request. Click a column head to sort; the table scrolls and the filters stay put.",
|
|
@@ -696,6 +698,8 @@ var zh = {
|
|
|
696
698
|
refreshHint: "\u8BF7\u6C42\u4E0E\u6A21\u578B\u9009\u62E9\u5668\u590D\u7528\u540C\u4E00\u4EFD\u5217\u8868\u7684\u65F6\u957F\u3002",
|
|
697
699
|
keepAliveLabel: "\u8FDE\u63A5\u7A7A\u95F2\u4FDD\u7559\uFF08\u79D2\uFF09",
|
|
698
700
|
keepAliveHint: "\u4E0E\u7F51\u5173\u7684\u8FDE\u63A5\u5728\u4E24\u6B21\u8BF7\u6C42\u4E4B\u95F4\u4FDD\u7559\u591A\u4E45\u3002\u5BF9\u8BDD\u4E2D\u6BCF\u6B21\u505C\u987F\u8F83\u4E45\u90FD\u8981\u91CD\u65B0\u63E1\u624B\u4E00\u6B21\uFF1B\u6BCF\u6B21\u6536\u5230\u56DE\u7B54\u540E\u8BA1\u65F6\u90FD\u4F1A\u91CD\u65B0\u5F00\u59CB\u3002",
|
|
701
|
+
requestGzipLabel: "\u8BF7\u6C42\u4F53 gzip \u538B\u7F29",
|
|
702
|
+
requestGzipHint: "1KB \u4EE5\u4E0A\u7684 JSON \u8BF7\u6C42\u4F53\u5148\u538B\u7F29\u518D\u53D1\uFF1B\u7F51\u5173\u5982\u679C\u62D2\u7EDD\u8BF7\u6C42\u5C31\u5173\u6389\u5B83\u3002",
|
|
699
703
|
requestLogTitle: "\u8BF7\u6C42\u65E5\u5FD7",
|
|
700
704
|
requestLogHint: "\u6392\u67E5\u7528\u7684\u9010\u8BF7\u6C42\u8BB0\u5F55\u3002\u9ED8\u8BA4\u5F00\u542F\uFF1B\u5173\u95ED\u540E\u8BF7\u6C42\u8DEF\u5F84\u4E0E\u6CA1\u6709\u8BE5\u65E5\u5FD7\u9010\u5B57\u8282\u4E00\u81F4\u3002",
|
|
701
705
|
requestLogPageHint: "\u6BCF\u4E2A\u8BF7\u6C42\u4E00\u884C\u3002\u70B9\u5217\u5934\u53EF\u6392\u5E8F\uFF1B\u8868\u683C\u6EDA\u52A8\uFF0C\u7B5B\u9009\u680F\u56FA\u5B9A\u5728\u4E0A\u65B9\u3002",
|
|
@@ -1031,11 +1035,13 @@ function settingsOf(value) {
|
|
|
1031
1035
|
const requestLogEnabled = record["requestLogEnabled"];
|
|
1032
1036
|
const requestLogDebug = record["requestLogDebug"];
|
|
1033
1037
|
const requestLogMaxEntries = record["requestLogMaxEntries"];
|
|
1038
|
+
const requestGzip = record["requestGzip"];
|
|
1034
1039
|
return {
|
|
1035
1040
|
modelVisibility: Object.fromEntries(entries),
|
|
1036
1041
|
refreshMinutes: minutes,
|
|
1037
1042
|
pinnedAddresses: Object.fromEntries(pinEntries),
|
|
1038
1043
|
keepAliveTimeoutMs: typeof keepAlive === "number" ? keepAlive : DEFAULT_KEEP_ALIVE_TIMEOUT_MS,
|
|
1044
|
+
requestGzip: typeof requestGzip === "boolean" ? requestGzip : true,
|
|
1039
1045
|
requestLogEnabled: typeof requestLogEnabled === "boolean" ? requestLogEnabled : true,
|
|
1040
1046
|
requestLogDebug: typeof requestLogDebug === "boolean" ? requestLogDebug : false,
|
|
1041
1047
|
requestLogMaxEntries: typeof requestLogMaxEntries === "number" ? requestLogMaxEntries : DEFAULT_REQUEST_LOG_MAX_ENTRIES
|
|
@@ -1450,6 +1456,20 @@ var SectionController = class _SectionController {
|
|
|
1450
1456
|
() => this.set({ settings: { ...current, keepAliveTimeoutMs: milliseconds } })
|
|
1451
1457
|
);
|
|
1452
1458
|
}
|
|
1459
|
+
/**
|
|
1460
|
+
* Flip request-body gzip. Off returns every request to plain JSON; it is
|
|
1461
|
+
* the whole fallback plan if the gateway ever rejects a compressed body.
|
|
1462
|
+
*/
|
|
1463
|
+
async setRequestGzip(enabled) {
|
|
1464
|
+
const scope = this.services.scope;
|
|
1465
|
+
const current = this.state.settings;
|
|
1466
|
+
if (scope === void 0 || current === void 0 || !this.state.writable) return;
|
|
1467
|
+
if (typeof enabled !== "boolean") return;
|
|
1468
|
+
await this.write(
|
|
1469
|
+
() => scope.set("requestGzip", enabled),
|
|
1470
|
+
() => this.set({ settings: { ...current, requestGzip: enabled } })
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1453
1473
|
/**
|
|
1454
1474
|
* Flip the request-log master switch. Off (the default) means no record is
|
|
1455
1475
|
* kept and the request path reads exactly as without the log.
|
|
@@ -1891,6 +1911,25 @@ function Section({ controller, t, getLocale, openRequestLog }) {
|
|
|
1891
1911
|
),
|
|
1892
1912
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: t("keepAliveHint") })
|
|
1893
1913
|
] }),
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: section_default.row, children: [
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: section_default.hint, children: [
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1917
|
+
"input",
|
|
1918
|
+
{
|
|
1919
|
+
type: "checkbox",
|
|
1920
|
+
checked: state.settings?.requestGzip ?? true,
|
|
1921
|
+
disabled: !editable || state.saving,
|
|
1922
|
+
onChange: (event) => {
|
|
1923
|
+
void act(async () => {
|
|
1924
|
+
await controller.setRequestGzip(event.target.checked);
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
),
|
|
1929
|
+
` ${t("requestGzipLabel")}`
|
|
1930
|
+
] }),
|
|
1931
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: section_default.hint, children: t("requestGzipHint") })
|
|
1932
|
+
] }),
|
|
1894
1933
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: section_default.row, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t("requestLogTitle") }) }),
|
|
1895
1934
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: section_default.hint, children: t("requestLogHint") }),
|
|
1896
1935
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: section_default.row, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: section_default.hint, children: [
|
package/lib/index.js
CHANGED
|
@@ -59979,7 +59979,7 @@ var require_mock_interceptor = __commonJS({
|
|
|
59979
59979
|
var require_mock_client = __commonJS({
|
|
59980
59980
|
"node_modules/undici/lib/mock/mock-client.js"(exports, module) {
|
|
59981
59981
|
"use strict";
|
|
59982
|
-
var { promisify } = __require("node:util");
|
|
59982
|
+
var { promisify: promisify2 } = __require("node:util");
|
|
59983
59983
|
var Client = require_client();
|
|
59984
59984
|
var { buildMockDispatch } = require_mock_utils();
|
|
59985
59985
|
var {
|
|
@@ -60027,7 +60027,7 @@ var require_mock_client = __commonJS({
|
|
|
60027
60027
|
this[kDispatches] = [];
|
|
60028
60028
|
}
|
|
60029
60029
|
async [kClose]() {
|
|
60030
|
-
await
|
|
60030
|
+
await promisify2(this[kOriginalClose])();
|
|
60031
60031
|
this[kConnected] = 0;
|
|
60032
60032
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
60033
60033
|
}
|
|
@@ -60240,7 +60240,7 @@ var require_mock_call_history = __commonJS({
|
|
|
60240
60240
|
var require_mock_pool = __commonJS({
|
|
60241
60241
|
"node_modules/undici/lib/mock/mock-pool.js"(exports, module) {
|
|
60242
60242
|
"use strict";
|
|
60243
|
-
var { promisify } = __require("node:util");
|
|
60243
|
+
var { promisify: promisify2 } = __require("node:util");
|
|
60244
60244
|
var Pool = require_pool();
|
|
60245
60245
|
var { buildMockDispatch } = require_mock_utils();
|
|
60246
60246
|
var {
|
|
@@ -60288,7 +60288,7 @@ var require_mock_pool = __commonJS({
|
|
|
60288
60288
|
this[kDispatches] = [];
|
|
60289
60289
|
}
|
|
60290
60290
|
async [kClose]() {
|
|
60291
|
-
await
|
|
60291
|
+
await promisify2(this[kOriginalClose])();
|
|
60292
60292
|
this[kConnected] = 0;
|
|
60293
60293
|
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
60294
60294
|
}
|
|
@@ -73563,6 +73563,8 @@ import {
|
|
|
73563
73563
|
resolveRetryPolicy
|
|
73564
73564
|
} from "@deepseek-ai/dsh-llm";
|
|
73565
73565
|
import { idleWatchdog, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
73566
|
+
import { promisify } from "node:util";
|
|
73567
|
+
import { constants as zlibConstants, gzip as gzipCallback } from "node:zlib";
|
|
73566
73568
|
|
|
73567
73569
|
// src/catalog/index.ts
|
|
73568
73570
|
init_models();
|
|
@@ -75757,6 +75759,10 @@ var fields = {
|
|
|
75757
75759
|
maxTokens: Schema.union([Schema.const(null), Schema.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER)])
|
|
75758
75760
|
})])).default({}),
|
|
75759
75761
|
modelProtocols: Schema.dict(Schema.string()).default({}),
|
|
75762
|
+
// On by default, off is the whole fallback plan: if the gateway ever
|
|
75763
|
+
// rejects a compressed body, one switch returns every request to plain
|
|
75764
|
+
// JSON with no other change.
|
|
75765
|
+
requestGzip: Schema.boolean().default(true),
|
|
75760
75766
|
// On by default: recording costs one call and one boolean per request
|
|
75761
75767
|
// plus a bounded ring, and buys a per-request trail whenever something
|
|
75762
75768
|
// looks wrong. Off returns the request path to exactly as without the
|
|
@@ -76610,6 +76616,21 @@ function bodyBytes(body) {
|
|
|
76610
76616
|
if (ArrayBuffer.isView(body)) return body.byteLength;
|
|
76611
76617
|
return void 0;
|
|
76612
76618
|
}
|
|
76619
|
+
var MIN_GZIP_BODY_BYTES = 1024;
|
|
76620
|
+
var gzipAsync = promisify(gzipCallback);
|
|
76621
|
+
async function gzipBody(armed, input, init) {
|
|
76622
|
+
const original = init?.body;
|
|
76623
|
+
const originalBytes = bodyBytes(original ?? void 0);
|
|
76624
|
+
if (!armed || typeof input !== "string" && !(input instanceof URL) || originalBytes === void 0 || originalBytes < MIN_GZIP_BODY_BYTES || typeof original !== "string" && !(original instanceof ArrayBuffer) && !ArrayBuffer.isView(original)) {
|
|
76625
|
+
return { body: original ?? null, bytes: originalBytes, headers: void 0 };
|
|
76626
|
+
}
|
|
76627
|
+
const bytes = typeof original === "string" ? Buffer.from(original) : original instanceof ArrayBuffer ? Buffer.from(original) : Buffer.from(original.buffer, original.byteOffset, original.byteLength);
|
|
76628
|
+
const compressed = await gzipAsync(bytes, { level: zlibConstants.Z_BEST_SPEED });
|
|
76629
|
+
const headers = new Headers(init?.headers);
|
|
76630
|
+
headers.delete("content-length");
|
|
76631
|
+
headers.set("content-encoding", "gzip");
|
|
76632
|
+
return { body: compressed, bytes: compressed.byteLength, headers };
|
|
76633
|
+
}
|
|
76613
76634
|
async function* observingTerminalUsage(events, observe) {
|
|
76614
76635
|
for await (const event of events) {
|
|
76615
76636
|
if (event.type === "done") observe(event.message.usage);
|
|
@@ -76795,12 +76816,17 @@ var OpencodeGoAdapter = class extends LlmAdapter {
|
|
|
76795
76816
|
}
|
|
76796
76817
|
});
|
|
76797
76818
|
const fetchFactory = this.options.fetch;
|
|
76798
|
-
const requestFetch =
|
|
76819
|
+
const requestFetch = fetchFactory === void 0 || span === void 0 && !config.requestGzip ? fetchFactory : () => {
|
|
76799
76820
|
const base = fetchFactory();
|
|
76800
76821
|
return (async (input, init) => {
|
|
76801
|
-
const
|
|
76802
|
-
|
|
76803
|
-
|
|
76822
|
+
const outgoing = await gzipBody(config.requestGzip, input, init);
|
|
76823
|
+
const response = await base(input, {
|
|
76824
|
+
...init,
|
|
76825
|
+
...outgoing.body === void 0 ? {} : { body: outgoing.body },
|
|
76826
|
+
...outgoing.headers === void 0 ? {} : { headers: outgoing.headers }
|
|
76827
|
+
});
|
|
76828
|
+
span?.request(typeof init?.method === "string" ? init.method : "POST", requestUrl(input), outgoing.bytes);
|
|
76829
|
+
span?.status(response.status);
|
|
76804
76830
|
return response;
|
|
76805
76831
|
});
|
|
76806
76832
|
};
|
|
@@ -77925,7 +77951,7 @@ function createUpdateChecker(deps) {
|
|
|
77925
77951
|
}
|
|
77926
77952
|
|
|
77927
77953
|
// src/update/version.ts
|
|
77928
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
77954
|
+
var PLUGIN_VERSION = true ? "0.1.70" : "0.0.0-dev";
|
|
77929
77955
|
|
|
77930
77956
|
// src/update/service.ts
|
|
77931
77957
|
import { TypertRemoteService as TypertRemoteService4 } from "@deepseek-ai/dsh-typert-protocol";
|
package/lib/types/config.d.ts
CHANGED
|
@@ -75,6 +75,14 @@ export interface OpencodeGoConfig {
|
|
|
75
75
|
* The escape hatch for a model whose family rule guessed wrong.
|
|
76
76
|
*/
|
|
77
77
|
modelProtocols: Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Whether JSON request bodies of 1 KB or more are gzip-compressed before
|
|
80
|
+
* sending. On by default: the gateway is expected to accept
|
|
81
|
+
* `Content-Encoding: gzip`, and small bodies are never worth the overhead.
|
|
82
|
+
* If the gateway ever rejects compressed bodies, turn this off — the
|
|
83
|
+
* off switch is the whole fallback plan.
|
|
84
|
+
*/
|
|
85
|
+
requestGzip: boolean;
|
|
78
86
|
/**
|
|
79
87
|
* Whether the request log records anything at all. On by default: one
|
|
80
88
|
* call and one boolean per request, plus a bounded ring. Off returns the
|
package/package.json
CHANGED