dsh-codearts 1.3.0 → 1.4.1

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.
@@ -1,5 +1,5 @@
1
- import { c as writeJsonAtomic, i as codeartsAccountsPath, l as defaultLoginConfig, s as readAccountDocument, u as refreshToken } from "./auth-CF9XHMX-.mjs";
2
- import { a as keeperLogPath, f as stopRequested, i as clearKeeperState, l as readKeeperState, p as writeKeeperState, r as KEEPER_TICK_MS, s as keeperStatePath, t as KEEPER_HEARTBEAT_MS } from "./keeper-P4FkDUEd.mjs";
1
+ import { d as OAuthTokenError, f as defaultLoginConfig, i as codeartsAccountsPath, l as readAccountDocument, p as refreshToken, u as writeJsonAtomic } from "./auth-C00dJphV.mjs";
2
+ import { a as keeperLogPath, f as stopRequested, i as clearKeeperState, l as readKeeperState, p as writeKeeperState, r as KEEPER_TICK_MS, s as keeperStatePath, t as KEEPER_HEARTBEAT_MS } from "./keeper-MHeAp_eV.mjs";
3
3
  import { appendFileSync, existsSync, unlinkSync } from "node:fs";
4
4
  //#region src/keeper-main.ts
5
5
  /**
@@ -115,13 +115,24 @@ async function tick(state) {
115
115
  refreshed += 1;
116
116
  log(`refreshed ${id.slice(0, 12)} → expires ${next.expiration}`);
117
117
  } catch (error) {
118
- doc.accounts[id] = {
119
- ...cred,
120
- stale: true
121
- };
122
- dirty = true;
123
- needsLogin.push(id);
124
- log(`refresh FAILED ${id.slice(0, 12)}: ${error instanceof Error ? error.message : String(error)}`);
118
+ const used = error instanceof OAuthTokenError && error.refreshTokenUsed;
119
+ if (used) {
120
+ const fresh = await readAccountDocument(accountsPath);
121
+ const advanced = fresh !== void 0 && fresh.accounts[id]?.refreshToken !== void 0 && fresh.accounts[id]?.refreshToken !== cred.refreshToken;
122
+ log(`refresh SKIPPED ${id.slice(0, 12)} (refresh token already used${advanced ? ", newer token on disk" : ""})`);
123
+ if (advanced) continue;
124
+ }
125
+ const permanent = !used && error instanceof OAuthTokenError && error.permanent;
126
+ if (permanent) {
127
+ doc.accounts[id] = {
128
+ ...cred,
129
+ stale: true
130
+ };
131
+ dirty = true;
132
+ needsLogin.push(id);
133
+ }
134
+ const reason = error instanceof OAuthTokenError ? `HTTP ${error.status} ${error.body.slice(0, 200)}` : error instanceof Error ? error.message : String(error);
135
+ log(`refresh FAILED ${id.slice(0, 12)} (${permanent ? "permanent, marked stale" : "transient, retry next pass"}): ${reason}`);
125
136
  }
126
137
  }
127
138
  if (dirty) await writeJsonAtomic(accountsPath, doc);
@@ -451,6 +451,7 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
451
451
  BENEFIT_MISSING_CODE: () => BENEFIT_MISSING_CODE,
452
452
  CONCURRENCY_CAP_CODE: () => CONCURRENCY_CAP_CODE,
453
453
  MAX_TOKENS_CEILING: () => MAX_TOKENS_CEILING,
454
+ MAX_TOKENS_FLOOR: () => MAX_TOKENS_FLOOR,
454
455
  PARAM_INVALID_CODE: () => PARAM_INVALID_CODE,
455
456
  SNAP_HOST: () => SNAP_HOST,
456
457
  TPM_LIMIT_CODE: () => TPM_LIMIT_CODE,
@@ -459,6 +460,7 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
459
460
  claimBenefit: () => claimBenefit,
460
461
  claimDailyWelfare: () => claimDailyWelfare,
461
462
  clearQueueStatus: () => clearQueueStatus,
463
+ contextWindowOverrideFor: () => contextWindowOverrideFor,
462
464
  degradeTokenCeiling: () => degradeTokenCeiling,
463
465
  estimateImageTokens: () => estimateImageTokens,
464
466
  estimatePromptTokens: () => estimatePromptTokens,
@@ -478,6 +480,8 @@ var upstream_exports = /* @__PURE__ */ __exportAll({
478
480
  isResignRefusal: () => isResignRefusal,
479
481
  isTpmLimit: () => isTpmLimit,
480
482
  isWelfareClaimedStatus: () => isWelfareClaimedStatus,
483
+ learnContextWindow: () => learnContextWindow,
484
+ learnedContextWindowFor: () => learnedContextWindowFor,
481
485
  maxTokensCeilingFor: () => maxTokensCeilingFor,
482
486
  modelUnavailableReasonText: () => modelUnavailableReasonText,
483
487
  pickDailyWelfareCampaign: () => pickDailyWelfareCampaign,
@@ -584,7 +588,12 @@ function isParamInvalidFrame(text) {
584
588
  * 免得该模型后面每一轮都先白撞一次。
585
589
  */
586
590
  const learnedMaxTokens = /* @__PURE__ */ new Map();
587
- /** 降档下限:再低就没有可用的生成长度了,此时宁可把具体错误报给用户。 */
591
+ /**
592
+ * 降档下限:再低就没有可用的生成长度了,此时宁可把具体错误报给用户。
593
+ *
594
+ * 导出是因为 shim 要拿它写报错文案(「max_tokens 已降到 8192 仍被拒」),文案里
595
+ * 的数字必须和真正的降档逻辑同源,不能在两处各写一个。
596
+ */
588
597
  const MAX_TOKENS_FLOOR = 8192;
589
598
  function ceilingKey(id) {
590
599
  return id.trim().toLowerCase();
@@ -598,11 +607,55 @@ function measuredCeilingFor(id) {
598
607
  */
599
608
  function degradeTokenCeiling(id) {
600
609
  const next = Math.floor(maxTokensCeilingFor(id) / 2);
601
- if (next < MAX_TOKENS_FLOOR) return 0;
610
+ if (next < 8192) return 0;
602
611
  learnedMaxTokens.set(ceilingKey(id), next);
603
612
  return next;
604
613
  }
605
614
  /**
615
+ * 本次进程内学到的「真实上下文窗口」上界(小写 id → tokens)。
616
+ *
617
+ * 目录值来自上游动态发现,但免费档真实窗口可能远小于标称、还会漂(issue #9:
618
+ * `deepseek-v4.1-flash-1017` 标称 1M、实测 ≈49 万,换一天又变)。上游对「装不下」
619
+ * 只回一句 InferHub.001001005.400,不说是哪个参数 —— 所以只能自己判:
620
+ * max_tokens 已经降到地板仍然被拒 ⇒ 不是 max_tokens 的问题,是 prompt 侧装不下
621
+ * ⇒ 把这次的 prompt 估算值记成该模型的上界。下一轮守卫就会在本地拦下来,并给出
622
+ * 指向上下文的报错,而不是让用户去猜「参数非法」。
623
+ *
624
+ * 与 learnedMaxTokens 一样是进程内状态:重启后第一次仍会白撞一次,之后立刻学会。
625
+ * 上游窗口只会收紧、不会放宽,所以取历史最小值,不被后面更大的估算抬高。
626
+ */
627
+ const learnedContextWindow = /* @__PURE__ */ new Map();
628
+ /** 该模型学到的真实窗口上界;没学过返回 undefined。 */
629
+ function learnedContextWindowFor(id) {
630
+ return learnedContextWindow.get(ceilingKey(id));
631
+ }
632
+ /**
633
+ * 记录一次「prompt 装不下」:把本次 prompt 估算值作为该模型的上界。
634
+ * @returns 学习后的上界(取历史最小值)
635
+ */
636
+ function learnContextWindow(id, promptTokens) {
637
+ const key = ceilingKey(id);
638
+ const measured = Math.max(1, Math.floor(promptTokens));
639
+ const previous = learnedContextWindow.get(key);
640
+ const learned = previous === void 0 ? measured : Math.min(previous, measured);
641
+ learnedContextWindow.set(key, learned);
642
+ return learned;
643
+ }
644
+ /**
645
+ * 从用户配置里取某模型的 contextWindow 覆盖值(id 大小写不敏感)。
646
+ *
647
+ * 非正数、NaN、Infinity 一律视为「没配」:这些值只会让守卫把每一次请求都判成
648
+ * 放不下,比目录值更糟。用户真要表达「不知道窗口」,删掉这个键即可。
649
+ */
650
+ function contextWindowOverrideFor(overrides, id) {
651
+ if (overrides === void 0) return void 0;
652
+ const key = ceilingKey(id);
653
+ for (const [rawKey, value] of Object.entries(overrides)) {
654
+ if (ceilingKey(rawKey) !== key) continue;
655
+ return Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
656
+ }
657
+ }
658
+ /**
606
659
  * 粗估一段**文本**占多少 token:CJK 每字约 1,其余每 4 字符约 1。
607
660
  *
608
661
  * 只要保守就够用 —— 它的用途是「在我们这边就把装不下的情况判掉」,
@@ -810,7 +863,8 @@ function prepareChatBody(rawJson, contextWindow = 0) {
810
863
  url: `${SNAP_HOST}${EP_CHAT}`,
811
864
  body: rawJson,
812
865
  model: "",
813
- chatId: ""
866
+ chatId: "",
867
+ promptTokens: 0
814
868
  };
815
869
  }
816
870
  const model = typeof parsed.model === "string" ? canonicalModel(parsed.model) : "";
@@ -837,11 +891,13 @@ function prepareChatBody(rawJson, contextWindow = 0) {
837
891
  if (body.stream_options === void 0 || typeof body.stream_options !== "object") body.stream_options = { include_usage: true };
838
892
  else body.stream_options.include_usage = true;
839
893
  if (body.max_tokens === void 0 && typeof parsed.max_completion_tokens === "number") body.max_tokens = parsed.max_completion_tokens;
894
+ /** 本次 prompt 的估算值:不管窗口知不知道都算,shim 要靠它学真实上界。 */
895
+ let promptTokens = 0;
840
896
  const ceiling = maxTokensCeilingFor(model);
841
897
  if (typeof body.max_tokens === "number") {
842
898
  let maxTokens = Math.min(body.max_tokens, ceiling);
899
+ promptTokens = estimatePromptTokens(body.messages, body.tools);
843
900
  if (contextWindow > 0) {
844
- const promptTokens = estimatePromptTokens(body.messages, body.tools);
845
901
  const room = contextWindow - promptTokens - PROMPT_ESTIMATE_MARGIN;
846
902
  if (room < MIN_USEFUL_OUTPUT_TOKENS) {
847
903
  body.max_tokens = maxTokens;
@@ -850,7 +906,8 @@ function prepareChatBody(rawJson, contextWindow = 0) {
850
906
  body: JSON.stringify(body),
851
907
  model,
852
908
  chatId,
853
- error: `上下文放不下:${model} 的窗口是 ${contextWindow} tokens,本次请求(含 ${Array.isArray(body.messages) ? body.messages.length : 0} 条消息与工具定义)估算约 ${promptTokens} tokens,剩余不足 ${MIN_USEFUL_OUTPUT_TOKENS} tokens 的生成余量。请新建会话或改用上下文更大的模型。`
909
+ promptTokens,
910
+ error: `上下文放不下:${model} 的窗口是 ${contextWindow} tokens,本次请求(含 ${Array.isArray(body.messages) ? body.messages.length : 0} 条消息与工具定义)估算约 ${promptTokens} tokens,剩余不足 ${MIN_USEFUL_OUTPUT_TOKENS} tokens 的生成余量。请新建会话或改用上下文更大的模型;如果目录里的窗口值不准,可在设置里覆盖该模型的 contextWindow。`
854
911
  };
855
912
  }
856
913
  maxTokens = Math.min(maxTokens, room);
@@ -877,7 +934,8 @@ function prepareChatBody(rawJson, contextWindow = 0) {
877
934
  url: `${SNAP_HOST}${EP_CHAT}`,
878
935
  body: JSON.stringify(body),
879
936
  model,
880
- chatId
937
+ chatId,
938
+ promptTokens
881
939
  };
882
940
  }
883
941
  /**
@@ -1605,11 +1663,13 @@ async function clearQueueStatus(credential, chatId, model, signal) {
1605
1663
  * `gateway/config` 给福利模型标的是 393216 / 384000,而聊天端点实测超过 65536
1606
1664
  * 就流内报 InferHub.001001005.400;DSH 会把 catalog 的 maxTokens 原样当
1607
1665
  * max_tokens 发出去,照抄标称值等于让每个请求都失败。
1608
- * - contextWindow 用发现值(只影响 DSH 的上下文计量与截断余量,不影响路由)。
1666
+ * - contextWindow 用发现值(只影响 DSH 的上下文计量与截断余量,不影响路由);
1667
+ * 用户配置的按模型覆盖值与进程内学到的真实上界在这里压过发现值(issue #9)。
1609
1668
  *
1669
+ * @param contextWindowOverrides 按模型 id 覆盖 contextWindow(大小写不敏感)
1610
1670
  * @throws 三路全失败,或合并结果为空。
1611
1671
  */
1612
- async function fetchModels(credential, signal) {
1672
+ async function fetchModels(credential, signal, contextWindowOverrides = {}) {
1613
1673
  const settled = await Promise.all([
1614
1674
  fetchBuiltinModels(credential, signal).then((models) => ({
1615
1675
  source: "builtin",
@@ -1659,11 +1719,17 @@ async function fetchModels(credential, signal) {
1659
1719
  return {
1660
1720
  models: merged.map((model) => {
1661
1721
  const thinking = variants.get(model.id.toLowerCase());
1722
+ const override = contextWindowOverrideFor(contextWindowOverrides, model.id);
1723
+ const learned = learnedContextWindowFor(model.id);
1724
+ const discovered = model.contextWindow > 0 ? model.contextWindow : UNKNOWN_CONTEXT_WINDOW;
1725
+ const base = override ?? discovered;
1726
+ const contextWindow = learned === void 0 ? base : Math.min(base, learned);
1662
1727
  return {
1663
1728
  ...model,
1664
1729
  ...thinking === void 0 ? {} : { thinking },
1665
- contextWindowKnown: model.contextWindow > 0,
1666
- contextWindow: model.contextWindow > 0 ? model.contextWindow : UNKNOWN_CONTEXT_WINDOW,
1730
+ contextWindowKnown: override !== void 0 || learned !== void 0 || model.contextWindow > 0,
1731
+ contextWindow,
1732
+ ...contextWindow === discovered ? {} : { contextWindowDiscovered: discovered },
1667
1733
  maxTokens: Math.min(model.maxTokens > 0 ? model.maxTokens : UNKNOWN_MAX_TOKENS, maxTokensCeilingFor(model.id))
1668
1734
  };
1669
1735
  }),
@@ -1886,4 +1952,4 @@ async function claimDailyWelfare(credential, signal) {
1886
1952
  };
1887
1953
  }
1888
1954
  //#endregion
1889
- export { clearBenefitBlocked as A, setDiscoveredBenefitModels as B, prepareChatBody as C, upstream_exports as D, upstreamErrorMessage as E, isBenefitModel as F, markModelUnavailable as I, mergeModelLists as L, filterEnabledModels as M, forgetModelUnavailable as N, CodeArtsCatalog as O, isBenefitBlocked as P, modelDisplayName as R, pickDailyWelfareCampaign as S, signedGet as T, isQueueableRate as _, clearQueueStatus as a, maxTokensCeilingFor as b, fetchModels as c, firstFrameError as d, isConcurrencyCap as f, isParamInvalidFrame as g, isNotMultimodal as h, claimDailyWelfare as i, creditRatioLabel as j, FALLBACK_CODEARTS_MODELS as k, fetchQueueStatus as l, isModelNotAccessible as m, canonicalModel as n, degradeTokenCeiling as o, isIamTokenError as p, chatStream as r, fetchCallerIdentity as s, SNAP_HOST as t, fetchWelfareCampaigns as u, isTpmLimit as v, rateLimitFrame as w, modelUnavailableReasonText as x, isWelfareClaimedStatus as y, modelUnavailableReason as z };
1955
+ export { upstreamErrorMessage as A, markModelUnavailable as B, learnedContextWindowFor as C, prepareChatBody as D, pickDailyWelfareCampaign as E, creditRatioLabel as F, modelDisplayName as H, filterEnabledModels as I, forgetModelUnavailable as L, CodeArtsCatalog as M, FALLBACK_CODEARTS_MODELS as N, rateLimitFrame as O, clearBenefitBlocked as P, isBenefitBlocked as R, learnContextWindow as S, modelUnavailableReasonText as T, modelUnavailableReason as U, mergeModelLists as V, setDiscoveredBenefitModels as W, isNotMultimodal as _, claimDailyWelfare as a, isTpmLimit as b, degradeTokenCeiling as c, fetchQueueStatus as d, fetchWelfareCampaigns as f, isModelNotAccessible as g, isIamTokenError as h, chatStream as i, upstream_exports as j, signedGet as k, fetchCallerIdentity as l, isConcurrencyCap as m, SNAP_HOST as n, clearQueueStatus as o, firstFrameError as p, canonicalModel as r, contextWindowOverrideFor as s, MAX_TOKENS_FLOOR as t, fetchModels as u, isParamInvalidFrame as v, maxTokensCeilingFor as w, isWelfareClaimedStatus as x, isQueueableRate as y, isBenefitModel as z };
@@ -1,9 +1,9 @@
1
- import { c as writeJsonAtomic } from "./auth-CF9XHMX-.mjs";
2
- import { B as setDiscoveredBenefitModels, F as isBenefitModel, L as mergeModelLists, R as modelDisplayName, c as fetchModels } from "./upstream-CVtspzAv.mjs";
1
+ import { u as writeJsonAtomic } from "./auth-C00dJphV.mjs";
2
+ import { H as modelDisplayName, V as mergeModelLists, W as setDiscoveredBenefitModels, u as fetchModels, z as isBenefitModel } from "./upstream-D1wYeXC7.mjs";
3
+ import { existsSync } from "node:fs";
3
4
  import { readFile } from "node:fs/promises";
4
5
  import { homedir } from "node:os";
5
6
  import { join } from "node:path";
6
- import { existsSync } from "node:fs";
7
7
  //#region src/discovery.ts
8
8
  /**
9
9
  * 动态模型发现:把「已登录账号」变成「当前可用模型清单」。
@@ -22,8 +22,9 @@ import { existsSync } from "node:fs";
22
22
  *
23
23
  * @param store 账号文档;逐个 `resolve()` 以拿到已续期的签名材料
24
24
  * @param signal 取消信号(宿主关停时用)
25
+ * @param contextWindowOverrides 用户按模型 id 配置的窗口覆盖值(issue #9)
25
26
  */
26
- async function discoverModels(store, signal) {
27
+ async function discoverModels(store, signal, contextWindowOverrides) {
27
28
  const ids = await store.ids();
28
29
  const accounts = [];
29
30
  for (const id of ids) {
@@ -46,7 +47,7 @@ async function discoverModels(store, signal) {
46
47
  continue;
47
48
  }
48
49
  try {
49
- const result = await fetchModels(resolved, signal);
50
+ const result = await fetchModels(resolved, signal, contextWindowOverrides);
50
51
  accounts.push({
51
52
  accountId: id,
52
53
  ...label === void 0 ? {} : { label },
@@ -81,8 +82,8 @@ async function discoverModels(store, signal) {
81
82
  *
82
83
  * @returns 提交后的目录;没有任何账号成功时返回 `undefined`(调用方保留原目录)
83
84
  */
84
- async function refreshCatalog(store, catalog, signal) {
85
- const outcome = await discoverModels(store, signal);
85
+ async function refreshCatalog(store, catalog, signal, contextWindowOverrides) {
86
+ const outcome = await discoverModels(store, signal, contextWindowOverrides);
86
87
  if (!outcome.anySucceeded || outcome.models.length === 0) return outcome;
87
88
  setDiscoveredBenefitModels(outcome.models.filter((model) => model.benefit === true).map((model) => model.id));
88
89
  catalog.set(outcome.models.map((model) => {
@@ -534,6 +535,6 @@ function percentileOf(buckets, ratio) {
534
535
  }
535
536
  //#endregion
536
537
  //#region src/version.ts
537
- const CODEARTS_VERSION = "1.3.0";
538
+ const CODEARTS_VERSION = "1.4.1";
538
539
  //#endregion
539
540
  export { refreshCatalog as a, discoverModels as i, CodeArtsUsageTracker as n, codeartsUsagePath as r, CODEARTS_VERSION as t };
package/package.json CHANGED
@@ -1,125 +1,125 @@
1
- {
2
- "name": "dsh-codearts",
3
- "displayName": "DSH CodeArts Connect",
4
- "description": "把华为云 CodeArts 接入 DeepSeek Harness —— 内置 OAuth2 登录(PKCE + DPoP),登录后即可在 DSH 对话窗口使用 CodeArts 的模型。",
5
- "version": "1.3.0",
6
- "packageManager": "pnpm@11.24.0",
7
- "author": "elegant01",
8
- "keywords": [
9
- "dsh-plugin",
10
- "deepseek-harness",
11
- "deepseek",
12
- "codearts",
13
- "huawei",
14
- "model-provider"
15
- ],
16
- "type": "module",
17
- "engines": {
18
- "node": "^22.19.0 || >=24.0.0"
19
- },
20
- "main": "lib/index.mjs",
21
- "types": "lib/index.d.mts",
22
- "bin": {
23
- "dsh-codearts": "lib/bin.mjs"
24
- },
25
- "scripts": {
26
- "build": "tsdown && node scripts/wrap-client.mjs",
27
- "test": "vitest run",
28
- "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.client.json",
29
- "check": "pnpm run typecheck && pnpm run test && pnpm run build",
30
- "deploy": "node scripts/deploy.mjs",
31
- "dev": "node scripts/dev.mjs",
32
- "hmr:on": "node scripts/hmr.mjs on",
33
- "hmr:off": "node scripts/hmr.mjs off",
34
- "hmr:status": "node scripts/hmr.mjs status"
35
- },
36
- "exports": {
37
- ".": {
38
- "types": "./lib/index.d.mts",
39
- "default": "./lib/index.mjs"
40
- },
41
- "./client": {
42
- "types": "./lib/client/index.d.cts",
43
- "default": "./lib/client/index.js"
44
- },
45
- "./cordis.patch.yml": "./cordis.patch.yml",
46
- "./package.json": "./package.json"
47
- },
48
- "files": [
49
- "lib",
50
- "cordis.patch.yml",
51
- "README.md",
52
- "README.en.md",
53
- "CHANGELOG.md",
54
- "INSTALL.md",
55
- "INSTALL.en.md",
56
- "DEV.md",
57
- "LICENSE"
58
- ],
59
- "license": "MIT",
60
- "repository": {
61
- "type": "git",
62
- "url": "git+https://github.com/elegant01/dsh-codearts.git"
63
- },
64
- "homepage": "https://github.com/elegant01/dsh-codearts#readme",
65
- "bugs": "https://github.com/elegant01/dsh-codearts/issues",
66
- "dsh": {
67
- "bundle": {
68
- "patch": "./cordis.patch.yml"
69
- },
70
- "client": {
71
- "inject": [
72
- "@deepseek-ai/dsh-client-ui-renderer",
73
- "@deepseek-ai/dsh-client-ui-settings-plugins",
74
- "@deepseek-ai/dsh-client-ui-conversation",
75
- "@deepseek-ai/dsh-client-ui-session",
76
- "@deepseek-ai/dsh-api-session-controller",
77
- "@deepseek-ai/dsh-client-locale"
78
- ],
79
- "external": [
80
- "@deepseek-ai/dsh-client-ui-primitives"
81
- ],
82
- "platform": "web"
83
- }
84
- },
85
- "peerDependencies": {
86
- "@deepseek-ai/cordis": "^4.0.2",
87
- "@deepseek-ai/dsh-atomic-write": ">=0.1.2-rc.1 <0.3.0-0",
88
- "@deepseek-ai/dsh-attachment": ">=0.1.2-rc.1 <0.3.0-0",
89
- "@deepseek-ai/dsh-home-paths": ">=0.1.2-rc.1 <0.3.0-0",
90
- "@deepseek-ai/dsh-host-webserver": ">=0.1.2-rc.1 <0.3.0-0",
91
- "@deepseek-ai/dsh-llm": ">=0.1.2-rc.1 <0.3.0-0",
92
- "@deepseek-ai/dsh-llm-pi-ai": ">=0.1.2-rc.1 <0.3.0-0",
93
- "@deepseek-ai/dsh-settings": ">=0.1.2-rc.1 <0.3.0-0",
94
- "@deepseek-ai/schemastery": "^3.18.2",
95
- "react": "^18.2.0"
96
- },
97
- "devDependencies": {
98
- "@deepseek-ai/cordis": "^4.0.2",
99
- "@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.2",
100
- "@deepseek-ai/dsh-atomic-write": "^0.2.1-rc.2",
101
- "@deepseek-ai/dsh-attachment": "^0.2.1-rc.2",
102
- "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.2",
103
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.2",
104
- "@deepseek-ai/dsh-client-ui-primitives": "^0.2.1-rc.2",
105
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.2",
106
- "@deepseek-ai/dsh-client-ui-session": "^0.2.1-rc.2",
107
- "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.2.1-rc.2",
108
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.2",
109
- "@deepseek-ai/dsh-credentials": "^0.2.1-rc.2",
110
- "@deepseek-ai/dsh-home-paths": "^0.2.1-rc.2",
111
- "@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.2",
112
- "@deepseek-ai/dsh-llm": "^0.2.1-rc.2",
113
- "@deepseek-ai/dsh-llm-pi-ai": "^0.2.1-rc.2",
114
- "@deepseek-ai/dsh-settings": "^0.2.1-rc.2",
115
- "@deepseek-ai/schemastery": "^3.18.2",
116
- "@earendil-works/pi-ai": "^1.3.0",
117
- "@types/node": "^22.20.4",
118
- "@types/react": "~18.3.1",
119
- "lightningcss": "^1.33.0",
120
- "react": "^18.2.0",
121
- "tsdown": "^0.22.2",
122
- "typescript": "^5.9.3",
123
- "vitest": "^4.1.8"
124
- }
125
- }
1
+ {
2
+ "name": "dsh-codearts",
3
+ "displayName": "DSH CodeArts Connect",
4
+ "description": "把华为云 CodeArts 接入 DeepSeek Harness —— 内置 OAuth2 登录(PKCE + DPoP),登录后即可在 DSH 对话窗口使用 CodeArts 的模型。",
5
+ "version": "1.4.1",
6
+ "packageManager": "pnpm@11.24.0",
7
+ "author": "elegant01",
8
+ "keywords": [
9
+ "dsh-plugin",
10
+ "deepseek-harness",
11
+ "deepseek",
12
+ "codearts",
13
+ "huawei",
14
+ "model-provider"
15
+ ],
16
+ "type": "module",
17
+ "engines": {
18
+ "node": "^22.19.0 || >=24.0.0"
19
+ },
20
+ "main": "lib/index.mjs",
21
+ "types": "lib/index.d.mts",
22
+ "bin": {
23
+ "dsh-codearts": "lib/bin.mjs"
24
+ },
25
+ "scripts": {
26
+ "build": "tsdown && node scripts/wrap-client.mjs",
27
+ "test": "vitest run",
28
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.client.json",
29
+ "check": "pnpm run typecheck && pnpm run test && pnpm run build",
30
+ "deploy": "node scripts/deploy.mjs",
31
+ "dev": "node scripts/dev.mjs",
32
+ "hmr:on": "node scripts/hmr.mjs on",
33
+ "hmr:off": "node scripts/hmr.mjs off",
34
+ "hmr:status": "node scripts/hmr.mjs status"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "types": "./lib/index.d.mts",
39
+ "default": "./lib/index.mjs"
40
+ },
41
+ "./client": {
42
+ "types": "./lib/client/index.d.cts",
43
+ "default": "./lib/client/index.js"
44
+ },
45
+ "./cordis.patch.yml": "./cordis.patch.yml",
46
+ "./package.json": "./package.json"
47
+ },
48
+ "files": [
49
+ "lib",
50
+ "cordis.patch.yml",
51
+ "README.md",
52
+ "README.en.md",
53
+ "CHANGELOG.md",
54
+ "INSTALL.md",
55
+ "INSTALL.en.md",
56
+ "DEV.md",
57
+ "LICENSE"
58
+ ],
59
+ "license": "MIT",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/elegant01/dsh-codearts.git"
63
+ },
64
+ "homepage": "https://github.com/elegant01/dsh-codearts#readme",
65
+ "bugs": "https://github.com/elegant01/dsh-codearts/issues",
66
+ "dsh": {
67
+ "bundle": {
68
+ "patch": "./cordis.patch.yml"
69
+ },
70
+ "client": {
71
+ "inject": [
72
+ "@deepseek-ai/dsh-client-ui-renderer",
73
+ "@deepseek-ai/dsh-client-ui-settings-plugins",
74
+ "@deepseek-ai/dsh-client-ui-conversation",
75
+ "@deepseek-ai/dsh-client-ui-session",
76
+ "@deepseek-ai/dsh-api-session-controller",
77
+ "@deepseek-ai/dsh-client-locale"
78
+ ],
79
+ "external": [
80
+ "@deepseek-ai/dsh-client-ui-primitives"
81
+ ],
82
+ "platform": "web"
83
+ }
84
+ },
85
+ "peerDependencies": {
86
+ "@deepseek-ai/cordis": "^4.0.2",
87
+ "@deepseek-ai/dsh-atomic-write": ">=0.1.2-rc.1 <0.3.0-0",
88
+ "@deepseek-ai/dsh-attachment": ">=0.1.2-rc.1 <0.3.0-0",
89
+ "@deepseek-ai/dsh-home-paths": ">=0.1.2-rc.1 <0.3.0-0",
90
+ "@deepseek-ai/dsh-host-webserver": ">=0.1.2-rc.1 <0.3.0-0",
91
+ "@deepseek-ai/dsh-llm": ">=0.1.2-rc.1 <0.3.0-0",
92
+ "@deepseek-ai/dsh-llm-pi-ai": ">=0.1.2-rc.1 <0.3.0-0",
93
+ "@deepseek-ai/dsh-settings": ">=0.1.2-rc.1 <0.3.0-0",
94
+ "@deepseek-ai/schemastery": "^3.18.2",
95
+ "react": "^18.2.0"
96
+ },
97
+ "devDependencies": {
98
+ "@deepseek-ai/cordis": "^4.0.2",
99
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.1-rc.2",
100
+ "@deepseek-ai/dsh-atomic-write": "^0.2.1-rc.2",
101
+ "@deepseek-ai/dsh-attachment": "^0.2.1-rc.2",
102
+ "@deepseek-ai/dsh-client-locale": "^0.2.1-rc.2",
103
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-rc.2",
104
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.1-rc.2",
105
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-rc.2",
106
+ "@deepseek-ai/dsh-client-ui-session": "^0.2.1-rc.2",
107
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.2.1-rc.2",
108
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.1-rc.2",
109
+ "@deepseek-ai/dsh-credentials": "^0.2.1-rc.2",
110
+ "@deepseek-ai/dsh-home-paths": "^0.2.1-rc.2",
111
+ "@deepseek-ai/dsh-host-webserver": "^0.2.1-rc.2",
112
+ "@deepseek-ai/dsh-llm": "^0.2.1-rc.2",
113
+ "@deepseek-ai/dsh-llm-pi-ai": "^0.2.1-rc.2",
114
+ "@deepseek-ai/dsh-settings": "^0.2.1-rc.2",
115
+ "@deepseek-ai/schemastery": "^3.18.2",
116
+ "@earendil-works/pi-ai": "^1.3.0",
117
+ "@types/node": "^22.20.4",
118
+ "@types/react": "~18.3.1",
119
+ "lightningcss": "^1.33.0",
120
+ "react": "^18.2.0",
121
+ "tsdown": "^0.22.2",
122
+ "typescript": "^5.9.3",
123
+ "vitest": "^4.1.8"
124
+ }
125
+ }
@@ -1,6 +1,6 @@
1
+ import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
1
2
  import { homedir } from "node:os";
2
3
  import { join } from "node:path";
3
- import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
4
4
  import { spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
6
6
  //#region src/keeper.ts