@eddyskywalker/dsh-chatgpt-subscription 1.3.1 → 1.5.0

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 (65) hide show
  1. package/lib/advisor-contracts-BG7iEfUc.js +8 -0
  2. package/lib/client.js +23 -13
  3. package/lib/client.js.map +1 -1
  4. package/lib/codemode.js +72 -7
  5. package/lib/index.js +260 -114
  6. package/lib/{preset-sync-RBsYhDY3.js → preset-sync-DspdQkYN.js} +1 -8
  7. package/lib/{progress-updates-jiHnSAmz.js → progress-updates-ART24-8J.js} +81 -4
  8. package/lib/progress-updates.js +1 -1
  9. package/lib/{tool-result-pruner-CuKHwU2R.js → tool-result-pruner-Duw9-Gwo.js} +381 -127
  10. package/lib/tool-result-pruner.js +1 -1
  11. package/lib/types/client/features/progress-updates/contracts.d.ts +2 -0
  12. package/lib/types/client/features/progress-updates/contracts.d.ts.map +1 -1
  13. package/lib/types/client/features/progress-updates/dashboard.d.ts.map +1 -1
  14. package/lib/types/client/features/progress-updates/locales.d.ts +8 -2
  15. package/lib/types/client/features/progress-updates/locales.d.ts.map +1 -1
  16. package/lib/types/client/locales-ru/grok.d.ts.map +1 -1
  17. package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
  18. package/lib/types/client/providers/grok/locales.d.ts +3 -1
  19. package/lib/types/client/providers/grok/locales.d.ts.map +1 -1
  20. package/lib/types/compat.d.ts +1 -1
  21. package/lib/types/host/common/model-facts-data.d.ts +4 -0
  22. package/lib/types/host/common/model-facts-data.d.ts.map +1 -0
  23. package/lib/types/host/common/model-facts.d.ts +41 -0
  24. package/lib/types/host/common/model-facts.d.ts.map +1 -0
  25. package/lib/types/host/common/prompt-cache-policy.d.ts.map +1 -1
  26. package/lib/types/host/providers/glm-coding-plan/model-catalog.d.ts +9 -11
  27. package/lib/types/host/providers/glm-coding-plan/model-catalog.d.ts.map +1 -1
  28. package/lib/types/host/providers/grok/model-catalog.d.ts +5 -1
  29. package/lib/types/host/providers/grok/model-catalog.d.ts.map +1 -1
  30. package/lib/types/host/providers/minimax-code/mapper.d.ts.map +1 -1
  31. package/lib/types/host/providers/minimax-code/model-catalog.d.ts +17 -11
  32. package/lib/types/host/providers/minimax-code/model-catalog.d.ts.map +1 -1
  33. package/lib/types/host/providers/qoder/mapper.d.ts +0 -25
  34. package/lib/types/host/providers/qoder/mapper.d.ts.map +1 -1
  35. package/lib/types/host/providers/qoder/model-catalog.d.ts.map +1 -1
  36. package/lib/types/host/providers/step-code/model-catalog.d.ts.map +1 -1
  37. package/lib/types/host/providers/workbuddy/model-catalog.d.ts.map +1 -1
  38. package/lib/types/host/runtime/advisor/index.d.ts +4 -1
  39. package/lib/types/host/runtime/advisor/index.d.ts.map +1 -1
  40. package/lib/types/host/runtime/advisor/prompt.d.ts +14 -0
  41. package/lib/types/host/runtime/advisor/prompt.d.ts.map +1 -1
  42. package/lib/types/host/runtime/advisor/request.d.ts +3 -0
  43. package/lib/types/host/runtime/advisor/request.d.ts.map +1 -1
  44. package/lib/types/host/runtime/codemode/transport.d.ts +4 -3
  45. package/lib/types/host/runtime/codemode/transport.d.ts.map +1 -1
  46. package/lib/types/host/runtime/deepseek-v41-flash/discipline.d.ts.map +1 -1
  47. package/lib/types/host/runtime/deepseek-v41-flash/index.d.ts +2 -2
  48. package/lib/types/host/runtime/deepseek-v41-flash/index.d.ts.map +1 -1
  49. package/lib/types/host/runtime/deepseek-v41-flash/match.d.ts.map +1 -1
  50. package/lib/types/host/runtime/deepseek-v41-flash/state-anchor.d.ts +4 -0
  51. package/lib/types/host/runtime/deepseek-v41-flash/state-anchor.d.ts.map +1 -1
  52. package/lib/types/host/runtime/open-models/identity.d.ts +6 -0
  53. package/lib/types/host/runtime/open-models/identity.d.ts.map +1 -0
  54. package/lib/types/host/runtime/open-models/index.d.ts +4 -5
  55. package/lib/types/host/runtime/open-models/index.d.ts.map +1 -1
  56. package/lib/types/host/runtime/open-models/profiles.d.ts +10 -22
  57. package/lib/types/host/runtime/open-models/profiles.d.ts.map +1 -1
  58. package/lib/types/host/runtime/open-models/state-anchor.d.ts.map +1 -1
  59. package/lib/types/host/runtime/progress-updates/projection.d.ts +6 -1
  60. package/lib/types/host/runtime/progress-updates/projection.d.ts.map +1 -1
  61. package/lib/types/host/runtime/progress-updates/store.d.ts +2 -0
  62. package/lib/types/host/runtime/progress-updates/store.d.ts.map +1 -1
  63. package/lib/types/shared/grok-contracts.d.ts +1 -1
  64. package/lib/types/shared/grok-contracts.d.ts.map +1 -1
  65. package/package.json +1 -1
@@ -251,13 +251,6 @@ function normalizeGenerateOptions(options) {
251
251
  };
252
252
  }
253
253
  //#endregion
254
- //#region src/shared/advisor-contracts.ts
255
- /** Public Advisor contracts shared by Host and Web; never include credentials or transcript content. */
256
- const CONSULT_ADVISOR_TOOL_NAME = "consult_advisor";
257
- const ADVISOR_STATE_PATH = "/advisor/state";
258
- /** 顾问工具的时限:吃满 PTC 的 600 秒上限,给请求留出收尾余量。 */
259
- const ADVISOR_TOOL_TIMEOUT_MS = 6e5;
260
- //#endregion
261
254
  //#region src/host/runtime/presets/preset-sync.ts
262
255
  /**
263
256
  * Get this plugin's bundled agent presets in front of the running harness:
@@ -774,4 +767,4 @@ function installBundledPresets(host, install) {
774
767
  return () => void 0;
775
768
  }
776
769
  //#endregion
777
- export { ADVISOR_TOOL_TIMEOUT_MS as a, PLUGIN_MESSAGE_SOURCE_KIND as c, formatToolUpdateNotice as d, leadingSystemEndIndex as f, normalizeGenerateOptions as h, ADVISOR_STATE_PATH as i, extractSystemText as l, midConversationUpdateToUserMessage as m, installBundledPresets as n, CONSULT_ADVISOR_TOOL_NAME as o, midConversationSystemToUserMessage as p, resolvesFromHere as r, LlmError$1 as s, candidatePackageRoots as t, formatMidConversationSystemReminder as u };
770
+ export { PLUGIN_MESSAGE_SOURCE_KIND as a, formatToolUpdateNotice as c, midConversationUpdateToUserMessage as d, normalizeGenerateOptions as f, LlmError$1 as i, leadingSystemEndIndex as l, installBundledPresets as n, extractSystemText as o, resolvesFromHere as r, formatMidConversationSystemReminder as s, candidatePackageRoots as t, midConversationSystemToUserMessage as u };
@@ -1,3 +1,4 @@
1
+ import "./advisor-contracts-BG7iEfUc.js";
1
2
  import { createUserMessage } from "@deepseek-ai/dsh-llm";
2
3
  import { defineTool } from "@deepseek-ai/dsh-tools";
3
4
  import { z } from "zod";
@@ -441,6 +442,7 @@ const PROGRESS_UPDATES_PROJECTION_KEY = "progressUpdates";
441
442
  /** 单条进展的 schema:与 `ProgressUpdate` 逐字同形。 */
442
443
  const UPDATE_SCHEMA = z.object({
443
444
  id: z.string(),
445
+ kind: z.literal("advisor").optional(),
444
446
  title: z.string().optional(),
445
447
  message: z.string(),
446
448
  at: z.number(),
@@ -449,7 +451,8 @@ const UPDATE_SCHEMA = z.object({
449
451
  /** 折叠状态的 schema(宿主状态)。 */
450
452
  const progressUpdatesStateSchema = z.object({
451
453
  updates: z.array(UPDATE_SCHEMA),
452
- source: z.string().optional()
454
+ source: z.string().optional(),
455
+ advisorCalls: z.record(z.string(), z.boolean()).optional()
453
456
  });
454
457
  /** wire 值的 schema(客户端看到的数组)。 */
455
458
  const progressUpdatesViewSchema = z.array(UPDATE_SCHEMA);
@@ -470,6 +473,42 @@ function updateIdOf(seq, source) {
470
473
  function stringOf(value) {
471
474
  return typeof value === "string" && value !== "" ? value : void 0;
472
475
  }
476
+ /** 最多记住多少条尚未结算的顾问调用;坏日志里的悬空调用不该无限增长。 */
477
+ const MAX_PENDING_ADVISOR_CALLS = 32;
478
+ /**
479
+ * 把工具结果里的内容块读成正文。
480
+ * @param content - `tool/result` 或 `tool/ptc-dispatch` 带的内容块。
481
+ * @returns 拼接后的文本;没有文本块时为空串。
482
+ */
483
+ function contentTextOf(content) {
484
+ if (typeof content === "string") return content.trim();
485
+ if (!Array.isArray(content)) return "";
486
+ return content.map((block) => typeof block === "object" && block !== null && !Array.isArray(block) && block.type === "text" && typeof block.text === "string" ? block.text : "").filter((text) => text !== "").join("\n").trim();
487
+ }
488
+ /**
489
+ * 追加一条顾问反馈进展。
490
+ * @param state - 当前折叠状态。
491
+ * @param event - 承载结果的事件;`seq`/`time` 缺一不可。
492
+ * @param message - 顾问反馈正文。
493
+ * @returns 新状态;事件缺稳定序号或时间时原样返回。
494
+ */
495
+ function appendAdvisorUpdate(state, event, message) {
496
+ const seq = event.seq;
497
+ if (typeof seq !== "number" || !Number.isFinite(seq)) return state;
498
+ const at = event.time;
499
+ if (typeof at !== "number" || !Number.isFinite(at)) return state;
500
+ const update = {
501
+ id: updateIdOf(seq, state.source),
502
+ kind: "advisor",
503
+ message,
504
+ at,
505
+ ...state.source === void 0 ? {} : { source: state.source }
506
+ };
507
+ return {
508
+ ...state,
509
+ updates: capUpdates([...state.updates, update])
510
+ };
511
+ }
473
512
  /**
474
513
  * 把 `tool/call` 里的 `arguments` 原文解析成进展内容。
475
514
  *
@@ -524,7 +563,7 @@ function parseDispatchedArguments(raw) {
524
563
  function progressUpdatesProjection() {
525
564
  return {
526
565
  key: PROGRESS_UPDATES_PROJECTION_KEY,
527
- stateVersion: 2,
566
+ stateVersion: 3,
528
567
  stateSchema: progressUpdatesStateSchema,
529
568
  init(header) {
530
569
  const source = stringOf(header?.id);
@@ -535,10 +574,48 @@ function progressUpdatesProjection() {
535
574
  },
536
575
  apply(state, event) {
537
576
  const isNative = event?.type === "tool/call";
577
+ const isResult = event?.type === "tool/result";
538
578
  const isDispatch = event?.type === "tool/ptc-dispatch";
539
- if (!isNative && !isDispatch) return state;
579
+ if (!isNative && !isResult && !isDispatch) return state;
540
580
  const data = event.data;
541
581
  if (typeof data !== "object" || data === null) return state;
582
+ if (isResult) {
583
+ const message = data.message;
584
+ if (typeof message !== "object" || message === null || Array.isArray(message)) return state;
585
+ const result = message;
586
+ const source = result.source;
587
+ const sourceCallId = typeof source === "object" && source !== null && !Array.isArray(source) ? stringOf(source.callId) : void 0;
588
+ const callId = stringOf(result.toolCallId) ?? sourceCallId;
589
+ if (callId === void 0 || state.advisorCalls?.[callId] !== true) return state;
590
+ const advisorCalls = { ...state.advisorCalls ?? {} };
591
+ delete advisorCalls[callId];
592
+ const next = {
593
+ ...state,
594
+ advisorCalls
595
+ };
596
+ if (result.isError === true) return next;
597
+ const text = contentTextOf(result.content);
598
+ return text === "" ? next : appendAdvisorUpdate(next, event, text);
599
+ }
600
+ if (isDispatch && data.name === "consult_advisor") {
601
+ if (data.isError === true) return state;
602
+ const text = contentTextOf(data.content);
603
+ return text === "" ? state : appendAdvisorUpdate(state, event, text);
604
+ }
605
+ if (isNative && data.name === "consult_advisor") {
606
+ const callId = stringOf(data.callId);
607
+ if (callId === void 0) return state;
608
+ const advisorCalls = {
609
+ ...state.advisorCalls ?? {},
610
+ [callId]: true
611
+ };
612
+ const pending = Object.keys(advisorCalls);
613
+ if (pending.length > MAX_PENDING_ADVISOR_CALLS) delete advisorCalls[pending[0]];
614
+ return {
615
+ ...state,
616
+ advisorCalls
617
+ };
618
+ }
542
619
  if (data.name !== "progress_update") return state;
543
620
  const body = isNative ? parseArguments(data.arguments) : parseDispatchedArguments(data.arguments);
544
621
  if (body === void 0) return state;
@@ -1165,4 +1242,4 @@ async function apply(ctx) {
1165
1242
  ctx.effect(() => installProgressUpdates(ctx, { settings: read }), "dsh-progress-updates: host half");
1166
1243
  }
1167
1244
  //#endregion
1168
- export { resolveProgressUpdatesSettings as a, name as i, attachProgressSettings as n, inject as r, apply as t };
1245
+ export { resolveProgressUpdatesSettings as a, name as i, attachProgressSettings as n, PROGRESS_UPDATE_LANGUAGES as o, inject as r, apply as t };
@@ -1,2 +1,2 @@
1
- import { i as name, n as attachProgressSettings, r as inject, t as apply } from "./progress-updates-jiHnSAmz.js";
1
+ import { i as name, n as attachProgressSettings, r as inject, t as apply } from "./progress-updates-ART24-8J.js";
2
2
  export { apply, attachProgressSettings, inject, name };