编排层③:活动装入/换版入口 —— 开发完能装进来,不必跑种子

此前活动只能靠 seed 装入,治理台没有任何入口 —— 这是「逐个开发活动」的拦路石。
补 POST /api/gov/activities(无代码通道:交清单 + .js 产物,都是数据),
两审在服务端跑;不过审按发布门同样的式样回 412 + ApiError.detail 带审计结论
(直接回业务体的话类型化客户端拿不到详情)。活动库给「装入 / 换版」卡:选文件或粘贴两份。
实测:0.1.0 → 0.2.0 版本并存;声明未注册的工具即 412 并点名到工具。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
2026-07-28 10:01:25 +08:00
co-authored by Claude Fable 5
parent c8cfd61929
commit 5619d86ce4
4 changed files with 644 additions and 2 deletions
+392
View File
@@ -1531,6 +1531,398 @@ export declare const saveWorkGroupRoute: {
}, z.core.$strip>;
}, z.core.$strip>;
};
/**
* 经安装通道装入活动包 —— **无代码通道**(ADR-004):交的是清单 + .js 产物,都是数据。
*
* 安装两审在服务端跑:静态审读清单(工具契约在否、模型名绑没绑、模版有没有脚本、
* 声明与已物化的台账冲不冲),回放审重演历史(首装无历史即免,以样例集替代)。
* **恒为新增、版本并存**:装入不覆盖旧版本,在途任务按其启动时版本跑完。
*/
export declare const installActivityRoute: {
readonly method: "POST";
readonly path: "/api/gov/activities";
readonly body: z.ZodObject<{
manifest: z.ZodObject<{
identity: z.ZodObject<{
activityId: z.core.$ZodBranded<z.ZodString, "ActivityId", "out">;
name: z.ZodString;
packageVersion: z.ZodString;
category: z.ZodString;
paradigm: z.ZodEnum<{
loop: "loop";
flow: "flow";
}>;
sdkVersion: z.ZodString;
checksum: z.ZodString;
signature: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
contract: 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>;
declarations: z.ZodObject<{
models: z.ZodDefault<z.ZodArray<z.ZodString>>;
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
version: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>>;
ledger: z.ZodDefault<z.ZodArray<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>>>;
listeners: z.ZodDefault<z.ZodArray<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>>>;
harness: z.ZodObject<{
memoryWindow: z.ZodDefault<z.ZodNumber>;
stallAfter: z.ZodDefault<z.ZodString>;
nudge: z.ZodDefault<z.ZodArray<z.ZodObject<{
after: z.ZodString;
action: z.ZodEnum<{
nudge: "nudge";
escalate: "escalate";
}>;
}, z.core.$strip>>>;
retry: z.ZodDefault<z.ZodObject<{
times: z.ZodDefault<z.ZodNumber>;
backoff: z.ZodDefault<z.ZodString>;
}, z.core.$strip>>;
}, z.core.$strip>;
}, z.core.$strip>;
assets: z.ZodObject<{
businessModel: z.ZodDiscriminatedUnion<[z.ZodObject<{
paradigm: z.ZodLiteral<"loop">;
cmmnXml: z.ZodString;
narrative: z.ZodString;
dmn: z.ZodObject<{
drd: z.ZodArray<z.ZodObject<{
decision: z.ZodString;
requires: z.ZodDefault<z.ZodArray<z.ZodString>>;
inputs: z.ZodDefault<z.ZodArray<z.ZodString>>;
}, z.core.$strip>>;
tables: z.ZodArray<z.ZodObject<{
id: z.ZodString;
label: z.ZodString;
hitPolicy: z.ZodDefault<z.ZodEnum<{
UNIQUE: "UNIQUE";
FIRST: "FIRST";
PRIORITY: "PRIORITY";
COLLECT: "COLLECT";
}>>;
inputs: z.ZodArray<z.ZodObject<{
name: z.ZodString;
expression: z.ZodString;
}, z.core.$strip>>;
outputs: z.ZodArray<z.ZodObject<{
name: z.ZodString;
}, z.core.$strip>>;
rules: z.ZodArray<z.ZodObject<{
id: z.ZodString;
when: z.ZodArray<z.ZodString>;
then: z.ZodArray<z.ZodUnknown>;
annotation: z.ZodOptional<z.ZodString>;
}, z.core.$strip>>;
}, z.core.$strip>>;
}, z.core.$strip>;
}, z.core.$strip>, z.ZodObject<{
paradigm: z.ZodLiteral<"flow">;
steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"tool">;
tool: z.ZodString;
name: z.ZodString;
label: z.ZodString;
input: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
output: z.ZodOptional<z.ZodObject<{
domain: z.ZodString;
object: z.ZodString;
key: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
fields: z.ZodRecord<z.ZodString, z.ZodString>;
}, z.core.$strip>>;
when: z.ZodOptional<z.ZodString>;
view: z.ZodOptional<z.ZodString>;
failure: z.ZodObject<{
retry: z.ZodObject<{
times: z.ZodNumber;
backoff: z.ZodString;
}, z.core.$strip>;
fallback: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"human">;
workOrder: z.ZodEnum<{
execution: "execution";
acceptance: "acceptance";
}>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"blocked">;
}, z.core.$strip>], "kind">;
}, z.core.$strip>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"llm">;
model: z.ZodString;
template: z.ZodString;
outputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
name: z.ZodString;
label: z.ZodString;
input: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
output: z.ZodOptional<z.ZodObject<{
domain: z.ZodString;
object: z.ZodString;
key: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
fields: z.ZodRecord<z.ZodString, z.ZodString>;
}, z.core.$strip>>;
when: z.ZodOptional<z.ZodString>;
view: z.ZodOptional<z.ZodString>;
failure: z.ZodObject<{
retry: z.ZodObject<{
times: z.ZodNumber;
backoff: z.ZodString;
}, z.core.$strip>;
fallback: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"human">;
workOrder: z.ZodEnum<{
execution: "execution";
acceptance: "acceptance";
}>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"blocked">;
}, z.core.$strip>], "kind">;
}, z.core.$strip>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"human">;
workOrder: z.ZodEnum<{
execution: "execution";
acceptance: "acceptance";
}>;
card: z.ZodRecord<z.ZodString, z.ZodUnknown>;
deadline: z.ZodString;
name: z.ZodString;
label: z.ZodString;
input: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
output: z.ZodOptional<z.ZodObject<{
domain: z.ZodString;
object: z.ZodString;
key: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
fields: z.ZodRecord<z.ZodString, z.ZodString>;
}, z.core.$strip>>;
when: z.ZodOptional<z.ZodString>;
view: z.ZodOptional<z.ZodString>;
failure: z.ZodObject<{
retry: z.ZodObject<{
times: z.ZodNumber;
backoff: z.ZodString;
}, z.core.$strip>;
fallback: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"human">;
workOrder: z.ZodEnum<{
execution: "execution";
acceptance: "acceptance";
}>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"blocked">;
}, z.core.$strip>], "kind">;
}, z.core.$strip>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"pure-tool">;
tool: z.ZodString;
name: z.ZodString;
label: z.ZodString;
input: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
output: z.ZodOptional<z.ZodObject<{
domain: z.ZodString;
object: z.ZodString;
key: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
fields: z.ZodRecord<z.ZodString, z.ZodString>;
}, z.core.$strip>>;
when: z.ZodOptional<z.ZodString>;
view: z.ZodOptional<z.ZodString>;
failure: z.ZodObject<{
retry: z.ZodObject<{
times: z.ZodNumber;
backoff: z.ZodString;
}, z.core.$strip>;
fallback: z.ZodDiscriminatedUnion<[z.ZodObject<{
kind: z.ZodLiteral<"human">;
workOrder: z.ZodEnum<{
execution: "execution";
acceptance: "acceptance";
}>;
}, z.core.$strip>, z.ZodObject<{
kind: z.ZodLiteral<"blocked">;
}, z.core.$strip>], "kind">;
}, z.core.$strip>;
}, z.core.$strip>], "kind">>;
parallelGroups: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
steps: z.ZodArray<z.ZodString>;
}, z.core.$strip>>>;
}, z.core.$strip>], "paradigm">;
skills: z.ZodDefault<z.ZodArray<z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "SkillId", "out">;
label: z.ZodString;
applicability: z.ZodString;
method: z.ZodString;
crystallized: z.ZodDefault<z.ZodArray<z.ZodObject<{
tool: z.ZodString;
input: z.ZodRecord<z.ZodString, z.ZodString>;
}, z.core.$strip>>>;
knowledgeRefs: z.ZodDefault<z.ZodArray<z.ZodString>>;
version: z.ZodString;
}, z.core.$strip>>>;
viewTemplates: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
html: z.ZodString;
}, z.core.$strip>>>;
cardSchemas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
distillHooks: z.ZodDefault<z.ZodArray<z.ZodObject<{
on: z.ZodEnum<{
terminal: "terminal";
milestone: "milestone";
}>;
milestone: z.ZodOptional<z.ZodString>;
prompt: z.ZodString;
}, z.core.$strip>>>;
}, z.core.$strip>;
samples: z.ZodArray<z.ZodObject<{
name: z.ZodString;
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
message: z.ZodOptional<z.ZodString>;
expect: z.ZodObject<{
ports: z.ZodArray<z.ZodString>;
payloadShape: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, z.core.$strip>;
}, z.core.$strip>>;
entry: z.ZodObject<{
file: z.ZodString;
checksum: z.ZodString;
}, z.core.$strip>;
}, z.core.$strip>;
artifact: z.ZodString;
}, z.core.$strip>;
readonly output: z.ZodObject<{
accepted: z.ZodBoolean;
activityId: z.ZodString;
packageVersion: z.ZodString;
staticFindings: z.ZodArray<z.ZodObject<{
code: z.ZodString;
severity: z.ZodString;
message: z.ZodString;
}, z.core.$strip>>;
replay: z.ZodObject<{
oldPassStillPass: z.ZodBoolean;
checked: z.ZodNumber;
skippedNoHistory: z.ZodBoolean;
regressions: z.ZodArray<z.ZodObject<{
taskId: z.ZodString;
detail: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
}, z.core.$strip>;
};
/**
* 导入自定义工具 —— 与第一方工具走**同一条门**:静态审 + 试运行审。
*