@eddyskywalker/dsh-chatgpt-subscription 0.82.1 → 0.82.3

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/aws-quick-mcp.js +18 -13
  3. package/lib/client.js.map +1 -1
  4. package/lib/{entry-tool-result-pruner-DY67oa5d.js → entry-tool-result-pruner-E_xILd9Z.js} +169 -11
  5. package/lib/index.js +1750 -724
  6. package/lib/tool-result-pruner.js +1 -1
  7. package/lib/types/compat.d.ts +1 -1
  8. package/lib/types/entry-tool-result-pruner.d.ts +3 -1
  9. package/lib/types/entry-tool-result-pruner.d.ts.map +1 -1
  10. package/lib/types/host/antigravity-acp/adapter.d.ts.map +1 -1
  11. package/lib/types/host/aws-quick/adapter.d.ts +37 -0
  12. package/lib/types/host/aws-quick/adapter.d.ts.map +1 -1
  13. package/lib/types/host/aws-quick/execution-broker.d.ts.map +1 -1
  14. package/lib/types/host/aws-quick/tool-bridge.d.ts +28 -0
  15. package/lib/types/host/aws-quick/tool-bridge.d.ts.map +1 -1
  16. package/lib/types/host/cache-warmup/install.d.ts +8 -0
  17. package/lib/types/host/cache-warmup/install.d.ts.map +1 -1
  18. package/lib/types/host/cache-warmup/result-tool.d.ts +2 -0
  19. package/lib/types/host/cache-warmup/result-tool.d.ts.map +1 -1
  20. package/lib/types/host/deepseek-v41-flash/discipline.d.ts +22 -0
  21. package/lib/types/host/deepseek-v41-flash/discipline.d.ts.map +1 -0
  22. package/lib/types/host/deepseek-v41-flash/index.d.ts +70 -0
  23. package/lib/types/host/deepseek-v41-flash/index.d.ts.map +1 -0
  24. package/lib/types/host/deepseek-v41-flash/match.d.ts +54 -0
  25. package/lib/types/host/deepseek-v41-flash/match.d.ts.map +1 -0
  26. package/lib/types/host/deepseek-v41-flash/observation-tagger.d.ts +36 -0
  27. package/lib/types/host/deepseek-v41-flash/observation-tagger.d.ts.map +1 -0
  28. package/lib/types/host/deepseek-v41-flash/state-anchor.d.ts +56 -0
  29. package/lib/types/host/deepseek-v41-flash/state-anchor.d.ts.map +1 -0
  30. package/lib/types/host/ptc-sdk-cache-guard.d.ts +5 -0
  31. package/lib/types/host/ptc-sdk-cache-guard.d.ts.map +1 -1
  32. package/lib/types/host/reasoning-collapse-guard/index.d.ts +4 -0
  33. package/lib/types/host/reasoning-collapse-guard/index.d.ts.map +1 -1
  34. package/lib/types/host/timeline-cache-guard.d.ts +5 -0
  35. package/lib/types/host/timeline-cache-guard.d.ts.map +1 -1
  36. package/lib/types/host/tool-result-pruner-guard.d.ts +5 -0
  37. package/lib/types/host/tool-result-pruner-guard.d.ts.map +1 -1
  38. package/lib/types/index.d.ts +11 -0
  39. package/lib/types/index.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -17,7 +17,7 @@ function codexRemoteCompactionEnabled(env = process.env) {
17
17
  /** A definite protocol refusal disables remote compaction until restart. */
18
18
  function noteCodexRemoteCompactionFailure(error) {
19
19
  const value = typeof error === "object" && error !== null ? error : {};
20
- const failure = isRecord$1(value.failure) ? value.failure : void 0;
20
+ const failure = isRecord$2(value.failure) ? value.failure : void 0;
21
21
  const status = typeof value.status === "number" ? value.status : typeof failure?.status === "number" ? failure.status : void 0;
22
22
  if (status !== 400 && status !== 404 && value.code !== "NOT_FOUND") return false;
23
23
  rejected = true;
@@ -58,7 +58,7 @@ function withCodexCompactionTrigger(payload) {
58
58
  }
59
59
  /** Keep the static head and the latest user turn around a fresh checkpoint. */
60
60
  function projectFreshCodexCompaction(payload, checkpoint) {
61
- const input = Array.isArray(payload.input) ? payload.input.filter((item) => isRecord$1(item)) : [];
61
+ const input = Array.isArray(payload.input) ? payload.input.filter((item) => isRecord$2(item)) : [];
62
62
  let firstUser = -1;
63
63
  let latestUser = -1;
64
64
  for (let index = 0; index < input.length; index += 1) {
@@ -121,7 +121,7 @@ function codexCompactionReplayMetadata(checkpoint) {
121
121
  };
122
122
  }
123
123
  function isCompactionItem(value) {
124
- return isRecord$1(value) && value.type === "compaction" && typeof value.encrypted_content === "string" && value.encrypted_content.length > 0;
124
+ return isRecord$2(value) && value.type === "compaction" && typeof value.encrypted_content === "string" && value.encrypted_content.length > 0;
125
125
  }
126
126
  function isUserItem(item) {
127
127
  return item.role === "user" && (item.type === void 0 || item.type === "message");
@@ -130,12 +130,164 @@ function positive(value) {
130
130
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : null;
131
131
  }
132
132
  function record(value) {
133
- return isRecord$1(value) ? value : null;
133
+ return isRecord$2(value) ? value : null;
134
134
  }
135
- function isRecord$1(value) {
135
+ function isRecord$2(value) {
136
136
  return typeof value === "object" && value !== null && !Array.isArray(value);
137
137
  }
138
138
  //#endregion
139
+ //#region src/host/deepseek-v41-flash/match.ts
140
+ /**
141
+ * DeepSeek V4.1 Flash 模型精准识别与跨代路由提取。
142
+ *
143
+ * 本模块是所有 DeepSeek V4.1 Flash 专属优化的唯一准入门:
144
+ * 只有真正在跑 DeepSeek V4.1 Flash(含 1017 快照、eco / fast 变体,以及
145
+ * 官方线路的 `deepseek-flash` 别名)的请求/会话才会返回 `true`;其余任何线路、
146
+ * 任何其他模型(包括 `deepseek-v4-pro`、`deepseek-v4-flash`、Qoder 下的老
147
+ * `DeepSeek-Flash`、Claude、GPT、Kimi、MiniMax、GLM、Qwen 等)一律返回 `false`。
148
+ *
149
+ * @module @eddyskywalker/dsh-chatgpt-subscription/host/deepseek-v41-flash/match
150
+ */
151
+ /** DeepSeek 官方第一方线路 ID(其目录中 `deepseek-flash` 明确指向 DeepSeek-V4.1-Flash)。 */
152
+ const DEEPSEEK_OFFICIAL_PROVIDERS = /* @__PURE__ */ new Set([
153
+ "deepseek-official",
154
+ "deepseek-account",
155
+ "deepseek"
156
+ ]);
157
+ /**
158
+ * 匹配任意命名空间下显式标明 V4.1 Flash 的裸模型名:
159
+ * - `deepseek-v4.1-flash` / `deepseek-v4.1-flash-1017` / `deepseek-v4.1-flash-eco` / `deepseek-v4.1-flash-fast`
160
+ * - `deepseek-v4p1-flash-1017`(部分网关 VMC/私有路由写法)
161
+ * - `deepseek_v4_1_flash` / `public_model_deepseek_v4_1_flash`
162
+ *
163
+ * 刻意不匹配:`deepseek-v4-flash`(旧一代 V4 Flash)、`deepseek-v4-pro`、`deepseek-chat`、`deepseek-reasoner`。
164
+ */
165
+ const EXPLICIT_V41_FLASH_PATTERN = /^(?:public[-_.]model[-_.])?deepseek[-_.]?v4(?:[._p]|[-_])1[-_.]?flash(?:[-_.]|$)/i;
166
+ /** 官方第一方线路上代表 DeepSeek-V4.1-Flash 的标准别名。 */
167
+ const OFFICIAL_FLASH_ALIAS_PATTERN = /^deepseek[-_.]?flash(?:[-_.]1017)?$/i;
168
+ /** 从可能带命名空间前缀的模型 ID 中取出最后一段裸名。 */
169
+ function bareModelId(model) {
170
+ const trimmed = model.trim();
171
+ const slash = trimmed.lastIndexOf("/");
172
+ return slash >= 0 ? trimmed.slice(slash + 1) : trimmed;
173
+ }
174
+ /**
175
+ * 判断一次请求或会话是否运行在 DeepSeek V4.1 Flash 上。
176
+ *
177
+ * - 任意 provider 下,显式 V4.1 Flash 模型 ID 均命中;
178
+ * - 裸别名 `deepseek-flash` 仅在 DeepSeek 官方第一方线路上命中,避免误伤
179
+ * 第三方线路里仍指向旧代 `DeepSeek-V4-Flash` 的同名别名(例如 Qoder)。
180
+ *
181
+ * @param model - 模型 ID。
182
+ * @param provider - 可选的 provider ID。
183
+ * @returns 确认为 DeepSeek V4.1 Flash 时返回 `true`。
184
+ */
185
+ function isDeepSeekV41Flash(model, provider) {
186
+ if (typeof model !== "string") return false;
187
+ const bare = bareModelId(model);
188
+ if (bare.length === 0) return false;
189
+ if (EXPLICIT_V41_FLASH_PATTERN.test(bare)) return true;
190
+ if (typeof provider === "string" && DEEPSEEK_OFFICIAL_PROVIDERS.has(provider.trim().toLowerCase())) return OFFICIAL_FLASH_ALIAS_PATTERN.test(bare);
191
+ return false;
192
+ }
193
+ function isRecord$1(value) {
194
+ return typeof value === "object" && value !== null;
195
+ }
196
+ function nonEmptyString(value) {
197
+ return typeof value === "string" && value.length > 0 ? value : void 0;
198
+ }
199
+ function readEffort(value) {
200
+ if (typeof value === "string" && value.length > 0) return value;
201
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
202
+ }
203
+ /**
204
+ * 从会话对象(`Session`)读取路由元数据。
205
+ *
206
+ * 按可靠性顺序读取:`requestHeader().config` → 扁平字段。
207
+ * 每步独立容错,不依赖任何单一 harness 代次类型。
208
+ */
209
+ function readSessionRoute(session) {
210
+ if (!isRecord$1(session)) return {};
211
+ let provider;
212
+ let model;
213
+ let reasoningEffort;
214
+ const requestHeader = session["requestHeader"];
215
+ if (typeof requestHeader === "function") try {
216
+ const header = requestHeader.call(session);
217
+ if (isRecord$1(header)) {
218
+ const config = header["config"];
219
+ if (isRecord$1(config)) {
220
+ provider = nonEmptyString(config["provider"]);
221
+ model = nonEmptyString(config["model"]);
222
+ reasoningEffort = readEffort(config["reasoningEffort"]);
223
+ }
224
+ }
225
+ } catch {}
226
+ provider ??= nonEmptyString(session["provider"]);
227
+ model ??= nonEmptyString(session["model"]);
228
+ reasoningEffort ??= readEffort(session["reasoningEffort"]);
229
+ const sessionId = nonEmptyString((isRecord$1(session["header"]) ? session["header"] : void 0)?.["id"]) ?? nonEmptyString(session["id"]);
230
+ return {
231
+ ...provider === void 0 ? {} : { provider },
232
+ ...model === void 0 ? {} : { model },
233
+ ...sessionId === void 0 ? {} : { sessionId },
234
+ ...reasoningEffort === void 0 ? {} : { reasoningEffort }
235
+ };
236
+ }
237
+ /**
238
+ * 从 `agent` / `scope` / `AssembleContext` 跨代读取完整路由。
239
+ *
240
+ * 优先级(与 `ptc-sdk-cache-guard` / `compaction-policy-guard` 对齐):
241
+ * 1. 显式传入的 `modelSelection`(当步已锁定的选择,覆盖首步与刚切模型瞬间);
242
+ * 2. `scope.model.current()`(agent 自己的模型选择读面,反映 pending ?? lastUsed);
243
+ * 3. `scope.session.requestHeader().config`(已落盘的请求头快照);
244
+ * 4. `scope.options` 与裸字段兜底。
245
+ */
246
+ function readScopeRoute(scope, modelSelection) {
247
+ let provider;
248
+ let model;
249
+ let sessionId;
250
+ let reasoningEffort;
251
+ const absorb = (candidate) => {
252
+ if (!isRecord$1(candidate)) return;
253
+ provider ??= nonEmptyString(candidate["provider"]);
254
+ model ??= nonEmptyString(candidate["model"]);
255
+ reasoningEffort ??= readEffort(candidate["reasoningEffort"]);
256
+ };
257
+ absorb(modelSelection);
258
+ if (isRecord$1(scope)) {
259
+ const modelService = scope["model"];
260
+ if (isRecord$1(modelService) && typeof modelService["current"] === "function") try {
261
+ absorb(modelService["current"].call(modelService));
262
+ } catch {}
263
+ const sessionRoute = readSessionRoute(scope["session"]);
264
+ provider ??= sessionRoute.provider;
265
+ model ??= sessionRoute.model;
266
+ sessionId ??= sessionRoute.sessionId;
267
+ reasoningEffort ??= sessionRoute.reasoningEffort;
268
+ absorb(scope["options"]);
269
+ absorb(scope["config"]);
270
+ absorb(scope);
271
+ sessionId ??= nonEmptyString(scope["id"]);
272
+ }
273
+ return {
274
+ ...provider === void 0 ? {} : { provider },
275
+ ...model === void 0 ? {} : { model },
276
+ ...sessionId === void 0 ? {} : { sessionId },
277
+ ...reasoningEffort === void 0 ? {} : { reasoningEffort }
278
+ };
279
+ }
280
+ /** 快捷判断:给定 scope/agent(及可选当步 `modelSelection`)是否为 DeepSeek V4.1 Flash。 */
281
+ function isDeepSeekV41FlashScope(scope, modelSelection) {
282
+ const route = readScopeRoute(scope, modelSelection);
283
+ return isDeepSeekV41Flash(route.model, route.provider);
284
+ }
285
+ /** 快捷判断:给定 session 对象是否为 DeepSeek V4.1 Flash。 */
286
+ function isDeepSeekV41FlashSession(session) {
287
+ const route = readSessionRoute(session);
288
+ return isDeepSeekV41Flash(route.model, route.provider);
289
+ }
290
+ //#endregion
139
291
  //#region src/entry-tool-result-pruner.ts
140
292
  /**
141
293
  * 「工具结果修剪器」的宿主入口 —— 本包自己的 loader 行(fork 版)。
@@ -302,11 +454,14 @@ function readSessionProvider(session) {
302
454
  * @param skipProviders - 跳过名单;省略时用默认的 `['kimi-code', 'minimax-code']`。
303
455
  * @returns 命中名单时为 `true`。
304
456
  */
305
- function shouldSkipPruningForSession(session, skipProviders = defaultSkipProviders()) {
457
+ function shouldSkipPruningForSession(session, skipProviders = defaultSkipProviders(), skipDeepSeekV41Flash = skipProviders === defaultSkipProviderSet) {
306
458
  const provider = readSessionProvider(session);
307
- if (provider === void 0) return false;
308
- if (provider === "codex-chatgpt" && codexRemoteCompactionEnabled()) return true;
309
- return skipProviders.has(provider);
459
+ if (provider !== void 0) {
460
+ if (provider === "codex-chatgpt" && codexRemoteCompactionEnabled()) return true;
461
+ if (skipProviders.has(provider)) return true;
462
+ }
463
+ if (skipDeepSeekV41Flash && isDeepSeekV41FlashSession(session)) return true;
464
+ return false;
310
465
  }
311
466
  /**
312
467
  * 断言一个正整数配置项。
@@ -391,6 +546,8 @@ var ToolResultPruner = class extends Service {
391
546
  config;
392
547
  /** 命中即整场跳过的 provider 集合。 */
393
548
  skipProviders;
549
+ /** 未显式覆写跳过名单时,默认按模型跳过 DeepSeek V4.1 Flash 以保护 50x 前缀缓存。 */
550
+ skipDeepSeekV41Flash;
394
551
  /**
395
552
  * @param ctx - 宿主上下文(服务自注册为 `toolResultPruner`)。
396
553
  * @param config - 原始配置。
@@ -399,6 +556,7 @@ var ToolResultPruner = class extends Service {
399
556
  super(ctx, PRUNER_SERVICE_NAME);
400
557
  this.config = resolveConfig(config);
401
558
  this.skipProviders = resolveSkipProviders(config.skipProviders);
559
+ this.skipDeepSeekV41Flash = config.skipProviders === void 0;
402
560
  }
403
561
  /**
404
562
  * 只统计文本块的码点数;非文本块不计价。
@@ -466,7 +624,7 @@ var ToolResultPruner = class extends Service {
466
624
  * @returns 已落地的替换与合计省下的码点数。
467
625
  */
468
626
  pruneSession(session) {
469
- if (shouldSkipPruningForSession(session, this.skipProviders)) return {
627
+ if (shouldSkipPruningForSession(session, this.skipProviders, this.skipDeepSeekV41Flash)) return {
470
628
  pruned: [],
471
629
  charsRemoved: 0
472
630
  };
@@ -542,4 +700,4 @@ var ToolResultPruner = class extends Service {
542
700
  }
543
701
  };
544
702
  //#endregion
545
- export { noteCodexRemoteCompactionFailure as _, ToolResultPruner as a, withCodexCompactionTrigger as b, resolveConfig as c, checkpointFromMetadata as d, checkpointFromOutputItems as f, latestCodexCompaction as g, isCompactionItem as h, PRUNE_MARKER as i, resolveSkipProviders as l, codexRemoteCompactionEnabled as m, DEFAULT_SKIP_PROVIDERS as n, codePointLength as o, codexCompactionReplayMetadata as p, PRUNER_SERVICE_NAME as r, readSessionProvider as s, DEFAULTS as t, shouldSkipPruningForSession as u, projectFreshCodexCompaction as v, shouldCompactCodexPayload as y };
703
+ export { noteCodexRemoteCompactionFailure as C, withCodexCompactionTrigger as E, latestCodexCompaction as S, shouldCompactCodexPayload as T, checkpointFromMetadata as _, ToolResultPruner as a, codexRemoteCompactionEnabled as b, resolveConfig as c, DEEPSEEK_OFFICIAL_PROVIDERS as d, isDeepSeekV41Flash as f, readSessionRoute as g, readScopeRoute as h, PRUNE_MARKER as i, resolveSkipProviders as l, isDeepSeekV41FlashSession as m, DEFAULT_SKIP_PROVIDERS as n, codePointLength as o, isDeepSeekV41FlashScope as p, PRUNER_SERVICE_NAME as r, readSessionProvider as s, DEFAULTS as t, shouldSkipPruningForSession as u, checkpointFromOutputItems as v, projectFreshCodexCompaction as w, isCompactionItem as x, codexCompactionReplayMetadata as y };