bailian-cli-runtime 2.7.1 → 2.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
@@ -1,4 +1,4 @@
1
- import { AnyCommand, ApiKeyCredential, AuthRequirement, AuthStore, BailianError, Client, Command, CommandPackManager, CommandRisk, ConfigStore, ExitCode, FlagDef, FlagDef as FlagDef$1, FlagsDef, Identity, ImageSizeProfile, Language, LocalizedText, OutputFormat, ParsedFlags, ResolutionSources, Settings, UsageError } from "bailian-cli-core";
1
+ import { AnyCommand, ApiKeyCredential, AuthRequirement, AuthStore, BailianError, Client, Command, CommandOutput, CommandPackManager, CommandRisk, ConfigStore, ExitCode, FlagDef, FlagDef as FlagDef$1, FlagsDef, Identity, ImageSizeProfile, Language, LocalizedText, ParsedFlags, ResolutionSources, Settings, UsageError } from "bailian-cli-core";
2
2
  //#region src/command-packs/types.d.ts
3
3
  interface CommandPackDefinition {
4
4
  commandPrefixes: readonly string[];
@@ -14,8 +14,10 @@ interface CommandPackPolicy {
14
14
  //#region src/create-cli.d.ts
15
15
  /** Per-product identity injected by each CLI entrypoint (bl / rag / …). */
16
16
  interface CliOptions {
17
- /** Binary name shown in help/usage/version output (e.g. "bl", "rag"). */
17
+ /** Product binary name and default invocation (e.g. "bl", "rag"). */
18
18
  binName: string;
19
+ /** Explicit executable invocation for structured command references. */
20
+ commandInvocation?: Identity["commandInvocation"];
19
21
  /** Product version for `--version` output, telemetry and update checks. */
20
22
  version: string;
21
23
  /** User-Agent / telemetry client name (e.g. "bailian-cli", "rag-cli")。必填,无默认。 */
@@ -30,7 +32,7 @@ interface CliOptions {
30
32
  interface Cli {
31
33
  run(argv?: string[]): Promise<void>;
32
34
  }
33
- /** 临时接管 Ctrl-C,由命令中断异步工作并完成清理;必须在 finally 中调用返回的释放函数。 */
35
+ /** Let a command cancel asynchronous work and finish cleanup before the runtime exits. */
34
36
  export declare function registerInterruptHandler(handler: () => void): () => void;
35
37
  /**
36
38
  * Build a CLI from an injected command set — each product (bl / rag / …) passes
@@ -110,6 +112,7 @@ export declare class CommandRegistry {
110
112
  //#endregion
111
113
  //#region src/introspect.d.ts
112
114
  interface CommandSchemaNode {
115
+ /** Complete subcommand chain after CommandSchema.bin, including fixed host subcommands. */
113
116
  path: readonly string[];
114
117
  description: LocalizedText;
115
118
  auth: AuthRequirement;
@@ -125,8 +128,10 @@ interface CommandSchemaNode {
125
128
  }
126
129
  interface CommandSchema {
127
130
  schema_version: 1;
131
+ /** Actual executable; combine with a command's path without splitting display text. */
128
132
  bin: string;
129
133
  version: string;
134
+ /** Executable path of the inspected root, group, or leaf. */
130
135
  scope: readonly string[];
131
136
  exitCodes: typeof ExitCode;
132
137
  globalFlags: Record<string, FlagDef$1>;
@@ -166,6 +171,7 @@ type Resolution = {
166
171
  } | {
167
172
  kind: "usageError";
168
173
  error: UsageError;
174
+ command?: AnyCommand;
169
175
  };
170
176
  /**
171
177
  * Classify argv into a {@link Resolution}. Pure over (argv, registry).
@@ -185,6 +191,7 @@ interface RunContext {
185
191
  prepared?: unknown;
186
192
  /** 静态产品身份(binName/version/npmPackage/clientName)。 */
187
193
  readonly identity: Identity;
194
+ readonly output: CommandOutput;
188
195
  /** The matched command path, e.g. ["speech","recognize"]. */
189
196
  readonly path: string[];
190
197
  readonly command: AnyCommand;
@@ -244,9 +251,30 @@ export declare function parseFlags<F extends FlagsDef>(rest: string[], defs: F,
244
251
  //#region src/proxy.d.ts
245
252
  export declare function setupProxyFromEnv(): void;
246
253
  //#endregion
254
+ //#region src/output/reporter.d.ts
255
+ interface OutputWriter {
256
+ write(chunk: string): unknown;
257
+ }
258
+ interface OutputReporterOptions {
259
+ settings: Pick<Settings, "output" | "quiet" | "verbose">;
260
+ stdout?: OutputWriter;
261
+ stderr?: OutputWriter;
262
+ localize?: (text: LocalizedText) => string;
263
+ commandPrefix?: string;
264
+ }
265
+ interface OutputReporter {
266
+ output: CommandOutput;
267
+ /** Runtime-only terminal error rendering. The lifecycle owns process exit. */
268
+ error(error: unknown): ExitCode;
269
+ }
270
+ /** Each invocation owns its writers, final result slot and terminal error state. */
271
+ export declare function createOutputReporter(options: OutputReporterOptions): OutputReporter;
272
+ //#endregion
247
273
  //#region src/error-handler.d.ts
248
- export declare function normalizeError(err: unknown, cliName: string): BailianError;
249
- export declare function handleError(err: unknown, cliName: string): never;
274
+ /** The invocation owns rendering; this boundary owns process termination. */
275
+ export declare function handleError(error: unknown, reporter: Pick<OutputReporter, "error">): never;
276
+ export declare function normalizeError(error: unknown, commandPrefix: string, localize: Localize): BailianError;
277
+ type Localize = (text: LocalizedText) => string;
250
278
  //#endregion
251
279
  //#region src/version.d.ts
252
280
  export declare const CLI_VERSION: string;
@@ -285,27 +313,6 @@ export declare const VOICE_TTS_PAGE = "https://help.aliyun.com/zh/model-studio/c
285
313
  */
286
314
  export declare function refundConsolePage(instanceId: string): string;
287
315
  //#endregion
288
- //#region src/output/output.d.ts
289
- /**
290
- * Emit the primary result of a command.
291
- * stdout → result (text by default; JSON with --output json)
292
- * stderr → human info (progress, logs, tips) — handled elsewhere
293
- */
294
- export declare function emitResult(data: unknown, format: OutputFormat): void;
295
- /**
296
- * Emit a bare value (file path, plain text) to stdout.
297
- * Used in --quiet mode or when the result is a single scalar.
298
- */
299
- export declare function emitBare(value: string): void;
300
- /**
301
- * Surface a server request id for text-mode output. Written to stderr (the
302
- * diagnostic channel) so it never corrupts the primary stdout result, mirroring
303
- * the request_id line the verbose HTTP logger prints. No-op when the id is
304
- * absent (e.g. dry-run) or in --quiet mode (which owes callers a bare scalar).
305
- * JSON output surfaces request_id inside the payload instead of calling this.
306
- */
307
- export declare function emitRequestId(requestId: string | undefined, quiet: boolean): void;
308
- //#endregion
309
316
  //#region src/output/table.d.ts
310
317
  /**
311
318
  * Tabular text formatting helper.
@@ -359,12 +366,6 @@ export declare function renderGauge(percent: number | null, label: string, width
359
366
  export declare function renderBoxTable(options: BoxTableOptions): string[];
360
367
  //#endregion
361
368
  //#region src/output/progress.d.ts
362
- interface Spinner {
363
- start(): void;
364
- update(text: string): void;
365
- stop(finalText?: string): void;
366
- }
367
- export declare function createSpinner(label: string): Spinner;
368
369
  interface ProgressBar {
369
370
  update(current: number): void;
370
371
  finish(): void;
@@ -376,7 +377,7 @@ export declare function printWelcomeBanner(cliName: string, translator?: Transla
376
377
  export declare function printQuickStart(tasks: readonly string[], language?: Language): void;
377
378
  //#endregion
378
379
  //#region src/output/status-bar.d.ts
379
- export declare function maybeShowStatusBar(settings: Settings, token: string, resolved: ApiKeyCredential): void;
380
+ export declare function maybeShowStatusBar(settings: Settings, token: string, resolved: ApiKeyCredential, output: CommandOutput): void;
380
381
  //#endregion
381
382
  //#region src/output/cjk-width.d.ts
382
383
  export declare function displayWidth(text: string): number;
@@ -407,6 +408,7 @@ export declare function ansi(out: NodeJS.WriteStream): AnsiStyles;
407
408
  //#endregion
408
409
  //#region src/utils/polling.d.ts
409
410
  interface PollOptions {
411
+ output: Pick<CommandOutput, "progress" | "debug">;
410
412
  /** Absolute task URL (Client passes absolute URLs through as-is). */
411
413
  url: string;
412
414
  /** Optional complete snapshot loader (for paginated task APIs). */
@@ -418,7 +420,7 @@ interface PollOptions {
418
420
  getStatus?: (data: unknown) => string;
419
421
  getErrorMessage?: (data: unknown) => string | undefined;
420
422
  }
421
- export declare function poll<T>(client: Client, settings: Settings, opts: PollOptions): Promise<T>;
423
+ export declare function poll<T>(client: Client, opts: PollOptions): Promise<T>;
422
424
  //#endregion
423
425
  //#region src/utils/download.d.ts
424
426
  export declare function downloadFile(url: string, destPath: string, opts?: {
@@ -438,12 +440,12 @@ export declare function getConcurrency(flags: {
438
440
  * Returns all resolved results in order.
439
441
  * If any single task fails, the error propagates (Promise.all semantics).
440
442
  *
441
- * @param n Number of concurrent executions
442
- * @param settings Resolved settings (for logging)
443
+ * @param count Number of concurrent executions
444
+ * @param output Invocation output for process information
443
445
  * @param task Async factory to execute
444
446
  * @param label Optional label for status output (e.g. "requests", "tasks")
445
447
  */
446
- export declare function runConcurrent<T>(n: number, settings: Settings, task: (index: number) => Promise<T>, label?: string): Promise<T[]>;
448
+ export declare function runConcurrent<T>(count: number, output: Pick<CommandOutput, "info">, task: (index: number) => Promise<T>, label?: "requests" | "tasks"): Promise<T[]>;
447
449
  /**
448
450
  * Parallel download helper — downloads multiple URLs concurrently.
449
451
  *
@@ -809,6 +811,8 @@ type PipelineLifecycleEvent = {
809
811
  };
810
812
  type PipelineEventHandler = (event: PipelineLifecycleEvent) => void | Promise<void>;
811
813
  interface ExecutePipelineOptions {
814
+ /** Invocation diagnostic sink; omitted library calls remain silent. */
815
+ output?: Pick<CommandOutput, "debug">;
812
816
  onEvent?: PipelineEventHandler;
813
817
  concurrency?: number;
814
818
  retryDelayBaseMs?: number;
@@ -862,6 +866,6 @@ export declare function collectPipelineHints(pipeline: PipelineDefinition, dispa
862
866
  //#endregion
863
867
  //#region src/pipeline/executor.d.ts
864
868
  export declare function executePipeline(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: ExecutePipelineOptions): Promise<PipelineExecutionReport>;
865
- export declare function streamPipelineEvents(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: Pick<ExecutePipelineOptions, "concurrency" | "basePath" | "dryRun" | "signal" | "timeoutSeconds" | "blRequestTimeoutSeconds" | "stepDispatcher">): AsyncGenerator<PipelineLifecycleEvent>;
869
+ export declare function streamPipelineEvents(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: Pick<ExecutePipelineOptions, "output" | "concurrency" | "basePath" | "dryRun" | "signal" | "timeoutSeconds" | "blRequestTimeoutSeconds" | "stepDispatcher">): AsyncGenerator<PipelineLifecycleEvent>;
866
870
  //#endregion
867
- export type { AnsiStyles, BarColumn, BoxTableOptions, Cli, CliOptions, Command, CommandPackCredentialAccess, CommandPackDefinition, CommandPackPolicy, CommandSchema, CommandSchemaNode, FlagDef, GaugeCell, LocateResult, Middleware, ParsePathResult, PipelineDefinition, PipelineLifecycleEvent, Resolution, RunContext, TextStyle };
871
+ export type { AnsiStyles, BarColumn, BoxTableOptions, Cli, CliOptions, Command, CommandPackCredentialAccess, CommandPackDefinition, CommandPackPolicy, CommandSchema, CommandSchemaNode, FlagDef, GaugeCell, LocateResult, Middleware, OutputReporter, OutputReporterOptions, OutputWriter, ParsePathResult, PipelineDefinition, PipelineLifecycleEvent, Resolution, RunContext, TextStyle };