@dan-ai-studio/dshopencodego 0.1.21 → 0.1.22
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 +2 -1
- package/README.md +2 -1
- package/lib/client.js +6 -6
- package/lib/index.js +10 -4
- package/lib/types/catalog/constants.d.ts +3 -1
- package/lib/types/catalog/constants.js +3 -1
- package/lib/types/catalog/index.d.ts +1 -1
- package/lib/types/catalog/index.js +1 -1
- package/lib/types/go-limits.js +1 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/index.js +4 -4
- package/lib/types/session-header.d.ts +5 -3
- package/lib/types/session-header.js +8 -4
- package/package.json +26 -26
package/README.en.md
CHANGED
|
@@ -83,7 +83,8 @@ Configuration lives in the profile's `cordis.patch.yml`:
|
|
|
83
83
|
config:
|
|
84
84
|
enabled: true # false withdraws the route only
|
|
85
85
|
apiKeyEnv: OPENCODE_GO_API_KEY # default
|
|
86
|
-
baseURL: https://opencode.ai/
|
|
86
|
+
baseURL: https://opencode.ai/inference/go/v1 # default (OpenCode Go endpoint, 37 subscription models)
|
|
87
|
+
# or https://opencode.ai/inference/v1 (Console main endpoint, 86 pay-as-you-go/free models)
|
|
87
88
|
refreshMinutes: 60 # live catalog TTL
|
|
88
89
|
modelVisibility: # per-model switches (deprecated default off)
|
|
89
90
|
glm-5: true
|
package/README.md
CHANGED
|
@@ -83,7 +83,8 @@ DSH 桌面端是 Electron 壳 + 完整的 dsh Web 应用,本插件对它同样
|
|
|
83
83
|
config:
|
|
84
84
|
enabled: true # false 仅撤下路由,插件保持挂载
|
|
85
85
|
apiKeyEnv: OPENCODE_GO_API_KEY # 默认值
|
|
86
|
-
baseURL: https://opencode.ai/
|
|
86
|
+
baseURL: https://opencode.ai/inference/go/v1 # 默认值(OpenCode Go 端点,37 个订阅模型)
|
|
87
|
+
# 也可指定为 https://opencode.ai/inference/v1(Console 主端点,包含 86 个按量/免费模型)
|
|
87
88
|
refreshMinutes: 60 # 目录缓存时长
|
|
88
89
|
modelVisibility: # 逐模型开关(弃用模型默认关闭)
|
|
89
90
|
glm-5: true
|
package/lib/client.js
CHANGED
|
@@ -453,16 +453,16 @@ function inputModalityLabels(model, t) {
|
|
|
453
453
|
return (model.inputModalities ?? []).map((modality) => t(MODALITY_KEYS[modality]));
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
// plugin-css
|
|
456
|
+
// plugin-css:D:\prj\dshopencodego\src\client\section.module.css
|
|
457
457
|
var id = "@dan-ai-studio/dshopencodego/section.module.css";
|
|
458
458
|
if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id) + "]")) {
|
|
459
459
|
const style = document.createElement("style");
|
|
460
460
|
style.dataset.plugin = "@dan-ai-studio/dshopencodego";
|
|
461
461
|
style.dataset.pluginCss = id;
|
|
462
|
-
style.textContent = ".
|
|
462
|
+
style.textContent = "._6tq0da_root{color:var(--dsw-alias-label-primary);flex-direction:column;gap:1.25rem;display:flex}._6tq0da_title{margin:0;font-size:1.05rem}._6tq0da_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:.8rem}._6tq0da_warn{color:var(--dsw-alias-state-warn-primary);margin:0;font-size:.8rem}._6tq0da_ok{color:var(--dsw-alias-state-success-primary);font-size:.8rem}._6tq0da_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}._6tq0da_row{flex-wrap:wrap;align-items:center;gap:.5rem;display:flex}._6tq0da_row>strong{margin-right:auto}._6tq0da_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}._6tq0da_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}._6tq0da_button:disabled{color:var(--dsw-alias-state-idle-primary);cursor:default}._6tq0da_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}._6tq0da_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}._6tq0da_list{flex-direction:column;display:flex}._6tq0da_item{border-top:1px solid var(--dsw-alias-border-l1);align-items:flex-start;gap:.5rem;padding:.45rem .15rem;display:flex}._6tq0da_item input[type=checkbox]{accent-color:var(--dsw-alias-brand-primary);margin-top:.15rem}._6tq0da_itemBody{flex-direction:column;gap:.15rem;min-width:0;display:flex}._6tq0da_itemMain{flex-wrap:wrap;align-items:baseline;gap:.6rem;display:flex}._6tq0da_itemMeta{color:var(--dsw-alias-label-secondary);flex-wrap:wrap;gap:.75rem;font-size:.75rem;display:flex}._6tq0da_itemModalities{color:var(--dsw-alias-label-secondary);font-size:.75rem}._6tq0da_name{color:var(--dsw-alias-label-primary)}._6tq0da_mono{color:var(--dsw-alias-label-secondary);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}._6tq0da_badge{color:var(--dsw-alias-brand-primary)}";
|
|
463
463
|
document.head.appendChild(style);
|
|
464
464
|
}
|
|
465
|
-
var section_default = { "
|
|
465
|
+
var section_default = { "item": "_6tq0da_item", "root": "_6tq0da_root", "input": "_6tq0da_input", "row": "_6tq0da_row", "itemMain": "_6tq0da_itemMain", "warn": "_6tq0da_warn", "badge": "_6tq0da_badge", "title": "_6tq0da_title", "block": "_6tq0da_block", "itemModalities": "_6tq0da_itemModalities", "mono": "_6tq0da_mono", "button": "_6tq0da_button", "hint": "_6tq0da_hint", "select": "_6tq0da_select", "name": "_6tq0da_name", "itemMeta": "_6tq0da_itemMeta", "list": "_6tq0da_list", "ok": "_6tq0da_ok", "itemBody": "_6tq0da_itemBody", "number": "_6tq0da_number" };
|
|
466
466
|
|
|
467
467
|
// src/client/Section.tsx
|
|
468
468
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -954,16 +954,16 @@ function Section({ controller, t, getLocale }) {
|
|
|
954
954
|
// src/client/UsagePill.tsx
|
|
955
955
|
var import_react2 = require("react");
|
|
956
956
|
|
|
957
|
-
// plugin-css
|
|
957
|
+
// plugin-css:D:\prj\dshopencodego\src\client\pill.module.css
|
|
958
958
|
var id2 = "@dan-ai-studio/dshopencodego/pill.module.css";
|
|
959
959
|
if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id2) + "]")) {
|
|
960
960
|
const style = document.createElement("style");
|
|
961
961
|
style.dataset.plugin = "@dan-ai-studio/dshopencodego";
|
|
962
962
|
style.dataset.pluginCss = id2;
|
|
963
|
-
style.textContent = ".
|
|
963
|
+
style.textContent = ".y-bZgq_root{align-items:center;display:inline-flex;position:relative}.y-bZgq_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}.y-bZgq_trigger:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2)}.y-bZgq_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}.y-bZgq_window{flex-direction:column;gap:.25rem;display:flex}.y-bZgq_row{justify-content:space-between;gap:.5rem;font-size:.85rem;display:flex}.y-bZgq_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:.75rem}.y-bZgq_progress{width:100%;height:.35rem;accent-color:var(--dsw-alias-brand-primary)}.y-bZgq_limited{color:var(--dsw-alias-state-warn-primary);font-size:.75rem}.y-bZgq_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}.y-bZgq_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}.y-bZgq_local{border-top:1px solid var(--dsw-alias-border-l1);flex-direction:column;gap:.2rem;padding-top:.5rem;display:flex}";
|
|
964
964
|
document.head.appendChild(style);
|
|
965
965
|
}
|
|
966
|
-
var pill_default = { "
|
|
966
|
+
var pill_default = { "hint": "y-bZgq_hint", "panel": "y-bZgq_panel", "warning": "y-bZgq_warning", "local": "y-bZgq_local", "progress": "y-bZgq_progress", "limited": "y-bZgq_limited", "retry": "y-bZgq_retry", "root": "y-bZgq_root", "trigger": "y-bZgq_trigger", "window": "y-bZgq_window", "row": "y-bZgq_row" };
|
|
967
967
|
|
|
968
968
|
// src/client/UsagePill.tsx
|
|
969
969
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
package/lib/index.js
CHANGED
|
@@ -73,7 +73,8 @@ import { attributionHeaders as attributionHeaders3, LlmError as LlmError4 } from
|
|
|
73
73
|
// src/catalog/constants.ts
|
|
74
74
|
var PROVIDER_ID = "opencode-go";
|
|
75
75
|
var DISPLAY_NAME = "OpenCode Go";
|
|
76
|
-
var DEFAULT_BASE_URL = "https://opencode.ai/
|
|
76
|
+
var DEFAULT_BASE_URL = "https://opencode.ai/inference/go/v1";
|
|
77
|
+
var CONSOLE_BASE_URL = "https://opencode.ai/inference/v1";
|
|
77
78
|
var MODEL_METADATA_URL = "https://models.dev/api.json";
|
|
78
79
|
var MODEL_METADATA_PROVIDER = "opencode-go";
|
|
79
80
|
var METADATA_FETCH_TIMEOUT_MS = 1e4;
|
|
@@ -1347,7 +1348,7 @@ var SEED_QUOTAS = {
|
|
|
1347
1348
|
"deepseek-v4-flash-vision-exp": { monthlyUsd: 15, monthlyRequests: 32500 },
|
|
1348
1349
|
"hy4-preview": { monthlyUsd: 30, monthlyRequests: 6770 },
|
|
1349
1350
|
"hy3": { monthlyUsd: 60, monthlyRequests: 21500 },
|
|
1350
|
-
|
|
1351
|
+
// 注意:space-bunny-free 并不在 Go 端点支持的 37 个模型列表中(请求会返回 400 错误),已依据 R-B4 予以剔除
|
|
1351
1352
|
"grok-4.7": { monthlyUsd: 15, monthlyRequests: 845 },
|
|
1352
1353
|
"grok-4.6": { monthlyUsd: 15, monthlyRequests: 845 },
|
|
1353
1354
|
"gpt-6-luna": { monthlyUsd: 15, monthlyRequests: 21130 },
|
|
@@ -1396,12 +1397,15 @@ function sortModels(models, now = Date.now()) {
|
|
|
1396
1397
|
import { randomUUID } from "node:crypto";
|
|
1397
1398
|
import { attributionHeaders as attributionHeaders4 } from "@deepseek-ai/dsh-llm";
|
|
1398
1399
|
var SESSION_HEADER = "x-opencode-session";
|
|
1400
|
+
var SESSION_AFFINITY_HEADER = "x-session-affinity";
|
|
1399
1401
|
function opencodeSessionValue(sessionId) {
|
|
1400
1402
|
return sessionId !== void 0 && sessionId.length > 0 ? sessionId : randomUUID();
|
|
1401
1403
|
}
|
|
1402
1404
|
function providerHeaders(sessionId) {
|
|
1405
|
+
const session = opencodeSessionValue(sessionId);
|
|
1403
1406
|
return {
|
|
1404
|
-
[SESSION_HEADER]:
|
|
1407
|
+
[SESSION_HEADER]: session,
|
|
1408
|
+
[SESSION_AFFINITY_HEADER]: session,
|
|
1405
1409
|
...attributionHeaders4()
|
|
1406
1410
|
};
|
|
1407
1411
|
}
|
|
@@ -2195,7 +2199,7 @@ function apply(ctx, raw) {
|
|
|
2195
2199
|
const undiscover = ctx.llm.registerModelDiscovery(name, async (request) => {
|
|
2196
2200
|
if (request.provider !== PROVIDER_ID && !(request.baseURL ?? "").includes("opencode.ai")) {
|
|
2197
2201
|
throw new LlmError12(
|
|
2198
|
-
"dshopencodego discovers only OpenCode
|
|
2202
|
+
"dshopencodego discovers only OpenCode Go/Console endpoints; enter this provider's models by hand",
|
|
2199
2203
|
"DISCOVERY_UNSUPPORTED"
|
|
2200
2204
|
);
|
|
2201
2205
|
}
|
|
@@ -2220,6 +2224,7 @@ function apply(ctx, raw) {
|
|
|
2220
2224
|
ctx.logger.info(`dshopencodego: route "${PROVIDER_ID}" registered as ${DISPLAY_NAME}`);
|
|
2221
2225
|
}
|
|
2222
2226
|
export {
|
|
2227
|
+
CONSOLE_BASE_URL,
|
|
2223
2228
|
Config,
|
|
2224
2229
|
DEFAULT_API_KEY_ENV,
|
|
2225
2230
|
DEFAULT_BASE_URL,
|
|
@@ -2228,6 +2233,7 @@ export {
|
|
|
2228
2233
|
OpencodeGoCatalog,
|
|
2229
2234
|
PROVIDER_ID,
|
|
2230
2235
|
PlainConfig,
|
|
2236
|
+
SESSION_AFFINITY_HEADER,
|
|
2231
2237
|
SESSION_HEADER,
|
|
2232
2238
|
apply,
|
|
2233
2239
|
assertBaseURL,
|
|
@@ -4,7 +4,9 @@ export declare const PROVIDER_ID = "opencode-go";
|
|
|
4
4
|
/** Selector label for the route. */
|
|
5
5
|
export declare const DISPLAY_NAME = "OpenCode Go";
|
|
6
6
|
/** Gateway base URL; `/models` and `/usage` hang off it. */
|
|
7
|
-
export declare const DEFAULT_BASE_URL = "https://opencode.ai/
|
|
7
|
+
export declare const DEFAULT_BASE_URL = "https://opencode.ai/inference/go/v1";
|
|
8
|
+
/** Console base URL (on-demand / free models, pay-as-you-go). */
|
|
9
|
+
export declare const CONSOLE_BASE_URL = "https://opencode.ai/inference/v1";
|
|
8
10
|
/** Online model metadata: capability, lifecycle, and pricing per model id. */
|
|
9
11
|
export declare const MODEL_METADATA_URL = "https://models.dev/api.json";
|
|
10
12
|
/** The models.dev provider key this plugin reads. */
|
|
@@ -4,7 +4,9 @@ export const PROVIDER_ID = 'opencode-go';
|
|
|
4
4
|
/** Selector label for the route. */
|
|
5
5
|
export const DISPLAY_NAME = 'OpenCode Go';
|
|
6
6
|
/** Gateway base URL; `/models` and `/usage` hang off it. */
|
|
7
|
-
export const DEFAULT_BASE_URL = 'https://opencode.ai/
|
|
7
|
+
export const DEFAULT_BASE_URL = 'https://opencode.ai/inference/go/v1';
|
|
8
|
+
/** Console base URL (on-demand / free models, pay-as-you-go). */
|
|
9
|
+
export const CONSOLE_BASE_URL = 'https://opencode.ai/inference/v1';
|
|
8
10
|
/** Online model metadata: capability, lifecycle, and pricing per model id. */
|
|
9
11
|
export const MODEL_METADATA_URL = 'https://models.dev/api.json';
|
|
10
12
|
/** The models.dev provider key this plugin reads. */
|
|
@@ -23,7 +23,7 @@ import type { LlmDiscoveredModel } from '@deepseek-ai/dsh-llm';
|
|
|
23
23
|
import type { GoDoc } from './go-doc.ts';
|
|
24
24
|
import type { ModelDefaults, ModelFacts } from './metadata.ts';
|
|
25
25
|
import type { GoQuota } from '../go-limits.ts';
|
|
26
|
-
export { PROVIDER_ID, DISPLAY_NAME, DEFAULT_BASE_URL } from './constants.ts';
|
|
26
|
+
export { PROVIDER_ID, DISPLAY_NAME, DEFAULT_BASE_URL, CONSOLE_BASE_URL } from './constants.ts';
|
|
27
27
|
export { readModelIds, fetchModelIds } from './gateway.ts';
|
|
28
28
|
export { readOnlineMetadata, toPiModel, modelBaseURL } from './metadata.ts';
|
|
29
29
|
export type { ModelFacts, OnlineMetadata, ModelDefaults } from './metadata.ts';
|
|
@@ -29,7 +29,7 @@ import { fetchModelIds } from "./gateway.js";
|
|
|
29
29
|
import { fetchGoDocument, GO_DOC_URLS } from "./go-doc.js";
|
|
30
30
|
import { readBoundedJson } from "./json-response.js";
|
|
31
31
|
import { readOnlineMetadata, toPiModel } from "./metadata.js";
|
|
32
|
-
export { PROVIDER_ID, DISPLAY_NAME, DEFAULT_BASE_URL } from "./constants.js";
|
|
32
|
+
export { PROVIDER_ID, DISPLAY_NAME, DEFAULT_BASE_URL, CONSOLE_BASE_URL } from "./constants.js";
|
|
33
33
|
export { readModelIds, fetchModelIds } from "./gateway.js";
|
|
34
34
|
export { readOnlineMetadata, toPiModel, modelBaseURL } from "./metadata.js";
|
|
35
35
|
export { decideProtocol, inferProtocol, protocolOfNpm } from "./protocol.js";
|
package/lib/types/go-limits.js
CHANGED
|
@@ -58,7 +58,7 @@ export const SEED_QUOTAS = {
|
|
|
58
58
|
'deepseek-v4-flash-vision-exp': { monthlyUsd: 15, monthlyRequests: 32_500 },
|
|
59
59
|
'hy4-preview': { monthlyUsd: 30, monthlyRequests: 6_770 },
|
|
60
60
|
'hy3': { monthlyUsd: 60, monthlyRequests: 21_500 },
|
|
61
|
-
|
|
61
|
+
// 注意:space-bunny-free 并不在 Go 端点支持的 37 个模型列表中(请求会返回 400 错误),已依据 R-B4 予以剔除
|
|
62
62
|
'grok-4.7': { monthlyUsd: 15, monthlyRequests: 845 },
|
|
63
63
|
'grok-4.6': { monthlyUsd: 15, monthlyRequests: 845 },
|
|
64
64
|
'gpt-6-luna': { monthlyUsd: 15, monthlyRequests: 21_130 },
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* config:
|
|
20
20
|
* enabled: true # false withdraws the route only
|
|
21
21
|
* apiKeyEnv: OPENCODE_GO_API_KEY # default
|
|
22
|
-
* baseURL: https://opencode.ai/
|
|
22
|
+
* baseURL: https://opencode.ai/inference/go/v1 # default
|
|
23
23
|
* refreshMinutes: 60 # live catalog TTL
|
|
24
24
|
* modelProtocols: # last-resort protocol override
|
|
25
25
|
* some-model: openai-responses
|
|
@@ -35,10 +35,10 @@ declare module '@deepseek-ai/cordis' {
|
|
|
35
35
|
}
|
|
36
36
|
export { OpencodeGoAdapter } from './adapter.ts';
|
|
37
37
|
export type { OpencodeGoAdapterOptions, OpencodeGoImageAccess } from './adapter.ts';
|
|
38
|
-
export { DEFAULT_BASE_URL, DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog, discoverCatalogModels } from './catalog/index.ts';
|
|
38
|
+
export { DEFAULT_BASE_URL, CONSOLE_BASE_URL, DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog, discoverCatalogModels } from './catalog/index.ts';
|
|
39
39
|
export { Config, PlainConfig, assertBaseURL, DEFAULT_API_KEY_ENV } from './config.ts';
|
|
40
40
|
export type { OpencodeGoConfig } from './config.ts';
|
|
41
|
-
export { SESSION_HEADER, opencodeSessionValue, providerHeaders } from './session-header.ts';
|
|
41
|
+
export { SESSION_HEADER, SESSION_AFFINITY_HEADER, opencodeSessionValue, providerHeaders } from './session-header.ts';
|
|
42
42
|
export { isModelEnabled, sortModels } from './models.ts';
|
|
43
43
|
export type { ModelSummary } from './models.ts';
|
|
44
44
|
export declare const name = "dshopencodego";
|
package/lib/types/index.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* config:
|
|
20
20
|
* enabled: true # false withdraws the route only
|
|
21
21
|
* apiKeyEnv: OPENCODE_GO_API_KEY # default
|
|
22
|
-
* baseURL: https://opencode.ai/
|
|
22
|
+
* baseURL: https://opencode.ai/inference/go/v1 # default
|
|
23
23
|
* refreshMinutes: 60 # live catalog TTL
|
|
24
24
|
* modelProtocols: # last-resort protocol override
|
|
25
25
|
* some-model: openai-responses
|
|
@@ -38,9 +38,9 @@ import { registerRemotes } from "./remotes.js";
|
|
|
38
38
|
import { OpencodeGoCatalogService } from "./catalog/service.js";
|
|
39
39
|
import { OpencodeGoUsageService, UsageMeter } from "./usage/index.js";
|
|
40
40
|
export { OpencodeGoAdapter } from "./adapter.js";
|
|
41
|
-
export { DEFAULT_BASE_URL, DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog, discoverCatalogModels } from "./catalog/index.js";
|
|
41
|
+
export { DEFAULT_BASE_URL, CONSOLE_BASE_URL, DISPLAY_NAME, PROVIDER_ID, OpencodeGoCatalog, discoverCatalogModels } from "./catalog/index.js";
|
|
42
42
|
export { Config, PlainConfig, assertBaseURL, DEFAULT_API_KEY_ENV } from "./config.js";
|
|
43
|
-
export { SESSION_HEADER, opencodeSessionValue, providerHeaders } from "./session-header.js";
|
|
43
|
+
export { SESSION_HEADER, SESSION_AFFINITY_HEADER, opencodeSessionValue, providerHeaders } from "./session-header.js";
|
|
44
44
|
export { isModelEnabled, sortModels } from "./models.js";
|
|
45
45
|
export const name = 'dshopencodego';
|
|
46
46
|
export const inject = ['llm'];
|
|
@@ -166,7 +166,7 @@ export function apply(ctx, raw) {
|
|
|
166
166
|
syncRoute();
|
|
167
167
|
const undiscover = ctx.llm.registerModelDiscovery(name, async (request) => {
|
|
168
168
|
if (request.provider !== PROVIDER_ID && !(request.baseURL ?? '').includes('opencode.ai')) {
|
|
169
|
-
throw new LlmError('dshopencodego discovers only OpenCode
|
|
169
|
+
throw new LlmError('dshopencodego discovers only OpenCode Go/Console endpoints; enter this provider\'s models by hand', 'DISCOVERY_UNSUPPORTED');
|
|
170
170
|
}
|
|
171
171
|
return discoverCatalogModels(adapter.catalogOf(current()));
|
|
172
172
|
});
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
/** Header name the gateway requires. */
|
|
19
19
|
export declare const SESSION_HEADER = "x-opencode-session";
|
|
20
|
+
/** Session affinity header for gateway routing and prompt caching. */
|
|
21
|
+
export declare const SESSION_AFFINITY_HEADER = "x-session-affinity";
|
|
20
22
|
/**
|
|
21
23
|
* The header value for one request.
|
|
22
24
|
* @param sessionId - the request's session id, if it names one.
|
|
@@ -27,9 +29,9 @@ export declare function opencodeSessionValue(sessionId: string | undefined): str
|
|
|
27
29
|
* Every header one provider request carries.
|
|
28
30
|
*
|
|
29
31
|
* The attribution `user-agent` is Harness-owned and always present; the session
|
|
30
|
-
*
|
|
31
|
-
* never win, because the gateway's routing decision must follow
|
|
32
|
-
* not a deployment string.
|
|
32
|
+
* and affinity headers are added on top of it. A caller-supplied header of the
|
|
33
|
+
* same name can never win, because the gateway's routing decision must follow
|
|
34
|
+
* the session, not a deployment string.
|
|
33
35
|
* @param sessionId - the request's session id, if it names one.
|
|
34
36
|
* @returns headers for the pi-ai request options.
|
|
35
37
|
*/
|
|
@@ -19,6 +19,8 @@ import { randomUUID } from 'node:crypto';
|
|
|
19
19
|
import { attributionHeaders } from '@deepseek-ai/dsh-llm';
|
|
20
20
|
/** Header name the gateway requires. */
|
|
21
21
|
export const SESSION_HEADER = 'x-opencode-session';
|
|
22
|
+
/** Session affinity header for gateway routing and prompt caching. */
|
|
23
|
+
export const SESSION_AFFINITY_HEADER = 'x-session-affinity';
|
|
22
24
|
/**
|
|
23
25
|
* The header value for one request.
|
|
24
26
|
* @param sessionId - the request's session id, if it names one.
|
|
@@ -31,15 +33,17 @@ export function opencodeSessionValue(sessionId) {
|
|
|
31
33
|
* Every header one provider request carries.
|
|
32
34
|
*
|
|
33
35
|
* The attribution `user-agent` is Harness-owned and always present; the session
|
|
34
|
-
*
|
|
35
|
-
* never win, because the gateway's routing decision must follow
|
|
36
|
-
* not a deployment string.
|
|
36
|
+
* and affinity headers are added on top of it. A caller-supplied header of the
|
|
37
|
+
* same name can never win, because the gateway's routing decision must follow
|
|
38
|
+
* the session, not a deployment string.
|
|
37
39
|
* @param sessionId - the request's session id, if it names one.
|
|
38
40
|
* @returns headers for the pi-ai request options.
|
|
39
41
|
*/
|
|
40
42
|
export function providerHeaders(sessionId) {
|
|
43
|
+
const session = opencodeSessionValue(sessionId);
|
|
41
44
|
return {
|
|
42
|
-
[SESSION_HEADER]:
|
|
45
|
+
[SESSION_HEADER]: session,
|
|
46
|
+
[SESSION_AFFINITY_HEADER]: session,
|
|
43
47
|
...attributionHeaders(),
|
|
44
48
|
};
|
|
45
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dan-ai-studio/dshopencodego",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "OpenCode Go provider for DeepSeek Harness: live gateway catalog, per-conversation session header, usage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": "^22.19.0 || >=24.0.0",
|
|
18
|
-
"dsh": ">=0.1.7-alpha.1 <0.2.0 || >=0.2.0-rc.1 <0.3.0"
|
|
18
|
+
"dsh": ">=0.1.7-alpha.1 <0.2.0 || >=0.2.0-rc.1 <0.2.1 || >=0.2.1-alpha.1 <0.3.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "./lib/index.js",
|
|
21
21
|
"types": "./lib/types/index.d.ts",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"prepack": "npm run build"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@deepseek-ai/schemastery": "~3.18.5-alpha.
|
|
70
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.2",
|
|
71
71
|
"@earendil-works/pi-ai": "~1.0.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@deepseek-ai/cordis": "4.0.2 || 4.0.3 || 4.0.4 || 4.0.5-alpha.1",
|
|
74
|
+
"@deepseek-ai/cordis": "4.0.2 || 4.0.3 || 4.0.4 || 4.0.5-alpha.1 || 4.0.5-alpha.2",
|
|
75
75
|
"@deepseek-ai/dsh-api-remotes": ">=0.1.7-alpha.1 <0.2.0 || >=0.2.0-rc.1 <0.3.0",
|
|
76
76
|
"@deepseek-ai/dsh-attachment": ">=0.1.7-alpha.1 <0.2.0 || >=0.2.0-rc.1 <0.3.0",
|
|
77
77
|
"@deepseek-ai/dsh-brand": ">=0.1.7-alpha.1 <0.2.0 || >=0.2.0-rc.1 <0.3.0",
|
|
@@ -111,28 +111,28 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@deepseek-ai/cordis": "4.0.5-alpha.
|
|
115
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.1-alpha.
|
|
116
|
-
"@deepseek-ai/dsh-attachment": "0.2.1-alpha.
|
|
117
|
-
"@deepseek-ai/dsh-brand": "0.2.1-alpha.
|
|
118
|
-
"@deepseek-ai/dsh-client-locale": "0.2.1-alpha.
|
|
119
|
-
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.
|
|
120
|
-
"@deepseek-ai/dsh-client-ui-conversation": "
|
|
121
|
-
"@deepseek-ai/dsh-client-ui-model-selection": "0.2.1-alpha.
|
|
122
|
-
"@deepseek-ai/dsh-client-ui-renderer": "
|
|
123
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-alpha.
|
|
124
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.
|
|
125
|
-
"@deepseek-ai/dsh-credentials": "0.2.1-alpha.
|
|
126
|
-
"@deepseek-ai/dsh-fs": "0.2.1-alpha.
|
|
127
|
-
"@deepseek-ai/dsh-launch-environment": "0.2.1-alpha.
|
|
128
|
-
"@deepseek-ai/dsh-llm": "0.2.1-alpha.
|
|
129
|
-
"@deepseek-ai/dsh-sandbox": "0.2.1-alpha.
|
|
130
|
-
"@deepseek-ai/dsh-scope": "0.2.1-alpha.
|
|
131
|
-
"@deepseek-ai/dsh-session": "0.2.1-alpha.
|
|
132
|
-
"@deepseek-ai/dsh-settings": "0.2.1-alpha.
|
|
133
|
-
"@deepseek-ai/dsh-timeout": "0.2.1-alpha.
|
|
134
|
-
"@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.
|
|
135
|
-
"@deepseek-ai/dsh-typert-registry": "
|
|
114
|
+
"@deepseek-ai/cordis": "4.0.5-alpha.2",
|
|
115
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.1-alpha.3",
|
|
116
|
+
"@deepseek-ai/dsh-attachment": "0.2.1-alpha.3",
|
|
117
|
+
"@deepseek-ai/dsh-brand": "0.2.1-alpha.3",
|
|
118
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-alpha.3",
|
|
119
|
+
"@deepseek-ai/dsh-client-store": "0.2.1-alpha.3",
|
|
120
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-alpha.3",
|
|
121
|
+
"@deepseek-ai/dsh-client-ui-model-selection": "0.2.1-alpha.3",
|
|
122
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.3",
|
|
123
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.1-alpha.3",
|
|
124
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.3",
|
|
125
|
+
"@deepseek-ai/dsh-credentials": "0.2.1-alpha.3",
|
|
126
|
+
"@deepseek-ai/dsh-fs": "0.2.1-alpha.3",
|
|
127
|
+
"@deepseek-ai/dsh-launch-environment": "0.2.1-alpha.3",
|
|
128
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
|
|
129
|
+
"@deepseek-ai/dsh-sandbox": "0.2.1-alpha.3",
|
|
130
|
+
"@deepseek-ai/dsh-scope": "0.2.1-alpha.3",
|
|
131
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.3",
|
|
132
|
+
"@deepseek-ai/dsh-settings": "0.2.1-alpha.3",
|
|
133
|
+
"@deepseek-ai/dsh-timeout": "0.2.1-alpha.3",
|
|
134
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.3",
|
|
135
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.1-alpha.3",
|
|
136
136
|
"@testing-library/dom": "^10.4.1",
|
|
137
137
|
"@testing-library/react": "^16.3.0",
|
|
138
138
|
"@types/node": "^22.20.0",
|