@eddyskywalker/dsh-chatgpt-subscription 0.9.2 → 0.9.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - **修复用户实测缺陷:选择 Claude Opus 5.5 必然失败(`claude_code_version_too_old`)**。上游原文:`Claude Code 2.1.251 does not support this model; version 2.1.280 or newer is required.` 那个 **2.1.251 是本插件自己申报的版本号**被服务端回显——本插件发布 `claude-opus-5-5`(该模型要求客户端 ≥ 2.1.280),却仍申报 2.1.251,两个数字自相矛盾,因此对该模型的每次请求都白花一个往返后被拒。**这是本插件引入的缺陷,与用户环境无关。**
6
+ - **根因不只是"数字写旧了"**:加模型与抬版本之间没有任何强制关系,所以同类缺陷会反复出现。修法分两层。
7
+ - **① 修正值与记录门槛**:`CLAUDE_CLI_VERSION` 由 `2.1.251` 改为 `2.1.283`(npm `latest` 的真实已发布版本,且 ≥ 2.1.280)。能力表新增可选字段 `minCliVersion`,**仅**给 `claude-opus-5-5` 填 `2.1.280`;其余 14 行**一律不填**,接口注释写明「缺省 = 未知门槛,不等于没有门槛」——不臆造无依据的数字。注:上游 npm `stable` tag 本身是 `2.1.274`,**低于该模型要求**,这正是 [anthropics/claude-code#96130](https://github.com/anthropics/claude-code/issues/96130) 报的坑。
8
+ - **② 本地预检,不再让上游报错**:新增 `assertClaudeCliVersionMeetsFloor()`,在 `requestStream()` **解析凭据之前、发起 fetch 之前**比较「生效版本 vs 该模型门槛」,低于则抛 `PROVIDER_ERROR`(**明确不是凭据错误**——错误文案直接写明「你的登录态仍然有效,重新登录不会改变它」,因为上游原文会误导用户去重新登录)。未记录门槛的模型行为不变;上游 400 分支保留,用于应对「本表尚未知的门槛」。
9
+ - **③ 加了会咬人的不变量锁**:测试断言「**申报的默认版本 ≥ 每一个模型的 `minCliVersion`**」,对**全表**遍历、且针对**申报常量本身**(不受 pin/环境变量影响),失败信息会同时点出两个版本号与修法。**我独立做了变异验证**:把 Opus 5.5 的门槛临时改成 `2.1.300`,测试立刻失败并输出 `CLAUDE_CLI_VERSION is 2.1.283 but claude-opus-5-5 requires 2.1.300 or newer…expected -17 to be greater than or equal to 0`;恢复后 22 项全绿。这条锁从此让「加了高门槛模型却忘抬版本」无法通过 CI。
10
+ - **排查过程中发现的另一件事**:npm 上 `0.9.0` 与 `0.9.2` **均已发布**,而**已发布的 0.9.2 仍然带着 `2.1.251` 且不含预检**(我拉了 tarball 核对)。同时 DSH web profile 通过软链接指向本仓库,而仓库的 `lib/` **是旧的**——所以运行中的插件确实跑的是有缺陷的构建。本次已重新 `npm run build`,构建产物现为 `2.1.283` + 预检(`lib` 由 .gitignore 覆盖,不入库)。
11
+ - **验证**:三个 tsconfig 均 **0 错误**;`npm test` **110 文件 / 1587 项通过、0 失败**;`npm run build` 成功。
12
+ - **临时可用的旁路**(无需等新版本):启动 DSH 前设 `DSH_CLAUDE_CLI_VERSION=2.1.283`。优先级为 pin > 环境变量 > 申报默认值。
13
+
14
+
5
15
  - **修复 Kimi Code 设置卡片「过一段时间就报 `rejected the stored credential (401)`」**:这不是登录态过期,而是**卡片拿着一个已经过期的 access token 去查用量**,并把服务端的 401 读成了「凭据被拒绝」。
6
16
  - **根因一:卡片从不刷新号池凭据**。`/status`、`/quota`、`/connection/test` 都把号池里的 credentials 原样交给 `fetchAccountQuota`,而它只在**没有**传入凭据时才会刷新——号池的刷新只发生在模型请求路径上(`getEffectiveAccount`)。Kimi 的 access token 只有 **900 秒**(实测本机凭据 `exp - iat = 900`),于是「15 分钟没发过 Kimi 消息」=「打开设置页必现 401」。实测本机两份存储:镜像里的 token 有效,号池里的 access token 已过期——正是这一条。
7
17
  - **根因二:同一枚轮换 refresh token 被两条路径各自刷新**。单凭据文件是号池主账号的**镜像**,但目录加载会绕过号池去刷它(`loadProviderModels` → `ensureAccessToken(store)`,且 stale-while-revalidate 会在后台再刷一次)。Kimi 的 refresh token 轮换后旧的即作废,于是镜像先刷成功就把号池那份变成死令牌;适配器下次刷新拿到 `invalid_grant`,账号被标 `authStatus=expired` 移出轮换,而进程内的「已拒绝」墓碑只在**重新登录**时清除——必须重新登录才能恢复。官方 CLI 正是为同一问题加了跨进程文件锁。
package/README.md CHANGED
@@ -424,6 +424,12 @@ DSH 设置页的「Subagent」卡片会把勾选的模型写成会话级的允
424
424
  「强制 effort」分支,若把 Opus 5.5 一并归入,就会**静默把每次请求抬高一档、花更多钱**,因此它走的是普通 adaptive
425
425
  分支。
426
426
 
427
+ 它还有一条**版本门槛**:上游要求申报的客户端版本 **≥ 2.1.280** 才为该模型提供服务。能力表用 `minCliVersion`
428
+ 记录这一点(**只有这一行有门槛**,其余 14 行缺省——缺省表示「未知」而不是「无门槛」,不臆造数字)。插件申报的
429
+ 默认版本为 **2.1.283**,并且**在发出请求之前就本地校验**「申报版本 vs 该模型门槛」,不满足时直接给出模型、当前
430
+ 版本与要求版本,**而不是白花一个往返让上游返回 400**。测试另有一条不变量:**申报的默认版本必须 ≥ 表中每个模型的
431
+ 门槛**——这条锁让「加了高门槛模型却忘了抬版本」无法通过 CI。
432
+
427
433
  ### 收编本机已有的 Claude Code 登录(可选,默认关闭)
428
434
 
429
435
  如果你本机已经登录过 Claude Code,可以点「收编本机登录」把它作为一条账号导入,省去再次登录。
@@ -559,7 +565,8 @@ npm pack --dry-run
559
565
  | Claude 相关接口返回 403 | 403 现在是**同源校验**的结果(修改状态的路由只接受同源 JSON POST)。若出现在浏览器里,检查是否从其它来源发起了请求;插件已不再有任何"确认后才能用"的门禁 |
560
566
  | 授权后粘贴授权码报「请把 # 后面的部分一起复制」 | 手动流程需要 `<授权码>#<state>` **整段**。只粘贴授权码是不被接受的:用流程自己的 state 顶上会架空 state 参数、把粘贴框变成登录 CSRF 的入口,因此插件宁可报错也不猜 |
561
567
  | loopback 回调收不到 / 端口绑定失败 | 端口探测失败会自动**降级为手动粘贴**(卡片会说明原因),照提示粘贴授权码即可。另:若浏览器把 `localhost` 解析到 `::1`,依赖浏览器的跨地址族回退可达本机 v4 监听,这是**假定**而非实测 |
562
- | 模型请求报持续 400 / 「You're out of extra usage」 | 可能是身份或版本门槛:订阅令牌要求 Claude Code 身份头与 `system` 首块,且服务端会校验你申报的客户端版本(过旧会答 `claude_code_version_too_old`)。可用 `DSH_CLAUDE_CLI_VERSION` 抬高申报版本;该错误被归类为**请求问题而非凭据问题**,不会把你登出 |
568
+ | 选择某个模型报 `claude_code_version_too_old`(例如 Opus 5.5 要求 2.1.280+) | 上游会校验本插件**申报的**客户端版本,新模型有各自的最低版本要求。插件现在会**在发出请求之前**本地拦下并告知模型、当前版本与要求版本(归类为**请求问题而非凭据问题**,**不会把你登出**——重新登录也不会有帮助)。用 `DSH_CLAUDE_CLI_VERSION` 抬高申报版本即可;已发布版本 ≥2.1.283 时 Opus 5.5 可直接使用 |
569
+ | 模型请求报持续 400 / 「You're out of extra usage」 | 可能是身份或版本门槛:订阅令牌要求 Claude Code 身份头与 `system` 首块,且服务端会校验你申报的客户端版本。此类错误被归类为**请求问题而非凭据问题**,不会把你登出 |
563
570
  | 额度显示为空 / 某项显示「—」 | 额度接口的键集随账号类型变化,未提供的窗口会显示为未知而**不会伪造 0**。注意 **`utilization` 是已用百分比,0% 表示尚未使用(正常态)**,不是额度耗尽;真正的耗尽会以 429 与响应头状态呈现。接口被限流时卡片保留上次成功快照并标注时间 |
564
571
  | 收编后提示「本机 Claude Code 登录已过期」 | 这是设计如此:收编的是**快照**,插件永不刷新它(Claude Code 刷新同一枚轮换令牌,两个进程各自刷新会互相作废)。回 Claude Code 重新登录后**再收编一次**即可 |
565
572
  | 账号被标为「无法识别账号身份」 | 服务端这个账号既没返回 uuid 也没返回 email,插件无法在再次登录时自动认出它。用卡片上的**手动合并**把它并入既有账号;这是已知限制,插件不会用假 id 掩盖它 |
package/lib/index.js CHANGED
@@ -21954,20 +21954,38 @@ const INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-14";
21954
21954
  /** Anthropic protocol revision sent as `anthropic-version`. */
21955
21955
  const ANTHROPIC_VERSION = "2023-06-01";
21956
21956
  /**
21957
- * Baseline client version this route reports to the subscription gateway.
21958
- *
21959
- * Upstream enforces a *minimum reported client version* on the subscription
21960
- * path: a value below the floor is refused with HTTP 400 and an error body whose
21961
- * code is `claude_code_version_too_old`. That is a hard stop for every request
21962
- * rather than a per-request failure, so it cannot be a compile-time literal that
21963
- * only moves when this package is republished — a user whose installed baseline
21964
- * has aged past the server's floor has to be able to raise it without waiting
21965
- * for a release.
21966
- *
21967
- * Read the effective value with {@link claudeCliVersion}, pin one with
21968
- * {@link setClaudeCliVersion}.
21969
- */
21970
- const CLAUDE_CLI_VERSION = "2.1.251";
21957
+ * Client version this route CLAIMS to be on the subscription gateway.
21958
+ *
21959
+ * Upstream enforces a *minimum reported client version* per model on the
21960
+ * subscription path: the version travels in the `user-agent` header (built by
21961
+ * `claudeUserAgent` in client.ts) and a claim below the floor is refused with
21962
+ * HTTP 400 and an error body whose code is `claude_code_version_too_old`. That
21963
+ * is a hard stop for the whole request rather than a per-request failure, and the
21964
+ * number in the refusal is OUR OWN claim echoed back — so the user is told their
21965
+ * client is too old without being told which model demanded more, which is
21966
+ * exactly how it misleads people into signing in again.
21967
+ *
21968
+ * THE INVARIANT THIS CONSTANT CARRIES. It must be at or above the highest
21969
+ * `minCliVersion` that any shipped model in `model-catalog.ts` declares. A
21970
+ * default below a shipped model's floor is a model this package advertises in
21971
+ * its own picker and then cannot call at all, which is the bug this comment now
21972
+ * records: `2.1.251` shipped while `claude-opus-5-5` — also shipped, and the
21973
+ * row the default picker leads with — requires `2.1.280`. The matching
21974
+ * regression lock lives in `test/claude-model-catalog.test.ts` and fails
21975
+ * loudly, naming both versions, when a future model's floor is added without
21976
+ * raising this value.
21977
+ *
21978
+ * The value is a REAL published `@anthropic-ai/claude-code` release, not a
21979
+ * number chosen merely to clear a floor: claiming a version that does not exist
21980
+ * trades a clear refusal for an unpredictable one. Note that npm's `stable`
21981
+ * dist-tag can itself sit below a model's floor, so `latest` is the tag to read.
21982
+ *
21983
+ * It is still not a literal that only moves when this package is republished: a
21984
+ * user whose installed baseline has aged past the server's floor has to be able
21985
+ * to raise it without waiting for a release. Read the effective value with
21986
+ * {@link claudeCliVersion}, pin one with {@link setClaudeCliVersion}.
21987
+ */
21988
+ const CLAUDE_CLI_VERSION = "2.1.283";
21971
21989
  /**
21972
21990
  * Loopback callback port the subscription flow defaults to.
21973
21991
  *
@@ -22069,6 +22087,67 @@ function setClaudeCliVersion(value) {
22069
22087
  cliVersionOverride = normalized === "" ? null : normalized;
22070
22088
  }
22071
22089
  /**
22090
+ * Compare two dotted numeric versions, e.g. `'2.1.283'` against `'2.1.280'`.
22091
+ *
22092
+ * This exists so a version FLOOR can be checked before a request is sent. The
22093
+ * comparison is deliberately small and TOTAL rather than a SemVer parser: the
22094
+ * only strings it ever sees are this line's own reported version (a pin, the
22095
+ * `DSH_CLAUDE_CLI_VERSION` override, or the shipped default) and the floors
22096
+ * recorded in the model catalog, and it must not throw on any of them — a
22097
+ * comparison that can throw would turn a misconfigured version into a crash
22098
+ * instead of the precise pre-flight refusal it was added to produce.
22099
+ *
22100
+ * Total means: a missing segment compares as 0 (`'2.1'` equals `'2.1.0'`), and a
22101
+ * segment that is not a run of decimal digits compares as 0 rather than as NaN
22102
+ * (`'abc'` equals `'0.0.0'`, and so does `''`). Leading zeros are exact rather
22103
+ * than octal, and an optional leading `v` is tolerated because that is how a
22104
+ * release is often written down.
22105
+ *
22106
+ * @returns a negative number, 0, or a positive number — the sign is the whole
22107
+ * contract, so callers compare against 0 rather than against ±1.
22108
+ */
22109
+ function compareDottedVersions(left, right) {
22110
+ const a = versionSegments(left);
22111
+ const b = versionSegments(right);
22112
+ const length = Math.max(a.length, b.length);
22113
+ for (let index = 0; index < length; index += 1) {
22114
+ const difference = (a[index] ?? 0) - (b[index] ?? 0);
22115
+ if (difference !== 0) return difference;
22116
+ }
22117
+ return 0;
22118
+ }
22119
+ /**
22120
+ * Whether one reported version clears a floor.
22121
+ *
22122
+ * An absent floor (`undefined`) means "no known floor" rather than "no floor",
22123
+ * so it never blocks a request: refusing a model because nobody recorded a
22124
+ * number would be this line inventing a restriction upstream never stated.
22125
+ * A MALFORMED version on either side, on the other hand, is refused — that is
22126
+ * the conservative direction, since the check exists to stop an unknown claim
22127
+ * from reaching a server that has already refused one.
22128
+ */
22129
+ function meetsDottedVersionFloor(version, floor) {
22130
+ if (floor === void 0 || floor.trim() === "") return true;
22131
+ if (!isDottedVersion(version)) return false;
22132
+ return compareDottedVersions(version, floor) >= 0;
22133
+ }
22134
+ /** Whether a string is a run of dot-separated decimal segments (an optional leading `v`). */
22135
+ function isDottedVersion(value) {
22136
+ const trimmed = value.trim().replace(/^v/i, "");
22137
+ return /^\d+(\.\d+)*$/.test(trimmed);
22138
+ }
22139
+ /** Numeric segments of a dotted version; a non-numeric or absent segment is 0. */
22140
+ function versionSegments(value) {
22141
+ const trimmed = value.trim().replace(/^v/i, "");
22142
+ if (trimmed === "") return [0];
22143
+ return trimmed.split(".").map((segment) => {
22144
+ const digits = /^\d+$/.test(segment.trim()) ? segment.trim() : "";
22145
+ if (digits === "") return 0;
22146
+ const parsed = Number.parseInt(digits, 10);
22147
+ return Number.isFinite(parsed) ? parsed : 0;
22148
+ });
22149
+ }
22150
+ /**
22072
22151
  * Resolve the browser authorization endpoint.
22073
22152
  *
22074
22153
  * The subscription flow has answered on more than one host, while its Console
@@ -22307,6 +22386,14 @@ function loopbackRedirectUri(port = DEFAULT_CALLBACK_PORT) {
22307
22386
  *
22308
22387
  * A future reader who notices the shared `supportsTemperature: false` and
22309
22388
  * "fixes" item 2 to 'mid-convo' has reintroduced exactly that bug.
22389
+ *
22390
+ * One more field on that row comes from neither source: its `minCliVersion`
22391
+ * floor is the number upstream itself states when it refuses the model
22392
+ * (`claude_code_version_too_old`, "version 2.1.280 or newer is required"). That
22393
+ * is a stronger witness than a documentation page — the server said it — and it
22394
+ * is recorded here so a claim below it is refused locally, before the request is
22395
+ * sent, instead of as an upstream 400 that names neither the model nor the number
22396
+ * the user has to reach.
22310
22397
  */
22311
22398
  /**
22312
22399
  * Fifteen rows: the snapshot's own 14, in the snapshot's own declaration order,
@@ -22577,7 +22664,8 @@ const CLAUDE_MODELS = Object.freeze([
22577
22664
  "xhigh",
22578
22665
  "max"
22579
22666
  ],
22580
- canDisableThinking: false
22667
+ canDisableThinking: false,
22668
+ minCliVersion: "2.1.280"
22581
22669
  }
22582
22670
  ]);
22583
22671
  /** Every id the fallback table knows, in declaration order. */
@@ -22681,6 +22769,24 @@ function claudeModelSupportsTemperature(modelId, catalog) {
22681
22769
  function claudeModelCanDisableThinking(modelId, catalog) {
22682
22770
  return resolveClaudeModel(modelId, catalog ?? CLAUDE_MODELS).canDisableThinking;
22683
22771
  }
22772
+ /**
22773
+ * Lowest reported client version upstream serves one model to, when known.
22774
+ *
22775
+ * `undefined` means "no known floor" — NOT "no floor" — so a caller must treat it
22776
+ * as "nothing to check" rather than as "any version is fine". The distinction
22777
+ * matters because the caller is a pre-flight refusal: an absent floor must let
22778
+ * the request through (refusing it would invent a restriction nobody recorded),
22779
+ * while a present floor must block a claim below it.
22780
+ *
22781
+ * Unlike the other per-model lookups this one does NOT resolve through the
22782
+ * conservative stub for an unknown id. The stub describes capabilities this line
22783
+ * assumes; a version floor is a fact about the server that this line either has
22784
+ * or has not observed, and manufacturing one for an unknown id would refuse a
22785
+ * model nobody has evidence against.
22786
+ */
22787
+ function claudeMinCliVersionFor(modelId, catalog) {
22788
+ return (catalog ?? CLAUDE_MODELS).find((model) => model.id === modelId)?.minCliVersion;
22789
+ }
22684
22790
  //#endregion
22685
22791
  //#region src/host/claude/token-store.ts
22686
22792
  /**
@@ -26804,7 +26910,11 @@ function cancelLogin() {
26804
26910
  * A reported-client-version rejection is a REQUEST problem even though it
26805
26911
  * arrives as a 400 that mentions the client: it must NOT sign the user out, and
26806
26912
  * it has a real remedy (raise the reported version), so it is handled
26807
- * explicitly with that remedy in the message.
26913
+ * explicitly with that remedy in the message. Where the catalog records a
26914
+ * model's floor, the same verdict is produced LOCALLY before the request is sent
26915
+ * ({@link assertClaudeCliVersionMeetsFloor}), so the ordinary case never spends
26916
+ * a request to be told the same thing less precisely; the upstream branch above
26917
+ * stays for a claim that is too low for a floor this table has not learned yet.
26808
26918
  *
26809
26919
  * ---------------------------------------------------------------------------
26810
26920
  * 5. ASSUMPTIONS AND JUDGEMENT CALLS
@@ -26891,6 +27001,46 @@ const MAX_COOLDOWN_MS = 300 * 60 * 1e3;
26891
27001
  /** What the user is told when this line has no credential to call with. */
26892
27002
  const MISSING_CREDENTIAL_MESSAGE = "Not signed in to Claude(订阅). Sign in from Settings > Claude.";
26893
27003
  /**
27004
+ * Refuse one model locally, before the request is sent, when the version this
27005
+ * route reports is below the floor that model declares.
27006
+ *
27007
+ * WHY THIS EXISTS. Upstream validates the reported client version — the
27008
+ * `user-agent` built by client.ts's `claudeUserAgent` — against a per-model
27009
+ * minimum and answers a claim below it with an HTTP 400 whose code is
27010
+ * `claude_code_version_too_old`. That refusal is correct but nearly unusable as
27011
+ * a diagnosis: the version in its text is OUR OWN claim echoed back, the model
27012
+ * is only identifiable from the request that was just consumed, and the number
27013
+ * the user has to reach is buried in prose. The predictable consequence was the
27014
+ * reported bug — a user reading "your client is too old" about a model this
27015
+ * package advertises, whose remedy the text never names, and whose wording reads
27016
+ * like a credential problem often enough that people sign in again for nothing.
27017
+ *
27018
+ * The catalog now records the floor per model (`minCliVersion`), so the same
27019
+ * verdict can be produced HERE, at zero cost, naming the model, the version in
27020
+ * force, the version required, and the remedy. The upstream refusal is left in
27021
+ * place exactly as it was — this is an addition to the path, not a replacement,
27022
+ * because a claim that clears every floor this table knows can still be too low
27023
+ * for something the table has not learned yet, and `toLlmError` still handles
27024
+ * that case with the same remedy.
27025
+ *
27026
+ * WHAT IT MUST NOT DO. It must not disable a model for anyone who never picks it:
27027
+ * the check runs on the REQUEST path, against the model actually being called, so
27028
+ * a floor for one row cannot remove another row from the picker. It must not be a
27029
+ * credential error either — nothing is wrong with the stored sign-in, and the
27030
+ * message says so outright, because signing in again is the wrong move and the
27031
+ * upstream text invites it.
27032
+ *
27033
+ * Called with the model the request is about to name, and with the catalog that
27034
+ * request resolved against, so a floor added for a live-only id is honoured too.
27035
+ */
27036
+ function assertClaudeCliVersionMeetsFloor(modelId, catalog = FALLBACK_MODELS) {
27037
+ const floor = claudeMinCliVersionFor(modelId, catalog);
27038
+ if (floor === void 0) return;
27039
+ const effective = claudeCliVersion();
27040
+ if (meetsDottedVersionFloor(effective, floor)) return;
27041
+ throw new LlmError("Claude(订阅) will not serve " + modelId + " to a client reporting version " + effective + ": upstream requires " + floor + " or newer for this model, and a lower claim is refused with claude_code_version_too_old. This was caught locally, before the request was sent. Raise the reported version with the DSH_CLAUDE_CLI_VERSION environment variable, or with a setClaudeCliVersion pin, then retry. The stored sign-in is still valid — this is not a credential problem and signing in again will not change it.", "PROVIDER_ERROR");
27042
+ }
27043
+ /**
26894
27044
  * The immutable id of the account a token came from, presented as the two-method
26895
27045
  * store oauth.ts wants. See module note 3.
26896
27046
  */
@@ -26975,6 +27125,23 @@ var ClaudeAdapter = class extends LlmAdapter {
26975
27125
  const live = await (this.options.loadCatalog ?? ((current) => loadCatalog(current, { fetchFn: this.options.fetchFn })))(credentials).catch(() => []);
26976
27126
  return live.length > 0 ? live : FALLBACK_MODELS;
26977
27127
  }
27128
+ /**
27129
+ * The catalog a REQUEST should be validated against.
27130
+ *
27131
+ * The same two branches {@link resolveModel} takes, in the same order, because
27132
+ * the live listing is authoritative for which ids exist and a floor recorded
27133
+ * for a live-only id would otherwise be skipped. An absent credential is not an
27134
+ * error here: with no account there is nothing to list and the shipped table is
27135
+ * the only answer available, which is exactly what the preview path already
27136
+ * assumes. A credential that cannot be read degrades to the shipped table for
27137
+ * the same reason — the floor check must not be the thing that turns a listing
27138
+ * failure into a failed request.
27139
+ */
27140
+ async catalogForRequest() {
27141
+ const record = await this.primaryAccount(await this.settings()).catch(() => null);
27142
+ if (record === null) return FALLBACK_MODELS;
27143
+ return this.catalog(record.credentials);
27144
+ }
26978
27145
  async listModels(provider) {
26979
27146
  const prov = provider || "claude-subscription";
26980
27147
  const settings = await this.settings();
@@ -27096,6 +27263,7 @@ var ClaudeAdapter = class extends LlmAdapter {
27096
27263
  const requestOptions = offloadOldestRequestImages(normalizeGenerateOptions(options));
27097
27264
  const images = await resolveRequestImages(requestOptions, this.options.attachments, signal);
27098
27265
  const toolNames = claudeToolNames(requestOptions.tools);
27266
+ assertClaudeCliVersionMeetsFloor(requestOptions.model, await this.catalogForRequest());
27099
27267
  const effort = requestOptions.reasoningEffort === void 0 || requestOptions.reasoningEffort === null ? void 0 : String(requestOptions.reasoningEffort);
27100
27268
  const thinking = claudeRequestThinks(requestOptions.model, effort);
27101
27269
  const pool = this.accountPool;
@@ -81,7 +81,11 @@
81
81
  * A reported-client-version rejection is a REQUEST problem even though it
82
82
  * arrives as a 400 that mentions the client: it must NOT sign the user out, and
83
83
  * it has a real remedy (raise the reported version), so it is handled
84
- * explicitly with that remedy in the message.
84
+ * explicitly with that remedy in the message. Where the catalog records a
85
+ * model's floor, the same verdict is produced LOCALLY before the request is sent
86
+ * ({@link assertClaudeCliVersionMeetsFloor}), so the ordinary case never spends
87
+ * a request to be told the same thing less precisely; the upstream branch above
88
+ * stays for a claim that is too low for a floor this table has not learned yet.
85
89
  *
86
90
  * ---------------------------------------------------------------------------
87
91
  * 5. ASSUMPTIONS AND JUDGEMENT CALLS
@@ -125,6 +129,40 @@ import { type AttachmentImageReader } from './mapper.ts';
125
129
  * message, and this is only the fallback for a response that states neither.
126
130
  */
127
131
  export declare const POOL_COOLDOWN_MS: number;
132
+ /**
133
+ * Refuse one model locally, before the request is sent, when the version this
134
+ * route reports is below the floor that model declares.
135
+ *
136
+ * WHY THIS EXISTS. Upstream validates the reported client version — the
137
+ * `user-agent` built by client.ts's `claudeUserAgent` — against a per-model
138
+ * minimum and answers a claim below it with an HTTP 400 whose code is
139
+ * `claude_code_version_too_old`. That refusal is correct but nearly unusable as
140
+ * a diagnosis: the version in its text is OUR OWN claim echoed back, the model
141
+ * is only identifiable from the request that was just consumed, and the number
142
+ * the user has to reach is buried in prose. The predictable consequence was the
143
+ * reported bug — a user reading "your client is too old" about a model this
144
+ * package advertises, whose remedy the text never names, and whose wording reads
145
+ * like a credential problem often enough that people sign in again for nothing.
146
+ *
147
+ * The catalog now records the floor per model (`minCliVersion`), so the same
148
+ * verdict can be produced HERE, at zero cost, naming the model, the version in
149
+ * force, the version required, and the remedy. The upstream refusal is left in
150
+ * place exactly as it was — this is an addition to the path, not a replacement,
151
+ * because a claim that clears every floor this table knows can still be too low
152
+ * for something the table has not learned yet, and `toLlmError` still handles
153
+ * that case with the same remedy.
154
+ *
155
+ * WHAT IT MUST NOT DO. It must not disable a model for anyone who never picks it:
156
+ * the check runs on the REQUEST path, against the model actually being called, so
157
+ * a floor for one row cannot remove another row from the picker. It must not be a
158
+ * credential error either — nothing is wrong with the stored sign-in, and the
159
+ * message says so outright, because signing in again is the wrong move and the
160
+ * upstream text invites it.
161
+ *
162
+ * Called with the model the request is about to name, and with the catalog that
163
+ * request resolved against, so a floor added for a live-only id is honoured too.
164
+ */
165
+ export declare function assertClaudeCliVersionMeetsFloor(modelId: string, catalog?: readonly ClaudeModelEntry[]): void;
128
166
  /**
129
167
  * The pool surface this adapter uses, stated structurally.
130
168
  *
@@ -196,6 +234,19 @@ export declare class ClaudeAdapter extends LlmAdapter {
196
234
  * caller-supplied seam that does neither.
197
235
  */
198
236
  private catalog;
237
+ /**
238
+ * The catalog a REQUEST should be validated against.
239
+ *
240
+ * The same two branches {@link resolveModel} takes, in the same order, because
241
+ * the live listing is authoritative for which ids exist and a floor recorded
242
+ * for a live-only id would otherwise be skipped. An absent credential is not an
243
+ * error here: with no account there is nothing to list and the shipped table is
244
+ * the only answer available, which is exactly what the preview path already
245
+ * assumes. A credential that cannot be read degrades to the shipped table for
246
+ * the same reason — the floor check must not be the thing that turns a listing
247
+ * failure into a failed request.
248
+ */
249
+ private catalogForRequest;
199
250
  listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
200
251
  resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
201
252
  prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgHG;AAEH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,iBAAiB,EAEjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAKL,WAAW,EACX,aAAa,EAGd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAEtB,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAQL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAUL,KAAK,qBAAqB,EAE3B,MAAM,aAAa,CAAA;AAkCpB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,QAAiB,CAAA;AAgB9C;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,mBAAmB,CACjB,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,OAAO,CAAC,EAAE,OA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AU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;IA6B/D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAwCpG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/F,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;IAanE;;;;;;;;;;OAUG;YACW,iBAAiB;IA8C/B;;;;;;;;OAQG;YACW,cAAc;YAkCb,aAAa;CAuI7B;AAsBD;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAC/B,iBAAiB,GAAG,SAAS,CAI/B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO,CAI3F;AAiBD,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,GAAE,MAAmB,GAAG,MAAM,CAUtF;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAO7D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,QAAQ,CA8D3D;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
@@ -219,6 +219,14 @@
219
219
  *
220
220
  * A future reader who notices the shared `supportsTemperature: false` and
221
221
  * "fixes" item 2 to 'mid-convo' has reintroduced exactly that bug.
222
+ *
223
+ * One more field on that row comes from neither source: its `minCliVersion`
224
+ * floor is the number upstream itself states when it refuses the model
225
+ * (`claude_code_version_too_old`, "version 2.1.280 or newer is required"). That
226
+ * is a stronger witness than a documentation page — the server said it — and it
227
+ * is recorded here so a claim below it is refused locally, before the request is
228
+ * sent, instead of as an upstream 400 that names neither the model nor the number
229
+ * the user has to reach.
222
230
  */
223
231
  /** One model's shipped capability entry. */
224
232
  export interface ClaudeModelEntry {
@@ -265,6 +273,25 @@ export interface ClaudeModelEntry {
265
273
  * at all): sending `{ type: 'disabled' }` is not a supported request.
266
274
  */
267
275
  canDisableThinking: boolean;
276
+ /**
277
+ * Lowest reported client version upstream serves this model to, when known.
278
+ *
279
+ * ABSENT MEANS "NO KNOWN FLOOR", WHICH IS NOT THE SAME AS "NO FLOOR". Upstream
280
+ * enforces a minimum reported client version per model and answers a claim
281
+ * below it with HTTP 400 / `claude_code_version_too_old`
282
+ * ({@link ERROR_CODE_CLIENT_VERSION_TOO_OLD} in types.ts, whose doc comment
283
+ * states the invariant that ties this field to `CLAUDE_CLI_VERSION`). Most
284
+ * rows here predate any reason to record a number, and a floor that is guessed
285
+ * is worse than one that is absent in both directions: too low and the request
286
+ * still reaches the server and is refused there, too high and this line
287
+ * refuses a model the user could actually call. So the field is set ONLY where
288
+ * a floor has been observed, and a reader must never read its absence as
289
+ * evidence that a model accepts any client version.
290
+ *
291
+ * The value is a dotted numeric version compared by
292
+ * `compareDottedVersions` / `meetsDottedVersionFloor` in types.ts.
293
+ */
294
+ minCliVersion?: string;
268
295
  }
269
296
  /**
270
297
  * Fifteen rows: the snapshot's own 14, in the snapshot's own declaration order,
@@ -362,4 +389,20 @@ export declare function claudeThinkingMode(modelId: string, catalog?: readonly C
362
389
  export declare function claudeModelSupportsTemperature(modelId: string, catalog?: readonly ClaudeModelEntry[]): boolean;
363
390
  /** Whether thinking can be turned off for one model. */
364
391
  export declare function claudeModelCanDisableThinking(modelId: string, catalog?: readonly ClaudeModelEntry[]): boolean;
392
+ /**
393
+ * Lowest reported client version upstream serves one model to, when known.
394
+ *
395
+ * `undefined` means "no known floor" — NOT "no floor" — so a caller must treat it
396
+ * as "nothing to check" rather than as "any version is fine". The distinction
397
+ * matters because the caller is a pre-flight refusal: an absent floor must let
398
+ * the request through (refusing it would invent a restriction nobody recorded),
399
+ * while a present floor must block a claim below it.
400
+ *
401
+ * Unlike the other per-model lookups this one does NOT resolve through the
402
+ * conservative stub for an unknown id. The stub describes capabilities this line
403
+ * assumes; a version floor is a fact about the server that this line either has
404
+ * or has not observed, and manufacturing one for an unknown id would refuse a
405
+ * model nobody has evidence against.
406
+ */
407
+ export declare function claudeMinCliVersionFor(modelId: string, catalog?: readonly ClaudeModelEntry[]): string | undefined;
365
408
  //# sourceMappingURL=model-catalog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6NG;AAIH,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAA;IACjB,6CAA6C;IAC7C,aAAa,EAAE,OAAO,CAAA;IACtB,kDAAkD;IAClD,mBAAmB,EAAE,OAAO,CAAA;IAC5B;;;;;;;;;;;;;;OAcG;IACH,YAAY,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,C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EAAE,GAAG,OAAO,CAE9G;AAED,wDAAwD;AACxD,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,GAAG,OAAO,CAE7G;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGjH"}
@@ -92,20 +92,38 @@ export declare const INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-1
92
92
  /** Anthropic protocol revision sent as `anthropic-version`. */
93
93
  export declare const ANTHROPIC_VERSION = "2023-06-01";
94
94
  /**
95
- * Baseline client version this route reports to the subscription gateway.
95
+ * Client version this route CLAIMS to be on the subscription gateway.
96
96
  *
97
- * Upstream enforces a *minimum reported client version* on the subscription
98
- * path: a value below the floor is refused with HTTP 400 and an error body whose
99
- * code is `claude_code_version_too_old`. That is a hard stop for every request
100
- * rather than a per-request failure, so it cannot be a compile-time literal that
101
- * only moves when this package is republished — a user whose installed baseline
102
- * has aged past the server's floor has to be able to raise it without waiting
103
- * for a release.
97
+ * Upstream enforces a *minimum reported client version* per model on the
98
+ * subscription path: the version travels in the `user-agent` header (built by
99
+ * `claudeUserAgent` in client.ts) and a claim below the floor is refused with
100
+ * HTTP 400 and an error body whose code is `claude_code_version_too_old`. That
101
+ * is a hard stop for the whole request rather than a per-request failure, and the
102
+ * number in the refusal is OUR OWN claim echoed back — so the user is told their
103
+ * client is too old without being told which model demanded more, which is
104
+ * exactly how it misleads people into signing in again.
104
105
  *
105
- * Read the effective value with {@link claudeCliVersion}, pin one with
106
- * {@link setClaudeCliVersion}.
106
+ * THE INVARIANT THIS CONSTANT CARRIES. It must be at or above the highest
107
+ * `minCliVersion` that any shipped model in `model-catalog.ts` declares. A
108
+ * default below a shipped model's floor is a model this package advertises in
109
+ * its own picker and then cannot call at all, which is the bug this comment now
110
+ * records: `2.1.251` shipped while `claude-opus-5-5` — also shipped, and the
111
+ * row the default picker leads with — requires `2.1.280`. The matching
112
+ * regression lock lives in `test/claude-model-catalog.test.ts` and fails
113
+ * loudly, naming both versions, when a future model's floor is added without
114
+ * raising this value.
115
+ *
116
+ * The value is a REAL published `@anthropic-ai/claude-code` release, not a
117
+ * number chosen merely to clear a floor: claiming a version that does not exist
118
+ * trades a clear refusal for an unpredictable one. Note that npm's `stable`
119
+ * dist-tag can itself sit below a model's floor, so `latest` is the tag to read.
120
+ *
121
+ * It is still not a literal that only moves when this package is republished: a
122
+ * user whose installed baseline has aged past the server's floor has to be able
123
+ * to raise it without waiting for a release. Read the effective value with
124
+ * {@link claudeCliVersion}, pin one with {@link setClaudeCliVersion}.
107
125
  */
108
- export declare const CLAUDE_CLI_VERSION = "2.1.251";
126
+ export declare const CLAUDE_CLI_VERSION = "2.1.283";
109
127
  /**
110
128
  * Loopback callback port the subscription flow defaults to.
111
129
  *
@@ -223,6 +241,38 @@ export declare function claudeCliVersion(): string;
223
241
  * environment and then the shipped baseline.
224
242
  */
225
243
  export declare function setClaudeCliVersion(value: string | null): void;
244
+ /**
245
+ * Compare two dotted numeric versions, e.g. `'2.1.283'` against `'2.1.280'`.
246
+ *
247
+ * This exists so a version FLOOR can be checked before a request is sent. The
248
+ * comparison is deliberately small and TOTAL rather than a SemVer parser: the
249
+ * only strings it ever sees are this line's own reported version (a pin, the
250
+ * `DSH_CLAUDE_CLI_VERSION` override, or the shipped default) and the floors
251
+ * recorded in the model catalog, and it must not throw on any of them — a
252
+ * comparison that can throw would turn a misconfigured version into a crash
253
+ * instead of the precise pre-flight refusal it was added to produce.
254
+ *
255
+ * Total means: a missing segment compares as 0 (`'2.1'` equals `'2.1.0'`), and a
256
+ * segment that is not a run of decimal digits compares as 0 rather than as NaN
257
+ * (`'abc'` equals `'0.0.0'`, and so does `''`). Leading zeros are exact rather
258
+ * than octal, and an optional leading `v` is tolerated because that is how a
259
+ * release is often written down.
260
+ *
261
+ * @returns a negative number, 0, or a positive number — the sign is the whole
262
+ * contract, so callers compare against 0 rather than against ±1.
263
+ */
264
+ export declare function compareDottedVersions(left: string, right: string): number;
265
+ /**
266
+ * Whether one reported version clears a floor.
267
+ *
268
+ * An absent floor (`undefined`) means "no known floor" rather than "no floor",
269
+ * so it never blocks a request: refusing a model because nobody recorded a
270
+ * number would be this line inventing a restriction upstream never stated.
271
+ * A MALFORMED version on either side, on the other hand, is refused — that is
272
+ * the conservative direction, since the check exists to stop an unknown claim
273
+ * from reaching a server that has already refused one.
274
+ */
275
+ export declare function meetsDottedVersionFloor(version: string, floor?: string): boolean;
226
276
  /**
227
277
  * Resolve the browser authorization endpoint.
228
278
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/host/claude/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,uCAAuC;AACvC,eAAO,MAAM,WAAW,wBAAwB,CAAA;AAChD,kEAAkE;AAClE,eAAO,MAAM,aAAa,mCAAe,CAAA;AAEzC,kFAAkF;AAClF,eAAO,MAAM,QAAQ,8BAA8B,CAAA;AAEnD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,2BAA2B,CAAA;AACrD,2EAA2E;AAC3E,eAAO,MAAM,WAAW,eAAe,CAAA;AACvC,gEAAgE;AAChE,eAAO,MAAM,UAAU,qBAAqB,CAAA;AAE5C;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,sCAAsC,CAAA;AACtE,wEAAwE;AACxE,eAAO,MAAM,eAAe,+CAA+C,CAAA;AAE3E;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,oDAAoD,CAAA;AAE1F;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,yCAAyC,CAAA;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,+GAA+G,CAAA;AAExI;;;;;GAKG;AACH,eAAO,MAAM,UAAU,qBAAqB,CAAA;AAC5C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+EAA+E;;IAE/E,iFAAiF;;IAEjF,mFAAmF;;IAEnF,uEAAuE;;IAEvE,kDAAkD;;IAElD,+CAA+C;;IAE/C,mFAAmF;;CAE3E,CAAA;AAEV,2CAA2C;AAC3C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAA;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,gCAAgC,CAAA;AAE9E,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAA8B,CAAA;AAEvF,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAKD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAG9D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CASzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAIhF;AAoBD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAA8B,GAAG,MAAM,CAEhF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eddyskywalker/dsh-chatgpt-subscription",
3
- "version": "0.9.2",
3
+ "version": "0.9.5",
4
4
  "description": "DSH provider plugin for Codex access through a ChatGPT subscription.",
5
5
  "author": {
6
6
  "name": "eddyskywalker",