@ai-setting/roy-agent-core 1.5.13-test → 1.5.15-test

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.
Files changed (141) hide show
  1. package/package.json +1 -1
  2. package/dist/config/index.d.ts +0 -1250
  3. package/dist/config/index.js +0 -32
  4. package/dist/env/agent/index.d.ts +0 -2279
  5. package/dist/env/agent/index.js +0 -24
  6. package/dist/env/commands/index.d.ts +0 -1131
  7. package/dist/env/commands/index.js +0 -14
  8. package/dist/env/debug/formatters/index.d.ts +0 -236
  9. package/dist/env/debug/formatters/index.js +0 -11
  10. package/dist/env/debug/index.d.ts +0 -1652
  11. package/dist/env/debug/index.js +0 -26
  12. package/dist/env/hook/index.d.ts +0 -279
  13. package/dist/env/hook/index.js +0 -29
  14. package/dist/env/index.d.ts +0 -3481
  15. package/dist/env/index.js +0 -82
  16. package/dist/env/llm/index.d.ts +0 -1760
  17. package/dist/env/llm/index.js +0 -40
  18. package/dist/env/log-trace/index.d.ts +0 -1574
  19. package/dist/env/log-trace/index.js +0 -83
  20. package/dist/env/mcp/index.d.ts +0 -1331
  21. package/dist/env/mcp/index.js +0 -39
  22. package/dist/env/mcp/tool/index.d.ts +0 -183
  23. package/dist/env/mcp/tool/index.js +0 -14
  24. package/dist/env/memory/built-in/index.d.ts +0 -232
  25. package/dist/env/memory/built-in/index.js +0 -11
  26. package/dist/env/memory/index.d.ts +0 -1799
  27. package/dist/env/memory/index.js +0 -56
  28. package/dist/env/memory/plugin/index.d.ts +0 -747
  29. package/dist/env/memory/plugin/index.js +0 -36
  30. package/dist/env/prompt/index.d.ts +0 -1164
  31. package/dist/env/prompt/index.js +0 -20
  32. package/dist/env/session/index.d.ts +0 -1908
  33. package/dist/env/session/index.js +0 -25
  34. package/dist/env/session/storage/index.d.ts +0 -564
  35. package/dist/env/session/storage/index.js +0 -18
  36. package/dist/env/skill/index.d.ts +0 -1266
  37. package/dist/env/skill/index.js +0 -34
  38. package/dist/env/skill/tool/index.d.ts +0 -193
  39. package/dist/env/skill/tool/index.js +0 -9
  40. package/dist/env/task/delegate/index.d.ts +0 -1612
  41. package/dist/env/task/delegate/index.js +0 -18
  42. package/dist/env/task/events/index.d.ts +0 -171
  43. package/dist/env/task/events/index.js +0 -7
  44. package/dist/env/task/hooks/index.d.ts +0 -624
  45. package/dist/env/task/hooks/index.js +0 -7
  46. package/dist/env/task/index.d.ts +0 -1553
  47. package/dist/env/task/index.js +0 -34
  48. package/dist/env/task/plugins/index.d.ts +0 -466
  49. package/dist/env/task/plugins/index.js +0 -23
  50. package/dist/env/task/storage/index.d.ts +0 -241
  51. package/dist/env/task/storage/index.js +0 -14
  52. package/dist/env/task/tools/index.d.ts +0 -1485
  53. package/dist/env/task/tools/index.js +0 -17
  54. package/dist/env/task/tools/operation/index.d.ts +0 -1484
  55. package/dist/env/task/tools/operation/index.js +0 -15
  56. package/dist/env/tool/built-in/index.d.ts +0 -218
  57. package/dist/env/tool/built-in/index.js +0 -25
  58. package/dist/env/tool/index.d.ts +0 -1396
  59. package/dist/env/tool/index.js +0 -39
  60. package/dist/env/workflow/decorators/index.d.ts +0 -2161
  61. package/dist/env/workflow/decorators/index.js +0 -27
  62. package/dist/env/workflow/engine/index.d.ts +0 -3453
  63. package/dist/env/workflow/engine/index.js +0 -28
  64. package/dist/env/workflow/index.d.ts +0 -3546
  65. package/dist/env/workflow/index.js +0 -136
  66. package/dist/env/workflow/nodes/index.d.ts +0 -2092
  67. package/dist/env/workflow/nodes/index.js +0 -19
  68. package/dist/env/workflow/service/index.d.ts +0 -227
  69. package/dist/env/workflow/service/index.js +0 -13
  70. package/dist/env/workflow/storage/index.d.ts +0 -165
  71. package/dist/env/workflow/storage/index.js +0 -27
  72. package/dist/env/workflow/tools/index.d.ts +0 -416
  73. package/dist/env/workflow/tools/index.js +0 -159
  74. package/dist/env/workflow/types/index.d.ts +0 -2255
  75. package/dist/env/workflow/types/index.js +0 -98
  76. package/dist/env/workflow/utils/index.d.ts +0 -2031
  77. package/dist/env/workflow/utils/index.js +0 -637
  78. package/dist/index.d.ts +0 -7858
  79. package/dist/index.js +0 -399
  80. package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
  81. package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
  82. package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
  83. package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
  84. package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
  85. package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
  86. package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
  87. package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
  88. package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
  89. package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
  90. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  91. package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
  92. package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
  93. package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
  94. package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
  95. package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
  96. package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
  97. package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
  98. package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
  99. package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
  100. package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
  101. package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
  102. package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
  103. package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
  104. package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
  105. package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
  106. package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
  107. package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
  108. package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
  109. package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
  110. package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
  111. package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
  112. package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
  113. package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
  114. package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
  115. package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
  116. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  117. package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
  118. package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
  119. package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
  120. package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
  121. package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
  122. package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
  123. package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
  124. package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
  125. package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
  126. package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
  127. package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
  128. package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
  129. package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
  130. package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
  131. package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
  132. package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
  133. package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
  134. package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
  135. package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
  136. package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
  137. package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
  138. package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
  139. package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
  140. package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
  141. package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
@@ -1,416 +0,0 @@
1
- import { z as z5 } from "zod";
2
- import { z as z4 } from "zod";
3
- import { z as z2, ZodType, ZodError } from "zod";
4
- /**
5
- * 沙箱配置
6
- */
7
- interface SandboxConfig {
8
- /** 是否启用沙箱 */
9
- enabled: boolean;
10
- /** 沙箱类型 */
11
- type: "native" | "docker";
12
- /** 动作过滤 */
13
- actionFilter?: {
14
- /** 包含的动作 */
15
- include?: string[];
16
- /** 排除的动作 */
17
- exclude?: string[];
18
- };
19
- /** 文件系统限制 */
20
- filesystem?: {
21
- /** 允许读取 */
22
- allowRead?: string[];
23
- /** 禁止读取 */
24
- denyRead?: string[];
25
- /** 允许写入 */
26
- allowWrite?: string[];
27
- /** 禁止写入 */
28
- denyWrite?: string[];
29
- };
30
- /** 网络限制 */
31
- network?: {
32
- /** 允许的域名 */
33
- allowedDomains?: string[];
34
- /** 禁止的域名 */
35
- deniedDomains?: string[];
36
- };
37
- /** Docker 配置 */
38
- docker?: {
39
- /** 镜像 */
40
- image?: string;
41
- /** 网络模式 */
42
- networkMode?: "bridge" | "host" | "none";
43
- /** 卷挂载 */
44
- volumes?: Record<string, string>;
45
- };
46
- }
47
- /**
48
- * 工具执行上下文
49
- */
50
- interface ToolContext {
51
- /** 工作目录 */
52
- workdir?: string;
53
- /** 用户 ID */
54
- user_id?: string;
55
- /** 会话 ID */
56
- session_id?: string;
57
- /** 消息 ID */
58
- message_id?: string;
59
- /** 中断信号 */
60
- abort?: AbortSignal;
61
- /** 额外元数据 */
62
- metadata?: Record<string, unknown>;
63
- /** 沙箱配置 */
64
- sandbox?: SandboxConfig;
65
- /** 沙箱 Provider */
66
- sandboxProvider?: unknown | null;
67
- }
68
- /**
69
- * 工具结果元数据
70
- */
71
- interface ToolResultMetadata {
72
- /** 执行时间(毫秒) */
73
- execution_time_ms: number;
74
- /** 输出大小(字节) */
75
- output_size?: number;
76
- /** 标准输出 */
77
- stdout?: string;
78
- /** 标准错误 */
79
- stderr?: string;
80
- /** 退出码 */
81
- exit_code?: number;
82
- /** Token 使用量 */
83
- usage?: {
84
- inputTokens: number;
85
- outputTokens: number;
86
- totalTokens?: number;
87
- };
88
- /** 额外元数据 */
89
- [key: string]: unknown;
90
- }
91
- /**
92
- * 工具执行结果
93
- */
94
- interface ToolResult2 {
95
- /** 是否成功 */
96
- success: boolean;
97
- /** 输出内容 */
98
- output: string | Record<string, unknown>;
99
- /** 错误信息 */
100
- error?: string;
101
- /** 结果元数据 */
102
- metadata?: ToolResultMetadata;
103
- }
104
- /**
105
- * 工具元数据
106
- */
107
- interface ToolMetadata {
108
- /** 分类 */
109
- category?: string;
110
- /** 标签 */
111
- tags?: string[];
112
- /** 版本 */
113
- version?: string;
114
- /** 作者 */
115
- author?: string;
116
- /** 是否实验性 */
117
- experimental?: boolean;
118
- /** MCP 工具信息(MCP adapter 使用) */
119
- mcpTool?: {
120
- originalName: string;
121
- originalDescription: string;
122
- inputSchema?: unknown;
123
- };
124
- }
125
- /**
126
- * 工具沙箱配置
127
- */
128
- interface ToolSandboxConfig {
129
- /** 是否启用沙箱 */
130
- enabled: boolean;
131
- /** 沙箱配置 */
132
- config?: Partial<SandboxConfig>;
133
- }
134
- /**
135
- * 工具权限配置
136
- */
137
- interface ToolPermissionConfig {
138
- /** 是否需要用户确认 */
139
- requireConfirmation?: boolean;
140
- /** 权限级别 */
141
- level?: "safe" | "dangerous" | "critical";
142
- }
143
- /**
144
- * 工具信息
145
- */
146
- interface ToolInfo<Parameters extends ZodType = ZodType> {
147
- /** 工具名称 */
148
- name: string;
149
- /** 工具描述 */
150
- description: string;
151
- /** 参数 Schema */
152
- parameters: Parameters;
153
- /** 初始化函数(可选) */
154
- init?: (ctx?: ToolContext) => Promise<void>;
155
- /** 执行函数 */
156
- execute: (args: z2.infer<Parameters>, ctx: ToolContext) => Promise<ToolResult2>;
157
- /** 参数验证错误格式化(可选) */
158
- formatValidationError?: (error: ZodError) => string;
159
- /** 沙箱配置 */
160
- sandbox?: ToolSandboxConfig;
161
- /** 权限配置 */
162
- permission?: ToolPermissionConfig;
163
- /** 工具元数据 */
164
- metadata?: ToolMetadata;
165
- }
166
- /**
167
- * 工具类型别名
168
- */
169
- type Tool = ToolInfo;
170
- declare const RunStatusSchema: unknown;
171
- type RunStatus = z4.infer<typeof RunStatusSchema>;
172
- interface RunOptions {
173
- input?: Record<string, any>;
174
- debug?: boolean;
175
- parallelLimit?: number | null;
176
- timeout?: number | null;
177
- /** @deprecated No-op: workflow always waits for completion */
178
- sync?: boolean;
179
- }
180
- interface RunResult {
181
- runId: string;
182
- /** Session ID (workflow_{runId} format) - useful for CLI resume */
183
- sessionId?: string;
184
- status: RunStatus;
185
- output?: Record<string, any>;
186
- error?: string;
187
- durationMs?: number;
188
- /** Pending node ID (when status is 'paused') */
189
- pendingNodeId?: string;
190
- /** Query from ask_user (when status is 'paused') */
191
- query?: string;
192
- /** Agent sub-session ID (for resuming agent nodes) */
193
- agentSessionId?: string;
194
- }
195
- declare const NodeDefinitionSchema: unknown;
196
- type NodeDefinition = z5.infer<typeof NodeDefinitionSchema>;
197
- declare const WorkflowConfigSchema: unknown;
198
- type WorkflowConfig = z5.infer<typeof WorkflowConfigSchema>;
199
- declare const WorkflowMetadataSchema: unknown;
200
- type WorkflowMetadata = z5.infer<typeof WorkflowMetadataSchema>;
201
- declare const WorkflowDefinitionSchema: unknown;
202
- type WorkflowDefinition = z5.infer<typeof WorkflowDefinitionSchema>;
203
- interface Workflow {
204
- id: string;
205
- name: string;
206
- version: string;
207
- description?: string;
208
- definition: WorkflowDefinition;
209
- config: WorkflowConfig;
210
- metadata: WorkflowMetadata;
211
- tags: string[];
212
- createdAt: Date;
213
- updatedAt: Date;
214
- }
215
- import { z as z7 } from "zod";
216
- interface WorkflowRepository {
217
- create(workflow: Omit<Workflow, "id" | "createdAt" | "updatedAt">): Workflow;
218
- getById(id: string): Workflow | null;
219
- getByName(name: string): Workflow | null;
220
- list(options?: ListOptions): Workflow[];
221
- update(id: string, updates: Partial<Workflow>): Workflow | null;
222
- delete(id: string): boolean;
223
- }
224
- interface CreateOptions {
225
- tags?: string[];
226
- metadata?: WorkflowMetadata;
227
- taskId?: number;
228
- force?: boolean;
229
- }
230
- interface ListOptions {
231
- tag?: string;
232
- taskId?: number;
233
- search?: string;
234
- limit?: number;
235
- offset?: number;
236
- }
237
- interface WorkflowUpdates {
238
- definition?: WorkflowDefinition;
239
- config?: WorkflowConfig;
240
- tags?: string[];
241
- metadata?: WorkflowMetadata;
242
- }
243
- interface WorkflowEngine {
244
- createSession(workflowId: string, options?: {
245
- input?: Record<string, any>;
246
- workflowName?: string;
247
- workflowVersion?: string;
248
- }): Promise<string>;
249
- run(sessionId: string, options?: RunOptions): Promise<RunResult>;
250
- runWorkflow(workflow: Workflow | WorkflowDefinition, options?: RunOptions): Promise<RunResult>;
251
- stop(sessionId: string, reason?: string): Promise<void>;
252
- addNode(sessionId: string, nodeDefinition: NodeDefinition): Promise<void>;
253
- removeNode(sessionId: string, nodeId: string): Promise<void>;
254
- }
255
- type WorkflowEngineFactory = (workflow: Workflow, options?: RunOptions) => Pick<WorkflowEngine, "run" | "stop" | "runWorkflow">;
256
- interface SessionInfo {
257
- id: string;
258
- title: string;
259
- metadata: WorkflowSessionMetadata3;
260
- createdAt: Date;
261
- updatedAt: Date;
262
- }
263
- interface WorkflowSessionMetadata3 {
264
- type: "workflow";
265
- runId?: string;
266
- workflowId?: string;
267
- workflowName: string;
268
- workflowVersion?: string;
269
- status: "running" | "paused" | "completed" | "failed";
270
- input?: any;
271
- rootNodeId?: string;
272
- agentSessions?: AgentSessionRef3[];
273
- }
274
- interface AgentSessionRef3 {
275
- nodeId: string;
276
- sessionId: string;
277
- status: "active" | "paused" | "completed";
278
- }
279
- declare class WorkflowService {
280
- private workflowRepository;
281
- private engineFactory;
282
- private sessionComponent?;
283
- constructor(workflowRepository: WorkflowRepository, engineFactory: WorkflowEngineFactory, sessionComponent?: {
284
- create(options: {
285
- id?: string;
286
- title: string;
287
- metadata: any;
288
- }): Promise<{
289
- id: string;
290
- }>;
291
- get(id: string): Promise<SessionInfo | null | undefined>;
292
- list?(options?: {
293
- limit?: number;
294
- offset?: number;
295
- }): Promise<SessionInfo[]>;
296
- update(id: string, updates: {
297
- metadata?: any;
298
- }): Promise<boolean>;
299
- addMessage(sessionId: string, message: any): Promise<string>;
300
- getMessages(sessionId: string): Promise<any[]>;
301
- } | undefined);
302
- /**
303
- * Create a new workflow from definition
304
- */
305
- createWorkflow(definition: WorkflowDefinition, options?: CreateOptions): Promise<Workflow>;
306
- /**
307
- * Get workflow by id or name
308
- */
309
- getWorkflow(idOrName: string): Workflow | null;
310
- /**
311
- * Get workflow by id
312
- */
313
- getWorkflowById(id: string): Workflow | null;
314
- /**
315
- * Get workflow by name
316
- */
317
- getWorkflowByName(name: string): Workflow | null;
318
- /**
319
- * List workflows with optional filters
320
- */
321
- listWorkflows(options?: ListOptions): Workflow[];
322
- /**
323
- * Update an existing workflow
324
- */
325
- updateWorkflow(idOrName: string, updates: WorkflowUpdates, options?: {
326
- tags?: string[];
327
- }): Promise<Workflow>;
328
- /**
329
- * Delete a workflow by name or id
330
- */
331
- deleteWorkflow(idOrName: string): Promise<boolean>;
332
- /**
333
- * Run a workflow by definition or name
334
- *
335
- * This creates a Session that represents the workflow run.
336
- * The Session ID is used as the run identifier for pause/resume.
337
- */
338
- runWorkflow(idOrNameOrDefinition: string | WorkflowDefinition, input?: Record<string, any>, options?: RunOptions): Promise<RunResult>;
339
- /**
340
- * Run workflow by name (convenience method)
341
- */
342
- runWorkflowByName(name: string, input?: Record<string, any>, options?: RunOptions): Promise<RunResult>;
343
- /**
344
- * Stop a running workflow session
345
- */
346
- stopRun(sessionId: string, reason?: string): Promise<void>;
347
- /**
348
- * Get workflow session by ID
349
- */
350
- getSession(sessionId: string): Promise<SessionInfo | null>;
351
- /**
352
- * List workflow sessions
353
- */
354
- listSessions(options?: {
355
- limit?: number;
356
- offset?: number;
357
- }): Promise<SessionInfo[]>;
358
- /**
359
- * Get messages from a workflow session
360
- */
361
- getSessionMessages(sessionId: string): Promise<any[]>;
362
- }
363
- /**
364
- * Input schema for run-workflow tool
365
- */
366
- declare const RunWorkflowInputSchema: unknown;
367
- type RunWorkflowInput = z7.infer<typeof RunWorkflowInputSchema>;
368
- /**
369
- * Run Workflow Tool interface for type-safe access
370
- */
371
- interface RunWorkflowToolInterface {
372
- name: "run-workflow";
373
- description: string;
374
- inputSchema: typeof RunWorkflowInputSchema;
375
- }
376
- /**
377
- * Create a run-workflow tool with the given WorkflowService
378
- *
379
- * @param workflowService - The WorkflowService instance for executing workflows
380
- * @returns A Tool instance for running workflows
381
- */
382
- declare function createRunWorkflowTool(workflowService: WorkflowService): Tool;
383
- /**
384
- * Initialize the run-workflow tool with a WorkflowService
385
- *
386
- * @param workflowService - The WorkflowService instance
387
- */
388
- declare function initRunWorkflowTool(workflowService: WorkflowService): void;
389
- /**
390
- * Get the run-workflow tool instance
391
- *
392
- * @throws Error if the tool has not been initialized
393
- */
394
- declare function getRunWorkflowTool(): Tool;
395
- /**
396
- * Reset the run-workflow tool (for testing)
397
- */
398
- declare function resetRunWorkflowTool(): void;
399
- type RunWorkflowTool = ReturnType<typeof createRunWorkflowTool>;
400
- import { z as z8 } from "zod";
401
- /**
402
- * AskUserTool input schema
403
- */
404
- declare const AskUserInputSchema: unknown;
405
- type AskUserInput = z8.infer<typeof AskUserInputSchema>;
406
- /**
407
- * AskUserTool
408
- *
409
- * A special tool that can be called by Agent to request user input.
410
- * Calling this tool will throw AskUserError, which the Executor will
411
- * catch and convert to a workflow pause event.
412
- */
413
- type AskUserTool = ToolInfo<typeof AskUserInputSchema>;
414
- declare const askUserTool: AskUserTool;
415
- declare const askUserToolInstance: unknown;
416
- export { resetRunWorkflowTool, initRunWorkflowTool, getRunWorkflowTool, createRunWorkflowTool, askUserToolInstance, askUserTool, RunWorkflowToolInterface, RunWorkflowTool, RunWorkflowInputSchema, RunWorkflowInput, AskUserTool, AskUserInputSchema, AskUserInput };
@@ -1,159 +0,0 @@
1
- import {
2
- AskUserInputSchema,
3
- askUserTool,
4
- askUserToolInstance
5
- } from "../../../shared/@ai-setting/roy-agent-core-0vbdz0x7.js";
6
- import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
7
- import {
8
- createLogger,
9
- init_logger
10
- } from "../../../shared/@ai-setting/roy-agent-core-44hnfb02.js";
11
- import"../../../shared/@ai-setting/roy-agent-core-xs5rsgat.js";
12
- import"../../../shared/@ai-setting/roy-agent-core-psv4v63c.js";
13
- import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
14
-
15
- // src/env/workflow/tools/run-workflow.ts
16
- init_logger();
17
- import { z } from "zod";
18
- var logger = createLogger("run-workflow-tool");
19
- var RunWorkflowInputSchema = z.object({
20
- workflow_name: z.string().describe("Name of the workflow to run"),
21
- input: z.record(z.any()).optional().describe("Input to pass to the workflow"),
22
- sync: z.boolean().default(true).describe("Wait for completion (default: true)"),
23
- timeout: z.number().positive().optional().describe("Timeout in milliseconds")
24
- });
25
- function createRunWorkflowTool(workflowService) {
26
- return {
27
- name: "run-workflow",
28
- description: "Run a workflow by name with optional input. Returns run_id, status, output, error, and duration_ms.",
29
- parameters: RunWorkflowInputSchema,
30
- sandbox: {
31
- enabled: false
32
- },
33
- permission: {
34
- level: "safe"
35
- },
36
- metadata: {
37
- category: "workflow",
38
- tags: ["workflow", "execute", "run"],
39
- version: "1.0.0",
40
- experimental: false
41
- },
42
- execute: async (args, ctx) => {
43
- const startTime = Date.now();
44
- const { workflow_name, input, sync = true, timeout } = args;
45
- logger.info(`Running workflow: ${workflow_name}`, { input, sync, timeout });
46
- let timeoutHandle;
47
- let durationMs;
48
- try {
49
- let result;
50
- if (timeout) {
51
- result = await Promise.race([
52
- workflowService.runWorkflow(workflow_name, input, { sync }),
53
- new Promise((_, reject) => {
54
- timeoutHandle = setTimeout(() => {
55
- reject(new Error("Workflow execution timed out"));
56
- }, timeout);
57
- })
58
- ]);
59
- } else {
60
- result = await workflowService.runWorkflow(workflow_name, input, { sync });
61
- }
62
- if (timeoutHandle) {
63
- clearTimeout(timeoutHandle);
64
- }
65
- durationMs = Date.now() - startTime;
66
- if (sync) {
67
- return {
68
- success: result.status === "completed",
69
- output: {
70
- run_id: result.runId,
71
- status: result.status,
72
- output: result.output,
73
- error: result.error,
74
- duration_ms: result.durationMs || durationMs
75
- },
76
- metadata: {
77
- execution_time_ms: durationMs
78
- }
79
- };
80
- } else {
81
- return {
82
- success: true,
83
- output: {
84
- run_id: result.runId,
85
- status: result.status,
86
- duration_ms: durationMs
87
- },
88
- metadata: {
89
- execution_time_ms: durationMs
90
- }
91
- };
92
- }
93
- } catch (error) {
94
- if (timeoutHandle) {
95
- clearTimeout(timeoutHandle);
96
- }
97
- durationMs = Date.now() - startTime;
98
- const errorMessage = error instanceof Error ? error.message : String(error);
99
- if (errorMessage.includes("Workflow not found")) {
100
- return {
101
- success: false,
102
- output: "",
103
- error: `Workflow not found: ${workflow_name}`,
104
- metadata: {
105
- execution_time_ms: durationMs
106
- }
107
- };
108
- }
109
- if (errorMessage.includes("abort") || errorMessage.includes("timed out")) {
110
- return {
111
- success: false,
112
- output: "",
113
- error: `Workflow execution timed out or was aborted: ${workflow_name}`,
114
- metadata: {
115
- execution_time_ms: durationMs
116
- }
117
- };
118
- }
119
- if (logger?.error) {
120
- logger.error(`Failed to run workflow: ${workflow_name}`, { error: errorMessage });
121
- }
122
- return {
123
- success: false,
124
- output: "",
125
- error: `Failed to run workflow ${workflow_name}: ${errorMessage}`,
126
- metadata: {
127
- execution_time_ms: durationMs
128
- }
129
- };
130
- }
131
- }
132
- };
133
- }
134
- var _runWorkflowTool = null;
135
- var _workflowService = null;
136
- function initRunWorkflowTool(workflowService) {
137
- _workflowService = workflowService;
138
- _runWorkflowTool = createRunWorkflowTool(workflowService);
139
- }
140
- function getRunWorkflowTool() {
141
- if (!_runWorkflowTool || !_workflowService) {
142
- throw new Error("run-workflow tool not initialized. Call initRunWorkflowTool(workflowService) first.");
143
- }
144
- return _runWorkflowTool;
145
- }
146
- function resetRunWorkflowTool() {
147
- _runWorkflowTool = null;
148
- _workflowService = null;
149
- }
150
- export {
151
- resetRunWorkflowTool,
152
- initRunWorkflowTool,
153
- getRunWorkflowTool,
154
- createRunWorkflowTool,
155
- askUserToolInstance,
156
- askUserTool,
157
- RunWorkflowInputSchema,
158
- AskUserInputSchema
159
- };