dsh-qoder-connect 0.1.4 → 0.1.8
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.en.md +13 -0
- package/README.md +13 -0
- package/assets/7.png +0 -0
- package/lib/bin.js +1 -1
- package/lib/client.js +739 -5
- package/lib/index.d.ts +97 -4
- package/lib/index.js +508 -41
- package/lib/{variants-CSeJqJpR.js → variants-DE76gF0Y.js} +186 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -141,11 +141,13 @@ interface QoderProbeAction {
|
|
|
141
141
|
* All are writes, which is why they share this route's in-process key
|
|
142
142
|
* and loopback guards rather than the read-only status GET.
|
|
143
143
|
*/
|
|
144
|
-
action: 'probe' | 'clear' | 'refresh' | 'set-maximum-context-window';
|
|
144
|
+
action: 'probe' | 'clear' | 'refresh' | 'set-maximum-context-window' | 'clear-checkin-logs' | 'checkin' | 'set-models-enabled';
|
|
145
145
|
/** Target model id; required for `probe`. */
|
|
146
146
|
model?: string;
|
|
147
|
-
/** Requested value for `set-maximum-context-window`. */
|
|
147
|
+
/** Requested value for `set-maximum-context-window` or `set-models-enabled`. */
|
|
148
148
|
enabled?: boolean;
|
|
149
|
+
/** Target model ids for `set-models-enabled` (supports single, batch, or all). */
|
|
150
|
+
models?: readonly string[];
|
|
149
151
|
}
|
|
150
152
|
/**
|
|
151
153
|
* Where the models a card is currently showing came from.
|
|
@@ -246,6 +248,8 @@ type QoderWebStatus = {
|
|
|
246
248
|
probe?: QoderWebProbeSection;
|
|
247
249
|
/** Card preference selecting larger declared context windows. */
|
|
248
250
|
useMaximumContextWindow?: boolean;
|
|
251
|
+
/** Disabled model IDs (blacklist) for this variant. */
|
|
252
|
+
disabledModels?: readonly string[];
|
|
249
253
|
/**
|
|
250
254
|
* The last automatic job-token refresh the self-heal performed, epoch ms.
|
|
251
255
|
* Absent when no refresh has happened in this process. The card renders
|
|
@@ -259,6 +263,33 @@ type QoderWebStatus = {
|
|
|
259
263
|
* loopback guard); it is never persisted and rotates per process.
|
|
260
264
|
*/
|
|
261
265
|
probeKey?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Daily check-in status record for this variant.
|
|
268
|
+
*/
|
|
269
|
+
checkIn?: {
|
|
270
|
+
lastDate: string;
|
|
271
|
+
lastAt: number;
|
|
272
|
+
status: 'claimed' | 'already-claimed' | 'no-campaign' | 'error';
|
|
273
|
+
amount?: number | undefined;
|
|
274
|
+
message?: string | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* When the scheduler's timer is next due, epoch ms.
|
|
277
|
+
*
|
|
278
|
+
* A day already claimed goes deliberately quiet, so without this the
|
|
279
|
+
* card cannot tell "scheduled and waiting" from "no timer at all" —
|
|
280
|
+
* which is exactly the doubt a missing timer created.
|
|
281
|
+
*/
|
|
282
|
+
nextRunAt?: number | undefined;
|
|
283
|
+
logs?: readonly {
|
|
284
|
+
id: string;
|
|
285
|
+
date: string;
|
|
286
|
+
timestamp: number;
|
|
287
|
+
status: 'claimed' | 'already-claimed' | 'no-campaign' | 'error';
|
|
288
|
+
amount?: number | undefined;
|
|
289
|
+
campaignKey?: string | undefined;
|
|
290
|
+
message?: string | undefined;
|
|
291
|
+
}[] | undefined;
|
|
292
|
+
};
|
|
262
293
|
/**
|
|
263
294
|
* In-process key authorizing PAT writes, including clearing. Travels with
|
|
264
295
|
* the document for the same reason `probeKey` does.
|
|
@@ -518,9 +549,13 @@ declare class QoderCatalog {
|
|
|
518
549
|
private useMaximumContextWindow;
|
|
519
550
|
/** Per-model window overrides (model id → tokens); an override wins over the preference. */
|
|
520
551
|
private modelContextWindows;
|
|
552
|
+
/** Disabled model IDs (blacklist); disabled models are filtered out from current(). */
|
|
553
|
+
private disabledModels;
|
|
521
554
|
constructor(initial?: readonly QoderModelInfo[]);
|
|
522
|
-
/** Current entries; empty while the variant has no usable credential. */
|
|
555
|
+
/** Current entries; empty while the variant has no usable credential, excluding disabled models. */
|
|
523
556
|
current(): readonly QoderModelInfo[];
|
|
557
|
+
/** All configured entries including disabled ones; empty while the variant has no usable credential. */
|
|
558
|
+
all(): readonly QoderModelInfo[];
|
|
524
559
|
/** Replace the list; callers invalidate their adapter snapshot after this. */
|
|
525
560
|
set(models: readonly QoderModelInfo[]): void;
|
|
526
561
|
/** Whether this variant's models are exposed at all. */
|
|
@@ -537,6 +572,13 @@ declare class QoderCatalog {
|
|
|
537
572
|
* changed, so the caller can skip an invalidation over an identical write.
|
|
538
573
|
*/
|
|
539
574
|
setModelContextWindows(modelContextWindows: Readonly<Record<string, number>>): boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Replace the disabled model IDs wholesale. Returns whether the set
|
|
577
|
+
* changed, so the caller can skip an invalidation over an identical write.
|
|
578
|
+
*/
|
|
579
|
+
setDisabledModels(disabledModels: readonly string[]): boolean;
|
|
580
|
+
/** Current disabled model IDs. */
|
|
581
|
+
getDisabledModels(): readonly string[];
|
|
540
582
|
/**
|
|
541
583
|
* Models to fall back to when the upstream fetch fails; ignores
|
|
542
584
|
* visibility, because the caller asking for the fallback already knows the
|
|
@@ -647,6 +689,14 @@ interface QoderQuota {
|
|
|
647
689
|
interface QoderQuotaUsage {
|
|
648
690
|
userQuota?: QoderQuota | undefined;
|
|
649
691
|
orgResourcePackage?: QoderQuota | undefined;
|
|
692
|
+
/**
|
|
693
|
+
* Credits granted on top of the plan — the daily campaign's 100, for one.
|
|
694
|
+
*
|
|
695
|
+
* A separate bucket upstream reports beside `userQuota`; it carries its own
|
|
696
|
+
* total and remaining, so leaving it out made the card show fewer packages
|
|
697
|
+
* than the account actually holds (two on the web, one here).
|
|
698
|
+
*/
|
|
699
|
+
addOnQuota?: QoderQuota | undefined;
|
|
650
700
|
totalUsagePercentage?: number | undefined;
|
|
651
701
|
isQuotaExceeded?: boolean | undefined;
|
|
652
702
|
expiresAt?: string | undefined;
|
|
@@ -692,6 +742,17 @@ interface QoderAccountInfo {
|
|
|
692
742
|
updatedAt: string;
|
|
693
743
|
}
|
|
694
744
|
//#endregion
|
|
745
|
+
//#region src/qoder/transport/checkin.d.ts
|
|
746
|
+
interface QoderCheckInResult {
|
|
747
|
+
variantId: string;
|
|
748
|
+
date: string;
|
|
749
|
+
timestamp: number;
|
|
750
|
+
status: 'claimed' | 'already-claimed' | 'no-campaign' | 'error';
|
|
751
|
+
amount?: number | undefined;
|
|
752
|
+
campaignKey?: string | undefined;
|
|
753
|
+
message?: string | undefined;
|
|
754
|
+
}
|
|
755
|
+
//#endregion
|
|
695
756
|
//#region src/qoder/transport/index.d.ts
|
|
696
757
|
interface QoderTransport {
|
|
697
758
|
stream(options: GenerateOptions, model?: QoderCatalogModel): AsyncIterable<StreamChunk>;
|
|
@@ -700,6 +761,7 @@ interface QoderTransport {
|
|
|
700
761
|
force?: boolean | undefined;
|
|
701
762
|
signal?: AbortSignal | undefined;
|
|
702
763
|
}): Promise<QoderAccountInfo>;
|
|
764
|
+
checkIn(signal?: AbortSignal): Promise<QoderCheckInResult>;
|
|
703
765
|
}
|
|
704
766
|
//#endregion
|
|
705
767
|
//#region src/upstream.d.ts
|
|
@@ -840,6 +902,10 @@ declare class QoderUpstreamClient {
|
|
|
840
902
|
* account's "unlimited" state.
|
|
841
903
|
*/
|
|
842
904
|
fetchCredits(signal?: AbortSignal): Promise<QoderCredits>;
|
|
905
|
+
/**
|
|
906
|
+
* Run daily benefit check-in for this client's variant.
|
|
907
|
+
*/
|
|
908
|
+
checkIn(signal?: AbortSignal): Promise<QoderCheckInResult>;
|
|
843
909
|
/**
|
|
844
910
|
* Stream one translated chat-completions request.
|
|
845
911
|
*
|
|
@@ -1341,10 +1407,22 @@ interface Config {
|
|
|
1341
1407
|
modelContextWindows?: Record<string, number>;
|
|
1342
1408
|
/** The China variant's per-model overrides; see {@link Config.modelContextWindows}. */
|
|
1343
1409
|
modelContextWindowsCN?: Record<string, number>;
|
|
1410
|
+
/** Models disabled for the global variant (blacklist). */
|
|
1411
|
+
disabledModels?: string[];
|
|
1412
|
+
/** Models disabled for the China variant (blacklist). */
|
|
1413
|
+
disabledModelsCN?: string[];
|
|
1344
1414
|
/** Show the China variant's sidebar quota card. */
|
|
1345
1415
|
sidebarQuotaCN?: boolean;
|
|
1346
1416
|
/** Show the global variant's sidebar quota card. */
|
|
1347
1417
|
sidebarQuotaGlobal?: boolean;
|
|
1418
|
+
/** Automatically check in daily at 10:00 (UTC+8) to claim credits for China variant. */
|
|
1419
|
+
autoCheckInCN?: boolean;
|
|
1420
|
+
/** Automatically check in daily at 10:00 (UTC+8) to claim credits for Global variant. */
|
|
1421
|
+
autoCheckInGlobal?: boolean;
|
|
1422
|
+
/** When the China variant checks in, as minutes past midnight in UTC+8 (600 = 10:00). */
|
|
1423
|
+
checkInMinuteCN?: number;
|
|
1424
|
+
/** When the Global variant checks in, as minutes past midnight in UTC+8 (600 = 10:00). */
|
|
1425
|
+
checkInMinuteGlobal?: number;
|
|
1348
1426
|
/**
|
|
1349
1427
|
* Sidebar quota refresh interval in milliseconds. One shared value (both
|
|
1350
1428
|
* cards poll on it) because the two widgets hit the same rate-limited
|
|
@@ -1363,6 +1441,21 @@ interface Config {
|
|
|
1363
1441
|
declare const QUOTA_POLL_DEFAULT_MS = 300000;
|
|
1364
1442
|
declare const QUOTA_POLL_MIN_MS = 60000;
|
|
1365
1443
|
declare const Config: z<Config>;
|
|
1444
|
+
/**
|
|
1445
|
+
* Every field each settings section owns, and therefore every field the live
|
|
1446
|
+
* configuration has to carry through.
|
|
1447
|
+
*
|
|
1448
|
+
* One list per section, shared by the merge and by the test that pins it to
|
|
1449
|
+
* the schema. Writing the merge out by hand is what broke auto check-in: the
|
|
1450
|
+
* `qoder-quota` section grew four fields (`autoCheckInCN`, `autoCheckInGlobal`,
|
|
1451
|
+
* `checkInMinuteCN`, `checkInMinuteGlobal`) while the merge kept copying only
|
|
1452
|
+
* the three that predated them, so `current().autoCheckInCN` read `undefined`
|
|
1453
|
+
* forever and the scheduler saw the toggle as permanently off. The card saved
|
|
1454
|
+
* it, the file held it, and nothing ever acted on it.
|
|
1455
|
+
*/
|
|
1456
|
+
declare const CN_SECTION_KEYS: readonly ["probeConsent", "useMaximumContextWindowCN", "modelContextWindowsCN", "disabledModelsCN"];
|
|
1457
|
+
declare const GLOBAL_SECTION_KEYS: readonly ["useMaximumContextWindow", "modelContextWindows", "disabledModels"];
|
|
1458
|
+
declare const QUOTA_SECTION_KEYS: readonly ["sidebarQuotaCN", "sidebarQuotaGlobal", "autoCheckInCN", "autoCheckInGlobal", "checkInMinuteCN", "checkInMinuteGlobal", "quotaPollMs"];
|
|
1366
1459
|
/**
|
|
1367
1460
|
* Start both variants: their loopback endpoints, the `qoder` and
|
|
1368
1461
|
* `qoder-global` providers, their configuration cards, and their
|
|
@@ -1375,4 +1468,4 @@ declare const Config: z<Config>;
|
|
|
1375
1468
|
*/
|
|
1376
1469
|
declare function apply(ctx: Context, config: Config): void;
|
|
1377
1470
|
//#endregion
|
|
1378
|
-
export { CHINA_VARIANT, Config, FALLBACK_QODER_MODELS, GLOBAL_VARIANT, KIND_STATUS, PROBE_EFFORT_CANDIDATES, type ProbeAttempt, type ProbeOutcome, type ProbeSender, QODER_AUTH_FILENAME, QODER_AUTH_PATH, QODER_DATA_DIR_ENV, QODER_DATA_DIR_NAME, QODER_GLOBAL_AUTH_PATH, QODER_GLOBAL_PROBE_PATH, QODER_GLOBAL_SETTINGS_NS, QODER_GLOBAL_STATUS_PATH, QODER_HOST_HEARTBEAT_FILENAME, QODER_PAT_ENV_CN, QODER_PAT_ENV_GLOBAL, QODER_PROBE_FILENAME, QODER_PROBE_PATH, QODER_PROVIDER, QODER_QUOTA_SETTINGS_NS, QODER_SETTINGS_NS, QODER_STATUS_PATH, QODER_STREAM_IDLE_TIMEOUT_MS, QODER_VARIANTS, QUOTA_POLL_DEFAULT_MS, QUOTA_POLL_MIN_MS, type QoderAdapter, type QoderAuthRequest, type QoderAuthRouteOptions, type QoderAuthSaveResult, type QoderAuthStatus, QoderCatalog, type QoderCatalogFetch, type QoderCatalogModelSnapshot, QoderCatalogStore, type QoderCatalogStoreOptions, type QoderChatResult, type QoderCredential, QoderCredentialStore, type QoderCreditAccount, type QoderCredits, type QoderEffort, type QoderHostHeartbeat, type QoderModelBilling, type QoderModelInfo, type QoderModelReasoning, type QoderPatSummary, type QoderProbeAction, type QoderProbeRecord, QoderProbeService, type QoderProbeStatus, QoderProbeStore, type QoderProbeValidation, type QoderShim, QoderUpstreamClient, type QoderVariant, type QoderVariantId, type QoderWebCatalog, type QoderWebCreditAccount, type QoderWebCredits, type QoderWebProbeModel, type QoderWebProbeSection, type QoderWebStatus, type ShimLogger, type UpstreamErrorKind, apply, classifyUpstreamError, clearHostHeartbeat, createAuthKey, createQoderAdapter, createQoderShim, fingerprintModel, inject, isHeartbeatProcessAlive, kindFromQoderFailure, modelInfoOf, name, normalizeCredits, patTail, probeModel, processStartTimeMs, qoderAuthHandler, qoderCatalogPath, qoderCredentialIdentity, qoderHostHeartbeatPath, qoderOwnAuthPath, qoderPluginDataDir, qoderProbePath, randomSentinel, readHostHeartbeat, registerQoderAuthRoute, variantFor };
|
|
1471
|
+
export { CHINA_VARIANT, CN_SECTION_KEYS, Config, FALLBACK_QODER_MODELS, GLOBAL_SECTION_KEYS, GLOBAL_VARIANT, KIND_STATUS, PROBE_EFFORT_CANDIDATES, type ProbeAttempt, type ProbeOutcome, type ProbeSender, QODER_AUTH_FILENAME, QODER_AUTH_PATH, QODER_DATA_DIR_ENV, QODER_DATA_DIR_NAME, QODER_GLOBAL_AUTH_PATH, QODER_GLOBAL_PROBE_PATH, QODER_GLOBAL_SETTINGS_NS, QODER_GLOBAL_STATUS_PATH, QODER_HOST_HEARTBEAT_FILENAME, QODER_PAT_ENV_CN, QODER_PAT_ENV_GLOBAL, QODER_PROBE_FILENAME, QODER_PROBE_PATH, QODER_PROVIDER, QODER_QUOTA_SETTINGS_NS, QODER_SETTINGS_NS, QODER_STATUS_PATH, QODER_STREAM_IDLE_TIMEOUT_MS, QODER_VARIANTS, QUOTA_POLL_DEFAULT_MS, QUOTA_POLL_MIN_MS, QUOTA_SECTION_KEYS, type QoderAdapter, type QoderAuthRequest, type QoderAuthRouteOptions, type QoderAuthSaveResult, type QoderAuthStatus, QoderCatalog, type QoderCatalogFetch, type QoderCatalogModelSnapshot, QoderCatalogStore, type QoderCatalogStoreOptions, type QoderChatResult, type QoderCredential, QoderCredentialStore, type QoderCreditAccount, type QoderCredits, type QoderEffort, type QoderHostHeartbeat, type QoderModelBilling, type QoderModelInfo, type QoderModelReasoning, type QoderPatSummary, type QoderProbeAction, type QoderProbeRecord, QoderProbeService, type QoderProbeStatus, QoderProbeStore, type QoderProbeValidation, type QoderShim, QoderUpstreamClient, type QoderVariant, type QoderVariantId, type QoderWebCatalog, type QoderWebCreditAccount, type QoderWebCredits, type QoderWebProbeModel, type QoderWebProbeSection, type QoderWebStatus, type ShimLogger, type UpstreamErrorKind, apply, classifyUpstreamError, clearHostHeartbeat, createAuthKey, createQoderAdapter, createQoderShim, fingerprintModel, inject, isHeartbeatProcessAlive, kindFromQoderFailure, modelInfoOf, name, normalizeCredits, patTail, probeModel, processStartTimeMs, qoderAuthHandler, qoderCatalogPath, qoderCredentialIdentity, qoderHostHeartbeatPath, qoderOwnAuthPath, qoderPluginDataDir, qoderProbePath, randomSentinel, readHostHeartbeat, registerQoderAuthRoute, variantFor };
|