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,46 @@
|
||||
/**
|
||||
* module: event —— 对外类型(编码规范 §10.1)。
|
||||
*/
|
||||
import type { Delivery, Envelope, EnvelopeDraft, EventId, ListenerId, ListenerSpec, OwnershipResolution, PositionId, RegisteredListener, TaskId } from '@contracts';
|
||||
import type { InboundFacts, OutboundRef, OwnershipKeyRules } from './internal/domain/ownership.ts';
|
||||
import type { ConsumptionPlan } from './internal/domain/delivery.ts';
|
||||
export type { Delivery, Envelope, EnvelopeDraft, ListenerSpec, OwnershipResolution, RegisteredListener };
|
||||
export type { InboundFacts, OutboundRef, OwnershipKeyRules, ConsumptionPlan };
|
||||
export declare class ListenerDeadlineError extends Error {
|
||||
readonly detail: string;
|
||||
constructor(detail: string);
|
||||
}
|
||||
/** 发布结果 —— 三级消费的判定结果,ingest 路由据此回执 */
|
||||
export type PublishResult = {
|
||||
readonly eventId: EventId;
|
||||
readonly plan: ConsumptionPlan;
|
||||
};
|
||||
export type InboundResult = PublishResult & {
|
||||
readonly resolution: OwnershipResolution;
|
||||
};
|
||||
export type EventService = {
|
||||
/** 先持久后投递:信封落 sys.event 与入队在同一事务 */
|
||||
publish(draft: EnvelopeDraft): Promise<PublishResult>;
|
||||
/** 通道入站:归属解析 → 归一 → 抛数据事件 */
|
||||
ingestInbound(input: {
|
||||
readonly facts: InboundFacts;
|
||||
readonly rules: OwnershipKeyRules;
|
||||
readonly draft: EnvelopeDraft;
|
||||
}): Promise<InboundResult>;
|
||||
getEvent(id: EventId): Promise<Envelope | undefined>;
|
||||
listByTask(taskId: TaskId, limit?: number): Promise<Envelope[]>;
|
||||
/** 监听注册表 —— 时限必配,注册即校验 */
|
||||
registerListener(taskId: TaskId, spec: ListenerSpec): Promise<RegisteredListener>;
|
||||
cancelListener(id: ListenerId): Promise<void>;
|
||||
listListeners(taskId: TaskId): Promise<RegisteredListener[]>;
|
||||
/** 到期扫描:抛时间事件,按阶梯催办 */
|
||||
sweepExpiredListeners(): Promise<RegisteredListener[]>;
|
||||
/** 出站关联记录 —— 归属解析①③级的对表来源 */
|
||||
recordOutbound(ref: OutboundRef): Promise<void>;
|
||||
/** 消费幂等:事件 ID × 消费者;已消费返回 false */
|
||||
claimConsumption(eventId: EventId, consumer: string): Promise<boolean>;
|
||||
/** 投递失败回执:重试或入死信 */
|
||||
reportFailure(deliveryId: string, error: string): Promise<Delivery>;
|
||||
};
|
||||
/** 无主兜底的收件岗位 —— 由通道实例配置给出 */
|
||||
export type FallbackPosition = PositionId;
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* module: event —— 唯一出口。只做 re-export,不写逻辑(编码规范 §10.1)。
|
||||
*/
|
||||
export type { ConsumptionPlan, Delivery, Envelope, EnvelopeDraft, EventService, InboundFacts, InboundResult, ListenerSpec, OutboundRef, OwnershipKeyRules, OwnershipResolution, PublishResult, RegisteredListener, } from './contract.ts';
|
||||
export { ListenerDeadlineError } from './contract.ts';
|
||||
export type { Clock, ConditionEvaluator, EventStore, IdGenerator, MessageFallback, TriggerMatcher, } from './port.ts';
|
||||
export type { EventServiceDeps } from './internal/usecase/event-service.ts';
|
||||
export { createEventService } from './internal/usecase/event-service.ts';
|
||||
export type { RetryDecision, RetryPolicy } from './internal/domain/delivery.ts';
|
||||
export { consumptionKey, DEFAULT_RETRY, decideRetry, fanOutTargets, planConsumption, } from './internal/domain/delivery.ts';
|
||||
export { deadlineMillis, matchesFilter, matchesListener, matchingListeners, scopeOf } from './internal/domain/listener-match.ts';
|
||||
export { extractKeys, resolveOwnership } from './internal/domain/ownership.ts';
|
||||
export { claimPendingDeliveries, createEventStore } from './internal/adapter/event-store.ts';
|
||||
export { consumptionTable, deliveryTable, eventTable, listenerTable, outboundRefTable, } from './internal/adapter/event-schema.ts';
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* module: event —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
|
||||
*
|
||||
* 注意层级:event 是 L1,而任务(L6)、触发器(L7)、消息(L2)都在其上 —— 三级消费的
|
||||
* 三个下游一律以**端口**声明、由 app 装配注入,event 不反向依赖上层(§4 / §5.2)。
|
||||
*/
|
||||
import type { Delivery, Envelope, EventId, RegisteredListener, TaskId } from '@contracts';
|
||||
import type { OutboundRef } from './internal/domain/ownership.ts';
|
||||
import type { ConditionEvaluator } from './internal/domain/listener-match.ts';
|
||||
export type Clock = {
|
||||
now(): Date;
|
||||
};
|
||||
export type IdGenerator = {
|
||||
next(): string;
|
||||
};
|
||||
export type { ConditionEvaluator };
|
||||
/** 事件存储 —— 「先持久后投递」的底座 */
|
||||
export type EventStore = {
|
||||
/** 信封落库与入队同一事务 */
|
||||
persistAndEnqueue(envelope: Envelope, targets: readonly Delivery[]): Promise<void>;
|
||||
get(id: EventId): Promise<Envelope | undefined>;
|
||||
listByTask(taskId: TaskId, limit: number): Promise<Envelope[]>;
|
||||
listenersOf(taskId: TaskId): Promise<RegisteredListener[]>;
|
||||
/** 全部 armed 监听 —— 事件到达时的匹配面 */
|
||||
armedListeners(): Promise<RegisteredListener[]>;
|
||||
saveListener(listener: RegisteredListener): Promise<void>;
|
||||
setListenerState(id: string, state: RegisteredListener['state']): Promise<void>;
|
||||
expiredListeners(now: Date): Promise<RegisteredListener[]>;
|
||||
saveOutbound(ref: OutboundRef): Promise<void>;
|
||||
recentOutbound(sinceMs: number, now: Date): Promise<OutboundRef[]>;
|
||||
/** 消费幂等表:唯一约束成功返回 true,冲突返回 false */
|
||||
claimConsumption(eventId: EventId, consumer: string): Promise<boolean>;
|
||||
getDelivery(id: string): Promise<Delivery | undefined>;
|
||||
updateDelivery(delivery: Delivery): Promise<void>;
|
||||
scheduleRetry(deliveryId: string, delayMs: number): Promise<void>;
|
||||
};
|
||||
/** 触发器判定 —— app 注入 `trigger`(L7)的只读用例;返回命中的触发器 ID */
|
||||
export type TriggerMatcher = {
|
||||
match(envelope: Envelope): Promise<string[]>;
|
||||
};
|
||||
/** 死信与无主兜底 —— app 注入 `message`(L2) */
|
||||
export type MessageFallback = {
|
||||
deadLetter(envelope: Envelope, error: string): Promise<void>;
|
||||
unowned(envelope: Envelope, fallbackPosition: string | undefined): Promise<void>;
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* module: ledger —— 对外类型(编码规范 §10.1)。只有类型和常量,没有实现。
|
||||
*/
|
||||
import type { LedgerAddress, LedgerKey, LedgerPage, LedgerQuery, LedgerRow, ObjectDeclaration, TaskId, WriteKind } from '@contracts';
|
||||
import type { MaterializedObject, MergeConflict, MergeNotice, MergedObject } from './internal/domain/schema-merge.ts';
|
||||
import type { ConflictFinding } from './internal/domain/task-view.ts';
|
||||
export type { LedgerAddress, LedgerKey, LedgerPage, LedgerQuery, LedgerRow, ObjectDeclaration, WriteKind };
|
||||
export type { MaterializedObject, MergeConflict, MergeNotice, MergedObject, ConflictFinding };
|
||||
export declare class DraftConflictError extends Error {
|
||||
readonly findings: readonly ConflictFinding[];
|
||||
constructor(findings: readonly ConflictFinding[]);
|
||||
}
|
||||
export declare class SchemaConflictError extends Error {
|
||||
readonly conflicts: readonly MergeConflict[];
|
||||
constructor(conflicts: readonly MergeConflict[]);
|
||||
}
|
||||
export declare class ObjectNotMaterializedError extends Error {
|
||||
readonly address: string;
|
||||
constructor(address: string);
|
||||
}
|
||||
/** 声明合并与物化的结果 —— 安装静态审读它:conflicts 非空即不上架 */
|
||||
export type SchemaApplyResult = {
|
||||
readonly merged: MergedObject | undefined;
|
||||
readonly notices: readonly MergeNotice[];
|
||||
readonly conflicts: readonly MergeConflict[];
|
||||
readonly applied: boolean;
|
||||
};
|
||||
export type ObjectAddress = {
|
||||
readonly domain: string;
|
||||
readonly object: string;
|
||||
};
|
||||
export type SystemWrite = {
|
||||
readonly address: ObjectAddress;
|
||||
readonly key: LedgerKey;
|
||||
readonly values: LedgerRow;
|
||||
/** 归因:哪条入站 / 哪次流转产生了这次系统写 */
|
||||
readonly cause: {
|
||||
readonly kind: 'inbound' | 'engine' | 'governance';
|
||||
readonly ref: string;
|
||||
};
|
||||
/** 系统写也可挂到任务上(入站归一到某任务),数据事件的目标即它 */
|
||||
readonly taskId?: TaskId;
|
||||
};
|
||||
export type DraftWrite = {
|
||||
readonly taskId: TaskId;
|
||||
readonly address: ObjectAddress;
|
||||
readonly key: LedgerKey;
|
||||
readonly patch: LedgerRow;
|
||||
readonly tombstone?: boolean;
|
||||
};
|
||||
export type ReleaseWriteResult = {
|
||||
readonly mergedRows: number;
|
||||
readonly emittedEvents: number;
|
||||
};
|
||||
/**
|
||||
* 写三分是**三个不同方法**,不是一个带 flag 的方法 —— 调用方拿不到「绕门」的形态(§7.2)。
|
||||
* systemWrite —— 登记世界已发生的事实,不过放行门,写正式版并**即时**抛数据事件
|
||||
* draftWrite —— 任务级草稿层,读己之写,**不抛**事件
|
||||
* releaseWrite —— 放行通过,草稿合并入正式版,**此刻**抛数据事件;原子且过冲突检查
|
||||
*/
|
||||
export type LedgerService = {
|
||||
applyDeclarations(declarations: readonly ObjectDeclaration[]): Promise<SchemaApplyResult[]>;
|
||||
describe(address: ObjectAddress): Promise<MaterializedObject | undefined>;
|
||||
listObjects(): Promise<ObjectAddress[]>;
|
||||
systemWrite(write: SystemWrite): Promise<void>;
|
||||
draftWrite(write: DraftWrite): Promise<void>;
|
||||
releaseWrite(taskId: TaskId): Promise<ReleaseWriteResult>;
|
||||
/** 正式版查询 —— 跨任务只见过门的事实 */
|
||||
query(query: LedgerQuery): Promise<LedgerPage>;
|
||||
/** 任务视图 = 正式版 + 本任务草稿层 */
|
||||
taskView(taskId: TaskId, query: LedgerQuery): Promise<LedgerPage>;
|
||||
/** 落地预检第五项:数据冲突检查 */
|
||||
checkConflicts(taskId: TaskId): Promise<ConflictFinding[]>;
|
||||
discardDrafts(taskId: TaskId): Promise<void>;
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* module: ledger —— 唯一出口。只做 re-export,不写逻辑(编码规范 §10.1)。
|
||||
*/
|
||||
export type { ConflictFinding, DraftWrite, LedgerAddress, LedgerKey, LedgerPage, LedgerQuery, LedgerRow, LedgerService, MaterializedObject, MergeConflict, MergeNotice, MergedObject, ObjectAddress, ObjectDeclaration, ReleaseWriteResult, SchemaApplyResult, SystemWrite, WriteKind, } from './contract.ts';
|
||||
export { DraftConflictError, ObjectNotMaterializedError, SchemaConflictError } from './contract.ts';
|
||||
export type { Clock, DraftStore, EventPublisher, IdGenerator, LedgerStore, ObjectRef } from './port.ts';
|
||||
export type { LedgerServiceDeps } from './internal/usecase/ledger-service.ts';
|
||||
export { createLedgerService } from './internal/usecase/ledger-service.ts';
|
||||
export type { MergedField, SchemaChange, SchemaPlan, WidenResult, } from './internal/domain/schema-merge.ts';
|
||||
export { mergeDeclarations, planIsNonDestructive, planSchemaChanges, widen, } from './internal/domain/schema-merge.ts';
|
||||
export type { DraftEntry } from './internal/domain/task-view.ts';
|
||||
export { detectConflicts, keyOf, overlay, pickKey } from './internal/domain/task-view.ts';
|
||||
export { createDraftStore, createLedgerStore, DRAFT_DDL, DRAFT_TABLE, tableNameOf } from './internal/adapter/ledger-store.ts';
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* module: ledger —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
|
||||
*/
|
||||
import type { EnvelopeDraft, LedgerKey, LedgerQuery, LedgerRow } from '@contracts';
|
||||
import type { MaterializedObject, SchemaChange } from './internal/domain/schema-merge.ts';
|
||||
import type { DraftEntry } from './internal/domain/task-view.ts';
|
||||
export type Clock = {
|
||||
now(): Date;
|
||||
};
|
||||
export type IdGenerator = {
|
||||
next(): string;
|
||||
};
|
||||
/** 数据事件的发射口 —— app 注入 `event` 模块的出口(§5.2) */
|
||||
export type EventPublisher = {
|
||||
publish(envelope: EnvelopeDraft): Promise<void>;
|
||||
};
|
||||
export type ObjectRef = {
|
||||
readonly domain: string;
|
||||
readonly object: string;
|
||||
};
|
||||
/**
|
||||
* 台账存储 —— 运行时 DDL / DML 由声明生成,ORM 静态 schema 不适用,
|
||||
* 一律 node-postgres 直写(§1 / ADR-002)。
|
||||
*/
|
||||
export type LedgerStore = {
|
||||
/** 已物化对象的列与主键;未物化返回 undefined */
|
||||
describe(ref: ObjectRef): Promise<MaterializedObject | undefined>;
|
||||
listObjects(): Promise<ObjectRef[]>;
|
||||
/** 执行「只增不破坏」的变更计划 */
|
||||
applyChanges(ref: ObjectRef, changes: readonly SchemaChange[]): Promise<void>;
|
||||
select(query: LedgerQuery): Promise<{
|
||||
rows: LedgerRow[];
|
||||
total: number;
|
||||
}>;
|
||||
selectByKeys(ref: ObjectRef, keys: readonly LedgerKey[]): Promise<LedgerRow[]>;
|
||||
upsert(ref: ObjectRef, key: LedgerKey, values: LedgerRow): Promise<void>;
|
||||
deleteRow(ref: ObjectRef, key: LedgerKey): Promise<void>;
|
||||
/** 放行写的原子性:草稿合并与事件登记同一事务 */
|
||||
transaction<T>(fn: (store: LedgerStore, drafts: DraftStore) => Promise<T>): Promise<T>;
|
||||
};
|
||||
/** 任务级草稿层 —— 推荐形态 ledger.__draft;物理形态可换,功能约束不可变(§7.2) */
|
||||
export type DraftStore = {
|
||||
list(taskId: string): Promise<Array<DraftEntry & ObjectRef>>;
|
||||
listForObject(taskId: string, ref: ObjectRef): Promise<DraftEntry[]>;
|
||||
put(taskId: string, ref: ObjectRef, entry: DraftEntry): Promise<void>;
|
||||
clear(taskId: string): Promise<void>;
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* module: llm —— 对外类型(编码规范 §10.1)。
|
||||
*
|
||||
* 两条缝之一(§7.3):`ModelGateway` 支持 record | replay | live 三模式 ——
|
||||
* **任何模型调用不经 ModelGateway,回放审就对它失明**(§12.5#10)。
|
||||
*/
|
||||
import type { LlmInstanceView, LlmProvider, TaskId } from '@contracts';
|
||||
import type { ModelBinding, BindingViolation } from './internal/domain/model-binding.ts';
|
||||
export type { LlmInstanceView, LlmProvider, ModelBinding, BindingViolation };
|
||||
/** 一条缝的三个开关位 */
|
||||
export declare const GATEWAY_MODES: readonly ["live", "record", "replay"];
|
||||
export type GatewayMode = (typeof GATEWAY_MODES)[number];
|
||||
export declare class ModelNotBoundError extends Error {
|
||||
readonly modelName: string;
|
||||
readonly violations: readonly BindingViolation[];
|
||||
constructor(modelName: string, violations: readonly BindingViolation[]);
|
||||
}
|
||||
export declare class ModelDisabledError extends Error {
|
||||
readonly modelName: string;
|
||||
constructor(modelName: string);
|
||||
}
|
||||
export declare class ReplayMissError extends Error {
|
||||
readonly key: string;
|
||||
constructor(key: string);
|
||||
}
|
||||
/** 模型调用的语义入参 —— 录制的就是它,不含任何凭证(ADR-009 #5) */
|
||||
export type ModelCall = {
|
||||
/** 活动声明的自定义模型名(逻辑名) */
|
||||
readonly model: string;
|
||||
readonly system?: string;
|
||||
readonly prompt: string;
|
||||
readonly temperature?: number;
|
||||
readonly maxOutputTokens?: number;
|
||||
/** 出参 schema(JSON Schema);给定即要求结构化出参并校验 */
|
||||
readonly outputSchema?: Record<string, unknown>;
|
||||
/** 录制/回放的定位:任务 × 步序号(§7.3) */
|
||||
readonly taskId?: TaskId;
|
||||
readonly stepNo?: number;
|
||||
/** 归因用:调用点标签(flow 步名 / loop 回合 / 系统用途) */
|
||||
readonly label?: string;
|
||||
};
|
||||
export type ModelUsage = {
|
||||
readonly inputTokens: number;
|
||||
readonly outputTokens: number;
|
||||
readonly latencyMs: number;
|
||||
};
|
||||
export type ModelResult = {
|
||||
readonly text: string;
|
||||
/** outputSchema 给定时的解析结果 */
|
||||
readonly object?: unknown;
|
||||
readonly usage: ModelUsage;
|
||||
/** 行为可归因:模型与版本记入留痕(OS 4.1) */
|
||||
readonly binding: {
|
||||
readonly name: string;
|
||||
readonly provider: LlmProvider;
|
||||
readonly model: string;
|
||||
};
|
||||
readonly mode: GatewayMode;
|
||||
};
|
||||
/**
|
||||
* 模型网关 —— 活动基座六件里的「LLM 调用」。
|
||||
* 活动只见自定义模型名;解析、凭证、录制回放全在此。
|
||||
*/
|
||||
export type ModelGateway = {
|
||||
readonly mode: GatewayMode;
|
||||
generate(call: ModelCall): Promise<ModelResult>;
|
||||
/** 换模式的网关 —— 回放审用 replay 模式重跑引擎(§7.3) */
|
||||
withMode(mode: GatewayMode): ModelGateway;
|
||||
};
|
||||
export type UpsertLlmInstance = {
|
||||
readonly id?: string | undefined;
|
||||
readonly name: string;
|
||||
readonly provider: LlmProvider;
|
||||
readonly baseUrl: string;
|
||||
readonly model: string;
|
||||
/** 只写不读:留空表示保持原值 */
|
||||
readonly apiKey?: string | undefined;
|
||||
readonly systemUse: boolean;
|
||||
readonly enabled: boolean;
|
||||
};
|
||||
export type LlmService = {
|
||||
list(): Promise<LlmInstanceView[]>;
|
||||
upsert(input: UpsertLlmInstance): Promise<LlmInstanceView>;
|
||||
remove(id: string): Promise<void>;
|
||||
/** 连通性探针 —— 治理台「测试连接」 */
|
||||
probe(id: string): Promise<{
|
||||
ok: boolean;
|
||||
latencyMs?: number;
|
||||
error?: string;
|
||||
}>;
|
||||
/** 安装静态审:核对活动声明的模型名已绑定(AM 11.3) */
|
||||
assertNamesBound(names: readonly string[]): Promise<{
|
||||
ok: boolean;
|
||||
missing: string[];
|
||||
}>;
|
||||
/** 系统用途模型 —— 叙述性小结 / 汇报生成 / 蒸馏钩子 */
|
||||
systemUseBinding(): Promise<ModelBinding | undefined>;
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* module: llm —— 唯一出口。只做 re-export,不写逻辑(编码规范 §10.1)。
|
||||
*/
|
||||
export type { BindingViolation, GatewayMode, LlmInstanceView, LlmProvider, LlmService, ModelBinding, ModelCall, ModelGateway, ModelResult, ModelUsage, UpsertLlmInstance, } from './contract.ts';
|
||||
export { GATEWAY_MODES, ModelDisabledError, ModelNotBoundError, ReplayMissError } from './contract.ts';
|
||||
export type { Clock, IdGenerator, LlmInstanceRepository, ProviderInvoker, ReplayRecord, ReplayStore, SecretBox, } from './port.ts';
|
||||
export type { LlmServiceDeps } from './internal/usecase/llm-service.ts';
|
||||
export { createLlmService } from './internal/usecase/llm-service.ts';
|
||||
export type { ModelGatewayDeps } from './internal/usecase/model-gateway.ts';
|
||||
export { createModelGateway } from './internal/usecase/model-gateway.ts';
|
||||
export { isBound, pickSystemUse, toPublicView, validateBinding } from './internal/domain/model-binding.ts';
|
||||
export { callFingerprint, replayKey, stableStringify } from './internal/domain/replay-key.ts';
|
||||
export { createLlmInstanceRepository, createReplayStore } from './internal/adapter/llm-repository.ts';
|
||||
export { createProviderInvoker, parseJsonLoose } from './internal/adapter/ai-sdk-provider.ts';
|
||||
export { llmInstanceTable, replayModelTable } from './internal/adapter/llm-schema.ts';
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* module: llm —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
|
||||
*/
|
||||
import type { ModelBinding } from './internal/domain/model-binding.ts';
|
||||
import type { ModelCall, ModelResult, ModelUsage } from './contract.ts';
|
||||
export type Clock = {
|
||||
now(): Date;
|
||||
};
|
||||
export type IdGenerator = {
|
||||
next(): string;
|
||||
};
|
||||
/** 凭证密封 —— 明文永不进 domain(ADR-009) */
|
||||
export type SecretBox = {
|
||||
seal(plaintext: string): string;
|
||||
open(cipher: string): string;
|
||||
};
|
||||
export type LlmInstanceRepository = {
|
||||
list(): Promise<ModelBinding[]>;
|
||||
findByName(name: string): Promise<ModelBinding | undefined>;
|
||||
findById(id: string): Promise<ModelBinding | undefined>;
|
||||
upsert(binding: ModelBinding): Promise<ModelBinding>;
|
||||
remove(id: string): Promise<void>;
|
||||
};
|
||||
/** 录制回放存储:按任务 × 步序号(§7.3) */
|
||||
export type ReplayRecord = {
|
||||
readonly key: string;
|
||||
readonly call: ModelCall;
|
||||
readonly result: {
|
||||
readonly text: string;
|
||||
readonly object?: unknown;
|
||||
readonly usage: ModelUsage;
|
||||
};
|
||||
readonly recordedAt: Date;
|
||||
};
|
||||
export type ReplayStore = {
|
||||
put(record: ReplayRecord): Promise<void>;
|
||||
get(key: string): Promise<ReplayRecord | undefined>;
|
||||
};
|
||||
/**
|
||||
* Provider 工厂 —— Vercel AI SDK 只准出现在 adapter(§6.2 / §11.4)。
|
||||
* usecase 只见本端口,拿不到任何 SDK 类型。
|
||||
*/
|
||||
export type ProviderInvoker = {
|
||||
invoke(input: {
|
||||
readonly binding: ModelBinding;
|
||||
readonly apiKey: string;
|
||||
readonly call: ModelCall;
|
||||
}): Promise<{
|
||||
text: string;
|
||||
object?: unknown;
|
||||
usage: ModelUsage;
|
||||
}>;
|
||||
};
|
||||
export type { ModelCall, ModelResult };
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* module: org —— 对外类型(编码规范 §10.1)。只有类型和常量,没有实现。
|
||||
*/
|
||||
import type { DisableCheck, Grant, GrantAction, GrantObject, Position, Session, Staff, StaffId } from '@contracts';
|
||||
export type { DisableCheck, Grant, GrantAction, GrantObject, Position, Session, Staff };
|
||||
/** 员工连同其岗位的读模型 —— 治理台员工管理列表用 */
|
||||
export type StaffWithPosition = Staff & {
|
||||
readonly position: Position;
|
||||
};
|
||||
export type CreateStaffInput = {
|
||||
readonly account: string;
|
||||
readonly name: string;
|
||||
readonly positionId: string;
|
||||
};
|
||||
export declare class StaffNotFoundError extends Error {
|
||||
readonly staffId: StaffId;
|
||||
constructor(staffId: StaffId);
|
||||
}
|
||||
export declare class PositionNotFoundError extends Error {
|
||||
readonly positionCode: string;
|
||||
constructor(positionCode: string);
|
||||
}
|
||||
export declare class AccountTakenError extends Error {
|
||||
readonly account: string;
|
||||
constructor(account: string);
|
||||
}
|
||||
/** 停用前置检查未过:在途任务与待答卡须先改派完毕(OS 02) */
|
||||
export declare class DisableBlockedError extends Error {
|
||||
readonly check: DisableCheck;
|
||||
constructor(check: DisableCheck);
|
||||
}
|
||||
export type OrgService = {
|
||||
listStaff(): Promise<{
|
||||
staff: StaffWithPosition[];
|
||||
positions: Position[];
|
||||
}>;
|
||||
getStaff(staffId: StaffId): Promise<StaffWithPosition>;
|
||||
findByAccount(account: string): Promise<StaffWithPosition | undefined>;
|
||||
createStaff(input: CreateStaffInput): Promise<Staff>;
|
||||
/** 停用前置检查 —— 只读,治理台先看再点 */
|
||||
checkDisable(staffId: StaffId): Promise<DisableCheck>;
|
||||
/** 停用 —— 前置检查不过即抛 DisableBlockedError,不做部分执行 */
|
||||
disableStaff(staffId: StaffId): Promise<void>;
|
||||
listGrants(positionId: string): Promise<Grant[]>;
|
||||
setGrants(positionId: string, grants: readonly Grant[]): Promise<Grant[]>;
|
||||
/** 岗位权限校验 —— app 层鉴权中间件读它 */
|
||||
authorize(staffId: StaffId, object: GrantObject, action: GrantAction): Promise<boolean>;
|
||||
loadSession(account: string): Promise<Session | undefined>;
|
||||
/** 岗位在岗人员 —— 负责人四策略解析的候选集来源(由 process 调用) */
|
||||
staffOfPosition(positionCode: string): Promise<StaffWithPosition[]>;
|
||||
ensureSeeded(): Promise<void>;
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* module: org —— 唯一出口。只做 re-export,不写逻辑(编码规范 §10.1)。
|
||||
*/
|
||||
export type { CreateStaffInput, DisableCheck, Grant, GrantAction, GrantObject, OrgService, Position, Session, Staff, StaffWithPosition, } from './contract.ts';
|
||||
export { AccountTakenError, DisableBlockedError, PositionNotFoundError, StaffNotFoundError, } from './contract.ts';
|
||||
export type { Clock, GrantRepository, IdGenerator, InFlightWorkProbe, PositionRepository, StaffRepository, } from './port.ts';
|
||||
export type { OrgServiceDeps } from './internal/usecase/org-service.ts';
|
||||
export { createOrgService } from './internal/usecase/org-service.ts';
|
||||
export { isAuthorized, actionCovers, objectCovers } from './internal/domain/authorization.ts';
|
||||
export { DEFAULT_LOGIN_ACCOUNT, POSITION_SEED, STAFF_SEED } from './internal/domain/seed-data.ts';
|
||||
export { createGrantRepository, createPositionRepository, createStaffRepository, objectKeyOf, } from './internal/adapter/org-repository.ts';
|
||||
export { grantTable, positionTable, staffTable } from './internal/adapter/org-schema.ts';
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* module: org —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
|
||||
* adapter 实现之,usecase 依赖之,app 装配之。
|
||||
*/
|
||||
import type { Grant, Position, PositionId, Staff, StaffId } from '@contracts';
|
||||
export type Clock = {
|
||||
now(): Date;
|
||||
};
|
||||
export type PositionRepository = {
|
||||
list(): Promise<Position[]>;
|
||||
findByCode(code: string): Promise<Position | undefined>;
|
||||
findById(id: PositionId): Promise<Position | undefined>;
|
||||
upsert(position: Omit<Position, 'id'> & {
|
||||
id?: PositionId;
|
||||
}): Promise<Position>;
|
||||
};
|
||||
export type StaffRepository = {
|
||||
list(): Promise<Staff[]>;
|
||||
findById(id: StaffId): Promise<Staff | undefined>;
|
||||
findByAccount(account: string): Promise<Staff | undefined>;
|
||||
listByPosition(positionId: PositionId): Promise<Staff[]>;
|
||||
insert(staff: Staff): Promise<Staff>;
|
||||
setState(id: StaffId, state: Staff['state']): Promise<void>;
|
||||
};
|
||||
export type GrantRepository = {
|
||||
listByPosition(positionId: PositionId): Promise<Grant[]>;
|
||||
replaceForPosition(positionId: PositionId, grants: readonly Grant[]): Promise<Grant[]>;
|
||||
};
|
||||
/**
|
||||
* 在途工作探针 —— 停用前置检查要问的是 L6 `task` 与 L3 `human-tool`,
|
||||
* 二者层级高于 org,故一律经本端口由 app 注入(编码规范 §5.2 同层/跨层协作规矩)。
|
||||
*/
|
||||
export type InFlightWorkProbe = {
|
||||
openTasksOf(staffId: StaffId): Promise<Array<{
|
||||
taskId: string;
|
||||
title: string;
|
||||
}>>;
|
||||
openCardsOf(staffId: StaffId): Promise<Array<{
|
||||
cardId: string;
|
||||
title: string;
|
||||
}>>;
|
||||
openApprovalsOf(staffId: StaffId): Promise<Array<{
|
||||
approvalId: string;
|
||||
title: string;
|
||||
}>>;
|
||||
};
|
||||
/** ID 生成 —— domain 零随机(§5.3) */
|
||||
export type IdGenerator = {
|
||||
next(): string;
|
||||
};
|
||||
@@ -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