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.
- package/LICENSE +21 -0
- package/README.md +129 -0
- package/cordis.patch.yml +12 -0
- package/lib/auth/claude-code-creds.d.ts +23 -0
- package/lib/auth/claude-code-creds.js +172 -0
- package/lib/auth/device-flow.d.ts +55 -0
- package/lib/auth/device-flow.js +177 -0
- package/lib/auth/jwt.d.ts +10 -0
- package/lib/auth/jwt.js +25 -0
- package/lib/auth/oauth-flow.d.ts +91 -0
- package/lib/auth/oauth-flow.js +227 -0
- package/lib/auth/pkce.d.ts +31 -0
- package/lib/auth/pkce.js +35 -0
- package/lib/auth/rpc.d.ts +209 -0
- package/lib/auth/rpc.js +386 -0
- package/lib/auth/store.d.ts +196 -0
- package/lib/auth/store.js +468 -0
- package/lib/client/CursorCard.d.ts +9 -0
- package/lib/client/CursorCard.js +113 -0
- package/lib/client/ExternalUsageCards.d.ts +9 -0
- package/lib/client/ExternalUsageCards.js +72 -0
- package/lib/client/ImageGallery.d.ts +54 -0
- package/lib/client/ImageGallery.js +112 -0
- package/lib/client/ImageGenerateToolview.d.ts +48 -0
- package/lib/client/ImageGenerateToolview.js +133 -0
- package/lib/client/ProviderAccountManager.d.ts +13 -0
- package/lib/client/ProviderAccountManager.js +147 -0
- package/lib/client/ProviderModelEditor.d.ts +39 -0
- package/lib/client/ProviderModelEditor.js +107 -0
- package/lib/client/SpeedSelect.d.ts +71 -0
- package/lib/client/SpeedSelect.js +177 -0
- package/lib/client/SubscriptionUsageBadge.d.ts +116 -0
- package/lib/client/SubscriptionUsageBadge.js +543 -0
- package/lib/client/SubscriptionsSection.d.ts +140 -0
- package/lib/client/SubscriptionsSection.js +544 -0
- package/lib/client/UsageBadgeDisplaySetting.d.ts +7 -0
- package/lib/client/UsageBadgeDisplaySetting.js +36 -0
- package/lib/client/VideoGenerateToolview.d.ts +42 -0
- package/lib/client/VideoGenerateToolview.js +175 -0
- package/lib/client/account-preferences.d.ts +24 -0
- package/lib/client/account-preferences.js +21 -0
- package/lib/client/fast-command.d.ts +2 -0
- package/lib/client/fast-command.js +4 -0
- package/lib/client/host-contract.d.ts +90 -0
- package/lib/client/host-contract.js +101 -0
- package/lib/client/host-icons.d.ts +24 -0
- package/lib/client/host-icons.js +21 -0
- package/lib/client/index.d.ts +27 -0
- package/lib/client/index.js +136 -0
- package/lib/client/locales.d.ts +297 -0
- package/lib/client/locales.js +295 -0
- package/lib/client/subscription-card-styles.d.ts +3 -0
- package/lib/client/subscription-card-styles.js +53 -0
- package/lib/client/subscriptions-rpc.d.ts +14 -0
- package/lib/client/subscriptions-rpc.js +34 -0
- package/lib/client/usage-badge-preferences.d.ts +11 -0
- package/lib/client/usage-badge-preferences.js +41 -0
- package/lib/client.js +4472 -0
- package/lib/client.js.map +1 -0
- package/lib/compat.d.ts +36 -0
- package/lib/compat.js +20 -0
- package/lib/http.d.ts +6 -0
- package/lib/http.js +15 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.js +14018 -0
- package/lib/model-defaults.d.ts +23 -0
- package/lib/model-defaults.js +237 -0
- package/lib/provider-settings.d.ts +39 -0
- package/lib/provider-settings.js +151 -0
- package/lib/providers/account-preferences.d.ts +41 -0
- package/lib/providers/account-preferences.js +153 -0
- package/lib/providers/accounts.d.ts +112 -0
- package/lib/providers/accounts.js +142 -0
- package/lib/providers/antigravity-oauth-client.d.ts +7 -0
- package/lib/providers/antigravity-oauth-client.js +7 -0
- package/lib/providers/antigravity.d.ts +110 -0
- package/lib/providers/antigravity.js +516 -0
- package/lib/providers/catalog-store.d.ts +48 -0
- package/lib/providers/catalog-store.js +243 -0
- package/lib/providers/claude-cli-version.d.ts +15 -0
- package/lib/providers/claude-cli-version.js +24 -0
- package/lib/providers/claude.d.ts +181 -0
- package/lib/providers/claude.js +680 -0
- package/lib/providers/codex-client-version.d.ts +8 -0
- package/lib/providers/codex-client-version.js +17 -0
- package/lib/providers/codex-search.d.ts +29 -0
- package/lib/providers/codex-search.js +198 -0
- package/lib/providers/codex.d.ts +229 -0
- package/lib/providers/codex.js +821 -0
- package/lib/providers/common.d.ts +389 -0
- package/lib/providers/common.js +656 -0
- package/lib/providers/copilot.d.ts +344 -0
- package/lib/providers/copilot.js +888 -0
- package/lib/providers/cursor-adapter.d.ts +15 -0
- package/lib/providers/cursor-adapter.js +39 -0
- package/lib/providers/cursor-auth.d.ts +43 -0
- package/lib/providers/cursor-auth.js +169 -0
- package/lib/providers/cursor-model-settings.d.ts +15 -0
- package/lib/providers/cursor-model-settings.js +51 -0
- package/lib/providers/cursor-usage.d.ts +9 -0
- package/lib/providers/cursor-usage.js +112 -0
- package/lib/providers/external-usage-controller.d.ts +19 -0
- package/lib/providers/external-usage-controller.js +32 -0
- package/lib/providers/external-usage.d.ts +8 -0
- package/lib/providers/external-usage.js +82 -0
- package/lib/providers/grok.d.ts +205 -0
- package/lib/providers/grok.js +713 -0
- package/lib/providers/image-pool.d.ts +30 -0
- package/lib/providers/image-pool.js +89 -0
- package/lib/providers/npm-cli-version.d.ts +56 -0
- package/lib/providers/npm-cli-version.js +98 -0
- package/lib/providers/pool-family.d.ts +56 -0
- package/lib/providers/pool-family.js +45 -0
- package/lib/providers/pool-health.d.ts +74 -0
- package/lib/providers/pool-health.js +150 -0
- package/lib/providers/pool-usage.d.ts +86 -0
- package/lib/providers/pool-usage.js +223 -0
- package/lib/providers/pool.d.ts +108 -0
- package/lib/providers/pool.js +368 -0
- package/lib/providers/rate-limit.d.ts +192 -0
- package/lib/providers/rate-limit.js +338 -0
- package/lib/tools/image-generate.d.ts +128 -0
- package/lib/tools/image-generate.js +438 -0
- package/lib/tools/registration.d.ts +15 -0
- package/lib/tools/registration.js +24 -0
- package/lib/tools/video-generate.d.ts +89 -0
- package/lib/tools/video-generate.js +257 -0
- package/lib/tools/x-search.d.ts +58 -0
- package/lib/tools/x-search.js +197 -0
- package/lib/translate/anthropic.d.ts +161 -0
- package/lib/translate/anthropic.js +515 -0
- package/lib/translate/antigravity-schema.d.ts +4 -0
- package/lib/translate/antigravity-schema.js +145 -0
- package/lib/translate/antigravity-thinking.d.ts +5 -0
- package/lib/translate/antigravity-thinking.js +44 -0
- package/lib/translate/antigravity.d.ts +114 -0
- package/lib/translate/antigravity.js +366 -0
- package/lib/translate/chat-completions.d.ts +120 -0
- package/lib/translate/chat-completions.js +382 -0
- package/lib/translate/resolved.d.ts +80 -0
- package/lib/translate/resolved.js +118 -0
- package/lib/translate/responses.d.ts +179 -0
- package/lib/translate/responses.js +408 -0
- package/lib/translate/sse.d.ts +21 -0
- package/lib/translate/sse.js +56 -0
- package/package.json +114 -0
- package/vendor/cursor/LICENSE +21 -0
- package/vendor/cursor/index.d.ts +18 -0
- package/vendor/cursor/index.js +3574 -0
- package/vendor/cursor/proto.js +254 -0
package/lib/compat.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-build compatibility with both published dsh lines (issue #53).
|
|
3
|
+
*
|
|
4
|
+
* dsh 0.1.2-alpha renamed `CallId` to `ToolCallId` in `@deepseek-ai/dsh-llm`.
|
|
5
|
+
* A named import of either symbol is an ESM link-time failure on the other
|
|
6
|
+
* line (the module executes before any code runs, so the whole profile boot
|
|
7
|
+
* dies). A namespace import never link-fails, and both constructors are pure
|
|
8
|
+
* type brands (`id as Branded`), so one runtime lookup serves both lines.
|
|
9
|
+
*
|
|
10
|
+
* `RpcResult` also moved homes: rc.2 ships it from the removed
|
|
11
|
+
* `@deepseek-ai/dsh-host-apiproxy/api`, the alpha as `ConnectionRpcResult`
|
|
12
|
+
* from `@deepseek-ai/dsh-client-connection`. Both are the same structural
|
|
13
|
+
* shape, so this local mirror avoids importing from either package.
|
|
14
|
+
*/
|
|
15
|
+
import type { ContentBlock } from '@deepseek-ai/dsh-llm';
|
|
16
|
+
/** The branded tool-call id of whichever dsh-llm line is installed. */
|
|
17
|
+
export type ToolCallId = Extract<ContentBlock, {
|
|
18
|
+
type: 'tool-call';
|
|
19
|
+
}>['id'];
|
|
20
|
+
/** Brand a string as a tool-call id: alpha's `ToolCallId`, rc.2's `CallId`. */
|
|
21
|
+
export declare const ToolCallId: (id: string) => ToolCallId;
|
|
22
|
+
/**
|
|
23
|
+
* Structural mirror of the RPC result both dsh lines use (rc.2's apiproxy
|
|
24
|
+
* `RpcResult`, the alpha's connection `ConnectionRpcResult`).
|
|
25
|
+
*/
|
|
26
|
+
export type RpcResult<T> = {
|
|
27
|
+
ok: true;
|
|
28
|
+
value: T;
|
|
29
|
+
} | {
|
|
30
|
+
ok: false;
|
|
31
|
+
error: {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
details: object;
|
|
35
|
+
};
|
|
36
|
+
};
|
package/lib/compat.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-build compatibility with both published dsh lines (issue #53).
|
|
3
|
+
*
|
|
4
|
+
* dsh 0.1.2-alpha renamed `CallId` to `ToolCallId` in `@deepseek-ai/dsh-llm`.
|
|
5
|
+
* A named import of either symbol is an ESM link-time failure on the other
|
|
6
|
+
* line (the module executes before any code runs, so the whole profile boot
|
|
7
|
+
* dies). A namespace import never link-fails, and both constructors are pure
|
|
8
|
+
* type brands (`id as Branded`), so one runtime lookup serves both lines.
|
|
9
|
+
*
|
|
10
|
+
* `RpcResult` also moved homes: rc.2 ships it from the removed
|
|
11
|
+
* `@deepseek-ai/dsh-host-apiproxy/api`, the alpha as `ConnectionRpcResult`
|
|
12
|
+
* from `@deepseek-ai/dsh-client-connection`. Both are the same structural
|
|
13
|
+
* shape, so this local mirror avoids importing from either package.
|
|
14
|
+
*/
|
|
15
|
+
import * as llm from '@deepseek-ai/dsh-llm';
|
|
16
|
+
/** Brand a string as a tool-call id: alpha's `ToolCallId`, rc.2's `CallId`. */
|
|
17
|
+
export const ToolCallId = (() => {
|
|
18
|
+
const exports = llm;
|
|
19
|
+
return (exports['ToolCallId'] ?? exports['CallId']);
|
|
20
|
+
})();
|
package/lib/http.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Keep a sufficient per-address connection budget on high-latency networks. */
|
|
2
|
+
export declare const MIN_CONNECT_ATTEMPT_TIMEOUT_MS = 1500;
|
|
3
|
+
export declare function ensureConnectAttemptTimeout(minMs?: number): number;
|
|
4
|
+
export declare function restoreConnectAttemptTimeout(previous: number): void;
|
|
5
|
+
/** Use DSH's global fetch routing, including its configured network proxy. */
|
|
6
|
+
export declare const hostFetch: typeof fetch;
|
package/lib/http.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Host-managed network routing for subscription requests. */
|
|
2
|
+
import { getDefaultAutoSelectFamilyAttemptTimeout, setDefaultAutoSelectFamilyAttemptTimeout } from 'node:net';
|
|
3
|
+
/** Keep a sufficient per-address connection budget on high-latency networks. */
|
|
4
|
+
export const MIN_CONNECT_ATTEMPT_TIMEOUT_MS = 1500;
|
|
5
|
+
export function ensureConnectAttemptTimeout(minMs = MIN_CONNECT_ATTEMPT_TIMEOUT_MS) {
|
|
6
|
+
const previous = getDefaultAutoSelectFamilyAttemptTimeout();
|
|
7
|
+
if (previous < minMs)
|
|
8
|
+
setDefaultAutoSelectFamilyAttemptTimeout(minMs);
|
|
9
|
+
return previous;
|
|
10
|
+
}
|
|
11
|
+
export function restoreConnectAttemptTimeout(previous) {
|
|
12
|
+
setDefaultAutoSelectFamilyAttemptTimeout(previous);
|
|
13
|
+
}
|
|
14
|
+
/** Use DSH's global fetch routing, including its configured network proxy. */
|
|
15
|
+
export const hostFetch = (input, init) => fetch(input, init);
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-subscriptions: register OAuth-subscription LLM providers
|
|
3
|
+
* (ChatGPT/Codex, Claude, Grok, GitHub Copilot, Google Antigravity) on `ctx.llm`, and expose the `/subscriptions-auth`
|
|
4
|
+
* RPC channel the web Settings page uses to run the logins. The token store
|
|
5
|
+
* lives at `~/.dsh/plugins/subscriptions/auth.json`; the channel registers only when
|
|
6
|
+
* a host `connection` service exists, so headless compositions load fine.
|
|
7
|
+
* @module dsh-subscriptions
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
10
|
+
import z from '@deepseek-ai/schemastery';
|
|
11
|
+
import type { ProviderId } from './auth/store.js';
|
|
12
|
+
import type { ModelEntry } from './providers/common.js';
|
|
13
|
+
import type { RateLimitConfig } from './providers/rate-limit.js';
|
|
14
|
+
import type { CliVersion, NpmCliVersionCache } from './providers/npm-cli-version.js';
|
|
15
|
+
export type { AccountPreferences, ProviderPreferences } from './provider-settings.js';
|
|
16
|
+
import type { PoolMemberRef } from './providers/pool-family.js';
|
|
17
|
+
import type { AntigravityRuntimeConfig } from './providers/antigravity.js';
|
|
18
|
+
export type { ModelEntry, ProviderUsage, UsageWindow } from './providers/common.js';
|
|
19
|
+
export type { RateLimitConfig, RateLimitWait } from './providers/rate-limit.js';
|
|
20
|
+
export type { ProviderStatus } from './auth/rpc.js';
|
|
21
|
+
export type { AntigravitySession, ClaudeSession, CodexSession, CopilotSession, GrokSession, ProviderId } from './auth/store.js';
|
|
22
|
+
export declare const name = "dsh-subscriptions";
|
|
23
|
+
export declare const inject: string[];
|
|
24
|
+
/** Default maximum provider idle time while one stream read is outstanding. */
|
|
25
|
+
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
|
|
26
|
+
/** Bound on one pool quota poll — member selection must not hang on a usage endpoint. */
|
|
27
|
+
export declare const POOL_USAGE_TIMEOUT_MS = 10000;
|
|
28
|
+
export { withTimeout } from './providers/common.js';
|
|
29
|
+
/** Plugin config, validated by the same-named schemastery schema. */
|
|
30
|
+
export interface Config {
|
|
31
|
+
/** Codex /models client_version override; does not change account entitlements. */
|
|
32
|
+
codexClientVersion?: string;
|
|
33
|
+
/** Provider routes to register; defaults to every supported provider. */
|
|
34
|
+
providers?: ProviderId[];
|
|
35
|
+
/** Maximum provider idle time while one stream read is outstanding (default five minutes). */
|
|
36
|
+
streamIdleTimeoutMs?: number;
|
|
37
|
+
/** Whether and how long a route waits out a closed rate-limit window. */
|
|
38
|
+
rateLimit?: RateLimitConfig;
|
|
39
|
+
/** Advisory model catalogs overriding the built-in defaults, per provider. */
|
|
40
|
+
models?: {
|
|
41
|
+
codex?: ModelEntry[];
|
|
42
|
+
claude?: ModelEntry[];
|
|
43
|
+
grok?: ModelEntry[];
|
|
44
|
+
copilot?: ModelEntry[];
|
|
45
|
+
antigravity?: ModelEntry[];
|
|
46
|
+
};
|
|
47
|
+
/** Antigravity-specific OAuth and endpoint configuration. */
|
|
48
|
+
antigravity?: AntigravityRuntimeConfig & {
|
|
49
|
+
/** Google OAuth client id. May instead be supplied as ANTIGRAVITY_CLIENT_ID. */
|
|
50
|
+
clientId?: string;
|
|
51
|
+
/** Google OAuth client secret, when required by the client registration. */
|
|
52
|
+
clientSecret?: string;
|
|
53
|
+
};
|
|
54
|
+
/** Same-subscription account pools (and optional extra tier models). */
|
|
55
|
+
pool?: {
|
|
56
|
+
/** Enable account pooling (default true; needs ≥2 accounts of one provider). */
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
/** Member selection: plain priority failover, or quota-aware urgency scheduling. */
|
|
59
|
+
strategy?: 'priority' | 'quota_aware';
|
|
60
|
+
/** A challenger must out-score the sticky member by this factor to take over (default 2). */
|
|
61
|
+
switchMargin?: number;
|
|
62
|
+
/** Auto-pool every catalog model across a provider's logged-in accounts (default true). */
|
|
63
|
+
autoAccounts?: boolean;
|
|
64
|
+
/** @deprecated Use {@link autoAccounts}. */
|
|
65
|
+
autoFamilies?: boolean;
|
|
66
|
+
/** Explicit account lists for one catalog model (same provider); replaces the auto pool. */
|
|
67
|
+
families?: Record<string, PoolMemberRef[]>;
|
|
68
|
+
/** Extra picker entries with heterogeneous fallbacks, listed under the first member's provider. */
|
|
69
|
+
tiers?: Record<string, PoolMemberRef[]>;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export declare const Config: z<Config>;
|
|
73
|
+
/**
|
|
74
|
+
* Read the CLI version a route presents for the Settings page. The first
|
|
75
|
+
* lookup is awaited (bounded by its own 5s deadline) so a slow registry is
|
|
76
|
+
* not misreported as a fallback; a later refresh is waited on only briefly,
|
|
77
|
+
* because the whole page waits on `status`, and the last result shows.
|
|
78
|
+
*/
|
|
79
|
+
export declare function presentedVersion(cache: Pick<NpmCliVersionCache, 'resolve' | 'current'>, waitMs?: number): () => Promise<CliVersion | undefined>;
|
|
80
|
+
export declare function apply(ctx: Context, config: Config): void;
|