@siming-org/core 0.4.0 → 0.5.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.
- package/dist/index.d.ts +1086 -9
- package/dist/index.js +1556 -354
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as mongodb from 'mongodb';
|
|
1
2
|
import { Db, MongoClient, MongoClientOptions, ClientSession, Collection, Document, Filter, ObjectId } from 'mongodb';
|
|
2
3
|
export { ClientSession, Db } from 'mongodb';
|
|
3
4
|
import { z } from 'zod';
|
|
@@ -220,6 +221,8 @@ type SkillRepo = Repo<Skill> & {
|
|
|
220
221
|
listSkills(opts?: AssetListOpts): Promise<Skill[]>;
|
|
221
222
|
/** 绑定校验批量预取(消 N+1):按引用方 scope 可见集过滤(N016 F04——project 引用方 = global + 本项目;global 引用方 = 仅 global) */
|
|
222
223
|
listSkillsByNames(names: string[], scope?: SkillScope, projectId?: string): Promise<Map<string, Skill>>;
|
|
224
|
+
/** 仅判断目标作用域是否被对方作用域同名资产阻塞,不返回资产内容。 */
|
|
225
|
+
hasNameScopeConflict(name: string, scope: SkillScope): Promise<boolean>;
|
|
223
226
|
/** by-name 复制(N016 F08/F11):源 scope 显式消歧 + 目标跨 scope 守卫;version 重置 '1.0.0' */
|
|
224
227
|
copySkill(sourceName: string, source: {
|
|
225
228
|
scope: SkillScope;
|
|
@@ -400,6 +403,8 @@ type AgentRepo = Repo<Agent> & {
|
|
|
400
403
|
listAgentsByScopeFilter(scope: AgentScope, projectId?: string, opts?: AssetListOpts): Promise<Agent[]>;
|
|
401
404
|
/** T202608290001:全量列举(管理视角,路由缺省路径)——opts 语义同上,保持启停过滤单点在仓储层 */
|
|
402
405
|
listAgents(opts?: AssetListOpts): Promise<Agent[]>;
|
|
406
|
+
/** 仅判断目标作用域是否被对方作用域同名资产阻塞,不返回资产内容。 */
|
|
407
|
+
hasNameScopeConflict(name: string, scope: AgentScope): Promise<boolean>;
|
|
403
408
|
/** by-name 复制(N016 F08/F11):源 scope 显式消歧 + 目标跨 scope 守卫 + boundSkills 按目标作用域重校验;version 重置 '1.0.0' */
|
|
404
409
|
copyAgent(sourceName: string, source: {
|
|
405
410
|
scope: AgentScope;
|
|
@@ -441,6 +446,19 @@ declare const DagNodeTrackSchema: z.ZodString;
|
|
|
441
446
|
declare const DAG_PHASES: readonly ["entry", "track", "test", "exit"];
|
|
442
447
|
declare const DAG_TRACKS: readonly ["backend", "ui", "all"];
|
|
443
448
|
declare const NODE_ID_PATTERN: RegExp;
|
|
449
|
+
/**
|
|
450
|
+
* 来源标记(T202609020001 K2):组装值拷贝时写入,双信号分工——
|
|
451
|
+
* code = 升级寻址键 / version = updatable 判定(K13 升版强制保证「版本不变则内容不变」)/
|
|
452
|
+
* contentHash = local-modified 判定基线(算法单源 computeNodeContentHash)。
|
|
453
|
+
* 可选字段:存量模板无此键 = 自建节点,零迁移。
|
|
454
|
+
*/
|
|
455
|
+
declare const SourcePresetSchema: z.ZodObject<{
|
|
456
|
+
code: z.ZodString;
|
|
457
|
+
version: z.ZodString;
|
|
458
|
+
contentHash: z.ZodString;
|
|
459
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
460
|
+
}, z.core.$strip>;
|
|
461
|
+
type SourcePreset = z.infer<typeof SourcePresetSchema>;
|
|
444
462
|
declare const DagNodeSchema: z.ZodObject<{
|
|
445
463
|
id: z.ZodString;
|
|
446
464
|
label: z.ZodString;
|
|
@@ -448,6 +466,13 @@ declare const DagNodeSchema: z.ZodObject<{
|
|
|
448
466
|
track: z.ZodString;
|
|
449
467
|
prompt: z.ZodString;
|
|
450
468
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
469
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
470
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
471
|
+
code: z.ZodString;
|
|
472
|
+
version: z.ZodString;
|
|
473
|
+
contentHash: z.ZodString;
|
|
474
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
475
|
+
}, z.core.$strip>>;
|
|
451
476
|
}, z.core.$strip>;
|
|
452
477
|
type DagNode = z.infer<typeof DagNodeSchema>;
|
|
453
478
|
/** 暂停点类型——固定枚举,引擎仅处理这两种语义(human_approval 落 paused / checkpoint 仅记录不停留) */
|
|
@@ -487,6 +512,22 @@ declare const EdgePausePointSchema: z.ZodObject<{
|
|
|
487
512
|
autoResume: z.ZodDefault<z.ZodBoolean>;
|
|
488
513
|
}, z.core.$strip>;
|
|
489
514
|
type EdgePausePoint = z.infer<typeof EdgePausePointSchema>;
|
|
515
|
+
/**
|
|
516
|
+
* 模板业务 code 格式:kebab-case 且至少含一个连字符段('-' 分隔多段,如 full-workflow)。
|
|
517
|
+
* 含连字符约束使 code 与 24-hex 数据库 id 形态可区分(纯 hex 串无连字符,天然被排除)——
|
|
518
|
+
* 支撑寻址二阶段判定(先 id 直查命中、未命中再按 code 项目内检索)与 AI 转录可核对性。
|
|
519
|
+
*/
|
|
520
|
+
declare const TEMPLATE_CODE_REGEX: RegExp;
|
|
521
|
+
declare const TEMPLATE_CODE_MAX_LENGTH = 31;
|
|
522
|
+
/** code 字段校验(创建侧强校验;长度与 project key 同口径 2-31,结构保证下限 3) */
|
|
523
|
+
declare const TemplateCodeFieldSchema: z.ZodString;
|
|
524
|
+
/** not-found 相近候选条目(防转录错误——错误信息携带项目内相近模板清单) */
|
|
525
|
+
declare const TemplateCandidateSchema: z.ZodObject<{
|
|
526
|
+
id: z.ZodString;
|
|
527
|
+
code: z.ZodString;
|
|
528
|
+
name: z.ZodString;
|
|
529
|
+
}, z.core.$strip>;
|
|
530
|
+
type TemplateCandidate = z.infer<typeof TemplateCandidateSchema>;
|
|
490
531
|
declare const DagEdgeSchema: z.ZodObject<{
|
|
491
532
|
from: z.ZodString;
|
|
492
533
|
to: z.ZodString;
|
|
@@ -506,6 +547,7 @@ declare const DagTemplateSchema: z.ZodObject<{
|
|
|
506
547
|
name: z.ZodString;
|
|
507
548
|
projectId: z.ZodString;
|
|
508
549
|
description: z.ZodString;
|
|
550
|
+
code: z.ZodOptional<z.ZodString>;
|
|
509
551
|
nodes: z.ZodArray<z.ZodObject<{
|
|
510
552
|
id: z.ZodString;
|
|
511
553
|
label: z.ZodString;
|
|
@@ -513,6 +555,13 @@ declare const DagTemplateSchema: z.ZodObject<{
|
|
|
513
555
|
track: z.ZodString;
|
|
514
556
|
prompt: z.ZodString;
|
|
515
557
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
558
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
559
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
560
|
+
code: z.ZodString;
|
|
561
|
+
version: z.ZodString;
|
|
562
|
+
contentHash: z.ZodString;
|
|
563
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
564
|
+
}, z.core.$strip>>;
|
|
516
565
|
}, z.core.$strip>>;
|
|
517
566
|
edges: z.ZodArray<z.ZodObject<{
|
|
518
567
|
from: z.ZodString;
|
|
@@ -541,6 +590,7 @@ type DagTemplate = z.infer<typeof DagTemplateSchema>;
|
|
|
541
590
|
declare const DagTemplateCreateSchema: z.ZodObject<{
|
|
542
591
|
version: z.ZodDefault<z.ZodString>;
|
|
543
592
|
name: z.ZodString;
|
|
593
|
+
code: z.ZodOptional<z.ZodString>;
|
|
544
594
|
description: z.ZodString;
|
|
545
595
|
projectId: z.ZodString;
|
|
546
596
|
nodes: z.ZodArray<z.ZodObject<{
|
|
@@ -550,6 +600,13 @@ declare const DagTemplateCreateSchema: z.ZodObject<{
|
|
|
550
600
|
track: z.ZodString;
|
|
551
601
|
prompt: z.ZodString;
|
|
552
602
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
603
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
604
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
605
|
+
code: z.ZodString;
|
|
606
|
+
version: z.ZodString;
|
|
607
|
+
contentHash: z.ZodString;
|
|
608
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
609
|
+
}, z.core.$strip>>;
|
|
553
610
|
}, z.core.$strip>>;
|
|
554
611
|
edges: z.ZodArray<z.ZodObject<{
|
|
555
612
|
from: z.ZodString;
|
|
@@ -574,9 +631,12 @@ type DagTemplateCreate = z.infer<typeof DagTemplateCreateSchema>;
|
|
|
574
631
|
/**
|
|
575
632
|
* 更新输入(PUT partial)。extend 剥离实体层 .default()——Zod 4 的 .partial() 保留字段
|
|
576
633
|
* default,空 body 会解析出 {isDefault:false, version:'1.0.0'} 并被 $set 写库(字段被静默重置)。
|
|
634
|
+
* code 无实体层 default,partial 后 optional 进 Update——仅供路由层不可变检测
|
|
635
|
+
* (body.code ≠ 现值 → 409 TEMPLATE_CODE_IMMUTABLE;= 现值剥离不写),路由层负责剥离。
|
|
577
636
|
*/
|
|
578
637
|
declare const DagTemplateUpdateSchema: z.ZodObject<{
|
|
579
638
|
name: z.ZodOptional<z.ZodString>;
|
|
639
|
+
code: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
580
640
|
description: z.ZodOptional<z.ZodString>;
|
|
581
641
|
projectId: z.ZodOptional<z.ZodString>;
|
|
582
642
|
nodes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -586,6 +646,13 @@ declare const DagTemplateUpdateSchema: z.ZodObject<{
|
|
|
586
646
|
track: z.ZodString;
|
|
587
647
|
prompt: z.ZodString;
|
|
588
648
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
649
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
650
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
651
|
+
code: z.ZodString;
|
|
652
|
+
version: z.ZodString;
|
|
653
|
+
contentHash: z.ZodString;
|
|
654
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
655
|
+
}, z.core.$strip>>;
|
|
589
656
|
}, z.core.$strip>>>;
|
|
590
657
|
edges: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
591
658
|
from: z.ZodString;
|
|
@@ -610,12 +677,25 @@ declare const DagTemplateUpdateSchema: z.ZodObject<{
|
|
|
610
677
|
type DagTemplateUpdate = z.infer<typeof DagTemplateUpdateSchema>;
|
|
611
678
|
/**
|
|
612
679
|
* 模板复制入参(N012 F5/D5,契约命名对齐方案 §3.2.3):目标项目 + 新名称;副本落库为可编辑独立实体(version 重置 '1.0.0',isDefault=false)。
|
|
680
|
+
* T202609020002:newCode 可选——显式指定副本 code(格式强校验);缺省按 newName 规范化自动生成。
|
|
681
|
+
* 副本 code 与源模板 code 相互独立(源 code 不随拷贝,同项目复制必撞唯一索引)。
|
|
613
682
|
*/
|
|
614
683
|
declare const DagTemplateCopySchema: z.ZodObject<{
|
|
615
684
|
newName: z.ZodString;
|
|
616
685
|
targetProjectId: z.ZodString;
|
|
686
|
+
newCode: z.ZodOptional<z.ZodString>;
|
|
617
687
|
}, z.core.$strip>;
|
|
618
688
|
type DagTemplateCopy = z.infer<typeof DagTemplateCopySchema>;
|
|
689
|
+
/**
|
|
690
|
+
* K12:模板节点 id 唯一共享校验(core 单点,路由 create/PUT 与 template-transfer applyImport 双挂)。
|
|
691
|
+
* 函数级校验而非 schema 级——模板级 schema 禁挂 refine(Zod4 派生陷阱,见 DagTemplateSchema 注释)。
|
|
692
|
+
*/
|
|
693
|
+
declare function findDuplicateNodeIds(nodes: ReadonlyArray<{
|
|
694
|
+
id: string;
|
|
695
|
+
}>): string[];
|
|
696
|
+
declare function assertUniqueNodeIds(nodes: ReadonlyArray<{
|
|
697
|
+
id: string;
|
|
698
|
+
}>): void;
|
|
619
699
|
|
|
620
700
|
type DagTemplateRepo = Repo<DagTemplate> & {
|
|
621
701
|
createDagTemplate(data: DagTemplateCreate): Promise<DagTemplate>;
|
|
@@ -623,15 +703,41 @@ type DagTemplateRepo = Repo<DagTemplate> & {
|
|
|
623
703
|
* N015 F17:list 支持 name 过滤(export 查查重按 projectId+name,name 项目内唯一)。
|
|
624
704
|
* T202608290001:includeDisabled 缺省排除停用模板(CLI/MCP 列举 + 建任务选择器视图);
|
|
625
705
|
* true 时含停用(Web 管理台列表视图)。by-id 寻址不过滤(详情/创建守卫走显式判定)。
|
|
706
|
+
* T202609020002:code 精确过滤(与 q 正交;code 项目内唯一,命中至多一条)。
|
|
626
707
|
*/
|
|
627
708
|
listDagTemplates(filter?: {
|
|
628
709
|
projectId?: string;
|
|
629
710
|
name?: string;
|
|
711
|
+
code?: string;
|
|
630
712
|
includeDisabled?: boolean;
|
|
631
713
|
}): Promise<DagTemplate[]>;
|
|
632
|
-
/** 深拷贝复制(N012 F5/D5):副本落目标项目,version 重置 '1.0.0'、isDefault=false;目标项目内重名 → 409
|
|
633
|
-
|
|
714
|
+
/** 深拷贝复制(N012 F5/D5):副本落目标项目,version 重置 '1.0.0'、isDefault=false;目标项目内重名 → 409。
|
|
715
|
+
* T202609020002:副本 code 独立——newCode 显式指定或按 newName 自动生成(源 code 不随拷贝,同项目必撞唯一索引)。 */
|
|
716
|
+
copyDagTemplate(sourceId: string, targetProjectId: string, newName: string, newCode?: string): Promise<DagTemplate>;
|
|
717
|
+
/** T202609020002:按 code 项目内寻址(含停用——与 by-id 详情同视图;启用过滤归创建守卫显式判定) */
|
|
718
|
+
getByCode(projectId: string, code: string): Promise<DagTemplate | null>;
|
|
719
|
+
/**
|
|
720
|
+
* T202609020002:二阶段寻址——24-hex 直查 id 命中即返回(兼容层优先探活,防正交误判劫持);
|
|
721
|
+
* hex 直查未命中不转 code 检索(code 必含连字符与 hex 形态互斥,检索必空)。
|
|
722
|
+
* 非 hex 形态且提供项目上下文 → 按 code 项目内检索;projectCtx 缺省时不检索
|
|
723
|
+
* (code 项目内唯一,无项目域无法消歧)。全未命中返回 null(候选清单归路由层)。
|
|
724
|
+
*/
|
|
725
|
+
resolveTemplateByRef(ref: string, projectCtx?: string): Promise<DagTemplate | null>;
|
|
726
|
+
/** T202609020002:not-found 相近候选(项目内全量含停用 → 内存评分排序,上限 limit;空数组 = 无相近) */
|
|
727
|
+
findSimilarTemplates(projectId: string, ref: string, limit?: number): Promise<TemplateCandidate[]>;
|
|
634
728
|
};
|
|
729
|
+
/** 展示名 → kebab 基串(纯函数):转小写、非字母数字折叠为连字符、合并连字符、裁长度。
|
|
730
|
+
* 中文名/纯特殊字符规范化后为空串(兜底序列覆盖,见 buildTemplateCode)。 */
|
|
731
|
+
declare function normalizeNameToTemplateCode(name: string): string;
|
|
732
|
+
/** code 合法口径单源(regex + 长度上限;创建生成/迁移判定/寻址校验共用)——server 迁移侧复用导出 */
|
|
733
|
+
declare function isLegalTemplateCode(code: string): boolean;
|
|
734
|
+
/**
|
|
735
|
+
* 生成项目内唯一合法 code(纯函数,创建缺省路径与存量迁移共用):
|
|
736
|
+
* - 多段名(规范化后含连字符)→ 原样采用;单段名 → 补 `tpl-` 前缀段(保证含连字符、与 id 形态可区分)
|
|
737
|
+
* - 规范化为空(纯中文/特殊字符名)→ `tpl-1` 兜底序列
|
|
738
|
+
* - 冲突消歧:`{primary}-2`、`{primary}-3` …(后缀追加前裁 base 保总长 ≤31)
|
|
739
|
+
*/
|
|
740
|
+
declare function buildTemplateCode(seedName: string, takenCodes: Iterable<string>): string;
|
|
635
741
|
declare function createDagTemplateRepo(db: Db): DagTemplateRepo;
|
|
636
742
|
|
|
637
743
|
/**
|
|
@@ -780,6 +886,21 @@ declare const NodeStateSchema: z.ZodObject<{
|
|
|
780
886
|
completedAt: z.ZodDefault<z.ZodNullable<z.ZodDate>>;
|
|
781
887
|
}, z.core.$strip>;
|
|
782
888
|
type NodeState = z.infer<typeof NodeStateSchema>;
|
|
889
|
+
/**
|
|
890
|
+
* 任务实例节点:任务创建时从模板值拷贝的运行态节点。
|
|
891
|
+
* `GET /api/tasks/:taskId/node/:nodeId` 在此结构上渲染 prompt 后返回同形 DTO;
|
|
892
|
+
* 它不同于流转资料包 NodeInfo(后者使用 nodeId 和 upcomingPause)。
|
|
893
|
+
*/
|
|
894
|
+
declare const DagInstanceNodeSchema: z.ZodObject<{
|
|
895
|
+
id: z.ZodString;
|
|
896
|
+
label: z.ZodString;
|
|
897
|
+
phase: z.ZodString;
|
|
898
|
+
track: z.ZodString;
|
|
899
|
+
prompt: z.ZodString;
|
|
900
|
+
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
901
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
902
|
+
}, z.core.$strip>;
|
|
903
|
+
type DagInstanceNode = z.infer<typeof DagInstanceNodeSchema>;
|
|
783
904
|
declare const DagInstanceSchema: z.ZodObject<{
|
|
784
905
|
templateId: z.ZodString;
|
|
785
906
|
templateVersion: z.ZodString;
|
|
@@ -790,6 +911,7 @@ declare const DagInstanceSchema: z.ZodObject<{
|
|
|
790
911
|
track: z.ZodString;
|
|
791
912
|
prompt: z.ZodString;
|
|
792
913
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
914
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
793
915
|
}, z.core.$strip>>;
|
|
794
916
|
edges: z.ZodArray<z.ZodObject<{
|
|
795
917
|
from: z.ZodString;
|
|
@@ -872,6 +994,7 @@ declare const TaskSchema: z.ZodObject<{
|
|
|
872
994
|
track: z.ZodString;
|
|
873
995
|
prompt: z.ZodString;
|
|
874
996
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
997
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
875
998
|
}, z.core.$strip>>;
|
|
876
999
|
edges: z.ZodArray<z.ZodObject<{
|
|
877
1000
|
from: z.ZodString;
|
|
@@ -1019,6 +1142,7 @@ declare const TaskContextSchema: z.ZodObject<{
|
|
|
1019
1142
|
track: z.ZodString;
|
|
1020
1143
|
prompt: z.ZodString;
|
|
1021
1144
|
skills: z.ZodArray<z.ZodString>;
|
|
1145
|
+
agents: z.ZodArray<z.ZodString>;
|
|
1022
1146
|
upcomingPause: z.ZodNullable<z.ZodString>;
|
|
1023
1147
|
}, z.core.$strip>>;
|
|
1024
1148
|
pausedAtEdge: z.ZodNullable<z.ZodObject<{
|
|
@@ -1404,6 +1528,598 @@ type EnumRegistryRepo = Repo<EnumRegistry> & {
|
|
|
1404
1528
|
};
|
|
1405
1529
|
declare function createEnumRegistryRepo(db: Db): EnumRegistryRepo;
|
|
1406
1530
|
|
|
1531
|
+
/**
|
|
1532
|
+
* NodePreset Schema — 通用 DAG 节点资产(T202609020001)
|
|
1533
|
+
*
|
|
1534
|
+
* code = 全局唯一(跨作用域)业务键(npm 分发 / 组合引用 / 升级寻址),kebab-case、创建后不可变;
|
|
1535
|
+
* nodeId = 组装进模板时的默认节点标识(模板内可改名且不影响来源关联——升级按 code 寻址)。
|
|
1536
|
+
* skills 在 Shape 层无 default(F22):防 Update 派生后 default 注入清空绑定——Create 侧显式 extend 注入。
|
|
1537
|
+
*/
|
|
1538
|
+
declare const NODE_PRESET_CODE_PATTERN: RegExp;
|
|
1539
|
+
/**
|
|
1540
|
+
* Shape 层(纯 object 不挂 refine;default 字段一律不在本层——scope/skills/version 均无 default)。
|
|
1541
|
+
* 实体/派生全从本层 omit/extend,禁止在 refined 全量 schema 上调对象级方法(Zod4 运行时陷阱)。
|
|
1542
|
+
*/
|
|
1543
|
+
declare const NodePresetShapeSchema: z.ZodObject<{
|
|
1544
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1545
|
+
code: z.ZodString;
|
|
1546
|
+
label: z.ZodString;
|
|
1547
|
+
nodeId: z.ZodString;
|
|
1548
|
+
phase: z.ZodString;
|
|
1549
|
+
track: z.ZodString;
|
|
1550
|
+
prompt: z.ZodString;
|
|
1551
|
+
skills: z.ZodArray<z.ZodString>;
|
|
1552
|
+
agents: z.ZodArray<z.ZodString>;
|
|
1553
|
+
scope: z.ZodEnum<{
|
|
1554
|
+
global: "global";
|
|
1555
|
+
project: "project";
|
|
1556
|
+
}>;
|
|
1557
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1558
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1559
|
+
version: z.ZodString;
|
|
1560
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
1561
|
+
package: z.ZodString;
|
|
1562
|
+
}, z.core.$strip>>;
|
|
1563
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1564
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1565
|
+
updatedAt: z.ZodOptional<z.ZodDate>;
|
|
1566
|
+
}, z.core.$strip>;
|
|
1567
|
+
declare const NodePresetSchema: z.ZodObject<{
|
|
1568
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1569
|
+
code: z.ZodString;
|
|
1570
|
+
label: z.ZodString;
|
|
1571
|
+
nodeId: z.ZodString;
|
|
1572
|
+
phase: z.ZodString;
|
|
1573
|
+
track: z.ZodString;
|
|
1574
|
+
prompt: z.ZodString;
|
|
1575
|
+
skills: z.ZodArray<z.ZodString>;
|
|
1576
|
+
agents: z.ZodArray<z.ZodString>;
|
|
1577
|
+
scope: z.ZodEnum<{
|
|
1578
|
+
global: "global";
|
|
1579
|
+
project: "project";
|
|
1580
|
+
}>;
|
|
1581
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1582
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1583
|
+
version: z.ZodString;
|
|
1584
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
1585
|
+
package: z.ZodString;
|
|
1586
|
+
}, z.core.$strip>>;
|
|
1587
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1588
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1589
|
+
updatedAt: z.ZodOptional<z.ZodDate>;
|
|
1590
|
+
}, z.core.$strip>;
|
|
1591
|
+
type NodePreset = z.infer<typeof NodePresetSchema>;
|
|
1592
|
+
/**
|
|
1593
|
+
* 创建输入:default 一律在派生层显式注入(skills/agents/version),Shape 保持无 default——
|
|
1594
|
+
* UpdateSchema 由同一 Shape 派生,Shape 层 default 会被 .partial() 保留注入(F22 反例)。
|
|
1595
|
+
*/
|
|
1596
|
+
declare const NodePresetCreateSchema: z.ZodObject<{
|
|
1597
|
+
code: z.ZodString;
|
|
1598
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1599
|
+
scope: z.ZodEnum<{
|
|
1600
|
+
global: "global";
|
|
1601
|
+
project: "project";
|
|
1602
|
+
}>;
|
|
1603
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1604
|
+
track: z.ZodString;
|
|
1605
|
+
phase: z.ZodString;
|
|
1606
|
+
label: z.ZodString;
|
|
1607
|
+
prompt: z.ZodString;
|
|
1608
|
+
nodeId: z.ZodString;
|
|
1609
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
1610
|
+
package: z.ZodString;
|
|
1611
|
+
}, z.core.$strip>>;
|
|
1612
|
+
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1613
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1614
|
+
version: z.ZodDefault<z.ZodString>;
|
|
1615
|
+
}, z.core.$strip>;
|
|
1616
|
+
type NodePresetCreate = z.infer<typeof NodePresetCreateSchema>;
|
|
1617
|
+
/**
|
|
1618
|
+
* 更新输入(PUT partial,先 partial 后挂 refine——Zod4 范式)。
|
|
1619
|
+
* code/scope/projectId 保留在 schema(partial 后可选)供不可变守卫判定:路由层「携带且与现值不同 → 409」
|
|
1620
|
+
* (对齐 skill/agent isScopeMutation 语义);同值携带为幂等 no-op,不触发守卫。
|
|
1621
|
+
*/
|
|
1622
|
+
declare const NodePresetUpdateSchema: z.ZodObject<{
|
|
1623
|
+
code: z.ZodOptional<z.ZodString>;
|
|
1624
|
+
description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1625
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
1626
|
+
global: "global";
|
|
1627
|
+
project: "project";
|
|
1628
|
+
}>>;
|
|
1629
|
+
projectId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1630
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1631
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1632
|
+
track: z.ZodOptional<z.ZodString>;
|
|
1633
|
+
phase: z.ZodOptional<z.ZodString>;
|
|
1634
|
+
label: z.ZodOptional<z.ZodString>;
|
|
1635
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
1636
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
1637
|
+
source: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1638
|
+
package: z.ZodString;
|
|
1639
|
+
}, z.core.$strip>>>;
|
|
1640
|
+
version: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
1641
|
+
}, z.core.$strip>;
|
|
1642
|
+
type NodePresetUpdate = z.infer<typeof NodePresetUpdateSchema>;
|
|
1643
|
+
/** by-code 复制入参:newCode 全局唯一预校验;副本 version 重置 '1.0.0'、剥除 source(手工副本无包来源) */
|
|
1644
|
+
declare const NodePresetCopySchema: z.ZodObject<{
|
|
1645
|
+
newCode: z.ZodString;
|
|
1646
|
+
newScope: z.ZodEnum<{
|
|
1647
|
+
global: "global";
|
|
1648
|
+
project: "project";
|
|
1649
|
+
}>;
|
|
1650
|
+
targetProjectId: z.ZodOptional<z.ZodString>;
|
|
1651
|
+
}, z.core.$strip>;
|
|
1652
|
+
type NodePresetCopy = z.infer<typeof NodePresetCopySchema>;
|
|
1653
|
+
|
|
1654
|
+
interface NodePresetListFilter {
|
|
1655
|
+
scope?: 'global' | 'project' | undefined;
|
|
1656
|
+
/** 叠加可见语义(scope 缺省时):global + 该项目专用 */
|
|
1657
|
+
projectId?: string | undefined;
|
|
1658
|
+
q?: string | undefined;
|
|
1659
|
+
includeDisabled?: boolean | undefined;
|
|
1660
|
+
}
|
|
1661
|
+
type NodePresetRepo = Repo<NodePreset> & {
|
|
1662
|
+
/** code 预校验(409 NODE_PRESET_CODE_EXISTS 先于 E11000 兜底)+ 落库 */
|
|
1663
|
+
createNodePreset(data: NodePresetCreate): Promise<NodePreset>;
|
|
1664
|
+
/** by-code 寻址(code 全局唯一无 scope 消歧);缺省排除停用(读可见性),写通道显式 includeDisabled */
|
|
1665
|
+
getByCode(code: string, opts?: {
|
|
1666
|
+
includeDisabled?: boolean | undefined;
|
|
1667
|
+
}): Promise<NodePreset | null>;
|
|
1668
|
+
/** 写通道更新(显式放行停用资产——启停不冻结管理操作,对齐 skill 惯例) */
|
|
1669
|
+
updateByCode(code: string, patch: EoptPartial<Omit<NodePreset, 'id'>>): Promise<NodePreset | null>;
|
|
1670
|
+
/** 写通道删除(同上放行停用) */
|
|
1671
|
+
deleteByCode(code: string): Promise<boolean>;
|
|
1672
|
+
/** 作用域过滤列表(scope=精确作用域 / projectId=叠加可见 / 缺省全量管理视角;q 搜 code 与 label) */
|
|
1673
|
+
listNodePresets(filter?: NodePresetListFilter): Promise<NodePreset[]>;
|
|
1674
|
+
/** 批量预取(含停用——升级 plan 的 source-disabled 判定依赖;code 全局唯一直查) */
|
|
1675
|
+
listByCodes(codes: string[]): Promise<Map<string, NodePreset>>;
|
|
1676
|
+
/** 仅返回 code 是否已占用;供受限身份做安装预检,不暴露归属或内容。 */
|
|
1677
|
+
isCodeOccupied(code: string): Promise<boolean>;
|
|
1678
|
+
/** by-code 复制:newCode 全局预校验;version 重置 '1.0.0'、剥除 source(手工副本无包来源)、副本默认启用 */
|
|
1679
|
+
copyNodePreset(sourceCode: string, target: {
|
|
1680
|
+
scope: 'global' | 'project';
|
|
1681
|
+
projectId?: string;
|
|
1682
|
+
}, input: NodePresetCopy): Promise<NodePreset>;
|
|
1683
|
+
};
|
|
1684
|
+
declare function createNodePresetRepo(db: Db): NodePresetRepo;
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* NodeLibrary Schema — npm 节点库安装登记(T202609020001 K7)
|
|
1688
|
+
*
|
|
1689
|
+
* 运维登记非用户资产:记录已装库的版本 / 节点 code 清单 / 组合定义全文(flow compose 数据通道)
|
|
1690
|
+
* 与漂移检测基线;同库重装按 name upsert 覆盖({name} unique)。
|
|
1691
|
+
* 写入经 server 端点 /api/node-libraries(CLI 是无状态 HTTP 客户端,不直连库)。
|
|
1692
|
+
*/
|
|
1693
|
+
/** 组合边(暂停点内联于 edge——与 DagEdge 模型一致,无顶层 pausePoints 字段) */
|
|
1694
|
+
declare const CompositionEdgeSchema: z.ZodObject<{
|
|
1695
|
+
from: z.ZodString;
|
|
1696
|
+
to: z.ZodString;
|
|
1697
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
1698
|
+
pausePoint: z.ZodOptional<z.ZodObject<{
|
|
1699
|
+
type: z.ZodEnum<{
|
|
1700
|
+
human_approval: "human_approval";
|
|
1701
|
+
checkpoint: "checkpoint";
|
|
1702
|
+
}>;
|
|
1703
|
+
description: z.ZodString;
|
|
1704
|
+
autoResume: z.ZodDefault<z.ZodBoolean>;
|
|
1705
|
+
}, z.core.$strip>>;
|
|
1706
|
+
}, z.core.$strip>;
|
|
1707
|
+
type CompositionEdge = z.infer<typeof CompositionEdgeSchema>;
|
|
1708
|
+
/** 组合定义(nodes 为 NodePreset code 引用清单;edges 拓扑照抄组装进模板) */
|
|
1709
|
+
declare const CompositionSchema: z.ZodObject<{
|
|
1710
|
+
name: z.ZodString;
|
|
1711
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1712
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
1713
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
1714
|
+
from: z.ZodString;
|
|
1715
|
+
to: z.ZodString;
|
|
1716
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
1717
|
+
pausePoint: z.ZodOptional<z.ZodObject<{
|
|
1718
|
+
type: z.ZodEnum<{
|
|
1719
|
+
human_approval: "human_approval";
|
|
1720
|
+
checkpoint: "checkpoint";
|
|
1721
|
+
}>;
|
|
1722
|
+
description: z.ZodString;
|
|
1723
|
+
autoResume: z.ZodDefault<z.ZodBoolean>;
|
|
1724
|
+
}, z.core.$strip>>;
|
|
1725
|
+
}, z.core.$strip>>;
|
|
1726
|
+
}, z.core.$strip>;
|
|
1727
|
+
type Composition = z.infer<typeof CompositionSchema>;
|
|
1728
|
+
declare const NodeLibrarySchema: z.ZodObject<{
|
|
1729
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1730
|
+
name: z.ZodString;
|
|
1731
|
+
version: z.ZodString;
|
|
1732
|
+
scope: z.ZodEnum<{
|
|
1733
|
+
global: "global";
|
|
1734
|
+
project: "project";
|
|
1735
|
+
}>;
|
|
1736
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1737
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
1738
|
+
compositions: z.ZodArray<z.ZodObject<{
|
|
1739
|
+
name: z.ZodString;
|
|
1740
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1741
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
1742
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
1743
|
+
from: z.ZodString;
|
|
1744
|
+
to: z.ZodString;
|
|
1745
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
1746
|
+
pausePoint: z.ZodOptional<z.ZodObject<{
|
|
1747
|
+
type: z.ZodEnum<{
|
|
1748
|
+
human_approval: "human_approval";
|
|
1749
|
+
checkpoint: "checkpoint";
|
|
1750
|
+
}>;
|
|
1751
|
+
description: z.ZodString;
|
|
1752
|
+
autoResume: z.ZodDefault<z.ZodBoolean>;
|
|
1753
|
+
}, z.core.$strip>>;
|
|
1754
|
+
}, z.core.$strip>>;
|
|
1755
|
+
}, z.core.$strip>>;
|
|
1756
|
+
installedAt: z.ZodOptional<z.ZodDate>;
|
|
1757
|
+
}, z.core.$strip>;
|
|
1758
|
+
type NodeLibrary = z.infer<typeof NodeLibrarySchema>;
|
|
1759
|
+
/** 安装登记 upsert 入参(flow install 全部节点落库成功后写入——登记后置,防节点半落库登记先行的部分副作用) */
|
|
1760
|
+
declare const NodeLibraryUpsertSchema: z.ZodObject<{
|
|
1761
|
+
name: z.ZodString;
|
|
1762
|
+
version: z.ZodString;
|
|
1763
|
+
scope: z.ZodEnum<{
|
|
1764
|
+
global: "global";
|
|
1765
|
+
project: "project";
|
|
1766
|
+
}>;
|
|
1767
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1768
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
1769
|
+
compositions: z.ZodArray<z.ZodObject<{
|
|
1770
|
+
name: z.ZodString;
|
|
1771
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1772
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
1773
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
1774
|
+
from: z.ZodString;
|
|
1775
|
+
to: z.ZodString;
|
|
1776
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
1777
|
+
pausePoint: z.ZodOptional<z.ZodObject<{
|
|
1778
|
+
type: z.ZodEnum<{
|
|
1779
|
+
human_approval: "human_approval";
|
|
1780
|
+
checkpoint: "checkpoint";
|
|
1781
|
+
}>;
|
|
1782
|
+
description: z.ZodString;
|
|
1783
|
+
autoResume: z.ZodDefault<z.ZodBoolean>;
|
|
1784
|
+
}, z.core.$strip>>;
|
|
1785
|
+
}, z.core.$strip>>;
|
|
1786
|
+
}, z.core.$strip>>;
|
|
1787
|
+
}, z.core.$strip>;
|
|
1788
|
+
type NodeLibraryUpsert = z.infer<typeof NodeLibraryUpsertSchema>;
|
|
1789
|
+
|
|
1790
|
+
type NodeLibraryRepo = Repo<NodeLibrary> & {
|
|
1791
|
+
/**
|
|
1792
|
+
* 同库重装 upsert({name} unique):按 name 定位整笔替换 version/nodes/compositions,
|
|
1793
|
+
* installedAt 刷新为本次安装时刻。scope 变更(global ↔ project)随 upsert 一并生效——
|
|
1794
|
+
* 登记是运维态非用户资产,以最后一次安装的事实为准。
|
|
1795
|
+
*/
|
|
1796
|
+
upsertNodeLibrary(data: NodeLibraryUpsert): Promise<NodeLibrary>;
|
|
1797
|
+
/** 可见性过滤列表(叠加/精确语义由路由层决定传参:project 上下文恒 overlay 本项目) */
|
|
1798
|
+
listNodeLibraries(filter?: {
|
|
1799
|
+
scope?: 'global' | 'project' | undefined;
|
|
1800
|
+
projectId?: string | undefined;
|
|
1801
|
+
}): Promise<NodeLibrary[]>;
|
|
1802
|
+
};
|
|
1803
|
+
declare function createNodeLibraryRepo(db: Db): NodeLibraryRepo;
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* Auth Schema — 云主机部署权限体系(T202608310001)
|
|
1807
|
+
* 三凭证模型:管理员账号密码(Web 登录)/ 管理员 Token(admin- 前缀,全权)/
|
|
1808
|
+
* 项目 Token(project- 前缀,绑定单项目读写、全局资产只读)。
|
|
1809
|
+
* 服务端仅存单向哈希(密码 scrypt / Token sha256),明文零落库。
|
|
1810
|
+
*/
|
|
1811
|
+
/** Token 类型:前缀自描述(admin- / project-),随机部分 43 字符 base64url */
|
|
1812
|
+
declare const AuthTokenTypeSchema: z.ZodEnum<{
|
|
1813
|
+
project: "project";
|
|
1814
|
+
admin: "admin";
|
|
1815
|
+
}>;
|
|
1816
|
+
type AuthTokenType = z.infer<typeof AuthTokenTypeSchema>;
|
|
1817
|
+
declare const AuthAccountSchema: z.ZodObject<{
|
|
1818
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1819
|
+
username: z.ZodString;
|
|
1820
|
+
passwordHash: z.ZodString;
|
|
1821
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1822
|
+
updatedAt: z.ZodOptional<z.ZodDate>;
|
|
1823
|
+
}, z.core.$strip>;
|
|
1824
|
+
type AuthAccount = z.infer<typeof AuthAccountSchema>;
|
|
1825
|
+
/** 初始化引导创建唯一管理员账号(PRD §3.2:密码最小长度 8) */
|
|
1826
|
+
declare const AuthAccountCreateSchema: z.ZodObject<{
|
|
1827
|
+
username: z.ZodString;
|
|
1828
|
+
password: z.ZodString;
|
|
1829
|
+
}, z.core.$strip>;
|
|
1830
|
+
type AuthAccountCreate = z.infer<typeof AuthAccountCreateSchema>;
|
|
1831
|
+
/** 修改密码:需验证当前密码;新密码策略同初始化(PRD §3.2) */
|
|
1832
|
+
declare const PasswordChangeSchema: z.ZodObject<{
|
|
1833
|
+
currentPassword: z.ZodString;
|
|
1834
|
+
newPassword: z.ZodString;
|
|
1835
|
+
}, z.core.$strip>;
|
|
1836
|
+
type PasswordChange = z.infer<typeof PasswordChangeSchema>;
|
|
1837
|
+
declare const LoginSchema: z.ZodObject<{
|
|
1838
|
+
username: z.ZodString;
|
|
1839
|
+
password: z.ZodString;
|
|
1840
|
+
}, z.core.$strip>;
|
|
1841
|
+
type LoginInput = z.infer<typeof LoginSchema>;
|
|
1842
|
+
declare const AuthTokenSchema: z.ZodObject<{
|
|
1843
|
+
id: z.ZodOptional<z.ZodString>;
|
|
1844
|
+
tokenHash: z.ZodString;
|
|
1845
|
+
type: z.ZodEnum<{
|
|
1846
|
+
project: "project";
|
|
1847
|
+
admin: "admin";
|
|
1848
|
+
}>;
|
|
1849
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1850
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
1851
|
+
updatedAt: z.ZodOptional<z.ZodDate>;
|
|
1852
|
+
}, z.core.$strip>;
|
|
1853
|
+
type AuthToken = z.infer<typeof AuthTokenSchema>;
|
|
1854
|
+
/** Token 生成响应:明文 Token 仅此形态出现一次(PRD §3.5 一次性展示) */
|
|
1855
|
+
declare const AuthTokenGenResponseSchema: z.ZodObject<{
|
|
1856
|
+
token: z.ZodString;
|
|
1857
|
+
type: z.ZodEnum<{
|
|
1858
|
+
project: "project";
|
|
1859
|
+
admin: "admin";
|
|
1860
|
+
}>;
|
|
1861
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1862
|
+
}, z.core.$strip>;
|
|
1863
|
+
type AuthTokenGenResponse = z.infer<typeof AuthTokenGenResponseSchema>;
|
|
1864
|
+
/** Token 状态视图(无值):列表/详情展示形态 */
|
|
1865
|
+
declare const AuthTokenStatusSchema: z.ZodObject<{
|
|
1866
|
+
type: z.ZodEnum<{
|
|
1867
|
+
project: "project";
|
|
1868
|
+
admin: "admin";
|
|
1869
|
+
}>;
|
|
1870
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
1871
|
+
hasToken: z.ZodBoolean;
|
|
1872
|
+
createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
1873
|
+
}, z.core.$strip>;
|
|
1874
|
+
type AuthTokenStatus = z.infer<typeof AuthTokenStatusSchema>;
|
|
1875
|
+
/** whoami 身份查询响应(身份四元组:身份 + 绑定项目 + server 地址 + 开关状态,PRD §3.6) */
|
|
1876
|
+
declare const AuthWhoamiSchema: z.ZodObject<{
|
|
1877
|
+
identity: z.ZodEnum<{
|
|
1878
|
+
none: "none";
|
|
1879
|
+
project: "project";
|
|
1880
|
+
admin: "admin";
|
|
1881
|
+
}>;
|
|
1882
|
+
project: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1883
|
+
id: z.ZodString;
|
|
1884
|
+
key: z.ZodString;
|
|
1885
|
+
name: z.ZodString;
|
|
1886
|
+
}, z.core.$strip>>>;
|
|
1887
|
+
authEnabled: z.ZodBoolean;
|
|
1888
|
+
server: z.ZodObject<{
|
|
1889
|
+
url: z.ZodString;
|
|
1890
|
+
}, z.core.$strip>;
|
|
1891
|
+
}, z.core.$strip>;
|
|
1892
|
+
type AuthWhoami = z.infer<typeof AuthWhoamiSchema>;
|
|
1893
|
+
/** 鉴权开关状态(预鉴权可达,例外②身份元信息) */
|
|
1894
|
+
declare const AuthStatusSchema: z.ZodObject<{
|
|
1895
|
+
authEnabled: z.ZodBoolean;
|
|
1896
|
+
needsSetup: z.ZodBoolean;
|
|
1897
|
+
}, z.core.$strip>;
|
|
1898
|
+
type AuthStatus = z.infer<typeof AuthStatusSchema>;
|
|
1899
|
+
|
|
1900
|
+
/** 凭证哈希单源(T202608310001):密码 scrypt / Token sha256 / 会话 id 随机——全部 Node 内置 crypto,零新依赖 */
|
|
1901
|
+
declare const AUTH_COLLECTIONS: {
|
|
1902
|
+
readonly accounts: "auth_accounts";
|
|
1903
|
+
readonly tokens: "auth_tokens";
|
|
1904
|
+
readonly sessions: "auth_sessions";
|
|
1905
|
+
};
|
|
1906
|
+
declare function createAuthAccountRepo(db: Db): {
|
|
1907
|
+
getAccount(): Promise<AuthAccount | null>;
|
|
1908
|
+
/** 创建唯一管理员账号:已有账号 → 409(并发初始化仅首个成功,PRD §3.2)。
|
|
1909
|
+
* 单例机制 = 固定 _id 插入(E11000 兜底任意并发形态——异名并发同样仅首个成功) */
|
|
1910
|
+
createAccount(username: string, passwordHash: string): Promise<AuthAccount>;
|
|
1911
|
+
updatePassword(accountId: string, newPasswordHash: string): Promise<AuthAccount | null>;
|
|
1912
|
+
list(filter?: mongodb.Filter<mongodb.Document>): Promise<{
|
|
1913
|
+
username: string;
|
|
1914
|
+
passwordHash: string;
|
|
1915
|
+
id?: string | undefined;
|
|
1916
|
+
createdAt?: Date | undefined;
|
|
1917
|
+
updatedAt?: Date | undefined;
|
|
1918
|
+
}[]>;
|
|
1919
|
+
getById(id: string): Promise<{
|
|
1920
|
+
username: string;
|
|
1921
|
+
passwordHash: string;
|
|
1922
|
+
id?: string | undefined;
|
|
1923
|
+
createdAt?: Date | undefined;
|
|
1924
|
+
updatedAt?: Date | undefined;
|
|
1925
|
+
} | null>;
|
|
1926
|
+
getByName(name: string): Promise<{
|
|
1927
|
+
username: string;
|
|
1928
|
+
passwordHash: string;
|
|
1929
|
+
id?: string | undefined;
|
|
1930
|
+
createdAt?: Date | undefined;
|
|
1931
|
+
updatedAt?: Date | undefined;
|
|
1932
|
+
} | null>;
|
|
1933
|
+
create(data: OmitId<{
|
|
1934
|
+
username: string;
|
|
1935
|
+
passwordHash: string;
|
|
1936
|
+
id?: string | undefined;
|
|
1937
|
+
createdAt?: Date | undefined;
|
|
1938
|
+
updatedAt?: Date | undefined;
|
|
1939
|
+
}>): Promise<{
|
|
1940
|
+
username: string;
|
|
1941
|
+
passwordHash: string;
|
|
1942
|
+
id?: string | undefined;
|
|
1943
|
+
createdAt?: Date | undefined;
|
|
1944
|
+
updatedAt?: Date | undefined;
|
|
1945
|
+
}>;
|
|
1946
|
+
update(id: string, patch: EoptPartial<OmitId<{
|
|
1947
|
+
username: string;
|
|
1948
|
+
passwordHash: string;
|
|
1949
|
+
id?: string | undefined;
|
|
1950
|
+
createdAt?: Date | undefined;
|
|
1951
|
+
updatedAt?: Date | undefined;
|
|
1952
|
+
}>>): Promise<{
|
|
1953
|
+
username: string;
|
|
1954
|
+
passwordHash: string;
|
|
1955
|
+
id?: string | undefined;
|
|
1956
|
+
createdAt?: Date | undefined;
|
|
1957
|
+
updatedAt?: Date | undefined;
|
|
1958
|
+
} | null>;
|
|
1959
|
+
delete(id: string): Promise<boolean>;
|
|
1960
|
+
_collection: mongodb.Collection<mongodb.Document>;
|
|
1961
|
+
};
|
|
1962
|
+
declare function createAuthTokenRepo(db: Db): {
|
|
1963
|
+
/** sha256(token 全串含前缀) 等值查询(唯一索引命中) */
|
|
1964
|
+
findByHash(tokenHash: string): Promise<AuthToken | null>;
|
|
1965
|
+
getTokenStatus(type: AuthTokenType, projectId?: string): Promise<{
|
|
1966
|
+
hasToken: boolean;
|
|
1967
|
+
createdAt: Date | null;
|
|
1968
|
+
}>;
|
|
1969
|
+
/** 重置语义:旧 Token 删除 + 新 Token 落库(重置后旧值立即失效,PRD §3.4)。
|
|
1970
|
+
* 事务包删+插(rs0 支持——失败窗口不留零 Token 状态,失败不变性);admin 单例 /
|
|
1971
|
+
* project 每项目一枚由 partial unique 索引兜底并发交错 */
|
|
1972
|
+
upsertToken(type: AuthTokenType, tokenHash: string, projectId?: string): Promise<AuthToken>;
|
|
1973
|
+
listProjectTokenStatuses(projectIds: string[]): Promise<Map<string, {
|
|
1974
|
+
hasToken: boolean;
|
|
1975
|
+
createdAt: Date | null;
|
|
1976
|
+
}>>;
|
|
1977
|
+
list(filter?: mongodb.Filter<mongodb.Document>): Promise<{
|
|
1978
|
+
tokenHash: string;
|
|
1979
|
+
type: "project" | "admin";
|
|
1980
|
+
id?: string | undefined;
|
|
1981
|
+
projectId?: string | undefined;
|
|
1982
|
+
createdAt?: Date | undefined;
|
|
1983
|
+
updatedAt?: Date | undefined;
|
|
1984
|
+
}[]>;
|
|
1985
|
+
getById(id: string): Promise<{
|
|
1986
|
+
tokenHash: string;
|
|
1987
|
+
type: "project" | "admin";
|
|
1988
|
+
id?: string | undefined;
|
|
1989
|
+
projectId?: string | undefined;
|
|
1990
|
+
createdAt?: Date | undefined;
|
|
1991
|
+
updatedAt?: Date | undefined;
|
|
1992
|
+
} | null>;
|
|
1993
|
+
getByName(name: string): Promise<{
|
|
1994
|
+
tokenHash: string;
|
|
1995
|
+
type: "project" | "admin";
|
|
1996
|
+
id?: string | undefined;
|
|
1997
|
+
projectId?: string | undefined;
|
|
1998
|
+
createdAt?: Date | undefined;
|
|
1999
|
+
updatedAt?: Date | undefined;
|
|
2000
|
+
} | null>;
|
|
2001
|
+
create(data: OmitId<{
|
|
2002
|
+
tokenHash: string;
|
|
2003
|
+
type: "project" | "admin";
|
|
2004
|
+
id?: string | undefined;
|
|
2005
|
+
projectId?: string | undefined;
|
|
2006
|
+
createdAt?: Date | undefined;
|
|
2007
|
+
updatedAt?: Date | undefined;
|
|
2008
|
+
}>): Promise<{
|
|
2009
|
+
tokenHash: string;
|
|
2010
|
+
type: "project" | "admin";
|
|
2011
|
+
id?: string | undefined;
|
|
2012
|
+
projectId?: string | undefined;
|
|
2013
|
+
createdAt?: Date | undefined;
|
|
2014
|
+
updatedAt?: Date | undefined;
|
|
2015
|
+
}>;
|
|
2016
|
+
update(id: string, patch: EoptPartial<OmitId<{
|
|
2017
|
+
tokenHash: string;
|
|
2018
|
+
type: "project" | "admin";
|
|
2019
|
+
id?: string | undefined;
|
|
2020
|
+
projectId?: string | undefined;
|
|
2021
|
+
createdAt?: Date | undefined;
|
|
2022
|
+
updatedAt?: Date | undefined;
|
|
2023
|
+
}>>): Promise<{
|
|
2024
|
+
tokenHash: string;
|
|
2025
|
+
type: "project" | "admin";
|
|
2026
|
+
id?: string | undefined;
|
|
2027
|
+
projectId?: string | undefined;
|
|
2028
|
+
createdAt?: Date | undefined;
|
|
2029
|
+
updatedAt?: Date | undefined;
|
|
2030
|
+
} | null>;
|
|
2031
|
+
delete(id: string): Promise<boolean>;
|
|
2032
|
+
_collection: mongodb.Collection<mongodb.Document>;
|
|
2033
|
+
};
|
|
2034
|
+
/** 会话实体(Zod 单源——core DTO 约定;TTL 清理 + 查询二次有效期判定) */
|
|
2035
|
+
declare const AuthSessionSchema: z.ZodObject<{
|
|
2036
|
+
id: z.ZodOptional<z.ZodString>;
|
|
2037
|
+
sessionId: z.ZodString;
|
|
2038
|
+
accountId: z.ZodString;
|
|
2039
|
+
expiresAt: z.ZodDate;
|
|
2040
|
+
createdAt: z.ZodOptional<z.ZodDate>;
|
|
2041
|
+
updatedAt: z.ZodOptional<z.ZodDate>;
|
|
2042
|
+
}, z.core.$strip>;
|
|
2043
|
+
type AuthSession = z.infer<typeof AuthSessionSchema>;
|
|
2044
|
+
declare function createAuthSessionRepo(db: Db): {
|
|
2045
|
+
createSession(sessionId: string, accountId: string, expiresAt: Date): Promise<AuthSession>;
|
|
2046
|
+
/** 有效期判定内联:过期即删返回 null(不等 TTL 清理) */
|
|
2047
|
+
findValidSession(sessionId: string): Promise<AuthSession | null>;
|
|
2048
|
+
deleteBySessionId(sessionId: string): Promise<boolean>;
|
|
2049
|
+
/** 启动时清扫过期会话(幂等,配合 TTL 索引) */
|
|
2050
|
+
deleteExpiredSessions(): Promise<number>;
|
|
2051
|
+
list(filter?: mongodb.Filter<mongodb.Document>): Promise<{
|
|
2052
|
+
sessionId: string;
|
|
2053
|
+
accountId: string;
|
|
2054
|
+
expiresAt: Date;
|
|
2055
|
+
id?: string | undefined;
|
|
2056
|
+
createdAt?: Date | undefined;
|
|
2057
|
+
updatedAt?: Date | undefined;
|
|
2058
|
+
}[]>;
|
|
2059
|
+
getById(id: string): Promise<{
|
|
2060
|
+
sessionId: string;
|
|
2061
|
+
accountId: string;
|
|
2062
|
+
expiresAt: Date;
|
|
2063
|
+
id?: string | undefined;
|
|
2064
|
+
createdAt?: Date | undefined;
|
|
2065
|
+
updatedAt?: Date | undefined;
|
|
2066
|
+
} | null>;
|
|
2067
|
+
getByName(name: string): Promise<{
|
|
2068
|
+
sessionId: string;
|
|
2069
|
+
accountId: string;
|
|
2070
|
+
expiresAt: Date;
|
|
2071
|
+
id?: string | undefined;
|
|
2072
|
+
createdAt?: Date | undefined;
|
|
2073
|
+
updatedAt?: Date | undefined;
|
|
2074
|
+
} | null>;
|
|
2075
|
+
create(data: OmitId<{
|
|
2076
|
+
sessionId: string;
|
|
2077
|
+
accountId: string;
|
|
2078
|
+
expiresAt: Date;
|
|
2079
|
+
id?: string | undefined;
|
|
2080
|
+
createdAt?: Date | undefined;
|
|
2081
|
+
updatedAt?: Date | undefined;
|
|
2082
|
+
}>): Promise<{
|
|
2083
|
+
sessionId: string;
|
|
2084
|
+
accountId: string;
|
|
2085
|
+
expiresAt: Date;
|
|
2086
|
+
id?: string | undefined;
|
|
2087
|
+
createdAt?: Date | undefined;
|
|
2088
|
+
updatedAt?: Date | undefined;
|
|
2089
|
+
}>;
|
|
2090
|
+
update(id: string, patch: EoptPartial<OmitId<{
|
|
2091
|
+
sessionId: string;
|
|
2092
|
+
accountId: string;
|
|
2093
|
+
expiresAt: Date;
|
|
2094
|
+
id?: string | undefined;
|
|
2095
|
+
createdAt?: Date | undefined;
|
|
2096
|
+
updatedAt?: Date | undefined;
|
|
2097
|
+
}>>): Promise<{
|
|
2098
|
+
sessionId: string;
|
|
2099
|
+
accountId: string;
|
|
2100
|
+
expiresAt: Date;
|
|
2101
|
+
id?: string | undefined;
|
|
2102
|
+
createdAt?: Date | undefined;
|
|
2103
|
+
updatedAt?: Date | undefined;
|
|
2104
|
+
} | null>;
|
|
2105
|
+
delete(id: string): Promise<boolean>;
|
|
2106
|
+
_collection: mongodb.Collection<mongodb.Document>;
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
/** 密码哈希存储形态:scrypt$N$r$p$salt$hash(参数内联,升参时存量哈希可校验迁移) */
|
|
2110
|
+
declare function hashPassword(password: string): Promise<string>;
|
|
2111
|
+
/** 密码校验(timingSafeEqual 防时序攻击;格式不符返回 false 不抛错) */
|
|
2112
|
+
declare function verifyPassword(password: string, stored: string): Promise<boolean>;
|
|
2113
|
+
/** Token 明文生成:前缀 + base64url(randomBytes(32))(43 字符 URL-safe,D3) */
|
|
2114
|
+
declare function generateToken(type: 'admin' | 'project'): string;
|
|
2115
|
+
/** Token 前缀合法性与类型提取(非前缀形态 = 格式非法) */
|
|
2116
|
+
declare function tokenTypeFromValue(token: string): AuthTokenKind | null;
|
|
2117
|
+
type AuthTokenKind = 'admin' | 'project';
|
|
2118
|
+
/** Token sha256 hex(哈希对象含前缀全串,D2) */
|
|
2119
|
+
declare function hashToken(token: string): string;
|
|
2120
|
+
/** 会话 id:256bit 随机 hex(D4) */
|
|
2121
|
+
declare function generateSessionId(): string;
|
|
2122
|
+
|
|
1407
2123
|
/**
|
|
1408
2124
|
* 引用文档 Schema(T202608270002:skill/agent 资产多文件支持)
|
|
1409
2125
|
* 引用文档 = 资产主文档之外的附加文档集合,以相对路径标识、内嵌实体存储;
|
|
@@ -1509,7 +2225,9 @@ declare function assertReferenceAggregateLimit(params: {
|
|
|
1509
2225
|
*/
|
|
1510
2226
|
/** 当前导出格式版本(前向兼容锚点:升级格式时递增并处理旧版兼容) */
|
|
1511
2227
|
declare const EXPORT_FORMAT_VERSION = "1.0";
|
|
1512
|
-
/** 模板内容投影:剥 id/projectId/enabled
|
|
2228
|
+
/** 模板内容投影:剥 id/projectId/enabled/时间戳/code;version/isDefault 剥 default 强制显式携带。
|
|
2229
|
+
* T202609020002:code 不入 bundle——code 项目内唯一且不可变,跨环境携带会在同名覆盖时违反不可变
|
|
2230
|
+
* (导入新建按目标项目自动生成,覆盖保留现值;跨环境稳定引用键是后续节点资产 code 的语义)。 */
|
|
1513
2231
|
declare const TemplatePayloadSchema: z.ZodObject<{
|
|
1514
2232
|
name: z.ZodString;
|
|
1515
2233
|
description: z.ZodString;
|
|
@@ -1520,6 +2238,13 @@ declare const TemplatePayloadSchema: z.ZodObject<{
|
|
|
1520
2238
|
track: z.ZodString;
|
|
1521
2239
|
prompt: z.ZodString;
|
|
1522
2240
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
2241
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2242
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
2243
|
+
code: z.ZodString;
|
|
2244
|
+
version: z.ZodString;
|
|
2245
|
+
contentHash: z.ZodString;
|
|
2246
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2247
|
+
}, z.core.$strip>>;
|
|
1523
2248
|
}, z.core.$strip>>;
|
|
1524
2249
|
edges: z.ZodArray<z.ZodObject<{
|
|
1525
2250
|
from: z.ZodString;
|
|
@@ -1613,6 +2338,13 @@ declare const ExportBundleSchema: z.ZodObject<{
|
|
|
1613
2338
|
track: z.ZodString;
|
|
1614
2339
|
prompt: z.ZodString;
|
|
1615
2340
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
2341
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2342
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
2343
|
+
code: z.ZodString;
|
|
2344
|
+
version: z.ZodString;
|
|
2345
|
+
contentHash: z.ZodString;
|
|
2346
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2347
|
+
}, z.core.$strip>>;
|
|
1616
2348
|
}, z.core.$strip>>;
|
|
1617
2349
|
edges: z.ZodArray<z.ZodObject<{
|
|
1618
2350
|
from: z.ZodString;
|
|
@@ -1696,6 +2428,13 @@ declare const ImportPlanRequestSchema: z.ZodObject<{
|
|
|
1696
2428
|
track: z.ZodString;
|
|
1697
2429
|
prompt: z.ZodString;
|
|
1698
2430
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
2431
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2432
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
2433
|
+
code: z.ZodString;
|
|
2434
|
+
version: z.ZodString;
|
|
2435
|
+
contentHash: z.ZodString;
|
|
2436
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2437
|
+
}, z.core.$strip>>;
|
|
1699
2438
|
}, z.core.$strip>>;
|
|
1700
2439
|
edges: z.ZodArray<z.ZodObject<{
|
|
1701
2440
|
from: z.ZodString;
|
|
@@ -1812,6 +2551,13 @@ declare const ImportApplyRequestSchema: z.ZodObject<{
|
|
|
1812
2551
|
track: z.ZodString;
|
|
1813
2552
|
prompt: z.ZodString;
|
|
1814
2553
|
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
2554
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2555
|
+
sourcePreset: z.ZodOptional<z.ZodObject<{
|
|
2556
|
+
code: z.ZodString;
|
|
2557
|
+
version: z.ZodString;
|
|
2558
|
+
contentHash: z.ZodString;
|
|
2559
|
+
agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2560
|
+
}, z.core.$strip>>;
|
|
1815
2561
|
}, z.core.$strip>>;
|
|
1816
2562
|
edges: z.ZodArray<z.ZodObject<{
|
|
1817
2563
|
from: z.ZodString;
|
|
@@ -1975,6 +2721,14 @@ declare const ImportPlanResponseSchema: z.ZodObject<{
|
|
|
1975
2721
|
project: "project";
|
|
1976
2722
|
}>;
|
|
1977
2723
|
}, z.core.$strip>>;
|
|
2724
|
+
directSkillChecks: z.ZodArray<z.ZodObject<{
|
|
2725
|
+
node: z.ZodString;
|
|
2726
|
+
skill: z.ZodString;
|
|
2727
|
+
status: z.ZodEnum<{
|
|
2728
|
+
ok: "ok";
|
|
2729
|
+
missing: "missing";
|
|
2730
|
+
}>;
|
|
2731
|
+
}, z.core.$strip>>;
|
|
1978
2732
|
warnings: z.ZodArray<z.ZodString>;
|
|
1979
2733
|
}, z.core.$strip>;
|
|
1980
2734
|
type ImportPlanResponse = z.infer<typeof ImportPlanResponseSchema>;
|
|
@@ -2016,6 +2770,7 @@ declare const ImportApplyResponseSchema: z.ZodObject<{
|
|
|
2016
2770
|
}>;
|
|
2017
2771
|
message: z.ZodOptional<z.ZodString>;
|
|
2018
2772
|
}, z.core.$strip>>;
|
|
2773
|
+
sourceStripped: z.ZodArray<z.ZodString>;
|
|
2019
2774
|
}, z.core.$strip>;
|
|
2020
2775
|
type ImportApplyResponse = z.infer<typeof ImportApplyResponseSchema>;
|
|
2021
2776
|
/** 决策向量寻址键(skill/agent 含 scope 段,modelAlias 空段) */
|
|
@@ -2070,6 +2825,7 @@ declare const NodeInfoSchema: z.ZodObject<{
|
|
|
2070
2825
|
track: z.ZodString;
|
|
2071
2826
|
prompt: z.ZodString;
|
|
2072
2827
|
skills: z.ZodArray<z.ZodString>;
|
|
2828
|
+
agents: z.ZodArray<z.ZodString>;
|
|
2073
2829
|
upcomingPause: z.ZodNullable<z.ZodString>;
|
|
2074
2830
|
}, z.core.$strip>;
|
|
2075
2831
|
type NodeInfo = z.infer<typeof NodeInfoSchema>;
|
|
@@ -2097,6 +2853,7 @@ declare const AdvanceResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2097
2853
|
track: z.ZodString;
|
|
2098
2854
|
prompt: z.ZodString;
|
|
2099
2855
|
skills: z.ZodArray<z.ZodString>;
|
|
2856
|
+
agents: z.ZodArray<z.ZodString>;
|
|
2100
2857
|
upcomingPause: z.ZodNullable<z.ZodString>;
|
|
2101
2858
|
}, z.core.$strip>;
|
|
2102
2859
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -2167,6 +2924,7 @@ declare const ApproveResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
2167
2924
|
track: z.ZodString;
|
|
2168
2925
|
prompt: z.ZodString;
|
|
2169
2926
|
skills: z.ZodArray<z.ZodString>;
|
|
2927
|
+
agents: z.ZodArray<z.ZodString>;
|
|
2170
2928
|
upcomingPause: z.ZodNullable<z.ZodString>;
|
|
2171
2929
|
}, z.core.$strip>;
|
|
2172
2930
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -2314,6 +3072,72 @@ declare const WriteAckSchema: z.ZodObject<{
|
|
|
2314
3072
|
}, z.core.$strip>;
|
|
2315
3073
|
}, z.core.$strip>;
|
|
2316
3074
|
type WriteAck = z.infer<typeof WriteAckSchema>;
|
|
3075
|
+
/** T202609010002 D6:批量写回执(WriteAck-B)——批量端点聚合形态:逐条新条目标识 +
|
|
3076
|
+
* 逐条失败定位 + 一份任务进度摘要;无逐条 echo(50 条 echo 反向制造膨胀)。
|
|
3077
|
+
* index 一律以调用方原始提交序为基准(artifact 本地 file 读取失败由 CLI 压缩提交,
|
|
3078
|
+
* CLI 负责把服务端序映射回原始序);applied=0 且有 failures 时由 CLI/MCP 层映射为
|
|
3079
|
+
* 失败三要素呈现。acceptance/non-goal 为纯字符串条目无 id/kind,entries 项仅 {index}。 */
|
|
3080
|
+
declare const TaskBatchEntrySchema: z.ZodObject<{
|
|
3081
|
+
index: z.ZodNumber;
|
|
3082
|
+
id: z.ZodOptional<z.ZodString>;
|
|
3083
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
3084
|
+
check: "check";
|
|
3085
|
+
decision: "decision";
|
|
3086
|
+
artifact: "artifact";
|
|
3087
|
+
confirmation: "confirmation";
|
|
3088
|
+
archnote: "archnote";
|
|
3089
|
+
}>>;
|
|
3090
|
+
}, z.core.$strip>;
|
|
3091
|
+
declare const TaskBatchFailureSchema: z.ZodObject<{
|
|
3092
|
+
index: z.ZodNumber;
|
|
3093
|
+
message: z.ZodString;
|
|
3094
|
+
hint: z.ZodOptional<z.ZodString>;
|
|
3095
|
+
}, z.core.$strip>;
|
|
3096
|
+
declare const TaskBatchAckSchema: z.ZodObject<{
|
|
3097
|
+
taskId: z.ZodString;
|
|
3098
|
+
applied: z.ZodNumber;
|
|
3099
|
+
updated: z.ZodArray<z.ZodString>;
|
|
3100
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
3101
|
+
index: z.ZodNumber;
|
|
3102
|
+
id: z.ZodOptional<z.ZodString>;
|
|
3103
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
3104
|
+
check: "check";
|
|
3105
|
+
decision: "decision";
|
|
3106
|
+
artifact: "artifact";
|
|
3107
|
+
confirmation: "confirmation";
|
|
3108
|
+
archnote: "archnote";
|
|
3109
|
+
}>>;
|
|
3110
|
+
}, z.core.$strip>>;
|
|
3111
|
+
failures: z.ZodArray<z.ZodObject<{
|
|
3112
|
+
index: z.ZodNumber;
|
|
3113
|
+
message: z.ZodString;
|
|
3114
|
+
hint: z.ZodOptional<z.ZodString>;
|
|
3115
|
+
}, z.core.$strip>>;
|
|
3116
|
+
updatedAt: z.ZodDate;
|
|
3117
|
+
task: z.ZodObject<{
|
|
3118
|
+
taskId: z.ZodString;
|
|
3119
|
+
title: z.ZodString;
|
|
3120
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
3121
|
+
feature: "feature";
|
|
3122
|
+
bugfix: "bugfix";
|
|
3123
|
+
"ui-tweak": "ui-tweak";
|
|
3124
|
+
research: "research";
|
|
3125
|
+
}>>;
|
|
3126
|
+
currentNode: z.ZodString;
|
|
3127
|
+
currentPhase: z.ZodString;
|
|
3128
|
+
status: z.ZodString;
|
|
3129
|
+
pausedAt: z.ZodNullable<z.ZodString>;
|
|
3130
|
+
track: z.ZodString;
|
|
3131
|
+
projectId: z.ZodString;
|
|
3132
|
+
progress: z.ZodObject<{
|
|
3133
|
+
completed: z.ZodNumber;
|
|
3134
|
+
total: z.ZodNumber;
|
|
3135
|
+
}, z.core.$strip>;
|
|
3136
|
+
}, z.core.$strip>;
|
|
3137
|
+
}, z.core.$strip>;
|
|
3138
|
+
type TaskBatchEntry = z.infer<typeof TaskBatchEntrySchema>;
|
|
3139
|
+
type TaskBatchFailure = z.infer<typeof TaskBatchFailureSchema>;
|
|
3140
|
+
type TaskBatchAck = z.infer<typeof TaskBatchAckSchema>;
|
|
2317
3141
|
/** T202608280007 F1:任务创建响应(原全量 Task 实体)——任务摘要 + 首节点开工资料,与 advance 轻量形态同构 */
|
|
2318
3142
|
declare const CreateTaskResponseSchema: z.ZodObject<{
|
|
2319
3143
|
task: z.ZodObject<{
|
|
@@ -2342,6 +3166,7 @@ declare const CreateTaskResponseSchema: z.ZodObject<{
|
|
|
2342
3166
|
track: z.ZodString;
|
|
2343
3167
|
prompt: z.ZodString;
|
|
2344
3168
|
skills: z.ZodArray<z.ZodString>;
|
|
3169
|
+
agents: z.ZodArray<z.ZodString>;
|
|
2345
3170
|
upcomingPause: z.ZodNullable<z.ZodString>;
|
|
2346
3171
|
}, z.core.$strip>;
|
|
2347
3172
|
}, z.core.$strip>;
|
|
@@ -2383,6 +3208,69 @@ declare const AssetSetEnabledSchema: z.ZodObject<{
|
|
|
2383
3208
|
}, z.core.$strip>;
|
|
2384
3209
|
type AssetSetEnabled = z.infer<typeof AssetSetEnabledSchema>;
|
|
2385
3210
|
|
|
3211
|
+
/**
|
|
3212
|
+
* 模板升级 HTTP 契约(T202609020001 K5)——plan/apply 两阶段协议的请求形状。
|
|
3213
|
+
* plan 响应与 apply 回执形状由 core 顶层模块 template-upgrade.ts 的纯函数类型承载(UpgradePlanResult / UpgradeApplyOutcome)。
|
|
3214
|
+
*/
|
|
3215
|
+
/** 升级节点五态(F23 组合态优先级:hash 差 ⇒ 一律 local-modified——本地修改保护优先于升级提示) */
|
|
3216
|
+
declare const UpgradeNodeStatusSchema: z.ZodEnum<{
|
|
3217
|
+
updatable: "updatable";
|
|
3218
|
+
"local-modified": "local-modified";
|
|
3219
|
+
"up-to-date": "up-to-date";
|
|
3220
|
+
"source-missing": "source-missing";
|
|
3221
|
+
"source-disabled": "source-disabled";
|
|
3222
|
+
}>;
|
|
3223
|
+
type UpgradeNodeStatus = z.infer<typeof UpgradeNodeStatusSchema>;
|
|
3224
|
+
declare const UpgradeActionSchema: z.ZodEnum<{
|
|
3225
|
+
skip: "skip";
|
|
3226
|
+
upgrade: "upgrade";
|
|
3227
|
+
keep: "keep";
|
|
3228
|
+
}>;
|
|
3229
|
+
type UpgradeAction = z.infer<typeof UpgradeActionSchema>;
|
|
3230
|
+
/**
|
|
3231
|
+
* 单节点升级决策。expected(可选)= 决策所依据的 plan 时刻状态——apply 重算当前状态与 expected
|
|
3232
|
+
* 不符 → 422 UPGRADE_STALE(防 plan→apply 时间窗内模板被编辑后决策静默覆盖本地修改);
|
|
3233
|
+
* 省略时仅做不变式校验(source-missing/source-disabled 一律按 skip、local-modified 必须显式决策)。
|
|
3234
|
+
*/
|
|
3235
|
+
declare const UpgradeDecisionSchema: z.ZodObject<{
|
|
3236
|
+
nodeId: z.ZodString;
|
|
3237
|
+
action: z.ZodEnum<{
|
|
3238
|
+
skip: "skip";
|
|
3239
|
+
upgrade: "upgrade";
|
|
3240
|
+
keep: "keep";
|
|
3241
|
+
}>;
|
|
3242
|
+
expected: z.ZodOptional<z.ZodObject<{
|
|
3243
|
+
status: z.ZodEnum<{
|
|
3244
|
+
updatable: "updatable";
|
|
3245
|
+
"local-modified": "local-modified";
|
|
3246
|
+
"up-to-date": "up-to-date";
|
|
3247
|
+
"source-missing": "source-missing";
|
|
3248
|
+
"source-disabled": "source-disabled";
|
|
3249
|
+
}>;
|
|
3250
|
+
}, z.core.$strip>>;
|
|
3251
|
+
}, z.core.$strip>;
|
|
3252
|
+
type UpgradeDecision = z.infer<typeof UpgradeDecisionSchema>;
|
|
3253
|
+
declare const UpgradeApplyRequestSchema: z.ZodObject<{
|
|
3254
|
+
decisions: z.ZodArray<z.ZodObject<{
|
|
3255
|
+
nodeId: z.ZodString;
|
|
3256
|
+
action: z.ZodEnum<{
|
|
3257
|
+
skip: "skip";
|
|
3258
|
+
upgrade: "upgrade";
|
|
3259
|
+
keep: "keep";
|
|
3260
|
+
}>;
|
|
3261
|
+
expected: z.ZodOptional<z.ZodObject<{
|
|
3262
|
+
status: z.ZodEnum<{
|
|
3263
|
+
updatable: "updatable";
|
|
3264
|
+
"local-modified": "local-modified";
|
|
3265
|
+
"up-to-date": "up-to-date";
|
|
3266
|
+
"source-missing": "source-missing";
|
|
3267
|
+
"source-disabled": "source-disabled";
|
|
3268
|
+
}>;
|
|
3269
|
+
}, z.core.$strip>>;
|
|
3270
|
+
}, z.core.$strip>>;
|
|
3271
|
+
}, z.core.$strip>;
|
|
3272
|
+
type UpgradeApplyRequest = z.infer<typeof UpgradeApplyRequestSchema>;
|
|
3273
|
+
|
|
2386
3274
|
/**
|
|
2387
3275
|
* 服务配置 schema(N018 D5):Zod 单一真相源,core 只承载纯 schema + env 键映射,
|
|
2388
3276
|
* 零 fs/process I/O(保持 core 领域纯净)。JSONC 文件加载/分层合并/来源追踪的 loader 在
|
|
@@ -2406,12 +3294,14 @@ declare const SimingConfigSchema: z.ZodObject<{
|
|
|
2406
3294
|
info: "info";
|
|
2407
3295
|
warn: "warn";
|
|
2408
3296
|
}>>;
|
|
2409
|
-
auth: z.
|
|
3297
|
+
auth: z.ZodPrefault<z.ZodObject<{
|
|
3298
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
3299
|
+
}, z.core.$strip>>;
|
|
2410
3300
|
cors: z.ZodOptional<z.ZodUnknown>;
|
|
2411
3301
|
}, z.core.$strip>;
|
|
2412
3302
|
type SimingConfig = z.infer<typeof SimingConfigSchema>;
|
|
2413
|
-
/** 可经环境变量/CLI 参数/配置文件配置的 key
|
|
2414
|
-
declare const SIMING_CONFIG_KEYS: readonly ["mongoUri", "port", "host", "logLevel"];
|
|
3303
|
+
/** 可经环境变量/CLI 参数/配置文件配置的 key(cors 仍为预留字段) */
|
|
3304
|
+
declare const SIMING_CONFIG_KEYS: readonly ["mongoUri", "port", "host", "logLevel", "auth"];
|
|
2415
3305
|
type SimingConfigKey = (typeof SIMING_CONFIG_KEYS)[number];
|
|
2416
3306
|
/**
|
|
2417
3307
|
* env 键映射单源(N018 D5):server env resolver 与 cli loader 共用,
|
|
@@ -2419,12 +3309,17 @@ type SimingConfigKey = (typeof SIMING_CONFIG_KEYS)[number];
|
|
|
2419
3309
|
* 沿用既有 server EnvSchema 约定(见 ENVIRONMENT.md)。
|
|
2420
3310
|
*/
|
|
2421
3311
|
declare const SIMING_CONFIG_ENV_KEYS: Record<SimingConfigKey, string>;
|
|
3312
|
+
/**
|
|
3313
|
+
* auth 键的 env 值解析(布尔字符串形态):SIMING_AUTH_ENABLED=true/false,
|
|
3314
|
+
* 其余值 fail-fast 由调用方处理(返回 undefined 表示 env 未提供)。
|
|
3315
|
+
*/
|
|
3316
|
+
declare function parseAuthEnabledEnvValue(raw: string): boolean | undefined;
|
|
2422
3317
|
|
|
2423
3318
|
/**
|
|
2424
3319
|
* Domain error types — thrown by core business logic, caught by server's app.onError().
|
|
2425
3320
|
*/
|
|
2426
3321
|
/** N012 语义化业务错误码(可选挂载到 AppError 子类;HTTP 形状向后兼容:error 字段缺省仍为 http 级 code) */
|
|
2427
|
-
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' | 'REFERENCE_IN_USE' | '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' | 'TEMPLATE_DISABLED';
|
|
3322
|
+
type BizCode = 'PROJECT_ARCHIVED' | 'TEMPLATE_PROJECT_MISMATCH' | 'TEMPLATE_PROJECT_IMMUTABLE' | 'SCOPE_IMMUTABLE' | 'TASK_PROJECT_IMMUTABLE' | 'DEFAULT_PROJECT_IMMUTABLE' | 'TEMPLATE_NAME_CONFLICT' | 'TEMPLATE_CODE_CONFLICT' | 'TEMPLATE_CODE_IMMUTABLE' | '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' | 'REFERENCE_IN_USE' | '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' | 'TEMPLATE_DISABLED' | 'AUTH_REQUIRED' | 'AUTH_TOKEN_INVALID' | 'AUTH_INVALID_CREDENTIALS' | 'AUTH_FORBIDDEN' | 'AUTH_ACCOUNT_EXISTS' | 'BATCH_EMPTY' | 'BATCH_LIMIT_EXCEEDED' | 'BATCH_PAYLOAD_TOO_LARGE' | 'NODE_PRESET_CODE_EXISTS' | 'NODE_PRESET_CODE_IMMUTABLE' | 'NODE_PRESET_VERSION_REQUIRED' | 'TEMPLATE_NODE_ID_DUPLICATE' | 'NODE_LIBRARY_COMPOSITION_NOT_FOUND' | 'UPGRADE_DECISION_REQUIRED' | 'UPGRADE_STALE' | 'FLOW_MANIFEST_INVALID';
|
|
2428
3323
|
/** bizCode → 用户可读中文 message(单一真相源,路由层抛错时引用) */
|
|
2429
3324
|
declare const BIZ_CODE_MESSAGES: Record<BizCode, string>;
|
|
2430
3325
|
interface AppErrorOptions {
|
|
@@ -2445,7 +3340,28 @@ declare class NotFoundError extends AppError {
|
|
|
2445
3340
|
readonly code = "not_found";
|
|
2446
3341
|
constructor(resource: string, id: string, options?: AppErrorOptions);
|
|
2447
3342
|
readonly bizCode?: BizCode;
|
|
3343
|
+
/**
|
|
3344
|
+
* T202609020002:not-found 相近候选清单(模板寻址防转录错误——格式合法但不存在的
|
|
3345
|
+
* code/数据库 id,错误信息携带项目内相近模板,转录错误可当场发现)。附加到响应体
|
|
3346
|
+
* 的 candidates 字段;仅模板寻址路由经 withTemplateCandidates 注入(构造后写入故非
|
|
3347
|
+
* readonly——外部读、内部一次写),其余资源 not-found 形态不变。
|
|
3348
|
+
*/
|
|
3349
|
+
templateCandidates?: {
|
|
3350
|
+
id: string;
|
|
3351
|
+
code: string;
|
|
3352
|
+
name: string;
|
|
3353
|
+
}[];
|
|
3354
|
+
withTemplateCandidates(candidates: {
|
|
3355
|
+
id: string;
|
|
3356
|
+
code: string;
|
|
3357
|
+
name: string;
|
|
3358
|
+
}[]): this;
|
|
2448
3359
|
toResponse(): {
|
|
3360
|
+
candidates?: {
|
|
3361
|
+
id: string;
|
|
3362
|
+
code: string;
|
|
3363
|
+
name: string;
|
|
3364
|
+
}[];
|
|
2449
3365
|
error: string;
|
|
2450
3366
|
message: string;
|
|
2451
3367
|
resource: string;
|
|
@@ -2490,6 +3406,28 @@ declare class ValidationError extends AppError {
|
|
|
2490
3406
|
issues: unknown[];
|
|
2491
3407
|
};
|
|
2492
3408
|
}
|
|
3409
|
+
/** 401 未授权(T202608310001:鉴权域——无凭证/凭证无效;message 取 BIZ_CODE_MESSAGES 单源) */
|
|
3410
|
+
declare class UnauthorizedError extends AppError {
|
|
3411
|
+
readonly bizCode: Extract<BizCode, 'AUTH_REQUIRED' | 'AUTH_TOKEN_INVALID' | 'AUTH_INVALID_CREDENTIALS'>;
|
|
3412
|
+
readonly statusCode = 401;
|
|
3413
|
+
readonly code = "unauthorized";
|
|
3414
|
+
constructor(bizCode: Extract<BizCode, 'AUTH_REQUIRED' | 'AUTH_TOKEN_INVALID' | 'AUTH_INVALID_CREDENTIALS'>);
|
|
3415
|
+
toResponse(): {
|
|
3416
|
+
error: "AUTH_REQUIRED" | "AUTH_TOKEN_INVALID" | "AUTH_INVALID_CREDENTIALS";
|
|
3417
|
+
message: string;
|
|
3418
|
+
};
|
|
3419
|
+
}
|
|
3420
|
+
/** 403 禁止(T202608310001:project 上下文越权 admin-only 端点) */
|
|
3421
|
+
declare class ForbiddenError extends AppError {
|
|
3422
|
+
readonly statusCode = 403;
|
|
3423
|
+
readonly code = "forbidden";
|
|
3424
|
+
readonly bizCode: "AUTH_FORBIDDEN";
|
|
3425
|
+
constructor();
|
|
3426
|
+
toResponse(): {
|
|
3427
|
+
error: "AUTH_FORBIDDEN";
|
|
3428
|
+
message: string;
|
|
3429
|
+
};
|
|
3430
|
+
}
|
|
2493
3431
|
|
|
2494
3432
|
/**
|
|
2495
3433
|
* 资产版本(skill/agent 的 version 字段)递增单源(T202608260002 D1 自 cli export 上移)。
|
|
@@ -2506,6 +3444,144 @@ declare function bumpPatch(version: string): string;
|
|
|
2506
3444
|
/** export 宽松语义:解析失败原样返回(不误伤自由文本版本) */
|
|
2507
3445
|
declare function bumpPatchOrPassthrough(version: string): string;
|
|
2508
3446
|
|
|
3447
|
+
/**
|
|
3448
|
+
* 模板内容比较(T202609030001 F1):导入内容 vs 服务器现值(同名同版本场景的门控 +
|
|
3449
|
+
* 两条 updated 分支的变更范围)。纯函数,无 I/O。
|
|
3450
|
+
*
|
|
3451
|
+
* 比较域 = name / description / nodes / edges / layout;不参与比较 =
|
|
3452
|
+
* id / createdAt / updatedAt / enabled / code / projectId / isDefault / version
|
|
3453
|
+
*(isDefault 跟随 export 先例,不由导入通道管理)。
|
|
3454
|
+
*/
|
|
3455
|
+
interface TemplateContentSource {
|
|
3456
|
+
name: string;
|
|
3457
|
+
description: string;
|
|
3458
|
+
nodes: DagNode[];
|
|
3459
|
+
edges: DagEdge[];
|
|
3460
|
+
layout?: Record<string, {
|
|
3461
|
+
x: number;
|
|
3462
|
+
y: number;
|
|
3463
|
+
}> | undefined;
|
|
3464
|
+
}
|
|
3465
|
+
/** 变更范围(预览 changes / 回执同构) */
|
|
3466
|
+
interface TemplateContentChanges {
|
|
3467
|
+
nodesAdded: string[];
|
|
3468
|
+
nodesRemoved: string[];
|
|
3469
|
+
nodesChanged: string[];
|
|
3470
|
+
edgesChanged: boolean;
|
|
3471
|
+
descriptionChanged: boolean;
|
|
3472
|
+
layoutChanged: boolean;
|
|
3473
|
+
}
|
|
3474
|
+
interface TemplateContentDiff {
|
|
3475
|
+
identical: boolean;
|
|
3476
|
+
changes: TemplateContentChanges;
|
|
3477
|
+
}
|
|
3478
|
+
/**
|
|
3479
|
+
* 导入内容 vs 服务器现值的内容比较。
|
|
3480
|
+
* canonical 归一:nodes 按 id 对齐(顺序差异不视为变更,skills 顺序不敏感由
|
|
3481
|
+
* computeNodeContentHash 保证);edges 排序后比较;layout 缺省归一为空对象;
|
|
3482
|
+
* description 原样比较(不 trim)。
|
|
3483
|
+
*/
|
|
3484
|
+
declare function diffTemplateContent(imported: TemplateContentSource, existing: TemplateContentSource): TemplateContentDiff;
|
|
3485
|
+
|
|
3486
|
+
/** 参与 hash 的内容字段(nodeId 不参与——模板内可改名,属模板图结构域非内容域) */
|
|
3487
|
+
type NodeContentFields = Pick<DagNode, 'label' | 'phase' | 'track' | 'prompt' | 'skills'>;
|
|
3488
|
+
/**
|
|
3489
|
+
* 节点内容规范化摘要(T202609020001 K2):sha256 → hex 前 16 位。
|
|
3490
|
+
* core 单源导出——server(节点详情响应 contentHash / 升级基线)与模板组装方共用同一算法,杜绝两端漂移。
|
|
3491
|
+
* 规范化规则:skills 排序后参与(数组顺序不敏感);对象字面量序固定(JSON.stringify 按 key 声明序)。
|
|
3492
|
+
*/
|
|
3493
|
+
declare function computeNodeContentHash(node: NodeContentFields): string;
|
|
3494
|
+
|
|
3495
|
+
/**
|
|
3496
|
+
* 模板升级状态机与决策执行(T202609020001 K5/K2/F23 纯函数层)。
|
|
3497
|
+
* server 路由层负责寻址/鉴权/落库,本模块只做「模板 + 节点库快照 → plan/apply 结果」的纯计算——
|
|
3498
|
+
* 单测直接覆盖五态与竞态路径,不依赖 HTTP。
|
|
3499
|
+
*
|
|
3500
|
+
* 双信号分工(K2):version 判 updatable(K13 升版强制保证版本信号可靠)、
|
|
3501
|
+
* contentHash 判 local-modified(模板节点当前内容 hash ≠ sourcePreset 基线)。
|
|
3502
|
+
* 组合态优先级(F23):hash 差存在 ⇒ status 一律 local-modified(本地修改保护优先于升级提示)。
|
|
3503
|
+
*/
|
|
3504
|
+
/** 单节点升级计划条目(plan 响应形状) */
|
|
3505
|
+
interface UpgradePlanItem {
|
|
3506
|
+
nodeId: string;
|
|
3507
|
+
source: {
|
|
3508
|
+
code: string;
|
|
3509
|
+
version: string;
|
|
3510
|
+
contentHash: string;
|
|
3511
|
+
};
|
|
3512
|
+
latest: {
|
|
3513
|
+
version: string;
|
|
3514
|
+
contentHash: string;
|
|
3515
|
+
enabled: boolean;
|
|
3516
|
+
} | null;
|
|
3517
|
+
status: UpgradeNodeStatus;
|
|
3518
|
+
localModified: boolean;
|
|
3519
|
+
diff: {
|
|
3520
|
+
prompt: 'changed' | null;
|
|
3521
|
+
label: 'changed' | null;
|
|
3522
|
+
phase: 'changed' | null;
|
|
3523
|
+
track: 'changed' | null;
|
|
3524
|
+
skills: {
|
|
3525
|
+
added: string[];
|
|
3526
|
+
removed: string[];
|
|
3527
|
+
} | null;
|
|
3528
|
+
agents: {
|
|
3529
|
+
added: string[];
|
|
3530
|
+
removed: string[];
|
|
3531
|
+
} | null;
|
|
3532
|
+
};
|
|
3533
|
+
}
|
|
3534
|
+
interface UpgradePlanResult {
|
|
3535
|
+
templateVersion: string;
|
|
3536
|
+
items: UpgradePlanItem[];
|
|
3537
|
+
upgradableCount: number;
|
|
3538
|
+
}
|
|
3539
|
+
/** apply 结果条目 */
|
|
3540
|
+
interface UpgradeApplyResultItem {
|
|
3541
|
+
nodeId: string;
|
|
3542
|
+
action: 'upgrade' | 'keep' | 'skip';
|
|
3543
|
+
applied: boolean;
|
|
3544
|
+
reason?: string | undefined;
|
|
3545
|
+
}
|
|
3546
|
+
interface UpgradeApplyOutcome {
|
|
3547
|
+
/** apply 后的完整节点数组(路由层一次 repo.update 原子落库——单文档更新无中间态) */
|
|
3548
|
+
nodes: DagNode[];
|
|
3549
|
+
/** apply 后模板版本(patch+1);null = 无实际变更不升版 */
|
|
3550
|
+
nextVersion: string | null;
|
|
3551
|
+
results: UpgradeApplyResultItem[];
|
|
3552
|
+
}
|
|
3553
|
+
/** apply 决策入参(HTTP UpgradeDecision 的子集形状——expected 可选,见 schema 注释) */
|
|
3554
|
+
interface UpgradeDecisionInput {
|
|
3555
|
+
nodeId: string;
|
|
3556
|
+
action: 'upgrade' | 'keep' | 'skip';
|
|
3557
|
+
expected?: {
|
|
3558
|
+
status: UpgradeNodeStatus;
|
|
3559
|
+
} | undefined;
|
|
3560
|
+
}
|
|
3561
|
+
/** 单节点状态机(F23 组合态优先级)。无 sourcePreset 的节点不参与升级(plan 已过滤,此处为防御分支) */
|
|
3562
|
+
declare function computeUpgradeStatus(node: DagNode, latest: NodePreset | null): {
|
|
3563
|
+
status: UpgradeNodeStatus;
|
|
3564
|
+
localModified: boolean;
|
|
3565
|
+
};
|
|
3566
|
+
/** 组装升级计划(纯函数)。presetsByCode 须含停用资产(source-disabled 判定依赖) */
|
|
3567
|
+
declare function buildUpgradePlan(template: DagTemplate, presetsByCode: ReadonlyMap<string, NodePreset>): UpgradePlanResult;
|
|
3568
|
+
/**
|
|
3569
|
+
* apply 决策执行(纯函数;写库由路由层一次原子更新完成)。
|
|
3570
|
+
*
|
|
3571
|
+
* 决策表(K5):
|
|
3572
|
+
* - upgrade:节点内容 ← 库最新值拷贝(nodeId 保持模板内现值——图结构域不迁移),基线回到库内容
|
|
3573
|
+
* - keep:内容保持本地,基线重置为本地内容 hash + 版本对齐已读库版本(下轮 plan 以版本判定不再提示,
|
|
3574
|
+
* 库再演进才重新提示——「不重复骚扰」语义)
|
|
3575
|
+
* - skip:不动,下轮 plan 仍列出
|
|
3576
|
+
*
|
|
3577
|
+
* 守卫(按序):
|
|
3578
|
+
* 1. 决策 nodeId 必须命中带 sourcePreset 的模板节点(未知/重复 → 422)
|
|
3579
|
+
* 2. local-modified(含组合态)节点缺决策 → 422 UPGRADE_DECISION_REQUIRED(强制显式决策)
|
|
3580
|
+
* 3. source-missing / source-disabled 一律按缺省 skip(无 upgrade/keep 语义可执行)
|
|
3581
|
+
* 4. STALE 重验:决策携带 expected 且与 apply 时刻重算状态不符 → 422 UPGRADE_STALE(附变化清单)
|
|
3582
|
+
*/
|
|
3583
|
+
declare function applyUpgradeDecisions(template: DagTemplate, presetsByCode: ReadonlyMap<string, NodePreset>, decisions: ReadonlyArray<UpgradeDecisionInput>): UpgradeApplyOutcome;
|
|
3584
|
+
|
|
2509
3585
|
/**
|
|
2510
3586
|
* N017 F8 流转引擎(新语义状态机,见技术方案 §2.2):
|
|
2511
3587
|
*
|
|
@@ -2640,12 +3716,13 @@ declare function generateEntryId(existing: readonly string[]): string;
|
|
|
2640
3716
|
*/
|
|
2641
3717
|
declare function renderPrompt(template: string, task: Task): string;
|
|
2642
3718
|
|
|
2643
|
-
/** 模板导入/导出编排依赖(repo 显式注入,无 DI
|
|
3719
|
+
/** 模板导入/导出编排依赖(repo 显式注入,无 DI 框架);nodePresetRepo 供 K10 sourcePreset 存在性检查 */
|
|
2644
3720
|
interface TemplateTransferDeps {
|
|
2645
3721
|
templateRepo: DagTemplateRepo;
|
|
2646
3722
|
skillRepo: SkillRepo;
|
|
2647
3723
|
agentRepo: AgentRepo;
|
|
2648
3724
|
modelAliasRepo: ModelAliasRepo;
|
|
3725
|
+
nodePresetRepo: NodePresetRepo;
|
|
2649
3726
|
}
|
|
2650
3727
|
/**
|
|
2651
3728
|
* 导出依赖闭包推导(T202608300002 §2.2,PRD 3.1 规则 1-4,一跳封闭):
|
|
@@ -2688,4 +3765,4 @@ declare function applyImport(deps: TemplateTransferDeps, targetProjectId: string
|
|
|
2688
3765
|
declare const VERSION: string;
|
|
2689
3766
|
declare function ping(): string;
|
|
2690
3767
|
|
|
2691
|
-
export { AGENT_MAIN_DOC, ARTIFACT_TYPES, type AdvanceDeps, type AdvanceInput, type AdvanceRequest, AdvanceRequestSchema, type AdvanceResponse, AdvanceResponseSchema, type Agent, type AgentCopy, AgentCopySchema, type AgentCreate, AgentCreateSchema, type AgentFunction, AgentFunctionSchema, type AgentPayload, AgentPayloadSchema, type AgentRepo, AgentSchema, type AgentScope, AgentScopeSchema, AgentShapeSchema, type AgentUpdate, AgentUpdateSchema, AppError, type AppErrorOptions, type ApproveRequest, ApproveRequestSchema, type ApproveResponse, ApproveResponseSchema, type ArchNote, ArchNoteSchema, type Artifact, ArtifactSchema, type ArtifactType, type AssetListOpts, type AssetSetEnabled, AssetSetEnabledSchema, BIZ_CODE_MESSAGES, BadRequestError, type BizCode, CONTEXT_VIEWS, type CancelRequest, CancelRequestSchema, type CheckItem, CheckItemSchema, type Confirmation, ConfirmationSchema, ConflictError, type ContextView, ContextViewSchema, type CreateTaskResponse, CreateTaskResponseSchema, 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, type DependencyAction, DependencyActionSchema, type DependencyCheck, DependencyCheckSchema, type DependencyStatus, DependencyStatusSchema, ENTRY_ID_REGEX, EXPORT_FORMAT_VERSION, type EchoItem, EchoItemSchema, type EdgePausePoint, EdgePausePointBaseSchema, EdgePausePointSchema, type EnumEntry, EnumEntrySchema, type EnumRegistry, type EnumRegistryCategory, EnumRegistryCategorySchema, type EnumRegistryRepo, EnumRegistrySchema, type EnumRegistryUpdate, EnumRegistryUpdateSchema, type ExportBundle, ExportBundleSchema, HistoryActionSchema, type HistoryEntry, HistoryEntrySchema, type ImportApplyRequest, ImportApplyRequestSchema, type ImportApplyResponse, ImportApplyResponseSchema, type ImportDecision, ImportDecisionSchema, type ImportPlanRequest, ImportPlanRequestSchema, type ImportPlanResponse, ImportPlanResponseSchema, type ModelAlias, type ModelAliasCreate, ModelAliasCreateSchema, type ModelAliasPayload, ModelAliasPayloadSchema, 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, REFERENCE_LIMITS, type ReferenceDoc, type Repo, type ResumeRequest, ResumeRequestSchema, type ReviewSummary, ReviewSummarySchema, SIMING_CODE_REGEX, SIMING_CONFIG_ENV_KEYS, SIMING_CONFIG_KEYS, SKILL_MAIN_DOC, type SimingClient, type SimingConfig, type SimingConfigKey, SimingConfigSchema, SimingLogLevelSchema, type Skill, type SkillCopy, SkillCopySchema, type SkillCreate, SkillCreateSchema, type SkillPayload, SkillPayloadSchema, type SkillRepo, SkillSchema, type SkillScope, SkillScopeSchema, SkillShapeSchema, type SkillUpdate, SkillUpdateSchema, TASK_PHASES, TASK_STATUSES, TASK_TYPES, type Task, type TaskContext, TaskContextSchema, type TaskCreateInput, TaskCreateInputSchema, type TaskDocContent, TaskDocContentSchema, type TaskPatch, TaskPhaseSchema, type TaskProgress, type TaskProgressPublic, TaskProgressPublicSchema, TaskProgressSchema, type TaskPublic, TaskPublicSchema, type TaskRepo, TaskSchema, TaskStatusSchema, type TaskSummary, TaskSummarySchema, type TaskType, type TemplatePayload, TemplatePayloadSchema, type TemplateTransferDeps, VERSION, ValidationError, WRITE_ACK_ENTRY_KINDS, type WithId, type WriteAck, type WriteAckEntryKind, WriteAckEntryKindSchema, WriteAckSchema, advanceTask, applyImport, approveTask, assertBoundSkillsCompatible, assertModelAliasExists, assertReferenceAggregateLimit, assertReferencesDeletable, buildImportPlan, bumpPatch, bumpPatchOrPassthrough, cancelTask, canonicalizeReferencePath, checkTermination, composeExportBundle, createAgentRepo, createDagTemplateRepo, createEnumRegistryRepo, createModelAliasRepo, createMongoClient, createProjectRepo, createReferencesSchema, createRepo, createSkillRepo, createTaskRepo, decisionKey, enabledNeFalse, escapeRegExpLiteral, excerpt, findNextEdge, findTemplateByName, generateEntryId, generateProjectKey, hasProjectDefault, mkHistory, pauseTask, ping, pruneInstance, renderPrompt, resumeTask, sumReferenceContentChars, taskProgress, toNodeInfo, toTaskPublic, trackMatchSet, withTransaction };
|
|
3768
|
+
export { AGENT_MAIN_DOC, ARTIFACT_TYPES, AUTH_COLLECTIONS, type AdvanceDeps, type AdvanceInput, type AdvanceRequest, AdvanceRequestSchema, type AdvanceResponse, AdvanceResponseSchema, type Agent, type AgentCopy, AgentCopySchema, type AgentCreate, AgentCreateSchema, type AgentFunction, AgentFunctionSchema, type AgentPayload, AgentPayloadSchema, type AgentRepo, AgentSchema, type AgentScope, AgentScopeSchema, AgentShapeSchema, type AgentUpdate, AgentUpdateSchema, AppError, type AppErrorOptions, type ApproveRequest, ApproveRequestSchema, type ApproveResponse, ApproveResponseSchema, type ArchNote, ArchNoteSchema, type Artifact, ArtifactSchema, type ArtifactType, type AssetListOpts, type AssetSetEnabled, AssetSetEnabledSchema, type AuthAccount, type AuthAccountCreate, AuthAccountCreateSchema, AuthAccountSchema, type AuthSession, type AuthStatus, AuthStatusSchema, type AuthToken, type AuthTokenGenResponse, AuthTokenGenResponseSchema, type AuthTokenKind, AuthTokenSchema, type AuthTokenStatus, AuthTokenStatusSchema, type AuthTokenType, AuthTokenTypeSchema, type AuthWhoami, AuthWhoamiSchema, BIZ_CODE_MESSAGES, BadRequestError, type BizCode, CONTEXT_VIEWS, type CancelRequest, CancelRequestSchema, type CheckItem, CheckItemSchema, type Composition, type CompositionEdge, CompositionEdgeSchema, CompositionSchema, type Confirmation, ConfirmationSchema, ConflictError, type ContextView, ContextViewSchema, type CreateTaskResponse, CreateTaskResponseSchema, DAG_PHASES, DAG_TRACKS, DEFAULT_PROJECT_KEY, type DagEdge, DagEdgeSchema, type DagInstance, type DagInstanceNode, DagInstanceNodeSchema, DagInstanceSchema, type DagNode, DagNodePhaseSchema, DagNodeSchema, DagNodeTrackSchema, type DagTemplate, type DagTemplateCopy, DagTemplateCopySchema, type DagTemplateCreate, DagTemplateCreateSchema, type DagTemplateRepo, DagTemplateSchema, type DagTemplateUpdate, DagTemplateUpdateSchema, type Decision, DecisionSchema, type DependencyAction, DependencyActionSchema, type DependencyCheck, DependencyCheckSchema, type DependencyStatus, DependencyStatusSchema, ENTRY_ID_REGEX, EXPORT_FORMAT_VERSION, type EchoItem, EchoItemSchema, type EdgePausePoint, EdgePausePointBaseSchema, EdgePausePointSchema, type EnumEntry, EnumEntrySchema, type EnumRegistry, type EnumRegistryCategory, EnumRegistryCategorySchema, type EnumRegistryRepo, EnumRegistrySchema, type EnumRegistryUpdate, EnumRegistryUpdateSchema, type ExportBundle, ExportBundleSchema, ForbiddenError, HistoryActionSchema, type HistoryEntry, HistoryEntrySchema, type ImportApplyRequest, ImportApplyRequestSchema, type ImportApplyResponse, ImportApplyResponseSchema, type ImportDecision, ImportDecisionSchema, type ImportPlanRequest, ImportPlanRequestSchema, type ImportPlanResponse, ImportPlanResponseSchema, type LoginInput, LoginSchema, type ModelAlias, type ModelAliasCreate, ModelAliasCreateSchema, type ModelAliasPayload, ModelAliasPayloadSchema, type ModelAliasRepo, ModelAliasSchema, ModelAliasShapeSchema, type ModelAliasUpdate, ModelAliasUpdateSchema, type ModelAliasWithRefCount, ModelAliasWithRefCountSchema, NODE_ID_PATTERN, NODE_PRESET_CODE_PATTERN, NODE_STATUSES, type NodeContentFields, type NodeInfo, NodeInfoSchema, type NodeLibrary, type NodeLibraryRepo, NodeLibrarySchema, type NodeLibraryUpsert, NodeLibraryUpsertSchema, type NodePreset, type NodePresetCopy, NodePresetCopySchema, type NodePresetCreate, NodePresetCreateSchema, type NodePresetListFilter, type NodePresetRepo, NodePresetSchema, NodePresetShapeSchema, type NodePresetUpdate, NodePresetUpdateSchema, type NodeRecord, NodeRecordSchema, type NodeState, NodeStateSchema, NodeStatusSchema, NotFoundError, OBJECT_ID_HEX, type OmitId, PAUSE_POINT_TYPES, type PasswordChange, PasswordChangeSchema, PausePointTypeSchema, type PauseRequest, PauseRequestSchema, type Project, type ProjectCreate, ProjectCreateSchema, type ProjectRepo, ProjectSchema, type ProjectStatus, ProjectStatusSchema, type ProjectUpdate, ProjectUpdateSchema, type PruneResult, REFERENCE_LIMITS, type ReferenceDoc, type Repo, type ResumeRequest, ResumeRequestSchema, type ReviewSummary, ReviewSummarySchema, SIMING_CODE_REGEX, SIMING_CONFIG_ENV_KEYS, SIMING_CONFIG_KEYS, SKILL_MAIN_DOC, type SimingClient, type SimingConfig, type SimingConfigKey, SimingConfigSchema, SimingLogLevelSchema, type Skill, type SkillCopy, SkillCopySchema, type SkillCreate, SkillCreateSchema, type SkillPayload, SkillPayloadSchema, type SkillRepo, SkillSchema, type SkillScope, SkillScopeSchema, SkillShapeSchema, type SkillUpdate, SkillUpdateSchema, type SourcePreset, SourcePresetSchema, TASK_PHASES, TASK_STATUSES, TASK_TYPES, TEMPLATE_CODE_MAX_LENGTH, TEMPLATE_CODE_REGEX, type Task, type TaskBatchAck, TaskBatchAckSchema, type TaskBatchEntry, TaskBatchEntrySchema, type TaskBatchFailure, TaskBatchFailureSchema, type TaskContext, TaskContextSchema, type TaskCreateInput, TaskCreateInputSchema, type TaskDocContent, TaskDocContentSchema, type TaskPatch, TaskPhaseSchema, type TaskProgress, type TaskProgressPublic, TaskProgressPublicSchema, TaskProgressSchema, type TaskPublic, TaskPublicSchema, type TaskRepo, TaskSchema, TaskStatusSchema, type TaskSummary, TaskSummarySchema, type TaskType, type TemplateCandidate, TemplateCandidateSchema, TemplateCodeFieldSchema, type TemplateContentChanges, type TemplateContentDiff, type TemplateContentSource, type TemplatePayload, TemplatePayloadSchema, type TemplateTransferDeps, UnauthorizedError, type UpgradeAction, UpgradeActionSchema, type UpgradeApplyOutcome, type UpgradeApplyRequest, UpgradeApplyRequestSchema, type UpgradeApplyResultItem, type UpgradeDecision, type UpgradeDecisionInput, UpgradeDecisionSchema, type UpgradeNodeStatus, UpgradeNodeStatusSchema, type UpgradePlanItem, type UpgradePlanResult, VERSION, ValidationError, WRITE_ACK_ENTRY_KINDS, type WithId, type WriteAck, type WriteAckEntryKind, WriteAckEntryKindSchema, WriteAckSchema, advanceTask, applyImport, applyUpgradeDecisions, approveTask, assertBoundSkillsCompatible, assertModelAliasExists, assertReferenceAggregateLimit, assertReferencesDeletable, assertUniqueNodeIds, buildImportPlan, buildTemplateCode, buildUpgradePlan, bumpPatch, bumpPatchOrPassthrough, cancelTask, canonicalizeReferencePath, checkTermination, composeExportBundle, computeNodeContentHash, computeUpgradeStatus, createAgentRepo, createAuthAccountRepo, createAuthSessionRepo, createAuthTokenRepo, createDagTemplateRepo, createEnumRegistryRepo, createModelAliasRepo, createMongoClient, createNodeLibraryRepo, createNodePresetRepo, createProjectRepo, createReferencesSchema, createRepo, createSkillRepo, createTaskRepo, decisionKey, diffTemplateContent, enabledNeFalse, escapeRegExpLiteral, excerpt, findDuplicateNodeIds, findNextEdge, findTemplateByName, generateEntryId, generateProjectKey, generateSessionId, generateToken, hasProjectDefault, hashPassword, hashToken, isLegalTemplateCode, mkHistory, normalizeNameToTemplateCode, parseAuthEnabledEnvValue, pauseTask, ping, pruneInstance, renderPrompt, resumeTask, sumReferenceContentChars, taskProgress, toNodeInfo, toTaskPublic, tokenTypeFromValue, trackMatchSet, verifyPassword, withTransaction };
|