@redonvn/event-ws-cliproxyapi-sdk 1.0.4 → 1.0.6
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/README.md +258 -428
- package/dist/client.d.ts +19 -0
- package/dist/client.js +96 -0
- package/dist/codec.d.ts +8 -0
- package/dist/codec.js +79 -0
- package/dist/errors/index.d.ts +13 -0
- package/dist/errors/index.js +26 -0
- package/dist/http/client.d.ts +260 -0
- package/dist/http/client.js +591 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/http/types.d.ts +783 -0
- package/dist/http/types.js +1 -0
- package/dist/http-client.d.ts +259 -0
- package/dist/http-client.js +557 -0
- package/dist/http-types.d.ts +677 -0
- package/dist/http-types.js +1 -0
- package/dist/management/client.d.ts +2 -1
- package/dist/management/client.js +3 -0
- package/dist/management/index.d.ts +1 -1
- package/dist/shared/types.d.ts +3 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.js +1 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/index.js +2 -0
- package/dist/ws/client.js +7 -1
- package/dist/ws/types.d.ts +3 -0
- package/package.json +26 -23
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTTPRequest, ProviderEvent, ProviderOptions, WSRequestContext } from './types.js';
|
|
2
|
+
export interface ProviderHandlers {
|
|
3
|
+
onRequest: (req: HTTPRequest, ctx: WSRequestContext) => void | Promise<void>;
|
|
4
|
+
onEvent?: (ev: ProviderEvent) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class CliproxyWSProvider {
|
|
7
|
+
private ws?;
|
|
8
|
+
private options;
|
|
9
|
+
private handlers?;
|
|
10
|
+
constructor(options: ProviderOptions);
|
|
11
|
+
connect(handlers: ProviderHandlers): Promise<void>;
|
|
12
|
+
close(): void;
|
|
13
|
+
private handleMessage;
|
|
14
|
+
private handleClose;
|
|
15
|
+
private buildContext;
|
|
16
|
+
private sendMessage;
|
|
17
|
+
}
|
|
18
|
+
export declare class CliproxyWSClient extends CliproxyWSProvider {
|
|
19
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { decodeRequest, encodeChunk, encodeError, encodeResponse } from './codec.js';
|
|
3
|
+
export class CliproxyWSProvider {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
connect(handlers) {
|
|
8
|
+
this.handlers = handlers;
|
|
9
|
+
if (this.ws && this.ws.readyState === WebSocket.OPEN)
|
|
10
|
+
return Promise.resolve();
|
|
11
|
+
const base = this.options.baseUrl.replace(/\/+$/, '');
|
|
12
|
+
const url = `${base.replace(/^http/, 'ws')}/v1/ws`;
|
|
13
|
+
const headers = {};
|
|
14
|
+
if (this.options.accessKey)
|
|
15
|
+
headers['Authorization'] = `Bearer ${this.options.accessKey}`;
|
|
16
|
+
this.ws = new WebSocket(url, { headers });
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const ws = this.ws;
|
|
19
|
+
const onOpen = () => {
|
|
20
|
+
this.handlers?.onEvent?.({ type: 'ws:open' });
|
|
21
|
+
resolve();
|
|
22
|
+
};
|
|
23
|
+
const onErr = (err) => reject(err);
|
|
24
|
+
ws.once('open', onOpen);
|
|
25
|
+
ws.once('error', onErr);
|
|
26
|
+
ws.on('message', (raw) => this.handleMessage(raw.toString()));
|
|
27
|
+
ws.on('close', (code, reason) => this.handleClose(code, reason.toString()));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
close() {
|
|
31
|
+
this.ws?.close();
|
|
32
|
+
}
|
|
33
|
+
handleMessage(raw) {
|
|
34
|
+
let msg;
|
|
35
|
+
try {
|
|
36
|
+
msg = JSON.parse(raw);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!msg || !msg.id || !msg.type)
|
|
42
|
+
return;
|
|
43
|
+
if (msg.type === 'ping') {
|
|
44
|
+
this.sendMessage('pong', msg.id);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (msg.type !== 'http_request')
|
|
48
|
+
return;
|
|
49
|
+
const req = decodeRequest(msg.payload);
|
|
50
|
+
const ctx = this.buildContext(msg.id);
|
|
51
|
+
this.handlers?.onEvent?.({ type: 'request', requestId: msg.id, request: req });
|
|
52
|
+
try {
|
|
53
|
+
const result = this.handlers?.onRequest(req, ctx);
|
|
54
|
+
if (result && typeof result.then === 'function') {
|
|
55
|
+
result.catch((err) => {
|
|
56
|
+
ctx.error(err?.message ?? 'provider error');
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
ctx.error(err instanceof Error ? err.message : 'provider error');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
handleClose(code, reason) {
|
|
65
|
+
this.handlers?.onEvent?.({ type: 'ws:close', code, reason });
|
|
66
|
+
}
|
|
67
|
+
buildContext(requestId) {
|
|
68
|
+
return {
|
|
69
|
+
requestId,
|
|
70
|
+
respond: (resp) => {
|
|
71
|
+
this.sendMessage('http_response', requestId, encodeResponse(resp));
|
|
72
|
+
},
|
|
73
|
+
streamStart: (status, headers) => {
|
|
74
|
+
const payload = encodeResponse({ status: status ?? 200, headers, body: '' });
|
|
75
|
+
this.sendMessage('stream_start', requestId, payload);
|
|
76
|
+
},
|
|
77
|
+
streamChunk: (chunk) => {
|
|
78
|
+
this.sendMessage('stream_chunk', requestId, encodeChunk(chunk));
|
|
79
|
+
},
|
|
80
|
+
streamEnd: () => {
|
|
81
|
+
this.sendMessage('stream_end', requestId);
|
|
82
|
+
},
|
|
83
|
+
error: (message, status) => {
|
|
84
|
+
this.sendMessage('error', requestId, encodeError(message, status));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
sendMessage(type, id, payload) {
|
|
89
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
|
|
90
|
+
return;
|
|
91
|
+
const msg = (payload === undefined ? { id, type } : { id, type, payload });
|
|
92
|
+
this.ws.send(JSON.stringify(msg));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export class CliproxyWSClient extends CliproxyWSProvider {
|
|
96
|
+
}
|
package/dist/codec.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HTTPRequest, HTTPResponse, WSErrorPayload, WSHttpRequestPayload, WSHttpResponsePayload, WSStreamChunkPayload } from './types.js';
|
|
2
|
+
export declare function decodeRequest(payload?: WSHttpRequestPayload): HTTPRequest;
|
|
3
|
+
export declare function encodeResponse(resp: HTTPResponse): WSHttpResponsePayload;
|
|
4
|
+
export declare function decodeResponse(payload?: WSHttpResponsePayload): HTTPResponse;
|
|
5
|
+
export declare function encodeChunk(chunk: string): WSStreamChunkPayload;
|
|
6
|
+
export declare function decodeChunk(payload?: WSStreamChunkPayload): string;
|
|
7
|
+
export declare function encodeError(message: string, status?: number): WSErrorPayload;
|
|
8
|
+
export declare function decodeError(payload?: WSErrorPayload): string;
|
package/dist/codec.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export function decodeRequest(payload) {
|
|
2
|
+
const method = typeof payload?.method === 'string' ? payload.method : 'GET';
|
|
3
|
+
const url = typeof payload?.url === 'string' ? payload.url : '';
|
|
4
|
+
const rawHeaders = payload?.headers;
|
|
5
|
+
const headers = {};
|
|
6
|
+
if (rawHeaders) {
|
|
7
|
+
for (const [key, raw] of Object.entries(rawHeaders)) {
|
|
8
|
+
if (Array.isArray(raw)) {
|
|
9
|
+
headers[key] = raw.map(String);
|
|
10
|
+
}
|
|
11
|
+
else if (typeof raw === 'string') {
|
|
12
|
+
headers[key] = [raw];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const body = typeof payload?.body === 'string' ? payload.body : '';
|
|
17
|
+
const sent_at = typeof payload?.sent_at === 'string' ? payload.sent_at : undefined;
|
|
18
|
+
return { method, url, headers, body, sent_at };
|
|
19
|
+
}
|
|
20
|
+
export function encodeResponse(resp) {
|
|
21
|
+
const headers = {};
|
|
22
|
+
if (resp.headers) {
|
|
23
|
+
for (const [key, value] of Object.entries(resp.headers)) {
|
|
24
|
+
if (Array.isArray(value))
|
|
25
|
+
headers[key] = value.map(String);
|
|
26
|
+
else
|
|
27
|
+
headers[key] = [String(value)];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
status: resp.status ?? 200,
|
|
32
|
+
headers,
|
|
33
|
+
body: resp.body ?? ''
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function decodeResponse(payload) {
|
|
37
|
+
const status = typeof payload?.status === 'number'
|
|
38
|
+
? payload.status
|
|
39
|
+
: typeof payload?.status === 'string'
|
|
40
|
+
? Number(payload.status)
|
|
41
|
+
: 200;
|
|
42
|
+
const headers = {};
|
|
43
|
+
const rawHeaders = payload?.headers;
|
|
44
|
+
if (rawHeaders) {
|
|
45
|
+
for (const [key, raw] of Object.entries(rawHeaders)) {
|
|
46
|
+
if (Array.isArray(raw)) {
|
|
47
|
+
headers[key] = raw.map(String);
|
|
48
|
+
}
|
|
49
|
+
else if (typeof raw === 'string') {
|
|
50
|
+
headers[key] = raw;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const body = typeof payload?.body === 'string' ? payload.body : '';
|
|
55
|
+
return { status, headers, body };
|
|
56
|
+
}
|
|
57
|
+
export function encodeChunk(chunk) {
|
|
58
|
+
return { data: chunk ?? '' };
|
|
59
|
+
}
|
|
60
|
+
export function decodeChunk(payload) {
|
|
61
|
+
const data = payload?.data;
|
|
62
|
+
return typeof data === 'string' ? data : '';
|
|
63
|
+
}
|
|
64
|
+
export function encodeError(message, status) {
|
|
65
|
+
const payload = { error: message || 'wsrelay: upstream error' };
|
|
66
|
+
if (typeof status === 'number' && !Number.isNaN(status)) {
|
|
67
|
+
payload.status = status;
|
|
68
|
+
}
|
|
69
|
+
return payload;
|
|
70
|
+
}
|
|
71
|
+
export function decodeError(payload) {
|
|
72
|
+
const message = typeof payload?.error === 'string' ? payload.error : 'wsrelay: upstream error';
|
|
73
|
+
const status = typeof payload?.status === 'number'
|
|
74
|
+
? payload.status
|
|
75
|
+
: typeof payload?.status === 'string'
|
|
76
|
+
? Number(payload.status)
|
|
77
|
+
: 0;
|
|
78
|
+
return status ? `${message} (status=${status})` : message;
|
|
79
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OpenAIErrorResponse, ErrorResponse, StatusResponse, JsonObject } from '../http/types.js';
|
|
2
|
+
export type ManagementErrorResponse = ErrorResponse;
|
|
3
|
+
export type ApiErrorPayload = OpenAIErrorResponse | ManagementErrorResponse | StatusResponse | JsonObject | {
|
|
4
|
+
error: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class APIError extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly payload?: ApiErrorPayload;
|
|
9
|
+
constructor(message: string, status: number, payload?: ApiErrorPayload);
|
|
10
|
+
}
|
|
11
|
+
export declare function isOpenAIError(payload: unknown): payload is OpenAIErrorResponse;
|
|
12
|
+
export declare function isStatusError(payload: unknown): payload is StatusResponse;
|
|
13
|
+
export declare function isManagementError(payload: unknown): payload is ManagementErrorResponse;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class APIError extends Error {
|
|
2
|
+
constructor(message, status, payload) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'APIError';
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.payload = payload;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function isOpenAIError(payload) {
|
|
10
|
+
if (!payload || typeof payload !== 'object')
|
|
11
|
+
return false;
|
|
12
|
+
const obj = payload;
|
|
13
|
+
return !!obj.error && typeof obj.error.message === 'string' && typeof obj.error.type === 'string';
|
|
14
|
+
}
|
|
15
|
+
export function isStatusError(payload) {
|
|
16
|
+
if (!payload || typeof payload !== 'object')
|
|
17
|
+
return false;
|
|
18
|
+
const obj = payload;
|
|
19
|
+
return typeof obj.status === 'string' && (obj.status === 'error' || obj.status === 'wait' || obj.status === 'ok');
|
|
20
|
+
}
|
|
21
|
+
export function isManagementError(payload) {
|
|
22
|
+
if (!payload || typeof payload !== 'object')
|
|
23
|
+
return false;
|
|
24
|
+
const obj = payload;
|
|
25
|
+
return typeof obj.error === 'string';
|
|
26
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import type { AmpModelMapping, AmpModelMappingsPatch, AmpUpstreamAPIKeyEntry, AmpUpstreamAPIKeysPatch, ApiCallRequest, ApiCallResponse, AuthFileDeleteResponse, AuthFileListQuery, AuthFileListResponse, AuthFileModelsQuery, AuthFileModelsResponse, AuthFileStatusRequest, AuthFileStatusResponse, AuthStatusResponse, ClaudeKey, ClaudeKeyPatch, ClaudeMessagesRequest, CliproxyAuthsQuery, CliproxyAuthsResponse, CliproxyChatRequest, CliproxyModelsQuery, CliproxyModelsResponse, CodexKey, CodexKeyPatch, Config, DeleteLogsResponse, ErrorLogFilesResponse, GeminiCompatibleRequest, GeminiGenerateContentRequest, GeminiKey, GeminiKeyPatch, KeepAliveResponse, KeyedValueResponse, LogLinesResponse, ModelListResponse, OAuthCallbackRequest, OAuthCallbackResponse, OAuthExcludedModelsPatch, OAuthModelAlias, OAuthModelAliasPatch, OAuthStartResponse, OpenAIChatCompletionRequest, OpenAICompatibility, OpenAICompatPatch, OpenAICompletionRequest, OpenAIResponsesRequest, PatchByIndexOrMatch, PatchStringListRequest, RootResponse, UsageExportResponse, UsageGetResponse, UsageImportRequest, UsageImportResponse, VertexCompatKey, VertexCompatPatch } from './types.js';
|
|
2
|
+
export interface HttpClientOptions {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
accessKey?: string;
|
|
5
|
+
managementKey?: string;
|
|
6
|
+
localPassword?: string;
|
|
7
|
+
fetch?: typeof fetch;
|
|
8
|
+
}
|
|
9
|
+
export interface RequestOptions {
|
|
10
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export declare class CliproxyApiClient {
|
|
14
|
+
readonly baseUrl: string;
|
|
15
|
+
private accessKey?;
|
|
16
|
+
private managementKey?;
|
|
17
|
+
private localPassword?;
|
|
18
|
+
private fetchImpl;
|
|
19
|
+
constructor(options: HttpClientOptions);
|
|
20
|
+
setAccessKey(key?: string): void;
|
|
21
|
+
setManagementKey(key?: string): void;
|
|
22
|
+
setLocalPassword(value?: string): void;
|
|
23
|
+
private buildUrl;
|
|
24
|
+
private requestJson;
|
|
25
|
+
private requestText;
|
|
26
|
+
private requestRaw;
|
|
27
|
+
private applyAuth;
|
|
28
|
+
private throwApiError;
|
|
29
|
+
getWebsocketUrl(path?: string): string;
|
|
30
|
+
getRoot(): Promise<RootResponse>;
|
|
31
|
+
getManagementHtml(): Promise<Response>;
|
|
32
|
+
keepAlive(): Promise<KeepAliveResponse>;
|
|
33
|
+
anthropicCallback(query: {
|
|
34
|
+
code?: string;
|
|
35
|
+
state?: string;
|
|
36
|
+
error?: string;
|
|
37
|
+
error_description?: string;
|
|
38
|
+
}): Promise<Response>;
|
|
39
|
+
codexCallback(query: {
|
|
40
|
+
code?: string;
|
|
41
|
+
state?: string;
|
|
42
|
+
error?: string;
|
|
43
|
+
error_description?: string;
|
|
44
|
+
}): Promise<Response>;
|
|
45
|
+
googleCallback(query: {
|
|
46
|
+
code?: string;
|
|
47
|
+
state?: string;
|
|
48
|
+
error?: string;
|
|
49
|
+
error_description?: string;
|
|
50
|
+
}): Promise<Response>;
|
|
51
|
+
iflowCallback(query: {
|
|
52
|
+
code?: string;
|
|
53
|
+
state?: string;
|
|
54
|
+
error?: string;
|
|
55
|
+
error_description?: string;
|
|
56
|
+
}): Promise<Response>;
|
|
57
|
+
antigravityCallback(query: {
|
|
58
|
+
code?: string;
|
|
59
|
+
state?: string;
|
|
60
|
+
error?: string;
|
|
61
|
+
error_description?: string;
|
|
62
|
+
}): Promise<Response>;
|
|
63
|
+
postV1Internal(method: string, body: GeminiGenerateContentRequest, options?: RequestOptions): Promise<Response>;
|
|
64
|
+
getModels(): Promise<ModelListResponse>;
|
|
65
|
+
postChatCompletions(body: OpenAIChatCompletionRequest, options?: RequestOptions): Promise<Response>;
|
|
66
|
+
postCompletions(body: OpenAICompletionRequest, options?: RequestOptions): Promise<Response>;
|
|
67
|
+
postMessages(body: ClaudeMessagesRequest, options?: RequestOptions): Promise<Response>;
|
|
68
|
+
postMessagesCountTokens(body: ClaudeMessagesRequest, options?: RequestOptions): Promise<Response>;
|
|
69
|
+
postResponses(body: OpenAIResponsesRequest, options?: RequestOptions): Promise<Response>;
|
|
70
|
+
postResponsesCompact(body: OpenAIResponsesRequest, options?: RequestOptions): Promise<Response>;
|
|
71
|
+
getCliproxyAuths(query?: CliproxyAuthsQuery): Promise<CliproxyAuthsResponse>;
|
|
72
|
+
getCliproxyModels(query?: CliproxyModelsQuery): Promise<CliproxyModelsResponse>;
|
|
73
|
+
postCliproxyChat(body: CliproxyChatRequest, options?: RequestOptions): Promise<Response>;
|
|
74
|
+
getGeminiModels(options?: RequestOptions): Promise<Response>;
|
|
75
|
+
postGeminiModelsAction(action: string, body: GeminiCompatibleRequest, options?: RequestOptions): Promise<Response>;
|
|
76
|
+
getGeminiModelsAction(action: string, query?: Record<string, string | number | boolean | undefined>, options?: RequestOptions): Promise<Response>;
|
|
77
|
+
getUsage(): Promise<UsageGetResponse>;
|
|
78
|
+
exportUsage(): Promise<UsageExportResponse>;
|
|
79
|
+
importUsage(body: UsageImportRequest): Promise<UsageImportResponse>;
|
|
80
|
+
getConfig(): Promise<Config>;
|
|
81
|
+
getConfigYaml(): Promise<string>;
|
|
82
|
+
putConfigYaml(body: string): Promise<KeyedValueResponse<"status", "ok">>;
|
|
83
|
+
getLatestVersion(): Promise<KeyedValueResponse<"latest-version", string>>;
|
|
84
|
+
getDebug(): Promise<KeyedValueResponse<"debug", boolean>>;
|
|
85
|
+
putDebug(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
86
|
+
patchDebug(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
87
|
+
getLoggingToFile(): Promise<KeyedValueResponse<"logging-to-file", boolean>>;
|
|
88
|
+
putLoggingToFile(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
89
|
+
patchLoggingToFile(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
90
|
+
getLogsMaxTotalSizeMB(): Promise<KeyedValueResponse<"logs-max-total-size-mb", number>>;
|
|
91
|
+
putLogsMaxTotalSizeMB(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
92
|
+
patchLogsMaxTotalSizeMB(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
93
|
+
getErrorLogsMaxFiles(): Promise<KeyedValueResponse<"error-logs-max-files", number>>;
|
|
94
|
+
putErrorLogsMaxFiles(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
95
|
+
patchErrorLogsMaxFiles(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
96
|
+
getUsageStatisticsEnabled(): Promise<KeyedValueResponse<"usage-statistics-enabled", boolean>>;
|
|
97
|
+
putUsageStatisticsEnabled(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
98
|
+
patchUsageStatisticsEnabled(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
99
|
+
getProxyUrl(): Promise<KeyedValueResponse<"proxy-url", string>>;
|
|
100
|
+
putProxyUrl(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
101
|
+
patchProxyUrl(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
102
|
+
deleteProxyUrl(): Promise<KeyedValueResponse<"status", "ok">>;
|
|
103
|
+
apiCall(body: ApiCallRequest): Promise<ApiCallResponse>;
|
|
104
|
+
getSwitchProject(): Promise<KeyedValueResponse<"switch-project", boolean>>;
|
|
105
|
+
putSwitchProject(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
106
|
+
patchSwitchProject(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
107
|
+
getSwitchPreviewModel(): Promise<KeyedValueResponse<"switch-preview-model", boolean>>;
|
|
108
|
+
putSwitchPreviewModel(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
109
|
+
patchSwitchPreviewModel(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
110
|
+
getApiKeys(): Promise<KeyedValueResponse<"api-keys", string[]>>;
|
|
111
|
+
putApiKeys(body: string[] | {
|
|
112
|
+
items: string[];
|
|
113
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
114
|
+
patchApiKeys(body: PatchStringListRequest): Promise<KeyedValueResponse<"status", "ok">>;
|
|
115
|
+
deleteApiKeys(query?: {
|
|
116
|
+
index?: number;
|
|
117
|
+
value?: string;
|
|
118
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
119
|
+
getGeminiKeys(): Promise<KeyedValueResponse<"gemini-api-key", GeminiKey[]>>;
|
|
120
|
+
putGeminiKeys(body: GeminiKey[] | {
|
|
121
|
+
items: GeminiKey[];
|
|
122
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
123
|
+
patchGeminiKey(body: PatchByIndexOrMatch<GeminiKeyPatch>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
124
|
+
deleteGeminiKey(query?: {
|
|
125
|
+
'api-key'?: string;
|
|
126
|
+
index?: number;
|
|
127
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
128
|
+
getLogs(query?: {
|
|
129
|
+
limit?: number;
|
|
130
|
+
after?: number;
|
|
131
|
+
}): Promise<LogLinesResponse>;
|
|
132
|
+
deleteLogs(): Promise<DeleteLogsResponse>;
|
|
133
|
+
getRequestErrorLogs(): Promise<ErrorLogFilesResponse>;
|
|
134
|
+
downloadRequestErrorLog(name: string): Promise<Response>;
|
|
135
|
+
getRequestLogById(id: string): Promise<Response>;
|
|
136
|
+
getRequestLog(): Promise<KeyedValueResponse<"request-log", boolean>>;
|
|
137
|
+
putRequestLog(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
138
|
+
patchRequestLog(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
139
|
+
getWebsocketAuth(): Promise<KeyedValueResponse<"ws-auth", boolean>>;
|
|
140
|
+
putWebsocketAuth(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
141
|
+
patchWebsocketAuth(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
142
|
+
getAmpCode(): Promise<KeyedValueResponse<"ampcode", import("./types.js").AmpCodeConfig>>;
|
|
143
|
+
getAmpUpstreamUrl(): Promise<KeyedValueResponse<"upstream-url", string>>;
|
|
144
|
+
putAmpUpstreamUrl(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
145
|
+
patchAmpUpstreamUrl(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
146
|
+
deleteAmpUpstreamUrl(): Promise<KeyedValueResponse<"status", "ok">>;
|
|
147
|
+
getAmpUpstreamApiKey(): Promise<KeyedValueResponse<"upstream-api-key", string>>;
|
|
148
|
+
putAmpUpstreamApiKey(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
149
|
+
patchAmpUpstreamApiKey(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
150
|
+
deleteAmpUpstreamApiKey(): Promise<KeyedValueResponse<"status", "ok">>;
|
|
151
|
+
getAmpRestrictManagementToLocalhost(): Promise<KeyedValueResponse<"restrict-management-to-localhost", boolean>>;
|
|
152
|
+
putAmpRestrictManagementToLocalhost(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
153
|
+
patchAmpRestrictManagementToLocalhost(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
154
|
+
getAmpModelMappings(): Promise<KeyedValueResponse<"model-mappings", AmpModelMapping[]>>;
|
|
155
|
+
putAmpModelMappings(body: AmpModelMapping[] | AmpModelMappingsPatch): Promise<KeyedValueResponse<"status", "ok">>;
|
|
156
|
+
patchAmpModelMappings(body: AmpModelMappingsPatch): Promise<KeyedValueResponse<"status", "ok">>;
|
|
157
|
+
deleteAmpModelMappings(query?: {
|
|
158
|
+
index?: number;
|
|
159
|
+
match?: string;
|
|
160
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
161
|
+
getAmpForceModelMappings(): Promise<KeyedValueResponse<"force-model-mappings", boolean>>;
|
|
162
|
+
putAmpForceModelMappings(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
163
|
+
patchAmpForceModelMappings(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
164
|
+
getAmpUpstreamApiKeys(): Promise<KeyedValueResponse<"upstream-api-keys", AmpUpstreamAPIKeyEntry[]>>;
|
|
165
|
+
putAmpUpstreamApiKeys(body: AmpUpstreamAPIKeyEntry[] | AmpUpstreamAPIKeysPatch): Promise<KeyedValueResponse<"status", "ok">>;
|
|
166
|
+
patchAmpUpstreamApiKeys(body: AmpUpstreamAPIKeysPatch): Promise<KeyedValueResponse<"status", "ok">>;
|
|
167
|
+
deleteAmpUpstreamApiKeys(query?: {
|
|
168
|
+
index?: number;
|
|
169
|
+
match?: string;
|
|
170
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
171
|
+
getRequestRetry(): Promise<KeyedValueResponse<"request-retry", number>>;
|
|
172
|
+
putRequestRetry(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
173
|
+
patchRequestRetry(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
174
|
+
getMaxRetryInterval(): Promise<KeyedValueResponse<"max-retry-interval", number>>;
|
|
175
|
+
putMaxRetryInterval(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
176
|
+
patchMaxRetryInterval(body: KeyedValueResponse<'value', number>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
177
|
+
getForceModelPrefix(): Promise<KeyedValueResponse<"force-model-prefix", boolean>>;
|
|
178
|
+
putForceModelPrefix(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
179
|
+
patchForceModelPrefix(body: KeyedValueResponse<'value', boolean>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
180
|
+
getRoutingStrategy(): Promise<KeyedValueResponse<"strategy", string>>;
|
|
181
|
+
putRoutingStrategy(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
182
|
+
patchRoutingStrategy(body: KeyedValueResponse<'value', string>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
183
|
+
getClaudeKeys(): Promise<KeyedValueResponse<"claude-api-key", ClaudeKey[]>>;
|
|
184
|
+
putClaudeKeys(body: ClaudeKey[] | {
|
|
185
|
+
items: ClaudeKey[];
|
|
186
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
187
|
+
patchClaudeKey(body: PatchByIndexOrMatch<ClaudeKeyPatch>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
188
|
+
deleteClaudeKey(query?: {
|
|
189
|
+
'api-key'?: string;
|
|
190
|
+
index?: number;
|
|
191
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
192
|
+
getCodexKeys(): Promise<KeyedValueResponse<"codex-api-key", CodexKey[]>>;
|
|
193
|
+
putCodexKeys(body: CodexKey[] | {
|
|
194
|
+
items: CodexKey[];
|
|
195
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
196
|
+
patchCodexKey(body: PatchByIndexOrMatch<CodexKeyPatch>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
197
|
+
deleteCodexKey(query?: {
|
|
198
|
+
'api-key'?: string;
|
|
199
|
+
index?: number;
|
|
200
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
201
|
+
getOpenAICompatibility(): Promise<KeyedValueResponse<"openai-compatibility", OpenAICompatibility[]>>;
|
|
202
|
+
putOpenAICompatibility(body: OpenAICompatibility[] | {
|
|
203
|
+
items: OpenAICompatibility[];
|
|
204
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
205
|
+
patchOpenAICompatibility(body: PatchByIndexOrMatch<OpenAICompatPatch>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
206
|
+
deleteOpenAICompatibility(query?: {
|
|
207
|
+
name?: string;
|
|
208
|
+
index?: number;
|
|
209
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
210
|
+
getVertexCompatKeys(): Promise<KeyedValueResponse<"vertex-api-key", VertexCompatKey[]>>;
|
|
211
|
+
putVertexCompatKeys(body: VertexCompatKey[] | {
|
|
212
|
+
items: VertexCompatKey[];
|
|
213
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
214
|
+
patchVertexCompatKey(body: PatchByIndexOrMatch<VertexCompatPatch>): Promise<KeyedValueResponse<"status", "ok">>;
|
|
215
|
+
deleteVertexCompatKey(query?: {
|
|
216
|
+
'api-key'?: string;
|
|
217
|
+
index?: number;
|
|
218
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
219
|
+
getOAuthExcludedModels(): Promise<KeyedValueResponse<"oauth-excluded-models", Record<string, string[]>>>;
|
|
220
|
+
putOAuthExcludedModels(body: Record<string, string[]> | {
|
|
221
|
+
items: Record<string, string[]>;
|
|
222
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
223
|
+
patchOAuthExcludedModels(body: OAuthExcludedModelsPatch): Promise<KeyedValueResponse<"status", "ok">>;
|
|
224
|
+
deleteOAuthExcludedModels(query?: {
|
|
225
|
+
provider?: string;
|
|
226
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
227
|
+
getOAuthModelAlias(): Promise<KeyedValueResponse<"oauth-model-alias", Record<string, OAuthModelAlias[]>>>;
|
|
228
|
+
putOAuthModelAlias(body: Record<string, OAuthModelAlias[]> | {
|
|
229
|
+
items: Record<string, OAuthModelAlias[]>;
|
|
230
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
231
|
+
patchOAuthModelAlias(body: PatchByIndexOrMatch<OAuthModelAliasPatch> | OAuthModelAliasPatch): Promise<KeyedValueResponse<"status", "ok">>;
|
|
232
|
+
deleteOAuthModelAlias(query?: {
|
|
233
|
+
provider?: string;
|
|
234
|
+
channel?: string;
|
|
235
|
+
}): Promise<KeyedValueResponse<"status", "ok">>;
|
|
236
|
+
listAuthFiles(query?: AuthFileListQuery): Promise<AuthFileListResponse>;
|
|
237
|
+
getAuthFileModels(query: AuthFileModelsQuery): Promise<AuthFileModelsResponse>;
|
|
238
|
+
getStaticModelDefinitions(channel: string): Promise<Response>;
|
|
239
|
+
downloadAuthFile(query: {
|
|
240
|
+
name: string;
|
|
241
|
+
}): Promise<Response>;
|
|
242
|
+
uploadAuthFile(file: Blob, name?: string): Promise<Response>;
|
|
243
|
+
deleteAuthFile(query: {
|
|
244
|
+
name: string;
|
|
245
|
+
}): Promise<AuthFileDeleteResponse>;
|
|
246
|
+
patchAuthFileStatus(body: AuthFileStatusRequest): Promise<AuthFileStatusResponse>;
|
|
247
|
+
importVertexCredential(file: Blob): Promise<Response>;
|
|
248
|
+
requestAnthropicAuthUrl(): Promise<OAuthStartResponse>;
|
|
249
|
+
requestCodexAuthUrl(): Promise<OAuthStartResponse>;
|
|
250
|
+
requestGeminiCliAuthUrl(): Promise<OAuthStartResponse>;
|
|
251
|
+
requestAntigravityAuthUrl(): Promise<OAuthStartResponse>;
|
|
252
|
+
requestQwenAuthUrl(): Promise<OAuthStartResponse>;
|
|
253
|
+
requestKimiAuthUrl(): Promise<OAuthStartResponse>;
|
|
254
|
+
requestIFlowAuthUrl(): Promise<OAuthStartResponse>;
|
|
255
|
+
requestIFlowCookieToken(body: KeyedValueResponse<'cookie', string>): Promise<OAuthStartResponse>;
|
|
256
|
+
postOAuthCallback(body: OAuthCallbackRequest): Promise<OAuthCallbackResponse>;
|
|
257
|
+
getAuthStatus(query?: {
|
|
258
|
+
state?: string;
|
|
259
|
+
}): Promise<AuthStatusResponse>;
|
|
260
|
+
}
|