@ai-accounts/ts-core 0.3.8 → 0.3.9
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/index.cjs +27 -2
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +27 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -190,17 +190,26 @@ async function toError(r) {
|
|
|
190
190
|
}
|
|
191
191
|
var AiAccountsClient = class {
|
|
192
192
|
baseUrl;
|
|
193
|
-
|
|
193
|
+
_resolveToken;
|
|
194
194
|
_fetch;
|
|
195
195
|
constructor(opts) {
|
|
196
196
|
this.baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
197
|
-
|
|
197
|
+
if (typeof opts.token === "function") {
|
|
198
|
+
this._resolveToken = opts.token;
|
|
199
|
+
} else {
|
|
200
|
+
const captured = opts.token;
|
|
201
|
+
this._resolveToken = () => captured;
|
|
202
|
+
}
|
|
198
203
|
if (opts.fetch) {
|
|
199
204
|
this._fetch = opts.fetch;
|
|
200
205
|
} else {
|
|
201
206
|
this._fetch = (input, init) => fetch(input, init);
|
|
202
207
|
}
|
|
203
208
|
}
|
|
209
|
+
get token() {
|
|
210
|
+
const t = this._resolveToken();
|
|
211
|
+
return t == null ? void 0 : t;
|
|
212
|
+
}
|
|
204
213
|
headers() {
|
|
205
214
|
const h = { "content-type": "application/json" };
|
|
206
215
|
if (this.token) h["authorization"] = `Bearer ${this.token}`;
|
|
@@ -330,6 +339,14 @@ var AiAccountsClient = class {
|
|
|
330
339
|
if (!r.ok) throw await toError(r);
|
|
331
340
|
yield* parseSseLoginEvents(r);
|
|
332
341
|
}
|
|
342
|
+
async listModels(backendId) {
|
|
343
|
+
const r = await this._fetch(
|
|
344
|
+
`${this.baseUrl}/api/v1/backends/${encodeURIComponent(backendId)}/models/`,
|
|
345
|
+
{ method: "GET", headers: this.headers() }
|
|
346
|
+
);
|
|
347
|
+
if (!r.ok) throw await toError(r);
|
|
348
|
+
return await r.json();
|
|
349
|
+
}
|
|
333
350
|
async getBackendMetadata() {
|
|
334
351
|
const r = await this._fetch(`${this.baseUrl}/api/v1/backends/_meta`, {
|
|
335
352
|
headers: this.headers()
|
|
@@ -424,6 +441,14 @@ var AiAccountsClient = class {
|
|
|
424
441
|
if (!r.ok) throw await toError(r);
|
|
425
442
|
return await r.json();
|
|
426
443
|
}
|
|
444
|
+
async cliproxyLoginStatus(sessionId) {
|
|
445
|
+
const r = await this._fetch(
|
|
446
|
+
`${this.baseUrl}/api/v1/cliproxy/login/status?session_id=${encodeURIComponent(sessionId)}`,
|
|
447
|
+
{ method: "GET", headers: this.headers() }
|
|
448
|
+
);
|
|
449
|
+
if (!r.ok) throw await toError(r);
|
|
450
|
+
return await r.json();
|
|
451
|
+
}
|
|
427
452
|
// --- CLIProxyAPI Server Lifecycle ---
|
|
428
453
|
async cliproxyServerStart(port = 8317, apiKey = "not-needed") {
|
|
429
454
|
const r = await this._fetch(`${this.baseUrl}/api/v1/cliproxy/server/start`, {
|
package/dist/index.d.cts
CHANGED
|
@@ -123,10 +123,16 @@ interface SynthesisState {
|
|
|
123
123
|
backendsCollected: string[];
|
|
124
124
|
error?: string;
|
|
125
125
|
}
|
|
126
|
+
interface BackendAccountOption {
|
|
127
|
+
/** Backend id (e.g. "bkd-…") — what gets sent as account_id. */
|
|
128
|
+
id: string;
|
|
129
|
+
/** Human-friendly label (display_name / email) — what the user sees. */
|
|
130
|
+
label: string;
|
|
131
|
+
}
|
|
126
132
|
interface BackendOption {
|
|
127
133
|
kind: string;
|
|
128
134
|
displayName: string;
|
|
129
|
-
accounts:
|
|
135
|
+
accounts: BackendAccountOption[];
|
|
130
136
|
models: string[];
|
|
131
137
|
}
|
|
132
138
|
type ProcessGroupType = 'tool_call' | 'reasoning' | 'code_execution';
|
|
@@ -151,17 +157,25 @@ type SmartChatEvent = _WithSeq<{
|
|
|
151
157
|
} | {
|
|
152
158
|
kind: 'backend_delta';
|
|
153
159
|
backend: string;
|
|
160
|
+
backend_kind?: string | null;
|
|
161
|
+
account_label?: string | null;
|
|
154
162
|
text: string;
|
|
155
163
|
} | {
|
|
156
164
|
kind: 'backend_complete';
|
|
157
165
|
backend: string;
|
|
166
|
+
backend_kind?: string | null;
|
|
167
|
+
account_label?: string | null;
|
|
158
168
|
} | {
|
|
159
169
|
kind: 'backend_error';
|
|
160
170
|
backend: string;
|
|
171
|
+
backend_kind?: string | null;
|
|
172
|
+
account_label?: string | null;
|
|
161
173
|
error: string;
|
|
162
174
|
} | {
|
|
163
175
|
kind: 'backend_timeout';
|
|
164
176
|
backend: string;
|
|
177
|
+
backend_kind?: string | null;
|
|
178
|
+
account_label?: string | null;
|
|
165
179
|
} | {
|
|
166
180
|
kind: 'synthesis_start';
|
|
167
181
|
primary_backend: string;
|
|
@@ -256,11 +270,17 @@ type CliproxyLoginBeginResponse = {
|
|
|
256
270
|
message: string;
|
|
257
271
|
oauth_url?: string | null;
|
|
258
272
|
device_code?: string | null;
|
|
273
|
+
session_id?: string | null;
|
|
259
274
|
};
|
|
260
275
|
type CliproxyCallbackForwardResponse = {
|
|
261
276
|
status: 'completed' | 'error';
|
|
262
277
|
message: string;
|
|
263
278
|
};
|
|
279
|
+
type CliproxyLoginStatus = {
|
|
280
|
+
state: 'running' | 'completed' | 'failed' | 'timeout' | 'unknown';
|
|
281
|
+
message: string;
|
|
282
|
+
returncode?: number | null;
|
|
283
|
+
};
|
|
264
284
|
|
|
265
285
|
interface ChatSessionDTO {
|
|
266
286
|
id: string;
|
|
@@ -1300,7 +1320,16 @@ interface DetectResultsDTO {
|
|
|
1300
1320
|
}
|
|
1301
1321
|
interface ClientOptions {
|
|
1302
1322
|
baseUrl: string;
|
|
1303
|
-
|
|
1323
|
+
/**
|
|
1324
|
+
* Bearer token sent on every authenticated request. May be a string
|
|
1325
|
+
* (captured once) or a getter (re-read per request). Use the getter
|
|
1326
|
+
* form when the token is sourced from a place that can change after
|
|
1327
|
+
* the client is constructed — e.g. ``localStorage`` after the user
|
|
1328
|
+
* generates an admin key on the welcome page; capturing at
|
|
1329
|
+
* construction would leave the client permanently unauthenticated
|
|
1330
|
+
* because the key didn't exist yet when the Vue app booted.
|
|
1331
|
+
*/
|
|
1332
|
+
token?: string | (() => string | undefined | null);
|
|
1304
1333
|
fetch?: typeof fetch;
|
|
1305
1334
|
}
|
|
1306
1335
|
interface ApiError extends Error {
|
|
@@ -1309,9 +1338,10 @@ interface ApiError extends Error {
|
|
|
1309
1338
|
}
|
|
1310
1339
|
declare class AiAccountsClient {
|
|
1311
1340
|
private readonly baseUrl;
|
|
1312
|
-
private readonly
|
|
1341
|
+
private readonly _resolveToken;
|
|
1313
1342
|
private readonly _fetch;
|
|
1314
1343
|
constructor(opts: ClientOptions);
|
|
1344
|
+
private get token();
|
|
1315
1345
|
private headers;
|
|
1316
1346
|
listBackends(): Promise<{
|
|
1317
1347
|
items: BackendDTO[];
|
|
@@ -1345,6 +1375,13 @@ declare class AiAccountsClient {
|
|
|
1345
1375
|
writeEagerLogin(accountId: string, sessionId: string, text: string): Promise<void>;
|
|
1346
1376
|
cancelLogin(accountId: string, sessionId: string): Promise<void>;
|
|
1347
1377
|
streamLogin(accountId: string, sessionId: string): AsyncIterable<LoginEvent>;
|
|
1378
|
+
listModels(backendId: string): Promise<{
|
|
1379
|
+
items: Array<{
|
|
1380
|
+
id: string;
|
|
1381
|
+
display_name: string;
|
|
1382
|
+
context_window: number | null;
|
|
1383
|
+
}>;
|
|
1384
|
+
}>;
|
|
1348
1385
|
getBackendMetadata(): Promise<{
|
|
1349
1386
|
items: BackendMetadata[];
|
|
1350
1387
|
}>;
|
|
@@ -1360,6 +1397,7 @@ declare class AiAccountsClient {
|
|
|
1360
1397
|
cliproxyInstall(): Promise<CliproxyInstallResult>;
|
|
1361
1398
|
cliproxyLoginBegin(backendKind: string, configDir?: string): Promise<CliproxyLoginBeginResponse>;
|
|
1362
1399
|
cliproxyCallbackForward(callbackUrl: string): Promise<CliproxyCallbackForwardResponse>;
|
|
1400
|
+
cliproxyLoginStatus(sessionId: string): Promise<CliproxyLoginStatus>;
|
|
1363
1401
|
cliproxyServerStart(port?: number, apiKey?: string): Promise<{
|
|
1364
1402
|
status: string;
|
|
1365
1403
|
port: number;
|
|
@@ -1524,4 +1562,4 @@ declare function createOnboardingFlow(opts: CreateOnboardingFlowOptions): Onboar
|
|
|
1524
1562
|
|
|
1525
1563
|
declare const version = "0.0.0";
|
|
1526
1564
|
|
|
1527
|
-
export { type AccountHealthDTO, type AccountWizard, type paths as AiAccountsApiPaths, AiAccountsClient, type AiAccountsEvent, type AiAccountsEventHandler, type ApiError, type BackendDTO, type BackendMetadata, type BackendOption, type BackendResponse, type ChatDelta, type ChatDoneEvent, type ChatMessageDTO, type ChatMode, type ChatSessionDTO, type ChatSessionDetailDTO, type ChatTokenEvent, type ChatToolCallEvent, type ClientOptions, type CliproxyCallbackForwardResponse, type CliproxyInstallResult, type CliproxyLoginBeginResponse, type CliproxyStatus, type CreateAccountWizardOptions, type CreateOnboardingFlowOptions, type DetectResultDTO, type DetectResultsDTO, type ErrorEvent, type FallbackChainEntryDTO, type InputSpec, type InstallCheck, type InstallResult, type LoginComplete, type LoginEvent, type LoginFailed, type LoginFlowKind, type LoginFlowSpec, type LoginResponseDTO, type MenuOptionDTO, type MenuPrompt, type OAuthDeviceLoginDTO, type OnboardingFlowMachine, type OnboardingMachineState, type OnboardingStateDTO, type PickResultDTO, type PlanOption, type ProcessGroupType, type ProgressUpdate, type PromptAnswer, type PtyExitEvent, type PtyOutputEvent, type PtyResizeEvent, type PtySessionDTO, PtySocket, type PtySocketOptions, type PtySpawnRequest, type SendChatRequest, type SessionEndEvent, type SessionStartEvent, type SmartChatEvent, type StdoutChunk, type SynthesisState, type TextPrompt, type ToolCallDelta, type UrlPrompt, type UsageWindowDTO, WIRE_PROTOCOL_VERSION, type WireEvent, type WizardState, createAccountWizard, createOnboardingFlow, version };
|
|
1565
|
+
export { type AccountHealthDTO, type AccountWizard, type paths as AiAccountsApiPaths, AiAccountsClient, type AiAccountsEvent, type AiAccountsEventHandler, type ApiError, type BackendAccountOption, type BackendDTO, type BackendMetadata, type BackendOption, type BackendResponse, type ChatDelta, type ChatDoneEvent, type ChatMessageDTO, type ChatMode, type ChatSessionDTO, type ChatSessionDetailDTO, type ChatTokenEvent, type ChatToolCallEvent, type ClientOptions, type CliproxyCallbackForwardResponse, type CliproxyInstallResult, type CliproxyLoginBeginResponse, type CliproxyLoginStatus, type CliproxyStatus, type CreateAccountWizardOptions, type CreateOnboardingFlowOptions, type DetectResultDTO, type DetectResultsDTO, type ErrorEvent, type FallbackChainEntryDTO, type InputSpec, type InstallCheck, type InstallResult, type LoginComplete, type LoginEvent, type LoginFailed, type LoginFlowKind, type LoginFlowSpec, type LoginResponseDTO, type MenuOptionDTO, type MenuPrompt, type OAuthDeviceLoginDTO, type OnboardingFlowMachine, type OnboardingMachineState, type OnboardingStateDTO, type PickResultDTO, type PlanOption, type ProcessGroupType, type ProgressUpdate, type PromptAnswer, type PtyExitEvent, type PtyOutputEvent, type PtyResizeEvent, type PtySessionDTO, PtySocket, type PtySocketOptions, type PtySpawnRequest, type SendChatRequest, type SessionEndEvent, type SessionStartEvent, type SmartChatEvent, type StdoutChunk, type SynthesisState, type TextPrompt, type ToolCallDelta, type UrlPrompt, type UsageWindowDTO, WIRE_PROTOCOL_VERSION, type WireEvent, type WizardState, createAccountWizard, createOnboardingFlow, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -123,10 +123,16 @@ interface SynthesisState {
|
|
|
123
123
|
backendsCollected: string[];
|
|
124
124
|
error?: string;
|
|
125
125
|
}
|
|
126
|
+
interface BackendAccountOption {
|
|
127
|
+
/** Backend id (e.g. "bkd-…") — what gets sent as account_id. */
|
|
128
|
+
id: string;
|
|
129
|
+
/** Human-friendly label (display_name / email) — what the user sees. */
|
|
130
|
+
label: string;
|
|
131
|
+
}
|
|
126
132
|
interface BackendOption {
|
|
127
133
|
kind: string;
|
|
128
134
|
displayName: string;
|
|
129
|
-
accounts:
|
|
135
|
+
accounts: BackendAccountOption[];
|
|
130
136
|
models: string[];
|
|
131
137
|
}
|
|
132
138
|
type ProcessGroupType = 'tool_call' | 'reasoning' | 'code_execution';
|
|
@@ -151,17 +157,25 @@ type SmartChatEvent = _WithSeq<{
|
|
|
151
157
|
} | {
|
|
152
158
|
kind: 'backend_delta';
|
|
153
159
|
backend: string;
|
|
160
|
+
backend_kind?: string | null;
|
|
161
|
+
account_label?: string | null;
|
|
154
162
|
text: string;
|
|
155
163
|
} | {
|
|
156
164
|
kind: 'backend_complete';
|
|
157
165
|
backend: string;
|
|
166
|
+
backend_kind?: string | null;
|
|
167
|
+
account_label?: string | null;
|
|
158
168
|
} | {
|
|
159
169
|
kind: 'backend_error';
|
|
160
170
|
backend: string;
|
|
171
|
+
backend_kind?: string | null;
|
|
172
|
+
account_label?: string | null;
|
|
161
173
|
error: string;
|
|
162
174
|
} | {
|
|
163
175
|
kind: 'backend_timeout';
|
|
164
176
|
backend: string;
|
|
177
|
+
backend_kind?: string | null;
|
|
178
|
+
account_label?: string | null;
|
|
165
179
|
} | {
|
|
166
180
|
kind: 'synthesis_start';
|
|
167
181
|
primary_backend: string;
|
|
@@ -256,11 +270,17 @@ type CliproxyLoginBeginResponse = {
|
|
|
256
270
|
message: string;
|
|
257
271
|
oauth_url?: string | null;
|
|
258
272
|
device_code?: string | null;
|
|
273
|
+
session_id?: string | null;
|
|
259
274
|
};
|
|
260
275
|
type CliproxyCallbackForwardResponse = {
|
|
261
276
|
status: 'completed' | 'error';
|
|
262
277
|
message: string;
|
|
263
278
|
};
|
|
279
|
+
type CliproxyLoginStatus = {
|
|
280
|
+
state: 'running' | 'completed' | 'failed' | 'timeout' | 'unknown';
|
|
281
|
+
message: string;
|
|
282
|
+
returncode?: number | null;
|
|
283
|
+
};
|
|
264
284
|
|
|
265
285
|
interface ChatSessionDTO {
|
|
266
286
|
id: string;
|
|
@@ -1300,7 +1320,16 @@ interface DetectResultsDTO {
|
|
|
1300
1320
|
}
|
|
1301
1321
|
interface ClientOptions {
|
|
1302
1322
|
baseUrl: string;
|
|
1303
|
-
|
|
1323
|
+
/**
|
|
1324
|
+
* Bearer token sent on every authenticated request. May be a string
|
|
1325
|
+
* (captured once) or a getter (re-read per request). Use the getter
|
|
1326
|
+
* form when the token is sourced from a place that can change after
|
|
1327
|
+
* the client is constructed — e.g. ``localStorage`` after the user
|
|
1328
|
+
* generates an admin key on the welcome page; capturing at
|
|
1329
|
+
* construction would leave the client permanently unauthenticated
|
|
1330
|
+
* because the key didn't exist yet when the Vue app booted.
|
|
1331
|
+
*/
|
|
1332
|
+
token?: string | (() => string | undefined | null);
|
|
1304
1333
|
fetch?: typeof fetch;
|
|
1305
1334
|
}
|
|
1306
1335
|
interface ApiError extends Error {
|
|
@@ -1309,9 +1338,10 @@ interface ApiError extends Error {
|
|
|
1309
1338
|
}
|
|
1310
1339
|
declare class AiAccountsClient {
|
|
1311
1340
|
private readonly baseUrl;
|
|
1312
|
-
private readonly
|
|
1341
|
+
private readonly _resolveToken;
|
|
1313
1342
|
private readonly _fetch;
|
|
1314
1343
|
constructor(opts: ClientOptions);
|
|
1344
|
+
private get token();
|
|
1315
1345
|
private headers;
|
|
1316
1346
|
listBackends(): Promise<{
|
|
1317
1347
|
items: BackendDTO[];
|
|
@@ -1345,6 +1375,13 @@ declare class AiAccountsClient {
|
|
|
1345
1375
|
writeEagerLogin(accountId: string, sessionId: string, text: string): Promise<void>;
|
|
1346
1376
|
cancelLogin(accountId: string, sessionId: string): Promise<void>;
|
|
1347
1377
|
streamLogin(accountId: string, sessionId: string): AsyncIterable<LoginEvent>;
|
|
1378
|
+
listModels(backendId: string): Promise<{
|
|
1379
|
+
items: Array<{
|
|
1380
|
+
id: string;
|
|
1381
|
+
display_name: string;
|
|
1382
|
+
context_window: number | null;
|
|
1383
|
+
}>;
|
|
1384
|
+
}>;
|
|
1348
1385
|
getBackendMetadata(): Promise<{
|
|
1349
1386
|
items: BackendMetadata[];
|
|
1350
1387
|
}>;
|
|
@@ -1360,6 +1397,7 @@ declare class AiAccountsClient {
|
|
|
1360
1397
|
cliproxyInstall(): Promise<CliproxyInstallResult>;
|
|
1361
1398
|
cliproxyLoginBegin(backendKind: string, configDir?: string): Promise<CliproxyLoginBeginResponse>;
|
|
1362
1399
|
cliproxyCallbackForward(callbackUrl: string): Promise<CliproxyCallbackForwardResponse>;
|
|
1400
|
+
cliproxyLoginStatus(sessionId: string): Promise<CliproxyLoginStatus>;
|
|
1363
1401
|
cliproxyServerStart(port?: number, apiKey?: string): Promise<{
|
|
1364
1402
|
status: string;
|
|
1365
1403
|
port: number;
|
|
@@ -1524,4 +1562,4 @@ declare function createOnboardingFlow(opts: CreateOnboardingFlowOptions): Onboar
|
|
|
1524
1562
|
|
|
1525
1563
|
declare const version = "0.0.0";
|
|
1526
1564
|
|
|
1527
|
-
export { type AccountHealthDTO, type AccountWizard, type paths as AiAccountsApiPaths, AiAccountsClient, type AiAccountsEvent, type AiAccountsEventHandler, type ApiError, type BackendDTO, type BackendMetadata, type BackendOption, type BackendResponse, type ChatDelta, type ChatDoneEvent, type ChatMessageDTO, type ChatMode, type ChatSessionDTO, type ChatSessionDetailDTO, type ChatTokenEvent, type ChatToolCallEvent, type ClientOptions, type CliproxyCallbackForwardResponse, type CliproxyInstallResult, type CliproxyLoginBeginResponse, type CliproxyStatus, type CreateAccountWizardOptions, type CreateOnboardingFlowOptions, type DetectResultDTO, type DetectResultsDTO, type ErrorEvent, type FallbackChainEntryDTO, type InputSpec, type InstallCheck, type InstallResult, type LoginComplete, type LoginEvent, type LoginFailed, type LoginFlowKind, type LoginFlowSpec, type LoginResponseDTO, type MenuOptionDTO, type MenuPrompt, type OAuthDeviceLoginDTO, type OnboardingFlowMachine, type OnboardingMachineState, type OnboardingStateDTO, type PickResultDTO, type PlanOption, type ProcessGroupType, type ProgressUpdate, type PromptAnswer, type PtyExitEvent, type PtyOutputEvent, type PtyResizeEvent, type PtySessionDTO, PtySocket, type PtySocketOptions, type PtySpawnRequest, type SendChatRequest, type SessionEndEvent, type SessionStartEvent, type SmartChatEvent, type StdoutChunk, type SynthesisState, type TextPrompt, type ToolCallDelta, type UrlPrompt, type UsageWindowDTO, WIRE_PROTOCOL_VERSION, type WireEvent, type WizardState, createAccountWizard, createOnboardingFlow, version };
|
|
1565
|
+
export { type AccountHealthDTO, type AccountWizard, type paths as AiAccountsApiPaths, AiAccountsClient, type AiAccountsEvent, type AiAccountsEventHandler, type ApiError, type BackendAccountOption, type BackendDTO, type BackendMetadata, type BackendOption, type BackendResponse, type ChatDelta, type ChatDoneEvent, type ChatMessageDTO, type ChatMode, type ChatSessionDTO, type ChatSessionDetailDTO, type ChatTokenEvent, type ChatToolCallEvent, type ClientOptions, type CliproxyCallbackForwardResponse, type CliproxyInstallResult, type CliproxyLoginBeginResponse, type CliproxyLoginStatus, type CliproxyStatus, type CreateAccountWizardOptions, type CreateOnboardingFlowOptions, type DetectResultDTO, type DetectResultsDTO, type ErrorEvent, type FallbackChainEntryDTO, type InputSpec, type InstallCheck, type InstallResult, type LoginComplete, type LoginEvent, type LoginFailed, type LoginFlowKind, type LoginFlowSpec, type LoginResponseDTO, type MenuOptionDTO, type MenuPrompt, type OAuthDeviceLoginDTO, type OnboardingFlowMachine, type OnboardingMachineState, type OnboardingStateDTO, type PickResultDTO, type PlanOption, type ProcessGroupType, type ProgressUpdate, type PromptAnswer, type PtyExitEvent, type PtyOutputEvent, type PtyResizeEvent, type PtySessionDTO, PtySocket, type PtySocketOptions, type PtySpawnRequest, type SendChatRequest, type SessionEndEvent, type SessionStartEvent, type SmartChatEvent, type StdoutChunk, type SynthesisState, type TextPrompt, type ToolCallDelta, type UrlPrompt, type UsageWindowDTO, WIRE_PROTOCOL_VERSION, type WireEvent, type WizardState, createAccountWizard, createOnboardingFlow, version };
|
package/dist/index.js
CHANGED
|
@@ -159,17 +159,26 @@ async function toError(r) {
|
|
|
159
159
|
}
|
|
160
160
|
var AiAccountsClient = class {
|
|
161
161
|
baseUrl;
|
|
162
|
-
|
|
162
|
+
_resolveToken;
|
|
163
163
|
_fetch;
|
|
164
164
|
constructor(opts) {
|
|
165
165
|
this.baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
166
|
-
|
|
166
|
+
if (typeof opts.token === "function") {
|
|
167
|
+
this._resolveToken = opts.token;
|
|
168
|
+
} else {
|
|
169
|
+
const captured = opts.token;
|
|
170
|
+
this._resolveToken = () => captured;
|
|
171
|
+
}
|
|
167
172
|
if (opts.fetch) {
|
|
168
173
|
this._fetch = opts.fetch;
|
|
169
174
|
} else {
|
|
170
175
|
this._fetch = (input, init) => fetch(input, init);
|
|
171
176
|
}
|
|
172
177
|
}
|
|
178
|
+
get token() {
|
|
179
|
+
const t = this._resolveToken();
|
|
180
|
+
return t == null ? void 0 : t;
|
|
181
|
+
}
|
|
173
182
|
headers() {
|
|
174
183
|
const h = { "content-type": "application/json" };
|
|
175
184
|
if (this.token) h["authorization"] = `Bearer ${this.token}`;
|
|
@@ -299,6 +308,14 @@ var AiAccountsClient = class {
|
|
|
299
308
|
if (!r.ok) throw await toError(r);
|
|
300
309
|
yield* parseSseLoginEvents(r);
|
|
301
310
|
}
|
|
311
|
+
async listModels(backendId) {
|
|
312
|
+
const r = await this._fetch(
|
|
313
|
+
`${this.baseUrl}/api/v1/backends/${encodeURIComponent(backendId)}/models/`,
|
|
314
|
+
{ method: "GET", headers: this.headers() }
|
|
315
|
+
);
|
|
316
|
+
if (!r.ok) throw await toError(r);
|
|
317
|
+
return await r.json();
|
|
318
|
+
}
|
|
302
319
|
async getBackendMetadata() {
|
|
303
320
|
const r = await this._fetch(`${this.baseUrl}/api/v1/backends/_meta`, {
|
|
304
321
|
headers: this.headers()
|
|
@@ -393,6 +410,14 @@ var AiAccountsClient = class {
|
|
|
393
410
|
if (!r.ok) throw await toError(r);
|
|
394
411
|
return await r.json();
|
|
395
412
|
}
|
|
413
|
+
async cliproxyLoginStatus(sessionId) {
|
|
414
|
+
const r = await this._fetch(
|
|
415
|
+
`${this.baseUrl}/api/v1/cliproxy/login/status?session_id=${encodeURIComponent(sessionId)}`,
|
|
416
|
+
{ method: "GET", headers: this.headers() }
|
|
417
|
+
);
|
|
418
|
+
if (!r.ok) throw await toError(r);
|
|
419
|
+
return await r.json();
|
|
420
|
+
}
|
|
396
421
|
// --- CLIProxyAPI Server Lifecycle ---
|
|
397
422
|
async cliproxyServerStart(port = 8317, apiKey = "not-needed") {
|
|
398
423
|
const r = await this._fetch(`${this.baseUrl}/api/v1/cliproxy/server/start`, {
|