@siming-org/core 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1696 @@
1
+ import { Db, MongoClient, MongoClientOptions, ClientSession, Collection, Document, Filter, ObjectId } from 'mongodb';
2
+ export { ClientSession, Db } from 'mongodb';
3
+ import { z } from 'zod';
4
+
5
+ interface SimingClient {
6
+ /** Access a database (defaults to URI database name or "siming"). */
7
+ db(name?: string): Db;
8
+ /** Close the underlying connection. */
9
+ close(): Promise<void>;
10
+ /** Underlying MongoClient — exposed for advanced use (e.g., startSession). @internal */
11
+ readonly _underlying: MongoClient;
12
+ }
13
+ /**
14
+ * Connect to MongoDB. Caller is responsible for close() at process exit.
15
+ * Database name resolution: explicit `db(name)` → URI path dbname → "siming" fallback.
16
+ * N018 §3.5:`options` 透传 MongoClientOptions(如 serverSelectionTimeoutMS 快速失败探测),默认不变。
17
+ */
18
+ declare function createMongoClient(uri?: string, options?: MongoClientOptions): Promise<SimingClient>;
19
+ /**
20
+ * Run a function inside a MongoDB transaction. Commits on success, aborts on error.
21
+ * Requires a replica set (see scripts/setup-mongodb.sh).
22
+ */
23
+ declare function withTransaction<T>(client: SimingClient, fn: (session: ClientSession) => Promise<T>): Promise<T>;
24
+
25
+ /**
26
+ * MongoDB document type with _id
27
+ */
28
+ type WithId<T> = T & {
29
+ _id: ObjectId;
30
+ };
31
+ /**
32
+ * Input type without id (for create operations)
33
+ */
34
+ type OmitId<T extends {
35
+ id?: string | undefined;
36
+ }> = Omit<T, 'id'>;
37
+ /**
38
+ * EOPT 兼容的 partial:可选属性允许显式 undefined(zod .partial() 的 z.infer 输出即此形状,
39
+ * 直接赋给 Partial<T> 会被 exactOptionalPropertyTypes 拒绝)
40
+ */
41
+ type EoptPartial<T> = {
42
+ [K in keyof T]?: T[K] | undefined;
43
+ };
44
+ /**
45
+ * Generic CRUD factory.
46
+ * Handles _id ↔ id mapping and timestamp management.
47
+ * All entities must have createdAt?/updatedAt? fields.
48
+ */
49
+ declare function createRepo<T extends {
50
+ id?: string | undefined;
51
+ }>(collection: Collection<Document>, options?: {
52
+ nameField?: string;
53
+ }): {
54
+ list(filter?: Filter<Document>): Promise<T[]>;
55
+ getById(id: string): Promise<T | null>;
56
+ getByName(name: string): Promise<T | null>;
57
+ create(data: OmitId<T>): Promise<T>;
58
+ update(id: string, patch: EoptPartial<OmitId<T>>): Promise<T | null>;
59
+ delete(id: string): Promise<boolean>;
60
+ /** Raw collection access for entity-specific queries */
61
+ readonly _collection: Collection<Document>;
62
+ };
63
+ type Repo<T extends {
64
+ id?: string | undefined;
65
+ }> = ReturnType<typeof createRepo<T>>;
66
+
67
+ /**
68
+ * Skill Schema — Skill 库(N012:支持全局 / 项目专用两种作用域)
69
+ * sync 到 ~/.agent/skills/;scope=project 时 projectId 必填(superRefine 保证)
70
+ */
71
+ declare const SkillScopeSchema: z.ZodEnum<{
72
+ global: "global";
73
+ project: "project";
74
+ }>;
75
+ declare const OBJECT_ID_HEX: RegExp;
76
+ declare const SkillSchema: z.ZodObject<{
77
+ id: z.ZodOptional<z.ZodString>;
78
+ name: z.ZodString;
79
+ description: z.ZodString;
80
+ content: z.ZodString;
81
+ category: z.ZodString;
82
+ version: z.ZodDefault<z.ZodString>;
83
+ scope: z.ZodDefault<z.ZodEnum<{
84
+ global: "global";
85
+ project: "project";
86
+ }>>;
87
+ projectId: z.ZodOptional<z.ZodString>;
88
+ createdAt: z.ZodOptional<z.ZodDate>;
89
+ updatedAt: z.ZodOptional<z.ZodDate>;
90
+ }, z.core.$strip>;
91
+ type Skill = z.infer<typeof SkillSchema>;
92
+ type SkillScope = z.infer<typeof SkillScopeSchema>;
93
+ /**
94
+ * 创建输入:scope 必填(PRD F7/Q6「无默认值,未选择不可提交」)。
95
+ * extend 覆盖 scope 字段定义以剥离实体层 default(.omit() 会保留字段的 default,缺省会静默补 'global' 而非 422);
96
+ * superRefine 独立重挂——不依赖 .omit() 对 refine 的保留行为。
97
+ */
98
+ declare const SkillCreateSchema: z.ZodObject<{
99
+ version: z.ZodDefault<z.ZodString>;
100
+ name: z.ZodString;
101
+ description: z.ZodString;
102
+ content: z.ZodString;
103
+ category: z.ZodString;
104
+ projectId: z.ZodOptional<z.ZodString>;
105
+ scope: z.ZodEnum<{
106
+ global: "global";
107
+ project: "project";
108
+ }>;
109
+ }, z.core.$strip>;
110
+ type SkillCreate = z.infer<typeof SkillCreateSchema>;
111
+ /**
112
+ * 更新输入(PUT partial)。两个关键点:
113
+ * 1. refine 必须挂在 .partial() 之后——Zod 4 运行时禁止对含 refinement 的 schema 调 .partial()
114
+ * (superRefine 的 `(): this` 类型签名会骗过编译期检查,运行时直接 throw)。
115
+ * 2. extend 必须剥离实体层 .default()——Zod 4 的 .partial() 保留字段 default,空 body 会
116
+ * 解析出 {scope:'global', version:'1.0.0'} 并被 $set 写库(version 被重置 + 项目专用资产假 409)。
117
+ */
118
+ declare const SkillUpdateSchema: z.ZodObject<{
119
+ name: z.ZodOptional<z.ZodString>;
120
+ description: z.ZodOptional<z.ZodString>;
121
+ content: z.ZodOptional<z.ZodString>;
122
+ category: z.ZodOptional<z.ZodString>;
123
+ projectId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
124
+ version: z.ZodOptional<z.ZodOptional<z.ZodString>>;
125
+ scope: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
126
+ global: "global";
127
+ project: "project";
128
+ }>>>;
129
+ }, z.core.$strip>;
130
+ type SkillUpdate = z.infer<typeof SkillUpdateSchema>;
131
+ /**
132
+ * Skill 复制入参(N012 F7/D9,契约命名对齐方案 §3.2.4):by-name 复制,目标作用域显式指定;副本 version 重置 '1.0.0'。
133
+ */
134
+ declare const SkillCopySchema: z.ZodObject<{
135
+ newName: z.ZodString;
136
+ newScope: z.ZodEnum<{
137
+ global: "global";
138
+ project: "project";
139
+ }>;
140
+ targetProjectId: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$strip>;
142
+ type SkillCopy = z.infer<typeof SkillCopySchema>;
143
+
144
+ type SkillRepo = Repo<Skill> & {
145
+ createSkill(data: SkillCreate): Promise<Skill>;
146
+ /** @deprecated N016 F13:无 scope 消歧(跨 scope 同名会误伤),改用 updateByNameScoped */
147
+ updateByName(name: string, patch: EoptPartial<Omit<Skill, 'id'>>): Promise<Skill | null>;
148
+ /** @deprecated N016 F13:无 scope 消歧(跨 scope 同名会误删),改用 deleteByNameScoped */
149
+ deleteByName(name: string): Promise<boolean>;
150
+ /** N016 F02:by-name 消歧更新——scope 显式指定(跨 scope 同名时不误伤;project → {name, projectId};global → {name, scope:'global'}) */
151
+ updateByNameScoped(name: string, scope: SkillScope, projectId: string | undefined, patch: EoptPartial<Omit<Skill, 'id'>>): Promise<Skill | null>;
152
+ /** N016 F02:by-name 消歧删除(同 updateByNameScoped,防止跨 scope 同名时误删) */
153
+ deleteByNameScoped(name: string, scope: SkillScope, projectId: string | undefined): Promise<boolean>;
154
+ /** N016 F12:by-name 消歧解析——scope 显式指定(project → {name, projectId};global → {name, scope:'global'}) */
155
+ getByNameScoped(name: string, scope: SkillScope, projectId?: string | undefined): Promise<Skill | null>;
156
+ /** 项目上下文叠加列表(F7):global + 指定项目专用 */
157
+ listSkillsByScope(projectId: string): Promise<Skill[]>;
158
+ /** N015 F12:按作用域过滤(install 拉取;projectId 仅 scope=project 时生效) */
159
+ listSkillsByScopeFilter(scope: SkillScope, projectId?: string): Promise<Skill[]>;
160
+ /** 绑定校验批量预取(消 N+1):按引用方 scope 可见集过滤(N016 F04——project 引用方 = global + 本项目;global 引用方 = 仅 global) */
161
+ listSkillsByNames(names: string[], scope?: SkillScope, projectId?: string): Promise<Map<string, Skill>>;
162
+ /** by-name 复制(N016 F08/F11):源 scope 显式消歧 + 目标跨 scope 守卫;version 重置 '1.0.0' */
163
+ copySkill(sourceName: string, source: {
164
+ scope: SkillScope;
165
+ projectId?: string;
166
+ }, target: {
167
+ scope: SkillScope;
168
+ projectId?: string;
169
+ }, newName: string): Promise<Skill>;
170
+ };
171
+ declare function createSkillRepo(db: Db): SkillRepo;
172
+
173
+ /**
174
+ * Agent Schema — subagent 定义
175
+ * N012:支持全局 / 项目专用两种作用域(scope=project 时 projectId 必填)
176
+ * N016 F1:移除 syncTargets 概念——SKILL/Agent 跨编程 Agent 通用,仅关联作用域,无关编程工具
177
+ */
178
+ declare const AgentScopeSchema: z.ZodEnum<{
179
+ global: "global";
180
+ project: "project";
181
+ }>;
182
+ declare const AgentSchema: z.ZodObject<{
183
+ id: z.ZodOptional<z.ZodString>;
184
+ name: z.ZodString;
185
+ description: z.ZodString;
186
+ systemPrompt: z.ZodString;
187
+ boundSkills: z.ZodDefault<z.ZodArray<z.ZodString>>;
188
+ model: z.ZodString;
189
+ version: z.ZodDefault<z.ZodString>;
190
+ tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
191
+ permissions: z.ZodDefault<z.ZodArray<z.ZodString>>;
192
+ scope: z.ZodDefault<z.ZodEnum<{
193
+ global: "global";
194
+ project: "project";
195
+ }>>;
196
+ projectId: z.ZodOptional<z.ZodString>;
197
+ createdAt: z.ZodOptional<z.ZodDate>;
198
+ updatedAt: z.ZodOptional<z.ZodDate>;
199
+ }, z.core.$strip>;
200
+ type Agent = z.infer<typeof AgentSchema>;
201
+ type AgentScope = z.infer<typeof AgentScopeSchema>;
202
+ /**
203
+ * 创建输入:scope 必填(PRD F7/Q6「无默认值,未选择不可提交」)。
204
+ * extend 覆盖 scope 字段定义以剥离实体层 default(.omit() 会保留字段的 default,缺省会静默补 'global' 而非 422);
205
+ * superRefine 独立重挂——不依赖 .omit() 对 refine 的保留行为。
206
+ */
207
+ declare const AgentCreateSchema: z.ZodObject<{
208
+ version: z.ZodDefault<z.ZodString>;
209
+ name: z.ZodString;
210
+ description: z.ZodString;
211
+ projectId: z.ZodOptional<z.ZodString>;
212
+ systemPrompt: z.ZodString;
213
+ boundSkills: z.ZodDefault<z.ZodArray<z.ZodString>>;
214
+ tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
215
+ permissions: z.ZodDefault<z.ZodArray<z.ZodString>>;
216
+ scope: z.ZodEnum<{
217
+ global: "global";
218
+ project: "project";
219
+ }>;
220
+ model: z.ZodString;
221
+ }, z.core.$strip>;
222
+ type AgentCreate = z.infer<typeof AgentCreateSchema>;
223
+ /**
224
+ * 更新输入(PUT partial)。两个关键点:
225
+ * 1. refine 必须挂在 .partial() 之后——Zod 4 运行时禁止对含 refinement 的 schema 调 .partial()
226
+ * (superRefine 的 `(): this` 类型签名会骗过编译期检查,运行时直接 throw)。
227
+ * 2. extend 必须剥离实体层 .default()——Zod 4 的 .partial() 保留字段 default,空 body 会
228
+ * 解析出 {scope:'global', boundSkills:[], ...} 并被 $set 写库(绑定被清空 + 项目专用资产假 409)。
229
+ */
230
+ declare const AgentUpdateSchema: z.ZodObject<{
231
+ name: z.ZodOptional<z.ZodString>;
232
+ description: z.ZodOptional<z.ZodString>;
233
+ projectId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
234
+ systemPrompt: z.ZodOptional<z.ZodString>;
235
+ boundSkills: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
236
+ version: z.ZodOptional<z.ZodOptional<z.ZodString>>;
237
+ tools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
238
+ permissions: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
239
+ scope: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
240
+ global: "global";
241
+ project: "project";
242
+ }>>>;
243
+ model: z.ZodOptional<z.ZodOptional<z.ZodString>>;
244
+ }, z.core.$strip>;
245
+ type AgentUpdate = z.infer<typeof AgentUpdateSchema>;
246
+ /**
247
+ * Agent 复制入参(N012 F7/D9,契约命名对齐方案 §3.2.4):by-name 复制,目标作用域显式指定;boundSkills 随迁并按目标作用域重校验(F06)。
248
+ */
249
+ declare const AgentCopySchema: z.ZodObject<{
250
+ newName: z.ZodString;
251
+ newScope: z.ZodEnum<{
252
+ global: "global";
253
+ project: "project";
254
+ }>;
255
+ targetProjectId: z.ZodOptional<z.ZodString>;
256
+ }, z.core.$strip>;
257
+ type AgentCopy = z.infer<typeof AgentCopySchema>;
258
+
259
+ type AgentRepo = Repo<Agent> & {
260
+ createAgent(data: AgentCreate): Promise<Agent>;
261
+ /** @deprecated N016 F13:无 scope 消歧(跨 scope 同名会误伤),改用 updateByNameScoped */
262
+ updateByName(name: string, patch: EoptPartial<Omit<Agent, 'id'>>): Promise<Agent | null>;
263
+ /** @deprecated N016 F13:无 scope 消歧(跨 scope 同名会误删),改用 deleteByNameScoped */
264
+ deleteByName(name: string): Promise<boolean>;
265
+ /** N016 F02:by-name 消歧更新——scope 显式指定(跨 scope 同名时不误伤;project → {name, projectId};global → {name, scope:'global'}) */
266
+ updateByNameScoped(name: string, scope: AgentScope, projectId: string | undefined, patch: EoptPartial<Omit<Agent, 'id'>>): Promise<Agent | null>;
267
+ /** N016 F02:by-name 消歧删除(同 updateByNameScoped,防止跨 scope 同名时误删) */
268
+ deleteByNameScoped(name: string, scope: AgentScope, projectId: string | undefined): Promise<boolean>;
269
+ /** N016 F12:by-name 消歧解析——scope 显式指定(project → {name, projectId};global → {name, scope:'global'}) */
270
+ getByNameScoped(name: string, scope: AgentScope, projectId?: string | undefined): Promise<Agent | null>;
271
+ /** 项目上下文叠加列表(F7):global + 指定项目专用 */
272
+ listAgentsByScope(projectId: string): Promise<Agent[]>;
273
+ /** N015 F12:按作用域过滤(install 拉取;projectId 仅 scope=project 时生效) */
274
+ listAgentsByScopeFilter(scope: AgentScope, projectId?: string): Promise<Agent[]>;
275
+ /** by-name 复制(N016 F08/F11):源 scope 显式消歧 + 目标跨 scope 守卫 + boundSkills 按目标作用域重校验;version 重置 '1.0.0' */
276
+ copyAgent(sourceName: string, source: {
277
+ scope: AgentScope;
278
+ projectId?: string;
279
+ }, target: {
280
+ scope: AgentScope;
281
+ projectId?: string;
282
+ }, newName: string, skillRepo: SkillRepo): Promise<Agent>;
283
+ };
284
+ declare function createAgentRepo(db: Db): AgentRepo;
285
+ /**
286
+ * N016 F04 绑定约束:全局 Agent 仅可绑全局 Skill;项目 Agent 可绑全局 + 本项目 Skill。
287
+ * 名字引用解析范围为引用方 scope 的可见集(project = global + 本项目;global = 全部 global),
288
+ * 由 scope-aware listSkillsByNames 保证集合内名字唯一(P4 唯一性模型)。
289
+ */
290
+ declare function assertBoundSkillsCompatible(skillRepo: SkillRepo, agentScope: AgentScope, agentProjectId: string | undefined, boundSkills: string[]): Promise<void>;
291
+
292
+ /**
293
+ * DAG Template 相关 Schemas
294
+ * 项目级流程模板(节点 + 转移 + 边暂停点)
295
+ *
296
+ * N017 F8:Gate 机制整体退役(GateSchema/GATE_TYPES/DagNode.gates 删除)——
297
+ * 引擎本就不消费 gates 校验结果,保留只会延续"程序强制"幻觉;
298
+ * 暂停点从模板顶层数组(afterNode 寻址)迁移为 DagEdge 内联字段(N017 D1)。
299
+ */
300
+ /**
301
+ * N016 F9:枚举放宽(D3)——dag_phase 全放开(引擎零分支,仅 currentPhase 存储),
302
+ * dag_track 自定义可流经引擎(findNextEdge 字符串比较),backend/ui/all 为内置(builtin 保护)。
303
+ * N020 决策 12:node id 收紧为 [A-Za-z0-9_-]+——节点记录写路径用点路径拼接
304
+ * (`nodeRecords.${nodeId}.checks`),id 含 `.`/`$` 会造成路径注入/错位。
305
+ */
306
+ declare const DagNodePhaseSchema: z.ZodString;
307
+ declare const DagNodeTrackSchema: z.ZodString;
308
+ /**
309
+ * 内置 phase/track 常量(seed 引用 + 文档化;注册表为运行时权威)。
310
+ * T202608240003:dag_track 另有任务级专用值 mixed/research(注册表 builtin,非节点
311
+ * track 值)——节点 track 不使用这两个值;本常量仅覆盖节点级内置值。
312
+ */
313
+ declare const DAG_PHASES: readonly ["entry", "track", "test", "exit"];
314
+ declare const DAG_TRACKS: readonly ["backend", "ui", "all"];
315
+ declare const NODE_ID_PATTERN: RegExp;
316
+ declare const DagNodeSchema: z.ZodObject<{
317
+ id: z.ZodString;
318
+ label: z.ZodString;
319
+ phase: z.ZodString;
320
+ track: z.ZodString;
321
+ prompt: z.ZodString;
322
+ skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
323
+ }, z.core.$strip>;
324
+ type DagNode = z.infer<typeof DagNodeSchema>;
325
+ /** 暂停点类型——固定枚举,引擎仅处理这两种语义(human_approval 落 paused / checkpoint 仅记录不停留) */
326
+ declare const PausePointTypeSchema: z.ZodEnum<{
327
+ human_approval: "human_approval";
328
+ checkpoint: "checkpoint";
329
+ }>;
330
+ /** 内置 pause 类型常量(seed 引用 + schema 枚举源) */
331
+ declare const PAUSE_POINT_TYPES: readonly ["human_approval", "checkpoint"];
332
+ /**
333
+ * N017 D1:边暂停点——暂停是流转路径的属性,内联使画布 edge 零 join 渲染标识,
334
+ * 删边连带删暂停点(级联语义天然)。
335
+ *
336
+ * 组合约束(N017 §2.2,消除枚举组合歧义):
337
+ * - human_approval + autoResume=false → 唯一合法的人工审批组合(advance 落 paused)
338
+ * - checkpoint + autoResume=true → 唯一合法的检查点组合(不停留仅记录)
339
+ * - 其余组合 schema 拒绝(模板创建/更新 422)
340
+ *
341
+ * superRefine 内聚在本对象级——DagTemplateSchema/DagTemplateCreateSchema 模板级
342
+ * 不挂任何 refine,否则 CreateSchema.partial() 派生 UpdateSchema 时触发
343
+ * Zod4「refined schema 禁 .partial()」运行时 throw(技术架构「Zod4 UpdateSchema 范式」)。
344
+ */
345
+ declare const EdgePausePointBaseSchema: z.ZodObject<{
346
+ type: z.ZodEnum<{
347
+ human_approval: "human_approval";
348
+ checkpoint: "checkpoint";
349
+ }>;
350
+ description: z.ZodString;
351
+ autoResume: z.ZodDefault<z.ZodBoolean>;
352
+ }, z.core.$strip>;
353
+ declare const EdgePausePointSchema: z.ZodObject<{
354
+ type: z.ZodEnum<{
355
+ human_approval: "human_approval";
356
+ checkpoint: "checkpoint";
357
+ }>;
358
+ description: z.ZodString;
359
+ autoResume: z.ZodDefault<z.ZodBoolean>;
360
+ }, z.core.$strip>;
361
+ type EdgePausePoint = z.infer<typeof EdgePausePointSchema>;
362
+ declare const DagEdgeSchema: z.ZodObject<{
363
+ from: z.ZodString;
364
+ to: z.ZodString;
365
+ condition: z.ZodOptional<z.ZodString>;
366
+ pausePoint: z.ZodOptional<z.ZodObject<{
367
+ type: z.ZodEnum<{
368
+ human_approval: "human_approval";
369
+ checkpoint: "checkpoint";
370
+ }>;
371
+ description: z.ZodString;
372
+ autoResume: z.ZodDefault<z.ZodBoolean>;
373
+ }, z.core.$strip>>;
374
+ }, z.core.$strip>;
375
+ type DagEdge = z.infer<typeof DagEdgeSchema>;
376
+ declare const DagTemplateSchema: z.ZodObject<{
377
+ id: z.ZodOptional<z.ZodString>;
378
+ name: z.ZodString;
379
+ projectId: z.ZodString;
380
+ description: z.ZodString;
381
+ nodes: z.ZodArray<z.ZodObject<{
382
+ id: z.ZodString;
383
+ label: z.ZodString;
384
+ phase: z.ZodString;
385
+ track: z.ZodString;
386
+ prompt: z.ZodString;
387
+ skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
388
+ }, z.core.$strip>>;
389
+ edges: z.ZodArray<z.ZodObject<{
390
+ from: z.ZodString;
391
+ to: z.ZodString;
392
+ condition: z.ZodOptional<z.ZodString>;
393
+ pausePoint: z.ZodOptional<z.ZodObject<{
394
+ type: z.ZodEnum<{
395
+ human_approval: "human_approval";
396
+ checkpoint: "checkpoint";
397
+ }>;
398
+ description: z.ZodString;
399
+ autoResume: z.ZodDefault<z.ZodBoolean>;
400
+ }, z.core.$strip>>;
401
+ }, z.core.$strip>>;
402
+ layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
403
+ x: z.ZodNumber;
404
+ y: z.ZodNumber;
405
+ }, z.core.$strip>>>;
406
+ isDefault: z.ZodDefault<z.ZodBoolean>;
407
+ version: z.ZodDefault<z.ZodString>;
408
+ createdAt: z.ZodOptional<z.ZodDate>;
409
+ updatedAt: z.ZodOptional<z.ZodDate>;
410
+ }, z.core.$strip>;
411
+ type DagTemplate = z.infer<typeof DagTemplateSchema>;
412
+ declare const DagTemplateCreateSchema: z.ZodObject<{
413
+ version: z.ZodDefault<z.ZodString>;
414
+ name: z.ZodString;
415
+ description: z.ZodString;
416
+ projectId: z.ZodString;
417
+ nodes: z.ZodArray<z.ZodObject<{
418
+ id: z.ZodString;
419
+ label: z.ZodString;
420
+ phase: z.ZodString;
421
+ track: z.ZodString;
422
+ prompt: z.ZodString;
423
+ skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
424
+ }, z.core.$strip>>;
425
+ edges: z.ZodArray<z.ZodObject<{
426
+ from: z.ZodString;
427
+ to: z.ZodString;
428
+ condition: z.ZodOptional<z.ZodString>;
429
+ pausePoint: z.ZodOptional<z.ZodObject<{
430
+ type: z.ZodEnum<{
431
+ human_approval: "human_approval";
432
+ checkpoint: "checkpoint";
433
+ }>;
434
+ description: z.ZodString;
435
+ autoResume: z.ZodDefault<z.ZodBoolean>;
436
+ }, z.core.$strip>>;
437
+ }, z.core.$strip>>;
438
+ layout: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
439
+ x: z.ZodNumber;
440
+ y: z.ZodNumber;
441
+ }, z.core.$strip>>>;
442
+ isDefault: z.ZodDefault<z.ZodBoolean>;
443
+ }, z.core.$strip>;
444
+ type DagTemplateCreate = z.infer<typeof DagTemplateCreateSchema>;
445
+ /**
446
+ * 更新输入(PUT partial)。extend 剥离实体层 .default()——Zod 4 的 .partial() 保留字段
447
+ * default,空 body 会解析出 {isDefault:false, version:'1.0.0'} 并被 $set 写库(字段被静默重置)。
448
+ */
449
+ declare const DagTemplateUpdateSchema: z.ZodObject<{
450
+ name: z.ZodOptional<z.ZodString>;
451
+ description: z.ZodOptional<z.ZodString>;
452
+ projectId: z.ZodOptional<z.ZodString>;
453
+ nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
454
+ id: z.ZodString;
455
+ label: z.ZodString;
456
+ phase: z.ZodString;
457
+ track: z.ZodString;
458
+ prompt: z.ZodString;
459
+ skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
460
+ }, z.core.$strip>>>;
461
+ edges: z.ZodOptional<z.ZodArray<z.ZodObject<{
462
+ from: z.ZodString;
463
+ to: z.ZodString;
464
+ condition: z.ZodOptional<z.ZodString>;
465
+ pausePoint: z.ZodOptional<z.ZodObject<{
466
+ type: z.ZodEnum<{
467
+ human_approval: "human_approval";
468
+ checkpoint: "checkpoint";
469
+ }>;
470
+ description: z.ZodString;
471
+ autoResume: z.ZodDefault<z.ZodBoolean>;
472
+ }, z.core.$strip>>;
473
+ }, z.core.$strip>>>;
474
+ layout: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
475
+ x: z.ZodNumber;
476
+ y: z.ZodNumber;
477
+ }, z.core.$strip>>>>;
478
+ isDefault: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
479
+ version: z.ZodOptional<z.ZodOptional<z.ZodString>>;
480
+ }, z.core.$strip>;
481
+ type DagTemplateUpdate = z.infer<typeof DagTemplateUpdateSchema>;
482
+ /**
483
+ * 模板复制入参(N012 F5/D5,契约命名对齐方案 §3.2.3):目标项目 + 新名称;副本落库为可编辑独立实体(version 重置 '1.0.0',isDefault=false)。
484
+ */
485
+ declare const DagTemplateCopySchema: z.ZodObject<{
486
+ newName: z.ZodString;
487
+ targetProjectId: z.ZodString;
488
+ }, z.core.$strip>;
489
+ type DagTemplateCopy = z.infer<typeof DagTemplateCopySchema>;
490
+
491
+ type DagTemplateRepo = Repo<DagTemplate> & {
492
+ createDagTemplate(data: DagTemplateCreate): Promise<DagTemplate>;
493
+ /** N015 F17:list 支持 name 过滤(export 查重按 projectId+name,name 项目内唯一) */
494
+ listDagTemplates(filter?: {
495
+ projectId?: string;
496
+ name?: string;
497
+ }): Promise<DagTemplate[]>;
498
+ /** 深拷贝复制(N012 F5/D5):副本落目标项目,version 重置 '1.0.0'、isDefault=false;目标项目内重名 → 409 */
499
+ copyDagTemplate(sourceId: string, targetProjectId: string, newName: string): Promise<DagTemplate>;
500
+ };
501
+ declare function createDagTemplateRepo(db: Db): DagTemplateRepo;
502
+
503
+ /**
504
+ * Task 相关 Schemas
505
+ * 从 DagTemplate 实例化的交付任务
506
+ *
507
+ * N017 F8:GateResultSchema / NodeState.gateResults 退役;
508
+ * DagInstance 暂停点迁到 edges 内联(D1),顶层数组删除;
509
+ * N020 D1:任务信息结构化落库——Task.doc(任务级文档)+ Task.nodeRecords
510
+ * (节点级执行记录)+ Task.archNotes(跨节点累积素材)。写操作一律条目追加 +
511
+ * 字段级更新($push/$set/arrayFilters),永不接受整文档提交(AI 全量重写易错)。
512
+ */
513
+ /**
514
+ * 任务类型(T202608240003):类型→路径映射由 task-create skill 持有(唯一真相源),
515
+ * 平台只承载类型标签与入口合法性校验——扩类型 = 代码(本枚举)+ skill 同步变更。
516
+ * 'research' 是保留契约值:模板 PRD 节点的调研变体判定 + track=research 的双向绑定都精确依赖它。
517
+ */
518
+ declare const TASK_TYPES: readonly ["feature", "bugfix", "ui-tweak", "research"];
519
+ type TaskType = (typeof TASK_TYPES)[number];
520
+ /** 条目短 id 格式:服务端生成 6 位 base36(条目定位/翻转用,同 record 内查重) */
521
+ declare const ENTRY_ID_REGEX: RegExp;
522
+ /** 完成判定清单条目(item = 判定项原文,passed = 逐项 ✅/❌ 状态) */
523
+ declare const CheckItemSchema: z.ZodObject<{
524
+ id: z.ZodString;
525
+ item: z.ZodString;
526
+ passed: z.ZodBoolean;
527
+ }, z.core.$strip>;
528
+ type CheckItem = z.infer<typeof CheckItemSchema>;
529
+ /** 产物类型静态枚举(决策 5:API 契约字段,非用户自定义分类) */
530
+ declare const ARTIFACT_TYPES: readonly ["prd", "tech", "code", "test", "doc", "other"];
531
+ type ArtifactType = (typeof ARTIFACT_TYPES)[number];
532
+ /**
533
+ * 产物引用(path 为引用文本,不触发 server fs 读写)。
534
+ * content:产物全文快照(可选,≤200k 字符)——登记时由 CLI --file 读文件写入;
535
+ * 断点续跑会话凭 context 即可取回设计文档实质内容,不依赖再访问项目仓库(跨会话/跨环境自足)。
536
+ */
537
+ declare const ArtifactSchema: z.ZodObject<{
538
+ id: z.ZodString;
539
+ type: z.ZodEnum<{
540
+ code: "code";
541
+ test: "test";
542
+ prd: "prd";
543
+ tech: "tech";
544
+ doc: "doc";
545
+ other: "other";
546
+ }>;
547
+ path: z.ZodString;
548
+ note: z.ZodOptional<z.ZodString>;
549
+ content: z.ZodOptional<z.ZodString>;
550
+ }, z.core.$strip>;
551
+ type Artifact = z.infer<typeof ArtifactSchema>;
552
+ /** 暂停点确认原文(HARD GATE:用户显式确认须留痕,max 2000 字符) */
553
+ declare const ConfirmationSchema: z.ZodObject<{
554
+ id: z.ZodString;
555
+ quote: z.ZodString;
556
+ at: z.ZodDate;
557
+ }, z.core.$strip>;
558
+ type Confirmation = z.infer<typeof ConfirmationSchema>;
559
+ /** 节点内关键决策条目(topic + 结论) */
560
+ declare const DecisionSchema: z.ZodObject<{
561
+ id: z.ZodString;
562
+ topic: z.ZodString;
563
+ decision: z.ZodString;
564
+ }, z.core.$strip>;
565
+ type Decision = z.infer<typeof DecisionSchema>;
566
+ /** oracle 审查结论摘要(rounds = 交互轮数,critical = 未修复 Critical 数) */
567
+ declare const ReviewSummarySchema: z.ZodObject<{
568
+ verdict: z.ZodEnum<{
569
+ pass: "pass";
570
+ fail: "fail";
571
+ }>;
572
+ rounds: z.ZodNumber;
573
+ critical: z.ZodNumber;
574
+ }, z.core.$strip>;
575
+ type ReviewSummary = z.infer<typeof ReviewSummarySchema>;
576
+ /**
577
+ * 节点执行记录(nodeId → record)。无 completedAt——完成时间单权威在
578
+ * dagInstance.nodeStates(决策 11:状态属性归状态机,双存必然漂移)。
579
+ */
580
+ declare const NodeRecordSchema: z.ZodObject<{
581
+ summary: z.ZodOptional<z.ZodString>;
582
+ checks: z.ZodDefault<z.ZodArray<z.ZodObject<{
583
+ id: z.ZodString;
584
+ item: z.ZodString;
585
+ passed: z.ZodBoolean;
586
+ }, z.core.$strip>>>;
587
+ artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
588
+ id: z.ZodString;
589
+ type: z.ZodEnum<{
590
+ code: "code";
591
+ test: "test";
592
+ prd: "prd";
593
+ tech: "tech";
594
+ doc: "doc";
595
+ other: "other";
596
+ }>;
597
+ path: z.ZodString;
598
+ note: z.ZodOptional<z.ZodString>;
599
+ content: z.ZodOptional<z.ZodString>;
600
+ }, z.core.$strip>>>;
601
+ confirmations: z.ZodDefault<z.ZodArray<z.ZodObject<{
602
+ id: z.ZodString;
603
+ quote: z.ZodString;
604
+ at: z.ZodDate;
605
+ }, z.core.$strip>>>;
606
+ decisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
607
+ id: z.ZodString;
608
+ topic: z.ZodString;
609
+ decision: z.ZodString;
610
+ }, z.core.$strip>>>;
611
+ review: z.ZodOptional<z.ZodObject<{
612
+ verdict: z.ZodEnum<{
613
+ pass: "pass";
614
+ fail: "fail";
615
+ }>;
616
+ rounds: z.ZodNumber;
617
+ critical: z.ZodNumber;
618
+ }, z.core.$strip>>;
619
+ }, z.core.$strip>;
620
+ type NodeRecord = z.infer<typeof NodeRecordSchema>;
621
+ /** 任务级文档:需求 What/Why + 验收标准 + 非目标 + 轨道识别结论 */
622
+ declare const TaskDocContentSchema: z.ZodObject<{
623
+ what: z.ZodString;
624
+ why: z.ZodString;
625
+ acceptance: z.ZodDefault<z.ZodArray<z.ZodString>>;
626
+ nonGoals: z.ZodDefault<z.ZodArray<z.ZodString>>;
627
+ trackNote: z.ZodOptional<z.ZodString>;
628
+ }, z.core.$strip>;
629
+ type TaskDocContent = z.infer<typeof TaskDocContentSchema>;
630
+ /** 架构信息收集条目(跨节点渐进追加,验收归档后统一归档到 docs/架构信息/) */
631
+ declare const ArchNoteSchema: z.ZodObject<{
632
+ id: z.ZodString;
633
+ text: z.ZodString;
634
+ at: z.ZodDate;
635
+ }, z.core.$strip>;
636
+ type ArchNote = z.infer<typeof ArchNoteSchema>;
637
+ /**
638
+ * N016 F9:枚举放宽(注册表 node_status 权威)。
639
+ * 内置值常量(seed 引用 + 文档化;注册表为运行时权威)。
640
+ */
641
+ declare const NodeStatusSchema: z.ZodString;
642
+ declare const NODE_STATUSES: readonly ["pending", "active", "completed", "skipped"];
643
+ declare const NodeStateSchema: z.ZodObject<{
644
+ status: z.ZodString;
645
+ enteredAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
646
+ completedAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
647
+ }, z.core.$strip>;
648
+ type NodeState = z.infer<typeof NodeStateSchema>;
649
+ declare const DagInstanceSchema: z.ZodObject<{
650
+ templateId: z.ZodString;
651
+ templateVersion: z.ZodString;
652
+ nodes: z.ZodArray<z.ZodObject<{
653
+ id: z.ZodString;
654
+ label: z.ZodString;
655
+ phase: z.ZodString;
656
+ track: z.ZodString;
657
+ prompt: z.ZodString;
658
+ skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
659
+ }, z.core.$strip>>;
660
+ edges: z.ZodArray<z.ZodObject<{
661
+ from: z.ZodString;
662
+ to: z.ZodString;
663
+ condition: z.ZodOptional<z.ZodString>;
664
+ pausePoint: z.ZodOptional<z.ZodObject<{
665
+ type: z.ZodEnum<{
666
+ human_approval: "human_approval";
667
+ checkpoint: "checkpoint";
668
+ }>;
669
+ description: z.ZodString;
670
+ autoResume: z.ZodDefault<z.ZodBoolean>;
671
+ }, z.core.$strip>>;
672
+ }, z.core.$strip>>;
673
+ prunedNodes: z.ZodArray<z.ZodString>;
674
+ nodeStates: z.ZodRecord<z.ZodString, z.ZodObject<{
675
+ status: z.ZodString;
676
+ enteredAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
677
+ completedAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
678
+ }, z.core.$strip>>;
679
+ }, z.core.$strip>;
680
+ type DagInstance = z.infer<typeof DagInstanceSchema>;
681
+ /**
682
+ * N017 D7:删 gate_failed(随 gates 退役),增 approved/rejected——
683
+ * 审批决策是新的领域事件,rejected 需要可追溯。
684
+ */
685
+ declare const HistoryActionSchema: z.ZodEnum<{
686
+ completed: "completed";
687
+ entered: "entered";
688
+ advanced: "advanced";
689
+ paused: "paused";
690
+ resumed: "resumed";
691
+ approved: "approved";
692
+ rejected: "rejected";
693
+ cancelled: "cancelled";
694
+ }>;
695
+ declare const HistoryEntrySchema: z.ZodObject<{
696
+ nodeId: z.ZodString;
697
+ action: z.ZodEnum<{
698
+ completed: "completed";
699
+ entered: "entered";
700
+ advanced: "advanced";
701
+ paused: "paused";
702
+ resumed: "resumed";
703
+ approved: "approved";
704
+ rejected: "rejected";
705
+ cancelled: "cancelled";
706
+ }>;
707
+ timestamp: z.ZodDefault<z.ZodDate>;
708
+ details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
709
+ }, z.core.$strip>;
710
+ type HistoryEntry = z.infer<typeof HistoryEntrySchema>;
711
+ /**
712
+ * N016 F9:枚举放宽(注册表 task_status / task_phase 权威)。
713
+ * 内置值常量(seed 引用 + 文档化;注册表为运行时权威)。
714
+ */
715
+ declare const TaskStatusSchema: z.ZodString;
716
+ declare const TaskPhaseSchema: z.ZodString;
717
+ declare const TASK_STATUSES: readonly ["active", "paused", "completed", "cancelled"];
718
+ declare const TASK_PHASES: readonly ["entry", "track", "test", "exit"];
719
+ declare const TaskSchema: z.ZodObject<{
720
+ id: z.ZodOptional<z.ZodString>;
721
+ taskId: z.ZodString;
722
+ title: z.ZodString;
723
+ type: z.ZodOptional<z.ZodEnum<{
724
+ feature: "feature";
725
+ bugfix: "bugfix";
726
+ "ui-tweak": "ui-tweak";
727
+ research: "research";
728
+ }>>;
729
+ projectId: z.ZodString;
730
+ dagTemplateId: z.ZodString;
731
+ dagInstance: z.ZodObject<{
732
+ templateId: z.ZodString;
733
+ templateVersion: z.ZodString;
734
+ nodes: z.ZodArray<z.ZodObject<{
735
+ id: z.ZodString;
736
+ label: z.ZodString;
737
+ phase: z.ZodString;
738
+ track: z.ZodString;
739
+ prompt: z.ZodString;
740
+ skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
741
+ }, z.core.$strip>>;
742
+ edges: z.ZodArray<z.ZodObject<{
743
+ from: z.ZodString;
744
+ to: z.ZodString;
745
+ condition: z.ZodOptional<z.ZodString>;
746
+ pausePoint: z.ZodOptional<z.ZodObject<{
747
+ type: z.ZodEnum<{
748
+ human_approval: "human_approval";
749
+ checkpoint: "checkpoint";
750
+ }>;
751
+ description: z.ZodString;
752
+ autoResume: z.ZodDefault<z.ZodBoolean>;
753
+ }, z.core.$strip>>;
754
+ }, z.core.$strip>>;
755
+ prunedNodes: z.ZodArray<z.ZodString>;
756
+ nodeStates: z.ZodRecord<z.ZodString, z.ZodObject<{
757
+ status: z.ZodString;
758
+ enteredAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
759
+ completedAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
760
+ }, z.core.$strip>>;
761
+ }, z.core.$strip>;
762
+ currentNode: z.ZodString;
763
+ currentPhase: z.ZodString;
764
+ status: z.ZodString;
765
+ pausedAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
766
+ track: z.ZodString;
767
+ doc: z.ZodOptional<z.ZodObject<{
768
+ what: z.ZodString;
769
+ why: z.ZodString;
770
+ acceptance: z.ZodDefault<z.ZodArray<z.ZodString>>;
771
+ nonGoals: z.ZodDefault<z.ZodArray<z.ZodString>>;
772
+ trackNote: z.ZodOptional<z.ZodString>;
773
+ }, z.core.$strip>>;
774
+ nodeRecords: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
775
+ summary: z.ZodOptional<z.ZodString>;
776
+ checks: z.ZodDefault<z.ZodArray<z.ZodObject<{
777
+ id: z.ZodString;
778
+ item: z.ZodString;
779
+ passed: z.ZodBoolean;
780
+ }, z.core.$strip>>>;
781
+ artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
782
+ id: z.ZodString;
783
+ type: z.ZodEnum<{
784
+ code: "code";
785
+ test: "test";
786
+ prd: "prd";
787
+ tech: "tech";
788
+ doc: "doc";
789
+ other: "other";
790
+ }>;
791
+ path: z.ZodString;
792
+ note: z.ZodOptional<z.ZodString>;
793
+ content: z.ZodOptional<z.ZodString>;
794
+ }, z.core.$strip>>>;
795
+ confirmations: z.ZodDefault<z.ZodArray<z.ZodObject<{
796
+ id: z.ZodString;
797
+ quote: z.ZodString;
798
+ at: z.ZodDate;
799
+ }, z.core.$strip>>>;
800
+ decisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
801
+ id: z.ZodString;
802
+ topic: z.ZodString;
803
+ decision: z.ZodString;
804
+ }, z.core.$strip>>>;
805
+ review: z.ZodOptional<z.ZodObject<{
806
+ verdict: z.ZodEnum<{
807
+ pass: "pass";
808
+ fail: "fail";
809
+ }>;
810
+ rounds: z.ZodNumber;
811
+ critical: z.ZodNumber;
812
+ }, z.core.$strip>>;
813
+ }, z.core.$strip>>>;
814
+ archNotes: z.ZodDefault<z.ZodArray<z.ZodObject<{
815
+ id: z.ZodString;
816
+ text: z.ZodString;
817
+ at: z.ZodDate;
818
+ }, z.core.$strip>>>;
819
+ history: z.ZodDefault<z.ZodArray<z.ZodObject<{
820
+ nodeId: z.ZodString;
821
+ action: z.ZodEnum<{
822
+ completed: "completed";
823
+ entered: "entered";
824
+ advanced: "advanced";
825
+ paused: "paused";
826
+ resumed: "resumed";
827
+ approved: "approved";
828
+ rejected: "rejected";
829
+ cancelled: "cancelled";
830
+ }>;
831
+ timestamp: z.ZodDefault<z.ZodDate>;
832
+ details: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
833
+ }, z.core.$strip>>>;
834
+ createdAt: z.ZodOptional<z.ZodDate>;
835
+ updatedAt: z.ZodOptional<z.ZodDate>;
836
+ }, z.core.$strip>;
837
+ type Task = z.infer<typeof TaskSchema>;
838
+ /**
839
+ * N020 D1:updateTask 的 patch 类型——常规字段平铺 key 之外允许点路径 key
840
+ * (如 "nodeRecords.TECH.summary")。repo 的 $set 按点路径直达嵌套字段,
841
+ * 使引擎收尾与常规字段在同一条 findOneAndUpdate 内原子写入(F02)。
842
+ * 禁止把 nodeRecords/doc/archNotes 作为嵌套对象整体放入 patch(整对象替换
843
+ * 读-改写窗口,违背小步写入模型)。
844
+ */
845
+ type TaskPatch = Partial<Task> & Record<string, unknown>;
846
+ declare const TaskCreateInputSchema: z.ZodObject<{
847
+ title: z.ZodString;
848
+ track: z.ZodString;
849
+ dagTemplateId: z.ZodString;
850
+ skipNodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
851
+ type: z.ZodOptional<z.ZodEnum<{
852
+ feature: "feature";
853
+ bugfix: "bugfix";
854
+ "ui-tweak": "ui-tweak";
855
+ research: "research";
856
+ }>>;
857
+ projectId: z.ZodOptional<z.ZodString>;
858
+ }, z.core.$strip>;
859
+ type TaskCreateInput = z.infer<typeof TaskCreateInputSchema>;
860
+
861
+ /**
862
+ * N017 F2:任务上下文(AI 推进任务的一站式查询载荷)。
863
+ * currentNode 仅 active 时非空;pausedAtEdge 仅暂停点暂停时非空(待审批边)。
864
+ */
865
+ declare const TaskContextSchema: z.ZodObject<{
866
+ task: z.ZodObject<{
867
+ taskId: z.ZodString;
868
+ title: z.ZodString;
869
+ type: z.ZodOptional<z.ZodEnum<{
870
+ feature: "feature";
871
+ bugfix: "bugfix";
872
+ "ui-tweak": "ui-tweak";
873
+ research: "research";
874
+ }>>;
875
+ currentNode: z.ZodString;
876
+ currentPhase: z.ZodString;
877
+ status: z.ZodString;
878
+ pausedAt: z.ZodNullable<z.ZodString>;
879
+ track: z.ZodString;
880
+ }, z.core.$strip>;
881
+ currentNode: z.ZodNullable<z.ZodObject<{
882
+ nodeId: z.ZodString;
883
+ label: z.ZodString;
884
+ phase: z.ZodString;
885
+ track: z.ZodString;
886
+ prompt: z.ZodString;
887
+ skills: z.ZodArray<z.ZodString>;
888
+ upcomingPause: z.ZodNullable<z.ZodString>;
889
+ }, z.core.$strip>>;
890
+ pausedAtEdge: z.ZodNullable<z.ZodObject<{
891
+ from: z.ZodString;
892
+ to: z.ZodString;
893
+ pausePoint: z.ZodObject<{
894
+ type: z.ZodEnum<{
895
+ human_approval: "human_approval";
896
+ checkpoint: "checkpoint";
897
+ }>;
898
+ description: z.ZodString;
899
+ autoResume: z.ZodDefault<z.ZodBoolean>;
900
+ }, z.core.$strip>;
901
+ }, z.core.$strip>>;
902
+ nodes: z.ZodArray<z.ZodObject<{
903
+ nodeId: z.ZodString;
904
+ label: z.ZodString;
905
+ status: z.ZodString;
906
+ enteredAt: z.ZodNullable<z.ZodDate>;
907
+ completedAt: z.ZodNullable<z.ZodDate>;
908
+ }, z.core.$strip>>;
909
+ taskDoc: z.ZodNullable<z.ZodObject<{
910
+ what: z.ZodString;
911
+ why: z.ZodString;
912
+ acceptance: z.ZodDefault<z.ZodArray<z.ZodString>>;
913
+ nonGoals: z.ZodDefault<z.ZodArray<z.ZodString>>;
914
+ trackNote: z.ZodOptional<z.ZodString>;
915
+ }, z.core.$strip>>;
916
+ nodeRecords: z.ZodRecord<z.ZodString, z.ZodObject<{
917
+ summary: z.ZodOptional<z.ZodString>;
918
+ checks: z.ZodDefault<z.ZodArray<z.ZodObject<{
919
+ id: z.ZodString;
920
+ item: z.ZodString;
921
+ passed: z.ZodBoolean;
922
+ }, z.core.$strip>>>;
923
+ artifacts: z.ZodDefault<z.ZodArray<z.ZodObject<{
924
+ id: z.ZodString;
925
+ type: z.ZodEnum<{
926
+ code: "code";
927
+ test: "test";
928
+ prd: "prd";
929
+ tech: "tech";
930
+ doc: "doc";
931
+ other: "other";
932
+ }>;
933
+ path: z.ZodString;
934
+ note: z.ZodOptional<z.ZodString>;
935
+ content: z.ZodOptional<z.ZodString>;
936
+ }, z.core.$strip>>>;
937
+ confirmations: z.ZodDefault<z.ZodArray<z.ZodObject<{
938
+ id: z.ZodString;
939
+ quote: z.ZodString;
940
+ at: z.ZodDate;
941
+ }, z.core.$strip>>>;
942
+ decisions: z.ZodDefault<z.ZodArray<z.ZodObject<{
943
+ id: z.ZodString;
944
+ topic: z.ZodString;
945
+ decision: z.ZodString;
946
+ }, z.core.$strip>>>;
947
+ review: z.ZodOptional<z.ZodObject<{
948
+ verdict: z.ZodEnum<{
949
+ pass: "pass";
950
+ fail: "fail";
951
+ }>;
952
+ rounds: z.ZodNumber;
953
+ critical: z.ZodNumber;
954
+ }, z.core.$strip>>;
955
+ }, z.core.$strip>>;
956
+ archNotes: z.ZodArray<z.ZodObject<{
957
+ id: z.ZodString;
958
+ text: z.ZodString;
959
+ at: z.ZodDate;
960
+ }, z.core.$strip>>;
961
+ }, z.core.$strip>;
962
+ type TaskContext = z.infer<typeof TaskContextSchema>;
963
+ /**
964
+ * N017 D6:任务列表概要投影——剥离 dagInstance(11 节点 prompt 全文)与 history。
965
+ * 补 createdAt:web TaskTable 消费 createdAt 列且为默认降序排序键,投影遗漏即断链。
966
+ */
967
+ declare const TaskSummarySchema: z.ZodObject<{
968
+ taskId: z.ZodString;
969
+ title: z.ZodString;
970
+ type: z.ZodOptional<z.ZodEnum<{
971
+ feature: "feature";
972
+ bugfix: "bugfix";
973
+ "ui-tweak": "ui-tweak";
974
+ research: "research";
975
+ }>>;
976
+ projectId: z.ZodString;
977
+ dagTemplateId: z.ZodString;
978
+ currentNode: z.ZodString;
979
+ currentPhase: z.ZodString;
980
+ status: z.ZodString;
981
+ pausedAt: z.ZodNullable<z.ZodString>;
982
+ track: z.ZodString;
983
+ progress: z.ZodObject<{
984
+ completed: z.ZodNumber;
985
+ total: z.ZodNumber;
986
+ }, z.core.$strip>;
987
+ createdAt: z.ZodOptional<z.ZodDate>;
988
+ updatedAt: z.ZodOptional<z.ZodDate>;
989
+ }, z.core.$strip>;
990
+ type TaskSummary = z.infer<typeof TaskSummarySchema>;
991
+
992
+ type TaskListFilter = {
993
+ status?: string;
994
+ track?: string;
995
+ projectId?: string;
996
+ page?: number;
997
+ limit?: number;
998
+ sort?: 'progress' | 'createdAt' | 'updatedAt';
999
+ };
1000
+ /**
1001
+ * N020 D1:点路径小步更新载荷。sets/pushes 的 key 均为(点)路径字符串,
1002
+ * 由路由层拼接(nodeId 已过实例校验,无注入面);单条 findOneAndUpdate 聚合
1003
+ * 执行保证 $set/$push/arrayFilters 原子生效,返回更新后实体。
1004
+ */
1005
+ interface TaskPathUpdate {
1006
+ /** $set 路径 → 值(如 { "nodeRecords.TECH.summary": "..." }) */
1007
+ sets?: Record<string, unknown>;
1008
+ /** $push 路径 → 值(如 { "nodeRecords.TECH.checks": item });$push 到不存在路径自动创建中间对象 */
1009
+ pushes?: Record<string, unknown>;
1010
+ /** arrayFilters(条目定位翻转用,如 [{ "e.id": "abc123" }]) */
1011
+ arrayFilters?: Record<string, unknown>[];
1012
+ }
1013
+ type TaskRepo = Repo<Task> & {
1014
+ /** resolvedProjectId 由路由层解析(D2:显式携带校验一致性后传入 / 缺省 = 模板 projectId),repo 不做隐式继承 */
1015
+ createTask(input: TaskCreateInput, template: DagTemplate, resolvedProjectId: string): Promise<Task>;
1016
+ getByTaskId(taskId: string): Promise<Task | null>;
1017
+ /** N015 F4/F5/F6 + N017 D6:分页 + 排序 + 进度概要投影(剥离 dagInstance/history;total 为过滤后总数) */
1018
+ listTasks(filter?: TaskListFilter): Promise<{
1019
+ items: TaskSummary[];
1020
+ total: number;
1021
+ }>;
1022
+ updateTask(taskId: string, patch: TaskPatch, cas?: {
1023
+ expectedStatus: string;
1024
+ expectedCurrentNode: string;
1025
+ }): Promise<Task>;
1026
+ /** N020 D1:小步原子写($set/$push/arrayFilters 单条聚合,见 TaskPathUpdate) */
1027
+ updateTaskPaths(taskId: string, update: TaskPathUpdate): Promise<Task>;
1028
+ };
1029
+ declare function createTaskRepo(db: Db): TaskRepo;
1030
+
1031
+ /**
1032
+ * Project Schema — 项目实体(N012)
1033
+ * 项目是 Task / DagTemplate 的归属维度;Skill / Agent 通过 scope 字段支持全局或项目专用。
1034
+ * key 是稳定锚点(迁移 / seed 用,默认项目 'default'),创建后不可变。
1035
+ */
1036
+ declare const ProjectStatusSchema: z.ZodEnum<{
1037
+ active: "active";
1038
+ archived: "archived";
1039
+ }>;
1040
+ declare const ProjectSchema: z.ZodObject<{
1041
+ id: z.ZodOptional<z.ZodString>;
1042
+ key: z.ZodString;
1043
+ name: z.ZodString;
1044
+ description: z.ZodOptional<z.ZodString>;
1045
+ status: z.ZodDefault<z.ZodEnum<{
1046
+ active: "active";
1047
+ archived: "archived";
1048
+ }>>;
1049
+ createdAt: z.ZodOptional<z.ZodDate>;
1050
+ updatedAt: z.ZodOptional<z.ZodDate>;
1051
+ }, z.core.$strip>;
1052
+ type Project = z.infer<typeof ProjectSchema>;
1053
+ type ProjectStatus = z.infer<typeof ProjectStatusSchema>;
1054
+ /**
1055
+ * 创建输入:key 可选——缺省由 core 层 generateProjectKey(name) 自动生成(D12),
1056
+ * API 调用方可显式指定(显式撞库 → 409,不静默改名)。
1057
+ */
1058
+ declare const ProjectCreateSchema: z.ZodObject<{
1059
+ key: z.ZodOptional<z.ZodString>;
1060
+ name: z.ZodString;
1061
+ description: z.ZodOptional<z.ZodString>;
1062
+ }, z.core.$strip>;
1063
+ type ProjectCreate = z.infer<typeof ProjectCreateSchema>;
1064
+ /**
1065
+ * 更新输入:不含 key(key 是锚点字段,创建后不可变,F6 精神)。
1066
+ */
1067
+ declare const ProjectUpdateSchema: z.ZodObject<{
1068
+ name: z.ZodOptional<z.ZodString>;
1069
+ description: z.ZodOptional<z.ZodString>;
1070
+ status: z.ZodOptional<z.ZodEnum<{
1071
+ active: "active";
1072
+ archived: "archived";
1073
+ }>>;
1074
+ }, z.core.$strip>;
1075
+ type ProjectUpdate = z.infer<typeof ProjectUpdateSchema>;
1076
+
1077
+ type ProjectRepo = Repo<Project> & {
1078
+ getByKey(key: string): Promise<Project | null>;
1079
+ /** 创建项目:key 缺省时由 name 自动生成(D12);显式 key 撞库 → 409(不静默改名),生成碰撞 → 后缀重试(上限 3) */
1080
+ createProject(data: ProjectCreate): Promise<Project>;
1081
+ };
1082
+ /** 默认项目锚点 key(seed / 迁移用,禁止停用) */
1083
+ declare const DEFAULT_PROJECT_KEY = "default";
1084
+ /**
1085
+ * 从项目名生成 kebab-case key(D12 / F-2R1):
1086
+ * 仅取 ASCII [a-z0-9] 段(CJK 等非 ASCII 全部丢弃),连字符拼接,截断至 31 字符;
1087
+ * 有效段不足(如纯中文名)→ 回退 `project-<新 ObjectId hex 前 8 位>`。
1088
+ */
1089
+ declare function generateProjectKey(name: string): string;
1090
+ declare function createProjectRepo(db: Db): ProjectRepo;
1091
+
1092
+ /**
1093
+ * ModelAlias Schema — 模型映射(N013 F3)
1094
+ * siming code → 展示名 + 真实模型标识 的全局映射表;
1095
+ * Agent.model 存 siming code(写路径三重保障:schema kebab 格式 → handler 存在性校验 → 删除端禁删兜底)。
1096
+ * 全局实体:无 scope/projectId(与项目维度正交)。
1097
+ */
1098
+ /**
1099
+ * siming code 格式:kebab-case(与 skill name 同款 regex,口径独立声明)
1100
+ */
1101
+ declare const SIMING_CODE_REGEX: RegExp;
1102
+ declare const ModelAliasShapeSchema: z.ZodObject<{
1103
+ id: z.ZodOptional<z.ZodString>;
1104
+ code: z.ZodString;
1105
+ name: z.ZodString;
1106
+ realModel: z.ZodString;
1107
+ createdAt: z.ZodOptional<z.ZodDate>;
1108
+ updatedAt: z.ZodOptional<z.ZodDate>;
1109
+ }, z.core.$strip>;
1110
+ declare const ModelAliasSchema: z.ZodObject<{
1111
+ id: z.ZodOptional<z.ZodString>;
1112
+ code: z.ZodString;
1113
+ name: z.ZodString;
1114
+ realModel: z.ZodString;
1115
+ createdAt: z.ZodOptional<z.ZodDate>;
1116
+ updatedAt: z.ZodOptional<z.ZodDate>;
1117
+ }, z.core.$strip>;
1118
+ type ModelAlias = z.infer<typeof ModelAliasSchema>;
1119
+ /** 创建输入:三字段必填(无 default 无 refine → 无 Zod4 UpdateSchema 派生陷阱) */
1120
+ declare const ModelAliasCreateSchema: z.ZodObject<{
1121
+ name: z.ZodString;
1122
+ code: z.ZodString;
1123
+ realModel: z.ZodString;
1124
+ }, z.core.$strip>;
1125
+ type ModelAliasCreate = z.infer<typeof ModelAliasCreateSchema>;
1126
+ /**
1127
+ * 更新输入(PUT partial)。独立 object 不从实体派生:
1128
+ * code optional 仅用于 D4 显式拒绝检测(code≠param → 409 MODEL_CODE_IMMUTABLE),非可更新字段;
1129
+ * name/realModel 为真正可更新字段。
1130
+ */
1131
+ declare const ModelAliasUpdateSchema: z.ZodObject<{
1132
+ code: z.ZodOptional<z.ZodString>;
1133
+ name: z.ZodOptional<z.ZodString>;
1134
+ realModel: z.ZodOptional<z.ZodString>;
1135
+ }, z.core.$strip>;
1136
+ type ModelAliasUpdate = z.infer<typeof ModelAliasUpdateSchema>;
1137
+ /** 列表项:实体 + 引用计数($lookup 聚合产出,D3) */
1138
+ declare const ModelAliasWithRefCountSchema: z.ZodObject<{
1139
+ id: z.ZodOptional<z.ZodString>;
1140
+ code: z.ZodString;
1141
+ name: z.ZodString;
1142
+ realModel: z.ZodString;
1143
+ createdAt: z.ZodOptional<z.ZodDate>;
1144
+ updatedAt: z.ZodOptional<z.ZodDate>;
1145
+ refCount: z.ZodNumber;
1146
+ }, z.core.$strip>;
1147
+ type ModelAliasWithRefCount = z.infer<typeof ModelAliasWithRefCountSchema>;
1148
+
1149
+ type ModelAliasRepo = Repo<ModelAlias> & {
1150
+ /** 列表 + 引用计数($lookup 单往返,D3);结果逐条套 toEntity 保持 _id→id 形状一致 */
1151
+ listWithRefCount(): Promise<ModelAliasWithRefCount[]>;
1152
+ getByCode(code: string): Promise<ModelAlias | null>;
1153
+ createModelAlias(data: ModelAliasCreate): Promise<ModelAlias>;
1154
+ updateByCode(code: string, patch: {
1155
+ name?: string;
1156
+ realModel?: string;
1157
+ }): Promise<ModelAlias | null>;
1158
+ /** 有引用禁删(F3):refCount>0 → 409 MODEL_ALIAS_IN_USE(message 附计数) */
1159
+ deleteByCode(code: string): Promise<boolean>;
1160
+ };
1161
+ declare function createModelAliasRepo(db: Db): ModelAliasRepo;
1162
+ /**
1163
+ * Agent.model 存在性共用守卫(D1,沿 assertBoundSkillsCompatible 模式)。
1164
+ * check-then-act 非原子(ACCEPTED-RISK:Phase-1 单用户不引入事务,见技术方案 §2.2 并发边界)。
1165
+ */
1166
+ declare function assertModelAliasExists(repo: ModelAliasRepo, code: string): Promise<void>;
1167
+
1168
+ /**
1169
+ * 枚举注册表 Schema(N016 D1/D4/D5)
1170
+ * settings-as-truth:7 类业务枚举(dag_phase / dag_track / pause_type /
1171
+ * task_status / node_status / skill_category / scope)由 DB 注册表维护,消费端(web 下拉 /
1172
+ * CLI 校验 / server validator)从注册表读取,消除硬编码漂移。
1173
+ * N017 F8:gate_type 类整体退役(gates 机制删除后无引用方)。
1174
+ *
1175
+ * 设计要点:
1176
+ * - 每类一个 document(category + entries 数组),避免 N+1 查询;
1177
+ * - entry 结构 {value, label, color?, order, builtin, active}:
1178
+ * - value:领域层存库的原始枚举值(引擎/DB 消费,不可臆造);
1179
+ * - label:展示文案(消费端下拉直接取用,消除 NodeEditDrawer 标签漂移);
1180
+ * - color:可选 UI 语义色 token(如 --success);
1181
+ * - order:下拉排序;builtin:内置值(禁删,D8);active:启停(禁用值下拉不可选,D8)。
1182
+ */
1183
+ /** 7 类注册表 category 白名单(D4:固定分类,不可增删) */
1184
+ declare const EnumRegistryCategorySchema: z.ZodEnum<{
1185
+ scope: "scope";
1186
+ dag_phase: "dag_phase";
1187
+ dag_track: "dag_track";
1188
+ pause_type: "pause_type";
1189
+ task_status: "task_status";
1190
+ node_status: "node_status";
1191
+ skill_category: "skill_category";
1192
+ }>;
1193
+ type EnumRegistryCategory = z.infer<typeof EnumRegistryCategorySchema>;
1194
+ /** 注册表条目(D5) */
1195
+ declare const EnumEntrySchema: z.ZodObject<{
1196
+ value: z.ZodString;
1197
+ label: z.ZodString;
1198
+ color: z.ZodOptional<z.ZodString>;
1199
+ order: z.ZodDefault<z.ZodNumber>;
1200
+ builtin: z.ZodDefault<z.ZodBoolean>;
1201
+ active: z.ZodDefault<z.ZodBoolean>;
1202
+ }, z.core.$strip>;
1203
+ type EnumEntry = z.infer<typeof EnumEntrySchema>;
1204
+ /** 注册表文档(每类一个) */
1205
+ declare const EnumRegistrySchema: z.ZodObject<{
1206
+ id: z.ZodOptional<z.ZodString>;
1207
+ category: z.ZodEnum<{
1208
+ scope: "scope";
1209
+ dag_phase: "dag_phase";
1210
+ dag_track: "dag_track";
1211
+ pause_type: "pause_type";
1212
+ task_status: "task_status";
1213
+ node_status: "node_status";
1214
+ skill_category: "skill_category";
1215
+ }>;
1216
+ entries: z.ZodDefault<z.ZodArray<z.ZodObject<{
1217
+ value: z.ZodString;
1218
+ label: z.ZodString;
1219
+ color: z.ZodOptional<z.ZodString>;
1220
+ order: z.ZodDefault<z.ZodNumber>;
1221
+ builtin: z.ZodDefault<z.ZodBoolean>;
1222
+ active: z.ZodDefault<z.ZodBoolean>;
1223
+ }, z.core.$strip>>>;
1224
+ updatedAt: z.ZodOptional<z.ZodDate>;
1225
+ }, z.core.$strip>;
1226
+ type EnumRegistry = z.infer<typeof EnumRegistrySchema>;
1227
+ /**
1228
+ * 更新输入(PUT partial):仅 entries 可更新(category 固定 = URL param)。
1229
+ * 独立 object 不派生(避免 Zod4 UpdateSchema 派生陷阱);entry 校验走 EnumEntrySchema。
1230
+ */
1231
+ declare const EnumRegistryUpdateSchema: z.ZodObject<{
1232
+ entries: z.ZodArray<z.ZodObject<{
1233
+ value: z.ZodString;
1234
+ label: z.ZodString;
1235
+ color: z.ZodOptional<z.ZodString>;
1236
+ order: z.ZodDefault<z.ZodNumber>;
1237
+ builtin: z.ZodDefault<z.ZodBoolean>;
1238
+ active: z.ZodDefault<z.ZodBoolean>;
1239
+ }, z.core.$strip>>;
1240
+ }, z.core.$strip>;
1241
+ type EnumRegistryUpdate = z.infer<typeof EnumRegistryUpdateSchema>;
1242
+
1243
+ type EnumRegistryRepo = Repo<EnumRegistry> & {
1244
+ /** 全量 7 类(SettingsPage 一次性加载;N017 删 gate_type 后由 8 类收窄) */
1245
+ listRegistries(): Promise<EnumRegistry[]>;
1246
+ /** 单类(按 category) */
1247
+ getRegistry(category: EnumRegistryCategory): Promise<EnumRegistry | null>;
1248
+ /** 单类缺省 → 空 entries(消费端兜底,不抛错) */
1249
+ getEntries(category: EnumRegistryCategory): Promise<EnumRegistry['entries']>;
1250
+ /**
1251
+ * 更新单类 entries(D8 服务端强制):
1252
+ * - builtin=true 的 entry 不可删(value 缺失即删除意图)→ 409 ENUM_ENTRY_BUILTIN
1253
+ * - builtin=true 的 entry value 不可改 → 409 ENUM_ENTRY_BUILTIN
1254
+ * - 非 builtin entry 不可升级为 builtin → 409 ENUM_ENTRY_BUILTIN
1255
+ * - 被业务资源引用的 entry 不可停用(active=false)→ 409 ENUM_ENTRY_IN_USE
1256
+ * - active=false 的 entry 可删(历史数据仍可读,仅新选择不可用)
1257
+ */
1258
+ updateRegistry(category: EnumRegistryCategory, patch: EnumRegistryUpdate): Promise<EnumRegistry | null>;
1259
+ /**
1260
+ * 删除单个 entry(D8 服务端强制):
1261
+ * - builtin=true → 409 ENUM_ENTRY_BUILTIN
1262
+ * - 被业务资源引用(dag_templates nodes.phase/track、skills.category、tasks.status/dagInstance.nodeStates.status)→ 409 ENUM_ENTRY_IN_USE(附引用计数)
1263
+ * - 目标不存在 → 404
1264
+ */
1265
+ deleteEntry(category: EnumRegistryCategory, value: string): Promise<boolean>;
1266
+ };
1267
+ declare function createEnumRegistryRepo(db: Db): EnumRegistryRepo;
1268
+
1269
+ /**
1270
+ * Advance / Approve 相关 Schemas
1271
+ *
1272
+ * N017 D5:审批(人工决策)与推进(节点完成)拆为两个动作——
1273
+ * advance 请求体变可选 {note?}(原 gateResults 数组删除);
1274
+ * 新增独立 ApproveRequest/ApproveResponse。
1275
+ */
1276
+ /**
1277
+ * N017 F8:gate 机制退役——advance 只是"当前节点完成,按出边流转"。
1278
+ * N020 D1:轻量收尾——note 为可选历史备注;summary 为可选收尾摘要
1279
+ * (写入 nodeRecords.<node>.summary,内容主体已在执行期间小步落库)。
1280
+ */
1281
+ declare const AdvanceRequestSchema: z.ZodObject<{
1282
+ note: z.ZodOptional<z.ZodString>;
1283
+ summary: z.ZodOptional<z.ZodString>;
1284
+ }, z.core.$strip>;
1285
+ type AdvanceRequest = z.infer<typeof AdvanceRequestSchema>;
1286
+ /** 暂停点审批:approved=通过并流转;rejected=驳回保持 paused(comment 为决策说明) */
1287
+ declare const ApproveRequestSchema: z.ZodObject<{
1288
+ decision: z.ZodEnum<{
1289
+ approved: "approved";
1290
+ rejected: "rejected";
1291
+ }>;
1292
+ comment: z.ZodOptional<z.ZodString>;
1293
+ }, z.core.$strip>;
1294
+ type ApproveRequest = z.infer<typeof ApproveRequestSchema>;
1295
+ declare const TaskPublicSchema: z.ZodObject<{
1296
+ taskId: z.ZodString;
1297
+ title: z.ZodString;
1298
+ type: z.ZodOptional<z.ZodEnum<{
1299
+ feature: "feature";
1300
+ bugfix: "bugfix";
1301
+ "ui-tweak": "ui-tweak";
1302
+ research: "research";
1303
+ }>>;
1304
+ currentNode: z.ZodString;
1305
+ currentPhase: z.ZodString;
1306
+ status: z.ZodString;
1307
+ pausedAt: z.ZodNullable<z.ZodString>;
1308
+ track: z.ZodString;
1309
+ }, z.core.$strip>;
1310
+ type TaskPublic = z.infer<typeof TaskPublicSchema>;
1311
+ /** N017 F8:删 gates;upcomingPause 语义改为"完成当前节点后出边上的暂停点描述"(经 findNextEdge 按轨选边) */
1312
+ declare const NodeInfoSchema: z.ZodObject<{
1313
+ nodeId: z.ZodString;
1314
+ label: z.ZodString;
1315
+ track: z.ZodString;
1316
+ prompt: z.ZodString;
1317
+ skills: z.ZodArray<z.ZodString>;
1318
+ upcomingPause: z.ZodNullable<z.ZodString>;
1319
+ }, z.core.$strip>;
1320
+ type NodeInfo = z.infer<typeof NodeInfoSchema>;
1321
+ /** N017 D7:删 gate_failed 分支(union 收窄为 advanced / paused / completed);paused 分支 pausePoint 类型改 EdgePausePoint */
1322
+ declare const AdvanceResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1323
+ status: z.ZodLiteral<"advanced">;
1324
+ task: z.ZodObject<{
1325
+ taskId: z.ZodString;
1326
+ title: z.ZodString;
1327
+ type: z.ZodOptional<z.ZodEnum<{
1328
+ feature: "feature";
1329
+ bugfix: "bugfix";
1330
+ "ui-tweak": "ui-tweak";
1331
+ research: "research";
1332
+ }>>;
1333
+ currentNode: z.ZodString;
1334
+ currentPhase: z.ZodString;
1335
+ status: z.ZodString;
1336
+ pausedAt: z.ZodNullable<z.ZodString>;
1337
+ track: z.ZodString;
1338
+ }, z.core.$strip>;
1339
+ nextNode: z.ZodObject<{
1340
+ nodeId: z.ZodString;
1341
+ label: z.ZodString;
1342
+ track: z.ZodString;
1343
+ prompt: z.ZodString;
1344
+ skills: z.ZodArray<z.ZodString>;
1345
+ upcomingPause: z.ZodNullable<z.ZodString>;
1346
+ }, z.core.$strip>;
1347
+ }, z.core.$strip>, z.ZodObject<{
1348
+ status: z.ZodLiteral<"paused">;
1349
+ task: z.ZodObject<{
1350
+ taskId: z.ZodString;
1351
+ title: z.ZodString;
1352
+ type: z.ZodOptional<z.ZodEnum<{
1353
+ feature: "feature";
1354
+ bugfix: "bugfix";
1355
+ "ui-tweak": "ui-tweak";
1356
+ research: "research";
1357
+ }>>;
1358
+ currentNode: z.ZodString;
1359
+ currentPhase: z.ZodString;
1360
+ status: z.ZodString;
1361
+ pausedAt: z.ZodNullable<z.ZodString>;
1362
+ track: z.ZodString;
1363
+ }, z.core.$strip>;
1364
+ pausePoint: z.ZodObject<{
1365
+ type: z.ZodEnum<{
1366
+ human_approval: "human_approval";
1367
+ checkpoint: "checkpoint";
1368
+ }>;
1369
+ description: z.ZodString;
1370
+ autoResume: z.ZodDefault<z.ZodBoolean>;
1371
+ }, z.core.$strip>;
1372
+ guidance: z.ZodString;
1373
+ }, z.core.$strip>, z.ZodObject<{
1374
+ status: z.ZodLiteral<"completed">;
1375
+ task: z.ZodObject<{
1376
+ taskId: z.ZodString;
1377
+ title: z.ZodString;
1378
+ type: z.ZodOptional<z.ZodEnum<{
1379
+ feature: "feature";
1380
+ bugfix: "bugfix";
1381
+ "ui-tweak": "ui-tweak";
1382
+ research: "research";
1383
+ }>>;
1384
+ currentNode: z.ZodString;
1385
+ currentPhase: z.ZodString;
1386
+ status: z.ZodString;
1387
+ pausedAt: z.ZodNullable<z.ZodString>;
1388
+ track: z.ZodString;
1389
+ }, z.core.$strip>;
1390
+ }, z.core.$strip>], "status">;
1391
+ type AdvanceResponse = z.infer<typeof AdvanceResponseSchema>;
1392
+ declare const ApproveResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1393
+ status: z.ZodLiteral<"advanced">;
1394
+ task: z.ZodObject<{
1395
+ taskId: z.ZodString;
1396
+ title: z.ZodString;
1397
+ type: z.ZodOptional<z.ZodEnum<{
1398
+ feature: "feature";
1399
+ bugfix: "bugfix";
1400
+ "ui-tweak": "ui-tweak";
1401
+ research: "research";
1402
+ }>>;
1403
+ currentNode: z.ZodString;
1404
+ currentPhase: z.ZodString;
1405
+ status: z.ZodString;
1406
+ pausedAt: z.ZodNullable<z.ZodString>;
1407
+ track: z.ZodString;
1408
+ }, z.core.$strip>;
1409
+ nextNode: z.ZodObject<{
1410
+ nodeId: z.ZodString;
1411
+ label: z.ZodString;
1412
+ track: z.ZodString;
1413
+ prompt: z.ZodString;
1414
+ skills: z.ZodArray<z.ZodString>;
1415
+ upcomingPause: z.ZodNullable<z.ZodString>;
1416
+ }, z.core.$strip>;
1417
+ }, z.core.$strip>, z.ZodObject<{
1418
+ status: z.ZodLiteral<"rejected">;
1419
+ task: z.ZodObject<{
1420
+ taskId: z.ZodString;
1421
+ title: z.ZodString;
1422
+ type: z.ZodOptional<z.ZodEnum<{
1423
+ feature: "feature";
1424
+ bugfix: "bugfix";
1425
+ "ui-tweak": "ui-tweak";
1426
+ research: "research";
1427
+ }>>;
1428
+ currentNode: z.ZodString;
1429
+ currentPhase: z.ZodString;
1430
+ status: z.ZodString;
1431
+ pausedAt: z.ZodNullable<z.ZodString>;
1432
+ track: z.ZodString;
1433
+ }, z.core.$strip>;
1434
+ guidance: z.ZodString;
1435
+ }, z.core.$strip>, z.ZodObject<{
1436
+ status: z.ZodLiteral<"completed">;
1437
+ task: z.ZodObject<{
1438
+ taskId: z.ZodString;
1439
+ title: z.ZodString;
1440
+ type: z.ZodOptional<z.ZodEnum<{
1441
+ feature: "feature";
1442
+ bugfix: "bugfix";
1443
+ "ui-tweak": "ui-tweak";
1444
+ research: "research";
1445
+ }>>;
1446
+ currentNode: z.ZodString;
1447
+ currentPhase: z.ZodString;
1448
+ status: z.ZodString;
1449
+ pausedAt: z.ZodNullable<z.ZodString>;
1450
+ track: z.ZodString;
1451
+ }, z.core.$strip>;
1452
+ }, z.core.$strip>], "status">;
1453
+ type ApproveResponse = z.infer<typeof ApproveResponseSchema>;
1454
+ declare const PauseRequestSchema: z.ZodObject<{
1455
+ reason: z.ZodOptional<z.ZodString>;
1456
+ }, z.core.$strip>;
1457
+ type PauseRequest = z.infer<typeof PauseRequestSchema>;
1458
+ declare const ResumeRequestSchema: z.ZodObject<{
1459
+ decision: z.ZodOptional<z.ZodString>;
1460
+ }, z.core.$strip>;
1461
+ type ResumeRequest = z.infer<typeof ResumeRequestSchema>;
1462
+
1463
+ /**
1464
+ * 服务配置 schema(N018 D5):Zod 单一真相源,core 只承载纯 schema + env 键映射,
1465
+ * 零 fs/process I/O(保持 core 领域纯净)。JSONC 文件加载/分层合并/来源追踪的 loader 在
1466
+ * @siming-org/cli(src/config/server-config-loader.ts);env 层适配在 @siming-org/server(src/config/env.ts)。
1467
+ *
1468
+ * 优先级链(N018 §3.4):CLI 参数 > 环境变量 > 用户级 > 系统级 > 内置默认值(按 key 浅合并)。
1469
+ */
1470
+ declare const SimingLogLevelSchema: z.ZodEnum<{
1471
+ error: "error";
1472
+ debug: "debug";
1473
+ info: "info";
1474
+ warn: "warn";
1475
+ }>;
1476
+ declare const SimingConfigSchema: z.ZodObject<{
1477
+ mongoUri: z.ZodDefault<z.ZodString>;
1478
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
1479
+ host: z.ZodDefault<z.ZodString>;
1480
+ logLevel: z.ZodDefault<z.ZodEnum<{
1481
+ error: "error";
1482
+ debug: "debug";
1483
+ info: "info";
1484
+ warn: "warn";
1485
+ }>>;
1486
+ auth: z.ZodOptional<z.ZodUnknown>;
1487
+ cors: z.ZodOptional<z.ZodUnknown>;
1488
+ }, z.core.$strip>;
1489
+ type SimingConfig = z.infer<typeof SimingConfigSchema>;
1490
+ /** 可经环境变量/CLI 参数/配置文件配置的 key(预留字段 auth/cors 除外) */
1491
+ declare const SIMING_CONFIG_KEYS: readonly ["mongoUri", "port", "host", "logLevel"];
1492
+ type SimingConfigKey = (typeof SIMING_CONFIG_KEYS)[number];
1493
+ /**
1494
+ * env 键映射单源(N018 D5):server env resolver 与 cli loader 共用,
1495
+ * 避免 SIMING_HOST/PORT 等键名在两处漂移。PORT 是通用键名(非 SIMING_* 前缀),
1496
+ * 沿用既有 server EnvSchema 约定(见 ENVIRONMENT.md)。
1497
+ */
1498
+ declare const SIMING_CONFIG_ENV_KEYS: Record<SimingConfigKey, string>;
1499
+
1500
+ /**
1501
+ * Domain error types — thrown by core business logic, caught by server's app.onError().
1502
+ */
1503
+ /** N012 语义化业务错误码(可选挂载到 AppError 子类;HTTP 形状向后兼容:error 字段缺省仍为 http 级 code) */
1504
+ type BizCode = 'PROJECT_ARCHIVED' | 'TEMPLATE_PROJECT_MISMATCH' | 'TEMPLATE_PROJECT_IMMUTABLE' | 'SCOPE_IMMUTABLE' | 'TASK_PROJECT_IMMUTABLE' | 'DEFAULT_PROJECT_IMMUTABLE' | 'TEMPLATE_NAME_CONFLICT' | 'PROJECT_NOT_FOUND' | 'AGENT_SKILL_SCOPE_CONFLICT' | 'MODEL_CODE_EXISTS' | 'MODEL_CODE_IMMUTABLE' | 'MODEL_ALIAS_IN_USE' | 'ENUM_ENTRY_BUILTIN' | 'ENUM_ENTRY_IN_USE' | 'ENUM_VALUE_CONFLICT' | 'NAME_SCOPE_CONFLICT' | 'TASK_DOC_NOT_SET' | 'TASK_DOC_NOT_FOUND' | 'TASK_DOC_SECTION_NOT_FOUND' | 'TASK_AT_PAUSE_POINT' | 'TASK_NOT_AT_PAUSE_POINT' | 'NODE_NOT_IN_INSTANCE' | 'CHECK_NOT_FOUND' | 'NODE_RECORD_NOT_WRITABLE' | 'TASK_TERMINATED' | 'TASK_PRUNE_GRAPH_INVALID' | 'TASK_SKIP_NODE_NOT_FOUND' | 'TASK_TYPE_TRACK_MISMATCH';
1505
+ /** bizCode → 用户可读中文 message(单一真相源,路由层抛错时引用) */
1506
+ declare const BIZ_CODE_MESSAGES: Record<BizCode, string>;
1507
+ interface AppErrorOptions {
1508
+ /** 语义化业务错误码(输出到 response.error,覆盖 http 级 code) */
1509
+ bizCode?: BizCode;
1510
+ /** 自定义 message(缺省沿用子类模板串;传入覆盖,通常配 BIZ_CODE_MESSAGES 使用) */
1511
+ message?: string;
1512
+ }
1513
+ declare abstract class AppError extends Error {
1514
+ abstract readonly statusCode: number;
1515
+ abstract readonly code: string;
1516
+ abstract toResponse(): Record<string, unknown>;
1517
+ }
1518
+ declare class NotFoundError extends AppError {
1519
+ readonly resource: string;
1520
+ readonly id: string;
1521
+ readonly statusCode = 404;
1522
+ readonly code = "not_found";
1523
+ constructor(resource: string, id: string, options?: AppErrorOptions);
1524
+ readonly bizCode?: BizCode;
1525
+ toResponse(): {
1526
+ error: string;
1527
+ message: string;
1528
+ resource: string;
1529
+ id: string;
1530
+ };
1531
+ }
1532
+ declare class BadRequestError extends AppError {
1533
+ readonly field?: string | undefined;
1534
+ readonly statusCode = 400;
1535
+ readonly code = "bad_request";
1536
+ constructor(message: string, field?: string | undefined, options?: AppErrorOptions);
1537
+ readonly bizCode?: BizCode;
1538
+ toResponse(): {
1539
+ field?: string;
1540
+ error: string;
1541
+ message: string;
1542
+ };
1543
+ }
1544
+ declare class ConflictError extends AppError {
1545
+ readonly resource: string;
1546
+ readonly id: string;
1547
+ readonly statusCode = 409;
1548
+ readonly code = "conflict";
1549
+ constructor(resource: string, id: string, options?: AppErrorOptions);
1550
+ readonly bizCode?: BizCode;
1551
+ toResponse(): {
1552
+ error: string;
1553
+ message: string;
1554
+ resource: string;
1555
+ id: string;
1556
+ };
1557
+ }
1558
+ declare class ValidationError extends AppError {
1559
+ readonly issues: unknown[];
1560
+ readonly statusCode = 422;
1561
+ readonly code = "validation_error";
1562
+ readonly bizCode?: BizCode;
1563
+ constructor(message: string, issues: unknown[], options?: AppErrorOptions);
1564
+ toResponse(): {
1565
+ error: string;
1566
+ message: string;
1567
+ issues: unknown[];
1568
+ };
1569
+ }
1570
+
1571
+ /**
1572
+ * N017 F8 流转引擎(新语义状态机,见技术方案 §2.2):
1573
+ *
1574
+ * active --advance--> active 出边无暂停 / checkpoint(autoResume)
1575
+ * active --advance--> paused 出边 pausePoint human_approval(pausedAt=from 节点)
1576
+ * active --advance--> completed 无出边且全终端完成(END 哨兵收敛)
1577
+ * paused --approve(approved)--> active 重推导边流转(含 to=END)
1578
+ * paused --approve(rejected)--> paused 记录 rejected 历史
1579
+ * active --pause()--> paused(手动, pausedAt=null) --resume()--> active
1580
+ *
1581
+ * gate 校验循环 / crossPausePoint / gate_failed 分支随 gates 机制整体退役。
1582
+ * N020 D1:advance 为轻量收尾 {summary?, note?}——记录内容已在执行期间经
1583
+ * 小步写端点落库,summary 用点路径 key 并入同条 findOneAndUpdate(F02)。
1584
+ */
1585
+ interface AdvanceDeps {
1586
+ getTask(taskId: string): Promise<Task | null>;
1587
+ updateTask(taskId: string,
1588
+ /** 常规字段平铺 key + N020 点路径 key("nodeRecords.<node>.summary")——同条 $set 原子合并 */
1589
+ patch: TaskPatch, cas?: {
1590
+ expectedStatus: string;
1591
+ expectedCurrentNode: string;
1592
+ }): Promise<Task>;
1593
+ }
1594
+ interface AdvanceInput {
1595
+ /** 节点完成备注(记入历史,可选) */
1596
+ note?: string;
1597
+ /**
1598
+ * 节点收尾摘要(N020 D1,可选):写入 nodeRecords.<node>.summary。
1599
+ * 收尾便捷参数——等价收尾前最后一次 `record set --summary`,后者覆盖前者
1600
+ * (同一 $set 目标,F12 双入口分工无冲突)。
1601
+ */
1602
+ summary?: string;
1603
+ }
1604
+ declare function advanceTask(deps: AdvanceDeps, taskId: string, input?: AdvanceInput): Promise<AdvanceResponse>;
1605
+ declare function approveTask(deps: AdvanceDeps, taskId: string, request: ApproveRequest): Promise<ApproveResponse>;
1606
+ declare function pauseTask(deps: AdvanceDeps, taskId: string, reason?: string): Promise<Task>;
1607
+ declare function resumeTask(deps: AdvanceDeps, taskId: string, decision?: string): Promise<Task>;
1608
+ /**
1609
+ * @internal 供单测直接验证的模块私有 helper(非公共 API)
1610
+ * N017:findNextNode → findNextEdge——返回边对象(调用方需要 pausePoint)
1611
+ * T202608240003:单轨匹配扩展为匹配集(mixed → {backend,ui,all},trackMatchSet 单源);
1612
+ * 多匹配消歧(判定顺序固定,防止 D6 保护成为不可达分支):
1613
+ * a. 按目标 track 值分组查重——任一分组 > 1 条 → D6 报错(模板同轨分叉)
1614
+ * b. 存在专属候选边(目标 track ≠ 'all')→ 全部专属候选中按模板边声明序取第一条
1615
+ * c. 无专属候选 → 取 all 边(唯一性已由 a 的分组查重保证)
1616
+ * 单轨任务匹配集合与旧逻辑逐字等价({track,'all'})且无多匹配出边 → 行为不变(兼容)。
1617
+ * 注意:消歧对单轨同样生效——「同轨专属边 + all 边」混合多匹配时取专属边(D4 意图),
1618
+ * 仅「同一 track 值多条边」维持 D6 报错(真分叉模板错误)。
1619
+ */
1620
+ declare function findNextEdge(edges: DagEdge[], nodes: Pick<DagNode, 'id' | 'track'>[], fromNodeId: string, track: string): DagEdge | null;
1621
+ /** @internal 供单测直接验证的模块私有 helper(非公共 API) */
1622
+ declare function checkTermination(nodes: DagNode[], edges: {
1623
+ from: string;
1624
+ to: string;
1625
+ condition?: string | undefined;
1626
+ }[], nodeStates: Record<string, NodeState>, upcomingCompletedState: NodeState, upcomingCompletedNodeId: string, track: string): boolean;
1627
+ /** @internal 供单测直接验证的模块私有 helper(非公共 API) */
1628
+ declare function toTaskPublic(task: Task): TaskPublic;
1629
+ /**
1630
+ * @internal 供单测直接验证的模块私有 helper(非公共 API)
1631
+ * N017:upcomingPause 经 findNextEdge 按轨选边后取该边 pausePoint——多出边节点(如
1632
+ * TECH→BACKEND/COMPONENT)禁止取首条出边,否则 backend 任务可能显示 ui 边的暂停点描述。
1633
+ */
1634
+ declare function toNodeInfo(node: DagNode, task: Task): NodeInfo;
1635
+ /** @internal 供单测直接验证的模块私有 helper(非公共 API) */
1636
+ declare function mkHistory(nodeId: string, action: HistoryEntry['action'], details: Record<string, unknown>): HistoryEntry;
1637
+
1638
+ /**
1639
+ * T202608240003 创建时剪枝(技术方案 §2.2):
1640
+ *
1641
+ * 任务创建时按「轨道自动剔除 ∪ 显式 skip」把模板实例化成定死路径——
1642
+ * 类型→路径映射由 task-create skill 持有(唯一真相源),平台只收
1643
+ * track + skipNodes 显式清单;本模块负责机械执行 + 图完整性校验。
1644
+ *
1645
+ * 管线:轨道剔除 → 显式剔除 → 删边 → 桥接(断链补边,pausePoint 继承)
1646
+ * → 图校验(6 条 fail-fast,a-f)。纯函数无 I/O,repo.createTask 调用后组装 dagInstance。
1647
+ */
1648
+ /** 剪枝结果:剩余节点/边(含桥接边)+ 被剪清单 + 入口节点 */
1649
+ interface PruneResult {
1650
+ nodes: DagNode[];
1651
+ edges: DagEdge[];
1652
+ prunedNodes: string[];
1653
+ entryNode: DagNode;
1654
+ }
1655
+ /**
1656
+ * 剪枝主函数(技术方案 §2.2 六步)。
1657
+ *
1658
+ * @param template 模板全量快照(nodes/edges)
1659
+ * @param taskTrack 任务轨道(注册表合法值,含 mixed/research)
1660
+ * @param skipNodeIds 显式剔除清单(skill 映射矩阵产物)
1661
+ */
1662
+ declare function pruneInstance(template: DagTemplate, taskTrack: string, skipNodeIds: string[]): PruneResult;
1663
+
1664
+ /**
1665
+ * T202608240003:任务轨道 → 实例节点 track 匹配集。
1666
+ * 独立单源模块——prune(剪枝轨道剔除 + 引擎路径可达性校验)与 advance-engine
1667
+ * (流转路由 + 终止判定)消费同一语义,防止剪枝与路由口径漂移。
1668
+ */
1669
+ /**
1670
+ * - backend/ui/research:匹配本轨道节点 + 'all' 哨兵
1671
+ * - mixed:匹配双轨道节点 + 'all'(两链串行,链序由引擎消歧的模板边声明序决定)
1672
+ * - 自定义轨道(注册表运行时权威):匹配本轨道 + 'all'(机械剪枝,语义自洽)
1673
+ */
1674
+ declare function trackMatchSet(taskTrack: string): ReadonlySet<string>;
1675
+
1676
+ /**
1677
+ * N020 D1:条目短 id 生成(服务端权威,客户端永不指定)。
1678
+ *
1679
+ * 6 位 base36(36^6 ≈ 21 亿空间)对单 record 内条目数(个位~十位)碰撞概率
1680
+ * 可忽略;仍带同容器查重重试(fail-safe)。条目定位/翻转(arrayFilters `e.id`)
1681
+ * 全部走服务端 id,不用数组 index(并发追加下不稳定,决策 6)。
1682
+ */
1683
+ /** 生成同容器内不重复的 6 位 base36 短 id(existing = 同 record 内已有条目 id) */
1684
+ declare function generateEntryId(existing: readonly string[]): string;
1685
+
1686
+ /**
1687
+ * 渲染节点 prompt 模板变量。
1688
+ * Phase-1 只支持 5 个 task 变量:{{task.title}}, {{task.taskId}}, {{task.projectId}}, {{task.track}}, {{task.currentNode}}。
1689
+ * 未匹配的 {{...}} 保留原样(不报错,方便后续扩展)。
1690
+ */
1691
+ declare function renderPrompt(template: string, task: Task): string;
1692
+
1693
+ declare const VERSION: string;
1694
+ declare function ping(): string;
1695
+
1696
+ export { ARTIFACT_TYPES, type AdvanceDeps, type AdvanceInput, type AdvanceRequest, AdvanceRequestSchema, type AdvanceResponse, AdvanceResponseSchema, type Agent, type AgentCopy, AgentCopySchema, type AgentCreate, AgentCreateSchema, type AgentRepo, AgentSchema, type AgentScope, AgentScopeSchema, type AgentUpdate, AgentUpdateSchema, AppError, type AppErrorOptions, type ApproveRequest, ApproveRequestSchema, type ApproveResponse, ApproveResponseSchema, type ArchNote, ArchNoteSchema, type Artifact, ArtifactSchema, type ArtifactType, BIZ_CODE_MESSAGES, BadRequestError, type BizCode, type CheckItem, CheckItemSchema, type Confirmation, ConfirmationSchema, ConflictError, DAG_PHASES, DAG_TRACKS, DEFAULT_PROJECT_KEY, type DagEdge, DagEdgeSchema, type DagInstance, DagInstanceSchema, type DagNode, DagNodePhaseSchema, DagNodeSchema, DagNodeTrackSchema, type DagTemplate, type DagTemplateCopy, DagTemplateCopySchema, type DagTemplateCreate, DagTemplateCreateSchema, type DagTemplateRepo, DagTemplateSchema, type DagTemplateUpdate, DagTemplateUpdateSchema, type Decision, DecisionSchema, ENTRY_ID_REGEX, type EdgePausePoint, EdgePausePointBaseSchema, EdgePausePointSchema, type EnumEntry, EnumEntrySchema, type EnumRegistry, type EnumRegistryCategory, EnumRegistryCategorySchema, type EnumRegistryRepo, EnumRegistrySchema, type EnumRegistryUpdate, EnumRegistryUpdateSchema, HistoryActionSchema, type HistoryEntry, HistoryEntrySchema, type ModelAlias, type ModelAliasCreate, ModelAliasCreateSchema, type ModelAliasRepo, ModelAliasSchema, ModelAliasShapeSchema, type ModelAliasUpdate, ModelAliasUpdateSchema, type ModelAliasWithRefCount, ModelAliasWithRefCountSchema, NODE_ID_PATTERN, NODE_STATUSES, type NodeInfo, NodeInfoSchema, type NodeRecord, NodeRecordSchema, type NodeState, NodeStateSchema, NodeStatusSchema, NotFoundError, OBJECT_ID_HEX, type OmitId, PAUSE_POINT_TYPES, PausePointTypeSchema, type PauseRequest, PauseRequestSchema, type Project, type ProjectCreate, ProjectCreateSchema, type ProjectRepo, ProjectSchema, type ProjectStatus, ProjectStatusSchema, type ProjectUpdate, ProjectUpdateSchema, type PruneResult, type Repo, type ResumeRequest, ResumeRequestSchema, type ReviewSummary, ReviewSummarySchema, SIMING_CODE_REGEX, SIMING_CONFIG_ENV_KEYS, SIMING_CONFIG_KEYS, type SimingClient, type SimingConfig, type SimingConfigKey, SimingConfigSchema, SimingLogLevelSchema, type Skill, type SkillCopy, SkillCopySchema, type SkillCreate, SkillCreateSchema, type SkillRepo, SkillSchema, type SkillScope, SkillScopeSchema, type SkillUpdate, SkillUpdateSchema, TASK_PHASES, TASK_STATUSES, TASK_TYPES, type Task, type TaskContext, TaskContextSchema, type TaskCreateInput, TaskCreateInputSchema, type TaskDocContent, TaskDocContentSchema, type TaskPatch, TaskPhaseSchema, type TaskPublic, TaskPublicSchema, type TaskRepo, TaskSchema, TaskStatusSchema, type TaskSummary, TaskSummarySchema, type TaskType, VERSION, ValidationError, type WithId, advanceTask, approveTask, assertBoundSkillsCompatible, assertModelAliasExists, checkTermination, createAgentRepo, createDagTemplateRepo, createEnumRegistryRepo, createModelAliasRepo, createMongoClient, createProjectRepo, createRepo, createSkillRepo, createTaskRepo, findNextEdge, generateEntryId, generateProjectKey, mkHistory, pauseTask, ping, pruneInstance, renderPrompt, resumeTask, toNodeInfo, toTaskPublic, trackMatchSet, withTransaction };