@eddyskywalker/dsh-chatgpt-subscription 0.8.0-alpha.1 → 0.8.2

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 (85) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +65 -0
  3. package/lib/client.js +2051 -456
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +4762 -1711
  6. package/lib/types/client/CodexSubscriptionSection.d.ts.map +1 -1
  7. package/lib/types/client/ProviderHubSection.d.ts.map +1 -1
  8. package/lib/types/client/antigravity/AntigravitySection.d.ts.map +1 -1
  9. package/lib/types/client/antigravity/locales.d.ts +14 -2
  10. package/lib/types/client/antigravity/locales.d.ts.map +1 -1
  11. package/lib/types/client/antigravity/styles.d.ts.map +1 -1
  12. package/lib/types/client/command-code/CommandCodeSection.d.ts.map +1 -1
  13. package/lib/types/client/command-code/locales.d.ts +14 -2
  14. package/lib/types/client/command-code/locales.d.ts.map +1 -1
  15. package/lib/types/client/index.d.ts +1 -0
  16. package/lib/types/client/index.d.ts.map +1 -1
  17. package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
  18. package/lib/types/client/kimi-code/locales.d.ts +14 -2
  19. package/lib/types/client/kimi-code/locales.d.ts.map +1 -1
  20. package/lib/types/client/kimi-code/styles.d.ts.map +1 -1
  21. package/lib/types/client/locales.d.ts +13 -5
  22. package/lib/types/client/locales.d.ts.map +1 -1
  23. package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +1 -1
  24. package/lib/types/client/workbuddy/locales.d.ts +84 -0
  25. package/lib/types/client/workbuddy/locales.d.ts.map +1 -1
  26. package/lib/types/client/zhipu/ZhipuComposerQuota.d.ts +26 -0
  27. package/lib/types/client/zhipu/ZhipuComposerQuota.d.ts.map +1 -0
  28. package/lib/types/client/zhipu/ZhipuSection.d.ts +11 -0
  29. package/lib/types/client/zhipu/ZhipuSection.d.ts.map +1 -0
  30. package/lib/types/client/zhipu/locales.d.ts +275 -0
  31. package/lib/types/client/zhipu/locales.d.ts.map +1 -0
  32. package/lib/types/client/zhipu/styles.d.ts +12 -0
  33. package/lib/types/client/zhipu/styles.d.ts.map +1 -0
  34. package/lib/types/host/antigravity/token-store.d.ts +5 -2
  35. package/lib/types/host/antigravity/token-store.d.ts.map +1 -1
  36. package/lib/types/host/command-code/routes.d.ts.map +1 -1
  37. package/lib/types/host/command-code/token-store.d.ts +5 -2
  38. package/lib/types/host/command-code/token-store.d.ts.map +1 -1
  39. package/lib/types/host/common/context-window-overrides.d.ts +12 -0
  40. package/lib/types/host/common/context-window-overrides.d.ts.map +1 -0
  41. package/lib/types/host/kimi-code/routes.d.ts.map +1 -1
  42. package/lib/types/host/kimi-code/token-store.d.ts +5 -2
  43. package/lib/types/host/kimi-code/token-store.d.ts.map +1 -1
  44. package/lib/types/host/preferences.d.ts.map +1 -1
  45. package/lib/types/host/routes.d.ts.map +1 -1
  46. package/lib/types/host/workbuddy/checkin.d.ts +134 -0
  47. package/lib/types/host/workbuddy/checkin.d.ts.map +1 -0
  48. package/lib/types/host/workbuddy/routes.d.ts +3 -0
  49. package/lib/types/host/workbuddy/routes.d.ts.map +1 -1
  50. package/lib/types/host/workbuddy/token-store.d.ts +29 -3
  51. package/lib/types/host/workbuddy/token-store.d.ts.map +1 -1
  52. package/lib/types/host/zhipu/account-pool.d.ts +43 -0
  53. package/lib/types/host/zhipu/account-pool.d.ts.map +1 -0
  54. package/lib/types/host/zhipu/adapter.d.ts +93 -0
  55. package/lib/types/host/zhipu/adapter.d.ts.map +1 -0
  56. package/lib/types/host/zhipu/client.d.ts +153 -0
  57. package/lib/types/host/zhipu/client.d.ts.map +1 -0
  58. package/lib/types/host/zhipu/mapper.d.ts +111 -0
  59. package/lib/types/host/zhipu/mapper.d.ts.map +1 -0
  60. package/lib/types/host/zhipu/model-catalog.d.ts +73 -0
  61. package/lib/types/host/zhipu/model-catalog.d.ts.map +1 -0
  62. package/lib/types/host/zhipu/routes.d.ts +33 -0
  63. package/lib/types/host/zhipu/routes.d.ts.map +1 -0
  64. package/lib/types/host/zhipu/token-store.d.ts +112 -0
  65. package/lib/types/host/zhipu/token-store.d.ts.map +1 -0
  66. package/lib/types/host/zhipu/types.d.ts +125 -0
  67. package/lib/types/host/zhipu/types.d.ts.map +1 -0
  68. package/lib/types/index.d.ts +8 -0
  69. package/lib/types/index.d.ts.map +1 -1
  70. package/lib/types/shared/antigravity-contracts.d.ts +2 -1
  71. package/lib/types/shared/antigravity-contracts.d.ts.map +1 -1
  72. package/lib/types/shared/command-code-contracts.d.ts +2 -1
  73. package/lib/types/shared/command-code-contracts.d.ts.map +1 -1
  74. package/lib/types/shared/contracts.d.ts +5 -9
  75. package/lib/types/shared/contracts.d.ts.map +1 -1
  76. package/lib/types/shared/kimi-code-contracts.d.ts +2 -1
  77. package/lib/types/shared/kimi-code-contracts.d.ts.map +1 -1
  78. package/lib/types/shared/model-catalog.d.ts +6 -4
  79. package/lib/types/shared/model-catalog.d.ts.map +1 -1
  80. package/lib/types/shared/preferences.d.ts.map +1 -1
  81. package/lib/types/shared/workbuddy-contracts.d.ts +42 -1
  82. package/lib/types/shared/workbuddy-contracts.d.ts.map +1 -1
  83. package/lib/types/shared/zhipu-contracts.d.ts +156 -0
  84. package/lib/types/shared/zhipu-contracts.d.ts.map +1 -0
  85. package/package.json +31 -31
@@ -4,6 +4,7 @@ import { FileCredentialStore, FileModelSettingsStore, type WorkBuddyPreferenceSt
4
4
  import { getCachedQuota } from './client.ts';
5
5
  import { type WorkBuddyModelEntry } from './model-catalog.ts';
6
6
  import type { WorkBuddyModelOption, WorkBuddyWebStatus } from '../../shared/workbuddy-contracts.ts';
7
+ import type { WorkBuddyCheckinService } from './checkin.ts';
7
8
  import type { WorkBuddyAccountPool } from './account-pool.ts';
8
9
  /**
9
10
  * The selection the card should show.
@@ -24,6 +25,8 @@ export interface WorkBuddyStatusOptions {
24
25
  conflict?: string | null | (() => string | null);
25
26
  /** Multi-account pool this line schedules through; absent keeps the single-account card. */
26
27
  accountPool?: WorkBuddyAccountPool;
28
+ /** Daily check-in scheduler; absent leaves the card's check-in row empty. */
29
+ checkin?: Pick<WorkBuddyCheckinService, 'tick' | 'summary'>;
27
30
  }
28
31
  /** Everything the settings card renders: account, quota, and the model catalog. */
29
32
  export declare function getWorkBuddyWebStatus(store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: WorkBuddyPreferenceStore, options?: WorkBuddyStatusOptions): Promise<WorkBuddyWebStatus>;
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAGL,sBAAsB,EACtB,WAAW,EACX,aAAa,EAEd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAGtB,KAAK,wBAAwB,EAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAKL,cAAc,EAIf,MAAM,aAAa,CAAA;AACpB,OAAO,EASL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAGV,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,qCAAqC,CAAA;AAG5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAyD7D;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,OAAO,UAAO,GACb,MAAM,EAAE,CASV;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,mBAAmB,EAAE,EACvC,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,eAAe,EAAE,SAAS,MAAM,EAAE,EAClC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,oBA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ACrC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,sBAAsB,EACrC,WAAW,CAAC,EAAE,wBAAwB,EACtC,OAAO,GAAE,sBAA2B,GACnC,MAAM,IAAI,CAwWZ;AAED,OAAO,EACL,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,CAAA"}
@@ -1,4 +1,5 @@
1
- import type { WorkBuddyReasoningEffort, WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
1
+ import type { WorkBuddyCheckinSettings, WorkBuddyReasoningEffort, WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
2
+ import { type ContextWindowOverridePatch } from '../common/context-window-overrides.ts';
2
3
  import type { CredentialStore } from '../token-store.ts';
3
4
  import { isIntlDomain } from './types.ts';
4
5
  export declare const WORKBUDDY_PREFERENCES_NAMESPACE = "dsh-workbuddy";
@@ -45,18 +46,41 @@ export interface WorkBuddyModelSettings {
45
46
  selectedAccountId: string | null;
46
47
  /** Desktop accounts hidden from this plugin without deleting CodeBuddy files. */
47
48
  hiddenAccountIds: string[];
49
+ /** Daily check-in scheduler preferences. */
50
+ checkin: WorkBuddyCheckinSettings;
48
51
  }
49
52
  export interface WorkBuddyPreferenceStore {
53
+ /**
54
+ * Resolve once the store has read whatever it was going to read.
55
+ *
56
+ * The file-backed store warms up asynchronously, so `status()` answers from
57
+ * shipped defaults until that read settles. A caller that acts on a
58
+ * preference at startup — the check-in scheduler signing in on boot — must
59
+ * await this first, or it acts on the default instead of the user's choice.
60
+ * A register-backed store reads synchronously and resolves immediately.
61
+ */
62
+ ready(): Promise<void>;
50
63
  status(): WorkBuddyModelSettings;
51
64
  update(patch: {
52
65
  enabled?: boolean;
53
66
  enabledModelIds?: string[];
54
- contextWindowOverrides?: Record<string, number>;
67
+ /** `null` deletes one override and falls back to the catalog default. */
68
+ contextWindowOverrides?: ContextWindowOverridePatch;
55
69
  defaultReasoningEffort?: WorkBuddyReasoningEffort | null;
56
70
  selectedAccountId?: string | null;
57
71
  hiddenAccountIds?: string[];
72
+ checkin?: Partial<WorkBuddyCheckinSettings>;
58
73
  }): Promise<WorkBuddyModelSettings>;
59
74
  }
75
+ /** Shipped check-in default: on. */
76
+ export declare const DEFAULT_CHECKIN_SETTINGS: WorkBuddyCheckinSettings;
77
+ /**
78
+ * Narrow an unknown stored/patched value into valid check-in settings.
79
+ *
80
+ * Documents written while the window was still configurable may carry
81
+ * startHour/endHour; those keys are inert now and dropped on the next write.
82
+ */
83
+ export declare function normalizeCheckinSettings(value: unknown): WorkBuddyCheckinSettings;
60
84
  /**
61
85
  * Bind the model selection to the DSH settings document when the harness still
62
86
  * offers one, and to the JSON file beside it otherwise: a harness without the
@@ -231,10 +255,12 @@ export declare class FileModelSettingsStore {
231
255
  updateSettings(patch: {
232
256
  enabled?: boolean;
233
257
  enabledModelIds?: string[];
234
- contextWindowOverrides?: Record<string, number>;
258
+ /** `null` deletes one override and falls back to the catalog default. */
259
+ contextWindowOverrides?: ContextWindowOverridePatch;
235
260
  defaultReasoningEffort?: WorkBuddyReasoningEffort | null;
236
261
  selectedAccountId?: string | null;
237
262
  hiddenAccountIds?: string[];
263
+ checkin?: Partial<WorkBuddyCheckinSettings>;
238
264
  }): Promise<WorkBuddyModelSettings>;
239
265
  }
240
266
  export { isIntlDomain };
@@ -1 +1 @@
1
- {"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/token-store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAMpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAIxD,OAAO,EAGL,YAAY,EAEb,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,+BAA+B,kBAAkB,CAAA;AAE9D,YAAY,EAAE,wBAAwB,EAAE,CAAA;AAOxC;;;;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AC,IAAI,CAAC;IAK5D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMxD,oEAAoE;IACpE,UAAU,IAAI,IAAI;IAKlB;;;;;;OAMG;IACG,WAAW,CACf,WAAW,EAAE,oBAAoB,EACjC,OAAO,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,oBAAoB,CAAC,GACxE,OAAO,CAAC,oBAAoB,CAAC;IAuBhC;;;;;;;OAOG;IACG,SAAS,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAmClE;AAED,+EAA+E;AAC/E,qBAAa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,SAAsB;IAE3D,IAAI,IAAI,MAAM;IAIR,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;IA8CvC,KAAK,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtD,cAAc,CAAC,KAAK,EAAE;QAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;QAC1B,yEAAyE;QACzE,sBAAsB,CAAC,EAAE,0BAA0B,CAAA;QACnD,sBAAsB,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAA;QACxD,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACjC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAA;KAC5C,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAyBpC;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { AccountPoolCore, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
2
+ import type { CredentialStore } from '../token-store.ts';
3
+ import { FileCredentialStore, type ZhipuCredentials } from './token-store.ts';
4
+ import type { ZhipuAccountSummaryDto, ZhipuRegion } from '../../shared/zhipu-contracts.ts';
5
+ /** One pooled GLM Coding Plan key: the credential plus the facts the card renders. */
6
+ export interface ZhipuPoolAccount extends PoolAccountShape<ZhipuCredentials> {
7
+ region: ZhipuRegion;
8
+ keyHint?: string;
9
+ apiBase?: string;
10
+ planLabel?: string;
11
+ planLevel?: string;
12
+ }
13
+ export type { ZhipuAccountSummaryDto };
14
+ /** Encrypted pool file this line owns; the pre-pool credential file stays the mirror. */
15
+ export declare function zhipuPoolPath(): string;
16
+ /** Validate and normalize one whole pool document. */
17
+ export declare function parseZhipuPoolData(value: unknown): PoolData<ZhipuPoolAccount>;
18
+ export interface ZhipuAccountPoolOptions {
19
+ /** Pre-pool credential file the pool mirrors its primary account into. */
20
+ store?: FileCredentialStore;
21
+ /** Test seam; production builds the platform backend from the pool path. */
22
+ backend?: CredentialStore<PoolData<ZhipuPoolAccount>>;
23
+ /** Accounts this pool accepts; defaults to the core's limit. */
24
+ maxAccounts?: number;
25
+ /** Account the card pinned, or null for automatic selection. */
26
+ preferAccountId?: () => string | null;
27
+ }
28
+ /**
29
+ * The GLM Coding Plan account pool.
30
+ *
31
+ * A Coding Plan credential is a long-lived console key with nothing to refresh,
32
+ * so this wrapper only supplies identity, display facts, and the mirror of the
33
+ * single-credential file the plugin used before the pool existed. Rotation is
34
+ * meaningful here for the same reason it is on the other key-based lines: a
35
+ * spent plan window is per-account, so another account can serve the turn.
36
+ */
37
+ export declare class ZhipuAccountPool extends AccountPoolCore<ZhipuCredentials, ZhipuPoolAccount, ZhipuAccountSummaryDto> {
38
+ private readonly store;
39
+ constructor(options?: ZhipuAccountPoolOptions);
40
+ /** The pre-pool credential file this pool mirrors its primary account into. */
41
+ mirrorStore(): FileCredentialStore;
42
+ }
43
+ //# sourceMappingURL=account-pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-pool.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/account-pool.ts"],"names":[],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,+EAA+E;IAC/E,WAAW,IAAI,mBAAmB;CAGnC"}
@@ -0,0 +1,93 @@
1
+ import { LlmAdapter, LlmError, ReasoningEffortId, type GenerateOptions, type LlmModelInfo, type LlmProviderInfo, type LlmResolvedModelInfo, type PreparedAdapterCall, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
2
+ import { PROVIDER_ID, PROVIDER_NAME } from './types.ts';
3
+ import { FileCredentialStore, FileModelSettingsStore, type ZhipuPreferenceStore } from './token-store.ts';
4
+ import { type ZhipuModelEntry } from './model-catalog.ts';
5
+ import { type AttachmentImageReader } from './mapper.ts';
6
+ import type { ZhipuCredentials } from './token-store.ts';
7
+ import type { ZhipuAccountPool } from './account-pool.ts';
8
+ /**
9
+ * Effort this route materializes when the caller names none.
10
+ *
11
+ * Preference order: the caller's explicit level when the model accepts it,
12
+ * otherwise the user's configured level when the model accepts it, otherwise
13
+ * nothing. Nothing is a real answer on this route: the provider's own default
14
+ * is `max` for a model that takes an effort field, so omitting the field is not
15
+ * "no thinking" — it is the provider's documented default.
16
+ *
17
+ * A candidate outside the model's ladder is converged onto the nearest rung
18
+ * rather than sent, because an unsupported level is an error (`code 1214`), and
19
+ * rather than dropped, because dropping the user's explicit choice silently
20
+ * changes how hard the model thinks.
21
+ */
22
+ export declare function resolveDefaultReasoningEffort(efforts: readonly string[], configuredEffort?: string | null): ReasoningEffortId | undefined;
23
+ /**
24
+ * Cooldown a 429 imposes when the service names no reset instant.
25
+ *
26
+ * The plan's allowance windows are hours long, so a shorter cooldown would
27
+ * rediscover the same exhausted window immediately.
28
+ */
29
+ export declare const POOL_COOLDOWN_MS: number;
30
+ export interface ZhipuAdapterOptions {
31
+ fetchFn?: typeof fetch;
32
+ attachments?: AttachmentImageReader;
33
+ /** Live catalog loader seam; defaults to the managed `/models` call. */
34
+ loadCatalog?: (credentials: ZhipuCredentials) => Promise<ZhipuModelEntry[]>;
35
+ /**
36
+ * Multi-account pool this adapter rotates through.
37
+ *
38
+ * Absent leaves the line on its single-credential path, which is what the
39
+ * headless tests and any caller that predates the pool use.
40
+ */
41
+ accountPool?: ZhipuAccountPool;
42
+ }
43
+ export declare class ZhipuAdapter extends LlmAdapter {
44
+ private readonly store;
45
+ private readonly modelSettings;
46
+ private readonly preferences?;
47
+ private readonly options;
48
+ /** Null keeps the pre-pool single-credential path. */
49
+ private readonly accountPool;
50
+ constructor(store?: FileCredentialStore, modelSettings?: FileModelSettingsStore, preferences?: ZhipuPreferenceStore | undefined, options?: ZhipuAdapterOptions);
51
+ providerInfo(provider: string): LlmProviderInfo;
52
+ providerRetryPolicy(): ResolvedRetryPolicy;
53
+ imageRequestPricing(): undefined;
54
+ private settings;
55
+ /**
56
+ * Credential the picker and the single-credential path read.
57
+ *
58
+ * With a pool installed the store holds the mirrored primary account, so this
59
+ * stays the same read path either way; the pool is consulted only when a
60
+ * request is actually served, which is where per-account rotation matters.
61
+ */
62
+ private credentials;
63
+ private catalog;
64
+ listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
65
+ resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
66
+ prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
67
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
68
+ /**
69
+ * Effort this request should carry, or `undefined` to send none.
70
+ *
71
+ * Order: the caller's explicit choice, then the user's configured level. Both
72
+ * are converged onto the model's own ladder — the provider rejects a level
73
+ * outside it — and a model that declares no ladder gets none, because sending
74
+ * an effort to a model that takes no such field is exactly the 400 this
75
+ * convergence exists to avoid.
76
+ */
77
+ private effortFor;
78
+ private requestStream;
79
+ }
80
+ /**
81
+ * Map one failed HTTP response onto a DSH failure.
82
+ *
83
+ * The platform reports its own condition inside a JSON `code` while the status
84
+ * line stays generic, so the body is read for the cases the status alone cannot
85
+ * express. Several distinct conditions share one status — 429 covers a spent
86
+ * window, a lapsed plan, and a per-model entitlement gap — and they need
87
+ * different actions, which is exactly why the code decides.
88
+ */
89
+ export declare function classifyFailure(status: number, detail: string, headers?: Headers): LlmError;
90
+ /** Read the platform's own numeric error code out of a response body. */
91
+ export declare function readErrorCode(detail: string): number | null;
92
+ export { PROVIDER_ID, PROVIDER_NAME };
93
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/adapter.ts"],"names":[],"mappings":"AAAA,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,EAGL,WAAW,EACX,aAAa,EAGd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAEtB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAQL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAQL,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAmBzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAC/B,iBAAiB,GAAG,SAAS,CAO/B;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAiB,CAAA;AAE9C,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;IACtB,WAAW,CAAC,EAAE,qBAAqB,CAAA;IACnC,wEAAwE;IACxE,W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d,OAAO,CAAC,EAAE,OAAO,GAChB,QAAQ,CAqGV;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK3D;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,153 @@
1
+ import type { ZhipuAccount, ZhipuAccountQuota, ZhipuMeter, ZhipuQuotaWindow } from '../../shared/zhipu-contracts.ts';
2
+ import { DEFAULT_CONTEXT_WINDOW, ERROR_CODE, PROVIDER_NAME } from './types.ts';
3
+ import { type ZhipuCredentials } from './token-store.ts';
4
+ import { ZHIPU_MODELS, type ZhipuModelEntry } from './model-catalog.ts';
5
+ export interface ZhipuRequestOptions {
6
+ fetchFn?: typeof fetch;
7
+ signal?: AbortSignal;
8
+ }
9
+ /**
10
+ * Headers one model request carries.
11
+ *
12
+ * The chat surface uses the documented bearer form. The key never appears in a
13
+ * log line: only the response body and status are ever reported.
14
+ */
15
+ export declare function zhipuHeaders(credentials: Pick<ZhipuCredentials, 'apiKey'>, extra?: Record<string, string>): Record<string, string>;
16
+ /**
17
+ * Headers the monitor/subscription surfaces carry.
18
+ *
19
+ * These two answer to the **raw** key with no `Bearer` prefix, which is the
20
+ * scheme the plan's own usage page uses: measured live, a request carrying the
21
+ * prefixed form is rejected with `code 401` where the raw form authenticates.
22
+ */
23
+ export declare function zhipuMonitorHeaders(apiKey: string, extra?: Record<string, string>): Record<string, string>;
24
+ /** Public account facts for the settings card. */
25
+ export declare function accountFromCredentials(credentials: ZhipuCredentials): ZhipuAccount;
26
+ /**
27
+ * Read the platform's own envelope error out of a business-level refusal.
28
+ *
29
+ * These two surfaces answer HTTP 200 with `success: false` and a numeric `code`
30
+ * for an authentication problem, so a caller that only checks `response.ok`
31
+ * would treat a rejected key as a successful read. Returns null when the body
32
+ * is not a refusal.
33
+ */
34
+ export declare function readEnvelopeError(payload: unknown): {
35
+ code: number | null;
36
+ message: string;
37
+ } | null;
38
+ /**
39
+ * Verify one key by asking the model listing for it.
40
+ *
41
+ * The listing is the cheapest authenticated read on the Coding Plan surface and
42
+ * is the same host the chat requests go to, so a success proves the key works
43
+ * on the deployment it was entered for. A key from the wrong console (a general
44
+ * open-platform key, or one issued by the other region) is rejected here rather
45
+ * than failing later inside a conversation.
46
+ *
47
+ * @returns the live catalog this read produced, so a caller that verifies does
48
+ * not have to fetch it again.
49
+ */
50
+ export declare function verifyApiKey(apiKey: string, region: ZhipuCredentials['region'], options?: ZhipuRequestOptions): Promise<ZhipuModelEntry[]>;
51
+ /** Console the user must have created the key on, named as it appears there. */
52
+ export declare function consoleName(region: ZhipuCredentials['region']): string;
53
+ /**
54
+ * Parse one `/models` payload.
55
+ *
56
+ * The listing reports each model's context window. It is merged over the
57
+ * shipped table, which stays the authority on the reasoning ladder and on image
58
+ * support: the listing states a window but not a capability, so a field it
59
+ * omits keeps the value this table declares rather than becoming a guess.
60
+ */
61
+ export declare function parseCatalogModels(payload: unknown, region: ZhipuCredentials['region']): ZhipuModelEntry[];
62
+ export declare function getCachedCatalog(): ZhipuModelEntry[];
63
+ export declare function clearCachedCatalog(): void;
64
+ /**
65
+ * Fetch the live catalog for one account.
66
+ *
67
+ * A failure returns an empty list and the caller falls back to the shipped
68
+ * table, which keeps a first run usable before sign-in.
69
+ */
70
+ export declare function fetchCatalog(credentials: ZhipuCredentials, options?: ZhipuRequestOptions): Promise<ZhipuModelEntry[]>;
71
+ /**
72
+ * Cached catalog with a TTL; a failed refresh keeps the previous snapshot.
73
+ *
74
+ * A snapshot read for the *other* region must never stand in: its entries
75
+ * declare only the region they came from, so the caller's region filter would
76
+ * drop every one of them and the picker would offer nothing instead of falling
77
+ * back to the shipped table.
78
+ */
79
+ export declare function loadCatalog(credentials: ZhipuCredentials, options?: ZhipuRequestOptions & {
80
+ force?: boolean;
81
+ }): Promise<ZhipuModelEntry[]>;
82
+ /**
83
+ * Window length in minutes implied by one reported window.
84
+ *
85
+ * The monitor service describes a window by a unit and a number rather than by
86
+ * a name: `unit 3 × number 5` is the plan's 5-hour credit window and
87
+ * `unit 6 × number 1` is its weekly one. The exact unit vocabulary is not
88
+ * documented, so this maps the two combinations the plan's own usage page shows
89
+ * and derives minutes from anything else it does not recognise.
90
+ */
91
+ export declare function windowMinutesOf(unit: number | undefined, number: number | undefined): number | null;
92
+ /** Turn one window length into the label the card shows. */
93
+ export declare function windowLabel(minutes: number | null, fallback: string): string;
94
+ /** One parsed limit entry from the monitor service. */
95
+ export interface ParsedQuotaLimit {
96
+ type: string;
97
+ unit: number | undefined;
98
+ number: number | undefined;
99
+ percentage: number | undefined;
100
+ currentValue: number | undefined;
101
+ total: number | undefined;
102
+ resetsAt: number | null;
103
+ usageDetails: Record<string, unknown> | undefined;
104
+ }
105
+ /**
106
+ * Parse the monitor payload's `limits` array.
107
+ *
108
+ * The plan's own page renders these directly. A limit is either a token/credit
109
+ * window (`TOKENS_LIMIT`, renamed `CREDIT_LIMIT` in newer responses) or a
110
+ * tool-call allowance (`TIME_LIMIT`); both shapes are read here rather than
111
+ * pinned to one spelling, because the service has used both names.
112
+ */
113
+ export declare function parseQuotaLimits(payload: unknown): ParsedQuotaLimit[];
114
+ /** Whether a limit entry is a token/credit window under either spelling. */
115
+ export declare function isTokenLimit(type: string): boolean;
116
+ /** Whether a limit entry is a tool-call allowance. */
117
+ export declare function isToolLimit(type: string): boolean;
118
+ /** Build the window list the card renders from the parsed limits. */
119
+ export declare function quotaWindows(limits: readonly ParsedQuotaLimit[]): ZhipuQuotaWindow[];
120
+ /** Build the meter list the card renders, windows and tool allowance together. */
121
+ export declare function quotaMeters(windows: readonly ZhipuQuotaWindow[], limits: readonly ParsedQuotaLimit[]): ZhipuMeter[];
122
+ /** Plan facts the subscription route reports. */
123
+ export interface ZhipuPlan {
124
+ planName: string | null;
125
+ planLevel: string | null;
126
+ renewsAt: number | null;
127
+ }
128
+ /**
129
+ * Parse the plan payload.
130
+ *
131
+ * Best effort by design: the quota meters are what the card is for, so a
132
+ * failure here must degrade to "no plan line" rather than blank the panel. The
133
+ * subscription host returns the plan under `data`, and the level is reported
134
+ * either as a machine name or as an expiry-bearing record; both shapes are read.
135
+ */
136
+ export declare function parsePlan(payload: unknown): ZhipuPlan;
137
+ export declare function getCachedQuota(): ZhipuAccountQuota | undefined;
138
+ export declare function clearCachedQuota(): void;
139
+ /**
140
+ * Read the account's plan allowance.
141
+ *
142
+ * Two routes answer this snapshot: the monitor route carries the windows, and
143
+ * the subscription route carries the plan name. They are independent, so a
144
+ * failure of the optional one must not blank the panel — but a failure of the
145
+ * monitor route is a real failure and is raised, because a snapshot with no
146
+ * windows would otherwise render as "nothing consumed".
147
+ */
148
+ export declare function fetchAccountQuota(credentials: ZhipuCredentials, options?: ZhipuRequestOptions & {
149
+ force?: boolean;
150
+ }): Promise<ZhipuAccountQuota>;
151
+ /** The shipped table, re-exported so callers need only this module. */
152
+ export { ZHIPU_MODELS, DEFAULT_CONTEXT_WINDOW, PROVIDER_NAME, ERROR_CODE };
153
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EACjB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAGL,sBAAsB,EAEtB,UAAU,EAGV,aAAa,EAMd,MAAM,YAAY,CAAA;AACnB,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAqB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAE1F,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AA6BD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,IAAI,CAAC,gBAAgB,EA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gBAAgB,EAAE,GAAG,UAAU,EAAE,CA2BnH;AAED,iDAAiD;AACjD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAgCrD;AAOD,wBAAgB,cAAc,IAAI,iBAAiB,GAAG,SAAS,CAE9D;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAKvC;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,gBAAgB,EAC7B,OAAO,GAAE,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACtD,OAAO,CAAC,iBAAiB,CAAC,CAwF5B;AAED,uEAAuE;AACvE,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,UAAU,EAAE,CAAA"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Wire mapping for the GLM Coding Plan chat endpoint.
3
+ *
4
+ * The endpoint is OpenAI Chat Completions shaped. This module absorbs the
5
+ * differences this route actually has, each one drawn from the provider's own
6
+ * documentation rather than assumed from the OpenAI default:
7
+ *
8
+ * 1. **Reasoning rides `delta.reasoning_content`,** not OpenAI's
9
+ * `reasoning_summary`, and is emitted as its own DSH reasoning block.
10
+ * 2. **`reasoning_effort` accepts only the model's own ladder.** The GLM-5.x
11
+ * family takes `low`/`high`/`max` (GLM-5.2 takes two of them), and any other
12
+ * value is an error rather than a hint. DSH's vocabulary is wider, so every
13
+ * value is converged onto the model's ladder before it is sent.
14
+ * 3. **`thinking` is left untouched.** Its default is `enabled`, and
15
+ * GLM-5.3 / GLM-5.3-FLASH / GLM-4.7 reject `thinking.type: "disabled"` as an
16
+ * error — so this route never sends a disabling value for any model and
17
+ * simply omits the field, which is the enabled default for all of them.
18
+ * 4. **No `stream_options`.** The provider's streaming documentation shows the
19
+ * usage object arriving on the final chunk without it, and the field is
20
+ * absent from the documented request schema; sending an undocumented field
21
+ * to this API risks a 400 for no gain.
22
+ */
23
+ import { type OutboundContentBlock, type GenerateOptions, type StreamChunk } from '../common/llm-compat.ts';
24
+ import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
25
+ /** Attachment seam this route needs: verified bytes for one durable image. */
26
+ export type AttachmentImageReader = Pick<AttachmentStore, 'readImage'>;
27
+ /** One durable user image resolved for an in-flight request, or proven unreadable. */
28
+ export type ResolvedRequestImage = {
29
+ readonly kind: 'inline';
30
+ readonly mediaType: string;
31
+ readonly data: string;
32
+ } | {
33
+ readonly kind: 'unavailable';
34
+ };
35
+ /** Resolved images keyed by durable attachment id; consumed by one request build. */
36
+ export type ResolvedRequestImages = ReadonlyMap<string, ResolvedRequestImage>;
37
+ /**
38
+ * Base64 image payload one request may carry.
39
+ *
40
+ * 12 MB matches what this plugin's other routes allow and keeps the
41
+ * conversation text and tool schemas in the same body.
42
+ */
43
+ export declare const MAX_REQUEST_IMAGE_BYTES: number;
44
+ /**
45
+ * Replace the oldest inline images with a text placeholder once one request
46
+ * would carry more than {@link MAX_REQUEST_IMAGE_BYTES} of base64 image data.
47
+ * Durable history is untouched; only the request about to be sent changes.
48
+ */
49
+ export declare function offloadOldestRequestImages(options: GenerateOptions): GenerateOptions;
50
+ /**
51
+ * Read every durable `{ type: 'image', attachment }` block one request carries.
52
+ * An unreadable image resolves to `unavailable` rather than disappearing, so
53
+ * the model is told the picture is missing instead of answering about a blank.
54
+ */
55
+ export declare function resolveRequestImages(options: GenerateOptions, attachments: AttachmentImageReader | undefined, signal?: AbortSignal): Promise<ResolvedRequestImages>;
56
+ /** Drop the JSON-Schema keywords provider gateways reject or ignore. */
57
+ export declare function stripMetaSchema(schema: unknown): Record<string, unknown>;
58
+ /**
59
+ * Build one `/api/coding/paas/v4/chat/completions` body.
60
+ *
61
+ * `reasoning_effort` is only included when the caller's level is already one
62
+ * the model declares. A level outside that ladder is dropped rather than
63
+ * snapped here: the adapter converges it against the model's own declaration
64
+ * before calling in, so a value reaching this builder is either valid or was
65
+ * deliberately withheld, and guessing here would hide a bug in that step.
66
+ */
67
+ export declare function buildChatRequest(options: GenerateOptions, images?: ResolvedRequestImages, declaredEfforts?: readonly string[]): Record<string, unknown>;
68
+ interface PendingToolCall {
69
+ blockIndex: number;
70
+ id: string;
71
+ name: string;
72
+ arguments: string;
73
+ started: boolean;
74
+ }
75
+ export interface ZhipuStreamState {
76
+ blocks: OutboundContentBlock[];
77
+ current: {
78
+ index: number;
79
+ type: 'text' | 'reasoning';
80
+ text: string;
81
+ } | null;
82
+ /** wire tool index -> accumulating call. */
83
+ toolCalls: Map<number, PendingToolCall>;
84
+ hasContent: boolean;
85
+ hasToolCall: boolean;
86
+ finishReason: string | null;
87
+ /** The `[DONE]` sentinel arrived. */
88
+ done: boolean;
89
+ /** Terminal chunks were already emitted. */
90
+ finished: boolean;
91
+ inputTokens: number;
92
+ outputTokens: number;
93
+ cacheReadTokens: number;
94
+ reasoningTokens: number;
95
+ sawUsage: boolean;
96
+ }
97
+ export declare function createStreamState(): ZhipuStreamState;
98
+ /** Feed one SSE line from the Coding Plan chat endpoint. */
99
+ export declare function processStreamLine(line: string, state: ZhipuStreamState): StreamChunk[];
100
+ /** Flush every open block, then emit usage and the terminal finish. */
101
+ export declare function closeStream(state: ZhipuStreamState): StreamChunk[];
102
+ /**
103
+ * A stream that ends without a terminal event is truncated, not complete.
104
+ *
105
+ * The endpoint always terminates with either `finish_reason` or `[DONE]`, so
106
+ * their absence means the connection dropped mid-answer and the partial text
107
+ * must not be presented as a finished reply.
108
+ */
109
+ export declare function assertStreamComplete(state: ZhipuStreamState): void;
110
+ export {};
111
+ //# sourceMappingURL=mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/mapper.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 *
4
+ * The runtime authority is the plan's own `/api/coding/paas/v4/models` listing,
5
+ * which reports each model's real context window; this table stands in before
6
+ * the first successful fetch and for a machine that cannot reach it yet.
7
+ *
8
+ * Nothing here is inferred from a model's name. Image support and the accepted
9
+ * reasoning ladder are per-model facts that the family name does not decide:
10
+ * `glm-5.3-flash` takes images while `glm-5.3` does not, and `glm-5.2` accepts
11
+ * two effort levels where `glm-5.3` accepts three.
12
+ *
13
+ * Sources, checked 2026-09 against the provider's published specification:
14
+ * - the Coding Plan model registry (`zai-coding-plan` on models.dev), which
15
+ * lists exactly the models the plan's own base URL serves;
16
+ * - the model pages and core-parameter table on docs.z.ai, which give the
17
+ * 1M-token window and 128K output cap of the GLM-5.x family;
18
+ * - the deep-thinking guide, which states that GLM-5.3 / GLM-5.3-FLASH / GLM-4.7
19
+ * no longer accept `thinking.type: "disabled"`.
20
+ */
21
+ import type { ZhipuRegion } from '../../shared/zhipu-contracts.ts';
22
+ /** One model's shipped capability entry. */
23
+ export interface ZhipuModelEntry {
24
+ id: string;
25
+ name: string;
26
+ /** Context window DSH assumes before an override is saved. */
27
+ contextWindow: number;
28
+ /** Maximum output tokens this route requests when a caller omits one. */
29
+ maxTokens: number;
30
+ /**
31
+ * Reasoning levels this model accepts, in escalating order.
32
+ *
33
+ * Empty means the model takes no `reasoning_effort` at all: it reasons (or
34
+ * does not) by its own default and the field is never sent, because upstream
35
+ * rejects an unsupported level outright.
36
+ */
37
+ reasoningEfforts: readonly string[];
38
+ /** Whether the model accepts image input on this route. */
39
+ supportsImage: boolean;
40
+ /**
41
+ * Whether the model can be told to skip thinking.
42
+ *
43
+ * GLM-5.3 / GLM-5.3-FLASH / GLM-4.7 cannot: the provider documents that
44
+ * sending `thinking.type: "disabled"` to them is an error, so this route never
45
+ * sends a disabling value for them.
46
+ */
47
+ canDisableThinking: boolean;
48
+ /** Deployments that serve this model. */
49
+ regions: readonly ZhipuRegion[];
50
+ description?: string;
51
+ }
52
+ export declare const ZHIPU_MODELS: readonly ZhipuModelEntry[];
53
+ /**
54
+ * Which models the shipped table resolves to when the live listing is
55
+ * unreachable. All of them: the table is already the Coding Plan's own model
56
+ * set, and hiding an entry would give the user no way to enable it.
57
+ */
58
+ export declare const DEFAULT_VISIBLE_MODEL_IDS: readonly string[];
59
+ /** The shipped table in the shape the routes and the picker read. */
60
+ export declare const FALLBACK_MODELS: readonly ZhipuModelEntry[];
61
+ /** Look one model up, or receive an unknown-model stub that claims nothing. */
62
+ export declare function resolveZhipuModel(modelId: string, catalog?: readonly ZhipuModelEntry[]): ZhipuModelEntry;
63
+ /** Models one deployment serves. */
64
+ export declare function modelsForRegion(region: ZhipuRegion, catalog?: readonly ZhipuModelEntry[]): ZhipuModelEntry[];
65
+ /** Context window this route assumes for one model, before any override. */
66
+ export declare function defaultContextWindowFor(modelId: string, catalog?: readonly ZhipuModelEntry[]): number;
67
+ /** Output cap one request asks for when the caller omits one. */
68
+ export declare function maxOutputTokensFor(modelId: string, catalog?: readonly ZhipuModelEntry[]): number;
69
+ /** Reasoning levels one model accepts; empty when it takes no effort field. */
70
+ export declare function zhipuReasoningEfforts(modelId: string, catalog?: readonly ZhipuModelEntry[]): string[];
71
+ /** Whether one model accepts image input on this route. */
72
+ export declare function zhipuModelSupportsImage(modelId: string, catalog?: readonly ZhipuModelEntry[]): boolean;
73
+ //# sourceMappingURL=model-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/zhipu/model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAGlE,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,SAAS,EAAE,MAA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