dsh-subscriptions 0.1.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 (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -0
  3. package/cordis.patch.yml +12 -0
  4. package/lib/auth/claude-code-creds.d.ts +23 -0
  5. package/lib/auth/claude-code-creds.js +172 -0
  6. package/lib/auth/device-flow.d.ts +55 -0
  7. package/lib/auth/device-flow.js +177 -0
  8. package/lib/auth/jwt.d.ts +10 -0
  9. package/lib/auth/jwt.js +25 -0
  10. package/lib/auth/oauth-flow.d.ts +91 -0
  11. package/lib/auth/oauth-flow.js +227 -0
  12. package/lib/auth/pkce.d.ts +31 -0
  13. package/lib/auth/pkce.js +35 -0
  14. package/lib/auth/rpc.d.ts +209 -0
  15. package/lib/auth/rpc.js +386 -0
  16. package/lib/auth/store.d.ts +196 -0
  17. package/lib/auth/store.js +468 -0
  18. package/lib/client/CursorCard.d.ts +9 -0
  19. package/lib/client/CursorCard.js +113 -0
  20. package/lib/client/ExternalUsageCards.d.ts +9 -0
  21. package/lib/client/ExternalUsageCards.js +72 -0
  22. package/lib/client/ImageGallery.d.ts +54 -0
  23. package/lib/client/ImageGallery.js +112 -0
  24. package/lib/client/ImageGenerateToolview.d.ts +48 -0
  25. package/lib/client/ImageGenerateToolview.js +133 -0
  26. package/lib/client/ProviderAccountManager.d.ts +13 -0
  27. package/lib/client/ProviderAccountManager.js +147 -0
  28. package/lib/client/ProviderModelEditor.d.ts +39 -0
  29. package/lib/client/ProviderModelEditor.js +107 -0
  30. package/lib/client/SpeedSelect.d.ts +71 -0
  31. package/lib/client/SpeedSelect.js +177 -0
  32. package/lib/client/SubscriptionUsageBadge.d.ts +116 -0
  33. package/lib/client/SubscriptionUsageBadge.js +543 -0
  34. package/lib/client/SubscriptionsSection.d.ts +140 -0
  35. package/lib/client/SubscriptionsSection.js +544 -0
  36. package/lib/client/UsageBadgeDisplaySetting.d.ts +7 -0
  37. package/lib/client/UsageBadgeDisplaySetting.js +36 -0
  38. package/lib/client/VideoGenerateToolview.d.ts +42 -0
  39. package/lib/client/VideoGenerateToolview.js +175 -0
  40. package/lib/client/account-preferences.d.ts +24 -0
  41. package/lib/client/account-preferences.js +21 -0
  42. package/lib/client/fast-command.d.ts +2 -0
  43. package/lib/client/fast-command.js +4 -0
  44. package/lib/client/host-contract.d.ts +90 -0
  45. package/lib/client/host-contract.js +101 -0
  46. package/lib/client/host-icons.d.ts +24 -0
  47. package/lib/client/host-icons.js +21 -0
  48. package/lib/client/index.d.ts +27 -0
  49. package/lib/client/index.js +136 -0
  50. package/lib/client/locales.d.ts +297 -0
  51. package/lib/client/locales.js +295 -0
  52. package/lib/client/subscription-card-styles.d.ts +3 -0
  53. package/lib/client/subscription-card-styles.js +53 -0
  54. package/lib/client/subscriptions-rpc.d.ts +14 -0
  55. package/lib/client/subscriptions-rpc.js +34 -0
  56. package/lib/client/usage-badge-preferences.d.ts +11 -0
  57. package/lib/client/usage-badge-preferences.js +41 -0
  58. package/lib/client.js +4472 -0
  59. package/lib/client.js.map +1 -0
  60. package/lib/compat.d.ts +36 -0
  61. package/lib/compat.js +20 -0
  62. package/lib/http.d.ts +6 -0
  63. package/lib/http.js +15 -0
  64. package/lib/index.d.ts +80 -0
  65. package/lib/index.js +14018 -0
  66. package/lib/model-defaults.d.ts +23 -0
  67. package/lib/model-defaults.js +237 -0
  68. package/lib/provider-settings.d.ts +39 -0
  69. package/lib/provider-settings.js +151 -0
  70. package/lib/providers/account-preferences.d.ts +41 -0
  71. package/lib/providers/account-preferences.js +153 -0
  72. package/lib/providers/accounts.d.ts +112 -0
  73. package/lib/providers/accounts.js +142 -0
  74. package/lib/providers/antigravity-oauth-client.d.ts +7 -0
  75. package/lib/providers/antigravity-oauth-client.js +7 -0
  76. package/lib/providers/antigravity.d.ts +110 -0
  77. package/lib/providers/antigravity.js +516 -0
  78. package/lib/providers/catalog-store.d.ts +48 -0
  79. package/lib/providers/catalog-store.js +243 -0
  80. package/lib/providers/claude-cli-version.d.ts +15 -0
  81. package/lib/providers/claude-cli-version.js +24 -0
  82. package/lib/providers/claude.d.ts +181 -0
  83. package/lib/providers/claude.js +680 -0
  84. package/lib/providers/codex-client-version.d.ts +8 -0
  85. package/lib/providers/codex-client-version.js +17 -0
  86. package/lib/providers/codex-search.d.ts +29 -0
  87. package/lib/providers/codex-search.js +198 -0
  88. package/lib/providers/codex.d.ts +229 -0
  89. package/lib/providers/codex.js +821 -0
  90. package/lib/providers/common.d.ts +389 -0
  91. package/lib/providers/common.js +656 -0
  92. package/lib/providers/copilot.d.ts +344 -0
  93. package/lib/providers/copilot.js +888 -0
  94. package/lib/providers/cursor-adapter.d.ts +15 -0
  95. package/lib/providers/cursor-adapter.js +39 -0
  96. package/lib/providers/cursor-auth.d.ts +43 -0
  97. package/lib/providers/cursor-auth.js +169 -0
  98. package/lib/providers/cursor-model-settings.d.ts +15 -0
  99. package/lib/providers/cursor-model-settings.js +51 -0
  100. package/lib/providers/cursor-usage.d.ts +9 -0
  101. package/lib/providers/cursor-usage.js +112 -0
  102. package/lib/providers/external-usage-controller.d.ts +19 -0
  103. package/lib/providers/external-usage-controller.js +32 -0
  104. package/lib/providers/external-usage.d.ts +8 -0
  105. package/lib/providers/external-usage.js +82 -0
  106. package/lib/providers/grok.d.ts +205 -0
  107. package/lib/providers/grok.js +713 -0
  108. package/lib/providers/image-pool.d.ts +30 -0
  109. package/lib/providers/image-pool.js +89 -0
  110. package/lib/providers/npm-cli-version.d.ts +56 -0
  111. package/lib/providers/npm-cli-version.js +98 -0
  112. package/lib/providers/pool-family.d.ts +56 -0
  113. package/lib/providers/pool-family.js +45 -0
  114. package/lib/providers/pool-health.d.ts +74 -0
  115. package/lib/providers/pool-health.js +150 -0
  116. package/lib/providers/pool-usage.d.ts +86 -0
  117. package/lib/providers/pool-usage.js +223 -0
  118. package/lib/providers/pool.d.ts +108 -0
  119. package/lib/providers/pool.js +368 -0
  120. package/lib/providers/rate-limit.d.ts +192 -0
  121. package/lib/providers/rate-limit.js +338 -0
  122. package/lib/tools/image-generate.d.ts +128 -0
  123. package/lib/tools/image-generate.js +438 -0
  124. package/lib/tools/registration.d.ts +15 -0
  125. package/lib/tools/registration.js +24 -0
  126. package/lib/tools/video-generate.d.ts +89 -0
  127. package/lib/tools/video-generate.js +257 -0
  128. package/lib/tools/x-search.d.ts +58 -0
  129. package/lib/tools/x-search.js +197 -0
  130. package/lib/translate/anthropic.d.ts +161 -0
  131. package/lib/translate/anthropic.js +515 -0
  132. package/lib/translate/antigravity-schema.d.ts +4 -0
  133. package/lib/translate/antigravity-schema.js +145 -0
  134. package/lib/translate/antigravity-thinking.d.ts +5 -0
  135. package/lib/translate/antigravity-thinking.js +44 -0
  136. package/lib/translate/antigravity.d.ts +114 -0
  137. package/lib/translate/antigravity.js +366 -0
  138. package/lib/translate/chat-completions.d.ts +120 -0
  139. package/lib/translate/chat-completions.js +382 -0
  140. package/lib/translate/resolved.d.ts +80 -0
  141. package/lib/translate/resolved.js +118 -0
  142. package/lib/translate/responses.d.ts +179 -0
  143. package/lib/translate/responses.js +408 -0
  144. package/lib/translate/sse.d.ts +21 -0
  145. package/lib/translate/sse.js +56 -0
  146. package/package.json +114 -0
  147. package/vendor/cursor/LICENSE +21 -0
  148. package/vendor/cursor/index.d.ts +18 -0
  149. package/vendor/cursor/index.js +3574 -0
  150. package/vendor/cursor/proto.js +254 -0
@@ -0,0 +1,344 @@
1
+ /**
2
+ * GitHub Copilot subscription provider: OAuth device-authorization flow with
3
+ * the VS Code Copilot Chat client id, a GitHub-token → Copilot-token exchange
4
+ * against `copilot_internal/v2/token`, and streaming against two upstream
5
+ * protocols chosen per model: the OpenAI-compatible chat completions endpoint
6
+ * for models whose catalog entry lists `/chat/completions`, and the Responses
7
+ * endpoint for the newer model families (gpt-5.5/5.6, …) that only list
8
+ * `/responses`. Both upstreams are stream-only.
9
+ *
10
+ * Two token generations are in play: the long-lived GitHub OAuth token (kept
11
+ * as the session's `refreshToken`) and the ~30-minute Copilot API token it
12
+ * exchanges into (the session's `accessToken`). A TokenManager "refresh" is a
13
+ * fresh exchange, so the standard preempt/401-retry machinery applies
14
+ * unchanged.
15
+ */
16
+ import { LlmAdapter } from '@deepseek-ai/dsh-llm';
17
+ import type { GenerateOptions, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, StreamChunk } from '@deepseek-ai/dsh-llm';
18
+ import type { DeviceFlowSpec } from '../auth/device-flow.js';
19
+ import type { CopilotSession } from '../auth/store.js';
20
+ import type { PoolAdapter } from './pool.js';
21
+ import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
22
+ import type { ReasoningReplayItem, ResponsesRequestInput, ResponsesStreamEvent } from '../translate/responses.js';
23
+ import { AccountTokenManager } from './accounts.js';
24
+ import type { CatalogPersistence, DiscoveredModel, FetchFn, ModelEntry } from './common.js';
25
+ import type { RateLimitWait } from './rate-limit.js';
26
+ /**
27
+ * Client id of the VS Code Copilot Chat GitHub App (pi-mono and
28
+ * copilot2api-go use the same value): the app is pre-authorized for the
29
+ * Copilot internal token exchange, a self-registered OAuth App is not.
30
+ */
31
+ export declare const COPILOT_CLIENT_ID = "Iv1.b507a08c87ecfe98";
32
+ export declare const COPILOT_DEVICE_CODE_URL = "https://github.com/login/device/code";
33
+ export declare const COPILOT_DEVICE_TOKEN_URL = "https://github.com/login/oauth/access_token";
34
+ export declare const COPILOT_TOKEN_URL = "https://api.github.com/copilot_internal/v2/token";
35
+ export declare const GITHUB_USER_URL = "https://api.github.com/user";
36
+ export declare const COPILOT_API_URL = "https://api.githubcopilot.com/chat/completions";
37
+ /** Responses endpoint for models whose catalog entry only lists `/responses`. */
38
+ export declare const COPILOT_RESPONSES_URL = "https://api.githubcopilot.com/responses";
39
+ export declare const COPILOT_MODELS_URL = "https://api.githubcopilot.com/models";
40
+ /** Refresh when the Copilot API token has less than this much life left. */
41
+ export declare const COPILOT_PREEMPT_MS: number;
42
+ /**
43
+ * The VS Code update feed answers a JSON array of version strings, latest
44
+ * stable first. The Copilot API rejects requests whose Editor-Version is too
45
+ * old with `401 IDE token expired`, so the version is resolved live (cached
46
+ * for a day) instead of hardcoded — a stale hardcode bricks every request.
47
+ */
48
+ export declare const VSCODE_RELEASES_URL = "https://update.code.visualstudio.com/api/releases/stable";
49
+ /** Last-known-good VS Code version when the feed is unreachable. */
50
+ export declare const FALLBACK_VSCODE_VERSION = "1.107.0";
51
+ /**
52
+ * Resolve the VS Code version presented as Editor-Version: the latest stable
53
+ * from the update feed, cached for a day, falling back to a pinned version
54
+ * when the feed fails. Concurrent resolves coalesce behind one fetch.
55
+ * @param fetchFn - fetch implementation (injectable for tests).
56
+ * @param forceRefresh - bypass the cache (a 401 `IDE token expired` retry).
57
+ * @returns a `major.minor.patch` version string.
58
+ */
59
+ export declare function latestVsCodeVersion(fetchFn?: FetchFn, forceRefresh?: boolean): Promise<string>;
60
+ /**
61
+ * The device-flow facts for the auth controller's DeviceFlowManager.
62
+ * @returns the flow spec for one attempt.
63
+ */
64
+ export declare function copilotDeviceFlow(): DeviceFlowSpec;
65
+ /**
66
+ * Header set presenting requests as the VS Code Copilot Chat extension; the
67
+ * Copilot API rejects traffic without an editor identity.
68
+ * @param hasVision - whether the request carries image input.
69
+ * @param vscodeVersion - Editor-Version value from {@link latestVsCodeVersion}.
70
+ * @returns headers to merge into Copilot API requests.
71
+ */
72
+ export declare function copilotHeaders(hasVision?: boolean, vscodeVersion?: string): Record<string, string>;
73
+ /** The freshly exchanged Copilot API token half of a session. */
74
+ interface CopilotTokenPair {
75
+ accessToken: string;
76
+ expiresAt: number;
77
+ }
78
+ /**
79
+ * Exchange a long-lived GitHub OAuth token for a short-lived Copilot API
80
+ * token. A 401/403 means the GitHub token is revoked or the account lost its
81
+ * Copilot subscription — permanent, re-login required.
82
+ * @param githubToken - the GitHub OAuth token from the device flow.
83
+ * @param fetchFn - fetch implementation (injectable for tests).
84
+ * @returns the Copilot API token and its expiry.
85
+ */
86
+ export declare function exchangeCopilotToken(githubToken: string, fetchFn?: FetchFn): Promise<CopilotTokenPair>;
87
+ /**
88
+ * Complete a device-flow login: exchange the GitHub token for a Copilot API
89
+ * token and read the GitHub login name for the status display.
90
+ * @param githubToken - the GitHub OAuth token the device flow released.
91
+ * @param fetchFn - fetch implementation (injectable for tests).
92
+ * @returns the session to store.
93
+ */
94
+ export declare function completeCopilotLogin(githubToken: string, fetchFn?: FetchFn): Promise<CopilotSession>;
95
+ /**
96
+ * Refresh a copilot session: re-exchange the long-lived GitHub token for a
97
+ * fresh Copilot API token.
98
+ * @param session - the stored session.
99
+ * @param fetchFn - fetch implementation (injectable for tests).
100
+ * @returns the fresh session to store.
101
+ */
102
+ export declare function refreshCopilot(session: CopilotSession, fetchFn?: FetchFn): Promise<CopilotSession>;
103
+ /**
104
+ * Whether a copilot refresh failure means the login is permanently gone.
105
+ * @param error - the thrown refresh error.
106
+ * @returns true when re-login is the only fix (GitHub token revoked or the subscription lost).
107
+ */
108
+ export declare function isCopilotPermanentRefreshError(error: unknown): boolean;
109
+ /**
110
+ * Fetch the live Copilot model list. Models hidden from the picker or
111
+ * disabled by policy are excluded, as are models able to speak neither
112
+ * protocol this adapter knows: an entry listing `/chat/completions` speaks
113
+ * the chat wire, one listing only `/responses` (the newer GPT families,
114
+ * e.g. gpt-5.6) speaks the Responses wire, and the choice is recorded on the
115
+ * discovered entry so requests pick the matching endpoint; an entry listing
116
+ * BOTH endpoints additionally records `/responses` availability, which
117
+ * {@link copilotRequestWire} uses to reroute tools+effort requests. Vision
118
+ * support from the catalog becomes the model's input modalities, and a
119
+ * non-empty `supports.reasoning_effort` array becomes the model's selectable
120
+ * reasoning efforts (the endpoint discloses no default, so none is claimed).
121
+ * @param session - the stored session (used as-is; never refreshed here).
122
+ * @param fetchFn - fetch implementation (injectable for tests).
123
+ * @param signal - caller cancellation (pool-assembly timeout).
124
+ * @returns discovered chat models in endpoint order.
125
+ */
126
+ export declare function fetchCopilotModels(session: CopilotSession, fetchFn?: FetchFn, signal?: AbortSignal): Promise<DiscoveredModel[]>;
127
+ /** Which upstream protocol one Copilot model speaks. */
128
+ export type CopilotWire = 'chat-completions' | 'responses';
129
+ /**
130
+ * The wire protocol for one model: the discovered catalog entry's recorded
131
+ * choice, defaulting to chat completions for unknown models (static-catalog
132
+ * and no-discovery configurations, and models listing both endpoints).
133
+ * @param entry - the discovered catalog entry, when known.
134
+ * @returns the protocol the request for this model must speak.
135
+ */
136
+ export declare function copilotWireFor(entry: DiscoveredModel | undefined): CopilotWire;
137
+ /**
138
+ * The upstream protocol for ONE REQUEST: the model's default wire, except
139
+ * that a dual-protocol model defaulting to chat completions must reroute to
140
+ * Responses when the request combines function tools with a reasoning effort
141
+ * — Copilot rejects exactly that combination on /chat/completions with
142
+ * HTTP 400 invalid_request_body ("Function tools with reasoning_effort are
143
+ * not supported … use /v1/responses or set reasoning_effort to 'none'",
144
+ * observed on gpt-5.4) while /responses serves it. Effort 'none' stays on
145
+ * the chat wire (the API allows the combination there), and models not
146
+ * listing /responses never reroute.
147
+ * @param entry - the discovered catalog entry, when known.
148
+ * @param options - the harness generate options (tools + effort only).
149
+ * @returns the protocol the request for this model must speak.
150
+ */
151
+ export declare function copilotRequestWire(entry: DiscoveredModel | undefined, options: Pick<GenerateOptions, 'tools' | 'reasoningEffort'>): CopilotWire;
152
+ /**
153
+ * The chat completions request body for one generation. The output cap rides
154
+ * `max_completion_tokens` — the newer OpenAI-family models on Copilot reject
155
+ * the legacy `max_tokens` parameter outright (HTTP 400 "Unsupported
156
+ * parameter"), and the rest of the catalog accepts the new spelling.
157
+ * @param options - the harness generate options.
158
+ * @param messages - translated wire messages (images pre-resolved).
159
+ * @returns the JSON body.
160
+ */
161
+ export declare function copilotChatRequestBody(options: GenerateOptions, messages: Record<string, unknown>[]): Record<string, unknown>;
162
+ /**
163
+ * The Responses request body for one generation (the wire the `/responses`-
164
+ * only model families speak). Usage arrives on `response.completed`.
165
+ * @param options - the harness generate options.
166
+ * @param resolved - translated instructions + input (images pre-resolved).
167
+ * @returns the JSON body.
168
+ */
169
+ export declare function copilotResponsesRequestBody(options: GenerateOptions, resolved: ResponsesRequestInput): Record<string, unknown>;
170
+ /**
171
+ * Rewrite Copilot's Responses-gateway item ids into stable per-item keys.
172
+ * Unlike chatgpt.com's Responses backend, the Copilot gateway mints a FRESH
173
+ * opaque `item.id`/`item_id` on every event of one response (the `added`,
174
+ * each delta, and the `done` all differ), which defeats id-keyed block
175
+ * assembly in the shared translator: text fragments would each open their
176
+ * own block, `done` would synthesize duplicates, and a function call whose
177
+ * arguments arrive whole only on `done` (the deltas carry empty strings)
178
+ * would close empty. The stable key derives from the event's `output_index`
179
+ * — the item's position in the response's output array, which survives the
180
+ * gateway's per-event id churn even when two items' events interleave on
181
+ * the wire (parallel tool calls do exactly that). Events without an
182
+ * `output_index` fall back to the key of the last `output_item.added`, which
183
+ * is only correct while one item's events stay contiguous — the pre-
184
+ * interleaving behavior, kept for gateways that omit the field; with no
185
+ * `added` seen yet they key to `copilot-item-0` as before. Function-call
186
+ * identity additionally rides the gateway-stable `call_id`.
187
+ */
188
+ export declare class CopilotResponsesItemNormalizer {
189
+ private readonly onCaptured?;
190
+ private adds;
191
+ private lastKey;
192
+ /** Call ids and completed reasoning items collected for the open response. */
193
+ private capturedCallIds;
194
+ private capturedReasoning;
195
+ /**
196
+ * @param onCaptured - fired at each `response.completed` that produced BOTH
197
+ * function calls and completed reasoning items, receiving the response's
198
+ * call ids and replayable reasoning items so the adapter can replay them
199
+ * on the next request.
200
+ */
201
+ constructor(onCaptured?: ((callIds: string[], items: ReasoningReplayItem[]) => void) | undefined);
202
+ /**
203
+ * [2026-08-23]-[a single arrival-order ordinal mis-buckets every event after
204
+ * a second item's `added`, mangling interleaved parallel tool calls;
205
+ * output_index is the only correlator the gateway keeps stable]-[changes
206
+ * keys only for streams that carry output_index; no-index streams keep the
207
+ * old last-added-key behavior byte for byte]
208
+ */
209
+ private keyFor;
210
+ /**
211
+ * Rewrite one parsed Responses event.
212
+ * @param event - the event as parsed off the wire.
213
+ * @returns the event with a stable item key.
214
+ */
215
+ push(event: ResponsesStreamEvent): ResponsesStreamEvent;
216
+ }
217
+ /** Constructor dependencies for {@link CopilotAdapter}. */
218
+ export interface CopilotAdapterOptions {
219
+ models: readonly ModelEntry[];
220
+ streamIdleTimeoutMs: number;
221
+ tokens: AccountTokenManager<CopilotSession>;
222
+ /** Late-bound pool facade (wired after adapter construction); pools list under their first member's provider. */
223
+ pool?: () => PoolAdapter | undefined;
224
+ /** Whether to fetch the live catalog when logged in (false when config `models` overrides). */
225
+ discovery: boolean;
226
+ /** Warning sink for discovery failures that fall back to the static catalog. */
227
+ onWarn?: (message: string) => void;
228
+ /** Fetch implementation for discovery (defaults to DSH's network routing). */
229
+ fetchFn?: FetchFn;
230
+ /** Resolve the attachment service per request; absent means image requests fail loudly. */
231
+ resolveAttachments?: () => AttachmentStore | undefined;
232
+ /** Durable catalog store seeding capability metadata across restarts. */
233
+ catalogStore?: CatalogPersistence;
234
+ /** How long this route may hold a turn open waiting for a rate-limit window; defaults to waiting on, six-hour ceiling. */
235
+ rateLimit?: RateLimitWait;
236
+ /**
237
+ * Per-model default reasoning effort override (the Settings page's picker).
238
+ * Returns the user-configured default for one model, or undefined to follow
239
+ * the provider's own default.
240
+ */
241
+ defaultEffortOf?: (model: string) => string | undefined;
242
+ }
243
+ /** Copilot wire adapter: one instance serves the `copilot` provider route. */
244
+ export declare class CopilotAdapter extends LlmAdapter {
245
+ private readonly options;
246
+ private readonly catalog;
247
+ /** In-memory catalogs for non-default accounts (the persisted cache is the default's). */
248
+ private readonly accountCatalogs;
249
+ /** Account whose snapshot currently lives in {@link catalog}; cleared on default change. */
250
+ private catalogOwner;
251
+ /**
252
+ * [2026-08-23]-[a reasoning model continuing a tool chain must get its
253
+ * reasoning back or it restarts from scratch every tool round trip; the
254
+ * items live in ADAPTER memory because dsh-llm's reasoning ContentBlock is
255
+ * a closed shape that cannot carry them through the harness]-[entries are
256
+ * namespaced per ACCOUNT × CONVERSATION × MODEL, idle out via a sliding
257
+ * TTL, and the whole store is dropped on auth transitions, so replay
258
+ * degrades to the old behavior instead of leaking across contexts]
259
+ */
260
+ private readonly replayByScope;
261
+ /** Call-id entries kept per scope; see {@link captureReasoning}. */
262
+ private static readonly REPLAY_CALL_LIMIT;
263
+ /** Conversation scopes kept at once; bounds memory when many sessions interleave. */
264
+ private static readonly REPLAY_SCOPE_LIMIT;
265
+ /** How long a captured entry stays replayable; tool round trips take minutes, not hours. */
266
+ private static readonly REPLAY_TTL_MS;
267
+ constructor(options: CopilotAdapterOptions);
268
+ /** Discovery fetcher: resolves the session through the refresh-aware path. */
269
+ private fetchCatalog;
270
+ /** Drop cached catalogs after login/logout so the next list does not reuse a stale plan. */
271
+ clearAccountCatalog(account?: string): void;
272
+ /** Persisted cache for the default account; a throwaway cache for any other. */
273
+ private catalogFor;
274
+ providerInfo(provider: string): LlmProviderInfo;
275
+ providerRetryPolicy(provider: string): import("@deepseek-ai/dsh-llm").ResolvedRetryPolicy;
276
+ private staticModels;
277
+ listModels(provider: string): Promise<readonly LlmModelInfo[]>;
278
+ /** The provider's own catalog: union of every account, or one account when named. */
279
+ listOwnModels(provider: string, account?: string, signal?: AbortSignal): Promise<readonly LlmModelInfo[]>;
280
+ /**
281
+ * The discovered entry for one model. Resolved through the cache's
282
+ * stale-while-revalidate path: capability metadata must stay stable across
283
+ * a long conversation — a mid-turn refetch must neither block nor fail the
284
+ * call before provider I/O.
285
+ */
286
+ private discovered;
287
+ /**
288
+ * [2026-08-23]-[a manually configured responses-only model combined with
289
+ * `discovery:false` left discovered() undefined, so copilotRequestWire
290
+ * silently defaulted to /chat/completions and the request 404/400'd at the
291
+ * gateway; an explicit config wire must win over catalog inference]-[config
292
+ * `models[].wire` now routes the request even without discovery]
293
+ */
294
+ private configuredWireEntry;
295
+ /**
296
+ * The replay scope isolating one ACCOUNT × CONVERSATION × MODEL. The
297
+ * account identity is the session's long-lived GitHub token (stable across
298
+ * Copilot-token refreshes, different per GitHub login); the conversation is
299
+ * the loop-stamped `sessionId`, falling back to the first message's id
300
+ * when a hand-built request carries no session stamp; the model separates
301
+ * wire families. A call id captured in one scope is invisible to every
302
+ * other scope, so reused ids cannot leak reasoning across accounts,
303
+ * conversations, or models.
304
+ */
305
+ private replayScope;
306
+ /**
307
+ * Store one response's completed reasoning items behind every call id it
308
+ * produced, inside one replay scope. Retention: a CONSUMED entry is kept —
309
+ * every later round of the same conversation replays ALL its earlier
310
+ * function_calls — until it idles out of the TTL (see {@link replayFor})
311
+ * or the per-scope entry cap evicts it oldest-first. All calls of one
312
+ * response share ONE entry object: toResponsesInput dedupes replays by
313
+ * array reference, so parallel calls replay the items once instead of once
314
+ * per call.
315
+ */
316
+ private captureReasoning;
317
+ /**
318
+ * The replay items for one call id in one scope, when still fresh. The TTL
319
+ * bounds IDLE time, not total age: a hit refreshes the entry (and its
320
+ * eviction recency), so an ongoing conversation keeps its chain alive
321
+ * while a conversation that stopped asking forgets within the TTL. An
322
+ * absent or aged-out entry answers `undefined` — the no-replay
323
+ * degradation, never an error.
324
+ */
325
+ private replayFor;
326
+ /**
327
+ * Drop every captured replay entry. Lookup correctness never depends on
328
+ * the call — the scope already carries the account identity — but the host
329
+ * wiring invokes this on every copilot auth transition (login, logout,
330
+ * credential death) so a switched account's memory never holds the
331
+ * previous account's encrypted reasoning at all; conversation teardown is
332
+ * bounded by the TTL and the caps.
333
+ */
334
+ clearReplayState(): void;
335
+ resolveModel(provider: string, model: string): Promise<LlmResolvedModelInfo>;
336
+ /** Capability resolution of the provider's own models (the pool resolves members here). */
337
+ resolveOwnModel(provider: string, model: string): Promise<LlmResolvedModelInfo>;
338
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
339
+ /** Pool seam: stream through one specific account instead of the default. */
340
+ streamAccount(options: GenerateOptions, account: string): AsyncIterable<StreamChunk>;
341
+ private streamCore;
342
+ private request;
343
+ }
344
+ export {};