@mars-sea/dsh-commandcode-provider 0.10.1 → 0.10.2
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 +22 -0
- package/README.md +7 -3
- package/README.zh-CN.md +7 -3
- package/lib/client.js +519 -144
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +122 -30
- package/lib/index.js +767 -576
- package/lib/index.js.map +1 -1
- package/package.json +8 -1
package/lib/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare function projectSlugFromPath(pathName: string): string;
|
|
|
24
24
|
declare function resolveAuthFileApiKey(): string | undefined;
|
|
25
25
|
/** Connection facts resolved fresh per request by the plugin entry. */
|
|
26
26
|
interface CommandCodeConnectionOptions {
|
|
27
|
-
/** API base; the Provider API lives under it (`/alpha/generate`, `/provider/v1/models`). */
|
|
27
|
+
/** API base; the Provider API lives under it (`/alpha/generate`, `/provider/v1/chat/completions`, `/provider/v1/models`). */
|
|
28
28
|
apiBase: string;
|
|
29
29
|
/** Working directory reported to the API (project slug, config block). */
|
|
30
30
|
workingDir: string;
|
|
@@ -46,10 +46,20 @@ interface CommandCodeConnectionOptions {
|
|
|
46
46
|
*/
|
|
47
47
|
filterModelsByPlan?: boolean;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* Visible-model allowlist: catalog model ids shown in pickers. Empty or
|
|
50
|
+
* unset means "show everything"; applies after the subscription-tier filter.
|
|
51
|
+
* The settings page persists it; the catalog endpoint serves the full
|
|
52
|
+
* catalog regardless so the page can always offer every model.
|
|
53
|
+
*/
|
|
54
|
+
visibleModels?: string[] | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Optional protocol hint. `'auto'` (default) uses billing/cache plus
|
|
57
|
+
* Provider API fallback; `'cli'` forces `/alpha/generate`; `'openai'`
|
|
58
|
+
* prefers `/provider/v1/chat/completions` but still falls back to the CLI
|
|
59
|
+
* transport on `upgrade_required` (Go-plan keys have no Provider API
|
|
60
|
+
* access — failing outright would strand them). This is a
|
|
61
|
+
* connection-level test/operator seam and is intentionally not part of
|
|
62
|
+
* the plugin's user settings schema.
|
|
53
63
|
*/
|
|
54
64
|
protocol?: 'auto' | CommandCodeProtocol;
|
|
55
65
|
}
|
|
@@ -193,10 +203,20 @@ declare class CommandCodeAdapter<C extends CommandCodeConnectionOptions = Comman
|
|
|
193
203
|
providerRetryPolicy(_provider: string): ResolvedRetryPolicy;
|
|
194
204
|
/** Refresh the catalog (live fetch, cache fallback) and return it. */
|
|
195
205
|
private loadCatalog;
|
|
196
|
-
listModels(provider: string
|
|
206
|
+
listModels(provider: string, opts?: {
|
|
207
|
+
unfiltered?: boolean;
|
|
208
|
+
}): Promise<readonly LlmModelInfo[]>;
|
|
197
209
|
resolveModel(provider: string, model: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
198
210
|
/** The headers every authenticated account endpoint shares. */
|
|
199
211
|
private accountHeaders;
|
|
212
|
+
/**
|
|
213
|
+
* Fetch one account endpoint and parse its JSON body. Returns the HTTP
|
|
214
|
+
* status alongside the parsed record so each caller applies its own
|
|
215
|
+
* failure accounting: the billing probe fails open silently, the usage
|
|
216
|
+
* report books failures per endpoint. Non-2xx and non-record bodies come
|
|
217
|
+
* back without a record; only a transport throw propagates to the caller.
|
|
218
|
+
*/
|
|
219
|
+
private fetchEndpointJson;
|
|
200
220
|
/**
|
|
201
221
|
* The billing facts behind the picker's plan filter, cached for
|
|
202
222
|
* {@link BILLING_ACCESS_TTL_MS} and shared across concurrent callers.
|
|
@@ -582,8 +602,9 @@ interface CommandCodeBillingAccess {
|
|
|
582
602
|
/**
|
|
583
603
|
* Whether the picker lists `modelId` for an account with the given billing
|
|
584
604
|
* access. Fails open at every uncertainty: no billing data, an unknown plan,
|
|
585
|
-
*
|
|
586
|
-
*
|
|
605
|
+
* a non-finite weight (corrupt billing fact), or a model outside
|
|
606
|
+
* {@link KNOWN_PLANS} all keep the model visible — the server remains the
|
|
607
|
+
* final gate (`403 MODEL_NOT_IN_PLAN`).
|
|
587
608
|
*/
|
|
588
609
|
declare function modelVisibleInPlan(modelId: string, access: CommandCodeBillingAccess | undefined): boolean;
|
|
589
610
|
/**
|
|
@@ -662,8 +683,8 @@ declare function planLabel(modelId: string): string | undefined;
|
|
|
662
683
|
declare function dealLabel(modelId: string, now?: number): string | undefined;
|
|
663
684
|
/**
|
|
664
685
|
* Compact human-readable context window, e.g. `1_000_000 -> "1M"`,
|
|
665
|
-
* `256_000 -> "256K"`, `262_144 -> "
|
|
666
|
-
* Returns undefined for unknown/absent sizes.
|
|
686
|
+
* `256_000 -> "256K"`, `262_144 -> "262K"` (floor to the nearest K).
|
|
687
|
+
* Returns undefined for unknown/absent sizes; values under 1K render raw.
|
|
667
688
|
*/
|
|
668
689
|
declare function formatContext(contextWindow: number | undefined): string | undefined;
|
|
669
690
|
/**
|
|
@@ -705,12 +726,20 @@ declare const USAGE_REPORT_ENDPOINT = "commandcode/report";
|
|
|
705
726
|
* deliberately minimal so one `parse` function satisfies it.
|
|
706
727
|
*/
|
|
707
728
|
declare const usageReportSchema: TypertSchema<CommandCodeAccountsReport>;
|
|
708
|
-
/** One catalog entry the settings page's
|
|
729
|
+
/** One catalog entry the settings page's model editors offer. */
|
|
709
730
|
interface CommandCodeCatalogModel {
|
|
710
731
|
/** Catalog model id (e.g. `deepseek/deepseek-v4-pro`). */
|
|
711
732
|
id: string;
|
|
712
733
|
/** Display name from the catalog. */
|
|
713
734
|
name: string;
|
|
735
|
+
/**
|
|
736
|
+
* Minimum plan-tier key for this model (a `KNOWN_PLANS` value: `go`,
|
|
737
|
+
* `goat`, `pro`, `provider`, `max`), or undefined for models outside the
|
|
738
|
+
* snapshot. The settings page groups the model-editor dropdowns under
|
|
739
|
+
* tier headings from this — the browser cannot import the Host's
|
|
740
|
+
* capability snapshot, so the Host stamps it per entry.
|
|
741
|
+
*/
|
|
742
|
+
tier?: string;
|
|
714
743
|
}
|
|
715
744
|
/** The model-catalog Remote result: the full catalog, sorted for picking. */
|
|
716
745
|
interface CommandCodeCatalog {
|
|
@@ -812,8 +841,9 @@ declare const loginStatusSchema: TypertSchema<CommandCodeLoginStatus>;
|
|
|
812
841
|
/**
|
|
813
842
|
* The browser-login face the usage service exposes (`commandcode/login*`).
|
|
814
843
|
* Backed by the Host-half {@link !CommandCodeLoginFlow} when the plugin entry
|
|
815
|
-
* wired one; absent,
|
|
816
|
-
*
|
|
844
|
+
* wired one; absent, `status`/`cancel` degrade to the idle status while
|
|
845
|
+
* `begin` rejects with a plain message (so the page's manual paste path
|
|
846
|
+
* stays the fallback instead of hanging).
|
|
817
847
|
*/
|
|
818
848
|
interface LoginFlowFacade {
|
|
819
849
|
/** Start (or rejoin) an attempt; rejects when it cannot start at all. */
|
|
@@ -834,9 +864,10 @@ interface CommandCodeUsageDeps<C extends CommandCodeConnectionOptions = CommandC
|
|
|
834
864
|
*/
|
|
835
865
|
reports?: () => Promise<CommandCodeAccountsReport>;
|
|
836
866
|
/**
|
|
837
|
-
* Model-catalog source for the
|
|
867
|
+
* Model-catalog source for the settings page's model editors (the
|
|
868
|
+
* routing-rule editor and the visible-models filter; wired by the plugin
|
|
838
869
|
* entry). Absent, the `models` endpoint answers an empty list — the page's
|
|
839
|
-
*
|
|
870
|
+
* editors degrade to the empty state.
|
|
840
871
|
*/
|
|
841
872
|
listModels?: () => Promise<CommandCodeCatalog>;
|
|
842
873
|
/**
|
|
@@ -866,10 +897,11 @@ declare class CommandCodeUsageService<C extends CommandCodeConnectionOptions = C
|
|
|
866
897
|
*/
|
|
867
898
|
report(): Promise<CommandCodeAccountsReport>;
|
|
868
899
|
/**
|
|
869
|
-
* The model catalog for the settings page's
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
900
|
+
* The full model catalog for the settings page's model editors (the
|
|
901
|
+
* routing-rule editor and the visible-models filter). The browser never
|
|
902
|
+
* calls the Command Code API directly — the Host serves the catalog
|
|
903
|
+
* (already fetched/cached by the adapter) so models can be picked from
|
|
904
|
+
* the live list instead of typed by hand.
|
|
873
905
|
*/
|
|
874
906
|
models(): Promise<CommandCodeCatalog>;
|
|
875
907
|
/**
|
|
@@ -1012,17 +1044,68 @@ declare class CommandCodeLoginFlow {
|
|
|
1012
1044
|
declare const COMMANDCODE_SEARCH_PROVIDER_ID = "commandcode";
|
|
1013
1045
|
/**
|
|
1014
1046
|
* The factory-declared search provider id dsh ships by default (from
|
|
1015
|
-
* `dsh-base`'s cordis patch `web.config.searchProvider`).
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1047
|
+
* `dsh-base`'s cordis patch `web.config.searchProvider`). Kept as a
|
|
1048
|
+
* documented reference only: disabling this plugin's `webSearch` toggle
|
|
1049
|
+
* restores the previously selected backend (see
|
|
1050
|
+
* {@link applyCommandCodeSearchSelection}) — it never forces this default,
|
|
1051
|
+
* because forcing it is what used to silence sibling search plugins such as
|
|
1052
|
+
* modsearch even with Command Code search turned off (issue #26).
|
|
1018
1053
|
*/
|
|
1019
1054
|
declare const DEFAULT_WEB_SEARCH_PROVIDER_ID = "deepseek-official";
|
|
1020
1055
|
/**
|
|
1021
1056
|
* Point the web seam's search selection at this plugin's provider (`commandcode`).
|
|
1022
1057
|
* Sets the runtime field; the next search call honours it because `search()`
|
|
1023
1058
|
* re-reads `searchProviderId` each time. Returns the prior id (or undefined).
|
|
1059
|
+
* Never throws: a hardened/frozen runtime shape must not break the
|
|
1060
|
+
* settings-save path that calls this — the provider simply stays
|
|
1061
|
+
* registered-but-unselected (the boot-time `searchProvider: commandcode`
|
|
1062
|
+
* cordis patch is the durable alternative).
|
|
1063
|
+
*
|
|
1064
|
+
* @deprecated Prefer {@link applyCommandCodeSearchSelection}: this overload
|
|
1065
|
+
* always overwrites the displaced backend with the factory default on
|
|
1066
|
+
* disable, so turning Command Code search off silences whichever provider
|
|
1067
|
+
* was selected before (e.g. modsearch) instead of restoring it (issue #26).
|
|
1024
1068
|
*/
|
|
1025
1069
|
declare function selectCommandCodeSearchProvider(web: WebRuntime, enable: boolean): string | undefined;
|
|
1070
|
+
/**
|
|
1071
|
+
* Tracked web-search selection state for one mounted `WebRuntime`.
|
|
1072
|
+
*
|
|
1073
|
+
* `owner` marks whether this plugin currently owns the selection (i.e. it
|
|
1074
|
+
* wrote `commandcode` and has not given it back yet). `displaced` is the
|
|
1075
|
+
* backend id the plugin displaced when it took over — restored when the
|
|
1076
|
+
* toggle turns off or the plugin unloads. `undefined` means "nothing was
|
|
1077
|
+
* configured, leave auto-select" and must round-trip untouched: writing the
|
|
1078
|
+
* factory default instead would still override a sibling plugin's own
|
|
1079
|
+
* constructor-time pin.
|
|
1080
|
+
*/
|
|
1081
|
+
interface CommandCodeSearchSelection {
|
|
1082
|
+
owner: boolean;
|
|
1083
|
+
displaced: string | undefined;
|
|
1084
|
+
}
|
|
1085
|
+
/** Fresh selection state: the plugin starts out not owning the selection. */
|
|
1086
|
+
declare function commandCodeSearchSelection(): CommandCodeSearchSelection;
|
|
1087
|
+
/**
|
|
1088
|
+
* Reach one end of the `webSearch` toggle without trampling sibling search
|
|
1089
|
+
* providers (issue #26).
|
|
1090
|
+
*
|
|
1091
|
+
* - Enabling writes `commandcode` and remembers whatever it displaced. When
|
|
1092
|
+
* the plugin already owns the selection (e.g. a settings save while still
|
|
1093
|
+
* on), the original `displaced` value is kept — the field currently holds
|
|
1094
|
+
* our own id, which must never be mistaken for the user's backend.
|
|
1095
|
+
* - Disabling hands the selection back to the remembered backend. When the
|
|
1096
|
+
* state holds no memory (a fresh boot straight into `webSearch: false`),
|
|
1097
|
+
* the field is left alone: the runtime's current value — a sibling's
|
|
1098
|
+
* cordis pin such as `searchProvider: modsearch`, or unset for
|
|
1099
|
+
* auto-select — already says what the user wants.
|
|
1100
|
+
* - When the field already reads `commandcode` at first touch (e.g. a
|
|
1101
|
+
* surviving runtime the plugin did not set, or a manual
|
|
1102
|
+
* `searchProvider: commandcode` pin), `displaced` stays undefined so the
|
|
1103
|
+
* later disable is a no-op rather than a guess at the factory default.
|
|
1104
|
+
*
|
|
1105
|
+
* Never throws: like the low-level rewrite, a hardened runtime shape degrades
|
|
1106
|
+
* to registered-but-unselected.
|
|
1107
|
+
*/
|
|
1108
|
+
declare function applyCommandCodeSearchSelection(web: WebRuntime, state: CommandCodeSearchSelection, enable: boolean): void;
|
|
1026
1109
|
/** Per-request facts the provider needs, all injected so the class stays cordis-free and testable. */
|
|
1027
1110
|
interface CommandCodeSearchProviderDeps {
|
|
1028
1111
|
/** Resolve one usable Command Code key (credential seam → env → auth file), or undefined when none. */
|
|
@@ -1043,7 +1126,7 @@ declare class CommandCodeSearchProvider implements WebSearchProvider {
|
|
|
1043
1126
|
private readonly deps;
|
|
1044
1127
|
readonly id = "commandcode";
|
|
1045
1128
|
constructor(deps: CommandCodeSearchProviderDeps);
|
|
1046
|
-
/** Cheap local check; must not make network calls. Presence of a
|
|
1129
|
+
/** Cheap local check; must not make network calls. Presence of a parseable base is enough. */
|
|
1047
1130
|
available(): boolean;
|
|
1048
1131
|
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
1049
1132
|
private resolveKey;
|
|
@@ -1085,6 +1168,12 @@ interface Config {
|
|
|
1085
1168
|
* full catalog visible). Set false to always list every model.
|
|
1086
1169
|
*/
|
|
1087
1170
|
filterModelsByPlan?: boolean;
|
|
1171
|
+
/**
|
|
1172
|
+
* Visible-model allowlist: catalog model ids shown in pickers. Empty or
|
|
1173
|
+
* unset means "show everything". Persisted by the settings page's model
|
|
1174
|
+
* filter card; applies after the subscription-tier filter.
|
|
1175
|
+
*/
|
|
1176
|
+
visibleModels?: string[];
|
|
1088
1177
|
/**
|
|
1089
1178
|
* Extra accounts for multi-account rotation. The top-level
|
|
1090
1179
|
* `apiKey`/`apiKeyEnv` (plus the CLI auth file) always form the first
|
|
@@ -1116,12 +1205,15 @@ interface Config {
|
|
|
1116
1205
|
/**
|
|
1117
1206
|
* Whether to use Command Code as the backend for dsh's model-facing
|
|
1118
1207
|
* `web_search` tool. When enabled, the plugin registers a `commandcode`
|
|
1119
|
-
* search provider on `ctx.web` AND
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
*
|
|
1208
|
+
* search provider on `ctx.web` AND selects `commandcode` in the web seam
|
|
1209
|
+
* (so it wins over the shipped `deepseek-official` or a sibling search
|
|
1210
|
+
* plugin's pin), using the SAME Command Code API key/base as chat. When
|
|
1211
|
+
* disabled, the selection is handed back to whichever backend was there
|
|
1212
|
+
* before — turning it off never forces the factory default, so a sibling
|
|
1213
|
+
* search plugin (e.g. modsearch) keeps working (issue #26). The rewrite
|
|
1214
|
+
* rides dsh's internal `searchProviderId`, which is read per search call,
|
|
1215
|
+
* so a setting change lands on the next search without a restart.
|
|
1216
|
+
* Defaults to true.
|
|
1125
1217
|
*/
|
|
1126
1218
|
webSearch?: boolean;
|
|
1127
1219
|
/**
|
|
@@ -1151,5 +1243,5 @@ interface ResolvedCommandCodeOptions extends CommandCodeConnectionOptions {
|
|
|
1151
1243
|
declare function resolveAdapterOptions(config: Config): ResolvedCommandCodeOptions;
|
|
1152
1244
|
declare function apply(ctx: Context, config: Config): void;
|
|
1153
1245
|
//#endregion
|
|
1154
|
-
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 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, applyCommands, applyUsageRemote, buildCommandAuthUrl, capabilityDescription, commandDefinition, compareByPlan, dealLabel, formatContext, inject, loginStatusSchema, matchModelRule, modelVisibleInPlan, name, parseLoginStatus, peakPricingLabel, peakPricingState, planLabel, projectSlugFromPath, resolveAdapterOptions, resolveAuthFileApiKey, selectAccountForModel, selectActiveAccount, selectCommandCodeSearchProvider, studioBaseForApiBase, subscriptionPlanInfo, usageReportSchema, validateCommandApiKey };
|
|
1246
|
+
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 };
|
|
1155
1247
|
//# sourceMappingURL=index.d.ts.map
|