Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bailian-kb-dsh/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bailian-kb-dsh",
"version": "2.10.4",
"version": "2.10.5",
"description": "Bailian knowledge-base tools for DeepSeek Harness: kb_search and kb_chat over the DashScope RAG API, plus the bl CLI management skill.",
"keywords": [
"alibaba-cloud",
Expand Down
2 changes: 1 addition & 1 deletion packages/bailian-memo-dsh/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bailian-memo-dsh",
"version": "2.10.4",
"version": "2.10.5",
"description": "Bailian personal memory for DeepSeek Harness: automatic recall, silent curation, and user-controlled remember/forget.",
"keywords": [
"alibaba-cloud",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bailian-cli",
"version": "2.10.4",
"version": "2.10.5",
"description": "CLI for Aliyun Model Studio (DashScope) AI Platform.",
"keywords": [
"agent",
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ import {
deployCapacityCreate,
deployCapacityScale,
deployCapacityRenew,
deployCapacityAutoRenewEnable,
deployCapacityAutoRenewDisable,
deployCapacityDelete,
deployCapacityUnsubscribe,
deployOverflow,
Expand All @@ -245,6 +247,12 @@ import {
deployDelete,
deployPause,
deployResume,
deployRouterVersions,
deployRouterCreate,
deployRouterList,
deployRouterGet,
deployRouterUpdate,
deployRouterDelete,
tokenPlanListSeats,
tokenPlanCreateKey,
tokenPlanAssignSeats,
Expand Down Expand Up @@ -613,6 +621,8 @@ export const commands: Record<string, AnyCommand> = {
"deploy capacity create": deployCapacityCreate,
"deploy capacity scale": deployCapacityScale,
"deploy capacity renew": deployCapacityRenew,
"deploy capacity auto-renew enable": deployCapacityAutoRenewEnable,
"deploy capacity auto-renew disable": deployCapacityAutoRenewDisable,
"deploy capacity delete": deployCapacityDelete,
"deploy capacity unsubscribe": deployCapacityUnsubscribe,
"deploy overflow": deployOverflow,
Expand All @@ -624,6 +634,12 @@ export const commands: Record<string, AnyCommand> = {
"deploy delete": deployDelete,
"deploy pause": deployPause,
"deploy resume": deployResume,
"deploy router versions": deployRouterVersions,
"deploy router create": deployRouterCreate,
"deploy router list": deployRouterList,
"deploy router get": deployRouterGet,
"deploy router update": deployRouterUpdate,
"deploy router delete": deployRouterDelete,
"token-plan list-seats": tokenPlanListSeats,
"token-plan create-key": tokenPlanCreateKey,
"token-plan assign-seats": tokenPlanAssignSeats,
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bailian-cli-commands",
"version": "2.10.4",
"version": "2.10.5",
"description": "Command library for bailian-cli products (knowledge, memory, media, …). See https://www.npmjs.com/package/bailian-cli for usage.",
"homepage": "https://bailian.console.aliyun.com/cli",
"bugs": {
Expand Down
142 changes: 140 additions & 2 deletions packages/commands/src/commands/deploy/capacity-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createCapacityInstance,
scaleCapacityInstance,
renewCapacityInstance,
updateCapacityInstanceAutoRenew,
deleteCapacityInstance,
buildReservationCapacity,
buildPrepaidInfo,
Expand Down Expand Up @@ -61,10 +62,11 @@ export const deployCapacityCreate = defineCommand({
},
flags: CREATE_FLAGS,
usageArgs:
"--deployed-model <code> --billing-method <PRE_PAY|POST_PAY> --input-tpm <kTPM> --output-tpm <kTPM> [--duration <days>] [--auto-renewal <true|false>] [--wait]",
"--deployed-model <code> --billing-method <PRE_PAY|POST_PAY> --input-tpm <kTPM> --output-tpm <kTPM> [--pricing-cycle <Day|Hour>] [--duration <n>] [--auto-renewal <true|false>] [--wait]",
exampleArgs: [
"--deployed-model example-code --billing-method POST_PAY --input-tpm 10000 --output-tpm 1000 --dry-run",
"--deployed-model example-code --billing-method PRE_PAY --input-tpm 10000 --output-tpm 1000 --duration 30 --auto-renewal false --dry-run",
"--deployed-model example-code --billing-method PRE_PAY --pricing-cycle Hour --duration 8 --auto-renewal false --input-tpm 10000 --output-tpm 1000 --dry-run",
],
notes: [
...MUTATION_NOTES,
Expand All @@ -74,6 +76,12 @@ export const deployCapacityCreate = defineCommand({
"zh-CN":
"沿用原 ModelCode、模型和性能档位。同一 ModelCode 只允许一个未释放的后付费实例;购买资格和实例数量限制由服务端校验。",
},
{
"en-US":
"The 8-hour off-peak window is an additional prepaid purchase: --pricing-cycle Hour with --duration 8, --auto-renewal false and no automatic-renewal duration. The selling window (22:00–24:00 Beijing time) and model support are validated by the server; created instances cannot be scaled, renewed, auto-renewed, released or unsubscribed and expire automatically.",
"zh-CN":
"8 小时闲时窗口按预付费叠加购买:--pricing-cycle Hour 配 --duration 8、--auto-renewal false,不传自动续费时长。售卖时段(北京时间 22:00–24:00)与模型支持由服务端校验;所建实例不可变配、续订、自动续费、释放或退订,到期自动失效。",
},
],
validate(flags) {
const error =
Expand Down Expand Up @@ -242,7 +250,7 @@ export const deployCapacityRenew = defineCommand({
},
flags: RENEW_FLAGS,
usageArgs:
"--deployed-model <code> --instance-id <id> --duration <days> --auto-renewal <true|false> [--is-change <true|false>] [--input-tpm <kTPM>] [--output-tpm <kTPM>] [--wait]",
"--deployed-model <code> --instance-id <id> --duration <n> --auto-renewal <true|false> [--is-change <true|false>] [--input-tpm <kTPM>] [--output-tpm <kTPM>] [--wait]",
exampleArgs: [
"--deployed-model example-code --instance-id example-instance --duration 30 --auto-renewal false --dry-run",
"--deployed-model example-code --instance-id example-instance --duration 30 --auto-renewal true --auto-renewal-duration 30 --dry-run",
Expand Down Expand Up @@ -410,3 +418,133 @@ export const deployCapacityDelete = defineCommand({
);
},
});

const AUTO_RENEW_FLAGS = {
...DEPLOYED_MODEL_FLAG,
...CAPACITY_INSTANCE_FLAG,
...WRITE_OPTIONS,
cycle: {
type: "string",
valueHint: "<Day>",
required: true,
choices: ["Day"] as const,
description: {
"en-US": "Automatic renewal cycle; the service currently accepts only Day (case-sensitive)",
"zh-CN": "自动续费周期单位;当前服务仅接受 Day(区分大小写)",
},
},
autoRenewalDuration: {
type: "number",
valueHint: "<days>",
required: true,
description: {
"en-US": "Days renewed at each automatic renewal, positive integer",
"zh-CN": "每次自动续费的天数,正整数",
},
},
} satisfies FlagsDef;

function defineCapacityAutoRenewCommand(autoRenewal: boolean) {
return defineCommand({
defaultOutput: "json",
description: autoRenewal
? {
"en-US": "Enable automatic renewal for one prepaid capacity instance",
"zh-CN": "开启单个预付费容量实例的自动续费",
}
: {
"en-US": "Disable automatic renewal for one prepaid capacity instance",
"zh-CN": "关闭单个预付费容量实例的自动续费",
},
auth: "apiKey",
risk: {
level: "high",
...(autoRenewal ? { reason: "billing" as const } : {}),
message: autoRenewal
? {
"en-US":
"Enabling automatic renewal starts recurring charges until it is disabled again.",
"zh-CN": "开启自动续费后将按周期持续扣费,直到再次关闭。",
}
: {
"en-US": "Disabling automatic renewal stops recurring charges at expiry.",
"zh-CN": "关闭自动续费后,到期不再自动续费扣款。",
},
},
flags: AUTO_RENEW_FLAGS,
usageArgs:
"--deployed-model <code> --instance-id <id> --cycle <Day> --auto-renewal-duration <days> [--wait]",
exampleArgs: [
"--deployed-model example-code --instance-id example-instance --cycle Day --auto-renewal-duration 30 --dry-run",
],
notes: [
...MUTATION_NOTES,
{
"en-US":
"Prepaid instances only; refreshes can_enable_auto_renew / can_disable_auto_renew before writing. 8-hour off-peak instances do not support automatic renewal. The operation usually completes synchronously and returns SUCCEEDED.",
"zh-CN":
"仅预付费实例;写入前刷新 can_enable_auto_renew / can_disable_auto_renew。8 小时闲时实例不支持自动续费。该操作通常同步完成并返回 SUCCEEDED。",
},
],
validate: (flags) => {
const optionError = validateQueryIds(flags) ?? validateWriteOptions(flags);
if (optionError) return optionError;
if (
flags.autoRenewalDuration === undefined ||
!Number.isSafeInteger(flags.autoRenewalDuration) ||
flags.autoRenewalDuration <= 0
)
return "--auto-renewal-duration must be a positive safe integer in days.\n--auto-renewal-duration 必须是正安全整数(天)。";
return undefined;
},
async run(ctx) {
const { flags, settings } = ctx;
const body = {
auto_renewal: autoRenewal,
auto_renewal_cycle: flags.cycle,
auto_renewal_duration: flags.autoRenewalDuration,
};
if (settings.dryRun) {
const resultData5 = {
action: autoRenewal
? "deploy.capacity.auto-renew.enable"
: "deploy.capacity.auto-renew.disable",
deployed_model: flags.deployedModel,
instance_id: flags.instanceId,
body,
client_request_id: flags.requestId ?? "<generated UUID>",
precheck: autoRenewal ? "can_enable_auto_renew" : "can_disable_auto_renew",
wait: flags.wait,
};
ctx.output.result(
resultData5,
ctx.settings.output === "text"
? { text: JSON.stringify(resultData5, null, 2) }
: undefined,
);
return;
}
const instance = await requireCapacityInstance(
ctx.client,
flags.deployedModel,
flags.instanceId,
autoRenewal ? "enable_auto_renew" : "disable_auto_renew",
);
if (instance.charge_type !== "pre_paid")
throw new BailianError(
"Only prepaid instances support automatic renewal. / 仅预付费实例支持自动续费。",
ExitCode.USAGE,
);
const requestId = flags.requestId ?? randomUUID();
const response = await submitCapacityWrite(requestId, () =>
updateCapacityInstanceAutoRenew(ctx.client, flags.deployedModel, flags.instanceId, body, {
requestId,
}),
);
await finishMutation(ctx, flags.deployedModel, response, flags, requestId, true);
},
});
}

export const deployCapacityAutoRenewEnable = defineCapacityAutoRenewCommand(true);
export const deployCapacityAutoRenewDisable = defineCapacityAutoRenewCommand(false);
20 changes: 13 additions & 7 deletions packages/commands/src/commands/deploy/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ const CREATE_FLAGS = {
type: "number",
valueHint: "<n>",
description: {
"en-US": "Legacy thinking-output capacity flag; not supported for PTU",
"zh-CN": "旧版思考输出容量参数;PTU 不支持此参数",
"en-US":
"Thinking-output capacity in kTPM (plan=ptu); only some models support it, validated server-side",
"zh-CN": "思考输出容量,单位 kTPM(plan=ptu);仅部分模型支持,由服务端校验",
},
},
chargeType: {
Expand Down Expand Up @@ -112,7 +113,7 @@ const CREATE_FLAGS = {
} satisfies FlagsDef;

const CREATE_USAGE =
"--model-name <model_name> [--display-name <display_name>] [--plan <plan>] [--charge-type <type>] [--service-tier <tier>] [--suffix <suffix>] [--input-tpm <n> --output-tpm <n>] [flags]";
"--model-name <model_name> [--display-name <display_name>] [--plan <plan>] [--charge-type <type>] [--service-tier <tier>] [--suffix <suffix>] [--pricing-cycle <Day|Hour>] [--input-tpm <n> --output-tpm <n>] [flags]";

const CREATE_RISK: CommandRisk = {
level: "high",
Expand All @@ -131,9 +132,15 @@ const CREATE_NOTES = [
},
{
"en-US":
"For plan=ptu, --charge-type, --input-tpm and --output-tpm are required. Capacity is in kTPM (1 kTPM = 1000 tokens/minute). Separate thinking-output capacity is unsupported. Prepaid requires --duration and explicit --auto-renewal true|false.",
"For plan=ptu, --charge-type, --input-tpm and --output-tpm are required. Capacity is in kTPM (1 kTPM = 1000 tokens/minute). Separate thinking-output capacity (--thinking-output-tpm) is only supported by some models and is validated server-side. Prepaid requires --duration and explicit --auto-renewal true|false.",
"zh-CN":
"plan=ptu 时,--charge-type、--input-tpm 和 --output-tpm 必填。容量单位为 kTPM(1 kTPM = 1000 Token/分钟),不支持单独的思考输出容量。预付费须提供 --duration 和显式 --auto-renewal true|false。",
"plan=ptu 时,--charge-type、--input-tpm 和 --output-tpm 必填。容量单位为 kTPM(1 kTPM = 1000 Token/分钟);单独的思考输出容量(--thinking-output-tpm)仅部分模型支持,由服务端校验。预付费须提供 --duration 和显式 --auto-renewal true|false。",
},
{
"en-US":
"The 8-hour off-peak window is prepaid ptu_default only: --pricing-cycle Hour with --duration 8, --auto-renewal false and an explicit --service-tier ptu_default. Service hours must fall within 22:00–08:00, so orders are accepted only between 22:00 and 24:00 Beijing time; model support is validated by the server.",
"zh-CN":
"8 小时闲时窗口仅限预付费 ptu_default:--pricing-cycle Hour 配 --duration 8、--auto-renewal false,且必须显式指定 --service-tier ptu_default。服务时段须完整落在 22:00–08:00,因此仅在北京时间 22:00–24:00 之间下单;模型支持由服务端校验。",
},
{
"en-US":
Expand Down Expand Up @@ -194,8 +201,6 @@ function validateCreate(
if (!flags.displayName?.trim()) {
return "--display-name is required for non-PTU plans. / 非 PTU 方案必须提供 --display-name。";
}
} else if (flags.thinkingOutputTpm !== undefined) {
return "--thinking-output-tpm is not supported for PTU. / PTU 不支持 --thinking-output-tpm。";
}
return validateWriteOptions(flags) ?? strategy.validateFlags(flags);
}
Expand Down Expand Up @@ -259,6 +264,7 @@ export const deployTextCreate = defineCommand({
"--model-name my-qwen-sft --display-name my-sft-test",
"--model-name qwen3.6-flash-2026-04-16 --plan ptu --charge-type post_paid --input-tpm 10000 --output-tpm 1000 --dry-run",
"--model-name qwen3.6-flash-2026-04-16 --plan ptu --charge-type pre_paid --service-tier ptu_default --input-tpm 10000 --output-tpm 1000 --duration 30 --auto-renewal false --dry-run",
"--model-name qwen3.6-flash-2026-04-16 --plan ptu --charge-type pre_paid --service-tier ptu_default --pricing-cycle Hour --duration 8 --auto-renewal false --input-tpm 10000 --output-tpm 1000 --dry-run",
"--model-name qwen3-8b --display-name my-qwen3-mu --plan mu",
"--model-name qwen3-8b --display-name my-qwen3 --plan mu --deploy-spec MU1 --capacity 2",
],
Expand Down
5 changes: 3 additions & 2 deletions packages/commands/src/commands/deploy/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default defineCommand({
const status = (deployment?.status ?? "").toUpperCase();
const plan = typeof deployment?.plan === "string" ? deployment.plan.trim().toLowerCase() : "";
const knownPtuPlan = plan === "ptu" || plan === "ptu_v2";
const knownModelRouterPlan = plan === "mr";
const knownNonPtuPlan = plan === "mu" || plan === "cu" || plan === "lora";
const hasMeaningfulPtuTier =
typeof deployment?.ptu_service_tier === "string" &&
Expand All @@ -95,7 +96,7 @@ export default defineCommand({
!Array.isArray(deployment.ptu_capacity) &&
Object.keys(deployment.ptu_capacity).length > 0;
const isPtu = knownPtuPlan || (!plan && (hasMeaningfulPtuTier || hasMeaningfulPtuCapacity));
if (!isPtu && !knownNonPtuPlan) {
if (!isPtu && !knownModelRouterPlan && !knownNonPtuPlan) {
throw new BailianError(
"Cannot determine deployment plan safely; deletion was not submitted. / 无法可靠判断部署计划类型;未提交删除请求。",
ExitCode.USAGE,
Expand Down Expand Up @@ -161,7 +162,7 @@ export default defineCommand({
);
}
}
} else if (status !== "STOPPED" && status !== "FAILED") {
} else if (!knownModelRouterPlan && status !== "STOPPED" && status !== "FAILED") {
throw new BailianError(
`Deployment ${deployedModel} must be STOPPED or FAILED before deletion (current: ${status || "unknown"}). / 部署 ${deployedModel} 删除前必须为 STOPPED 或 FAILED(当前:${status || "未知"})。`,
ExitCode.USAGE,
Expand Down
34 changes: 28 additions & 6 deletions packages/commands/src/commands/deploy/mutation-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ export const CAPACITY_FLAGS = {
} satisfies FlagsDef;

export const PREPAID_FLAGS = {
pricingCycle: {
type: "string",
valueHint: "<Day|Hour>",
choices: ["Day", "Hour"] as const,
description: {
"en-US":
"Prepaid pricing cycle (case-sensitive): Day (default) or Hour for the 8-hour off-peak window",
"zh-CN": "预付费计费周期(区分大小写):Day(默认)或 Hour(8 小时闲时窗口)",
},
},
duration: {
type: "number",
valueHint: "<days>",
valueHint: "<n>",
description: {
"en-US": "Prepaid purchase/renewal duration, positive integer days",
"zh-CN": "预付费购买或续订天数,正整数",
"en-US": "Prepaid duration: positive integer days for Day, exactly 8 hours for Hour",
"zh-CN": "预付费时长:Day 使用正整数天数,Hour 固定为 8 小时",
},
},
autoRenewal: {
Expand Down Expand Up @@ -127,9 +137,9 @@ export const MUTATION_NOTES: LocalizedText[] = [
},
{
"en-US":
"Capacities are absolute kTPM for one instance, not increments or ModelCode totals. Zero capacity is not release. Model-specific steps, limits and purchase periods are validated by the server. Automatic renewal configuration is part of purchase/scale/renew, not a standalone free setting change.",
"Capacities are absolute kTPM for one instance, not increments or ModelCode totals. Zero capacity is not release. Model-specific steps, limits and purchase periods are validated by the server. Automatic renewal is configured at purchase/renewal and changed via `deploy capacity auto-renew enable` / `disable`.",
"zh-CN":
"容量是单个实例的绝对 kTPM,不是增量或 ModelCode 总量;容量归零不等于释放。模型步长、上下限及购买时长限制由服务端校验。自动续费配置属于购买、变配或续订流程,不是独立免费设置操作。",
"容量是单个实例的绝对 kTPM,不是增量或 ModelCode 总量;容量归零不等于释放。模型步长、上下限及购买时长限制由服务端校验。自动续费在购买或续订时配置,变更请使用 `deploy capacity auto-renew enable` / `disable`。",
},
];

Expand Down Expand Up @@ -169,10 +179,22 @@ export async function requireCapacityInstance(
client: Client,
code: string,
id: string,
action: "scale" | "renew" | "delete",
action: "scale" | "renew" | "delete" | "enable_auto_renew" | "disable_auto_renew",
): Promise<CapacityInstance> {
const response = await getCapacityInstance(client, code, id);
const instance = response.output ?? response.data;
if (
action === "delete" &&
instance?.pre_paid_info?.pricing_cycle === "Hour" &&
instance.deleted !== true
) {
throw new BailianError(
"8-hour off-peak instances cannot be released or unsubscribed; they expire automatically at gmt_expired. / 8 小时闲时实例不能释放或退订,到期后自动失效。",
ExitCode.USAGE,
undefined,
{ cause: response },
);
}
if (!instance || instance.deleted === true || instance[`can_${action}`] !== true) {
throw new BailianError(
`Capacity instance does not currently allow ${action}; refresh its details. / 容量实例当前不允许 ${action},请刷新详情。`,
Expand Down
Loading