persona-core 1.0.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/db/client.d.ts +55 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +157 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +7 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/repositories/executionRepository.d.ts +15 -0
- package/dist/db/repositories/executionRepository.d.ts.map +1 -0
- package/dist/db/repositories/executionRepository.js +41 -0
- package/dist/db/repositories/executionRepository.js.map +1 -0
- package/dist/db/repositories/index.d.ts +10 -0
- package/dist/db/repositories/index.d.ts.map +1 -0
- package/dist/db/repositories/index.js +10 -0
- package/dist/db/repositories/index.js.map +1 -0
- package/dist/db/repositories/nodeRepository.d.ts +15 -0
- package/dist/db/repositories/nodeRepository.d.ts.map +1 -0
- package/dist/db/repositories/nodeRepository.js +61 -0
- package/dist/db/repositories/nodeRepository.js.map +1 -0
- package/dist/db/repositories/personaRepository.d.ts +13 -0
- package/dist/db/repositories/personaRepository.d.ts.map +1 -0
- package/dist/db/repositories/personaRepository.js +42 -0
- package/dist/db/repositories/personaRepository.js.map +1 -0
- package/dist/db/repositories/planResultRepository.d.ts +13 -0
- package/dist/db/repositories/planResultRepository.d.ts.map +1 -0
- package/dist/db/repositories/planResultRepository.js +30 -0
- package/dist/db/repositories/planResultRepository.js.map +1 -0
- package/dist/db/repositories/scheduleRepository.d.ts +27 -0
- package/dist/db/repositories/scheduleRepository.d.ts.map +1 -0
- package/dist/db/repositories/scheduleRepository.js +187 -0
- package/dist/db/repositories/scheduleRepository.js.map +1 -0
- package/dist/db/repositories/types.d.ts +132 -0
- package/dist/db/repositories/types.d.ts.map +1 -0
- package/dist/db/repositories/types.js +5 -0
- package/dist/db/repositories/types.js.map +1 -0
- package/dist/db/schema.d.ts +742 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +85 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/capabilities.d.ts +56 -0
- package/dist/llm/capabilities.d.ts.map +1 -0
- package/dist/llm/capabilities.js +305 -0
- package/dist/llm/capabilities.js.map +1 -0
- package/dist/llm/index.d.ts +7 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +10 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/interfaces.d.ts +249 -0
- package/dist/llm/interfaces.d.ts.map +1 -0
- package/dist/llm/interfaces.js +5 -0
- package/dist/llm/interfaces.js.map +1 -0
- package/dist/llm/providers/anthropic-compatible.d.ts +48 -0
- package/dist/llm/providers/anthropic-compatible.d.ts.map +1 -0
- package/dist/llm/providers/anthropic-compatible.js +163 -0
- package/dist/llm/providers/anthropic-compatible.js.map +1 -0
- package/dist/llm/providers/index.d.ts +14 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +12 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/openai-compatible.d.ts +59 -0
- package/dist/llm/providers/openai-compatible.d.ts.map +1 -0
- package/dist/llm/providers/openai-compatible.js +207 -0
- package/dist/llm/providers/openai-compatible.js.map +1 -0
- package/dist/services/actionService.d.ts +132 -0
- package/dist/services/actionService.d.ts.map +1 -0
- package/dist/services/actionService.js +971 -0
- package/dist/services/actionService.js.map +1 -0
- package/dist/services/branchService.d.ts +19 -0
- package/dist/services/branchService.d.ts.map +1 -0
- package/dist/services/branchService.js +50 -0
- package/dist/services/branchService.js.map +1 -0
- package/dist/services/expressionEvaluator.d.ts +16 -0
- package/dist/services/expressionEvaluator.d.ts.map +1 -0
- package/dist/services/expressionEvaluator.js +70 -0
- package/dist/services/expressionEvaluator.js.map +1 -0
- package/dist/services/factory.d.ts +43 -0
- package/dist/services/factory.d.ts.map +1 -0
- package/dist/services/factory.js +30 -0
- package/dist/services/factory.js.map +1 -0
- package/dist/services/index.d.ts +15 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +17 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/interfaces.d.ts +117 -0
- package/dist/services/interfaces.d.ts.map +1 -0
- package/dist/services/interfaces.js +5 -0
- package/dist/services/interfaces.js.map +1 -0
- package/dist/services/loaders/fileLoader.d.ts +56 -0
- package/dist/services/loaders/fileLoader.d.ts.map +1 -0
- package/dist/services/loaders/fileLoader.js +161 -0
- package/dist/services/loaders/fileLoader.js.map +1 -0
- package/dist/services/loaders/index.d.ts +6 -0
- package/dist/services/loaders/index.d.ts.map +1 -0
- package/dist/services/loaders/index.js +6 -0
- package/dist/services/loaders/index.js.map +1 -0
- package/dist/services/loaders/transformers.d.ts +32 -0
- package/dist/services/loaders/transformers.d.ts.map +1 -0
- package/dist/services/loaders/transformers.js +78 -0
- package/dist/services/loaders/transformers.js.map +1 -0
- package/dist/services/mockAction.d.ts +65 -0
- package/dist/services/mockAction.d.ts.map +1 -0
- package/dist/services/mockAction.js +153 -0
- package/dist/services/mockAction.js.map +1 -0
- package/dist/services/mockBranch.d.ts +50 -0
- package/dist/services/mockBranch.d.ts.map +1 -0
- package/dist/services/mockBranch.js +75 -0
- package/dist/services/mockBranch.js.map +1 -0
- package/dist/services/mockThinking.d.ts +68 -0
- package/dist/services/mockThinking.d.ts.map +1 -0
- package/dist/services/mockThinking.js +89 -0
- package/dist/services/mockThinking.js.map +1 -0
- package/dist/services/thinkingService.d.ts +15 -0
- package/dist/services/thinkingService.d.ts.map +1 -0
- package/dist/services/thinkingService.js +117 -0
- package/dist/services/thinkingService.js.map +1 -0
- package/dist/temporal/activities/actionActivities.d.ts +15 -0
- package/dist/temporal/activities/actionActivities.d.ts.map +1 -0
- package/dist/temporal/activities/actionActivities.js +140 -0
- package/dist/temporal/activities/actionActivities.js.map +1 -0
- package/dist/temporal/activities/branchActivities.d.ts +13 -0
- package/dist/temporal/activities/branchActivities.d.ts.map +1 -0
- package/dist/temporal/activities/branchActivities.js +26 -0
- package/dist/temporal/activities/branchActivities.js.map +1 -0
- package/dist/temporal/activities/dbActivities.d.ts +14 -0
- package/dist/temporal/activities/dbActivities.d.ts.map +1 -0
- package/dist/temporal/activities/dbActivities.js +84 -0
- package/dist/temporal/activities/dbActivities.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +9 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +9 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/thinkingActivities.d.ts +17 -0
- package/dist/temporal/activities/thinkingActivities.d.ts.map +1 -0
- package/dist/temporal/activities/thinkingActivities.js +145 -0
- package/dist/temporal/activities/thinkingActivities.js.map +1 -0
- package/dist/temporal/activities/types.d.ts +100 -0
- package/dist/temporal/activities/types.d.ts.map +1 -0
- package/dist/temporal/activities/types.js +5 -0
- package/dist/temporal/activities/types.js.map +1 -0
- package/dist/temporal/client.d.ts +43 -0
- package/dist/temporal/client.d.ts.map +1 -0
- package/dist/temporal/client.js +75 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/index.d.ts +10 -0
- package/dist/temporal/index.d.ts.map +1 -0
- package/dist/temporal/index.js +12 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/personaCoreClient.d.ts +199 -0
- package/dist/temporal/personaCoreClient.d.ts.map +1 -0
- package/dist/temporal/personaCoreClient.js +233 -0
- package/dist/temporal/personaCoreClient.js.map +1 -0
- package/dist/temporal/personaWorker.d.ts +141 -0
- package/dist/temporal/personaWorker.d.ts.map +1 -0
- package/dist/temporal/personaWorker.js +93 -0
- package/dist/temporal/personaWorker.js.map +1 -0
- package/dist/temporal/worker.d.ts +66 -0
- package/dist/temporal/worker.d.ts.map +1 -0
- package/dist/temporal/worker.js +109 -0
- package/dist/temporal/worker.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +5 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +5 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/scheduleWorkflow.d.ts +31 -0
- package/dist/temporal/workflows/scheduleWorkflow.d.ts.map +1 -0
- package/dist/temporal/workflows/scheduleWorkflow.js +256 -0
- package/dist/temporal/workflows/scheduleWorkflow.js.map +1 -0
- package/dist/types/common.d.ts +81 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +5 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/nodes.d.ts +496 -0
- package/dist/types/nodes.d.ts.map +1 -0
- package/dist/types/nodes.js +5 -0
- package/dist/types/nodes.js.map +1 -0
- package/dist/types/persona.d.ts +59 -0
- package/dist/types/persona.d.ts.map +1 -0
- package/dist/types/persona.js +36 -0
- package/dist/types/persona.js.map +1 -0
- package/dist/types/schedule.d.ts +143 -0
- package/dist/types/schedule.d.ts.map +1 -0
- package/dist/types/schedule.js +155 -0
- package/dist/types/schedule.js.map +1 -0
- package/dist/utils/dateUtils.d.ts +31 -0
- package/dist/utils/dateUtils.d.ts.map +1 -0
- package/dist/utils/dateUtils.js +53 -0
- package/dist/utils/dateUtils.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/inputResolver.d.ts +43 -0
- package/dist/utils/inputResolver.d.ts.map +1 -0
- package/dist/utils/inputResolver.js +137 -0
- package/dist/utils/inputResolver.js.map +1 -0
- package/dist/utils/sharedDataUtils.d.ts +36 -0
- package/dist/utils/sharedDataUtils.d.ts.map +1 -0
- package/dist/utils/sharedDataUtils.js +84 -0
- package/dist/utils/sharedDataUtils.js.map +1 -0
- package/dist/utils/typeGuards.d.ts +33 -0
- package/dist/utils/typeGuards.d.ts.map +1 -0
- package/dist/utils/typeGuards.js +50 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/docs/add-llm-provider.md +353 -0
- package/docs/external/deepseek-v32.md +28 -0
- package/docs/quick-start.md +849 -0
- package/docs/suite-guide.md +148 -0
- package/docs/usage-guide.md +1487 -0
- package/package.json +80 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 节点类型定义
|
|
3
|
+
*/
|
|
4
|
+
import { ActionTypeId, NodeId, SharedDataDeclaration, NodeInputValue, OutputMapping } from './common.js';
|
|
5
|
+
/**
|
|
6
|
+
* 动作执行类型枚举
|
|
7
|
+
* 系统内置,不可动态扩展
|
|
8
|
+
*/
|
|
9
|
+
export type ActionExecutionType = 'api_call' | 'file_write' | 'file_read' | 'database_query' | 'llm_call' | 'http_request' | 'shell_command';
|
|
10
|
+
/**
|
|
11
|
+
* 输入/输出字段定义
|
|
12
|
+
*/
|
|
13
|
+
export interface FieldDefinition {
|
|
14
|
+
name: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* TypeScript 类型格式的类型描述
|
|
19
|
+
*
|
|
20
|
+
* 使用标准 TypeScript 类型语法:
|
|
21
|
+
* - 基础类型: "string", "number", "boolean"
|
|
22
|
+
* - 数组类型: "Array<T>" 或 "T[]"
|
|
23
|
+
* - 对象类型: "{ field1: Type1, field2: Type2 }"
|
|
24
|
+
* - 复合类型: "Array<{ title: string, url: string }>"
|
|
25
|
+
* - 可选字段: "{ required: string, optional?: number }"
|
|
26
|
+
*
|
|
27
|
+
* 示例:
|
|
28
|
+
* - "string"
|
|
29
|
+
* - "number"
|
|
30
|
+
* - "boolean"
|
|
31
|
+
* - "Array<{ title: string, link: string, snippet: string }>"
|
|
32
|
+
* - "{ name: string, count: number, items?: string[] }"
|
|
33
|
+
*
|
|
34
|
+
* 默认值: "string"
|
|
35
|
+
*/
|
|
36
|
+
typeHint?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 异步模式定义
|
|
40
|
+
*/
|
|
41
|
+
export interface AsyncModeConfig {
|
|
42
|
+
/** 是否为异步任务(需要轮询或等待回调) */
|
|
43
|
+
isAsync: boolean;
|
|
44
|
+
/** 默认轮询间隔(毫秒),如果是轮询模式 */
|
|
45
|
+
defaultCheckIntervalMs?: number;
|
|
46
|
+
/** 默认超时时间(毫秒) */
|
|
47
|
+
defaultTimeoutMs?: number;
|
|
48
|
+
/**
|
|
49
|
+
* 从提交任务响应中提取 taskId 的 JSONPath
|
|
50
|
+
* 支持点号分隔路径,如: "data.taskId" 或 "id"
|
|
51
|
+
* 默认为 "taskId"
|
|
52
|
+
*/
|
|
53
|
+
taskIdPath?: string;
|
|
54
|
+
/**
|
|
55
|
+
* 任务状态检查配置
|
|
56
|
+
*/
|
|
57
|
+
statusCheck?: AsyncStatusCheckConfig;
|
|
58
|
+
/**
|
|
59
|
+
* 任务结果获取配置
|
|
60
|
+
* 如果不配置,结果从最后一次成功的状态检查响应中提取
|
|
61
|
+
*/
|
|
62
|
+
resultFetch?: AsyncResultFetchConfig;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 异步任务状态检查配置
|
|
66
|
+
*/
|
|
67
|
+
export interface AsyncStatusCheckConfig {
|
|
68
|
+
/**
|
|
69
|
+
* 状态检查的 URL 模板
|
|
70
|
+
* 支持变量替换:
|
|
71
|
+
* - ${taskId}: 任务 ID
|
|
72
|
+
* - ${inputFieldName}: 从提交时的输入中获取值
|
|
73
|
+
*
|
|
74
|
+
* 例如: "https://api.example.com/tasks/${taskId}/status"
|
|
75
|
+
* 例如: "https://api.example.com/v1/generations/${taskId}"
|
|
76
|
+
*/
|
|
77
|
+
url: string;
|
|
78
|
+
/**
|
|
79
|
+
* HTTP 方法,默认 GET
|
|
80
|
+
*/
|
|
81
|
+
method?: 'GET' | 'POST';
|
|
82
|
+
/**
|
|
83
|
+
* 额外的请求头(会与 apiConfig.headers 合并)
|
|
84
|
+
*/
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
/**
|
|
87
|
+
* 状态字段提取配置
|
|
88
|
+
*/
|
|
89
|
+
extract: AsyncStatusExtractConfig;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 状态提取配置
|
|
93
|
+
*/
|
|
94
|
+
export interface AsyncStatusExtractConfig {
|
|
95
|
+
/**
|
|
96
|
+
* 状态值的 JSONPath
|
|
97
|
+
* 默认为 "status"
|
|
98
|
+
*/
|
|
99
|
+
statusPath?: string;
|
|
100
|
+
/**
|
|
101
|
+
* 表示任务完成的状态值
|
|
102
|
+
* 可以是单个值或多个可能的值
|
|
103
|
+
* 默认为 "completed"
|
|
104
|
+
*/
|
|
105
|
+
completedValues?: string | string[];
|
|
106
|
+
/**
|
|
107
|
+
* 表示任务失败的状态值
|
|
108
|
+
* 可以是单个值或多个可能的值
|
|
109
|
+
* 默认为 "failed"
|
|
110
|
+
*/
|
|
111
|
+
failedValues?: string | string[];
|
|
112
|
+
/**
|
|
113
|
+
* 表示任务进行中的状态值(可选)
|
|
114
|
+
* 用于日志和调试
|
|
115
|
+
*/
|
|
116
|
+
pendingValues?: string | string[];
|
|
117
|
+
/**
|
|
118
|
+
* 错误信息的 JSONPath
|
|
119
|
+
* 默认为 "error"
|
|
120
|
+
*/
|
|
121
|
+
errorPath?: string;
|
|
122
|
+
/**
|
|
123
|
+
* 进度百分比的 JSONPath(可选)
|
|
124
|
+
* 用于报告进度
|
|
125
|
+
*/
|
|
126
|
+
progressPath?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 异步任务结果获取配置
|
|
130
|
+
*/
|
|
131
|
+
export interface AsyncResultFetchConfig {
|
|
132
|
+
/**
|
|
133
|
+
* 结果获取的 URL 模板
|
|
134
|
+
* 支持 ${taskId} 和 ${inputFieldName} 变量
|
|
135
|
+
*
|
|
136
|
+
* 如果不配置,使用状态检查的最后响应作为结果
|
|
137
|
+
*/
|
|
138
|
+
url?: string;
|
|
139
|
+
/**
|
|
140
|
+
* HTTP 方法,默认 GET
|
|
141
|
+
*/
|
|
142
|
+
method?: 'GET' | 'POST';
|
|
143
|
+
/**
|
|
144
|
+
* 额外的请求头
|
|
145
|
+
*/
|
|
146
|
+
headers?: Record<string, string>;
|
|
147
|
+
/**
|
|
148
|
+
* 结果字段提取映射
|
|
149
|
+
* key: 输出字段名(对应 outputFields 中定义的字段)
|
|
150
|
+
* value: JSONPath 表达式
|
|
151
|
+
*
|
|
152
|
+
* 例如: { "videoUrl": "data.video.url", "duration": "data.video.duration" }
|
|
153
|
+
*
|
|
154
|
+
* 如果不配置,使用整个响应体作为 outputs
|
|
155
|
+
*/
|
|
156
|
+
extract?: Record<string, string>;
|
|
157
|
+
/**
|
|
158
|
+
* 从状态检查响应中提取结果的配置
|
|
159
|
+
* 当 url 未配置时使用
|
|
160
|
+
* 表示直接从状态检查的响应中提取最终结果
|
|
161
|
+
*/
|
|
162
|
+
extractFromStatus?: Record<string, string>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* HTTP 方法类型
|
|
166
|
+
*/
|
|
167
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
168
|
+
/**
|
|
169
|
+
* API 调用配置
|
|
170
|
+
* 用于 api_call 类型的动作,定义 HTTP 请求的详细配置
|
|
171
|
+
*/
|
|
172
|
+
export interface ApiCallConfig {
|
|
173
|
+
/**
|
|
174
|
+
* API 端点 URL
|
|
175
|
+
* 支持模板变量,如: "https://api.example.com/users/${userId}"
|
|
176
|
+
* 模板变量从 inputFields 中解析
|
|
177
|
+
*/
|
|
178
|
+
url: string;
|
|
179
|
+
/** HTTP 方法,默认为 GET */
|
|
180
|
+
method?: HttpMethod;
|
|
181
|
+
/**
|
|
182
|
+
* 请求头配置
|
|
183
|
+
* 定义如何构建 HTTP 请求头
|
|
184
|
+
*/
|
|
185
|
+
headers?: {
|
|
186
|
+
/**
|
|
187
|
+
* 内容类型
|
|
188
|
+
* static: 使用固定的键值对
|
|
189
|
+
* template: 使用 Nunjucks 模板
|
|
190
|
+
*/
|
|
191
|
+
type: 'static' | 'template';
|
|
192
|
+
/**
|
|
193
|
+
* 静态请求头值
|
|
194
|
+
* 当 type 为 'static' 时使用
|
|
195
|
+
*/
|
|
196
|
+
values?: Record<string, string>;
|
|
197
|
+
/**
|
|
198
|
+
* 请求头模板(使用 Nunjucks 模板引擎)
|
|
199
|
+
* 当 type 为 'template' 时使用
|
|
200
|
+
* 模板应返回一个 JSON 对象,键值对将作为 HTTP 请求头
|
|
201
|
+
*
|
|
202
|
+
* 例如:
|
|
203
|
+
* ```
|
|
204
|
+
* {
|
|
205
|
+
* "Authorization": "Bearer {{ apiKey }}",
|
|
206
|
+
* "X-Custom-Header": "{{ customValue }}"
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
template?: string;
|
|
211
|
+
/**
|
|
212
|
+
* 基础请求头
|
|
213
|
+
* 无论 type 是什么,这些 headers 总是会被添加
|
|
214
|
+
* 优先级最低(会被 values 或 template 结果覆盖)
|
|
215
|
+
*/
|
|
216
|
+
base?: Record<string, string>;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* 静态 Cookies
|
|
220
|
+
* 可以在 Persona 定义时设置固定的 cookies
|
|
221
|
+
*/
|
|
222
|
+
cookies?: Record<string, string>;
|
|
223
|
+
/**
|
|
224
|
+
* 请求体配置
|
|
225
|
+
* 定义如何从 inputFields 构建请求体
|
|
226
|
+
*/
|
|
227
|
+
body?: {
|
|
228
|
+
/**
|
|
229
|
+
* 内容类型
|
|
230
|
+
* json: 将 inputFields 序列化为 JSON
|
|
231
|
+
* form: 将 inputFields 序列化为 form-urlencoded
|
|
232
|
+
* raw: 使用指定字段的原始值
|
|
233
|
+
* template: 使用 JSON 模板,支持 ${fieldName} 变量替换
|
|
234
|
+
*/
|
|
235
|
+
contentType: 'json' | 'form' | 'raw' | 'template';
|
|
236
|
+
/**
|
|
237
|
+
* 如果 contentType 为 raw,指定使用哪个输入字段作为请求体
|
|
238
|
+
*/
|
|
239
|
+
rawField?: string;
|
|
240
|
+
/**
|
|
241
|
+
* 如果 contentType 为 template,定义 JSON 模板字符串
|
|
242
|
+
* 支持 ${fieldName} 格式的变量替换
|
|
243
|
+
* 例如: '{"model": "gpt-4", "prompt": "${userPrompt}"}'
|
|
244
|
+
* 变量值将被 JSON 安全转义
|
|
245
|
+
*/
|
|
246
|
+
template?: string;
|
|
247
|
+
/**
|
|
248
|
+
* 要包含在请求体中的输入字段名列表
|
|
249
|
+
* 如果不指定,将使用所有 inputFields
|
|
250
|
+
*/
|
|
251
|
+
includeFields?: string[];
|
|
252
|
+
/**
|
|
253
|
+
* 要从请求体中排除的输入字段名列表
|
|
254
|
+
*/
|
|
255
|
+
excludeFields?: string[];
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* 响应配置
|
|
259
|
+
*/
|
|
260
|
+
response?: {
|
|
261
|
+
/**
|
|
262
|
+
* 期望的响应类型
|
|
263
|
+
* json: 解析为 JSON 对象
|
|
264
|
+
* text: 返回原始文本
|
|
265
|
+
* binary: 返回二进制数据
|
|
266
|
+
*/
|
|
267
|
+
type?: 'json' | 'text' | 'binary';
|
|
268
|
+
/**
|
|
269
|
+
* 从响应中提取特定字段的映射
|
|
270
|
+
* 例如: { "items": "data.results", "total": "meta.total" }
|
|
271
|
+
* 使用 JSONPath 风格的表达式
|
|
272
|
+
*/
|
|
273
|
+
extract?: Record<string, string>;
|
|
274
|
+
/**
|
|
275
|
+
* 大数据保存到文件配置
|
|
276
|
+
* 用于处理图片、视频等大型响应数据,避免超出 Temporal payload 限制
|
|
277
|
+
*/
|
|
278
|
+
saveToFile?: {
|
|
279
|
+
/** 是否启用保存到文件 */
|
|
280
|
+
enabled: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* 从哪个输入字段获取保存路径
|
|
283
|
+
* 例如: "outputPath" 表示从 inputs.outputPath 获取文件路径
|
|
284
|
+
*/
|
|
285
|
+
pathField: string;
|
|
286
|
+
/**
|
|
287
|
+
* 从响应中提取要保存数据的路径(JSONPath 风格)
|
|
288
|
+
* 例如: "choices[0].message.images[0].image_url"
|
|
289
|
+
* 如果不指定,则保存整个响应
|
|
290
|
+
*/
|
|
291
|
+
dataPath?: string;
|
|
292
|
+
/**
|
|
293
|
+
* 输出字段名,用于返回保存后的文件路径
|
|
294
|
+
* 默认为 "filePath"
|
|
295
|
+
*/
|
|
296
|
+
outputField?: string;
|
|
297
|
+
/**
|
|
298
|
+
* 数据格式,用于确定如何处理数据
|
|
299
|
+
* base64: base64 编码的数据(可能带有 data URI 前缀)
|
|
300
|
+
* binary: 二进制数据
|
|
301
|
+
* text: 文本数据
|
|
302
|
+
* json: JSON 数据(将格式化保存)
|
|
303
|
+
* 默认根据数据内容自动检测
|
|
304
|
+
*/
|
|
305
|
+
dataFormat?: 'base64' | 'binary' | 'text' | 'json' | 'auto';
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* 超时时间(毫秒),默认 30000
|
|
310
|
+
*/
|
|
311
|
+
timeoutMs?: number;
|
|
312
|
+
/**
|
|
313
|
+
* 是否跟随重定向,默认 true
|
|
314
|
+
*/
|
|
315
|
+
followRedirects?: boolean;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 动作节点类型
|
|
319
|
+
* 由 Persona 提供,定义可执行的具体动作
|
|
320
|
+
*/
|
|
321
|
+
export interface ActionNodeType {
|
|
322
|
+
kind: 'action';
|
|
323
|
+
/** 动作类型唯一标识 */
|
|
324
|
+
id: ActionTypeId;
|
|
325
|
+
/** 语义名称,如 "搜索"、"回复帖子" */
|
|
326
|
+
name: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
/** 执行类型 */
|
|
329
|
+
executionType: ActionExecutionType;
|
|
330
|
+
/**
|
|
331
|
+
* API 调用配置
|
|
332
|
+
* 仅当 executionType 为 'api_call' 时有效
|
|
333
|
+
*/
|
|
334
|
+
apiConfig?: ApiCallConfig;
|
|
335
|
+
/** 异步模式配置 */
|
|
336
|
+
asyncMode?: AsyncModeConfig;
|
|
337
|
+
/** 输入字段定义 */
|
|
338
|
+
inputFields: FieldDefinition[];
|
|
339
|
+
/** 输出字段定义 */
|
|
340
|
+
outputFields: FieldDefinition[];
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* 思考节点类型
|
|
344
|
+
* 系统内置类型,不可自定义
|
|
345
|
+
*/
|
|
346
|
+
export interface ThinkingNodeType {
|
|
347
|
+
kind: 'thinking';
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* 分支决策类型
|
|
351
|
+
*/
|
|
352
|
+
export type BranchDecisionType = 'llm' | 'expression' | 'function';
|
|
353
|
+
/**
|
|
354
|
+
* 分支节点类型
|
|
355
|
+
* 系统内置类型,不可自定义
|
|
356
|
+
*/
|
|
357
|
+
export interface BranchNodeType {
|
|
358
|
+
kind: 'branch';
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 所有节点类型的联合类型
|
|
362
|
+
*/
|
|
363
|
+
export type NodeType = ThinkingNodeType | ActionNodeType | BranchNodeType;
|
|
364
|
+
/**
|
|
365
|
+
* 节点实例基础接口
|
|
366
|
+
*/
|
|
367
|
+
interface NodeInstanceBase {
|
|
368
|
+
/** 节点实例唯一标识 */
|
|
369
|
+
id: NodeId;
|
|
370
|
+
/** 下一个节点的 ID,null 表示结束 */
|
|
371
|
+
nextNodeId: NodeId | null;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 思考节点实例
|
|
375
|
+
*/
|
|
376
|
+
export interface ThinkingNodeInstance extends NodeInstanceBase {
|
|
377
|
+
kind: 'thinking';
|
|
378
|
+
/** 思考的具体需求/提示 */
|
|
379
|
+
thinkingPrompt: string;
|
|
380
|
+
/**
|
|
381
|
+
* 共享数据声明
|
|
382
|
+
* 思考节点可以声明新的共享数据字段
|
|
383
|
+
*/
|
|
384
|
+
sharedDataDeclaration?: SharedDataDeclaration;
|
|
385
|
+
/**
|
|
386
|
+
* 输入值映射:字段名 -> 输入值(固定值或引用)
|
|
387
|
+
* 允许思考节点读取 Shared Data 进行决策
|
|
388
|
+
*/
|
|
389
|
+
inputs: Record<string, NodeInputValue>;
|
|
390
|
+
/**
|
|
391
|
+
* 输出映射配置
|
|
392
|
+
* 允许思考节点将分析结果写入 Shared Data
|
|
393
|
+
*/
|
|
394
|
+
outputMappings?: OutputMapping[];
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* 动作节点实例
|
|
398
|
+
*/
|
|
399
|
+
export interface ActionNodeInstance extends NodeInstanceBase {
|
|
400
|
+
kind: 'action';
|
|
401
|
+
/** 引用的动作类型 ID */
|
|
402
|
+
actionTypeId: ActionTypeId;
|
|
403
|
+
/** 输入值映射:字段名 -> 输入值(固定值或引用) */
|
|
404
|
+
inputs: Record<string, NodeInputValue>;
|
|
405
|
+
/** 输出映射配置 */
|
|
406
|
+
outputMappings: OutputMapping[];
|
|
407
|
+
/** 重试配置 */
|
|
408
|
+
retryConfig?: RetryConfig;
|
|
409
|
+
/** 异步执行配置(覆盖类型定义中的默认值) */
|
|
410
|
+
asyncConfig?: {
|
|
411
|
+
timeoutMs?: number;
|
|
412
|
+
checkIntervalMs?: number;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* 重试配置
|
|
417
|
+
*/
|
|
418
|
+
export interface RetryConfig {
|
|
419
|
+
/** 最大重试次数 */
|
|
420
|
+
maxRetries: number;
|
|
421
|
+
/** 重试间隔(毫秒) */
|
|
422
|
+
retryIntervalMs: number;
|
|
423
|
+
/** 是否使用指数退避 */
|
|
424
|
+
exponentialBackoff?: boolean;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* 分支条件
|
|
428
|
+
*/
|
|
429
|
+
export interface BranchCondition {
|
|
430
|
+
/** 分支标识 */
|
|
431
|
+
branchId: string;
|
|
432
|
+
/** 分支名称 */
|
|
433
|
+
name: string;
|
|
434
|
+
/** 目标节点 ID */
|
|
435
|
+
targetNodeId: NodeId;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* LLM 决策配置
|
|
439
|
+
*/
|
|
440
|
+
export interface LLMDecisionConfig {
|
|
441
|
+
type: 'llm';
|
|
442
|
+
/**
|
|
443
|
+
* 决策提示
|
|
444
|
+
* LLM 将根据 inputs 中的数据和此提示进行决策
|
|
445
|
+
*/
|
|
446
|
+
prompt: string;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* 表达式决策配置
|
|
450
|
+
*/
|
|
451
|
+
export interface ExpressionDecisionConfig {
|
|
452
|
+
type: 'expression';
|
|
453
|
+
/**
|
|
454
|
+
* 条件表达式映射:branchId -> 表达式
|
|
455
|
+
* 表达式可以引用 inputs 中的字段,如: "input.counter >= 10"
|
|
456
|
+
*/
|
|
457
|
+
conditions: Record<string, string>;
|
|
458
|
+
/** 默认分支 ID,当所有条件都不满足时使用 */
|
|
459
|
+
defaultBranchId: string;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* 函数决策配置
|
|
463
|
+
*/
|
|
464
|
+
export interface FunctionDecisionConfig {
|
|
465
|
+
type: 'function';
|
|
466
|
+
/**
|
|
467
|
+
* 函数名称,需要在运行时注册
|
|
468
|
+
* 函数将接收 inputs 作为参数
|
|
469
|
+
*/
|
|
470
|
+
functionName: string;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* 决策配置联合类型
|
|
474
|
+
*/
|
|
475
|
+
export type DecisionConfig = LLMDecisionConfig | ExpressionDecisionConfig | FunctionDecisionConfig;
|
|
476
|
+
/**
|
|
477
|
+
* 分支节点实例
|
|
478
|
+
*/
|
|
479
|
+
export interface BranchNodeInstance extends NodeInstanceBase {
|
|
480
|
+
kind: 'branch';
|
|
481
|
+
/** 分支条件列表 */
|
|
482
|
+
branches: BranchCondition[];
|
|
483
|
+
/**
|
|
484
|
+
* 输入值映射
|
|
485
|
+
* 为决策逻辑提供数据上下文
|
|
486
|
+
*/
|
|
487
|
+
inputs: Record<string, NodeInputValue>;
|
|
488
|
+
/** 决策配置 */
|
|
489
|
+
decisionConfig: DecisionConfig;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* 所有节点实例的联合类型
|
|
493
|
+
*/
|
|
494
|
+
export type NodeInstance = ThinkingNodeInstance | ActionNodeInstance | BranchNodeInstance;
|
|
495
|
+
export {};
|
|
496
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/types/nodes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,YAAY,EACZ,MAAM,EACN,qBAAqB,EACrB,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAOrB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC3B,UAAU,GACV,YAAY,GACZ,WAAW,GACX,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yBAAyB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;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AAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,2BAA2B;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,wBAAwB,GACxB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,IAAI,EAAE,QAAQ,CAAC;IACf,aAAa;IACb,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,WAAW;IACX,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../src/types/nodes.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persona 数据结构定义
|
|
3
|
+
* Persona 代表一个人格/角色,为 Schedule 提供上下文和能力
|
|
4
|
+
*/
|
|
5
|
+
import { PersonaId } from './common.js';
|
|
6
|
+
import { ActionNodeType } from './nodes.js';
|
|
7
|
+
/**
|
|
8
|
+
* Persona 定义
|
|
9
|
+
*
|
|
10
|
+
* 功能:
|
|
11
|
+
* 1. 提供 System Prompt,定义角色的行为风格
|
|
12
|
+
* 2. 提供可用的动作节点类型,定义角色可以执行的动作
|
|
13
|
+
*/
|
|
14
|
+
export interface Persona {
|
|
15
|
+
/** Persona 唯一标识 */
|
|
16
|
+
id: PersonaId;
|
|
17
|
+
/** Persona 名称 */
|
|
18
|
+
name: string;
|
|
19
|
+
/** 描述 */
|
|
20
|
+
description?: string;
|
|
21
|
+
/**
|
|
22
|
+
* System Prompt
|
|
23
|
+
* 定义角色的基本行为和风格
|
|
24
|
+
* 例如:"你是一个社交网络内容创作者,非常幽默"
|
|
25
|
+
*/
|
|
26
|
+
systemPrompt: string;
|
|
27
|
+
/**
|
|
28
|
+
* 可用的动作节点类型列表
|
|
29
|
+
* 这些动作类型可以在 Schedule 中被使用
|
|
30
|
+
* 注意:思考节点和分支节点是系统内置的,不在这里定义
|
|
31
|
+
*/
|
|
32
|
+
actionTypes: ActionNodeType[];
|
|
33
|
+
/** 创建时间 */
|
|
34
|
+
createdAt: Date;
|
|
35
|
+
/** 更新时间 */
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 创建 Persona 的输入参数
|
|
40
|
+
*/
|
|
41
|
+
export interface CreatePersonaInput {
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
systemPrompt: string;
|
|
45
|
+
actionTypes: ActionNodeType[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 根据动作类型 ID 查找动作类型
|
|
49
|
+
*/
|
|
50
|
+
export declare function findActionType(persona: Persona, actionTypeId: string): ActionNodeType | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* 验证 Persona 的动作类型是否有效
|
|
53
|
+
* 检查是否有重复的 ID
|
|
54
|
+
*/
|
|
55
|
+
export declare function validatePersonaActionTypes(persona: Persona): {
|
|
56
|
+
isValid: boolean;
|
|
57
|
+
errors: string[];
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=persona.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona.d.ts","sourceRoot":"","sources":["../../src/types/persona.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,mBAAmB;IACnB,EAAE,EAAE,SAAS,CAAC;IAEd,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IAEb,SAAS;IACT,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,WAAW,EAAE,cAAc,EAAE,CAAC;IAE9B,WAAW;IACX,SAAS,EAAE,IAAI,CAAC;IAEhB,WAAW;IACX,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAE5B;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAuBA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persona 数据结构定义
|
|
3
|
+
* Persona 代表一个人格/角色,为 Schedule 提供上下文和能力
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 根据动作类型 ID 查找动作类型
|
|
7
|
+
*/
|
|
8
|
+
export function findActionType(persona, actionTypeId) {
|
|
9
|
+
return persona.actionTypes.find(at => at.id === actionTypeId);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 验证 Persona 的动作类型是否有效
|
|
13
|
+
* 检查是否有重复的 ID
|
|
14
|
+
*/
|
|
15
|
+
export function validatePersonaActionTypes(persona) {
|
|
16
|
+
const errors = [];
|
|
17
|
+
const idSet = new Set();
|
|
18
|
+
for (const actionType of persona.actionTypes) {
|
|
19
|
+
if (idSet.has(actionType.id)) {
|
|
20
|
+
errors.push(`重复的动作类型 ID: ${actionType.id}`);
|
|
21
|
+
}
|
|
22
|
+
idSet.add(actionType.id);
|
|
23
|
+
// 验证必填字段
|
|
24
|
+
if (!actionType.name) {
|
|
25
|
+
errors.push(`动作类型 ${actionType.id} 缺少名称`);
|
|
26
|
+
}
|
|
27
|
+
if (!actionType.executionType) {
|
|
28
|
+
errors.push(`动作类型 ${actionType.id} 缺少执行类型`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
isValid: errors.length === 0,
|
|
33
|
+
errors,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=persona.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona.js","sourceRoot":"","sources":["../../src/types/persona.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqDH;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,YAAoB;IAEpB,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAgB;IAIzD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QAC7C,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,eAAe,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAEzB,SAAS;QACT,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,QAAQ,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,QAAQ,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM;KACP,CAAC;AACJ,CAAC"}
|