@mars-sea/dsh-commandcode-provider 0.10.3 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +63 -1
- package/README.zh-CN.md +63 -1
- package/lib/client.js +115 -28
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +219 -3
- package/lib/index.js +546 -22
- package/lib/index.js.map +1 -1
- package/package.json +4 -2
package/lib/index.d.ts
CHANGED
|
@@ -52,6 +52,16 @@ interface CommandCodeConnectionOptions {
|
|
|
52
52
|
* catalog regardless so the page can always offer every model.
|
|
53
53
|
*/
|
|
54
54
|
visibleModels?: string[] | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Per-model visibility overrides, keyed by catalog id. Written by the
|
|
57
|
+
* terminal settings page, whose checkbox list gives every model its own
|
|
58
|
+
* boolean field: a field writes one value at one path, so membership in
|
|
59
|
+
* {@link visibleModels} cannot be expressed from there, while a flag can.
|
|
60
|
+
* An id present here decides that model on its own (true = listed, false =
|
|
61
|
+
* hidden); an id absent here follows {@link visibleModels} exactly as it did
|
|
62
|
+
* before, so composition configs and the web page are unaffected.
|
|
63
|
+
*/
|
|
64
|
+
modelVisibility?: Readonly<Record<string, boolean>> | undefined;
|
|
55
65
|
/**
|
|
56
66
|
* Optional protocol hint. `'auto'` (default) uses billing/cache plus
|
|
57
67
|
* Provider API fallback; `'cli'` forces `/alpha/generate`; `'openai'`
|
|
@@ -441,7 +451,20 @@ declare class CommandCodeAccountPool {
|
|
|
441
451
|
* key until the stored credential changes.
|
|
442
452
|
*/
|
|
443
453
|
markRejected(apiKey: string, rejection: AccountRejection): void;
|
|
444
|
-
/**
|
|
454
|
+
/**
|
|
455
|
+
* One account's key: literal → credential seam → auth file (default slot).
|
|
456
|
+
*
|
|
457
|
+
* Every source is normalized here, at the single point where a slot's key
|
|
458
|
+
* enters the pool. The adapter sends the key through the harness's
|
|
459
|
+
* `assertUsableApiKey()`, which trims it — a stored key from the credentials
|
|
460
|
+
* seam, a `.env` line, or a shell export all pick up surrounding whitespace
|
|
461
|
+
* — and reports that trimmed form back to `markRejected()`. Returning the
|
|
462
|
+
* raw value would file every 429/401 mark under a key no later lookup can
|
|
463
|
+
* find: rotation would re-offer the same account, the account card would show
|
|
464
|
+
* no mark, and the usage endpoints would 401 while chat kept working.
|
|
465
|
+
* Normalizing once makes resolution, probing, marking, and the request path
|
|
466
|
+
* agree on one string.
|
|
467
|
+
*/
|
|
445
468
|
private resolveSlotKey;
|
|
446
469
|
/** Hand out the chosen account's key. */
|
|
447
470
|
private pick;
|
|
@@ -1022,6 +1045,14 @@ declare class CommandCodeLoginFlow {
|
|
|
1022
1045
|
private timer;
|
|
1023
1046
|
/** Settle hooks of the live attempt's callback promise. */
|
|
1024
1047
|
private settle;
|
|
1048
|
+
/**
|
|
1049
|
+
* Attempt generation. A delivered callback keeps validating the key
|
|
1050
|
+
* asynchronously (`complete()`), and that window is open to a cancel or a
|
|
1051
|
+
* fresh `begin()`; the generation lets a late completion recognize that it
|
|
1052
|
+
* no longer owns the status face and stop instead of storing a credential
|
|
1053
|
+
* the user cancelled and flipping the page back to success.
|
|
1054
|
+
*/
|
|
1055
|
+
private attemptSeq;
|
|
1025
1056
|
private disposed;
|
|
1026
1057
|
constructor(deps: CommandCodeLoginFlowDeps);
|
|
1027
1058
|
/** Subscribe to state transitions. @returns the disposer. */
|
|
@@ -1052,8 +1083,19 @@ declare class CommandCodeLoginFlow {
|
|
|
1052
1083
|
private handleCallback;
|
|
1053
1084
|
/** Answer a decisive callback, stop listening, and settle the attempt. */
|
|
1054
1085
|
private settleAttempt;
|
|
1055
|
-
/**
|
|
1086
|
+
/**
|
|
1087
|
+
* Post-validation completion: whoami check, then hand-off to storage.
|
|
1088
|
+
*
|
|
1089
|
+
* Every step re-checks {@link ownsAttempt} first: the whoami round-trip and
|
|
1090
|
+
* the credential write are awaits, and the user may cancel (or start another
|
|
1091
|
+
* attempt) while one is in flight. A completion that no longer owns the
|
|
1092
|
+
* attempt must not write the key or publish a status — otherwise cancel
|
|
1093
|
+
* would report "cancelled" while the credential landed anyway, and the page
|
|
1094
|
+
* would silently flip to success.
|
|
1095
|
+
*/
|
|
1056
1096
|
private complete;
|
|
1097
|
+
/** Whether one attempt still owns the status face (not cancelled, replaced, or disposed). */
|
|
1098
|
+
private ownsAttempt;
|
|
1057
1099
|
/** Map a tagged settle rejection onto the status face. */
|
|
1058
1100
|
private failFrom;
|
|
1059
1101
|
private clearTimer;
|
|
@@ -1154,6 +1196,171 @@ declare class CommandCodeSearchProvider implements WebSearchProvider {
|
|
|
1154
1196
|
private resolveKey;
|
|
1155
1197
|
}
|
|
1156
1198
|
//#endregion
|
|
1199
|
+
//#region src/tui-settings.d.ts
|
|
1200
|
+
/** Provider-owned translations for one title, label, or hint. */
|
|
1201
|
+
interface TuiLocalizedText {
|
|
1202
|
+
readonly zh?: string;
|
|
1203
|
+
readonly en?: string;
|
|
1204
|
+
}
|
|
1205
|
+
/** Control kinds the dsh-TUI settings screen knows how to render. */
|
|
1206
|
+
type TuiSettingsFieldKind = 'text' | 'number' | 'boolean' | 'select';
|
|
1207
|
+
/** One choice of an options-bearing field. */
|
|
1208
|
+
interface TuiSettingsFieldOption {
|
|
1209
|
+
/** Stored value. */
|
|
1210
|
+
readonly value: string;
|
|
1211
|
+
/** Display label (English; also the fallback). */
|
|
1212
|
+
readonly label: string;
|
|
1213
|
+
/** Provider-owned translations for the label. */
|
|
1214
|
+
readonly descriptions?: TuiLocalizedText;
|
|
1215
|
+
}
|
|
1216
|
+
/** The write one field's draft stages when the section is saved. */
|
|
1217
|
+
type TuiSettingsFieldWrite = {
|
|
1218
|
+
readonly kind: 'set';
|
|
1219
|
+
readonly value: unknown;
|
|
1220
|
+
} | {
|
|
1221
|
+
readonly kind: 'clear';
|
|
1222
|
+
};
|
|
1223
|
+
/** One editable field inside a section. */
|
|
1224
|
+
interface TuiSettingsField {
|
|
1225
|
+
/** Key path from the section root, in the settings service's `mutate` vocabulary. */
|
|
1226
|
+
readonly path: readonly string[];
|
|
1227
|
+
/** Short field label (English; also the fallback). */
|
|
1228
|
+
readonly label: string;
|
|
1229
|
+
/** Provider-owned translations for the label. */
|
|
1230
|
+
readonly descriptions?: TuiLocalizedText;
|
|
1231
|
+
/** Optional one-line help rendered under the field. */
|
|
1232
|
+
readonly hint?: string;
|
|
1233
|
+
/** Provider-owned translations for the hint. */
|
|
1234
|
+
readonly hintDescriptions?: TuiLocalizedText;
|
|
1235
|
+
/** Optional group id; grouped fields render on that group's subpage. */
|
|
1236
|
+
readonly group?: string;
|
|
1237
|
+
readonly kind: TuiSettingsFieldKind;
|
|
1238
|
+
/**
|
|
1239
|
+
* Choices for an options-bearing field. A `text` field that carries options
|
|
1240
|
+
* is the TUI's own "preset plus custom value" shape: `←`/`→` cycle the
|
|
1241
|
+
* presets while Enter opens the text editor.
|
|
1242
|
+
*/
|
|
1243
|
+
readonly options?: readonly TuiSettingsFieldOption[];
|
|
1244
|
+
/** Input placeholder for `kind: 'text' | 'number'`. */
|
|
1245
|
+
readonly placeholder?: string;
|
|
1246
|
+
/**
|
|
1247
|
+
* Credential control: the literal never rides the settings document — the
|
|
1248
|
+
* draft starts blank on every open, a blank draft writes nothing, and a
|
|
1249
|
+
* typed draft writes through the credentials seam under `ref`.
|
|
1250
|
+
*/
|
|
1251
|
+
readonly secret?: {
|
|
1252
|
+
readonly ref: string;
|
|
1253
|
+
};
|
|
1254
|
+
/** Render a stored value as draft text. */
|
|
1255
|
+
readonly format?: (value: unknown) => string;
|
|
1256
|
+
/** The write a draft text stages; `undefined` marks the draft invalid. */
|
|
1257
|
+
readonly parse?: (text: string) => TuiSettingsFieldWrite | undefined;
|
|
1258
|
+
}
|
|
1259
|
+
/** Optional navigation group inside one section. */
|
|
1260
|
+
interface TuiSettingsGroup {
|
|
1261
|
+
/** Stable identifier, unique inside the section. */
|
|
1262
|
+
readonly id: string;
|
|
1263
|
+
/** Group title (English; also the fallback). */
|
|
1264
|
+
readonly title: string;
|
|
1265
|
+
/** Provider-owned translations for the title. */
|
|
1266
|
+
readonly descriptions?: TuiLocalizedText;
|
|
1267
|
+
}
|
|
1268
|
+
/** One plugin's section inside the dsh-TUI settings screen. */
|
|
1269
|
+
interface TuiSettingsSection {
|
|
1270
|
+
/** Settings namespace this section edits. */
|
|
1271
|
+
readonly ns: string;
|
|
1272
|
+
/** Section title (English; also the fallback). */
|
|
1273
|
+
readonly title: string;
|
|
1274
|
+
/** Provider-owned translations for the title. */
|
|
1275
|
+
readonly descriptions?: TuiLocalizedText;
|
|
1276
|
+
/** Optional navigation groups, in display order. */
|
|
1277
|
+
readonly groups?: readonly TuiSettingsGroup[];
|
|
1278
|
+
/** Editable fields, in display order. */
|
|
1279
|
+
readonly fields: readonly TuiSettingsField[];
|
|
1280
|
+
}
|
|
1281
|
+
/** The slice of the `tuiSettingsSections` service this module uses. */
|
|
1282
|
+
interface TuiSettingsSectionsService {
|
|
1283
|
+
/** Declare a section; the returned disposer withdraws it. */
|
|
1284
|
+
register(section: TuiSettingsSection): () => void;
|
|
1285
|
+
}
|
|
1286
|
+
/** The selector value meaning "no pinned account — follow rotation order". */
|
|
1287
|
+
declare const ACTIVE_ACCOUNT_AUTO = "auto";
|
|
1288
|
+
/** The selector value meaning "no language override — follow the shell locale". */
|
|
1289
|
+
declare const LANG_AUTO = "auto";
|
|
1290
|
+
/** One catalog model offered as a checkbox. */
|
|
1291
|
+
interface TuiModelChoice {
|
|
1292
|
+
/** Catalog model id, e.g. `deepseek/deepseek-v4-pro`. */
|
|
1293
|
+
readonly id: string;
|
|
1294
|
+
/** Minimum plan tier key from `KNOWN_PLANS`. */
|
|
1295
|
+
readonly tier: string;
|
|
1296
|
+
/** Whether the model is currently free, so it leads its group. */
|
|
1297
|
+
readonly free: boolean;
|
|
1298
|
+
/** Footer hint for the focused row: plan tier · deal · peak · `Image`. */
|
|
1299
|
+
readonly hint: string;
|
|
1300
|
+
}
|
|
1301
|
+
/** Everything the section needs from the plugin entry. */
|
|
1302
|
+
interface CommandCodeTuiSettingsDeps {
|
|
1303
|
+
/** The plugin's settings namespace (`llm-commandcode`). */
|
|
1304
|
+
ns: string;
|
|
1305
|
+
/** Section title; defaults to `Command Code`. */
|
|
1306
|
+
title?: string;
|
|
1307
|
+
/**
|
|
1308
|
+
* The credential reference the API-key field writes through, read per
|
|
1309
|
+
* registration so a `Config.apiKeyEnv` change re-targets the field instead
|
|
1310
|
+
* of silently writing to the old reference.
|
|
1311
|
+
*/
|
|
1312
|
+
apiKeyRef: () => string;
|
|
1313
|
+
/**
|
|
1314
|
+
* Account slots for the active-account selector, in rotation order, read
|
|
1315
|
+
* per registration. A changed list re-registers the section (see
|
|
1316
|
+
* {@link applyCommandCodeTuiSettings}).
|
|
1317
|
+
*/
|
|
1318
|
+
accountSlots: () => readonly {
|
|
1319
|
+
id: string;
|
|
1320
|
+
label: string;
|
|
1321
|
+
}[];
|
|
1322
|
+
/**
|
|
1323
|
+
* The stored model allowlist, read LIVE at save time. A checkbox judges its
|
|
1324
|
+
* inherited state against this, so it must be read when the write runs, not
|
|
1325
|
+
* captured when the section was registered. An empty list means "every model
|
|
1326
|
+
* is visible" (the adapter's rule).
|
|
1327
|
+
*/
|
|
1328
|
+
visibleModels: () => readonly string[];
|
|
1329
|
+
/**
|
|
1330
|
+
* The per-model override map the checkboxes write, read per registration so
|
|
1331
|
+
* ids this build's catalog does not know still get a row of their own. Same
|
|
1332
|
+
* live-read rule as {@link visibleModels}.
|
|
1333
|
+
*/
|
|
1334
|
+
modelVisibility?: () => Readonly<Record<string, boolean>> | undefined;
|
|
1335
|
+
/** The models to offer as checkboxes; defaults to the static snapshot. */
|
|
1336
|
+
modelChoices?: () => readonly TuiModelChoice[];
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Build the section descriptor. Pure, so tests can pin the exact fields
|
|
1340
|
+
* without a dsh-TUI host.
|
|
1341
|
+
*
|
|
1342
|
+
* Field choices worth keeping: the two option-bearing fields (`activeAccount`,
|
|
1343
|
+
* `lang`) are `text` + `options` rather than `select`, because a `select`
|
|
1344
|
+
* cannot express "unset" — cycling only ever lands on a declared option, so a
|
|
1345
|
+
* `select` would strand the user on a pinned value with no way back to
|
|
1346
|
+
* automatic. The `auto` sentinel plus a `parse` that clears the path keeps the
|
|
1347
|
+
* unset state reachable. `filterModelsByPlan` formats its EFFECTIVE default
|
|
1348
|
+
* (unset means true at the adapter), so a fresh install reads true instead of
|
|
1349
|
+
* the screen's "(empty)".
|
|
1350
|
+
*/
|
|
1351
|
+
declare function buildCommandCodeTuiSection(deps: CommandCodeTuiSettingsDeps): TuiSettingsSection;
|
|
1352
|
+
/**
|
|
1353
|
+
* Register the Command Code section on a dsh-TUI host.
|
|
1354
|
+
*
|
|
1355
|
+
* @param ctx - the context of an activated `tuiSettingsSections` injection.
|
|
1356
|
+
* @param deps - plugin-owned facts the section reads.
|
|
1357
|
+
* @returns a refresh function that re-registers the section when a fact it
|
|
1358
|
+
* renders changed (the plugin entry calls it from its settings `onChange`
|
|
1359
|
+
* hook), or `undefined` when the seam is unusable. The returned function is
|
|
1360
|
+
* inert after the fiber is torn down.
|
|
1361
|
+
*/
|
|
1362
|
+
declare function applyCommandCodeTuiSettings(ctx: Context, deps: CommandCodeTuiSettingsDeps): (() => void) | undefined;
|
|
1363
|
+
//#endregion
|
|
1157
1364
|
//#region src/index.d.ts
|
|
1158
1365
|
declare const name = "llm-commandcode";
|
|
1159
1366
|
declare const inject: string[];
|
|
@@ -1196,6 +1403,15 @@ interface Config {
|
|
|
1196
1403
|
* filter card; applies after the subscription-tier filter.
|
|
1197
1404
|
*/
|
|
1198
1405
|
visibleModels?: string[];
|
|
1406
|
+
/**
|
|
1407
|
+
* Per-model visibility overrides from the terminal settings page's checkbox
|
|
1408
|
+
* list, keyed by catalog id (`true` = listed, `false` = hidden). An id here
|
|
1409
|
+
* decides that model on its own; an id absent here follows `visibleModels`.
|
|
1410
|
+
* dsh-TUI keys a staged edit by the field's path, so the checkboxes need one
|
|
1411
|
+
* path per model — a map — because a boolean field cannot express "this id
|
|
1412
|
+
* is a member of the array".
|
|
1413
|
+
*/
|
|
1414
|
+
modelVisibility?: Record<string, boolean>;
|
|
1199
1415
|
/**
|
|
1200
1416
|
* Extra accounts for multi-account rotation. The top-level
|
|
1201
1417
|
* `apiKey`/`apiKeyEnv` (plus the CLI auth file) always form the first
|
|
@@ -1265,5 +1481,5 @@ interface ResolvedCommandCodeOptions extends CommandCodeConnectionOptions {
|
|
|
1265
1481
|
declare function resolveAdapterOptions(config: Config): ResolvedCommandCodeOptions;
|
|
1266
1482
|
declare function apply(ctx: Context, config: Config): void;
|
|
1267
1483
|
//#endregion
|
|
1268
|
-
export { type ApiKeyValidation, BILLING_ACCESS_TTL_MS, COMMANDCODE_SEARCH_PROVIDER_ID, COMMAND_CODE_CLI_VERSION, type CommandCodeAccountConfig, CommandCodeAccountPool, type CommandCodeAccountSlot, type CommandCodeAccountState, type CommandCodeAccountUsage, type CommandCodeAccountsReport, CommandCodeAdapter, type CommandCodeAdapterDeps, type CommandCodeBillingAccess, type CommandCodeCommandDeps, type CommandCodeConnectionOptions, type CommandCodeLoginCredentials, type CommandCodeLoginFailureReason, CommandCodeLoginFlow, type CommandCodeLoginFlowDeps, type CommandCodeLoginStatus, type CommandCodeModelAccountRule, CommandCodeSearchProvider, type CommandCodeSearchProviderDeps, type CommandCodeSearchSelection, type CommandCodeUsageDeps, type CommandCodeUsageReport, CommandCodeUsageService, Config, DEFAULT_API_BASE, DEFAULT_GENERATE_MAX_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MODELS_CACHE_PATH, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_WEB_SEARCH_PROVIDER_ID, KNOWN_DEALS, KNOWN_EFFORTS, KNOWN_IMAGE_MODELS, KNOWN_PEAK_PRICING, KNOWN_PLANS, KNOWN_SUBSCRIPTION_PLANS, KNOWN_THINKING_MODELS, LOGIN_ALLOWED_ORIGINS, LOGIN_BEGIN_ENDPOINT, LOGIN_BODY_LIMIT_BYTES, LOGIN_CANCEL_ENDPOINT, LOGIN_MAX_PORT_ATTEMPTS, LOGIN_START_PORT, LOGIN_STATUS_ENDPOINT, LOGIN_TIMEOUT_MS, type LoginFlowFacade, PLAN_LABELS, PLAN_ORDER, PROVIDER, type ResolveAttachments, ResolvedCommandCodeOptions, USAGE_REPORT_ENDPOINT, accountUsable, apply, applyCommandCodeSearchSelection, applyCommands, applyUsageRemote, buildCommandAuthUrl, capabilityDescription, commandCodeSearchSelection, commandDefinition, compareByPlan, dealLabel, formatContext, inject, loginStatusSchema, matchModelRule, modelVisibleInPlan, name, parseLoginStatus, peakPricingLabel, peakPricingState, planLabel, projectSlugFromPath, resolveAdapterOptions, resolveAuthFileApiKey, selectAccountForModel, selectActiveAccount, selectCommandCodeSearchProvider, studioBaseForApiBase, subscriptionPlanInfo, usageReportSchema, validateCommandApiKey };
|
|
1484
|
+
export { ACTIVE_ACCOUNT_AUTO, type ApiKeyValidation, BILLING_ACCESS_TTL_MS, COMMANDCODE_SEARCH_PROVIDER_ID, COMMAND_CODE_CLI_VERSION, type CommandCodeAccountConfig, CommandCodeAccountPool, type CommandCodeAccountSlot, type CommandCodeAccountState, type CommandCodeAccountUsage, type CommandCodeAccountsReport, CommandCodeAdapter, type CommandCodeAdapterDeps, type CommandCodeBillingAccess, type CommandCodeCommandDeps, type CommandCodeConnectionOptions, type CommandCodeLoginCredentials, type CommandCodeLoginFailureReason, CommandCodeLoginFlow, type CommandCodeLoginFlowDeps, type CommandCodeLoginStatus, type CommandCodeModelAccountRule, CommandCodeSearchProvider, type CommandCodeSearchProviderDeps, type CommandCodeSearchSelection, type CommandCodeTuiSettingsDeps, type CommandCodeUsageDeps, type CommandCodeUsageReport, CommandCodeUsageService, Config, DEFAULT_API_BASE, DEFAULT_GENERATE_MAX_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MODELS_CACHE_PATH, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_STREAM_IDLE_TIMEOUT_MS, DEFAULT_WEB_SEARCH_PROVIDER_ID, KNOWN_DEALS, KNOWN_EFFORTS, KNOWN_IMAGE_MODELS, KNOWN_PEAK_PRICING, KNOWN_PLANS, KNOWN_SUBSCRIPTION_PLANS, KNOWN_THINKING_MODELS, LANG_AUTO, LOGIN_ALLOWED_ORIGINS, LOGIN_BEGIN_ENDPOINT, LOGIN_BODY_LIMIT_BYTES, LOGIN_CANCEL_ENDPOINT, LOGIN_MAX_PORT_ATTEMPTS, LOGIN_START_PORT, LOGIN_STATUS_ENDPOINT, LOGIN_TIMEOUT_MS, type LoginFlowFacade, PLAN_LABELS, PLAN_ORDER, PROVIDER, type ResolveAttachments, ResolvedCommandCodeOptions, type TuiSettingsField, type TuiSettingsFieldOption, type TuiSettingsFieldWrite, type TuiSettingsGroup, type TuiSettingsSection, type TuiSettingsSectionsService, USAGE_REPORT_ENDPOINT, accountUsable, apply, applyCommandCodeSearchSelection, applyCommandCodeTuiSettings, applyCommands, applyUsageRemote, buildCommandAuthUrl, buildCommandCodeTuiSection, capabilityDescription, commandCodeSearchSelection, commandDefinition, compareByPlan, dealLabel, formatContext, inject, loginStatusSchema, matchModelRule, modelVisibleInPlan, name, parseLoginStatus, peakPricingLabel, peakPricingState, planLabel, projectSlugFromPath, resolveAdapterOptions, resolveAuthFileApiKey, selectAccountForModel, selectActiveAccount, selectCommandCodeSearchProvider, studioBaseForApiBase, subscriptionPlanInfo, usageReportSchema, validateCommandApiKey };
|
|
1269
1485
|
//# sourceMappingURL=index.d.ts.map
|