bailian-cli-core 1.6.1 → 1.8.0

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.d.mts CHANGED
@@ -38,6 +38,10 @@ declare class BailianError extends Error {
38
38
  };
39
39
  };
40
40
  }
41
+ /** Invalid usage: unknown command, bad/unknown flag, missing required, failed validation. */
42
+ declare class UsageError extends BailianError {
43
+ constructor(message: string, hint?: string);
44
+ }
41
45
  //#endregion
42
46
  //#region src/errors/api.d.ts
43
47
  interface ApiErrorBody {
@@ -93,6 +97,14 @@ interface ChatTool {
93
97
  parameters: Record<string, unknown>;
94
98
  };
95
99
  }
100
+ interface ChatResponseFormat {
101
+ type: "json_object" | "json_schema";
102
+ json_schema?: {
103
+ name: string;
104
+ schema?: Record<string, unknown>;
105
+ strict?: boolean;
106
+ };
107
+ }
96
108
  interface ChatRequest {
97
109
  model: string;
98
110
  messages: ChatMessage[];
@@ -117,6 +129,7 @@ interface ChatRequest {
117
129
  stream_options?: {
118
130
  include_usage?: boolean;
119
131
  };
132
+ response_format?: ChatResponseFormat;
120
133
  }
121
134
  interface ChatChoice {
122
135
  index: number;
@@ -412,38 +425,6 @@ interface UserProfileResponse {
412
425
  attributes: ProfileAttribute[];
413
426
  };
414
427
  }
415
- interface KnowledgeRetrieveRequest {
416
- IndexId: string;
417
- Query: string;
418
- DenseSimilarityTopK?: number;
419
- SparseSimilarityTopK?: number;
420
- EnableReranking?: boolean;
421
- EnableRewrite?: boolean;
422
- RerankTopN?: number;
423
- TopK?: number;
424
- Rerank?: Array<{
425
- ModelName?: string;
426
- RerankMode?: string;
427
- RerankInstruct?: string;
428
- }>;
429
- RerankTopN_legacy?: number;
430
- SearchFilters?: Array<{
431
- Key: string;
432
- Value: string;
433
- Operator: string;
434
- }>;
435
- }
436
- interface KnowledgeRetrieveResponse {
437
- Success: boolean;
438
- RequestId: string;
439
- Data: {
440
- Nodes: Array<{
441
- Text: string;
442
- Score: number;
443
- Metadata: Record<string, unknown>;
444
- }>;
445
- };
446
- }
447
428
  interface DashScopeKnowledgeRetrieveRequest {
448
429
  index_id: string;
449
430
  query: string;
@@ -666,11 +647,6 @@ interface DashScopeTaskResponse {
666
647
  request_id: string;
667
648
  }
668
649
  //#endregion
669
- //#region src/auth/credentials.d.ts
670
- declare function loadApiKeyFromConfig(): string | null;
671
- declare function saveApiKeyToConfig(apiKey: string): Promise<void>;
672
- declare function clearApiKey(): Promise<void>;
673
- //#endregion
674
650
  //#region src/config/schema.d.ts
675
651
  declare const REGIONS: {
676
652
  readonly cn: "https://dashscope.aliyuncs.com";
@@ -688,6 +664,10 @@ interface ConfigFile {
688
664
  api_key?: string;
689
665
  /** OAuth-style token from `bl auth login --console` callback; sent as `Authorization: Bearer …` */
690
666
  access_token?: string;
667
+ /** Alibaba Cloud OpenAPI AccessKey ID from `bl auth login --open-api`. */
668
+ access_key_id?: string;
669
+ /** Alibaba Cloud OpenAPI AccessKey secret from `bl auth login --open-api`. */
670
+ access_key_secret?: string;
691
671
  base_url?: string;
692
672
  output?: "text" | "json";
693
673
  output_dir?: string;
@@ -697,8 +677,6 @@ interface ConfigFile {
697
677
  default_image_model?: string;
698
678
  default_speech_model?: string;
699
679
  default_omni_model?: string;
700
- access_key_id?: string;
701
- access_key_secret?: string;
702
680
  workspace_id?: string;
703
681
  console_site?: "domestic" | "international";
704
682
  console_region?: string;
@@ -706,22 +684,30 @@ interface ConfigFile {
706
684
  telemetry?: boolean;
707
685
  }
708
686
  declare function parseConfigFile(raw: unknown): ConfigFile;
709
- interface Config {
710
- clientName?: string;
711
- clientVersion?: string;
712
- /** Product binary name (e.g. "bl", "rag"), injected by createCli for command-facing output. */
713
- binName?: string;
714
- /** npm package name for self-update (e.g. "bailian-cli", "bailian-cli-rag"), injected by createCli. */
715
- npmPackage?: string;
716
- apiKey?: string;
717
- /** `DASHSCOPE_ACCESS_TOKEN` env (explicit override). */
718
- accessTokenEnv?: string;
719
- /** `access_token` in config file (console login). */
720
- fileAccessToken?: string;
721
- fileApiKey?: string;
687
+ /** 静态产品身份,createCli 注入一次(bl/rag 各异,故注入而非模块常量)。 */
688
+ interface Identity {
689
+ /** Product binary name, e.g. "bl", "rag". */
690
+ binName: string;
691
+ version: string;
692
+ /** npm package name for self-update, e.g. "bailian-cli". */
693
+ npmPackage: string;
694
+ /** User-Agent / telemetry client name. */
695
+ clientName: string;
696
+ }
697
+ /**
698
+ * 命令唯一会读的配置面(flag/env/file 解析后的有效值)。
699
+ * 不含身份(Identity)、不含秘密(credential);console 三元组为 dry-run 展示保留,
700
+ * 真实调用走 ConsoleCredential(同链解析,受控重叠)。
701
+ */
702
+ interface Settings {
722
703
  configPath?: string;
723
- baseUrl: string;
724
704
  output: "text" | "json";
705
+ /**
706
+ * Whether `output` came from an explicit source (flag/env/file) rather than
707
+ * the default. Commands whose default format differs from the global default
708
+ * (e.g. `advisor recommend` defaults to json) branch on this.
709
+ */
710
+ outputExplicit: boolean;
725
711
  outputDir?: string;
726
712
  timeout: number;
727
713
  defaultTextModel?: string;
@@ -729,100 +715,93 @@ interface Config {
729
715
  defaultImageModel?: string;
730
716
  defaultSpeechModel?: string;
731
717
  defaultOmniModel?: string;
732
- accessKeyId?: string;
733
- accessKeySecret?: string;
734
718
  workspaceId?: string;
735
- consoleSite?: "domestic" | "international";
736
719
  consoleRegion?: string;
720
+ consoleSite?: "domestic" | "international";
737
721
  consoleSwitchAgent?: number;
738
722
  verbose: boolean;
739
723
  quiet: boolean;
740
- noColor: boolean;
741
- yes: boolean;
742
724
  dryRun: boolean;
743
- nonInteractive: boolean;
744
- async: boolean;
745
725
  telemetry: boolean;
746
726
  }
747
727
  //#endregion
748
- //#region src/auth/types.d.ts
749
- type AuthMethod = "api-key" | "access-token";
750
- interface ResolvedCredential {
751
- token: string;
752
- method: AuthMethod;
753
- source: string;
754
- }
755
- //#endregion
756
- //#region src/auth/resolver.d.ts
757
- declare function resolveCredential(config: Config): Promise<ResolvedCredential>;
728
+ //#region src/config/store.d.ts
758
729
  /**
759
- * Credential for Bailian **console** CLI gateway only (`callConsoleGateway`).
760
- * DashScope API keys are not valid Bearer tokens for this gateway — use env/file
761
- * `access_token` even when `api_key` is also present in config.
730
+ * config 命令族的持久化能力面(lint 限定 commands/config/** 使用)
731
+ * 读写都直达磁盘(非 dispatch 时的快照),与现有 config set/show 的行为一致。
762
732
  */
763
- /** Thrown when `callConsoleGateway` has no usable console session token. */
764
- declare const CONSOLE_GATEWAY_NO_TOKEN_MESSAGE = "No console access token found.";
765
- declare function resolveConsoleGatewayCredential(config: Config): Promise<ResolvedCredential>;
733
+ interface ConfigStore {
734
+ read(): ConfigFile;
735
+ /** 合并写入;patch 里值为 undefined 的键会被删除。 */
736
+ write(patch: Partial<ConfigFile>): Promise<void>;
737
+ /** 删除指定键。 */
738
+ unset(keys: (keyof ConfigFile)[]): Promise<void>;
739
+ path: string;
740
+ }
741
+ declare function makeConfigStore(): ConfigStore;
766
742
  //#endregion
767
- //#region src/client/ak-sign.d.ts
768
- /**
769
- * Alibaba Cloud V3 Signature (ROA style) for Bailian Cloud API.
770
- *
771
- * Used by Knowledge Base Retrieve API which requires AK/SK authentication
772
- * instead of Bearer token.
773
- *
774
- * Reference: https://help.aliyun.com/document_detail/2712195.html
775
- */
776
- interface AkSignConfig {
743
+ //#region src/auth/types.d.ts
744
+ /** Where a resolved credential came from (shown by `bl auth status`). */
745
+ type CredentialSource = "flag" | "env" | "config";
746
+ /** Credential for the **model domain** (DashScope data plane). Always an API key. */
747
+ interface ApiKeyCredential {
748
+ token: string;
749
+ /** Base URL to send this key's requests to. */
750
+ baseUrl: string;
751
+ source: CredentialSource;
752
+ }
753
+ /** Credential for the **console domain** (Bailian console gateway). An access token + region/site. */
754
+ interface ConsoleCredential {
755
+ token: string;
756
+ region: string;
757
+ site: "domestic" | "international";
758
+ switchAgent?: number;
759
+ source: CredentialSource;
760
+ }
761
+ /** Credential for Alibaba Cloud OpenAPI calls signed with AK/SK. */
762
+ interface OpenApiCredential {
777
763
  accessKeyId: string;
778
764
  accessKeySecret: string;
779
- action: string;
780
- version: string;
781
- body: string;
782
- host: string;
783
- pathname: string;
784
- method?: string;
765
+ source: CredentialSource;
766
+ }
767
+ /** Full auth snapshot for display (`bl auth status`) — what would resolve per domain. */
768
+ interface AuthState {
769
+ apiKey?: ApiKeyCredential;
770
+ console?: ConsoleCredential;
771
+ openapi?: OpenApiCredential;
785
772
  }
786
- declare function signRequest(cfg: AkSignConfig): Record<string, string>;
787
- //#endregion
788
- //#region src/client/endpoints.d.ts
789
- declare function chatEndpoint(baseUrl: string): string;
790
- declare function imageEndpoint(baseUrl: string): string;
791
- declare function imageSyncEndpoint(baseUrl: string): string;
792
- declare function videoGenerateEndpoint(baseUrl: string): string;
793
- declare function taskEndpoint(baseUrl: string, taskId: string): string;
794
- declare function appCompletionEndpoint(baseUrl: string, appId: string): string;
795
- declare function memoryAddEndpoint(baseUrl: string): string;
796
- declare function memorySearchEndpoint(baseUrl: string): string;
797
- declare function memoryListEndpoint(baseUrl: string): string;
798
- declare function memoryNodeEndpoint(baseUrl: string, nodeId: string): string;
799
- declare function speechSynthesizeEndpoint(baseUrl: string): string;
800
- declare function speechRecognizeEndpoint(baseUrl: string): string;
801
- declare function profileSchemaEndpoint(baseUrl: string): string;
802
- declare function userProfileEndpoint(baseUrl: string, schemaId: string): string;
803
- declare function knowledgeRetrieveEndpoint(baseUrl: string): string;
804
- declare function knowledgeSearchEndpoint(workspaceId: string): string;
805
- declare function knowledgeChatEndpoint(workspaceId: string): string;
806
- declare function mcpWebSearchEndpoint(baseUrl: string): string;
807
773
  //#endregion
808
- //#region src/client/headers.d.ts
774
+ //#region src/auth/store.d.ts
775
+ /** 登录允许落盘的键:凭证本体 + 登录回调携带的连接/作用域字段。 */
776
+ type AuthPersistPatch = Pick<ConfigFile, "api_key" | "access_token" | "access_key_id" | "access_key_secret" | "base_url" | "console_site" | "console_region" | "console_switch_agent" | "workspace_id">;
809
777
  /**
810
- * Shared HTTP request headers for all outgoing requests.
811
- *
812
- * Centralises the `x-dashscope-source-config` header so every fetch call
813
- * (both via the central http client and the bypass paths) uses the
814
- * same values from a single source of truth.
778
+ * auth 命令族的凭证能力面(lint 限定 commands/auth/** 使用)。
779
+ * 登录产生的全部落盘走 login,不放宽 configStore 的边界。
815
780
  */
816
- declare const CHANNEL = "bailian-cli";
817
- declare const TAGS: {
818
- t1: string;
819
- t2: string;
820
- };
821
- declare const SOURCE_CONFIG: string;
822
- /** Standard tracking headers required on every outbound request. */
823
- declare function trackingHeaders(): Record<string, string>;
781
+ interface AuthStore {
782
+ /** 各域"将会解析出"的凭证快照(auth status 用)。 */
783
+ describe(): AuthState;
784
+ /** 磁盘上当前是否存有各域凭证(区别于 describe:只看 file,不含 flag/env 源)。 */
785
+ stored(): {
786
+ apiKey: boolean;
787
+ console: boolean;
788
+ openapi: boolean;
789
+ };
790
+ /** model 域 baseUrl 链(flag > env > file > 默认);验证 API key 等无凭证场景用。 */
791
+ resolveBaseUrl(): string;
792
+ /** 登录落盘:合并写入,undefined 键忽略。 */
793
+ login(patch: AuthPersistPatch): Promise<void>;
794
+ /** 清凭证:console/openapi 只删对应域;all 清全部登录凭证。返回是否有变更。 */
795
+ logout(scope: "console" | "openapi" | "all"): Promise<boolean>;
796
+ }
797
+ declare function makeAuthStore(sources: ResolutionSources): AuthStore;
824
798
  //#endregion
825
799
  //#region src/client/http.d.ts
800
+ /** 传输层依赖:UA 用 identity,timeout/verbose 用 settings。凭证由调用方(Client)注头。 */
801
+ interface HttpDeps {
802
+ identity: Identity;
803
+ settings: Settings;
804
+ }
826
805
  interface RequestOpts {
827
806
  url: string;
828
807
  method?: string;
@@ -830,12 +809,29 @@ interface RequestOpts {
830
809
  headers?: Record<string, string>;
831
810
  timeout?: number;
832
811
  stream?: boolean;
833
- noAuth?: boolean;
834
812
  async?: boolean;
835
813
  signal?: AbortSignal;
836
814
  }
837
- declare function request(config: Config, opts: RequestOpts): Promise<Response>;
838
- declare function requestJson<T>(config: Config, opts: RequestOpts): Promise<T>;
815
+ declare function request(deps: HttpDeps, opts: RequestOpts): Promise<Response>;
816
+ declare function requestJson<T>(deps: HttpDeps, opts: RequestOpts): Promise<T>;
817
+ //#endregion
818
+ //#region src/client/acs.d.ts
819
+ type AcsQueryParams = Record<string, string | string[] | undefined>;
820
+ interface AcsSignConfig {
821
+ accessKeyId: string;
822
+ accessKeySecret: string;
823
+ action: string;
824
+ version: string;
825
+ body: string;
826
+ host: string;
827
+ pathname: string;
828
+ method?: string;
829
+ /** ACS3 canonical query string (sorted, encoded, no leading `?`). */
830
+ queryString?: string;
831
+ }
832
+ /** Build ACS3 canonical query string from OpenAPI query parameters. */
833
+ declare function buildAcsCanonicalQuery(params: AcsQueryParams): string;
834
+ declare function signAcsRequest(cfg: AcsSignConfig): Record<string, string>;
839
835
  //#endregion
840
836
  //#region src/client/mcp.d.ts
841
837
  interface McpTool {
@@ -857,14 +853,14 @@ interface McpToolResult {
857
853
  * The path is `/api/v1/mcps/<serverCode>/mcp`; the `serverCode` is taken
858
854
  * verbatim from `bl mcp list` (e.g. `WebSearch`, `market-cmapi00073529`).
859
855
  */
860
- declare function bailianMcpUrl(baseUrl: string, serverCode: string): string;
856
+ declare function bailianMcpPath(serverCode: string): string;
861
857
  declare class McpClient {
862
858
  private url;
863
859
  private sessionId;
864
860
  private nextId;
865
- private config;
861
+ private deps;
866
862
  private authToken;
867
- constructor(config: Config, url: string);
863
+ constructor(deps: HttpDeps, url: string, authToken?: string);
868
864
  /** Initialize the MCP session. Must be called before any other method. */
869
865
  initialize(): Promise<void>;
870
866
  listTools(): Promise<McpTool[]>;
@@ -874,6 +870,353 @@ declare class McpClient {
874
870
  private send;
875
871
  }
876
872
  //#endregion
873
+ //#region src/client/client.d.ts
874
+ /** Client 的结构化依赖:身份 + 有效配置 + 各域凭证(按命令的 auth 注入)。 */
875
+ interface ClientDeps {
876
+ identity: Identity;
877
+ settings: Settings;
878
+ /** Model 域 base URL(凭证无关链解析,resolveModelBaseUrl;有 apiCred 时两者一致)。 */
879
+ baseUrl: string;
880
+ apiCred?: ApiKeyCredential;
881
+ consoleCred?: ConsoleCredential;
882
+ openApiCred?: OpenApiCredential;
883
+ }
884
+ /** Like {@link RequestOpts} but with a `path` (credential baseUrl prepended) or an absolute URL. */
885
+ interface ClientRequestOpts extends Omit<RequestOpts, "url" | "noAuth"> {
886
+ path: string;
887
+ }
888
+ interface ClientOpenApiQueryOpts {
889
+ host: string;
890
+ path: string;
891
+ action: string;
892
+ version: string;
893
+ method: "GET" | "POST";
894
+ queryParams: AcsQueryParams;
895
+ }
896
+ interface OpenApiResponse {
897
+ Success?: boolean;
898
+ Code?: string;
899
+ Message?: string;
900
+ }
901
+ /**
902
+ * A command's network surface: call its methods to reach the API — the
903
+ * credential and base URL are already baked in, so commands never handle tokens
904
+ * or baseUrl. Model methods (`request`/`requestJson`/`mcp`) need an api key;
905
+ * `uploadFile` only needs one for local files, and passes URLs through without
906
+ * credentials. `console` needs a console token; calling one without its
907
+ * credential throws.
908
+ */
909
+ declare class Client {
910
+ private readonly deps;
911
+ constructor(deps: ClientDeps);
912
+ private get http();
913
+ private requireApi;
914
+ private requireOpenApi;
915
+ /** Model-domain base URL. Readable without a key (e.g. dry-run preview); real requests still need one. */
916
+ get baseUrl(): string;
917
+ /** Full URL for a model-domain {@link path}; build request/display URLs only through this. */
918
+ url(path: string): string;
919
+ private toOpts;
920
+ request(opts: ClientRequestOpts): Promise<Response>;
921
+ requestJson<T>(opts: ClientRequestOpts): Promise<T>;
922
+ /** Resolve a file arg: upload a local path to OSS (returns oss:// URL), or pass a URL through. */
923
+ uploadFile(source: string, model: string, opts?: {
924
+ signal?: AbortSignal;
925
+ }): Promise<string>;
926
+ /** Open an MCP client. Accepts a path (prepended with the model baseUrl) or an absolute URL. */
927
+ mcp(pathOrUrl: string): McpClient;
928
+ console<T>(api: string, data: Record<string, unknown>): Promise<T>;
929
+ openApiQueryJson<T extends OpenApiResponse>(opts: ClientOpenApiQueryOpts): Promise<T>;
930
+ }
931
+ //#endregion
932
+ //#region src/types/command-pack-manager.d.ts
933
+ interface CommandPackMutationResult {
934
+ name: string;
935
+ version?: string;
936
+ commands: string[];
937
+ }
938
+ interface CommandPackReport {
939
+ name: string;
940
+ version?: string;
941
+ source: "installed" | "linked";
942
+ status: "loaded" | "failed";
943
+ commands: string[];
944
+ error?: string;
945
+ }
946
+ /** Product-bound Command Pack management surface injected by the CLI runtime. */
947
+ interface CommandPackManager {
948
+ install(spec: string): Promise<CommandPackMutationResult>;
949
+ link(path: string): Promise<CommandPackMutationResult>;
950
+ list(): Promise<CommandPackReport[]>;
951
+ remove(name: string): Promise<void>;
952
+ }
953
+ //#endregion
954
+ //#region src/types/command.d.ts
955
+ /** A presence flag: `--quiet`. No value; absent → false. */
956
+ interface SwitchFlag {
957
+ type: "switch";
958
+ description: string;
959
+ }
960
+ /** A value flag: `--prompt <text>`, `--n <count>`, `--watermark true|false`. */
961
+ interface ValueFlag {
962
+ type: "string" | "number" | "boolean" | "array";
963
+ description: string;
964
+ valueHint: string;
965
+ required?: boolean;
966
+ /**
967
+ * Restrict to a fixed set of values. The parser rejects anything else and the
968
+ * parsed type narrows to the union. Declare with `as const` so the literals
969
+ * survive inference: `choices: ["mp3", "wav"] as const`.
970
+ */
971
+ choices?: readonly string[];
972
+ }
973
+ type FlagDef = SwitchFlag | ValueFlag;
974
+ type FlagsDef = Record<string, FlagDef>;
975
+ type ParsedValue<F extends FlagDef> = F extends SwitchFlag ? boolean : F extends {
976
+ type: "number";
977
+ } ? number : F extends {
978
+ type: "boolean";
979
+ } ? boolean : F extends {
980
+ choices: readonly (infer C extends string)[];
981
+ } ? F extends {
982
+ type: "array";
983
+ } ? C[] : C : F extends {
984
+ type: "array";
985
+ } ? string[] : string;
986
+ /** Switches and `required` value flags are present; other value flags optional. */
987
+ type IsRequired<F extends FlagDef> = F extends SwitchFlag ? true : F extends {
988
+ required: true;
989
+ } ? true : false;
990
+ /**
991
+ * Map a FlagsDef to the parsed flags object type. Required flags (switches +
992
+ * `required: true`) are required properties; optional value flags are `?`.
993
+ */
994
+ type ParsedFlags<F extends FlagsDef> = { [K in keyof F as IsRequired<F[K]> extends true ? K : never]: ParsedValue<F[K]> } & { [K in keyof F as IsRequired<F[K]> extends true ? never : K]?: ParsedValue<F[K]> };
995
+ type AuthRequirement = "apiKey" | "console" | "openapi" | "none";
996
+ /** 所有命令都可用的全局 flag。 */
997
+ declare const GLOBAL_FLAGS: {
998
+ output: {
999
+ type: "string";
1000
+ valueHint: string;
1001
+ description: string;
1002
+ };
1003
+ timeout: {
1004
+ type: "number";
1005
+ valueHint: string;
1006
+ description: string;
1007
+ };
1008
+ quiet: {
1009
+ type: "switch";
1010
+ description: string;
1011
+ };
1012
+ verbose: {
1013
+ type: "switch";
1014
+ description: string;
1015
+ };
1016
+ dryRun: {
1017
+ type: "switch";
1018
+ description: string;
1019
+ };
1020
+ help: {
1021
+ type: "switch";
1022
+ description: string;
1023
+ };
1024
+ version: {
1025
+ type: "switch";
1026
+ description: string;
1027
+ };
1028
+ };
1029
+ /** Command-scoped flag for commands that support parallel API calls. */
1030
+ declare const CONCURRENT_FLAG: {
1031
+ concurrent: {
1032
+ type: "number";
1033
+ valueHint: string;
1034
+ description: string;
1035
+ };
1036
+ };
1037
+ /** Command-scoped flag for task-based commands that can return without polling. */
1038
+ declare const ASYNC_FLAG: {
1039
+ async: {
1040
+ type: "switch";
1041
+ description: string;
1042
+ };
1043
+ };
1044
+ /** Model 域凭证/连接 flag,`auth: "apiKey"` 命令可见。 */
1045
+ declare const MODEL_AUTH_FLAGS: {
1046
+ apiKey: {
1047
+ type: "string";
1048
+ valueHint: string;
1049
+ description: string;
1050
+ };
1051
+ baseUrl: {
1052
+ type: "string";
1053
+ valueHint: string;
1054
+ description: string;
1055
+ };
1056
+ };
1057
+ /** Console 域目标/作用域 flag,`auth: "console"` 命令可见。 */
1058
+ declare const CONSOLE_AUTH_FLAGS: {
1059
+ consoleRegion: {
1060
+ type: "string";
1061
+ valueHint: string;
1062
+ description: string;
1063
+ };
1064
+ consoleSite: {
1065
+ type: "string";
1066
+ valueHint: string;
1067
+ description: string;
1068
+ };
1069
+ consoleSwitchAgent: {
1070
+ type: "number";
1071
+ valueHint: string;
1072
+ description: string;
1073
+ };
1074
+ workspaceId: {
1075
+ type: "string";
1076
+ valueHint: string;
1077
+ description: string;
1078
+ };
1079
+ };
1080
+ /** Alibaba Cloud OpenAPI AK/SK credential flags, visible to `auth: "openapi"` commands. */
1081
+ declare const OPENAPI_AUTH_FLAGS: {
1082
+ accessKeyId: {
1083
+ type: "string";
1084
+ valueHint: string;
1085
+ description: string;
1086
+ };
1087
+ accessKeySecret: {
1088
+ type: "string";
1089
+ valueHint: string;
1090
+ description: string;
1091
+ };
1092
+ };
1093
+ /** sources 里可能出现的全部 flag(全局 + 凭证域)。 */
1094
+ type SourceFlags = ParsedFlags<typeof GLOBAL_FLAGS & typeof MODEL_AUTH_FLAGS & typeof CONSOLE_AUTH_FLAGS & typeof OPENAPI_AUTH_FLAGS>;
1095
+ /** 该命令可见的凭证域 flag 定义。 */
1096
+ declare function credentialFlagDefs(cmd: {
1097
+ auth: AuthRequirement;
1098
+ }): FlagsDef;
1099
+ /**
1100
+ * What a command's `run` receives: `client` for all network calls (its
1101
+ * credential is already injected per the command's `auth`), `settings` for the
1102
+ * resolved configuration surface, `identity` for product identity, and `flags`
1103
+ * for parsed arguments. Never handle tokens or baseUrl.
1104
+ */
1105
+ interface CommandContext<F extends FlagsDef = FlagsDef> {
1106
+ /** 静态产品身份(binName/version/npmPackage/clientName)。 */
1107
+ identity: Identity;
1108
+ /** flag/env/file 解析后的有效配置面。 */
1109
+ settings: Settings;
1110
+ /** 只含本命令声明的 flag;全局 flag 经 settings 读。 */
1111
+ flags: ParsedFlags<F>;
1112
+ /** Network surface; the credential for the command's `auth` is pre-injected. */
1113
+ client: Client;
1114
+ /** 配置持久化能力;lint 限定 commands/config/** 使用。 */
1115
+ configStore: ConfigStore;
1116
+ /** 鉴权持久化能力;lint 限定 commands/auth/** 使用。 */
1117
+ authStore: AuthStore;
1118
+ /** Command Pack 管理能力;lint 限定 commands/plugin/** 使用。 */
1119
+ commandPacks: CommandPackManager;
1120
+ }
1121
+ /**
1122
+ * A command. Generic over its flags `F` so `run`/`validate` receive precisely
1123
+ * typed flags (`ParsedFlags<F>` = 命令自有 flag). Stored heterogeneously as
1124
+ * {@link AnyCommand}; the precise typing lives at the `defineCommand` call site.
1125
+ */
1126
+ interface Command<F extends FlagsDef = FlagsDef> {
1127
+ description: string;
1128
+ /** Credential this command requires. See {@link AuthRequirement}. */
1129
+ auth: AuthRequirement;
1130
+ /** Usage line arg portion, e.g. "--prompt <text> [flags]". Manually written. */
1131
+ usageArgs?: string;
1132
+ /** Example arg strings (without the `<bin> <path>` prefix). */
1133
+ exampleArgs?: string[];
1134
+ notes?: string[];
1135
+ flags?: F;
1136
+ /**
1137
+ * Cross-flag validation, after parsing and before run. Return an error message
1138
+ * → UsageError; undefined to pass. Single-flag `required` is enforced by the
1139
+ * parser — use this for rules spanning flags or depending on a flag's *value*.
1140
+ */
1141
+ validate?: (flags: ParsedFlags<F>) => string | undefined;
1142
+ run: (ctx: CommandContext<F>) => Promise<void>;
1143
+ }
1144
+ /** Type-erased command for heterogeneous storage (registry / context). */
1145
+ type AnyCommand = Command<any>;
1146
+ /** Identity wrapper whose only job is to infer `F` from `spec.flags`. */
1147
+ declare function defineCommand<F extends FlagsDef>(spec: Command<F>): Command<F>;
1148
+ //#endregion
1149
+ //#region src/config/loader.d.ts
1150
+ declare function readConfigFile(): ConfigFile;
1151
+ declare function writeConfigFile(data: Record<string, unknown>): Promise<void>;
1152
+ /**
1153
+ * 解析的三个来源,dispatch 边界一次构建。flags 收 Partial:ParsedFlags 里 switch 是
1154
+ * 必填 boolean,收 Partial 让 pipeline 等无 flag 场景传 {} 即可。
1155
+ */
1156
+ interface ResolutionSources {
1157
+ flags: Partial<SourceFlags>;
1158
+ file: ConfigFile;
1159
+ env: NodeJS.ProcessEnv;
1160
+ }
1161
+ declare function buildSources(flags: Partial<SourceFlags>): ResolutionSources;
1162
+ /**
1163
+ * 纯解析 sources → Settings(命令唯一会读的配置面)。不含身份、baseUrl、鉴权。
1164
+ * 各字段链序 flag > env > file > 默认;锁定表 tests/config-priority.test.ts。
1165
+ */
1166
+ declare function buildSettings(s: ResolutionSources): Settings;
1167
+ //#endregion
1168
+ //#region src/auth/resolver.d.ts
1169
+ /** Model-domain baseUrl(flag > env > file > cn)——无需 key 也可解析;login 验证等用。 */
1170
+ declare function resolveModelBaseUrl(s: ResolutionSources): string;
1171
+ /**
1172
+ * Model-domain credential from sources. Priority: `--api-key` flag >
1173
+ * `DASHSCOPE_API_KEY` env > config.json `api_key`. baseUrl: flag > env > file > cn.
1174
+ */
1175
+ declare function resolveApiKey(s: ResolutionSources): ApiKeyCredential;
1176
+ /** Console-domain credential from sources — access token + 连接目标(flag > file > 默认)。 */
1177
+ declare function resolveConsole(s: ResolutionSources): ConsoleCredential;
1178
+ /** Alibaba Cloud OpenAPI AK/SK credential. Priority: flags > env > config. */
1179
+ declare function resolveOpenApi(s: ResolutionSources): OpenApiCredential;
1180
+ /** Full auth snapshot from sources — what would resolve per domain (or undefined). */
1181
+ declare function describeAuthState(s: ResolutionSources): AuthState;
1182
+ //#endregion
1183
+ //#region src/client/endpoints.d.ts
1184
+ declare function chatPath(): string;
1185
+ declare function imagePath(): string;
1186
+ declare function imageSyncPath(): string;
1187
+ declare function videoGeneratePath(): string;
1188
+ declare function taskPath(taskId: string): string;
1189
+ declare function appCompletionPath(appId: string): string;
1190
+ declare function memoryAddPath(): string;
1191
+ declare function memorySearchPath(): string;
1192
+ declare function memoryListPath(): string;
1193
+ declare function memoryNodePath(nodeId: string): string;
1194
+ declare function speechSynthesizePath(): string;
1195
+ declare function speechRecognizePath(): string;
1196
+ declare function profileSchemaPath(): string;
1197
+ declare function userProfilePath(schemaId: string): string;
1198
+ declare function knowledgeRetrievePath(): string;
1199
+ declare function knowledgeSearchEndpoint(workspaceId: string): string;
1200
+ declare function knowledgeChatEndpoint(workspaceId: string): string;
1201
+ declare function mcpWebSearchPath(): string;
1202
+ //#endregion
1203
+ //#region src/client/headers.d.ts
1204
+ /**
1205
+ * Shared HTTP request headers for all outgoing requests.
1206
+ *
1207
+ * Centralises the `x-dashscope-source-config` header so every fetch call
1208
+ * (both via the central http client and the bypass paths) uses the
1209
+ * same values from a single source of truth.
1210
+ */
1211
+ declare const CHANNEL = "bailian-cli";
1212
+ declare const TAGS: {
1213
+ t1: string;
1214
+ t2: string;
1215
+ };
1216
+ declare const SOURCE_CONFIG: string;
1217
+ /** Standard tracking headers required on every outbound request. */
1218
+ declare function trackingHeaders(): Record<string, string>;
1219
+ //#endregion
877
1220
  //#region src/client/stream.d.ts
878
1221
  interface ServerSentEvent {
879
1222
  event?: string;
@@ -884,8 +1227,11 @@ declare function parseSSE(response: Response): AsyncGenerator<ServerSentEvent>;
884
1227
  //#endregion
885
1228
  //#region src/console/gateway.d.ts
886
1229
  type ConsoleSite = "domestic" | "international";
887
- /** Resolved console gateway settings (same defaults as {@link callConsoleGateway}). */
888
- declare function effectiveConsoleGatewayConfig(config: Config): {
1230
+ /**
1231
+ * Resolved console gateway settings (same defaults as {@link callConsoleGateway}).
1232
+ * 参数只需 settings 的 console 三元组;dry-run 展示分支直接传 settings。
1233
+ */
1234
+ declare function effectiveConsoleGatewayConfig(config: Pick<Settings, "consoleRegion" | "consoleSite" | "consoleSwitchAgent">): {
889
1235
  consoleRegion: string;
890
1236
  consoleSite: ConsoleSite;
891
1237
  consoleSwitchAgent?: number;
@@ -894,28 +1240,29 @@ interface ConsoleGatewayRequest {
894
1240
  /** Console API name, e.g. zeldaEasy.broadscope-bailian.freeTrial.queryFreeTierQuota */
895
1241
  api: string;
896
1242
  data: Record<string, unknown>;
897
- /** Console region (e.g. cn-beijing, ap-southeast-1). Falls back to config.consoleRegion, then "cn-beijing". */
898
- region?: string;
899
- /** Console site. Falls back to config.consoleSite, then "domestic". */
900
- site?: ConsoleSite;
901
- /** Switch-agent UID for delegated access. Falls back to config.consoleSwitchAgent. */
902
- switchAgent?: number;
903
1243
  }
904
1244
  /**
905
1245
  * Invoke a Bailian **console** OpenAPI via the CLI gateway (`/cli/api.json`).
906
- * `token` is the console `access_token` (from `bl auth login --console`); when
907
- * omitted the request is sent without an Authorization header, which works for
908
- * public console APIs that don't require a login session.
909
- *
910
- * Gateway URL and action are resolved from `region + site` via {@link REGION_GATEWAYS}.
911
- * Each parameter falls back to the corresponding config value, then to a hardcoded default.
1246
+ * 目标(region/site/switchAgent)与 token 均由调用方解析后传入:Client.console
1247
+ * ConsoleCredential;公共目录类 API(如 advisor 的模型目录)可不带 token 匿名调用。
912
1248
  */
913
- declare function callConsoleGateway(config: Config, token: string | undefined, {
1249
+ interface ConsoleGatewayTarget {
1250
+ region: string;
1251
+ site: ConsoleSite;
1252
+ switchAgent?: number;
1253
+ token?: string;
1254
+ }
1255
+ declare function callConsoleGateway(target: ConsoleGatewayTarget, timeoutSec: number, {
914
1256
  api,
915
1257
  data
916
1258
  }: ConsoleGatewayRequest): Promise<unknown>;
917
1259
  //#endregion
918
1260
  //#region src/console/models.d.ts
1261
+ declare const MODEL_LIST_API = "zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels";
1262
+ declare const PREDICT_CONFIG_API = "zeldaEasy.bmp.modelPredictRpcService.getPredictParamConfig";
1263
+ type ConsoleCall = (api: string, data: Record<string, unknown>) => Promise<unknown>;
1264
+ /** Unwrap the DataV2 double-envelope that console gateway returns. */
1265
+ declare function unwrapResponse(result: Record<string, unknown>): Record<string, unknown>;
919
1266
  interface ModelListParams {
920
1267
  pageNo?: number;
921
1268
  pageSize?: number;
@@ -927,32 +1274,70 @@ interface ModelListResult {
927
1274
  total: number;
928
1275
  models: Record<string, unknown>[];
929
1276
  }
930
- declare function fetchModelList(config: Config, token: string, params?: ModelListParams): Promise<ModelListResult>;
931
- //#endregion
932
- //#region src/types/flags.d.ts
933
- interface GlobalFlags {
934
- apiKey?: string;
935
- baseUrl?: string;
936
- output?: string;
937
- quiet: boolean;
938
- verbose: boolean;
939
- timeout?: number;
940
- noColor: boolean;
941
- yes: boolean;
942
- dryRun: boolean;
943
- help: boolean;
944
- nonInteractive: boolean;
945
- async: boolean;
946
- consoleRegion?: string;
947
- consoleSite?: string;
948
- consoleSwitchAgent?: number;
1277
+ /** Page the console model-list API. `call` makes the gateway request (e.g. `client.console`). */
1278
+ declare function fetchModelList(call: ConsoleCall, params?: ModelListParams): Promise<ModelListResult>;
1279
+ interface ModelPriceInfo {
1280
+ type?: string;
1281
+ priceUnit?: string;
1282
+ price?: string | number;
949
1283
  [key: string]: unknown;
950
1284
  }
951
- //#endregion
952
- //#region src/config/loader.d.ts
953
- declare function readConfigFile(): ConfigFile;
954
- declare function writeConfigFile(data: Record<string, unknown>): Promise<void>;
955
- declare function loadConfig(flags: GlobalFlags): Config;
1285
+ interface ModelGroupItem {
1286
+ model: string;
1287
+ name: string;
1288
+ description?: string;
1289
+ shortDescription?: string;
1290
+ provider?: string;
1291
+ capabilities?: string[];
1292
+ features?: string[];
1293
+ contextWindow?: number;
1294
+ maxOutputTokens?: number;
1295
+ maxInputTokens?: number;
1296
+ inferenceMetadata?: Record<string, unknown>;
1297
+ prices?: ModelPriceInfo[];
1298
+ qpmInfo?: Record<string, Record<string, unknown>>;
1299
+ docUrl?: string;
1300
+ versionTag?: string;
1301
+ openSource?: boolean;
1302
+ category?: string;
1303
+ predictConfig?: PredictConfigEntry[];
1304
+ [key: string]: unknown;
1305
+ }
1306
+ interface ModelGroup {
1307
+ model: string;
1308
+ name: string;
1309
+ description?: string;
1310
+ updateAt?: string;
1311
+ items: ModelGroupItem[];
1312
+ [key: string]: unknown;
1313
+ }
1314
+ interface ModelGroupParams {
1315
+ pageNo?: number;
1316
+ pageSize?: number;
1317
+ name?: string;
1318
+ providers?: string[];
1319
+ capabilities?: string[];
1320
+ features?: string[];
1321
+ contextWindows?: string[];
1322
+ querySampleCode?: boolean;
1323
+ }
1324
+ interface ModelGroupResult {
1325
+ total: number;
1326
+ groups: ModelGroup[];
1327
+ }
1328
+ /** Fetch model families with optional filters and query flags. */
1329
+ declare function fetchModelGroups(call: ConsoleCall, params?: ModelGroupParams): Promise<ModelGroupResult>;
1330
+ /** Fetch a single model family with all detail flags enabled. */
1331
+ declare function fetchModelDetail(call: ConsoleCall, modelKey: string): Promise<ModelGroup | null>;
1332
+ interface PredictConfigEntry {
1333
+ name: string;
1334
+ key: string;
1335
+ default?: unknown;
1336
+ tip?: string;
1337
+ range?: unknown;
1338
+ }
1339
+ /** Fetch the input parameter schema for a specific model. */
1340
+ declare function fetchPredictConfig(call: ConsoleCall, modelId: string): Promise<PredictConfigEntry[] | null>;
956
1341
  //#endregion
957
1342
  //#region src/config/paths.d.ts
958
1343
  declare function getConfigDir(): string;
@@ -1108,7 +1493,7 @@ interface DatasetUploadParams {
1108
1493
  * `Response`'s helper to avoid the buffer doubling. Fall back to readFileSync
1109
1494
  * for small files where streaming overhead isn't worth it.
1110
1495
  */
1111
- declare function uploadDataset(config: Config, params: DatasetUploadParams): Promise<DatasetFile>;
1496
+ declare function uploadDataset(client: Client, params: DatasetUploadParams): Promise<DatasetFile>;
1112
1497
  interface DatasetListParams {
1113
1498
  pageNo?: number;
1114
1499
  pageSize?: number;
@@ -1116,11 +1501,11 @@ interface DatasetListParams {
1116
1501
  signal?: AbortSignal;
1117
1502
  }
1118
1503
  /** GET /api/v1/files */
1119
- declare function listDatasets(config: Config, params?: DatasetListParams): Promise<DatasetListResponse>;
1504
+ declare function listDatasets(client: Client, params?: DatasetListParams): Promise<DatasetListResponse>;
1120
1505
  /** GET /api/v1/files/{file_id} */
1121
- declare function getDataset(config: Config, fileId: string, signal?: AbortSignal): Promise<DatasetGetResponse>;
1506
+ declare function getDataset(client: Client, fileId: string, signal?: AbortSignal): Promise<DatasetGetResponse>;
1122
1507
  /** DELETE /api/v1/files/{file_id} */
1123
- declare function deleteDataset(config: Config, fileId: string, signal?: AbortSignal): Promise<DatasetDeleteResponse>;
1508
+ declare function deleteDataset(client: Client, fileId: string, signal?: AbortSignal): Promise<DatasetDeleteResponse>;
1124
1509
  //#endregion
1125
1510
  //#region src/dataset/validate/types.d.ts
1126
1511
  /**
@@ -1156,9 +1541,15 @@ interface ValidateOpts {
1156
1541
  * platform ten minutes in.
1157
1542
  */
1158
1543
  schema?: DatasetSchema;
1544
+ /**
1545
+ * Model identifier (`--model`) forwarded for schema-agnostic cross-checks —
1546
+ * e.g. the video validator uses it to verify a `kf2v` model is paired with
1547
+ * first+last-frame data. Optional: absent for bare file-id flows.
1548
+ */
1549
+ model?: string;
1159
1550
  }
1160
1551
  /** The schemas a `.jsonl` record can be validated against. */
1161
- type DatasetSchema = "chatml" | "dpo" | "cpt";
1552
+ type DatasetSchema = "chatml" | "dpo" | "cpt" | "tts" | "image" | "video";
1162
1553
  type ValidationSeverity = "error" | "warning";
1163
1554
  interface ValidationIssue {
1164
1555
  severity: ValidationSeverity;
@@ -1198,6 +1589,78 @@ interface ValidatorSpec {
1198
1589
  validate(filePath: string, opts: ValidateOpts): Promise<ValidationResult>;
1199
1590
  }
1200
1591
  //#endregion
1592
+ //#region src/finetune/profiles/types.d.ts
1593
+ /**
1594
+ * Data modality detected by the inspector from file content.
1595
+ *
1596
+ * The inspector peeks at the first record of a JSONL or the `data.jsonl` inside
1597
+ * a ZIP to determine what kind of data the file carries. This is orthogonal to
1598
+ * the training type — `sft-lora` accepts both `.jsonl` (text) and `.zip`
1599
+ * (audio / image / video).
1600
+ *
1601
+ * `"image-i2i"` is a subtype of `"image"` — the first record contains an
1602
+ * `input_img` field (image-to-image). `"video-kf2v"` is a subtype of `"video"`
1603
+ * — the first record contains a `last_frame_path` field (first+last-frame video,
1604
+ * Wan kf2v). Profiles can branch on subtypes to adjust hyper-parameter defaults
1605
+ * or cross-check the chosen `--model`. Callers that don't care about a subtype
1606
+ * can normalise `"image-i2i"` → `"image"` and `"video-kf2v"` → `"video"`.
1607
+ */
1608
+ type DataModality = "text" | "audio" | "image" | "image-i2i" | "video" | "video-kf2v";
1609
+ /**
1610
+ * A training profile. One per `--training-type` CLI value.
1611
+ *
1612
+ * The profile owns all modality-specific branching internally — callers
1613
+ * (`create.ts`) interact with it through a uniform interface and never need
1614
+ * to know whether the data is text, audio, or something else.
1615
+ */
1616
+ interface TrainingProfile {
1617
+ /** CLI vocabulary: the value users pass to `--training-type`. */
1618
+ clientTrainingType: string;
1619
+ /** Server `training_type` for the POST /fine-tunes request body. */
1620
+ serverTrainingType: string;
1621
+ /** File extensions this profile accepts (lower-case, with dot). */
1622
+ acceptedExtensions: string[];
1623
+ /**
1624
+ * Validate the training data file. The profile internally routes to the
1625
+ * correct validator based on `modality` (detected by the data inspector).
1626
+ */
1627
+ validate(filePath: string, modality: DataModality, opts: ValidateOpts): Promise<ValidationResult>;
1628
+ /**
1629
+ * Build the `hyper_parameters` object for the API request. Merges user-supplied
1630
+ * flags with modality-specific defaults (e.g. audio TTS uses `lm_max_epoch` /
1631
+ * `fm_max_epoch`, text SFT uses `n_epochs` / `batch_size`).
1632
+ */
1633
+ resolveHyperParameters(modality: DataModality, flags: Record<string, unknown>): Record<string, unknown>;
1634
+ /**
1635
+ * Whether a specific pre-flight gate should be skipped for the given modality.
1636
+ * Common gates: `"batch_size"` (samples must exceed batch_size), etc.
1637
+ * Audio TTS skips the batch-size gate (no batch_size hyper-parameter).
1638
+ */
1639
+ shouldSkipGate(gate: string, modality: DataModality): boolean;
1640
+ /**
1641
+ * Whether the model-capability pre-flight check should be skipped.
1642
+ * Audio models (e.g. cosyvoice-v3-flash) report `supports.sft = false` in
1643
+ * `listFoundationModels` but the API accepts `efficient_sft` — the check
1644
+ * would incorrectly block the submission.
1645
+ */
1646
+ shouldSkipCapabilityCheck(modality: DataModality): boolean;
1647
+ }
1648
+ //#endregion
1649
+ //#region src/dataset/inspect.d.ts
1650
+ /**
1651
+ * Inspect a file and return its data modality.
1652
+ *
1653
+ * `.jsonl` → read the first non-blank line, parse JSON, check fields.
1654
+ * `.zip` → locate `data.jsonl` inside the archive, read its first line.
1655
+ *
1656
+ * Image data returns `"image"` (T2I) or `"image-i2i"` (I2I, first record
1657
+ * has `input_img`). Callers that don't distinguish can normalise to `"image"`.
1658
+ *
1659
+ * Throws USAGE if the file extension is not `.jsonl` or `.zip`, or if the
1660
+ * content cannot be parsed.
1661
+ */
1662
+ declare function detectModality(filePath: string): Promise<DataModality>;
1663
+ //#endregion
1201
1664
  //#region src/dataset/validate/registry.d.ts
1202
1665
  /** Lookup the validator that handles a given file extension. */
1203
1666
  declare function pickValidator(filePath: string): ValidatorSpec;
@@ -1221,6 +1684,12 @@ declare function listSupportedFormats(): {
1221
1684
  * raises the cap or differentiates per-purpose limits.
1222
1685
  */
1223
1686
  declare const MAX_DATASET_BYTES: number;
1687
+ /**
1688
+ * Image / video ZIP size cap — 1 GB per the platform docs (vs 300 MB for
1689
+ * text / audio). Used by `bl dataset upload` for media schemas and by the
1690
+ * `sft-lora` training profile for image / video validation.
1691
+ */
1692
+ declare const MAX_MEDIA_ZIP_BYTES: number;
1224
1693
  /**
1225
1694
  * Parse a `--schema` CLI value into a `DatasetSchema` (or `undefined` for
1226
1695
  * auto-detect). Single source of truth for the schema vocabulary so `dataset
@@ -1433,7 +1902,7 @@ interface GetFineTuneResponse {
1433
1902
  //#endregion
1434
1903
  //#region src/finetune/api.d.ts
1435
1904
  /** POST /api/v1/fine-tunes */
1436
- declare function createFineTune(config: Config, body: CreateFineTuneRequest, signal?: AbortSignal): Promise<CreateFineTuneResponse>;
1905
+ declare function createFineTune(client: Client, body: CreateFineTuneRequest, signal?: AbortSignal): Promise<CreateFineTuneResponse>;
1437
1906
  interface ListFineTunesParams {
1438
1907
  pageNo?: number;
1439
1908
  pageSize?: number;
@@ -1441,30 +1910,30 @@ interface ListFineTunesParams {
1441
1910
  signal?: AbortSignal;
1442
1911
  }
1443
1912
  /** GET /api/v1/fine-tunes */
1444
- declare function listFineTunes(config: Config, params?: ListFineTunesParams): Promise<ListFineTunesResponse>;
1913
+ declare function listFineTunes(client: Client, params?: ListFineTunesParams): Promise<ListFineTunesResponse>;
1445
1914
  /** GET /api/v1/fine-tunes/{job_id} */
1446
- declare function getFineTune(config: Config, jobId: string, signal?: AbortSignal): Promise<GetFineTuneResponse>;
1915
+ declare function getFineTune(client: Client, jobId: string, signal?: AbortSignal): Promise<GetFineTuneResponse>;
1447
1916
  /** POST /api/v1/fine-tunes/{job_id}/cancel */
1448
- declare function cancelFineTune(config: Config, jobId: string, signal?: AbortSignal): Promise<CancelFineTuneResponse>;
1917
+ declare function cancelFineTune(client: Client, jobId: string, signal?: AbortSignal): Promise<CancelFineTuneResponse>;
1449
1918
  /** DELETE /api/v1/fine-tunes/{job_id} */
1450
- declare function deleteFineTune(config: Config, jobId: string, signal?: AbortSignal): Promise<DeleteFineTuneResponse>;
1919
+ declare function deleteFineTune(client: Client, jobId: string, signal?: AbortSignal): Promise<DeleteFineTuneResponse>;
1451
1920
  interface GetFineTuneLogsParams {
1452
1921
  pageNo?: number;
1453
1922
  pageSize?: number;
1454
1923
  signal?: AbortSignal;
1455
1924
  }
1456
1925
  /** GET /api/v1/fine-tunes/{job_id}/logs */
1457
- declare function getFineTuneLogs(config: Config, jobId: string, params?: GetFineTuneLogsParams): Promise<GetFineTuneLogsResponse>;
1926
+ declare function getFineTuneLogs(client: Client, jobId: string, params?: GetFineTuneLogsParams): Promise<GetFineTuneLogsResponse>;
1458
1927
  /** GET /api/v1/fine-tunes/{job_id}/checkpoints */
1459
- declare function listCheckpoints(config: Config, jobId: string, signal?: AbortSignal): Promise<ListCheckpointsResponse>;
1928
+ declare function listCheckpoints(client: Client, jobId: string, signal?: AbortSignal): Promise<ListCheckpointsResponse>;
1460
1929
  /**
1461
1930
  * GET /api/v1/fine-tunes/{job_id}/export/{checkpoint}?model_name={name}
1462
1931
  *
1463
1932
  * Publishes a training checkpoint as a deployable model — required before
1464
- * `bl deploy create` can target it. The platform may auto-export the best
1933
+ * `deploy <modality> create` can target it. The platform may auto-export the best
1465
1934
  * checkpoint on SUCCEEDED, but explicit export is the canonical path.
1466
1935
  */
1467
- declare function exportCheckpoint(config: Config, jobId: string, checkpoint: string, modelName: string, signal?: AbortSignal): Promise<ExportCheckpointResponse>;
1936
+ declare function exportCheckpoint(client: Client, jobId: string, checkpoint: string, modelName: string, signal?: AbortSignal): Promise<ExportCheckpointResponse>;
1468
1937
  //#endregion
1469
1938
  //#region src/finetune/capability.d.ts
1470
1939
  /**
@@ -1531,8 +2000,6 @@ interface ModelCapability {
1531
2000
  }
1532
2001
  /** True when `value` is one of the accepted CLI training types. */
1533
2002
  declare function isTrainingTypeCli(value: string): value is TrainingTypeCli;
1534
- /** Map a CLI training type to the server `training_type` for the request body. */
1535
- declare function toServerTrainingType(value: TrainingTypeCli): string;
1536
2003
  /** The (method, variant) pair a CLI training type resolves to. */
1537
2004
  declare function trainingTypeMethodVariant(value: TrainingTypeCli): {
1538
2005
  method: string;
@@ -1562,7 +2029,7 @@ declare function listSupportedTrainingTypes(model: ModelCapability | undefined |
1562
2029
  * server's `name` filter is a substring match, so we additionally require an
1563
2030
  * exact `model` equality to avoid e.g. `qwen3-8b` matching `qwen3-8b-v2`).
1564
2031
  */
1565
- declare function fetchModelCapability(config: Config, modelName: string): Promise<ModelCapability | null>;
2032
+ declare function fetchModelCapability(settings: Settings, modelName: string): Promise<ModelCapability | null>;
1566
2033
  //#endregion
1567
2034
  //#region src/finetune/preflight.d.ts
1568
2035
  /** Stable issue code for "too few training samples for the batch size". */
@@ -1606,6 +2073,12 @@ interface BatchSizeGateResult {
1606
2073
  */
1607
2074
  declare function preflightBatchSizeGate(input: BatchSizeGateInput): BatchSizeGateResult;
1608
2075
  //#endregion
2076
+ //#region src/finetune/profiles/registry.d.ts
2077
+ /** Look up a profile by its CLI training-type name. Throws USAGE if unknown. */
2078
+ declare function getProfile(clientTrainingType: string): TrainingProfile;
2079
+ /** All registered CLI training-type names (for help text / whitelisting). */
2080
+ declare function listTrainingTypes(): string[];
2081
+ //#endregion
1609
2082
  //#region src/deploy/types.d.ts
1610
2083
  /**
1611
2084
  * Model-deployment API types.
@@ -1724,8 +2197,8 @@ interface CreateDeploymentRequest {
1724
2197
  plan: string;
1725
2198
  /** Required by API even for token-billed (lora) plans where it is ignored — CLI injects 1. */
1726
2199
  capacity?: number;
1727
- /** Optional template id for advanced configurations. */
1728
- template_id?: string;
2200
+ /** Deploy spec id (e.g. "MU1", "dps-..."), sent as `deploy_spec` in POST body. */
2201
+ deploy_spec?: string;
1729
2202
  /**
1730
2203
  * PTU capacity (provisioned throughput limits). Only effective when
1731
2204
  * `plan === "ptu"`. The doc says this defaults to 10000/1000 when omitted,
@@ -1733,9 +2206,27 @@ interface CreateDeploymentRequest {
1733
2206
  * info"), so the CLI treats it as required for ptu.
1734
2207
  */
1735
2208
  ptu_capacity?: PtuCapacity;
2209
+ /**
2210
+ * AIGC generation config for fine-tuned Wan video (i2v/kf2v) LoRA deployments.
2211
+ * Ignored by non-video plans. See `AigcConfig`.
2212
+ */
2213
+ aigc_config?: AigcConfig;
1736
2214
  /** Future-compat: arbitrary additional fields are forwarded as-is. */
1737
2215
  [k: string]: unknown;
1738
2216
  }
2217
+ /**
2218
+ * AIGC generation config — used when deploying fine-tuned Wan video (i2v/kf2v)
2219
+ * LoRA models. Controls how prompts are applied at inference time:
2220
+ * - use_input_prompt=false: ignore the caller's prompt, use the preset
2221
+ * `prompt` template instead (the common LoRA case).
2222
+ * - use_input_prompt=true: honor the caller's prompt.
2223
+ * `lora_prompt_default` is the default trigger-word phrase appended for the LoRA.
2224
+ */
2225
+ interface AigcConfig {
2226
+ use_input_prompt?: boolean;
2227
+ prompt?: string;
2228
+ lora_prompt_default?: string;
2229
+ }
1739
2230
  /** PTU throughput limits — only used when `plan === "ptu"`. */
1740
2231
  interface PtuCapacity {
1741
2232
  /** Max input tokens per minute (all models). */
@@ -1843,7 +2334,7 @@ interface UpdateDeploymentResponse {
1843
2334
  //#endregion
1844
2335
  //#region src/deploy/api.d.ts
1845
2336
  /** POST /api/v1/deployments */
1846
- declare function createDeployment(config: Config, body: CreateDeploymentRequest, signal?: AbortSignal): Promise<CreateDeploymentResponse>;
2337
+ declare function createDeployment(client: Client, body: CreateDeploymentRequest, signal?: AbortSignal): Promise<CreateDeploymentResponse>;
1847
2338
  interface ListDeploymentsParams {
1848
2339
  pageNo?: number;
1849
2340
  pageSize?: number;
@@ -1851,11 +2342,11 @@ interface ListDeploymentsParams {
1851
2342
  signal?: AbortSignal;
1852
2343
  }
1853
2344
  /** GET /api/v1/deployments */
1854
- declare function listDeployments(config: Config, params?: ListDeploymentsParams): Promise<ListDeploymentsResponse>;
2345
+ declare function listDeployments(client: Client, params?: ListDeploymentsParams): Promise<ListDeploymentsResponse>;
1855
2346
  /** GET /api/v1/deployments/{deployed_model} */
1856
- declare function getDeployment(config: Config, deployedModel: string, signal?: AbortSignal): Promise<GetDeploymentResponse>;
2347
+ declare function getDeployment(client: Client, deployedModel: string, signal?: AbortSignal): Promise<GetDeploymentResponse>;
1857
2348
  /** DELETE /api/v1/deployments/{deployed_model} */
1858
- declare function deleteDeployment(config: Config, deployedModel: string, signal?: AbortSignal): Promise<DeleteDeploymentResponse>;
2349
+ declare function deleteDeployment(client: Client, deployedModel: string, signal?: AbortSignal): Promise<DeleteDeploymentResponse>;
1859
2350
  interface ListDeployableModelsParams {
1860
2351
  pageNo?: number;
1861
2352
  pageSize?: number;
@@ -1866,57 +2357,165 @@ interface ListDeployableModelsParams {
1866
2357
  signal?: AbortSignal;
1867
2358
  }
1868
2359
  /** GET /api/v1/deployments/models */
1869
- declare function listDeployableModels(config: Config, params?: ListDeployableModelsParams): Promise<ListDeployableModelsResponse>;
2360
+ declare function listDeployableModels(client: Client, params?: ListDeployableModelsParams): Promise<ListDeployableModelsResponse>;
1870
2361
  /** PUT /api/v1/deployments/{deployed_model}/scale */
1871
- declare function scaleDeployment(config: Config, deployedModel: string, body: ScaleDeploymentRequest, signal?: AbortSignal): Promise<ScaleDeploymentResponse>;
2362
+ declare function scaleDeployment(client: Client, deployedModel: string, body: ScaleDeploymentRequest, signal?: AbortSignal): Promise<ScaleDeploymentResponse>;
1872
2363
  /**
1873
2364
  * PUT /api/v1/deployments/{deployed_model}/update
1874
2365
  *
1875
2366
  * Update rate limits. At least one of `rpm_limit` / `tpm_limit` must be set.
1876
2367
  */
1877
- declare function updateDeployment(config: Config, deployedModel: string, body: UpdateDeploymentRequest, signal?: AbortSignal): Promise<UpdateDeploymentResponse>;
2368
+ declare function updateDeployment(client: Client, deployedModel: string, body: UpdateDeploymentRequest, signal?: AbortSignal): Promise<UpdateDeploymentResponse>;
1878
2369
  //#endregion
1879
- //#region src/types/command.d.ts
1880
- interface OptionDef {
1881
- flag: string;
1882
- description: string;
1883
- type?: "string" | "number" | "boolean" | "array";
1884
- required?: boolean;
2370
+ //#region src/deploy/constants.d.ts
2371
+ /**
2372
+ * Deploy-domain constants — billing plans, billing methods and template
2373
+ * charge types. Centralised here so no `deploy` command carries a magic
2374
+ * string for these server-contract values.
2375
+ */
2376
+ /** Billing plan (`--plan` value, matches the server's deployment plan). */
2377
+ declare const DEPLOY_PLAN: {
2378
+ /** Token-billed; the CLI default. */readonly LORA: "lora"; /** Token-billed, provisioned throughput. */
2379
+ readonly PTU: "ptu"; /** Model-unit-billed. */
2380
+ readonly MU: "mu";
2381
+ };
2382
+ type DeployPlan = (typeof DEPLOY_PLAN)[keyof typeof DEPLOY_PLAN];
2383
+ /** CLI default plan when `--plan` is omitted. */
2384
+ declare const DEFAULT_DEPLOY_PLAN: DeployPlan;
2385
+ /** Deployment target modality — fixes the default plan when `--plan` is omitted. */
2386
+ type DeployModality = "text" | "audio" | "image";
2387
+ /**
2388
+ * Default plan per modality when `--plan` is omitted.
2389
+ *
2390
+ * The contract differs by modality (verified against the DashScope docs):
2391
+ * - text / image LoRA outputs deploy Token-billed (`lora`) — the image
2392
+ * fine-tune guide's deploy example uses `plan: "lora"`.
2393
+ * - CosyVoice (audio TTS) outputs deploy model-unit-billed (`mu`) — the
2394
+ * speech-synthesis guide fixes `plan: "mu"` and requires deploy_spec /
2395
+ * capacity / billing_method (all auto-picked by the mu strategy).
2396
+ */
2397
+ declare function defaultDeployPlan(modality: DeployModality): DeployPlan;
2398
+ /** Billing method (`billing_method`, plan=mu only). */
2399
+ declare const BILLING_METHOD: {
2400
+ /** Post-paid (currently the only server-supported value). */readonly POST_PAY: "POST_PAY"; /** Pre-paid. */
2401
+ readonly PRE_PAY: "PRE_PAY";
2402
+ };
2403
+ type BillingMethod = (typeof BILLING_METHOD)[keyof typeof BILLING_METHOD];
2404
+ /** Default billing method for plan=mu when `--billing-method` is omitted. */
2405
+ declare const DEFAULT_BILLING_METHOD: BillingMethod;
2406
+ /** Template charge type (`charge_type`) returned by the deployable-models catalog. */
2407
+ declare const CHARGE_TYPE: {
2408
+ readonly POST_PAID: "post_paid";
2409
+ readonly PRE_PAID: "pre_paid";
2410
+ };
2411
+ type ChargeType = (typeof CHARGE_TYPE)[keyof typeof CHARGE_TYPE];
2412
+ //#endregion
2413
+ //#region src/deploy/plans.d.ts
2414
+ /** Plan-relevant subset of `deploy <modality> create` flags (parsed flags satisfy this shape). */
2415
+ interface CreatePlanFlags {
2416
+ plan?: string;
2417
+ deploySpec?: string;
2418
+ capacity?: number;
2419
+ billingMethod?: string;
2420
+ inputTpm?: number;
2421
+ outputTpm?: number;
2422
+ thinkingOutputTpm?: number;
2423
+ }
2424
+ interface PlanContext {
2425
+ client: Client;
2426
+ /** True in --dry-run: strategies must skip side-effecting catalog lookups. */
2427
+ dryRun: boolean;
2428
+ /** CLI bin name, for usage hints in error messages. */
2429
+ binName: string;
2430
+ flags: CreatePlanFlags;
2431
+ /** Underlying model identifier (`--model`). */
2432
+ model: string;
2433
+ /** Console display name (`--name`). */
2434
+ name: string;
1885
2435
  }
1886
- interface Command {
1887
- description: string;
2436
+ interface PlanResolved {
1888
2437
  /**
1889
- * Argument portion of the usage line, WITHOUT the `<bin> <path>` prefix
1890
- * (e.g. "--index-id <id> --query <text> [flags]"). The runtime prepends the
1891
- * product binary name and the command's actual path when rendering help, so
1892
- * the same command renders correctly under any product (bl / rag / …).
2438
+ * Plan-specific fields to merge into the request body. The shared envelope
2439
+ * (`{model_name, name, plan}`) is added by the caller.
1893
2440
  */
1894
- usageArgs?: string;
1895
- options?: OptionDef[];
2441
+ body: Record<string, unknown>;
2442
+ }
2443
+ interface PlanStrategy {
2444
+ /** Plan id, matches `--plan` CLI value. */
2445
+ name: string;
2446
+ /** Returns an error message when required flags are missing; undefined to pass. */
2447
+ validateFlags(flags: CreatePlanFlags): string | undefined;
1896
2448
  /**
1897
- * Example argument strings, each WITHOUT the `<bin> <path>` prefix
1898
- * (e.g. '--index-id idx_xxx --query "..."'). The runtime prepends
1899
- * `<bin> <path>` per product when rendering help.
2449
+ * Resolve plan-specific bits to a body fragment. May call into the API
2450
+ * (e.g. mu auto-picks a template from the deployable-models catalog).
1900
2451
  */
1901
- exampleArgs?: string[];
1902
- skipDefaultApiKeySetup?: boolean;
1903
- notes?: string[];
1904
- execute: (config: Config, flags: GlobalFlags) => Promise<void>;
2452
+ resolve(ctx: PlanContext): Promise<PlanResolved>;
1905
2453
  }
1906
- interface CommandSpec {
1907
- description: string;
1908
- /** See {@link Command.usageArgs} argument portion only, no `<bin> <path>` prefix. */
1909
- usageArgs?: string;
1910
- options?: OptionDef[];
1911
- /** See {@link Command.exampleArgs} — argument strings only, no `<bin> <path>` prefix. */
1912
- exampleArgs?: string[];
1913
- skipDefaultApiKeySetup?: boolean;
1914
- notes?: string[];
1915
- run: (config: Config, flags: GlobalFlags) => Promise<void>;
2454
+ /**
2455
+ * Registry of supported plans. Adding a new plan = one entry here. The
2456
+ * catalog lists some additional plan names (e.g. `ptu_v2`) that are NOT
2457
+ * accepted by the create endpoint, so the dispatcher in the command will
2458
+ * reject anything outside this table with a clear USAGE error.
2459
+ */
2460
+ declare const STRATEGIES: Record<string, PlanStrategy>;
2461
+ /** Throws USAGE if `plan` is not in the strategy table. */
2462
+ declare function pickPlanStrategy(plan: string): PlanStrategy;
2463
+ //#endregion
2464
+ //#region src/types/command-pack.d.ts
2465
+ /** Current Command Pack protocol version understood by this release. */
2466
+ declare const COMMAND_PACK_API_VERSION: 1;
2467
+ /** `package.json#bailianCli` metadata for a Command Pack package. */
2468
+ interface CommandPackMeta {
2469
+ type: "command-pack";
2470
+ apiVersion: number;
2471
+ /** ESM entry path relative to the package root. */
2472
+ entry: string;
2473
+ /** Optional minimum compatible bailian-cli version. */
2474
+ minCliVersion?: string;
2475
+ }
2476
+ /** Explicit credential delegation surface available only to trusted Command Packs. */
2477
+ interface CommandPackCredentials {
2478
+ apiKey(): ApiKeyCredential;
2479
+ }
2480
+ interface CommandPackOutputOptions {
2481
+ /** Custom text-mode representation; JSON mode always serializes the primary data. */
2482
+ text?: string;
2483
+ }
2484
+ /** Stable stdout surface supplied by the host. */
2485
+ interface CommandPackOutput {
2486
+ result(data: unknown, options?: CommandPackOutputOptions): void;
2487
+ line(value: string): void;
2488
+ write(chunk: string): void;
2489
+ }
2490
+ interface CommandPackErrorOptions {
2491
+ hint?: string;
2492
+ cause?: unknown;
2493
+ }
2494
+ /** Host-native semantic error factories; throw the returned Error. */
2495
+ interface CommandPackErrors {
2496
+ general(message: string, options?: CommandPackErrorOptions): Error;
2497
+ usage(message: string, hint?: string): Error;
2498
+ timeout(message?: string, options?: CommandPackErrorOptions): Error;
2499
+ }
2500
+ /** Stable API 1 execution context. It deliberately contains no raw credentials. */
2501
+ interface CommandPackContext<F extends FlagsDef = FlagsDef> {
2502
+ identity: Identity;
2503
+ settings: Settings;
2504
+ flags: ParsedFlags<F>;
2505
+ client: Client;
2506
+ output: CommandPackOutput;
2507
+ errors: CommandPackErrors;
2508
+ }
2509
+ /** Privileged context available only when product policy grants raw API-key access. */
2510
+ type CommandPackApiKeyContext<F extends FlagsDef = FlagsDef> = CommandPackContext<F> & {
2511
+ credentials: CommandPackCredentials;
2512
+ };
2513
+ /** Command shape exported by an API 1 Command Pack. */
2514
+ interface CommandPackCommand<F extends FlagsDef = FlagsDef, C extends CommandPackContext<F> = CommandPackContext<F>> extends Omit<Command<F>, "run"> {
2515
+ run(ctx: C): Promise<void>;
1916
2516
  }
1917
- declare function defineCommand(spec: CommandSpec): Command;
1918
- /** Global flags shared by all commands — drives the parser's type resolution. */
1919
- declare const GLOBAL_OPTIONS: OptionDef[];
2517
+ /** A Command Pack explicitly maps product command paths to command implementations. */
2518
+ type CommandPack = Record<string, CommandPackCommand<any, any>>;
1920
2519
  //#endregion
1921
2520
  //#region src/utils/filename.d.ts
1922
2521
  declare function generateFilename(prefix: string, prompt: string): string;
@@ -1933,7 +2532,7 @@ declare function generateFilename(prefix: string, prompt: string): string;
1933
2532
  * Optionally appends a subdirectory (e.g. 'images', 'videos', 'speech').
1934
2533
  * Creates the directory if it doesn't exist.
1935
2534
  */
1936
- declare function resolveOutputDir(config: Config, options?: {
2535
+ declare function resolveOutputDir(settings: Settings, options?: {
1937
2536
  flagDir?: string;
1938
2537
  subDir?: string;
1939
2538
  }): string;
@@ -1941,33 +2540,6 @@ declare function resolveOutputDir(config: Config, options?: {
1941
2540
  //#region src/utils/token.d.ts
1942
2541
  declare function maskToken(token: string): string;
1943
2542
  //#endregion
1944
- //#region src/utils/env.d.ts
1945
- /**
1946
- * Environment detection utilities for bailian-cli.
1947
- *
1948
- * Used to determine whether the CLI is running in an interactive terminal
1949
- * (human user) or in a non-interactive environment (CI, agent, pipe, etc.),
1950
- * so commands can adjust their behavior accordingly.
1951
- */
1952
- /**
1953
- * Detects whether the current environment is interactive.
1954
- *
1955
- * Returns false when:
1956
- * - stdout or stdin is not a TTY
1957
- * - The --non-interactive flag was explicitly set
1958
- * - The process is running in a known CI environment (CI env var present)
1959
- *
1960
- * Returns true when stdout and stdin are both TTYs and --non-interactive
1961
- * was not passed.
1962
- */
1963
- declare function isInteractive(options?: {
1964
- nonInteractive?: boolean;
1965
- }): boolean;
1966
- /**
1967
- * Detects whether the current process is running in a CI environment.
1968
- */
1969
- declare function isCI(): boolean;
1970
- //#endregion
1971
2543
  //#region src/utils/object.d.ts
1972
2544
  /**
1973
2545
  * Generic object-cleaning utilities.
@@ -2007,7 +2579,7 @@ interface TrackingEvent {
2007
2579
  cliVersion: string;
2008
2580
  nodeVersion: string;
2009
2581
  os: string;
2010
- authMethod?: string;
2582
+ authMethod?: AuthRequirement;
2011
2583
  params?: Record<string, unknown>;
2012
2584
  }
2013
2585
  declare function createTrackingEvent(opts: {
@@ -2020,7 +2592,7 @@ declare function createTrackingEvent(opts: {
2020
2592
  requestId?: string;
2021
2593
  };
2022
2594
  cliVersion: string;
2023
- authMethod?: string;
2595
+ authMethod?: AuthRequirement;
2024
2596
  params?: Record<string, unknown>;
2025
2597
  }): TrackingEvent;
2026
2598
  //#endregion
@@ -2040,7 +2612,13 @@ declare function localSink(event: TrackingEvent): Promise<void>;
2040
2612
  declare function remoteSink(event: TrackingEvent): Promise<void>;
2041
2613
  //#endregion
2042
2614
  //#region src/telemetry/tracker.d.ts
2043
- declare function trackCommandExecution(config: Config, commandPath: string[], flags: GlobalFlags, fn: () => Promise<void>): Promise<void>;
2615
+ /** 遥测只记录命令声明的鉴权域,不接触具体凭证能力。 */
2616
+ interface TrackingDeps {
2617
+ identity: Identity;
2618
+ settings: Settings;
2619
+ authMethod?: AuthRequirement;
2620
+ }
2621
+ declare function trackCommandExecution(deps: TrackingDeps, commandPath: string[], flags: Record<string, unknown>, fn: () => Promise<void>): Promise<void>;
2044
2622
  //#endregion
2045
2623
  //#region src/advisor/types.d.ts
2046
2624
  type Modality = "Text" | "Image" | "Video" | "Audio";
@@ -2120,6 +2698,13 @@ interface IntentProfile {
2120
2698
  segments?: IntentSegment[];
2121
2699
  taskSummary: string;
2122
2700
  scenarioHints: string[];
2701
+ /**
2702
+ * LLM-refined, self-contained English description of the need, optimized for
2703
+ * semantic matching against model descriptions. Used as the embedding query
2704
+ * for soft-track recall. Empty when intent analysis degrades (recall then
2705
+ * falls back to the raw user query).
2706
+ */
2707
+ semanticQuery: string;
2123
2708
  inputModality: Modality[];
2124
2709
  outputModality: Modality[];
2125
2710
  requiredCapabilities: Capability[];
@@ -2197,21 +2782,37 @@ type RecommendResult = SingleResult | PipelineResult;
2197
2782
  interface GetModelsOptions {
2198
2783
  onPrepareStart?: () => void;
2199
2784
  }
2200
- declare function getModels(config: Config, options?: GetModelsOptions): Promise<ModelProfile[]>;
2785
+ declare function getModels(settings: Settings, options?: GetModelsOptions): Promise<ModelProfile[]>;
2786
+ //#endregion
2787
+ //#region src/advisor/constants/scoring.d.ts
2788
+ declare const SEMANTIC_TOP_K = 20;
2201
2789
  //#endregion
2202
2790
  //#region src/advisor/intent.d.ts
2203
- declare function analyzeIntent(config: Config, input: string): Promise<IntentProfile>;
2791
+ /**
2792
+ * Analyze the user's input to produce an IntentProfile.
2793
+ *
2794
+ * Calls `qwen3.6-flash` via the OpenAI-compatible chat endpoint to extract
2795
+ * structured intent fields: taskSummary, modalities, capabilities, budget,
2796
+ * qualityPreference, modelPreference (mode/targets/excludes), and more.
2797
+ *
2798
+ * On failure, degrades gracefully to DEFAULT_INTENT with confidence 0.
2799
+ */
2800
+ declare function analyzeIntent(client: Client, input: string): Promise<IntentProfile>;
2204
2801
  //#endregion
2205
2802
  //#region src/advisor/recall.d.ts
2206
2803
  interface ScoredCandidate {
2207
2804
  model: ModelProfile;
2208
2805
  score: number;
2806
+ /** Normalized [0,1] preference-satisfaction score (capability/feature/context/quality). */
2807
+ hardScore?: number;
2808
+ /** Cosine similarity [0,1] between the semantic query and the model embedding. */
2809
+ softScore?: number;
2209
2810
  }
2210
2811
  declare function recallCandidates(models: ModelProfile[], intent: IntentProfile): ScoredCandidate[];
2211
2812
  //#endregion
2212
2813
  //#region src/advisor/recall-semantic.d.ts
2213
2814
  declare function isSemanticAvailable(): boolean;
2214
- declare function recallSemantic(config: Config, models: ModelProfile[], query: string, topK: number, intent?: IntentProfile): Promise<ScoredCandidate[]>;
2815
+ declare function recallSemantic(client: Client, models: ModelProfile[], query: string, topK: number, intent?: IntentProfile): Promise<ScoredCandidate[]>;
2215
2816
  //#endregion
2216
2817
  //#region src/advisor/recommend.d.ts
2217
2818
  interface RecommendOptions {
@@ -2220,7 +2821,7 @@ interface RecommendOptions {
2220
2821
  enableThinking?: boolean;
2221
2822
  }
2222
2823
  declare function buildDocLink(docUrl?: string): string | undefined;
2223
- declare function rankModels(config: Config, candidates: ScoredCandidate[], intent: IntentProfile, userInput: string, top: number, options?: RecommendOptions): Promise<RecommendResult>;
2824
+ declare function rankModels(client: Client, candidates: ScoredCandidate[], intent: IntentProfile, userInput: string, top: number, options?: RecommendOptions): Promise<RecommendResult>;
2224
2825
  //#endregion
2225
2826
  //#region src/advisor/sources/types.d.ts
2226
2827
  interface ModelSource {
@@ -2229,4 +2830,4 @@ interface ModelSource {
2229
2830
  load(): Promise<ModelProfile[]>;
2230
2831
  }
2231
2832
  //#endregion
2232
- export { AkSignConfig, type ApiErrorBody, AppCompletionRequest, AppCompletionResponse, AppStreamChunk, AuthMethod, BAILIAN_HOST, BailianError, BatchSizeGateInput, BatchSizeGateResult, Budget, Budgets, CHANNEL, CONSOLE_GATEWAY_NO_TOKEN_MESSAGE, CancelFineTuneResponse, Capabilities, Capability, ChatChoice, ChatMessage, ChatMessageContent, ChatRequest, ChatResponse, ChatTool, Command, CommandSpec, Complexities, Complexity, Config, ConfigFile, ConsoleGatewayRequest, ConsoleSite, ContextNeed, ContextNeeds, CreateDeploymentRequest, CreateDeploymentResponse, CreateFineTuneRequest, CreateFineTuneResponse, DEFAULT_TRAINING_TYPE, DOCS_HOSTS, DashScopeASRRequest, DashScopeASRTaskResult, DashScopeAsyncResponse, DashScopeImageRequest, DashScopeImageSyncResponse, DashScopeKnowledgeRetrieveRequest, DashScopeKnowledgeRetrieveResponse, DashScopeTTSRequest, DashScopeTTSResponse, DashScopeTTSStreamChunk, DashScopeTaskResponse, DashScopeVideoEditRequest, DashScopeVideoRefRequest, DashScopeVideoRequest, DatasetDeleteResponse, DatasetFile, DatasetGetResponse, DatasetListParams, DatasetListResponse, DatasetSchema, DatasetUploadParams, DatasetUploadResponse, DeleteDeploymentResponse, DeleteFineTuneResponse, DeployableModel, DeployableTemplate, Deployment, ExitCode, ExportCheckpointResponse, Feature, Features, FineTuneCheckpoint, FineTuneHyperParameters, FineTuneJob, FineTuneLogEntry, GLOBAL_OPTIONS, GetDeploymentResponse, GetFineTuneLogsParams, GetFineTuneLogsResponse, GetFineTuneResponse, GetModelsOptions, GlobalFlags, INSUFFICIENT_SAMPLES_CODE, IntentProfile, IntentSegment, KnowledgeChatContentPart, KnowledgeChatMessage, KnowledgeChatRequest, KnowledgeChatStreamChunk, KnowledgeRetrieveRequest, KnowledgeRetrieveResponse, KnowledgeSearchRequest, KnowledgeSearchResponse, ListCheckpointsResponse, ListDeployableModelsParams, ListDeployableModelsResponse, ListDeploymentsParams, ListDeploymentsResponse, ListFineTunesParams, ListFineTunesResponse, MAX_DATASET_BYTES, McpClient, McpTool, McpToolResult, MemoryAddRequest, MemoryAddResponse, MemoryMessage, MemoryNode, MemoryNodeListResponse, MemoryNodeUpdateRequest, MemorySearchRequest, MemorySearchResponse, Modalities, Modality, ModelCapability, ModelCategories, ModelCategory, ModelListParams, ModelListResult, ModelPreference, ModelPrice, ModelProfile, ModelSource, OptionDef, OutputFormat, PipelineResult, PipelineStep, PreferenceMode, ProfileAttribute, ProfileSchemaCreateRequest, ProfileSchemaCreateResponse, PtuCapacity, QpmLimit, QualityPreference, QualityPreferences, REGIONS, RecommendOptions, RecommendResult, RecommendedModel, Region, RequestOpts, ResolvedCredential, SOURCE_CONFIG, ScaleDeploymentRequest, ScaleDeploymentResponse, ScoredCandidate, ServerSentEvent, SingleResult, StreamChoice, StreamChunk, TAGS, TRAINING_TYPES_CLI, TRAINING_TYPE_MAP, TrackingEvent, TrainingTypeCli, UpdateDeploymentRequest, UpdateDeploymentResponse, UserProfileResponse, ValidateOpts, ValidationIssue, ValidationResult, ValidationSeverity, ValidationStats, ValidatorSpec, analyzeIntent, appCompletionEndpoint, bailianMcpUrl, buildDocLink, callConsoleGateway, cancelFineTune, chatEndpoint, clearApiKey, createDeployment, createFineTune, createTrackingEvent, defineCommand, deleteDataset, deleteDeployment, deleteFineTune, detectOutputFormat, effectiveConsoleGatewayConfig, ensureConfigDir, exportCheckpoint, fetchModelCapability, fetchModelList, flushTelemetry, formatErrorJson, formatIssue, formatJson, formatOutput, formatText, generateFilename, getConfigDir, getConfigPath, getCredentialsPath, getDataset, getDeployment, getFineTune, getFineTuneLogs, getModels, imageEndpoint, imageSyncEndpoint, isCI, isInteractive, isLocalFile, isSemanticAvailable, isTrainingTypeCli, knowledgeChatEndpoint, knowledgeRetrieveEndpoint, knowledgeSearchEndpoint, listCheckpoints, listDatasets, listDeployableModels, listDeployments, listFineTunes, listSupportedFormats, listSupportedTrainingTypes, loadApiKeyFromConfig, loadConfig, localSink, mapApiError, maskToken, mcpWebSearchEndpoint, memoryAddEndpoint, memoryListEndpoint, memoryNodeEndpoint, memorySearchEndpoint, modelSupportsTrainingType, parseBooleanValue, parseConfigFile, parseDatasetSchemaFlag, parseOptionalBooleanValue, parseSSE, pickValidator, preflightBatchSizeGate, profileSchemaEndpoint, rankModels, readConfigFile, recallCandidates, recallSemantic, registerValidator, remoteSink, request, requestJson, resolveBooleanFlag, resolveConsoleGatewayCredential, resolveCredential, resolveFileUrl, resolveOutputDir, resolveWatermark, saveApiKeyToConfig, scaleDeployment, signRequest, speechRecognizeEndpoint, speechSynthesizeEndpoint, stripUndefined, taskEndpoint, toServerTrainingType, trackCommandExecution, trackingHeaders, trainingTypeMethodVariant, updateDeployment, uploadDataset, uploadFile, userProfileEndpoint, validateDataset, videoGenerateEndpoint, writeConfigFile };
2833
+ export { ASYNC_FLAG, AcsQueryParams, AcsSignConfig, AigcConfig, AnyCommand, type ApiErrorBody, ApiKeyCredential, AppCompletionRequest, AppCompletionResponse, AppStreamChunk, AuthPersistPatch, AuthRequirement, AuthState, AuthStore, BAILIAN_HOST, BILLING_METHOD, BailianError, BatchSizeGateInput, BatchSizeGateResult, BillingMethod, Budget, Budgets, CHANNEL, CHARGE_TYPE, COMMAND_PACK_API_VERSION, CONCURRENT_FLAG, CONSOLE_AUTH_FLAGS, CancelFineTuneResponse, Capabilities, Capability, ChargeType, ChatChoice, ChatMessage, ChatMessageContent, ChatRequest, ChatResponse, ChatResponseFormat, ChatTool, Client, ClientOpenApiQueryOpts, ClientRequestOpts, Command, CommandContext, CommandPack, CommandPackApiKeyContext, CommandPackCommand, CommandPackContext, CommandPackCredentials, CommandPackErrorOptions, CommandPackErrors, CommandPackManager, CommandPackMeta, CommandPackMutationResult, CommandPackOutput, CommandPackOutputOptions, CommandPackReport, Complexities, Complexity, ConfigFile, ConfigStore, ConsoleCredential, ConsoleGatewayRequest, ConsoleSite, ContextNeed, ContextNeeds, CreateDeploymentRequest, CreateDeploymentResponse, CreateFineTuneRequest, CreateFineTuneResponse, CreatePlanFlags, CredentialSource, DEFAULT_BILLING_METHOD, DEFAULT_DEPLOY_PLAN, DEFAULT_TRAINING_TYPE, DEPLOY_PLAN, DOCS_HOSTS, DashScopeASRRequest, DashScopeASRTaskResult, DashScopeAsyncResponse, DashScopeImageRequest, DashScopeImageSyncResponse, DashScopeKnowledgeRetrieveRequest, DashScopeKnowledgeRetrieveResponse, DashScopeTTSRequest, DashScopeTTSResponse, DashScopeTTSStreamChunk, DashScopeTaskResponse, DashScopeVideoEditRequest, DashScopeVideoRefRequest, DashScopeVideoRequest, type DataModality, DatasetDeleteResponse, DatasetFile, DatasetGetResponse, DatasetListParams, DatasetListResponse, DatasetSchema, DatasetUploadParams, DatasetUploadResponse, DeleteDeploymentResponse, DeleteFineTuneResponse, DeployModality, DeployPlan, DeployableModel, DeployableTemplate, Deployment, ExitCode, ExportCheckpointResponse, Feature, Features, FineTuneCheckpoint, FineTuneHyperParameters, FineTuneJob, FineTuneLogEntry, FlagDef, FlagsDef, GLOBAL_FLAGS, GetDeploymentResponse, GetFineTuneLogsParams, GetFineTuneLogsResponse, GetFineTuneResponse, GetModelsOptions, INSUFFICIENT_SAMPLES_CODE, Identity, IntentProfile, IntentSegment, KnowledgeChatContentPart, KnowledgeChatMessage, KnowledgeChatRequest, KnowledgeChatStreamChunk, KnowledgeSearchRequest, KnowledgeSearchResponse, ListCheckpointsResponse, ListDeployableModelsParams, ListDeployableModelsResponse, ListDeploymentsParams, ListDeploymentsResponse, ListFineTunesParams, ListFineTunesResponse, MAX_DATASET_BYTES, MAX_MEDIA_ZIP_BYTES, MODEL_AUTH_FLAGS, MODEL_LIST_API, McpClient, McpTool, McpToolResult, MemoryAddRequest, MemoryAddResponse, MemoryMessage, MemoryNode, MemoryNodeListResponse, MemoryNodeUpdateRequest, MemorySearchRequest, MemorySearchResponse, Modalities, Modality, ModelCapability, ModelCategories, ModelCategory, ModelGroup, ModelGroupItem, ModelGroupParams, ModelGroupResult, ModelListParams, ModelListResult, ModelPreference, ModelPrice, ModelPriceInfo, ModelProfile, ModelSource, OPENAPI_AUTH_FLAGS, OpenApiCredential, OutputFormat, PREDICT_CONFIG_API, ParsedFlags, PipelineResult, PipelineStep, PlanContext, PlanResolved, PlanStrategy, PredictConfigEntry, PreferenceMode, ProfileAttribute, ProfileSchemaCreateRequest, ProfileSchemaCreateResponse, PtuCapacity, QpmLimit, QualityPreference, QualityPreferences, REGIONS, RecommendOptions, RecommendResult, RecommendedModel, Region, RequestOpts, ResolutionSources, SEMANTIC_TOP_K, SOURCE_CONFIG, STRATEGIES, ScaleDeploymentRequest, ScaleDeploymentResponse, ScoredCandidate, ServerSentEvent, Settings, SingleResult, SourceFlags, StreamChoice, StreamChunk, TAGS, TRAINING_TYPES_CLI, TRAINING_TYPE_MAP, TrackingEvent, type TrainingProfile, TrainingTypeCli, UpdateDeploymentRequest, UpdateDeploymentResponse, UsageError, UserProfileResponse, ValidateOpts, ValidationIssue, ValidationResult, ValidationSeverity, ValidationStats, ValidatorSpec, analyzeIntent, appCompletionPath, bailianMcpPath, buildAcsCanonicalQuery, buildDocLink, buildSettings, buildSources, callConsoleGateway, cancelFineTune, chatPath, createDeployment, createFineTune, createTrackingEvent, credentialFlagDefs, defaultDeployPlan, defineCommand, deleteDataset, deleteDeployment, deleteFineTune, describeAuthState, detectModality, detectOutputFormat, effectiveConsoleGatewayConfig, ensureConfigDir, exportCheckpoint, fetchModelCapability, fetchModelDetail, fetchModelGroups, fetchModelList, fetchPredictConfig, flushTelemetry, formatErrorJson, formatIssue, formatJson, formatOutput, formatText, generateFilename, getConfigDir, getConfigPath, getCredentialsPath, getDataset, getDeployment, getFineTune, getFineTuneLogs, getModels, getProfile, imagePath, imageSyncPath, isLocalFile, isSemanticAvailable, isTrainingTypeCli, knowledgeChatEndpoint, knowledgeRetrievePath, knowledgeSearchEndpoint, listCheckpoints, listDatasets, listDeployableModels, listDeployments, listFineTunes, listSupportedFormats, listSupportedTrainingTypes, listTrainingTypes, localSink, makeAuthStore, makeConfigStore, mapApiError, maskToken, mcpWebSearchPath, memoryAddPath, memoryListPath, memoryNodePath, memorySearchPath, modelSupportsTrainingType, parseBooleanValue, parseConfigFile, parseDatasetSchemaFlag, parseOptionalBooleanValue, parseSSE, pickPlanStrategy, pickValidator, preflightBatchSizeGate, profileSchemaPath, rankModels, readConfigFile, recallCandidates, recallSemantic, registerValidator, remoteSink, request, requestJson, resolveApiKey, resolveBooleanFlag, resolveConsole, resolveFileUrl, resolveModelBaseUrl, resolveOpenApi, resolveOutputDir, resolveWatermark, scaleDeployment, signAcsRequest, speechRecognizePath, speechSynthesizePath, stripUndefined, taskPath, trackCommandExecution, trackingHeaders, trainingTypeMethodVariant, unwrapResponse, updateDeployment, uploadDataset, uploadFile, userProfilePath, validateDataset, videoGeneratePath, writeConfigFile };