bailian-cli-runtime 2.5.1 → 2.6.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
@@ -1,4 +1,4 @@
1
- import { AnyCommand, ApiKeyCredential, AuthStore, Client, Command, CommandPackManager, ConfigStore, FlagDef, FlagsDef, Identity, ImageSizeProfile, Language, LocalizedText, OutputFormat, ParsedFlags, ResolutionSources, Settings, UsageError } from "bailian-cli-core";
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";
2
2
  //#region src/command-packs/types.d.ts
3
3
  interface CommandPackDefinition {
4
4
  commandPrefixes: readonly string[];
@@ -30,6 +30,8 @@ interface CliOptions {
30
30
  interface Cli {
31
31
  run(argv?: string[]): Promise<void>;
32
32
  }
33
+ /** 临时接管 Ctrl-C,由命令中断异步工作并完成清理;必须在 finally 中调用返回的释放函数。 */
34
+ export declare function registerInterruptHandler(handler: () => void): () => void;
33
35
  /**
34
36
  * Build a CLI from an injected command set — each product (bl / rag / …) passes
35
37
  * its own commands + identity. `run` resolves argv into a {@link Resolution},
@@ -74,6 +76,13 @@ export declare class CommandRegistry {
74
76
  private localize;
75
77
  private register;
76
78
  getAllCommands(): AnyCommand[];
79
+ /** Read-only metadata traversal for command discovery and documentation. */
80
+ entries(path?: readonly string[]): readonly {
81
+ path: readonly string[];
82
+ command: AnyCommand;
83
+ }[];
84
+ /** No fallback when aliases make the intended product route ambiguous. */
85
+ commandPath(command: AnyCommand): string[] | undefined;
77
86
  /** First registered command path, for the "Getting Help" example (e.g. "knowledge search"). */
78
87
  private helpExample;
79
88
  /**
@@ -99,6 +108,36 @@ export declare class CommandRegistry {
99
108
  private printChildren;
100
109
  }
101
110
  //#endregion
111
+ //#region src/introspect.d.ts
112
+ interface CommandSchemaNode {
113
+ path: readonly string[];
114
+ description: LocalizedText;
115
+ auth: AuthRequirement;
116
+ usage: string;
117
+ flags: Record<string, FlagDef$1>;
118
+ notes: readonly LocalizedText[];
119
+ examples: readonly LocalizedText[];
120
+ risk?: CommandRisk;
121
+ preparation: "none" | "read-only";
122
+ constraints: {
123
+ crossFlagValidation: "not-exported";
124
+ };
125
+ }
126
+ interface CommandSchema {
127
+ schema_version: 1;
128
+ bin: string;
129
+ version: string;
130
+ scope: readonly string[];
131
+ exitCodes: typeof ExitCode;
132
+ globalFlags: Record<string, FlagDef$1>;
133
+ credentialFlags: Record<AuthRequirement, Record<string, FlagDef$1>>;
134
+ commands: readonly CommandSchemaNode[];
135
+ }
136
+ /** Only declarative metadata is exported. Never read settings, credentials, or execute callbacks. */
137
+ export declare function buildCommandSchema(registry: CommandRegistry, identity: Identity, path?: readonly string[]): CommandSchema;
138
+ /** Recursively sort object keys, preserving semantically ordered arrays. */
139
+ export declare function serializeCommandSchema(schema: CommandSchema): string;
140
+ //#endregion
102
141
  //#region src/resolve.d.ts
103
142
  /**
104
143
  * What an invocation resolves to — "what to do" expressed as data, not control
@@ -111,6 +150,9 @@ export declare class CommandRegistry {
111
150
  */
112
151
  type Resolution = {
113
152
  kind: "version";
153
+ } | {
154
+ kind: "introspect";
155
+ path: string[];
114
156
  } | {
115
157
  kind: "help";
116
158
  path: string[];
@@ -139,6 +181,8 @@ export declare function resolve(argv: string[], registry: CommandRegistry, local
139
181
  * {@link authStage}). A stage reads these and may augment them before `next()`.
140
182
  */
141
183
  interface RunContext {
184
+ commandPath?: (command: AnyCommand) => string[] | undefined;
185
+ prepared?: unknown;
142
186
  /** 静态产品身份(binName/version/npmPackage/clientName)。 */
143
187
  readonly identity: Identity;
144
188
  /** The matched command path, e.g. ["speech","recognize"]. */
@@ -179,6 +223,7 @@ interface ParsePathResult {
179
223
  rest: string[];
180
224
  hasHelpFlag: boolean;
181
225
  hasVersionFlag: boolean;
226
+ hasIntrospectFlag: boolean;
182
227
  }
183
228
  /**
184
229
  * First-pass routing parse.
@@ -200,6 +245,7 @@ export declare function parseFlags<F extends FlagsDef>(rest: string[], defs: F,
200
245
  export declare function setupProxyFromEnv(): void;
201
246
  //#endregion
202
247
  //#region src/error-handler.d.ts
248
+ export declare function normalizeError(err: unknown, cliName: string): BailianError;
203
249
  export declare function handleError(err: unknown, cliName: string): never;
204
250
  //#endregion
205
251
  //#region src/version.d.ts
@@ -219,6 +265,8 @@ export declare const BAILIAN_CONSOLE_ROOT = "https://bailian.console.aliyun.com"
219
265
  export declare const BAILIAN_CONSOLE = "https://bailian.console.aliyun.com/cn-beijing";
220
266
  /** Direct deep link to API key management page. */
221
267
  export declare const API_KEY_PAGE = "https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key";
268
+ /** Running-time billing, shared trial allowance and model-call charges for RAG. */
269
+ export declare const KNOWLEDGE_BILLING_PAGE = "https://help.aliyun.com/zh/model-studio/billing-for-knowledge-base";
222
270
  /** Direct deep link to the Token Plan subscription overview and API key entry. */
223
271
  export declare const TOKEN_PLAN_PAGE = "https://bailian.console.aliyun.com/cn-beijing?tab=plan#/efm/subscription/overview";
224
272
  /** MCP marketplace detail page for a server code (e.g. WebSearch, market-cmapi00073529). */
@@ -361,6 +409,8 @@ export declare function ansi(out: NodeJS.WriteStream): AnsiStyles;
361
409
  interface PollOptions {
362
410
  /** Absolute task URL (Client passes absolute URLs through as-is). */
363
411
  url: string;
412
+ /** Optional complete snapshot loader (for paginated task APIs). */
413
+ load?: () => Promise<unknown>;
364
414
  intervalSec: number;
365
415
  timeoutSec: number;
366
416
  isComplete: (data: unknown) => boolean;
@@ -814,4 +864,4 @@ export declare function collectPipelineHints(pipeline: PipelineDefinition, dispa
814
864
  export declare function executePipeline(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: ExecutePipelineOptions): Promise<PipelineExecutionReport>;
815
865
  export declare function streamPipelineEvents(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: Pick<ExecutePipelineOptions, "concurrency" | "basePath" | "dryRun" | "signal" | "timeoutSeconds" | "blRequestTimeoutSeconds" | "stepDispatcher">): AsyncGenerator<PipelineLifecycleEvent>;
816
866
  //#endregion
817
- export type { AnsiStyles, BarColumn, BoxTableOptions, Cli, CliOptions, Command, CommandPackCredentialAccess, CommandPackDefinition, CommandPackPolicy, FlagDef, GaugeCell, LocateResult, Middleware, ParsePathResult, PipelineDefinition, PipelineLifecycleEvent, Resolution, RunContext, TextStyle };
867
+ export type { AnsiStyles, BarColumn, BoxTableOptions, Cli, CliOptions, Command, CommandPackCredentialAccess, CommandPackDefinition, CommandPackPolicy, CommandSchema, CommandSchemaNode, FlagDef, GaugeCell, LocateResult, Middleware, ParsePathResult, PipelineDefinition, PipelineLifecycleEvent, Resolution, RunContext, TextStyle };