bailian-cli-runtime 0.0.0-beta-46d8474-20260626
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/LICENSE +202 -0
- package/dist/chunk-POvHkJ8y.mjs +1 -0
- package/dist/dist-DgvkrLd1.mjs +36 -0
- package/dist/index.d.mts +563 -0
- package/dist/index.mjs +55 -0
- package/package.json +63 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { Command, Command as Command$1, Config, GlobalFlags, OptionDef, OptionDef as OptionDef$1, OutputFormat, ResolvedCredential } from "bailian-cli-core";
|
|
2
|
+
|
|
3
|
+
//#region src/create-cli.d.ts
|
|
4
|
+
/** Per-product identity injected by each CLI entrypoint (bl / rag / …). */
|
|
5
|
+
interface CliOptions {
|
|
6
|
+
/** Binary name shown in help/usage/version output (e.g. "bl", "rag"). */
|
|
7
|
+
binName: string;
|
|
8
|
+
/** Product version for `--version` output, telemetry and update checks. */
|
|
9
|
+
version: string;
|
|
10
|
+
/** Telemetry client name (e.g. "bailian-cli", "rag-cli"). Defaults to `binName`. */
|
|
11
|
+
clientName?: string;
|
|
12
|
+
/** npm package name for self-update (e.g. "bailian-cli", "bailian-cli-rag"). */
|
|
13
|
+
npmPackage: string;
|
|
14
|
+
}
|
|
15
|
+
interface Cli {
|
|
16
|
+
run(argv?: string[]): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build a CLI from an injected command set. The runtime is agnostic to *which*
|
|
20
|
+
* commands exist — each product (bailian-cli, rag-cli, …) passes its own map and
|
|
21
|
+
* identity. No module-level singleton: the registry is scoped to this instance.
|
|
22
|
+
*/
|
|
23
|
+
declare function createCli(commands: Record<string, Command$1>, opts: CliOptions): Cli;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/registry.d.ts
|
|
26
|
+
declare class CommandRegistry {
|
|
27
|
+
private root;
|
|
28
|
+
/** Binary name shown in usage/help/error strings (e.g. "bl", "rag"). */
|
|
29
|
+
private readonly cliName;
|
|
30
|
+
constructor(commands: Record<string, Command$1>, cliName: string);
|
|
31
|
+
private register;
|
|
32
|
+
getAllCommands(): Command$1[];
|
|
33
|
+
/** First registered command path, for the "Getting Help" example (e.g. "knowledge retrieve"). */
|
|
34
|
+
private helpExample;
|
|
35
|
+
isGroupPath(commandPath: string[]): boolean;
|
|
36
|
+
resolve(commandPath: string[]): {
|
|
37
|
+
command: Command$1;
|
|
38
|
+
extra: string[];
|
|
39
|
+
};
|
|
40
|
+
private buildResourceLines;
|
|
41
|
+
private buildGlobalFlagLines;
|
|
42
|
+
private bold;
|
|
43
|
+
private accent;
|
|
44
|
+
private dim;
|
|
45
|
+
printHelp(commandPath: string[], out?: NodeJS.WriteStream): void;
|
|
46
|
+
private printPipelineQuickStart;
|
|
47
|
+
private printRootHelp;
|
|
48
|
+
private printCommandHelp;
|
|
49
|
+
private printChildren;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/args.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* Quick scan: collect positional (non-dash) args to determine the command path.
|
|
55
|
+
* Skips global flags and their values so that e.g. `--output json text chat`
|
|
56
|
+
* correctly produces ['text', 'chat'] instead of ['json', 'text', 'chat'].
|
|
57
|
+
*/
|
|
58
|
+
declare function scanCommandPath(argv: string[], globalOptions?: OptionDef$1[]): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Full flag parse. Types are derived entirely from the provided OptionDef schema:
|
|
61
|
+
* - boolean: no <value> placeholder in flag string (or type: 'boolean')
|
|
62
|
+
* - number: type: 'number'
|
|
63
|
+
* - array: type: 'array' (repeatable via multiple --flag occurrences)
|
|
64
|
+
* - default: string
|
|
65
|
+
*/
|
|
66
|
+
declare function parseFlags(argv: string[], options: OptionDef$1[]): GlobalFlags;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/proxy.d.ts
|
|
69
|
+
declare function setupProxyFromEnv(): void;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/error-handler.d.ts
|
|
72
|
+
declare function handleError(err: unknown, cliName: string): never;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/version.d.ts
|
|
75
|
+
declare const CLI_VERSION: string;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/urls.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* User-facing Aliyun Bailian / Model Studio console URLs.
|
|
80
|
+
*
|
|
81
|
+
* Single source of truth for all `bailian.console.aliyun.com/*` references
|
|
82
|
+
* across cli source. Currently pinned to cn-beijing — expand to a region map
|
|
83
|
+
* if/when overseas console support is added.
|
|
84
|
+
*/
|
|
85
|
+
/** Root entry — generic console landing, region picker. */
|
|
86
|
+
declare const BAILIAN_CONSOLE_ROOT = "https://bailian.console.aliyun.com";
|
|
87
|
+
/** Region-pinned console base. Add a region map if/when overseas is supported. */
|
|
88
|
+
declare const BAILIAN_CONSOLE = "https://bailian.console.aliyun.com/cn-beijing";
|
|
89
|
+
/** Direct deep link to API key management page. */
|
|
90
|
+
declare const API_KEY_PAGE = "https://bailian.console.aliyun.com/cn-beijing/?tab=app#/api-key";
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/output/output.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* Emit the primary result of a command.
|
|
95
|
+
*
|
|
96
|
+
* Design principle:
|
|
97
|
+
* stdout → structured data only (JSON when piped, text when TTY)
|
|
98
|
+
* stderr → human info (progress, logs, tips) — handled elsewhere
|
|
99
|
+
*
|
|
100
|
+
* This ensures `bl cmd ... | jq .` always receives clean JSON,
|
|
101
|
+
* while interactive users see human-readable text.
|
|
102
|
+
*/
|
|
103
|
+
declare function emitResult(data: unknown, format: OutputFormat): void;
|
|
104
|
+
/**
|
|
105
|
+
* Emit a bare value (file path, plain text) to stdout.
|
|
106
|
+
* Used in --quiet mode or when the result is a single scalar.
|
|
107
|
+
*/
|
|
108
|
+
declare function emitBare(value: string): void;
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/output/prompt.d.ts
|
|
111
|
+
/**
|
|
112
|
+
* Build a command-usage string for the running command: `<binName> <path> <args>`.
|
|
113
|
+
* Both the product binary name and the command path come from the runtime, so
|
|
114
|
+
* callers never hardcode "bl" or their own path — the same code renders as
|
|
115
|
+
* `bl knowledge retrieve …` under bl and `rag retrieve …` under rag.
|
|
116
|
+
*/
|
|
117
|
+
declare function cmdUsage(config: Config, args?: string): string;
|
|
118
|
+
/**
|
|
119
|
+
* Prompt the user for a text value.
|
|
120
|
+
* Only call this when isInteractive() is true; otherwise the function returns
|
|
121
|
+
* undefined immediately so the caller can fail fast.
|
|
122
|
+
*/
|
|
123
|
+
declare function promptText(options: {
|
|
124
|
+
message: string;
|
|
125
|
+
defaultValue?: string;
|
|
126
|
+
}): Promise<string | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* Like promptText but confirms with y/N before proceeding.
|
|
129
|
+
*/
|
|
130
|
+
declare function promptConfirm(options: {
|
|
131
|
+
message: string;
|
|
132
|
+
initialValue?: boolean;
|
|
133
|
+
}): Promise<boolean | undefined>;
|
|
134
|
+
/**
|
|
135
|
+
* Prompt the user to select one value from a list.
|
|
136
|
+
* Only call this when isInteractive() is true; otherwise the function returns
|
|
137
|
+
* undefined immediately so the caller can fail fast.
|
|
138
|
+
*/
|
|
139
|
+
declare function promptSelect(options: {
|
|
140
|
+
message: string;
|
|
141
|
+
choices: Array<{
|
|
142
|
+
value: string;
|
|
143
|
+
label: string;
|
|
144
|
+
hint?: string;
|
|
145
|
+
}>;
|
|
146
|
+
defaultValue?: string;
|
|
147
|
+
}): Promise<string | undefined>;
|
|
148
|
+
/**
|
|
149
|
+
* Fail fast with a user-friendly error when a required option is missing
|
|
150
|
+
* in non-interactive (agent / CI) mode.
|
|
151
|
+
*/
|
|
152
|
+
declare function failIfMissing(flagName: string, context: string): never;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/output/progress.d.ts
|
|
155
|
+
interface Spinner {
|
|
156
|
+
start(): void;
|
|
157
|
+
update(text: string): void;
|
|
158
|
+
stop(finalText?: string): void;
|
|
159
|
+
}
|
|
160
|
+
declare function createSpinner(label: string): Spinner;
|
|
161
|
+
interface ProgressBar {
|
|
162
|
+
update(current: number): void;
|
|
163
|
+
finish(): void;
|
|
164
|
+
}
|
|
165
|
+
declare function createProgressBar(total: number, label?: string): ProgressBar;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/output/banner.d.ts
|
|
168
|
+
declare function printWelcomeBanner(cliName: string): void;
|
|
169
|
+
declare function printQuickStart(): void;
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/output/status-bar.d.ts
|
|
172
|
+
declare function maybeShowStatusBar(config: Config, token: string, resolved?: ResolvedCredential): void;
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/output/cjk-width.d.ts
|
|
175
|
+
declare function displayWidth(text: string): number;
|
|
176
|
+
declare function padEnd(text: string, targetWidth: number): string;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/utils/polling.d.ts
|
|
179
|
+
interface PollOptions {
|
|
180
|
+
url: string;
|
|
181
|
+
intervalSec: number;
|
|
182
|
+
timeoutSec: number;
|
|
183
|
+
isComplete: (data: unknown) => boolean;
|
|
184
|
+
isFailed: (data: unknown) => boolean;
|
|
185
|
+
getStatus?: (data: unknown) => string;
|
|
186
|
+
getErrorMessage?: (data: unknown) => string | undefined;
|
|
187
|
+
}
|
|
188
|
+
declare function poll<T>(config: Config, opts: PollOptions): Promise<T>;
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/utils/download.d.ts
|
|
191
|
+
declare function downloadFile(url: string, destPath: string, opts?: {
|
|
192
|
+
quiet?: boolean;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
size: number;
|
|
195
|
+
}>;
|
|
196
|
+
declare function formatBytes(bytes: number): string;
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/utils/concurrent.d.ts
|
|
199
|
+
/** Resolve concurrency from flags (defaults to 1). */
|
|
200
|
+
declare function getConcurrency(flags: GlobalFlags): number;
|
|
201
|
+
/**
|
|
202
|
+
* Run an async task N times concurrently.
|
|
203
|
+
* Returns all resolved results in order.
|
|
204
|
+
* If any single task fails, the error propagates (Promise.all semantics).
|
|
205
|
+
*
|
|
206
|
+
* @param n Number of concurrent executions
|
|
207
|
+
* @param config CLI config (for logging)
|
|
208
|
+
* @param task Async factory to execute
|
|
209
|
+
* @param label Optional label for status output (e.g. "requests", "tasks")
|
|
210
|
+
*/
|
|
211
|
+
declare function runConcurrent<T>(n: number, config: Config, task: (index: number) => Promise<T>, label?: string): Promise<T[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Parallel download helper — downloads multiple URLs concurrently.
|
|
214
|
+
*
|
|
215
|
+
* @param items Array of { url, destPath } pairs
|
|
216
|
+
* @param downloadFn Download function (url, destPath, opts) => Promise
|
|
217
|
+
* @param opts Options passed to download function
|
|
218
|
+
* @returns Array of saved file paths in order
|
|
219
|
+
*/
|
|
220
|
+
declare function downloadParallel(items: Array<{
|
|
221
|
+
url: string;
|
|
222
|
+
destPath: string;
|
|
223
|
+
}>, downloadFn: (url: string, destPath: string, opts?: {
|
|
224
|
+
quiet?: boolean;
|
|
225
|
+
}) => Promise<unknown>, opts?: {
|
|
226
|
+
quiet?: boolean;
|
|
227
|
+
}): Promise<string[]>;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/utils/image-size.d.ts
|
|
230
|
+
/** Resolve `--size` value: accept ratio (3:4) or pixel (W*H) format. */
|
|
231
|
+
declare function resolveImageSize(input: string, useSync: boolean): string;
|
|
232
|
+
declare function resolveImageSize(input: string | undefined, useSync: boolean): string | undefined;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/utils/ensure-key.d.ts
|
|
235
|
+
declare function ensureApiKey(config: Config): Promise<void>;
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/utils/command-help.d.ts
|
|
238
|
+
declare function setExecutingCommandPath(path: string[]): void;
|
|
239
|
+
declare function getExecutingCommandPath(): string[];
|
|
240
|
+
declare function registerCommandHelpPrinter(fn: (commandPath: string[], out: NodeJS.WriteStream) => void): void;
|
|
241
|
+
/** Print help for the command currently being executed (must call `setExecutingCommandPath` first). */
|
|
242
|
+
declare function printCurrentCommandHelp(out?: NodeJS.WriteStream): void;
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/utils/update-checker.d.ts
|
|
245
|
+
declare const NPM_REGISTRY = "https://registry.npmjs.org";
|
|
246
|
+
/** Default npm package; products override per-call via the `npmPackage` argument. */
|
|
247
|
+
declare const NPM_PACKAGE = "bailian-cli";
|
|
248
|
+
declare function fetchLatestVersion(timeoutMs?: number, npmPackage?: string): Promise<string | null>;
|
|
249
|
+
declare function getPendingUpdateNotification(): string | null;
|
|
250
|
+
declare function checkForUpdate(currentVersion: string, npmPackage?: string): Promise<void>;
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/utils/flag-descriptions.d.ts
|
|
253
|
+
/** Shared --foo <bool> help text; keep wording consistent with actual CLI/request behavior. */
|
|
254
|
+
declare const BOOL_FLAG_WATERMARK = "Enable watermark (true/false). Omit flag to use CLI default (true).";
|
|
255
|
+
/** CLI sends prompt_extend=true when flag omitted (qwen-image edit, etc.). */
|
|
256
|
+
declare const BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE = "Enable prompt extend (true/false). Omit flag to use CLI default (true).";
|
|
257
|
+
/** Sync qwen-image defaults on; async models omit the field unless flag is set. */
|
|
258
|
+
declare const BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE = "Enable prompt extend (true/false). Omit flag: true for qwen-image sync; parameter omitted on async models (API default).";
|
|
259
|
+
/** CLI omits prompt_extend in the request when flag is unset (video commands). */
|
|
260
|
+
declare const BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT = "Enable prompt extend (true/false). Omit flag to omit the parameter (DashScope default).";
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/pipeline/types.d.ts
|
|
263
|
+
declare const WORKFLOW_VERSION = "workflow/v1";
|
|
264
|
+
interface StepArtifact {
|
|
265
|
+
id?: string;
|
|
266
|
+
path?: string;
|
|
267
|
+
url?: string;
|
|
268
|
+
mediaType?: string;
|
|
269
|
+
taskId?: string;
|
|
270
|
+
kind?: string;
|
|
271
|
+
expiresAt?: string;
|
|
272
|
+
metadata?: Record<string, unknown>;
|
|
273
|
+
}
|
|
274
|
+
interface StepWarning {
|
|
275
|
+
code: string;
|
|
276
|
+
message: string;
|
|
277
|
+
details?: Record<string, unknown>;
|
|
278
|
+
}
|
|
279
|
+
interface StepResult {
|
|
280
|
+
data?: unknown;
|
|
281
|
+
artifacts?: StepArtifact[];
|
|
282
|
+
warnings?: StepWarning[];
|
|
283
|
+
metadata?: Record<string, unknown>;
|
|
284
|
+
}
|
|
285
|
+
interface StructuredStepErrorShape {
|
|
286
|
+
code: string;
|
|
287
|
+
message: string;
|
|
288
|
+
step?: string;
|
|
289
|
+
details?: Record<string, unknown>;
|
|
290
|
+
}
|
|
291
|
+
type JsonSchemaPrimitiveType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
292
|
+
interface JsonSchema {
|
|
293
|
+
type?: JsonSchemaPrimitiveType | JsonSchemaPrimitiveType[];
|
|
294
|
+
properties?: Record<string, JsonSchema>;
|
|
295
|
+
items?: JsonSchema;
|
|
296
|
+
required?: string[];
|
|
297
|
+
enum?: unknown[];
|
|
298
|
+
default?: unknown;
|
|
299
|
+
description?: string;
|
|
300
|
+
format?: string;
|
|
301
|
+
additionalProperties?: boolean | JsonSchema;
|
|
302
|
+
}
|
|
303
|
+
type PipelineInputExpression = unknown | {
|
|
304
|
+
$input: string;
|
|
305
|
+
} | {
|
|
306
|
+
$from: string;
|
|
307
|
+
path?: string;
|
|
308
|
+
} | {
|
|
309
|
+
$env: string;
|
|
310
|
+
} | {
|
|
311
|
+
$secret: string;
|
|
312
|
+
} | {
|
|
313
|
+
$concat: PipelineInputExpression[];
|
|
314
|
+
} | {
|
|
315
|
+
$coalesce: PipelineInputExpression[];
|
|
316
|
+
} | {
|
|
317
|
+
$js: string;
|
|
318
|
+
args?: Record<string, PipelineInputExpression>;
|
|
319
|
+
};
|
|
320
|
+
type PipelineConditionExpression = boolean | PipelineInputExpression | {
|
|
321
|
+
$exists: PipelineInputExpression;
|
|
322
|
+
} | {
|
|
323
|
+
$eq: [PipelineInputExpression, PipelineInputExpression];
|
|
324
|
+
} | {
|
|
325
|
+
$ne: [PipelineInputExpression, PipelineInputExpression];
|
|
326
|
+
} | {
|
|
327
|
+
$gt: [PipelineInputExpression, PipelineInputExpression];
|
|
328
|
+
} | {
|
|
329
|
+
$gte: [PipelineInputExpression, PipelineInputExpression];
|
|
330
|
+
} | {
|
|
331
|
+
$lt: [PipelineInputExpression, PipelineInputExpression];
|
|
332
|
+
} | {
|
|
333
|
+
$lte: [PipelineInputExpression, PipelineInputExpression];
|
|
334
|
+
} | {
|
|
335
|
+
$in: [PipelineInputExpression, PipelineInputExpression];
|
|
336
|
+
} | {
|
|
337
|
+
$contains: [PipelineInputExpression, PipelineInputExpression];
|
|
338
|
+
} | {
|
|
339
|
+
$and: PipelineConditionExpression[];
|
|
340
|
+
} | {
|
|
341
|
+
$or: PipelineConditionExpression[];
|
|
342
|
+
} | {
|
|
343
|
+
$not: PipelineConditionExpression;
|
|
344
|
+
};
|
|
345
|
+
interface PipelineRetryPolicy {
|
|
346
|
+
maxAttempts?: number;
|
|
347
|
+
backoff?: "none" | "linear" | "exponential";
|
|
348
|
+
}
|
|
349
|
+
interface PipelineBinding {
|
|
350
|
+
from?: "env";
|
|
351
|
+
name: string;
|
|
352
|
+
required?: boolean;
|
|
353
|
+
default?: unknown;
|
|
354
|
+
}
|
|
355
|
+
interface PipelineStep {
|
|
356
|
+
id: string;
|
|
357
|
+
type: string;
|
|
358
|
+
input: Record<string, PipelineInputExpression>;
|
|
359
|
+
dependsOn?: string[];
|
|
360
|
+
when?: PipelineConditionExpression;
|
|
361
|
+
retry?: PipelineRetryPolicy;
|
|
362
|
+
timeout?: string | number;
|
|
363
|
+
}
|
|
364
|
+
interface PipelineDefinition {
|
|
365
|
+
version: typeof WORKFLOW_VERSION;
|
|
366
|
+
inputs?: JsonSchema;
|
|
367
|
+
env?: Record<string, string | PipelineBinding>;
|
|
368
|
+
secrets?: Record<string, string | PipelineBinding>;
|
|
369
|
+
steps: PipelineStep[];
|
|
370
|
+
}
|
|
371
|
+
interface PipelineStepReport {
|
|
372
|
+
id: string;
|
|
373
|
+
type: string;
|
|
374
|
+
status: "planned" | "succeeded" | "failed" | "skipped";
|
|
375
|
+
dependencies?: string[];
|
|
376
|
+
input?: Record<string, unknown>;
|
|
377
|
+
output?: StepResult;
|
|
378
|
+
error?: StructuredStepErrorShape;
|
|
379
|
+
startedAt?: string;
|
|
380
|
+
finishedAt?: string;
|
|
381
|
+
attempts?: number;
|
|
382
|
+
skipReason?: string;
|
|
383
|
+
condition?: "pending" | "true" | "false";
|
|
384
|
+
}
|
|
385
|
+
interface PipelineExecutionReport {
|
|
386
|
+
status: "planned" | "succeeded" | "failed";
|
|
387
|
+
version: typeof WORKFLOW_VERSION;
|
|
388
|
+
steps: PipelineStepReport[];
|
|
389
|
+
artifacts: StepArtifact[];
|
|
390
|
+
}
|
|
391
|
+
interface PipelineEventStep {
|
|
392
|
+
id: string;
|
|
393
|
+
type: string;
|
|
394
|
+
dependencies?: string[];
|
|
395
|
+
index?: number;
|
|
396
|
+
total?: number;
|
|
397
|
+
}
|
|
398
|
+
interface PipelineEventTiming {
|
|
399
|
+
startedAt?: string;
|
|
400
|
+
finishedAt?: string;
|
|
401
|
+
durationMs?: number;
|
|
402
|
+
}
|
|
403
|
+
interface PipelineEventInputSummary {
|
|
404
|
+
keys: string[];
|
|
405
|
+
redactedKeys?: string[];
|
|
406
|
+
}
|
|
407
|
+
interface PipelineEventOutputSummary {
|
|
408
|
+
dataType?: string;
|
|
409
|
+
artifactCount: number;
|
|
410
|
+
warningCount: number;
|
|
411
|
+
metadata?: Record<string, unknown>;
|
|
412
|
+
}
|
|
413
|
+
type PipelineLifecycleEvent = {
|
|
414
|
+
type: "pipeline.started";
|
|
415
|
+
timestamp: string;
|
|
416
|
+
status: "running" | "planned";
|
|
417
|
+
stepCount: number;
|
|
418
|
+
dryRun: boolean;
|
|
419
|
+
} | {
|
|
420
|
+
type: "step.input.resolved";
|
|
421
|
+
timestamp: string;
|
|
422
|
+
status: "running" | "planned";
|
|
423
|
+
step: PipelineEventStep;
|
|
424
|
+
input: PipelineEventInputSummary;
|
|
425
|
+
} | {
|
|
426
|
+
type: "step.planned";
|
|
427
|
+
timestamp: string;
|
|
428
|
+
status: "planned";
|
|
429
|
+
step: PipelineEventStep;
|
|
430
|
+
input: PipelineEventInputSummary;
|
|
431
|
+
condition?: "pending";
|
|
432
|
+
} | {
|
|
433
|
+
type: "step.started";
|
|
434
|
+
timestamp: string;
|
|
435
|
+
status: "running";
|
|
436
|
+
step: PipelineEventStep;
|
|
437
|
+
timing: PipelineEventTiming;
|
|
438
|
+
attempt: number;
|
|
439
|
+
} | {
|
|
440
|
+
type: "step.retrying";
|
|
441
|
+
timestamp: string;
|
|
442
|
+
status: "running";
|
|
443
|
+
step: PipelineEventStep;
|
|
444
|
+
attempt: number;
|
|
445
|
+
nextAttempt: number;
|
|
446
|
+
error: StructuredStepErrorShape;
|
|
447
|
+
} | {
|
|
448
|
+
type: "artifact.created";
|
|
449
|
+
timestamp: string;
|
|
450
|
+
status: "running";
|
|
451
|
+
step: PipelineEventStep;
|
|
452
|
+
artifact: StepArtifact;
|
|
453
|
+
} | {
|
|
454
|
+
type: "step.succeeded";
|
|
455
|
+
timestamp: string;
|
|
456
|
+
status: "running";
|
|
457
|
+
step: PipelineEventStep;
|
|
458
|
+
timing: PipelineEventTiming;
|
|
459
|
+
output: PipelineEventOutputSummary;
|
|
460
|
+
attempt: number;
|
|
461
|
+
warnings?: StepWarning[];
|
|
462
|
+
} | {
|
|
463
|
+
type: "step.skipped";
|
|
464
|
+
timestamp: string;
|
|
465
|
+
status: "running" | "planned";
|
|
466
|
+
step: PipelineEventStep;
|
|
467
|
+
reason: string;
|
|
468
|
+
} | {
|
|
469
|
+
type: "step.failed";
|
|
470
|
+
timestamp: string;
|
|
471
|
+
status: "failed";
|
|
472
|
+
step: PipelineEventStep;
|
|
473
|
+
timing: PipelineEventTiming;
|
|
474
|
+
attempt: number;
|
|
475
|
+
error: StructuredStepErrorShape;
|
|
476
|
+
} | {
|
|
477
|
+
type: "pipeline.planned";
|
|
478
|
+
timestamp: string;
|
|
479
|
+
status: "planned";
|
|
480
|
+
stepCount: number;
|
|
481
|
+
artifactCount: number;
|
|
482
|
+
} | {
|
|
483
|
+
type: "pipeline.succeeded";
|
|
484
|
+
timestamp: string;
|
|
485
|
+
status: "succeeded";
|
|
486
|
+
stepCount: number;
|
|
487
|
+
artifactCount: number;
|
|
488
|
+
} | {
|
|
489
|
+
type: "step.polling";
|
|
490
|
+
timestamp: string;
|
|
491
|
+
status: "running";
|
|
492
|
+
step: PipelineEventStep;
|
|
493
|
+
taskId: string;
|
|
494
|
+
taskStatus: string;
|
|
495
|
+
elapsedMs: number;
|
|
496
|
+
pollAttempt: number;
|
|
497
|
+
} | {
|
|
498
|
+
type: "pipeline.failed";
|
|
499
|
+
timestamp: string;
|
|
500
|
+
status: "failed";
|
|
501
|
+
stepCount: number;
|
|
502
|
+
artifactCount: number;
|
|
503
|
+
failedStep: PipelineEventStep;
|
|
504
|
+
error: StructuredStepErrorShape;
|
|
505
|
+
};
|
|
506
|
+
type PipelineEventHandler = (event: PipelineLifecycleEvent) => void | Promise<void>;
|
|
507
|
+
interface ExecutePipelineOptions {
|
|
508
|
+
onEvent?: PipelineEventHandler;
|
|
509
|
+
concurrency?: number;
|
|
510
|
+
retryDelayBaseMs?: number;
|
|
511
|
+
sleep?: (ms: number) => Promise<void>;
|
|
512
|
+
basePath?: string;
|
|
513
|
+
dryRun?: boolean;
|
|
514
|
+
signal?: AbortSignal;
|
|
515
|
+
timeoutSeconds?: number;
|
|
516
|
+
blRequestTimeoutSeconds?: number;
|
|
517
|
+
stepDispatcher?: StepDispatcher;
|
|
518
|
+
}
|
|
519
|
+
interface StepOutputPath {
|
|
520
|
+
path: string;
|
|
521
|
+
description: string;
|
|
522
|
+
}
|
|
523
|
+
interface StepOutputSchema {
|
|
524
|
+
description?: string;
|
|
525
|
+
paths: StepOutputPath[];
|
|
526
|
+
}
|
|
527
|
+
type StepHandler = (input: Record<string, unknown>, ctx: StepContext) => Promise<StepResult> | StepResult;
|
|
528
|
+
interface StepContext {
|
|
529
|
+
dryRun: boolean;
|
|
530
|
+
signal?: AbortSignal;
|
|
531
|
+
timeoutSeconds?: number;
|
|
532
|
+
blRequestTimeoutSeconds?: number;
|
|
533
|
+
emitEvent?: (event: Record<string, unknown>) => void | Promise<void>;
|
|
534
|
+
blConfig?: unknown;
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/pipeline/dispatcher.d.ts
|
|
538
|
+
declare class StepDispatcher {
|
|
539
|
+
private readonly handlers;
|
|
540
|
+
private readonly outputSchemas;
|
|
541
|
+
registerStep(id: string, handler: StepHandler, outputSchema?: StepOutputSchema): void;
|
|
542
|
+
executeStep(id: string, input: Record<string, unknown>, ctx: StepContext): Promise<StepResult> | StepResult;
|
|
543
|
+
hasStep(id: string): boolean;
|
|
544
|
+
listSteps(): string[];
|
|
545
|
+
getOutputSchema(id: string): StepOutputSchema | undefined;
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/pipeline/init.d.ts
|
|
549
|
+
declare function initPipelineSteps(dispatcher?: StepDispatcher): StepDispatcher;
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/pipeline/validation.d.ts
|
|
552
|
+
declare function collectPipelineIssues(pipeline: PipelineDefinition, dispatcher?: StepDispatcher): string[];
|
|
553
|
+
/**
|
|
554
|
+
* Collect non-blocking hints about potentially invalid $from paths.
|
|
555
|
+
* These do not prevent execution but help workflow authors catch typos.
|
|
556
|
+
*/
|
|
557
|
+
declare function collectPipelineHints(pipeline: PipelineDefinition, dispatcher?: StepDispatcher): string[];
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/pipeline/executor.d.ts
|
|
560
|
+
declare function executePipeline(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: ExecutePipelineOptions): Promise<PipelineExecutionReport>;
|
|
561
|
+
declare function streamPipelineEvents(pipeline: PipelineDefinition, runtimeInput?: Record<string, unknown>, options?: Pick<ExecutePipelineOptions, "concurrency" | "basePath" | "dryRun" | "signal" | "timeoutSeconds" | "blRequestTimeoutSeconds" | "stepDispatcher">): AsyncGenerator<PipelineLifecycleEvent>;
|
|
562
|
+
//#endregion
|
|
563
|
+
export { API_KEY_PAGE, BAILIAN_CONSOLE, BAILIAN_CONSOLE_ROOT, BOOL_FLAG_PROMPT_EXTEND_API_DEFAULT, BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE, BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE, BOOL_FLAG_WATERMARK, CLI_VERSION, type Cli, type CliOptions, type Command, CommandRegistry, NPM_PACKAGE, NPM_REGISTRY, type OptionDef, type PipelineDefinition, type PipelineLifecycleEvent, checkForUpdate, cmdUsage, collectPipelineHints, collectPipelineIssues, createCli, createProgressBar, createSpinner, displayWidth, downloadFile, downloadParallel, emitBare, emitResult, ensureApiKey, executePipeline, failIfMissing, fetchLatestVersion, formatBytes, getConcurrency, getExecutingCommandPath, getPendingUpdateNotification, handleError, initPipelineSteps, maybeShowStatusBar, padEnd, parseFlags, poll, printCurrentCommandHelp, printQuickStart, printWelcomeBanner, promptConfirm, promptSelect, promptText, registerCommandHelpPrinter, resolveImageSize, runConcurrent, scanCommandPath, setExecutingCommandPath, setupProxyFromEnv, streamPipelineEvents };
|