@eddyskywalker/dsh-chatgpt-subscription 0.2.21 → 0.3.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/CHANGELOG.md +74 -0
- package/README.md +115 -1
- package/lib/client.js +2825 -512
- package/lib/client.js.map +1 -1
- package/lib/index.js +8630 -389
- package/lib/types/client/ProviderHubSection.d.ts +15 -0
- package/lib/types/client/ProviderHubSection.d.ts.map +1 -0
- package/lib/types/client/command-code/CommandCodeComposerQuota.d.ts +24 -0
- package/lib/types/client/command-code/CommandCodeComposerQuota.d.ts.map +1 -0
- package/lib/types/client/command-code/CommandCodeSection.d.ts +11 -0
- package/lib/types/client/command-code/CommandCodeSection.d.ts.map +1 -0
- package/lib/types/client/command-code/locales.d.ts +401 -0
- package/lib/types/client/command-code/locales.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/kimi-code/KimiCodeComposerQuota.d.ts +25 -0
- package/lib/types/client/kimi-code/KimiCodeComposerQuota.d.ts.map +1 -0
- package/lib/types/client/kimi-code/KimiCodeSection.d.ts +11 -0
- package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -0
- package/lib/types/client/kimi-code/KimiModelCapabilities.d.ts +16 -0
- package/lib/types/client/kimi-code/KimiModelCapabilities.d.ts.map +1 -0
- package/lib/types/client/kimi-code/locales.d.ts +665 -0
- package/lib/types/client/kimi-code/locales.d.ts.map +1 -0
- package/lib/types/client/kimi-code/styles.d.ts +4 -0
- package/lib/types/client/kimi-code/styles.d.ts.map +1 -0
- package/lib/types/client/locales.d.ts +3 -1
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/styles.d.ts.map +1 -1
- package/lib/types/host/command-code/adapter.d.ts +34 -0
- package/lib/types/host/command-code/adapter.d.ts.map +1 -0
- package/lib/types/host/command-code/client.d.ts +99 -0
- package/lib/types/host/command-code/client.d.ts.map +1 -0
- package/lib/types/host/command-code/mapper.d.ts +102 -0
- package/lib/types/host/command-code/mapper.d.ts.map +1 -0
- package/lib/types/host/command-code/model-catalog.d.ts +31 -0
- package/lib/types/host/command-code/model-catalog.d.ts.map +1 -0
- package/lib/types/host/command-code/oauth.d.ts +89 -0
- package/lib/types/host/command-code/oauth.d.ts.map +1 -0
- package/lib/types/host/command-code/plans.d.ts +40 -0
- package/lib/types/host/command-code/plans.d.ts.map +1 -0
- package/lib/types/host/command-code/routes.d.ts +27 -0
- package/lib/types/host/command-code/routes.d.ts.map +1 -0
- package/lib/types/host/command-code/token-store.d.ts +88 -0
- package/lib/types/host/command-code/token-store.d.ts.map +1 -0
- package/lib/types/host/command-code/types.d.ts +138 -0
- package/lib/types/host/command-code/types.d.ts.map +1 -0
- package/lib/types/host/kimi-code/adapter.d.ts +112 -0
- package/lib/types/host/kimi-code/adapter.d.ts.map +1 -0
- package/lib/types/host/kimi-code/client.d.ts +161 -0
- package/lib/types/host/kimi-code/client.d.ts.map +1 -0
- package/lib/types/host/kimi-code/mapper.d.ts +334 -0
- package/lib/types/host/kimi-code/mapper.d.ts.map +1 -0
- package/lib/types/host/kimi-code/modalities.d.ts +94 -0
- package/lib/types/host/kimi-code/modalities.d.ts.map +1 -0
- package/lib/types/host/kimi-code/model-catalog.d.ts +77 -0
- package/lib/types/host/kimi-code/model-catalog.d.ts.map +1 -0
- package/lib/types/host/kimi-code/oauth.d.ts +133 -0
- package/lib/types/host/kimi-code/oauth.d.ts.map +1 -0
- package/lib/types/host/kimi-code/routes.d.ts +26 -0
- package/lib/types/host/kimi-code/routes.d.ts.map +1 -0
- package/lib/types/host/kimi-code/token-store.d.ts +135 -0
- package/lib/types/host/kimi-code/token-store.d.ts.map +1 -0
- package/lib/types/host/kimi-code/types.d.ts +174 -0
- package/lib/types/host/kimi-code/types.d.ts.map +1 -0
- package/lib/types/host/relay-probe.d.ts +161 -0
- package/lib/types/host/relay-probe.d.ts.map +1 -0
- package/lib/types/host/responses-client.d.ts.map +1 -1
- package/lib/types/index.d.ts +13 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/command-code-contracts.d.ts +119 -0
- package/lib/types/shared/command-code-contracts.d.ts.map +1 -0
- package/lib/types/shared/kimi-code-contracts.d.ts +203 -0
- package/lib/types/shared/kimi-code-contracts.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contracts between the Command Code host routes and the browser settings
|
|
3
|
+
* card. Everything here is public: no credential ever crosses this boundary.
|
|
4
|
+
*/
|
|
5
|
+
/** Deployment of the Command Code API a credential was issued against. */
|
|
6
|
+
export type CommandCodeApiEnv = 'prod' | 'staging' | 'local';
|
|
7
|
+
/**
|
|
8
|
+
* Reasoning levels the provider registry can expose. The exact set is per
|
|
9
|
+
* model — `minimal` is the cheapest budget, `xhigh` sits between `high` and
|
|
10
|
+
* `max`, and most models declare only a subset.
|
|
11
|
+
*/
|
|
12
|
+
export type CommandCodeReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
13
|
+
/** Every level, in escalating order; the settings card renders exactly these. */
|
|
14
|
+
export declare const COMMAND_CODE_REASONING_EFFORTS: readonly CommandCodeReasoningEffort[];
|
|
15
|
+
/** One model offered by the Command Code provider API. */
|
|
16
|
+
export interface CommandCodeModelOption {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
/** Enabled models are the ones DSH offers in the conversation model picker. */
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
/** Context window the live catalog reports for this model. */
|
|
22
|
+
defaultContextWindow: number;
|
|
23
|
+
/** Effective context window: the override when one is saved, else the default. */
|
|
24
|
+
contextWindow: number;
|
|
25
|
+
/** Maximum output tokens this route requests when a caller omits one. */
|
|
26
|
+
defaultMaxTokens: number;
|
|
27
|
+
/** Reasoning levels this route exposes; absent for non-reasoning models. */
|
|
28
|
+
reasoningEfforts?: string[];
|
|
29
|
+
/** Reasoning dialect the adapter uses on the wire. */
|
|
30
|
+
wire: CommandCodeWire;
|
|
31
|
+
}
|
|
32
|
+
/** Request/response dialect a model id is served over. */
|
|
33
|
+
export type CommandCodeWire = 'openai' | 'anthropic';
|
|
34
|
+
/** One credit / spend meter reported by the billing service. */
|
|
35
|
+
export interface CommandCodeMeter {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
/** Used fraction in [0, 1] when the service reports a bounded allowance. */
|
|
39
|
+
usedFraction: number | null;
|
|
40
|
+
/** Remaining fraction in [0, 1], when the service reports one. */
|
|
41
|
+
remainingFraction: number | null;
|
|
42
|
+
used: string | null;
|
|
43
|
+
limit: string | null;
|
|
44
|
+
/** Unix milliseconds the meter resets, when reported. */
|
|
45
|
+
resetsAt: number | null;
|
|
46
|
+
description: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** Windowed request/token allowance reported by the usage service. */
|
|
49
|
+
export interface CommandCodeUsageWindow {
|
|
50
|
+
id: string;
|
|
51
|
+
label: string;
|
|
52
|
+
usedPercent: number;
|
|
53
|
+
windowDurationMins: number | null;
|
|
54
|
+
resetsAt: number | null;
|
|
55
|
+
}
|
|
56
|
+
/** Account identity returned by `/alpha/whoami`. */
|
|
57
|
+
export interface CommandCodeAccount {
|
|
58
|
+
userId: string | null;
|
|
59
|
+
userName: string | null;
|
|
60
|
+
email: string | null;
|
|
61
|
+
organizationName: string | null;
|
|
62
|
+
keyName: string | null;
|
|
63
|
+
planLabel: string | null;
|
|
64
|
+
planId: string | null;
|
|
65
|
+
authenticatedAt: number | null;
|
|
66
|
+
}
|
|
67
|
+
/** One point-in-time quota snapshot for the signed-in Command Code account. */
|
|
68
|
+
export interface CommandCodeAccountQuota {
|
|
69
|
+
account: CommandCodeAccount;
|
|
70
|
+
/** Credit balance in the provider's own unit, when reported. */
|
|
71
|
+
creditBalance: string | null;
|
|
72
|
+
/** True when the plan bills against an unlimited allowance. */
|
|
73
|
+
unlimited: boolean;
|
|
74
|
+
/** Machine id the service reports, e.g. `individual-goat`. */
|
|
75
|
+
planId: string | null;
|
|
76
|
+
/** Display name for {@link planId}, e.g. `GOAT`. */
|
|
77
|
+
planName: string | null;
|
|
78
|
+
/** Monthly credits the plan grants, when the id is recognized. */
|
|
79
|
+
planMonthlyCredits: number | null;
|
|
80
|
+
/** Subscription state the service reports, e.g. `active`. */
|
|
81
|
+
subscriptionStatus: string | null;
|
|
82
|
+
/** End of the current billing period, as Unix milliseconds. */
|
|
83
|
+
periodEndsAt: number | null;
|
|
84
|
+
meters: CommandCodeMeter[];
|
|
85
|
+
windows: CommandCodeUsageWindow[];
|
|
86
|
+
/** Raw service payloads, kept for diagnostics in the settings card. */
|
|
87
|
+
fetchedAt: number;
|
|
88
|
+
sources: string[];
|
|
89
|
+
}
|
|
90
|
+
/** Everything the settings card and the composer badge render. */
|
|
91
|
+
export interface CommandCodeWebStatus {
|
|
92
|
+
authenticated: boolean;
|
|
93
|
+
hasCredentials: boolean;
|
|
94
|
+
storagePath: string;
|
|
95
|
+
apiEnv: CommandCodeApiEnv;
|
|
96
|
+
account: CommandCodeAccount | null;
|
|
97
|
+
quota: CommandCodeAccountQuota | null;
|
|
98
|
+
lastFetchedAt: number | null;
|
|
99
|
+
models: CommandCodeModelOption[];
|
|
100
|
+
contextWindowOverrides: Record<string, number>;
|
|
101
|
+
defaultReasoningEffort: CommandCodeReasoningEffort | null;
|
|
102
|
+
/** Route the plugin currently serves; false when another plugin owns it. */
|
|
103
|
+
serving: boolean;
|
|
104
|
+
/** Diagnostic when the route is owned by a different adapter family. */
|
|
105
|
+
conflict: string | null;
|
|
106
|
+
}
|
|
107
|
+
/** Patch accepted by the models/settings routes. */
|
|
108
|
+
export interface CommandCodeSettingsUpdateDto {
|
|
109
|
+
enabledModelIds?: string[];
|
|
110
|
+
contextWindowOverrides?: Record<string, number>;
|
|
111
|
+
defaultReasoningEffort?: CommandCodeReasoningEffort | null;
|
|
112
|
+
}
|
|
113
|
+
/** Result of a manual API-key submission or a compatibility probe. */
|
|
114
|
+
export interface CommandCodeConnectionDto {
|
|
115
|
+
connected: boolean;
|
|
116
|
+
account: CommandCodeAccount | null;
|
|
117
|
+
checkedAt: number;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=command-code-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-code-contracts.d.ts","sourceRoot":"","sources":["../../../src/shared/command-code-contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;AAE5D;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAA;AAEhG,iFAAiF;AACjF,eAAO,MAAM,8BAA8B,EAAE,SAAS,0BAA0B,EAC1B,CAAA;AAEtD,0DAA0D;AAC1D,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,+EAA+E;IAC/E,OAAO,EAAE,OAAO,CAAA;IAChB,8DAA8D;IAC9D,oBAAoB,EAAE,MAAM,CAAA;IAC5B,kFAAkF;IAClF,aAAa,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,gBAAgB,EAAE,MAAM,CAAA;IACxB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,sDAAsD;IACtD,IAAI,EAAE,eAAe,CAAA;CACtB;AAED,0DAA0D;AAC1D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEpD,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,4EAA4E;IAC5E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,kE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Wire contracts between the Kimi Code host routes and the browser settings
|
|
3
|
+
* card. Everything here is public: no credential ever crosses this boundary.
|
|
4
|
+
*
|
|
5
|
+
* Kimi Code (https://www.kimi.com/code) is a Moonshot AI coding subscription,
|
|
6
|
+
* distinct from the pay-as-you-go Moonshot Open Platform: its credentials come
|
|
7
|
+
* from an OAuth device flow against auth.kimi.com and its inference lives at
|
|
8
|
+
* https://api.kimi.com/coding/v1.
|
|
9
|
+
*/
|
|
10
|
+
/** Region a Kimi Code account belongs to; decides which hosts the client uses. */
|
|
11
|
+
export type KimiCodeRegion = 'mainland-cn' | 'global';
|
|
12
|
+
/**
|
|
13
|
+
* Request/response dialect used for the model calls.
|
|
14
|
+
*
|
|
15
|
+
* The official Kimi Code CLI configures its managed provider as `type = "kimi"`,
|
|
16
|
+
* an OpenAI-compatible chat-completions client, so that is the default here.
|
|
17
|
+
* The Anthropic Messages dialect is offered too because the service documents
|
|
18
|
+
* `https://api.kimi.com/coding/` as an Anthropic-compatible base URL for
|
|
19
|
+
* third-party tools, and some models behave better with a thinking budget.
|
|
20
|
+
*/
|
|
21
|
+
export type KimiCodeWire = 'openai' | 'anthropic';
|
|
22
|
+
/**
|
|
23
|
+
* Thinking level a Kimi Code model accepts.
|
|
24
|
+
*
|
|
25
|
+
* Kimi Code maps a tool's effort onto exactly three K3 levels plus a thinking-off
|
|
26
|
+
* switch. The documented mapping is authoritative and deliberately narrower than
|
|
27
|
+
* the generic level set other providers use:
|
|
28
|
+
*
|
|
29
|
+
* - `low` <- `low` / `minimum` / `light`
|
|
30
|
+
* - `high` <- `high` / `medium`
|
|
31
|
+
* - `max` <- `ultra` / `max` / `xhigh`
|
|
32
|
+
* - `none` -> thinking disabled (`thinking.type = "disabled"`)
|
|
33
|
+
*
|
|
34
|
+
* Anything else the client sends is rejected by the service with HTTP 400, so
|
|
35
|
+
* no other level is ever put on the wire.
|
|
36
|
+
*/
|
|
37
|
+
export type KimiCodeReasoningEffort = 'low' | 'high' | 'max' | 'none';
|
|
38
|
+
/** Every level, in escalating order; the settings card renders exactly these. */
|
|
39
|
+
export declare const KIMI_CODE_REASONING_EFFORTS: readonly KimiCodeReasoningEffort[];
|
|
40
|
+
/** One model offered by the Kimi Code coding endpoint. */
|
|
41
|
+
export interface KimiCodeModelOption {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
/** Enabled models are the ones DSH offers in the conversation model picker. */
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
/** Context window the catalog reports for this model. */
|
|
47
|
+
defaultContextWindow: number;
|
|
48
|
+
/** Effective context window: the override when one is saved, else the default. */
|
|
49
|
+
contextWindow: number;
|
|
50
|
+
/** Maximum output tokens this route requests when a caller omits one. */
|
|
51
|
+
defaultMaxTokens: number;
|
|
52
|
+
/** Thinking levels this model accepts; absent for a model that cannot reason. */
|
|
53
|
+
reasoningEfforts?: string[];
|
|
54
|
+
/** Thinking level used when the conversation does not pick one. */
|
|
55
|
+
defaultReasoningEffort?: string;
|
|
56
|
+
/** Request/response dialect the adapter uses on the wire. */
|
|
57
|
+
wire: KimiCodeWire;
|
|
58
|
+
/** Human description from the official model table. */
|
|
59
|
+
description: string | null;
|
|
60
|
+
/** Whether the model accepts video input as well as images. */
|
|
61
|
+
supportsVideo: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the model accepts message-level tool declarations
|
|
64
|
+
* (`messages[].tools`), Kimi's `dynamically_loaded_tools` capability.
|
|
65
|
+
*
|
|
66
|
+
* The card shows it because it is the one K3 feature that changes how a
|
|
67
|
+
* client should be shaped rather than what it may send: a session that
|
|
68
|
+
* progressively discloses tools keeps its top-level list stable, which is
|
|
69
|
+
* what protects the prefix cache.
|
|
70
|
+
*/
|
|
71
|
+
supportsDynamicTools: boolean;
|
|
72
|
+
/** Subscription tier the model needs, when it is not open to every member. */
|
|
73
|
+
minimumPlan: string | null;
|
|
74
|
+
}
|
|
75
|
+
/** One quota window reported for the signed-in account. */
|
|
76
|
+
export interface KimiCodeUsageWindow {
|
|
77
|
+
id: string;
|
|
78
|
+
label: string;
|
|
79
|
+
/** Used fraction in [0, 1]. */
|
|
80
|
+
usedFraction: number;
|
|
81
|
+
/** Convenience integer for the card and badge. */
|
|
82
|
+
usedPercent: number;
|
|
83
|
+
/** Nominal window length in minutes, when the service states one. */
|
|
84
|
+
windowDurationMins: number | null;
|
|
85
|
+
/** Unix milliseconds the window resets, when reported. */
|
|
86
|
+
resetsAt: number | null;
|
|
87
|
+
/** Allowance as the service reports it (request counts), when reported. */
|
|
88
|
+
limit: string | null;
|
|
89
|
+
used: string | null;
|
|
90
|
+
remaining: string | null;
|
|
91
|
+
}
|
|
92
|
+
/** Pay-as-you-go wallet the account can fall back on once a window is spent. */
|
|
93
|
+
export interface KimiCodeExtraUsage {
|
|
94
|
+
/** Remaining wallet balance in the currency's minor unit. */
|
|
95
|
+
balanceCents: number | null;
|
|
96
|
+
totalCents: number | null;
|
|
97
|
+
monthlyChargeLimitEnabled: boolean;
|
|
98
|
+
monthlyChargeLimitCents: number | null;
|
|
99
|
+
monthlyUsedCents: number | null;
|
|
100
|
+
currency: string | null;
|
|
101
|
+
}
|
|
102
|
+
/** Account identity, resolved from the token and the usage response. */
|
|
103
|
+
export interface KimiCodeAccount {
|
|
104
|
+
userId: string | null;
|
|
105
|
+
nickname: string | null;
|
|
106
|
+
email: string | null;
|
|
107
|
+
/** Subscription tier display name, for example Moderato. */
|
|
108
|
+
planName: string | null;
|
|
109
|
+
/** Machine tier level when the service reports one. */
|
|
110
|
+
planLevel: string | null;
|
|
111
|
+
region: KimiCodeRegion | null;
|
|
112
|
+
authenticatedAt: number | null;
|
|
113
|
+
}
|
|
114
|
+
/** One point-in-time quota snapshot for the signed-in Kimi Code account. */
|
|
115
|
+
export interface KimiCodeAccountQuota {
|
|
116
|
+
account: KimiCodeAccount;
|
|
117
|
+
/** Subscription tier display name, when the service reports one. */
|
|
118
|
+
planName: string | null;
|
|
119
|
+
/** Every quota window the account currently has. */
|
|
120
|
+
windows: KimiCodeUsageWindow[];
|
|
121
|
+
/** Pay-as-you-go booster wallet, when the account has one. */
|
|
122
|
+
extraUsage: KimiCodeExtraUsage | null;
|
|
123
|
+
/** Unix milliseconds this snapshot was fetched. */
|
|
124
|
+
fetchedAt: number;
|
|
125
|
+
/** Endpoint paths that answered, kept for diagnostics in the card. */
|
|
126
|
+
sources: string[];
|
|
127
|
+
}
|
|
128
|
+
/** Everything the settings card and the composer badge render. */
|
|
129
|
+
export interface KimiCodeWebStatus {
|
|
130
|
+
authenticated: boolean;
|
|
131
|
+
hasCredentials: boolean;
|
|
132
|
+
storagePath: string;
|
|
133
|
+
region: KimiCodeRegion;
|
|
134
|
+
oauthHost: string;
|
|
135
|
+
codingBaseUrl: string;
|
|
136
|
+
account: KimiCodeAccount | null;
|
|
137
|
+
quota: KimiCodeAccountQuota | null;
|
|
138
|
+
lastFetchedAt: number | null;
|
|
139
|
+
/** When true the stored refresh token was rejected and sign-in is required. */
|
|
140
|
+
credentialsRejected: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Why the quota could not be read, when the last attempt failed.
|
|
143
|
+
*
|
|
144
|
+
* Reported beside the snapshot rather than in place of it: a transient
|
|
145
|
+
* failure should explain itself without hiding the account that is signed in.
|
|
146
|
+
*/
|
|
147
|
+
quotaError?: string | null;
|
|
148
|
+
/** Rolling prefix-cache effectiveness for this process, when requests ran. */
|
|
149
|
+
cache: KimiCodeCacheStatsDto | null;
|
|
150
|
+
/** Whether Preserved Thinking is currently requested on the wire. */
|
|
151
|
+
preserveThinking: boolean;
|
|
152
|
+
models: KimiCodeModelOption[];
|
|
153
|
+
contextWindowOverrides: Record<string, number>;
|
|
154
|
+
defaultReasoningEffort: KimiCodeReasoningEffort | null;
|
|
155
|
+
/** Region used for the next login flow. */
|
|
156
|
+
loginRegion: KimiCodeRegion;
|
|
157
|
+
/** Route the plugin currently serves; false when another plugin owns it. */
|
|
158
|
+
serving: boolean;
|
|
159
|
+
/** Diagnostic when the route is owned by a different adapter family. */
|
|
160
|
+
conflict: string | null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* How well Kimi's automatic prefix cache is working for this process.
|
|
164
|
+
*
|
|
165
|
+
* Reported because the cache is invisible otherwise: it is content-hash based
|
|
166
|
+
* with no marker to set, so the read ratio is the only evidence a session is
|
|
167
|
+
* actually reusing its prefix.
|
|
168
|
+
*/
|
|
169
|
+
export interface KimiCodeCacheStatsDto {
|
|
170
|
+
requests: number;
|
|
171
|
+
cachedTokens: number;
|
|
172
|
+
freshTokens: number;
|
|
173
|
+
outputTokens: number;
|
|
174
|
+
/** Cached / (cached + fresh); null until a request reports usage. */
|
|
175
|
+
hitRatio: number | null;
|
|
176
|
+
}
|
|
177
|
+
/** Patch accepted by the models/settings routes. */
|
|
178
|
+
export interface KimiCodeSettingsUpdateDto {
|
|
179
|
+
enabledModelIds?: string[];
|
|
180
|
+
contextWindowOverrides?: Record<string, number>;
|
|
181
|
+
defaultReasoningEffort?: KimiCodeReasoningEffort | null;
|
|
182
|
+
}
|
|
183
|
+
/** Live state of the device-code login flow the card polls. */
|
|
184
|
+
export interface KimiCodeLoginFlowStatus {
|
|
185
|
+
status: 'idle' | 'pending' | 'complete' | 'error';
|
|
186
|
+
/** Page the user must open, including the pre-filled user code. */
|
|
187
|
+
verificationUriComplete?: string;
|
|
188
|
+
verificationUri?: string;
|
|
189
|
+
userCode?: string;
|
|
190
|
+
startedAt?: number;
|
|
191
|
+
completedAt?: number;
|
|
192
|
+
/** Unix milliseconds the device code stops being valid. */
|
|
193
|
+
expiresAt?: number;
|
|
194
|
+
progress?: string;
|
|
195
|
+
error?: string;
|
|
196
|
+
}
|
|
197
|
+
/** Result of an explicit connection test. */
|
|
198
|
+
export interface KimiCodeConnectionDto {
|
|
199
|
+
connected: boolean;
|
|
200
|
+
latencyMs: number;
|
|
201
|
+
account: KimiCodeAccount | null;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=kimi-code-contracts.d.ts.map
|
|
@@ -0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