forked from ChaiHao/BPOS-MVP
M1: 底座 —— @contracts 首版 + event / ledger / org / llm
@contracts 首版(§8.1 九个文件): - id 品牌 ID / terminal 终态五名与归侧四标签 / envelope 信封六字段与四类事件 - card 工单两模式 + 对话卡族(形状对齐 2026-07-26 原型定稿) - contract7 契约七件 / ledger 三级寻址与写三分 / process-package 流程包 DSL 与触发器三类 - manifest 活动包清单六区(含 CMMN·DMN·步序声明的资产形状)/ org / api 路由契约 模块(L1): - event 信封存储、归属解析三级短路、投递五诺、监听注册表、三级消费裁定 - ledger schema 自生长(最大化合并/最宽类型/只增不破坏)、任务视图叠加、写三分、冲突检查 - org 岗位授权(客体三类×动作三种)、停用前置检查、会话、种子播种 - llm 四元绑定、ModelGateway 三模式(live/record/replay)—— 两缝之一 app 装配:Hono 服务 + 鉴权中间件 + 治理台/工作台路由;drizzle 迁移;AES-256-GCM 凭证密封 ADR-007 工具链与门禁 · ADR-008 投递队列 · ADR-009 凭证加密 (ADR 编号自 007 续:编码规范 §14 已用到 006,README 写「从 005 续」是笔误) 门禁五道全绿;96 个测试通过,含对真实 PG 的 ledger 集成测试 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
co-authored by
Claude Opus 5
parent
7cd664af3a
commit
14d4fa046a
@@ -0,0 +1,308 @@
|
||||
/**
|
||||
* 治理台路由契约(编码规范 §8.1 / §9.1)。
|
||||
* 治理台九功能不设后端 governance 模块:每个功能是对应模块的管理用例 + 本文件的路由组装(§3)。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
export declare const listStaffRoute: {
|
||||
readonly method: "GET";
|
||||
readonly path: "/api/gov/staff";
|
||||
readonly output: z.ZodObject<{
|
||||
staff: z.ZodArray<z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
account: z.ZodString;
|
||||
name: z.ZodString;
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
state: z.ZodDefault<z.ZodEnum<{
|
||||
active: "active";
|
||||
disabled: "disabled";
|
||||
}>>;
|
||||
position: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
code: z.ZodString;
|
||||
name: z.ZodString;
|
||||
note: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>>;
|
||||
positions: z.ZodArray<z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
code: z.ZodString;
|
||||
name: z.ZodString;
|
||||
note: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const createStaffRoute: {
|
||||
readonly method: "POST";
|
||||
readonly path: "/api/gov/staff";
|
||||
readonly body: z.ZodObject<{
|
||||
account: z.ZodString;
|
||||
name: z.ZodString;
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
account: z.ZodString;
|
||||
name: z.ZodString;
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
state: z.ZodDefault<z.ZodEnum<{
|
||||
active: "active";
|
||||
disabled: "disabled";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const disableStaffCheckRoute: {
|
||||
readonly method: "GET";
|
||||
readonly path: "/api/gov/staff/:staffId/disable-check";
|
||||
readonly params: z.ZodObject<{
|
||||
staffId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
staffId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
blocked: z.ZodBoolean;
|
||||
openTasks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
taskId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
openCards: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
cardId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
openApprovals: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
approvalId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const disableStaffRoute: {
|
||||
readonly method: "POST";
|
||||
readonly path: "/api/gov/staff/:staffId/disable";
|
||||
readonly params: z.ZodObject<{
|
||||
staffId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
ok: z.ZodBoolean;
|
||||
check: z.ZodObject<{
|
||||
staffId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
blocked: z.ZodBoolean;
|
||||
openTasks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
taskId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
openCards: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
cardId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
openApprovals: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
approvalId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const listGrantsRoute: {
|
||||
readonly method: "GET";
|
||||
readonly path: "/api/gov/positions/:positionId/grants";
|
||||
readonly params: z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
grants: z.ZodArray<z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
object: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
action: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const setGrantsRoute: {
|
||||
readonly method: "POST";
|
||||
readonly path: "/api/gov/positions/:positionId/grants";
|
||||
readonly params: z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>;
|
||||
readonly body: z.ZodObject<{
|
||||
grants: z.ZodArray<z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
object: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
action: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
grants: z.ZodArray<z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
object: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
action: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const LLM_PROVIDERS: readonly ["openai-compatible", "openai", "deepseek", "anthropic", "qwen"];
|
||||
export declare const llmProviderSchema: z.ZodEnum<{
|
||||
"openai-compatible": "openai-compatible";
|
||||
openai: "openai";
|
||||
deepseek: "deepseek";
|
||||
anthropic: "anthropic";
|
||||
qwen: "qwen";
|
||||
}>;
|
||||
export type LlmProvider = z.infer<typeof llmProviderSchema>;
|
||||
/** 活动只见自定义模型名;Provider / URL / API-Key / Model 四元在系统侧绑定,活动不触厂商与密钥 */
|
||||
export declare const llmInstanceViewSchema: z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
name: z.ZodString;
|
||||
provider: z.ZodEnum<{
|
||||
"openai-compatible": "openai-compatible";
|
||||
openai: "openai";
|
||||
deepseek: "deepseek";
|
||||
anthropic: "anthropic";
|
||||
qwen: "qwen";
|
||||
}>;
|
||||
baseUrl: z.ZodString;
|
||||
model: z.ZodString;
|
||||
apiKeyBound: z.ZodBoolean;
|
||||
systemUse: z.ZodDefault<z.ZodBoolean>;
|
||||
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
export type LlmInstanceView = z.infer<typeof llmInstanceViewSchema>;
|
||||
export declare const listLlmInstancesRoute: {
|
||||
readonly method: "GET";
|
||||
readonly path: "/api/gov/llm";
|
||||
readonly output: z.ZodObject<{
|
||||
instances: z.ZodArray<z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
name: z.ZodString;
|
||||
provider: z.ZodEnum<{
|
||||
"openai-compatible": "openai-compatible";
|
||||
openai: "openai";
|
||||
deepseek: "deepseek";
|
||||
anthropic: "anthropic";
|
||||
qwen: "qwen";
|
||||
}>;
|
||||
baseUrl: z.ZodString;
|
||||
model: z.ZodString;
|
||||
apiKeyBound: z.ZodBoolean;
|
||||
systemUse: z.ZodDefault<z.ZodBoolean>;
|
||||
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const upsertLlmInstanceRoute: {
|
||||
readonly method: "POST";
|
||||
readonly path: "/api/gov/llm";
|
||||
readonly body: z.ZodObject<{
|
||||
id: z.ZodOptional<z.ZodString>;
|
||||
name: z.ZodString;
|
||||
provider: z.ZodEnum<{
|
||||
"openai-compatible": "openai-compatible";
|
||||
openai: "openai";
|
||||
deepseek: "deepseek";
|
||||
anthropic: "anthropic";
|
||||
qwen: "qwen";
|
||||
}>;
|
||||
baseUrl: z.ZodString;
|
||||
model: z.ZodString;
|
||||
apiKey: z.ZodOptional<z.ZodString>;
|
||||
systemUse: z.ZodDefault<z.ZodBoolean>;
|
||||
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
name: z.ZodString;
|
||||
provider: z.ZodEnum<{
|
||||
"openai-compatible": "openai-compatible";
|
||||
openai: "openai";
|
||||
deepseek: "deepseek";
|
||||
anthropic: "anthropic";
|
||||
qwen: "qwen";
|
||||
}>;
|
||||
baseUrl: z.ZodString;
|
||||
model: z.ZodString;
|
||||
apiKeyBound: z.ZodBoolean;
|
||||
systemUse: z.ZodDefault<z.ZodBoolean>;
|
||||
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const probeLlmInstanceRoute: {
|
||||
readonly method: "POST";
|
||||
readonly path: "/api/gov/llm/:id/probe";
|
||||
readonly params: z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
ok: z.ZodBoolean;
|
||||
latencyMs: z.ZodOptional<z.ZodNumber>;
|
||||
error: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 路由契约的形状(编码规范 §8.1 / §9.2)。
|
||||
*
|
||||
* 前端只经 `shared/typed-fetch` + 本目录的路由契约与服务端交互;组件内禁止裸 fetch。
|
||||
* **禁止 Hono RPC 客户端** —— 它要求前端 import 后端类型,违反 §5.1。
|
||||
*/
|
||||
import type { z } from 'zod';
|
||||
export declare const HTTP_METHODS: readonly ["GET", "POST", "PATCH", "DELETE"];
|
||||
export type HttpMethod = (typeof HTTP_METHODS)[number];
|
||||
/**
|
||||
* 一条路由契约。`path` 用 `:name` 表示路径参数,与 `params` 的键一一对应。
|
||||
* body 只在 POST/PATCH 上有意义;GET 用 query。
|
||||
*/
|
||||
export type RouteContract<TParams extends z.ZodTypeAny = z.ZodTypeAny, TQuery extends z.ZodTypeAny = z.ZodTypeAny, TBody extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
|
||||
readonly method: HttpMethod;
|
||||
readonly path: string;
|
||||
readonly params?: TParams;
|
||||
readonly query?: TQuery;
|
||||
readonly body?: TBody;
|
||||
readonly output: TOutput;
|
||||
};
|
||||
export type RouteOutput<R extends RouteContract> = z.infer<R['output']>;
|
||||
export type RouteBody<R extends RouteContract> = R['body'] extends z.ZodTypeAny ? z.infer<R['body']> : never;
|
||||
/** 结构化错误:前端按 code 分辨,不解析文案 */
|
||||
export declare const API_ERROR_CODES: readonly ["unauthenticated", "forbidden", "not-found", "validation-failed", "conflict", "precondition-failed", "internal"];
|
||||
export type ApiErrorCode = (typeof API_ERROR_CODES)[number];
|
||||
export type ApiError = {
|
||||
readonly code: ApiErrorCode;
|
||||
readonly message: string;
|
||||
readonly detail?: unknown;
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './http.ts';
|
||||
export * from './workbench.ts';
|
||||
export * from './governance.ts';
|
||||
export * from './ingest.ts';
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 入站路由契约(编码规范 §8.1)。
|
||||
*
|
||||
* 通道入站 → 归属解析 → 统一事件流(OS 06)。MVP 的邮件通道以**模拟通道**接入:
|
||||
* mock 只允许出现在**外界**(邮件通道与外部系统),系统内部机制不得 mock(README MVP 完成判据)。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
/** 一封入站邮件的归一形状 —— 真实邮件通道与模拟通道共用 */
|
||||
export declare const inboundMailSchema: z.ZodObject<{
|
||||
messageId: z.ZodString;
|
||||
threadId: z.ZodOptional<z.ZodString>;
|
||||
from: z.ZodString;
|
||||
to: z.ZodArray<z.ZodString>;
|
||||
cc: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
subject: z.ZodString;
|
||||
body: z.ZodString;
|
||||
receivedAt: z.ZodISODateTime;
|
||||
attachments: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
contentType: z.ZodString;
|
||||
size: z.ZodNumber;
|
||||
ref: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
export type InboundMail = z.infer<typeof inboundMailSchema>;
|
||||
export declare const ingestMailRoute: {
|
||||
readonly method: "POST";
|
||||
readonly path: "/api/ingest/channel/:channelId/mail";
|
||||
readonly params: z.ZodObject<{
|
||||
channelId: z.core.$ZodBranded<z.ZodString, "ChannelId", "out">;
|
||||
}, z.core.$strip>;
|
||||
readonly body: z.ZodObject<{
|
||||
messageId: z.ZodString;
|
||||
threadId: z.ZodOptional<z.ZodString>;
|
||||
from: z.ZodString;
|
||||
to: z.ZodArray<z.ZodString>;
|
||||
cc: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
subject: z.ZodString;
|
||||
body: z.ZodString;
|
||||
receivedAt: z.ZodISODateTime;
|
||||
attachments: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
contentType: z.ZodString;
|
||||
size: z.ZodNumber;
|
||||
ref: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
readonly output: z.ZodObject<{
|
||||
eventId: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
|
||||
resolution: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
outcome: z.ZodLiteral<"owned">;
|
||||
rule: z.ZodEnum<{
|
||||
thread: "thread";
|
||||
"listener-key": "listener-key";
|
||||
"address-window": "address-window";
|
||||
}>;
|
||||
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
outcome: z.ZodLiteral<"unowned">;
|
||||
reason: z.ZodEnum<{
|
||||
"no-match": "no-match";
|
||||
ambiguous: "ambiguous";
|
||||
"extract-failed": "extract-failed";
|
||||
}>;
|
||||
fallbackPosition: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "PositionId", "out">>;
|
||||
}, z.core.$strip>], "outcome">;
|
||||
listenersHit: z.ZodNumber;
|
||||
triggersHit: z.ZodNumber;
|
||||
fellBackToMessage: z.ZodBoolean;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 工作台路由契约(编码规范 §8.1 / §9.1)。
|
||||
* 工作台五要素:任务 / 审批 / 消息 / 纪要 / 汇报 —— 同一份过程事实的五种投影。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
export declare const sessionRoute: {
|
||||
readonly method: "GET";
|
||||
readonly path: "/api/session";
|
||||
readonly output: z.ZodObject<{
|
||||
staff: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
account: z.ZodString;
|
||||
name: z.ZodString;
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
state: z.ZodDefault<z.ZodEnum<{
|
||||
active: "active";
|
||||
disabled: "disabled";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
position: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
code: z.ZodString;
|
||||
name: z.ZodString;
|
||||
note: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
grants: z.ZodArray<z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
object: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
action: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
export declare const healthRoute: {
|
||||
readonly method: "GET";
|
||||
readonly path: "/api/health";
|
||||
readonly output: z.ZodObject<{
|
||||
ok: z.ZodBoolean;
|
||||
version: z.ZodString;
|
||||
db: z.ZodEnum<{
|
||||
up: "up";
|
||||
down: "down";
|
||||
}>;
|
||||
}, z.core.$strip>;
|
||||
};
|
||||
+1486
File diff suppressed because it is too large
Load Diff
+187
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* 契约七件(编码规范 §8.1;语义出处 OS 4.1,AM 01)。
|
||||
*
|
||||
* 契约是活动对调用方暴露的全部真相,也是对 Agent 机制的全部授权;
|
||||
* 两种范式同一契约格式 —— 这是「统一套执行契约」的锚点。
|
||||
* 契约必须在活动启动前冻结;运行中不得变更 —— 变更即新版本。
|
||||
*
|
||||
* ADR-003:**声明层 = JSON Schema 2020-12 子集**(活动声明是运行时数据,可 diff 可版本),
|
||||
* 代码层 = zod。本文件用 zod 描述「声明的形状」,声明里的 schema 字段本身是 JSON Schema。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
/** JSON Schema 2020-12 子集的运行时形态 —— 由 ajv 校验,不在编译期展开 */
|
||||
export declare const jsonSchemaSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
export type JsonSchema = z.infer<typeof jsonSchemaSchema>;
|
||||
export declare const contractInputSchema: z.ZodObject<{
|
||||
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
messageAllowed: z.ZodDefault<z.ZodBoolean>;
|
||||
messageHint: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type ContractInput = z.infer<typeof contractInputSchema>;
|
||||
export declare const outputPortSchema: z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
description: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type OutputPort = z.infer<typeof outputPortSchema>;
|
||||
export declare const outputPortsSchema: z.ZodObject<{
|
||||
mandatory: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
description: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
selective: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
group: z.ZodString;
|
||||
ports: z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
description: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
export type OutputPorts = z.infer<typeof outputPortsSchema>;
|
||||
export declare const requiredDeliverableSchema: z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
label: z.ZodString;
|
||||
schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
||||
}, z.core.$strip>;
|
||||
export type RequiredDeliverable = z.infer<typeof requiredDeliverableSchema>;
|
||||
export declare const acceptanceCriterionSchema: z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
label: z.ZodString;
|
||||
level: z.ZodEnum<{
|
||||
L1: "L1";
|
||||
L2: "L2";
|
||||
L3: "L3";
|
||||
L4: "L4";
|
||||
L5: "L5";
|
||||
}>;
|
||||
predicate: z.ZodOptional<z.ZodString>;
|
||||
modelRef: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type AcceptanceCriterion = z.infer<typeof acceptanceCriterionSchema>;
|
||||
export declare const prohibitionSchema: z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
statement: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
export type Prohibition = z.infer<typeof prohibitionSchema>;
|
||||
export declare const authorizationBoundarySchema: z.ZodObject<{
|
||||
discretion: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
statement: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
preauthorizedActions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
tool: z.ZodString;
|
||||
operation: z.ZodString;
|
||||
limit: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
humanCallBudget: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
export type AuthorizationBoundary = z.infer<typeof authorizationBoundarySchema>;
|
||||
/** 预算四类上限 —— 由基座在环外强制,不得由活动代码自查自守(AM 10.1) */
|
||||
export declare const budgetCapsSchema: z.ZodObject<{
|
||||
steps: z.ZodNumber;
|
||||
tokens: z.ZodNumber;
|
||||
activeMinutes: z.ZodNumber;
|
||||
humanCalls: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
export type BudgetCaps = z.infer<typeof budgetCapsSchema>;
|
||||
export declare const resourceDeclarationSchema: z.ZodObject<{
|
||||
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
version: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
skills: z.ZodDefault<z.ZodArray<z.core.$ZodBranded<z.ZodString, "SkillId", "out">>>;
|
||||
models: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
budget: z.ZodObject<{
|
||||
steps: z.ZodNumber;
|
||||
tokens: z.ZodNumber;
|
||||
activeMinutes: z.ZodNumber;
|
||||
humanCalls: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>;
|
||||
export type ResourceDeclaration = z.infer<typeof resourceDeclarationSchema>;
|
||||
export declare const sevenPartContractSchema: z.ZodObject<{
|
||||
activityId: z.core.$ZodBranded<z.ZodString, "ActivityId", "out">;
|
||||
version: z.ZodString;
|
||||
input: z.ZodObject<{
|
||||
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
messageAllowed: z.ZodDefault<z.ZodBoolean>;
|
||||
messageHint: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
output: z.ZodObject<{
|
||||
mandatory: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
description: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
selective: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
group: z.ZodString;
|
||||
ports: z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
description: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
requiredDeliverables: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
label: z.ZodString;
|
||||
schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
||||
}, z.core.$strip>>>;
|
||||
acceptanceCriteria: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
label: z.ZodString;
|
||||
level: z.ZodEnum<{
|
||||
L1: "L1";
|
||||
L2: "L2";
|
||||
L3: "L3";
|
||||
L4: "L4";
|
||||
L5: "L5";
|
||||
}>;
|
||||
predicate: z.ZodOptional<z.ZodString>;
|
||||
modelRef: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
prohibitions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
statement: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
authorization: z.ZodObject<{
|
||||
discretion: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
key: z.ZodString;
|
||||
statement: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
preauthorizedActions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
tool: z.ZodString;
|
||||
operation: z.ZodString;
|
||||
limit: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
humanCallBudget: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
resources: z.ZodObject<{
|
||||
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
version: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>>>;
|
||||
skills: z.ZodDefault<z.ZodArray<z.core.$ZodBranded<z.ZodString, "SkillId", "out">>>;
|
||||
models: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
budget: z.ZodObject<{
|
||||
steps: z.ZodNumber;
|
||||
tokens: z.ZodNumber;
|
||||
activeMinutes: z.ZodNumber;
|
||||
humanCalls: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>;
|
||||
export type SevenPartContract = z.infer<typeof sevenPartContractSchema>;
|
||||
/**
|
||||
* 完成时的发射集合 = 全部必发口 + 每个选择组各一口(AM 1.2)。
|
||||
* 纯函数,前后端同源:前端预演、后端裁决。
|
||||
*/
|
||||
export declare function emissionPortNames(ports: OutputPorts, selected: Readonly<Record<string, string>>): string[];
|
||||
/** 选择组必须恰选一口 —— 未选或选了组外的口即非法 */
|
||||
export declare function validateSelection(ports: OutputPorts, selected: Readonly<Record<string, string>>): string[];
|
||||
/** 验收等级不得谎报:L4 不得标注为 L1–L3;生成者不得自评(AM 12.1) */
|
||||
export declare function machineCheckable(criterion: AcceptanceCriterion): boolean;
|
||||
+343
@@ -0,0 +1,343 @@
|
||||
/**
|
||||
* 统一事件标准(编码规范 §8.1;语义出处 OS 06)。
|
||||
*
|
||||
* 系统向活动只以统一信封抛四类事件;一条事件流,三级消费(任务监听 / 触发器 / 消息)。
|
||||
* 投递五诺(先持久后投递 / 同任务按序 / 至少一次 + 幂等 / 处理有回执 / 扇出与幂等)
|
||||
* 是 `event` 模块的实现承诺,不在本文件表达 —— 本文件只定信封的形状。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
export declare const EVENT_TYPES: readonly ["data", "time", "human", "control"];
|
||||
export declare const eventTypeSchema: z.ZodEnum<{
|
||||
human: "human";
|
||||
data: "data";
|
||||
time: "time";
|
||||
control: "control";
|
||||
}>;
|
||||
export type EventType = z.infer<typeof eventTypeSchema>;
|
||||
export declare const EVENT_TYPE_LABEL: Readonly<Record<EventType, string>>;
|
||||
/** 消费目标四类(OS 6.1):任务 / 触发器 / 工作流 / 消息收件岗位 */
|
||||
export declare const eventTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"trigger">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"workflow">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "WorkflowId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"message-position">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>], "kind">;
|
||||
export type EventTarget = z.infer<typeof eventTargetSchema>;
|
||||
/** 起因:数据对象 / 卡 ID / 定时器 ID —— 「这条事件是被什么激起的」 */
|
||||
export declare const eventCauseSchema: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
"ledger-write": "ledger-write";
|
||||
"card-reply": "card-reply";
|
||||
timer: "timer";
|
||||
inbound: "inbound";
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
}>;
|
||||
ref: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
export type EventCause = z.infer<typeof eventCauseSchema>;
|
||||
export declare const EVENT_SOURCES: readonly ["channel", "engine", "desk", "governance"];
|
||||
export declare const eventSourceKindSchema: z.ZodEnum<{
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
channel: "channel";
|
||||
desk: "desk";
|
||||
}>;
|
||||
export type EventSourceKind = z.infer<typeof eventSourceKindSchema>;
|
||||
export declare const eventSourceSchema: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
channel: "channel";
|
||||
desk: "desk";
|
||||
}>;
|
||||
channelId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ChannelId", "out">>;
|
||||
detail: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type EventSource = z.infer<typeof eventSourceSchema>;
|
||||
/** 载荷:schema 化内容 + 原件指针(如邮件原文的存档地址) */
|
||||
export declare const eventPayloadSchema: z.ZodObject<{
|
||||
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
originRef: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type EventPayload = z.infer<typeof eventPayloadSchema>;
|
||||
export declare const envelopeSchema: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
|
||||
type: z.ZodEnum<{
|
||||
human: "human";
|
||||
data: "data";
|
||||
time: "time";
|
||||
control: "control";
|
||||
}>;
|
||||
correlation: z.ZodObject<{
|
||||
target: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"trigger">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"workflow">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "WorkflowId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"message-position">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>], "kind">>;
|
||||
cause: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
"ledger-write": "ledger-write";
|
||||
"card-reply": "card-reply";
|
||||
timer: "timer";
|
||||
inbound: "inbound";
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
}>;
|
||||
ref: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
keys: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
||||
}, z.core.$strip>;
|
||||
payload: z.ZodObject<{
|
||||
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
originRef: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
occurredAt: z.ZodISODateTime;
|
||||
source: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
channel: "channel";
|
||||
desk: "desk";
|
||||
}>;
|
||||
channelId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ChannelId", "out">>;
|
||||
detail: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
trace: z.ZodObject<{
|
||||
storeRef: z.ZodString;
|
||||
taskMemoryRef: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>;
|
||||
export type Envelope = z.infer<typeof envelopeSchema>;
|
||||
/**
|
||||
* 尚未落存储的信封草稿 —— `publish` 的入参。
|
||||
*
|
||||
* `target` 在此**可空**:原始事件未必知道自己该被谁消费。归属解析(6.2)与三级消费判定
|
||||
* (任务监听 / 触发器 / 消息兜底,6.3)由 `event` 模块完成,并为每个命中目标生成一份
|
||||
* 独立投递 —— 投递出去的信封「关联 = 单目标」,这正是扇出与幂等承诺的形态。
|
||||
* `storeRef` 由 event adapter 落库时补。
|
||||
*/
|
||||
export declare const envelopeDraftSchema: z.ZodObject<{
|
||||
type: z.ZodEnum<{
|
||||
human: "human";
|
||||
data: "data";
|
||||
time: "time";
|
||||
control: "control";
|
||||
}>;
|
||||
payload: z.ZodObject<{
|
||||
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
originRef: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
source: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
channel: "channel";
|
||||
desk: "desk";
|
||||
}>;
|
||||
channelId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ChannelId", "out">>;
|
||||
detail: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
correlation: z.ZodObject<{
|
||||
target: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"trigger">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"workflow">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "WorkflowId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"message-position">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>], "kind">>;
|
||||
cause: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
"ledger-write": "ledger-write";
|
||||
"card-reply": "card-reply";
|
||||
timer: "timer";
|
||||
inbound: "inbound";
|
||||
governance: "governance";
|
||||
engine: "engine";
|
||||
}>;
|
||||
ref: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
keys: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
||||
}, z.core.$strip>;
|
||||
occurredAt: z.ZodISODateTime;
|
||||
id: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "EventId", "out">>;
|
||||
}, z.core.$strip>;
|
||||
export type EnvelopeDraft = z.infer<typeof envelopeDraftSchema>;
|
||||
/** 控制事件载荷:三语义 + 发起人 */
|
||||
export declare const controlPayloadSchema: z.ZodObject<{
|
||||
semantic: z.ZodEnum<{
|
||||
pause: "pause";
|
||||
halt: "halt";
|
||||
terminate: "terminate";
|
||||
}>;
|
||||
reason: z.ZodOptional<z.ZodString>;
|
||||
issuedBy: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
export type ControlPayload = z.infer<typeof controlPayloadSchema>;
|
||||
/** 时间事件载荷:哪个监听 / 定时器到点 */
|
||||
export declare const timePayloadSchema: z.ZodObject<{
|
||||
listenerId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ListenerId", "out">>;
|
||||
timerRef: z.ZodString;
|
||||
escalation: z.ZodOptional<z.ZodEnum<{
|
||||
nudge: "nudge";
|
||||
reroute: "reroute";
|
||||
escalate: "escalate";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
export type TimePayload = z.infer<typeof timePayloadSchema>;
|
||||
/** 数据事件载荷:域.对象.主键 的正式版写入 —— 草稿写不抛事件(OS 09) */
|
||||
export declare const dataPayloadSchema: z.ZodObject<{
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
primaryKey: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
||||
changed: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
||||
operation: z.ZodEnum<{
|
||||
insert: "insert";
|
||||
update: "update";
|
||||
delete: "delete";
|
||||
}>;
|
||||
}, z.core.$strip>;
|
||||
export type DataPayload = z.infer<typeof dataPayloadSchema>;
|
||||
/**
|
||||
* 处理语义:loop 事件即观察 / flow 事件即步的完成条件。
|
||||
* 这是**引擎层**的区分,交互层不可见(编码规范 §9 双层边界)。
|
||||
*/
|
||||
export declare const LISTENER_SEMANTICS: readonly ["observe", "complete-step"];
|
||||
export declare const listenerSemanticSchema: z.ZodEnum<{
|
||||
observe: "observe";
|
||||
"complete-step": "complete-step";
|
||||
}>;
|
||||
export type ListenerSemantic = z.infer<typeof listenerSemanticSchema>;
|
||||
export declare const listenerSpecSchema: z.ZodObject<{
|
||||
origin: z.ZodEnum<{
|
||||
static: "static";
|
||||
dynamic: "dynamic";
|
||||
}>;
|
||||
eventType: z.ZodEnum<{
|
||||
human: "human";
|
||||
data: "data";
|
||||
time: "time";
|
||||
control: "control";
|
||||
}>;
|
||||
keyFilter: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
||||
condition: z.ZodOptional<z.ZodString>;
|
||||
semantic: z.ZodEnum<{
|
||||
observe: "observe";
|
||||
"complete-step": "complete-step";
|
||||
}>;
|
||||
deadline: z.ZodString;
|
||||
escalation: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
||||
nudge: "nudge";
|
||||
reroute: "reroute";
|
||||
escalate: "escalate";
|
||||
}>>>;
|
||||
}, z.core.$strip>;
|
||||
export type ListenerSpec = z.infer<typeof listenerSpecSchema>;
|
||||
export declare const registeredListenerSchema: z.ZodObject<{
|
||||
origin: z.ZodEnum<{
|
||||
static: "static";
|
||||
dynamic: "dynamic";
|
||||
}>;
|
||||
eventType: z.ZodEnum<{
|
||||
human: "human";
|
||||
data: "data";
|
||||
time: "time";
|
||||
control: "control";
|
||||
}>;
|
||||
keyFilter: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
||||
condition: z.ZodOptional<z.ZodString>;
|
||||
semantic: z.ZodEnum<{
|
||||
observe: "observe";
|
||||
"complete-step": "complete-step";
|
||||
}>;
|
||||
deadline: z.ZodString;
|
||||
escalation: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
||||
nudge: "nudge";
|
||||
reroute: "reroute";
|
||||
escalate: "escalate";
|
||||
}>>>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "ListenerId", "out">;
|
||||
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
registeredAt: z.ZodISODateTime;
|
||||
expiresAt: z.ZodISODateTime;
|
||||
state: z.ZodEnum<{
|
||||
armed: "armed";
|
||||
fired: "fired";
|
||||
expired: "expired";
|
||||
cancelled: "cancelled";
|
||||
}>;
|
||||
}, z.core.$strip>;
|
||||
export type RegisteredListener = z.infer<typeof registeredListenerSchema>;
|
||||
export declare const deliverySchema: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "DeliveryId", "out">;
|
||||
eventId: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
|
||||
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"trigger">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"workflow">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "WorkflowId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"message-position">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
}, z.core.$strip>], "kind">;
|
||||
attempt: z.ZodNumber;
|
||||
state: z.ZodEnum<{
|
||||
pending: "pending";
|
||||
delivered: "delivered";
|
||||
failed: "failed";
|
||||
"dead-letter": "dead-letter";
|
||||
}>;
|
||||
lastError: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type Delivery = z.infer<typeof deliverySchema>;
|
||||
/** 匹配次序确定、逐级短路:① 线程精确 ② 关联键命中监听 ③ 地址 + 时间窗 */
|
||||
export declare const OWNERSHIP_RULES: readonly ["thread", "listener-key", "address-window"];
|
||||
export declare const ownershipRuleSchema: z.ZodEnum<{
|
||||
thread: "thread";
|
||||
"listener-key": "listener-key";
|
||||
"address-window": "address-window";
|
||||
}>;
|
||||
export type OwnershipRule = z.infer<typeof ownershipRuleSchema>;
|
||||
export declare const ownershipResolutionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
outcome: z.ZodLiteral<"owned">;
|
||||
rule: z.ZodEnum<{
|
||||
thread: "thread";
|
||||
"listener-key": "listener-key";
|
||||
"address-window": "address-window";
|
||||
}>;
|
||||
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
outcome: z.ZodLiteral<"unowned">;
|
||||
reason: z.ZodEnum<{
|
||||
"no-match": "no-match";
|
||||
ambiguous: "ambiguous";
|
||||
"extract-failed": "extract-failed";
|
||||
}>;
|
||||
fallbackPosition: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "PositionId", "out">>;
|
||||
}, z.core.$strip>], "outcome">;
|
||||
export type OwnershipResolution = z.infer<typeof ownershipResolutionSchema>;
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 品牌 ID(编码规范 §8.1)。
|
||||
*
|
||||
* 每一类 ID 有自己的名义类型 —— TaskId 传不进要 WorkflowId 的位置,编译期就拦下。
|
||||
* 运行时形态一律是非空字符串;生成归 adapter(clock / uuid 走 port,domain 零随机)。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
export declare const staffIdSchema: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
export type StaffId = z.infer<typeof staffIdSchema>;
|
||||
export declare const positionIdSchema: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
export type PositionId = z.infer<typeof positionIdSchema>;
|
||||
export declare const processPackageIdSchema: z.core.$ZodBranded<z.ZodString, "ProcessPackageId", "out">;
|
||||
export type ProcessPackageId = z.infer<typeof processPackageIdSchema>;
|
||||
export declare const workflowIdSchema: z.core.$ZodBranded<z.ZodString, "WorkflowId", "out">;
|
||||
export type WorkflowId = z.infer<typeof workflowIdSchema>;
|
||||
export declare const nodeIdSchema: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
export type NodeId = z.infer<typeof nodeIdSchema>;
|
||||
export declare const triggerIdSchema: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||
export type TriggerId = z.infer<typeof triggerIdSchema>;
|
||||
export declare const approvalIdSchema: z.core.$ZodBranded<z.ZodString, "ApprovalId", "out">;
|
||||
export type ApprovalId = z.infer<typeof approvalIdSchema>;
|
||||
export declare const activityIdSchema: z.core.$ZodBranded<z.ZodString, "ActivityId", "out">;
|
||||
export type ActivityId = z.infer<typeof activityIdSchema>;
|
||||
export declare const taskIdSchema: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
export type TaskId = z.infer<typeof taskIdSchema>;
|
||||
export declare const deliverableIdSchema: z.core.$ZodBranded<z.ZodString, "DeliverableId", "out">;
|
||||
export type DeliverableId = z.infer<typeof deliverableIdSchema>;
|
||||
export declare const stageIdSchema: z.core.$ZodBranded<z.ZodString, "StageId", "out">;
|
||||
export type StageId = z.infer<typeof stageIdSchema>;
|
||||
export declare const cardIdSchema: z.core.$ZodBranded<z.ZodString, "CardId", "out">;
|
||||
export type CardId = z.infer<typeof cardIdSchema>;
|
||||
export declare const workOrderIdSchema: z.core.$ZodBranded<z.ZodString, "WorkOrderId", "out">;
|
||||
export type WorkOrderId = z.infer<typeof workOrderIdSchema>;
|
||||
export declare const eventIdSchema: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
|
||||
export type EventId = z.infer<typeof eventIdSchema>;
|
||||
export declare const deliveryIdSchema: z.core.$ZodBranded<z.ZodString, "DeliveryId", "out">;
|
||||
export type DeliveryId = z.infer<typeof deliveryIdSchema>;
|
||||
export declare const listenerIdSchema: z.core.$ZodBranded<z.ZodString, "ListenerId", "out">;
|
||||
export type ListenerId = z.infer<typeof listenerIdSchema>;
|
||||
export declare const messageIdSchema: z.core.$ZodBranded<z.ZodString, "MessageId", "out">;
|
||||
export type MessageId = z.infer<typeof messageIdSchema>;
|
||||
export declare const toolIdSchema: z.core.$ZodBranded<z.ZodString, "ToolId", "out">;
|
||||
export type ToolId = z.infer<typeof toolIdSchema>;
|
||||
export declare const llmInstanceIdSchema: z.core.$ZodBranded<z.ZodString, "LlmInstanceId", "out">;
|
||||
export type LlmInstanceId = z.infer<typeof llmInstanceIdSchema>;
|
||||
export declare const channelIdSchema: z.core.$ZodBranded<z.ZodString, "ChannelId", "out">;
|
||||
export type ChannelId = z.infer<typeof channelIdSchema>;
|
||||
export declare const skillIdSchema: z.core.$ZodBranded<z.ZodString, "SkillId", "out">;
|
||||
export type SkillId = z.infer<typeof skillIdSchema>;
|
||||
export declare const memoryEntryIdSchema: z.core.$ZodBranded<z.ZodString, "MemoryEntryId", "out">;
|
||||
export type MemoryEntryId = z.infer<typeof memoryEntryIdSchema>;
|
||||
export declare const actionIntentIdSchema: z.core.$ZodBranded<z.ZodString, "ActionIntentId", "out">;
|
||||
export type ActionIntentId = z.infer<typeof actionIntentIdSchema>;
|
||||
export declare const minuteIdSchema: z.core.$ZodBranded<z.ZodString, "MinuteId", "out">;
|
||||
export type MinuteId = z.infer<typeof minuteIdSchema>;
|
||||
+11
-1
@@ -3,4 +3,14 @@
|
||||
* 只有 zod schema、常量、品牌类型与推导类型,零实现。
|
||||
* 修改本包任何导出 = 契约变更(§12.4)。
|
||||
*/
|
||||
export declare const CONTRACTS_VERSION = "0.0.0-m0";
|
||||
export declare const CONTRACTS_VERSION = "0.1.0-m1";
|
||||
export * from './id.ts';
|
||||
export * from './terminal.ts';
|
||||
export * from './envelope.ts';
|
||||
export * from './card.ts';
|
||||
export * from './contract7.ts';
|
||||
export * from './ledger.ts';
|
||||
export * from './process-package.ts';
|
||||
export * from './manifest.ts';
|
||||
export * from './org.ts';
|
||||
export * from './api/index.ts';
|
||||
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
/**
|
||||
* 数据与台账(编码规范 §8.1 / §7.2;语义出处 OS 04 / 09,AM 10.3 / 11.1)。
|
||||
*
|
||||
* 三级寻址「数据域.数据对象.字段」+ 通用事务性接口 + 写三分(系统写 / 草稿写 / 放行写)。
|
||||
* 写三分是 `ledger` 出口上的**三个不同方法**,不是一个带 flag 的方法 —— 调用方拿不到「绕门」的形态。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
/**
|
||||
* 数据域:活动自持域用活动名,共享域固定为 `shared`(AM 11.3 暗耦合禁令)。
|
||||
* 活动间不得共享自持域的数据表;跨活动的事实只有两条路 —— 输出口载荷,或共享域。
|
||||
*/
|
||||
export declare const SHARED_DOMAIN = "shared";
|
||||
export declare const ledgerAddressSchema: z.ZodObject<{
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type LedgerAddress = z.infer<typeof ledgerAddressSchema>;
|
||||
export declare function formatAddress(address: LedgerAddress): string;
|
||||
export declare function parseAddress(text: string): LedgerAddress;
|
||||
export declare function isSharedDomain(address: LedgerAddress): boolean;
|
||||
/**
|
||||
* 字段类型 —— 台账自生长的类型格。
|
||||
* 「同名异型取能兼容双方的最宽类型」(放宽即增,不破坏);语义互斥才拦下(OS 04)。
|
||||
*/
|
||||
export declare const LEDGER_FIELD_TYPES: readonly ["text", "number", "integer", "boolean", "date", "timestamp", "json"];
|
||||
export declare const ledgerFieldTypeSchema: z.ZodEnum<{
|
||||
number: "number";
|
||||
boolean: "boolean";
|
||||
json: "json";
|
||||
text: "text";
|
||||
date: "date";
|
||||
integer: "integer";
|
||||
timestamp: "timestamp";
|
||||
}>;
|
||||
export type LedgerFieldType = z.infer<typeof ledgerFieldTypeSchema>;
|
||||
/** 字段使用声明 —— 声明的是**活动要用什么字段**,不是对象该定义什么字段 */
|
||||
export declare const fieldDeclarationSchema: z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
type: z.ZodEnum<{
|
||||
number: "number";
|
||||
boolean: "boolean";
|
||||
json: "json";
|
||||
text: "text";
|
||||
date: "date";
|
||||
integer: "integer";
|
||||
timestamp: "timestamp";
|
||||
}>;
|
||||
label: z.ZodOptional<z.ZodString>;
|
||||
primaryKey: z.ZodDefault<z.ZodBoolean>;
|
||||
masked: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
export type FieldDeclaration = z.infer<typeof fieldDeclarationSchema>;
|
||||
export declare const objectDeclarationSchema: z.ZodObject<{
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
label: z.ZodOptional<z.ZodString>;
|
||||
fields: z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
type: z.ZodEnum<{
|
||||
number: "number";
|
||||
boolean: "boolean";
|
||||
json: "json";
|
||||
text: "text";
|
||||
date: "date";
|
||||
integer: "integer";
|
||||
timestamp: "timestamp";
|
||||
}>;
|
||||
label: z.ZodOptional<z.ZodString>;
|
||||
primaryKey: z.ZodDefault<z.ZodBoolean>;
|
||||
masked: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
export type ObjectDeclaration = z.infer<typeof objectDeclarationSchema>;
|
||||
export declare const ledgerRowSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
export type LedgerRow = z.infer<typeof ledgerRowSchema>;
|
||||
export declare const ledgerKeySchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
||||
export type LedgerKey = z.infer<typeof ledgerKeySchema>;
|
||||
export declare const LEDGER_OPERATIONS: readonly ["insert", "update", "upsert", "delete"];
|
||||
export declare const ledgerOperationSchema: z.ZodEnum<{
|
||||
insert: "insert";
|
||||
update: "update";
|
||||
delete: "delete";
|
||||
upsert: "upsert";
|
||||
}>;
|
||||
export type LedgerOperation = z.infer<typeof ledgerOperationSchema>;
|
||||
export declare const ledgerMutationSchema: z.ZodObject<{
|
||||
address: z.ZodObject<{
|
||||
object: z.ZodString;
|
||||
domain: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
operation: z.ZodEnum<{
|
||||
insert: "insert";
|
||||
update: "update";
|
||||
delete: "delete";
|
||||
upsert: "upsert";
|
||||
}>;
|
||||
key: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
||||
values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
||||
}, z.core.$strip>;
|
||||
export type LedgerMutation = z.infer<typeof ledgerMutationSchema>;
|
||||
/** 查询:简单等值过滤 + 排序 + 分页(治理台数据管理的记录浏览也走这里) */
|
||||
export declare const ledgerQuerySchema: z.ZodObject<{
|
||||
address: z.ZodObject<{
|
||||
object: z.ZodString;
|
||||
domain: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
where: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
||||
orderBy: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
field: z.ZodString;
|
||||
dir: z.ZodEnum<{
|
||||
desc: "desc";
|
||||
asc: "asc";
|
||||
}>;
|
||||
}, z.core.$strip>>>;
|
||||
limit: z.ZodDefault<z.ZodNumber>;
|
||||
offset: z.ZodDefault<z.ZodNumber>;
|
||||
}, z.core.$strip>;
|
||||
export type LedgerQuery = z.infer<typeof ledgerQuerySchema>;
|
||||
export declare const ledgerPageSchema: z.ZodObject<{
|
||||
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
||||
total: z.ZodNumber;
|
||||
}, z.core.$strip>;
|
||||
export type LedgerPage = z.infer<typeof ledgerPageSchema>;
|
||||
/**
|
||||
* ① system —— 系统写:入站归一、流转记录、留痕。登记世界已发生的事实,不过放行门,
|
||||
* 写入正式版并**即时产生数据事件**。
|
||||
* ② draft —— 草稿写:任务级草稿层(读己之写:本任务可见、正式版不可见、**不产生数据事件**)。
|
||||
* ③ release —— 放行写:草稿层合并入正式版,**此刻才产生数据事件**。
|
||||
*/
|
||||
export declare const WRITE_KINDS: readonly ["system", "draft", "release"];
|
||||
export declare const writeKindSchema: z.ZodEnum<{
|
||||
draft: "draft";
|
||||
system: "system";
|
||||
release: "release";
|
||||
}>;
|
||||
export type WriteKind = z.infer<typeof writeKindSchema>;
|
||||
export declare const WRITE_KIND_LABEL: Readonly<Record<WriteKind, string>>;
|
||||
/** 三分的不变量,机检用:只有 draft 不抛数据事件 */
|
||||
export declare function emitsDataEvent(kind: WriteKind): boolean;
|
||||
/** 任务视图 = 正式版 + 本任务草稿层;环内推进读它,不依赖事件(OS 09) */
|
||||
export declare const taskViewRequestSchema: z.ZodObject<{
|
||||
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
query: z.ZodObject<{
|
||||
address: z.ZodObject<{
|
||||
object: z.ZodString;
|
||||
domain: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
where: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
||||
orderBy: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
field: z.ZodString;
|
||||
dir: z.ZodEnum<{
|
||||
desc: "desc";
|
||||
asc: "asc";
|
||||
}>;
|
||||
}, z.core.$strip>>>;
|
||||
limit: z.ZodDefault<z.ZodNumber>;
|
||||
offset: z.ZodDefault<z.ZodNumber>;
|
||||
}, z.core.$strip>;
|
||||
}, z.core.$strip>;
|
||||
export type TaskViewRequest = z.infer<typeof taskViewRequestSchema>;
|
||||
export declare const draftPatchSchema: z.ZodObject<{
|
||||
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
address: z.ZodObject<{
|
||||
object: z.ZodString;
|
||||
domain: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
key: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
||||
patch: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
tombstone: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
export type DraftPatch = z.infer<typeof draftPatchSchema>;
|
||||
/** 数据冲突检查(落地预检第五项):他单已改同一字段即预检不过(OS 7.3) */
|
||||
export declare const draftConflictSchema: z.ZodObject<{
|
||||
address: z.ZodObject<{
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
key: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
||||
field: z.ZodString;
|
||||
draftValue: z.ZodUnknown;
|
||||
officialValue: z.ZodUnknown;
|
||||
baselineValue: z.ZodUnknown;
|
||||
}, z.core.$strip>;
|
||||
export type DraftConflict = z.infer<typeof draftConflictSchema>;
|
||||
export declare const ACTION_INTENT_STATES: readonly ["drafted", "prechecked", "landed", "failed", "abandoned"];
|
||||
export declare const actionIntentStateSchema: z.ZodEnum<{
|
||||
failed: "failed";
|
||||
drafted: "drafted";
|
||||
prechecked: "prechecked";
|
||||
landed: "landed";
|
||||
abandoned: "abandoned";
|
||||
}>;
|
||||
export type ActionIntentState = z.infer<typeof actionIntentStateSchema>;
|
||||
export declare const actionIntentSchema: z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
||||
tool: z.ZodString;
|
||||
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
idempotencyKey: z.ZodString;
|
||||
state: z.ZodEnum<{
|
||||
failed: "failed";
|
||||
drafted: "drafted";
|
||||
prechecked: "prechecked";
|
||||
landed: "landed";
|
||||
abandoned: "abandoned";
|
||||
}>;
|
||||
label: z.ZodString;
|
||||
detail: z.ZodOptional<z.ZodString>;
|
||||
error: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type ActionIntent = z.infer<typeof actionIntentSchema>;
|
||||
+1263
File diff suppressed because it is too large
Load Diff
+176
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* 员工、岗位与权限(编码规范 §4 · `org`;语义出处 OS 02 员工管理)。
|
||||
*
|
||||
* 权限按岗位授予:客体三类(数据 域.对象[.字段] / 治理功能 / 任务)× 动作三种(读 / 写 / 治理)。
|
||||
* 任务负责人与被征答人对所涉内容**天然可见**,不另行授权。
|
||||
* 单组织、≤50 人:不做多租户,不引 OAuth/OIDC(编码规范 §4 鉴权定调)。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
export declare const positionSchema: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
code: z.ZodString;
|
||||
name: z.ZodString;
|
||||
note: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type Position = z.infer<typeof positionSchema>;
|
||||
export declare const STAFF_STATES: readonly ["active", "disabled"];
|
||||
export declare const staffStateSchema: z.ZodEnum<{
|
||||
active: "active";
|
||||
disabled: "disabled";
|
||||
}>;
|
||||
export type StaffState = z.infer<typeof staffStateSchema>;
|
||||
export declare const staffSchema: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
account: z.ZodString;
|
||||
name: z.ZodString;
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
state: z.ZodDefault<z.ZodEnum<{
|
||||
active: "active";
|
||||
disabled: "disabled";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
export type Staff = z.infer<typeof staffSchema>;
|
||||
export declare const GRANT_ACTIONS: readonly ["read", "write", "govern"];
|
||||
export declare const grantActionSchema: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
export type GrantAction = z.infer<typeof grantActionSchema>;
|
||||
export declare const GRANT_ACTION_LABEL: Readonly<Record<GrantAction, string>>;
|
||||
/** 治理台九功能 —— 授权客体之一 */
|
||||
export declare const GOVERNANCE_FUNCTIONS: readonly ["task", "staff", "process", "trigger", "activity", "tool", "data", "memory", "system"];
|
||||
export declare const governanceFunctionSchema: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
export type GovernanceFunction = z.infer<typeof governanceFunctionSchema>;
|
||||
export declare const GOVERNANCE_FUNCTION_LABEL: Readonly<Record<GovernanceFunction, string>>;
|
||||
export declare const grantObjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
export type GrantObject = z.infer<typeof grantObjectSchema>;
|
||||
export declare const grantSchema: z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
object: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
action: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
}, z.core.$strip>;
|
||||
export type Grant = z.infer<typeof grantSchema>;
|
||||
/** 员工停用前,其在途任务与待答卡须先改派完毕 */
|
||||
export declare const disableCheckSchema: z.ZodObject<{
|
||||
staffId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
blocked: z.ZodBoolean;
|
||||
openTasks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
taskId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
openCards: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
cardId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
openApprovals: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
approvalId: z.ZodString;
|
||||
title: z.ZodString;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
export type DisableCheck = z.infer<typeof disableCheckSchema>;
|
||||
export declare const sessionSchema: z.ZodObject<{
|
||||
staff: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
|
||||
account: z.ZodString;
|
||||
name: z.ZodString;
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
state: z.ZodDefault<z.ZodEnum<{
|
||||
active: "active";
|
||||
disabled: "disabled";
|
||||
}>>;
|
||||
}, z.core.$strip>;
|
||||
position: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
code: z.ZodString;
|
||||
name: z.ZodString;
|
||||
note: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
grants: z.ZodArray<z.ZodObject<{
|
||||
positionId: z.core.$ZodBranded<z.ZodString, "PositionId", "out">;
|
||||
object: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"data">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"governance">;
|
||||
function: z.ZodEnum<{
|
||||
data: "data";
|
||||
task: "task";
|
||||
trigger: "trigger";
|
||||
system: "system";
|
||||
tool: "tool";
|
||||
activity: "activity";
|
||||
staff: "staff";
|
||||
process: "process";
|
||||
memory: "memory";
|
||||
}>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"task">;
|
||||
activityId: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
action: z.ZodEnum<{
|
||||
read: "read";
|
||||
write: "write";
|
||||
govern: "govern";
|
||||
}>;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
export type Session = z.infer<typeof sessionSchema>;
|
||||
@@ -0,0 +1,548 @@
|
||||
/**
|
||||
* 流程包 DSL 与触发器配置(编码规范 §8.1;语义出处 OS 03)。
|
||||
*
|
||||
* 流程包 = 调用接口 + 两种活动(声明)+ 审批点 + 两种网关;工作流 = 其运行时实例。
|
||||
* 触发器与流程包**平级**:不入流程包结构、不随流程包版本,配置独立存放。
|
||||
*
|
||||
* 编排铁律:**连线即映射,画图即校验,不闭合不得发布** —— 存在未完成边、未满足必填
|
||||
* 或类型冲突的流程包可存草稿、不得发布。校验算法在 `process` 的 domain,本文件只定形状。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
export declare const OWNER_STRATEGIES: readonly ["assigned", "sole", "rotation", "follow-source"];
|
||||
export declare const ownerStrategySchema: z.ZodEnum<{
|
||||
assigned: "assigned";
|
||||
sole: "sole";
|
||||
rotation: "rotation";
|
||||
"follow-source": "follow-source";
|
||||
}>;
|
||||
export type OwnerStrategy = z.infer<typeof ownerStrategySchema>;
|
||||
export declare const OWNER_STRATEGY_LABEL: Readonly<Record<OwnerStrategy, string>>;
|
||||
export declare const ownerSpecSchema: z.ZodObject<{
|
||||
position: z.ZodString;
|
||||
strategy: z.ZodDefault<z.ZodEnum<{
|
||||
assigned: "assigned";
|
||||
sole: "sole";
|
||||
rotation: "rotation";
|
||||
"follow-source": "follow-source";
|
||||
}>>;
|
||||
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
|
||||
}, z.core.$strip>;
|
||||
export type OwnerSpec = z.infer<typeof ownerSpecSchema>;
|
||||
/**
|
||||
* 映射来源四类:上游输出口载荷字段 / 流程变量 / 起单载荷 / 常量;
|
||||
* 允许 S-FEEL 表达式做转换(与触发器字段映射同一形式)。
|
||||
*/
|
||||
export declare const mappingSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
export type MappingSource = z.infer<typeof mappingSourceSchema>;
|
||||
export declare const fieldMappingSchema: z.ZodObject<{
|
||||
target: z.ZodString;
|
||||
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
}, z.core.$strip>;
|
||||
export type FieldMapping = z.infer<typeof fieldMappingSchema>;
|
||||
export declare const edgeSchema: z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
from: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
to: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
condition: z.ZodOptional<z.ZodString>;
|
||||
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
target: z.ZodString;
|
||||
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
}, z.core.$strip>>>;
|
||||
label: z.ZodOptional<z.ZodString>;
|
||||
reopen: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
export type Edge = z.infer<typeof edgeSchema>;
|
||||
export declare const failureDispositionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"terminate">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"reroute">;
|
||||
edgeId: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"escalate">;
|
||||
approvalNodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"tolerate">;
|
||||
}, z.core.$strip>], "kind">;
|
||||
export type FailureDisposition = z.infer<typeof failureDispositionSchema>;
|
||||
export declare const FAILURE_DISPOSITION_LABEL: Readonly<Record<FailureDisposition['kind'], string>>;
|
||||
export declare const nudgeLadderSchema: z.ZodObject<{
|
||||
deadline: z.ZodString;
|
||||
steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
after: z.ZodString;
|
||||
action: z.ZodEnum<{
|
||||
nudge: "nudge";
|
||||
escalate: "escalate";
|
||||
}>;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>;
|
||||
export type NudgeLadder = z.infer<typeof nudgeLadderSchema>;
|
||||
export declare const GATEWAY_KINDS: readonly ["parallel", "exclusive"];
|
||||
export declare const gatewayKindSchema: z.ZodEnum<{
|
||||
parallel: "parallel";
|
||||
exclusive: "exclusive";
|
||||
}>;
|
||||
export type GatewayKind = z.infer<typeof gatewayKindSchema>;
|
||||
export declare const GATEWAY_KIND_LABEL: Readonly<Record<GatewayKind, string>>;
|
||||
export declare const processNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"start">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"end">;
|
||||
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"activity">;
|
||||
activityId: z.core.$ZodBranded<z.ZodString, "ActivityId", "out">;
|
||||
activityVersion: z.ZodOptional<z.ZodString>;
|
||||
owner: z.ZodObject<{
|
||||
position: z.ZodString;
|
||||
strategy: z.ZodDefault<z.ZodEnum<{
|
||||
assigned: "assigned";
|
||||
sole: "sole";
|
||||
rotation: "rotation";
|
||||
"follow-source": "follow-source";
|
||||
}>>;
|
||||
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
|
||||
}, z.core.$strip>;
|
||||
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"terminate">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"reroute">;
|
||||
edgeId: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"escalate">;
|
||||
approvalNodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"tolerate">;
|
||||
}, z.core.$strip>], "kind">>;
|
||||
message: z.ZodOptional<z.ZodString>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"approval">;
|
||||
approver: z.ZodObject<{
|
||||
position: z.ZodString;
|
||||
strategy: z.ZodDefault<z.ZodEnum<{
|
||||
assigned: "assigned";
|
||||
sole: "sole";
|
||||
rotation: "rotation";
|
||||
"follow-source": "follow-source";
|
||||
}>>;
|
||||
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
|
||||
}, z.core.$strip>;
|
||||
reject: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"reopen">;
|
||||
nodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
target: z.ZodString;
|
||||
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"terminate">;
|
||||
}, z.core.$strip>], "kind">;
|
||||
nudge: z.ZodOptional<z.ZodObject<{
|
||||
deadline: z.ZodString;
|
||||
steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
after: z.ZodString;
|
||||
action: z.ZodEnum<{
|
||||
nudge: "nudge";
|
||||
escalate: "escalate";
|
||||
}>;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>>;
|
||||
message: z.ZodOptional<z.ZodString>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"gateway">;
|
||||
gateway: z.ZodEnum<{
|
||||
parallel: "parallel";
|
||||
exclusive: "exclusive";
|
||||
}>;
|
||||
mode: z.ZodEnum<{
|
||||
join: "join";
|
||||
fork: "fork";
|
||||
}>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
export type ProcessNode = z.infer<typeof processNodeSchema>;
|
||||
export declare const callInterfaceSchema: z.ZodObject<{
|
||||
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
output: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
}, z.core.$strip>;
|
||||
export type CallInterface = z.infer<typeof callInterfaceSchema>;
|
||||
export declare const PROCESS_PACKAGE_STATES: readonly ["draft", "published", "retired"];
|
||||
export declare const processPackageStateSchema: z.ZodEnum<{
|
||||
draft: "draft";
|
||||
published: "published";
|
||||
retired: "retired";
|
||||
}>;
|
||||
export type ProcessPackageState = z.infer<typeof processPackageStateSchema>;
|
||||
export declare const processPackageSchema: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "ProcessPackageId", "out">;
|
||||
name: z.ZodString;
|
||||
version: z.ZodNumber;
|
||||
state: z.ZodEnum<{
|
||||
draft: "draft";
|
||||
published: "published";
|
||||
retired: "retired";
|
||||
}>;
|
||||
callInterface: z.ZodObject<{
|
||||
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
output: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
}, z.core.$strip>;
|
||||
nodes: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"start">;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"end">;
|
||||
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"activity">;
|
||||
activityId: z.core.$ZodBranded<z.ZodString, "ActivityId", "out">;
|
||||
activityVersion: z.ZodOptional<z.ZodString>;
|
||||
owner: z.ZodObject<{
|
||||
position: z.ZodString;
|
||||
strategy: z.ZodDefault<z.ZodEnum<{
|
||||
assigned: "assigned";
|
||||
sole: "sole";
|
||||
rotation: "rotation";
|
||||
"follow-source": "follow-source";
|
||||
}>>;
|
||||
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
|
||||
}, z.core.$strip>;
|
||||
failure: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"terminate">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"reroute">;
|
||||
edgeId: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"escalate">;
|
||||
approvalNodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"tolerate">;
|
||||
}, z.core.$strip>], "kind">>;
|
||||
message: z.ZodOptional<z.ZodString>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"approval">;
|
||||
approver: z.ZodObject<{
|
||||
position: z.ZodString;
|
||||
strategy: z.ZodDefault<z.ZodEnum<{
|
||||
assigned: "assigned";
|
||||
sole: "sole";
|
||||
rotation: "rotation";
|
||||
"follow-source": "follow-source";
|
||||
}>>;
|
||||
staffId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "StaffId", "out">>;
|
||||
}, z.core.$strip>;
|
||||
reject: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"reopen">;
|
||||
nodeId: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
target: z.ZodString;
|
||||
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"terminate">;
|
||||
}, z.core.$strip>], "kind">;
|
||||
nudge: z.ZodOptional<z.ZodObject<{
|
||||
deadline: z.ZodString;
|
||||
steps: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
after: z.ZodString;
|
||||
action: z.ZodEnum<{
|
||||
nudge: "nudge";
|
||||
escalate: "escalate";
|
||||
}>;
|
||||
}, z.core.$strip>>>;
|
||||
}, z.core.$strip>>;
|
||||
message: z.ZodOptional<z.ZodString>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"gateway">;
|
||||
gateway: z.ZodEnum<{
|
||||
parallel: "parallel";
|
||||
exclusive: "exclusive";
|
||||
}>;
|
||||
mode: z.ZodEnum<{
|
||||
join: "join";
|
||||
fork: "fork";
|
||||
}>;
|
||||
id: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
label: z.ZodString;
|
||||
layout: z.ZodOptional<z.ZodObject<{
|
||||
row: z.ZodNumber;
|
||||
col: z.ZodNumber;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>], "kind">>;
|
||||
edges: z.ZodArray<z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
from: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
to: z.core.$ZodBranded<z.ZodString, "NodeId", "out">;
|
||||
condition: z.ZodOptional<z.ZodString>;
|
||||
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
target: z.ZodString;
|
||||
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
}, z.core.$strip>>>;
|
||||
label: z.ZodOptional<z.ZodString>;
|
||||
reopen: z.ZodDefault<z.ZodBoolean>;
|
||||
}, z.core.$strip>>;
|
||||
variables: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
name: z.ZodString;
|
||||
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
||||
}, z.core.$strip>>>;
|
||||
description: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>;
|
||||
export type ProcessPackage = z.infer<typeof processPackageSchema>;
|
||||
export declare const CLOSURE_VIOLATION_KINDS: readonly ["edge-unmapped", "required-unmapped", "type-conflict", "dangling-node", "gateway-unbalanced", "join-ambiguous-source", "tolerate-required-dependency", "unknown-activity", "missing-owner-position"];
|
||||
export declare const closureViolationKindSchema: z.ZodEnum<{
|
||||
"edge-unmapped": "edge-unmapped";
|
||||
"required-unmapped": "required-unmapped";
|
||||
"type-conflict": "type-conflict";
|
||||
"dangling-node": "dangling-node";
|
||||
"gateway-unbalanced": "gateway-unbalanced";
|
||||
"join-ambiguous-source": "join-ambiguous-source";
|
||||
"tolerate-required-dependency": "tolerate-required-dependency";
|
||||
"unknown-activity": "unknown-activity";
|
||||
"missing-owner-position": "missing-owner-position";
|
||||
}>;
|
||||
export type ClosureViolationKind = z.infer<typeof closureViolationKindSchema>;
|
||||
export declare const closureViolationSchema: z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
"edge-unmapped": "edge-unmapped";
|
||||
"required-unmapped": "required-unmapped";
|
||||
"type-conflict": "type-conflict";
|
||||
"dangling-node": "dangling-node";
|
||||
"gateway-unbalanced": "gateway-unbalanced";
|
||||
"join-ambiguous-source": "join-ambiguous-source";
|
||||
"tolerate-required-dependency": "tolerate-required-dependency";
|
||||
"unknown-activity": "unknown-activity";
|
||||
"missing-owner-position": "missing-owner-position";
|
||||
}>;
|
||||
nodeId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "NodeId", "out">>;
|
||||
edgeId: z.ZodOptional<z.ZodString>;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
message: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
export type ClosureViolation = z.infer<typeof closureViolationSchema>;
|
||||
export declare const closureReportSchema: z.ZodObject<{
|
||||
publishable: z.ZodBoolean;
|
||||
violations: z.ZodArray<z.ZodObject<{
|
||||
kind: z.ZodEnum<{
|
||||
"edge-unmapped": "edge-unmapped";
|
||||
"required-unmapped": "required-unmapped";
|
||||
"type-conflict": "type-conflict";
|
||||
"dangling-node": "dangling-node";
|
||||
"gateway-unbalanced": "gateway-unbalanced";
|
||||
"join-ambiguous-source": "join-ambiguous-source";
|
||||
"tolerate-required-dependency": "tolerate-required-dependency";
|
||||
"unknown-activity": "unknown-activity";
|
||||
"missing-owner-position": "missing-owner-position";
|
||||
}>;
|
||||
nodeId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "NodeId", "out">>;
|
||||
edgeId: z.ZodOptional<z.ZodString>;
|
||||
field: z.ZodOptional<z.ZodString>;
|
||||
message: z.ZodString;
|
||||
}, z.core.$strip>>;
|
||||
}, z.core.$strip>;
|
||||
export type ClosureReport = z.infer<typeof closureReportSchema>;
|
||||
export declare const TRIGGER_KINDS: readonly ["periodic", "event", "registration"];
|
||||
export declare const triggerKindSchema: z.ZodEnum<{
|
||||
periodic: "periodic";
|
||||
event: "event";
|
||||
registration: "registration";
|
||||
}>;
|
||||
export type TriggerKind = z.infer<typeof triggerKindSchema>;
|
||||
export declare const TRIGGER_KIND_LABEL: Readonly<Record<TriggerKind, string>>;
|
||||
export declare const triggerConfigSchema: z.ZodObject<{
|
||||
id: z.core.$ZodBranded<z.ZodString, "TriggerId", "out">;
|
||||
name: z.ZodString;
|
||||
enabled: z.ZodDefault<z.ZodBoolean>;
|
||||
processPackageId: z.core.$ZodBranded<z.ZodString, "ProcessPackageId", "out">;
|
||||
mapping: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
||||
target: z.ZodString;
|
||||
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
from: z.ZodLiteral<"output-port">;
|
||||
port: z.ZodString;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"workflow-var">;
|
||||
name: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"initiation">;
|
||||
path: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"constant">;
|
||||
value: z.ZodUnknown;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
from: z.ZodLiteral<"expression">;
|
||||
sfeel: z.ZodString;
|
||||
}, z.core.$strip>], "from">;
|
||||
}, z.core.$strip>>>;
|
||||
spec: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
||||
kind: z.ZodLiteral<"periodic">;
|
||||
mode: z.ZodLiteral<"calendar">;
|
||||
calendar: z.ZodString;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"periodic">;
|
||||
mode: z.ZodLiteral<"data-calendar">;
|
||||
domain: z.ZodString;
|
||||
object: z.ZodString;
|
||||
dateField: z.ZodString;
|
||||
offset: z.ZodString;
|
||||
filter: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"event">;
|
||||
rule: z.ZodString;
|
||||
eventType: z.ZodDefault<z.ZodEnum<{
|
||||
human: "human";
|
||||
data: "data";
|
||||
time: "time";
|
||||
control: "control";
|
||||
}>>;
|
||||
}, z.core.$strip>, z.ZodObject<{
|
||||
kind: z.ZodLiteral<"registration">;
|
||||
formHint: z.ZodOptional<z.ZodString>;
|
||||
}, z.core.$strip>], "kind">;
|
||||
}, z.core.$strip>;
|
||||
export type TriggerConfig = z.infer<typeof triggerConfigSchema>;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 终态五名与非终态注记(编码规范 §8.1;语义出处 OS 4.3 / AM 1.3)。
|
||||
*
|
||||
* 终态由**系统**裁定,封闭枚举,活动与模型不得增删。
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
/** 终态五名 —— 唯一成功终态是 released(放行通过且落地收敛,输出口已发射) */
|
||||
export declare const TERMINAL_STATES: readonly ["released", "blocked", "stalled", "exhausted", "terminated"];
|
||||
export declare const terminalStateSchema: z.ZodEnum<{
|
||||
released: "released";
|
||||
blocked: "blocked";
|
||||
stalled: "stalled";
|
||||
exhausted: "exhausted";
|
||||
terminated: "terminated";
|
||||
}>;
|
||||
export type TerminalState = z.infer<typeof terminalStateSchema>;
|
||||
export declare const TERMINAL_STATE_LABEL: Readonly<Record<TerminalState, string>>;
|
||||
/** 触发者 —— OS 4.3 的第三列 */
|
||||
export declare const TERMINAL_STATE_TRIGGER: Readonly<Record<TerminalState, string>>;
|
||||
export declare function isSuccessTerminal(state: TerminalState): boolean;
|
||||
/** 驳回:放行卡的环内回转,任务继续 —— redo 按原要求重做 / revise 带意见迭代 */
|
||||
export declare const REJECTION_KINDS: readonly ["redo", "revise"];
|
||||
export declare const rejectionKindSchema: z.ZodEnum<{
|
||||
redo: "redo";
|
||||
revise: "revise";
|
||||
}>;
|
||||
export type RejectionKind = z.infer<typeof rejectionKindSchema>;
|
||||
export declare const REJECTION_KIND_LABEL: Readonly<Record<RejectionKind, string>>;
|
||||
/** 控制三语义(OS 06):暂停 = 可恢复冻结 · 叫停 = 负责人紧急中断 · 终止 = 不可恢复关闭 */
|
||||
export declare const CONTROL_SEMANTICS: readonly ["pause", "halt", "terminate"];
|
||||
export declare const controlSemanticSchema: z.ZodEnum<{
|
||||
pause: "pause";
|
||||
halt: "halt";
|
||||
terminate: "terminate";
|
||||
}>;
|
||||
export type ControlSemantic = z.infer<typeof controlSemanticSchema>;
|
||||
export declare const CONTROL_SEMANTIC_LABEL: Readonly<Record<ControlSemantic, string>>;
|
||||
/**
|
||||
* 任务运行态 —— 与终态分层:终态是收场名,运行态是「此刻在干嘛」。
|
||||
* landing-blocked(落地受阻)是运行态不是终态,处置后仍收敛于终态名录(OS 7.3)。
|
||||
*/
|
||||
export declare const TASK_RUNTIME_STATES: readonly ["running", "awaiting-human", "awaiting-event", "suspended", "landing-blocked", "terminal"];
|
||||
export declare const taskRuntimeStateSchema: z.ZodEnum<{
|
||||
running: "running";
|
||||
"awaiting-human": "awaiting-human";
|
||||
"awaiting-event": "awaiting-event";
|
||||
suspended: "suspended";
|
||||
"landing-blocked": "landing-blocked";
|
||||
terminal: "terminal";
|
||||
}>;
|
||||
export type TaskRuntimeState = z.infer<typeof taskRuntimeStateSchema>;
|
||||
export declare const TASK_RUNTIME_STATE_LABEL: Readonly<Record<TaskRuntimeState, string>>;
|
||||
export declare const WORKFLOW_STATES: readonly ["running", "waiting", "completed", "terminated", "abnormal"];
|
||||
export declare const workflowStateSchema: z.ZodEnum<{
|
||||
terminated: "terminated";
|
||||
running: "running";
|
||||
waiting: "waiting";
|
||||
completed: "completed";
|
||||
abnormal: "abnormal";
|
||||
}>;
|
||||
export type WorkflowState = z.infer<typeof workflowStateSchema>;
|
||||
export declare const WORKFLOW_STATE_LABEL: Readonly<Record<WorkflowState, string>>;
|
||||
export declare const ATTRIBUTION_SIDES: readonly ["machine", "human", "human-verdict", "world-wait"];
|
||||
export declare const attributionSideSchema: z.ZodEnum<{
|
||||
machine: "machine";
|
||||
human: "human";
|
||||
"human-verdict": "human-verdict";
|
||||
"world-wait": "world-wait";
|
||||
}>;
|
||||
export type AttributionSide = z.infer<typeof attributionSideSchema>;
|
||||
export declare const ATTRIBUTION_SIDE_LABEL: Readonly<Record<AttributionSide, string>>;
|
||||
export declare const ACCEPTANCE_LEVELS: readonly ["L1", "L2", "L3", "L4", "L5"];
|
||||
export declare const acceptanceLevelSchema: z.ZodEnum<{
|
||||
L1: "L1";
|
||||
L2: "L2";
|
||||
L3: "L3";
|
||||
L4: "L4";
|
||||
L5: "L5";
|
||||
}>;
|
||||
export type AcceptanceLevel = z.infer<typeof acceptanceLevelSchema>;
|
||||
export declare const ACCEPTANCE_LEVEL_LABEL: Readonly<Record<AcceptanceLevel, string>>;
|
||||
/** L1–L4 是质量关,L5 是责任关 —— 判据全绿只是可提交,完成只出自放行通过 */
|
||||
export declare function isResponsibilityGate(level: AcceptanceLevel): boolean;
|
||||
Reference in New Issue
Block a user