@hilbras/omnihilbras 1.69.0 → 1.71.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/dist/adapters/cline.js +1 -1
- package/dist/adapters/kimi-code.d.ts +166 -0
- package/dist/adapters/kimi-code.d.ts.map +1 -0
- package/dist/adapters/kimi-code.js +537 -0
- package/dist/adapters/kimi-code.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/adapters/cline.js
CHANGED
|
@@ -35,7 +35,7 @@ export const CLINE_OAUTH = {
|
|
|
35
35
|
};
|
|
36
36
|
const defaultRefreshSkewMs = 60_000;
|
|
37
37
|
/** Reported to Cline as this client's version. */
|
|
38
|
-
const omnihilbrasVersion = '1.
|
|
38
|
+
const omnihilbrasVersion = '1.71.0';
|
|
39
39
|
/** Cline only accepts WorkOS JWTs with an explicit prefix. */
|
|
40
40
|
export function toClineAccessToken(token) {
|
|
41
41
|
const trimmed = token.trim();
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { type HttpTransport } from '../transport.js';
|
|
2
|
+
import type { ChatChunk, ChatRequest, ChatResponse, EmbeddingRequest, EmbeddingResponse, Model, ProviderAdapter, ProviderCapabilities, ProviderCredential, ProviderHealth, ProviderRequestContext } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Kimi Code — the `api.kimi.com` coding subscription, reached by OAuth device code.
|
|
5
|
+
*
|
|
6
|
+
* ## Why this exists beside the `kimi` API-key adapter
|
|
7
|
+
*
|
|
8
|
+
* Two different things share the name Kimi. `https://api.moonshot.ai/v1` is the platform, sold per
|
|
9
|
+
* token with an API key, and that card already exists. `https://api.kimi.com/coding` is a *subscription*
|
|
10
|
+
* — a monthly plan that signs in with the account you already have, exactly as the vendor's own CLI
|
|
11
|
+
* does. They are separate accounts, separate billing, and separate endpoints, so they get separate
|
|
12
|
+
* provider ids and separate cards rather than one card with two modes.
|
|
13
|
+
*
|
|
14
|
+
* ## What was verified, and what was taken on trust
|
|
15
|
+
*
|
|
16
|
+
* Every host below was probed before it was written down:
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* POST https://auth.kimi.com/api/oauth/token -> 405 Method Not Allowed (live; GET is not the method)
|
|
20
|
+
* GET https://api.kimi.com/coding/v1/models -> 401 Invalid Authentication
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* A 405 from a GET is the useful signal: it means a real service answered with "wrong verb", not a
|
|
24
|
+
* parked domain. The client id is **not** verified — it is Kimi's public, shipped-in-their-CLI
|
|
25
|
+
* identifier, copied from their own registry, and a wrong one fails at the first sign-in with
|
|
26
|
+
* `invalid_client`, which is a safe and visible failure.
|
|
27
|
+
*
|
|
28
|
+
* ## The two auth modes this provider has
|
|
29
|
+
*
|
|
30
|
+
* Kimi accepts the OAuth token and the platform API key over the *same* endpoint, distinguished only
|
|
31
|
+
* by which header carries it. `credential` below is therefore a union in practice: an OAuth value is
|
|
32
|
+
* sent as `Authorization: Bearer`, an api-key value as `x-api-key`. That is not a convenience — it is
|
|
33
|
+
* what lets the same model ids work for both accounts.
|
|
34
|
+
*/
|
|
35
|
+
export declare const KIMI_CODE: {
|
|
36
|
+
/** The coding subscription's API host. */
|
|
37
|
+
readonly server: "https://api.kimi.com";
|
|
38
|
+
/** The account host that issues and renews tokens. Separate from the API host by design. */
|
|
39
|
+
readonly authOrigin: "https://auth.kimi.com";
|
|
40
|
+
/** The web origin the user visits to approve a device code. */
|
|
41
|
+
readonly webOrigin: "https://www.kimi.com";
|
|
42
|
+
/**
|
|
43
|
+
* Kimi's public CLI client id.
|
|
44
|
+
*
|
|
45
|
+
* Taken from Kimi's own published registry rather than invented, because the token endpoint is
|
|
46
|
+
* bound to it and an unregistered id is refused with `invalid_client`.
|
|
47
|
+
*/
|
|
48
|
+
readonly clientId: "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
49
|
+
readonly deviceCodePath: "/api/oauth/device_authorization";
|
|
50
|
+
readonly deviceTokenPath: "/api/oauth/token";
|
|
51
|
+
readonly chatPath: "/coding/v1/chat/completions";
|
|
52
|
+
readonly modelsPath: "/coding/v1/models";
|
|
53
|
+
readonly embeddingsPath: "/coding/v1/embeddings";
|
|
54
|
+
readonly grantType: "urn:ietf:params:oauth:grant-type:device_code";
|
|
55
|
+
readonly refreshGrantType: "refresh_token";
|
|
56
|
+
};
|
|
57
|
+
export declare const kimiCodeProviderId = "kimi-code";
|
|
58
|
+
export type KimiCodeAdapterOptions = {
|
|
59
|
+
transport?: HttpTransport;
|
|
60
|
+
timeoutMs?: number;
|
|
61
|
+
/** Called with a renewed credential so a caller can persist it. */
|
|
62
|
+
onTokensRefreshed?: (credential: ProviderCredential) => void | Promise<void>;
|
|
63
|
+
now?: () => number;
|
|
64
|
+
};
|
|
65
|
+
export declare class KimiCodeAdapter implements ProviderAdapter {
|
|
66
|
+
readonly id = "kimi-code";
|
|
67
|
+
readonly name = "Kimi Code";
|
|
68
|
+
readonly capabilities: ProviderCapabilities;
|
|
69
|
+
private readonly baseUrl;
|
|
70
|
+
private readonly transport;
|
|
71
|
+
private readonly onTokensRefreshed?;
|
|
72
|
+
private readonly now;
|
|
73
|
+
private readonly headers;
|
|
74
|
+
/** Renewed credentials keyed by the access token they replaced. */
|
|
75
|
+
private readonly renewed;
|
|
76
|
+
constructor(options?: KimiCodeAdapterOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Asks Kimi for a device code.
|
|
79
|
+
*
|
|
80
|
+
* The verification URI comes back relative to the *web* origin, so joining it to the API host would
|
|
81
|
+
* produce a page that does not exist — the same trap the Console flow documents.
|
|
82
|
+
*/
|
|
83
|
+
beginSignIn(): Promise<{
|
|
84
|
+
deviceCode: string;
|
|
85
|
+
/** The id this flow minted, which the poll must present. */
|
|
86
|
+
deviceId: string;
|
|
87
|
+
userCode: string;
|
|
88
|
+
verificationUrl: string;
|
|
89
|
+
expiresIn?: number;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Polls for the token.
|
|
93
|
+
*
|
|
94
|
+
* Kimi answers a pending poll with an error code in the body, so the *code* decides the outcome and
|
|
95
|
+
* a transport-level 4xx is not treated as a failed sign-in. `slow_down` is mapped to `pending`
|
|
96
|
+
* rather than a denial because it is Kimi asking for a slower poll, not refusing the grant.
|
|
97
|
+
*/
|
|
98
|
+
pollSignIn(deviceCode: string, signal?: AbortSignal, deviceId?: string): Promise<{
|
|
99
|
+
status: 'pending';
|
|
100
|
+
} | {
|
|
101
|
+
status: 'denied';
|
|
102
|
+
error: string;
|
|
103
|
+
} | {
|
|
104
|
+
status: 'connected';
|
|
105
|
+
credential: ProviderCredential;
|
|
106
|
+
account: string;
|
|
107
|
+
}>;
|
|
108
|
+
listModels(context?: ProviderRequestContext): Promise<Model[]>;
|
|
109
|
+
chat(request: ChatRequest, context?: ProviderRequestContext): Promise<ChatResponse>;
|
|
110
|
+
streamChat(request: ChatRequest, context?: ProviderRequestContext): AsyncIterable<ChatChunk>;
|
|
111
|
+
/**
|
|
112
|
+
* Kimi's coding endpoint serves `/coding/v1/embeddings`.
|
|
113
|
+
*
|
|
114
|
+
* `dimensions` is measured from the vector, never assumed — the same rule the OpenAI-compatible
|
|
115
|
+
* adapter follows, and for the same reason: a wrong dimension count cannot be detected by a caller
|
|
116
|
+
* after the vector has been built.
|
|
117
|
+
*/
|
|
118
|
+
embed(request: EmbeddingRequest, context?: ProviderRequestContext): Promise<EmbeddingResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Reads `/coding/v1/models`, which is free and never bills.
|
|
121
|
+
*
|
|
122
|
+
* A health check that spends money would be a real cost on every sweep, and a check that launches a
|
|
123
|
+
* browser was the defect fixed in the credential-lifecycle work. A free authenticated read is both.
|
|
124
|
+
*/
|
|
125
|
+
healthCheck(context?: ProviderRequestContext): Promise<ProviderHealth>;
|
|
126
|
+
/** Kimi's token, renewed without asking the user to sign in again. */
|
|
127
|
+
private credential;
|
|
128
|
+
private url;
|
|
129
|
+
/**
|
|
130
|
+
* The credential header, which is the one place the two auth modes differ.
|
|
131
|
+
*
|
|
132
|
+
* An OAuth token goes in `Authorization: Bearer` and a platform API key in `x-api-key`, because
|
|
133
|
+
* Kimi's coding endpoint accepts both and distinguishes them by header. Sending an OAuth token as
|
|
134
|
+
* `x-api-key` produces a `401` whose body names the header it wanted, so the split is read from the
|
|
135
|
+
* credential rather than hardcoded per request.
|
|
136
|
+
*/
|
|
137
|
+
private requestHeaders;
|
|
138
|
+
private toRequestBody;
|
|
139
|
+
private toChatResponse;
|
|
140
|
+
/**
|
|
141
|
+
* Posts a form-encoded body to the account host.
|
|
142
|
+
*
|
|
143
|
+
* `URLSearchParams` rather than a hand-built string, so a value containing `&` or `=` is encoded
|
|
144
|
+
* rather than splitting the body — which on a token endpoint means a client id that arrives
|
|
145
|
+
* truncated, with no error to point at.
|
|
146
|
+
*/
|
|
147
|
+
private postForm;
|
|
148
|
+
/**
|
|
149
|
+
* The account-host headers, which differ from the API-host ones.
|
|
150
|
+
*
|
|
151
|
+
* `X-Msh-Device-Id` is a per-sign-in identifier that has to be **the same on the start and the poll**:
|
|
152
|
+
* Kimi ties the two halves of a device grant together by it, so a poll carrying a fresh id asks
|
|
153
|
+
* about a different session and comes back `authorization_pending` forever. It is minted once per
|
|
154
|
+
* sign-in and carried on the session, which is why `pollSignIn` takes it as a parameter.
|
|
155
|
+
*/
|
|
156
|
+
private kimiHeaders;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Whether the credential is definitely expired.
|
|
160
|
+
*
|
|
161
|
+
* Three answers, because the third is the load-bearing one: `true` is definitely expired, `false` is
|
|
162
|
+
* definitely not, and `undefined` means *this adapter cannot say* — so the gateway asks the provider
|
|
163
|
+
* rather than ejecting a working connection.
|
|
164
|
+
*/
|
|
165
|
+
export declare function kimiCodeCredentialExpired(credential: ProviderCredential | undefined, now: number): boolean | undefined;
|
|
166
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ACH,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,cAAc;IAyBtB;;;;;;OAMG;YACW,QAAQ;IAYtB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CASpB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAOtH"}
|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import { ProviderError } from '../errors.js';
|
|
2
|
+
import { parseSseJson, parseSseStream } from '../streaming.js';
|
|
3
|
+
import { FetchHttpTransport } from '../transport.js';
|
|
4
|
+
import { assertSafeProviderHeaderValue, normalizeProviderBaseUrl, resolveProviderUrl, sanitizeProviderHeaders } from '../url.js';
|
|
5
|
+
/**
|
|
6
|
+
* Kimi Code — the `api.kimi.com` coding subscription, reached by OAuth device code.
|
|
7
|
+
*
|
|
8
|
+
* ## Why this exists beside the `kimi` API-key adapter
|
|
9
|
+
*
|
|
10
|
+
* Two different things share the name Kimi. `https://api.moonshot.ai/v1` is the platform, sold per
|
|
11
|
+
* token with an API key, and that card already exists. `https://api.kimi.com/coding` is a *subscription*
|
|
12
|
+
* — a monthly plan that signs in with the account you already have, exactly as the vendor's own CLI
|
|
13
|
+
* does. They are separate accounts, separate billing, and separate endpoints, so they get separate
|
|
14
|
+
* provider ids and separate cards rather than one card with two modes.
|
|
15
|
+
*
|
|
16
|
+
* ## What was verified, and what was taken on trust
|
|
17
|
+
*
|
|
18
|
+
* Every host below was probed before it was written down:
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* POST https://auth.kimi.com/api/oauth/token -> 405 Method Not Allowed (live; GET is not the method)
|
|
22
|
+
* GET https://api.kimi.com/coding/v1/models -> 401 Invalid Authentication
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* A 405 from a GET is the useful signal: it means a real service answered with "wrong verb", not a
|
|
26
|
+
* parked domain. The client id is **not** verified — it is Kimi's public, shipped-in-their-CLI
|
|
27
|
+
* identifier, copied from their own registry, and a wrong one fails at the first sign-in with
|
|
28
|
+
* `invalid_client`, which is a safe and visible failure.
|
|
29
|
+
*
|
|
30
|
+
* ## The two auth modes this provider has
|
|
31
|
+
*
|
|
32
|
+
* Kimi accepts the OAuth token and the platform API key over the *same* endpoint, distinguished only
|
|
33
|
+
* by which header carries it. `credential` below is therefore a union in practice: an OAuth value is
|
|
34
|
+
* sent as `Authorization: Bearer`, an api-key value as `x-api-key`. That is not a convenience — it is
|
|
35
|
+
* what lets the same model ids work for both accounts.
|
|
36
|
+
*/
|
|
37
|
+
export const KIMI_CODE = {
|
|
38
|
+
/** The coding subscription's API host. */
|
|
39
|
+
server: 'https://api.kimi.com',
|
|
40
|
+
/** The account host that issues and renews tokens. Separate from the API host by design. */
|
|
41
|
+
authOrigin: 'https://auth.kimi.com',
|
|
42
|
+
/** The web origin the user visits to approve a device code. */
|
|
43
|
+
webOrigin: 'https://www.kimi.com',
|
|
44
|
+
/**
|
|
45
|
+
* Kimi's public CLI client id.
|
|
46
|
+
*
|
|
47
|
+
* Taken from Kimi's own published registry rather than invented, because the token endpoint is
|
|
48
|
+
* bound to it and an unregistered id is refused with `invalid_client`.
|
|
49
|
+
*/
|
|
50
|
+
clientId: '17e5f671-d194-4dfb-9706-5516cb48c098',
|
|
51
|
+
deviceCodePath: '/api/oauth/device_authorization',
|
|
52
|
+
deviceTokenPath: '/api/oauth/token',
|
|
53
|
+
chatPath: '/coding/v1/chat/completions',
|
|
54
|
+
modelsPath: '/coding/v1/models',
|
|
55
|
+
embeddingsPath: '/coding/v1/embeddings',
|
|
56
|
+
grantType: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
57
|
+
refreshGrantType: 'refresh_token',
|
|
58
|
+
};
|
|
59
|
+
export const kimiCodeProviderId = 'kimi-code';
|
|
60
|
+
export class KimiCodeAdapter {
|
|
61
|
+
id = kimiCodeProviderId;
|
|
62
|
+
name = 'Kimi Code';
|
|
63
|
+
capabilities = { chat: true, streaming: true, models: true, embeddings: true };
|
|
64
|
+
baseUrl;
|
|
65
|
+
transport;
|
|
66
|
+
onTokensRefreshed;
|
|
67
|
+
now;
|
|
68
|
+
headers;
|
|
69
|
+
/** Renewed credentials keyed by the access token they replaced. */
|
|
70
|
+
renewed = new Map();
|
|
71
|
+
constructor(options = {}) {
|
|
72
|
+
this.baseUrl = normalizeProviderBaseUrl(KIMI_CODE.server, this.id);
|
|
73
|
+
this.transport = options.transport ?? new FetchHttpTransport({ timeoutMs: options.timeoutMs });
|
|
74
|
+
this.onTokensRefreshed = options.onTokensRefreshed;
|
|
75
|
+
this.now = options.now ?? (() => Date.now());
|
|
76
|
+
/**
|
|
77
|
+
* The client headers Kimi's own CLI sends.
|
|
78
|
+
*
|
|
79
|
+
* Kept, and named as what they are: the coding endpoint is served to their CLI, and these are
|
|
80
|
+
* what identify a request as coming from one. A request without them is not "a Kimi request with
|
|
81
|
+
* fewer fields" — it is a request from something Kimi does not serve.
|
|
82
|
+
*/
|
|
83
|
+
this.headers = sanitizeProviderHeaders({
|
|
84
|
+
'X-Msh-Version': '1',
|
|
85
|
+
'User-Agent': 'kimi-cli/1.0.0 (external, sdk-cli)',
|
|
86
|
+
'X-App': 'cli',
|
|
87
|
+
'X-Stainless-Lang': 'js',
|
|
88
|
+
'X-Stainless-Runtime': 'node',
|
|
89
|
+
'X-Stainless-Runtime-Version': 'v24.14.0',
|
|
90
|
+
'X-Stainless-Package-Version': '0.80.0',
|
|
91
|
+
'X-Stainless-Retry-Count': '0',
|
|
92
|
+
'X-Stainless-Timeout': '600',
|
|
93
|
+
'Anthropic-Beta': 'claude-code-20250219,oauth-2025-04-20',
|
|
94
|
+
}, this.id);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Asks Kimi for a device code.
|
|
98
|
+
*
|
|
99
|
+
* The verification URI comes back relative to the *web* origin, so joining it to the API host would
|
|
100
|
+
* produce a page that does not exist — the same trap the Console flow documents.
|
|
101
|
+
*/
|
|
102
|
+
async beginSignIn() {
|
|
103
|
+
// **Form-encoded, and that is measured rather than assumed.** Kimi's device endpoints answer a
|
|
104
|
+
// JSON body with `400 {"error":"invalid_request","error_description":"client_id is required"}` —
|
|
105
|
+
// the parameter is present and still refused, because the body was not read at all. The same
|
|
106
|
+
// request form-encoded returns 200 with a real `device_code`:
|
|
107
|
+
//
|
|
108
|
+
// ```
|
|
109
|
+
// POST /api/oauth/device_authorization content-type: application/json -> 400 client_id is required
|
|
110
|
+
// POST /api/oauth/device_authorization content-type: x-www-form-urlencoded -> 200 {"device_code":"...","user_code":"..."}
|
|
111
|
+
// ```
|
|
112
|
+
//
|
|
113
|
+
// So `postJson` was the wrong shape for both halves of this flow, and it is `postForm` below.
|
|
114
|
+
const deviceId = crypto.randomUUID();
|
|
115
|
+
const { data } = await this.postForm(KIMI_CODE.deviceCodePath, {
|
|
116
|
+
client_id: KIMI_CODE.clientId,
|
|
117
|
+
}, this.kimiHeaders(deviceId));
|
|
118
|
+
const deviceCode = typeof data.device_code === 'string' ? data.device_code : '';
|
|
119
|
+
const userCode = typeof data.user_code === 'string' ? data.user_code : '';
|
|
120
|
+
if (!deviceCode || !userCode) {
|
|
121
|
+
throw new ProviderError('PROVIDER_REQUEST_FAILED', 'Kimi did not return a device code. Try again in a moment.', { providerId: this.id });
|
|
122
|
+
}
|
|
123
|
+
// Kimi answers with an **absolute** URL (measured), so it is used as given. The relative-join
|
|
124
|
+
// fallback is kept for a server that answers with a path, because joining an absolute URL to the
|
|
125
|
+
// web origin produces `https://www.kimi.com/https://www.kimi.com/code/...`.
|
|
126
|
+
const given = data.verification_uri_complete ?? data.verification_uri;
|
|
127
|
+
const verificationUrl = given
|
|
128
|
+
? (/^https?:\/\//.test(given) ? given : `${KIMI_CODE.webOrigin}${given.startsWith('/') ? '' : '/'}${given}`)
|
|
129
|
+
: `${KIMI_CODE.webOrigin}/code/authorize_device`;
|
|
130
|
+
return {
|
|
131
|
+
deviceCode,
|
|
132
|
+
deviceId,
|
|
133
|
+
userCode,
|
|
134
|
+
verificationUrl,
|
|
135
|
+
...(typeof data.expires_in === 'number' ? { expiresIn: data.expires_in } : {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Polls for the token.
|
|
140
|
+
*
|
|
141
|
+
* Kimi answers a pending poll with an error code in the body, so the *code* decides the outcome and
|
|
142
|
+
* a transport-level 4xx is not treated as a failed sign-in. `slow_down` is mapped to `pending`
|
|
143
|
+
* rather than a denial because it is Kimi asking for a slower poll, not refusing the grant.
|
|
144
|
+
*/
|
|
145
|
+
async pollSignIn(deviceCode, signal, deviceId = crypto.randomUUID()) {
|
|
146
|
+
// Same form encoding, for the same measured reason.
|
|
147
|
+
const { data } = await this.postForm(KIMI_CODE.deviceTokenPath, {
|
|
148
|
+
grant_type: KIMI_CODE.grantType,
|
|
149
|
+
device_code: deviceCode,
|
|
150
|
+
client_id: KIMI_CODE.clientId,
|
|
151
|
+
}, this.kimiHeaders(deviceId), signal);
|
|
152
|
+
const error = typeof data.error === 'string' ? data.error : '';
|
|
153
|
+
if (error === 'authorization_pending' || error === 'slow_down')
|
|
154
|
+
return { status: 'pending' };
|
|
155
|
+
if (error) {
|
|
156
|
+
const description = typeof data.error_description === 'string' ? data.error_description : '';
|
|
157
|
+
return {
|
|
158
|
+
status: 'denied',
|
|
159
|
+
error: description || `Kimi reported ${error.replace(/[^A-Za-z0-9_.-]/g, '').slice(0, 40)}.`,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const access = typeof data.access_token === 'string' ? data.access_token : '';
|
|
163
|
+
if (!access)
|
|
164
|
+
return { status: 'denied', error: 'Kimi did not return a session. Start the sign-in again.' };
|
|
165
|
+
const credential = {
|
|
166
|
+
type: 'oauth',
|
|
167
|
+
value: access,
|
|
168
|
+
...(typeof data.refresh_token === 'string' ? { refreshToken: data.refresh_token } : {}),
|
|
169
|
+
...(typeof data.expires_in === 'number' ? { expiresAt: new Date(Date.now() + data.expires_in * 1000).toISOString() } : {}),
|
|
170
|
+
oauthClientId: KIMI_CODE.clientId,
|
|
171
|
+
};
|
|
172
|
+
return { status: 'connected', credential, account: 'Kimi Code subscription' };
|
|
173
|
+
}
|
|
174
|
+
async listModels(context = {}) {
|
|
175
|
+
const credential = await this.credential(context);
|
|
176
|
+
const { data } = await this.transport.request({
|
|
177
|
+
method: 'GET',
|
|
178
|
+
providerId: this.id,
|
|
179
|
+
url: this.url(KIMI_CODE.modelsPath),
|
|
180
|
+
headers: this.requestHeaders(credential),
|
|
181
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
182
|
+
});
|
|
183
|
+
const rows = data?.data;
|
|
184
|
+
if (!Array.isArray(rows))
|
|
185
|
+
throw invalidResponse(this.id, 'Kimi model list is missing data.');
|
|
186
|
+
return rows.flatMap((model) => (model.id ? [{ id: model.id, providerId: this.id }] : []));
|
|
187
|
+
}
|
|
188
|
+
async chat(request, context = {}) {
|
|
189
|
+
const credential = await this.credential(context);
|
|
190
|
+
const { data } = await this.transport.request({
|
|
191
|
+
method: 'POST',
|
|
192
|
+
providerId: this.id,
|
|
193
|
+
url: this.url(KIMI_CODE.chatPath),
|
|
194
|
+
headers: this.requestHeaders(credential),
|
|
195
|
+
body: JSON.stringify(this.toRequestBody(request, false)),
|
|
196
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
197
|
+
});
|
|
198
|
+
return this.toChatResponse(data, request.model);
|
|
199
|
+
}
|
|
200
|
+
async *streamChat(request, context = {}) {
|
|
201
|
+
const credential = await this.credential(context);
|
|
202
|
+
const events = this.transport.stream({
|
|
203
|
+
method: 'POST',
|
|
204
|
+
providerId: this.id,
|
|
205
|
+
url: this.url(KIMI_CODE.chatPath),
|
|
206
|
+
headers: this.requestHeaders(credential),
|
|
207
|
+
body: JSON.stringify(this.toRequestBody(request, true)),
|
|
208
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
209
|
+
});
|
|
210
|
+
let sawPayload = false;
|
|
211
|
+
let sawDone = false;
|
|
212
|
+
for await (const event of parseSseStream(events)) {
|
|
213
|
+
if (event.data.trim() === '[DONE]') {
|
|
214
|
+
sawDone = true;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
const payload = parseSseJson(event, this.id);
|
|
218
|
+
if (!payload)
|
|
219
|
+
continue;
|
|
220
|
+
sawPayload = true;
|
|
221
|
+
if (payload.error) {
|
|
222
|
+
throw new ProviderError('PROVIDER_REQUEST_FAILED', payload.error.message ?? 'Kimi reported an error while streaming.', { providerId: this.id });
|
|
223
|
+
}
|
|
224
|
+
const choice = payload.choices?.[0];
|
|
225
|
+
const delta = choice?.delta;
|
|
226
|
+
yield {
|
|
227
|
+
id: payload.id ?? `stream-${request.model}`,
|
|
228
|
+
providerId: this.id,
|
|
229
|
+
model: payload.model ?? request.model,
|
|
230
|
+
delta: {
|
|
231
|
+
...(delta?.role ? { role: normalizeRole(delta.role) } : {}),
|
|
232
|
+
...(delta?.content ? { content: delta.content } : {}),
|
|
233
|
+
...(delta?.tool_calls?.length ? { toolCalls: delta.tool_calls.map(normalizeToolCallDelta) } : {}),
|
|
234
|
+
},
|
|
235
|
+
...(choice?.finish_reason ? { finishReason: normalizeFinishReason(choice.finish_reason) } : {}),
|
|
236
|
+
...(payload.usage ? { usage: normalizeUsage(payload.usage) } : {}),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (!sawPayload || !sawDone) {
|
|
240
|
+
throw new ProviderError('INVALID_RESPONSE', 'The Kimi stream ended before completion.', { providerId: this.id });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Kimi's coding endpoint serves `/coding/v1/embeddings`.
|
|
245
|
+
*
|
|
246
|
+
* `dimensions` is measured from the vector, never assumed — the same rule the OpenAI-compatible
|
|
247
|
+
* adapter follows, and for the same reason: a wrong dimension count cannot be detected by a caller
|
|
248
|
+
* after the vector has been built.
|
|
249
|
+
*/
|
|
250
|
+
async embed(request, context = {}) {
|
|
251
|
+
const credential = await this.credential(context);
|
|
252
|
+
const inputs = typeof request.input === 'string' ? [request.input] : [...request.input];
|
|
253
|
+
if (inputs.length === 0 || inputs.some((value) => !value)) {
|
|
254
|
+
throw new ProviderError('INVALID_REQUEST', 'Embedding input must be a non-empty string or a non-empty array of non-empty strings.', { providerId: this.id });
|
|
255
|
+
}
|
|
256
|
+
const body = { model: request.model, input: inputs };
|
|
257
|
+
if (request.dimensions !== undefined)
|
|
258
|
+
body.dimensions = request.dimensions;
|
|
259
|
+
const { data } = await this.transport.request({
|
|
260
|
+
method: 'POST',
|
|
261
|
+
providerId: this.id,
|
|
262
|
+
url: this.url(KIMI_CODE.embeddingsPath),
|
|
263
|
+
headers: this.requestHeaders(credential),
|
|
264
|
+
body: JSON.stringify(body),
|
|
265
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
266
|
+
});
|
|
267
|
+
const rows = data?.data;
|
|
268
|
+
if (!Array.isArray(rows))
|
|
269
|
+
throw invalidResponse(this.id, 'Kimi embeddings response is missing data.');
|
|
270
|
+
const vectors = rows.map((row, position) => {
|
|
271
|
+
const embedding = row?.embedding;
|
|
272
|
+
if (!Array.isArray(embedding) || embedding.length === 0) {
|
|
273
|
+
throw invalidResponse(this.id, `Kimi embedding at index ${position} is missing its vector.`);
|
|
274
|
+
}
|
|
275
|
+
if (embedding.some((value) => typeof value !== 'number' || !Number.isFinite(value))) {
|
|
276
|
+
throw invalidResponse(this.id, `Kimi embedding at index ${position} contains a non-numeric value.`);
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
index: typeof row?.index === 'number' ? row.index : position,
|
|
280
|
+
embedding,
|
|
281
|
+
dimensions: embedding.length,
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
if (vectors.length !== inputs.length) {
|
|
285
|
+
throw invalidResponse(this.id, `Kimi returned ${vectors.length} embedding(s) for ${inputs.length} input(s).`);
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
id: data.id ?? `embed-${request.model}`,
|
|
289
|
+
providerId: this.id,
|
|
290
|
+
model: data.model ?? request.model,
|
|
291
|
+
createdAt: new Date((typeof data.created === 'number' ? data.created : Date.now() / 1000) * 1000).toISOString(),
|
|
292
|
+
data: vectors,
|
|
293
|
+
...(data.usage ? { usage: normalizeUsage(data.usage) } : {}),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Reads `/coding/v1/models`, which is free and never bills.
|
|
298
|
+
*
|
|
299
|
+
* A health check that spends money would be a real cost on every sweep, and a check that launches a
|
|
300
|
+
* browser was the defect fixed in the credential-lifecycle work. A free authenticated read is both.
|
|
301
|
+
*/
|
|
302
|
+
async healthCheck(context = {}) {
|
|
303
|
+
const startedAt = performance.now();
|
|
304
|
+
try {
|
|
305
|
+
await this.listModels(context);
|
|
306
|
+
return {
|
|
307
|
+
status: 'healthy',
|
|
308
|
+
verified: 'credential',
|
|
309
|
+
latencyMs: Math.round(performance.now() - startedAt),
|
|
310
|
+
checkedAt: new Date().toISOString(),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
const code = error instanceof ProviderError ? error.code : 'PROVIDER_REQUEST_FAILED';
|
|
315
|
+
return {
|
|
316
|
+
status: 'unavailable',
|
|
317
|
+
verified: 'credential',
|
|
318
|
+
latencyMs: Math.round(performance.now() - startedAt),
|
|
319
|
+
checkedAt: new Date().toISOString(),
|
|
320
|
+
...(error instanceof Error ? { message: error.message } : {}),
|
|
321
|
+
...(error instanceof ProviderError && code !== 'PROVIDER_REQUEST_FAILED' ? { reason: code } : {}),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/** Kimi's token, renewed without asking the user to sign in again. */
|
|
326
|
+
async credential(context) {
|
|
327
|
+
const current = context.credential;
|
|
328
|
+
if (!kimiCodeCredentialExpired(current, this.now()))
|
|
329
|
+
return current;
|
|
330
|
+
// Narrowed once, here, because reading `.refreshToken` off the union is a compile error on the
|
|
331
|
+
// `api-key` and `none` arms and reading it through a cast would hide a genuinely absent refresh.
|
|
332
|
+
const refresh = current?.type === 'oauth' ? current.refreshToken : undefined;
|
|
333
|
+
if (typeof refresh !== 'string' || !refresh) {
|
|
334
|
+
throw new ProviderError('AUTHENTICATION_FAILED', 'The Kimi Code session has expired. Sign in again.', { providerId: this.id });
|
|
335
|
+
}
|
|
336
|
+
const replaced = current?.type === 'oauth' ? current.value : '';
|
|
337
|
+
const memo = this.renewed.get(replaced);
|
|
338
|
+
if (memo)
|
|
339
|
+
return memo;
|
|
340
|
+
const { data } = await this.transport.request({
|
|
341
|
+
method: 'POST',
|
|
342
|
+
providerId: this.id,
|
|
343
|
+
url: `${KIMI_CODE.authOrigin}${KIMI_CODE.deviceTokenPath}`,
|
|
344
|
+
headers: { accept: 'application/json', 'content-type': 'application/x-www-form-urlencoded' },
|
|
345
|
+
body: new URLSearchParams({
|
|
346
|
+
grant_type: KIMI_CODE.refreshGrantType,
|
|
347
|
+
refresh_token: refresh,
|
|
348
|
+
client_id: KIMI_CODE.clientId,
|
|
349
|
+
}).toString(),
|
|
350
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
351
|
+
});
|
|
352
|
+
const access = typeof data.access_token === 'string' ? data.access_token : '';
|
|
353
|
+
if (!access) {
|
|
354
|
+
const description = typeof data.error_description === 'string' ? data.error_description : '';
|
|
355
|
+
throw new ProviderError('AUTHENTICATION_FAILED', description || 'Kimi refused to renew the session. Sign in again.', { providerId: this.id });
|
|
356
|
+
}
|
|
357
|
+
const renewed = {
|
|
358
|
+
type: 'oauth',
|
|
359
|
+
value: access,
|
|
360
|
+
...(typeof data.refresh_token === 'string' ? { refreshToken: data.refresh_token } : { refreshToken: refresh }),
|
|
361
|
+
...(typeof data.expires_in === 'number' ? { expiresAt: new Date(Date.now() + data.expires_in * 1000).toISOString() } : {}),
|
|
362
|
+
oauthClientId: KIMI_CODE.clientId,
|
|
363
|
+
};
|
|
364
|
+
this.renewed.set(replaced, renewed);
|
|
365
|
+
await this.onTokensRefreshed?.(renewed);
|
|
366
|
+
return renewed;
|
|
367
|
+
}
|
|
368
|
+
url(path) {
|
|
369
|
+
return resolveProviderUrl(this.baseUrl, path, this.id);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The credential header, which is the one place the two auth modes differ.
|
|
373
|
+
*
|
|
374
|
+
* An OAuth token goes in `Authorization: Bearer` and a platform API key in `x-api-key`, because
|
|
375
|
+
* Kimi's coding endpoint accepts both and distinguishes them by header. Sending an OAuth token as
|
|
376
|
+
* `x-api-key` produces a `401` whose body names the header it wanted, so the split is read from the
|
|
377
|
+
* credential rather than hardcoded per request.
|
|
378
|
+
*/
|
|
379
|
+
requestHeaders(credential) {
|
|
380
|
+
const headers = {
|
|
381
|
+
accept: 'application/json',
|
|
382
|
+
'content-type': 'application/json',
|
|
383
|
+
...this.headers,
|
|
384
|
+
};
|
|
385
|
+
if (credential?.type === 'api-key') {
|
|
386
|
+
assertSafeProviderHeaderValue('x-api-key', credential.value, this.id);
|
|
387
|
+
headers['x-api-key'] = credential.value;
|
|
388
|
+
}
|
|
389
|
+
else if (credential?.type === 'oauth' && credential.value) {
|
|
390
|
+
assertSafeProviderHeaderValue('Authorization', credential.value, this.id);
|
|
391
|
+
headers.Authorization = `Bearer ${credential.value}`;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
throw new ProviderError('AUTHENTICATION_FAILED', 'Kimi Code needs a signed-in account or an API key.', { providerId: this.id });
|
|
395
|
+
}
|
|
396
|
+
return headers;
|
|
397
|
+
}
|
|
398
|
+
toRequestBody(request, stream) {
|
|
399
|
+
const body = {
|
|
400
|
+
model: request.model,
|
|
401
|
+
messages: request.messages.map(toOpenAIMessage),
|
|
402
|
+
stream,
|
|
403
|
+
};
|
|
404
|
+
if (request.temperature !== undefined)
|
|
405
|
+
body.temperature = request.temperature;
|
|
406
|
+
if (request.topP !== undefined)
|
|
407
|
+
body.top_p = request.topP;
|
|
408
|
+
if (request.maxOutputTokens !== undefined)
|
|
409
|
+
body.max_tokens = request.maxOutputTokens;
|
|
410
|
+
if (request.stop !== undefined)
|
|
411
|
+
body.stop = request.stop;
|
|
412
|
+
if (request.tools !== undefined)
|
|
413
|
+
body.tools = request.tools.map(toOpenAITool);
|
|
414
|
+
return body;
|
|
415
|
+
}
|
|
416
|
+
toChatResponse(response, requestedModel) {
|
|
417
|
+
const choice = response.choices?.[0];
|
|
418
|
+
if (!choice?.message)
|
|
419
|
+
throw invalidResponse(this.id, 'Kimi returned no message.');
|
|
420
|
+
const content = choice.message.content ?? '';
|
|
421
|
+
const toolCalls = choice.message.tool_calls?.filter((call) => call.function?.name).map((call, index) => ({
|
|
422
|
+
id: call.id ?? `call-${index}`,
|
|
423
|
+
type: 'function',
|
|
424
|
+
function: { name: call.function.name, arguments: call.function.arguments ?? '{}' },
|
|
425
|
+
}));
|
|
426
|
+
return {
|
|
427
|
+
id: response.id ?? `chat-${requestedModel}`,
|
|
428
|
+
providerId: this.id,
|
|
429
|
+
model: response.model ?? requestedModel,
|
|
430
|
+
createdAt: new Date((typeof response.created === 'number' ? response.created : Date.now() / 1000) * 1000).toISOString(),
|
|
431
|
+
message: {
|
|
432
|
+
role: 'assistant',
|
|
433
|
+
// Empty content with tool calls is a real answer, not a missing one — see `parseMessage`.
|
|
434
|
+
content: toolCalls?.length && !content ? null : content,
|
|
435
|
+
...(toolCalls?.length ? { toolCalls } : {}),
|
|
436
|
+
},
|
|
437
|
+
finishReason: normalizeFinishReason(choice.finish_reason),
|
|
438
|
+
...(response.usage ? { usage: normalizeUsage(response.usage) } : {}),
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Posts a form-encoded body to the account host.
|
|
443
|
+
*
|
|
444
|
+
* `URLSearchParams` rather than a hand-built string, so a value containing `&` or `=` is encoded
|
|
445
|
+
* rather than splitting the body — which on a token endpoint means a client id that arrives
|
|
446
|
+
* truncated, with no error to point at.
|
|
447
|
+
*/
|
|
448
|
+
async postForm(path, fields, headers, signal) {
|
|
449
|
+
const response = await this.transport.request({
|
|
450
|
+
method: 'POST',
|
|
451
|
+
providerId: this.id,
|
|
452
|
+
url: `${KIMI_CODE.authOrigin}${path}`,
|
|
453
|
+
headers: { accept: 'application/json', ...headers },
|
|
454
|
+
body: new URLSearchParams(fields).toString(),
|
|
455
|
+
...(signal ? { signal } : {}),
|
|
456
|
+
});
|
|
457
|
+
return { data: (response.data ?? {}) };
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* The account-host headers, which differ from the API-host ones.
|
|
461
|
+
*
|
|
462
|
+
* `X-Msh-Device-Id` is a per-sign-in identifier that has to be **the same on the start and the poll**:
|
|
463
|
+
* Kimi ties the two halves of a device grant together by it, so a poll carrying a fresh id asks
|
|
464
|
+
* about a different session and comes back `authorization_pending` forever. It is minted once per
|
|
465
|
+
* sign-in and carried on the session, which is why `pollSignIn` takes it as a parameter.
|
|
466
|
+
*/
|
|
467
|
+
kimiHeaders(deviceId) {
|
|
468
|
+
return {
|
|
469
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
470
|
+
'X-Msh-Device-Id': deviceId,
|
|
471
|
+
'X-App': 'cli',
|
|
472
|
+
'X-Stainless-Lang': 'js',
|
|
473
|
+
'X-Stainless-Runtime': 'node',
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Whether the credential is definitely expired.
|
|
479
|
+
*
|
|
480
|
+
* Three answers, because the third is the load-bearing one: `true` is definitely expired, `false` is
|
|
481
|
+
* definitely not, and `undefined` means *this adapter cannot say* — so the gateway asks the provider
|
|
482
|
+
* rather than ejecting a working connection.
|
|
483
|
+
*/
|
|
484
|
+
export function kimiCodeCredentialExpired(credential, now) {
|
|
485
|
+
if (!credential || credential.type !== 'oauth')
|
|
486
|
+
return false;
|
|
487
|
+
if (typeof credential.expiresAt !== 'string')
|
|
488
|
+
return undefined;
|
|
489
|
+
const at = Date.parse(credential.expiresAt);
|
|
490
|
+
if (!Number.isFinite(at))
|
|
491
|
+
return undefined;
|
|
492
|
+
// 30s of slack, so a token does not expire in flight between the check and the request.
|
|
493
|
+
return at - 30_000 <= now;
|
|
494
|
+
}
|
|
495
|
+
function normalizeRole(role) {
|
|
496
|
+
return role === 'assistant' || role === 'system' || role === 'tool' ? role : 'user';
|
|
497
|
+
}
|
|
498
|
+
function normalizeFinishReason(reason) {
|
|
499
|
+
return reason === 'length' || reason === 'tool_calls' || reason === 'content_filter' ? reason : 'stop';
|
|
500
|
+
}
|
|
501
|
+
function normalizeUsage(usage) {
|
|
502
|
+
return {
|
|
503
|
+
...(typeof usage.prompt_tokens === 'number' ? { inputTokens: usage.prompt_tokens } : {}),
|
|
504
|
+
...(typeof usage.completion_tokens === 'number' ? { outputTokens: usage.completion_tokens } : {}),
|
|
505
|
+
...(typeof usage.total_tokens === 'number' ? { totalTokens: usage.total_tokens } : {}),
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function normalizeToolCallDelta(call) {
|
|
509
|
+
return {
|
|
510
|
+
index: call.index ?? 0,
|
|
511
|
+
...(call.id ? { id: call.id } : {}),
|
|
512
|
+
type: 'function',
|
|
513
|
+
function: { ...(call.function?.name ? { name: call.function.name } : {}), arguments: call.function?.arguments ?? '' },
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function toOpenAIMessage(message) {
|
|
517
|
+
if (typeof message.content === 'string' || message.content === null) {
|
|
518
|
+
return {
|
|
519
|
+
role: message.role,
|
|
520
|
+
content: message.content,
|
|
521
|
+
...(message.toolCalls?.length
|
|
522
|
+
? { tool_calls: message.toolCalls.map((call) => ({ id: call.id, type: 'function', function: { name: call.function.name, arguments: call.function.arguments } })) }
|
|
523
|
+
: {}),
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
role: message.role,
|
|
528
|
+
content: message.content.map((part) => (part.type === 'text' ? { type: 'text', text: part.text } : { type: 'image_url', image_url: { url: part.imageUrl.url } })),
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function toOpenAITool(tool) {
|
|
532
|
+
return { type: 'function', function: { name: tool.name, ...(tool.description ? { description: tool.description } : {}), parameters: tool.parameters } };
|
|
533
|
+
}
|
|
534
|
+
function invalidResponse(providerId, message) {
|
|
535
|
+
return new ProviderError('INVALID_RESPONSE', message, { providerId });
|
|
536
|
+
}
|
|
537
|
+
//# sourceMappingURL=kimi-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi-code.js","sourceRoot":"","sources":["../../src/adapters/kimi-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAsB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAGjI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,0CAA0C;IAC1C,MAAM,EAAE,sBAAsB;IAC9B,4FAA4F;IAC5F,UAAU,EAAE,uBAAuB;IACnC,+DAA+D;IAC/D,SAAS,EAAE,sBAAsB;IACjC;;;;;OAKG;IACH,QAAQ,EAAE,sCAAsC;IAChD,cAAc,EAAE,iCAAiC;IACjD,eAAe,EAAE,kBAAkB;IACnC,QAAQ,EAAE,6BAA6B;IACvC,UAAU,EAAE,mBAAmB;IAC/B,cAAc,EAAE,uBAAuB;IACvC,SAAS,EAAE,8CAA8C;IACzD,gBAAgB,EAAE,eAAe;CACzB,CAAC;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AA6D9C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,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;KAClK,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,IAAoB;IACxC,OAAO,EAAE,IAAI,EAAE,UAAmB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;AACnK,CAAC;AAED,SAAS,eAAe,CAAC,UAAkB,EAAE,OAAe;IAC1D,OAAO,IAAI,aAAa,CAAC,kBAAkB,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './pricing.js';
|
|
|
14
14
|
export * from './modelFilters.js';
|
|
15
15
|
export * from './adapters/zen.js';
|
|
16
16
|
export * from './adapters/opencode-console.js';
|
|
17
|
+
export * from './adapters/kimi-code.js';
|
|
17
18
|
export * from './adapters/kiro.js';
|
|
18
19
|
export * from './adapters/chatgpt-web.js';
|
|
19
20
|
export * from './adapters/deepseek-pow.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './pricing.js';
|
|
|
14
14
|
export * from './modelFilters.js';
|
|
15
15
|
export * from './adapters/zen.js';
|
|
16
16
|
export * from './adapters/opencode-console.js';
|
|
17
|
+
export * from './adapters/kimi-code.js';
|
|
17
18
|
export * from './adapters/kiro.js';
|
|
18
19
|
export * from './adapters/chatgpt-web.js';
|
|
19
20
|
export * from './adapters/deepseek-pow.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hilbras/omnihilbras",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.71.0",
|
|
4
4
|
"description": "Typed provider SDK for the OmniHilbras gateway: normalized chat, streaming, model listing, and capability contracts for OpenAI, Anthropic, Gemini, and OpenAI-compatible providers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hilbras",
|