@world-engines/dag-flow 0.1.3-alpha.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/LICENSE +46 -0
- package/dist/document.d.ts +193 -0
- package/dist/document.js +704 -0
- package/dist/executor.d.ts +136 -0
- package/dist/executor.js +543 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/sandbox.d.ts +43 -0
- package/dist/sandbox.js +379 -0
- package/dist/tmw-scribe.d.ts +88 -0
- package/dist/tmw-scribe.js +128 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
WorldEngine 官方作者工具许可证
|
|
2
|
+
|
|
3
|
+
版权所有 (c) 2026 Nixdorfer。保留所有权利。
|
|
4
|
+
|
|
5
|
+
本仓库的源代码、构建材料及附带资源(统称“本作品”)不是开源软件,
|
|
6
|
+
不适用任何 OSI 认证的开源许可证。
|
|
7
|
+
|
|
8
|
+
一、官方作者工具分发许可
|
|
9
|
+
|
|
10
|
+
版权所有者可以通过其官方网站、npm registry、签名安装包或其他官方渠道,
|
|
11
|
+
复制并分发由本作品构建的 WorldEngine 作者工具及其必要运行资源
|
|
12
|
+
(统称“官方作者工具”)。仅版权所有者或其书面指定的发布者享有此分发权。
|
|
13
|
+
|
|
14
|
+
二、作者用户许可
|
|
15
|
+
|
|
16
|
+
从官方渠道取得官方作者工具的作者用户,可以:
|
|
17
|
+
|
|
18
|
+
1. 安装和运行官方作者工具;
|
|
19
|
+
2. 使用官方作者工具创作、编辑、预览、导入、导出和提交其有权处理的内容;
|
|
20
|
+
3. 为上述使用目的制作合理必要的本地备份副本。
|
|
21
|
+
|
|
22
|
+
三、未授予的权利
|
|
23
|
+
|
|
24
|
+
除第二条明确允许的行为外,本许可证不授予作者用户或其他第三方以下权利:
|
|
25
|
+
|
|
26
|
+
1. 修改、改编、反编译、反汇编或制作官方作者工具的派生作品;
|
|
27
|
+
2. 复制、镜像、转发、再上传、出售、出租、再分发或再许可官方作者工具;
|
|
28
|
+
3. 使用本作品的源代码、构建材料或任何部分开发、提供或训练其他产品或服务;
|
|
29
|
+
4. 删除或规避版权、许可、签名、访问控制或其他权利管理信息。
|
|
30
|
+
|
|
31
|
+
法律强制允许且合同不得排除的权利不受上述限制影响。
|
|
32
|
+
|
|
33
|
+
四、源代码查看
|
|
34
|
+
|
|
35
|
+
第三方可以在已获合法访问权限的范围内查看本作品,用于审查、安全研究或学习参考;
|
|
36
|
+
查看不授予运行、复制、修改、分发、再许可或用于其他产品与服务的权利。
|
|
37
|
+
|
|
38
|
+
五、无担保与责任限制
|
|
39
|
+
|
|
40
|
+
本作品与官方作者工具均按“现状”提供,不附带任何明示或暗示的担保。
|
|
41
|
+
在适用法律允许的最大范围内,版权所有者不对因访问或使用本作品或官方作者工具
|
|
42
|
+
造成的任何损失承担责任。
|
|
43
|
+
|
|
44
|
+
六、终止
|
|
45
|
+
|
|
46
|
+
违反本许可证将立即终止相应的访问与使用权;终止不影响版权所有者已经产生的权利和救济。
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/** 浏览器和 Node 共用的作者 Agent DAG 文档。 */
|
|
2
|
+
/** 当前持久化版本。读取器仍接受 v1,并通过 upgradeDagDocument 显式规范化。 */
|
|
3
|
+
export declare const DAG_FLOW_SCHEMA_VERSION: 2;
|
|
4
|
+
export declare const DAG_FLOW_LEGACY_SCHEMA_VERSION: 1;
|
|
5
|
+
export type DagSchemaVersion = typeof DAG_FLOW_LEGACY_SCHEMA_VERSION | typeof DAG_FLOW_SCHEMA_VERSION;
|
|
6
|
+
export declare const DAG_FLOW_SOURCE_SECTION_KEY: "view.agent_dag";
|
|
7
|
+
export declare const DAG_FLOW_VIEW_PERMISSION: "view";
|
|
8
|
+
export declare const SYSTEM_USER_INPUT_NODE_ID: "user_input";
|
|
9
|
+
export declare const SYSTEM_DIRECTOR_NODE_ID: "director";
|
|
10
|
+
export declare const SYSTEM_TEXT_OUTPUT_NODE_ID: "text_output";
|
|
11
|
+
/** 作者 Agent 只能插入这三个由系统调度的阶段,不能改写系统主线。 */
|
|
12
|
+
export declare const DAG_INSERTION_SLOTS: readonly ["before_director", "after_scribe", "after_writer"];
|
|
13
|
+
export type DagInsertionSlot = typeof DAG_INSERTION_SLOTS[number];
|
|
14
|
+
/** v2 将每个可插入阶段的控制流边界作为持久化数据保存。 */
|
|
15
|
+
export interface DagStageBoundary {
|
|
16
|
+
readonly slot: DagInsertionSlot;
|
|
17
|
+
readonly start_id: string;
|
|
18
|
+
readonly handoff_id: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const DAG_STAGE_BOUNDARIES: readonly DagStageBoundary[];
|
|
21
|
+
export interface DagStageStartNode {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly kind: "stage_start";
|
|
24
|
+
readonly slot: DagInsertionSlot;
|
|
25
|
+
readonly system: true;
|
|
26
|
+
}
|
|
27
|
+
export interface DagStageHandoffNode {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly kind: "stage_handoff";
|
|
30
|
+
readonly slot: DagInsertionSlot;
|
|
31
|
+
readonly system: true;
|
|
32
|
+
}
|
|
33
|
+
export interface DagStageFlow {
|
|
34
|
+
readonly enabled: true;
|
|
35
|
+
}
|
|
36
|
+
/** 仅供界面展示的真实系统角色;它们不是可编辑 DAG 节点。 */
|
|
37
|
+
export declare const SYSTEM_AGENT_ROLE_CATALOG: readonly [{
|
|
38
|
+
readonly id: "director";
|
|
39
|
+
readonly label: "Director";
|
|
40
|
+
}, {
|
|
41
|
+
readonly id: "screenwriter";
|
|
42
|
+
readonly label: "Screenwriter";
|
|
43
|
+
}, {
|
|
44
|
+
readonly id: "scribe";
|
|
45
|
+
readonly label: "Scribe";
|
|
46
|
+
}, {
|
|
47
|
+
readonly id: "writer";
|
|
48
|
+
readonly label: "Writer";
|
|
49
|
+
}, {
|
|
50
|
+
readonly id: "scene";
|
|
51
|
+
readonly label: "Scene";
|
|
52
|
+
}, {
|
|
53
|
+
readonly id: "photographer";
|
|
54
|
+
readonly label: "Photographer";
|
|
55
|
+
}, {
|
|
56
|
+
readonly id: "voice";
|
|
57
|
+
readonly label: "Voice";
|
|
58
|
+
}];
|
|
59
|
+
export type DagSystemAgentRole = typeof SYSTEM_AGENT_ROLE_CATALOG[number]["id"];
|
|
60
|
+
/** 编剧召回是 WASM 检索工具而非冻结 LLM Agent,不能承载可执行提示词覆盖。 */
|
|
61
|
+
export declare const EDITABLE_SYSTEM_AGENT_ROLES: readonly ["director", "scribe", "writer", "scene", "photographer", "voice"];
|
|
62
|
+
export type EditableDagSystemAgentRole = typeof EDITABLE_SYSTEM_AGENT_ROLES[number];
|
|
63
|
+
/** 可在 DAG 内部传递的有限、无循环、普通 JSON 值。 */
|
|
64
|
+
export type DagJson = null | boolean | number | string | readonly DagJson[] | {
|
|
65
|
+
readonly [key: string]: DagJson;
|
|
66
|
+
};
|
|
67
|
+
export interface DagPosition {
|
|
68
|
+
readonly x: number;
|
|
69
|
+
readonly y: number;
|
|
70
|
+
}
|
|
71
|
+
export interface DagPortRef {
|
|
72
|
+
readonly node_id: string;
|
|
73
|
+
readonly port: string;
|
|
74
|
+
}
|
|
75
|
+
export interface DagEdge {
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly from: DagPortRef;
|
|
78
|
+
readonly to: DagPortRef;
|
|
79
|
+
}
|
|
80
|
+
/** 后端将三段作者内容注入 Agent 消息;执行器不改写 Agent 的返回正文。 */
|
|
81
|
+
export interface DagPromptTemplates {
|
|
82
|
+
readonly system: string;
|
|
83
|
+
readonly primer: string;
|
|
84
|
+
readonly anchor: string;
|
|
85
|
+
}
|
|
86
|
+
export interface DagPromptBlock {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly name: string;
|
|
89
|
+
readonly role: "system" | "assistant" | "user";
|
|
90
|
+
readonly content: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 系统角色的作者可编辑消息层。平台安全策略、语言策略和工具协议仍由运行时追加,
|
|
94
|
+
* 不在这个文档中删除或伪造。键缺省时保留冻结运行时的既有默认层,保证旧文档兼容。
|
|
95
|
+
*/
|
|
96
|
+
export type DagSystemAgentPrompts = Readonly<Partial<Record<DagSystemAgentRole, readonly DagPromptBlock[]>>>;
|
|
97
|
+
export declare function defaultSystemAgentPromptBlocks(role: DagSystemAgentRole): readonly DagPromptBlock[];
|
|
98
|
+
export interface DagAgentNode {
|
|
99
|
+
readonly id: string;
|
|
100
|
+
readonly name?: string;
|
|
101
|
+
readonly kind: "agent";
|
|
102
|
+
readonly config: {
|
|
103
|
+
readonly system_prompt: string;
|
|
104
|
+
readonly model_id: string;
|
|
105
|
+
readonly require_json: boolean;
|
|
106
|
+
readonly prompt_injection: "enabled" | "disabled";
|
|
107
|
+
readonly templates: DagPromptTemplates;
|
|
108
|
+
readonly prompt_blocks?: readonly DagPromptBlock[];
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export interface DagScriptNode {
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly name?: string;
|
|
114
|
+
readonly kind: "script";
|
|
115
|
+
readonly config: {
|
|
116
|
+
readonly source: string;
|
|
117
|
+
readonly entrypoint?: "main";
|
|
118
|
+
readonly paths?: readonly string[];
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export interface DagUserInputNode {
|
|
122
|
+
readonly id: typeof SYSTEM_USER_INPUT_NODE_ID;
|
|
123
|
+
readonly kind: "user_input";
|
|
124
|
+
readonly system: true;
|
|
125
|
+
}
|
|
126
|
+
export interface DagDirectorNode {
|
|
127
|
+
readonly id: typeof SYSTEM_DIRECTOR_NODE_ID;
|
|
128
|
+
readonly kind: "director";
|
|
129
|
+
readonly system: true;
|
|
130
|
+
}
|
|
131
|
+
export interface DagTextOutputNode {
|
|
132
|
+
readonly id: typeof SYSTEM_TEXT_OUTPUT_NODE_ID;
|
|
133
|
+
readonly kind: "text_output";
|
|
134
|
+
readonly system: true;
|
|
135
|
+
readonly name?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface DagAuthorTextOutputNode {
|
|
138
|
+
readonly id: string;
|
|
139
|
+
readonly name: string;
|
|
140
|
+
readonly kind: "text_output";
|
|
141
|
+
readonly system?: never;
|
|
142
|
+
}
|
|
143
|
+
export type DagNode = DagAgentNode | DagScriptNode | DagAuthorTextOutputNode | DagUserInputNode | DagDirectorNode | DagTextOutputNode | DagStageStartNode | DagStageHandoffNode;
|
|
144
|
+
export interface DagDocument {
|
|
145
|
+
readonly schema_version: DagSchemaVersion;
|
|
146
|
+
readonly section_key: typeof DAG_FLOW_SOURCE_SECTION_KEY;
|
|
147
|
+
readonly permission: typeof DAG_FLOW_VIEW_PERMISSION;
|
|
148
|
+
readonly nodes: readonly DagNode[];
|
|
149
|
+
readonly edges: readonly DagEdge[];
|
|
150
|
+
/** 各系统 Agent 的作者可编辑消息层;没有键时仍由运行时使用冻结默认提示词。 */
|
|
151
|
+
readonly system_agent_prompts?: DagSystemAgentPrompts;
|
|
152
|
+
/** 数组顺序就是该阶段的 Agent 执行顺序;槽内 Agent 不使用作者边。 */
|
|
153
|
+
readonly insertion_slots?: Readonly<Partial<Record<DagInsertionSlot, readonly string[]>>>;
|
|
154
|
+
readonly positions?: Readonly<Record<string, DagPosition>>;
|
|
155
|
+
/** v2 阶段边界;边界本身是控制流算子,不携带业务数据。 */
|
|
156
|
+
readonly stage_boundaries?: readonly DagStageBoundary[];
|
|
157
|
+
/** 文本出口是否立即结束本轮;缺省保持 v1 多出口兼容,v2 编辑器显式写 true。 */
|
|
158
|
+
readonly execution?: Readonly<{
|
|
159
|
+
readonly terminal_on_text_output?: boolean;
|
|
160
|
+
}>;
|
|
161
|
+
/** 存在时由真实三阶段 start/handoff 图执行,不再使用 insertion_slots 投影。 */
|
|
162
|
+
readonly stage_flow?: DagStageFlow;
|
|
163
|
+
}
|
|
164
|
+
export type DagValidationMode = "draft" | "run" | "publish";
|
|
165
|
+
export interface DagValidationIssue {
|
|
166
|
+
readonly code: string;
|
|
167
|
+
readonly message: string;
|
|
168
|
+
readonly node_id?: string;
|
|
169
|
+
readonly edge_id?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface DagValidationResult {
|
|
172
|
+
readonly ok: boolean;
|
|
173
|
+
readonly issues: readonly DagValidationIssue[];
|
|
174
|
+
}
|
|
175
|
+
export declare function createEmptyDagDocument(): DagDocument;
|
|
176
|
+
/** 创建可序列化、可执行的三阶段控制流图。默认 start → handoff 可由作者删除后重新接线。 */
|
|
177
|
+
export declare function createStageDagDocument(): DagDocument;
|
|
178
|
+
export interface DagUpgradeResult {
|
|
179
|
+
readonly document: DagDocument;
|
|
180
|
+
readonly migrated: boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 将 v1 文档升级为 v2。升级只补齐明确的阶段边界,不猜测节点之间的作者连线;
|
|
184
|
+
* 形状不明确或版本过新时拒绝,避免把旧数据静默解释成另一条执行路径。
|
|
185
|
+
*/
|
|
186
|
+
export declare function upgradeDagDocument(value: unknown): DagUpgradeResult;
|
|
187
|
+
/** 对不可信 JSON 文档只返回问题清单,永不因形状错误抛出。 */
|
|
188
|
+
export declare function validateDagDocument(document: unknown, options?: {
|
|
189
|
+
readonly mode?: DagValidationMode;
|
|
190
|
+
}): DagValidationResult;
|
|
191
|
+
/** 判断值能否完整且无损地作为 DAG 内部的 JSON 值传递。 */
|
|
192
|
+
export declare function isDagJson(value: unknown): value is DagJson;
|
|
193
|
+
export declare function dagMixedToString(value: DagJson): string;
|