/** * CodeMeta — v1.6.0 协议核心 * * report.code 是业务命运的单一信息源;status / level / semantic 全部由此派生。 * * 设备端调用 dispatchMessage(code, data) 时,协议层自动按 code 推导 status / level, * 集成方接收消息后调用 resolveCodeMeta(code) 查表得到 semantic / requiresErrorBlock 等。 * * 设计依据:claude-docs/protocol-upgrade-proposal-v1.6.0.md */ import type { ReportLevel, MessageType, CommandType, ProgressPhase, ProgressSourceType } from './index'; /** v1.6.0:单一 status enum,合并 v1.5.0 的 CommandStatus + ProgressStatus */ export declare enum MessageStatus { IN_PROGRESS = "IN_PROGRESS", COMPLETED = "COMPLETED", FAILED = "FAILED", CANCELLED = "CANCELLED" } /** 业务语义分类——终态语义 + 进度语义 */ export type CodeSemantic = 'success' | 'partial' | 'failure' | 'no-op' | 'cancel' | 'busy' | 'phase_start' | 'phase_end' | 'phase_failed' | 'step_success' | 'step_failed' | 'step_skipped' | 'step_progress' | 'retry' | 'retry_pending' | 'warning'; /** * 单一 code 的元数据描述符 * * 派生字段(status / level)会序列化进消息; * 客户端字段(semantic / requiresErrorBlock / isTerminal)仅供查表,不进消息。 */ export interface CodeMeta { isTerminal: boolean; status: MessageStatus; /** * v1.10.3: 支持 array 类型 (partial-failure 多 level 允许) * - string (e.g., 'INFO'): Edge validator 严格相等校验 (大多数 entry) * - readonly ReportLevel[] (e.g., ['INFO','WARNING','ERROR']): Edge validator includes 校验 (partial-failure 场景) */ level: ReportLevel | readonly ReportLevel[]; semantic: CodeSemantic; requiresErrorBlock: boolean; /** * v1.8.0: 上下文派生应用的规则名(debug + dashboard 用),不参与序列化 */ appliedRules?: string[]; /** * v1.8.0: R3 invariant 破坏标记 — Edge 收到此返回值时强制 reject (即使 messageType=PROGRESS_UPDATE) * 仅在 R3 (EDGE_CACHE_* phase + sourceType !== EDGE) 触发,其它规则不会设置 */ violationReason?: string; } /** * v1.8.0: resolveCodeMeta 派生上下文 (5 维 tuple) * * 详见 upgrade-guide-v1.8.0.md §3.2 R1-R7 派生规则。 * * - messageType: wire `type` 字段 * - parentCommandType: 父命令 commandType (Edge/Backend 查 requestRef 关联的 CommandMessage 获得) * - phase: wire `phase` 字段 (PROGRESS_UPDATE 含) * - sourceType: wire `sourceType` 字段 * - subCommandType: wire `command.commandType` (BATCH 子项时一般 SIMPLE) */ export interface CodeMetaContext { messageType?: MessageType; parentCommandType?: CommandType; phase?: ProgressPhase | string; sourceType?: ProgressSourceType; subCommandType?: CommandType; } /** * 终态 code 显式 META 表 * * 这些 code 是业务命运决断点,每个语义都是独特的,**不能用后缀规则推导**。 * 设备端发送终态消息时,dispatchMessage 在此表查询,自动填充消息字段。 */ export declare const EXPLICIT_META: Record; /** * 单一 code 解析入口 (v1.8.0 升维双签名) * * 解析顺序: * 0. v1.8.0 上下文派生 (applyContextRules) — 仅在 ctx 提供时 * 规则 R1-R7 详见 upgrade-guide-v1.8.0.md §3.2 * 1. 终态显式表(EXPLICIT_META) — 17 entries closed enum * (PROGRAM 7 + QUICK_DETECTION 5 + SYNC_MONITORING_TABLE 3 + EDGE 2) * 2. 后缀规则(SUFFIX_RULES) — 20 条规则覆盖数百个进度 + 终态 code * (v1.7.6: +_READ_SUCCESS / _WRITE_SUCCESS SIMPLE 终态后缀) * (v1.7.7: +_READ_FAILED / _WRITE_FAILED + BATCH _ALL_SUCCESS / _PARTIAL_SUCCESS / _ALL_FAILED 终态) * (v1.7.8: +_BROADCAST_SUCCESS / _BROADCAST_FAILED ECAN 广播 WRITE 终态) * (v1.8.0: +_STEP_OK / _STEP_FAIL BATCH/COMPLEX 子项进度显式后缀 — Q9) * 3. 兜底(FALLBACK_META) — 未知 code 降级 * * @param code report.code 字符串 * @param ctx (可选) v1.8.0 上下文 — 不提供时与 v1.7.8 行为兼容 * @returns CodeMeta — status / level / semantic / requiresErrorBlock / isTerminal [+ appliedRules + violationReason] */ export declare function resolveCodeMeta(code: string, ctx?: CodeMetaContext): CodeMeta; /** * 判断 code 是否已知(命中显式表或后缀规则,不走兜底) */ export declare function isKnownCode(code: string): boolean; //# sourceMappingURL=code-meta.d.ts.map