bailian-cli-core 2.7.2 → 2.8.1

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
@@ -47,6 +47,14 @@ export declare class UsageError extends BailianError {
47
47
  constructor(message: string, hint?: string);
48
48
  }
49
49
  //#endregion
50
+ //#region src/errors/credential.d.ts
51
+ type CredentialFailure = "missing-api-key" | "missing-console-token" | "expired-console-session" | "missing-openapi-pair" | "incomplete-openapi-flag" | "incomplete-openapi-env" | "incomplete-openapi-config";
52
+ /** Local credential failure facts; CLI recovery instructions belong to the host. */
53
+ export declare class CredentialError extends BailianError {
54
+ readonly reason: CredentialFailure;
55
+ constructor(reason: CredentialFailure, message: string, hint?: string, options?: BailianErrorOptions);
56
+ }
57
+ //#endregion
50
58
  //#region src/errors/api.d.ts
51
59
  interface ApiErrorBody {
52
60
  error?: {
@@ -1342,6 +1350,11 @@ export declare function parseConfigFile(raw: unknown): ConfigFile;
1342
1350
  interface Identity {
1343
1351
  /** Product binary name, e.g. "bl", "rag". */
1344
1352
  binName: string;
1353
+ /** Executable and fixed host subcommands; display text is derived from this structure. */
1354
+ commandInvocation?: {
1355
+ readonly bin: string;
1356
+ readonly path: readonly string[];
1357
+ };
1345
1358
  version: string;
1346
1359
  /** npm package name for self-update, e.g. "bailian-cli". */
1347
1360
  npmPackage: string;
@@ -1481,6 +1494,8 @@ export declare function makeAuthStore(sources: ResolutionSources): AuthStore;
1481
1494
  interface HttpDeps {
1482
1495
  identity: Identity;
1483
1496
  settings: Settings;
1497
+ /** Optional diagnostic sink; core never writes to terminal streams. */
1498
+ debug?: (diagnostic: OutputMessage) => void;
1484
1499
  }
1485
1500
  interface RequestOpts {
1486
1501
  url: string;
@@ -1616,12 +1631,17 @@ export declare function connectBailianMcpWithFallback(options: ConnectBailianMcp
1616
1631
  interface ClientDeps {
1617
1632
  identity: Identity;
1618
1633
  settings: Settings;
1634
+ debug?: HttpDeps["debug"];
1619
1635
  /** Model 域 base URL(凭证无关链解析,resolveModelBaseUrl;有 apiCred 时两者一致)。 */
1620
1636
  baseUrl: string;
1621
1637
  /** True only when the shared URL chain used its default; explicit origins win over service defaults. */
1622
1638
  baseUrlIsDefault?: boolean;
1623
1639
  apiCred?: ApiKeyCredential;
1624
1640
  consoleCred?: ConsoleCredential;
1641
+ /** Lazily resolve AK/SK only when the Console token is missing or expired. */
1642
+ resolveConsoleOpenApiCredential?: () => OpenApiCredential;
1643
+ /** Optional host-provided recovery text; core does not construct CLI instructions. */
1644
+ consoleRecoveryHint?: string;
1625
1645
  openApiCred?: OpenApiCredential;
1626
1646
  }
1627
1647
  /** Like {@link RequestOpts} but with a `path` (credential baseUrl prepended) or an absolute URL. */
@@ -1656,11 +1676,12 @@ interface OpenApiResponse {
1656
1676
  * credential and base URL are already baked in, so commands never handle tokens
1657
1677
  * or baseUrl. Model methods (`request`/`requestJson`/`mcp`) need an api key;
1658
1678
  * `uploadFile` only needs one for local files, and passes URLs through without
1659
- * credentials. `console` needs a console token; calling one without its
1660
- * credential throws.
1679
+ * credentials. `console` uses a Console token, obtaining one lazily from
1680
+ * resolved AK/SK when needed. Concurrent calls share the exchange, not results.
1661
1681
  */
1662
1682
  export declare class Client {
1663
1683
  private readonly deps;
1684
+ private consoleSession;
1664
1685
  constructor(deps: ClientDeps);
1665
1686
  private get http();
1666
1687
  private requireApi;
@@ -1975,6 +1996,7 @@ type SourceFlags = ParsedFlags<typeof GLOBAL_FLAGS & typeof MODEL_AUTH_FLAGS & t
1975
1996
  /** 该命令可见的凭证域 flag 定义。 */
1976
1997
  export declare function credentialFlagDefs(cmd: {
1977
1998
  auth: AuthRequirement;
1999
+ optionalConsole?: boolean;
1978
2000
  }): FlagsDef;
1979
2001
  /**
1980
2002
  * What a command's `run` receives: `client` for all network calls (its
@@ -1989,6 +2011,8 @@ interface CommandContext<F extends FlagsDef = FlagsDef, Prepared = undefined> {
1989
2011
  prepared?: Prepared;
1990
2012
  /** 静态产品身份(binName/version/npmPackage/clientName)。 */
1991
2013
  identity: Identity;
2014
+ /** Unified per-invocation result and diagnostic output. */
2015
+ output: CommandOutput;
1992
2016
  /**
1993
2017
  * Locale selector for user-facing output: picks the `en-US` / `zh-CN` variant
1994
2018
  * of a {@link LocalizedText} per the resolved language. Supplied by the runtime
@@ -2033,9 +2057,25 @@ interface CommandPreparation<Prepared> {
2033
2057
  notices: readonly CommandNotice[];
2034
2058
  }
2035
2059
  interface Command<F extends FlagsDef = FlagsDef, Prepared = undefined> {
2060
+ /** Fallback when no output format is configured by flag, environment or Profile. */
2061
+ defaultOutput?: Settings["output"];
2062
+ /** Native terminal presentation when no flag, environment or Profile selects a format. */
2063
+ defaultInteractiveOutput?: Settings["output"];
2064
+ /** Existing command switches that explicitly request diagnostic output (for example --trace). */
2065
+ verboseFlags?: readonly (keyof F & string)[];
2066
+ /** Apply defaultOutput over a Profile preference; flag/env still take precedence. */
2067
+ defaultOutputOverridesProfile?: boolean;
2036
2068
  description: LocalizedText;
2037
2069
  /** Credential this command requires. See {@link AuthRequirement}. */
2038
2070
  auth: AuthRequirement;
2071
+ /**
2072
+ * Best-effort secondary console credential for `auth: "apiKey"` commands.
2073
+ * When true, the runtime additionally resolves the console credential and
2074
+ * injects it when available; a missing/expired console session never blocks
2075
+ * the command. Console-domain flags become visible so the precheck target can
2076
+ * be selected explicitly.
2077
+ */
2078
+ optionalConsole?: boolean;
2039
2079
  /**
2040
2080
  * Runtime-classified operation risk and its user-facing consequence message.
2041
2081
  * Omit for normal commands.
@@ -2067,6 +2107,27 @@ type AnyCommand = Command<any, any>;
2067
2107
  /** Identity wrapper whose only job is to infer `F` from `spec.flags`. */
2068
2108
  export declare function defineCommand<F extends FlagsDef, Prepared = undefined>(spec: Command<F, Prepared>): Command<F, Prepared>;
2069
2109
  //#endregion
2110
+ //#region src/types/output.d.ts
2111
+ /** Custom text presentation never replaces the primary JSON data. */
2112
+ interface OutputResultOptions {
2113
+ text?: string;
2114
+ }
2115
+ interface OutputDiagnostic {
2116
+ message: LocalizedText;
2117
+ code?: string;
2118
+ /** Structured diagnostic context; the runtime redacts credential keys. */
2119
+ details?: unknown;
2120
+ }
2121
+ type OutputMessage = LocalizedText | OutputDiagnostic;
2122
+ /** Per-invocation output surface. Throw terminal failures instead of printing them. */
2123
+ interface CommandOutput {
2124
+ result(data: unknown, options?: OutputResultOptions): void;
2125
+ progress(message: LocalizedText): void;
2126
+ info(message: LocalizedText): void;
2127
+ warning(warning: OutputMessage): void;
2128
+ debug(details: OutputMessage): void;
2129
+ }
2130
+ //#endregion
2070
2131
  //#region src/config/loader.d.ts
2071
2132
  /**
2072
2133
  * 校验并规范化 `--config <name>`:`undefined`/""/"default" 都视为未指定(等价顶层默认配置)。
@@ -2122,7 +2183,11 @@ interface ApiKeyResolutionSourceSelection {
2122
2183
  * environment API connection override bypasses it entirely.
2123
2184
  */
2124
2185
  export declare function selectApiKeyResolutionSources(sources: ResolutionSources, capability: string): ApiKeyResolutionSourceSelection;
2125
- export declare function buildSources(flags: Partial<SourceFlags>): ResolutionSources;
2186
+ export declare function buildSources(flags: Partial<SourceFlags>, onWarning?: (warning: OutputDiagnostic) => void): ResolutionSources;
2187
+ /** Presentation-only resolution, also safe before config loading or unrelated validation. */
2188
+ export declare function buildOutputSettings({ flags, env, file }: Pick<ResolutionSources, "flags" | "env"> & {
2189
+ file?: ConfigFile;
2190
+ }): Pick<Settings, "output" | "outputExplicit" | "outputSource" | "quiet" | "verbose">;
2126
2191
  /**
2127
2192
  * 纯解析 sources → Settings(命令唯一会读的配置面)。不含身份、baseUrl、鉴权。
2128
2193
  * 各字段链序 flag > env > file > 默认;锁定表 tests/config-priority.test.ts。
@@ -2155,7 +2220,7 @@ export declare function resolveModelBaseUrl(s: ResolutionSources, fallback?: str
2155
2220
  export declare function resolveApiKey(s: ResolutionSources): ApiKeyCredential;
2156
2221
  /** Console-domain credential from sources — access token + 连接目标(flag > file > 默认)。 */
2157
2222
  export declare function resolveConsole(s: ResolutionSources): ConsoleCredential;
2158
- /** Alibaba Cloud OpenAPI AK/SK credential. Priority: flags > env > config. */
2223
+ /** AK/SK priority: flags > Bailian env > selected config > Alibaba Cloud env. */
2159
2224
  export declare function resolveOpenApi(s: ResolutionSources): OpenApiCredential;
2160
2225
  /** Full auth snapshot from sources — what would resolve per domain (or undefined). */
2161
2226
  export declare function describeAuthState(s: ResolutionSources): AuthState;
@@ -2182,7 +2247,9 @@ type ConsoleCall = (api: string, data: Record<string, unknown>) => Promise<unkno
2182
2247
  * Build an anonymous (token-less) gateway caller for public catalog APIs such
2183
2248
  * as `listFoundationModels` — no console login required.
2184
2249
  */
2185
- export declare function anonymousConsoleCall(config: Pick<Settings, "consoleRegion" | "consoleSite" | "consoleSwitchAgent" | "timeout">): ConsoleCall;
2250
+ export declare function anonymousConsoleCall(config: Pick<Settings, "consoleRegion" | "consoleSite" | "consoleSwitchAgent" | "timeout">, options?: Pick<HttpDeps, "debug"> & {
2251
+ recoveryHint?: string;
2252
+ }): ConsoleCall;
2186
2253
  /**
2187
2254
  * Invoke a Bailian **console** OpenAPI via the CLI gateway (`/cli/api.json`).
2188
2255
  * 目标(region/site/switchAgent)与 token 均由调用方解析后传入:Client.console 传
@@ -2194,16 +2261,19 @@ interface ConsoleGatewayTarget {
2194
2261
  switchAgent?: number;
2195
2262
  token?: string;
2196
2263
  }
2197
- export declare function callConsoleGateway(target: ConsoleGatewayTarget, timeoutSec: number, { api, data }: ConsoleGatewayRequest, settings?: Pick<Settings, "verbose">): Promise<unknown>;
2264
+ export declare function callConsoleGateway(target: ConsoleGatewayTarget, timeoutSec: number, { api, data }: ConsoleGatewayRequest, options?: Pick<HttpDeps, "debug"> & {
2265
+ recoveryHint?: string;
2266
+ }): Promise<unknown>;
2198
2267
  //#endregion
2199
2268
  //#region src/auth/refresh-token.d.ts
2200
2269
  /** Console 目标优先;仅在地域缺省时从已知模型域名推导,不猜测未知站点。 */
2201
2270
  export declare function resolveCLIAccessTokenTarget(settings: Pick<Settings, "consoleRegion" | "consoleSite" | "consoleSwitchAgent">, baseUrl: string): Omit<ConsoleGatewayTarget, "token">;
2202
2271
  /** 首次登录只读验证;直接调用网关,避免错误触发递归刷新。 */
2203
- export declare function validateConsoleAccessToken(target: ConsoleGatewayTarget, settings: Settings): Promise<void>;
2272
+ export declare function validateConsoleAccessToken(target: ConsoleGatewayTarget, settings: Settings, diagnostics?: Pick<HttpDeps, "debug">): Promise<void>;
2204
2273
  export declare function generateCLIAccessToken(opts: {
2205
2274
  identity: Identity;
2206
2275
  settings: Settings;
2276
+ debug?: HttpDeps["debug"];
2207
2277
  baseUrl: string;
2208
2278
  accessKeyId: string;
2209
2279
  accessKeySecret: string;
@@ -2213,15 +2283,20 @@ export declare function generateCLIAccessToken(opts: {
2213
2283
  Success?: boolean;
2214
2284
  }>;
2215
2285
  /**
2216
- * Try to refresh the console access_token using stored AK/SK.
2286
+ * Obtain a Console token using resolved AK/SK, or selected-config AK/SK for legacy callers.
2217
2287
  * Returns the new token on success, or null if AK/SK are not available.
2218
2288
  */
2219
2289
  export declare function refreshAccessToken(opts: {
2220
2290
  identity: Identity;
2221
2291
  settings: Settings;
2292
+ debug?: HttpDeps["debug"];
2222
2293
  baseUrl: string;
2223
2294
  /** 重试原请求作为验证;独立调用时默认通过只读 loginInfo 校验。 */
2224
2295
  validateToken?: (token: string) => Promise<void>;
2296
+ /** Already selected by the shared credential chain; legacy callers use the selected config. */
2297
+ credential?: OpenApiCredential;
2298
+ /** Defaults to persistence only for local config credentials; temporary credentials stay in memory. */
2299
+ persist?: boolean;
2225
2300
  }): Promise<string | null>;
2226
2301
  //#endregion
2227
2302
  //#region src/client/endpoints.d.ts
@@ -2577,6 +2652,7 @@ interface BailianControlAuth {
2577
2652
  accessKeyId: string;
2578
2653
  accessKeySecret: string;
2579
2654
  securityToken?: string;
2655
+ debug?: HttpDeps["debug"];
2580
2656
  }
2581
2657
  interface CreateUserReqDTO {
2582
2658
  outerKey: string;
@@ -2936,6 +3012,27 @@ export declare function formatErrorJson(code: number, message: string, hint?: st
2936
3012
  //#region src/output/text.d.ts
2937
3013
  export declare function formatText(data: unknown): string;
2938
3014
  //#endregion
3015
+ //#region src/output/diagnostics.d.ts
3016
+ /** Convert diagnostics to inert data; never invoke accessors or serialization hooks. */
3017
+ export declare function sanitizeDiagnosticDetails(value: unknown, ancestors?: Set<object>, depth?: number): unknown;
3018
+ //#endregion
3019
+ //#region src/output/command.d.ts
3020
+ type Invocation = Pick<Identity, "binName" | "commandInvocation"> | string;
3021
+ type CommandFormatter = (arguments_?: string) => string;
3022
+ interface ExecutableCommand {
3023
+ bin: string;
3024
+ path: string[];
3025
+ args: string[];
3026
+ }
3027
+ /** Build argv for shell:false consumers; never interpret a human-facing prefix. */
3028
+ export declare function buildCommandInvocation(identity: Pick<Identity, "binName" | "commandInvocation">, path?: readonly string[], args?: readonly string[]): ExecutableCommand;
3029
+ /** Format a complete instruction at the point where the invocation is known. */
3030
+ export declare function formatCommand(invocation: Invocation, arguments_?: string): string;
3031
+ /** Reference used only in fixed CLI metadata, before the invocation is known. */
3032
+ export declare function commandRef(arguments_?: string): string;
3033
+ /** Resolve fixed help/reference templates; never pass service or user-generated text. */
3034
+ export declare function renderCommandText(text: string, invocation: Invocation): string;
3035
+ //#endregion
2939
3036
  //#region src/files/upload.d.ts
2940
3037
  interface UploadOptions {
2941
3038
  apiKey: string;
@@ -4117,7 +4214,7 @@ export declare function listSupportedTrainingTypes(model: ModelCapability | unde
4117
4214
  * server's `name` filter is a substring match, so we additionally require an
4118
4215
  * exact `model` equality to avoid e.g. `qwen3-8b` matching `qwen3-8b-v2`).
4119
4216
  */
4120
- export declare function fetchModelCapability(settings: Settings, modelName: string): Promise<ModelCapability | null>;
4217
+ export declare function fetchModelCapability(settings: Settings, modelName: string, diagnostics?: Pick<HttpDeps, "debug">): Promise<ModelCapability | null>;
4121
4218
  //#endregion
4122
4219
  //#region src/finetune/preflight.d.ts
4123
4220
  /** Stable issue code for "too few training samples for the batch size". */
@@ -4753,7 +4850,8 @@ export interface PlanContext {
4753
4850
  /** True in --dry-run: strategies must skip side-effecting catalog lookups. */
4754
4851
  dryRun: boolean;
4755
4852
  /** CLI bin name, for usage hints in error messages. */
4756
- binName: string;
4853
+ /** Optional recovery text supplied by the calling product. */
4854
+ modelUnavailableHint?: string;
4757
4855
  flags: CreatePlanFlags;
4758
4856
  /** Underlying model identifier (`--model`). */
4759
4857
  model: string;
@@ -4818,6 +4916,145 @@ export declare function listIndependentDeployedModels(client: Client): Promise<M
4818
4916
  */
4819
4917
  export declare function findDeploymentEntry(entries: ModelServiceEntry[], deployedModel: string): ModelServiceEntry | undefined;
4820
4918
  //#endregion
4919
+ //#region src/model-import/types.d.ts
4920
+ /**
4921
+ * Custom model import API types.
4922
+ *
4923
+ * Maps DashScope `/api/v1/custom_models/import` request/response shapes
4924
+ * (snake_case preserved verbatim — callers decide how to surface fields).
4925
+ */
4926
+ /** OSS storage location of the model files to import. */
4927
+ export interface CustomModelImportStorageInfo {
4928
+ bucket_name: string;
4929
+ /** Directory prefix; must end with `/` and cannot be the bucket root. */
4930
+ object_key: string;
4931
+ }
4932
+ /** POST /api/v1/custom_models/import request body. */
4933
+ export interface CreateCustomModelImportRequest {
4934
+ /** Base model ID (e.g. `qwen3-32b`). */
4935
+ model_name: string;
4936
+ /** Display name; server defaults to the base model name when omitted. */
4937
+ display_name?: string;
4938
+ /** Import source. Only `oss` is currently supported. */
4939
+ source: string;
4940
+ /** `lora` (LoRA-tuned) or `full` (fully-tuned). */
4941
+ weight_type: string;
4942
+ storage_info: CustomModelImportStorageInfo;
4943
+ }
4944
+ /** A custom model import job as returned by the platform. */
4945
+ export interface CustomModelImportJob {
4946
+ job_id?: string;
4947
+ /** Server-generated model identifier (base model name + timestamp suffix). */
4948
+ model_name?: string;
4949
+ display_name?: string;
4950
+ /** Uppercase `OSS` in responses. */
4951
+ source?: string;
4952
+ /** Present on create; omitted by get/list. */
4953
+ weight_type?: string;
4954
+ storage_info?: CustomModelImportStorageInfo;
4955
+ /** PENDING | RUNNING | SUCCESSED | FAILED (server values verbatim). */
4956
+ status?: string;
4957
+ /** Present when status is FAILED; server-provided reason text. */
4958
+ error_code?: string;
4959
+ gmt_create?: string;
4960
+ [key: string]: unknown;
4961
+ }
4962
+ export interface CreateCustomModelImportResponse {
4963
+ request_id?: string;
4964
+ output?: CustomModelImportJob;
4965
+ data?: CustomModelImportJob;
4966
+ }
4967
+ export interface GetCustomModelImportResponse {
4968
+ request_id?: string;
4969
+ output?: CustomModelImportJob;
4970
+ data?: CustomModelImportJob;
4971
+ }
4972
+ export interface DeleteCustomModelImportResponse {
4973
+ request_id?: string;
4974
+ output?: CustomModelImportJob;
4975
+ data?: CustomModelImportJob;
4976
+ }
4977
+ export interface ListCustomModelImportsResponse {
4978
+ request_id?: string;
4979
+ output?: {
4980
+ total?: number;
4981
+ page_no?: number;
4982
+ page_size?: number;
4983
+ list?: CustomModelImportJob[];
4984
+ [key: string]: unknown;
4985
+ };
4986
+ data?: {
4987
+ total?: number;
4988
+ page_no?: number;
4989
+ page_size?: number;
4990
+ list?: CustomModelImportJob[];
4991
+ [key: string]: unknown;
4992
+ };
4993
+ }
4994
+ /** Entry returned by the console `listSupportImportModels` catalog API. */
4995
+ export interface SupportImportModel {
4996
+ /** Display name (e.g. `Qwen3-32B`); may be absent. */
4997
+ name?: string;
4998
+ /** Model ID used to match `--base-model` (e.g. `qwen3-32b`). */
4999
+ model?: string;
5000
+ /** Training methods supported for import (e.g. `sft`, `efficient_sft`). */
5001
+ supportTrainTypes?: string[];
5002
+ postProcessCapabilities?: {
5003
+ quantizationSupported?: boolean;
5004
+ mtpSupported?: boolean;
5005
+ quantizationStrategyCodes?: string[];
5006
+ [key: string]: unknown;
5007
+ };
5008
+ [key: string]: unknown;
5009
+ }
5010
+ /** Parsed `listSupportImportModels` catalog result. */
5011
+ export interface SupportImportModelsResult {
5012
+ total?: number;
5013
+ pageNo?: number;
5014
+ pageSize?: number;
5015
+ list: SupportImportModel[];
5016
+ }
5017
+ //#endregion
5018
+ //#region src/model-import/api.d.ts
5019
+ /** POST /api/v1/custom_models/import */
5020
+ export declare function createCustomModelImport(client: Client, body: CreateCustomModelImportRequest, signal?: AbortSignal): Promise<CreateCustomModelImportResponse>;
5021
+ export interface ListCustomModelImportsParams {
5022
+ pageNo?: number;
5023
+ pageSize?: number;
5024
+ status?: string;
5025
+ /** Exact match against the server-generated `model_name`. */
5026
+ modelName?: string;
5027
+ signal?: AbortSignal;
5028
+ }
5029
+ /** GET /api/v1/custom_models/import */
5030
+ export declare function listCustomModelImports(client: Client, params?: ListCustomModelImportsParams): Promise<ListCustomModelImportsResponse>;
5031
+ /** GET /api/v1/custom_models/import/{job_id} */
5032
+ export declare function getCustomModelImport(client: Client, jobId: string, signal?: AbortSignal): Promise<GetCustomModelImportResponse>;
5033
+ /** DELETE /api/v1/custom_models/import/{job_id} */
5034
+ export declare function deleteCustomModelImport(client: Client, jobId: string, signal?: AbortSignal): Promise<DeleteCustomModelImportResponse>;
5035
+ //#endregion
5036
+ //#region src/model-import/console.d.ts
5037
+ export declare const LIST_SUPPORT_IMPORT_MODELS_API = "zeldaEasy.broadscope-platform.customModel.listSupportImportModels";
5038
+ /**
5039
+ * List base models that currently support custom-model import.
5040
+ *
5041
+ * Requires a console credential (`client.console` throws AUTH without one);
5042
+ * callers that treat this as an optional precheck must catch that error.
5043
+ */
5044
+ export declare function listSupportImportModels(client: Client): Promise<SupportImportModelsResult>;
5045
+ /** Exact (case-insensitive) match on the catalog `model` ID. */
5046
+ export declare function findSupportImportModel(models: readonly SupportImportModel[], baseModel: string): SupportImportModel | undefined;
5047
+ /**
5048
+ * Console train type required by an import weight type.
5049
+ *
5050
+ * The catalog's `supportTrainTypes` uses the fine-tune vocabulary: `sft`
5051
+ * (full-parameter) and `efficient_sft` (LoRA). Mapping the import
5052
+ * `weight_type` onto that vocabulary lets callers reject unsupported
5053
+ * combinations before the service answers with its opaque
5054
+ * "No import access for base model" error.
5055
+ */
5056
+ export declare function requiredTrainTypeForWeightType(weightType: string): "sft" | "efficient_sft";
5057
+ //#endregion
4821
5058
  //#region src/speech/vocabulary.d.ts
4822
5059
  /** Fixed model id for the hot-word customization endpoint. */
4823
5060
  export declare const SPEECH_BIASING_MODEL = "speech-biasing";
@@ -5131,7 +5368,7 @@ export declare function createTrackingEvent(opts: {
5131
5368
  *
5132
5369
  * 1. 先调用 `_sendAll` 排空 tracker 内部的去抖队列,把还卡在 500ms 合并窗口里
5133
5370
  * 的事件立刻推上网络。
5134
- * 2. 然后用硬超时 race 所有已追踪的 fetch promise。
5371
+ * 2. 在预算内等待发送,预算耗尽时真正取消 DNS/HTTP/body 工作。
5135
5372
  *
5136
5373
  * 埋点永远不应阻塞 CLI:调用方应传入较短的超时(例如 1000ms),并始终与超时
5137
5374
  * race。错误与超时一律静默吞掉。
@@ -5375,6 +5612,10 @@ interface RecommendDeps {
5375
5612
  catalog: () => Promise<ModelProfile$1[]>;
5376
5613
  families?: () => Promise<Map<string, FamilyProfile>>;
5377
5614
  verbose?: boolean;
5615
+ /** Optional host-owned trace sink; the pure engine never writes standard streams. */
5616
+ onTrace?: (trace: RecommendTrace) => void;
5617
+ /** Optional host-owned agent diagnostic sink. */
5618
+ onDiagnostic?: (message: string) => void;
5378
5619
  /** When provided, the engine appends decision-log lines here (--think). */
5379
5620
  decisionLog?: string[];
5380
5621
  /** When > 0, overrides the router's default slate size (`--top`). */
@@ -5418,6 +5659,40 @@ interface LLMClient {
5418
5659
  chatJson<T>(messages: Message[], opts?: LLMCallOptions): Promise<T>;
5419
5660
  chatWithTools(messages: Message[], tools: ToolDef[], opts?: LLMCallOptions): Promise<ToolResponse>;
5420
5661
  }
5662
+ interface RecommendTrace {
5663
+ timestamp: string;
5664
+ input: string;
5665
+ routingReason?: string;
5666
+ matchedScenes?: string[];
5667
+ sceneConfidence?: number;
5668
+ performance: {
5669
+ intentMs?: number;
5670
+ recallMs?: number;
5671
+ scoreMs?: number;
5672
+ rankMs?: number;
5673
+ explainMs?: number;
5674
+ totalMs?: number;
5675
+ llmCalls: number;
5676
+ };
5677
+ /** Stage fallbacks that happened, each with its cause (formatted as "llm-generate→template-text (429 rate_limit)" in logs). */
5678
+ degradations: Degradation[];
5679
+ /** Set when the run aborted on an LLM failure (intent failure, or a fatal error in any stage). */
5680
+ failure?: TraceFailure;
5681
+ /** LLM reasoning content captured when --think is enabled. */
5682
+ thinking?: ThinkingEntry[];
5683
+ }
5684
+ interface ThinkingEntry {
5685
+ stage: string;
5686
+ content: string;
5687
+ }
5688
+ interface TraceFailure {
5689
+ stage: string;
5690
+ kind: string;
5691
+ status?: number;
5692
+ code?: string;
5693
+ requestId?: string;
5694
+ message: string;
5695
+ }
5421
5696
  /** Structured degradation for JSON output / programmatic consumers. */
5422
5697
  interface Degradation {
5423
5698
  stage: string;
@@ -5550,6 +5825,8 @@ export declare const DEFAULT_LLM_MODEL = "qwen-flash-2025-07-28";
5550
5825
  interface LLMClientOptions {
5551
5826
  baseUrl: string;
5552
5827
  apiKey: string;
5828
+ /** 宿主注入带渠道标识与诊断的传输;独立使用时保留原生 fetch。 */
5829
+ fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
5553
5830
  /** Default model for chat/chatJson calls. */
5554
5831
  defaultModel?: string;
5555
5832
  timeoutMs?: number;
@@ -5573,7 +5850,7 @@ interface LLMClientOptions {
5573
5850
  /**
5574
5851
  * Self-contained OpenAI-compatible LLM client over fetch.
5575
5852
  * Kept free of bailian-cli-core imports so the engine compiles standalone;
5576
- * the command layer wires it up from ctx.client.baseUrl + credentials.
5853
+ * 宿主通过选项注入连接凭证与传输,不改变引擎的超时、SSE 或错误语义。
5577
5854
  */
5578
5855
  export declare function createLLMClient(options: LLMClientOptions): LLMClient;
5579
5856
  //#endregion
@@ -6228,4 +6505,4 @@ export declare function installSkillWithFanout(name: string, entry: SkillIndexEn
6228
6505
  export declare function listSkillDirsOnDisk(): string[];
6229
6506
  export declare function computeSkillStatuses(index: SkillsIndex, lock: SkillLockFile, diskNames: string[]): SkillStatusRow[];
6230
6507
  //#endregion
6231
- export { type AcsQueryParams, type AcsSignConfig, type AgentResult, type AgentTarget, type AigcImageEditInput, type AigcImageGenInput, type AigcTtsInput, type AigcTtsResult, type AigcVideoSubmitInput, type AigcVideoTaskResult, type AnyCommand, type ApiErrorBody, type ApiKeyCredential, type ApiKeyLoginKind, type ApiKeyResolutionSourceSelection, type AppCompletionRequest, type AppCompletionResponse, type AppStreamChunk, type AsrApiKind, type AsrApiRoute, type AsrContextMessage, type AsrFlashFamily, type AuthPersistPatch, type AuthRequirement, type AuthState, type AuthStore, type BailianControlAuth, type Budget, type BuildAsrFlashRequestOpts, type CallerAttribution, type Capability, type ChatChoice, type ChatMessage, type ChatMessageContent, type ChatRequest, type ChatResponse, type ChatResponseFormat, type ChatTool, type Clarification, type ClientOpenApiJsonOpts, type ClientOpenApiQueryOpts, type ClientRequestOpts, type Command, type CommandContext, type CommandNotice, type CommandPack, type CommandPackApiKeyContext, type CommandPackCommand, type CommandPackContext, type CommandPackCredentials, type CommandPackErrorOptions, type CommandPackErrors, type CommandPackManager, type CommandPackMeta, type CommandPackMutationResult, type CommandPackOutput, type CommandPackOutputOptions, type CommandPackReport, type CommandPreparation, type CommandRisk, type CommandRiskLevel, type Complexity, type ConfigFile, type ConfigProfiles, type ConfigStore, type ConnectBailianMcpOptions, type ConsoleCall, type ConsoleCredential, type ConsoleGatewayRequest, type ConsoleGatewayTarget, type ConsoleSite, type ContextNeed, type CreateUserReqDTO, type CredentialSource, type DashScopeASRRequest, type DashScopeASRTaskResult, type DashScopeASRTranscriptionItem, type DashScopeAsyncResponse, type DashScopeImageRequest, type DashScopeImageSyncResponse, type DashScopeTTSRequest, type DashScopeTTSResponse, type DashScopeTTSStreamChunk, type DashScopeTaskResponse, type DashScopeVideoEditRequest, type DashScopeVideoRefRequest, type DashScopeVideoRequest, type DataModality, type DatasetSchema, type Degradation, type IntentProfile as EngineIntentProfile, type RecommendResult as EngineRecommendResult, type RecommendSuccess as EngineRecommendSuccess, type RecommendSuccess, type Recommendation as EngineRecommendation, type StepRecommendation as EngineStepRecommendation, type ExecutionPlan, type FamilyProfile, type FanoutOutcome, type Feature, type FetchImplementation, type FlagDef, type FlagsDef, type HttpDeps, type Identity, type ImageApiKind, type ImageApiRoute, type ImageInputStyle, type ImageSizeProfile, type InstallMethod, type InstallMethodIdentity, type InstalledSkill, type IntentSegment, type Interaction, type KnowledgeChatContentPart, type KnowledgeChatMessage, type KnowledgeChatRequest, type KnowledgeChatStreamChunk, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type LLMClient, type LLMClientOptions, type LLMErrorKind, type LLMStage, type Language, type IntentProfile$1 as LegacyIntentProfile, type ModelProfile as LegacyModelProfile, type RecommendResult$1 as LegacyRecommendResult, type LinkResult, type LocalizedText, type McpConnectedClient, type McpTool, type McpToolResult, type McpToolResultContent, type MemoryAddAsyncResponse, type MemoryAddRequest, type MemoryContentPart, type MemoryEvent, type MemoryEventResourceType, type MemoryEventResponse, type MemoryEventResult, type MemoryEventStatus, type MemoryExtractScene, type MemoryMessage, type MemoryNode, type MemoryNodeDetailResponse, type MemoryNodeListResponse, type MemoryNodeUpdateRequest, type MemoryPlanVersion, type MemorySearchRequest, type MemorySearchResponse, type MemorySkillExportResponse, type MemoryToolCall, type MemoryType, type Modality, type ModelCategory, type ModelConnectionProvenance, type ModelGroup, type ModelGroupItem, type ModelGroupParams, type ModelGroupResult, type ModelListParams, type ModelListResult, type ModelOfflineInfo, type ModelOfflineNotice, type ModelPreference, type ModelPrice, type ModelPriceInfo, type ModelSampleCodeV2, type ModelSampleSnippet, type OpenApiCredential, type OutputFormat, type ParsedFlags, type PipelineResult, type PipelineStep, type PredictConfigEntry, type PreferenceMode, type ProfileAttribute, type ProfileSchemaAttribute, type ProfileSchemaAttributeOperation, type ProfileSchemaCreateRequest, type ProfileSchemaCreateResponse, type ProfileSchemaDetailResponse, type ProfileSchemaListResponse, type ProfileSchemaSummary, type ProfileSchemaUpdateRequest, type QpmLimit, type QualityPreference, type RagAddCategoryData, type RagAddCategoryResponse, type RagAddConnectorResponse, type RagAddFileData, type RagAddFileResponse, type RagAgentConfig, type RagAgentDetail, type RagAgentGetData, type RagAgentGetResponse, type RagAgentListData, type RagAgentListResponse, type RagAgentMutationData, type RagAgentMutationResponse, type RagAgentRow, type RagBatchUpdateTagResponse, type RagCategory, type RagChunkListData, type RagChunkListResponse, type RagChunkNode, type RagChunkNodeMetadata, type RagConnectorInfo, type RagConnectorResponse, type RagCreateIndexV2Data, type RagCreateIndexV2Response, type RagDataCenterFile, type RagDeleteFileData, type RagDeleteFileResponse, type RagDescribeFileResponse, type RagGetConnectorResponse, type RagIndexFileDetailRow, type RagIndexFileDetailsResponse, type RagIndexFileRow, type RagIndexFilesData, type RagIndexFilesResponse, type RagIndexJobDoc, type RagIndexJobStatusData, type RagIndexJobStatusResponse, type RagIndexListData, type RagIndexListResponse, type RagIndexRow, type RagJobCreateData, type RagJobCreateResponse, type RagListCategoryData, type RagListCategoryResponse, type RagListFileData, type RagListFileResponse, type RagMonitorData, type RagMonitorResponse, type RagMutationResponse, type RagOssImportData, type RagOssImportFileResult, type RagOssImportResponse, type RagQpsMonitorData, type RagResponse, type RagStorageMonitorData, type RagUploadLeaseData, type RagUploadLeaseParam, type RagUploadLeaseResponse, type RecommendDeps, type RecommendSession, type RecommendedModel, type Region, type RequestOpts, type ResolutionSources, type ResponsesOutputContent, type ResponsesOutputItem, type ResponsesRequest, type ResponsesResponse, type ResponsesStreamEvent, type SecurityAlert, type SecurityAlertList, type SecurityOverview, type SecurityRiskLevel, type SecurityScanStat, type SecurityToggle, type ServerSentEvent, type Settings, type SingleResult, type SkillIndexEntry, type SkillInstallRecord, type SkillLockEntry, type SkillLockFile, type SkillMeta, type SkillStatus, type SkillStatusRow, type SkillsIndex, type SourceFlags, type StreamChoice, type StreamChunk, type ToolDeps, type TrackingDeps, type TrackingEvent, type TrackingIdentity, type TrainingProfile, type TrajectoryEvent, type UserProfileAttribute, type UserProfileResponse, type UserProfileValueItem, type UserProfileValueUpdateRequest, type ValidateOpts, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidationStats, type ValidatorSpec, type VocabularyEntry, type VocabularyEnvelope, type VocabularyListItem, type VocabularyRequest, analyzeIntent as analyzeEngineIntent, recommend as recommendEngine, route as routeEngine };
6508
+ export { type AcsQueryParams, type AcsSignConfig, type AgentResult, type AgentTarget, type AigcImageEditInput, type AigcImageGenInput, type AigcTtsInput, type AigcTtsResult, type AigcVideoSubmitInput, type AigcVideoTaskResult, type AnyCommand, type ApiErrorBody, type ApiKeyCredential, type ApiKeyLoginKind, type ApiKeyResolutionSourceSelection, type AppCompletionRequest, type AppCompletionResponse, type AppStreamChunk, type AsrApiKind, type AsrApiRoute, type AsrContextMessage, type AsrFlashFamily, type AuthPersistPatch, type AuthRequirement, type AuthState, type AuthStore, type BailianControlAuth, type Budget, type BuildAsrFlashRequestOpts, type CallerAttribution, type Capability, type ChatChoice, type ChatMessage, type ChatMessageContent, type ChatRequest, type ChatResponse, type ChatResponseFormat, type ChatTool, type Clarification, type ClientOpenApiJsonOpts, type ClientOpenApiQueryOpts, type ClientRequestOpts, type Command, type CommandContext, type CommandFormatter, type CommandNotice, type CommandOutput, type CommandPack, type CommandPackApiKeyContext, type CommandPackCommand, type CommandPackContext, type CommandPackCredentials, type CommandPackErrorOptions, type CommandPackErrors, type CommandPackManager, type CommandPackMeta, type CommandPackMutationResult, type CommandPackOutput, type CommandPackOutputOptions, type CommandPackReport, type CommandPreparation, type CommandRisk, type CommandRiskLevel, type Complexity, type ConfigFile, type ConfigProfiles, type ConfigStore, type ConnectBailianMcpOptions, type ConsoleCall, type ConsoleCredential, type ConsoleGatewayRequest, type ConsoleGatewayTarget, type ConsoleSite, type ContextNeed, type CreateUserReqDTO, type CredentialFailure, type CredentialSource, type DashScopeASRRequest, type DashScopeASRTaskResult, type DashScopeASRTranscriptionItem, type DashScopeAsyncResponse, type DashScopeImageRequest, type DashScopeImageSyncResponse, type DashScopeTTSRequest, type DashScopeTTSResponse, type DashScopeTTSStreamChunk, type DashScopeTaskResponse, type DashScopeVideoEditRequest, type DashScopeVideoRefRequest, type DashScopeVideoRequest, type DataModality, type DatasetSchema, type Degradation, type IntentProfile as EngineIntentProfile, type RecommendResult as EngineRecommendResult, type RecommendSuccess as EngineRecommendSuccess, type RecommendSuccess, type Recommendation as EngineRecommendation, type StepRecommendation as EngineStepRecommendation, type ExecutableCommand, type ExecutionPlan, type FamilyProfile, type FanoutOutcome, type Feature, type FetchImplementation, type FlagDef, type FlagsDef, type HttpDeps, type Identity, type ImageApiKind, type ImageApiRoute, type ImageInputStyle, type ImageSizeProfile, type InstallMethod, type InstallMethodIdentity, type InstalledSkill, type IntentSegment, type Interaction, type KnowledgeChatContentPart, type KnowledgeChatMessage, type KnowledgeChatRequest, type KnowledgeChatStreamChunk, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type LLMClient, type LLMClientOptions, type LLMErrorKind, type LLMStage, type Language, type IntentProfile$1 as LegacyIntentProfile, type ModelProfile as LegacyModelProfile, type RecommendResult$1 as LegacyRecommendResult, type LinkResult, type LocalizedText, type McpConnectedClient, type McpTool, type McpToolResult, type McpToolResultContent, type MemoryAddAsyncResponse, type MemoryAddRequest, type MemoryContentPart, type MemoryEvent, type MemoryEventResourceType, type MemoryEventResponse, type MemoryEventResult, type MemoryEventStatus, type MemoryExtractScene, type MemoryMessage, type MemoryNode, type MemoryNodeDetailResponse, type MemoryNodeListResponse, type MemoryNodeUpdateRequest, type MemoryPlanVersion, type MemorySearchRequest, type MemorySearchResponse, type MemorySkillExportResponse, type MemoryToolCall, type MemoryType, type Modality, type ModelCategory, type ModelConnectionProvenance, type ModelGroup, type ModelGroupItem, type ModelGroupParams, type ModelGroupResult, type ModelListParams, type ModelListResult, type ModelOfflineInfo, type ModelOfflineNotice, type ModelPreference, type ModelPrice, type ModelPriceInfo, type ModelSampleCodeV2, type ModelSampleSnippet, type OpenApiCredential, type OutputDiagnostic, type OutputFormat, type OutputMessage, type OutputResultOptions, type ParsedFlags, type PipelineResult, type PipelineStep, type PredictConfigEntry, type PreferenceMode, type ProfileAttribute, type ProfileSchemaAttribute, type ProfileSchemaAttributeOperation, type ProfileSchemaCreateRequest, type ProfileSchemaCreateResponse, type ProfileSchemaDetailResponse, type ProfileSchemaListResponse, type ProfileSchemaSummary, type ProfileSchemaUpdateRequest, type QpmLimit, type QualityPreference, type RagAddCategoryData, type RagAddCategoryResponse, type RagAddConnectorResponse, type RagAddFileData, type RagAddFileResponse, type RagAgentConfig, type RagAgentDetail, type RagAgentGetData, type RagAgentGetResponse, type RagAgentListData, type RagAgentListResponse, type RagAgentMutationData, type RagAgentMutationResponse, type RagAgentRow, type RagBatchUpdateTagResponse, type RagCategory, type RagChunkListData, type RagChunkListResponse, type RagChunkNode, type RagChunkNodeMetadata, type RagConnectorInfo, type RagConnectorResponse, type RagCreateIndexV2Data, type RagCreateIndexV2Response, type RagDataCenterFile, type RagDeleteFileData, type RagDeleteFileResponse, type RagDescribeFileResponse, type RagGetConnectorResponse, type RagIndexFileDetailRow, type RagIndexFileDetailsResponse, type RagIndexFileRow, type RagIndexFilesData, type RagIndexFilesResponse, type RagIndexJobDoc, type RagIndexJobStatusData, type RagIndexJobStatusResponse, type RagIndexListData, type RagIndexListResponse, type RagIndexRow, type RagJobCreateData, type RagJobCreateResponse, type RagListCategoryData, type RagListCategoryResponse, type RagListFileData, type RagListFileResponse, type RagMonitorData, type RagMonitorResponse, type RagMutationResponse, type RagOssImportData, type RagOssImportFileResult, type RagOssImportResponse, type RagQpsMonitorData, type RagResponse, type RagStorageMonitorData, type RagUploadLeaseData, type RagUploadLeaseParam, type RagUploadLeaseResponse, type RecommendDeps, type RecommendSession, type RecommendedModel, type Region, type RequestOpts, type ResolutionSources, type ResponsesOutputContent, type ResponsesOutputItem, type ResponsesRequest, type ResponsesResponse, type ResponsesStreamEvent, type SecurityAlert, type SecurityAlertList, type SecurityOverview, type SecurityRiskLevel, type SecurityScanStat, type SecurityToggle, type ServerSentEvent, type Settings, type SingleResult, type SkillIndexEntry, type SkillInstallRecord, type SkillLockEntry, type SkillLockFile, type SkillMeta, type SkillStatus, type SkillStatusRow, type SkillsIndex, type SourceFlags, type StreamChoice, type StreamChunk, type ToolDeps, type TrackingDeps, type TrackingEvent, type TrackingIdentity, type TrainingProfile, type TrajectoryEvent, type UserProfileAttribute, type UserProfileResponse, type UserProfileValueItem, type UserProfileValueUpdateRequest, type ValidateOpts, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidationStats, type ValidatorSpec, type VocabularyEntry, type VocabularyEnvelope, type VocabularyListItem, type VocabularyRequest, analyzeIntent as analyzeEngineIntent, recommend as recommendEngine, route as routeEngine };