/** * 品牌 ID(编码规范 §8.1)。 * * 每一类 ID 有自己的名义类型 —— TaskId 传不进要 WorkflowId 的位置,编译期就拦下。 * 运行时形态一律是非空字符串;生成归 adapter(clock / uuid 走 port,domain 零随机)。 */ import { z } from 'zod'; function brandedId(_brand: B, label: string) { return z .string() .min(1, `${label}不得为空`) .max(128, `${label}过长`) .brand(); } /* ── 组织 ─────────────────────────────────────────────────────────────── */ export const staffIdSchema = brandedId('StaffId', '员工 ID'); export type StaffId = z.infer; export const positionIdSchema = brandedId('PositionId', '岗位 ID'); export type PositionId = z.infer; /* ── 流程层 ───────────────────────────────────────────────────────────── */ export const processPackageIdSchema = brandedId('ProcessPackageId', '流程包 ID'); export type ProcessPackageId = z.infer; export const workflowIdSchema = brandedId('WorkflowId', '工作流 ID'); export type WorkflowId = z.infer; export const nodeIdSchema = brandedId('NodeId', '节点 ID'); export type NodeId = z.infer; export const triggerIdSchema = brandedId('TriggerId', '触发器 ID'); export type TriggerId = z.infer; export const approvalIdSchema = brandedId('ApprovalId', '审批单 ID'); export type ApprovalId = z.infer; /* ── 活动与任务 ───────────────────────────────────────────────────────── */ export const activityIdSchema = brandedId('ActivityId', '活动 ID'); export type ActivityId = z.infer; export const taskIdSchema = brandedId('TaskId', '任务 ID'); export type TaskId = z.infer; export const deliverableIdSchema = brandedId('DeliverableId', '过程成果 ID'); export type DeliverableId = z.infer; export const stageIdSchema = brandedId('StageId', '阶段 ID'); export type StageId = z.infer; /* ── 人类工具 ─────────────────────────────────────────────────────────── */ export const cardIdSchema = brandedId('CardId', '卡 ID'); export type CardId = z.infer; export const workOrderIdSchema = brandedId('WorkOrderId', '工单 ID'); export type WorkOrderId = z.infer; /* ── 事件 ─────────────────────────────────────────────────────────────── */ export const eventIdSchema = brandedId('EventId', '事件 ID'); export type EventId = z.infer; export const deliveryIdSchema = brandedId('DeliveryId', '投递 ID'); export type DeliveryId = z.infer; export const listenerIdSchema = brandedId('ListenerId', '监听 ID'); export type ListenerId = z.infer; export const messageIdSchema = brandedId('MessageId', '消息 ID'); export type MessageId = z.infer; /* ── 调用层与基座 ─────────────────────────────────────────────────────── */ export const toolIdSchema = brandedId('ToolId', '工具 ID'); export type ToolId = z.infer; export const llmInstanceIdSchema = brandedId('LlmInstanceId', 'LLM 实例 ID'); export type LlmInstanceId = z.infer; export const channelIdSchema = brandedId('ChannelId', '通道实例 ID'); export type ChannelId = z.infer; export const skillIdSchema = brandedId('SkillId', '技能 ID'); export type SkillId = z.infer; export const memoryEntryIdSchema = brandedId('MemoryEntryId', '记忆条目 ID'); export type MemoryEntryId = z.infer; export const actionIntentIdSchema = brandedId('ActionIntentId', '动作意向 ID'); export type ActionIntentId = z.infer; export const minuteIdSchema = brandedId('MinuteId', '纪要 ID'); export type MinuteId = z.infer;