bailian-cli-core 2.0.0 → 2.0.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
@@ -1900,6 +1900,7 @@ export declare function speechVocabularyPath(): string;
1900
1900
  export declare function profileSchemaPath(): string;
1901
1901
  export declare function userProfilePath(schemaId: string): string;
1902
1902
  export declare function knowledgeRetrievePath(): string;
1903
+ export declare function workspaceMaaSBaseUrl(workspaceId: string): string;
1903
1904
  export declare function knowledgeSearchEndpoint(workspaceId: string): string;
1904
1905
  export declare function knowledgeChatEndpoint(workspaceId: string): string;
1905
1906
  /** Per-workspace AgentStudio host (same shape as {@link ragEndpoint}'s host). */
@@ -1909,6 +1910,18 @@ export declare function securityOverviewEndpoint(host: string): string;
1909
1910
  /** GET alert list (agent_logs); filters / pagination go in the query string. */
1910
1911
  export declare function securityAgentLogsEndpoint(host: string): string;
1911
1912
  export declare function mcpWebSearchPath(): string;
1913
+ /** GET /api/v1/deployments/{deployed_model}/capacity-instances */
1914
+ export declare function deploymentCapacityInstancesPath(code: string): string;
1915
+ /** GET /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id} */
1916
+ export declare function deploymentCapacityInstancePath(code: string, id: string): string;
1917
+ /** PUT /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}/scale */
1918
+ export declare function deploymentCapacityInstanceScalePath(code: string, id: string): string;
1919
+ /** PUT /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}/renew */
1920
+ export declare function deploymentCapacityInstanceRenewPath(code: string, id: string): string;
1921
+ /** PUT /api/v1/deployments/{deployed_model}/update-overflowstrategy */
1922
+ export declare function deploymentOverflowPath(code: string): string;
1923
+ /** GET /api/v1/deployments/{deployed_model}/capacity-operations/{operation_id} */
1924
+ export declare function deploymentCapacityOperationPath(code: string, id: string): string;
1912
1925
  export declare function ragEndpoint(workspaceId: string, path: string): string;
1913
1926
  /** AgentStudio workspace files; template uploads send source=sandbox_template. */
1914
1927
  export declare function agentStudioFilesPath(): string;
@@ -3237,6 +3250,18 @@ export interface Deployment {
3237
3250
  /** PTU-only token-rate limits. */
3238
3251
  input_tpm?: number;
3239
3252
  output_tpm?: number;
3253
+ /** Aggregate effective reservation capacity, in kTPM. */
3254
+ ptu_capacity?: ReservationCapacity;
3255
+ /** ptu_fast | ptu_default | future service tiers. */
3256
+ ptu_service_tier?: string;
3257
+ pre_paid_info?: PrePaidInfo;
3258
+ pre_paid_instance_id?: string;
3259
+ pre_paid_gmt_expired?: string;
3260
+ /** enable | disable | future overflow strategies. */
3261
+ overflow_strategy?: string;
3262
+ fail_reason?: string;
3263
+ operation_id?: string;
3264
+ instance_id?: string;
3240
3265
  enable_thinking?: boolean;
3241
3266
  max_context_length?: number;
3242
3267
  workspace_id?: string;
@@ -3247,6 +3272,71 @@ export interface Deployment {
3247
3272
  /** Free-form additional fields are preserved by callers. */
3248
3273
  [k: string]: unknown;
3249
3274
  }
3275
+ /** Reservation capacity returned by queries; separate from legacy PTU write input. */
3276
+ export interface ReservationCapacity {
3277
+ /** Input capacity in kTPM (1 kTPM = 1000 tokens/minute); zero is valid. */
3278
+ input_tpm?: number;
3279
+ /** Output capacity in kTPM; zero is valid. */
3280
+ output_tpm?: number;
3281
+ [key: string]: unknown;
3282
+ }
3283
+ /** Prepaid purchase and renewal configuration returned by queries. */
3284
+ export interface PrePaidInfo {
3285
+ /** Purchase / renewal duration in days. */
3286
+ duration?: number;
3287
+ auto_renewal?: boolean;
3288
+ /** Automatic renewal duration in days. */
3289
+ auto_renewal_duration?: number;
3290
+ /** Renewal cycle unit, e.g. Day. */
3291
+ auto_renewal_cycle?: string;
3292
+ [key: string]: unknown;
3293
+ }
3294
+ /** A capacity instance returned by list/detail queries, including released instances. */
3295
+ export interface CapacityInstance {
3296
+ /** The deployment's ModelCode. Identifiers are opaque strings. */
3297
+ model_service_id?: string;
3298
+ instance_id?: string;
3299
+ /** pre_paid | post_paid | future charge types. */
3300
+ charge_type?: string;
3301
+ /** Instance lifecycle state; future states are preserved. */
3302
+ status?: string;
3303
+ deleted?: boolean;
3304
+ /** Currently confirmed serving capacity. */
3305
+ effective_capacity?: ReservationCapacity;
3306
+ /** Configured / contracted capacity, which may remain while stopped or suspended. */
3307
+ configured_capacity?: ReservationCapacity;
3308
+ /** Pending target, not effective capacity; may be absent or null in a stable state. */
3309
+ target_capacity?: ReservationCapacity | null;
3310
+ pre_paid_info?: PrePaidInfo;
3311
+ gmt_expired?: string;
3312
+ can_scale?: boolean;
3313
+ can_renew?: boolean;
3314
+ can_delete?: boolean;
3315
+ fail_reason?: string;
3316
+ gmt_created?: string;
3317
+ gmt_modified?: string;
3318
+ gmt_deleted?: string;
3319
+ [key: string]: unknown;
3320
+ }
3321
+ /** A capacity operation returned by a query; no state or identifier normalization. */
3322
+ export interface CapacityOperation {
3323
+ operation_id?: string;
3324
+ /** Original operation request ID, distinct from the query response's request_id. */
3325
+ request_id?: string;
3326
+ /** CREATE | SCALE | RENEW | DELETE | STOP | REFUND | future operation types. */
3327
+ operation_type?: string;
3328
+ /** PROCESSING | SUCCEEDED | FAILED | future operation states. */
3329
+ operation_status?: string;
3330
+ model_service_id?: string;
3331
+ instance_id?: string;
3332
+ from_status?: string;
3333
+ current_status?: string;
3334
+ error_code?: string;
3335
+ error_message?: string;
3336
+ gmt_created?: string;
3337
+ gmt_finished?: string;
3338
+ [key: string]: unknown;
3339
+ }
3250
3340
  /** A single deployable model record (GET /deployments/models). */
3251
3341
  export interface DeployableModel {
3252
3342
  model_name?: string;
@@ -3314,20 +3404,23 @@ export interface DeployableTemplate {
3314
3404
  export interface CreateDeploymentRequest {
3315
3405
  /** Required. The catalog or fine-tuned model identifier. */
3316
3406
  model_name: string;
3317
- /** Required. Display name shown in the console. */
3318
- name: string;
3407
+ /** Optional display name; PTU creation generates one when omitted. */
3408
+ name?: string;
3319
3409
  /** Required. Billing plan: mu | cu | ptu | lora. CLI defaults to "lora". */
3320
3410
  plan: string;
3411
+ /** Required for PTU creation; distinct from instance billing_method. */
3412
+ charge_type?: "pre_paid" | "post_paid";
3413
+ /** PTU performance tier; the service defaults to ptu_fast. */
3414
+ service_tier?: "ptu_fast" | "ptu_default";
3415
+ /** Optional ModelCode suffix; generated by the service when omitted. */
3416
+ suffix?: string;
3417
+ /** Required for prepaid PTU creation; omitted for postpaid. */
3418
+ pre_paid_info?: PrePaidInfo;
3321
3419
  /** Required by API even for token-billed (lora) plans where it is ignored — CLI injects 1. */
3322
3420
  capacity?: number;
3323
3421
  /** Deploy spec id (e.g. "MU1", "dps-..."), sent as `deploy_spec` in POST body. */
3324
3422
  deploy_spec?: string;
3325
- /**
3326
- * PTU capacity (provisioned throughput limits). Only effective when
3327
- * `plan === "ptu"`. The doc says this defaults to 10000/1000 when omitted,
3328
- * but the platform currently rejects creation without it ("Miss ptu capacity
3329
- * info"), so the CLI treats it as required for ptu.
3330
- */
3423
+ /** Required PTU capacity in kTPM; values are forwarded without conversion. */
3331
3424
  ptu_capacity?: PtuCapacity;
3332
3425
  /**
3333
3426
  * AIGC generation config for fine-tuned Wan video (i2v/kf2v) LoRA deployments.
@@ -3350,13 +3443,13 @@ export interface AigcConfig {
3350
3443
  prompt?: string;
3351
3444
  lora_prompt_default?: string;
3352
3445
  }
3353
- /** PTU throughput limits — only used when `plan === "ptu"`. */
3446
+ /** Legacy PTU input shape, retained for source compatibility. */
3354
3447
  export interface PtuCapacity {
3355
- /** Max input tokens per minute (all models). */
3448
+ /** Input capacity in kTPM. */
3356
3449
  input_tpm?: number;
3357
- /** Max output tokens per minute (all models). */
3450
+ /** Output capacity in kTPM. */
3358
3451
  output_tpm?: number;
3359
- /** Max thinking-output tokens per minute (some models only). */
3452
+ /** @deprecated Current reservation models do not support separate thinking-output capacity. */
3360
3453
  thinking_output_tpm?: number;
3361
3454
  }
3362
3455
  /** POST /api/v1/deployments response. */
@@ -3389,18 +3482,69 @@ export interface GetDeploymentResponse {
3389
3482
  output?: Deployment;
3390
3483
  data?: Deployment;
3391
3484
  }
3392
- /** DELETE /api/v1/deployments/{deployed_model} response. */
3393
- export interface DeleteDeploymentResponse {
3485
+ /** GET /api/v1/deployments/{deployed_model}/capacity-instances response. */
3486
+ export interface ListCapacityInstancesResponse {
3394
3487
  request_id?: string;
3395
3488
  output?: {
3489
+ records?: CapacityInstance[];
3490
+ /** Total record count, not the current page's records. */
3491
+ items?: number;
3492
+ page?: number;
3493
+ itemsPerPage?: number;
3494
+ pageCount?: number;
3495
+ [key: string]: unknown;
3496
+ };
3497
+ data?: ListCapacityInstancesResponse["output"];
3498
+ [key: string]: unknown;
3499
+ }
3500
+ /** GET /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id} response. */
3501
+ export interface GetCapacityInstanceResponse {
3502
+ request_id?: string;
3503
+ output?: CapacityInstance;
3504
+ data?: CapacityInstance;
3505
+ [key: string]: unknown;
3506
+ }
3507
+ /** GET /api/v1/deployments/{deployed_model}/capacity-operations/{operation_id} response. */
3508
+ export interface GetCapacityOperationResponse {
3509
+ request_id?: string;
3510
+ output?: CapacityOperation;
3511
+ data?: CapacityOperation;
3512
+ [key: string]: unknown;
3513
+ }
3514
+ /** Instance writes return an operation, including HTTP 200 responses with status FAILED. */
3515
+ export type CapacityOperationResponse = GetCapacityOperationResponse;
3516
+ /** POST /api/v1/deployments/{deployed_model}/capacity-instances request body. */
3517
+ export interface CreateCapacityInstanceRequest {
3518
+ billing_method: "PRE_PAY" | "POST_PAY";
3519
+ ptu_capacity: ReservationCapacity;
3520
+ /** Required for PRE_PAY; omitted for POST_PAY. */
3521
+ pre_paid_info?: PrePaidInfo;
3522
+ }
3523
+ /** PUT /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}/scale body. */
3524
+ export interface ScaleCapacityInstanceRequest {
3525
+ /** Absolute target capacity for this instance, not a delta or deployment total. */
3526
+ ptu_capacity: ReservationCapacity;
3527
+ /** Omit to reuse saved prepaid information; do not send for postpaid. */
3528
+ pre_paid_info?: PrePaidInfo;
3529
+ order_type?: "UPGRADE" | "DOWNGRADE";
3530
+ }
3531
+ /** PUT /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}/renew body. */
3532
+ export interface RenewCapacityInstanceRequest {
3533
+ pre_paid_info: PrePaidInfo;
3534
+ /** Required to be true when changing capacity; defaults to false on the service. */
3535
+ is_change?: boolean;
3536
+ ptu_capacity?: ReservationCapacity;
3537
+ }
3538
+ /** PUT /api/v1/deployments/{deployed_model}/update-overflowstrategy response. */
3539
+ export type UpdateDeploymentOverflowResponse = GetDeploymentResponse;
3540
+ /** DELETE /api/v1/deployments/{deployed_model} response, including legacy deleted flags. */
3541
+ export interface DeleteDeploymentResponse {
3542
+ request_id?: string;
3543
+ output?: Deployment & {
3396
3544
  deleted?: boolean;
3397
- deployed_model?: string;
3398
- [k: string]: unknown;
3399
3545
  };
3400
- data?: {
3546
+ data?: Deployment & {
3401
3547
  deleted?: boolean;
3402
- deployed_model?: string;
3403
- [k: string]: unknown;
3404
3548
  };
3405
3549
  }
3406
3550
  /** GET /api/v1/deployments/models response. */
@@ -3423,9 +3567,15 @@ export interface ListDeployableModelsResponse {
3423
3567
  }
3424
3568
  /** PUT /api/v1/deployments/{deployed_model}/scale request body. */
3425
3569
  export interface ScaleDeploymentRequest {
3426
- /** New capacity in plan units. Server-side constraint: integer multiple of `base_capacity`, < 1000. */
3570
+ /** New capacity in legacy MU plan units. */
3427
3571
  capacity?: number;
3428
- /** PTU-only token-rate adjustments. */
3572
+ /** Required for PTU when more than one undeleted instance exists. */
3573
+ instance_id?: string;
3574
+ /** Absolute PTU target capacity for the selected instance, in kTPM. */
3575
+ ptu_capacity?: ReservationCapacity;
3576
+ pre_paid_info?: PrePaidInfo;
3577
+ order_type?: "UPGRADE" | "DOWNGRADE";
3578
+ /** Legacy top-level PTU fields retained for source compatibility. */
3429
3579
  input_tpm?: number;
3430
3580
  output_tpm?: number;
3431
3581
  [k: string]: unknown;
@@ -3456,18 +3606,52 @@ export interface UpdateDeploymentResponse {
3456
3606
  }
3457
3607
  //#endregion
3458
3608
  //#region src/deploy/api.d.ts
3459
- /** POST /api/v1/deployments */
3609
+ /** Caller-owned idempotency key; wrappers never generate keys or retry writes. */
3610
+ export interface CapacityWriteOptions {
3611
+ requestId?: string;
3612
+ signal?: AbortSignal;
3613
+ }
3614
+ /** POST /api/v1/deployments; initial ModelCode creation has no instance-idempotency guarantee. */
3460
3615
  export declare function createDeployment(client: Client, body: CreateDeploymentRequest, signal?: AbortSignal): Promise<CreateDeploymentResponse>;
3461
3616
  export interface ListDeploymentsParams {
3462
3617
  pageNo?: number;
3463
3618
  pageSize?: number;
3464
- status?: string;
3619
+ plan?: string;
3465
3620
  signal?: AbortSignal;
3466
3621
  }
3467
3622
  /** GET /api/v1/deployments */
3468
3623
  export declare function listDeployments(client: Client, params?: ListDeploymentsParams): Promise<ListDeploymentsResponse>;
3469
3624
  /** GET /api/v1/deployments/{deployed_model} */
3470
3625
  export declare function getDeployment(client: Client, deployedModel: string, signal?: AbortSignal): Promise<GetDeploymentResponse>;
3626
+ export interface ListCapacityInstancesParams {
3627
+ pageNo?: number;
3628
+ pageSize?: number;
3629
+ includeDeleted?: boolean;
3630
+ statuses?: string[];
3631
+ chargeTypes?: string[];
3632
+ signal?: AbortSignal;
3633
+ }
3634
+ /** GET /api/v1/deployments/{deployed_model}/capacity-instances */
3635
+ export declare function listCapacityInstances(client: Client, code: string, params?: ListCapacityInstancesParams): Promise<ListCapacityInstancesResponse>;
3636
+ /** GET /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id} */
3637
+ export declare function getCapacityInstance(client: Client, code: string, id: string, signal?: AbortSignal): Promise<GetCapacityInstanceResponse>;
3638
+ /** GET /api/v1/deployments/{deployed_model}/capacity-operations/{operation_id} */
3639
+ export declare function getCapacityOperation(client: Client, code: string, id: string, signal?: AbortSignal): Promise<GetCapacityOperationResponse>;
3640
+ /**
3641
+ * POST /api/v1/deployments/{deployed_model}/capacity-instances
3642
+ * All instance writes return operations verbatim; callers must check operation_status, even on HTTP 200.
3643
+ */
3644
+ export declare function createCapacityInstance(client: Client, code: string, body: CreateCapacityInstanceRequest, options?: CapacityWriteOptions): Promise<CapacityOperationResponse>;
3645
+ /** PUT /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}/scale */
3646
+ export declare function scaleCapacityInstance(client: Client, code: string, id: string, body: ScaleCapacityInstanceRequest, options?: CapacityWriteOptions): Promise<CapacityOperationResponse>;
3647
+ /** PUT /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}/renew */
3648
+ export declare function renewCapacityInstance(client: Client, code: string, id: string, body: RenewCapacityInstanceRequest, options?: CapacityWriteOptions): Promise<CapacityOperationResponse>;
3649
+ /** DELETE /api/v1/deployments/{deployed_model}/capacity-instances/{instance_id}; no JSON body. */
3650
+ export declare function deleteCapacityInstance(client: Client, code: string, id: string, options?: CapacityWriteOptions & {
3651
+ reason?: string;
3652
+ }): Promise<CapacityOperationResponse>;
3653
+ /** PUT /api/v1/deployments/{deployed_model}/update-overflowstrategy */
3654
+ export declare function updateDeploymentOverflow(client: Client, code: string, strategy: "enable" | "disable", signal?: AbortSignal): Promise<UpdateDeploymentOverflowResponse>;
3471
3655
  /** DELETE /api/v1/deployments/{deployed_model} */
3472
3656
  export declare function deleteDeployment(client: Client, deployedModel: string, signal?: AbortSignal): Promise<DeleteDeploymentResponse>;
3473
3657
  export interface ListDeployableModelsParams {
@@ -3482,7 +3666,7 @@ export interface ListDeployableModelsParams {
3482
3666
  /** GET /api/v1/deployments/models */
3483
3667
  export declare function listDeployableModels(client: Client, params?: ListDeployableModelsParams): Promise<ListDeployableModelsResponse>;
3484
3668
  /** PUT /api/v1/deployments/{deployed_model}/scale */
3485
- export declare function scaleDeployment(client: Client, deployedModel: string, body: ScaleDeploymentRequest, signal?: AbortSignal): Promise<ScaleDeploymentResponse>;
3669
+ export declare function scaleDeployment(client: Client, deployedModel: string, body: ScaleDeploymentRequest, signal?: AbortSignal, requestId?: string): Promise<ScaleDeploymentResponse>;
3486
3670
  /**
3487
3671
  * PUT /api/v1/deployments/{deployed_model}/update
3488
3672
  *
@@ -3538,15 +3722,36 @@ export declare const CHARGE_TYPE: {
3538
3722
  };
3539
3723
  export type ChargeType = (typeof CHARGE_TYPE)[keyof typeof CHARGE_TYPE];
3540
3724
  //#endregion
3725
+ //#region src/deploy/reservation.d.ts
3726
+ /** Shared flags for reservation creation, scaling and renewal; capacity is in kTPM. */
3727
+ export interface ReservationFlags {
3728
+ inputTpm?: number;
3729
+ outputTpm?: number;
3730
+ duration?: number;
3731
+ autoRenewal?: boolean;
3732
+ autoRenewalDuration?: number;
3733
+ autoRenewalCycle?: string;
3734
+ }
3735
+ /** Validate paired capacity locally; model-specific steps and limits belong to the service. */
3736
+ export declare function validateReservationCapacity(flags: ReservationFlags, required: boolean): string | undefined;
3737
+ /** Build validated capacity without converting units or dropping zero. */
3738
+ export declare function buildReservationCapacity(flags: ReservationFlags): ReservationCapacity;
3739
+ export declare function hasPrepaidFlags(flags: ReservationFlags): boolean;
3740
+ /** Validate a complete prepaid block whenever any prepaid field is supplied. */
3741
+ export declare function validatePrepaidFlags(flags: ReservationFlags, required: boolean): string | undefined;
3742
+ /** Build validated prepaid information, preserving explicit false and omitting absent fields. */
3743
+ export declare function buildPrepaidInfo(flags: ReservationFlags): PrePaidInfo | undefined;
3744
+ //#endregion
3541
3745
  //#region src/deploy/plans.d.ts
3542
3746
  /** Plan-relevant subset of `deploy <modality> create` flags (parsed flags satisfy this shape). */
3543
- export interface CreatePlanFlags {
3747
+ export interface CreatePlanFlags extends ReservationFlags {
3544
3748
  plan?: string;
3545
3749
  deploySpec?: string;
3546
3750
  capacity?: number;
3547
3751
  billingMethod?: string;
3548
- inputTpm?: number;
3549
- outputTpm?: number;
3752
+ chargeType?: string;
3753
+ serviceTier?: string;
3754
+ suffix?: string;
3550
3755
  thinkingOutputTpm?: number;
3551
3756
  }
3552
3757
  export interface PlanContext {
@@ -3558,8 +3763,8 @@ export interface PlanContext {
3558
3763
  flags: CreatePlanFlags;
3559
3764
  /** Underlying model identifier (`--model`). */
3560
3765
  model: string;
3561
- /** Console display name (`--name`). */
3562
- name: string;
3766
+ /** Optional console display name (`--name`); PTU can use the generated name. */
3767
+ name?: string;
3563
3768
  }
3564
3769
  export interface PlanResolved {
3565
3770
  /**