This repository has been archived on 2026-09-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
BPOS-TMP-REPO/api-report/packages/contracts/src/activity-ops.d.ts
T
xcsandClaude Fable 5 0923fbfe4d feat(ops): 运营中心 · 活动模块接口落地 —— L1/L2/L3 十一条(全 ops)+ 设计端活动库两条改名让位
`apps/api/src/app/activity-ops/*`(service / store / instance-state / instance-steps / launch-params /
summaries / view-html / view-scope)+ `routes/activities.ts`;契约 `activity-ops.ts` / `api/activity-ops.ts`
(与队友按文档补的那版 43 个导出同名,多 INSTANCE_REASON_KINDS / STEP_RESULTS / launchOptionSchema);
迁移 0035_activity_ops;《API文档-活动模块》按契约回写。
设计端活动库 GET/POST `/api/gov/activities` 改名 `/api/gov/activity-packages`,`/api/gov/activities/*`
整个让给运营端(前端 import 路由对象,零改动);activity-registry CONTRACT.md 与路由总表同步。
2026-08-27 另一会话做的,一直留在工作树没入库;与同批另两条提交互相依赖,以合并提交为验证单位。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0167qWjeyBwvfdGovd7FWbCu
2026-08-27 23:20:15 +08:00

354 lines
12 KiB
TypeScript

/**
* 运营中心 · 活动模块的契约(L1 活动清单 / L2 活动详情 / L3 实例详情;`docs/API文档-活动模块.md`)。
*
* 只有 zod schema 与推导类型。两个概念(2026-08-25 用户定):
* · **活动** = 装进来的活动包在运营面上的投影 —— 名称 / 分类 / 版本 / 模型来自清单,
* 负责人 / 说明 / 图标 / 色相来自运营侧档案(`sys.activity_profile`,活动包本身不载这些);
* · **实例** = 这个活动的一次运行(一张 task)—— 五态是对 task 运行态 / 终态的**如实映射**,
* 不是第六套状态机(见 `INSTANCE_STATE_LABEL` 旁的口径)。
*/
import { z } from 'zod';
/** 运营态:激活中 / 已禁用 —— 禁用只拦「新启动」,已完成与在途实例都不受影响(2026-08-27 用户定) */
export declare const ACTIVITY_STATUSES: readonly ["active", "disabled"];
export declare const activityStatusSchema: z.ZodEnum<{
active: "active";
disabled: "disabled";
}>;
export type ActivityStatus = z.infer<typeof activityStatusSchema>;
export declare const ACTIVITY_STATUS_LABEL: Readonly<Record<ActivityStatus, string>>;
/** 业务色相 —— 一卡一色;缺省由前端兜底(`blue`) */
export declare const ACTIVITY_HUES: readonly ["blue", "teal", "amber", "violet"];
export declare const activityHueSchema: z.ZodEnum<{
blue: "blue";
teal: "teal";
amber: "amber";
violet: "violet";
}>;
export type ActivityHue = z.infer<typeof activityHueSchema>;
/** 凡出人都是两段:展示用 name,筛选 / 提交用 id */
export declare const staffRefSchema: z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
name: z.ZodString;
}, z.core.$strip>;
export type StaffRef = z.infer<typeof staffRefSchema>;
export declare const activitySummarySchema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
biz: z.ZodString;
status: z.ZodEnum<{
active: "active";
disabled: "disabled";
}>;
version: z.ZodString;
owner: z.ZodNullable<z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
name: z.ZodString;
}, z.core.$strip>>;
llm: z.ZodString;
instanceCount: z.ZodNumber;
createdAt: z.ZodString;
ico: z.ZodOptional<z.ZodString>;
hue: z.ZodOptional<z.ZodEnum<{
blue: "blue";
teal: "teal";
amber: "amber";
violet: "violet";
}>>;
}, z.core.$strip>;
export type ActivitySummary = z.infer<typeof activitySummarySchema>;
export declare const activityDetailSchema: z.ZodObject<{
name: z.ZodString;
id: z.ZodString;
version: z.ZodString;
status: z.ZodEnum<{
active: "active";
disabled: "disabled";
}>;
createdAt: z.ZodString;
biz: z.ZodString;
owner: z.ZodNullable<z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
name: z.ZodString;
}, z.core.$strip>>;
llm: z.ZodString;
ico: z.ZodOptional<z.ZodString>;
hue: z.ZodOptional<z.ZodEnum<{
blue: "blue";
teal: "teal";
amber: "amber";
violet: "violet";
}>>;
desc: z.ZodString;
view: z.ZodNullable<z.ZodObject<{
url: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
export type ActivityDetail = z.infer<typeof activityDetailSchema>;
/**
* 沙箱视图向父页报高的消息类型(postMessage 载荷 `{ type, height }`)。
* 视图模版本身**无脚本**(安装静态审拦着);报高脚本由服务端在出口那一刻注入。
*/
export declare const ACTIVITY_VIEW_HEIGHT_MESSAGE = "jcai:view-height";
/**
* 实例五态(2026-08-25 用户定),对 task 的如实映射:
* pending 已建单、推进器还没领到(`used.steps = 0`)
* running 在途(含等人回传 / 监听中 / 挂起 / 落地受阻)
* completed 终态 released
* rejected 验收被负责人打回、模型还没重新提交的那一段(重新提交后回 running)
* failed 终态 blocked / stalled / exhausted,以及手动终止(靠 `reason.kind='terminated'` 区分)
*/
export declare const INSTANCE_STATES: readonly ["pending", "running", "completed", "rejected", "failed"];
export declare const instanceStateSchema: z.ZodEnum<{
running: "running";
completed: "completed";
pending: "pending";
failed: "failed";
rejected: "rejected";
}>;
export type InstanceState = z.infer<typeof instanceStateSchema>;
export declare const INSTANCE_STATE_LABEL: Readonly<Record<InstanceState, string>>;
export declare const instanceSummarySchema: z.ZodObject<{
id: z.ZodString;
no: z.ZodString;
state: z.ZodEnum<{
running: "running";
completed: "completed";
pending: "pending";
failed: "failed";
rejected: "rejected";
}>;
owner: z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
name: z.ZodString;
}, z.core.$strip>;
input: z.ZodString;
output: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
}, z.core.$strip>;
export type InstanceSummary = z.infer<typeof instanceSummarySchema>;
export declare const instanceStatsSchema: z.ZodObject<{
total: z.ZodNumber;
byState: z.ZodRecord<z.ZodEnum<{
running: "running";
completed: "completed";
pending: "pending";
failed: "failed";
rejected: "rejected";
}>, z.ZodNumber>;
}, z.core.$strip>;
export type InstanceStats = z.infer<typeof instanceStatsSchema>;
export declare const instanceListSchema: z.ZodObject<{
stats: z.ZodObject<{
total: z.ZodNumber;
byState: z.ZodRecord<z.ZodEnum<{
running: "running";
completed: "completed";
pending: "pending";
failed: "failed";
rejected: "rejected";
}>, z.ZodNumber>;
}, z.core.$strip>;
total: z.ZodNumber;
page: z.ZodNumber;
size: z.ZodNumber;
items: z.ZodArray<z.ZodObject<{
id: z.ZodString;
no: z.ZodString;
state: z.ZodEnum<{
running: "running";
completed: "completed";
pending: "pending";
failed: "failed";
rejected: "rejected";
}>;
owner: z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
name: z.ZodString;
}, z.core.$strip>;
input: z.ZodString;
output: z.ZodNullable<z.ZodString>;
startedAt: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
export type InstanceList = z.infer<typeof instanceListSchema>;
export declare const instanceFileSchema: z.ZodObject<{
index: z.ZodNumber;
name: z.ZodString;
contentType: z.ZodString;
size: z.ZodNumber;
}, z.core.$strip>;
export type InstanceFile = z.infer<typeof instanceFileSchema>;
export declare const INSTANCE_REASON_KINDS: readonly ["rejected", "failed", "terminated"];
export declare const instanceReasonSchema: z.ZodObject<{
kind: z.ZodEnum<{
terminated: "terminated";
failed: "failed";
rejected: "rejected";
}>;
text: z.ZodString;
}, z.core.$strip>;
export type InstanceReason = z.infer<typeof instanceReasonSchema>;
export declare const STEP_RESULTS: readonly ["done", "fail", "current", "pending"];
export declare const instanceStepSchema: z.ZodObject<{
seq: z.ZodNumber;
name: z.ZodString;
by: z.ZodEnum<{
human: "human";
agent: "agent";
}>;
byName: z.ZodString;
at: z.ZodNullable<z.ZodString>;
durationMs: z.ZodNullable<z.ZodNumber>;
res: z.ZodEnum<{
pending: "pending";
done: "done";
fail: "fail";
current: "current";
}>;
note: z.ZodString;
}, z.core.$strip>;
export type InstanceStep = z.infer<typeof instanceStepSchema>;
/** 起单来源:manual(运营端手动启动)/ upstream(工作流节点)/ mail 等通道名 / testbed(测试台试跑)/ system */
export declare const instanceSourceSchema: z.ZodObject<{
kind: z.ZodString;
label: z.ZodString;
}, z.core.$strip>;
export type InstanceSource = z.infer<typeof instanceSourceSchema>;
export declare const instanceDetailSchema: z.ZodObject<{
id: z.ZodString;
state: z.ZodEnum<{
running: "running";
completed: "completed";
pending: "pending";
failed: "failed";
rejected: "rejected";
}>;
startedAt: z.ZodString;
owner: z.ZodObject<{
id: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
name: z.ZodString;
}, z.core.$strip>;
no: z.ZodString;
activityId: z.ZodString;
llm: z.ZodString;
endedAt: z.ZodNullable<z.ZodString>;
durationMs: z.ZodNullable<z.ZodNumber>;
reason: z.ZodNullable<z.ZodObject<{
kind: z.ZodEnum<{
terminated: "terminated";
failed: "failed";
rejected: "rejected";
}>;
text: z.ZodString;
}, z.core.$strip>>;
input: z.ZodObject<{
content: z.ZodString;
source: z.ZodObject<{
kind: z.ZodString;
label: z.ZodString;
}, z.core.$strip>;
submittedAt: z.ZodString;
files: z.ZodArray<z.ZodObject<{
index: z.ZodNumber;
name: z.ZodString;
contentType: z.ZodString;
size: z.ZodNumber;
}, z.core.$strip>>;
}, z.core.$strip>;
output: z.ZodObject<{
files: z.ZodArray<z.ZodObject<{
index: z.ZodNumber;
name: z.ZodString;
contentType: z.ZodString;
size: z.ZodNumber;
}, z.core.$strip>>;
}, z.core.$strip>;
steps: z.ZodArray<z.ZodObject<{
seq: z.ZodNumber;
name: z.ZodString;
by: z.ZodEnum<{
human: "human";
agent: "agent";
}>;
byName: z.ZodString;
at: z.ZodNullable<z.ZodString>;
durationMs: z.ZodNullable<z.ZodNumber>;
res: z.ZodEnum<{
pending: "pending";
done: "done";
fail: "fail";
current: "current";
}>;
note: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
export type InstanceDetail = z.infer<typeof instanceDetailSchema>;
/**
* 控件种类:text 单行 / textarea 多行 / select 单选(只能选候选)/ combo 选择 + 新增 / list 字符串数组。
* 新增种类前后端一起升级;前端遇到不认识的 type 摆「暂不支持的控件」。
*/
export declare const LAUNCH_PARAM_TYPES: readonly ["text", "textarea", "select", "combo", "list"];
export declare const launchParamTypeSchema: z.ZodEnum<{
text: "text";
textarea: "textarea";
select: "select";
combo: "combo";
list: "list";
}>;
export type LaunchParamType = z.infer<typeof launchParamTypeSchema>;
export declare const launchOptionSchema: z.ZodObject<{
value: z.ZodString;
label: z.ZodString;
}, z.core.$strip>;
export type LaunchOption = z.infer<typeof launchOptionSchema>;
export declare const launchParamSchema: z.ZodObject<{
key: z.ZodString;
label: z.ZodString;
type: z.ZodEnum<{
text: "text";
textarea: "textarea";
select: "select";
combo: "combo";
list: "list";
}>;
required: z.ZodOptional<z.ZodBoolean>;
desc: z.ZodOptional<z.ZodString>;
placeholder: z.ZodOptional<z.ZodString>;
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
value: z.ZodString;
label: z.ZodString;
}, z.core.$strip>>>;
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
}, z.core.$strip>;
export type LaunchParam = z.infer<typeof launchParamSchema>;
export declare const launchParamsSchema: z.ZodObject<{
activityId: z.ZodString;
version: z.ZodString;
params: z.ZodArray<z.ZodObject<{
key: z.ZodString;
label: z.ZodString;
type: z.ZodEnum<{
text: "text";
textarea: "textarea";
select: "select";
combo: "combo";
list: "list";
}>;
required: z.ZodOptional<z.ZodBoolean>;
desc: z.ZodOptional<z.ZodString>;
placeholder: z.ZodOptional<z.ZodString>;
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
value: z.ZodString;
label: z.ZodString;
}, z.core.$strip>>>;
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
}, z.core.$strip>>;
}, z.core.$strip>;
export type LaunchParams = z.infer<typeof launchParamsSchema>;
export declare const launchInputSchema: z.ZodObject<{
idempotencyKey: z.ZodString;
ownerId: z.core.$ZodBranded<z.ZodString, "StaffId", "out">;
params: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
}, z.core.$strip>;
export type LaunchInput = z.infer<typeof launchInputSchema>;