diff --git a/.agents/skills/unidesk-sub2api/SKILL.md b/.agents/skills/unidesk-sub2api/SKILL.md index 8606e0ff..2bdf693e 100644 --- a/.agents/skills/unidesk-sub2api/SKILL.md +++ b/.agents/skills/unidesk-sub2api/SKILL.md @@ -35,7 +35,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool runtime events --target PK0 - 单 target 运行面先用 `status --target `; - 代理、数据库和公网路径的完整判定用 `validate --target `。 -- `priority` 数值越小优先级越高,`0` 合法且最高: +- `priority` 数值越小优先级越高,合法范围为 `1..1000`,`1` 最高: - 这是 Sub2API 调度的稳定合同,后续调优不得为确认方向重复检索源码; - 只有真实调度结果与该合同冲突时,才下钻官方 scheduler 实现。 - 查询账号周限保护统一使用 `runtime get --account `: diff --git a/.agents/skills/unidesk-sub2api/references/codex-pool.md b/.agents/skills/unidesk-sub2api/references/codex-pool.md index 54e303df..1c4f9c25 100644 --- a/.agents/skills/unidesk-sub2api/references/codex-pool.md +++ b/.agents/skills/unidesk-sub2api/references/codex-pool.md @@ -116,7 +116,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts --template bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts --template --confirm bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --template --select-configured-policy --account-type apikey --exclude-accounts -bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts --kind priority --priority <0-1000> --confirm +bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts --kind priority --priority <1-1000> --confirm bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts --kind capacity --capacity <1-100000> --confirm bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --account --kind account-name --name --confirm bun scripts/cli.ts platform-infra sub2api codex-pool runtime delete --target PK01 --account --kind temp-unschedulable @@ -238,7 +238,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool cleanup-probes --target D60 - 手工账号需要采用模板时: - 写入使用显式 `runtime apply --account ...` 或 `--accounts ... --template ... --confirm`。 - 删除使用相同显式 selector 的 `runtime delete --kind temp-unschedulable --confirm`。 -- 账号全局 `priority` 使用 `runtime apply --kind priority --priority <0-1000>`: +- 账号全局 `priority` 使用 `runtime apply --kind priority --priority <1-1000>`: - 数值越小优先级越高,不存在分组级 priority; - 单账号和精准批量都必须先 dry-run,确认写入后逐账号回读并显示 before、desired、actual 与 reconciled; - 只更新账号 priority,不携带 credentials、分组、容量、代理、状态、可调度或临时不可调度字段。 @@ -256,7 +256,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool cleanup-probes --target D60 - 同一次账号级查询直接读取评分、可归因上游失败率、TTFT、用量、Token、标准 API 计费基数、当前名称成本标注和 priority; - 只有需要确认 capacity、schedulable、proxy、临时不可调度规则或上游 5h/7d 周窗口保护时,才补一次 `runtime get --account `; - 只有需要跨账号比较时才使用全组 `runtime errors --group `;单账号任务不得先跑全组大报表,再重复账号级查询; - - priority 数值越小越优先,`0` 合法且最高;这是稳定合同,除非真实调度结果冲突,不得重复检索源码确认方向。成本只参与人工经济性判断,必须同时考虑可靠性、TTFT、容量、可调度状态和样本置信度,不得按成本自动排序; + - priority 数值越小越优先,合法范围为 `1..1000`,`1` 最高;CLI 必须在提交远端作业前拒绝 `0` 和负数。成本只参与人工经济性判断,必须同时考虑可靠性、TTFT、容量、可调度状态和样本置信度,不得按成本自动排序; - 名称成本标注和 priority 是两个独立 runtime 字段:分别先 dry-run,再顺序 confirm;禁止并发更新同一账号,避免整对象更新互相覆盖; - 两项 confirm 已各自回读一致后,最后只执行一次 `runtime get` 验收完整状态;不重复 confirm,不用全组查询代替账号回读。 - 模型路由先用 `runtime get --account ...` 获取账号配置,再用 `runtime errors --account ... --full` 获取原生 Ops 已观测模型证据: diff --git a/scripts/src/platform-infra-sub2api-codex/config.ts b/scripts/src/platform-infra-sub2api-codex/config.ts index 8d95327a..65919997 100644 --- a/scripts/src/platform-infra-sub2api-codex/config.ts +++ b/scripts/src/platform-infra-sub2api-codex/config.ts @@ -722,8 +722,8 @@ export function readAccountPriority(value: unknown, key: string, fallback?: numb throw new Error(`${codexPoolConfigPath}.${key} is required`); } const priority = numberValue(value); - if (priority === null || !Number.isInteger(priority) || priority < 0 || priority > 1000) { - throw new Error(`${codexPoolConfigPath}.${key} must be an integer from 0 to 1000`); + if (priority === null || !Number.isInteger(priority) || priority < 1 || priority > 1000) { + throw new Error(`${codexPoolConfigPath}.${key} must be an integer from 1 to 1000`); } return priority; } diff --git a/scripts/src/platform-infra-sub2api-codex/runtime-options.ts b/scripts/src/platform-infra-sub2api-codex/runtime-options.ts index 66eea64d..6bcf7b6c 100644 --- a/scripts/src/platform-infra-sub2api-codex/runtime-options.ts +++ b/scripts/src/platform-infra-sub2api-codex/runtime-options.ts @@ -31,7 +31,7 @@ export interface RuntimeOptions { export function parseRuntimeOptions(args: string[]): RuntimeOptions { const [actionRaw = "list", ...rest] = args; if (!(["list", "get", "errors", "events", "infrastructure", "apply", "delete"] as string[]).includes(actionRaw)) { - throw new Error("runtime usage: list|get|errors|events|infrastructure|apply|delete [--account |--accounts |--select-configured-policy --account-type apikey [--exclude-accounts ]] [--recent 24h] [--group |--all-groups] [--platform ] [--page-token ] [--since 24h] [--tail 50000] [--template ] [--kind temp-unschedulable|priority|account-name|capacity] [--priority <0-1000>|--name |--capacity <1-100000>] [--confirm] [--target ] [--json|--full|--raw]"); + throw new Error("runtime usage: list|get|errors|events|infrastructure|apply|delete [--account |--accounts |--select-configured-policy --account-type apikey [--exclude-accounts ]] [--recent 24h] [--group |--all-groups] [--platform ] [--page-token ] [--since 24h] [--tail 50000] [--template ] [--kind temp-unschedulable|priority|account-name|capacity] [--priority <1-1000>|--name |--capacity <1-100000>] [--confirm] [--target ] [--json|--full|--raw]"); } let account: string | null = null; let accounts: string[] = []; @@ -130,7 +130,7 @@ export function parseRuntimeOptions(args: string[]): RuntimeOptions { if (!selectConfiguredPolicy && excludeAccounts.length > 0) throw new Error("--exclude-accounts requires --select-configured-policy"); if (action === "apply" && kind === "temp-unschedulable" && !template) throw new Error("runtime apply --kind temp-unschedulable requires --template "); if (kind === "priority" && action !== "apply") throw new Error("runtime --kind priority only supports apply"); - if (kind === "priority" && priority === null) throw new Error("runtime apply --kind priority requires --priority <0-1000>"); + if (kind === "priority" && priority === null) throw new Error("runtime apply --kind priority requires --priority <1-1000>"); if (kind === "priority" && template !== null) throw new Error("runtime apply --kind priority does not accept --template"); if (kind !== "priority" && priority !== null) throw new Error("--priority requires --kind priority"); if (kind === "capacity" && action !== "apply") throw new Error("runtime --kind capacity only supports apply"); @@ -184,7 +184,7 @@ function parseCapacity(value: string): number { function parsePriority(value: string): number { const parsed = Number(value); - if (!Number.isInteger(parsed) || parsed < 0 || parsed > 1000) throw new Error("--priority must be an integer from 0 to 1000"); + if (!Number.isInteger(parsed) || parsed < 1 || parsed > 1000) throw new Error("--priority must be an integer from 1 to 1000"); return parsed; } diff --git a/scripts/src/platform-infra-sub2api-codex/runtime-remote-script-head.ts b/scripts/src/platform-infra-sub2api-codex/runtime-remote-script-head.ts index 64f1df0f..3a9d6418 100644 --- a/scripts/src/platform-infra-sub2api-codex/runtime-remote-script-head.ts +++ b/scripts/src/platform-infra-sub2api-codex/runtime-remote-script-head.ts @@ -333,7 +333,7 @@ def account_summary(detail, include_rules=False, token=None): "priority": detail.get("priority"), "createdAt": detail.get("created_at"), "updatedAt": detail.get("updated_at"), - "prioritySemantics": {"order": "lower-is-higher", "highest": 0}, + "prioritySemantics": {"order": "lower-is-higher", "highest": 1}, "tempUnschedulable": {key: policy[key] for key in ("enabled", "ruleCount", "statusCodes")}, "matchingTemplate": matching_template(credentials), "poolModeEnabled": credentials.get("pool_mode") is True, diff --git a/scripts/src/platform-infra-sub2api-codex/runtime-render.ts b/scripts/src/platform-infra-sub2api-codex/runtime-render.ts index 3cc0ab45..858fc53f 100644 --- a/scripts/src/platform-infra-sub2api-codex/runtime-render.ts +++ b/scripts/src/platform-infra-sub2api-codex/runtime-render.ts @@ -509,7 +509,7 @@ function renderRuntimeErrors(lines: string[], runtime: Record, ])); } const scoreRule = runtimeRecord(accountQuality.scoreRule) ?? {}; - lines.push(`SCORE RULE reliability=${runtimeText(scoreRule.reliabilityWeight)} latency=${runtimeText(scoreRule.latencyWeight)} availability=${runtimeText(scoreRule.availabilityWeight)} confidence=separate priority=lower-is-higher highest=0`); + lines.push(`SCORE RULE reliability=${runtimeText(scoreRule.reliabilityWeight)} latency=${runtimeText(scoreRule.latencyWeight)} availability=${runtimeText(scoreRule.availabilityWeight)} confidence=separate priority=lower-is-higher highest=1`); if (typeof accountQuality.attribution === "string") lines.push(`NOTE: ${accountQuality.attribution}`); } const errorModels = runtimeRecords(customerErrors.modelBuckets); diff --git a/scripts/src/platform-infra-sub2api-codex/runtime.ts b/scripts/src/platform-infra-sub2api-codex/runtime.ts index bdc7d70a..ba38b094 100644 --- a/scripts/src/platform-infra-sub2api-codex/runtime.ts +++ b/scripts/src/platform-infra-sub2api-codex/runtime.ts @@ -180,7 +180,7 @@ function renderRuntimeHelp(args: string[]): RenderedCliResult { "", "Kinds:", " temp-unschedulable Requires --template ", - " priority Requires --priority <0-1000>; lower is higher", + " priority Requires --priority <1-1000>; lower is higher", " capacity Requires --capacity <1-100000>; account concurrency guard", " account-name Requires one --account and --name ", "", diff --git a/scripts/src/platform-infra-sub2api-codex/types.ts b/scripts/src/platform-infra-sub2api-codex/types.ts index dc2aabb9..6f75171b 100644 --- a/scripts/src/platform-infra-sub2api-codex/types.ts +++ b/scripts/src/platform-infra-sub2api-codex/types.ts @@ -442,7 +442,7 @@ export function codexPoolHelp(): unknown { "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --account --template [--target PK01] [--confirm]", "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts --template [--target PK01] [--confirm] [--full|--raw]", "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --template --select-configured-policy --account-type apikey [--exclude-accounts ] [--target PK01] [--confirm] [--json|--full|--raw]", - "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts --kind priority --priority <0-1000> [--target PK01] [--confirm]", + "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts --kind priority --priority <1-1000> [--target PK01] [--confirm]", "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts --kind capacity --capacity <1-100000> [--target PK01] [--confirm]", "bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --account --kind account-name --name [--target PK01] [--confirm]", "bun scripts/cli.ts platform-infra sub2api codex-pool runtime delete --account --kind temp-unschedulable [--target PK01] [--confirm]",